@stigmer/runner 3.0.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/README.md +212 -0
- package/dist/.build-fingerprint +1 -0
- package/dist/activities/call-agent-status.d.ts +37 -0
- package/dist/activities/call-agent-status.js +91 -0
- package/dist/activities/call-agent-status.js.map +1 -0
- package/dist/activities/call-agent.d.ts +25 -0
- package/dist/activities/call-agent.js +233 -0
- package/dist/activities/call-agent.js.map +1 -0
- package/dist/activities/call-eval.d.ts +50 -0
- package/dist/activities/call-eval.js +244 -0
- package/dist/activities/call-eval.js.map +1 -0
- package/dist/activities/call-function.d.ts +21 -0
- package/dist/activities/call-function.js +54 -0
- package/dist/activities/call-function.js.map +1 -0
- package/dist/activities/call-grpc.d.ts +22 -0
- package/dist/activities/call-grpc.js +101 -0
- package/dist/activities/call-grpc.js.map +1 -0
- package/dist/activities/call-http.d.ts +32 -0
- package/dist/activities/call-http.js +134 -0
- package/dist/activities/call-http.js.map +1 -0
- package/dist/activities/call-llm.d.ts +39 -0
- package/dist/activities/call-llm.js +260 -0
- package/dist/activities/call-llm.js.map +1 -0
- package/dist/activities/call-transform.d.ts +20 -0
- package/dist/activities/call-transform.js +33 -0
- package/dist/activities/call-transform.js.map +1 -0
- package/dist/activities/call-validate.d.ts +41 -0
- package/dist/activities/call-validate.js +163 -0
- package/dist/activities/call-validate.js.map +1 -0
- package/dist/activities/classify-tool-approvals.d.ts +47 -0
- package/dist/activities/classify-tool-approvals.js +207 -0
- package/dist/activities/classify-tool-approvals.js.map +1 -0
- package/dist/activities/discover-mcp-server.d.ts +65 -0
- package/dist/activities/discover-mcp-server.js +269 -0
- package/dist/activities/discover-mcp-server.js.map +1 -0
- package/dist/activities/emit-event.d.ts +46 -0
- package/dist/activities/emit-event.js +125 -0
- package/dist/activities/emit-event.js.map +1 -0
- package/dist/activities/ensure-thread.d.ts +24 -0
- package/dist/activities/ensure-thread.js +44 -0
- package/dist/activities/ensure-thread.js.map +1 -0
- package/dist/activities/evaluate-expressions.d.ts +21 -0
- package/dist/activities/evaluate-expressions.js +39 -0
- package/dist/activities/evaluate-expressions.js.map +1 -0
- package/dist/activities/execute-cursor/approval-policy.d.ts +104 -0
- package/dist/activities/execute-cursor/approval-policy.js +193 -0
- package/dist/activities/execute-cursor/approval-policy.js.map +1 -0
- package/dist/activities/execute-cursor/approval-state.d.ts +157 -0
- package/dist/activities/execute-cursor/approval-state.js +223 -0
- package/dist/activities/execute-cursor/approval-state.js.map +1 -0
- package/dist/activities/execute-cursor/attachment-resolver.d.ts +19 -0
- package/dist/activities/execute-cursor/attachment-resolver.js +52 -0
- package/dist/activities/execute-cursor/attachment-resolver.js.map +1 -0
- package/dist/activities/execute-cursor/blueprint-resolver.d.ts +66 -0
- package/dist/activities/execute-cursor/blueprint-resolver.js +169 -0
- package/dist/activities/execute-cursor/blueprint-resolver.js.map +1 -0
- package/dist/activities/execute-cursor/connect-backfill.d.ts +18 -0
- package/dist/activities/execute-cursor/connect-backfill.js +27 -0
- package/dist/activities/execute-cursor/connect-backfill.js.map +1 -0
- package/dist/activities/execute-cursor/cursor-event-recorder.d.ts +24 -0
- package/dist/activities/execute-cursor/cursor-event-recorder.js +66 -0
- package/dist/activities/execute-cursor/cursor-event-recorder.js.map +1 -0
- package/dist/activities/execute-cursor/cursor-mode.d.ts +32 -0
- package/dist/activities/execute-cursor/cursor-mode.js +36 -0
- package/dist/activities/execute-cursor/cursor-mode.js.map +1 -0
- package/dist/activities/execute-cursor/delta-enricher.d.ts +87 -0
- package/dist/activities/execute-cursor/delta-enricher.js +265 -0
- package/dist/activities/execute-cursor/delta-enricher.js.map +1 -0
- package/dist/activities/execute-cursor/env-resolver.d.ts +19 -0
- package/dist/activities/execute-cursor/env-resolver.js +47 -0
- package/dist/activities/execute-cursor/env-resolver.js.map +1 -0
- package/dist/activities/execute-cursor/error-classifier.d.ts +73 -0
- package/dist/activities/execute-cursor/error-classifier.js +185 -0
- package/dist/activities/execute-cursor/error-classifier.js.map +1 -0
- package/dist/activities/execute-cursor/fetch-interceptor.d.ts +59 -0
- package/dist/activities/execute-cursor/fetch-interceptor.js +317 -0
- package/dist/activities/execute-cursor/fetch-interceptor.js.map +1 -0
- package/dist/activities/execute-cursor/hitl-diagnostics.d.ts +32 -0
- package/dist/activities/execute-cursor/hitl-diagnostics.js +73 -0
- package/dist/activities/execute-cursor/hitl-diagnostics.js.map +1 -0
- package/dist/activities/execute-cursor/hook-script.d.ts +47 -0
- package/dist/activities/execute-cursor/hook-script.js +156 -0
- package/dist/activities/execute-cursor/hook-script.js.map +1 -0
- package/dist/activities/execute-cursor/http2-interceptor.d.ts +94 -0
- package/dist/activities/execute-cursor/http2-interceptor.js +209 -0
- package/dist/activities/execute-cursor/http2-interceptor.js.map +1 -0
- package/dist/activities/execute-cursor/index.d.ts +67 -0
- package/dist/activities/execute-cursor/index.js +1176 -0
- package/dist/activities/execute-cursor/index.js.map +1 -0
- package/dist/activities/execute-cursor/mcp-config.d.ts +30 -0
- package/dist/activities/execute-cursor/mcp-config.js +39 -0
- package/dist/activities/execute-cursor/mcp-config.js.map +1 -0
- package/dist/activities/execute-cursor/mcp-resolver.d.ts +91 -0
- package/dist/activities/execute-cursor/mcp-resolver.js +178 -0
- package/dist/activities/execute-cursor/mcp-resolver.js.map +1 -0
- package/dist/activities/execute-cursor/message-translator.d.ts +211 -0
- package/dist/activities/execute-cursor/message-translator.js +786 -0
- package/dist/activities/execute-cursor/message-translator.js.map +1 -0
- package/dist/activities/execute-cursor/model-pricing-data.d.ts +40 -0
- package/dist/activities/execute-cursor/model-pricing-data.js +114 -0
- package/dist/activities/execute-cursor/model-pricing-data.js.map +1 -0
- package/dist/activities/execute-cursor/model-pricing.d.ts +42 -0
- package/dist/activities/execute-cursor/model-pricing.js +141 -0
- package/dist/activities/execute-cursor/model-pricing.js.map +1 -0
- package/dist/activities/execute-cursor/placeholder-resolver.d.ts +34 -0
- package/dist/activities/execute-cursor/placeholder-resolver.js +82 -0
- package/dist/activities/execute-cursor/placeholder-resolver.js.map +1 -0
- package/dist/activities/execute-cursor/prompt-builder.d.ts +80 -0
- package/dist/activities/execute-cursor/prompt-builder.js +280 -0
- package/dist/activities/execute-cursor/prompt-builder.js.map +1 -0
- package/dist/activities/execute-cursor/rejection-capture.d.ts +30 -0
- package/dist/activities/execute-cursor/rejection-capture.js +80 -0
- package/dist/activities/execute-cursor/rejection-capture.js.map +1 -0
- package/dist/activities/execute-cursor/session-lifecycle.d.ts +189 -0
- package/dist/activities/execute-cursor/session-lifecycle.js +285 -0
- package/dist/activities/execute-cursor/session-lifecycle.js.map +1 -0
- package/dist/activities/execute-cursor/skill-resolver.d.ts +29 -0
- package/dist/activities/execute-cursor/skill-resolver.js +134 -0
- package/dist/activities/execute-cursor/skill-resolver.js.map +1 -0
- package/dist/activities/execute-cursor/subagent-config.d.ts +34 -0
- package/dist/activities/execute-cursor/subagent-config.js +55 -0
- package/dist/activities/execute-cursor/subagent-config.js.map +1 -0
- package/dist/activities/execute-cursor/todo-tracker.d.ts +35 -0
- package/dist/activities/execute-cursor/todo-tracker.js +108 -0
- package/dist/activities/execute-cursor/todo-tracker.js.map +1 -0
- package/dist/activities/execute-cursor/usage-accumulator.d.ts +55 -0
- package/dist/activities/execute-cursor/usage-accumulator.js +89 -0
- package/dist/activities/execute-cursor/usage-accumulator.js.map +1 -0
- package/dist/activities/execute-cursor/workspace-provision.d.ts +22 -0
- package/dist/activities/execute-cursor/workspace-provision.js +37 -0
- package/dist/activities/execute-cursor/workspace-provision.js.map +1 -0
- package/dist/activities/execute-cursor/workspace-setup.d.ts +27 -0
- package/dist/activities/execute-cursor/workspace-setup.js +61 -0
- package/dist/activities/execute-cursor/workspace-setup.js.map +1 -0
- package/dist/activities/execute-deep-agent/__test-utils__/v3-event-fixtures.d.ts +71 -0
- package/dist/activities/execute-deep-agent/__test-utils__/v3-event-fixtures.js +182 -0
- package/dist/activities/execute-deep-agent/__test-utils__/v3-event-fixtures.js.map +1 -0
- package/dist/activities/execute-deep-agent/attachment-injector.d.ts +67 -0
- package/dist/activities/execute-deep-agent/attachment-injector.js +306 -0
- package/dist/activities/execute-deep-agent/attachment-injector.js.map +1 -0
- package/dist/activities/execute-deep-agent/auto-publish.d.ts +17 -0
- package/dist/activities/execute-deep-agent/auto-publish.js +71 -0
- package/dist/activities/execute-deep-agent/auto-publish.js.map +1 -0
- package/dist/activities/execute-deep-agent/environment.d.ts +24 -0
- package/dist/activities/execute-deep-agent/environment.js +50 -0
- package/dist/activities/execute-deep-agent/environment.js.map +1 -0
- package/dist/activities/execute-deep-agent/event-recorder.d.ts +21 -0
- package/dist/activities/execute-deep-agent/event-recorder.js +67 -0
- package/dist/activities/execute-deep-agent/event-recorder.js.map +1 -0
- package/dist/activities/execute-deep-agent/execution-state.d.ts +61 -0
- package/dist/activities/execute-deep-agent/execution-state.js +76 -0
- package/dist/activities/execute-deep-agent/execution-state.js.map +1 -0
- package/dist/activities/execute-deep-agent/execution-status-writer.d.ts +17 -0
- package/dist/activities/execute-deep-agent/execution-status-writer.js +9 -0
- package/dist/activities/execute-deep-agent/execution-status-writer.js.map +1 -0
- package/dist/activities/execute-deep-agent/hitl.d.ts +58 -0
- package/dist/activities/execute-deep-agent/hitl.js +155 -0
- package/dist/activities/execute-deep-agent/hitl.js.map +1 -0
- package/dist/activities/execute-deep-agent/index.d.ts +14 -0
- package/dist/activities/execute-deep-agent/index.js +286 -0
- package/dist/activities/execute-deep-agent/index.js.map +1 -0
- package/dist/activities/execute-deep-agent/inline-publisher.d.ts +36 -0
- package/dist/activities/execute-deep-agent/inline-publisher.js +105 -0
- package/dist/activities/execute-deep-agent/inline-publisher.js.map +1 -0
- package/dist/activities/execute-deep-agent/post-stream.d.ts +23 -0
- package/dist/activities/execute-deep-agent/post-stream.js +71 -0
- package/dist/activities/execute-deep-agent/post-stream.js.map +1 -0
- package/dist/activities/execute-deep-agent/prompt-builder.d.ts +27 -0
- package/dist/activities/execute-deep-agent/prompt-builder.js +200 -0
- package/dist/activities/execute-deep-agent/prompt-builder.js.map +1 -0
- package/dist/activities/execute-deep-agent/setup.d.ts +55 -0
- package/dist/activities/execute-deep-agent/setup.js +411 -0
- package/dist/activities/execute-deep-agent/setup.js.map +1 -0
- package/dist/activities/execute-deep-agent/status-builder-shared.d.ts +39 -0
- package/dist/activities/execute-deep-agent/status-builder-shared.js +120 -0
- package/dist/activities/execute-deep-agent/status-builder-shared.js.map +1 -0
- package/dist/activities/execute-deep-agent/status-builder.d.ts +81 -0
- package/dist/activities/execute-deep-agent/status-builder.js +312 -0
- package/dist/activities/execute-deep-agent/status-builder.js.map +1 -0
- package/dist/activities/execute-deep-agent/streaming-scheduler.d.ts +60 -0
- package/dist/activities/execute-deep-agent/streaming-scheduler.js +114 -0
- package/dist/activities/execute-deep-agent/streaming-scheduler.js.map +1 -0
- package/dist/activities/execute-deep-agent/streaming-side-effects.d.ts +22 -0
- package/dist/activities/execute-deep-agent/streaming-side-effects.js +83 -0
- package/dist/activities/execute-deep-agent/streaming-side-effects.js.map +1 -0
- package/dist/activities/execute-deep-agent/streaming-terminal.d.ts +12 -0
- package/dist/activities/execute-deep-agent/streaming-terminal.js +71 -0
- package/dist/activities/execute-deep-agent/streaming-terminal.js.map +1 -0
- package/dist/activities/execute-deep-agent/streaming-v3.d.ts +13 -0
- package/dist/activities/execute-deep-agent/streaming-v3.js +170 -0
- package/dist/activities/execute-deep-agent/streaming-v3.js.map +1 -0
- package/dist/activities/execute-deep-agent/streaming.d.ts +66 -0
- package/dist/activities/execute-deep-agent/streaming.js +169 -0
- package/dist/activities/execute-deep-agent/streaming.js.map +1 -0
- package/dist/activities/execute-deep-agent/subagent-tracker.d.ts +90 -0
- package/dist/activities/execute-deep-agent/subagent-tracker.js +364 -0
- package/dist/activities/execute-deep-agent/subagent-tracker.js.map +1 -0
- package/dist/activities/execute-deep-agent/subagent-transformer.d.ts +150 -0
- package/dist/activities/execute-deep-agent/subagent-transformer.js +450 -0
- package/dist/activities/execute-deep-agent/subagent-transformer.js.map +1 -0
- package/dist/activities/execute-deep-agent/subagent-wiring.d.ts +28 -0
- package/dist/activities/execute-deep-agent/subagent-wiring.js +40 -0
- package/dist/activities/execute-deep-agent/subagent-wiring.js.map +1 -0
- package/dist/activities/execute-deep-agent/v3-event-recorder.d.ts +31 -0
- package/dist/activities/execute-deep-agent/v3-event-recorder.js +71 -0
- package/dist/activities/execute-deep-agent/v3-event-recorder.js.map +1 -0
- package/dist/activities/execute-deep-agent/v3-events.d.ts +102 -0
- package/dist/activities/execute-deep-agent/v3-events.js +35 -0
- package/dist/activities/execute-deep-agent/v3-events.js.map +1 -0
- package/dist/activities/execute-deep-agent/v3-protocol-normalizer.d.ts +15 -0
- package/dist/activities/execute-deep-agent/v3-protocol-normalizer.js +235 -0
- package/dist/activities/execute-deep-agent/v3-protocol-normalizer.js.map +1 -0
- package/dist/activities/execute-deep-agent/v3-status-builder.d.ts +68 -0
- package/dist/activities/execute-deep-agent/v3-status-builder.js +394 -0
- package/dist/activities/execute-deep-agent/v3-status-builder.js.map +1 -0
- package/dist/activities/execute-deep-agent/writeback-coordinator.d.ts +71 -0
- package/dist/activities/execute-deep-agent/writeback-coordinator.js +295 -0
- package/dist/activities/execute-deep-agent/writeback-coordinator.js.map +1 -0
- package/dist/activities/hydrate-workflow-execution.d.ts +32 -0
- package/dist/activities/hydrate-workflow-execution.js +212 -0
- package/dist/activities/hydrate-workflow-execution.js.map +1 -0
- package/dist/activities/notification.d.ts +19 -0
- package/dist/activities/notification.js +47 -0
- package/dist/activities/notification.js.map +1 -0
- package/dist/activities/promote-task-output.d.ts +38 -0
- package/dist/activities/promote-task-output.js +90 -0
- package/dist/activities/promote-task-output.js.map +1 -0
- package/dist/activities/run-command.d.ts +15 -0
- package/dist/activities/run-command.js +123 -0
- package/dist/activities/run-command.js.map +1 -0
- package/dist/activities/workflow-event-activities.d.ts +48 -0
- package/dist/activities/workflow-event-activities.js +415 -0
- package/dist/activities/workflow-event-activities.js.map +1 -0
- package/dist/bootstrap.d.ts +80 -0
- package/dist/bootstrap.js +114 -0
- package/dist/bootstrap.js.map +1 -0
- package/dist/budget/index.d.ts +1 -0
- package/dist/budget/index.js +2 -0
- package/dist/budget/index.js.map +1 -0
- package/dist/budget/tracker.d.ts +52 -0
- package/dist/budget/tracker.js +123 -0
- package/dist/budget/tracker.js.map +1 -0
- package/dist/claimcheck/compressor.d.ts +2 -0
- package/dist/claimcheck/compressor.js +8 -0
- package/dist/claimcheck/compressor.js.map +1 -0
- package/dist/claimcheck/config.d.ts +7 -0
- package/dist/claimcheck/config.js +10 -0
- package/dist/claimcheck/config.js.map +1 -0
- package/dist/claimcheck/index.d.ts +3 -0
- package/dist/claimcheck/index.js +4 -0
- package/dist/claimcheck/index.js.map +1 -0
- package/dist/claimcheck/payload-codec.d.ts +23 -0
- package/dist/claimcheck/payload-codec.js +81 -0
- package/dist/claimcheck/payload-codec.js.map +1 -0
- package/dist/client/server-contracts.d.ts +52 -0
- package/dist/client/server-contracts.js +72 -0
- package/dist/client/server-contracts.js.map +1 -0
- package/dist/client/stigmer-client.d.ts +131 -0
- package/dist/client/stigmer-client.js +239 -0
- package/dist/client/stigmer-client.js.map +1 -0
- package/dist/config.d.ts +64 -0
- package/dist/config.js +123 -0
- package/dist/config.js.map +1 -0
- package/dist/idle-watchdog.d.ts +11 -0
- package/dist/idle-watchdog.js +24 -0
- package/dist/idle-watchdog.js.map +1 -0
- package/dist/index.d.ts +43 -0
- package/dist/index.js +42 -0
- package/dist/index.js.map +1 -0
- package/dist/interceptors/workflow-metrics-sink.d.ts +11 -0
- package/dist/interceptors/workflow-metrics-sink.js +51 -0
- package/dist/interceptors/workflow-metrics-sink.js.map +1 -0
- package/dist/ipc-protocol-fixtures.d.ts +32 -0
- package/dist/ipc-protocol-fixtures.js +69 -0
- package/dist/ipc-protocol-fixtures.js.map +1 -0
- package/dist/ipc-protocol.d.ts +60 -0
- package/dist/ipc-protocol.js +19 -0
- package/dist/ipc-protocol.js.map +1 -0
- package/dist/main.d.ts +19 -0
- package/dist/main.js +292 -0
- package/dist/main.js.map +1 -0
- package/dist/middleware/approval-gate.d.ts +30 -0
- package/dist/middleware/approval-gate.js +125 -0
- package/dist/middleware/approval-gate.js.map +1 -0
- package/dist/middleware/cost-cap.d.ts +22 -0
- package/dist/middleware/cost-cap.js +159 -0
- package/dist/middleware/cost-cap.js.map +1 -0
- package/dist/middleware/error-hints.d.ts +27 -0
- package/dist/middleware/error-hints.js +116 -0
- package/dist/middleware/error-hints.js.map +1 -0
- package/dist/middleware/execution-budget.d.ts +20 -0
- package/dist/middleware/execution-budget.js +151 -0
- package/dist/middleware/execution-budget.js.map +1 -0
- package/dist/middleware/graceful-stop.d.ts +17 -0
- package/dist/middleware/graceful-stop.js +63 -0
- package/dist/middleware/graceful-stop.js.map +1 -0
- package/dist/middleware/index.d.ts +27 -0
- package/dist/middleware/index.js +45 -0
- package/dist/middleware/index.js.map +1 -0
- package/dist/middleware/loop-detection.d.ts +14 -0
- package/dist/middleware/loop-detection.js +156 -0
- package/dist/middleware/loop-detection.js.map +1 -0
- package/dist/middleware/otel-spans.d.ts +11 -0
- package/dist/middleware/otel-spans.js +177 -0
- package/dist/middleware/otel-spans.js.map +1 -0
- package/dist/middleware/think-tool.d.ts +23 -0
- package/dist/middleware/think-tool.js +33 -0
- package/dist/middleware/think-tool.js.map +1 -0
- package/dist/middleware/tool-truncation.d.ts +16 -0
- package/dist/middleware/tool-truncation.js +67 -0
- package/dist/middleware/tool-truncation.js.map +1 -0
- package/dist/middleware/types.d.ts +100 -0
- package/dist/middleware/types.js +9 -0
- package/dist/middleware/types.js.map +1 -0
- package/dist/notification/index.d.ts +2 -0
- package/dist/notification/index.js +6 -0
- package/dist/notification/index.js.map +1 -0
- package/dist/notification/provider.d.ts +29 -0
- package/dist/notification/provider.js +25 -0
- package/dist/notification/provider.js.map +1 -0
- package/dist/notification/webhook.d.ts +13 -0
- package/dist/notification/webhook.js +55 -0
- package/dist/notification/webhook.js.map +1 -0
- package/dist/otel-metrics.d.ts +21 -0
- package/dist/otel-metrics.js +54 -0
- package/dist/otel-metrics.js.map +1 -0
- package/dist/otel.d.ts +57 -0
- package/dist/otel.js +164 -0
- package/dist/otel.js.map +1 -0
- package/dist/runner-manager.d.ts +113 -0
- package/dist/runner-manager.js +412 -0
- package/dist/runner-manager.js.map +1 -0
- package/dist/runner-token-coordinator.d.ts +56 -0
- package/dist/runner-token-coordinator.js +84 -0
- package/dist/runner-token-coordinator.js.map +1 -0
- package/dist/runner.d.ts +104 -0
- package/dist/runner.js +234 -0
- package/dist/runner.js.map +1 -0
- package/dist/shared/approval-policy.d.ts +45 -0
- package/dist/shared/approval-policy.js +122 -0
- package/dist/shared/approval-policy.js.map +1 -0
- package/dist/shared/artifact-storage.d.ts +44 -0
- package/dist/shared/artifact-storage.js +162 -0
- package/dist/shared/artifact-storage.js.map +1 -0
- package/dist/shared/checkpointer/factory.d.ts +28 -0
- package/dist/shared/checkpointer/factory.js +55 -0
- package/dist/shared/checkpointer/factory.js.map +1 -0
- package/dist/shared/checkpointer/http-saver.d.ts +34 -0
- package/dist/shared/checkpointer/http-saver.js +274 -0
- package/dist/shared/checkpointer/http-saver.js.map +1 -0
- package/dist/shared/checkpointer/types.d.ts +12 -0
- package/dist/shared/checkpointer/types.js +2 -0
- package/dist/shared/checkpointer/types.js.map +1 -0
- package/dist/shared/connect-backfill.d.ts +58 -0
- package/dist/shared/connect-backfill.js +119 -0
- package/dist/shared/connect-backfill.js.map +1 -0
- package/dist/shared/extract-json.d.ts +26 -0
- package/dist/shared/extract-json.js +140 -0
- package/dist/shared/extract-json.js.map +1 -0
- package/dist/shared/grpc-retry.d.ts +35 -0
- package/dist/shared/grpc-retry.js +78 -0
- package/dist/shared/grpc-retry.js.map +1 -0
- package/dist/shared/heartbeat.d.ts +22 -0
- package/dist/shared/heartbeat.js +55 -0
- package/dist/shared/heartbeat.js.map +1 -0
- package/dist/shared/json-schema-to-zod.d.ts +13 -0
- package/dist/shared/json-schema-to-zod.js +49 -0
- package/dist/shared/json-schema-to-zod.js.map +1 -0
- package/dist/shared/llm-proxy.d.ts +57 -0
- package/dist/shared/llm-proxy.js +116 -0
- package/dist/shared/llm-proxy.js.map +1 -0
- package/dist/shared/mcp-manager.d.ts +47 -0
- package/dist/shared/mcp-manager.js +118 -0
- package/dist/shared/mcp-manager.js.map +1 -0
- package/dist/shared/mcp-resolver.d.ts +41 -0
- package/dist/shared/mcp-resolver.js +96 -0
- package/dist/shared/mcp-resolver.js.map +1 -0
- package/dist/shared/model-pricing-data.d.ts +18 -0
- package/dist/shared/model-pricing-data.js +78 -0
- package/dist/shared/model-pricing-data.js.map +1 -0
- package/dist/shared/model-pricing.d.ts +24 -0
- package/dist/shared/model-pricing.js +58 -0
- package/dist/shared/model-pricing.js.map +1 -0
- package/dist/shared/model-registry.d.ts +55 -0
- package/dist/shared/model-registry.js +178 -0
- package/dist/shared/model-registry.js.map +1 -0
- package/dist/shared/placeholder-resolver.d.ts +27 -0
- package/dist/shared/placeholder-resolver.js +75 -0
- package/dist/shared/placeholder-resolver.js.map +1 -0
- package/dist/shared/plan-artifact.d.ts +56 -0
- package/dist/shared/plan-artifact.js +98 -0
- package/dist/shared/plan-artifact.js.map +1 -0
- package/dist/shared/skill-relevance.d.ts +65 -0
- package/dist/shared/skill-relevance.js +175 -0
- package/dist/shared/skill-relevance.js.map +1 -0
- package/dist/shared/skill-writer.d.ts +73 -0
- package/dist/shared/skill-writer.js +230 -0
- package/dist/shared/skill-writer.js.map +1 -0
- package/dist/shared/status.d.ts +37 -0
- package/dist/shared/status.js +73 -0
- package/dist/shared/status.js.map +1 -0
- package/dist/shared/subagent-gate.d.ts +41 -0
- package/dist/shared/subagent-gate.js +93 -0
- package/dist/shared/subagent-gate.js.map +1 -0
- package/dist/shared/tool-kind.d.ts +22 -0
- package/dist/shared/tool-kind.js +79 -0
- package/dist/shared/tool-kind.js.map +1 -0
- package/dist/shared/workspace/file-tree.d.ts +13 -0
- package/dist/shared/workspace/file-tree.js +101 -0
- package/dist/shared/workspace/file-tree.js.map +1 -0
- package/dist/shared/workspace/local-backend.d.ts +41 -0
- package/dist/shared/workspace/local-backend.js +113 -0
- package/dist/shared/workspace/local-backend.js.map +1 -0
- package/dist/shared/workspace/platform-dir.d.ts +25 -0
- package/dist/shared/workspace/platform-dir.js +36 -0
- package/dist/shared/workspace/platform-dir.js.map +1 -0
- package/dist/shared/workspace/platform-mount.d.ts +95 -0
- package/dist/shared/workspace/platform-mount.js +157 -0
- package/dist/shared/workspace/platform-mount.js.map +1 -0
- package/dist/shared/workspace/provisioner.d.ts +47 -0
- package/dist/shared/workspace/provisioner.js +84 -0
- package/dist/shared/workspace/provisioner.js.map +1 -0
- package/dist/shared/workspace/sources/empty.d.ts +8 -0
- package/dist/shared/workspace/sources/empty.js +18 -0
- package/dist/shared/workspace/sources/empty.js.map +1 -0
- package/dist/shared/workspace/sources/git.d.ts +22 -0
- package/dist/shared/workspace/sources/git.js +207 -0
- package/dist/shared/workspace/sources/git.js.map +1 -0
- package/dist/shared/workspace/sources/local-path.d.ts +17 -0
- package/dist/shared/workspace/sources/local-path.js +57 -0
- package/dist/shared/workspace/sources/local-path.js.map +1 -0
- package/dist/shared/workspace/types.d.ts +58 -0
- package/dist/shared/workspace/types.js +25 -0
- package/dist/shared/workspace/types.js.map +1 -0
- package/dist/shared/zip-extract.d.ts +30 -0
- package/dist/shared/zip-extract.js +150 -0
- package/dist/shared/zip-extract.js.map +1 -0
- package/dist/worker.d.ts +27 -0
- package/dist/worker.js +65 -0
- package/dist/worker.js.map +1 -0
- package/dist/workflow-engine/clone.d.ts +11 -0
- package/dist/workflow-engine/clone.js +21 -0
- package/dist/workflow-engine/clone.js.map +1 -0
- package/dist/workflow-engine/do-executor.d.ts +27 -0
- package/dist/workflow-engine/do-executor.js +418 -0
- package/dist/workflow-engine/do-executor.js.map +1 -0
- package/dist/workflow-engine/duration.d.ts +12 -0
- package/dist/workflow-engine/duration.js +25 -0
- package/dist/workflow-engine/duration.js.map +1 -0
- package/dist/workflow-engine/error-utils.d.ts +42 -0
- package/dist/workflow-engine/error-utils.js +77 -0
- package/dist/workflow-engine/error-utils.js.map +1 -0
- package/dist/workflow-engine/errors.d.ts +46 -0
- package/dist/workflow-engine/errors.js +105 -0
- package/dist/workflow-engine/errors.js.map +1 -0
- package/dist/workflow-engine/expression-utils.d.ts +60 -0
- package/dist/workflow-engine/expression-utils.js +108 -0
- package/dist/workflow-engine/expression-utils.js.map +1 -0
- package/dist/workflow-engine/expression.d.ts +132 -0
- package/dist/workflow-engine/expression.js +366 -0
- package/dist/workflow-engine/expression.js.map +1 -0
- package/dist/workflow-engine/loader.d.ts +23 -0
- package/dist/workflow-engine/loader.js +429 -0
- package/dist/workflow-engine/loader.js.map +1 -0
- package/dist/workflow-engine/recovery.d.ts +53 -0
- package/dist/workflow-engine/recovery.js +46 -0
- package/dist/workflow-engine/recovery.js.map +1 -0
- package/dist/workflow-engine/resolve.d.ts +83 -0
- package/dist/workflow-engine/resolve.js +257 -0
- package/dist/workflow-engine/resolve.js.map +1 -0
- package/dist/workflow-engine/retry.d.ts +30 -0
- package/dist/workflow-engine/retry.js +97 -0
- package/dist/workflow-engine/retry.js.map +1 -0
- package/dist/workflow-engine/state.d.ts +26 -0
- package/dist/workflow-engine/state.js +49 -0
- package/dist/workflow-engine/state.js.map +1 -0
- package/dist/workflow-engine/task-factory.d.ts +20 -0
- package/dist/workflow-engine/task-factory.js +133 -0
- package/dist/workflow-engine/task-factory.js.map +1 -0
- package/dist/workflow-engine/task-status-accumulator.d.ts +59 -0
- package/dist/workflow-engine/task-status-accumulator.js +164 -0
- package/dist/workflow-engine/task-status-accumulator.js.map +1 -0
- package/dist/workflow-engine/tasks/call-agent-output.d.ts +26 -0
- package/dist/workflow-engine/tasks/call-agent-output.js +109 -0
- package/dist/workflow-engine/tasks/call-agent-output.js.map +1 -0
- package/dist/workflow-engine/tasks/call-agent.d.ts +31 -0
- package/dist/workflow-engine/tasks/call-agent.js +161 -0
- package/dist/workflow-engine/tasks/call-agent.js.map +1 -0
- package/dist/workflow-engine/tasks/call-function.d.ts +19 -0
- package/dist/workflow-engine/tasks/call-function.js +64 -0
- package/dist/workflow-engine/tasks/call-function.js.map +1 -0
- package/dist/workflow-engine/tasks/call-grpc.d.ts +15 -0
- package/dist/workflow-engine/tasks/call-grpc.js +27 -0
- package/dist/workflow-engine/tasks/call-grpc.js.map +1 -0
- package/dist/workflow-engine/tasks/call-http.d.ts +19 -0
- package/dist/workflow-engine/tasks/call-http.js +31 -0
- package/dist/workflow-engine/tasks/call-http.js.map +1 -0
- package/dist/workflow-engine/tasks/for.d.ts +39 -0
- package/dist/workflow-engine/tasks/for.js +154 -0
- package/dist/workflow-engine/tasks/for.js.map +1 -0
- package/dist/workflow-engine/tasks/fork.d.ts +42 -0
- package/dist/workflow-engine/tasks/fork.js +142 -0
- package/dist/workflow-engine/tasks/fork.js.map +1 -0
- package/dist/workflow-engine/tasks/human-input.d.ts +33 -0
- package/dist/workflow-engine/tasks/human-input.js +109 -0
- package/dist/workflow-engine/tasks/human-input.js.map +1 -0
- package/dist/workflow-engine/tasks/listen.d.ts +34 -0
- package/dist/workflow-engine/tasks/listen.js +119 -0
- package/dist/workflow-engine/tasks/listen.js.map +1 -0
- package/dist/workflow-engine/tasks/raise.d.ts +18 -0
- package/dist/workflow-engine/tasks/raise.js +60 -0
- package/dist/workflow-engine/tasks/raise.js.map +1 -0
- package/dist/workflow-engine/tasks/run.d.ts +39 -0
- package/dist/workflow-engine/tasks/run.js +114 -0
- package/dist/workflow-engine/tasks/run.js.map +1 -0
- package/dist/workflow-engine/tasks/set.d.ts +15 -0
- package/dist/workflow-engine/tasks/set.js +31 -0
- package/dist/workflow-engine/tasks/set.js.map +1 -0
- package/dist/workflow-engine/tasks/switch.d.ts +25 -0
- package/dist/workflow-engine/tasks/switch.js +76 -0
- package/dist/workflow-engine/tasks/switch.js.map +1 -0
- package/dist/workflow-engine/tasks/try.d.ts +49 -0
- package/dist/workflow-engine/tasks/try.js +189 -0
- package/dist/workflow-engine/tasks/try.js.map +1 -0
- package/dist/workflow-engine/tasks/wait.d.ts +24 -0
- package/dist/workflow-engine/tasks/wait.js +39 -0
- package/dist/workflow-engine/tasks/wait.js.map +1 -0
- package/dist/workflow-engine/types.d.ts +682 -0
- package/dist/workflow-engine/types.js +47 -0
- package/dist/workflow-engine/types.js.map +1 -0
- package/dist/workflows/call-agent-orchestrator.d.ts +31 -0
- package/dist/workflows/call-agent-orchestrator.js +214 -0
- package/dist/workflows/call-agent-orchestrator.js.map +1 -0
- package/dist/workflows/connect-mcp-server.d.ts +20 -0
- package/dist/workflows/connect-mcp-server.js +113 -0
- package/dist/workflows/connect-mcp-server.js.map +1 -0
- package/dist/workflows/engine-core.d.ts +36 -0
- package/dist/workflows/engine-core.js +272 -0
- package/dist/workflows/engine-core.js.map +1 -0
- package/dist/workflows/execute-from-execution.d.ts +32 -0
- package/dist/workflows/execute-from-execution.js +71 -0
- package/dist/workflows/execute-from-execution.js.map +1 -0
- package/dist/workflows/execute-serverless-workflow.d.ts +32 -0
- package/dist/workflows/execute-serverless-workflow.js +36 -0
- package/dist/workflows/execute-serverless-workflow.js.map +1 -0
- package/dist/workflows/human-input-orchestrator.d.ts +19 -0
- package/dist/workflows/human-input-orchestrator.js +59 -0
- package/dist/workflows/human-input-orchestrator.js.map +1 -0
- package/dist/workflows/index.d.ts +22 -0
- package/dist/workflows/index.js +23 -0
- package/dist/workflows/index.js.map +1 -0
- package/dist/workflows/listen-orchestrator.d.ts +29 -0
- package/dist/workflows/listen-orchestrator.js +143 -0
- package/dist/workflows/listen-orchestrator.js.map +1 -0
- package/dist/workflows/metrics-sink.d.ts +33 -0
- package/dist/workflows/metrics-sink.js +21 -0
- package/dist/workflows/metrics-sink.js.map +1 -0
- package/dist/workflows/run-orchestrator.d.ts +15 -0
- package/dist/workflows/run-orchestrator.js +27 -0
- package/dist/workflows/run-orchestrator.js.map +1 -0
- package/dist/workflows/types.d.ts +46 -0
- package/dist/workflows/types.js +15 -0
- package/dist/workflows/types.js.map +1 -0
- package/dist/workflows/workflow-signals.d.ts +29 -0
- package/dist/workflows/workflow-signals.js +46 -0
- package/dist/workflows/workflow-signals.js.map +1 -0
- package/package.json +108 -0
- package/src/__test-utils__/__tests__/replay-fetch.test.ts +155 -0
- package/src/__test-utils__/mock-client.ts +44 -0
- package/src/__test-utils__/mock-workspace.ts +28 -0
- package/src/__test-utils__/proto-helpers.ts +41 -0
- package/src/__test-utils__/replay-fetch.ts +523 -0
- package/src/__tests__/bootstrap.test.ts +221 -0
- package/src/__tests__/claimcheck-codec.test.ts +257 -0
- package/src/__tests__/config.test.ts +150 -0
- package/src/__tests__/deterministic-eval-llm.test.ts +269 -0
- package/src/__tests__/deterministic-mcp-hitl.test.ts +405 -0
- package/src/__tests__/golden-e2e.test.ts +250 -0
- package/src/__tests__/ipc-protocol-fixtures.test.ts +66 -0
- package/src/__tests__/ipc-protocol.test.ts +32 -0
- package/src/__tests__/otel-metrics.test.ts +40 -0
- package/src/__tests__/runner-manager.test.ts +55 -0
- package/src/__tests__/runner-token-coordinator.test.ts +166 -0
- package/src/__tests__/runner.test.ts +182 -0
- package/src/__tests__/worker.test.ts +18 -0
- package/src/activities/__tests__/call-agent-contracts.test.ts +483 -0
- package/src/activities/__tests__/call-agent.test.ts +263 -0
- package/src/activities/__tests__/call-function.test.ts +47 -0
- package/src/activities/__tests__/call-grpc.test.ts +39 -0
- package/src/activities/__tests__/call-http.test.ts +288 -0
- package/src/activities/__tests__/call-llm.test.ts +301 -0
- package/src/activities/__tests__/classify-tool-approvals.test.ts +430 -0
- package/src/activities/__tests__/discover-mcp-server.test.ts +641 -0
- package/src/activities/__tests__/ensure-thread.test.ts +96 -0
- package/src/activities/__tests__/error-classifier.test.ts +372 -0
- package/src/activities/__tests__/evaluate-expressions.test.ts +114 -0
- package/src/activities/__tests__/hydrate-workflow-execution.test.ts +321 -0
- package/src/activities/__tests__/notification.test.ts +151 -0
- package/src/activities/__tests__/workflow-event-activities.test.ts +664 -0
- package/src/activities/call-agent-status.ts +130 -0
- package/src/activities/call-agent.ts +302 -0
- package/src/activities/call-eval.ts +333 -0
- package/src/activities/call-function.ts +73 -0
- package/src/activities/call-grpc.ts +140 -0
- package/src/activities/call-http.ts +185 -0
- package/src/activities/call-llm.ts +379 -0
- package/src/activities/call-transform.ts +54 -0
- package/src/activities/call-validate.ts +223 -0
- package/src/activities/classify-tool-approvals.ts +319 -0
- package/src/activities/discover-mcp-server.ts +411 -0
- package/src/activities/emit-event.ts +195 -0
- package/src/activities/ensure-thread.ts +45 -0
- package/src/activities/evaluate-expressions.ts +47 -0
- package/src/activities/execute-cursor/__tests__/approval-gate.test.ts +188 -0
- package/src/activities/execute-cursor/__tests__/build-prompt.test.ts +111 -0
- package/src/activities/execute-cursor/__tests__/cursor-baseurl-routing.test.ts +86 -0
- package/src/activities/execute-cursor/__tests__/cursor-fetch-interceptor-bypass.test.ts +64 -0
- package/src/activities/execute-cursor/__tests__/cursor-mode.test.ts +95 -0
- package/src/activities/execute-cursor/__tests__/cursor-sdk-auth-smoke.test.ts +90 -0
- package/src/activities/execute-cursor/__tests__/delta-enricher.test.ts +242 -0
- package/src/activities/execute-cursor/__tests__/error-classifier-introspection.test.ts +156 -0
- package/src/activities/execute-cursor/__tests__/fetch-interceptor.test.ts +211 -0
- package/src/activities/execute-cursor/__tests__/hitl-ledger.test.ts +298 -0
- package/src/activities/execute-cursor/__tests__/http2-interceptor.test.ts +360 -0
- package/src/activities/execute-cursor/__tests__/message-translator.test.ts +657 -0
- package/src/activities/execute-cursor/__tests__/model-pricing.test.ts +92 -0
- package/src/activities/execute-cursor/__tests__/prompt-builder-delegation.test.ts +101 -0
- package/src/activities/execute-cursor/__tests__/runner-error-regressions.test.ts +144 -0
- package/src/activities/execute-cursor/__tests__/session-lifecycle.test.ts +65 -0
- package/src/activities/execute-cursor/__tests__/skill-resolver.test.ts +265 -0
- package/src/activities/execute-cursor/__tests__/subagent-config.test.ts +107 -0
- package/src/activities/execute-cursor/__tests__/todo-tracker.test.ts +498 -0
- package/src/activities/execute-cursor/__tests__/workspace-provision.test.ts +283 -0
- package/src/activities/execute-cursor/approval-policy.ts +224 -0
- package/src/activities/execute-cursor/approval-state.ts +311 -0
- package/src/activities/execute-cursor/attachment-resolver.ts +78 -0
- package/src/activities/execute-cursor/blueprint-resolver.ts +234 -0
- package/src/activities/execute-cursor/connect-backfill.ts +49 -0
- package/src/activities/execute-cursor/cursor-event-recorder.ts +83 -0
- package/src/activities/execute-cursor/cursor-mode.ts +42 -0
- package/src/activities/execute-cursor/delta-enricher.ts +307 -0
- package/src/activities/execute-cursor/env-resolver.ts +64 -0
- package/src/activities/execute-cursor/error-classifier.ts +247 -0
- package/src/activities/execute-cursor/fetch-interceptor.ts +382 -0
- package/src/activities/execute-cursor/hitl-diagnostics.ts +82 -0
- package/src/activities/execute-cursor/hook-script.ts +159 -0
- package/src/activities/execute-cursor/http2-interceptor.ts +253 -0
- package/src/activities/execute-cursor/index.ts +1439 -0
- package/src/activities/execute-cursor/mcp-config.ts +66 -0
- package/src/activities/execute-cursor/mcp-resolver.ts +271 -0
- package/src/activities/execute-cursor/message-translator.ts +896 -0
- package/src/activities/execute-cursor/model-pricing-data.ts +167 -0
- package/src/activities/execute-cursor/model-pricing.ts +167 -0
- package/src/activities/execute-cursor/placeholder-resolver.ts +109 -0
- package/src/activities/execute-cursor/prompt-builder.ts +349 -0
- package/src/activities/execute-cursor/rejection-capture.ts +100 -0
- package/src/activities/execute-cursor/session-lifecycle.ts +429 -0
- package/src/activities/execute-cursor/skill-resolver.ts +176 -0
- package/src/activities/execute-cursor/subagent-config.ts +62 -0
- package/src/activities/execute-cursor/todo-tracker.ts +133 -0
- package/src/activities/execute-cursor/usage-accumulator.ts +126 -0
- package/src/activities/execute-cursor/workspace-provision.ts +55 -0
- package/src/activities/execute-cursor/workspace-setup.ts +75 -0
- package/src/activities/execute-deep-agent/__test-utils__/v3-event-fixtures.ts +281 -0
- package/src/activities/execute-deep-agent/__tests__/attachment-injector.test.ts +720 -0
- package/src/activities/execute-deep-agent/__tests__/auto-publish.test.ts +146 -0
- package/src/activities/execute-deep-agent/__tests__/environment.test.ts +103 -0
- package/src/activities/execute-deep-agent/__tests__/event-recorder.test.ts +150 -0
- package/src/activities/execute-deep-agent/__tests__/execution-state-extended.test.ts +150 -0
- package/src/activities/execute-deep-agent/__tests__/execution-state.test.ts +157 -0
- package/src/activities/execute-deep-agent/__tests__/hitl-integration.test.ts +223 -0
- package/src/activities/execute-deep-agent/__tests__/hitl.test.ts +244 -0
- package/src/activities/execute-deep-agent/__tests__/index.test.ts +91 -0
- package/src/activities/execute-deep-agent/__tests__/inline-publisher.test.ts +240 -0
- package/src/activities/execute-deep-agent/__tests__/post-stream.test.ts +112 -0
- package/src/activities/execute-deep-agent/__tests__/prompt-builder.test.ts +208 -0
- package/src/activities/execute-deep-agent/__tests__/status-builder.test.ts +1771 -0
- package/src/activities/execute-deep-agent/__tests__/streaming-scheduler.test.ts +199 -0
- package/src/activities/execute-deep-agent/__tests__/streaming-v3.test.ts +527 -0
- package/src/activities/execute-deep-agent/__tests__/streaming.test.ts +508 -0
- package/src/activities/execute-deep-agent/__tests__/subagent-tracker.test.ts +474 -0
- package/src/activities/execute-deep-agent/__tests__/subagent-transformer.test.ts +734 -0
- package/src/activities/execute-deep-agent/__tests__/subagent-wiring.test.ts +71 -0
- package/src/activities/execute-deep-agent/__tests__/summarization-verification.test.ts +323 -0
- package/src/activities/execute-deep-agent/__tests__/v3-event-recorder.test.ts +186 -0
- package/src/activities/execute-deep-agent/__tests__/v3-protocol-normalizer.test.ts +324 -0
- package/src/activities/execute-deep-agent/__tests__/v3-status-builder.test.ts +504 -0
- package/src/activities/execute-deep-agent/__tests__/writeback-coordinator.test.ts +399 -0
- package/src/activities/execute-deep-agent/attachment-injector.ts +470 -0
- package/src/activities/execute-deep-agent/auto-publish.ts +80 -0
- package/src/activities/execute-deep-agent/environment.ts +67 -0
- package/src/activities/execute-deep-agent/event-recorder.ts +95 -0
- package/src/activities/execute-deep-agent/execution-state.ts +87 -0
- package/src/activities/execute-deep-agent/execution-status-writer.ts +19 -0
- package/src/activities/execute-deep-agent/hitl.ts +221 -0
- package/src/activities/execute-deep-agent/index.ts +342 -0
- package/src/activities/execute-deep-agent/inline-publisher.ts +134 -0
- package/src/activities/execute-deep-agent/post-stream.ts +109 -0
- package/src/activities/execute-deep-agent/prompt-builder.ts +264 -0
- package/src/activities/execute-deep-agent/setup.ts +599 -0
- package/src/activities/execute-deep-agent/status-builder-shared.ts +136 -0
- package/src/activities/execute-deep-agent/status-builder.ts +412 -0
- package/src/activities/execute-deep-agent/streaming-scheduler.ts +159 -0
- package/src/activities/execute-deep-agent/streaming-side-effects.ts +89 -0
- package/src/activities/execute-deep-agent/streaming-terminal.ts +96 -0
- package/src/activities/execute-deep-agent/streaming-v3.ts +272 -0
- package/src/activities/execute-deep-agent/streaming.ts +303 -0
- package/src/activities/execute-deep-agent/subagent-tracker.ts +445 -0
- package/src/activities/execute-deep-agent/subagent-transformer.ts +648 -0
- package/src/activities/execute-deep-agent/subagent-wiring.ts +56 -0
- package/src/activities/execute-deep-agent/v3-event-recorder.ts +111 -0
- package/src/activities/execute-deep-agent/v3-events.ts +153 -0
- package/src/activities/execute-deep-agent/v3-protocol-normalizer.ts +264 -0
- package/src/activities/execute-deep-agent/v3-status-builder.ts +490 -0
- package/src/activities/execute-deep-agent/writeback-coordinator.ts +420 -0
- package/src/activities/hydrate-workflow-execution.ts +306 -0
- package/src/activities/notification.ts +71 -0
- package/src/activities/promote-task-output.ts +126 -0
- package/src/activities/run-command.ts +148 -0
- package/src/activities/workflow-event-activities.ts +481 -0
- package/src/bootstrap.ts +173 -0
- package/src/budget/__tests__/tracker.test.ts +293 -0
- package/src/budget/index.ts +9 -0
- package/src/budget/tracker.ts +171 -0
- package/src/claimcheck/compressor.ts +9 -0
- package/src/claimcheck/config.ts +20 -0
- package/src/claimcheck/index.ts +3 -0
- package/src/claimcheck/payload-codec.ts +107 -0
- package/src/client/__tests__/server-contracts.test.ts +149 -0
- package/src/client/__tests__/stigmer-client.test.ts +142 -0
- package/src/client/server-contracts.ts +125 -0
- package/src/client/stigmer-client.ts +339 -0
- package/src/config.ts +185 -0
- package/src/idle-watchdog.ts +28 -0
- package/src/index.ts +48 -0
- package/src/interceptors/workflow-metrics-sink.ts +56 -0
- package/src/ipc-protocol-fixtures.ts +117 -0
- package/src/ipc-protocol.ts +113 -0
- package/src/main.ts +324 -0
- package/src/middleware/__tests__/approval-gate.test.ts +231 -0
- package/src/middleware/__tests__/cost-cap.test.ts +192 -0
- package/src/middleware/__tests__/error-hints.test.ts +90 -0
- package/src/middleware/__tests__/execution-budget.test.ts +138 -0
- package/src/middleware/__tests__/graceful-stop.test.ts +105 -0
- package/src/middleware/__tests__/loop-detection.test.ts +137 -0
- package/src/middleware/__tests__/otel-spans.test.ts +89 -0
- package/src/middleware/__tests__/think-tool.test.ts +26 -0
- package/src/middleware/__tests__/tool-truncation.test.ts +112 -0
- package/src/middleware/approval-gate.ts +179 -0
- package/src/middleware/cost-cap.ts +213 -0
- package/src/middleware/error-hints.ts +136 -0
- package/src/middleware/execution-budget.ts +176 -0
- package/src/middleware/graceful-stop.ts +86 -0
- package/src/middleware/index.ts +70 -0
- package/src/middleware/loop-detection.ts +192 -0
- package/src/middleware/otel-spans.ts +205 -0
- package/src/middleware/think-tool.ts +38 -0
- package/src/middleware/tool-truncation.ts +94 -0
- package/src/middleware/types.ts +114 -0
- package/src/notification/__tests__/provider.test.ts +85 -0
- package/src/notification/__tests__/webhook.test.ts +127 -0
- package/src/notification/index.ts +15 -0
- package/src/notification/provider.ts +52 -0
- package/src/notification/webhook.ts +61 -0
- package/src/otel-metrics.ts +73 -0
- package/src/otel.ts +194 -0
- package/src/runner-manager.ts +652 -0
- package/src/runner-token-coordinator.ts +135 -0
- package/src/runner.ts +380 -0
- package/src/shared/__tests__/approval-policy.test.ts +256 -0
- package/src/shared/__tests__/artifact-storage-extended.test.ts +208 -0
- package/src/shared/__tests__/artifact-storage.test.ts +365 -0
- package/src/shared/__tests__/connect-backfill.test.ts +346 -0
- package/src/shared/__tests__/extract-json.test.ts +153 -0
- package/src/shared/__tests__/grpc-retry-extended.test.ts +176 -0
- package/src/shared/__tests__/grpc-retry.test.ts +172 -0
- package/src/shared/__tests__/json-schema-to-zod.test.ts +227 -0
- package/src/shared/__tests__/llm-proxy.test.ts +179 -0
- package/src/shared/__tests__/mcp-manager.test.ts +154 -0
- package/src/shared/__tests__/model-pricing.test.ts +85 -0
- package/src/shared/__tests__/model-registry.test.ts +197 -0
- package/src/shared/__tests__/placeholder-resolver.test.ts +210 -0
- package/src/shared/__tests__/plan-artifact.test.ts +142 -0
- package/src/shared/__tests__/skill-relevance.test.ts +292 -0
- package/src/shared/__tests__/skill-writer.test.ts +349 -0
- package/src/shared/__tests__/status.test.ts +142 -0
- package/src/shared/__tests__/subagent-gate.test.ts +112 -0
- package/src/shared/__tests__/tool-kind.test.ts +58 -0
- package/src/shared/__tests__/zip-extract.test.ts +204 -0
- package/src/shared/approval-policy.ts +146 -0
- package/src/shared/artifact-storage.ts +207 -0
- package/src/shared/checkpointer/__tests__/factory.test.ts +42 -0
- package/src/shared/checkpointer/__tests__/http-saver.test.ts +176 -0
- package/src/shared/checkpointer/factory.ts +73 -0
- package/src/shared/checkpointer/http-saver.ts +349 -0
- package/src/shared/checkpointer/types.ts +12 -0
- package/src/shared/connect-backfill.ts +162 -0
- package/src/shared/extract-json.ts +153 -0
- package/src/shared/grpc-retry.ts +113 -0
- package/src/shared/heartbeat.ts +70 -0
- package/src/shared/json-schema-to-zod.ts +53 -0
- package/src/shared/llm-proxy.ts +138 -0
- package/src/shared/mcp-manager.ts +150 -0
- package/src/shared/mcp-resolver.ts +150 -0
- package/src/shared/model-pricing-data.ts +109 -0
- package/src/shared/model-pricing.ts +81 -0
- package/src/shared/model-registry.ts +214 -0
- package/src/shared/placeholder-resolver.ts +102 -0
- package/src/shared/plan-artifact.ts +120 -0
- package/src/shared/skill-relevance.ts +222 -0
- package/src/shared/skill-writer.ts +300 -0
- package/src/shared/status.ts +94 -0
- package/src/shared/subagent-gate.ts +117 -0
- package/src/shared/tool-kind.ts +91 -0
- package/src/shared/workspace/__tests__/file-tree.test.ts +210 -0
- package/src/shared/workspace/__tests__/git-source.test.ts +423 -0
- package/src/shared/workspace/__tests__/local-backend-platform.test.ts +259 -0
- package/src/shared/workspace/__tests__/local-backend.test.ts +154 -0
- package/src/shared/workspace/__tests__/platform-mount.test.ts +378 -0
- package/src/shared/workspace/__tests__/provisioner.test.ts +145 -0
- package/src/shared/workspace/file-tree.ts +116 -0
- package/src/shared/workspace/local-backend.ts +140 -0
- package/src/shared/workspace/platform-dir.ts +38 -0
- package/src/shared/workspace/platform-mount.ts +190 -0
- package/src/shared/workspace/provisioner.ts +150 -0
- package/src/shared/workspace/sources/empty.ts +20 -0
- package/src/shared/workspace/sources/git.ts +285 -0
- package/src/shared/workspace/sources/local-path.ts +89 -0
- package/src/shared/workspace/types.ts +69 -0
- package/src/shared/zip-extract.ts +193 -0
- package/src/worker.ts +98 -0
- package/src/workflow-engine/__tests__/do-executor-recovery.test.ts +382 -0
- package/src/workflow-engine/__tests__/do-executor.test.ts +963 -0
- package/src/workflow-engine/__tests__/errors.test.ts +174 -0
- package/src/workflow-engine/__tests__/expression.test.ts +776 -0
- package/src/workflow-engine/__tests__/for.test.ts +575 -0
- package/src/workflow-engine/__tests__/fork.test.ts +838 -0
- package/src/workflow-engine/__tests__/golden-execution.test.ts +1085 -0
- package/src/workflow-engine/__tests__/jq-wasm-spike.test.ts +90 -0
- package/src/workflow-engine/__tests__/loader.test.ts +1393 -0
- package/src/workflow-engine/__tests__/pause-resume.test.ts +267 -0
- package/src/workflow-engine/__tests__/recovery.test.ts +115 -0
- package/src/workflow-engine/__tests__/resolve.test.ts +432 -0
- package/src/workflow-engine/__tests__/retry.test.ts +306 -0
- package/src/workflow-engine/__tests__/state.test.ts +174 -0
- package/src/workflow-engine/__tests__/task-status-accumulator.test.ts +373 -0
- package/src/workflow-engine/__tests__/tasks/call-agent-output.test.ts +120 -0
- package/src/workflow-engine/__tests__/tasks/call-agent.test.ts +816 -0
- package/src/workflow-engine/__tests__/tasks/call-function.test.ts +205 -0
- package/src/workflow-engine/__tests__/tasks/call-grpc.test.ts +133 -0
- package/src/workflow-engine/__tests__/tasks/call-http.test.ts +150 -0
- package/src/workflow-engine/__tests__/tasks/emit-event.test.ts +322 -0
- package/src/workflow-engine/__tests__/tasks/human-input.test.ts +416 -0
- package/src/workflow-engine/__tests__/tasks/listen.test.ts +422 -0
- package/src/workflow-engine/__tests__/tasks/raise.test.ts +166 -0
- package/src/workflow-engine/__tests__/tasks/run.test.ts +272 -0
- package/src/workflow-engine/__tests__/tasks/set.test.ts +127 -0
- package/src/workflow-engine/__tests__/tasks/switch.test.ts +277 -0
- package/src/workflow-engine/__tests__/tasks/try.test.ts +590 -0
- package/src/workflow-engine/__tests__/tasks/wait.test.ts +173 -0
- package/src/workflow-engine/clone.ts +18 -0
- package/src/workflow-engine/do-executor.ts +569 -0
- package/src/workflow-engine/duration.ts +22 -0
- package/src/workflow-engine/error-utils.ts +97 -0
- package/src/workflow-engine/errors.ts +130 -0
- package/src/workflow-engine/expression-utils.ts +129 -0
- package/src/workflow-engine/expression.ts +430 -0
- package/src/workflow-engine/loader.ts +524 -0
- package/src/workflow-engine/recovery.ts +80 -0
- package/src/workflow-engine/resolve.ts +342 -0
- package/src/workflow-engine/retry.ts +109 -0
- package/src/workflow-engine/state.ts +56 -0
- package/src/workflow-engine/task-factory.ts +160 -0
- package/src/workflow-engine/task-status-accumulator.ts +204 -0
- package/src/workflow-engine/tasks/call-agent-output.ts +132 -0
- package/src/workflow-engine/tasks/call-agent.ts +221 -0
- package/src/workflow-engine/tasks/call-function.ts +107 -0
- package/src/workflow-engine/tasks/call-grpc.ts +47 -0
- package/src/workflow-engine/tasks/call-http.ts +51 -0
- package/src/workflow-engine/tasks/for.ts +244 -0
- package/src/workflow-engine/tasks/fork.ts +228 -0
- package/src/workflow-engine/tasks/human-input.ts +147 -0
- package/src/workflow-engine/tasks/listen.ts +166 -0
- package/src/workflow-engine/tasks/raise.ts +81 -0
- package/src/workflow-engine/tasks/run.ts +142 -0
- package/src/workflow-engine/tasks/set.ts +47 -0
- package/src/workflow-engine/tasks/switch.ts +102 -0
- package/src/workflow-engine/tasks/try.ts +274 -0
- package/src/workflow-engine/tasks/wait.ts +53 -0
- package/src/workflow-engine/types.ts +911 -0
- package/src/workflows/__tests__/connect-mcp-server.test.ts +359 -0
- package/src/workflows/__tests__/execute-serverless-workflow.test.ts +277 -0
- package/src/workflows/call-agent-orchestrator.ts +283 -0
- package/src/workflows/connect-mcp-server.ts +152 -0
- package/src/workflows/engine-core.ts +406 -0
- package/src/workflows/execute-from-execution.ts +101 -0
- package/src/workflows/execute-serverless-workflow.ts +60 -0
- package/src/workflows/human-input-orchestrator.ts +76 -0
- package/src/workflows/index.ts +32 -0
- package/src/workflows/listen-orchestrator.ts +200 -0
- package/src/workflows/metrics-sink.ts +48 -0
- package/src/workflows/run-orchestrator.ts +34 -0
- package/src/workflows/types.ts +64 -0
- package/src/workflows/workflow-signals.ts +55 -0
|
@@ -0,0 +1,213 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Cost cap middleware for agent execution budget enforcement.
|
|
3
|
+
*
|
|
4
|
+
* Tracks running estimated cost of LLM calls and enforces a
|
|
5
|
+
* configurable cost ceiling:
|
|
6
|
+
*
|
|
7
|
+
* afterModel — extracts usage_metadata from the latest AIMessage,
|
|
8
|
+
* computes incremental cost, accumulates a running total. Injects
|
|
9
|
+
* a warning SystemMessage at ~80% and a termination message at 100%.
|
|
10
|
+
*
|
|
11
|
+
* wrapToolCall — blocks all tool execution when the budget is exceeded,
|
|
12
|
+
* giving the model one final tool-free round to produce a summary.
|
|
13
|
+
*
|
|
14
|
+
* Only injected when maxCostUsd > 0 is explicitly configured.
|
|
15
|
+
*/
|
|
16
|
+
|
|
17
|
+
import { ToolMessage, SystemMessage } from "@langchain/core/messages";
|
|
18
|
+
import type { StigmerMiddleware, CostCapConfig } from "./types.js";
|
|
19
|
+
|
|
20
|
+
const DEFAULT_WARNING_PCT = 80;
|
|
21
|
+
const MIN_WARNING_PCT = 50;
|
|
22
|
+
const MAX_WARNING_PCT = 95;
|
|
23
|
+
|
|
24
|
+
export interface CostCapMiddleware extends StigmerMiddleware {
|
|
25
|
+
readonly runningCost: number;
|
|
26
|
+
readonly exceeded: boolean;
|
|
27
|
+
forSubAgent(): StigmerMiddleware;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
interface UsageMetadata {
|
|
31
|
+
input_tokens?: number;
|
|
32
|
+
output_tokens?: number;
|
|
33
|
+
input_token_details?: { cache_read?: number } | null;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
function extractUsage(aiMessage: Record<string, unknown>): {
|
|
37
|
+
totalInput: number; output: number; cacheRead: number;
|
|
38
|
+
} {
|
|
39
|
+
const usage = (aiMessage as { usage_metadata?: UsageMetadata }).usage_metadata;
|
|
40
|
+
if (!usage) return { totalInput: 0, output: 0, cacheRead: 0 };
|
|
41
|
+
|
|
42
|
+
const totalInput = usage.input_tokens ?? 0;
|
|
43
|
+
const output = usage.output_tokens ?? 0;
|
|
44
|
+
const details = usage.input_token_details;
|
|
45
|
+
const cacheRead = (details && typeof details === "object")
|
|
46
|
+
? (details.cache_read ?? 0)
|
|
47
|
+
: 0;
|
|
48
|
+
|
|
49
|
+
return { totalInput, output, cacheRead };
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
export function createCostCapMiddleware(config: CostCapConfig): CostCapMiddleware {
|
|
53
|
+
const {
|
|
54
|
+
maxCostUsd,
|
|
55
|
+
inputPricePerMillion,
|
|
56
|
+
outputPricePerMillion,
|
|
57
|
+
cacheReadPricePerMillion,
|
|
58
|
+
} = config;
|
|
59
|
+
const warningPct = config.warningPct ?? DEFAULT_WARNING_PCT;
|
|
60
|
+
|
|
61
|
+
if (maxCostUsd <= 0) throw new Error(`maxCostUsd must be positive, got ${maxCostUsd}`);
|
|
62
|
+
if (warningPct < MIN_WARNING_PCT || warningPct > MAX_WARNING_PCT) {
|
|
63
|
+
throw new Error(`warningPct must be between ${MIN_WARNING_PCT} and ${MAX_WARNING_PCT}, got ${warningPct}`);
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
let runningCost = 0;
|
|
67
|
+
let warned = false;
|
|
68
|
+
let exceeded = false;
|
|
69
|
+
let modelCallCount = 0;
|
|
70
|
+
|
|
71
|
+
function computeCallCost(totalInput: number, output: number, cacheRead: number): number {
|
|
72
|
+
let inputCost: number;
|
|
73
|
+
let cacheCost: number;
|
|
74
|
+
|
|
75
|
+
if (cacheReadPricePerMillion > 0 && cacheRead > 0) {
|
|
76
|
+
const regularInput = Math.max(totalInput - cacheRead, 0);
|
|
77
|
+
inputCost = regularInput * inputPricePerMillion;
|
|
78
|
+
cacheCost = cacheRead * cacheReadPricePerMillion;
|
|
79
|
+
} else {
|
|
80
|
+
inputCost = totalInput * inputPricePerMillion;
|
|
81
|
+
cacheCost = 0;
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
const outputCost = output * outputPricePerMillion;
|
|
85
|
+
return (inputCost + cacheCost + outputCost) / 1_000_000;
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
function createWarningMessage(): SystemMessage {
|
|
89
|
+
const pct = maxCostUsd > 0 ? (runningCost / maxCostUsd * 100) : 0;
|
|
90
|
+
const remaining = Math.max(maxCostUsd - runningCost, 0);
|
|
91
|
+
return new SystemMessage({
|
|
92
|
+
content:
|
|
93
|
+
`Budget warning: This execution has consumed ` +
|
|
94
|
+
`$${runningCost.toFixed(4)} of the $${maxCostUsd.toFixed(2)} ` +
|
|
95
|
+
`budget (${pct.toFixed(0)}%). ` +
|
|
96
|
+
`Approximately $${remaining.toFixed(4)} remaining. ` +
|
|
97
|
+
`Prioritize completing your current task. Summarize results ` +
|
|
98
|
+
`and any remaining work so the user can continue in the next message.`,
|
|
99
|
+
});
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
function createExceededMessage(): SystemMessage {
|
|
103
|
+
return new SystemMessage({
|
|
104
|
+
content:
|
|
105
|
+
`Budget exceeded: This execution has consumed ` +
|
|
106
|
+
`$${runningCost.toFixed(4)}, exceeding the ` +
|
|
107
|
+
`$${maxCostUsd.toFixed(2)} budget. ` +
|
|
108
|
+
`All tool calls are now blocked. ` +
|
|
109
|
+
`Respond with a summary of what you accomplished and ` +
|
|
110
|
+
`what work remains so the user can continue.`,
|
|
111
|
+
});
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
function processAfterModel(state: Record<string, unknown>): { messages: SystemMessage[] } | void {
|
|
115
|
+
if (exceeded) return;
|
|
116
|
+
|
|
117
|
+
const messages = (state.messages ?? []) as unknown[];
|
|
118
|
+
let lastAi: Record<string, unknown> | null = null;
|
|
119
|
+
for (let i = messages.length - 1; i >= 0; i--) {
|
|
120
|
+
const msg = messages[i] as { _getType?: () => string };
|
|
121
|
+
if (msg?._getType?.() === "ai") {
|
|
122
|
+
lastAi = msg as Record<string, unknown>;
|
|
123
|
+
break;
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
if (!lastAi) return;
|
|
127
|
+
|
|
128
|
+
const { totalInput, output, cacheRead } = extractUsage(lastAi);
|
|
129
|
+
if (totalInput === 0 && output === 0) return;
|
|
130
|
+
|
|
131
|
+
const callCost = computeCallCost(totalInput, output, cacheRead);
|
|
132
|
+
runningCost += callCost;
|
|
133
|
+
modelCallCount++;
|
|
134
|
+
|
|
135
|
+
const warningThreshold = maxCostUsd * warningPct / 100;
|
|
136
|
+
|
|
137
|
+
if (runningCost >= maxCostUsd) {
|
|
138
|
+
exceeded = true;
|
|
139
|
+
console.warn(
|
|
140
|
+
`[CostCap] EXCEEDED: $${runningCost.toFixed(4)} >= $${maxCostUsd.toFixed(2)} ` +
|
|
141
|
+
`after ${modelCallCount} calls. Tool execution will be blocked.`,
|
|
142
|
+
);
|
|
143
|
+
return { messages: [createExceededMessage()] };
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
if (!warned && runningCost >= warningThreshold) {
|
|
147
|
+
warned = true;
|
|
148
|
+
console.warn(
|
|
149
|
+
`[CostCap] WARNING: $${runningCost.toFixed(4)} >= $${warningThreshold.toFixed(4)} ` +
|
|
150
|
+
`(${warningPct}% of $${maxCostUsd.toFixed(2)}) after ${modelCallCount} calls.`,
|
|
151
|
+
);
|
|
152
|
+
return { messages: [createWarningMessage()] };
|
|
153
|
+
}
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
async function processWrapToolCall(
|
|
157
|
+
request: Parameters<NonNullable<StigmerMiddleware["wrapToolCall"]>>[0],
|
|
158
|
+
handler: Parameters<NonNullable<StigmerMiddleware["wrapToolCall"]>>[1],
|
|
159
|
+
) {
|
|
160
|
+
if (exceeded) {
|
|
161
|
+
return new ToolMessage({
|
|
162
|
+
content:
|
|
163
|
+
`[Budget exceeded: tool execution blocked. ` +
|
|
164
|
+
`Summarize your progress for the user.]`,
|
|
165
|
+
tool_call_id: request.toolCall.id,
|
|
166
|
+
name: request.toolCall.name,
|
|
167
|
+
});
|
|
168
|
+
}
|
|
169
|
+
return await handler(request);
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
const middleware: CostCapMiddleware = {
|
|
173
|
+
name: "CostCapMiddleware",
|
|
174
|
+
|
|
175
|
+
get runningCost() { return runningCost; },
|
|
176
|
+
get exceeded() { return exceeded; },
|
|
177
|
+
|
|
178
|
+
beforeAgent() {
|
|
179
|
+
runningCost = 0;
|
|
180
|
+
warned = false;
|
|
181
|
+
exceeded = false;
|
|
182
|
+
modelCallCount = 0;
|
|
183
|
+
},
|
|
184
|
+
|
|
185
|
+
afterModel(state) {
|
|
186
|
+
return processAfterModel(state);
|
|
187
|
+
},
|
|
188
|
+
|
|
189
|
+
wrapToolCall: processWrapToolCall,
|
|
190
|
+
|
|
191
|
+
afterAgent() {
|
|
192
|
+
const pctUsed = maxCostUsd > 0
|
|
193
|
+
? (runningCost / maxCostUsd * 100)
|
|
194
|
+
: 0;
|
|
195
|
+
console.log(
|
|
196
|
+
`[CostCap] Summary: $${runningCost.toFixed(4)} of $${maxCostUsd.toFixed(2)} ` +
|
|
197
|
+
`(~${pctUsed.toFixed(0)}%) across ${modelCallCount} calls, ` +
|
|
198
|
+
`warned=${warned}, exceeded=${exceeded}`,
|
|
199
|
+
);
|
|
200
|
+
},
|
|
201
|
+
|
|
202
|
+
forSubAgent(): StigmerMiddleware {
|
|
203
|
+
return {
|
|
204
|
+
name: "CostCapSubAgentView",
|
|
205
|
+
// Sub-agent view does NOT reset state on beforeAgent
|
|
206
|
+
afterModel(state) { return processAfterModel(state); },
|
|
207
|
+
wrapToolCall: processWrapToolCall,
|
|
208
|
+
};
|
|
209
|
+
},
|
|
210
|
+
};
|
|
211
|
+
|
|
212
|
+
return middleware;
|
|
213
|
+
}
|
|
@@ -0,0 +1,136 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Error message enrichment for agent resilience.
|
|
3
|
+
*
|
|
4
|
+
* Two exports:
|
|
5
|
+
* 1. enrichErrorMessage() — pure utility that pattern-matches tool errors
|
|
6
|
+
* to actionable recovery hints.
|
|
7
|
+
* 2. createErrorHintsMiddleware() — wrapToolCall middleware that catches
|
|
8
|
+
* tool execution errors and enriches the ToolMessage with hints.
|
|
9
|
+
*
|
|
10
|
+
* Zero external dependencies beyond LangChain messages.
|
|
11
|
+
*/
|
|
12
|
+
|
|
13
|
+
import { ToolMessage } from "@langchain/core/messages";
|
|
14
|
+
import type { StigmerMiddleware } from "./types.js";
|
|
15
|
+
|
|
16
|
+
/**
|
|
17
|
+
* Enrich an error message with contextual recovery hints.
|
|
18
|
+
*
|
|
19
|
+
* Analyzes the error string and tool name to produce actionable
|
|
20
|
+
* suggestions that help the LLM try alternative approaches.
|
|
21
|
+
*/
|
|
22
|
+
export function enrichErrorMessage(toolName: string, error: string): string {
|
|
23
|
+
const hints: string[] = [];
|
|
24
|
+
const errorLower = error.toLowerCase();
|
|
25
|
+
const toolLower = toolName.toLowerCase();
|
|
26
|
+
|
|
27
|
+
if (errorLower.includes("not found") || errorLower.includes("no such file")) {
|
|
28
|
+
hints.push("Try using ls or glob to discover available files/resources");
|
|
29
|
+
hints.push("Check if the path is correct — use ls on the parent directory");
|
|
30
|
+
hints.push("The file might be in a different location — search with glob patterns");
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
if (errorLower.includes("permission") || errorLower.includes("access denied")) {
|
|
34
|
+
hints.push("Check if the path is correct and accessible");
|
|
35
|
+
hints.push("Verify you have the right permissions for this operation");
|
|
36
|
+
hints.push("Try an alternative location if the target is read-only");
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
if (errorLower.includes("text to replace not found")) {
|
|
40
|
+
hints.push("Re-read the file with the read tool to see its current contents");
|
|
41
|
+
hints.push("The file content may have changed — use the actual text from read output");
|
|
42
|
+
hints.push("Check for whitespace differences (tabs vs spaces, trailing newlines)");
|
|
43
|
+
hints.push("If the exact text cannot be matched, use write to replace the entire file");
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
if (toolLower.includes("edit") || toolLower.includes("write")) {
|
|
47
|
+
hints.push("Try reading the target first to understand its current state");
|
|
48
|
+
hints.push("If editing fails, try read + modify + write as a complete replacement");
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
if (errorLower.includes("auth") || errorLower.includes("unauthorized") || errorLower.includes("403")) {
|
|
52
|
+
hints.push("Verify authentication credentials are correct");
|
|
53
|
+
hints.push("Check if the token has expired or lacks required permissions");
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
if (errorLower.includes("connection") || errorLower.includes("timeout") || errorLower.includes("unavailable")) {
|
|
57
|
+
hints.push("This may be a transient error — wait a moment and retry");
|
|
58
|
+
hints.push("Check if the service is available");
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
if (errorLower.includes("invalid") || errorLower.includes("malformed") || errorLower.includes("format")) {
|
|
62
|
+
hints.push("Review the parameter format and types");
|
|
63
|
+
hints.push("Try with simplified or default parameters first");
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
if (errorLower.includes("rpc error") || errorLower.includes("grpc")) {
|
|
67
|
+
if (errorLower.includes("not found") || errorLower.includes("notfound")) {
|
|
68
|
+
hints.push("The requested resource does not exist on the platform yet");
|
|
69
|
+
hints.push("Use a list or search tool to discover existing resources");
|
|
70
|
+
}
|
|
71
|
+
if (errorLower.includes("permission denied") || errorLower.includes("permissiondenied")) {
|
|
72
|
+
hints.push("The API key or credentials lack permission for this operation");
|
|
73
|
+
}
|
|
74
|
+
if (errorLower.includes("unavailable")) {
|
|
75
|
+
hints.push("The backend service is temporarily unreachable — wait and retry");
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
if (
|
|
80
|
+
errorLower.includes("not found") &&
|
|
81
|
+
(errorLower.includes("org") || errorLower.includes("slug") ||
|
|
82
|
+
errorLower.includes("server") || errorLower.includes("environment"))
|
|
83
|
+
) {
|
|
84
|
+
hints.push("Verify the org and slug/name values are correct");
|
|
85
|
+
hints.push("The resource may not have been created yet");
|
|
86
|
+
hints.push("Use a list operation to see what exists in the current org/environment");
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
if (errorLower.includes("rate") || errorLower.includes("limit") ||
|
|
90
|
+
errorLower.includes("quota") || errorLower.includes("429")) {
|
|
91
|
+
hints.push("Wait a moment before retrying — rate limits reset over time");
|
|
92
|
+
hints.push("Try reducing the scope of your request");
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
if (hints.length > 0) {
|
|
96
|
+
const recovery = hints.map(h => `- ${h}`).join("\n");
|
|
97
|
+
return `Error: ${error}\n\nRecovery suggestions:\n${recovery}`;
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
return (
|
|
101
|
+
`Error: ${error}\n\n` +
|
|
102
|
+
"Recovery suggestions:\n" +
|
|
103
|
+
"- Analyze the error message for clues about what went wrong\n" +
|
|
104
|
+
"- Try a different approach or alternative tool\n" +
|
|
105
|
+
"- Verify your inputs and assumptions are correct"
|
|
106
|
+
);
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
/**
|
|
110
|
+
* Create middleware that enriches tool execution errors with recovery hints.
|
|
111
|
+
*
|
|
112
|
+
* Wraps every tool call in a try/catch. On error, produces a ToolMessage
|
|
113
|
+
* with the enriched error text instead of letting the error propagate
|
|
114
|
+
* as a raw string.
|
|
115
|
+
*/
|
|
116
|
+
export function createErrorHintsMiddleware(): StigmerMiddleware {
|
|
117
|
+
return {
|
|
118
|
+
name: "ErrorHintsMiddleware",
|
|
119
|
+
|
|
120
|
+
async wrapToolCall(request, handler) {
|
|
121
|
+
try {
|
|
122
|
+
return await handler(request);
|
|
123
|
+
} catch (err: unknown) {
|
|
124
|
+
const errorMessage = err instanceof Error ? err.message : String(err);
|
|
125
|
+
const toolName = request.toolCall.name;
|
|
126
|
+
const enriched = enrichErrorMessage(toolName, errorMessage);
|
|
127
|
+
|
|
128
|
+
return new ToolMessage({
|
|
129
|
+
content: enriched,
|
|
130
|
+
tool_call_id: request.toolCall.id,
|
|
131
|
+
name: toolName,
|
|
132
|
+
});
|
|
133
|
+
}
|
|
134
|
+
},
|
|
135
|
+
};
|
|
136
|
+
}
|
|
@@ -0,0 +1,176 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Execution budget middleware for autonomous agents.
|
|
3
|
+
*
|
|
4
|
+
* Two operating modes:
|
|
5
|
+
*
|
|
6
|
+
* Threshold mode (default, warningInterval=null):
|
|
7
|
+
* Fires a single SystemMessage at a computed percentage of the
|
|
8
|
+
* LangGraph recursion limit.
|
|
9
|
+
*
|
|
10
|
+
* Periodic mode (warningInterval set):
|
|
11
|
+
* Fires a SystemMessage every N model rounds with escalating urgency,
|
|
12
|
+
* up to maxWarnings times.
|
|
13
|
+
*
|
|
14
|
+
* Uses wrapModelCall (not afterModel) to safely prepend advisory
|
|
15
|
+
* messages to the model's input, avoiding the AIMessage/ToolMessage
|
|
16
|
+
* ordering violation that would occur if we injected between a
|
|
17
|
+
* tool_use AIMessage and its corresponding ToolMessage.
|
|
18
|
+
*/
|
|
19
|
+
|
|
20
|
+
import { SystemMessage } from "@langchain/core/messages";
|
|
21
|
+
import type { StigmerMiddleware, ExecutionBudgetConfig } from "./types.js";
|
|
22
|
+
|
|
23
|
+
const DEFAULT_RECURSION_LIMIT = 6000;
|
|
24
|
+
const DEFAULT_WARNING_PCT = 80;
|
|
25
|
+
const MIN_WARNING_PCT = 50;
|
|
26
|
+
const MAX_WARNING_PCT = 95;
|
|
27
|
+
const MIN_ROUNDS_BEFORE_WARNING = 3;
|
|
28
|
+
|
|
29
|
+
const PERIODIC_MESSAGES: readonly string[] = [
|
|
30
|
+
"You have been working for {rounds} model rounds. " +
|
|
31
|
+
"If your task is nearing completion, start wrapping up. " +
|
|
32
|
+
"Summarize progress so far and outline any remaining steps.",
|
|
33
|
+
|
|
34
|
+
"Extended execution: {rounds} model rounds. " +
|
|
35
|
+
"Prioritize completing your current task now. " +
|
|
36
|
+
"Summarize results and any remaining work so the user can " +
|
|
37
|
+
"continue in the next message.",
|
|
38
|
+
|
|
39
|
+
"Long-running execution: {rounds} model rounds. " +
|
|
40
|
+
"Wrap up your work — provide your findings and conclude. " +
|
|
41
|
+
"If you cannot finish, summarize what you accomplished and what remains.",
|
|
42
|
+
|
|
43
|
+
"Critical: {rounds} model rounds reached. " +
|
|
44
|
+
"Provide your final answer immediately with whatever " +
|
|
45
|
+
"information you have gathered. Do not start new tool calls " +
|
|
46
|
+
"unless absolutely essential to your conclusion.",
|
|
47
|
+
];
|
|
48
|
+
|
|
49
|
+
function computeWarningRound(recursionLimit: number, warningPct: number): number {
|
|
50
|
+
const estimatedTotalRounds = Math.floor(recursionLimit / 6);
|
|
51
|
+
const threshold = Math.floor(estimatedTotalRounds * warningPct / 100);
|
|
52
|
+
return Math.max(threshold, MIN_ROUNDS_BEFORE_WARNING);
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
export function createExecutionBudgetMiddleware(
|
|
56
|
+
config: Partial<ExecutionBudgetConfig> = {},
|
|
57
|
+
): StigmerMiddleware {
|
|
58
|
+
const recursionLimit = config.recursionLimit ?? DEFAULT_RECURSION_LIMIT;
|
|
59
|
+
const warningPct = config.warningPct ?? DEFAULT_WARNING_PCT;
|
|
60
|
+
const warningInterval = config.warningInterval ?? null;
|
|
61
|
+
const maxWarnings = config.maxWarnings ?? 4;
|
|
62
|
+
|
|
63
|
+
const isPeriodic = warningInterval !== null;
|
|
64
|
+
|
|
65
|
+
if (isPeriodic) {
|
|
66
|
+
if (warningInterval <= 0) throw new Error(`warningInterval must be positive, got ${warningInterval}`);
|
|
67
|
+
if (maxWarnings <= 0) throw new Error(`maxWarnings must be positive, got ${maxWarnings}`);
|
|
68
|
+
} else {
|
|
69
|
+
if (warningPct < MIN_WARNING_PCT || warningPct > MAX_WARNING_PCT) {
|
|
70
|
+
throw new Error(`warningPct must be between ${MIN_WARNING_PCT} and ${MAX_WARNING_PCT}, got ${warningPct}`);
|
|
71
|
+
}
|
|
72
|
+
if (recursionLimit <= 0) throw new Error(`recursionLimit must be positive, got ${recursionLimit}`);
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
let modelRoundCount = 0;
|
|
76
|
+
let warningCount = 0;
|
|
77
|
+
let nextWarningRound = isPeriodic
|
|
78
|
+
? warningInterval!
|
|
79
|
+
: computeWarningRound(recursionLimit, warningPct);
|
|
80
|
+
let pendingAdvisory: SystemMessage | null = null;
|
|
81
|
+
|
|
82
|
+
function createThresholdWarning(): SystemMessage {
|
|
83
|
+
const estimatedTotal = Math.floor(recursionLimit / 6);
|
|
84
|
+
const remaining = Math.max(estimatedTotal - modelRoundCount, 0);
|
|
85
|
+
return new SystemMessage({
|
|
86
|
+
content:
|
|
87
|
+
`You are approaching the step limit for this message ` +
|
|
88
|
+
`(approximately ${warningPct}% used, ~${remaining} rounds remaining). ` +
|
|
89
|
+
`Prioritize completing your current task. Summarize results ` +
|
|
90
|
+
`and any remaining work so the user can continue in the next message.`,
|
|
91
|
+
});
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
function createPeriodicWarning(): SystemMessage {
|
|
95
|
+
const idx = Math.min(warningCount, PERIODIC_MESSAGES.length) - 1;
|
|
96
|
+
const template = PERIODIC_MESSAGES[Math.max(idx, 0)];
|
|
97
|
+
return new SystemMessage({
|
|
98
|
+
content: template.replace("{rounds}", String(modelRoundCount)),
|
|
99
|
+
});
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
function evaluateBudget(): void {
|
|
103
|
+
if (isPeriodic) {
|
|
104
|
+
if (warningCount >= maxWarnings) return;
|
|
105
|
+
if (modelRoundCount >= nextWarningRound) {
|
|
106
|
+
warningCount++;
|
|
107
|
+
nextWarningRound += warningInterval!;
|
|
108
|
+
console.warn(
|
|
109
|
+
`[ExecutionBudget] Advisory ${warningCount}/${maxWarnings}: ` +
|
|
110
|
+
`round ${modelRoundCount} (interval=${warningInterval})`,
|
|
111
|
+
);
|
|
112
|
+
pendingAdvisory = createPeriodicWarning();
|
|
113
|
+
}
|
|
114
|
+
} else {
|
|
115
|
+
if (warningCount > 0) return;
|
|
116
|
+
if (modelRoundCount >= nextWarningRound) {
|
|
117
|
+
warningCount = 1;
|
|
118
|
+
const estimatedTotal = Math.floor(recursionLimit / 6);
|
|
119
|
+
console.warn(
|
|
120
|
+
`[ExecutionBudget] WARNING: round ${modelRoundCount} of ~${estimatedTotal} ` +
|
|
121
|
+
`(~${warningPct}% of recursion_limit=${recursionLimit})`,
|
|
122
|
+
);
|
|
123
|
+
pendingAdvisory = createThresholdWarning();
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
return {
|
|
129
|
+
name: "ExecutionBudgetMiddleware",
|
|
130
|
+
|
|
131
|
+
beforeAgent() {
|
|
132
|
+
modelRoundCount = 0;
|
|
133
|
+
warningCount = 0;
|
|
134
|
+
pendingAdvisory = null;
|
|
135
|
+
nextWarningRound = isPeriodic
|
|
136
|
+
? warningInterval!
|
|
137
|
+
: computeWarningRound(recursionLimit, warningPct);
|
|
138
|
+
},
|
|
139
|
+
|
|
140
|
+
async wrapModelCall(request, handler) {
|
|
141
|
+
let effectiveRequest = request;
|
|
142
|
+
|
|
143
|
+
if (pendingAdvisory !== null) {
|
|
144
|
+
const advisory = pendingAdvisory;
|
|
145
|
+
pendingAdvisory = null;
|
|
146
|
+
const messages = [...(request.messages as unknown[]), advisory];
|
|
147
|
+
effectiveRequest = { ...request, messages };
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
const response = await handler(effectiveRequest);
|
|
151
|
+
|
|
152
|
+
modelRoundCount++;
|
|
153
|
+
evaluateBudget();
|
|
154
|
+
|
|
155
|
+
return response;
|
|
156
|
+
},
|
|
157
|
+
|
|
158
|
+
afterAgent() {
|
|
159
|
+
if (isPeriodic) {
|
|
160
|
+
console.log(
|
|
161
|
+
`[ExecutionBudget] Summary (periodic): ${modelRoundCount} model rounds, ` +
|
|
162
|
+
`${warningCount}/${maxWarnings} advisories (interval=${warningInterval})`,
|
|
163
|
+
);
|
|
164
|
+
} else {
|
|
165
|
+
const estimatedTotal = Math.floor(recursionLimit / 6);
|
|
166
|
+
const pctUsed = estimatedTotal > 0
|
|
167
|
+
? Math.floor(modelRoundCount * 100 / estimatedTotal)
|
|
168
|
+
: 0;
|
|
169
|
+
console.log(
|
|
170
|
+
`[ExecutionBudget] Summary (threshold): ${modelRoundCount} rounds ` +
|
|
171
|
+
`of ~${estimatedTotal} (~${pctUsed}% used), warnings=${warningCount}`,
|
|
172
|
+
);
|
|
173
|
+
}
|
|
174
|
+
},
|
|
175
|
+
};
|
|
176
|
+
}
|
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Platform-level graceful stop middleware.
|
|
3
|
+
*
|
|
4
|
+
* Activated externally when the platform signals the runner to stop
|
|
5
|
+
* (e.g. via ExecutionControlSignal.STOP from the updateStatus RPC).
|
|
6
|
+
* Once activated, blocks all tool execution and gives the model one
|
|
7
|
+
* final tool-free round to produce a summary.
|
|
8
|
+
*
|
|
9
|
+
* Always injected into the agent graph. Inert until activate() is called.
|
|
10
|
+
*/
|
|
11
|
+
|
|
12
|
+
import { ToolMessage, SystemMessage } from "@langchain/core/messages";
|
|
13
|
+
import type { StigmerMiddleware } from "./types.js";
|
|
14
|
+
|
|
15
|
+
const DEFAULT_STOP_MESSAGE =
|
|
16
|
+
"The platform has requested this execution to stop. All tool calls are " +
|
|
17
|
+
"now blocked. Respond with a concise summary of what you accomplished " +
|
|
18
|
+
"and what work remains so the user can continue in their next session.";
|
|
19
|
+
|
|
20
|
+
export interface GracefulStopMiddleware extends StigmerMiddleware {
|
|
21
|
+
readonly activated: boolean;
|
|
22
|
+
activate(reason?: string): void;
|
|
23
|
+
forSubAgent(): StigmerMiddleware;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
export function createGracefulStopMiddleware(): GracefulStopMiddleware {
|
|
27
|
+
let _activated = false;
|
|
28
|
+
let _messageInjected = false;
|
|
29
|
+
let _reason = "";
|
|
30
|
+
|
|
31
|
+
const middleware: GracefulStopMiddleware = {
|
|
32
|
+
name: "GracefulStopMiddleware",
|
|
33
|
+
|
|
34
|
+
get activated() {
|
|
35
|
+
return _activated;
|
|
36
|
+
},
|
|
37
|
+
|
|
38
|
+
activate(reason = "") {
|
|
39
|
+
if (!_activated) {
|
|
40
|
+
_activated = true;
|
|
41
|
+
_reason = reason;
|
|
42
|
+
console.warn(
|
|
43
|
+
`[PLATFORM_STOP] GracefulStopMiddleware activated (reason=${reason || "unspecified"})`,
|
|
44
|
+
);
|
|
45
|
+
}
|
|
46
|
+
},
|
|
47
|
+
|
|
48
|
+
afterModel() {
|
|
49
|
+
if (!_activated || _messageInjected) return;
|
|
50
|
+
_messageInjected = true;
|
|
51
|
+
const msg = _reason || DEFAULT_STOP_MESSAGE;
|
|
52
|
+
return { messages: [new SystemMessage({ content: msg })] };
|
|
53
|
+
},
|
|
54
|
+
|
|
55
|
+
async wrapToolCall(request, handler) {
|
|
56
|
+
if (!_activated) return handler(request);
|
|
57
|
+
|
|
58
|
+
console.log(
|
|
59
|
+
`[PLATFORM_STOP] Blocking tool '${request.toolCall.name}' (id=${request.toolCall.id})`,
|
|
60
|
+
);
|
|
61
|
+
return new ToolMessage({
|
|
62
|
+
content:
|
|
63
|
+
"[Execution stopped by platform: tool execution blocked. " +
|
|
64
|
+
"Summarize your progress for the user.]",
|
|
65
|
+
tool_call_id: request.toolCall.id,
|
|
66
|
+
name: request.toolCall.name,
|
|
67
|
+
});
|
|
68
|
+
},
|
|
69
|
+
|
|
70
|
+
forSubAgent(): StigmerMiddleware {
|
|
71
|
+
return {
|
|
72
|
+
name: "GracefulStopSubAgentView",
|
|
73
|
+
|
|
74
|
+
afterModel() {
|
|
75
|
+
return middleware.afterModel!({} as any, {});
|
|
76
|
+
},
|
|
77
|
+
|
|
78
|
+
async wrapToolCall(request, handler) {
|
|
79
|
+
return middleware.wrapToolCall!(request, handler);
|
|
80
|
+
},
|
|
81
|
+
};
|
|
82
|
+
},
|
|
83
|
+
};
|
|
84
|
+
|
|
85
|
+
return middleware;
|
|
86
|
+
}
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Middleware stack factory.
|
|
3
|
+
*
|
|
4
|
+
* Assembles the ordered middleware array from a MiddlewareStackConfig.
|
|
5
|
+
* The composition order matches the Python create_deep_agent injection:
|
|
6
|
+
*
|
|
7
|
+
* 1. Loop detection (always)
|
|
8
|
+
* 2. Execution budget (always)
|
|
9
|
+
* 3. Tool truncation (always)
|
|
10
|
+
* 4. Graceful stop (always, inert until activated)
|
|
11
|
+
* 5. Cost cap (conditional: only when maxCostUsd > 0)
|
|
12
|
+
* 6. Error hints (always)
|
|
13
|
+
* 7. OTel spans (always, no-op when OTel not configured)
|
|
14
|
+
*/
|
|
15
|
+
|
|
16
|
+
import type { StigmerMiddleware, MiddlewareStackConfig } from "./types.js";
|
|
17
|
+
import type { GracefulStopMiddleware } from "./graceful-stop.js";
|
|
18
|
+
import { createLoopDetectionMiddleware } from "./loop-detection.js";
|
|
19
|
+
import { createExecutionBudgetMiddleware } from "./execution-budget.js";
|
|
20
|
+
import { createToolTruncationMiddleware } from "./tool-truncation.js";
|
|
21
|
+
import { createGracefulStopMiddleware } from "./graceful-stop.js";
|
|
22
|
+
import { createApprovalGateMiddleware } from "./approval-gate.js";
|
|
23
|
+
import { createCostCapMiddleware, type CostCapMiddleware } from "./cost-cap.js";
|
|
24
|
+
import { createErrorHintsMiddleware } from "./error-hints.js";
|
|
25
|
+
import { createOtelSpansMiddleware } from "./otel-spans.js";
|
|
26
|
+
|
|
27
|
+
export { createThinkTool } from "./think-tool.js";
|
|
28
|
+
export type { GracefulStopMiddleware } from "./graceful-stop.js";
|
|
29
|
+
export type { CostCapMiddleware } from "./cost-cap.js";
|
|
30
|
+
export type { StigmerMiddleware, MiddlewareStackConfig } from "./types.js";
|
|
31
|
+
|
|
32
|
+
export interface MiddlewareStackResult {
|
|
33
|
+
readonly middleware: StigmerMiddleware[];
|
|
34
|
+
readonly gracefulStop: GracefulStopMiddleware;
|
|
35
|
+
readonly costCap: CostCapMiddleware | null;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
export function buildMiddlewareStack(
|
|
39
|
+
config: MiddlewareStackConfig = {},
|
|
40
|
+
): MiddlewareStackResult {
|
|
41
|
+
const stack: StigmerMiddleware[] = [];
|
|
42
|
+
|
|
43
|
+
stack.push(createLoopDetectionMiddleware(config.loopDetection));
|
|
44
|
+
|
|
45
|
+
stack.push(createExecutionBudgetMiddleware(config.executionBudget));
|
|
46
|
+
|
|
47
|
+
stack.push(createToolTruncationMiddleware(config.toolTruncation));
|
|
48
|
+
|
|
49
|
+
const gracefulStop = createGracefulStopMiddleware();
|
|
50
|
+
stack.push(gracefulStop);
|
|
51
|
+
|
|
52
|
+
if (config.approvalGate) {
|
|
53
|
+
stack.push(createApprovalGateMiddleware(config.approvalGate));
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
if (config.costCap && config.costCap.maxCostUsd > 0) {
|
|
57
|
+
const costCapMiddleware = createCostCapMiddleware(config.costCap);
|
|
58
|
+
stack.push(costCapMiddleware);
|
|
59
|
+
|
|
60
|
+
stack.push(createErrorHintsMiddleware());
|
|
61
|
+
stack.push(createOtelSpansMiddleware(config.otelSpans));
|
|
62
|
+
|
|
63
|
+
return { middleware: stack, gracefulStop, costCap: costCapMiddleware };
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
stack.push(createErrorHintsMiddleware());
|
|
67
|
+
stack.push(createOtelSpansMiddleware(config.otelSpans));
|
|
68
|
+
|
|
69
|
+
return { middleware: stack, gracefulStop, costCap: null };
|
|
70
|
+
}
|