@exaudeus/workrail 2.1.0 → 3.1.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/compiler/resolve-templates.d.ts +5 -0
- package/dist/application/services/compiler/resolve-templates.js +35 -0
- package/dist/application/services/compiler/routine-loader.d.ts +11 -0
- package/dist/application/services/compiler/routine-loader.js +45 -0
- package/dist/application/services/compiler/template-registry.d.ts +4 -2
- package/dist/application/services/compiler/template-registry.js +105 -4
- package/dist/application/services/workflow-compiler.js +34 -3
- package/dist/di/container.js +10 -1
- package/dist/di/tokens.d.ts +1 -0
- package/dist/di/tokens.js +1 -0
- package/dist/engine/engine-factory.d.ts +3 -0
- package/dist/engine/engine-factory.js +295 -0
- package/dist/engine/index.d.ts +3 -0
- package/dist/engine/index.js +12 -0
- package/dist/engine/types.d.ts +130 -0
- package/dist/engine/types.js +18 -0
- package/dist/manifest.json +146 -74
- package/dist/mcp/handlers/v2-checkpoint.d.ts +31 -1
- package/dist/mcp/handlers/v2-checkpoint.js +76 -64
- package/dist/mcp/handlers/v2-execution/continue-advance.d.ts +2 -0
- package/dist/mcp/handlers/v2-execution/continue-advance.js +5 -5
- package/dist/mcp/handlers/v2-execution/continue-rehydrate.d.ts +2 -0
- package/dist/mcp/handlers/v2-execution/continue-rehydrate.js +17 -22
- package/dist/mcp/handlers/v2-execution/index.d.ts +10 -17
- package/dist/mcp/handlers/v2-execution/index.js +44 -54
- package/dist/mcp/handlers/v2-execution/replay.d.ts +4 -15
- package/dist/mcp/handlers/v2-execution/replay.js +52 -128
- package/dist/mcp/handlers/v2-execution/start.d.ts +3 -2
- package/dist/mcp/handlers/v2-execution/start.js +18 -46
- package/dist/mcp/handlers/v2-token-ops.d.ts +45 -24
- package/dist/mcp/handlers/v2-token-ops.js +372 -32
- package/dist/mcp/output-schemas.d.ts +104 -283
- package/dist/mcp/output-schemas.js +24 -22
- package/dist/mcp/server.js +8 -0
- package/dist/mcp/types.d.ts +4 -0
- package/dist/mcp/v2/tools.d.ts +22 -52
- package/dist/mcp/v2/tools.js +18 -32
- package/dist/mcp/v2-response-formatter.js +12 -16
- package/dist/runtime/runtime-mode.d.ts +2 -0
- package/dist/v2/durable-core/domain/prompt-renderer.d.ts +1 -0
- package/dist/v2/durable-core/domain/prompt-renderer.js +5 -3
- package/dist/v2/durable-core/schemas/export-bundle/index.d.ts +14 -14
- package/dist/v2/durable-core/schemas/session/events.d.ts +4 -4
- package/dist/v2/durable-core/schemas/session/validation-event.d.ts +2 -2
- package/dist/v2/durable-core/tokens/payloads.d.ts +32 -32
- package/dist/v2/durable-core/tokens/short-token.d.ts +38 -0
- package/dist/v2/durable-core/tokens/short-token.js +126 -0
- package/dist/v2/durable-core/tokens/token-patterns.d.ts +4 -0
- package/dist/v2/durable-core/tokens/token-patterns.js +9 -0
- package/dist/v2/infra/in-memory/token-alias-store/index.d.ts +11 -0
- package/dist/v2/infra/in-memory/token-alias-store/index.js +38 -0
- package/dist/v2/infra/local/data-dir/index.d.ts +1 -0
- package/dist/v2/infra/local/data-dir/index.js +3 -0
- package/dist/v2/infra/local/token-alias-store/index.d.ts +16 -0
- package/dist/v2/infra/local/token-alias-store/index.js +117 -0
- package/dist/v2/ports/data-dir.port.d.ts +1 -0
- package/dist/v2/ports/token-alias-store.port.d.ts +33 -0
- package/dist/v2/ports/token-alias-store.port.js +2 -0
- package/package.json +8 -1
- package/workflows/coding-task-workflow-agentic.lean.v2.json +41 -3
- package/workflows/examples/routine-injection-example.json +28 -0
|
@@ -1,8 +1,10 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.OpenDashboardOutputSchema = exports.ReadSessionSchemaOutputSchema = exports.ReadSessionOutputSchema = exports.UpdateSessionOutputSchema = exports.CreateSessionOutputSchema = exports.V2StartWorkflowOutputSchema = exports.V2CheckpointWorkflowOutputSchema = exports.V2ResumeSessionOutputSchema = exports.V2ContinueWorkflowOutputSchema = exports.V2BlockerReportSchema = exports.V2NextCallSchema = exports.V2NextIntentSchema = exports.V2PreferencesSchema = exports.V2PendingStepSchema = exports.V2WorkflowInspectOutputSchema = exports.V2WorkflowListOutputSchema = exports.V2WorkflowListItemSchema = exports.WorkflowGetSchemaOutputSchema = exports.WorkflowValidateJsonOutputSchema = exports.WorkflowNextOutputSchema = exports.WorkflowGetOutputSchema = exports.WorkflowListOutputSchema = exports.WorkflowSummarySchema = exports.JsonValueSchema = void 0;
|
|
4
|
+
exports.toPendingStep = toPendingStep;
|
|
4
5
|
const zod_1 = require("zod");
|
|
5
6
|
const state_js_1 = require("../domain/execution/state.js");
|
|
7
|
+
const token_patterns_js_1 = require("../v2/durable-core/tokens/token-patterns.js");
|
|
6
8
|
const JsonPrimitiveSchema = zod_1.z.union([zod_1.z.string(), zod_1.z.number(), zod_1.z.boolean(), zod_1.z.null()]);
|
|
7
9
|
exports.JsonValueSchema = zod_1.z.lazy(() => zod_1.z.union([JsonPrimitiveSchema, zod_1.z.array(exports.JsonValueSchema), zod_1.z.record(exports.JsonValueSchema)]));
|
|
8
10
|
exports.WorkflowSummarySchema = zod_1.z.object({
|
|
@@ -66,7 +68,18 @@ exports.V2PendingStepSchema = zod_1.z.object({
|
|
|
66
68
|
stepId: zod_1.z.string().min(1),
|
|
67
69
|
title: zod_1.z.string().min(1),
|
|
68
70
|
prompt: zod_1.z.string().min(1),
|
|
71
|
+
agentRole: zod_1.z.string().min(1).optional(),
|
|
69
72
|
});
|
|
73
|
+
function toPendingStep(meta) {
|
|
74
|
+
if (!meta)
|
|
75
|
+
return null;
|
|
76
|
+
return {
|
|
77
|
+
stepId: meta.stepId,
|
|
78
|
+
title: meta.title,
|
|
79
|
+
prompt: meta.prompt,
|
|
80
|
+
...(meta.agentRole ? { agentRole: meta.agentRole } : {}),
|
|
81
|
+
};
|
|
82
|
+
}
|
|
70
83
|
exports.V2PreferencesSchema = zod_1.z.object({
|
|
71
84
|
autonomy: zod_1.z.enum(['guided', 'full_auto_stop_on_user_deps', 'full_auto_never_stop']),
|
|
72
85
|
riskPolicy: zod_1.z.enum(['conservative', 'balanced', 'aggressive']),
|
|
@@ -77,18 +90,9 @@ exports.V2NextIntentSchema = zod_1.z.enum([
|
|
|
77
90
|
'rehydrate_only',
|
|
78
91
|
'complete',
|
|
79
92
|
]);
|
|
80
|
-
const V2NextCallAdvanceParams = zod_1.z.object({
|
|
81
|
-
intent: zod_1.z.literal('advance'),
|
|
82
|
-
stateToken: zod_1.z.string().min(1),
|
|
83
|
-
ackToken: zod_1.z.string().min(1),
|
|
84
|
-
});
|
|
85
|
-
const V2NextCallRehydrateParams = zod_1.z.object({
|
|
86
|
-
intent: zod_1.z.literal('rehydrate'),
|
|
87
|
-
stateToken: zod_1.z.string().min(1),
|
|
88
|
-
});
|
|
89
93
|
exports.V2NextCallSchema = zod_1.z.object({
|
|
90
94
|
tool: zod_1.z.literal('continue_workflow'),
|
|
91
|
-
params: zod_1.z.
|
|
95
|
+
params: zod_1.z.object({ continueToken: zod_1.z.string().min(1) }),
|
|
92
96
|
}).nullable();
|
|
93
97
|
function utf8ByteLength(s) {
|
|
94
98
|
return new TextEncoder().encode(s).length;
|
|
@@ -176,11 +180,11 @@ exports.V2BlockerReportSchema = zod_1.z
|
|
|
176
180
|
}
|
|
177
181
|
}
|
|
178
182
|
});
|
|
179
|
-
const checkpointTokenSchema = zod_1.z.string().regex(
|
|
183
|
+
const checkpointTokenSchema = zod_1.z.string().regex(token_patterns_js_1.CHECKPOINT_TOKEN_PATTERN, 'Invalid checkpointToken format').optional();
|
|
184
|
+
const continueTokenSchema = zod_1.z.string().regex(token_patterns_js_1.CONTINUE_TOKEN_PATTERN, 'Invalid continueToken format').optional();
|
|
180
185
|
const V2ContinueWorkflowOkSchema = zod_1.z.object({
|
|
181
186
|
kind: zod_1.z.literal('ok'),
|
|
182
|
-
|
|
183
|
-
ackToken: zod_1.z.string().regex(/^ack1[023456789acdefghjklmnpqrstuvwxyz]+$/, 'Invalid ackToken format').optional(),
|
|
187
|
+
continueToken: continueTokenSchema,
|
|
184
188
|
checkpointToken: checkpointTokenSchema,
|
|
185
189
|
isComplete: zod_1.z.boolean(),
|
|
186
190
|
pending: exports.V2PendingStepSchema.nullable(),
|
|
@@ -190,8 +194,7 @@ const V2ContinueWorkflowOkSchema = zod_1.z.object({
|
|
|
190
194
|
});
|
|
191
195
|
const V2ContinueWorkflowBlockedSchema = zod_1.z.object({
|
|
192
196
|
kind: zod_1.z.literal('blocked'),
|
|
193
|
-
|
|
194
|
-
ackToken: zod_1.z.string().regex(/^ack1[023456789acdefghjklmnpqrstuvwxyz]+$/, 'Invalid ackToken format').optional(),
|
|
197
|
+
continueToken: continueTokenSchema,
|
|
195
198
|
checkpointToken: checkpointTokenSchema,
|
|
196
199
|
isComplete: zod_1.z.boolean(),
|
|
197
200
|
pending: exports.V2PendingStepSchema.nullable(),
|
|
@@ -200,7 +203,7 @@ const V2ContinueWorkflowBlockedSchema = zod_1.z.object({
|
|
|
200
203
|
nextCall: exports.V2NextCallSchema,
|
|
201
204
|
blockers: exports.V2BlockerReportSchema,
|
|
202
205
|
retryable: zod_1.z.boolean().optional(),
|
|
203
|
-
|
|
206
|
+
retryContinueToken: zod_1.z.string().optional(),
|
|
204
207
|
validation: zod_1.z
|
|
205
208
|
.object({
|
|
206
209
|
issues: zod_1.z.array(zod_1.z.string()),
|
|
@@ -211,12 +214,12 @@ const V2ContinueWorkflowBlockedSchema = zod_1.z.object({
|
|
|
211
214
|
exports.V2ContinueWorkflowOutputSchema = zod_1.z.discriminatedUnion('kind', [
|
|
212
215
|
V2ContinueWorkflowOkSchema,
|
|
213
216
|
V2ContinueWorkflowBlockedSchema,
|
|
214
|
-
]).refine((data) => (data.pending ? data.
|
|
217
|
+
]).refine((data) => (data.pending ? data.continueToken != null : true), { message: 'continueToken is required when a pending step exists' });
|
|
215
218
|
exports.V2ResumeSessionOutputSchema = zod_1.z.object({
|
|
216
219
|
candidates: zod_1.z.array(zod_1.z.object({
|
|
217
220
|
sessionId: zod_1.z.string().min(1),
|
|
218
221
|
runId: zod_1.z.string().min(1),
|
|
219
|
-
stateToken: zod_1.z.string().regex(
|
|
222
|
+
stateToken: zod_1.z.string().regex(token_patterns_js_1.STATE_TOKEN_PATTERN, 'Invalid stateToken format'),
|
|
220
223
|
snippet: zod_1.z.string().max(1024),
|
|
221
224
|
whyMatched: zod_1.z.array(zod_1.z.enum([
|
|
222
225
|
'matched_head_sha',
|
|
@@ -230,20 +233,19 @@ exports.V2ResumeSessionOutputSchema = zod_1.z.object({
|
|
|
230
233
|
});
|
|
231
234
|
exports.V2CheckpointWorkflowOutputSchema = zod_1.z.object({
|
|
232
235
|
checkpointNodeId: zod_1.z.string().min(1),
|
|
233
|
-
stateToken: zod_1.z.string().regex(
|
|
236
|
+
stateToken: zod_1.z.string().regex(token_patterns_js_1.STATE_TOKEN_PATTERN, 'Invalid stateToken format'),
|
|
234
237
|
nextCall: exports.V2NextCallSchema.describe('Pre-built template for your next continue_workflow call. ' +
|
|
235
238
|
'After checkpoint, use this to rehydrate and continue working on the current step.'),
|
|
236
239
|
});
|
|
237
240
|
exports.V2StartWorkflowOutputSchema = zod_1.z.object({
|
|
238
|
-
|
|
239
|
-
ackToken: zod_1.z.string().regex(/^ack1[023456789acdefghjklmnpqrstuvwxyz]+$/, 'Invalid ackToken format').optional(),
|
|
241
|
+
continueToken: continueTokenSchema,
|
|
240
242
|
checkpointToken: checkpointTokenSchema,
|
|
241
243
|
isComplete: zod_1.z.boolean(),
|
|
242
244
|
pending: exports.V2PendingStepSchema.nullable(),
|
|
243
245
|
preferences: exports.V2PreferencesSchema,
|
|
244
246
|
nextIntent: exports.V2NextIntentSchema,
|
|
245
247
|
nextCall: exports.V2NextCallSchema,
|
|
246
|
-
}).refine((data) => (data.pending ? data.
|
|
248
|
+
}).refine((data) => (data.pending ? data.continueToken != null : true), { message: 'continueToken is required when a pending step exists' });
|
|
247
249
|
exports.CreateSessionOutputSchema = zod_1.z.object({
|
|
248
250
|
sessionId: zod_1.z.string().min(1),
|
|
249
251
|
workflowId: zod_1.z.string().min(1),
|
package/dist/mcp/server.js
CHANGED
|
@@ -81,6 +81,7 @@ async function createToolContext() {
|
|
|
81
81
|
else {
|
|
82
82
|
const sha256 = container_js_1.container.resolve(tokens_js_1.DI.V2.Sha256);
|
|
83
83
|
const crypto = container_js_1.container.resolve(tokens_js_1.DI.V2.Crypto);
|
|
84
|
+
const entropy = container_js_1.container.resolve(tokens_js_1.DI.V2.RandomEntropy);
|
|
84
85
|
const hmac = container_js_1.container.resolve(tokens_js_1.DI.V2.HmacSha256);
|
|
85
86
|
const base64url = container_js_1.container.resolve(tokens_js_1.DI.V2.Base64Url);
|
|
86
87
|
const base32 = container_js_1.container.resolve(tokens_js_1.DI.V2.Base32);
|
|
@@ -104,6 +105,11 @@ async function createToolContext() {
|
|
|
104
105
|
compiler,
|
|
105
106
|
normalizeToExecutable: v1_to_v2_shim_js_1.normalizeV1WorkflowToPinnedSnapshot,
|
|
106
107
|
};
|
|
108
|
+
const tokenAliasStore = container_js_1.container.resolve(tokens_js_1.DI.V2.TokenAliasStore);
|
|
109
|
+
const aliasLoadResult = await tokenAliasStore.loadIndex();
|
|
110
|
+
if (aliasLoadResult.isErr()) {
|
|
111
|
+
console.error(`[V2Init] Token alias index load warning: ${aliasLoadResult.error.message}`);
|
|
112
|
+
}
|
|
107
113
|
v2 = {
|
|
108
114
|
gate,
|
|
109
115
|
sessionStore,
|
|
@@ -111,8 +117,10 @@ async function createToolContext() {
|
|
|
111
117
|
pinnedStore,
|
|
112
118
|
sha256,
|
|
113
119
|
crypto,
|
|
120
|
+
entropy,
|
|
114
121
|
idFactory,
|
|
115
122
|
tokenCodecPorts,
|
|
123
|
+
tokenAliasStore,
|
|
116
124
|
validationPipelineDeps,
|
|
117
125
|
resolvedRootUris: [],
|
|
118
126
|
workspaceResolver: new index_js_1.LocalWorkspaceAnchorV2(process.cwd()),
|
package/dist/mcp/types.d.ts
CHANGED
|
@@ -17,6 +17,8 @@ import type { DataDirPortV2 } from '../v2/ports/data-dir.port.js';
|
|
|
17
17
|
import type { DirectoryListingPortV2 } from '../v2/ports/directory-listing.port.js';
|
|
18
18
|
import type { SessionSummaryProviderPortV2 } from '../v2/ports/session-summary-provider.port.js';
|
|
19
19
|
import type { ValidationPipelineDepsPhase1a } from '../application/services/workflow-validation-pipeline.js';
|
|
20
|
+
import type { TokenAliasStorePortV2 } from '../v2/ports/token-alias-store.port.js';
|
|
21
|
+
import type { RandomEntropyPortV2 } from '../v2/ports/random-entropy.port.js';
|
|
20
22
|
export interface SessionHealthDetails {
|
|
21
23
|
readonly health: SessionHealthV2;
|
|
22
24
|
}
|
|
@@ -56,6 +58,8 @@ export interface V2Dependencies {
|
|
|
56
58
|
readonly crypto: CryptoPortV2;
|
|
57
59
|
readonly idFactory: IdFactoryV2;
|
|
58
60
|
readonly tokenCodecPorts: TokenCodecPorts;
|
|
61
|
+
readonly tokenAliasStore: TokenAliasStorePortV2;
|
|
62
|
+
readonly entropy: RandomEntropyPortV2;
|
|
59
63
|
readonly validationPipelineDeps: ValidationPipelineDepsPhase1a;
|
|
60
64
|
readonly resolvedRootUris?: readonly string[];
|
|
61
65
|
readonly workspaceResolver?: WorkspaceContextResolverPortV2;
|
package/dist/mcp/v2/tools.d.ts
CHANGED
|
@@ -34,9 +34,8 @@ export declare const V2StartWorkflowInput: z.ZodObject<{
|
|
|
34
34
|
}>;
|
|
35
35
|
export type V2StartWorkflowInput = z.infer<typeof V2StartWorkflowInput>;
|
|
36
36
|
export declare const V2ContinueWorkflowInputShape: z.ZodObject<{
|
|
37
|
+
continueToken: z.ZodString;
|
|
37
38
|
intent: z.ZodOptional<z.ZodEnum<["advance", "rehydrate"]>>;
|
|
38
|
-
stateToken: z.ZodString;
|
|
39
|
-
ackToken: z.ZodOptional<z.ZodString>;
|
|
40
39
|
context: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
|
|
41
40
|
output: z.ZodOptional<z.ZodObject<{
|
|
42
41
|
notesMarkdown: z.ZodOptional<z.ZodString>;
|
|
@@ -49,28 +48,25 @@ export declare const V2ContinueWorkflowInputShape: z.ZodObject<{
|
|
|
49
48
|
artifacts?: unknown[] | undefined;
|
|
50
49
|
}>>;
|
|
51
50
|
}, "strict", z.ZodTypeAny, {
|
|
52
|
-
|
|
51
|
+
continueToken: string;
|
|
53
52
|
context?: Record<string, unknown> | undefined;
|
|
54
53
|
output?: {
|
|
55
54
|
notesMarkdown?: string | undefined;
|
|
56
55
|
artifacts?: unknown[] | undefined;
|
|
57
56
|
} | undefined;
|
|
58
57
|
intent?: "advance" | "rehydrate" | undefined;
|
|
59
|
-
ackToken?: string | undefined;
|
|
60
58
|
}, {
|
|
61
|
-
|
|
59
|
+
continueToken: string;
|
|
62
60
|
context?: Record<string, unknown> | undefined;
|
|
63
61
|
output?: {
|
|
64
62
|
notesMarkdown?: string | undefined;
|
|
65
63
|
artifacts?: unknown[] | undefined;
|
|
66
64
|
} | undefined;
|
|
67
65
|
intent?: "advance" | "rehydrate" | undefined;
|
|
68
|
-
ackToken?: string | undefined;
|
|
69
66
|
}>;
|
|
70
|
-
export declare const V2ContinueWorkflowInput: z.
|
|
67
|
+
export declare const V2ContinueWorkflowInput: z.ZodEffects<z.ZodEffects<z.ZodObject<{
|
|
68
|
+
continueToken: z.ZodString;
|
|
71
69
|
intent: z.ZodOptional<z.ZodEnum<["advance", "rehydrate"]>>;
|
|
72
|
-
stateToken: z.ZodString;
|
|
73
|
-
ackToken: z.ZodOptional<z.ZodString>;
|
|
74
70
|
context: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
|
|
75
71
|
output: z.ZodOptional<z.ZodObject<{
|
|
76
72
|
notesMarkdown: z.ZodOptional<z.ZodString>;
|
|
@@ -83,80 +79,54 @@ export declare const V2ContinueWorkflowInput: z.ZodPipeline<z.ZodEffects<z.ZodOb
|
|
|
83
79
|
artifacts?: unknown[] | undefined;
|
|
84
80
|
}>>;
|
|
85
81
|
}, "strict", z.ZodTypeAny, {
|
|
86
|
-
|
|
82
|
+
continueToken: string;
|
|
87
83
|
context?: Record<string, unknown> | undefined;
|
|
88
84
|
output?: {
|
|
89
85
|
notesMarkdown?: string | undefined;
|
|
90
86
|
artifacts?: unknown[] | undefined;
|
|
91
87
|
} | undefined;
|
|
92
88
|
intent?: "advance" | "rehydrate" | undefined;
|
|
93
|
-
ackToken?: string | undefined;
|
|
94
89
|
}, {
|
|
95
|
-
|
|
90
|
+
continueToken: string;
|
|
96
91
|
context?: Record<string, unknown> | undefined;
|
|
97
92
|
output?: {
|
|
98
93
|
notesMarkdown?: string | undefined;
|
|
99
94
|
artifacts?: unknown[] | undefined;
|
|
100
95
|
} | undefined;
|
|
101
96
|
intent?: "advance" | "rehydrate" | undefined;
|
|
102
|
-
ackToken?: string | undefined;
|
|
103
97
|
}>, {
|
|
104
|
-
|
|
98
|
+
continueToken: string;
|
|
105
99
|
context?: Record<string, unknown> | undefined;
|
|
106
100
|
output?: {
|
|
107
101
|
notesMarkdown?: string | undefined;
|
|
108
102
|
artifacts?: unknown[] | undefined;
|
|
109
103
|
} | undefined;
|
|
110
104
|
intent?: "advance" | "rehydrate" | undefined;
|
|
111
|
-
ackToken?: string | undefined;
|
|
112
|
-
} & {
|
|
113
|
-
intent: "advance" | "rehydrate";
|
|
114
105
|
}, {
|
|
115
|
-
|
|
106
|
+
continueToken: string;
|
|
116
107
|
context?: Record<string, unknown> | undefined;
|
|
117
108
|
output?: {
|
|
118
109
|
notesMarkdown?: string | undefined;
|
|
119
110
|
artifacts?: unknown[] | undefined;
|
|
120
111
|
} | undefined;
|
|
121
112
|
intent?: "advance" | "rehydrate" | undefined;
|
|
122
|
-
ackToken?: string | undefined;
|
|
123
|
-
}>, z.ZodEffects<z.ZodType<{
|
|
124
|
-
intent: "advance" | "rehydrate";
|
|
125
|
-
stateToken: string;
|
|
126
|
-
ackToken?: string;
|
|
127
|
-
context?: Record<string, unknown>;
|
|
128
|
-
output?: {
|
|
129
|
-
notesMarkdown?: string;
|
|
130
|
-
artifacts?: unknown[];
|
|
131
|
-
};
|
|
132
|
-
}, z.ZodTypeDef, {
|
|
133
|
-
intent: "advance" | "rehydrate";
|
|
134
|
-
stateToken: string;
|
|
135
|
-
ackToken?: string;
|
|
136
|
-
context?: Record<string, unknown>;
|
|
137
|
-
output?: {
|
|
138
|
-
notesMarkdown?: string;
|
|
139
|
-
artifacts?: unknown[];
|
|
140
|
-
};
|
|
141
113
|
}>, {
|
|
142
|
-
intent: "advance" | "rehydrate";
|
|
143
|
-
stateToken: string;
|
|
144
|
-
ackToken?: string;
|
|
145
|
-
context?: Record<string, unknown>;
|
|
146
114
|
output?: {
|
|
147
|
-
notesMarkdown?: string;
|
|
148
|
-
artifacts?: unknown[];
|
|
149
|
-
};
|
|
150
|
-
|
|
115
|
+
notesMarkdown?: string | undefined;
|
|
116
|
+
artifacts?: unknown[] | undefined;
|
|
117
|
+
} | undefined;
|
|
118
|
+
context?: Record<string, unknown> | undefined;
|
|
151
119
|
intent: "advance" | "rehydrate";
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
120
|
+
continueToken: string;
|
|
121
|
+
}, {
|
|
122
|
+
continueToken: string;
|
|
123
|
+
context?: Record<string, unknown> | undefined;
|
|
155
124
|
output?: {
|
|
156
|
-
notesMarkdown?: string;
|
|
157
|
-
artifacts?: unknown[];
|
|
158
|
-
};
|
|
159
|
-
|
|
125
|
+
notesMarkdown?: string | undefined;
|
|
126
|
+
artifacts?: unknown[] | undefined;
|
|
127
|
+
} | undefined;
|
|
128
|
+
intent?: "advance" | "rehydrate" | undefined;
|
|
129
|
+
}>;
|
|
160
130
|
export type V2ContinueWorkflowInput = z.infer<typeof V2ContinueWorkflowInput>;
|
|
161
131
|
export declare const V2ResumeSessionInput: z.ZodObject<{
|
|
162
132
|
query: z.ZodOptional<z.ZodString>;
|
package/dist/mcp/v2/tools.js
CHANGED
|
@@ -19,12 +19,12 @@ exports.V2StartWorkflowInput = zod_1.z.object({
|
|
|
19
19
|
workspacePath: workspacePathField.describe('Absolute path to your current workspace directory (e.g. the "Workspace:" value from your system parameters). Used to resolve the correct project-scoped workflow variant and to anchor this session to your workspace for future resume_session discovery. Pass this on every start_workflow call. If omitted, WorkRail uses MCP roots when available, then falls back to the server process directory.'),
|
|
20
20
|
});
|
|
21
21
|
exports.V2ContinueWorkflowInputShape = zod_1.z.object({
|
|
22
|
-
|
|
23
|
-
'
|
|
24
|
-
|
|
25
|
-
'
|
|
26
|
-
|
|
27
|
-
|
|
22
|
+
continueToken: zod_1.z.string().min(1).describe('The single token for your next continue_workflow call. Carries session identity AND advance authority. ' +
|
|
23
|
+
'Round-trip exactly as received from start_workflow or previous continue_workflow — never decode, inspect, or modify it.'),
|
|
24
|
+
intent: zod_1.z.enum(['advance', 'rehydrate']).optional().describe('What you want to do. Auto-inferred if omitted: ' +
|
|
25
|
+
'output present → "advance", output absent → "rehydrate". ' +
|
|
26
|
+
'"advance": I completed the current step. ' +
|
|
27
|
+
'"rehydrate": Remind me what the current step is (state recovery after rewind/lost context) — do NOT include output.'),
|
|
28
28
|
context: zod_1.z.record(zod_1.z.unknown()).optional().describe('External facts (only if CHANGED since last call). Omit this entirely if no facts changed. WorkRail auto-merges with previous context. Example: if context={branch:"main"} at start, do NOT re-pass it unless branch changed. Pass only NEW or OVERRIDDEN values.'),
|
|
29
29
|
output: zod_1.z
|
|
30
30
|
.object({
|
|
@@ -41,39 +41,25 @@ exports.V2ContinueWorkflowInputShape = zod_1.z.object({
|
|
|
41
41
|
.describe('Durable output to attach to the current node. Only valid when intent is "advance".'),
|
|
42
42
|
}).strict();
|
|
43
43
|
exports.V2ContinueWorkflowInput = exports.V2ContinueWorkflowInputShape
|
|
44
|
-
.
|
|
45
|
-
const intent = data.intent ?? (data.ackToken ? 'advance' : 'rehydrate');
|
|
46
|
-
return { ...data, intent };
|
|
47
|
-
})
|
|
48
|
-
.pipe(zod_1.z.custom().superRefine((data, ctx) => {
|
|
49
|
-
if (data.intent === 'advance' && !data.ackToken) {
|
|
50
|
-
ctx.addIssue({
|
|
51
|
-
code: zod_1.z.ZodIssueCode.custom,
|
|
52
|
-
path: ['ackToken'],
|
|
53
|
-
message: 'intent is "advance" but ackToken is missing. ' +
|
|
54
|
-
'To advance to the next step, include the ackToken from the previous start_workflow or continue_workflow response. ' +
|
|
55
|
-
'If you don\'t have an ackToken, set intent to "rehydrate" to recover the current step.',
|
|
56
|
-
});
|
|
57
|
-
}
|
|
58
|
-
if (data.intent === 'rehydrate' && data.ackToken) {
|
|
59
|
-
ctx.addIssue({
|
|
60
|
-
code: zod_1.z.ZodIssueCode.custom,
|
|
61
|
-
path: ['ackToken'],
|
|
62
|
-
message: 'intent is "rehydrate" but ackToken was provided. ' +
|
|
63
|
-
'Rehydration recovers the current step without advancing — it does not accept ackToken. ' +
|
|
64
|
-
'To advance, set intent to "advance". To rehydrate, remove ackToken.',
|
|
65
|
-
});
|
|
66
|
-
}
|
|
44
|
+
.superRefine((data, ctx) => {
|
|
67
45
|
if (data.intent === 'rehydrate' && data.output) {
|
|
68
46
|
ctx.addIssue({
|
|
69
47
|
code: zod_1.z.ZodIssueCode.custom,
|
|
70
48
|
path: ['output'],
|
|
71
49
|
message: 'intent is "rehydrate" but output was provided. ' +
|
|
72
|
-
'Rehydration is read-only state recovery — it does not accept output.
|
|
73
|
-
'To submit output and advance, set intent to "advance" and include ackToken.',
|
|
50
|
+
'Rehydration is read-only state recovery — it does not accept output.',
|
|
74
51
|
});
|
|
75
52
|
}
|
|
76
|
-
})
|
|
53
|
+
})
|
|
54
|
+
.transform((data) => {
|
|
55
|
+
const intent = data.intent ?? (data.output ? 'advance' : 'rehydrate');
|
|
56
|
+
return {
|
|
57
|
+
intent,
|
|
58
|
+
continueToken: data.continueToken,
|
|
59
|
+
...(data.context ? { context: data.context } : {}),
|
|
60
|
+
...(data.output ? { output: data.output } : {}),
|
|
61
|
+
};
|
|
62
|
+
});
|
|
77
63
|
exports.V2ResumeSessionInput = zod_1.z.object({
|
|
78
64
|
query: zod_1.z.string().max(256).optional().describe('Free text search to find a relevant session. Matches against recap notes and workflow IDs.'),
|
|
79
65
|
gitBranch: zod_1.z.string().max(256).optional().describe('Git branch name to match against session observations. Overrides auto-detected branch.'),
|
|
@@ -5,8 +5,7 @@ function isV2ExecutionResponse(data) {
|
|
|
5
5
|
if (typeof data !== 'object' || data === null)
|
|
6
6
|
return false;
|
|
7
7
|
const d = data;
|
|
8
|
-
return (
|
|
9
|
-
'pending' in d &&
|
|
8
|
+
return ('pending' in d &&
|
|
10
9
|
typeof d.nextIntent === 'string' &&
|
|
11
10
|
typeof d.preferences === 'object' && d.preferences !== null);
|
|
12
11
|
}
|
|
@@ -45,22 +44,19 @@ const PERSONA_SYSTEM = '---------\nSYSTEM\n---------';
|
|
|
45
44
|
function formatTokenBlock(data) {
|
|
46
45
|
const params = {};
|
|
47
46
|
if (data.nextCall) {
|
|
48
|
-
params.
|
|
49
|
-
if (data.nextCall.params.ackToken) {
|
|
50
|
-
params.ackToken = data.nextCall.params.ackToken;
|
|
51
|
-
}
|
|
47
|
+
params.continueToken = data.nextCall.params.continueToken;
|
|
52
48
|
}
|
|
53
|
-
else {
|
|
54
|
-
params.
|
|
49
|
+
else if (data.continueToken) {
|
|
50
|
+
params.continueToken = data.continueToken;
|
|
55
51
|
}
|
|
56
52
|
const lines = [];
|
|
53
|
+
if (data.pending?.stepId) {
|
|
54
|
+
lines.push(`**Tokens for step \`${data.pending.stepId}\` — use these for your next \`continue_workflow\` call (not tokens from earlier steps):**`);
|
|
55
|
+
lines.push('');
|
|
56
|
+
}
|
|
57
57
|
lines.push('```json');
|
|
58
58
|
lines.push(JSON.stringify(params));
|
|
59
59
|
lines.push('```');
|
|
60
|
-
if (data.checkpointToken) {
|
|
61
|
-
lines.push('');
|
|
62
|
-
lines.push(`Checkpoint token (for \`checkpoint_workflow\`): \`${data.checkpointToken}\``);
|
|
63
|
-
}
|
|
64
60
|
return lines.join('\n');
|
|
65
61
|
}
|
|
66
62
|
function formatComplete(_data) {
|
|
@@ -151,6 +147,8 @@ function formatRehydrate(data) {
|
|
|
151
147
|
}
|
|
152
148
|
lines.push(PERSONA_SYSTEM);
|
|
153
149
|
lines.push('');
|
|
150
|
+
lines.push(formatTokenBlock(data));
|
|
151
|
+
lines.push('');
|
|
154
152
|
if (!data.pending) {
|
|
155
153
|
lines.push('# State Recovered');
|
|
156
154
|
lines.push('');
|
|
@@ -158,8 +156,6 @@ function formatRehydrate(data) {
|
|
|
158
156
|
lines.push('');
|
|
159
157
|
}
|
|
160
158
|
lines.push('Continue working on this step. When done, call `continue_workflow` to advance.');
|
|
161
|
-
lines.push('');
|
|
162
|
-
lines.push(formatTokenBlock(data));
|
|
163
159
|
return lines.join('\n');
|
|
164
160
|
}
|
|
165
161
|
function formatSuccess(data) {
|
|
@@ -175,12 +171,12 @@ function formatSuccess(data) {
|
|
|
175
171
|
}
|
|
176
172
|
lines.push(PERSONA_SYSTEM);
|
|
177
173
|
lines.push('');
|
|
174
|
+
lines.push(formatTokenBlock(data));
|
|
175
|
+
lines.push('');
|
|
178
176
|
lines.push('Execute this step, then call `continue_workflow` to advance.');
|
|
179
177
|
lines.push('');
|
|
180
178
|
lines.push('Include `output.notesMarkdown` documenting your work — what you did, key decisions, what you produced, and anything notable.');
|
|
181
179
|
lines.push('');
|
|
182
|
-
lines.push(formatTokenBlock(data));
|
|
183
|
-
lines.push('');
|
|
184
180
|
lines.push(formatPreferences(data.preferences));
|
|
185
181
|
return lines.join('\n');
|
|
186
182
|
}
|
|
@@ -210,6 +210,7 @@ function renderPendingPrompt(args) {
|
|
|
210
210
|
}
|
|
211
211
|
const baseTitle = step.title;
|
|
212
212
|
const basePrompt = step.prompt;
|
|
213
|
+
const agentRole = step.agentRole;
|
|
213
214
|
const requireConfirmation = Boolean(step.requireConfirmation);
|
|
214
215
|
const functionReferences = step.functionReferences ?? [];
|
|
215
216
|
const outputContract = 'outputContract' in step
|
|
@@ -261,7 +262,7 @@ function renderPendingPrompt(args) {
|
|
|
261
262
|
'Omitting notes will block this step — use the `retryAckToken` to fix and retry.';
|
|
262
263
|
const enhancedPrompt = loopBanner + basePrompt + requirementsSection + contractSection + notesSection;
|
|
263
264
|
if (!args.rehydrateOnly) {
|
|
264
|
-
return (0, neverthrow_1.ok)({ stepId: args.stepId, title: baseTitle, prompt: enhancedPrompt, requireConfirmation });
|
|
265
|
+
return (0, neverthrow_1.ok)({ stepId: args.stepId, title: baseTitle, prompt: enhancedPrompt, agentRole, requireConfirmation });
|
|
265
266
|
}
|
|
266
267
|
const projectionsRes = loadRecoveryProjections({ truth: args.truth, runId: args.runId });
|
|
267
268
|
if (projectionsRes.isErr()) {
|
|
@@ -269,6 +270,7 @@ function renderPendingPrompt(args) {
|
|
|
269
270
|
stepId: args.stepId,
|
|
270
271
|
title: baseTitle,
|
|
271
272
|
prompt: enhancedPrompt + '\n\n' + projectionsRes.error,
|
|
273
|
+
agentRole,
|
|
272
274
|
requireConfirmation,
|
|
273
275
|
});
|
|
274
276
|
}
|
|
@@ -284,10 +286,10 @@ function renderPendingPrompt(args) {
|
|
|
284
286
|
functionReferences,
|
|
285
287
|
});
|
|
286
288
|
if (sections.length === 0) {
|
|
287
|
-
return (0, neverthrow_1.ok)({ stepId: args.stepId, title: baseTitle, prompt: enhancedPrompt, requireConfirmation });
|
|
289
|
+
return (0, neverthrow_1.ok)({ stepId: args.stepId, title: baseTitle, prompt: enhancedPrompt, agentRole, requireConfirmation });
|
|
288
290
|
}
|
|
289
291
|
const recoveryText = `## Recovery Context\n\n${sections.join('\n\n')}`;
|
|
290
292
|
const combinedPrompt = `${enhancedPrompt}\n\n${recoveryText}`;
|
|
291
293
|
const finalPrompt = applyPromptBudget(combinedPrompt);
|
|
292
|
-
return (0, neverthrow_1.ok)({ stepId: args.stepId, title: baseTitle, prompt: finalPrompt, requireConfirmation });
|
|
294
|
+
return (0, neverthrow_1.ok)({ stepId: args.stepId, title: baseTitle, prompt: finalPrompt, agentRole, requireConfirmation });
|
|
293
295
|
}
|
|
@@ -889,8 +889,8 @@ export declare const SessionContentsV1Schema: z.ZodObject<{
|
|
|
889
889
|
}>;
|
|
890
890
|
}, "strict", z.ZodTypeAny, {
|
|
891
891
|
contractRef: string;
|
|
892
|
-
validationId: string;
|
|
893
892
|
attemptId: string;
|
|
893
|
+
validationId: string;
|
|
894
894
|
result: {
|
|
895
895
|
issues: readonly string[];
|
|
896
896
|
valid: boolean;
|
|
@@ -898,8 +898,8 @@ export declare const SessionContentsV1Schema: z.ZodObject<{
|
|
|
898
898
|
};
|
|
899
899
|
}, {
|
|
900
900
|
contractRef: string;
|
|
901
|
-
validationId: string;
|
|
902
901
|
attemptId: string;
|
|
902
|
+
validationId: string;
|
|
903
903
|
result: {
|
|
904
904
|
issues: readonly string[];
|
|
905
905
|
valid: boolean;
|
|
@@ -911,8 +911,8 @@ export declare const SessionContentsV1Schema: z.ZodObject<{
|
|
|
911
911
|
sessionId: string;
|
|
912
912
|
data: {
|
|
913
913
|
contractRef: string;
|
|
914
|
-
validationId: string;
|
|
915
914
|
attemptId: string;
|
|
915
|
+
validationId: string;
|
|
916
916
|
result: {
|
|
917
917
|
issues: readonly string[];
|
|
918
918
|
valid: boolean;
|
|
@@ -932,8 +932,8 @@ export declare const SessionContentsV1Schema: z.ZodObject<{
|
|
|
932
932
|
sessionId: string;
|
|
933
933
|
data: {
|
|
934
934
|
contractRef: string;
|
|
935
|
-
validationId: string;
|
|
936
935
|
attemptId: string;
|
|
936
|
+
validationId: string;
|
|
937
937
|
result: {
|
|
938
938
|
issues: readonly string[];
|
|
939
939
|
valid: boolean;
|
|
@@ -4385,8 +4385,8 @@ export declare const SessionContentsV1Schema: z.ZodObject<{
|
|
|
4385
4385
|
sessionId: string;
|
|
4386
4386
|
data: {
|
|
4387
4387
|
contractRef: string;
|
|
4388
|
-
validationId: string;
|
|
4389
4388
|
attemptId: string;
|
|
4389
|
+
validationId: string;
|
|
4390
4390
|
result: {
|
|
4391
4391
|
issues: readonly string[];
|
|
4392
4392
|
valid: boolean;
|
|
@@ -4897,8 +4897,8 @@ export declare const SessionContentsV1Schema: z.ZodObject<{
|
|
|
4897
4897
|
sessionId: string;
|
|
4898
4898
|
data: {
|
|
4899
4899
|
contractRef: string;
|
|
4900
|
-
validationId: string;
|
|
4901
4900
|
attemptId: string;
|
|
4901
|
+
validationId: string;
|
|
4902
4902
|
result: {
|
|
4903
4903
|
issues: readonly string[];
|
|
4904
4904
|
valid: boolean;
|
|
@@ -6011,8 +6011,8 @@ export declare const ExportBundleV1Schema: z.ZodObject<{
|
|
|
6011
6011
|
}>;
|
|
6012
6012
|
}, "strict", z.ZodTypeAny, {
|
|
6013
6013
|
contractRef: string;
|
|
6014
|
-
validationId: string;
|
|
6015
6014
|
attemptId: string;
|
|
6015
|
+
validationId: string;
|
|
6016
6016
|
result: {
|
|
6017
6017
|
issues: readonly string[];
|
|
6018
6018
|
valid: boolean;
|
|
@@ -6020,8 +6020,8 @@ export declare const ExportBundleV1Schema: z.ZodObject<{
|
|
|
6020
6020
|
};
|
|
6021
6021
|
}, {
|
|
6022
6022
|
contractRef: string;
|
|
6023
|
-
validationId: string;
|
|
6024
6023
|
attemptId: string;
|
|
6024
|
+
validationId: string;
|
|
6025
6025
|
result: {
|
|
6026
6026
|
issues: readonly string[];
|
|
6027
6027
|
valid: boolean;
|
|
@@ -6033,8 +6033,8 @@ export declare const ExportBundleV1Schema: z.ZodObject<{
|
|
|
6033
6033
|
sessionId: string;
|
|
6034
6034
|
data: {
|
|
6035
6035
|
contractRef: string;
|
|
6036
|
-
validationId: string;
|
|
6037
6036
|
attemptId: string;
|
|
6037
|
+
validationId: string;
|
|
6038
6038
|
result: {
|
|
6039
6039
|
issues: readonly string[];
|
|
6040
6040
|
valid: boolean;
|
|
@@ -6054,8 +6054,8 @@ export declare const ExportBundleV1Schema: z.ZodObject<{
|
|
|
6054
6054
|
sessionId: string;
|
|
6055
6055
|
data: {
|
|
6056
6056
|
contractRef: string;
|
|
6057
|
-
validationId: string;
|
|
6058
6057
|
attemptId: string;
|
|
6058
|
+
validationId: string;
|
|
6059
6059
|
result: {
|
|
6060
6060
|
issues: readonly string[];
|
|
6061
6061
|
valid: boolean;
|
|
@@ -9507,8 +9507,8 @@ export declare const ExportBundleV1Schema: z.ZodObject<{
|
|
|
9507
9507
|
sessionId: string;
|
|
9508
9508
|
data: {
|
|
9509
9509
|
contractRef: string;
|
|
9510
|
-
validationId: string;
|
|
9511
9510
|
attemptId: string;
|
|
9511
|
+
validationId: string;
|
|
9512
9512
|
result: {
|
|
9513
9513
|
issues: readonly string[];
|
|
9514
9514
|
valid: boolean;
|
|
@@ -10019,8 +10019,8 @@ export declare const ExportBundleV1Schema: z.ZodObject<{
|
|
|
10019
10019
|
sessionId: string;
|
|
10020
10020
|
data: {
|
|
10021
10021
|
contractRef: string;
|
|
10022
|
-
validationId: string;
|
|
10023
10022
|
attemptId: string;
|
|
10023
|
+
validationId: string;
|
|
10024
10024
|
result: {
|
|
10025
10025
|
issues: readonly string[];
|
|
10026
10026
|
valid: boolean;
|
|
@@ -10560,8 +10560,8 @@ export declare const ExportBundleV1Schema: z.ZodObject<{
|
|
|
10560
10560
|
sessionId: string;
|
|
10561
10561
|
data: {
|
|
10562
10562
|
contractRef: string;
|
|
10563
|
-
validationId: string;
|
|
10564
10563
|
attemptId: string;
|
|
10564
|
+
validationId: string;
|
|
10565
10565
|
result: {
|
|
10566
10566
|
issues: readonly string[];
|
|
10567
10567
|
valid: boolean;
|
|
@@ -11089,8 +11089,8 @@ export declare const ExportBundleV1Schema: z.ZodObject<{
|
|
|
11089
11089
|
sessionId: string;
|
|
11090
11090
|
data: {
|
|
11091
11091
|
contractRef: string;
|
|
11092
|
-
validationId: string;
|
|
11093
11092
|
attemptId: string;
|
|
11093
|
+
validationId: string;
|
|
11094
11094
|
result: {
|
|
11095
11095
|
issues: readonly string[];
|
|
11096
11096
|
valid: boolean;
|