@1agents/acp-service 0.8.0 → 0.8.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +5 -0
- package/dist/bin/acp-service.js +0 -0
- package/dist/src/a2a/executor.js +34 -9
- package/dist/src/a2a/index.d.ts +1 -0
- package/dist/src/a2a/index.js +1 -0
- package/dist/src/a2a/lease.d.ts +13 -0
- package/dist/src/a2a/lease.js +149 -0
- package/dist/src/a2a/request-id.d.ts +2 -0
- package/dist/src/a2a/request-id.js +6 -0
- package/dist/src/a2a/server.js +13 -1
- package/dist/src/a2a/store.d.ts +4 -6
- package/dist/src/a2a/store.js +14 -114
- package/dist/src/a2a/types.d.ts +9 -0
- package/dist/src/acp-connection.d.ts +2 -1
- package/dist/src/acp-connection.js +52 -9
- package/dist/src/bridge.js +38 -39
- package/package.json +3 -2
- package/vendor/dsh/README.md +12 -2
- package/vendor/dsh/a2a-executor.d.ts +7 -1
- package/vendor/dsh/a2a-executor.js +56 -15
- package/vendor/dsh/a2a.d.ts +2 -1
- package/vendor/dsh/a2a.js +9 -5
- package/vendor/dsh/adapter.d.ts +3 -1
- package/vendor/dsh/adapter.js +144 -16
- package/vendor/dsh/diagnostics.d.ts +42 -0
- package/vendor/dsh/diagnostics.js +176 -0
- package/vendor/dsh/index.d.ts +1 -0
- package/vendor/dsh/index.js +16 -4
- package/vendor/runtime/dist/{cli-DUHyAADv.js → cli-Bdzplbpj.js} +4 -4
- package/vendor/runtime/dist/{cli-DUHyAADv.js.map → cli-Bdzplbpj.js.map} +1 -1
- package/vendor/runtime/dist/cli.d.ts +1 -1
- package/vendor/runtime/dist/cli.js +8 -8
- package/vendor/runtime/dist/{client-DjkWknf7.d.ts → client-BXOiB0ND.d.ts} +2 -2
- package/vendor/runtime/dist/{client-DjkWknf7.d.ts.map → client-BXOiB0ND.d.ts.map} +1 -1
- package/vendor/runtime/dist/{flows-CiJSCy4D.js → flows-BKlAuzM8.js} +4 -4
- package/vendor/runtime/dist/{flows-CiJSCy4D.js.map → flows-BKlAuzM8.js.map} +1 -1
- package/vendor/runtime/dist/flows.d.ts +2 -2
- package/vendor/runtime/dist/flows.js +1 -1
- package/vendor/runtime/dist/{invocation-options-BlIySxIw.js → invocation-options-DMy77sEU.js} +4 -4
- package/vendor/runtime/dist/{invocation-options-BlIySxIw.js.map → invocation-options-DMy77sEU.js.map} +1 -1
- package/vendor/runtime/dist/{ipc-BlljKR2b.js → ipc-CLv2iL89.js} +260 -2
- package/vendor/runtime/dist/ipc-CLv2iL89.js.map +1 -0
- package/vendor/runtime/dist/{output-BzXQKArM.js → output-I-t-v55D.js} +3 -3
- package/vendor/runtime/dist/{output-BzXQKArM.js.map → output-I-t-v55D.js.map} +1 -1
- package/vendor/runtime/dist/{queue-owner-runtime-DSFdsS_y.js → queue-owner-runtime-RN3uSid0.js} +2 -2
- package/vendor/runtime/dist/{queue-owner-runtime-DSFdsS_y.js.map → queue-owner-runtime-RN3uSid0.js.map} +1 -1
- package/vendor/runtime/dist/runtime.d.ts +25 -15
- package/vendor/runtime/dist/runtime.d.ts.map +1 -1
- package/vendor/runtime/dist/runtime.js +57 -37
- package/vendor/runtime/dist/runtime.js.map +1 -1
- package/vendor/runtime/dist/{session-options-ORCchZGk.d.ts → session-options-DNnDfiUt.d.ts} +18 -2
- package/vendor/runtime/dist/session-options-DNnDfiUt.d.ts.map +1 -0
- package/vendor/runtime/dist/{session-watch-BiBTBMz4.js → session-watch-CmHbH0jS.js} +4 -4
- package/vendor/runtime/dist/{session-watch-BiBTBMz4.js.map → session-watch-CmHbH0jS.js.map} +1 -1
- package/vendor/runtime/dist/{watch-iYiP-lOo.js → watch-BE-kKa7o.js} +2 -2
- package/vendor/runtime/dist/{watch-iYiP-lOo.js.map → watch-BE-kKa7o.js.map} +1 -1
- package/vendor/runtime/skills/acpx/SKILL.md +1 -0
- package/vendor/runtime/dist/ipc-BlljKR2b.js.map +0 -1
- package/vendor/runtime/dist/session-options-ORCchZGk.d.ts.map +0 -1
|
@@ -117,6 +117,22 @@ type PermissionEscalationEvent = {
|
|
|
117
117
|
};
|
|
118
118
|
type AcpJsonRpcMessage = AnyMessage;
|
|
119
119
|
type AcpMessageDirection = "outbound" | "inbound";
|
|
120
|
+
declare const OUTPUT_ERROR_ORIGINS: readonly ["cli", "runtime", "queue", "acp"];
|
|
121
|
+
type OutputErrorOrigin = (typeof OUTPUT_ERROR_ORIGINS)[number];
|
|
122
|
+
type SafeErrorCategory = "quota" | "rate_limit" | "budget" | "auth" | "cancelled" | "timeout" | "permission" | "unknown";
|
|
123
|
+
type SafeErrorOrigin = OutputErrorOrigin | "service" | "transport" | "dsh" | "a2a";
|
|
124
|
+
/** A bounded public error projection; never includes provider messages or raw data. */
|
|
125
|
+
type SafeError = {
|
|
126
|
+
message: string;
|
|
127
|
+
category: SafeErrorCategory;
|
|
128
|
+
providerCode?: string;
|
|
129
|
+
retryable: boolean;
|
|
130
|
+
outcomeUnknown: boolean;
|
|
131
|
+
origin: SafeErrorOrigin;
|
|
132
|
+
operationId?: string;
|
|
133
|
+
code?: string;
|
|
134
|
+
detailCode?: string;
|
|
135
|
+
};
|
|
120
136
|
type PermissionStats = {
|
|
121
137
|
requested: number;
|
|
122
138
|
approved: number;
|
|
@@ -422,5 +438,5 @@ type SessionAgentOptions = {
|
|
|
422
438
|
env?: Record<string, string>;
|
|
423
439
|
};
|
|
424
440
|
//#endregion
|
|
425
|
-
export {
|
|
426
|
-
//# sourceMappingURL=session-options-
|
|
441
|
+
export { GrokExitPlanModeRequest as A, PermissionPolicy as C, SafeErrorOrigin as D, SafeErrorCategory as E, GrokAskUserQuestionResponse as F, GrokExitPlanOutcome as M, GrokAskUserAnswers as N, SessionRecord as O, GrokAskUserQuestionRequest as P, PermissionMode as S, SafeError as T, AcpProcessSpawnFailure as _, AcpElicitationHandler as a, McpServer$1 as b, AcpElicitationResponse as c, AcpPermissionHandler as d, AcpPermissionRequest as f, AcpProcessLifecycle as g, AcpProcessLaunchScope as h, AcpElicitationContext as i, GrokExitPlanModeResponse as j, PromptInput as k, AcpJsonRpcMessage as l, AcpProcessLaunch as m, SystemPromptOption as n, AcpElicitationMode as o, AcpProcessExit as p, AcpClientOptions as r, AcpElicitationRequest as s, SessionAgentOptions as t, AcpPermissionDecision as u, AcpProcessStarted as v, PermissionStats as w, NonInteractivePermissionPolicy as x, AuthPolicy as y };
|
|
442
|
+
//# sourceMappingURL=session-options-DNnDfiUt.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"session-options-DNnDfiUt.d.ts","names":[],"sources":["../src/acp/grok-ask-user.ts","../src/acp/grok-exit-plan.ts","../src/prompt-content.ts","../src/types.ts","../src/runtime/engine/session-options.ts"],"mappings":";;KAYY;EACV;EACA;EACA;;KAGU;EACV;EACA,SAAS;;EAET;;KAGU;EACV;EACA;EACA,WAAW;EACX;;;KAIU;KAEA,qBAAqB,eAAe;KAEpC;EAEN;EACA,SAAS;EACT;;EAEA;;EACA;;EACA;;;;KC7BM;EACV;EACA;EACA;;KAGU;KAEA;EACV,SAAS;EACT;;;;KCxBU,cAAc;;;KC0Bd;EACV;EACA,KAAK;EACL,cAAc;;KAGJ;EACN;;EACA;;EACA;;EACA;;EACA;;KAEM,wBACV,SAAS,sBACT;EAAW,QAAQ;MAChB,QAAQ;cAEA;KACD,6BAA6B;KAC7B,wBAAwB;KAExB;;EAEV,WAAW;;EAEX,QAAQ;;KAGL;EACH,QAAQ;;KAGE;EAEN;EACA,UAAU,eAAe;IACvB;EACD;IAAsB;EACtB;IAAqB;KAEhB,yBACV,SAAS,uBACT,SAAS,0BACN,QAAQ;cAiBA;KACD,yBAAyB;cAExB;KACD,qBAAqB;cAEpB;KACD,yCAAyC;cAExC;KACD,iCAAiC;KAEjC;EACV;EACA;EACA;EACA,gBAAgB;;KAGN;EACV;EACA;EACA;EACA;EACA;EACA;EACA,WAAW;EACX;EACA;EACA;EACA;;KAQU,oBAAoB;KACpB;cAaC;KAC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ACA;;EAEA;;EAEA,YAAY;IAAQ;IAAc;;;KAGxB;EAEN;;EAGA,OAAO;;KAGD;EACV;EACA;EACA;EACA,SAAS;EACT;;KAGU;EAEN;;EAGA;IACE;IACA;;;EAIF;;EAGA,SAAS;;KAGH;EACV;EACA,SAAS;;KAGC;EACV,SAAS;EACT,cAAc,eAAe;EAC7B;;KAGU;EAEN,MAAM;;EAGN,OAAO;;KAID;EACV;EACA;EACA;EACA;EACA;EACA;;KAGU;EACV;EACA;;KAGU;EACV;EACA;EACA;;KAYU;EACV;EACA;EACA;EACA;EACA;EACA;EACA;;KAGU;EACV;EACA;EACA;EACA,yBAAyB;EACzB;EACA;EACA,wBAAwB;EACxB;EACA,qBAAqB;EACrB,iBAAiB;EACjB;IACE;IACA;IACA;IACA;MAA2B;;IAC3B,MAAM;;EAER,eAAe,eAAe;;KAGpB;EACV;EACA;EACA;EACA;;KAGU;EACV,eAAe;EACf;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA,UAAU;EACV;EACA;EACA;EACA;EACA;EACA;EACA,sBAAsB,OAAO;EAC7B;EACA;EACA;EACA,oBAAoB;EACpB;EACA,UAAU;EACV;EACA,wBAAwB;EACxB,kBAAkB;EAClB,qBAAqB,eAAe;EACpC,OAAO;EACP,eAAe;;;;KCxjBL;EAAgC;;KAEhC;EACV;EACA;EACA;EACA,eAAe;EAKf,aAAa;;;;;;;;;;EAUb,MAAM"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { i as JsonMessageSanitizer, t as createOutputFormatter } from "./output-
|
|
2
|
-
import { ct as parsePromptStopReason, rt as isAcpJsonRpcMessage } from "./ipc-
|
|
3
|
-
import { t as watchSession } from "./watch-
|
|
1
|
+
import { i as JsonMessageSanitizer, t as createOutputFormatter } from "./output-I-t-v55D.js";
|
|
2
|
+
import { ct as parsePromptStopReason, rt as isAcpJsonRpcMessage } from "./ipc-CLv2iL89.js";
|
|
3
|
+
import { t as watchSession } from "./watch-BE-kKa7o.js";
|
|
4
4
|
import { once } from "node:events";
|
|
5
5
|
//#region src/cli/session-watch.ts
|
|
6
6
|
function watchRenderer(policy) {
|
|
@@ -73,4 +73,4 @@ async function runSessionWatch(record, options) {
|
|
|
73
73
|
//#endregion
|
|
74
74
|
export { runSessionWatch };
|
|
75
75
|
|
|
76
|
-
//# sourceMappingURL=session-watch-
|
|
76
|
+
//# sourceMappingURL=session-watch-CmHbH0jS.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"session-watch-
|
|
1
|
+
{"version":3,"file":"session-watch-CmHbH0jS.js","names":[],"sources":["../src/cli/session-watch.ts"],"sourcesContent":["import { once } from \"node:events\";\nimport { isAcpJsonRpcMessage, parsePromptStopReason } from \"../acp/jsonrpc.js\";\nimport type { SessionWatchEvent } from \"../session/journal.js\";\nimport { watchSession } from \"../session/watch.js\";\nimport type { OutputFormatter, OutputPolicy, SessionRecord } from \"../types.js\";\nimport { JsonMessageSanitizer } from \"./output/json-formatter.js\";\nimport { createOutputFormatter } from \"./output/output.js\";\n\nfunction watchRenderer(policy: OutputPolicy): (event: SessionWatchEvent) => string[] {\n const chunks: string[] = [];\n const stdout = {\n write: (chunk: string) => {\n chunks.push(chunk);\n },\n };\n let sanitizer = new JsonMessageSanitizer(policy.suppressReads, true);\n let formatter = createOutputFormatter(policy.format, { stdout });\n return (event) => {\n chunks.length = 0;\n if (event.type === \"turn_started\") {\n sanitizer = new JsonMessageSanitizer(policy.suppressReads, true);\n formatter = createOutputFormatter(policy.format, { stdout });\n }\n if (policy.format === \"json\") {\n chunks.push(\n JSON.stringify(\n event.type === \"message\"\n ? { ...event, message: sanitizer.sanitize(event.message) }\n : event,\n ) + \"\\n\",\n );\n } else if (event.type === \"message\") {\n renderWatchMessage(event, sanitizer, formatter, policy.format === \"quiet\");\n } else {\n if (event.type === \"turn_result\") {\n formatter.flush();\n }\n if (policy.format !== \"quiet\") {\n chunks.push(watchLifecycleLine(event));\n }\n }\n return chunks;\n };\n}\n\nfunction renderWatchMessage(\n event: Extract<SessionWatchEvent, { type: \"message\" }>,\n sanitizer: JsonMessageSanitizer,\n formatter: OutputFormatter,\n quiet: boolean,\n): void {\n const message = sanitizer.sanitize(event.message);\n if (!isAcpJsonRpcMessage(message)) {\n throw new Error(\"Invalid sanitized session message\");\n }\n if (quiet || parsePromptStopReason(message) === undefined) {\n formatter.onAcpMessage(message);\n }\n}\n\nfunction watchLifecycleLine(event: Exclude<SessionWatchEvent, { type: \"message\" }>): string {\n if (event.type === \"turn_started\") {\n return `\\n[${event.requestId}] started cursor=${event.cursor}\\n`;\n }\n const detail =\n event.result.status === \"failed\" ? event.result.error.message : event.result.stopReason;\n return `\\n[${event.requestId}] ${event.result.status}${detail ? `: ${detail}` : \"\"} cursor=${event.cursor}\\n`;\n}\n\nexport async function runSessionWatch(\n record: SessionRecord,\n options: { cursor?: string; policy: OutputPolicy },\n): Promise<void> {\n const stopped = new AbortController();\n let outputError: Error | undefined;\n const stop = () => stopped.abort();\n const onOutputError = (error: Error) => {\n if ((error as NodeJS.ErrnoException).code !== \"EPIPE\") {\n outputError = error;\n }\n stop();\n };\n const render = watchRenderer(options.policy);\n process.on(\"SIGINT\", stop);\n process.on(\"SIGTERM\", stop);\n process.on(\"SIGHUP\", stop);\n process.stdout.on(\"error\", onOutputError);\n try {\n for await (const event of watchSession({\n record,\n cursor: options.cursor,\n signal: stopped.signal,\n })) {\n for (const chunk of render(event)) {\n if (stopped.signal.aborted) {\n break;\n }\n if (!process.stdout.write(chunk)) {\n await once(process.stdout, \"drain\", { signal: stopped.signal });\n }\n }\n }\n } catch (error) {\n if (!stopped.signal.aborted) {\n throw error;\n }\n } finally {\n process.off(\"SIGINT\", stop);\n process.off(\"SIGTERM\", stop);\n process.off(\"SIGHUP\", stop);\n process.stdout.off(\"error\", onOutputError);\n }\n if (outputError) {\n throw outputError;\n }\n}\n"],"mappings":";;;;;AAQA,SAAS,cAAc,QAA8D;CACnF,MAAM,SAAmB,CA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sB,gBACpB,QACA,SACe;CACf,MAAM,UAAU,IAAI,gBAAgB;CACpC,IAAI;CACJ,MAAM,aAAa,QAAQ,MAAM;CACjC,MAAM,iBAAiB,UAAiB;EACtC,IAAK,MAAgC,SAAS,SAC5C,cAAc;EAEhB,KAAK;CACP;CACA,MAAM,SAAS,cAAc,QAAQ,MAAM;CAC3C,QAAQ,GAAG,UAAU,IAAI;CACzB,QAAQ,GAAG,WAAW,IAAI;CAC1B,QAAQ,GAAG,UAAU,IAAI;CACzB,QAAQ,OAAO,GAAG,SAAS,aAAa;CACxC,IAAI;EACF,WAAW,MAAM,SAAS,aAAa;GACrC;GACA,QAAQ,QAAQ;GAChB,QAAQ,QAAQ;EAClB,CAAC,GACC,KAAK,MAAM,SAAS,OAAO,KAAK,GAAG;GACjC,IAAI,QAAQ,OAAO,SACjB;GAEF,IAAI,CAAC,QAAQ,OAAO,MAAM,KAAK,GAC7B,MAAM,KAAK,QAAQ,QAAQ,SAAS,EAAE,QAAQ,QAAQ,OAAO,CAAC;EAElE;CAEJ,SAAS,OAAO;EACd,IAAI,CAAC,QAAQ,OAAO,SAClB,MAAM;CAEV,UAAU;EACR,QAAQ,IAAI,UAAU,IAAI;EAC1B,QAAQ,IAAI,WAAW,IAAI;EAC3B,QAAQ,IAAI,UAAU,IAAI;EAC1B,QAAQ,OAAO,IAAI,SAAS,aAAa;CAC3C;CACA,IAAI,aACF,MAAM;AAEV"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { E as observeProcessIncarnation, J as watchSession$1, L as readSessionRecord,
|
|
1
|
+
import { E as observeProcessIncarnation, J as watchSession$1, L as readSessionRecord, Zt as SessionNotFoundError, l as readQueueOwnerRecord, q as SessionWatchError } from "./ipc-CLv2iL89.js";
|
|
2
2
|
//#region src/session/watch.ts
|
|
3
3
|
const OWNER_OBSERVATION_REUSE_MS = 1e3;
|
|
4
4
|
function reuseObservation(cached) {
|
|
@@ -82,4 +82,4 @@ function watchSession(options) {
|
|
|
82
82
|
//#endregion
|
|
83
83
|
export { watchSession as t };
|
|
84
84
|
|
|
85
|
-
//# sourceMappingURL=watch-
|
|
85
|
+
//# sourceMappingURL=watch-BE-kKa7o.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"watch-
|
|
1
|
+
{"version":3,"file":"watch-BE-kKa7o.js","names":["watchJournal"],"sources":["../src/session/watch.ts"],"sourcesContent":["import { SessionNotFoundError } from \"../errors.js\";\nimport { observeProcessIncarnation, type ProcessIncarnation } from \"../process-identity.js\";\nimport type { SessionRecord } from \"../types.js\";\nimport {\n SessionWatchError,\n watchSession as watchJournal,\n type SessionWatchEvent,\n} from \"./journal.js\";\nimport { readSessionRecord } from \"./persistence.js\";\nimport { readQueueOwnerRecord, type QueueOwnerRecord } from \"./queue/lease-store.js\";\n\nconst OWNER_OBSERVATION_REUSE_MS = 1_000;\n\ntype WatchObservation = {\n ownerKey: string | null;\n incarnation?: { state: ProcessIncarnation; checkedAt: number; decisionPending: boolean };\n missingRequest: string | null;\n};\n\nfunction reuseObservation(cached: WatchObservation[\"incarnation\"]): boolean {\n if (!cached) {\n return false;\n }\n // A query first forces a journal reread, then gets one decision pass even\n // after a slow consumer. Otherwise repeated probes can defer errors forever.\n if (cached.decisionPending) {\n cached.decisionPending = false;\n return true;\n }\n return (\n cached.state === \"gone\" || performance.now() - cached.checkedAt < OWNER_OBSERVATION_REUSE_MS\n );\n}\n\nfunction selectOwner(owner: QueueOwnerRecord | undefined, observation: WatchObservation): boolean {\n // Heartbeats and retirement receipts do not change the owner's incarnation.\n // Keep only this small key, never the potentially large descendant receipt.\n const key = owner\n ? JSON.stringify([owner.pid, owner.ownerGeneration, owner.processIdentity])\n : null;\n if (key === observation.ownerKey) {\n return false;\n }\n observation.ownerKey = key;\n observation.incarnation = undefined;\n observation.missingRequest = null;\n return true;\n}\n\nasync function runningOwner(\n recordId: string,\n observation: WatchObservation,\n): Promise<{ owner?: QueueOwnerRecord; queried: boolean }> {\n let owner = await readQueueOwnerRecord(recordId);\n selectOwner(owner, observation);\n if (!owner) {\n return { queried: false };\n }\n const cached = observation.incarnation;\n let queried = false;\n // A verified departed incarnation cannot return. Cache that fact even for\n // idle watches; other observations are bounded independently of journal polls.\n if (!reuseObservation(cached)) {\n queried = true;\n // Observation cadence must not truncate the canonical provider's query budget.\n const state = await observeProcessIncarnation(owner.pid, owner.processIdentity);\n owner = await readQueueOwnerRecord(recordId);\n if (selectOwner(owner, observation)) {\n // A replacement may have settled or recovered the journal during the\n // query. Let the reader revisit it before interpreting the old result.\n return { owner, queried };\n }\n observation.incarnation = { state, checkedAt: performance.now(), decisionPending: true };\n }\n return { owner: observation.incarnation?.state === \"gone\" ? undefined : owner, queried };\n}\n\nasync function continueWatching(\n recordId: string,\n pendingRequestId: string | null,\n observation: WatchObservation,\n): Promise<boolean> {\n const { owner, queried } = await runningOwner(recordId, observation);\n if (queried) {\n // A probe can outlast a journal update, including replacement by an older\n // owner. Revisit the journal before any unsupported/unknown/end decision.\n observation.missingRequest = owner ? null : pendingRequestId;\n return true;\n }\n if (owner) {\n if (!owner.sessionWatch) {\n throw new SessionWatchError(\n \"WATCH_OWNER_UNSUPPORTED\",\n \"This running session owner predates passive watching. Let it expire when idle or explicitly close the session before starting new work.\",\n );\n }\n observation.missingRequest = null;\n return true;\n }\n if (pendingRequestId && pendingRequestId === observation.missingRequest) {\n throw new SessionWatchError(\n \"WATCH_OUTCOME_UNKNOWN\",\n `Session owner ended without a settled result for request ${pendingRequestId}; its outcome is unknown. Resume watching from the last cursor after recovery, and do not automatically replay the prompt.`,\n );\n }\n observation.missingRequest = pendingRequestId;\n if (pendingRequestId) {\n return true;\n }\n return await isSessionOpen(recordId);\n}\n\nasync function isSessionOpen(recordId: string): Promise<boolean> {\n const record = await readSessionRecord(recordId);\n if (!record || record.acpxRecordId !== recordId) {\n throw new SessionNotFoundError(recordId);\n }\n return record.closed !== true;\n}\n\nexport function watchSession(options: {\n record: SessionRecord | Promise<SessionRecord>;\n cursor?: string;\n signal?: AbortSignal;\n}): AsyncIterable<SessionWatchEvent> {\n return {\n [Symbol.asyncIterator]() {\n const observation: WatchObservation = { ownerKey: null, missingRequest: null };\n return watchJournal({\n ...options,\n continueWatching: (record, requestId) =>\n continueWatching(record.acpxRecordId, requestId, observation),\n })[Symbol.asyncIterator]();\n },\n };\n}\n"],"mappings":";;AAWA,MAAM,6BAA6B;AAQnC,SAAS,iBAAiB,QAAkD;CAC1E,IAAI,CAAC,QACH,OAAO;CAIT,IAAI,OAAO,iBAAiB;EAC1B,OAAO,kBAAkB;EACzB,OAAO;CACT;CACA,OACE,OAAO,UAAU,UAAU,YAAY,IAAI,IAAI,OAAO,YAAY;AAEtE;AAEA,SAAS,YAAY,OAAqC,aAAwC;CAGhG,MAAM,MAAM,QACR,KAAK,UAAU;EAAC,MAAM;EAAK,MAAM;EAAiB,MAAM;CAAe,CAAC,IACxE;CACJ,IAAI,QAAQ,YAAY,UACtB,OAAO;CAET,YAAY,WAAW;CACvB,YAAY,cAAc,KAAA;CAC1B,YAAY,iBAAiB;CAC7B,OAAO;AACT;AAEA,eAAe,aACb,UACA,aACyD;CACzD,IAAI,QAAQ,MAAM,qBAAqB,QAAQ;CAC/C,YAAY,OAAO,WAAW;CAC9B,IAAI,CAAC,OACH,OAAO,EAAE,SAAS,MAAM;CAE1B,MAAM,SAAS,YAAY;CAC3B,IAAI,UAAU;CAGd,IAAI,CAAC,iBAAiB,MAAM,GAAG;EAC7B,UAAU;EAEV,MAAM,QAAQ,MAAM,0BAA0B,MAAM,KAAK,MAAM,eAAe;EAC9E,QAAQ,MAAM,qBAAqB,QAAQ;EAC3C,IAAI,YAAY,OAAO,WAAW,GAGhC,OAAO;GAAE;GAAO;EAAQ;EAE1B,YAAY,cAAc;GAAE;GAAO,WAAW,YAAY,IAAI;GAAG,iBAAiB;EAAK;CACzF;CACA,OAAO;EAAE,OAAO,YAAY,aAAa,UAAU,SAAS,KAAA,IAAY;EAAO;CAAQ;AACzF;AAEA,eAAe,iBACb,UACA,kBACA,aACkB;CAClB,MAAM,EAAE,OAAO,YAAY,MAAM,aAAa,UAAU,WAAW;CACnE,IAAI,SAAS;EAGX,YAAY,iBAAiB,QAAQ,OAAO;EAC5C,OAAO;CACT;CACA,IAAI,OAAO;EACT,IAAI,CAAC,MAAM,cACT,MAAM,IAAI,kBACR,2BACA,yIACF;EAEF,YAAY,iBAAiB;EAC7B,OAAO;CACT;CACA,IAAI,oBAAoB,qBAAqB,YAAY,gBACvD,MAAM,IAAI,kBACR,yBACA,4DAA4D,iBAAiB,2HAC/E;CAEF,YAAY,iBAAiB;CAC7B,IAAI,kBACF,OAAO;CAET,OAAO,MAAM,cAAc,QAAQ;AACrC;AAEA,eAAe,cAAc,UAAoC;CAC/D,MAAM,SAAS,MAAM,kBAAkB,QAAQ;CAC/C,IAAI,CAAC,UAAU,OAAO,iBAAiB,UACrC,MAAM,IAAI,qBAAqB,QAAQ;CAEzC,OAAO,OAAO,WAAW;AAC3B;AAEA,SAAgB,aAAa,SAIQ;CACnC,OAAO,EACL,CAAC,OAAO,iBAAiB;EACvB,MAAM,cAAgC;GAAE,UAAU;GAAM,gBAAgB;EAAK;EAC7E,OAAOA,eAAa;GAClB,GAAG;GACH,mBAAmB,QAAQ,cACzB,iBAAiB,OAAO,cAAc,WAAW,WAAW;EAChE,CAAC,CAAC,CAAC,OAAO,cAAc,CAAC;CAC3B,EACF;AACF"}
|
|
@@ -36,6 +36,7 @@ Core capabilities:
|
|
|
36
36
|
- Structured streaming output (`text`, `json`, `quiet`) with optional `--suppress-reads`
|
|
37
37
|
- Prompt-response `_meta` preservation across direct, queued, compare, and embedded-runtime results
|
|
38
38
|
- Embedded runtime text events retain message IDs and recognized Codex `commentary` / `final_answer` phases as `messagePhase`; use explicit phases to select report text while keeping the full execution stream, and do not infer finality from prose or tool timing
|
|
39
|
+
- Embedded runtime failures expose safe optional category, provider code, retryability, delivery uncertainty, origin and operation ID fields. Use structured signals instead of provider prose; a failed resource condition does not automatically retry or wait. See `docs/safe-errors.md` for projection and host limitations.
|
|
39
40
|
- Built-in agent registry plus raw `--agent` escape hatch
|
|
40
41
|
- Claude system prompt override via `--system-prompt` / `--append-system-prompt`
|
|
41
42
|
- Optional ACP filesystem and terminal capability opt-outs via `--no-fs` and `--no-terminal`
|