Orkas is an open-source (MIT), local-first AI team for your desktop: a Commander turns your goal into to-dos and coordinates 16 built-in specialist agents plus Claude Code, Codex, OpenCode, OpenClaw and Hermes, with projects, scheduled automations and connectors. Free app for macOS & Windows; built-in models or your own keys.
JavaScript agent-collaborationagent-harnessagent-orchestrationagent-teamagent-workflowai-assistantai-automationai-employeeai-productivityai-teamai-workflowautonomous-agentsclaude-code-guiclaude-coworkdesktop-agentlocal-firstmulti-agentmulti-agent-systemself-evolving-agentstask-automation
Bound local application failure diagnostics
wyt1c19bcc94484
diff --git a/src/main/features/web_apps/runtime.ts b/src/main/features/web_apps/runtime.tsindex 52f8921b..0a14aad5 100644--- a/src/main/features/web_apps/runtime.ts+++ b/src/main/features/web_apps/runtime.ts@@ -11,6 +11,7 @@ import { isPathAllowed } from '../../util/path-sandbox';import { MAX_TEXT_FILE_BYTES } from '../../util/file-size-limits';import { LocalAppData } from './data';import {createLogger} from '../../logger';+import { logErrorSummary } from '../../util/log-redact';import { commonMethod, type AppType, type DataDefinition } from './data-contract';import { RequestHistory } from './request-history';import { requireLocalAppType } from './commercial-entry';@@ -78,6 +79,27 @@ interface ParsedStore { signature: string; owner: string; bytes: number; entriesconst storeSignature = (st: { dev: number; ino: number; size: number; mtimeMs: number; ctimeMs: number }) =>`${st.dev}:${st.ino}:${st.size}:${st.mtimeMs}:${st.ctimeMs}`;const error = (code: string): never => { throw new AppError(code); };+const callLog = createLogger('web-app-runtime');+const CALL_FAILURE_WINDOW_MS = 60_000;+const CALL_FAILURE_MAX_KEYS = 64;+const callFailures = new Map<string, { at: number; suppressed: number }>();+/** One warning per catalog method + code per minute, with the suppressed+ * count carried forward. Unexpected non-AppError causes keep only a redacted+ * summary; app arguments, results, paths, and identities are never logged. */+function logCallFailure(method: string, code: string, cause: unknown): void {+ try {+ const key = `${method}\0${code}`, now = Date.now();+ const seen = callFailures.get(key);+ if (seen && now - seen.at < CALL_FAILURE_WINDOW_MS) { seen.suppressed++; return; }+ if (!seen && callFailures.size >= CALL_FAILURE_MAX_KEYS) {+ for (const [old, entry] of callFailures) if (now - entry.at >= CALL_FAILURE_WINDOW_MS) callFailures.delete(old);+ if (callFailures.size >= CALL_FAILURE_MAX_KEYS) return;+ }+ callFailures.set(key, { at: now, suppressed: 0 });+ callLog.warn('web app call failed', { method, code, suppressed_count: seen?.suppressed || 0,+ ...(cause instanceof AppError ? {} : { error: logErrorSummary(cause) }) });+ } catch { /* Diagnostics are best effort. */ }+}const liveRuntimes=new Set<WeakRef<WebAppRuntime>>();const heldAppData=new Set<string>();export function holdAppData(uid:string,key:string){const identity=JSON.stringify([uid,key]);if(heldAppData.has(identity))throw new AppError('E_BUSY');heldAppData.add(identity);return ()=>heldAppData.delete(identity);}@@ -317,6 +339,17 @@ export class WebAppRuntime {async call(uid: string, owner: number, token: string, requestId: string, method: string, raw: unknown,progress: (event: unknown) => void = () => {}) {const s = this.current(uid, owner, token);+ try { return await this.dispatch(s, requestId, method, raw, progress); }+ catch (cause) {+ const code = cause instanceof AppError ? cause.code : 'E_FAILED';+ if (code !== 'E_CANCELLED' && code !== 'E_CLOSED') {+ logCallFailure(Object.hasOwn(METHODS, method) ? method : 'unknown', code, cause);+ }+ throw cause;+ }+ }+ private async dispatch(s: Instance, requestId: string, method: string, raw: unknown,+ progress: (event: unknown) => void) {if (s.bundle.browserOnly) return error('E_UNAVAILABLE');if (!/^[a-zA-Z0-9_-]{1,64}$/.test(requestId)) return error('E_INPUT');if (s.seen.has(requestId)) return error('E_DUPLICATE');diff --git a/test/main/features/web_apps.test.ts b/test/main/features/web_apps.test.tsindex 2d54cb7a..93a0a1b9 100644--- a/test/main/features/web_apps.test.ts+++ b/test/main/features/web_apps.test.ts@@ -335,6 +335,31 @@ describe('Web app capability journeys', () => {expect(host.closed).toHaveBeenCalledTimes(2);expect(host.closed).toHaveBeenLastCalledWith(uid, { id: b.token, owner: 1 });});+ it('logs one redacted warning per method and code per minute and nothing for cancellation', async () => {+ const warn = vi.fn();+ vi.doMock('../../../src/main/logger', async (original) => ({ ...(await original<any>()),+ createLogger: () => ({ warn, info: vi.fn(), error: vi.fn(), debug: vi.fn() }) }));+ try {+ vi.resetModules();+ const logged = await import('../../../src/main/features/web_apps/runtime');+ const rt = new logged.WebAppRuntime(host);+ const a = rt.open(uid, 1, bundle());+ host.generate = async () => { throw new Error('/Users/test/private provider body'); };+ for (let i = 0; i < 3; i += 1) {+ await expect(rt.call(uid, 1, a.token, `fail-${i}`, 'ai.generate', { prompt: 'secret prompt' })).rejects.toThrow();+ }+ await expect(rt.call(uid, 1, a.token, 'tool', 'tools.call', { name: 'bash', arguments: {} })).rejects.toMatchObject({ code: 'E_TOOL' });+ host.generate = async () => { throw new logged.AppError('E_CANCELLED'); };+ await expect(rt.call(uid, 1, a.token, 'cancelled', 'ai.generate', { prompt: 'x' })).rejects.toMatchObject({ code: 'E_CANCELLED' });+ const rows = warn.mock.calls.filter(([message]) => message === 'web app call failed');+ expect(rows).toEqual([+ ['web app call failed', { method: 'ai.generate', code: 'E_FAILED', suppressed_count: 0, error: expect.objectContaining({ message_hash: expect.any(String) }) }],+ ['web app call failed', { method: 'tools.call', code: 'E_TOOL', suppressed_count: 0 }],+ ]);+ expect(JSON.stringify(warn.mock.calls)).not.toMatch(/alice|secret prompt|provider body/);+ rt.closeOwner(1);+ } finally { vi.doUnmock('../../../src/main/logger'); }+ });it('delivers streaming progress and usage without an app-specific output default', async () => {const a=open(), progress=vi.fn(); host.generate=vi.fn(async(_uid,_args,_signal,out)=>{out({type:'delta',text:'Hi'});return {text:'Hi',usage:{outputTokens:1},stopReason:'end_turn'};});expect(await runtime.call(uid,1,a.token,'model','ai.generate',{prompt:'Hello'},progress)).toMatchObject({text:'Hi',usage:{outputTokens:1}});