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

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 (165) hide show
  1. package/README.md +89 -2
  2. package/dist/AgentDataPreloader.d.ts +4 -2
  3. package/dist/AgentDataPreloader.d.ts.map +1 -1
  4. package/dist/AgentDataPreloader.js +21 -12
  5. package/dist/AgentDataPreloader.js.map +1 -1
  6. package/dist/AgentRunner.d.ts +150 -5
  7. package/dist/AgentRunner.d.ts.map +1 -1
  8. package/dist/AgentRunner.js +588 -64
  9. package/dist/AgentRunner.js.map +1 -1
  10. package/dist/AgentWakeTriggerService.d.ts +183 -0
  11. package/dist/AgentWakeTriggerService.d.ts.map +1 -0
  12. package/dist/AgentWakeTriggerService.js +485 -0
  13. package/dist/AgentWakeTriggerService.js.map +1 -0
  14. package/dist/ArtifactToolManager.d.ts +1 -0
  15. package/dist/ArtifactToolManager.d.ts.map +1 -1
  16. package/dist/ArtifactToolManager.js +5 -0
  17. package/dist/ArtifactToolManager.js.map +1 -1
  18. package/dist/ConversationToolManager.d.ts +1 -1
  19. package/dist/ConversationToolManager.d.ts.map +1 -1
  20. package/dist/ConversationToolManager.js +10 -4
  21. package/dist/ConversationToolManager.js.map +1 -1
  22. package/dist/MJAIAgentRequestEntityServer.d.ts +15 -1
  23. package/dist/MJAIAgentRequestEntityServer.d.ts.map +1 -1
  24. package/dist/MJAIAgentRequestEntityServer.js +63 -3
  25. package/dist/MJAIAgentRequestEntityServer.js.map +1 -1
  26. package/dist/agent-context-injector.d.ts +21 -4
  27. package/dist/agent-context-injector.d.ts.map +1 -1
  28. package/dist/agent-context-injector.js +49 -13
  29. package/dist/agent-context-injector.js.map +1 -1
  30. package/dist/agent-memory-context-builder.js +2 -2
  31. package/dist/agent-memory-context-builder.js.map +1 -1
  32. package/dist/agent-pre-execution-rag.d.ts.map +1 -1
  33. package/dist/agent-pre-execution-rag.js +6 -8
  34. package/dist/agent-pre-execution-rag.js.map +1 -1
  35. package/dist/agent-run-watchdog.d.ts +71 -18
  36. package/dist/agent-run-watchdog.d.ts.map +1 -1
  37. package/dist/agent-run-watchdog.js +223 -90
  38. package/dist/agent-run-watchdog.js.map +1 -1
  39. package/dist/agent-types/flow-agent-type.d.ts +13 -0
  40. package/dist/agent-types/flow-agent-type.d.ts.map +1 -1
  41. package/dist/agent-types/flow-agent-type.js +165 -27
  42. package/dist/agent-types/flow-agent-type.js.map +1 -1
  43. package/dist/agent-types/loop-agent-prompt-params.d.ts +32 -5
  44. package/dist/agent-types/loop-agent-prompt-params.d.ts.map +1 -1
  45. package/dist/agent-types/loop-agent-prompt-params.js +5 -3
  46. package/dist/agent-types/loop-agent-prompt-params.js.map +1 -1
  47. package/dist/agent-types/loop-agent-response-type.d.ts +35 -4
  48. package/dist/agent-types/loop-agent-response-type.d.ts.map +1 -1
  49. package/dist/agent-types/loop-agent-response-type.js +1 -1
  50. package/dist/agent-types/loop-agent-response-type.js.map +1 -1
  51. package/dist/agent-types/loop-agent-type.d.ts +103 -9
  52. package/dist/agent-types/loop-agent-type.d.ts.map +1 -1
  53. package/dist/agent-types/loop-agent-type.js +351 -68
  54. package/dist/agent-types/loop-agent-type.js.map +1 -1
  55. package/dist/base-agent.d.ts +551 -44
  56. package/dist/base-agent.d.ts.map +1 -1
  57. package/dist/base-agent.js +2742 -549
  58. package/dist/base-agent.js.map +1 -1
  59. package/dist/bound-action-params.d.ts +57 -0
  60. package/dist/bound-action-params.d.ts.map +1 -0
  61. package/dist/bound-action-params.js +91 -0
  62. package/dist/bound-action-params.js.map +1 -0
  63. package/dist/catalog-narrowing.d.ts.map +1 -1
  64. package/dist/catalog-narrowing.js +6 -3
  65. package/dist/catalog-narrowing.js.map +1 -1
  66. package/dist/handoff-target.d.ts +80 -0
  67. package/dist/handoff-target.d.ts.map +1 -0
  68. package/dist/handoff-target.js +158 -0
  69. package/dist/handoff-target.js.map +1 -0
  70. package/dist/index.d.ts +7 -0
  71. package/dist/index.d.ts.map +1 -1
  72. package/dist/index.js +7 -0
  73. package/dist/index.js.map +1 -1
  74. package/dist/memory-cleanup-agent.d.ts.map +1 -1
  75. package/dist/memory-cleanup-agent.js +3 -0
  76. package/dist/memory-cleanup-agent.js.map +1 -1
  77. package/dist/memory-manager-agent.d.ts.map +1 -1
  78. package/dist/memory-manager-agent.js +8 -1
  79. package/dist/memory-manager-agent.js.map +1 -1
  80. package/dist/native-tools/action-tool-builder.d.ts +6 -0
  81. package/dist/native-tools/action-tool-builder.d.ts.map +1 -1
  82. package/dist/native-tools/action-tool-builder.js +21 -5
  83. package/dist/native-tools/action-tool-builder.js.map +1 -1
  84. package/dist/native-tools/agent-tools.d.ts +64 -0
  85. package/dist/native-tools/agent-tools.d.ts.map +1 -0
  86. package/dist/native-tools/agent-tools.js +23 -0
  87. package/dist/native-tools/agent-tools.js.map +1 -0
  88. package/dist/native-tools/control-tools.d.ts +40 -7
  89. package/dist/native-tools/control-tools.d.ts.map +1 -1
  90. package/dist/native-tools/control-tools.js +139 -50
  91. package/dist/native-tools/control-tools.js.map +1 -1
  92. package/dist/native-tools/framework-tools.d.ts +47 -0
  93. package/dist/native-tools/framework-tools.d.ts.map +1 -0
  94. package/dist/native-tools/framework-tools.js +187 -0
  95. package/dist/native-tools/framework-tools.js.map +1 -0
  96. package/dist/native-tools/native-control-config.d.ts +93 -0
  97. package/dist/native-tools/native-control-config.d.ts.map +1 -0
  98. package/dist/native-tools/native-control-config.js +104 -0
  99. package/dist/native-tools/native-control-config.js.map +1 -0
  100. package/dist/native-tools/tool-result-turns.d.ts +41 -8
  101. package/dist/native-tools/tool-result-turns.d.ts.map +1 -1
  102. package/dist/native-tools/tool-result-turns.js +76 -2
  103. package/dist/native-tools/tool-result-turns.js.map +1 -1
  104. package/dist/native-tools/turn-mode.d.ts +8 -0
  105. package/dist/native-tools/turn-mode.d.ts.map +1 -0
  106. package/dist/native-tools/turn-mode.js +14 -0
  107. package/dist/native-tools/turn-mode.js.map +1 -0
  108. package/dist/pipeline/pipeline-registry.d.ts +5 -12
  109. package/dist/pipeline/pipeline-registry.d.ts.map +1 -1
  110. package/dist/pipeline/pipeline-registry.js +28 -2
  111. package/dist/pipeline/pipeline-registry.js.map +1 -1
  112. package/dist/pipeline/providers/serialize.d.ts +7 -3
  113. package/dist/pipeline/providers/serialize.d.ts.map +1 -1
  114. package/dist/pipeline/providers/serialize.js +9 -5
  115. package/dist/pipeline/providers/serialize.js.map +1 -1
  116. package/dist/query-builder-agent.d.ts +20 -1
  117. package/dist/query-builder-agent.d.ts.map +1 -1
  118. package/dist/query-builder-agent.js +35 -3
  119. package/dist/query-builder-agent.js.map +1 -1
  120. package/dist/realtime/bridge-room-transcript-sink.js +3 -0
  121. package/dist/realtime/bridge-room-transcript-sink.js.map +1 -1
  122. package/dist/realtime/bridge-session-transcript-sink.js +1 -0
  123. package/dist/realtime/bridge-session-transcript-sink.js.map +1 -1
  124. package/dist/realtime/realtime-client-session-service.d.ts +22 -2
  125. package/dist/realtime/realtime-client-session-service.d.ts.map +1 -1
  126. package/dist/realtime/realtime-client-session-service.js +70 -10
  127. package/dist/realtime/realtime-client-session-service.js.map +1 -1
  128. package/dist/realtime/realtime-coagent-config.d.ts.map +1 -1
  129. package/dist/realtime/realtime-coagent-config.js +2 -28
  130. package/dist/realtime/realtime-coagent-config.js.map +1 -1
  131. package/dist/realtime/realtime-recording-capture.d.ts +1 -0
  132. package/dist/realtime/realtime-recording-capture.d.ts.map +1 -1
  133. package/dist/realtime/realtime-recording-capture.js +17 -3
  134. package/dist/realtime/realtime-recording-capture.js.map +1 -1
  135. package/dist/realtime/realtime-recording-ledger.d.ts +20 -0
  136. package/dist/realtime/realtime-recording-ledger.d.ts.map +1 -1
  137. package/dist/realtime/realtime-recording-ledger.js +16 -0
  138. package/dist/realtime/realtime-recording-ledger.js.map +1 -1
  139. package/dist/realtime/realtime-recording-opus-assembly.d.ts.map +1 -1
  140. package/dist/realtime/realtime-recording-opus-assembly.js +9 -4
  141. package/dist/realtime/realtime-recording-opus-assembly.js.map +1 -1
  142. package/dist/realtime/realtime-recording-store.d.ts +6 -5
  143. package/dist/realtime/realtime-recording-store.d.ts.map +1 -1
  144. package/dist/realtime/realtime-recording-store.js +47 -21
  145. package/dist/realtime/realtime-recording-store.js.map +1 -1
  146. package/dist/realtime/realtime-session-runner.d.ts.map +1 -1
  147. package/dist/realtime/realtime-session-runner.js +5 -7
  148. package/dist/realtime/realtime-session-runner.js.map +1 -1
  149. package/dist/realtime/realtime-turn-moderator.d.ts.map +1 -1
  150. package/dist/realtime/realtime-turn-moderator.js +1 -0
  151. package/dist/realtime/realtime-turn-moderator.js.map +1 -1
  152. package/dist/rubric-evaluation-agent-runner.js +1 -0
  153. package/dist/rubric-evaluation-agent-runner.js.map +1 -1
  154. package/dist/runtime-state-fragment.d.ts.map +1 -1
  155. package/dist/runtime-state-fragment.js +3 -0
  156. package/dist/runtime-state-fragment.js.map +1 -1
  157. package/dist/sub-agent-consult.d.ts +75 -0
  158. package/dist/sub-agent-consult.d.ts.map +1 -0
  159. package/dist/sub-agent-consult.js +193 -0
  160. package/dist/sub-agent-consult.js.map +1 -0
  161. package/dist/volatile-child-prompt.d.ts +7 -0
  162. package/dist/volatile-child-prompt.d.ts.map +1 -1
  163. package/dist/volatile-child-prompt.js +8 -0
  164. package/dist/volatile-child-prompt.js.map +1 -1
  165. package/package.json +20 -20
