@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.
Files changed (80) hide show
  1. package/README.md +45 -0
  2. package/dist/AgentRunner.d.ts +5 -2
  3. package/dist/AgentRunner.d.ts.map +1 -1
  4. package/dist/AgentRunner.js +14 -4
  5. package/dist/AgentRunner.js.map +1 -1
  6. package/dist/MemoryWriteManager.d.ts +188 -0
  7. package/dist/MemoryWriteManager.d.ts.map +1 -0
  8. package/dist/MemoryWriteManager.js +299 -0
  9. package/dist/MemoryWriteManager.js.map +1 -0
  10. package/dist/agent-context-injector.d.ts +29 -0
  11. package/dist/agent-context-injector.d.ts.map +1 -1
  12. package/dist/agent-context-injector.js +90 -32
  13. package/dist/agent-context-injector.js.map +1 -1
  14. package/dist/agent-memory-context-builder.d.ts +100 -0
  15. package/dist/agent-memory-context-builder.d.ts.map +1 -0
  16. package/dist/agent-memory-context-builder.js +172 -0
  17. package/dist/agent-memory-context-builder.js.map +1 -0
  18. package/dist/agent-types/index.d.ts +1 -0
  19. package/dist/agent-types/index.d.ts.map +1 -1
  20. package/dist/agent-types/index.js +1 -0
  21. package/dist/agent-types/index.js.map +1 -1
  22. package/dist/agent-types/loop-agent-response-type.d.ts +12 -1
  23. package/dist/agent-types/loop-agent-response-type.d.ts.map +1 -1
  24. package/dist/agent-types/loop-agent-response-type.js.map +1 -1
  25. package/dist/agent-types/loop-agent-type.d.ts.map +1 -1
  26. package/dist/agent-types/loop-agent-type.js +4 -0
  27. package/dist/agent-types/loop-agent-type.js.map +1 -1
  28. package/dist/agent-types/realtime-agent-type.d.ts +146 -0
  29. package/dist/agent-types/realtime-agent-type.d.ts.map +1 -0
  30. package/dist/agent-types/realtime-agent-type.js +176 -0
  31. package/dist/agent-types/realtime-agent-type.js.map +1 -0
  32. package/dist/base-agent.d.ts +365 -24
  33. package/dist/base-agent.d.ts.map +1 -1
  34. package/dist/base-agent.js +995 -175
  35. package/dist/base-agent.js.map +1 -1
  36. package/dist/index.d.ts +11 -0
  37. package/dist/index.d.ts.map +1 -1
  38. package/dist/index.js +15 -0
  39. package/dist/index.js.map +1 -1
  40. package/dist/memory-manager-agent.d.ts +55 -2
  41. package/dist/memory-manager-agent.d.ts.map +1 -1
  42. package/dist/memory-manager-agent.js +261 -62
  43. package/dist/memory-manager-agent.js.map +1 -1
  44. package/dist/realtime/meeting-controls-channel-server.d.ts +198 -0
  45. package/dist/realtime/meeting-controls-channel-server.d.ts.map +1 -0
  46. package/dist/realtime/meeting-controls-channel-server.js +319 -0
  47. package/dist/realtime/meeting-controls-channel-server.js.map +1 -0
  48. package/dist/realtime/meeting-controls-state.d.ts +191 -0
  49. package/dist/realtime/meeting-controls-state.d.ts.map +1 -0
  50. package/dist/realtime/meeting-controls-state.js +219 -0
  51. package/dist/realtime/meeting-controls-state.js.map +1 -0
  52. package/dist/realtime/realtime-channel-server-host.d.ts +166 -0
  53. package/dist/realtime/realtime-channel-server-host.d.ts.map +1 -0
  54. package/dist/realtime/realtime-channel-server-host.js +378 -0
  55. package/dist/realtime/realtime-channel-server-host.js.map +1 -0
  56. package/dist/realtime/realtime-client-session-service.d.ts +884 -0
  57. package/dist/realtime/realtime-client-session-service.d.ts.map +1 -0
  58. package/dist/realtime/realtime-client-session-service.js +1401 -0
  59. package/dist/realtime/realtime-client-session-service.js.map +1 -0
  60. package/dist/realtime/realtime-coagent-config.d.ts +202 -0
  61. package/dist/realtime/realtime-coagent-config.d.ts.map +1 -0
  62. package/dist/realtime/realtime-coagent-config.js +334 -0
  63. package/dist/realtime/realtime-coagent-config.js.map +1 -0
  64. package/dist/realtime/realtime-narration.d.ts +67 -0
  65. package/dist/realtime/realtime-narration.d.ts.map +1 -0
  66. package/dist/realtime/realtime-narration.js +127 -0
  67. package/dist/realtime/realtime-narration.js.map +1 -0
  68. package/dist/realtime/realtime-session-runner.d.ts +383 -0
  69. package/dist/realtime/realtime-session-runner.d.ts.map +1 -0
  70. package/dist/realtime/realtime-session-runner.js +532 -0
  71. package/dist/realtime/realtime-session-runner.js.map +1 -0
  72. package/dist/realtime/realtime-tool-broker.d.ts +279 -0
  73. package/dist/realtime/realtime-tool-broker.d.ts.map +1 -0
  74. package/dist/realtime/realtime-tool-broker.js +184 -0
  75. package/dist/realtime/realtime-tool-broker.js.map +1 -0
  76. package/dist/realtime/whiteboard-channel-server.d.ts +50 -0
  77. package/dist/realtime/whiteboard-channel-server.d.ts.map +1 -0
  78. package/dist/realtime/whiteboard-channel-server.js +85 -0
  79. package/dist/realtime/whiteboard-channel-server.js.map +1 -0
  80. package/package.json +17 -17
