@the-open-engine/zeroshot 6.30.2 → 6.31.1
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/cli/index.js +1 -2
- package/lib/agent-cli-provider/adapters/acp.d.ts.map +1 -1
- package/lib/agent-cli-provider/adapters/acp.js +7 -11
- package/lib/agent-cli-provider/adapters/acp.js.map +1 -1
- package/lib/agent-cli-provider/adapters/omp-policy.d.ts +4 -0
- package/lib/agent-cli-provider/adapters/omp-policy.d.ts.map +1 -0
- package/lib/agent-cli-provider/adapters/omp-policy.js +47 -0
- package/lib/agent-cli-provider/adapters/omp-policy.js.map +1 -0
- package/lib/agent-cli-provider/adapters/omp.d.ts.map +1 -1
- package/lib/agent-cli-provider/adapters/omp.js +8 -158
- package/lib/agent-cli-provider/adapters/omp.js.map +1 -1
- package/lib/agent-cli-provider/adapters/pi.d.ts.map +1 -1
- package/lib/agent-cli-provider/adapters/pi.js +12 -124
- package/lib/agent-cli-provider/adapters/pi.js.map +1 -1
- package/lib/agent-cli-provider/assistant-stream.d.ts +27 -0
- package/lib/agent-cli-provider/assistant-stream.d.ts.map +1 -0
- package/lib/agent-cli-provider/assistant-stream.js +119 -0
- package/lib/agent-cli-provider/assistant-stream.js.map +1 -0
- package/lib/agent-cli-provider/contract-actions.d.ts.map +1 -1
- package/lib/agent-cli-provider/contract-actions.js +42 -1
- package/lib/agent-cli-provider/contract-actions.js.map +1 -1
- package/lib/agent-cli-provider/contract-invoke.d.ts.map +1 -1
- package/lib/agent-cli-provider/contract-invoke.js +68 -38
- package/lib/agent-cli-provider/contract-invoke.js.map +1 -1
- package/lib/agent-cli-provider/contract-support.d.ts +5 -6
- package/lib/agent-cli-provider/contract-support.d.ts.map +1 -1
- package/lib/agent-cli-provider/contract-support.js +99 -6
- package/lib/agent-cli-provider/contract-support.js.map +1 -1
- package/lib/agent-cli-provider/index.d.ts +8 -6
- package/lib/agent-cli-provider/index.d.ts.map +1 -1
- package/lib/agent-cli-provider/index.js +34 -10
- package/lib/agent-cli-provider/index.js.map +1 -1
- package/lib/agent-cli-provider/omp/auth-policy.d.ts +31 -0
- package/lib/agent-cli-provider/omp/auth-policy.d.ts.map +1 -0
- package/lib/agent-cli-provider/omp/auth-policy.js +98 -0
- package/lib/agent-cli-provider/omp/auth-policy.js.map +1 -0
- package/lib/agent-cli-provider/{omp-release.d.ts → omp/release.d.ts} +1 -1
- package/lib/agent-cli-provider/omp/release.d.ts.map +1 -0
- package/lib/agent-cli-provider/{omp-release.js → omp/release.js} +1 -1
- package/lib/agent-cli-provider/omp/release.js.map +1 -0
- package/lib/agent-cli-provider/{omp-rpc-bounds.d.ts → omp/rpc-bounds.d.ts} +1 -1
- package/lib/agent-cli-provider/omp/rpc-bounds.d.ts.map +1 -0
- package/lib/agent-cli-provider/{omp-rpc-bounds.js → omp/rpc-bounds.js} +1 -1
- package/lib/agent-cli-provider/omp/rpc-bounds.js.map +1 -0
- package/lib/agent-cli-provider/omp/rpc-driver-channel.d.ts +19 -0
- package/lib/agent-cli-provider/omp/rpc-driver-channel.d.ts.map +1 -0
- package/lib/agent-cli-provider/omp/rpc-driver-channel.js +109 -0
- package/lib/agent-cli-provider/omp/rpc-driver-channel.js.map +1 -0
- package/lib/agent-cli-provider/omp/rpc-driver-dispatch.d.ts +27 -0
- package/lib/agent-cli-provider/omp/rpc-driver-dispatch.d.ts.map +1 -0
- package/lib/agent-cli-provider/omp/rpc-driver-dispatch.js +135 -0
- package/lib/agent-cli-provider/omp/rpc-driver-dispatch.js.map +1 -0
- package/lib/agent-cli-provider/omp/rpc-driver-runner.d.ts +3 -0
- package/lib/agent-cli-provider/omp/rpc-driver-runner.d.ts.map +1 -0
- package/lib/agent-cli-provider/omp/rpc-driver-runner.js +205 -0
- package/lib/agent-cli-provider/omp/rpc-driver-runner.js.map +1 -0
- package/lib/agent-cli-provider/omp/rpc-driver-state.d.ts +80 -0
- package/lib/agent-cli-provider/omp/rpc-driver-state.d.ts.map +1 -0
- package/lib/agent-cli-provider/omp/rpc-driver-state.js +86 -0
- package/lib/agent-cli-provider/omp/rpc-driver-state.js.map +1 -0
- package/lib/agent-cli-provider/omp/rpc-driver.d.ts +3 -0
- package/lib/agent-cli-provider/omp/rpc-driver.d.ts.map +1 -0
- package/lib/agent-cli-provider/omp/rpc-driver.js +6 -0
- package/lib/agent-cli-provider/omp/rpc-driver.js.map +1 -0
- package/lib/agent-cli-provider/omp/rpc-event-lines.d.ts +8 -0
- package/lib/agent-cli-provider/omp/rpc-event-lines.d.ts.map +1 -0
- package/lib/agent-cli-provider/omp/rpc-event-lines.js +59 -0
- package/lib/agent-cli-provider/omp/rpc-event-lines.js.map +1 -0
- package/lib/agent-cli-provider/omp/rpc-events.d.ts +16 -0
- package/lib/agent-cli-provider/omp/rpc-events.d.ts.map +1 -0
- package/lib/agent-cli-provider/omp/rpc-events.js +115 -0
- package/lib/agent-cli-provider/omp/rpc-events.js.map +1 -0
- package/lib/agent-cli-provider/{omp-rpc-protocol.d.ts → omp/rpc-protocol-contract.d.ts} +1 -13
- package/lib/agent-cli-provider/omp/rpc-protocol-contract.d.ts.map +1 -0
- package/lib/agent-cli-provider/omp/rpc-protocol-contract.js +54 -0
- package/lib/agent-cli-provider/omp/rpc-protocol-contract.js.map +1 -0
- package/lib/agent-cli-provider/omp/rpc-protocol.d.ts +15 -0
- package/lib/agent-cli-provider/omp/rpc-protocol.d.ts.map +1 -0
- package/lib/agent-cli-provider/omp/rpc-protocol.js +208 -0
- package/lib/agent-cli-provider/omp/rpc-protocol.js.map +1 -0
- package/lib/agent-cli-provider/{omp-rpc-session.d.ts → omp/rpc-session.d.ts} +1 -1
- package/lib/agent-cli-provider/omp/rpc-session.d.ts.map +1 -0
- package/lib/agent-cli-provider/{omp-rpc-session.js → omp/rpc-session.js} +1 -1
- package/lib/agent-cli-provider/omp/rpc-session.js.map +1 -0
- package/lib/agent-cli-provider/omp/sdk-contract.d.ts +34 -0
- package/lib/agent-cli-provider/omp/sdk-contract.d.ts.map +1 -0
- package/lib/agent-cli-provider/omp/sdk-contract.js +81 -0
- package/lib/agent-cli-provider/omp/sdk-contract.js.map +1 -0
- package/lib/agent-cli-provider/omp/sdk-process-credentials.d.ts +6 -0
- package/lib/agent-cli-provider/omp/sdk-process-credentials.d.ts.map +1 -0
- package/lib/agent-cli-provider/omp/sdk-process-credentials.js +44 -0
- package/lib/agent-cli-provider/omp/sdk-process-credentials.js.map +1 -0
- package/lib/agent-cli-provider/omp/sdk-process-error.d.ts +5 -0
- package/lib/agent-cli-provider/omp/sdk-process-error.d.ts.map +1 -0
- package/lib/agent-cli-provider/omp/sdk-process-error.js +13 -0
- package/lib/agent-cli-provider/omp/sdk-process-error.js.map +1 -0
- package/lib/agent-cli-provider/omp/sdk-process-io.d.ts +18 -0
- package/lib/agent-cli-provider/omp/sdk-process-io.d.ts.map +1 -0
- package/lib/agent-cli-provider/omp/sdk-process-io.js +80 -0
- package/lib/agent-cli-provider/omp/sdk-process-io.js.map +1 -0
- package/lib/agent-cli-provider/omp/sdk-process-private-runtime.d.ts +51 -0
- package/lib/agent-cli-provider/omp/sdk-process-private-runtime.d.ts.map +1 -0
- package/lib/agent-cli-provider/omp/sdk-process-private-runtime.js +154 -0
- package/lib/agent-cli-provider/omp/sdk-process-private-runtime.js.map +1 -0
- package/lib/agent-cli-provider/omp/sdk-process-result.d.ts +26 -0
- package/lib/agent-cli-provider/omp/sdk-process-result.d.ts.map +1 -0
- package/lib/agent-cli-provider/omp/sdk-process-result.js +117 -0
- package/lib/agent-cli-provider/omp/sdk-process-result.js.map +1 -0
- package/lib/agent-cli-provider/omp/sdk-process-runner.d.ts +7 -0
- package/lib/agent-cli-provider/omp/sdk-process-runner.d.ts.map +1 -0
- package/lib/agent-cli-provider/omp/sdk-process-runner.js +204 -0
- package/lib/agent-cli-provider/omp/sdk-process-runner.js.map +1 -0
- package/lib/agent-cli-provider/omp/sdk-protocol-collector.d.ts +3 -0
- package/lib/agent-cli-provider/omp/sdk-protocol-collector.d.ts.map +1 -0
- package/lib/agent-cli-provider/omp/sdk-protocol-collector.js +145 -0
- package/lib/agent-cli-provider/omp/sdk-protocol-collector.js.map +1 -0
- package/lib/agent-cli-provider/omp/sdk-protocol-frame.d.ts +4 -0
- package/lib/agent-cli-provider/omp/sdk-protocol-frame.d.ts.map +1 -0
- package/lib/agent-cli-provider/omp/sdk-protocol-frame.js +183 -0
- package/lib/agent-cli-provider/omp/sdk-protocol-frame.js.map +1 -0
- package/lib/agent-cli-provider/omp/sdk-protocol-request.d.ts +8 -0
- package/lib/agent-cli-provider/omp/sdk-protocol-request.d.ts.map +1 -0
- package/lib/agent-cli-provider/omp/sdk-protocol-request.js +170 -0
- package/lib/agent-cli-provider/omp/sdk-protocol-request.js.map +1 -0
- package/lib/agent-cli-provider/omp/sdk-protocol-result.d.ts +5 -0
- package/lib/agent-cli-provider/omp/sdk-protocol-result.d.ts.map +1 -0
- package/lib/agent-cli-provider/omp/sdk-protocol-result.js +74 -0
- package/lib/agent-cli-provider/omp/sdk-protocol-result.js.map +1 -0
- package/lib/agent-cli-provider/omp/sdk-protocol-types.d.ts +94 -0
- package/lib/agent-cli-provider/omp/sdk-protocol-types.d.ts.map +1 -0
- package/lib/agent-cli-provider/omp/sdk-protocol-types.js +54 -0
- package/lib/agent-cli-provider/omp/sdk-protocol-types.js.map +1 -0
- package/lib/agent-cli-provider/omp/sdk-protocol-value.d.ts +18 -0
- package/lib/agent-cli-provider/omp/sdk-protocol-value.d.ts.map +1 -0
- package/lib/agent-cli-provider/omp/sdk-protocol-value.js +229 -0
- package/lib/agent-cli-provider/omp/sdk-protocol-value.js.map +1 -0
- package/lib/agent-cli-provider/omp/sdk-protocol.d.ts +7 -0
- package/lib/agent-cli-provider/omp/sdk-protocol.d.ts.map +1 -0
- package/lib/agent-cli-provider/omp/sdk-protocol.js +28 -0
- package/lib/agent-cli-provider/omp/sdk-protocol.js.map +1 -0
- package/lib/agent-cli-provider/omp/sdk-runtime.d.ts +29 -0
- package/lib/agent-cli-provider/omp/sdk-runtime.d.ts.map +1 -0
- package/lib/agent-cli-provider/omp/sdk-runtime.js +110 -0
- package/lib/agent-cli-provider/omp/sdk-runtime.js.map +1 -0
- package/lib/agent-cli-provider/omp/sdk-settings-auth.d.ts +3 -0
- package/lib/agent-cli-provider/omp/sdk-settings-auth.d.ts.map +1 -0
- package/lib/agent-cli-provider/omp/sdk-settings-auth.js +86 -0
- package/lib/agent-cli-provider/omp/sdk-settings-auth.js.map +1 -0
- package/lib/agent-cli-provider/omp/sdk-settings-constants.d.ts +26 -0
- package/lib/agent-cli-provider/omp/sdk-settings-constants.d.ts.map +1 -0
- package/lib/agent-cli-provider/omp/sdk-settings-constants.js +148 -0
- package/lib/agent-cli-provider/omp/sdk-settings-constants.js.map +1 -0
- package/lib/agent-cli-provider/omp/sdk-settings-model-fields.d.ts +5 -0
- package/lib/agent-cli-provider/omp/sdk-settings-model-fields.d.ts.map +1 -0
- package/lib/agent-cli-provider/omp/sdk-settings-model-fields.js +198 -0
- package/lib/agent-cli-provider/omp/sdk-settings-model-fields.js.map +1 -0
- package/lib/agent-cli-provider/omp/sdk-settings-model.d.ts +4 -0
- package/lib/agent-cli-provider/omp/sdk-settings-model.d.ts.map +1 -0
- package/lib/agent-cli-provider/omp/sdk-settings-model.js +163 -0
- package/lib/agent-cli-provider/omp/sdk-settings-model.js.map +1 -0
- package/lib/agent-cli-provider/omp/sdk-settings-normalize.d.ts +18 -0
- package/lib/agent-cli-provider/omp/sdk-settings-normalize.d.ts.map +1 -0
- package/lib/agent-cli-provider/omp/sdk-settings-normalize.js +148 -0
- package/lib/agent-cli-provider/omp/sdk-settings-normalize.js.map +1 -0
- package/lib/agent-cli-provider/omp/sdk-settings-selector.d.ts +3 -0
- package/lib/agent-cli-provider/omp/sdk-settings-selector.d.ts.map +1 -0
- package/lib/agent-cli-provider/omp/sdk-settings-selector.js +22 -0
- package/lib/agent-cli-provider/omp/sdk-settings-selector.js.map +1 -0
- package/lib/agent-cli-provider/omp/sdk-settings-types.d.ts +68 -0
- package/lib/agent-cli-provider/omp/sdk-settings-types.d.ts.map +1 -0
- package/lib/agent-cli-provider/omp/sdk-settings-types.js +19 -0
- package/lib/agent-cli-provider/omp/sdk-settings-types.js.map +1 -0
- package/lib/agent-cli-provider/omp/sdk-settings-values.d.ts +14 -0
- package/lib/agent-cli-provider/omp/sdk-settings-values.d.ts.map +1 -0
- package/lib/agent-cli-provider/omp/sdk-settings-values.js +112 -0
- package/lib/agent-cli-provider/omp/sdk-settings-values.js.map +1 -0
- package/lib/agent-cli-provider/omp/sdk-settings.d.ts +5 -0
- package/lib/agent-cli-provider/omp/sdk-settings.d.ts.map +1 -0
- package/lib/agent-cli-provider/omp/sdk-settings.js +16 -0
- package/lib/agent-cli-provider/omp/sdk-settings.js.map +1 -0
- package/lib/agent-cli-provider/omp/sdk-sidecar-context.d.ts +11 -0
- package/lib/agent-cli-provider/omp/sdk-sidecar-context.d.ts.map +1 -0
- package/lib/agent-cli-provider/omp/sdk-sidecar-context.js +171 -0
- package/lib/agent-cli-provider/omp/sdk-sidecar-context.js.map +1 -0
- package/lib/agent-cli-provider/omp/sdk-sidecar-credentials.d.ts +5 -0
- package/lib/agent-cli-provider/omp/sdk-sidecar-credentials.d.ts.map +1 -0
- package/lib/agent-cli-provider/omp/sdk-sidecar-credentials.js +94 -0
- package/lib/agent-cli-provider/omp/sdk-sidecar-credentials.js.map +1 -0
- package/lib/agent-cli-provider/omp/sdk-sidecar-execute.d.ts +5 -0
- package/lib/agent-cli-provider/omp/sdk-sidecar-execute.d.ts.map +1 -0
- package/lib/agent-cli-provider/omp/sdk-sidecar-execute.js +175 -0
- package/lib/agent-cli-provider/omp/sdk-sidecar-execute.js.map +1 -0
- package/lib/agent-cli-provider/omp/sdk-sidecar-output.d.ts +5 -0
- package/lib/agent-cli-provider/omp/sdk-sidecar-output.d.ts.map +1 -0
- package/lib/agent-cli-provider/omp/sdk-sidecar-output.js +216 -0
- package/lib/agent-cli-provider/omp/sdk-sidecar-output.js.map +1 -0
- package/lib/agent-cli-provider/omp/sdk-sidecar-runtime.d.ts +11 -0
- package/lib/agent-cli-provider/omp/sdk-sidecar-runtime.d.ts.map +1 -0
- package/lib/agent-cli-provider/omp/sdk-sidecar-runtime.js +265 -0
- package/lib/agent-cli-provider/omp/sdk-sidecar-runtime.js.map +1 -0
- package/lib/agent-cli-provider/omp/sdk-sidecar-types.d.ts +148 -0
- package/lib/agent-cli-provider/omp/sdk-sidecar-types.d.ts.map +1 -0
- package/lib/agent-cli-provider/omp/sdk-sidecar-types.js +84 -0
- package/lib/agent-cli-provider/omp/sdk-sidecar-types.js.map +1 -0
- package/lib/agent-cli-provider/omp/sdk-sidecar.d.ts +4 -0
- package/lib/agent-cli-provider/omp/sdk-sidecar.d.ts.map +1 -0
- package/lib/agent-cli-provider/omp/sdk-sidecar.js +9 -0
- package/lib/agent-cli-provider/omp/sdk-sidecar.js.map +1 -0
- package/lib/agent-cli-provider/process-runner.d.ts +1 -0
- package/lib/agent-cli-provider/process-runner.d.ts.map +1 -1
- package/lib/agent-cli-provider/process-runner.js +19 -6
- package/lib/agent-cli-provider/process-runner.js.map +1 -1
- package/lib/agent-cli-provider/provider-registry.d.ts +18 -4
- package/lib/agent-cli-provider/provider-registry.d.ts.map +1 -1
- package/lib/agent-cli-provider/provider-registry.js +21 -7
- package/lib/agent-cli-provider/provider-registry.js.map +1 -1
- package/lib/agent-cli-provider/single-agent-runtime.d.ts +10 -1
- package/lib/agent-cli-provider/single-agent-runtime.d.ts.map +1 -1
- package/lib/agent-cli-provider/single-agent-runtime.js +378 -11
- package/lib/agent-cli-provider/single-agent-runtime.js.map +1 -1
- package/lib/agent-cli-provider/types.d.ts +110 -2
- package/lib/agent-cli-provider/types.d.ts.map +1 -1
- package/lib/agent-cli-provider/types.js.map +1 -1
- package/npm-shrinkwrap.json +18116 -0
- package/package.json +16 -3
- package/scripts/omp/bun-ffi.d.ts +28 -0
- package/scripts/omp/host-supervisor-cleanup.ts +100 -0
- package/scripts/omp/host-supervisor-launch.ts +38 -0
- package/scripts/omp/host-supervisor-native.ts +181 -0
- package/scripts/omp/host-supervisor-tracker.ts +258 -0
- package/scripts/omp/host-supervisor.ts +298 -0
- package/scripts/omp/promise-gate.ts +13 -0
- package/scripts/omp/runtime-identities.js +283 -0
- package/scripts/omp/runtime-lock.js +232 -0
- package/scripts/omp/runtime-release.js +105 -0
- package/scripts/omp/runtime.js +33 -0
- package/scripts/omp/sidecar.ts +124 -0
- package/scripts/opcore-introduced-check.js +5 -0
- package/scripts/release-preflight.js +19 -0
- package/src/agent-cli-provider/adapters/acp.ts +18 -17
- package/src/agent-cli-provider/adapters/omp-policy.ts +45 -0
- package/src/agent-cli-provider/adapters/omp.ts +9 -155
- package/src/agent-cli-provider/adapters/pi.ts +15 -145
- package/src/agent-cli-provider/assistant-stream.ts +155 -0
- package/src/agent-cli-provider/contract-actions.ts +14 -2
- package/src/agent-cli-provider/contract-invoke.ts +77 -40
- package/src/agent-cli-provider/contract-support.ts +83 -12
- package/src/agent-cli-provider/index.ts +60 -5
- package/src/agent-cli-provider/omp/auth-policy.ts +126 -0
- package/src/agent-cli-provider/omp/rpc-driver-channel.ts +144 -0
- package/src/agent-cli-provider/omp/rpc-driver-dispatch.ts +177 -0
- package/src/agent-cli-provider/omp/rpc-driver-runner.ts +199 -0
- package/src/agent-cli-provider/omp/rpc-driver-state.ts +165 -0
- package/src/agent-cli-provider/omp/rpc-driver.ts +8 -0
- package/src/agent-cli-provider/omp/rpc-event-lines.ts +58 -0
- package/src/agent-cli-provider/omp/rpc-events.ts +154 -0
- package/src/agent-cli-provider/omp/rpc-protocol-contract.ts +77 -0
- package/src/agent-cli-provider/{omp-rpc-protocol.ts → omp/rpc-protocol.ts} +9 -111
- package/src/agent-cli-provider/omp/sdk-contract.ts +123 -0
- package/src/agent-cli-provider/omp/sdk-process-credentials.ts +55 -0
- package/src/agent-cli-provider/omp/sdk-process-error.ts +9 -0
- package/src/agent-cli-provider/omp/sdk-process-io.ts +92 -0
- package/src/agent-cli-provider/omp/sdk-process-private-runtime.ts +249 -0
- package/src/agent-cli-provider/omp/sdk-process-result.ts +181 -0
- package/src/agent-cli-provider/omp/sdk-process-runner.ts +281 -0
- package/src/agent-cli-provider/omp/sdk-protocol-collector.ts +140 -0
- package/src/agent-cli-provider/omp/sdk-protocol-frame.ts +260 -0
- package/src/agent-cli-provider/omp/sdk-protocol-request.ts +181 -0
- package/src/agent-cli-provider/omp/sdk-protocol-result.ts +80 -0
- package/src/agent-cli-provider/omp/sdk-protocol-types.ts +156 -0
- package/src/agent-cli-provider/omp/sdk-protocol-value.ts +234 -0
- package/src/agent-cli-provider/omp/sdk-protocol.ts +46 -0
- package/src/agent-cli-provider/omp/sdk-runtime.ts +159 -0
- package/src/agent-cli-provider/omp/sdk-settings-auth.ts +78 -0
- package/src/agent-cli-provider/omp/sdk-settings-constants.ts +147 -0
- package/src/agent-cli-provider/omp/sdk-settings-model-fields.ts +233 -0
- package/src/agent-cli-provider/omp/sdk-settings-model.ts +238 -0
- package/src/agent-cli-provider/omp/sdk-settings-normalize.ts +242 -0
- package/src/agent-cli-provider/omp/sdk-settings-selector.ts +28 -0
- package/src/agent-cli-provider/omp/sdk-settings-types.ts +88 -0
- package/src/agent-cli-provider/omp/sdk-settings-values.ts +118 -0
- package/src/agent-cli-provider/omp/sdk-settings.ts +33 -0
- package/src/agent-cli-provider/omp/sdk-sidecar-context.ts +199 -0
- package/src/agent-cli-provider/omp/sdk-sidecar-credentials.ts +100 -0
- package/src/agent-cli-provider/omp/sdk-sidecar-execute.ts +201 -0
- package/src/agent-cli-provider/omp/sdk-sidecar-output.ts +235 -0
- package/src/agent-cli-provider/omp/sdk-sidecar-runtime.ts +244 -0
- package/src/agent-cli-provider/omp/sdk-sidecar-types.ts +173 -0
- package/src/agent-cli-provider/omp/sdk-sidecar.ts +3 -0
- package/src/agent-cli-provider/process-runner.ts +22 -8
- package/src/agent-cli-provider/provider-registry.ts +29 -10
- package/src/agent-cli-provider/single-agent-runtime.ts +444 -18
- package/src/agent-cli-provider/types.ts +131 -3
- package/src/command-cleanup-ownership.js +15 -0
- package/task-lib/omp-sdk-runtime.js +8 -0
- package/task-lib/runner.js +121 -40
- package/task-lib/sdk-watcher.js +154 -0
- package/cli/lib/first-run.js +0 -223
- package/lib/agent-cli-provider/omp-release.d.ts.map +0 -1
- package/lib/agent-cli-provider/omp-release.js.map +0 -1
- package/lib/agent-cli-provider/omp-rpc-bounds.d.ts.map +0 -1
- package/lib/agent-cli-provider/omp-rpc-bounds.js.map +0 -1
- package/lib/agent-cli-provider/omp-rpc-driver.d.ts +0 -40
- package/lib/agent-cli-provider/omp-rpc-driver.d.ts.map +0 -1
- package/lib/agent-cli-provider/omp-rpc-driver.js +0 -519
- package/lib/agent-cli-provider/omp-rpc-driver.js.map +0 -1
- package/lib/agent-cli-provider/omp-rpc-events.d.ts +0 -28
- package/lib/agent-cli-provider/omp-rpc-events.d.ts.map +0 -1
- package/lib/agent-cli-provider/omp-rpc-events.js +0 -264
- package/lib/agent-cli-provider/omp-rpc-events.js.map +0 -1
- package/lib/agent-cli-provider/omp-rpc-protocol.d.ts.map +0 -1
- package/lib/agent-cli-provider/omp-rpc-protocol.js +0 -272
- package/lib/agent-cli-provider/omp-rpc-protocol.js.map +0 -1
- package/lib/agent-cli-provider/omp-rpc-session.d.ts.map +0 -1
- package/lib/agent-cli-provider/omp-rpc-session.js.map +0 -1
- package/src/agent-cli-provider/omp-rpc-driver.ts +0 -639
- package/src/agent-cli-provider/omp-rpc-events.ts +0 -318
- /package/src/agent-cli-provider/{omp-release.ts → omp/release.ts} +0 -0
- /package/src/agent-cli-provider/{omp-rpc-bounds.ts → omp/rpc-bounds.ts} +0 -0
- /package/src/agent-cli-provider/{omp-rpc-session.ts → omp/rpc-session.ts} +0 -0
|
@@ -1,16 +1,21 @@
|
|
|
1
1
|
import { buildAcpPrompt } from './adapters/acp';
|
|
2
2
|
import { buildOmpPrompt } from './adapters/omp';
|
|
3
3
|
import { runAcpStdioPrompt } from './acp-stdio-runner';
|
|
4
|
-
import { runOmpRpcTask } from './omp
|
|
5
|
-
import { ABORT_GRACE_MS, EXIT_GRACE_MS } from './omp
|
|
6
|
-
import { OMP_SUPPORTED_VERSION } from './omp
|
|
4
|
+
import { runOmpRpcTask } from './omp/rpc-driver';
|
|
5
|
+
import { ABORT_GRACE_MS, EXIT_GRACE_MS } from './omp/rpc-bounds';
|
|
6
|
+
import { OMP_SUPPORTED_VERSION } from './omp/release';
|
|
7
7
|
import { commandRedactions } from './contract-env';
|
|
8
8
|
import { successEnvelope, type ContractEnvelope } from './contract-envelope';
|
|
9
9
|
import { buildCommandSpec, optionalNumber, schemaMode, type RequestData } from './contract-support';
|
|
10
10
|
import { providerFailureClassification } from './invoke-evidence';
|
|
11
11
|
import { parseOutputEvents } from './contract-parse';
|
|
12
12
|
import { isRecord, unknownToMessage } from './json';
|
|
13
|
-
import {
|
|
13
|
+
import {
|
|
14
|
+
invokeEvidence,
|
|
15
|
+
isContractOmpSdkProcessResult,
|
|
16
|
+
ompSdkFailureClassification,
|
|
17
|
+
} from './omp/sdk-contract';
|
|
18
|
+
import { runOmpSdkProcess } from './omp/sdk-process-runner';
|
|
14
19
|
import type { CommandSpec } from './types';
|
|
15
20
|
import type { ProcessResult, ProcessRunner, ProcessRunnerOptions } from './process-runner';
|
|
16
21
|
|
|
@@ -123,27 +128,66 @@ export async function runInvoke(
|
|
|
123
128
|
runner: ProcessRunner,
|
|
124
129
|
runtimeSettings?: Record<string, unknown>
|
|
125
130
|
): Promise<ContractEnvelope> {
|
|
126
|
-
const
|
|
131
|
+
const prepared = buildCommandSpec(request, runtimeSettings);
|
|
132
|
+
const { adapter, commandSpec, context, options } = prepared;
|
|
127
133
|
const timeoutMs = optionalNumber(request.raw, 'timeoutMs');
|
|
128
134
|
const runnerOptions = timeoutMs === undefined ? {} : { timeoutMs };
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
135
|
+
let result: ProcessResult;
|
|
136
|
+
let cleanup: readonly CleanupResult[];
|
|
137
|
+
if (prepared.invoke.parser === 'omp-sdk-ndjson') {
|
|
138
|
+
const privateArtifacts = prepared.privateArtifacts;
|
|
139
|
+
if (privateArtifacts === undefined) {
|
|
140
|
+
throw new Error('OMP SDK prepared invocation is missing private artifact ownership.');
|
|
141
|
+
}
|
|
142
|
+
const sdkResult = await runOmpSdkProcess(prepared, runnerOptions);
|
|
143
|
+
result = sdkResult;
|
|
144
|
+
cleanup = [
|
|
145
|
+
{
|
|
146
|
+
path: privateArtifacts.root,
|
|
147
|
+
removed: sdkResult.cleanupAttestation.clean,
|
|
148
|
+
},
|
|
149
|
+
];
|
|
150
|
+
} else {
|
|
151
|
+
let invokeRunner: ProcessRunner;
|
|
152
|
+
switch (prepared.invoke.lane) {
|
|
153
|
+
case 'spawn':
|
|
154
|
+
invokeRunner = runner;
|
|
155
|
+
break;
|
|
156
|
+
case 'acp-stdio':
|
|
157
|
+
invokeRunner = (
|
|
158
|
+
spec: CommandSpec,
|
|
159
|
+
invokeOptions?: ProcessRunnerOptions
|
|
160
|
+
): Promise<ProcessResult> =>
|
|
161
|
+
runAcpStdioPrompt(adapter.id, spec, buildAcpPrompt(context, options), invokeOptions);
|
|
162
|
+
break;
|
|
163
|
+
case 'rpc-stdio':
|
|
164
|
+
invokeRunner = (
|
|
165
|
+
spec: CommandSpec,
|
|
166
|
+
invokeOptions?: ProcessRunnerOptions
|
|
167
|
+
): Promise<ProcessResult> =>
|
|
168
|
+
runOmpRpcContractPrompt(spec, buildOmpPrompt(context, options), invokeOptions);
|
|
169
|
+
break;
|
|
170
|
+
}
|
|
171
|
+
({ result, cleanup } = await runAndCleanup(commandSpec, invokeRunner, runnerOptions));
|
|
172
|
+
}
|
|
173
|
+
const sdkResult = isContractOmpSdkProcessResult(result) ? result : null;
|
|
174
|
+
const parsed =
|
|
175
|
+
sdkResult === null
|
|
176
|
+
? parseOutputEvents(adapter, {
|
|
177
|
+
chunk: [result.stdout, result.stderr].join('\n'),
|
|
178
|
+
sources: [
|
|
179
|
+
{ name: 'stdout', value: result.stdout },
|
|
180
|
+
{ name: 'stderr', value: result.stderr },
|
|
181
|
+
],
|
|
182
|
+
})
|
|
183
|
+
: {
|
|
184
|
+
events: sdkResult.terminal.type === 'result' ? [sdkResult.terminal.event] : [],
|
|
185
|
+
diagnostics: [],
|
|
186
|
+
};
|
|
187
|
+
const classification =
|
|
188
|
+
sdkResult === null
|
|
189
|
+
? providerFailureClassification(adapter, result, parsed.events)
|
|
190
|
+
: ompSdkFailureClassification(sdkResult);
|
|
147
191
|
return successEnvelope({
|
|
148
192
|
command: request.command ?? 'invoke',
|
|
149
193
|
adapter,
|
|
@@ -154,10 +198,16 @@ export async function runInvoke(
|
|
|
154
198
|
commandSpec,
|
|
155
199
|
outputFormat: options.outputFormat ?? null,
|
|
156
200
|
schemaMode: schemaMode(options),
|
|
157
|
-
evidence:
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
201
|
+
evidence:
|
|
202
|
+
sdkResult === null
|
|
203
|
+
? { stdout: result.stdout, stderr: result.stderr }
|
|
204
|
+
: {
|
|
205
|
+
stdout: '',
|
|
206
|
+
stderr: sdkResult.diagnosticStderr,
|
|
207
|
+
terminal: sdkResult.terminal.frame,
|
|
208
|
+
progress: sdkResult.progress,
|
|
209
|
+
cleanupAttestation: sdkResult.cleanupAttestation,
|
|
210
|
+
},
|
|
161
211
|
events: parsed.events,
|
|
162
212
|
diagnostics: parsed.diagnostics,
|
|
163
213
|
exitCode: result.exitCode,
|
|
@@ -170,16 +220,3 @@ export async function runInvoke(
|
|
|
170
220
|
},
|
|
171
221
|
});
|
|
172
222
|
}
|
|
173
|
-
|
|
174
|
-
function invokeEvidence(
|
|
175
|
-
result: ProcessResult,
|
|
176
|
-
timeoutMs: number | undefined
|
|
177
|
-
): Record<string, unknown> {
|
|
178
|
-
return {
|
|
179
|
-
exitCode: result.exitCode,
|
|
180
|
-
signal: result.signal,
|
|
181
|
-
durationMs: result.durationMs,
|
|
182
|
-
timedOut: result.timedOut ?? false,
|
|
183
|
-
timeoutMs: result.timeoutMs ?? timeoutMs ?? null,
|
|
184
|
-
};
|
|
185
|
-
}
|
|
@@ -1,8 +1,13 @@
|
|
|
1
|
+
import * as fs from 'node:fs';
|
|
2
|
+
|
|
1
3
|
import { getProviderAdapter } from './adapters';
|
|
2
4
|
import { getString, isRecord, parseJson } from './json';
|
|
3
5
|
import { mergeRedactions } from './redaction';
|
|
4
6
|
import { requestOptions } from './contract-options';
|
|
5
|
-
import {
|
|
7
|
+
import {
|
|
8
|
+
prepareSingleAgentProviderCommand,
|
|
9
|
+
type PreparedSingleAgentProviderCommand,
|
|
10
|
+
} from './single-agent-runtime';
|
|
6
11
|
import type { BuildProviderCommandOptions, CommandSpec, ProviderAdapter } from './types';
|
|
7
12
|
export {
|
|
8
13
|
contractError,
|
|
@@ -90,19 +95,60 @@ function findReservedCommandEnvKey(
|
|
|
90
95
|
function buildOptions(request: RequestData): BuildProviderCommandOptions {
|
|
91
96
|
const options = requestOptions(request.raw.options);
|
|
92
97
|
const cwd = optionalString(request.raw, 'cwd');
|
|
93
|
-
|
|
94
|
-
|
|
98
|
+
const rawOptionExecutionContext = isRecord(request.raw.options)
|
|
99
|
+
? request.raw.options.executionContext
|
|
100
|
+
: undefined;
|
|
101
|
+
if (
|
|
102
|
+
rawOptionExecutionContext !== undefined &&
|
|
103
|
+
typeof rawOptionExecutionContext !== 'string'
|
|
104
|
+
) {
|
|
105
|
+
throw contractError({
|
|
106
|
+
code: 'invalid-field',
|
|
107
|
+
message:
|
|
108
|
+
'options.executionContext must be "host", "detached", "docker", or "benchmark".',
|
|
109
|
+
exitCode: 2,
|
|
110
|
+
field: 'options.executionContext',
|
|
111
|
+
});
|
|
112
|
+
}
|
|
113
|
+
const topLevelExecutionContext = optionalString(request.raw, 'executionContext');
|
|
114
|
+
const rawExecutionContext = rawOptionExecutionContext ?? topLevelExecutionContext;
|
|
115
|
+
let executionContext: BuildProviderCommandOptions['executionContext'];
|
|
116
|
+
if (
|
|
117
|
+
rawExecutionContext === undefined ||
|
|
118
|
+
rawExecutionContext === 'host' ||
|
|
119
|
+
rawExecutionContext === 'detached' ||
|
|
120
|
+
rawExecutionContext === 'docker' ||
|
|
121
|
+
rawExecutionContext === 'benchmark'
|
|
122
|
+
) {
|
|
123
|
+
executionContext = rawExecutionContext;
|
|
124
|
+
} else {
|
|
125
|
+
throw contractError({
|
|
126
|
+
code: 'invalid-field',
|
|
127
|
+
message: `${
|
|
128
|
+
rawOptionExecutionContext === undefined ? 'executionContext' : 'options.executionContext'
|
|
129
|
+
} must be "host", "detached", "docker", or "benchmark".`,
|
|
130
|
+
exitCode: 2,
|
|
131
|
+
field:
|
|
132
|
+
rawOptionExecutionContext === undefined
|
|
133
|
+
? 'executionContext'
|
|
134
|
+
: 'options.executionContext',
|
|
135
|
+
});
|
|
136
|
+
}
|
|
137
|
+
return {
|
|
138
|
+
...options,
|
|
139
|
+
...(cwd === undefined || options.cwd !== undefined ? {} : { cwd }),
|
|
140
|
+
...(executionContext === undefined ? {} : { executionContext }),
|
|
141
|
+
};
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
export interface PreparedCommandSpec extends PreparedSingleAgentProviderCommand {
|
|
145
|
+
readonly context: string;
|
|
95
146
|
}
|
|
96
147
|
|
|
97
148
|
export function buildCommandSpec(
|
|
98
149
|
request: RequestData,
|
|
99
150
|
runtimeSettings?: Record<string, unknown>
|
|
100
|
-
): {
|
|
101
|
-
readonly adapter: ProviderAdapter;
|
|
102
|
-
readonly commandSpec: CommandSpec;
|
|
103
|
-
readonly options: BuildProviderCommandOptions;
|
|
104
|
-
readonly context: string;
|
|
105
|
-
} {
|
|
151
|
+
): PreparedCommandSpec {
|
|
106
152
|
const adapter = adapterForProvider(request.provider);
|
|
107
153
|
const context = requiredString(request.raw, 'context');
|
|
108
154
|
const options = buildOptions(request);
|
|
@@ -114,11 +160,36 @@ export function buildCommandSpec(
|
|
|
114
160
|
},
|
|
115
161
|
runtimeSettings
|
|
116
162
|
);
|
|
163
|
+
if (prepared.invoke.parser === 'omp-sdk-ndjson' && Object.keys(request.env).length > 0) {
|
|
164
|
+
const privateRoot = prepared.privateArtifacts?.root;
|
|
165
|
+
if (privateRoot !== undefined) {
|
|
166
|
+
try {
|
|
167
|
+
fs.rmSync(privateRoot, { recursive: true, force: true });
|
|
168
|
+
if (fs.existsSync(privateRoot)) throw new Error('private root still exists');
|
|
169
|
+
} catch {
|
|
170
|
+
throw contractError({
|
|
171
|
+
code: 'invalid-request',
|
|
172
|
+
message: 'OMP SDK private request cleanup failed before spawn.',
|
|
173
|
+
exitCode: 1,
|
|
174
|
+
field: 'env',
|
|
175
|
+
});
|
|
176
|
+
}
|
|
177
|
+
}
|
|
178
|
+
throw contractError({
|
|
179
|
+
code: 'forbidden-field',
|
|
180
|
+
message:
|
|
181
|
+
'env is not accepted for OMP SDK requests; the final spawn owner resolves only credential names declared by providerSettings.omp.auth.',
|
|
182
|
+
exitCode: 2,
|
|
183
|
+
field: 'env',
|
|
184
|
+
});
|
|
185
|
+
}
|
|
117
186
|
return {
|
|
118
|
-
|
|
187
|
+
...prepared,
|
|
119
188
|
context,
|
|
120
|
-
|
|
121
|
-
|
|
189
|
+
commandSpec:
|
|
190
|
+
prepared.invoke.parser === 'omp-sdk-ndjson'
|
|
191
|
+
? prepared.commandSpec
|
|
192
|
+
: mergeCommandSpec(prepared.commandSpec, request.env),
|
|
122
193
|
};
|
|
123
194
|
}
|
|
124
195
|
|
|
@@ -40,12 +40,20 @@ export {
|
|
|
40
40
|
type OmpRpcTaskHooks,
|
|
41
41
|
type OmpRpcTaskRequest,
|
|
42
42
|
type OmpRpcTaskResult,
|
|
43
|
-
} from './omp
|
|
43
|
+
} from './omp/rpc-driver';
|
|
44
44
|
export { buildOmpPrompt } from './adapters/omp';
|
|
45
|
-
export { DEFAULT_OMP_RPC_DECODER_LIMITS } from './omp
|
|
46
|
-
export { ABORT_GRACE_MS, EXIT_GRACE_MS } from './omp
|
|
47
|
-
export { OMP_SUPPORTED_VERSION } from './omp
|
|
48
|
-
export type { OmpSessionLaunch, VerifiedOmpPartition, VerifiedOmpSessionFile } from './omp
|
|
45
|
+
export { DEFAULT_OMP_RPC_DECODER_LIMITS } from './omp/rpc-protocol';
|
|
46
|
+
export { ABORT_GRACE_MS, EXIT_GRACE_MS } from './omp/rpc-bounds';
|
|
47
|
+
export { OMP_SUPPORTED_VERSION } from './omp/release';
|
|
48
|
+
export type { OmpSessionLaunch, VerifiedOmpPartition, VerifiedOmpSessionFile } from './omp/rpc-session';
|
|
49
|
+
export {
|
|
50
|
+
OmpSdkProcessRunnerError,
|
|
51
|
+
runOmpSdkProcess,
|
|
52
|
+
spawnOmpSdkProcess,
|
|
53
|
+
type OmpSdkProcessResult,
|
|
54
|
+
type OmpSdkProcessRunnerOptions,
|
|
55
|
+
type OmpSdkRunningProcess,
|
|
56
|
+
} from './omp/sdk-process-runner';
|
|
49
57
|
export {
|
|
50
58
|
detectRuntimeProviderCliFeatures,
|
|
51
59
|
prepareSingleAgentProviderCommand,
|
|
@@ -69,6 +77,46 @@ export {
|
|
|
69
77
|
supportsProviderCapability,
|
|
70
78
|
supportsProviderOutputReformatting,
|
|
71
79
|
} from './provider-registry';
|
|
80
|
+
export {
|
|
81
|
+
createOmpSdkProtocolCollector,
|
|
82
|
+
decodeOmpSdkProtocolFrame,
|
|
83
|
+
decodeOmpSdkSidecarRequest,
|
|
84
|
+
normalizeOmpSdkResultFrame,
|
|
85
|
+
ompSdkOutputSchemaForRequest,
|
|
86
|
+
parseOmpSdkProtocolFrame,
|
|
87
|
+
parseOmpSdkSidecarRequest,
|
|
88
|
+
validateOmpSdkProtocolResultFrame,
|
|
89
|
+
OMP_SDK_BACKEND_VERSION,
|
|
90
|
+
OMP_SDK_BUN_VERSION,
|
|
91
|
+
OMP_SDK_ERROR_CODES,
|
|
92
|
+
OMP_SDK_MAX_FRAME_BYTES,
|
|
93
|
+
OMP_SDK_MAX_REQUEST_BYTES,
|
|
94
|
+
OMP_SDK_MAX_STDOUT_BYTES,
|
|
95
|
+
OMP_SDK_PROGRESS_STAGES,
|
|
96
|
+
OMP_SDK_PROTOCOL_VERSION,
|
|
97
|
+
OMP_SDK_TEXT_OUTPUT_SCHEMA,
|
|
98
|
+
OMP_SDK_TOOL_IDS,
|
|
99
|
+
type OmpSdkCollectedTerminal,
|
|
100
|
+
type OmpSdkErrorCategory,
|
|
101
|
+
type OmpSdkErrorCode,
|
|
102
|
+
type OmpSdkJsonSidecarRequest,
|
|
103
|
+
type OmpSdkModelsConfig,
|
|
104
|
+
type OmpSdkOutputMode,
|
|
105
|
+
type OmpSdkProgressStage,
|
|
106
|
+
type OmpSdkProtocolCollector,
|
|
107
|
+
type OmpSdkProtocolCollectorOptions,
|
|
108
|
+
type OmpSdkProtocolErrorFrame,
|
|
109
|
+
type OmpSdkProtocolFrame,
|
|
110
|
+
type OmpSdkProtocolProgressFrame,
|
|
111
|
+
type OmpSdkProtocolResultFrame,
|
|
112
|
+
type OmpSdkProtocolTerminalFrame,
|
|
113
|
+
type OmpSdkRequestAuth,
|
|
114
|
+
type OmpSdkSafeError,
|
|
115
|
+
type OmpSdkSidecarRequest,
|
|
116
|
+
type OmpSdkTextSidecarRequest,
|
|
117
|
+
type OmpSdkToolId,
|
|
118
|
+
} from './omp/sdk-protocol';
|
|
119
|
+
|
|
72
120
|
|
|
73
121
|
export type {
|
|
74
122
|
AgentCliProviderHelperMetadata,
|
|
@@ -88,12 +136,19 @@ export type {
|
|
|
88
136
|
GatewayToolPolicy,
|
|
89
137
|
GeminiCliFeatures,
|
|
90
138
|
KnownProviderName,
|
|
139
|
+
InvocationLane,
|
|
140
|
+
InvocationLaneMetadata,
|
|
91
141
|
LevelModelSpec,
|
|
92
142
|
LevelOverrides,
|
|
93
143
|
ModelCatalogEntry,
|
|
94
144
|
ModelLevel,
|
|
95
145
|
ModelSpec,
|
|
96
146
|
OmpCliFeatures,
|
|
147
|
+
OmpSdkRequestedIdentity,
|
|
148
|
+
OmpSdkResolvedIdentity,
|
|
149
|
+
OmpSdkStrictOutputEvidence,
|
|
150
|
+
OmpSdkTerminalEvidence,
|
|
151
|
+
OmpSdkUsageEvidence,
|
|
97
152
|
OpencodeCliFeatures,
|
|
98
153
|
OutputEvent,
|
|
99
154
|
OutputFormat,
|
|
@@ -0,0 +1,126 @@
|
|
|
1
|
+
import { chmodSync, constants, copyFileSync, lstatSync } from 'node:fs';
|
|
2
|
+
import { join } from 'node:path';
|
|
3
|
+
|
|
4
|
+
export type OmpAuthStorageMode = 'environment' | 'broker' | 'none' | 'omp-home';
|
|
5
|
+
|
|
6
|
+
interface ClosableAuthStorage {
|
|
7
|
+
close(): void;
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
interface BrokerCredentials {
|
|
11
|
+
readonly token?: string | undefined;
|
|
12
|
+
readonly url?: string | undefined;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
interface OmpAuthStoragePolicyOptions<T extends ClosableAuthStorage> {
|
|
16
|
+
readonly mode: OmpAuthStorageMode;
|
|
17
|
+
readonly sourceDirectory?: unknown;
|
|
18
|
+
readonly privateAgentDirectory: string;
|
|
19
|
+
readonly privateDatabasePath: string;
|
|
20
|
+
readonly brokerCachePath: string;
|
|
21
|
+
readonly brokerCredentials?: BrokerCredentials;
|
|
22
|
+
readonly sourceLabel: string;
|
|
23
|
+
readonly createDatabase: (databasePath: string) => Promise<T>;
|
|
24
|
+
readonly discoverBroker: (
|
|
25
|
+
agentDirectory: string,
|
|
26
|
+
options: { cachePath: string; sourceLabel: string }
|
|
27
|
+
) => Promise<T>;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
|
|
31
|
+
/**
|
|
32
|
+
* Snapshot only OMP's credential database. Configuration, broker token, and
|
|
33
|
+
* other files in the source home are deliberately outside this policy.
|
|
34
|
+
*/
|
|
35
|
+
export function snapshotOmpAuthDatabase(
|
|
36
|
+
sourceDirectory: unknown,
|
|
37
|
+
privateDatabasePath: string
|
|
38
|
+
): void {
|
|
39
|
+
if (typeof sourceDirectory !== 'string' || sourceDirectory.length === 0) {
|
|
40
|
+
throw new Error('OMP local auth source must be a non-empty directory path');
|
|
41
|
+
}
|
|
42
|
+
const sourceDatabasePath = join(sourceDirectory, 'agent.db');
|
|
43
|
+
let sourceStat;
|
|
44
|
+
try {
|
|
45
|
+
sourceStat = lstatSync(sourceDatabasePath);
|
|
46
|
+
} catch (error) {
|
|
47
|
+
const code =
|
|
48
|
+
error !== null &&
|
|
49
|
+
typeof error === 'object' &&
|
|
50
|
+
'code' in error &&
|
|
51
|
+
typeof error.code === 'string'
|
|
52
|
+
? error.code
|
|
53
|
+
: undefined;
|
|
54
|
+
if (code === 'ENOENT') {
|
|
55
|
+
throw new Error(`OMP local auth source is missing agent.db at ${sourceDatabasePath}`);
|
|
56
|
+
}
|
|
57
|
+
throw error;
|
|
58
|
+
}
|
|
59
|
+
if (!sourceStat.isFile() || sourceStat.isSymbolicLink()) {
|
|
60
|
+
throw new Error(`OMP local auth source must be a regular agent.db file at ${sourceDatabasePath}`);
|
|
61
|
+
}
|
|
62
|
+
copyFileSync(sourceDatabasePath, privateDatabasePath, constants.COPYFILE_EXCL);
|
|
63
|
+
chmodSync(privateDatabasePath, 0o600);
|
|
64
|
+
|
|
65
|
+
for (const suffix of ['-wal', '-shm']) {
|
|
66
|
+
const sourceSidecar = `${sourceDatabasePath}${suffix}`;
|
|
67
|
+
const privateSidecar = `${privateDatabasePath}${suffix}`;
|
|
68
|
+
try {
|
|
69
|
+
const sidecarStat = lstatSync(sourceSidecar);
|
|
70
|
+
if (!sidecarStat.isFile() || sidecarStat.isSymbolicLink()) {
|
|
71
|
+
throw new Error(`OMP local auth source sidecar must be a regular file: ${sourceSidecar}`);
|
|
72
|
+
}
|
|
73
|
+
copyFileSync(sourceSidecar, privateSidecar, constants.COPYFILE_EXCL);
|
|
74
|
+
chmodSync(privateSidecar, 0o600);
|
|
75
|
+
} catch (error) {
|
|
76
|
+
const code =
|
|
77
|
+
error !== null &&
|
|
78
|
+
typeof error === 'object' &&
|
|
79
|
+
'code' in error &&
|
|
80
|
+
typeof error.code === 'string'
|
|
81
|
+
? error.code
|
|
82
|
+
: undefined;
|
|
83
|
+
if (code !== 'ENOENT') throw error;
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
/** Open auth through one fail-closed policy shared by diagnostics and execution. */
|
|
89
|
+
export async function openOmpAuthStorage<T extends ClosableAuthStorage>(
|
|
90
|
+
options: OmpAuthStoragePolicyOptions<T>
|
|
91
|
+
): Promise<T> {
|
|
92
|
+
if (options.mode === 'omp-home') {
|
|
93
|
+
snapshotOmpAuthDatabase(options.sourceDirectory, options.privateDatabasePath);
|
|
94
|
+
return options.createDatabase(options.privateDatabasePath);
|
|
95
|
+
}
|
|
96
|
+
if (options.mode !== 'broker') {
|
|
97
|
+
return options.createDatabase(options.privateDatabasePath);
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
const url = options.brokerCredentials?.url;
|
|
101
|
+
const token = options.brokerCredentials?.token;
|
|
102
|
+
if (
|
|
103
|
+
typeof url !== 'string' ||
|
|
104
|
+
url.length === 0 ||
|
|
105
|
+
typeof token !== 'string' ||
|
|
106
|
+
token.length === 0
|
|
107
|
+
) {
|
|
108
|
+
throw new Error('OMP broker credentials are missing');
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
const previousUrl = process.env.OMP_AUTH_BROKER_URL;
|
|
112
|
+
const previousToken = process.env.OMP_AUTH_BROKER_TOKEN;
|
|
113
|
+
process.env.OMP_AUTH_BROKER_URL = url;
|
|
114
|
+
process.env.OMP_AUTH_BROKER_TOKEN = token;
|
|
115
|
+
try {
|
|
116
|
+
return await options.discoverBroker(options.privateAgentDirectory, {
|
|
117
|
+
cachePath: options.brokerCachePath,
|
|
118
|
+
sourceLabel: options.sourceLabel,
|
|
119
|
+
});
|
|
120
|
+
} finally {
|
|
121
|
+
if (previousUrl === undefined) delete process.env.OMP_AUTH_BROKER_URL;
|
|
122
|
+
else process.env.OMP_AUTH_BROKER_URL = previousUrl;
|
|
123
|
+
if (previousToken === undefined) delete process.env.OMP_AUTH_BROKER_TOKEN;
|
|
124
|
+
else process.env.OMP_AUTH_BROKER_TOKEN = previousToken;
|
|
125
|
+
}
|
|
126
|
+
}
|
|
@@ -0,0 +1,144 @@
|
|
|
1
|
+
import type { ChildProcessWithoutNullStreams } from 'node:child_process';
|
|
2
|
+
|
|
3
|
+
import { MAX_LIFETIME_REQUEST_IDS, MAX_PENDING_REQUESTS } from './rpc-bounds';
|
|
4
|
+
import {
|
|
5
|
+
DEFAULT_OMP_RPC_DECODER_LIMITS,
|
|
6
|
+
encodeOmpRpcCommand,
|
|
7
|
+
type OmpRpcCommand,
|
|
8
|
+
type OmpRpcInboundFrame,
|
|
9
|
+
} from './rpc-protocol';
|
|
10
|
+
import { getBoolean, getOptionalString, getString } from '../json';
|
|
11
|
+
import { OmpRpcTaskFailure, UI_RESPONDERS, type DriverState } from './rpc-driver-state';
|
|
12
|
+
|
|
13
|
+
export class OmpRpcChannel {
|
|
14
|
+
constructor(
|
|
15
|
+
private readonly child: ChildProcessWithoutNullStreams,
|
|
16
|
+
private readonly state: DriverState
|
|
17
|
+
) {}
|
|
18
|
+
|
|
19
|
+
registerLifetimeId(id: string): boolean {
|
|
20
|
+
if (this.state.lifetimeRequestIds.has(id)) return true;
|
|
21
|
+
if (this.state.lifetimeRequestIds.size >= MAX_LIFETIME_REQUEST_IDS) return false;
|
|
22
|
+
this.state.lifetimeRequestIds.add(id);
|
|
23
|
+
return true;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
writeFrame(frame: OmpRpcCommand): void {
|
|
27
|
+
if (this.child.stdin.destroyed) return;
|
|
28
|
+
try {
|
|
29
|
+
this.child.stdin.write(
|
|
30
|
+
encodeOmpRpcCommand(frame, DEFAULT_OMP_RPC_DECODER_LIMITS.maxPhysicalFrameBytes)
|
|
31
|
+
);
|
|
32
|
+
} catch {
|
|
33
|
+
// Stdin already closed; the close handler settles the task.
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
sendCommand(command: OmpRpcCommand): Promise<Record<string, unknown>> {
|
|
38
|
+
const id = command.id ?? '';
|
|
39
|
+
if (!this.registerLifetimeId(id)) {
|
|
40
|
+
return Promise.reject(
|
|
41
|
+
new OmpRpcTaskFailure(
|
|
42
|
+
'lifetime-request-id-exceeded',
|
|
43
|
+
`command id "${id}" exceeds the lifetime request-id bound.`
|
|
44
|
+
)
|
|
45
|
+
);
|
|
46
|
+
}
|
|
47
|
+
if (this.state.pending.size >= MAX_PENDING_REQUESTS) {
|
|
48
|
+
return Promise.reject(
|
|
49
|
+
new OmpRpcTaskFailure(
|
|
50
|
+
'pending-request-exceeded',
|
|
51
|
+
'too many concurrent outbound RPC commands are awaiting a response.'
|
|
52
|
+
)
|
|
53
|
+
);
|
|
54
|
+
}
|
|
55
|
+
return new Promise<Record<string, unknown>>((resolve, reject) => {
|
|
56
|
+
this.state.pending.set(id, { resolve, reject });
|
|
57
|
+
this.writeFrame(command);
|
|
58
|
+
});
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
assertSuccessfulResponse(response: Record<string, unknown>, command: string, id: string): void {
|
|
62
|
+
if (getString(response, 'command') !== command || getString(response, 'id') !== id) {
|
|
63
|
+
throw new OmpRpcTaskFailure(
|
|
64
|
+
'malformed-response',
|
|
65
|
+
`Expected a ${command} response with id "${id}".`
|
|
66
|
+
);
|
|
67
|
+
}
|
|
68
|
+
if (getBoolean(response, 'success') !== true) {
|
|
69
|
+
throw new OmpRpcTaskFailure(
|
|
70
|
+
'unsafe-config',
|
|
71
|
+
getString(response, 'error') ?? `${command} was rejected.`
|
|
72
|
+
);
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
handleResponse(frame: OmpRpcInboundFrame): void {
|
|
77
|
+
const id = getOptionalString(frame, 'id');
|
|
78
|
+
if (!id) return;
|
|
79
|
+
const command = this.state.pending.get(id);
|
|
80
|
+
if (command === undefined) return;
|
|
81
|
+
this.state.pending.delete(id);
|
|
82
|
+
command.resolve(frame);
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
handleExtensionUiRequest(frame: OmpRpcInboundFrame): void {
|
|
86
|
+
const id = getString(frame, 'id');
|
|
87
|
+
const method = getString(frame, 'method');
|
|
88
|
+
if (id === null || method === null) {
|
|
89
|
+
throw new OmpRpcTaskFailure(
|
|
90
|
+
'malformed-extension-ui-request',
|
|
91
|
+
'extension_ui_request is missing id/method.'
|
|
92
|
+
);
|
|
93
|
+
}
|
|
94
|
+
this.assertInboundId(id);
|
|
95
|
+
const responder = UI_RESPONDERS[method];
|
|
96
|
+
if (responder === undefined) {
|
|
97
|
+
throw new OmpRpcTaskFailure(
|
|
98
|
+
'unsupported-ui-method',
|
|
99
|
+
`extension_ui_request used unsupported method "${method}".`
|
|
100
|
+
);
|
|
101
|
+
}
|
|
102
|
+
this.writeFrame(responder(id));
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
handleHostToolCall(frame: OmpRpcInboundFrame): void {
|
|
106
|
+
const id = this.inboundId(frame, 'malformed-host-tool-call', 'host_tool_call is missing id.');
|
|
107
|
+
this.writeFrame({
|
|
108
|
+
type: 'host_tool_result',
|
|
109
|
+
id,
|
|
110
|
+
isError: true,
|
|
111
|
+
result: { content: [{ type: 'text', text: 'Zeroshot declares no host tools' }] },
|
|
112
|
+
});
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
handleHostUriRequest(frame: OmpRpcInboundFrame): void {
|
|
116
|
+
const id = this.inboundId(
|
|
117
|
+
frame,
|
|
118
|
+
'malformed-host-uri-request',
|
|
119
|
+
'host_uri_request is missing id.'
|
|
120
|
+
);
|
|
121
|
+
this.writeFrame({
|
|
122
|
+
type: 'host_uri_result',
|
|
123
|
+
id,
|
|
124
|
+
isError: true,
|
|
125
|
+
error: 'Zeroshot declares no host URI schemes',
|
|
126
|
+
});
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
private inboundId(frame: OmpRpcInboundFrame, code: string, message: string): string {
|
|
130
|
+
const id = getString(frame, 'id');
|
|
131
|
+
if (id === null) throw new OmpRpcTaskFailure(code, message);
|
|
132
|
+
this.assertInboundId(id);
|
|
133
|
+
return id;
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
private assertInboundId(id: string): void {
|
|
137
|
+
if (!this.registerLifetimeId(id)) {
|
|
138
|
+
throw new OmpRpcTaskFailure(
|
|
139
|
+
'lifetime-request-id-exceeded',
|
|
140
|
+
`inbound request id "${id}" exceeds the lifetime request-id bound.`
|
|
141
|
+
);
|
|
142
|
+
}
|
|
143
|
+
}
|
|
144
|
+
}
|