@viewportai/daemon 0.31.0 → 0.32.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +25 -0
- package/README.md +339 -242
- package/dist/chunk-33YDFYW2.js +355 -0
- package/dist/chunk-5MLJY3NS.js +182 -0
- package/dist/chunk-62D4ICYA.js +634 -0
- package/dist/chunk-76ISR4QO.js +5045 -0
- package/dist/chunk-BFV7PIQD.js +639 -0
- package/dist/chunk-EACFI34X.js +2307 -0
- package/dist/chunk-FXZH5JGQ.js +599 -0
- package/dist/chunk-K2WDCPZB.js +377 -0
- package/dist/chunk-NBLB22VR.js +70 -0
- package/dist/chunk-YJFNBSD3.js +229 -0
- package/dist/cli/bin.d.ts +1 -0
- package/dist/cli/bin.js +2311 -0
- package/dist/client/index.d.ts +294 -0
- package/dist/client/index.js +708 -0
- package/dist/identity-CH_omX_I.d.ts +20 -0
- package/dist/index.d.ts +109 -26
- package/dist/index.js +34 -223
- package/dist/info-aU2-5A8G.d.ts +602 -0
- package/dist/pipe-BlqIy51a.d.ts +19 -0
- package/dist/protocol/index.d.ts +113 -0
- package/dist/protocol/index.js +222 -0
- package/dist/pushes-B1v3BF2N.d.ts +659 -0
- package/dist/relay/index.d.ts +122 -0
- package/dist/relay/index.js +26 -0
- package/dist/results-Ct1ZVYOZ.d.ts +716 -0
- package/dist/serve-MuBojIIs.d.ts +155 -0
- package/dist/server/index.d.ts +165 -0
- package/dist/server/index.js +31 -0
- package/dist/supervisor-CZ_i_hSc.d.ts +791 -0
- package/dist/testing/index.d.ts +163 -0
- package/dist/testing/index.js +445 -0
- package/dist/testing/vitest.d.ts +12 -0
- package/dist/testing/vitest.js +58 -0
- package/package.json +88 -87
- package/spec/schemas/daemon/channel/v1.json +176 -0
- package/spec/schemas/daemon/event/v1.json +551 -0
- package/spec/schemas/daemon/protocol/v1.json +1557 -0
- package/bin/vpd.js +0 -2
- package/dist/adapters/claude-message-normalizer.d.ts +0 -24
- package/dist/adapters/claude-message-normalizer.d.ts.map +0 -1
- package/dist/adapters/claude-message-normalizer.js +0 -192
- package/dist/adapters/claude-message-normalizer.js.map +0 -1
- package/dist/adapters/claude.d.ts +0 -104
- package/dist/adapters/claude.d.ts.map +0 -1
- package/dist/adapters/claude.js +0 -503
- package/dist/adapters/claude.js.map +0 -1
- package/dist/adapters/codex-event-normalizers.d.ts +0 -10
- package/dist/adapters/codex-event-normalizers.d.ts.map +0 -1
- package/dist/adapters/codex-event-normalizers.js +0 -261
- package/dist/adapters/codex-event-normalizers.js.map +0 -1
- package/dist/adapters/codex-sdk-loader.d.ts +0 -48
- package/dist/adapters/codex-sdk-loader.d.ts.map +0 -1
- package/dist/adapters/codex-sdk-loader.js +0 -19
- package/dist/adapters/codex-sdk-loader.js.map +0 -1
- package/dist/adapters/codex.d.ts +0 -65
- package/dist/adapters/codex.d.ts.map +0 -1
- package/dist/adapters/codex.js +0 -606
- package/dist/adapters/codex.js.map +0 -1
- package/dist/adapters/gemini-cli.d.ts +0 -50
- package/dist/adapters/gemini-cli.d.ts.map +0 -1
- package/dist/adapters/gemini-cli.js +0 -205
- package/dist/adapters/gemini-cli.js.map +0 -1
- package/dist/adapters/pty.d.ts +0 -57
- package/dist/adapters/pty.d.ts.map +0 -1
- package/dist/adapters/pty.js +0 -250
- package/dist/adapters/pty.js.map +0 -1
- package/dist/agents/aider.d.ts +0 -9
- package/dist/agents/aider.d.ts.map +0 -1
- package/dist/agents/aider.js +0 -37
- package/dist/agents/aider.js.map +0 -1
- package/dist/agents/built-in.d.ts +0 -4
- package/dist/agents/built-in.d.ts.map +0 -1
- package/dist/agents/built-in.js +0 -6
- package/dist/agents/built-in.js.map +0 -1
- package/dist/agents/claude.d.ts +0 -12
- package/dist/agents/claude.d.ts.map +0 -1
- package/dist/agents/claude.js +0 -93
- package/dist/agents/claude.js.map +0 -1
- package/dist/agents/codex-defaults.d.ts +0 -2
- package/dist/agents/codex-defaults.d.ts.map +0 -1
- package/dist/agents/codex-defaults.js +0 -2
- package/dist/agents/codex-defaults.js.map +0 -1
- package/dist/agents/codex.d.ts +0 -6
- package/dist/agents/codex.d.ts.map +0 -1
- package/dist/agents/codex.js +0 -82
- package/dist/agents/codex.js.map +0 -1
- package/dist/agents/command-detection.d.ts +0 -6
- package/dist/agents/command-detection.d.ts.map +0 -1
- package/dist/agents/command-detection.js +0 -12
- package/dist/agents/command-detection.js.map +0 -1
- package/dist/agents/custom-command.d.ts +0 -3
- package/dist/agents/custom-command.d.ts.map +0 -1
- package/dist/agents/custom-command.js +0 -58
- package/dist/agents/custom-command.js.map +0 -1
- package/dist/agents/gemini.d.ts +0 -6
- package/dist/agents/gemini.d.ts.map +0 -1
- package/dist/agents/gemini.js +0 -36
- package/dist/agents/gemini.js.map +0 -1
- package/dist/cli/agent-commands.d.ts +0 -2
- package/dist/cli/agent-commands.d.ts.map +0 -1
- package/dist/cli/agent-commands.js +0 -97
- package/dist/cli/agent-commands.js.map +0 -1
- package/dist/cli/args.d.ts +0 -9
- package/dist/cli/args.d.ts.map +0 -1
- package/dist/cli/args.js +0 -96
- package/dist/cli/args.js.map +0 -1
- package/dist/cli/bind-command.d.ts +0 -2
- package/dist/cli/bind-command.d.ts.map +0 -1
- package/dist/cli/bind-command.js +0 -61
- package/dist/cli/bind-command.js.map +0 -1
- package/dist/cli/check-command.d.ts +0 -2
- package/dist/cli/check-command.d.ts.map +0 -1
- package/dist/cli/check-command.js +0 -168
- package/dist/cli/check-command.js.map +0 -1
- package/dist/cli/command-shared.d.ts +0 -81
- package/dist/cli/command-shared.d.ts.map +0 -1
- package/dist/cli/command-shared.js +0 -237
- package/dist/cli/command-shared.js.map +0 -1
- package/dist/cli/commands.d.ts +0 -36
- package/dist/cli/commands.d.ts.map +0 -1
- package/dist/cli/commands.js +0 -36
- package/dist/cli/commands.js.map +0 -1
- package/dist/cli/context-access-command.d.ts +0 -3
- package/dist/cli/context-access-command.d.ts.map +0 -1
- package/dist/cli/context-access-command.js +0 -63
- package/dist/cli/context-access-command.js.map +0 -1
- package/dist/cli/context-add-command.d.ts +0 -2
- package/dist/cli/context-add-command.d.ts.map +0 -1
- package/dist/cli/context-add-command.js +0 -74
- package/dist/cli/context-add-command.js.map +0 -1
- package/dist/cli/context-candidate-preview-command.d.ts +0 -2
- package/dist/cli/context-candidate-preview-command.d.ts.map +0 -1
- package/dist/cli/context-candidate-preview-command.js +0 -52
- package/dist/cli/context-candidate-preview-command.js.map +0 -1
- package/dist/cli/context-command-parsers.d.ts +0 -4
- package/dist/cli/context-command-parsers.d.ts.map +0 -1
- package/dist/cli/context-command-parsers.js +0 -32
- package/dist/cli/context-command-parsers.js.map +0 -1
- package/dist/cli/context-command.d.ts +0 -2
- package/dist/cli/context-command.d.ts.map +0 -1
- package/dist/cli/context-command.js +0 -950
- package/dist/cli/context-command.js.map +0 -1
- package/dist/cli/context-github-use-command.d.ts +0 -2
- package/dist/cli/context-github-use-command.d.ts.map +0 -1
- package/dist/cli/context-github-use-command.js +0 -68
- package/dist/cli/context-github-use-command.js.map +0 -1
- package/dist/cli/context-provider-command.d.ts +0 -4
- package/dist/cli/context-provider-command.d.ts.map +0 -1
- package/dist/cli/context-provider-command.js +0 -277
- package/dist/cli/context-provider-command.js.map +0 -1
- package/dist/cli/context-provider-propose.d.ts +0 -27
- package/dist/cli/context-provider-propose.d.ts.map +0 -1
- package/dist/cli/context-provider-propose.js +0 -31
- package/dist/cli/context-provider-propose.js.map +0 -1
- package/dist/cli/context-provider-resolve.d.ts +0 -11
- package/dist/cli/context-provider-resolve.d.ts.map +0 -1
- package/dist/cli/context-provider-resolve.js +0 -22
- package/dist/cli/context-provider-resolve.js.map +0 -1
- package/dist/cli/context-rules-command.d.ts +0 -2
- package/dist/cli/context-rules-command.d.ts.map +0 -1
- package/dist/cli/context-rules-command.js +0 -93
- package/dist/cli/context-rules-command.js.map +0 -1
- package/dist/cli/context-sync-target.d.ts +0 -37
- package/dist/cli/context-sync-target.d.ts.map +0 -1
- package/dist/cli/context-sync-target.js +0 -180
- package/dist/cli/context-sync-target.js.map +0 -1
- package/dist/cli/context-vault-metadata-command.d.ts +0 -36
- package/dist/cli/context-vault-metadata-command.d.ts.map +0 -1
- package/dist/cli/context-vault-metadata-command.js +0 -250
- package/dist/cli/context-vault-metadata-command.js.map +0 -1
- package/dist/cli/context-vault-use-command.d.ts +0 -2
- package/dist/cli/context-vault-use-command.d.ts.map +0 -1
- package/dist/cli/context-vault-use-command.js +0 -55
- package/dist/cli/context-vault-use-command.js.map +0 -1
- package/dist/cli/contract-authorization.d.ts +0 -25
- package/dist/cli/contract-authorization.d.ts.map +0 -1
- package/dist/cli/contract-authorization.js +0 -97
- package/dist/cli/contract-authorization.js.map +0 -1
- package/dist/cli/daemon-client.d.ts +0 -31
- package/dist/cli/daemon-client.d.ts.map +0 -1
- package/dist/cli/daemon-client.js +0 -208
- package/dist/cli/daemon-client.js.map +0 -1
- package/dist/cli/daemon-lifecycle.d.ts +0 -19
- package/dist/cli/daemon-lifecycle.d.ts.map +0 -1
- package/dist/cli/daemon-lifecycle.js +0 -298
- package/dist/cli/daemon-lifecycle.js.map +0 -1
- package/dist/cli/daemon-runtime-state.d.ts +0 -47
- package/dist/cli/daemon-runtime-state.d.ts.map +0 -1
- package/dist/cli/daemon-runtime-state.js +0 -2
- package/dist/cli/daemon-runtime-state.js.map +0 -1
- package/dist/cli/daemon-settings.d.ts +0 -9
- package/dist/cli/daemon-settings.d.ts.map +0 -1
- package/dist/cli/daemon-settings.js +0 -321
- package/dist/cli/daemon-settings.js.map +0 -1
- package/dist/cli/diagnostic-command.d.ts +0 -2
- package/dist/cli/diagnostic-command.d.ts.map +0 -1
- package/dist/cli/diagnostic-command.js +0 -102
- package/dist/cli/diagnostic-command.js.map +0 -1
- package/dist/cli/directory-commands.d.ts +0 -4
- package/dist/cli/directory-commands.d.ts.map +0 -1
- package/dist/cli/directory-commands.js +0 -198
- package/dist/cli/directory-commands.js.map +0 -1
- package/dist/cli/global-flags.d.ts +0 -2
- package/dist/cli/global-flags.d.ts.map +0 -1
- package/dist/cli/global-flags.js +0 -9
- package/dist/cli/global-flags.js.map +0 -1
- package/dist/cli/guard-command.d.ts +0 -34
- package/dist/cli/guard-command.d.ts.map +0 -1
- package/dist/cli/guard-command.js +0 -161
- package/dist/cli/guard-command.js.map +0 -1
- package/dist/cli/hook-command.d.ts +0 -23
- package/dist/cli/hook-command.d.ts.map +0 -1
- package/dist/cli/hook-command.js +0 -169
- package/dist/cli/hook-command.js.map +0 -1
- package/dist/cli/install-command.d.ts +0 -6
- package/dist/cli/install-command.d.ts.map +0 -1
- package/dist/cli/install-command.js +0 -125
- package/dist/cli/install-command.js.map +0 -1
- package/dist/cli/lifecycle-commands.d.ts +0 -15
- package/dist/cli/lifecycle-commands.d.ts.map +0 -1
- package/dist/cli/lifecycle-commands.js +0 -369
- package/dist/cli/lifecycle-commands.js.map +0 -1
- package/dist/cli/lifecycle-doctor-command.d.ts +0 -2
- package/dist/cli/lifecycle-doctor-command.d.ts.map +0 -1
- package/dist/cli/lifecycle-doctor-command.js +0 -100
- package/dist/cli/lifecycle-doctor-command.js.map +0 -1
- package/dist/cli/lifecycle-pair-command.d.ts +0 -6
- package/dist/cli/lifecycle-pair-command.d.ts.map +0 -1
- package/dist/cli/lifecycle-pair-command.js +0 -358
- package/dist/cli/lifecycle-pair-command.js.map +0 -1
- package/dist/cli/lifecycle-pair-server.d.ts +0 -29
- package/dist/cli/lifecycle-pair-server.d.ts.map +0 -1
- package/dist/cli/lifecycle-pair-server.js +0 -208
- package/dist/cli/lifecycle-pair-server.js.map +0 -1
- package/dist/cli/lifecycle-status-command.d.ts +0 -2
- package/dist/cli/lifecycle-status-command.d.ts.map +0 -1
- package/dist/cli/lifecycle-status-command.js +0 -340
- package/dist/cli/lifecycle-status-command.js.map +0 -1
- package/dist/cli/lifecycle-update-command.d.ts +0 -2
- package/dist/cli/lifecycle-update-command.d.ts.map +0 -1
- package/dist/cli/lifecycle-update-command.js +0 -92
- package/dist/cli/lifecycle-update-command.js.map +0 -1
- package/dist/cli/listen-target.d.ts +0 -13
- package/dist/cli/listen-target.d.ts.map +0 -1
- package/dist/cli/listen-target.js +0 -102
- package/dist/cli/listen-target.js.map +0 -1
- package/dist/cli/local-tls.d.ts +0 -9
- package/dist/cli/local-tls.d.ts.map +0 -1
- package/dist/cli/local-tls.js +0 -84
- package/dist/cli/local-tls.js.map +0 -1
- package/dist/cli/managed-session-verification-contract.d.ts +0 -46
- package/dist/cli/managed-session-verification-contract.d.ts.map +0 -1
- package/dist/cli/managed-session-verification-contract.js +0 -2
- package/dist/cli/managed-session-verification-contract.js.map +0 -1
- package/dist/cli/network.d.ts +0 -11
- package/dist/cli/network.d.ts.map +0 -1
- package/dist/cli/network.js +0 -173
- package/dist/cli/network.js.map +0 -1
- package/dist/cli/open-url.d.ts +0 -2
- package/dist/cli/open-url.d.ts.map +0 -1
- package/dist/cli/open-url.js +0 -21
- package/dist/cli/open-url.js.map +0 -1
- package/dist/cli/orchestration-commands.d.ts +0 -8
- package/dist/cli/orchestration-commands.d.ts.map +0 -1
- package/dist/cli/orchestration-commands.js +0 -340
- package/dist/cli/orchestration-commands.js.map +0 -1
- package/dist/cli/org-binding.d.ts +0 -41
- package/dist/cli/org-binding.d.ts.map +0 -1
- package/dist/cli/org-binding.js +0 -211
- package/dist/cli/org-binding.js.map +0 -1
- package/dist/cli/pairing-name-resolver.d.ts +0 -2
- package/dist/cli/pairing-name-resolver.d.ts.map +0 -1
- package/dist/cli/pairing-name-resolver.js +0 -48
- package/dist/cli/pairing-name-resolver.js.map +0 -1
- package/dist/cli/permission-commands.d.ts +0 -2
- package/dist/cli/permission-commands.d.ts.map +0 -1
- package/dist/cli/permission-commands.js +0 -148
- package/dist/cli/permission-commands.js.map +0 -1
- package/dist/cli/policy-schema-validator.d.ts +0 -240
- package/dist/cli/policy-schema-validator.d.ts.map +0 -1
- package/dist/cli/policy-schema-validator.js +0 -315
- package/dist/cli/policy-schema-validator.js.map +0 -1
- package/dist/cli/profile-command.d.ts +0 -3
- package/dist/cli/profile-command.d.ts.map +0 -1
- package/dist/cli/profile-command.js +0 -320
- package/dist/cli/profile-command.js.map +0 -1
- package/dist/cli/profile-runtime-commands.d.ts +0 -6
- package/dist/cli/profile-runtime-commands.d.ts.map +0 -1
- package/dist/cli/profile-runtime-commands.js +0 -127
- package/dist/cli/profile-runtime-commands.js.map +0 -1
- package/dist/cli/relay-binding-config.d.ts +0 -8
- package/dist/cli/relay-binding-config.d.ts.map +0 -1
- package/dist/cli/relay-binding-config.js +0 -62
- package/dist/cli/relay-binding-config.js.map +0 -1
- package/dist/cli/relay-diagnostics.d.ts +0 -8
- package/dist/cli/relay-diagnostics.d.ts.map +0 -1
- package/dist/cli/relay-diagnostics.js +0 -45
- package/dist/cli/relay-diagnostics.js.map +0 -1
- package/dist/cli/relay-launch-bindings.d.ts +0 -22
- package/dist/cli/relay-launch-bindings.d.ts.map +0 -1
- package/dist/cli/relay-launch-bindings.js +0 -36
- package/dist/cli/relay-launch-bindings.js.map +0 -1
- package/dist/cli/remote-commands.d.ts +0 -3
- package/dist/cli/remote-commands.d.ts.map +0 -1
- package/dist/cli/remote-commands.js +0 -312
- package/dist/cli/remote-commands.js.map +0 -1
- package/dist/cli/remote-decision-keys.d.ts +0 -8
- package/dist/cli/remote-decision-keys.d.ts.map +0 -1
- package/dist/cli/remote-decision-keys.js +0 -59
- package/dist/cli/remote-decision-keys.js.map +0 -1
- package/dist/cli/resource-config-command.d.ts +0 -9
- package/dist/cli/resource-config-command.d.ts.map +0 -1
- package/dist/cli/resource-config-command.js +0 -295
- package/dist/cli/resource-config-command.js.map +0 -1
- package/dist/cli/runtime-toolchain.d.ts +0 -35
- package/dist/cli/runtime-toolchain.d.ts.map +0 -1
- package/dist/cli/runtime-toolchain.js +0 -184
- package/dist/cli/runtime-toolchain.js.map +0 -1
- package/dist/cli/service-commands.d.ts +0 -21
- package/dist/cli/service-commands.d.ts.map +0 -1
- package/dist/cli/service-commands.js +0 -295
- package/dist/cli/service-commands.js.map +0 -1
- package/dist/cli/session-commands.d.ts +0 -5
- package/dist/cli/session-commands.d.ts.map +0 -1
- package/dist/cli/session-commands.js +0 -237
- package/dist/cli/session-commands.js.map +0 -1
- package/dist/cli/setup-command.d.ts +0 -17
- package/dist/cli/setup-command.d.ts.map +0 -1
- package/dist/cli/setup-command.js +0 -278
- package/dist/cli/setup-command.js.map +0 -1
- package/dist/cli/signal-command.d.ts +0 -2
- package/dist/cli/signal-command.d.ts.map +0 -1
- package/dist/cli/signal-command.js +0 -258
- package/dist/cli/signal-command.js.map +0 -1
- package/dist/cli/skills-command.d.ts +0 -2
- package/dist/cli/skills-command.d.ts.map +0 -1
- package/dist/cli/skills-command.js +0 -208
- package/dist/cli/skills-command.js.map +0 -1
- package/dist/cli/supervisor-protocol.d.ts +0 -55
- package/dist/cli/supervisor-protocol.d.ts.map +0 -1
- package/dist/cli/supervisor-protocol.js +0 -5
- package/dist/cli/supervisor-protocol.js.map +0 -1
- package/dist/cli/supervisor-runtime-config.d.ts +0 -4
- package/dist/cli/supervisor-runtime-config.d.ts.map +0 -1
- package/dist/cli/supervisor-runtime-config.js +0 -112
- package/dist/cli/supervisor-runtime-config.js.map +0 -1
- package/dist/cli/supervisor.d.ts +0 -10
- package/dist/cli/supervisor.d.ts.map +0 -1
- package/dist/cli/supervisor.js +0 -252
- package/dist/cli/supervisor.js.map +0 -1
- package/dist/cli/support-packet.d.ts +0 -7
- package/dist/cli/support-packet.d.ts.map +0 -1
- package/dist/cli/support-packet.js +0 -19
- package/dist/cli/support-packet.js.map +0 -1
- package/dist/cli/team-resource-command.d.ts +0 -2
- package/dist/cli/team-resource-command.d.ts.map +0 -1
- package/dist/cli/team-resource-command.js +0 -364
- package/dist/cli/team-resource-command.js.map +0 -1
- package/dist/cli/uninstall-command.d.ts +0 -2
- package/dist/cli/uninstall-command.d.ts.map +0 -1
- package/dist/cli/uninstall-command.js +0 -111
- package/dist/cli/uninstall-command.js.map +0 -1
- package/dist/cli/unlock-command.d.ts +0 -2
- package/dist/cli/unlock-command.d.ts.map +0 -1
- package/dist/cli/unlock-command.js +0 -35
- package/dist/cli/unlock-command.js.map +0 -1
- package/dist/cli/watch-command.d.ts +0 -3
- package/dist/cli/watch-command.d.ts.map +0 -1
- package/dist/cli/watch-command.js +0 -42
- package/dist/cli/watch-command.js.map +0 -1
- package/dist/cli/worker-command.d.ts +0 -3
- package/dist/cli/worker-command.d.ts.map +0 -1
- package/dist/cli/worker-command.js +0 -518
- package/dist/cli/worker-command.js.map +0 -1
- package/dist/cli/worker-process-lock.d.ts +0 -27
- package/dist/cli/worker-process-lock.d.ts.map +0 -1
- package/dist/cli/worker-process-lock.js +0 -150
- package/dist/cli/worker-process-lock.js.map +0 -1
- package/dist/cli/worker-profile.d.ts +0 -90
- package/dist/cli/worker-profile.d.ts.map +0 -1
- package/dist/cli/worker-profile.js +0 -302
- package/dist/cli/worker-profile.js.map +0 -1
- package/dist/cli/worker-runtime.d.ts +0 -83
- package/dist/cli/worker-runtime.d.ts.map +0 -1
- package/dist/cli/worker-runtime.js +0 -1825
- package/dist/cli/worker-runtime.js.map +0 -1
- package/dist/cli/workflow-commands.d.ts +0 -3
- package/dist/cli/workflow-commands.d.ts.map +0 -1
- package/dist/cli/workflow-commands.js +0 -404
- package/dist/cli/workflow-commands.js.map +0 -1
- package/dist/cli/workflow-contract-resolver.d.ts +0 -13
- package/dist/cli/workflow-contract-resolver.d.ts.map +0 -1
- package/dist/cli/workflow-contract-resolver.js +0 -68
- package/dist/cli/workflow-contract-resolver.js.map +0 -1
- package/dist/cli/workflow-run-json.d.ts +0 -34
- package/dist/cli/workflow-run-json.d.ts.map +0 -1
- package/dist/cli/workflow-run-json.js +0 -118
- package/dist/cli/workflow-run-json.js.map +0 -1
- package/dist/cli/worktree-commands.d.ts +0 -2
- package/dist/cli/worktree-commands.d.ts.map +0 -1
- package/dist/cli/worktree-commands.js +0 -260
- package/dist/cli/worktree-commands.js.map +0 -1
- package/dist/cli/ws-client.d.ts +0 -20
- package/dist/cli/ws-client.d.ts.map +0 -1
- package/dist/cli/ws-client.js +0 -128
- package/dist/cli/ws-client.js.map +0 -1
- package/dist/config-resolution/approval-rules.d.ts +0 -5
- package/dist/config-resolution/approval-rules.d.ts.map +0 -1
- package/dist/config-resolution/approval-rules.js +0 -14
- package/dist/config-resolution/approval-rules.js.map +0 -1
- package/dist/config-resolution/config-writer.d.ts +0 -51
- package/dist/config-resolution/config-writer.d.ts.map +0 -1
- package/dist/config-resolution/config-writer.js +0 -164
- package/dist/config-resolution/config-writer.js.map +0 -1
- package/dist/config-resolution/context-package-manifest.d.ts +0 -3
- package/dist/config-resolution/context-package-manifest.d.ts.map +0 -1
- package/dist/config-resolution/context-package-manifest.js +0 -23
- package/dist/config-resolution/context-package-manifest.js.map +0 -1
- package/dist/config-resolution/discovery.d.ts +0 -18
- package/dist/config-resolution/discovery.d.ts.map +0 -1
- package/dist/config-resolution/discovery.js +0 -225
- package/dist/config-resolution/discovery.js.map +0 -1
- package/dist/config-resolution/index.d.ts +0 -4
- package/dist/config-resolution/index.d.ts.map +0 -1
- package/dist/config-resolution/index.js +0 -4
- package/dist/config-resolution/index.js.map +0 -1
- package/dist/config-resolution/provider-defaults.d.ts +0 -4
- package/dist/config-resolution/provider-defaults.d.ts.map +0 -1
- package/dist/config-resolution/provider-defaults.js +0 -27
- package/dist/config-resolution/provider-defaults.js.map +0 -1
- package/dist/config-resolution/resolver.d.ts +0 -16
- package/dist/config-resolution/resolver.d.ts.map +0 -1
- package/dist/config-resolution/resolver.js +0 -329
- package/dist/config-resolution/resolver.js.map +0 -1
- package/dist/config-resolution/schema.d.ts +0 -127
- package/dist/config-resolution/schema.d.ts.map +0 -1
- package/dist/config-resolution/schema.js +0 -189
- package/dist/config-resolution/schema.js.map +0 -1
- package/dist/config-resolution/stable-json.d.ts +0 -3
- package/dist/config-resolution/stable-json.d.ts.map +0 -1
- package/dist/config-resolution/stable-json.js +0 -18
- package/dist/config-resolution/stable-json.js.map +0 -1
- package/dist/config-resolution/types.d.ts +0 -134
- package/dist/config-resolution/types.d.ts.map +0 -1
- package/dist/config-resolution/types.js +0 -5
- package/dist/config-resolution/types.js.map +0 -1
- package/dist/context/local-edge-auto-sync.d.ts +0 -17
- package/dist/context/local-edge-auto-sync.d.ts.map +0 -1
- package/dist/context/local-edge-auto-sync.js +0 -94
- package/dist/context/local-edge-auto-sync.js.map +0 -1
- package/dist/context/local-edge-candidates.d.ts +0 -58
- package/dist/context/local-edge-candidates.d.ts.map +0 -1
- package/dist/context/local-edge-candidates.js +0 -276
- package/dist/context/local-edge-candidates.js.map +0 -1
- package/dist/context/local-edge-crypto.d.ts +0 -28
- package/dist/context/local-edge-crypto.d.ts.map +0 -1
- package/dist/context/local-edge-crypto.js +0 -76
- package/dist/context/local-edge-crypto.js.map +0 -1
- package/dist/context/local-edge-decision-applications.d.ts +0 -13
- package/dist/context/local-edge-decision-applications.d.ts.map +0 -1
- package/dist/context/local-edge-decision-applications.js +0 -78
- package/dist/context/local-edge-decision-applications.js.map +0 -1
- package/dist/context/local-edge-decision-signature.d.ts +0 -3
- package/dist/context/local-edge-decision-signature.d.ts.map +0 -1
- package/dist/context/local-edge-decision-signature.js +0 -67
- package/dist/context/local-edge-decision-signature.js.map +0 -1
- package/dist/context/local-edge-engine.d.ts +0 -38
- package/dist/context/local-edge-engine.d.ts.map +0 -1
- package/dist/context/local-edge-engine.js +0 -138
- package/dist/context/local-edge-engine.js.map +0 -1
- package/dist/context/local-edge-key-store.d.ts +0 -4
- package/dist/context/local-edge-key-store.d.ts.map +0 -1
- package/dist/context/local-edge-key-store.js +0 -21
- package/dist/context/local-edge-key-store.js.map +0 -1
- package/dist/context/local-edge-metadata.d.ts +0 -8
- package/dist/context/local-edge-metadata.d.ts.map +0 -1
- package/dist/context/local-edge-metadata.js +0 -105
- package/dist/context/local-edge-metadata.js.map +0 -1
- package/dist/context/local-edge-paths.d.ts +0 -4
- package/dist/context/local-edge-paths.d.ts.map +0 -1
- package/dist/context/local-edge-paths.js +0 -11
- package/dist/context/local-edge-paths.js.map +0 -1
- package/dist/context/local-edge-store.d.ts +0 -137
- package/dist/context/local-edge-store.d.ts.map +0 -1
- package/dist/context/local-edge-store.js +0 -284
- package/dist/context/local-edge-store.js.map +0 -1
- package/dist/context/local-edge-sync.d.ts +0 -104
- package/dist/context/local-edge-sync.d.ts.map +0 -1
- package/dist/context/local-edge-sync.js +0 -716
- package/dist/context/local-edge-sync.js.map +0 -1
- package/dist/context/local-edge-types.d.ts +0 -330
- package/dist/context/local-edge-types.d.ts.map +0 -1
- package/dist/context/local-edge-types.js +0 -5
- package/dist/context/local-edge-types.js.map +0 -1
- package/dist/context-providers/confluence-provider.d.ts +0 -3
- package/dist/context-providers/confluence-provider.d.ts.map +0 -1
- package/dist/context-providers/confluence-provider.js +0 -170
- package/dist/context-providers/confluence-provider.js.map +0 -1
- package/dist/context-providers/github-repo-provider.d.ts +0 -3
- package/dist/context-providers/github-repo-provider.d.ts.map +0 -1
- package/dist/context-providers/github-repo-provider.js +0 -313
- package/dist/context-providers/github-repo-provider.js.map +0 -1
- package/dist/context-providers/notion-provider.d.ts +0 -3
- package/dist/context-providers/notion-provider.d.ts.map +0 -1
- package/dist/context-providers/notion-provider.js +0 -157
- package/dist/context-providers/notion-provider.js.map +0 -1
- package/dist/context-providers/registry.d.ts +0 -5
- package/dist/context-providers/registry.d.ts.map +0 -1
- package/dist/context-providers/registry.js +0 -19
- package/dist/context-providers/registry.js.map +0 -1
- package/dist/context-providers/repo-docs-provider.d.ts +0 -19
- package/dist/context-providers/repo-docs-provider.d.ts.map +0 -1
- package/dist/context-providers/repo-docs-provider.js +0 -188
- package/dist/context-providers/repo-docs-provider.js.map +0 -1
- package/dist/context-providers/types.d.ts +0 -75
- package/dist/context-providers/types.d.ts.map +0 -1
- package/dist/context-providers/types.js +0 -2
- package/dist/context-providers/types.js.map +0 -1
- package/dist/context-providers/viewport-vault-provider.d.ts +0 -3
- package/dist/context-providers/viewport-vault-provider.d.ts.map +0 -1
- package/dist/context-providers/viewport-vault-provider.js +0 -84
- package/dist/context-providers/viewport-vault-provider.js.map +0 -1
- package/dist/core/agent-registry.d.ts +0 -130
- package/dist/core/agent-registry.d.ts.map +0 -1
- package/dist/core/agent-registry.js +0 -131
- package/dist/core/agent-registry.js.map +0 -1
- package/dist/core/config-schema.d.ts +0 -230
- package/dist/core/config-schema.d.ts.map +0 -1
- package/dist/core/config-schema.js +0 -175
- package/dist/core/config-schema.js.map +0 -1
- package/dist/core/config.d.ts +0 -305
- package/dist/core/config.d.ts.map +0 -1
- package/dist/core/config.js +0 -453
- package/dist/core/config.js.map +0 -1
- package/dist/core/daemon.d.ts +0 -147
- package/dist/core/daemon.d.ts.map +0 -1
- package/dist/core/daemon.js +0 -275
- package/dist/core/daemon.js.map +0 -1
- package/dist/core/discovered-sessions.d.ts +0 -7
- package/dist/core/discovered-sessions.d.ts.map +0 -1
- package/dist/core/discovered-sessions.js +0 -44
- package/dist/core/discovered-sessions.js.map +0 -1
- package/dist/core/error-codes.d.ts +0 -32
- package/dist/core/error-codes.d.ts.map +0 -1
- package/dist/core/error-codes.js +0 -31
- package/dist/core/error-codes.js.map +0 -1
- package/dist/core/errors.d.ts +0 -16
- package/dist/core/errors.d.ts.map +0 -1
- package/dist/core/errors.js +0 -45
- package/dist/core/errors.js.map +0 -1
- package/dist/core/events.d.ts +0 -213
- package/dist/core/events.d.ts.map +0 -1
- package/dist/core/events.js +0 -61
- package/dist/core/events.js.map +0 -1
- package/dist/core/interfaces.d.ts +0 -304
- package/dist/core/interfaces.d.ts.map +0 -1
- package/dist/core/interfaces.js +0 -9
- package/dist/core/interfaces.js.map +0 -1
- package/dist/core/logger.d.ts +0 -11
- package/dist/core/logger.d.ts.map +0 -1
- package/dist/core/logger.js +0 -23
- package/dist/core/logger.js.map +0 -1
- package/dist/core/machine-name.d.ts +0 -3
- package/dist/core/machine-name.d.ts.map +0 -1
- package/dist/core/machine-name.js +0 -11
- package/dist/core/machine-name.js.map +0 -1
- package/dist/core/metrics.d.ts +0 -24
- package/dist/core/metrics.d.ts.map +0 -1
- package/dist/core/metrics.js +0 -32
- package/dist/core/metrics.js.map +0 -1
- package/dist/core/output.d.ts +0 -13
- package/dist/core/output.d.ts.map +0 -1
- package/dist/core/output.js +0 -23
- package/dist/core/output.js.map +0 -1
- package/dist/core/package-meta.d.ts +0 -12
- package/dist/core/package-meta.d.ts.map +0 -1
- package/dist/core/package-meta.js +0 -87
- package/dist/core/package-meta.js.map +0 -1
- package/dist/core/permission-coordinator.d.ts +0 -67
- package/dist/core/permission-coordinator.d.ts.map +0 -1
- package/dist/core/permission-coordinator.js +0 -211
- package/dist/core/permission-coordinator.js.map +0 -1
- package/dist/core/profiles.d.ts +0 -43
- package/dist/core/profiles.d.ts.map +0 -1
- package/dist/core/profiles.js +0 -181
- package/dist/core/profiles.js.map +0 -1
- package/dist/core/redaction.d.ts +0 -4
- package/dist/core/redaction.d.ts.map +0 -1
- package/dist/core/redaction.js +0 -76
- package/dist/core/redaction.js.map +0 -1
- package/dist/core/runtime-identity.d.ts +0 -45
- package/dist/core/runtime-identity.d.ts.map +0 -1
- package/dist/core/runtime-identity.js +0 -130
- package/dist/core/runtime-identity.js.map +0 -1
- package/dist/core/session-context-prompt.d.ts +0 -22
- package/dist/core/session-context-prompt.d.ts.map +0 -1
- package/dist/core/session-context-prompt.js +0 -213
- package/dist/core/session-context-prompt.js.map +0 -1
- package/dist/core/session-discovery-runner.d.ts +0 -11
- package/dist/core/session-discovery-runner.d.ts.map +0 -1
- package/dist/core/session-discovery-runner.js +0 -37
- package/dist/core/session-discovery-runner.js.map +0 -1
- package/dist/core/session-manager.d.ts +0 -130
- package/dist/core/session-manager.d.ts.map +0 -1
- package/dist/core/session-manager.js +0 -434
- package/dist/core/session-manager.js.map +0 -1
- package/dist/core/session-state-file.d.ts +0 -20
- package/dist/core/session-state-file.d.ts.map +0 -1
- package/dist/core/session-state-file.js +0 -51
- package/dist/core/session-state-file.js.map +0 -1
- package/dist/core/types.d.ts +0 -290
- package/dist/core/types.d.ts.map +0 -1
- package/dist/core/types.js +0 -88
- package/dist/core/types.js.map +0 -1
- package/dist/core/workflow-linked-discovery.d.ts +0 -17
- package/dist/core/workflow-linked-discovery.d.ts.map +0 -1
- package/dist/core/workflow-linked-discovery.js +0 -53
- package/dist/core/workflow-linked-discovery.js.map +0 -1
- package/dist/directories/manager.d.ts +0 -33
- package/dist/directories/manager.d.ts.map +0 -1
- package/dist/directories/manager.js +0 -129
- package/dist/directories/manager.js.map +0 -1
- package/dist/discovery/claude.d.ts +0 -29
- package/dist/discovery/claude.d.ts.map +0 -1
- package/dist/discovery/claude.js +0 -66
- package/dist/discovery/claude.js.map +0 -1
- package/dist/discovery/codex-parser.d.ts +0 -20
- package/dist/discovery/codex-parser.d.ts.map +0 -1
- package/dist/discovery/codex-parser.js +0 -378
- package/dist/discovery/codex-parser.js.map +0 -1
- package/dist/discovery/codex-summary.d.ts +0 -6
- package/dist/discovery/codex-summary.d.ts.map +0 -1
- package/dist/discovery/codex-summary.js +0 -27
- package/dist/discovery/codex-summary.js.map +0 -1
- package/dist/discovery/codex.d.ts +0 -32
- package/dist/discovery/codex.d.ts.map +0 -1
- package/dist/discovery/codex.js +0 -206
- package/dist/discovery/codex.js.map +0 -1
- package/dist/discovery/dedupe.d.ts +0 -3
- package/dist/discovery/dedupe.d.ts.map +0 -1
- package/dist/discovery/dedupe.js +0 -13
- package/dist/discovery/dedupe.js.map +0 -1
- package/dist/discovery/gemini.d.ts +0 -15
- package/dist/discovery/gemini.d.ts.map +0 -1
- package/dist/discovery/gemini.js +0 -151
- package/dist/discovery/gemini.js.map +0 -1
- package/dist/discovery/jsonl-entry-parser.d.ts +0 -74
- package/dist/discovery/jsonl-entry-parser.d.ts.map +0 -1
- package/dist/discovery/jsonl-entry-parser.js +0 -1034
- package/dist/discovery/jsonl-entry-parser.js.map +0 -1
- package/dist/discovery/jsonl-paths.d.ts +0 -17
- package/dist/discovery/jsonl-paths.d.ts.map +0 -1
- package/dist/discovery/jsonl-paths.js +0 -56
- package/dist/discovery/jsonl-paths.js.map +0 -1
- package/dist/discovery/jsonl-reader.d.ts +0 -121
- package/dist/discovery/jsonl-reader.d.ts.map +0 -1
- package/dist/discovery/jsonl-reader.js +0 -458
- package/dist/discovery/jsonl-reader.js.map +0 -1
- package/dist/discovery/watcher.d.ts +0 -29
- package/dist/discovery/watcher.d.ts.map +0 -1
- package/dist/discovery/watcher.js +0 -426
- package/dist/discovery/watcher.js.map +0 -1
- package/dist/hooks/capabilities.d.ts +0 -17
- package/dist/hooks/capabilities.d.ts.map +0 -1
- package/dist/hooks/capabilities.js +0 -114
- package/dist/hooks/capabilities.js.map +0 -1
- package/dist/hooks/context-injector.d.ts +0 -7
- package/dist/hooks/context-injector.d.ts.map +0 -1
- package/dist/hooks/context-injector.js +0 -91
- package/dist/hooks/context-injector.js.map +0 -1
- package/dist/hooks/ephemeral-plan-drafts.d.ts +0 -34
- package/dist/hooks/ephemeral-plan-drafts.d.ts.map +0 -1
- package/dist/hooks/ephemeral-plan-drafts.js +0 -62
- package/dist/hooks/ephemeral-plan-drafts.js.map +0 -1
- package/dist/hooks/index.d.ts +0 -12
- package/dist/hooks/index.d.ts.map +0 -1
- package/dist/hooks/index.js +0 -9
- package/dist/hooks/index.js.map +0 -1
- package/dist/hooks/installers/base.d.ts +0 -27
- package/dist/hooks/installers/base.d.ts.map +0 -1
- package/dist/hooks/installers/base.js +0 -9
- package/dist/hooks/installers/base.js.map +0 -1
- package/dist/hooks/installers/claude.d.ts +0 -18
- package/dist/hooks/installers/claude.d.ts.map +0 -1
- package/dist/hooks/installers/claude.js +0 -146
- package/dist/hooks/installers/claude.js.map +0 -1
- package/dist/hooks/plan-extractor.d.ts +0 -20
- package/dist/hooks/plan-extractor.d.ts.map +0 -1
- package/dist/hooks/plan-extractor.js +0 -128
- package/dist/hooks/plan-extractor.js.map +0 -1
- package/dist/hooks/platform-plan-sync.d.ts +0 -24
- package/dist/hooks/platform-plan-sync.d.ts.map +0 -1
- package/dist/hooks/platform-plan-sync.js +0 -115
- package/dist/hooks/platform-plan-sync.js.map +0 -1
- package/dist/hooks/router.d.ts +0 -64
- package/dist/hooks/router.d.ts.map +0 -1
- package/dist/hooks/router.js +0 -245
- package/dist/hooks/router.js.map +0 -1
- package/dist/hooks/specific-events.d.ts +0 -11
- package/dist/hooks/specific-events.d.ts.map +0 -1
- package/dist/hooks/specific-events.js +0 -201
- package/dist/hooks/specific-events.js.map +0 -1
- package/dist/hooks/supervision.d.ts +0 -29
- package/dist/hooks/supervision.d.ts.map +0 -1
- package/dist/hooks/supervision.js +0 -79
- package/dist/hooks/supervision.js.map +0 -1
- package/dist/hooks/trusted-edge-plan-artifacts.d.ts +0 -118
- package/dist/hooks/trusted-edge-plan-artifacts.d.ts.map +0 -1
- package/dist/hooks/trusted-edge-plan-artifacts.js +0 -386
- package/dist/hooks/trusted-edge-plan-artifacts.js.map +0 -1
- package/dist/hooks/types.d.ts +0 -204
- package/dist/hooks/types.d.ts.map +0 -1
- package/dist/hooks/types.js +0 -184
- package/dist/hooks/types.js.map +0 -1
- package/dist/index.d.ts.map +0 -1
- package/dist/index.js.map +0 -1
- package/dist/permissions/engine.d.ts +0 -23
- package/dist/permissions/engine.d.ts.map +0 -1
- package/dist/permissions/engine.js +0 -43
- package/dist/permissions/engine.js.map +0 -1
- package/dist/plugins/loader.d.ts +0 -44
- package/dist/plugins/loader.d.ts.map +0 -1
- package/dist/plugins/loader.js +0 -200
- package/dist/plugins/loader.js.map +0 -1
- package/dist/relay/bridge-backoff.d.ts +0 -3
- package/dist/relay/bridge-backoff.d.ts.map +0 -1
- package/dist/relay/bridge-backoff.js +0 -10
- package/dist/relay/bridge-backoff.js.map +0 -1
- package/dist/relay/bridge-connections.d.ts +0 -26
- package/dist/relay/bridge-connections.d.ts.map +0 -1
- package/dist/relay/bridge-connections.js +0 -34
- package/dist/relay/bridge-connections.js.map +0 -1
- package/dist/relay/bridge-constants.d.ts +0 -12
- package/dist/relay/bridge-constants.d.ts.map +0 -1
- package/dist/relay/bridge-constants.js +0 -12
- package/dist/relay/bridge-constants.js.map +0 -1
- package/dist/relay/bridge-crypto.d.ts +0 -19
- package/dist/relay/bridge-crypto.d.ts.map +0 -1
- package/dist/relay/bridge-crypto.js +0 -72
- package/dist/relay/bridge-crypto.js.map +0 -1
- package/dist/relay/bridge-daemon-key-registration.d.ts +0 -18
- package/dist/relay/bridge-daemon-key-registration.d.ts.map +0 -1
- package/dist/relay/bridge-daemon-key-registration.js +0 -94
- package/dist/relay/bridge-daemon-key-registration.js.map +0 -1
- package/dist/relay/bridge-errors.d.ts +0 -8
- package/dist/relay/bridge-errors.d.ts.map +0 -1
- package/dist/relay/bridge-errors.js +0 -23
- package/dist/relay/bridge-errors.js.map +0 -1
- package/dist/relay/bridge-frame-logger.d.ts +0 -2
- package/dist/relay/bridge-frame-logger.d.ts.map +0 -1
- package/dist/relay/bridge-frame-logger.js +0 -37
- package/dist/relay/bridge-frame-logger.js.map +0 -1
- package/dist/relay/bridge-handshake-profile.d.ts +0 -3
- package/dist/relay/bridge-handshake-profile.d.ts.map +0 -1
- package/dist/relay/bridge-handshake-profile.js +0 -7
- package/dist/relay/bridge-handshake-profile.js.map +0 -1
- package/dist/relay/bridge-identity-store.d.ts +0 -9
- package/dist/relay/bridge-identity-store.d.ts.map +0 -1
- package/dist/relay/bridge-identity-store.js +0 -77
- package/dist/relay/bridge-identity-store.js.map +0 -1
- package/dist/relay/bridge-jwt.d.ts +0 -18
- package/dist/relay/bridge-jwt.d.ts.map +0 -1
- package/dist/relay/bridge-jwt.js +0 -130
- package/dist/relay/bridge-jwt.js.map +0 -1
- package/dist/relay/bridge-key-exchange.d.ts +0 -46
- package/dist/relay/bridge-key-exchange.d.ts.map +0 -1
- package/dist/relay/bridge-key-exchange.js +0 -186
- package/dist/relay/bridge-key-exchange.js.map +0 -1
- package/dist/relay/bridge-network.d.ts +0 -12
- package/dist/relay/bridge-network.d.ts.map +0 -1
- package/dist/relay/bridge-network.js +0 -90
- package/dist/relay/bridge-network.js.map +0 -1
- package/dist/relay/bridge-noise-v3.d.ts +0 -74
- package/dist/relay/bridge-noise-v3.d.ts.map +0 -1
- package/dist/relay/bridge-noise-v3.js +0 -406
- package/dist/relay/bridge-noise-v3.js.map +0 -1
- package/dist/relay/bridge-org-routing-filter.d.ts +0 -8
- package/dist/relay/bridge-org-routing-filter.d.ts.map +0 -1
- package/dist/relay/bridge-org-routing-filter.js +0 -129
- package/dist/relay/bridge-org-routing-filter.js.map +0 -1
- package/dist/relay/bridge-pairing-channel.d.ts +0 -12
- package/dist/relay/bridge-pairing-channel.d.ts.map +0 -1
- package/dist/relay/bridge-pairing-channel.js +0 -30
- package/dist/relay/bridge-pairing-channel.js.map +0 -1
- package/dist/relay/bridge-pairing-control-handler.d.ts +0 -26
- package/dist/relay/bridge-pairing-control-handler.d.ts.map +0 -1
- package/dist/relay/bridge-pairing-control-handler.js +0 -136
- package/dist/relay/bridge-pairing-control-handler.js.map +0 -1
- package/dist/relay/bridge-relay-sessions.d.ts +0 -45
- package/dist/relay/bridge-relay-sessions.d.ts.map +0 -1
- package/dist/relay/bridge-relay-sessions.js +0 -88
- package/dist/relay/bridge-relay-sessions.js.map +0 -1
- package/dist/relay/bridge-token-issuer.d.ts +0 -33
- package/dist/relay/bridge-token-issuer.d.ts.map +0 -1
- package/dist/relay/bridge-token-issuer.js +0 -173
- package/dist/relay/bridge-token-issuer.js.map +0 -1
- package/dist/relay/daemon-relay-bridge.d.ts +0 -92
- package/dist/relay/daemon-relay-bridge.d.ts.map +0 -1
- package/dist/relay/daemon-relay-bridge.js +0 -549
- package/dist/relay/daemon-relay-bridge.js.map +0 -1
- package/dist/relay/relay-control-frames.d.ts +0 -31
- package/dist/relay/relay-control-frames.d.ts.map +0 -1
- package/dist/relay/relay-control-frames.js +0 -65
- package/dist/relay/relay-control-frames.js.map +0 -1
- package/dist/security/child-env.d.ts +0 -3
- package/dist/security/child-env.d.ts.map +0 -1
- package/dist/security/child-env.js +0 -44
- package/dist/security/child-env.js.map +0 -1
- package/dist/security/epoch-enrollment.d.ts +0 -48
- package/dist/security/epoch-enrollment.d.ts.map +0 -1
- package/dist/security/epoch-enrollment.js +0 -290
- package/dist/security/epoch-enrollment.js.map +0 -1
- package/dist/security/epoch-protocol.d.ts +0 -181
- package/dist/security/epoch-protocol.d.ts.map +0 -1
- package/dist/security/epoch-protocol.js +0 -285
- package/dist/security/epoch-protocol.js.map +0 -1
- package/dist/security/epoch-public-pins.d.ts +0 -19
- package/dist/security/epoch-public-pins.d.ts.map +0 -1
- package/dist/security/epoch-public-pins.js +0 -129
- package/dist/security/epoch-public-pins.js.map +0 -1
- package/dist/security/epoch-recovery.d.ts +0 -56
- package/dist/security/epoch-recovery.d.ts.map +0 -1
- package/dist/security/epoch-recovery.js +0 -314
- package/dist/security/epoch-recovery.js.map +0 -1
- package/dist/security/epoch-store.d.ts +0 -111
- package/dist/security/epoch-store.d.ts.map +0 -1
- package/dist/security/epoch-store.js +0 -224
- package/dist/security/epoch-store.js.map +0 -1
- package/dist/security/epoch-sync.d.ts +0 -47
- package/dist/security/epoch-sync.d.ts.map +0 -1
- package/dist/security/epoch-sync.js +0 -371
- package/dist/security/epoch-sync.js.map +0 -1
- package/dist/security/team-epoch-grant-payloads.d.ts +0 -44
- package/dist/security/team-epoch-grant-payloads.d.ts.map +0 -1
- package/dist/security/team-epoch-grant-payloads.js +0 -100
- package/dist/security/team-epoch-grant-payloads.js.map +0 -1
- package/dist/security/team-epoch-grants.d.ts +0 -31
- package/dist/security/team-epoch-grants.d.ts.map +0 -1
- package/dist/security/team-epoch-grants.js +0 -194
- package/dist/security/team-epoch-grants.js.map +0 -1
- package/dist/server/auth.d.ts +0 -33
- package/dist/server/auth.d.ts.map +0 -1
- package/dist/server/auth.js +0 -82
- package/dist/server/auth.js.map +0 -1
- package/dist/server/context-preview-service.d.ts +0 -26
- package/dist/server/context-preview-service.d.ts.map +0 -1
- package/dist/server/context-preview-service.js +0 -71
- package/dist/server/context-preview-service.js.map +0 -1
- package/dist/server/discovered-session-window.d.ts +0 -4
- package/dist/server/discovered-session-window.d.ts.map +0 -1
- package/dist/server/discovered-session-window.js +0 -5
- package/dist/server/discovered-session-window.js.map +0 -1
- package/dist/server/discovered-watch-key.d.ts +0 -5
- package/dist/server/discovered-watch-key.d.ts.map +0 -1
- package/dist/server/discovered-watch-key.js +0 -31
- package/dist/server/discovered-watch-key.js.map +0 -1
- package/dist/server/hello-builder.d.ts +0 -102
- package/dist/server/hello-builder.d.ts.map +0 -1
- package/dist/server/hello-builder.js +0 -227
- package/dist/server/hello-builder.js.map +0 -1
- package/dist/server/http-context-routes.d.ts +0 -4
- package/dist/server/http-context-routes.d.ts.map +0 -1
- package/dist/server/http-context-routes.js +0 -283
- package/dist/server/http-context-routes.js.map +0 -1
- package/dist/server/http-health-routes.d.ts +0 -11
- package/dist/server/http-health-routes.d.ts.map +0 -1
- package/dist/server/http-health-routes.js +0 -69
- package/dist/server/http-health-routes.js.map +0 -1
- package/dist/server/http-lifecycle-routes.d.ts +0 -6
- package/dist/server/http-lifecycle-routes.d.ts.map +0 -1
- package/dist/server/http-lifecycle-routes.js +0 -17
- package/dist/server/http-lifecycle-routes.js.map +0 -1
- package/dist/server/http-pairing-routes.d.ts +0 -14
- package/dist/server/http-pairing-routes.d.ts.map +0 -1
- package/dist/server/http-pairing-routes.js +0 -110
- package/dist/server/http-pairing-routes.js.map +0 -1
- package/dist/server/http-request-schemas.d.ts +0 -152
- package/dist/server/http-request-schemas.d.ts.map +0 -1
- package/dist/server/http-request-schemas.js +0 -183
- package/dist/server/http-request-schemas.js.map +0 -1
- package/dist/server/http-route-types.d.ts +0 -11
- package/dist/server/http-route-types.d.ts.map +0 -1
- package/dist/server/http-route-types.js +0 -2
- package/dist/server/http-route-types.js.map +0 -1
- package/dist/server/http-server.d.ts +0 -26
- package/dist/server/http-server.d.ts.map +0 -1
- package/dist/server/http-server.js +0 -400
- package/dist/server/http-server.js.map +0 -1
- package/dist/server/http-session-routes.d.ts +0 -4
- package/dist/server/http-session-routes.d.ts.map +0 -1
- package/dist/server/http-session-routes.js +0 -234
- package/dist/server/http-session-routes.js.map +0 -1
- package/dist/server/message-normalizers.d.ts +0 -11
- package/dist/server/message-normalizers.d.ts.map +0 -1
- package/dist/server/message-normalizers.js +0 -104
- package/dist/server/message-normalizers.js.map +0 -1
- package/dist/server/pairing-file-store.d.ts +0 -10
- package/dist/server/pairing-file-store.d.ts.map +0 -1
- package/dist/server/pairing-file-store.js +0 -69
- package/dist/server/pairing-file-store.js.map +0 -1
- package/dist/server/pairing-identity-store.d.ts +0 -5
- package/dist/server/pairing-identity-store.d.ts.map +0 -1
- package/dist/server/pairing-identity-store.js +0 -121
- package/dist/server/pairing-identity-store.js.map +0 -1
- package/dist/server/pairing-offer-types.d.ts +0 -98
- package/dist/server/pairing-offer-types.d.ts.map +0 -1
- package/dist/server/pairing-offer-types.js +0 -2
- package/dist/server/pairing-offer-types.js.map +0 -1
- package/dist/server/pairing-offers.d.ts +0 -29
- package/dist/server/pairing-offers.d.ts.map +0 -1
- package/dist/server/pairing-offers.js +0 -351
- package/dist/server/pairing-offers.js.map +0 -1
- package/dist/server/pairing-peer-bindings.d.ts +0 -18
- package/dist/server/pairing-peer-bindings.d.ts.map +0 -1
- package/dist/server/pairing-peer-bindings.js +0 -198
- package/dist/server/pairing-peer-bindings.js.map +0 -1
- package/dist/server/rate-limiter.d.ts +0 -21
- package/dist/server/rate-limiter.d.ts.map +0 -1
- package/dist/server/rate-limiter.js +0 -70
- package/dist/server/rate-limiter.js.map +0 -1
- package/dist/server/replay-events.d.ts +0 -6
- package/dist/server/replay-events.d.ts.map +0 -1
- package/dist/server/replay-events.js +0 -104
- package/dist/server/replay-events.js.map +0 -1
- package/dist/server/replay-persistence.d.ts +0 -18
- package/dist/server/replay-persistence.d.ts.map +0 -1
- package/dist/server/replay-persistence.js +0 -123
- package/dist/server/replay-persistence.js.map +0 -1
- package/dist/server/replay-types.d.ts +0 -25
- package/dist/server/replay-types.d.ts.map +0 -1
- package/dist/server/replay-types.js +0 -2
- package/dist/server/replay-types.js.map +0 -1
- package/dist/server/ring-buffer.d.ts +0 -48
- package/dist/server/ring-buffer.d.ts.map +0 -1
- package/dist/server/ring-buffer.js +0 -235
- package/dist/server/ring-buffer.js.map +0 -1
- package/dist/server/security.d.ts +0 -22
- package/dist/server/security.d.ts.map +0 -1
- package/dist/server/security.js +0 -127
- package/dist/server/security.js.map +0 -1
- package/dist/server/session-message-reader.d.ts +0 -15
- package/dist/server/session-message-reader.d.ts.map +0 -1
- package/dist/server/session-message-reader.js +0 -107
- package/dist/server/session-message-reader.js.map +0 -1
- package/dist/server/trusted-edge-command-capability.d.ts +0 -15
- package/dist/server/trusted-edge-command-capability.d.ts.map +0 -1
- package/dist/server/trusted-edge-command-capability.js +0 -118
- package/dist/server/trusted-edge-command-capability.js.map +0 -1
- package/dist/server/ws-command-handlers.d.ts +0 -28
- package/dist/server/ws-command-handlers.d.ts.map +0 -1
- package/dist/server/ws-command-handlers.js +0 -489
- package/dist/server/ws-command-handlers.js.map +0 -1
- package/dist/server/ws-daemon-event-bridge.d.ts +0 -22
- package/dist/server/ws-daemon-event-bridge.d.ts.map +0 -1
- package/dist/server/ws-daemon-event-bridge.js +0 -392
- package/dist/server/ws-daemon-event-bridge.js.map +0 -1
- package/dist/server/ws-limits.d.ts +0 -2
- package/dist/server/ws-limits.d.ts.map +0 -1
- package/dist/server/ws-limits.js +0 -12
- package/dist/server/ws-limits.js.map +0 -1
- package/dist/server/ws-protocol.d.ts +0 -858
- package/dist/server/ws-protocol.d.ts.map +0 -1
- package/dist/server/ws-protocol.js +0 -417
- package/dist/server/ws-protocol.js.map +0 -1
- package/dist/server/ws-server.d.ts +0 -26
- package/dist/server/ws-server.d.ts.map +0 -1
- package/dist/server/ws-server.js +0 -314
- package/dist/server/ws-server.js.map +0 -1
- package/dist/server/ws-session-command-handlers.d.ts +0 -29
- package/dist/server/ws-session-command-handlers.d.ts.map +0 -1
- package/dist/server/ws-session-command-handlers.js +0 -320
- package/dist/server/ws-session-command-handlers.js.map +0 -1
- package/dist/server/ws-workflow-command-handlers.d.ts +0 -17
- package/dist/server/ws-workflow-command-handlers.d.ts.map +0 -1
- package/dist/server/ws-workflow-command-handlers.js +0 -68
- package/dist/server/ws-workflow-command-handlers.js.map +0 -1
- package/dist/session-enrichment/git.d.ts +0 -9
- package/dist/session-enrichment/git.d.ts.map +0 -1
- package/dist/session-enrichment/git.js +0 -48
- package/dist/session-enrichment/git.js.map +0 -1
- package/dist/startup-agents.d.ts +0 -6
- package/dist/startup-agents.d.ts.map +0 -1
- package/dist/startup-agents.js +0 -102
- package/dist/startup-agents.js.map +0 -1
- package/dist/startup-prereqs.d.ts +0 -29
- package/dist/startup-prereqs.d.ts.map +0 -1
- package/dist/startup-prereqs.js +0 -209
- package/dist/startup-prereqs.js.map +0 -1
- package/dist/startup-relay-security.d.ts +0 -3
- package/dist/startup-relay-security.d.ts.map +0 -1
- package/dist/startup-relay-security.js +0 -61
- package/dist/startup-relay-security.js.map +0 -1
- package/dist/startup-session-persistence.d.ts +0 -7
- package/dist/startup-session-persistence.d.ts.map +0 -1
- package/dist/startup-session-persistence.js +0 -72
- package/dist/startup-session-persistence.js.map +0 -1
- package/dist/startup-watchers.d.ts +0 -7
- package/dist/startup-watchers.d.ts.map +0 -1
- package/dist/startup-watchers.js +0 -196
- package/dist/startup-watchers.js.map +0 -1
- package/dist/startup.d.ts +0 -29
- package/dist/startup.d.ts.map +0 -1
- package/dist/startup.js +0 -549
- package/dist/startup.js.map +0 -1
- package/dist/tracking/git-tracker.d.ts +0 -56
- package/dist/tracking/git-tracker.d.ts.map +0 -1
- package/dist/tracking/git-tracker.js +0 -342
- package/dist/tracking/git-tracker.js.map +0 -1
- package/dist/tracking/noop-tracker.d.ts +0 -27
- package/dist/tracking/noop-tracker.d.ts.map +0 -1
- package/dist/tracking/noop-tracker.js +0 -42
- package/dist/tracking/noop-tracker.js.map +0 -1
- package/dist/workflows/action-adapters.d.ts +0 -10
- package/dist/workflows/action-adapters.d.ts.map +0 -1
- package/dist/workflows/action-adapters.js +0 -203
- package/dist/workflows/action-adapters.js.map +0 -1
- package/dist/workflows/action-digest.d.ts +0 -8
- package/dist/workflows/action-digest.d.ts.map +0 -1
- package/dist/workflows/action-digest.js +0 -36
- package/dist/workflows/action-digest.js.map +0 -1
- package/dist/workflows/action-execution-ledger.d.ts +0 -8
- package/dist/workflows/action-execution-ledger.d.ts.map +0 -1
- package/dist/workflows/action-execution-ledger.js +0 -64
- package/dist/workflows/action-execution-ledger.js.map +0 -1
- package/dist/workflows/action-policy.d.ts +0 -3
- package/dist/workflows/action-policy.d.ts.map +0 -1
- package/dist/workflows/action-policy.js +0 -13
- package/dist/workflows/action-policy.js.map +0 -1
- package/dist/workflows/action-provider-adapters.d.ts +0 -17
- package/dist/workflows/action-provider-adapters.d.ts.map +0 -1
- package/dist/workflows/action-provider-adapters.js +0 -674
- package/dist/workflows/action-provider-adapters.js.map +0 -1
- package/dist/workflows/action-provider-utils.d.ts +0 -25
- package/dist/workflows/action-provider-utils.d.ts.map +0 -1
- package/dist/workflows/action-provider-utils.js +0 -121
- package/dist/workflows/action-provider-utils.js.map +0 -1
- package/dist/workflows/approval-actor.d.ts +0 -6
- package/dist/workflows/approval-actor.d.ts.map +0 -1
- package/dist/workflows/approval-actor.js +0 -27
- package/dist/workflows/approval-actor.js.map +0 -1
- package/dist/workflows/approval-on-reject.d.ts +0 -17
- package/dist/workflows/approval-on-reject.d.ts.map +0 -1
- package/dist/workflows/approval-on-reject.js +0 -64
- package/dist/workflows/approval-on-reject.js.map +0 -1
- package/dist/workflows/artifact-collector.d.ts +0 -11
- package/dist/workflows/artifact-collector.d.ts.map +0 -1
- package/dist/workflows/artifact-collector.js +0 -59
- package/dist/workflows/artifact-collector.js.map +0 -1
- package/dist/workflows/checkout-node.d.ts +0 -22
- package/dist/workflows/checkout-node.d.ts.map +0 -1
- package/dist/workflows/checkout-node.js +0 -201
- package/dist/workflows/checkout-node.js.map +0 -1
- package/dist/workflows/context-node-resolver.d.ts +0 -51
- package/dist/workflows/context-node-resolver.d.ts.map +0 -1
- package/dist/workflows/context-node-resolver.js +0 -932
- package/dist/workflows/context-node-resolver.js.map +0 -1
- package/dist/workflows/context-update-targets.d.ts +0 -12
- package/dist/workflows/context-update-targets.d.ts.map +0 -1
- package/dist/workflows/context-update-targets.js +0 -52
- package/dist/workflows/context-update-targets.js.map +0 -1
- package/dist/workflows/contract-binding.d.ts +0 -3
- package/dist/workflows/contract-binding.d.ts.map +0 -1
- package/dist/workflows/contract-binding.js +0 -19
- package/dist/workflows/contract-binding.js.map +0 -1
- package/dist/workflows/daemon-session.d.ts +0 -47
- package/dist/workflows/daemon-session.d.ts.map +0 -1
- package/dist/workflows/daemon-session.js +0 -320
- package/dist/workflows/daemon-session.js.map +0 -1
- package/dist/workflows/event-types.d.ts +0 -10
- package/dist/workflows/event-types.d.ts.map +0 -1
- package/dist/workflows/event-types.js +0 -2
- package/dist/workflows/event-types.js.map +0 -1
- package/dist/workflows/expression.d.ts +0 -81
- package/dist/workflows/expression.d.ts.map +0 -1
- package/dist/workflows/expression.js +0 -149
- package/dist/workflows/expression.js.map +0 -1
- package/dist/workflows/git-publish-node.d.ts +0 -43
- package/dist/workflows/git-publish-node.d.ts.map +0 -1
- package/dist/workflows/git-publish-node.js +0 -322
- package/dist/workflows/git-publish-node.js.map +0 -1
- package/dist/workflows/hook-registry.d.ts +0 -24
- package/dist/workflows/hook-registry.d.ts.map +0 -1
- package/dist/workflows/hook-registry.js +0 -52
- package/dist/workflows/hook-registry.js.map +0 -1
- package/dist/workflows/hook-types.d.ts +0 -21
- package/dist/workflows/hook-types.d.ts.map +0 -1
- package/dist/workflows/hook-types.js +0 -2
- package/dist/workflows/hook-types.js.map +0 -1
- package/dist/workflows/inline-agent-types.d.ts +0 -28
- package/dist/workflows/inline-agent-types.d.ts.map +0 -1
- package/dist/workflows/inline-agent-types.js +0 -2
- package/dist/workflows/inline-agent-types.js.map +0 -1
- package/dist/workflows/inline-agents.d.ts +0 -8
- package/dist/workflows/inline-agents.d.ts.map +0 -1
- package/dist/workflows/inline-agents.js +0 -108
- package/dist/workflows/inline-agents.js.map +0 -1
- package/dist/workflows/loop-executor.d.ts +0 -17
- package/dist/workflows/loop-executor.d.ts.map +0 -1
- package/dist/workflows/loop-executor.js +0 -175
- package/dist/workflows/loop-executor.js.map +0 -1
- package/dist/workflows/node-executor.d.ts +0 -31
- package/dist/workflows/node-executor.d.ts.map +0 -1
- package/dist/workflows/node-executor.js +0 -405
- package/dist/workflows/node-executor.js.map +0 -1
- package/dist/workflows/node-registry.d.ts +0 -42
- package/dist/workflows/node-registry.d.ts.map +0 -1
- package/dist/workflows/node-registry.js +0 -931
- package/dist/workflows/node-registry.js.map +0 -1
- package/dist/workflows/parser.d.ts +0 -17
- package/dist/workflows/parser.d.ts.map +0 -1
- package/dist/workflows/parser.js +0 -361
- package/dist/workflows/parser.js.map +0 -1
- package/dist/workflows/platform-command-applier.d.ts +0 -17
- package/dist/workflows/platform-command-applier.d.ts.map +0 -1
- package/dist/workflows/platform-command-applier.js +0 -264
- package/dist/workflows/platform-command-applier.js.map +0 -1
- package/dist/workflows/platform-context-client.d.ts +0 -59
- package/dist/workflows/platform-context-client.d.ts.map +0 -1
- package/dist/workflows/platform-context-client.internal.d.ts +0 -23
- package/dist/workflows/platform-context-client.internal.d.ts.map +0 -1
- package/dist/workflows/platform-context-client.internal.js +0 -124
- package/dist/workflows/platform-context-client.internal.js.map +0 -1
- package/dist/workflows/platform-context-client.js +0 -272
- package/dist/workflows/platform-context-client.js.map +0 -1
- package/dist/workflows/platform-context-client.types.d.ts +0 -41
- package/dist/workflows/platform-context-client.types.d.ts.map +0 -1
- package/dist/workflows/platform-context-client.types.js +0 -2
- package/dist/workflows/platform-context-client.types.js.map +0 -1
- package/dist/workflows/platform-runtime-command.d.ts +0 -40
- package/dist/workflows/platform-runtime-command.d.ts.map +0 -1
- package/dist/workflows/platform-runtime-command.js +0 -104
- package/dist/workflows/platform-runtime-command.js.map +0 -1
- package/dist/workflows/platform-sync-format.d.ts +0 -12
- package/dist/workflows/platform-sync-format.d.ts.map +0 -1
- package/dist/workflows/platform-sync-format.js +0 -60
- package/dist/workflows/platform-sync-format.js.map +0 -1
- package/dist/workflows/platform-sync-payload.d.ts +0 -9
- package/dist/workflows/platform-sync-payload.d.ts.map +0 -1
- package/dist/workflows/platform-sync-payload.js +0 -530
- package/dist/workflows/platform-sync-payload.js.map +0 -1
- package/dist/workflows/platform-sync.d.ts +0 -37
- package/dist/workflows/platform-sync.d.ts.map +0 -1
- package/dist/workflows/platform-sync.js +0 -243
- package/dist/workflows/platform-sync.js.map +0 -1
- package/dist/workflows/plugin-loader.d.ts +0 -28
- package/dist/workflows/plugin-loader.d.ts.map +0 -1
- package/dist/workflows/plugin-loader.js +0 -143
- package/dist/workflows/plugin-loader.js.map +0 -1
- package/dist/workflows/policy-enforcement.d.ts +0 -43
- package/dist/workflows/policy-enforcement.d.ts.map +0 -1
- package/dist/workflows/policy-enforcement.js +0 -0
- package/dist/workflows/policy-enforcement.js.map +0 -1
- package/dist/workflows/preflight.d.ts +0 -9
- package/dist/workflows/preflight.d.ts.map +0 -1
- package/dist/workflows/preflight.js +0 -171
- package/dist/workflows/preflight.js.map +0 -1
- package/dist/workflows/prompt-output.d.ts +0 -10
- package/dist/workflows/prompt-output.d.ts.map +0 -1
- package/dist/workflows/prompt-output.js +0 -93
- package/dist/workflows/prompt-output.js.map +0 -1
- package/dist/workflows/provider-reconciliation.d.ts +0 -28
- package/dist/workflows/provider-reconciliation.d.ts.map +0 -1
- package/dist/workflows/provider-reconciliation.js +0 -218
- package/dist/workflows/provider-reconciliation.js.map +0 -1
- package/dist/workflows/retry-classifier.d.ts +0 -18
- package/dist/workflows/retry-classifier.d.ts.map +0 -1
- package/dist/workflows/retry-classifier.js +0 -30
- package/dist/workflows/retry-classifier.js.map +0 -1
- package/dist/workflows/review-packet.d.ts +0 -3
- package/dist/workflows/review-packet.d.ts.map +0 -1
- package/dist/workflows/review-packet.js +0 -155
- package/dist/workflows/review-packet.js.map +0 -1
- package/dist/workflows/run-preparation.d.ts +0 -24
- package/dist/workflows/run-preparation.d.ts.map +0 -1
- package/dist/workflows/run-preparation.js +0 -258
- package/dist/workflows/run-preparation.js.map +0 -1
- package/dist/workflows/run-receipt-validation.d.ts +0 -29
- package/dist/workflows/run-receipt-validation.d.ts.map +0 -1
- package/dist/workflows/run-receipt-validation.js +0 -106
- package/dist/workflows/run-receipt-validation.js.map +0 -1
- package/dist/workflows/run-types.d.ts +0 -261
- package/dist/workflows/run-types.d.ts.map +0 -1
- package/dist/workflows/run-types.js +0 -2
- package/dist/workflows/run-types.js.map +0 -1
- package/dist/workflows/runner-canceler.d.ts +0 -22
- package/dist/workflows/runner-canceler.d.ts.map +0 -1
- package/dist/workflows/runner-canceler.js +0 -91
- package/dist/workflows/runner-canceler.js.map +0 -1
- package/dist/workflows/runner-hook-events.d.ts +0 -19
- package/dist/workflows/runner-hook-events.d.ts.map +0 -1
- package/dist/workflows/runner-hook-events.js +0 -16
- package/dist/workflows/runner-hook-events.js.map +0 -1
- package/dist/workflows/runner-reconciler.d.ts +0 -19
- package/dist/workflows/runner-reconciler.d.ts.map +0 -1
- package/dist/workflows/runner-reconciler.js +0 -109
- package/dist/workflows/runner-reconciler.js.map +0 -1
- package/dist/workflows/runner-resumer.d.ts +0 -33
- package/dist/workflows/runner-resumer.d.ts.map +0 -1
- package/dist/workflows/runner-resumer.js +0 -81
- package/dist/workflows/runner-resumer.js.map +0 -1
- package/dist/workflows/runner-scheduler.d.ts +0 -38
- package/dist/workflows/runner-scheduler.d.ts.map +0 -1
- package/dist/workflows/runner-scheduler.js +0 -243
- package/dist/workflows/runner-scheduler.js.map +0 -1
- package/dist/workflows/runner-shared.d.ts +0 -21
- package/dist/workflows/runner-shared.d.ts.map +0 -1
- package/dist/workflows/runner-shared.js +0 -92
- package/dist/workflows/runner-shared.js.map +0 -1
- package/dist/workflows/runner.d.ts +0 -49
- package/dist/workflows/runner.d.ts.map +0 -1
- package/dist/workflows/runner.js +0 -661
- package/dist/workflows/runner.js.map +0 -1
- package/dist/workflows/runtime-helpers.d.ts +0 -60
- package/dist/workflows/runtime-helpers.d.ts.map +0 -1
- package/dist/workflows/runtime-helpers.js +0 -267
- package/dist/workflows/runtime-helpers.js.map +0 -1
- package/dist/workflows/session-completion.d.ts +0 -7
- package/dist/workflows/session-completion.d.ts.map +0 -1
- package/dist/workflows/session-completion.js +0 -117
- package/dist/workflows/session-completion.js.map +0 -1
- package/dist/workflows/session-links.d.ts +0 -21
- package/dist/workflows/session-links.d.ts.map +0 -1
- package/dist/workflows/session-links.js +0 -77
- package/dist/workflows/session-links.js.map +0 -1
- package/dist/workflows/session-output.d.ts +0 -30
- package/dist/workflows/session-output.d.ts.map +0 -1
- package/dist/workflows/session-output.js +0 -231
- package/dist/workflows/session-output.js.map +0 -1
- package/dist/workflows/session-policy.d.ts +0 -39
- package/dist/workflows/session-policy.d.ts.map +0 -1
- package/dist/workflows/session-policy.js +0 -93
- package/dist/workflows/session-policy.js.map +0 -1
- package/dist/workflows/shell-abort-registry.d.ts +0 -11
- package/dist/workflows/shell-abort-registry.d.ts.map +0 -1
- package/dist/workflows/shell-abort-registry.js +0 -35
- package/dist/workflows/shell-abort-registry.js.map +0 -1
- package/dist/workflows/store.d.ts +0 -14
- package/dist/workflows/store.d.ts.map +0 -1
- package/dist/workflows/store.js +0 -160
- package/dist/workflows/store.js.map +0 -1
- package/dist/workflows/structured-outputs.d.ts +0 -24
- package/dist/workflows/structured-outputs.d.ts.map +0 -1
- package/dist/workflows/structured-outputs.js +0 -174
- package/dist/workflows/structured-outputs.js.map +0 -1
- package/dist/workflows/subflow-executor.d.ts +0 -15
- package/dist/workflows/subflow-executor.d.ts.map +0 -1
- package/dist/workflows/subflow-executor.js +0 -181
- package/dist/workflows/subflow-executor.js.map +0 -1
- package/dist/workflows/trigger-rule.d.ts +0 -22
- package/dist/workflows/trigger-rule.d.ts.map +0 -1
- package/dist/workflows/trigger-rule.js +0 -57
- package/dist/workflows/trigger-rule.js.map +0 -1
- package/dist/workflows/types.d.ts +0 -418
- package/dist/workflows/types.d.ts.map +0 -1
- package/dist/workflows/types.js +0 -2
- package/dist/workflows/types.js.map +0 -1
- package/dist/workflows/workflow-authority-contract.d.ts +0 -25
- package/dist/workflows/workflow-authority-contract.d.ts.map +0 -1
- package/dist/workflows/workflow-authority-contract.js +0 -389
- package/dist/workflows/workflow-authority-contract.js.map +0 -1
- package/dist/workflows/workflow-executor-schema.d.ts +0 -51
- package/dist/workflows/workflow-executor-schema.d.ts.map +0 -1
- package/dist/workflows/workflow-executor-schema.js +0 -81
- package/dist/workflows/workflow-executor-schema.js.map +0 -1
- package/dist/workflows/workflow-production-schema.d.ts +0 -178
- package/dist/workflows/workflow-production-schema.d.ts.map +0 -1
- package/dist/workflows/workflow-production-schema.js +0 -202
- package/dist/workflows/workflow-production-schema.js.map +0 -1
- package/dist/workflows/workflow-production-types.d.ts +0 -123
- package/dist/workflows/workflow-production-types.d.ts.map +0 -1
- package/dist/workflows/workflow-production-types.js +0 -2
- package/dist/workflows/workflow-production-types.js.map +0 -1
- package/dist/workflows/workflow-schema-common.d.ts +0 -332
- package/dist/workflows/workflow-schema-common.d.ts.map +0 -1
- package/dist/workflows/workflow-schema-common.js +0 -135
- package/dist/workflows/workflow-schema-common.js.map +0 -1
- package/dist/workflows/workflow-schema.d.ts +0 -3037
- package/dist/workflows/workflow-schema.d.ts.map +0 -1
- package/dist/workflows/workflow-schema.js +0 -415
- package/dist/workflows/workflow-schema.js.map +0 -1
- package/dist/workflows/workflow-source.d.ts +0 -3
- package/dist/workflows/workflow-source.d.ts.map +0 -1
- package/dist/workflows/workflow-source.js +0 -29
- package/dist/workflows/workflow-source.js.map +0 -1
- package/docs/README.md +0 -18
- package/docs/configuration.md +0 -248
- package/docs/developer-workflows.md +0 -123
- package/docs/protocol-contract.json +0 -20
- package/docs/protocol-matrix.json +0 -375
- package/docs/protocol-pin.json +0 -5
- package/docs/releasing.md +0 -36
- package/docs/security.md +0 -49
- package/docs/test-vectors/relay-noise-v2.json +0 -42
- package/docs/test-vectors/relay-noise-v3.json +0 -51
- package/docs/testing.md +0 -112
- package/node_modules/@viewportai/context-engine/README.md +0 -33
- package/node_modules/@viewportai/context-engine/fixtures/protocol-vectors/README.md +0 -37
- package/node_modules/@viewportai/context-engine/fixtures/protocol-vectors/bundle-manifest.json +0 -50
- package/node_modules/@viewportai/context-engine/fixtures/protocol-vectors/erase-receipt.json +0 -10
- package/node_modules/@viewportai/context-engine/fixtures/protocol-vectors/event.json +0 -29
- package/node_modules/@viewportai/context-engine/fixtures/protocol-vectors/hpke-key-grant.json +0 -24
- package/node_modules/@viewportai/context-engine/fixtures/protocol-vectors/key-grant.json +0 -21
- package/node_modules/@viewportai/context-engine/fixtures/protocol-vectors/profile.json +0 -12
- package/node_modules/@viewportai/context-engine/fixtures/protocol-vectors/signed-event.json +0 -28
- package/node_modules/@viewportai/context-engine/fixtures/protocol-vectors/standalone-decoder.mjs +0 -124
- package/node_modules/@viewportai/context-engine/package.json +0 -11
- package/node_modules/@viewportai/context-engine/schemas/context_bundle_manifest_v1.schema.json +0 -134
- package/node_modules/@viewportai/context-engine/schemas/context_erase_receipt_v1.schema.json +0 -27
- package/node_modules/@viewportai/context-engine/schemas/context_event_v1.schema.json +0 -216
- package/node_modules/@viewportai/context-engine/schemas/context_key_grant_hpke_draft_01.schema.json +0 -27
- package/node_modules/@viewportai/context-engine/schemas/context_key_grant_v1.schema.json +0 -24
- package/node_modules/@viewportai/context-engine/schemas/context_profile_v1.schema.json +0 -24
- package/node_modules/@viewportai/context-engine/src/cli.js +0 -177
- package/node_modules/@viewportai/context-engine/src/crypto/canonical.js +0 -21
- package/node_modules/@viewportai/context-engine/src/crypto/envelope.js +0 -37
- package/node_modules/@viewportai/context-engine/src/crypto/hpke-grants.js +0 -298
- package/node_modules/@viewportai/context-engine/src/crypto/keys.js +0 -122
- package/node_modules/@viewportai/context-engine/src/crypto/signatures.js +0 -23
- package/node_modules/@viewportai/context-engine/src/index.js +0 -12
- package/node_modules/@viewportai/context-engine/src/protocol/schemas.js +0 -50
- package/node_modules/@viewportai/context-engine/src/repo/access-model.js +0 -170
- package/node_modules/@viewportai/context-engine/src/repo/bundles.js +0 -180
- package/node_modules/@viewportai/context-engine/src/repo/candidates.js +0 -207
- package/node_modules/@viewportai/context-engine/src/repo/devices.js +0 -141
- package/node_modules/@viewportai/context-engine/src/repo/events.js +0 -101
- package/node_modules/@viewportai/context-engine/src/repo/files.js +0 -33
- package/node_modules/@viewportai/context-engine/src/repo/identities.js +0 -132
- package/node_modules/@viewportai/context-engine/src/repo/key-store.js +0 -126
- package/node_modules/@viewportai/context-engine/src/repo/materializer.js +0 -314
- package/node_modules/@viewportai/context-engine/src/repo/membership.js +0 -192
- package/node_modules/@viewportai/context-engine/src/repo/paths.js +0 -25
- package/node_modules/@viewportai/context-engine/src/repo/profiles.js +0 -54
- package/node_modules/@viewportai/context-engine/src/repo/receipts.js +0 -68
- package/node_modules/@viewportai/context-engine/src/repo/sync.js +0 -163
- package/node_modules/@viewportai/context-engine/src/repo/users.js +0 -134
- package/node_modules/@viewportai/context-engine/src/repo/vault.js +0 -548
- package/node_modules/@viewportai/context-engine/src/store/local-semantic.js +0 -69
- package/node_modules/@viewportai/context-engine/src/store/search.js +0 -25
- package/node_modules/@viewportai/context-engine/src/store/sqlite.js +0 -76
- package/schemas/viewport-config-v1.schema.json +0 -213
- package/schemas/workflow-v1.schema.json +0 -510
|
@@ -1,1825 +0,0 @@
|
|
|
1
|
-
import crypto from 'node:crypto';
|
|
2
|
-
import { spawn } from 'node:child_process';
|
|
3
|
-
import { constants as fsConstants } from 'node:fs';
|
|
4
|
-
import fs from 'node:fs/promises';
|
|
5
|
-
import os from 'node:os';
|
|
6
|
-
import path from 'node:path';
|
|
7
|
-
import { WebSocket } from 'ws';
|
|
8
|
-
import YAML from 'yaml';
|
|
9
|
-
import { ConfigManager } from '../core/config.js';
|
|
10
|
-
import { Daemon } from '../core/daemon.js';
|
|
11
|
-
import { loadAgents } from '../startup-agents.js';
|
|
12
|
-
import { envNameForCredentialRef } from '../workflows/action-provider-utils.js';
|
|
13
|
-
import { GitTracker } from '../tracking/git-tracker.js';
|
|
14
|
-
import { workflowRunToSyncPayload } from '../workflows/platform-sync-payload.js';
|
|
15
|
-
import { WorkflowRunStore } from '../workflows/store.js';
|
|
16
|
-
import { transportFetch } from './network.js';
|
|
17
|
-
import { acquireWorkerProcessLock } from './worker-process-lock.js';
|
|
18
|
-
import { readWorkerPairingRecord, workerProfileIntegrity, } from './worker-profile.js';
|
|
19
|
-
function runtimeContextTargetIdValue(primary, fallback) {
|
|
20
|
-
return stringValue(primary?.['runtime_context_target_id'] ??
|
|
21
|
-
primary?.['runtimeContextTargetId'] ??
|
|
22
|
-
primary?.['runtime_target_id'] ??
|
|
23
|
-
primary?.['runtimeTargetId'] ??
|
|
24
|
-
fallback?.['runtime_context_target_id'] ??
|
|
25
|
-
fallback?.['runtimeContextTargetId'] ??
|
|
26
|
-
fallback?.['runtime_target_id'] ??
|
|
27
|
-
fallback?.['runtimeTargetId']);
|
|
28
|
-
}
|
|
29
|
-
function hostedRuntimeContextTargetId(profile, lease) {
|
|
30
|
-
return (lease.runtimeTargetId ??
|
|
31
|
-
(profile.managedExecutorId ? `managed_executor:${profile.managedExecutorId}` : undefined));
|
|
32
|
-
}
|
|
33
|
-
function hostedWorkflowInputs(profile, lease) {
|
|
34
|
-
const base = { ...(lease.inputSnapshot ?? {}) };
|
|
35
|
-
const runtimeTargetId = hostedRuntimeContextTargetId(profile, lease);
|
|
36
|
-
if (!profile.serverUrl ||
|
|
37
|
-
!profile.workspaceId ||
|
|
38
|
-
!lease.assignmentClaimToken ||
|
|
39
|
-
!runtimeTargetId) {
|
|
40
|
-
return Object.keys(base).length > 0 ? base : undefined;
|
|
41
|
-
}
|
|
42
|
-
const viewport = isWorkflowInputRecord(base['viewport']) ? { ...base['viewport'] } : {};
|
|
43
|
-
viewport['runtimeContextTarget'] = {
|
|
44
|
-
schema: 'viewport.runtime_context_target/v1',
|
|
45
|
-
serverUrl: profile.serverUrl,
|
|
46
|
-
workspaceId: profile.workspaceId,
|
|
47
|
-
runtimeTargetId,
|
|
48
|
-
credential: lease.assignmentClaimToken,
|
|
49
|
-
};
|
|
50
|
-
base['viewport'] = viewport;
|
|
51
|
-
return base;
|
|
52
|
-
}
|
|
53
|
-
function isWorkflowInputRecord(value) {
|
|
54
|
-
return Boolean(value && typeof value === 'object' && !Array.isArray(value));
|
|
55
|
-
}
|
|
56
|
-
class HttpPollingTransport {
|
|
57
|
-
profile;
|
|
58
|
-
mode;
|
|
59
|
-
constructor(profile, mode) {
|
|
60
|
-
this.profile = profile;
|
|
61
|
-
this.mode = mode;
|
|
62
|
-
}
|
|
63
|
-
claim(body) {
|
|
64
|
-
return claimLeaseHttp(this.profile, body);
|
|
65
|
-
}
|
|
66
|
-
heartbeat(options) {
|
|
67
|
-
return heartbeatHttp(this.profile, {
|
|
68
|
-
...options,
|
|
69
|
-
transport: this.mode,
|
|
70
|
-
});
|
|
71
|
-
}
|
|
72
|
-
sync(lease, execution) {
|
|
73
|
-
return syncLeaseHttp(this.profile, lease, execution);
|
|
74
|
-
}
|
|
75
|
-
cleanup(lease) {
|
|
76
|
-
return cleanupLeaseHttp(this.profile, lease);
|
|
77
|
-
}
|
|
78
|
-
pollRuntimeCommands(lease) {
|
|
79
|
-
return fetchHostedAssignmentHttp(this.profile, lease);
|
|
80
|
-
}
|
|
81
|
-
}
|
|
82
|
-
class RelayWorkerTransport {
|
|
83
|
-
profile;
|
|
84
|
-
mode = 'relay';
|
|
85
|
-
ws = null;
|
|
86
|
-
pending = new Map();
|
|
87
|
-
constructor(profile) {
|
|
88
|
-
this.profile = profile;
|
|
89
|
-
}
|
|
90
|
-
async claim(body) {
|
|
91
|
-
return claimLeaseHttp(this.profile, body, (request) => this.dispatchHostedManagedExecutorRequest(request));
|
|
92
|
-
}
|
|
93
|
-
async heartbeat(options) {
|
|
94
|
-
return heartbeatHttp(this.profile, {
|
|
95
|
-
...options,
|
|
96
|
-
transport: 'relay',
|
|
97
|
-
}, (request) => this.dispatchHostedManagedExecutorRequest(request));
|
|
98
|
-
}
|
|
99
|
-
async sync(lease, execution) {
|
|
100
|
-
return syncLeaseHttp(this.profile, lease, execution, (request) => this.dispatchHostedManagedExecutorRequest(request));
|
|
101
|
-
}
|
|
102
|
-
async cleanup(lease) {
|
|
103
|
-
return cleanupLeaseHttp(this.profile, lease);
|
|
104
|
-
}
|
|
105
|
-
async pollRuntimeCommands(lease) {
|
|
106
|
-
return fetchHostedAssignmentHttp(this.profile, lease, (request) => this.dispatchHostedManagedExecutorRequest(request));
|
|
107
|
-
}
|
|
108
|
-
async dispatchHostedManagedExecutorRequest(request) {
|
|
109
|
-
const ws = await this.connection();
|
|
110
|
-
const requestId = crypto.randomUUID();
|
|
111
|
-
const frame = {
|
|
112
|
-
type: 'viewport.worker_transport.request/v1',
|
|
113
|
-
requestId,
|
|
114
|
-
method: request.method,
|
|
115
|
-
path: request.requestPath,
|
|
116
|
-
headers: request.headers,
|
|
117
|
-
body: request.serialized,
|
|
118
|
-
};
|
|
119
|
-
return new Promise((resolve, reject) => {
|
|
120
|
-
const timeout = setTimeout(() => {
|
|
121
|
-
this.pending.delete(requestId);
|
|
122
|
-
reject(new Error(`Relay worker transport request ${request.path} timed out.`));
|
|
123
|
-
}, relayWorkerRequestTimeoutMs());
|
|
124
|
-
this.pending.set(requestId, { resolve, reject, timeout });
|
|
125
|
-
ws.send(JSON.stringify(frame), (error) => {
|
|
126
|
-
if (error) {
|
|
127
|
-
clearTimeout(timeout);
|
|
128
|
-
this.pending.delete(requestId);
|
|
129
|
-
reject(error);
|
|
130
|
-
}
|
|
131
|
-
});
|
|
132
|
-
});
|
|
133
|
-
}
|
|
134
|
-
async connection() {
|
|
135
|
-
if (this.ws && this.ws.readyState === WebSocket.OPEN) {
|
|
136
|
-
return this.ws;
|
|
137
|
-
}
|
|
138
|
-
if (!isHostedManagedExecutorProfile(this.profile)) {
|
|
139
|
-
throw new Error('Relay worker transport requires a hosted managed executor profile.');
|
|
140
|
-
}
|
|
141
|
-
const tokenResponse = await hostedManagedExecutorFetch(this.profile, 'POST', 'relay-token', {
|
|
142
|
-
credential: this.profile.credential,
|
|
143
|
-
ttl_seconds: 3600,
|
|
144
|
-
});
|
|
145
|
-
const tokenPayload = (await tokenResponse.json());
|
|
146
|
-
const token = stringValue(tokenPayload['relayToken']);
|
|
147
|
-
const claims = recordValue(tokenPayload['claims']);
|
|
148
|
-
const claimRelayWsBaseUrl = stringValue(claims?.['relayWsBaseUrl']);
|
|
149
|
-
if (!token) {
|
|
150
|
-
throw new Error('Relay worker transport token response did not include a relay token.');
|
|
151
|
-
}
|
|
152
|
-
const relayWsBaseUrl = this.profile.relayWsBaseUrl ??
|
|
153
|
-
process.env['VIEWPORT_RELAY_WS_BASE_URL'] ??
|
|
154
|
-
process.env['VPD_RELAY_WS_BASE_URL'] ??
|
|
155
|
-
claimRelayWsBaseUrl ??
|
|
156
|
-
relayWsBaseUrlFromServerUrl(this.profile.serverUrl);
|
|
157
|
-
const url = new URL(relayWsBaseUrl);
|
|
158
|
-
url.searchParams.set('role', 'worker');
|
|
159
|
-
url.searchParams.set('workspaceId', this.profile.workspaceId);
|
|
160
|
-
const ws = new WebSocket(url, {
|
|
161
|
-
headers: {
|
|
162
|
-
Authorization: `Bearer ${token}`,
|
|
163
|
-
},
|
|
164
|
-
});
|
|
165
|
-
await new Promise((resolve, reject) => {
|
|
166
|
-
const timeout = setTimeout(() => reject(new Error('Relay worker transport connection timed out.')), relayWorkerConnectionTimeoutMs());
|
|
167
|
-
ws.once('open', () => {
|
|
168
|
-
clearTimeout(timeout);
|
|
169
|
-
resolve();
|
|
170
|
-
});
|
|
171
|
-
ws.once('error', (error) => {
|
|
172
|
-
clearTimeout(timeout);
|
|
173
|
-
reject(error);
|
|
174
|
-
});
|
|
175
|
-
});
|
|
176
|
-
ws.on('message', (raw) => {
|
|
177
|
-
this.handleMessage(raw.toString('utf8'));
|
|
178
|
-
});
|
|
179
|
-
ws.on('close', () => {
|
|
180
|
-
for (const [requestId, pending] of this.pending.entries()) {
|
|
181
|
-
clearTimeout(pending.timeout);
|
|
182
|
-
pending.reject(new Error('Relay worker transport connection closed.'));
|
|
183
|
-
this.pending.delete(requestId);
|
|
184
|
-
}
|
|
185
|
-
this.ws = null;
|
|
186
|
-
});
|
|
187
|
-
this.ws = ws;
|
|
188
|
-
return ws;
|
|
189
|
-
}
|
|
190
|
-
handleMessage(text) {
|
|
191
|
-
let frame;
|
|
192
|
-
try {
|
|
193
|
-
const parsed = JSON.parse(text);
|
|
194
|
-
if (!parsed || typeof parsed !== 'object' || Array.isArray(parsed))
|
|
195
|
-
return;
|
|
196
|
-
frame = parsed;
|
|
197
|
-
}
|
|
198
|
-
catch {
|
|
199
|
-
return;
|
|
200
|
-
}
|
|
201
|
-
if (frame['type'] !== 'viewport.worker_transport.response/v1')
|
|
202
|
-
return;
|
|
203
|
-
const requestId = stringValue(frame['requestId']);
|
|
204
|
-
if (!requestId)
|
|
205
|
-
return;
|
|
206
|
-
const pending = this.pending.get(requestId);
|
|
207
|
-
if (!pending)
|
|
208
|
-
return;
|
|
209
|
-
this.pending.delete(requestId);
|
|
210
|
-
clearTimeout(pending.timeout);
|
|
211
|
-
const status = typeof frame['status'] === 'number' ? frame['status'] : 502;
|
|
212
|
-
const headers = recordValue(frame['headers']);
|
|
213
|
-
const body = typeof frame['body'] === 'string' ? frame['body'] : '';
|
|
214
|
-
const responseBody = status === 204 || status === 205 || status === 304 ? null : body;
|
|
215
|
-
pending.resolve(new Response(responseBody, { status, headers }));
|
|
216
|
-
}
|
|
217
|
-
}
|
|
218
|
-
const DEFAULT_HOSTED_LEASE_SECONDS = 1_800;
|
|
219
|
-
export async function runStandaloneWorker(options) {
|
|
220
|
-
const bootstrap = await loadWorkerRuntimeBootstrap(options.bootstrapPath, options.registrationProfilePath);
|
|
221
|
-
const profile = bootstrap.profile;
|
|
222
|
-
let processLock = null;
|
|
223
|
-
try {
|
|
224
|
-
await validateWorkerWorkspaceRoot(profile.workspaceRoot);
|
|
225
|
-
const transport = options.transport ?? profile.transport;
|
|
226
|
-
if (transport === 'inbound') {
|
|
227
|
-
validateInboundWorkerGate(profile);
|
|
228
|
-
}
|
|
229
|
-
const workerTransport = transport === 'relay'
|
|
230
|
-
? new RelayWorkerTransport(profile)
|
|
231
|
-
: new HttpPollingTransport(profile, transport);
|
|
232
|
-
processLock =
|
|
233
|
-
options.lifecycle === 'persistent' && !options.once
|
|
234
|
-
? acquireWorkerProcessLock({
|
|
235
|
-
server: profile.serverUrl,
|
|
236
|
-
workspaceId: profile.workspaceId ?? profile.publicKeyFingerprint,
|
|
237
|
-
executorId: profile.managedExecutorId ?? profile.publicKeyFingerprint,
|
|
238
|
-
runnerProfile: runnerPoolFromCapabilities(profile.capabilities),
|
|
239
|
-
accessMode: transport,
|
|
240
|
-
})
|
|
241
|
-
: null;
|
|
242
|
-
let lastHeartbeatAt = Date.now();
|
|
243
|
-
await workerTransport.heartbeat({
|
|
244
|
-
status: 'online',
|
|
245
|
-
healthStatus: 'idle',
|
|
246
|
-
lifecycle: options.lifecycle,
|
|
247
|
-
});
|
|
248
|
-
if (bootstrap.lease) {
|
|
249
|
-
const result = await executeBootstrapLease(profile, workerTransport, bootstrap.lease);
|
|
250
|
-
await workerTransport.heartbeat({
|
|
251
|
-
status: 'offline',
|
|
252
|
-
healthStatus: 'offline',
|
|
253
|
-
lifecycle: options.lifecycle,
|
|
254
|
-
});
|
|
255
|
-
return result;
|
|
256
|
-
}
|
|
257
|
-
if (options.leaseToken) {
|
|
258
|
-
throw new Error('`vpd worker run-once --lease` no longer fabricates a completed sync (EXEC-01). ' +
|
|
259
|
-
'Use `vpd worker run-once --bootstrap <file>` to execute the leased work.');
|
|
260
|
-
}
|
|
261
|
-
const result = {
|
|
262
|
-
claimed: 0,
|
|
263
|
-
completed: 0,
|
|
264
|
-
blocked: 0,
|
|
265
|
-
failed: 0,
|
|
266
|
-
cleanup: 0,
|
|
267
|
-
denied: 0,
|
|
268
|
-
};
|
|
269
|
-
try {
|
|
270
|
-
while (!options.abortSignal?.aborted) {
|
|
271
|
-
const lease = await workerTransport.claim({
|
|
272
|
-
lifecycle: options.lifecycle,
|
|
273
|
-
transport,
|
|
274
|
-
leaseSeconds: options.leaseSeconds,
|
|
275
|
-
});
|
|
276
|
-
if (!lease) {
|
|
277
|
-
if (options.once || options.lifecycle !== 'persistent')
|
|
278
|
-
break;
|
|
279
|
-
const now = Date.now();
|
|
280
|
-
if (now - lastHeartbeatAt > 30_000) {
|
|
281
|
-
await workerTransport.heartbeat({
|
|
282
|
-
status: 'online',
|
|
283
|
-
healthStatus: 'idle',
|
|
284
|
-
lifecycle: options.lifecycle,
|
|
285
|
-
});
|
|
286
|
-
lastHeartbeatAt = now;
|
|
287
|
-
}
|
|
288
|
-
await sleepWithAbort(options.pollIntervalMs ?? 5_000, options.abortSignal);
|
|
289
|
-
continue;
|
|
290
|
-
}
|
|
291
|
-
result.claimed += 1;
|
|
292
|
-
let execution = await executeClaim(profile, workerTransport, lease);
|
|
293
|
-
if (isHostedManagedExecutorProfile(profile) &&
|
|
294
|
-
execution.status === 'blocked' &&
|
|
295
|
-
execution.run) {
|
|
296
|
-
await workerTransport.sync(lease, execution);
|
|
297
|
-
execution = await resumeBlockedHostedExecution(profile, workerTransport, lease, execution);
|
|
298
|
-
if (execution.status !== 'blocked') {
|
|
299
|
-
await workerTransport.sync(lease, execution);
|
|
300
|
-
}
|
|
301
|
-
}
|
|
302
|
-
else {
|
|
303
|
-
await workerTransport.sync(lease, execution);
|
|
304
|
-
}
|
|
305
|
-
await maybeExecuteHostedSessionVerification(profile, workerTransport, lease, execution);
|
|
306
|
-
if (execution.status === 'completed') {
|
|
307
|
-
result.completed += 1;
|
|
308
|
-
}
|
|
309
|
-
else if (execution.status === 'blocked') {
|
|
310
|
-
result.blocked += 1;
|
|
311
|
-
}
|
|
312
|
-
else {
|
|
313
|
-
result.failed += 1;
|
|
314
|
-
}
|
|
315
|
-
await workerTransport.cleanup(lease);
|
|
316
|
-
result.cleanup += 1;
|
|
317
|
-
if (options.once)
|
|
318
|
-
break;
|
|
319
|
-
}
|
|
320
|
-
}
|
|
321
|
-
finally {
|
|
322
|
-
await workerTransport.heartbeat({
|
|
323
|
-
status: 'offline',
|
|
324
|
-
healthStatus: 'offline',
|
|
325
|
-
lifecycle: options.lifecycle,
|
|
326
|
-
});
|
|
327
|
-
}
|
|
328
|
-
return result;
|
|
329
|
-
}
|
|
330
|
-
finally {
|
|
331
|
-
processLock?.release();
|
|
332
|
-
await bootstrap.cleanup?.();
|
|
333
|
-
}
|
|
334
|
-
}
|
|
335
|
-
async function executeBootstrapLease(profile, transport, lease) {
|
|
336
|
-
const execution = await executeClaim(profile, transport, lease);
|
|
337
|
-
await transport.sync(lease, execution);
|
|
338
|
-
await maybeExecuteHostedSessionVerification(profile, transport, lease, execution);
|
|
339
|
-
await transport.cleanup(lease);
|
|
340
|
-
return {
|
|
341
|
-
claimed: 1,
|
|
342
|
-
completed: execution.status === 'completed' ? 1 : 0,
|
|
343
|
-
blocked: execution.status === 'blocked' ? 1 : 0,
|
|
344
|
-
failed: execution.status === 'failed' || execution.status === 'canceled' ? 1 : 0,
|
|
345
|
-
cleanup: 1,
|
|
346
|
-
denied: 0,
|
|
347
|
-
};
|
|
348
|
-
}
|
|
349
|
-
function runnerPoolFromCapabilities(capabilities) {
|
|
350
|
-
const value = capabilities['runner_pool'] ?? capabilities['runnerPool'];
|
|
351
|
-
return typeof value === 'string' && value.trim() !== '' ? value : undefined;
|
|
352
|
-
}
|
|
353
|
-
async function validateWorkerWorkspaceRoot(workspaceRoot) {
|
|
354
|
-
const resolved = path.resolve(workspaceRoot);
|
|
355
|
-
let stat;
|
|
356
|
-
try {
|
|
357
|
-
stat = await fs.stat(resolved);
|
|
358
|
-
}
|
|
359
|
-
catch {
|
|
360
|
-
throw new Error(`Worker workspace root is not available: ${resolved}. Run vpd pair --worker or configure a valid worker workspace root before starting the worker.`);
|
|
361
|
-
}
|
|
362
|
-
if (!stat.isDirectory()) {
|
|
363
|
-
throw new Error(`Worker workspace root is not a directory: ${resolved}.`);
|
|
364
|
-
}
|
|
365
|
-
try {
|
|
366
|
-
await fs.access(resolved, fsConstants.R_OK | fsConstants.W_OK | fsConstants.X_OK);
|
|
367
|
-
}
|
|
368
|
-
catch {
|
|
369
|
-
throw new Error(`Worker workspace root is not readable and writable: ${resolved}.`);
|
|
370
|
-
}
|
|
371
|
-
}
|
|
372
|
-
async function executeClaim(profile, transport, lease) {
|
|
373
|
-
if (!isHostedManagedExecutorProfile(profile)) {
|
|
374
|
-
return { status: 'completed' };
|
|
375
|
-
}
|
|
376
|
-
return withGatewayLeaseProcessEnv(lease, () => executeHostedWorkflowClaim(profile, transport, lease));
|
|
377
|
-
}
|
|
378
|
-
async function loadWorkerRuntimeBootstrap(bootstrapPath, registrationProfilePath) {
|
|
379
|
-
if (bootstrapPath) {
|
|
380
|
-
return loadSandboxBootstrap(bootstrapPath);
|
|
381
|
-
}
|
|
382
|
-
if (registrationProfilePath) {
|
|
383
|
-
return {
|
|
384
|
-
profile: await loadManagedExecutorRuntimeProfile(registrationProfilePath),
|
|
385
|
-
};
|
|
386
|
-
}
|
|
387
|
-
return { profile: await loadWorkerRuntimeProfile() };
|
|
388
|
-
}
|
|
389
|
-
async function loadManagedExecutorRuntimeProfile(profilePath) {
|
|
390
|
-
const profile = await readManagedExecutorRegistrationProfile(profilePath);
|
|
391
|
-
const credential = await credentialFromManagedExecutorProfile(profile);
|
|
392
|
-
const missing = [];
|
|
393
|
-
if (!profile.serverUrl)
|
|
394
|
-
missing.push('server URL');
|
|
395
|
-
if (!profile.workspaceId)
|
|
396
|
-
missing.push('workspace id');
|
|
397
|
-
if (!profile.executorId)
|
|
398
|
-
missing.push('managed executor id');
|
|
399
|
-
if (!credential)
|
|
400
|
-
missing.push('managed executor credential');
|
|
401
|
-
if (missing.length > 0) {
|
|
402
|
-
throw new Error(`Managed executor registration profile is missing ${missing.join(', ')}.`);
|
|
403
|
-
}
|
|
404
|
-
const identity = await ensureManagedExecutorIdentity(profile.identityKeyPath ??
|
|
405
|
-
managedExecutorIdentityPath(profile.workspaceId, profile.executorId));
|
|
406
|
-
const workspaceRoot = managedExecutorWorkspaceRoot(profile);
|
|
407
|
-
await fs.mkdir(workspaceRoot, { recursive: true, mode: 0o700 });
|
|
408
|
-
const runnerPool = stringValue(profile.capabilities?.['runner_pool']) ??
|
|
409
|
-
stringValue(profile.capabilities?.['runnerPool']) ??
|
|
410
|
-
profile.runnerProfile;
|
|
411
|
-
const capabilities = {
|
|
412
|
-
...(profile.capabilities ?? {}),
|
|
413
|
-
...(runnerPool ? { runner_pool: runnerPool } : {}),
|
|
414
|
-
...(profile.runnerPosture ? { runner_posture: profile.runnerPosture } : {}),
|
|
415
|
-
};
|
|
416
|
-
return {
|
|
417
|
-
serverUrl: profile.serverUrl.replace(/\/+$/, ''),
|
|
418
|
-
serverId: profile.serverId,
|
|
419
|
-
lifecycle: 'persistent',
|
|
420
|
-
transport: workerTransportValue(profile.accessMode) ?? 'polling',
|
|
421
|
-
workspaceId: profile.workspaceId,
|
|
422
|
-
managedExecutorId: profile.executorId,
|
|
423
|
-
credential: credential,
|
|
424
|
-
workspaceRoot,
|
|
425
|
-
identityKeyPath: identity.path,
|
|
426
|
-
publicKeyFingerprint: identity.publicKeyFingerprint,
|
|
427
|
-
capabilities,
|
|
428
|
-
};
|
|
429
|
-
}
|
|
430
|
-
async function readManagedExecutorRegistrationProfile(profilePath) {
|
|
431
|
-
const resolved = resolveProfilePath(profilePath);
|
|
432
|
-
const parsed = JSON.parse(await fs.readFile(resolved, 'utf8'));
|
|
433
|
-
if (!parsed || typeof parsed !== 'object' || Array.isArray(parsed)) {
|
|
434
|
-
throw new Error(`Managed executor registration profile is not a JSON object: ${resolved}`);
|
|
435
|
-
}
|
|
436
|
-
const record = parsed;
|
|
437
|
-
const schema = stringValue(record['schema']);
|
|
438
|
-
if (schema && schema !== 'viewport.managed_executor_registration/v1') {
|
|
439
|
-
throw new Error(`Unsupported managed executor registration profile schema: ${schema}`);
|
|
440
|
-
}
|
|
441
|
-
const daemon = recordValue(record['daemon']);
|
|
442
|
-
const worker = recordValue(daemon?.['worker']);
|
|
443
|
-
return {
|
|
444
|
-
serverUrl: stringValue(record['server_url']) ??
|
|
445
|
-
stringValue(record['serverUrl']) ??
|
|
446
|
-
stringValue(worker?.['serverUrl']) ??
|
|
447
|
-
stringValue(worker?.['server_url']),
|
|
448
|
-
serverId: stringValue(record['server_id']) ??
|
|
449
|
-
stringValue(record['serverId']) ??
|
|
450
|
-
stringValue(record['control_plane_id']) ??
|
|
451
|
-
stringValue(worker?.['serverId']) ??
|
|
452
|
-
stringValue(worker?.['server_id']) ??
|
|
453
|
-
stringValue(worker?.['control_plane_id']),
|
|
454
|
-
workspaceId: stringValue(record['workspace_id']) ??
|
|
455
|
-
stringValue(record['workspaceId']) ??
|
|
456
|
-
stringValue(worker?.['workspaceId']) ??
|
|
457
|
-
stringValue(worker?.['workspace_id']),
|
|
458
|
-
executorId: stringValue(record['managed_executor_id']) ??
|
|
459
|
-
stringValue(record['executor_id']) ??
|
|
460
|
-
stringValue(record['executorId']) ??
|
|
461
|
-
stringValue(worker?.['managedExecutorId']) ??
|
|
462
|
-
stringValue(worker?.['managed_executor_id']),
|
|
463
|
-
credential: stringValue(record['credential']) ?? stringValue(worker?.['credential']),
|
|
464
|
-
credentialFile: stringValue(record['credential_file']) ??
|
|
465
|
-
stringValue(record['credentialFile']) ??
|
|
466
|
-
stringValue(worker?.['credentialFile']) ??
|
|
467
|
-
stringValue(worker?.['credential_file']),
|
|
468
|
-
accessMode: stringValue(record['access_mode']) ??
|
|
469
|
-
stringValue(record['accessMode']) ??
|
|
470
|
-
stringValue(worker?.['accessMode']) ??
|
|
471
|
-
stringValue(worker?.['access_mode']) ??
|
|
472
|
-
stringValue(worker?.['transport']),
|
|
473
|
-
runnerProfile: stringValue(record['runner_profile']) ??
|
|
474
|
-
stringValue(record['runnerProfile']) ??
|
|
475
|
-
stringValue(worker?.['runnerProfile']) ??
|
|
476
|
-
stringValue(worker?.['runner_profile']),
|
|
477
|
-
runnerPosture: recordValue(record['runner_posture']) ??
|
|
478
|
-
recordValue(record['runnerPosture']) ??
|
|
479
|
-
recordValue(worker?.['runnerPosture']) ??
|
|
480
|
-
recordValue(worker?.['runner_posture']) ??
|
|
481
|
-
undefined,
|
|
482
|
-
workspaceRoot: stringValue(record['workspace_root']) ??
|
|
483
|
-
stringValue(record['workspaceRoot']) ??
|
|
484
|
-
stringValue(record['workdir']) ??
|
|
485
|
-
stringValue(worker?.['workspaceRoot']) ??
|
|
486
|
-
stringValue(worker?.['workspace_root']) ??
|
|
487
|
-
stringValue(worker?.['workdir']),
|
|
488
|
-
identityKeyPath: stringValue(record['identity_key_path']) ??
|
|
489
|
-
stringValue(record['identityKeyPath']) ??
|
|
490
|
-
stringValue(worker?.['identityKeyPath']) ??
|
|
491
|
-
stringValue(worker?.['identity_key_path']),
|
|
492
|
-
capabilities: recordValue(record['capabilities']) ?? recordValue(worker?.['capabilities']) ?? undefined,
|
|
493
|
-
};
|
|
494
|
-
}
|
|
495
|
-
async function credentialFromManagedExecutorProfile(profile) {
|
|
496
|
-
if (profile.credentialFile) {
|
|
497
|
-
const value = (await fs.readFile(resolveProfilePath(profile.credentialFile), 'utf8')).trim();
|
|
498
|
-
if (!value) {
|
|
499
|
-
throw new Error(`Managed executor credential file is empty: ${resolveProfilePath(profile.credentialFile)}`);
|
|
500
|
-
}
|
|
501
|
-
return value;
|
|
502
|
-
}
|
|
503
|
-
return (profile.credential ??
|
|
504
|
-
process.env['VIEWPORT_MANAGED_EXECUTOR_TOKEN'] ??
|
|
505
|
-
process.env['VPD_MANAGED_EXECUTOR_TOKEN']);
|
|
506
|
-
}
|
|
507
|
-
function managedExecutorWorkspaceRoot(profile) {
|
|
508
|
-
if (profile.workspaceRoot)
|
|
509
|
-
return path.resolve(resolveProfilePath(profile.workspaceRoot));
|
|
510
|
-
const safeName = `${safeFilename(profile.workspaceId ?? 'workspace')}-${safeFilename(profile.executorId ?? 'executor')}`;
|
|
511
|
-
return path.join(os.homedir(), '.viewport', 'managed-executors', 'workspaces', safeName);
|
|
512
|
-
}
|
|
513
|
-
function managedExecutorIdentityPath(workspaceId, executorId) {
|
|
514
|
-
const safeName = `${safeFilename(workspaceId)}-${safeFilename(executorId)}.json`;
|
|
515
|
-
return path.join(os.homedir(), '.viewport', 'managed-executors', 'identities', safeName);
|
|
516
|
-
}
|
|
517
|
-
async function ensureManagedExecutorIdentity(identityPath) {
|
|
518
|
-
const resolved = resolveProfilePath(identityPath);
|
|
519
|
-
try {
|
|
520
|
-
const parsed = JSON.parse(await fs.readFile(resolved, 'utf8'));
|
|
521
|
-
if (parsed.algorithm?.toLowerCase() === 'ed25519' &&
|
|
522
|
-
typeof parsed.publicKey === 'string' &&
|
|
523
|
-
typeof parsed.privateKey === 'string') {
|
|
524
|
-
return {
|
|
525
|
-
publicKey: parsed.publicKey,
|
|
526
|
-
privateKey: parsed.privateKey,
|
|
527
|
-
publicKeyFingerprint: normalizeWorkerFingerprint(parsed.publicKeyFingerprint) ??
|
|
528
|
-
publicKeyFingerprint(parsed.publicKey),
|
|
529
|
-
path: resolved,
|
|
530
|
-
};
|
|
531
|
-
}
|
|
532
|
-
}
|
|
533
|
-
catch {
|
|
534
|
-
// Generate below.
|
|
535
|
-
}
|
|
536
|
-
const pair = crypto.generateKeyPairSync('ed25519');
|
|
537
|
-
const publicKey = pair.publicKey.export({ format: 'pem', type: 'spki' }).toString();
|
|
538
|
-
const privateKey = pair.privateKey.export({ format: 'pem', type: 'pkcs8' }).toString();
|
|
539
|
-
const record = {
|
|
540
|
-
version: 1,
|
|
541
|
-
algorithm: 'ed25519',
|
|
542
|
-
publicKey,
|
|
543
|
-
privateKey,
|
|
544
|
-
publicKeyFingerprint: publicKeyFingerprint(publicKey),
|
|
545
|
-
createdAt: new Date().toISOString(),
|
|
546
|
-
};
|
|
547
|
-
await fs.mkdir(path.dirname(resolved), { recursive: true, mode: 0o700 });
|
|
548
|
-
await fs.writeFile(resolved, `${JSON.stringify(record, null, 2)}\n`, {
|
|
549
|
-
encoding: 'utf8',
|
|
550
|
-
mode: 0o600,
|
|
551
|
-
});
|
|
552
|
-
await fs.chmod(resolved, 0o600);
|
|
553
|
-
return { ...record, path: resolved };
|
|
554
|
-
}
|
|
555
|
-
function publicKeyFingerprint(publicKeyPem) {
|
|
556
|
-
const key = crypto.createPublicKey(publicKeyPem);
|
|
557
|
-
const der = key.export({ format: 'der', type: 'spki' });
|
|
558
|
-
return crypto.createHash('sha256').update(der).digest('hex');
|
|
559
|
-
}
|
|
560
|
-
function normalizeWorkerFingerprint(value) {
|
|
561
|
-
if (typeof value !== 'string')
|
|
562
|
-
return undefined;
|
|
563
|
-
const normalized = value
|
|
564
|
-
.trim()
|
|
565
|
-
.toLowerCase()
|
|
566
|
-
.replace(/^sha256:/, '');
|
|
567
|
-
return /^[a-f0-9]{64}$/.test(normalized) ? normalized : undefined;
|
|
568
|
-
}
|
|
569
|
-
function resolveProfilePath(profilePath) {
|
|
570
|
-
if (profilePath === '~')
|
|
571
|
-
return os.homedir();
|
|
572
|
-
if (profilePath.startsWith('~/'))
|
|
573
|
-
return path.join(os.homedir(), profilePath.slice(2));
|
|
574
|
-
return path.resolve(profilePath);
|
|
575
|
-
}
|
|
576
|
-
function safeFilename(value) {
|
|
577
|
-
return value.replace(/[^a-z0-9._-]+/gi, '_').replace(/^_+|_+$/g, '') || 'default';
|
|
578
|
-
}
|
|
579
|
-
async function loadWorkerRuntimeProfile() {
|
|
580
|
-
const manager = new ConfigManager();
|
|
581
|
-
await manager.load();
|
|
582
|
-
const worker = manager.getDaemonConfig()?.worker;
|
|
583
|
-
const missing = [];
|
|
584
|
-
if (!worker?.serverUrl)
|
|
585
|
-
missing.push('server URL');
|
|
586
|
-
if (!worker?.workspaceRoot)
|
|
587
|
-
missing.push('workspace root');
|
|
588
|
-
if (!worker?.publicKeyFingerprint)
|
|
589
|
-
missing.push('worker identity');
|
|
590
|
-
if (missing.length > 0) {
|
|
591
|
-
throw new Error(`Worker profile is not configured: missing ${missing.join(', ')}.`);
|
|
592
|
-
}
|
|
593
|
-
const pairing = await readWorkerPairingRecord(worker.stateDir);
|
|
594
|
-
const integrity = workerProfileIntegrity(worker, pairing);
|
|
595
|
-
if (!integrity.ok) {
|
|
596
|
-
throw new Error(`Worker profile does not match the approved pairing record: ${integrity.mismatches.join(', ')}. Run \`vpd worker reset\`, then pair this worker again.`);
|
|
597
|
-
}
|
|
598
|
-
return {
|
|
599
|
-
serverUrl: worker.serverUrl,
|
|
600
|
-
serverId: worker.serverId,
|
|
601
|
-
lifecycle: worker.lifecycle ?? 'persistent',
|
|
602
|
-
transport: worker.transport ?? 'polling',
|
|
603
|
-
inbound: recordValue(worker.inbound),
|
|
604
|
-
workspaceId: worker.workspaceId ?? process.env['VIEWPORT_WORKSPACE_ID'],
|
|
605
|
-
managedExecutorId: worker.managedExecutorId ?? process.env['VIEWPORT_MANAGED_EXECUTOR_ID'],
|
|
606
|
-
credential: worker.credential ??
|
|
607
|
-
process.env['VIEWPORT_MANAGED_EXECUTOR_TOKEN'] ??
|
|
608
|
-
process.env['VPD_MANAGED_EXECUTOR_TOKEN'],
|
|
609
|
-
relayWsBaseUrl: process.env['VIEWPORT_RELAY_WS_BASE_URL'] ?? process.env['VPD_RELAY_WS_BASE_URL'],
|
|
610
|
-
workspaceRoot: worker.workspaceRoot,
|
|
611
|
-
identityKeyPath: worker.identityKeyPath,
|
|
612
|
-
publicKeyFingerprint: worker.publicKeyFingerprint,
|
|
613
|
-
capabilities: worker.capabilities ?? {},
|
|
614
|
-
};
|
|
615
|
-
}
|
|
616
|
-
async function loadSandboxBootstrap(bootstrapPath) {
|
|
617
|
-
const raw = JSON.parse(await fs.readFile(bootstrapPath, 'utf8'));
|
|
618
|
-
if (raw['schema'] !== 'viewport.sandbox_bootstrap/v1') {
|
|
619
|
-
throw new Error('Sandbox bootstrap file must use schema viewport.sandbox_bootstrap/v1.');
|
|
620
|
-
}
|
|
621
|
-
const workspaceRoot = requiredString(raw['workspace_root'] ?? raw['workspaceRoot'], 'workspace_root');
|
|
622
|
-
const identity = recordValue(raw['identity']);
|
|
623
|
-
const identityFile = await materializeBootstrapIdentity(identity, workspaceRoot);
|
|
624
|
-
const profile = {
|
|
625
|
-
serverUrl: requiredString(raw['server_url'] ?? raw['serverUrl'], 'server_url'),
|
|
626
|
-
serverId: stringValue(raw['server_id'] ?? raw['serverId']),
|
|
627
|
-
lifecycle: 'ephemeral',
|
|
628
|
-
transport: workerTransportValue(raw['transport']) ?? 'polling',
|
|
629
|
-
workspaceId: requiredString(raw['workspace_id'] ?? raw['workspaceId'], 'workspace_id'),
|
|
630
|
-
managedExecutorId: requiredString(raw['executor_id'] ?? raw['executorId'], 'executor_id'),
|
|
631
|
-
credential: requiredString(raw['credential'], 'credential'),
|
|
632
|
-
relayWsBaseUrl: stringValue(raw['relay_ws_base_url'] ?? raw['relayWsBaseUrl'] ?? raw['relay_url'] ?? raw['relayUrl']),
|
|
633
|
-
workspaceRoot,
|
|
634
|
-
identityKeyPath: identityFile.path,
|
|
635
|
-
publicKeyFingerprint: identityFile.publicKeyFingerprint,
|
|
636
|
-
capabilities: recordValue(raw['capabilities']) ?? {},
|
|
637
|
-
};
|
|
638
|
-
return {
|
|
639
|
-
profile,
|
|
640
|
-
lease: claimedLeaseFromBootstrap(recordValue(raw['lease'])),
|
|
641
|
-
cleanup: async () => {
|
|
642
|
-
if (identityFile.ephemeral) {
|
|
643
|
-
await fs.rm(identityFile.path, { force: true });
|
|
644
|
-
}
|
|
645
|
-
},
|
|
646
|
-
};
|
|
647
|
-
}
|
|
648
|
-
function claimedLeaseFromBootstrap(rawLease) {
|
|
649
|
-
if (!rawLease)
|
|
650
|
-
return undefined;
|
|
651
|
-
const id = requiredString(rawLease['id'] ?? rawLease['lease_id'] ?? rawLease['leaseId'], 'lease.id');
|
|
652
|
-
return {
|
|
653
|
-
id,
|
|
654
|
-
agentSessionId: stringValue(rawLease['agent_session_id'] ?? rawLease['agentSessionId']),
|
|
655
|
-
runId: stringValue(rawLease['workflow_run_id'] ?? rawLease['run_id'] ?? rawLease['runId']),
|
|
656
|
-
runtimeRunId: stringValue(rawLease['runtime_run_id'] ?? rawLease['runtimeRunId']),
|
|
657
|
-
leaseToken: stringValue(rawLease['lease_token'] ?? rawLease['leaseToken']),
|
|
658
|
-
assignmentClaimToken: stringValue(rawLease['assignment_claim_token'] ?? rawLease['assignmentClaimToken']),
|
|
659
|
-
sessionVerificationContract: sessionVerificationContractValue(rawLease['session_verification_contract'] ?? rawLease['sessionVerificationContract']),
|
|
660
|
-
gateway: gatewayLeaseValue(rawLease['gateway'] ?? rawLease['gatewayLease']),
|
|
661
|
-
yamlSnapshot: stringValue(rawLease['yaml_snapshot'] ?? rawLease['yamlSnapshot']),
|
|
662
|
-
sourceRef: stringValue(rawLease['source_ref'] ?? rawLease['sourceRef']),
|
|
663
|
-
directoryPath: stringValue(rawLease['directory_path'] ?? rawLease['directoryPath']),
|
|
664
|
-
inputSnapshot: recordValue(rawLease['input_snapshot'] ?? rawLease['inputSnapshot']),
|
|
665
|
-
resourceManifest: recordValue(rawLease['resource_manifest'] ?? rawLease['resourceManifest']),
|
|
666
|
-
workflowAuthorityContract: recordValue(rawLease['workflow_authority_contract'] ?? rawLease['workflowAuthorityContract']),
|
|
667
|
-
executionProfileSnapshot: recordValue(rawLease['execution_profile_snapshot'] ?? rawLease['executionProfileSnapshot']),
|
|
668
|
-
workflowSnapshot: recordValue(rawLease['workflow_snapshot'] ?? rawLease['workflowSnapshot']),
|
|
669
|
-
runtimeTargetId: runtimeContextTargetIdValue(rawLease),
|
|
670
|
-
dataCapturePolicy: dataCapturePolicyValue(rawLease['data_capture_policy'] ?? rawLease['dataCapturePolicy']),
|
|
671
|
-
};
|
|
672
|
-
}
|
|
673
|
-
function gatewayLeaseValue(value) {
|
|
674
|
-
const record = recordValue(value);
|
|
675
|
-
if (!record)
|
|
676
|
-
return undefined;
|
|
677
|
-
const provider = stringValue(record['provider']);
|
|
678
|
-
if (provider !== 'anthropic' && provider !== 'openai' && provider !== 'gemini') {
|
|
679
|
-
return undefined;
|
|
680
|
-
}
|
|
681
|
-
const gatewayBaseUrl = stringValue(record['gateway_base_url'] ??
|
|
682
|
-
record['gatewayBaseUrl'] ??
|
|
683
|
-
record['base_url'] ??
|
|
684
|
-
record['baseUrl']);
|
|
685
|
-
const virtualKey = recordValue(record['virtual_key'] ?? record['virtualKey']);
|
|
686
|
-
const token = stringValue(virtualKey?.['token']);
|
|
687
|
-
const modelAllow = arrayOfStrings(record['model_allow'] ?? record['modelAllow']);
|
|
688
|
-
if (!gatewayBaseUrl || !token || modelAllow.length === 0) {
|
|
689
|
-
return undefined;
|
|
690
|
-
}
|
|
691
|
-
return {
|
|
692
|
-
gatewayBaseUrl: gatewayBaseUrl.replace(/\/+$/, ''),
|
|
693
|
-
provider,
|
|
694
|
-
modelAllow,
|
|
695
|
-
virtualKey: { token },
|
|
696
|
-
};
|
|
697
|
-
}
|
|
698
|
-
async function withGatewayLeaseProcessEnv(lease, callback) {
|
|
699
|
-
const env = gatewayLeaseEnv(lease.gateway);
|
|
700
|
-
const previous = new Map();
|
|
701
|
-
for (const [key, value] of Object.entries(env)) {
|
|
702
|
-
previous.set(key, process.env[key]);
|
|
703
|
-
process.env[key] = value;
|
|
704
|
-
}
|
|
705
|
-
try {
|
|
706
|
-
return await callback();
|
|
707
|
-
}
|
|
708
|
-
finally {
|
|
709
|
-
for (const [key, value] of previous.entries()) {
|
|
710
|
-
if (value === undefined) {
|
|
711
|
-
delete process.env[key];
|
|
712
|
-
}
|
|
713
|
-
else {
|
|
714
|
-
process.env[key] = value;
|
|
715
|
-
}
|
|
716
|
-
}
|
|
717
|
-
}
|
|
718
|
-
}
|
|
719
|
-
function gatewayLeaseEnv(gateway) {
|
|
720
|
-
if (!gateway)
|
|
721
|
-
return {};
|
|
722
|
-
const model = gateway.modelAllow[0] ?? '';
|
|
723
|
-
const base = gateway.gatewayBaseUrl.replace(/\/+$/, '');
|
|
724
|
-
const common = {
|
|
725
|
-
VIEWPORT_GATEWAY_BASE_URL: base,
|
|
726
|
-
VIEWPORT_LLM_PROVIDER: gateway.provider,
|
|
727
|
-
VIEWPORT_LLM_MODEL: model,
|
|
728
|
-
VIEWPORT_LLM_VIRTUAL_KEY: gateway.virtualKey.token,
|
|
729
|
-
};
|
|
730
|
-
if (gateway.provider === 'openai') {
|
|
731
|
-
return {
|
|
732
|
-
...common,
|
|
733
|
-
CODEX_API_KEY: gateway.virtualKey.token,
|
|
734
|
-
OPENAI_API_KEY: gateway.virtualKey.token,
|
|
735
|
-
OPENAI_BASE_URL: `${base}/openai/v1`,
|
|
736
|
-
};
|
|
737
|
-
}
|
|
738
|
-
if (gateway.provider === 'anthropic') {
|
|
739
|
-
return {
|
|
740
|
-
...common,
|
|
741
|
-
ANTHROPIC_API_KEY: gateway.virtualKey.token,
|
|
742
|
-
ANTHROPIC_BASE_URL: `${base}/anthropic`,
|
|
743
|
-
// Claude Code defaults to its own preferred model; the lease's model
|
|
744
|
-
// allow-list is the governed truth, so make its head the agent default.
|
|
745
|
-
...(model ? { ANTHROPIC_MODEL: model, ANTHROPIC_SMALL_FAST_MODEL: model } : {}),
|
|
746
|
-
};
|
|
747
|
-
}
|
|
748
|
-
return {
|
|
749
|
-
...common,
|
|
750
|
-
GEMINI_API_KEY: gateway.virtualKey.token,
|
|
751
|
-
GEMINI_BASE_URL: `${base}/gemini/v1beta/openai`,
|
|
752
|
-
GOOGLE_GENERATIVE_AI_API_KEY: gateway.virtualKey.token,
|
|
753
|
-
};
|
|
754
|
-
}
|
|
755
|
-
function gatewayLeaseCredentialEnv(gateway) {
|
|
756
|
-
if (!gateway)
|
|
757
|
-
return {};
|
|
758
|
-
const env = gatewayLeaseEnv(gateway);
|
|
759
|
-
const aliases = {};
|
|
760
|
-
for (const [name, value] of Object.entries(env)) {
|
|
761
|
-
aliases[envNameForCredentialRef(name)] = value;
|
|
762
|
-
}
|
|
763
|
-
return aliases;
|
|
764
|
-
}
|
|
765
|
-
async function materializeBootstrapIdentity(identity, workspaceRoot) {
|
|
766
|
-
if (!identity) {
|
|
767
|
-
throw new Error('Sandbox bootstrap file is missing identity.');
|
|
768
|
-
}
|
|
769
|
-
const publicKey = requiredString(identity['public_key'] ?? identity['publicKey'], 'identity.public_key');
|
|
770
|
-
const privateKey = requiredString(identity['private_key'] ?? identity['privateKey'], 'identity.private_key');
|
|
771
|
-
const publicKeyFingerprint = requiredString(identity['public_key_fingerprint'] ?? identity['publicKeyFingerprint'], 'identity.public_key_fingerprint');
|
|
772
|
-
const dir = path.join(workspaceRoot, '.viewport', 'bootstrap');
|
|
773
|
-
await fs.mkdir(dir, { recursive: true, mode: 0o700 });
|
|
774
|
-
const filePath = path.join(dir, `identity-${crypto.randomUUID()}.json`);
|
|
775
|
-
await fs.writeFile(filePath, `${JSON.stringify({ publicKey, privateKey, publicKeyFingerprint })}\n`, { mode: 0o600 });
|
|
776
|
-
return { path: filePath, publicKeyFingerprint, ephemeral: true };
|
|
777
|
-
}
|
|
778
|
-
function workerTransportValue(value) {
|
|
779
|
-
return value === 'polling' || value === 'relay' || value === 'inbound' ? value : undefined;
|
|
780
|
-
}
|
|
781
|
-
function requiredString(value, label) {
|
|
782
|
-
const result = stringValue(value);
|
|
783
|
-
if (!result) {
|
|
784
|
-
throw new Error(`Sandbox bootstrap file is missing ${label}.`);
|
|
785
|
-
}
|
|
786
|
-
return result;
|
|
787
|
-
}
|
|
788
|
-
function validateInboundWorkerGate(profile) {
|
|
789
|
-
const enabled = profile.inbound?.enabled === true || process.env['VPD_WORKER_INBOUND_EXPERIMENTAL'] === '1';
|
|
790
|
-
if (!enabled) {
|
|
791
|
-
throw new Error('Inbound worker transport is disabled by default. Enable VPD_WORKER_INBOUND_EXPERIMENTAL=1 only with signed inbound proof, replay protection, and control-plane claim verification.');
|
|
792
|
-
}
|
|
793
|
-
const missing = [];
|
|
794
|
-
if (profile.inbound?.signedRequests !== true)
|
|
795
|
-
missing.push('signed inbound requests');
|
|
796
|
-
if (profile.inbound?.replayProtection !== true)
|
|
797
|
-
missing.push('replay protection');
|
|
798
|
-
if (profile.inbound?.controlPlaneClaimVerify !== true) {
|
|
799
|
-
missing.push('control-plane claim verification');
|
|
800
|
-
}
|
|
801
|
-
if (missing.length > 0) {
|
|
802
|
-
throw new Error(`Inbound worker transport is gated: missing ${missing.join(', ')}.`);
|
|
803
|
-
}
|
|
804
|
-
throw new Error('Inbound worker transport listener is not implemented yet; do not enable inbound without the signed listener proof.');
|
|
805
|
-
}
|
|
806
|
-
async function claimLeaseHttp(profile, body, dispatcher) {
|
|
807
|
-
const leaseSeconds = positiveInteger(body['leaseSeconds']) ?? DEFAULT_HOSTED_LEASE_SECONDS;
|
|
808
|
-
const response = isHostedManagedExecutorProfile(profile)
|
|
809
|
-
? await hostedManagedExecutorFetch(profile, 'POST', 'claim', {
|
|
810
|
-
credential: profile.credential,
|
|
811
|
-
lease_seconds: leaseSeconds,
|
|
812
|
-
}, undefined, undefined, [], dispatcher)
|
|
813
|
-
: await workerFetch(profile, 'workers/claim', body);
|
|
814
|
-
if (response.status === 204)
|
|
815
|
-
return null;
|
|
816
|
-
const parsed = (await response.json());
|
|
817
|
-
const data = parsed['data'] && typeof parsed['data'] === 'object'
|
|
818
|
-
? parsed['data']
|
|
819
|
-
: parsed;
|
|
820
|
-
const rawLease = data['run_lease'] && typeof data['run_lease'] === 'object'
|
|
821
|
-
? data['run_lease']
|
|
822
|
-
: data['lease'] && typeof data['lease'] === 'object'
|
|
823
|
-
? data['lease']
|
|
824
|
-
: data;
|
|
825
|
-
const id = stringValue(rawLease['id'] ?? rawLease['lease_id']);
|
|
826
|
-
if (!id) {
|
|
827
|
-
throw new Error('Worker claim response did not include a lease id.');
|
|
828
|
-
}
|
|
829
|
-
return {
|
|
830
|
-
id,
|
|
831
|
-
agentSessionId: stringValue(data['agent_session_id'] ??
|
|
832
|
-
data['agentSessionId'] ??
|
|
833
|
-
rawLease['agent_session_id'] ??
|
|
834
|
-
rawLease['agentSessionId']),
|
|
835
|
-
runId: stringValue(data['id'] ?? rawLease['workflow_run_id'] ?? rawLease['run_id'] ?? rawLease['runId']),
|
|
836
|
-
runtimeRunId: stringValue(data['runtime_run_id'] ?? rawLease['runtime_run_id']),
|
|
837
|
-
leaseToken: stringValue(rawLease['lease_token'] ?? rawLease['leaseToken']),
|
|
838
|
-
assignmentClaimToken: stringValue(data['assignment_claim_token']),
|
|
839
|
-
sessionVerificationContract: sessionVerificationContractValue(data['session_verification_contract'] ??
|
|
840
|
-
data['sessionVerificationContract'] ??
|
|
841
|
-
rawLease['session_verification_contract'] ??
|
|
842
|
-
rawLease['sessionVerificationContract']),
|
|
843
|
-
yamlSnapshot: stringValue(data['yaml_snapshot'] ?? rawLease['yaml_snapshot']),
|
|
844
|
-
sourceRef: stringValue(data['source_ref'] ?? rawLease['source_ref']),
|
|
845
|
-
directoryPath: stringValue(data['directory_path'] ?? rawLease['directory_path']),
|
|
846
|
-
inputSnapshot: recordValue(data['input_snapshot'] ?? rawLease['input_snapshot']),
|
|
847
|
-
resourceManifest: recordValue(data['resource_manifest'] ?? rawLease['resource_manifest']),
|
|
848
|
-
workflowAuthorityContract: recordValue(data['workflow_authority_contract'] ?? rawLease['workflow_authority_contract']),
|
|
849
|
-
executionProfileSnapshot: recordValue(data['execution_profile_snapshot'] ?? rawLease['execution_profile_snapshot']),
|
|
850
|
-
workflowSnapshot: recordValue(data['workflow_snapshot'] ?? rawLease['workflow_snapshot']),
|
|
851
|
-
runtimeTargetId: runtimeContextTargetIdValue(data, rawLease),
|
|
852
|
-
dataCapturePolicy: dataCapturePolicyValue(data['data_capture_policy'] ?? rawLease['data_capture_policy']),
|
|
853
|
-
};
|
|
854
|
-
}
|
|
855
|
-
async function heartbeatHttp(profile, options, dispatcher) {
|
|
856
|
-
const capabilityPayload = managedExecutorCapabilities(profile.capabilities);
|
|
857
|
-
if (isHostedManagedExecutorProfile(profile)) {
|
|
858
|
-
await hostedManagedExecutorFetch(profile, 'POST', 'heartbeat', {
|
|
859
|
-
credential: profile.credential,
|
|
860
|
-
status: options.status,
|
|
861
|
-
health_status: options.healthStatus,
|
|
862
|
-
access_mode: options.transport,
|
|
863
|
-
runner_mode: options.lifecycle === 'ephemeral' ? 'viewport_managed' : 'self_hosted',
|
|
864
|
-
runner_provider: options.lifecycle === 'ephemeral' ? 'viewport_cloud' : 'local',
|
|
865
|
-
context_execution_mode: options.lifecycle === 'ephemeral'
|
|
866
|
-
? 'viewport_managed'
|
|
867
|
-
: 'customer_managed_context_worker',
|
|
868
|
-
credential_mode: options.lifecycle === 'ephemeral' ? 'run_scoped_grant' : 'runner_local',
|
|
869
|
-
runner_profile: stringValue(capabilityPayload['runner_pool']) ??
|
|
870
|
-
stringValue(capabilityPayload['runnerPool']) ??
|
|
871
|
-
null,
|
|
872
|
-
runner_posture: {
|
|
873
|
-
transport: { mode: options.transport },
|
|
874
|
-
execution: {
|
|
875
|
-
kind: options.lifecycle === 'ephemeral' ? 'ephemeral-worker' : 'persistent-worker',
|
|
876
|
-
},
|
|
877
|
-
},
|
|
878
|
-
capabilities: capabilityPayload,
|
|
879
|
-
}, undefined, undefined, [], dispatcher);
|
|
880
|
-
return;
|
|
881
|
-
}
|
|
882
|
-
await workerRequest(profile, 'workers/heartbeat', {
|
|
883
|
-
status: options.status,
|
|
884
|
-
health_status: options.healthStatus,
|
|
885
|
-
lifecycle: options.lifecycle,
|
|
886
|
-
transport: options.transport,
|
|
887
|
-
workspace_root: profile.workspaceRoot,
|
|
888
|
-
public_key_fingerprint: profile.publicKeyFingerprint,
|
|
889
|
-
capabilities: profile.capabilities,
|
|
890
|
-
});
|
|
891
|
-
}
|
|
892
|
-
async function syncLeaseHttp(profile, lease, execution, dispatcher) {
|
|
893
|
-
const status = execution.status;
|
|
894
|
-
if (isHostedManagedExecutorProfile(profile)) {
|
|
895
|
-
if (!lease.runId) {
|
|
896
|
-
throw new Error('Hosted managed executor sync requires a workflow run id.');
|
|
897
|
-
}
|
|
898
|
-
const runPayload = execution.run
|
|
899
|
-
? workflowRunToSyncPayload(execution.run, {
|
|
900
|
-
enforceDataCapturePolicy: true,
|
|
901
|
-
includeApprovalDecisions: false,
|
|
902
|
-
})
|
|
903
|
-
: undefined;
|
|
904
|
-
const failure = execution.failure ?? hostedWorkerExecutionUnavailableFailure();
|
|
905
|
-
await hostedManagedExecutorFetch(profile, 'PATCH', `workflow-runs/${encodeURIComponent(lease.runId)}/sync`, {
|
|
906
|
-
...(runPayload ?? {}),
|
|
907
|
-
credential: profile.credential,
|
|
908
|
-
runtime_run_id: typeof runPayload?.['runtime_run_id'] === 'string'
|
|
909
|
-
? runPayload['runtime_run_id']
|
|
910
|
-
: `vpd-worker-${lease.runId}`,
|
|
911
|
-
status,
|
|
912
|
-
completed_at: status === 'blocked'
|
|
913
|
-
? null
|
|
914
|
-
: typeof runPayload?.['completed_at'] === 'string'
|
|
915
|
-
? runPayload['completed_at']
|
|
916
|
-
: new Date().toISOString(),
|
|
917
|
-
...(status === 'failed'
|
|
918
|
-
? {
|
|
919
|
-
error_summary: failure.summary,
|
|
920
|
-
failure: {
|
|
921
|
-
schema: 'viewport.workflow_failure/v1',
|
|
922
|
-
error_code: failure.errorCode,
|
|
923
|
-
failure_class: failure.failureClass,
|
|
924
|
-
summary: failure.summary,
|
|
925
|
-
next_check: failure.nextCheck,
|
|
926
|
-
retry_safe: failure.retrySafe,
|
|
927
|
-
lease_released: true,
|
|
928
|
-
details: {
|
|
929
|
-
worker_runtime: 'standalone',
|
|
930
|
-
hosted_managed_executor: true,
|
|
931
|
-
},
|
|
932
|
-
},
|
|
933
|
-
}
|
|
934
|
-
: {}),
|
|
935
|
-
events: [
|
|
936
|
-
...(Array.isArray(runPayload?.['events'])
|
|
937
|
-
? runPayload['events']
|
|
938
|
-
: []),
|
|
939
|
-
{
|
|
940
|
-
runtime_event_id: `vpd-worker-${lease.runId}-${status}`,
|
|
941
|
-
type: status === 'completed' ? 'run-completed' : 'run-failed',
|
|
942
|
-
severity: status === 'completed' ? 'info' : 'error',
|
|
943
|
-
message: `vpd worker marked run ${status}`,
|
|
944
|
-
},
|
|
945
|
-
],
|
|
946
|
-
}, lease.assignmentClaimToken, lease.leaseToken, [], dispatcher);
|
|
947
|
-
return;
|
|
948
|
-
}
|
|
949
|
-
await workerRequest(profile, `workers/leases/${encodeURIComponent(lease.id)}/sync`, {
|
|
950
|
-
lease_id: lease.id,
|
|
951
|
-
run_id: lease.runId ?? null,
|
|
952
|
-
status,
|
|
953
|
-
event_type: 'phase8_fixture',
|
|
954
|
-
runtime_event_id: `phase8-${lease.id}-${status}`,
|
|
955
|
-
});
|
|
956
|
-
}
|
|
957
|
-
async function executeHostedWorkflowClaim(profile, transport, lease) {
|
|
958
|
-
if (!lease.leaseToken) {
|
|
959
|
-
return {
|
|
960
|
-
status: 'failed',
|
|
961
|
-
failure: hostedWorkerMissingLeaseTokenFailure(),
|
|
962
|
-
};
|
|
963
|
-
}
|
|
964
|
-
if (!lease.yamlSnapshot) {
|
|
965
|
-
return {
|
|
966
|
-
status: 'failed',
|
|
967
|
-
failure: hostedWorkerExecutionUnavailableFailure(),
|
|
968
|
-
};
|
|
969
|
-
}
|
|
970
|
-
try {
|
|
971
|
-
const daemon = await createStandaloneWorkerDaemon();
|
|
972
|
-
const existing = await existingHostedRuntimeRun(lease);
|
|
973
|
-
if (existing) {
|
|
974
|
-
if (existing.status === 'blocked') {
|
|
975
|
-
const body = await transport.pollRuntimeCommands(lease);
|
|
976
|
-
const runtimeSecretEnv = await runtimeSecretEnvForHostedRun(profile, lease, transport);
|
|
977
|
-
const applied = await daemon.workflowRunner.applyRuntimeCommandBody(existing.id, body, {
|
|
978
|
-
runtimeSecretEnv,
|
|
979
|
-
});
|
|
980
|
-
if (applied > 0) {
|
|
981
|
-
const completed = await waitForWorkflowRun(daemon, existing.id);
|
|
982
|
-
return {
|
|
983
|
-
status: normalizeWorkflowStatus(completed.status),
|
|
984
|
-
run: completed,
|
|
985
|
-
daemon,
|
|
986
|
-
...(completed.status === 'failed' || completed.status === 'canceled'
|
|
987
|
-
? { failure: workflowRunFailure(completed) }
|
|
988
|
-
: {}),
|
|
989
|
-
};
|
|
990
|
-
}
|
|
991
|
-
}
|
|
992
|
-
return {
|
|
993
|
-
status: normalizeWorkflowStatus(existing.status),
|
|
994
|
-
run: existing,
|
|
995
|
-
daemon,
|
|
996
|
-
...(existing.status === 'failed' || existing.status === 'canceled'
|
|
997
|
-
? { failure: workflowRunFailure(existing) }
|
|
998
|
-
: {}),
|
|
999
|
-
};
|
|
1000
|
-
}
|
|
1001
|
-
const directoryPath = path.resolve(lease.directoryPath ?? profile.workspaceRoot);
|
|
1002
|
-
await fs.mkdir(directoryPath, { recursive: true });
|
|
1003
|
-
const directory = await daemon.directoryManager.register(directoryPath);
|
|
1004
|
-
const runtimeSecretEnv = await runtimeSecretEnvForHostedRun(profile, lease, transport);
|
|
1005
|
-
const run = await daemon.workflowRunner.startRun({
|
|
1006
|
-
workflowYaml: lease.yamlSnapshot,
|
|
1007
|
-
workflowSourceRef: lease.sourceRef ?? `viewport://managed-executor/${lease.runId ?? lease.id}`,
|
|
1008
|
-
directoryId: directory.id,
|
|
1009
|
-
inputs: hostedWorkflowInputs(profile, lease),
|
|
1010
|
-
resourceId: profile.workspaceId,
|
|
1011
|
-
runtimeTargetId: hostedRuntimeContextTargetId(profile, lease),
|
|
1012
|
-
platformRunId: lease.runId,
|
|
1013
|
-
agentSessionId: lease.agentSessionId,
|
|
1014
|
-
resourceManifest: lease.resourceManifest,
|
|
1015
|
-
workflowAuthorityContract: lease.workflowAuthorityContract,
|
|
1016
|
-
dataCapturePolicy: lease.dataCapturePolicy,
|
|
1017
|
-
runtimeSecretEnv,
|
|
1018
|
-
initiation: 'cli',
|
|
1019
|
-
});
|
|
1020
|
-
const completed = await waitForWorkflowRun(daemon, run.id);
|
|
1021
|
-
return {
|
|
1022
|
-
status: normalizeWorkflowStatus(completed.status),
|
|
1023
|
-
run: completed,
|
|
1024
|
-
daemon,
|
|
1025
|
-
...(completed.status === 'failed' || completed.status === 'canceled'
|
|
1026
|
-
? { failure: workflowRunFailure(completed) }
|
|
1027
|
-
: {}),
|
|
1028
|
-
};
|
|
1029
|
-
}
|
|
1030
|
-
catch (error) {
|
|
1031
|
-
return {
|
|
1032
|
-
status: 'failed',
|
|
1033
|
-
failure: {
|
|
1034
|
-
errorCode: 'RUNNER_WORKFLOW_EXECUTION_FAILED',
|
|
1035
|
-
failureClass: 'internal_error',
|
|
1036
|
-
summary: error instanceof Error ? error.message : 'Standalone worker execution failed.',
|
|
1037
|
-
nextCheck: 'Inspect worker logs and workflow execution receipts.',
|
|
1038
|
-
retrySafe: false,
|
|
1039
|
-
},
|
|
1040
|
-
};
|
|
1041
|
-
}
|
|
1042
|
-
}
|
|
1043
|
-
async function materializeHostedRunCredentials(profile, lease, dispatcher) {
|
|
1044
|
-
if (!lease.runId) {
|
|
1045
|
-
throw new Error('Hosted managed executor credential materialization requires a workflow run id.');
|
|
1046
|
-
}
|
|
1047
|
-
if (!lease.assignmentClaimToken) {
|
|
1048
|
-
throw new Error('Hosted managed executor credential materialization requires a claim token.');
|
|
1049
|
-
}
|
|
1050
|
-
const runtimeSecretEnv = {};
|
|
1051
|
-
const handles = credentialHandlesFromLease(lease);
|
|
1052
|
-
for (const handle of handles) {
|
|
1053
|
-
const response = await hostedManagedExecutorFetch(profile, 'POST', `workflow-runs/${encodeURIComponent(lease.runId)}/credential-material`, {
|
|
1054
|
-
credential: profile.credential,
|
|
1055
|
-
handle,
|
|
1056
|
-
...repositoryForCredentialHandle(lease, handle),
|
|
1057
|
-
}, lease.assignmentClaimToken, lease.leaseToken, [], dispatcher);
|
|
1058
|
-
const parsed = (await response.json());
|
|
1059
|
-
const data = parsed['data'] && typeof parsed['data'] === 'object'
|
|
1060
|
-
? parsed['data']
|
|
1061
|
-
: parsed;
|
|
1062
|
-
const secret = stringValue(data['secret']);
|
|
1063
|
-
if (secret) {
|
|
1064
|
-
runtimeSecretEnv[envNameForCredentialRef(handle)] = secret;
|
|
1065
|
-
}
|
|
1066
|
-
}
|
|
1067
|
-
return runtimeSecretEnv;
|
|
1068
|
-
}
|
|
1069
|
-
async function runtimeSecretEnvForHostedRun(profile, lease, transport) {
|
|
1070
|
-
const dispatcher = transport instanceof RelayWorkerTransport
|
|
1071
|
-
? (request) => transport.dispatchHostedManagedExecutorRequest(request)
|
|
1072
|
-
: undefined;
|
|
1073
|
-
return {
|
|
1074
|
-
...(await materializeHostedRunCredentials(profile, lease, dispatcher)),
|
|
1075
|
-
...gatewayLeaseCredentialEnv(lease.gateway),
|
|
1076
|
-
...gatewayLeaseEnv(lease.gateway),
|
|
1077
|
-
};
|
|
1078
|
-
}
|
|
1079
|
-
function credentialHandlesFromLease(lease) {
|
|
1080
|
-
const workflow = yamlSnapshotDocument(lease);
|
|
1081
|
-
const handles = new Set();
|
|
1082
|
-
for (const handle of [
|
|
1083
|
-
...workflowNodeCredentialRefs(isRecord(workflow) ? workflow['nodes'] : undefined),
|
|
1084
|
-
...topLevelCredentialRefs(isRecord(workflow) ? workflow['credentials'] : undefined),
|
|
1085
|
-
...profileCredentialRefs(lease.executionProfileSnapshot),
|
|
1086
|
-
...profileCredentialRefs(lease.workflowSnapshot),
|
|
1087
|
-
...providerActionCredentialRefs(lease.workflowAuthorityContract),
|
|
1088
|
-
]) {
|
|
1089
|
-
handles.add(handle);
|
|
1090
|
-
}
|
|
1091
|
-
return [...handles].sort();
|
|
1092
|
-
}
|
|
1093
|
-
function repositoryForCredentialHandle(lease, handle) {
|
|
1094
|
-
const workflow = yamlSnapshotDocument(lease);
|
|
1095
|
-
const nodes = isRecord(workflow) ? workflow['nodes'] : undefined;
|
|
1096
|
-
if (!isRecord(nodes))
|
|
1097
|
-
return {};
|
|
1098
|
-
for (const node of Object.values(nodes)) {
|
|
1099
|
-
if (!isRecord(node))
|
|
1100
|
-
continue;
|
|
1101
|
-
const withValue = isRecord(node['with']) ? node['with'] : {};
|
|
1102
|
-
const credentialRef = stringValue(withValue['credential_ref']) ??
|
|
1103
|
-
stringValue(withValue['credentialRef']) ??
|
|
1104
|
-
stringValue(node['credential_ref']) ??
|
|
1105
|
-
stringValue(node['credentialRef']);
|
|
1106
|
-
if (credentialRef !== handle)
|
|
1107
|
-
continue;
|
|
1108
|
-
const repository = renderLeaseTemplate(repositoryTemplateForNode(node, withValue), lease);
|
|
1109
|
-
if (repository)
|
|
1110
|
-
return { repository };
|
|
1111
|
-
}
|
|
1112
|
-
return {};
|
|
1113
|
-
}
|
|
1114
|
-
function workflowNodeCredentialRefs(nodes) {
|
|
1115
|
-
if (!isRecord(nodes))
|
|
1116
|
-
return [];
|
|
1117
|
-
return Object.values(nodes).flatMap((node) => {
|
|
1118
|
-
if (!isRecord(node))
|
|
1119
|
-
return [];
|
|
1120
|
-
const type = stringValue(node['type']);
|
|
1121
|
-
if (type !== 'action' && type !== 'checkout' && type !== 'git_publish')
|
|
1122
|
-
return [];
|
|
1123
|
-
const withValue = isRecord(node['with']) ? node['with'] : {};
|
|
1124
|
-
const credentialRef = stringValue(withValue['credential_ref']) ??
|
|
1125
|
-
stringValue(withValue['credentialRef']) ??
|
|
1126
|
-
stringValue(node['credential_ref']) ??
|
|
1127
|
-
stringValue(node['credentialRef']);
|
|
1128
|
-
return credentialRef ? [credentialRef] : [];
|
|
1129
|
-
});
|
|
1130
|
-
}
|
|
1131
|
-
function topLevelCredentialRefs(credentials) {
|
|
1132
|
-
if (!isRecord(credentials))
|
|
1133
|
-
return [];
|
|
1134
|
-
const refs = [];
|
|
1135
|
-
for (const value of Object.values(credentials)) {
|
|
1136
|
-
refs.push(...credentialEntriesFrom(value));
|
|
1137
|
-
}
|
|
1138
|
-
return refs;
|
|
1139
|
-
}
|
|
1140
|
-
function profileCredentialRefs(snapshot) {
|
|
1141
|
-
const credentials = pathValue(asRecord(snapshot), ['credentials']);
|
|
1142
|
-
if (!isRecord(credentials))
|
|
1143
|
-
return [];
|
|
1144
|
-
const refs = [];
|
|
1145
|
-
for (const value of Object.values(credentials)) {
|
|
1146
|
-
refs.push(...credentialEntriesFrom(value));
|
|
1147
|
-
}
|
|
1148
|
-
return refs;
|
|
1149
|
-
}
|
|
1150
|
-
function credentialEntriesFrom(value) {
|
|
1151
|
-
if (!Array.isArray(value))
|
|
1152
|
-
return [];
|
|
1153
|
-
return value.flatMap((entry) => {
|
|
1154
|
-
if (typeof entry === 'string' && entry.trim() !== '')
|
|
1155
|
-
return [entry.trim()];
|
|
1156
|
-
if (!isRecord(entry))
|
|
1157
|
-
return [];
|
|
1158
|
-
const handle = stringValue(entry['handle']) ??
|
|
1159
|
-
stringValue(entry['ref']) ??
|
|
1160
|
-
stringValue(entry['credential_ref']) ??
|
|
1161
|
-
stringValue(entry['credentialRef']);
|
|
1162
|
-
return handle ? [handle] : [];
|
|
1163
|
-
});
|
|
1164
|
-
}
|
|
1165
|
-
function providerActionCredentialRefs(contract) {
|
|
1166
|
-
const entries = pathValue(asRecord(contract), ['credentials', 'provider_actions']);
|
|
1167
|
-
if (!Array.isArray(entries))
|
|
1168
|
-
return [];
|
|
1169
|
-
return entries.flatMap((entry) => {
|
|
1170
|
-
if (typeof entry === 'string' && entry.trim() !== '')
|
|
1171
|
-
return [entry.trim()];
|
|
1172
|
-
if (!isRecord(entry))
|
|
1173
|
-
return [];
|
|
1174
|
-
const value = stringValue(entry['handle']) ??
|
|
1175
|
-
stringValue(entry['ref']) ??
|
|
1176
|
-
stringValue(entry['credential_ref']);
|
|
1177
|
-
return value ? [value] : [];
|
|
1178
|
-
});
|
|
1179
|
-
}
|
|
1180
|
-
function repositoryTemplateForNode(node, withValue) {
|
|
1181
|
-
return (stringValue(withValue['repository']) ??
|
|
1182
|
-
stringValue(withValue['repo']) ??
|
|
1183
|
-
stringValue(node['repository']) ??
|
|
1184
|
-
stringValue(node['repo']));
|
|
1185
|
-
}
|
|
1186
|
-
function renderLeaseTemplate(value, lease) {
|
|
1187
|
-
if (!value)
|
|
1188
|
-
return null;
|
|
1189
|
-
const inputs = isRecord(lease.inputSnapshot) ? lease.inputSnapshot : {};
|
|
1190
|
-
const rendered = value.replace(/\{\{\s*inputs\.([A-Za-z0-9_]+)\s*\}\}/g, (_match, key) => {
|
|
1191
|
-
const input = inputs[key];
|
|
1192
|
-
return typeof input === 'string' || typeof input === 'number' || typeof input === 'boolean'
|
|
1193
|
-
? String(input)
|
|
1194
|
-
: '';
|
|
1195
|
-
});
|
|
1196
|
-
const trimmed = rendered.trim();
|
|
1197
|
-
return trimmed === '' || trimmed.includes('{{') ? null : trimmed;
|
|
1198
|
-
}
|
|
1199
|
-
function yamlSnapshotDocument(lease) {
|
|
1200
|
-
if (!lease.yamlSnapshot)
|
|
1201
|
-
return null;
|
|
1202
|
-
try {
|
|
1203
|
-
return YAML.parse(lease.yamlSnapshot);
|
|
1204
|
-
}
|
|
1205
|
-
catch {
|
|
1206
|
-
return null;
|
|
1207
|
-
}
|
|
1208
|
-
}
|
|
1209
|
-
async function existingHostedRuntimeRun(lease) {
|
|
1210
|
-
if (!lease.runtimeRunId)
|
|
1211
|
-
return null;
|
|
1212
|
-
const existing = await new WorkflowRunStore().get(lease.runtimeRunId);
|
|
1213
|
-
if (!existing)
|
|
1214
|
-
return null;
|
|
1215
|
-
if (lease.runId && existing.platformRunId !== lease.runId)
|
|
1216
|
-
return null;
|
|
1217
|
-
return existing;
|
|
1218
|
-
}
|
|
1219
|
-
async function resumeBlockedHostedExecution(profile, transport, lease, execution) {
|
|
1220
|
-
if (!execution.daemon || !execution.run || execution.status !== 'blocked') {
|
|
1221
|
-
return execution;
|
|
1222
|
-
}
|
|
1223
|
-
const daemon = execution.daemon;
|
|
1224
|
-
const workflowRunId = execution.run.id;
|
|
1225
|
-
const deadline = Date.now() + 10 * 60_000;
|
|
1226
|
-
while (Date.now() < deadline) {
|
|
1227
|
-
const body = await transport.pollRuntimeCommands(lease);
|
|
1228
|
-
if (!hasRuntimeCommands(body)) {
|
|
1229
|
-
if (shouldRetryHostedCommandPoll(body)) {
|
|
1230
|
-
continue;
|
|
1231
|
-
}
|
|
1232
|
-
return execution;
|
|
1233
|
-
}
|
|
1234
|
-
const runtimeSecretEnv = await runtimeSecretEnvForHostedRun(profile, lease);
|
|
1235
|
-
const applied = await daemon.workflowRunner.applyRuntimeCommandBody(workflowRunId, body, {
|
|
1236
|
-
runtimeSecretEnv,
|
|
1237
|
-
});
|
|
1238
|
-
if (applied > 0) {
|
|
1239
|
-
const completed = await waitForWorkflowRun(daemon, workflowRunId);
|
|
1240
|
-
if (completed.status === 'blocked') {
|
|
1241
|
-
const blockedExecution = {
|
|
1242
|
-
status: 'blocked',
|
|
1243
|
-
run: completed,
|
|
1244
|
-
daemon,
|
|
1245
|
-
};
|
|
1246
|
-
await transport.sync(lease, blockedExecution);
|
|
1247
|
-
execution = blockedExecution;
|
|
1248
|
-
continue;
|
|
1249
|
-
}
|
|
1250
|
-
return {
|
|
1251
|
-
status: normalizeWorkflowStatus(completed.status),
|
|
1252
|
-
run: completed,
|
|
1253
|
-
daemon,
|
|
1254
|
-
...(completed.status === 'failed' || completed.status === 'canceled'
|
|
1255
|
-
? { failure: workflowRunFailure(completed) }
|
|
1256
|
-
: {}),
|
|
1257
|
-
};
|
|
1258
|
-
}
|
|
1259
|
-
await sleep(2_000);
|
|
1260
|
-
}
|
|
1261
|
-
return execution;
|
|
1262
|
-
}
|
|
1263
|
-
async function maybeExecuteHostedSessionVerification(profile, transport, lease, execution) {
|
|
1264
|
-
if (!isHostedManagedExecutorProfile(profile))
|
|
1265
|
-
return;
|
|
1266
|
-
if (execution.status !== 'completed' || !execution.run)
|
|
1267
|
-
return;
|
|
1268
|
-
const contract = await executableHostedSessionVerificationContract(transport, lease);
|
|
1269
|
-
if (!contract || !verificationRunnerMayExecute(contract))
|
|
1270
|
-
return;
|
|
1271
|
-
const agentSessionId = verificationAgentSessionId(contract);
|
|
1272
|
-
if (!agentSessionId)
|
|
1273
|
-
return;
|
|
1274
|
-
const commands = verificationCommands(contract);
|
|
1275
|
-
if (commands.length === 0)
|
|
1276
|
-
return;
|
|
1277
|
-
const runDirectoryPath = execution.run.directoryPath ?? lease.directoryPath ?? profile.workspaceRoot;
|
|
1278
|
-
const defaultCommandDirectory = verificationDefaultCommandDirectory(execution.run);
|
|
1279
|
-
const commandResults = [];
|
|
1280
|
-
const artifactRefs = [];
|
|
1281
|
-
for (const command of commands) {
|
|
1282
|
-
const name = verificationCommandName(command, commandResults.length + 1);
|
|
1283
|
-
const commandText = verificationCommandText(command);
|
|
1284
|
-
let result;
|
|
1285
|
-
let executionError;
|
|
1286
|
-
try {
|
|
1287
|
-
const cwd = verificationCommandCwd(runDirectoryPath, command, defaultCommandDirectory);
|
|
1288
|
-
result = await runShellCommand(commandText, '', cwd);
|
|
1289
|
-
}
|
|
1290
|
-
catch (error) {
|
|
1291
|
-
executionError = errorMessage(error);
|
|
1292
|
-
result = { exitCode: 1, stdout: '', stderr: '' };
|
|
1293
|
-
}
|
|
1294
|
-
const stdoutDigest = sha256Text(result.stdout);
|
|
1295
|
-
const stderrDigest = sha256Text(result.stderr);
|
|
1296
|
-
const status = result.exitCode === 0 ? 'passed' : 'failed';
|
|
1297
|
-
artifactRefs.push(`verification:${name}:stdout:${stdoutDigest}`);
|
|
1298
|
-
if (result.stderr.trim() !== '') {
|
|
1299
|
-
artifactRefs.push(`verification:${name}:stderr:${stderrDigest}`);
|
|
1300
|
-
}
|
|
1301
|
-
commandResults.push({
|
|
1302
|
-
schema: 'viewport.verification_command_result/v1',
|
|
1303
|
-
name,
|
|
1304
|
-
status,
|
|
1305
|
-
required: command.required !== false,
|
|
1306
|
-
exit_code: result.exitCode,
|
|
1307
|
-
command_sha256: sha256Text(commandText),
|
|
1308
|
-
stdout_sha256: stdoutDigest,
|
|
1309
|
-
stderr_sha256: stderrDigest,
|
|
1310
|
-
stdout_bytes: Buffer.byteLength(result.stdout, 'utf8'),
|
|
1311
|
-
stderr_bytes: Buffer.byteLength(result.stderr, 'utf8'),
|
|
1312
|
-
working_directory: verificationCommandWorkingDirectory(command) ??
|
|
1313
|
-
verificationDisplayWorkingDirectory(runDirectoryPath, defaultCommandDirectory),
|
|
1314
|
-
raw_output_included: false,
|
|
1315
|
-
...(executionError ? { error: executionError } : {}),
|
|
1316
|
-
});
|
|
1317
|
-
}
|
|
1318
|
-
const requiredFailures = commandResults.filter((result) => result['required'] !== false && result['status'] !== 'passed');
|
|
1319
|
-
const passedCount = commandResults.filter((result) => result['status'] === 'passed').length;
|
|
1320
|
-
const status = requiredFailures.length > 0 ? 'failed' : 'passed';
|
|
1321
|
-
const summary = status === 'passed'
|
|
1322
|
-
? `${passedCount}/${commandResults.length} verification commands passed.`
|
|
1323
|
-
: `${requiredFailures.length} required verification command(s) failed.`;
|
|
1324
|
-
await postHostedSessionVerificationAttempt(profile, transport, lease, contract, agentSessionId, {
|
|
1325
|
-
status,
|
|
1326
|
-
attempt_kind: 'verification',
|
|
1327
|
-
summary,
|
|
1328
|
-
artifact_refs: artifactRefs.slice(0, 50),
|
|
1329
|
-
verification_pack: {
|
|
1330
|
-
schema: 'viewport.verification_pack_result/v1',
|
|
1331
|
-
source_schema: contract.schema ?? null,
|
|
1332
|
-
agent_session_id: agentSessionId,
|
|
1333
|
-
workflow_run_id: lease.runId,
|
|
1334
|
-
policy_hash: typeof contract['policy_hash'] === 'string' ? contract['policy_hash'] : null,
|
|
1335
|
-
command_results: commandResults,
|
|
1336
|
-
required_artifacts: verificationRequiredArtifacts(contract),
|
|
1337
|
-
raw_command_output_included: false,
|
|
1338
|
-
agent_self_assessment_used: false,
|
|
1339
|
-
},
|
|
1340
|
-
repair_recommendation: status === 'passed'
|
|
1341
|
-
? { action: 'none' }
|
|
1342
|
-
: {
|
|
1343
|
-
action: 'ask_human',
|
|
1344
|
-
failed_commands: requiredFailures.map((result) => result['name']),
|
|
1345
|
-
},
|
|
1346
|
-
});
|
|
1347
|
-
}
|
|
1348
|
-
async function executableHostedSessionVerificationContract(transport, lease) {
|
|
1349
|
-
const contract = lease.sessionVerificationContract;
|
|
1350
|
-
if (contract && verificationRunnerMayExecute(contract))
|
|
1351
|
-
return contract;
|
|
1352
|
-
if (!leaseMayHaveSessionVerification(lease))
|
|
1353
|
-
return contract ?? null;
|
|
1354
|
-
const refreshed = await transport.pollRuntimeCommands(lease);
|
|
1355
|
-
return sessionVerificationContractFromBody(refreshed) ?? contract ?? null;
|
|
1356
|
-
}
|
|
1357
|
-
function leaseMayHaveSessionVerification(lease) {
|
|
1358
|
-
const policyPin = recordValue(lease.workflowSnapshot?.['product20_policy_pin']);
|
|
1359
|
-
return Boolean(lease.agentSessionId ||
|
|
1360
|
-
stringValue(policyPin?.['agent_session_id']) ||
|
|
1361
|
-
lease.sessionVerificationContract);
|
|
1362
|
-
}
|
|
1363
|
-
function sessionVerificationContractFromBody(body) {
|
|
1364
|
-
const record = recordValue(body);
|
|
1365
|
-
const data = recordValue(record?.['data']);
|
|
1366
|
-
return (sessionVerificationContractValue(data?.['session_verification_contract'] ??
|
|
1367
|
-
data?.['sessionVerificationContract'] ??
|
|
1368
|
-
record?.['session_verification_contract'] ??
|
|
1369
|
-
record?.['sessionVerificationContract']) ?? null);
|
|
1370
|
-
}
|
|
1371
|
-
function sessionVerificationContractValue(value) {
|
|
1372
|
-
const record = recordValue(value);
|
|
1373
|
-
if (!record)
|
|
1374
|
-
return undefined;
|
|
1375
|
-
return record;
|
|
1376
|
-
}
|
|
1377
|
-
function verificationRunnerMayExecute(contract) {
|
|
1378
|
-
const access = contract.access_model ?? contract.accessModel ?? {};
|
|
1379
|
-
return access.runner_may_execute_commands === true || access.runnerMayExecuteCommands === true;
|
|
1380
|
-
}
|
|
1381
|
-
function verificationAgentSessionId(contract) {
|
|
1382
|
-
return contract.agent_session_id ?? contract.agentSessionId ?? null;
|
|
1383
|
-
}
|
|
1384
|
-
function verificationCommands(contract) {
|
|
1385
|
-
return (contract.commands ?? []).filter((command) => verificationCommandText(command) !== '');
|
|
1386
|
-
}
|
|
1387
|
-
function verificationCommandName(command, index) {
|
|
1388
|
-
return command.name?.trim() || `verification-${index}`;
|
|
1389
|
-
}
|
|
1390
|
-
function verificationCommandText(command) {
|
|
1391
|
-
return command.command?.trim() ?? '';
|
|
1392
|
-
}
|
|
1393
|
-
function verificationCommandWorkingDirectory(command) {
|
|
1394
|
-
return command.working_directory?.trim() || command.workingDirectory?.trim() || null;
|
|
1395
|
-
}
|
|
1396
|
-
function verificationCommandCwd(runDirectoryPath, command, defaultDirectoryPath) {
|
|
1397
|
-
const workingDirectory = verificationCommandWorkingDirectory(command);
|
|
1398
|
-
const root = path.resolve(runDirectoryPath);
|
|
1399
|
-
const resolved = workingDirectory
|
|
1400
|
-
? path.resolve(root, workingDirectory)
|
|
1401
|
-
: path.resolve(defaultDirectoryPath ?? root);
|
|
1402
|
-
const relative = path.relative(root, resolved);
|
|
1403
|
-
if (relative.startsWith('..') || path.isAbsolute(relative)) {
|
|
1404
|
-
throw new Error('Verification command working_directory must stay inside the run directory.');
|
|
1405
|
-
}
|
|
1406
|
-
return resolved;
|
|
1407
|
-
}
|
|
1408
|
-
function verificationDefaultCommandDirectory(run) {
|
|
1409
|
-
const root = path.resolve(run.directoryPath);
|
|
1410
|
-
for (const node of Object.values(run.nodes ?? {})) {
|
|
1411
|
-
if (node.type !== 'checkout')
|
|
1412
|
-
continue;
|
|
1413
|
-
const candidate = typeof node.outputs?.['path'] === 'string' ? node.outputs['path'] : null;
|
|
1414
|
-
if (!candidate)
|
|
1415
|
-
continue;
|
|
1416
|
-
const resolved = path.resolve(candidate);
|
|
1417
|
-
const relative = path.relative(root, resolved);
|
|
1418
|
-
if (!relative.startsWith('..') && !path.isAbsolute(relative)) {
|
|
1419
|
-
return resolved;
|
|
1420
|
-
}
|
|
1421
|
-
}
|
|
1422
|
-
return root;
|
|
1423
|
-
}
|
|
1424
|
-
function verificationDisplayWorkingDirectory(runDirectoryPath, directoryPath) {
|
|
1425
|
-
const root = path.resolve(runDirectoryPath);
|
|
1426
|
-
const resolved = path.resolve(directoryPath);
|
|
1427
|
-
const relative = path.relative(root, resolved);
|
|
1428
|
-
if (relative === '')
|
|
1429
|
-
return '.';
|
|
1430
|
-
if (relative.startsWith('..') || path.isAbsolute(relative))
|
|
1431
|
-
return '.';
|
|
1432
|
-
return relative;
|
|
1433
|
-
}
|
|
1434
|
-
function verificationRequiredArtifacts(contract) {
|
|
1435
|
-
return contract.required_artifacts ?? contract.requiredArtifacts ?? [];
|
|
1436
|
-
}
|
|
1437
|
-
async function runShellCommand(command, stdin, cwd = process.cwd()) {
|
|
1438
|
-
return new Promise((resolve, reject) => {
|
|
1439
|
-
const child = spawn('sh', ['-lc', command], {
|
|
1440
|
-
cwd,
|
|
1441
|
-
stdio: ['pipe', 'pipe', 'pipe'],
|
|
1442
|
-
env: process.env,
|
|
1443
|
-
});
|
|
1444
|
-
const stdout = [];
|
|
1445
|
-
const stderr = [];
|
|
1446
|
-
child.stdout.on('data', (chunk) => {
|
|
1447
|
-
stdout.push(Buffer.isBuffer(chunk) ? chunk : Buffer.from(chunk));
|
|
1448
|
-
});
|
|
1449
|
-
child.stderr.on('data', (chunk) => {
|
|
1450
|
-
stderr.push(Buffer.isBuffer(chunk) ? chunk : Buffer.from(chunk));
|
|
1451
|
-
});
|
|
1452
|
-
child.on('error', reject);
|
|
1453
|
-
child.on('close', (code) => {
|
|
1454
|
-
resolve({
|
|
1455
|
-
exitCode: code ?? 1,
|
|
1456
|
-
stdout: Buffer.concat(stdout).toString('utf8'),
|
|
1457
|
-
stderr: Buffer.concat(stderr).toString('utf8'),
|
|
1458
|
-
});
|
|
1459
|
-
});
|
|
1460
|
-
child.stdin.end(stdin);
|
|
1461
|
-
});
|
|
1462
|
-
}
|
|
1463
|
-
function sha256Text(value) {
|
|
1464
|
-
return `sha256:${crypto.createHash('sha256').update(value).digest('hex')}`;
|
|
1465
|
-
}
|
|
1466
|
-
function errorMessage(error) {
|
|
1467
|
-
return error instanceof Error ? error.message : String(error);
|
|
1468
|
-
}
|
|
1469
|
-
async function postHostedSessionVerificationAttempt(profile, transport, lease, contract, agentSessionId, payload) {
|
|
1470
|
-
if (!lease.runId) {
|
|
1471
|
-
throw new Error('Hosted session verification requires a workflow run id.');
|
|
1472
|
-
}
|
|
1473
|
-
const runLeaseToken = lease.assignmentClaimToken ?? lease.leaseToken;
|
|
1474
|
-
if (!runLeaseToken) {
|
|
1475
|
-
throw new Error('Hosted session verification requires a run lease token.');
|
|
1476
|
-
}
|
|
1477
|
-
const suffix = hostedVerificationRuntimePathSuffix(profile, contract, agentSessionId) ??
|
|
1478
|
-
`workflow-runs/${encodeURIComponent(lease.runId)}/agent-sessions/${encodeURIComponent(agentSessionId)}/verification-attempts`;
|
|
1479
|
-
const dispatcher = transport instanceof RelayWorkerTransport
|
|
1480
|
-
? (request) => transport.dispatchHostedManagedExecutorRequest(request)
|
|
1481
|
-
: undefined;
|
|
1482
|
-
await hostedManagedExecutorFetch(profile, 'POST', suffix, {
|
|
1483
|
-
credential: profile.credential,
|
|
1484
|
-
...payload,
|
|
1485
|
-
}, undefined, runLeaseToken, [], dispatcher);
|
|
1486
|
-
}
|
|
1487
|
-
function hostedVerificationRuntimePathSuffix(profile, contract, agentSessionId) {
|
|
1488
|
-
const runtimeTool = contract.runtime_tool ?? contract.runtimeTool ?? {};
|
|
1489
|
-
const endpoint = runtimeTool.runtime_endpoint ?? runtimeTool.runtimeEndpoint;
|
|
1490
|
-
if (typeof endpoint !== 'string' || endpoint.trim() === '')
|
|
1491
|
-
return null;
|
|
1492
|
-
const normalized = endpoint.trim();
|
|
1493
|
-
const prefix = `/api/runtime/workspaces/${encodeURIComponent(profile.workspaceId ?? '')}/managed-executors/${encodeURIComponent(profile.managedExecutorId ?? '')}/`;
|
|
1494
|
-
if (normalized.startsWith(prefix)) {
|
|
1495
|
-
return normalized.slice(prefix.length);
|
|
1496
|
-
}
|
|
1497
|
-
const fallback = `/workflow-runs/`;
|
|
1498
|
-
const index = normalized.indexOf(fallback);
|
|
1499
|
-
if (index >= 0 && normalized.includes(`/agent-sessions/${encodeURIComponent(agentSessionId)}/`)) {
|
|
1500
|
-
return normalized.slice(index + 1);
|
|
1501
|
-
}
|
|
1502
|
-
return null;
|
|
1503
|
-
}
|
|
1504
|
-
async function fetchHostedAssignmentHttp(profile, lease, dispatcher) {
|
|
1505
|
-
if (!lease.runId) {
|
|
1506
|
-
throw new Error('Hosted managed executor assignment polling requires a workflow run id.');
|
|
1507
|
-
}
|
|
1508
|
-
const response = await hostedManagedExecutorFetch(profile, 'GET', `workflow-runs/${encodeURIComponent(lease.runId)}`, {}, lease.assignmentClaimToken, lease.leaseToken, [429], dispatcher);
|
|
1509
|
-
if (response.status === 429) {
|
|
1510
|
-
await sleep(retryAfterMs(response));
|
|
1511
|
-
return { runtime_commands: [], _viewport_worker_retry: true };
|
|
1512
|
-
}
|
|
1513
|
-
return (await response.json());
|
|
1514
|
-
}
|
|
1515
|
-
function hasRuntimeCommands(body) {
|
|
1516
|
-
return Array.isArray(body.runtime_commands) && body.runtime_commands.length > 0;
|
|
1517
|
-
}
|
|
1518
|
-
function shouldRetryHostedCommandPoll(body) {
|
|
1519
|
-
return body._viewport_worker_retry === true;
|
|
1520
|
-
}
|
|
1521
|
-
async function createStandaloneWorkerDaemon() {
|
|
1522
|
-
const daemon = new Daemon();
|
|
1523
|
-
await daemon.initialize();
|
|
1524
|
-
const registry = await loadAgents(daemon);
|
|
1525
|
-
daemon.setModelProvider(() => registry.fetchAllModels());
|
|
1526
|
-
daemon.setTrackerFactory((trackerConfig, sessionId) => new GitTracker(trackerConfig, sessionId));
|
|
1527
|
-
daemon.resumePendingWorkflowRuns();
|
|
1528
|
-
return daemon;
|
|
1529
|
-
}
|
|
1530
|
-
async function waitForWorkflowRun(daemon, runId) {
|
|
1531
|
-
const deadline = Date.now() + 10 * 60_000;
|
|
1532
|
-
let last = null;
|
|
1533
|
-
const store = new WorkflowRunStore();
|
|
1534
|
-
while (Date.now() < deadline) {
|
|
1535
|
-
last = (await store.get(runId)) ?? (await daemon.workflowRunner.getRun(runId));
|
|
1536
|
-
if (last && ['completed', 'failed', 'blocked', 'canceled'].includes(last.status)) {
|
|
1537
|
-
return last;
|
|
1538
|
-
}
|
|
1539
|
-
await new Promise((resolve) => setTimeout(resolve, 100));
|
|
1540
|
-
}
|
|
1541
|
-
throw new Error(`Workflow run ${runId} did not reach a terminal or blocked state.`);
|
|
1542
|
-
}
|
|
1543
|
-
function normalizeWorkflowStatus(status) {
|
|
1544
|
-
return ['completed', 'failed', 'blocked', 'canceled'].includes(status)
|
|
1545
|
-
? status
|
|
1546
|
-
: 'failed';
|
|
1547
|
-
}
|
|
1548
|
-
function hostedWorkerExecutionUnavailableFailure() {
|
|
1549
|
-
return {
|
|
1550
|
-
errorCode: 'RUNNER_EXECUTION_ENGINE_UNAVAILABLE',
|
|
1551
|
-
failureClass: 'internal_error',
|
|
1552
|
-
summary: 'Standalone hosted worker claimed the run but no workflow execution engine is wired yet.',
|
|
1553
|
-
nextCheck: 'Wire the in-process workflow executor before enabling hosted worker completion.',
|
|
1554
|
-
retrySafe: false,
|
|
1555
|
-
};
|
|
1556
|
-
}
|
|
1557
|
-
function hostedWorkerMissingLeaseTokenFailure() {
|
|
1558
|
-
return {
|
|
1559
|
-
errorCode: 'RUNNER_LEASE_TOKEN_MISSING',
|
|
1560
|
-
failureClass: 'authorization_denied',
|
|
1561
|
-
summary: 'Hosted worker claim did not include a server-issued run lease token.',
|
|
1562
|
-
nextCheck: 'Re-pair the worker or upgrade the control plane to return run_lease.lease_token.',
|
|
1563
|
-
retrySafe: false,
|
|
1564
|
-
};
|
|
1565
|
-
}
|
|
1566
|
-
function workflowRunFailure(run) {
|
|
1567
|
-
return {
|
|
1568
|
-
errorCode: run.status === 'canceled' ? 'RUNNER_WORKFLOW_CANCELED' : 'RUNNER_WORKFLOW_FAILED',
|
|
1569
|
-
failureClass: run.status === 'canceled' ? 'canceled' : 'workflow_error',
|
|
1570
|
-
summary: run.error ?? `Workflow run ended with status ${run.status}.`,
|
|
1571
|
-
nextCheck: 'Inspect workflow node receipts and worker logs.',
|
|
1572
|
-
retrySafe: false,
|
|
1573
|
-
};
|
|
1574
|
-
}
|
|
1575
|
-
async function cleanupLeaseHttp(profile, lease) {
|
|
1576
|
-
if (isHostedManagedExecutorProfile(profile)) {
|
|
1577
|
-
return;
|
|
1578
|
-
}
|
|
1579
|
-
await workerRequest(profile, `workers/leases/${encodeURIComponent(lease.id)}/cleanup`, {
|
|
1580
|
-
lease_id: lease.id,
|
|
1581
|
-
run_id: lease.runId ?? null,
|
|
1582
|
-
status: 'cleanup_completed',
|
|
1583
|
-
runtime_event_id: `phase8-${lease.id}-cleanup`,
|
|
1584
|
-
});
|
|
1585
|
-
}
|
|
1586
|
-
async function workerRequest(profile, path, body) {
|
|
1587
|
-
await workerFetch(profile, path, body);
|
|
1588
|
-
}
|
|
1589
|
-
async function workerFetch(profile, path, body) {
|
|
1590
|
-
const requestPath = `/api/runtime/${path}`;
|
|
1591
|
-
const serialized = JSON.stringify(body);
|
|
1592
|
-
const signed = await signWorkerRequest(profile, 'POST', requestPath, serialized);
|
|
1593
|
-
const response = await transportFetch(`${profile.serverUrl.replace(/\/+$/, '')}${requestPath}`, {
|
|
1594
|
-
method: 'POST',
|
|
1595
|
-
headers: {
|
|
1596
|
-
'Content-Type': 'application/json',
|
|
1597
|
-
'X-Viewport-Worker-Fingerprint': profile.publicKeyFingerprint,
|
|
1598
|
-
'X-Viewport-Worker-Timestamp': signed.timestamp,
|
|
1599
|
-
'X-Viewport-Worker-Nonce': signed.nonce,
|
|
1600
|
-
'X-Viewport-Worker-Body-SHA256': signed.bodySha256,
|
|
1601
|
-
'X-Viewport-Worker-Signature': signed.signature,
|
|
1602
|
-
...(signed.serverId ? { 'X-Viewport-Server-Id': signed.serverId } : {}),
|
|
1603
|
-
},
|
|
1604
|
-
body: serialized,
|
|
1605
|
-
});
|
|
1606
|
-
if (!response.ok) {
|
|
1607
|
-
const text = await response.text().catch(() => '');
|
|
1608
|
-
throw new Error(`Worker runtime request ${path} failed with HTTP ${response.status}: ${text}`);
|
|
1609
|
-
}
|
|
1610
|
-
return response;
|
|
1611
|
-
}
|
|
1612
|
-
function isHostedManagedExecutorProfile(profile) {
|
|
1613
|
-
return Boolean(profile.workspaceId && profile.managedExecutorId && profile.credential);
|
|
1614
|
-
}
|
|
1615
|
-
function managedExecutorCapabilities(capabilities) {
|
|
1616
|
-
const { schema: _schema, ...normalized } = capabilities;
|
|
1617
|
-
const agents = capabilities['agents'];
|
|
1618
|
-
if (!Array.isArray(agents))
|
|
1619
|
-
return normalized;
|
|
1620
|
-
const objectAgents = agents
|
|
1621
|
-
.filter((agent) => typeof agent === 'object' && agent !== null && !Array.isArray(agent))
|
|
1622
|
-
.map((agent) => {
|
|
1623
|
-
const record = agent;
|
|
1624
|
-
const id = stringValue(record['id']);
|
|
1625
|
-
return id ? [id, record] : null;
|
|
1626
|
-
})
|
|
1627
|
-
.filter((entry) => entry !== null);
|
|
1628
|
-
if (objectAgents.length === 0)
|
|
1629
|
-
return normalized;
|
|
1630
|
-
return {
|
|
1631
|
-
...normalized,
|
|
1632
|
-
agents: Object.fromEntries(objectAgents),
|
|
1633
|
-
};
|
|
1634
|
-
}
|
|
1635
|
-
async function hostedManagedExecutorFetch(profile, method, path, body, assignmentClaimToken, runLeaseToken, allowedStatuses = [], dispatcher) {
|
|
1636
|
-
if (!profile.workspaceId || !profile.managedExecutorId || !profile.credential) {
|
|
1637
|
-
throw new Error('Hosted managed executor profile is missing workspace, executor, or credential.');
|
|
1638
|
-
}
|
|
1639
|
-
const requestPath = `/api/runtime/workspaces/${encodeURIComponent(profile.workspaceId)}/managed-executors/${encodeURIComponent(profile.managedExecutorId)}/${path}`;
|
|
1640
|
-
const serialized = method === 'GET' ? '' : JSON.stringify(body);
|
|
1641
|
-
const url = `${profile.serverUrl.replace(/\/+$/, '')}${requestPath}`;
|
|
1642
|
-
let lastResponse = null;
|
|
1643
|
-
const maxAttempts = hostedManagedExecutorMaxAttempts();
|
|
1644
|
-
for (let attempt = 1; attempt <= maxAttempts; attempt += 1) {
|
|
1645
|
-
const signed = await signWorkerRequest(profile, method, requestPath, serialized);
|
|
1646
|
-
const headers = {
|
|
1647
|
-
Authorization: `Bearer ${profile.credential}`,
|
|
1648
|
-
Accept: 'application/json',
|
|
1649
|
-
'Content-Type': 'application/json',
|
|
1650
|
-
...(runLeaseToken
|
|
1651
|
-
? { 'X-Viewport-Run-Lease': runLeaseToken }
|
|
1652
|
-
: assignmentClaimToken
|
|
1653
|
-
? { 'X-Viewport-Assignment-Claim': assignmentClaimToken }
|
|
1654
|
-
: {}),
|
|
1655
|
-
'X-Viewport-Worker-Fingerprint': profile.publicKeyFingerprint,
|
|
1656
|
-
'X-Viewport-Worker-Timestamp': signed.timestamp,
|
|
1657
|
-
'X-Viewport-Worker-Nonce': signed.nonce,
|
|
1658
|
-
'X-Viewport-Worker-Body-SHA256': signed.bodySha256,
|
|
1659
|
-
'X-Viewport-Worker-Signature': signed.signature,
|
|
1660
|
-
...(signed.serverId ? { 'X-Viewport-Server-Id': signed.serverId } : {}),
|
|
1661
|
-
};
|
|
1662
|
-
const request = {
|
|
1663
|
-
method,
|
|
1664
|
-
path,
|
|
1665
|
-
requestPath,
|
|
1666
|
-
url,
|
|
1667
|
-
serialized,
|
|
1668
|
-
headers,
|
|
1669
|
-
};
|
|
1670
|
-
const response = dispatcher
|
|
1671
|
-
? await dispatcher(request)
|
|
1672
|
-
: await transportFetch(url, {
|
|
1673
|
-
method,
|
|
1674
|
-
headers,
|
|
1675
|
-
...(method === 'GET' ? {} : { body: serialized }),
|
|
1676
|
-
});
|
|
1677
|
-
if (response.ok || allowedStatuses.includes(response.status)) {
|
|
1678
|
-
return response;
|
|
1679
|
-
}
|
|
1680
|
-
lastResponse = response;
|
|
1681
|
-
if (!isHostedManagedExecutorTransientStatus(response.status) || attempt === maxAttempts) {
|
|
1682
|
-
break;
|
|
1683
|
-
}
|
|
1684
|
-
await response.text().catch(() => '');
|
|
1685
|
-
await sleep(hostedManagedExecutorRetryDelayMs(response, attempt));
|
|
1686
|
-
}
|
|
1687
|
-
const response = lastResponse;
|
|
1688
|
-
if (!response) {
|
|
1689
|
-
throw new Error(`Hosted managed executor request ${path} failed before dispatch.`);
|
|
1690
|
-
}
|
|
1691
|
-
if (!response.ok) {
|
|
1692
|
-
const text = await response.text().catch(() => '');
|
|
1693
|
-
throw new Error(`Hosted managed executor request ${path} failed with HTTP ${response.status}: ${text}`);
|
|
1694
|
-
}
|
|
1695
|
-
return response;
|
|
1696
|
-
}
|
|
1697
|
-
function hostedManagedExecutorMaxAttempts() {
|
|
1698
|
-
return 4;
|
|
1699
|
-
}
|
|
1700
|
-
function isHostedManagedExecutorTransientStatus(status) {
|
|
1701
|
-
return status === 429 || status === 500 || status === 502 || status === 503 || status === 504;
|
|
1702
|
-
}
|
|
1703
|
-
function hostedManagedExecutorRetryDelayMs(response, attempt) {
|
|
1704
|
-
if (response.status === 429) {
|
|
1705
|
-
return retryAfterMs(response);
|
|
1706
|
-
}
|
|
1707
|
-
return Math.min(500 * 2 ** (attempt - 1), 5_000);
|
|
1708
|
-
}
|
|
1709
|
-
function retryAfterMs(response) {
|
|
1710
|
-
const raw = response.headers.get('retry-after');
|
|
1711
|
-
const seconds = raw ? Number.parseInt(raw, 10) : NaN;
|
|
1712
|
-
if (Number.isFinite(seconds) && seconds > 0) {
|
|
1713
|
-
return Math.min(seconds * 1_000, 30_000);
|
|
1714
|
-
}
|
|
1715
|
-
return 5_000;
|
|
1716
|
-
}
|
|
1717
|
-
function relayWorkerConnectionTimeoutMs() {
|
|
1718
|
-
return positiveIntegerFromEnv('VIEWPORT_RELAY_WORKER_CONNECT_TIMEOUT_MS') ?? 10_000;
|
|
1719
|
-
}
|
|
1720
|
-
function relayWorkerRequestTimeoutMs() {
|
|
1721
|
-
return positiveIntegerFromEnv('VIEWPORT_RELAY_WORKER_REQUEST_TIMEOUT_MS') ?? 60_000;
|
|
1722
|
-
}
|
|
1723
|
-
function positiveIntegerFromEnv(name) {
|
|
1724
|
-
const value = process.env[name];
|
|
1725
|
-
if (!value)
|
|
1726
|
-
return undefined;
|
|
1727
|
-
const parsed = Number.parseInt(value, 10);
|
|
1728
|
-
return Number.isInteger(parsed) && parsed > 0 ? parsed : undefined;
|
|
1729
|
-
}
|
|
1730
|
-
function relayWsBaseUrlFromServerUrl(serverUrl) {
|
|
1731
|
-
const parsed = new URL(serverUrl);
|
|
1732
|
-
const protocol = parsed.protocol === 'https:' ? 'wss:' : 'ws:';
|
|
1733
|
-
const hostname = parsed.hostname.startsWith('api.')
|
|
1734
|
-
? `relay.${parsed.hostname.slice(4)}`
|
|
1735
|
-
: parsed.hostname;
|
|
1736
|
-
return `${protocol}//${hostname}${parsed.port ? `:${parsed.port}` : ''}/ws`;
|
|
1737
|
-
}
|
|
1738
|
-
function sleep(ms) {
|
|
1739
|
-
return new Promise((resolve) => setTimeout(resolve, ms));
|
|
1740
|
-
}
|
|
1741
|
-
function sleepWithAbort(ms, signal) {
|
|
1742
|
-
if (!signal)
|
|
1743
|
-
return sleep(ms);
|
|
1744
|
-
if (signal.aborted)
|
|
1745
|
-
return Promise.resolve();
|
|
1746
|
-
return new Promise((resolve) => {
|
|
1747
|
-
const timeout = setTimeout(done, ms);
|
|
1748
|
-
signal.addEventListener('abort', done, { once: true });
|
|
1749
|
-
function done() {
|
|
1750
|
-
clearTimeout(timeout);
|
|
1751
|
-
signal?.removeEventListener('abort', done);
|
|
1752
|
-
resolve();
|
|
1753
|
-
}
|
|
1754
|
-
});
|
|
1755
|
-
}
|
|
1756
|
-
function stringValue(value) {
|
|
1757
|
-
return typeof value === 'string' && value.trim() !== '' ? value : undefined;
|
|
1758
|
-
}
|
|
1759
|
-
function positiveInteger(value) {
|
|
1760
|
-
if (typeof value !== 'number' || !Number.isInteger(value) || value <= 0) {
|
|
1761
|
-
return undefined;
|
|
1762
|
-
}
|
|
1763
|
-
return value;
|
|
1764
|
-
}
|
|
1765
|
-
function recordValue(value) {
|
|
1766
|
-
if (!value || typeof value !== 'object' || Array.isArray(value))
|
|
1767
|
-
return undefined;
|
|
1768
|
-
return value;
|
|
1769
|
-
}
|
|
1770
|
-
function arrayOfStrings(value) {
|
|
1771
|
-
return Array.isArray(value)
|
|
1772
|
-
? value.filter((item) => typeof item === 'string' && item.trim() !== '')
|
|
1773
|
-
: [];
|
|
1774
|
-
}
|
|
1775
|
-
function isRecord(value) {
|
|
1776
|
-
return Boolean(value && typeof value === 'object' && !Array.isArray(value));
|
|
1777
|
-
}
|
|
1778
|
-
function asRecord(value) {
|
|
1779
|
-
return isRecord(value) ? value : {};
|
|
1780
|
-
}
|
|
1781
|
-
function pathValue(value, pathParts) {
|
|
1782
|
-
let current = value;
|
|
1783
|
-
for (const part of pathParts) {
|
|
1784
|
-
if (!isRecord(current))
|
|
1785
|
-
return undefined;
|
|
1786
|
-
current = current[part];
|
|
1787
|
-
}
|
|
1788
|
-
return current;
|
|
1789
|
-
}
|
|
1790
|
-
function dataCapturePolicyValue(value) {
|
|
1791
|
-
const record = recordValue(value);
|
|
1792
|
-
if (!record)
|
|
1793
|
-
return undefined;
|
|
1794
|
-
const transcripts = record['transcripts'];
|
|
1795
|
-
const logs = record['logs'];
|
|
1796
|
-
const artifacts = record['artifacts'];
|
|
1797
|
-
if ((transcripts === 'none' || transcripts === 'excerpt') &&
|
|
1798
|
-
(logs === 'metadata' || logs === 'content') &&
|
|
1799
|
-
(artifacts === 'metadata' || artifacts === 'local_reference')) {
|
|
1800
|
-
return { transcripts, logs, artifacts };
|
|
1801
|
-
}
|
|
1802
|
-
return undefined;
|
|
1803
|
-
}
|
|
1804
|
-
async function signWorkerRequest(profile, method, requestPath, body) {
|
|
1805
|
-
const identity = JSON.parse(await fs.readFile(profile.identityKeyPath, 'utf8'));
|
|
1806
|
-
if (identity.publicKeyFingerprint !== profile.publicKeyFingerprint) {
|
|
1807
|
-
throw new Error('Worker identity fingerprint does not match worker profile.');
|
|
1808
|
-
}
|
|
1809
|
-
const timestamp = new Date().toISOString();
|
|
1810
|
-
const nonce = crypto.randomBytes(16).toString('hex');
|
|
1811
|
-
const bodySha256 = crypto.createHash('sha256').update(body).digest('hex');
|
|
1812
|
-
const canonical = [
|
|
1813
|
-
method.toUpperCase(),
|
|
1814
|
-
requestPath,
|
|
1815
|
-
bodySha256,
|
|
1816
|
-
nonce,
|
|
1817
|
-
timestamp,
|
|
1818
|
-
...(profile.serverId ? [profile.serverId] : []),
|
|
1819
|
-
].join('\n');
|
|
1820
|
-
const signature = crypto
|
|
1821
|
-
.sign(null, Buffer.from(canonical), identity.privateKey)
|
|
1822
|
-
.toString('base64');
|
|
1823
|
-
return { timestamp, nonce, bodySha256, signature, serverId: profile.serverId };
|
|
1824
|
-
}
|
|
1825
|
-
//# sourceMappingURL=worker-runtime.js.map
|