@@ -0,0 +1,67 @@
1
+ /**
2
+ * @fileoverview Shared narration helpers for BOTH realtime topologies.
3
+ *
4
+ * Two concerns live here so they exist exactly once:
5
+ *
6
+ * 1. **DB template resolution** — {@link ResolveNarrationInstructionsTemplate} looks up the
7
+ * seeded `Realtime Co-Agent - Progress Narration` prompt (with the deprecated pre-rename
8
+ * fallback) in {@link AIEngine}'s cached prompts. The client-direct path threads the
9
+ * template to the browser at session mint; the server-bridged path
10
+ * ({@link import('./realtime-session-runner.js').RealtimeSessionRunner}) consumes it directly.
11
+ * 2. **Instruction building** — {@link BuildServerNarrationInstructions} substitutes the
12
+ * template's placeholders (or falls back to the documented built-in first-person wording)
13
+ * for the server-bridged runner's spoken progress updates. The Angular voice session has
14
+ * its own richer builder (it also chains the model's PRIOR spoken narrations, which only
15
+ * the browser can observe); this server-side builder is deliberately compact.
16
+ *
17
+ * @module @memberjunction/ai-agents
18
+ * @author MemberJunction.com
19
+ */
20
+ /**
21
+ * The seeded name of the `MJ: AI Prompts` row whose `TemplateText` carries the first-person
22
+ * progress-narration instructions (with a `{{ progressMessage }}` placeholder).
23
+ */
24
+ export declare const NARRATION_PROMPT_NAME = "Realtime Co-Agent - Progress Narration";
25
+ /**
26
+ * DEPRECATED legacy name of {@link NARRATION_PROMPT_NAME}, from before the co-agent's rename
27
+ * from "Voice Co-Agent" to "Realtime Co-Agent". Deployments that have not re-synced the prompt
28
+ * seed still carry this name, so {@link ResolveNarrationInstructionsTemplate} falls back to it
29
+ * (with a deprecation log).
30
+ */
31
+ export declare const LEGACY_NARRATION_PROMPT_NAME = "Voice Co-Agent - Progress Narration";
32
+ /**
33
+ * Resolves the DB-driven progress-narration instruction template: the Active `MJ: AI Prompts`
34
+ * row named {@link NARRATION_PROMPT_NAME}, read from {@link AIEngine}'s cached prompts. When
35
+ * the current name is absent, falls back to the DEPRECATED {@link LEGACY_NARRATION_PROMPT_NAME}
36
+ * (pre-rename seed) with a deprecation log. **Tolerant**: returns `null` (never throws) when
37
+ * neither prompt is present, the text is empty, or the engine cache is unavailable — consumers
38
+ * fall back to the built-in narration instruction wording.
39
+ *
40
+ * @returns The template text (containing a `{{ progressMessage }}` placeholder), or `null`.
41
+ */
42
+ export declare function ResolveNarrationInstructionsTemplate(): string | null;
43
+ /**
44
+ * The documented BUILT-IN fallback wording for a server-bridged spoken progress update —
45
+ * strictly first person (the co-agent owns the work), one short sentence, no repetition.
46
+ * Used when no DB template resolved for the deployment.
47
+ *
48
+ * @param digest The aggregated progress digest (one or more updates, oldest first).
49
+ * @param updateNumber 1-based number of this spoken update within the current task.
50
+ * @returns The complete spoken-update instruction text.
51
+ */
52
+ export declare function DefaultServerNarrationInstructions(digest: string, updateNumber: number): string;
53
+ /**
54
+ * Builds the spoken-update instructions for the server-bridged runner from the DB template
55
+ * (substituting `{{ progressMessage }}` / `{{ updateNumber }}`, space and no-space variants),
56
+ * falling back to {@link DefaultServerNarrationInstructions} when the template is absent or
57
+ * blank. The `{{ priorNarrations }}` placeholder is substituted with a neutral note — the
58
+ * server-bridged path cannot observe what the model actually SAID (those transcripts ride the
59
+ * provider socket), unlike the browser host which chains them.
60
+ *
61
+ * @param template The DB-driven instruction template, or `null`/`undefined` when unavailable.
62
+ * @param digest The aggregated progress digest (one or more updates, oldest first).
63
+ * @param updateNumber 1-based number of this spoken update within the current task.
64
+ * @returns The complete spoken-update instruction text.
65
+ */
66
+ export declare function BuildServerNarrationInstructions(template: string | null | undefined, digest: string, updateNumber: number): string;
67
+ //# sourceMappingURL=realtime-narration.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"realtime-narration.d.ts","sourceRoot":"","sources":["../../src/realtime/realtime-narration.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;GAkBG;AAKH;;;GAGG;AACH,eAAO,MAAM,qBAAqB,2CAA2C,CAAC;AAE9E;;;;;GAKG;AACH,eAAO,MAAM,4BAA4B,wCAAwC,CAAC;AAOlF;;;;;;;;;GASG;AACH,wBAAgB,oCAAoC,IAAI,MAAM,GAAG,IAAI,CAmBpE;AAwBD;;;;;;;;GAQG;AACH,wBAAgB,kCAAkC,CAAC,MAAM,EAAE,MAAM,EAAE,YAAY,EAAE,MAAM,GAAG,MAAM,CAU/F;AAED;;;;;;;;;;;;GAYG;AACH,wBAAgB,gCAAgC,CAC5C,QAAQ,EAAE,MAAM,GAAG,IAAI,GAAG,SAAS,EACnC,MAAM,EAAE,MAAM,EACd,YAAY,EAAE,MAAM,GACrB,MAAM,CAcR"}
@@ -0,0 +1,127 @@
1
+ /**
2
+ * @fileoverview Shared narration helpers for BOTH realtime topologies.
3
+ *
4
+ * Two concerns live here so they exist exactly once:
5
+ *
6
+ * 1. **DB template resolution** — {@link ResolveNarrationInstructionsTemplate} looks up the
7
+ * seeded `Realtime Co-Agent - Progress Narration` prompt (with the deprecated pre-rename
8
+ * fallback) in {@link AIEngine}'s cached prompts. The client-direct path threads the
9
+ * template to the browser at session mint; the server-bridged path
10
+ * ({@link import('./realtime-session-runner.js').RealtimeSessionRunner}) consumes it directly.
11
+ * 2. **Instruction building** — {@link BuildServerNarrationInstructions} substitutes the
12
+ * template's placeholders (or falls back to the documented built-in first-person wording)
13
+ * for the server-bridged runner's spoken progress updates. The Angular voice session has
14
+ * its own richer builder (it also chains the model's PRIOR spoken narrations, which only
15
+ * the browser can observe); this server-side builder is deliberately compact.
16
+ *
17
+ * @module @memberjunction/ai-agents
18
+ * @author MemberJunction.com
19
+ */
20
+ import { LogStatus } from '@memberjunction/core';
21
+ import { AIEngine } from '@memberjunction/aiengine';
22
+ /**
23
+ * The seeded name of the `MJ: AI Prompts` row whose `TemplateText` carries the first-person
24
+ * progress-narration instructions (with a `{{ progressMessage }}` placeholder).
25
+ */
26
+ export const NARRATION_PROMPT_NAME = 'Realtime Co-Agent - Progress Narration';
27
+ /**
28
+ * DEPRECATED legacy name of {@link NARRATION_PROMPT_NAME}, from before the co-agent's rename
29
+ * from "Voice Co-Agent" to "Realtime Co-Agent". Deployments that have not re-synced the prompt
30
+ * seed still carry this name, so {@link ResolveNarrationInstructionsTemplate} falls back to it
31
+ * (with a deprecation log).
32
+ */
33
+ export const LEGACY_NARRATION_PROMPT_NAME = 'Voice Co-Agent - Progress Narration';
34
+ /** Placeholder token variants substituted by {@link BuildServerNarrationInstructions}. */
35
+ const PROGRESS_TOKENS = ['{{ progressMessage }}', '{{progressMessage}}'];
36
+ const PRIOR_TOKENS = ['{{ priorNarrations }}', '{{priorNarrations}}'];
37
+ const NUMBER_TOKENS = ['{{ updateNumber }}', '{{updateNumber}}'];
38
+ /**
39
+ * Resolves the DB-driven progress-narration instruction template: the Active `MJ: AI Prompts`
40
+ * row named {@link NARRATION_PROMPT_NAME}, read from {@link AIEngine}'s cached prompts. When
41
+ * the current name is absent, falls back to the DEPRECATED {@link LEGACY_NARRATION_PROMPT_NAME}
42
+ * (pre-rename seed) with a deprecation log. **Tolerant**: returns `null` (never throws) when
43
+ * neither prompt is present, the text is empty, or the engine cache is unavailable — consumers
44
+ * fall back to the built-in narration instruction wording.
45
+ *
46
+ * @returns The template text (containing a `{{ progressMessage }}` placeholder), or `null`.
47
+ */
48
+ export function ResolveNarrationInstructionsTemplate() {
49
+ try {
50
+ const current = findActiveNarrationPromptText(NARRATION_PROMPT_NAME);
51
+ if (current) {
52
+ return current;
53
+ }
54
+ const legacy = findActiveNarrationPromptText(LEGACY_NARRATION_PROMPT_NAME);
55
+ if (legacy) {
56
+ LogStatus(`Realtime narration: resolved the narration prompt via its DEPRECATED legacy name ` +
57
+ `'${LEGACY_NARRATION_PROMPT_NAME}'. Re-sync the prompt seed metadata to rename it to ` +
58
+ `'${NARRATION_PROMPT_NAME}'.`);
59
+ return legacy;
60
+ }
61
+ return null;
62
+ }
63
+ catch {
64
+ return null; // engine cache unavailable — tolerated, consumers fall back
65
+ }
66
+ }
67
+ /**
68
+ * Finds the Active `MJ: AI Prompts` row with the given name (case/whitespace-insensitive) in
69
+ * {@link AIEngine}'s cached prompts and returns its non-empty `TemplateText`, or `null`.
70
+ */
71
+ function findActiveNarrationPromptText(promptName) {
72
+ const wanted = promptName.toLowerCase();
73
+ const prompt = (AIEngine.Instance.Prompts ?? []).find(p => p.Name?.trim().toLowerCase() === wanted && p.Status === 'Active');
74
+ const text = prompt?.TemplateText;
75
+ return text && text.trim().length > 0 ? text : null;
76
+ }
77
+ /** Replaces every occurrence of each token variant with the value. */
78
+ function replaceTokens(text, tokens, value) {
79
+ let out = text;
80
+ for (const t of tokens) {
81
+ out = out.split(t).join(value);
82
+ }
83
+ return out;
84
+ }
85
+ /**
86
+ * The documented BUILT-IN fallback wording for a server-bridged spoken progress update —
87
+ * strictly first person (the co-agent owns the work), one short sentence, no repetition.
88
+ * Used when no DB template resolved for the deployment.
89
+ *
90
+ * @param digest The aggregated progress digest (one or more updates, oldest first).
91
+ * @param updateNumber 1-based number of this spoken update within the current task.
92
+ * @returns The complete spoken-update instruction text.
93
+ */
94
+ export function DefaultServerNarrationInstructions(digest, updateNumber) {
95
+ return (`Live progress on the work YOU are doing for the user (oldest first): ${digest}. ` +
96
+ `This is spoken update #${updateNumber} for this task. ` +
97
+ `Say ONE short, natural sentence in the FIRST PERSON continuing the story of what you are doing ` +
98
+ `("I'm pulling that up now", "Got the first part — grabbing the rest"). VARY the phrasing across ` +
99
+ `updates and never repeat information you've already conveyed — only add what's new. Strictly first ` +
100
+ `person: the words "it" and the agent's name must not be the subject of your sentence, and never say ` +
101
+ `generic filler like "it's still running in the background".`);
102
+ }
103
+ /**
104
+ * Builds the spoken-update instructions for the server-bridged runner from the DB template
105
+ * (substituting `{{ progressMessage }}` / `{{ updateNumber }}`, space and no-space variants),
106
+ * falling back to {@link DefaultServerNarrationInstructions} when the template is absent or
107
+ * blank. The `{{ priorNarrations }}` placeholder is substituted with a neutral note — the
108
+ * server-bridged path cannot observe what the model actually SAID (those transcripts ride the
109
+ * provider socket), unlike the browser host which chains them.
110
+ *
111
+ * @param template The DB-driven instruction template, or `null`/`undefined` when unavailable.
112
+ * @param digest The aggregated progress digest (one or more updates, oldest first).
113
+ * @param updateNumber 1-based number of this spoken update within the current task.
114
+ * @returns The complete spoken-update instruction text.
115
+ */
116
+ export function BuildServerNarrationInstructions(template, digest, updateNumber) {
117
+ if (!template || template.trim().length === 0) {
118
+ return DefaultServerNarrationInstructions(digest, updateNumber);
119
+ }
120
+ let out = replaceTokens(template, PROGRESS_TOKENS, digest);
121
+ out = replaceTokens(out, PRIOR_TOKENS, updateNumber <= 1
122
+ ? 'Nothing yet — this is your first spoken update for this task.'
123
+ : `You have already spoken ${updateNumber - 1} update(s) for this task — do not repeat yourself; only add what's new.`);
124
+ out = replaceTokens(out, NUMBER_TOKENS, String(updateNumber));
125
+ return out;
126
+ }
127
+ //# sourceMappingURL=realtime-narration.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"realtime-narration.js","sourceRoot":"","sources":["../../src/realtime/realtime-narration.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;GAkBG;AAEH,OAAO,EAAE,SAAS,EAAE,MAAM,sBAAsB,CAAC;AACjD,OAAO,EAAE,QAAQ,EAAE,MAAM,0BAA0B,CAAC;AAEpD;;;GAGG;AACH,MAAM,CAAC,MAAM,qBAAqB,GAAG,wCAAwC,CAAC;AAE9E;;;;;GAKG;AACH,MAAM,CAAC,MAAM,4BAA4B,GAAG,qCAAqC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seRealtimeModel` session for
3
+ * the {@link RealtimeAgentType} (Realtime Co-Agent).
4
+ *
5
+ * The {@link RealtimeSessionRunner} owns the lifecycle of a single full-duplex
6
+ * {@link IRealtimeSession}: it opens the session, registers a **stable, target-independent** tool
7
+ * set (always including `invoke-target-agent`), wires the provider event handlers, routes tool
8
+ * calls (invoke-target → delegate to the target agent; others → an injected tool executor),
9
+ * persists each transcript turn as a conversation detail, accumulates usage and checkpoints it on
10
+ * a debounced cadence, and aborts any in-flight delegated run on barge-in.
11
+ *
12
+ * **Why dependency injection.** Every collaborator that would otherwise pull in `BaseAgent`,
13
+ * metadata, or the database is injected via {@link RealtimeSessionRunnerDeps}. That keeps the
14
+ * runner fully unit-testable against a mock realtime model and mock collaborators (this is the
15
+ * P2b-i deliverable). In P2b-ii, `BaseAgent` supplies the real implementations (model resolution
16
+ * from agent metadata, the `ExecuteSubAgent`-backed delegate, `ConversationDetail` persistence,
17
+ * and the `AIPromptRun` usage checkpoint).
18
+ *
19
+ * @module @memberjunction/ai-agents
20
+ * @author MemberJunction.com
21
+ */
22
+ import { BaseRealtimeModel, RealtimeSessionParams, RealtimeTranscript, RealtimeToolCall, RealtimeUsage, RealtimeToolDefinition } from '@memberjunction/ai';
23
+ import { INVOKE_TARGET_AGENT_TOOL_NAME, DelegateToTargetRequest, DelegatedResult, ToolExecutionResult, RealtimeStatusLogger, RealtimeErrorLogger } from './realtime-tool-broker.js';
24
+ export { INVOKE_TARGET_AGENT_TOOL_NAME, DelegateToTargetRequest, DelegatedResult, ToolExecutionResult, RealtimeStatusLogger, RealtimeErrorLogger };
25
+ /**
26
+ * The injected collaborators that drive a realtime session.
27
+ *
28
+ * Each member is a seam that decouples the runner from `BaseAgent`/metadata/DB so it can be
29
+ * exercised with mocks. `BaseAgent` supplies the production implementations in P2b-ii.
30
+ */
31
+ export interface RealtimeSessionRunnerDeps {
32
+ /**
33
+ * The resolved realtime model whose {@link BaseRealtimeModel.StartSession} opens the duplex
34
+ * session. In production, resolved from the agent's `MJ: AI Models` metadata via the
35
+ * ClassFactory; in tests, a mock model.
36
+ */
37
+ Model: BaseRealtimeModel;
38
+ /**
39
+ * The session parameters (system prompt with companion/"voice for" framing + assembled
40
+ * memory/context, model API name, and optional provider config). The runner adds the stable
41
+ * tool set itself — callers should not pre-populate {@link RealtimeSessionParams.Tools} with
42
+ * the `invoke-target-agent` tool.
43
+ */
44
+ SessionParams: RealtimeSessionParams;
45
+ /**
46
+ * Extra realtime tools to register *in addition to* the always-present `invoke-target-agent`
47
+ * tool — e.g. fixed UI/control tools. These stay target-independent (see
48
+ * {@link INVOKE_TARGET_AGENT_TOOL_NAME}). Optional.
49
+ */
50
+ ExtraTools?: RealtimeToolDefinition[];
51
+ /**
52
+ * Server-executed tool definitions contributed by the session's **server-side interactive
53
+ * channels** (`BaseRealtimeChannelServer.GetServerToolDefinitions`, aggregated by
54
+ * `RealtimeChannelServerHost.GetSessionServerTools`). Registered alongside
55
+ * {@link RealtimeSessionRunnerDeps.ExtraTools} and the stable target tool; when the model invokes
56
+ * one, the runner routes it to {@link RealtimeSessionRunnerDeps.ExecuteServerChannelTool} BEFORE
57
+ * the generic {@link RealtimeSessionRunnerDeps.ExecuteTool}, so channel tools execute server-side
58
+ * (a bridged bot has no browser). Optional and additive — absent on the client-direct path and
59
+ * on server-bridged runs without channels, leaving the existing tool set behavior untouched.
60
+ *
61
+ * This is the deferred "channel tool contribution feeding the runner's tool set" the realtime
62
+ * guide flagged — now driven.
63
+ */
64
+ ServerChannelTools?: RealtimeToolDefinition[];
65
+ /**
66
+ * Executes ONE server-channel tool call (a tool whose name was contributed via
67
+ * {@link RealtimeSessionRunnerDeps.ServerChannelTools}). In production this is bound to
68
+ * `RealtimeChannelServerHost.ExecuteSessionServerTool(sessionID, …)`. Must resolve with a result
69
+ * (never throw — the broker wraps any throw into a structured error). When omitted, a contributed
70
+ * server-channel tool falls through to the generic {@link RealtimeSessionRunnerDeps.ExecuteTool}.
71
+ */
72
+ ExecuteServerChannelTool?: (call: RealtimeToolCall) => Promise<ToolExecutionResult>;
73
+ /**
74
+ * Runs the target agent for an `invoke-target-agent` tool call. The runner creates and owns a
75
+ * fresh `AbortController` per delegated call and passes its signal in via
76
+ * {@link DelegateToTargetRequest.AbortSignal}; barge-in aborts it. In production this is
77
+ * backed by `BaseAgent.ExecuteSubAgent` (top-level target only — sub-agents are not exposed).
78
+ */
79
+ DelegateToTarget: (request: DelegateToTargetRequest) => Promise<DelegatedResult>;
80
+ /**
81
+ * Executes a non-target tool call (any tool other than `invoke-target-agent`). In production
82
+ * this routes to the co-agent's server/client/UI tool execution under the session's context
83
+ * user.
84
+ */
85
+ ExecuteTool: (call: RealtimeToolCall) => Promise<ToolExecutionResult>;
86
+ /**
87
+ * Persists a transcript turn as a `ConversationDetail` stamped with the session ID. In
88
+ * production this writes the durable transcript; in tests, a spy.
89
+ */
90
+ PersistTranscript: (transcript: RealtimeTranscript) => Promise<void>;
91
+ /**
92
+ * Checkpoints the *accumulated* usage onto the single long-lived `AIPromptRun`. The runner
93
+ * accumulates `OnUsage` deltas and invokes this on a debounced cadence and on close, so a
94
+ * crash-driven janitor close finalizes from the last-persisted values and loses nothing.
95
+ */
96
+ CheckpointUsage: (usage: RealtimeUsage) => Promise<void>;
97
+ /** Optional debounce window (ms) for usage checkpoints. Defaults to 5000ms. */
98
+ UsageCheckpointDebounceMs?: number;
99
+ /**
100
+ * Optional DB-driven progress-narration instruction template (the
101
+ * `Realtime Co-Agent - Progress Narration` prompt's `TemplateText`, containing a
102
+ * `{{ progressMessage }}` placeholder). When absent/`null`, the runner falls back to the
103
+ * built-in first-person wording (see `BuildServerNarrationInstructions`). `BaseAgent`
104
+ * supplies this via the shared narration lookup in `realtime-narration.ts`.
105
+ */
106
+ NarrationInstructionsTemplate?: string | null;
107
+ /**
108
+ * Optional narration pace override (ms) — the minimum gap between spoken progress updates,
109
+ * normally sourced from the co-agent's EFFECTIVE realtime configuration
110
+ * (`realtime.narration.paceMs`: type `DefaultConfiguration` ← agent `TypeConfiguration` ←
111
+ * runtime overrides). When absent or not a positive finite number, the runner's built-in
112
+ * default (8000 ms) applies. `BaseAgent` supplies this on the server-bridged path.
113
+ */
114
+ NarrationPaceMs?: number | null;
115
+ /** Optional verbose-aware status logger. */
116
+ LogStatus?: RealtimeStatusLogger;
117
+ /** Optional error logger. */
118
+ LogError?: RealtimeErrorLogger;
119
+ }
120
+ /**
121
+ * The outcome of a completed realtime session run.
122
+ */
123
+ export interface RealtimeSessionResult {
124
+ /** Whether the session ran to a clean close. */
125
+ Success: boolean;
126
+ /** The final accumulated usage that was checkpointed at close. */
127
+ FinalUsage: RealtimeUsage;
128
+ /** Total transcript turns persisted during the session. */
129
+ TranscriptTurnCount: number;
130
+ /** An error message if the session failed to start or finalize. */
131
+ ErrorMessage?: string;
132
+ }
133
+ /**
134
+ * Orchestrates a single `BaseRealtimeModel` duplex session for the Realtime agent type.
135
+ *
136
+ * Construct with a fully-populated {@link RealtimeSessionRunnerDeps}, then call {@link Run} to
137
+ * drive the session to completion, or {@link Start}/{@link Stop} to control it explicitly.
138
+ */
139
+ export declare class RealtimeSessionRunner {
140
+ /** First spoken update fires no earlier than this long after a delegation burst starts. */
141
+ private static readonly FirstNarrationDelayMs;
142
+ /** Minimum gap between SUBSEQUENT spoken updates (floods aggregate into one digest). */
143
+ private static readonly NarrationIntervalMs;
144
+ /** Max progress messages aggregated into one spoken digest. */
145
+ private static readonly MaxDigestMessages;
146
+ /**
147
+ * Progress steps worth narrating — mirrors the client-direct resolver's filter so both
148
+ * topologies narrate the same signal and drop the same initialization/finalization noise.
149
+ */
150
+ private static readonly SignificantProgressSteps;
151
+ private deps;
152
+ private session;
153
+ /** Accumulated usage across all `OnUsage` deltas, flushed to the checkpoint on debounce/close. */
154
+ private accumulatedUsage;
155
+ /** Whether there is accumulated usage that has not yet been checkpointed. */
156
+ private usageDirty;
157
+ /** Pending debounce timer handle for usage checkpoints. */
158
+ private usageDebounceTimer;
159
+ /** Count of delegations currently in flight (anchors the narration burst lifecycle). */
160
+ private activeDelegations;
161
+ /** Epoch ms when the current delegation burst began (first in-flight delegation). */
162
+ private narrationBurstStartedAt;
163
+ /** Epoch ms of the last spoken update; 0 = never. SESSION-global spacing floor. */
164
+ private lastNarrationAt;
165
+ /** Spoken updates so far in the current burst (1-based numbering for the instructions). */
166
+ private narrationCount;
167
+ /** Aggregation buffer: distinct progress messages since the last spoken update (oldest first). */
168
+ private pendingNarrationMessages;
169
+ /** Tail message of the last digest, so an identical trailing progress event isn't re-buffered. */
170
+ private lastNarratedTail;
171
+ /** Pending deferred-narration timer; cancelled when the delegation finishes / barge-in lands. */
172
+ private narrationTimer;
173
+ /**
174
+ * The shared, topology-agnostic tool-execution path. The runner delegates all tool-call routing,
175
+ * abort-controller ownership, and result/error serialization to this broker so the server-bridged
176
+ * path executes a tool call identically to the client-direct relay path.
177
+ */
178
+ private toolBroker;
179
+ /**
180
+ * Names of the contributed server-channel tools ({@link RealtimeSessionRunnerDeps.ServerChannelTools}),
181
+ * used to route a non-target tool call to the channel handler. Empty when no channels contributed.
182
+ */
183
+ private readonly serverChannelToolNames;
184
+ /** Count of transcript turns persisted, surfaced in the result. */
185
+ private transcriptTurnCount;
186
+ /** Whether {@link Stop} has been initiated, to make finalization idempotent. */
187
+ private stopped;
188
+ /**
189
+ * @param deps The injected collaborators that drive the session.
190
+ */
191
+ constructor(deps: RealtimeSessionRunnerDeps);
192
+ /**
193
+ * Routes a non-target tool call: a contributed server-channel tool goes to the channel handler
194
+ * ({@link RealtimeSessionRunnerDeps.ExecuteServerChannelTool}); everything else goes to the
195
+ * generic {@link RealtimeSessionRunnerDeps.ExecuteTool}. When a tool is a server-channel tool but
196
+ * no channel handler is wired, it falls through to the generic executor (defensive).
197
+ *
198
+ * @param call The non-target tool call emitted by the model.
199
+ * @returns The tool execution result.
200
+ */
201
+ private executeNonTargetTool;
202
+ /**
203
+ * The debounce window (ms) for usage checkpoints, defaulting to 5000ms.
204
+ */
205
+ private get debounceMs();
206
+ /**
207
+ * Builds the realtime tool set registered with the provider.
208
+ *
209
+ * Always includes the stable, target-independent {@link INVOKE_TARGET_AGENT_TOOL_NAME} tool,
210
+ * followed by any {@link RealtimeSessionRunnerDeps.ExtraTools} and then any contributed
211
+ * {@link RealtimeSessionRunnerDeps.ServerChannelTools} (the server-side interactive channels'
212
+ * dynamic vocabulary). This is the full set the provider sees — everything target-specific runs
213
+ * *inside* the delegated agent's own run and is never registered on the realtime socket.
214
+ *
215
+ * @returns The ordered tool definitions to register.
216
+ */
217
+ BuildToolSet(): RealtimeToolDefinition[];
218
+ /**
219
+ * Opens the session, registers tools, and wires all provider event handlers.
220
+ *
221
+ * Idempotent guard: throws if the session is already started. After this resolves, the session
222
+ * is live and streaming; call {@link Stop} (or {@link Run}, which awaits closure) to finalize.
223
+ *
224
+ * @throws If the model fails to start a session.
225
+ */
226
+ Start(): Promise<void>;
227
+ /**
228
+ * Registers the provider event handlers on the live session.
229
+ *
230
+ * @param session The active session to wire.
231
+ */
232
+ private wireHandlers;
233
+ /**
234
+ * Handles a session error per the {@link IRealtimeSession.OnError} fatality contract:
235
+ * - `Fatal: true` (transport/socket failure, credential expiry, unexpected close) — the
236
+ * session is unusable, so the runner finalizes cleanly via {@link Stop} (final usage
237
+ * flush, delegated-run abort, idempotent teardown) instead of idling on a dead socket.
238
+ * - `Fatal: false` — a provider-reported, recoverable error frame; logged, session
239
+ * continues.
240
+ *
241
+ * @param error The error surfaced by the live session.
242
+ */
243
+ private handleSessionError;
244
+ /**
245
+ * Persists a transcript turn via the injected persistence collaborator.
246
+ *
247
+ * @param transcript The transcript event (partial or final) emitted by the model.
248
+ */
249
+ private handleTranscript;
250
+ /**
251
+ * Routes a tool call through the shared {@link RealtimeToolBroker} and feeds its serialized
252
+ * result back to the model.
253
+ *
254
+ * The broker performs identical routing for both topologies (`invoke-target-agent` → delegate;
255
+ * everything else → the tool executor), owns the per-call abort controller, and serializes the
256
+ * success/error result. The runner only relays the broker's `ResultJson` over the live session
257
+ * via {@link IRealtimeSession.SendToolResult}.
258
+ *
259
+ * @param call The tool-call request emitted by the model.
260
+ */
261
+ private handleToolCall;
262
+ /**
263
+ * Sends a serialized tool result to the live session, logging (but not rethrowing) any failure.
264
+ *
265
+ * @param callID The originating tool call's id.
266
+ * @param resultJson The JSON-stringified result to send.
267
+ * @param operation A short description of the send operation, used in error logging.
268
+ */
269
+ private dispatchToolResult;
270
+ /**
271
+ * Accumulates a usage delta and schedules a debounced checkpoint.
272
+ *
273
+ * @param usage The incremental usage update reported by the provider.
274
+ */
275
+ private handleUsage;
276
+ /**
277
+ * Schedules a single debounced usage checkpoint. Repeated calls within the window coalesce
278
+ * into one flush, bounding write frequency during a token-heavy turn.
279
+ */
280
+ private scheduleUsageCheckpoint;
281
+ /**
282
+ * Flushes the accumulated usage to the checkpoint collaborator if there is anything new.
283
+ *
284
+ * Sends a snapshot of the *cumulative* total (matching the plan's "finalize from the
285
+ * last-persisted values" contract) and clears the dirty flag.
286
+ */
287
+ private flushUsage;
288
+ /**
289
+ * Handles a provider-detected interruption (barge-in).
290
+ *
291
+ * Aborts the in-flight delegated run's controller (if any) so a stale delegated result is
292
+ * never narrated into a conversation that has moved on. Turn detection / VAD and stopping the
293
+ * model's current turn are owned by the provider; the consequence for delegated work is ours.
294
+ */
295
+ private handleInterruption;
296
+ /**
297
+ * Runs one delegated call through the injected delegate while owning the NARRATION burst
298
+ * around it: progress events are threaded back via {@link DelegateToTargetRequest.OnProgress},
299
+ * and when the delegation finishes (success, failure, or abort) any still-pending spoken
300
+ * update is cancelled — the final tool result is about to be voiced, so an interim "still
301
+ * working…" line is moot.
302
+ */
303
+ private runDelegateWithNarration;
304
+ /**
305
+ * Anchors a fresh narration burst when no other delegation is in flight. Deliberately NOT
306
+ * reset across bursts: {@link lastNarrationAt} (the ~8s spacing floor is SESSION-global, so
307
+ * sequential tool calls seconds apart can never narrate faster than the interval).
308
+ */
309
+ private beginDelegationBurst;
310
+ /** Closes one delegation; when none remain in flight, pending narration is cancelled. */
311
+ private endDelegation;
312
+ /**
313
+ * Consumes one delegated-run progress event:
314
+ * - significant steps only (mirrors the client-direct resolver's filter);
315
+ * - the message is ALWAYS injected as a background context note (feature-detected —
316
+ * {@link IRealtimeSession.SendContextNote} is an optional capability) so the model can
317
+ * draw on it whenever it next speaks;
318
+ * - a THROTTLED spoken update is scheduled (feature-detected —
319
+ * {@link IRealtimeSession.RequestSpokenUpdate} is optional): first at ~5s into the burst,
320
+ * then every ~8s, with floods aggregated into ONE digest. Collision with an in-flight
321
+ * model response is the DRIVER's obligation (queue or skip) per the
322
+ * `RequestSpokenUpdate` contract, so the runner does not gate on busy state.
323
+ */
324
+ private handleDelegationProgress;
325
+ /** Adds a progress message to the digest buffer (deduped, capped, oldest-first). */
326
+ private bufferNarrationMessage;
327
+ /**
328
+ * ms until the next spoken update is allowed. Two constraints, BOTH enforced:
329
+ * - first update of a burst: no earlier than ~5s after the burst started;
330
+ * - ~8s since the last spoken update, SESSION-global.
331
+ */
332
+ private nextNarrationDelayMs;
333
+ /**
334
+ * The effective spoken-update spacing: the deps' configuration-driven
335
+ * {@link RealtimeSessionRunnerDeps.NarrationPaceMs} when it is a positive finite number,
336
+ * else the built-in {@link RealtimeSessionRunner.NarrationIntervalMs} default.
337
+ */
338
+ private narrationIntervalMs;
339
+ /**
340
+ * Speaks the aggregated progress digest — unless the work already finished (buffer cancelled)
341
+ * or the session is gone. Per-turn collision safety is the driver's `RequestSpokenUpdate`
342
+ * obligation (queue or skip), so no busy gate is needed here.
343
+ */
344
+ private fireDeferredNarration;
345
+ /** Cancels any deferred spoken update and drops the digest buffer. */
346
+ private cancelPendingNarration;
347
+ /**
348
+ * Closes the session and finalizes usage. Idempotent: a second call is a no-op.
349
+ *
350
+ * Cancels any pending debounce timer, performs a final synchronous-cadence usage flush so no
351
+ * partial usage is lost, closes the underlying session, and returns the run result.
352
+ *
353
+ * @returns The final {@link RealtimeSessionResult}.
354
+ */
355
+ Stop(): Promise<RealtimeSessionResult>;
356
+ /**
357
+ * Builds the run result from the current accumulated state.
358
+ *
359
+ * @param success Whether the session is considered successful.
360
+ * @param errorMessage Optional error message to attach.
361
+ * @returns The result object.
362
+ */
363
+ private buildResult;
364
+ /**
365
+ * Convenience lifecycle: starts the session and immediately finalizes it.
366
+ *
367
+ * This is primarily useful for tests and for callers that drive the session entirely through
368
+ * the injected handlers (which fire between {@link Start} and {@link Stop}). Most real callers
369
+ * will use {@link Start} then later {@link Stop} when the user hangs up or the session times
370
+ * out. If start fails, a failed result is returned with the error.
371
+ *
372
+ * @returns The final {@link RealtimeSessionResult}.
373
+ */
374
+ Run(): Promise<RealtimeSessionResult>;
375
+ /**
376
+ * Logs an error via the injected logger (if any), prefixed with the failing operation.
377
+ *
378
+ * @param error The thrown error or message.
379
+ * @param operation A short description of what was being attempted.
380
+ */
381
+ private logError;
382
+ }
383
+ //# sourceMappingURL=realtime-session-runner.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"realtime-session-runner.d.ts","sourceRoot":"","sources":["../../src/realtime/realtime-session-runner.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;GAoBG;AAEH,OAAO,EACH,iBAAiB,EAEjB,qBAAqB,EACrB,kBAAkB,EAClB,gBAAgB,EAChB,aAAa,EACb,sBAAsB,EAGzB,MAAM,oBAAoB,CAAC;AAC5B,OAAO,EAEH,6BAA6B,EAC7B,uBAAuB,EACvB,eAAe,EACf,mBAAmB,EACnB,oBAAoB,EACpB,mBAAmB,EACtB,MAAM,wBAAwB,CAAC;AAKhC,OAAO,EACH,6BAA6B,EAC7B,uBAAuB,EACvB,eAAe,EACf,mBAAmB,EACnB,oBAAoB,EACpB,mBAAmB,EACtB,CAAC;AAEF;;;;;GAKG;AACH,MAAM,WAAW,yBAAyB;IACtC;;;;OAIG;IACH,KAAK,EAAE,iBAAiB,CAAC;IAEzB;;;;;OAKG;IACH,aAAa,EAAE,qBAAqB,CAAC;IAErC;;;;OAIG;IACH,UAAU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