@exaudeus/workrail 3.16.0 → 3.18.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.
Files changed (68) hide show
  1. package/dist/application/services/validation-engine.js +7 -11
  2. package/dist/application/services/workflow-compiler.js +9 -11
  3. package/dist/application/use-cases/raw-workflow-file-scanner.js +10 -13
  4. package/dist/cli/commands/index.d.ts +1 -1
  5. package/dist/cli/commands/index.js +2 -1
  6. package/dist/cli/commands/init.d.ts +10 -0
  7. package/dist/cli/commands/init.js +72 -0
  8. package/dist/cli.js +13 -1
  9. package/dist/config/config-file.d.ts +8 -0
  10. package/dist/config/config-file.js +141 -0
  11. package/dist/config/feature-flags.js +8 -0
  12. package/dist/console/assets/index-BwJelCXK.js +28 -0
  13. package/dist/console/index.html +1 -1
  14. package/dist/di/container.d.ts +1 -0
  15. package/dist/di/container.js +24 -7
  16. package/dist/infrastructure/session/HttpServer.d.ts +0 -1
  17. package/dist/infrastructure/session/HttpServer.js +4 -46
  18. package/dist/manifest.json +120 -128
  19. package/dist/mcp/assert-output.js +2 -1
  20. package/dist/mcp/dev-mode.d.ts +1 -0
  21. package/dist/mcp/dev-mode.js +12 -0
  22. package/dist/mcp/handler-factory.d.ts +1 -1
  23. package/dist/mcp/handler-factory.js +8 -7
  24. package/dist/mcp/handlers/shared/request-workflow-reader.d.ts +1 -0
  25. package/dist/mcp/handlers/shared/request-workflow-reader.js +90 -20
  26. package/dist/mcp/handlers/v2-advance-core/assessment-consequences.d.ts +1 -1
  27. package/dist/mcp/handlers/v2-advance-core/assessment-consequences.js +14 -11
  28. package/dist/mcp/handlers/v2-advance-core/assessment-validation.d.ts +5 -3
  29. package/dist/mcp/handlers/v2-advance-core/assessment-validation.js +109 -87
  30. package/dist/mcp/handlers/v2-advance-core/input-validation.d.ts +0 -4
  31. package/dist/mcp/handlers/v2-advance-core/input-validation.js +1 -3
  32. package/dist/mcp/handlers/v2-advance-core/outcome-blocked.js +8 -3
  33. package/dist/mcp/handlers/v2-advance-core/outcome-success.js +8 -3
  34. package/dist/mcp/handlers/v2-execution/continue-advance.d.ts +1 -0
  35. package/dist/mcp/handlers/v2-execution/continue-advance.js +3 -1
  36. package/dist/mcp/handlers/v2-execution/continue-rehydrate.d.ts +1 -0
  37. package/dist/mcp/handlers/v2-execution/continue-rehydrate.js +2 -1
  38. package/dist/mcp/handlers/v2-execution/index.js +2 -0
  39. package/dist/mcp/handlers/v2-execution/replay.d.ts +2 -0
  40. package/dist/mcp/handlers/v2-execution/replay.js +7 -4
  41. package/dist/mcp/handlers/v2-execution/start.js +48 -20
  42. package/dist/mcp/handlers/v2-workflow.js +4 -2
  43. package/dist/mcp/output-schemas.d.ts +17 -12
  44. package/dist/mcp/output-schemas.js +12 -11
  45. package/dist/mcp/server.js +3 -2
  46. package/dist/mcp/v2-response-formatter.d.ts +1 -1
  47. package/dist/mcp/v2-response-formatter.js +2 -3
  48. package/dist/types/workflow-definition.d.ts +3 -1
  49. package/dist/types/workflow-definition.js +2 -0
  50. package/dist/v2/durable-core/domain/prompt-renderer.d.ts +1 -0
  51. package/dist/v2/durable-core/domain/prompt-renderer.js +5 -2
  52. package/dist/v2/durable-core/schemas/compiled-workflow/index.js +4 -3
  53. package/dist/v2/infra/local/pinned-workflow-store/index.d.ts +2 -0
  54. package/dist/v2/infra/local/pinned-workflow-store/index.js +49 -0
  55. package/dist/v2/infra/local/remembered-roots-store/index.d.ts +3 -1
  56. package/dist/v2/infra/local/remembered-roots-store/index.js +6 -3
  57. package/dist/v2/infra/local/workspace-anchor/index.js +4 -2
  58. package/dist/v2/ports/pinned-workflow-store.port.d.ts +2 -0
  59. package/dist/v2/usecases/console-routes.js +3 -2
  60. package/package.json +1 -1
  61. package/spec/authoring-spec.json +3 -3
  62. package/spec/workflow.schema.json +1 -2
  63. package/workflows/workflow-for-workflows.json +558 -448
  64. package/dist/console/assets/index-BE5PAgPO.js +0 -28
  65. package/dist/env-flags.d.ts +0 -1
  66. package/dist/env-flags.js +0 -4
  67. package/dist/mcp/handlers/v2-resolve-refs-envelope.d.ts +0 -5
  68. package/dist/mcp/handlers/v2-resolve-refs-envelope.js +0 -17
@@ -75,6 +75,7 @@ function loadAndRehydrate(args) {
75
75
  aliasStore: tokenAliasStore,
76
76
  entropy,
77
77
  resolvedRootUris: args.ctx.v2.resolvedRootUris,
78
+ cleanResponseFormat: args.ctx.featureFlags?.isEnabled('cleanResponseFormat') ?? false,
78
79
  }));
