Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 15 additions & 3 deletions src/mcp/resources.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,11 @@ function registerHealthResource(server: McpServer, deps: ResourceDependencies):
},
async (): Promise<ReadResourceResult> => {
const memoryHealth = deps.memory
? await deps.memory.healthCheck().catch(() => ({ qdrant: false, ollama: false }))
? await deps.memory.healthCheck().catch((err: unknown) => {
const msg = err instanceof Error ? err.message : String(err);
console.warn(`[mcp] health resource memory check failed: ${msg}`);
return { qdrant: false, ollama: false };
})
: { qdrant: false, ollama: false };

const uptimeSeconds = Math.floor((Date.now() - deps.startedAt) / 1000);
Expand Down Expand Up @@ -284,7 +288,11 @@ function registerMemoryRecentResource(server: McpServer, deps: ResourceDependenc
};
}

const episodes = await deps.memory.recallEpisodes("recent activity", { limit: 10 }).catch(() => []);
const episodes = await deps.memory.recallEpisodes("recent activity", { limit: 10 }).catch((err: unknown) => {
const msg = err instanceof Error ? err.message : String(err);
console.warn(`[mcp] memory-recent recallEpisodes failed: ${msg}`);
return [];
});
return {
contents: [
{
Expand Down Expand Up @@ -318,7 +326,11 @@ function registerMemoryDomainResource(server: McpServer, deps: ResourceDependenc
return { contents: [{ uri: uri.href, text: JSON.stringify({ facts: [], available: false }) }] };
}

const facts = await deps.memory.recallFacts(topic as string, { limit: 20 }).catch(() => []);
const facts = await deps.memory.recallFacts(topic as string, { limit: 20 }).catch((err: unknown) => {
const msg = err instanceof Error ? err.message : String(err);
console.warn(`[mcp] memory-domain recallFacts failed: ${msg}`);
return [];
});
return {
contents: [
{
Expand Down
15 changes: 9 additions & 6 deletions src/mcp/tools-swe.ts
Original file line number Diff line number Diff line change
Expand Up @@ -56,8 +56,9 @@ function registerCodebaseQuery(server: McpServer, deps: ToolDependencies): void
timestamp: e.started_at,
}));
}
} catch {
// Memory unavailable, continue without it
} catch (err: unknown) {
const msg = err instanceof Error ? err.message : String(err);
console.warn(`[mcp] codebase_query recallEpisodes failed: ${msg}`);
}

try {
Expand All @@ -68,8 +69,9 @@ function registerCodebaseQuery(server: McpServer, deps: ToolDependencies): void
confidence: f.confidence,
}));
}
} catch {
// Memory unavailable, continue without it
} catch (err: unknown) {
const msg = err instanceof Error ? err.message : String(err);
console.warn(`[mcp] codebase_query recallFacts failed: ${msg}`);
}
}

Expand Down Expand Up @@ -280,8 +282,9 @@ function registerRepoInfo(server: McpServer, deps: ToolDependencies): void {
fact: f.natural_language,
}));
}
} catch {
// Continue without memory
} catch (err: unknown) {
const msg = err instanceof Error ? err.message : String(err);
console.warn(`[mcp] repo_info recallFacts failed: ${msg}`);
}
}

