@memberjunction/ai-agents 6.2.0-edge.3 → 6.2.0-edge.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (182) hide show
  1. package/README.md +100 -7
  2. package/dist/AgentRunner.d.ts +55 -5
  3. package/dist/AgentRunner.d.ts.map +1 -1
  4. package/dist/AgentRunner.js +277 -59
  5. package/dist/AgentRunner.js.map +1 -1
  6. package/dist/ArtifactToolManager.d.ts +11 -3
  7. package/dist/ArtifactToolManager.d.ts.map +1 -1
  8. package/dist/ArtifactToolManager.js +72 -6
  9. package/dist/ArtifactToolManager.js.map +1 -1
  10. package/dist/ClientToolRequestManager.d.ts +11 -1
  11. package/dist/ClientToolRequestManager.d.ts.map +1 -1
  12. package/dist/ClientToolRequestManager.js +19 -6
  13. package/dist/ClientToolRequestManager.js.map +1 -1
  14. package/dist/ConversationCompactionManager.d.ts +2 -0
  15. package/dist/ConversationCompactionManager.d.ts.map +1 -1
  16. package/dist/ConversationCompactionManager.js +2 -2
  17. package/dist/ConversationCompactionManager.js.map +1 -1
  18. package/dist/ConversationToolManager.d.ts +13 -2
  19. package/dist/ConversationToolManager.d.ts.map +1 -1
  20. package/dist/ConversationToolManager.js +19 -3
  21. package/dist/ConversationToolManager.js.map +1 -1
  22. package/dist/KnowledgeAgent.d.ts.map +1 -1
  23. package/dist/KnowledgeAgent.js +6 -1
  24. package/dist/KnowledgeAgent.js.map +1 -1
  25. package/dist/MJAIAgentRequestEntityServer.d.ts +6 -0
  26. package/dist/MJAIAgentRequestEntityServer.d.ts.map +1 -1
  27. package/dist/MJAIAgentRequestEntityServer.js +26 -1
  28. package/dist/MJAIAgentRequestEntityServer.js.map +1 -1
  29. package/dist/PayloadChangeAnalyzer.d.ts.map +1 -1
  30. package/dist/PayloadChangeAnalyzer.js +53 -30
  31. package/dist/PayloadChangeAnalyzer.js.map +1 -1
  32. package/dist/PayloadManager.d.ts +35 -2
  33. package/dist/PayloadManager.d.ts.map +1 -1
  34. package/dist/PayloadManager.js +250 -149
  35. package/dist/PayloadManager.js.map +1 -1
  36. package/dist/ScratchpadManager.d.ts +18 -0
  37. package/dist/ScratchpadManager.d.ts.map +1 -1
  38. package/dist/ScratchpadManager.js +61 -0
  39. package/dist/ScratchpadManager.js.map +1 -1
  40. package/dist/agent-audience.d.ts +38 -0
  41. package/dist/agent-audience.d.ts.map +1 -0
  42. package/dist/agent-audience.js +99 -0
  43. package/dist/agent-audience.js.map +1 -0
  44. package/dist/agent-context-injector.d.ts +17 -2
  45. package/dist/agent-context-injector.d.ts.map +1 -1
  46. package/dist/agent-context-injector.js +23 -7
  47. package/dist/agent-context-injector.js.map +1 -1
  48. package/dist/agent-memory-context-builder.d.ts +7 -2
  49. package/dist/agent-memory-context-builder.d.ts.map +1 -1
  50. package/dist/agent-memory-context-builder.js +12 -3
  51. package/dist/agent-memory-context-builder.js.map +1 -1
  52. package/dist/agent-pre-execution-rag.d.ts +101 -9
  53. package/dist/agent-pre-execution-rag.d.ts.map +1 -1
  54. package/dist/agent-pre-execution-rag.js +224 -23
  55. package/dist/agent-pre-execution-rag.js.map +1 -1
  56. package/dist/agent-run-watchdog.d.ts +65 -5
  57. package/dist/agent-run-watchdog.d.ts.map +1 -1
  58. package/dist/agent-run-watchdog.js +143 -28
  59. package/dist/agent-run-watchdog.js.map +1 -1
  60. package/dist/agent-types/flow-agent-type.d.ts +8 -0
  61. package/dist/agent-types/flow-agent-type.d.ts.map +1 -1
  62. package/dist/agent-types/flow-agent-type.js +48 -6
  63. package/dist/agent-types/flow-agent-type.js.map +1 -1
  64. package/dist/agent-types/loop-agent-prompt-params.d.ts +7 -0
  65. package/dist/agent-types/loop-agent-prompt-params.d.ts.map +1 -1
  66. package/dist/agent-types/loop-agent-prompt-params.js +1 -0
  67. package/dist/agent-types/loop-agent-prompt-params.js.map +1 -1
  68. package/dist/agent-types/loop-agent-response-type.d.ts +8 -2
  69. package/dist/agent-types/loop-agent-response-type.d.ts.map +1 -1
  70. package/dist/agent-types/loop-agent-response-type.js.map +1 -1
  71. package/dist/agent-types/loop-agent-type.d.ts +9 -2
  72. package/dist/agent-types/loop-agent-type.d.ts.map +1 -1
  73. package/dist/agent-types/loop-agent-type.js +60 -16
  74. package/dist/agent-types/loop-agent-type.js.map +1 -1
  75. package/dist/artifact-tools/SearchResultSetToolLibrary.js +4 -4
  76. package/dist/artifact-tools/SearchResultSetToolLibrary.js.map +1 -1
  77. package/dist/base-agent.d.ts +837 -43
  78. package/dist/base-agent.d.ts.map +1 -1
  79. package/dist/base-agent.js +3081 -663
  80. package/dist/base-agent.js.map +1 -1
  81. package/dist/client-tool-results.d.ts +45 -0
  82. package/dist/client-tool-results.d.ts.map +1 -0
  83. package/dist/client-tool-results.js +94 -0
  84. package/dist/client-tool-results.js.map +1 -0
  85. package/dist/index.d.ts +9 -0
  86. package/dist/index.d.ts.map +1 -1
  87. package/dist/index.js +9 -0
  88. package/dist/index.js.map +1 -1
  89. package/dist/memory-manager-agent.d.ts.map +1 -1
  90. package/dist/memory-manager-agent.js +46 -34
  91. package/dist/memory-manager-agent.js.map +1 -1
  92. package/dist/native-tools/action-param-schema.d.ts +57 -0
  93. package/dist/native-tools/action-param-schema.d.ts.map +1 -0
  94. package/dist/native-tools/action-param-schema.js +238 -0
  95. package/dist/native-tools/action-param-schema.js.map +1 -0
  96. package/dist/native-tools/action-tool-builder.d.ts +5 -4
  97. package/dist/native-tools/action-tool-builder.d.ts.map +1 -1
  98. package/dist/native-tools/action-tool-builder.js +29 -71
  99. package/dist/native-tools/action-tool-builder.js.map +1 -1
  100. package/dist/native-tools/json-argument.d.ts +41 -0
  101. package/dist/native-tools/json-argument.d.ts.map +1 -0
  102. package/dist/native-tools/json-argument.js +79 -0
  103. package/dist/native-tools/json-argument.js.map +1 -0
  104. package/dist/prior-turn-tool-result-cache.d.ts +31 -12
  105. package/dist/prior-turn-tool-result-cache.d.ts.map +1 -1
  106. package/dist/prior-turn-tool-result-cache.js +59 -16
  107. package/dist/prior-turn-tool-result-cache.js.map +1 -1
  108. package/dist/query-builder-agent.d.ts +13 -4
  109. package/dist/query-builder-agent.d.ts.map +1 -1
  110. package/dist/query-builder-agent.js +102 -27
  111. package/dist/query-builder-agent.js.map +1 -1
  112. package/dist/realtime/bridge-realtime-session-factory.d.ts +44 -2
  113. package/dist/realtime/bridge-realtime-session-factory.d.ts.map +1 -1
  114. package/dist/realtime/bridge-realtime-session-factory.js +68 -20
  115. package/dist/realtime/bridge-realtime-session-factory.js.map +1 -1
  116. package/dist/realtime/bridge-realtime-usage-recorder.d.ts +81 -0
  117. package/dist/realtime/bridge-realtime-usage-recorder.d.ts.map +1 -0
  118. package/dist/realtime/bridge-realtime-usage-recorder.js +194 -0
  119. package/dist/realtime/bridge-realtime-usage-recorder.js.map +1 -0
  120. package/dist/realtime/client-only-channel-server.d.ts +83 -0
  121. package/dist/realtime/client-only-channel-server.d.ts.map +1 -0
  122. package/dist/realtime/client-only-channel-server.js +107 -0
  123. package/dist/realtime/client-only-channel-server.js.map +1 -0
  124. package/dist/realtime/identity-verification-channel-server.d.ts +50 -0
  125. package/dist/realtime/identity-verification-channel-server.d.ts.map +1 -0
  126. package/dist/realtime/identity-verification-channel-server.js +66 -0
  127. package/dist/realtime/identity-verification-channel-server.js.map +1 -0
  128. package/dist/realtime/interactive-component-channel-server.d.ts +39 -0
  129. package/dist/realtime/interactive-component-channel-server.d.ts.map +1 -0
  130. package/dist/realtime/interactive-component-channel-server.js +55 -0
  131. package/dist/realtime/interactive-component-channel-server.js.map +1 -0
  132. package/dist/realtime/realtime-avatar-resolution.d.ts +194 -0
  133. package/dist/realtime/realtime-avatar-resolution.d.ts.map +1 -0
  134. package/dist/realtime/realtime-avatar-resolution.js +208 -0
  135. package/dist/realtime/realtime-avatar-resolution.js.map +1 -0
  136. package/dist/realtime/realtime-channel-policy.d.ts +81 -0
  137. package/dist/realtime/realtime-channel-policy.d.ts.map +1 -0
  138. package/dist/realtime/realtime-channel-policy.js +91 -0
  139. package/dist/realtime/realtime-channel-policy.js.map +1 -0
  140. package/dist/realtime/realtime-channel-server-host.d.ts +14 -0
  141. package/dist/realtime/realtime-channel-server-host.d.ts.map +1 -1
  142. package/dist/realtime/realtime-channel-server-host.js +35 -0
  143. package/dist/realtime/realtime-channel-server-host.js.map +1 -1
  144. package/dist/realtime/realtime-client-session-service.d.ts +435 -34
  145. package/dist/realtime/realtime-client-session-service.d.ts.map +1 -1
  146. package/dist/realtime/realtime-client-session-service.js +806 -139
  147. package/dist/realtime/realtime-client-session-service.js.map +1 -1
  148. package/dist/realtime/realtime-coagent-config.d.ts +102 -16
  149. package/dist/realtime/realtime-coagent-config.d.ts.map +1 -1
  150. package/dist/realtime/realtime-coagent-config.js +126 -5
  151. package/dist/realtime/realtime-coagent-config.js.map +1 -1
  152. package/dist/realtime/realtime-recording-ledger.d.ts +130 -0
  153. package/dist/realtime/realtime-recording-ledger.d.ts.map +1 -0
  154. package/dist/realtime/realtime-recording-ledger.js +190 -0
  155. package/dist/realtime/realtime-recording-ledger.js.map +1 -0
  156. package/dist/realtime/realtime-recording-opus-assembly.d.ts +211 -0
  157. package/dist/realtime/realtime-recording-opus-assembly.d.ts.map +1 -0
  158. package/dist/realtime/realtime-recording-opus-assembly.js +706 -0
  159. package/dist/realtime/realtime-recording-opus-assembly.js.map +1 -0
  160. package/dist/realtime/realtime-recording-store.d.ts +174 -17
  161. package/dist/realtime/realtime-recording-store.d.ts.map +1 -1
  162. package/dist/realtime/realtime-recording-store.js +552 -58
  163. package/dist/realtime/realtime-recording-store.js.map +1 -1
  164. package/dist/realtime/realtime-session-runner.js +4 -4
  165. package/dist/realtime/realtime-session-runner.js.map +1 -1
  166. package/dist/realtime/realtime-turn-moderator.d.ts +2 -1
  167. package/dist/realtime/realtime-turn-moderator.d.ts.map +1 -1
  168. package/dist/realtime/realtime-turn-moderator.js +7 -1
  169. package/dist/realtime/realtime-turn-moderator.js.map +1 -1
  170. package/dist/realtime/realtime-vendor-resolution.d.ts +9 -0
  171. package/dist/realtime/realtime-vendor-resolution.d.ts.map +1 -1
  172. package/dist/realtime/realtime-vendor-resolution.js +16 -5
  173. package/dist/realtime/realtime-vendor-resolution.js.map +1 -1
  174. package/dist/realtime/realtime-video-output-gate.d.ts +83 -0
  175. package/dist/realtime/realtime-video-output-gate.d.ts.map +1 -0
  176. package/dist/realtime/realtime-video-output-gate.js +79 -0
  177. package/dist/realtime/realtime-video-output-gate.js.map +1 -0
  178. package/dist/tool-result-format.d.ts +14 -0
  179. package/dist/tool-result-format.d.ts.map +1 -1
  180. package/dist/tool-result-format.js.map +1 -1
  181. package/dist/volatile-child-prompt.js +3 -3
  182. package/package.json +21 -19