79
80
  }
80
81
  function executeContinueWorkflow(input, ctx) {
@@ -140,6 +141,7 @@ function executeContinueWorkflow(input, ctx) {
140
141
  sha256,
141
142
  aliasStore: tokenAliasStore,
142
143
  entropy,
144
+ cleanResponseFormat: ctx.featureFlags?.isEnabled('cleanResponseFormat') ?? false,
143
145
  }))
144
146
  .map((response) => ({ response }));
145
147
  });
@@ -25,6 +25,7 @@ export declare function buildAdvancedReplayResponse(args: {
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
27
  readonly precomputedIndex?: import('../../../v2/durable-core/session-index.js').SessionIndex;
28
+ readonly cleanResponseFormat?: boolean;
28
29
  }): RA<z.infer<typeof V2ContinueWorkflowOutputSchema>, ContinueWorkflowError>;
29
30
  export declare function replayFromRecordedAdvance(args: {
30
31
  readonly recordedEvent: Extract<DomainEventV1, {
@@ -43,4 +44,5 @@ export declare function replayFromRecordedAdvance(args: {
43
44
  readonly aliasStore: import('../../../v2/ports/token-alias-store.port.js').TokenAliasStorePortV2;
44
45
  readonly entropy: import('../../../v2/ports/random-entropy.port.js').RandomEntropyPortV2;
45
46
  readonly precomputedIndex?: import('../../../v2/durable-core/session-index.js').SessionIndex;
47
+ readonly cleanResponseFormat?: boolean;
46
48
  }): RA<z.infer<typeof V2ContinueWorkflowOutputSchema>, ContinueWorkflowError>;
@@ -78,6 +78,7 @@ function buildAdvancedReplayResponse(args) {
78
78
  nodeId: (0, index_js_1.asNodeId)(String(toNodeIdBranded)),
79
79
  rehydrateOnly: false,
80
80
  precomputedIndex: args.precomputedIndex,
81
+ cleanResponseFormat: args.cleanResponseFormat,
81
82
  });
82
83
  if (result.isErr()) {
83
84
  return (0, neverthrow_1.errAsync)({ kind: 'prompt_render_failed', message: result.error.message });
@@ -116,6 +117,7 @@ function buildAdvancedReplayResponse(args) {
116
117
  nodeId: (0, index_js_1.asNodeId)(String(toNodeIdBranded)),
117
118
  rehydrateOnly: false,
118
119
  precomputedIndex: args.precomputedIndex,
120
+ cleanResponseFormat: args.cleanResponseFormat,
119
121
  });
120
122
  if (result.isErr()) {
121
123
  return (0, neverthrow_1.errAsync)({ kind: 'prompt_render_failed', message: result.error.message });
@@ -151,11 +153,11 @@ function buildStepContext(events, completedNodeId) {
151
153
  console.warn(`[workrail:replay] stepContext projection failed for node '${String(completedNodeId)}' — stepContext will be absent: ${projection.error.message}`);
152
154
  return undefined;
153
155
  }
154
- const recorded = (0, assessments_js_1.getLatestAssessmentForNode)(projection.value, String(completedNodeId));
155
- if (!recorded)
156
+ const allRecorded = projection.value.byNodeId[String(completedNodeId)];
157
+ if (!allRecorded || allRecorded.length === 0)
156
158
  return undefined;
157
159
  return {
158
- assessments: {
160
+ assessments: allRecorded.map((recorded) => ({
159
161
  assessmentId: recorded.assessmentId,
160
162
  dimensions: recorded.dimensions.map((d) => ({
161
163
  dimensionId: d.dimensionId,
@@ -163,7 +165,7 @@ function buildStepContext(events, completedNodeId) {
163
165
  ...(d.rationale !== undefined ? { rationale: d.rationale } : {}),
164
166
  })),
165
167
  normalizationNotes: recorded.normalizationNotes,
166
- },
168
+ })),
167
169
  };
168
170
  }
169
171
  function replayFromRecordedAdvance(args) {
@@ -208,6 +210,7 @@ function replayFromRecordedAdvance(args) {
208
210
  aliasStore,
209
211
  entropy,
210
212
  precomputedIndex: args.precomputedIndex,
213
+ cleanResponseFormat: args.cleanResponseFormat,
211
214
  });
212
215
  });
213
216
  }