@@ -34,8 +34,9 @@ export const DEFAULT_RESPONSE_TYPE_INCLUSION_RULES = {
34
34
  pipeline: true,
35
35
  decisions: true,
36
36
  finishIf: true,
37
- // The one section that defaults OFF — see `enableTaskGraphs` (D3).
38
- tasks: false
37
+ // The sections that default OFF — capability gates, see `enableTaskGraphs` (D3) and `enableHandoff` (D14).
38
+ tasks: false,
39
+ handoff: false
39
40
  };
40
41
  /**
41
42
  * The most decision requests answered from one agent turn, unless `decisionsMaxRequests` overrides
@@ -100,8 +101,9 @@ export const DEFAULT_LOOP_AGENT_PROMPT_PARAMS = {
100
101
  finishIfThreshold: 0.9,
101
102
  // Off: an opt-in check that costs a decision call per flagged payload change.
102
103
  payloadFeedbackCheck: false,
103
- // Deliberately false — a capability gate, not a token-savings flag (D3).
104
+ // Deliberately false — capability gates, not token-savings flags (D3, D14).
104
105
  enableTaskGraphs: false,
106
+ enableHandoff: false,
105
107
  maxSubAgentsInPrompt: -1,
106
108
  maxActionsInPrompt: -1,
107
109
  clientToolResultMaxChars: -1,
@@ -1 +1 @@
1
- {"version":3,"file":"loop-agent-prompt-params.js","sourceRoot":"","sources":["../../src/agent-types/loop-agent-prompt-params.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;GAoBG;AA2GH;;;GAGG;AACH,MAAM,CAAC,MAAM,qCAAqC,GAAyC;IACvF,OAAO,EAAE,IAAI;IACb,aAAa,EAAE,IAAI;IACnB,QAAQ,EAAE,IAAI;IACd,OAAO,EAAE,IAAI;IACb,KAAK,EAAE,IAAI;IACX,UAAU,EAAE,IAAI;IAChB,iBAAiB,EAAE,IAAI;IACvB,QAAQ,EAAE,IAAI;IACd,SAAS,EAAE,IAAI;IACf,QAAQ,EAAE,IAAI;IACd,mEAAmE;IACnE,KAAK,EAAE,KAAK;CACf,CAAC;AA0cF;;;;GAIG;AACH,MAAM,CAAC,MAAM,8BAA8B,GAAG,CAAC,CAAC;AAEhD;;;;;GAKG;AACH,MAAM,CAAC,MAAM,2BAA2B,GAAG,GAAG,CAAC;AAE/C,iFAAiF;AACjF,MAAM,CAAC,MAAM,eAAe,GAA4B,CAAC,KAAK,EAAE,QAAQ,EAAE,IAAI,CAAC,CAAC;AAEhF;;;GAGG;AACH,MAAM,UAAU,cAAc,CAAC,KAAc;IACzC,OAAO,eAAe,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,CAAC,IAAI,KAAK,KAAK,CAAC,CAAC;AACxD,CAAC;AAED;;;GAGG;AACH,MAAM,UAAU,mBAAmB,CAAC,KAAc;IAC9C,OAAO,cAAc,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC;AACjD,CAAC;AAED;;;;GAIG;AACH,MAAM,CAAC,MAAM,gCAAgC,GAAwC;IACjF,6BAA6B,EAAE,EAAE,GAAG,qCAAqC,EAAE;IAC3E,kBAAkB,EAAE,IAAI;IACxB,gBAAgB,EAAE,IAAI;IACtB,uBAAuB,EAAE,IAAI;IAC7B,kBAAkB,EAAE,IAAI;IACxB,2BAA2B,EAAE,IAAI;IACjC,uBAAuB,EAAE,IAAI;IAC7B,sBAAsB,EAAE,IAAI;IAC5B,uBAAuB,EAAE,IAAI;IAC7B,qBAAqB,EAAE,IAAI;IAC3B,uBAAuB,EAAE,MAAM;IAC/B,iBAAiB,EAAE,MAAM;IACzB,kBAAkB,EAAE,EAAE;IACtB,wBAAwB,EAAE,IAAI;IAC9B,4BAA4B,EAAE,IAAI;IAClC,mBAAmB,EAAE,IAAI;IACzB,mGAAmG;IACnG,gBAAgB,EAAE,KAAK;IACvB,oBAAoB,EAAE,KAAK;IAC3B,iBAAiB,EAAE,GAAG;IACtB,oBAAoB,EAAE,8BAA8B;IACpD,wBAAwB,EAAE,2BAA2B;IACrD,kBAAkB,EAAE,kBAAkB;IACtC,YAAY,EAAE,KAAK;IACnB,mBAAmB,EAAE,IAAI;IACzB,iBAAiB,EAAE,GAAG;IACtB,8EAA8E;IAC9E,oBAAoB,EAAE,KAAK;IAC3B,yEAAyE;IACzE,gBAAgB,EAAE,KAAK;IACvB,oBAAoB,EAAE,CAAC,CAAC;IACxB,kBAAkB,EAAE,CAAC,CAAC;IACtB,wBAAwB,EAAE,CAAC,CAAC;IAC5B,iBAAiB,EAAE,KAAK;CAC3B,CAAC"}
1
+ {"version":3,"file":"loop-agent-prompt-params.js","sourceRoot":"","sources":["../../src/agent-types/loop-agent-prompt-params.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;GAoBG;AAsHH;;;GAGG;AACH,MAAM,CAAC,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AAuB,EAAE,MAAM;IAC/B,iBAAiB,EAAE,MAAM;IACzB,kBAAkB,EAAE,EAAE;IACtB,wBAAwB,EAAE,IAAI;IAC9B,4BAA4B,EAAE,IAAI;IAClC,mBAAmB,EAAE,IAAI;IACzB,mGAAmG;IACnG,gBAAgB,EAAE,KAAK;IACvB,oBAAoB,EAAE,KAAK;IAC3B,iBAAiB,EAAE,GAAG;IACtB,oBAAoB,EAAE,8BAA8B;IACpD,wBAAwB,EAAE,2BAA2B;IACrD,kBAAkB,EAAE,kBAAkB;IACtC,YAAY,EAAE,KAAK;IACnB,mBAAmB,EAAE,IAAI;IACzB,iBAAiB,EAAE,GAAG;IACtB,8EAA8E;IAC9E,oBAAoB,EAAE,KAAK;IAC3B,4EAA4E;IAC5E,gBAAgB,EAAE,KAAK;IACvB,aAAa,EAAE,KAAK;IACpB,oBAAoB,EAAE,CAAC,CAAC;IACxB,kBAAkB,EAAE,CAAC,CAAC;IACtB,wBAAwB,EAAE,CAAC,CAAC;IAC5B,iBAAiB,EAAE,KAAK;CAC3B,CAAC"}
@@ -1,4 +1,4 @@
1
- import { AgentPayloadChangeRequest, ForEachOperation, WhileOperation, AgentResponseForm, ActionableCommand, AutomaticCommand, AgentScratchpad, AgentPipelineRequest, TaskGraphSpec, AgentDecisionRequest, AgentFinishIf, ArtifactDirective } from "@memberjunction/ai-core-plus";
1
+ import { AgentPayloadChangeRequest, ForEachOperation, WhileOperation, AgentResponseForm, ActionableCommand, AutomaticCommand, AgentScratchpad, AgentPipelineRequest, TaskGraphSpec, AgentDecisionRequest, AgentFinishIf, AgentHandoffRequest, ArtifactDirective } from "@memberjunction/ai-core-plus";
2
2
  import { ArtifactToolCall } from "../ArtifactToolManager.js";
3
3
  import { ConversationToolCall } from "../ConversationToolManager.js";
4
4
  import { MemoryWriteRequest } from "../MemoryWriteManager.js";
@@ -16,7 +16,7 @@ export type { ForEachOperation, WhileOperation, ArtifactToolCall, ConversationTo
16
16
  * lower-cased `'chat'` passes validation (which compares case-insensitively) and then falls
17
17
  * through to `default:` — a forced Retry that costs a whole iteration.
18
18
  */
