@atolis-hq/wake 0.4.102 → 0.4.104

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 (48) hide show
  1. package/dist/src/activities/pr/policy.d.ts +2 -0
  2. package/dist/src/activities/pr/policy.js +9 -1
  3. package/dist/src/bootstrap/artifact-mcp.js +20 -1
  4. package/dist/src/bootstrap/surface-api-delivery.js +6 -2
  5. package/dist/src/bootstrap/version.js +1 -1
  6. package/dist/src/integrations/application/delegation-outputs.js +41 -5
  7. package/dist/src/orchestration/application/conversation-command-reactor.js +25 -0
  8. package/dist/src/orchestration/application/delegated-work.d.ts +55 -2
  9. package/dist/src/orchestration/application/delegated-work.js +170 -23
  10. package/dist/src/orchestration/application/delegation-attention-escalations.d.ts +11 -0
  11. package/dist/src/orchestration/application/delegation-attention-escalations.js +36 -0
  12. package/dist/src/orchestration/application/delegation-attention-state.d.ts +53 -0
  13. package/dist/src/orchestration/application/delegation-attention-state.js +194 -0
  14. package/dist/src/orchestration/application/delegation-attention.d.ts +58 -0
  15. package/dist/src/orchestration/application/delegation-attention.js +206 -0
  16. package/dist/src/orchestration/application/delegation-commands.d.ts +52 -1
  17. package/dist/src/orchestration/application/delegation-commands.js +22 -3
  18. package/dist/src/orchestration/application/delegation-gate.d.ts +8 -3
  19. package/dist/src/orchestration/application/delegation-gate.js +45 -11
  20. package/dist/src/orchestration/application/delegation-ledger.d.ts +2 -0
  21. package/dist/src/orchestration/application/delegation-ledger.js +8 -0
  22. package/dist/src/orchestration/application/delegation-prerequisites.d.ts +28 -0
  23. package/dist/src/orchestration/application/delegation-prerequisites.js +118 -0
  24. package/dist/src/orchestration/application/delegation-reservation.js +1 -1
  25. package/dist/src/orchestration/application/delegation-wait-graph.d.ts +7 -0
  26. package/dist/src/orchestration/application/delegation-wait-graph.js +122 -0
  27. package/dist/src/orchestration/application/orchestration-repository.d.ts +5 -0
  28. package/dist/src/orchestration/application/orchestration-repository.js +3 -0
  29. package/dist/src/orchestration/application/orchestration-service.d.ts +103 -1
  30. package/dist/src/orchestration/application/orchestration-service.js +40 -2
  31. package/dist/src/orchestration/application/prerequisite-readiness.d.ts +68 -0
  32. package/dist/src/orchestration/application/prerequisite-readiness.js +217 -0
  33. package/dist/src/orchestration/contracts/delegation-ports.d.ts +2 -1
  34. package/dist/src/orchestration/contracts/delegation.d.ts +150 -0
  35. package/dist/src/orchestration/contracts/delegation.js +84 -1
  36. package/dist/src/orchestration/contracts/event-decoder.js +11 -1
  37. package/dist/src/orchestration/contracts/event-factory.js +12 -5
  38. package/dist/src/orchestration/contracts/events.d.ts +27 -1
  39. package/dist/src/orchestration/contracts/events.js +6 -0
  40. package/dist/src/orchestration/contracts/views.d.ts +6 -0
  41. package/dist/src/orchestration/contracts/vocabulary.d.ts +45 -0
  42. package/dist/src/orchestration/contracts/vocabulary.js +41 -0
  43. package/dist/src/orchestration/domain/workflow-instance-events.d.ts +1 -0
  44. package/dist/src/orchestration/domain/workflow-instance-events.js +31 -0
  45. package/dist/src/orchestration/index.d.ts +3 -3
  46. package/dist/src/orchestration/index.js +2 -2
  47. package/dist/src/surfaces/mcp/delegation.js +37 -10
  48. package/package.json +1 -1
@@ -3,16 +3,22 @@ import type { ActivationId, ActivityName, ActivityOutcome, ActivityOutcomeKind }
3
3
  import type { WorkItemId } from '../../work/index.js';
4
4
  import type { OrchestrationWaitingActivityOutcome } from './activity-outcome.js';