@@ -26,6 +26,8 @@ const request_workflow_reader_js_1 = require("../shared/request-workflow-reader.
26
26
  const step_content_envelope_js_1 = require("../../step-content-envelope.js");
27
27
  const v2_workspace_resolution_js_2 = require("../v2-workspace-resolution.js");
28
28
  const v2_reference_resolver_js_1 = require("../v2-reference-resolver.js");
29
+ const with_timeout_js_1 = require("../shared/with-timeout.js");
30
+ const REFERENCE_RESOLUTION_TIMEOUT_MS = 5000;
29
31
  function loadAndPinWorkflow(args) {
30
32
  const { workflowId, workflowReader, crypto, pinnedStore, validationPipelineDeps, workspacePath, resolvedRootUris } = args;
31
33
  return neverthrow_1.ResultAsync.fromPromise(workflowReader.getWorkflowById(workflowId), (e) => ({
@@ -77,7 +79,7 @@ function loadAndPinWorkflow(args) {
77
79
  }
78
80
  return pinnedStore.put(workflowHash, enrichedCompiled)
79
81
  .mapErr((cause) => ({ kind: 'pinned_workflow_store_failed', cause }))
80
- .andThen(() => pinnedStore.get(workflowHash).mapErr((cause) => ({ kind: 'pinned_workflow_store_failed', cause })));
82
+ .map(() => enrichedCompiled);
81
83
  })
82
84
  .andThen((pinned) => {
83
85
  if (!pinned || pinned.sourceKind !== 'v1_pinned' || !(0, workflow_definition_js_1.hasWorkflowDefinitionShape)(pinned.definition)) {
@@ -239,10 +241,11 @@ function executeStartWorkflow(input, ctx) {
239
241
  workspacePath: input.workspacePath,
240
242
  resolvedRootUris: ctx.v2.resolvedRootUris,
241
243
  rememberedRootsStore: ctx.v2.rememberedRootsStore,
244
+ managedSourceStore: ctx.v2.managedSourceStore,
242
245
  }), (err) => ({
243
246
  kind: 'precondition_failed',
244
247
  message: `Failed to initialize workflow reader: ${String(err)}`,
245
- })).map(({ reader, stalePaths }) => ({
248
+ })).map(({ reader, stalePaths, managedStoreError }) => ({
246
249
  workflowReader: {
247
250
  getWorkflowById: async (workflowId) => {
248
251
  const requestResult = await reader.getWorkflowById(workflowId);
@@ -252,21 +255,24 @@ function executeStartWorkflow(input, ctx) {
252
255
  },
253
256
  },
254
257
  stalePaths,
258
+ managedStoreError,
255
259
  }))
256
- : (0, neverthrow_1.okAsync)({ workflowReader: ctx.workflowService, stalePaths: [] });
257
- return readerRA.andThen(({ workflowReader, stalePaths }) => loadAndPinWorkflow({
258
- workflowId: input.workflowId,
259
- workflowReader,
260
- crypto,
261
- pinnedStore,
262
- validationPipelineDeps,
263
- workspacePath: input.workspacePath,
264
- resolvedRootUris: ctx.v2.resolvedRootUris,
265
- })
266
- .andThen(({ workflow, firstStep, workflowHash, pinnedWorkflow, resolvedReferences }) => {
267
- const anchorsRA = (0, v2_workspace_resolution_js_1.resolveWorkspaceAnchors)(ctx.v2, input.workspacePath)
268
- .map((anchors) => (0, observation_builder_js_1.anchorsToObservations)(anchors));
269
- return anchorsRA.andThen((observations) => {
260
+ : (0, neverthrow_1.okAsync)({ workflowReader: ctx.workflowService, stalePaths: [], managedStoreError: undefined });
261
+ const anchorsRA = (0, v2_workspace_resolution_js_1.resolveWorkspaceAnchors)(ctx.v2, input.workspacePath)
262
+ .map((anchors) => (0, observation_builder_js_1.anchorsToObservations)(anchors))
263
+ .mapErr((x) => x);
264
+ return readerRA.andThen(({ workflowReader, stalePaths, managedStoreError }) => {
265
+ const pinnedRA = loadAndPinWorkflow({
266
+ workflowId: input.workflowId,
267
+ workflowReader,
268
+ crypto,
269
+ pinnedStore,
270
+ validationPipelineDeps,
271
+ workspacePath: input.workspacePath,
272
+ resolvedRootUris: ctx.v2.resolvedRootUris,
273
+ });
274
+ return neverthrow_1.ResultAsync.combine([pinnedRA, anchorsRA])
275
+ .andThen(([{ workflow, firstStep, workflowHash, pinnedWorkflow, resolvedReferences }, observations]) => {
270
276
  const sessionId = idFactory.mintSessionId();
271
277
  const runId = idFactory.mintRunId();
272
278
  const nodeId = idFactory.mintNodeId();
@@ -314,11 +320,11 @@ function executeStartWorkflow(input, ctx) {
314
320
  snapshotPins: [{ snapshotRef, eventIndex: 2, createdByEventId: events[2].eventId }],
315
321
  }, emptyTruth))
316
322
  .mapErr((cause) => ({ kind: 'session_append_failed', cause }))
317
- .map(() => ({ workflow, firstStep, workflowHash, pinnedWorkflow, resolvedReferences, sessionId, runId, nodeId }));
323
+ .map(() => ({ workflow, firstStep, workflowHash, pinnedWorkflow, resolvedReferences, sessionId, runId, nodeId, stalePaths, managedStoreError }));
318
324
  });
319
325
  });
320
326
  })
321
- .andThen(({ pinnedWorkflow, firstStep, workflowHash, sessionId, runId, nodeId, resolvedReferences }) => {
327
+ .andThen(({ pinnedWorkflow, firstStep, workflowHash, sessionId, runId, nodeId, resolvedReferences, stalePaths, managedStoreError }) => {
322
328
  const wfRefRes = (0, workflow_hash_ref_js_1.deriveWorkflowHashRef)(workflowHash);
323
329
  if (wfRefRes.isErr()) {
324
330
  return (0, neverthrow_1.errAsync)({
@@ -346,6 +352,7 @@ function executeStartWorkflow(input, ctx) {
346
352
  runId: (0, index_js_1.asRunId)(String(runId)),
347
353
  nodeId: (0, index_js_1.asNodeId)(String(nodeId)),
348
354
  rehydrateOnly: false,
355
+ cleanResponseFormat: ctx.featureFlags?.isEnabled('cleanResponseFormat') ?? false,
349
356
  });
350
357
  if (metaResult.isErr()) {
351
358
  return (0, neverthrow_1.errAsync)({
@@ -361,6 +368,9 @@ function executeStartWorkflow(input, ctx) {
361
368
  meta,
362
369
  references: resolvedReferences,
363
370
  });
371
+ const startWarnings = managedStoreError !== undefined
372
+ ? [`Managed workflow source store was temporarily unavailable (${managedStoreError}). Managed sources were not loaded.`]
373
+ : undefined;
364
374
  const parsed = {
365
375
  continueToken: tokens.continueToken,
366
376
  checkpointToken: tokens.checkpointToken,
@@ -370,16 +380,34 @@ function executeStartWorkflow(input, ctx) {
370
380
  nextIntent,
371
381
  nextCall: (0, index_js_2.buildNextCall)({ continueToken: tokens.continueToken, isComplete: false, pending }),
372
382
  ...(stalePaths.length > 0 ? { staleRoots: [...stalePaths] } : {}),
383
+ ...(startWarnings !== undefined ? { warnings: startWarnings } : {}),
373
384
  };
374
385
  return (0, neverthrow_1.okAsync)({ response: parsed, contentEnvelope });
375
386
  });
376
- }));
387
+ });
377
388
  }
378
389
  function enrichPinnedSnapshotWithResolvedReferences(snapshot, references, workspacePath) {
379
390
  if (references.length === 0) {
380
391
  return (0, neverthrow_1.okAsync)({ snapshot, resolvedReferences: [] });
381
392
  }
382
- return neverthrow_1.ResultAsync.fromPromise((0, v2_reference_resolver_js_1.resolveWorkflowReferences)(references, workspacePath), () => ({ kind: 'reference_resolution_failed' })).map((result) => {
393
+ const allUnresolved = references.map((ref) => ({
394
+ id: ref.id,
395
+ title: ref.title,
396
+ source: ref.source,
397
+ purpose: ref.purpose,
398
+ authoritative: ref.authoritative,
399
+ resolveFrom: (ref.resolveFrom ?? 'workspace'),
400
+ status: 'unresolved',
401
+ }));
402
+ const resolutionPromise = (0, with_timeout_js_1.withTimeout)((0, v2_reference_resolver_js_1.resolveWorkflowReferences)(references, workspacePath), REFERENCE_RESOLUTION_TIMEOUT_MS, 'reference_resolution').catch(() => null);
403
+ return neverthrow_1.ResultAsync.fromPromise(resolutionPromise, () => ({ kind: 'reference_resolution_failed' })).map((result) => {
404
+ if (result === null) {
405
+ console.warn('[workrail:reference-resolution] timed out; all references marked unresolved');
406
+ return {
407
+ snapshot: { ...snapshot, resolvedReferences: [...allUnresolved] },
408
+ resolvedReferences: allUnresolved,
409
+ };
410
+ }
383
411
  for (const warning of result.warnings) {
384
412
  console.warn(`[workrail:reference-resolution] ${warning.message}`);
385
413
  }
@@ -15,6 +15,7 @@ const neverthrow_1 = require("neverthrow");
15
15
  const types_js_1 = require("../types.js");
16
16
  const error_mapper_js_1 = require("../error-mapper.js");
17
17
  const v2_execution_helpers_js_1 = require("./v2-execution-helpers.js");
18
+ const assert_never_js_1 = require("../../runtime/assert-never.js");
18
19
  const v1_to_v2_shim_js_1 = require("../../v2/read-only/v1-to-v2-shim.js");
19
20
  const hashing_js_1 = require("../../v2/durable-core/canonical/hashing.js");
20
21
  const TIMEOUT_MS = 30000;
@@ -35,8 +36,7 @@ function readCurrentSpecVersion() {
35
36
  }
36
37
  }
37
38
  const CURRENT_SPEC_VERSION = readCurrentSpecVersion();
38
- const DEV_STALENESS = process.env['WORKRAIL_DEV_STALENESS'] === '1';
39
- function shouldShowStaleness(category, devMode = DEV_STALENESS) {
39
+ function shouldShowStaleness(category, devMode = (0, dev_mode_js_1.isDevMode)()) {
40
40
  if (devMode)
41
41
  return true;
42
42
  return category === 'personal' || category === 'rooted_sharing' || category === 'external';
@@ -96,6 +96,7 @@ function computeWorkflowStaleness(stamp, currentVersion) {
96
96
  specVersionAtLastReview: stamp,
97
97
  };
98
98
  }
99
+ const dev_mode_js_1 = require("../dev-mode.js");
99
100
  const with_timeout_js_1 = require("./shared/with-timeout.js");
100
101
  const request_workflow_reader_js_1 = require("./shared/request-workflow-reader.js");
101
102
  const remembered_roots_js_1 = require("./shared/remembered-roots.js");
@@ -443,6 +444,7 @@ function deriveSourceCatalogEntry(options) {
443
444
  case 'plugin':
444
445
  return { sourceKey, category: 'external', source: { kind: source.kind, displayName }, sourceMode: 'live_directory', effectiveWorkflowCount: effective, totalWorkflowCount: total, shadowedWorkflowCount: shadowed };
445
446
  }
447
+ (0, assert_never_js_1.assertNever)(source);
446
448
  }
447
449
  function deriveSourceKey(source) {
448
450
  switch (source.kind) {
@@ -1368,7 +1368,7 @@ export declare const V2BindingDriftWarningSchema: z.ZodObject<{
1368
1368
  currentValue: string;
1369
1369
  }>;
1370
1370
  export declare const V2StepContextSchema: z.ZodObject<{
1371
- assessments: z.ZodOptional<z.ZodObject<{
1371
+ assessments: z.ZodOptional<z.ZodArray<z.ZodObject<{
1372
1372
  assessmentId: z.ZodString;
1373
1373
  dimensions: z.ZodArray<z.ZodObject<{
1374
1374
  dimensionId: z.ZodString;
@@ -1400,7 +1400,7 @@ export declare const V2StepContextSchema: z.ZodObject<{
1400
1400
  rationale?: string | undefined;
1401
1401
  }[];
1402
1402
  normalizationNotes: readonly string[];
1403
- }>>;
1403
+ }>, "many">>;
1404
1404
  }, "strip", z.ZodTypeAny, {
1405
1405
  assessments?: {
1406
1406
  assessmentId: string;
@@ -1410,7 +1410,7 @@ export declare const V2StepContextSchema: z.ZodObject<{
1410
1410
  rationale?: string | undefined;
1411
1411
  }[];
1412
1412
  normalizationNotes: readonly string[];
1413
- } | undefined;
1413
+ }[] | undefined;
1414
1414
  }, {
1415
1415
  assessments?: {
1416
1416
  assessmentId: string;
@@ -1420,7 +1420,7 @@ export declare const V2StepContextSchema: z.ZodObject<{
1420
1420
  rationale?: string | undefined;
1421
1421
  }[];
1422
1422
  normalizationNotes: readonly string[];
1423
- } | undefined;
1423
+ }[] | undefined;
1424
1424
  }>;
1425
1425
  export declare const V2ContinueWorkflowOutputSchema: z.ZodEffects<z.ZodDiscriminatedUnion<"kind", [z.ZodObject<{
1426
1426
  kind: z.ZodLiteral<"ok">;
@@ -1491,7 +1491,7 @@ export declare const V2ContinueWorkflowOutputSchema: z.ZodEffects<z.ZodDiscrimin
1491
1491
  currentValue: string;
1492
1492
  }>, "many">>;
1493
1493
  stepContext: z.ZodOptional<z.ZodObject<{
1494
- assessments: z.ZodOptional<z.ZodObject<{
1494
+ assessments: z.ZodOptional<z.ZodArray<z.ZodObject<{
1495
1495
  assessmentId: z.ZodString;
1496
1496
  dimensions: z.ZodArray<z.ZodObject<{
1497
1497
  dimensionId: z.ZodString;
@@ -1523,7 +1523,7 @@ export declare const V2ContinueWorkflowOutputSchema: z.ZodEffects<z.ZodDiscrimin
1523
1523
  rationale?: string | undefined;
1524
1524
  }[];
1525
1525
  normalizationNotes: readonly string[];
1526
- }>>;
1526
+ }>, "many">>;
1527
1527
  }, "strip", z.ZodTypeAny, {
1528
1528
  assessments?: {
1529
1529
  assessmentId: string;
@@ -1533,7 +1533,7 @@ export declare const V2ContinueWorkflowOutputSchema: z.ZodEffects<z.ZodDiscrimin
1533
1533
  rationale?: string | undefined;
1534
1534
  }[];
1535
1535
  normalizationNotes: readonly string[];
1536
- } | undefined;
1536
+ }[] | undefined;
1537
1537
  }, {
1538
1538
  assessments?: {
1539
1539
  assessmentId: string;
@@ -1543,7 +1543,7 @@ export declare const V2ContinueWorkflowOutputSchema: z.ZodEffects<z.ZodDiscrimin
1543
1543
  rationale?: string | undefined;
1544
1544
  }[];
1545
1545
  normalizationNotes: readonly string[];
1546
- } | undefined;
1546
+ }[] | undefined;
1547
1547
  }>>;
1548
1548
  }, "strip", z.ZodTypeAny, {
1549
1549
  kind: "ok";
@@ -1582,7 +1582,7 @@ export declare const V2ContinueWorkflowOutputSchema: z.ZodEffects<z.ZodDiscrimin
1582
1582
  rationale?: string | undefined;
1583
1583
  }[];
1584
1584
  normalizationNotes: readonly string[];
1585
- } | undefined;
1585
+ }[] | undefined;
1586
1586
  } | undefined;
1587
1587
  }, {
1588
1588
  kind: "ok";
@@ -1621,7 +1621,7 @@ export declare const V2ContinueWorkflowOutputSchema: z.ZodEffects<z.ZodDiscrimin
1621
1621
  rationale?: string | undefined;
1622
1622
  }[];
1623
1623
  normalizationNotes: readonly string[];
1624
- } | undefined;
1624
+ }[] | undefined;
1625
1625
  } | undefined;
1626
1626
  }>, z.ZodObject<{
1627
1627
  kind: z.ZodLiteral<"blocked">;
@@ -2058,7 +2058,7 @@ export declare const V2ContinueWorkflowOutputSchema: z.ZodEffects<z.ZodDiscrimin
2058
2058
  rationale?: string | undefined;
2059
2059
  }[];
