aws-runtime-bridge 1.9.172 → 1.9.179
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +314 -0
- package/README.md +61 -2
- package/dist/adapter/AcodeSdkAdapter.d.ts +374 -1
- package/dist/adapter/AcodeSdkAdapter.js +3 -3
- package/dist/adapter/AdapterRegistry.d.ts +28 -0
- package/dist/adapter/ClaudeSdkAdapter.d.ts +71 -0
- package/dist/adapter/CodexSdkAdapter.d.ts +14 -0
- package/dist/adapter/OpencodeSdkAdapter.d.ts +44 -0
- package/dist/adapter/acode-tool-names.d.ts +9 -0
- package/dist/adapter/idle-poll-loop.d.ts +20 -0
- package/dist/adapter/index.d.ts +3 -0
- package/dist/adapter/instance-ai-config-resolver.d.ts +20 -0
- package/dist/adapter/prompts.d.ts +12 -0
- package/dist/adapter/types.d.ts +184 -0
- package/dist/browser/browser-bootstrap.d.ts +15 -0
- package/dist/browser/browser-connect-token.d.ts +11 -0
- package/dist/browser/browser-frame-encode.d.ts +32 -0
- package/dist/browser/browser-pool.d.ts +129 -0
- package/dist/browser/browser-profile-store.d.ts +41 -0
- package/dist/browser/browser-ws-bridge.d.ts +20 -0
- package/dist/browser/built-in-browser-tools.d.ts +44 -0
- package/dist/browser/element-locator.d.ts +25 -0
- package/dist/browser/element-picker.d.ts +30 -0
- package/dist/browser/frame-encode.d.ts +19 -0
- package/dist/browser/input-dispatcher.d.ts +35 -0
- package/dist/browser/listener-store.d.ts +44 -0
- package/dist/browser/page-listener-manager.d.ts +88 -0
- package/dist/browser/page-listener-types.d.ts +38 -0
- package/dist/browser/screencast-differ.d.ts +10 -0
- package/dist/browser/screencast-manager.d.ts +94 -0
- package/dist/browser/snapshot-serializer.d.ts +56 -0
- package/dist/browser/ssrf-guard.d.ts +44 -0
- package/dist/browser/stealth.d.ts +21 -0
- package/dist/browser/step-archive.d.ts +13 -0
- package/dist/browser/types.d.ts +100 -0
- package/dist/browser/ws-server.d.ts +54 -0
- package/dist/config.d.ts +138 -2
- package/dist/config.js +2 -2
- package/dist/desktop/built-in-desktop-tools.d.ts +68 -0
- package/dist/desktop/built-in-desktop-tools.js +2 -1
- package/dist/desktop/desktop-control.d.ts +142 -0
- package/dist/desktop/desktop-control.js +2 -0
- package/dist/desktop/desktop-mcp-client.d.ts +28 -0
- package/dist/desktop/desktop-staleness.d.ts +66 -0
- package/dist/desktop/desktop-staleness.js +2 -0
- package/dist/index.d.ts +4 -0
- package/dist/index.js +1 -1
- package/dist/middleware/auth.d.ts +26 -0
- package/dist/middleware/auth.js +1 -1
- package/dist/remote-desktop/computer-control.d.ts +3 -0
- package/dist/remote-desktop/coords.d.ts +6 -0
- package/dist/remote-desktop/frame-backpressure.d.ts +10 -0
- package/dist/remote-desktop/frame-encode.d.ts +3 -0
- package/dist/remote-desktop/index.js +2 -2
- package/dist/remote-desktop/input-dispatcher.d.ts +4 -0
- package/dist/remote-desktop/permission-manager.d.ts +3 -0
- package/dist/remote-desktop/screen-capture.d.ts +91 -0
- package/dist/remote-desktop/session-manager.d.ts +47 -0
- package/dist/remote-desktop/session-manager.js +1 -1
- package/dist/remote-desktop/system-backend.d.ts +64 -0
- package/dist/remote-desktop/types.d.ts +25 -0
- package/dist/remote-desktop/ui-automation.d.ts +11 -0
- package/dist/remote-desktop/win32-api.d.ts +10 -0
- package/dist/routes/acode-todos.d.ts +13 -0
- package/dist/routes/agent-state.d.ts +15 -0
- package/dist/routes/ai-sources.js +1 -1
- package/dist/routes/background-tasks.d.ts +18 -0
- package/dist/routes/background-tasks.js +2 -2
- package/dist/routes/bridge-temp-files.d.ts +1 -0
- package/dist/routes/bridge-temp-files.js +2 -0
- package/dist/routes/browser-listeners.d.ts +17 -0
- package/dist/routes/browser-sessions.d.ts +10 -0
- package/dist/routes/capabilities.js +1 -1
- package/dist/routes/dashboard-icon.d.ts +9 -0
- package/dist/routes/dashboard-icon.js +2 -0
- package/dist/routes/dashboard-theme.d.ts +24 -0
- package/dist/routes/dashboard-theme.js +157 -0
- package/dist/routes/dashboard.d.ts +9 -0
- package/dist/routes/dashboard.js +2021 -628
- package/dist/routes/debug-mount.d.ts +16 -0
- package/dist/routes/desktop-control.d.ts +15 -0
- package/dist/routes/desktop-control.js +2 -0
- package/dist/routes/events.d.ts +4 -0
- package/dist/routes/file-browser.d.ts +15 -10
- package/dist/routes/file-browser.js +1 -1
- package/dist/routes/file-change-diff.d.ts +25 -0
- package/dist/routes/file-diff-rollback.d.ts +28 -0
- package/dist/routes/file-snapshot.d.ts +7 -0
- package/dist/routes/git.d.ts +185 -0
- package/dist/routes/git.js +34 -34
- package/dist/routes/instance-tool-status.d.ts +5 -0
- package/dist/routes/instance.d.ts +8 -0
- package/dist/routes/instance.js +1 -1
- package/dist/routes/jdks.d.ts +4 -0
- package/dist/routes/launch.d.ts +5 -0
- package/dist/routes/lsp-providers.d.ts +11 -0
- package/dist/routes/lsp-providers.js +2 -0
- package/dist/routes/lsp.d.ts +41 -0
- package/dist/routes/lsp.js +4 -2
- package/dist/routes/mcp-extra.d.ts +15 -0
- package/dist/routes/mcp.d.ts +16 -0
- package/dist/routes/mcp.js +1 -1
- package/dist/routes/plugins.d.ts +19 -0
- package/dist/routes/plugins.js +1 -1
- package/dist/routes/processes.d.ts +4 -0
- package/dist/routes/properties.d.ts +4 -0
- package/dist/routes/pty.d.ts +29 -0
- package/dist/routes/runtime-binding.d.ts +3 -0
- package/dist/routes/sessions.d.ts +22 -0
- package/dist/routes/sessions.js +1 -1
- package/dist/routes/skills.d.ts +15 -0
- package/dist/routes/skills.js +1 -1
- package/dist/routes/sub-agents.d.ts +11 -0
- package/dist/routes/sub-agents.js +1 -1
- package/dist/routes/task-context.d.ts +5 -0
- package/dist/routes/tech-stack.d.ts +6 -0
- package/dist/routes/tech-stack.js +2 -0
- package/dist/routes/terminal.d.ts +122 -0
- package/dist/routes/terminal.js +22 -22
- package/dist/routes/workspace-index.d.ts +12 -0
- package/dist/routes/workspace-index.js +2 -0
- package/dist/routes/yml.d.ts +4 -0
- package/dist/scripts/migrate-user-scopes.d.ts +26 -0
- package/dist/scripts/migrate-user-scopes.js +2 -0
- package/dist/services/access-control.d.ts +21 -0
- package/dist/services/acode-bg-manager.d.ts +21 -0
- package/dist/services/acode-package.d.ts +10 -0
- package/dist/services/acode-package.js +1 -1
- package/dist/services/agent-capability-sync.d.ts +26 -0
- package/dist/services/agent-capability-sync.js +1 -1
- package/dist/services/agent-event-store.d.ts +20 -0
- package/dist/services/agent-ownership.d.ts +58 -0
- package/dist/services/agent-ownership.js +3 -0
- package/dist/services/agent-process-manager.d.ts +154 -0
- package/dist/services/agent-pty-manager.d.ts +39 -0
- package/dist/services/agent-pty-manager.js +5 -4
- package/dist/services/agent-startup-memory.d.ts +34 -0
- package/dist/services/agent-startup-memory.js +4 -4
- package/dist/services/ai-config-service.d.ts +26 -52
- package/dist/services/ai-config-service.js +1 -3
- package/dist/services/ai-source-apply.d.ts +7 -15
- package/dist/services/ai-source-apply.js +1 -1
- package/dist/services/auto-register.d.ts +165 -1
- package/dist/services/auto-register.js +1 -1
- package/dist/services/aws-client-agent-mcp.d.ts +14 -0
- package/dist/services/aws-client-agent-mcp.js +2 -2
- package/dist/services/bridge-package-publish-hooks.d.ts +14 -0
- package/dist/services/bridge-pairing.d.ts +82 -0
- package/dist/services/bridge-pairing.js +2 -0
- package/dist/services/bridge-temp-files.d.ts +65 -0
- package/dist/services/bridge-temp-files.js +2 -0
- package/dist/services/browser-session-manager.d.ts +71 -0
- package/dist/services/capability-config.d.ts +60 -15
- package/dist/services/capability-config.js +2 -2
- package/dist/services/change-cache-retention.d.ts +9 -0
- package/dist/services/changelog.d.ts +9 -0
- package/dist/services/cli-commands.d.ts +82 -0
- package/dist/services/cli-commands.js +6 -6
- package/dist/services/connection-key-rotation.d.ts +27 -0
- package/dist/services/connection-key-rotation.js +2 -0
- package/dist/services/debug-mount.d.ts +49 -0
- package/dist/services/desktop-mcp-manager.d.ts +103 -1
- package/dist/services/desktop-mcp-manager.js +1 -1
- package/dist/services/event-delta-pusher.d.ts +15 -0
- package/dist/services/fileSnapshotStore.d.ts +42 -0
- package/dist/services/fileSnapshotStore.js +1 -1
- package/dist/services/gitignore.d.ts +21 -0
- package/dist/services/gitignore.js +2 -0
- package/dist/services/instance-ai-config-service.d.ts +9 -0
- package/dist/services/instance-ai-config-service.js +1 -1
- package/dist/services/instance-features.d.ts +127 -0
- package/dist/services/instance-features.js +1 -1
- package/dist/services/instance-init-service.d.ts +3 -0
- package/dist/services/instance-init-service.js +1 -1
- package/dist/services/instance-state.d.ts +23 -0
- package/dist/services/jdk-scanner.d.ts +15 -0
- package/dist/services/launch-manager.d.ts +138 -0
- package/dist/services/launch-metrics.d.ts +42 -0
- package/dist/services/launch-streams.d.ts +19 -0
- package/dist/services/lifecycle-state.d.ts +5 -0
- package/dist/services/log-retention.d.ts +38 -0
- package/dist/services/log-retention.js +1 -1
- package/dist/services/lsp/install-manager.d.ts +55 -0
- package/dist/services/lsp/install-manager.js +2 -0
- package/dist/services/lsp/provider-registry.d.ts +108 -0
- package/dist/services/lsp/provider-registry.js +2 -0
- package/dist/services/lsp/uri-rewrite.d.ts +44 -0
- package/dist/services/lsp/uri-rewrite.js +2 -0
- package/dist/services/lsp-stdio-bridge.d.ts +41 -4
- package/dist/services/lsp-stdio-bridge.js +3 -3
- package/dist/services/mcp-deploy.d.ts +45 -4
- package/dist/services/mcp-deploy.js +4 -4
- package/dist/services/mcp-env-injector.d.ts +52 -0
- package/dist/services/mcp-launch-binding-queue.d.ts +12 -0
- package/dist/services/mcp-package.d.ts +22 -0
- package/dist/services/mcp-package.js +1 -1
- package/dist/services/mcp-probe-client.d.ts +19 -0
- package/dist/services/mcp-probe-client.js +1 -1
- package/dist/services/open-doc-events.d.ts +43 -0
- package/dist/services/open-doc-events.js +2 -0
- package/dist/services/open-doc-registry.d.ts +59 -0
- package/dist/services/open-doc-registry.js +2 -0
- package/dist/services/orphan-monitor.d.ts +43 -0
- package/dist/services/panel-auth.d.ts +24 -0
- package/dist/services/panel-env.d.ts +28 -0
- package/dist/services/plugin-deployment.d.ts +34 -1
- package/dist/services/plugin-deployment.js +2 -2
- package/dist/services/plugin-event-buffer.d.ts +21 -0
- package/dist/services/plugin-fs.d.ts +11 -0
- package/dist/services/plugin-handler-adapter.d.ts +13 -0
- package/dist/services/plugin-listener-runner.d.ts +10 -0
- package/dist/services/plugin-loader.d.ts +15 -0
- package/dist/services/plugin-manager.d.ts +95 -9
- package/dist/services/plugin-manager.js +4 -4
- package/dist/services/plugin-manifest.d.ts +14 -0
- package/dist/services/plugin-package.d.ts +13 -0
- package/dist/services/plugin-runtime.d.ts +15 -0
- package/dist/services/port-detector.d.ts +15 -0
- package/dist/services/process-detail.d.ts +3 -0
- package/dist/services/process-detector.d.ts +132 -0
- package/dist/services/process-registry.d.ts +120 -0
- package/dist/services/process-top.d.ts +6 -0
- package/dist/services/request-identity.d.ts +77 -0
- package/dist/services/request-identity.js +2 -0
- package/dist/services/request-invalid-dump.d.ts +4 -0
- package/dist/services/request-invalid-dump.js +1 -1
- package/dist/services/ring-buffer.d.ts +33 -0
- package/dist/services/runtime-binding.d.ts +56 -4
- package/dist/services/runtime-binding.js +4 -4
- package/dist/services/runtime-lifecycle-policy.d.ts +17 -0
- package/dist/services/runtime-resources-snapshot.d.ts +26 -0
- package/dist/services/runtime-resources-snapshot.js +2 -2
- package/dist/services/sdk-tool-file-change-recorder.d.ts +9 -0
- package/dist/services/session-output.d.ts +63 -0
- package/dist/services/session-output.js +3 -3
- package/dist/services/skill-manager.d.ts +42 -5
- package/dist/services/skill-manager.js +3 -3
- package/dist/services/snapshot-retention.d.ts +30 -0
- package/dist/services/snapshot-retention.js +2 -0
- package/dist/services/startup-config-wizard.d.ts +7 -1
- package/dist/services/startup-config-wizard.js +10 -10
- package/dist/services/system-metrics.d.ts +3 -0
- package/dist/services/tech-stack-scanner.d.ts +43 -0
- package/dist/services/tech-stack-scanner.js +2 -0
- package/dist/services/terminal-persistence.d.ts +43 -0
- package/dist/services/tool-installer.d.ts +12 -0
- package/dist/services/tunnel-client.d.ts +99 -2
- package/dist/services/tunnel-client.js +1 -1
- package/dist/services/update-log.d.ts +6 -0
- package/dist/services/update-notifier.d.ts +17 -0
- package/dist/services/update-notifier.js +2 -2
- package/dist/services/user-scope.d.ts +115 -0
- package/dist/services/user-scope.js +2 -0
- package/dist/services/windows-service-manager.d.ts +12 -0
- package/dist/services/workspace-files.d.ts +64 -0
- package/dist/services/workspace-index/index-manager.d.ts +46 -0
- package/dist/services/workspace-index/index-manager.js +2 -0
- package/dist/services/workspace-index/indexer.d.ts +15 -0
- package/dist/services/workspace-index/indexer.js +2 -0
- package/dist/services/workspace-index/query.d.ts +74 -0
- package/dist/services/workspace-index/query.js +5 -0
- package/dist/services/workspace-index/resolver.d.ts +26 -0
- package/dist/services/workspace-index/resolver.js +2 -0
- package/dist/services/workspace-index/types.d.ts +89 -0
- package/dist/services/workspace-index/types.js +2 -0
- package/dist/services/workspace-watch.d.ts +4 -0
- package/dist/services/workspaceTaskChangeWatcher.d.ts +49 -0
- package/dist/services/workspaceTaskChangeWatcher.js +2 -2
- package/dist/types.d.ts +9 -0
- package/dist/utils/config-write-queue.d.ts +11 -0
- package/dist/utils/env-safety.d.ts +21 -0
- package/dist/utils/file-utils.d.ts +15 -0
- package/dist/utils/instance-ai-config-debug-logger.d.ts +15 -0
- package/dist/utils/lifecycle-log.d.ts +5 -0
- package/dist/utils/logger.d.ts +13 -0
- package/dist/utils/logger.js +2 -1
- package/dist/utils/npm-version.d.ts +10 -0
- package/dist/utils/path-utils.d.ts +12 -0
- package/dist/utils/scheduler-url.d.ts +18 -0
- package/dist/utils/scheduler-url.js +2 -0
- package/dist/utils/sdk-package-loader.d.ts +13 -0
- package/dist/utils/sdk-package-loader.js +1 -1
- package/dist/utils/target-identity.d.ts +31 -0
- package/dist/utils/target-identity.js +2 -0
- package/dist/utils/validation.d.ts +17 -0
- package/dist/utils/yaml-utils.d.ts +48 -0
- package/package/acode/dist/__tests__/summary-request-helper.d.ts +12 -0
- package/package/acode/dist/__tests__/summary-request-helper.js +2 -0
- package/package/acode/dist/ask-user-question-tool.d.ts +17 -0
- package/package/acode/dist/await-complete-tool.d.ts +12 -0
- package/package/acode/dist/background-command-manager.d.ts +105 -0
- package/package/acode/dist/background-command-store.d.ts +27 -0
- package/package/acode/dist/background-command-tools.d.ts +8 -0
- package/package/acode/dist/background-output-ringbuffer.d.ts +15 -0
- package/package/acode/dist/built-in-file-tools.d.ts +65 -0
- package/package/acode/dist/built-in-symbols-tool.d.ts +3 -0
- package/package/acode/dist/builtins/commandArtifacts.d.ts +3 -0
- package/package/acode/dist/builtins/shellCommandPreparation.d.ts +17 -0
- package/package/acode/dist/builtins/shellCommandRunner.d.ts +4 -0
- package/package/acode/dist/builtins/shellOutputDecoder.d.ts +15 -0
- package/package/acode/dist/cache-control.d.ts +71 -0
- package/package/acode/dist/cache-control.js +2 -0
- package/package/acode/dist/commands/commandLoader.d.ts +3 -0
- package/package/acode/dist/commands/commandParser.d.ts +3 -0
- package/package/acode/dist/commands/commandRegistry.d.ts +3 -0
- package/package/acode/dist/compaction.d.ts +388 -4
- package/package/acode/dist/compaction.js +19 -17
- package/package/acode/dist/config.d.ts +3 -0
- package/package/acode/dist/context-overflow.d.ts +32 -0
- package/package/acode/dist/fs-utils.d.ts +18 -0
- package/package/acode/dist/hooks/hookBus.d.ts +3 -0
- package/package/acode/dist/image-utils.d.ts +35 -0
- package/package/acode/dist/index.d.ts +1 -0
- package/package/acode/dist/index.js +1 -1
- package/package/acode/dist/mcpToolNames.d.ts +32 -0
- package/package/acode/dist/microcompact.d.ts +110 -0
- package/package/acode/dist/microcompact.js +2 -0
- package/package/acode/dist/parsers/ast-cache.d.ts +41 -0
- package/package/acode/dist/parsers/file-index.d.ts +83 -0
- package/package/acode/dist/parsers/file-index.js +4 -0
- package/package/acode/dist/parsers/language-detector.d.ts +4 -0
- package/package/acode/dist/parsers/tree-sitter-loader.d.ts +12 -0
- package/package/acode/dist/parsers/types.d.ts +11 -0
- package/package/acode/dist/paths.d.ts +14 -0
- package/package/acode/dist/plugin-types.d.ts +34 -0
- package/package/acode/dist/read-file-state.d.ts +15 -0
- package/package/acode/dist/runtime-environment.d.ts +16 -0
- package/package/acode/dist/runtime.d.ts +828 -9
- package/package/acode/dist/runtime.js +40 -33
- package/package/acode/dist/skill-tool.d.ts +20 -0
- package/package/acode/dist/sub-agent-manager.d.ts +169 -0
- package/package/acode/dist/sub-agent-manager.js +1 -1
- package/package/acode/dist/sub-agent-store.d.ts +50 -0
- package/package/acode/dist/sub-agent-tools.d.ts +15 -0
- package/package/acode/dist/sub-agent-types.d.ts +13 -0
- package/package/acode/dist/terminal-tool.d.ts +15 -0
- package/package/acode/dist/terminal-types.d.ts +10 -0
- package/package/acode/dist/todo-store.d.ts +15 -0
- package/package/acode/dist/token-estimator.d.ts +32 -0
- package/package/acode/dist/token-estimator.js +2 -0
- package/package/acode/dist/tool-allocation.d.ts +113 -0
- package/package/acode/dist/tool-concurrency/index.d.ts +8 -0
- package/package/acode/dist/tool-concurrency/observability.d.ts +32 -0
- package/package/acode/dist/tool-concurrency/resource-lock.d.ts +30 -0
- package/package/acode/dist/tool-concurrency/scheduler.d.ts +19 -0
- package/package/acode/dist/tool-concurrency/types.d.ts +57 -0
- package/package/acode/dist/tool-group-manager.d.ts +195 -0
- package/package/acode/dist/tool-group-manager.js +4 -4
- package/package/acode/dist/types.d.ts +192 -0
- package/package/aws-client-agent-mcp/README.md +130 -215
- package/package/aws-client-agent-mcp/dist/ability-market-tools.d.ts +57 -0
- package/package/aws-client-agent-mcp/dist/ability-market-tools.js +1 -1
- package/package/aws-client-agent-mcp/dist/agent-client.d.ts +290 -3
- package/package/aws-client-agent-mcp/dist/agent-client.js +1 -1
- package/package/aws-client-agent-mcp/dist/config.d.ts +18 -0
- package/package/aws-client-agent-mcp/dist/constants.d.ts +2 -0
- package/package/aws-client-agent-mcp/dist/context-manager.d.ts +70 -0
- package/package/aws-client-agent-mcp/dist/http-client.d.ts +61 -0
- package/package/aws-client-agent-mcp/dist/index.d.ts +10 -0
- package/package/aws-client-agent-mcp/dist/logger.d.ts +24 -0
- package/package/aws-client-agent-mcp/dist/mcp-server.d.ts +610 -0
- package/package/aws-client-agent-mcp/dist/mcp-server.js +25 -23
- package/package/aws-client-agent-mcp/dist/mcp-tools.d.ts +158 -0
- package/package/aws-client-agent-mcp/dist/mcp-tools.js +38 -22
- package/package/aws-client-agent-mcp/dist/memory-store.d.ts +102 -2
- package/package/aws-client-agent-mcp/dist/memory-store.js +27 -2
- package/package/aws-client-agent-mcp/dist/memory-tools.d.ts +18 -0
- package/package/aws-client-agent-mcp/dist/memory-tools.js +13 -9
- package/package/aws-client-agent-mcp/dist/message-buffer.d.ts +86 -0
- package/package/aws-client-agent-mcp/dist/messageContent.d.ts +24 -0
- package/package/aws-client-agent-mcp/dist/office/office-equation.d.ts +19 -0
- package/package/aws-client-agent-mcp/dist/office/office-image.d.ts +18 -0
- package/package/aws-client-agent-mcp/dist/office/office-workspace.d.ts +29 -0
- package/package/aws-client-agent-mcp/dist/parent-lifecycle.d.ts +18 -0
- package/package/aws-client-agent-mcp/dist/runtime-launch-binding.d.ts +6 -0
- package/package/aws-client-agent-mcp/dist/server-memory-store.d.ts +5 -1
- package/package/aws-client-agent-mcp/dist/server-memory-store.js +1 -1
- package/package/aws-client-agent-mcp/dist/status-reporter.d.ts +41 -0
- package/package/aws-client-agent-mcp/dist/tool-groups.d.ts +136 -0
- package/package/aws-client-agent-mcp/dist/types.d.ts +174 -0
- package/package/aws-client-agent-mcp/dist/watchdog.d.ts +7 -0
- package/package/aws-client-agent-mcp/dist/websocket-client.d.ts +108 -0
- package/package.json +1 -1
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import m from"node:crypto";import
|
|
1
|
+
import m from"node:crypto";import c from"node:fs";import a from"node:path";import{getRuntimeHomeDir as T}from"../config.js";import{createLogger as U}from"../utils/logger.js";import{normalizeSchedulerUrl as F}from"../utils/scheduler-url.js";import{buildTargetKey as I,fingerprintUserKey as H}from"../utils/target-identity.js";const g=U("runtime-binding"),A="sha256",b=K();function K(){const e=m.randomInt(0,1e6);return String(e).padStart(6,"0").replace(/(\d{3})(\d{3})/,"$1-$2")}function d(){return a.join(T(),".aws-bridge")}function h(){return a.join(d(),"binding.json")}function S(){return a.join(d(),"runtime-tokens.properties")}function w(e){return m.createHash(A).update(e,"utf8").digest("hex")}function E(e,n){const t=Buffer.from(e,"hex"),r=Buffer.from(n,"hex");return t.length!==r.length?!1:m.timingSafeEqual(t,r)}function O(e,n){const t=Buffer.from(e,"utf8"),r=Buffer.from(n,"utf8");return t.length!==r.length?!1:m.timingSafeEqual(t,r)}function p(e){return String(e||"").trim()}function f(e){return F(e)}function M(){return b}function W(){return h()}function G(){return S()}function y(e){const n=f(e);if(n)return n;const t=String(e||"").trim();return t?t.replace(/\/+$/,"").toLowerCase():""}function R(e){const n=y(e);if(!n)throw new Error("serverBaseUrl is required to build runtime token key");return m.createHash("md5").update(n,"utf8").digest("hex")}function x(e,n){const t=y(e);if(!t)throw new Error("serverBaseUrl is required to build runtime token key");return I(t,n)}function k(){const e=new Map;try{const n=c.readFileSync(S(),"utf8");for(const t of n.split(/\r?\n/)){const r=t.trim();if(!r||r.startsWith("#"))continue;const i=r.indexOf("=");if(i<=0)continue;const o=r.slice(0,i).trim(),s=r.slice(i+1).trim();o&&s&&e.set(o,s)}}catch{}return e}function B(e){c.mkdirSync(d(),{recursive:!0});const n=[...e.entries()].sort(([t],[r])=>t.localeCompare(r)).map(([t,r])=>`${t}=${r}`);c.writeFileSync(S(),`${n.join(`
|
|
2
2
|
`)}
|
|
3
|
-
`,{encoding:"utf8",mode:384})}function
|
|
4
|
-
`,{encoding:"utf8",mode:384}),
|
|
5
|
-
`,{encoding:"utf8",mode:384}),g.info("[runtime-bridge] runtime binding cleared")}function
|
|
3
|
+
`,{encoding:"utf8",mode:384})}function j(e){const n=p(e.accessToken);if(n.length<16)throw new Error("accessToken must be at least 16 characters");const t=x(e.serverBaseUrl,e.userKey),r=k();return r.set(t,n),B(r),t}function D(e,n){if(e)try{const t=k(),r=x(e,n),i=t.get(r);if(i)return i;if(!!String(n||"").trim())return;const s=v(e);return s.length===1?s[0].accessToken:s.length>1?void 0:t.get(R(e))}catch{return}}function v(e){const n=y(e);if(!n)return[];const t=[],r=`${n}#`;for(const[i,o]of k().entries())i.startsWith(r)&&t.push({userKeyFingerprint:i.slice(r.length),accessToken:o});return t}function Q(e,n){if(!e)return!1;try{const t=k(),r=t.delete(x(e,n)),i=String(n||"").trim()?!1:t.delete(R(e));return(r||i)&&B(t),r||i}catch{return!1}}function q(e){if(!e)return!1;for(const n of k().values())if(O(e,n))return!0;return!1}function l(){try{const e=c.readFileSync(h(),"utf8"),n=JSON.parse(e);if(n?.status==="paired"&&n.tokenHash)return{...n,schedulerBaseUrl:f(n.schedulerBaseUrl)||n.schedulerBaseUrl}}catch{}return{status:"unpaired"}}function V(){const e=l(),n={...e};return delete n.tokenHash,delete n.accessToken,{...n,paired:e.status==="paired"}}function X(){const e=l();return e.status==="paired"&&!!e.tokenHash}function Y(e){const n=p(e);if(!n)return!1;const t=l();return t.status==="paired"&&t.tokenHash&&E(w(n),t.tokenHash)?!0:q(n)}function Z(e,n){const t=D(e,n);if(t)return t;const r=l();if(r.status==="paired"){if(e){const i=f(e),o=f(r.schedulerBaseUrl);if(i&&o&&i===o){if(String(n||"").trim()){const s=v(i),u=new Set(s.map($=>$.userKeyFingerprint));if(u.size>1&&!u.has(H(n)))return}return p(r.accessToken)||void 0}return}return p(r.accessToken)||void 0}}function ee(e){return String(e||"").trim()===b}function ne(e){const n=p(e.accessToken);if(n.length<16)throw new Error("accessToken must be at least 16 characters");const t=l(),r=f(e.schedulerBaseUrl)||f(t.schedulerBaseUrl),i=new Date().toISOString(),o={status:"paired",instanceId:e.instanceId?String(e.instanceId):t.instanceId,userId:e.userId?String(e.userId):t.userId,schedulerBaseUrl:r,accessToken:n,tokenHash:w(n),createdAt:t.createdAt||i,updatedAt:i};if(c.mkdirSync(d(),{recursive:!0}),c.writeFileSync(h(),`${JSON.stringify(o,null,2)}
|
|
4
|
+
`,{encoding:"utf8",mode:384}),o.schedulerBaseUrl){const s=j({serverBaseUrl:o.schedulerBaseUrl,accessToken:n,userKey:e.userKey});g.info(`[runtime-bridge] scoped runtime token saved: key=${s}`+(e.userKey?` (userKey=****${String(e.userKey).slice(-4)})`:""))}return g.info(`[runtime-bridge] runtime binding saved: ${h()}`),o}function te(){const n={...l(),status:"unpaired",accessToken:void 0,tokenHash:void 0,revokedAt:new Date().toISOString(),updatedAt:new Date().toISOString()};c.mkdirSync(d(),{recursive:!0}),c.writeFileSync(h(),`${JSON.stringify(n,null,2)}
|
|
5
|
+
`,{encoding:"utf8",mode:384}),g.info("[runtime-bridge] runtime binding cleared")}function re(){const e=T(),n=a.join(e,".agentswork","runtime-bridge"),t=d();if(n===t||!c.existsSync(n))return;const r=["binding.json","runtime-tokens.properties"];let i=0;for(const o of r){const s=a.join(n,o),u=a.join(t,o);if(c.existsSync(s)&&!c.existsSync(u)){c.mkdirSync(t,{recursive:!0}),c.copyFileSync(s,u);try{c.chmodSync(u,384)}catch{}i++,g.info(`[runtime-bridge] \u5DF2\u8FC1\u79FB ${s} \u2192 ${u}`)}}i>0&&g.info(`[runtime-bridge] \u5DF2\u8FC1\u79FB ${i} \u4E2A\u914D\u7F6E\u6587\u4EF6\u4ECE ${n} \u5230 ${t}`)}export{R as buildLegacyRuntimeTokenKey,x as buildRuntimeTokenKey,te as clearRuntimeBinding,Q as clearScopedRuntimeAccessToken,Z as getRuntimeAccessToken,W as getRuntimeBindingFilePath,V as getRuntimeBindingPublicState,M as getRuntimePairingCode,G as getRuntimeTokenStoreFilePath,D as getScopedRuntimeAccessToken,X as hasRuntimeBinding,v as listScopedRuntimeAccessTokens,l as loadRuntimeBinding,re as migrateOldBindingDir,f as normalizeSchedulerBaseUrl,ne as saveRuntimeBinding,j as saveScopedRuntimeAccessToken,Y as validateRuntimeBindingToken,ee as validateRuntimePairingCode};
|
|
6
6
|
|
|
@@ -8,8 +8,25 @@ export interface GracefulShutdownPlan {
|
|
|
8
8
|
stopTunnelClient: boolean;
|
|
9
9
|
}
|
|
10
10
|
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
|
|
11
20
|
export declare function buildGracefulShutdownPlan(preserveSessions: boolean): GracefulShutdownPlan;
|
|
12
21
|
|
|
22
|
+
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
|
|
13
26
|
export declare function shouldCleanupPersistedSessionsOnStartup(preserveSessions: boolean, env?: NodeJS.ProcessEnv): boolean;
|
|
14
27
|
|
|
28
|
+
|
|
29
|
+
|
|
30
|
+
|
|
31
|
+
|
|
15
32
|
export declare function shouldAutoCleanOrphanProcesses(env?: NodeJS.ProcessEnv): boolean;
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import
|
|
2
|
-
`)}async function
|
|
1
|
+
import m from"axios";import{getBrowserPool as f}from"../browser/browser-pool.js";import{resolveSchedulerBaseUrl as p}from"../config.js";import{ptySessions as g}from"../routes/pty.js";import{createLogger as $}from"../utils/logger.js";import{getAcodeBgManager as h}from"./acode-bg-manager.js";import{agentPtyManager as w}from"./agent-pty-manager.js";import{listOpenDocuments as b}from"./open-doc-registry.js";import{getRuntimeAccessToken as l}from"./runtime-binding.js";import{subAgentManager as k}from"./sub-agent-manager-instance.js";const i=$("runtime-resources"),S=3e3,a=20,y={pencil:"open pencil canvas",draw:"open draw diagram",office:"open office document"};function c(t,e){const n=String(t??"").replace(/\s+/g," ").trim();return n.length>e?`${n.slice(0,e)}\u2026`:n}function D(t){if(typeof t!="number"||!Number.isFinite(t)||t<=0)return"";const e=new Date(t),n=r=>String(r).padStart(2,"0");return`${n(e.getHours())}:${n(e.getMinutes())}`}async function v(t){try{const e=await h();return e?.listTasksWithReconcile?(await e.listTasksWithReconcile(t,"running")).filter(r=>r.status==="running").slice(0,a).map(r=>{const o=D(r.startedAt),s=r.description?c(r.description,60):c(r.commandPreview||r.command,80);return{kind:"background commands",text:`${r.taskId} \`${s}\`${o?` (since ${o})`:""}`}}):[]}catch(e){return i.warn(`collect background commands failed: ${e?.message}`),[]}}function x(t){try{const e=[];let n=[];try{n=w.listWaitingForInput(t)}catch(o){i.warn(`collect terminals waiting-input failed: ${o?.message}`)}const r=new Set(n);for(const o of g.values()){if(o.ownerUserId!==t||o.status!=="running")continue;if(e.length>=a)break;const s=c(o.title||o.shell,60),d=r.has(o.id)?"running, waiting for input":"running";e.push({kind:"terminals",text:`${o.id} ${s} (${d})`})}return e}catch(e){return i.warn(`collect terminals failed: ${e?.message}`),[]}}function A(t){try{return k.listActiveByParent(t).slice(0,a).map(n=>({kind:"sub-agents",text:`${n.subId} ${n.subagentType} "${c(n.description,60)}" (running)`}))}catch(e){return i.warn(`collect sub-agents failed: ${e?.message}`),[]}}function T(t){try{return f().listSessions(t).slice(0,a).map(n=>{const r=c(n.title||n.browserId,40),o=c(n.currentUrl,80);return{kind:"browsers",text:`${c(n.browserId,40)} "${r}"${o?` ${o}`:""}`}})}catch(e){return i.warn(`collect browsers failed: ${e?.message}`),[]}}function M(t){try{return b(t).map(e=>{const n=e.docId?`${e.docId} `:"",r=e.detail?` (${e.detail})`:"";return{kind:y[e.kind],text:`${n}${e.name}${r}`}})}catch(e){return i.warn(`collect open documents failed: ${e?.message}`),[]}}function u(t,e){if(!Array.isArray(e))return[];const n=[];for(const r of e){if(n.length>=a)break;const o=c(String(r?.name??r?.docId??""),60);if(!o)continue;const s=String(r?.permission??"").trim();n.push({kind:t,text:`${o}${s?` (${s})`:""}`})}return n}async function R(t){try{const{url:e}=p();if(!e)return[];const n=l(e)||l();if(!n)return[];const o=(await m.get(`${e}/api/runtime/agent-resources`,{params:{agentId:t},headers:{"X-Runtime-Token":n},timeout:S})).data??{};return[...u("office docs",o.officeDocs),...u("pencil docs",o.pencilDocs),...u("draw docs",o.drawDocs)]}catch(e){return i.warn(`collect java docs failed (office/pencil/draw omitted): agentId=${t}, error=${e?.message}`),[]}}function _(t){const e=new Map;for(const r of t){const o=e.get(r.kind);o?o.push(r.text):e.set(r.kind,[r.text])}const n=["[Runtime resources \u2014 live snapshot taken after context compaction.]","These already exist and are still running/available. Reuse them instead of creating duplicates","(do not start another dev server, open another browser, or redraw an existing document).","Details (output, page content, document body) are not included \u2014 query them when needed."];for(const[r,o]of e)n.push(`- ${r} (${o.length}): ${o.join("; ")}`);return n.join(`
|
|
2
|
+
`)}async function W(t){if(!t)return null;try{const[e,n]=await Promise.all([v(t),R(t)]),r=[...e,...x(t),...A(t),...T(t),...M(t),...n];if(r.length===0)return null;const o=_(r);return i.debug(`snapshot built for agentId=${t}: ${r.length} entries (${[...new Set(r.map(s=>s.kind))].join(", ")})`),o}catch(e){return i.warn(`build snapshot failed: ${e?.message}`),null}}export{W as buildRuntimeResourcesSnapshot};
|
|
3
3
|
|
|
@@ -1,9 +1,18 @@
|
|
|
1
1
|
import { type ProviderEvent } from "../adapter/types.js";
|
|
2
2
|
|
|
3
|
+
|
|
4
|
+
|
|
5
|
+
|
|
3
6
|
export declare function onSdkToolUseStart(sessionId: string, toolUseId: string | undefined, toolInput: Record<string, unknown> | undefined, toolName?: string, workspacePath?: string): void;
|
|
4
7
|
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
|
|
5
11
|
export declare function forgetSession(sessionId: string): void;
|
|
6
12
|
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
|
|
7
16
|
export declare function onSdkToolUseEnd(event: ProviderEvent, entry: {
|
|
8
17
|
sessionId: string;
|
|
9
18
|
agentId: string;
|
|
@@ -1,11 +1,23 @@
|
|
|
1
1
|
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
|
|
5
|
+
|
|
2
6
|
import { type AxiosResponse } from "axios";
|
|
3
7
|
import type { RuntimeToolBatchMetrics } from "../adapter/types.js";
|
|
4
8
|
import type { Session } from "../types.js";
|
|
5
9
|
import { RingBuffer, type RingBufferEntry, type RingBufferSlice } from "./ring-buffer.js";
|
|
6
10
|
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
|
|
7
14
|
export type BridgeEventCategory = "status" | "output" | "question" | "file_changed";
|
|
8
15
|
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
|
|
9
21
|
export interface BridgeEventPayload {
|
|
10
22
|
readonly category: BridgeEventCategory;
|
|
11
23
|
readonly agentId: string;
|
|
@@ -44,6 +56,11 @@ export interface BridgeEventPayload {
|
|
|
44
56
|
|
|
45
57
|
export type { RingBufferEntry, RingBufferSlice };
|
|
46
58
|
|
|
59
|
+
|
|
60
|
+
|
|
61
|
+
|
|
62
|
+
|
|
63
|
+
|
|
47
64
|
export declare const bridgeEventBuffer: RingBuffer<BridgeEventPayload>;
|
|
48
65
|
interface RuntimeStatusActionInfo {
|
|
49
66
|
actionType?: string;
|
|
@@ -68,6 +85,12 @@ export interface RuntimeCallbackAuthOptions {
|
|
|
68
85
|
export interface RuntimeOutputMetadata {
|
|
69
86
|
sourceEventType?: string;
|
|
70
87
|
|
|
88
|
+
|
|
89
|
+
|
|
90
|
+
|
|
91
|
+
|
|
92
|
+
|
|
93
|
+
|
|
71
94
|
skipLocalPersist?: boolean;
|
|
72
95
|
logLevel?: "info" | "warn" | "error";
|
|
73
96
|
logMessage?: string;
|
|
@@ -81,6 +104,13 @@ export interface RuntimeOutputMetadata {
|
|
|
81
104
|
|
|
82
105
|
export declare const sessions: Map<string, Session>;
|
|
83
106
|
|
|
107
|
+
|
|
108
|
+
|
|
109
|
+
|
|
110
|
+
|
|
111
|
+
|
|
112
|
+
|
|
113
|
+
|
|
84
114
|
export declare function sendStatus(agentId: string, sessionId: string | null, status: string, actionInfo?: RuntimeStatusActionInfo, usage?: {
|
|
85
115
|
inputTokens: number;
|
|
86
116
|
outputTokens: number;
|
|
@@ -94,8 +124,23 @@ export declare function sendStatus(agentId: string, sessionId: string | null, st
|
|
|
94
124
|
cacheMissTokens?: number;
|
|
95
125
|
}, authOptions?: RuntimeCallbackAuthOptions, timestamp?: number, sourceEventType?: string): Promise<AxiosResponse<unknown> | undefined>;
|
|
96
126
|
|
|
127
|
+
|
|
128
|
+
|
|
129
|
+
|
|
130
|
+
|
|
131
|
+
|
|
132
|
+
|
|
133
|
+
|
|
97
134
|
export declare function sendOutput(agentId: string, output: string, sessionId: string, seq: number, metadata?: RuntimeOutputMetadata, authOptions?: RuntimeCallbackAuthOptions, signal?: AbortSignal): Promise<void>;
|
|
98
135
|
|
|
136
|
+
|
|
137
|
+
|
|
138
|
+
|
|
139
|
+
|
|
140
|
+
|
|
141
|
+
|
|
142
|
+
|
|
143
|
+
|
|
99
144
|
export declare function sendQuestionRequest(agentId: string, sessionId: string, questions: unknown[], authOptions?: RuntimeCallbackAuthOptions, toolCallId?: string): Promise<void>;
|
|
100
145
|
export interface RuntimeFileChangedPayload {
|
|
101
146
|
bridgeBaseUrl?: string;
|
|
@@ -114,12 +159,30 @@ export interface ToolAuthRequestPayload {
|
|
|
114
159
|
operation?: string;
|
|
115
160
|
}
|
|
116
161
|
|
|
162
|
+
|
|
163
|
+
|
|
164
|
+
|
|
165
|
+
|
|
117
166
|
export declare function sendToolAuthRequest(agentId: string, sessionId: string, request: ToolAuthRequestPayload, authOptions?: RuntimeCallbackAuthOptions): Promise<void>;
|
|
118
167
|
|
|
168
|
+
|
|
169
|
+
|
|
119
170
|
export declare function sendFileChanged(payload: RuntimeFileChangedPayload): Promise<void>;
|
|
120
171
|
|
|
172
|
+
|
|
173
|
+
|
|
174
|
+
|
|
175
|
+
|
|
121
176
|
export declare function appendSessionOutput(sessionId: string, data: string): void;
|
|
122
177
|
|
|
178
|
+
|
|
179
|
+
|
|
180
|
+
|
|
181
|
+
|
|
123
182
|
export declare function scheduleOutputFlush(sessionId: string): void;
|
|
124
183
|
|
|
184
|
+
|
|
185
|
+
|
|
186
|
+
|
|
187
|
+
|
|
125
188
|
export declare function flushSessionOutput(sessionId: string): Promise<void>;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import
|
|
2
|
-
${
|
|
1
|
+
import m from"axios";import{resolveSchedulerBaseUrlFrom as H}from"../config.js";import{requestRuntimeAccessTokenRefreshForServer as P,resolveTargetIdentityFromToken as C}from"../services/auto-register.js";import{logger as d}from"../utils/logger.js";import{agentEventStore as S}from"./agent-event-store.js";import{scheduleEventPush as $}from"./event-delta-pusher.js";import{RingBuffer as O}from"./ring-buffer.js";import{getRuntimeAccessToken as _}from"./runtime-binding.js";const B=new O(2e3);function k(t,n=b(t)){const c=t?.runtimeAccessToken||_(n)||_();return c?{"X-Runtime-Token":c}:void 0}function x(t){if(t)return{schedulerBaseUrl:t.schedulerBaseUrl}}function b(t){return H(t?.schedulerBaseUrl).url}const D=100;function w(t){if(typeof t!="object"||t===null)return;const n=t.response;if(typeof n!="object"||n===null)return;const c=n.status;return typeof c=="number"?c:void 0}let R=null;async function L(t,n){if(R)return R;R=(async()=>{try{const c=n?C(n)?.identityKey:void 0,e=await P(t,c);return e.success&&e.runtimeAccessToken?(d.info("[session-output] Runtime token refreshed after 401"),!0):(d.warn("[session-output] Runtime token refresh failed",{error:e.error}),!1)}catch(c){return d.warn("[session-output] Runtime token refresh threw",{error:c}),!1}})();try{return await R}finally{R=null}}const E=8e3,M=64*1024,g=32*1024,v=15e3,U=new Map;async function V(t,n,c,e,r,o,a,l){const i={agentId:t,sessionId:n,status:c};a!==void 0&&(i.timestamp=a),e&&(e.actionType&&(i.actionType=e.actionType),e.actionLabel&&(i.actionLabel=e.actionLabel),e.actionDetail&&(i.actionDetail=e.actionDetail),e.actionInput&&(i.actionInput=e.actionInput),e.actionResult&&(i.actionResult=e.actionResult),e.actionError&&(i.actionError=e.actionError),e.actionId&&(i.actionId=e.actionId),e.parentId&&(i.parentId=e.parentId),e.batchId&&(i.batchId=e.batchId),e.batchMetrics&&(i.batchMetrics=e.batchMetrics)),r&&(i.inputTokens=r.inputTokens,i.outputTokens=r.outputTokens,r.contextLimit&&(i.contextLimit=r.contextLimit),r.maxOutput&&(i.maxOutput=r.maxOutput),r.inputLimit&&(i.inputLimit=r.inputLimit),r.compactionThreshold&&(i.compactionThreshold=r.compactionThreshold),r.cacheHitTokens!==void 0&&(i.cacheHitTokens=r.cacheHitTokens),r.cacheMissTokens!==void 0&&(i.cacheMissTokens=r.cacheMissTokens)),l&&(i.sourceEventType=l),process.env.ACODE_TOKEN_DEBUG==="1"&&(i.inputTokens!==void 0||i.outputTokens!==void 0||i.cacheHitTokens!==void 0||i.cacheMissTokens!==void 0)&&console.log(`[TokenDebug][SendStatus] status=${c} inputTokens=${i.inputTokens??"(none)"} outputTokens=${i.outputTokens??"(none)"} cacheHitTokens=${i.cacheHitTokens??"(none)"} cacheMissTokens=${i.cacheMissTokens??"(none)"} contextLimit=${i.contextLimit??"(none)"} actionType=${i.actionType??"(none)"}`);const s=b(o),f=k(o,s);if(!f){d.warn("Skip runtime status callback because runtime token is missing",{agentId:t,sessionId:n,status:c,schedulerBaseUrl:s});return}const T=e?.actionType==="context_compaction";T&&d.info("[compaction-diag] sendStatus enter",{agentId:t,sessionId:n,status:c,actionId:e?.actionId,parentId:e?.parentId,actionLabel:e?.actionLabel});try{const u=await m.post(`${s}/api/runtime/callback/status`,i,{headers:f,timeout:15e3});if(T){const p=u?.data;d.info("[compaction-diag] sendStatus success",{agentId:t,actionId:e?.actionId,actionLabel:e?.actionLabel,httpStatus:u?.status,ignored:p?.ignored,responseBody:p})}return u}catch(u){if(w(u)===401&&await L(s,f?.["X-Runtime-Token"])){const y=k(x(o),s);if(y)try{const h=await m.post(`${s}/api/runtime/callback/status`,i,{headers:y,timeout:15e3});if(T){const A=h?.data;d.info("[compaction-diag] sendStatus retry success",{agentId:t,actionId:e?.actionId,actionLabel:e?.actionLabel,httpStatus:h?.status,ignored:A?.ignored})}return h}catch(h){d.warn("Runtime status callback retry failed after token refresh",{agentId:t,sessionId:n,status:c,error:h});return}}d.warn("Runtime status callback failed",{agentId:t,sessionId:n,status:c,schedulerBaseUrl:s,error:u});return}finally{const u={category:"status",agentId:t,sessionId:n,status:c,actionType:e?.actionType,actionLabel:e?.actionLabel,actionDetail:e?.actionDetail,actionInput:e?.actionInput,actionResult:e?.actionResult,actionError:e?.actionError,actionId:e?.actionId,parentId:e?.parentId,batchId:e?.batchId,batchMetrics:e?.batchMetrics,inputTokens:r?.inputTokens,outputTokens:r?.outputTokens,cacheHitTokens:r?.cacheHitTokens,cacheMissTokens:r?.cacheMissTokens,sourceEventType:l};B.append(u);const p=S.append(t,u);$(t,p,o)}}async function F(t,n,c,e,r,o,a){const l=b(o),i=k(o,l);try{if(!i){d.warn("Skip runtime output callback because runtime token is missing",{agentId:t,sessionId:c,schedulerBaseUrl:l});return}const s={headers:i,timeout:v};a&&(s.signal=a),await m.post(`${l}/api/runtime/callback/output`,{agentId:t,output:n,sessionId:c,seq:e,...r},s)}catch(s){if(a?.aborted||s?.name==="AbortError"||s?.code==="ERR_CANCELED")throw s;if(w(s)===401&&await L(l,i?.["X-Runtime-Token"])){const T=k(x(o),l);if(T)try{const u={headers:T,timeout:v};a&&(u.signal=a),await m.post(`${l}/api/runtime/callback/output`,{agentId:t,output:n,sessionId:c,seq:e,...r},u);return}catch{}}throw d.warn("Runtime output callback failed",{agentId:t,sessionId:c,error:s}),s}finally{if(!r?.skipLocalPersist){const s=n.length>E?`...(truncated)
|
|
2
|
+
${n.slice(-E)}`:n,f={category:"output",agentId:t,sessionId:c,output:s,seq:e,sourceEventType:r?.sourceEventType,logLevel:r?.logLevel,logCategory:r?.logCategory};B.appendOrMerge(f,u=>{const p=u.data;if(p.category!=="output"||p.sessionId!==c||p.sourceEventType!==r?.sourceEventType||Date.now()-u.timestamp>1e4)return!1;const y=(p.output||"").length,h=(f.output||"").length;return y+h<=E},(u,p)=>{const y=u.output||"",h=p.output||"";return y.includes(h)?u:{...u,output:`${y}${h}`}});const T=S.appendOrMergeOutput(t,f);$(t,T,o)}}}async function Y(t,n,c,e,r){const o=b(e),a={agentId:t,sessionId:n,questions:c,...r?{toolCallId:r}:{}},l=k(e,o);try{if(!l)return;await m.post(`${o}/api/runtime/callback/question`,a,{headers:l})}catch(i){if(w(i)===401&&await L(o,l?.["X-Runtime-Token"])){const f=k(x(e),o);if(f)try{await m.post(`${o}/api/runtime/callback/question`,a,{headers:f});return}catch{}}}finally{const i={category:"question",agentId:t,sessionId:n,...r?{toolCallId:r}:{},questions:c};B.append(i);const s=S.append(t,i);$(t,s,e)}}async function Z(t,n,c,e){const r=b(e),o={agentId:t,sessionId:n,...c},a=k(e,r);try{if(!a)return;await m.post(`${r}/api/runtime/callback/tool-auth`,o,{headers:a})}catch(l){if(w(l)===401&&await L(r,a?.["X-Runtime-Token"])){const s=k(x(e),r);if(s)try{await m.post(`${r}/api/runtime/callback/tool-auth`,o,{headers:s});return}catch{}}}}async function I(t){const n=b(),c=k(void 0,n);try{if(!c)return;await m.post(`${n}/api/runtime/callback/file-changed`,t,{headers:c})}catch(e){if(w(e)===401&&await L(n,c?.["X-Runtime-Token"])){const o=k(void 0,n);if(o)try{await m.post(`${n}/api/runtime/callback/file-changed`,t,{headers:o});return}catch{}}}finally{const e={category:"file_changed",agentId:"",sessionId:null,workspacePath:t.workspacePath,filePath:t.filePath,eventType:t.eventType,size:t.size};B.append(e)}}function ee(t,n){const c=U.get(t);if(!c||!n)return;const e=`${c.outputBuffer}${n}`;if(e.length<=M){c.outputBuffer=e;return}const o=`\r
|
|
3
3
|
[AgentsWorkStudio: omitted ${e.length-M} chars of old terminal output]\r
|
|
4
|
-
`,
|
|
4
|
+
`,a=Math.max(0,M-o.length);c.outputBuffer=`${o}${e.slice(-a)}`}function X(t){const n=U.get(t);n&&(n.flushTimer||(n.flushTimer=setTimeout(()=>{n.flushTimer=null,q(t).catch(()=>{})},D)))}async function q(t){const n=U.get(t);if(!n||n.flushInFlight||!n.outputBuffer)return;const c=n.outputBuffer.slice(0,g);n.outputBuffer=n.outputBuffer.slice(g);const e=(async()=>{const r=n.seq+1;n.seq=r,await F(n.agentId,c,t,r),U.get(t)?.outputBuffer&&X(t)})();n.flushInFlight=e;try{await e}finally{const r=U.get(t);r&&(r.flushInFlight=null)}}export{ee as appendSessionOutput,B as bridgeEventBuffer,q as flushSessionOutput,X as scheduleOutputFlush,I as sendFileChanged,F as sendOutput,Y as sendQuestionRequest,V as sendStatus,Z as sendToolAuthRequest,U as sessions};
|
|
5
5
|
|
|
@@ -1,4 +1,23 @@
|
|
|
1
1
|
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
import { type UserScope } from "./user-scope.js";
|
|
2
21
|
export interface DeployedSkillEntry {
|
|
3
22
|
skillName: string;
|
|
4
23
|
zipFile: string;
|
|
@@ -16,9 +35,15 @@ export interface DeployedSkillResult {
|
|
|
16
35
|
|
|
17
36
|
export declare function isValidSkillName(name: unknown): name is string;
|
|
18
37
|
export declare class SkillManager {
|
|
38
|
+
private readonly scope;
|
|
19
39
|
private readonly rootDir;
|
|
20
|
-
private static
|
|
21
|
-
|
|
40
|
+
private static instances;
|
|
41
|
+
|
|
42
|
+
|
|
43
|
+
|
|
44
|
+
|
|
45
|
+
|
|
46
|
+
static forScope(scope: UserScope): SkillManager;
|
|
22
47
|
private constructor();
|
|
23
48
|
private manifestFile;
|
|
24
49
|
private skillDir;
|
|
@@ -26,6 +51,11 @@ export declare class SkillManager {
|
|
|
26
51
|
private readManifest;
|
|
27
52
|
private writeManifest;
|
|
28
53
|
|
|
54
|
+
|
|
55
|
+
|
|
56
|
+
|
|
57
|
+
|
|
58
|
+
|
|
29
59
|
saveSharedSkill(zipBuffer: Buffer, originalName: string, defaultEnabled?: boolean, sha256?: string, requestedSkillName?: string): Promise<DeployedSkillResult>;
|
|
30
60
|
|
|
31
61
|
removeDeployedSkill(skillName: string): Promise<{
|
|
@@ -39,6 +69,9 @@ export declare class SkillManager {
|
|
|
39
69
|
private readPrivateManifest;
|
|
40
70
|
private writePrivateManifest;
|
|
41
71
|
|
|
72
|
+
|
|
73
|
+
|
|
74
|
+
|
|
42
75
|
savePrivateSkill(agentId: string, zipBuffer: Buffer, originalName: string, sha256?: string, requestedSkillName?: string): Promise<DeployedSkillResult>;
|
|
43
76
|
|
|
44
77
|
removePrivateSkill(agentId: string, skillName: string): Promise<{
|
|
@@ -50,7 +83,11 @@ export declare class SkillManager {
|
|
|
50
83
|
|
|
51
84
|
deployedDefaultEnabled(): Record<string, boolean>;
|
|
52
85
|
|
|
53
|
-
|
|
86
|
+
|
|
87
|
+
|
|
88
|
+
|
|
89
|
+
private applyToUserAgents;
|
|
54
90
|
}
|
|
55
|
-
|
|
56
|
-
export declare
|
|
91
|
+
|
|
92
|
+
export declare function getSkillManager(scope: UserScope): SkillManager;
|
|
93
|
+
export declare const reconcileSkillsDefaultsFromDeployed: (scope: UserScope) => number;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{promises as F,cpSync as
|
|
2
|
-
`,"utf8")}async saveSharedSkill(r,e,t=!0,o,
|
|
3
|
-
`,"utf8")}async savePrivateSkill(r,e,t,o,
|
|
1
|
+
import{promises as F,cpSync as d,existsSync as p,mkdirSync as D,readFileSync as E,rmSync as h,writeFileSync as P}from"node:fs";import i from"node:path";import{getBridgeInstancePrivateSkillsDir as N,getBridgeInstancePrivateSkillsManifest as z}from"../config.js";import{runExclusiveConfigWrite as w}from"../utils/config-write-queue.js";import{extractSkillZip as K,resolveSkillSourceDirFromExtractRoot as A}from"../utils/file-utils.js";import{createLogger as J}from"../utils/logger.js";import{syncAgentSkillFarm as L}from"./agent-capability-sync.js";import{listAgentsOwnedBy as R}from"./agent-ownership.js";import{setDeployedDefaultsProvider as _,reconcileDefaultsFromDeployed as T}from"./capability-config.js";import{getAgentInitRoot as j}from"./instance-state.js";import{getUserSkillsDeployedDir as U}from"./user-scope.js";const v=J("skill-manager");function M(a){return typeof a=="string"&&a.length>0&&a.length<=128&&/^[a-zA-Z0-9_.-]+$/.test(a)}const x=1;class g{static forScope(r){const e=U(r),t=i.resolve(e);let o=this.instances.get(t);return o||(o=new g(r,e),this.instances.set(t,o)),o}constructor(r,e){this.scope=r,this.rootDir=e}manifestFile(){return i.join(this.rootDir,"manifest.json")}skillDir(r){const e=i.join(this.rootDir,r),t=i.resolve(this.rootDir);if(i.resolve(e)!==i.join(t,r))throw new Error(`\u6280\u80FD\u76EE\u5F55\u8D8A\u51FA\u90E8\u7F72\u533A: ${r}`);return e}isHealthy(r){return p(i.join(this.skillDir(r),"SKILL.md"))}readManifest(){try{const r=JSON.parse(E(this.manifestFile(),"utf8"));return Array.isArray(r.skills)?r.skills.filter(e=>e&&e.skillName):[]}catch{return[]}}writeManifest(r){D(this.rootDir,{recursive:!0}),P(this.manifestFile(),`${JSON.stringify({version:x,skills:r},null,2)}
|
|
2
|
+
`,"utf8")}async saveSharedSkill(r,e,t=!0,o,S){if(!r||r.length===0)return{ok:!1,error:"zip \u5305\u5185\u5BB9\u4E3A\u7A7A"};const y=i.join(j("_tmp"),`skill-deploy-${Date.now()}-${Math.random().toString(36).slice(2,8)}`);try{await b(r,y);const n=await A(y),l=i.basename(i.resolve(n)),$=String(e||"").replace(/\.zip$/i,"").trim(),s=S&&S.trim()||(l&&!l.startsWith("skill-deploy-")?l:"")||$;if(!M(s))return{ok:!1,error:`\u6280\u80FD\u540D\u975E\u6CD5: ${JSON.stringify(s)}`};if(!p(i.join(n,"SKILL.md")))return{ok:!1,error:`\u6280\u80FD\u5305\u7F3A\u5C11 SKILL.md: ${e}`};const u=this.readManifest().find(c=>c.skillName===s);if(u&&u.sha256===o&&this.isHealthy(s))return{ok:!0,skillName:s};D(this.rootDir,{recursive:!0});const m=this.skillDir(s),k=i.join(this.rootDir,`.old-${s}-${Date.now()}-${Math.random().toString(36).slice(2,8)}`);if(p(m))try{d(m,k,{recursive:!0})}catch{h(m,{recursive:!0,force:!0})}try{d(n,m,{recursive:!0})}catch(c){throw p(k)&&(h(m,{recursive:!0,force:!0}),d(k,m,{recursive:!0})),c}return p(k)&&h(k,{recursive:!0,force:!0}),await w(this.manifestFile(),()=>{const c=this.readManifest().filter(f=>f.skillName!==s);c.push({skillName:s,zipFile:u?.zipFile??`${s}.zip`,fileName:e,defaultEnabled:t,sha256:o}),this.writeManifest(c)}),v.info("[shared] \u6280\u80FD\u5DF2\u90E8\u7F72\u5230\u7528\u6237\u5E93: %s\uFF08scope=%s/%s \u6765\u6E90 %s%s\uFF09",s,this.scope.tenantId,this.scope.userId,e,o?`, sha256=${o.slice(0,12)}\u2026`:""),this.applyToUserAgents(),{ok:!0,skillName:s}}catch(n){const l=n instanceof Error?n.message:String(n);return v.warn("[shared] \u6280\u80FD\u90E8\u7F72\u5931\u8D25\uFF08%s\uFF09: %s",e,l),{ok:!1,error:`\u6280\u80FD\u90E8\u7F72\u5931\u8D25: ${l}`}}finally{try{h(y,{recursive:!0,force:!0})}catch{}}}async removeDeployedSkill(r){if(!M(r))return{ok:!1,error:"skillName \u975E\u6CD5"};await w(this.manifestFile(),()=>{const e=this.readManifest().filter(t=>t.skillName!==r);this.writeManifest(e)});try{h(this.skillDir(r),{recursive:!0,force:!0})}catch(e){return{ok:!1,error:`\u90E8\u7F72\u76EE\u5F55\u6E05\u7406\u5931\u8D25: ${e instanceof Error?e.message:String(e)}`}}return this.applyToUserAgents(),v.info("[shared] \u6280\u80FD\u5DF2\u4ECE\u7528\u6237\u5E93\u79FB\u9664\u90E8\u7F72: %s",r),{ok:!0}}listDeployed(){return this.readManifest().filter(r=>!/^skill-deploy-/.test(r.skillName)).map(r=>({...r,deployed:this.isHealthy(r.skillName)}))}privateManifestFile(r){return z(r)}privateSkillDir(r,e){const t=i.resolve(N(r)),o=i.join(t,e);if(i.resolve(o)!==i.join(t,e))throw new Error(`\u79C1\u6709\u6280\u80FD\u76EE\u5F55\u8D8A\u51FA\u5B9E\u4F8B\u79C1\u6709\u533A: ${e}`);return o}readPrivateManifest(r){try{const e=JSON.parse(E(this.privateManifestFile(r),"utf8"));return Array.isArray(e.skills)?e.skills.filter(t=>t&&t.skillName):[]}catch{return[]}}writePrivateManifest(r,e){const t=this.privateManifestFile(r);D(i.dirname(t),{recursive:!0}),P(t,`${JSON.stringify({version:x,skills:e},null,2)}
|
|
3
|
+
`,"utf8")}async savePrivateSkill(r,e,t,o,S){if(!r)return{ok:!1,error:"agentId is required"};if(!e||e.length===0)return{ok:!1,error:"zip \u5305\u5185\u5BB9\u4E3A\u7A7A"};const y=i.join(j("_tmp"),`skill-private-${Date.now()}-${Math.random().toString(36).slice(2,8)}`);try{await b(e,y);const n=await A(y),l=i.basename(i.resolve(n)),$=String(t||"").replace(/\.zip$/i,"").trim(),s=S&&S.trim()||(l&&!l.startsWith("skill-private-")?l:"")||$;if(!M(s))return{ok:!1,error:`\u6280\u80FD\u540D\u975E\u6CD5: ${JSON.stringify(s)}`};if(!p(i.join(n,"SKILL.md")))return{ok:!1,error:`\u6280\u80FD\u5305\u7F3A\u5C11 SKILL.md: ${t}`};const u=this.privateSkillDir(r,s),m=N(r);D(m,{recursive:!0});const k=this.readPrivateManifest(r).find(f=>f.skillName===s);if(k&&k.sha256===o&&p(i.join(u,"SKILL.md")))return{ok:!0,skillName:s};const c=i.join(m,`.old-${s}-${Date.now()}-${Math.random().toString(36).slice(2,8)}`);if(p(u))try{d(u,c,{recursive:!0})}catch{h(u,{recursive:!0,force:!0})}try{d(n,u,{recursive:!0})}catch(f){throw p(c)&&(h(u,{recursive:!0,force:!0}),d(c,u,{recursive:!0})),f}p(c)&&h(c,{recursive:!0,force:!0}),await w(this.privateManifestFile(r),()=>{const f=this.readPrivateManifest(r).filter(O=>O.skillName!==s);f.push({skillName:s,zipFile:k?.zipFile??`${s}.zip`,fileName:t,defaultEnabled:!0,sha256:o}),this.writePrivateManifest(r,f)}),v.info("[private] agent=%s \u79C1\u6709\u6280\u80FD\u5DF2\u5B89\u88C5: %s\uFF08\u6765\u6E90 %s%s\uFF09",r,s,t,o?`, sha256=${o.slice(0,12)}\u2026`:"");try{L(r)}catch(f){v.warn("[private] agent=%s \u79C1\u6709\u6280\u80FD\u5B89\u88C5\u540E\u540C\u6B65\u519C\u573A\u5931\u8D25: %s",r,f instanceof Error?f.message:String(f))}return{ok:!0,skillName:s}}catch(n){const l=n instanceof Error?n.message:String(n);return v.warn("[private] \u79C1\u6709\u6280\u80FD\u5B89\u88C5\u5931\u8D25\uFF08%s\uFF09: %s",t,l),{ok:!1,error:`\u79C1\u6709\u6280\u80FD\u5B89\u88C5\u5931\u8D25: ${l}`}}finally{try{h(y,{recursive:!0,force:!0})}catch{}}}async removePrivateSkill(r,e){if(!r)return{ok:!1,error:"agentId is required"};if(!M(e))return{ok:!1,error:"skillName \u975E\u6CD5"};await w(this.privateManifestFile(r),()=>{const t=this.readPrivateManifest(r).filter(o=>o.skillName!==e);this.writePrivateManifest(r,t)});try{h(this.privateSkillDir(r,e),{recursive:!0,force:!0})}catch(t){return{ok:!1,error:`\u79C1\u6709\u6280\u80FD\u76EE\u5F55\u6E05\u7406\u5931\u8D25: ${t instanceof Error?t.message:String(t)}`}}try{L(r)}catch{}return v.info("[private] agent=%s \u79C1\u6709\u6280\u80FD\u5DF2\u79FB\u9664: %s",r,e),{ok:!0}}listPrivateSkills(r){return r?this.readPrivateManifest(r).filter(e=>!/^skill-private-/.test(e.skillName)).map(e=>({...e,deployed:p(i.join(this.privateSkillDir(r,e.skillName),"SKILL.md"))})):[]}deployedDefaultEnabled(){const r={};for(const e of this.readManifest())/^skill-deploy-/.test(e.skillName)||(r[e.skillName]=e.defaultEnabled);return r}applyToUserAgents(){for(const r of R(this.scope))try{L(r)}catch(e){v.warn("[shared] \u540C\u6B65\u6280\u80FD\u519C\u573A\u5931\u8D25 agent=%s: %s",r,e instanceof Error?e.message:String(e))}}}g.instances=new Map;function Y(a){return g.forScope(a)}async function b(a,r){const e=i.join(j("_tmp"),`skill-${Date.now()}-${Math.random().toString(36).slice(2,8)}.zip`);await F.mkdir(i.dirname(e),{recursive:!0}),await F.writeFile(e,a);try{await K(e,r)}finally{await F.rm(e,{force:!0}).catch(()=>{})}}_("skills",a=>a?g.forScope(a).deployedDefaultEnabled():{});const rr=a=>T(a,"skills");export{g as SkillManager,Y as getSkillManager,M as isValidSkillName,rr as reconcileSkillsDefaultsFromDeployed};
|
|
4
4
|
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
|
|
26
|
+
export declare function setSnapshotRetentionDays(days: unknown, fromConfig?: boolean): void;
|
|
27
|
+
|
|
28
|
+
export declare function getSnapshotRetentionDays(): number | null;
|
|
29
|
+
|
|
30
|
+
export declare function resetSnapshotRetentionForTest(): void;
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
const u=3650;let t=null,l=!1;function i(e,o=!1){if(o&&l)return;if(o||(l=!0),e==null||e===""){t=null;return}if(typeof e=="boolean"){t=null;return}const n=Number(e);if(!Number.isFinite(n)||n<=0){t=null;return}t=Math.min(Math.floor(n),3650)}function r(){return t}function s(){t=null,l=!1}export{r as getSnapshotRetentionDays,s as resetSnapshotRetentionForTest,i as setSnapshotRetentionDays};
|
|
2
|
+
|
|
@@ -6,11 +6,14 @@ interface AutoRegisterTargetConfig {
|
|
|
6
6
|
[key: string]: unknown;
|
|
7
7
|
}
|
|
8
8
|
interface StartupConfigFile {
|
|
9
|
-
connectionKey?: string;
|
|
10
9
|
autoRegisterTargets?: AutoRegisterTargetConfig[];
|
|
11
10
|
[key: string]: unknown;
|
|
12
11
|
}
|
|
13
12
|
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
|
|
14
17
|
export declare const MINIMAL_CONFIG_TEMPLATE: StartupConfigFile;
|
|
15
18
|
|
|
16
19
|
export declare function formatConfigExample(template?: object): string;
|
|
@@ -29,5 +32,8 @@ export type StartupConfigWizardResult = "exists" | "created" | "configured" | "s
|
|
|
29
32
|
export declare function ensureStartupConfig(options?: EnsureStartupConfigOptions): Promise<StartupConfigWizardResult>;
|
|
30
33
|
export declare function configureStartupConfig(options?: EnsureStartupConfigOptions): Promise<StartupConfigWizardResult>;
|
|
31
34
|
|
|
35
|
+
|
|
36
|
+
|
|
37
|
+
|
|
32
38
|
export declare function printConfigExampleCommand(options?: EnsureStartupConfigOptions): Promise<StartupConfigWizardResult>;
|
|
33
39
|
export {};
|
|
@@ -1,14 +1,14 @@
|
|
|
1
|
-
import{randomBytes as
|
|
1
|
+
import{randomBytes as T}from"node:crypto";import{existsSync as m,readFileSync as R}from"node:fs";import E from"node:os";import{stdin as x,stdout as i}from"node:process";import{createInterface as _}from"node:readline/promises";import{atomicWriteJsonFile as U}from"../utils/file-utils.js";import{logger as o}from"../utils/logger.js";import{getAutoRegisterConfigFilePath as d}from"./auto-register.js";const w={autoRegisterTargets:[{instanceName:"<\u5B9E\u4F8B\u540D\u79F0\uFF0C\u4F8B\u5982 \u6211\u7684\u4E3B\u673A>",serverUrl:"http://<\u8C03\u5EA6\u4E2D\u5FC3IP>:<\u7AEF\u53E3>",userKey:"<\u4F60\u7684 userKey>",connectionKey:"<\u8BE5 target \u4E13\u7528\u8FDE\u63A5\u5BC6\u94A5\uFF0C\u53EF\u7531\u5411\u5BFC\u751F\u6210>",instanceId:"<\u5B9E\u4F8BID\uFF0C\u9996\u6B21\u53EF\u7559\u7A7A\u7531\u670D\u52A1\u7AEF\u751F\u6210>"}],panelUsername:"<\u9762\u677F\u7528\u6237\u540D>",panelPassword:"<\u9762\u677F\u5BC6\u7801>"};function K(t=w){return`[runtime-bridge] \u6700\u5C0F\u914D\u7F6E\u793A\u4F8B\uFF08\u8BF7\u5C06 <\u5360\u4F4D\u7B26> \u66FF\u6362\u4E3A\u771F\u5B9E\u503C\u540E\u4FDD\u5B58\uFF09:
|
|
2
2
|
${JSON.stringify(t,null,2)}
|
|
3
|
-
[runtime-bridge] \u8BF4\u660E\
|
|
4
|
-
[runtime-bridge] \u81EA\u52A8\u751F\u6210 connectionKey: ${
|
|
5
|
-
[runtime-bridge] \u8BF7\u4FDD\u5B58\u8BE5 connectionKey\uFF1Bserver/\u9762\u677F\u8FDE\u63A5\u6B64 Bridge \u65F6\u9700\u8981\u4F7F\u7528\u5B83\u3002`;o.info(
|
|
6
|
-
`)}async function y(t,e,
|
|
7
|
-
`)}}async function
|
|
8
|
-
`)}}async function q(t){for(;;){const e=await t.question("\u672A\u68C0\u6D4B\u5230\u914D\u7F6E\u6587\u4EF6\uFF0C\u8BF7\u9009\u62E9\u914D\u7F6E\u65B9\u5F0F\uFF1A[1] \u5B8C\u6574\u9010\u6B65\u5F15\u5BFC [2] \u6700\u5C0F\u914D\u7F6E\u793A\u4F8B\uFF08\u751F\u6210\u5360\u4F4D\u7B26\u6A21\u677F\uFF0C\u7A0D\u540E\u624B\u52A8\u586B\u5199\uFF09 (\u9ED8\u8BA4 1): "),
|
|
9
|
-
`)}}async function
|
|
3
|
+
[runtime-bridge] \u8BF4\u660E\uFF1AconnectionKey \u5C5E\u4E8E\u6BCF\u4E2A target\uFF0C\u591A\u4E2A target \u4E0D\u5F97\u5171\u7528\uFF1BinstanceId \u9996\u6B21\u53EF\u7701\u7565\uFF0C\u7531\u670D\u52A1\u7AEF\u751F\u6210\uFF1BpanelUsername / panelPassword \u4E3A\u53EF\u9009\u9762\u677F\u8BA4\u8BC1\u3002`}function l(t){return t.trim().toLowerCase()}function N(t){return["","y","yes","\u662F","\u597D","\u914D\u7F6E"].includes(l(t))}function k(t){return["n","no","\u5426","\u4E0D","\u8DF3\u8FC7","skip","s"].includes(l(t))}function B(t){if(!m(t))return{};try{const e=JSON.parse(R(t,"utf-8"));return e&&typeof e=="object"&&!Array.isArray(e)?e:{}}catch(e){const n=e;return o.warn(`[runtime-bridge] \u8BFB\u53D6\u73B0\u6709\u914D\u7F6E\u5931\u8D25\uFF0C\u5C06\u4F7F\u7528\u7A7A\u9ED8\u8BA4\u503C: ${n.message}`),{}}}function Y(){return`awsb_${T(24).toString("base64url")}`}async function g(t,e){await U(t,e)}async function p(t,e){const n=e();await g(t,{connectionKey:n});const r=`[runtime-bridge] \u5DF2\u521B\u5EFA\u914D\u7F6E\u6587\u4EF6: ${t}
|
|
4
|
+
[runtime-bridge] \u81EA\u52A8\u751F\u6210 connectionKey: ${n}
|
|
5
|
+
[runtime-bridge] \u8BF7\u4FDD\u5B58\u8BE5 connectionKey\uFF1Bserver/\u9762\u677F\u8FDE\u63A5\u6B64 Bridge \u65F6\u9700\u8981\u4F7F\u7528\u5B83\u3002`;o.info(r),i.write(`${r}
|
|
6
|
+
`)}async function y(t,e,n){return(await t.question(`${e}\uFF08\u9ED8\u8BA4\u4F7F\u7528\u5F53\u524D\u503C ${n}\uFF0C\u76F4\u63A5\u56DE\u8F66\u4FDD\u7559\uFF09: `)).trim()||n}const $=10;async function b(t,e,n){let r=0;for(;;){const a=(await t.question(n?`${e}\uFF08\u9ED8\u8BA4\u4F7F\u7528\u5F53\u524D\u503C ${n}\uFF0C\u76F4\u63A5\u56DE\u8F66\u4FDD\u7559\uFF09: `:`${e}: `)).trim();if(a)return a;if(n)return n;if(r++,r>=$)throw new Error(`${e} \u8F93\u5165\u8D85\u8FC7\u6700\u5927\u91CD\u8BD5\u6B21\u6570\uFF08${$}\uFF09\uFF0C\u9000\u51FA\u914D\u7F6E\u5F15\u5BFC`);i.write(`${e} \u4E0D\u80FD\u4E3A\u7A7A\uFF0C\u8BF7\u91CD\u65B0\u8F93\u5165\u3002
|
|
7
|
+
`)}}async function W(t){for(;;){const e=await t.question(`\u672A\u68C0\u6D4B\u5230 ${d()}\uFF0C\u662F\u5426\u73B0\u5728\u8FDB\u5165\u81EA\u52A8\u6CE8\u518C\u914D\u7F6E\u5F15\u5BFC\uFF1F(Y/n): `);if(N(e))return!0;if(k(e))return!1;i.write(`\u8BF7\u8F93\u5165 Y \u7EE7\u7EED\u914D\u7F6E\uFF0C\u6216\u8F93\u5165 n \u8DF3\u8FC7\u3002
|
|
8
|
+
`)}}async function q(t){for(;;){const e=await t.question("\u672A\u68C0\u6D4B\u5230\u914D\u7F6E\u6587\u4EF6\uFF0C\u8BF7\u9009\u62E9\u914D\u7F6E\u65B9\u5F0F\uFF1A[1] \u5B8C\u6574\u9010\u6B65\u5F15\u5BFC [2] \u6700\u5C0F\u914D\u7F6E\u793A\u4F8B\uFF08\u751F\u6210\u5360\u4F4D\u7B26\u6A21\u677F\uFF0C\u7A0D\u540E\u624B\u52A8\u586B\u5199\uFF09 (\u9ED8\u8BA4 1): "),n=l(e);if(n===""||n==="1"||n==="full"||n==="\u5B8C\u6574"||n==="\u5F15\u5BFC")return"full";if(n==="2"||n==="minimal"||n==="\u6700\u5C0F"||n==="\u793A\u4F8B")return"minimal";i.write(`\u8BF7\u8F93\u5165 1\uFF08\u5B8C\u6574\u5F15\u5BFC\uFF09\u6216 2\uFF08\u6700\u5C0F\u914D\u7F6E\u793A\u4F8B\uFF09\u3002
|
|
9
|
+
`)}}async function S(t,e={}){const n=e.autoRegisterTargets?.[0]||{},r="http://127.0.0.1:8080",a=E.hostname()||"AgentsWork Runtime Bridge",c=n.registerAddr||n.registerIp||"127.0.0.1",u=await b(t,"connectionKey\uFF08\u8BE5 target \u4E13\u7528\u8FDE\u63A5\u5BC6\u94A5\uFF09",String(n.connectionKey||e.connectionKey||"").trim()||void 0),f=await y(t,"serverUrl\uFF08\u8C03\u5EA6\u4E2D\u5FC3\u5730\u5740\uFF09",n.serverUrl||r),v=await y(t,"instanceName\uFF08\u5B9E\u4F8B\u540D\u79F0\uFF09",n.instanceName||a),A=await b(t,"userKey\uFF08\u7528\u6237 API Key\uFF09",n.userKey),P=await y(t,"registerAddr\uFF08Bridge \u5BF9\u5916\u8BBF\u95EE\u5730\u5740\uFF0C\u652F\u6301 host:port / \u7EAF host / \u5B8C\u6574 URL\uFF09",c),C={...n};delete C.registerIp;const h={...e};return delete h.connectionKey,{...h,autoRegisterTargets:[{...C,serverUrl:f,instanceName:v,userKey:A,connectionKey:u,registerAddr:P}]}}async function I(t){return{prompt:t.prompt||_({input:x,output:i,terminal:!0}),shouldClosePrompt:!t.prompt}}async function z(t={}){const e=t.configPath||d(),n=t.generateConnectionKey||Y;if(m(e))return"exists";if((t.env||process.env).AWS_BRIDGE_SKIP_SETUP==="true")return await p(e,n),o.info("[runtime-bridge] AWS_BRIDGE_SKIP_SETUP=true\uFF0C\u8DF3\u8FC7\u9996\u6B21\u914D\u7F6E\u5F15\u5BFC"),"skipped";if(!(t.interactive??!!(process.stdin.isTTY&&process.stdout.isTTY)))return await p(e,n),o.info(`[runtime-bridge] \u672A\u68C0\u6D4B\u5230\u914D\u7F6E\u6587\u4EF6: ${e}\uFF1B\u5F53\u524D\u4E3A\u975E\u4EA4\u4E92\u73AF\u5883\uFF0C\u8DF3\u8FC7\u9996\u6B21\u914D\u7F6E\u5F15\u5BFC`),"non-interactive";const{prompt:s,shouldClosePrompt:c}=await I(t);try{if(!await W(s))return await p(e,n),o.info("[runtime-bridge] \u5DF2\u8DF3\u8FC7\u9996\u6B21\u914D\u7F6E\u5F15\u5BFC"),"skipped";const f=await S(s);return await g(e,f),o.info(`[runtime-bridge] \u5DF2\u5199\u5165\u914D\u7F6E\u6587\u4EF6: ${e}`),"created"}catch(u){const f=u;return o.warn(`[runtime-bridge] \u9996\u6B21\u914D\u7F6E\u5F15\u5BFC\u5931\u8D25: ${f.message}`),"failed"}finally{c&&s.close()}}async function Q(t={}){const e=t.configPath||d();if(!(t.interactive??!!(process.stdin.isTTY&&process.stdout.isTTY)))return o.warn("[runtime-bridge] awsb config \u9700\u8981\u4EA4\u4E92\u5F0F\u7EC8\u7AEF"),"failed";const{prompt:r,shouldClosePrompt:a}=await I(t);try{const s=B(e);if(!m(e)&&await q(r)==="minimal")return i.write(K()),await g(e,w),i.write(`[runtime-bridge] \u5DF2\u5C06\u6700\u5C0F\u914D\u7F6E\u793A\u4F8B\u6A21\u677F\u5199\u5165: ${e}
|
|
10
10
|
`),i.write(`[runtime-bridge] \u8BF7\u5C06 <\u5360\u4F4D\u7B26> \u66FF\u6362\u4E3A\u771F\u5B9E\u503C\u540E\u4FDD\u5B58\u3002
|
|
11
|
-
`),"created";const u=await
|
|
11
|
+
`),"created";const u=await S(r,s);return await g(e,u),o.info(`[runtime-bridge] \u5DF2\u66F4\u65B0\u914D\u7F6E\u6587\u4EF6: ${e}`),"configured"}catch(s){const c=s;return o.warn(`[runtime-bridge] \u914D\u7F6E\u5F15\u5BFC\u5931\u8D25: ${c.message}`),"failed"}finally{a&&r.close()}}async function X(t={}){const e=t.configPath||d();i.write(K());try{return await g(e,w),i.write(`[runtime-bridge] \u5DF2\u5C06\u6700\u5C0F\u914D\u7F6E\u793A\u4F8B\u6A21\u677F\u5199\u5165: ${e}
|
|
12
12
|
`),i.write(`[runtime-bridge] \u8BF7\u5C06 <\u5360\u4F4D\u7B26> \u66FF\u6362\u4E3A\u771F\u5B9E\u503C\u540E\u4FDD\u5B58\u3002
|
|
13
|
-
`),"created"}catch(
|
|
13
|
+
`),"created"}catch(n){const r=n;return o.warn(`[runtime-bridge] \u5199\u5165\u793A\u4F8B\u6A21\u677F\u5931\u8D25: ${r.message}`),"failed"}}export{w as MINIMAL_CONFIG_TEMPLATE,Q as configureStartupConfig,z as ensureStartupConfig,K as formatConfigExample,X as printConfigExampleCommand};
|
|
14
14
|
|