@@ -11,9 +11,9 @@
11
11
  */
12
12
  import { createHash } from 'crypto';
13
13
  import { LogError, LogStatusEx, IsVerboseLoggingEnabled, LogStatus, Metadata, RunView, RunQuery, ProviderType } from '@memberjunction/core';
14
- import { MJGlobal, UUIDsEqual, IsValidUUID, EscapeSQLString } from '@memberjunction/global';
14
+ import { MJGlobal, UUIDsEqual, IsValidUUID, EscapeSQLString, IndexByUUID } from '@memberjunction/global';
15
15
  import { AIEngine } from '@memberjunction/aiengine';
16
- import { ResolvePromptRunUserID } from '@memberjunction/ai-core-plus';
16
+ import { ResolvePromptRunUserID, WithAgentRunDataTrustApplied } from '@memberjunction/ai-core-plus';
17
17
  import { PlanArtifactTarget, IsKnownArtifactBehavior } from './artifact-target-plan.js';
18
18
  import { BaseAgent } from './base-agent.js';
19
19
  import { MJEnvironmentEntityExtended, ArtifactMetadataEngine, ConversationEngine, ExtractBase64FromDataUrl, DecideInlineStorage } from '@memberjunction/core-entities';
@@ -53,6 +53,28 @@ export function selectPrimaryArtifact(fileArtifacts, payloadArtifact) {
53
53
  * ```
54
54
  */
55
55
  export class AgentRunner {
56
+ /**
57
+ * The status and message the agent's reply detail ends with, from the run's result.
58
+ *
59
+ * A run the user stopped is not an error: its reply is marked Complete with a short "stopped"
60
+ * message, so the chat shows a quiet end rather than a red failure, and the run row (Cancelled,
61
+ * with its reason and the payload as it stood) carries the detail. Every other outcome keeps the
62
+ * long-standing mapping: the run's message when it wrote one, else Completed or the error.
63
+ */
64
+ static ResolveFinalDetailState(agentResult) {
65
+ const run = agentResult.agentRun;
66
+ if (run?.Status === 'Cancelled') {
67
+ const byUser = run.CancellationReason === 'User Request';
68
+ return {
69
+ Status: 'Complete',
70
+ Message: byUser ? 'Stopped by user' : `Stopped: ${run.ErrorMessage || 'the run was cancelled'}`,
71
+ };
72
+ }
73
+ return {
74
+ Status: agentResult.success ? 'Complete' : 'Error',
75
+ Message: run?.Message || (agentResult.success ? '✅ Completed' : run?.ErrorMessage || '❌ Failed'),
76
+ };
77
+ }
56
78
  /**
57
79
  * Why a conversation-detail `Save()` returned false, for an error or log line. The owner gate in
58
80
  * `MJConversationDetailEntityExtended` refuses a non-owner's write (e.g. the elevated System user
@@ -64,6 +86,8 @@ export class AgentRunner {
64
86
  }
65
87
  /** Fallback artifact type for agent payloads when the agent declares no DefaultArtifactTypeID. */
66
88
  static { this.JSON_ARTIFACT_TYPE_ID = 'ae674c7e-ea0d-49ea-89e4-0649f5eb20d4'; }
89
+ /** Artifact type for structured research report payloads containing `{ report: { html } }`. */
90
+ static { this.RESEARCH_CONTENT_ARTIFACT_TYPE_ID = 'a7b8c9d0-e1f2-3a4b-5c6d-7e8f9a0b1c2d'; }
67
91
  /**
68
92
  * Max length of `MJ: Artifacts.Name` (`nvarchar(255)`).
69
93
  *
@@ -116,12 +140,34 @@ export class AgentRunner {
116
140
  if (!agentInstance) {
117
141
  throw new Error(`Failed to create agent instance for driver class: ${driverClass}`);
118
142
  }
143
+ // Ensure caller params carries the shared AgentTreeBudget reference before any shallow
144
+ // clone occurs in hydrateConversationArtifacts or Execute.
145
+ if (!params.treeBudget) {
146
+ params.treeBudget = {
147
+ maxTreeSteps: params.maxTreeSteps,
148
+ maxTreeTokens: params.maxTreeTokens,
149
+ maxTreeCost: params.maxTreeCost,
150
+ maxTreeDurationMs: params.maxTreeDurationMs,
151
+ totalSteps: 0,
152
+ totalTokens: 0,
153
+ totalCost: 0,
154
+ startedAtMs: Date.now()
155
+ };
156
+ }
119
157
  // A conversation-linked run must see the conversation's artifacts no matter which
120
158
  // entry point the caller used. See hydrateConversationArtifacts for why.
121
159
  const runParams = await this.hydrateConversationArtifacts(params);
160
+ runParams.treeBudget = params.treeBudget;
122
161
  // Execute the agent and return the result directly, threading the isolated provider.
123
162
  // Favor provider already in params (caller-supplied) over the instance-level provider.
124
- return await agentInstance.Execute({ ...runParams, provider: runParams.provider || this._provider });
163
+ try {
164
+ return await agentInstance.Execute({ ...runParams, provider: runParams.provider || this._provider });
165
+ }
166
+ finally {
167
+ if (agentInstance.TreeBudget) {
168
+ params.treeBudget = agentInstance.TreeBudget;
169
+ }
170
+ }
125
171
  }
126
172
  catch (error) {
127
173
  const errorMessage = error instanceof Error ? error.message : 'Unknown error occurred';
@@ -257,6 +303,7 @@ export class AgentRunner {
257
303
  userMessageDetail.Role = 'User';
258
304
  userMessageDetail.UserID = contextUser.ID;
259
305
  userMessageDetail.HiddenToUser = false;
306
+ userMessageDetail.BranchID = params.ConversationBranchID ?? null;
260
307
  // Link to test run if provided (for test execution traceability)
261
308
  if (options.testRunId) {
262
309
  userMessageDetail.TestRunID = options.testRunId;
@@ -275,6 +322,7 @@ export class AgentRunner {
275
322
  agentResponseDetail.Status = 'In-Progress';
276
323
  agentResponseDetail.HiddenToUser = false;
277
324
  agentResponseDetail.AgentID = params.agent.ID;
325
+ agentResponseDetail.BranchID = params.ConversationBranchID ?? null;
278
326
  // Link to test run if provided (for test execution traceability)
279
327
  if (options.testRunId) {
280
328
  agentResponseDetail.TestRunID = options.testRunId;
@@ -290,6 +338,13 @@ export class AgentRunner {
290
338
  // Flag to prevent late progress callbacks from overwriting final status
291
339
  // Progress callbacks fire async and may complete AFTER agent returns
292
340
  let agentExecutionCompleted = false;
341
+ // Progress saves run one at a time on this chain, and the final update awaits it.
342
+ // EnsureSaveComplete() alone is not enough: it resolves on the entity's 'save' event,
343
+ // which BaseEntity raises before the save finishes committing, so a progress save
344
+ // can still be in flight when the final update calls Save(). BaseEntity.Save() hands
345
+ // a concurrent caller the in-flight save's promise, so the final status was dropped
346
+ // and the detail stayed 'In-Progress' with the last progress message.
347
+ let progressSaves = Promise.resolve();
293
348
  // Wrap progress callback to update agent response detail
294
349
  const originalOnProgress = params.onProgress;
295
350
  const wrappedOnProgress = agentResponseDetail
@@ -305,11 +360,21 @@ export class AgentRunner {
305
360
  }
306
361
  // Update the agent response detail with progress message
307
362
  if (agentResponseDetail && progress.message) {
308
- agentResponseDetail.Message = progress.message;
309
- const saved = await agentResponseDetail.Save();
310
- if (!saved) {
311
- LogError(`Failed to save agent response detail progress update: ${AgentRunner.saveFailureReason(agentResponseDetail)}`);
312
- }
363
+ const detail = agentResponseDetail;
364
+ const message = progress.message;
365
+ progressSaves = progressSaves.then(async () => {
366
+ try {
367
+ detail.Message = message;
368
+ if (!(await detail.Save())) {
369
+ LogError(`Failed to save agent response detail progress update: ${AgentRunner.saveFailureReason(detail)}`);
370
+ }
371
+ }
372
+ catch (error) {
373
+ // A failed progress save must not break the chain the final update awaits
374
+ LogError(`Failed to save agent response detail progress update: ${error}`, undefined, error);
375
+ }
376
+ });
377
+ await progressSaves;
313
378
  }
314
379
  // Call original callback if provided
315
380
  if (originalOnProgress) {
@@ -317,12 +382,14 @@ export class AgentRunner {
317
382
  }
318
383
  }
319
384
  : originalOnProgress;
320
- // Gather all artifacts from this conversation for the ArtifactToolManager.
385
+ // The run reads the branch the caller named, else the branch its reply row carries. Undefined is Main.
386
+ const runBranchId = params.ConversationBranchID ?? agentResponseDetail?.BranchID ?? undefined;
387
+ // Gather all artifacts on the run's branch path of this conversation for the ArtifactToolManager.
321
388
  // Per design doc Section 8.8: in the in-conversation flow, "the agent continues
322
389
  // the conversation with the artifact already available." This means ALL artifacts
323
- // in the conversation (both agent-produced Output and user-attached Input) should
390
+ // on that path (both agent-produced Output and user-attached Input) should
324
391
  // be available to the agent via artifact tools.
325
- const inputArtifacts = await this.gatherConversationArtifacts(conversationId, contextUser, params.ConversationHistoryFrom);
392
+ const inputArtifacts = await this.gatherConversationArtifacts(conversationId, contextUser, params.ConversationHistoryFrom, runBranchId);
326
393
  const modifiedParams = {
327
394
  ...params,
328
395
  // First-class conversationId gates the cross-turn context features
@@ -339,6 +406,7 @@ export class AgentRunner {
339
406
  // (BaseAgent tests `inputArtifacts?.length`, so [] and undefined behave identically there.)
340
407
  inputArtifacts,
341
408
  conversationDetailId: agentResponseDetailId,
409
+ ...(runBranchId !== undefined ? { ConversationBranchID: runBranchId } : {}),
342
410
  onProgress: wrappedOnProgress
343
411
  };
344
412
  // Returning-visitor memory (RV3): for a public web-widget guest with remembering on, derive the
@@ -370,8 +438,9 @@ export class AgentRunner {
370
438
  // Step 5: Update agent response detail with final result.
371
439
  const updateDetail = async () => {
372
440
  if (agentResponseDetail && agentResponseDetailId) {
373
- // Wait for any in-flight progress save to complete
374
- // EnsureSaveComplete() resolves immediately if no save in progress
441
+ // Wait for every queued progress save (none can be added: the flag is set),
442
+ // then for any other save still in flight on this entity
443
+ await progressSaves;
375
444
  await agentResponseDetail.EnsureSaveComplete();
376
445
  LogStatus('Updating agent response detail with final result');
377
446
  // Reload to get any updates from agent execution
@@ -379,11 +448,9 @@ export class AgentRunner {
379
448
  if (!loaded) {
380
449
  LogError(`Failed to reload agent response detail ${agentResponseDetailId}`);
381
450
  }
382
- agentResponseDetail.Message = agentResult.agentRun?.Message ||
383
- (agentResult.success
384
- ? '✅ Completed'
385
- : agentResult.agentRun?.ErrorMessage || '❌ Failed');
386
- agentResponseDetail.Status = agentResult.success ? 'Complete' : 'Error';
451
+ const finalState = AgentRunner.ResolveFinalDetailState(agentResult);
452
+ agentResponseDetail.Message = finalState.Message;
453
+ agentResponseDetail.Status = finalState.Status;
387
454
  // Set response form and command fields
388
455
  if (agentResult.responseForm) {
389
456
  agentResponseDetail.ResponseForm = JSON.stringify(agentResult.responseForm);
@@ -536,6 +603,7 @@ export class AgentRunner {
536
603
  async GetMaxVersionForArtifact(artifactId, contextUser, provider) {
537
604
  try {
538
605
  const rv = RunView.FromMetadataProvider(provider || this._provider);
606
+ // conversation-scope: artifact-wide read; version numbers are unique per artifact across every path
539
607
  const result = await rv.RunView({
540
608
  EntityName: 'MJ: Artifact Versions',
541
609
  ExtraFilter: `ArtifactID='${AgentRunner.filterId(artifactId, 'GetMaxVersionForArtifact artifactId')}'`,
@@ -582,6 +650,7 @@ export class AgentRunner {
582
650
  return null;
583
651
  }
584
652
  const rv = RunView.FromMetadataProvider(provider || this._provider);
653
+ // conversation-scope: artifact-wide read; compares with the artifact's latest version number, which is global
585
654
  const result = await rv.RunView({
586
655
  EntityName: 'MJ: Artifact Versions',
587
656
  ExtraFilter: `ArtifactID='${AgentRunner.filterId(artifactId, 'CheckForDuplicateVersion artifactId')}' AND VersionNumber=${latestVersion}`,
@@ -620,6 +689,60 @@ export class AgentRunner {
620
689
  LogStatus(`Linked artifact to conversation detail ${conversationDetailId}`);
621
690
  return { artifactId, versionId, versionNumber };
622
691
  }
692
+ /**
693
+ * Gives the current reply an existing artifact version whose content equals the new payload.
694
+ * The reply gets an `Output` link to that version (unless it already has one), which makes the
695
+ * version visible on the reply's branch path, and the result is the same tuple the normal
696
+ * version-creation path returns. When the link-exists read fails, no link is written and the
697
+ * result is `undefined`, so a failed read never adds a second link for the same pair.
698
+ *
699
+ * @param versionId - The existing version with identical content
700
+ * @param conversationDetailId - The reply row to link the version to
701
+ * @param artifactId - The parent artifact ID
702
+ * @param versionNumber - The existing version's number
703
+ * @param contextUser - User context for the read and the save
704
+ * @param provider - Metadata provider for the read and the save
705
+ * @returns The standard artifact result tuple for the existing version, or `undefined` when
706
+ * the link-exists read failed
707
+ */
708
+ async reuseVersionForReply(versionId, conversationDetailId, artifactId, versionNumber, contextUser, provider) {
709
+ LogStatus(`Reusing version ${versionNumber} of artifact ${artifactId} for this reply (identical content)`);
710
+ const linkExists = await this.hasOutputLink(conversationDetailId, versionId, contextUser, provider);
711
+ if (linkExists === null) {
712
+ return undefined;
713
+ }
714
+ if (linkExists) {
715
+ return { artifactId, versionId, versionNumber };
716
+ }
717
+ return this.LinkArtifactToConversationDetail(versionId, conversationDetailId, artifactId, versionNumber, contextUser, provider);
718
+ }
719
+ /**
720
+ * Checks whether a conversation detail already has an `Output` link to an artifact version.
721
+ * A failed read is logged and returns `null`.
722
+ *
723
+ * @param conversationDetailId - The conversation detail to check
724
+ * @param versionId - The artifact version to look for
725
+ * @param contextUser - User context for the read
726
+ * @param provider - Metadata provider for the read
727
+ * @returns `true` when the link exists, `false` when it does not, `null` when the read failed
728
+ */
729
+ async hasOutputLink(conversationDetailId, versionId, contextUser, provider) {
730
+ const rv = RunView.FromMetadataProvider(provider);
731
+ const result = await rv.RunView({
732
+ EntityName: 'MJ: Conversation Detail Artifacts',
733
+ ExtraFilter: `ConversationDetailID='${AgentRunner.filterId(conversationDetailId, 'hasOutputLink conversationDetailId')}' ` +
734
+ `AND ArtifactVersionID='${AgentRunner.filterId(versionId, 'hasOutputLink versionId')}' AND Direction='Output'`,
735
+ Fields: ['ID'],
736
+ MaxRows: 1,
737
+ ResultType: 'simple'
738
+ }, contextUser);
739
+ if (!result.Success) {
740
+ LogError(`Could not check for an existing artifact link on conversation detail ${conversationDetailId} ` +
741
+ `(no link written): ${result.ErrorMessage}`);
742
+ return null;
743
+ }
744
+ return result.Results.length > 0;
745
+ }
623
746
  /**
624
747
  * Finds the most recent artifact for a conversation detail to determine versioning.
625
748
  * Queries the junction table to locate artifacts linked to a specific conversation message.
@@ -683,6 +806,11 @@ export class AgentRunner {
683
806
  * 3. If previous artifact exists, creates new version of it
684
807
  * 4. If no previous artifact, creates entirely new artifact
685
808
  *
809
+ * When the payload equals the version a new one would follow, no version is created. Inside a
810
+ * conversation that existing version is linked to the reply (an `Output` link, unless one
811
+ * exists) and returned; if the link-exists read fails, nothing is written and the method returns
812
+ * `undefined`. Outside a conversation the method returns `undefined`.
813
+ *
686
814
  * Respects the agent's ArtifactCreationMode configuration:
687
815
  * - "Never": Skips artifact creation entirely
688
816
  * - "System Only": Creates artifact with Visibility='System Only'
@@ -720,8 +848,34 @@ export class AgentRunner {
720
848
  }
721
849
  // Check agent's ArtifactCreationMode
722
850
  await AIEngine.Instance.Config(false, contextUser);
723
- const agent = AIEngine.Instance.Agents.find(a => UUIDsEqual(a.ID, agentRun.AgentID));
724
- const creationMode = agent?.ArtifactCreationMode;
851
+ const agentsById = IndexByUUID(AIEngine.Instance.Agents);
852
+ let agent = agentsById.Get(agentRun.AgentID);
853
+ let creationMode = agent?.ArtifactCreationMode;
854
+ // When an orchestrator with ArtifactCreationMode='Never' or 'System Only' (or no
855
+ // DefaultArtifactTypeID, such as Sage) delegates a folded single-node task graph (or
856
+ // sub-agent step) to a specialist agent (such as Query Builder or Research Agent) that
857
+ // DOES produce user-visible artifacts, resolve the artifact creation mode and
858
+ // DefaultArtifactTypeID from the last completed Sub-Agent step's specialist agent so
859
+ // the specialist's deliverable artifact is persisted with the specialist's
860
+ // DefaultArtifactTypeID and visibility.
861
+ if ((creationMode === 'Never' || creationMode === 'System Only' || !agent?.DefaultArtifactTypeID) && agentRun?.Steps?.length) {
862
+ for (let i = agentRun.Steps.length - 1; i >= 0; i--) {
863
+ const step = agentRun.Steps[i];
864
+ if (step.StepType === 'Sub-Agent' && step.Success) {
865
+ const subAgentId = step.TargetID || step.SubAgentRun?.AgentID;
866
+ const delegatedAgent = subAgentId
867
+ ? agentsById.Get(subAgentId)
868
+ : undefined;
869
+ if (delegatedAgent &&
870
+ delegatedAgent.ArtifactCreationMode !== 'Never' &&
871
+ (delegatedAgent.DefaultArtifactTypeID != null || delegatedAgent.ArtifactCreationMode === 'Always')) {
872
+ agent = delegatedAgent;
873
+ creationMode = delegatedAgent.ArtifactCreationMode;
874
+ break;
875
+ }
876
+ }
877
+ }
878
+ }
725
879
  if (creationMode === 'Never') {
726
880
  LogStatus(`Skipping artifact creation - agent "${agent?.Name}" has ArtifactCreationMode='Never'`);
727
881
  return undefined;
@@ -800,7 +954,7 @@ export class AgentRunner {
800
954
  LogStatus(`Creating version ${newVersionNumber} of existing artifact ${artifactId}`);
801
955
  }
802
956
  else {
803
- const artifact = await this.createArtifactHeader(md, contextUser, agent, creationMode, directive);
957
+ const artifact = await this.createArtifactHeader(md, contextUser, agent, creationMode, directive, payload);
804
958
  artifactId = artifact.ID;
805
959
  newVersionNumber = 1;
806
960
  isNewArtifact = true;
@@ -809,12 +963,17 @@ export class AgentRunner {
809
963
  }
810
964
  // Serialize the payload once — used for both dedup check and version creation
811
965
  const serializedContent = JSON.stringify(payload, null, 2);
812
- // Skip version creation if content is identical to the latest version
966
+ // Identical content creates no new version. Inside a conversation the existing version
967
+ // is linked to this reply instead; outside one there is nothing to link.
813
968
  if (!isNewArtifact && newVersionNumber > 1) {
814
- const existingVersionId = await this.CheckForDuplicateVersion(artifactId, serializedContent, newVersionNumber - 1, contextUser, provider);
969
+ const latestVersionNumber = newVersionNumber - 1;
970
+ const existingVersionId = await this.CheckForDuplicateVersion(artifactId, serializedContent, latestVersionNumber, contextUser, provider);
815
971
  if (existingVersionId) {
816
- console.debug(`Skipping duplicate artifact version — content identical to version ${newVersionNumber - 1}`);
817
- return undefined;
972
+ if (!conversationDetailId) {
973
+ console.debug(`Skipping duplicate artifact version — content identical to version ${latestVersionNumber}`);
974
+ return undefined;
975
+ }
976
+ return await this.reuseVersionForReply(existingVersionId, conversationDetailId, artifactId, latestVersionNumber, contextUser, md);
818
977
  }
819
978
  }
820
979
  // Create artifact version with content
@@ -823,19 +982,54 @@ export class AgentRunner {
823
982
  version.VersionNumber = newVersionNumber;
824
983
  version.Content = serializedContent;
825
984
  version.UserID = contextUser.ID;
985
+ const directiveName = AgentRunner.safeDirectiveText(directive?.name, AgentRunner.ARTIFACT_NAME_MAX_LENGTH);
986
+ const directiveDescription = AgentRunner.safeDirectiveText(directive?.description);
987
+ const payloadRecord = (typeof payload === 'object' && payload !== null && !Array.isArray(payload))
988
+ ? payload
989
+ : undefined;
990
+ const reportRecord = (typeof payloadRecord?.report === 'object' && payloadRecord.report !== null && !Array.isArray(payloadRecord.report))
991
+ ? payloadRecord.report
992
+ : undefined;
993
+ const synthesisRecord = (typeof payloadRecord?.synthesis === 'object' && payloadRecord.synthesis !== null && !Array.isArray(payloadRecord.synthesis))
994
+ ? payloadRecord.synthesis
995
+ : undefined;
996
+ const payloadName = AgentRunner.safeDirectiveText(payloadRecord?.title ?? payloadRecord?.name ?? payloadRecord?.savedQueryName ?? reportRecord?.name, AgentRunner.ARTIFACT_NAME_MAX_LENGTH);
997
+ const payloadDescription = AgentRunner.safeDirectiveText(payloadRecord?.description ?? payloadRecord?.interpretation ?? reportRecord?.description ?? synthesisRecord?.executiveSummary);
998
+ if (directiveName || payloadName) {
999
+ version.Name = directiveName || payloadName || null;
1000
+ }
1001
+ if (directiveDescription || payloadDescription) {
1002
+ version.Description = directiveDescription || payloadDescription || null;
1003
+ }
826
1004
  if (!(await version.Save())) {
827
1005
  throw new Error('Failed to save artifact version');
828
1006
  }
829
1007
  LogStatus(`Created artifact version ${newVersionNumber} (${version.ID})`);
830
- // First version of a new artifact: adopt the extracted Name attribute unless the agent named it
831
- if (isNewArtifact && newVersionNumber === 1 && !AgentRunner.safeDirectiveText(directive?.name, AgentRunner.ARTIFACT_NAME_MAX_LENGTH)) {
832
- const nameAttr = version.Attributes?.find((attr) => attr.StandardProperty === 'name' || attr.Name?.toLowerCase() === 'name');
833
- let extractedName = nameAttr?.Value?.trim();
834
- if (extractedName && extractedName.toLowerCase() !== 'null') {
835
- extractedName = extractedName.replace(/^["']|["']$/g, '');
1008
+ // First version of a new artifact: adopt the extracted Name/Description attribute (or payload title/description)
1009
+ // unless the agent explicitly named/described it via artifactDirective.
1010
+ if (isNewArtifact && newVersionNumber === 1 && (!directiveName || !directiveDescription)) {
1011
+ const attrs = version.Attributes;
1012
+ const nameAttr = attrs?.find((attr) => attr.StandardProperty === 'name' || attr.Name?.toLowerCase() === 'name');
1013
+ const descAttr = attrs?.find((attr) => attr.StandardProperty === 'description' || attr.Name?.toLowerCase() === 'description');
1014
+ const cleanAttr = (val, maxLen) => {
1015
+ const trimmed = val?.trim();
1016
+ if (!trimmed || trimmed.toLowerCase() === 'null') {
1017
+ return undefined;
1018
+ }
1019
+ const unquoted = trimmed.replace(/^["']|["']$/g, '').trim();
1020
+ return AgentRunner.safeDirectiveText(unquoted, maxLen);
1021
+ };
1022
+ const resolvedName = !directiveName ? (cleanAttr(nameAttr?.Value, AgentRunner.ARTIFACT_NAME_MAX_LENGTH) || payloadName) : undefined;
1023
+ const resolvedDescription = !directiveDescription ? (cleanAttr(descAttr?.Value) || payloadDescription) : undefined;
1024
+ if (resolvedName || resolvedDescription) {
836
1025
  const artifact = await md.GetEntityObject('MJ: Artifacts', contextUser);
837
1026
  if (await artifact.Load(artifactId)) {
838
- artifact.Name = extractedName;
1027
+ if (resolvedName) {
1028
+ artifact.Name = resolvedName;
1029
+ }
1030
+ if (resolvedDescription) {
1031
+ artifact.Description = resolvedDescription;
1032
+ }
839
1033
  if (await artifact.Save()) {
840
1034
  LogStatus(`Updated artifact name to: ${artifact.Name}`);
841
1035
  }
@@ -1049,7 +1243,7 @@ export class AgentRunner {
1049
1243
  * Creates the artifact header row. Name and description come from the agent's directive when
1050
1244
  * it supplied them (e.g. Skip's artifactRequest); otherwise the historical placeholder.
1051
1245
  */
1052
- async createArtifactHeader(md, contextUser, agent, creationMode, directive) {
1246
+ async createArtifactHeader(md, contextUser, agent, creationMode, directive, payload) {
1053
1247
  const artifact = await md.GetEntityObject('MJ: Artifacts', contextUser);
1054
1248
  const agentName = agent?.Name || 'Agent';
1055
1249
  // Both fields are model output: coerced, trimmed, and (for Name) clamped to its column so a
@@ -1059,8 +1253,17 @@ export class AgentRunner {
1059
1253
  // Description is nvarchar(MAX), so there is no length to clamp to — only the type to check.
1060
1254
  artifact.Description = AgentRunner.safeDirectiveText(directive?.description)
1061
1255
  || `Payload returned by ${agentName}`;
1062
- // Use agent's DefaultArtifactTypeID if available
1063
- artifact.TypeID = agent?.DefaultArtifactTypeID || AgentRunner.JSON_ARTIFACT_TYPE_ID;
1256
+ // Use agent's DefaultArtifactTypeID if available; otherwise infer Research Content when
1257
+ // the payload carries a non-empty report.html string (e.g., Research Report Writer).
1258
+ const payloadObj = (typeof payload === 'object' && payload !== null && !Array.isArray(payload))
1259
+ ? payload
1260
+ : undefined;
1261
+ const reportObj = (typeof payloadObj?.report === 'object' && payloadObj.report !== null && !Array.isArray(payloadObj.report))
1262
+ ? payloadObj.report
1263
+ : undefined;
1264
+ const hasReportHtml = typeof reportObj?.html === 'string' && reportObj.html.trim().length > 0;
1265
+ artifact.TypeID = agent?.DefaultArtifactTypeID
1266
+ || (hasReportHtml ? AgentRunner.RESEARCH_CONTENT_ARTIFACT_TYPE_ID : AgentRunner.JSON_ARTIFACT_TYPE_ID);
1064
1267
  artifact.UserID = contextUser.ID;
1065
1268
  artifact.EnvironmentID = contextUser.EnvironmentID || MJEnvironmentEntityExtended.DefaultEnvironmentID;
1066
1269
  // Set visibility based on agent's ArtifactCreationMode
@@ -1607,8 +1810,10 @@ export class AgentRunner {
1607
1810
  if (!contextUser?.ReturningVisitorContext) {
1608
1811
  return;
1609
1812
  }
1610
- // Gate 2: need a conversation to read from, and an explicit caller scope always wins.
1611
- if (!conversationId || params.PrimaryScopeRecordID || params.data?.PrimaryScopeRecordID) {
1813
+ // Gate 2: need a conversation to read from, and an explicit caller scope always wins — a data scope only when
1814
+ // the run will honour it (TrustReservedRunData; BaseAgent.Execute drops it otherwise).
1815
+ const runData = WithAgentRunDataTrustApplied(params).Params.data;
1816
+ if (!conversationId || params.PrimaryScopeRecordID || runData?.PrimaryScopeRecordID) {
1612
1817
  return;
1613
1818
  }
1614
1819
  const convo = await md.GetEntityObject('MJ: Conversations', contextUser);
@@ -1665,7 +1870,7 @@ export class AgentRunner {
1665
1870
  if (!conversationId) {
1666
1871
  return params;
1667
1872
  }
1668
- const inputArtifacts = await this.gatherConversationArtifacts(conversationId, params.contextUser, params.ConversationHistoryFrom);
1873
+ const inputArtifacts = await this.gatherConversationArtifacts(conversationId, params.contextUser, params.ConversationHistoryFrom, params.ConversationBranchID);
1669
1874
  return inputArtifacts.length > 0 ? { ...params, inputArtifacts } : params;
1670
1875
  }
1671
1876
  /**
@@ -1684,23 +1889,25 @@ export class AgentRunner {
1684
1889
  return (await detail.Load(params.conversationDetailId)) ? detail.ConversationID : undefined;
1685
1890
  }
1686
1891
  /**
1687
- * Gathers all artifacts from a conversation (both artifact-system records and
1688
- * uploaded file attachments) so the ArtifactToolManager can make them available
1892
+ * Gathers the artifacts on the run's branch path of a conversation (both artifact-system
1893
+ * records and uploaded file attachments) so the ArtifactToolManager can make them available
1689
1894
  * to the agent as input artifacts.
1690
1895
  *
1691
1896
  * @param historyFrom The run's history floor (`ExecuteAgentParams.ConversationHistoryFrom`).
1692
1897
  * When set, only artifacts attached to messages written at or after it are gathered.
1898
+ * @param branchId The run's branch; only artifacts of messages on its path that no rerun
1899
+ * replaced are gathered.
1693
1900
  */
1694
- async gatherConversationArtifacts(conversationId, contextUser, historyFrom) {
1901
+ async gatherConversationArtifacts(conversationId, contextUser, historyFrom, branchId) {
1695
1902
  try {
1696
1903
  const rv = new RunView();
1697
- const conversationFilter = `ConversationID='${conversationId}'`;
1698
- // Get all conversation detail IDs for this conversation (from its floor, if the run has one)
1904
+ const pathFilter = await ConversationEngine.BranchPathFilterFresh(conversationId, branchId, contextUser);
1905
+ // Get the IDs of the live conversation details on the run's branch path (from its floor, if the run has one)
1699
1906
  const details = await rv.RunView({
1700
1907
  EntityName: 'MJ: Conversation Details',
1701
- ExtraFilter: historyFrom
1702
- ? `${conversationFilter} AND ${ConversationEngine.HistoryFromFilter(historyFrom)}`
1703
- : conversationFilter,
1908
+ ExtraFilter: ConversationEngine.LiveRowsFilter(historyFrom
1909
+ ? `${pathFilter} AND ${ConversationEngine.HistoryFromFilter(historyFrom)}`
1910
+ : pathFilter),
1704
1911
  Fields: ['ID'],
1705
1912
  ResultType: 'simple',
1706
1913
  }, contextUser);
@@ -1746,7 +1953,7 @@ export class AgentRunner {
1746
1953
  const typeName = row.TypeName || 'Text';
1747
1954
  let content = '';
1748
1955
  if (row.ContentMode === 'File' && row.FileID) {
1749
- const downloaded = await this.downloadArtifactFileContent(row.FileID, contextUser);
1956
+ const downloaded = await this.DownloadArtifactFileContent(row.FileID, contextUser);
1750
1957
  if (downloaded) {
1751
1958
  content = downloaded;
1752
1959
  }
@@ -1772,10 +1979,18 @@ export class AgentRunner {
1772
1979
  content = await this.hydrateSqlBackedContent(content, contextUser);
1773
1980
  }
1774
1981
  if (content) {
1982
+ const rawDescription = row.VersionDescription || row.ArtifactDescription;
1983
+ const cleanDescription = rawDescription && !rawDescription.startsWith('Payload returned by ')
1984
+ ? rawDescription
1985
+ : undefined;
1775
1986
  inputArtifacts.push({
1776
1987
  name: artifactName,
1777
1988
  typeName,
1778
1989
  content,
1990
+ ...(row.ArtifactID ? { artifactId: row.ArtifactID } : {}),
1991
+ ...(row.VersionID ? { versionId: row.VersionID } : {}),
1992
+ ...(row.VersionNumber != null ? { versionNumber: row.VersionNumber } : {}),
1993
+ ...(cleanDescription ? { description: cleanDescription } : {}),
1779
1994
  mimeType: row.MimeType ?? undefined,
1780
1995
  ...(row.ToolLibraryClass ? { toolLibraryClass: row.ToolLibraryClass } : {}),
1781
1996
  deliveryMode: row.DefaultDeliveryMode ?? 'ToolsOnly',
@@ -1880,20 +2095,25 @@ export class AgentRunner {
1880
2095
  }
1881
2096
  /**
1882
2097
  * Downloads binary content for a file-backed artifact from MJStorage.
1883
- * Uses FileStorageEngine to resolve the storage account and driver,
1884
- * then fetches the file by its ProviderKey.
2098
+ * Reads the `MJ: Files` row as the user, then resolves it through
2099
+ * `FileStorageEngine.ResolveFileObject`, which applies the storage-account gate and the
2100
+ * tracked-file rule before any driver call — the same path every other file-ID route uses.
1885
2101
  *
1886
2102
  * @param fileId - The MJ: Files entity ID referenced by ArtifactVersion.FileID
1887
2103
  * @param contextUser - User context for storage driver authentication
1888
2104
  * @returns Buffer of file content, or null if download fails
1889
2105
  */
1890
- async downloadArtifactFileContent(fileId, contextUser) {
2106
+ async DownloadArtifactFileContent(fileId, contextUser) {
2107
+ if (!IsValidUUID(fileId)) {
2108
+ LogError(`[AgentRunner] Refusing to read artifact file content: '${fileId}' is not a file ID`);
2109
+ return null;
2110
+ }
1891
2111
  try {
1892
2112
  await FileStorageEngine.Instance.Config(false, contextUser);
1893
- const rv = new RunView();
2113
+ const rv = RunView.FromMetadataProvider(this._provider);
1894
2114
  const fileResult = await rv.RunView({
1895
2115
  EntityName: 'MJ: Files',
1896
- ExtraFilter: `ID = '${fileId}'`,
2116
+ ExtraFilter: `ID = '${EscapeSQLString(fileId.trim())}'`,
1897
2117
  Fields: ['ID', 'Name', 'ContentType', 'ProviderID', 'ProviderKey'],
1898
2118
  ResultType: 'simple',
1899
2119
  }, contextUser);
@@ -1901,15 +2121,13 @@ export class AgentRunner {
1901
2121
  LogError(`[AgentRunner] File not found in MJ: Files for FileID: ${fileId}`);
1902
2122
  return null;
1903
2123
  }
1904
- const file = fileResult.Results[0];
1905
- const accounts = FileStorageEngine.Instance.GetAccountsByProviderID(file.ProviderID);
1906
- if (accounts.length === 0) {
1907
- LogError(`[AgentRunner] No FileStorageAccount found for ProviderID: ${file.ProviderID}`);
2124
+ // Account gate and tracked-file rule first; a refusal throws and is logged below.
2125
+ const resolved = await FileStorageEngine.Instance.ResolveFileObject(fileResult.Results[0], contextUser, 'Read', this._provider);
2126
+ if (!resolved) {
2127
+ LogError(`[AgentRunner] No FileStorageAccount found for ProviderID: ${fileResult.Results[0].ProviderID}`);
1908
2128
  return null;
1909
2129
  }
1910
- const driver = await FileStorageEngine.Instance.GetDriver(accounts[0].ID, contextUser);
1911
- const objectName = file.ProviderKey ?? file.Name;
1912
- const content = await driver.GetObject({ fullPath: objectName });
2130
+ const content = await resolved.Driver.GetObject({ fullPath: resolved.ObjectKey });
1913
2131
  // GetObject returns string or Buffer depending on provider
1914
2132
  if (Buffer.isBuffer(content)) {
1915
2133
  return content;