19
- export declare const LOOP_NEXT_STEP_TYPES: readonly ["Actions", "ClientTools", "Sub-Agent", "Chat", "Retry", "ForEach", "While", "Pipeline", "Skill", "Plan", "Tasks"];
19
+ export declare const LOOP_NEXT_STEP_TYPES: readonly ["Actions", "ClientTools", "Sub-Agent", "Chat", "Retry", "ForEach", "While", "Pipeline", "Skill", "Plan", "Tasks", "Handoff"];
20
20
  /** The `nextStep.type` union, derived from the interface rather than restated. */
21
21
  export type LoopNextStepType = NonNullable<LoopAgentResponse['nextStep']>['type'];
22
22
  /**
@@ -109,9 +109,9 @@ export interface LoopAgentResponse<P = any> {
109
109
  */
110
110
  nextStep?: {
111
111
  /**
112
- * Operation type: 'Actions' | 'ClientTools' | 'Sub-Agent' | 'Chat' | 'Retry' | 'ForEach' | 'While' | 'Pipeline' | 'Skill' | 'Plan' | 'Tasks'
112
+ * Operation type: 'Actions' | 'ClientTools' | 'Sub-Agent' | 'Chat' | 'Retry' | 'ForEach' | 'While' | 'Pipeline' | 'Skill' | 'Plan' | 'Tasks' | 'Handoff'
113
113
  */
114
- type: 'Actions' | 'ClientTools' | 'Sub-Agent' | 'Chat' | 'Retry' | 'ForEach' | 'While' | 'Pipeline' | 'Skill' | 'Plan' | 'Tasks';
114
+ type: 'Actions' | 'ClientTools' | 'Sub-Agent' | 'Chat' | 'Retry' | 'ForEach' | 'While' | 'Pipeline' | 'Skill' | 'Plan' | 'Tasks' | 'Handoff';
115
115
  /**
116
116
  * Actions to execute (when type='Actions')
117
117
  */
@@ -156,6 +156,17 @@ export interface LoopAgentResponse<P = any> {
156
156
  * true=end parent, false=continue
157
157
  */
158
158
  terminateAfter: boolean;
159
+ /**
160
+ * The ID of this sub-agent's earlier run that ended with a question to this agent;
161
+ * set it only to answer that question; the framework resumes that run (its payload,
162
+ * its question, then your message).
163
+ */
164
+ resumeRunId?: string;
165
+ /**
166
+ * Optional configuration preset of the target sub-agent, by name (or display name).
167
+ * Overrides the relationship's default `ConfigurationPresetID` and the parent's `configurationId`.
168
+ */
169
+ presetName?: string;
159
170
  };
160
171
  /**
161
172
  * Multiple sub-agents to run in parallel (when type='Sub-Agent')
@@ -165,6 +176,17 @@ export interface LoopAgentResponse<P = any> {
165
176
  message: string;
166
177
  templateParameters?: Record<string, any>;
167
178
  terminateAfter: boolean;
179
+ /**
180
+ * The ID of this sub-agent's earlier run that ended with a question to this agent;
181
+ * set it only to answer that question; the framework resumes that run (its payload,
182
+ * its question, then your message).
183
+ */
184
+ resumeRunId?: string;
185
+ /**
186
+ * Optional configuration preset of the target sub-agent, by name (or display name).
187
+ * Overrides the relationship's default `ConfigurationPresetID` and the parent's `configurationId`.
188
+ */
189
+ presetName?: string;
168
190
  }>;
