style: apply oxfmt formatting to new/modified files

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
Apple 2026-01-28 02:11:55 +05:30
parent e9babf40aa
commit 9d75e6dc9c
4 changed files with 43 additions and 21 deletions

View File

@ -40,10 +40,7 @@ export function createAccountBase<TAccountConfig extends Record<string, unknown>
return ids[0] ?? DEFAULT_ACCOUNT_ID; return ids[0] ?? DEFAULT_ACCOUNT_ID;
} }
function resolveAccountConfig( function resolveAccountConfig(cfg: MoltbotConfig, accountId: string): TAccountConfig | undefined {
cfg: MoltbotConfig,
accountId: string,
): TAccountConfig | undefined {
const accounts = getChannelSection(cfg)?.accounts; const accounts = getChannelSection(cfg)?.accounts;
if (!accounts || typeof accounts !== "object") return undefined; if (!accounts || typeof accounts !== "object") return undefined;
return accounts[accountId] as TAccountConfig | undefined; return accounts[accountId] as TAccountConfig | undefined;

View File

@ -156,9 +156,7 @@ describe("full pipeline: inbound -> routing -> agent -> reply", () => {
it("returns an error reply when the agent throws", async () => { it("returns an error reply when the agent throws", async () => {
await withTempHome(async (home) => { await withTempHome(async (home) => {
vi.mocked(runEmbeddedPiAgent).mockRejectedValue( vi.mocked(runEmbeddedPiAgent).mockRejectedValue(new Error("model rate limit exceeded"));
new Error("model rate limit exceeded"),
);
const cfg = makeCfg(home); const cfg = makeCfg(home);

View File

@ -181,7 +181,16 @@ function resolveDiscordGuildEntry(guilds: DiscordConfig["guilds"], groupSpace?:
} }
function resolveDiscordChannelEntry( function resolveDiscordChannelEntry(
channelEntries: Record<string, { requireMention?: boolean; tools?: GroupToolPolicyConfig; toolsBySender?: GroupToolPolicyBySenderConfig }> | undefined, channelEntries:
| Record<
string,
{
requireMention?: boolean;
tools?: GroupToolPolicyConfig;
toolsBySender?: GroupToolPolicyBySenderConfig;
}
>
| undefined,
params: GroupMentionParams, params: GroupMentionParams,
) { ) {
if (!channelEntries || Object.keys(channelEntries).length === 0) return undefined; if (!channelEntries || Object.keys(channelEntries).length === 0) return undefined;

View File

@ -730,7 +730,9 @@ export class MemoryIndexManager {
} catch (err) { } catch (err) {
try { try {
this.db.exec("ROLLBACK"); this.db.exec("ROLLBACK");
} catch { /* expected: db may already be closed */ } } catch {
/* expected: db may already be closed */
}
throw err; throw err;
} }
} }
@ -1046,14 +1048,18 @@ export class MemoryIndexManager {
`DELETE FROM ${VECTOR_TABLE} WHERE id IN (SELECT id FROM chunks WHERE path = ? AND source = ?)`, `DELETE FROM ${VECTOR_TABLE} WHERE id IN (SELECT id FROM chunks WHERE path = ? AND source = ?)`,
) )
.run(stale.path, "memory"); .run(stale.path, "memory");
} catch (err) { logSwallowed("memory:syncMemory:vector", err); } } catch (err) {
logSwallowed("memory:syncMemory:vector", err);
}
this.db.prepare(`DELETE FROM chunks WHERE path = ? AND source = ?`).run(stale.path, "memory"); this.db.prepare(`DELETE FROM chunks WHERE path = ? AND source = ?`).run(stale.path, "memory");
if (this.fts.enabled && this.fts.available) { if (this.fts.enabled && this.fts.available) {
try { try {
this.db this.db
.prepare(`DELETE FROM ${FTS_TABLE} WHERE path = ? AND source = ? AND model = ?`) .prepare(`DELETE FROM ${FTS_TABLE} WHERE path = ? AND source = ? AND model = ?`)
.run(stale.path, "memory", this.provider.model); .run(stale.path, "memory", this.provider.model);
} catch (err) { logSwallowed("memory:syncMemory:fts", err); } } catch (err) {
logSwallowed("memory:syncMemory:fts", err);
}
} }
} }
} }
@ -1143,7 +1149,9 @@ export class MemoryIndexManager {
`DELETE FROM ${VECTOR_TABLE} WHERE id IN (SELECT id FROM chunks WHERE path = ? AND source = ?)`, `DELETE FROM ${VECTOR_TABLE} WHERE id IN (SELECT id FROM chunks WHERE path = ? AND source = ?)`,
) )
.run(stale.path, "sessions"); .run(stale.path, "sessions");
} catch (err) { logSwallowed("memory:syncSessions:vector", err); } } catch (err) {
logSwallowed("memory:syncSessions:vector", err);
}
this.db this.db
.prepare(`DELETE FROM chunks WHERE path = ? AND source = ?`) .prepare(`DELETE FROM chunks WHERE path = ? AND source = ?`)
.run(stale.path, "sessions"); .run(stale.path, "sessions");
@ -1152,7 +1160,9 @@ export class MemoryIndexManager {
this.db this.db
.prepare(`DELETE FROM ${FTS_TABLE} WHERE path = ? AND source = ? AND model = ?`) .prepare(`DELETE FROM ${FTS_TABLE} WHERE path = ? AND source = ? AND model = ?`)
.run(stale.path, "sessions", this.provider.model); .run(stale.path, "sessions", this.provider.model);
} catch (err) { logSwallowed("memory:syncSessions:fts", err); } } catch (err) {
logSwallowed("memory:syncSessions:fts", err);
}
} }
} }
this.pruneSessionMaps(activePaths); this.pruneSessionMaps(activePaths);
@ -1406,7 +1416,9 @@ export class MemoryIndexManager {
} catch (err) { } catch (err) {
try { try {
this.db.close(); this.db.close();
} catch { /* expected: db may already be closed */ } } catch {
/* expected: db may already be closed */
}
await this.removeIndexFiles(tempDbPath); await this.removeIndexFiles(tempDbPath);
restoreOriginalState(); restoreOriginalState();
throw err; throw err;
@ -1419,7 +1431,9 @@ export class MemoryIndexManager {
if (this.fts.enabled && this.fts.available) { if (this.fts.enabled && this.fts.available) {
try { try {
this.db.exec(`DELETE FROM ${FTS_TABLE}`); this.db.exec(`DELETE FROM ${FTS_TABLE}`);
} catch (err) { logSwallowed("memory:resetIndex:fts", err); } } catch (err) {
logSwallowed("memory:resetIndex:fts", err);
}
} }
this.dropVectorTable(); this.dropVectorTable();
this.vector.dims = undefined; this.vector.dims = undefined;
@ -1631,9 +1645,7 @@ export class MemoryIndexManager {
private pruneExpiredCacheEntries(): void { private pruneExpiredCacheEntries(): void {
if (!this.cache.enabled) return; if (!this.cache.enabled) return;
const cutoffMs = Date.now() - EMBEDDING_CACHE_TTL_MS; const cutoffMs = Date.now() - EMBEDDING_CACHE_TTL_MS;
this.db this.db.prepare(`DELETE FROM ${EMBEDDING_CACHE_TABLE} WHERE updated_at < ?`).run(cutoffMs);
.prepare(`DELETE FROM ${EMBEDDING_CACHE_TABLE} WHERE updated_at < ?`)
.run(cutoffMs);
} }
private pruneEmbeddingCacheIfNeeded(): void { private pruneEmbeddingCacheIfNeeded(): void {
@ -2123,14 +2135,18 @@ export class MemoryIndexManager {
`DELETE FROM ${VECTOR_TABLE} WHERE id IN (SELECT id FROM chunks WHERE path = ? AND source = ?)`, `DELETE FROM ${VECTOR_TABLE} WHERE id IN (SELECT id FROM chunks WHERE path = ? AND source = ?)`,
) )
.run(entry.path, options.source); .run(entry.path, options.source);
} catch (err) { logSwallowed("memory:indexFile:vector", err); } } catch (err) {
logSwallowed("memory:indexFile:vector", err);
}
} }
if (this.fts.enabled && this.fts.available) { if (this.fts.enabled && this.fts.available) {
try { try {
this.db this.db
.prepare(`DELETE FROM ${FTS_TABLE} WHERE path = ? AND source = ? AND model = ?`) .prepare(`DELETE FROM ${FTS_TABLE} WHERE path = ? AND source = ? AND model = ?`)
.run(entry.path, options.source, this.provider.model); .run(entry.path, options.source, this.provider.model);
} catch (err) { logSwallowed("memory:indexFile:fts", err); } } catch (err) {
logSwallowed("memory:indexFile:fts", err);
}
} }
this.db this.db
.prepare(`DELETE FROM chunks WHERE path = ? AND source = ?`) .prepare(`DELETE FROM chunks WHERE path = ? AND source = ?`)
@ -2167,7 +2183,9 @@ export class MemoryIndexManager {
if (vectorReady && embedding.length > 0) { if (vectorReady && embedding.length > 0) {
try { try {
this.db.prepare(`DELETE FROM ${VECTOR_TABLE} WHERE id = ?`).run(id); this.db.prepare(`DELETE FROM ${VECTOR_TABLE} WHERE id = ?`).run(id);
} catch (err) { logSwallowed("memory:indexFile:vectorRow", err); } } catch (err) {
logSwallowed("memory:indexFile:vectorRow", err);
}
this.db this.db
.prepare(`INSERT INTO ${VECTOR_TABLE} (id, embedding) VALUES (?, ?)`) .prepare(`INSERT INTO ${VECTOR_TABLE} (id, embedding) VALUES (?, ?)`)
.run(id, vectorToBlob(embedding)); .run(id, vectorToBlob(embedding));