@memberjunction/ai-agents 5.40.2 → 5.42.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 +53 -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 +386 -39
- package/dist/base-agent.d.ts.map +1 -1
- package/dist/base-agent.js +1121 -261
- package/dist/base-agent.js.map +1 -1
- package/dist/index.d.ts +13 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +17 -0
- package/dist/index.js.map +1 -1
- package/dist/memory-manager-agent.d.ts +99 -4
- package/dist/memory-manager-agent.d.ts.map +1 -1
- package/dist/memory-manager-agent.js +349 -117
- package/dist/memory-manager-agent.js.map +1 -1
- package/dist/realtime/bridge-realtime-session-factory.d.ts +111 -0
- package/dist/realtime/bridge-realtime-session-factory.d.ts.map +1 -0
- package/dist/realtime/bridge-realtime-session-factory.js +163 -0
- package/dist/realtime/bridge-realtime-session-factory.js.map +1 -0
- package/dist/realtime/bridge-room-transcript-sink.d.ts +58 -0
- package/dist/realtime/bridge-room-transcript-sink.d.ts.map +1 -0
- package/dist/realtime/bridge-room-transcript-sink.js +127 -0
- package/dist/realtime/bridge-room-transcript-sink.js.map +1 -0
- 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 +1026 -0
- package/dist/realtime/realtime-client-session-service.d.ts.map +1 -0
- package/dist/realtime/realtime-client-session-service.js +1607 -0
- package/dist/realtime/realtime-client-session-service.js.map +1 -0
- package/dist/realtime/realtime-coagent-config.d.ts +258 -0
- package/dist/realtime/realtime-coagent-config.d.ts.map +1 -0
- package/dist/realtime/realtime-coagent-config.js +408 -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 +294 -0
- package/dist/realtime/realtime-tool-broker.d.ts.map +1 -0
- package/dist/realtime/realtime-tool-broker.js +206 -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"}
|