mirror of
https://github.com/moltbot/moltbot.git
synced 2026-04-29 09:41:08 +00:00
refactor: dedupe tlon monitor record helper
This commit is contained in:
@@ -1,14 +1,10 @@
|
||||
import type { RuntimeEnv } from "../../api.js";
|
||||
import { extractCites, extractMessageText, type ParsedCite } from "./utils.js";
|
||||
import { asRecord, extractCites, extractMessageText, type ParsedCite } from "./utils.js";
|
||||
|
||||
type TlonScryApi = {
|
||||
scry: (path: string) => Promise<unknown>;
|
||||
};
|
||||
|
||||
function asRecord(value: unknown): Record<string, unknown> | null {
|
||||
return value && typeof value === "object" ? (value as Record<string, unknown>) : null;
|
||||
}
|
||||
|
||||
export function createTlonCitationResolver(params: { api: TlonScryApi; runtime: RuntimeEnv }) {
|
||||
const { api, runtime } = params;
|
||||
|
||||
|
||||
@@ -1,10 +1,6 @@
|
||||
import type { RuntimeEnv } from "../../api.js";
|
||||
import type { Foreigns } from "../urbit/foreigns.js";
|
||||
import { formatChangesDate } from "./utils.js";
|
||||
|
||||
function asRecord(value: unknown): Record<string, unknown> | null {
|
||||
return value && typeof value === "object" ? (value as Record<string, unknown>) : null;
|
||||
}
|
||||
import { asRecord, formatChangesDate } from "./utils.js";
|
||||
|
||||
function formatErrorMessage(error: unknown): string {
|
||||
return error instanceof Error ? error.message : String(error);
|
||||
|
||||
@@ -1,9 +1,5 @@
|
||||
import type { RuntimeEnv } from "../../api.js";
|
||||
import { extractMessageText } from "./utils.js";
|
||||
|
||||
function asRecord(value: unknown): Record<string, unknown> | null {
|
||||
return value && typeof value === "object" ? (value as Record<string, unknown>) : null;
|
||||
}
|
||||
import { asRecord, extractMessageText } from "./utils.js";
|
||||
|
||||
function formatErrorMessage(error: unknown): string {
|
||||
return error instanceof Error ? error.message : String(error);
|
||||
|
||||
@@ -28,6 +28,7 @@ import {
|
||||
mergeUniqueStrings,
|
||||
shouldMigrateTlonSetting,
|
||||
} from "./settings-helpers.js";
|
||||
import { asRecord } from "./utils.js";
|
||||
import {
|
||||
extractMessageText,
|
||||
formatModelName,
|
||||
@@ -45,10 +46,6 @@ export type MonitorTlonOpts = {
|
||||
accountId?: string | null;
|
||||
};
|
||||
|
||||
function asRecord(value: unknown): Record<string, unknown> | null {
|
||||
return value && typeof value === "object" ? (value as Record<string, unknown>) : null;
|
||||
}
|
||||
|
||||
function readString(record: Record<string, unknown> | null, key: string): string | undefined {
|
||||
const value = record?.[key];
|
||||
return typeof value === "string" ? value : undefined;
|
||||
|
||||
@@ -181,7 +181,7 @@ export async function resolveAuthorizedMessageText(params: {
|
||||
return citedContent + rawText;
|
||||
}
|
||||
|
||||
function asRecord(value: unknown): Record<string, unknown> | null {
|
||||
export function asRecord(value: unknown): Record<string, unknown> | null {
|
||||
return value && typeof value === "object" ? (value as Record<string, unknown>) : null;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user