@the-open-engine/zeroshot 6.30.2 → 6.31.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/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/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
|
@@ -0,0 +1,156 @@
|
|
|
1
|
+
import { OMP_SDK_TOOL_IDS } from './sdk-settings';
|
|
2
|
+
import type {
|
|
3
|
+
OmpModelsConfig,
|
|
4
|
+
OmpSdkAuth,
|
|
5
|
+
OmpSdkToolId as SettingsOmpSdkToolId,
|
|
6
|
+
} from './sdk-settings';
|
|
7
|
+
import type { OmpSdkTerminalEvidence, ReasoningEffort, ResultEvent } from '../types';
|
|
8
|
+
|
|
9
|
+
export const OMP_SDK_PROTOCOL_VERSION = 1 as const;
|
|
10
|
+
export const OMP_SDK_BACKEND_VERSION = '17.2.1' as const;
|
|
11
|
+
export const OMP_SDK_BUN_VERSION = '1.3.14' as const;
|
|
12
|
+
export const OMP_SDK_MAX_REQUEST_BYTES = 8 * 1024 * 1024;
|
|
13
|
+
export const OMP_SDK_MAX_FRAME_BYTES = 1024 * 1024;
|
|
14
|
+
export const OMP_SDK_MAX_STDOUT_BYTES = 8 * 1024 * 1024;
|
|
15
|
+
export const OMP_SDK_MAX_CREDENTIAL_BYTES = 64 * 1024;
|
|
16
|
+
|
|
17
|
+
export const OMP_SDK_EXECUTION_CONTEXTS = ['host', 'detached', 'docker', 'benchmark'] as const;
|
|
18
|
+
export { OMP_SDK_TOOL_IDS };
|
|
19
|
+
export type OmpSdkToolId = SettingsOmpSdkToolId;
|
|
20
|
+
export type OmpSdkRequestAuth = OmpSdkAuth;
|
|
21
|
+
export type OmpSdkModelsConfig = OmpModelsConfig;
|
|
22
|
+
export type OmpSdkOutputMode = 'json' | 'text';
|
|
23
|
+
export type OmpSdkExecutionContext = (typeof OMP_SDK_EXECUTION_CONTEXTS)[number];
|
|
24
|
+
|
|
25
|
+
interface OmpSdkRequestBase {
|
|
26
|
+
readonly protocolVersion: 1;
|
|
27
|
+
readonly runId: string;
|
|
28
|
+
readonly cwd: string;
|
|
29
|
+
readonly executionContext: OmpSdkExecutionContext;
|
|
30
|
+
readonly prompt: string;
|
|
31
|
+
readonly modelSelector: string;
|
|
32
|
+
readonly reasoningEffort: ReasoningEffort;
|
|
33
|
+
readonly modelsConfig: OmpSdkModelsConfig;
|
|
34
|
+
readonly auth: OmpSdkRequestAuth;
|
|
35
|
+
readonly tools: readonly OmpSdkToolId[];
|
|
36
|
+
readonly context: string;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
export interface OmpSdkJsonSidecarRequest extends OmpSdkRequestBase {
|
|
40
|
+
readonly outputMode: 'json';
|
|
41
|
+
readonly outputSchema: boolean | Readonly<Record<string, unknown>>;
|
|
42
|
+
}
|
|
43
|
+
export interface OmpSdkTextSidecarRequest extends OmpSdkRequestBase {
|
|
44
|
+
readonly outputMode: 'text';
|
|
45
|
+
readonly outputSchema?: never;
|
|
46
|
+
}
|
|
47
|
+
export type OmpSdkSidecarRequest = OmpSdkJsonSidecarRequest | OmpSdkTextSidecarRequest;
|
|
48
|
+
|
|
49
|
+
export const OMP_SDK_TEXT_OUTPUT_SCHEMA = Object.freeze({
|
|
50
|
+
type: 'object',
|
|
51
|
+
properties: Object.freeze({ result: Object.freeze({ type: 'string' }) }),
|
|
52
|
+
required: Object.freeze(['result']),
|
|
53
|
+
additionalProperties: false,
|
|
54
|
+
}) as Readonly<Record<string, unknown>>;
|
|
55
|
+
|
|
56
|
+
export const OMP_SDK_PROGRESS_STAGES = [
|
|
57
|
+
'starting',
|
|
58
|
+
'resolving-model',
|
|
59
|
+
'running',
|
|
60
|
+
'tearing-down',
|
|
61
|
+
] as const;
|
|
62
|
+
export type OmpSdkProgressStage = (typeof OMP_SDK_PROGRESS_STAGES)[number];
|
|
63
|
+
|
|
64
|
+
export interface OmpSdkProtocolProgressFrame {
|
|
65
|
+
readonly protocolVersion: 1;
|
|
66
|
+
readonly type: 'progress';
|
|
67
|
+
readonly runId: string;
|
|
68
|
+
readonly sequence: number;
|
|
69
|
+
readonly stage: OmpSdkProgressStage;
|
|
70
|
+
}
|
|
71
|
+
export interface OmpSdkProtocolResultFrame extends OmpSdkTerminalEvidence {
|
|
72
|
+
readonly protocolVersion: 1;
|
|
73
|
+
readonly type: 'result';
|
|
74
|
+
readonly runId: string;
|
|
75
|
+
readonly value: unknown;
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
export const OMP_SDK_ERROR_CODES = [
|
|
79
|
+
'invalid-request',
|
|
80
|
+
'model-resolution',
|
|
81
|
+
'model-fallback',
|
|
82
|
+
'provider-auth',
|
|
83
|
+
'provider-rate-limit',
|
|
84
|
+
'provider-timeout',
|
|
85
|
+
'provider-error',
|
|
86
|
+
'schema-violation',
|
|
87
|
+
'cancelled',
|
|
88
|
+
'sdk-error',
|
|
89
|
+
'cleanup-error',
|
|
90
|
+
'internal-error',
|
|
91
|
+
] as const;
|
|
92
|
+
export type OmpSdkErrorCode = (typeof OMP_SDK_ERROR_CODES)[number];
|
|
93
|
+
export type OmpSdkErrorCategory =
|
|
94
|
+
| 'request'
|
|
95
|
+
| 'model'
|
|
96
|
+
| 'auth'
|
|
97
|
+
| 'rate-limit'
|
|
98
|
+
| 'timeout'
|
|
99
|
+
| 'provider'
|
|
100
|
+
| 'schema'
|
|
101
|
+
| 'cancelled'
|
|
102
|
+
| 'sdk'
|
|
103
|
+
| 'cleanup'
|
|
104
|
+
| 'internal';
|
|
105
|
+
export interface OmpSdkSafeError {
|
|
106
|
+
readonly code: OmpSdkErrorCode;
|
|
107
|
+
readonly category: OmpSdkErrorCategory;
|
|
108
|
+
readonly retryable: boolean;
|
|
109
|
+
readonly redacted: true;
|
|
110
|
+
}
|
|
111
|
+
export interface OmpSdkProtocolErrorFrame {
|
|
112
|
+
readonly protocolVersion: 1;
|
|
113
|
+
readonly type: 'error';
|
|
114
|
+
readonly runId: string;
|
|
115
|
+
readonly backend: OmpSdkTerminalEvidence['backend'];
|
|
116
|
+
readonly runtime: OmpSdkTerminalEvidence['runtime'];
|
|
117
|
+
readonly error: OmpSdkSafeError;
|
|
118
|
+
}
|
|
119
|
+
export type OmpSdkProtocolFrame =
|
|
120
|
+
| OmpSdkProtocolProgressFrame
|
|
121
|
+
| OmpSdkProtocolResultFrame
|
|
122
|
+
| OmpSdkProtocolErrorFrame;
|
|
123
|
+
export type OmpSdkProtocolTerminalFrame = OmpSdkProtocolResultFrame | OmpSdkProtocolErrorFrame;
|
|
124
|
+
export type OmpSdkCollectedTerminal =
|
|
125
|
+
| {
|
|
126
|
+
readonly type: 'result';
|
|
127
|
+
readonly frame: OmpSdkProtocolResultFrame;
|
|
128
|
+
readonly event: ResultEvent;
|
|
129
|
+
}
|
|
130
|
+
| { readonly type: 'error'; readonly frame: OmpSdkProtocolErrorFrame };
|
|
131
|
+
|
|
132
|
+
export interface OmpSdkProtocolCollectorOptions {
|
|
133
|
+
readonly request: OmpSdkSidecarRequest;
|
|
134
|
+
readonly maxFrameBytes?: number;
|
|
135
|
+
readonly maxStdoutBytes?: number;
|
|
136
|
+
}
|
|
137
|
+
export interface OmpSdkProtocolCollector {
|
|
138
|
+
readonly progress: readonly OmpSdkProtocolProgressFrame[];
|
|
139
|
+
write(chunk: string | Uint8Array): readonly OmpSdkProtocolFrame[];
|
|
140
|
+
finish(exitCode: number): OmpSdkCollectedTerminal;
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
export const CATEGORY: Readonly<Record<OmpSdkErrorCode, OmpSdkErrorCategory>> = {
|
|
144
|
+
'invalid-request': 'request',
|
|
145
|
+
'model-resolution': 'model',
|
|
146
|
+
'model-fallback': 'model',
|
|
147
|
+
'provider-auth': 'auth',
|
|
148
|
+
'provider-rate-limit': 'rate-limit',
|
|
149
|
+
'provider-timeout': 'timeout',
|
|
150
|
+
'provider-error': 'provider',
|
|
151
|
+
'schema-violation': 'schema',
|
|
152
|
+
cancelled: 'cancelled',
|
|
153
|
+
'sdk-error': 'sdk',
|
|
154
|
+
'cleanup-error': 'cleanup',
|
|
155
|
+
'internal-error': 'internal',
|
|
156
|
+
};
|
|
@@ -0,0 +1,234 @@
|
|
|
1
|
+
import Ajv from 'ajv';
|
|
2
|
+
|
|
3
|
+
import { contractError } from '../contract-errors';
|
|
4
|
+
import { parseExactOmpModelSelector } from './sdk-settings';
|
|
5
|
+
const MAX_RUN_ID_BYTES = 128;
|
|
6
|
+
const MAX_SELECTOR_BYTES = 1024;
|
|
7
|
+
const MAX_JSON_DEPTH = 64;
|
|
8
|
+
const MAX_JSON_NODES = 100_000;
|
|
9
|
+
const MAX_SCHEMA_STRING_BYTES = 16 * 1024;
|
|
10
|
+
const MAX_SCHEMA_ARRAY_ITEMS = 4_096;
|
|
11
|
+
const MAX_SCHEMA_OBJECT_KEYS = 4_096;
|
|
12
|
+
const MAX_SCHEMA_KEY_BYTES = 1_024;
|
|
13
|
+
const UNSAFE_REGEX_SCHEMA_KEYWORDS: Readonly<Record<string, true>> = {
|
|
14
|
+
pattern: true,
|
|
15
|
+
patternProperties: true,
|
|
16
|
+
};
|
|
17
|
+
|
|
18
|
+
export type Fail = (message: string, field?: string) => never;
|
|
19
|
+
export function includesLiteral<T extends string>(
|
|
20
|
+
values: readonly T[],
|
|
21
|
+
value: unknown
|
|
22
|
+
): value is T {
|
|
23
|
+
return typeof value === 'string' && values.some((candidate) => candidate === value);
|
|
24
|
+
}
|
|
25
|
+
function failure(code: string, message: string, field?: string): never {
|
|
26
|
+
throw contractError({ code, message, exitCode: 2, ...(field === undefined ? {} : { field }) });
|
|
27
|
+
}
|
|
28
|
+
export function protocolFailure(message: string, field?: string): never {
|
|
29
|
+
return failure('omp-sdk-protocol', message, field);
|
|
30
|
+
}
|
|
31
|
+
export function requestFailure(message: string, field?: string): never {
|
|
32
|
+
return failure('invalid-omp-sdk-request', message, field);
|
|
33
|
+
}
|
|
34
|
+
export function isRecord(value: unknown): value is Record<string, unknown> {
|
|
35
|
+
return typeof value === 'object' && value !== null && !Array.isArray(value);
|
|
36
|
+
}
|
|
37
|
+
export function exact(
|
|
38
|
+
record: Record<string, unknown>,
|
|
39
|
+
required: readonly string[],
|
|
40
|
+
optional: readonly string[],
|
|
41
|
+
subject: string,
|
|
42
|
+
fail: Fail
|
|
43
|
+
): void {
|
|
44
|
+
const allowed = new Set([...required, ...optional]);
|
|
45
|
+
for (const key of required) {
|
|
46
|
+
if (!Object.prototype.hasOwnProperty.call(record, key)) {
|
|
47
|
+
fail(`${subject}.${key} is required.`, `${subject}.${key}`);
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
for (const key of Object.keys(record)) {
|
|
51
|
+
if (!allowed.has(key)) fail(`${subject}.${key} is not allowed.`, `${subject}.${key}`);
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
export function string(
|
|
55
|
+
value: unknown,
|
|
56
|
+
field: string,
|
|
57
|
+
maxBytes: number,
|
|
58
|
+
empty: boolean,
|
|
59
|
+
fail: Fail
|
|
60
|
+
): string {
|
|
61
|
+
if (typeof value !== 'string' || (!empty && value.length === 0)) {
|
|
62
|
+
return fail(`${field} must be ${empty ? 'a string' : 'a non-empty string'}.`, field);
|
|
63
|
+
}
|
|
64
|
+
if (Buffer.byteLength(value) > maxBytes)
|
|
65
|
+
return fail(`${field} exceeds ${maxBytes} bytes.`, field);
|
|
66
|
+
return value;
|
|
67
|
+
}
|
|
68
|
+
export function parseRunId(value: unknown, field: string, fail: Fail): string {
|
|
69
|
+
const parsed = string(value, field, MAX_RUN_ID_BYTES, false, fail);
|
|
70
|
+
if (!/^[A-Za-z0-9][A-Za-z0-9._:-]*$/.test(parsed)) {
|
|
71
|
+
fail(`${field} contains unsupported characters.`, field);
|
|
72
|
+
}
|
|
73
|
+
return parsed;
|
|
74
|
+
}
|
|
75
|
+
export function literal<T extends string | number | boolean>(
|
|
76
|
+
value: unknown,
|
|
77
|
+
expected: T,
|
|
78
|
+
field: string,
|
|
79
|
+
fail: Fail
|
|
80
|
+
): T {
|
|
81
|
+
if (value !== expected) return fail(`${field} must be ${JSON.stringify(expected)}.`, field);
|
|
82
|
+
return expected;
|
|
83
|
+
}
|
|
84
|
+
export function number(value: unknown, field: string, integer: boolean): number {
|
|
85
|
+
if (
|
|
86
|
+
typeof value !== 'number' ||
|
|
87
|
+
!Number.isFinite(value) ||
|
|
88
|
+
value < 0 ||
|
|
89
|
+
(integer && !Number.isInteger(value))
|
|
90
|
+
) {
|
|
91
|
+
protocolFailure(`${field} must be a finite nonnegative${integer ? ' integer' : ''}.`, field);
|
|
92
|
+
}
|
|
93
|
+
return value;
|
|
94
|
+
}
|
|
95
|
+
export function json(value: unknown, field: string, fail: Fail): void {
|
|
96
|
+
const stack: Array<{ value: unknown; depth: number; field: string }> = [
|
|
97
|
+
{ value, depth: 0, field },
|
|
98
|
+
];
|
|
99
|
+
const seen = new Set<object>();
|
|
100
|
+
let count = 0;
|
|
101
|
+
while (stack.length > 0) {
|
|
102
|
+
const item = stack.pop();
|
|
103
|
+
if (item === undefined) break;
|
|
104
|
+
if (++count > MAX_JSON_NODES) fail(`${field} exceeds ${MAX_JSON_NODES} JSON nodes.`, field);
|
|
105
|
+
if (item.depth > MAX_JSON_DEPTH) fail(`${field} exceeds JSON depth ${MAX_JSON_DEPTH}.`, field);
|
|
106
|
+
const current = item.value;
|
|
107
|
+
if (
|
|
108
|
+
current === null ||
|
|
109
|
+
typeof current === 'string' ||
|
|
110
|
+
typeof current === 'boolean' ||
|
|
111
|
+
(typeof current === 'number' && Number.isFinite(current))
|
|
112
|
+
) {
|
|
113
|
+
continue;
|
|
114
|
+
}
|
|
115
|
+
if (typeof current !== 'object')
|
|
116
|
+
fail(`${item.field} must contain only JSON values.`, item.field);
|
|
117
|
+
if (seen.has(current))
|
|
118
|
+
fail(`${item.field} must not contain shared or cyclic objects.`, item.field);
|
|
119
|
+
seen.add(current);
|
|
120
|
+
if (Array.isArray(current)) {
|
|
121
|
+
current.forEach((child, index) =>
|
|
122
|
+
stack.push({ value: child, depth: item.depth + 1, field: `${item.field}[${index}]` })
|
|
123
|
+
);
|
|
124
|
+
} else {
|
|
125
|
+
const prototype = Reflect.getPrototypeOf(current);
|
|
126
|
+
if (prototype !== Object.prototype && prototype !== null) {
|
|
127
|
+
fail(`${item.field} must contain plain JSON objects.`, item.field);
|
|
128
|
+
}
|
|
129
|
+
Object.entries(current).forEach(([key, child]) =>
|
|
130
|
+
stack.push({ value: child, depth: item.depth + 1, field: `${item.field}.${key}` })
|
|
131
|
+
);
|
|
132
|
+
}
|
|
133
|
+
}
|
|
134
|
+
}
|
|
135
|
+
export function serializedLimit(value: unknown, max: number, subject: string, fail: Fail): void {
|
|
136
|
+
let encoded: unknown;
|
|
137
|
+
try {
|
|
138
|
+
encoded = JSON.stringify(value);
|
|
139
|
+
} catch {
|
|
140
|
+
fail(`${subject} is not JSON serializable.`);
|
|
141
|
+
}
|
|
142
|
+
if (typeof encoded !== 'string' || Buffer.byteLength(encoded) > max) {
|
|
143
|
+
fail(`${subject} exceeds ${max} bytes.`);
|
|
144
|
+
}
|
|
145
|
+
}
|
|
146
|
+
export function selector(value: unknown, field: string, fail: Fail): string {
|
|
147
|
+
const parsed = string(value, field, MAX_SELECTOR_BYTES, false, fail);
|
|
148
|
+
try {
|
|
149
|
+
parseExactOmpModelSelector(parsed);
|
|
150
|
+
} catch {
|
|
151
|
+
fail(`${field} must be an exact full provider/model selector.`, field);
|
|
152
|
+
}
|
|
153
|
+
return parsed;
|
|
154
|
+
}
|
|
155
|
+
export function validateSchemaSafety(schema: unknown): void {
|
|
156
|
+
const stack: Array<{ readonly value: unknown; readonly field: string }> = [
|
|
157
|
+
{ value: schema, field: 'request.outputSchema' },
|
|
158
|
+
];
|
|
159
|
+
while (stack.length > 0) {
|
|
160
|
+
const item = stack.pop();
|
|
161
|
+
if (item === undefined) break;
|
|
162
|
+
if (typeof item.value === 'string') {
|
|
163
|
+
if (Buffer.byteLength(item.value) > MAX_SCHEMA_STRING_BYTES) {
|
|
164
|
+
requestFailure(`${item.field} exceeds ${MAX_SCHEMA_STRING_BYTES} bytes.`, item.field);
|
|
165
|
+
}
|
|
166
|
+
continue;
|
|
167
|
+
}
|
|
168
|
+
if (Array.isArray(item.value)) {
|
|
169
|
+
if (item.value.length > MAX_SCHEMA_ARRAY_ITEMS) {
|
|
170
|
+
requestFailure(`${item.field} exceeds ${MAX_SCHEMA_ARRAY_ITEMS} items.`, item.field);
|
|
171
|
+
}
|
|
172
|
+
item.value.forEach((value, index) => stack.push({ value, field: `${item.field}[${index}]` }));
|
|
173
|
+
continue;
|
|
174
|
+
}
|
|
175
|
+
if (!isRecord(item.value)) continue;
|
|
176
|
+
const entries = Object.entries(item.value);
|
|
177
|
+
if (entries.length > MAX_SCHEMA_OBJECT_KEYS) {
|
|
178
|
+
requestFailure(`${item.field} exceeds ${MAX_SCHEMA_OBJECT_KEYS} properties.`, item.field);
|
|
179
|
+
}
|
|
180
|
+
for (const [key, value] of entries) {
|
|
181
|
+
if (Buffer.byteLength(key) > MAX_SCHEMA_KEY_BYTES) {
|
|
182
|
+
requestFailure(`${item.field} has an oversized keyword or property name.`, item.field);
|
|
183
|
+
}
|
|
184
|
+
const field = `${item.field}.${key}`;
|
|
185
|
+
if (UNSAFE_REGEX_SCHEMA_KEYWORDS[key] === true) {
|
|
186
|
+
requestFailure(
|
|
187
|
+
`${field} is forbidden because regular-expression schemas are not accepted.`,
|
|
188
|
+
field
|
|
189
|
+
);
|
|
190
|
+
}
|
|
191
|
+
stack.push({ value, field });
|
|
192
|
+
}
|
|
193
|
+
}
|
|
194
|
+
}
|
|
195
|
+
function deepFreezeJson(value: unknown): void {
|
|
196
|
+
if (typeof value !== 'object' || value === null || Object.isFrozen(value)) return;
|
|
197
|
+
if (Array.isArray(value)) {
|
|
198
|
+
value.forEach((child) => deepFreezeJson(child));
|
|
199
|
+
} else if (isRecord(value)) {
|
|
200
|
+
Object.values(value).forEach((child) => deepFreezeJson(child));
|
|
201
|
+
}
|
|
202
|
+
Object.freeze(value);
|
|
203
|
+
}
|
|
204
|
+
/** @returns A deeply frozen boolean or object JSON Schema snapshot. */
|
|
205
|
+
export function immutableJsonSnapshot(value: unknown): boolean | Readonly<Record<string, unknown>> {
|
|
206
|
+
const encoded: unknown = JSON.stringify(value);
|
|
207
|
+
if (typeof encoded !== 'string') {
|
|
208
|
+
requestFailure('request.outputSchema is not JSON serializable.');
|
|
209
|
+
}
|
|
210
|
+
const parsed: unknown = JSON.parse(encoded);
|
|
211
|
+
if (typeof parsed !== 'boolean' && !isRecord(parsed)) {
|
|
212
|
+
requestFailure('request.outputSchema must be a JSON Schema object or boolean.');
|
|
213
|
+
}
|
|
214
|
+
deepFreezeJson(parsed);
|
|
215
|
+
return parsed;
|
|
216
|
+
}
|
|
217
|
+
export function schemaValidator(
|
|
218
|
+
schema: boolean | Readonly<Record<string, unknown>>
|
|
219
|
+
): (value: unknown) => boolean {
|
|
220
|
+
try {
|
|
221
|
+
const validate = new Ajv({
|
|
222
|
+
allErrors: true,
|
|
223
|
+
coerceTypes: false,
|
|
224
|
+
strict: false,
|
|
225
|
+
validateFormats: false,
|
|
226
|
+
}).compile(schema);
|
|
227
|
+
return (value: unknown): boolean => validate(value) === true;
|
|
228
|
+
} catch {
|
|
229
|
+
return requestFailure(
|
|
230
|
+
'request.outputSchema must be a valid JSON Schema.',
|
|
231
|
+
'request.outputSchema'
|
|
232
|
+
);
|
|
233
|
+
}
|
|
234
|
+
}
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
export {
|
|
2
|
+
OMP_SDK_BACKEND_VERSION,
|
|
3
|
+
OMP_SDK_BUN_VERSION,
|
|
4
|
+
OMP_SDK_ERROR_CODES,
|
|
5
|
+
OMP_SDK_MAX_CREDENTIAL_BYTES,
|
|
6
|
+
OMP_SDK_MAX_FRAME_BYTES,
|
|
7
|
+
OMP_SDK_MAX_REQUEST_BYTES,
|
|
8
|
+
OMP_SDK_MAX_STDOUT_BYTES,
|
|
9
|
+
OMP_SDK_PROGRESS_STAGES,
|
|
10
|
+
OMP_SDK_PROTOCOL_VERSION,
|
|
11
|
+
OMP_SDK_TEXT_OUTPUT_SCHEMA,
|
|
12
|
+
OMP_SDK_TOOL_IDS,
|
|
13
|
+
} from './sdk-protocol-types';
|
|
14
|
+
export type {
|
|
15
|
+
OmpSdkCollectedTerminal,
|
|
16
|
+
OmpSdkErrorCategory,
|
|
17
|
+
OmpSdkErrorCode,
|
|
18
|
+
OmpSdkExecutionContext,
|
|
19
|
+
OmpSdkJsonSidecarRequest,
|
|
20
|
+
OmpSdkModelsConfig,
|
|
21
|
+
OmpSdkOutputMode,
|
|
22
|
+
OmpSdkProgressStage,
|
|
23
|
+
OmpSdkProtocolCollector,
|
|
24
|
+
OmpSdkProtocolCollectorOptions,
|
|
25
|
+
OmpSdkProtocolErrorFrame,
|
|
26
|
+
OmpSdkProtocolFrame,
|
|
27
|
+
OmpSdkProtocolProgressFrame,
|
|
28
|
+
OmpSdkProtocolResultFrame,
|
|
29
|
+
OmpSdkProtocolTerminalFrame,
|
|
30
|
+
OmpSdkRequestAuth,
|
|
31
|
+
OmpSdkSafeError,
|
|
32
|
+
OmpSdkSidecarRequest,
|
|
33
|
+
OmpSdkTextSidecarRequest,
|
|
34
|
+
OmpSdkToolId,
|
|
35
|
+
} from './sdk-protocol-types';
|
|
36
|
+
export {
|
|
37
|
+
decodeOmpSdkSidecarRequest,
|
|
38
|
+
ompSdkOutputSchemaForRequest,
|
|
39
|
+
parseOmpSdkSidecarRequest,
|
|
40
|
+
} from './sdk-protocol-request';
|
|
41
|
+
export { decodeOmpSdkProtocolFrame, parseOmpSdkProtocolFrame } from './sdk-protocol-frame';
|
|
42
|
+
export {
|
|
43
|
+
normalizeOmpSdkResultFrame,
|
|
44
|
+
validateOmpSdkProtocolResultFrame,
|
|
45
|
+
} from './sdk-protocol-result';
|
|
46
|
+
export { createOmpSdkProtocolCollector } from './sdk-protocol-collector';
|
|
@@ -0,0 +1,159 @@
|
|
|
1
|
+
import { resolve } from 'node:path';
|
|
2
|
+
import { isRecord } from '../json';
|
|
3
|
+
|
|
4
|
+
export const OMP_SDK_HOST_SUPERVISOR_PROTOCOL_VERSION = 1 as const;
|
|
5
|
+
export const OMP_SDK_MAX_SUPERVISOR_ATTESTATION_BYTES = 8 * 1024;
|
|
6
|
+
|
|
7
|
+
export interface OmpSdkSupervisorSemanticOutcome {
|
|
8
|
+
readonly exitCode: number | null;
|
|
9
|
+
readonly signal: string | null;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
export interface OmpSdkSupervisorCleanAttestation {
|
|
13
|
+
readonly protocolVersion: typeof OMP_SDK_HOST_SUPERVISOR_PROTOCOL_VERSION;
|
|
14
|
+
readonly type: 'cleanup-attestation';
|
|
15
|
+
readonly status: 'clean';
|
|
16
|
+
readonly mode: 'linux-subreaper-pidfd';
|
|
17
|
+
readonly subreaper: true;
|
|
18
|
+
readonly pidfd: true;
|
|
19
|
+
readonly terminalBuffered: true;
|
|
20
|
+
readonly ownedProcessCount: 0;
|
|
21
|
+
readonly cancelled: boolean;
|
|
22
|
+
readonly semantic: OmpSdkSupervisorSemanticOutcome;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
export interface OmpSdkSupervisorErrorAttestation {
|
|
26
|
+
readonly protocolVersion: typeof OMP_SDK_HOST_SUPERVISOR_PROTOCOL_VERSION;
|
|
27
|
+
readonly type: 'cleanup-attestation';
|
|
28
|
+
readonly status: 'error';
|
|
29
|
+
readonly code: 'capability-unavailable' | 'cleanup-uncertain' | 'invalid-invocation';
|
|
30
|
+
readonly semanticStarted: boolean;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
export type OmpSdkSupervisorAttestation =
|
|
34
|
+
| OmpSdkSupervisorCleanAttestation
|
|
35
|
+
| OmpSdkSupervisorErrorAttestation;
|
|
36
|
+
|
|
37
|
+
|
|
38
|
+
function compareKeys(left: string, right: string): number {
|
|
39
|
+
if (left < right) return -1;
|
|
40
|
+
if (left > right) return 1;
|
|
41
|
+
return 0;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
function hasExactKeys(value: Record<string, unknown>, expected: readonly string[]): boolean {
|
|
45
|
+
const actual = Object.keys(value).sort(compareKeys);
|
|
46
|
+
const keys = [...expected].sort(compareKeys);
|
|
47
|
+
return actual.length === keys.length && actual.every((key, index) => key === keys[index]);
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
function isExitCode(value: unknown): value is number | null {
|
|
51
|
+
return (
|
|
52
|
+
value === null ||
|
|
53
|
+
(typeof value === 'number' && Number.isSafeInteger(value) && value >= 0 && value <= 255)
|
|
54
|
+
);
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
function isSignal(value: unknown): value is string | null {
|
|
58
|
+
return value === null || (typeof value === 'string' && /^SIG[A-Z0-9]+$/u.test(value));
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
function isSupervisorErrorCode(
|
|
62
|
+
value: unknown
|
|
63
|
+
): value is OmpSdkSupervisorErrorAttestation['code'] {
|
|
64
|
+
return (
|
|
65
|
+
value === 'capability-unavailable' ||
|
|
66
|
+
value === 'cleanup-uncertain' ||
|
|
67
|
+
value === 'invalid-invocation'
|
|
68
|
+
);
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
function isSupervisorSemanticOutcome(value: unknown): value is OmpSdkSupervisorSemanticOutcome {
|
|
72
|
+
if (
|
|
73
|
+
!isRecord(value) ||
|
|
74
|
+
!hasExactKeys(value, ['exitCode', 'signal']) ||
|
|
75
|
+
!isExitCode(value.exitCode) ||
|
|
76
|
+
!isSignal(value.signal)
|
|
77
|
+
) {
|
|
78
|
+
return false;
|
|
79
|
+
}
|
|
80
|
+
return (value.exitCode === null) !== (value.signal === null);
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
function isSupervisorErrorAttestation(
|
|
84
|
+
value: unknown
|
|
85
|
+
): value is OmpSdkSupervisorErrorAttestation {
|
|
86
|
+
return (
|
|
87
|
+
isRecord(value) &&
|
|
88
|
+
hasExactKeys(value, ['protocolVersion', 'type', 'status', 'code', 'semanticStarted']) &&
|
|
89
|
+
value.protocolVersion === OMP_SDK_HOST_SUPERVISOR_PROTOCOL_VERSION &&
|
|
90
|
+
value.type === 'cleanup-attestation' &&
|
|
91
|
+
value.status === 'error' &&
|
|
92
|
+
isSupervisorErrorCode(value.code) &&
|
|
93
|
+
typeof value.semanticStarted === 'boolean'
|
|
94
|
+
);
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
function isSupervisorCleanAttestation(
|
|
98
|
+
value: unknown
|
|
99
|
+
): value is OmpSdkSupervisorCleanAttestation {
|
|
100
|
+
return (
|
|
101
|
+
isRecord(value) &&
|
|
102
|
+
hasExactKeys(value, [
|
|
103
|
+
'protocolVersion',
|
|
104
|
+
'type',
|
|
105
|
+
'status',
|
|
106
|
+
'mode',
|
|
107
|
+
'subreaper',
|
|
108
|
+
'pidfd',
|
|
109
|
+
'terminalBuffered',
|
|
110
|
+
'ownedProcessCount',
|
|
111
|
+
'cancelled',
|
|
112
|
+
'semantic',
|
|
113
|
+
]) &&
|
|
114
|
+
value.protocolVersion === OMP_SDK_HOST_SUPERVISOR_PROTOCOL_VERSION &&
|
|
115
|
+
value.type === 'cleanup-attestation' &&
|
|
116
|
+
value.status === 'clean' &&
|
|
117
|
+
value.mode === 'linux-subreaper-pidfd' &&
|
|
118
|
+
value.subreaper === true &&
|
|
119
|
+
value.pidfd === true &&
|
|
120
|
+
value.terminalBuffered === true &&
|
|
121
|
+
value.ownedProcessCount === 0 &&
|
|
122
|
+
typeof value.cancelled === 'boolean' &&
|
|
123
|
+
isSupervisorSemanticOutcome(value.semantic)
|
|
124
|
+
);
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
export function parseOmpSdkSupervisorAttestation(bytes: Buffer): OmpSdkSupervisorAttestation {
|
|
128
|
+
if (bytes.byteLength === 0 || bytes.byteLength > OMP_SDK_MAX_SUPERVISOR_ATTESTATION_BYTES) {
|
|
129
|
+
throw new Error('OMP SDK supervisor attestation size is invalid.');
|
|
130
|
+
}
|
|
131
|
+
const source = bytes.toString('utf8');
|
|
132
|
+
if (!source.endsWith('\n') || source.slice(0, -1).includes('\n')) {
|
|
133
|
+
throw new Error('OMP SDK supervisor must emit exactly one attestation frame.');
|
|
134
|
+
}
|
|
135
|
+
let parsed: unknown;
|
|
136
|
+
try {
|
|
137
|
+
parsed = JSON.parse(source.slice(0, -1));
|
|
138
|
+
} catch {
|
|
139
|
+
throw new Error('OMP SDK supervisor attestation is malformed.');
|
|
140
|
+
}
|
|
141
|
+
if (!isRecord(parsed) || parsed.protocolVersion !== OMP_SDK_HOST_SUPERVISOR_PROTOCOL_VERSION ||
|
|
142
|
+
parsed.type !== 'cleanup-attestation' || (parsed.status !== 'clean' && parsed.status !== 'error')) {
|
|
143
|
+
throw new Error('OMP SDK supervisor attestation identity is invalid.');
|
|
144
|
+
}
|
|
145
|
+
if (parsed.status === 'error') {
|
|
146
|
+
if (!isSupervisorErrorAttestation(parsed)) {
|
|
147
|
+
throw new Error('OMP SDK supervisor error attestation is invalid.');
|
|
148
|
+
}
|
|
149
|
+
return parsed;
|
|
150
|
+
}
|
|
151
|
+
if (!isSupervisorCleanAttestation(parsed)) {
|
|
152
|
+
throw new Error('OMP SDK supervisor clean attestation is invalid.');
|
|
153
|
+
}
|
|
154
|
+
return parsed;
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
export function resolveOmpSdkHostSupervisorPath(): string {
|
|
158
|
+
return resolve(__dirname, '..', '..', '..', 'scripts', 'omp', 'host-supervisor.ts');
|
|
159
|
+
}
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
import * as path from 'node:path';
|
|
2
|
+
|
|
3
|
+
import { invalidField } from '../contract-errors';
|
|
4
|
+
import { isRecord } from '../json';
|
|
5
|
+
import { ENV_NAME } from './sdk-settings-constants';
|
|
6
|
+
import type { OmpSdkAuth, OmpSettingsValidationContext } from './sdk-settings-types';
|
|
7
|
+
import { assertProviderId, enumValue, rejectUnknown } from './sdk-settings-values';
|
|
8
|
+
|
|
9
|
+
export function normalizeAuth(value: unknown, context: OmpSettingsValidationContext): OmpSdkAuth {
|
|
10
|
+
if (!isRecord(value)) {
|
|
11
|
+
invalidField('providerSettings.omp.auth', 'OMP auth must be a discriminated object.');
|
|
12
|
+
}
|
|
13
|
+
const mode = enumValue(
|
|
14
|
+
value.mode,
|
|
15
|
+
['environment', 'broker', 'omp-home', 'none'] as const,
|
|
16
|
+
'providerSettings.omp.auth.mode'
|
|
17
|
+
);
|
|
18
|
+
if (mode === 'environment') {
|
|
19
|
+
rejectUnknown(value, new Set(['mode', 'credentials']), 'providerSettings.omp.auth');
|
|
20
|
+
if (!isRecord(value.credentials) || Object.keys(value.credentials).length === 0) {
|
|
21
|
+
invalidField(
|
|
22
|
+
'providerSettings.omp.auth.credentials',
|
|
23
|
+
'Environment auth requires at least one provider credential reference.'
|
|
24
|
+
);
|
|
25
|
+
}
|
|
26
|
+
const credentials: Record<string, { env: string }> = {};
|
|
27
|
+
for (const [provider, credential] of Object.entries(value.credentials)) {
|
|
28
|
+
assertProviderId(provider, `providerSettings.omp.auth.credentials.${provider}`);
|
|
29
|
+
if (!isRecord(credential)) {
|
|
30
|
+
invalidField(
|
|
31
|
+
`providerSettings.omp.auth.credentials.${provider}`,
|
|
32
|
+
'Provider credential references must be objects.'
|
|
33
|
+
);
|
|
34
|
+
}
|
|
35
|
+
rejectUnknown(
|
|
36
|
+
credential,
|
|
37
|
+
new Set(['env']),
|
|
38
|
+
`providerSettings.omp.auth.credentials.${provider}`
|
|
39
|
+
);
|
|
40
|
+
if (typeof credential.env !== 'string' || !ENV_NAME.test(credential.env)) {
|
|
41
|
+
invalidField(
|
|
42
|
+
`providerSettings.omp.auth.credentials.${provider}.env`,
|
|
43
|
+
'Credential references must contain only a valid environment variable name.'
|
|
44
|
+
);
|
|
45
|
+
}
|
|
46
|
+
credentials[provider] = { env: credential.env };
|
|
47
|
+
}
|
|
48
|
+
return { mode, credentials };
|
|
49
|
+
}
|
|
50
|
+
if (mode === 'broker') {
|
|
51
|
+
rejectUnknown(value, new Set(['mode']), 'providerSettings.omp.auth');
|
|
52
|
+
return { mode };
|
|
53
|
+
}
|
|
54
|
+
if (mode === 'none') {
|
|
55
|
+
rejectUnknown(value, new Set(['mode']), 'providerSettings.omp.auth');
|
|
56
|
+
return { mode };
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
rejectUnknown(value, new Set(['mode', 'path']), 'providerSettings.omp.auth');
|
|
60
|
+
if (context.executionContext !== undefined && context.executionContext !== 'host') {
|
|
61
|
+
invalidField(
|
|
62
|
+
'providerSettings.omp.auth.mode',
|
|
63
|
+
'omp-home authentication is local host-only and forbidden for detached or Docker execution.'
|
|
64
|
+
);
|
|
65
|
+
}
|
|
66
|
+
if (
|
|
67
|
+
typeof value.path !== 'string' ||
|
|
68
|
+
!path.isAbsolute(value.path) ||
|
|
69
|
+
value.path.includes('\0') ||
|
|
70
|
+
value.path.trim() !== value.path
|
|
71
|
+
) {
|
|
72
|
+
invalidField(
|
|
73
|
+
'providerSettings.omp.auth.path',
|
|
74
|
+
'omp-home authentication requires an explicit absolute local path.'
|
|
75
|
+
);
|
|
76
|
+
}
|
|
77
|
+
return { mode, path: path.normalize(value.path) };
|
|
78
|
+
}
|