169
191
  /**
170
192
  * Client tools to invoke (when type='ClientTools').
@@ -220,6 +242,15 @@ export interface LoopAgentResponse<P = any> {
220
242
  * results into the conversation or starts you a fresh turn with the outcome.
221
243
  */
222
244
  tasks?: TaskGraphSpec;
245
+ /**
246
+ * Conversation handoff details (when type='Handoff'). Required for that type.
247
+ *
248
+ * Transfers the conversation turn to another agent so that agent answers in this
249
+ * conversation as itself, with its own settings. Emitting one ends your turn; put
250
+ * everything the target agent needs in `brief`. Use `Handoff` when another agent
251
+ * should own the request, and `Sub-Agent` when you need a result back.
252
+ */
253
+ handoff?: AgentHandoffRequest;
223
254
  /**
224
255
  * Conditional completion gate for Actions or Sub-Agent steps.
225
256
  * Evaluated inline after the step executes: if all questions pass the probability
@@ -1 +1 @@
1
- {"version":3,"file":"loop-agent-response-type.d.ts","sourceRoot":"","sources":["../../src/agent-types/loop-agent-response-type.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,yBAAyB,EAAE,gBAAgB,EAAE,cAAc,EAAE,iBAAiB,EAAE,iBAAiB,EAAE,gBAAgB,EAAE,eAAe,EAAE,oBAAoB,EAAE,aAAa,EAAE,oBAAoB,EAAE,aAAa,EAAE,iBAAiB,EA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AC,MAAM,EAAE,OAAO,CAAC,CAAC;YACjC,MAAM,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;YACjC,SAAS,CAAC,EAAE,MAAM,CAAC;YACnB,SAAS,CAAC,EAAE,MAAM,CAAC;YACnB,WAAW,CAAC,EAAE,MAAM,CAAC;YACrB,WAAW,CAAC,EAAE,MAAM,CAAC;SACxB,CAAC,CAAC;QAEH;;WAEG;QACH,OAAO,CAAC,EAAE,gBAAgB,CAAC;QAE3B;;WAEG;QACH,KAAK,CAAC,EAAE,cAAc,CAAC;QAEvB;;;;;WAKG;QACH,MAAM,CAAC,EAAE,KAAK,CAAC;YACX,IAAI,EAAE,MAAM,CAAC;YACb;;;;eAIG;YACH,MAAM,CAAC,EAAE,MAAM,CAAC;SACnB,CAAC,CAAC;QAEH;;;;WAIG;QACH,IAAI,CAAC,EAAE,MAAM,CAAC;QAEd;;;;;;;;;WASG;QACH,KAAK,CAAC,EAAE,aAAa,CAAC;QAEtB;;;;;;;WAOG;QACH,OAAO,CAAC,EAAE,mBAAmB,CAAC;QAE9B;;;;WAIG;QACH,QAAQ,CAAC,EAAE,aAAa,CAAC;KAC5B,CAAC;CACL"}
@@ -13,7 +13,7 @@
13
13
  */
