@superblocksteam/vite-plugin-file-sync 2.0.178-next.3 → 2.0.179-next.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/dist/agent-tool-executor/claude-sandbox.d.ts +1 -2
- package/dist/agent-tool-executor/claude-sandbox.d.ts.map +1 -1
- package/dist/agent-tool-executor/claude-sandbox.js +1 -3
- package/dist/agent-tool-executor/claude-sandbox.js.map +1 -1
- package/dist/agent-tool-executor/claude-shell.d.ts +1 -14
- package/dist/agent-tool-executor/claude-shell.d.ts.map +1 -1
- package/dist/agent-tool-executor/claude-shell.js +7 -61
- package/dist/agent-tool-executor/claude-shell.js.map +1 -1
- package/dist/agent-tool-executor/claude-tools.d.ts +0 -4
- package/dist/agent-tool-executor/claude-tools.d.ts.map +1 -1
- package/dist/agent-tool-executor/claude-tools.js +1 -1
- package/dist/agent-tool-executor/claude-tools.js.map +1 -1
- package/dist/agent-tool-executor/codex-drafts.d.ts +1 -2
- package/dist/agent-tool-executor/codex-drafts.d.ts.map +1 -1
- package/dist/agent-tool-executor/codex-drafts.js +1 -4
- package/dist/agent-tool-executor/codex-drafts.js.map +1 -1
- package/dist/agent-tool-executor/codex-execution-policy.d.ts +1 -1
- package/dist/agent-tool-executor/codex-execution-policy.d.ts.map +1 -1
- package/dist/agent-tool-executor/codex-execution-policy.js +15 -2
- package/dist/agent-tool-executor/codex-execution-policy.js.map +1 -1
- package/dist/agent-tool-executor/native-os-sandbox.d.ts +2 -2
- package/dist/agent-tool-executor/native-os-sandbox.js +2 -2
- package/dist/agent-tool-executor/native-tool-servers.d.ts +10 -5
- package/dist/agent-tool-executor/native-tool-servers.d.ts.map +1 -1
- package/dist/agent-tool-executor/native-tool-servers.js +23 -9
- package/dist/agent-tool-executor/native-tool-servers.js.map +1 -1
- package/dist/ai-service/agent/middleware.d.ts.map +1 -1
- package/dist/ai-service/agent/middleware.js +1 -0
- package/dist/ai-service/agent/middleware.js.map +1 -1
- package/dist/ai-service/agent/prompts/build-base-system-prompt.d.ts +6 -0
- package/dist/ai-service/agent/prompts/build-base-system-prompt.d.ts.map +1 -1
- package/dist/ai-service/agent/prompts/build-base-system-prompt.js +4 -0
- package/dist/ai-service/agent/prompts/build-base-system-prompt.js.map +1 -1
- package/dist/ai-service/agent/prompts/project-prompt.d.ts +11 -0
- package/dist/ai-service/agent/prompts/project-prompt.d.ts.map +1 -0
- package/dist/ai-service/agent/prompts/project-prompt.js +20 -0
- package/dist/ai-service/agent/prompts/project-prompt.js.map +1 -0
- package/dist/ai-service/agent/tools/apis/test-api.d.ts +57 -0
- package/dist/ai-service/agent/tools/apis/test-api.d.ts.map +1 -1
- package/dist/ai-service/agent/tools/apis/test-api.js +1 -1
- package/dist/ai-service/agent/tools/apis/test-api.js.map +1 -1
- package/dist/ai-service/agent/tools/branching/branch-tools.d.ts +2 -8
- package/dist/ai-service/agent/tools/branching/branch-tools.d.ts.map +1 -1
- package/dist/ai-service/agent/tools/branching/branch-tools.js +8 -8
- package/dist/ai-service/agent/tools/branching/branch-tools.js.map +1 -1
- package/dist/ai-service/agent/tools/build-capture-screenshot.d.ts +1 -0
- package/dist/ai-service/agent/tools/build-capture-screenshot.d.ts.map +1 -1
- package/dist/ai-service/agent/tools/build-capture-screenshot.js +24 -1
- package/dist/ai-service/agent/tools/build-capture-screenshot.js.map +1 -1
- package/dist/ai-service/agent/tools/build-list-files.d.ts +1 -1
- package/dist/ai-service/agent/tools/build-list-files.d.ts.map +1 -1
- package/dist/ai-service/agent/tools/build-list-files.js +14 -1
- package/dist/ai-service/agent/tools/build-list-files.js.map +1 -1
- package/dist/ai-service/agent/tools/databases/dev-database-tools.d.ts +6 -6
- package/dist/ai-service/agent/tools/databases/dev-database-tools.d.ts.map +1 -1
- package/dist/ai-service/agent/tools/search-web.d.ts +22 -0
- package/dist/ai-service/agent/tools/search-web.d.ts.map +1 -0
- package/dist/ai-service/agent/tools/search-web.js +87 -0
- package/dist/ai-service/agent/tools/search-web.js.map +1 -0
- package/dist/ai-service/attachments/artifact-reference.d.ts +14 -0
- package/dist/ai-service/attachments/artifact-reference.d.ts.map +1 -0
- package/dist/ai-service/attachments/artifact-reference.js +28 -0
- package/dist/ai-service/attachments/artifact-reference.js.map +1 -0
- package/dist/ai-service/attachments/artifact-storage.d.ts +61 -0
- package/dist/ai-service/attachments/artifact-storage.d.ts.map +1 -0
- package/dist/ai-service/attachments/artifact-storage.js +178 -0
- package/dist/ai-service/attachments/artifact-storage.js.map +1 -0
- package/dist/ai-service/attachments/native-attachment-preparations.d.ts +32 -0
- package/dist/ai-service/attachments/native-attachment-preparations.d.ts.map +1 -0
- package/dist/ai-service/attachments/native-attachment-preparations.js +80 -0
- package/dist/ai-service/attachments/native-attachment-preparations.js.map +1 -0
- package/dist/ai-service/attachments/text-upload-artifacts.d.ts +14 -10
- package/dist/ai-service/attachments/text-upload-artifacts.d.ts.map +1 -1
- package/dist/ai-service/attachments/text-upload-artifacts.js +21 -86
- package/dist/ai-service/attachments/text-upload-artifacts.js.map +1 -1
- package/dist/ai-service/attachments/upload-artifact-paths.d.ts +2 -0
- package/dist/ai-service/attachments/upload-artifact-paths.d.ts.map +1 -1
- package/dist/ai-service/attachments/upload-artifact-paths.js +2 -0
- package/dist/ai-service/attachments/upload-artifact-paths.js.map +1 -1
- package/dist/ai-service/attachments/uploaded-content-part.d.ts +1 -0
- package/dist/ai-service/attachments/uploaded-content-part.d.ts.map +1 -1
- package/dist/ai-service/attachments/uploaded-content-part.js +3 -7
- package/dist/ai-service/attachments/uploaded-content-part.js.map +1 -1
- package/dist/ai-service/attachments/validate-prompt-attachments.d.ts +12 -3
- package/dist/ai-service/attachments/validate-prompt-attachments.d.ts.map +1 -1
- package/dist/ai-service/attachments/validate-prompt-attachments.js +171 -55
- package/dist/ai-service/attachments/validate-prompt-attachments.js.map +1 -1
- package/dist/ai-service/builder-context-usage.d.ts +12 -0
- package/dist/ai-service/builder-context-usage.d.ts.map +1 -0
- package/dist/ai-service/builder-context-usage.js +23 -0
- package/dist/ai-service/builder-context-usage.js.map +1 -0
- package/dist/ai-service/builder-conversation.d.ts +65 -9
- package/dist/ai-service/builder-conversation.d.ts.map +1 -1
- package/dist/ai-service/builder-conversation.js +229 -62
- package/dist/ai-service/builder-conversation.js.map +1 -1
- package/dist/ai-service/builder-core-prompt.d.ts +23 -0
- package/dist/ai-service/builder-core-prompt.d.ts.map +1 -0
- package/dist/ai-service/builder-core-prompt.js +148 -0
- package/dist/ai-service/builder-core-prompt.js.map +1 -0
- package/dist/ai-service/builder-failure-drain.d.ts +25 -0
- package/dist/ai-service/builder-failure-drain.d.ts.map +1 -0
- package/dist/ai-service/builder-failure-drain.js +67 -0
- package/dist/ai-service/builder-failure-drain.js.map +1 -0
- package/dist/ai-service/builder-failure-notice.d.ts +21 -0
- package/dist/ai-service/builder-failure-notice.d.ts.map +1 -0
- package/dist/ai-service/builder-failure-notice.js +47 -0
- package/dist/ai-service/builder-failure-notice.js.map +1 -0
- package/dist/ai-service/builder-inference-auth.d.ts +5 -2
- package/dist/ai-service/builder-inference-auth.d.ts.map +1 -1
- package/dist/ai-service/builder-inference-auth.js +25 -4
- package/dist/ai-service/builder-inference-auth.js.map +1 -1
- package/dist/ai-service/builder-runtime-auth-metrics.d.ts +15 -0
- package/dist/ai-service/builder-runtime-auth-metrics.d.ts.map +1 -0
- package/dist/ai-service/builder-runtime-auth-metrics.js +40 -0
- package/dist/ai-service/builder-runtime-auth-metrics.js.map +1 -0
- package/dist/ai-service/builder-runtime-auth.d.ts +53 -0
- package/dist/ai-service/builder-runtime-auth.d.ts.map +1 -0
- package/dist/ai-service/builder-runtime-auth.js +166 -0
- package/dist/ai-service/builder-runtime-auth.js.map +1 -0
- package/dist/ai-service/builder-runtime.d.ts +201 -23
- package/dist/ai-service/builder-runtime.d.ts.map +1 -1
- package/dist/ai-service/builder-runtime.js +355 -109
- package/dist/ai-service/builder-runtime.js.map +1 -1
- package/dist/ai-service/builder-skills-auth.d.ts +16 -0
- package/dist/ai-service/builder-skills-auth.d.ts.map +1 -0
- package/dist/ai-service/builder-skills-auth.js +107 -0
- package/dist/ai-service/builder-skills-auth.js.map +1 -0
- package/dist/ai-service/builder-subagents.d.ts +37 -0
- package/dist/ai-service/builder-subagents.d.ts.map +1 -0
- package/dist/ai-service/builder-subagents.js +103 -0
- package/dist/ai-service/builder-subagents.js.map +1 -0
- package/dist/ai-service/builder-tool-callbacks.d.ts.map +1 -1
- package/dist/ai-service/builder-tool-callbacks.js +21 -4
- package/dist/ai-service/builder-tool-callbacks.js.map +1 -1
- package/dist/ai-service/builder-tools.d.ts +11 -7
- package/dist/ai-service/builder-tools.d.ts.map +1 -1
- package/dist/ai-service/builder-tools.js +89 -34
- package/dist/ai-service/builder-tools.js.map +1 -1
- package/dist/ai-service/builder-workspace.d.ts +48 -0
- package/dist/ai-service/builder-workspace.d.ts.map +1 -1
- package/dist/ai-service/builder-workspace.js +139 -19
- package/dist/ai-service/builder-workspace.js.map +1 -1
- package/dist/ai-service/chat/chat-session-store.d.ts +31 -3
- package/dist/ai-service/chat/chat-session-store.d.ts.map +1 -1
- package/dist/ai-service/chat/chat-session-store.js +104 -10
- package/dist/ai-service/chat/chat-session-store.js.map +1 -1
- package/dist/ai-service/context-download.d.ts +4 -2
- package/dist/ai-service/context-download.d.ts.map +1 -1
- package/dist/ai-service/context-download.js +13 -3
- package/dist/ai-service/context-download.js.map +1 -1
- package/dist/ai-service/demo-agents/api-tools.d.ts +14 -0
- package/dist/ai-service/demo-agents/api-tools.d.ts.map +1 -0
- package/dist/ai-service/demo-agents/api-tools.js +58 -0
- package/dist/ai-service/demo-agents/api-tools.js.map +1 -0
- package/dist/ai-service/demo-agents/enabled.d.ts +7 -0
- package/dist/ai-service/demo-agents/enabled.d.ts.map +1 -0
- package/dist/ai-service/demo-agents/enabled.js +8 -0
- package/dist/ai-service/demo-agents/enabled.js.map +1 -0
- package/dist/ai-service/demo-agents/handlers.d.ts +77 -0
- package/dist/ai-service/demo-agents/handlers.d.ts.map +1 -0
- package/dist/ai-service/demo-agents/handlers.js +95 -0
- package/dist/ai-service/demo-agents/handlers.js.map +1 -0
- package/dist/ai-service/demo-agents/load-agents.d.ts +9 -0
- package/dist/ai-service/demo-agents/load-agents.d.ts.map +1 -0
- package/dist/ai-service/demo-agents/load-agents.js +76 -0
- package/dist/ai-service/demo-agents/load-agents.js.map +1 -0
- package/dist/ai-service/demo-agents/run-agent.d.ts +39 -0
- package/dist/ai-service/demo-agents/run-agent.d.ts.map +1 -0
- package/dist/ai-service/demo-agents/run-agent.js +119 -0
- package/dist/ai-service/demo-agents/run-agent.js.map +1 -0
- package/dist/ai-service/demo-agents/sessions.d.ts +5 -0
- package/dist/ai-service/demo-agents/sessions.d.ts.map +1 -0
- package/dist/ai-service/demo-agents/sessions.js +33 -0
- package/dist/ai-service/demo-agents/sessions.js.map +1 -0
- package/dist/ai-service/demo-agents/system-prompt.d.ts +12 -0
- package/dist/ai-service/demo-agents/system-prompt.d.ts.map +1 -0
- package/dist/ai-service/demo-agents/system-prompt.js +56 -0
- package/dist/ai-service/demo-agents/system-prompt.js.map +1 -0
- package/dist/ai-service/demo-agents/types.d.ts +95 -0
- package/dist/ai-service/demo-agents/types.d.ts.map +1 -0
- package/dist/ai-service/demo-agents/types.js +15 -0
- package/dist/ai-service/demo-agents/types.js.map +1 -0
- package/dist/ai-service/features.d.ts +11 -0
- package/dist/ai-service/features.d.ts.map +1 -1
- package/dist/ai-service/features.js +11 -0
- package/dist/ai-service/features.js.map +1 -1
- package/dist/ai-service/index.d.ts +202 -4
- package/dist/ai-service/index.d.ts.map +1 -1
- package/dist/ai-service/index.js +1020 -104
- package/dist/ai-service/index.js.map +1 -1
- package/dist/ai-service/judge/tools/playwright-action.d.ts +5 -5
- package/dist/ai-service/llm/context-v2/compaction/server-side.d.ts +5 -1
- package/dist/ai-service/llm/context-v2/compaction/server-side.d.ts.map +1 -1
- package/dist/ai-service/llm/context-v2/compaction/server-side.js +9 -2
- package/dist/ai-service/llm/context-v2/compaction/server-side.js.map +1 -1
- package/dist/ai-service/llm/context-v2/context-management.d.ts +5 -0
- package/dist/ai-service/llm/context-v2/context-management.d.ts.map +1 -1
- package/dist/ai-service/llm/context-v2/context-management.js +3 -0
- package/dist/ai-service/llm/context-v2/context-management.js.map +1 -1
- package/dist/ai-service/llm/context-v2/context-metrics.d.ts.map +1 -1
- package/dist/ai-service/llm/context-v2/context-metrics.js +3 -2
- package/dist/ai-service/llm/context-v2/context-metrics.js.map +1 -1
- package/dist/ai-service/llm/context-v2/manager.d.ts +2 -1
- package/dist/ai-service/llm/context-v2/manager.d.ts.map +1 -1
- package/dist/ai-service/llm/context-v2/manager.js +12 -1
- package/dist/ai-service/llm/context-v2/manager.js.map +1 -1
- package/dist/ai-service/llm/context-v2/types.d.ts +10 -0
- package/dist/ai-service/llm/context-v2/types.d.ts.map +1 -1
- package/dist/ai-service/llm/context-v2/types.js +43 -8
- package/dist/ai-service/llm/context-v2/types.js.map +1 -1
- package/dist/ai-service/llm/error.d.ts +16 -0
- package/dist/ai-service/llm/error.d.ts.map +1 -1
- package/dist/ai-service/llm/error.js +69 -0
- package/dist/ai-service/llm/error.js.map +1 -1
- package/dist/ai-service/llm/stream/config.d.ts +2 -2
- package/dist/ai-service/llm/stream/config.d.ts.map +1 -1
- package/dist/ai-service/llm/stream/config.js +6 -4
- package/dist/ai-service/llm/stream/config.js.map +1 -1
- package/dist/ai-service/llm/stream/observers/retry-notification.d.ts.map +1 -1
- package/dist/ai-service/llm/stream/observers/retry-notification.js +8 -1
- package/dist/ai-service/llm/stream/observers/retry-notification.js.map +1 -1
- package/dist/ai-service/llm/stream/orchestrator.d.ts +1 -0
- package/dist/ai-service/llm/stream/orchestrator.d.ts.map +1 -1
- package/dist/ai-service/llm/stream/orchestrator.js +53 -1
- package/dist/ai-service/llm/stream/orchestrator.js.map +1 -1
- package/dist/ai-service/llm/stream/retry-engine.d.ts +3 -1
- package/dist/ai-service/llm/stream/retry-engine.d.ts.map +1 -1
- package/dist/ai-service/llm/stream/retry-engine.js +21 -4
- package/dist/ai-service/llm/stream/retry-engine.js.map +1 -1
- package/dist/ai-service/llm/stream/retry-schedule.d.ts +27 -0
- package/dist/ai-service/llm/stream/retry-schedule.d.ts.map +1 -0
- package/dist/ai-service/llm/stream/retry-schedule.js +28 -0
- package/dist/ai-service/llm/stream/retry-schedule.js.map +1 -0
- package/dist/ai-service/llm/stream/session.d.ts +2 -0
- package/dist/ai-service/llm/stream/session.d.ts.map +1 -1
- package/dist/ai-service/llm/stream/session.js +2 -0
- package/dist/ai-service/llm/stream/session.js.map +1 -1
- package/dist/ai-service/llm/terminal-error-message.d.ts +67 -0
- package/dist/ai-service/llm/terminal-error-message.d.ts.map +1 -0
- package/dist/ai-service/llm/terminal-error-message.js +154 -0
- package/dist/ai-service/llm/terminal-error-message.js.map +1 -0
- package/dist/ai-service/native-secret-redactor.js +1 -1
- package/dist/ai-service/native-secret-redactor.js.map +1 -1
- package/dist/ai-service/native-turn-failure.d.ts +35 -0
- package/dist/ai-service/native-turn-failure.d.ts.map +1 -0
- package/dist/ai-service/native-turn-failure.js +149 -0
- package/dist/ai-service/native-turn-failure.js.map +1 -0
- package/dist/ai-service/outbound-trace-context.d.ts +18 -0
- package/dist/ai-service/outbound-trace-context.d.ts.map +1 -0
- package/dist/ai-service/outbound-trace-context.js +20 -0
- package/dist/ai-service/outbound-trace-context.js.map +1 -0
- package/dist/ai-service/policy-gate-review.d.ts +18 -3
- package/dist/ai-service/policy-gate-review.d.ts.map +1 -1
- package/dist/ai-service/policy-gate-review.js +32 -10
- package/dist/ai-service/policy-gate-review.js.map +1 -1
- package/dist/ai-service/security/secret-scanner-service.d.ts +2 -1
- package/dist/ai-service/security/secret-scanner-service.d.ts.map +1 -1
- package/dist/ai-service/security/secret-scanner-service.js +60 -9
- package/dist/ai-service/security/secret-scanner-service.js.map +1 -1
- package/dist/ai-service/security/secret-scanner.d.ts +17 -16
- package/dist/ai-service/security/secret-scanner.d.ts.map +1 -1
- package/dist/ai-service/security/secret-scanner.js +91 -159
- package/dist/ai-service/security/secret-scanner.js.map +1 -1
- package/dist/ai-service/security/trufflehog-diagnostics.d.ts +17 -0
- package/dist/ai-service/security/trufflehog-diagnostics.d.ts.map +1 -0
- package/dist/ai-service/security/trufflehog-diagnostics.js +20 -0
- package/dist/ai-service/security/trufflehog-diagnostics.js.map +1 -0
- package/dist/ai-service/security/trufflehog-process.d.ts +80 -0
- package/dist/ai-service/security/trufflehog-process.d.ts.map +1 -0
- package/dist/ai-service/security/trufflehog-process.js +305 -0
- package/dist/ai-service/security/trufflehog-process.js.map +1 -0
- package/dist/ai-service/state-machine/clark-fsm.d.ts +3 -0
- package/dist/ai-service/state-machine/clark-fsm.d.ts.map +1 -1
- package/dist/ai-service/state-machine/clark-fsm.js.map +1 -1
- package/dist/ai-service/state-machine/handlers/agent-planning.d.ts +0 -12
- package/dist/ai-service/state-machine/handlers/agent-planning.d.ts.map +1 -1
- package/dist/ai-service/state-machine/handlers/agent-planning.js +3 -121
- package/dist/ai-service/state-machine/handlers/agent-planning.js.map +1 -1
- package/dist/ai-service/state-machine/handlers/idle.d.ts.map +1 -1
- package/dist/ai-service/state-machine/handlers/idle.js +3 -2
- package/dist/ai-service/state-machine/handlers/idle.js.map +1 -1
- package/dist/ai-service/state-machine/handlers/llm-generating.d.ts.map +1 -1
- package/dist/ai-service/state-machine/handlers/llm-generating.js +27 -11
- package/dist/ai-service/state-machine/handlers/llm-generating.js.map +1 -1
- package/dist/ai-service/state-machine/helpers/stable-peer.d.ts.map +1 -1
- package/dist/ai-service/state-machine/helpers/stable-peer.js +14 -5
- package/dist/ai-service/state-machine/helpers/stable-peer.js.map +1 -1
- package/dist/ai-service/types.d.ts +2 -0
- package/dist/ai-service/types.d.ts.map +1 -1
- package/dist/ai-service/types.js.map +1 -1
- package/dist/ai-service/workspace-metrics.d.ts +1 -0
- package/dist/ai-service/workspace-metrics.d.ts.map +1 -1
- package/dist/ai-service/workspace-metrics.js +14 -1
- package/dist/ai-service/workspace-metrics.js.map +1 -1
- package/dist/attachment-artifacts.d.ts +4 -0
- package/dist/attachment-artifacts.d.ts.map +1 -0
- package/dist/attachment-artifacts.js +4 -0
- package/dist/attachment-artifacts.js.map +1 -0
- package/dist/dev-server-ws-smoke-client.d.ts.map +1 -1
- package/dist/dev-server-ws-smoke-client.js +1 -0
- package/dist/dev-server-ws-smoke-client.js.map +1 -1
- package/dist/file-sync-vite-plugin.d.ts.map +1 -1
- package/dist/file-sync-vite-plugin.js +51 -2
- package/dist/file-sync-vite-plugin.js.map +1 -1
- package/dist/git-service/credential-scope.d.ts +1 -0
- package/dist/git-service/credential-scope.d.ts.map +1 -1
- package/dist/git-service/credential-scope.js +56 -1
- package/dist/git-service/credential-scope.js.map +1 -1
- package/dist/index.d.ts +9 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +5 -0
- package/dist/index.js.map +1 -1
- package/dist/inject-index-vite-plugin.d.ts.map +1 -1
- package/dist/inject-index-vite-plugin.js +2 -0
- package/dist/inject-index-vite-plugin.js.map +1 -1
- package/dist/injected-index.d.ts.map +1 -1
- package/dist/injected-index.js +2 -0
- package/dist/injected-index.js.map +1 -1
- package/dist/lock-service/branch-metrics.d.ts +3 -0
- package/dist/lock-service/branch-metrics.d.ts.map +1 -0
- package/dist/lock-service/branch-metrics.js +15 -0
- package/dist/lock-service/branch-metrics.js.map +1 -0
- package/dist/lock-service/index.d.ts +9 -0
- package/dist/lock-service/index.d.ts.map +1 -1
- package/dist/lock-service/index.js +55 -7
- package/dist/lock-service/index.js.map +1 -1
- package/dist/plugin-options.d.ts +7 -7
- package/dist/plugin-options.d.ts.map +1 -1
- package/dist/policy-gate-live-step.d.ts +25 -0
- package/dist/policy-gate-live-step.d.ts.map +1 -0
- package/dist/policy-gate-live-step.js +197 -0
- package/dist/policy-gate-live-step.js.map +1 -0
- package/dist/policy-gate-run-registry.d.ts +10 -0
- package/dist/policy-gate-run-registry.d.ts.map +1 -1
- package/dist/policy-gate-run-registry.js +28 -0
- package/dist/policy-gate-run-registry.js.map +1 -1
- package/dist/policy-gate-runner.d.ts +9 -1
- package/dist/policy-gate-runner.d.ts.map +1 -1
- package/dist/policy-gate-runner.js +100 -36
- package/dist/policy-gate-runner.js.map +1 -1
- package/dist/policy-gates/authorization.d.ts +9 -0
- package/dist/policy-gates/authorization.d.ts.map +1 -0
- package/dist/policy-gates/authorization.js +12 -0
- package/dist/policy-gates/authorization.js.map +1 -0
- package/dist/policy-gates/index.d.ts +5 -0
- package/dist/policy-gates/index.d.ts.map +1 -0
- package/dist/policy-gates/index.js +4 -0
- package/dist/policy-gates/index.js.map +1 -0
- package/dist/policy-gates/metrics.d.ts +23 -0
- package/dist/policy-gates/metrics.d.ts.map +1 -0
- package/dist/policy-gates/metrics.js +19 -0
- package/dist/policy-gates/metrics.js.map +1 -0
- package/dist/project-agent-tools.d.ts +23 -0
- package/dist/project-agent-tools.d.ts.map +1 -0
- package/dist/project-agent-tools.js +73 -0
- package/dist/project-agent-tools.js.map +1 -0
- package/dist/project-functions.d.ts +19 -0
- package/dist/project-functions.d.ts.map +1 -0
- package/dist/project-functions.js +70 -0
- package/dist/project-functions.js.map +1 -0
- package/dist/project-manifest.d.ts +150 -0
- package/dist/project-manifest.d.ts.map +1 -0
- package/dist/project-manifest.js +284 -0
- package/dist/project-manifest.js.map +1 -0
- package/dist/review-runner.d.ts.map +1 -1
- package/dist/review-runner.js +12 -14
- package/dist/review-runner.js.map +1 -1
- package/dist/socket-manager.d.ts +2 -1
- package/dist/socket-manager.d.ts.map +1 -1
- package/dist/socket-manager.js +162 -6
- package/dist/socket-manager.js.map +1 -1
- package/dist/sync-service/index.d.ts.map +1 -1
- package/dist/sync-service/index.js +2 -0
- package/dist/sync-service/index.js.map +1 -1
- package/dist/workspace-sync-methods.d.ts +21 -1
- package/dist/workspace-sync-methods.d.ts.map +1 -1
- package/package.json +17 -21
- package/dist/agent-tool-executor/claude-sandbox-placeholders.d.ts +0 -38
- package/dist/agent-tool-executor/claude-sandbox-placeholders.d.ts.map +0 -1
- package/dist/agent-tool-executor/claude-sandbox-placeholders.js +0 -132
- package/dist/agent-tool-executor/claude-sandbox-placeholders.js.map +0 -1
- package/dist/ai-service/skills/system/native.d.ts +0 -15
- package/dist/ai-service/skills/system/native.d.ts.map +0 -1
- package/dist/ai-service/skills/system/native.js +0 -32
- package/dist/ai-service/skills/system/native.js.map +0 -1
- package/dist/native-system-skills.d.ts +0 -2
- package/dist/native-system-skills.d.ts.map +0 -1
- package/dist/native-system-skills.js +0 -4
- package/dist/native-system-skills.js.map +0 -1
|
@@ -1,17 +1,23 @@
|
|
|
1
1
|
import { randomBytes } from "node:crypto";
|
|
2
|
-
import {
|
|
3
|
-
import { context, propagation, trace } from "@opentelemetry/api";
|
|
2
|
+
import { context, trace } from "@opentelemetry/api";
|
|
4
3
|
import { asSchema, tool } from "ai";
|
|
5
4
|
import { z } from "zod";
|
|
6
5
|
import { NativeBuilderModel, } from "@superblocksteam/shared";
|
|
7
|
-
import { WORKSPACE_INGRESS_PORT, deriveWorkspaceEndpointToken, deriveWorkspaceToken, workspaceEndpointSchema, } from "@superblocksteam/workspace-sync/control";
|
|
6
|
+
import { BUILDER_RUNTIME_ENDPOINT_HEADER, BUILDER_RUNTIME_INVOCATIONS_PATH, BUILDER_RUNTIME_SESSION_HEADER, BUILDER_RUNTIME_SIGN_GRANT_HEADER, BUILDER_RUNTIME_SIGN_PATH, WORKSPACE_INGRESS_PORT, builderRuntimeEndpointHeaderSchema, deriveWorkspaceEndpointToken, deriveWorkspaceToken, workspaceEndpointSchema, } from "@superblocksteam/workspace-sync/control";
|
|
8
7
|
import { getErrorMeta } from "../util/logger.js";
|
|
9
8
|
import { getToolOutput } from "./agent/tool-message-utils.js";
|
|
10
9
|
import { movesEditor } from "./agent/tools/branching/branch-tools.js";
|
|
10
|
+
import { BuilderFailureDrain, } from "./builder-failure-drain.js";
|
|
11
11
|
import { BuilderInferenceAuthError } from "./builder-inference-auth.js";
|
|
12
12
|
import { AgentCoreToolHost } from "./builder-tool-callbacks.js";
|
|
13
13
|
import { NativeCallbackOrder } from "./native-callback-order.js";
|
|
14
14
|
import { NativeSecretRedactor } from "./native-secret-redactor.js";
|
|
15
|
+
import { OutboundTraceContext, } from "./outbound-trace-context.js";
|
|
16
|
+
/** Runtime control calls whose failure to authorize inference stops the turn. */
|
|
17
|
+
const INFERENCE_AUTH_CALLS = new Set([
|
|
18
|
+
"__runtime_redact",
|
|
19
|
+
"__runtime_inference_token",
|
|
20
|
+
]);
|
|
15
21
|
const executionDescriptorSchema = z
|
|
16
22
|
.object({
|
|
17
23
|
token: z.string().min(32).max(4096),
|
|
@@ -26,11 +32,30 @@ const executionDescriptorSchema = z
|
|
|
26
32
|
.max(2048),
|
|
27
33
|
})
|
|
28
34
|
.strict();
|
|
35
|
+
const tokenCountSchema = z.number().int().nonnegative();
|
|
36
|
+
/** How full the root conversation's context window is when a turn ends. */
|
|
37
|
+
const contextUsageSchema = z.object({
|
|
38
|
+
usedTokens: tokenCountSchema,
|
|
39
|
+
windowTokens: tokenCountSchema,
|
|
40
|
+
/** Occupancy at which the harness summarizes older messages. */
|
|
41
|
+
compactionTokens: tokenCountSchema,
|
|
42
|
+
breakdown: z
|
|
43
|
+
.object({
|
|
44
|
+
systemPrompt: tokenCountSchema,
|
|
45
|
+
tools: tokenCountSchema,
|
|
46
|
+
conversation: tokenCountSchema,
|
|
47
|
+
})
|
|
48
|
+
.optional()
|
|
49
|
+
.catch(undefined),
|
|
50
|
+
});
|
|
29
51
|
const usageSchema = z.object({
|
|
30
|
-
inputTokens:
|
|
31
|
-
outputTokens:
|
|
32
|
-
cacheReadTokens:
|
|
33
|
-
cacheWriteTokens:
|
|
52
|
+
inputTokens: tokenCountSchema,
|
|
53
|
+
outputTokens: tokenCountSchema,
|
|
54
|
+
cacheReadTokens: tokenCountSchema.optional(),
|
|
55
|
+
cacheWriteTokens: tokenCountSchema.optional(),
|
|
56
|
+
// Lenient: the ring is a convenience, so a shape this host does not know
|
|
57
|
+
// must not fail the stream parse.
|
|
58
|
+
context: contextUsageSchema.optional().catch(undefined),
|
|
34
59
|
});
|
|
35
60
|
/**
|
|
36
61
|
* Workspace state on an AgentCore `finish` event. Not strict: the runtime may
|
|
@@ -47,7 +72,25 @@ const workspaceFinishSchema = z.object({
|
|
|
47
72
|
* the VM's `/sb-dev-updates`; `workspace.open` returns it.
|
|
48
73
|
*/
|
|
49
74
|
internalToken: z.string().min(1).max(4096).optional(),
|
|
75
|
+
/** `workspace.open` from a runtime that accepts a turn's `ownerId`. */
|
|
76
|
+
ownerScoped: z.boolean().optional(),
|
|
50
77
|
});
|
|
78
|
+
/**
|
|
79
|
+
* Why a native turn failed, as the runtime classifies it. Mirrors the
|
|
80
|
+
* runtime's wire enum; the host and runtime deploy independently, so a value
|
|
81
|
+
* this host does not know reads as `unknown`.
|
|
82
|
+
*/
|
|
83
|
+
const runtimeFailureReasonSchema = z.enum([
|
|
84
|
+
"context_window_exceeded",
|
|
85
|
+
"usage_limit_exceeded",
|
|
86
|
+
"inference_rejected",
|
|
87
|
+
"inference_unavailable",
|
|
88
|
+
"stream_interrupted",
|
|
89
|
+
"attachment_limit_exceeded",
|
|
90
|
+
"attachment_unavailable",
|
|
91
|
+
"attachment_unsupported",
|
|
92
|
+
"unknown",
|
|
93
|
+
]);
|
|
51
94
|
const eventSchema = z.discriminatedUnion("type", [
|
|
52
95
|
z.object({ type: z.literal("session"), sessionId: z.string().min(1) }),
|
|
53
96
|
z.object({ type: z.literal("callback-ready"), id: z.string().uuid() }),
|
|
@@ -62,6 +105,9 @@ const eventSchema = z.discriminatedUnion("type", [
|
|
|
62
105
|
toolCallId: z.string(),
|
|
63
106
|
toolName: z.string(),
|
|
64
107
|
input: z.unknown(),
|
|
108
|
+
// The sub-agent call this call was made inside. Lenient: grouping is a
|
|
109
|
+
// convenience and must not fail the stream parse.
|
|
110
|
+
parentToolCallId: z.string().optional().catch(undefined),
|
|
65
111
|
}),
|
|
66
112
|
z.object({
|
|
67
113
|
type: z.literal("tool-result"),
|
|
@@ -81,19 +127,46 @@ const eventSchema = z.discriminatedUnion("type", [
|
|
|
81
127
|
type: z.literal("error"),
|
|
82
128
|
message: z.string(),
|
|
83
129
|
code: z.string().optional(),
|
|
130
|
+
// Lenient: an unrecognized value must not fail the stream parse.
|
|
131
|
+
reason: runtimeFailureReasonSchema.catch("unknown").optional(),
|
|
132
|
+
// Set when the invocation failed before its turn began to run.
|
|
133
|
+
beforeTurn: z.boolean().optional().catch(undefined),
|
|
134
|
+
// Older runtimes marked beforeTurn only before session acquisition.
|
|
135
|
+
runSubmitted: z.boolean().optional().catch(true),
|
|
84
136
|
}),
|
|
85
137
|
]);
|
|
138
|
+
/** A bounded runtime failure; user advice is owned by the shared failure taxonomy. */
|
|
86
139
|
export class BuilderRuntimeError extends Error {
|
|
87
140
|
code;
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
141
|
+
beforeTurn;
|
|
142
|
+
runSubmitted;
|
|
143
|
+
cleanupConfirmed;
|
|
144
|
+
cleanupOutcome;
|
|
145
|
+
reason;
|
|
146
|
+
constructor(code, reason = "unknown",
|
|
147
|
+
/** Whether the invocation failed before its turn began to run. */
|
|
148
|
+
beforeTurn = false,
|
|
149
|
+
/** Whether the session recorded this run ID before the failure. */
|
|
150
|
+
runSubmitted = false,
|
|
151
|
+
/** Whether the runtime acknowledged completing cleanup for this invocation. */
|
|
152
|
+
cleanupConfirmed = true,
|
|
153
|
+
/** The terminal cleanup observation when confirmation failed. */
|
|
154
|
+
cleanupOutcome) {
|
|
155
|
+
super("The builder runtime reported a failure");
|
|
94
156
|
this.code = code;
|
|
157
|
+
this.beforeTurn = beforeTurn;
|
|
158
|
+
this.runSubmitted = runSubmitted;
|
|
159
|
+
this.cleanupConfirmed = cleanupConfirmed;
|
|
160
|
+
this.cleanupOutcome = cleanupOutcome;
|
|
161
|
+
// Re-validated: a caller can still pass an unchecked wire value.
|
|
162
|
+
this.reason = runtimeFailureReasonSchema.catch("unknown").parse(reason);
|
|
163
|
+
}
|
|
164
|
+
/** Preserves the reported failure while forbidding an automatic retry. */
|
|
165
|
+
withUnconfirmedCleanup(outcome = "stream_failed") {
|
|
166
|
+
return new BuilderRuntimeError(this.code, this.reason, this.beforeTurn, this.runSubmitted, false, outcome);
|
|
95
167
|
}
|
|
96
|
-
|
|
168
|
+
/** Logs the safe failure classification and its invocation-attempt context. */
|
|
169
|
+
static log(error, logger, attempt) {
|
|
97
170
|
const code = error instanceof BuilderRuntimeError
|
|
98
171
|
? z
|
|
99
172
|
.enum([
|
|
@@ -108,12 +181,32 @@ export class BuilderRuntimeError extends Error {
|
|
|
108
181
|
])
|
|
109
182
|
.safeParse(error.code)
|
|
110
183
|
: undefined;
|
|
184
|
+
const reason = error instanceof BuilderRuntimeError
|
|
185
|
+
? runtimeFailureReasonSchema.catch("unknown").parse(error.reason)
|
|
186
|
+
: undefined;
|
|
111
187
|
logger.warn("Native builder operation failed", {
|
|
112
188
|
...getErrorMeta(error),
|
|
113
189
|
...(code && { "failure.code": code.success ? code.data : "unknown" }),
|
|
190
|
+
...(reason && { "failure.reason": reason }),
|
|
191
|
+
...(error instanceof BuilderRuntimeError && {
|
|
192
|
+
"failure.before_turn": error.beforeTurn,
|
|
193
|
+
"failure.run_submitted": error.runSubmitted,
|
|
194
|
+
"failure.cleanup_confirmed": error.cleanupConfirmed,
|
|
195
|
+
...(error.cleanupOutcome && {
|
|
196
|
+
"failure.cleanup_outcome": error.cleanupOutcome,
|
|
197
|
+
}),
|
|
198
|
+
}),
|
|
199
|
+
...(attempt && {
|
|
200
|
+
"retry.attempt": attempt.attempt,
|
|
201
|
+
"retry.will_retry": attempt.willRetry,
|
|
202
|
+
}),
|
|
114
203
|
});
|
|
115
204
|
}
|
|
116
205
|
}
|
|
206
|
+
/** An AWS SDK service error, which carries the HTTP status AgentCore answered. */
|
|
207
|
+
const awsServiceErrorSchema = z.object({
|
|
208
|
+
$metadata: z.object({ httpStatusCode: z.number().int() }),
|
|
209
|
+
});
|
|
117
210
|
/** A non-2xx answer from the local runtime, before any event streamed. */
|
|
118
211
|
export class BuilderRuntimeHttpError extends Error {
|
|
119
212
|
status;
|
|
@@ -121,18 +214,20 @@ export class BuilderRuntimeHttpError extends Error {
|
|
|
121
214
|
super(`Native builder runtime answered HTTP ${status}`);
|
|
122
215
|
this.status = status;
|
|
123
216
|
}
|
|
217
|
+
/** The HTTP status a local runtime or AgentCore failure carries, if any. */
|
|
218
|
+
static statusOf(error) {
|
|
219
|
+
if (error instanceof BuilderRuntimeHttpError)
|
|
220
|
+
return error.status;
|
|
221
|
+
return awsServiceErrorSchema.safeParse(error).data?.$metadata
|
|
222
|
+
.httpStatusCode;
|
|
223
|
+
}
|
|
124
224
|
}
|
|
125
225
|
/**
|
|
126
226
|
* The W3C trace context of `ctx` as invocation payload fields. Empty when no
|
|
127
227
|
* propagator is installed or `ctx` holds no span.
|
|
128
228
|
*/
|
|
129
229
|
export function invocationTraceContext(ctx = context.active()) {
|
|
130
|
-
|
|
131
|
-
propagation.inject(ctx, carrier);
|
|
132
|
-
return {
|
|
133
|
-
...(carrier.traceparent && { traceparent: carrier.traceparent }),
|
|
134
|
-
...(carrier.tracestate && { tracestate: carrier.tracestate }),
|
|
135
|
-
};
|
|
230
|
+
return OutboundTraceContext.fields(ctx);
|
|
136
231
|
}
|
|
137
232
|
/**
|
|
138
233
|
* AgentCore returned no session endpoint for `workspace.open`: the runtime is
|
|
@@ -146,25 +241,11 @@ export class WorkspaceEndpointMissingError extends Error {
|
|
|
146
241
|
this.name = "WorkspaceEndpointMissingError";
|
|
147
242
|
}
|
|
148
243
|
}
|
|
149
|
-
|
|
150
|
-
* The URL that reaches `port` in the VM. AgentCore returns the session
|
|
151
|
-
* endpoint without a port, and that bare host answers AccessDenied; each
|
|
152
|
-
* allowed port is addressed as `<port>--<host>`. A URL that already names a
|
|
153
|
-
* port is kept as it is.
|
|
154
|
-
*/
|
|
155
|
-
export function sessionEndpointForPort(sessionEndpointUrl, port) {
|
|
156
|
-
const url = new URL(sessionEndpointUrl);
|
|
157
|
-
if (!/^\d+--/.test(url.hostname))
|
|
158
|
-
url.hostname = `${port}--${url.hostname}`;
|
|
159
|
-
return url.origin;
|
|
160
|
-
}
|
|
244
|
+
export { sessionEndpointForPort } from "@superblocksteam/workspace-sync/control";
|
|
161
245
|
export class BuilderRuntime {
|
|
162
246
|
harness;
|
|
163
|
-
runtimeArn;
|
|
164
|
-
qualifier;
|
|
165
247
|
callback;
|
|
166
248
|
remoteEnvironment;
|
|
167
|
-
region;
|
|
168
249
|
localUrl;
|
|
169
250
|
localToken;
|
|
170
251
|
execution;
|
|
@@ -174,9 +255,7 @@ export class BuilderRuntime {
|
|
|
174
255
|
static configuredHarnesses(env) {
|
|
175
256
|
return ["codex", "claude_code"].filter((harness) => {
|
|
176
257
|
try {
|
|
177
|
-
|
|
178
|
-
runtime?.client?.destroy();
|
|
179
|
-
return runtime !== undefined;
|
|
258
|
+
return this.fromEnvironment(env, true, "", "/", harness) !== undefined;
|
|
180
259
|
}
|
|
181
260
|
catch {
|
|
182
261
|
return false;
|
|
@@ -188,26 +267,20 @@ export class BuilderRuntime {
|
|
|
188
267
|
get model() {
|
|
189
268
|
return this.selectedModel ?? NativeBuilderModel.resolve(this.harness);
|
|
190
269
|
}
|
|
191
|
-
|
|
192
|
-
constructor(harness, runtimeArn, qualifier, callback, remoteEnvironment, region, localUrl, localToken, execution,
|
|
270
|
+
constructor(harness, callback, remoteEnvironment, localUrl, localToken, execution,
|
|
193
271
|
/** Keys the workspace token; see {@link workspaceEdge}. */
|
|
194
272
|
workspaceSecret = "",
|
|
195
273
|
/** The local VM ingress, overriding the default next to `localUrl`. */
|
|
196
274
|
localWorkspaceUrl, selectedModel) {
|
|
197
275
|
this.harness = harness;
|
|
198
|
-
this.runtimeArn = runtimeArn;
|
|
199
|
-
this.qualifier = qualifier;
|
|
200
276
|
this.callback = callback;
|
|
201
277
|
this.remoteEnvironment = remoteEnvironment;
|
|
202
|
-
this.region = region;
|
|
203
278
|
this.localUrl = localUrl;
|
|
204
279
|
this.localToken = localToken;
|
|
205
280
|
this.execution = execution;
|
|
206
281
|
this.workspaceSecret = workspaceSecret;
|
|
207
282
|
this.localWorkspaceUrl = localWorkspaceUrl;
|
|
208
283
|
this.selectedModel = selectedModel;
|
|
209
|
-
if (!localUrl)
|
|
210
|
-
this.client = new BedrockAgentCoreClient({ region, maxAttempts: 1 });
|
|
211
284
|
}
|
|
212
285
|
static fromEnvironment(env, splitMode, applicationId, appRootDirPath, harness = env.SUPERBLOCKS_BUILDER_HARNESS ?? "clark", execution) {
|
|
213
286
|
if (harness === "clark")
|
|
@@ -217,6 +290,8 @@ export class BuilderRuntime {
|
|
|
217
290
|
if (!splitMode)
|
|
218
291
|
throw new Error("Native builder requires split live-edit mode");
|
|
219
292
|
const prefix = harness === "codex" ? "CODEX" : "CLAUDE";
|
|
293
|
+
// The runtime ARN only says the harness is on: the server invokes its own
|
|
294
|
+
// configured runtime, so this process never names one to AgentCore.
|
|
220
295
|
const runtimeArn = env[`SUPERBLOCKS_AGENTCORE_${prefix}_RUNTIME_ARN`] ?? "";
|
|
221
296
|
const match = /^arn:aws(?:-us-gov|-cn)?:bedrock-agentcore:([a-z0-9-]+):[0-9]{12}:runtime\/[A-Za-z][A-Za-z0-9_-]*$/.exec(runtimeArn);
|
|
222
297
|
let localUrl = env.SUPERBLOCKS_BUILDER_RUNTIME_URL;
|
|
@@ -247,7 +322,7 @@ export class BuilderRuntime {
|
|
|
247
322
|
throw new Error("Native builder requires an execution control token of at least 32 characters");
|
|
248
323
|
if (!appRootDirPath?.startsWith("/"))
|
|
249
324
|
throw new Error("Native builder requires an absolute application root");
|
|
250
|
-
return new BuilderRuntime(harness,
|
|
325
|
+
return new BuilderRuntime(harness, {
|
|
251
326
|
url: this.websocketUrl(env.SUPERBLOCKS_BUILDER_CALLBACK_URL, "/sb-updates", !!localUrl),
|
|
252
327
|
token: randomBytes(32).toString("hex"),
|
|
253
328
|
appId: applicationId,
|
|
@@ -257,13 +332,13 @@ export class BuilderRuntime {
|
|
|
257
332
|
: (env.SUPERBLOCKS_CLAUDE_TOOL_SERVER_URL ??
|
|
258
333
|
env.SUPERBLOCKS_CODEX_EXEC_SERVER_URL), "/sb-dev-exec", !!localUrl),
|
|
259
334
|
cwd: appRootDirPath,
|
|
260
|
-
},
|
|
335
|
+
}, localUrl, env.SUPERBLOCKS_BUILDER_RUNTIME_TOKEN, execution, env.SUPERBLOCKS_AGENT_TOOL_TOKEN, env.SUPERBLOCKS_BUILDER_WORKSPACE_URL || undefined);
|
|
261
336
|
}
|
|
262
337
|
withModel(preferredModel) {
|
|
263
338
|
const model = NativeBuilderModel.resolve(this.harness, preferredModel);
|
|
264
339
|
if (model === this.model)
|
|
265
340
|
return this;
|
|
266
|
-
return new BuilderRuntime(this.harness, this.
|
|
341
|
+
return new BuilderRuntime(this.harness, this.callback, this.remoteEnvironment, this.localUrl, this.localToken, this.execution, this.workspaceSecret, this.localWorkspaceUrl, model);
|
|
267
342
|
}
|
|
268
343
|
static isLoopback(url) {
|
|
269
344
|
return ["127.0.0.1", "localhost", "[::1]"].includes(url.hostname);
|
|
@@ -280,6 +355,32 @@ export class BuilderRuntime {
|
|
|
280
355
|
throw new Error(`Native builder requires a wss URL ending in ${pathname}`);
|
|
281
356
|
return url.toString();
|
|
282
357
|
}
|
|
358
|
+
/**
|
|
359
|
+
* A hidden control tool that mints a fresh credential for the runtime in the VM. When the
|
|
360
|
+
* mint finds the chat or branch changed, `onScopeChanged` receives the failure that stops the turn.
|
|
361
|
+
*/
|
|
362
|
+
credentialRenewalTool(credential, refresh, turnSignal, onScopeChanged) {
|
|
363
|
+
return tool({
|
|
364
|
+
inputSchema: z.object({}).strict(),
|
|
365
|
+
execute: async (_input, { abortSignal }) => {
|
|
366
|
+
if (!refresh)
|
|
367
|
+
throw new Error(`Native builder has no ${credential} refresh path`);
|
|
368
|
+
try {
|
|
369
|
+
const token = await refresh(abortSignal ?? turnSignal);
|
|
370
|
+
return { token: z.string().min(1).parse(token) };
|
|
371
|
+
}
|
|
372
|
+
catch (error) {
|
|
373
|
+
if (error instanceof BuilderInferenceAuthError)
|
|
374
|
+
onScopeChanged(new BuilderRuntimeError(error.code));
|
|
375
|
+
throw error;
|
|
376
|
+
}
|
|
377
|
+
},
|
|
378
|
+
toModelOutput: ({ output }) => ({
|
|
379
|
+
type: "json",
|
|
380
|
+
value: { token: output.token },
|
|
381
|
+
}),
|
|
382
|
+
});
|
|
383
|
+
}
|
|
283
384
|
providerFor(_model) {
|
|
284
385
|
return this.harness === "codex" ? "openai" : "anthropic";
|
|
285
386
|
}
|
|
@@ -288,34 +389,70 @@ export class BuilderRuntime {
|
|
|
288
389
|
throw new Error("Native model tools cannot use the reserved runtime namespace");
|
|
289
390
|
if (!options.inference?.token || !/^[a-f0-9]{64}$/.test(options.actorId))
|
|
290
391
|
throw new Error("Native builder requires scoped inference credentials and actor identity");
|
|
392
|
+
if (!options.skills?.token)
|
|
393
|
+
throw new Error("Native builder requires Skills credentials");
|
|
291
394
|
const inferenceUrl = new URL(options.inference.url);
|
|
292
|
-
|
|
395
|
+
const skillsUrl = new URL(options.skills.url);
|
|
396
|
+
const isValidProxyUrl = (url) => (url.protocol === "https:" ||
|
|
293
397
|
(this.localUrl &&
|
|
294
|
-
|
|
295
|
-
BuilderRuntime.isLoopback(
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
398
|
+
url.protocol === "http:" &&
|
|
399
|
+
BuilderRuntime.isLoopback(url))) &&
|
|
400
|
+
!url.username &&
|
|
401
|
+
!url.password &&
|
|
402
|
+
!url.search &&
|
|
403
|
+
!url.hash;
|
|
404
|
+
if (!isValidProxyUrl(inferenceUrl))
|
|
300
405
|
throw new Error("Invalid native inference proxy URL");
|
|
406
|
+
if (!isValidProxyUrl(skillsUrl))
|
|
407
|
+
throw new Error("Invalid native Skills proxy URL");
|
|
301
408
|
// A workspace turn's tools run in the VM, not on a remote environment,
|
|
302
409
|
// so there is no DEV execution to authorize.
|
|
303
410
|
const execution = options.workspaceLocal ? undefined : this.execution;
|
|
304
411
|
if (!execution && !options.workspaceLocal)
|
|
305
412
|
throw new Error("Native builder requires DEV execution authorization");
|
|
306
413
|
const callbacks = new NativeCallbackOrder();
|
|
414
|
+
let restoredAttachments;
|
|
307
415
|
const callbackResults = new Map();
|
|
308
416
|
let inferenceFailure;
|
|
417
|
+
let skillsFailure;
|
|
309
418
|
const closeTools = this.toolHost.register({
|
|
310
419
|
traceContext: options.traceContext,
|
|
311
420
|
runId: options.runId,
|
|
312
421
|
concurrentTools: new Set([
|
|
313
422
|
...(options.concurrentTools ?? []),
|
|
314
423
|
"__runtime_redact",
|
|
424
|
+
"__runtime_skills_token",
|
|
425
|
+
"__runtime_inference_token",
|
|
315
426
|
]),
|
|
316
427
|
tools: {
|
|
317
428
|
...options.tools,
|
|
318
429
|
...options.callbackTools,
|
|
430
|
+
__runtime_attachment: tool({
|
|
431
|
+
inputSchema: z
|
|
432
|
+
.object({
|
|
433
|
+
index: z.number().int().nonnegative().optional(),
|
|
434
|
+
offset: z.number().int().nonnegative().optional(),
|
|
435
|
+
history: z.boolean().optional(),
|
|
436
|
+
})
|
|
437
|
+
.strict(),
|
|
438
|
+
execute: async ({ index, offset, history }) => {
|
|
439
|
+
const files = history
|
|
440
|
+
? await (restoredAttachments ??=
|
|
441
|
+
options.restoreAttachments?.() ?? Promise.resolve([]))
|
|
442
|
+
: (options.attachments ?? []);
|
|
443
|
+
if (index === undefined)
|
|
444
|
+
return { count: files.length };
|
|
445
|
+
const file = files[index];
|
|
446
|
+
if (!file || offset === undefined || offset > file.bytes.byteLength)
|
|
447
|
+
throw new Error("Attachment is unavailable");
|
|
448
|
+
return {
|
|
449
|
+
fileName: file.fileName,
|
|
450
|
+
mimeType: file.mimeType,
|
|
451
|
+
sizeBytes: file.bytes.byteLength,
|
|
452
|
+
data: Buffer.from(file.bytes.subarray(offset, offset + 256 * 1024)).toString("base64"),
|
|
453
|
+
};
|
|
454
|
+
},
|
|
455
|
+
}),
|
|
319
456
|
__runtime_redact: tool({
|
|
320
457
|
inputSchema: z
|
|
321
458
|
.object({
|
|
@@ -354,6 +491,12 @@ export class BuilderRuntime {
|
|
|
354
491
|
}),
|
|
355
492
|
}),
|
|
356
493
|
}),
|
|
494
|
+
__runtime_skills_token: this.credentialRenewalTool("Skills", options.refreshSkills?.bind(options), options.signal, (failure) => {
|
|
495
|
+
skillsFailure = failure;
|
|
496
|
+
}),
|
|
497
|
+
__runtime_inference_token: this.credentialRenewalTool("inference", options.refreshInference?.bind(options), options.signal, (failure) => {
|
|
498
|
+
inferenceFailure = failure;
|
|
499
|
+
}),
|
|
357
500
|
},
|
|
358
501
|
messages: [],
|
|
359
502
|
signal: options.signal,
|
|
@@ -374,7 +517,8 @@ export class BuilderRuntime {
|
|
|
374
517
|
}
|
|
375
518
|
const stopReason = movesEditor(result.output)
|
|
376
519
|
? "branch_navigation"
|
|
377
|
-
: result.toolName
|
|
520
|
+
: (INFERENCE_AUTH_CALLS.has(result.toolName) && inferenceFailure) ||
|
|
521
|
+
(result.toolName === "__runtime_skills_token" && skillsFailure)
|
|
378
522
|
? "inference_auth_failure"
|
|
379
523
|
: undefined;
|
|
380
524
|
if (stopReason)
|
|
@@ -386,6 +530,7 @@ export class BuilderRuntime {
|
|
|
386
530
|
});
|
|
387
531
|
let mustRevoke = false;
|
|
388
532
|
let failure;
|
|
533
|
+
let invoked = false;
|
|
389
534
|
try {
|
|
390
535
|
options.signal.throwIfAborted();
|
|
391
536
|
mustRevoke = !!execution;
|
|
@@ -396,19 +541,29 @@ export class BuilderRuntime {
|
|
|
396
541
|
name,
|
|
397
542
|
description: tool.description ?? "",
|
|
398
543
|
inputSchema: await asSchema(tool.inputSchema).jsonSchema,
|
|
544
|
+
...(options.concurrentTools?.has(name) && { readOnly: true }),
|
|
399
545
|
})));
|
|
400
546
|
const payload = JSON.stringify({
|
|
401
547
|
provider: this.providerFor(this.model),
|
|
402
548
|
model: this.model,
|
|
403
549
|
mode: options.mode ?? "build",
|
|
404
550
|
prompt: options.prompt,
|
|
551
|
+
...(options.attachments?.length && {
|
|
552
|
+
attachmentCount: options.attachments.length,
|
|
553
|
+
}),
|
|
405
554
|
system: options.system,
|
|
406
555
|
tools,
|
|
407
|
-
capabilities: {
|
|
556
|
+
capabilities: {
|
|
557
|
+
planMessages: true,
|
|
558
|
+
orderedCallbacks: true,
|
|
559
|
+
...(options.restoreAttachments && { attachmentHistory: true }),
|
|
560
|
+
},
|
|
408
561
|
conversationId: options.conversationId,
|
|
409
562
|
actorId: options.actorId,
|
|
563
|
+
...(options.ownerId && { ownerId: options.ownerId }),
|
|
410
564
|
sessionId: options.sessionId,
|
|
411
565
|
inference: options.inference,
|
|
566
|
+
skills: options.skills,
|
|
412
567
|
callback: { ...this.callback, runId: options.runId },
|
|
413
568
|
...(options.workspaceLocal
|
|
414
569
|
? { workspace: { local: true } }
|
|
@@ -419,24 +574,33 @@ export class BuilderRuntime {
|
|
|
419
574
|
});
|
|
420
575
|
const body = await this.invokeRaw({
|
|
421
576
|
payload,
|
|
422
|
-
|
|
577
|
+
session: options.workspaceSessionKey ? "workspace" : "chat",
|
|
578
|
+
access: options.access,
|
|
423
579
|
signal: options.signal,
|
|
424
580
|
});
|
|
581
|
+
invoked = true;
|
|
425
582
|
await this.consume(body, {
|
|
426
583
|
...options,
|
|
427
584
|
onEvent: (event) => {
|
|
428
585
|
if (inferenceFailure)
|
|
429
586
|
throw inferenceFailure;
|
|
587
|
+
if (skillsFailure)
|
|
588
|
+
throw skillsFailure;
|
|
430
589
|
return options.onEvent(event);
|
|
431
590
|
},
|
|
432
591
|
}, callbacks, callbackResults);
|
|
433
592
|
if (inferenceFailure)
|
|
434
593
|
throw inferenceFailure;
|
|
594
|
+
if (skillsFailure)
|
|
595
|
+
throw skillsFailure;
|
|
435
596
|
}
|
|
436
597
|
catch (error) {
|
|
437
|
-
failure = { error: inferenceFailure ?? error };
|
|
598
|
+
failure = { error: inferenceFailure ?? skillsFailure ?? error };
|
|
438
599
|
}
|
|
439
600
|
finally {
|
|
601
|
+
// Before the tools close, so the VM stops instead of failing its next callback.
|
|
602
|
+
if (invoked && options.signal.aborted)
|
|
603
|
+
await this.cancelTurn(options);
|
|
440
604
|
closeTools();
|
|
441
605
|
callbackResults.clear();
|
|
442
606
|
}
|
|
@@ -451,6 +615,30 @@ export class BuilderRuntime {
|
|
|
451
615
|
if (failure)
|
|
452
616
|
throw failure.error;
|
|
453
617
|
}
|
|
618
|
+
/**
|
|
619
|
+
* Tells the VM to stop run `runId`. AgentCore keeps an invocation running
|
|
620
|
+
* after its caller hangs up, so aborting our stream alone leaves the turn
|
|
621
|
+
* going. Best effort: a runtime without `turn.cancel` answers 422.
|
|
622
|
+
*/
|
|
623
|
+
async cancelTurn(options) {
|
|
624
|
+
try {
|
|
625
|
+
const body = await this.invokeRaw({
|
|
626
|
+
payload: JSON.stringify({
|
|
627
|
+
kind: "turn.cancel",
|
|
628
|
+
provider: this.providerFor(this.model),
|
|
629
|
+
runId: options.runId,
|
|
630
|
+
actorId: options.actorId,
|
|
631
|
+
}),
|
|
632
|
+
session: options.workspaceSessionKey ? "workspace" : "chat",
|
|
633
|
+
access: options.access,
|
|
634
|
+
signal: AbortSignal.timeout(5_000),
|
|
635
|
+
});
|
|
636
|
+
await body[Symbol.asyncIterator]().return?.();
|
|
637
|
+
}
|
|
638
|
+
catch {
|
|
639
|
+
// The turn still ends when the VM's next callback finds the run closed.
|
|
640
|
+
}
|
|
641
|
+
}
|
|
454
642
|
/**
|
|
455
643
|
* The workspace edge's base URL (no path) and the token the VM presents to
|
|
456
644
|
* it and accepts from it, for one workspace session. The edge is the
|
|
@@ -473,15 +661,17 @@ export class BuilderRuntime {
|
|
|
473
661
|
}
|
|
474
662
|
/**
|
|
475
663
|
* Posts a `workspace.open` payload and resolves where the VM's ingress is
|
|
476
|
-
* reachable: AgentCore
|
|
664
|
+
* reachable: the AgentCore session endpoint the server opened, with the
|
|
665
|
+
* grant the edge presents to the server for each signature, or for the local
|
|
477
666
|
* transport `SUPERBLOCKS_BUILDER_WORKSPACE_URL`, else the ingress port on
|
|
478
667
|
* the local runtime's host. Throws {@link WorkspaceEndpointMissingError}
|
|
479
|
-
* when AgentCore
|
|
668
|
+
* when AgentCore returned no session endpoint.
|
|
480
669
|
*/
|
|
481
|
-
async invokeWorkspaceOpen({ payload, sessionKey, signal, }) {
|
|
482
|
-
const { body,
|
|
670
|
+
async invokeWorkspaceOpen({ payload, sessionKey, access, signal, }) {
|
|
671
|
+
const { body, endpoint } = await this.send({
|
|
483
672
|
payload,
|
|
484
|
-
|
|
673
|
+
session: "workspace",
|
|
674
|
+
access,
|
|
485
675
|
signal,
|
|
486
676
|
});
|
|
487
677
|
if (this.localUrl)
|
|
@@ -494,7 +684,7 @@ export class BuilderRuntime {
|
|
|
494
684
|
sessionKey,
|
|
495
685
|
}),
|
|
496
686
|
};
|
|
497
|
-
if (!
|
|
687
|
+
if (!endpoint || !access) {
|
|
498
688
|
void body[Symbol.asyncIterator]()
|
|
499
689
|
.return?.()
|
|
500
690
|
.catch(() => { });
|
|
@@ -504,16 +694,26 @@ export class BuilderRuntime {
|
|
|
504
694
|
body,
|
|
505
695
|
endpoint: workspaceEndpointSchema.parse({
|
|
506
696
|
auth: "sigv4",
|
|
507
|
-
url:
|
|
508
|
-
region:
|
|
697
|
+
url: endpoint.url,
|
|
698
|
+
region: endpoint.region,
|
|
509
699
|
sessionKey,
|
|
700
|
+
signer: {
|
|
701
|
+
url: new URL(BUILDER_RUNTIME_SIGN_PATH, access.serverUrl).toString(),
|
|
702
|
+
grant: endpoint.grant,
|
|
703
|
+
},
|
|
510
704
|
}),
|
|
511
705
|
};
|
|
512
706
|
}
|
|
513
707
|
async invokeRaw(options) {
|
|
514
708
|
return (await this.send(options)).body;
|
|
515
709
|
}
|
|
516
|
-
|
|
710
|
+
/**
|
|
711
|
+
* Sends one invocation: to the local runtime in development, otherwise to
|
|
712
|
+
* the Superblocks server, which picks the runtime and the runtime session
|
|
713
|
+
* (`session` only says which of the token's two it is) and invokes AgentCore
|
|
714
|
+
* with its own credentials. This process holds none.
|
|
715
|
+
*/
|
|
716
|
+
async send({ payload, session, access, signal, }) {
|
|
517
717
|
if (this.localUrl) {
|
|
518
718
|
const response = await fetch(this.localUrl, {
|
|
519
719
|
method: "POST",
|
|
@@ -526,31 +726,53 @@ export class BuilderRuntime {
|
|
|
526
726
|
},
|
|
527
727
|
body: payload,
|
|
528
728
|
});
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
|
|
729
|
+
return { body: await BuilderRuntime.eventStream(response) };
|
|
730
|
+
}
|
|
731
|
+
if (!access)
|
|
732
|
+
throw new Error("The native builder runtime needs server access");
|
|
733
|
+
for (let attempt = 0;; attempt++) {
|
|
734
|
+
const response = await fetch(new URL(BUILDER_RUNTIME_INVOCATIONS_PATH, access.serverUrl), {
|
|
735
|
+
method: "POST",
|
|
736
|
+
redirect: "error",
|
|
737
|
+
signal,
|
|
738
|
+
headers: {
|
|
739
|
+
Authorization: `Bearer ${await access.token(signal, { refresh: attempt > 0 })}`,
|
|
740
|
+
"Content-Type": "application/json",
|
|
741
|
+
Accept: "text/event-stream",
|
|
742
|
+
[BUILDER_RUNTIME_SESSION_HEADER]: session,
|
|
743
|
+
},
|
|
744
|
+
body: payload,
|
|
745
|
+
});
|
|
746
|
+
// A lapsed or revoked token: one more try with a new one.
|
|
747
|
+
if (response.status === 401 && attempt === 0) {
|
|
535
748
|
await response.body?.cancel();
|
|
536
|
-
|
|
749
|
+
continue;
|
|
537
750
|
}
|
|
538
|
-
|
|
751
|
+
const body = await BuilderRuntime.eventStream(response);
|
|
752
|
+
const endpointHeader = response.headers.get(BUILDER_RUNTIME_ENDPOINT_HEADER);
|
|
753
|
+
const grant = response.headers.get(BUILDER_RUNTIME_SIGN_GRANT_HEADER);
|
|
754
|
+
const endpoint = endpointHeader && grant
|
|
755
|
+
? builderRuntimeEndpointHeaderSchema.safeParse(JSON.parse(endpointHeader))
|
|
756
|
+
: undefined;
|
|
757
|
+
return {
|
|
758
|
+
body,
|
|
759
|
+
...(endpoint?.success &&
|
|
760
|
+
grant && { endpoint: { ...endpoint.data, grant } }),
|
|
761
|
+
};
|
|
539
762
|
}
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
|
|
544
|
-
|
|
545
|
-
|
|
546
|
-
|
|
547
|
-
|
|
548
|
-
|
|
763
|
+
}
|
|
764
|
+
/** The event-stream body of a runtime answer; throws on anything else. */
|
|
765
|
+
static async eventStream(response) {
|
|
766
|
+
if (!response.ok) {
|
|
767
|
+
await response.body?.cancel();
|
|
768
|
+
throw new BuilderRuntimeHttpError(response.status);
|
|
769
|
+
}
|
|
770
|
+
if (!response.body ||
|
|
771
|
+
!response.headers.get("content-type")?.includes("text/event-stream")) {
|
|
772
|
+
await response.body?.cancel();
|
|
549
773
|
throw new Error("Native builder returned an invalid response");
|
|
550
|
-
|
|
551
|
-
|
|
552
|
-
sessionEndpointUrl: result.sessionEndpointUrl,
|
|
553
|
-
};
|
|
774
|
+
}
|
|
775
|
+
return response.body;
|
|
554
776
|
}
|
|
555
777
|
/**
|
|
556
778
|
* Reads validated SSE events from a runtime body, ending after `finish`.
|
|
@@ -602,29 +824,53 @@ export class BuilderRuntime {
|
|
|
602
824
|
}
|
|
603
825
|
}
|
|
604
826
|
async consume(body, options, callbacks, callbackResults) {
|
|
605
|
-
|
|
606
|
-
|
|
607
|
-
|
|
608
|
-
|
|
609
|
-
event.
|
|
610
|
-
|
|
611
|
-
|
|
612
|
-
|
|
613
|
-
|
|
614
|
-
|
|
827
|
+
let failure;
|
|
828
|
+
const cleanup = new BuilderFailureDrain(options.signal);
|
|
829
|
+
try {
|
|
830
|
+
for await (const event of BuilderRuntime.readEvents(body, cleanup.signal)) {
|
|
831
|
+
if (event.type === "error" && !failure) {
|
|
832
|
+
failure = new BuilderRuntimeError(event.code ?? "INVOCATION_FAILED", event.reason, event.beforeTurn === true, event.runSubmitted === true);
|
|
833
|
+
cleanup.start();
|
|
834
|
+
}
|
|
835
|
+
// A finish confirms the runtime released its run before another invocation.
|
|
836
|
+
if (failure && event.type === "finish")
|
|
837
|
+
cleanup.finish();
|
|
838
|
+
if (failure)
|
|
839
|
+
continue;
|
|
840
|
+
await this.forwardEvent(event, options, callbacks, callbackResults);
|
|
841
|
+
}
|
|
842
|
+
}
|
|
843
|
+
catch (error) {
|
|
844
|
+
if (!failure || options.signal.aborted)
|
|
845
|
+
throw error;
|
|
846
|
+
throw failure.withUnconfirmedCleanup(cleanup.outcome);
|
|
847
|
+
}
|
|
848
|
+
finally {
|
|
849
|
+
cleanup.close();
|
|
850
|
+
}
|
|
851
|
+
if (failure)
|
|
852
|
+
throw failure;
|
|
853
|
+
}
|
|
854
|
+
async forwardEvent(event, options, callbacks, callbackResults) {
|
|
855
|
+
if ((event.type === "tool-call" || event.type === "tool-result") &&
|
|
856
|
+
event.toolName.startsWith("__runtime_"))
|
|
857
|
+
return;
|
|
858
|
+
if (event.type === "tool-result" &&
|
|
859
|
+
callbackResults.get(event.toolCallId) === event.toolName)
|
|
860
|
+
return;
|
|
861
|
+
await options.onEvent(event.type === "tool-call"
|
|
862
|
+
? {
|
|
863
|
+
...event,
|
|
864
|
+
input: await this.secrets.redact(event.input, options.signal),
|
|
865
|
+
}
|
|
866
|
+
: event.type === "tool-result"
|
|
615
867
|
? {
|
|
616
868
|
...event,
|
|
617
|
-
|
|
869
|
+
output: await this.secrets.redact(event.output, options.signal),
|
|
618
870
|
}
|
|
619
|
-
: event
|
|
620
|
-
|
|
621
|
-
|
|
622
|
-
output: await this.secrets.redact(event.output, options.signal),
|
|
623
|
-
}
|
|
624
|
-
: event);
|
|
625
|
-
if (event.type === "tool-call")
|
|
626
|
-
callbacks.arrive(event.toolCallId);
|
|
627
|
-
}
|
|
871
|
+
: event);
|
|
872
|
+
if (event.type === "tool-call")
|
|
873
|
+
callbacks.arrive(event.toolCallId);
|
|
628
874
|
}
|
|
629
875
|
}
|
|
630
876
|
//# sourceMappingURL=builder-runtime.js.map
|