@stigmer/runner 3.14.0 → 3.15.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/.build-fingerprint +1 -1
- package/dist/__test-utils__/execution-record-fixture.d.ts +47 -0
- package/dist/__test-utils__/execution-record-fixture.js +68 -0
- package/dist/__test-utils__/execution-record-fixture.js.map +1 -0
- package/dist/__test-utils__/harness-contract/types.d.ts +166 -0
- package/dist/__test-utils__/harness-contract/types.js +49 -0
- package/dist/__test-utils__/harness-contract/types.js.map +1 -0
- package/dist/__test-utils__/hermetic-activity.d.ts +268 -0
- package/dist/__test-utils__/hermetic-activity.js +385 -0
- package/dist/__test-utils__/hermetic-activity.js.map +1 -0
- package/dist/__test-utils__/mock-client.d.ts +13 -0
- package/dist/__test-utils__/mock-client.js +45 -0
- package/dist/__test-utils__/mock-client.js.map +1 -0
- package/dist/__test-utils__/mock-workspace.d.ts +15 -0
- package/dist/__test-utils__/mock-workspace.js +21 -0
- package/dist/__test-utils__/mock-workspace.js.map +1 -0
- package/dist/__test-utils__/model-registry-fixture.d.ts +56 -0
- package/dist/__test-utils__/model-registry-fixture.js +66 -0
- package/dist/__test-utils__/model-registry-fixture.js.map +1 -0
- package/dist/__test-utils__/turn-input-fixture.d.ts +60 -0
- package/dist/__test-utils__/turn-input-fixture.js +118 -0
- package/dist/__test-utils__/turn-input-fixture.js.map +1 -0
- package/dist/activities/execute-cursor/__test-utils__/contract-subject.d.ts +107 -0
- package/dist/activities/execute-cursor/__test-utils__/contract-subject.js +344 -0
- package/dist/activities/execute-cursor/__test-utils__/contract-subject.js.map +1 -0
- package/dist/activities/execute-cursor/__test-utils__/cursor-hook-harness.d.ts +20 -0
- package/dist/activities/execute-cursor/__test-utils__/cursor-hook-harness.js +58 -0
- package/dist/activities/execute-cursor/__test-utils__/cursor-hook-harness.js.map +1 -1
- package/dist/activities/execute-cursor/__test-utils__/gateway-substrate.js +2 -32
- package/dist/activities/execute-cursor/__test-utils__/gateway-substrate.js.map +1 -1
- package/dist/activities/execute-cursor/__test-utils__/hermetic-cursor.d.ts +148 -0
- package/dist/activities/execute-cursor/__test-utils__/hermetic-cursor.js +257 -0
- package/dist/activities/execute-cursor/__test-utils__/hermetic-cursor.js.map +1 -0
- package/dist/activities/execute-cursor/__test-utils__/scripted-agent.d.ts +183 -0
- package/dist/activities/execute-cursor/__test-utils__/scripted-agent.js +262 -0
- package/dist/activities/execute-cursor/__test-utils__/scripted-agent.js.map +1 -0
- package/dist/activities/execute-cursor/__test-utils__/scripted-sdk.d.ts +138 -0
- package/dist/activities/execute-cursor/__test-utils__/scripted-sdk.js +191 -0
- package/dist/activities/execute-cursor/__test-utils__/scripted-sdk.js.map +1 -0
- package/dist/activities/execute-cursor/adapter.d.ts +55 -0
- package/dist/activities/execute-cursor/adapter.js +119 -0
- package/dist/activities/execute-cursor/adapter.js.map +1 -0
- package/dist/activities/execute-cursor/approval-state.d.ts +2 -2
- package/dist/activities/execute-cursor/approval-state.js.map +1 -1
- package/dist/activities/execute-cursor/capture-flow.d.ts +15 -30
- package/dist/activities/execute-cursor/capture-flow.js +17 -26
- package/dist/activities/execute-cursor/capture-flow.js.map +1 -1
- package/dist/activities/execute-cursor/cursor-capabilities.d.ts +23 -0
- package/dist/activities/execute-cursor/cursor-capabilities.js +33 -0
- package/dist/activities/execute-cursor/cursor-capabilities.js.map +1 -0
- package/dist/activities/execute-cursor/cursor-mcp-config.d.ts +2 -2
- package/dist/activities/execute-cursor/cursor-mcp-config.js.map +1 -1
- package/dist/activities/execute-cursor/fetch-interceptor.d.ts +15 -25
- package/dist/activities/execute-cursor/fetch-interceptor.js +39 -33
- package/dist/activities/execute-cursor/fetch-interceptor.js.map +1 -1
- package/dist/activities/execute-cursor/http2-interceptor.d.ts +21 -17
- package/dist/activities/execute-cursor/http2-interceptor.js +38 -31
- package/dist/activities/execute-cursor/http2-interceptor.js.map +1 -1
- package/dist/activities/execute-cursor/message-translator.d.ts +28 -19
- package/dist/activities/execute-cursor/message-translator.js +76 -27
- package/dist/activities/execute-cursor/message-translator.js.map +1 -1
- package/dist/activities/execute-cursor/prompt-builder.d.ts +180 -11
- package/dist/activities/execute-cursor/prompt-builder.js +171 -0
- package/dist/activities/execute-cursor/prompt-builder.js.map +1 -1
- package/dist/activities/execute-cursor/rejection-capture.d.ts +3 -6
- package/dist/activities/execute-cursor/rejection-capture.js +5 -7
- package/dist/activities/execute-cursor/rejection-capture.js.map +1 -1
- package/dist/activities/execute-cursor/session-lifecycle.d.ts +1 -4
- package/dist/activities/execute-cursor/session-lifecycle.js.map +1 -1
- package/dist/activities/execute-cursor/turn-boundary.d.ts +1 -1
- package/dist/activities/execute-cursor/turn-settle.d.ts +49 -0
- package/dist/activities/execute-cursor/turn-settle.js +507 -0
- package/dist/activities/execute-cursor/turn-settle.js.map +1 -0
- package/dist/activities/execute-cursor/turn-setup.d.ts +173 -0
- package/dist/activities/execute-cursor/turn-setup.js +496 -0
- package/dist/activities/execute-cursor/turn-setup.js.map +1 -0
- package/dist/activities/execute-cursor/turn-stream.d.ts +41 -71
- package/dist/activities/execute-cursor/turn-stream.js +70 -135
- package/dist/activities/execute-cursor/turn-stream.js.map +1 -1
- package/dist/activities/execute-cursor/turn.d.ts +43 -0
- package/dist/activities/execute-cursor/turn.js +222 -0
- package/dist/activities/execute-cursor/turn.js.map +1 -0
- package/dist/activities/execute-cursor/usage-pricing.d.ts +38 -0
- package/dist/activities/execute-cursor/usage-pricing.js +50 -0
- package/dist/activities/execute-cursor/usage-pricing.js.map +1 -0
- package/dist/activities/execute-deep-agent/approval-file-change.d.ts +1 -1
- package/dist/activities/execute-deep-agent/approval-file-change.js +1 -1
- package/dist/activities/execute-deep-agent/environment.js +1 -1
- package/dist/activities/execute-deep-agent/environment.js.map +1 -1
- package/dist/activities/execute-deep-agent/setup.js +3 -2
- package/dist/activities/execute-deep-agent/setup.js.map +1 -1
- package/dist/activities/hydrate-workflow-execution.js +1 -1
- package/dist/activities/hydrate-workflow-execution.js.map +1 -1
- package/dist/config.d.ts +15 -0
- package/dist/config.js.map +1 -1
- package/dist/harness/capabilities.d.ts +87 -0
- package/dist/harness/capabilities.js +37 -0
- package/dist/harness/capabilities.js.map +1 -0
- package/dist/harness/persist-chokepoint.d.ts +74 -0
- package/dist/harness/persist-chokepoint.js +88 -0
- package/dist/harness/persist-chokepoint.js.map +1 -0
- package/dist/harness/registry.d.ts +106 -0
- package/dist/harness/registry.js +168 -0
- package/dist/harness/registry.js.map +1 -0
- package/dist/harness/run-turn.d.ts +53 -0
- package/dist/harness/run-turn.js +528 -0
- package/dist/harness/run-turn.js.map +1 -0
- package/dist/harness/stop-controller.d.ts +50 -0
- package/dist/harness/stop-controller.js +62 -0
- package/dist/harness/stop-controller.js.map +1 -0
- package/dist/harness/terminal-table.d.ts +141 -0
- package/dist/harness/terminal-table.js +239 -0
- package/dist/harness/terminal-table.js.map +1 -0
- package/dist/harness/turn-context.d.ts +523 -0
- package/dist/harness/turn-context.js +739 -0
- package/dist/harness/turn-context.js.map +1 -0
- package/dist/harness/types.d.ts +448 -0
- package/dist/harness/types.js +64 -0
- package/dist/harness/types.js.map +1 -0
- package/dist/harness/usage-accumulator.d.ts +68 -0
- package/dist/harness/usage-accumulator.js +101 -0
- package/dist/harness/usage-accumulator.js.map +1 -0
- package/dist/harness-adapters.d.ts +27 -0
- package/dist/harness-adapters.js +28 -0
- package/dist/harness-adapters.js.map +1 -0
- package/dist/main.js.map +1 -1
- package/dist/runner-manager.js +64 -48
- package/dist/runner-manager.js.map +1 -1
- package/dist/runner.d.ts +5 -4
- package/dist/runner.js +65 -64
- package/dist/runner.js.map +1 -1
- package/dist/shared/approval-policy.d.ts +1 -1
- package/dist/shared/approval-policy.js.map +1 -1
- package/dist/{activities/execute-cursor → shared}/attachment-resolver.d.ts +2 -2
- package/dist/{activities/execute-cursor → shared}/attachment-resolver.js +5 -5
- package/dist/shared/attachment-resolver.js.map +1 -0
- package/dist/{activities/execute-cursor → shared}/blueprint-resolver.d.ts +7 -5
- package/dist/{activities/execute-cursor → shared}/blueprint-resolver.js +3 -63
- package/dist/shared/blueprint-resolver.js.map +1 -0
- package/dist/shared/channel-attachment.d.ts +1 -1
- package/dist/shared/channel-attachment.js.map +1 -1
- package/dist/{activities/execute-cursor → shared}/cost-guard.d.ts +5 -1
- package/dist/{activities/execute-cursor → shared}/cost-guard.js +5 -1
- package/dist/shared/cost-guard.js.map +1 -0
- package/dist/{activities/execute-cursor → shared}/env-resolver.d.ts +1 -1
- package/dist/shared/env-resolver.js.map +1 -0
- package/dist/{activities/execute-cursor → shared}/exact-apply.d.ts +1 -1
- package/dist/{activities/execute-cursor → shared}/exact-apply.js +6 -6
- package/dist/shared/exact-apply.js.map +1 -0
- package/dist/shared/execution-context.d.ts +35 -0
- package/dist/shared/execution-context.js +38 -0
- package/dist/shared/execution-context.js.map +1 -0
- package/dist/{activities/execute-cursor → shared}/extract-structured-output.d.ts +5 -2
- package/dist/{activities/execute-cursor → shared}/extract-structured-output.js +9 -6
- package/dist/shared/extract-structured-output.js.map +1 -0
- package/dist/shared/filereview/capture.d.ts +1 -1
- package/dist/shared/filereview/capture.js +1 -1
- package/dist/shared/heartbeat.d.ts +13 -11
- package/dist/shared/heartbeat.js +14 -29
- package/dist/shared/heartbeat.js.map +1 -1
- package/dist/{activities/execute-cursor → shared}/persist-decision.d.ts +5 -2
- package/dist/{activities/execute-cursor → shared}/persist-decision.js +4 -1
- package/dist/shared/persist-decision.js.map +1 -0
- package/dist/{activities/execute-cursor → shared}/skill-resolver.d.ts +16 -3
- package/dist/{activities/execute-cursor → shared}/skill-resolver.js +12 -4
- package/dist/shared/skill-resolver.js.map +1 -0
- package/dist/shared/subagent-rows.d.ts +21 -0
- package/dist/shared/subagent-rows.js +34 -0
- package/dist/shared/subagent-rows.js.map +1 -0
- package/dist/shared/worker-shutdown.d.ts +43 -16
- package/dist/shared/worker-shutdown.js +28 -13
- package/dist/shared/worker-shutdown.js.map +1 -1
- package/dist/shared/workspace/platform-dir.d.ts +1 -1
- package/dist/shared/workspace/platform-dir.js +1 -1
- package/dist/shared/workspace/session-provision.d.ts +54 -0
- package/dist/{activities/execute-cursor/workspace-provision.js → shared/workspace/session-provision.js} +15 -12
- package/dist/shared/workspace/session-provision.js.map +1 -0
- package/package.json +4 -4
- package/src/__test-utils__/__tests__/harness-contract-self-check.test.ts +325 -0
- package/src/__test-utils__/config-fixture.ts +63 -0
- package/src/__test-utils__/execution-record-fixture.ts +104 -0
- package/src/__test-utils__/harness-boot-order-child.ts +58 -0
- package/src/__test-utils__/harness-contract/contract.ts +581 -0
- package/src/__test-utils__/harness-contract/recording-sink.ts +107 -0
- package/src/__test-utils__/harness-contract/runtime-contract.ts +666 -0
- package/src/__test-utils__/harness-contract/scripted-adapter.ts +349 -0
- package/src/__test-utils__/harness-contract/types.ts +176 -0
- package/src/__test-utils__/hermetic-activity.ts +502 -0
- package/src/__test-utils__/model-registry-fixture.ts +72 -0
- package/src/__test-utils__/module-specifiers.ts +82 -0
- package/src/__test-utils__/proto-helpers.ts +25 -0
- package/src/__test-utils__/turn-input-fixture.ts +155 -0
- package/src/__tests__/harness-boot-order.test.ts +77 -0
- package/src/__tests__/harness-contract.test.ts +27 -0
- package/src/__tests__/runner-manager.test.ts +18 -0
- package/src/activities/execute-cursor/__test-utils__/__tests__/scripted-double.test.ts +102 -0
- package/src/activities/execute-cursor/__test-utils__/contract-subject.ts +396 -0
- package/src/activities/execute-cursor/__test-utils__/cursor-hook-harness.ts +66 -0
- package/src/activities/execute-cursor/__test-utils__/gateway-substrate.ts +2 -43
- package/src/activities/execute-cursor/__test-utils__/hermetic-cursor.ts +342 -0
- package/src/activities/execute-cursor/__test-utils__/scripted-agent.ts +368 -0
- package/src/activities/execute-cursor/__test-utils__/scripted-sdk.ts +254 -0
- package/src/activities/execute-cursor/__tests__/adapter-is-temporal-free.test.ts +45 -0
- package/src/activities/execute-cursor/__tests__/approval-decisions-agree.test.ts +90 -0
- package/src/activities/execute-cursor/__tests__/build-prompt.test.ts +7 -8
- package/src/activities/execute-cursor/__tests__/capture-flow.test.ts +28 -1
- package/src/activities/execute-cursor/__tests__/deny-gate-exact-apply.test.ts +1 -1
- package/src/activities/execute-cursor/__tests__/fetch-interceptor.test.ts +64 -6
- package/src/activities/execute-cursor/__tests__/hermetic/deny-and-retry.test.ts +228 -0
- package/src/activities/execute-cursor/__tests__/hermetic/file-review-capture.test.ts +180 -0
- package/src/activities/execute-cursor/__tests__/hermetic/goldens/cost-cap.status.json +53 -0
- package/src/activities/execute-cursor/__tests__/hermetic/goldens/deny-and-retry.turn1.status.json +55 -0
- package/src/activities/execute-cursor/__tests__/hermetic/goldens/deny-and-retry.turn2.status.json +77 -0
- package/src/activities/execute-cursor/__tests__/hermetic/goldens/file-review-capture.status.json +126 -0
- package/src/activities/execute-cursor/__tests__/hermetic/goldens/pause.status.json +40 -0
- package/src/activities/execute-cursor/__tests__/hermetic/goldens/plain-turn.status.json +48 -0
- package/src/activities/execute-cursor/__tests__/hermetic/goldens/platform-stop.status.json +56 -0
- package/src/activities/execute-cursor/__tests__/hermetic/goldens/recovery-fresh-agent.status.json +53 -0
- package/src/activities/execute-cursor/__tests__/hermetic/goldens/recovery-transport-timeout.status.json +48 -0
- package/src/activities/execute-cursor/__tests__/hermetic/goldens/resolution-error.status.json +18 -0
- package/src/activities/execute-cursor/__tests__/hermetic/goldens/run-cancelled.status.json +36 -0
- package/src/activities/execute-cursor/__tests__/hermetic/goldens/run-error-non-retryable.status.json +37 -0
- package/src/activities/execute-cursor/__tests__/hermetic/goldens/sdk-error-at-create.status.json +38 -0
- package/src/activities/execute-cursor/__tests__/hermetic/goldens/stall.status.json +59 -0
- package/src/activities/execute-cursor/__tests__/hermetic/goldens/tool-call.status.json +68 -0
- package/src/activities/execute-cursor/__tests__/hermetic/goldens/unattributed-hook-block.status.json +79 -0
- package/src/activities/execute-cursor/__tests__/hermetic/goldens/worker-shutdown.status.json +42 -0
- package/src/activities/execute-cursor/__tests__/hermetic/harness-contract.test.ts +170 -0
- package/src/activities/execute-cursor/__tests__/hermetic/pause-vs-shutdown.test.ts +205 -0
- package/src/activities/execute-cursor/__tests__/hermetic/plain-turn.test.ts +171 -0
- package/src/activities/execute-cursor/__tests__/hermetic/recovery-fresh-agent.test.ts +156 -0
- package/src/activities/execute-cursor/__tests__/hermetic/run-wait-arms.test.ts +286 -0
- package/src/activities/execute-cursor/__tests__/hermetic/stream-self-stop-arms.test.ts +332 -0
- package/src/activities/execute-cursor/__tests__/hermetic/thrown-error-arms.test.ts +193 -0
- package/src/activities/execute-cursor/__tests__/hermetic/tool-call.test.ts +137 -0
- package/src/activities/execute-cursor/__tests__/hermetic/unattributed-hook-block.test.ts +185 -0
- package/src/activities/execute-cursor/__tests__/hermetic/workspace-lock-timeout.test.ts +151 -0
- package/src/activities/execute-cursor/__tests__/http2-interceptor.test.ts +65 -35
- package/src/activities/execute-cursor/__tests__/message-translator.test.ts +0 -40
- package/src/activities/execute-cursor/__tests__/same-identity-reproposal.test.ts +171 -0
- package/src/activities/execute-cursor/__tests__/turn-stream.test.ts +118 -243
- package/src/activities/execute-cursor/__tests__/usage-pricing.test.ts +84 -0
- package/src/activities/execute-cursor/adapter.ts +138 -0
- package/src/activities/execute-cursor/approval-state.ts +2 -2
- package/src/activities/execute-cursor/capture-flow.ts +18 -41
- package/src/activities/execute-cursor/cursor-capabilities.ts +35 -0
- package/src/activities/execute-cursor/cursor-mcp-config.ts +2 -2
- package/src/activities/execute-cursor/fetch-interceptor.ts +48 -45
- package/src/activities/execute-cursor/http2-interceptor.ts +47 -34
- package/src/activities/execute-cursor/message-translator.ts +90 -45
- package/src/activities/execute-cursor/prompt-builder.ts +327 -12
- package/src/activities/execute-cursor/rejection-capture.ts +5 -12
- package/src/activities/execute-cursor/session-lifecycle.ts +1 -5
- package/src/activities/execute-cursor/turn-boundary.ts +1 -1
- package/src/activities/execute-cursor/turn-settle.ts +601 -0
- package/src/activities/execute-cursor/turn-setup.ts +645 -0
- package/src/activities/execute-cursor/turn-stream.ts +84 -210
- package/src/activities/execute-cursor/turn.ts +240 -0
- package/src/activities/execute-cursor/usage-pricing.ts +67 -0
- package/src/activities/execute-deep-agent/approval-file-change.ts +1 -1
- package/src/activities/execute-deep-agent/environment.ts +1 -1
- package/src/activities/execute-deep-agent/setup.ts +3 -2
- package/src/activities/hydrate-workflow-execution.ts +1 -1
- package/src/config.ts +13 -0
- package/src/harness/__tests__/import-direction.test.ts +168 -0
- package/src/harness/__tests__/persist-chokepoint.test.ts +146 -0
- package/src/harness/__tests__/registry.test.ts +168 -0
- package/src/harness/__tests__/run-turn.test.ts +165 -0
- package/src/harness/__tests__/stop-controller.test.ts +49 -0
- package/src/harness/__tests__/turn-context.test.ts +178 -0
- package/src/harness/__tests__/usage-accumulator.test.ts +83 -0
- package/src/harness/capabilities.ts +92 -0
- package/src/harness/persist-chokepoint.ts +112 -0
- package/src/harness/registry.ts +197 -0
- package/src/harness/run-turn.ts +618 -0
- package/src/harness/stop-controller.ts +83 -0
- package/src/harness/terminal-table.ts +276 -0
- package/src/harness/turn-context.ts +1028 -0
- package/src/harness/types.ts +473 -0
- package/src/harness/usage-accumulator.ts +122 -0
- package/src/harness-adapters.ts +30 -0
- package/src/main.ts +1 -1
- package/src/runner-manager.ts +68 -61
- package/src/runner.ts +67 -78
- package/src/shared/__tests__/attachment-naming.test.ts +1 -1
- package/src/{activities/execute-cursor → shared}/__tests__/attachment-resolver.test.ts +6 -4
- package/src/{activities/execute-cursor → shared}/__tests__/cost-guard.test.ts +2 -1
- package/src/{activities/execute-cursor → shared}/__tests__/exact-apply.test.ts +3 -3
- package/src/{activities/execute-cursor → shared}/__tests__/extract-structured-output.test.ts +8 -8
- package/src/{activities/execute-cursor → shared}/__tests__/persist-decision.test.ts +4 -2
- package/src/{activities/execute-cursor → shared}/__tests__/skill-resolver.test.ts +1 -1
- package/src/shared/__tests__/subagent-rows.test.ts +34 -0
- package/src/shared/__tests__/worker-shutdown.test.ts +44 -39
- package/src/shared/approval-policy.ts +1 -1
- package/src/{activities/execute-cursor → shared}/attachment-resolver.ts +6 -6
- package/src/{activities/execute-cursor → shared}/blueprint-resolver.ts +7 -78
- package/src/shared/channel-attachment.ts +1 -1
- package/src/{activities/execute-cursor → shared}/cost-guard.ts +5 -1
- package/src/{activities/execute-cursor → shared}/env-resolver.ts +1 -1
- package/src/{activities/execute-cursor → shared}/exact-apply.ts +7 -7
- package/src/shared/execution-context.ts +45 -0
- package/src/{activities/execute-cursor → shared}/extract-structured-output.ts +10 -7
- package/src/shared/filereview/capture.ts +1 -1
- package/src/shared/heartbeat.ts +13 -33
- package/src/{activities/execute-cursor → shared}/persist-decision.ts +5 -2
- package/src/{activities/execute-cursor → shared}/skill-resolver.ts +20 -6
- package/src/shared/subagent-rows.ts +39 -0
- package/src/shared/worker-shutdown.ts +55 -25
- package/src/{activities/execute-cursor/__tests__/workspace-provision.test.ts → shared/workspace/__tests__/session-provision.test.ts} +25 -28
- package/src/shared/workspace/platform-dir.ts +1 -1
- package/src/{activities/execute-cursor/workspace-provision.ts → shared/workspace/session-provision.ts} +29 -16
- package/dist/activities/execute-cursor/attachment-resolver.js.map +0 -1
- package/dist/activities/execute-cursor/blueprint-resolver.js.map +0 -1
- package/dist/activities/execute-cursor/cost-guard.js.map +0 -1
- package/dist/activities/execute-cursor/env-resolver.js.map +0 -1
- package/dist/activities/execute-cursor/exact-apply.js.map +0 -1
- package/dist/activities/execute-cursor/extract-structured-output.js.map +0 -1
- package/dist/activities/execute-cursor/index.d.ts +0 -209
- package/dist/activities/execute-cursor/index.js +0 -2345
- package/dist/activities/execute-cursor/index.js.map +0 -1
- package/dist/activities/execute-cursor/persist-decision.js.map +0 -1
- package/dist/activities/execute-cursor/skill-resolver.js.map +0 -1
- package/dist/activities/execute-cursor/usage-accumulator.d.ts +0 -89
- package/dist/activities/execute-cursor/usage-accumulator.js +0 -121
- package/dist/activities/execute-cursor/usage-accumulator.js.map +0 -1
- package/dist/activities/execute-cursor/workspace-provision.d.ts +0 -42
- package/dist/activities/execute-cursor/workspace-provision.js.map +0 -1
- package/src/activities/execute-cursor/__tests__/usage-accumulator.test.ts +0 -164
- package/src/activities/execute-cursor/index.ts +0 -2876
- package/src/activities/execute-cursor/usage-accumulator.ts +0 -169
- /package/dist/{activities/execute-cursor → shared}/env-resolver.js +0 -0
|
@@ -48,10 +48,10 @@
|
|
|
48
48
|
*/
|
|
49
49
|
import { isAbsolute, relative, resolve } from "node:path";
|
|
50
50
|
import { ApprovalAction, ToolCallStatus, } from "@stigmer/protos/ai/stigmer/agentic/agentexecution/v1/enum_pb";
|
|
51
|
-
import { ELISION_MARKER } from "
|
|
52
|
-
import { extractFilePath, extractWriteContent } from "
|
|
53
|
-
import { resolveWorkspacePath } from "
|
|
54
|
-
import { utcTimestamp } from "
|
|
51
|
+
import { ELISION_MARKER } from "./status-offload.js";
|
|
52
|
+
import { extractFilePath, extractWriteContent } from "./file-tools.js";
|
|
53
|
+
import { resolveWorkspacePath } from "./file-change.js";
|
|
54
|
+
import { utcTimestamp } from "./status.js";
|
|
55
55
|
/**
|
|
56
56
|
* Apply every APPROVED whole-file write in `messages` to disk with its EXACT
|
|
57
57
|
* approved bytes, marking each applied tool call COMPLETED in place.
|
|
@@ -113,7 +113,7 @@ export async function applyApprovedWholeFileWrites(opts) {
|
|
|
113
113
|
tc.completedAt = utcTimestamp();
|
|
114
114
|
tc.error = "";
|
|
115
115
|
applied.add(tc.id);
|
|
116
|
-
console.log(`
|
|
116
|
+
console.log(`[exact-apply] wrote approved bytes to ${target} ` +
|
|
117
117
|
`(tool=${tc.id}); no resource grant issued, so a further change ` +
|
|
118
118
|
`re-gates. execution=${opts.executionId}`);
|
|
119
119
|
}
|
|
@@ -198,7 +198,7 @@ function isWithinWorkspace(absTarget, workspaceDirs) {
|
|
|
198
198
|
});
|
|
199
199
|
}
|
|
200
200
|
function logSkip(executionId, tc, reason) {
|
|
201
|
-
console.log(`
|
|
201
|
+
console.log(`[exact-apply] skipped (falling back to grant+reinvocation): ` +
|
|
202
202
|
`tool=${tc.id} reason="${reason}" execution=${executionId}`);
|
|
203
203
|
}
|
|
204
204
|
//# sourceMappingURL=exact-apply.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"exact-apply.js","sourceRoot":"","sources":["../../src/shared/exact-apply.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA+CG;AAEH,OAAO,EAAE,UAAU,EAAE,QAAQ,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAC1D,OAAO,EACL,cAAc,EACd,cAAc,GACf,MAAM,8DAA8D,CAAC;AAMtE,OAAO,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAC;AACrD,OAAO,EAAE,eAAe,EAAE,mBAAmB,EAAE,MAAM,iBAAiB,CAAC;AACvE,OAAO,EAAE,oBAAoB,EAAE,MAAM,kBAAkB,CAAC;AAExD,OAAO,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAc3C;;;;;;;;;;;;;;GAcG;AACH,MAAM,CAAC,KAAK,UAAU,4BAA4B,CAChD,IAAuB;IAEvB,MAAM,OAAO,GAAG,IAAI,GAAG,EAAU,CAAC;IAElC,KAAK,MAAM,GAAG,IAAI,IAAI,CAAC,QAAQ,EAAE,CAAC;QAChC,KAAK,MAAM,EAAE,IAAI,GAAG,CAAC,SAAS,EAAE,CAAC;YAC/B,IAAI,CAAC,wBAAwB,CAAC,EAAE,CAAC;gBAAE,SAAS;YAE5C,MAAM,IAAI,GAAG,UAAU,CAAC,EAAE,CAAC,CAAC;YAC5B,MAAM,OAAO,GAAG,eAAe,CAAC,IAAI,CAAC,CAAC;YACtC,IAAI,CAAC,OAAO,EAAE,CAAC;gBACb,iEAAiE;gBACjE,+CAA+C;gBAC/C,OAAO,CAAC,IAAI,CAAC,WAAW,EAAE,EAAE,EAAE,2BAA2B,CAAC,CAAC;gBAC3D,SAAS;YACX,CAA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QACtC,CAAC,CAAC,EAAE,CAAC;AACT,CAAC;AAED,iFAAiF;AACjF,SAAS,iBAAiB,CACxB,SAAiB,EACjB,aAAgC;IAEhC,MAAM,MAAM,GAAG,OAAO,CAAC,SAAS,CAAC,CAAC;IAClC,OAAO,aAAa,CAAC,IAAI,CAAC,CAAC,GAAG,EAAE,EAAE;QAChC,MAAM,IAAI,GAAG,OAAO,CAAC,GAAG,CAAC,CAAC;QAC1B,IAAI,MAAM,KAAK,IAAI;YAAE,OAAO,IAAI,CAAC;QACjC,MAAM,GAAG,GAAG,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC,CAAC;QACnC,OAAO,GAAG,KAAK,EAAE,IAAI,CAAC,GAAG,CAAC,UAAU,CAAC,IAAI,CAAC,IAAI,CAAC,UAAU,CAAC,GAAG,CAAC,CAAC;IACjE,CAAC,CAAC,CAAC;AACL,CAAC;AAED,SAAS,OAAO,CAAC,WAAmB,EAAE,EAAY,EAAE,MAAc;IAChE,OAAO,CAAC,GAAG,CACT,8DAA8D;QAC5D,QAAQ,EAAE,CAAC,EAAE,YAAY,MAAM,eAAe,WAAW,EAAE,CAC9D,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The execution-scoped context — "this async work belongs to execution X" —
|
|
3
|
+
* as an `AsyncLocalStorage` the turn runtime enters once around the WHOLE
|
|
4
|
+
* activity, and the transport layer reads per request.
|
|
5
|
+
*
|
|
6
|
+
* Why it is the runtime's and not a harness's: every proxy-bound request the
|
|
7
|
+
* runner makes carries `x-stigmer-execution-id` from this store (the Cursor
|
|
8
|
+
* fetch and HTTP/2 interceptors stamp it; `rejection-capture.ts` correlates
|
|
9
|
+
* unhandled rejections by it), and a large share of those requests are made
|
|
10
|
+
* OUTSIDE any engine stretch — attachment downloads and status offload
|
|
11
|
+
* through the artifact proxy, the memory selection, the structured-output
|
|
12
|
+
* extraction and the plan-artifact publish in the epilogue, and in a cloud
|
|
13
|
+
* sandbox the control-plane writes themselves. Under `maxConcurrentActivities
|
|
14
|
+
* > 1` the fallback (a module-level id, `fetch-interceptor.ts`
|
|
15
|
+
* `setInterceptorExecutionId`) is whichever turn set it last; this store is
|
|
16
|
+
* what makes concurrent turns not overwrite each other's headers.
|
|
17
|
+
*
|
|
18
|
+
* Moved from `activities/execute-cursor/fetch-interceptor.ts` (S2 M3,
|
|
19
|
+
* Q-M3-12) so `harness/run-turn.ts` can enter it without importing the
|
|
20
|
+
* adapter; the interceptors import it from here. No harness enters it: the
|
|
21
|
+
* contract lists it among the things deliberately NOT on `TurnSink`.
|
|
22
|
+
*/
|
|
23
|
+
import { AsyncLocalStorage } from "node:async_hooks";
|
|
24
|
+
export interface ExecutionContextStore {
|
|
25
|
+
readonly executionId: string;
|
|
26
|
+
}
|
|
27
|
+
/** The store, for readers that stamp or correlate by execution id. */
|
|
28
|
+
export declare function getExecutionContext(): AsyncLocalStorage<ExecutionContextStore>;
|
|
29
|
+
/**
|
|
30
|
+
* Run an async function with execution-scoped context. The executionId is
|
|
31
|
+
* propagated through the async call chain via AsyncLocalStorage, ensuring
|
|
32
|
+
* concurrent activities on the same runner process don't overwrite each
|
|
33
|
+
* other's proxy headers.
|
|
34
|
+
*/
|
|
35
|
+
export declare function runWithExecutionContext<T>(executionId: string, fn: () => Promise<T>): Promise<T>;
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The execution-scoped context — "this async work belongs to execution X" —
|
|
3
|
+
* as an `AsyncLocalStorage` the turn runtime enters once around the WHOLE
|
|
4
|
+
* activity, and the transport layer reads per request.
|
|
5
|
+
*
|
|
6
|
+
* Why it is the runtime's and not a harness's: every proxy-bound request the
|
|
7
|
+
* runner makes carries `x-stigmer-execution-id` from this store (the Cursor
|
|
8
|
+
* fetch and HTTP/2 interceptors stamp it; `rejection-capture.ts` correlates
|
|
9
|
+
* unhandled rejections by it), and a large share of those requests are made
|
|
10
|
+
* OUTSIDE any engine stretch — attachment downloads and status offload
|
|
11
|
+
* through the artifact proxy, the memory selection, the structured-output
|
|
12
|
+
* extraction and the plan-artifact publish in the epilogue, and in a cloud
|
|
13
|
+
* sandbox the control-plane writes themselves. Under `maxConcurrentActivities
|
|
14
|
+
* > 1` the fallback (a module-level id, `fetch-interceptor.ts`
|
|
15
|
+
* `setInterceptorExecutionId`) is whichever turn set it last; this store is
|
|
16
|
+
* what makes concurrent turns not overwrite each other's headers.
|
|
17
|
+
*
|
|
18
|
+
* Moved from `activities/execute-cursor/fetch-interceptor.ts` (S2 M3,
|
|
19
|
+
* Q-M3-12) so `harness/run-turn.ts` can enter it without importing the
|
|
20
|
+
* adapter; the interceptors import it from here. No harness enters it: the
|
|
21
|
+
* contract lists it among the things deliberately NOT on `TurnSink`.
|
|
22
|
+
*/
|
|
23
|
+
import { AsyncLocalStorage } from "node:async_hooks";
|
|
24
|
+
const executionContext = new AsyncLocalStorage();
|
|
25
|
+
/** The store, for readers that stamp or correlate by execution id. */
|
|
26
|
+
export function getExecutionContext() {
|
|
27
|
+
return executionContext;
|
|
28
|
+
}
|
|
29
|
+
/**
|
|
30
|
+
* Run an async function with execution-scoped context. The executionId is
|
|
31
|
+
* propagated through the async call chain via AsyncLocalStorage, ensuring
|
|
32
|
+
* concurrent activities on the same runner process don't overwrite each
|
|
33
|
+
* other's proxy headers.
|
|
34
|
+
*/
|
|
35
|
+
export function runWithExecutionContext(executionId, fn) {
|
|
36
|
+
return executionContext.run({ executionId }, fn);
|
|
37
|
+
}
|
|
38
|
+
//# sourceMappingURL=execution-context.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"execution-context.js","sourceRoot":"","sources":["../../src/shared/execution-context.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;GAqBG;AAEH,OAAO,EAAE,iBAAiB,EAAE,MAAM,kBAAkB,CAAC;AAMrD,MAAM,gBAAgB,GAAG,IAAI,iBAAiB,EAAyB,CAAC;AAExE,sEAAsE;AACtE,MAAM,UAAU,mBAAmB;IACjC,OAAO,gBAAgB,CAAC;AAC1B,CAAC;AAED;;;;;GAKG;AACH,MAAM,UAAU,uBAAuB,CAAI,WAAmB,EAAE,EAAoB;IAClF,OAAO,gBAAgB,CAAC,GAAG,CAAC,EAAE,WAAW,EAAE,EAAE,EAAE,CAAC,CAAC;AACnD,CAAC"}
|
|
@@ -1,5 +1,8 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Tier-2 structured-output extraction for
|
|
2
|
+
* Tier-2 structured-output extraction for a harness turn.
|
|
3
|
+
*
|
|
4
|
+
* Harness-agnostic: the Cursor activity is today's only caller and the turn
|
|
5
|
+
* runtime takes it over in S2 M3 (the native harness has no tier 2 today).
|
|
3
6
|
*
|
|
4
7
|
* When tier-1 text extraction (shared/extract-json.ts) cannot find JSON in
|
|
5
8
|
* the agent's free-text response, this tier asks an economy-tier LLM to
|
|
@@ -12,7 +15,7 @@
|
|
|
12
15
|
* lazily at the call site, mirroring its tier-1 import, which is what
|
|
13
16
|
* bundle-slim's deferred evaluation preserves.
|
|
14
17
|
*/
|
|
15
|
-
import type { Config } from "
|
|
18
|
+
import type { Config } from "../config.js";
|
|
16
19
|
/**
|
|
17
20
|
* Extract structured data from an agent's free-text response using an
|
|
18
21
|
* economy-tier LLM with withStructuredOutput (function-calling).
|
|
@@ -1,5 +1,8 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Tier-2 structured-output extraction for
|
|
2
|
+
* Tier-2 structured-output extraction for a harness turn.
|
|
3
|
+
*
|
|
4
|
+
* Harness-agnostic: the Cursor activity is today's only caller and the turn
|
|
5
|
+
* runtime takes it over in S2 M3 (the native harness has no tier 2 today).
|
|
3
6
|
*
|
|
4
7
|
* When tier-1 text extraction (shared/extract-json.ts) cannot find JSON in
|
|
5
8
|
* the agent's free-text response, this tier asks an economy-tier LLM to
|
|
@@ -12,11 +15,11 @@
|
|
|
12
15
|
* lazily at the call site, mirroring its tier-1 import, which is what
|
|
13
16
|
* bundle-slim's deferred evaluation preserves.
|
|
14
17
|
*/
|
|
15
|
-
import { getEconomyModel } from "
|
|
16
|
-
import { buildChatModel } from "
|
|
17
|
-
import { checkDirectCredentials } from "
|
|
18
|
-
import { tryInferProvider } from "
|
|
19
|
-
import { jsonSchemaToZod } from "
|
|
18
|
+
import { getEconomyModel } from "./model-registry.js";
|
|
19
|
+
import { buildChatModel } from "./model-client.js";
|
|
20
|
+
import { checkDirectCredentials } from "./llm-backend.js";
|
|
21
|
+
import { tryInferProvider } from "./llm-proxy.js";
|
|
22
|
+
import { jsonSchemaToZod } from "./json-schema-to-zod.js";
|
|
20
23
|
/**
|
|
21
24
|
* Extract structured data from an agent's free-text response using an
|
|
22
25
|
* economy-tier LLM with withStructuredOutput (function-calling).
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"extract-structured-output.js","sourceRoot":"","sources":["../../src/shared/extract-structured-output.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AAGH,OAAO,EAAE,eAAe,EAAE,MAAM,qBAAqB,CAAC;AACtD,OAAO,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAC;AACnD,OAAO,EAAE,sBAAsB,EAAE,MAAM,kBAAkB,CAAC;AAC1D,OAAO,EAAE,gBAAgB,EAAE,MAAM,gBAAgB,CAAC;AAClD,OAAO,EAAE,eAAe,EAAE,MAAM,yBAAyB,CAAC;AAE1D;;;;;;;;;;;;GAYG;AACH,MAAM,CAAC,KAAK,UAAU,uBAAuB,CAC3C,aAAqB,EACrB,MAA+B,EAC/B,MAAc,EACd,YAAoB;IAEpB,MAAM,eAAe,GAAG,MAAM,eAAe,CAAC,YAAY,CAAC,CAAC;IAC5D,MAAM,aAAa,GAAG,MAAM,CAAC,aAAa,IAAI,SAAS,CAAC;IAExD,IAAI,CAAC,aAAa,EAAE,CAAC;QACnB,MAAM,QAAQ,GAAG,gBAAgB,CAAC,eAAe,CAAC,CAAC;QACnD,MAAM,OAAO,GAAG,QAAQ,KAAK,IAAI,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,sBAAsB,CAAC,QAAQ,CAAC,CAAC;QAC5E,IAAI,OAAO,KAAK,IAAI,EAAE,CAAC;YACrB,MAAM,IAAI,KAAK,CACb,0CAA0C,QAAQ,SAAS;gBAC3D,IAAI,eAAe,iCAAiC,OAAO,EAAE,CAC9D,CAAC;QACJ,CAAC;IACH,CAAC;IAED,MAAM,EAAE,KAAK,EAAE,GAAG,EAAE,GAAG,MAAM,cAAc,CAAC;QAC1C,SAAS,EAAE,eAAe;QAC1B,aAAa;QACb,YAAY,EAAE,MAAM,CAAC,YAAY,IAAI,SAAS;QAC9C,SAAS,EAAE,IAAI;KAChB,CAAC,CAAC;IAEH,MAAM,SAAS,GAAG,eAAe,CAAC,MAAM,CAAC,CAAC;IAC1C,MAAM,UAAU,GAAG,GAAG,CAAC,oBAAoB,CAAC,SAAS,CAAC,CAAC;IAEvD,MAAM,MAAM,GAAG,MAAM,UAAU,CAAC,MAAM,CAAC;QACrC,EAAE,IAAI,EAAE,QAAQ,EAAE,OAAO,EAAE,sGAAsG,EAAE;QACnI,EAAE,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,aAAa,EAAE;KACzC,CAAC,CAAC;IAEH,OAAO,MAAM,IAAI,IAAI,CAAC;AACxB,CAAC"}
|
|
@@ -40,7 +40,7 @@ import { type BlobReader, type CasPathCapture } from "./cas-substrate.js";
|
|
|
40
40
|
* no capture substrate and falls back to the deny-gate: the agent still runs, but
|
|
41
41
|
* file writes gate pre-execution instead of flowing. In the Cursor harness that
|
|
42
42
|
* fallback is also the ONLY branch that arms the resume-time exact-apply guarantee
|
|
43
|
-
* (see
|
|
43
|
+
* (see shared/exact-apply.ts); the deep-agent harness re-applies an
|
|
44
44
|
* approved write via LangGraph checkpoint replay and needs no exact-apply. Keeping
|
|
45
45
|
* this the single, named, truth-table-tested decision pins exactly when the
|
|
46
46
|
* no-storage deny-gate engages in either harness.
|
|
@@ -42,7 +42,7 @@ import { isSecretLikePath } from "./secret-paths.js";
|
|
|
42
42
|
* no capture substrate and falls back to the deny-gate: the agent still runs, but
|
|
43
43
|
* file writes gate pre-execution instead of flowing. In the Cursor harness that
|
|
44
44
|
* fallback is also the ONLY branch that arms the resume-time exact-apply guarantee
|
|
45
|
-
* (see
|
|
45
|
+
* (see shared/exact-apply.ts); the deep-agent harness re-applies an
|
|
46
46
|
* approved write via LangGraph checkpoint replay and needs no exact-apply. Keeping
|
|
47
47
|
* this the single, named, truth-table-tested decision pins exactly when the
|
|
48
48
|
* no-storage deny-gate engages in either harness.
|
|
@@ -3,20 +3,22 @@
|
|
|
3
3
|
*
|
|
4
4
|
* Provides a periodic heartbeat loop that activities can start for
|
|
5
5
|
* long-running operations. The loop sends heartbeat details at a
|
|
6
|
-
* configurable interval and stops when
|
|
7
|
-
* returned abort function is called.
|
|
6
|
+
* configurable interval and stops when the returned handle is stopped.
|
|
8
7
|
*
|
|
9
|
-
* Heartbeats
|
|
10
|
-
*
|
|
11
|
-
*
|
|
8
|
+
* Heartbeats keep Temporal from timing the activity out
|
|
9
|
+
* (`heartbeatTimeout`) and are how an activity RECEIVES cancellation: the
|
|
10
|
+
* server piggybacks a cancel request on a heartbeat response, and the SDK
|
|
11
|
+
* then aborts `Context.current().cancellationSignal`. `Context.heartbeat()`
|
|
12
|
+
* itself never throws for cancellation (it enqueues to the worker's
|
|
13
|
+
* heartbeat subject — `@temporalio/activity/lib/index.js`
|
|
14
|
+
* `Context.heartbeat`, `@temporalio/worker/lib/worker.js` the heartbeat
|
|
15
|
+
* callback; the SDK's own doc: "Cancellation is not propagated from this
|
|
16
|
+
* function"). Until S2 M3 this handle carried two flags for a throw that
|
|
17
|
+
* cannot happen; a turn reads its interruption from the signal's reason
|
|
18
|
+
* instead (`worker-shutdown.ts` `classifyTurnInterruption`).
|
|
12
19
|
*/
|
|
13
20
|
export interface HeartbeatHandle {
|
|
14
21
|
stop(): void;
|
|
15
|
-
readonly cancelled: boolean;
|
|
16
|
-
readonly workerShutdown: boolean;
|
|
17
22
|
}
|
|
18
|
-
export
|
|
19
|
-
shutdownSignal?: AbortSignal;
|
|
20
|
-
}
|
|
21
|
-
export declare function startHeartbeat(intervalMs: number, getDetails?: () => Record<string, unknown>, options?: HeartbeatOptions): HeartbeatHandle;
|
|
23
|
+
export declare function startHeartbeat(intervalMs: number, getDetails?: () => Record<string, unknown>): HeartbeatHandle;
|
|
22
24
|
export declare function checkCancellation(): void;
|
package/dist/shared/heartbeat.js
CHANGED
|
@@ -3,48 +3,33 @@
|
|
|
3
3
|
*
|
|
4
4
|
* Provides a periodic heartbeat loop that activities can start for
|
|
5
5
|
* long-running operations. The loop sends heartbeat details at a
|
|
6
|
-
* configurable interval and stops when
|
|
7
|
-
* returned abort function is called.
|
|
6
|
+
* configurable interval and stops when the returned handle is stopped.
|
|
8
7
|
*
|
|
9
|
-
* Heartbeats
|
|
10
|
-
*
|
|
11
|
-
*
|
|
8
|
+
* Heartbeats keep Temporal from timing the activity out
|
|
9
|
+
* (`heartbeatTimeout`) and are how an activity RECEIVES cancellation: the
|
|
10
|
+
* server piggybacks a cancel request on a heartbeat response, and the SDK
|
|
11
|
+
* then aborts `Context.current().cancellationSignal`. `Context.heartbeat()`
|
|
12
|
+
* itself never throws for cancellation (it enqueues to the worker's
|
|
13
|
+
* heartbeat subject — `@temporalio/activity/lib/index.js`
|
|
14
|
+
* `Context.heartbeat`, `@temporalio/worker/lib/worker.js` the heartbeat
|
|
15
|
+
* callback; the SDK's own doc: "Cancellation is not propagated from this
|
|
16
|
+
* function"). Until S2 M3 this handle carried two flags for a throw that
|
|
17
|
+
* cannot happen; a turn reads its interruption from the signal's reason
|
|
18
|
+
* instead (`worker-shutdown.ts` `classifyTurnInterruption`).
|
|
12
19
|
*/
|
|
13
20
|
import { Context, CancelledFailure } from "@temporalio/activity";
|
|
14
|
-
export function startHeartbeat(intervalMs, getDetails
|
|
21
|
+
export function startHeartbeat(intervalMs, getDetails) {
|
|
15
22
|
let stopped = false;
|
|
16
|
-
let wasCancelled = false;
|
|
17
|
-
let wasWorkerShutdown = false;
|
|
18
23
|
const timer = setInterval(() => {
|
|
19
24
|
if (stopped)
|
|
20
25
|
return;
|
|
21
|
-
|
|
22
|
-
Context.current().heartbeat(getDetails?.());
|
|
23
|
-
}
|
|
24
|
-
catch (err) {
|
|
25
|
-
if (err instanceof CancelledFailure) {
|
|
26
|
-
if (options?.shutdownSignal?.aborted) {
|
|
27
|
-
wasWorkerShutdown = true;
|
|
28
|
-
}
|
|
29
|
-
else {
|
|
30
|
-
wasCancelled = true;
|
|
31
|
-
}
|
|
32
|
-
stopped = true;
|
|
33
|
-
clearInterval(timer);
|
|
34
|
-
}
|
|
35
|
-
}
|
|
26
|
+
Context.current().heartbeat(getDetails?.());
|
|
36
27
|
}, intervalMs);
|
|
37
28
|
return {
|
|
38
29
|
stop() {
|
|
39
30
|
stopped = true;
|
|
40
31
|
clearInterval(timer);
|
|
41
32
|
},
|
|
42
|
-
get cancelled() {
|
|
43
|
-
return wasCancelled;
|
|
44
|
-
},
|
|
45
|
-
get workerShutdown() {
|
|
46
|
-
return wasWorkerShutdown;
|
|
47
|
-
},
|
|
48
33
|
};
|
|
49
34
|
}
|
|
50
35
|
export function checkCancellation() {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"heartbeat.js","sourceRoot":"","sources":["../../src/shared/heartbeat.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"heartbeat.js","sourceRoot":"","sources":["../../src/shared/heartbeat.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;GAkBG;AAEH,OAAO,EAAE,OAAO,EAAE,gBAAgB,EAAE,MAAM,sBAAsB,CAAC;AAMjE,MAAM,UAAU,cAAc,CAC5B,UAAkB,EAClB,UAA0C;IAE1C,IAAI,OAAO,GAAG,KAAK,CAAC;IAEpB,MAAM,KAAK,GAAG,WAAW,CAAC,GAAG,EAAE;QAC7B,IAAI,OAAO;YAAE,OAAO;QACpB,OAAO,CAAC,OAAO,EAAE,CAAC,SAAS,CAAC,UAAU,EAAE,EAAE,CAAC,CAAC;IAC9C,CAAC,EAAE,UAAU,CAAC,CAAC;IAEf,OAAO;QACL,IAAI;YACF,OAAO,GAAG,IAAI,CAAC;YACf,aAAa,CAAC,KAAK,CAAC,CAAC;QACvB,CAAC;KACF,CAAC;AACJ,CAAC;AAED,MAAM,UAAU,iBAAiB;IAC/B,IAAI,OAAO,CAAC,OAAO,EAAE,CAAC,kBAAkB,CAAC,OAAO,EAAE,CAAC;QACjD,MAAM,IAAI,gBAAgB,CAAC,gCAAgC,CAAC,CAAC;IAC/D,CAAC;AACH,CAAC"}
|
|
@@ -1,5 +1,8 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Streaming persist decision for
|
|
2
|
+
* Streaming persist decision for a harness turn.
|
|
3
|
+
*
|
|
4
|
+
* Harness-agnostic: the Cursor stream loop is today's only caller, the turn
|
|
5
|
+
* runtime takes it over in S2 M3, and S3 retires the native twin below.
|
|
3
6
|
*
|
|
4
7
|
* Mirrors the native deep-agent harness (execute-deep-agent/streaming.ts):
|
|
5
8
|
* `shouldPersist = forceFlush || scheduler.shouldSendUpdate(eventCount)`.
|
|
@@ -9,7 +12,7 @@
|
|
|
9
12
|
* Extracted as a single pure function so the stream loop and its unit tests
|
|
10
13
|
* exercise the same implementation and cannot drift.
|
|
11
14
|
*/
|
|
12
|
-
import type { StreamingUpdateScheduler } from "
|
|
15
|
+
import type { StreamingUpdateScheduler } from "./streaming-scheduler.js";
|
|
13
16
|
/**
|
|
14
17
|
* Force-flush signals — discrete, user-visible state changes that must reach the
|
|
15
18
|
* live stream immediately, independent of the scheduler's time cadence.
|
|
@@ -1,5 +1,8 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Streaming persist decision for
|
|
2
|
+
* Streaming persist decision for a harness turn.
|
|
3
|
+
*
|
|
4
|
+
* Harness-agnostic: the Cursor stream loop is today's only caller, the turn
|
|
5
|
+
* runtime takes it over in S2 M3, and S3 retires the native twin below.
|
|
3
6
|
*
|
|
4
7
|
* Mirrors the native deep-agent harness (execute-deep-agent/streaming.ts):
|
|
5
8
|
* `shouldPersist = forceFlush || scheduler.shouldSendUpdate(eventCount)`.
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"persist-decision.js","sourceRoot":"","sources":["../../src/shared/persist-decision.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AAoBH;;;;;;;;;;;;;GAaG;AACH,MAAM,UAAU,4BAA4B,CAC1C,OAA0B,EAC1B,SAAmC,EACnC,UAAkB,EAClB,KAAc;IAEd,MAAM,UAAU,GACd,OAAO,CAAC,kBAAkB,IAAI,OAAO,CAAC,UAAU,IAAI,OAAO,CAAC,YAAY,CAAC;IAC3E,OAAO,UAAU,IAAI,SAAS,CAAC,gBAAgB,CAAC,UAAU,EAAE,KAAK,CAAC,CAAC;AACrE,CAAC"}
|
|
@@ -5,9 +5,17 @@
|
|
|
5
5
|
* - Mounts each skill via the shared skill-mount mechanics (SKILL.md +
|
|
6
6
|
* extracted artifact, hash-keyed cache — see shared/skill-mount.ts)
|
|
7
7
|
* - Uses a platform-managed directory outside the workspace
|
|
8
|
-
* - Ensures the workspace `.stigmer` symlink (see stigmer-link.ts)
|
|
8
|
+
* - Ensures the workspace `.stigmer` symlink (see workspace/stigmer-link.ts)
|
|
9
9
|
* - Returns metadata for prompt injection
|
|
10
10
|
*
|
|
11
|
+
* A turn-runtime phase (`harness/turn-context.ts` `mountSkills`): it reads
|
|
12
|
+
* the control plane, which only the runtime holds, and writes under the
|
|
13
|
+
* platform dir the runtime owns; the harness renders the returned metadata
|
|
14
|
+
* into its prompt in its own placement. Moved from
|
|
15
|
+
* `activities/execute-cursor/` at S2 M3b; the native harness's twin
|
|
16
|
+
* (`skill-writer.ts` `fetchSkillsByRefs` + `mountSkills`) is what S3
|
|
17
|
+
* reconciles it with.
|
|
18
|
+
*
|
|
11
19
|
* The mount is cached by the skill's content-addressed version hash
|
|
12
20
|
* (stigmer/stigmer#672): metadata is fetched on every execution (that keeps
|
|
13
21
|
* latest-version freshness), but the artifact download and file rewrite are
|
|
@@ -16,9 +24,14 @@
|
|
|
16
24
|
* message after the first pays a metadata read instead of a full artifact
|
|
17
25
|
* transfer.
|
|
18
26
|
*/
|
|
19
|
-
import type { StigmerClient } from "
|
|
27
|
+
import type { StigmerClient } from "../client/stigmer-client.js";
|
|
20
28
|
import type { ApiResourceReference } from "@stigmer/protos/ai/stigmer/commons/apiresource/io_pb";
|
|
21
|
-
|
|
29
|
+
/** One mounted skill as a prompt renders it: its name, its description, and the workspace-relative path of its SKILL.md. */
|
|
30
|
+
export interface SkillMetadata {
|
|
31
|
+
name: string;
|
|
32
|
+
description: string;
|
|
33
|
+
path: string;
|
|
34
|
+
}
|
|
22
35
|
export interface SkillResolverOptions {
|
|
23
36
|
sessionId: string;
|
|
24
37
|
primaryWorkspaceDir: string;
|
|
@@ -5,9 +5,17 @@
|
|
|
5
5
|
* - Mounts each skill via the shared skill-mount mechanics (SKILL.md +
|
|
6
6
|
* extracted artifact, hash-keyed cache — see shared/skill-mount.ts)
|
|
7
7
|
* - Uses a platform-managed directory outside the workspace
|
|
8
|
-
* - Ensures the workspace `.stigmer` symlink (see stigmer-link.ts)
|
|
8
|
+
* - Ensures the workspace `.stigmer` symlink (see workspace/stigmer-link.ts)
|
|
9
9
|
* - Returns metadata for prompt injection
|
|
10
10
|
*
|
|
11
|
+
* A turn-runtime phase (`harness/turn-context.ts` `mountSkills`): it reads
|
|
12
|
+
* the control plane, which only the runtime holds, and writes under the
|
|
13
|
+
* platform dir the runtime owns; the harness renders the returned metadata
|
|
14
|
+
* into its prompt in its own placement. Moved from
|
|
15
|
+
* `activities/execute-cursor/` at S2 M3b; the native harness's twin
|
|
16
|
+
* (`skill-writer.ts` `fetchSkillsByRefs` + `mountSkills`) is what S3
|
|
17
|
+
* reconciles it with.
|
|
18
|
+
*
|
|
11
19
|
* The mount is cached by the skill's content-addressed version hash
|
|
12
20
|
* (stigmer/stigmer#672): metadata is fetched on every execution (that keeps
|
|
13
21
|
* latest-version freshness), but the artifact download and file rewrite are
|
|
@@ -18,9 +26,9 @@
|
|
|
18
26
|
*/
|
|
19
27
|
import { mkdir } from "node:fs/promises";
|
|
20
28
|
import { join } from "node:path";
|
|
21
|
-
import { getPlatformDir } from "
|
|
22
|
-
import { SKILLS_SUBDIR, mountIsFresh, downloadArtifact, writeSkillMount, } from "
|
|
23
|
-
import { ensureStigmerSymlink, STIGMER_LOCAL_STATE_DIR } from "
|
|
29
|
+
import { getPlatformDir } from "./workspace/platform-dir.js";
|
|
30
|
+
import { SKILLS_SUBDIR, mountIsFresh, downloadArtifact, writeSkillMount, } from "./skill-mount.js";
|
|
31
|
+
import { ensureStigmerSymlink, STIGMER_LOCAL_STATE_DIR } from "./workspace/stigmer-link.js";
|
|
24
32
|
/**
|
|
25
33
|
* Resolve skill references into written SKILL.md files and prompt metadata.
|
|
26
34
|
*
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"skill-resolver.js","sourceRoot":"","sources":["../../src/shared/skill-resolver.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AAEH,OAAO,EAAE,KAAK,EAAE,MAAM,kBAAkB,CAAC;AACzC,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AAGjC,OAAO,EAAE,cAAc,EAAE,MAAM,6BAA6B,CAAC;AAC7D,OAAO,EACL,aAAa,EACb,YAAY,EACZ,gBAAgB,EAChB,eAAe,GAChB,MAAM,kBAAkB,CAAC;AAC1B,OAAO,EAAE,oBAAoB,EAAE,uBAAuB,EAAE,MAAM,6BAA6B,CAAC;AAc5F;;;;;;GAMG;AACH,MAAM,CAAC,KAAK,UAAU,aAAa,CACjC,MAAqB,EACrB,SAAiC,EACjC,OAA6B;IAE7B,OAAO,CAAC,GAAG,CACT,6BAA6B,O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C,OAAO,CAAC,CAAC,CAAC,GAAG,EAAE,CACrG,CAAC;gBACJ,CAAC;YACH,CAAC;YAED,MAAM,eAAe,CAAC,KAAK,EAAE,QAAQ,EAAE,aAAa,CAAC,CAAC;YACtD,OAAO,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;YACnB,OAAO,CAAC,GAAG,CAAC,gCAAgC,IAAI,OAAO,IAAI,CAAC,IAAI,EAAE,CAAC,CAAC;QACtE,CAAC;QAAC,OAAO,GAAG,EAAE,CAAC;YACb,OAAO,CAAC,IAAI,CACV,2CAA2C,GAAG,CAAC,GAAG,IAAI,GAAG,CAAC,IAAI,KAAK,GAAG,YAAY,KAAK,CAAC,CAAC,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC,CAAC,GAAG,EAAE,CAC9G,CAAC;QACJ,CAAC;IACH,CAAC;IAED,OAAO,CAAC,GAAG,CACT,8BAA8B,OAAO,CAAC,MAAM,IAAI,SAAS,CAAC,MAAM,kBAAkB,CACnF,CAAC;IAEF,OAAO,OAAO,CAAC;AACjB,CAAC"}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Terminal transitions on the sub-agent rows of an execution status,
|
|
3
|
+
* operating on the proto array itself.
|
|
4
|
+
*
|
|
5
|
+
* One function today: marking every non-terminal sub-agent CANCELLED when a
|
|
6
|
+
* turn ends without them (a pause, a shutdown, a stall, a cost cap, an
|
|
7
|
+
* infrastructure cancel), so the final snapshot has no permanent IN_PROGRESS
|
|
8
|
+
* "zombie" delegation. Harness-agnostic (a `SubAgentExecution` is the
|
|
9
|
+
* platform's row, not an engine's), read by the turn runtime's terminal
|
|
10
|
+
* table and the Cursor accumulator's own finalize alike.
|
|
11
|
+
*
|
|
12
|
+
* Moved from `activities/execute-cursor/message-translator.ts` at S2 M3 so
|
|
13
|
+
* the runtime's catch can reach it; the body is unchanged.
|
|
14
|
+
*/
|
|
15
|
+
import type { SubAgentExecution } from "@stigmer/protos/ai/stigmer/agentic/agentexecution/v1/subagent_pb";
|
|
16
|
+
/**
|
|
17
|
+
* Transition any non-terminal sub-agent (IN_PROGRESS or PENDING) in the given
|
|
18
|
+
* proto array to CANCELLED with a completion timestamp, in place. Returns
|
|
19
|
+
* true if any sub-agent changed.
|
|
20
|
+
*/
|
|
21
|
+
export declare function cancelInProgressSubAgentProtos(subAgents: SubAgentExecution[]): boolean;
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Terminal transitions on the sub-agent rows of an execution status,
|
|
3
|
+
* operating on the proto array itself.
|
|
4
|
+
*
|
|
5
|
+
* One function today: marking every non-terminal sub-agent CANCELLED when a
|
|
6
|
+
* turn ends without them (a pause, a shutdown, a stall, a cost cap, an
|
|
7
|
+
* infrastructure cancel), so the final snapshot has no permanent IN_PROGRESS
|
|
8
|
+
* "zombie" delegation. Harness-agnostic (a `SubAgentExecution` is the
|
|
9
|
+
* platform's row, not an engine's), read by the turn runtime's terminal
|
|
10
|
+
* table and the Cursor accumulator's own finalize alike.
|
|
11
|
+
*
|
|
12
|
+
* Moved from `activities/execute-cursor/message-translator.ts` at S2 M3 so
|
|
13
|
+
* the runtime's catch can reach it; the body is unchanged.
|
|
14
|
+
*/
|
|
15
|
+
import { SubAgentStatus } from "@stigmer/protos/ai/stigmer/agentic/agentexecution/v1/enum_pb";
|
|
16
|
+
import { utcTimestamp } from "./status.js";
|
|
17
|
+
/**
|
|
18
|
+
* Transition any non-terminal sub-agent (IN_PROGRESS or PENDING) in the given
|
|
19
|
+
* proto array to CANCELLED with a completion timestamp, in place. Returns
|
|
20
|
+
* true if any sub-agent changed.
|
|
21
|
+
*/
|
|
22
|
+
export function cancelInProgressSubAgentProtos(subAgents) {
|
|
23
|
+
let changed = false;
|
|
24
|
+
for (const sub of subAgents) {
|
|
25
|
+
if (sub.status === SubAgentStatus.SUB_AGENT_IN_PROGRESS ||
|
|
26
|
+
sub.status === SubAgentStatus.SUB_AGENT_PENDING) {
|
|
27
|
+
sub.status = SubAgentStatus.SUB_AGENT_CANCELLED;
|
|
28
|
+
sub.completedAt = utcTimestamp();
|
|
29
|
+
changed = true;
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
return changed;
|
|
33
|
+
}
|
|
34
|
+
//# sourceMappingURL=subagent-rows.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"subagent-rows.js","sourceRoot":"","sources":["../../src/shared/subagent-rows.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AAGH,OAAO,EAAE,cAAc,EAAE,MAAM,8DAA8D,CAAC;AAE9F,OAAO,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAE3C;;;;GAIG;AACH,MAAM,UAAU,8BAA8B,CAAC,SAA8B;IAC3E,IAAI,OAAO,GAAG,KAAK,CAAC;IACpB,KAAK,MAAM,GAAG,IAAI,SAAS,EAAE,CAAC;QAC5B,IACE,GAAG,CAAC,MAAM,KAAK,cAAc,CAAC,qBAAqB;YACnD,GAAG,CAAC,MAAM,KAAK,cAAc,CAAC,iBAAiB,EAC/C,CAAC;YACD,GAAG,CAAC,MAAM,GAAG,cAAc,CAAC,mBAAmB,CAAC;YAChD,GAAG,CAAC,WAAW,GAAG,YAAY,EAAE,CAAC;YACjC,OAAO,GAAG,IAAI,CAAC;QACjB,CAAC;IACH,CAAC;IACD,OAAO,OAAO,CAAC;AACjB,CAAC"}
|
|
@@ -40,28 +40,55 @@ export declare function getShutdownSignalForQueue(taskQueue: string): AbortSigna
|
|
|
40
40
|
export declare function signalWorkerShutdown(taskQueue: string): void;
|
|
41
41
|
/** Drop the registration once the queue's worker is fully torn down. */
|
|
42
42
|
export declare function unregisterWorkerShutdownSignal(taskQueue: string): void;
|
|
43
|
-
/**
|
|
43
|
+
/**
|
|
44
|
+
* Why Temporal cancelled the activity, as the SDK states it: the message of
|
|
45
|
+
* the `CancelledFailure` it aborted `Context.current().cancellationSignal`
|
|
46
|
+
* with (`@temporalio/activity`'s module header lists them — `CANCELLED` for a
|
|
47
|
+
* workflow-requested cancel, `TIMED_OUT` when a heartbeat or other timeout
|
|
48
|
+
* fired server-side, `NOT_FOUND` when the run closed, `WORKER_SHUTDOWN`,
|
|
49
|
+
* `HEARTBEAT_DETAILS_CONVERSION_FAILED`, `PAUSED`). `undefined` when no
|
|
50
|
+
* cancellation was delivered.
|
|
51
|
+
*/
|
|
52
|
+
export type CancellationReason = string | undefined;
|
|
53
|
+
/** The reason a cancellation signal carries, or `undefined` when it has not aborted. */
|
|
54
|
+
export declare function cancellationReasonOf(signal: AbortSignal): CancellationReason;
|
|
55
|
+
/** The evidence a turn's interruption classification weighs (see below). */
|
|
44
56
|
export interface TurnInterruptionEvidence {
|
|
45
|
-
/** The
|
|
46
|
-
|
|
47
|
-
/** The periodic heartbeat threw CancelledFailure with the signal aborted. */
|
|
48
|
-
heartbeatWorkerShutdown: boolean;
|
|
49
|
-
/** Temporal delivered cancellation to the activity. */
|
|
50
|
-
cancellationSignalAborted: boolean;
|
|
57
|
+
/** The delivered cancellation's reason; `undefined` when none was delivered. */
|
|
58
|
+
readonly cancellationReason: CancellationReason;
|
|
51
59
|
/** This queue's worker-shutdown signal is aborted. */
|
|
52
|
-
shutdownSignalAborted: boolean;
|
|
60
|
+
readonly shutdownSignalAborted: boolean;
|
|
53
61
|
}
|
|
54
62
|
/**
|
|
55
|
-
*
|
|
56
|
-
*
|
|
57
|
-
*
|
|
63
|
+
* How Temporal's cancellation reads to the turn:
|
|
64
|
+
* - `worker-shutdown`: the runner is draining (the queue's signal, or the
|
|
65
|
+
* SDK's own `WORKER_SHUTDOWN`); FAILED with the shutdown copy, thrown.
|
|
66
|
+
* - `pause`: the workflow asked (`CANCELLED`, the Pause RPC's path);
|
|
67
|
+
* PAUSED, thrown.
|
|
68
|
+
* - `infrastructure`: the platform cancelled for its own reason (a heartbeat
|
|
69
|
+
* timeout, a closed run); FAILED with the unresponsive copy, thrown.
|
|
70
|
+
* - `none`: nothing was delivered.
|
|
71
|
+
*/
|
|
72
|
+
export type TurnInterruption = "worker-shutdown" | "pause" | "infrastructure" | "none";
|
|
73
|
+
/**
|
|
74
|
+
* Classify how (whether) Temporal interrupted the turn, from the two live
|
|
75
|
+
* facts: the reason on the cancellation signal and the queue's shutdown
|
|
76
|
+
* signal. Pure so the decision table is directly testable.
|
|
58
77
|
*
|
|
59
78
|
* The load-bearing rule is the grace-window guard (#776): an aborted
|
|
60
79
|
* shutdown signal ALONE is "none", because a run that completes normally
|
|
61
80
|
* inside the drain grace window reaches the classification with the signal
|
|
62
|
-
* already aborted and nothing actually interrupted. Shutdown requires
|
|
63
|
-
*
|
|
64
|
-
*
|
|
65
|
-
*
|
|
81
|
+
* already aborted and nothing actually interrupted. Shutdown requires a
|
|
82
|
+
* delivered cancellation alongside the signal.
|
|
83
|
+
*
|
|
84
|
+
* Until S2 M3 the evidence also carried two flags from the periodic
|
|
85
|
+
* heartbeat ("it threw `CancelledFailure`"), and a delivered cancellation
|
|
86
|
+
* without them read as "none". `Context.heartbeat()` never throws in the
|
|
87
|
+
* Temporal TypeScript SDK (it enqueues to the worker's heartbeat subject;
|
|
88
|
+
* `@temporalio/activity/lib/index.js` `Context.heartbeat`,
|
|
89
|
+
* `@temporalio/worker/lib/worker.js` the heartbeat callback), so the flags
|
|
90
|
+
* were never set and a pause was in fact recognised by the stream loop's
|
|
91
|
+
* own cancellation check. The reason the SDK puts on the signal is the
|
|
92
|
+
* direct identity that inference stood in for.
|
|
66
93
|
*/
|
|
67
|
-
export declare function classifyTurnInterruption(evidence: TurnInterruptionEvidence):
|
|
94
|
+
export declare function classifyTurnInterruption(evidence: TurnInterruptionEvidence): TurnInterruption;
|
|
@@ -51,29 +51,44 @@ export function signalWorkerShutdown(taskQueue) {
|
|
|
51
51
|
export function unregisterWorkerShutdownSignal(taskQueue) {
|
|
52
52
|
registry.delete(taskQueue);
|
|
53
53
|
}
|
|
54
|
+
/** The reason a cancellation signal carries, or `undefined` when it has not aborted. */
|
|
55
|
+
export function cancellationReasonOf(signal) {
|
|
56
|
+
if (!signal.aborted)
|
|
57
|
+
return undefined;
|
|
58
|
+
const reason = signal.reason;
|
|
59
|
+
if (reason instanceof Error)
|
|
60
|
+
return reason.message;
|
|
61
|
+
return typeof reason === "string" ? reason : "CANCELLED";
|
|
62
|
+
}
|
|
54
63
|
/**
|
|
55
|
-
* Classify how (whether)
|
|
56
|
-
*
|
|
57
|
-
*
|
|
64
|
+
* Classify how (whether) Temporal interrupted the turn, from the two live
|
|
65
|
+
* facts: the reason on the cancellation signal and the queue's shutdown
|
|
66
|
+
* signal. Pure so the decision table is directly testable.
|
|
58
67
|
*
|
|
59
68
|
* The load-bearing rule is the grace-window guard (#776): an aborted
|
|
60
69
|
* shutdown signal ALONE is "none", because a run that completes normally
|
|
61
70
|
* inside the drain grace window reaches the classification with the signal
|
|
62
|
-
* already aborted and nothing actually interrupted. Shutdown requires
|
|
63
|
-
*
|
|
64
|
-
*
|
|
65
|
-
*
|
|
71
|
+
* already aborted and nothing actually interrupted. Shutdown requires a
|
|
72
|
+
* delivered cancellation alongside the signal.
|
|
73
|
+
*
|
|
74
|
+
* Until S2 M3 the evidence also carried two flags from the periodic
|
|
75
|
+
* heartbeat ("it threw `CancelledFailure`"), and a delivered cancellation
|
|
76
|
+
* without them read as "none". `Context.heartbeat()` never throws in the
|
|
77
|
+
* Temporal TypeScript SDK (it enqueues to the worker's heartbeat subject;
|
|
78
|
+
* `@temporalio/activity/lib/index.js` `Context.heartbeat`,
|
|
79
|
+
* `@temporalio/worker/lib/worker.js` the heartbeat callback), so the flags
|
|
80
|
+
* were never set and a pause was in fact recognised by the stream loop's
|
|
81
|
+
* own cancellation check. The reason the SDK puts on the signal is the
|
|
82
|
+
* direct identity that inference stood in for.
|
|
66
83
|
*/
|
|
67
84
|
export function classifyTurnInterruption(evidence) {
|
|
68
|
-
const
|
|
69
|
-
|
|
70
|
-
evidence.cancellationSignalAborted;
|
|
71
|
-
if (!interrupted) {
|
|
85
|
+
const { cancellationReason, shutdownSignalAborted } = evidence;
|
|
86
|
+
if (cancellationReason === undefined) {
|
|
72
87
|
return "none";
|
|
73
88
|
}
|
|
74
|
-
if (
|
|
89
|
+
if (shutdownSignalAborted || cancellationReason === "WORKER_SHUTDOWN") {
|
|
75
90
|
return "worker-shutdown";
|
|
76
91
|
}
|
|
77
|
-
return
|
|
92
|
+
return cancellationReason === "CANCELLED" ? "pause" : "infrastructure";
|
|
78
93
|
}
|
|
79
94
|
//# sourceMappingURL=worker-shutdown.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"worker-shutdown.js","sourceRoot":"","sources":["../../src/shared/worker-shutdown.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AAEH,MAAM,QAAQ,GAAG,IAAI,GAAG,EAA2B,CAAC;AAEpD;;;;;GAKG;AACH,MAAM,UAAU,4BAA4B,CAAC,SAAiB;IAC5D,MAAM,UAAU,GAAG,IAAI,eAAe,EAAE,CAAC;IACzC,QAAQ,CAAC,GAAG,CAAC,SAAS,EAAE,UAAU,CAAC,CAAC;IACpC,OAAO,UAAU,CAAC;AACpB,CAAC;AAED,kFAAkF;AAClF,MAAM,UAAU,yBAAyB,CAAC,SAAiB;IACzD,OAAO,QAAQ,CAAC,GAAG,CAAC,SAAS,CAAC,EAAE,MAAM,CAAC;AACzC,CAAC;AAED;;;GAGG;AACH,MAAM,UAAU,oBAAoB,CAAC,SAAiB;IACpD,QAAQ,CAAC,GAAG,CAAC,SAAS,CAAC,EAAE,KAAK,EAAE,CAAC;AACnC,CAAC;AAED,wEAAwE;AACxE,MAAM,UAAU,8BAA8B,CAAC,SAAiB;IAC9D,QAAQ,CAAC,MAAM,CAAC,SAAS,CAAC,CAAC;AAC7B,CAAC;
|
|
1
|
+
{"version":3,"file":"worker-shutdown.js","sourceRoot":"","sources":["../../src/shared/worker-shutdown.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;GA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