@astrosheep/keiyaku 4.6.8 → 4.6.9
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 +40 -14
- package/build/plugins/claude/.claude-plugin/plugin.json +1 -1
- package/build/plugins/claude/skills/keiyaku/SKILL.md +5 -6
- package/build/plugins/claude/skills/keiyaku-akuma/SKILL.md +1 -1
- package/build/plugins/claude/skills/keiyaku-akuma/references/automation.md +8 -8
- package/build/plugins/claude/skills/keiyaku-babysit/SKILL.md +1 -1
- package/build/plugins/claude/skills/keiyaku-bind/SKILL.md +9 -9
- package/build/plugins/claude/skills/keiyaku-debt/SKILL.md +91 -0
- package/build/plugins/claude/skills/keiyaku-workflow/SKILL.md +2 -2
- package/build/plugins/codex/.codex-plugin/plugin.json +1 -1
- package/build/plugins/codex/skills/keiyaku/SKILL.md +5 -6
- package/build/plugins/codex/skills/keiyaku-akuma/SKILL.md +1 -1
- package/build/plugins/codex/skills/keiyaku-akuma/references/automation.md +8 -8
- package/build/plugins/codex/skills/keiyaku-babysit/SKILL.md +1 -1
- package/build/plugins/codex/skills/keiyaku-bind/SKILL.md +9 -9
- package/build/plugins/codex/skills/keiyaku-debt/SKILL.md +91 -0
- package/build/plugins/codex/skills/keiyaku-workflow/SKILL.md +2 -2
- package/build/plugins/opencode/index.js +1 -1
- package/build/plugins/opencode/skills/keiyaku/SKILL.md +5 -6
- package/build/plugins/opencode/skills/keiyaku-akuma/SKILL.md +1 -1
- package/build/plugins/opencode/skills/keiyaku-akuma/references/automation.md +8 -8
- package/build/plugins/opencode/skills/keiyaku-babysit/SKILL.md +1 -1
- package/build/plugins/opencode/skills/keiyaku-bind/SKILL.md +9 -9
- package/build/plugins/opencode/skills/keiyaku-debt/SKILL.md +91 -0
- package/build/plugins/opencode/skills/keiyaku-workflow/SKILL.md +2 -2
- package/build/skills/keiyaku/SKILL.md +5 -6
- package/build/skills/keiyaku-akuma/SKILL.md +1 -1
- package/build/skills/keiyaku-akuma/references/automation.md +8 -8
- package/build/skills/keiyaku-babysit/SKILL.md +1 -1
- package/build/skills/keiyaku-bind/SKILL.md +9 -9
- package/build/skills/keiyaku-debt/SKILL.md +91 -0
- package/build/skills/keiyaku-workflow/SKILL.md +2 -2
- package/build/src/akuma/akuma-instance.d.ts +2 -0
- package/build/src/akuma/akuma-instance.js +10 -0
- package/build/src/akuma/akuma-observe.d.ts +33 -8
- package/build/src/akuma/akuma-observe.js +88 -64
- package/build/src/akuma/akuma-owner.d.ts +11 -2
- package/build/src/akuma/akuma-owner.js +45 -35
- package/build/src/akuma/akuma-selection-execution.js +9 -1
- package/build/src/akuma/akuma-stream.d.ts +22 -0
- package/build/src/akuma/akuma-stream.js +116 -0
- package/build/src/akuma/akuma-wait.d.ts +1 -40
- package/build/src/akuma/akuma-wait.js +23 -84
- package/build/src/akuma/akuma.d.ts +17 -11
- package/build/src/akuma/akuma.js +2 -0
- package/build/src/akuma/allowed.d.ts +7 -12
- package/build/src/akuma/allowed.js +13 -4
- package/build/src/akuma/body-supervisor.d.ts +5 -5
- package/build/src/akuma/body-supervisor.js +22 -20
- package/build/src/akuma/body.js +28 -1
- package/build/src/akuma/call-request.d.ts +12 -22
- package/build/src/akuma/heart/activity-schema.d.ts +12 -0
- package/build/src/akuma/heart/activity-schema.js +6 -0
- package/build/src/akuma/heart/index.d.ts +59 -2
- package/build/src/akuma/heart/index.js +87 -8
- package/build/src/akuma/heart/rows.js +5 -3
- package/build/src/akuma/heart/soul.d.ts +9 -0
- package/build/src/akuma/heart/soul.js +29 -0
- package/build/src/akuma/heart/storage.d.ts +15 -0
- package/build/src/akuma/heart/storage.js +55 -0
- package/build/src/akuma/heart/timeline.d.ts +7 -0
- package/build/src/akuma/heart/timeline.js +10 -0
- package/build/src/akuma/index.d.ts +1 -0
- package/build/src/akuma/projection.d.ts +25 -0
- package/build/src/akuma/projection.js +24 -7
- package/build/src/akuma/provider-recipe.d.ts +11 -0
- package/build/src/akuma/provider-recipe.js +23 -0
- package/build/src/akuma/provider.d.ts +25 -0
- package/build/src/akuma/provider.js +99 -7
- package/build/src/akuma/providers/acp/events.js +25 -2
- package/build/src/akuma/providers/claude/events.js +76 -10
- package/build/src/akuma/providers/claude/index.js +2 -5
- package/build/src/akuma/providers/codex-app-server/events.js +17 -2
- package/build/src/akuma/providers/codex-app-server/index.js +15 -9
- package/build/src/akuma/providers/decode.d.ts +8 -0
- package/build/src/akuma/providers/decode.js +21 -0
- package/build/src/akuma/providers/grok-build/index.js +10 -26
- package/build/src/akuma/providers/opencode-sdk/event-stream.d.ts +3 -3
- package/build/src/akuma/providers/opencode-sdk/event-stream.js +2 -25
- package/build/src/akuma/providers/opencode-sdk/events.d.ts +7 -43
- package/build/src/akuma/providers/opencode-sdk/events.js +147 -284
- package/build/src/akuma/providers/opencode-sdk/index.js +267 -421
- package/build/src/akuma/providers/opencode-sdk/native-http.d.ts +9 -0
- package/build/src/akuma/providers/opencode-sdk/native-http.js +69 -0
- package/build/src/akuma/providers/opencode-sdk/session.d.ts +42 -36
- package/build/src/akuma/providers/opencode-sdk/session.js +75 -82
- package/build/src/akuma/providers/paseo/events.d.ts +8 -0
- package/build/src/akuma/providers/paseo/events.js +58 -11
- package/build/src/akuma/providers/paseo/index.js +11 -7
- package/build/src/akuma/providers/pi/events.d.ts +2 -0
- package/build/src/akuma/providers/pi/events.js +32 -24
- package/build/src/akuma/providers/pi/index.js +21 -35
- package/build/src/akuma/request-lifecycle.d.ts +1 -2
- package/build/src/akuma/request-lifecycle.js +2 -8
- package/build/src/akuma/request-rendezvous.js +38 -55
- package/build/src/akuma/request-serve.d.ts +1 -1
- package/build/src/akuma/request-serve.js +77 -113
- package/build/src/akuma/selection-observation.d.ts +57 -51
- package/build/src/akuma/selection-observation.js +3 -3
- package/build/src/akuma/turn-drive.d.ts +3 -0
- package/build/src/akuma/turn-drive.js +26 -5
- package/build/src/akuma-body.js +12 -22
- package/build/src/cli/akuma-caller.js +10 -0
- package/build/src/cli/commands/akuma-grammar.js +3 -4
- package/build/src/cli/commands/akuma.js +13 -51
- package/build/src/cli/commands/contract-grammar.d.ts +7 -6
- package/build/src/cli/commands/contract-grammar.js +27 -32
- package/build/src/cli/commands/contract-help.d.ts +16 -7
- package/build/src/cli/commands/contract-help.js +20 -11
- package/build/src/cli/commands/contract.js +11 -11
- package/build/src/cli/commands/debt-grammar.d.ts +19 -0
- package/build/src/cli/commands/debt-grammar.js +323 -0
- package/build/src/cli/commands/debt-query.d.ts +5 -0
- package/build/src/cli/commands/{task-query.js → debt-query.js} +9 -9
- package/build/src/cli/commands/{task.d.ts → debt.d.ts} +2 -2
- package/build/src/cli/commands/{task.js → debt.js} +83 -143
- package/build/src/cli/coordinates.d.ts +1 -1
- package/build/src/cli/coordinates.js +1 -1
- package/build/src/cli/parse.d.ts +4 -4
- package/build/src/cli/parse.js +17 -16
- package/build/src/cli/render/akuma-activity.d.ts +11 -83
- package/build/src/cli/render/akuma-activity.js +20 -382
- package/build/src/cli/render/catalog.d.ts +2 -2
- package/build/src/cli/render/catalog.js +5 -5
- package/build/src/cli/render/contract.js +2 -2
- package/build/src/cli/render/debt.d.ts +28 -0
- package/build/src/cli/render/{task.js → debt.js} +51 -112
- package/build/src/cli/render/kanshi.js +28 -28
- package/build/src/cli/render/marks.d.ts +5 -5
- package/build/src/cli/render/marks.js +4 -10
- package/build/src/cli/render/nuke.js +1 -1
- package/build/src/cli/runtime.js +3 -3
- package/build/src/cli/scan.d.ts +1 -1
- package/build/src/cli/usage.d.ts +1 -1
- package/build/src/cli/usage.js +4 -4
- package/build/src/contract-worktree.js +3 -3
- package/build/src/debt/board.d.ts +160 -0
- package/build/src/{task → debt}/board.js +89 -89
- package/build/src/debt/catalog.d.ts +11 -0
- package/build/src/debt/catalog.js +59 -0
- package/build/src/{task → debt}/context.d.ts +1 -1
- package/build/src/{task → debt}/context.js +1 -1
- package/build/src/{task → debt}/created-observation.d.ts +6 -10
- package/build/src/{task → debt}/created-observation.js +7 -7
- package/build/src/debt/document.d.ts +37 -0
- package/build/src/{task → debt}/document.js +37 -37
- package/build/src/debt/identity.d.ts +21 -0
- package/build/src/{task → debt}/identity.js +35 -35
- package/build/src/debt/index.d.ts +111 -0
- package/build/src/debt/index.js +203 -0
- package/build/src/{task → debt}/input.d.ts +8 -8
- package/build/src/{task → debt}/input.js +21 -21
- package/build/src/debt/lifecycle-operations.d.ts +6 -0
- package/build/src/{task → debt}/lifecycle-operations.js +27 -31
- package/build/src/debt/mutation-result.d.ts +981 -0
- package/build/src/debt/mutation-result.js +109 -0
- package/build/src/debt/mutation.d.ts +424 -0
- package/build/src/debt/mutation.js +223 -0
- package/build/src/debt/operation-types.d.ts +71 -0
- package/build/src/debt/operations.d.ts +28 -0
- package/build/src/{task → debt}/operations.js +59 -60
- package/build/src/debt/query.d.ts +76 -0
- package/build/src/{task → debt}/query.js +55 -55
- package/build/src/{task → debt}/store.d.ts +13 -13
- package/build/src/{task → debt}/store.js +58 -49
- package/build/src/debt/view.d.ts +4 -0
- package/build/src/debt/view.js +7 -0
- package/build/src/identity/coordinates.d.ts +1 -1
- package/build/src/index.d.ts +13 -13
- package/build/src/index.js +9 -9
- package/build/src/kanshi/index.d.ts +1 -1
- package/build/src/kanshi/read.js +33 -33
- package/build/src/kanshi/report.d.ts +7 -7
- package/build/src/kanshi/select.js +4 -4
- package/build/src/library/akumas.d.ts +2 -3
- package/build/src/library/bind.d.ts +3 -3
- package/build/src/library/bind.js +5 -5
- package/build/src/library/contract-creation.js +5 -5
- package/build/src/library/contract-execution.js +4 -4
- package/build/src/library/contract-types.d.ts +2 -2
- package/build/src/library/input.d.ts +2 -2
- package/build/src/library/input.js +5 -5
- package/build/src/library/invocation.js +2 -2
- package/build/src/library/nuke.js +3 -3
- package/build/src/library/outcome.d.ts +126 -126
- package/build/src/library/outcome.js +3 -3
- package/build/src/library/selection.d.ts +1 -4
- package/build/src/library/selection.js +11 -62
- package/build/src/plugin/public.d.ts +5 -0
- package/build/src/plugin/runtime.js +3 -1
- package/build/src/runtime/proc/windows-launch.exe +0 -0
- package/build/src/settlement/fence.d.ts +3 -3
- package/build/src/settlement/fence.js +4 -4
- package/build/src/settlement/holder.d.ts +16 -16
- package/build/src/settlement/holder.js +69 -63
- package/build/src/settlement/settle.d.ts +5 -5
- package/build/src/settlement/settle.js +53 -53
- package/package.json +12 -6
- package/plugins/paseo/plugin/index.server.ts +17 -0
- package/plugins/paseo/plugin/paseo-plugin.json +4 -0
- package/plugins/paseo/plugin/server/attach.ts +52 -0
- package/plugins/paseo/plugin/server/keiyaku.ts +44 -0
- package/plugins/paseo/plugin/server/message.ts +60 -0
- package/plugins/paseo/plugin/server/mirror.ts +193 -0
- package/plugins/paseo/plugin/server/model.ts +14 -0
- package/plugins/paseo/plugin/server/provider.ts +276 -0
- package/plugins/paseo/plugin/server/sdk-worker.ts +237 -0
- package/plugins/paseo/plugin/server/sdk.ts +289 -0
- package/plugins/paseo/plugin/server/stop.ts +26 -0
- package/plugins/paseo/plugin/server/transport.ts +35 -0
- package/plugins/paseo/plugin/shared/attach-rpc.ts +10 -0
- package/plugins/paseo/plugin/shared/refresh-rpc.ts +6 -0
- package/plugins/paseo/plugin/tsconfig.json +6 -0
- package/skills/keiyaku/SKILL.md +5 -6
- package/skills/keiyaku-akuma/SKILL.md +1 -1
- package/skills/keiyaku-akuma/references/automation.md +8 -8
- package/skills/keiyaku-babysit/SKILL.md +1 -1
- package/skills/keiyaku-bind/SKILL.md +9 -9
- package/skills/keiyaku-debt/SKILL.md +91 -0
- package/skills/keiyaku-workflow/SKILL.md +2 -2
- package/build/plugins/claude/skills/keiyaku-task/SKILL.md +0 -104
- package/build/plugins/codex/skills/keiyaku-task/SKILL.md +0 -104
- package/build/plugins/opencode/skills/keiyaku-task/SKILL.md +0 -104
- package/build/skills/keiyaku-task/SKILL.md +0 -104
- package/build/src/cli/commands/task-grammar.d.ts +0 -19
- package/build/src/cli/commands/task-grammar.js +0 -384
- package/build/src/cli/commands/task-query.d.ts +0 -5
- package/build/src/cli/render/task.d.ts +0 -39
- package/build/src/task/board.d.ts +0 -168
- package/build/src/task/catalog.d.ts +0 -11
- package/build/src/task/catalog.js +0 -59
- package/build/src/task/compose-language.d.ts +0 -57
- package/build/src/task/compose-language.js +0 -364
- package/build/src/task/compose-parser.d.ts +0 -32
- package/build/src/task/compose-parser.js +0 -180
- package/build/src/task/compose.d.ts +0 -16
- package/build/src/task/compose.js +0 -189
- package/build/src/task/document.d.ts +0 -39
- package/build/src/task/identity.d.ts +0 -21
- package/build/src/task/index.d.ts +0 -138
- package/build/src/task/index.js +0 -269
- package/build/src/task/lifecycle-operations.d.ts +0 -6
- package/build/src/task/mutation-result.d.ts +0 -1726
- package/build/src/task/mutation-result.js +0 -198
- package/build/src/task/mutation.d.ts +0 -590
- package/build/src/task/mutation.js +0 -262
- package/build/src/task/operation-types.d.ts +0 -71
- package/build/src/task/operations.d.ts +0 -28
- package/build/src/task/query.d.ts +0 -76
- package/build/src/task/view.d.ts +0 -4
- package/build/src/task/view.js +0 -7
- package/skills/keiyaku-task/SKILL.md +0 -104
- /package/build/src/{task → debt}/operation-types.js +0 -0
|
@@ -37,4 +37,11 @@ export declare function readStatusBatch(database: DatabaseSync, input: StatusFac
|
|
|
37
37
|
};
|
|
38
38
|
export declare function statusFacts(database: DatabaseSync, input: StatusFactInput): readonly TimelineFact[];
|
|
39
39
|
export declare function activityFactSlice(database: DatabaseSync): ActivityFactSlice;
|
|
40
|
+
/**
|
|
41
|
+
* SQLite's cross-connection change counter, sampled inside the read
|
|
42
|
+
* transaction. It identifies exactly the snapshot that transaction decodes: a
|
|
43
|
+
* commit from another connection during the read cannot be mistaken for this
|
|
44
|
+
* one and skipped, because the next transaction reports a new counter.
|
|
45
|
+
*/
|
|
46
|
+
export declare function timelineDataVersion(database: DatabaseSync): number;
|
|
40
47
|
export {};
|
|
@@ -124,3 +124,13 @@ export function activityFactSlice(database) {
|
|
|
124
124
|
highest: bounds.highest,
|
|
125
125
|
};
|
|
126
126
|
}
|
|
127
|
+
/**
|
|
128
|
+
* SQLite's cross-connection change counter, sampled inside the read
|
|
129
|
+
* transaction. It identifies exactly the snapshot that transaction decodes: a
|
|
130
|
+
* commit from another connection during the read cannot be mistaken for this
|
|
131
|
+
* one and skipped, because the next transaction reports a new counter.
|
|
132
|
+
*/
|
|
133
|
+
export function timelineDataVersion(database) {
|
|
134
|
+
const row = database.prepare("PRAGMA data_version").get();
|
|
135
|
+
return row?.data_version ?? 0;
|
|
136
|
+
}
|
|
@@ -5,6 +5,7 @@ export type { ArchetypeCatalog, ArchetypeCatalogInput, ArchetypeCatalogRow } fro
|
|
|
5
5
|
export { AkumaBusyError, AkumaDecodeError, AkumaNotBornError, AkumaProviderError } from "./akuma-errors.js";
|
|
6
6
|
export { Akuma } from "./akuma-instance.js";
|
|
7
7
|
export type { AkumaAskOptions, AkumaBirthInput, AkumaHistoryOptions, AkumaHostOptions, AkumaIdleOptions, AkumaIdleResult, AkumaSignalOptions, AkumaTellOptions, } from "./akuma-instance.js";
|
|
8
|
+
export type { AkumaStreamSnapshot } from "./akuma-stream.js";
|
|
8
9
|
export type { InterruptReceipt } from "./akuma-owner.js";
|
|
9
10
|
export type { AkumaStatus } from "./akuma.js";
|
|
10
11
|
export { ALLOWED_ACTIONS } from "./allowed.js";
|
|
@@ -65,6 +65,7 @@ declare const outcomeRowSchema: z.ZodObject<{
|
|
|
65
65
|
kind: z.ZodLiteral<"answered">;
|
|
66
66
|
historyId: z.ZodString;
|
|
67
67
|
answer: z.ZodString;
|
|
68
|
+
foldedSaidSequence: z.ZodOptional<z.ZodNumber>;
|
|
68
69
|
}, z.core.$strict>, z.ZodObject<{
|
|
69
70
|
kind: z.ZodLiteral<"failed">;
|
|
70
71
|
historyId: z.ZodString;
|
|
@@ -105,6 +106,7 @@ declare const activeToolRowSchema: z.ZodObject<{
|
|
|
105
106
|
unspecified: "unspecified";
|
|
106
107
|
}>;
|
|
107
108
|
path: z.ZodString;
|
|
109
|
+
patch: z.ZodOptional<z.ZodString>;
|
|
108
110
|
diffstat: z.ZodOptional<z.ZodObject<{
|
|
109
111
|
added: z.ZodNumber;
|
|
110
112
|
removed: z.ZodNumber;
|
|
@@ -119,6 +121,7 @@ declare const activeToolRowSchema: z.ZodObject<{
|
|
|
119
121
|
}, z.core.$strict>>;
|
|
120
122
|
}, z.core.$strict>]>;
|
|
121
123
|
state: z.ZodLiteral<"active">;
|
|
124
|
+
toolId: z.ZodOptional<z.ZodString>;
|
|
122
125
|
truncated: z.ZodOptional<z.ZodLiteral<true>>;
|
|
123
126
|
}, z.core.$strict>;
|
|
124
127
|
declare const completedToolRowSchema: z.ZodObject<{
|
|
@@ -156,6 +159,7 @@ declare const completedToolRowSchema: z.ZodObject<{
|
|
|
156
159
|
unspecified: "unspecified";
|
|
157
160
|
}>;
|
|
158
161
|
path: z.ZodString;
|
|
162
|
+
patch: z.ZodOptional<z.ZodString>;
|
|
159
163
|
diffstat: z.ZodOptional<z.ZodObject<{
|
|
160
164
|
added: z.ZodNumber;
|
|
161
165
|
removed: z.ZodNumber;
|
|
@@ -175,8 +179,10 @@ declare const completedToolRowSchema: z.ZodObject<{
|
|
|
175
179
|
ok: "ok";
|
|
176
180
|
}>;
|
|
177
181
|
message: z.ZodOptional<z.ZodString>;
|
|
182
|
+
output: z.ZodOptional<z.ZodString>;
|
|
178
183
|
exitCode: z.ZodOptional<z.ZodNumber>;
|
|
179
184
|
}, z.core.$strict>;
|
|
185
|
+
toolId: z.ZodOptional<z.ZodString>;
|
|
180
186
|
truncated: z.ZodOptional<z.ZodLiteral<true>>;
|
|
181
187
|
}, z.core.$strict>;
|
|
182
188
|
declare const unsettledToolRowSchema: z.ZodObject<{
|
|
@@ -213,6 +219,7 @@ declare const unsettledToolRowSchema: z.ZodObject<{
|
|
|
213
219
|
unspecified: "unspecified";
|
|
214
220
|
}>;
|
|
215
221
|
path: z.ZodString;
|
|
222
|
+
patch: z.ZodOptional<z.ZodString>;
|
|
216
223
|
diffstat: z.ZodOptional<z.ZodObject<{
|
|
217
224
|
added: z.ZodNumber;
|
|
218
225
|
removed: z.ZodNumber;
|
|
@@ -227,6 +234,7 @@ declare const unsettledToolRowSchema: z.ZodObject<{
|
|
|
227
234
|
}, z.core.$strict>>;
|
|
228
235
|
}, z.core.$strict>]>;
|
|
229
236
|
state: z.ZodLiteral<"unsettled">;
|
|
237
|
+
toolId: z.ZodOptional<z.ZodString>;
|
|
230
238
|
truncated: z.ZodOptional<z.ZodLiteral<true>>;
|
|
231
239
|
}, z.core.$strict>;
|
|
232
240
|
declare const openSnapshotRowSchema: z.ZodUnion<readonly [z.ZodUnion<readonly [z.ZodObject<{
|
|
@@ -322,6 +330,7 @@ declare const openSnapshotRowSchema: z.ZodUnion<readonly [z.ZodUnion<readonly [z
|
|
|
322
330
|
unspecified: "unspecified";
|
|
323
331
|
}>;
|
|
324
332
|
path: z.ZodString;
|
|
333
|
+
patch: z.ZodOptional<z.ZodString>;
|
|
325
334
|
diffstat: z.ZodOptional<z.ZodObject<{
|
|
326
335
|
added: z.ZodNumber;
|
|
327
336
|
removed: z.ZodNumber;
|
|
@@ -336,6 +345,7 @@ declare const openSnapshotRowSchema: z.ZodUnion<readonly [z.ZodUnion<readonly [z
|
|
|
336
345
|
}, z.core.$strict>>;
|
|
337
346
|
}, z.core.$strict>]>;
|
|
338
347
|
state: z.ZodLiteral<"active">;
|
|
348
|
+
toolId: z.ZodOptional<z.ZodString>;
|
|
339
349
|
truncated: z.ZodOptional<z.ZodLiteral<true>>;
|
|
340
350
|
}, z.core.$strict>, z.ZodObject<{
|
|
341
351
|
kind: z.ZodLiteral<"tool">;
|
|
@@ -372,6 +382,7 @@ declare const openSnapshotRowSchema: z.ZodUnion<readonly [z.ZodUnion<readonly [z
|
|
|
372
382
|
unspecified: "unspecified";
|
|
373
383
|
}>;
|
|
374
384
|
path: z.ZodString;
|
|
385
|
+
patch: z.ZodOptional<z.ZodString>;
|
|
375
386
|
diffstat: z.ZodOptional<z.ZodObject<{
|
|
376
387
|
added: z.ZodNumber;
|
|
377
388
|
removed: z.ZodNumber;
|
|
@@ -391,8 +402,10 @@ declare const openSnapshotRowSchema: z.ZodUnion<readonly [z.ZodUnion<readonly [z
|
|
|
391
402
|
ok: "ok";
|
|
392
403
|
}>;
|
|
393
404
|
message: z.ZodOptional<z.ZodString>;
|
|
405
|
+
output: z.ZodOptional<z.ZodString>;
|
|
394
406
|
exitCode: z.ZodOptional<z.ZodNumber>;
|
|
395
407
|
}, z.core.$strict>;
|
|
408
|
+
toolId: z.ZodOptional<z.ZodString>;
|
|
396
409
|
truncated: z.ZodOptional<z.ZodLiteral<true>>;
|
|
397
410
|
}, z.core.$strict>]>;
|
|
398
411
|
declare const idleSnapshotRowSchema: z.ZodUnion<readonly [z.ZodUnion<readonly [z.ZodObject<{
|
|
@@ -489,6 +502,7 @@ declare const idleSnapshotRowSchema: z.ZodUnion<readonly [z.ZodUnion<readonly [z
|
|
|
489
502
|
unspecified: "unspecified";
|
|
490
503
|
}>;
|
|
491
504
|
path: z.ZodString;
|
|
505
|
+
patch: z.ZodOptional<z.ZodString>;
|
|
492
506
|
diffstat: z.ZodOptional<z.ZodObject<{
|
|
493
507
|
added: z.ZodNumber;
|
|
494
508
|
removed: z.ZodNumber;
|
|
@@ -508,8 +522,10 @@ declare const idleSnapshotRowSchema: z.ZodUnion<readonly [z.ZodUnion<readonly [z
|
|
|
508
522
|
ok: "ok";
|
|
509
523
|
}>;
|
|
510
524
|
message: z.ZodOptional<z.ZodString>;
|
|
525
|
+
output: z.ZodOptional<z.ZodString>;
|
|
511
526
|
exitCode: z.ZodOptional<z.ZodNumber>;
|
|
512
527
|
}, z.core.$strict>;
|
|
528
|
+
toolId: z.ZodOptional<z.ZodString>;
|
|
513
529
|
truncated: z.ZodOptional<z.ZodLiteral<true>>;
|
|
514
530
|
}, z.core.$strict>]>;
|
|
515
531
|
declare const snapshotEntrySchema: <Row extends z.ZodType>(row: Row) => z.ZodUnion<readonly [z.ZodObject<{
|
|
@@ -677,6 +693,7 @@ export declare const activitySnapshotSchema: z.ZodUnion<readonly [z.ZodObject<{
|
|
|
677
693
|
unspecified: "unspecified";
|
|
678
694
|
}>;
|
|
679
695
|
path: z.ZodString;
|
|
696
|
+
patch: z.ZodOptional<z.ZodString>;
|
|
680
697
|
diffstat: z.ZodOptional<z.ZodObject<{
|
|
681
698
|
added: z.ZodNumber;
|
|
682
699
|
removed: z.ZodNumber;
|
|
@@ -691,6 +708,7 @@ export declare const activitySnapshotSchema: z.ZodUnion<readonly [z.ZodObject<{
|
|
|
691
708
|
}, z.core.$strict>>;
|
|
692
709
|
}, z.core.$strict>]>;
|
|
693
710
|
state: z.ZodLiteral<"active">;
|
|
711
|
+
toolId: z.ZodOptional<z.ZodString>;
|
|
694
712
|
truncated: z.ZodOptional<z.ZodLiteral<true>>;
|
|
695
713
|
}, z.core.$strict>, z.ZodObject<{
|
|
696
714
|
kind: z.ZodLiteral<"tool">;
|
|
@@ -727,6 +745,7 @@ export declare const activitySnapshotSchema: z.ZodUnion<readonly [z.ZodObject<{
|
|
|
727
745
|
unspecified: "unspecified";
|
|
728
746
|
}>;
|
|
729
747
|
path: z.ZodString;
|
|
748
|
+
patch: z.ZodOptional<z.ZodString>;
|
|
730
749
|
diffstat: z.ZodOptional<z.ZodObject<{
|
|
731
750
|
added: z.ZodNumber;
|
|
732
751
|
removed: z.ZodNumber;
|
|
@@ -746,8 +765,10 @@ export declare const activitySnapshotSchema: z.ZodUnion<readonly [z.ZodObject<{
|
|
|
746
765
|
ok: "ok";
|
|
747
766
|
}>;
|
|
748
767
|
message: z.ZodOptional<z.ZodString>;
|
|
768
|
+
output: z.ZodOptional<z.ZodString>;
|
|
749
769
|
exitCode: z.ZodOptional<z.ZodNumber>;
|
|
750
770
|
}, z.core.$strict>;
|
|
771
|
+
toolId: z.ZodOptional<z.ZodString>;
|
|
751
772
|
truncated: z.ZodOptional<z.ZodLiteral<true>>;
|
|
752
773
|
}, z.core.$strict>]>;
|
|
753
774
|
}, z.core.$strict>]>>>;
|
|
@@ -780,6 +801,7 @@ export declare const activitySnapshotSchema: z.ZodUnion<readonly [z.ZodObject<{
|
|
|
780
801
|
kind: z.ZodLiteral<"answered">;
|
|
781
802
|
historyId: z.ZodString;
|
|
782
803
|
answer: z.ZodString;
|
|
804
|
+
foldedSaidSequence: z.ZodOptional<z.ZodNumber>;
|
|
783
805
|
}, z.core.$strict>, z.ZodObject<{
|
|
784
806
|
kind: z.ZodLiteral<"failed">;
|
|
785
807
|
historyId: z.ZodString;
|
|
@@ -885,6 +907,7 @@ export declare const activitySnapshotSchema: z.ZodUnion<readonly [z.ZodObject<{
|
|
|
885
907
|
unspecified: "unspecified";
|
|
886
908
|
}>;
|
|
887
909
|
path: z.ZodString;
|
|
910
|
+
patch: z.ZodOptional<z.ZodString>;
|
|
888
911
|
diffstat: z.ZodOptional<z.ZodObject<{
|
|
889
912
|
added: z.ZodNumber;
|
|
890
913
|
removed: z.ZodNumber;
|
|
@@ -904,8 +927,10 @@ export declare const activitySnapshotSchema: z.ZodUnion<readonly [z.ZodObject<{
|
|
|
904
927
|
ok: "ok";
|
|
905
928
|
}>;
|
|
906
929
|
message: z.ZodOptional<z.ZodString>;
|
|
930
|
+
output: z.ZodOptional<z.ZodString>;
|
|
907
931
|
exitCode: z.ZodOptional<z.ZodNumber>;
|
|
908
932
|
}, z.core.$strict>;
|
|
933
|
+
toolId: z.ZodOptional<z.ZodString>;
|
|
909
934
|
truncated: z.ZodOptional<z.ZodLiteral<true>>;
|
|
910
935
|
}, z.core.$strict>]>;
|
|
911
936
|
}, z.core.$strict>]>>>;
|
|
@@ -69,7 +69,14 @@ export const tellRowSchema = z
|
|
|
69
69
|
})
|
|
70
70
|
.strict();
|
|
71
71
|
const outcomeSchema = z.union([
|
|
72
|
-
z
|
|
72
|
+
z
|
|
73
|
+
.object({
|
|
74
|
+
kind: z.literal("answered"),
|
|
75
|
+
historyId: nonblankTextSchema,
|
|
76
|
+
answer: z.string(),
|
|
77
|
+
foldedSaidSequence: countSchema.optional(),
|
|
78
|
+
})
|
|
79
|
+
.strict(),
|
|
73
80
|
z.object({ kind: z.literal("failed"), historyId: nonblankTextSchema, diagnostic: z.string() }).strict(),
|
|
74
81
|
]);
|
|
75
82
|
const outcomeRowSchema = z
|
|
@@ -90,6 +97,7 @@ const activeToolRowSchema = z
|
|
|
90
97
|
name: nonblankTextSchema,
|
|
91
98
|
call: publicToolCallSchema,
|
|
92
99
|
state: z.literal("active"),
|
|
100
|
+
toolId: z.string().optional(),
|
|
93
101
|
truncated: z.literal(true).optional(),
|
|
94
102
|
})
|
|
95
103
|
.strict();
|
|
@@ -103,6 +111,7 @@ const completedToolRowSchema = z
|
|
|
103
111
|
name: nonblankTextSchema,
|
|
104
112
|
call: publicToolCallSchema,
|
|
105
113
|
state: publicToolResultSchema,
|
|
114
|
+
toolId: z.string().optional(),
|
|
106
115
|
truncated: z.literal(true).optional(),
|
|
107
116
|
})
|
|
108
117
|
.strict();
|
|
@@ -115,6 +124,7 @@ const unsettledToolRowSchema = z
|
|
|
115
124
|
name: nonblankTextSchema,
|
|
116
125
|
call: publicToolCallSchema,
|
|
117
126
|
state: z.literal("unsettled"),
|
|
127
|
+
toolId: z.string().optional(),
|
|
118
128
|
truncated: z.literal(true).optional(),
|
|
119
129
|
})
|
|
120
130
|
.strict();
|
|
@@ -239,6 +249,7 @@ function projectToolEvent(rows, running, fact, event, phase) {
|
|
|
239
249
|
turnSequence: fact.turnSequence,
|
|
240
250
|
at: fact.at,
|
|
241
251
|
name: event.name,
|
|
252
|
+
toolId: event.id,
|
|
242
253
|
call: event.call,
|
|
243
254
|
state: phase === "open" ? "active" : "unsettled",
|
|
244
255
|
...(event.truncated === true ? { truncated: true } : {}),
|
|
@@ -254,6 +265,7 @@ function projectToolEvent(rows, running, fact, event, phase) {
|
|
|
254
265
|
turnSequence: fact.turnSequence,
|
|
255
266
|
at: fact.at,
|
|
256
267
|
name: event.name,
|
|
268
|
+
toolId: event.id,
|
|
257
269
|
call: event.call,
|
|
258
270
|
state: event.result,
|
|
259
271
|
...(event.truncated === true ? { truncated: true } : {}),
|
|
@@ -268,6 +280,7 @@ function projectToolEvent(rows, running, fact, event, phase) {
|
|
|
268
280
|
at: fact.at,
|
|
269
281
|
...(durationMs === undefined ? {} : { durationMs }),
|
|
270
282
|
name: event.name,
|
|
283
|
+
toolId: event.id,
|
|
271
284
|
call: event.call,
|
|
272
285
|
state: event.result,
|
|
273
286
|
...(started.truncated === true || event.truncated === true ? { truncated: true } : {}),
|
|
@@ -300,16 +313,20 @@ function demoteActive(row) {
|
|
|
300
313
|
}
|
|
301
314
|
function foldOutcomeVoice(rows, outcome) {
|
|
302
315
|
if (outcome?.outcome.kind !== "answered")
|
|
303
|
-
return rows;
|
|
316
|
+
return { rows, outcome };
|
|
304
317
|
const finalVoice = rows.findLast((row) => row.kind === "said");
|
|
305
318
|
return finalVoice?.text === outcome.outcome.answer && finalVoice.truncated !== true
|
|
306
|
-
?
|
|
307
|
-
|
|
319
|
+
? {
|
|
320
|
+
rows: rows.filter((row) => row !== finalVoice),
|
|
321
|
+
outcome: { ...outcome, outcome: { ...outcome.outcome, foldedSaidSequence: finalVoice.sequence } },
|
|
322
|
+
}
|
|
323
|
+
: { rows, outcome };
|
|
308
324
|
}
|
|
309
325
|
function finishTurn(turn) {
|
|
310
|
-
const
|
|
311
|
-
|
|
312
|
-
|
|
326
|
+
const folded = foldOutcomeVoice(turn.rows, turn.outcome);
|
|
327
|
+
const rows = [...folded.rows].sort((left, right) => left.sequence - right.sequence);
|
|
328
|
+
if (turn.phase === "closed" && folded.outcome !== undefined) {
|
|
329
|
+
return { kind: "closed", turn: turn.turn, rows: rows.map(demoteActive), outcome: folded.outcome };
|
|
313
330
|
}
|
|
314
331
|
if (rows.some((row) => row.kind === "tool" && row.state === "unsettled")) {
|
|
315
332
|
throw new Error(`open Turn ${turn.turn.turnSequence} contains an unsettled tool`);
|
|
@@ -58,6 +58,17 @@ export declare const providerRecipeSchema: z.ZodPipe<z.ZodObject<{
|
|
|
58
58
|
env?: Record<string, string> | undefined;
|
|
59
59
|
}>>;
|
|
60
60
|
export type ProviderExecution = z.infer<typeof providerRecipeSchema>;
|
|
61
|
+
/**
|
|
62
|
+
* One observed runtime model, admitted under the same identity rules a birth
|
|
63
|
+
* selection obeys: a nonblank native identifier, or an explicit unknown whose
|
|
64
|
+
* replacement the native surface did not name.
|
|
65
|
+
*/
|
|
66
|
+
export declare function decodeRuntimeModel(value: unknown): string | undefined;
|
|
67
|
+
/**
|
|
68
|
+
* Recipe members without the current-model member, which an otherwise frozen
|
|
69
|
+
* recipe does not own: it lives once, as the Soul's mutable current selection.
|
|
70
|
+
*/
|
|
71
|
+
export declare function withoutModel(options: ProviderOptions): ProviderOptions;
|
|
61
72
|
export declare function decodeProviderOptions(value: unknown): ProviderOptions;
|
|
62
73
|
export declare function decodeProviderRecipe(value: unknown): ProviderExecution;
|
|
63
74
|
export {};
|
|
@@ -52,6 +52,29 @@ export const providerRecipeSchema = z
|
|
|
52
52
|
...(config === undefined ? {} : { config: snapshot(config) }),
|
|
53
53
|
...(env === undefined ? {} : { env: Object.freeze(env) }),
|
|
54
54
|
}));
|
|
55
|
+
/**
|
|
56
|
+
* One observed runtime model, admitted under the same identity rules a birth
|
|
57
|
+
* selection obeys: a nonblank native identifier, or an explicit unknown whose
|
|
58
|
+
* replacement the native surface did not name.
|
|
59
|
+
*/
|
|
60
|
+
export function decodeRuntimeModel(value) {
|
|
61
|
+
if (value === undefined)
|
|
62
|
+
return undefined;
|
|
63
|
+
const parsed = modelText.safeParse(value);
|
|
64
|
+
if (!parsed.success)
|
|
65
|
+
throw new TypeError(parsed.error.issues[0]?.message ?? "provider option model must be a nonblank string", {
|
|
66
|
+
cause: parsed.error,
|
|
67
|
+
});
|
|
68
|
+
return parsed.data;
|
|
69
|
+
}
|
|
70
|
+
/**
|
|
71
|
+
* Recipe members without the current-model member, which an otherwise frozen
|
|
72
|
+
* recipe does not own: it lives once, as the Soul's mutable current selection.
|
|
73
|
+
*/
|
|
74
|
+
export function withoutModel(options) {
|
|
75
|
+
const { model: _current, ...rest } = options;
|
|
76
|
+
return rest;
|
|
77
|
+
}
|
|
55
78
|
export function decodeProviderOptions(value) {
|
|
56
79
|
const parsed = providerOptionsSchema.safeParse(value);
|
|
57
80
|
if (!parsed.success)
|
|
@@ -16,6 +16,14 @@ export declare function boundedToolInput(input: unknown): ToolInput | undefined;
|
|
|
16
16
|
export declare function otherToolCall(display: string, input?: unknown): Extract<ToolCall, {
|
|
17
17
|
kind: "other";
|
|
18
18
|
}>;
|
|
19
|
+
/**
|
|
20
|
+
* One provider-neutral runtime-model observation. Adapters emit it only from
|
|
21
|
+
* native evidence that names an actual model; `undefined` reports a known
|
|
22
|
+
* model change whose replacement the native surface did not identify.
|
|
23
|
+
*/
|
|
24
|
+
export declare function modelEvent(model?: string): Extract<AgentEvent, {
|
|
25
|
+
type: "model";
|
|
26
|
+
}>;
|
|
19
27
|
export declare function noteEvent(note: string): Extract<AgentEvent, {
|
|
20
28
|
type: "note";
|
|
21
29
|
}>;
|
|
@@ -56,6 +64,23 @@ export type TellSubmission = Readonly<{
|
|
|
56
64
|
}> | Readonly<{
|
|
57
65
|
kind: "turn-ended";
|
|
58
66
|
}>;
|
|
67
|
+
export type TellRegistry<Key> = Readonly<{
|
|
68
|
+
register(key: Key, id: string): Promise<TellSubmission>;
|
|
69
|
+
/** Native evidence naming the booked tell resolves its wait; false when none was booked. */
|
|
70
|
+
accept(key: Key): boolean;
|
|
71
|
+
fail(key: Key, error: unknown): void;
|
|
72
|
+
end(): void;
|
|
73
|
+
}>;
|
|
74
|
+
/**
|
|
75
|
+
* One live-tell receipt book, keyed by whatever evidence proves acceptance: a
|
|
76
|
+
* native message identity or the tell id itself, with `fenceOf` naming the
|
|
77
|
+
* receipt. Register before the text reaches the native surface. Ending the
|
|
78
|
+
* turn ends every remaining wait, and every later registration too.
|
|
79
|
+
*/
|
|
80
|
+
export declare function tellRegistry<Key>(fenceOf?: (id: string) => string): TellRegistry<Key>;
|
|
81
|
+
export declare function launchPrompt(body: string, tells: readonly Readonly<{
|
|
82
|
+
text: string;
|
|
83
|
+
}>[], schema?: string): string;
|
|
59
84
|
export type Session = Readonly<{
|
|
60
85
|
admission: Readonly<{
|
|
61
86
|
fence: ProviderFence;
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
export { AKUMA_REQUESTS_ENV, AKUMA_REQUESTS_ENTRY_ENV } from "./providers/execution-environment.js";
|
|
2
2
|
const AGENT_EVENT_TEXT_LIMIT = 16_384;
|
|
3
3
|
const AGENT_THOUGHT_TEXT_LIMIT = 4_000;
|
|
4
|
+
const OBSERVED_TEXT_TRUNCATION_MARKER = "\n…[truncated]";
|
|
4
5
|
export const AGENT_EVENT_QUEUE_LIMIT = 256;
|
|
5
6
|
export { decodeAgentEvent } from "./heart/activity-schema.js";
|
|
6
7
|
function boundedToolCall(call) {
|
|
@@ -33,14 +34,24 @@ function boundedToolCall(call) {
|
|
|
33
34
|
(call.path !== undefined && call.path.length > AGENT_EVENT_TEXT_LIMIT) ||
|
|
34
35
|
(call.glob !== undefined && call.glob.length > AGENT_EVENT_TEXT_LIMIT),
|
|
35
36
|
};
|
|
36
|
-
case "fileChange":
|
|
37
|
+
case "fileChange": {
|
|
38
|
+
const bounded = call.changes.map((change) => {
|
|
39
|
+
const patch = change.patch === undefined ? undefined : boundedObservedText(change.patch);
|
|
40
|
+
return {
|
|
41
|
+
value: {
|
|
42
|
+
...change,
|
|
43
|
+
path: boundedEventText(change.path),
|
|
44
|
+
...(patch === undefined ? {} : { patch: patch.value }),
|
|
45
|
+
},
|
|
46
|
+
truncated: patch?.truncated === true,
|
|
47
|
+
};
|
|
48
|
+
});
|
|
37
49
|
return {
|
|
38
|
-
value: {
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
},
|
|
42
|
-
truncated: call.changes.some((change) => change.path.length > AGENT_EVENT_TEXT_LIMIT),
|
|
50
|
+
value: { kind: call.kind, changes: bounded.map((change) => change.value) },
|
|
51
|
+
truncated: bounded.some((change) => change.truncated) ||
|
|
52
|
+
call.changes.some((change) => change.path.length > AGENT_EVENT_TEXT_LIMIT),
|
|
43
53
|
};
|
|
54
|
+
}
|
|
44
55
|
case "other": {
|
|
45
56
|
const input = call.input;
|
|
46
57
|
const display = boundedEventText(call.display);
|
|
@@ -62,13 +73,15 @@ function boundedToolCall(call) {
|
|
|
62
73
|
}
|
|
63
74
|
}
|
|
64
75
|
function boundedToolResult(result) {
|
|
76
|
+
const output = result.output === undefined ? undefined : boundedObservedText(result.output);
|
|
65
77
|
return {
|
|
66
78
|
value: {
|
|
67
79
|
status: result.status,
|
|
68
80
|
...(result.message === undefined ? {} : { message: boundedEventText(result.message) }),
|
|
81
|
+
...(output === undefined ? {} : { output: output.value }),
|
|
69
82
|
...(result.exitCode === undefined ? {} : { exitCode: result.exitCode }),
|
|
70
83
|
},
|
|
71
|
-
truncated: result.message !== undefined && result.message.length > AGENT_EVENT_TEXT_LIMIT,
|
|
84
|
+
truncated: (result.message !== undefined && result.message.length > AGENT_EVENT_TEXT_LIMIT) || output?.truncated === true,
|
|
72
85
|
};
|
|
73
86
|
}
|
|
74
87
|
export function encodeAgentEvent(event) {
|
|
@@ -82,6 +95,10 @@ export function encodeAgentEvent(event) {
|
|
|
82
95
|
: { sessionId: event.coordinate.sessionId };
|
|
83
96
|
return { type: event.type, coordinate };
|
|
84
97
|
}
|
|
98
|
+
case "model":
|
|
99
|
+
return event.model === undefined
|
|
100
|
+
? { type: event.type }
|
|
101
|
+
: { type: event.type, model: boundedEventText(event.model) };
|
|
85
102
|
case "assistant":
|
|
86
103
|
return marked({ type: event.type, text: boundedEventText(event.text) }, event.text.length > AGENT_EVENT_TEXT_LIMIT);
|
|
87
104
|
case "thought":
|
|
@@ -158,9 +175,37 @@ function boundedToolInputJson(value) {
|
|
|
158
175
|
function boundedEventText(value) {
|
|
159
176
|
return value.slice(0, AGENT_EVENT_TEXT_LIMIT);
|
|
160
177
|
}
|
|
178
|
+
/**
|
|
179
|
+
* Bound one observed result text or patch. Observed content carries its own
|
|
180
|
+
* visible truncation marker inside the same budget: a cut diff that still looks
|
|
181
|
+
* complete is worse than a marked one, and the marker is part of that bound so
|
|
182
|
+
* re-encoding an already bounded value changes nothing. The cut lands on a
|
|
183
|
+
* complete code point, never a UTF-16 surrogate half.
|
|
184
|
+
*/
|
|
185
|
+
function boundedObservedText(value) {
|
|
186
|
+
if (value.length <= AGENT_EVENT_TEXT_LIMIT)
|
|
187
|
+
return { value, truncated: false };
|
|
188
|
+
const budget = AGENT_EVENT_TEXT_LIMIT - OBSERVED_TEXT_TRUNCATION_MARKER.length;
|
|
189
|
+
return {
|
|
190
|
+
value: `${value.slice(0, cutBeforeSurrogate(value, budget))}${OBSERVED_TEXT_TRUNCATION_MARKER}`,
|
|
191
|
+
truncated: true,
|
|
192
|
+
};
|
|
193
|
+
}
|
|
194
|
+
function cutBeforeSurrogate(value, budget) {
|
|
195
|
+
const lastKept = value.charCodeAt(budget - 1);
|
|
196
|
+
return lastKept >= 0xd800 && lastKept <= 0xdbff ? budget - 1 : budget;
|
|
197
|
+
}
|
|
161
198
|
function boundedThoughtText(value) {
|
|
162
199
|
return value.slice(0, AGENT_THOUGHT_TEXT_LIMIT);
|
|
163
200
|
}
|
|
201
|
+
/**
|
|
202
|
+
* One provider-neutral runtime-model observation. Adapters emit it only from
|
|
203
|
+
* native evidence that names an actual model; `undefined` reports a known
|
|
204
|
+
* model change whose replacement the native surface did not identify.
|
|
205
|
+
*/
|
|
206
|
+
export function modelEvent(model) {
|
|
207
|
+
return model === undefined ? { type: "model" } : { type: "model", model: boundedEventText(model) };
|
|
208
|
+
}
|
|
164
209
|
export function noteEvent(note) {
|
|
165
210
|
return { type: "note", text: note.replace(/\s+/g, " ").trim() };
|
|
166
211
|
}
|
|
@@ -250,6 +295,53 @@ export class AgentEventChannel {
|
|
|
250
295
|
};
|
|
251
296
|
}
|
|
252
297
|
}
|
|
298
|
+
/**
|
|
299
|
+
* One live-tell receipt book, keyed by whatever evidence proves acceptance: a
|
|
300
|
+
* native message identity or the tell id itself, with `fenceOf` naming the
|
|
301
|
+
* receipt. Register before the text reaches the native surface. Ending the
|
|
302
|
+
* turn ends every remaining wait, and every later registration too.
|
|
303
|
+
*/
|
|
304
|
+
export function tellRegistry(fenceOf = (id) => id) {
|
|
305
|
+
const waiting = new Map();
|
|
306
|
+
let ended = false;
|
|
307
|
+
const take = (key) => {
|
|
308
|
+
const waiter = waiting.get(key);
|
|
309
|
+
if (waiter !== undefined)
|
|
310
|
+
waiting.delete(key);
|
|
311
|
+
return waiter;
|
|
312
|
+
};
|
|
313
|
+
return {
|
|
314
|
+
register(key, id) {
|
|
315
|
+
if (ended)
|
|
316
|
+
return Promise.resolve({ kind: "turn-ended" });
|
|
317
|
+
if (waiting.has(key))
|
|
318
|
+
throw new Error("duplicate live tell");
|
|
319
|
+
return new Promise((resolve, reject) => waiting.set(key, { id, resolve, reject }));
|
|
320
|
+
},
|
|
321
|
+
accept(key) {
|
|
322
|
+
const waiter = take(key);
|
|
323
|
+
waiter?.resolve({ kind: "accepted", fence: fenceOf(waiter.id) });
|
|
324
|
+
return waiter !== undefined;
|
|
325
|
+
},
|
|
326
|
+
fail(key, error) {
|
|
327
|
+
take(key)?.reject(error);
|
|
328
|
+
},
|
|
329
|
+
end() {
|
|
330
|
+
ended = true;
|
|
331
|
+
for (const waiter of waiting.values())
|
|
332
|
+
waiter.resolve({ kind: "turn-ended" });
|
|
333
|
+
waiting.clear();
|
|
334
|
+
},
|
|
335
|
+
};
|
|
336
|
+
}
|
|
337
|
+
/** The one launch text: the body, every launch tell, then any schema, blank-line separated. */
|
|
338
|
+
const JSON_SCHEMA_PROMPT = "Respond with JSON matching this JSON Schema and no other text:";
|
|
339
|
+
export function launchPrompt(body, tells, schema) {
|
|
340
|
+
const parts = [body, ...tells.map((tell) => tell.text)];
|
|
341
|
+
if (schema !== undefined)
|
|
342
|
+
parts.push(JSON_SCHEMA_PROMPT, schema);
|
|
343
|
+
return parts.filter((part) => part.length > 0).join("\n\n");
|
|
344
|
+
}
|
|
253
345
|
/**
|
|
254
346
|
* Starts provider work after its caller has received custody. The input signal
|
|
255
347
|
* remains a cancellation notification; this attempt owns its own controller
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { noteEvent, otherToolCall, unknownEvent } from "../../provider.js";
|
|
2
|
-
import { nonblank, object, positiveLine } from "../decode.js";
|
|
2
|
+
import { nonblank, object, positiveLine, stringValue } from "../decode.js";
|
|
3
3
|
export const EMPTY_ACP_EVENT_STATE = Object.freeze({
|
|
4
4
|
answer: "",
|
|
5
5
|
assistantMessageId: null,
|
|
@@ -40,6 +40,25 @@ function locationFact(locations) {
|
|
|
40
40
|
}
|
|
41
41
|
return {};
|
|
42
42
|
}
|
|
43
|
+
/**
|
|
44
|
+
* The observed result text of one ACP tool update: its text content blocks in
|
|
45
|
+
* native order, otherwise a raw output that is itself a string. A raw output of
|
|
46
|
+
* any other shape is left absent rather than stringified.
|
|
47
|
+
*/
|
|
48
|
+
function verifiedToolOutput(update) {
|
|
49
|
+
if (Array.isArray(update.content)) {
|
|
50
|
+
const blocks = update.content.flatMap((entry) => {
|
|
51
|
+
const value = object(entry);
|
|
52
|
+
if (value?.type !== "content")
|
|
53
|
+
return [];
|
|
54
|
+
const content = object(value.content);
|
|
55
|
+
return content?.type === "text" && typeof content.text === "string" ? [content.text] : [];
|
|
56
|
+
});
|
|
57
|
+
if (blocks.length > 0)
|
|
58
|
+
return blocks.join("");
|
|
59
|
+
}
|
|
60
|
+
return stringValue(update.rawOutput);
|
|
61
|
+
}
|
|
43
62
|
function standardCall(update, name) {
|
|
44
63
|
const location = locationFact(update.locations);
|
|
45
64
|
if (update.kind === "read") {
|
|
@@ -109,6 +128,7 @@ export function mapAcpUpdate(update, previous, interpret) {
|
|
|
109
128
|
const observed = observeTool(update, previous.tools.get(update.toolCallId), interpret);
|
|
110
129
|
const tools = new Map(previous.tools);
|
|
111
130
|
if (update.status === "completed" || update.status === "failed") {
|
|
131
|
+
const output = verifiedToolOutput(update);
|
|
112
132
|
tools.delete(update.toolCallId);
|
|
113
133
|
return flushAcpEvents({ ...previous, tools }, [
|
|
114
134
|
{
|
|
@@ -116,7 +136,10 @@ export function mapAcpUpdate(update, previous, interpret) {
|
|
|
116
136
|
phase: "completed",
|
|
117
137
|
id: update.toolCallId,
|
|
118
138
|
...observed,
|
|
119
|
-
result: {
|
|
139
|
+
result: {
|
|
140
|
+
status: update.status === "completed" ? "ok" : "error",
|
|
141
|
+
...(output === undefined ? {} : { output }),
|
|
142
|
+
},
|
|
120
143
|
},
|
|
121
144
|
]);
|
|
122
145
|
}
|