@memberjunction/task-graph 6.1.0-edge.2 → 6.1.0-edge.4

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 (53) hide show
  1. package/LICENSE +180 -4
  2. package/README.md +30 -1
  3. package/dist/TaskClaimStore.d.ts +376 -4
  4. package/dist/TaskClaimStore.d.ts.map +1 -1
  5. package/dist/TaskClaimStore.js +600 -20
  6. package/dist/TaskClaimStore.js.map +1 -1
  7. package/dist/TaskGraphDispatcher.d.ts +326 -25
  8. package/dist/TaskGraphDispatcher.d.ts.map +1 -1
  9. package/dist/TaskGraphDispatcher.js +1604 -286
  10. package/dist/TaskGraphDispatcher.js.map +1 -1
  11. package/dist/TaskGraphService.d.ts +255 -5
  12. package/dist/TaskGraphService.d.ts.map +1 -1
  13. package/dist/TaskGraphService.js +583 -26
  14. package/dist/TaskGraphService.js.map +1 -1
  15. package/dist/TaskGraphSubmitterImpl.d.ts.map +1 -1
  16. package/dist/TaskGraphSubmitterImpl.js +5 -0
  17. package/dist/TaskGraphSubmitterImpl.js.map +1 -1
  18. package/dist/condition-gate.d.ts +128 -0
  19. package/dist/condition-gate.d.ts.map +1 -0
  20. package/dist/condition-gate.js +257 -0
  21. package/dist/condition-gate.js.map +1 -0
  22. package/dist/debug-state.d.ts +102 -0
  23. package/dist/debug-state.d.ts.map +1 -0
  24. package/dist/debug-state.js +135 -0
  25. package/dist/debug-state.js.map +1 -0
  26. package/dist/index.d.ts +6 -0
  27. package/dist/index.d.ts.map +1 -1
  28. package/dist/index.js +6 -0
  29. package/dist/index.js.map +1 -1
  30. package/dist/operations/TaskGraphDebugOperations.d.ts +99 -0
  31. package/dist/operations/TaskGraphDebugOperations.d.ts.map +1 -0
  32. package/dist/operations/TaskGraphDebugOperations.js +310 -0
  33. package/dist/operations/TaskGraphDebugOperations.js.map +1 -0
  34. package/dist/operations/TaskGraphOperations.d.ts +20 -2
  35. package/dist/operations/TaskGraphOperations.d.ts.map +1 -1
  36. package/dist/operations/TaskGraphOperations.js +47 -8
  37. package/dist/operations/TaskGraphOperations.js.map +1 -1
  38. package/dist/settlement-rescue.d.ts +85 -0
  39. package/dist/settlement-rescue.d.ts.map +1 -0
  40. package/dist/settlement-rescue.js +119 -0
  41. package/dist/settlement-rescue.js.map +1 -0
  42. package/dist/task-graph-kick.d.ts +3 -0
  43. package/dist/task-graph-kick.d.ts.map +1 -0
  44. package/dist/task-graph-kick.js +17 -0
  45. package/dist/task-graph-kick.js.map +1 -0
  46. package/dist/task-predicates.d.ts +77 -0
  47. package/dist/task-predicates.d.ts.map +1 -0
  48. package/dist/task-predicates.js +75 -0
  49. package/dist/task-predicates.js.map +1 -0
  50. package/dist/types.d.ts +110 -1
  51. package/dist/types.d.ts.map +1 -1
  52. package/dist/types.js.map +1 -1
  53. package/package.json +12 -11
