@astrosheep/keiyaku 2.9.13 → 4.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +5 -132
- package/build/integrations/marketplace/.agents/plugins/marketplace.json +12 -0
- package/build/integrations/marketplace/.claude-plugin/marketplace.json +5 -0
- package/build/integrations/marketplace/plugins/keiyaku/.claude-plugin/plugin.json +7 -0
- package/build/integrations/marketplace/plugins/keiyaku/.codex-plugin/plugin.json +18 -0
- package/build/integrations/marketplace/plugins/keiyaku/opencode.js +16 -0
- package/build/integrations/marketplace/plugins/keiyaku/package.json +8 -0
- package/build/integrations/marketplace/plugins/keiyaku/skills/keiyaku/SKILL.md +42 -0
- package/build/integrations/marketplace/plugins/keiyaku/skills/keiyaku-akuma/SKILL.md +53 -0
- package/build/integrations/marketplace/plugins/keiyaku/skills/keiyaku-bind/SKILL.md +94 -0
- package/build/integrations/marketplace/plugins/keiyaku/skills/keiyaku-bind/agents/openai.yaml +4 -0
- package/build/integrations/marketplace/plugins/keiyaku/skills/keiyaku-task/SKILL.md +97 -0
- package/build/integrations/marketplace/plugins/keiyaku/skills/keiyaku-workflow/SKILL.md +189 -0
- package/build/src/akuma/akuma.d.ts +124 -0
- package/build/src/akuma/akuma.js +414 -0
- package/build/src/akuma/archetype.d.ts +39 -0
- package/build/src/akuma/archetype.js +207 -0
- package/build/src/akuma/body.d.ts +20 -0
- package/build/src/akuma/body.js +417 -0
- package/build/src/akuma/coordinate.d.ts +9 -0
- package/build/src/akuma/coordinate.js +22 -0
- package/build/src/akuma/heart/facts.d.ts +202 -0
- package/build/src/akuma/heart/facts.js +9 -0
- package/build/src/akuma/heart/index.d.ts +90 -0
- package/build/src/akuma/heart/index.js +240 -0
- package/build/src/akuma/heart/rows.d.ts +166 -0
- package/build/src/akuma/heart/rows.js +299 -0
- package/build/src/akuma/heart/schema.d.ts +5 -0
- package/build/src/akuma/heart/schema.js +160 -0
- package/build/src/akuma/heart/storage.d.ts +33 -0
- package/build/src/akuma/heart/storage.js +164 -0
- package/build/src/akuma/heart/tells.d.ts +12 -0
- package/build/src/akuma/heart/tells.js +79 -0
- package/build/src/akuma/heart/timeline.d.ts +15 -0
- package/build/src/akuma/heart/timeline.js +86 -0
- package/build/src/akuma/identity.d.ts +46 -0
- package/build/src/akuma/identity.js +89 -0
- package/build/src/akuma/index.d.ts +9 -0
- package/build/src/akuma/index.js +3 -0
- package/build/src/akuma/projection.d.ts +97 -0
- package/build/src/akuma/projection.js +145 -0
- package/build/src/akuma/provider.d.ts +169 -0
- package/build/src/akuma/provider.js +255 -0
- package/build/src/akuma/providers/claude/events.d.ts +52 -0
- package/build/src/akuma/providers/claude/events.js +185 -0
- package/build/src/akuma/providers/claude/index.d.ts +46 -0
- package/build/src/akuma/providers/claude/index.js +265 -0
- package/build/src/akuma/providers/claude/input.d.ts +13 -0
- package/build/src/akuma/providers/claude/input.js +109 -0
- package/build/src/akuma/providers/codex-app-server/events.d.ts +110 -0
- package/build/src/akuma/providers/codex-app-server/events.js +337 -0
- package/build/src/akuma/providers/codex-app-server/index.d.ts +29 -0
- package/build/src/akuma/providers/codex-app-server/index.js +213 -0
- package/build/src/akuma/providers/index.d.ts +4 -0
- package/build/src/akuma/providers/index.js +85 -0
- package/build/src/akuma/providers/opencode-sdk/events.d.ts +48 -0
- package/build/src/akuma/providers/opencode-sdk/events.js +116 -0
- package/build/src/akuma/providers/opencode-sdk/index.d.ts +32 -0
- package/build/src/akuma/providers/opencode-sdk/index.js +203 -0
- package/build/src/akuma/providers/opencode-sdk/session.d.ts +41 -0
- package/build/src/akuma/providers/opencode-sdk/session.js +62 -0
- package/build/src/akuma/providers/pi/events.d.ts +33 -0
- package/build/src/akuma/providers/pi/events.js +128 -0
- package/build/src/akuma/providers/pi/index.d.ts +11 -0
- package/build/src/akuma/providers/pi/index.js +162 -0
- package/build/src/akuma/publication.d.ts +10 -0
- package/build/src/akuma/publication.js +107 -0
- package/build/src/akuma/requests.d.ts +47 -0
- package/build/src/akuma/requests.js +391 -0
- package/build/src/alias/index.d.ts +18 -0
- package/build/src/alias/index.js +103 -0
- package/build/src/body/amend.d.ts +2 -0
- package/build/src/body/amend.js +289 -0
- package/build/src/body/arc.d.ts +2 -0
- package/build/src/body/arc.js +54 -0
- package/build/src/body/decode.d.ts +4 -0
- package/build/src/body/decode.js +146 -0
- package/build/src/body/keys.d.ts +4 -0
- package/build/src/body/keys.js +11 -0
- package/build/src/body/region.d.ts +6 -0
- package/build/src/body/region.js +139 -0
- package/build/src/body/render.d.ts +4 -0
- package/build/src/body/render.js +74 -0
- package/build/src/body/shape.d.ts +29 -0
- package/build/src/body/shape.js +22 -0
- package/build/src/body/types.d.ts +28 -0
- package/build/src/body/verification.d.ts +7 -0
- package/build/src/body/verification.js +40 -0
- package/build/src/cli/accepted.d.ts +18 -0
- package/build/src/cli/accepted.js +66 -0
- package/build/src/cli/actor.d.ts +8 -0
- package/build/src/cli/actor.js +11 -0
- package/build/src/cli/commands/akuma-invoke.d.ts +77 -0
- package/build/src/cli/commands/akuma-invoke.js +112 -0
- package/build/src/cli/commands/akuma.d.ts +50 -0
- package/build/src/cli/commands/akuma.js +262 -0
- package/build/src/cli/commands/amend.d.ts +13 -0
- package/build/src/cli/commands/amend.js +13 -0
- package/build/src/cli/commands/bind.d.ts +12 -0
- package/build/src/cli/commands/bind.js +17 -0
- package/build/src/cli/commands/contract.d.ts +142 -0
- package/build/src/cli/commands/contract.js +14 -0
- package/build/src/cli/commands/install.d.ts +25 -0
- package/build/src/cli/commands/install.js +105 -0
- package/build/src/cli/commands/task-invoke.d.ts +11 -0
- package/build/src/cli/commands/task-invoke.js +117 -0
- package/build/src/cli/commands/task.d.ts +16 -0
- package/build/src/cli/commands/task.js +144 -0
- package/build/src/cli/index.d.ts +2 -0
- package/build/src/cli/index.js +3 -0
- package/build/src/cli/invoke.d.ts +22 -0
- package/build/src/cli/invoke.js +463 -0
- package/build/src/cli/main.d.ts +1 -0
- package/build/src/cli/main.js +98 -0
- package/build/src/cli/parse.d.ts +107 -0
- package/build/src/cli/parse.js +348 -0
- package/build/src/cli/render/akuma-tool.d.ts +13 -0
- package/build/src/cli/render/akuma-tool.js +72 -0
- package/build/src/cli/render/akuma.d.ts +7 -0
- package/build/src/cli/render/akuma.js +194 -0
- package/build/src/cli/render/board.d.ts +2 -0
- package/build/src/cli/render/board.js +4 -0
- package/build/src/cli/render/catalog.d.ts +2 -0
- package/build/src/cli/render/catalog.js +16 -0
- package/build/src/cli/render/contract.d.ts +4 -0
- package/build/src/cli/render/contract.js +102 -0
- package/build/src/cli/render/kanshi.d.ts +3 -0
- package/build/src/cli/render/kanshi.js +252 -0
- package/build/src/cli/render/refusal.d.ts +2 -0
- package/build/src/cli/render/refusal.js +21 -0
- package/build/src/cli/render/settings.d.ts +3 -0
- package/build/src/cli/render/settings.js +30 -0
- package/build/src/cli/render/task.d.ts +6 -0
- package/build/src/cli/render/task.js +105 -0
- package/build/src/cli/render/terminal.d.ts +23 -0
- package/build/src/cli/render/terminal.js +151 -0
- package/build/src/cli/render/text.d.ts +3 -0
- package/build/src/cli/render/text.js +20 -0
- package/build/src/cli/result.d.ts +67 -0
- package/build/src/cli/selectors.d.ts +9 -0
- package/build/src/cli/selectors.js +66 -0
- package/build/src/cli/usage.d.ts +6 -0
- package/build/src/cli/usage.js +19 -0
- package/build/src/contract-worktree.d.ts +43 -0
- package/build/src/contract-worktree.js +213 -0
- package/build/src/coordination/durable-file.d.ts +4 -0
- package/build/src/coordination/durable-file.js +79 -0
- package/build/src/coordination/sqlite-transaction-lock.d.ts +14 -0
- package/build/src/coordination/sqlite-transaction-lock.js +119 -0
- package/build/src/core/decide.d.ts +45 -0
- package/build/src/core/facts/codec.d.ts +3 -0
- package/build/src/core/facts/codec.js +277 -0
- package/build/src/core/facts/eligibility.d.ts +7 -0
- package/build/src/core/facts/eligibility.js +26 -0
- package/build/src/core/facts/errors.d.ts +3 -0
- package/build/src/core/facts/errors.js +6 -0
- package/build/src/core/facts/fold.d.ts +2 -0
- package/build/src/core/facts/fold.js +97 -0
- package/build/src/core/facts/gate.d.ts +24 -0
- package/build/src/core/facts/gate.js +52 -0
- package/build/src/core/facts/observation.d.ts +15 -0
- package/build/src/core/facts/observation.js +35 -0
- package/build/src/core/facts/offer.d.ts +21 -0
- package/build/src/core/facts/types.d.ts +137 -0
- package/build/src/core/facts/types.js +66 -0
- package/build/src/core/subject.d.ts +21 -0
- package/build/src/core/subject.js +89 -0
- package/build/src/core/verbs/abandon.d.ts +13 -0
- package/build/src/core/verbs/abandon.js +17 -0
- package/build/src/core/verbs/amend.d.ts +14 -0
- package/build/src/core/verbs/amend.js +52 -0
- package/build/src/core/verbs/arc.d.ts +13 -0
- package/build/src/core/verbs/arc.js +25 -0
- package/build/src/core/verbs/attestation.d.ts +13 -0
- package/build/src/core/verbs/attestation.js +21 -0
- package/build/src/core/verbs/bind.d.ts +13 -0
- package/build/src/core/verbs/bind.js +26 -0
- package/build/src/core/verbs/deliver.d.ts +13 -0
- package/build/src/core/verbs/deliver.js +42 -0
- package/build/src/core/verbs/placement.d.ts +13 -0
- package/build/src/core/verbs/placement.js +37 -0
- package/build/src/dispatch/index.d.ts +33 -0
- package/build/src/dispatch/index.js +168 -0
- package/build/src/duration.d.ts +10 -0
- package/build/src/duration.js +22 -0
- package/build/src/git/admission.d.ts +18 -0
- package/build/src/git/admission.js +126 -0
- package/build/src/git/hooks.d.ts +49 -0
- package/build/src/git/hooks.js +310 -0
- package/build/src/git/identity.d.ts +17 -0
- package/build/src/git/identity.js +47 -0
- package/build/src/git/integration.d.ts +49 -0
- package/build/src/git/integration.js +214 -0
- package/build/src/git/observe.d.ts +50 -0
- package/build/src/git/observe.js +330 -0
- package/build/src/git/read-observation.d.ts +41 -0
- package/build/src/git/read-observation.js +361 -0
- package/build/src/git/reconcile.d.ts +59 -0
- package/build/src/git/reconcile.js +376 -0
- package/build/src/git/repository.d.ts +95 -0
- package/build/src/git/repository.js +490 -0
- package/build/src/git/scratch.d.ts +13 -0
- package/build/src/git/scratch.js +66 -0
- package/build/src/git/target-placement.d.ts +56 -0
- package/build/src/git/target-placement.js +255 -0
- package/build/src/git/tender.d.ts +48 -0
- package/build/src/git/tender.js +82 -0
- package/build/src/git/terminal-seal.d.ts +24 -0
- package/build/src/git/terminal-seal.js +87 -0
- package/build/src/git/tree.d.ts +34 -0
- package/build/src/git/tree.js +116 -0
- package/build/src/git/workspace.d.ts +21 -0
- package/build/src/git/workspace.js +104 -0
- package/build/src/identity/coordinates.d.ts +9 -0
- package/build/src/identity/coordinates.js +20 -0
- package/build/src/identity/normalize.d.ts +8 -0
- package/build/src/identity/normalize.js +45 -0
- package/build/src/identity/selector.d.ts +12 -0
- package/build/src/identity/selector.js +26 -0
- package/build/src/index.d.ts +6 -0
- package/build/src/index.js +3 -0
- package/build/src/kanshi/index.d.ts +5 -0
- package/build/src/kanshi/index.js +2 -0
- package/build/src/kanshi/read.d.ts +8 -0
- package/build/src/kanshi/read.js +209 -0
- package/build/src/kanshi/report.d.ts +60 -0
- package/build/src/kanshi/select.d.ts +8 -0
- package/build/src/kanshi/select.js +21 -0
- package/build/src/library/address.d.ts +48 -0
- package/build/src/library/address.js +134 -0
- package/build/src/library/akuma-creation.d.ts +83 -0
- package/build/src/library/akuma-creation.js +152 -0
- package/build/src/library/bind.d.ts +21 -0
- package/build/src/library/bind.js +56 -0
- package/build/src/library/catalog.d.ts +58 -0
- package/build/src/library/catalog.js +72 -0
- package/build/src/library/configuration.d.ts +17 -0
- package/build/src/library/configuration.js +97 -0
- package/build/src/library/contract.d.ts +120 -0
- package/build/src/library/contract.js +335 -0
- package/build/src/library/delivery.d.ts +23 -0
- package/build/src/library/delivery.js +21 -0
- package/build/src/library/fleet.d.ts +65 -0
- package/build/src/library/fleet.js +189 -0
- package/build/src/library/input.d.ts +16 -0
- package/build/src/library/input.js +101 -0
- package/build/src/library/keiyaku.d.ts +42 -0
- package/build/src/library/keiyaku.js +26 -0
- package/build/src/library/mutation.d.ts +38 -0
- package/build/src/library/mutation.js +39 -0
- package/build/src/library/refusal.d.ts +21 -0
- package/build/src/library/refusal.js +29 -0
- package/build/src/library/region.d.ts +18 -0
- package/build/src/library/region.js +30 -0
- package/build/src/library/repo.d.ts +36 -0
- package/build/src/library/repo.js +76 -0
- package/build/src/markdown/diff.d.ts +1 -0
- package/build/src/markdown/diff.js +4 -0
- package/build/src/markdown/lex.d.ts +3 -0
- package/build/src/markdown/lex.js +221 -0
- package/build/src/markdown/parse.d.ts +2 -0
- package/build/src/markdown/parse.js +221 -0
- package/build/src/markdown/query.d.ts +21 -0
- package/build/src/markdown/query.js +51 -0
- package/build/src/markdown/types.d.ts +118 -0
- package/build/src/markdown/types.js +6 -0
- package/build/src/protocol/attempt.d.ts +49 -0
- package/build/src/protocol/attempt.js +150 -0
- package/build/src/protocol/bind.d.ts +32 -0
- package/build/src/protocol/bind.js +70 -0
- package/build/src/protocol/intent.d.ts +76 -0
- package/build/src/protocol/intent.js +90 -0
- package/build/src/protocol/operations.d.ts +198 -0
- package/build/src/protocol/operations.js +485 -0
- package/build/src/protocol/outcome.d.ts +23 -0
- package/build/src/protocol/outcome.js +21 -0
- package/build/src/protocol/placement.d.ts +30 -0
- package/build/src/protocol/placement.js +114 -0
- package/build/src/protocol/read/audit.d.ts +31 -0
- package/build/src/protocol/read/audit.js +55 -0
- package/build/src/protocol/read/documents.d.ts +8 -0
- package/build/src/protocol/read/documents.js +16 -0
- package/build/src/protocol/read/status.d.ts +44 -0
- package/build/src/protocol/read/status.js +60 -0
- package/build/src/protocol/run.d.ts +81 -0
- package/build/src/protocol/run.js +64 -0
- package/build/src/runtime/proc/line-rpc.d.ts +38 -0
- package/build/src/runtime/proc/line-rpc.js +145 -0
- package/build/src/runtime/proc/run.d.ts +70 -0
- package/build/src/runtime/proc/run.js +226 -0
- package/build/src/settings.d.ts +51 -0
- package/build/src/settings.js +114 -0
- package/build/src/settlement/fence.d.ts +9 -0
- package/build/src/settlement/fence.js +23 -0
- package/build/src/settlement/holder.d.ts +36 -0
- package/build/src/settlement/holder.js +187 -0
- package/build/src/settlement/settle.d.ts +44 -0
- package/build/src/settlement/settle.js +165 -0
- package/build/src/task/board.d.ts +83 -0
- package/build/src/task/board.js +165 -0
- package/build/src/task/compose.d.ts +25 -0
- package/build/src/task/compose.js +232 -0
- package/build/src/task/context.d.ts +4 -0
- package/build/src/task/context.js +51 -0
- package/build/src/task/document.d.ts +24 -0
- package/build/src/task/document.js +118 -0
- package/build/src/task/identity.d.ts +12 -0
- package/build/src/task/identity.js +47 -0
- package/build/src/task/index.d.ts +90 -0
- package/build/src/task/index.js +182 -0
- package/build/src/task/operations.d.ts +134 -0
- package/build/src/task/operations.js +198 -0
- package/build/src/task/store.d.ts +20 -0
- package/build/src/task/store.js +114 -0
- package/build/src/verification/declaration.d.ts +23 -0
- package/build/src/verification/declaration.js +14 -0
- package/build/src/verification/execution.d.ts +49 -0
- package/build/src/verification/execution.js +104 -0
- package/build/src/world.d.ts +13 -0
- package/build/src/world.js +103 -0
- package/package.json +65 -44
- package/build/.tsbuildinfo +0 -1
- package/build/agents/call-terms.js +0 -32
- package/build/agents/harness/activity-values.js +0 -70
- package/build/agents/harness/control-types.js +0 -18
- package/build/agents/harness/event-channel.js +0 -213
- package/build/agents/harness/event-persistence.js +0 -220
- package/build/agents/harness/events.js +0 -48
- package/build/agents/harness/execution-handle.js +0 -172
- package/build/agents/harness/index.js +0 -11
- package/build/agents/harness/outcome-error.js +0 -81
- package/build/agents/harness/outcome.js +0 -220
- package/build/agents/harness/projection.js +0 -369
- package/build/agents/harness/provider-adapter.js +0 -58
- package/build/agents/harness/router.js +0 -30
- package/build/agents/harness/runtime.js +0 -85
- package/build/agents/harness/session.js +0 -15
- package/build/agents/launch-snapshot/model.js +0 -127
- package/build/agents/launch-snapshot/parse-helpers.js +0 -114
- package/build/agents/launch-snapshot/resolve.js +0 -46
- package/build/agents/opencode-sdk.js +0 -159
- package/build/agents/providers/claude-agent-sdk/adapter.js +0 -396
- package/build/agents/providers/claude-agent-sdk/events.js +0 -218
- package/build/agents/providers/claude-agent-sdk/registration.js +0 -225
- package/build/agents/providers/claude-agent-sdk/session-schema.js +0 -2
- package/build/agents/providers/claude-agent-sdk/session.js +0 -172
- package/build/agents/providers/codex-app-server/adapter.js +0 -387
- package/build/agents/providers/codex-app-server/events.js +0 -492
- package/build/agents/providers/codex-app-server/identity.js +0 -1
- package/build/agents/providers/codex-app-server/policy.js +0 -29
- package/build/agents/providers/codex-app-server/registration.js +0 -259
- package/build/agents/providers/codex-app-server/session-schema.js +0 -6
- package/build/agents/providers/codex-app-server/session.js +0 -273
- package/build/agents/providers/event-type-tail.js +0 -16
- package/build/agents/providers/opencode-sdk/adapter.js +0 -402
- package/build/agents/providers/opencode-sdk/events.js +0 -380
- package/build/agents/providers/opencode-sdk/registration.js +0 -146
- package/build/agents/providers/opencode-sdk/session-schema.js +0 -2
- package/build/agents/providers/opencode-sdk/session.js +0 -187
- package/build/agents/providers/pi/adapter.js +0 -285
- package/build/agents/providers/pi/checkpoint.js +0 -49
- package/build/agents/providers/pi/events.js +0 -285
- package/build/agents/providers/pi/registration.js +0 -160
- package/build/agents/providers/pi/session-schema.js +0 -6
- package/build/agents/providers/registration.js +0 -7
- package/build/agents/providers/registry.js +0 -76
- package/build/agents/selector.js +0 -120
- package/build/agents/session.js +0 -29
- package/build/agents/string-tail-buffer.js +0 -44
- package/build/agents/types.js +0 -30
- package/build/artifact-directories.js +0 -22
- package/build/cli/commands/akuma/akuma/handler.js +0 -5
- package/build/cli/commands/akuma/akuma/meta.js +0 -17
- package/build/cli/commands/akuma/catalog.js +0 -10
- package/build/cli/commands/akuma/list/handler.js +0 -15
- package/build/cli/commands/akuma/list/meta-list.js +0 -12
- package/build/cli/commands/akuma/list/meta-ls.js +0 -9
- package/build/cli/commands/akuma/show/handler.js +0 -27
- package/build/cli/commands/akuma/show/meta.js +0 -8
- package/build/cli/commands/akuma.js +0 -186
- package/build/cli/commands/contract/amend/handler.js +0 -17
- package/build/cli/commands/contract/amend/meta.js +0 -13
- package/build/cli/commands/contract/arc/handler.js +0 -16
- package/build/cli/commands/contract/arc/meta.js +0 -28
- package/build/cli/commands/contract/audit/handler.js +0 -42
- package/build/cli/commands/contract/audit/meta.js +0 -17
- package/build/cli/commands/contract/bind/handler.js +0 -39
- package/build/cli/commands/contract/bind/meta.js +0 -96
- package/build/cli/commands/contract/catalog.js +0 -18
- package/build/cli/commands/contract/forfeit/handler.js +0 -17
- package/build/cli/commands/contract/forfeit/meta.js +0 -12
- package/build/cli/commands/contract/log/handler.js +0 -12
- package/build/cli/commands/contract/log/meta.js +0 -12
- package/build/cli/commands/contract/petition/handler.js +0 -64
- package/build/cli/commands/contract/petition/meta.js +0 -23
- package/build/cli/commands/contract/renew/handler.js +0 -65
- package/build/cli/commands/contract/renew/meta.js +0 -19
- package/build/cli/commands/metadata.js +0 -68
- package/build/cli/commands/projection/call/handler.js +0 -43
- package/build/cli/commands/projection/call/meta.js +0 -12
- package/build/cli/commands/projection/catalog.js +0 -16
- package/build/cli/commands/projection/fork/handler.js +0 -61
- package/build/cli/commands/projection/fork/meta.js +0 -12
- package/build/cli/commands/projection/history/handler.js +0 -65
- package/build/cli/commands/projection/history/meta.js +0 -9
- package/build/cli/commands/projection/kill/handler.js +0 -20
- package/build/cli/commands/projection/kill/meta.js +0 -11
- package/build/cli/commands/projection/shared.js +0 -27
- package/build/cli/commands/projection/status/handler.js +0 -42
- package/build/cli/commands/projection/status/meta.js +0 -20
- package/build/cli/commands/projection/tell/handler.js +0 -32
- package/build/cli/commands/projection/tell/meta.js +0 -12
- package/build/cli/commands/projection/wait/handler.js +0 -80
- package/build/cli/commands/projection/wait/meta.js +0 -16
- package/build/cli/commands/registry.js +0 -48
- package/build/cli/commands/shared.js +0 -74
- package/build/cli/commands/skills/catalog.js +0 -6
- package/build/cli/commands/skills/install/handler.js +0 -7
- package/build/cli/commands/skills/install/meta.js +0 -9
- package/build/cli/commands/skills/skills/handler.js +0 -4
- package/build/cli/commands/skills/skills/meta.js +0 -10
- package/build/cli/commands/system/catalog.js +0 -10
- package/build/cli/commands/system/completion/handler.js +0 -10
- package/build/cli/commands/system/completion/meta.js +0 -9
- package/build/cli/commands/system/dump-env/handler.js +0 -3
- package/build/cli/commands/system/dump-env/meta.js +0 -10
- package/build/cli/commands/system/guide/handler.js +0 -4
- package/build/cli/commands/system/guide/meta.js +0 -9
- package/build/cli/commands/task/add/handler.js +0 -38
- package/build/cli/commands/task/add/meta.js +0 -31
- package/build/cli/commands/task/catalog.js +0 -32
- package/build/cli/commands/task/compose/handler.js +0 -18
- package/build/cli/commands/task/compose/meta.js +0 -10
- package/build/cli/commands/task/doctor/handler.js +0 -3
- package/build/cli/commands/task/doctor/meta.js +0 -8
- package/build/cli/commands/task/done/handler.js +0 -10
- package/build/cli/commands/task/done/meta.js +0 -8
- package/build/cli/commands/task/drop/handler.js +0 -8
- package/build/cli/commands/task/drop/meta.js +0 -11
- package/build/cli/commands/task/hold/handler.js +0 -3
- package/build/cli/commands/task/hold/meta.js +0 -8
- package/build/cli/commands/task/log/handler.js +0 -12
- package/build/cli/commands/task/log/meta.js +0 -8
- package/build/cli/commands/task/ls/handler.js +0 -17
- package/build/cli/commands/task/ls/meta.js +0 -8
- package/build/cli/commands/task/note/handler.js +0 -6
- package/build/cli/commands/task/note/meta.js +0 -11
- package/build/cli/commands/task/resume/handler.js +0 -3
- package/build/cli/commands/task/resume/meta.js +0 -8
- package/build/cli/commands/task/shared.js +0 -181
- package/build/cli/commands/task/show/handler.js +0 -13
- package/build/cli/commands/task/show/meta.js +0 -8
- package/build/cli/commands/task/start/handler.js +0 -3
- package/build/cli/commands/task/start/meta.js +0 -8
- package/build/cli/commands/task/stop/handler.js +0 -10
- package/build/cli/commands/task/stop/meta.js +0 -8
- package/build/cli/commands/task/task/handler.js +0 -5
- package/build/cli/commands/task/task/meta.js +0 -11
- package/build/cli/commands/task/update/handler.js +0 -21
- package/build/cli/commands/task/update/meta.js +0 -12
- package/build/cli/commands/verification/handler.js +0 -43
- package/build/cli/commands/verification/meta.js +0 -13
- package/build/cli/completion.js +0 -91
- package/build/cli/draft-artifact.js +0 -50
- package/build/cli/flags.js +0 -321
- package/build/cli/help.js +0 -99
- package/build/cli/index.js +0 -333
- package/build/cli/missing-subcommand.js +0 -7
- package/build/cli/output-stream-error-policy.js +0 -31
- package/build/cli/parse-flags.js +0 -301
- package/build/cli/parse-metadata.js +0 -132
- package/build/cli/parse-selectors.js +0 -83
- package/build/cli/parse.js +0 -250
- package/build/cli/projection-address.js +0 -105
- package/build/cli/render/address.js +0 -101
- package/build/cli/render/amendment-warning.js +0 -8
- package/build/cli/render/arc.js +0 -88
- package/build/cli/render/audit.js +0 -440
- package/build/cli/render/call.js +0 -70
- package/build/cli/render/compact-text.js +0 -3
- package/build/cli/render/errors.js +0 -101
- package/build/cli/render/format.js +0 -226
- package/build/cli/render/kanshi.js +0 -300
- package/build/cli/render/kill.js +0 -9
- package/build/cli/render/lifecycle.js +0 -56
- package/build/cli/render/line-width.js +0 -103
- package/build/cli/render/misc.js +0 -84
- package/build/cli/render/path-prefix-compaction.js +0 -131
- package/build/cli/render/petition.js +0 -85
- package/build/cli/render/projection-activity.js +0 -332
- package/build/cli/render/projection-history.js +0 -77
- package/build/cli/render/response-style.js +0 -27
- package/build/cli/render/shared.js +0 -232
- package/build/cli/render/skills.js +0 -10
- package/build/cli/render/status-indicator.js +0 -47
- package/build/cli/render/status.js +0 -243
- package/build/cli/render/success-response.js +0 -95
- package/build/cli/render/task.js +0 -175
- package/build/cli/render/tell.js +0 -11
- package/build/cli/render/terminal-failure.js +0 -65
- package/build/cli/render/tool-command-normalization.js +0 -137
- package/build/cli/render/tool-ledger-rollup.js +0 -74
- package/build/cli/render/tool-presentation.js +0 -98
- package/build/cli/render/types.js +0 -2
- package/build/cli/render/verification.js +0 -23
- package/build/cli/render/wait.js +0 -343
- package/build/cli/skills-install.js +0 -348
- package/build/cli/subagent-guard.js +0 -25
- package/build/cli/types.js +0 -2
- package/build/config/akuma-loader.js +0 -240
- package/build/config/env-keys.js +0 -57
- package/build/config/env.js +0 -304
- package/build/config/provider-policy-ownership.js +0 -10
- package/build/config/settings/disease.js +0 -33
- package/build/config/settings/knobs.js +0 -14
- package/build/config/settings/loader.js +0 -275
- package/build/config/settings/provider-instance-fields.js +0 -51
- package/build/config/settings/schema.js +0 -113
- package/build/core/address-carrier.js +0 -89
- package/build/core/addressing.js +0 -407
- package/build/core/amend.js +0 -321
- package/build/core/amendment-criteria.js +0 -17
- package/build/core/amendment-warning.js +0 -10
- package/build/core/arc.js +0 -293
- package/build/core/atomic-publish.js +0 -64
- package/build/core/audit/candidate.js +0 -141
- package/build/core/audit/coordinates.js +0 -230
- package/build/core/audit/evidence.js +0 -156
- package/build/core/audit/facade.js +0 -65
- package/build/core/audit/readiness.js +0 -4
- package/build/core/audit/report.js +0 -38
- package/build/core/audit.js +0 -1
- package/build/core/bind-reconciliation.js +0 -409
- package/build/core/bind-workspace.js +0 -115
- package/build/core/bind.js +0 -503
- package/build/core/call/call.js +0 -235
- package/build/core/call/context.js +0 -210
- package/build/core/call/execution.js +0 -255
- package/build/core/call/prompt.js +0 -27
- package/build/core/call/reference.js +0 -24
- package/build/core/call-persist.js +0 -76
- package/build/core/command-markdown.js +0 -45
- package/build/core/context.js +0 -104
- package/build/core/contract-carrier-runtime.js +0 -512
- package/build/core/contract-carrier.js +0 -353
- package/build/core/contract-view.js +0 -319
- package/build/core/contract.js +0 -19
- package/build/core/derived-replay.js +0 -340
- package/build/core/draft.js +0 -400
- package/build/core/execution-coordinate.js +0 -46
- package/build/core/execution-pact.js +0 -126
- package/build/core/forfeit.js +0 -132
- package/build/core/hints.js +0 -34
- package/build/core/identifier-slug.js +0 -116
- package/build/core/ids.js +0 -90
- package/build/core/lifecycle-history.js +0 -48
- package/build/core/lifecycle-recovery.js +0 -122
- package/build/core/lifecycle-runner.js +0 -377
- package/build/core/log.js +0 -50
- package/build/core/markdown/lex.js +0 -274
- package/build/core/markdown/parser.js +0 -260
- package/build/core/markdown/render.js +0 -68
- package/build/core/markdown/sections.js +0 -80
- package/build/core/markdown/titles.js +0 -9
- package/build/core/markdown/types.js +0 -6
- package/build/core/outcome-base.js +0 -185
- package/build/core/places.js +0 -175
- package/build/core/projection/akuma-name.js +0 -43
- package/build/core/projection/generation/database.js +0 -473
- package/build/core/projection/generation/identity.js +0 -84
- package/build/core/projection/generation/ledger.js +0 -91
- package/build/core/projection/generation/model.js +0 -261
- package/build/core/projection/generation/projection-generation-continuation.js +0 -84
- package/build/core/projection/generation/projection-generation-doorbell.js +0 -88
- package/build/core/projection/generation/projection-generation-execution.js +0 -241
- package/build/core/projection/generation/projection-generation-identity.js +0 -21
- package/build/core/projection/generation/projection-generation-launcher.js +0 -154
- package/build/core/projection/generation/projection-generation-process.js +0 -47
- package/build/core/projection/generation/projection-generation-runner.js +0 -489
- package/build/core/projection/generation/projection-generation-runtime.js +0 -46
- package/build/core/projection/generation/protocol.js +0 -68
- package/build/core/projection/generation/store.js +0 -108
- package/build/core/projection/generation/transitions.js +0 -463
- package/build/core/projection/heart.js +0 -9
- package/build/core/projection/index.js +0 -28
- package/build/core/projection/projection-activity.js +0 -273
- package/build/core/projection/projection-alias.js +0 -131
- package/build/core/projection/projection-coordinate.js +0 -61
- package/build/core/projection/projection-core.js +0 -127
- package/build/core/projection/projection-execution-observer.js +0 -270
- package/build/core/projection/projection-history.js +0 -474
- package/build/core/projection/projection-identity.js +0 -11
- package/build/core/projection/projection-kill.js +0 -112
- package/build/core/projection/projection-life-observer.js +0 -101
- package/build/core/projection/projection-mint.js +0 -170
- package/build/core/projection/projection-status-observation.js +0 -434
- package/build/core/projection/projection-status.js +0 -442
- package/build/core/projection/projection-terminal-failure.js +0 -111
- package/build/core/projection/projection-wait.js +0 -337
- package/build/core/projection/projection-wake.js +0 -298
- package/build/core/projection/tell/launch-store.js +0 -244
- package/build/core/projection/tell/model.js +0 -98
- package/build/core/projection/tell/store.js +0 -245
- package/build/core/provider-loader-ports.js +0 -4
- package/build/core/registry.js +0 -100
- package/build/core/renew-build.js +0 -554
- package/build/core/renew-plan.js +0 -264
- package/build/core/renew-rewrite.js +0 -118
- package/build/core/renew.js +0 -345
- package/build/core/repository-ledger/accepted-fold-read.js +0 -22
- package/build/core/repository-ledger/accepted-tail.js +0 -116
- package/build/core/repository-ledger/admission.js +0 -38
- package/build/core/repository-ledger/authoritative-transaction.js +0 -1
- package/build/core/repository-ledger/claim-evidence.js +0 -147
- package/build/core/repository-ledger/codec.js +0 -303
- package/build/core/repository-ledger/current-state-store.js +0 -968
- package/build/core/repository-ledger/fold-repository.js +0 -374
- package/build/core/repository-ledger/fold.js +0 -248
- package/build/core/repository-ledger/git-object-store.js +0 -243
- package/build/core/repository-ledger/history-read.js +0 -15
- package/build/core/repository-ledger/identity.js +0 -60
- package/build/core/repository-ledger/incremental-read.js +0 -153
- package/build/core/repository-ledger/index.js +0 -15
- package/build/core/repository-ledger/inventory-plan.js +0 -75
- package/build/core/repository-ledger/inventory.js +0 -310
- package/build/core/repository-ledger/publication-admission.js +0 -125
- package/build/core/repository-ledger/publication.js +0 -353
- package/build/core/repository-ledger/read-model.js +0 -517
- package/build/core/repository-ledger/transaction-membership.js +0 -78
- package/build/core/repository-ledger/traversal.js +0 -404
- package/build/core/repository-ledger/write-transaction.js +0 -346
- package/build/core/response-artifact-catalog-sqlite.js +0 -112
- package/build/core/response-artifact-catalog.js +0 -7
- package/build/core/response-artifact-id.js +0 -5
- package/build/core/run-control/connection-bound-close.js +0 -41
- package/build/core/run-control/detached-lease-bootstrap.js +0 -208
- package/build/core/run-control/detached-process.js +0 -14
- package/build/core/run-control/index.js +0 -6
- package/build/core/run-control/process-tree.js +0 -139
- package/build/core/run-control/runner-lease.js +0 -172
- package/build/core/run-control/sqlite-process-lifetime-lock.js +0 -174
- package/build/core/scope.js +0 -416
- package/build/core/seal.js +0 -364
- package/build/core/settlement/claim-delivery.js +0 -82
- package/build/core/settlement/claim.js +0 -258
- package/build/core/settlement/index.js +0 -19
- package/build/core/settlement/petition-claim-gates.js +0 -247
- package/build/core/settlement/petition-forfeit.js +0 -46
- package/build/core/settlement/petition-head-guard.js +0 -12
- package/build/core/settlement/petition-io.js +0 -1
- package/build/core/settlement/petition-preview.js +0 -125
- package/build/core/settlement/petition-window.js +0 -50
- package/build/core/settlement/petition.js +0 -315
- package/build/core/settlement/queue-read-model.js +0 -120
- package/build/core/settlement/queue-seat-allocation.js +0 -65
- package/build/core/settlement/queue.js +0 -6
- package/build/core/settlement/settlement.js +0 -385
- package/build/core/settlement/verdict.js +0 -126
- package/build/core/settlement/verification.js +0 -554
- package/build/core/status/board.js +0 -455
- package/build/core/status/drift.js +0 -113
- package/build/core/status/lifecycle.js +0 -11
- package/build/core/stored-agent-event.js +0 -129
- package/build/core/structured-query.js +0 -23
- package/build/core/target-ref.js +0 -10
- package/build/core/task/board.js +0 -248
- package/build/core/task/commands.js +0 -401
- package/build/core/task/compose.js +0 -328
- package/build/core/task/coordinate.js +0 -56
- package/build/core/task/document.js +0 -273
- package/build/core/task/index.js +0 -16
- package/build/core/task/model.js +0 -8
- package/build/core/task/query.js +0 -204
- package/build/core/task/settlement-git.js +0 -423
- package/build/core/task/settlement-policy.js +0 -137
- package/build/core/task/source-board.js +0 -104
- package/build/core/task/source-model.js +0 -1
- package/build/core/task/task-bind-preparation.js +0 -243
- package/build/core/task/task-contract.js +0 -371
- package/build/core/task/task-doctor.js +0 -14
- package/build/core/task/task-file-transaction.js +0 -171
- package/build/core/task/task-git-actor.js +0 -33
- package/build/core/task/task-git-runtime.js +0 -97
- package/build/core/task/task-git-store.js +0 -400
- package/build/core/task/task-repository.js +0 -1
- package/build/core/task/task-store-repository.js +0 -97
- package/build/core/task/task-store.js +0 -1
- package/build/core/task/task-worktree.js +0 -25
- package/build/core/task/task.js +0 -7
- package/build/core/task/tree.js +0 -37
- package/build/core/task/validation.js +0 -48
- package/build/core/transcripts.js +0 -485
- package/build/core/validation.js +0 -17
- package/build/core/verification-declaration.js +0 -95
- package/build/core/worktree-bootstrap.js +0 -195
- package/build/core/worktree-path.js +0 -371
- package/build/errno.js +0 -3
- package/build/flow-error.js +0 -191
- package/build/fs/durability.js +0 -27
- package/build/fs/path-coordinate.js +0 -16
- package/build/generated/version.js +0 -3
- package/build/git/branches.js +0 -84
- package/build/git/commits.js +0 -151
- package/build/git/core.js +0 -86
- package/build/git/diff/parsers.js +0 -181
- package/build/git/diff/pathspec.js +0 -3
- package/build/git/diff/preview.js +0 -38
- package/build/git/diff/read.js +0 -105
- package/build/git/diff/structured.js +0 -127
- package/build/git/diff/types.js +0 -1
- package/build/git/path-coordinate.js +0 -17
- package/build/git/process.js +0 -229
- package/build/git/refs.js +0 -250
- package/build/git/staging.js +0 -79
- package/build/git/streaming-batch.js +0 -354
- package/build/git/worktree.js +0 -175
- package/build/index.js +0 -67
- package/build/keiyaku-constants.js +0 -2
- package/build/keiyaku.js +0 -30
- package/build/telemetry/debug-log.js +0 -40
- package/build/telemetry/logger.js +0 -48
- package/skills/keiyaku/SKILL.md +0 -46
- package/skills/keiyaku-akuma/SKILL.md +0 -97
- package/skills/keiyaku-task/SKILL.md +0 -118
- package/skills/keiyaku-workflow/SKILL.md +0 -191
- /package/build/{agents/launch-snapshot → src/body}/types.js +0 -0
- /package/build/{agents/providers/claude-agent-sdk/terms.js → src/cli/result.js} +0 -0
- /package/build/{agents/providers/codex-app-server/terms.js → src/core/decide.js} +0 -0
- /package/build/{agents/providers/opencode-sdk/terms.js → src/core/facts/offer.js} +0 -0
- /package/build/{agents/providers/pi/terms.js → src/kanshi/report.js} +0 -0
|
@@ -0,0 +1,169 @@
|
|
|
1
|
+
import type { Confinement, ProviderOptions } from "./heart/index.js";
|
|
2
|
+
import { decodeResumeCoordinate, encodeResumeCoordinate, type ResumeCoordinate } from "./coordinate.js";
|
|
3
|
+
export type { ResumeCoordinate } from "./coordinate.js";
|
|
4
|
+
export type { ProviderOptions } from "./heart/index.js";
|
|
5
|
+
export declare const AKUMA_REQUESTS_ENV = "AKUMA_REQUESTS";
|
|
6
|
+
export declare const AGENT_EVENT_TEXT_LIMIT = 16384;
|
|
7
|
+
export declare const AGENT_THOUGHT_TEXT_LIMIT = 4000;
|
|
8
|
+
export type ToolCall = Readonly<{
|
|
9
|
+
kind: "run";
|
|
10
|
+
command: string;
|
|
11
|
+
}> | Readonly<{
|
|
12
|
+
kind: "read";
|
|
13
|
+
path: string;
|
|
14
|
+
}> | Readonly<{
|
|
15
|
+
kind: "search";
|
|
16
|
+
query: string;
|
|
17
|
+
}> | Readonly<{
|
|
18
|
+
kind: "fileChange";
|
|
19
|
+
changes: readonly Readonly<{
|
|
20
|
+
op: "add" | "update" | "delete";
|
|
21
|
+
path: string;
|
|
22
|
+
diffstat?: Readonly<{
|
|
23
|
+
added: number;
|
|
24
|
+
removed: number;
|
|
25
|
+
}>;
|
|
26
|
+
}>[];
|
|
27
|
+
}> | Readonly<{
|
|
28
|
+
kind: "other";
|
|
29
|
+
display: string;
|
|
30
|
+
}>;
|
|
31
|
+
export type ToolResult = Readonly<{
|
|
32
|
+
status: "ok" | "error";
|
|
33
|
+
message?: string;
|
|
34
|
+
exitCode?: number;
|
|
35
|
+
}>;
|
|
36
|
+
export type ToolEvent = Readonly<{
|
|
37
|
+
type: "tool";
|
|
38
|
+
id: string;
|
|
39
|
+
name: string;
|
|
40
|
+
call: ToolCall;
|
|
41
|
+
truncated?: true;
|
|
42
|
+
}> & (Readonly<{
|
|
43
|
+
phase: "started";
|
|
44
|
+
result?: never;
|
|
45
|
+
}> | Readonly<{
|
|
46
|
+
phase: "completed";
|
|
47
|
+
result: ToolResult;
|
|
48
|
+
}>);
|
|
49
|
+
export type AgentEvent = Readonly<{
|
|
50
|
+
type: "session";
|
|
51
|
+
coordinate: ResumeCoordinate;
|
|
52
|
+
}> | Readonly<{
|
|
53
|
+
type: "assistant";
|
|
54
|
+
text: string;
|
|
55
|
+
truncated?: true;
|
|
56
|
+
}> | Readonly<{
|
|
57
|
+
type: "thought";
|
|
58
|
+
text: string;
|
|
59
|
+
truncated?: true;
|
|
60
|
+
}> | ToolEvent | Readonly<{
|
|
61
|
+
type: "note";
|
|
62
|
+
text: string;
|
|
63
|
+
truncated?: true;
|
|
64
|
+
}> | Readonly<{
|
|
65
|
+
type: "unknown";
|
|
66
|
+
kind: string;
|
|
67
|
+
truncated?: true;
|
|
68
|
+
}>;
|
|
69
|
+
export { decodeResumeCoordinate, encodeResumeCoordinate };
|
|
70
|
+
export declare function decodeProviderOptions(value: unknown): ProviderOptions;
|
|
71
|
+
export declare function decodeAgentEvent(value: unknown): AgentEvent;
|
|
72
|
+
export declare function encodeAgentEvent(event: AgentEvent): unknown;
|
|
73
|
+
export declare function boundedEventText(value: string): string;
|
|
74
|
+
export declare function boundedThoughtText(value: string): string;
|
|
75
|
+
export declare function noteEvent(note: string): Extract<AgentEvent, {
|
|
76
|
+
type: "note";
|
|
77
|
+
}>;
|
|
78
|
+
export declare function unknownEvent(kind: string): Extract<AgentEvent, {
|
|
79
|
+
type: "unknown";
|
|
80
|
+
}>;
|
|
81
|
+
export declare class AgentEventChannel implements AsyncIterable<AgentEvent> {
|
|
82
|
+
private readonly queued;
|
|
83
|
+
private readonly waiters;
|
|
84
|
+
private ended;
|
|
85
|
+
emit(event: AgentEvent): void;
|
|
86
|
+
end(): void;
|
|
87
|
+
[Symbol.asyncIterator](): AsyncIterator<AgentEvent>;
|
|
88
|
+
}
|
|
89
|
+
export type TurnResult = Readonly<{
|
|
90
|
+
kind: "answered";
|
|
91
|
+
answer: string;
|
|
92
|
+
historyId: string;
|
|
93
|
+
}> | Readonly<{
|
|
94
|
+
kind: "failed";
|
|
95
|
+
diagnostic: string;
|
|
96
|
+
}>;
|
|
97
|
+
export type ProviderFence = string;
|
|
98
|
+
export type TellReceipt = Readonly<{
|
|
99
|
+
evidence: "exact";
|
|
100
|
+
tellId: string;
|
|
101
|
+
kind: string;
|
|
102
|
+
}> | Readonly<{
|
|
103
|
+
evidence: "fence";
|
|
104
|
+
fence: ProviderFence;
|
|
105
|
+
kind: string;
|
|
106
|
+
}>;
|
|
107
|
+
export type TellSubmission = Readonly<{
|
|
108
|
+
kind: "accepted";
|
|
109
|
+
fence: ProviderFence;
|
|
110
|
+
}> | Readonly<{
|
|
111
|
+
kind: "turn-ended";
|
|
112
|
+
}>;
|
|
113
|
+
export type Session = Readonly<{
|
|
114
|
+
admission: Readonly<{
|
|
115
|
+
fence: ProviderFence;
|
|
116
|
+
}>;
|
|
117
|
+
events: AsyncIterable<AgentEvent>;
|
|
118
|
+
receipts?: AsyncIterable<TellReceipt>;
|
|
119
|
+
completion: Promise<TurnResult>;
|
|
120
|
+
abort(): Promise<void>;
|
|
121
|
+
tell?(tell: Readonly<{
|
|
122
|
+
id: string;
|
|
123
|
+
text: string;
|
|
124
|
+
}>): Promise<TellSubmission>;
|
|
125
|
+
}>;
|
|
126
|
+
export type DriveInput = Readonly<{
|
|
127
|
+
body: string;
|
|
128
|
+
launchTells: readonly Readonly<{
|
|
129
|
+
id: string;
|
|
130
|
+
text: string;
|
|
131
|
+
}>[];
|
|
132
|
+
cwd: string;
|
|
133
|
+
options: ProviderOptions;
|
|
134
|
+
requests?: Readonly<{
|
|
135
|
+
dir: string;
|
|
136
|
+
}>;
|
|
137
|
+
}>;
|
|
138
|
+
export type ProviderOptionAdmission = Readonly<{
|
|
139
|
+
kind: "admitted";
|
|
140
|
+
options: ProviderOptions;
|
|
141
|
+
}> | Readonly<{
|
|
142
|
+
kind: "refused";
|
|
143
|
+
diagnostic: string;
|
|
144
|
+
}>;
|
|
145
|
+
export type ProviderAdapter = Readonly<{
|
|
146
|
+
confinement(input: Readonly<{
|
|
147
|
+
cwd: string;
|
|
148
|
+
options: ProviderOptions;
|
|
149
|
+
}>): Confinement;
|
|
150
|
+
admitOptions(options: ProviderOptions): ProviderOptionAdmission;
|
|
151
|
+
fork?(input: Readonly<{
|
|
152
|
+
session: ResumeCoordinate;
|
|
153
|
+
at: string;
|
|
154
|
+
cwd: string;
|
|
155
|
+
}>): Promise<Readonly<{
|
|
156
|
+
session: ResumeCoordinate;
|
|
157
|
+
}>>;
|
|
158
|
+
start(input: DriveInput & Readonly<{
|
|
159
|
+
session: Readonly<{
|
|
160
|
+
kind: "fresh";
|
|
161
|
+
}>;
|
|
162
|
+
}>): Promise<Session>;
|
|
163
|
+
resume?(input: DriveInput & Readonly<{
|
|
164
|
+
session: Readonly<{
|
|
165
|
+
kind: "resume";
|
|
166
|
+
coordinate: ResumeCoordinate;
|
|
167
|
+
}>;
|
|
168
|
+
}>): Promise<Session>;
|
|
169
|
+
}>;
|
|
@@ -0,0 +1,255 @@
|
|
|
1
|
+
import { decodeResumeCoordinate, encodeResumeCoordinate } from "./coordinate.js";
|
|
2
|
+
export const AKUMA_REQUESTS_ENV = "AKUMA_REQUESTS";
|
|
3
|
+
export const AGENT_EVENT_TEXT_LIMIT = 16_384;
|
|
4
|
+
export const AGENT_THOUGHT_TEXT_LIMIT = 4_000;
|
|
5
|
+
const AGENT_EVENT_TYPES = {
|
|
6
|
+
session: true,
|
|
7
|
+
assistant: true,
|
|
8
|
+
thought: true,
|
|
9
|
+
tool: true,
|
|
10
|
+
note: true,
|
|
11
|
+
unknown: true,
|
|
12
|
+
};
|
|
13
|
+
function object(value) {
|
|
14
|
+
return value !== null && typeof value === "object" && !Array.isArray(value)
|
|
15
|
+
? value
|
|
16
|
+
: null;
|
|
17
|
+
}
|
|
18
|
+
export { decodeResumeCoordinate, encodeResumeCoordinate };
|
|
19
|
+
function optionText(options, field, blank) {
|
|
20
|
+
const selected = options[field];
|
|
21
|
+
if (selected === undefined)
|
|
22
|
+
return undefined;
|
|
23
|
+
if (typeof selected !== "string" || (blank === "refuse" && selected.trim().length === 0)) {
|
|
24
|
+
throw new TypeError(`provider option ${field} must be ${blank === "allow" ? "a string" : "a nonblank string"}`);
|
|
25
|
+
}
|
|
26
|
+
return selected;
|
|
27
|
+
}
|
|
28
|
+
function optionEnum(options, field, allowed) {
|
|
29
|
+
const selected = options[field];
|
|
30
|
+
if (selected === undefined)
|
|
31
|
+
return undefined;
|
|
32
|
+
if (typeof selected !== "string" || !allowed.includes(selected)) {
|
|
33
|
+
throw new TypeError(`provider option ${field} must be ${allowed.join(", ")}`);
|
|
34
|
+
}
|
|
35
|
+
return selected;
|
|
36
|
+
}
|
|
37
|
+
export function decodeProviderOptions(value) {
|
|
38
|
+
const options = object(value);
|
|
39
|
+
if (options === null)
|
|
40
|
+
throw new TypeError("provider options must be an object");
|
|
41
|
+
const allowed = ["access", "effort", "model", "network", "systemPrompt"];
|
|
42
|
+
const unknown = Object.keys(options).find((key) => !allowed.includes(key));
|
|
43
|
+
if (unknown !== undefined)
|
|
44
|
+
throw new TypeError(`provider options have unknown field ${unknown}`);
|
|
45
|
+
const model = optionText(options, "model", "refuse");
|
|
46
|
+
const effort = optionText(options, "effort", "refuse");
|
|
47
|
+
const access = optionEnum(options, "access", ["read", "write", "auto"]);
|
|
48
|
+
const network = optionEnum(options, "network", ["disabled", "enabled"]);
|
|
49
|
+
const systemPrompt = optionText(options, "systemPrompt", "allow");
|
|
50
|
+
return Object.freeze({
|
|
51
|
+
...(model === undefined ? {} : { model }),
|
|
52
|
+
...(effort === undefined ? {} : { effort }),
|
|
53
|
+
...(access === undefined ? {} : { access }),
|
|
54
|
+
...(network === undefined ? {} : { network }),
|
|
55
|
+
...(systemPrompt === undefined ? {} : { systemPrompt }),
|
|
56
|
+
});
|
|
57
|
+
}
|
|
58
|
+
function eventType(value) {
|
|
59
|
+
return typeof value === "string" && Object.hasOwn(AGENT_EVENT_TYPES, value);
|
|
60
|
+
}
|
|
61
|
+
function decodeToolCall(value) {
|
|
62
|
+
const call = object(value);
|
|
63
|
+
if (call?.kind === "run" && typeof call.command === "string")
|
|
64
|
+
return { kind: "run", command: call.command };
|
|
65
|
+
if (call?.kind === "read" && typeof call.path === "string")
|
|
66
|
+
return { kind: "read", path: call.path };
|
|
67
|
+
if (call?.kind === "search" && typeof call.query === "string")
|
|
68
|
+
return { kind: "search", query: call.query };
|
|
69
|
+
if (call?.kind === "fileChange" && Array.isArray(call.changes)) {
|
|
70
|
+
const changes = call.changes.map((value) => {
|
|
71
|
+
const change = object(value);
|
|
72
|
+
if (change === null || (change.op !== "add" && change.op !== "update" && change.op !== "delete")
|
|
73
|
+
|| typeof change.path !== "string")
|
|
74
|
+
return null;
|
|
75
|
+
const rawDiffstat = change.diffstat;
|
|
76
|
+
const op = change.op;
|
|
77
|
+
if (rawDiffstat === undefined)
|
|
78
|
+
return { op, path: change.path };
|
|
79
|
+
const diffstat = object(rawDiffstat);
|
|
80
|
+
if (diffstat === null || !Number.isSafeInteger(diffstat.added) || !Number.isSafeInteger(diffstat.removed)
|
|
81
|
+
|| diffstat.added < 0 || diffstat.removed < 0)
|
|
82
|
+
return null;
|
|
83
|
+
return {
|
|
84
|
+
op,
|
|
85
|
+
path: change.path,
|
|
86
|
+
diffstat: { added: diffstat.added, removed: diffstat.removed },
|
|
87
|
+
};
|
|
88
|
+
});
|
|
89
|
+
if (changes.every((change) => change !== null))
|
|
90
|
+
return { kind: "fileChange", changes };
|
|
91
|
+
}
|
|
92
|
+
if (call?.kind === "other" && typeof call.display === "string")
|
|
93
|
+
return { kind: "other", display: call.display };
|
|
94
|
+
return null;
|
|
95
|
+
}
|
|
96
|
+
function decodeToolResult(value) {
|
|
97
|
+
const result = object(value);
|
|
98
|
+
if (result === null || (result.status !== "ok" && result.status !== "error"))
|
|
99
|
+
return null;
|
|
100
|
+
if (result.message !== undefined && typeof result.message !== "string")
|
|
101
|
+
return null;
|
|
102
|
+
if (result.exitCode !== undefined && !Number.isSafeInteger(result.exitCode))
|
|
103
|
+
return null;
|
|
104
|
+
return {
|
|
105
|
+
status: result.status,
|
|
106
|
+
...(result.message === undefined ? {} : { message: result.message }),
|
|
107
|
+
...(result.exitCode === undefined ? {} : { exitCode: result.exitCode }),
|
|
108
|
+
};
|
|
109
|
+
}
|
|
110
|
+
function decodeToolEvent(event) {
|
|
111
|
+
if (event.truncated !== undefined && event.truncated !== true)
|
|
112
|
+
return null;
|
|
113
|
+
if (typeof event.id !== "string" || typeof event.name !== "string")
|
|
114
|
+
return null;
|
|
115
|
+
const call = decodeToolCall(event.call);
|
|
116
|
+
if (call !== null && event.phase === "started" && event.result === undefined) {
|
|
117
|
+
return { type: "tool", phase: "started", id: event.id, name: event.name, call,
|
|
118
|
+
...(event.truncated === true ? { truncated: true } : {}) };
|
|
119
|
+
}
|
|
120
|
+
const result = decodeToolResult(event.result);
|
|
121
|
+
if (call !== null && event.phase === "completed" && result !== null) {
|
|
122
|
+
return { type: "tool", phase: "completed", id: event.id, name: event.name, call, result,
|
|
123
|
+
...(event.truncated === true ? { truncated: true } : {}) };
|
|
124
|
+
}
|
|
125
|
+
return null;
|
|
126
|
+
}
|
|
127
|
+
function decodeTypedEvent(type, event) {
|
|
128
|
+
if (type !== "session" && event.truncated !== undefined && event.truncated !== true)
|
|
129
|
+
return null;
|
|
130
|
+
const truncated = event.truncated === true ? { truncated: true } : {};
|
|
131
|
+
switch (type) {
|
|
132
|
+
case "assistant":
|
|
133
|
+
case "thought": return typeof event.text === "string" ? { type, text: event.text, ...truncated } : null;
|
|
134
|
+
case "note": return typeof event.text === "string" ? { type, text: event.text, ...truncated } : null;
|
|
135
|
+
case "unknown": return typeof event.kind === "string" ? { type, kind: event.kind, ...truncated } : null;
|
|
136
|
+
case "session": {
|
|
137
|
+
const coordinate = decodeResumeCoordinate(event.coordinate);
|
|
138
|
+
return coordinate === null ? null : { type, coordinate };
|
|
139
|
+
}
|
|
140
|
+
case "tool": return decodeToolEvent(event);
|
|
141
|
+
default: return type;
|
|
142
|
+
}
|
|
143
|
+
}
|
|
144
|
+
export function decodeAgentEvent(value) {
|
|
145
|
+
const event = object(value);
|
|
146
|
+
if (event === null || !eventType(event.type))
|
|
147
|
+
throw new Error("Akuma activity has an invalid event shape");
|
|
148
|
+
const decoded = decodeTypedEvent(event.type, event);
|
|
149
|
+
if (decoded === null)
|
|
150
|
+
throw new Error("Akuma activity has an invalid event shape");
|
|
151
|
+
return decoded;
|
|
152
|
+
}
|
|
153
|
+
function boundedToolCall(call) {
|
|
154
|
+
switch (call.kind) {
|
|
155
|
+
case "run": return { value: { kind: call.kind, command: boundedEventText(call.command) }, truncated: call.command.length > AGENT_EVENT_TEXT_LIMIT };
|
|
156
|
+
case "read": return { value: { kind: call.kind, path: boundedEventText(call.path) }, truncated: call.path.length > AGENT_EVENT_TEXT_LIMIT };
|
|
157
|
+
case "search": return { value: { kind: call.kind, query: boundedEventText(call.query) }, truncated: call.query.length > AGENT_EVENT_TEXT_LIMIT };
|
|
158
|
+
case "fileChange": return {
|
|
159
|
+
value: {
|
|
160
|
+
kind: call.kind,
|
|
161
|
+
changes: call.changes.map((change) => ({ ...change, path: boundedEventText(change.path) })),
|
|
162
|
+
},
|
|
163
|
+
truncated: call.changes.some((change) => change.path.length > AGENT_EVENT_TEXT_LIMIT),
|
|
164
|
+
};
|
|
165
|
+
case "other": return { value: { kind: call.kind, display: boundedEventText(call.display) }, truncated: call.display.length > AGENT_EVENT_TEXT_LIMIT };
|
|
166
|
+
default: return call;
|
|
167
|
+
}
|
|
168
|
+
}
|
|
169
|
+
function boundedToolResult(result) {
|
|
170
|
+
return {
|
|
171
|
+
value: {
|
|
172
|
+
status: result.status,
|
|
173
|
+
...(result.message === undefined ? {} : { message: boundedEventText(result.message) }),
|
|
174
|
+
...(result.exitCode === undefined ? {} : { exitCode: result.exitCode }),
|
|
175
|
+
},
|
|
176
|
+
truncated: result.message !== undefined && result.message.length > AGENT_EVENT_TEXT_LIMIT,
|
|
177
|
+
};
|
|
178
|
+
}
|
|
179
|
+
export function encodeAgentEvent(event) {
|
|
180
|
+
const marked = (value, changed) => ({
|
|
181
|
+
...value,
|
|
182
|
+
...(changed || ("truncated" in event && event.truncated === true) ? { truncated: true } : {}),
|
|
183
|
+
});
|
|
184
|
+
switch (event.type) {
|
|
185
|
+
case "session": return { type: event.type, coordinate: encodeResumeCoordinate(event.coordinate) };
|
|
186
|
+
case "assistant": return marked({ type: event.type, text: boundedEventText(event.text) }, event.text.length > AGENT_EVENT_TEXT_LIMIT);
|
|
187
|
+
case "thought": return marked({ type: event.type, text: boundedThoughtText(event.text) }, event.text.length > AGENT_THOUGHT_TEXT_LIMIT);
|
|
188
|
+
case "note": return marked({ type: event.type, text: boundedEventText(event.text) }, event.text.length > AGENT_EVENT_TEXT_LIMIT);
|
|
189
|
+
case "unknown": return marked({ type: event.type, kind: boundedEventText(event.kind) }, event.kind.length > AGENT_EVENT_TEXT_LIMIT);
|
|
190
|
+
case "tool": {
|
|
191
|
+
const call = boundedToolCall(event.call);
|
|
192
|
+
const name = boundedEventText(event.name);
|
|
193
|
+
const result = event.phase === "completed" ? boundedToolResult(event.result) : undefined;
|
|
194
|
+
return marked(event.phase === "started" ? {
|
|
195
|
+
type: event.type,
|
|
196
|
+
id: event.id,
|
|
197
|
+
phase: event.phase,
|
|
198
|
+
name,
|
|
199
|
+
call: call.value,
|
|
200
|
+
}
|
|
201
|
+
: {
|
|
202
|
+
type: event.type,
|
|
203
|
+
id: event.id,
|
|
204
|
+
phase: event.phase,
|
|
205
|
+
name,
|
|
206
|
+
call: call.value,
|
|
207
|
+
result: result.value,
|
|
208
|
+
}, name !== event.name || call.truncated || result?.truncated === true);
|
|
209
|
+
}
|
|
210
|
+
default: return event;
|
|
211
|
+
}
|
|
212
|
+
}
|
|
213
|
+
export function boundedEventText(value) {
|
|
214
|
+
return value.slice(0, AGENT_EVENT_TEXT_LIMIT);
|
|
215
|
+
}
|
|
216
|
+
export function boundedThoughtText(value) {
|
|
217
|
+
return value.slice(0, AGENT_THOUGHT_TEXT_LIMIT);
|
|
218
|
+
}
|
|
219
|
+
export function noteEvent(note) {
|
|
220
|
+
return { type: "note", text: note.replace(/\s+/g, " ").trim() };
|
|
221
|
+
}
|
|
222
|
+
export function unknownEvent(kind) {
|
|
223
|
+
return { type: "unknown", kind };
|
|
224
|
+
}
|
|
225
|
+
export class AgentEventChannel {
|
|
226
|
+
queued = [];
|
|
227
|
+
waiters = [];
|
|
228
|
+
ended = false;
|
|
229
|
+
emit(event) {
|
|
230
|
+
const waiter = this.waiters.shift();
|
|
231
|
+
if (waiter === undefined)
|
|
232
|
+
this.queued.push(event);
|
|
233
|
+
else
|
|
234
|
+
waiter.resolve({ done: false, value: event });
|
|
235
|
+
}
|
|
236
|
+
end() {
|
|
237
|
+
if (this.ended)
|
|
238
|
+
return;
|
|
239
|
+
this.ended = true;
|
|
240
|
+
for (const waiter of this.waiters.splice(0))
|
|
241
|
+
waiter.resolve({ done: true, value: undefined });
|
|
242
|
+
}
|
|
243
|
+
[Symbol.asyncIterator]() {
|
|
244
|
+
return {
|
|
245
|
+
next: () => {
|
|
246
|
+
const event = this.queued.shift();
|
|
247
|
+
if (event !== undefined)
|
|
248
|
+
return Promise.resolve({ done: false, value: event });
|
|
249
|
+
if (this.ended)
|
|
250
|
+
return Promise.resolve({ done: true, value: undefined });
|
|
251
|
+
return new Promise((resolve) => this.waiters.push({ resolve }));
|
|
252
|
+
},
|
|
253
|
+
};
|
|
254
|
+
}
|
|
255
|
+
}
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import type { SDKMessage } from "@anthropic-ai/claude-agent-sdk";
|
|
2
|
+
import { AgentEventChannel, type ToolCall } from "../../provider.js";
|
|
3
|
+
export type ClaudeObservationState = {
|
|
4
|
+
tools: Map<string, Readonly<{
|
|
5
|
+
name: string;
|
|
6
|
+
call: ToolCall;
|
|
7
|
+
}>>;
|
|
8
|
+
};
|
|
9
|
+
export declare const CLAUDE_MESSAGE_DISPOSITIONS: {
|
|
10
|
+
readonly assistant: "assistant";
|
|
11
|
+
readonly auth_status: "auth";
|
|
12
|
+
readonly conversation_reset: "note";
|
|
13
|
+
readonly prompt_suggestion: "drop";
|
|
14
|
+
readonly rate_limit_event: "drop";
|
|
15
|
+
readonly result: "terminal";
|
|
16
|
+
readonly stream_event: "drop";
|
|
17
|
+
readonly system: "system";
|
|
18
|
+
readonly tool_progress: "drop";
|
|
19
|
+
readonly tool_use_summary: "drop";
|
|
20
|
+
readonly user: "tool-results";
|
|
21
|
+
};
|
|
22
|
+
export declare const CLAUDE_SYSTEM_DISPOSITIONS: {
|
|
23
|
+
readonly api_retry: "note";
|
|
24
|
+
readonly background_tasks_changed: "note";
|
|
25
|
+
readonly commands_changed: "drop";
|
|
26
|
+
readonly compact_boundary: "drop";
|
|
27
|
+
readonly control_request_progress: "control-progress";
|
|
28
|
+
readonly elicitation_complete: "drop";
|
|
29
|
+
readonly files_persisted: "note";
|
|
30
|
+
readonly hook_progress: "drop";
|
|
31
|
+
readonly hook_response: "drop";
|
|
32
|
+
readonly hook_started: "note";
|
|
33
|
+
readonly informational: "note";
|
|
34
|
+
readonly init: "drop";
|
|
35
|
+
readonly local_command_output: "drop";
|
|
36
|
+
readonly memory_recall: "drop";
|
|
37
|
+
readonly mirror_error: "note";
|
|
38
|
+
readonly model_refusal_fallback: "note";
|
|
39
|
+
readonly model_refusal_no_fallback: "note";
|
|
40
|
+
readonly notification: "note";
|
|
41
|
+
readonly permission_denied: "note";
|
|
42
|
+
readonly plugin_install: "note";
|
|
43
|
+
readonly session_state_changed: "drop";
|
|
44
|
+
readonly status: "note";
|
|
45
|
+
readonly task_notification: "note";
|
|
46
|
+
readonly task_progress: "note";
|
|
47
|
+
readonly task_started: "note";
|
|
48
|
+
readonly task_updated: "note";
|
|
49
|
+
readonly thinking_tokens: "drop";
|
|
50
|
+
readonly worker_shutting_down: "note";
|
|
51
|
+
};
|
|
52
|
+
export declare function emitClaudeMessage(message: SDKMessage, events: AgentEventChannel, state: ClaudeObservationState): void;
|
|
@@ -0,0 +1,185 @@
|
|
|
1
|
+
import { noteEvent, unknownEvent, } from "../../provider.js";
|
|
2
|
+
export const CLAUDE_MESSAGE_DISPOSITIONS = {
|
|
3
|
+
assistant: "assistant",
|
|
4
|
+
auth_status: "auth",
|
|
5
|
+
conversation_reset: "note",
|
|
6
|
+
prompt_suggestion: "drop",
|
|
7
|
+
rate_limit_event: "drop",
|
|
8
|
+
result: "terminal",
|
|
9
|
+
stream_event: "drop",
|
|
10
|
+
system: "system",
|
|
11
|
+
tool_progress: "drop",
|
|
12
|
+
tool_use_summary: "drop",
|
|
13
|
+
user: "tool-results",
|
|
14
|
+
};
|
|
15
|
+
export const CLAUDE_SYSTEM_DISPOSITIONS = {
|
|
16
|
+
api_retry: "note",
|
|
17
|
+
background_tasks_changed: "note",
|
|
18
|
+
commands_changed: "drop",
|
|
19
|
+
compact_boundary: "drop",
|
|
20
|
+
control_request_progress: "control-progress",
|
|
21
|
+
elicitation_complete: "drop",
|
|
22
|
+
files_persisted: "note",
|
|
23
|
+
hook_progress: "drop",
|
|
24
|
+
hook_response: "drop",
|
|
25
|
+
hook_started: "note",
|
|
26
|
+
informational: "note",
|
|
27
|
+
init: "drop",
|
|
28
|
+
local_command_output: "drop",
|
|
29
|
+
memory_recall: "drop",
|
|
30
|
+
mirror_error: "note",
|
|
31
|
+
model_refusal_fallback: "note",
|
|
32
|
+
model_refusal_no_fallback: "note",
|
|
33
|
+
notification: "note",
|
|
34
|
+
permission_denied: "note",
|
|
35
|
+
plugin_install: "note",
|
|
36
|
+
session_state_changed: "drop",
|
|
37
|
+
status: "note",
|
|
38
|
+
task_notification: "note",
|
|
39
|
+
task_progress: "note",
|
|
40
|
+
task_started: "note",
|
|
41
|
+
task_updated: "note",
|
|
42
|
+
thinking_tokens: "drop",
|
|
43
|
+
worker_shutting_down: "note",
|
|
44
|
+
};
|
|
45
|
+
function object(value) {
|
|
46
|
+
return value !== null && typeof value === "object" && !Array.isArray(value)
|
|
47
|
+
? value
|
|
48
|
+
: undefined;
|
|
49
|
+
}
|
|
50
|
+
function nonblank(value) {
|
|
51
|
+
return typeof value === "string" && value.trim().length > 0 ? value.trim() : undefined;
|
|
52
|
+
}
|
|
53
|
+
function number(value) {
|
|
54
|
+
return typeof value === "number" && Number.isFinite(value) ? value : undefined;
|
|
55
|
+
}
|
|
56
|
+
const CLAUDE_SYSTEM_NOTES = {
|
|
57
|
+
api_retry: (message) => {
|
|
58
|
+
const attempt = number(message.attempt);
|
|
59
|
+
const maximum = number(message.max_retries);
|
|
60
|
+
return attempt === undefined || maximum === undefined
|
|
61
|
+
? "Retrying request"
|
|
62
|
+
: `Retrying request ${attempt}/${maximum}`;
|
|
63
|
+
},
|
|
64
|
+
background_tasks_changed: (message) => `Background tasks: ${Array.isArray(message.tasks) ? message.tasks.length : 0}`,
|
|
65
|
+
files_persisted: (message) => {
|
|
66
|
+
const files = Array.isArray(message.files) ? message.files.length : 0;
|
|
67
|
+
const failed = Array.isArray(message.failed) ? message.failed.length : 0;
|
|
68
|
+
return failed === 0 ? `Persisted ${files} files` : `Persisted ${files} files; ${failed} failed`;
|
|
69
|
+
},
|
|
70
|
+
hook_started: (message) => `Hook ${nonblank(message.hook_name) ?? "unknown"} started`,
|
|
71
|
+
informational: (message) => nonblank(message.content) ?? "Informational notice",
|
|
72
|
+
mirror_error: (message) => `Transcript mirror warning: ${nonblank(message.error) ?? nonblank(message.message) ?? "unknown error"}`,
|
|
73
|
+
model_refusal_fallback: () => "Model refusal; using fallback",
|
|
74
|
+
model_refusal_no_fallback: () => "Model refusal; no fallback available",
|
|
75
|
+
notification: (message) => nonblank(message.message) ?? nonblank(message.content) ?? "Notification",
|
|
76
|
+
permission_denied: (message) => `Permission refused${nonblank(message.message) === undefined ? "" : `: ${nonblank(message.message)}`}`,
|
|
77
|
+
plugin_install: (message) => `Plugin install ${nonblank(message.status) ?? "updated"}${nonblank(message.name) === undefined ? "" : `: ${nonblank(message.name)}`}`,
|
|
78
|
+
status: (message) => `Status: ${nonblank(message.status) ?? "idle"}${nonblank(message.error) === undefined ? "" : ` (${nonblank(message.error)})`}`,
|
|
79
|
+
task_notification: (message) => `Task ${nonblank(message.task_id) ?? "unknown"} ${nonblank(message.status) ?? "updated"}`,
|
|
80
|
+
task_progress: (message) => nonblank(message.description) ?? `Task ${nonblank(message.task_id) ?? "unknown"} progressed`,
|
|
81
|
+
task_started: (message) => nonblank(message.description) ?? `Task ${nonblank(message.task_id) ?? "unknown"} started`,
|
|
82
|
+
task_updated: (message) => `Task ${nonblank(message.task_id) ?? "unknown"} updated`,
|
|
83
|
+
worker_shutting_down: (message) => `Worker stopping: ${nonblank(message.reason) ?? "unknown reason"}`,
|
|
84
|
+
};
|
|
85
|
+
function toolCall(name, input) {
|
|
86
|
+
const value = object(input) ?? {};
|
|
87
|
+
const command = nonblank(value.command);
|
|
88
|
+
if (command !== undefined)
|
|
89
|
+
return { kind: "run", command };
|
|
90
|
+
const path = nonblank(value.file_path) ?? nonblank(value.path);
|
|
91
|
+
if (/^(?:read|view)/iu.test(name) && path !== undefined)
|
|
92
|
+
return { kind: "read", path };
|
|
93
|
+
const query = nonblank(value.query) ?? nonblank(value.pattern);
|
|
94
|
+
if (/search|grep|glob/iu.test(name) && query !== undefined)
|
|
95
|
+
return { kind: "search", query };
|
|
96
|
+
if (/write/iu.test(name) && path !== undefined)
|
|
97
|
+
return { kind: "fileChange", changes: [{ op: "add", path }] };
|
|
98
|
+
if (/edit|notebook/iu.test(name) && path !== undefined)
|
|
99
|
+
return { kind: "fileChange", changes: [{ op: "update", path }] };
|
|
100
|
+
return { kind: "other", display: name };
|
|
101
|
+
}
|
|
102
|
+
function assistantEvents(message, events, state) {
|
|
103
|
+
if (message.aborted === true)
|
|
104
|
+
return;
|
|
105
|
+
if (message.error !== undefined) {
|
|
106
|
+
events.emit(noteEvent(`Assistant error: ${message.error}`));
|
|
107
|
+
return;
|
|
108
|
+
}
|
|
109
|
+
const text = message.message.content
|
|
110
|
+
.filter((block) => block.type === "text")
|
|
111
|
+
.map((block) => block.text).join("");
|
|
112
|
+
if (text.length > 0)
|
|
113
|
+
events.emit({ type: "assistant", text });
|
|
114
|
+
for (const block of message.message.content) {
|
|
115
|
+
const value = object(block);
|
|
116
|
+
if (value?.type === "thinking" && typeof value.thinking === "string" && value.thinking.trim().length > 0) {
|
|
117
|
+
events.emit({ type: "thought", text: value.thinking });
|
|
118
|
+
continue;
|
|
119
|
+
}
|
|
120
|
+
if (block.type !== "tool_use")
|
|
121
|
+
continue;
|
|
122
|
+
const call = toolCall(block.name, block.input);
|
|
123
|
+
state.tools.set(block.id, { name: block.name, call });
|
|
124
|
+
events.emit({ type: "tool", phase: "started", id: block.id, name: block.name, call });
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
function toolResultEvents(message, events, state) {
|
|
128
|
+
const content = object(message.message)?.content;
|
|
129
|
+
if (!Array.isArray(content))
|
|
130
|
+
return;
|
|
131
|
+
for (const block of content) {
|
|
132
|
+
const value = object(block);
|
|
133
|
+
if (value?.type !== "tool_result")
|
|
134
|
+
continue;
|
|
135
|
+
const id = nonblank(value.tool_use_id);
|
|
136
|
+
if (id === undefined)
|
|
137
|
+
continue;
|
|
138
|
+
const observed = state.tools.get(id);
|
|
139
|
+
if (observed === undefined)
|
|
140
|
+
continue;
|
|
141
|
+
state.tools.delete(id);
|
|
142
|
+
events.emit({
|
|
143
|
+
type: "tool", phase: "completed", id, name: observed.name, call: observed.call,
|
|
144
|
+
result: { status: value.is_error === true ? "error" : "ok" },
|
|
145
|
+
});
|
|
146
|
+
}
|
|
147
|
+
}
|
|
148
|
+
function emitSystemMessage(value, events) {
|
|
149
|
+
const subtype = nonblank(value?.subtype) ?? "unknown";
|
|
150
|
+
if (!Object.hasOwn(CLAUDE_SYSTEM_DISPOSITIONS, subtype)) {
|
|
151
|
+
events.emit(unknownEvent(subtype));
|
|
152
|
+
return;
|
|
153
|
+
}
|
|
154
|
+
const systemDisposition = CLAUDE_SYSTEM_DISPOSITIONS[subtype];
|
|
155
|
+
if (systemDisposition === "drop")
|
|
156
|
+
return;
|
|
157
|
+
if (systemDisposition === "control-progress" && value?.status !== "api_retry")
|
|
158
|
+
return;
|
|
159
|
+
const note = CLAUDE_SYSTEM_NOTES[subtype];
|
|
160
|
+
events.emit(noteEvent(note?.(value ?? {}) ?? subtype));
|
|
161
|
+
}
|
|
162
|
+
export function emitClaudeMessage(message, events, state) {
|
|
163
|
+
const value = object(message) ?? {};
|
|
164
|
+
const kind = nonblank(value.type) ?? "unknown";
|
|
165
|
+
if (!Object.hasOwn(CLAUDE_MESSAGE_DISPOSITIONS, kind))
|
|
166
|
+
return events.emit(unknownEvent(kind));
|
|
167
|
+
const disposition = CLAUDE_MESSAGE_DISPOSITIONS[kind];
|
|
168
|
+
if (disposition === "assistant") {
|
|
169
|
+
assistantEvents(message, events, state);
|
|
170
|
+
}
|
|
171
|
+
else if (disposition === "tool-results") {
|
|
172
|
+
toolResultEvents(message, events, state);
|
|
173
|
+
}
|
|
174
|
+
else if (disposition === "auth") {
|
|
175
|
+
const error = nonblank(value.error);
|
|
176
|
+
if (error !== undefined)
|
|
177
|
+
events.emit(noteEvent(`Authentication warning: ${error}`));
|
|
178
|
+
}
|
|
179
|
+
else if (disposition === "note") {
|
|
180
|
+
events.emit(noteEvent("Conversation reset"));
|
|
181
|
+
}
|
|
182
|
+
else if (disposition === "system") {
|
|
183
|
+
emitSystemMessage(value, events);
|
|
184
|
+
}
|
|
185
|
+
}
|