@exaudeus/workrail 3.15.0 → 3.16.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/application/services/workflow-service.d.ts +2 -0
- package/dist/application/services/workflow-service.js +3 -0
- package/dist/console/assets/index-BE5PAgPO.js +28 -0
- package/dist/console/assets/index-BZNM03t1.css +1 -0
- package/dist/console/index.html +2 -2
- package/dist/env-flags.d.ts +1 -0
- package/dist/env-flags.js +4 -0
- package/dist/infrastructure/session/HttpServer.d.ts +3 -3
- package/dist/infrastructure/session/HttpServer.js +68 -74
- package/dist/infrastructure/storage/caching-workflow-storage.d.ts +2 -0
- package/dist/infrastructure/storage/caching-workflow-storage.js +15 -6
- package/dist/infrastructure/storage/file-workflow-storage.js +3 -4
- package/dist/infrastructure/storage/schema-validating-workflow-storage.js +9 -8
- package/dist/manifest.json +257 -193
- package/dist/mcp/assert-output.d.ts +37 -0
- package/dist/mcp/assert-output.js +52 -0
- package/dist/mcp/boundary-coercion.d.ts +1 -0
- package/dist/mcp/boundary-coercion.js +44 -0
- package/dist/mcp/dev-mode.d.ts +1 -0
- package/dist/mcp/dev-mode.js +4 -0
- package/dist/mcp/handler-factory.js +12 -9
- package/dist/mcp/handlers/session.js +8 -9
- package/dist/mcp/handlers/v2-advance-core/event-builders.d.ts +2 -0
- package/dist/mcp/handlers/v2-advance-core/event-builders.js +6 -6
- package/dist/mcp/handlers/v2-advance-core/index.d.ts +2 -0
- package/dist/mcp/handlers/v2-advance-core/index.js +4 -3
- package/dist/mcp/handlers/v2-advance-core/input-validation.d.ts +2 -0
- package/dist/mcp/handlers/v2-advance-core/input-validation.js +32 -9
- package/dist/mcp/handlers/v2-advance-core/outcome-blocked.d.ts +2 -0
- package/dist/mcp/handlers/v2-advance-core/outcome-blocked.js +1 -1
- package/dist/mcp/handlers/v2-advance-core/outcome-success.d.ts +2 -0
- package/dist/mcp/handlers/v2-advance-core/outcome-success.js +1 -1
- package/dist/mcp/handlers/v2-checkpoint.d.ts +1 -1
- package/dist/mcp/handlers/v2-checkpoint.js +5 -6
- package/dist/mcp/handlers/v2-execution/advance.d.ts +4 -2
- package/dist/mcp/handlers/v2-execution/advance.js +5 -7
- package/dist/mcp/handlers/v2-execution/continue-advance.js +56 -26
- package/dist/mcp/handlers/v2-execution/continue-rehydrate.d.ts +1 -1
- package/dist/mcp/handlers/v2-execution/continue-rehydrate.js +9 -9
- package/dist/mcp/handlers/v2-execution/replay.d.ts +6 -4
- package/dist/mcp/handlers/v2-execution/replay.js +47 -30
- package/dist/mcp/handlers/v2-execution/start.d.ts +2 -3
- package/dist/mcp/handlers/v2-execution/start.js +11 -11
- package/dist/mcp/handlers/v2-execution/workflow-object-cache.d.ts +5 -0
- package/dist/mcp/handlers/v2-execution/workflow-object-cache.js +19 -0
- package/dist/mcp/handlers/v2-execution-helpers.d.ts +1 -0
- package/dist/mcp/handlers/v2-execution-helpers.js +23 -7
- package/dist/mcp/handlers/v2-resume.d.ts +1 -1
- package/dist/mcp/handlers/v2-resume.js +3 -4
- package/dist/mcp/handlers/v2-state-conversion.js +5 -1
- package/dist/mcp/handlers/v2-workflow.d.ts +80 -0
- package/dist/mcp/handlers/v2-workflow.js +36 -21
- package/dist/mcp/handlers/workflow.d.ts +2 -5
- package/dist/mcp/handlers/workflow.js +15 -12
- package/dist/mcp/output-schemas.d.ts +20 -27
- package/dist/mcp/output-schemas.js +5 -7
- package/dist/mcp/server.js +22 -4
- package/dist/mcp/tool-call-timing.d.ts +24 -0
- package/dist/mcp/tool-call-timing.js +85 -0
- package/dist/mcp/transports/http-entry.js +3 -2
- package/dist/mcp/transports/http-listener.d.ts +1 -0
- package/dist/mcp/transports/http-listener.js +25 -0
- package/dist/mcp/transports/shutdown-hooks.d.ts +4 -1
- package/dist/mcp/transports/shutdown-hooks.js +3 -2
- package/dist/mcp/transports/stdio-entry.js +6 -28
- package/dist/mcp/v2-response-formatter.js +2 -4
- package/dist/mcp/validation/schema-introspection.d.ts +1 -0
- package/dist/mcp/validation/schema-introspection.js +15 -5
- package/dist/mcp/validation/suggestion-generator.js +2 -2
- package/dist/runtime/adapters/node-process-signals.d.ts +1 -0
- package/dist/runtime/adapters/node-process-signals.js +5 -0
- package/dist/runtime/adapters/noop-process-signals.d.ts +1 -0
- package/dist/runtime/adapters/noop-process-signals.js +2 -0
- package/dist/runtime/ports/process-signals.d.ts +1 -0
- package/dist/types/workflow-definition.d.ts +2 -0
- package/dist/types/workflow.d.ts +3 -0
- package/dist/types/workflow.js +35 -26
- package/dist/v2/durable-core/domain/context-template-resolver.js +2 -2
- package/dist/v2/durable-core/domain/function-definition-expander.js +2 -17
- package/dist/v2/durable-core/domain/prompt-renderer.d.ts +1 -0
- package/dist/v2/durable-core/domain/prompt-renderer.js +23 -18
- package/dist/v2/durable-core/domain/recap-recovery.js +23 -16
- package/dist/v2/durable-core/domain/retrieval-contract.js +13 -7
- package/dist/v2/durable-core/session-index.d.ts +22 -0
- package/dist/v2/durable-core/session-index.js +58 -0
- package/dist/v2/durable-core/sorted-event-log.d.ts +6 -0
- package/dist/v2/durable-core/sorted-event-log.js +15 -0
- package/dist/v2/infra/local/fs/index.js +8 -8
- package/dist/v2/infra/local/session-store/index.d.ts +1 -1
- package/dist/v2/infra/local/session-store/index.js +71 -61
- package/dist/v2/infra/local/session-summary-provider/index.js +9 -4
- package/dist/v2/infra/local/snapshot-store/index.js +2 -1
- package/dist/v2/ports/session-event-log-store.port.d.ts +1 -1
- package/dist/v2/projections/assessment-consequences.d.ts +2 -1
- package/dist/v2/projections/assessment-consequences.js +0 -5
- package/dist/v2/projections/assessments.d.ts +2 -1
- package/dist/v2/projections/assessments.js +2 -4
- package/dist/v2/projections/gaps.d.ts +2 -1
- package/dist/v2/projections/gaps.js +0 -5
- package/dist/v2/projections/preferences.d.ts +2 -1
- package/dist/v2/projections/preferences.js +0 -5
- package/dist/v2/projections/run-context.d.ts +2 -2
- package/dist/v2/projections/run-context.js +0 -5
- package/dist/v2/projections/run-dag.js +7 -1
- package/dist/v2/projections/run-execution-trace.d.ts +8 -0
- package/dist/v2/projections/run-execution-trace.js +124 -0
- package/dist/v2/projections/run-status-signals.d.ts +2 -2
- package/dist/v2/usecases/console-routes.d.ts +3 -1
- package/dist/v2/usecases/console-routes.js +123 -25
- package/dist/v2/usecases/console-service.d.ts +1 -0
- package/dist/v2/usecases/console-service.js +83 -25
- package/dist/v2/usecases/console-types.d.ts +53 -0
- package/dist/v2/usecases/worktree-service.js +32 -1
- package/package.json +6 -5
- package/spec/workflow.schema.json +18 -0
- package/workflows/adaptive-ticket-creation.json +23 -16
- package/workflows/architecture-scalability-audit.json +29 -22
- package/workflows/bug-investigation.agentic.v2.json +7 -0
- package/workflows/coding-task-workflow-agentic.json +7 -0
- package/workflows/coding-task-workflow-agentic.lean.v2.json +16 -8
- package/workflows/coding-task-workflow-agentic.v2.json +7 -0
- package/workflows/cross-platform-code-conversion.v2.json +7 -0
- package/workflows/document-creation-workflow.json +15 -8
- package/workflows/documentation-update-workflow.json +15 -8
- package/workflows/intelligent-test-case-generation.json +7 -0
- package/workflows/learner-centered-course-workflow.json +9 -2
- package/workflows/mr-review-workflow.agentic.v2.json +7 -0
- package/workflows/personal-learning-materials-creation-branched.json +15 -8
- package/workflows/presentation-creation.json +12 -5
- package/workflows/production-readiness-audit.json +7 -0
- package/workflows/relocation-workflow-us.json +39 -32
- package/workflows/scoped-documentation-workflow.json +33 -26
- package/workflows/ui-ux-design-workflow.json +7 -0
- package/workflows/workflow-diagnose-environment.json +6 -0
- package/workflows/workflow-for-workflows.json +7 -0
- package/workflows/workflow-for-workflows.v2.json +23 -11
- package/workflows/wr.discovery.json +8 -1
- package/dist/console/assets/index-BZYIjrzJ.js +0 -28
- package/dist/console/assets/index-OLCKbDdm.css +0 -1
|
@@ -1,19 +1,27 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.handleAdvanceIntent = handleAdvanceIntent;
|
|
4
|
-
const
|
|
4
|
+
const workflow_object_cache_js_1 = require("./workflow-object-cache.js");
|
|
5
5
|
const workflow_hash_ref_js_1 = require("../../../v2/durable-core/ids/workflow-hash-ref.js");
|
|
6
6
|
const neverthrow_1 = require("neverthrow");
|
|
7
|
-
const workflow_source_js_1 = require("../../../types/workflow-source.js");
|
|
8
7
|
const workflow_definition_js_1 = require("../../../types/workflow-definition.js");
|
|
9
8
|
const v2_error_mapping_js_1 = require("../v2-error-mapping.js");
|
|
10
|
-
const constants_js_1 = require("../../../v2/durable-core/constants.js");
|
|
11
9
|
const replay_js_1 = require("./replay.js");
|
|
12
10
|
const advance_js_1 = require("./advance.js");
|
|
11
|
+
const sorted_event_log_js_1 = require("../../../v2/durable-core/sorted-event-log.js");
|
|
12
|
+
const session_index_js_1 = require("../../../v2/durable-core/session-index.js");
|
|
13
13
|
function handleAdvanceIntent(args) {
|
|
14
14
|
const { input, sessionId, runId, nodeId, attemptId, workflowHashRef, truth, gate, sessionStore, snapshotStore, pinnedStore, tokenCodecPorts, idFactory, sha256, aliasStore, entropy } = args;
|
|
15
15
|
const dedupeKey = `advance_recorded:${sessionId}:${nodeId}:${attemptId}`;
|
|
16
|
-
const
|
|
16
|
+
const preLockSortedResult = (0, sorted_event_log_js_1.asSortedEventLog)(truth.events);
|
|
17
|
+
if (preLockSortedResult.isErr()) {
|
|
18
|
+
return (0, neverthrow_1.errAsync)({
|
|
19
|
+
kind: 'invariant_violation',
|
|
20
|
+
message: `Session events are not sorted: ${preLockSortedResult.error.message}`,
|
|
21
|
+
});
|
|
22
|
+
}
|
|
23
|
+
const preLockIndex = (0, session_index_js_1.buildSessionIndex)(preLockSortedResult.value);
|
|
24
|
+
const runStarted = preLockIndex.runStartedByRunId.get(String(runId));
|
|
17
25
|
if (!runStarted) {
|
|
18
26
|
return (0, neverthrow_1.errAsync)({
|
|
19
27
|
kind: 'token_unknown_node',
|
|
@@ -37,7 +45,7 @@ function handleAdvanceIntent(args) {
|
|
|
37
45
|
suggestion: 'Use the continueToken returned by WorkRail for this run.',
|
|
38
46
|
});
|
|
39
47
|
}
|
|
40
|
-
const nodeCreated =
|
|
48
|
+
const nodeCreated = preLockIndex.nodeCreatedByNodeId.get(String(nodeId));
|
|
41
49
|
if (!nodeCreated) {
|
|
42
50
|
return (0, neverthrow_1.errAsync)({
|
|
43
51
|
kind: 'token_unknown_node',
|
|
@@ -45,22 +53,24 @@ function handleAdvanceIntent(args) {
|
|
|
45
53
|
suggestion: 'Use tokens returned by WorkRail for an existing node.',
|
|
46
54
|
});
|
|
47
55
|
}
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
56
|
+
if (nodeCreated.data.workflowHash !== workflowHash) {
|
|
57
|
+
const nodeRefRes = (0, workflow_hash_ref_js_1.deriveWorkflowHashRef)(nodeCreated.data.workflowHash);
|
|
58
|
+
if (nodeRefRes.isErr()) {
|
|
59
|
+
return (0, neverthrow_1.errAsync)({
|
|
60
|
+
kind: 'precondition_failed',
|
|
61
|
+
message: nodeRefRes.error.message,
|
|
62
|
+
suggestion: 'Re-pin the workflow via start_workflow.',
|
|
63
|
+
});
|
|
64
|
+
}
|
|
65
|
+
if (String(nodeRefRes.value) !== String(workflowHashRef)) {
|
|
66
|
+
return (0, neverthrow_1.errAsync)({
|
|
67
|
+
kind: 'precondition_failed',
|
|
68
|
+
message: 'workflowHash mismatch for this node.',
|
|
69
|
+
suggestion: 'Use the continueToken returned by WorkRail for this node.',
|
|
70
|
+
});
|
|
71
|
+
}
|
|
62
72
|
}
|
|
63
|
-
const existing =
|
|
73
|
+
const existing = preLockIndex.advanceRecordedByDedupeKey.get(dedupeKey);
|
|
64
74
|
return pinnedStore.get(workflowHash)
|
|
65
75
|
.mapErr((cause) => ({ kind: 'pinned_workflow_store_failed', cause }))
|
|
66
76
|
.andThen((compiled) => {
|
|
@@ -75,7 +85,7 @@ function handleAdvanceIntent(args) {
|
|
|
75
85
|
suggestion: 'Re-pin the workflow via start_workflow.',
|
|
76
86
|
});
|
|
77
87
|
}
|
|
78
|
-
const pinnedWorkflow = (0,
|
|
88
|
+
const pinnedWorkflow = (0, workflow_object_cache_js_1.getCachedWorkflow)(workflowHash, compiled.definition);
|
|
79
89
|
if (existing) {
|
|
80
90
|
return (0, replay_js_1.replayFromRecordedAdvance)({
|
|
81
91
|
recordedEvent: existing,
|
|
@@ -95,9 +105,17 @@ function handleAdvanceIntent(args) {
|
|
|
95
105
|
}
|
|
96
106
|
return gate
|
|
97
107
|
.withHealthySessionLock(sessionId, (lock) => sessionStore.load(sessionId).andThen((truthLocked) => {
|
|
98
|
-
const
|
|
108
|
+
const lockedSortedResult = (0, sorted_event_log_js_1.asSortedEventLog)(truthLocked.events);
|
|
109
|
+
if (lockedSortedResult.isErr()) {
|
|
110
|
+
return (0, neverthrow_1.errAsync)({
|
|
111
|
+
kind: 'invariant_violation',
|
|
112
|
+
message: `Locked session events are not sorted: ${lockedSortedResult.error.message}`,
|
|
113
|
+
});
|
|
114
|
+
}
|
|
115
|
+
const lockedIndex = (0, session_index_js_1.buildSessionIndex)(lockedSortedResult.value);
|
|
116
|
+
const existingLocked = lockedIndex.advanceRecordedByDedupeKey.get(dedupeKey);
|
|
99
117
|
if (existingLocked)
|
|
100
|
-
return (0, neverthrow_1.okAsync)({ kind: 'replay', truth: truthLocked, recordedEvent: existingLocked });
|
|
118
|
+
return (0, neverthrow_1.okAsync)({ kind: 'replay', truth: truthLocked, recordedEvent: existingLocked, precomputedIndex: lockedIndex });
|
|
101
119
|
return (0, advance_js_1.advanceAndRecord)({
|
|
102
120
|
truth: truthLocked,
|
|
103
121
|
sessionId,
|
|
@@ -114,9 +132,21 @@ function handleAdvanceIntent(args) {
|
|
|
114
132
|
sessionStore,
|
|
115
133
|
sha256,
|
|
116
134
|
idFactory,
|
|
135
|
+
lockedIndex,
|
|
117
136
|
}).andThen(() => sessionStore
|
|
118
137
|
.load(sessionId)
|
|
119
|
-
.
|
|
138
|
+
.andThen((truthAfter) => {
|
|
139
|
+
const afterSortedResult = (0, sorted_event_log_js_1.asSortedEventLog)(truthAfter.events);
|
|
140
|
+
if (afterSortedResult.isErr()) {
|
|
141
|
+
return (0, neverthrow_1.errAsync)({
|
|
142
|
+
kind: 'invariant_violation',
|
|
143
|
+
message: `Post-advance session events are not sorted: ${afterSortedResult.error.message}`,
|
|
144
|
+
});
|
|
145
|
+
}
|
|
146
|
+
const index2 = (0, session_index_js_1.buildSessionIndex)(afterSortedResult.value);
|
|
147
|
+
const recordedEvent = index2.advanceRecordedByDedupeKey.get(dedupeKey) ?? null;
|
|
148
|
+
return (0, neverthrow_1.okAsync)({ kind: 'replay', truth: truthAfter, recordedEvent, precomputedIndex: index2 });
|
|
149
|
+
}));
|
|
120
150
|
}))
|
|
121
151
|
.mapErr((cause) => {
|
|
122
152
|
if ((0, v2_error_mapping_js_1.isInternalError)(cause)) {
|
|
@@ -146,8 +176,7 @@ function handleAdvanceIntent(args) {
|
|
|
146
176
|
})
|
|
147
177
|
.andThen((res) => {
|
|
148
178
|
const truth2 = res.truth;
|
|
149
|
-
const recordedEvent = res.recordedEvent
|
|
150
|
-
truth2.events.find((e) => e.kind === constants_js_1.EVENT_KIND.ADVANCE_RECORDED && e.dedupeKey === dedupeKey);
|
|
179
|
+
const recordedEvent = res.recordedEvent;
|
|
151
180
|
if (!recordedEvent) {
|
|
152
181
|
return (0, neverthrow_1.errAsync)({
|
|
153
182
|
kind: 'invariant_violation',
|
|
@@ -157,6 +186,7 @@ function handleAdvanceIntent(args) {
|
|
|
157
186
|
return (0, replay_js_1.replayFromRecordedAdvance)({
|
|
158
187
|
recordedEvent,
|
|
159
188
|
truth: truth2,
|
|
189
|
+
precomputedIndex: res.precomputedIndex,
|
|
160
190
|
sessionId,
|
|
161
191
|
runId,
|
|
162
192
|
nodeId,
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { V2ContinueWorkflowInput } from '../../v2/tools.js';
|
|
2
|
-
import { V2ContinueWorkflowOutputSchema } from '../../output-schemas.js';
|
|
2
|
+
import type { V2ContinueWorkflowOutputSchema } from '../../output-schemas.js';
|
|
3
3
|
import { type SessionId, type RunId, type NodeId } from '../../../v2/durable-core/ids/index.js';
|
|
4
4
|
import type { LoadedSessionTruthV2 } from '../../../v2/ports/session-event-log-store.port.js';
|
|
5
5
|
import type { TokenCodecPorts } from '../../../v2/durable-core/tokens/token-codec-ports.js';
|
|
@@ -6,11 +6,10 @@ const binding_drift_js_1 = require("../../../v2/durable-core/domain/binding-drif
|
|
|
6
6
|
const binding_registry_js_1 = require("../../../application/services/compiler/binding-registry.js");
|
|
7
7
|
const v2_workspace_resolution_js_1 = require("../v2-workspace-resolution.js");
|
|
8
8
|
const snapshot_state_js_1 = require("../../../v2/durable-core/projections/snapshot-state.js");
|
|
9
|
-
const
|
|
9
|
+
const workflow_object_cache_js_1 = require("./workflow-object-cache.js");
|
|
10
10
|
const index_js_1 = require("../../../v2/durable-core/ids/index.js");
|
|
11
11
|
const workflow_hash_ref_js_1 = require("../../../v2/durable-core/ids/workflow-hash-ref.js");
|
|
12
12
|
const neverthrow_1 = require("neverthrow");
|
|
13
|
-
const workflow_source_js_1 = require("../../../types/workflow-source.js");
|
|
14
13
|
const workflow_definition_js_1 = require("../../../types/workflow-definition.js");
|
|
15
14
|
const v2_execution_helpers_js_1 = require("../v2-execution-helpers.js");
|
|
16
15
|
const prompt_renderer_js_1 = require("../../../v2/durable-core/domain/prompt-renderer.js");
|
|
@@ -19,6 +18,7 @@ const v2_state_conversion_js_1 = require("../v2-state-conversion.js");
|
|
|
19
18
|
const constants_js_1 = require("../../../v2/durable-core/constants.js");
|
|
20
19
|
const index_js_2 = require("./index.js");
|
|
21
20
|
const step_content_envelope_js_1 = require("../../step-content-envelope.js");
|
|
21
|
+
const assert_output_js_1 = require("../../assert-output.js");
|
|
22
22
|
function handleRehydrateIntent(args) {
|
|
23
23
|
const { input, sessionId, runId, nodeId, workflowHashRef, truth, tokenCodecPorts, pinnedStore, snapshotStore, idFactory, aliasStore, entropy, resolvedRootUris } = args;
|
|
24
24
|
const runStarted = truth.events.find((e) => e.kind === constants_js_1.EVENT_KIND.RUN_STARTED && e.scope.runId === String(runId));
|
|
@@ -93,15 +93,15 @@ function handleRehydrateIntent(args) {
|
|
|
93
93
|
if (!pending) {
|
|
94
94
|
const preferences = (0, v2_execution_helpers_js_1.derivePreferencesOrDefault)({ truth, runId, nodeId });
|
|
95
95
|
const nextIntent = (0, v2_state_conversion_js_1.deriveNextIntent)({ rehydrateOnly: true, isComplete, pending: null });
|
|
96
|
-
const parsed =
|
|
96
|
+
const parsed = (0, assert_output_js_1.assertOutput)({
|
|
97
97
|
kind: 'ok',
|
|
98
98
|
isComplete,
|
|
99
99
|
pending: null,
|
|
100
100
|
preferences,
|
|
101
101
|
nextIntent,
|
|
102
102
|
nextCall: null,
|
|
103
|
-
...(driftWarnings.length > 0 ? { warnings: driftWarnings } : {}),
|
|
104
|
-
});
|
|
103
|
+
...(driftWarnings.length > 0 ? { warnings: [...driftWarnings] } : {}),
|
|
104
|
+
}, assert_output_js_1.assertContinueTokenPresence);
|
|
105
105
|
return (0, neverthrow_1.okAsync)({ response: parsed });
|
|
106
106
|
}
|
|
107
107
|
const attemptId = (0, v2_token_ops_js_1.newAttemptId)(idFactory);
|
|
@@ -115,7 +115,7 @@ function handleRehydrateIntent(args) {
|
|
|
115
115
|
return (0, v2_token_ops_js_1.mintContinueAndCheckpointTokens)({ entry: entryBase, ports: tokenCodecPorts, aliasStore, entropy })
|
|
116
116
|
.mapErr((failure) => ({ kind: 'token_signing_failed', cause: failure }))
|
|
117
117
|
.andThen(({ continueToken: continueTokenValue, checkpointToken: checkpointTokenValue }) => {
|
|
118
|
-
const wf = (0,
|
|
118
|
+
const wf = (0, workflow_object_cache_js_1.getCachedWorkflow)(workflowHash, pinned.definition);
|
|
119
119
|
const metaRes = (0, prompt_renderer_js_1.renderPendingPrompt)({
|
|
120
120
|
workflow: wf,
|
|
121
121
|
stepId: String(pending.stepId),
|
|
@@ -138,7 +138,7 @@ function handleRehydrateIntent(args) {
|
|
|
138
138
|
meta,
|
|
139
139
|
references: pinned.resolvedReferences ?? buildPinnedReferencesFallback(pinned.definition.references ?? []),
|
|
140
140
|
});
|
|
141
|
-
const parsed =
|
|
141
|
+
const parsed = (0, assert_output_js_1.assertOutput)({
|
|
142
142
|
kind: 'ok',
|
|
143
143
|
continueToken: continueTokenValue,
|
|
144
144
|
checkpointToken: checkpointTokenValue,
|
|
@@ -147,8 +147,8 @@ function handleRehydrateIntent(args) {
|
|
|
147
147
|
preferences,
|
|
148
148
|
nextIntent,
|
|
149
149
|
nextCall: (0, index_js_2.buildNextCall)({ continueToken: continueTokenValue, isComplete, pending: meta }),
|
|
150
|
-
...(driftWarnings.length > 0 ? { warnings: driftWarnings } : {}),
|
|
151
|
-
});
|
|
150
|
+
...(driftWarnings.length > 0 ? { warnings: [...driftWarnings] } : {}),
|
|
151
|
+
}, assert_output_js_1.assertContinueTokenPresence);
|
|
152
152
|
return (0, neverthrow_1.okAsync)({ response: parsed, contentEnvelope });
|
|
153
153
|
});
|
|
154
154
|
});
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { V2ContinueWorkflowOutputSchema } from '../../output-schemas.js';
|
|
1
|
+
import type { V2ContinueWorkflowOutputSchema } from '../../output-schemas.js';
|
|
2
2
|
import type { ExecutionSnapshotFileV1 } from '../../../v2/durable-core/schemas/execution-snapshot/index.js';
|
|
3
3
|
import { type AttemptId } from '../../../v2/durable-core/tokens/index.js';
|
|
4
|
-
import {
|
|
4
|
+
import type { Workflow } from '../../../types/workflow.js';
|
|
5
5
|
import type { DomainEventV1 } from '../../../v2/durable-core/schemas/session/index.js';
|
|
6
6
|
import { type SessionId, type RunId, type NodeId, type WorkflowHash } from '../../../v2/durable-core/ids/index.js';
|
|
7
7
|
import type { LoadedSessionTruthV2 } from '../../../v2/ports/session-event-log-store.port.js';
|
|
@@ -17,13 +17,14 @@ export declare function buildAdvancedReplayResponse(args: {
|
|
|
17
17
|
readonly toNodeId: NodeId;
|
|
18
18
|
readonly attemptId: AttemptId;
|
|
19
19
|
readonly toSnapshot: ExecutionSnapshotFileV1;
|
|
20
|
-
readonly workflow:
|
|
20
|
+
readonly workflow: Workflow;
|
|
21
21
|
readonly truth: LoadedSessionTruthV2;
|
|
22
22
|
readonly workflowHash: WorkflowHash;
|
|
23
23
|
readonly ports: TokenCodecPorts;
|
|
24
24
|
readonly sha256: Sha256PortV2;
|
|
25
25
|
readonly aliasStore: import('../../../v2/ports/token-alias-store.port.js').TokenAliasStorePortV2;
|
|
26
26
|
readonly entropy: import('../../../v2/ports/random-entropy.port.js').RandomEntropyPortV2;
|
|
27
|
+
readonly precomputedIndex?: import('../../../v2/durable-core/session-index.js').SessionIndex;
|
|
27
28
|
}): RA<z.infer<typeof V2ContinueWorkflowOutputSchema>, ContinueWorkflowError>;
|
|
28
29
|
export declare function replayFromRecordedAdvance(args: {
|
|
29
30
|
readonly recordedEvent: Extract<DomainEventV1, {
|
|
@@ -35,10 +36,11 @@ export declare function replayFromRecordedAdvance(args: {
|
|
|
35
36
|
readonly nodeId: NodeId;
|
|
36
37
|
readonly workflowHash: WorkflowHash;
|
|
37
38
|
readonly attemptId: AttemptId;
|
|
38
|
-
readonly pinnedWorkflow:
|
|
39
|
+
readonly pinnedWorkflow: Workflow;
|
|
39
40
|
readonly snapshotStore: import('../../../v2/ports/snapshot-store.port.js').SnapshotStorePortV2;
|
|
40
41
|
readonly sha256: Sha256PortV2;
|
|
41
42
|
readonly tokenCodecPorts: TokenCodecPorts;
|
|
42
43
|
readonly aliasStore: import('../../../v2/ports/token-alias-store.port.js').TokenAliasStorePortV2;
|
|
43
44
|
readonly entropy: import('../../../v2/ports/random-entropy.port.js').RandomEntropyPortV2;
|
|
45
|
+
readonly precomputedIndex?: import('../../../v2/durable-core/session-index.js').SessionIndex;
|
|
44
46
|
}): RA<z.infer<typeof V2ContinueWorkflowOutputSchema>, ContinueWorkflowError>;
|
|
@@ -15,6 +15,8 @@ const v2_state_conversion_js_1 = require("../v2-state-conversion.js");
|
|
|
15
15
|
const constants_js_1 = require("../../../v2/durable-core/constants.js");
|
|
16
16
|
const index_js_2 = require("./index.js");
|
|
17
17
|
const assessments_js_1 = require("../../../v2/projections/assessments.js");
|
|
18
|
+
const assert_output_js_1 = require("../../assert-output.js");
|
|
19
|
+
const sorted_event_log_js_1 = require("../../../v2/durable-core/sorted-event-log.js");
|
|
18
20
|
function buildAdvancedReplayResponse(args) {
|
|
19
21
|
const { sessionId, runId, fromNodeId, toNodeId, attemptId, toSnapshot, workflow, truth, workflowHash, ports, sha256, aliasStore, entropy } = args;
|
|
20
22
|
const toNodeIdBranded = (0, index_js_1.asNodeId)(String(toNodeId));
|
|
@@ -75,29 +77,33 @@ function buildAdvancedReplayResponse(args) {
|
|
|
75
77
|
runId: (0, index_js_1.asRunId)(String(runId)),
|
|
76
78
|
nodeId: (0, index_js_1.asNodeId)(String(toNodeIdBranded)),
|
|
77
79
|
rehydrateOnly: false,
|
|
80
|
+
precomputedIndex: args.precomputedIndex,
|
|
78
81
|
});
|
|
79
82
|
if (result.isErr()) {
|
|
80
83
|
return (0, neverthrow_1.errAsync)({ kind: 'prompt_render_failed', message: result.error.message });
|
|
81
84
|
}
|
|
82
85
|
blockedMeta = result.value;
|
|
83
86
|
}
|
|
84
|
-
const preferences = (0, v2_execution_helpers_js_1.derivePreferencesOrDefault)({ truth, runId, nodeId: toNodeIdBranded });
|
|
87
|
+
const preferences = (0, v2_execution_helpers_js_1.derivePreferencesOrDefault)({ truth, runId, nodeId: toNodeIdBranded, precomputedIndex: args.precomputedIndex });
|
|
85
88
|
const nextIntent = (0, v2_state_conversion_js_1.deriveNextIntent)({ rehydrateOnly: false, isComplete, pending: blockedMeta });
|
|
86
|
-
return nextTokensMint.andThen((nextTokens) => retryContinueMint.andThen((retryContinueToken) =>
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
89
|
+
return nextTokensMint.andThen((nextTokens) => retryContinueMint.andThen((retryContinueToken) => {
|
|
90
|
+
const out = (0, assert_output_js_1.assertOutput)({
|
|
91
|
+
kind: 'blocked',
|
|
92
|
+
continueToken: pending ? nextTokens.continueToken : undefined,
|
|
93
|
+
checkpointToken: pending ? nextTokens.checkpointToken : undefined,
|
|
94
|
+
isComplete,
|
|
95
|
+
pending: (0, output_schemas_js_1.toPendingStep)(blockedMeta),
|
|
96
|
+
preferences,
|
|
97
|
+
nextIntent,
|
|
98
|
+
nextCall: (0, index_js_2.buildNextCall)({ continueToken: pending ? nextTokens.continueToken : undefined, isComplete, pending: blockedMeta, retryContinueToken }),
|
|
99
|
+
blockers,
|
|
100
|
+
retryable,
|
|
101
|
+
retryContinueToken,
|
|
102
|
+
validation,
|
|
103
|
+
assessmentFollowup,
|
|
104
|
+
}, assert_output_js_1.assertContinueTokenPresence);
|
|
105
|
+
return (0, neverthrow_1.okAsync)(out);
|
|
106
|
+
}));
|
|
101
107
|
}
|
|
102
108
|
let okMeta = null;
|
|
103
109
|
if (pending) {
|
|
@@ -109,29 +115,38 @@ function buildAdvancedReplayResponse(args) {
|
|
|
109
115
|
runId: (0, index_js_1.asRunId)(String(runId)),
|
|
110
116
|
nodeId: (0, index_js_1.asNodeId)(String(toNodeIdBranded)),
|
|
111
117
|
rehydrateOnly: false,
|
|
118
|
+
precomputedIndex: args.precomputedIndex,
|
|
112
119
|
});
|
|
113
120
|
if (result.isErr()) {
|
|
114
121
|
return (0, neverthrow_1.errAsync)({ kind: 'prompt_render_failed', message: result.error.message });
|
|
115
122
|
}
|
|
116
123
|
okMeta = result.value;
|
|
117
124
|
}
|
|
118
|
-
const preferences = (0, v2_execution_helpers_js_1.derivePreferencesOrDefault)({ truth, runId, nodeId: toNodeIdBranded });
|
|
125
|
+
const preferences = (0, v2_execution_helpers_js_1.derivePreferencesOrDefault)({ truth, runId, nodeId: toNodeIdBranded, precomputedIndex: args.precomputedIndex });
|
|
119
126
|
const nextIntent = (0, v2_state_conversion_js_1.deriveNextIntent)({ rehydrateOnly: false, isComplete, pending: okMeta });
|
|
120
127
|
const stepContext = buildStepContext(truth.events, fromNodeId);
|
|
121
|
-
return nextTokensMint.andThen((nextTokens) =>
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
128
|
+
return nextTokensMint.andThen((nextTokens) => {
|
|
129
|
+
const out = (0, assert_output_js_1.assertOutput)({
|
|
130
|
+
kind: 'ok',
|
|
131
|
+
continueToken: pending ? nextTokens.continueToken : undefined,
|
|
132
|
+
checkpointToken: pending ? nextTokens.checkpointToken : undefined,
|
|
133
|
+
isComplete,
|
|
134
|
+
pending: (0, output_schemas_js_1.toPendingStep)(okMeta),
|
|
135
|
+
preferences,
|
|
136
|
+
nextIntent,
|
|
137
|
+
nextCall: (0, index_js_2.buildNextCall)({ continueToken: pending ? nextTokens.continueToken : undefined, isComplete, pending: okMeta }),
|
|
138
|
+
stepContext,
|
|
139
|
+
}, assert_output_js_1.assertContinueTokenPresence);
|
|
140
|
+
return (0, neverthrow_1.okAsync)(out);
|
|
141
|
+
});
|
|
132
142
|
}
|
|
133
143
|
function buildStepContext(events, completedNodeId) {
|
|
134
|
-
const
|
|
144
|
+
const sortedEventsRes = (0, sorted_event_log_js_1.asSortedEventLog)(events);
|
|
145
|
+
if (sortedEventsRes.isErr()) {
|
|
146
|
+
console.warn(`[workrail:replay] stepContext events unsorted for node '${String(completedNodeId)}' — stepContext will be absent: ${sortedEventsRes.error.message}`);
|
|
147
|
+
return undefined;
|
|
148
|
+
}
|
|
149
|
+
const projection = (0, assessments_js_1.projectAssessmentsV2)(sortedEventsRes.value);
|
|
135
150
|
if (projection.isErr()) {
|
|
136
151
|
console.warn(`[workrail:replay] stepContext projection failed for node '${String(completedNodeId)}' — stepContext will be absent: ${projection.error.message}`);
|
|
137
152
|
return undefined;
|
|
@@ -160,7 +175,8 @@ function replayFromRecordedAdvance(args) {
|
|
|
160
175
|
});
|
|
161
176
|
}
|
|
162
177
|
const toNodeId = (0, index_js_1.asNodeId)(String(recordedEvent.data.outcome.toNodeId));
|
|
163
|
-
const toNode =
|
|
178
|
+
const toNode = args.precomputedIndex?.nodeCreatedByNodeId.get(String(toNodeId))
|
|
179
|
+
?? truth.events.find((e) => e.kind === constants_js_1.EVENT_KIND.NODE_CREATED && e.scope?.nodeId === String(toNodeId));
|
|
164
180
|
if (!toNode) {
|
|
165
181
|
return (0, neverthrow_1.errAsync)({
|
|
166
182
|
kind: 'invariant_violation',
|
|
@@ -191,6 +207,7 @@ function replayFromRecordedAdvance(args) {
|
|
|
191
207
|
sha256,
|
|
192
208
|
aliasStore,
|
|
193
209
|
entropy,
|
|
210
|
+
precomputedIndex: args.precomputedIndex,
|
|
194
211
|
});
|
|
195
212
|
});
|
|
196
213
|
}
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import type { V2ToolContext } from '../../types.js';
|
|
2
|
-
import { V2StartWorkflowOutputSchema } from '../../output-schemas.js';
|
|
3
|
-
import { createWorkflow } from '../../../types/workflow.js';
|
|
2
|
+
import type { V2StartWorkflowOutputSchema } from '../../output-schemas.js';
|
|
4
3
|
import type { DomainEventV1 } from '../../../v2/durable-core/schemas/session/index.js';
|
|
5
4
|
import { type SessionId, type RunId, type NodeId, type WorkflowHash } from '../../../v2/durable-core/ids/index.js';
|
|
6
5
|
import type { Sha256PortV2 } from '../../../v2/ports/sha256.port.js';
|
|
@@ -26,7 +25,7 @@ export declare function loadAndPinWorkflow(args: {
|
|
|
26
25
|
}): RA<{
|
|
27
26
|
readonly workflow: import('../../../types/workflow.js').Workflow;
|
|
28
27
|
readonly workflowHash: WorkflowHash;
|
|
29
|
-
readonly pinnedWorkflow:
|
|
28
|
+
readonly pinnedWorkflow: import('../../../types/workflow.js').Workflow;
|
|
30
29
|
readonly firstStep: {
|
|
31
30
|
readonly id: string;
|
|
32
31
|
};
|
|
@@ -6,15 +6,14 @@ exports.mintStartTokens = mintStartTokens;
|
|
|
6
6
|
exports.executeStartWorkflow = executeStartWorkflow;
|
|
7
7
|
const output_schemas_js_1 = require("../../output-schemas.js");
|
|
8
8
|
const step_instance_key_js_1 = require("../../../v2/durable-core/schemas/execution-snapshot/step-instance-key.js");
|
|
9
|
-
const workflow_js_1 = require("../../../types/workflow.js");
|
|
10
9
|
const index_js_1 = require("../../../v2/durable-core/ids/index.js");
|
|
11
10
|
const workflow_hash_ref_js_1 = require("../../../v2/durable-core/ids/workflow-hash-ref.js");
|
|
12
11
|
const neverthrow_1 = require("neverthrow");
|
|
13
12
|
const workflow_validation_pipeline_js_1 = require("../../../application/services/workflow-validation-pipeline.js");
|
|
14
13
|
const hashing_js_1 = require("../../../v2/durable-core/canonical/hashing.js");
|
|
15
14
|
const observation_builder_js_1 = require("../../../v2/durable-core/domain/observation-builder.js");
|
|
16
|
-
const workflow_source_js_1 = require("../../../types/workflow-source.js");
|
|
17
15
|
const workflow_definition_js_1 = require("../../../types/workflow-definition.js");
|
|
16
|
+
const workflow_object_cache_js_1 = require("./workflow-object-cache.js");
|
|
18
17
|
const prompt_renderer_js_1 = require("../../../v2/durable-core/domain/prompt-renderer.js");
|
|
19
18
|
const v2_workspace_resolution_js_1 = require("../v2-workspace-resolution.js");
|
|
20
19
|
const v2_token_ops_js_1 = require("../v2-token-ops.js");
|
|
@@ -73,13 +72,13 @@ function loadAndPinWorkflow(args) {
|
|
|
73
72
|
return pinnedStore.get(workflowHash)
|
|
74
73
|
.mapErr((cause) => ({ kind: 'pinned_workflow_store_failed', cause }))
|
|
75
74
|
.andThen((existingPinned) => {
|
|
76
|
-
if (
|
|
77
|
-
return
|
|
78
|
-
.mapErr((cause) => ({ kind: 'pinned_workflow_store_failed', cause }));
|
|
75
|
+
if (existingPinned) {
|
|
76
|
+
return (0, neverthrow_1.okAsync)(existingPinned);
|
|
79
77
|
}
|
|
80
|
-
return (
|
|
78
|
+
return pinnedStore.put(workflowHash, enrichedCompiled)
|
|
79
|
+
.mapErr((cause) => ({ kind: 'pinned_workflow_store_failed', cause }))
|
|
80
|
+
.andThen(() => pinnedStore.get(workflowHash).mapErr((cause) => ({ kind: 'pinned_workflow_store_failed', cause })));
|
|
81
81
|
})
|
|
82
|
-
.andThen(() => pinnedStore.get(workflowHash).mapErr((cause) => ({ kind: 'pinned_workflow_store_failed', cause })))
|
|
83
82
|
.andThen((pinned) => {
|
|
84
83
|
if (!pinned || pinned.sourceKind !== 'v1_pinned' || !(0, workflow_definition_js_1.hasWorkflowDefinitionShape)(pinned.definition)) {
|
|
85
84
|
return (0, neverthrow_1.errAsync)({
|
|
@@ -87,7 +86,7 @@ function loadAndPinWorkflow(args) {
|
|
|
87
86
|
message: 'Failed to pin executable workflow snapshot (missing or invalid pinned workflow).',
|
|
88
87
|
});
|
|
89
88
|
}
|
|
90
|
-
const pinnedWorkflow = (0,
|
|
89
|
+
const pinnedWorkflow = (0, workflow_object_cache_js_1.getCachedWorkflow)(workflowHash, pinned.definition);
|
|
91
90
|
const resolution = (0, start_construction_js_1.resolveFirstStep)(workflow, pinned);
|
|
92
91
|
if (resolution.isErr()) {
|
|
93
92
|
const error = resolution.error.reason === 'no_steps'
|
|
@@ -309,10 +308,11 @@ function executeStartWorkflow(input, ctx) {
|
|
|
309
308
|
idFactory,
|
|
310
309
|
goal: input.goal,
|
|
311
310
|
});
|
|
311
|
+
const emptyTruth = { manifest: [], events: [] };
|
|
312
312
|
return gate.withHealthySessionLock(sessionId, (lock) => sessionStore.append(lock, {
|
|
313
313
|
events,
|
|
314
314
|
snapshotPins: [{ snapshotRef, eventIndex: 2, createdByEventId: events[2].eventId }],
|
|
315
|
-
}))
|
|
315
|
+
}, emptyTruth))
|
|
316
316
|
.mapErr((cause) => ({ kind: 'session_append_failed', cause }))
|
|
317
317
|
.map(() => ({ workflow, firstStep, workflowHash, pinnedWorkflow, resolvedReferences, sessionId, runId, nodeId }));
|
|
318
318
|
});
|
|
@@ -361,7 +361,7 @@ function executeStartWorkflow(input, ctx) {
|
|
|
361
361
|
meta,
|
|
362
362
|
references: resolvedReferences,
|
|
363
363
|
});
|
|
364
|
-
const parsed =
|
|
364
|
+
const parsed = {
|
|
365
365
|
continueToken: tokens.continueToken,
|
|
366
366
|
checkpointToken: tokens.checkpointToken,
|
|
367
367
|
isComplete: false,
|
|
@@ -370,7 +370,7 @@ function executeStartWorkflow(input, ctx) {
|
|
|
370
370
|
nextIntent,
|
|
371
371
|
nextCall: (0, index_js_2.buildNextCall)({ continueToken: tokens.continueToken, isComplete: false, pending }),
|
|
372
372
|
...(stalePaths.length > 0 ? { staleRoots: [...stalePaths] } : {}),
|
|
373
|
-
}
|
|
373
|
+
};
|
|
374
374
|
return (0, neverthrow_1.okAsync)({ response: parsed, contentEnvelope });
|
|
375
375
|
});
|
|
376
376
|
}));
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import type { WorkflowDefinition } from '../../../types/workflow-definition.js';
|
|
2
|
+
import type { Workflow } from '../../../types/workflow.js';
|
|
3
|
+
import type { WorkflowHash } from '../../../v2/durable-core/ids/index.js';
|
|
4
|
+
export declare function getCachedWorkflow(workflowHash: WorkflowHash, definition: WorkflowDefinition): Workflow;
|
|
5
|
+
export declare function clearWorkflowObjectCacheForTesting(): void;
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.getCachedWorkflow = getCachedWorkflow;
|
|
4
|
+
exports.clearWorkflowObjectCacheForTesting = clearWorkflowObjectCacheForTesting;
|
|
5
|
+
const workflow_js_1 = require("../../../types/workflow.js");
|
|
6
|
+
const workflow_source_js_1 = require("../../../types/workflow-source.js");
|
|
7
|
+
const _cache = new Map();
|
|
8
|
+
function getCachedWorkflow(workflowHash, definition) {
|
|
9
|
+
const key = String(workflowHash);
|
|
10
|
+
const existing = _cache.get(key);
|
|
11
|
+
if (existing !== undefined)
|
|
12
|
+
return existing;
|
|
13
|
+
const wf = (0, workflow_js_1.createWorkflow)(definition, (0, workflow_source_js_1.createBundledSource)());
|
|
14
|
+
_cache.set(key, wf);
|
|
15
|
+
return wf;
|
|
16
|
+
}
|
|
17
|
+
function clearWorkflowObjectCacheForTesting() {
|
|
18
|
+
_cache.clear();
|
|
19
|
+
}
|
|
@@ -120,4 +120,5 @@ export declare function derivePreferencesOrDefault(args: {
|
|
|
120
120
|
readonly truth: LoadedSessionTruthV2;
|
|
121
121
|
readonly runId: RunId;
|
|
122
122
|
readonly nodeId: NodeId;
|
|
123
|
+
readonly precomputedIndex?: import('../../v2/durable-core/session-index.js').SessionIndex;
|
|
123
124
|
}): PreferencesV2;
|
|
@@ -266,20 +266,36 @@ function mapSessionOrGateErrorToToolError(e) {
|
|
|
266
266
|
}
|
|
267
267
|
const constants_js_1 = require("../../v2/durable-core/constants.js");
|
|
268
268
|
const preferences_js_1 = require("../../v2/projections/preferences.js");
|
|
269
|
+
const sorted_event_log_js_1 = require("../../v2/durable-core/sorted-event-log.js");
|
|
269
270
|
exports.defaultPreferences = {
|
|
270
271
|
autonomy: 'guided',
|
|
271
272
|
riskPolicy: 'conservative'
|
|
272
273
|
};
|
|
273
274
|
function derivePreferencesOrDefault(args) {
|
|
275
|
+
let sortedEventsForPrefs;
|
|
274
276
|
const parentByNodeId = {};
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
277
|
+
if (args.precomputedIndex) {
|
|
278
|
+
sortedEventsForPrefs = args.precomputedIndex.sortedEvents;
|
|
279
|
+
for (const [nodeId, evt] of args.precomputedIndex.nodeCreatedByNodeId) {
|
|
280
|
+
if (evt.scope.runId === String(args.runId)) {
|
|
281
|
+
parentByNodeId[nodeId] = evt.data.parentNodeId ?? null;
|
|
282
|
+
}
|
|
283
|
+
}
|
|
284
|
+
}
|
|
285
|
+
else {
|
|
286
|
+
for (const e of args.truth.events) {
|
|
287
|
+
if (e.kind !== constants_js_1.EVENT_KIND.NODE_CREATED)
|
|
288
|
+
continue;
|
|
289
|
+
if (e.scope?.runId !== String(args.runId))
|
|
290
|
+
continue;
|
|
291
|
+
parentByNodeId[String(e.scope.nodeId)] = e.data.parentNodeId;
|
|
292
|
+
}
|
|
293
|
+
const sortedEventsRes = (0, sorted_event_log_js_1.asSortedEventLog)(args.truth.events);
|
|
294
|
+
if (sortedEventsRes.isErr())
|
|
295
|
+
return exports.defaultPreferences;
|
|
296
|
+
sortedEventsForPrefs = sortedEventsRes.value;
|
|
281
297
|
}
|
|
282
|
-
const prefs = (0, preferences_js_1.projectPreferencesV2)(
|
|
298
|
+
const prefs = (0, preferences_js_1.projectPreferencesV2)(sortedEventsForPrefs, parentByNodeId);
|
|
283
299
|
if (prefs.isErr())
|
|
284
300
|
return exports.defaultPreferences;
|
|
285
301
|
const p = prefs.value.byNodeId[String(args.nodeId)]?.effective;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type { z } from 'zod';
|
|
2
2
|
import type { V2ResumeSessionInput } from '../v2/tools.js';
|
|
3
3
|
import type { ToolContext, ToolResult } from '../types.js';
|
|
4
|
-
import { V2ResumeSessionOutputSchema } from '../output-schemas.js';
|
|
4
|
+
import type { V2ResumeSessionOutputSchema } from '../output-schemas.js';
|
|
5
5
|
type ResumeInput = z.infer<typeof V2ResumeSessionInput>;
|
|
6
6
|
type ResumeOutput = z.infer<typeof V2ResumeSessionOutputSchema>;
|
|
7
7
|
export declare function handleV2ResumeSession(input: ResumeInput, ctx: ToolContext): Promise<ToolResult<ResumeOutput>>;
|
|
@@ -2,7 +2,6 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.handleV2ResumeSession = handleV2ResumeSession;
|
|
4
4
|
const types_js_1 = require("../types.js");
|
|
5
|
-
const output_schemas_js_1 = require("../output-schemas.js");
|
|
6
5
|
const v2_token_ops_js_1 = require("./v2-token-ops.js");
|
|
7
6
|
const index_js_1 = require("../../v2/durable-core/ids/index.js");
|
|
8
7
|
const resume_session_js_1 = require("../../v2/usecases/resume-session.js");
|
|
@@ -43,10 +42,10 @@ async function handleV2ResumeSession(input, ctx) {
|
|
|
43
42
|
if (skipped > 0) {
|
|
44
43
|
console.error(`[workrail:resume] ${skipped}/${candidates.length} candidate(s) skipped: token minting failed (workflowHashRef derivation or signing error)`);
|
|
45
44
|
}
|
|
46
|
-
const output =
|
|
47
|
-
candidates: outputCandidates,
|
|
45
|
+
const output = {
|
|
46
|
+
candidates: [...outputCandidates],
|
|
48
47
|
totalEligible: totalFound,
|
|
49
|
-
}
|
|
48
|
+
};
|
|
50
49
|
return {
|
|
51
50
|
type: 'success',
|
|
52
51
|
data: output,
|
|
@@ -9,6 +9,7 @@ exports.derivePreferencesForNode = derivePreferencesForNode;
|
|
|
9
9
|
exports.deriveNextIntent = deriveNextIntent;
|
|
10
10
|
const step_instance_key_js_1 = require("../../v2/durable-core/schemas/execution-snapshot/step-instance-key.js");
|
|
11
11
|
const preferences_js_1 = require("../../v2/projections/preferences.js");
|
|
12
|
+
const sorted_event_log_js_1 = require("../../v2/durable-core/sorted-event-log.js");
|
|
12
13
|
const constants_js_1 = require("../../v2/durable-core/constants.js");
|
|
13
14
|
function toV1ExecutionState(engineState) {
|
|
14
15
|
if (engineState.kind === 'init')
|
|
@@ -94,7 +95,10 @@ function derivePreferencesForNode(args) {
|
|
|
94
95
|
continue;
|
|
95
96
|
parentByNodeId[String(e.scope.nodeId)] = e.data.parentNodeId;
|
|
96
97
|
}
|
|
97
|
-
const
|
|
98
|
+
const sortedEventsRes = (0, sorted_event_log_js_1.asSortedEventLog)(args.truth.events);
|
|
99
|
+
if (sortedEventsRes.isErr())
|
|
100
|
+
return exports.defaultPreferences;
|
|
101
|
+
const prefs = (0, preferences_js_1.projectPreferencesV2)(sortedEventsRes.value, parentByNodeId);
|
|
98
102
|
if (prefs.isErr())
|
|
99
103
|
return exports.defaultPreferences;
|
|
100
104
|
const p = prefs.value.byNodeId[String(args.nodeId)]?.effective;
|