@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
|
@@ -0,0 +1,140 @@
|
|
|
1
|
+
import { TextDecoder } from 'node:util';
|
|
2
|
+
|
|
3
|
+
import { decodeOmpSdkProtocolFrame } from './sdk-protocol-frame';
|
|
4
|
+
import { parseOmpSdkSidecarRequest } from './sdk-protocol-request';
|
|
5
|
+
import { normalizeOmpSdkResultFrame } from './sdk-protocol-result';
|
|
6
|
+
import {
|
|
7
|
+
OMP_SDK_MAX_FRAME_BYTES,
|
|
8
|
+
OMP_SDK_MAX_STDOUT_BYTES,
|
|
9
|
+
type OmpSdkCollectedTerminal,
|
|
10
|
+
type OmpSdkProtocolCollector,
|
|
11
|
+
type OmpSdkProtocolCollectorOptions,
|
|
12
|
+
type OmpSdkProtocolProgressFrame,
|
|
13
|
+
type OmpSdkSidecarRequest,
|
|
14
|
+
type OmpSdkProtocolFrame,
|
|
15
|
+
} from './sdk-protocol-types';
|
|
16
|
+
import { protocolFailure } from './sdk-protocol-value';
|
|
17
|
+
|
|
18
|
+
class Collector implements OmpSdkProtocolCollector {
|
|
19
|
+
readonly #request: OmpSdkSidecarRequest;
|
|
20
|
+
readonly #maxFrame: number;
|
|
21
|
+
readonly #maxStdout: number;
|
|
22
|
+
readonly #decoder = new TextDecoder('utf-8', { fatal: true });
|
|
23
|
+
readonly #progress: OmpSdkProtocolProgressFrame[] = [];
|
|
24
|
+
#pending = '';
|
|
25
|
+
#bytes = 0;
|
|
26
|
+
#terminal: OmpSdkCollectedTerminal | undefined;
|
|
27
|
+
#closed = false;
|
|
28
|
+
#failed = false;
|
|
29
|
+
|
|
30
|
+
constructor(options: OmpSdkProtocolCollectorOptions) {
|
|
31
|
+
this.#request = parseOmpSdkSidecarRequest(options.request);
|
|
32
|
+
this.#maxFrame = limit(options.maxFrameBytes, OMP_SDK_MAX_FRAME_BYTES, 'maxFrameBytes');
|
|
33
|
+
this.#maxStdout = limit(options.maxStdoutBytes, OMP_SDK_MAX_STDOUT_BYTES, 'maxStdoutBytes');
|
|
34
|
+
}
|
|
35
|
+
get progress(): readonly OmpSdkProtocolProgressFrame[] {
|
|
36
|
+
return this.#progress;
|
|
37
|
+
}
|
|
38
|
+
write(chunk: string | Uint8Array): readonly OmpSdkProtocolFrame[] {
|
|
39
|
+
this.#writable();
|
|
40
|
+
const bytes = typeof chunk === 'string' ? Buffer.from(chunk) : Buffer.from(chunk);
|
|
41
|
+
if (this.#terminal !== undefined && bytes.byteLength > 0) {
|
|
42
|
+
return this.#fail('data follows terminal frame.');
|
|
43
|
+
}
|
|
44
|
+
this.#bytes += bytes.byteLength;
|
|
45
|
+
if (this.#bytes > this.#maxStdout) return this.#fail('stdout is oversized.');
|
|
46
|
+
try {
|
|
47
|
+
this.#pending += this.#decoder.decode(bytes, { stream: true });
|
|
48
|
+
} catch {
|
|
49
|
+
return this.#fail('stdout is not valid UTF-8.');
|
|
50
|
+
}
|
|
51
|
+
try {
|
|
52
|
+
return this.#drain(false);
|
|
53
|
+
} catch (error) {
|
|
54
|
+
this.#failed = true;
|
|
55
|
+
throw error;
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
finish(exitCode: number): OmpSdkCollectedTerminal {
|
|
59
|
+
this.#writable();
|
|
60
|
+
if (!Number.isInteger(exitCode) || exitCode < 0)
|
|
61
|
+
return this.#fail('invalid sidecar exit code.');
|
|
62
|
+
try {
|
|
63
|
+
this.#pending += this.#decoder.decode();
|
|
64
|
+
} catch {
|
|
65
|
+
return this.#fail('stdout is not valid UTF-8.');
|
|
66
|
+
}
|
|
67
|
+
try {
|
|
68
|
+
this.#drain(true);
|
|
69
|
+
} catch (error) {
|
|
70
|
+
this.#failed = true;
|
|
71
|
+
throw error;
|
|
72
|
+
}
|
|
73
|
+
if (this.#terminal === undefined) return this.#fail('missing terminal frame.');
|
|
74
|
+
if (this.#terminal.type === 'result' && exitCode !== 0)
|
|
75
|
+
return this.#fail('result requires exit zero.');
|
|
76
|
+
if (this.#terminal.type === 'error' && exitCode === 0)
|
|
77
|
+
return this.#fail('error requires nonzero exit.');
|
|
78
|
+
this.#closed = true;
|
|
79
|
+
return this.#terminal;
|
|
80
|
+
}
|
|
81
|
+
#writable(): void {
|
|
82
|
+
if (this.#failed) protocolFailure('collector is failed.');
|
|
83
|
+
if (this.#closed) protocolFailure('collector is finished.');
|
|
84
|
+
}
|
|
85
|
+
#drain(final: boolean): readonly OmpSdkProtocolFrame[] {
|
|
86
|
+
const frames: OmpSdkProtocolFrame[] = [];
|
|
87
|
+
let newline = this.#pending.indexOf('\n');
|
|
88
|
+
while (newline >= 0) {
|
|
89
|
+
const line = this.#pending.slice(0, newline);
|
|
90
|
+
this.#pending = this.#pending.slice(newline + 1);
|
|
91
|
+
frames.push(this.#accept(line));
|
|
92
|
+
newline = this.#pending.indexOf('\n');
|
|
93
|
+
}
|
|
94
|
+
if (final && this.#pending.length > 0) {
|
|
95
|
+
const line = this.#pending;
|
|
96
|
+
this.#pending = '';
|
|
97
|
+
frames.push(this.#accept(line));
|
|
98
|
+
} else if (Buffer.byteLength(this.#pending) > this.#maxFrame) {
|
|
99
|
+
return this.#fail('frame is oversized.');
|
|
100
|
+
}
|
|
101
|
+
return frames;
|
|
102
|
+
}
|
|
103
|
+
#accept(line: string): OmpSdkProtocolFrame {
|
|
104
|
+
if (this.#terminal !== undefined) return this.#fail('data follows terminal frame.');
|
|
105
|
+
const bytes = Buffer.byteLength(line);
|
|
106
|
+
if (bytes === 0 || bytes > this.#maxFrame) return this.#fail('frame has invalid byte length.');
|
|
107
|
+
const frame = decodeOmpSdkProtocolFrame(line);
|
|
108
|
+
if (frame.runId !== this.#request.runId)
|
|
109
|
+
return this.#fail('frame.runId does not match request.');
|
|
110
|
+
if (frame.type === 'progress') {
|
|
111
|
+
if (frame.sequence !== this.#progress.length) return this.#fail('invalid progress sequence.');
|
|
112
|
+
this.#progress.push(frame);
|
|
113
|
+
} else if (frame.type === 'result') {
|
|
114
|
+
this.#terminal = {
|
|
115
|
+
type: 'result',
|
|
116
|
+
frame,
|
|
117
|
+
event: normalizeOmpSdkResultFrame(frame, this.#request),
|
|
118
|
+
};
|
|
119
|
+
} else {
|
|
120
|
+
this.#terminal = { type: 'error', frame };
|
|
121
|
+
}
|
|
122
|
+
return frame;
|
|
123
|
+
}
|
|
124
|
+
#fail(message: string): never {
|
|
125
|
+
this.#failed = true;
|
|
126
|
+
return protocolFailure(message);
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
function limit(value: number | undefined, fallback: number, field: string): number {
|
|
130
|
+
if (value === undefined) return fallback;
|
|
131
|
+
if (!Number.isSafeInteger(value) || value <= 0 || value > fallback) {
|
|
132
|
+
protocolFailure(`${field} must be a positive integer no greater than ${fallback}.`);
|
|
133
|
+
}
|
|
134
|
+
return value;
|
|
135
|
+
}
|
|
136
|
+
export function createOmpSdkProtocolCollector(
|
|
137
|
+
options: OmpSdkProtocolCollectorOptions
|
|
138
|
+
): OmpSdkProtocolCollector {
|
|
139
|
+
return new Collector(options);
|
|
140
|
+
}
|
|
@@ -0,0 +1,260 @@
|
|
|
1
|
+
import { OMP_SDK_REASONING_EFFORTS } from './sdk-settings';
|
|
2
|
+
import type {
|
|
3
|
+
OmpSdkRequestedIdentity,
|
|
4
|
+
OmpSdkStrictOutputEvidence,
|
|
5
|
+
OmpSdkTerminalEvidence,
|
|
6
|
+
OmpSdkUsageEvidence,
|
|
7
|
+
} from '../types';
|
|
8
|
+
import {
|
|
9
|
+
CATEGORY,
|
|
10
|
+
OMP_SDK_BACKEND_VERSION,
|
|
11
|
+
OMP_SDK_BUN_VERSION,
|
|
12
|
+
OMP_SDK_ERROR_CODES,
|
|
13
|
+
OMP_SDK_MAX_FRAME_BYTES,
|
|
14
|
+
OMP_SDK_PROGRESS_STAGES,
|
|
15
|
+
type OmpSdkProtocolErrorFrame,
|
|
16
|
+
type OmpSdkProtocolFrame,
|
|
17
|
+
type OmpSdkProtocolProgressFrame,
|
|
18
|
+
type OmpSdkProtocolResultFrame,
|
|
19
|
+
} from './sdk-protocol-types';
|
|
20
|
+
import { decode } from './sdk-protocol-request';
|
|
21
|
+
import {
|
|
22
|
+
exact,
|
|
23
|
+
includesLiteral,
|
|
24
|
+
isRecord,
|
|
25
|
+
json,
|
|
26
|
+
literal,
|
|
27
|
+
number,
|
|
28
|
+
parseRunId,
|
|
29
|
+
protocolFailure,
|
|
30
|
+
selector,
|
|
31
|
+
serializedLimit,
|
|
32
|
+
} from './sdk-protocol-value';
|
|
33
|
+
|
|
34
|
+
function backend(value: unknown): OmpSdkTerminalEvidence['backend'] {
|
|
35
|
+
if (!isRecord(value)) protocolFailure('frame.backend must be an object.');
|
|
36
|
+
exact(value, ['id', 'version'], [], 'frame.backend', protocolFailure);
|
|
37
|
+
literal(value.id, 'omp-sdk', 'frame.backend.id', protocolFailure);
|
|
38
|
+
literal(value.version, OMP_SDK_BACKEND_VERSION, 'frame.backend.version', protocolFailure);
|
|
39
|
+
return { id: 'omp-sdk', version: OMP_SDK_BACKEND_VERSION };
|
|
40
|
+
}
|
|
41
|
+
function runtime(value: unknown): OmpSdkTerminalEvidence['runtime'] {
|
|
42
|
+
if (!isRecord(value)) protocolFailure('frame.runtime must be an object.');
|
|
43
|
+
exact(value, ['name', 'version'], [], 'frame.runtime', protocolFailure);
|
|
44
|
+
literal(value.name, 'bun', 'frame.runtime.name', protocolFailure);
|
|
45
|
+
literal(value.version, OMP_SDK_BUN_VERSION, 'frame.runtime.version', protocolFailure);
|
|
46
|
+
return { name: 'bun', version: OMP_SDK_BUN_VERSION };
|
|
47
|
+
}
|
|
48
|
+
function requested(value: unknown): OmpSdkRequestedIdentity {
|
|
49
|
+
if (!isRecord(value)) protocolFailure('frame.requested must be an object.');
|
|
50
|
+
exact(
|
|
51
|
+
value,
|
|
52
|
+
['modelSelector', 'reasoningEffort', 'outputMode'],
|
|
53
|
+
[],
|
|
54
|
+
'frame.requested',
|
|
55
|
+
protocolFailure
|
|
56
|
+
);
|
|
57
|
+
const modelSelector = selector(
|
|
58
|
+
value.modelSelector,
|
|
59
|
+
'frame.requested.modelSelector',
|
|
60
|
+
protocolFailure
|
|
61
|
+
);
|
|
62
|
+
if (!includesLiteral(OMP_SDK_REASONING_EFFORTS, value.reasoningEffort))
|
|
63
|
+
protocolFailure('invalid requested effort.');
|
|
64
|
+
if (value.outputMode !== 'json' && value.outputMode !== 'text')
|
|
65
|
+
protocolFailure('invalid requested mode.');
|
|
66
|
+
return { modelSelector, reasoningEffort: value.reasoningEffort, outputMode: value.outputMode };
|
|
67
|
+
}
|
|
68
|
+
function strictOutput(value: unknown): OmpSdkStrictOutputEvidence {
|
|
69
|
+
if (!isRecord(value)) protocolFailure('frame.strictOutput must be an object.');
|
|
70
|
+
exact(
|
|
71
|
+
value,
|
|
72
|
+
['source', 'mode', 'status', 'yieldCount'],
|
|
73
|
+
[],
|
|
74
|
+
'frame.strictOutput',
|
|
75
|
+
protocolFailure
|
|
76
|
+
);
|
|
77
|
+
literal(value.source, 'caller', 'frame.strictOutput.source', protocolFailure);
|
|
78
|
+
literal(value.mode, 'strict', 'frame.strictOutput.mode', protocolFailure);
|
|
79
|
+
literal(value.status, 'valid', 'frame.strictOutput.status', protocolFailure);
|
|
80
|
+
literal(value.yieldCount, 1, 'frame.strictOutput.yieldCount', protocolFailure);
|
|
81
|
+
return { source: 'caller', mode: 'strict', status: 'valid', yieldCount: 1 };
|
|
82
|
+
}
|
|
83
|
+
function usage(value: unknown): OmpSdkUsageEvidence {
|
|
84
|
+
if (!isRecord(value)) protocolFailure('frame.usage must be an object.');
|
|
85
|
+
exact(
|
|
86
|
+
value,
|
|
87
|
+
[
|
|
88
|
+
'source',
|
|
89
|
+
'completeness',
|
|
90
|
+
'inputTokens',
|
|
91
|
+
'outputTokens',
|
|
92
|
+
'cacheReadInputTokens',
|
|
93
|
+
'cacheCreationInputTokens',
|
|
94
|
+
'totalTokens',
|
|
95
|
+
'requests',
|
|
96
|
+
'durationMs',
|
|
97
|
+
'cost',
|
|
98
|
+
],
|
|
99
|
+
[],
|
|
100
|
+
'frame.usage',
|
|
101
|
+
protocolFailure
|
|
102
|
+
);
|
|
103
|
+
literal(value.source, 'omp-aggregate', 'frame.usage.source', protocolFailure);
|
|
104
|
+
literal(value.completeness, 'unknown', 'frame.usage.completeness', protocolFailure);
|
|
105
|
+
if (!isRecord(value.cost)) protocolFailure('frame.usage.cost must be an object.');
|
|
106
|
+
exact(
|
|
107
|
+
value.cost,
|
|
108
|
+
['input', 'output', 'cacheRead', 'cacheWrite', 'total'],
|
|
109
|
+
[],
|
|
110
|
+
'frame.usage.cost',
|
|
111
|
+
protocolFailure
|
|
112
|
+
);
|
|
113
|
+
return {
|
|
114
|
+
source: 'omp-aggregate',
|
|
115
|
+
completeness: 'unknown',
|
|
116
|
+
inputTokens: number(value.inputTokens, 'frame.usage.inputTokens', true),
|
|
117
|
+
outputTokens: number(value.outputTokens, 'frame.usage.outputTokens', true),
|
|
118
|
+
cacheReadInputTokens: number(
|
|
119
|
+
value.cacheReadInputTokens,
|
|
120
|
+
'frame.usage.cacheReadInputTokens',
|
|
121
|
+
true
|
|
122
|
+
),
|
|
123
|
+
cacheCreationInputTokens: number(
|
|
124
|
+
value.cacheCreationInputTokens,
|
|
125
|
+
'frame.usage.cacheCreationInputTokens',
|
|
126
|
+
true
|
|
127
|
+
),
|
|
128
|
+
totalTokens: number(value.totalTokens, 'frame.usage.totalTokens', true),
|
|
129
|
+
requests: number(value.requests, 'frame.usage.requests', true),
|
|
130
|
+
durationMs: number(value.durationMs, 'frame.usage.durationMs', false),
|
|
131
|
+
cost: {
|
|
132
|
+
input: number(value.cost.input, 'frame.usage.cost.input', false),
|
|
133
|
+
output: number(value.cost.output, 'frame.usage.cost.output', false),
|
|
134
|
+
cacheRead: number(value.cost.cacheRead, 'frame.usage.cost.cacheRead', false),
|
|
135
|
+
cacheWrite: number(value.cost.cacheWrite, 'frame.usage.cost.cacheWrite', false),
|
|
136
|
+
total: number(value.cost.total, 'frame.usage.cost.total', false),
|
|
137
|
+
},
|
|
138
|
+
};
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
function resultFrame(value: Record<string, unknown>): OmpSdkProtocolResultFrame {
|
|
142
|
+
exact(
|
|
143
|
+
value,
|
|
144
|
+
[
|
|
145
|
+
'protocolVersion',
|
|
146
|
+
'type',
|
|
147
|
+
'runId',
|
|
148
|
+
'backend',
|
|
149
|
+
'runtime',
|
|
150
|
+
'requested',
|
|
151
|
+
'resolved',
|
|
152
|
+
'strictOutput',
|
|
153
|
+
'fallback',
|
|
154
|
+
'execution',
|
|
155
|
+
'value',
|
|
156
|
+
'usage',
|
|
157
|
+
],
|
|
158
|
+
[],
|
|
159
|
+
'frame',
|
|
160
|
+
protocolFailure
|
|
161
|
+
);
|
|
162
|
+
literal(value.protocolVersion, 1, 'frame.protocolVersion', protocolFailure);
|
|
163
|
+
literal(value.type, 'result', 'frame.type', protocolFailure);
|
|
164
|
+
const runId = parseRunId(value.runId, 'frame.runId', protocolFailure);
|
|
165
|
+
const parsedRequested = requested(value.requested);
|
|
166
|
+
if (!isRecord(value.resolved)) protocolFailure('frame.resolved must be an object.');
|
|
167
|
+
exact(value.resolved, ['modelSelector'], [], 'frame.resolved', protocolFailure);
|
|
168
|
+
const resolved = {
|
|
169
|
+
modelSelector: selector(
|
|
170
|
+
value.resolved.modelSelector,
|
|
171
|
+
'frame.resolved.modelSelector',
|
|
172
|
+
protocolFailure
|
|
173
|
+
),
|
|
174
|
+
};
|
|
175
|
+
const parsedStrict = strictOutput(value.strictOutput);
|
|
176
|
+
literal(value.fallback, false, 'frame.fallback', protocolFailure);
|
|
177
|
+
if (!isRecord(value.execution)) protocolFailure('frame.execution must be an object.');
|
|
178
|
+
exact(value.execution, ['exitCode', 'aborted'], [], 'frame.execution', protocolFailure);
|
|
179
|
+
literal(value.execution.exitCode, 0, 'frame.execution.exitCode', protocolFailure);
|
|
180
|
+
literal(value.execution.aborted, false, 'frame.execution.aborted', protocolFailure);
|
|
181
|
+
json(value.value, 'frame.value', protocolFailure);
|
|
182
|
+
return {
|
|
183
|
+
protocolVersion: 1,
|
|
184
|
+
type: 'result',
|
|
185
|
+
runId,
|
|
186
|
+
backend: backend(value.backend),
|
|
187
|
+
runtime: runtime(value.runtime),
|
|
188
|
+
requested: parsedRequested,
|
|
189
|
+
resolved,
|
|
190
|
+
strictOutput: parsedStrict,
|
|
191
|
+
fallback: false,
|
|
192
|
+
execution: { exitCode: 0, aborted: false },
|
|
193
|
+
value: value.value,
|
|
194
|
+
usage: usage(value.usage),
|
|
195
|
+
};
|
|
196
|
+
}
|
|
197
|
+
function errorFrame(value: Record<string, unknown>): OmpSdkProtocolErrorFrame {
|
|
198
|
+
exact(
|
|
199
|
+
value,
|
|
200
|
+
['protocolVersion', 'type', 'runId', 'backend', 'runtime', 'error'],
|
|
201
|
+
[],
|
|
202
|
+
'frame',
|
|
203
|
+
protocolFailure
|
|
204
|
+
);
|
|
205
|
+
literal(value.protocolVersion, 1, 'frame.protocolVersion', protocolFailure);
|
|
206
|
+
literal(value.type, 'error', 'frame.type', protocolFailure);
|
|
207
|
+
const runId = parseRunId(value.runId, 'frame.runId', protocolFailure);
|
|
208
|
+
if (!isRecord(value.error)) protocolFailure('frame.error must be an object.');
|
|
209
|
+
exact(
|
|
210
|
+
value.error,
|
|
211
|
+
['code', 'category', 'retryable', 'redacted'],
|
|
212
|
+
[],
|
|
213
|
+
'frame.error',
|
|
214
|
+
protocolFailure
|
|
215
|
+
);
|
|
216
|
+
if (!includesLiteral(OMP_SDK_ERROR_CODES, value.error.code))
|
|
217
|
+
protocolFailure('frame.error.code is unsupported.');
|
|
218
|
+
const code = value.error.code;
|
|
219
|
+
const category = CATEGORY[code];
|
|
220
|
+
literal(value.error.category, category, 'frame.error.category', protocolFailure);
|
|
221
|
+
if (typeof value.error.retryable !== 'boolean')
|
|
222
|
+
protocolFailure('frame.error.retryable must be boolean.');
|
|
223
|
+
literal(value.error.redacted, true, 'frame.error.redacted', protocolFailure);
|
|
224
|
+
return {
|
|
225
|
+
protocolVersion: 1,
|
|
226
|
+
type: 'error',
|
|
227
|
+
runId,
|
|
228
|
+
backend: backend(value.backend),
|
|
229
|
+
runtime: runtime(value.runtime),
|
|
230
|
+
error: { code, category, retryable: value.error.retryable, redacted: true },
|
|
231
|
+
};
|
|
232
|
+
}
|
|
233
|
+
function progressFrame(value: Record<string, unknown>): OmpSdkProtocolProgressFrame {
|
|
234
|
+
exact(
|
|
235
|
+
value,
|
|
236
|
+
['protocolVersion', 'type', 'runId', 'sequence', 'stage'],
|
|
237
|
+
[],
|
|
238
|
+
'frame',
|
|
239
|
+
protocolFailure
|
|
240
|
+
);
|
|
241
|
+
literal(value.protocolVersion, 1, 'frame.protocolVersion', protocolFailure);
|
|
242
|
+
literal(value.type, 'progress', 'frame.type', protocolFailure);
|
|
243
|
+
const runId = parseRunId(value.runId, 'frame.runId', protocolFailure);
|
|
244
|
+
const sequence = number(value.sequence, 'frame.sequence', true);
|
|
245
|
+
if (!includesLiteral(OMP_SDK_PROGRESS_STAGES, value.stage))
|
|
246
|
+
protocolFailure('frame.stage is unsupported.');
|
|
247
|
+
return { protocolVersion: 1, type: 'progress', runId, sequence, stage: value.stage };
|
|
248
|
+
}
|
|
249
|
+
|
|
250
|
+
export function parseOmpSdkProtocolFrame(value: unknown): OmpSdkProtocolFrame {
|
|
251
|
+
if (!isRecord(value)) protocolFailure('frame must be an object.');
|
|
252
|
+
serializedLimit(value, OMP_SDK_MAX_FRAME_BYTES, 'frame', protocolFailure);
|
|
253
|
+
if (value.type === 'progress') return progressFrame(value);
|
|
254
|
+
if (value.type === 'result') return resultFrame(value);
|
|
255
|
+
if (value.type === 'error') return errorFrame(value);
|
|
256
|
+
return protocolFailure('frame.type is unsupported.', 'frame.type');
|
|
257
|
+
}
|
|
258
|
+
export function decodeOmpSdkProtocolFrame(line: string | Uint8Array): OmpSdkProtocolFrame {
|
|
259
|
+
return parseOmpSdkProtocolFrame(decode(line, OMP_SDK_MAX_FRAME_BYTES, 'frame', protocolFailure));
|
|
260
|
+
}
|
|
@@ -0,0 +1,181 @@
|
|
|
1
|
+
import * as path from 'node:path';
|
|
2
|
+
import { TextDecoder } from 'node:util';
|
|
3
|
+
|
|
4
|
+
import {
|
|
5
|
+
normalizeOmpSdkSettings,
|
|
6
|
+
OMP_SDK_REASONING_EFFORTS,
|
|
7
|
+
OMP_SDK_SETTINGS_DEFAULTS,
|
|
8
|
+
} from './sdk-settings';
|
|
9
|
+
import type { ConfiguredOmpSdkSettings } from './sdk-settings';
|
|
10
|
+
import type { ReasoningEffort } from '../types';
|
|
11
|
+
const MAX_PATH_BYTES = 16 * 1024;
|
|
12
|
+
const MAX_PROMPT_BYTES = 4 * 1024 * 1024;
|
|
13
|
+
const MAX_CONTEXT_BYTES = 1024 * 1024;
|
|
14
|
+
import {
|
|
15
|
+
OMP_SDK_EXECUTION_CONTEXTS,
|
|
16
|
+
OMP_SDK_MAX_REQUEST_BYTES,
|
|
17
|
+
OMP_SDK_TEXT_OUTPUT_SCHEMA,
|
|
18
|
+
type OmpSdkExecutionContext,
|
|
19
|
+
type OmpSdkSidecarRequest,
|
|
20
|
+
} from './sdk-protocol-types';
|
|
21
|
+
import {
|
|
22
|
+
exact,
|
|
23
|
+
immutableJsonSnapshot,
|
|
24
|
+
includesLiteral,
|
|
25
|
+
isRecord,
|
|
26
|
+
json,
|
|
27
|
+
literal,
|
|
28
|
+
parseRunId,
|
|
29
|
+
requestFailure,
|
|
30
|
+
schemaValidator,
|
|
31
|
+
selector,
|
|
32
|
+
serializedLimit,
|
|
33
|
+
string,
|
|
34
|
+
validateSchemaSafety,
|
|
35
|
+
type Fail,
|
|
36
|
+
} from './sdk-protocol-value';
|
|
37
|
+
|
|
38
|
+
export function parseOmpSdkSidecarRequest(value: unknown): OmpSdkSidecarRequest {
|
|
39
|
+
if (!isRecord(value)) requestFailure('request must be an object.', 'request');
|
|
40
|
+
serializedLimit(value, OMP_SDK_MAX_REQUEST_BYTES, 'request', requestFailure);
|
|
41
|
+
exact(
|
|
42
|
+
value,
|
|
43
|
+
[
|
|
44
|
+
'protocolVersion',
|
|
45
|
+
'runId',
|
|
46
|
+
'cwd',
|
|
47
|
+
'prompt',
|
|
48
|
+
'executionContext',
|
|
49
|
+
'modelSelector',
|
|
50
|
+
'reasoningEffort',
|
|
51
|
+
'outputMode',
|
|
52
|
+
'modelsConfig',
|
|
53
|
+
'auth',
|
|
54
|
+
'tools',
|
|
55
|
+
'context',
|
|
56
|
+
],
|
|
57
|
+
['outputSchema'],
|
|
58
|
+
'request',
|
|
59
|
+
requestFailure
|
|
60
|
+
);
|
|
61
|
+
literal(value.protocolVersion, 1, 'request.protocolVersion', requestFailure);
|
|
62
|
+
const runId = parseRunId(value.runId, 'request.runId', requestFailure);
|
|
63
|
+
const cwd = string(value.cwd, 'request.cwd', MAX_PATH_BYTES, false, requestFailure);
|
|
64
|
+
if (!includesLiteral(OMP_SDK_EXECUTION_CONTEXTS, value.executionContext)) {
|
|
65
|
+
requestFailure(
|
|
66
|
+
'request.executionContext must be "host", "detached", "docker", or "benchmark".',
|
|
67
|
+
'request.executionContext'
|
|
68
|
+
);
|
|
69
|
+
}
|
|
70
|
+
const executionContext: OmpSdkExecutionContext = value.executionContext;
|
|
71
|
+
if (!path.isAbsolute(cwd)) requestFailure('request.cwd must be absolute.', 'request.cwd');
|
|
72
|
+
const prompt = string(value.prompt, 'request.prompt', MAX_PROMPT_BYTES, false, requestFailure);
|
|
73
|
+
const modelSelector = selector(value.modelSelector, 'request.modelSelector', requestFailure);
|
|
74
|
+
if (!includesLiteral(OMP_SDK_REASONING_EFFORTS, value.reasoningEffort)) {
|
|
75
|
+
requestFailure('request.reasoningEffort is unsupported.');
|
|
76
|
+
}
|
|
77
|
+
const reasoningEffort: ReasoningEffort = value.reasoningEffort;
|
|
78
|
+
json(value.modelsConfig, 'request.modelsConfig', requestFailure);
|
|
79
|
+
json(value.auth, 'request.auth', requestFailure);
|
|
80
|
+
json(value.tools, 'request.tools', requestFailure);
|
|
81
|
+
const context = string(value.context, 'request.context', MAX_CONTEXT_BYTES, true, requestFailure);
|
|
82
|
+
const normalizedSettings = ((): Readonly<ConfiguredOmpSdkSettings> => {
|
|
83
|
+
try {
|
|
84
|
+
return normalizeOmpSdkSettings(
|
|
85
|
+
{
|
|
86
|
+
...OMP_SDK_SETTINGS_DEFAULTS,
|
|
87
|
+
levelOverrides: {
|
|
88
|
+
level1: { model: modelSelector, reasoningEffort },
|
|
89
|
+
level2: { model: modelSelector, reasoningEffort },
|
|
90
|
+
level3: { model: modelSelector, reasoningEffort },
|
|
91
|
+
},
|
|
92
|
+
modelsConfig: value.modelsConfig,
|
|
93
|
+
auth: value.auth,
|
|
94
|
+
tools: value.tools,
|
|
95
|
+
},
|
|
96
|
+
{
|
|
97
|
+
executionContext: executionContext === 'benchmark' ? 'docker' : executionContext,
|
|
98
|
+
requireModelConfiguration: true,
|
|
99
|
+
}
|
|
100
|
+
);
|
|
101
|
+
} catch {
|
|
102
|
+
return requestFailure('request provider settings failed closed validation.');
|
|
103
|
+
}
|
|
104
|
+
})();
|
|
105
|
+
const selectedProvider = modelSelector.slice(0, modelSelector.indexOf('/'));
|
|
106
|
+
if (
|
|
107
|
+
normalizedSettings.auth.mode === 'broker' &&
|
|
108
|
+
normalizedSettings.modelsConfig.providers[selectedProvider] !== undefined
|
|
109
|
+
) {
|
|
110
|
+
requestFailure(
|
|
111
|
+
'request.modelsConfig cannot override the selected provider when broker auth is used.',
|
|
112
|
+
`request.modelsConfig.providers.${selectedProvider}`
|
|
113
|
+
);
|
|
114
|
+
}
|
|
115
|
+
const base = {
|
|
116
|
+
protocolVersion: 1 as const,
|
|
117
|
+
runId,
|
|
118
|
+
cwd,
|
|
119
|
+
executionContext,
|
|
120
|
+
prompt,
|
|
121
|
+
modelSelector,
|
|
122
|
+
reasoningEffort,
|
|
123
|
+
modelsConfig: normalizedSettings.modelsConfig,
|
|
124
|
+
auth: normalizedSettings.auth,
|
|
125
|
+
tools: normalizedSettings.tools,
|
|
126
|
+
context,
|
|
127
|
+
};
|
|
128
|
+
if (value.outputMode === 'json') {
|
|
129
|
+
if (
|
|
130
|
+
value.outputSchema !== true &&
|
|
131
|
+
value.outputSchema !== false &&
|
|
132
|
+
!isRecord(value.outputSchema)
|
|
133
|
+
) {
|
|
134
|
+
requestFailure('request.outputSchema must be a JSON Schema object or boolean.');
|
|
135
|
+
}
|
|
136
|
+
json(value.outputSchema, 'request.outputSchema', requestFailure);
|
|
137
|
+
validateSchemaSafety(value.outputSchema);
|
|
138
|
+
const outputSchema = immutableJsonSnapshot(value.outputSchema);
|
|
139
|
+
schemaValidator(outputSchema);
|
|
140
|
+
return Object.freeze({ ...base, outputMode: 'json' as const, outputSchema });
|
|
141
|
+
}
|
|
142
|
+
if (value.outputMode !== 'text') requestFailure('request.outputMode must be "json" or "text".');
|
|
143
|
+
if (value.outputSchema !== undefined)
|
|
144
|
+
requestFailure('request.outputSchema is forbidden in text mode.');
|
|
145
|
+
return Object.freeze({ ...base, outputMode: 'text' as const });
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
export function decode(
|
|
149
|
+
input: string | Uint8Array,
|
|
150
|
+
max: number,
|
|
151
|
+
subject: string,
|
|
152
|
+
fail: Fail
|
|
153
|
+
): unknown {
|
|
154
|
+
const bytes = typeof input === 'string' ? Buffer.from(input) : Buffer.from(input);
|
|
155
|
+
if (bytes.byteLength === 0 || bytes.byteLength > max)
|
|
156
|
+
fail(`${subject} has an invalid byte length.`);
|
|
157
|
+
let text: string;
|
|
158
|
+
try {
|
|
159
|
+
text = new TextDecoder('utf-8', { fatal: true }).decode(bytes);
|
|
160
|
+
} catch {
|
|
161
|
+
return fail(`${subject} is not valid UTF-8.`);
|
|
162
|
+
}
|
|
163
|
+
try {
|
|
164
|
+
return JSON.parse(text);
|
|
165
|
+
} catch {
|
|
166
|
+
return fail(`${subject} is not valid JSON.`);
|
|
167
|
+
}
|
|
168
|
+
}
|
|
169
|
+
export function decodeOmpSdkSidecarRequest(input: string | Uint8Array): OmpSdkSidecarRequest {
|
|
170
|
+
return parseOmpSdkSidecarRequest(
|
|
171
|
+
decode(input, OMP_SDK_MAX_REQUEST_BYTES, 'request', requestFailure)
|
|
172
|
+
);
|
|
173
|
+
}
|
|
174
|
+
/** @returns The built-in text schema or the request's validated JSON Schema. */
|
|
175
|
+
export function ompSdkOutputSchemaForRequest(
|
|
176
|
+
request: OmpSdkSidecarRequest
|
|
177
|
+
): boolean | Readonly<Record<string, unknown>> {
|
|
178
|
+
let outputSchema: boolean | Readonly<Record<string, unknown>> = OMP_SDK_TEXT_OUTPUT_SCHEMA;
|
|
179
|
+
if (request.outputMode === 'json') outputSchema = request.outputSchema;
|
|
180
|
+
return outputSchema;
|
|
181
|
+
}
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
import type { ResultEvent } from '../types';
|
|
2
|
+
import {
|
|
3
|
+
OMP_SDK_TEXT_OUTPUT_SCHEMA,
|
|
4
|
+
type OmpSdkProtocolResultFrame,
|
|
5
|
+
type OmpSdkSidecarRequest,
|
|
6
|
+
} from './sdk-protocol-types';
|
|
7
|
+
import { parseOmpSdkProtocolFrame } from './sdk-protocol-frame';
|
|
8
|
+
import { protocolFailure, schemaValidator } from './sdk-protocol-value';
|
|
9
|
+
|
|
10
|
+
function checkedValue(frame: OmpSdkProtocolResultFrame, request: OmpSdkSidecarRequest): unknown {
|
|
11
|
+
if (frame.runId !== request.runId) protocolFailure('frame.runId does not match request.');
|
|
12
|
+
if (
|
|
13
|
+
frame.requested.modelSelector !== request.modelSelector ||
|
|
14
|
+
frame.requested.reasoningEffort !== request.reasoningEffort ||
|
|
15
|
+
frame.requested.outputMode !== request.outputMode
|
|
16
|
+
) {
|
|
17
|
+
protocolFailure('frame.requested does not match request.');
|
|
18
|
+
}
|
|
19
|
+
if (frame.resolved.modelSelector !== request.modelSelector)
|
|
20
|
+
protocolFailure('resolved model is not exact.');
|
|
21
|
+
if (request.outputMode === 'text') {
|
|
22
|
+
if (typeof frame.value !== 'string') protocolFailure('invalid text result.');
|
|
23
|
+
if (!schemaValidator(OMP_SDK_TEXT_OUTPUT_SCHEMA)({ result: frame.value })) {
|
|
24
|
+
protocolFailure('frame.value failed host schema validation.');
|
|
25
|
+
}
|
|
26
|
+
return frame.value;
|
|
27
|
+
}
|
|
28
|
+
if (!schemaValidator(request.outputSchema)(frame.value)) {
|
|
29
|
+
protocolFailure('frame.value failed host schema validation.');
|
|
30
|
+
}
|
|
31
|
+
return frame.value;
|
|
32
|
+
}
|
|
33
|
+
export function validateOmpSdkProtocolResultFrame(
|
|
34
|
+
value: unknown,
|
|
35
|
+
request: OmpSdkSidecarRequest
|
|
36
|
+
): OmpSdkProtocolResultFrame {
|
|
37
|
+
const frame = parseOmpSdkProtocolFrame(value);
|
|
38
|
+
if (frame.type !== 'result') protocolFailure('a result frame is required.');
|
|
39
|
+
checkedValue(frame, request);
|
|
40
|
+
return frame;
|
|
41
|
+
}
|
|
42
|
+
export function normalizeOmpSdkResultFrame(
|
|
43
|
+
value: unknown,
|
|
44
|
+
request: OmpSdkSidecarRequest
|
|
45
|
+
): ResultEvent {
|
|
46
|
+
const parsed = parseOmpSdkProtocolFrame(value);
|
|
47
|
+
if (parsed.type !== 'result') protocolFailure('a result frame is required.');
|
|
48
|
+
const frame = parsed;
|
|
49
|
+
const result = checkedValue(frame, request);
|
|
50
|
+
const parsedUsage = frame.usage;
|
|
51
|
+
return {
|
|
52
|
+
type: 'result',
|
|
53
|
+
success: true,
|
|
54
|
+
result,
|
|
55
|
+
cost: parsedUsage.cost.total,
|
|
56
|
+
duration: parsedUsage.durationMs,
|
|
57
|
+
inputTokens:
|
|
58
|
+
parsedUsage.inputTokens +
|
|
59
|
+
parsedUsage.cacheReadInputTokens +
|
|
60
|
+
parsedUsage.cacheCreationInputTokens,
|
|
61
|
+
outputTokens: parsedUsage.outputTokens,
|
|
62
|
+
cacheReadInputTokens: parsedUsage.cacheReadInputTokens,
|
|
63
|
+
cacheCreationInputTokens: parsedUsage.cacheCreationInputTokens,
|
|
64
|
+
modelUsage: parsedUsage,
|
|
65
|
+
requests: parsedUsage.requests,
|
|
66
|
+
usageSource: 'omp-aggregate',
|
|
67
|
+
usageCompleteness: 'unknown',
|
|
68
|
+
invocation: { lane: 'spawn', pty: false, protocol: 'omp-sdk-v1' },
|
|
69
|
+
ompSdk: {
|
|
70
|
+
backend: frame.backend,
|
|
71
|
+
runtime: frame.runtime,
|
|
72
|
+
requested: frame.requested,
|
|
73
|
+
resolved: frame.resolved,
|
|
74
|
+
strictOutput: frame.strictOutput,
|
|
75
|
+
fallback: false,
|
|
76
|
+
execution: frame.execution,
|
|
77
|
+
usage: parsedUsage,
|
|
78
|
+
},
|
|
79
|
+
};
|
|
80
|
+
}
|