2060
2060
  normalizationNotes: readonly string[];
2061
- } | undefined;
2061
+ }[] | undefined;
2062
2062
  } | undefined;
2063
2063
  } | {
2064
2064
  kind: "blocked";
@@ -2155,7 +2155,7 @@ export declare const V2ContinueWorkflowOutputSchema: z.ZodEffects<z.ZodDiscrimin
2155
2155
  rationale?: string | undefined;
2156
2156
  }[];
2157
2157
  normalizationNotes: readonly string[];
2158
- } | undefined;
2158
+ }[] | undefined;
2159
2159
  } | undefined;
2160
2160
  } | {
2161
2161
  kind: "blocked";
@@ -2443,6 +2443,7 @@ export declare const V2StartWorkflowOutputSchema: z.ZodEffects<z.ZodObject<{
2443
2443
  tool: "continue_workflow";
2444
2444
  }>>;
2445
2445
  staleRoots: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
2446
+ warnings: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
2446
2447
  }, "strip", z.ZodTypeAny, {
2447
2448
  pending: {
2448
2449
  stepId: string;
@@ -2462,6 +2463,7 @@ export declare const V2StartWorkflowOutputSchema: z.ZodEffects<z.ZodObject<{
2462
2463
  };
2463
2464
  tool: "continue_workflow";
2464
2465
  } | null;
2466
+ warnings?: string[] | undefined;
2465
2467
  continueToken?: string | undefined;
2466
2468
  checkpointToken?: string | undefined;
2467
2469
  staleRoots?: string[] | undefined;
@@ -2484,6 +2486,7 @@ export declare const V2StartWorkflowOutputSchema: z.ZodEffects<z.ZodObject<{
2484
2486
  };
2485
2487
  tool: "continue_workflow";
2486
2488
  } | null;
