@jini-ai/agent-runtime 0.1.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/LICENSE +201 -0
- package/README.md +43 -0
- package/dist/acp-model-probe.d.ts +48 -0
- package/dist/acp-model-probe.d.ts.map +1 -0
- package/dist/acp-model-probe.js +15 -0
- package/dist/acp-model-probe.js.map +1 -0
- package/dist/agent-protocol/acp/account-failure.d.ts +54 -0
- package/dist/agent-protocol/acp/account-failure.d.ts.map +1 -0
- package/dist/agent-protocol/acp/account-failure.js +37 -0
- package/dist/agent-protocol/acp/account-failure.js.map +1 -0
- package/dist/agent-protocol/acp/constants.d.ts +26 -0
- package/dist/agent-protocol/acp/constants.d.ts.map +1 -0
- package/dist/agent-protocol/acp/constants.js +39 -0
- package/dist/agent-protocol/acp/constants.js.map +1 -0
- package/dist/agent-protocol/acp/index.d.ts +14 -0
- package/dist/agent-protocol/acp/index.d.ts.map +1 -0
- package/dist/agent-protocol/acp/index.js +14 -0
- package/dist/agent-protocol/acp/index.js.map +1 -0
- package/dist/agent-protocol/acp/json.d.ts +82 -0
- package/dist/agent-protocol/acp/json.d.ts.map +1 -0
- package/dist/agent-protocol/acp/json.js +144 -0
- package/dist/agent-protocol/acp/json.js.map +1 -0
- package/dist/agent-protocol/acp/models.d.ts +112 -0
- package/dist/agent-protocol/acp/models.d.ts.map +1 -0
- package/dist/agent-protocol/acp/models.js +293 -0
- package/dist/agent-protocol/acp/models.js.map +1 -0
- package/dist/agent-protocol/acp/rpc.d.ts +107 -0
- package/dist/agent-protocol/acp/rpc.d.ts.map +1 -0
- package/dist/agent-protocol/acp/rpc.js +162 -0
- package/dist/agent-protocol/acp/rpc.js.map +1 -0
- package/dist/agent-protocol/acp/session-params.d.ts +55 -0
- package/dist/agent-protocol/acp/session-params.d.ts.map +1 -0
- package/dist/agent-protocol/acp/session-params.js +81 -0
- package/dist/agent-protocol/acp/session-params.js.map +1 -0
- package/dist/agent-protocol/acp/session.d.ts +101 -0
- package/dist/agent-protocol/acp/session.d.ts.map +1 -0
- package/dist/agent-protocol/acp/session.js +832 -0
- package/dist/agent-protocol/acp/session.js.map +1 -0
- package/dist/agent-protocol/acp/text-suppression.d.ts +73 -0
- package/dist/agent-protocol/acp/text-suppression.d.ts.map +1 -0
- package/dist/agent-protocol/acp/text-suppression.js +229 -0
- package/dist/agent-protocol/acp/text-suppression.js.map +1 -0
- package/dist/agent-protocol/acp/types.d.ts +27 -0
- package/dist/agent-protocol/acp/types.d.ts.map +1 -0
- package/dist/agent-protocol/acp/types.js +2 -0
- package/dist/agent-protocol/acp/types.js.map +1 -0
- package/dist/agent-protocol/acp/updates.d.ts +166 -0
- package/dist/agent-protocol/acp/updates.d.ts.map +1 -0
- package/dist/agent-protocol/acp/updates.js +268 -0
- package/dist/agent-protocol/acp/updates.js.map +1 -0
- package/dist/agent-protocol/core/index.d.ts +6 -0
- package/dist/agent-protocol/core/index.d.ts.map +1 -0
- package/dist/agent-protocol/core/index.js +6 -0
- package/dist/agent-protocol/core/index.js.map +1 -0
- package/dist/agent-protocol/core/json-line-stream.d.ts +42 -0
- package/dist/agent-protocol/core/json-line-stream.d.ts.map +1 -0
- package/dist/agent-protocol/core/json-line-stream.js +333 -0
- package/dist/agent-protocol/core/json-line-stream.js.map +1 -0
- package/dist/agent-protocol/index.d.ts +8 -0
- package/dist/agent-protocol/index.d.ts.map +1 -0
- package/dist/agent-protocol/index.js +8 -0
- package/dist/agent-protocol/index.js.map +1 -0
- package/dist/agent-protocol/pi-rpc/events.d.ts +26 -0
- package/dist/agent-protocol/pi-rpc/events.d.ts.map +1 -0
- package/dist/agent-protocol/pi-rpc/events.js +167 -0
- package/dist/agent-protocol/pi-rpc/events.js.map +1 -0
- package/dist/agent-protocol/pi-rpc/index.d.ts +11 -0
- package/dist/agent-protocol/pi-rpc/index.d.ts.map +1 -0
- package/dist/agent-protocol/pi-rpc/index.js +11 -0
- package/dist/agent-protocol/pi-rpc/index.js.map +1 -0
- package/dist/agent-protocol/pi-rpc/internal.d.ts +45 -0
- package/dist/agent-protocol/pi-rpc/internal.d.ts.map +1 -0
- package/dist/agent-protocol/pi-rpc/internal.js +41 -0
- package/dist/agent-protocol/pi-rpc/internal.js.map +1 -0
- package/dist/agent-protocol/pi-rpc/models.d.ts +21 -0
- package/dist/agent-protocol/pi-rpc/models.d.ts.map +1 -0
- package/dist/agent-protocol/pi-rpc/models.js +48 -0
- package/dist/agent-protocol/pi-rpc/models.js.map +1 -0
- package/dist/agent-protocol/pi-rpc/session.d.ts +106 -0
- package/dist/agent-protocol/pi-rpc/session.d.ts.map +1 -0
- package/dist/agent-protocol/pi-rpc/session.js +371 -0
- package/dist/agent-protocol/pi-rpc/session.js.map +1 -0
- package/dist/amr-model-cache.d.ts +40 -0
- package/dist/amr-model-cache.d.ts.map +1 -0
- package/dist/amr-model-cache.js +79 -0
- package/dist/amr-model-cache.js.map +1 -0
- package/dist/amr-profile-resolver.d.ts +21 -0
- package/dist/amr-profile-resolver.d.ts.map +1 -0
- package/dist/amr-profile-resolver.js +4 -0
- package/dist/amr-profile-resolver.js.map +1 -0
- package/dist/artifact-taxonomy.d.ts +27 -0
- package/dist/artifact-taxonomy.d.ts.map +1 -0
- package/dist/artifact-taxonomy.js +5 -0
- package/dist/artifact-taxonomy.js.map +1 -0
- package/dist/auth.d.ts +25 -0
- package/dist/auth.d.ts.map +1 -0
- package/dist/auth.js +332 -0
- package/dist/auth.js.map +1 -0
- package/dist/capabilities.d.ts +9 -0
- package/dist/capabilities.d.ts.map +1 -0
- package/dist/capabilities.js +2 -0
- package/dist/capabilities.js.map +1 -0
- package/dist/claude-stream.d.ts +37 -0
- package/dist/claude-stream.d.ts.map +1 -0
- package/dist/claude-stream.js +660 -0
- package/dist/claude-stream.js.map +1 -0
- package/dist/copilot-stream.d.ts +37 -0
- package/dist/copilot-stream.d.ts.map +1 -0
- package/dist/copilot-stream.js +136 -0
- package/dist/copilot-stream.js.map +1 -0
- package/dist/defs/aider.d.ts +13 -0
- package/dist/defs/aider.d.ts.map +1 -0
- package/dist/defs/aider.js +63 -0
- package/dist/defs/aider.js.map +1 -0
- package/dist/defs/amp.d.ts +12 -0
- package/dist/defs/amp.d.ts.map +1 -0
- package/dist/defs/amp.js +56 -0
- package/dist/defs/amp.js.map +1 -0
- package/dist/defs/amr.d.ts +37 -0
- package/dist/defs/amr.d.ts.map +1 -0
- package/dist/defs/amr.js +303 -0
- package/dist/defs/amr.js.map +1 -0
- package/dist/defs/antigravity.d.ts +25 -0
- package/dist/defs/antigravity.d.ts.map +1 -0
- package/dist/defs/antigravity.js +213 -0
- package/dist/defs/antigravity.js.map +1 -0
- package/dist/defs/claude.d.ts +30 -0
- package/dist/defs/claude.d.ts.map +1 -0
- package/dist/defs/claude.js +130 -0
- package/dist/defs/claude.js.map +1 -0
- package/dist/defs/codebuddy.d.ts +26 -0
- package/dist/defs/codebuddy.d.ts.map +1 -0
- package/dist/defs/codebuddy.js +124 -0
- package/dist/defs/codebuddy.js.map +1 -0
- package/dist/defs/codex.d.ts +30 -0
- package/dist/defs/codex.d.ts.map +1 -0
- package/dist/defs/codex.js +196 -0
- package/dist/defs/codex.js.map +1 -0
- package/dist/defs/copilot.d.ts +12 -0
- package/dist/defs/copilot.d.ts.map +1 -0
- package/dist/defs/copilot.js +88 -0
- package/dist/defs/copilot.js.map +1 -0
- package/dist/defs/cursor-agent.d.ts +27 -0
- package/dist/defs/cursor-agent.d.ts.map +1 -0
- package/dist/defs/cursor-agent.js +93 -0
- package/dist/defs/cursor-agent.js.map +1 -0
- package/dist/defs/deepseek.d.ts +12 -0
- package/dist/defs/deepseek.d.ts.map +1 -0
- package/dist/defs/deepseek.js +53 -0
- package/dist/defs/deepseek.js.map +1 -0
- package/dist/defs/devin.d.ts +12 -0
- package/dist/defs/devin.d.ts.map +1 -0
- package/dist/defs/devin.js +45 -0
- package/dist/defs/devin.js.map +1 -0
- package/dist/defs/grok-build.d.ts +26 -0
- package/dist/defs/grok-build.d.ts.map +1 -0
- package/dist/defs/grok-build.js +105 -0
- package/dist/defs/grok-build.js.map +1 -0
- package/dist/defs/hermes.d.ts +13 -0
- package/dist/defs/hermes.d.ts.map +1 -0
- package/dist/defs/hermes.js +51 -0
- package/dist/defs/hermes.js.map +1 -0
- package/dist/defs/index.d.ts +33 -0
- package/dist/defs/index.d.ts.map +1 -0
- package/dist/defs/index.js +33 -0
- package/dist/defs/index.js.map +1 -0
- package/dist/defs/kilo.d.ts +12 -0
- package/dist/defs/kilo.d.ts.map +1 -0
- package/dist/defs/kilo.js +20 -0
- package/dist/defs/kilo.js.map +1 -0
- package/dist/defs/kimi.d.ts +13 -0
- package/dist/defs/kimi.d.ts.map +1 -0
- package/dist/defs/kimi.js +26 -0
- package/dist/defs/kimi.js.map +1 -0
- package/dist/defs/kiro.d.ts +12 -0
- package/dist/defs/kiro.d.ts.map +1 -0
- package/dist/defs/kiro.js +20 -0
- package/dist/defs/kiro.js.map +1 -0
- package/dist/defs/mimo.d.ts +13 -0
- package/dist/defs/mimo.d.ts.map +1 -0
- package/dist/defs/mimo.js +26 -0
- package/dist/defs/mimo.js.map +1 -0
- package/dist/defs/opencode.d.ts +27 -0
- package/dist/defs/opencode.d.ts.map +1 -0
- package/dist/defs/opencode.js +89 -0
- package/dist/defs/opencode.js.map +1 -0
- package/dist/defs/pi.d.ts +18 -0
- package/dist/defs/pi.d.ts.map +1 -0
- package/dist/defs/pi.js +94 -0
- package/dist/defs/pi.js.map +1 -0
- package/dist/defs/qoder.d.ts +11 -0
- package/dist/defs/qoder.d.ts.map +1 -0
- package/dist/defs/qoder.js +50 -0
- package/dist/defs/qoder.js.map +1 -0
- package/dist/defs/qwen.d.ts +11 -0
- package/dist/defs/qwen.d.ts.map +1 -0
- package/dist/defs/qwen.js +28 -0
- package/dist/defs/qwen.js.map +1 -0
- package/dist/defs/reasonix.d.ts +20 -0
- package/dist/defs/reasonix.d.ts.map +1 -0
- package/dist/defs/reasonix.js +60 -0
- package/dist/defs/reasonix.js.map +1 -0
- package/dist/defs/shared.d.ts +23 -0
- package/dist/defs/shared.d.ts.map +1 -0
- package/dist/defs/shared.js +58 -0
- package/dist/defs/shared.js.map +1 -0
- package/dist/defs/trae-cli.d.ts +14 -0
- package/dist/defs/trae-cli.d.ts.map +1 -0
- package/dist/defs/trae-cli.js +22 -0
- package/dist/defs/trae-cli.js.map +1 -0
- package/dist/defs/vibe.d.ts +12 -0
- package/dist/defs/vibe.d.ts.map +1 -0
- package/dist/defs/vibe.js +20 -0
- package/dist/defs/vibe.js.map +1 -0
- package/dist/detection.d.ts +14 -0
- package/dist/detection.d.ts.map +1 -0
- package/dist/detection.js +266 -0
- package/dist/detection.js.map +1 -0
- package/dist/diagnostics.d.ts +8 -0
- package/dist/diagnostics.d.ts.map +1 -0
- package/dist/diagnostics.js +95 -0
- package/dist/diagnostics.js.map +1 -0
- package/dist/env.d.ts +19 -0
- package/dist/env.d.ts.map +1 -0
- package/dist/env.js +95 -0
- package/dist/env.js.map +1 -0
- package/dist/executables.d.ts +24 -0
- package/dist/executables.d.ts.map +1 -0
- package/dist/executables.js +349 -0
- package/dist/executables.js.map +1 -0
- package/dist/index.d.ts +74 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +102 -0
- package/dist/index.js.map +1 -0
- package/dist/invocation.d.ts +6 -0
- package/dist/invocation.d.ts.map +1 -0
- package/dist/invocation.js +47 -0
- package/dist/invocation.js.map +1 -0
- package/dist/json-event-stream.d.ts +9 -0
- package/dist/json-event-stream.d.ts.map +1 -0
- package/dist/json-event-stream.js +856 -0
- package/dist/json-event-stream.js.map +1 -0
- package/dist/launch.d.ts +12 -0
- package/dist/launch.d.ts.map +1 -0
- package/dist/launch.js +221 -0
- package/dist/launch.js.map +1 -0
- package/dist/mcp.d.ts +44 -0
- package/dist/mcp.d.ts.map +1 -0
- package/dist/mcp.js +12 -0
- package/dist/mcp.js.map +1 -0
- package/dist/metadata.d.ts +24 -0
- package/dist/metadata.d.ts.map +1 -0
- package/dist/metadata.js +100 -0
- package/dist/metadata.js.map +1 -0
- package/dist/mmd-routes.d.ts +12 -0
- package/dist/mmd-routes.d.ts.map +1 -0
- package/dist/mmd-routes.js +146 -0
- package/dist/mmd-routes.js.map +1 -0
- package/dist/model-registry.d.ts +120 -0
- package/dist/model-registry.d.ts.map +1 -0
- package/dist/model-registry.js +77 -0
- package/dist/model-registry.js.map +1 -0
- package/dist/models.d.ts +16 -0
- package/dist/models.d.ts.map +1 -0
- package/dist/models.js +93 -0
- package/dist/models.js.map +1 -0
- package/dist/opencode-log.d.ts +16 -0
- package/dist/opencode-log.d.ts.map +1 -0
- package/dist/opencode-log.js +163 -0
- package/dist/opencode-log.js.map +1 -0
- package/dist/paths.d.ts +3 -0
- package/dist/paths.d.ts.map +1 -0
- package/dist/paths.js +29 -0
- package/dist/paths.js.map +1 -0
- package/dist/pi-models.d.ts +13 -0
- package/dist/pi-models.d.ts.map +1 -0
- package/dist/pi-models.js +36 -0
- package/dist/pi-models.js.map +1 -0
- package/dist/prompt-augmenter.d.ts +60 -0
- package/dist/prompt-augmenter.d.ts.map +1 -0
- package/dist/prompt-augmenter.js +26 -0
- package/dist/prompt-augmenter.js.map +1 -0
- package/dist/prompt-budget.d.ts +20 -0
- package/dist/prompt-budget.d.ts.map +1 -0
- package/dist/prompt-budget.js +226 -0
- package/dist/prompt-budget.js.map +1 -0
- package/dist/prompt-file.d.ts +7 -0
- package/dist/prompt-file.d.ts.map +1 -0
- package/dist/prompt-file.js +27 -0
- package/dist/prompt-file.js.map +1 -0
- package/dist/providers/aihubmix.d.ts +99 -0
- package/dist/providers/aihubmix.d.ts.map +1 -0
- package/dist/providers/aihubmix.js +239 -0
- package/dist/providers/aihubmix.js.map +1 -0
- package/dist/providers/anthropic-messages.d.ts +116 -0
- package/dist/providers/anthropic-messages.d.ts.map +1 -0
- package/dist/providers/anthropic-messages.js +313 -0
- package/dist/providers/anthropic-messages.js.map +1 -0
- package/dist/providers/azure-chat.d.ts +99 -0
- package/dist/providers/azure-chat.d.ts.map +1 -0
- package/dist/providers/azure-chat.js +164 -0
- package/dist/providers/azure-chat.js.map +1 -0
- package/dist/providers/connection-guard.d.ts +67 -0
- package/dist/providers/connection-guard.d.ts.map +1 -0
- package/dist/providers/connection-guard.js +211 -0
- package/dist/providers/connection-guard.js.map +1 -0
- package/dist/providers/elevenlabs.d.ts +28 -0
- package/dist/providers/elevenlabs.d.ts.map +1 -0
- package/dist/providers/elevenlabs.js +138 -0
- package/dist/providers/elevenlabs.js.map +1 -0
- package/dist/providers/google-messages.d.ts +108 -0
- package/dist/providers/google-messages.d.ts.map +1 -0
- package/dist/providers/google-messages.js +284 -0
- package/dist/providers/google-messages.js.map +1 -0
- package/dist/providers/google.d.ts +20 -0
- package/dist/providers/google.d.ts.map +1 -0
- package/dist/providers/google.js +42 -0
- package/dist/providers/google.js.map +1 -0
- package/dist/providers/index.d.ts +39 -0
- package/dist/providers/index.d.ts.map +1 -0
- package/dist/providers/index.js +39 -0
- package/dist/providers/index.js.map +1 -0
- package/dist/providers/model-catalog.d.ts +32 -0
- package/dist/providers/model-catalog.d.ts.map +1 -0
- package/dist/providers/model-catalog.js +394 -0
- package/dist/providers/model-catalog.js.map +1 -0
- package/dist/providers/oauth-callback-server.d.ts +35 -0
- package/dist/providers/oauth-callback-server.d.ts.map +1 -0
- package/dist/providers/oauth-callback-server.js +217 -0
- package/dist/providers/oauth-callback-server.js.map +1 -0
- package/dist/providers/oauth-credentials.d.ts +29 -0
- package/dist/providers/oauth-credentials.d.ts.map +1 -0
- package/dist/providers/oauth-credentials.js +70 -0
- package/dist/providers/oauth-credentials.js.map +1 -0
- package/dist/providers/oauth-provider.d.ts +95 -0
- package/dist/providers/oauth-provider.d.ts.map +1 -0
- package/dist/providers/oauth-provider.js +130 -0
- package/dist/providers/oauth-provider.js.map +1 -0
- package/dist/providers/oauth-tokens.d.ts +35 -0
- package/dist/providers/oauth-tokens.d.ts.map +1 -0
- package/dist/providers/oauth-tokens.js +136 -0
- package/dist/providers/oauth-tokens.js.map +1 -0
- package/dist/providers/ollama-chat.d.ts +106 -0
- package/dist/providers/ollama-chat.d.ts.map +1 -0
- package/dist/providers/ollama-chat.js +292 -0
- package/dist/providers/ollama-chat.js.map +1 -0
- package/dist/providers/openai-chat.d.ts +147 -0
- package/dist/providers/openai-chat.d.ts.map +1 -0
- package/dist/providers/openai-chat.js +302 -0
- package/dist/providers/openai-chat.js.map +1 -0
- package/dist/providers/pkce.d.ts +81 -0
- package/dist/providers/pkce.d.ts.map +1 -0
- package/dist/providers/pkce.js +176 -0
- package/dist/providers/pkce.js.map +1 -0
- package/dist/providers/sse-decode.d.ts +47 -0
- package/dist/providers/sse-decode.d.ts.map +1 -0
- package/dist/providers/sse-decode.js +109 -0
- package/dist/providers/sse-decode.js.map +1 -0
- package/dist/providers/token-params.d.ts +29 -0
- package/dist/providers/token-params.d.ts.map +1 -0
- package/dist/providers/token-params.js +41 -0
- package/dist/providers/token-params.js.map +1 -0
- package/dist/providers/turn-end-guard.d.ts +37 -0
- package/dist/providers/turn-end-guard.d.ts.map +1 -0
- package/dist/providers/turn-end-guard.js +42 -0
- package/dist/providers/turn-end-guard.js.map +1 -0
- package/dist/providers/types.d.ts +36 -0
- package/dist/providers/types.d.ts.map +1 -0
- package/dist/providers/types.js +13 -0
- package/dist/providers/types.js.map +1 -0
- package/dist/qoder-stream.d.ts +19 -0
- package/dist/qoder-stream.d.ts.map +1 -0
- package/dist/qoder-stream.js +167 -0
- package/dist/qoder-stream.js.map +1 -0
- package/dist/registry.d.ts +5 -0
- package/dist/registry.d.ts.map +1 -0
- package/dist/registry.js +58 -0
- package/dist/registry.js.map +1 -0
- package/dist/resolution.d.ts +2 -0
- package/dist/resolution.d.ts.map +1 -0
- package/dist/resolution.js +19 -0
- package/dist/resolution.js.map +1 -0
- package/dist/role-marker-guard.d.ts +53 -0
- package/dist/role-marker-guard.d.ts.map +1 -0
- package/dist/role-marker-guard.js +280 -0
- package/dist/role-marker-guard.js.map +1 -0
- package/dist/telemetry-sink.d.ts +35 -0
- package/dist/telemetry-sink.d.ts.map +1 -0
- package/dist/telemetry-sink.js +5 -0
- package/dist/telemetry-sink.js.map +1 -0
- package/dist/terminal-launch.d.ts +11 -0
- package/dist/terminal-launch.d.ts.map +1 -0
- package/dist/terminal-launch.js +123 -0
- package/dist/terminal-launch.js.map +1 -0
- package/dist/types.d.ts +185 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/types.js +2 -0
- package/dist/types.js.map +1 -0
- package/package.json +47 -0
|
@@ -0,0 +1,268 @@
|
|
|
1
|
+
import { asObject, acpValueKind, objectKeys, extractAcpUpdateText } from './json.js';
|
|
2
|
+
import { accountFailureDetails, noopAccountFailureClassifier, } from './account-failure.js';
|
|
3
|
+
/**
|
|
4
|
+
* Produces a shallow diagnostic snapshot of an ACP update object for the
|
|
5
|
+
* `acp_raw_event_shape` diagnostic event. Captures key presence, value kinds,
|
|
6
|
+
* and content structure without serialising the full update, so the payload
|
|
7
|
+
* stays bounded in size. Emitted only for AMR sessions where unknown shapes
|
|
8
|
+
* may require debugging.
|
|
9
|
+
*
|
|
10
|
+
* @param update - A parsed ACP `session/update` params object.
|
|
11
|
+
* @returns A flat diagnostic object suitable for inclusion in an agent event payload.
|
|
12
|
+
*/
|
|
13
|
+
export function acpRawEventShape(update) {
|
|
14
|
+
const content = update.content;
|
|
15
|
+
const rawInput = update.rawInput;
|
|
16
|
+
const locations = update.locations;
|
|
17
|
+
return {
|
|
18
|
+
sessionUpdate: typeof update.sessionUpdate === 'string' ? update.sessionUpdate : null,
|
|
19
|
+
keys: objectKeys(update),
|
|
20
|
+
contentKind: acpValueKind(content),
|
|
21
|
+
contentKeys: objectKeys(content),
|
|
22
|
+
hasText: Boolean(extractAcpUpdateText(update)),
|
|
23
|
+
hasTopLevelText: typeof update.text === 'string' && update.text.length > 0,
|
|
24
|
+
hasTopLevelDelta: typeof update.delta === 'string' && update.delta.length > 0,
|
|
25
|
+
hasTopLevelMessage: update.message !== undefined,
|
|
26
|
+
hasToolCallId: acpToolCallId(update) !== null,
|
|
27
|
+
hasRawInput: rawInput !== undefined,
|
|
28
|
+
rawInputKind: acpValueKind(rawInput),
|
|
29
|
+
rawInputKeys: objectKeys(rawInput),
|
|
30
|
+
locationsKind: acpValueKind(locations),
|
|
31
|
+
locationsCount: Array.isArray(locations) ? locations.length : undefined,
|
|
32
|
+
status: typeof update.status === 'string' ? update.status : undefined,
|
|
33
|
+
titlePresent: typeof update.title === 'string' && update.title.length > 0,
|
|
34
|
+
};
|
|
35
|
+
}
|
|
36
|
+
/**
|
|
37
|
+
* Normalises the `status` field of an ACP update to a lowercase,
|
|
38
|
+
* whitespace-and-punctuation-stripped token. Returns `''` when the field
|
|
39
|
+
* is absent or not a string, so all status comparisons use the token form.
|
|
40
|
+
*
|
|
41
|
+
* @param update - A parsed ACP `session/update` params object.
|
|
42
|
+
*/
|
|
43
|
+
export function acpUpdateStatus(update) {
|
|
44
|
+
return typeof update.status === 'string'
|
|
45
|
+
? update.status.trim().toLowerCase().replace(/[\s_-]+/g, '')
|
|
46
|
+
: '';
|
|
47
|
+
}
|
|
48
|
+
/**
|
|
49
|
+
* Returns `true` when the update's `status` field represents a successful
|
|
50
|
+
* terminal state (`completed`, `complete`, `succeeded`, or `success`).
|
|
51
|
+
* Used to decide when to emit deferred artifact-write tool events.
|
|
52
|
+
*/
|
|
53
|
+
export function isAcpCompletedStatus(update) {
|
|
54
|
+
const status = acpUpdateStatus(update);
|
|
55
|
+
return status === 'completed' || status === 'complete' || status === 'succeeded' || status === 'success';
|
|
56
|
+
}
|
|
57
|
+
/**
|
|
58
|
+
* Returns `true` when the update's `status` field represents a terminal
|
|
59
|
+
* failure state (`failed`, `failure`, `error`, `cancelled`, or `canceled`).
|
|
60
|
+
* Used to clean up pending write-suppression state and emit failed tool events.
|
|
61
|
+
*/
|
|
62
|
+
export function isAcpTerminalFailureStatus(update) {
|
|
63
|
+
const status = acpUpdateStatus(update);
|
|
64
|
+
return status === 'failed' || status === 'failure' || status === 'error' || status === 'cancelled' || status === 'canceled';
|
|
65
|
+
}
|
|
66
|
+
/**
|
|
67
|
+
* Returns `true` when the update's status is `'retry'`. Signals that the AMR
|
|
68
|
+
* agent wants to restart the request; the session promoter maps this to a
|
|
69
|
+
* structured error payload via `promotedAmrRetryStatusPayload`.
|
|
70
|
+
*/
|
|
71
|
+
export function isAcpRetryStatus(update) {
|
|
72
|
+
return acpUpdateStatus(update) === 'retry';
|
|
73
|
+
}
|
|
74
|
+
/**
|
|
75
|
+
* Recursively collects all text-bearing leaf values from an ACP update
|
|
76
|
+
* (strings, numbers, booleans) up to 4 levels deep. Used to produce a flat
|
|
77
|
+
* text corpus for an injected `AccountFailureClassifier` to pattern-match
|
|
78
|
+
* against, without requiring knowledge of a specific agent's response shape.
|
|
79
|
+
*
|
|
80
|
+
* @param value - Any value from a parsed ACP session update.
|
|
81
|
+
* @param depth - Current recursion depth (max 4); callers omit this.
|
|
82
|
+
* @returns A flat array of trimmed non-empty string representations.
|
|
83
|
+
*/
|
|
84
|
+
export function acpUpdateDiagnosticText(value, depth = 0) {
|
|
85
|
+
if (depth > 4)
|
|
86
|
+
return [];
|
|
87
|
+
if (typeof value === 'string')
|
|
88
|
+
return value.trim() ? [value] : [];
|
|
89
|
+
if (typeof value === 'number' || typeof value === 'boolean')
|
|
90
|
+
return [String(value)];
|
|
91
|
+
if (Array.isArray(value)) {
|
|
92
|
+
return value.flatMap((item) => acpUpdateDiagnosticText(item, depth + 1));
|
|
93
|
+
}
|
|
94
|
+
const obj = asObject(value);
|
|
95
|
+
if (!obj)
|
|
96
|
+
return [];
|
|
97
|
+
const parts = [];
|
|
98
|
+
for (const key of [
|
|
99
|
+
'type',
|
|
100
|
+
'status',
|
|
101
|
+
'code',
|
|
102
|
+
'message',
|
|
103
|
+
'detail',
|
|
104
|
+
'details',
|
|
105
|
+
'error',
|
|
106
|
+
'recovery',
|
|
107
|
+
'pauseReason',
|
|
108
|
+
'content',
|
|
109
|
+
'text',
|
|
110
|
+
'rawInput',
|
|
111
|
+
]) {
|
|
112
|
+
if (key in obj) {
|
|
113
|
+
parts.push(...acpUpdateDiagnosticText(obj[key], depth + 1));
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
return parts;
|
|
117
|
+
}
|
|
118
|
+
/**
|
|
119
|
+
* Promotes an AMR `retry` status update into a structured error payload when
|
|
120
|
+
* the update's diagnostic text matches a known account-failure pattern (e.g.
|
|
121
|
+
* quota exceeded, auth failure), as decided by `classifier`. Returns `null`
|
|
122
|
+
* when the update is not a retry, or when `classifier` finds no match.
|
|
123
|
+
*
|
|
124
|
+
* @param update - A parsed ACP `session/update` params object.
|
|
125
|
+
* @param classifier - The account-failure classifier to consult; defaults to
|
|
126
|
+
* `noopAccountFailureClassifier`, under which this always returns `null`.
|
|
127
|
+
* @returns A structured error payload with `message` and `error`, or `null`.
|
|
128
|
+
*/
|
|
129
|
+
export function promotedAmrRetryStatusPayload(update, classifier = noopAccountFailureClassifier) {
|
|
130
|
+
if (!isAcpRetryStatus(update))
|
|
131
|
+
return null;
|
|
132
|
+
const diagnosticText = acpUpdateDiagnosticText(update).join('\n');
|
|
133
|
+
const failure = classifier.classify(diagnosticText);
|
|
134
|
+
if (!failure)
|
|
135
|
+
return null;
|
|
136
|
+
return {
|
|
137
|
+
message: failure.message,
|
|
138
|
+
error: {
|
|
139
|
+
code: failure.code,
|
|
140
|
+
message: failure.message,
|
|
141
|
+
retryable: false,
|
|
142
|
+
details: {
|
|
143
|
+
...accountFailureDetails(failure),
|
|
144
|
+
promoted_by: 'agent_runtime_acp_retry_status',
|
|
145
|
+
},
|
|
146
|
+
},
|
|
147
|
+
};
|
|
148
|
+
}
|
|
149
|
+
/**
|
|
150
|
+
* Scans a rolling tail of AMR stderr output for known retry/session-failure
|
|
151
|
+
* signals and, when found, promotes a match (via `classifier`) to a
|
|
152
|
+
* structured error payload. Returns `null` when the chunk does not contain
|
|
153
|
+
* the expected markers or does not match a known failure pattern.
|
|
154
|
+
*
|
|
155
|
+
* @param chunk - A tail slice of accumulated stderr bytes from the AMR subprocess.
|
|
156
|
+
* @param classifier - The account-failure classifier to consult; defaults to
|
|
157
|
+
* `noopAccountFailureClassifier`, under which this always returns `null`.
|
|
158
|
+
* @returns A structured error payload, or `null` when not applicable.
|
|
159
|
+
*/
|
|
160
|
+
export function promotedAmrStderrPayload(chunk, classifier = noopAccountFailureClassifier) {
|
|
161
|
+
if (!/opencode_event_stream_failure|session\.status/i.test(chunk))
|
|
162
|
+
return null;
|
|
163
|
+
if (!/\bretry\b/i.test(chunk))
|
|
164
|
+
return null;
|
|
165
|
+
const failure = classifier.classify(chunk);
|
|
166
|
+
if (!failure)
|
|
167
|
+
return null;
|
|
168
|
+
return {
|
|
169
|
+
message: failure.message,
|
|
170
|
+
error: {
|
|
171
|
+
code: failure.code,
|
|
172
|
+
message: failure.message,
|
|
173
|
+
retryable: false,
|
|
174
|
+
details: {
|
|
175
|
+
...accountFailureDetails(failure),
|
|
176
|
+
promoted_by: 'agent_runtime_acp_stderr_retry_status',
|
|
177
|
+
},
|
|
178
|
+
},
|
|
179
|
+
};
|
|
180
|
+
}
|
|
181
|
+
/**
|
|
182
|
+
* Extracts and trims the `toolCallId` string from an ACP update, or returns
|
|
183
|
+
* `null` when absent or empty. Used as a stable dedup key for artifact-write
|
|
184
|
+
* tracking across update frames.
|
|
185
|
+
*
|
|
186
|
+
* @param update - A parsed ACP `session/update` params object.
|
|
187
|
+
*/
|
|
188
|
+
export function acpToolCallId(update) {
|
|
189
|
+
return typeof update.toolCallId === 'string' && update.toolCallId.trim()
|
|
190
|
+
? update.toolCallId.trim()
|
|
191
|
+
: null;
|
|
192
|
+
}
|
|
193
|
+
/**
|
|
194
|
+
* Returns `true` when the update's `title` or `name` field contains a word
|
|
195
|
+
* that indicates a file-write operation (`edit`, `write`, `create`, `update`,
|
|
196
|
+
* `save`, `patch`, or `replace`). Used to heuristically identify
|
|
197
|
+
* artifact-write tool calls before their `toolCallId` is known.
|
|
198
|
+
*
|
|
199
|
+
* @param update - A parsed ACP `session/update` params object.
|
|
200
|
+
*/
|
|
201
|
+
export function isAcpArtifactWriteLabel(update) {
|
|
202
|
+
const label = [
|
|
203
|
+
typeof update.title === 'string' ? update.title : '',
|
|
204
|
+
typeof update.name === 'string' ? update.name : '',
|
|
205
|
+
].join(' ');
|
|
206
|
+
return /\b(?:edit|write|create|update|save|patch|replace)\b/i.test(label);
|
|
207
|
+
}
|
|
208
|
+
/**
|
|
209
|
+
* Returns `true` when an ACP update represents the terminal completion of an
|
|
210
|
+
* artifact-write tool call and should arm the DSML text suppressor. Requires
|
|
211
|
+
* a completed status combined with either a write-style label or a tool call
|
|
212
|
+
* id tracked in `writeToolCallIds`.
|
|
213
|
+
*
|
|
214
|
+
* @param update - A parsed ACP `session/update` params object.
|
|
215
|
+
* @param writeToolCallIds - The set of tool call ids identified as artifact writes so far.
|
|
216
|
+
*/
|
|
217
|
+
export function isAcpArtifactWriteUpdate(update, writeToolCallIds) {
|
|
218
|
+
if (!isAcpCompletedStatus(update))
|
|
219
|
+
return false;
|
|
220
|
+
const toolCallId = acpToolCallId(update);
|
|
221
|
+
return isAcpArtifactWriteLabel(update) || (toolCallId ? writeToolCallIds.has(toolCallId) : false);
|
|
222
|
+
}
|
|
223
|
+
// Best-effort file path for an ACP artifact-write tool call. ACP can carry a
|
|
224
|
+
// `locations: [{ path }]` array and/or `content: [{ type:'diff', path }]`
|
|
225
|
+
// entries, but many agents omit both and send only a human `title` ("edit").
|
|
226
|
+
// Returns null when no concrete path is present; the caller then falls back to
|
|
227
|
+
// the toolCallId as a dedup key.
|
|
228
|
+
/**
|
|
229
|
+
* Best-effort extraction of a concrete file path from an ACP artifact-write
|
|
230
|
+
* tool call update, checking three sources in priority order:
|
|
231
|
+
* 1. `locations` or `content` array entries with a `path` field.
|
|
232
|
+
* 2. `rawInput.path`, `rawInput.file_path`, or `rawInput.filename`.
|
|
233
|
+
* 3. A filename token embedded in the human-readable `title` field.
|
|
234
|
+
*
|
|
235
|
+
* Returns `null` when no concrete path is present; the caller then falls
|
|
236
|
+
* back to the toolCallId as a dedup key.
|
|
237
|
+
*
|
|
238
|
+
* @param update - A parsed ACP `session/update` params object.
|
|
239
|
+
* @returns An absolute or relative file path string, or `null` when absent.
|
|
240
|
+
*/
|
|
241
|
+
export function acpArtifactWritePath(update) {
|
|
242
|
+
// 1. ACP `locations: [{ path }]` and `content: [{ path }]` (diff entries).
|
|
243
|
+
for (const field of [update.locations, update.content]) {
|
|
244
|
+
if (!Array.isArray(field))
|
|
245
|
+
continue;
|
|
246
|
+
for (const entry of field) {
|
|
247
|
+
const path = asObject(entry)?.path;
|
|
248
|
+
if (typeof path === 'string' && path.trim())
|
|
249
|
+
return path.trim();
|
|
250
|
+
}
|
|
251
|
+
}
|
|
252
|
+
// 2. Tool input echoed by some agents as `rawInput.{path,file_path,filename}`.
|
|
253
|
+
const rawInput = asObject(update.rawInput);
|
|
254
|
+
for (const key of ['path', 'file_path', 'filename']) {
|
|
255
|
+
const value = rawInput?.[key];
|
|
256
|
+
if (typeof value === 'string' && value.trim())
|
|
257
|
+
return value.trim();
|
|
258
|
+
}
|
|
259
|
+
// 3. A filename token embedded in the human title, e.g. "Write index.html".
|
|
260
|
+
// Keeping the real extension lets `isArtifactPath` correctly EXCLUDE
|
|
261
|
+
// non-artifact writes (e.g. "edit config.json"), matching the claude path.
|
|
262
|
+
const title = typeof update.title === 'string' ? update.title : '';
|
|
263
|
+
const match = title.match(/[\w./-]+\.[A-Za-z0-9]+/);
|
|
264
|
+
if (match?.[0])
|
|
265
|
+
return match[0];
|
|
266
|
+
return null;
|
|
267
|
+
}
|
|
268
|
+
//# sourceMappingURL=updates.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"updates.js","sourceRoot":"","sources":["../../../src/agent-protocol/acp/updates.ts"],"names":[],"mappings":"AAQA,OAAO,EAAE,QAAQ,EAAE,YAAY,EAAE,UAAU,EAAE,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AI,CAAC;YACnC,IAAI,OAAO,IAAI,KAAK,QAAQ,IAAI,IAAI,CAAC,IAAI,EAAE;gBAAE,OAAO,IAAI,CAAC,IAAI,EAAE,CAAC;QAClE,CAAC;IACH,CAAC;IACD,+EAA+E;IAC/E,MAAM,QAAQ,GAAG,QAAQ,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAC;IAC3C,KAAK,MAAM,GAAG,IAAI,CAAC,MAAM,EAAE,WAAW,EAAE,UAAU,CAAC,EAAE,CAAC;QACpD,MAAM,KAAK,GAAG,QAAQ,EAAE,CAAC,GAAG,CAAC,CAAC;QAC9B,IAAI,OAAO,KAAK,KAAK,QAAQ,IAAI,KAAK,CAAC,IAAI,EAAE;YAAE,OAAO,KAAK,CAAC,IAAI,EAAE,CAAC;IACrE,CAAC;IACD,4EAA4E;IAC5E,qEAAqE;IACrE,2EAA2E;IAC3E,MAAM,KAAK,GAAG,OAAO,MAAM,CAAC,KAAK,KAAK,QAAQ,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC,EAAE,CAAC;IACnE,MAAM,KAAK,GAAG,KAAK,CAAC,KAAK,CAAC,wBAAwB,CAAC,CAAC;IACpD,IAAI,KAAK,EAAE,CAAC,CAAC,CAAC;QAAE,OAAO,KAAK,CAAC,CAAC,CAAC,CAAC;IAChC,OAAO,IAAI,CAAC;AACd,CAAC"}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
/** @module agent-protocol/core
|
|
2
|
+
* Foundation barrel for the agent-protocol module. Re-exports the shared
|
|
3
|
+
* JSON-line stream parser consumed by every protocol adapter (acp/, pi-rpc/).
|
|
4
|
+
*/
|
|
5
|
+
export { createJsonLineStream } from './json-line-stream.js';
|
|
6
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/agent-protocol/core/index.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,OAAO,EAAE,oBAAoB,EAAE,MAAM,uBAAuB,CAAC"}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
/** @module agent-protocol/core
|
|
2
|
+
* Foundation barrel for the agent-protocol module. Re-exports the shared
|
|
3
|
+
* JSON-line stream parser consumed by every protocol adapter (acp/, pi-rpc/).
|
|
4
|
+
*/
|
|
5
|
+
export { createJsonLineStream } from './json-line-stream.js';
|
|
6
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/agent-protocol/core/index.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,OAAO,EAAE,oBAAoB,EAAE,MAAM,uBAAuB,CAAC"}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
/** @module agent-protocol/core/json-line-stream
|
|
2
|
+
* Streaming JSON-line parser that reassembles pretty-printed and multiline
|
|
3
|
+
* JSON-RPC messages across chunk boundaries. Shared transport used by both the
|
|
4
|
+
* acp/ and pi-rpc/ protocol adapters; this file has no dependencies on any
|
|
5
|
+
* other agent-protocol sibling.
|
|
6
|
+
*/
|
|
7
|
+
/**
|
|
8
|
+
* Creates a streaming JSON-line parser over a raw byte/string stream.
|
|
9
|
+
* Buffers incoming chunks, splits on newline boundaries, and attempts
|
|
10
|
+
* `JSON.parse` on each line. Accumulates pretty-printed (multiline) JSON across
|
|
11
|
+
* up to 256 lines and 128 kB before abandoning and re-trying the current line
|
|
12
|
+
* as a fresh candidate.
|
|
13
|
+
*
|
|
14
|
+
* Used as the shared ACP transport: both the acp/ and pi-rpc/ adapters call
|
|
15
|
+
* this to decode JSON-RPC frames from a subprocess's stdout.
|
|
16
|
+
*
|
|
17
|
+
* @param onMessage - Called for each successfully parsed JSON value along with
|
|
18
|
+
* the raw reassembled line string as a second argument.
|
|
19
|
+
* @returns An object with `feed(chunk)` for incremental input and `flush()` to
|
|
20
|
+
* drain any residual buffered content at stream end.
|
|
21
|
+
*/
|
|
22
|
+
export declare function createJsonLineStream(onMessage: (message: unknown, rawLine: string) => void): {
|
|
23
|
+
feed(chunk: string): void;
|
|
24
|
+
flush(): void;
|
|
25
|
+
};
|
|
26
|
+
/**
|
|
27
|
+
* Incremental JSON completeness classifier used by `createJsonLineStream` to
|
|
28
|
+
* decide whether an accumulating multiline candidate can still resolve into
|
|
29
|
+
* valid JSON.
|
|
30
|
+
*
|
|
31
|
+
* Performs a single-pass character-level parse, tracking object and array
|
|
32
|
+
* frames on a stack. Returns:
|
|
33
|
+
* - `'complete'` — a syntactically valid, fully closed JSON value.
|
|
34
|
+
* - `'incomplete'` — valid so far but the document is still open (unclosed
|
|
35
|
+
* strings, objects, or arrays).
|
|
36
|
+
* - `'invalid'` — an irrecoverable syntax error was encountered.
|
|
37
|
+
*
|
|
38
|
+
* @param value - A string candidate to classify, typically one or more
|
|
39
|
+
* accumulated stdout lines from an ACP subprocess.
|
|
40
|
+
*/
|
|
41
|
+
export declare function classifyJsonCandidate(value: string): 'complete' | 'incomplete' | 'invalid';
|
|
42
|
+
//# sourceMappingURL=json-line-stream.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"json-line-stream.d.ts","sourceRoot":"","sources":["../../../src/agent-protocol/core/json-line-stream.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH;;;;;;;;;;;;;;GAcG;AACH,wBAAgB,oBAAoB,CAAC,SAAS,EAAE,CAAC,OAAO,EAAE,OAAO,EAAE,OAAO,EAAE,MAAM,KAAK,IAAI;gBA6D3E,MAAM;;EA4BrB;AACD;;;;;;;;;;;;;;GAcG;AACH,wBAAgB,qBAAqB,CAAC,KAAK,EAAE,MAAM,GAAG,UAAU,GAAG,YAAY,GAAG,SAAS,CAmM1F"}
|
|
@@ -0,0 +1,333 @@
|
|
|
1
|
+
/** @module agent-protocol/core/json-line-stream
|
|
2
|
+
* Streaming JSON-line parser that reassembles pretty-printed and multiline
|
|
3
|
+
* JSON-RPC messages across chunk boundaries. Shared transport used by both the
|
|
4
|
+
* acp/ and pi-rpc/ protocol adapters; this file has no dependencies on any
|
|
5
|
+
* other agent-protocol sibling.
|
|
6
|
+
*/
|
|
7
|
+
/**
|
|
8
|
+
* Creates a streaming JSON-line parser over a raw byte/string stream.
|
|
9
|
+
* Buffers incoming chunks, splits on newline boundaries, and attempts
|
|
10
|
+
* `JSON.parse` on each line. Accumulates pretty-printed (multiline) JSON across
|
|
11
|
+
* up to 256 lines and 128 kB before abandoning and re-trying the current line
|
|
12
|
+
* as a fresh candidate.
|
|
13
|
+
*
|
|
14
|
+
* Used as the shared ACP transport: both the acp/ and pi-rpc/ adapters call
|
|
15
|
+
* this to decode JSON-RPC frames from a subprocess's stdout.
|
|
16
|
+
*
|
|
17
|
+
* @param onMessage - Called for each successfully parsed JSON value along with
|
|
18
|
+
* the raw reassembled line string as a second argument.
|
|
19
|
+
* @returns An object with `feed(chunk)` for incremental input and `flush()` to
|
|
20
|
+
* drain any residual buffered content at stream end.
|
|
21
|
+
*/
|
|
22
|
+
export function createJsonLineStream(onMessage) {
|
|
23
|
+
let buffer = '';
|
|
24
|
+
let pendingJson = '';
|
|
25
|
+
let pendingJsonLineCount = 0;
|
|
26
|
+
const emit = (candidate) => {
|
|
27
|
+
try {
|
|
28
|
+
onMessage(JSON.parse(candidate), candidate);
|
|
29
|
+
return true;
|
|
30
|
+
}
|
|
31
|
+
catch {
|
|
32
|
+
return false;
|
|
33
|
+
}
|
|
34
|
+
};
|
|
35
|
+
const startPendingJson = (line) => {
|
|
36
|
+
pendingJson = line;
|
|
37
|
+
pendingJsonLineCount = 1;
|
|
38
|
+
};
|
|
39
|
+
const resetPendingJson = () => {
|
|
40
|
+
pendingJson = '';
|
|
41
|
+
pendingJsonLineCount = 0;
|
|
42
|
+
};
|
|
43
|
+
const handleLine = (line) => {
|
|
44
|
+
const trimmed = line.trim();
|
|
45
|
+
if (!trimmed)
|
|
46
|
+
return;
|
|
47
|
+
if (pendingJson) {
|
|
48
|
+
const nextCandidate = `${pendingJson}\n${trimmed}`;
|
|
49
|
+
if (emit(nextCandidate)) {
|
|
50
|
+
resetPendingJson();
|
|
51
|
+
return;
|
|
52
|
+
}
|
|
53
|
+
pendingJsonLineCount += 1;
|
|
54
|
+
const state = classifyJsonCandidate(nextCandidate);
|
|
55
|
+
if (state === 'incomplete' &&
|
|
56
|
+
nextCandidate.length <= 128_000 &&
|
|
57
|
+
pendingJsonLineCount <= 256) {
|
|
58
|
+
pendingJson = nextCandidate;
|
|
59
|
+
return;
|
|
60
|
+
}
|
|
61
|
+
resetPendingJson();
|
|
62
|
+
handleLine(trimmed);
|
|
63
|
+
return;
|
|
64
|
+
}
|
|
65
|
+
if (emit(trimmed))
|
|
66
|
+
return;
|
|
67
|
+
// ACP is line-delimited JSON-RPC, but a few bridges have emitted
|
|
68
|
+
// pretty-printed JSON during startup. Keep a bounded aggregate so an
|
|
69
|
+
// otherwise valid multiline initialize response does not get discarded
|
|
70
|
+
// line-by-line and leave the session stuck in spawn pending.
|
|
71
|
+
if ((trimmed.startsWith('{') || trimmed.startsWith('[')) &&
|
|
72
|
+
classifyJsonCandidate(trimmed) === 'incomplete') {
|
|
73
|
+
startPendingJson(trimmed);
|
|
74
|
+
}
|
|
75
|
+
};
|
|
76
|
+
return {
|
|
77
|
+
feed(chunk) {
|
|
78
|
+
buffer += chunk;
|
|
79
|
+
const lines = buffer.split('\n');
|
|
80
|
+
buffer = lines.pop() || '';
|
|
81
|
+
for (const line of lines) {
|
|
82
|
+
handleLine(line);
|
|
83
|
+
}
|
|
84
|
+
},
|
|
85
|
+
flush() {
|
|
86
|
+
const trimmed = buffer.trim();
|
|
87
|
+
buffer = '';
|
|
88
|
+
if (trimmed) {
|
|
89
|
+
handleLine(trimmed);
|
|
90
|
+
}
|
|
91
|
+
// Any `pendingJson` still set at this point was, by construction, the
|
|
92
|
+
// most recent candidate `classifyJsonCandidate` judged structurally
|
|
93
|
+
// incomplete (an unclosed string/object/array) — the exact same
|
|
94
|
+
// judgment `JSON.parse` agrees with (verified by fuzz-testing 200k
|
|
95
|
+
// truncated-JSON candidates: zero cases where classify says
|
|
96
|
+
// 'incomplete' but JSON.parse would actually succeed), so a bare
|
|
97
|
+
// re-attempt at end-of-stream could never succeed. The origin file had
|
|
98
|
+
// a defensive `if (pendingJson && emit(pendingJson)) { pendingJson =
|
|
99
|
+
// '' }` here that was provably dead code; removed per this package's
|
|
100
|
+
// coverage-driven dead-branch discipline rather than left uncovered or
|
|
101
|
+
// suppressed. See source-map.md.
|
|
102
|
+
// Ignore trailing non-JSON log lines on stdout.
|
|
103
|
+
},
|
|
104
|
+
};
|
|
105
|
+
}
|
|
106
|
+
/**
|
|
107
|
+
* Incremental JSON completeness classifier used by `createJsonLineStream` to
|
|
108
|
+
* decide whether an accumulating multiline candidate can still resolve into
|
|
109
|
+
* valid JSON.
|
|
110
|
+
*
|
|
111
|
+
* Performs a single-pass character-level parse, tracking object and array
|
|
112
|
+
* frames on a stack. Returns:
|
|
113
|
+
* - `'complete'` — a syntactically valid, fully closed JSON value.
|
|
114
|
+
* - `'incomplete'` — valid so far but the document is still open (unclosed
|
|
115
|
+
* strings, objects, or arrays).
|
|
116
|
+
* - `'invalid'` — an irrecoverable syntax error was encountered.
|
|
117
|
+
*
|
|
118
|
+
* @param value - A string candidate to classify, typically one or more
|
|
119
|
+
* accumulated stdout lines from an ACP subprocess.
|
|
120
|
+
*/
|
|
121
|
+
export function classifyJsonCandidate(value) {
|
|
122
|
+
const stack = [];
|
|
123
|
+
let rootComplete = false;
|
|
124
|
+
const afterValue = () => {
|
|
125
|
+
const parent = stack.at(-1);
|
|
126
|
+
if (!parent) {
|
|
127
|
+
rootComplete = true;
|
|
128
|
+
return;
|
|
129
|
+
}
|
|
130
|
+
parent.expect = 'commaOrEnd';
|
|
131
|
+
};
|
|
132
|
+
// Every call site below is already nested inside a check that has
|
|
133
|
+
// established the top-of-stack frame's kind (`current.kind === 'object'`,
|
|
134
|
+
// or implicitly 'array' when that check fails), so the frame `closeFrame`
|
|
135
|
+
// pops always exists and always matches the kind being closed. The origin
|
|
136
|
+
// file guarded against a mismatch (`!current || current.kind !== kind`)
|
|
137
|
+
// and returned `false` for callers to translate into `'invalid'`; that
|
|
138
|
+
// guard was provably dead (verified by a 2M-trial adversarial fuzz,
|
|
139
|
+
// including deliberately malformed bracket sequences, finding zero
|
|
140
|
+
// mismatches) and is removed here per this package's coverage-driven
|
|
141
|
+
// dead-branch discipline. See source-map.md.
|
|
142
|
+
const closeFrame = () => {
|
|
143
|
+
stack.pop();
|
|
144
|
+
afterValue();
|
|
145
|
+
};
|
|
146
|
+
const parseString = (start) => {
|
|
147
|
+
for (let index = start + 1; index < value.length; index += 1) {
|
|
148
|
+
const char = value[index];
|
|
149
|
+
if (char === '\\') {
|
|
150
|
+
index += 1;
|
|
151
|
+
continue;
|
|
152
|
+
}
|
|
153
|
+
if (char === '"')
|
|
154
|
+
return index;
|
|
155
|
+
}
|
|
156
|
+
return null;
|
|
157
|
+
};
|
|
158
|
+
const parseLiteral = (start, literal) => {
|
|
159
|
+
for (let offset = 0; offset < literal.length; offset += 1) {
|
|
160
|
+
const char = value[start + offset];
|
|
161
|
+
if (char === undefined)
|
|
162
|
+
return null;
|
|
163
|
+
if (char !== literal[offset])
|
|
164
|
+
return false;
|
|
165
|
+
}
|
|
166
|
+
return start + literal.length - 1;
|
|
167
|
+
};
|
|
168
|
+
const parseNumber = (start) => {
|
|
169
|
+
let index = start;
|
|
170
|
+
if (value[index] === '-')
|
|
171
|
+
index += 1;
|
|
172
|
+
if (value[index] === '0') {
|
|
173
|
+
index += 1;
|
|
174
|
+
}
|
|
175
|
+
else if (/[1-9]/.test(value[index] ?? '')) {
|
|
176
|
+
while (/[0-9]/.test(value[index] ?? ''))
|
|
177
|
+
index += 1;
|
|
178
|
+
}
|
|
179
|
+
else {
|
|
180
|
+
return false;
|
|
181
|
+
}
|
|
182
|
+
if (value[index] === '.') {
|
|
183
|
+
index += 1;
|
|
184
|
+
if (!/[0-9]/.test(value[index] ?? ''))
|
|
185
|
+
return false;
|
|
186
|
+
while (/[0-9]/.test(value[index] ?? ''))
|
|
187
|
+
index += 1;
|
|
188
|
+
}
|
|
189
|
+
if (value[index] === 'e' || value[index] === 'E') {
|
|
190
|
+
index += 1;
|
|
191
|
+
if (value[index] === '+' || value[index] === '-')
|
|
192
|
+
index += 1;
|
|
193
|
+
if (!/[0-9]/.test(value[index] ?? ''))
|
|
194
|
+
return false;
|
|
195
|
+
while (/[0-9]/.test(value[index] ?? ''))
|
|
196
|
+
index += 1;
|
|
197
|
+
}
|
|
198
|
+
return index - 1;
|
|
199
|
+
};
|
|
200
|
+
const parseValue = (index) => {
|
|
201
|
+
const char = value[index];
|
|
202
|
+
if (char === '"') {
|
|
203
|
+
const end = parseString(index);
|
|
204
|
+
if (end === null)
|
|
205
|
+
return null;
|
|
206
|
+
afterValue();
|
|
207
|
+
return end;
|
|
208
|
+
}
|
|
209
|
+
if (char === '{') {
|
|
210
|
+
stack.push({ kind: 'object', expect: 'keyOrEnd' });
|
|
211
|
+
return index;
|
|
212
|
+
}
|
|
213
|
+
if (char === '[') {
|
|
214
|
+
stack.push({ kind: 'array', expect: 'valueOrEnd' });
|
|
215
|
+
return index;
|
|
216
|
+
}
|
|
217
|
+
if (char === 't') {
|
|
218
|
+
const end = parseLiteral(index, 'true');
|
|
219
|
+
if (end === false || end === null)
|
|
220
|
+
return end;
|
|
221
|
+
afterValue();
|
|
222
|
+
return end;
|
|
223
|
+
}
|
|
224
|
+
if (char === 'f') {
|
|
225
|
+
const end = parseLiteral(index, 'false');
|
|
226
|
+
if (end === false || end === null)
|
|
227
|
+
return end;
|
|
228
|
+
afterValue();
|
|
229
|
+
return end;
|
|
230
|
+
}
|
|
231
|
+
if (char === 'n') {
|
|
232
|
+
const end = parseLiteral(index, 'null');
|
|
233
|
+
if (end === false || end === null)
|
|
234
|
+
return end;
|
|
235
|
+
afterValue();
|
|
236
|
+
return end;
|
|
237
|
+
}
|
|
238
|
+
// `parseValue` is only ever called (below, and from the main loop) with
|
|
239
|
+
// an `index` already known to be within `value`'s bounds, so `char` is
|
|
240
|
+
// always defined here; the non-null assertion documents that instead of
|
|
241
|
+
// a `?? ''` fallback that could never actually be exercised.
|
|
242
|
+
if (char === '-' || /[0-9]/.test(char)) {
|
|
243
|
+
const end = parseNumber(index);
|
|
244
|
+
if (end === false)
|
|
245
|
+
return false;
|
|
246
|
+
afterValue();
|
|
247
|
+
return end;
|
|
248
|
+
}
|
|
249
|
+
return false;
|
|
250
|
+
};
|
|
251
|
+
for (let index = 0; index < value.length; index += 1) {
|
|
252
|
+
// The loop bound (`index < value.length`) guarantees this index always
|
|
253
|
+
// yields a defined character; the non-null assertion documents that
|
|
254
|
+
// runtime invariant in place of a `noUncheckedIndexedAccess`-driven
|
|
255
|
+
// guard that could never actually trigger.
|
|
256
|
+
const char = value[index];
|
|
257
|
+
if (/\s/.test(char))
|
|
258
|
+
continue;
|
|
259
|
+
const current = stack.at(-1);
|
|
260
|
+
if (!current) {
|
|
261
|
+
if (rootComplete)
|
|
262
|
+
return 'invalid';
|
|
263
|
+
const end = parseValue(index);
|
|
264
|
+
if (end === false)
|
|
265
|
+
return 'invalid';
|
|
266
|
+
if (end === null)
|
|
267
|
+
return 'incomplete';
|
|
268
|
+
index = end;
|
|
269
|
+
continue;
|
|
270
|
+
}
|
|
271
|
+
if (current.kind === 'object') {
|
|
272
|
+
if (current.expect === 'keyOrEnd') {
|
|
273
|
+
if (char === '}') {
|
|
274
|
+
closeFrame();
|
|
275
|
+
continue;
|
|
276
|
+
}
|
|
277
|
+
if (char !== '"')
|
|
278
|
+
return 'invalid';
|
|
279
|
+
const end = parseString(index);
|
|
280
|
+
if (end === null)
|
|
281
|
+
return 'incomplete';
|
|
282
|
+
current.expect = 'colon';
|
|
283
|
+
index = end;
|
|
284
|
+
continue;
|
|
285
|
+
}
|
|
286
|
+
if (current.expect === 'colon') {
|
|
287
|
+
if (char !== ':')
|
|
288
|
+
return 'invalid';
|
|
289
|
+
current.expect = 'value';
|
|
290
|
+
continue;
|
|
291
|
+
}
|
|
292
|
+
if (current.expect === 'value') {
|
|
293
|
+
const end = parseValue(index);
|
|
294
|
+
if (end === false)
|
|
295
|
+
return 'invalid';
|
|
296
|
+
if (end === null)
|
|
297
|
+
return 'incomplete';
|
|
298
|
+
index = end;
|
|
299
|
+
continue;
|
|
300
|
+
}
|
|
301
|
+
if (char === '}') {
|
|
302
|
+
closeFrame();
|
|
303
|
+
continue;
|
|
304
|
+
}
|
|
305
|
+
if (char !== ',')
|
|
306
|
+
return 'invalid';
|
|
307
|
+
current.expect = 'keyOrEnd';
|
|
308
|
+
continue;
|
|
309
|
+
}
|
|
310
|
+
if (current.expect === 'valueOrEnd') {
|
|
311
|
+
if (char === ']') {
|
|
312
|
+
closeFrame();
|
|
313
|
+
continue;
|
|
314
|
+
}
|
|
315
|
+
const end = parseValue(index);
|
|
316
|
+
if (end === false)
|
|
317
|
+
return 'invalid';
|
|
318
|
+
if (end === null)
|
|
319
|
+
return 'incomplete';
|
|
320
|
+
index = end;
|
|
321
|
+
continue;
|
|
322
|
+
}
|
|
323
|
+
if (char === ']') {
|
|
324
|
+
closeFrame();
|
|
325
|
+
continue;
|
|
326
|
+
}
|
|
327
|
+
if (char !== ',')
|
|
328
|
+
return 'invalid';
|
|
329
|
+
current.expect = 'valueOrEnd';
|
|
330
|
+
}
|
|
331
|
+
return rootComplete && stack.length === 0 ? 'complete' : 'incomplete';
|
|
332
|
+
}
|
|
333
|
+
//# sourceMappingURL=json-line-stream.js.map
|