@astrosheep/keiyaku 4.1.0 → 4.1.2
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 +1 -1
- package/build/integrations/marketplace/plugins/keiyaku/skills/keiyaku/SKILL.md +3 -0
- package/build/integrations/marketplace/plugins/keiyaku/skills/keiyaku-akuma/SKILL.md +3 -0
- package/build/integrations/marketplace/plugins/keiyaku/skills/keiyaku-workflow/SKILL.md +3 -6
- package/build/src/akuma/akuma-errors.d.ts +6 -0
- package/build/src/akuma/akuma-errors.js +9 -0
- package/build/src/akuma/akuma-handle.d.ts +39 -0
- package/build/src/akuma/akuma-handle.js +263 -0
- package/build/src/akuma/akuma-observe.d.ts +19 -0
- package/build/src/akuma/akuma-observe.js +74 -0
- package/build/src/akuma/akuma-product-symbols.d.ts +1 -0
- package/build/src/akuma/akuma-product-symbols.js +1 -0
- package/build/src/akuma/akuma-product.d.ts +18 -0
- package/build/src/akuma/akuma-product.js +154 -0
- package/build/src/akuma/akuma.d.ts +37 -81
- package/build/src/akuma/akuma.js +39 -447
- package/build/src/akuma/allowed.d.ts +1 -0
- package/build/src/akuma/allowed.js +6 -0
- package/build/src/akuma/archetype.js +8 -5
- package/build/src/akuma/body-supervisor.d.ts +26 -0
- package/build/src/akuma/body-supervisor.js +89 -0
- package/build/src/akuma/body.d.ts +45 -4
- package/build/src/akuma/body.js +145 -35
- package/build/src/akuma/coordinate.js +17 -7
- package/build/src/akuma/heart/facts.js +1 -1
- package/build/src/akuma/heart/index.d.ts +1 -1
- package/build/src/akuma/heart/index.js +2 -4
- package/build/src/akuma/heart/request-authority.js +4 -4
- package/build/src/akuma/heart/request-rows.js +27 -16
- package/build/src/akuma/heart/rows.js +79 -41
- package/build/src/akuma/heart/soul.js +1 -1
- package/build/src/akuma/heart/storage.d.ts +1 -0
- package/build/src/akuma/heart/storage.js +76 -11
- package/build/src/akuma/heart/tells.js +35 -18
- package/build/src/akuma/heart/timeline.js +19 -11
- package/build/src/akuma/identity.d.ts +1 -0
- package/build/src/akuma/identity.js +1 -0
- package/build/src/akuma/index.d.ts +3 -3
- package/build/src/akuma/index.js +1 -1
- package/build/src/akuma/nuke.js +106 -14
- package/build/src/akuma/projection-read.d.ts +17 -0
- package/build/src/akuma/projection-read.js +135 -0
- package/build/src/akuma/projection.d.ts +1 -16
- package/build/src/akuma/projection.js +77 -154
- package/build/src/akuma/provider-recipe.js +11 -5
- package/build/src/akuma/provider.js +105 -62
- package/build/src/akuma/providers/acp/config.js +5 -6
- package/build/src/akuma/providers/acp/core.js +17 -10
- package/build/src/akuma/providers/acp/events.js +38 -29
- package/build/src/akuma/providers/acp/index.js +13 -9
- package/build/src/akuma/providers/claude/events.js +8 -12
- package/build/src/akuma/providers/claude/index.d.ts +1 -0
- package/build/src/akuma/providers/claude/index.js +55 -26
- package/build/src/akuma/providers/claude/input.js +6 -2
- package/build/src/akuma/providers/codex-app-server/events.js +61 -36
- package/build/src/akuma/providers/codex-app-server/index.js +25 -13
- package/build/src/akuma/providers/grok-build/index.js +22 -25
- package/build/src/akuma/providers/index.js +2 -18
- package/build/src/akuma/providers/opencode-sdk/events.js +32 -18
- package/build/src/akuma/providers/opencode-sdk/index.js +26 -17
- package/build/src/akuma/providers/opencode-sdk/session.js +21 -5
- package/build/src/akuma/providers/pi/events.js +26 -19
- package/build/src/akuma/providers/pi/index.js +58 -40
- package/build/src/akuma/publication.js +9 -9
- package/build/src/akuma/request-execution.d.ts +6 -0
- package/build/src/akuma/request-execution.js +86 -0
- package/build/src/akuma/request-serve.d.ts +12 -1
- package/build/src/akuma/request-serve.js +19 -122
- package/build/src/akuma/request-wire.d.ts +2 -2
- package/build/src/akuma/request-wire.js +75 -102
- package/build/src/akuma/requests.js +2 -2
- package/build/src/akuma/{body-turn.d.ts → turn-drive.d.ts} +2 -25
- package/build/src/akuma/{body-turn.js → turn-drive.js} +20 -103
- package/build/src/akuma-body.js +6 -5
- package/build/src/body/amend.d.ts +4 -1
- package/build/src/body/amend.js +14 -6
- package/build/src/body/decode.js +2 -4
- package/build/src/body/envelope.js +2 -4
- package/build/src/body/region.d.ts +1 -2
- package/build/src/body/region.js +2 -70
- package/build/src/body/render.js +17 -12
- package/build/src/body/shape.js +1 -7
- package/build/src/cli/accepted.d.ts +1 -1
- package/build/src/cli/accepted.js +8 -1
- package/build/src/cli/commands/akuma-invoke.js +18 -6
- package/build/src/cli/commands/akuma.d.ts +0 -6
- package/build/src/cli/commands/akuma.js +11 -24
- package/build/src/cli/commands/amend.d.ts +2 -2
- package/build/src/cli/commands/amend.js +2 -4
- package/build/src/cli/commands/bind.d.ts +4 -4
- package/build/src/cli/commands/bind.js +16 -6
- package/build/src/cli/commands/contract-invoke.d.ts +25 -0
- package/build/src/cli/commands/contract-invoke.js +193 -0
- package/build/src/cli/commands/contract.d.ts +109 -10
- package/build/src/cli/commands/contract.js +339 -16
- package/build/src/cli/commands/install.d.ts +1 -1
- package/build/src/cli/commands/install.js +23 -15
- package/build/src/cli/commands/task-invoke.js +187 -67
- package/build/src/cli/commands/task-query.js +48 -24
- package/build/src/cli/commands/task.js +150 -38
- package/build/src/cli/coordinates.js +2 -4
- package/build/src/cli/invoke.js +92 -208
- package/build/src/cli/main.js +4 -2
- package/build/src/cli/parse.d.ts +3 -90
- package/build/src/cli/parse.js +27 -233
- package/build/src/cli/render/akuma-activity.d.ts +38 -0
- package/build/src/cli/render/akuma-activity.js +362 -0
- package/build/src/cli/render/akuma-tool-command.js +6 -7
- package/build/src/cli/render/akuma-tool.js +10 -8
- package/build/src/cli/render/akuma.d.ts +1 -1
- package/build/src/cli/render/akuma.js +61 -353
- package/build/src/cli/render/audit.js +5 -15
- package/build/src/cli/render/board.d.ts +1 -0
- package/build/src/cli/render/board.js +17 -0
- package/build/src/cli/render/catalog.js +81 -8
- package/build/src/cli/render/contract-history.d.ts +2 -0
- package/build/src/cli/render/contract-history.js +83 -0
- package/build/src/cli/render/contract-observation.d.ts +10 -0
- package/build/src/cli/render/contract-observation.js +58 -0
- package/build/src/cli/render/contract.d.ts +1 -2
- package/build/src/cli/render/contract.js +41 -142
- package/build/src/cli/render/kanshi.js +239 -215
- package/build/src/cli/render/receipt.js +2 -9
- package/build/src/cli/render/refusal.js +10 -15
- package/build/src/cli/render/region.js +22 -6
- package/build/src/cli/render/settings.js +4 -4
- package/build/src/cli/render/task.js +34 -14
- package/build/src/cli/render/terminal.js +16 -5
- package/build/src/cli/result.d.ts +3 -3
- package/build/src/cli/runtime.d.ts +6 -1
- package/build/src/cli/runtime.js +84 -63
- package/build/src/cli/selectors.js +2 -4
- package/build/src/cli/usage.js +6 -5
- package/build/src/contract-worktree.d.ts +1 -23
- package/build/src/contract-worktree.js +79 -155
- package/build/src/coordination/durable-file.js +7 -3
- package/build/src/coordination/sqlite-transaction-lock.js +29 -12
- package/build/src/core/facts/codec.js +7 -3
- package/build/src/core/facts/types.d.ts +1 -1
- package/build/src/core/subject.js +16 -9
- package/build/src/core/verbs/abandon.d.ts +1 -1
- package/build/src/core/verbs/abandon.js +1 -1
- package/build/src/core/verbs/amend.d.ts +1 -1
- package/build/src/core/verbs/amend.js +7 -7
- package/build/src/core/verbs/attestation.js +4 -1
- package/build/src/core/verbs/bind.d.ts +1 -1
- package/build/src/core/verbs/bind.js +1 -1
- package/build/src/core/verbs/placement.d.ts +1 -1
- package/build/src/core/verbs/placement.js +10 -8
- package/build/src/dispatch/index.js +8 -6
- package/build/src/duration.js +5 -1
- package/build/src/git/admission.js +5 -3
- package/build/src/git/hooks.d.ts +8 -0
- package/build/src/git/hooks.js +63 -14
- package/build/src/git/identity.js +1 -4
- package/build/src/git/integration.d.ts +2 -3
- package/build/src/git/integration.js +32 -39
- package/build/src/git/nuke.d.ts +1 -1
- package/build/src/git/nuke.js +110 -57
- package/build/src/git/observe.d.ts +13 -1
- package/build/src/git/observe.js +51 -44
- package/build/src/git/process.js +4 -2
- package/build/src/git/read-observation.js +10 -8
- package/build/src/git/reconcile.d.ts +22 -2
- package/build/src/git/reconcile.js +38 -274
- package/build/src/git/repository.d.ts +2 -0
- package/build/src/git/repository.js +13 -22
- package/build/src/git/scratch.d.ts +8 -5
- package/build/src/git/scratch.js +29 -2
- package/build/src/git/target-placement.d.ts +9 -10
- package/build/src/git/target-placement.js +59 -62
- package/build/src/git/tender.js +13 -46
- package/build/src/git/terminal-reconcile.d.ts +21 -0
- package/build/src/git/terminal-reconcile.js +278 -0
- package/build/src/git/terminal-seal.js +15 -12
- package/build/src/git/tree.js +5 -2
- package/build/src/git/workspace.d.ts +24 -2
- package/build/src/git/workspace.js +120 -16
- package/build/src/identity/coordinates.js +3 -1
- package/build/src/identity/selector.js +6 -3
- package/build/src/kanshi/fleet.d.ts +6 -0
- package/build/src/kanshi/fleet.js +27 -0
- package/build/src/kanshi/index.d.ts +1 -1
- package/build/src/kanshi/read.js +60 -48
- package/build/src/kanshi/report.d.ts +11 -23
- package/build/src/kanshi/select.js +25 -24
- package/build/src/library/address.d.ts +2 -1
- package/build/src/library/address.js +7 -8
- package/build/src/library/akuma-creation.js +20 -12
- package/build/src/library/audit.d.ts +0 -1
- package/build/src/library/audit.js +1 -2
- package/build/src/library/bind.d.ts +53 -5
- package/build/src/library/bind.js +98 -22
- package/build/src/library/catalog.d.ts +1 -0
- package/build/src/library/catalog.js +6 -3
- package/build/src/library/configuration.js +3 -1
- package/build/src/library/continuation.d.ts +15 -4
- package/build/src/library/continuation.js +24 -16
- package/build/src/library/contract-bind.d.ts +26 -0
- package/build/src/library/contract-bind.js +106 -0
- package/build/src/library/contract-operations.d.ts +77 -0
- package/build/src/library/contract-operations.js +130 -0
- package/build/src/library/contract-types.d.ts +95 -0
- package/build/src/library/contract-types.js +1 -0
- package/build/src/library/contract.d.ts +19 -154
- package/build/src/library/contract.js +46 -261
- package/build/src/library/fleet.d.ts +1 -1
- package/build/src/library/fleet.js +19 -11
- package/build/src/library/input.d.ts +2 -0
- package/build/src/library/input.js +14 -0
- package/build/src/library/keiyaku.d.ts +8 -7
- package/build/src/library/keiyaku.js +3 -3
- package/build/src/library/nuke.js +14 -5
- package/build/src/library/reconcile.d.ts +9 -4
- package/build/src/library/reconcile.js +30 -24
- package/build/src/library/refusal.d.ts +13 -5
- package/build/src/library/refusal.js +7 -0
- package/build/src/library/region.d.ts +8 -7
- package/build/src/library/region.js +31 -11
- package/build/src/library/repo.js +2 -2
- package/build/src/markdown/lex.js +9 -2
- package/build/src/markdown/parse.js +11 -7
- package/build/src/markdown/query.js +4 -2
- package/build/src/protocol/amend.js +3 -1
- package/build/src/protocol/attempt.d.ts +7 -3
- package/build/src/protocol/attempt.js +9 -5
- package/build/src/protocol/audit.d.ts +1 -1
- package/build/src/protocol/audit.js +4 -14
- package/build/src/protocol/bind.d.ts +19 -6
- package/build/src/protocol/bind.js +28 -13
- package/build/src/protocol/completion.d.ts +0 -1
- package/build/src/protocol/completion.js +1 -3
- package/build/src/protocol/deliver.d.ts +1 -3
- package/build/src/protocol/deliver.js +15 -39
- package/build/src/protocol/intent.d.ts +1 -0
- package/build/src/protocol/intent.js +9 -7
- package/build/src/protocol/operations.d.ts +3 -7
- package/build/src/protocol/operations.js +5 -3
- package/build/src/protocol/placement.d.ts +0 -1
- package/build/src/protocol/placement.js +6 -6
- package/build/src/protocol/read/observation.d.ts +11 -0
- package/build/src/protocol/read/observation.js +37 -0
- package/build/src/protocol/read/status.d.ts +23 -12
- package/build/src/protocol/read/status.js +90 -72
- package/build/src/protocol/reconcile.d.ts +1 -0
- package/build/src/protocol/reconcile.js +2 -3
- package/build/src/protocol/reintegrate.js +1 -1
- package/build/src/protocol/review.d.ts +0 -1
- package/build/src/protocol/review.js +15 -22
- package/build/src/protocol/run.d.ts +1 -0
- package/build/src/protocol/run.js +4 -5
- package/build/src/runtime/proc/launch.d.ts +33 -0
- package/build/src/runtime/proc/launch.js +98 -0
- package/build/src/runtime/proc/line-rpc.js +9 -3
- package/build/src/runtime/proc/run.d.ts +12 -6
- package/build/src/runtime/proc/run.js +78 -21
- package/build/src/runtime/proc/stdio.js +7 -10
- package/build/src/settings.js +6 -2
- package/build/src/settlement/holder.js +13 -10
- package/build/src/settlement/settle.js +39 -6
- package/build/src/task/board.js +12 -6
- package/build/src/task/compose.js +85 -22
- package/build/src/task/context.js +21 -8
- package/build/src/task/document.js +46 -10
- package/build/src/task/identity.js +5 -2
- package/build/src/task/index.d.ts +0 -1
- package/build/src/task/index.js +119 -34
- package/build/src/task/input.js +29 -7
- package/build/src/task/mutation.js +61 -19
- package/build/src/task/operations.d.ts +6 -1
- package/build/src/task/operations.js +83 -29
- package/build/src/task/query.js +55 -26
- package/build/src/task/store.d.ts +3 -1
- package/build/src/task/store.js +81 -17
- package/build/src/verification/execution.js +14 -11
- package/build/src/workspace-place.js +19 -7
- package/build/src/world.js +16 -6
- package/package.json +8 -3
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { randomUUID } from "node:crypto";
|
|
2
2
|
import { abortable } from "../../abort.js";
|
|
3
3
|
import { AKUMA_REQUESTS_ENV, AgentEventChannel, } from "../../provider.js";
|
|
4
|
-
import { emitClaudeMessage
|
|
4
|
+
import { emitClaudeMessage } from "./events.js";
|
|
5
5
|
import { claudeUserMessage, createClaudeInput, isClaudeTurnEnded } from "./input.js";
|
|
6
6
|
export { CLAUDE_MESSAGE_DISPOSITIONS, CLAUDE_SYSTEM_DISPOSITIONS } from "./events.js";
|
|
7
7
|
class ReceiptChannel {
|
|
@@ -59,25 +59,32 @@ function claudeSessionId(coordinate) {
|
|
|
59
59
|
function claudeQueryOptions(input, execution, abortController) {
|
|
60
60
|
const mode = permissionMode(input.options.readonly);
|
|
61
61
|
return {
|
|
62
|
+
...(execution.config ?? {}),
|
|
62
63
|
cwd: input.cwd,
|
|
63
64
|
abortController,
|
|
64
65
|
...(input.requests === undefined ? {} : { additionalDirectories: [input.requests.dir] }),
|
|
65
66
|
...(execution.executable === undefined ? {} : { pathToClaudeCodeExecutable: execution.executable }),
|
|
66
|
-
...(
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
67
|
+
...(execution.env === undefined && input.requests === undefined
|
|
68
|
+
? {}
|
|
69
|
+
: {
|
|
70
|
+
env: {
|
|
71
|
+
...process.env,
|
|
72
|
+
...execution.env,
|
|
73
|
+
...(input.requests === undefined ? {} : { [AKUMA_REQUESTS_ENV]: input.requests.dir }),
|
|
74
|
+
},
|
|
75
|
+
}),
|
|
71
76
|
permissionMode: mode,
|
|
72
77
|
...(mode === "bypassPermissions" ? { allowDangerouslySkipPermissions: true } : {}),
|
|
73
78
|
settingSources: ["user", "project", "local"],
|
|
74
79
|
...(input.options.model === undefined ? {} : { model: input.options.model }),
|
|
75
80
|
...(input.options.effort === undefined ? {} : { effort: input.options.effort }),
|
|
76
|
-
...(input.options.systemPrompt === undefined || input.options.systemPrompt.length === 0
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
:
|
|
80
|
-
|
|
81
|
+
...(input.options.systemPrompt === undefined || input.options.systemPrompt.length === 0
|
|
82
|
+
? {}
|
|
83
|
+
: {
|
|
84
|
+
systemPrompt: input.options.systemPromptMode === "replace"
|
|
85
|
+
? input.options.systemPrompt
|
|
86
|
+
: { type: "preset", preset: "claude_code", append: input.options.systemPrompt },
|
|
87
|
+
}),
|
|
81
88
|
...(input.session.kind === "fresh" ? {} : { resume: claudeSessionId(input.session.coordinate) }),
|
|
82
89
|
};
|
|
83
90
|
}
|
|
@@ -96,8 +103,7 @@ async function forkClaude(load, execution, input) {
|
|
|
96
103
|
return { session: { sessionId: forked.sessionId } };
|
|
97
104
|
}
|
|
98
105
|
function launchText(input) {
|
|
99
|
-
return [input.body, ...input.launchTells.map((tell) => tell.text)]
|
|
100
|
-
.filter((part) => part.length > 0).join("\n\n");
|
|
106
|
+
return [input.body, ...input.launchTells.map((tell) => tell.text)].filter((part) => part.length > 0).join("\n\n");
|
|
101
107
|
}
|
|
102
108
|
function successfulResult(message, historyId) {
|
|
103
109
|
return {
|
|
@@ -117,9 +123,14 @@ function observeClaudeQuery(context) {
|
|
|
117
123
|
const observation = { tools: new Map() };
|
|
118
124
|
let admit;
|
|
119
125
|
let rejectAdmission;
|
|
120
|
-
const admission = new Promise((resolve, reject) => {
|
|
126
|
+
const admission = new Promise((resolve, reject) => {
|
|
127
|
+
admit = resolve;
|
|
128
|
+
rejectAdmission = reject;
|
|
129
|
+
});
|
|
121
130
|
let settle;
|
|
122
|
-
const completion = new Promise((resolve) => {
|
|
131
|
+
const completion = new Promise((resolve) => {
|
|
132
|
+
settle = resolve;
|
|
133
|
+
});
|
|
123
134
|
let checkpoint = 0, ended = false;
|
|
124
135
|
const settleReceipts = () => {
|
|
125
136
|
if (ended && state.openSubmissions === 0 && accepted.every((tell) => tell.visible))
|
|
@@ -154,8 +165,10 @@ function observeClaudeQuery(context) {
|
|
|
154
165
|
admit();
|
|
155
166
|
}
|
|
156
167
|
emitClaudeMessage(message, events, observation);
|
|
157
|
-
if (message.type === "assistant" &&
|
|
158
|
-
|
|
168
|
+
if (message.type === "assistant" &&
|
|
169
|
+
message.parent_tool_use_id === null &&
|
|
170
|
+
typeof message.uuid === "string" &&
|
|
171
|
+
message.uuid.length > 0)
|
|
159
172
|
historyId = message.uuid;
|
|
160
173
|
if (message.type !== "result")
|
|
161
174
|
continue;
|
|
@@ -193,8 +206,12 @@ function observeClaudeQuery(context) {
|
|
|
193
206
|
return {
|
|
194
207
|
admission,
|
|
195
208
|
completion,
|
|
196
|
-
get ended() {
|
|
197
|
-
|
|
209
|
+
get ended() {
|
|
210
|
+
return ended;
|
|
211
|
+
},
|
|
212
|
+
get checkpoint() {
|
|
213
|
+
return checkpoint;
|
|
214
|
+
},
|
|
198
215
|
flushReceipts,
|
|
199
216
|
settleReceipts,
|
|
200
217
|
};
|
|
@@ -227,8 +244,16 @@ async function driveClaude(load, execution, drive) {
|
|
|
227
244
|
const abortSetup = () => shutDown(signal.reason);
|
|
228
245
|
signal.addEventListener("abort", abortSetup, { once: true });
|
|
229
246
|
const observed = observeClaudeQuery({
|
|
230
|
-
query,
|
|
231
|
-
|
|
247
|
+
query,
|
|
248
|
+
input,
|
|
249
|
+
events,
|
|
250
|
+
receipts,
|
|
251
|
+
accepted,
|
|
252
|
+
state: {
|
|
253
|
+
get openSubmissions() {
|
|
254
|
+
return openSubmissions;
|
|
255
|
+
},
|
|
256
|
+
},
|
|
232
257
|
});
|
|
233
258
|
try {
|
|
234
259
|
await Promise.all([launchAcknowledged, observed.admission]);
|
|
@@ -248,10 +273,12 @@ async function driveClaude(load, execution, drive) {
|
|
|
248
273
|
const ordinal = ++submission;
|
|
249
274
|
return new Promise((resolve, reject) => {
|
|
250
275
|
const pending = { id: tell.id, afterCheckpoint: 0, visible: false };
|
|
251
|
-
void input
|
|
276
|
+
void input
|
|
277
|
+
.push(claudeUserMessage(tell.text), () => {
|
|
252
278
|
pending.afterCheckpoint = observed.checkpoint;
|
|
253
279
|
accepted.push(pending);
|
|
254
|
-
})
|
|
280
|
+
})
|
|
281
|
+
.then(() => {
|
|
255
282
|
openSubmissions -= 1;
|
|
256
283
|
resolve({ kind: "accepted", fence: `claude:${run}:${ordinal}` });
|
|
257
284
|
queueMicrotask(() => {
|
|
@@ -279,8 +306,10 @@ async function driveClaude(load, execution, drive) {
|
|
|
279
306
|
},
|
|
280
307
|
};
|
|
281
308
|
}
|
|
282
|
-
export function createClaudeProvider(loadOrExecution = async () => await import("@anthropic-ai/claude-agent-sdk"), execution = {}) {
|
|
283
|
-
const load = typeof loadOrExecution === "function"
|
|
309
|
+
export function createClaudeProvider(loadOrExecution = async () => (await import("@anthropic-ai/claude-agent-sdk")), execution = {}) {
|
|
310
|
+
const load = typeof loadOrExecution === "function"
|
|
311
|
+
? loadOrExecution
|
|
312
|
+
: async () => (await import("@anthropic-ai/claude-agent-sdk"));
|
|
284
313
|
const selectedExecution = typeof loadOrExecution === "function" ? execution : loadOrExecution;
|
|
285
314
|
return {
|
|
286
315
|
admitOptions: admitClaudeOptions,
|
|
@@ -289,4 +318,4 @@ export function createClaudeProvider(loadOrExecution = async () => await import(
|
|
|
289
318
|
resume: (input) => driveClaude(load, selectedExecution, input),
|
|
290
319
|
};
|
|
291
320
|
}
|
|
292
|
-
export const claudeProvider = createClaudeProvider(async () => await import("@anthropic-ai/claude-agent-sdk"));
|
|
321
|
+
export const claudeProvider = createClaudeProvider(async () => (await import("@anthropic-ai/claude-agent-sdk")));
|
|
@@ -49,8 +49,12 @@ export function createClaudeInput() {
|
|
|
49
49
|
entry.pulled.reject(error);
|
|
50
50
|
};
|
|
51
51
|
return {
|
|
52
|
-
get closed() {
|
|
53
|
-
|
|
52
|
+
get closed() {
|
|
53
|
+
return closed;
|
|
54
|
+
},
|
|
55
|
+
get pending() {
|
|
56
|
+
return queue.length + (previous === undefined ? 0 : 1);
|
|
57
|
+
},
|
|
54
58
|
push(message, onPulled) {
|
|
55
59
|
if (closed)
|
|
56
60
|
return Promise.reject(failure ?? ended());
|
|
@@ -112,11 +112,16 @@ function turnError(value) {
|
|
|
112
112
|
}
|
|
113
113
|
function itemNote(item, kind) {
|
|
114
114
|
switch (kind) {
|
|
115
|
-
case "enteredReviewMode":
|
|
116
|
-
|
|
117
|
-
case "
|
|
118
|
-
|
|
119
|
-
|
|
115
|
+
case "enteredReviewMode":
|
|
116
|
+
return "Entered review mode";
|
|
117
|
+
case "exitedReviewMode":
|
|
118
|
+
return "Exited review mode";
|
|
119
|
+
case "sleep":
|
|
120
|
+
return "Waiting";
|
|
121
|
+
case "subAgentActivity":
|
|
122
|
+
return `Agent activity: ${codexText(item.kind) ?? "updated"}`;
|
|
123
|
+
default:
|
|
124
|
+
return kind;
|
|
120
125
|
}
|
|
121
126
|
}
|
|
122
127
|
function itemToolName(item, kind) {
|
|
@@ -132,9 +137,7 @@ function fileChangeOp(value) {
|
|
|
132
137
|
if (value === "add" || value === "update" || value === "delete")
|
|
133
138
|
return value;
|
|
134
139
|
const record = codexObject(value);
|
|
135
|
-
return record?.type === "add" || record?.type === "update" || record?.type === "delete"
|
|
136
|
-
? record.type
|
|
137
|
-
: undefined;
|
|
140
|
+
return record?.type === "add" || record?.type === "update" || record?.type === "delete" ? record.type : undefined;
|
|
138
141
|
}
|
|
139
142
|
function itemChanges(item) {
|
|
140
143
|
if (!Array.isArray(item.changes))
|
|
@@ -146,11 +149,13 @@ function itemChanges(item) {
|
|
|
146
149
|
if (path === undefined || op === undefined)
|
|
147
150
|
return [];
|
|
148
151
|
const diffstat = typeof change?.diff === "string" ? diffstatFromUnifiedPatch(change.diff) : undefined;
|
|
149
|
-
return [
|
|
152
|
+
return [
|
|
153
|
+
{
|
|
150
154
|
op,
|
|
151
155
|
path,
|
|
152
156
|
...(diffstat === undefined ? {} : { diffstat }),
|
|
153
|
-
}
|
|
157
|
+
},
|
|
158
|
+
];
|
|
154
159
|
});
|
|
155
160
|
}
|
|
156
161
|
function reasoningSummary(item) {
|
|
@@ -158,12 +163,14 @@ function reasoningSummary(item) {
|
|
|
158
163
|
return codexText(item.summary);
|
|
159
164
|
if (!Array.isArray(item.summary))
|
|
160
165
|
return undefined;
|
|
161
|
-
return codexText(item.summary
|
|
166
|
+
return codexText(item.summary
|
|
167
|
+
.map((part) => {
|
|
162
168
|
if (typeof part === "string")
|
|
163
169
|
return part;
|
|
164
170
|
const value = codexObject(part);
|
|
165
|
-
return value?.type === "summary_text" || value?.type === "text" ? codexText(value.text) ?? "" : "";
|
|
166
|
-
})
|
|
171
|
+
return value?.type === "summary_text" || value?.type === "text" ? (codexText(value.text) ?? "") : "";
|
|
172
|
+
})
|
|
173
|
+
.join("\n"));
|
|
167
174
|
}
|
|
168
175
|
function itemToolCall(item, kind) {
|
|
169
176
|
if (kind === "commandExecution") {
|
|
@@ -175,9 +182,7 @@ function itemToolCall(item, kind) {
|
|
|
175
182
|
}
|
|
176
183
|
if (kind === "webSearch") {
|
|
177
184
|
const query = codexText(item.query);
|
|
178
|
-
return query === undefined
|
|
179
|
-
? { kind: "other", display: "web search" }
|
|
180
|
-
: { kind: "search", query, scope: "web" };
|
|
185
|
+
return query === undefined ? { kind: "other", display: "web search" } : { kind: "search", query, scope: "web" };
|
|
181
186
|
}
|
|
182
187
|
if (kind === "fileChange") {
|
|
183
188
|
const changes = itemChanges(item);
|
|
@@ -256,24 +261,42 @@ function emitItem(item, completed, events, state) {
|
|
|
256
261
|
function notificationAction(method, params) {
|
|
257
262
|
const message = codexText(params.message) ?? codexText(params.reason) ?? codexText(params.error);
|
|
258
263
|
switch (method) {
|
|
259
|
-
case "configWarning":
|
|
260
|
-
|
|
261
|
-
case "
|
|
262
|
-
|
|
263
|
-
case "
|
|
264
|
-
|
|
265
|
-
case "
|
|
266
|
-
|
|
267
|
-
case "
|
|
268
|
-
|
|
269
|
-
case "
|
|
270
|
-
|
|
271
|
-
case "
|
|
272
|
-
|
|
273
|
-
case "
|
|
274
|
-
|
|
275
|
-
case "
|
|
276
|
-
|
|
264
|
+
case "configWarning":
|
|
265
|
+
return `Configuration warning: ${message ?? "unknown warning"}`;
|
|
266
|
+
case "deprecationNotice":
|
|
267
|
+
return `Deprecation warning: ${message ?? "deprecated behavior"}`;
|
|
268
|
+
case "externalAgentConfig/import/completed":
|
|
269
|
+
return "External agent configuration import completed";
|
|
270
|
+
case "externalAgentConfig/import/progress":
|
|
271
|
+
return "External agent configuration import updated";
|
|
272
|
+
case "fs/changed":
|
|
273
|
+
return "Filesystem changed";
|
|
274
|
+
case "guardianWarning":
|
|
275
|
+
return `Guardian warning: ${message ?? "action warned"}`;
|
|
276
|
+
case "hook/started":
|
|
277
|
+
return `Hook ${codexText(params.name) ?? codexText(params.hookName) ?? "unknown"} started`;
|
|
278
|
+
case "item/autoApprovalReview/completed":
|
|
279
|
+
return "Action approval review completed";
|
|
280
|
+
case "item/autoApprovalReview/started":
|
|
281
|
+
return "Action approval review started";
|
|
282
|
+
case "model/rerouted":
|
|
283
|
+
return `Model rerouted${message === undefined ? "" : `: ${message}`}`;
|
|
284
|
+
case "thread/goal/cleared":
|
|
285
|
+
return "Goal cleared";
|
|
286
|
+
case "thread/goal/updated":
|
|
287
|
+
return "Goal updated";
|
|
288
|
+
case "thread/realtime/error":
|
|
289
|
+
return `Realtime warning: ${message ?? "unknown error"}`;
|
|
290
|
+
case "turn/moderationMetadata":
|
|
291
|
+
return "Moderation updated";
|
|
292
|
+
case "warning":
|
|
293
|
+
return `Warning: ${message ?? "unknown warning"}`;
|
|
294
|
+
case "windows/worldWritableWarning":
|
|
295
|
+
return `Filesystem warning: ${message ?? "world-writable path"}`;
|
|
296
|
+
case "windowsSandbox/setupCompleted":
|
|
297
|
+
return "Windows sandbox setup completed";
|
|
298
|
+
default:
|
|
299
|
+
return method;
|
|
277
300
|
}
|
|
278
301
|
}
|
|
279
302
|
function observeError(params, state, events) {
|
|
@@ -303,7 +326,8 @@ export function codexNotificationResult(notification, state, events) {
|
|
|
303
326
|
const disposition = CODEX_NOTIFICATION_DISPOSITIONS[method];
|
|
304
327
|
const params = codexObject(notification.params) ?? {};
|
|
305
328
|
switch (disposition) {
|
|
306
|
-
case "drop":
|
|
329
|
+
case "drop":
|
|
330
|
+
return undefined;
|
|
307
331
|
case "note":
|
|
308
332
|
events.emit(noteEvent(notificationAction(method, params)));
|
|
309
333
|
return undefined;
|
|
@@ -323,6 +347,7 @@ export function codexNotificationResult(notification, state, events) {
|
|
|
323
347
|
case "error":
|
|
324
348
|
observeError(params, state, events);
|
|
325
349
|
return undefined;
|
|
326
|
-
case "terminal":
|
|
350
|
+
case "terminal":
|
|
351
|
+
return terminalResult(params, state);
|
|
327
352
|
}
|
|
328
353
|
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { LineRpcProcess } from "../../../runtime/proc/line-rpc.js";
|
|
2
2
|
import { AgentEventChannel, AKUMA_REQUESTS_ENV, } from "../../provider.js";
|
|
3
|
-
import { codexNotificationResult, codexObject, codexText
|
|
3
|
+
import { codexNotificationResult, codexObject, codexText } from "./events.js";
|
|
4
4
|
export { CODEX_ITEM_DISPOSITIONS, CODEX_NOTIFICATION_DISPOSITIONS } from "./events.js";
|
|
5
5
|
function diagnostic(error) {
|
|
6
6
|
return error instanceof Error ? error.message : String(error);
|
|
@@ -83,8 +83,14 @@ async function admitTurn(server, input, state, events, config) {
|
|
|
83
83
|
events.emit({ type: "session", coordinate: { sessionId: state.threadId } });
|
|
84
84
|
state.turnId = turnId(await server.request("turn/start", {
|
|
85
85
|
threadId: state.threadId,
|
|
86
|
-
input: [
|
|
87
|
-
|
|
86
|
+
input: [
|
|
87
|
+
{
|
|
88
|
+
type: "text",
|
|
89
|
+
text: [input.body, ...input.launchTells.map((tell) => tell.text)]
|
|
90
|
+
.filter((part) => part.length > 0)
|
|
91
|
+
.join("\n\n"),
|
|
92
|
+
},
|
|
93
|
+
],
|
|
88
94
|
...(input.options.model === undefined ? {} : { model: input.options.model }),
|
|
89
95
|
...(input.options.effort === undefined ? {} : { effort: input.options.effort }),
|
|
90
96
|
approvalPolicy: "never",
|
|
@@ -126,15 +132,21 @@ async function startCodex(execution, input) {
|
|
|
126
132
|
const server = new LineRpcProcess({
|
|
127
133
|
argv: [execution.executable ?? "codex", "app-server", "--listen", "stdio://"],
|
|
128
134
|
cwd: input.cwd,
|
|
129
|
-
...(
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
135
|
+
...(execution.env === undefined && input.requests === undefined
|
|
136
|
+
? {}
|
|
137
|
+
: {
|
|
138
|
+
env: {
|
|
139
|
+
...process.env,
|
|
140
|
+
...execution.env,
|
|
141
|
+
...(input.requests === undefined ? {} : { [AKUMA_REQUESTS_ENV]: input.requests.dir }),
|
|
142
|
+
},
|
|
143
|
+
}),
|
|
134
144
|
});
|
|
135
145
|
const state = { settled: false, tools: new Map() };
|
|
136
146
|
let settle;
|
|
137
|
-
const completion = new Promise((resolve) => {
|
|
147
|
+
const completion = new Promise((resolve) => {
|
|
148
|
+
settle = resolve;
|
|
149
|
+
});
|
|
138
150
|
let terminal;
|
|
139
151
|
const finish = (result) => {
|
|
140
152
|
if (terminal !== undefined)
|
|
@@ -162,7 +174,9 @@ async function startCodex(execution, input) {
|
|
|
162
174
|
kind: "failed",
|
|
163
175
|
diagnostic: `codex app-server made forbidden interactive request ${request.method}`,
|
|
164
176
|
}));
|
|
165
|
-
const abortSetup = () => {
|
|
177
|
+
const abortSetup = () => {
|
|
178
|
+
void server.close(true);
|
|
179
|
+
};
|
|
166
180
|
signal.addEventListener("abort", abortSetup, { once: true });
|
|
167
181
|
try {
|
|
168
182
|
signal.throwIfAborted();
|
|
@@ -194,9 +208,7 @@ async function startCodex(execution, input) {
|
|
|
194
208
|
};
|
|
195
209
|
}
|
|
196
210
|
export function createCodexAppServerProvider(input = "codex") {
|
|
197
|
-
const execution = typeof input === "string"
|
|
198
|
-
? { name: "codex-app-server", kind: "codex-app-server", executable: input }
|
|
199
|
-
: input;
|
|
211
|
+
const execution = typeof input === "string" ? { name: "codex-app-server", kind: "codex-app-server", executable: input } : input;
|
|
200
212
|
return {
|
|
201
213
|
admitOptions(options) {
|
|
202
214
|
return {
|
|
@@ -52,51 +52,50 @@ function fileChangeCall(name, input) {
|
|
|
52
52
|
if (name !== "search_replace")
|
|
53
53
|
return undefined;
|
|
54
54
|
const path = nonblank(input.file_path);
|
|
55
|
-
return path === undefined
|
|
56
|
-
? undefined
|
|
57
|
-
: { kind: "fileChange", changes: [{ op: "unspecified", path }] };
|
|
55
|
+
return path === undefined ? undefined : { kind: "fileChange", changes: [{ op: "unspecified", path }] };
|
|
58
56
|
}
|
|
59
57
|
export const interpretGrokTool = (update) => {
|
|
60
58
|
const name = nativeName(update);
|
|
61
59
|
const input = object(update.rawInput);
|
|
62
60
|
if (name === undefined || input === undefined)
|
|
63
61
|
return undefined;
|
|
64
|
-
return readCall(name, input)
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
62
|
+
return (readCall(name, input) ??
|
|
63
|
+
contentSearchCall(name, input) ??
|
|
64
|
+
runCall(name, input) ??
|
|
65
|
+
webSearchCall(name, input) ??
|
|
66
|
+
fileChangeCall(name, input));
|
|
69
67
|
};
|
|
70
68
|
function optionAdmission(options) {
|
|
71
69
|
if (options.network !== undefined) {
|
|
72
70
|
return { kind: "refused", diagnostic: "Grok Build does not support the network option" };
|
|
73
71
|
}
|
|
74
|
-
if (options.systemPrompt !== undefined
|
|
75
|
-
&& options.systemPrompt.length > 0
|
|
76
|
-
&& options.systemPromptMode === undefined) {
|
|
72
|
+
if (options.systemPrompt !== undefined && options.systemPrompt.length > 0 && options.systemPromptMode === undefined) {
|
|
77
73
|
return { kind: "refused", diagnostic: "Grok Build does not support the systemPrompt option" };
|
|
78
74
|
}
|
|
79
75
|
return {
|
|
80
76
|
kind: "admitted",
|
|
81
77
|
options,
|
|
82
|
-
...(options.readonly === undefined
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
78
|
+
...(options.readonly === undefined
|
|
79
|
+
? {}
|
|
80
|
+
: {
|
|
81
|
+
readonly: {
|
|
82
|
+
enforcement: "none",
|
|
83
|
+
diagnostic: "Grok Build cannot remove task-surface mutation capabilities",
|
|
84
|
+
},
|
|
85
|
+
}),
|
|
88
86
|
};
|
|
89
87
|
}
|
|
90
|
-
function grokSessionMeta(options) {
|
|
88
|
+
function grokSessionMeta(config, options) {
|
|
89
|
+
const configured = config === undefined ? {} : { freshSessionMeta: config, loadSessionMeta: config };
|
|
91
90
|
if (options.systemPrompt === undefined || options.systemPrompt.length === 0)
|
|
92
|
-
return
|
|
91
|
+
return configured;
|
|
93
92
|
if (options.systemPromptMode === "append")
|
|
94
|
-
return { freshSessionMeta: { rules: options.systemPrompt } };
|
|
93
|
+
return { ...configured, freshSessionMeta: { ...config, rules: options.systemPrompt } };
|
|
95
94
|
if (options.systemPromptMode === "replace") {
|
|
96
95
|
const meta = { systemPromptOverride: options.systemPrompt };
|
|
97
|
-
return { freshSessionMeta: meta, loadSessionMeta: meta };
|
|
96
|
+
return { ...configured, freshSessionMeta: { ...config, ...meta }, loadSessionMeta: { ...config, ...meta } };
|
|
98
97
|
}
|
|
99
|
-
return
|
|
98
|
+
return configured;
|
|
100
99
|
}
|
|
101
100
|
function argv(execution, options) {
|
|
102
101
|
if (execution.executable === undefined)
|
|
@@ -132,8 +131,6 @@ function withInterject(live) {
|
|
|
132
131
|
export function createGrokBuildProvider(execution, dependencies = {}) {
|
|
133
132
|
if (execution.executable === undefined)
|
|
134
133
|
throw new TypeError("Grok Build provider execution requires executable");
|
|
135
|
-
if (execution.config !== undefined)
|
|
136
|
-
throw new TypeError("Grok Build provider does not support execution config");
|
|
137
134
|
const drive = async (input) => {
|
|
138
135
|
const launch = {
|
|
139
136
|
argv: argv(execution, input.options),
|
|
@@ -142,7 +139,7 @@ export function createGrokBuildProvider(execution, dependencies = {}) {
|
|
|
142
139
|
return withInterject(await startAcpSession(launch, input, {
|
|
143
140
|
...dependencies,
|
|
144
141
|
interpretTool: interpretGrokTool,
|
|
145
|
-
...grokSessionMeta(input.options),
|
|
142
|
+
...grokSessionMeta(execution.config, input.options),
|
|
146
143
|
}));
|
|
147
144
|
};
|
|
148
145
|
return {
|
|
@@ -1,27 +1,11 @@
|
|
|
1
1
|
import { decodeProviderRecipe } from "../provider-recipe.js";
|
|
2
|
-
import { decodeAcpConfig } from "./acp/config.js";
|
|
3
2
|
export function decodeProviderExecution(input) {
|
|
4
3
|
const decoded = decodeProviderRecipe(input);
|
|
5
|
-
if ((decoded.kind === "claude-agent-sdk" || decoded.kind === "opencode-sdk") && decoded.config !== undefined) {
|
|
6
|
-
throw new TypeError(`provider execution config is unsupported by ${decoded.kind}`);
|
|
7
|
-
}
|
|
8
|
-
if (decoded.kind === "pi") {
|
|
9
|
-
if (decoded.executable !== undefined || decoded.config !== undefined) {
|
|
10
|
-
throw new TypeError("Pi provider does not support executable or config");
|
|
11
|
-
}
|
|
12
|
-
if (decoded.env !== undefined && Object.keys(decoded.env).length > 0) {
|
|
13
|
-
throw new TypeError("env injection not supported for provider pi");
|
|
14
|
-
}
|
|
15
|
-
}
|
|
16
|
-
if (decoded.kind === "grok-build" && decoded.config !== undefined) {
|
|
17
|
-
throw new TypeError("Grok Build does not support execution config");
|
|
18
|
-
}
|
|
19
|
-
const config = decoded.kind === "acp" ? decodeAcpConfig(decoded.config) : decoded.config;
|
|
20
4
|
return Object.freeze({
|
|
21
5
|
name: decoded.name,
|
|
22
6
|
kind: decoded.kind,
|
|
23
7
|
...(decoded.executable === undefined ? {} : { executable: decoded.executable }),
|
|
24
|
-
...(config === undefined ? {} : { config }),
|
|
8
|
+
...(decoded.config === undefined ? {} : { config: decoded.config }),
|
|
25
9
|
...(decoded.env === undefined ? {} : { env: decoded.env }),
|
|
26
10
|
});
|
|
27
11
|
}
|
|
@@ -30,7 +14,7 @@ async function adapterFor(execution) {
|
|
|
30
14
|
return (await import("./acp/index.js")).createAcpProvider(execution);
|
|
31
15
|
if (execution.kind === "claude-agent-sdk") {
|
|
32
16
|
const { claudeProvider, createClaudeProvider } = await import("./claude/index.js");
|
|
33
|
-
return execution.executable === undefined && execution.env === undefined
|
|
17
|
+
return execution.executable === undefined && execution.config === undefined && execution.env === undefined
|
|
34
18
|
? claudeProvider
|
|
35
19
|
: createClaudeProvider(execution);
|
|
36
20
|
}
|
|
@@ -46,7 +46,8 @@ const RUNTIME_DROPPED_EVENT_KINDS = new Set([
|
|
|
46
46
|
]);
|
|
47
47
|
function object(value) {
|
|
48
48
|
return value !== null && typeof value === "object" && !Array.isArray(value)
|
|
49
|
-
? value
|
|
49
|
+
? value
|
|
50
|
+
: undefined;
|
|
50
51
|
}
|
|
51
52
|
function text(value) {
|
|
52
53
|
return typeof value === "string" && value.length > 0 ? value : undefined;
|
|
@@ -83,8 +84,7 @@ function editCall(input, metadata) {
|
|
|
83
84
|
}
|
|
84
85
|
function writeCall(input, metadata) {
|
|
85
86
|
const path = text(metadata?.filepath) ?? text(input?.filePath);
|
|
86
|
-
const op = metadata?.exists === false ? "add"
|
|
87
|
-
: metadata?.exists === true ? "update" : undefined;
|
|
87
|
+
const op = metadata?.exists === false ? "add" : metadata?.exists === true ? "update" : undefined;
|
|
88
88
|
return path === undefined || op === undefined ? undefined : fileChange([change(op, path, undefined)]);
|
|
89
89
|
}
|
|
90
90
|
function applyPatchFile(value) {
|
|
@@ -92,10 +92,13 @@ function applyPatchFile(value) {
|
|
|
92
92
|
if (file === undefined)
|
|
93
93
|
return undefined;
|
|
94
94
|
const type = file.type;
|
|
95
|
-
const op = type === "add"
|
|
96
|
-
|
|
95
|
+
const op = type === "add"
|
|
96
|
+
? "add"
|
|
97
|
+
: type === "delete"
|
|
98
|
+
? "delete"
|
|
97
99
|
: type === "update" || type === "modify" || type === "move"
|
|
98
|
-
? "update"
|
|
100
|
+
? "update"
|
|
101
|
+
: undefined;
|
|
99
102
|
const path = type === "move" ? text(file.movePath) : text(file.filePath);
|
|
100
103
|
return op === undefined || path === undefined ? undefined : change(op, path, diffstat(file));
|
|
101
104
|
}
|
|
@@ -115,9 +118,7 @@ function strongerCall(previous, next) {
|
|
|
115
118
|
return next;
|
|
116
119
|
}
|
|
117
120
|
function runCall(name, value) {
|
|
118
|
-
return name === "bash" || name === "shell"
|
|
119
|
-
? { kind: "run", command: text(value?.command) ?? name }
|
|
120
|
-
: undefined;
|
|
121
|
+
return name === "bash" || name === "shell" ? { kind: "run", command: text(value?.command) ?? name } : undefined;
|
|
121
122
|
}
|
|
122
123
|
function readCall(name, value) {
|
|
123
124
|
if (name !== "read")
|
|
@@ -189,9 +190,16 @@ function resultFor(state, failed) {
|
|
|
189
190
|
const exit = object(state.metadata)?.exit;
|
|
190
191
|
const exitCode = typeof exit === "number" && Number.isInteger(exit) ? exit : undefined;
|
|
191
192
|
if (failed) {
|
|
192
|
-
return {
|
|
193
|
+
return {
|
|
194
|
+
status: "error",
|
|
195
|
+
message: text(state.error) ?? "OpenCode tool failed",
|
|
196
|
+
...(exitCode === undefined ? {} : { exitCode }),
|
|
197
|
+
};
|
|
193
198
|
}
|
|
194
|
-
return {
|
|
199
|
+
return {
|
|
200
|
+
status: exitCode !== undefined && exitCode !== 0 ? "error" : "ok",
|
|
201
|
+
...(exitCode === undefined ? {} : { exitCode }),
|
|
202
|
+
};
|
|
195
203
|
}
|
|
196
204
|
function mapToolPart(part, events, state) {
|
|
197
205
|
if (!belongs(part, state))
|
|
@@ -202,8 +210,9 @@ function mapToolPart(part, events, state) {
|
|
|
202
210
|
if (id === undefined || name === undefined || toolState === undefined)
|
|
203
211
|
return;
|
|
204
212
|
const next = callFor(name, toolState.input, toolState.metadata);
|
|
205
|
-
if ((toolState.status === "pending" || toolState.status === "running")
|
|
206
|
-
|
|
213
|
+
if ((toolState.status === "pending" || toolState.status === "running") &&
|
|
214
|
+
!state.tools.has(id) &&
|
|
215
|
+
!state.completedTools.has(id)) {
|
|
207
216
|
if (next === undefined)
|
|
208
217
|
return;
|
|
209
218
|
const observed = { name, call: next };
|
|
@@ -251,17 +260,19 @@ function mapSessionError(properties, events, state) {
|
|
|
251
260
|
function mapTodo(properties, events, state) {
|
|
252
261
|
if (properties.sessionID !== state.sessionId || !Array.isArray(properties.todos))
|
|
253
262
|
return;
|
|
254
|
-
const summary = properties.todos
|
|
263
|
+
const summary = properties.todos
|
|
264
|
+
.flatMap((value) => {
|
|
255
265
|
const todo = object(value);
|
|
256
266
|
const content = text(todo?.content);
|
|
257
267
|
return content === undefined ? [] : [`${text(todo?.status) ?? "todo"}: ${content}`];
|
|
258
|
-
})
|
|
268
|
+
})
|
|
269
|
+
.join("; ");
|
|
259
270
|
if (summary.length > 0)
|
|
260
271
|
events.emit(noteEvent(summary));
|
|
261
272
|
}
|
|
262
273
|
function ignoredEvent(type) {
|
|
263
|
-
return typeof type === "string"
|
|
264
|
-
|
|
274
|
+
return (typeof type === "string" &&
|
|
275
|
+
(OPENCODE_EVENT_DISPOSITIONS[type] === "dropped" || RUNTIME_DROPPED_EVENT_KINDS.has(type)));
|
|
265
276
|
}
|
|
266
277
|
export function mapEvent(value, events, state) {
|
|
267
278
|
const event = object(value);
|
|
@@ -276,7 +287,10 @@ export function mapEvent(value, events, state) {
|
|
|
276
287
|
}
|
|
277
288
|
if (event.type === "message.updated") {
|
|
278
289
|
const info = object(properties.info);
|
|
279
|
-
if (info !== undefined &&
|
|
290
|
+
if (info !== undefined &&
|
|
291
|
+
info.sessionID === state.sessionId &&
|
|
292
|
+
info.role === "assistant" &&
|
|
293
|
+
info.error !== undefined) {
|
|
280
294
|
state.failure = diagnostic(info.error);
|
|
281
295
|
}
|
|
282
296
|
return;
|