@gajae-code/coding-agent 0.10.1 → 0.11.0
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/CHANGELOG.md +70 -2
- package/dist/types/append-only-mode.d.ts +1 -1
- package/dist/types/cli/args.d.ts +4 -5
- package/dist/types/cli/daemon-cli.d.ts +12 -1
- package/dist/types/cli/notify-cli.d.ts +21 -1
- package/dist/types/cli.d.ts +3 -0
- package/dist/types/commands/daemon.d.ts +39 -0
- package/dist/types/commands/launch.d.ts +3 -0
- package/dist/types/commands/notify.d.ts +28 -1
- package/dist/types/commands/sdk.d.ts +33 -0
- package/dist/types/config/atomic-yaml-patch.d.ts +85 -0
- package/dist/types/config/model-profile-activation.d.ts +35 -15
- package/dist/types/config/model-profiles.d.ts +11 -5
- package/dist/types/config/model-registry.d.ts +3 -3
- package/dist/types/config/model-resolver.d.ts +39 -6
- package/dist/types/config/model-selector-value.d.ts +17 -0
- package/dist/types/config/models-config-schema.d.ts +10 -6
- package/dist/types/config/settings-schema.d.ts +133 -6
- package/dist/types/config/settings.d.ts +63 -35
- package/dist/types/coordinator-mcp/model-preset.d.ts +7 -6
- package/dist/types/coordinator-mcp/server.d.ts +6 -49
- package/dist/types/daemon/builtin.d.ts +6 -5
- package/dist/types/daemon/control-types.d.ts +1 -1
- package/dist/types/discovery/mcp-json.d.ts +12 -1
- package/dist/types/extensibility/custom-tools/types.d.ts +1 -1
- package/dist/types/extensibility/extensions/compact-handler.d.ts +4 -2
- package/dist/types/extensibility/extensions/get-commands-handler.d.ts +2 -2
- package/dist/types/extensibility/extensions/loader.d.ts +10 -1
- package/dist/types/extensibility/extensions/runner.d.ts +3 -3
- package/dist/types/extensibility/extensions/types.d.ts +141 -16
- package/dist/types/extensibility/hooks/types.d.ts +1 -1
- package/dist/types/gjc-runtime/launch-tmux.d.ts +3 -2
- package/dist/types/gjc-runtime/psmux-detect.d.ts +3 -0
- package/dist/types/gjc-runtime/session-state-sidecar.d.ts +3 -0
- package/dist/types/gjc-runtime/team-runtime.d.ts +3 -4
- package/dist/types/gjc-runtime/tmux-owner-isolation-cli.d.ts +13 -0
- package/dist/types/gjc-runtime/tmux-sessions.d.ts +4 -1
- package/dist/types/gjc-runtime/windows-powershell-command.d.ts +9 -0
- package/dist/types/harness-control-plane/operate.d.ts +5 -5
- package/dist/types/harness-control-plane/owner.d.ts +18 -4
- package/dist/types/harness-control-plane/receipts.d.ts +0 -1
- package/dist/types/harness-control-plane/sdk-transport.d.ts +43 -0
- package/dist/types/harness-control-plane/session-transport.d.ts +48 -0
- package/dist/types/harness-control-plane/types.d.ts +3 -4
- package/dist/types/lsp/index.d.ts +1 -1
- package/dist/types/main.d.ts +32 -38
- package/dist/types/modes/acp/acp-agent.d.ts +224 -53
- package/dist/types/modes/acp/acp-client-bridge.d.ts +1 -0
- package/dist/types/modes/acp/acp-mode.d.ts +6 -15
- package/dist/types/modes/acp/permission-mode.d.ts +4 -0
- package/dist/types/modes/acp/startup-options.d.ts +6 -0
- package/dist/types/modes/components/agent-dashboard.d.ts +3 -0
- package/dist/types/modes/components/gajae-pet-widget.d.ts +1 -0
- package/dist/types/modes/components/model-selector.d.ts +1 -0
- package/dist/types/modes/components/notifications-settings-editor.d.ts +135 -0
- package/dist/types/modes/components/pet-capability.d.ts +37 -0
- package/dist/types/modes/components/pet-selector.d.ts +1 -1
- package/dist/types/modes/components/settings-selector.d.ts +15 -4
- package/dist/types/modes/components/welcome.d.ts +1 -1
- package/dist/types/modes/controllers/selector-controller.d.ts +35 -1
- package/dist/types/modes/index.d.ts +0 -4
- package/dist/types/modes/interactive-mode.d.ts +5 -1
- package/dist/types/modes/runtime-init.d.ts +2 -2
- package/dist/types/modes/shared/agent-wire/approval-gate.d.ts +6 -9
- package/dist/types/modes/shared/agent-wire/deep-interview-gate.d.ts +4 -6
- package/dist/types/modes/shared/agent-wire/event-contract.d.ts +6 -6
- package/dist/types/modes/shared/agent-wire/event-envelope.d.ts +4 -9
- package/dist/types/modes/shared/agent-wire/event-observation.d.ts +1 -1
- package/dist/types/modes/shared/agent-wire/workflow-gate-broker.d.ts +169 -30
- package/dist/types/modes/shared/agent-wire/workflow-gate-schema.d.ts +7 -7
- package/dist/types/modes/shared/agent-wire/workflow-gate-types.d.ts +105 -0
- package/dist/types/modes/types.d.ts +16 -1
- package/dist/types/runtime-mcp/client.d.ts +2 -0
- package/dist/types/runtime-mcp/config.d.ts +5 -1
- package/dist/types/runtime-mcp/manager.d.ts +8 -1
- package/dist/types/runtime-mcp/types.d.ts +4 -0
- package/dist/types/sdk/acp/adapter.d.ts +67 -0
- package/dist/types/sdk/acp/index.d.ts +2 -0
- package/dist/types/sdk/broker/broker.d.ts +53 -0
- package/dist/types/sdk/broker/discovery.d.ts +30 -0
- package/dist/types/sdk/broker/ensure.d.ts +33 -0
- package/dist/types/sdk/broker/identity.d.ts +3 -0
- package/dist/types/sdk/broker/index.d.ts +8 -0
- package/dist/types/sdk/broker/lifecycle-ledger.d.ts +95 -0
- package/dist/types/sdk/broker/lifecycle.d.ts +85 -0
- package/dist/types/sdk/broker/process-incarnation.d.ts +14 -0
- package/dist/types/sdk/broker/runtime.d.ts +33 -0
- package/dist/types/sdk/broker/session-index.d.ts +57 -0
- package/dist/types/sdk/broker/state-version.d.ts +8 -0
- package/dist/types/sdk/broker/transport.d.ts +9 -0
- package/dist/types/sdk/bus/chat-command-policy.d.ts +49 -0
- package/dist/types/sdk/bus/chat-daemon-cli.d.ts +21 -0
- package/dist/types/sdk/bus/chat-daemon-control.d.ts +111 -0
- package/dist/types/sdk/bus/chat-daemon-runtime.d.ts +77 -0
- package/dist/types/sdk/bus/chat-effect-journal.d.ts +84 -0
- package/dist/types/{notifications → sdk/bus}/config-commands.d.ts +7 -2
- package/dist/types/sdk/bus/config.d.ts +274 -0
- package/dist/types/sdk/bus/conversation-store.d.ts +72 -0
- package/dist/types/sdk/bus/discord-conversation.d.ts +58 -0
- package/dist/types/sdk/bus/discord-daemon.d.ts +45 -0
- package/dist/types/sdk/bus/discord-live-provider.d.ts +70 -0
- package/dist/types/sdk/bus/discord-provider.d.ts +85 -0
- package/dist/types/{notifications → sdk/bus}/html-format.d.ts +2 -2
- package/dist/types/{notifications → sdk/bus}/index.d.ts +113 -13
- package/dist/types/{notifications → sdk/bus}/lifecycle-control-runtime.d.ts +4 -2
- package/dist/types/{notifications → sdk/bus}/lifecycle-orchestrator.d.ts +18 -21
- package/dist/types/{notifications → sdk/bus}/managed-daemon.d.ts +1 -1
- package/dist/types/sdk/bus/native-runtime-compatibility.d.ts +13 -0
- package/dist/types/sdk/bus/notification-orchestration.d.ts +170 -0
- package/dist/types/{notifications → sdk/bus}/notification-service.d.ts +7 -1
- package/dist/types/sdk/bus/session-control.d.ts +83 -0
- package/dist/types/sdk/bus/slack-conversation.d.ts +56 -0
- package/dist/types/sdk/bus/slack-daemon.d.ts +60 -0
- package/dist/types/sdk/bus/slack-live-provider.d.ts +59 -0
- package/dist/types/sdk/bus/slack-provider.d.ts +55 -0
- package/dist/types/{notifications → sdk/bus}/telegram-cli.d.ts +4 -4
- package/dist/types/{notifications → sdk/bus}/telegram-daemon-cli.d.ts +14 -5
- package/dist/types/sdk/bus/telegram-daemon-contract.d.ts +12 -0
- package/dist/types/{notifications → sdk/bus}/telegram-daemon-control.d.ts +2 -2
- package/dist/types/{notifications → sdk/bus}/telegram-daemon.d.ts +55 -17
- package/dist/types/{notifications → sdk/bus}/telegram-reference.d.ts +2 -2
- package/dist/types/sdk/bus/telegram-setup.d.ts +128 -0
- package/dist/types/{notifications → sdk/bus}/topic-registry.d.ts +11 -0
- package/dist/types/sdk/cli/index.d.ts +1 -0
- package/dist/types/sdk/cli/session-cli.d.ts +19 -0
- package/dist/types/sdk/client/client.d.ts +1 -0
- package/dist/types/sdk/client/discovery.d.ts +27 -0
- package/dist/types/sdk/client/index.d.ts +2 -0
- package/dist/types/sdk/host/control/dispatch.d.ts +34 -0
- package/dist/types/sdk/host/control/index.d.ts +2 -0
- package/dist/types/sdk/host/control/operations.d.ts +65 -0
- package/dist/types/sdk/host/events.d.ts +35 -0
- package/dist/types/sdk/host/host.d.ts +35 -0
- package/dist/types/sdk/host/index.d.ts +4 -0
- package/dist/types/sdk/host/query/cursor.d.ts +62 -0
- package/dist/types/sdk/host/query/handlers.d.ts +70 -0
- package/dist/types/sdk/host/query/index.d.ts +3 -0
- package/dist/types/sdk/host/query/revision-store.d.ts +60 -0
- package/dist/types/sdk/host/reverse-leases.d.ts +45 -0
- package/dist/types/sdk/host/types.d.ts +32 -0
- package/dist/types/sdk/index.d.ts +6 -0
- package/dist/types/sdk/lifecycle-session.d.ts +14 -0
- package/dist/types/sdk/mcp/index.d.ts +1 -0
- package/dist/types/sdk/mcp/server.d.ts +37 -0
- package/dist/types/sdk/models.d.ts +44 -0
- package/dist/types/sdk/protocol/adapter-validation.d.ts +14 -0
- package/dist/types/sdk/protocol/operation-registry.d.ts +24 -0
- package/dist/types/{sdk.d.ts → sdk/session.d.ts} +44 -38
- package/dist/types/sdk/startup-capability.d.ts +50 -0
- package/dist/types/session/agent-session.d.ts +114 -21
- package/dist/types/session/default-model-selection.d.ts +25 -0
- package/dist/types/session/fallback-chain-controller.d.ts +52 -0
- package/dist/types/session/session-manager.d.ts +58 -1
- package/dist/types/setup/credential-auto-import.d.ts +36 -6
- package/dist/types/tools/ask-answer-registry.d.ts +1 -1
- package/dist/types/tools/browser/benchmark/detector-report.d.ts +63 -0
- package/dist/types/tools/browser/benchmark/run-suite.d.ts +18 -0
- package/dist/types/tools/browser/launch.d.ts +22 -0
- package/dist/types/tools/browser/profile-discovery.d.ts +31 -0
- package/dist/types/tools/browser/profile-posture.d.ts +37 -0
- package/dist/types/tools/browser/profile-reuse.d.ts +39 -0
- package/dist/types/tools/browser/profile-warmup.d.ts +39 -0
- package/dist/types/tools/browser/registry.d.ts +19 -0
- package/dist/types/tools/browser/tab-protocol.d.ts +4 -0
- package/dist/types/tools/index.d.ts +8 -8
- package/package.json +34 -13
- package/scripts/build-sdk-package-smoke.ts +94 -0
- package/scripts/capture-notifications-settings-showcase.ts +435 -0
- package/scripts/compile-args.ts +4 -2
- package/scripts/g005-daemon-smoke.ts +4 -5
- package/scripts/g011-daemon-path-smoke.ts +5 -5
- package/scripts/generate-sdk-adapter-parity-manifest.ts +163 -0
- package/scripts/generate-sdk-operation-inventory.ts +867 -0
- package/scripts/generate-telegram-baseline-manifest.ts +128 -0
- package/scripts/manifest-schema.ts +124 -0
- package/scripts/run-test-manifest.ts +153 -0
- package/scripts/run-threat-model-check.ts +157 -0
- package/scripts/verify-gjc-sdk-canonicalization.ts +3467 -0
- package/scripts/verify-gjc-sdk-rename.ts +90 -0
- package/src/append-only-mode.ts +1 -1
- package/src/cli/args.ts +43 -12
- package/src/cli/auth-gateway-cli.ts +2 -2
- package/src/cli/config-cli.ts +2 -1
- package/src/cli/daemon-cli.ts +63 -14
- package/src/cli/list-models.ts +1 -1
- package/src/cli/notify-cli.ts +288 -286
- package/src/cli.ts +21 -2
- package/src/commands/daemon.ts +50 -6
- package/src/commands/harness.ts +93 -36
- package/src/commands/launch.ts +5 -2
- package/src/commands/mcp-serve.ts +19 -12
- package/src/commands/notify.ts +36 -3
- package/src/commands/sdk.ts +426 -0
- package/src/commit/agentic/agent.ts +1 -0
- package/src/config/atomic-yaml-patch.ts +423 -0
- package/src/config/model-profile-activation.ts +240 -89
- package/src/config/model-profiles.ts +37 -34
- package/src/config/model-registry.ts +51 -26
- package/src/config/model-resolver.ts +138 -51
- package/src/config/model-selector-value.ts +50 -0
- package/src/config/models-config-schema.ts +14 -21
- package/src/config/settings-schema.ts +128 -10
- package/src/config/settings.ts +1120 -158
- package/src/coordinator-mcp/model-preset.ts +74 -20
- package/src/coordinator-mcp/server.ts +1597 -3052
- package/src/daemon/builtin.ts +8 -5
- package/src/daemon/control-types.ts +1 -1
- package/src/defaults/gjc/skills/team/SKILL.md +4 -4
- package/src/discovery/mcp-json.ts +327 -20
- package/src/extensibility/custom-tools/types.ts +1 -1
- package/src/extensibility/extensions/compact-handler.ts +3 -3
- package/src/extensibility/extensions/get-commands-handler.ts +2 -2
- package/src/extensibility/extensions/loader.ts +69 -5
- package/src/extensibility/extensions/runner.ts +112 -4
- package/src/extensibility/extensions/types.ts +176 -17
- package/src/extensibility/hooks/types.ts +1 -1
- package/src/extensibility/slash-commands.ts +3 -3
- package/src/gjc-runtime/launch-tmux.ts +170 -86
- package/src/gjc-runtime/psmux-detect.ts +82 -4
- package/src/gjc-runtime/session-state-sidecar.ts +41 -31
- package/src/gjc-runtime/team-runtime.ts +54 -35
- package/src/gjc-runtime/tmux-owner-isolation-cli.ts +53 -17
- package/src/gjc-runtime/tmux-owner-isolation.ts +5 -2
- package/src/gjc-runtime/tmux-sessions.ts +19 -13
- package/src/gjc-runtime/ultragoal-guard.ts +53 -6
- package/src/gjc-runtime/ultragoal-runtime.ts +155 -3
- package/src/gjc-runtime/windows-powershell-command.ts +58 -0
- package/src/harness-control-plane/operate.ts +9 -9
- package/src/harness-control-plane/owner.ts +283 -39
- package/src/harness-control-plane/receipts.ts +0 -1
- package/src/harness-control-plane/sdk-transport.ts +395 -0
- package/src/harness-control-plane/session-transport.ts +94 -0
- package/src/harness-control-plane/types.ts +1 -1
- package/src/internal-urls/docs-index.generated.ts +36 -37
- package/src/lsp/client.ts +42 -6
- package/src/lsp/index.ts +2 -2
- package/src/main.ts +299 -204
- package/src/modes/DESIGN.md +258 -0
- package/src/modes/acp/acp-agent.ts +1228 -2612
- package/src/modes/acp/acp-client-bridge.ts +2 -20
- package/src/modes/acp/acp-event-mapper.ts +18 -2
- package/src/modes/acp/acp-mode.ts +8 -36
- package/src/modes/acp/permission-mode.ts +25 -0
- package/src/modes/acp/startup-options.ts +6 -0
- package/src/modes/components/agent-dashboard.ts +37 -17
- package/src/modes/components/custom-editor.ts +1 -0
- package/src/modes/components/gajae-pet-widget.ts +169 -20
- package/src/modes/components/model-selector.ts +93 -35
- package/src/modes/components/notifications-settings-editor.ts +1379 -0
- package/src/modes/components/pet-capability.ts +115 -0
- package/src/modes/components/pet-selector.ts +4 -6
- package/src/modes/components/settings-selector.ts +86 -11
- package/src/modes/components/welcome.ts +4 -4
- package/src/modes/controllers/command-controller.ts +1 -2
- package/src/modes/controllers/event-controller.ts +11 -16
- package/src/modes/controllers/extension-ui-controller.ts +357 -12
- package/src/modes/controllers/input-controller.ts +43 -13
- package/src/modes/controllers/selector-controller.ts +671 -44
- package/src/modes/index.ts +0 -22
- package/src/modes/interactive-mode.ts +108 -24
- package/src/modes/runtime-init.ts +298 -6
- package/src/modes/shared/agent-wire/approval-gate.ts +9 -11
- package/src/modes/shared/agent-wire/deep-interview-gate.ts +10 -11
- package/src/modes/shared/agent-wire/event-contract.ts +7 -8
- package/src/modes/shared/agent-wire/event-envelope.ts +9 -17
- package/src/modes/shared/agent-wire/event-observation.ts +16 -7
- package/src/modes/shared/agent-wire/workflow-gate-broker.ts +1254 -87
- package/src/modes/shared/agent-wire/workflow-gate-schema.ts +15 -15
- package/src/modes/shared/agent-wire/workflow-gate-types.ts +113 -0
- package/src/modes/types.ts +16 -1
- package/src/runtime-mcp/client.ts +94 -19
- package/src/runtime-mcp/config.ts +27 -15
- package/src/runtime-mcp/manager.ts +343 -105
- package/src/runtime-mcp/oauth-flow.ts +42 -12
- package/src/runtime-mcp/transports/http.ts +49 -19
- package/src/runtime-mcp/transports/stdio.ts +47 -28
- package/src/runtime-mcp/types.ts +10 -0
- package/src/sdk/acp/adapter.ts +418 -0
- package/src/sdk/acp/index.ts +2 -0
- package/src/sdk/broker/broker.ts +642 -0
- package/src/sdk/broker/discovery.ts +94 -0
- package/src/sdk/broker/ensure.ts +249 -0
- package/src/sdk/broker/identity.ts +42 -0
- package/src/sdk/broker/index.ts +8 -0
- package/src/sdk/broker/internal-source-marker-2178.txt +1 -0
- package/src/sdk/broker/internal-source.bunfig.toml +1 -0
- package/src/sdk/broker/lifecycle-ledger.ts +286 -0
- package/src/sdk/broker/lifecycle.ts +2157 -0
- package/src/sdk/broker/process-incarnation.ts +159 -0
- package/src/sdk/broker/runtime.ts +164 -0
- package/src/sdk/broker/session-index.ts +318 -0
- package/src/sdk/broker/state-version.ts +23 -0
- package/src/sdk/broker/transport.ts +125 -0
- package/src/sdk/bus/chat-command-policy.ts +107 -0
- package/src/sdk/bus/chat-daemon-cli.ts +214 -0
- package/src/sdk/bus/chat-daemon-control.ts +713 -0
- package/src/sdk/bus/chat-daemon-runtime.ts +526 -0
- package/src/sdk/bus/chat-effect-journal.ts +353 -0
- package/src/{notifications → sdk/bus}/config-commands.ts +39 -10
- package/src/sdk/bus/config.ts +433 -0
- package/src/sdk/bus/conversation-store.ts +391 -0
- package/src/sdk/bus/discord-conversation.ts +85 -0
- package/src/sdk/bus/discord-daemon.ts +2275 -0
- package/src/sdk/bus/discord-live-provider.ts +521 -0
- package/src/sdk/bus/discord-provider.ts +56 -0
- package/src/{notifications → sdk/bus}/html-format.ts +2 -2
- package/src/sdk/bus/index.ts +3943 -0
- package/src/{notifications → sdk/bus}/lifecycle-commands.ts +2 -0
- package/src/{notifications → sdk/bus}/lifecycle-control-runtime.ts +225 -196
- package/src/{notifications → sdk/bus}/lifecycle-orchestrator.ts +161 -74
- package/src/{notifications → sdk/bus}/managed-daemon.ts +2 -2
- package/src/sdk/bus/native-runtime-compatibility.ts +42 -0
- package/src/sdk/bus/natives-augment.d.ts +38 -0
- package/src/sdk/bus/notification-orchestration.ts +535 -0
- package/src/{notifications → sdk/bus}/notification-service.ts +106 -12
- package/src/sdk/bus/session-control.ts +333 -0
- package/src/sdk/bus/slack-conversation.ts +74 -0
- package/src/sdk/bus/slack-daemon.ts +2144 -0
- package/src/sdk/bus/slack-live-provider.ts +380 -0
- package/src/sdk/bus/slack-provider.ts +76 -0
- package/src/{notifications → sdk/bus}/telegram-cli.ts +8 -8
- package/src/sdk/bus/telegram-daemon-cli.ts +330 -0
- package/src/sdk/bus/telegram-daemon-contract.ts +14 -0
- package/src/{notifications → sdk/bus}/telegram-daemon-control.ts +4 -4
- package/src/{notifications → sdk/bus}/telegram-daemon.ts +502 -54
- package/src/{notifications → sdk/bus}/telegram-reference.ts +2 -2
- package/src/sdk/bus/telegram-setup.ts +663 -0
- package/src/{notifications → sdk/bus}/topic-registry.ts +32 -0
- package/src/sdk/cli/index.ts +1 -0
- package/src/sdk/cli/session-cli.ts +275 -0
- package/src/sdk/client/client.ts +1 -0
- package/src/sdk/client/discovery.ts +108 -0
- package/src/sdk/client/index.ts +2 -0
- package/src/sdk/host/control/dispatch.ts +367 -0
- package/src/sdk/host/control/index.ts +10 -0
- package/src/sdk/host/control/operations.ts +63 -0
- package/src/sdk/host/events.ts +91 -0
- package/src/sdk/host/host.ts +296 -0
- package/src/sdk/host/index.ts +4 -0
- package/src/sdk/host/query/cursor.ts +189 -0
- package/src/sdk/host/query/handlers.ts +533 -0
- package/src/sdk/host/query/index.ts +3 -0
- package/src/sdk/host/query/revision-store.ts +1126 -0
- package/src/sdk/host/reverse-leases.ts +325 -0
- package/src/sdk/host/types.ts +29 -0
- package/src/sdk/index.ts +13 -0
- package/src/sdk/lifecycle-session.ts +39 -0
- package/src/sdk/mcp/index.ts +1 -0
- package/src/sdk/mcp/server.ts +332 -0
- package/src/sdk/models.ts +168 -0
- package/src/sdk/protocol/adapter-validation.ts +48 -0
- package/src/sdk/protocol/operation-inventory.generated.json +5654 -0
- package/src/sdk/protocol/operation-registry.ts +312 -0
- package/src/{sdk.ts → sdk/session.ts} +339 -212
- package/src/sdk/startup-capability.ts +189 -0
- package/src/session/agent-session.ts +2470 -866
- package/src/session/default-model-selection.ts +93 -0
- package/src/session/fallback-chain-controller.ts +136 -0
- package/src/session/session-manager.ts +447 -13
- package/src/session/session-storage.ts +8 -1
- package/src/setup/credential-auto-import.ts +290 -35
- package/src/setup/hermes/templates/operator-instructions.v1.md +3 -5
- package/src/slash-commands/builtin-registry.ts +33 -30
- package/src/task/executor.ts +62 -13
- package/src/tools/ask-answer-registry.ts +1 -1
- package/src/tools/ask.ts +13 -8
- package/src/tools/browser/STEALTH-THIRD-PARTY-NOTICES.md +26 -0
- package/src/tools/browser/benchmark/detector-report.ts +157 -0
- package/src/tools/browser/benchmark/run-suite.ts +39 -0
- package/src/tools/browser/launch.ts +124 -19
- package/src/tools/browser/profile-discovery.ts +63 -0
- package/src/tools/browser/profile-posture.ts +59 -0
- package/src/tools/browser/profile-reuse.ts +102 -0
- package/src/tools/browser/profile-warmup.ts +109 -0
- package/src/tools/browser/registry.ts +87 -11
- package/src/tools/browser/tab-protocol.ts +1 -0
- package/src/tools/browser/tab-supervisor.ts +1 -0
- package/src/tools/browser/tab-worker.ts +1 -1
- package/src/tools/browser.ts +6 -0
- package/src/tools/index.ts +8 -8
- package/src/tools/puppeteer/14_stealth_permissions.txt +57 -0
- package/src/tools/puppeteer/15_stealth_webrtc.txt +60 -0
- package/src/tools/telegram-send.ts +2 -2
- package/vendor/insane-search/MANIFEST.json +2 -1
- package/vendor/insane-search/engine/bias_check.py +4 -1
- package/vendor/insane-search/engine/phase0.py +26 -1
- package/dist/types/harness-control-plane/rpc-adapter.d.ts +0 -69
- package/dist/types/modes/bridge/auth.d.ts +0 -12
- package/dist/types/modes/bridge/bridge-client-bridge.d.ts +0 -9
- package/dist/types/modes/bridge/bridge-mode.d.ts +0 -47
- package/dist/types/modes/bridge/bridge-ui-context.d.ts +0 -88
- package/dist/types/modes/bridge/event-stream.d.ts +0 -8
- package/dist/types/modes/rpc/host-tools.d.ts +0 -1
- package/dist/types/modes/rpc/host-uris.d.ts +0 -1
- package/dist/types/modes/rpc/rpc-client.d.ts +0 -299
- package/dist/types/modes/rpc/rpc-mode.d.ts +0 -86
- package/dist/types/modes/rpc/rpc-socket-security.d.ts +0 -10
- package/dist/types/modes/rpc/rpc-types.d.ts +0 -810
- package/dist/types/modes/shared/agent-wire/command-contract.d.ts +0 -18
- package/dist/types/modes/shared/agent-wire/command-dispatch.d.ts +0 -37
- package/dist/types/modes/shared/agent-wire/command-validation.d.ts +0 -2
- package/dist/types/modes/shared/agent-wire/handshake.d.ts +0 -56
- package/dist/types/modes/shared/agent-wire/host-tool-bridge.d.ts +0 -16
- package/dist/types/modes/shared/agent-wire/host-uri-bridge.d.ts +0 -17
- package/dist/types/modes/shared/agent-wire/protocol.d.ts +0 -25
- package/dist/types/modes/shared/agent-wire/responses.d.ts +0 -4
- package/dist/types/modes/shared/agent-wire/scopes.d.ts +0 -18
- package/dist/types/modes/shared/agent-wire/session-registry.d.ts +0 -25
- package/dist/types/modes/shared/agent-wire/ui-request-broker.d.ts +0 -42
- package/dist/types/modes/shared/agent-wire/ui-result.d.ts +0 -27
- package/dist/types/modes/shared/agent-wire/unattended-action-policy.d.ts +0 -29
- package/dist/types/modes/shared/agent-wire/unattended-audit.d.ts +0 -68
- package/dist/types/modes/shared/agent-wire/unattended-run-controller.d.ts +0 -166
- package/dist/types/modes/shared/agent-wire/unattended-session.d.ts +0 -127
- package/dist/types/notifications/config.d.ts +0 -132
- package/src/harness-control-plane/rpc-adapter.ts +0 -290
- package/src/modes/bridge/auth.ts +0 -41
- package/src/modes/bridge/bridge-client-bridge.ts +0 -47
- package/src/modes/bridge/bridge-mode.ts +0 -675
- package/src/modes/bridge/bridge-ui-context.ts +0 -200
- package/src/modes/bridge/event-stream.ts +0 -70
- package/src/modes/rpc/host-tools.ts +0 -1
- package/src/modes/rpc/host-uris.ts +0 -1
- package/src/modes/rpc/rpc-client.ts +0 -1166
- package/src/modes/rpc/rpc-mode.ts +0 -1029
- package/src/modes/rpc/rpc-socket-security.ts +0 -115
- package/src/modes/rpc/rpc-types.ts +0 -637
- package/src/modes/shared/agent-wire/command-contract.ts +0 -18
- package/src/modes/shared/agent-wire/command-dispatch.ts +0 -498
- package/src/modes/shared/agent-wire/command-validation.ts +0 -181
- package/src/modes/shared/agent-wire/handshake.ts +0 -157
- package/src/modes/shared/agent-wire/host-tool-bridge.ts +0 -197
- package/src/modes/shared/agent-wire/host-uri-bridge.ts +0 -236
- package/src/modes/shared/agent-wire/protocol.ts +0 -46
- package/src/modes/shared/agent-wire/responses.ts +0 -17
- package/src/modes/shared/agent-wire/scopes.ts +0 -94
- package/src/modes/shared/agent-wire/session-registry.ts +0 -109
- package/src/modes/shared/agent-wire/ui-request-broker.ts +0 -150
- package/src/modes/shared/agent-wire/ui-result.ts +0 -48
- package/src/modes/shared/agent-wire/unattended-action-policy.ts +0 -365
- package/src/modes/shared/agent-wire/unattended-audit.ts +0 -176
- package/src/modes/shared/agent-wire/unattended-run-controller.ts +0 -426
- package/src/modes/shared/agent-wire/unattended-session.ts +0 -528
- package/src/notifications/config.ts +0 -219
- package/src/notifications/index.ts +0 -1835
- package/src/notifications/telegram-daemon-cli.ts +0 -243
- package/src/tools/puppeteer/09_stealth_locale.txt +0 -46
- /package/dist/types/{notifications → sdk/bus}/attachment-registry.d.ts +0 -0
- /package/dist/types/{notifications → sdk/bus}/chat-adapters.d.ts +0 -0
- /package/dist/types/{notifications → sdk/bus}/daemon-paths.d.ts +0 -0
- /package/dist/types/{notifications → sdk/bus}/engine.d.ts +0 -0
- /package/dist/types/{notifications → sdk/bus}/helpers.d.ts +0 -0
- /package/dist/types/{notifications → sdk/bus}/lifecycle-commands.d.ts +0 -0
- /package/dist/types/{notifications → sdk/bus}/operator-runtime.d.ts +0 -0
- /package/dist/types/{notifications → sdk/bus}/rate-limit-pool.d.ts +0 -0
- /package/dist/types/{notifications → sdk/bus}/recent-activity.d.ts +0 -0
- /package/dist/types/{notifications → sdk/bus}/reply-sent-store.d.ts +0 -0
- /package/dist/types/{notifications → sdk/bus}/rich-draft.d.ts +0 -0
- /package/dist/types/{notifications → sdk/bus}/rich-render.d.ts +0 -0
- /package/dist/types/{notifications → sdk/bus}/threaded-inbound.d.ts +0 -0
- /package/dist/types/{notifications → sdk/bus}/threaded-render.d.ts +0 -0
- /package/src/{notifications → sdk/bus}/attachment-registry.ts +0 -0
- /package/src/{notifications → sdk/bus}/chat-adapters.ts +0 -0
- /package/src/{notifications → sdk/bus}/daemon-paths.ts +0 -0
- /package/src/{notifications → sdk/bus}/engine.ts +0 -0
- /package/src/{notifications → sdk/bus}/helpers.ts +0 -0
- /package/src/{notifications → sdk/bus}/operator-runtime.ts +0 -0
- /package/src/{notifications → sdk/bus}/rate-limit-pool.ts +0 -0
- /package/src/{notifications → sdk/bus}/recent-activity.ts +0 -0
- /package/src/{notifications → sdk/bus}/reply-sent-store.ts +0 -0
- /package/src/{notifications → sdk/bus}/rich-draft.ts +0 -0
- /package/src/{notifications → sdk/bus}/rich-render.ts +0 -0
- /package/src/{notifications → sdk/bus}/threaded-inbound.ts +0 -0
- /package/src/{notifications → sdk/bus}/threaded-render.ts +0 -0
|
@@ -1,157 +0,0 @@
|
|
|
1
|
-
import type { RpcUnattendedDeclaration } from "../../rpc/rpc-types";
|
|
2
|
-
import { BRIDGE_PROTOCOL_VERSION, type BridgeFrameType } from "./protocol";
|
|
3
|
-
import type { BridgeCommandScope } from "./scopes";
|
|
4
|
-
|
|
5
|
-
export type BridgeCapability =
|
|
6
|
-
| "events"
|
|
7
|
-
| "prompt"
|
|
8
|
-
| "permission"
|
|
9
|
-
| "elicitation"
|
|
10
|
-
| "ui.declarative"
|
|
11
|
-
| "ui.editor"
|
|
12
|
-
| "ui.terminal_input"
|
|
13
|
-
| "host_tools"
|
|
14
|
-
| "host_uri"
|
|
15
|
-
| "client_bridge.read_text_file"
|
|
16
|
-
| "client_bridge.write_text_file"
|
|
17
|
-
| "client_bridge.create_terminal"
|
|
18
|
-
| "workflow_gate";
|
|
19
|
-
|
|
20
|
-
export interface BridgeProtocolRange {
|
|
21
|
-
min: number;
|
|
22
|
-
max: number;
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
export interface BridgeHandshakeRequest {
|
|
26
|
-
protocol_version_range: BridgeProtocolRange;
|
|
27
|
-
capabilities: BridgeCapability[];
|
|
28
|
-
requested_scopes: BridgeCommandScope[];
|
|
29
|
-
last_seq?: number;
|
|
30
|
-
/** Optional unattended declaration (budget + scope + action allowlist) for #318/#319. */
|
|
31
|
-
unattended?: RpcUnattendedDeclaration;
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
export interface BridgeEndpointDescriptor {
|
|
35
|
-
events: string;
|
|
36
|
-
commands: string;
|
|
37
|
-
uiResponses: string;
|
|
38
|
-
claimControl: string;
|
|
39
|
-
disconnectControl: string;
|
|
40
|
-
hostToolResults: string;
|
|
41
|
-
hostUriResults: string;
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
export interface BridgeHandshakeAccepted {
|
|
45
|
-
status: "accepted";
|
|
46
|
-
protocol_version: typeof BRIDGE_PROTOCOL_VERSION;
|
|
47
|
-
session_id: string;
|
|
48
|
-
accepted_capabilities: BridgeCapability[];
|
|
49
|
-
accepted_scopes: BridgeCommandScope[];
|
|
50
|
-
unsupported: BridgeCapability[];
|
|
51
|
-
endpoints: BridgeEndpointDescriptor;
|
|
52
|
-
frame_types: BridgeFrameType[];
|
|
53
|
-
/** Echoed unattended declaration when one was supplied and accepted (#321). */
|
|
54
|
-
accepted_unattended?: RpcUnattendedDeclaration;
|
|
55
|
-
/** Server-side accepted unattended mode after live negotiation, not just declaration echo. */
|
|
56
|
-
unattended_active?: boolean;
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
export interface BridgeHandshakeRejected {
|
|
60
|
-
status: "rejected";
|
|
61
|
-
reason: "incompatible_version" | "unauthorized" | "invalid_request";
|
|
62
|
-
message: string;
|
|
63
|
-
}
|
|
64
|
-
|
|
65
|
-
export type BridgeHandshakeResponse = BridgeHandshakeAccepted | BridgeHandshakeRejected;
|
|
66
|
-
|
|
67
|
-
/** Shape-validate an optional unattended declaration carried on the handshake. */
|
|
68
|
-
export function isUnattendedDeclarationShape(value: unknown): value is RpcUnattendedDeclaration {
|
|
69
|
-
if (!value || typeof value !== "object") return false;
|
|
70
|
-
const d = value as Record<string, unknown>;
|
|
71
|
-
const b = d.budget as Record<string, unknown> | undefined;
|
|
72
|
-
const budgetOk =
|
|
73
|
-
!!b &&
|
|
74
|
-
typeof b === "object" &&
|
|
75
|
-
// Match UnattendedRunController fail-closed validation: positive finite budgets.
|
|
76
|
-
["max_tokens", "max_tool_calls", "max_wall_time_ms", "max_cost_usd"].every(
|
|
77
|
-
k => typeof b[k] === "number" && Number.isFinite(b[k] as number) && (b[k] as number) > 0,
|
|
78
|
-
);
|
|
79
|
-
return (
|
|
80
|
-
typeof d.actor === "string" &&
|
|
81
|
-
d.actor.trim() !== "" &&
|
|
82
|
-
budgetOk &&
|
|
83
|
-
Array.isArray(d.scopes) &&
|
|
84
|
-
d.scopes.every(s => typeof s === "string") &&
|
|
85
|
-
Array.isArray(d.action_allowlist) &&
|
|
86
|
-
d.action_allowlist.every(s => typeof s === "string")
|
|
87
|
-
);
|
|
88
|
-
}
|
|
89
|
-
export function isBridgeHandshakeRequest(value: unknown): value is BridgeHandshakeRequest {
|
|
90
|
-
if (!value || typeof value !== "object") return false;
|
|
91
|
-
const request = value as {
|
|
92
|
-
protocol_version_range?: unknown;
|
|
93
|
-
capabilities?: unknown;
|
|
94
|
-
requested_scopes?: unknown;
|
|
95
|
-
last_seq?: unknown;
|
|
96
|
-
unattended?: unknown;
|
|
97
|
-
};
|
|
98
|
-
const range = request.protocol_version_range as { min?: unknown; max?: unknown } | undefined;
|
|
99
|
-
return (
|
|
100
|
-
!!range &&
|
|
101
|
-
typeof range.min === "number" &&
|
|
102
|
-
Number.isInteger(range.min) &&
|
|
103
|
-
typeof range.max === "number" &&
|
|
104
|
-
Number.isInteger(range.max) &&
|
|
105
|
-
Array.isArray(request.capabilities) &&
|
|
106
|
-
request.capabilities.every(capability => typeof capability === "string") &&
|
|
107
|
-
Array.isArray(request.requested_scopes) &&
|
|
108
|
-
request.requested_scopes.every(scope => typeof scope === "string") &&
|
|
109
|
-
(request.last_seq === undefined ||
|
|
110
|
-
(typeof request.last_seq === "number" && Number.isInteger(request.last_seq))) &&
|
|
111
|
-
(request.unattended === undefined || isUnattendedDeclarationShape(request.unattended))
|
|
112
|
-
);
|
|
113
|
-
}
|
|
114
|
-
|
|
115
|
-
export function negotiateBridgeHandshake(
|
|
116
|
-
request: BridgeHandshakeRequest,
|
|
117
|
-
server: {
|
|
118
|
-
sessionId: string;
|
|
119
|
-
capabilities: readonly BridgeCapability[];
|
|
120
|
-
scopes: readonly BridgeCommandScope[];
|
|
121
|
-
endpoints: BridgeEndpointDescriptor;
|
|
122
|
-
frameTypes: readonly BridgeFrameType[];
|
|
123
|
-
acceptedUnattended?: RpcUnattendedDeclaration;
|
|
124
|
-
},
|
|
125
|
-
): BridgeHandshakeResponse {
|
|
126
|
-
if (
|
|
127
|
-
request.protocol_version_range.min > BRIDGE_PROTOCOL_VERSION ||
|
|
128
|
-
request.protocol_version_range.max < BRIDGE_PROTOCOL_VERSION
|
|
129
|
-
) {
|
|
130
|
-
return {
|
|
131
|
-
status: "rejected",
|
|
132
|
-
reason: "incompatible_version",
|
|
133
|
-
message: `Bridge protocol v${BRIDGE_PROTOCOL_VERSION} is outside client range ${request.protocol_version_range.min}..${request.protocol_version_range.max}`,
|
|
134
|
-
};
|
|
135
|
-
}
|
|
136
|
-
const serverCapabilities = new Set(server.capabilities);
|
|
137
|
-
const acceptedCapabilities = request.capabilities.filter(capability => serverCapabilities.has(capability));
|
|
138
|
-
const acceptedSet = new Set(acceptedCapabilities);
|
|
139
|
-
const unsupported = request.capabilities.filter(capability => !acceptedSet.has(capability));
|
|
140
|
-
const serverScopes = new Set(server.scopes);
|
|
141
|
-
const acceptedScopes = request.requested_scopes.filter(scope => serverScopes.has(scope));
|
|
142
|
-
const accepted: BridgeHandshakeAccepted = {
|
|
143
|
-
status: "accepted",
|
|
144
|
-
protocol_version: BRIDGE_PROTOCOL_VERSION,
|
|
145
|
-
session_id: server.sessionId,
|
|
146
|
-
accepted_capabilities: acceptedCapabilities,
|
|
147
|
-
accepted_scopes: acceptedScopes,
|
|
148
|
-
unsupported,
|
|
149
|
-
endpoints: server.endpoints,
|
|
150
|
-
frame_types: [...server.frameTypes],
|
|
151
|
-
};
|
|
152
|
-
if (server.acceptedUnattended !== undefined && acceptedSet.has("workflow_gate")) {
|
|
153
|
-
accepted.accepted_unattended = server.acceptedUnattended;
|
|
154
|
-
accepted.unattended_active = true;
|
|
155
|
-
}
|
|
156
|
-
return accepted;
|
|
157
|
-
}
|
|
@@ -1,197 +0,0 @@
|
|
|
1
|
-
import type { AgentTool, AgentToolResult, AgentToolUpdateCallback } from "@gajae-code/agent-core";
|
|
2
|
-
import type { Static, TSchema } from "@gajae-code/ai";
|
|
3
|
-
import { Snowflake } from "@gajae-code/utils";
|
|
4
|
-
import { applyToolProxy } from "../../../extensibility/tool-proxy";
|
|
5
|
-
import type {
|
|
6
|
-
RpcHostToolCallRequest,
|
|
7
|
-
RpcHostToolCancelRequest,
|
|
8
|
-
RpcHostToolDefinition,
|
|
9
|
-
RpcHostToolResult,
|
|
10
|
-
RpcHostToolUpdate,
|
|
11
|
-
} from "../../rpc/rpc-types";
|
|
12
|
-
import type { Theme } from "../../theme/theme";
|
|
13
|
-
|
|
14
|
-
type RpcHostToolOutput = (frame: RpcHostToolCallRequest | RpcHostToolCancelRequest) => void;
|
|
15
|
-
|
|
16
|
-
type PendingHostToolCall = {
|
|
17
|
-
resolve: (result: AgentToolResult<unknown>) => void;
|
|
18
|
-
reject: (error: Error) => void;
|
|
19
|
-
onUpdate?: AgentToolUpdateCallback<unknown>;
|
|
20
|
-
};
|
|
21
|
-
|
|
22
|
-
function isAgentToolResult(value: unknown): value is AgentToolResult<unknown> {
|
|
23
|
-
if (!value || typeof value !== "object") return false;
|
|
24
|
-
const content = (value as { content?: unknown }).content;
|
|
25
|
-
return (
|
|
26
|
-
Array.isArray(content) &&
|
|
27
|
-
content.every(item => !!item && typeof item === "object" && typeof (item as { type?: unknown }).type === "string")
|
|
28
|
-
);
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
export function isRpcHostToolResult(value: unknown): value is RpcHostToolResult {
|
|
32
|
-
if (!value || typeof value !== "object") return false;
|
|
33
|
-
const frame = value as { type?: unknown; id?: unknown; result?: unknown; isError?: unknown };
|
|
34
|
-
return (
|
|
35
|
-
frame.type === "host_tool_result" &&
|
|
36
|
-
typeof frame.id === "string" &&
|
|
37
|
-
isAgentToolResult(frame.result) &&
|
|
38
|
-
(frame.isError === undefined || typeof frame.isError === "boolean")
|
|
39
|
-
);
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
export function isRpcHostToolUpdate(value: unknown): value is RpcHostToolUpdate {
|
|
43
|
-
if (!value || typeof value !== "object") return false;
|
|
44
|
-
const frame = value as { type?: unknown; id?: unknown; partialResult?: unknown };
|
|
45
|
-
return frame.type === "host_tool_update" && typeof frame.id === "string" && isAgentToolResult(frame.partialResult);
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
class RpcHostToolAdapter<TParams extends TSchema = TSchema, TTheme extends Theme = Theme>
|
|
49
|
-
implements AgentTool<TParams, unknown, TTheme>
|
|
50
|
-
{
|
|
51
|
-
declare name: string;
|
|
52
|
-
declare label: string;
|
|
53
|
-
declare description: string;
|
|
54
|
-
declare parameters: TParams;
|
|
55
|
-
readonly strict = true;
|
|
56
|
-
concurrency: "shared" | "exclusive" = "shared";
|
|
57
|
-
#bridge: RpcHostToolBridge;
|
|
58
|
-
#definition: RpcHostToolDefinition;
|
|
59
|
-
|
|
60
|
-
constructor(definition: RpcHostToolDefinition, bridge: RpcHostToolBridge) {
|
|
61
|
-
this.#definition = definition;
|
|
62
|
-
this.#bridge = bridge;
|
|
63
|
-
applyToolProxy(definition, this);
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
execute(
|
|
67
|
-
toolCallId: string,
|
|
68
|
-
params: Static<TParams>,
|
|
69
|
-
signal?: AbortSignal,
|
|
70
|
-
onUpdate?: AgentToolUpdateCallback<unknown>,
|
|
71
|
-
): Promise<AgentToolResult<unknown>> {
|
|
72
|
-
return this.#bridge.requestExecution(
|
|
73
|
-
this.#definition,
|
|
74
|
-
toolCallId,
|
|
75
|
-
params as Record<string, unknown>,
|
|
76
|
-
signal,
|
|
77
|
-
onUpdate,
|
|
78
|
-
);
|
|
79
|
-
}
|
|
80
|
-
}
|
|
81
|
-
|
|
82
|
-
export class RpcHostToolBridge {
|
|
83
|
-
#output: RpcHostToolOutput;
|
|
84
|
-
#definitions = new Map<string, RpcHostToolDefinition>();
|
|
85
|
-
#pendingCalls = new Map<string, PendingHostToolCall>();
|
|
86
|
-
|
|
87
|
-
constructor(output: RpcHostToolOutput) {
|
|
88
|
-
this.#output = output;
|
|
89
|
-
}
|
|
90
|
-
|
|
91
|
-
getToolNames(): string[] {
|
|
92
|
-
return Array.from(this.#definitions.keys());
|
|
93
|
-
}
|
|
94
|
-
|
|
95
|
-
setTools(tools: RpcHostToolDefinition[]): AgentTool[] {
|
|
96
|
-
if (tools.some(tool => tool.name === "ask")) {
|
|
97
|
-
throw new Error('RPC host tool "ask" is reserved and cannot be supplied by the host');
|
|
98
|
-
}
|
|
99
|
-
this.#definitions = new Map(tools.map(tool => [tool.name, tool]));
|
|
100
|
-
return tools.map(tool => new RpcHostToolAdapter(tool, this));
|
|
101
|
-
}
|
|
102
|
-
|
|
103
|
-
handleResult(frame: RpcHostToolResult): boolean {
|
|
104
|
-
const pending = this.#pendingCalls.get(frame.id);
|
|
105
|
-
if (!pending) return false;
|
|
106
|
-
this.#pendingCalls.delete(frame.id);
|
|
107
|
-
if (frame.isError) {
|
|
108
|
-
const text = frame.result.content
|
|
109
|
-
.filter(
|
|
110
|
-
(item): item is { type: "text"; text: string } => item.type === "text" && typeof item.text === "string",
|
|
111
|
-
)
|
|
112
|
-
.map(item => item.text)
|
|
113
|
-
.join("\n")
|
|
114
|
-
.trim();
|
|
115
|
-
pending.reject(new Error(text || "Host tool execution failed"));
|
|
116
|
-
return true;
|
|
117
|
-
}
|
|
118
|
-
pending.resolve(frame.result);
|
|
119
|
-
return true;
|
|
120
|
-
}
|
|
121
|
-
|
|
122
|
-
handleUpdate(frame: RpcHostToolUpdate): boolean {
|
|
123
|
-
const pending = this.#pendingCalls.get(frame.id);
|
|
124
|
-
if (!pending) return false;
|
|
125
|
-
pending.onUpdate?.(frame.partialResult);
|
|
126
|
-
return true;
|
|
127
|
-
}
|
|
128
|
-
|
|
129
|
-
requestExecution(
|
|
130
|
-
definition: RpcHostToolDefinition,
|
|
131
|
-
toolCallId: string,
|
|
132
|
-
args: Record<string, unknown>,
|
|
133
|
-
signal?: AbortSignal,
|
|
134
|
-
onUpdate?: AgentToolUpdateCallback<unknown>,
|
|
135
|
-
): Promise<AgentToolResult<unknown>> {
|
|
136
|
-
if (signal?.aborted) {
|
|
137
|
-
return Promise.reject(new Error(`Host tool "${definition.name}" was aborted`));
|
|
138
|
-
}
|
|
139
|
-
|
|
140
|
-
const id = Snowflake.next() as string;
|
|
141
|
-
const { promise, resolve, reject } = Promise.withResolvers<AgentToolResult<unknown>>();
|
|
142
|
-
let settled = false;
|
|
143
|
-
|
|
144
|
-
const cleanup = () => {
|
|
145
|
-
signal?.removeEventListener("abort", onAbort);
|
|
146
|
-
this.#pendingCalls.delete(id);
|
|
147
|
-
};
|
|
148
|
-
|
|
149
|
-
const onAbort = () => {
|
|
150
|
-
if (settled) return;
|
|
151
|
-
settled = true;
|
|
152
|
-
cleanup();
|
|
153
|
-
this.#output({
|
|
154
|
-
type: "host_tool_cancel",
|
|
155
|
-
id: Snowflake.next() as string,
|
|
156
|
-
targetId: id,
|
|
157
|
-
});
|
|
158
|
-
reject(new Error(`Host tool "${definition.name}" was aborted`));
|
|
159
|
-
};
|
|
160
|
-
|
|
161
|
-
signal?.addEventListener("abort", onAbort, { once: true });
|
|
162
|
-
this.#pendingCalls.set(id, {
|
|
163
|
-
resolve: result => {
|
|
164
|
-
if (settled) return;
|
|
165
|
-
settled = true;
|
|
166
|
-
cleanup();
|
|
167
|
-
resolve(result);
|
|
168
|
-
},
|
|
169
|
-
reject: error => {
|
|
170
|
-
if (settled) return;
|
|
171
|
-
settled = true;
|
|
172
|
-
cleanup();
|
|
173
|
-
reject(error);
|
|
174
|
-
},
|
|
175
|
-
onUpdate,
|
|
176
|
-
});
|
|
177
|
-
|
|
178
|
-
this.#output({
|
|
179
|
-
type: "host_tool_call",
|
|
180
|
-
id,
|
|
181
|
-
toolCallId,
|
|
182
|
-
toolName: definition.name,
|
|
183
|
-
arguments: args,
|
|
184
|
-
});
|
|
185
|
-
|
|
186
|
-
return promise;
|
|
187
|
-
}
|
|
188
|
-
|
|
189
|
-
rejectAllPending(message: string): void {
|
|
190
|
-
const error = new Error(message);
|
|
191
|
-
const pendingCalls = Array.from(this.#pendingCalls.values());
|
|
192
|
-
this.#pendingCalls.clear();
|
|
193
|
-
for (const pending of pendingCalls) {
|
|
194
|
-
pending.reject(error);
|
|
195
|
-
}
|
|
196
|
-
}
|
|
197
|
-
}
|
|
@@ -1,236 +0,0 @@
|
|
|
1
|
-
import { Snowflake } from "@gajae-code/utils";
|
|
2
|
-
import { InternalUrlRouter } from "../../../internal-urls";
|
|
3
|
-
import type {
|
|
4
|
-
InternalResource,
|
|
5
|
-
InternalUrl,
|
|
6
|
-
ProtocolHandler,
|
|
7
|
-
ResolveContext,
|
|
8
|
-
WriteContext,
|
|
9
|
-
} from "../../../internal-urls/types";
|
|
10
|
-
import type {
|
|
11
|
-
RpcHostUriCancelRequest,
|
|
12
|
-
RpcHostUriRequest,
|
|
13
|
-
RpcHostUriResult,
|
|
14
|
-
RpcHostUriSchemeDefinition,
|
|
15
|
-
} from "../../rpc/rpc-types";
|
|
16
|
-
|
|
17
|
-
const RESERVED_INTERNAL_URI_SCHEMES = new Set(["gjc", "agent", "artifact", "memory", "local", "rule", "issue", "pr"]);
|
|
18
|
-
|
|
19
|
-
type RpcHostUriOutput = (frame: RpcHostUriRequest | RpcHostUriCancelRequest) => void;
|
|
20
|
-
|
|
21
|
-
type PendingUriRequest = {
|
|
22
|
-
operation: "read" | "write";
|
|
23
|
-
url: string;
|
|
24
|
-
resolve: (frame: RpcHostUriResult) => void;
|
|
25
|
-
reject: (error: Error) => void;
|
|
26
|
-
};
|
|
27
|
-
|
|
28
|
-
export function isRpcHostUriResult(value: unknown): value is RpcHostUriResult {
|
|
29
|
-
if (!value || typeof value !== "object") return false;
|
|
30
|
-
const frame = value as {
|
|
31
|
-
type?: unknown;
|
|
32
|
-
id?: unknown;
|
|
33
|
-
content?: unknown;
|
|
34
|
-
contentType?: unknown;
|
|
35
|
-
notes?: unknown;
|
|
36
|
-
immutable?: unknown;
|
|
37
|
-
isError?: unknown;
|
|
38
|
-
error?: unknown;
|
|
39
|
-
};
|
|
40
|
-
return (
|
|
41
|
-
frame.type === "host_uri_result" &&
|
|
42
|
-
typeof frame.id === "string" &&
|
|
43
|
-
(frame.content === undefined || typeof frame.content === "string") &&
|
|
44
|
-
(frame.contentType === undefined ||
|
|
45
|
-
frame.contentType === "text/markdown" ||
|
|
46
|
-
frame.contentType === "application/json" ||
|
|
47
|
-
frame.contentType === "text/plain") &&
|
|
48
|
-
(frame.notes === undefined ||
|
|
49
|
-
(Array.isArray(frame.notes) && frame.notes.every(note => typeof note === "string"))) &&
|
|
50
|
-
(frame.immutable === undefined || typeof frame.immutable === "boolean") &&
|
|
51
|
-
(frame.isError === undefined || typeof frame.isError === "boolean") &&
|
|
52
|
-
(frame.error === undefined || typeof frame.error === "string")
|
|
53
|
-
);
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
class RpcHostUriProtocolHandler implements ProtocolHandler {
|
|
57
|
-
readonly scheme: string;
|
|
58
|
-
readonly immutable: boolean;
|
|
59
|
-
readonly write?: (url: InternalUrl, content: string, context?: WriteContext) => Promise<void>;
|
|
60
|
-
readonly #bridge: RpcHostUriBridge;
|
|
61
|
-
|
|
62
|
-
constructor(definition: RpcHostUriSchemeDefinition, bridge: RpcHostUriBridge) {
|
|
63
|
-
this.scheme = definition.scheme;
|
|
64
|
-
this.immutable = definition.immutable === true;
|
|
65
|
-
this.#bridge = bridge;
|
|
66
|
-
if (definition.writable === true) {
|
|
67
|
-
this.write = (url, content, context) => this.#bridge.requestWrite(this.scheme, url, content, context);
|
|
68
|
-
}
|
|
69
|
-
}
|
|
70
|
-
|
|
71
|
-
resolve(url: InternalUrl, context?: ResolveContext): Promise<InternalResource> {
|
|
72
|
-
return this.#bridge.requestRead(this.scheme, url, context);
|
|
73
|
-
}
|
|
74
|
-
}
|
|
75
|
-
|
|
76
|
-
export class RpcHostUriBridge {
|
|
77
|
-
#output: RpcHostUriOutput;
|
|
78
|
-
#router: InternalUrlRouter;
|
|
79
|
-
#definitions = new Map<string, RpcHostUriSchemeDefinition>();
|
|
80
|
-
#pending = new Map<string, PendingUriRequest>();
|
|
81
|
-
|
|
82
|
-
constructor(output: RpcHostUriOutput, router: InternalUrlRouter = InternalUrlRouter.instance()) {
|
|
83
|
-
this.#output = output;
|
|
84
|
-
this.#router = router;
|
|
85
|
-
}
|
|
86
|
-
|
|
87
|
-
getSchemes(): string[] {
|
|
88
|
-
return Array.from(this.#definitions.keys());
|
|
89
|
-
}
|
|
90
|
-
|
|
91
|
-
setSchemes(schemes: RpcHostUriSchemeDefinition[]): string[] {
|
|
92
|
-
const normalized = new Map<string, RpcHostUriSchemeDefinition>();
|
|
93
|
-
for (const raw of schemes) {
|
|
94
|
-
const scheme = typeof raw?.scheme === "string" ? raw.scheme.trim().toLowerCase() : "";
|
|
95
|
-
if (!scheme) {
|
|
96
|
-
throw new Error("Host URI scheme must be a non-empty string");
|
|
97
|
-
}
|
|
98
|
-
if (!/^[a-z][a-z0-9+.-]*$/.test(scheme)) {
|
|
99
|
-
throw new Error(`Host URI scheme contains invalid characters: ${raw.scheme}`);
|
|
100
|
-
}
|
|
101
|
-
if (RESERVED_INTERNAL_URI_SCHEMES.has(scheme)) {
|
|
102
|
-
throw new Error(`Host URI scheme is reserved: ${scheme}`);
|
|
103
|
-
}
|
|
104
|
-
normalized.set(scheme, {
|
|
105
|
-
scheme,
|
|
106
|
-
description: typeof raw.description === "string" ? raw.description : undefined,
|
|
107
|
-
writable: raw.writable === true,
|
|
108
|
-
immutable: raw.immutable === true,
|
|
109
|
-
});
|
|
110
|
-
}
|
|
111
|
-
|
|
112
|
-
for (const previous of this.#definitions.keys()) {
|
|
113
|
-
if (!normalized.has(previous)) {
|
|
114
|
-
this.#router.unregister(previous);
|
|
115
|
-
}
|
|
116
|
-
}
|
|
117
|
-
for (const definition of normalized.values()) {
|
|
118
|
-
this.#router.register(new RpcHostUriProtocolHandler(definition, this));
|
|
119
|
-
}
|
|
120
|
-
this.#definitions = normalized;
|
|
121
|
-
return Array.from(normalized.keys());
|
|
122
|
-
}
|
|
123
|
-
|
|
124
|
-
clear(message: string = "Host URI bridge shut down"): void {
|
|
125
|
-
for (const scheme of this.#definitions.keys()) {
|
|
126
|
-
this.#router.unregister(scheme);
|
|
127
|
-
}
|
|
128
|
-
this.#definitions.clear();
|
|
129
|
-
this.rejectAllPending(message);
|
|
130
|
-
}
|
|
131
|
-
|
|
132
|
-
handleResult(frame: RpcHostUriResult): boolean {
|
|
133
|
-
const pending = this.#pending.get(frame.id);
|
|
134
|
-
if (!pending) return false;
|
|
135
|
-
this.#pending.delete(frame.id);
|
|
136
|
-
pending.resolve(frame);
|
|
137
|
-
return true;
|
|
138
|
-
}
|
|
139
|
-
|
|
140
|
-
rejectAllPending(message: string): void {
|
|
141
|
-
const error = new Error(message);
|
|
142
|
-
const pending = Array.from(this.#pending.values());
|
|
143
|
-
this.#pending.clear();
|
|
144
|
-
for (const entry of pending) {
|
|
145
|
-
entry.reject(error);
|
|
146
|
-
}
|
|
147
|
-
}
|
|
148
|
-
|
|
149
|
-
async requestRead(scheme: string, url: InternalUrl, context?: ResolveContext): Promise<InternalResource> {
|
|
150
|
-
const result = await this.#dispatch("read", url.href, undefined, context?.signal);
|
|
151
|
-
if (result.isError) {
|
|
152
|
-
throw new Error(result.error || result.content || `Host URI read failed for ${url.href}`);
|
|
153
|
-
}
|
|
154
|
-
const content = result.content ?? "";
|
|
155
|
-
const contentType = result.contentType ?? "text/plain";
|
|
156
|
-
const definition = this.#definitions.get(scheme);
|
|
157
|
-
return {
|
|
158
|
-
url: url.href,
|
|
159
|
-
content,
|
|
160
|
-
contentType,
|
|
161
|
-
size: Buffer.byteLength(content, "utf-8"),
|
|
162
|
-
notes: result.notes && result.notes.length > 0 ? [...result.notes] : undefined,
|
|
163
|
-
immutable: result.immutable ?? definition?.immutable === true,
|
|
164
|
-
};
|
|
165
|
-
}
|
|
166
|
-
|
|
167
|
-
async requestWrite(_scheme: string, url: InternalUrl, content: string, context?: WriteContext): Promise<void> {
|
|
168
|
-
const result = await this.#dispatch("write", url.href, content, context?.signal);
|
|
169
|
-
if (result.isError) {
|
|
170
|
-
throw new Error(result.error || result.content || `Host URI write failed for ${url.href}`);
|
|
171
|
-
}
|
|
172
|
-
}
|
|
173
|
-
|
|
174
|
-
#dispatch(
|
|
175
|
-
operation: "read" | "write",
|
|
176
|
-
url: string,
|
|
177
|
-
content: string | undefined,
|
|
178
|
-
signal: AbortSignal | undefined,
|
|
179
|
-
): Promise<RpcHostUriResult> {
|
|
180
|
-
if (signal?.aborted) {
|
|
181
|
-
return Promise.reject(new Error(`Host URI ${operation} for ${url} was aborted`));
|
|
182
|
-
}
|
|
183
|
-
|
|
184
|
-
const id = Snowflake.next() as string;
|
|
185
|
-
const { promise, resolve, reject } = Promise.withResolvers<RpcHostUriResult>();
|
|
186
|
-
let settled = false;
|
|
187
|
-
|
|
188
|
-
const cleanup = () => {
|
|
189
|
-
signal?.removeEventListener("abort", onAbort);
|
|
190
|
-
this.#pending.delete(id);
|
|
191
|
-
};
|
|
192
|
-
|
|
193
|
-
const onAbort = () => {
|
|
194
|
-
if (settled) return;
|
|
195
|
-
settled = true;
|
|
196
|
-
cleanup();
|
|
197
|
-
this.#output({
|
|
198
|
-
type: "host_uri_cancel",
|
|
199
|
-
id: Snowflake.next() as string,
|
|
200
|
-
targetId: id,
|
|
201
|
-
});
|
|
202
|
-
reject(new Error(`Host URI ${operation} for ${url} was aborted`));
|
|
203
|
-
};
|
|
204
|
-
|
|
205
|
-
signal?.addEventListener("abort", onAbort, { once: true });
|
|
206
|
-
this.#pending.set(id, {
|
|
207
|
-
operation,
|
|
208
|
-
url,
|
|
209
|
-
resolve: frame => {
|
|
210
|
-
if (settled) return;
|
|
211
|
-
settled = true;
|
|
212
|
-
cleanup();
|
|
213
|
-
resolve(frame);
|
|
214
|
-
},
|
|
215
|
-
reject: err => {
|
|
216
|
-
if (settled) return;
|
|
217
|
-
settled = true;
|
|
218
|
-
cleanup();
|
|
219
|
-
reject(err);
|
|
220
|
-
},
|
|
221
|
-
});
|
|
222
|
-
|
|
223
|
-
const frame: RpcHostUriRequest = {
|
|
224
|
-
type: "host_uri_request",
|
|
225
|
-
id,
|
|
226
|
-
operation,
|
|
227
|
-
url,
|
|
228
|
-
};
|
|
229
|
-
if (operation === "write") {
|
|
230
|
-
frame.content = content ?? "";
|
|
231
|
-
}
|
|
232
|
-
this.#output(frame);
|
|
233
|
-
|
|
234
|
-
return promise;
|
|
235
|
-
}
|
|
236
|
-
}
|
|
@@ -1,46 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Shared agent-wire protocol primitives for GJC bridge surfaces.
|
|
3
|
-
*
|
|
4
|
-
* The canonical event/frame contract now lives in `event-contract.ts`. This
|
|
5
|
-
* module re-exports it under the historical `Bridge*` names so existing RPC and
|
|
6
|
-
* Bridge code keeps compiling while the adapters migrate to the canonical
|
|
7
|
-
* `AgentWire*` names. See `.gjc/specs/deep-interview-reconcile-rpc-adapters.md`.
|
|
8
|
-
*/
|
|
9
|
-
import type {
|
|
10
|
-
AgentWireEventFrame,
|
|
11
|
-
AgentWireEventPayload,
|
|
12
|
-
AgentWireEventType,
|
|
13
|
-
AgentWireFrameEnvelope,
|
|
14
|
-
AgentWireFrameType,
|
|
15
|
-
} from "./event-contract";
|
|
16
|
-
import { AGENT_WIRE_EVENT_TYPES, AGENT_WIRE_PROTOCOL_VERSION } from "./event-contract";
|
|
17
|
-
|
|
18
|
-
/** Wire protocol version. Bump on breaking envelope/semantic changes. */
|
|
19
|
-
export const BRIDGE_PROTOCOL_VERSION = AGENT_WIRE_PROTOCOL_VERSION;
|
|
20
|
-
|
|
21
|
-
/** The discriminant of every `AgentSessionEvent` the agent can emit. */
|
|
22
|
-
export type AgentSessionEventType = AgentWireEventType;
|
|
23
|
-
|
|
24
|
-
/** Every agent-session event type, derived from the exhaustive registry. */
|
|
25
|
-
export const AGENT_SESSION_EVENT_TYPES: readonly AgentSessionEventType[] = AGENT_WIRE_EVENT_TYPES;
|
|
26
|
-
|
|
27
|
-
/** Top-level frame categories carried over any bridge transport. */
|
|
28
|
-
export type BridgeFrameType = AgentWireFrameType;
|
|
29
|
-
|
|
30
|
-
/** Universal frame envelope. See {@link AgentWireFrameEnvelope}. */
|
|
31
|
-
export type BridgeFrameEnvelope<
|
|
32
|
-
TType extends BridgeFrameType = BridgeFrameType,
|
|
33
|
-
TPayload = unknown,
|
|
34
|
-
> = AgentWireFrameEnvelope<TType, TPayload>;
|
|
35
|
-
|
|
36
|
-
/** Payload carried by an `event` frame. See {@link AgentWireEventPayload}. */
|
|
37
|
-
export type BridgeEventPayload = AgentWireEventPayload;
|
|
38
|
-
|
|
39
|
-
/** An `AgentSessionEvent` serialized into a versioned wire frame. */
|
|
40
|
-
export type BridgeEventFrame = AgentWireEventFrame;
|
|
41
|
-
|
|
42
|
-
/** A `workflow_gate` event serialized into a versioned wire frame (#321). */
|
|
43
|
-
export type BridgeWorkflowGateFrame = BridgeFrameEnvelope<
|
|
44
|
-
"workflow_gate",
|
|
45
|
-
import("../../rpc/rpc-types").RpcWorkflowGate
|
|
46
|
-
>;
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
/** Shared RPC-compatible response helpers for agent-wire consumers. */
|
|
2
|
-
import type { RpcCommand, RpcResponse } from "../../rpc/rpc-types";
|
|
3
|
-
|
|
4
|
-
export function rpcSuccess<T extends RpcCommand["type"]>(
|
|
5
|
-
id: string | undefined,
|
|
6
|
-
command: T,
|
|
7
|
-
data?: object | null,
|
|
8
|
-
): RpcResponse {
|
|
9
|
-
if (data === undefined) {
|
|
10
|
-
return { id, type: "response", command, success: true } as RpcResponse;
|
|
11
|
-
}
|
|
12
|
-
return { id, type: "response", command, success: true, data } as RpcResponse;
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
export function rpcError(id: string | undefined, command: string, error: string | object): RpcResponse {
|
|
16
|
-
return { id, type: "response", command, success: false, error } as RpcResponse;
|
|
17
|
-
}
|