@@ -0,0 +1,310 @@
1
+ var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
2
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
3
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
4
+ else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
5
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
6
+ };
7
+ /**
8
+ * @fileoverview Remote Operation implementations for the task-graph debug/runner control plane —
9
+ * pause, resume, single-step, breakpoints, edge overrides, and the step-level intervention verbs.
10
+ *
11
+ * Ships per the standing rule from #3576: every task-graph control verb is a Remote Operation, so
12
+ * the console UI, MCP callers, and an Action wrapper all reach the same typed call site. All logic
13
+ * stays in `TaskGraphService`; these are thin adapters.
14
+ *
15
+ * **Registration note.** These subclasses extend `BaseRemotableOperation` directly and declare
16
+ * their own `OperationKey`/`ExecutionMode`/`RequiredScope`, rather than extending a CodeGen-emitted
17
+ * base from `@memberjunction/core-entities` the way `TaskGraphOperations.ts` does. The metadata rows
18
+ * for these operations ship in `metadata/remote-operations/.remote-operations.json`; once
19
+ * `mj sync push` + `mj codegen` have run, CodeGen emits the typed bases and a follow-up may
20
+ * re-parent these classes onto them — the runtime contract (ClassFactory key + metadata
21
+ * invokability gate) is identical either way.
22
+ *
23
+ * **Authorization.** The debug verbs write through guarded SQL, not through entity permissions, so
24
+ * each one gates explicitly: the caller must be the graph's recorded owner or an Owner-type user.
25
+ * A graph with no recorded owner fails closed for everyone but Owner-type users.
26
+ *
27
+ * @module @memberjunction/task-graph
28
+ */
29
+ import { RegisterClass } from '@memberjunction/global';
30
+ import { BaseRemotableOperation, RunView } from '@memberjunction/core';
31
+ import { UUIDsEqual } from '@memberjunction/global';
32
+ import { ParseTaskGraphParentMetadata, TASK_TYPE_NAME, TaskGraphService } from '../TaskGraphService.js';
33
+ // ── shared plumbing ────────────────────────────────────────────────────────
34
+ function submitContext(provider, user) {
35
+ // EnvironmentID is empty on every debug path: the graph already exists, and the service reads
36
+ // the field only while persisting a new one.
37
+ return { EnvironmentID: '', ConversationDetailID: null, ContextUser: user, Provider: provider };
38
+ }
39
+ /**
40
+ * The caller must be the graph's recorded owner, or an Owner-type user.
41
+ *
42
+ * Explicit here because the debug verbs write through guarded SQL rather than entity saves, so
43
+ * entity permissions never see them. Fails closed: a graph with no recorded owner (submitted before
44
+ * ownership stamping) is controllable only by Owner-type users.
45
+ */
46
+ async function authorizeGraphControl(parentTaskID, provider, user) {
47
+ if (user.Type?.trim().toLowerCase() === 'owner')
48
+ return null;
49
+ const parent = await provider.GetEntityObject('MJ: Tasks', user);
50
+ if (!(await parent.Load(parentTaskID)))
51
+ return 'No such workflow run.';
52
+ const owner = ParseTaskGraphParentMetadata(parent.InputPayload).submittedByUserID;
53
+ if (!owner || !UUIDsEqual(owner, user.ID)) {
54
+ return 'Only the workflow run\'s owner can control it.';
55
+ }
56
+ return null;
57
+ }
58
+ /**
59
+ * Resolves a child task's graph, so task-scoped verbs authorize against the same owner.
60
+ *
61
+ * **Proves the parent is a WORKFLOW graph, not merely that the task has one.** `MJ: Tasks` holds
62
+ * conversation tasks and users' personal to-dos alongside workflow steps, and both of those can be
63
+ * parented too — so "has a ParentID" is not "is a step of a workflow run". Without the type check
64
+ * the ownership gate below is the only thing standing between these verbs and any parented row in
65
+ * the table, and for an Owner-type caller that gate returns before loading anything. The guarded
66
+ * statements carry the same discriminator as a second layer; this is the first.
67
+ */
68
+ async function graphOfTask(taskID, provider, user) {
69
+ const task = await provider.GetEntityObject('MJ: Tasks', user);
70
+ if (!(await task.Load(taskID)))
71
+ return { error: 'No such step.' };
72
+ if (!task.ParentID)
73
+ return { error: 'That task is not a step of a workflow run.' };
74
+ const parent = await provider.GetEntityObject('MJ: Tasks', user);
75
+ if (!(await parent.Load(task.ParentID)))
76
+ return { error: 'That step\'s workflow run could not be read.' };
77
+ const workflowTypeID = await resolveWorkflowTaskTypeID(provider, user);
78
+ if (!workflowTypeID || !UUIDsEqual(parent.TypeID ?? '', workflowTypeID)) {
79
+ return { error: 'That task is not a step of a workflow run.' };
80
+ }
81
+ return { parentTaskID: task.ParentID };
82
+ }
83
+ /**
84
+ * The `AI Workflow` task type's ID, or null when the row does not exist.
85
+ *
86
+ * Read rather than created: these verbs act on graphs that already exist, so an absent type row
87
+ * means there are no workflow graphs to act on — minting one from a debug verb would be a write on
88
+ * a read path, and would make the check it feeds vacuously pass.
89
+ */
90
+ async function resolveWorkflowTaskTypeID(provider, user) {
91
+ const result = await RunView.FromMetadataProvider(provider).RunView({
92
+ EntityName: 'MJ: Task Types',
93
+ ExtraFilter: `Name='${TASK_TYPE_NAME}'`,
94
+ Fields: ['ID'],
95
+ ResultType: 'simple',
96
+ MaxRows: 1,
97
+ }, user);
98
+ return result.Success ? (result.Results?.[0]?.ID ?? null) : null;
99
+ }
100
+ function failed(errorMessage) {
101
+ return { success: false, errorMessage };
102
+ }
103
+ // ── the verbs ──────────────────────────────────────────────────────────────
104
+ /** `TaskGraph.Pause` — nothing new starts; in-flight steps finish and their completions land. */
105
+ let TaskGraphPauseServerOperation = class TaskGraphPauseServerOperation extends BaseRemotableOperation {
106
+ constructor() {
107
+ super(...arguments);
108
+ this.OperationKey = 'TaskGraph.Pause';
109
+ this.ExecutionMode = 'Sync';
110
+ this.RequiredScope = 'taskgraph:execute';
111
+ }
112
+ async InternalExecute(input, provider, user) {
113
+ if (!input?.parentTaskID)
114
+ throw new Error('parentTaskID is required');
115
+ const denied = await authorizeGraphControl(input.parentTaskID, provider, user);
116
+ if (denied)
117
+ return failed(denied);
118
+ const result = await new TaskGraphService().PauseGraph(input.parentTaskID, submitContext(provider, user), user.ID);
119
+ return { success: result.Success, debug: result.Debug, errorMessage: result.ErrorMessage };
120
+ }
121
+ };
122
+ TaskGraphPauseServerOperation = __decorate([
123
+ RegisterClass(BaseRemotableOperation, 'TaskGraph.Pause')
124
+ ], TaskGraphPauseServerOperation);
125
+ export { TaskGraphPauseServerOperation };
126
+ /** `TaskGraph.Resume` — claiming continues; breakpoints and overrides survive. */
127
+ let TaskGraphResumeServerOperation = class TaskGraphResumeServerOperation extends BaseRemotableOperation {
128
+ constructor() {
129
+ super(...arguments);
130
+ this.OperationKey = 'TaskGraph.Resume';
131
+ this.ExecutionMode = 'Sync';
132
+ this.RequiredScope = 'taskgraph:execute';
133
+ }
134
+ async InternalExecute(input, provider, user) {
135
+ if (!input?.parentTaskID)
136
+ throw new Error('parentTaskID is required');
137
+ const denied = await authorizeGraphControl(input.parentTaskID, provider, user);
138
+ if (denied)
139
+ return failed(denied);
140
+ const result = await new TaskGraphService().ResumeGraph(input.parentTaskID, submitContext(provider, user));
141
+ return { success: result.Success, debug: result.Debug, errorMessage: result.ErrorMessage };
142
+ }
143
+ };
144
+ TaskGraphResumeServerOperation = __decorate([
145
+ RegisterClass(BaseRemotableOperation, 'TaskGraph.Resume')
146
+ ], TaskGraphResumeServerOperation);
147
+ export { TaskGraphResumeServerOperation };
148
+ /** `TaskGraph.Step` — arm a one-shot claim allowance on a paused workflow. */
149
+ let TaskGraphStepServerOperation = class TaskGraphStepServerOperation extends BaseRemotableOperation {
150
+ constructor() {
151
+ super(...arguments);
152
+ this.OperationKey = 'TaskGraph.Step';
153
+ this.ExecutionMode = 'Sync';
154
+ this.RequiredScope = 'taskgraph:execute';
155
+ }
156
+ async InternalExecute(input, provider, user) {
157
+ if (!input?.parentTaskID)
158
+ throw new Error('parentTaskID is required');
159
+ const denied = await authorizeGraphControl(input.parentTaskID, provider, user);
160
+ if (denied)
161
+ return failed(denied);
162
+ const target = input.target === 'wave' || input.target === 'one'
163
+ ? input.target
164
+ : input.target ? input.target : 'one';
165
+ const result = await new TaskGraphService().StepGraph(input.parentTaskID, target, submitContext(provider, user));
166
+ return { success: result.Success, debug: result.Debug, errorMessage: result.ErrorMessage };
167
+ }
168
+ };
169
+ TaskGraphStepServerOperation = __decorate([
170
+ RegisterClass(BaseRemotableOperation, 'TaskGraph.Step')
171
+ ], TaskGraphStepServerOperation);
172
+ export { TaskGraphStepServerOperation };
173
+ /** `TaskGraph.SetBreakpoints` — replace the workflow's breakpoint set. */
174
+ let TaskGraphSetBreakpointsServerOperation = class TaskGraphSetBreakpointsServerOperation extends BaseRemotableOperation {
175
+ constructor() {
176
+ super(...arguments);
177
+ this.OperationKey = 'TaskGraph.SetBreakpoints';
178
+ this.ExecutionMode = 'Sync';
179
+ this.RequiredScope = 'taskgraph:execute';
180
+ }
181
+ async InternalExecute(input, provider, user) {
182
+ if (!input?.parentTaskID)
183
+ throw new Error('parentTaskID is required');
184
+ if (!Array.isArray(input.taskIDs))
185
+ throw new Error('taskIDs is required (empty array clears)');
186
+ const denied = await authorizeGraphControl(input.parentTaskID, provider, user);
187
+ if (denied)
188
+ return failed(denied);
189
+ const result = await new TaskGraphService().SetBreakpoints(input.parentTaskID, input.taskIDs, submitContext(provider, user));
190
+ return { success: result.Success, debug: result.Debug, errorMessage: result.ErrorMessage };
191
+ }
192
+ };
193
+ TaskGraphSetBreakpointsServerOperation = __decorate([
194
+ RegisterClass(BaseRemotableOperation, 'TaskGraph.SetBreakpoints')
195
+ ], TaskGraphSetBreakpointsServerOperation);
196
+ export { TaskGraphSetBreakpointsServerOperation };
197
+ /** `TaskGraph.OverrideEdge` — answer a path the engine cannot decide (or decided wrongly). */
198
+ let TaskGraphOverrideEdgeServerOperation = class TaskGraphOverrideEdgeServerOperation extends BaseRemotableOperation {
199
+ constructor() {
200
+ super(...arguments);
201
+ this.OperationKey = 'TaskGraph.OverrideEdge';
202
+ this.ExecutionMode = 'Sync';
203
+ this.RequiredScope = 'taskgraph:execute';
204
+ }
205
+ async InternalExecute(input, provider, user) {
206
+ if (!input?.parentTaskID)
207
+ throw new Error('parentTaskID is required');
208
+ if (!input?.edgeID)
209
+ throw new Error('edgeID is required');
210
+ const denied = await authorizeGraphControl(input.parentTaskID, provider, user);
211
+ if (denied)
212
+ return failed(denied);
213
+ const verdict = input.verdict === 'true' || input.verdict === 'false' ? input.verdict : null;
214
+ const result = await new TaskGraphService().SetEdgeOverride(input.parentTaskID, input.edgeID, verdict, submitContext(provider, user));
215
+ return { success: result.Success, debug: result.Debug, errorMessage: result.ErrorMessage };
216
+ }
217
+ };
218
+ TaskGraphOverrideEdgeServerOperation = __decorate([
219
+ RegisterClass(BaseRemotableOperation, 'TaskGraph.OverrideEdge')
220
+ ], TaskGraphOverrideEdgeServerOperation);
221
+ export { TaskGraphOverrideEdgeServerOperation };
222
+ /** `TaskGraph.SkipTask` — declare a Pending step not-taken; dependents proceed. */
223
+ let TaskGraphSkipTaskServerOperation = class TaskGraphSkipTaskServerOperation extends BaseRemotableOperation {
224
+ constructor() {
225
+ super(...arguments);
226
+ this.OperationKey = 'TaskGraph.SkipTask';
227
+ this.ExecutionMode = 'Sync';
228
+ this.RequiredScope = 'taskgraph:execute';
229
+ }
230
+ async InternalExecute(input, provider, user) {
231
+ if (!input?.taskID)
232
+ throw new Error('taskID is required');
233
+ const graph = await graphOfTask(input.taskID, provider, user);
234
+ if ('error' in graph)
235
+ return failed(graph.error);
236
+ const denied = await authorizeGraphControl(graph.parentTaskID, provider, user);
237
+ if (denied)
238
+ return failed(denied);
239
+ const result = await new TaskGraphService().SkipTask(input.taskID, submitContext(provider, user));
240
+ return { success: result.Success, errorMessage: result.ErrorMessage };
241
+ }
242
+ };
243
+ TaskGraphSkipTaskServerOperation = __decorate([
244
+ RegisterClass(BaseRemotableOperation, 'TaskGraph.SkipTask')
245
+ ], TaskGraphSkipTaskServerOperation);
246
+ export { TaskGraphSkipTaskServerOperation };
247
+ /** `TaskGraph.ForceCompleteTask` — mark a wedged or externally-resolved step Complete with a supplied output. */
248
+ let TaskGraphForceCompleteTaskServerOperation = class TaskGraphForceCompleteTaskServerOperation extends BaseRemotableOperation {
249
+ constructor() {
250
+ super(...arguments);
251
+ this.OperationKey = 'TaskGraph.ForceCompleteTask';
252
+ this.ExecutionMode = 'Sync';
253
+ this.RequiredScope = 'taskgraph:execute';
254
+ }
255
+ async InternalExecute(input, provider, user) {
256
+ if (!input?.taskID)
257
+ throw new Error('taskID is required');
258
+ const graph = await graphOfTask(input.taskID, provider, user);
259
+ if ('error' in graph)
260
+ return failed(graph.error);
261
+ const denied = await authorizeGraphControl(graph.parentTaskID, provider, user);
262
+ if (denied)
263
+ return failed(denied);
264
+ const result = await new TaskGraphService().ForceCompleteTask(input.taskID, input.payload ?? null, submitContext(provider, user));
265
+ return { success: result.Success, errorMessage: result.ErrorMessage };
266
+ }
267
+ };
268
+ TaskGraphForceCompleteTaskServerOperation = __decorate([
269
+ RegisterClass(BaseRemotableOperation, 'TaskGraph.ForceCompleteTask')
270
+ ], TaskGraphForceCompleteTaskServerOperation);
271
+ export { TaskGraphForceCompleteTaskServerOperation };
272
+ /** `TaskGraph.UpdateTaskInput` — replace a Pending step's input before stepping it. */
273
+ let TaskGraphUpdateTaskInputServerOperation = class TaskGraphUpdateTaskInputServerOperation extends BaseRemotableOperation {
274
+ constructor() {
275
+ super(...arguments);
276
+ this.OperationKey = 'TaskGraph.UpdateTaskInput';
277
+ this.ExecutionMode = 'Sync';
278
+ this.RequiredScope = 'taskgraph:execute';
279
+ }
280
+ async InternalExecute(input, provider, user) {
281
+ if (!input?.taskID)
282
+ throw new Error('taskID is required');
283
+ if (input.payload === undefined)
284
+ throw new Error('payload is required');
285
+ const graph = await graphOfTask(input.taskID, provider, user);
286
+ if ('error' in graph)
287
+ return failed(graph.error);
288
+ const denied = await authorizeGraphControl(graph.parentTaskID, provider, user);
289
+ if (denied)
290
+ return failed(denied);
291
+ const result = await new TaskGraphService().UpdateTaskInput(input.taskID, input.payload, submitContext(provider, user));
292
+ return { success: result.Success, errorMessage: result.ErrorMessage };
293
+ }
294
+ };
295
+ TaskGraphUpdateTaskInputServerOperation = __decorate([
296
+ RegisterClass(BaseRemotableOperation, 'TaskGraph.UpdateTaskInput')
297
+ ], TaskGraphUpdateTaskInputServerOperation);
298
+ export { TaskGraphUpdateTaskInputServerOperation };
299
+ /** Prevents tree-shaking of the registered operation classes. */
300
+ export function LoadTaskGraphDebugOperations() {
301
+ void TaskGraphPauseServerOperation;
302
+ void TaskGraphResumeServerOperation;
303
+ void TaskGraphStepServerOperation;
304
+ void TaskGraphSetBreakpointsServerOperation;
305
+ void TaskGraphOverrideEdgeServerOperation;
306
+ void TaskGraphSkipTaskServerOperation;
307
+ void TaskGraphForceCompleteTaskServerOperation;
308
+ void TaskGraphUpdateTaskInputServerOperation;
309
+ }
310
+ //# sourceMappingURL=TaskGraphDebugOperations.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"TaskGraphDebugOperations.js","sourceRoot":"","sources":["../../src/operations/TaskGraphDebugOperations.ts"],"names":[],"mappings":";;;;;;AAAA;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,OAAO,EAAE,aAAa,EAAE,MAAM,wBAAwB,CAAC;AACvD,OAAO,EAAE,sBAAsB,EAAqB,OAAO,EAAY,MAAM,sBAAsB,CAAC;AACpG,OAAO,EAAE,UAAU,EAAE,MAAM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C;IAC/C,KAAK,uCAAuC,CAAC;AACjD,CAAC"}
@@ -6,9 +6,25 @@ import { TaskGraphSubmitOperation, TaskGraphCancelOperation, TaskGraphRetryTaskO
6
6
  * Returning before execution is the point: the caller is freed the moment the work is safe, and the
7
7
  * dispatcher owns it from there. That is what lets an agent submit a graph over MCP without holding
8
8
  * anything open.
9
+ *
10
+ * **REMAINING LIMITATION (C5/D1): a remote submission does not bind to an agent run.**
11
+ * `TaskGraphSubmitContext` carries `AgentRunID`, and this input deliberately has no field for it —
12
+ * whether a remote caller's graph should BIND to an agent run (cost rollup, `reinvoke` routing) is
13
+ * the D1 execution-identity design question, to be decided rather than defaulted. Until then a
14
+ * remote submission records `submittedByAgentRunID: null`: no cost rollup, and `reinvoke` degrades
15
+ * to a message. The other two fields the in-process path carries DO ride this operation now —
16
+ * `reinvokeDepth` (clamped; see below) so the runaway-loop cap counts remote hops, and the R3-3
17
+ * `invocation` envelope so `data.*`/`context.*` conditions evaluate against the invocation instead
18
+ * of nothing.
9
19
  */
10
20
  export declare class TaskGraphSubmitServerOperation extends TaskGraphSubmitOperation {
11
- protected InternalExecute(input: TaskGraphSubmitInput, provider: IMetadataProvider, user: UserInfo): Promise<TaskGraphSubmitOutput>;
21
+ protected InternalExecute(input: TaskGraphSubmitInput & {
22
+ reinvokeDepth?: number;
23
+ invocation?: {
24
+ data?: unknown;
25
+ context?: unknown;
26
+ };
27
+ }, provider: IMetadataProvider, user: UserInfo): Promise<TaskGraphSubmitOutput>;
12
28
  }
13
29
  /** `TaskGraph.Cancel` — cancel a graph and every task in it that has not already settled. */
14
30
  export declare class TaskGraphCancelServerOperation extends TaskGraphCancelOperation {
@@ -21,7 +37,9 @@ export declare class TaskGraphCancelServerOperation extends TaskGraphCancelOpera
21
37
  * exactly as stuck as before, because nothing downstream ever becomes eligible again.
22
38
  */
23
39
  export declare class TaskGraphRetryTaskServerOperation extends TaskGraphRetryTaskOperation {
24
- protected InternalExecute(input: TaskGraphRetryInput, provider: IMetadataProvider, user: UserInfo): Promise<TaskGraphControlOutput>;
40
+ protected InternalExecute(input: TaskGraphRetryInput & {
41
+ inputPayload?: Record<string, unknown> | string;
42
+ }, provider: IMetadataProvider, user: UserInfo): Promise<TaskGraphControlOutput>;
25
43
  }
26
44
  /**
27
45
  * `TaskGraph.GetStatus` — snapshot a graph's progress without waiting for anything.
@@ -1 +1 @@
1
- {"version":3,"file":"TaskGraphOperations.d.ts","sourceRoot":"","sources":["../../src/operations/TaskGraphOperations.ts"],"names":[],"mappings":"AAqBA,OAAO,EAA0B,iBAAiB,EAAW,QAAQ,EAAE,MAAM,sBAAsB,CAAC;AACpG,OAAO,EAEH,wBAAwB,EACxB,wBAAwB,EACxB,2BAA2B,EAC3B,2BAA2B,EAC3B,KAAK,oBAAoB,EACzB,KAAK,qBAAqB,EAC1B,KAAK,qBAAqB,EAC1B,KAAK,sBAAsB,EAC3B,KAAK,mBAAmB,EACxB,KAAK,qBAAqB,EAC7B,MAAM,+BAA+B,CAAC;AAuCvC;;;;;;GAMG;AACH,qBACa,8BAA+B,SAAQ,wBAAwB;cACxD,eAAe,CAC3B,KAAK,EAAE,oBAAoB,EAC3B,QAAQ,EAAE,iBAAiB,EAC3B,IAAI,EAAE,QAAQ,GACf,OAAO,CAAC,qBAAqB,CAAC;CAepC;AAED,6FAA6F;AAC7F,qBACa,8BAA+B,SAAQ,wBAAwB;cACxD,eAAe,CAC3B,KAAK,EAAE,qBAAqB,EAC5B,QAAQ,EAAE,iBAAiB,EAC3B,IAAI,EAAE,QAAQ,GACf,OAAO,CAAC,sBAAsB,CAAC;CAYrC;AAED;;;;;GAKG;AACH,qBACa,iCAAkC,SAAQ,2BAA2B;cAC9D,eAAe,CAC3B,KAAK,EAAE,mBAAmB,EAC1B,QAAQ,EAAE,iBAAiB,EAC3B,IAAI,EAAE,QAAQ,GACf,OAAO,CAAC,sBAAsB,CAAC;CAUrC;AAED;;;;;;;GAOG;AACH,qBACa,iCAAkC,SAAQ,2BAA2B;cAC9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C,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,MAAM,CAAA;KAAE,EAChF,QAAQ,EAAE,iBAAiB,EAC3B,IAAI,EAAE,QAAQ,GACf,OAAO,CAAC,sBAAsB,CAAC;CAUrC;AAED;;;;;;;GAOG;AACH,qBACa,iCAAkC,SAAQ,2BAA2B;cAC9D,eAAe,CAC3B,KAAK,EAAE,qBAAqB,EAC5B,QAAQ,EAAE,iBAAiB,EAC3B,IAAI,EAAE,QAAQ,GACf,OAAO,CAAC,qBAAqB,CAAC;CAkCpC;AAED,iEAAiE;AACjE,wBAAgB,uBAAuB,IAAI,IAAI,CAY9C"}
@@ -28,8 +28,9 @@ import { RegisterClass } from '@memberjunction/global';
28
28
  import { BaseRemotableOperation, RunView } from '@memberjunction/core';
29
29
  import { TaskGraphSubmitOperation, TaskGraphCancelOperation, TaskGraphRetryTaskOperation, TaskGraphGetStatusOperation, } from '@memberjunction/core-entities';
30
30
  import { ComputeParentRollup } from '@memberjunction/ai-core-plus';
31
- import { TaskGraphService } from '../TaskGraphService.js';
31
+ import { ClampReinvokeDepth, TaskGraphService } from '../TaskGraphService.js';
32
32
  import { LoadWorkflowDraftOperation } from './WorkflowDraftOperation.js';
33
+ import { LoadTaskGraphDebugOperations } from './TaskGraphDebugOperations.js';
33
34
  /**
34
35
  * Builds the service context from the operation's provider + user.
35
36
  *
@@ -51,15 +52,42 @@ function submitContext(provider, user, environmentID, conversationDetailID) {
51
52
  * Returning before execution is the point: the caller is freed the moment the work is safe, and the
52
53
  * dispatcher owns it from there. That is what lets an agent submit a graph over MCP without holding
53
54
  * anything open.
55
+ *
56
+ * **REMAINING LIMITATION (C5/D1): a remote submission does not bind to an agent run.**
57
+ * `TaskGraphSubmitContext` carries `AgentRunID`, and this input deliberately has no field for it —
58
+ * whether a remote caller's graph should BIND to an agent run (cost rollup, `reinvoke` routing) is
59
+ * the D1 execution-identity design question, to be decided rather than defaulted. Until then a
60
+ * remote submission records `submittedByAgentRunID: null`: no cost rollup, and `reinvoke` degrades
61
+ * to a message. The other two fields the in-process path carries DO ride this operation now —
62
+ * `reinvokeDepth` (clamped; see below) so the runaway-loop cap counts remote hops, and the R3-3
63
+ * `invocation` envelope so `data.*`/`context.*` conditions evaluate against the invocation instead
64
+ * of nothing.
54
65
  */
55
66
  let TaskGraphSubmitServerOperation = class TaskGraphSubmitServerOperation extends TaskGraphSubmitOperation {
56
- async InternalExecute(input, provider, user) {
67
+ async InternalExecute(
68
+ // Widened locally until CodeGen re-emits the base from the updated metadata row, the
69
+ // RetryTask precedent. Two of the three fields the in-process path carries now ride the
70
+ // remote one too: `reinvokeDepth`, because the runaway-loop cap is a safety bound that
71
+ // must count remote hops the same as local ones, and `invocation`, because a flow graph's
72
+ // documented `data.*`/`context.*` conditions (R3-3) are dead on arrival without it.
73
+ // `AgentRunID` stays deliberately absent — whether a remote caller's graph should BIND to
74
+ // an agent run is the D1 execution-identity design question, not a dropped field.
75
+ input, provider, user) {
57
76
  if (!input?.spec)
58
77
  throw new Error('spec is required');
59
78
  if (!input?.environmentID)
60
79
  throw new Error('environmentID is required');
61
80
  const spec = input.spec;
62
- const result = await new TaskGraphService().Submit(spec, submitContext(provider, user, input.environmentID, input.conversationDetailID));
81
+ const invocation = input.invocation && (input.invocation.data !== undefined || input.invocation.context !== undefined)
82
+ ? { Data: input.invocation.data, Context: input.invocation.context }
83
+ : undefined;
84
+ const result = await new TaskGraphService().Submit(spec, {
85
+ ...submitContext(provider, user, input.environmentID, input.conversationDetailID),
86
+ // CLAMPED, not merely finite — see ClampReinvokeDepth: a negative caller-supplied
87
+ // seed would buy hops against the runaway-loop cap.
88
+ ReinvokeDepth: ClampReinvokeDepth(input.reinvokeDepth),
89
+ Invocation: invocation,
90
+ });
63
91
  return {
64
92
  success: result.Success,
65
93
  parentTaskID: result.ParentTaskID,
@@ -78,9 +106,12 @@ let TaskGraphCancelServerOperation = class TaskGraphCancelServerOperation extend
78
106
  throw new Error('parentTaskID is required');
79
107
  // EnvironmentID is unused on the cancel path — the graph already exists, so nothing new is
80
108
  // created that would need one.
81
- const ok = await new TaskGraphService().Cancel(input.parentTaskID, submitContext(provider, user, ''));
82
- if (!ok)
83
- return { success: false, errorMessage: 'Cancel failed; see the server log for detail.' };
109
+ const result = await new TaskGraphService().Cancel(input.parentTaskID, submitContext(provider, user, ''));
110
+ // The verdict names what survived, so the caller can tell the user which parts of their
111
+ // workflow are still running rather than reporting a success the graph does not reflect.
112
+ if (!result.Success) {
113
+ return { success: false, errorMessage: result.ErrorMessage ?? 'Cancel failed; see the server log for detail.' };
114
+ }
84
115
  const parent = await provider.GetEntityObject('MJ: Tasks', user);
85
116
  const loaded = await parent.Load(input.parentTaskID);
86
117
  return { success: true, status: loaded ? parent.Status : undefined };
@@ -97,10 +128,14 @@ export { TaskGraphCancelServerOperation };
97
128
  * exactly as stuck as before, because nothing downstream ever becomes eligible again.
98
129
  */
99
130
  let TaskGraphRetryTaskServerOperation = class TaskGraphRetryTaskServerOperation extends TaskGraphRetryTaskOperation {
100
- async InternalExecute(input, provider, user) {
131
+ async InternalExecute(
132
+ // Widened locally until CodeGen re-emits the base from the updated metadata row: the
133
+ // optional edited input rides the retry so an operator can correct the brief they watched
134
+ // fail. See the InputTypeDefinition on the `TaskGraph.RetryTask` metadata record.
135
+ input, provider, user) {
101
136
  if (!input?.taskID)
102
137
  throw new Error('taskID is required');
103
- const ok = await new TaskGraphService().Retry(input.taskID, submitContext(provider, user, ''));
138
+ const ok = await new TaskGraphService().Retry(input.taskID, submitContext(provider, user, ''), input.inputPayload);
104
139
  if (!ok)
105
140
  return { success: false, errorMessage: 'Retry failed; the task may not be in a Failed state.' };
106
141
  const task = await provider.GetEntityObject('MJ: Tasks', user);
@@ -164,5 +199,9 @@ export function LoadTaskGraphOperations() {
164
199
  // Workflow authoring rides the same loader: a host that starts the dispatcher but never
165
200
  // registered these would accept a draft request and route it to the contract-only base.
166
201
  LoadWorkflowDraftOperation();
202
+ // The debug/runner control plane (pause, step, breakpoints, interventions) rides it too, for
203
+ // the same reason — a host with the dispatcher but no debug verbs would accept a console's
204
+ // pause request and route it to the throwing base.
205
+ LoadTaskGraphDebugOperations();
167
206
  }
168
207
  //# sourceMappingURL=TaskGraphOperations.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"TaskGraphOperations.js","sourceRoot":"","sources":["../../src/operations/TaskGraphOperations.ts"],"names":[],"mappings":";;;;;;AAAA;;;;;;;;;;;;;;;;;;;GAmBG;AACH,OAAO,EAAE,aAAa,EAAE,MAAM,wBAAwB,CAAC;AACvD,OAAO,EAAE,sBAAsB,EAAqB,OAAO,EAAY,MAAM,sBAAsB,CAAC;AACpG,OAAO,EAEH,wBAAwB,EACxB,wBAAwB,EACxB,2BAA2B,EAC3B,2BAA2B,GAO9B,MAAM,+BAA+B,CAAC;AACvC,OAAO,EAAE,mBAAmB,EAAgD,MAAM,8BAA8B,CAAC;AACjH,OAAO,EAAE,gBAAgB,EAA0B,MAAM,qBAAqB,CAAC;AAC/E,OAAO,EAAE,0BAA0B,EAAE,MAAM,0BAA0B,CAAC;AAetE;;;;;;GAMG;AACH,SAAS,aAAa,CAClB,QAA2B,EAC3B,IAAc,EACd,aAAqB,EACrB,oBAAoC;IAEpC,OAAO;QACH,aAAa,EAAE,aAAa;QAC5B,oBAAoB,EAAE,oBAAoB,IAAI,IAAI;QAClD,WAAW,EAAE,IAAI;QACjB,QAAQ,EAAE,QAAQ;KACrB,CAAC;AACN,CAAC;AAED;;;;;;GAMG;AAEI,IAAM,8BAA8B,GAApC,MAAM,8BAA+B,SAAQ,wBAAwB;IAC9D,KAAK,CAAC,eAAe,CAC3B,KAA2B,EAC3B,QAA2B,EAC3B,IAAc;QAEd,IAAI,CAAC,KAAK,EAAE,IAAI;YAAE,MAAM,IAAI,KAAK,CAAC,kBAAkB,CAAC,CAAC;QACtD,IAAI,CAAC,KAAK,EAAE,aAAa;YAAE,MAAM,IAAI,KAAK,CAAC,2BAA2B,CAAC,CAAC;QAExE,MA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,CAAC;CACJ,CAAA;AAvCY,iCAAiC;IAD7C,aAAa,CAAC,sBAAsB,EAAE,qBAAqB,CAAC;GAChD,iCAAiC,CAuC7C;;AAED,iEAAiE;AACjE,MAAM,UAAU,uBAAuB;IACnC,KAAK,8BAA8B,CAAC;IACpC,KAAK,8BAA8B,CAAC;IACpC,KAAK,iCAAiC,CAAC;IACvC,KAAK,iCAAiC,CAAC;IACvC,wFAAwF;IACxF,wFAAwF;IACxF,0BAA0B,EAAE,CAAC;AACjC,CAAC"}
1
+ {"version":3,"file":"TaskGraphOperations.js","sourceRoot":"","sources":["../../src/operations/TaskGraphOperations.ts"],"names":[],"mappings":";;;;;;AAAA;;;;;;;;;;;;;;;;;;;GAmBG;AACH,OAAO,EAAE,aAAa,EAAE,MAAM,wBAAwB,CAAC;AACvD,OAAO,EAAE,sBAAsB,EAAqB,OAAO,EAAY,MAAM,sBAAsB,CAAC;AACpG,OAAO,EAEH,wBAAwB,EACxB,wBAAwB,EACxB,2BAA2B,EAC3B,2BAA2B,GAO9B,MAAM,+BAA+B,CAAC;AACvC,OAAO,EAAE,mBAAmB,EAAkF,MAAM,8BAA8B,CAAC;AACnJ,OAAO,EAAE,kBAAkB,EAAE,gBAAgB,EAA0B,MAAM,qBAAqB,CAAC;AACnG,OAAO,EAAE,0BAA0B,EAAE,MAAM,0BAA0B,CAAC;AACtE,OAAO,EAAE,4BAA4B,EAAE,MAAM,4BAA4B,CAAC;AAe1E;;;;;;GAMG;AACH,SAAS,aAAa,CAClB,QAA2B,EAC3B,IAAc,EACd,aAAqB,EACrB,oBAAoC;IAEpC,OAAO;QACH,aAAa,EAAE,aAAa;QAC5B,oBAAoB,EAAE,oBAAoB,IAAI,IAAI;QAClD,WAAW,EAAE,IAAI;QACjB,QAAQ,EAAE,QAAQ;KACrB,CAAC;AACN,CAAC;AAED;;;;;;;;;;;;;;;;GAgBG;AAEI,IAAM,8BAA8B,GAApC,MAAM,8BAA+B,SAAQ,wBAAwB;IAC9D,KAAK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AC7B,6FAA6F;IAC7F,2FAA2F;IAC3F,mDAAmD;IACnD,4BAA4B,EAAE,CAAC;AACnC,CAAC"}
@@ -0,0 +1,85 @@
1
+ /** How long after settling a graph is still eligible for a normal continuation delivery. */
2
+ export declare const UNSETTLED_SWEEP_WINDOW_HOURS = 24;
3
+ /**
4
+ * How far back the ONE startup sweep looks.
5
+ *
6
+ * Wider than the steady-state window because a deployment gap is exactly the case the rescue exists
7
+ * for: nothing was running, so nothing swept, and the graphs stranded by whatever took the process
8
+ * down are older than a day by the time it returns. Runs once at `Start()`, so the cost of the wider
9
+ * scan is paid once per process, not once per poll.
10
+ */
11
+ export declare const UNSETTLED_STARTUP_WINDOW_HOURS: number;
12
+ /**
13
+ * How long a settled graph waits for its submitting run to park before giving up on it.
14
+ *
15
+ * `BaseAgent.finalizeAgentRun` parks the run within moments of the graph becoming dispatchable, so
16
+ * the honest window is seconds; anything beyond this means the submitting process is gone. Generous
17
+ * enough that a loaded machine does not trip it, short enough that a dead submitter cannot hold a
18
+ * completed workflow's announcement hostage for a day.
19
+ */
20
+ export declare const SUBMITTER_PARK_GRACE_MS: number;
21
+ /**
22
+ * Whether this pass's writes to the submitting run will mean anything yet.
23
+ *
24
+ * **The `Running` case is the whole point.** A graph can settle before the run that submitted it has
25
+ * parked at all: `finalizeAgentRun` sets `Paused` *after* the graph is durable and dispatchable, so
26
+ * a fast graph finishes first. Both of the settled branch's writes then land wrong — the lifecycle
27
+ * write silently returns (its guard is `Status === 'Paused'`), and the cost write is overwritten
28
+ * moments later by finalize's own full-row save carrying the nulls it held before the dispatcher
29
+ * wrote anything. Neither failure is visible, and the pass then claims the delivery marker, making
30
+ * itself the last pass ever to look at the graph. The run stays `Paused` forever.
31
+ *
32
+ * Every other status proceeds: `Paused` is the case settlement exists for, and a run already
33
+ * `Completed`/`Failed`/`Cancelled` reached that for its own reasons — the lifecycle write's own
34
+ * guard declines it, which is correct, and delivery should not be held up by it.
35
+ *
36
+ * **Bounded, because "not parked yet" and "the submitter died before parking" look identical from
37
+ * here.** Waiting forever on the second loses the outcome of work that actually completed, which is
38
+ * strictly worse than announcing it late — so past the grace period the caller proceeds and says
39
+ * why. The run stays `Running`, which is visibly wrong and belongs to whatever reconciles abandoned
40
+ * runs, not to the graph that finished correctly.
41
+ *
42
+ * @param settledForMs how long ago the graph reached its terminal status
43
+ */
44
+ export declare function IsSubmittingRunReady(runStatus: string, settledForMs: number, graceMs?: number): boolean;
45
+ /** The shape the third sweep arm selects — everything needed to judge "settled but undelivered". */
46
+ export type UnsettledCandidate = {
47
+ ID: string | null;
48
+ InputPayload: string | null;
49
+ };
50
+ /**
51
+ * The oldest `__mj_UpdatedAt` still worth rescuing, as an ISO string for the SQL filter.
52
+ *
53
+ * The bound is on ABANDONMENT, not age: `__mj_UpdatedAt` advances on every settle attempt, so a
54
+ * graph something is still actively retrying keeps re-entering the window. What ages out is a graph
55
+ * nothing has touched — which is the only kind this sweep can help.
56
+ */
57
+ export declare function SweepCutoff(now: Date, windowHours: number): string;
58
+ /**
59
+ * Picks the graphs that reached a terminal status without delivering their continuation.
60
+ *
61
+ * Filtered here rather than in SQL because the delivery marker lives inside the parent's
62
+ * `InputPayload` JSON, and it lives there deliberately: one representation means the writer
63
+ * (`TryClaimContinuation`) and the reader are pinned to each other, and a graph settled before any
64
+ * of this existed is judged by the same parser as one settled after — which a new column plus a
65
+ * backfill could not promise.
66
+ *
67
+ * **An unreadable payload counts as undelivered.** It is selected, the claim then refuses it
68
+ * (`ISJSON` guard), and it is selected again next pass until it ages out of the window. That is the
69
+ * intended shape: we cannot prove such a graph was delivered, so we must not assume it, and the
70
+ * window is what keeps "cannot prove" from meaning "retry forever".
71
+ */
72
+ export declare function SelectUnsettledGraphIDs(rows: readonly UnsettledCandidate[]): string[];
73
+ /**
74
+ * Whether a settlement is too old to deliver as if it had just happened.
75
+ *
76
+ * A graph stranded by a crash and found days later should still settle its run and stop showing as
77
+ * `Paused` — but re-invoking the submitting agent on stale context, or messaging a conversation
78
+ * about work that finished last week, is worse than not delivering. So an expired settlement takes
79
+ * the same once-only claim and records itself as `expired`, which keeps the distinction visible
80
+ * afterwards instead of erasing it.
81
+ *
82
+ * A graph with no `CompletedAt` has not settled at all, so there is nothing to have expired.
83
+ */
84
+ export declare function IsSettlementExpired(completedAt: Date | null | undefined, now: Date, windowHours?: number): boolean;
85
+ //# sourceMappingURL=settlement-rescue.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"settlement-rescue.d.ts","sourceRoot":"","sources":["../src/settlement-rescue.ts"],"names":[],"mappings":"AAoBA,4FAA4F;AAC5F,eAAO,MAAM,4BAA4B,KAAK,CAAC;AAE/C;;;;;;;GAOG;AACH,eAAO,MAAM,8BAA8B,QAAU,CAAC;AAEtD;;;;;;;GAOG;AACH,eAAO,MAAM,uBAAuB,QAAa,CAAC;AAElD;;;;;;;;;;;;;;;;;;;;;;GAsBG;AACH,wBAAgB,oBAAoB,CAChC,SAAS,EAAE,MAAM,EACjB,YAAY,EAAE,MAAM,EACpB,OAAO,GAAE,MAAgC,GAC1C,OAAO,CAGT;AAED,oGAAoG;AACpG,MAAM,MAAM,kBAAkB,GAAG;IAC7B,EAAE,EAAE,MAAM,GAAG,IAAI,CAAC;IAClB,YAAY,EAAE,MAAM,GAAG,IAAI,CAAC;CAC/B,CAAC;AAEF;;;;;;GAMG;AACH,wBAAgB,WAAW,CAAC,GAAG,EAAE,IAAI,EAAE,WAAW,EAAE,MAAM,GAAG,MAAM,CAElE;AAED;;;;;;;;;;;;;GAaG;AACH,wBAAgB,uBAAuB,CAAC,IAAI,EAAE,SAAS,kBAAkB,EAAE,GAAG,MAAM,EAAE,CAQrF;AAED;;;;;;;;;;GAUG;AACH,wBAAgB,mBAAmB,CAC/B,WAAW,EAAE,IAAI,GAAG,IAAI,GAAG,SAAS,EACpC,GAAG,EAAE,IAAI,EACT,WAAW,GAAE,MAAqC,GACnD,OAAO,CAGT"}