@atolis-hq/wake 0.4.103 → 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 (32) hide show
  1. package/dist/src/bootstrap/artifact-mcp.js +20 -1
  2. package/dist/src/bootstrap/version.js +1 -1
  3. package/dist/src/orchestration/application/conversation-command-reactor.js +25 -0
  4. package/dist/src/orchestration/application/delegated-work.d.ts +9 -0
  5. package/dist/src/orchestration/application/delegated-work.js +53 -20
  6. package/dist/src/orchestration/application/delegation-attention-escalations.d.ts +11 -0
  7. package/dist/src/orchestration/application/delegation-attention-escalations.js +36 -0
  8. package/dist/src/orchestration/application/delegation-attention-state.d.ts +53 -0
  9. package/dist/src/orchestration/application/delegation-attention-state.js +194 -0
  10. package/dist/src/orchestration/application/delegation-attention.d.ts +58 -0
  11. package/dist/src/orchestration/application/delegation-attention.js +206 -0
  12. package/dist/src/orchestration/application/delegation-commands.d.ts +5 -1
  13. package/dist/src/orchestration/application/delegation-commands.js +18 -1
  14. package/dist/src/orchestration/application/delegation-gate.d.ts +4 -1
  15. package/dist/src/orchestration/application/delegation-gate.js +15 -3
  16. package/dist/src/orchestration/application/orchestration-service.d.ts +16 -1
  17. package/dist/src/orchestration/application/orchestration-service.js +38 -1
  18. package/dist/src/orchestration/contracts/delegation.d.ts +63 -1
  19. package/dist/src/orchestration/contracts/delegation.js +49 -1
  20. package/dist/src/orchestration/contracts/event-decoder.js +4 -1
  21. package/dist/src/orchestration/contracts/event-factory.js +7 -1
  22. package/dist/src/orchestration/contracts/events.d.ts +15 -1
  23. package/dist/src/orchestration/contracts/events.js +3 -0
  24. package/dist/src/orchestration/contracts/views.d.ts +6 -0
  25. package/dist/src/orchestration/contracts/vocabulary.d.ts +18 -0
  26. package/dist/src/orchestration/contracts/vocabulary.js +16 -0
  27. package/dist/src/orchestration/domain/workflow-instance-events.d.ts +1 -0
  28. package/dist/src/orchestration/domain/workflow-instance-events.js +28 -0
  29. package/dist/src/orchestration/index.d.ts +3 -3
  30. package/dist/src/orchestration/index.js +2 -2
  31. package/dist/src/surfaces/mcp/delegation.js +20 -1
  32. package/package.json +1 -1
@@ -3,7 +3,7 @@ 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 { DelegationInputs, 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: {
@@ -16,6 +16,9 @@ export declare const OrchestrationEventType: {
16
16
  readonly DelegationWaitStarted: "orchestration.delegation-wait-started";
17
17
  readonly DelegationJoined: "orchestration.delegation-joined";
18
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";
19
22
  readonly DelegationReconciliationFailed: "orchestration.delegation-reconciliation-failed";
20
23
  readonly WorkflowDefinitionRegistered: "orchestration.workflow-definition-registered";
21
24
  readonly InstanceStarted: "orchestration.instance-started";
@@ -66,6 +69,17 @@ export interface OrchestrationEventPayloads {
66
69
  readonly reason: string;
67
70
  };
68
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
+ };
69
83
  readonly [OrchestrationEventType.DelegationFailed]: {
70
84
  readonly cohortId: string;
71
85
  readonly reason: string;
@@ -9,6 +9,9 @@ export const OrchestrationEventType = {
9
9
  DelegationWaitStarted: 'orchestration.delegation-wait-started',
10
10
  DelegationJoined: 'orchestration.delegation-joined',
11
11
  DelegationFailed: 'orchestration.delegation-failed',
12
+ DelegationAttentionRequested: 'orchestration.delegation-attention-requested',
13
+ DelegationAttentionResponded: 'orchestration.delegation-attention-responded',
14
+ DelegationAttentionResolved: 'orchestration.delegation-attention-resolved',
12
15
  DelegationReconciliationFailed: 'orchestration.delegation-reconciliation-failed',
13
16
  WorkflowDefinitionRegistered: 'orchestration.workflow-definition-registered',
14
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;
@@ -56,6 +56,23 @@ export declare const DelegationPrerequisiteCondition: {
56
56
  readonly DeliveryReady: "delivery-ready";
57
57
  readonly MergedChange: "merged-change";
58
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>;
59
76
  export declare const DelegationConflictCode: {
60
77
  readonly SelfDependency: "self-dependency";
61
78
  readonly MissingTarget: "missing-target";
@@ -66,6 +83,7 @@ export declare const DelegationConflictCode: {
66
83
  readonly MultipleBases: "multiple-bases";
67
84
  readonly WaitCycle: "wait-cycle";
68
85
  readonly StalePlan: "stale-plan";
86
+ readonly AttentionOpen: "attention-open";
69
87
  };
70
88
  export type DelegationConflictCode = ValueOf<typeof DelegationConflictCode>;
71
89
  export declare const PrerequisiteBlockCode: {
@@ -49,6 +49,21 @@ export const DelegationPrerequisiteCondition = defineClosedVocabulary({
49
49
  DeliveryReady: 'delivery-ready',
50
50
  MergedChange: 'merged-change',
51
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
+ });
52
67
  export const DelegationConflictCode = defineClosedVocabulary({
53
68
  SelfDependency: 'self-dependency',
54
69
  MissingTarget: 'missing-target',
@@ -59,6 +74,7 @@ export const DelegationConflictCode = defineClosedVocabulary({
59
74
  MultipleBases: 'multiple-bases',
60
75
  WaitCycle: 'wait-cycle',
61
76
  StalePlan: 'stale-plan',
77
+ AttentionOpen: 'attention-open',
62
78
  });
63
79
  export const PrerequisiteBlockCode = defineClosedVocabulary({
64
80
  Waiting: 'prerequisite-waiting',
@@ -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:
@@ -273,6 +298,9 @@ export function immutableWorkflowInstanceView(state) {
273
298
  ...(state.requestId === undefined ? {} : { requestId: state.requestId }),
274
299
  ...(state.delegationFence === undefined ? {} : { delegationFence: state.delegationFence }),
275
300
  ...(state.delegationWait === undefined ? {} : { delegationWait: state.delegationWait }),
301
+ ...(state.delegationAttention === undefined
302
+ ? {}
303
+ : { delegationAttention: state.delegationAttention }),
276
304
  status: state.status,
277
305
  ...(state.blockReason === undefined ? {} : { blockReason: state.blockReason }),
278
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 { DelegationConflictError, 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, DelegationInputs, DelegationPrerequisite, DelegationReservation, DelegationResult, 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 { DelegationConflictError, 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,4 +1,4 @@
1
- import { DelegationConflictError, 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', {
@@ -20,6 +20,25 @@ export function registerDelegationTools(server, input) {
20
20
  };
21
21
  }
22
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
+ });
23
42
  server.registerTool('wake_delegation_inspect', {
24
43
  description: 'Inspect this delivery tree, child workflows, results and blockers, and the Repository Resource IDs an explicit repository selection may name.',
25
44
  }, async () => ({
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atolis-hq/wake",
3
- "version": "0.4.103",
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": {