@astrosheep/keiyaku 4.6.7 → 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 +46 -16
- 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/plugins/pi/keiyaku.ts +0 -5
- 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-call.d.ts +2 -0
- package/build/src/akuma/akuma-call.js +8 -2
- package/build/src/akuma/akuma-instance.d.ts +14 -1
- package/build/src/akuma/akuma-instance.js +37 -7
- package/build/src/akuma/akuma-observe.d.ts +33 -8
- package/build/src/akuma/akuma-observe.js +89 -63
- package/build/src/akuma/akuma-owner.d.ts +14 -2
- package/build/src/akuma/akuma-owner.js +49 -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 +52 -16
- package/build/src/akuma/akuma.js +10 -10
- package/build/src/akuma/allowed.d.ts +7 -12
- package/build/src/akuma/allowed.js +13 -4
- package/build/src/akuma/archetype.d.ts +7 -15
- package/build/src/akuma/archetype.js +36 -35
- package/build/src/akuma/body-supervisor.d.ts +5 -5
- package/build/src/akuma/body-supervisor.js +22 -20
- package/build/src/akuma/body.d.ts +5 -3
- package/build/src/akuma/body.js +57 -8
- package/build/src/akuma/call-request.d.ts +30 -32
- package/build/src/akuma/call-request.js +10 -3
- package/build/src/akuma/caller.d.ts +39 -0
- package/build/src/akuma/caller.js +36 -0
- package/build/src/akuma/dispatch-association.d.ts +0 -1
- package/build/src/akuma/dispatch-association.js +0 -3
- 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/facts.d.ts +16 -12
- package/build/src/akuma/heart/facts.js +8 -0
- package/build/src/akuma/heart/index.d.ts +61 -9
- package/build/src/akuma/heart/index.js +89 -24
- package/build/src/akuma/heart/rows.d.ts +3 -3
- package/build/src/akuma/heart/rows.js +5 -3
- package/build/src/akuma/heart/soul.d.ts +10 -1
- package/build/src/akuma/heart/soul.js +34 -24
- package/build/src/akuma/heart/storage.d.ts +20 -0
- package/build/src/akuma/heart/storage.js +62 -3
- package/build/src/akuma/heart/timeline.d.ts +7 -0
- package/build/src/akuma/heart/timeline.js +10 -0
- package/build/src/akuma/identity.d.ts +0 -1
- package/build/src/akuma/identity.js +2 -5
- package/build/src/akuma/index.d.ts +6 -2
- package/build/src/akuma/index.js +1 -0
- package/build/src/akuma/nuke.js +6 -28
- package/build/src/akuma/projection.d.ts +25 -11
- package/build/src/akuma/projection.js +24 -7
- package/build/src/akuma/provider-recipe.d.ts +18 -6
- package/build/src/akuma/provider-recipe.js +24 -1
- package/build/src/akuma/provider.d.ts +31 -10
- package/build/src/akuma/provider.js +105 -14
- package/build/src/akuma/providers/acp/events.js +29 -19
- package/build/src/akuma/providers/acp/index.js +2 -3
- package/build/src/akuma/providers/claude/events.js +110 -69
- package/build/src/akuma/providers/claude/index.d.ts +2 -2
- package/build/src/akuma/providers/claude/index.js +4 -8
- package/build/src/akuma/providers/codex-app-server/events.js +17 -2
- package/build/src/akuma/providers/codex-app-server/index.js +17 -11
- package/build/src/akuma/providers/decode.d.ts +33 -0
- package/build/src/akuma/providers/decode.js +65 -0
- package/build/src/akuma/providers/execution-environment.d.ts +2 -1
- package/build/src/akuma/providers/execution-environment.js +3 -0
- package/build/src/akuma/providers/grok-build/index.js +16 -48
- package/build/src/akuma/providers/index.js +2 -0
- package/build/src/akuma/providers/lifecycle.d.ts +9 -0
- package/build/src/akuma/providers/lifecycle.js +10 -0
- 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 +146 -296
- package/build/src/akuma/providers/opencode-sdk/index.js +270 -431
- 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 -84
- package/build/src/akuma/providers/paseo/events.d.ts +33 -0
- package/build/src/akuma/providers/paseo/events.js +204 -0
- package/build/src/akuma/providers/paseo/index.d.ts +9 -0
- package/build/src/akuma/providers/paseo/index.js +357 -0
- package/build/src/akuma/providers/pi/events.d.ts +2 -0
- package/build/src/akuma/providers/pi/events.js +36 -38
- package/build/src/akuma/providers/pi/index.js +21 -35
- package/build/src/akuma/publication.d.ts +2 -0
- package/build/src/akuma/publication.js +5 -0
- package/build/src/akuma/request-lifecycle.d.ts +4 -2
- package/build/src/akuma/request-lifecycle.js +27 -12
- 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/requests.d.ts +3 -1
- package/build/src/akuma/requests.js +32 -0
- package/build/src/akuma/selection-observation.d.ts +129 -53
- package/build/src/akuma/selection-observation.js +3 -9
- package/build/src/akuma/turn-drive.d.ts +3 -0
- package/build/src/akuma/turn-drive.js +28 -10
- package/build/src/akuma-body.js +12 -22
- package/build/src/cli/akuma-caller.d.ts +3 -0
- package/build/src/cli/akuma-caller.js +31 -0
- package/build/src/cli/commands/akuma-grammar.js +10 -16
- package/build/src/cli/commands/akuma.js +25 -55
- package/build/src/cli/commands/contract-grammar.d.ts +9 -7
- package/build/src/cli/commands/contract-grammar.js +40 -47
- package/build/src/cli/commands/contract-help.d.ts +17 -7
- package/build/src/cli/commands/contract-help.js +50 -11
- package/build/src/cli/commands/contract.js +34 -63
- 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} +87 -164
- package/build/src/cli/coordinates.d.ts +1 -1
- package/build/src/cli/coordinates.js +1 -1
- package/build/src/cli/parse.d.ts +5 -5
- 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 +4 -7
- package/build/src/cli/render/catalog.js +5 -5
- package/build/src/cli/render/contract-history.js +3 -6
- package/build/src/cli/render/contract.js +17 -52
- package/build/src/cli/render/debt.d.ts +28 -0
- package/build/src/cli/render/{task.js → debt.js} +55 -133
- 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/render/receipt.js +3 -10
- package/build/src/cli/runtime.d.ts +1 -1
- package/build/src/cli/runtime.js +14 -20
- package/build/src/cli/scan.d.ts +1 -1
- package/build/src/cli/selectors.d.ts +3 -6
- package/build/src/cli/selectors.js +22 -53
- 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/dispatch/index.d.ts +3 -3
- package/build/src/dispatch/index.js +1 -2
- package/build/src/git/observe.d.ts +6 -2
- package/build/src/git/observe.js +6 -2
- package/build/src/identity/coordinates.d.ts +1 -1
- package/build/src/index.d.ts +17 -17
- package/build/src/index.js +11 -11
- package/build/src/kanshi/index.d.ts +2 -2
- package/build/src/kanshi/read.js +54 -39
- package/build/src/kanshi/report.d.ts +7 -7
- package/build/src/kanshi/select.js +4 -4
- package/build/src/library/address.js +2 -4
- package/build/src/library/akuma-creation.d.ts +5 -1
- package/build/src/library/akuma-creation.js +27 -47
- package/build/src/library/akumas.d.ts +7 -7
- package/build/src/library/akumas.js +13 -9
- package/build/src/library/bind.d.ts +17 -17
- package/build/src/library/bind.js +16 -12
- package/build/src/library/contract-address.d.ts +9 -0
- package/build/src/library/contract-address.js +71 -0
- package/build/src/library/contract-composition.d.ts +4 -7
- package/build/src/library/contract-composition.js +6 -18
- package/build/src/library/contract-creation.d.ts +3 -5
- package/build/src/library/contract-creation.js +24 -22
- package/build/src/library/contract-execution.js +21 -26
- package/build/src/library/contract-outcomes.d.ts +2 -14
- package/build/src/library/contract-outcomes.js +2 -13
- package/build/src/library/contract-types.d.ts +38 -4
- package/build/src/library/delivery.d.ts +0 -2
- package/build/src/library/delivery.js +2 -5
- 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/keiyaku.d.ts +0 -5
- package/build/src/library/keiyaku.js +6 -12
- package/build/src/library/nuke.js +3 -3
- package/build/src/library/outcome.d.ts +626 -625
- package/build/src/library/outcome.js +13 -3
- package/build/src/library/reconcile.js +8 -16
- package/build/src/library/refusal.d.ts +2 -2
- package/build/src/library/repo.d.ts +3 -2
- package/build/src/library/repo.js +10 -5
- package/build/src/library/selection.d.ts +5 -8
- package/build/src/library/selection.js +22 -73
- package/build/src/plugin/akuma-signals.d.ts +2 -0
- package/build/src/plugin/akuma-signals.js +4 -0
- package/build/src/plugin/public.d.ts +32 -2
- package/build/src/plugin/runtime.js +5 -3
- package/build/src/protocol/amend.js +3 -2
- package/build/src/protocol/attempt.js +3 -8
- package/build/src/protocol/bind.d.ts +2 -2
- package/build/src/protocol/bind.js +1 -1
- package/build/src/protocol/deliver.js +3 -3
- package/build/src/protocol/operations.d.ts +1 -3
- package/build/src/protocol/operations.js +0 -8
- package/build/src/protocol/outcome.d.ts +1 -2
- package/build/src/protocol/outcome.js +1 -13
- package/build/src/protocol/placement.js +3 -10
- package/build/src/protocol/read/status.js +31 -70
- package/build/src/protocol/reintegrate.js +3 -10
- package/build/src/protocol/review.js +3 -3
- package/build/src/protocol/run.d.ts +5 -1
- package/build/src/protocol/run.js +3 -3
- 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 +19 -9
- 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/plugins/pi/keiyaku.ts +57 -0
- package/skills/keiyaku/SKILL.md +43 -0
- package/skills/keiyaku-akuma/SKILL.md +130 -0
- package/skills/keiyaku-akuma/references/automation.md +269 -0
- package/skills/keiyaku-babysit/SKILL.md +65 -0
- package/skills/keiyaku-bind/SKILL.md +216 -0
- package/skills/keiyaku-bind/agents/openai.yaml +4 -0
- package/skills/keiyaku-debt/SKILL.md +91 -0
- package/skills/keiyaku-workflow/SKILL.md +129 -0
- 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/amend.d.ts +0 -12
- package/build/src/cli/commands/amend.js +0 -10
- package/build/src/cli/commands/bind.d.ts +0 -11
- package/build/src/cli/commands/bind.js +0 -23
- 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 -41
- package/build/src/dispatch/association.d.ts +0 -1
- package/build/src/dispatch/association.js +0 -1
- 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/build/src/{task → debt}/operation-types.js +0 -0
|
@@ -1,322 +1,172 @@
|
|
|
1
|
-
import { noteEvent, otherToolCall } from "../../provider.js";
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
"installation.updated": "dropped",
|
|
5
|
-
"installation.update-available": "dropped",
|
|
6
|
-
"lsp.client.diagnostics": "dropped",
|
|
7
|
-
"lsp.updated": "dropped",
|
|
8
|
-
"message.updated": "mapped",
|
|
9
|
-
"message.removed": "dropped",
|
|
10
|
-
"message.part.updated": "mapped",
|
|
11
|
-
"message.part.removed": "dropped",
|
|
12
|
-
"permission.updated": "dropped",
|
|
13
|
-
"permission.replied": "dropped",
|
|
14
|
-
"session.status": "dropped",
|
|
15
|
-
"session.idle": "dropped",
|
|
16
|
-
"session.compacted": "note",
|
|
17
|
-
"file.edited": "dropped",
|
|
18
|
-
"todo.updated": "mapped",
|
|
19
|
-
"command.executed": "dropped",
|
|
20
|
-
"session.created": "dropped",
|
|
21
|
-
"session.updated": "dropped",
|
|
22
|
-
"session.deleted": "dropped",
|
|
23
|
-
"session.diff": "dropped",
|
|
24
|
-
"session.error": "mapped",
|
|
25
|
-
"file.watcher.updated": "dropped",
|
|
26
|
-
"vcs.branch.updated": "dropped",
|
|
27
|
-
"tui.prompt.append": "dropped",
|
|
28
|
-
"tui.command.execute": "dropped",
|
|
29
|
-
"tui.toast.show": "dropped",
|
|
30
|
-
"pty.created": "dropped",
|
|
31
|
-
"pty.updated": "dropped",
|
|
32
|
-
"pty.exited": "dropped",
|
|
33
|
-
"pty.deleted": "dropped",
|
|
34
|
-
"server.connected": "dropped",
|
|
35
|
-
};
|
|
36
|
-
// OpenCode may emit these server-side metadata events before the generated
|
|
37
|
-
// SDK union catches up. They are all non-narrative and therefore remain drop
|
|
38
|
-
// dispositions; genuinely new execution events still use the unknown arm.
|
|
39
|
-
const RUNTIME_DROPPED_EVENT_KINDS = new Set([
|
|
40
|
-
"plugin.added",
|
|
41
|
-
"catalog.updated",
|
|
42
|
-
"reference.updated",
|
|
43
|
-
"integration.updated",
|
|
44
|
-
"server.heartbeat",
|
|
45
|
-
"message.part.delta",
|
|
46
|
-
]);
|
|
47
|
-
function object(value) {
|
|
48
|
-
return value !== null && typeof value === "object" && !Array.isArray(value)
|
|
49
|
-
? value
|
|
50
|
-
: undefined;
|
|
51
|
-
}
|
|
52
|
-
function text(value) {
|
|
53
|
-
return typeof value === "string" && value.length > 0 ? value : undefined;
|
|
54
|
-
}
|
|
55
|
-
function diagnostic(value) {
|
|
1
|
+
import { modelEvent, noteEvent, otherToolCall, } from "../../provider.js";
|
|
2
|
+
import { nonnegativeCount, object, positiveLine, stringValue, text } from "../decode.js";
|
|
3
|
+
export function diagnostic(value) {
|
|
56
4
|
const data = object(value);
|
|
57
|
-
|
|
58
|
-
return text(nested?.message) ?? text(data?.message) ?? "OpenCode session failed";
|
|
5
|
+
return text(data?.message) ?? text(object(data?.data)?.message) ?? "OpenCode execution failed";
|
|
59
6
|
}
|
|
60
|
-
function
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
7
|
+
function callFor(name, input) {
|
|
8
|
+
const value = object(input);
|
|
9
|
+
if (name === "shell")
|
|
10
|
+
return { kind: "run", command: text(value?.command) ?? name };
|
|
11
|
+
if (name === "read") {
|
|
12
|
+
const path = text(value?.filePath) ?? text(value?.path);
|
|
13
|
+
if (path !== undefined)
|
|
14
|
+
return {
|
|
15
|
+
kind: "read",
|
|
16
|
+
path,
|
|
17
|
+
...(positiveLine(value?.offset) === undefined ? {} : { offset: positiveLine(value?.offset) }),
|
|
18
|
+
...(positiveLine(value?.limit) === undefined ? {} : { limit: positiveLine(value?.limit) }),
|
|
19
|
+
};
|
|
20
|
+
}
|
|
21
|
+
if (name === "grep" || name === "glob") {
|
|
22
|
+
const query = text(value?.pattern);
|
|
23
|
+
const path = text(value?.path);
|
|
24
|
+
if (query !== undefined)
|
|
25
|
+
return {
|
|
26
|
+
kind: "search",
|
|
27
|
+
scope: name === "glob" ? "files" : "content",
|
|
28
|
+
query,
|
|
29
|
+
...(path === undefined ? {} : { path }),
|
|
30
|
+
};
|
|
31
|
+
}
|
|
32
|
+
if (name === "edit") {
|
|
33
|
+
const path = text(value?.path);
|
|
34
|
+
if (path !== undefined)
|
|
35
|
+
return { kind: "fileChange", changes: [{ op: "update", path }] };
|
|
36
|
+
}
|
|
37
|
+
return otherToolCall(name, input);
|
|
65
38
|
}
|
|
66
|
-
function
|
|
67
|
-
|
|
39
|
+
function observedChanges(metadata) {
|
|
40
|
+
const files = object(metadata)?.files;
|
|
41
|
+
if (!Array.isArray(files))
|
|
68
42
|
return undefined;
|
|
69
|
-
const
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
43
|
+
const changes = files.flatMap((item) => {
|
|
44
|
+
const file = object(item);
|
|
45
|
+
const path = text(file?.file);
|
|
46
|
+
const status = file?.status;
|
|
47
|
+
if (path === undefined || (status !== "added" && status !== "deleted" && status !== "modified"))
|
|
48
|
+
return [];
|
|
49
|
+
const added = nonnegativeCount(file?.additions);
|
|
50
|
+
const removed = nonnegativeCount(file?.deletions);
|
|
51
|
+
const patch = stringValue(file?.patch);
|
|
52
|
+
return [
|
|
53
|
+
{
|
|
54
|
+
op: status === "added" ? "add" : status === "deleted" ? "delete" : "update",
|
|
55
|
+
path,
|
|
56
|
+
...(added === undefined || removed === undefined ? {} : { diffstat: { added, removed } }),
|
|
57
|
+
...(patch === undefined ? {} : { patch }),
|
|
58
|
+
},
|
|
59
|
+
];
|
|
60
|
+
});
|
|
74
61
|
return changes.length === 0 ? undefined : { kind: "fileChange", changes };
|
|
75
62
|
}
|
|
76
|
-
function
|
|
77
|
-
|
|
78
|
-
}
|
|
79
|
-
function editCall(input, metadata) {
|
|
80
|
-
const path = text(input?.filePath);
|
|
81
|
-
if (path === undefined)
|
|
82
|
-
return undefined;
|
|
83
|
-
return fileChange([change("update", path, diffstat(object(metadata?.filediff)))]);
|
|
84
|
-
}
|
|
85
|
-
function writeCall(input, metadata) {
|
|
86
|
-
const path = text(metadata?.filepath) ?? text(input?.filePath);
|
|
87
|
-
const op = metadata?.exists === false ? "add" : metadata?.exists === true ? "update" : undefined;
|
|
88
|
-
return path === undefined || op === undefined ? undefined : fileChange([change(op, path, undefined)]);
|
|
89
|
-
}
|
|
90
|
-
function applyPatchFile(value) {
|
|
91
|
-
const file = object(value);
|
|
92
|
-
if (file === undefined)
|
|
93
|
-
return undefined;
|
|
94
|
-
const type = file.type;
|
|
95
|
-
const op = type === "add"
|
|
96
|
-
? "add"
|
|
97
|
-
: type === "delete"
|
|
98
|
-
? "delete"
|
|
99
|
-
: type === "update" || type === "modify" || type === "move"
|
|
100
|
-
? "update"
|
|
101
|
-
: undefined;
|
|
102
|
-
const path = type === "move" ? text(file.movePath) : text(file.filePath);
|
|
103
|
-
return op === undefined || path === undefined ? undefined : change(op, path, diffstat(file));
|
|
104
|
-
}
|
|
105
|
-
function applyPatchCall(metadata) {
|
|
106
|
-
if (!Array.isArray(metadata?.files))
|
|
107
|
-
return undefined;
|
|
108
|
-
return fileChange(metadata.files.flatMap((value) => {
|
|
109
|
-
const next = applyPatchFile(value);
|
|
110
|
-
return next === undefined ? [] : [next];
|
|
111
|
-
}));
|
|
112
|
-
}
|
|
113
|
-
function strongerCall(previous, next) {
|
|
114
|
-
if (next === undefined)
|
|
115
|
-
return previous;
|
|
116
|
-
if (previous?.kind === "fileChange" && next.kind !== "fileChange")
|
|
117
|
-
return previous;
|
|
118
|
-
// The correlated start's admitted preview is authority: a later update never
|
|
119
|
-
// overwrites it, empty or conflicting, while a start without one adopts supplied evidence.
|
|
120
|
-
if (next.kind === "other" && previous?.kind === "other" && previous.input !== undefined)
|
|
121
|
-
return { ...next, input: previous.input };
|
|
122
|
-
return next;
|
|
123
|
-
}
|
|
124
|
-
function runCall(name, value) {
|
|
125
|
-
return name === "bash" || name === "shell" ? { kind: "run", command: text(value?.command) ?? name } : undefined;
|
|
126
|
-
}
|
|
127
|
-
function readCall(name, value) {
|
|
128
|
-
if (name !== "read")
|
|
129
|
-
return undefined;
|
|
130
|
-
const path = text(value?.filePath) ?? text(value?.path);
|
|
131
|
-
if (path === undefined)
|
|
63
|
+
function output(content) {
|
|
64
|
+
if (!Array.isArray(content))
|
|
132
65
|
return undefined;
|
|
133
|
-
const
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
...(limit === undefined ? {} : { limit }),
|
|
140
|
-
};
|
|
141
|
-
}
|
|
142
|
-
function searchCall(name, value) {
|
|
143
|
-
if (name !== "grep" && name !== "glob" && name !== "search")
|
|
144
|
-
return undefined;
|
|
145
|
-
const query = text(value?.pattern) ?? text(value?.query);
|
|
146
|
-
if (query === undefined)
|
|
147
|
-
return undefined;
|
|
148
|
-
const path = text(value?.path) ?? text(value?.filePath);
|
|
149
|
-
const glob = text(value?.glob);
|
|
150
|
-
const scope = name === "glob" ? "files" : "content";
|
|
151
|
-
return {
|
|
152
|
-
kind: "search",
|
|
153
|
-
query,
|
|
154
|
-
scope,
|
|
155
|
-
...(path === undefined ? {} : { path }),
|
|
156
|
-
...(scope === "content" && glob !== undefined ? { glob } : {}),
|
|
157
|
-
};
|
|
158
|
-
}
|
|
159
|
-
function callFor(name, input, metadata) {
|
|
160
|
-
const value = object(input);
|
|
161
|
-
const meta = object(metadata);
|
|
162
|
-
const lower = name.toLowerCase();
|
|
163
|
-
if (lower === "bash" || lower === "shell")
|
|
164
|
-
return runCall(lower, value);
|
|
165
|
-
if (lower === "read")
|
|
166
|
-
return readCall(lower, value);
|
|
167
|
-
if (lower === "grep" || lower === "glob" || lower === "search")
|
|
168
|
-
return searchCall(lower, value);
|
|
169
|
-
if (lower === "edit")
|
|
170
|
-
return editCall(value, meta) ?? otherToolCall(name, input);
|
|
171
|
-
if (lower === "write")
|
|
172
|
-
return writeCall(value, meta) ?? otherToolCall(name, input);
|
|
173
|
-
if (lower === "apply_patch")
|
|
174
|
-
return applyPatchCall(meta) ?? otherToolCall(name, input);
|
|
175
|
-
return otherToolCall(name, input);
|
|
176
|
-
}
|
|
177
|
-
function belongs(part, state) {
|
|
178
|
-
return state.sessionId === undefined || part.sessionID === state.sessionId;
|
|
179
|
-
}
|
|
180
|
-
function mapTextPart(part, events, state, thought) {
|
|
181
|
-
const id = text(part.id);
|
|
182
|
-
const time = object(part.time);
|
|
183
|
-
const content = text(part.text);
|
|
184
|
-
const seen = thought ? state.reasoningParts : state.assistantParts;
|
|
185
|
-
if (!belongs(part, state) || id === undefined || content === undefined || time?.end === undefined || seen.has(id))
|
|
186
|
-
return;
|
|
187
|
-
seen.add(id);
|
|
188
|
-
if (thought)
|
|
189
|
-
events.emit({ type: "thought", text: content });
|
|
190
|
-
else
|
|
191
|
-
events.emit({ type: "assistant", text: content });
|
|
192
|
-
}
|
|
193
|
-
function resultFor(state, failed) {
|
|
194
|
-
const exit = object(state.metadata)?.exit;
|
|
195
|
-
const exitCode = typeof exit === "number" && Number.isInteger(exit) ? exit : undefined;
|
|
196
|
-
if (failed) {
|
|
197
|
-
return {
|
|
198
|
-
status: "error",
|
|
199
|
-
message: text(state.error) ?? "OpenCode tool failed",
|
|
200
|
-
...(exitCode === undefined ? {} : { exitCode }),
|
|
201
|
-
};
|
|
202
|
-
}
|
|
203
|
-
return {
|
|
204
|
-
status: exitCode !== undefined && exitCode !== 0 ? "error" : "ok",
|
|
205
|
-
...(exitCode === undefined ? {} : { exitCode }),
|
|
206
|
-
};
|
|
66
|
+
const parts = content.flatMap((part) => {
|
|
67
|
+
const value = object(part);
|
|
68
|
+
const text = value?.type === "text" ? stringValue(value.text) : undefined;
|
|
69
|
+
return text === undefined ? [] : [text];
|
|
70
|
+
});
|
|
71
|
+
return parts.length === 0 ? undefined : parts.join("\n\n");
|
|
207
72
|
}
|
|
208
|
-
|
|
209
|
-
|
|
73
|
+
const DROPPED = new Set([
|
|
74
|
+
"server.connected",
|
|
75
|
+
"server.heartbeat",
|
|
76
|
+
"session.created",
|
|
77
|
+
"session.forked",
|
|
78
|
+
"session.deleted",
|
|
79
|
+
"session.inbox.enqueued",
|
|
80
|
+
"session.inbox.delivered",
|
|
81
|
+
"session.inbox.cancelled",
|
|
82
|
+
"session.inbox.delivery.changed",
|
|
83
|
+
"session.execution.started",
|
|
84
|
+
"session.execution.succeeded",
|
|
85
|
+
"session.execution.failed",
|
|
86
|
+
"session.execution.interrupted",
|
|
87
|
+
"session.model.selected",
|
|
88
|
+
"session.agent.selected",
|
|
89
|
+
"session.instructions.updated",
|
|
90
|
+
"session.permissions",
|
|
91
|
+
"session.step.streamed",
|
|
92
|
+
"session.step.ended",
|
|
93
|
+
"session.usage.updated",
|
|
94
|
+
"session.usage.recorded",
|
|
95
|
+
"session.text.started",
|
|
96
|
+
"session.text.delta",
|
|
97
|
+
"session.reasoning.started",
|
|
98
|
+
"session.reasoning.delta",
|
|
99
|
+
"session.tool.input.delta",
|
|
100
|
+
"session.tool.input.ended",
|
|
101
|
+
"session.tool.progress",
|
|
102
|
+
"session.retry.scheduled",
|
|
103
|
+
]);
|
|
104
|
+
/** Only complete native values enter narration. The caller enforces submission/step correlation. */
|
|
105
|
+
export function mapEvent(value, events, state) {
|
|
106
|
+
const event = object(value);
|
|
107
|
+
if (event === undefined || typeof event.type !== "string")
|
|
210
108
|
return;
|
|
211
|
-
const
|
|
212
|
-
|
|
213
|
-
const toolState = object(part.state);
|
|
214
|
-
if (id === undefined || name === undefined || toolState === undefined)
|
|
109
|
+
const data = object(event.data) ?? {};
|
|
110
|
+
if (state.sessionId !== undefined && data.sessionID !== state.sessionId)
|
|
215
111
|
return;
|
|
216
|
-
const
|
|
217
|
-
if (
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
state.tools.set(id, observed);
|
|
224
|
-
events.emit({ type: "tool", phase: "started", id, ...observed });
|
|
112
|
+
const type = event.type;
|
|
113
|
+
if (type === "session.step.started") {
|
|
114
|
+
const model = object(data.model);
|
|
115
|
+
const provider = text(model?.providerID);
|
|
116
|
+
const id = text(model?.id);
|
|
117
|
+
if (provider !== undefined && id !== undefined)
|
|
118
|
+
events.emit(modelEvent(`${provider}/${id}`));
|
|
225
119
|
return;
|
|
226
120
|
}
|
|
227
|
-
if (
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
const call = strongerCall(started?.call, next);
|
|
231
|
-
if (call === undefined)
|
|
121
|
+
if (type === "session.text.ended" || type === "session.reasoning.ended") {
|
|
122
|
+
if (typeof data.text === "string")
|
|
123
|
+
events.emit({ type: type === "session.text.ended" ? "assistant" : "thought", text: data.text });
|
|
232
124
|
return;
|
|
233
|
-
const observed = { name: started?.name ?? name, call };
|
|
234
|
-
if (!state.tools.has(id)) {
|
|
235
|
-
state.tools.set(id, observed);
|
|
236
|
-
events.emit({ type: "tool", phase: "started", id, ...observed });
|
|
237
125
|
}
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
state.completedTools.add(id);
|
|
242
|
-
events.emit({
|
|
243
|
-
type: "tool",
|
|
244
|
-
phase: "completed",
|
|
245
|
-
id,
|
|
246
|
-
...observed,
|
|
247
|
-
result: resultFor(toolState, toolState.status === "error"),
|
|
248
|
-
});
|
|
249
|
-
}
|
|
250
|
-
function mapPart(part, events, state) {
|
|
251
|
-
if (part.type === "text")
|
|
252
|
-
return mapTextPart(part, events, state, false);
|
|
253
|
-
if (part.type === "reasoning")
|
|
254
|
-
return mapTextPart(part, events, state, true);
|
|
255
|
-
if (part.type === "tool")
|
|
256
|
-
mapToolPart(part, events, state);
|
|
257
|
-
}
|
|
258
|
-
function mapSessionError(properties, events, state) {
|
|
259
|
-
if (state.sessionId !== undefined && properties.sessionID !== state.sessionId)
|
|
260
|
-
return;
|
|
261
|
-
state.failure = diagnostic(properties.error);
|
|
262
|
-
events.emit(noteEvent(state.failure));
|
|
263
|
-
}
|
|
264
|
-
function mapTodo(properties, events, state) {
|
|
265
|
-
if (properties.sessionID !== state.sessionId || !Array.isArray(properties.todos))
|
|
266
|
-
return;
|
|
267
|
-
const summary = properties.todos
|
|
268
|
-
.flatMap((value) => {
|
|
269
|
-
const todo = object(value);
|
|
270
|
-
const content = text(todo?.content);
|
|
271
|
-
return content === undefined ? [] : [`${text(todo?.status) ?? "todo"}: ${content}`];
|
|
272
|
-
})
|
|
273
|
-
.join("; ");
|
|
274
|
-
if (summary.length > 0)
|
|
275
|
-
events.emit(noteEvent(summary));
|
|
276
|
-
}
|
|
277
|
-
function ignoredEvent(type) {
|
|
278
|
-
return (typeof type === "string" &&
|
|
279
|
-
(OPENCODE_EVENT_DISPOSITIONS[type] === "dropped" || RUNTIME_DROPPED_EVENT_KINDS.has(type)));
|
|
280
|
-
}
|
|
281
|
-
export function mapEvent(value, events, state) {
|
|
282
|
-
const event = object(value);
|
|
283
|
-
if (event === undefined)
|
|
284
|
-
return;
|
|
285
|
-
const properties = object(event.properties) ?? {};
|
|
286
|
-
if (event.type === "message.part.updated") {
|
|
287
|
-
const part = object(properties.part);
|
|
288
|
-
if (part !== undefined)
|
|
289
|
-
mapPart(part, events, state);
|
|
126
|
+
if (type === "session.tool.input.started") {
|
|
127
|
+
if (typeof data.id === "string" && typeof data.name === "string")
|
|
128
|
+
state.tools.set(data.id, { name: data.name });
|
|
290
129
|
return;
|
|
291
130
|
}
|
|
292
|
-
if (
|
|
293
|
-
const
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
131
|
+
if (type === "session.tool.called" || type === "session.tool.success" || type === "session.tool.failed") {
|
|
132
|
+
const id = text(data.id);
|
|
133
|
+
const started = id === undefined ? undefined : state.tools.get(id);
|
|
134
|
+
if (id === undefined || started === undefined || state.completed.has(id))
|
|
135
|
+
return;
|
|
136
|
+
if (started.call === undefined) {
|
|
137
|
+
started.call = callFor(started.name, data.input);
|
|
138
|
+
events.emit({ type: "tool", phase: "started", id, name: started.name, call: started.call });
|
|
139
|
+
}
|
|
140
|
+
if (type === "session.tool.called")
|
|
141
|
+
return;
|
|
142
|
+
if (started.name === "edit" || started.name === "patch" || started.name === "write") {
|
|
143
|
+
started.call = observedChanges(data.metadata) ?? started.call;
|
|
299
144
|
}
|
|
145
|
+
const observed = output(data.content);
|
|
146
|
+
const nativeExit = object(data.metadata)?.exit;
|
|
147
|
+
const exit = typeof nativeExit === "number" && Number.isInteger(nativeExit) ? nativeExit : undefined;
|
|
148
|
+
const result = {
|
|
149
|
+
status: type === "session.tool.failed" || (exit !== undefined && exit !== 0) ? "error" : "ok",
|
|
150
|
+
...(type === "session.tool.failed" ? { message: diagnostic(data.error) } : {}),
|
|
151
|
+
...(observed === undefined ? {} : { output: observed }),
|
|
152
|
+
...(exit === undefined ? {} : { exitCode: exit }),
|
|
153
|
+
};
|
|
154
|
+
state.completed.add(id);
|
|
155
|
+
events.emit({ type: "tool", phase: "completed", id, name: started.name, call: started.call, result });
|
|
300
156
|
return;
|
|
301
157
|
}
|
|
302
|
-
if (
|
|
303
|
-
return mapSessionError(properties, events, state);
|
|
304
|
-
if (event.type === "session.compacted") {
|
|
158
|
+
if (type === "session.compaction.ended") {
|
|
305
159
|
events.emit(noteEvent("Context compacted"));
|
|
306
160
|
return;
|
|
307
161
|
}
|
|
308
|
-
if (
|
|
309
|
-
|
|
310
|
-
|
|
162
|
+
if (type === "session.compaction.failed") {
|
|
163
|
+
events.emit(noteEvent(diagnostic(data.error)));
|
|
164
|
+
return;
|
|
165
|
+
}
|
|
166
|
+
if (type === "session.compaction.started" || type === "session.compaction.delta" || DROPPED.has(type))
|
|
311
167
|
return;
|
|
312
|
-
events.emit({ type: "unknown", kind:
|
|
168
|
+
events.emit({ type: "unknown", kind: type });
|
|
313
169
|
}
|
|
314
170
|
export function createEventState(sessionId) {
|
|
315
|
-
return {
|
|
316
|
-
...(sessionId === undefined ? {} : { sessionId }),
|
|
317
|
-
assistantParts: new Set(),
|
|
318
|
-
reasoningParts: new Set(),
|
|
319
|
-
tools: new Map(),
|
|
320
|
-
completedTools: new Set(),
|
|
321
|
-
};
|
|
171
|
+
return { ...(sessionId === undefined ? {} : { sessionId }), tools: new Map(), completed: new Set() };
|
|
322
172
|
}
|