2489
+ warnings?: string[] | undefined;
2487
2490
  continueToken?: string | undefined;
2488
2491
  checkpointToken?: string | undefined;
2489
2492
  staleRoots?: string[] | undefined;
@@ -2506,6 +2509,7 @@ export declare const V2StartWorkflowOutputSchema: z.ZodEffects<z.ZodObject<{
2506
2509
  };
2507
2510
  tool: "continue_workflow";
2508
2511
  } | null;
2512
+ warnings?: string[] | undefined;
2509
2513
  continueToken?: string | undefined;
2510
2514
  checkpointToken?: string | undefined;
2511
2515
  staleRoots?: string[] | undefined;
@@ -2528,6 +2532,7 @@ export declare const V2StartWorkflowOutputSchema: z.ZodEffects<z.ZodObject<{
2528
2532
  };
2529
2533
  tool: "continue_workflow";
2530
2534
  } | null;
2535
+ warnings?: string[] | undefined;
2531
2536
  continueToken?: string | undefined;
2532
2537
  checkpointToken?: string | undefined;
2533
2538
  staleRoots?: string[] | undefined;
@@ -288,18 +288,17 @@ exports.V2BindingDriftWarningSchema = zod_1.z.object({
288
288
  pinnedValue: zod_1.z.string().min(1),
289
289
  currentValue: zod_1.z.string().min(1),
290
290
  });
