@memberjunction/ai-agents 6.2.0-edge.2 → 6.2.0-edge.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +6 -0
- package/dist/AgentDecisionService.d.ts +8 -1
- package/dist/AgentDecisionService.d.ts.map +1 -1
- package/dist/AgentDecisionService.js +4 -0
- package/dist/AgentDecisionService.js.map +1 -1
- package/dist/AgentRunner.d.ts +51 -2
- package/dist/AgentRunner.d.ts.map +1 -1
- package/dist/AgentRunner.js +121 -23
- package/dist/AgentRunner.js.map +1 -1
- package/dist/ConversationCompactionManager.d.ts +9 -1
- package/dist/ConversationCompactionManager.d.ts.map +1 -1
- package/dist/ConversationCompactionManager.js +6 -3
- package/dist/ConversationCompactionManager.js.map +1 -1
- package/dist/ConversationToolManager.d.ts +13 -2
- package/dist/ConversationToolManager.d.ts.map +1 -1
- package/dist/ConversationToolManager.js +19 -3
- package/dist/ConversationToolManager.js.map +1 -1
- package/dist/KnowledgeAgent.d.ts.map +1 -1
- package/dist/KnowledgeAgent.js +6 -1
- package/dist/KnowledgeAgent.js.map +1 -1
- package/dist/MJAIAgentRequestEntityServer.d.ts +6 -0
- package/dist/MJAIAgentRequestEntityServer.d.ts.map +1 -1
- package/dist/MJAIAgentRequestEntityServer.js +26 -1
- package/dist/MJAIAgentRequestEntityServer.js.map +1 -1
- package/dist/PayloadFeedbackManager.d.ts +3 -0
- package/dist/PayloadFeedbackManager.d.ts.map +1 -1
- package/dist/PayloadFeedbackManager.js +2 -1
- package/dist/PayloadFeedbackManager.js.map +1 -1
- package/dist/agent-run-watchdog.d.ts +65 -5
- package/dist/agent-run-watchdog.d.ts.map +1 -1
- package/dist/agent-run-watchdog.js +143 -28
- package/dist/agent-run-watchdog.js.map +1 -1
- package/dist/agent-types/loop-agent-prompt-params.d.ts +7 -0
- package/dist/agent-types/loop-agent-prompt-params.d.ts.map +1 -1
- package/dist/agent-types/loop-agent-prompt-params.js +1 -0
- package/dist/agent-types/loop-agent-prompt-params.js.map +1 -1
- package/dist/agent-types/loop-agent-type.d.ts +20 -0
- package/dist/agent-types/loop-agent-type.d.ts.map +1 -1
- package/dist/agent-types/loop-agent-type.js +73 -2
- package/dist/agent-types/loop-agent-type.js.map +1 -1
- package/dist/artifact-tools/SearchResultSetToolLibrary.js +4 -4
- package/dist/artifact-tools/SearchResultSetToolLibrary.js.map +1 -1
- package/dist/base-agent.d.ts +310 -26
- package/dist/base-agent.d.ts.map +1 -1
- package/dist/base-agent.js +867 -244
- package/dist/base-agent.js.map +1 -1
- package/dist/client-tool-results.d.ts +45 -0
- package/dist/client-tool-results.d.ts.map +1 -0
- package/dist/client-tool-results.js +94 -0
- package/dist/client-tool-results.js.map +1 -0
- package/dist/index.d.ts +9 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +9 -0
- package/dist/index.js.map +1 -1
- package/dist/native-tools/action-tool-builder.d.ts +14 -0
- package/dist/native-tools/action-tool-builder.d.ts.map +1 -1
- package/dist/native-tools/action-tool-builder.js +62 -7
- package/dist/native-tools/action-tool-builder.js.map +1 -1
- package/dist/native-tools/control-tools.d.ts +17 -1
- package/dist/native-tools/control-tools.d.ts.map +1 -1
- package/dist/native-tools/control-tools.js +40 -3
- package/dist/native-tools/control-tools.js.map +1 -1
- package/dist/prior-turn-tool-result-cache.d.ts +31 -12
- package/dist/prior-turn-tool-result-cache.d.ts.map +1 -1
- package/dist/prior-turn-tool-result-cache.js +59 -16
- package/dist/prior-turn-tool-result-cache.js.map +1 -1
- package/dist/realtime/bridge-host-params.d.ts +22 -0
- package/dist/realtime/bridge-host-params.d.ts.map +1 -0
- package/dist/realtime/bridge-host-params.js +53 -0
- package/dist/realtime/bridge-host-params.js.map +1 -0
- package/dist/realtime/bridge-realtime-session-factory.d.ts +63 -3
- package/dist/realtime/bridge-realtime-session-factory.d.ts.map +1 -1
- package/dist/realtime/bridge-realtime-session-factory.js +83 -22
- package/dist/realtime/bridge-realtime-session-factory.js.map +1 -1
- package/dist/realtime/bridge-realtime-usage-recorder.d.ts +81 -0
- package/dist/realtime/bridge-realtime-usage-recorder.d.ts.map +1 -0
- package/dist/realtime/bridge-realtime-usage-recorder.js +194 -0
- package/dist/realtime/bridge-realtime-usage-recorder.js.map +1 -0
- package/dist/realtime/bridge-session-transcript-sink.d.ts +37 -0
- package/dist/realtime/bridge-session-transcript-sink.d.ts.map +1 -0
- package/dist/realtime/bridge-session-transcript-sink.js +58 -0
- package/dist/realtime/bridge-session-transcript-sink.js.map +1 -0
- package/dist/realtime/client-only-channel-server.d.ts +83 -0
- package/dist/realtime/client-only-channel-server.d.ts.map +1 -0
- package/dist/realtime/client-only-channel-server.js +107 -0
- package/dist/realtime/client-only-channel-server.js.map +1 -0
- package/dist/realtime/identity-verification-channel-server.d.ts +50 -0
- package/dist/realtime/identity-verification-channel-server.d.ts.map +1 -0
- package/dist/realtime/identity-verification-channel-server.js +66 -0
- package/dist/realtime/identity-verification-channel-server.js.map +1 -0
- package/dist/realtime/interactive-component-channel-server.d.ts +39 -0
- package/dist/realtime/interactive-component-channel-server.d.ts.map +1 -0
- package/dist/realtime/interactive-component-channel-server.js +55 -0
- package/dist/realtime/interactive-component-channel-server.js.map +1 -0
- package/dist/realtime/realtime-avatar-resolution.d.ts +194 -0
- package/dist/realtime/realtime-avatar-resolution.d.ts.map +1 -0
- package/dist/realtime/realtime-avatar-resolution.js +208 -0
- package/dist/realtime/realtime-avatar-resolution.js.map +1 -0
- package/dist/realtime/realtime-channel-policy.d.ts +81 -0
- package/dist/realtime/realtime-channel-policy.d.ts.map +1 -0
- package/dist/realtime/realtime-channel-policy.js +91 -0
- package/dist/realtime/realtime-channel-policy.js.map +1 -0
- package/dist/realtime/realtime-channel-server-host.d.ts +14 -0
- package/dist/realtime/realtime-channel-server-host.d.ts.map +1 -1
- package/dist/realtime/realtime-channel-server-host.js +35 -0
- package/dist/realtime/realtime-channel-server-host.js.map +1 -1
- package/dist/realtime/realtime-client-session-service.d.ts +493 -30
- package/dist/realtime/realtime-client-session-service.d.ts.map +1 -1
- package/dist/realtime/realtime-client-session-service.js +825 -98
- package/dist/realtime/realtime-client-session-service.js.map +1 -1
- package/dist/realtime/realtime-coagent-config.d.ts +94 -15
- package/dist/realtime/realtime-coagent-config.d.ts.map +1 -1
- package/dist/realtime/realtime-coagent-config.js +109 -4
- package/dist/realtime/realtime-coagent-config.js.map +1 -1
- package/dist/realtime/realtime-coagent-resolution.d.ts +90 -0
- package/dist/realtime/realtime-coagent-resolution.d.ts.map +1 -0
- package/dist/realtime/realtime-coagent-resolution.js +186 -0
- package/dist/realtime/realtime-coagent-resolution.js.map +1 -0
- package/dist/realtime/realtime-delegation-narrator.d.ts +97 -0
- package/dist/realtime/realtime-delegation-narrator.d.ts.map +1 -0
- package/dist/realtime/realtime-delegation-narrator.js +162 -0
- package/dist/realtime/realtime-delegation-narrator.js.map +1 -0
- package/dist/realtime/realtime-recording-store.d.ts +136 -16
- package/dist/realtime/realtime-recording-store.d.ts.map +1 -1
- package/dist/realtime/realtime-recording-store.js +505 -39
- package/dist/realtime/realtime-recording-store.js.map +1 -1
- package/dist/realtime/realtime-session-runner.d.ts +2 -82
- package/dist/realtime/realtime-session-runner.d.ts.map +1 -1
- package/dist/realtime/realtime-session-runner.js +16 -191
- package/dist/realtime/realtime-session-runner.js.map +1 -1
- package/dist/realtime/realtime-vendor-resolution.d.ts +9 -0
- package/dist/realtime/realtime-vendor-resolution.d.ts.map +1 -1
- package/dist/realtime/realtime-vendor-resolution.js +16 -5
- package/dist/realtime/realtime-vendor-resolution.js.map +1 -1
- package/dist/realtime/realtime-video-output-gate.d.ts +83 -0
- package/dist/realtime/realtime-video-output-gate.d.ts.map +1 -0
- package/dist/realtime/realtime-video-output-gate.js +79 -0
- package/dist/realtime/realtime-video-output-gate.js.map +1 -0
- package/dist/rubric-evaluation-agent-runner.js +17 -8
- package/dist/rubric-evaluation-agent-runner.js.map +1 -1
- package/dist/self-check.d.ts +6 -3
- package/dist/self-check.d.ts.map +1 -1
- package/dist/self-check.js +3 -3
- package/dist/self-check.js.map +1 -1
- package/dist/tool-result-format.d.ts +14 -0
- package/dist/tool-result-format.d.ts.map +1 -1
- package/dist/tool-result-format.js.map +1 -1
- package/package.json +19 -19
|
@@ -32,11 +32,36 @@
|
|
|
32
32
|
import { UserInfo, IMetadataProvider } from '@memberjunction/core';
|
|
33
33
|
import { MJLruCache } from '@memberjunction/global';
|
|
34
34
|
import { MJActionEntityExtended } from '@memberjunction/actions-base';
|
|
35
|
-
import { BaseRealtimeModel, ChatMessage, ClientRealtimeSessionConfig, AIAPIKey, AIAPIKeyResolver, IRealtimeSession, JSONObject, RealtimeSessionParams, RealtimeToolCall, RealtimeToolDefinition } from '@memberjunction/ai';
|
|
36
|
-
import { MJAIAgentEntityExtended, MJAIModelEntityExtended, MJAIAgentRunEntityExtended, AgentExecutionProgressCallback, ExecuteAgentResult, AppContextSnapshot } from '@memberjunction/ai-core-plus';
|
|
35
|
+
import { BaseRealtimeModel, ChatMessage, ClientRealtimeSessionConfig, AIAPIKey, AIAPIKeyResolver, AICredentialScope, IRealtimeSession, JSONObject, RealtimeAvatarStatus, RealtimeSessionParams, RealtimeToolCall, RealtimeToolDefinition } from '@memberjunction/ai';
|
|
36
|
+
import { MJAIAgentEntityExtended, MJAIModelEntityExtended, MJAIAgentRunEntityExtended, AgentExecutionProgressCallback, ExecuteAgentResult, AppContextSnapshot, type IAgentSettings, type RealtimeChannelCandidate, type RealtimeSessionClientPolicy, type RealtimeSessionClientTools } from '@memberjunction/ai-core-plus';
|
|
37
|
+
import { type RealtimeAvatarResolution } from './realtime-avatar-resolution.js';
|
|
37
38
|
import { RealtimeToolBroker, RealtimeColleague, DelegateToTargetRequest, DelegatedResult, DelegatedRunArtifact, ToolExecutionResult } from './realtime-tool-broker.js';
|
|
38
39
|
import { RealtimeAllowedAgent, RealtimeCoAgentConfig, RealtimeDirectActionsConfig } from './realtime-coagent-config.js';
|
|
39
40
|
import { RealtimeVendorSelection } from './realtime-vendor-resolution.js';
|
|
41
|
+
import { type RealtimeUsageRecord } from '@memberjunction/ai-engine-base';
|
|
42
|
+
import { type RealtimeChannelRegistryRow } from './realtime-channel-policy.js';
|
|
43
|
+
/**
|
|
44
|
+
* How long closing a bridged (server-held) session waits for its model session to close before the session's runs are
|
|
45
|
+
* finalized anyway, in milliseconds. A model session reports its last usage while it closes (a Gemini avatar session,
|
|
46
|
+
* the seconds of video it has not reported yet), and the runs are priced from what was stored when they are finalized.
|
|
47
|
+
*/
|
|
48
|
+
export declare const BRIDGE_SESSION_CLOSE_WAIT_MS = 5000;
|
|
49
|
+
/**
|
|
50
|
+
* Context passed to {@link PrepareClientSessionInput.ResolveHostTools} describing the
|
|
51
|
+
* model, vendor, and driver resolved for the realtime session.
|
|
52
|
+
*/
|
|
53
|
+
export interface RealtimeHostToolsResolutionContext {
|
|
54
|
+
/** The resolved model entity ID. */
|
|
55
|
+
ModelID?: string;
|
|
56
|
+
/** The resolved model vendor ID, if known. */
|
|
57
|
+
ModelVendorID?: string;
|
|
58
|
+
/** The resolved realtime driver class name (e.g. 'OpenAILiveRealtime'). */
|
|
59
|
+
DriverClass?: string;
|
|
60
|
+
}
|
|
61
|
+
/**
|
|
62
|
+
* Resolver callback signature for dynamically resolving host tools prior to session start.
|
|
63
|
+
*/
|
|
64
|
+
export type RealtimeHostToolsResolver = (resolved: RealtimeHostToolsResolutionContext) => RealtimeToolDefinition[] | undefined;
|
|
40
65
|
/**
|
|
41
66
|
* Input for {@link RealtimeClientSessionService.PrepareClientSession}.
|
|
42
67
|
*
|
|
@@ -56,6 +81,13 @@ export interface PrepareClientSessionInput {
|
|
|
56
81
|
* client-initiated session today.
|
|
57
82
|
*/
|
|
58
83
|
APIKeys?: AIAPIKey[];
|
|
84
|
+
/**
|
|
85
|
+
* The run's credential scope (`ExecuteAgentParams.CredentialScope`). `'RuntimeOnly'` makes
|
|
86
|
+
* {@link PrepareClientSessionInput.APIKeys} the whole key chain: a vendor they do not key is not
|
|
87
|
+
* selected, and the {@link RealtimeClientSessionService.getAPIKeyForDriver} seam (by default the
|
|
88
|
+
* platform's environment key) is never consulted. Absent ⇒ `'Any'`.
|
|
89
|
+
*/
|
|
90
|
+
CredentialScope?: AICredentialScope;
|
|
59
91
|
/** The Realtime Co-Agent entity. Provide this OR {@link PrepareClientSessionInput.CoAgentID}. */
|
|
60
92
|
CoAgent?: MJAIAgentEntityExtended;
|
|
61
93
|
/** The Realtime Co-Agent id (resolved from cached metadata). Provide this OR {@link PrepareClientSessionInput.CoAgent}. */
|
|
@@ -73,6 +105,15 @@ export interface PrepareClientSessionInput {
|
|
|
73
105
|
* app layer (the cascade rests on type/co-agent/target/override only).
|
|
74
106
|
*/
|
|
75
107
|
ApplicationID?: string;
|
|
108
|
+
/**
|
|
109
|
+
* The interactive channels the BROWSER reports it could mount in this session (key, code defaults,
|
|
110
|
+
* native tools, host-declared?). When present the service scopes them — registry kill switch, agent
|
|
111
|
+
* and app configuration (`realtime.channels`) — narrows/completes {@link ExtraTools} to match, and
|
|
112
|
+
* returns the resolved {@link RealtimeClientSessionPrepResult.ClientPolicy} for the browser to
|
|
113
|
+
* activate. Absent ⇒ no scoping (a client that predates channel scoping, or a host that mints
|
|
114
|
+
* through its own proxy): {@link ExtraTools} is used exactly as declared.
|
|
115
|
+
*/
|
|
116
|
+
ChannelCandidates?: RealtimeChannelCandidate[];
|
|
76
117
|
/**
|
|
77
118
|
* Optional app-context snapshot — where the user is, what they see, and the live capability
|
|
78
119
|
* manifest — injected into the companion system prompt at mint (the session-start half of the
|
|
@@ -82,6 +123,23 @@ export interface PrepareClientSessionInput {
|
|
|
82
123
|
AppContext?: AppContextSnapshot;
|
|
83
124
|
/** Prior conversation history to seed the model's context. Optional. */
|
|
84
125
|
ConversationMessages?: ChatMessage[];
|
|
126
|
+
/**
|
|
127
|
+
* Tools the HOST (not the co-agent runtime) declares AND executes — e.g. a phone call's `transfer_call`,
|
|
128
|
+
* `send_dtmf` and `end_call`. They are added to the session's tool set but, unlike {@link ExtraTools}, are
|
|
129
|
+
* NOT described as interactive-surface tools in the prompt. The host executes them through the runtime's
|
|
130
|
+
* local tool handler ({@link BridgeRealtimeRuntime.SetLocalToolHandler}).
|
|
131
|
+
*/
|
|
132
|
+
HostTools?: RealtimeToolDefinition[];
|
|
133
|
+
/**
|
|
134
|
+
* Optional callback that allows the host to resolve host tools dynamically based on
|
|
135
|
+
* the model, vendor, and driver actually resolved for the session, before session opening.
|
|
136
|
+
*/
|
|
137
|
+
ResolveHostTools?: RealtimeHostToolsResolver;
|
|
138
|
+
/**
|
|
139
|
+
* Host-authored instructions appended to the system prompt (e.g. "this is an audio-only phone call …",
|
|
140
|
+
* the caller's number and verification status). Empty/absent adds nothing.
|
|
141
|
+
*/
|
|
142
|
+
HostFraming?: string;
|
|
85
143
|
/**
|
|
86
144
|
* Pre-formatted, role-tagged transcript lines (`User: …` / `Assistant: …`, newline-separated)
|
|
87
145
|
* from the caller's PRIOR session leg(s) when this session RESUMES one (`lastSessionId`).
|
|
@@ -132,6 +190,34 @@ export interface PrepareClientSessionInput {
|
|
|
132
190
|
* addressing GATE is the bridge's `RegexAddressedMatcher`. Ignored unless {@link DisableAutoResponse}.
|
|
133
191
|
*/
|
|
134
192
|
SelfNames?: string[];
|
|
193
|
+
/**
|
|
194
|
+
* `'room'` for a server-side (bridged) session whose host publishes the agent's avatar into a meeting room: the
|
|
195
|
+
* avatar request resolved for the voiced agent carries it (`RealtimeAvatarSettings.Delivery`), so a driver may
|
|
196
|
+
* render it there. Absent: a server-side session asks for no video (the driver logs `bridged`), and its avatar
|
|
197
|
+
* status says `bridged` also when the prep asked the driver for none, or the driver reported nothing. Ignored on a
|
|
198
|
+
* {@link PhoneCall}.
|
|
199
|
+
*/
|
|
200
|
+
AvatarDelivery?: 'room';
|
|
201
|
+
/**
|
|
202
|
+
* `true` for a server-side session (a bridged meeting or a phone call), which can show the agent's avatar only when its
|
|
203
|
+
* host publishes it into a room ({@link AvatarDelivery} `'room'`). Without that, the default model walk's video
|
|
204
|
+
* preference skips the session: no model would bring it an avatar. Absent: a browser (client-direct) session.
|
|
205
|
+
*/
|
|
206
|
+
ServerSide?: boolean;
|
|
207
|
+
/**
|
|
208
|
+
* `true` when the session is a phone call: a carrier call (Twilio, Vonage, RingCentral), or a call that reaches a
|
|
209
|
+
* LiveKit room through SIP. The caller hears the agent and sees nothing, so the session asks the driver for no avatar,
|
|
210
|
+
* even in a room that could show one, and reports why (`phone`); the avatar persona's voice is kept, and the default
|
|
211
|
+
* model walk prefers no avatar model. Absent: not a phone call.
|
|
212
|
+
*/
|
|
213
|
+
PhoneCall?: boolean;
|
|
214
|
+
/**
|
|
215
|
+
* `false` when the app showing a browser session shows no agent video: none of its channels shows it (the embeddable
|
|
216
|
+
* widgets and the mobile app today; the mint's `showsAgentVideo` argument). The session then asks the driver for no
|
|
217
|
+
* avatar and reports why (`host`), the avatar persona's voice is kept, and the default model walk prefers no avatar
|
|
218
|
+
* model. Absent or `true`: the app may show it, and the browser decides at connect (`host` or `browser` then).
|
|
219
|
+
*/
|
|
220
|
+
ShowsAgentVideo?: boolean;
|
|
135
221
|
/**
|
|
136
222
|
* Optional server-authoritative hard ceiling on the session's wall-clock duration, in seconds.
|
|
137
223
|
* Threaded into {@link RealtimeSessionParams.MaxSessionSeconds} so a driver can bound the
|
|
@@ -140,6 +226,11 @@ export interface PrepareClientSessionInput {
|
|
|
140
226
|
* deployments (a public web-widget guest's `VoiceMaxSessionMinutes`); omitted otherwise.
|
|
141
227
|
*/
|
|
142
228
|
MaxSessionSeconds?: number;
|
|
229
|
+
/**
|
|
230
|
+
* When `true`, no direct actions are projected for the session, so the model gets none and the
|
|
231
|
+
* session's relays run none. Set for callers that may not run actions directly.
|
|
232
|
+
*/
|
|
233
|
+
ExcludeDirectActions?: boolean;
|
|
143
234
|
}
|
|
144
235
|
/**
|
|
145
236
|
* Result of {@link RealtimeClientSessionService.PrepareClientSession}.
|
|
@@ -214,6 +305,12 @@ export interface RealtimeClientSessionPrepResult {
|
|
|
214
305
|
* (client drivers apply provider voice settings client-side in the client-direct topology).
|
|
215
306
|
*/
|
|
216
307
|
EffectiveConfig?: RealtimeCoAgentConfig;
|
|
308
|
+
/**
|
|
309
|
+
* The resolved channel scope and client-tool tiers for the browser to activate — present only when
|
|
310
|
+
* the input carried {@link PrepareClientSessionInput.ChannelCandidates}. The transport layer returns
|
|
311
|
+
* it in the mint result and persists the in-session channel keys on the session.
|
|
312
|
+
*/
|
|
313
|
+
ClientPolicy?: RealtimeSessionClientPolicy;
|
|
217
314
|
/**
|
|
218
315
|
* The effective narration pace (`realtime.narration.paceMs`) — minimum gap in ms between
|
|
219
316
|
* spoken progress updates. `undefined` when not configured (clients/runners use their
|
|
@@ -222,6 +319,12 @@ export interface RealtimeClientSessionPrepResult {
|
|
|
222
319
|
* `RealtimeSessionRunnerDeps.NarrationPaceMs`.
|
|
223
320
|
*/
|
|
224
321
|
NarrationPaceMs?: number;
|
|
322
|
+
/**
|
|
323
|
+
* The live avatar the session asked for and whether it shows: granted, or audio only and why
|
|
324
|
+
* ({@link ResolveRealtimeAvatarStatus}). Absent when the voiced agent asked for no avatar (its video setting is
|
|
325
|
+
* off). The transport layer returns it in the mint result, so the call can say why it shows no avatar.
|
|
326
|
+
*/
|
|
327
|
+
AvatarStatus?: RealtimeAvatarStatus;
|
|
225
328
|
}
|
|
226
329
|
/**
|
|
227
330
|
* The resolved co-agent system prompt text plus the id of the prompt it came from, returned by
|
|
@@ -242,9 +345,15 @@ export interface CoAgentSystemPromptResolution {
|
|
|
242
345
|
export interface ExecuteRelayedToolInput {
|
|
243
346
|
/** The shared session id grouping this voice session's runs. */
|
|
244
347
|
AgentSessionID: string;
|
|
245
|
-
/**
|
|
348
|
+
/**
|
|
349
|
+
* The id of the (co-agent) run that owns this session, used as the delegated run's parent. Optional.
|
|
350
|
+
* The caller passes it only when it is a run of this session.
|
|
351
|
+
*/
|
|
246
352
|
ParentRunID?: string;
|
|
247
|
-
/**
|
|
353
|
+
/**
|
|
354
|
+
* The top-level (lead) target agent id for `invoke-target-agent` delegation. The caller must have
|
|
355
|
+
* checked that the acting user may run this agent.
|
|
356
|
+
*/
|
|
248
357
|
TargetAgentID: string;
|
|
249
358
|
/**
|
|
250
359
|
* The session's effective allowed delegation targets (the union-accumulated set from the config
|
|
@@ -256,7 +365,8 @@ export interface ExecuteRelayedToolInput {
|
|
|
256
365
|
/**
|
|
257
366
|
* Optional direct actions configuration for this session, derived once during session prep
|
|
258
367
|
* (cascade: co-agent + runtime overrides + target + app settings). When present, direct action
|
|
259
|
-
* enforcement checks this configuration instead of recomputing from target alone.
|
|
368
|
+
* enforcement checks this configuration instead of recomputing from target alone. Pass it only
|
|
369
|
+
* from server-side state, never from a client-writable source such as a session's `Config`.
|
|
260
370
|
*/
|
|
261
371
|
DirectActions?: RealtimeDirectActionsConfig;
|
|
262
372
|
/** The tool call the browser relayed from the provider. */
|
|
@@ -277,9 +387,20 @@ export interface ExecuteRelayedToolInput {
|
|
|
277
387
|
* Optional id of a previously-paused delegated run (Status `AwaitingFeedback`) to RESUME instead
|
|
278
388
|
* of starting a fresh run. When set, {@link delegateToTarget} passes it as `lastRunId` (with
|
|
279
389
|
* `autoPopulateLastRunPayload`) to {@link AgentRunner.RunAgent}, so the user's answer continues
|
|
280
|
-
* the SAME interactive run (e.g. confirming a Query Builder task graph).
|
|
390
|
+
* the SAME interactive run (e.g. confirming a Query Builder task graph). The caller passes it only
|
|
391
|
+
* when it is a run of this session.
|
|
281
392
|
*/
|
|
282
393
|
ResumeRunID?: string;
|
|
394
|
+
/**
|
|
395
|
+
* The browser's GraphQL session id. Lets the delegated run execute client tools the surface
|
|
396
|
+
* registered, because the client-tool request channel is keyed on this id.
|
|
397
|
+
*/
|
|
398
|
+
BrowserSessionID?: string;
|
|
399
|
+
/**
|
|
400
|
+
* The app-context snapshot the browser sent at session start, so the delegated run's prompt sees
|
|
401
|
+
* surface context and tools. It does not follow later navigation in the browser.
|
|
402
|
+
*/
|
|
403
|
+
AppContext?: AppContextSnapshot;
|
|
283
404
|
/**
|
|
284
405
|
* The id of the human this delegation is FOR, threaded into the delegated run's `userId`.
|
|
285
406
|
*
|
|
@@ -335,23 +456,85 @@ export interface RealtimeSessionParamsPrep {
|
|
|
335
456
|
EffectiveConfig?: RealtimeCoAgentConfig;
|
|
336
457
|
/** The assembled session params (TARGET-identity prompt, stable tools incl. invoke-target, voice, memory). */
|
|
337
458
|
SessionParams?: RealtimeSessionParams;
|
|
459
|
+
/** The resolved channel scope + client-tool tiers, when the input carried channel candidates. */
|
|
460
|
+
ClientPolicy?: RealtimeSessionClientPolicy;
|
|
461
|
+
/**
|
|
462
|
+
* The avatar the session asks for, or why there is none; empty when the voiced agent asked for none. The session
|
|
463
|
+
* params carry the request itself (`SessionParams.Avatar`); this keeps the reason for the call's avatar status.
|
|
464
|
+
*/
|
|
465
|
+
AvatarResolution?: RealtimeAvatarResolution;
|
|
338
466
|
}
|
|
339
467
|
/**
|
|
340
468
|
* The runtime handle returned by {@link RealtimeClientSessionService.WireBridgeRealtimeSession} — the
|
|
341
469
|
* server long-lived (bridged) counterpart to what `PrepareClientSession` returns for the browser. The
|
|
342
470
|
* bridge holds this for the life of the session: the observability run ids (for nesting + correlation)
|
|
343
|
-
* and an **idempotent** {@link Finalize}
|
|
344
|
-
*
|
|
345
|
-
*
|
|
471
|
+
* and an **idempotent** {@link Finalize} that keeps the co-agent run + prompt run from dangling in
|
|
472
|
+
* `Running`. It runs when the session's `Close()` is invoked, once the model session has closed, and when
|
|
473
|
+
* the connection drops; whichever comes first runs it, and a later call waits for that run.
|
|
346
474
|
*/
|
|
347
475
|
export interface BridgeRealtimeRuntime {
|
|
348
476
|
/** The `MJ: AI Agent Runs` row id created for this voice session (delegated runs nest under it). */
|
|
349
477
|
CoAgentRunID?: string;
|
|
350
478
|
/** The `MJ: AI Prompt Runs` row id for the session's system prompt. */
|
|
351
479
|
PromptRunID?: string;
|
|
352
|
-
/**
|
|
353
|
-
|
|
480
|
+
/**
|
|
481
|
+
* Writes the session's last usage, then finalizes the co-agent + prompt run; usage reported afterwards is not
|
|
482
|
+
* stored. Closing the session runs it after the model session closed, so what the session reports while closing
|
|
483
|
+
* is kept; calling it before `Close()` would drop that report. Idempotent, so every teardown path may call it: it
|
|
484
|
+
* runs once, and every call returns the first call's promise and resolves only once the runs are finalized. The
|
|
485
|
+
* first call decides the outcome: its `success` and `errorMessage` stand.
|
|
486
|
+
*
|
|
487
|
+
* The session's `Close()` finalizes with `success` true, so a host whose bridge start failed calls
|
|
488
|
+
* `Finalize(false, error)` BEFORE it closes the session: the run, its prompt run and its step then read `Failed`
|
|
489
|
+
* with the start's error, and the close finalizes nothing more.
|
|
490
|
+
*
|
|
491
|
+
* @param success `true` → `Completed`, `false` → `Failed`.
|
|
492
|
+
* @param errorMessage Why the session failed, stamped on the failed run, prompt run and step. Ignored on success.
|
|
493
|
+
*/
|
|
494
|
+
Finalize: (success: boolean, errorMessage?: string) => Promise<void>;
|
|
495
|
+
/**
|
|
496
|
+
* Aborts every delegated run currently in flight for this session (and drops pending narration). This is the
|
|
497
|
+
* EXPLICIT cancel — on a phone it backs the `cancel_pending_work` tool — and is deliberately NOT what a
|
|
498
|
+
* barge-in does (see {@link CancelPendingNarration}). Returns how many were aborted (0 when nothing was
|
|
499
|
+
* running; never throws).
|
|
500
|
+
*/
|
|
501
|
+
CancelInFlightDelegations: () => number;
|
|
502
|
+
/**
|
|
503
|
+
* Drops any queued spoken progress update without touching the delegated work — what a barge-in does. The
|
|
504
|
+
* caller took the floor, so a pending "still working on it" is stale, but the jobs they asked for keep
|
|
505
|
+
* running. Never throws.
|
|
506
|
+
*/
|
|
507
|
+
CancelPendingNarration: () => void;
|
|
508
|
+
/**
|
|
509
|
+
* Installs (or clears, with `undefined`) the host's local tool handler. A tool call whose name the handler
|
|
510
|
+
* {@link BridgeLocalToolHandler.Handles} is executed by the host instead of the shared delegation path.
|
|
511
|
+
*/
|
|
512
|
+
SetLocalToolHandler: (handler: BridgeLocalToolHandler | undefined) => void;
|
|
513
|
+
/**
|
|
514
|
+
* Whether the agent watches LiveKit meetings (`realtime.video.watchMeetings` in its effective configuration, which
|
|
515
|
+
* includes the voiced agent's own). The room coordinator reads it, with whether the session takes video, to decide
|
|
516
|
+
* whether the bot reads the cameras and screens people allow.
|
|
517
|
+
*/
|
|
518
|
+
WatchesMeetingVideo: boolean;
|
|
519
|
+
}
|
|
520
|
+
/**
|
|
521
|
+
* Executes tools the host declared through {@link PrepareClientSessionInput.HostTools}. Bound after the session
|
|
522
|
+
* is wired because the object that can act on them (a phone call's bridge) does not exist until the bridge
|
|
523
|
+
* engine has started.
|
|
524
|
+
*/
|
|
525
|
+
export interface BridgeLocalToolHandler {
|
|
526
|
+
/** Whether this handler owns `toolName`. */
|
|
527
|
+
Handles(toolName: string): boolean;
|
|
528
|
+
/** Runs one call; the returned string is the JSON handed back to the model. Never needs to catch — errors are reported to the model. */
|
|
529
|
+
Execute(call: RealtimeToolCall): Promise<string>;
|
|
354
530
|
}
|
|
531
|
+
/**
|
|
532
|
+
* Returns the runtime wired onto a bridged realtime session by
|
|
533
|
+
* {@link RealtimeClientSessionService.WireBridgeRealtimeSession}, or `undefined` for a session that was never
|
|
534
|
+
* wired. Lets a host that only holds the {@link IRealtimeSession} (the telephony services) cancel delegations on
|
|
535
|
+
* barge-in and install its local tool handler.
|
|
536
|
+
*/
|
|
537
|
+
export declare function GetBridgeRealtimeRuntime(session: IRealtimeSession): BridgeRealtimeRuntime | undefined;
|
|
355
538
|
/**
|
|
356
539
|
* Outcome of resolving the realtime model for a session: either a usable {@link RealtimeModelResolution}
|
|
357
540
|
* or a specific, human-readable failure reason (used for explicit preferred-model failures, where the
|
|
@@ -505,6 +688,11 @@ export declare class RealtimeClientSessionService {
|
|
|
505
688
|
* @returns The prep result (Success + ClientConfig/SessionParams, or Success: false + ErrorMessage).
|
|
506
689
|
*/
|
|
507
690
|
PrepareClientSession(input: PrepareClientSessionInput, contextUser: UserInfo, provider: IMetadataProvider): Promise<RealtimeClientSessionPrepResult>;
|
|
691
|
+
/**
|
|
692
|
+
* The call's avatar status once the driver has minted the session (see {@link ResolveRealtimeAvatarStatus}), with one
|
|
693
|
+
* log line saying whether the avatar shows. `undefined`, and no line, when the session asked for no avatar.
|
|
694
|
+
*/
|
|
695
|
+
private resolveMintedAvatarStatus;
|
|
508
696
|
/**
|
|
509
697
|
* Wires a **server long-lived (bridged)** realtime session onto the SAME core machinery the
|
|
510
698
|
* client-direct path uses — so a LiveKit (or future Zoom/Teams) agent does real work and is tracked
|
|
@@ -515,12 +703,22 @@ export declare class RealtimeClientSessionService {
|
|
|
515
703
|
* under the co-agent run, supports barge-in cancel + paused-run resume — all of it, for free).
|
|
516
704
|
*
|
|
517
705
|
* Responsibilities, in order:
|
|
706
|
+
* 0. Report the avatar status the driver had nothing to say about: a prep that asked the driver for no avatar (a
|
|
707
|
+
* phone call, no face for the model's vendor, an unknown avatar, a Video/Output row that turns video off) leaves
|
|
708
|
+
* the driver nothing to report, and a driver that renders no avatar ignores a request, so the session's
|
|
709
|
+
* `AvatarStatus` says why instead of saying nothing ({@link ResolveBridgedAvatarStatus}).
|
|
518
710
|
* 1. Create the co-agent observability run (+ prompt run + step) so the voice session shows up in the
|
|
519
711
|
* agent-run timeline and delegated runs nest under it (best-effort; a failure just omits the ids).
|
|
520
|
-
* 2.
|
|
521
|
-
*
|
|
712
|
+
* 2. Record the session's usage on the co-agent prompt run, as client-direct calls do: `session.OnUsage` →
|
|
713
|
+
* {@link BridgeRealtimeUsageRecorder} → {@link AccumulatePromptRunUsage}, every 10 s and once more at finalize.
|
|
714
|
+
* 3. Wire `session.OnToolCall` → `ExecuteRelayedTool` → `session.SendToolResult`.
|
|
715
|
+
* 4. Guarantee finalize-once: wrap `session.Close()` and listen for an unexpected drop (`OnClose`), both
|
|
522
716
|
* routed through one idempotent finalizer. The bridge teardown calls `Close()`, so the run finalizes
|
|
523
|
-
* on graceful end; a dropped socket finalizes via `OnClose
|
|
717
|
+
* on graceful end; a dropped socket finalizes via `OnClose`, and a `Close()` after it waits for that
|
|
718
|
+
* finalize. The wrapped `Close()` closes the model session first (waiting up to
|
|
719
|
+
* {@link BRIDGE_SESSION_CLOSE_WAIT_MS}), so the usage it reports while closing is recorded; the
|
|
720
|
+
* finalizer then writes the session's last usage before it finalizes the runs, so the prompt run is
|
|
721
|
+
* priced from its final counts.
|
|
524
722
|
*
|
|
525
723
|
* @param session The live realtime session the bridge owns (from `model.StartSession`).
|
|
526
724
|
* @param input The same prep input used to build the session (carries AgentSessionID, TargetAgentID, …).
|
|
@@ -530,6 +728,47 @@ export declare class RealtimeClientSessionService {
|
|
|
530
728
|
* @returns A {@link BridgeRealtimeRuntime} the bridge holds for the session lifetime.
|
|
531
729
|
*/
|
|
532
730
|
WireBridgeRealtimeSession(session: IRealtimeSession, input: PrepareClientSessionInput, prep: RealtimeSessionParamsPrep, contextUser: UserInfo, provider: IMetadataProvider): Promise<BridgeRealtimeRuntime>;
|
|
731
|
+
/**
|
|
732
|
+
* Gives a bridged session the avatar status its driver had nothing to say about ({@link ResolveBridgedAvatarStatus}),
|
|
733
|
+
* with one log line: a prep that asked the driver for no avatar (a phone call, no face for the model's vendor, an
|
|
734
|
+
* unknown avatar, a Video/Output row that turns video off) leaves the driver nothing to report, and a driver that
|
|
735
|
+
* renders no avatar ignores a request and reports nothing. A host reads it like any driver's status (the LiveKit room
|
|
736
|
+
* puts it on the agent's bot, so the room shows its notice). A status the driver reported stands.
|
|
737
|
+
*/
|
|
738
|
+
private reportBridgedAvatarStatus;
|
|
739
|
+
/**
|
|
740
|
+
* Records a bridged session's usage on its co-agent prompt run. The recorder is the session's only `OnUsage`
|
|
741
|
+
* subscriber: drivers keep one usage handler. Without a prompt run there is nowhere to record, so nothing subscribes
|
|
742
|
+
* and one line is logged, as the client-direct relay logs a dropped delta.
|
|
743
|
+
*/
|
|
744
|
+
private wireBridgeUsage;
|
|
745
|
+
/**
|
|
746
|
+
* The bridged session's finalizer. It closes the usage recorder first (no more updates; the unwritten usage is
|
|
747
|
+
* written), so the prompt run's cost, computed when finalize stamps `CompletedAt`, covers the whole session. On a
|
|
748
|
+
* graceful close it runs after the model session closed (see `finalizeOnBridgeClose`).
|
|
749
|
+
*
|
|
750
|
+
* It runs once, and every call returns the first call's promise: whichever path calls second (a `Close()` after a
|
|
751
|
+
* dropped connection's `OnClose` started the finalize) resolves only once the runs are finalized and priced. The
|
|
752
|
+
* first call decides the outcome (see {@link BridgeRealtimeRuntime.Finalize}).
|
|
753
|
+
*/
|
|
754
|
+
private createBridgeFinalizer;
|
|
755
|
+
/** Tool calls → the host's local handler or the shared delegation entry point, then the result back to the model. */
|
|
756
|
+
private wireBridgeToolCalls;
|
|
757
|
+
/**
|
|
758
|
+
* Finalizes on graceful teardown (the bridge calls `Close()`) and on an unexpected drop. Both go through the one
|
|
759
|
+
* finalizer, which runs once: a double fire finalizes once, and a `Close()` after a drop waits for the finalize the
|
|
760
|
+
* drop started, so it resolves only once the runs are finalized. Both finalize as completed: a host whose bridge
|
|
761
|
+
* start failed calls {@link BridgeRealtimeRuntime.Finalize} with `false` and the start's error before it closes the
|
|
762
|
+
* session.
|
|
763
|
+
*
|
|
764
|
+
* `Close()` closes the model session before it finalizes: a session reports its last usage while it closes (a
|
|
765
|
+
* Gemini avatar session, the seconds of video not reported yet), and the finalizer stores only what was reported
|
|
766
|
+
* before it ran. The close is waited for up to {@link BRIDGE_SESSION_CLOSE_WAIT_MS}. The runs are finalized whether
|
|
767
|
+
* the close finished, failed or is still running; a failed close still rejects, after the finalize.
|
|
768
|
+
*
|
|
769
|
+
* @param promptRunID The session's co-agent prompt run, which names the session in a log line.
|
|
770
|
+
*/
|
|
771
|
+
private finalizeOnBridgeClose;
|
|
533
772
|
/**
|
|
534
773
|
* Degenerate {@link BridgeRealtimeRuntime} for the rare case wiring is attempted without a resolved
|
|
535
774
|
* co-agent: answer every tool call with a clear "not available" error and a no-op finalize. Keeps the
|
|
@@ -557,6 +796,57 @@ export declare class RealtimeClientSessionService {
|
|
|
557
796
|
* @returns The prep result: `Success` + co-agent/resolution/effective-config/session-params, or `Success: false`.
|
|
558
797
|
*/
|
|
559
798
|
PrepareRealtimeSessionParams(input: PrepareClientSessionInput, contextUser: UserInfo, provider: IMetadataProvider): Promise<RealtimeSessionParamsPrep>;
|
|
799
|
+
/**
|
|
800
|
+
* Applies channel scoping and the client-tool tiers to a prepare input.
|
|
801
|
+
*
|
|
802
|
+
* - **App tier into the prompt.** `Application.AgentSettings.ClientTools` is resolved to metadata
|
|
803
|
+
* and layered, through the unified {@link ResolveClientTools}, beneath the live surface's own
|
|
804
|
+
* manifest in the app-context snapshot — so the co-agent is told about tools the app declares
|
|
805
|
+
* even when the active surface did not republish them. (Only the HOST can run them; the browser
|
|
806
|
+
* reports "declared but not registered" for one it has no handler for.) The agent's static
|
|
807
|
+
* junction tools are deliberately NOT added to the voice prompt — voice prompts are
|
|
808
|
+
* token-sensitive and a tool with no browser handler is noise — but they ride the returned policy
|
|
809
|
+
* so the browser can describe them.
|
|
810
|
+
* - **Channel scoping.** When the browser reported candidates, they are scoped against the
|
|
811
|
+
* registry and the cascade's `channels` section, and the declared tools narrowed to match
|
|
812
|
+
* ({@link BuildSessionChannelPolicy}).
|
|
813
|
+
*
|
|
814
|
+
* @returns The (possibly adjusted) input, and the policy to hand back when candidates were reported.
|
|
815
|
+
*/
|
|
816
|
+
protected scopeSessionInput(input: PrepareClientSessionInput, effectiveConfig: RealtimeCoAgentConfig, contextUser: UserInfo, provider: IMetadataProvider, modelHasZeroDataRetention?: boolean): Promise<{
|
|
817
|
+
Input: PrepareClientSessionInput;
|
|
818
|
+
ClientPolicy?: RealtimeSessionClientPolicy;
|
|
819
|
+
}>;
|
|
820
|
+
/**
|
|
821
|
+
* Whether the session model's effective catalog configuration (type < model < vendor < model-vendor)
|
|
822
|
+
* declares `Privacy.ZeroDataRetention: true`. Fails closed: a model or vendor row that cannot be
|
|
823
|
+
* resolved, or a catalog lookup that throws, reads as "not declared", so an agent that REQUIRES zero
|
|
824
|
+
* data retention loses exposure rather than gaining it. Overridable seam.
|
|
825
|
+
*
|
|
826
|
+
* @param modelID The resolved `MJ: AI Models` id.
|
|
827
|
+
* @param modelVendorID The resolved model-vendor row id (the cascade's most specific layer).
|
|
828
|
+
*/
|
|
829
|
+
protected modelHasZeroDataRetention(modelID: string | undefined, modelVendorID: string | undefined): boolean;
|
|
830
|
+
/**
|
|
831
|
+
* Layers the app's client tools beneath the surface's manifest in the app-context snapshot, through
|
|
832
|
+
* the unified resolver (`session > app`, first match by name wins). Returns the SAME snapshot object
|
|
833
|
+
* when nothing changes, so callers can detect "no change" by identity.
|
|
834
|
+
*/
|
|
835
|
+
private withAppToolTier;
|
|
836
|
+
/**
|
|
837
|
+
* The server's view of the channel registry (`MJ: AI Agent Channels`), read from the request
|
|
838
|
+
* provider's cached {@link AIEngineBase} rows (already configured by the prepare). Overridable seam.
|
|
839
|
+
* Tolerant: an unloaded cache yields an empty registry (every candidate then reads as having no
|
|
840
|
+
* row), never a throw.
|
|
841
|
+
*/
|
|
842
|
+
protected readChannelRegistry(provider: IMetadataProvider): RealtimeChannelRegistryRow[];
|
|
843
|
+
/**
|
|
844
|
+
* Resolves the client-tool tiers the browser is told about at mint: the APP tier
|
|
845
|
+
* (`Application.AgentSettings.ClientTools` resolved against the tool-definition catalog) and the
|
|
846
|
+
* STATIC tier (the target agent's `MJ: AI Agent Client Tools` junction). Overridable seam; tolerant —
|
|
847
|
+
* any failure yields empty tiers and never fails the mint.
|
|
848
|
+
*/
|
|
849
|
+
protected resolveSessionClientToolTiers(applicationId: string | undefined, targetAgentId: string, contextUser: UserInfo): Promise<RealtimeSessionClientTools>;
|
|
560
850
|
/**
|
|
561
851
|
* Resolves the EFFECTIVE realtime configuration via the surface-agnostic precedence cascade:
|
|
562
852
|
* agent-TYPE `DefaultConfiguration` (base) < **co-agent** `TypeConfiguration` < **target agent**
|
|
@@ -572,6 +862,16 @@ export declare class RealtimeClientSessionService {
|
|
|
572
862
|
* @returns The normalized effective configuration (possibly empty, never `null`).
|
|
573
863
|
*/
|
|
574
864
|
protected resolveEffectiveConfig(coAgent: MJAIAgentEntityExtended, overridesJson?: string, targetAgent?: MJAIAgentEntityExtended | null, appSettingsJson?: string | null): RealtimeCoAgentConfig;
|
|
865
|
+
/**
|
|
866
|
+
* Logs one line, once per co-agent and target pair per process, when the effective configuration sets
|
|
867
|
+
* `realtime.video.provider` or `realtime.video.providers`. Both are deprecated and nothing reads them, so an author
|
|
868
|
+
* who set them would otherwise get nothing and no word of it.
|
|
869
|
+
*
|
|
870
|
+
* @param config The effective configuration.
|
|
871
|
+
* @param coAgent The co-agent.
|
|
872
|
+
* @param targetAgent The voiced agent, when there is one.
|
|
873
|
+
*/
|
|
874
|
+
private logDeprecatedVideoKeys;
|
|
575
875
|
/**
|
|
576
876
|
* Resolves the APP cascade layer JSON from `Application.AgentSettings`: the `Realtime` overrides
|
|
577
877
|
* (persona/disclosure/model) plus `RelevantAgents` mapped to the union-accumulated allowed-agent
|
|
@@ -586,6 +886,14 @@ export declare class RealtimeClientSessionService {
|
|
|
586
886
|
* @returns The canonical app-layer JSON string, or `null`.
|
|
587
887
|
*/
|
|
588
888
|
protected resolveAppRealtimeOverrides(applicationId: string | undefined, contextUser: UserInfo, provider: IMetadataProvider): Promise<string | null>;
|
|
889
|
+
/**
|
|
890
|
+
* Reads and parses an application's `AgentSettings` (one tiny by-ID read, served from the provider's
|
|
891
|
+
* RunView cache on repeat). The RAW column is parsed with {@link ParseAgentSettings} rather than read
|
|
892
|
+
* through the CodeGen-generated `AgentSettingsObject` accessor, so a field added to the settings
|
|
893
|
+
* interface works the moment the code reading it ships, before CodeGen next refreshes the copy.
|
|
894
|
+
* Tolerant — a blank id, a failed read, a missing app, or an app with no usable settings returns `null`.
|
|
895
|
+
*/
|
|
896
|
+
protected loadAppAgentSettings(applicationId: string | undefined, contextUser: UserInfo): Promise<IAgentSettings | null>;
|
|
589
897
|
/**
|
|
590
898
|
* Reads the co-agent's TYPE-level `DefaultConfiguration` from {@link AIEngine}'s cached agent
|
|
591
899
|
* types. **Overridable seam**; tolerant — an absent type or unloaded cache returns `null`.
|
|
@@ -621,6 +929,20 @@ export declare class RealtimeClientSessionService {
|
|
|
621
929
|
* `CompleteMessage`) when the save fails.
|
|
622
930
|
*/
|
|
623
931
|
private createCoAgentRun;
|
|
932
|
+
/**
|
|
933
|
+
* Keeps a voice session's co-agent run alive as far as the {@link AgentRunWatchdog} is concerned. The
|
|
934
|
+
* run spans the whole call, but no agent loop owns it, so nothing stamped its heartbeat: the watchdog
|
|
935
|
+
* force-failed every call that ran past ~5 minutes ("no liveness heartbeat … owning process presumed
|
|
936
|
+
* dead") while the call carried on. Called when the run is created and again on each persisted
|
|
937
|
+
* session heartbeat (`SessionManager`), so whichever server instance the session is talking to keeps
|
|
938
|
+
* it fresh; the watchdog drops it once it is finalized. Only a database provider can stamp heartbeats —
|
|
939
|
+
* any other provider is a no-op, as for every agent run.
|
|
940
|
+
*
|
|
941
|
+
* @param coAgentRunID The session's co-agent run id (from its `Config`), or nothing.
|
|
942
|
+
* @param provider The request-scoped metadata provider.
|
|
943
|
+
* @param contextUser The user the heartbeat writes run as.
|
|
944
|
+
*/
|
|
945
|
+
KeepCoAgentRunAlive(coAgentRunID: string | null | undefined, provider: IMetadataProvider, contextUser: UserInfo): void;
|
|
624
946
|
/**
|
|
625
947
|
* Creates the co-agent `AIPromptRun` row (Status `Running`) linked to the co-agent run via
|
|
626
948
|
* `AgentRunID` AND to the co-agent itself via `AgentID` — so the run shows up both on the
|
|
@@ -650,8 +972,22 @@ export declare class RealtimeClientSessionService {
|
|
|
650
972
|
* @param provider The request-scoped metadata provider.
|
|
651
973
|
* @param success Whether the session ended successfully (controls Completed vs Failed).
|
|
652
974
|
* @param coAgentRunStepID The co-agent run's single `MJ: AI Agent Run Steps` row id, or `null` to skip.
|
|
975
|
+
* @param errorMessage Why the session failed (for example the bridge start's error), stamped as `ErrorMessage` on each
|
|
976
|
+
* record it fails. Ignored when `success` is true. Without it the step gets a generic line and the runs none.
|
|
977
|
+
*/
|
|
978
|
+
FinalizeCoAgentRun(coAgentRunID: string | null, promptRunID: string | null, contextUser: UserInfo, provider: IMetadataProvider, success?: boolean, coAgentRunStepID?: string | null, errorMessage?: string): Promise<void>;
|
|
979
|
+
/**
|
|
980
|
+
* Copies the co-agent prompt run's tokens and cost onto the co-agent run. The realtime model's usage
|
|
981
|
+
* accumulates on the prompt run ({@link AccumulatePromptRunUsage}), which prices itself; the run's
|
|
982
|
+
* own `TotalCost` / `Total*TokensUsed` stayed 0, so everything that sums agent runs — the realtime
|
|
983
|
+
* analytics dashboard's per-session cost among them — left out the voice model entirely and showed
|
|
984
|
+
* only the delegated runs. Mirrors how an agent loop derives its run totals from its prompt runs.
|
|
985
|
+
*
|
|
986
|
+
* Applied whatever the run's status: a run the watchdog already failed, or one a shutdown cancelled,
|
|
987
|
+
* still owes its cost. Runs after {@link finalizePromptRun}, which waits for in-flight usage writes,
|
|
988
|
+
* so the copy sees the final counts. Tolerant: logs, never throws.
|
|
653
989
|
*/
|
|
654
|
-
|
|
990
|
+
private rollUpCoAgentRunUsage;
|
|
655
991
|
/**
|
|
656
992
|
* Finalizes the **co-agent observability run(s)** for an agent session that were left `Running` because
|
|
657
993
|
* the session was reaped WITHOUT a live in-memory handle — a prior-boot orphan or a cross-host teardown,
|
|
@@ -680,15 +1016,22 @@ export declare class RealtimeClientSessionService {
|
|
|
680
1016
|
* run — which is the replacement path that migration's design notes prescribe.
|
|
681
1017
|
*/
|
|
682
1018
|
private findCoAgentChildLogIds;
|
|
683
|
-
/**
|
|
1019
|
+
/**
|
|
1020
|
+
* Loads + finalizes the co-agent `AIAgentRun` if still `Running`, with `failure` as its `ErrorMessage` when it fails.
|
|
1021
|
+
* Tolerant: logs, never throws.
|
|
1022
|
+
*/
|
|
684
1023
|
private finalizeAgentRun;
|
|
685
1024
|
/**
|
|
686
1025
|
* Loads + finalizes the co-agent run's single system-prompt `MJ: AI Agent Run Steps` row if
|
|
687
|
-
* still `Running` (Status `Completed`/`Failed`, `CompletedAt`, `Success`
|
|
688
|
-
* missing/already-finalized step is a no-op; a
|
|
1026
|
+
* still `Running` (Status `Completed`/`Failed`, `CompletedAt`, `Success`; a failed step's `ErrorMessage` is
|
|
1027
|
+
* `failure`, or a generic line without one). Tolerant: a missing/already-finalized step is a no-op; a
|
|
1028
|
+
* load/save failure is logged, never thrown.
|
|
689
1029
|
*/
|
|
690
1030
|
private finalizeRunStep;
|
|
691
|
-
/**
|
|
1031
|
+
/**
|
|
1032
|
+
* Loads + finalizes the co-agent `AIPromptRun` if still `Running`, with `failure` as its `ErrorMessage` when it fails.
|
|
1033
|
+
* Tolerant: logs, never throws.
|
|
1034
|
+
*/
|
|
692
1035
|
private finalizePromptRun;
|
|
693
1036
|
/**
|
|
694
1037
|
* Appends (or replaces) one transcript turn onto the co-agent's long-lived `AIPromptRun.Messages`,
|
|
@@ -715,12 +1058,27 @@ export declare class RealtimeClientSessionService {
|
|
|
715
1058
|
* high-frequency usage checkpoint never overwrites freshly-appended transcript turns (and vice-versa).
|
|
716
1059
|
* Best-effort: load/save failures log and return `false`, never throw.
|
|
717
1060
|
*
|
|
1061
|
+
* The per-modality details add into the usage record the run keeps in `ModelSpecificResponseDetails`
|
|
1062
|
+
* (`RealtimeUsage.Input` / `.Output`, which pricing reads at finalize); every other key there is kept. The
|
|
1063
|
+
* stored output video seconds never exceed the run's elapsed time plus 30 seconds, and the stored output video
|
|
1064
|
+
* tokens never exceed 6,192 a second of that: usage is client-reported, and avatar video carries a price, per
|
|
1065
|
+
* minute or per token.
|
|
1066
|
+
*
|
|
718
1067
|
* @param promptRunID The co-agent observability prompt run.
|
|
719
1068
|
* @param inputDelta Input-token delta to add (caller clamps to >= 0).
|
|
720
1069
|
* @param outputDelta Output-token delta to add (caller clamps to >= 0).
|
|
1070
|
+
* @param details Per-modality usage to add (input and output blocks, avatar video seconds included).
|
|
721
1071
|
* @returns `true` when the accumulated usage was persisted.
|
|
722
1072
|
*/
|
|
723
|
-
AccumulatePromptRunUsage(promptRunID: string, inputDelta: number, outputDelta: number, contextUser: UserInfo, provider: IMetadataProvider): Promise<boolean>;
|
|
1073
|
+
AccumulatePromptRunUsage(promptRunID: string, inputDelta: number, outputDelta: number, contextUser: UserInfo, provider: IMetadataProvider, details?: RealtimeUsageRecord): Promise<boolean>;
|
|
1074
|
+
/**
|
|
1075
|
+
* Adds relayed per-modality usage into the run's usage record, with the output video seconds capped at the run's
|
|
1076
|
+
* elapsed time plus {@link VIDEO_SECONDS_GRACE}, and the output video tokens at that many seconds of
|
|
1077
|
+
* {@link VIDEO_TOKENS_PER_SECOND}. Details that are not a JSON object are left alone (logged).
|
|
1078
|
+
*/
|
|
1079
|
+
private mergeUsageDetails;
|
|
1080
|
+
/** One log line for each output video quantity the merge capped. */
|
|
1081
|
+
private logClampedVideo;
|
|
724
1082
|
/** Parses the prompt run's `Messages` JSON into a mutable chat-message array (tolerant: `[]` on empty/malformed). */
|
|
725
1083
|
private parsePromptRunMessages;
|
|
726
1084
|
/**
|
|
@@ -795,15 +1153,41 @@ export declare class RealtimeClientSessionService {
|
|
|
795
1153
|
* {@link resolveConfiguredModelPreference}. METADATA preferences degrade gracefully — an
|
|
796
1154
|
* unsatisfiable preference logs and FALLS THROUGH to the default (mirroring the co-agent
|
|
797
1155
|
* resolution chain's tolerant metadata steps), it never breaks calls.
|
|
798
|
-
* - Without either: the
|
|
799
|
-
* (
|
|
1156
|
+
* - Without either: the default walk ({@link resolveDefaultRealtimeModel}): for a co-agent with video on, in a session
|
|
1157
|
+
* that could show an avatar (a browser session, or a server-side one with {@link PrepareClientSessionInput.AvatarDelivery}
|
|
1158
|
+
* `'room'`), the first candidate that shows one ({@link ResolveAvatarRealtimeModel}); else the existing default via
|
|
1159
|
+
* {@link resolveRealtimeModel} (highest-PowerRank active Realtime model), with the generic
|
|
1160
|
+
* {@link noModelMessage} on failure. The two explicit choices above win over the video preference.
|
|
1161
|
+
*
|
|
1162
|
+
* On every path the chosen model's vendor follows whether the session will show an avatar (the video setting is on
|
|
1163
|
+
* and the session could show one): among the model's keyed vendors, one that renders avatars (Vertex AI for Gemini
|
|
1164
|
+
* 3.8 Live) only when it will, else one that renders none; see {@link resolveVendorAndInstantiate}.
|
|
800
1165
|
*
|
|
801
1166
|
* @param input The prepare-session input (carries the optional preferred model id).
|
|
802
1167
|
* @param coAgent The resolved co-agent (threaded to the default-resolution seam).
|
|
803
|
-
* @param effectiveConfig The resolved effective configuration (carries `modelPreference`).
|
|
1168
|
+
* @param effectiveConfig The resolved effective configuration (carries `modelPreference` and the video setting).
|
|
804
1169
|
* @returns The resolution outcome (resolution or failure reason).
|
|
805
1170
|
*/
|
|
806
1171
|
protected resolveModelForSession(input: PrepareClientSessionInput, coAgent: MJAIAgentEntityExtended, effectiveConfig?: RealtimeCoAgentConfig): Promise<RealtimeModelResolutionOutcome>;
|
|
1172
|
+
/**
|
|
1173
|
+
* The default walk. With `preferAvatar` (the co-agent's video setting is on and the session could show an avatar),
|
|
1174
|
+
* it takes the first candidate that shows one ({@link ResolveAvatarRealtimeModel}). When none does, or without it, it
|
|
1175
|
+
* takes {@link resolveRealtimeModel}'s choice; when one was preferred, one log line says the call stays audio only.
|
|
1176
|
+
*/
|
|
1177
|
+
private resolveDefaultRealtimeModel;
|
|
1178
|
+
/**
|
|
1179
|
+
* For a co-agent with video on: the first candidate that shows an avatar and supports client-direct sessions, in the
|
|
1180
|
+
* default walk's order (highest PowerRank first; a model's Active vendor rows by Priority, each with a usable key).
|
|
1181
|
+
* A candidate shows an avatar when its model's Video/Output row allows video or it has none, and its driver renders
|
|
1182
|
+
* avatars for the vendor's API name on its endpoint ({@link RealtimeModelShowsAvatar}). Every keyed vendor of a model
|
|
1183
|
+
* is tried, not only the first. **Overridable seam.**
|
|
1184
|
+
*
|
|
1185
|
+
* @param coAgent The co-agent (reserved for future per-agent model preference).
|
|
1186
|
+
* @param resolve The session's run-scoped key resolver (run keys only; see {@link resolveVendorAndInstantiate}).
|
|
1187
|
+
* @param credentialScope The session's credential scope; see {@link resolveVendorAndInstantiate}.
|
|
1188
|
+
* @returns The resolution, or `null` when no candidate shows an avatar.
|
|
1189
|
+
*/
|
|
1190
|
+
protected ResolveAvatarRealtimeModel(coAgent: MJAIAgentEntityExtended, resolve?: AIAPIKeyResolver, credentialScope?: AICredentialScope): RealtimeModelResolution | null;
|
|
807
1191
|
/**
|
|
808
1192
|
* The session's run-scoped keys as a resolver: the key for a driver class when the run carries
|
|
809
1193
|
* one, else `undefined` — no platform fallback. The fallback belongs to
|
|
@@ -823,9 +1207,11 @@ export declare class RealtimeClientSessionService {
|
|
|
823
1207
|
*
|
|
824
1208
|
* @param effectiveConfig The resolved effective configuration.
|
|
825
1209
|
* @param resolve The session's run-scoped key resolver (run keys only; see {@link resolveVendorAndInstantiate}).
|
|
1210
|
+
* @param credentialScope The session's credential scope; see {@link resolveVendorAndInstantiate}.
|
|
1211
|
+
* @param showsAvatar Whether the session will show an avatar; see {@link resolveVendorAndInstantiate}.
|
|
826
1212
|
* @returns The resolution, or `null` when no preference is configured or it can't be satisfied.
|
|
827
1213
|
*/
|
|
828
|
-
protected resolveConfiguredModelPreference(effectiveConfig?: RealtimeCoAgentConfig, resolve?: AIAPIKeyResolver): RealtimeModelResolution | null;
|
|
1214
|
+
protected resolveConfiguredModelPreference(effectiveConfig?: RealtimeCoAgentConfig, resolve?: AIAPIKeyResolver, credentialScope?: AICredentialScope, showsAvatar?: boolean): RealtimeModelResolution | null;
|
|
829
1215
|
/**
|
|
830
1216
|
* Looks up a model by ID (UUID-insensitive) or, failing that, by case/whitespace-insensitive
|
|
831
1217
|
* Name in {@link AIEngine}'s cached models. **Overridable seam**; tolerant of an unloaded cache.
|
|
@@ -841,9 +1227,11 @@ export declare class RealtimeClientSessionService {
|
|
|
841
1227
|
*
|
|
842
1228
|
* @param preferredModelID The `MJ: AI Models.ID` the user chose.
|
|
843
1229
|
* @param resolve The session's run-scoped key resolver (run keys only; see {@link resolveVendorAndInstantiate}).
|
|
1230
|
+
* @param credentialScope The session's credential scope; see {@link resolveVendorAndInstantiate}.
|
|
1231
|
+
* @param showsAvatar Whether the session will show an avatar; see {@link resolveVendorAndInstantiate}.
|
|
844
1232
|
* @returns The resolution outcome (resolution or a specific failure reason).
|
|
845
1233
|
*/
|
|
846
|
-
protected resolvePreferredRealtimeModel(preferredModelID: string, resolve?: AIAPIKeyResolver): RealtimeModelResolutionOutcome;
|
|
1234
|
+
protected resolvePreferredRealtimeModel(preferredModelID: string, resolve?: AIAPIKeyResolver, credentialScope?: AICredentialScope, showsAvatar?: boolean): RealtimeModelResolutionOutcome;
|
|
847
1235
|
/**
|
|
848
1236
|
* Looks up a model by id in {@link AIEngine}'s cached models. **Overridable seam** for tests.
|
|
849
1237
|
*
|
|
@@ -864,9 +1252,11 @@ export declare class RealtimeClientSessionService {
|
|
|
864
1252
|
*
|
|
865
1253
|
* @param coAgent The co-agent being voiced (reserved for future per-agent model preference).
|
|
866
1254
|
* @param resolve The session's run-scoped key resolver (run keys only; see {@link resolveVendorAndInstantiate}).
|
|
1255
|
+
* @param credentialScope The session's credential scope; see {@link resolveVendorAndInstantiate}.
|
|
1256
|
+
* @param showsAvatar Whether the session will show an avatar; see {@link resolveVendorAndInstantiate}.
|
|
867
1257
|
* @returns The resolved model + identifiers, or `null`.
|
|
868
1258
|
*/
|
|
869
|
-
protected resolveRealtimeModel(coAgent: MJAIAgentEntityExtended, resolve?: AIAPIKeyResolver): Promise<RealtimeModelResolution | null>;
|
|
1259
|
+
protected resolveRealtimeModel(coAgent: MJAIAgentEntityExtended, resolve?: AIAPIKeyResolver, credentialScope?: AICredentialScope, showsAvatar?: boolean): Promise<RealtimeModelResolution | null>;
|
|
870
1260
|
/**
|
|
871
1261
|
* Shared tail of model resolution: picks the vendor (with a usable API key) for an
|
|
872
1262
|
* already-chosen model entity and instantiates its realtime driver.
|
|
@@ -879,9 +1269,26 @@ export declare class RealtimeClientSessionService {
|
|
|
879
1269
|
* @param resolve The session's run-scoped key resolver. Expected to answer with run keys only:
|
|
880
1270
|
* one that falls back to the environment itself answers before {@link getAPIKeyForDriver} and
|
|
881
1271
|
* so bypasses an override of it.
|
|
1272
|
+
* @param credentialScope A scope that rules out the `'Environment'` source (`'RuntimeOnly'`) drops the
|
|
1273
|
+
* {@link getAPIKeyForDriver} seam: the run's keys are the whole chain, so a vendor they do not key
|
|
1274
|
+
* is never selected on the platform's key.
|
|
1275
|
+
* @param showsAvatar Whether the session will show an avatar. The highest-Priority keyed vendor stands when it
|
|
1276
|
+
* renders avatars ({@link RealtimeModelShowsAvatar}) exactly when the session will show one; otherwise the first
|
|
1277
|
+
* other keyed vendor that does is taken, when there is one. So a vendor that renders avatars (Vertex AI for Gemini
|
|
1278
|
+
* 3.8 Live, with its own billing and limits) takes a session only when it will show an avatar, or when it is the
|
|
1279
|
+
* only keyed vendor; and a session that will show one goes to such a vendor whatever the Priority order.
|
|
882
1280
|
* @returns The full resolution, or `null` when no vendor/key/driver can be satisfied.
|
|
883
1281
|
*/
|
|
884
|
-
protected resolveVendorAndInstantiate(model: MJAIModelEntityExtended, resolve?: AIAPIKeyResolver): RealtimeModelResolution | null;
|
|
1282
|
+
protected resolveVendorAndInstantiate(model: MJAIModelEntityExtended, resolve?: AIAPIKeyResolver, credentialScope?: AICredentialScope, showsAvatar?: boolean): RealtimeModelResolution | null;
|
|
1283
|
+
/**
|
|
1284
|
+
* The session's complete key chain for vendor selection and the mint (see {@link resolveVendorAndInstantiate}): the
|
|
1285
|
+
* run's keys first, then this service's own seam (which subclasses and tests override), so a run-scoped credential
|
|
1286
|
+
* wins without taking that seam away from anyone who replaced it. A scope that rules out the environment has no second
|
|
1287
|
+
* step: the seam's default is the platform key.
|
|
1288
|
+
*/
|
|
1289
|
+
private buildKeyChain;
|
|
1290
|
+
/** Instantiates a vendor's realtime driver with its key from the chain; `null` when the key or the driver is missing. */
|
|
1291
|
+
private instantiateRealtimeVendor;
|
|
885
1292
|
/**
|
|
886
1293
|
* Resolves the API key for a vendor driver class. **Overridable seam** (wraps the module-level
|
|
887
1294
|
* {@link GetAIAPIKey}) so tests can simulate present/absent keys without environment setup.
|
|
@@ -904,7 +1311,9 @@ export declare class RealtimeClientSessionService {
|
|
|
904
1311
|
protected createModelInstance(driverClass: string, apiKey: string): BaseRealtimeModel | null;
|
|
905
1312
|
/**
|
|
906
1313
|
* The active models of AIModelType `Realtime`, sorted highest-PowerRank first — the candidate
|
|
907
|
-
* list {@link resolveRealtimeModel} walks until one yields a usable client-direct driver
|
|
1314
|
+
* list {@link resolveRealtimeModel} walks until one yields a usable client-direct driver, and
|
|
1315
|
+
* {@link ResolveAvatarRealtimeModel} walks first for a co-agent with video on. Equal PowerRanks
|
|
1316
|
+
* keep the engine's cached order (a stable sort).
|
|
908
1317
|
* Returns ALL candidates (not just the top pick) so a keyless or non-client-direct top model
|
|
909
1318
|
* falls through to the next usable one instead of dead-ending the whole resolution.
|
|
910
1319
|
*
|
|
@@ -947,9 +1356,32 @@ export declare class RealtimeClientSessionService {
|
|
|
947
1356
|
* @param driverClass The resolved vendor's DriverClass — matches per-provider voice settings.
|
|
948
1357
|
* @param modelID The resolved `MJ: AI Models` id — keys the model-catalog `ModelConfiguration` cascade.
|
|
949
1358
|
* @param modelVendorID The resolved `MJ: AI Model Vendors` ROW id — the cascade's most-specific layer.
|
|
1359
|
+
* @param resolvedAvatar The session's avatar resolution, when the caller already made it; resolved here otherwise.
|
|
950
1360
|
* @returns The assembled session params.
|
|
951
1361
|
*/
|
|
952
|
-
protected buildSessionParams(input: PrepareClientSessionInput, coAgent: MJAIAgentEntityExtended, modelApiName: string, contextUser: UserInfo, provider: IMetadataProvider, effectiveConfig?: RealtimeCoAgentConfig, driverClass?: string, modelID?: string, modelVendorID?: string): Promise<RealtimeSessionParams>;
|
|
1362
|
+
protected buildSessionParams(input: PrepareClientSessionInput, coAgent: MJAIAgentEntityExtended, modelApiName: string, contextUser: UserInfo, provider: IMetadataProvider, effectiveConfig?: RealtimeCoAgentConfig, driverClass?: string, modelID?: string, modelVendorID?: string, resolvedAvatar?: RealtimeAvatarResolution): Promise<RealtimeSessionParams>;
|
|
1363
|
+
/**
|
|
1364
|
+
* The live avatar this session asks for, if any: from the voiced agent's persona, or `realtime.video.avatarId`,
|
|
1365
|
+
* when the agent's video setting is on (see `ResolveRealtimeAvatar`). A call that picked an avatar (its runtime
|
|
1366
|
+
* override names `realtime.video.avatarId`) while that setting is off asks for none, with reason `video-off`. A model
|
|
1367
|
+
* whose `MJ: AI Model Modalities`
|
|
1368
|
+
* Video/Output row turns video off asks for none (reason `endpoint`, one log line); otherwise whether the session can
|
|
1369
|
+
* render it is the driver's call. A seam so tests can supply a resolution without the engine's persona metadata.
|
|
1370
|
+
*
|
|
1371
|
+
* @param input The prepare-session input (the voiced agent).
|
|
1372
|
+
* @param coAgent The co-agent.
|
|
1373
|
+
* @param effectiveConfig The effective configuration.
|
|
1374
|
+
* @param modelID The resolved model.
|
|
1375
|
+
* @param modelVendorID The resolved model-vendor row; its vendor scopes the persona bindings.
|
|
1376
|
+
*/
|
|
1377
|
+
protected ResolveSessionAvatar(input: PrepareClientSessionInput, coAgent: MJAIAgentEntityExtended, effectiveConfig: RealtimeCoAgentConfig | undefined, modelID: string | undefined, modelVendorID: string | undefined): RealtimeAvatarResolution;
|
|
1378
|
+
/**
|
|
1379
|
+
* The config bag with the avatar persona's voice, so the face and the voice match, unless a voice was picked in this
|
|
1380
|
+
* call (a runtime override's `realtime.voice.default.voice`), which wins. A session nobody would see the avatar in (a
|
|
1381
|
+
* phone call, an app without agent video) keeps the voice without the face, so the agent sounds the same as in a call
|
|
1382
|
+
* that shows it.
|
|
1383
|
+
*/
|
|
1384
|
+
private withAvatarVoice;
|
|
953
1385
|
/**
|
|
954
1386
|
* Builds the provider-pact `Config` bag for the session: the effective config's resolved voice
|
|
955
1387
|
* settings (per {@link GetProviderVoiceSettings} — the persona's agnostic wire-level slots
|
|
@@ -1124,6 +1556,8 @@ export declare class RealtimeClientSessionService {
|
|
|
1124
1556
|
* @returns The tools to register at session start.
|
|
1125
1557
|
*/
|
|
1126
1558
|
protected buildStableToolSet(extraTools?: RealtimeToolDefinition[]): RealtimeToolDefinition[];
|
|
1559
|
+
/** Appends the host-declared tools to a stable tool set, dropping any whose name is already taken. */
|
|
1560
|
+
protected appendHostTools(tools: RealtimeToolDefinition[], hostTools?: RealtimeToolDefinition[]): RealtimeToolDefinition[];
|
|
1127
1561
|
/**
|
|
1128
1562
|
* Builds the {@link RealtimeToolBroker} for a relayed tool call, wiring `DelegateToTarget` to a
|
|
1129
1563
|
* target-agent run and `ExecuteTool` to direct-action execution or a structured "not available" placeholder.
|
|
@@ -1214,11 +1648,13 @@ export declare class RealtimeClientSessionService {
|
|
|
1214
1648
|
/**
|
|
1215
1649
|
* Runs (or resumes) the target agent for a delegation. Threads the combined abort signal, parent
|
|
1216
1650
|
* run linkage, session id, and the `OnProgress` callback so the resolver can stream progress.
|
|
1651
|
+
* The browser session id becomes the run's `sessionID` (client-tool channel) and the app-context
|
|
1652
|
+
* snapshot rides `data.appContext` (prompt context and surface tools); both are optional.
|
|
1217
1653
|
* When {@link ExecuteRelayedToolInput.ResumeRunID} is set, resumes that paused run via
|
|
1218
1654
|
* `lastRunId` + `autoPopulateLastRunPayload` (the user's answer continues the same interactive
|
|
1219
1655
|
* run) instead of starting fresh.
|
|
1220
1656
|
*
|
|
1221
|
-
* @param input The relayed tool input (linkage, progress callback, optional resume id).
|
|
1657
|
+
* @param input The relayed tool input (linkage, progress callback, optional resume id, browser session, app context).
|
|
1222
1658
|
* @param request The broker's delegation request (call id + arguments + abort signal).
|
|
1223
1659
|
* @param target The resolved target agent.
|
|
1224
1660
|
* @param contextUser The calling user.
|
|
@@ -1269,17 +1705,27 @@ export declare class RealtimeClientSessionService {
|
|
|
1269
1705
|
* @returns The active action entities assigned to the agent.
|
|
1270
1706
|
*/
|
|
1271
1707
|
protected getTargetAgentActions(targetAgentID: string): MJActionEntityExtended[];
|
|
1708
|
+
/**
|
|
1709
|
+
* The session's direct-action tools. When the input excludes direct actions, none, and the empty
|
|
1710
|
+
* projection is recorded so the session's relays run none.
|
|
1711
|
+
*/
|
|
1712
|
+
private projectDirectActions;
|
|
1272
1713
|
/**
|
|
1273
1714
|
* Builds the projected direct action tool definitions for a target agent if supported by the driver.
|
|
1274
1715
|
* Gated by driver capability (`SupportsDynamicToolSet`) and explicit configuration opt-in
|
|
1275
1716
|
* (`Configuration.realtime.directActions.enabled = true`).
|
|
1276
1717
|
*
|
|
1718
|
+
* With `agentSessionID`, the projection is recorded for the session, even when it is empty: relayed
|
|
1719
|
+
* direct-action calls for the session may run only the projected actions.
|
|
1720
|
+
*
|
|
1277
1721
|
* @param targetAgentID The target agent ID being voiced.
|
|
1278
1722
|
* @param effectiveConfig The resolved effective configuration.
|
|
1279
1723
|
* @param driverClass The resolved vendor's DriverClass.
|
|
1280
1724
|
* @returns The array of projected direct action tools (empty if unsupported or disabled).
|
|
1281
1725
|
*/
|
|
1282
1726
|
BuildDirectActionTools(targetAgentID: string | undefined, effectiveConfig?: RealtimeCoAgentConfig, driverClass?: string, agentSessionID?: string): RealtimeToolDefinition[];
|
|
1727
|
+
/** Records that a session projected no direct actions, so its relays run none. */
|
|
1728
|
+
private recordEmptyProjection;
|
|
1283
1729
|
/** @deprecated Use {@link BuildDirectActionTools}. */
|
|
1284
1730
|
buildDirectActionTools(targetAgentID: string | undefined, effectiveConfig?: RealtimeCoAgentConfig, driverClass?: string, agentSessionID?: string): RealtimeToolDefinition[];
|
|
1285
1731
|
/**
|
|
@@ -1296,12 +1742,29 @@ export declare class RealtimeClientSessionService {
|
|
|
1296
1742
|
* configured timeout. If the tool is unrecognized, disallowed, or target resolution fails,
|
|
1297
1743
|
* returns a structured "not available" result.
|
|
1298
1744
|
*
|
|
1745
|
+
* When this service holds the session's start-time projection, only the projected actions may
|
|
1746
|
+
* run, whatever target the input names. When it holds none, the target agent's own metadata
|
|
1747
|
+
* decides: another process prepared the session, the entry was evicted or lost on a restart, or
|
|
1748
|
+
* the session was never started through this service (for example a row created through the
|
|
1749
|
+
* entity API). That fallback skips the driver-capability gate but is still limited to the
|
|
1750
|
+
* target's own direct-actions allowlist.
|
|
1751
|
+
*
|
|
1299
1752
|
* @param call The non-target tool call.
|
|
1300
1753
|
* @param input The optional relayed tool input context.
|
|
1301
1754
|
* @param contextUser The calling user context.
|
|
1302
1755
|
* @returns A {@link ToolExecutionResult} for the model's tool_response.
|
|
1303
1756
|
*/
|
|
1304
1757
|
protected executeNonTargetTool(call: RealtimeToolCall, input?: ExecuteRelayedToolInput, contextUser?: UserInfo): Promise<ToolExecutionResult>;
|
|
1758
|
+
/**
|
|
1759
|
+
* Finds the action a relayed tool name refers to: the exact wire name first, then a
|
|
1760
|
+
* case-insensitive match.
|
|
1761
|
+
*/
|
|
1762
|
+
private findWireAction;
|
|
1763
|
+
/**
|
|
1764
|
+
* True when the action is in the session's start-time projection, or when this service holds no
|
|
1765
|
+
* projection for the session (see {@link executeNonTargetTool} for when that happens).
|
|
1766
|
+
*/
|
|
1767
|
+
private isInProjection;
|
|
1305
1768
|
/**
|
|
1306
1769
|
* Parses JSON arguments string into a key-value record of parameters.
|
|
1307
1770
|
* Distinguishes "no arguments" (valid for zero-param action) from "unparseable JSON".
|