@superblocksteam/vite-plugin-file-sync 2.0.183 → 2.0.185-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-file-tools.d.ts +10 -72
- package/dist/agent-tool-executor/claude-file-tools.d.ts.map +1 -1
- package/dist/agent-tool-executor/claude-sandbox.d.ts +1 -15
- package/dist/agent-tool-executor/claude-sandbox.d.ts.map +1 -1
- package/dist/agent-tool-executor/claude-shell.d.ts +4 -36
- package/dist/agent-tool-executor/claude-shell.d.ts.map +1 -1
- package/dist/agent-tool-executor/claude-tool-server.js +2 -2
- package/dist/agent-tool-executor/claude-tool-server.js.map +1 -1
- package/dist/agent-tool-executor/codex-exec-server.d.ts.map +1 -1
- package/dist/agent-tool-executor/codex-exec-server.js +6 -4
- package/dist/agent-tool-executor/codex-exec-server.js.map +1 -1
- package/dist/agent-tool-executor/codex-execution-policy.js +2 -2
- package/dist/agent-tool-executor/codex-execution-policy.js.map +1 -1
- package/dist/agent-tool-executor/native-draft-service.d.ts +5 -2
- package/dist/agent-tool-executor/native-draft-service.d.ts.map +1 -1
- package/dist/agent-tool-executor/native-tool-environment.js +1 -1
- package/dist/agent-tool-executor/native-tool-environment.js.map +1 -1
- package/dist/ai-service/agent/prompts/build-base-system-prompt.d.ts +2 -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 +9 -2
- package/dist/ai-service/agent/prompts/build-base-system-prompt.js.map +1 -1
- package/dist/ai-service/agent/tools/apis/analysis.d.ts.map +1 -1
- package/dist/ai-service/agent/tools/apis/analysis.js +36 -67
- package/dist/ai-service/agent/tools/apis/analysis.js.map +1 -1
- package/dist/ai-service/agent/tools/apis/api-executor.d.ts +1 -0
- package/dist/ai-service/agent/tools/apis/api-executor.d.ts.map +1 -1
- package/dist/ai-service/agent/tools/apis/api-executor.js +1 -0
- package/dist/ai-service/agent/tools/apis/api-executor.js.map +1 -1
- package/dist/ai-service/agent/tools/apis/api-validation-orchestrator.d.ts +2 -0
- package/dist/ai-service/agent/tools/apis/api-validation-orchestrator.d.ts.map +1 -1
- package/dist/ai-service/agent/tools/apis/api-validation-orchestrator.js +1 -0
- package/dist/ai-service/agent/tools/apis/api-validation-orchestrator.js.map +1 -1
- package/dist/ai-service/agent/tools/apis/test-api.d.ts +22 -1
- package/dist/ai-service/agent/tools/apis/test-api.d.ts.map +1 -1
- package/dist/ai-service/agent/tools/apis/test-api.js +115 -65
- 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 -2
- package/dist/ai-service/agent/tools/branching/branch-tools.d.ts.map +1 -1
- package/dist/ai-service/agent/tools/branching/branch-tools.js +1 -1
- package/dist/ai-service/agent/tools/branching/branch-tools.js.map +1 -1
- package/dist/ai-service/agent/tools/build-copy-utils.d.ts +13 -44
- package/dist/ai-service/agent/tools/build-copy-utils.d.ts.map +1 -1
- package/dist/ai-service/agent/tools/build-debug.d.ts +1 -1
- package/dist/ai-service/agent/tools/build-debug.d.ts.map +1 -1
- package/dist/ai-service/agent/tools/build-delete-file.d.ts +1 -0
- package/dist/ai-service/agent/tools/build-delete-file.d.ts.map +1 -1
- package/dist/ai-service/agent/tools/build-delete-file.js +3 -0
- package/dist/ai-service/agent/tools/build-delete-file.js.map +1 -1
- package/dist/ai-service/agent/tools/build-edit-file.d.ts +2 -0
- package/dist/ai-service/agent/tools/build-edit-file.d.ts.map +1 -1
- package/dist/ai-service/agent/tools/build-edit-file.js +7 -0
- package/dist/ai-service/agent/tools/build-edit-file.js.map +1 -1
- package/dist/ai-service/agent/tools/build-install-packages.d.ts.map +1 -1
- package/dist/ai-service/agent/tools/build-install-packages.js +5 -1
- package/dist/ai-service/agent/tools/build-install-packages.js.map +1 -1
- package/dist/ai-service/agent/tools/build-list-files.d.ts +1 -1
- package/dist/ai-service/agent/tools/build-multi-edit-file.d.ts +1 -0
- package/dist/ai-service/agent/tools/build-multi-edit-file.d.ts.map +1 -1
- package/dist/ai-service/agent/tools/build-multi-edit-file.js +3 -0
- package/dist/ai-service/agent/tools/build-multi-edit-file.js.map +1 -1
- package/dist/ai-service/agent/tools/build-navigate-preview.js +2 -2
- package/dist/ai-service/agent/tools/build-navigate-preview.js.map +1 -1
- package/dist/ai-service/agent/tools/build-write-file.d.ts +1 -0
- package/dist/ai-service/agent/tools/build-write-file.d.ts.map +1 -1
- package/dist/ai-service/agent/tools/build-write-file.js +3 -0
- package/dist/ai-service/agent/tools/build-write-file.js.map +1 -1
- package/dist/ai-service/agent/tools/clear-error-cache.d.ts +1 -1
- package/dist/ai-service/agent/tools/databases/dev-database-tasks.d.ts +39 -185
- package/dist/ai-service/agent/tools/databases/dev-database-tasks.d.ts.map +1 -1
- package/dist/ai-service/agent/tools/databases/dev-database-tasks.js +35 -13
- package/dist/ai-service/agent/tools/databases/dev-database-tasks.js.map +1 -1
- package/dist/ai-service/agent/tools/databases/dev-database-tools.d.ts +2 -2
- package/dist/ai-service/agent/tools/get-security-findings.d.ts +1 -1
- package/dist/ai-service/agent/tools/integrations/execute-request.d.ts +71 -268
- package/dist/ai-service/agent/tools/integrations/execute-request.d.ts.map +1 -1
- package/dist/ai-service/agent/tools/integrations/execute-request.js +20 -11
- package/dist/ai-service/agent/tools/integrations/execute-request.js.map +1 -1
- package/dist/ai-service/agent/tools/integrations/index.d.ts +1 -1
- package/dist/ai-service/agent/tools/integrations/index.d.ts.map +1 -1
- package/dist/ai-service/agent/tools/integrations/index.js +1 -1
- package/dist/ai-service/agent/tools/integrations/index.js.map +1 -1
- package/dist/ai-service/agent/tools/integrations/integration-setup.d.ts +2 -2
- package/dist/ai-service/agent/tools/integrations/integration-setup.js +3 -3
- package/dist/ai-service/agent/tools/integrations/integration-setup.js.map +1 -1
- package/dist/ai-service/agent/tools/integrations/internal.d.ts +14 -2
- package/dist/ai-service/agent/tools/integrations/internal.d.ts.map +1 -1
- package/dist/ai-service/agent/tools/integrations/internal.js +5 -2
- package/dist/ai-service/agent/tools/integrations/internal.js.map +1 -1
- package/dist/ai-service/agent/tools/project-agent-feedback.d.ts +17 -0
- package/dist/ai-service/agent/tools/project-agent-feedback.d.ts.map +1 -0
- package/dist/ai-service/agent/tools/project-agent-feedback.js +87 -0
- package/dist/ai-service/agent/tools/project-agent-feedback.js.map +1 -0
- package/dist/ai-service/agent/tools/report-security-findings.d.ts +25 -112
- package/dist/ai-service/agent/tools/report-security-findings.d.ts.map +1 -1
- package/dist/ai-service/agent/tools.d.ts.map +1 -1
- package/dist/ai-service/agent/tools.js +1 -0
- package/dist/ai-service/agent/tools.js.map +1 -1
- package/dist/ai-service/agent/tools2/access-control.d.ts +6 -0
- package/dist/ai-service/agent/tools2/access-control.d.ts.map +1 -1
- package/dist/ai-service/agent/tools2/access-control.js +16 -10
- package/dist/ai-service/agent/tools2/access-control.js.map +1 -1
- package/dist/ai-service/agent/tools2/registry.d.ts +4 -2
- package/dist/ai-service/agent/tools2/registry.d.ts.map +1 -1
- package/dist/ai-service/agent/tools2/registry.js +21 -9
- package/dist/ai-service/agent/tools2/registry.js.map +1 -1
- package/dist/ai-service/agent/tools2/tool-execution-scope.d.ts +10 -0
- package/dist/ai-service/agent/tools2/tool-execution-scope.d.ts.map +1 -0
- package/dist/ai-service/agent/tools2/tool-execution-scope.js +21 -0
- package/dist/ai-service/agent/tools2/tool-execution-scope.js.map +1 -0
- package/dist/ai-service/agent/tools2/tools/end-test-run.d.ts +1 -1
- package/dist/ai-service/agent/tools2/tools/list-tasks.d.ts +1 -1
- package/dist/ai-service/agent/tools2/types.d.ts +1 -1
- package/dist/ai-service/agent/tools2/types.d.ts.map +1 -1
- package/dist/ai-service/agent/tools2/types.js.map +1 -1
- package/dist/ai-service/app-interface/invalid-lockfile-error.d.ts +11 -0
- package/dist/ai-service/app-interface/invalid-lockfile-error.d.ts.map +1 -0
- package/dist/ai-service/app-interface/invalid-lockfile-error.js +27 -0
- package/dist/ai-service/app-interface/invalid-lockfile-error.js.map +1 -0
- package/dist/ai-service/app-interface/npm-lockfile-sources.d.ts +13 -0
- package/dist/ai-service/app-interface/npm-lockfile-sources.d.ts.map +1 -0
- package/dist/ai-service/app-interface/npm-lockfile-sources.js +129 -0
- package/dist/ai-service/app-interface/npm-lockfile-sources.js.map +1 -0
- package/dist/ai-service/app-interface/npm-registry.d.ts +20 -10
- package/dist/ai-service/app-interface/npm-registry.d.ts.map +1 -1
- package/dist/ai-service/app-interface/npm-registry.js +109 -73
- package/dist/ai-service/app-interface/npm-registry.js.map +1 -1
- package/dist/ai-service/app-interface/registry-lockfile-preparer.d.ts +46 -0
- package/dist/ai-service/app-interface/registry-lockfile-preparer.d.ts.map +1 -0
- package/dist/ai-service/app-interface/registry-lockfile-preparer.js +88 -0
- package/dist/ai-service/app-interface/registry-lockfile-preparer.js.map +1 -0
- package/dist/ai-service/app-interface/shell.d.ts +14 -4
- package/dist/ai-service/app-interface/shell.d.ts.map +1 -1
- package/dist/ai-service/app-interface/shell.js +45 -30
- package/dist/ai-service/app-interface/shell.js.map +1 -1
- package/dist/ai-service/attachments/validate-prompt-attachments.d.ts.map +1 -1
- package/dist/ai-service/attachments/validate-prompt-attachments.js +12 -2
- package/dist/ai-service/attachments/validate-prompt-attachments.js.map +1 -1
- package/dist/ai-service/builder-binding-error.d.ts +5 -0
- package/dist/ai-service/builder-binding-error.d.ts.map +1 -0
- package/dist/ai-service/builder-binding-error.js +8 -0
- package/dist/ai-service/builder-binding-error.js.map +1 -0
- package/dist/ai-service/builder-conversation.d.ts +71 -6
- package/dist/ai-service/builder-conversation.d.ts.map +1 -1
- package/dist/ai-service/builder-conversation.js +549 -83
- package/dist/ai-service/builder-conversation.js.map +1 -1
- package/dist/ai-service/builder-core-prompt.d.ts +3 -3
- package/dist/ai-service/builder-core-prompt.d.ts.map +1 -1
- package/dist/ai-service/builder-core-prompt.js +22 -34
- package/dist/ai-service/builder-core-prompt.js.map +1 -1
- package/dist/ai-service/builder-runtime-auth.d.ts.map +1 -1
- package/dist/ai-service/builder-runtime-auth.js +6 -2
- package/dist/ai-service/builder-runtime-auth.js.map +1 -1
- package/dist/ai-service/builder-runtime.d.ts +105 -240
- package/dist/ai-service/builder-runtime.d.ts.map +1 -1
- package/dist/ai-service/builder-runtime.js +391 -77
- package/dist/ai-service/builder-runtime.js.map +1 -1
- package/dist/ai-service/builder-session-store.d.ts +1 -7
- package/dist/ai-service/builder-session-store.d.ts.map +1 -1
- package/dist/ai-service/builder-session-store.js +1 -1
- package/dist/ai-service/builder-session-store.js.map +1 -1
- package/dist/ai-service/builder-tool-callbacks.d.ts +19 -0
- package/dist/ai-service/builder-tool-callbacks.d.ts.map +1 -1
- package/dist/ai-service/builder-tool-callbacks.js +151 -31
- package/dist/ai-service/builder-tool-callbacks.js.map +1 -1
- package/dist/ai-service/builder-tools.d.ts +28 -5
- package/dist/ai-service/builder-tools.d.ts.map +1 -1
- package/dist/ai-service/builder-tools.js +214 -45
- package/dist/ai-service/builder-tools.js.map +1 -1
- package/dist/ai-service/builder-workspace.d.ts +1 -0
- package/dist/ai-service/builder-workspace.d.ts.map +1 -1
- package/dist/ai-service/builder-workspace.js +15 -6
- package/dist/ai-service/builder-workspace.js.map +1 -1
- package/dist/ai-service/chat/chat-session-store.d.ts +2 -2
- package/dist/ai-service/chat/chat-session-store.d.ts.map +1 -1
- package/dist/ai-service/chat/chat-session-store.js +25 -8
- package/dist/ai-service/chat/chat-session-store.js.map +1 -1
- package/dist/ai-service/demo-agents/handlers.d.ts +11 -24
- package/dist/ai-service/demo-agents/handlers.d.ts.map +1 -1
- package/dist/ai-service/demo-agents/handlers.js +19 -30
- package/dist/ai-service/demo-agents/handlers.js.map +1 -1
- package/dist/ai-service/demo-agents/load-agents.d.ts +9 -2
- package/dist/ai-service/demo-agents/load-agents.d.ts.map +1 -1
- package/dist/ai-service/demo-agents/load-agents.js +50 -49
- package/dist/ai-service/demo-agents/load-agents.js.map +1 -1
- package/dist/ai-service/demo-agents/run-agent.d.ts.map +1 -1
- package/dist/ai-service/demo-agents/run-agent.js +50 -5
- package/dist/ai-service/demo-agents/run-agent.js.map +1 -1
- package/dist/ai-service/demo-agents/system-prompt.d.ts +6 -5
- package/dist/ai-service/demo-agents/system-prompt.d.ts.map +1 -1
- package/dist/ai-service/demo-agents/system-prompt.js +18 -26
- package/dist/ai-service/demo-agents/system-prompt.js.map +1 -1
- package/dist/ai-service/demo-agents/types.d.ts +9 -56
- package/dist/ai-service/demo-agents/types.d.ts.map +1 -1
- package/dist/ai-service/demo-agents/types.js +0 -7
- package/dist/ai-service/demo-agents/types.js.map +1 -1
- package/dist/ai-service/dev-database-file-sync.d.ts +2 -1
- package/dist/ai-service/dev-database-file-sync.d.ts.map +1 -1
- package/dist/ai-service/dev-database-file-sync.js.map +1 -1
- package/dist/ai-service/features.d.ts +20 -8
- package/dist/ai-service/features.d.ts.map +1 -1
- package/dist/ai-service/index.d.ts +107 -15
- package/dist/ai-service/index.d.ts.map +1 -1
- package/dist/ai-service/index.js +588 -139
- 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/judge/tools/playwright-action.d.ts.map +1 -1
- package/dist/ai-service/judge/tools/playwright-action.js +4 -1
- package/dist/ai-service/judge/tools/playwright-action.js.map +1 -1
- package/dist/ai-service/llm/context-v2/context-metrics.js +2 -2
- package/dist/ai-service/llm/context-v2/storage/event-types.d.ts +45 -110
- package/dist/ai-service/llm/context-v2/storage/event-types.d.ts.map +1 -1
- package/dist/ai-service/llm/context-v2/storage/event-types.js +3 -3
- package/dist/ai-service/llm/context-v2/storage/event-types.js.map +1 -1
- package/dist/ai-service/llm/interaction/adapters/vercel.d.ts.map +1 -1
- package/dist/ai-service/llm/interaction/adapters/vercel.js +6 -1
- package/dist/ai-service/llm/interaction/adapters/vercel.js.map +1 -1
- package/dist/ai-service/mcp/adapter/json-schema-to-zod.d.ts.map +1 -1
- package/dist/ai-service/mcp/adapter/json-schema-to-zod.js.map +1 -1
- package/dist/ai-service/mcp/embedded-playwright-mcp-server.d.ts +2 -0
- package/dist/ai-service/mcp/embedded-playwright-mcp-server.d.ts.map +1 -1
- package/dist/ai-service/mcp/embedded-playwright-mcp-server.js +28 -0
- package/dist/ai-service/mcp/embedded-playwright-mcp-server.js.map +1 -1
- package/dist/ai-service/mcp/playwright-server.d.ts +2 -0
- package/dist/ai-service/mcp/playwright-server.d.ts.map +1 -1
- package/dist/ai-service/mcp/playwright-server.js +1 -0
- package/dist/ai-service/mcp/playwright-server.js.map +1 -1
- package/dist/ai-service/migration-prompt-gating.d.ts +2 -0
- package/dist/ai-service/migration-prompt-gating.d.ts.map +1 -1
- package/dist/ai-service/migration-prompt-gating.js +3 -0
- package/dist/ai-service/migration-prompt-gating.js.map +1 -1
- package/dist/ai-service/native-turn-failure.d.ts +13 -0
- package/dist/ai-service/native-turn-failure.d.ts.map +1 -1
- package/dist/ai-service/native-turn-failure.js +46 -1
- package/dist/ai-service/native-turn-failure.js.map +1 -1
- package/dist/ai-service/prompt-builder-service/types.d.ts +3 -1
- package/dist/ai-service/prompt-builder-service/types.d.ts.map +1 -1
- package/dist/ai-service/security/vulnerability-triage.d.ts +12 -30
- package/dist/ai-service/security/vulnerability-triage.d.ts.map +1 -1
- package/dist/ai-service/skills/system/_registry.generated.d.ts.map +1 -1
- package/dist/ai-service/skills/system/_registry.generated.js +6 -0
- package/dist/ai-service/skills/system/_registry.generated.js.map +1 -1
- package/dist/ai-service/skills/system/project-agents/references/errors.generated.d.ts +2 -0
- package/dist/ai-service/skills/system/project-agents/references/errors.generated.d.ts.map +1 -0
- package/dist/ai-service/skills/system/project-agents/references/errors.generated.js +26 -0
- package/dist/ai-service/skills/system/project-agents/references/errors.generated.js.map +1 -0
- package/dist/ai-service/skills/system/project-agents/references/fields.generated.d.ts +2 -0
- package/dist/ai-service/skills/system/project-agents/references/fields.generated.d.ts.map +1 -0
- package/dist/ai-service/skills/system/project-agents/references/fields.generated.js +55 -0
- package/dist/ai-service/skills/system/project-agents/references/fields.generated.js.map +1 -0
- package/dist/ai-service/skills/system/project-agents/skill.generated.d.ts +2 -0
- package/dist/ai-service/skills/system/project-agents/skill.generated.d.ts.map +1 -0
- package/dist/ai-service/skills/system/project-agents/skill.generated.js +74 -0
- package/dist/ai-service/skills/system/project-agents/skill.generated.js.map +1 -0
- package/dist/ai-service/state-machine/handlers/llm-generating.d.ts.map +1 -1
- package/dist/ai-service/state-machine/handlers/llm-generating.js +10 -7
- package/dist/ai-service/state-machine/handlers/llm-generating.js.map +1 -1
- package/dist/ai-service/state-machine/helpers/prompt-failure.d.ts +8 -0
- package/dist/ai-service/state-machine/helpers/prompt-failure.d.ts.map +1 -1
- package/dist/ai-service/state-machine/helpers/prompt-failure.js +25 -8
- package/dist/ai-service/state-machine/helpers/prompt-failure.js.map +1 -1
- package/dist/ai-service/state-machine/helpers/prompt-request-metrics.d.ts +4 -0
- package/dist/ai-service/state-machine/helpers/prompt-request-metrics.d.ts.map +1 -1
- package/dist/ai-service/state-machine/helpers/prompt-request-metrics.js +4 -0
- package/dist/ai-service/state-machine/helpers/prompt-request-metrics.js.map +1 -1
- package/dist/ai-service/state-machine/helpers/stable-peer.d.ts +2 -0
- package/dist/ai-service/state-machine/helpers/stable-peer.d.ts.map +1 -1
- package/dist/ai-service/state-machine/helpers/stable-peer.js +9 -2
- package/dist/ai-service/state-machine/helpers/stable-peer.js.map +1 -1
- package/dist/ai-service/tasks/task-store.d.ts.map +1 -1
- package/dist/ai-service/tasks/task-store.js +1 -1
- package/dist/ai-service/tasks/task-store.js.map +1 -1
- package/dist/ai-service/tasks/types.d.ts +5 -1
- package/dist/ai-service/tasks/types.d.ts.map +1 -1
- package/dist/ai-service/tool-input-schema.d.ts +14 -0
- package/dist/ai-service/tool-input-schema.d.ts.map +1 -0
- package/dist/ai-service/tool-input-schema.js +23 -0
- package/dist/ai-service/tool-input-schema.js.map +1 -0
- package/dist/ai-service/util/inference-jwt.d.ts +5 -0
- package/dist/ai-service/util/inference-jwt.d.ts.map +1 -1
- package/dist/ai-service/util/inference-jwt.js +17 -0
- package/dist/ai-service/util/inference-jwt.js.map +1 -1
- package/dist/ai-service/workspace-mirror.d.ts +2 -0
- package/dist/ai-service/workspace-mirror.d.ts.map +1 -1
- package/dist/ai-service/workspace-mirror.js +21 -0
- package/dist/ai-service/workspace-mirror.js.map +1 -1
- package/dist/ai-service/workspace-package-registry.d.ts +3 -0
- package/dist/ai-service/workspace-package-registry.d.ts.map +1 -0
- package/dist/ai-service/workspace-package-registry.js +87 -0
- package/dist/ai-service/workspace-package-registry.js.map +1 -0
- package/dist/ai-service/workspace-package-state.d.ts +12 -0
- package/dist/ai-service/workspace-package-state.d.ts.map +1 -0
- package/dist/ai-service/workspace-package-state.js +47 -0
- package/dist/ai-service/workspace-package-state.js.map +1 -0
- package/dist/ai-service/workspace-packages.d.ts +234 -0
- package/dist/ai-service/workspace-packages.d.ts.map +1 -0
- package/dist/ai-service/workspace-packages.js +466 -0
- package/dist/ai-service/workspace-packages.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 +3 -1
- package/dist/file-sync-vite-plugin.d.ts.map +1 -1
- package/dist/file-sync-vite-plugin.js +28 -11
- package/dist/file-sync-vite-plugin.js.map +1 -1
- package/dist/file-system-manager.d.ts.map +1 -1
- package/dist/file-system-manager.js +11 -13
- package/dist/file-system-manager.js.map +1 -1
- package/dist/import-check.d.ts +16 -0
- package/dist/import-check.d.ts.map +1 -0
- package/dist/import-check.js +23 -0
- package/dist/import-check.js.map +1 -0
- package/dist/index.d.ts +5 -3
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +2 -1
- package/dist/index.js.map +1 -1
- package/dist/lock-service/branch-metrics.d.ts +1 -1
- package/dist/lock-service/branch-metrics.d.ts.map +1 -1
- package/dist/lock-service/branch-metrics.js.map +1 -1
- package/dist/lock-service/index.d.ts +51 -0
- package/dist/lock-service/index.d.ts.map +1 -1
- package/dist/lock-service/index.js +176 -0
- package/dist/lock-service/index.js.map +1 -1
- package/dist/plugin-options.d.ts +9 -1
- package/dist/plugin-options.d.ts.map +1 -1
- package/dist/plugin-options.js.map +1 -1
- package/dist/policy-gate-runner.d.ts +1 -9
- package/dist/policy-gate-runner.d.ts.map +1 -1
- package/dist/project-agent-update.d.ts +44 -0
- package/dist/project-agent-update.d.ts.map +1 -0
- package/dist/project-agent-update.js +125 -0
- package/dist/project-agent-update.js.map +1 -0
- package/dist/project-agents.d.ts +31 -0
- package/dist/project-agents.d.ts.map +1 -0
- package/dist/project-agents.js +50 -0
- package/dist/project-agents.js.map +1 -0
- package/dist/project-manifest.d.ts +8 -108
- package/dist/project-manifest.d.ts.map +1 -1
- package/dist/project-manifest.js +28 -115
- package/dist/project-manifest.js.map +1 -1
- package/dist/server-rpc/index.d.ts +6 -0
- package/dist/server-rpc/index.d.ts.map +1 -1
- package/dist/server-rpc/index.js +13 -1
- package/dist/server-rpc/index.js.map +1 -1
- package/dist/socket-manager.d.ts +3 -1
- package/dist/socket-manager.d.ts.map +1 -1
- package/dist/socket-manager.js +122 -72
- package/dist/socket-manager.js.map +1 -1
- package/dist/sync-service/draft-mutation.d.ts +6 -2
- package/dist/sync-service/draft-mutation.d.ts.map +1 -1
- package/dist/sync-service/draft-mutation.js +20 -33
- package/dist/sync-service/draft-mutation.js.map +1 -1
- package/dist/sync-service/index.d.ts +6 -6
- package/dist/sync-service/index.d.ts.map +1 -1
- package/dist/sync-service/index.js +29 -61
- package/dist/sync-service/index.js.map +1 -1
- package/dist/workspace-sync-methods.d.ts +5 -20
- package/dist/workspace-sync-methods.d.ts.map +1 -1
- package/package.json +17 -13
- package/dist/project-agent-tools.d.ts +0 -23
- package/dist/project-agent-tools.d.ts.map +0 -1
- package/dist/project-agent-tools.js +0 -73
- package/dist/project-agent-tools.js.map +0 -1
- package/dist/sync-service/native-draft-session.d.ts +0 -3
- package/dist/sync-service/native-draft-session.d.ts.map +0 -1
- package/dist/sync-service/native-draft-session.js +0 -4
- package/dist/sync-service/native-draft-session.js.map +0 -1
|
@@ -1,10 +1,12 @@
|
|
|
1
|
+
/** Runs native builder turns and coordinates their editor callbacks and recovery. */
|
|
1
2
|
import { randomBytes } from "node:crypto";
|
|
2
|
-
import { context, trace } from "@opentelemetry/api";
|
|
3
|
+
import { context, metrics, trace } from "@opentelemetry/api";
|
|
3
4
|
import { asSchema, tool } from "ai";
|
|
4
5
|
import { z } from "zod";
|
|
6
|
+
import { NATIVE_BUILDER_PROVIDERS, } from "@superblocksteam/library-shared/types";
|
|
5
7
|
import { NativeBuilderModel, } from "@superblocksteam/shared";
|
|
6
8
|
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";
|
|
7
|
-
import { getErrorMeta } from "../util/logger.js";
|
|
9
|
+
import { getErrorMeta, getLogger } from "../util/logger.js";
|
|
8
10
|
import { getToolOutput } from "./agent/tool-message-utils.js";
|
|
9
11
|
import { movesEditor } from "./agent/tools/branching/branch-tools.js";
|
|
10
12
|
import { BuilderFailureDrain, } from "./builder-failure-drain.js";
|
|
@@ -13,11 +15,82 @@ import { AgentCoreToolHost } from "./builder-tool-callbacks.js";
|
|
|
13
15
|
import { NativeCallbackOrder } from "./native-callback-order.js";
|
|
14
16
|
import { NativeSecretRedactor } from "./native-secret-redactor.js";
|
|
15
17
|
import { OutboundTraceContext, } from "./outbound-trace-context.js";
|
|
18
|
+
import { toolInputSchema } from "./tool-input-schema.js";
|
|
16
19
|
/** Runtime control calls whose failure to authorize inference stops the turn. */
|
|
17
20
|
const INFERENCE_AUTH_CALLS = new Set([
|
|
18
21
|
"__runtime_redact",
|
|
19
22
|
"__runtime_inference_token",
|
|
20
23
|
]);
|
|
24
|
+
/** Runtime control calls, which never wait on a stream event. */
|
|
25
|
+
const RUNTIME_CONTROL_CALLS = new Set([
|
|
26
|
+
"__runtime_redact",
|
|
27
|
+
"__runtime_skills_token",
|
|
28
|
+
"__runtime_inference_token",
|
|
29
|
+
]);
|
|
30
|
+
/** Error codes with which a runtime declines a `turn.attach`. */
|
|
31
|
+
const ATTACH_REFUSALS = new Set([
|
|
32
|
+
"RUN_NOT_FOUND",
|
|
33
|
+
"RUN_ENDED",
|
|
34
|
+
"ATTACH_GAP",
|
|
35
|
+
"UNSUPPORTED_INVOCATION",
|
|
36
|
+
]);
|
|
37
|
+
const MAX_REATTACH_DELAY_MS = 4_000;
|
|
38
|
+
class AttachRefusedError extends Error {
|
|
39
|
+
code;
|
|
40
|
+
constructor(code) {
|
|
41
|
+
super(`The builder runtime refused to reattach: ${code}`);
|
|
42
|
+
this.code = code;
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
class AttachTimeoutError extends Error {
|
|
46
|
+
constructor() {
|
|
47
|
+
super("Reattaching to the builder runtime timed out");
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
class StreamEndedError extends Error {
|
|
51
|
+
constructor() {
|
|
52
|
+
super("Native builder stream ended without a finish event");
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
/** Whether `error` means the connection carrying a runtime stream was lost. */
|
|
56
|
+
function isTransportLoss(error) {
|
|
57
|
+
let current = error;
|
|
58
|
+
for (let depth = 0; current instanceof Error && depth < 5; depth++) {
|
|
59
|
+
const code = "code" in current ? current.code : undefined;
|
|
60
|
+
if (
|
|
61
|
+
// A proxy or a draining server can end the body cleanly mid-turn.
|
|
62
|
+
current instanceof StreamEndedError ||
|
|
63
|
+
current.message === "terminated" ||
|
|
64
|
+
current.message === "fetch failed" ||
|
|
65
|
+
current.message.includes("other side closed") ||
|
|
66
|
+
code === "UND_ERR_SOCKET" ||
|
|
67
|
+
code === "ECONNRESET" ||
|
|
68
|
+
code === "ECONNREFUSED")
|
|
69
|
+
return true;
|
|
70
|
+
current = current.cause;
|
|
71
|
+
}
|
|
72
|
+
return false;
|
|
73
|
+
}
|
|
74
|
+
function parseSeq(value) {
|
|
75
|
+
if (!/^[1-9][0-9]{0,15}$/.test(value))
|
|
76
|
+
return undefined;
|
|
77
|
+
const seq = Number(value);
|
|
78
|
+
return Number.isSafeInteger(seq) ? seq : undefined;
|
|
79
|
+
}
|
|
80
|
+
function delay(ms, signal) {
|
|
81
|
+
return new Promise((resolve, reject) => {
|
|
82
|
+
signal.throwIfAborted();
|
|
83
|
+
const onAbort = () => {
|
|
84
|
+
clearTimeout(timer);
|
|
85
|
+
reject(signal.reason);
|
|
86
|
+
};
|
|
87
|
+
const timer = setTimeout(() => {
|
|
88
|
+
signal.removeEventListener("abort", onAbort);
|
|
89
|
+
resolve();
|
|
90
|
+
}, ms);
|
|
91
|
+
signal.addEventListener("abort", onAbort, { once: true });
|
|
92
|
+
});
|
|
93
|
+
}
|
|
21
94
|
const executionDescriptorSchema = z
|
|
22
95
|
.object({
|
|
23
96
|
token: z.string().min(32).max(4096),
|
|
@@ -67,6 +140,8 @@ const workspaceFinishSchema = z.object({
|
|
|
67
140
|
dbfsHash: z.string().min(1).optional(),
|
|
68
141
|
rehydrate: z.enum(["fresh", "resumed", "replayed", "reloaded"]).optional(),
|
|
69
142
|
filesChanged: z.boolean().optional(),
|
|
143
|
+
/** The AI checkpoint the VM's turn end created; absent when it created none. */
|
|
144
|
+
commitId: z.string().min(1).optional(),
|
|
70
145
|
/**
|
|
71
146
|
* Per-VM-boot credential the AI process presents as an ai-service peer on
|
|
72
147
|
* the VM's `/sb-dev-updates`; `workspace.open` returns it.
|
|
@@ -93,8 +168,14 @@ const runtimeFailureReasonSchema = z.enum([
|
|
|
93
168
|
]);
|
|
94
169
|
const eventSchema = z.discriminatedUnion("type", [
|
|
95
170
|
z.object({ type: z.literal("session"), sessionId: z.string().min(1) }),
|
|
96
|
-
z.object({ type: z.literal("callback-ready"), id: z.
|
|
97
|
-
z.object({
|
|
171
|
+
z.object({ type: z.literal("callback-ready"), id: z.guid() }),
|
|
172
|
+
z.object({
|
|
173
|
+
type: z.literal("text-delta"),
|
|
174
|
+
text: z.string(),
|
|
175
|
+
// Trailing characters the harness abandoned on a retry. Lenient: a bad
|
|
176
|
+
// value only keeps text the user already saw.
|
|
177
|
+
discard: z.number().int().positive().optional().catch(undefined),
|
|
178
|
+
}),
|
|
98
179
|
z.object({
|
|
99
180
|
type: z.literal("plan"),
|
|
100
181
|
id: z.string().min(1),
|
|
@@ -104,7 +185,7 @@ const eventSchema = z.discriminatedUnion("type", [
|
|
|
104
185
|
type: z.literal("tool-call"),
|
|
105
186
|
toolCallId: z.string(),
|
|
106
187
|
toolName: z.string(),
|
|
107
|
-
input: z.unknown(),
|
|
188
|
+
input: z.unknown().optional(),
|
|
108
189
|
// The sub-agent call this call was made inside. Lenient: grouping is a
|
|
109
190
|
// convenience and must not fail the stream parse.
|
|
110
191
|
parentToolCallId: z.string().optional().catch(undefined),
|
|
@@ -113,7 +194,7 @@ const eventSchema = z.discriminatedUnion("type", [
|
|
|
113
194
|
type: z.literal("tool-result"),
|
|
114
195
|
toolCallId: z.string(),
|
|
115
196
|
toolName: z.string(),
|
|
116
|
-
output: z.unknown(),
|
|
197
|
+
output: z.unknown().optional(),
|
|
117
198
|
isError: z.boolean().optional(),
|
|
118
199
|
}),
|
|
119
200
|
// Workspace turn-end data rides on `finish` rather than a new event type:
|
|
@@ -122,6 +203,8 @@ const eventSchema = z.discriminatedUnion("type", [
|
|
|
122
203
|
type: z.literal("finish"),
|
|
123
204
|
usage: usageSchema,
|
|
124
205
|
workspace: workspaceFinishSchema.optional(),
|
|
206
|
+
/** On `turn.cancel`, whether a running turn was stopped. */
|
|
207
|
+
cancelled: z.boolean().optional(),
|
|
125
208
|
}),
|
|
126
209
|
z.object({
|
|
127
210
|
type: z.literal("error"),
|
|
@@ -166,7 +249,7 @@ export class BuilderRuntimeError extends Error {
|
|
|
166
249
|
return new BuilderRuntimeError(this.code, this.reason, this.beforeTurn, this.runSubmitted, false, outcome);
|
|
167
250
|
}
|
|
168
251
|
/** Logs the safe failure classification and its invocation-attempt context. */
|
|
169
|
-
static log(error, logger, attempt) {
|
|
252
|
+
static log(error, logger, attempt, context) {
|
|
170
253
|
const code = error instanceof BuilderRuntimeError
|
|
171
254
|
? z
|
|
172
255
|
.enum([
|
|
@@ -185,6 +268,7 @@ export class BuilderRuntimeError extends Error {
|
|
|
185
268
|
? runtimeFailureReasonSchema.catch("unknown").parse(error.reason)
|
|
186
269
|
: undefined;
|
|
187
270
|
logger.warn("Native builder operation failed", {
|
|
271
|
+
...context,
|
|
188
272
|
...getErrorMeta(error),
|
|
189
273
|
...(code && { "failure.code": code.success ? code.data : "unknown" }),
|
|
190
274
|
...(reason && { "failure.reason": reason }),
|
|
@@ -250,8 +334,7 @@ export class BuilderRuntime {
|
|
|
250
334
|
localToken;
|
|
251
335
|
execution;
|
|
252
336
|
workspaceSecret;
|
|
253
|
-
|
|
254
|
-
selectedModel;
|
|
337
|
+
options;
|
|
255
338
|
static configuredHarnesses(env) {
|
|
256
339
|
return ["codex", "claude_code"].filter((harness) => {
|
|
257
340
|
try {
|
|
@@ -263,15 +346,28 @@ export class BuilderRuntime {
|
|
|
263
346
|
});
|
|
264
347
|
}
|
|
265
348
|
toolHost = new AgentCoreToolHost();
|
|
349
|
+
/**
|
|
350
|
+
* How long a cancelled workspace turn's stream stays open for the finish
|
|
351
|
+
* naming its checkpoint before it is closed as for any other turn.
|
|
352
|
+
*/
|
|
353
|
+
cancelFinishTimeoutMs = 30_000;
|
|
354
|
+
reattachOutcomes = metrics
|
|
355
|
+
.getMeter("superblocks.ai_service")
|
|
356
|
+
.createCounter("superblocks.ai_service.builder_reattach", {
|
|
357
|
+
description: "Native builder turns whose lost stream was reattached or given up",
|
|
358
|
+
unit: "1",
|
|
359
|
+
});
|
|
360
|
+
/** How long after a turn's stream is lost it may be reattached. */
|
|
361
|
+
reattachBudgetMs = 15_000;
|
|
362
|
+
/** The first pause before reattaching; it doubles per attempt. */
|
|
363
|
+
reattachDelayMs = 250;
|
|
266
364
|
secrets = new NativeSecretRedactor();
|
|
267
365
|
get model() {
|
|
268
|
-
return this.selectedModel ?? NativeBuilderModel.resolve(this.harness);
|
|
366
|
+
return (this.options.selectedModel ?? NativeBuilderModel.resolve(this.harness));
|
|
269
367
|
}
|
|
270
368
|
constructor(harness, callback, remoteEnvironment, localUrl, localToken, execution,
|
|
271
369
|
/** Keys the workspace token; see {@link workspaceEdge}. */
|
|
272
|
-
workspaceSecret = "",
|
|
273
|
-
/** The local VM ingress, overriding the default next to `localUrl`. */
|
|
274
|
-
localWorkspaceUrl, selectedModel) {
|
|
370
|
+
workspaceSecret = "", options = {}) {
|
|
275
371
|
this.harness = harness;
|
|
276
372
|
this.callback = callback;
|
|
277
373
|
this.remoteEnvironment = remoteEnvironment;
|
|
@@ -279,8 +375,7 @@ export class BuilderRuntime {
|
|
|
279
375
|
this.localToken = localToken;
|
|
280
376
|
this.execution = execution;
|
|
281
377
|
this.workspaceSecret = workspaceSecret;
|
|
282
|
-
this.
|
|
283
|
-
this.selectedModel = selectedModel;
|
|
378
|
+
this.options = options;
|
|
284
379
|
}
|
|
285
380
|
static fromEnvironment(env, splitMode, applicationId, appRootDirPath, harness = env.SUPERBLOCKS_BUILDER_HARNESS ?? "clark", execution) {
|
|
286
381
|
if (harness === "clark")
|
|
@@ -322,23 +417,27 @@ export class BuilderRuntime {
|
|
|
322
417
|
throw new Error("Native builder requires an execution control token of at least 32 characters");
|
|
323
418
|
if (!appRootDirPath?.startsWith("/"))
|
|
324
419
|
throw new Error("Native builder requires an absolute application root");
|
|
420
|
+
const localAgentCore = env.SUPERBLOCKS_LOCAL_AGENTCORE === "true";
|
|
325
421
|
return new BuilderRuntime(harness, {
|
|
326
|
-
url: this.websocketUrl(env.SUPERBLOCKS_BUILDER_CALLBACK_URL, "/sb-updates", !!localUrl),
|
|
422
|
+
url: this.websocketUrl(env.SUPERBLOCKS_BUILDER_CALLBACK_URL, "/sb-updates", !!localUrl || localAgentCore),
|
|
327
423
|
token: randomBytes(32).toString("hex"),
|
|
328
424
|
appId: applicationId,
|
|
329
425
|
}, {
|
|
330
426
|
url: this.websocketUrl(harness === "codex"
|
|
331
427
|
? env.SUPERBLOCKS_CODEX_EXEC_SERVER_URL
|
|
332
428
|
: (env.SUPERBLOCKS_CLAUDE_TOOL_SERVER_URL ??
|
|
333
|
-
env.SUPERBLOCKS_CODEX_EXEC_SERVER_URL), "/sb-dev-exec", !!localUrl),
|
|
429
|
+
env.SUPERBLOCKS_CODEX_EXEC_SERVER_URL), "/sb-dev-exec", !!localUrl || localAgentCore),
|
|
334
430
|
cwd: appRootDirPath,
|
|
335
|
-
}, localUrl, env.SUPERBLOCKS_BUILDER_RUNTIME_TOKEN, execution, env.SUPERBLOCKS_AGENT_TOOL_TOKEN,
|
|
431
|
+
}, localUrl, env.SUPERBLOCKS_BUILDER_RUNTIME_TOKEN, execution, env.SUPERBLOCKS_AGENT_TOOL_TOKEN, {
|
|
432
|
+
localWorkspaceUrl: env.SUPERBLOCKS_BUILDER_WORKSPACE_URL || undefined,
|
|
433
|
+
localAgentCore,
|
|
434
|
+
});
|
|
336
435
|
}
|
|
337
436
|
withModel(preferredModel) {
|
|
338
437
|
const model = NativeBuilderModel.resolve(this.harness, preferredModel);
|
|
339
438
|
if (model === this.model)
|
|
340
439
|
return this;
|
|
341
|
-
return new BuilderRuntime(this.harness, this.callback, this.remoteEnvironment, this.localUrl, this.localToken, this.execution, this.workspaceSecret, this.
|
|
440
|
+
return new BuilderRuntime(this.harness, this.callback, this.remoteEnvironment, this.localUrl, this.localToken, this.execution, this.workspaceSecret, { ...this.options, selectedModel: model });
|
|
342
441
|
}
|
|
343
442
|
static isLoopback(url) {
|
|
344
443
|
return ["127.0.0.1", "localhost", "[::1]"].includes(url.hostname);
|
|
@@ -381,8 +480,9 @@ export class BuilderRuntime {
|
|
|
381
480
|
}),
|
|
382
481
|
});
|
|
383
482
|
}
|
|
483
|
+
/** Resolves provider routing from the shared native harness contract. */
|
|
384
484
|
providerFor(_model) {
|
|
385
|
-
return this.harness
|
|
485
|
+
return NATIVE_BUILDER_PROVIDERS[this.harness];
|
|
386
486
|
}
|
|
387
487
|
async invoke(options) {
|
|
388
488
|
if (Object.keys(options.tools).some((name) => name.startsWith("__runtime_")))
|
|
@@ -394,7 +494,7 @@ export class BuilderRuntime {
|
|
|
394
494
|
const inferenceUrl = new URL(options.inference.url);
|
|
395
495
|
const skillsUrl = new URL(options.skills.url);
|
|
396
496
|
const isValidProxyUrl = (url) => (url.protocol === "https:" ||
|
|
397
|
-
(this.localUrl &&
|
|
497
|
+
((this.localUrl || this.options.localAgentCore) &&
|
|
398
498
|
url.protocol === "http:" &&
|
|
399
499
|
BuilderRuntime.isLoopback(url))) &&
|
|
400
500
|
!url.username &&
|
|
@@ -420,10 +520,9 @@ export class BuilderRuntime {
|
|
|
420
520
|
runId: options.runId,
|
|
421
521
|
concurrentTools: new Set([
|
|
422
522
|
...(options.concurrentTools ?? []),
|
|
423
|
-
|
|
424
|
-
"__runtime_skills_token",
|
|
425
|
-
"__runtime_inference_token",
|
|
523
|
+
...RUNTIME_CONTROL_CALLS,
|
|
426
524
|
]),
|
|
525
|
+
unorderedTools: RUNTIME_CONTROL_CALLS,
|
|
427
526
|
tools: {
|
|
428
527
|
...options.tools,
|
|
429
528
|
...options.callbackTools,
|
|
@@ -530,7 +629,21 @@ export class BuilderRuntime {
|
|
|
530
629
|
});
|
|
531
630
|
let mustRevoke = false;
|
|
532
631
|
let failure;
|
|
533
|
-
|
|
632
|
+
// The runtime's stream. A cancel closes it, except that a workspace
|
|
633
|
+
// turn's end commits its tree even when cancelled and its finish names
|
|
634
|
+
// that checkpoint: once its stream is open, a cancel stops the turn with
|
|
635
|
+
// `turn.cancel` and keeps reading. Closing the stream is the fallback
|
|
636
|
+
// when that call fails or the finish does not come in time.
|
|
637
|
+
const stream = new AbortController();
|
|
638
|
+
let streaming = false;
|
|
639
|
+
options.signal.addEventListener("abort", () => {
|
|
640
|
+
const close = () => stream.abort(options.signal.reason);
|
|
641
|
+
if (!options.workspaceLocal || !streaming)
|
|
642
|
+
return close();
|
|
643
|
+
const timer = setTimeout(close, this.cancelFinishTimeoutMs);
|
|
644
|
+
stream.signal.addEventListener("abort", () => clearTimeout(timer));
|
|
645
|
+
void this.cancelTurn(options, stream.signal).then((cancelled) => cancelled || close());
|
|
646
|
+
}, { once: true, signal: stream.signal });
|
|
534
647
|
try {
|
|
535
648
|
options.signal.throwIfAborted();
|
|
536
649
|
mustRevoke = !!execution;
|
|
@@ -540,7 +653,8 @@ export class BuilderRuntime {
|
|
|
540
653
|
const tools = await Promise.all(Object.entries(options.tools).map(async ([name, tool]) => ({
|
|
541
654
|
name,
|
|
542
655
|
description: tool.description ?? "",
|
|
543
|
-
inputSchema: await asSchema(tool.inputSchema)
|
|
656
|
+
inputSchema: await asSchema(toolInputSchema(tool.inputSchema))
|
|
657
|
+
.jsonSchema,
|
|
544
658
|
...(options.concurrentTools?.has(name) && { readOnly: true }),
|
|
545
659
|
})));
|
|
546
660
|
const payload = JSON.stringify({
|
|
@@ -576,31 +690,42 @@ export class BuilderRuntime {
|
|
|
576
690
|
payload,
|
|
577
691
|
session: options.workspaceSessionKey ? "workspace" : "chat",
|
|
578
692
|
access: options.access,
|
|
579
|
-
signal:
|
|
693
|
+
signal: stream.signal,
|
|
580
694
|
});
|
|
581
|
-
|
|
582
|
-
await this.
|
|
695
|
+
streaming = true;
|
|
696
|
+
await this.followTurn(body, stream.signal, {
|
|
583
697
|
...options,
|
|
584
698
|
onEvent: (event) => {
|
|
585
|
-
|
|
586
|
-
|
|
587
|
-
|
|
588
|
-
|
|
699
|
+
// After an inference or Skills auth failure, drop events but still
|
|
700
|
+
// deliver the finish naming the checkpoint the workspace turn
|
|
701
|
+
// committed.
|
|
702
|
+
if ((inferenceFailure || skillsFailure) &&
|
|
703
|
+
!(event.type === "finish" && event.workspace))
|
|
704
|
+
return;
|
|
589
705
|
return options.onEvent(event);
|
|
590
706
|
},
|
|
591
|
-
}, callbacks, callbackResults
|
|
707
|
+
}, callbacks, callbackResults,
|
|
708
|
+
// A workspace turn still owes the finish naming its committed checkpoint.
|
|
709
|
+
() => !!options.workspaceSessionKey ||
|
|
710
|
+
(!inferenceFailure && !skillsFailure));
|
|
592
711
|
if (inferenceFailure)
|
|
593
712
|
throw inferenceFailure;
|
|
594
713
|
if (skillsFailure)
|
|
595
714
|
throw skillsFailure;
|
|
715
|
+
options.signal.throwIfAborted();
|
|
596
716
|
}
|
|
597
717
|
catch (error) {
|
|
598
718
|
failure = { error: inferenceFailure ?? skillsFailure ?? error };
|
|
599
719
|
}
|
|
600
720
|
finally {
|
|
601
|
-
//
|
|
602
|
-
|
|
603
|
-
|
|
721
|
+
// Ends the cancel's fallback timer and any cancel still in flight.
|
|
722
|
+
stream.abort();
|
|
723
|
+
// A cancelled turn whose stream closed without its own `turn.cancel`
|
|
724
|
+
// still runs in the VM, since AgentCore keeps an invocation going after
|
|
725
|
+
// its caller hangs up. Before the tools close, so the VM stops instead
|
|
726
|
+
// of failing its next callback.
|
|
727
|
+
if (streaming && options.signal.aborted && !options.workspaceLocal)
|
|
728
|
+
await this.cancelTurn(options, AbortSignal.timeout(5_000), false);
|
|
604
729
|
closeTools();
|
|
605
730
|
callbackResults.clear();
|
|
606
731
|
}
|
|
@@ -615,30 +740,6 @@ export class BuilderRuntime {
|
|
|
615
740
|
if (failure)
|
|
616
741
|
throw failure.error;
|
|
617
742
|
}
|
|
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
|
-
}
|
|
642
743
|
/**
|
|
643
744
|
* The workspace edge's base URL (no path) and the token the VM presents to
|
|
644
745
|
* it and accepts from it, for one workspace session. The edge is the
|
|
@@ -679,7 +780,7 @@ export class BuilderRuntime {
|
|
|
679
780
|
body,
|
|
680
781
|
endpoint: workspaceEndpointSchema.parse({
|
|
681
782
|
auth: "none",
|
|
682
|
-
url: this.localWorkspaceUrl ??
|
|
783
|
+
url: this.options.localWorkspaceUrl ??
|
|
683
784
|
`http://${new URL(this.localUrl).hostname}:${WORKSPACE_INGRESS_PORT}`,
|
|
684
785
|
sessionKey,
|
|
685
786
|
}),
|
|
@@ -779,6 +880,14 @@ export class BuilderRuntime {
|
|
|
779
880
|
* Throws when the stream ends without one or a frame is too large.
|
|
780
881
|
*/
|
|
781
882
|
static async *readEvents(body, signal) {
|
|
883
|
+
for await (const { event } of BuilderRuntime.readFrames(body, signal))
|
|
884
|
+
yield event;
|
|
885
|
+
}
|
|
886
|
+
/**
|
|
887
|
+
* {@link readEvents} with each frame's `id:` sequence number. A frame
|
|
888
|
+
* without a valid id has none.
|
|
889
|
+
*/
|
|
890
|
+
static async *readFrames(body, signal) {
|
|
782
891
|
const decoder = new TextDecoder("utf-8", { fatal: true });
|
|
783
892
|
let buffer = "";
|
|
784
893
|
const iterator = body[Symbol.asyncIterator]();
|
|
@@ -801,47 +910,252 @@ export class BuilderRuntime {
|
|
|
801
910
|
throw new Error("Native builder event exceeds size limit");
|
|
802
911
|
const frame = buffer.slice(0, boundary.index);
|
|
803
912
|
buffer = buffer.slice(boundary.index + boundary[0].length);
|
|
804
|
-
const
|
|
805
|
-
|
|
913
|
+
const lines = frame.split(/\r?\n/);
|
|
914
|
+
const data = lines
|
|
806
915
|
.filter((line) => line.startsWith("data:"))
|
|
807
916
|
.map((line) => line.slice(5).trimStart())
|
|
808
917
|
.join("\n");
|
|
809
918
|
if (!data)
|
|
810
919
|
continue;
|
|
811
920
|
const event = eventSchema.parse(JSON.parse(data));
|
|
812
|
-
|
|
921
|
+
const id = lines.findLast((line) => line.startsWith("id:"));
|
|
922
|
+
const seq = id === undefined ? undefined : parseSeq(id.slice(3).trim());
|
|
923
|
+
yield seq === undefined ? { event } : { event, seq };
|
|
813
924
|
if (event.type === "finish")
|
|
814
925
|
return;
|
|
815
926
|
}
|
|
816
927
|
if (buffer.length > 8_388_608)
|
|
817
928
|
throw new Error("Native builder event exceeds size limit");
|
|
818
929
|
}
|
|
819
|
-
throw new
|
|
930
|
+
throw new StreamEndedError();
|
|
820
931
|
}
|
|
821
932
|
finally {
|
|
822
933
|
signal.removeEventListener("abort", onAbort);
|
|
823
934
|
void iterator.return?.().catch(() => { });
|
|
824
935
|
}
|
|
825
936
|
}
|
|
826
|
-
|
|
937
|
+
/**
|
|
938
|
+
* Asks the runtime to stop the turn `options.runId` without closing its
|
|
939
|
+
* stream. AgentCore keeps an invocation running after its caller hangs up,
|
|
940
|
+
* so closing the stream alone leaves the turn going. False when it could
|
|
941
|
+
* not: an older runtime (which answers 422), or no such turn running.
|
|
942
|
+
* Without `awaitReply` it only sends the cancel and reports true.
|
|
943
|
+
*/
|
|
944
|
+
async cancelTurn(options, signal, awaitReply = true) {
|
|
945
|
+
try {
|
|
946
|
+
const body = await this.invokeRaw({
|
|
947
|
+
payload: JSON.stringify({
|
|
948
|
+
kind: "turn.cancel",
|
|
949
|
+
provider: this.providerFor(this.model),
|
|
950
|
+
runId: options.runId,
|
|
951
|
+
actorId: options.actorId,
|
|
952
|
+
}),
|
|
953
|
+
session: options.workspaceSessionKey ? "workspace" : "chat",
|
|
954
|
+
access: options.access,
|
|
955
|
+
signal,
|
|
956
|
+
});
|
|
957
|
+
if (!awaitReply) {
|
|
958
|
+
await body[Symbol.asyncIterator]().return?.();
|
|
959
|
+
return true;
|
|
960
|
+
}
|
|
961
|
+
for await (const event of BuilderRuntime.readEvents(body, signal))
|
|
962
|
+
if (event.type === "finish")
|
|
963
|
+
return event.cancelled === true;
|
|
964
|
+
return false;
|
|
965
|
+
}
|
|
966
|
+
catch {
|
|
967
|
+
return false;
|
|
968
|
+
}
|
|
969
|
+
}
|
|
970
|
+
/**
|
|
971
|
+
* Consumes a turn's stream. When the connection carrying it is lost, the
|
|
972
|
+
* turn is still running in the VM, so this reattaches with `turn.attach`
|
|
973
|
+
* and resumes after the last event it delivered. Each loss may be
|
|
974
|
+
* reattached for {@link reattachBudgetMs}; an attach stream that delivered
|
|
975
|
+
* new events or stayed open that long counts as reconnected, so a later
|
|
976
|
+
* loss gets a new budget. A refused or exhausted reattach fails with the
|
|
977
|
+
* first transport error.
|
|
978
|
+
*/
|
|
979
|
+
async followTurn(first, signal, options, callbacks, callbackResults, canReattach) {
|
|
980
|
+
const cursor = { seq: 0 };
|
|
981
|
+
let body = first;
|
|
982
|
+
let lost;
|
|
983
|
+
let pause = this.reattachDelayMs;
|
|
984
|
+
let attempts = 0;
|
|
985
|
+
let losses = 0;
|
|
986
|
+
// Once per turn whose stream was lost.
|
|
987
|
+
const settle = (outcome, cause) => {
|
|
988
|
+
trace.getSpan(options.traceContext ?? context.active())?.setAttributes({
|
|
989
|
+
"builder.reattach.attempts": attempts,
|
|
990
|
+
"builder.reattach.episodes": losses,
|
|
991
|
+
"builder.reattach.outcome": outcome,
|
|
992
|
+
});
|
|
993
|
+
this.reattachOutcomes.add(1, { "reattach.outcome": outcome });
|
|
994
|
+
const attributes = {
|
|
995
|
+
"builder.run_id": options.runId,
|
|
996
|
+
"builder.reattach.after_seq": cursor.seq,
|
|
997
|
+
"builder.reattach.attempts": attempts,
|
|
998
|
+
"builder.reattach.episodes": losses,
|
|
999
|
+
"builder.reattach.outcome": outcome,
|
|
1000
|
+
};
|
|
1001
|
+
if (outcome === "recovered") {
|
|
1002
|
+
getLogger().info("Native builder turn reattached", attributes);
|
|
1003
|
+
return;
|
|
1004
|
+
}
|
|
1005
|
+
const status = BuilderRuntimeHttpError.statusOf(cause);
|
|
1006
|
+
getLogger().warn("Native builder turn could not be reattached", {
|
|
1007
|
+
...attributes,
|
|
1008
|
+
...(cause !== undefined && getErrorMeta(cause)),
|
|
1009
|
+
...(cause instanceof AttachRefusedError && {
|
|
1010
|
+
"builder.reattach.refusal": cause.code,
|
|
1011
|
+
}),
|
|
1012
|
+
...(status !== undefined && { "builder.reattach.status": status }),
|
|
1013
|
+
});
|
|
1014
|
+
};
|
|
1015
|
+
for (;;) {
|
|
1016
|
+
let opened = false;
|
|
1017
|
+
let openedAt = 0;
|
|
1018
|
+
const seqBefore = cursor.seq;
|
|
1019
|
+
try {
|
|
1020
|
+
if (!body) {
|
|
1021
|
+
if (!lost)
|
|
1022
|
+
throw new Error("Native builder has no stream to read");
|
|
1023
|
+
attempts++;
|
|
1024
|
+
body = await this.attachTurn(options, cursor.seq, signal, lost.until - performance.now());
|
|
1025
|
+
opened = true;
|
|
1026
|
+
openedAt = performance.now();
|
|
1027
|
+
}
|
|
1028
|
+
await this.consume(body, signal, options, callbacks, callbackResults, cursor, lost !== undefined);
|
|
1029
|
+
if (lost)
|
|
1030
|
+
settle("recovered");
|
|
1031
|
+
return;
|
|
1032
|
+
}
|
|
1033
|
+
catch (error) {
|
|
1034
|
+
body = undefined;
|
|
1035
|
+
if (signal.aborted || options.signal.aborted) {
|
|
1036
|
+
if (lost)
|
|
1037
|
+
settle("cancelled", error);
|
|
1038
|
+
throw error;
|
|
1039
|
+
}
|
|
1040
|
+
const transient = isTransportLoss(error) ||
|
|
1041
|
+
error instanceof AttachTimeoutError ||
|
|
1042
|
+
(BuilderRuntimeHttpError.statusOf(error) ?? 0) >= 500;
|
|
1043
|
+
// An attach that drops at once is the same loss, so its retries back off.
|
|
1044
|
+
let newLoss = opened &&
|
|
1045
|
+
(cursor.seq > seqBefore ||
|
|
1046
|
+
performance.now() - openedAt >= this.reattachBudgetMs);
|
|
1047
|
+
if (!lost) {
|
|
1048
|
+
if (!isTransportLoss(error) || !canReattach())
|
|
1049
|
+
throw error;
|
|
1050
|
+
lost = { error, until: 0 };
|
|
1051
|
+
newLoss = true;
|
|
1052
|
+
}
|
|
1053
|
+
else if (error instanceof AttachRefusedError ||
|
|
1054
|
+
(!opened && !transient)) {
|
|
1055
|
+
settle("refused", error);
|
|
1056
|
+
throw lost.error;
|
|
1057
|
+
}
|
|
1058
|
+
else if (!transient) {
|
|
1059
|
+
// The reattached turn itself failed.
|
|
1060
|
+
settle("failed", error);
|
|
1061
|
+
throw error;
|
|
1062
|
+
}
|
|
1063
|
+
if (newLoss) {
|
|
1064
|
+
losses++;
|
|
1065
|
+
lost.until = performance.now() + this.reattachBudgetMs;
|
|
1066
|
+
pause = this.reattachDelayMs;
|
|
1067
|
+
getLogger().warn("Native builder turn stream lost; reattaching", {
|
|
1068
|
+
...getErrorMeta(error),
|
|
1069
|
+
"builder.run_id": options.runId,
|
|
1070
|
+
"builder.reattach.after_seq": cursor.seq,
|
|
1071
|
+
"builder.reattach.episodes": losses,
|
|
1072
|
+
});
|
|
1073
|
+
}
|
|
1074
|
+
if (performance.now() + pause >= lost.until) {
|
|
1075
|
+
settle("exhausted", error);
|
|
1076
|
+
throw lost.error;
|
|
1077
|
+
}
|
|
1078
|
+
try {
|
|
1079
|
+
await delay(pause, AbortSignal.any([signal, options.signal]));
|
|
1080
|
+
}
|
|
1081
|
+
catch (aborted) {
|
|
1082
|
+
settle("cancelled", aborted);
|
|
1083
|
+
throw aborted;
|
|
1084
|
+
}
|
|
1085
|
+
pause = Math.min(pause * 2, MAX_REATTACH_DELAY_MS);
|
|
1086
|
+
}
|
|
1087
|
+
}
|
|
1088
|
+
}
|
|
1089
|
+
/**
|
|
1090
|
+
* Opens a `turn.attach` stream replaying the run's events after `afterSeq`.
|
|
1091
|
+
* `timeoutMs` bounds only the request, not the stream it opens.
|
|
1092
|
+
*/
|
|
1093
|
+
async attachTurn(options, afterSeq, signal, timeoutMs) {
|
|
1094
|
+
const request = new AbortController();
|
|
1095
|
+
const timer = setTimeout(() => request.abort(new AttachTimeoutError()), Math.max(timeoutMs, 0));
|
|
1096
|
+
try {
|
|
1097
|
+
return await this.invokeRaw({
|
|
1098
|
+
payload: JSON.stringify({
|
|
1099
|
+
kind: "turn.attach",
|
|
1100
|
+
provider: this.providerFor(this.model),
|
|
1101
|
+
runId: options.runId,
|
|
1102
|
+
actorId: options.actorId,
|
|
1103
|
+
afterSeq,
|
|
1104
|
+
}),
|
|
1105
|
+
session: options.workspaceSessionKey ? "workspace" : "chat",
|
|
1106
|
+
access: options.access,
|
|
1107
|
+
signal: AbortSignal.any([signal, request.signal]),
|
|
1108
|
+
});
|
|
1109
|
+
}
|
|
1110
|
+
finally {
|
|
1111
|
+
clearTimeout(timer);
|
|
1112
|
+
}
|
|
1113
|
+
}
|
|
1114
|
+
async consume(body, signal, options, callbacks, callbackResults, cursor, attaching) {
|
|
827
1115
|
let failure;
|
|
828
|
-
const cleanup = new BuilderFailureDrain(
|
|
1116
|
+
const cleanup = new BuilderFailureDrain(signal);
|
|
829
1117
|
try {
|
|
830
|
-
for await (const event of BuilderRuntime.
|
|
831
|
-
if (
|
|
1118
|
+
for await (const { event, seq } of BuilderRuntime.readFrames(body, cleanup.signal)) {
|
|
1119
|
+
if (seq !== undefined) {
|
|
1120
|
+
if (seq <= cursor.seq)
|
|
1121
|
+
continue;
|
|
1122
|
+
cursor.seq = seq;
|
|
1123
|
+
}
|
|
1124
|
+
if (attaching &&
|
|
1125
|
+
event.type === "error" &&
|
|
1126
|
+
event.code &&
|
|
1127
|
+
ATTACH_REFUSALS.has(event.code))
|
|
1128
|
+
throw new AttachRefusedError(event.code);
|
|
1129
|
+
if (failure || options.signal.aborted) {
|
|
1130
|
+
// A finish confirms the runtime released its run before another
|
|
1131
|
+
// invocation.
|
|
1132
|
+
if (failure && event.type === "finish")
|
|
1133
|
+
cleanup.finish();
|
|
1134
|
+
// A workspace turn's end commits even when the turn failed or was
|
|
1135
|
+
// cancelled; its finish names that checkpoint.
|
|
1136
|
+
if (event.type === "finish" && event.workspace)
|
|
1137
|
+
await options.onEvent(event);
|
|
1138
|
+
continue;
|
|
1139
|
+
}
|
|
1140
|
+
if (event.type === "error") {
|
|
832
1141
|
failure = new BuilderRuntimeError(event.code ?? "INVOCATION_FAILED", event.reason, event.beforeTurn === true, event.runSubmitted === true);
|
|
833
1142
|
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
1143
|
continue;
|
|
840
|
-
|
|
1144
|
+
}
|
|
1145
|
+
try {
|
|
1146
|
+
await this.forwardEvent(event, options, callbacks, callbackResults);
|
|
1147
|
+
}
|
|
1148
|
+
catch (error) {
|
|
1149
|
+
// A cancel stopped this event; a workspace turn's stream is still
|
|
1150
|
+
// read for its finish, and any other stream is closed.
|
|
1151
|
+
if (!options.signal.aborted)
|
|
1152
|
+
throw error;
|
|
1153
|
+
}
|
|
841
1154
|
}
|
|
842
1155
|
}
|
|
843
1156
|
catch (error) {
|
|
844
|
-
|
|
1157
|
+
// The stream after an error matters only for that finish.
|
|
1158
|
+
if (!failure || signal.aborted)
|
|
845
1159
|
throw error;
|
|
846
1160
|
throw failure.withUnconfirmedCleanup(cleanup.outcome);
|
|
847
1161
|
}
|