Expand Down
18 changes: 15 additions & 3 deletions src/mcp/tools-universal.ts
Original file line number Diff line number Diff line change
Expand Up @@ -257,7 +257,11 @@ async function searchMemoryCore(
const results: Record<string, unknown[]> = {};

if (options.memoryType === "all" || options.memoryType === "episodic") {
const episodes = await deps.memory.recallEpisodes(options.query, { limit: options.limit }).catch(() => []);
const episodes = await deps.memory.recallEpisodes(options.query, { limit: options.limit }).catch((err: unknown) => {
const msg = err instanceof Error ? err.message : String(err);
console.warn(`[mcp] memory_search recallEpisodes failed: ${msg}`);
return [];
});
const daysBack = options.daysBack;
if (daysBack != null && daysBack > 0) {
const cutoff = Date.now() - daysBack * 24 * 60 * 60 * 1000;
Expand All @@ -273,10 +277,18 @@ async function searchMemoryCore(
}
}
if (options.memoryType === "all" || options.memoryType === "semantic") {
results.facts = await deps.memory.recallFacts(options.query, { limit: options.limit }).catch(() => []);
results.facts = await deps.memory.recallFacts(options.query, { limit: options.limit }).catch((err: unknown) => {
const msg = err instanceof Error ? err.message : String(err);
console.warn(`[mcp] memory_search recallFacts failed: ${msg}`);
return [];
});
}
if (options.memoryType === "all" || options.memoryType === "procedural") {
const proc = await deps.memory.findProcedure(options.query).catch(() => null);
const proc = await deps.memory.findProcedure(options.query).catch((err: unknown) => {
const msg = err instanceof Error ? err.message : String(err);
console.warn(`[mcp] memory_search findProcedure failed: ${msg}`);
return null;
});
results.procedures = proc ? [proc] : [];
}

Expand Down
11 changes: 8 additions & 3 deletions src/onboarding/profiler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -51,17 +51,22 @@ export type SlackProfileClient = {
* All API calls are best-effort - failures degrade gracefully to null fields.
*/
export async function profileOwner(client: SlackProfileClient, ownerUserId: string): Promise<OwnerProfile> {
const logWarn = (api: string) => (err: unknown) => {
const msg = err instanceof Error ? err.message : String(err);
console.warn(`[onboarding] Slack ${api} failed for ${ownerUserId}: ${msg}`);
return null;
};
const [userResult, teamResult, channelsResult] = await Promise.all([
client.users.info({ user: ownerUserId }).catch(() => null),
client.team.info().catch(() => null),
client.users.info({ user: ownerUserId }).catch(logWarn("users.info")),
client.team.info().catch(logWarn("team.info")),
client.users
.conversations({
user: ownerUserId,
types: "public_channel",
exclude_archived: true,
limit: 100,
})
.catch(() => null),
.catch(logWarn("users.conversations")),
]);

const user = userResult?.user;
Expand Down
4 changes: 3 additions & 1 deletion src/persona/llm-caller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,9 @@ export function parseEnvelope(text: string): LlmTurnResult {
let parsed: unknown;
try {
parsed = JSON.parse(json);
} catch {
} catch (err: unknown) {
const msg = err instanceof Error ? err.message : String(err);
console.warn(`[first-hour] envelope JSON parse failed: ${msg}`);
return {
pulls_executed: [],
saved_drafts: [],
Expand Down
4 changes: 3 additions & 1 deletion src/plugins/curated.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,9 @@ export function loadCuratedOverlay(pathOverride?: string): CuratedOverlay {
let mtimeMs: number;
try {
mtimeMs = statSync(path).mtimeMs;
} catch {
} catch (err: unknown) {
const msg = err instanceof Error ? err.message : String(err);
console.warn(`[plugins] curated overlay stat failed (${path}): ${msg}`);
return DEFAULT_OVERLAY;
}

Expand Down
4 changes: 3 additions & 1 deletion src/scheduler/parse-with-sonnet.ts
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,9 @@ export async function parseJobDescription(description: string, deps: ParseDeps =
const parsed = JobCreateInputSchema.safeParse(result.data);
if (!parsed.success) return { ok: false, status: 422, error: GENERIC_ERROR };
return { ok: true, proposal: parsed.data, warnings: [] };
} catch {
} catch (err: unknown) {
const detail = err instanceof Error ? err.message : String(err);
console.warn(`[scheduler] Sonnet parse failed: ${detail}`);
return { ok: false, status: 422, error: GENERIC_ERROR };
}
}
4 changes: 3 additions & 1 deletion src/scheduler/schedule.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,9 @@ export function computeNextRunAt(schedule: Schedule, afterMs: number = Date.now(
try {
const cron = new Cron(schedule.expr, { timezone: tz, mode: "5-part" });
return cron.nextRun(new Date(afterMs));
} catch {
} catch (err: unknown) {
const msg = err instanceof Error ? err.message : String(err);
console.warn(`[scheduler] Invalid cron "${schedule.expr}" (tz=${tz}): ${msg}`);
return null;
}
}
Expand Down
5 changes: 4 additions & 1 deletion src/scheduler/service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -321,7 +321,10 @@ export class Scheduler {
for (const cb of this.jobCompleteCallbacks) {
try {
cb(name, status);
} catch {}
} catch (err: unknown) {
const msg = err instanceof Error ? err.message : String(err);
console.warn(`[scheduler] Job-complete callback error for "${name}": ${msg}`);
}
}
}

Expand Down
4 changes: 3 additions & 1 deletion src/secrets/crypto.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,9 @@ export function getEncryptionKey(): Buffer {
}
cachedKey = buf;
return cachedKey;
} catch {
} catch (err: unknown) {
const detail = err instanceof Error ? err.message : String(err);
console.warn(`[secrets] Could not load encryption key from ${keyPath}: ${detail}. Generating new key.`);
const key = randomBytes(KEY_LENGTH);
const dir = dirname(keyPath);
if (!existsSync(dir)) {
Expand Down
8 changes: 6 additions & 2 deletions src/skills/storage.ts
Original file line number Diff line number Diff line change
Expand Up @@ -238,7 +238,9 @@ export function writeSkill(input: WriteInput, options: { mustExist: boolean }):
} else {
previousBody = prevRaw;
}
} catch {
} catch (err: unknown) {
const msg = err instanceof Error ? err.message : String(err);
console.warn(`[skills] Failed to read previous skill content for ${name}: ${msg}`);
previousBody = null;
}
} else if (options.mustExist) {
Expand Down Expand Up @@ -287,7 +289,9 @@ export function deleteSkill(name: string): DeleteResult {
const prevRaw = readFileSync(file, "utf-8");
const prevParsed = parseFrontmatter(prevRaw);
previousBody = prevParsed.ok ? prevParsed.parsed.body : prevRaw;
} catch {
} catch (err: unknown) {
const msg = err instanceof Error ? err.message : String(err);
console.warn(`[skills] Failed to read previous skill content for ${name}: ${msg}`);
previousBody = null;
}
try {
Expand Down
8 changes: 6 additions & 2 deletions src/subagents/storage.ts
Original file line number Diff line number Diff line change
Expand Up @@ -217,7 +217,9 @@ export function writeSubagent(input: WriteInput, options: { mustExist: boolean }
} else {
previousBody = prevRaw;
}
} catch {
} catch (err: unknown) {
const msg = err instanceof Error ? err.message : String(err);
console.warn(`[subagents] Failed to read previous content for ${name}: ${msg}`);
previousBody = null;
}
} else if (options.mustExist) {
Expand Down Expand Up @@ -263,7 +265,9 @@ export function deleteSubagent(name: string): DeleteResult {
const prevRaw = readFileSync(file, "utf-8");
const prevParsed = parseFrontmatter(prevRaw);
previousBody = prevParsed.ok ? prevParsed.parsed.body : prevRaw;
} catch {
} catch (err: unknown) {
const msg = err instanceof Error ? err.message : String(err);
console.warn(`[subagents] Failed to read previous content for ${name}: ${msg}`);
previousBody = null;
}
try {
Expand Down
12 changes: 9 additions & 3 deletions src/ui/api/evolution.ts
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,9 @@ function buildOverview(deps: EvolutionApiDeps): OverviewResponse {
if (deps.queue) {
try {
poisonCount = deps.queue.listPoisonPile().length;
} catch {
} catch (err: unknown) {
const msg = err instanceof Error ? err.message : String(err);
console.warn(`[evolution] Failed to read poison pile: ${msg}`);
poisonCount = 0;
}
}
Expand Down Expand Up @@ -207,15 +209,19 @@ function readFilePreview(configDir: string, relPath: string): { content: string;
let size = 0;
try {
size = statSync(absolute).size;
} catch {
} catch (err: unknown) {
const msg = err instanceof Error ? err.message : String(err);
console.warn(`[evolution] stat failed for ${relPath}: ${msg}`);
size = 0;
}
try {
const raw = readFileSync(absolute);
const cap = FILE_PREVIEW_BYTE_CAP;
const sliced = raw.length <= cap ? raw : raw.subarray(0, cap);
return { content: sliced.toString("utf-8"), size };
} catch {
} catch (err: unknown) {
const msg = err instanceof Error ? err.message : String(err);
console.warn(`[evolution] read failed for ${relPath}: ${msg}`);
return { content: "", size };
}
}
Expand Down
24 changes: 19 additions & 5 deletions src/ui/api/identity.ts
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,9 @@ function readMetaSync(): AvatarMeta | null {
const parsed = JSON.parse(text) as AvatarMeta;
if (!parsed || typeof parsed.ext !== "string" || typeof parsed.mime !== "string") return null;
return parsed;
} catch {
} catch (err: unknown) {
const msg = err instanceof Error ? err.message : String(err);
console.warn(`[identity] Failed to read avatar meta: ${msg}`);
return null;
}
}
Expand Down Expand Up @@ -173,7 +175,10 @@ export async function handleAvatarPost(req: Request): Promise<Response> {
} catch (err: unknown) {
try {
if (existsSync(tmpFile)) unlinkSync(tmpFile);
} catch {}
} catch (cleanupErr: unknown) {
const cleanupMsg = cleanupErr instanceof Error ? cleanupErr.message : String(cleanupErr);
console.warn(`[identity] Failed to clean up tmp avatar file: ${cleanupMsg}`);
}
const msg = err instanceof Error ? err.message : String(err);
return errJson(`Avatar write failed: ${msg}`, 500);
}
Expand All @@ -184,7 +189,10 @@ export async function handleAvatarPost(req: Request): Promise<Response> {
} catch (err: unknown) {
try {
if (existsSync(tmpMeta)) unlinkSync(tmpMeta);
} catch {}
} catch (cleanupErr: unknown) {
const cleanupMsg = cleanupErr instanceof Error ? cleanupErr.message : String(cleanupErr);
console.warn(`[identity] Failed to clean up tmp meta file: ${cleanupMsg}`);
}
const msg = err instanceof Error ? err.message : String(err);
return errJson(`Avatar meta write failed: ${msg}`, 500);
}
Expand All @@ -196,7 +204,10 @@ export async function handleAvatarPost(req: Request): Promise<Response> {
if (entry.endsWith(".tmp")) continue;
try {
unlinkSync(resolve(dir, entry));
} catch {}
} catch (err: unknown) {
const msg = err instanceof Error ? err.message : String(err);
console.warn(`[identity] Failed to prune old avatar ${entry}: ${msg}`);
}
}

return Response.json({ ok: true, url: "/ui/avatar", size: bytes.byteLength, mime });
Expand All @@ -209,7 +220,10 @@ export function handleAvatarDelete(): Response {
if (!entry.startsWith("avatar.")) continue;
try {
unlinkSync(resolve(dir, entry));
} catch {}
} catch (err: unknown) {
const msg = err instanceof Error ? err.message : String(err);
console.warn(`[identity] Failed to delete avatar file ${entry}: ${msg}`);
}
}
return new Response(null, { status: 204 });
}
Expand Down
5 changes: 4 additions & 1 deletion src/ui/api/pages.ts
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,10 @@ async function extractTitle(absolutePath: string, rel: string): Promise<string>
return decoded.slice(0, MAX_TITLE_LEN);
}
}
} catch {}
} catch (err: unknown) {
const msg = err instanceof Error ? err.message : String(err);
console.warn(`[pages] Failed to extract title from ${rel}: ${msg}`);
}
return filenameTitle(rel).slice(0, MAX_TITLE_LEN);
}

Expand Down
Loading