291
+ const V2StepContextAssessmentSchema = zod_1.z.object({
292
+ assessmentId: zod_1.z.string().min(1),
293
+ dimensions: zod_1.z.array(zod_1.z.object({
294
+ dimensionId: zod_1.z.string().min(1),
295
+ level: zod_1.z.string().min(1),
296
+ rationale: zod_1.z.string().optional(),
297
+ })),
298
+ normalizationNotes: zod_1.z.array(zod_1.z.string()).readonly(),
299
+ });
291
300
  exports.V2StepContextSchema = zod_1.z.object({
292
- assessments: zod_1.z
293
- .object({
294
- assessmentId: zod_1.z.string().min(1),
295
- dimensions: zod_1.z.array(zod_1.z.object({
296
- dimensionId: zod_1.z.string().min(1),
297
- level: zod_1.z.string().min(1),
298
- rationale: zod_1.z.string().optional(),
299
- })),
300
- normalizationNotes: zod_1.z.array(zod_1.z.string()).readonly(),
301
- })
302
- .optional(),
301
+ assessments: zod_1.z.array(V2StepContextAssessmentSchema).optional(),
303
302
  });
304
303
  const V2ContinueWorkflowOkSchema = zod_1.z.object({
305
304
  kind: zod_1.z.literal('ok'),
@@ -392,6 +391,8 @@ exports.V2StartWorkflowOutputSchema = zod_1.z.object({
392
391
  staleRoots: zod_1.z.array(zod_1.z.string()).optional().describe('Workflow source paths that were inaccessible during discovery (missing remembered roots or missing managed source directories). ' +
393
392
  'Workflows from these paths were not included in this response. ' +
394
393
  'These paths will be rechecked on the next call.'),
394
+ warnings: zod_1.z.array(zod_1.z.string()).optional().describe('Non-fatal warnings about workflow source availability. ' +
395
+ 'The workflow was started successfully but some sources may have been unavailable (e.g., managed source store temporarily inaccessible).'),
395
396
  }).refine((data) => (data.pending ? data.continueToken != null : true), { message: 'continueToken is required when a pending step exists' });
396
397
  exports.CreateSessionOutputSchema = zod_1.z.object({
397
398
  sessionId: zod_1.z.string().min(1),
@@ -217,10 +217,11 @@ async function composeServer() {
217
217
  server.setRequestHandler(ListToolsRequestSchema, async () => ({
218
218
  tools,
219
219
  }));
220
- const timingSink = dev_mode_js_1.DEV_MODE
220
+ const devMode = (0, dev_mode_js_1.isDevMode)();
221
+ const timingSink = devMode
221
222
  ? (0, tool_call_timing_js_1.composeSinks)((0, tool_call_timing_js_1.createRingBufferSink)(timingRingBuffer), (0, tool_call_timing_js_1.createDevPerfSink)())
222
223
  : (0, tool_call_timing_js_1.createRingBufferSink)(timingRingBuffer);
223
- if (dev_mode_js_1.DEV_MODE) {
224
+ if (devMode) {
224
225
  console.error('[PerfTrace] WORKRAIL_DEV=1 -- tool call timing active');
225
226
  }
226
227
  server.setRequestHandler(CallToolRequestSchema, async (request) => {
@@ -8,5 +8,5 @@ export interface FormattedResponse {
8
8
  readonly references?: FormattedReferences;
9
9
  readonly supplements?: readonly FormattedSupplement[];
10
10
  }
11
- export declare function formatV2ExecutionResponse(data: unknown): FormattedResponse | null;
11
+ export declare function formatV2ExecutionResponse(data: unknown, cleanResponseFormat: boolean): FormattedResponse | null;
12
12
  export declare function formatV2ResumeResponse(data: unknown): FormattedResponse | null;
@@ -4,7 +4,6 @@ exports.formatV2ExecutionResponse = formatV2ExecutionResponse;
4
4
  exports.formatV2ResumeResponse = formatV2ResumeResponse;
5
5
  const render_envelope_js_1 = require("./render-envelope.js");
6
6
  const response_supplements_js_1 = require("./response-supplements.js");
7
- const env_flags_js_1 = require("../env-flags.js");
8
7
  function isV2ExecutionResponse(data) {
9
8
  if (typeof data !== 'object' || data === null)
10
9
  return false;
@@ -348,11 +347,11 @@ function renderReferencesSection(contentEnvelope, lifecycle) {
348
347
  return null;
349
348
  }
350
349
  }
351
- function formatV2ExecutionResponse(data) {
350
+ function formatV2ExecutionResponse(data, cleanResponseFormat) {
352
351
  const renderInput = deriveRenderInput(data);
353
352
  if (!renderInput)
354
353
  return null;
355
- const cleanFormat = env_flags_js_1.CLEAN_RESPONSE_FORMAT;
354
+ const cleanFormat = cleanResponseFormat;
356
355
  const { response, lifecycle, contentEnvelope } = renderInput;
357
356
  const references = renderReferencesSection(contentEnvelope, lifecycle);
358
357
  if (cleanFormat) {
@@ -110,13 +110,15 @@ export interface WorkflowRecommendedPreferences {
110
110
  readonly recommendedAutonomy?: 'guided' | 'full_auto_stop_on_user_deps' | 'full_auto_never_stop';
111
111
  readonly recommendedRiskPolicy?: 'conservative' | 'balanced' | 'aggressive';
112
112
  }
113
+ export declare const RESOLVE_FROM_VALUES: readonly ["workspace", "package"];
114
+ export type ResolveFrom = typeof RESOLVE_FROM_VALUES[number];
113
115
  export interface WorkflowReference {
114
116
  readonly id: string;
115
117
  readonly title: string;
116
118
  readonly source: string;
117
119
  readonly purpose: string;
118
120
  readonly authoritative: boolean;
119
- readonly resolveFrom?: 'workspace' | 'package';
121
+ readonly resolveFrom?: ResolveFrom;
120
122
  }
121
123
  export interface WorkflowDefinition {
122
124
  readonly id: string;
@@ -1,10 +1,12 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.RESOLVE_FROM_VALUES = void 0;
3
4
  exports.isLoopStepDefinition = isLoopStepDefinition;
4
5
  exports.isWorkflowStepDefinition = isWorkflowStepDefinition;
5
6
  exports.stepHasPromptSource = stepHasPromptSource;
6
7
  exports.hasWorkflowDefinitionShape = hasWorkflowDefinitionShape;
7
8
  exports.createWorkflowDefinition = createWorkflowDefinition;
9
+ exports.RESOLVE_FROM_VALUES = ['workspace', 'package'];
8
10
  function isLoopStepDefinition(step) {
9
11
  return 'type' in step && step.type === 'loop';
10
12
  }
@@ -25,4 +25,5 @@ export declare function renderPendingPrompt(args: {
25
25
  readonly nodeId: NodeId;
26
26
  readonly rehydrateOnly: boolean;
27
27
  readonly precomputedIndex?: import('../session-index.js').SessionIndex;
28
+ readonly cleanResponseFormat?: boolean;
28
29
  }): Result<StepMetadata, PromptRenderError>;
@@ -17,7 +17,6 @@ const sorted_event_log_js_1 = require("../sorted-event-log.js");
17
17
  const condition_evaluator_js_1 = require("../../../utils/condition-evaluator.js");
18
18
  const context_template_resolver_js_1 = require("./context-template-resolver.js");
19
19
  const retrieval_contract_js_1 = require("./retrieval-contract.js");
20
- const env_flags_js_1 = require("../../../env-flags.js");
21
20
  function buildNonTipSegments(args) {
22
21
  const segments = [];
23
22
  const childSummary = (0, recap_recovery_js_1.buildChildSummary)({ nodeId: args.nodeId, dag: args.run });
@@ -178,9 +177,13 @@ function formatOutputContractRequirements(outputContract) {
178
177
  function formatAssessmentRequirements(assessments) {
179
178
  if (assessments.length === 0)
180
179
  return [];
180
+ const multiRef = assessments.length > 1;
181
181
  const requirements = [];
182
182
  for (const assessment of assessments) {
183
183
  requirements.push('Provide an artifact with kind: "wr.assessment"');
184
+ if (multiRef) {
185
+ requirements.push(`Set assessmentId: "${assessment.id}" on the artifact so the engine can match it to the correct assessment.`);
186
+ }
184
187
  requirements.push(`Assessment target: "${assessment.id}"`);
185
188
  requirements.push(`Dimensions: ${assessment.dimensions.map((dimension) => `${dimension.id} (${dimension.levels.join(' | ')})`).join(', ')}`);
186
189
  requirements.push('Use only canonical dimension levels. If the engine rejects the artifact, correct the submitted levels instead of inventing new ones.');
@@ -246,7 +249,7 @@ function renderPendingPrompt(args) {
246
249
  const renderContext = { ...sessionContext, ...loopRenderContext };
247
250
  const basePrompt = (0, context_template_resolver_js_1.resolveContextTemplates)(step.prompt ?? '', renderContext);
248
251
  const baseTitle = (0, context_template_resolver_js_1.resolveContextTemplates)(step.title, renderContext);
249
- const cleanResponseFormat = env_flags_js_1.CLEAN_RESPONSE_FORMAT;
252
+ const cleanResponseFormat = args.cleanResponseFormat ?? false;
250
253
  const loopBanner = buildLoopContextBanner({ loopPath: args.loopPath, isExitStep, maxIterations, cleanFormat: cleanResponseFormat });
251
254
  const validationCriteria = step.validationCriteria;
252
255
  const requirements = (0, validation_requirements_extractor_js_1.extractValidationRequirements)(validationCriteria);
@@ -3,6 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.CompiledWorkflowSnapshotSchema = exports.CompiledWorkflowSnapshotV1Schema = void 0;
4
4
  const zod_1 = require("zod");
5
5
  const json_zod_js_1 = require("../../canonical/json-zod.js");
6
+ const workflow_definition_js_1 = require("../../../../types/workflow-definition.js");
6
7
  const CompiledWorkflowSnapshotV1PreviewSchema = zod_1.z.object({
7
8
  schemaVersion: zod_1.z.literal(1),
8
9
  sourceKind: zod_1.z.literal('v1_preview'),
@@ -33,7 +34,7 @@ const CompiledWorkflowSnapshotV1PinnedSchema = zod_1.z.object({
33
34
  source: zod_1.z.string().min(1),
34
35
  purpose: zod_1.z.string().min(1),
35
36
  authoritative: zod_1.z.boolean(),
36
- resolveFrom: zod_1.z.enum(['workspace', 'package']),
37
+ resolveFrom: zod_1.z.enum(workflow_definition_js_1.RESOLVE_FROM_VALUES),
37
38
  status: zod_1.z.literal('resolved'),
38
39
  resolvedPath: zod_1.z.string().min(1),
39
40
  }),
@@ -43,7 +44,7 @@ const CompiledWorkflowSnapshotV1PinnedSchema = zod_1.z.object({
43
44
  source: zod_1.z.string().min(1),
44
45
  purpose: zod_1.z.string().min(1),
45
46
  authoritative: zod_1.z.boolean(),
46
- resolveFrom: zod_1.z.enum(['workspace', 'package']),
47
+ resolveFrom: zod_1.z.enum(workflow_definition_js_1.RESOLVE_FROM_VALUES),
47
48
  status: zod_1.z.literal('unresolved'),
48
49
  }),
49
50
  zod_1.z.object({
@@ -52,7 +53,7 @@ const CompiledWorkflowSnapshotV1PinnedSchema = zod_1.z.object({
52
53
  source: zod_1.z.string().min(1),
53
54
  purpose: zod_1.z.string().min(1),
54
55
  authoritative: zod_1.z.boolean(),
55
- resolveFrom: zod_1.z.enum(['workspace', 'package']),
56
+ resolveFrom: zod_1.z.enum(workflow_definition_js_1.RESOLVE_FROM_VALUES),
56
57
  status: zod_1.z.literal('pinned'),
57
58
  }),
58
59
  ])).optional(),
@@ -9,5 +9,7 @@ export declare class LocalPinnedWorkflowStoreV2 implements PinnedWorkflowStorePo
9
9
  private readonly fs;
10
10
  constructor(dataDir: DataDirPortV2, fs: FileSystemPortV2);
11
11
  get(workflowHash: WorkflowHash): ResultAsync<CompiledWorkflowSnapshot | null, PinnedWorkflowStoreError>;
12
+ list(): ResultAsync<readonly WorkflowHash[], PinnedWorkflowStoreError>;
13
+ prune(_olderThanMs: number): ResultAsync<number, PinnedWorkflowStoreError>;
12
14
  put(workflowHash: WorkflowHash, compiled: CompiledWorkflowSnapshot): ResultAsync<void, PinnedWorkflowStoreError>;
13
15
  }