14
14
  export const LOOP_NEXT_STEP_TYPES = [
15
15
  'Actions', 'ClientTools', 'Sub-Agent', 'Chat', 'Retry',
16
- 'ForEach', 'While', 'Pipeline', 'Skill', 'Plan', 'Tasks'
16
+ 'ForEach', 'While', 'Pipeline', 'Skill', 'Plan', 'Tasks', 'Handoff'
17
17
  ];
18
18
  const _noInventedValues = true;
19
19
  const _noForgottenValues = true;
@@ -1 +1 @@
1
- {"version":3,"file":"loop-agent-response-type.js","sourceRoot":"","sources":["../../src/agent-types/loop-agent-response-type.ts"],"names":[],"mappings":"AAQA;;;;;;;;;;;;GAYG;AACH,MAAM,CAAC,MAAM,oBAAoB,GAAG;IAChC,SAAS,EAAE,aAAa,EAAE,WAAW,EAAE,MAAM,EAAE,OAAO;IACtD,SAAS,EAAE,OAAO,EAAE,UAAU,EAAE,OAAO,EAAE,MAAM,EAAE,OAAO;CAClD,CAAC;AAUX,MAAM,iBAAiB,GAAyD,IAAI,CAAC;AACrF,MAAM,kBAAkB,GAAyD,IAAI,CAAC;AAkPtF,oEAAoE;AACpE,sDAAsD"}
1
+ {"version":3,"file":"loop-agent-response-type.js","sourceRoot":"","sources":["../../src/agent-types/loop-agent-response-type.ts"],"names":[],"mappings":"AAQA;;;;;;;;;;;;GAYG;AACH,MAAM,CAAC,MAAM,oBAAoB,GAAG;IAChC,SAAS,EAAE,aAAa,EAAE,WAAW,EAAE,MAAM,EAAE,OAAO;IACtD,SAAS,EAAE,OAAO,EAAE,UAAU,EAAE,OAAO,EAAE,MAAM,EAAE,OAAO,EAAE,SAAS;CAC7D,CAAC;AAUX,MAAM,iBAAiB,GAAyD,IAAI,CAAC;AACrF,MAAM,kBAAkB,GAAyD,IAAI,CAAC;AAoRtF,oEAAoE;AACpE,sDAAsD"}
@@ -10,7 +10,7 @@
10
10
  * @since 2.49.0
