@memberjunction/ai-agents 6.3.0-edge.0 → 6.3.0-edge.1
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 +8 -5
- package/dist/AgentDataPreloader.d.ts +9 -2
- package/dist/AgentDataPreloader.d.ts.map +1 -1
- package/dist/AgentDataPreloader.js +134 -15
- package/dist/AgentDataPreloader.js.map +1 -1
- package/dist/AgentDecisionService.d.ts +10 -1
- package/dist/AgentDecisionService.d.ts.map +1 -1
- package/dist/AgentDecisionService.js +28 -13
- package/dist/AgentDecisionService.js.map +1 -1
- package/dist/AgentRunner.d.ts +57 -15
- package/dist/AgentRunner.d.ts.map +1 -1
- package/dist/AgentRunner.js +692 -101
- package/dist/AgentRunner.js.map +1 -1
- package/dist/ArtifactToolManager.d.ts +134 -39
- package/dist/ArtifactToolManager.d.ts.map +1 -1
- package/dist/ArtifactToolManager.js +2761 -321
- package/dist/ArtifactToolManager.js.map +1 -1
- package/dist/GovernedArtifactService.d.ts +367 -0
- package/dist/GovernedArtifactService.d.ts.map +1 -0
- package/dist/GovernedArtifactService.js +2569 -0
- package/dist/GovernedArtifactService.js.map +1 -0
- package/dist/PayloadManager.d.ts +46 -0
- package/dist/PayloadManager.d.ts.map +1 -1
- package/dist/PayloadManager.js +284 -66
- package/dist/PayloadManager.js.map +1 -1
- package/dist/SkillMarkdownConverter.d.ts.map +1 -1
- package/dist/SkillMarkdownConverter.js +4 -2
- package/dist/SkillMarkdownConverter.js.map +1 -1
- package/dist/agent-context-injector.d.ts +2 -25
- package/dist/agent-context-injector.d.ts.map +1 -1
- package/dist/agent-context-injector.js +38 -153
- package/dist/agent-context-injector.js.map +1 -1
- package/dist/agent-instance.d.ts +28 -0
- package/dist/agent-instance.d.ts.map +1 -0
- package/dist/agent-instance.js +39 -0
- package/dist/agent-instance.js.map +1 -0
- package/dist/agent-memory-context-builder.d.ts.map +1 -1
- package/dist/agent-memory-context-builder.js +46 -42
- package/dist/agent-memory-context-builder.js.map +1 -1
- package/dist/agent-pre-execution-rag.d.ts.map +1 -1
- package/dist/agent-pre-execution-rag.js +5 -0
- package/dist/agent-pre-execution-rag.js.map +1 -1
- package/dist/agent-run-watchdog.d.ts +38 -6
- package/dist/agent-run-watchdog.d.ts.map +1 -1
- package/dist/agent-run-watchdog.js +75 -13
- package/dist/agent-run-watchdog.js.map +1 -1
- package/dist/agent-types/flow-agent-type.d.ts +6 -1
- package/dist/agent-types/flow-agent-type.d.ts.map +1 -1
- package/dist/agent-types/flow-agent-type.js +30 -7
- package/dist/agent-types/flow-agent-type.js.map +1 -1
- package/dist/agent-types/loop-agent-type.d.ts +4 -0
- package/dist/agent-types/loop-agent-type.d.ts.map +1 -1
- package/dist/agent-types/loop-agent-type.js +29 -0
- package/dist/agent-types/loop-agent-type.js.map +1 -1
- package/dist/artifact-presence-locator.d.ts +132 -0
- package/dist/artifact-presence-locator.d.ts.map +1 -0
- package/dist/artifact-presence-locator.js +472 -0
- package/dist/artifact-presence-locator.js.map +1 -0
- package/dist/artifact-tools/CSVToolLibrary.d.ts +2 -2
- package/dist/artifact-tools/CSVToolLibrary.d.ts.map +1 -1
- package/dist/artifact-tools/CSVToolLibrary.js +41 -14
- package/dist/artifact-tools/CSVToolLibrary.js.map +1 -1
- package/dist/artifact-tools/DataSnapshotToolLibrary.d.ts +2 -2
- package/dist/artifact-tools/DataSnapshotToolLibrary.d.ts.map +1 -1
- package/dist/artifact-tools/DataSnapshotToolLibrary.js +53 -21
- package/dist/artifact-tools/DataSnapshotToolLibrary.js.map +1 -1
- package/dist/artifact-tools/DocumentToolLibrary.d.ts +101 -0
- package/dist/artifact-tools/DocumentToolLibrary.d.ts.map +1 -0
- package/dist/artifact-tools/DocumentToolLibrary.js +1846 -0
- package/dist/artifact-tools/DocumentToolLibrary.js.map +1 -0
- package/dist/artifact-tools/DocxToolLibrary.d.ts +2 -4
- package/dist/artifact-tools/DocxToolLibrary.d.ts.map +1 -1
- package/dist/artifact-tools/DocxToolLibrary.js +42 -30
- package/dist/artifact-tools/DocxToolLibrary.js.map +1 -1
- package/dist/artifact-tools/ExcelToolLibrary.d.ts +2 -3
- package/dist/artifact-tools/ExcelToolLibrary.d.ts.map +1 -1
- package/dist/artifact-tools/ExcelToolLibrary.js +105 -49
- package/dist/artifact-tools/ExcelToolLibrary.js.map +1 -1
- package/dist/artifact-tools/GenericBinaryToolLibrary.d.ts +2 -2
- package/dist/artifact-tools/GenericBinaryToolLibrary.d.ts.map +1 -1
- package/dist/artifact-tools/GenericBinaryToolLibrary.js +3 -2
- package/dist/artifact-tools/GenericBinaryToolLibrary.js.map +1 -1
- package/dist/artifact-tools/JSONToolLibrary.d.ts +4 -4
- package/dist/artifact-tools/JSONToolLibrary.d.ts.map +1 -1
- package/dist/artifact-tools/JSONToolLibrary.js +32 -11
- package/dist/artifact-tools/JSONToolLibrary.js.map +1 -1
- package/dist/artifact-tools/PDFToolLibrary.d.ts +27 -3
- package/dist/artifact-tools/PDFToolLibrary.d.ts.map +1 -1
- package/dist/artifact-tools/PDFToolLibrary.js +36 -21
- package/dist/artifact-tools/PDFToolLibrary.js.map +1 -1
- package/dist/artifact-tools/SearchResultSetToolLibrary.d.ts +2 -2
- package/dist/artifact-tools/SearchResultSetToolLibrary.d.ts.map +1 -1
- package/dist/artifact-tools/SearchResultSetToolLibrary.js +83 -24
- package/dist/artifact-tools/SearchResultSetToolLibrary.js.map +1 -1
- package/dist/artifact-tools/SlideDeckToolLibrary.d.ts +50 -0
- package/dist/artifact-tools/SlideDeckToolLibrary.d.ts.map +1 -0
- package/dist/artifact-tools/SlideDeckToolLibrary.js +1617 -0
- package/dist/artifact-tools/SlideDeckToolLibrary.js.map +1 -0
- package/dist/artifact-tools/SpreadsheetToolLibrary.d.ts +87 -0
- package/dist/artifact-tools/SpreadsheetToolLibrary.d.ts.map +1 -0
- package/dist/artifact-tools/SpreadsheetToolLibrary.js +3351 -0
- package/dist/artifact-tools/SpreadsheetToolLibrary.js.map +1 -0
- package/dist/artifact-tools/TextToolLibrary.d.ts +3 -3
- package/dist/artifact-tools/TextToolLibrary.d.ts.map +1 -1
- package/dist/artifact-tools/TextToolLibrary.js +34 -24
- package/dist/artifact-tools/TextToolLibrary.js.map +1 -1
- package/dist/artifact-tools/WhiteboardToolLibrary.d.ts +69 -0
- package/dist/artifact-tools/WhiteboardToolLibrary.d.ts.map +1 -0
- package/dist/artifact-tools/WhiteboardToolLibrary.js +555 -0
- package/dist/artifact-tools/WhiteboardToolLibrary.js.map +1 -0
- package/dist/artifact-tools/artifact-comment-suggestion-helper.d.ts +98 -0
- package/dist/artifact-tools/artifact-comment-suggestion-helper.d.ts.map +1 -0
- package/dist/artifact-tools/artifact-comment-suggestion-helper.js +851 -0
- package/dist/artifact-tools/artifact-comment-suggestion-helper.js.map +1 -0
- package/dist/artifact-tools/artifact-tool-helpers.d.ts +21 -0
- package/dist/artifact-tools/artifact-tool-helpers.d.ts.map +1 -0
- package/dist/artifact-tools/artifact-tool-helpers.js +74 -0
- package/dist/artifact-tools/artifact-tool-helpers.js.map +1 -0
- package/dist/artifact-tools/grepHelper.d.ts +27 -0
- package/dist/artifact-tools/grepHelper.d.ts.map +1 -0
- package/dist/artifact-tools/grepHelper.js +229 -0
- package/dist/artifact-tools/grepHelper.js.map +1 -0
- package/dist/artifact-tools/node-vm-safe-regex.d.ts +10 -0
- package/dist/artifact-tools/node-vm-safe-regex.d.ts.map +1 -0
- package/dist/artifact-tools/node-vm-safe-regex.js +148 -0
- package/dist/artifact-tools/node-vm-safe-regex.js.map +1 -0
- package/dist/base-agent.d.ts +119 -14
- package/dist/base-agent.d.ts.map +1 -1
- package/dist/base-agent.js +529 -112
- package/dist/base-agent.js.map +1 -1
- package/dist/decision-discovery.d.ts +42 -15
- package/dist/decision-discovery.d.ts.map +1 -1
- package/dist/decision-discovery.js +90 -20
- package/dist/decision-discovery.js.map +1 -1
- package/dist/index.d.ts +12 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +12 -2
- package/dist/index.js.map +1 -1
- package/dist/memory-decision-uses.d.ts +206 -0
- package/dist/memory-decision-uses.d.ts.map +1 -0
- package/dist/memory-decision-uses.js +259 -0
- package/dist/memory-decision-uses.js.map +1 -0
- package/dist/memory-manager-agent.d.ts +66 -6
- package/dist/memory-manager-agent.d.ts.map +1 -1
- package/dist/memory-manager-agent.js +184 -31
- package/dist/memory-manager-agent.js.map +1 -1
- package/dist/memory-note-gate.d.ts +12 -9
- package/dist/memory-note-gate.d.ts.map +1 -1
- package/dist/memory-note-gate.js +16 -11
- package/dist/memory-note-gate.js.map +1 -1
- package/dist/native-tools/agent-tool-circuit-breaker.d.ts +44 -0
- package/dist/native-tools/agent-tool-circuit-breaker.d.ts.map +1 -0
- package/dist/native-tools/agent-tool-circuit-breaker.js +71 -0
- package/dist/native-tools/agent-tool-circuit-breaker.js.map +1 -0
- package/dist/native-tools/agent-tools.d.ts +7 -0
- package/dist/native-tools/agent-tools.d.ts.map +1 -1
- package/dist/native-tools/agent-tools.js.map +1 -1
- package/dist/native-tools/control-tools.d.ts +8 -1
- package/dist/native-tools/control-tools.d.ts.map +1 -1
- package/dist/native-tools/control-tools.js +38 -5
- package/dist/native-tools/control-tools.js.map +1 -1
- package/dist/native-tools/framework-tools.d.ts +3 -3
- package/dist/native-tools/framework-tools.d.ts.map +1 -1
- package/dist/native-tools/framework-tools.js +20 -8
- package/dist/native-tools/framework-tools.js.map +1 -1
- package/dist/payload-path-keys.d.ts +54 -0
- package/dist/payload-path-keys.d.ts.map +1 -0
- package/dist/payload-path-keys.js +126 -0
- package/dist/payload-path-keys.js.map +1 -0
- package/dist/pipeline/template.d.ts +9 -4
- package/dist/pipeline/template.d.ts.map +1 -1
- package/dist/pipeline/template.js +29 -30
- package/dist/pipeline/template.js.map +1 -1
- package/dist/realtime/artifact-workspace-channel-server.d.ts +27 -0
- package/dist/realtime/artifact-workspace-channel-server.d.ts.map +1 -0
- package/dist/realtime/artifact-workspace-channel-server.js +43 -0
- package/dist/realtime/artifact-workspace-channel-server.js.map +1 -0
- package/dist/realtime/bridge-realtime-session-factory.d.ts +2 -2
- package/dist/realtime/bridge-realtime-session-factory.d.ts.map +1 -1
- package/dist/realtime/bridge-realtime-session-factory.js +7 -56
- package/dist/realtime/bridge-realtime-session-factory.js.map +1 -1
- package/dist/realtime/realtime-artifact-helpers.d.ts +37 -0
- package/dist/realtime/realtime-artifact-helpers.d.ts.map +1 -0
- package/dist/realtime/realtime-artifact-helpers.js +150 -0
- package/dist/realtime/realtime-artifact-helpers.js.map +1 -0
- package/dist/realtime/realtime-client-session-service.d.ts +87 -17
- package/dist/realtime/realtime-client-session-service.d.ts.map +1 -1
- package/dist/realtime/realtime-client-session-service.js +259 -39
- package/dist/realtime/realtime-client-session-service.js.map +1 -1
- package/dist/realtime/realtime-coagent-config.d.ts +22 -7
- package/dist/realtime/realtime-coagent-config.d.ts.map +1 -1
- package/dist/realtime/realtime-coagent-config.js +20 -22
- package/dist/realtime/realtime-coagent-config.js.map +1 -1
- package/dist/realtime/realtime-moderator-decision.d.ts +86 -0
- package/dist/realtime/realtime-moderator-decision.d.ts.map +1 -0
- package/dist/realtime/realtime-moderator-decision.js +131 -0
- package/dist/realtime/realtime-moderator-decision.js.map +1 -0
- package/dist/realtime/realtime-tool-broker.d.ts +6 -0
- package/dist/realtime/realtime-tool-broker.d.ts.map +1 -1
- package/dist/realtime/realtime-tool-broker.js +4 -2
- package/dist/realtime/realtime-tool-broker.js.map +1 -1
- package/dist/realtime/realtime-turn-moderator.d.ts +20 -0
- package/dist/realtime/realtime-turn-moderator.d.ts.map +1 -1
- package/dist/realtime/realtime-turn-moderator.js +63 -8
- package/dist/realtime/realtime-turn-moderator.js.map +1 -1
- package/dist/repeated-failing-step.d.ts +50 -0
- package/dist/repeated-failing-step.d.ts.map +1 -0
- package/dist/repeated-failing-step.js +130 -0
- package/dist/repeated-failing-step.js.map +1 -0
- package/dist/tsconfig.tsbuildinfo +1 -0
- package/package.json +20 -20
|
@@ -40,10 +40,12 @@ import { RealtimeSessionCanShowAvatar, ResolveBridgedAvatarStatus, ResolveRealti
|
|
|
40
40
|
import { ChooseRealtimeVendorForAvatar, ReadRealtimeVideoOutputRow, RealtimeModelShowsAvatar } from './realtime-video-output-gate.js';
|
|
41
41
|
import { AgentMemoryContextBuilder } from '../agent-memory-context-builder.js';
|
|
42
42
|
import { AgentRunner } from '../AgentRunner.js';
|
|
43
|
+
import { GovernedArtifactService } from '../GovernedArtifactService.js';
|
|
43
44
|
import { AgentRunWatchdog } from '../agent-run-watchdog.js';
|
|
44
45
|
import { DelegationNarrator } from './realtime-delegation-narrator.js';
|
|
45
46
|
import { FilterAllowedAgentsByCanRun } from './realtime-coagent-resolution.js';
|
|
46
47
|
import { BridgeRealtimeUsageRecorder } from './bridge-realtime-usage-recorder.js';
|
|
48
|
+
import { CollectDelegatedRunArtifacts, ExtractDirectActionArtifacts, } from './realtime-artifact-helpers.js';
|
|
47
49
|
import { RealtimeToolBroker, INVOKE_TARGET_AGENT_TOOL_NAME, INVOKE_TARGET_AGENT_DESCRIPTION, BuildRealtimeAgentFraming } from './realtime-tool-broker.js';
|
|
48
50
|
import { NARRATION_PROMPT_NAME, LEGACY_NARRATION_PROMPT_NAME, ResolveNarrationInstructionsTemplate } from './realtime-narration.js';
|
|
49
51
|
import { BuildVoiceMannerSection, BuildAppRealtimeOverridesJson, DeepMergeConfigs, FindDeprecatedRealtimeVideoKeys, GetModelCatalogSessionSettings, GetDisclosureForTarget, GetNarrationPaceMs, GetProviderVoiceSettings, GetSessionTuningSettings, GetWatchesMeetingVideo, ResolveEffectiveRealtimeConfig, MatchProviderVoiceSettings, GetDirectActionsConfig, IsActionAllowedForDirectInvocation } from './realtime-coagent-config.js';
|
|
@@ -300,6 +302,16 @@ export class RealtimeClientSessionService {
|
|
|
300
302
|
maxSize: 5_000,
|
|
301
303
|
ttlMs: 4 * 60 * 60 * 1000,
|
|
302
304
|
});
|
|
305
|
+
/** Maps session id -> live accumulated artifacts touched, created, or seeded during the voice session. */
|
|
306
|
+
this.sessionArtifacts = new MJLruCache({
|
|
307
|
+
maxSize: 5_000,
|
|
308
|
+
ttlMs: 4 * 60 * 60 * 1000,
|
|
309
|
+
});
|
|
310
|
+
/** Maps session id -> associated ConversationID recorded during session prep. */
|
|
311
|
+
this.sessionConversationIds = new MJLruCache({
|
|
312
|
+
maxSize: 5_000,
|
|
313
|
+
ttlMs: 4 * 60 * 60 * 1000,
|
|
314
|
+
});
|
|
303
315
|
/**
|
|
304
316
|
* IN-FLIGHT DELEGATION REGISTRY — the server half of the client-direct CANCEL channel.
|
|
305
317
|
*
|
|
@@ -338,6 +350,59 @@ export class RealtimeClientSessionService {
|
|
|
338
350
|
ttlMs: 4 * 60 * 60 * 1000, // 4h backstop — generous vs. any realistic session duration
|
|
339
351
|
});
|
|
340
352
|
}
|
|
353
|
+
/** Records/merges artifacts into the live session ledger, deduplicating by normalized ArtifactID. */
|
|
354
|
+
RecordSessionArtifacts(agentSessionID, items) {
|
|
355
|
+
const key = agentSessionID?.trim();
|
|
356
|
+
if (!key) {
|
|
357
|
+
return [];
|
|
358
|
+
}
|
|
359
|
+
const existing = this.sessionArtifacts.Get(key) ?? [];
|
|
360
|
+
const byNormId = new Map();
|
|
361
|
+
for (const item of existing) {
|
|
362
|
+
const norm = NormalizeUUID((item.ArtifactID ?? '').trim());
|
|
363
|
+
if (norm) {
|
|
364
|
+
byNormId.set(norm, item);
|
|
365
|
+
}
|
|
366
|
+
}
|
|
367
|
+
for (const item of items ?? []) {
|
|
368
|
+
const rawId = (item.ArtifactID ?? '').trim();
|
|
369
|
+
const norm = NormalizeUUID(rawId);
|
|
370
|
+
if (!norm) {
|
|
371
|
+
continue;
|
|
372
|
+
}
|
|
373
|
+
const prior = byNormId.get(norm);
|
|
374
|
+
const isSummary = 'LatestVersionID' in item || 'LatestVersionNumber' in item || 'Type' in item;
|
|
375
|
+
const summaryItem = isSummary ? item : undefined;
|
|
376
|
+
const delegatedItem = !isSummary ? item : undefined;
|
|
377
|
+
const hasNewerPriorVersion = prior?.LatestVersionNumber !== undefined &&
|
|
378
|
+
(summaryItem?.LatestVersionNumber === undefined
|
|
379
|
+
? isSummary
|
|
380
|
+
: summaryItem.LatestVersionNumber < prior.LatestVersionNumber);
|
|
381
|
+
const merged = {
|
|
382
|
+
ArtifactID: rawId,
|
|
383
|
+
Name: item.Name?.trim() || prior?.Name || 'Untitled Artifact',
|
|
384
|
+
Type: summaryItem?.Type ?? delegatedItem?.ArtifactTypeName ?? prior?.Type,
|
|
385
|
+
LatestVersionID: hasNewerPriorVersion
|
|
386
|
+
? prior?.LatestVersionID
|
|
387
|
+
: summaryItem?.LatestVersionID ?? (delegatedItem?.ArtifactVersionID || undefined) ?? prior?.LatestVersionID,
|
|
388
|
+
LatestVersionNumber: hasNewerPriorVersion
|
|
389
|
+
? prior?.LatestVersionNumber
|
|
390
|
+
: summaryItem?.LatestVersionNumber ?? prior?.LatestVersionNumber,
|
|
391
|
+
};
|
|
392
|
+
byNormId.set(norm, merged);
|
|
393
|
+
}
|
|
394
|
+
const mergedList = Array.from(byNormId.values());
|
|
395
|
+
this.sessionArtifacts.Set(key, mergedList);
|
|
396
|
+
return mergedList;
|
|
397
|
+
}
|
|
398
|
+
/** Returns the live deduplicated artifact ledger for the given voice session. */
|
|
399
|
+
GetSessionArtifacts(agentSessionID) {
|
|
400
|
+
const key = agentSessionID?.trim();
|
|
401
|
+
if (!key) {
|
|
402
|
+
return [];
|
|
403
|
+
}
|
|
404
|
+
return [...(this.sessionArtifacts.Get(key) ?? [])];
|
|
405
|
+
}
|
|
341
406
|
/**
|
|
342
407
|
* Builds a wire-name to action map from candidate actions, sanitizing each
|
|
343
408
|
* action's name and deduplicating collisions (first action wins).
|
|
@@ -760,7 +825,7 @@ export class RealtimeClientSessionService {
|
|
|
760
825
|
return null;
|
|
761
826
|
}
|
|
762
827
|
const configObj = JSON.parse(session.Config_);
|
|
763
|
-
return { Snapshot: configObj
|
|
828
|
+
return { Snapshot: configObj.realtimeMintSnapshot, AgentID: session.AgentID };
|
|
764
829
|
}
|
|
765
830
|
catch (error) {
|
|
766
831
|
LogError(`RealtimeClientSessionService.loadPersistedMintSnapshot failed: ${error instanceof Error ? error.message : String(error)}`);
|
|
@@ -938,6 +1003,9 @@ export class RealtimeClientSessionService {
|
|
|
938
1003
|
TargetAgentID: wiring.Input.TargetAgentID,
|
|
939
1004
|
AllowedAgents: wiring.AllowedAgents,
|
|
940
1005
|
DirectActions: wiring.Prep.EffectiveConfig?.realtime?.directActions,
|
|
1006
|
+
// The preparing run's scope and skills, from the server-built prep input.
|
|
1007
|
+
RunScope: wiring.Input.RunScope,
|
|
1008
|
+
ActiveSkillIDs: wiring.Input.ActiveSkillIDs,
|
|
941
1009
|
OnProgress: (progress) => wiring.Narrator.HandleProgress(progress),
|
|
942
1010
|
Call: call,
|
|
943
1011
|
}, wiring.ContextUser, wiring.Provider))).ResultJson;
|
|
@@ -1019,6 +1087,15 @@ export class RealtimeClientSessionService {
|
|
|
1019
1087
|
*/
|
|
1020
1088
|
async PrepareRealtimeSessionParams(input, contextUser, provider) {
|
|
1021
1089
|
await this.configureEngine(contextUser, provider);
|
|
1090
|
+
const sessionKey = input.AgentSessionID?.trim();
|
|
1091
|
+
if (sessionKey) {
|
|
1092
|
+
if (input.ConversationID?.trim()) {
|
|
1093
|
+
this.sessionConversationIds.Set(sessionKey, input.ConversationID.trim());
|
|
1094
|
+
}
|
|
1095
|
+
if (input.ConversationArtifacts?.length) {
|
|
1096
|
+
this.RecordSessionArtifacts(sessionKey, input.ConversationArtifacts);
|
|
1097
|
+
}
|
|
1098
|
+
}
|
|
1022
1099
|
const coAgent = this.resolveCoAgent(input);
|
|
1023
1100
|
if (!coAgent) {
|
|
1024
1101
|
return { Success: false, ErrorMessage: 'The Realtime Co-Agent could not be resolved from the supplied id or entity.' };
|
|
@@ -2564,8 +2641,9 @@ export class RealtimeClientSessionService {
|
|
|
2564
2641
|
const appContextSection = this.buildAppContextSection(input.AppContext);
|
|
2565
2642
|
const priorTranscript = this.formatPriorTranscript(input.PriorTranscript);
|
|
2566
2643
|
const history = this.formatConversationHistory(input.ConversationMessages);
|
|
2644
|
+
const artifacts = this.formatConversationArtifacts(input.ConversationArtifacts);
|
|
2567
2645
|
const memory = memoryContext ?? await this.assembleMemoryContext(input, coAgent, contextUser, provider);
|
|
2568
|
-
return [framing, meetingFraming, hostFraming, coAgentPrompt, voiceManner, targetIdentity, appContextSection, priorTranscript, history, memory]
|
|
2646
|
+
return [framing, meetingFraming, hostFraming, coAgentPrompt, voiceManner, targetIdentity, appContextSection, priorTranscript, history, artifacts, memory]
|
|
2569
2647
|
.filter(part => part && part.trim().length > 0)
|
|
2570
2648
|
.join('\n\n');
|
|
2571
2649
|
}
|
|
@@ -2687,9 +2765,15 @@ export class RealtimeClientSessionService {
|
|
|
2687
2765
|
`Knowledge Hub" → ContextTool with action 'NavigateToApp'; "open this record"; "switch to the X tab"). ` +
|
|
2688
2766
|
`Do NOT route in-app navigation/actions through '${INVOKE_TARGET_AGENT_TOOL_NAME}', and NEVER say you ` +
|
|
2689
2767
|
`need an active session id or a screen snapshot to do them — calling 'ContextTool' is all that's ` +
|
|
2690
|
-
`needed. Reserve '${INVOKE_TARGET_AGENT_TOOL_NAME}' for actual analysis / data work, not navigation. ` +
|
|
2768
|
+
`needed. Reserve '${INVOKE_TARGET_AGENT_TOOL_NAME}' for actual analysis / data / artifact creation work, not navigation. ` +
|
|
2691
2769
|
`When a channel note lists interactive channels you can use, 'ContextTool' also addresses ONE of ` +
|
|
2692
|
-
`them: add "target": { "channel": "<channel name>" } and use that channel's action names
|
|
2770
|
+
`them: add "target": { "channel": "<channel name>" } and use that channel's action names (for example, ` +
|
|
2771
|
+
`in 'ArtifactWorkspace' call ContextTool with action 'open' and params { "artifactId": "<id>" } or ` +
|
|
2772
|
+
`{ "name": "<title>" }; call action 'navigate_to_anchor' with params { "artifactId"?: "<id>", ` +
|
|
2773
|
+
`"sheet"?: "<sheet>", "range"?: "<A1:D10>", "heading"?: "<section>", "blockId"?: "<id>", ` +
|
|
2774
|
+
`"slideNumber"?: <1-based n>, "elementId"?: "<id>", "highlightMs"?: <ms> } to jump the user's viewer straight to a cell, section, slide, ` +
|
|
2775
|
+
`or element; and call action 'set_view_mode' with params { "artifactId"?: "<id>", "mode": "edit" | "suggest" | "diff" | "present" } to ` +
|
|
2776
|
+
`switch viewer mode. Watch 'selection_changed' context events to see what the user highlighted).`;
|
|
2693
2777
|
}
|
|
2694
2778
|
return clause;
|
|
2695
2779
|
}
|
|
@@ -2785,6 +2869,35 @@ export class RealtimeClientSessionService {
|
|
|
2785
2869
|
.filter(line => line.length > 0);
|
|
2786
2870
|
return lines.length > 0 ? `Conversation so far:\n${lines.join('\n')}` : '';
|
|
2787
2871
|
}
|
|
2872
|
+
/**
|
|
2873
|
+
* Formats artifacts already created or attached in the conversation before this call started
|
|
2874
|
+
* so the co-agent can open or revise them by ID rather than duplicating them.
|
|
2875
|
+
*
|
|
2876
|
+
* @param artifacts The deduplicated conversation artifact summaries, or undefined.
|
|
2877
|
+
* @returns The formatted section, or empty string when none exist.
|
|
2878
|
+
*/
|
|
2879
|
+
formatConversationArtifacts(artifacts) {
|
|
2880
|
+
if (!artifacts || artifacts.length === 0) {
|
|
2881
|
+
return '';
|
|
2882
|
+
}
|
|
2883
|
+
const lines = artifacts
|
|
2884
|
+
.filter(a => a.ArtifactID && a.Name)
|
|
2885
|
+
.map(a => {
|
|
2886
|
+
const typePart = a.Type ? `, Type: ${a.Type}` : '';
|
|
2887
|
+
const verPart = typeof a.LatestVersionNumber === 'number' ? `, LatestVersion: v${a.LatestVersionNumber}` : '';
|
|
2888
|
+
return `- "${a.Name}" (ArtifactID: ${a.ArtifactID}${typePart}${verPart})`;
|
|
2889
|
+
});
|
|
2890
|
+
if (lines.length === 0) {
|
|
2891
|
+
return '';
|
|
2892
|
+
}
|
|
2893
|
+
return ('Artifacts already in this conversation (to display a Doc, Spreadsheet, or Presentation in the workspace use ContextTool with ' +
|
|
2894
|
+
'target={ "channel": "ArtifactWorkspace" }, action="open", params={ "artifactId": "<ArtifactID>" }; ' +
|
|
2895
|
+
'to jump the viewer to a specific section, cell range, or slide use action="navigate_to_anchor" with ' +
|
|
2896
|
+
'params={ "artifactId"?: "<ArtifactID>", "sheet"?: "<sheet>", "range"?: "<A1:D10>", "heading"?: "<heading>", "blockId"?: "<id>", "slideNumber"?: <1-based n>, "elementId"?: "<id>", "highlightMs"?: <ms> }; ' +
|
|
2897
|
+
'to change mode use action="set_view_mode" with params={ "artifactId"?: "<ArtifactID>", "mode": "edit" | "suggest" | "diff" | "present" }; ' +
|
|
2898
|
+
'to revise an existing artifact via invoke-target-agent, include its ArtifactID so the agent updates it instead of creating a duplicate):\n' +
|
|
2899
|
+
lines.join('\n'));
|
|
2900
|
+
}
|
|
2788
2901
|
/**
|
|
2789
2902
|
* Assembles the same memory/context block a loop agent injects, reusing
|
|
2790
2903
|
* {@link AgentMemoryContextBuilder} so there is no duplicated retrieval logic. The builder
|
|
@@ -2920,7 +3033,7 @@ export class RealtimeClientSessionService {
|
|
|
2920
3033
|
buildToolBroker(input, contextUser, provider) {
|
|
2921
3034
|
const deps = {
|
|
2922
3035
|
DelegateToTarget: (request) => this.delegateToTarget(input, request, contextUser, provider),
|
|
2923
|
-
ExecuteTool: (call) => this.executeNonTargetTool(call, input, contextUser)
|
|
3036
|
+
ExecuteTool: (call) => this.executeNonTargetTool(call, input, contextUser, provider)
|
|
2924
3037
|
};
|
|
2925
3038
|
return new RealtimeToolBroker(deps);
|
|
2926
3039
|
}
|
|
@@ -2950,6 +3063,9 @@ export class RealtimeClientSessionService {
|
|
|
2950
3063
|
try {
|
|
2951
3064
|
const result = await this.runDelegatedAgent(input, request, resolution.Agent, contextUser, provider);
|
|
2952
3065
|
const artifacts = await this.createDelegatedRunArtifacts(result, contextUser, provider);
|
|
3066
|
+
if (artifacts?.length && input.AgentSessionID?.trim()) {
|
|
3067
|
+
this.RecordSessionArtifacts(input.AgentSessionID, artifacts);
|
|
3068
|
+
}
|
|
2953
3069
|
return this.buildDelegatedResult(request.CallID, result, artifacts);
|
|
2954
3070
|
}
|
|
2955
3071
|
catch (error) {
|
|
@@ -3049,8 +3165,9 @@ export class RealtimeClientSessionService {
|
|
|
3049
3165
|
async createDelegatedRunArtifacts(result, contextUser, provider) {
|
|
3050
3166
|
const paused = result.agentRun?.Status === 'AwaitingFeedback';
|
|
3051
3167
|
const payload = result.payload;
|
|
3052
|
-
const hasPayload = payload != null && Object.keys(payload).length > 0;
|
|
3053
|
-
|
|
3168
|
+
const hasPayload = payload != null && typeof payload === 'object' && Object.keys(payload).length > 0;
|
|
3169
|
+
const hasTouched = (result.touchedArtifacts?.length ?? 0) > 0;
|
|
3170
|
+
if (!hasTouched && (!result.success || paused || !hasPayload)) {
|
|
3054
3171
|
return undefined;
|
|
3055
3172
|
}
|
|
3056
3173
|
try {
|
|
@@ -3063,35 +3180,25 @@ export class RealtimeClientSessionService {
|
|
|
3063
3180
|
}
|
|
3064
3181
|
}
|
|
3065
3182
|
/**
|
|
3066
|
-
* The DB-backed artifact-creation seam:
|
|
3067
|
-
*
|
|
3068
|
-
*
|
|
3069
|
-
*
|
|
3070
|
-
* Artifacts whose Visibility resolved to `System Only` (the agent's ArtifactCreationMode) are
|
|
3071
|
-
* created but NOT surfaced to the overlay — matching how chat hides them from users.
|
|
3072
|
-
*
|
|
3073
|
-
* **Overridable seam** so tests can exercise {@link createDelegatedRunArtifacts}' eligibility
|
|
3074
|
-
* guards without a DB.
|
|
3075
|
-
*
|
|
3076
|
-
* @param result The delegated agent execution result (payload + agentRun).
|
|
3077
|
-
* @param contextUser The calling user.
|
|
3078
|
-
* @param provider The request-scoped metadata provider.
|
|
3079
|
-
* @returns The produced artifact descriptor(s), or `undefined`.
|
|
3183
|
+
* The DB-backed artifact-creation seam: surfaces collaborative artifacts touched during the run
|
|
3184
|
+
* (`result.touchedArtifacts`) plus any payload artifact created by `AgentRunner.ProcessAgentArtifacts`
|
|
3185
|
+
* (without a conversation detail on voice paths). Payload artifacts are created only on completed,
|
|
3186
|
+
* successful runs (paused/failed runs still surface touched governed artifacts).
|
|
3080
3187
|
*/
|
|
3081
3188
|
async processRunArtifacts(result, contextUser, provider) {
|
|
3189
|
+
const paused = result.agentRun?.Status === 'AwaitingFeedback';
|
|
3190
|
+
const canProcessPayload = result.success && !paused;
|
|
3082
3191
|
const runner = new AgentRunner(provider);
|
|
3083
|
-
|
|
3084
|
-
|
|
3085
|
-
|
|
3086
|
-
|
|
3087
|
-
|
|
3088
|
-
|
|
3089
|
-
|
|
3090
|
-
|
|
3091
|
-
|
|
3092
|
-
|
|
3093
|
-
}
|
|
3094
|
-
return [{ ArtifactID: info.artifactId, ArtifactVersionID: info.versionId, Name: artifact.Name }];
|
|
3192
|
+
return CollectDelegatedRunArtifacts({
|
|
3193
|
+
Result: result,
|
|
3194
|
+
ContextUser: contextUser,
|
|
3195
|
+
Provider: provider,
|
|
3196
|
+
...(canProcessPayload
|
|
3197
|
+
? {
|
|
3198
|
+
ProcessPayloadArtifacts: (r) => runner.ProcessAgentArtifacts(r, undefined, undefined, contextUser, provider),
|
|
3199
|
+
}
|
|
3200
|
+
: {}),
|
|
3201
|
+
});
|
|
3095
3202
|
}
|
|
3096
3203
|
/**
|
|
3097
3204
|
* Runs (or resumes) the target agent for a delegation. Threads the combined abort signal, parent
|
|
@@ -3114,6 +3221,41 @@ export class RealtimeClientSessionService {
|
|
|
3114
3221
|
const parentRun = await this.loadParentRun(input.ParentRunID, contextUser, provider);
|
|
3115
3222
|
const runner = new AgentRunner(provider);
|
|
3116
3223
|
const combined = this.combineSignals(request.AbortSignal, input.AbortSignal);
|
|
3224
|
+
const sessionKey = input.AgentSessionID?.trim();
|
|
3225
|
+
const sessionSummaries = sessionKey
|
|
3226
|
+
? this.RecordSessionArtifacts(sessionKey, input.ConversationArtifacts)
|
|
3227
|
+
: (input.ConversationArtifacts ?? []);
|
|
3228
|
+
const effectiveConversationId = input.ConversationID?.trim() || (sessionKey ? this.sessionConversationIds.Get(sessionKey) : undefined);
|
|
3229
|
+
const resolvedInputArtifacts = [];
|
|
3230
|
+
for (const summary of sessionSummaries) {
|
|
3231
|
+
try {
|
|
3232
|
+
const loaded = await GovernedArtifactService.Instance.LoadReadableArtifactState(provider, contextUser, summary.ArtifactID);
|
|
3233
|
+
if (loaded.state) {
|
|
3234
|
+
const st = loaded.state;
|
|
3235
|
+
resolvedInputArtifacts.push({
|
|
3236
|
+
name: st.name,
|
|
3237
|
+
typeName: st.typeName,
|
|
3238
|
+
content: st.content,
|
|
3239
|
+
artifactId: st.artifactId,
|
|
3240
|
+
...(st.versionId ? { versionId: st.versionId } : {}),
|
|
3241
|
+
versionNumber: st.versionNumber,
|
|
3242
|
+
...(st.description ? { description: st.description } : {}),
|
|
3243
|
+
...(st.mimeType ? { mimeType: st.mimeType } : {}),
|
|
3244
|
+
...(st.toolLibraryClass ? { toolLibraryClass: st.toolLibraryClass } : {}),
|
|
3245
|
+
});
|
|
3246
|
+
}
|
|
3247
|
+
}
|
|
3248
|
+
catch {
|
|
3249
|
+
// Non-fatal: individual unreadable/evicted artifact does not abort delegated run
|
|
3250
|
+
}
|
|
3251
|
+
}
|
|
3252
|
+
const runData = {};
|
|
3253
|
+
if (input.AppContext) {
|
|
3254
|
+
runData.appContext = input.AppContext;
|
|
3255
|
+
}
|
|
3256
|
+
if (sessionSummaries.length > 0) {
|
|
3257
|
+
runData.conversationArtifacts = sessionSummaries;
|
|
3258
|
+
}
|
|
3117
3259
|
try {
|
|
3118
3260
|
return await runner.RunAgent({
|
|
3119
3261
|
agent: target,
|
|
@@ -3128,16 +3270,35 @@ export class RealtimeClientSessionService {
|
|
|
3128
3270
|
parentRun: parentRun ?? undefined,
|
|
3129
3271
|
agentSessionID: input.AgentSessionID,
|
|
3130
3272
|
sessionID: input.BrowserSessionID,
|
|
3131
|
-
|
|
3273
|
+
...(effectiveConversationId ? { conversationId: effectiveConversationId } : {}),
|
|
3274
|
+
...(resolvedInputArtifacts.length > 0 ? { inputArtifacts: resolvedInputArtifacts } : {}),
|
|
3275
|
+
data: Object.keys(runData).length > 0 ? runData : undefined,
|
|
3132
3276
|
onProgress: input.OnProgress,
|
|
3133
3277
|
lastRunId: input.ResumeRunID,
|
|
3134
|
-
autoPopulateLastRunPayload: input.ResumeRunID ? true : undefined
|
|
3278
|
+
autoPopulateLastRunPayload: input.ResumeRunID ? true : undefined,
|
|
3279
|
+
// The session's run scope and active skills (#5624), as BaseAgent hands a sub-agent its own.
|
|
3280
|
+
...this.delegatedRunScope(input)
|
|
3135
3281
|
});
|
|
3136
3282
|
}
|
|
3137
3283
|
finally {
|
|
3138
3284
|
combined.Dispose();
|
|
3139
3285
|
}
|
|
3140
3286
|
}
|
|
3287
|
+
/**
|
|
3288
|
+
* The scope a delegated target-agent run starts with: the session's ({@link ExecuteRelayedToolInput.RunScope}) and
|
|
3289
|
+
* its active skills, in the `ExecuteAgentParams` fields BaseAgent propagates to a sub-agent. Nothing for a session
|
|
3290
|
+
* with no scope, so the delegated run is unscoped, as before.
|
|
3291
|
+
*/
|
|
3292
|
+
delegatedRunScope(input) {
|
|
3293
|
+
const scope = input.RunScope;
|
|
3294
|
+
return {
|
|
3295
|
+
...(scope?.PrimaryScopeEntityName ? { PrimaryScopeEntityName: scope.PrimaryScopeEntityName } : {}),
|
|
3296
|
+
...(scope?.PrimaryScopeRecordID ? { PrimaryScopeRecordID: scope.PrimaryScopeRecordID } : {}),
|
|
3297
|
+
...(scope?.SecondaryScopes ? { SecondaryScopes: { ...scope.SecondaryScopes } } : {}),
|
|
3298
|
+
...(scope?.SearchScopeIDs?.length ? { SearchScopeIDs: [...scope.SearchScopeIDs] } : {}),
|
|
3299
|
+
...(input.ActiveSkillIDs?.length ? { parentActivatedSkillIDs: [...input.ActiveSkillIDs] } : {}),
|
|
3300
|
+
};
|
|
3301
|
+
}
|
|
3141
3302
|
/**
|
|
3142
3303
|
* Maps an {@link ExecuteAgentResult} onto the broker's {@link DelegatedResult}, special-casing a
|
|
3143
3304
|
* run that paused awaiting feedback. An `AwaitingFeedback` run is a valid intermediate outcome,
|
|
@@ -3160,7 +3321,8 @@ export class RealtimeClientSessionService {
|
|
|
3160
3321
|
Success: true,
|
|
3161
3322
|
Output: `You need an answer from the user before you can continue this work. Ask them, in your own first-person voice: ${question}`,
|
|
3162
3323
|
PausedRunID: result.agentRun.ID,
|
|
3163
|
-
RunID: result.agentRun.ID
|
|
3324
|
+
RunID: result.agentRun.ID,
|
|
3325
|
+
...(artifacts ? { Artifacts: artifacts } : {}),
|
|
3164
3326
|
};
|
|
3165
3327
|
}
|
|
3166
3328
|
return {
|
|
@@ -3315,6 +3477,32 @@ export class RealtimeClientSessionService {
|
|
|
3315
3477
|
type: schemaType,
|
|
3316
3478
|
description: p.Description || p.Name
|
|
3317
3479
|
};
|
|
3480
|
+
if (p.IsArray) {
|
|
3481
|
+
const lowerName = p.Name.trim().toLowerCase();
|
|
3482
|
+
if (lowerName === 'operations' || lowerName === 'initialoperations') {
|
|
3483
|
+
propSchema.items = {
|
|
3484
|
+
type: 'object',
|
|
3485
|
+
description: 'Single governed artifact tool invocation inside the array.',
|
|
3486
|
+
properties: {
|
|
3487
|
+
tool: {
|
|
3488
|
+
type: 'string',
|
|
3489
|
+
description: 'Exact artifact tool name, e.g. "write_cells", "insert_block_after", "add_slide".'
|
|
3490
|
+
},
|
|
3491
|
+
input: {
|
|
3492
|
+
type: 'object',
|
|
3493
|
+
description: 'JSON arguments object matching the selected tool\'s inputSchema.'
|
|
3494
|
+
}
|
|
3495
|
+
},
|
|
3496
|
+
required: ['tool']
|
|
3497
|
+
};
|
|
3498
|
+
}
|
|
3499
|
+
else if (p.ValueType === 'Simple Object' || p.ValueType === 'BaseEntity Sub-Class') {
|
|
3500
|
+
propSchema.items = { type: 'object' };
|
|
3501
|
+
}
|
|
3502
|
+
else {
|
|
3503
|
+
propSchema.items = { type: 'string' };
|
|
3504
|
+
}
|
|
3505
|
+
}
|
|
3318
3506
|
properties[p.Name] = propSchema;
|
|
3319
3507
|
if (p.IsRequired) {
|
|
3320
3508
|
required.push(p.Name);
|
|
@@ -3349,7 +3537,7 @@ export class RealtimeClientSessionService {
|
|
|
3349
3537
|
* @param contextUser The calling user context.
|
|
3350
3538
|
* @returns A {@link ToolExecutionResult} for the model's tool_response.
|
|
3351
3539
|
*/
|
|
3352
|
-
async executeNonTargetTool(call, input, contextUser) {
|
|
3540
|
+
async executeNonTargetTool(call, input, contextUser, provider) {
|
|
3353
3541
|
if (!input?.TargetAgentID) {
|
|
3354
3542
|
return {
|
|
3355
3543
|
CallID: call.CallID,
|
|
@@ -3406,7 +3594,19 @@ export class RealtimeClientSessionService {
|
|
|
3406
3594
|
runParams.ContextUser = executingUser;
|
|
3407
3595
|
runParams.Params = actionParams;
|
|
3408
3596
|
runParams.Filters = [];
|
|
3409
|
-
|
|
3597
|
+
if (provider) {
|
|
3598
|
+
runParams.Provider = provider;
|
|
3599
|
+
}
|
|
3600
|
+
// The session's run scope and active skills, as BaseAgent stamps them on every action call in a run
|
|
3601
|
+
// (#5624). The arguments are model-written, so without them a Scoped Search here runs as a direct call
|
|
3602
|
+
// and searches whatever tenant and skill the model names.
|
|
3603
|
+
runParams.RunScope = this.directToolRunScope(input);
|
|
3604
|
+
runParams.Context = {
|
|
3605
|
+
AgentID: target.ID,
|
|
3606
|
+
AgentName: target.Name,
|
|
3607
|
+
...(input.ParentRunID ? { AgentRunID: input.ParentRunID } : {}),
|
|
3608
|
+
ActiveSkillIDs: [...(input.ActiveSkillIDs ?? [])]
|
|
3609
|
+
};
|
|
3410
3610
|
let timerHandle;
|
|
3411
3611
|
const timeoutPromise = new Promise((_, reject) => {
|
|
3412
3612
|
timerHandle = setTimeout(() => {
|
|
@@ -3425,10 +3625,15 @@ export class RealtimeClientSessionService {
|
|
|
3425
3625
|
}
|
|
3426
3626
|
});
|
|
3427
3627
|
const outputText = result.Message || (result.Success ? 'Action completed successfully.' : 'Action failed.');
|
|
3628
|
+
const actionArtifacts = ExtractDirectActionArtifacts(action.Name, result.Success, result.Params);
|
|
3629
|
+
if (actionArtifacts?.length && input.AgentSessionID?.trim()) {
|
|
3630
|
+
this.RecordSessionArtifacts(input.AgentSessionID, actionArtifacts);
|
|
3631
|
+
}
|
|
3428
3632
|
return {
|
|
3429
3633
|
CallID: call.CallID,
|
|
3430
3634
|
Success: result.Success,
|
|
3431
|
-
Output: outputText
|
|
3635
|
+
Output: outputText,
|
|
3636
|
+
...(actionArtifacts ? { Artifacts: actionArtifacts } : {})
|
|
3432
3637
|
};
|
|
3433
3638
|
}
|
|
3434
3639
|
catch (error) {
|
|
@@ -3440,6 +3645,21 @@ export class RealtimeClientSessionService {
|
|
|
3440
3645
|
};
|
|
3441
3646
|
}
|
|
3442
3647
|
}
|
|
3648
|
+
/**
|
|
3649
|
+
* The `RunScope` a direct tool call carries: the session's ({@link ExecuteRelayedToolInput.RunScope}), copied so
|
|
3650
|
+
* an action cannot change what the next call sees, or an unscoped run's (every field null) when the session has
|
|
3651
|
+
* none. Never absent: an absent `RunScope` tells an action it is called outside any run.
|
|
3652
|
+
*/
|
|
3653
|
+
directToolRunScope(input) {
|
|
3654
|
+
const scope = input.RunScope;
|
|
3655
|
+
if (!scope) {
|
|
3656
|
+
return { PrimaryScopeEntityName: null, PrimaryScopeRecordID: null, SecondaryScopes: null };
|
|
3657
|
+
}
|
|
3658
|
+
const secondary = scope.SecondaryScopes
|
|
3659
|
+
? Object.fromEntries(Object.entries(scope.SecondaryScopes).map(([key, value]) => [key, Array.isArray(value) ? [...value] : value]))
|
|
3660
|
+
: null;
|
|
3661
|
+
return { ...scope, SecondaryScopes: secondary, ...(scope.SearchScopeIDs ? { SearchScopeIDs: [...scope.SearchScopeIDs] } : {}) };
|
|
3662
|
+
}
|
|
3443
3663
|
/**
|
|
3444
3664
|
* Finds the action a relayed tool name refers to: the exact wire name first, then a
|
|
3445
3665
|
* case-insensitive match.
|