5
5
  import type { ApprovalAuthority, CompiledResourceTransition, CompiledWorkflow, StageConfig, TransitionTarget } from './config.js';
6
- import type { DelegationReservation, DelegationResult } from './delegation.js';
6
+ import type { DelegationAttentionRequest, DelegationAttentionResponse, DelegationInputs, DelegationReservation, DelegationResult } from './delegation.js';
7
7
  import type { CommandName, OrchestrationGroupId, SignalName, StageName, WorkflowInstanceId, WorkflowName } from './identifiers.js';
8
8
  import type { ChildOrchestrationGroupStreamId, ChildOrchestrationGroupStreamRef, PrimaryOrchestrationGroupStreamRef, WorkflowDefinitionsStreamRef, WorkflowInstanceStreamRef } from './streams.js';
9
9
  export declare const OrchestrationEventType: {
10
10
  readonly DelegationReserved: "orchestration.delegation-reserved";
11
+ readonly DelegationInputsResolved: "orchestration.delegation-inputs-resolved";
12
+ readonly DelegationChildBlocked: "orchestration.delegation-child-blocked";
13
+ readonly DelegationPrerequisiteBlocked: "orchestration.delegation-prerequisite-blocked";
11
14
  readonly DelegationRegistered: "orchestration.delegation-registered";
12
15
  readonly DelegationResultSelected: "orchestration.delegation-result-selected";
13
16
  readonly DelegationWaitStarted: "orchestration.delegation-wait-started";
14
17
  readonly DelegationJoined: "orchestration.delegation-joined";
15
18
  readonly DelegationFailed: "orchestration.delegation-failed";
19
+ readonly DelegationAttentionRequested: "orchestration.delegation-attention-requested";
20
+ readonly DelegationAttentionResponded: "orchestration.delegation-attention-responded";
21
+ readonly DelegationAttentionResolved: "orchestration.delegation-attention-resolved";
16
22
  readonly DelegationReconciliationFailed: "orchestration.delegation-reconciliation-failed";
17
23
  readonly WorkflowDefinitionRegistered: "orchestration.workflow-definition-registered";
18
24
  readonly InstanceStarted: "orchestration.instance-started";
@@ -53,7 +59,27 @@ export interface DeferredWorkflowSignal {
53
59
  readonly target?: TransitionTarget;
54
60
  }
55
61
  export interface OrchestrationEventPayloads {
62
+ readonly [OrchestrationEventType.DelegationChildBlocked]: {
63
+ readonly childWorkItemId: WorkItemId;
64
+ readonly reason: string;
65
+ };
66
+ readonly [OrchestrationEventType.DelegationInputsResolved]: DelegationInputs;
67
+ readonly [OrchestrationEventType.DelegationPrerequisiteBlocked]: {
68
+ readonly childWorkItemId: WorkItemId;
69
+ readonly reason: string;
70
+ };
56
71
  readonly [OrchestrationEventType.SignalDeferred]: DeferredWorkflowSignal;
72
+ readonly [OrchestrationEventType.DelegationAttentionRequested]: DelegationAttentionRequest;
73
+ readonly [OrchestrationEventType.DelegationAttentionResponded]: DelegationAttentionResponse;
74
+ readonly [OrchestrationEventType.DelegationAttentionResolved]: {
75
+ readonly cohortId: string;
76
+ readonly attentionKey: string;
77
+ readonly activationId: ActivationId;
78
+ /** The batched human question, published through the ordinary accepted-outcome route. */
79
+ readonly escalation?: string;
80
+ /** The assessment run itself failed; the cohort is untouched and may be re-assessed. */
81
+ readonly assessmentFailure?: string;
82
+ };
57
83
  readonly [OrchestrationEventType.DelegationFailed]: {
58
84
  readonly cohortId: string;
59
85
  readonly reason: string;
@@ -1,11 +1,17 @@
1
1
  import { signalName } from './identifiers.js';
2
2
  export const OrchestrationEventType = {
3
3
  DelegationReserved: 'orchestration.delegation-reserved',
4
+ DelegationInputsResolved: 'orchestration.delegation-inputs-resolved',
5
+ DelegationChildBlocked: 'orchestration.delegation-child-blocked',
6
+ DelegationPrerequisiteBlocked: 'orchestration.delegation-prerequisite-blocked',
4
7
  DelegationRegistered: 'orchestration.delegation-registered',
5
8
  DelegationResultSelected: 'orchestration.delegation-result-selected',
6
9
  DelegationWaitStarted: 'orchestration.delegation-wait-started',
7
10
  DelegationJoined: 'orchestration.delegation-joined',
8
11
  DelegationFailed: 'orchestration.delegation-failed',
12
+ DelegationAttentionRequested: 'orchestration.delegation-attention-requested',
13
+ DelegationAttentionResponded: 'orchestration.delegation-attention-responded',
14
+ DelegationAttentionResolved: 'orchestration.delegation-attention-resolved',
9
15
  DelegationReconciliationFailed: 'orchestration.delegation-reconciliation-failed',
10
16
  WorkflowDefinitionRegistered: 'orchestration.workflow-definition-registered',
11
17
  InstanceStarted: 'orchestration.instance-started',
@@ -54,6 +54,12 @@ export interface WorkflowInstanceView {
54
54
  readonly cohortId: string;
55
55
  readonly activationId: ActivationId;
56
56
  };
57
+ /** Set while a coalesced attention activation owns the parent; the cohort wait is suspended. */
58
+ readonly delegationAttention?: {
59
+ readonly cohortId: string;
60
+ readonly attentionKey: string;
61
+ readonly activationId: ActivationId;
62
+ };
57
63
  readonly delegationWait?: {
58
64
  readonly cohortId: string;
59
65
  readonly activationId: ActivationId;
@@ -50,3 +50,48 @@ export type ConversationSurfaceCapability = ValueOf<typeof ConversationSurfaceCa
50
50
  export declare const DelegationOutputKind: {
51
51
  readonly Change: "change";
52
52
  };
53
+ export declare const DelegationPrerequisiteCondition: {
54
+ readonly AcceptedOutput: "accepted-output";
55
+ readonly PushedChange: "pushed-change";
56
+ readonly DeliveryReady: "delivery-ready";
57
+ readonly MergedChange: "merged-change";
58
+ };
59
+ export declare const DelegationBlockerKind: {
60
+ /** Terminal failure, cancellation, exhausted budget or a changed consumed input. */
61
+ readonly Failed: "failed";
62
+ /** A child workflow blocked for assignment clarification the parent may answer. */
63
+ readonly Context: "assignment-context";
64
+ };
65
+ export type DelegationBlockerKind = ValueOf<typeof DelegationBlockerKind>;
66
+ export declare const DelegationAttentionRejection: {
67
+ readonly NoAttention: "no-attention";
68
+ readonly OutsideHierarchy: "outside-hierarchy";
69
+ readonly UnknownBlocker: "unknown-blocker";
70
+ readonly NotAnswerable: "not-answerable";
71
+ readonly StaleRevision: "stale-revision";
72
+ readonly NotBlocked: "not-blocked";
73
+ readonly Duplicate: "duplicate";
74
+ };
75
+ export type DelegationAttentionRejection = ValueOf<typeof DelegationAttentionRejection>;
76
+ export declare const DelegationConflictCode: {
77
+ readonly SelfDependency: "self-dependency";
78
+ readonly MissingTarget: "missing-target";
79
+ readonly MissingOutput: "missing-output";
80
+ readonly OutputKind: "output-kind";
81
+ readonly CrossRepositoryBase: "cross-repository-base";
82
+ readonly CrossRepositoryChange: "cross-repository-change";
83
+ readonly MultipleBases: "multiple-bases";
84
+ readonly WaitCycle: "wait-cycle";
85
+ readonly StalePlan: "stale-plan";
86
+ readonly AttentionOpen: "attention-open";
87
+ };
88
+ export type DelegationConflictCode = ValueOf<typeof DelegationConflictCode>;
89
+ export declare const PrerequisiteBlockCode: {
90
+ readonly Waiting: "prerequisite-waiting";
91
+ readonly Changed: "prerequisite-changed";
92
+ readonly Failed: "prerequisite-failed";
93
+ readonly Unavailable: "prerequisite-unavailable";
94
+ readonly Cycle: "prerequisite-cycle";
95
+ readonly Blocked: "prerequisite-blocked";
96
+ };
97
+ export type PrerequisiteBlockCode = ValueOf<typeof PrerequisiteBlockCode>;
@@ -43,3 +43,44 @@ export const ConversationSurfaceCapability = defineClosedVocabulary({
43
43
  Operator: 'operator-surface',
44
44
  });
45
45
  export const DelegationOutputKind = defineClosedVocabulary({ Change: 'change' });
46
+ export const DelegationPrerequisiteCondition = defineClosedVocabulary({
47
+ AcceptedOutput: 'accepted-output',
48
+ PushedChange: 'pushed-change',
49
+ DeliveryReady: 'delivery-ready',
50
+ MergedChange: 'merged-change',
51
+ });
52
+ export const DelegationBlockerKind = defineClosedVocabulary({
53
+ /** Terminal failure, cancellation, exhausted budget or a changed consumed input. */
54
+ Failed: 'failed',
55
+ /** A child workflow blocked for assignment clarification the parent may answer. */
56
+ Context: 'assignment-context',
57
+ });
58
+ export const DelegationAttentionRejection = defineClosedVocabulary({
59
+ NoAttention: 'no-attention',
60
+ OutsideHierarchy: 'outside-hierarchy',
61
+ UnknownBlocker: 'unknown-blocker',
62
+ NotAnswerable: 'not-answerable',
63
+ StaleRevision: 'stale-revision',
64
+ NotBlocked: 'not-blocked',
65
+ Duplicate: 'duplicate',
66
+ });
67
+ export const DelegationConflictCode = defineClosedVocabulary({
68
+ SelfDependency: 'self-dependency',
69
+ MissingTarget: 'missing-target',
70
+ MissingOutput: 'missing-output',
71
+ OutputKind: 'output-kind',
72
+ CrossRepositoryBase: 'cross-repository-base',
73
+ CrossRepositoryChange: 'cross-repository-change',
74
+ MultipleBases: 'multiple-bases',
75
+ WaitCycle: 'wait-cycle',
76
+ StalePlan: 'stale-plan',
77
+ AttentionOpen: 'attention-open',
78
+ });
79
+ export const PrerequisiteBlockCode = defineClosedVocabulary({
80
+ Waiting: 'prerequisite-waiting',
81
+ Changed: 'prerequisite-changed',
82
+ Failed: 'prerequisite-failed',
83
+ Unavailable: 'prerequisite-unavailable',
84
+ Cycle: 'prerequisite-cycle',
85
+ Blocked: 'prerequisite-blocked',
86
+ });
@@ -24,6 +24,7 @@ export type MutableWorkflowInstance = {
24
24
  requestId?: string;
25
25
  delegationFence?: WorkflowInstanceView['delegationFence'];
26
26
  delegationWait?: WorkflowInstanceView['delegationWait'];
27
+ delegationAttention?: WorkflowInstanceView['delegationAttention'];
27
28
  status: WorkflowInstanceView['status'];
28
29
  blockReason?: string;
29
30
  currentStage: WorkflowInstanceView['currentStage'];
@@ -129,12 +129,14 @@ function applyLifecycleFact(state, event) {
129
129
  return;
130
130
  case OrchestrationEventType.InstanceCompleted:
131
131
  delete state.delegationWait;
132
+ delete state.delegationAttention;
132
133
  state.status = orchestrationStatusTransitions[OrchestrationEventType.InstanceCompleted];
133
134
  delete state.pendingActivation;
134
135
  delete state.waitingFor;
135
136
  return;
136
137
  case OrchestrationEventType.InstanceBlocked:
137
138
  delete state.delegationWait;
139
+ delete state.delegationAttention;
138
140
  state.status = orchestrationStatusTransitions[OrchestrationEventType.InstanceBlocked];
139
141
  state.blockReason = event.payload.reason;
140
142
  return;
@@ -143,6 +145,7 @@ function applyLifecycleFact(state, event) {
143
145
  return;
144
146
  case OrchestrationEventType.InstanceSuperseded:
145
147
  delete state.delegationWait;
148
+ delete state.delegationAttention;
146
149
  state.status = orchestrationStatusTransitions[OrchestrationEventType.InstanceSuperseded];
147
150
  return;
148
151
  default:
@@ -152,6 +155,7 @@ function applyLifecycleFact(state, event) {
152
155
  function applyDelegationFact(state, event) {
153
156
  if (event.eventType === OrchestrationEventType.DelegationJoined) {
154
157
  delete state.delegationWait;
158
+ delete state.delegationAttention;
155
159
  delete state.delegationFence;
156
160
  return;
157
161
  }
@@ -168,6 +172,27 @@ function applyCoordinationFact(state, event) {
168
172
  case OrchestrationEventType.GroupBudgetExhausted:
169
173
  case OrchestrationEventType.DelegationFailed:
170
174
  delete state.delegationFence;
175
+ delete state.delegationAttention;
176
+ return;
177
+ case OrchestrationEventType.DelegationAttentionRequested:
178
+ state.delegationAttention = {
179
+ cohortId: event.payload.cohortId,
180
+ attentionKey: event.payload.attentionKey,
181
+ activationId: event.payload.activationId,
182
+ };
183
+ return;
184
+ case OrchestrationEventType.DelegationAttentionResolved:
185
+ // The assessment is not an outcome route: the unresolved cohort wait is simply restored.
186
+ if (state.delegationAttention?.attentionKey !== event.payload.attentionKey)
187
+ return;
188
+ delete state.delegationAttention;
189
+ if (!state.acceptedOutcomes.includes(event.payload.activationId))
190
+ state.acceptedOutcomes.push(event.payload.activationId);
191
+ updateActivationStatus(state, event.payload.activationId, ActivityActivationStatus.Completed);
192
+ if (state.delegationWait !== undefined)
193
+ state.status = WorkflowStatus.Waiting;
194
+ return;
195
+ case OrchestrationEventType.DelegationAttentionResponded:
171
196
  return;
172
197
  case OrchestrationEventType.DelegationReconciliationFailed:
173
198
  case OrchestrationEventType.SignalDeferred:
@@ -180,6 +205,9 @@ function applyCoordinationFact(state, event) {
180
205
  };
181
206
  return;
182
207
  case OrchestrationEventType.DelegationRegistered:
208
+ case OrchestrationEventType.DelegationInputsResolved:
209
+ case OrchestrationEventType.DelegationPrerequisiteBlocked:
210
+ case OrchestrationEventType.DelegationChildBlocked:
183
211
  case OrchestrationEventType.DelegationResultSelected:
184
212
  return;
185
213
  case OrchestrationEventType.DelegationWaitStarted:
@@ -270,6 +298,9 @@ export function immutableWorkflowInstanceView(state) {
270
298
  ...(state.requestId === undefined ? {} : { requestId: state.requestId }),
271
299
  ...(state.delegationFence === undefined ? {} : { delegationFence: state.delegationFence }),
272
300
  ...(state.delegationWait === undefined ? {} : { delegationWait: state.delegationWait }),
301
+ ...(state.delegationAttention === undefined
302
+ ? {}
303
+ : { delegationAttention: state.delegationAttention }),
273
304
  status: state.status,
274
305
  ...(state.blockReason === undefined ? {} : { blockReason: state.blockReason }),
275
306
  currentStage: state.currentStage,
@@ -33,7 +33,7 @@ export * from './domain/workflow-selector.js';
33
33
  export * from './application/work-completion-summary.js';
34
34
  export type { WorkflowCompileDiagnostic } from './domain/compile-diagnostics.js';
35
35
  export type { DelegationArtifacts, DelegationRepositories } from './contracts/delegation-ports.js';
36
- export { DelegationPendingError } from './contracts/delegation.js';
36
+ export { DelegationAttentionError, DelegationConflictError, DelegationPendingError, } from './contracts/delegation.js';
37
37
  export type { DelegationAuthority } from './contracts/delegation-ports.js';
38
- export { delegationSubmissionSchema } from './contracts/delegation.js';
39
- export type { DelegationCaller, DelegationReservation, DelegationSubmission, } from './contracts/delegation.js';
38
+ export { delegationAttentionReplySchema, delegationSubmissionSchema, } from './contracts/delegation.js';
39
+ export type { DelegationAttentionBlocker, DelegationAttentionReply, DelegationAttentionRequest, DelegationCaller, DelegationInputs, DelegationPrerequisite, DelegationReservation, DelegationResult, DelegationSubmission, } from './contracts/delegation.js';
@@ -31,5 +31,5 @@ export * from './domain/interpreter.js';
31
31
  export * from './domain/workflow-instance.js';
32
32
  export * from './domain/workflow-selector.js';
33
33
  export * from './application/work-completion-summary.js';
34
- export { DelegationPendingError } from './contracts/delegation.js';
35
- export { delegationSubmissionSchema } from './contracts/delegation.js';
34
+ export { DelegationAttentionError, DelegationConflictError, DelegationPendingError, } from './contracts/delegation.js';
35
+ export { delegationAttentionReplySchema, delegationSubmissionSchema, } from './contracts/delegation.js';
@@ -1,17 +1,44 @@
1
- import { delegationSubmissionSchema, } from '../../orchestration/index.js';
1
+ import { DelegationAttentionError, DelegationConflictError, delegationAttentionReplySchema, delegationSubmissionSchema, } from '../../orchestration/index.js';
2
2
  /** The bound caller is never accepted as a tool argument. */
3
3
  export function registerDelegationTools(server, input) {
4
4
  server.registerTool('wake_delegation_submit', {
5
- description: 'Submit independent child work under this workflow delegation policy. End the current activity normally after submission; Wake waits and resumes it with joined results.',
5
+ description: 'Submit child work with optional queued named-output prerequisites under this workflow delegation policy. Use expectedPlanRevision from inspection; useAsBase selects only a same-repository upstream change. End the current activity normally after submission; Wake waits and resumes it with joined results or terminal failure facts. Inspect failureReason and blockers before submitting replacement assignments in a new cohort; existing receipts remain immutable.',
6
6
  inputSchema: delegationSubmissionSchema,
7
- }, async (command) => ({
8
- content: [
9
- {
10
- type: 'text',
11
- text: JSON.stringify(await input.orchestration.submitDelegation(await input.caller(), command, input.commandContext())),
12
- },
13
- ],
14
- }));
7
+ }, async (command) => {
8
+ try {
9
+ const reservation = await input.orchestration.submitDelegation(await input.caller(), command, input.commandContext());
10
+ return { content: [{ type: 'text', text: JSON.stringify(reservation) }] };
11
+ }
12
+ catch (error) {
13
+ if (!(error instanceof DelegationConflictError))
14
+ throw error;
15
+ return {
16
+ isError: true,
17
+ content: [
18
+ { type: 'text', text: JSON.stringify({ code: error.code, message: error.message }) },
19
+ ],
20
+ };
21
+ }
22
+ });
23
+ server.registerTool('wake_delegation_respond', {
24
+ description: 'Answer one assignment-context blocker from the attention request returned by wake_delegation_inspect. Name the child, blocker and expectedRevision, and list the exact accepted artifact revisions the child may read. Only a child blocked for assignment context can be resumed; failures need follow-up work in a new cohort and human review, consent or approval gates cannot be answered here. End the activity normally afterwards; unresolved reasons stay tracked and the cohort wait resumes.',
25
+ inputSchema: delegationAttentionReplySchema,
26
+ }, async (reply) => {
27
+ try {
28
+ const attention = await input.orchestration.respondToDelegationAttention(await input.caller(), reply, input.commandContext());
29
+ return { content: [{ type: 'text', text: JSON.stringify(attention) }] };
30
+ }
31
+ catch (error) {
32
+ if (!(error instanceof DelegationAttentionError))
33
+ throw error;
34
+ return {
35
+ isError: true,
36
+ content: [
37
+ { type: 'text', text: JSON.stringify({ code: error.code, message: error.message }) },
38
+ ],
39
+ };
40
+ }
41
+ });
15
42
  server.registerTool('wake_delegation_inspect', {
16
43
  description: 'Inspect this delivery tree, child workflows, results and blockers, and the Repository Resource IDs an explicit repository selection may name.',
17
44
  }, async () => ({
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atolis-hq/wake",
3
- "version": "0.4.102",
3
+ "version": "0.4.104",
4
4
  "description": "Local autonomous agent control plane for software development",
5
5
  "license": "Apache-2.0",
6
6
  "repository": {