11
11
  */
12
12
  import { BaseAgentType } from './base-agent-type.js';
13
- import type { NativeToolBinding } from '../native-tools/control-tools.js';
13
+ import { type NativeToolBinding } from '../native-tools/control-tools.js';
14
14
  import { AIPromptRunResult, BaseAgentNextStep, AIPromptParams, ExecuteAgentParams, AgentConfiguration, AgentAction } from '@memberjunction/ai-core-plus';
15
15
  import { MJAIPromptEntityExtended } from '@memberjunction/ai-core-plus';
16
16
  export declare class LoopAgentType extends BaseAgentType {
@@ -43,10 +43,13 @@ export declare class LoopAgentType extends BaseAgentType {
43
43
  /**
44
44
  * Resolves whether this agent may emit durable task graphs.
45
45
  *
46
- * Read from the merged three-level params bag (schema defaults → agent config → runtime
47
- * override), so a per-run override behaves like every other Loop parameter. Absent means NO:
48
- * this is the one Loop flag whose default is off, because the capability creates durable rows
49
- * that outlive the run rather than merely adding prompt text (D3).
46
+ * Read from `params.data.__agentTypePromptParams`, which `BaseAgent.determineNextStep`
47
+ * populates on a shallow copy of `params` from `this._agentTypePromptParams` (the merged
48
+ * three-level params bag: schema defaults → agent config → runtime override, with
49
+ * `withoutTaskGraphs` applied when the run withholds them), or which a direct unit caller
50
+ * supplies in `params.data`. Absent means NO: this is the one Loop flag whose default is
51
+ * off, because the capability creates durable rows that outlive the run rather than merely
52
+ * adding prompt text (D3).
50
53
  */
51
54
  private taskGraphsEnabled;
52
55
  /**
@@ -68,8 +71,28 @@ export declare class LoopAgentType extends BaseAgentType {
68
71
  * The reason is carried onto the run step rather than discarded: a user who edits a two-node
69
72
  * graph down to one changes its durability and observability, and should be able to read that
70
73
  * off the run record instead of inferring it.
74
+ *
75
+ * Note: `LoopAgentType` only checks structural eligibility here because it has no view of the
76
+ * run's effective sub-agent set (`ParentID` children, active relationships, and runtime skill /
77
+ * `subAgentChanges` grants). If the folded target is not resolvable via
78
+ * `BaseAgent.resolveSubAgentByName`, `BaseAgent.validateNextStep` unfolds the step back to
79
+ * `'Tasks'` (`folded: false`) so it submits durably instead of failing sub-agent validation.
71
80
  */
72
81
  private describeFold;
82
+ /**
83
+ * Resolves whether this agent may emit a conversation handoff (`nextStep.type === 'Handoff'`).
84
+ *
85
+ * Read from `params.data.__agentTypePromptParams`, which `BaseAgent.determineNextStep`
86
+ * populates on a shallow copy of `params` from `this._agentTypePromptParams` (with
87
+ * `withoutHandoff` applied when the run withholds handoff), or which a direct unit caller
88
+ * supplies in `params.data`. Absent means NO (D14).
89
+ */
90
+ private handoffEnabled;
91
+ /**
92
+ * Applies a `'Handoff'` emission to the next step: capability gate and shape validation.
93
+ * Never folds into a Sub-Agent step — a handoff transfers ownership of the conversation turn.
94
+ */
95
+ private applyHandoffStep;
73
96
  InitializeAgentTypeState<ATS = any, P = any>(params: ExecuteAgentParams<any, P>): Promise<ATS>;
74
97
  /**
75
98
  * Determines the next step based on the structured response from the AI model.
@@ -95,12 +118,71 @@ export declare class LoopAgentType extends BaseAgentType {
95
118
  * documented to do this, measured at roughly one forced call in six, so the loop
96
119
  * has to be able to say "that tool does not exist" rather than appear to hang.
97
120
  */
98
- protected nextStepFromNativeToolCalls(promptResult: AIPromptRunResult, bindings?: ReadonlyMap<string, NativeToolBinding>): BaseAgentNextStep | null;
121
+ protected nextStepFromNativeToolCalls(promptResult: AIPromptRunResult, bindings?: ReadonlyMap<string, NativeToolBinding>, relaxedTurnShapes?: boolean): BaseAgentNextStep | null;
122
+ /**
123
+ * Whether a binding runs on a hybrid turn. Actions and the agent's own tools run in every native
124
+ * mode; control tools — and the framework tools, which are declared as control tools — are
125
+ * stripped from a hybrid request, so a call to one there is a call to an undeclared tool.
126
+ */
127
+ private dispatchableOnHybrid;
128
+ /** What to do instead, after a call to a tool that does not exist on this turn. */
129
+ private unknownToolAdvice;
99
130
  /** Pairs each call with its binding; a control-tool binding counts only under implicit control flow. */
100
131
  private resolveNativeCalls;
101
- /** The turn-reading table of spec §2.1, one row per branch. */
102
- private routeResolvedCalls;
103
- /** `ask_user` ends the run as Chat / AwaitingFeedback; it must travel alone and carry a message. */
132
+ /**
133
+ * The turn-reading table of spec §2.1, with each control call alone on its turn — the default.
134
+ *
135
+ * `ask_user` and `complete_task` must be the only call on their turn, at most one
136
+ * `payload_change_request` is allowed, and acting and delegating cannot share a turn; each of
137
+ * these is a Retry that runs nothing. The agent's own tools ride along with Actions or a
138
+ * delegation, and alone are a turn of their own.
139
+ *
140
+ * @param completeTaskDeclared Whether the agent declares `complete_task`; a text-terminal agent
141
+ * does not, and is told to finish in plain text instead.
142
+ */
143
+ private routeStrict;
144
+ /**
145
+ * The turn-reading table with relaxed turn shapes (`NativeControl.RelaxedTurnShapes`): every
146
+ * call on the turn is honoured where the loop can do so without skipping a check.
147
+ * - Writes — the agent's own tools and `payload_change_request` — run inline, in call order,
148
+ * and are answered one by one. A single payload change keeps the step's own payload channel.
149
+ * - `ask_user` or `complete_task` after writes: the writes run, then the turn asks or completes
150
+ * through the normal Chat or Success validation. A failed write declines it (see BaseAgent).
151
+ * - Actions with a delegation, `ask_user` or `complete_task`: the Actions run, and the other
152
+ * calls are answered as not run — they were made before the Actions' results existed, and
153
+ * running them afterwards would skip the validation a turn's own decision gets.
154
+ *
155
+ * @param completeTaskDeclared Whether the agent declares `complete_task`; a text-terminal agent
156
+ * does not, and is told to finish in plain text instead.
157
+ */
158
+ private routeRelaxed;
159
+ /** The turn's calls by kind; `writes` holds agent-tool and payload calls in the order the model made them. */
160
+ private groupResolvedCalls;
161
+ /**
162
+ * The step for every non-terminal call on the turn, or undefined when there are none.
163
+ *
164
+ * One `payload_change_request` on a turn with no terminal call rides on the step's own payload
165
+ * channel, as it always has. Several — or one beside `ask_user` / `complete_task`, whose step
166
+ * cannot answer it — run with the agent's tools as ordered writes, each answered by its result.
167
+ */
168
+ private workStep;
169
+ /** Whether a step only writes — runs inline in the prompt step, with nothing executed after it. */
170
+ private isWritesOnly;
171
+ /** `ask_user` with the turn's other calls: after writes it asks; beside Actions or delegations it is declined. */
172
+ private withAskUser;
173
+ /** Adds one declined call to a step's list. */
174
+ private withDeclined;
175
+ /** `complete_task` with the turn's other calls — see {@link routeRelaxed} for when it runs. */
176
+ private withCompleteTask;
177
+ /** The turn's write calls, in call order, as the step carries them — or nothing when there are none. */
178
+ private agentToolCallRequests;
179
+ /**
180
+ * Agent-tool calls with no Action or delegation: the loop runs them, answers each call with its
181
+ * result, and goes again. A Retry with no instructions, so nothing but the results is added —
182
+ * the same non-terminal "go again" the payload-only turn uses.
183
+ */
184
+ private agentToolsStep;
185
+ /** `ask_user` ends the run as Chat / AwaitingFeedback; it must carry a message. */
104
186
  private askUserStep;
105
187
  /**
106
188
  * `complete_task` → Success, carrying its payload change — the native twin of the envelope's
@@ -133,6 +215,18 @@ export declare class LoopAgentType extends BaseAgentType {
133
215
  * (Pipeline uses it the same way); the instructions are what the loop shows the model.
134
216
  */
135
217
  private payloadOnlyStep;
218
+ /**
219
+ * What the model is told after a tool call the provider rejected — one it could not read, or one
220
+ * to a tool this turn did not offer — with the provider's description of the call, when it gave
221
+ * one, so the model can see what it sent.
222
+ */
223
+ private rejectedToolCallInstructions;
224
+ /**
225
+ * What a model on implicit control flow is told after writing JSON that could not be read. It
226
+ * names `complete_task` only when the agent declares it, and the envelope's step types only
227
+ * when the agent still has an envelope.
228
+ */
229
+ private envelopeAttemptInstructions;
136
230
  DetermineNextStep<P = any, ATS = any>(promptResult: AIPromptRunResult | null, params: ExecuteAgentParams<any, P>, payload: P, agentTypeState: ATS, nativeToolBindings?: ReadonlyMap<string, NativeToolBinding>): Promise<BaseAgentNextStep<P>>;
137
231
  /** Whether the response requests an Actions or Sub-Agent step that carries a valid finishIf. */
138
232
  private isGatedStep;
@@ -1 +1 @@
1
- {"version":3,"file":"loop-agent-type.d.ts","sourceRoot":"","sources":["../../src/agent-types/loop-agent-type.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAIH,OAAO,EAAE,aAAa,EAAE,MAAM,mBAAmB,CAAC;AAClD,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,+BAA+B,CAAC;AAMvE,OAAO,EAAE,iBAAiB,EAAE,iBAAiB,EAAE,cAAc,EAAE,kBAAkB,EAAE,kBAAkB,EAAE,WAAW,EAElE,MAAM,8BAA8B,CAAC;AAErF,OAAO,EAAE,wBAAwB,EAAE,MAAM,8BAA8B,CAAC;AAqDxE,qBACa,aAAc,SAAQ,aAAa;IAC5C,4GAA4G;IAC5G,IAAoB,uBAAuB,IAAI,OAAO,CAErD;IAED,OAAO,CAAC,UAAU,CAAiC;IAEnD;;;;;OAKG;IACH,OAAO,CAAC,8BAA8B,CAAK;IAE3C;;;;;;;;;;;;;;OAcG;IACH,OAAO,CAAC,2BAA2B;IAoCnC;;;;;;;OAOG;IACH,OAAO,CAAC,iBAAiB;IAKzB;;;;;;OAMG;IACH,OAAO,CAAC,cAAc;IAwEtB;;;OAGG;IACH,OAAO,CAAC,wBAAwB;IAwBhC;;;;;;OAMG;IACH,OAAO,CAAC,YAAY;IA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