@memberjunction/ai-agents 5.40.2 → 5.41.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 +45 -0
- package/dist/AgentRunner.d.ts +5 -2
- package/dist/AgentRunner.d.ts.map +1 -1
- package/dist/AgentRunner.js +14 -4
- package/dist/AgentRunner.js.map +1 -1
- package/dist/MemoryWriteManager.d.ts +188 -0
- package/dist/MemoryWriteManager.d.ts.map +1 -0
- package/dist/MemoryWriteManager.js +299 -0
- package/dist/MemoryWriteManager.js.map +1 -0
- package/dist/agent-context-injector.d.ts +29 -0
- package/dist/agent-context-injector.d.ts.map +1 -1
- package/dist/agent-context-injector.js +90 -32
- package/dist/agent-context-injector.js.map +1 -1
- package/dist/agent-memory-context-builder.d.ts +100 -0
- package/dist/agent-memory-context-builder.d.ts.map +1 -0
- package/dist/agent-memory-context-builder.js +172 -0
- package/dist/agent-memory-context-builder.js.map +1 -0
- package/dist/agent-types/index.d.ts +1 -0
- package/dist/agent-types/index.d.ts.map +1 -1
- package/dist/agent-types/index.js +1 -0
- package/dist/agent-types/index.js.map +1 -1
- package/dist/agent-types/loop-agent-response-type.d.ts +12 -1
- package/dist/agent-types/loop-agent-response-type.d.ts.map +1 -1
- package/dist/agent-types/loop-agent-response-type.js.map +1 -1
- package/dist/agent-types/loop-agent-type.d.ts.map +1 -1
- package/dist/agent-types/loop-agent-type.js +4 -0
- package/dist/agent-types/loop-agent-type.js.map +1 -1
- package/dist/agent-types/realtime-agent-type.d.ts +146 -0
- package/dist/agent-types/realtime-agent-type.d.ts.map +1 -0
- package/dist/agent-types/realtime-agent-type.js +176 -0
- package/dist/agent-types/realtime-agent-type.js.map +1 -0
- package/dist/base-agent.d.ts +365 -24
- package/dist/base-agent.d.ts.map +1 -1
- package/dist/base-agent.js +995 -175
- package/dist/base-agent.js.map +1 -1
- package/dist/index.d.ts +11 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +15 -0
- package/dist/index.js.map +1 -1
- package/dist/memory-manager-agent.d.ts +55 -2
- package/dist/memory-manager-agent.d.ts.map +1 -1
- package/dist/memory-manager-agent.js +261 -62
- package/dist/memory-manager-agent.js.map +1 -1
- package/dist/realtime/meeting-controls-channel-server.d.ts +198 -0
- package/dist/realtime/meeting-controls-channel-server.d.ts.map +1 -0
- package/dist/realtime/meeting-controls-channel-server.js +319 -0
- package/dist/realtime/meeting-controls-channel-server.js.map +1 -0
- package/dist/realtime/meeting-controls-state.d.ts +191 -0
- package/dist/realtime/meeting-controls-state.d.ts.map +1 -0
- package/dist/realtime/meeting-controls-state.js +219 -0
- package/dist/realtime/meeting-controls-state.js.map +1 -0
- package/dist/realtime/realtime-channel-server-host.d.ts +166 -0
- package/dist/realtime/realtime-channel-server-host.d.ts.map +1 -0
- package/dist/realtime/realtime-channel-server-host.js +378 -0
- package/dist/realtime/realtime-channel-server-host.js.map +1 -0
- package/dist/realtime/realtime-client-session-service.d.ts +884 -0
- package/dist/realtime/realtime-client-session-service.d.ts.map +1 -0
- package/dist/realtime/realtime-client-session-service.js +1401 -0
- package/dist/realtime/realtime-client-session-service.js.map +1 -0
- package/dist/realtime/realtime-coagent-config.d.ts +202 -0
- package/dist/realtime/realtime-coagent-config.d.ts.map +1 -0
- package/dist/realtime/realtime-coagent-config.js +334 -0
- package/dist/realtime/realtime-coagent-config.js.map +1 -0
- package/dist/realtime/realtime-narration.d.ts +67 -0
- package/dist/realtime/realtime-narration.d.ts.map +1 -0
- package/dist/realtime/realtime-narration.js +127 -0
- package/dist/realtime/realtime-narration.js.map +1 -0
- package/dist/realtime/realtime-session-runner.d.ts +383 -0
- package/dist/realtime/realtime-session-runner.d.ts.map +1 -0
- package/dist/realtime/realtime-session-runner.js +532 -0
- package/dist/realtime/realtime-session-runner.js.map +1 -0
- package/dist/realtime/realtime-tool-broker.d.ts +279 -0
- package/dist/realtime/realtime-tool-broker.d.ts.map +1 -0
- package/dist/realtime/realtime-tool-broker.js +184 -0
- package/dist/realtime/realtime-tool-broker.js.map +1 -0
- package/dist/realtime/whiteboard-channel-server.d.ts +50 -0
- package/dist/realtime/whiteboard-channel-server.d.ts.map +1 -0
- package/dist/realtime/whiteboard-channel-server.js +85 -0
- package/dist/realtime/whiteboard-channel-server.js.map +1 -0
- package/package.json +17 -17
|
@@ -0,0 +1,176 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @fileoverview Implementation of the Realtime Agent Type for streaming, full-duplex,
|
|
3
|
+
* tool-calling sessions (voice today, video later).
|
|
4
|
+
*
|
|
5
|
+
* Unlike {@link LoopAgentType} and `FlowAgentType`, the Realtime agent type does **not**
|
|
6
|
+
* drive an iterative request/response reasoning loop. Modern real-time models (Gemini Live,
|
|
7
|
+
* GPT Realtime, and — as a fast-follow — the Eleven Labs stack) own the listen-reason-speak
|
|
8
|
+
* loop themselves. The Realtime agent type therefore wraps a `BaseRealtimeModel` session and
|
|
9
|
+
* delegates the conversation lifecycle to {@link RealtimeSessionRunner}, instead of being
|
|
10
|
+
* pumped turn-by-turn by `BaseAgent`'s loop.
|
|
11
|
+
*
|
|
12
|
+
* This class is built in isolation (P2b-i): it is a registered peer of Loop/Flow, but the
|
|
13
|
+
* wiring inside `BaseAgent` that branches into the session runner is a separate later task.
|
|
14
|
+
* The {@link RealtimeAgentType.IsSessionDriven} getter is the marker `BaseAgent` will use to
|
|
15
|
+
* make that branch.
|
|
16
|
+
*
|
|
17
|
+
* @module @memberjunction/ai-agents
|
|
18
|
+
* @author MemberJunction.com
|
|
19
|
+
*/
|
|
20
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
21
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
22
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
23
|
+
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;
|
|
24
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
25
|
+
};
|
|
26
|
+
import { RegisterClass } from '@memberjunction/global';
|
|
27
|
+
import { LogError } from '@memberjunction/core';
|
|
28
|
+
import { BaseAgentType } from './base-agent-type.js';
|
|
29
|
+
/**
|
|
30
|
+
* Implementation of the Realtime Agent Type pattern.
|
|
31
|
+
*
|
|
32
|
+
* A first-class peer of Loop and Flow that drives a {@link BaseRealtimeModel} session rather
|
|
33
|
+
* than an iterative reasoning loop. Because it is a real MJ agent type, an agent of this type
|
|
34
|
+
* inherits the entire framework for free: server tools (actions), client tools, artifacts,
|
|
35
|
+
* prompts, memory, permissions, and observability. The first agent shipped of this type is the
|
|
36
|
+
* Realtime Co-Agent, which voices on behalf of a target agent.
|
|
37
|
+
*
|
|
38
|
+
* **Execution branch.** The realtime path is session-driven: `BaseAgent` (in a later task) will
|
|
39
|
+
* detect {@link IsSessionDriven} (or `instanceof RealtimeAgentType`) and hand control to a
|
|
40
|
+
* {@link RealtimeSessionRunner} rather than entering the loop. As a consequence, the
|
|
41
|
+
* loop-oriented abstract methods below are implemented defensively — they should never be reached
|
|
42
|
+
* in normal operation.
|
|
43
|
+
*
|
|
44
|
+
* @class RealtimeAgentType
|
|
45
|
+
* @extends BaseAgentType
|
|
46
|
+
*/
|
|
47
|
+
let RealtimeAgentType = class RealtimeAgentType extends BaseAgentType {
|
|
48
|
+
/**
|
|
49
|
+
* Marks this agent type as session-driven rather than loop-driven.
|
|
50
|
+
*
|
|
51
|
+
* `BaseAgent` will use this getter (added on this subclass; `base-agent-type.ts` is left
|
|
52
|
+
* untouched in this task) to branch into a {@link RealtimeSessionRunner} instead of the
|
|
53
|
+
* iterative reasoning loop. Other agent types do not expose this member; `BaseAgent` should
|
|
54
|
+
* treat its absence as `false`, or equivalently detect this type via `instanceof
|
|
55
|
+
* RealtimeAgentType`.
|
|
56
|
+
*
|
|
57
|
+
* @returns Always `true` — realtime agents are driven by a long-lived duplex session.
|
|
58
|
+
*/
|
|
59
|
+
get IsSessionDriven() {
|
|
60
|
+
return true;
|
|
61
|
+
}
|
|
62
|
+
/**
|
|
63
|
+
* Realtime agents drive their conversation through a live model session, not through
|
|
64
|
+
* agent-level loop prompts. The companion/system prompt is supplied to the realtime model at
|
|
65
|
+
* session start, so the agent-level prompt relationship is not required.
|
|
66
|
+
*
|
|
67
|
+
* @returns Always `false` — agent-level loop prompts are not required for realtime agents.
|
|
68
|
+
*/
|
|
69
|
+
get RequiresAgentLevelPrompts() {
|
|
70
|
+
return false;
|
|
71
|
+
}
|
|
72
|
+
/**
|
|
73
|
+
* Initializes agent-type-specific state for a realtime run.
|
|
74
|
+
*
|
|
75
|
+
* The Realtime agent type keeps no iterative loop state — all live state lives inside the
|
|
76
|
+
* {@link RealtimeSessionRunner} and the underlying provider session — so an empty state object
|
|
77
|
+
* is returned, mirroring {@link LoopAgentType.InitializeAgentTypeState}.
|
|
78
|
+
*
|
|
79
|
+
* @param params The agent execution params (unused for realtime state).
|
|
80
|
+
* @returns An empty agent-type state object.
|
|
81
|
+
*/
|
|
82
|
+
async InitializeAgentTypeState(params) {
|
|
83
|
+
// Realtime agents do not maintain iterative loop state; the session runner + provider
|
|
84
|
+
// session own all live state. Return an empty object to satisfy the contract.
|
|
85
|
+
return {};
|
|
86
|
+
}
|
|
87
|
+
/**
|
|
88
|
+
* Determines the next step from a prompt result.
|
|
89
|
+
*
|
|
90
|
+
* Realtime agents are session-driven and never enter the iterative reasoning loop, so this
|
|
91
|
+
* method should never be reached in normal operation. It is implemented defensively: it logs
|
|
92
|
+
* and returns a terminal `Failed` step rather than throwing, so a mis-wired caller degrades
|
|
93
|
+
* gracefully instead of crashing a live session.
|
|
94
|
+
*
|
|
95
|
+
* @param promptResult Result from prompt execution (unused).
|
|
96
|
+
* @param params The full execution parameters (unused).
|
|
97
|
+
* @param payload The current payload (unused).
|
|
98
|
+
* @param agentTypeState The agent-type state (unused).
|
|
99
|
+
* @returns A terminal `Failed` step describing the misuse.
|
|
100
|
+
*/
|
|
101
|
+
async DetermineNextStep(promptResult, params, payload, agentTypeState) {
|
|
102
|
+
const message = 'RealtimeAgentType.DetermineNextStep was called, but realtime agents are session-driven and ' +
|
|
103
|
+
'do not use the iterative reasoning loop. This indicates the agent was routed through the loop ' +
|
|
104
|
+
'path instead of the RealtimeSessionRunner. Check that BaseAgent branched on IsSessionDriven.';
|
|
105
|
+
LogError(message);
|
|
106
|
+
return this.createNextStep('Failed', { terminate: true, errorMessage: message });
|
|
107
|
+
}
|
|
108
|
+
/**
|
|
109
|
+
* Determines the initial step for a realtime agent.
|
|
110
|
+
*
|
|
111
|
+
* The realtime conversation is owned by the session runner, so there is no loop step to
|
|
112
|
+
* begin. Returning `null` defers to the caller; in practice `BaseAgent` branches on
|
|
113
|
+
* {@link IsSessionDriven} before this would matter.
|
|
114
|
+
*
|
|
115
|
+
* @param params The full execution parameters (unused).
|
|
116
|
+
* @param payload The current payload (unused).
|
|
117
|
+
* @param agentTypeState The agent-type state (unused).
|
|
118
|
+
* @returns Always `null` — there is no loop step to seed.
|
|
119
|
+
*/
|
|
120
|
+
async DetermineInitialStep(params, payload, agentTypeState) {
|
|
121
|
+
return null;
|
|
122
|
+
}
|
|
123
|
+
/**
|
|
124
|
+
* Pre-processes a retry step.
|
|
125
|
+
*
|
|
126
|
+
* Realtime agents have no loop retry semantics; `null` is returned to indicate "no custom
|
|
127
|
+
* behavior", consistent with {@link LoopAgentType.PreProcessNextStep}.
|
|
128
|
+
*
|
|
129
|
+
* @param params The full execution parameters (unused).
|
|
130
|
+
* @param step The retry step (unused).
|
|
131
|
+
* @param payload The current payload (unused).
|
|
132
|
+
* @param agentTypeState The agent-type state (unused).
|
|
133
|
+
* @returns Always `null`.
|
|
134
|
+
*/
|
|
135
|
+
async PreProcessNextStep(params, step, payload, agentTypeState) {
|
|
136
|
+
return null;
|
|
137
|
+
}
|
|
138
|
+
/**
|
|
139
|
+
* Gets the prompt to use for a step.
|
|
140
|
+
*
|
|
141
|
+
* Realtime agents do not select per-step loop prompts — the companion/system prompt is handed
|
|
142
|
+
* to the realtime model at session start. The default child prompt (if any) is returned for
|
|
143
|
+
* completeness, but it is not used to drive the conversation.
|
|
144
|
+
*
|
|
145
|
+
* @param params The execution parameters (unused).
|
|
146
|
+
* @param config The loaded agent configuration.
|
|
147
|
+
* @param payload The current payload (unused).
|
|
148
|
+
* @param agentTypeState The agent-type state (unused).
|
|
149
|
+
* @param previousDecision The previous step decision (unused).
|
|
150
|
+
* @returns The configured child prompt, or `null` if none is configured.
|
|
151
|
+
*/
|
|
152
|
+
async GetPromptForStep(params, config, payload, agentTypeState, previousDecision) {
|
|
153
|
+
return config.childPrompt || null;
|
|
154
|
+
}
|
|
155
|
+
/**
|
|
156
|
+
* Injects a payload into a prompt.
|
|
157
|
+
*
|
|
158
|
+
* Realtime conversations are not driven by loop prompts, so there is no per-turn payload to
|
|
159
|
+
* inject. This is a no-op (defensive against a mis-wired caller), in contrast to
|
|
160
|
+
* {@link LoopAgentType.InjectPayload} which injects the current payload into the loop prompt.
|
|
161
|
+
*
|
|
162
|
+
* @param payload The payload to inject (unused).
|
|
163
|
+
* @param agentTypeState The agent-type state (unused).
|
|
164
|
+
* @param prompt The prompt parameters (unused).
|
|
165
|
+
* @param agentInfo Agent identification info (unused).
|
|
166
|
+
*/
|
|
167
|
+
async InjectPayload(payload, agentTypeState, prompt, agentInfo) {
|
|
168
|
+
// No-op: the realtime session runner owns context injection at session start, not the
|
|
169
|
+
// per-turn loop prompt path. Nothing to inject here.
|
|
170
|
+
}
|
|
171
|
+
};
|
|
172
|
+
RealtimeAgentType = __decorate([
|
|
173
|
+
RegisterClass(BaseAgentType, "RealtimeAgentType")
|
|
174
|
+
], RealtimeAgentType);
|
|
175
|
+
export { RealtimeAgentType };
|
|
176
|
+
//# sourceMappingURL=realtime-agent-type.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"realtime-agent-type.js","sourceRoot":"","sources":["../../src/agent-types/realtime-agent-type.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;GAkBG;;;;;;;AAEH,OAAO,EAAE,aAAa,EAAE,MAAM,wBAAwB,CAAC;AACvD,OAAO,EAAE,QAAQ,EAAE,MAAM,sBAAsB,CAAC;AAShD,OAAO,EAAE,aAAa,EAAE,MAAM,mBAAmB,CAAC;AAElD;;;;;;;;;;;;;;;;;GAiBG;AAEI,IAAM,iBAAiB,GAAvB,MAAM,iBAAkB,SAAQ,aAAa;IAChD;;;;;;;;;;OAUG;IACH,IAAW,eAAe;QACtB,OAAO,IAAI,CAAC;IAChB,CAAC;IAED;;;;;;OAMG;IACH,IAAoB,yBAAyB;QACzC,OAAO,KAAK,CAAC;IACjB,CAAC;IAED;;;;;;;;;OASG;IACI,KAAK,CAAC,wBAAwB,CAAqB,MAAkC;QACxF,sFAAsF;QACtF,8EAA8E;QAC9E,OAAO,EAAS,CAAC;IACrB,CAAC;IAED;;;;;;;;;;;;;OAaG;IACI,KAAK,CAAC,iBAAiB,CAC1B,YAAsC,EACtC,MAAkC,EAClC,OAAU,EACV,cAAmB;QAEnB,MAAM,OAAO,GACT,6FAA6F;YAC7F,gGAAgG;YAChG,8FAA8F,CAAC;QACnG,QAAQ,CAAC,OAAO,CAAC,CAAC;QAClB,OAAO,IAAI,CAAC,cAAc,CAAI,QAAQ,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,YAAY,EAAE,OAAO,EAAE,CAAC,CAAC;IACxF,CAAC;IAED;;;;;;;;;;;OAWG;IACI,KAAK,CAAC,oBAAoB,CAC7B,MAA6B,EAC7B,OAAU,EACV,cAAmB;QAEnB,OAAO,IAAI,CAAC;IAChB,CAAC;IAED;;;;;;;;;;;OAWG;IACI,KAAK,CAAC,kBAAkB,CAC3B,MAA6B,EAC7B,IAA0B,EAC1B,OAAU,EACV,cAAmB;QAEnB,OAAO,IAAI,CAAC;IAChB,CAAC;IAED;;;;;;;;;;;;;OAaG;IACI,KAAK,CAAC,gBAAgB,CACzB,MAA0B,EAC1B,MAA0B,EAC1B,OAAU,EACV,cAAmB,EACnB,gBAA8C;QAE9C,OAAO,MAAM,CAAC,WAAW,IAAI,IAAI,CAAC;IACtC,CAAC;IAED;;;;;;;;;;;OAWG;IACI,KAAK,CAAC,aAAa,CACtB,OAAU,EACV,cAAmB,EACnB,MAAsB,EACtB,SAAmD;QAEnD,sFAAsF;QACtF,qDAAqD;IACzD,CAAC;CACJ,CAAA;AA7JY,iBAAiB;IAD7B,aAAa,CAAC,aAAa,EAAE,mBAAmB,CAAC;GACrC,iBAAiB,CA6J7B"}
|
package/dist/base-agent.d.ts
CHANGED
|
@@ -11,15 +11,40 @@
|
|
|
11
11
|
* @since 2.49.0
|
|
12
12
|
*/
|
|
13
13
|
import { MJAIAgentTypeEntity, MJTemplateParamEntity, MJAIAgentRelationshipEntity, MJAIAgentNoteEntity, MJAIAgentExampleEntity } from '@memberjunction/core-entities';
|
|
14
|
-
import { MJAIAgentRunEntityExtended, MJAIAgentRunStepEntityExtended, MJAIPromptEntityExtended, MJAIAgentEntityExtended } from "@memberjunction/ai-core-plus";
|
|
14
|
+
import { MJAIAgentRunEntityExtended, MJAIAgentRunStepEntityExtended, MJAIPromptEntityExtended, MJAIAgentEntityExtended, MJAIPromptRunEntityExtended } from "@memberjunction/ai-core-plus";
|
|
15
15
|
import { UserInfo, IMetadataProvider } from '@memberjunction/core';
|
|
16
|
-
import { ChatMessage, ChatMessageContent } from '@memberjunction/ai';
|
|
16
|
+
import { ChatMessage, ChatMessageContent, BaseRealtimeModel } from '@memberjunction/ai';
|
|
17
17
|
import { BaseAgentType } from './agent-types/base-agent-type.js';
|
|
18
|
+
import { RealtimeSessionRunnerDeps } from './realtime/realtime-session-runner.js';
|
|
19
|
+
import { RealtimeCoAgentConfig } from './realtime/realtime-coagent-config.js';
|
|
20
|
+
import { AIEngine } from '@memberjunction/aiengine';
|
|
18
21
|
import { AgentPreExecutionRAGResult } from './agent-pre-execution-rag.js';
|
|
19
|
-
import { AIPromptParams, AIPromptRunResult, ExecuteAgentParams, AgentConfiguration, ExecuteAgentResult, AgentAction, AgentSubAgentRequest, BaseAgentNextStep, MessageLifecycleEvent, AgentChatMessage, AIModelSelectionInfo, ActionChange, ActionChangeScope, MediaOutput, FileOutputRef, SecondaryScopeConfig, SecondaryScopeValue, AgentPipelineRequest } from '@memberjunction/ai-core-plus';
|
|
22
|
+
import { AIPromptParams, AIPromptRunResult, ExecuteAgentParams, AgentConfiguration, ExecuteAgentResult, AgentAction, AgentSubAgentRequest, BaseAgentNextStep, MessageLifecycleEvent, AgentChatMessage, AIModelSelectionInfo, ActionChange, ActionChangeScope, SubAgentChange, MediaOutput, FileOutputRef, SecondaryScopeConfig, SecondaryScopeValue, AgentPipelineRequest } from '@memberjunction/ai-core-plus';
|
|
20
23
|
import { MJActionEntityExtended, ActionResult } from '@memberjunction/actions-base';
|
|
21
24
|
import { ArtifactToolCall, StoredToolResult } from './ArtifactToolManager.js';
|
|
25
|
+
import { MemoryWriteRequest, MemoryWriteResult } from './MemoryWriteManager.js';
|
|
22
26
|
import { PipelineToolRegistry, PipelineExecutionResult } from './pipeline/index.js';
|
|
27
|
+
/**
|
|
28
|
+
* The agent-invariant "base" catalog cached (process-wide) on AIEngine and reused across runs/steps.
|
|
29
|
+
* Holds the resolved sub-agents + actions and their formatted markdown, plus the base merged
|
|
30
|
+
* agent-type prompt params (with NO runtime overrides applied). Runtime `actionChanges` /
|
|
31
|
+
* `subAgentChanges` / `__agentTypePromptParams` overrides are layered on top per run from a clone.
|
|
32
|
+
*/
|
|
33
|
+
interface AgentBaseCatalog {
|
|
34
|
+
/** Resolved active sub-agents (direct ParentID children + active relationships), de-duped. */
|
|
35
|
+
uniqueActiveSubAgents: MJAIAgentEntityExtended[];
|
|
36
|
+
subAgentCount: number;
|
|
37
|
+
/** Markdown describing uniqueActiveSubAgents (the base set). */
|
|
38
|
+
subAgentDetails: string;
|
|
39
|
+
/** Actions matched to the agent's active AIAgentAction junctions, BEFORE filtering by action Status — needed as the input to applyActionChanges. */
|
|
40
|
+
baseActionsRaw: MJActionEntityExtended[];
|
|
41
|
+
/** baseActionsRaw filtered to Status='Active' — the fast-path effective action set. */
|
|
42
|
+
activeActions: MJActionEntityExtended[];
|
|
43
|
+
/** Markdown describing activeActions (the base set). */
|
|
44
|
+
actionDetails: string;
|
|
45
|
+
/** Agent-type prompt params merged from schema defaults + agent config (NO runtime overrides). */
|
|
46
|
+
baseAgentTypePromptParams: Record<string, unknown>;
|
|
47
|
+
}
|
|
23
48
|
export declare class BaseAgent {
|
|
24
49
|
/**
|
|
25
50
|
* Maximum allowed validation retries before forcing failure.
|
|
@@ -69,6 +94,16 @@ export declare class BaseAgent {
|
|
|
69
94
|
* INSERT on millisecond-fast steps (e.g. pipelines), which left them stuck at `Running`.
|
|
70
95
|
*/
|
|
71
96
|
private _stepSavePromises;
|
|
97
|
+
/**
|
|
98
|
+
* Per-step 'started'-INSERT promises, keyed by the step entity instance. The create INSERT is
|
|
99
|
+
* fire-and-forget (the agent flow never blocks on it — the PK is client-generated by NewRecord() so
|
|
100
|
+
* the ID is valid immediately). Every UPDATE-phase save ({@link queueStepSave}) chains after this
|
|
101
|
+
* INSERT promise so the UPDATE never races ahead of the create, and force-persists with
|
|
102
|
+
* `IgnoreDirtyState` so a mutation absorbed by the INSERT's post-save dirty-reset (which silently
|
|
103
|
+
* no-op'd UPDATEs and left fast create→finalize steps stuck at Status='Running') is still written.
|
|
104
|
+
* A WeakMap so entries are GC'd with the entity.
|
|
105
|
+
*/
|
|
106
|
+
private _stepInsertPromises;
|
|
72
107
|
/**
|
|
73
108
|
* Active per-request metadata provider, set at the start of Execute().
|
|
74
109
|
* Defaults to the global Metadata.Provider; overridden when a per-request
|
|
@@ -358,6 +393,11 @@ export declare class BaseAgent {
|
|
|
358
393
|
* Allows agents to explore input artifacts on demand.
|
|
359
394
|
*/
|
|
360
395
|
private _artifactToolManager;
|
|
396
|
+
/**
|
|
397
|
+
* Manages in-flight durable memory writes for the current agent run.
|
|
398
|
+
* Only consulted when the agent has AllowMemoryWrite enabled.
|
|
399
|
+
*/
|
|
400
|
+
private _memoryWriteManager;
|
|
361
401
|
/**
|
|
362
402
|
* Effective actions available to this agent after applying actionChanges.
|
|
363
403
|
* Populated during gatherPromptTemplateData() and used for validation in executeActionsStep().
|
|
@@ -490,6 +530,247 @@ export declare class BaseAgent {
|
|
|
490
530
|
*/
|
|
491
531
|
protected get DefaultAgentTimeoutMS(): number;
|
|
492
532
|
Execute<C = any, R = any>(params: ExecuteAgentParams<C>): Promise<ExecuteAgentResult<R>>;
|
|
533
|
+
/**
|
|
534
|
+
* Type guard for whether the resolved agent-type instance is session-driven.
|
|
535
|
+
*
|
|
536
|
+
* Detects the Realtime agent type without importing it (and without `instanceof`, which is
|
|
537
|
+
* brittle under bundler class-duplication) by duck-typing the `IsSessionDriven` getter that
|
|
538
|
+
* `RealtimeAgentType` adds. `BaseAgentType` (and Loop/Flow) do not expose this member, so the
|
|
539
|
+
* guard returns `false` for them and the iterative loop runs unchanged.
|
|
540
|
+
*
|
|
541
|
+
* @param agentType The resolved agent-type instance for this run.
|
|
542
|
+
* @returns `true` only when the type explicitly marks itself session-driven.
|
|
543
|
+
*/
|
|
544
|
+
protected isSessionDrivenAgentType(agentType: BaseAgentType): agentType is BaseAgentType & {
|
|
545
|
+
IsSessionDriven: true;
|
|
546
|
+
};
|
|
547
|
+
/**
|
|
548
|
+
* Drives a session-driven (Realtime) agent run end-to-end.
|
|
549
|
+
*
|
|
550
|
+
* Resolves the realtime model, assembles the session parameters (system prompt + memory/context),
|
|
551
|
+
* builds the {@link RealtimeSessionRunnerDeps} from this agent's collaborators, runs the
|
|
552
|
+
* {@link RealtimeSessionRunner}, and maps the result onto the finalized `AIAgentRun`.
|
|
553
|
+
*
|
|
554
|
+
* If no realtime model can be resolved (expected today, before the P3 drivers / P4 model
|
|
555
|
+
* metadata land), it finalizes the run as a clean FAILED result with an actionable message
|
|
556
|
+
* rather than throwing — a mis-provisioned environment must not crash the caller.
|
|
557
|
+
*
|
|
558
|
+
* @template R The caller's expected payload type (unused on the realtime path; the session
|
|
559
|
+
* produces transcript/usage rather than a structured payload).
|
|
560
|
+
* @param params The wrapped execution parameters.
|
|
561
|
+
* @param config The loaded agent configuration (provides the system prompt, if any).
|
|
562
|
+
* @returns The finalized {@link ExecuteAgentResult}.
|
|
563
|
+
*/
|
|
564
|
+
protected executeRealtimeSession<R = any>(params: ExecuteAgentParams, config: AgentConfiguration): Promise<ExecuteAgentResult<R>>;
|
|
565
|
+
/**
|
|
566
|
+
* Resolves the realtime model + vendor driver + API key for a session-driven run.
|
|
567
|
+
*
|
|
568
|
+
* **Overridable seam.** This is the single injection point that test subclasses override to
|
|
569
|
+
* return a mock {@link BaseRealtimeModel}, so {@link executeRealtimeSession} can be exercised
|
|
570
|
+
* without provider SDKs or DB metadata.
|
|
571
|
+
*
|
|
572
|
+
* Production resolution: pick the highest-power active model of AIModelType `Realtime`; then
|
|
573
|
+
* pick its highest-priority active vendor whose `DriverClass` has a resolvable API key; then
|
|
574
|
+
* instantiate the driver via the `ClassFactory`. Returns `null` (never throws) if any step
|
|
575
|
+
* can't be satisfied — the caller turns that into a clean FAILED result. (Per-agent realtime
|
|
576
|
+
* model preference can later be wired through the agent's prompt-model config, the same path
|
|
577
|
+
* loop agents use for `ModelSelectionMode`; the AI Agent entity has no direct model FK.)
|
|
578
|
+
*
|
|
579
|
+
* @param params The execution parameters (for the agent + context user).
|
|
580
|
+
* @returns The resolved model instance plus its model/vendor identifiers, or `null`.
|
|
581
|
+
*/
|
|
582
|
+
protected resolveRealtimeModel(params: ExecuteAgentParams): Promise<{
|
|
583
|
+
model: BaseRealtimeModel;
|
|
584
|
+
modelID: string;
|
|
585
|
+
vendorID: string;
|
|
586
|
+
apiName: string;
|
|
587
|
+
driverClass?: string;
|
|
588
|
+
} | null>;
|
|
589
|
+
/**
|
|
590
|
+
* Selects the `MJ: AI Models` row to use for a realtime session: the highest-power active
|
|
591
|
+
* model of AIModelType `Realtime`. Returns `null` when no `Realtime` model exists in metadata
|
|
592
|
+
* (expected before P4).
|
|
593
|
+
*
|
|
594
|
+
* @param agent The agent being executed (reserved for future per-agent model preference).
|
|
595
|
+
* @returns The chosen model entity, or `null`.
|
|
596
|
+
*/
|
|
597
|
+
private selectRealtimeModelEntity;
|
|
598
|
+
/**
|
|
599
|
+
* Resolves the agent's EFFECTIVE realtime configuration — the agent TYPE's
|
|
600
|
+
* `DefaultConfiguration` (base layer) deep-merged with the agent's `TypeConfiguration`
|
|
601
|
+
* (per-agent layer; the server-bridged path has no runtime-override layer). Tolerant:
|
|
602
|
+
* malformed layers contribute nothing and an unloaded type cache yields no type defaults.
|
|
603
|
+
* See `realtime/realtime-coagent-config.ts` for the merge contract.
|
|
604
|
+
*
|
|
605
|
+
* @param agent The session-driven (Realtime) agent.
|
|
606
|
+
* @returns The normalized effective configuration (possibly empty, never `null`).
|
|
607
|
+
*/
|
|
608
|
+
protected resolveRealtimeEffectiveConfig(agent: MJAIAgentEntityExtended): RealtimeCoAgentConfig;
|
|
609
|
+
/**
|
|
610
|
+
* Selects the highest-priority active vendor for a model whose `DriverClass` has a resolvable
|
|
611
|
+
* API key. Mirrors the vendor-selection pattern used by prompt execution.
|
|
612
|
+
*
|
|
613
|
+
* @param modelID The chosen model's ID.
|
|
614
|
+
* @returns The vendor driver/api identifiers, or `null` when none has a usable key.
|
|
615
|
+
*/
|
|
616
|
+
private selectRealtimeVendor;
|
|
617
|
+
/**
|
|
618
|
+
* Creates the single long-lived `AIPromptRun` that realtime usage is checkpointed onto.
|
|
619
|
+
*
|
|
620
|
+
* One run is created per session (not per turn) so {@link RealtimeSessionRunnerDeps.CheckpointUsage}
|
|
621
|
+
* can incrementally update the same record — crash-safe by design. Returns `null` on failure;
|
|
622
|
+
* the session still runs (usage checkpoints simply become no-ops).
|
|
623
|
+
*
|
|
624
|
+
* @param params The execution parameters.
|
|
625
|
+
* @param config The agent configuration (provides the system prompt id, if any).
|
|
626
|
+
* @param modelResolution The resolved model/vendor identifiers.
|
|
627
|
+
* @returns The persisted prompt run, or `null` if it could not be created.
|
|
628
|
+
*/
|
|
629
|
+
private createRealtimePromptRun;
|
|
630
|
+
/**
|
|
631
|
+
* Builds the fully-populated {@link RealtimeSessionRunnerDeps} from this agent's collaborators.
|
|
632
|
+
*
|
|
633
|
+
* Each dependency is a thin closure over BaseAgent state so the runner stays decoupled from
|
|
634
|
+
* metadata/DB. The closures cover: target delegation (via {@link ExecuteSubAgent}), non-target
|
|
635
|
+
* tool execution, transcript persistence (as `ConversationDetail`), and usage checkpointing
|
|
636
|
+
* (onto the long-lived prompt run).
|
|
637
|
+
*
|
|
638
|
+
* @param params The execution parameters.
|
|
639
|
+
* @param config The agent configuration.
|
|
640
|
+
* @param modelResolution The resolved realtime model + identifiers.
|
|
641
|
+
* @param promptRun The long-lived prompt run for usage checkpoints (may be `null`).
|
|
642
|
+
* @returns The assembled deps object.
|
|
643
|
+
*/
|
|
644
|
+
protected buildRealtimeSessionDeps(params: ExecuteAgentParams, config: AgentConfiguration, modelResolution: {
|
|
645
|
+
model: BaseRealtimeModel;
|
|
646
|
+
apiName: string;
|
|
647
|
+
driverClass?: string;
|
|
648
|
+
}, promptRun: MJAIPromptRunEntityExtended | null): Promise<RealtimeSessionRunnerDeps>;
|
|
649
|
+
/**
|
|
650
|
+
* Assembles the {@link RealtimeSessionParams} for the session.
|
|
651
|
+
*
|
|
652
|
+
* The system prompt is framed as a companion "voice for the target agent". The base system
|
|
653
|
+
* prompt text (when an agent-level system prompt exists) plus the same memory/context a loop
|
|
654
|
+
* agent would assemble (via {@link AgentMemoryContextBuilder}) are concatenated. The
|
|
655
|
+
* always-present `invoke-target-agent` tool is added by the runner itself, so it is NOT
|
|
656
|
+
* populated here.
|
|
657
|
+
*
|
|
658
|
+
* @param params The execution parameters.
|
|
659
|
+
* @param config The agent configuration.
|
|
660
|
+
* @param modelApiName The vendor API name of the resolved realtime model.
|
|
661
|
+
* @returns The session parameters.
|
|
662
|
+
*/
|
|
663
|
+
private buildRealtimeSessionParams;
|
|
664
|
+
/**
|
|
665
|
+
* Assembles the same memory/context block a loop agent injects, reusing
|
|
666
|
+
* {@link AgentMemoryContextBuilder} so there is no duplicated retrieval logic. The builder
|
|
667
|
+
* unshifts a system message onto a throwaway array, which we pull back out as plain text to
|
|
668
|
+
* feed the realtime model's session context.
|
|
669
|
+
*
|
|
670
|
+
* @param params The execution parameters.
|
|
671
|
+
* @returns The concatenated context text (empty string when nothing was injected).
|
|
672
|
+
*/
|
|
673
|
+
private assembleRealtimeContext;
|
|
674
|
+
/**
|
|
675
|
+
* Delegates an `invoke-target-agent` tool call to the top-level target agent.
|
|
676
|
+
*
|
|
677
|
+
* Threads the runner-owned {@link DelegateToTargetRequest.AbortSignal} into the child run's
|
|
678
|
+
* `cancellationToken` (so barge-in cancels the delegated work), and links the child run to this
|
|
679
|
+
* run via `parentRun` (→ `ParentRunID`) while propagating `agentSessionID` so both runs group
|
|
680
|
+
* under the same session.
|
|
681
|
+
*
|
|
682
|
+
* **Target source.** The target agent id comes from `params.data.targetAgentID` when present
|
|
683
|
+
* (the Realtime Co-Agent receives its target as a runtime parameter), falling back to the agent's
|
|
684
|
+
* own `DefaultModelID`-style config is NOT applicable here; absent a target the delegation
|
|
685
|
+
* returns a failed {@link DelegatedResult} the model can narrate.
|
|
686
|
+
*
|
|
687
|
+
* @param params The (parent) execution parameters.
|
|
688
|
+
* @param config The agent configuration (unused today; reserved for target-from-config wiring).
|
|
689
|
+
* @param request The delegation request derived from the tool call.
|
|
690
|
+
* @returns The delegated result for the model's tool_response.
|
|
691
|
+
*/
|
|
692
|
+
private delegateRealtimeToTarget;
|
|
693
|
+
/**
|
|
694
|
+
* Combines the runner-supplied delegation progress callback with the host-level one so a
|
|
695
|
+
* single `onProgress` fans out to both. Returns the lone callback when only one exists, and
|
|
696
|
+
* `undefined` when neither does. A throw from one consumer never starves the other.
|
|
697
|
+
*/
|
|
698
|
+
private combineProgressCallbacks;
|
|
699
|
+
/**
|
|
700
|
+
* Resolves the top-level target agent for the voice session.
|
|
701
|
+
*
|
|
702
|
+
* The target is supplied as a runtime parameter on `params.data.targetAgentID` (the Voice
|
|
703
|
+
* Co-Agent voices on behalf of a target chosen at session start). Returns `null` when no
|
|
704
|
+
* resolvable target is configured.
|
|
705
|
+
*
|
|
706
|
+
* @param params The execution parameters.
|
|
707
|
+
* @returns The target agent entity, or `null`.
|
|
708
|
+
*/
|
|
709
|
+
private resolveRealtimeTargetAgent;
|
|
710
|
+
/**
|
|
711
|
+
* Parses the natural-language request text out of an `invoke-target-agent` call's arguments.
|
|
712
|
+
* Falls back to the raw argument string when it is not the expected `{ request: string }` JSON.
|
|
713
|
+
*
|
|
714
|
+
* @param argumentsJson The raw arguments string emitted by the model.
|
|
715
|
+
* @returns The request text to hand to the target agent.
|
|
716
|
+
*/
|
|
717
|
+
private parseDelegateRequestText;
|
|
718
|
+
/**
|
|
719
|
+
* Executes a non-target realtime tool call by routing it through the agent's existing action
|
|
720
|
+
* execution under the session context user.
|
|
721
|
+
*
|
|
722
|
+
* Today this maps the realtime call onto the agent's configured actions by name; unknown tools
|
|
723
|
+
* return a failed {@link ToolExecutionResult} the model can narrate. (The richer client/UI tool
|
|
724
|
+
* routing is wired in a later phase; this keeps server actions usable now.)
|
|
725
|
+
*
|
|
726
|
+
* @param params The execution parameters.
|
|
727
|
+
* @param call The non-target tool call.
|
|
728
|
+
* @returns The tool execution result for the model's tool_response.
|
|
729
|
+
*/
|
|
730
|
+
private executeRealtimeTool;
|
|
731
|
+
/**
|
|
732
|
+
* Parses a realtime tool call's JSON arguments into an action parameter map.
|
|
733
|
+
*
|
|
734
|
+
* @param argumentsJson The raw arguments string.
|
|
735
|
+
* @returns A record of parameter name → value (empty when not parseable).
|
|
736
|
+
*/
|
|
737
|
+
private parseRealtimeToolParams;
|
|
738
|
+
/**
|
|
739
|
+
* Persists a single realtime transcript turn as a `ConversationDetail` stamped with the
|
|
740
|
+
* session id. User turns are written as `Role='User'`, assistant turns as `Role='AI'`. Only
|
|
741
|
+
* final transcripts are persisted (interim/partial updates are skipped to avoid churn).
|
|
742
|
+
*
|
|
743
|
+
* @param params The execution parameters (provides conversation id + context user).
|
|
744
|
+
* @param transcript The transcript turn emitted by the model.
|
|
745
|
+
*/
|
|
746
|
+
private persistRealtimeTranscript;
|
|
747
|
+
/**
|
|
748
|
+
* Checkpoints accumulated realtime usage onto the single long-lived prompt run. This is the
|
|
749
|
+
* incremental, crash-safe write the runner invokes on a debounced cadence and at close.
|
|
750
|
+
*
|
|
751
|
+
* @param promptRun The long-lived prompt run (no-op when `null`).
|
|
752
|
+
* @param usage The cumulative usage snapshot to persist.
|
|
753
|
+
*/
|
|
754
|
+
private checkpointRealtimeUsage;
|
|
755
|
+
/**
|
|
756
|
+
* Maps a completed {@link RealtimeSessionResult} onto the finalized `AIAgentRun` and returns
|
|
757
|
+
* the {@link ExecuteAgentResult}. A clean close finalizes as success; a session error finalizes
|
|
758
|
+
* as failure with the error message.
|
|
759
|
+
*
|
|
760
|
+
* @template R The caller's payload type (unused on the realtime path).
|
|
761
|
+
* @param params The execution parameters.
|
|
762
|
+
* @param sessionResult The result returned by {@link RealtimeSessionRunner.Run}.
|
|
763
|
+
* @returns The finalized agent result.
|
|
764
|
+
*/
|
|
765
|
+
private finalizeRealtimeRun;
|
|
766
|
+
/**
|
|
767
|
+
* Builds a terminal `Success` step describing the completion of a realtime session, used to
|
|
768
|
+
* finalize the run through the shared {@link finalizeAgentRun} path.
|
|
769
|
+
*
|
|
770
|
+
* @template R The caller's payload type.
|
|
771
|
+
* @returns A terminal success step.
|
|
772
|
+
*/
|
|
773
|
+
private createSessionSuccessStep;
|
|
493
774
|
/**
|
|
494
775
|
* Sub-classes can override this method to perform any specialized initialization
|
|
495
776
|
* @param params
|
|
@@ -526,21 +807,16 @@ export declare class BaseAgent {
|
|
|
526
807
|
* @protected
|
|
527
808
|
*/
|
|
528
809
|
protected initializeEngines(contextUser?: UserInfo): Promise<void>;
|
|
529
|
-
/**
|
|
530
|
-
* Storage for injected memory context to prepend to prompts
|
|
531
|
-
*/
|
|
532
|
-
private _memoryContext;
|
|
533
810
|
/**
|
|
534
811
|
* Storage for injected notes and examples to include in result
|
|
535
812
|
*/
|
|
536
813
|
private _injectedMemory;
|
|
537
814
|
/**
|
|
538
815
|
* Storage for injected pre-execution RAG context (Phase 1C of search-scopes-rag-plus).
|
|
539
|
-
* Contains the
|
|
540
|
-
*
|
|
541
|
-
*
|
|
816
|
+
* Contains the structured per-scope / combined result detail for downstream observability
|
|
817
|
+
* and artifact persistence. The formatted `<retrieved_context>` system-message block is
|
|
818
|
+
* unshifted onto `conversationMessages` by the shared {@link AgentMemoryContextBuilder}.
|
|
542
819
|
*/
|
|
543
|
-
private _ragContext;
|
|
544
820
|
private _injectedRAG;
|
|
545
821
|
/**
|
|
546
822
|
* Determine the scope label for a note based on its scope fields.
|
|
@@ -998,6 +1274,42 @@ export declare class BaseAgent {
|
|
|
998
1274
|
* @protected
|
|
999
1275
|
*/
|
|
1000
1276
|
protected capStandaloneToolResultText(text: string): string;
|
|
1277
|
+
/**
|
|
1278
|
+
* Executes a batch of in-flight memory writes, recording each as its own
|
|
1279
|
+
* `Tool` AIAgentRunStep (a sibling of the Prompt step that requested them)
|
|
1280
|
+
* with full inputs/outcomes captured in InputData/OutputData.
|
|
1281
|
+
*
|
|
1282
|
+
* Writes run SEQUENTIALLY (not Promise.all like artifact tools) by design:
|
|
1283
|
+
* each persisted note is embedded and synced into the in-memory vector
|
|
1284
|
+
* service on Save, so write N must be visible to write N+1's near-duplicate
|
|
1285
|
+
* check (this is also what makes same-run supersede-own work). The per-run
|
|
1286
|
+
* cap bounds the cost of the serialization.
|
|
1287
|
+
*
|
|
1288
|
+
* Step naming convention: `Memory Write` for log/UI clarity.
|
|
1289
|
+
*
|
|
1290
|
+
* @protected
|
|
1291
|
+
*/
|
|
1292
|
+
protected executeMemoryWritesAsSteps(writes: MemoryWriteRequest[], params: ExecuteAgentParams): Promise<MemoryWriteResult[]>;
|
|
1293
|
+
/**
|
|
1294
|
+
* Turn-loop entry point for in-flight memory writes, gated on the agent's
|
|
1295
|
+
* AllowMemoryWrite flag. When disabled but the LLM emitted writes anyway
|
|
1296
|
+
* (prompt drift / injection attempt), records ONE summary skip step —
|
|
1297
|
+
* observable without per-write noise — and tells the agent the memories
|
|
1298
|
+
* were NOT saved so it stops re-emitting. When enabled, executes the
|
|
1299
|
+
* writes as run steps and injects the results message.
|
|
1300
|
+
*
|
|
1301
|
+
* @protected
|
|
1302
|
+
*/
|
|
1303
|
+
protected processMemoryWritesForTurn(memoryWrites: MemoryWriteRequest[], params: ExecuteAgentParams): Promise<void>;
|
|
1304
|
+
/**
|
|
1305
|
+
* Pushes a single user-role message containing memory-write outcomes into
|
|
1306
|
+
* the conversation, mirroring `injectArtifactToolResultsMessage`'s
|
|
1307
|
+
* inject-once-then-expire pattern. Closing the loop here is what stops the
|
|
1308
|
+
* LLM from re-emitting the same memory on subsequent turns.
|
|
1309
|
+
*
|
|
1310
|
+
* @protected
|
|
1311
|
+
*/
|
|
1312
|
+
protected injectMemoryWriteResultsMessage(params: ExecuteAgentParams, results: MemoryWriteResult[]): void;
|
|
1001
1313
|
/**
|
|
1002
1314
|
* Builds a per-run {@link PipelineToolRegistry} that unifies the three pipeline-able
|
|
1003
1315
|
* substrates behind one namespace: built-in transforms, the agent's effective Actions, and
|
|
@@ -1055,6 +1367,28 @@ export declare class BaseAgent {
|
|
|
1055
1367
|
* @private
|
|
1056
1368
|
*/
|
|
1057
1369
|
private gatherPromptTemplateData;
|
|
1370
|
+
/**
|
|
1371
|
+
* Builds the agent-invariant {@link AgentBaseCatalog} — the resolved sub-agents + actions and
|
|
1372
|
+
* their formatted markdown, plus the base agent-type prompt params. Computed once per agent and
|
|
1373
|
+
* cached on AIEngine (see gatherPromptTemplateData); does NOT apply any runtime overrides.
|
|
1374
|
+
*
|
|
1375
|
+
* @protected
|
|
1376
|
+
*/
|
|
1377
|
+
protected buildAgentBaseCatalog(agent: MJAIAgentEntityExtended, engine: AIEngine): AgentBaseCatalog;
|
|
1378
|
+
/**
|
|
1379
|
+
* Applies runtime {@link SubAgentChange}s to a base sub-agent set — the sub-agent counterpart of
|
|
1380
|
+
* {@link applyActionChanges}. Returns a NEW array (never mutates the cached base set).
|
|
1381
|
+
*
|
|
1382
|
+
* @protected
|
|
1383
|
+
*/
|
|
1384
|
+
protected applySubAgentChanges(baseSubAgents: MJAIAgentEntityExtended[], subAgentChanges: SubAgentChange[], agentId: string, isRoot: boolean, engine: AIEngine): MJAIAgentEntityExtended[];
|
|
1385
|
+
/**
|
|
1386
|
+
* Filters/transforms sub-agent changes for propagation to a sub-agent — the sub-agent counterpart
|
|
1387
|
+
* of {@link filterActionChangesForSubAgent} (same propagation rules).
|
|
1388
|
+
*
|
|
1389
|
+
* @protected
|
|
1390
|
+
*/
|
|
1391
|
+
protected filterSubAgentChangesForSubAgent(subAgentChanges: SubAgentChange[] | undefined): SubAgentChange[] | undefined;
|
|
1058
1392
|
/**
|
|
1059
1393
|
* Builds merged agent type prompt params from schema defaults,
|
|
1060
1394
|
* agent config, and runtime overrides.
|
|
@@ -1408,20 +1742,26 @@ export declare class BaseAgent {
|
|
|
1408
1742
|
*/
|
|
1409
1743
|
protected finalizeStepEntity(stepEntity: MJAIAgentRunStepEntityExtended, success: boolean, errorMessage?: string, outputData?: any): Promise<void>;
|
|
1410
1744
|
/**
|
|
1411
|
-
*
|
|
1412
|
-
*
|
|
1413
|
-
*
|
|
1414
|
-
*
|
|
1415
|
-
* -
|
|
1416
|
-
*
|
|
1417
|
-
*
|
|
1418
|
-
|
|
1419
|
-
|
|
1745
|
+
* Saves one step record and ALWAYS logs (never swallows, never verbose-gated) a failure via `LogError`
|
|
1746
|
+
* with `LatestResult.CompleteMessage` — the log is observability, so a failure must surface but must
|
|
1747
|
+
* not throw into the agent loop. The `update` phase force-saves with `IgnoreDirtyState` because a
|
|
1748
|
+
* finalize/TargetLogID mutation applied while the INSERT was still in flight gets absorbed by the
|
|
1749
|
+
* INSERT's post-save dirty-reset, leaving the new values only in memory (the "step stuck at Running"
|
|
1750
|
+
* bug); forcing the UPDATE re-persists them. `insert` saves normally.
|
|
1751
|
+
* @returns whether the row persisted.
|
|
1752
|
+
*/
|
|
1753
|
+
private saveStepRecord;
|
|
1754
|
+
/**
|
|
1755
|
+
* Queues a fire-and-forget UPDATE of a step entity whose fields the caller has ALREADY mutated.
|
|
1420
1756
|
*
|
|
1421
|
-
*
|
|
1422
|
-
*
|
|
1423
|
-
*
|
|
1424
|
-
*
|
|
1757
|
+
* - The agent flow never awaits this (logging is fire-and-forget).
|
|
1758
|
+
* - Chains after the step's 'started' INSERT and any prior queued save, so the UPDATE never races
|
|
1759
|
+
* ahead of the INSERT; updates to DIFFERENT steps run concurrently.
|
|
1760
|
+
* - Force-persists (IgnoreDirtyState) because a mutation applied while the INSERT was in flight can be
|
|
1761
|
+
* absorbed by the INSERT's post-save dirty-reset, leaving the entity "clean" with the new values
|
|
1762
|
+
* only in memory — without the force, the UPDATE would silently no-op and the row would stay stuck
|
|
1763
|
+
* at Status='Running' / null TargetLogID.
|
|
1764
|
+
* - Failures are logged (never thrown) and surfaced via `_pendingSaves` at run finalize.
|
|
1425
1765
|
*
|
|
1426
1766
|
* @protected
|
|
1427
1767
|
*/
|
|
@@ -2199,4 +2539,5 @@ export declare class BaseAgent {
|
|
|
2199
2539
|
*/
|
|
2200
2540
|
private validateAndApplySecondaryScopes;
|
|
2201
2541
|
}
|
|
2542
|
+
export {};
|
|
2202
2543
|
//# sourceMappingURL=base-agent.d.ts.map
|