@atolis-hq/wake 0.4.100 → 0.4.102
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/src/artifacts/application/operator-instructions-service.js +2 -2
- package/dist/src/bootstrap/artifact-mcp.d.ts +1 -0
- package/dist/src/bootstrap/artifact-mcp.js +27 -2
- package/dist/src/bootstrap/composition-root.js +6 -1
- package/dist/src/bootstrap/config/root-schema.d.ts +14 -0
- package/dist/src/bootstrap/delegation-authority.d.ts +10 -0
- package/dist/src/bootstrap/delegation-authority.js +52 -0
- package/dist/src/bootstrap/integration-runtime.js +5 -3
- package/dist/src/bootstrap/persistence-composition.js +1 -1
- package/dist/src/bootstrap/surface-api-delivery.d.ts +4 -0
- package/dist/src/bootstrap/surface-api-delivery.js +35 -0
- package/dist/src/bootstrap/surface-api-work-applications.js +2 -0
- package/dist/src/bootstrap/version.js +1 -1
- package/dist/src/control-plane/application/activation-scheduler-ports.d.ts +4 -1
- package/dist/src/control-plane/application/activation-scheduler.js +2 -1
- package/dist/src/control-plane/application/advance-once-dispatch.d.ts +4 -15
- package/dist/src/control-plane/application/advance-once-dispatch.js +15 -26
- package/dist/src/control-plane/application/trigger-recovery.js +2 -1
- package/dist/src/control-plane/application/trigger-workflow.d.ts +2 -1
- package/dist/src/control-plane/application/work-cancellation-policy.d.ts +1 -0
- package/dist/src/control-plane/application/work-cancellation-policy.js +6 -1
- package/dist/src/control-plane/domain/delivery-capacity.d.ts +9 -0
- package/dist/src/control-plane/domain/delivery-capacity.js +40 -0
- package/dist/src/control-plane/domain/dispatch-policy.d.ts +1 -0
- package/dist/src/control-plane/domain/dispatch-policy.js +6 -0
- package/dist/src/control-plane/domain/open-work-policy.d.ts +2 -7
- package/dist/src/control-plane/domain/open-work-policy.js +12 -9
- package/dist/src/execution/application/repository-assignments.d.ts +1 -1
- package/dist/src/execution/application/repository-assignments.js +7 -4
- package/dist/src/node_modules/@atolis-hq/eventing/dist/runtime/cached-journal-view.d.ts +9 -1
- package/dist/src/node_modules/@atolis-hq/eventing/dist/runtime/cached-journal-view.d.ts.map +1 -1
- package/dist/src/node_modules/@atolis-hq/eventing/dist/runtime/cached-journal-view.js +62 -7
- package/dist/src/node_modules/@atolis-hq/eventing/dist/store/event-journal.d.ts +2 -5
- package/dist/src/node_modules/@atolis-hq/eventing/dist/store/event-journal.d.ts.map +1 -1
- package/dist/src/node_modules/@atolis-hq/eventing-filesystem/dist/file-event-journal.d.ts +12 -13
- package/dist/src/node_modules/@atolis-hq/eventing-filesystem/dist/file-event-journal.d.ts.map +1 -1
- package/dist/src/node_modules/@atolis-hq/eventing-filesystem/dist/file-event-journal.js +168 -109
- package/dist/src/orchestration/application/deferred-signals.d.ts +4 -2
- package/dist/src/orchestration/application/deferred-signals.js +47 -37
- package/dist/src/orchestration/application/delegated-work.d.ts +54 -0
- package/dist/src/orchestration/application/delegated-work.js +64 -1
- package/dist/src/orchestration/application/delegation-commands.d.ts +119 -0
- package/dist/src/orchestration/application/delegation-commands.js +99 -0
- package/dist/src/orchestration/application/delegation-gate.d.ts +15 -5
- package/dist/src/orchestration/application/delegation-gate.js +44 -4
- package/dist/src/orchestration/application/orchestration-service.d.ts +150 -2
- package/dist/src/orchestration/application/orchestration-service.js +52 -6
- package/dist/src/orchestration/contracts/config.d.ts +16 -0
- package/dist/src/orchestration/contracts/config.js +10 -0
- package/dist/src/orchestration/contracts/delegation-ports.d.ts +10 -1
- package/dist/src/orchestration/contracts/delegation.d.ts +34 -0
- package/dist/src/orchestration/contracts/delegation.js +8 -0
- package/dist/src/orchestration/domain/compiler.js +7 -0
- package/dist/src/orchestration/index.d.ts +3 -0
- package/dist/src/orchestration/index.js +1 -0
- package/dist/src/surfaces/api/contracts/work.d.ts +14 -0
- package/dist/src/surfaces/index.d.ts +1 -0
- package/dist/src/surfaces/index.js +1 -0
- package/dist/src/surfaces/mcp/delegation.d.ts +9 -0
- package/dist/src/surfaces/mcp/delegation.js +25 -0
- package/dist/src/surfaces/web-assets/assets/index-C5R-aWzH.js +1192 -0
- package/dist/src/surfaces/web-assets/index.html +1 -1
- package/dist/src/work/application/work-index.d.ts +21 -0
- package/dist/src/work/application/work-index.js +73 -0
- package/dist/src/work/application/work-service.d.ts +3 -0
- package/dist/src/work/application/work-service.js +3 -0
- package/dist/src/work/domain/delivery-availability.d.ts +14 -0
- package/dist/src/work/domain/delivery-availability.js +20 -0
- package/dist/src/work/index.d.ts +2 -0
- package/dist/src/work/index.js +2 -0
- package/package.json +2 -1
- package/dist/src/surfaces/web-assets/assets/index-s9CWgq-s.js +0 -1192
|
@@ -1,5 +1,7 @@
|
|
|
1
|
+
import { expireTimedOutAwait } from '../domain/interpreter.js';
|
|
1
2
|
import { DeferredSignals } from './deferred-signals.js';
|
|
2
3
|
import { DelegatedWork } from './delegated-work.js';
|
|
4
|
+
import { DelegationCommands } from './delegation-commands.js';
|
|
3
5
|
import { DelegationGate } from './delegation-gate.js';
|
|
4
6
|
import { expireTimedOutWaits } from './expire-timed-out-waits.js';
|
|
5
7
|
import { recoverPolicyBlockedMerges } from './policy-blocked-merge-recovery.js';
|
|
@@ -8,7 +10,7 @@ import { selectOrchestrationEvent } from '../contracts/event-decoder.js';
|
|
|
8
10
|
import { OrchestrationEventType } from '../contracts/events.js';
|
|
9
11
|
import { commandName, workflowInstanceId as toWorkflowInstanceId, } from '../contracts/identifiers.js';
|
|
10
12
|
import { childOrchestrationGroupStream, workflowInstanceStream } from '../contracts/streams.js';
|
|
11
|
-
import { ApprovalAuthorityKind, ConversationBuiltInCommand } from '../contracts/vocabulary.js';
|
|
13
|
+
import { ApprovalAuthorityKind, ConversationBuiltInCommand, WorkflowStatus, } from '../contracts/vocabulary.js';
|
|
12
14
|
import { isGroupBudgetExtensionEligible, isNeedsClarificationResumeEligible, isPlainReplyResumeEligible, selectChangesResumeTargets, } from '../domain/operator-retry-policy.js';
|
|
13
15
|
import { AcceptActivityOutcome } from './accept-activity-outcome.js';
|
|
14
16
|
import { AcceptSignal } from './accept-signal.js';
|
|
@@ -23,6 +25,7 @@ import { StartWorkflow } from './start-workflow.js';
|
|
|
23
25
|
import { continuesWaitingForSameWatchGate } from './watch-child-transitions.js';
|
|
24
26
|
import { WorkflowDefinitionRegistry } from './workflow-definition-registry.js';
|
|
25
27
|
export class OrchestrationService {
|
|
28
|
+
delegationCommands;
|
|
26
29
|
delegationGate;
|
|
27
30
|
delegatedWork;
|
|
28
31
|
repository;
|
|
@@ -45,7 +48,7 @@ export class OrchestrationService {
|
|
|
45
48
|
this.work = work;
|
|
46
49
|
const repository = new OrchestrationRepository(journal);
|
|
47
50
|
this.repository = repository;
|
|
48
|
-
this.delegationGate = new DelegationGate(repository);
|
|
51
|
+
this.delegationGate = new DelegationGate(repository, work);
|
|
49
52
|
const dependencies = delegation?.({
|
|
50
53
|
isActivationAccepted: (id, item) => this.isActivationAccepted(id, item),
|
|
51
54
|
});
|
|
@@ -53,13 +56,15 @@ export class OrchestrationService {
|
|
|
53
56
|
this.definitions = new WorkflowDefinitionRegistry(journal, projections, definitions);
|
|
54
57
|
this.startWorkflow = new StartWorkflow(repository, this.claims, work, this.definitions);
|
|
55
58
|
this.delegatedWork = new DelegatedWork(repository, work, this.claims, this.definitions, this.startWorkflow, {
|
|
59
|
+
authority: dependencies?.authority,
|
|
56
60
|
artifacts: dependencies?.artifacts ?? unavailableArtifacts,
|
|
57
61
|
repositories: dependencies?.repositories,
|
|
58
62
|
runHasEnded: dependencies?.runHasEnded ?? unavailableRunCompletion,
|
|
59
63
|
});
|
|
64
|
+
this.delegationCommands = new DelegationCommands(repository, work, this.startWorkflow, this.definitions, this.delegatedWork, dependencies?.authority ?? unavailableDelegationAuthority);
|
|
60
65
|
this.advanceWorkflow = new AdvanceWorkflow(repository, this.startWorkflow, (command, context) => this.acceptOutcome(command, context), isAgentActivity);
|
|
61
66
|
this.acceptWorkflowSignal = new AcceptSignal(repository, this.startWorkflow, work);
|
|
62
|
-
this.deferredSignals = new DeferredSignals(repository, (id, signal, context) => this.delegationGate.run(id, () => this.acceptWorkflowSignal.execute(id, signal, context)), (id, target, evidenceId, context) => this.delegationGate.run(id, () => this.advanceWorkflow.applyResourceTransition(id, target, evidenceId, context)), (
|
|
67
|
+
this.deferredSignals = new DeferredSignals(repository, (id, signal, context) => this.delegationGate.run(id, () => this.acceptWorkflowSignal.execute(id, signal, context)), (id, target, evidenceId, context) => this.delegationGate.run(id, () => this.advanceWorkflow.applyResourceTransition(id, target, evidenceId, context)), (ids) => this.delegationGate.fencedAmong(ids));
|
|
63
68
|
this.childWorkflows = new RequestChild(repository, this.claims, new GroupBudgetRecorder(journal), this.startWorkflow, this.advanceWorkflow);
|
|
64
69
|
this.acceptActivityOutcome = new AcceptActivityOutcome(repository, this.startWorkflow, async (context) => {
|
|
65
70
|
await this.delegatedWork.reconcile(context);
|
|
@@ -67,6 +72,9 @@ export class OrchestrationService {
|
|
|
67
72
|
await this.deferredSignals.reconcile(context);
|
|
68
73
|
});
|
|
69
74
|
}
|
|
75
|
+
repositoryAuthority(workItemId) {
|
|
76
|
+
return this.delegatedWork.repositoryScope(workItemId);
|
|
77
|
+
}
|
|
70
78
|
repositoryAssignment(workItemId) {
|
|
71
79
|
return this.delegatedWork.repositoryFor(workItemId);
|
|
72
80
|
}
|
|
@@ -75,6 +83,31 @@ export class OrchestrationService {
|
|
|
75
83
|
(item === undefined || view.workItemId === item) &&
|
|
76
84
|
view.acceptedOutcomes.some((accepted) => accepted === id));
|
|
77
85
|
}
|
|
86
|
+
submitDelegation(caller, input, context) {
|
|
87
|
+
return this.delegationCommands.submit(caller, input, context);
|
|
88
|
+
}
|
|
89
|
+
inspectDelegation(caller, context) {
|
|
90
|
+
return this.delegationCommands.inspect(caller, context);
|
|
91
|
+
}
|
|
92
|
+
deliveryTree(id) {
|
|
93
|
+
return this.delegatedWork.inspect(id);
|
|
94
|
+
}
|
|
95
|
+
deliveryRunLimit(id) {
|
|
96
|
+
return this.delegatedWork.runLimit(id);
|
|
97
|
+
}
|
|
98
|
+
async hasLiveDelegatedWork(id) {
|
|
99
|
+
// A concluded root can never join its cohorts, so nothing remains to wait for.
|
|
100
|
+
const root = await this.work.get(id);
|
|
101
|
+
if (root === null || root.deleted === true || root.state !== WorkStatus.Open)
|
|
102
|
+
return false;
|
|
103
|
+
return (await this.deliveryTree(id)).some((cohort) => !cohort.settled &&
|
|
104
|
+
cohort.children.some(({ work, workflow }) => work !== null &&
|
|
105
|
+
work.deleted !== true &&
|
|
106
|
+
work.state === WorkStatus.Open &&
|
|
107
|
+
(workflow === null ||
|
|
108
|
+
(workflow.status !== WorkflowStatus.Completed &&
|
|
109
|
+
workflow.status !== WorkflowStatus.Superseded))));
|
|
110
|
+
}
|
|
78
111
|
joinedDelegationResults(id, cohortId) {
|
|
79
112
|
return this.delegatedWork.results(id, cohortId);
|
|
80
113
|
}
|
|
@@ -186,7 +219,10 @@ export class OrchestrationService {
|
|
|
186
219
|
markActivationStarted(workflowInstanceId, activationId, context) {
|
|
187
220
|
return this.advanceWorkflow.markActivationStarted(workflowInstanceId, activationId, context);
|
|
188
221
|
}
|
|
189
|
-
validateActivationDispatch(workflowInstanceId, context) {
|
|
222
|
+
async validateActivationDispatch(workflowInstanceId, context) {
|
|
223
|
+
const view = (await this.repository.load(workflowInstanceId)).view;
|
|
224
|
+
if (view !== null && (await this.delegationGate.unavailable(view)))
|
|
225
|
+
return false;
|
|
190
226
|
return this.childWorkflows.validateChildDispatch(workflowInstanceId, context);
|
|
191
227
|
}
|
|
192
228
|
block(workflowInstanceId, reason, context) {
|
|
@@ -264,13 +300,19 @@ export class OrchestrationService {
|
|
|
264
300
|
}
|
|
265
301
|
async listPendingActivations(workItemId) {
|
|
266
302
|
const entries = await this.advanceWorkflow.listPendingActivations(workItemId);
|
|
267
|
-
return
|
|
303
|
+
return this.delegationGate.filterAvailable(entries, (entry) => entry.workflow);
|
|
268
304
|
}
|
|
269
305
|
listWaiting(signalKind) {
|
|
270
306
|
return this.advanceWorkflow.listWaiting(signalKind);
|
|
271
307
|
}
|
|
272
308
|
async expireTimedOutWaits(context) {
|
|
273
|
-
|
|
309
|
+
// Only instances whose await has actually timed out need the gate, which is almost never any.
|
|
310
|
+
const due = (await this.repository.list()).filter(({ view }) => view !== null &&
|
|
311
|
+
expireTimedOutAwait(view, {
|
|
312
|
+
occurredAt: context.occurredAt,
|
|
313
|
+
causationId: context.commandId,
|
|
314
|
+
}).kind !== 'ignored');
|
|
315
|
+
return expireTimedOutWaits(this.repository, context, await this.delegationGate.filterAvailable(due, ({ view }) => view));
|
|
274
316
|
}
|
|
275
317
|
listAll() {
|
|
276
318
|
return this.advanceWorkflow.listAll();
|
|
@@ -369,3 +411,7 @@ const unavailableArtifacts = {
|
|
|
369
411
|
registerChild: unavailableRunCompletion,
|
|
370
412
|
qualifyingOutputs: unavailableRunCompletion,
|
|
371
413
|
};
|
|
414
|
+
const unavailableDelegationAuthority = {
|
|
415
|
+
assertCaller: unavailableRunCompletion,
|
|
416
|
+
repositories: unavailableRunCompletion,
|
|
417
|
+
};
|
|
@@ -214,8 +214,23 @@ export declare const supplementalCommandConfigSchema: z.ZodObject<{
|
|
|
214
214
|
watch: "watch";
|
|
215
215
|
}>>>;
|
|
216
216
|
}, z.core.$strict>;
|
|
217
|
+
export declare const delegationPolicySchema: z.ZodObject<{
|
|
218
|
+
workflows: z.ZodArray<z.ZodString>;
|
|
219
|
+
repositories: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
220
|
+
maxDepth: z.ZodNumber;
|
|
221
|
+
maxDescendants: z.ZodNumber;
|
|
222
|
+
maxConcurrentRuns: z.ZodNumber;
|
|
223
|
+
}, z.core.$strict>;
|
|
224
|
+
export type DelegationPolicy = z.infer<typeof delegationPolicySchema>;
|
|
217
225
|
export declare const workflowDefinitionConfigSchema: z.ZodObject<{
|
|
218
226
|
entry: z.ZodOptional<z.ZodString>;
|
|
227
|
+
delegation: z.ZodOptional<z.ZodObject<{
|
|
228
|
+
workflows: z.ZodArray<z.ZodString>;
|
|
229
|
+
repositories: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
230
|
+
maxDepth: z.ZodNumber;
|
|
231
|
+
maxDescendants: z.ZodNumber;
|
|
232
|
+
maxConcurrentRuns: z.ZodNumber;
|
|
233
|
+
}, z.core.$strict>>;
|
|
219
234
|
commands: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodObject<{
|
|
220
235
|
activity: z.ZodString;
|
|
221
236
|
with: z.ZodOptional<z.ZodUnknown>;
|
|
@@ -414,6 +429,7 @@ export interface CompiledWatch extends Omit<WatchConfig, 'workflow' | 'while' |
|
|
|
414
429
|
};
|
|
415
430
|
}
|
|
416
431
|
export interface CompiledWorkflow {
|
|
432
|
+
readonly delegation?: DelegationPolicy;
|
|
417
433
|
readonly remainingAgentSteps?: Readonly<Record<StageName, number>>;
|
|
418
434
|
readonly name: WorkflowName;
|
|
419
435
|
readonly entry: StageName;
|
|
@@ -151,9 +151,19 @@ export const supplementalCommandConfigSchema = z
|
|
|
151
151
|
allowedActors: z.array(approvalAuthorityKind).min(1).readonly(),
|
|
152
152
|
})
|
|
153
153
|
.strict();
|
|
154
|
+
export const delegationPolicySchema = z
|
|
155
|
+
.object({
|
|
156
|
+
workflows: z.array(identifier).min(1),
|
|
157
|
+
repositories: z.array(identifier).min(1).optional(),
|
|
158
|
+
maxDepth: z.number().int().positive(),
|
|
159
|
+
maxDescendants: z.number().int().positive(),
|
|
160
|
+
maxConcurrentRuns: z.number().int().positive(),
|
|
161
|
+
})
|
|
162
|
+
.strict();
|
|
154
163
|
export const workflowDefinitionConfigSchema = z
|
|
155
164
|
.object({
|
|
156
165
|
entry: identifier.optional(),
|
|
166
|
+
delegation: delegationPolicySchema.optional(),
|
|
157
167
|
commands: z.record(commandName, supplementalCommandConfigSchema).optional(),
|
|
158
168
|
watches: z.array(watchConfigSchema).readonly().optional(),
|
|
159
169
|
stages: z
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { CommandContext } from '@atolis-hq/eventing';
|
|
2
2
|
import type { RepositoryAssignment } from '../../execution/index.js';
|
|
3
|
-
import type { DelegatedAssignment, DelegationReservation, DelegationResult, DelegationRevisionReference, RepositoryAssignmentRequest } from './delegation.js';
|
|
3
|
+
import type { DelegatedAssignment, DelegationCaller, DelegationReservation, DelegationResult, DelegationRevisionReference, RepositoryAssignmentRequest } from './delegation.js';
|
|
4
4
|
import type { WorkflowInstanceView } from './views.js';
|
|
5
5
|
/** Trusted Bootstrap adapters; no provider, Run or session authority is supplied by assignments. */
|
|
6
6
|
export interface DelegationArtifacts {
|
|
@@ -13,6 +13,15 @@ export interface DelegationArtifacts {
|
|
|
13
13
|
}, context: CommandContext): Promise<void>;
|
|
14
14
|
qualifyingOutputs(child: WorkflowInstanceView, outputs: DelegatedAssignment['outputs']): Promise<DelegationResult['outputs'] | null>;
|
|
15
15
|
}
|
|
16
|
+
export interface DelegationAuthority {
|
|
17
|
+
assertCaller(caller: DelegationCaller, parent: WorkflowInstanceView): Promise<void>;
|
|
18
|
+
repositories(parent: WorkflowInstanceView): Promise<readonly string[]>;
|
|
19
|
+
/**
|
|
20
|
+
* Records the root's default repository scope from trusted provider identity when no
|
|
21
|
+
* Repository Resource is yet correlated. Agent input never reaches this binding.
|
|
22
|
+
*/
|
|
23
|
+
bindRepositoryScope?(root: WorkflowInstanceView, context: CommandContext): Promise<void>;
|
|
24
|
+
}
|
|
16
25
|
/** Resolves only repositories already authorized by the parent's resource scope. */
|
|
17
26
|
export interface DelegationRepositories {
|
|
18
27
|
resolve(parent: WorkflowInstanceView, request: RepositoryAssignmentRequest): Promise<RepositoryAssignment>;
|
|
@@ -18,6 +18,7 @@ export declare const delegatedAssignmentSchema: z.ZodObject<{
|
|
|
18
18
|
objective: z.ZodString;
|
|
19
19
|
criteria: z.ZodArray<z.ZodString>;
|
|
20
20
|
workflowName: z.ZodPipe<z.ZodString, z.ZodTransform<import("./identifiers.js").WorkflowName, string>>;
|
|
21
|
+
repositoryResourceIds: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
21
22
|
workflowFingerprint: z.ZodString;
|
|
22
23
|
context: z.ZodArray<z.ZodObject<{
|
|
23
24
|
workItemId: z.ZodPipe<z.ZodString, z.ZodTransform<import("../../work/index.js").WorkItemId, string>>;
|
|
@@ -39,6 +40,36 @@ export declare const delegatedAssignmentSchema: z.ZodObject<{
|
|
|
39
40
|
requireChecks: z.ZodOptional<z.ZodBoolean>;
|
|
40
41
|
}, z.core.$strict>]>>;
|
|
41
42
|
}, z.core.$strict>;
|
|
43
|
+
export declare const delegationSubmissionSchema: z.ZodObject<{
|
|
44
|
+
cohortId: z.ZodString;
|
|
45
|
+
assignments: z.ZodArray<z.ZodObject<{
|
|
46
|
+
objective: z.ZodString;
|
|
47
|
+
repository: z.ZodOptional<z.ZodObject<{
|
|
48
|
+
resourceId: z.ZodString;
|
|
49
|
+
sourceRef: z.ZodString;
|
|
50
|
+
sourceRevision: z.ZodOptional<z.ZodString>;
|
|
51
|
+
pullRequestBase: z.ZodString;
|
|
52
|
+
}, z.core.$strict>>;
|
|
53
|
+
context: z.ZodArray<z.ZodObject<{
|
|
54
|
+
workItemId: z.ZodPipe<z.ZodString, z.ZodTransform<import("../../work/index.js").WorkItemId, string>>;
|
|
55
|
+
revisionId: z.ZodString;
|
|
56
|
+
}, z.core.$strict>>;
|
|
57
|
+
assignmentId: z.ZodString;
|
|
58
|
+
criteria: z.ZodArray<z.ZodString>;
|
|
59
|
+
workflowName: z.ZodPipe<z.ZodString, z.ZodTransform<import("./identifiers.js").WorkflowName, string>>;
|
|
60
|
+
repositoryResourceIds: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
61
|
+
outputs: z.ZodArray<z.ZodUnion<readonly [z.ZodObject<{
|
|
62
|
+
name: z.ZodString;
|
|
63
|
+
path: z.ZodString;
|
|
64
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
65
|
+
name: z.ZodString;
|
|
66
|
+
kind: z.ZodLiteral<"change">;
|
|
67
|
+
requireReview: z.ZodOptional<z.ZodBoolean>;
|
|
68
|
+
requireChecks: z.ZodOptional<z.ZodBoolean>;
|
|
69
|
+
}, z.core.$strict>]>>;
|
|
70
|
+
}, z.core.$strict>>;
|
|
71
|
+
}, z.core.$strict>;
|
|
72
|
+
export type DelegationSubmission = z.infer<typeof delegationSubmissionSchema>;
|
|
42
73
|
export type DelegatedAssignment = z.infer<typeof delegatedAssignmentSchema>;
|
|
43
74
|
export declare const delegationReservationSchema: z.ZodObject<{
|
|
44
75
|
cohortId: z.ZodString;
|
|
@@ -48,6 +79,7 @@ export declare const delegationReservationSchema: z.ZodObject<{
|
|
|
48
79
|
activationId: z.ZodPipe<z.ZodString, z.ZodTransform<import("../../activities/index.js").ActivationId, string>>;
|
|
49
80
|
runId: z.ZodString;
|
|
50
81
|
ancestors: z.ZodArray<z.ZodPipe<z.ZodString, z.ZodTransform<import("../../work/index.js").WorkItemId, string>>>;
|
|
82
|
+
maxConcurrentRuns: z.ZodOptional<z.ZodNumber>;
|
|
51
83
|
maxDepth: z.ZodNumber;
|
|
52
84
|
maxDescendants: z.ZodNumber;
|
|
53
85
|
children: z.ZodArray<z.ZodObject<{
|
|
@@ -55,6 +87,7 @@ export declare const delegationReservationSchema: z.ZodObject<{
|
|
|
55
87
|
objective: z.ZodString;
|
|
56
88
|
criteria: z.ZodArray<z.ZodString>;
|
|
57
89
|
workflowName: z.ZodPipe<z.ZodString, z.ZodTransform<import("./identifiers.js").WorkflowName, string>>;
|
|
90
|
+
repositoryResourceIds: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
58
91
|
workflowFingerprint: z.ZodString;
|
|
59
92
|
context: z.ZodArray<z.ZodObject<{
|
|
60
93
|
workItemId: z.ZodPipe<z.ZodString, z.ZodTransform<import("../../work/index.js").WorkItemId, string>>;
|
|
@@ -128,6 +161,7 @@ export declare const delegationJoinSchema: z.ZodObject<{
|
|
|
128
161
|
}, z.core.$strict>>;
|
|
129
162
|
}, z.core.$strict>;
|
|
130
163
|
export interface DelegationLimits {
|
|
164
|
+
readonly maxConcurrentRuns?: number;
|
|
131
165
|
readonly maxDepth: number;
|
|
132
166
|
readonly maxDescendants: number;
|
|
133
167
|
}
|
|
@@ -27,6 +27,7 @@ export const delegatedAssignmentSchema = z
|
|
|
27
27
|
objective: z.string().trim().min(1),
|
|
28
28
|
criteria: z.array(z.string().trim().min(1)).min(1),
|
|
29
29
|
workflowName: brandedStringSchema(workflowName),
|
|
30
|
+
repositoryResourceIds: z.array(z.string().min(1)).optional(),
|
|
30
31
|
workflowFingerprint: z.string().min(1),
|
|
31
32
|
context: z.array(delegationRevisionReferenceSchema),
|
|
32
33
|
repository: repositoryAssignmentRequestSchema.optional(),
|
|
@@ -45,6 +46,12 @@ export const delegatedAssignmentSchema = z
|
|
|
45
46
|
.min(1),
|
|
46
47
|
})
|
|
47
48
|
.strict();
|
|
49
|
+
export const delegationSubmissionSchema = z
|
|
50
|
+
.object({
|
|
51
|
+
cohortId: z.string().min(1),
|
|
52
|
+
assignments: z.array(delegatedAssignmentSchema.omit({ workflowFingerprint: true })).min(1),
|
|
53
|
+
})
|
|
54
|
+
.strict();
|
|
48
55
|
export const delegationReservationSchema = z
|
|
49
56
|
.object({
|
|
50
57
|
cohortId: z.string().min(1),
|
|
@@ -54,6 +61,7 @@ export const delegationReservationSchema = z
|
|
|
54
61
|
activationId: brandedStringSchema(activationId),
|
|
55
62
|
runId: z.string().min(1),
|
|
56
63
|
ancestors: z.array(brandedStringSchema(workItemId)),
|
|
64
|
+
maxConcurrentRuns: z.number().int().positive().optional(),
|
|
57
65
|
maxDepth: z.number().int().positive(),
|
|
58
66
|
maxDescendants: z.number().int().positive(),
|
|
59
67
|
children: z
|
|
@@ -11,6 +11,7 @@ import { assertCyclesBounded, assertReachable, remainingAgentSteps } from './wor
|
|
|
11
11
|
export function compileWorkflow(name, input, activities, knownWorkflowNames = [name], reportDiagnostic = () => { }) {
|
|
12
12
|
const compiledName = workflowName(name);
|
|
13
13
|
const config = workflowDefinitionConfigSchema.parse(input);
|
|
14
|
+
assertDelegationWorkflows(config, knownWorkflowNames);
|
|
14
15
|
const rawStageNames = Object.keys(config.stages);
|
|
15
16
|
for (const candidate of rawStageNames) {
|
|
16
17
|
if (isReservedRouteTarget(candidate))
|
|
@@ -30,6 +31,7 @@ export function compileWorkflow(name, input, activities, knownWorkflowNames = [n
|
|
|
30
31
|
reportUnroutedOutcomes(name, stages, activities, reportDiagnostic);
|
|
31
32
|
return Object.freeze({
|
|
32
33
|
remainingAgentSteps: Object.freeze(remainingAgentSteps(stages, (activity) => activities.describe(activity).executionKind === ActivityExecutionKind.Agent)),
|
|
34
|
+
...(config.delegation === undefined ? {} : { delegation: config.delegation }),
|
|
33
35
|
name: compiledName,
|
|
34
36
|
entry: compiledEntry,
|
|
35
37
|
commands: Object.freeze(commands),
|
|
@@ -176,3 +178,8 @@ function compileAuthority(workflow, rawStageName, entry, declaredWatchIds) {
|
|
|
176
178
|
throw new Error(`Unknown watch reference in workflow "${workflow}" stage "${rawStageName}": "${entry.id}"`);
|
|
177
179
|
return { kind: ApprovalAuthorityKind.Watch, watch: watchId(entry.id) };
|
|
178
180
|
}
|
|
181
|
+
function assertDelegationWorkflows(config, known) {
|
|
182
|
+
for (const child of config.delegation?.workflows ?? [])
|
|
183
|
+
if (!known.includes(child))
|
|
184
|
+
throw new Error('Unknown delegation workflow: ' + child);
|
|
185
|
+
}
|
|
@@ -34,3 +34,6 @@ 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
36
|
export { DelegationPendingError } from './contracts/delegation.js';
|
|
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';
|
|
@@ -32,3 +32,4 @@ export * from './domain/workflow-instance.js';
|
|
|
32
32
|
export * from './domain/workflow-selector.js';
|
|
33
33
|
export * from './application/work-completion-summary.js';
|
|
34
34
|
export { DelegationPendingError } from './contracts/delegation.js';
|
|
35
|
+
export { delegationSubmissionSchema } from './contracts/delegation.js';
|
|
@@ -19,6 +19,20 @@ export interface WorkItemResponse {
|
|
|
19
19
|
readonly lastRunOutcome?: string;
|
|
20
20
|
}
|
|
21
21
|
export interface WorkDetailResponse {
|
|
22
|
+
readonly delegation?: {
|
|
23
|
+
readonly rootWorkItemKey: WorkItemKey;
|
|
24
|
+
readonly parentWorkItemKey?: WorkItemKey;
|
|
25
|
+
readonly children: readonly {
|
|
26
|
+
readonly workItemKey: WorkItemKey;
|
|
27
|
+
readonly parentWorkItemKey: WorkItemKey;
|
|
28
|
+
readonly objective: string;
|
|
29
|
+
readonly workflowName: string;
|
|
30
|
+
readonly status: string;
|
|
31
|
+
readonly cohortId: string;
|
|
32
|
+
readonly blockReason?: string;
|
|
33
|
+
readonly resources: readonly ResourceItemResponse[];
|
|
34
|
+
}[];
|
|
35
|
+
};
|
|
22
36
|
readonly triggerOrigin?: string;
|
|
23
37
|
readonly work: WorkItemResponse;
|
|
24
38
|
readonly resources: readonly ResourceItemResponse[];
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { CommandContext } from '@atolis-hq/eventing';
|
|
2
|
+
import type { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';
|
|
3
|
+
import { type DelegationCaller, type OrchestrationService } from '../../orchestration/index.js';
|
|
4
|
+
/** The bound caller is never accepted as a tool argument. */
|
|
5
|
+
export declare function registerDelegationTools(server: McpServer, input: {
|
|
6
|
+
readonly orchestration: OrchestrationService;
|
|
7
|
+
readonly caller: () => Promise<DelegationCaller>;
|
|
8
|
+
readonly commandContext: () => CommandContext;
|
|
9
|
+
}): void;
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { delegationSubmissionSchema, } from '../../orchestration/index.js';
|
|
2
|
+
/** The bound caller is never accepted as a tool argument. */
|
|
3
|
+
export function registerDelegationTools(server, input) {
|
|
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.',
|
|
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
|
+
}));
|
|
15
|
+
server.registerTool('wake_delegation_inspect', {
|
|
16
|
+
description: 'Inspect this delivery tree, child workflows, results and blockers, and the Repository Resource IDs an explicit repository selection may name.',
|
|
17
|
+
}, async () => ({
|
|
18
|
+
content: [
|
|
19
|
+
{
|
|
20
|
+
type: 'text',
|
|
21
|
+
text: JSON.stringify(await input.orchestration.inspectDelegation(await input.caller(), input.commandContext())),
|
|
22
|
+
},
|
|
23
|
+
],
|
|
24
|
+
}));
|
|
25
|
+
}
|