@memberjunction/ai-agents 6.1.2 → 6.2.0-edge.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +6 -5
- package/dist/agent-types/base-agent-type.d.ts +26 -0
- package/dist/agent-types/base-agent-type.d.ts.map +1 -1
- package/dist/agent-types/base-agent-type.js +13 -0
- package/dist/agent-types/base-agent-type.js.map +1 -1
- package/dist/agent-types/flow-agent-type.d.ts +110 -34
- package/dist/agent-types/flow-agent-type.d.ts.map +1 -1
- package/dist/agent-types/flow-agent-type.js +156 -79
- package/dist/agent-types/flow-agent-type.js.map +1 -1
- package/dist/base-agent.d.ts +24 -0
- package/dist/base-agent.d.ts.map +1 -1
- package/dist/base-agent.js +57 -1
- package/dist/base-agent.js.map +1 -1
- package/package.json +18 -18
package/README.md
CHANGED
|
@@ -142,13 +142,14 @@ Conversational agent that runs in a loop: prompt -> decide -> act -> repeat. Bes
|
|
|
142
142
|
|
|
143
143
|
Step-based agent that follows a predefined flow graph — steps with explicit conditional paths between them. Best for deterministic workflows where the execution path is known in advance.
|
|
144
144
|
|
|
145
|
-
**A Flow agent no longer walks its own graph.** `DetermineInitialStep` compiles the agent's `AIAgentStep` + `AIAgentStepPath` rows into a `TaskGraphSpec` and returns a `Tasks` step; `BaseAgent.executeTasksStep` submits it and detaches. From that point the workflow is `Task` rows owned by the durable dispatcher in [`@memberjunction/task-graph`](../../TaskGraph/README.md), with the same claiming, conditions, skip cascade, retry and failure semantics as any other graph — one traversal engine, one set of rules, one place a bug can be fixed.
|
|
145
|
+
**A top-level Flow agent no longer walks its own graph.** `DetermineInitialStep` compiles the agent's `AIAgentStep` + `AIAgentStepPath` rows into a `TaskGraphSpec` and returns a `Tasks` step; `BaseAgent.executeTasksStep` submits it and detaches. From that point the workflow is `Task` rows owned by the durable dispatcher in [`@memberjunction/task-graph`](../../TaskGraph/README.md), with the same claiming, conditions, skip cascade, retry and failure semantics as any other graph — one traversal engine, one set of rules, one place a bug can be fixed.
|
|
146
146
|
|
|
147
|
-
|
|
147
|
+
Consequences worth knowing before you debug one:
|
|
148
148
|
|
|
149
|
-
- **
|
|
150
|
-
- **
|
|
151
|
-
- **A `
|
|
149
|
+
- **A dispatched run ends at submission.** It returns a handle ("Started — 4 tasks running"), not a result, and parks as `Paused` until the dispatcher settles the graph. Per-step detail lives in `Task` rows, not in `AIAgentRunStep`, and cost arrives afterwards via `TotalCostRollup` (see the guide).
|
|
150
|
+
- **A run that needs the result walks the flow in-process.** A sub-agent run (one with `parentRun`) does this automatically, and a top-level caller opts in with `agentTypeParams.executionMode: 'inRun'` (`FlowAgentExecuteParams`). The run returns the flow's final payload, as in 5.x, and `startAtStep` works. A dispatched run that reaches the walker by mistake is refused at its choke point.
|
|
151
|
+
- **The mode is on the run.** A completed `Decision` step named "Workflow runs in this run" or "Workflow runs on the task-graph dispatcher" records which engine ran it and why.
|
|
152
|
+
- **A dispatched `Sub-Agent` node starts its own `AIAgentRun`**, linked from `Task.AgentRunID` and parented to the submitting run. If that sub-agent is itself a Flow agent, it runs in-process and returns its result to the task.
|
|
152
153
|
|
|
153
154
|
See the **[Workflows and Task Graphs Guide](../../../guides/WORKFLOW_AND_TASK_GRAPH_GUIDE.md)** for the full model: node kinds, exclusive groups, payload mappings, loops, failure semantics, observability, and a worked configuration example.
|
|
154
155
|
|
|
@@ -16,6 +16,21 @@ import { MJAIAgentTypeEntity } from '@memberjunction/core-entities';
|
|
|
16
16
|
import { MJAIPromptEntityExtended } from "@memberjunction/ai-core-plus";
|
|
17
17
|
import { JSONValidator } from '@memberjunction/global';
|
|
18
18
|
import { ActionResult } from '@memberjunction/actions-base';
|
|
19
|
+
/**
|
|
20
|
+
* How an agent type decided to execute a run, recorded on the run as a completed `Decision` step.
|
|
21
|
+
*
|
|
22
|
+
* Some agent types can run the same agent in more than one way (a Flow agent runs either in this
|
|
23
|
+
* process or on the task-graph dispatcher). Which way was taken changes what the run record means,
|
|
24
|
+
* so it belongs on the record, not only in a log line that is gone by the time someone investigates.
|
|
25
|
+
*/
|
|
26
|
+
export interface AgentTypeExecutionRouting {
|
|
27
|
+
/** The step name shown in the run timeline, naming the chosen mode. */
|
|
28
|
+
StepName: string;
|
|
29
|
+
/** Why this mode was chosen, in words an operator can act on. */
|
|
30
|
+
Reason: string;
|
|
31
|
+
/** Stored as the step's output data. */
|
|
32
|
+
Detail: Record<string, string>;
|
|
33
|
+
}
|
|
19
34
|
/**
|
|
20
35
|
* Abstract base class for agent type implementations.
|
|
21
36
|
*
|
|
@@ -398,6 +413,17 @@ export declare abstract class BaseAgentType {
|
|
|
398
413
|
* @since 2.113.0
|
|
399
414
|
*/
|
|
400
415
|
HandleStepFallback<P = any, ATS = any>(step: BaseAgentNextStep<P>, config: AgentConfiguration, params: ExecuteAgentParams<P>, payload: P, agentTypeState: ATS): Promise<BaseAgentNextStep<P> | null>;
|
|
416
|
+
/**
|
|
417
|
+
* Describes how this run is being executed, once {@link DetermineInitialStep} has decided.
|
|
418
|
+
*
|
|
419
|
+
* BaseAgent calls this right after `DetermineInitialStep` and, when it returns a value, writes
|
|
420
|
+
* it to the run as a completed `Decision` step. Default: null, meaning the agent type has only
|
|
421
|
+
* one way to run and there is nothing to record.
|
|
422
|
+
*
|
|
423
|
+
* @param agentTypeState - The state returned by {@link InitializeAgentTypeState}
|
|
424
|
+
* @since 6.1.3
|
|
425
|
+
*/
|
|
426
|
+
DescribeExecutionRouting<ATS>(agentTypeState: ATS): AgentTypeExecutionRouting | null;
|
|
401
427
|
/**
|
|
402
428
|
* Determines if loop results should be injected as a temporary user message
|
|
403
429
|
* before the next prompt execution (for LLM reasoning).
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"base-agent-type.d.ts","sourceRoot":"","sources":["../../src/agent-types/base-agent-type.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAEH,OAAO,EAAE,cAAc,EAAE,iBAAiB,EAAE,iBAAiB,EAAE,yBAAyB,EAAE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,EAAE;QACL,IAAI,EAAE,GAAG,CAAC;QACV,KAAK,EAAE,MAAM,CAAC;QACd,OAAO,EAAE,CAAC,CAAC;QACX,QAAQ,EAAE,SAAS,GAAG,OAAO,CAAC;QAC9B,YAAY,EAAE,MAAM,CAAC;QACrB,YAAY,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;QACtC,eAAe,CAAC,EAAE;YAAE,IAAI,EAAE,MAAM,CAAC;YAAC,OAAO,EAAE,MAAM,CAAC;YAAC,kBAAkB,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAA;SAAE,CAAC;KACpG,GACF;QACC,YAAY,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;QACvC,eAAe,CAAC,EAAE;YAAE,IAAI,EAAE,MAAM,CAAC;YAAC,OAAO,EAAE,MAAM,CAAC;YAAC,kBAAkB,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAA;SAAE,CAAC;QACjG,OAAO,CAAC,EAAE,CAAC,CAAC;KACf,GAAG,IAAI;IAIR;;;;;;;;;;OAUG;IACI,kBAAkB,CAAC,CAAC,CAAC,EACxB,eAAe,EAAE;QACb,aAAa,CAAC,EAAE,YAAY,EAAE,CAAC;QAC/B,cAAc,CAAC,EAAE,GAAG,CAAC;QACrB,cAAc,EAAE,CAAC,CAAC;QAClB,YAAY,EAAE,MAAM,CAAC;QACrB,IAAI,EAAE,GAAG,CAAC;QACV,KAAK,EAAE,MAAM,CAAC;QACd,WAAW,EAAE,GAAG,CAAC;KACpB,GACF,CAAC,GAAG,IAAI;CAGd"}
|
|
@@ -398,6 +398,19 @@ export class BaseAgentType {
|
|
|
398
398
|
// (fall back to prompt execution if prompts are configured)
|
|
399
399
|
return null;
|
|
400
400
|
}
|
|
401
|
+
/**
|
|
402
|
+
* Describes how this run is being executed, once {@link DetermineInitialStep} has decided.
|
|
403
|
+
*
|
|
404
|
+
* BaseAgent calls this right after `DetermineInitialStep` and, when it returns a value, writes
|
|
405
|
+
* it to the run as a completed `Decision` step. Default: null, meaning the agent type has only
|
|
406
|
+
* one way to run and there is nothing to record.
|
|
407
|
+
*
|
|
408
|
+
* @param agentTypeState - The state returned by {@link InitializeAgentTypeState}
|
|
409
|
+
* @since 6.1.3
|
|
410
|
+
*/
|
|
411
|
+
DescribeExecutionRouting(agentTypeState) {
|
|
412
|
+
return null;
|
|
413
|
+
}
|
|
401
414
|
/**
|
|
402
415
|
* Determines if loop results should be injected as a temporary user message
|
|
403
416
|
* before the next prompt execution (for LLM reasoning).
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"base-agent-type.js","sourceRoot":"","sources":["../../src/agent-types/base-agent-type.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAMH,OAAO,EAAE,QAAQ,EAAE,aAAa,EAAE,MAAM,wBAAwB,CAAC;AACjE,OAAO,EAAE,QAAQ,EAAE,uBAAuB,EAAE,MAAM,sBAAsB,CAAC;
|
|
1
|
+
{"version":3,"file":"base-agent-type.js","sourceRoot":"","sources":["../../src/agent-types/base-agent-type.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAMH,OAAO,EAAE,QAAQ,EAAE,aAAa,EAAE,MAAM,wBAAwB,CAAC;AACjE,OAAO,EAAE,QAAQ,EAAE,uBAAuB,EAAE,MAAM,sBAAsB,CAAC;AAmBzE;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAiCG;AACH,MAAM,OAAgB,aAAa;IAAnC;QACI;;;WAGG;QACO,mBAAc,GAAkB,IAAI,aAAa,EAAE,CAAC;IA8mBlE,CAAC;IA5mBG;;;;;;;;;;;;;OAaG;IACH,IAAW,uBAAuB;QAC9B,OAAO,KAAK,CAAC;IACjB,CAAC;IAED;;;OAGG;aACoB,gCAA2B,GAAG,kBAAkB,AAArB,CAAsB;IA6IxE;;;;;;;;;;;;;;;;;OAiBG;IACI,MAAM,CAAC,KAAK,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,cAAiB,EACjB,cAAmB,EACnB,WAAiC;QAEjC,sCAAsC;QACtC,oDAAoD;QACpD,OAAO,IAAI,CAAC;IAChB,CAAC;IAED;;;;;;;;;;;;;;;OAeG;IACI,KAAK,CAAC,uBAAuB,CAChC,cAAmB,EACnB,eAAqC,EACrC,cAAiB,EACjB,cAAmB,EACnB,WAAiC;QAEjC,sCAAsC;QACtC,oDAAoD;QACpD,OAAO,IAAI,CAAC;IAChB,CAAC;IAED;;;;;;;;;;OAUG;IACH,IAAW,yBAAyB;QAChC,OAAO,IAAI,CAAC,CAAC,4CAA4C;IAC7D,CAAC;IAED;;;;;;;;;OASG;IACI,8BAA8B;QACjC,OAAO,kEAAkE;YAClE,kEAAkE,CAAC;IAC9E,CAAC;IAED;;;;;;;;;;;;;;;;;;;OAmBG;IACI,KAAK,CAAC,kBAAkB,CAC3B,IAA0B,EAC1B,MAA0B,EAC1B,MAA6B,EAC7B,OAAU,EACV,cAAmB;QAEnB,2EAA2E;QAC3E,4DAA4D;QAC5D,OAAO,IAAI,CAAC;IAChB,CAAC;IAED;;;;;;;;;OASG;IACI,wBAAwB,CAAM,cAAmB;QACpD,OAAO,IAAI,CAAC;IAChB,CAAC;IAED;;;;;;;;;OASG;IACH,IAAW,0BAA0B;QACjC,OAAO,IAAI,CAAC,CAAE,4CAA4C;IAC9D,CAAC;IAED;;;;;;;;;;OAUG;IACI,mBAAmB,CACtB,OAQC;QAMD,OAAO,IAAI,CAAC,CAAE,6BAA6B;IAC/C,CAAC;IAED;;;;;;;;;;OAUG;IACI,kBAAkB,CACrB,eAQC;QAED,OAAO,IAAI,CAAC,CAAE,6BAA6B;IAC/C,CAAC"}
|
|
@@ -10,11 +10,27 @@
|
|
|
10
10
|
* @author MemberJunction.com
|
|
11
11
|
* @since 2.76.0
|
|
12
12
|
*/
|
|
13
|
-
import { BaseAgentType } from './base-agent-type.js';
|
|
13
|
+
import { BaseAgentType, type AgentTypeExecutionRouting } from './base-agent-type.js';
|
|
14
14
|
import { AIPromptRunResult, BaseAgentNextStep, AIPromptParams, AgentPayloadChangeRequest, AgentAction, ExecuteAgentParams, AgentConfiguration } from '@memberjunction/ai-core-plus';
|
|
15
15
|
import { MJAIAgentStepEntity } from '@memberjunction/core-entities';
|
|
16
16
|
import { MJAIPromptEntityExtended } from "@memberjunction/ai-core-plus";
|
|
17
17
|
import { ActionResult } from '@memberjunction/actions-base';
|
|
18
|
+
/**
|
|
19
|
+
* Where a Flow agent's steps execute.
|
|
20
|
+
*
|
|
21
|
+
* - `'dispatch'`: the flow compiles to a task graph and the durable task-graph dispatcher runs it.
|
|
22
|
+
* The run submits the graph and returns before any step has run. This survives page reloads and
|
|
23
|
+
* server restarts, and is the default for a top-level run.
|
|
24
|
+
* - `'inRun'`: this agent run walks the flow itself and returns the flow's final payload. Anything
|
|
25
|
+
* that needs the result as part of its own work uses it: a parent agent, or an API request that
|
|
26
|
+
* must answer its client. It is chosen automatically for a sub-agent run.
|
|
27
|
+
*
|
|
28
|
+
* Both modes choose outgoing paths with the same engine (`SelectOutgoingEdges`), so a flow takes
|
|
29
|
+
* the same branches either way.
|
|
30
|
+
*
|
|
31
|
+
* @since 6.1.3
|
|
32
|
+
*/
|
|
33
|
+
export type FlowExecutionMode = 'dispatch' | 'inRun';
|
|
18
34
|
/**
|
|
19
35
|
* Flow execution state that tracks the progress through the workflow.
|
|
20
36
|
* This is maintained by the Flow Agent Type during execution.
|
|
@@ -33,6 +49,13 @@ export declare class FlowExecutionState {
|
|
|
33
49
|
stepResults: Map<string, unknown>;
|
|
34
50
|
/** Ordered list of step IDs in execution order */
|
|
35
51
|
executionPath: string[];
|
|
52
|
+
/**
|
|
53
|
+
* Where this run's steps execute. Decided once by `DetermineInitialStep` and read by every
|
|
54
|
+
* later hook, so a run never switches engines part-way through.
|
|
55
|
+
*/
|
|
56
|
+
executionMode: FlowExecutionMode;
|
|
57
|
+
/** Why {@link executionMode} was chosen. Unset until `DetermineInitialStep` has decided. */
|
|
58
|
+
executionModeReason?: string;
|
|
36
59
|
/** Special fields from action output mappings (message, reasoning, confidence) */
|
|
37
60
|
specialFields?: {
|
|
38
61
|
message?: string;
|
|
@@ -95,6 +118,20 @@ export interface FlowAgentExecuteParams {
|
|
|
95
118
|
* The step's output mapping is not applied when skipped.
|
|
96
119
|
*/
|
|
97
120
|
skipSteps?: MJAIAgentStepEntity[];
|
|
121
|
+
/**
|
|
122
|
+
* Where the flow's steps execute. See {@link FlowExecutionMode}.
|
|
123
|
+
*
|
|
124
|
+
* Set `'inRun'` when the caller needs the flow's result in the same request, for example an API
|
|
125
|
+
* handler that returns the final payload to its client. A dispatched run returns as soon as its
|
|
126
|
+
* steps are scheduled, so such a caller would otherwise continue before any work had happened.
|
|
127
|
+
*
|
|
128
|
+
* When omitted, a sub-agent run (one with `parentRun`) executes `'inRun'`, because its parent
|
|
129
|
+
* consumes the result, and a top-level run executes `'dispatch'`. Setting `'dispatch'` on a
|
|
130
|
+
* sub-agent run is refused for the same reason.
|
|
131
|
+
*
|
|
132
|
+
* @since 6.1.3
|
|
133
|
+
*/
|
|
134
|
+
executionMode?: FlowExecutionMode;
|
|
98
135
|
}
|
|
99
136
|
/**
|
|
100
137
|
* Implementation of the Flow Agent Type pattern.
|
|
@@ -106,6 +143,11 @@ export interface FlowAgentExecuteParams {
|
|
|
106
143
|
* - Support for Actions, Sub-Agents, and Prompts as step types
|
|
107
144
|
* - Deterministic execution with optional AI-driven decision points
|
|
108
145
|
*
|
|
146
|
+
* **Two ways to run.** A top-level run compiles the flow to a task graph and hands it to the durable
|
|
147
|
+
* task-graph dispatcher. A run whose caller needs the result (a sub-agent run, or a caller that sets
|
|
148
|
+
* `agentTypeParams.executionMode = 'inRun'`) walks the flow in this process and returns the final
|
|
149
|
+
* payload. See {@link FlowExecutionMode}.
|
|
150
|
+
*
|
|
109
151
|
* @class FlowAgentType
|
|
110
152
|
* @extends BaseAgentType
|
|
111
153
|
*
|
|
@@ -133,26 +175,22 @@ export declare class FlowAgentType extends BaseAgentType {
|
|
|
133
175
|
*/
|
|
134
176
|
InitializeAgentTypeState<ATS = any, P = any>(params: ExecuteAgentParams<any, P>): Promise<ATS>;
|
|
135
177
|
/**
|
|
136
|
-
* Refuses to
|
|
137
|
-
*
|
|
138
|
-
* **Disabled, not deleted.** The in-run walker below is the differential suite's oracle — the
|
|
139
|
-
* only independent statement of what a flow *used* to do, and therefore the only thing the
|
|
140
|
-
* compiled graph can be checked against. Deleting it would leave the compiler unfalsifiable.
|
|
141
|
-
* But leaving it *runnable* would be worse: a routing mistake would fall back to the old engine
|
|
142
|
-
* and produce a run that looks correct while proving nothing, which is exactly the failure mode
|
|
143
|
-
* a cutover has to rule out.
|
|
178
|
+
* Refuses to walk a flow step in this process unless the run chose in-run execution.
|
|
144
179
|
*
|
|
145
|
-
*
|
|
146
|
-
* on the
|
|
180
|
+
* **A safety net, not a switch.** `DetermineInitialStep` decides the mode once and records it on
|
|
181
|
+
* the run's {@link FlowExecutionState}. A dispatched run ends on its `Tasks` step, so the walker
|
|
182
|
+
* should never see it. If a routing mistake ever sends one here, running the walker would
|
|
183
|
+
* produce a run that looks correct while the dispatcher also runs the same graph. Refusing keeps
|
|
184
|
+
* "this dispatched workflow ran on the dispatcher" a fact rather than an assumption.
|
|
147
185
|
*
|
|
148
186
|
* Declared `void` rather than `never` on purpose. `never` would narrow everything after each
|
|
149
|
-
* call site to unreachable, and TypeScript
|
|
150
|
-
* all — which would defeat the "stays compiled" half of the arrangement and let the oracle rot.
|
|
187
|
+
* call site to unreachable, and TypeScript would stop type-checking the walker behind it.
|
|
151
188
|
*
|
|
152
|
-
* @throws
|
|
189
|
+
* @throws when the run is not in `'inRun'` mode. The message names the step so the refusal is
|
|
190
|
+
* diagnosable.
|
|
153
191
|
* @private
|
|
154
192
|
*/
|
|
155
|
-
private
|
|
193
|
+
private refuseUnlessInRun;
|
|
156
194
|
/**
|
|
157
195
|
* Determines the next step based on the flow graph structure.
|
|
158
196
|
*
|
|
@@ -342,34 +380,72 @@ export declare class FlowAgentType extends BaseAgentType {
|
|
|
342
380
|
*/
|
|
343
381
|
PostProcessActionStep<P = any, ATS = any>(actionResults: ActionResult[], actions: AgentAction[], currentPayload: P, agentTypeState: ATS, currentStep: BaseAgentNextStep<P>): Promise<AgentPayloadChangeRequest<P> | null>;
|
|
344
382
|
/**
|
|
345
|
-
*
|
|
383
|
+
* Decides where this flow runs, records the decision, and returns its first step.
|
|
346
384
|
*
|
|
347
|
-
* **
|
|
348
|
-
*
|
|
349
|
-
*
|
|
350
|
-
*
|
|
351
|
-
*
|
|
352
|
-
* can be fixed. The in-run walker below is retained as the differential suite's oracle and is
|
|
353
|
-
* unreachable at runtime (see {@link refuseInRunFlowExecution}).
|
|
385
|
+
* **The rule: a run that needs the flow's result runs in-process; everything else is
|
|
386
|
+
* dispatched.** A dispatched flow submits a task graph and returns before any step has run.
|
|
387
|
+
* That is right for a person starting a workflow, and wrong for anything that consumes the
|
|
388
|
+
* result: a parent agent, or an API handler answering its client. Those callers get the in-run
|
|
389
|
+
* walker, which returns the flow's final payload. See {@link FlowExecutionMode}.
|
|
354
390
|
*
|
|
355
|
-
*
|
|
356
|
-
*
|
|
357
|
-
*
|
|
391
|
+
* The decision is made once, here, and stored on the run's {@link FlowExecutionState}. Every
|
|
392
|
+
* later hook reads it, and BaseAgent records it on the run through
|
|
393
|
+
* {@link DescribeExecutionRouting}.
|
|
358
394
|
*
|
|
359
395
|
* @param {ExecuteAgentParams} params - The full execution parameters
|
|
360
|
-
* @returns
|
|
396
|
+
* @returns The first in-run step, or the `Tasks` step carrying the compiled graph
|
|
361
397
|
*
|
|
362
398
|
* @override
|
|
363
399
|
* @since 2.76.0
|
|
364
400
|
*/
|
|
365
401
|
DetermineInitialStep<P = any, ATS = any>(params: ExecuteAgentParams<P>, payload: P, agentTypeState: ATS): Promise<BaseAgentNextStep<P> | null>;
|
|
366
402
|
/**
|
|
367
|
-
*
|
|
403
|
+
* Stores the run's execution mode and the reason for it on the flow state.
|
|
404
|
+
*
|
|
405
|
+
* An explicit `'inRun'` wins. Otherwise a sub-agent run is in-run, because its parent consumes
|
|
406
|
+
* the result. That covers Sub-Agent tasks inside a dispatched graph too: the task-graph agent
|
|
407
|
+
* runner passes the submitting run as `parentRun`, so a flow nested in a flow returns its result
|
|
408
|
+
* to the task that started it.
|
|
409
|
+
*
|
|
410
|
+
* @private
|
|
411
|
+
*/
|
|
412
|
+
private applyExecutionMode;
|
|
413
|
+
/**
|
|
414
|
+
* Records which engine ran this flow and why, as a `Decision` step on the run.
|
|
415
|
+
*
|
|
416
|
+
* @override
|
|
417
|
+
* @since 6.1.3
|
|
418
|
+
*/
|
|
419
|
+
DescribeExecutionRouting<ATS>(agentTypeState: ATS): AgentTypeExecutionRouting | null;
|
|
420
|
+
/**
|
|
421
|
+
* Compiles the flow and hands it to the task-graph dispatcher (C1.3).
|
|
422
|
+
*
|
|
423
|
+
* The agent does not walk its own graph in this mode. It compiles its persisted steps and paths
|
|
424
|
+
* into a `TaskGraphSpec` and returns a `Tasks` step, which `BaseAgent.executeTasksStep` submits
|
|
425
|
+
* and detaches from. Claiming, conditions, exclusive choice, skip cascade, retry and failure
|
|
426
|
+
* semantics all belong to the dispatcher from there.
|
|
427
|
+
*
|
|
428
|
+
* **Compile failures are authoring failures, and are reported as such.** A flow with no
|
|
429
|
+
* starting step or a loop in it is something the user can fix in the editor, so the message
|
|
430
|
+
* names the step and the problem rather than reporting an internal error.
|
|
431
|
+
*
|
|
432
|
+
* @private
|
|
433
|
+
*/
|
|
434
|
+
private determineInitialStepForDispatch;
|
|
435
|
+
/**
|
|
436
|
+
* Logs what the compile produced.
|
|
437
|
+
*
|
|
438
|
+
* Excluded steps are reported, never dropped in silence: a user who disabled a step or left one
|
|
439
|
+
* unconnected should be able to read that off the run rather than wonder why it did nothing.
|
|
440
|
+
*
|
|
441
|
+
* @private
|
|
442
|
+
*/
|
|
443
|
+
private logCompiledGraph;
|
|
444
|
+
/**
|
|
445
|
+
* The in-run walker's entry point, used when the run's mode is `'inRun'`.
|
|
368
446
|
*
|
|
369
|
-
*
|
|
370
|
-
*
|
|
371
|
-
* no longer called by {@link DetermineInitialStep}, and {@link createStepForFlowNode} refuses if
|
|
372
|
-
* anything reaches it, so a workflow that runs at all provably ran on the dispatcher.
|
|
447
|
+
* Honours `startAtStep`, which the dispatched path cannot. Apart from path selection, which now
|
|
448
|
+
* goes through the shared `SelectOutgoingEdges` engine, the walker is the one MJ 5.x shipped.
|
|
373
449
|
*
|
|
374
450
|
* @private
|
|
375
451
|
*/
|
|
@@ -392,9 +468,9 @@ export declare class FlowAgentType extends BaseAgentType {
|
|
|
392
468
|
* @override
|
|
393
469
|
* @since 2.76.0
|
|
394
470
|
*/
|
|
395
|
-
PreProcessNextStep<P = any, ATS = any>(
|
|
471
|
+
PreProcessNextStep<P = any, ATS = any>(params: ExecuteAgentParams<P>, step: BaseAgentNextStep<P>, payload: P, agentTypeState: ATS): Promise<BaseAgentNextStep<P> | null>;
|
|
396
472
|
/**
|
|
397
|
-
* The in-run walker's post-step hook
|
|
473
|
+
* The in-run walker's post-step hook, used when the run's mode is `'inRun'`.
|
|
398
474
|
*
|
|
399
475
|
* @private
|
|
400
476
|
*/
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"flow-agent-type.d.ts","sourceRoot":"","sources":["../../src/agent-types/flow-agent-type.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAMH,OAAO,EAAE,aAAa,EAAE,MAAM,mBAAmB,CAAC;
|
|
1
|
+
{"version":3,"file":"flow-agent-type.d.ts","sourceRoot":"","sources":["../../src/agent-types/flow-agent-type.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAMH,OAAO,EAAE,aAAa,EAAE,KAAK,yBAAyB,EAAE,MAAM,mBAAmB,CAAC;AAClF,OAAO,EAAE,iBAAiB,EAAE,iBAAiB,EAAE,cAAc,EAAE,yBAAyB,EAAE,WAAW,EAAE,kBAAkB,EAAE,kBAAkB,EAAoC,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