@memberjunction/ai-agents 5.48.0 → 5.50.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (63) hide show
  1. package/README.md +14 -0
  2. package/dist/AgentRunner.d.ts.map +1 -1
  3. package/dist/AgentRunner.js +5 -0
  4. package/dist/AgentRunner.js.map +1 -1
  5. package/dist/ConversationCompactionManager.d.ts +202 -0
  6. package/dist/ConversationCompactionManager.d.ts.map +1 -0
  7. package/dist/ConversationCompactionManager.js +399 -0
  8. package/dist/ConversationCompactionManager.js.map +1 -0
  9. package/dist/ConversationToolManager.d.ts +154 -0
  10. package/dist/ConversationToolManager.d.ts.map +1 -0
  11. package/dist/ConversationToolManager.js +336 -0
  12. package/dist/ConversationToolManager.js.map +1 -0
  13. package/dist/agent-types/loop-agent-prompt-params.d.ts +8 -0
  14. package/dist/agent-types/loop-agent-prompt-params.d.ts.map +1 -1
  15. package/dist/agent-types/loop-agent-prompt-params.js +1 -0
  16. package/dist/agent-types/loop-agent-prompt-params.js.map +1 -1
  17. package/dist/agent-types/loop-agent-response-type.d.ts +10 -1
  18. package/dist/agent-types/loop-agent-response-type.d.ts.map +1 -1
  19. package/dist/agent-types/loop-agent-response-type.js.map +1 -1
  20. package/dist/agent-types/loop-agent-type.d.ts +23 -34
  21. package/dist/agent-types/loop-agent-type.d.ts.map +1 -1
  22. package/dist/agent-types/loop-agent-type.js +75 -2
  23. package/dist/agent-types/loop-agent-type.js.map +1 -1
  24. package/dist/base-agent.d.ts +314 -4
  25. package/dist/base-agent.d.ts.map +1 -1
  26. package/dist/base-agent.js +863 -95
  27. package/dist/base-agent.js.map +1 -1
  28. package/dist/conversation-history-format.d.ts +19 -0
  29. package/dist/conversation-history-format.d.ts.map +1 -0
  30. package/dist/conversation-history-format.js +40 -0
  31. package/dist/conversation-history-format.js.map +1 -0
  32. package/dist/index.d.ts +4 -0
  33. package/dist/index.d.ts.map +1 -1
  34. package/dist/index.js +4 -0
  35. package/dist/index.js.map +1 -1
  36. package/dist/prior-turn-tool-result-cache.d.ts +71 -0
  37. package/dist/prior-turn-tool-result-cache.d.ts.map +1 -0
  38. package/dist/prior-turn-tool-result-cache.js +85 -0
  39. package/dist/prior-turn-tool-result-cache.js.map +1 -0
  40. package/dist/realtime/realtime-client-session-service.d.ts +8 -1
  41. package/dist/realtime/realtime-client-session-service.d.ts.map +1 -1
  42. package/dist/realtime/realtime-client-session-service.js +44 -14
  43. package/dist/realtime/realtime-client-session-service.js.map +1 -1
  44. package/dist/realtime/realtime-coagent-config.d.ts +41 -0
  45. package/dist/realtime/realtime-coagent-config.d.ts.map +1 -1
  46. package/dist/realtime/realtime-coagent-config.js +69 -0
  47. package/dist/realtime/realtime-coagent-config.js.map +1 -1
  48. package/dist/realtime/realtime-session-runner.d.ts +72 -1
  49. package/dist/realtime/realtime-session-runner.d.ts.map +1 -1
  50. package/dist/realtime/realtime-session-runner.js +215 -13
  51. package/dist/realtime/realtime-session-runner.js.map +1 -1
  52. package/dist/realtime/realtime-tool-broker.d.ts +7 -2
  53. package/dist/realtime/realtime-tool-broker.d.ts.map +1 -1
  54. package/dist/realtime/realtime-tool-broker.js +13 -10
  55. package/dist/realtime/realtime-tool-broker.js.map +1 -1
  56. package/dist/realtime/realtime-turn-moderator.d.ts.map +1 -1
  57. package/dist/realtime/realtime-turn-moderator.js +0 -1
  58. package/dist/realtime/realtime-turn-moderator.js.map +1 -1
  59. package/dist/tool-result-format.d.ts +78 -0
  60. package/dist/tool-result-format.d.ts.map +1 -0
  61. package/dist/tool-result-format.js +46 -0
  62. package/dist/tool-result-format.js.map +1 -0
  63. package/package.json +18 -18
@@ -0,0 +1,78 @@
1
+ /**
2
+ * @fileoverview Single source of truth for the markdown tool-result section shape
3
+ * rendered back into the LLM's context:
4
+ *
5
+ * ```
6
+ * ### [ordinal. ][prefix.]tool({...input})
7
+ * ```json
8
+ * ...result data...
9
+ * ```
10
+ * ```
11
+ *
12
+ * Three call sites feed this shape to the model — same-turn conversation-tool
13
+ * injection, same-turn artifact-tool injection, and the prior-turn carry-forward
14
+ * message — and the loop-agent system prompt teaches the model to read it. All of
15
+ * them must render through these functions so the contract cannot drift between
16
+ * paths. Callers own size-capping policy; these functions only own the shape.
17
+ *
18
+ * @module @memberjunction/ai-agents
19
+ */
20
+ /**
21
+ * The tool families whose step results are eligible for prior-turn carry-forward —
22
+ * single source of the family values. Stamp sites and the eligibility check both
23
+ * derive from this map so a renamed value breaks at compile time, never silently.
24
+ */
25
+ export declare const CarryForwardToolFamily: {
26
+ readonly Conversation: "conversation";
27
+ readonly Artifact: "artifact";
28
+ };
29
+ /** One of the {@link CarryForwardToolFamily} values. */
30
+ export type CarryForwardToolFamilyValue = typeof CarryForwardToolFamily[keyof typeof CarryForwardToolFamily];
31
+ /**
32
+ * The cross-turn contract persisted in a tool step's `OutputData` by the conversation- and
33
+ * artifact-tool executors and read back by `BaseAgent.BuildPriorTurnToolResultsMessage` on
34
+ * the NEXT run. Write sites construct this type and the reader parses into a Partial of it,
35
+ * so the two sides cannot drift without a compile error.
36
+ */
37
+ export interface CarryForwardToolStepOutput {
38
+ /** Structured carry-forward discriminator — StepName is display-only */
39
+ toolFamily: CarryForwardToolFamilyValue;
40
+ /** The tool that produced this result */
41
+ tool: string;
42
+ /** The tool's input object */
43
+ input: unknown;
44
+ /** The tool outcome; only `success === true` results are carried forward */
45
+ result: {
46
+ success: boolean;
47
+ data?: unknown;
48
+ errorMessage?: string;
49
+ };
50
+ /** Invocation duration in milliseconds */
51
+ durationMs?: number;
52
+ /** Artifact-family only: the artifact the tool ran against */
53
+ artifactId?: string;
54
+ /** summarizeRange only: the recursive sub-call's AIPromptRun ID */
55
+ promptRunId?: string;
56
+ }
57
+ /** The minimal step projection the prior-turn carry-forward loader fetches and the renderer reads. */
58
+ export interface CarryForwardStepRecord {
59
+ OutputData: string | null;
60
+ }
61
+ /** Identifies one tool call within a rendered result section. */
62
+ export interface ToolResultSectionParts {
63
+ /** The tool name, e.g. `getMessageBySequence` */
64
+ tool: string;
65
+ /** The tool's input object (rendered as compact JSON in the heading) */
66
+ input: unknown;
67
+ /** 1-based ordinal when rendering a numbered multi-result message */
68
+ ordinal?: number;
69
+ /** Signature prefix for target-scoped tools, e.g. an artifact ID (`{prefix}.{tool}(...)`) */
70
+ signaturePrefix?: string;
71
+ }
72
+ /** Renders result data for the fenced block: strings pass through, everything else pretty-JSON. */
73
+ export declare function RenderToolResultData(data: unknown): string;
74
+ /** One successful tool-result section: heading + fenced JSON body (body already capped by the caller). */
75
+ export declare function FormatToolResultSection(parts: ToolResultSectionParts, body: string): string;
76
+ /** One failed tool-result section: heading + bolded error line. */
77
+ export declare function FormatToolErrorSection(parts: ToolResultSectionParts, errorMessage: string | undefined): string;
78
+ //# sourceMappingURL=tool-result-format.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"tool-result-format.d.ts","sourceRoot":"","sources":["../src/tool-result-format.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;GAkBG;AAEH;;;;GAIG;AACH,eAAO,MAAM,sBAAsB;;;CAGzB,CAAC;AAEX,wDAAwD;AACxD,MAAM,MAAM,2BAA2B,GAAG,OAAO,sBAAsB,CAAC,MAAM,OAAO,sBAAsB,CAAC,CAAC;AAE7G;;;;;GAKG;AACH,MAAM,WAAW,0BAA0B;IACvC,wEAAwE;IACxE,UAAU,EAAE,2BAA2B,CAAC;IACxC,yCAAyC;IACzC,IAAI,EAAE,MAAM,CAAC;IACb,8BAA8B;IAC9B,KAAK,EAAE,OAAO,CAAC;IACf,4EAA4E;IAC5E,MAAM,EAAE;QAAE,OAAO,EAAE,OAAO,CAAC;QAAC,IAAI,CAAC,EAAE,OAAO,CAAC;QAAC,YAAY,CAAC,EAAE,MAAM,CAAA;KAAE,CAAC;IACpE,0CAA0C;IAC1C,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,8DAA8D;IAC9D,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,mEAAmE;IACnE,WAAW,CAAC,EAAE,MAAM,CAAC;CACxB;AAED,sGAAsG;AACtG,MAAM,WAAW,sBAAsB;IACnC,UAAU,EAAE,MAAM,GAAG,IAAI,CAAC;CAC7B;AAED,iEAAiE;AACjE,MAAM,WAAW,sBAAsB;IACnC,iDAAiD;IACjD,IAAI,EAAE,MAAM,CAAC;IACb,wEAAwE;IACxE,KAAK,EAAE,OAAO,CAAC;IACf,qEAAqE;IACrE,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,6FAA6F;IAC7F,eAAe,CAAC,EAAE,MAAM,CAAC;CAC5B;AAQD,mGAAmG;AACnG,wBAAgB,oBAAoB,CAAC,IAAI,EAAE,OAAO,GAAG,MAAM,CAE1D;AAED,0GAA0G;AAC1G,wBAAgB,uBAAuB,CAAC,KAAK,EAAE,sBAAsB,EAAE,IAAI,EAAE,MAAM,GAAG,MAAM,CAE3F;AAED,mEAAmE;AACnE,wBAAgB,sBAAsB,CAAC,KAAK,EAAE,sBAAsB,EAAE,YAAY,EAAE,MAAM,GAAG,SAAS,GAAG,MAAM,CAE9G"}
@@ -0,0 +1,46 @@
1
+ /**
2
+ * @fileoverview Single source of truth for the markdown tool-result section shape
3
+ * rendered back into the LLM's context:
4
+ *
5
+ * ```
6
+ * ### [ordinal. ][prefix.]tool({...input})
7
+ * ```json
8
+ * ...result data...
9
+ * ```
10
+ * ```
11
+ *
12
+ * Three call sites feed this shape to the model — same-turn conversation-tool
13
+ * injection, same-turn artifact-tool injection, and the prior-turn carry-forward
14
+ * message — and the loop-agent system prompt teaches the model to read it. All of
15
+ * them must render through these functions so the contract cannot drift between
16
+ * paths. Callers own size-capping policy; these functions only own the shape.
17
+ *
18
+ * @module @memberjunction/ai-agents
19
+ */
20
+ /**
21
+ * The tool families whose step results are eligible for prior-turn carry-forward —
22
+ * single source of the family values. Stamp sites and the eligibility check both
23
+ * derive from this map so a renamed value breaks at compile time, never silently.
24
+ */
25
+ export const CarryForwardToolFamily = {
26
+ Conversation: 'conversation',
27
+ Artifact: 'artifact'
28
+ };
29
+ function formatHeading(parts) {
30
+ const ordinal = parts.ordinal !== undefined ? `${parts.ordinal}. ` : '';
31
+ const prefix = parts.signaturePrefix ? `${parts.signaturePrefix}.` : '';
32
+ return `### ${ordinal}${prefix}${parts.tool}(${JSON.stringify(parts.input || {})})`;
33
+ }
34
+ /** Renders result data for the fenced block: strings pass through, everything else pretty-JSON. */
35
+ export function RenderToolResultData(data) {
36
+ return typeof data === 'string' ? data : JSON.stringify(data, null, 2);
37
+ }
38
+ /** One successful tool-result section: heading + fenced JSON body (body already capped by the caller). */
39
+ export function FormatToolResultSection(parts, body) {
40
+ return `${formatHeading(parts)}\n\`\`\`json\n${body}\n\`\`\``;
41
+ }
42
+ /** One failed tool-result section: heading + bolded error line. */
43
+ export function FormatToolErrorSection(parts, errorMessage) {
44
+ return `${formatHeading(parts)}\n**Error:** ${errorMessage}`;
45
+ }
46
+ //# sourceMappingURL=tool-result-format.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"tool-result-format.js","sourceRoot":"","sources":["../src/tool-result-format.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;GAkBG;AAEH;;;;GAIG;AACH,MAAM,CAAC,MAAM,sBAAsB,GAAG;IAClC,YAAY,EAAE,cAAc;IAC5B,QAAQ,EAAE,UAAU;CACd,CAAC;AA6CX,SAAS,aAAa,CAAC,KAA6B;IAChD,MAAM,OAAO,GAAG,KAAK,CAAC,OAAO,KAAK,SAAS,CAAC,CAAC,CAAC,GAAG,KAAK,CAAC,OAAO,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC;IACxE,MAAM,MAAM,GAAG,KAAK,CAAC,eAAe,CAAC,CAAC,CAAC,GAAG,KAAK,CAAC,eAAe,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC;IACxE,OAAO,OAAO,OAAO,GAAG,MAAM,GAAG,KAAK,CAAC,IAAI,IAAI,IAAI,CAAC,SAAS,CAAC,KAAK,CAAC,KAAK,IAAI,EAAE,CAAC,GAAG,CAAC;AACxF,CAAC;AAED,mGAAmG;AACnG,MAAM,UAAU,oBAAoB,CAAC,IAAa;IAC9C,OAAO,OAAO,IAAI,KAAK,QAAQ,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,IAAI,CAAC,SAAS,CAAC,IAAI,EAAE,IAAI,EAAE,CAAC,CAAC,CAAC;AAC3E,CAAC;AAED,0GAA0G;AAC1G,MAAM,UAAU,uBAAuB,CAAC,KAA6B,EAAE,IAAY;IAC/E,OAAO,GAAG,aAAa,CAAC,KAAK,CAAC,iBAAiB,IAAI,UAAU,CAAC;AAClE,CAAC;AAED,mEAAmE;AACnE,MAAM,UAAU,sBAAsB,CAAC,KAA6B,EAAE,YAAgC;IAClG,OAAO,GAAG,aAAa,CAAC,KAAK,CAAC,gBAAgB,YAAY,EAAE,CAAC;AACjE,CAAC"}
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@memberjunction/ai-agents",
3
3
  "type": "module",
4
- "version": "5.48.0",
4
+ "version": "5.50.0",
5
5
  "description": "MemberJunction: AI Agent Execution and Management",
6
6
  "main": "dist/index.js",
7
7
  "types": "dist/index.d.ts",
@@ -17,23 +17,23 @@
17
17
  "author": "MemberJunction.com",
18
18
  "license": "ISC",
19
19
  "dependencies": {
20
- "@memberjunction/actions": "5.48.0",
21
- "@memberjunction/actions-base": "5.48.0",
22
- "@memberjunction/ai": "5.48.0",
23
- "@memberjunction/ai-core-plus": "5.48.0",
24
- "@memberjunction/ai-engine-base": "5.48.0",
25
- "@memberjunction/ai-prompts": "5.48.0",
26
- "@memberjunction/ai-reranker": "5.48.0",
27
- "@memberjunction/ai-vector-dupe": "5.48.0",
28
- "@memberjunction/ai-vector-sync": "5.48.0",
29
- "@memberjunction/aiengine": "5.48.0",
30
- "@memberjunction/context-crush": "5.48.0",
31
- "@memberjunction/core": "5.48.0",
32
- "@memberjunction/core-entities": "5.48.0",
33
- "@memberjunction/global": "5.48.0",
34
- "@memberjunction/search-engine": "5.48.0",
35
- "@memberjunction/storage": "5.48.0",
36
- "@memberjunction/templates": "5.48.0",
20
+ "@memberjunction/actions": "5.50.0",
21
+ "@memberjunction/actions-base": "5.50.0",
22
+ "@memberjunction/ai": "5.50.0",
23
+ "@memberjunction/ai-core-plus": "5.50.0",
24
+ "@memberjunction/ai-engine-base": "5.50.0",
25
+ "@memberjunction/ai-prompts": "5.50.0",
26
+ "@memberjunction/ai-reranker": "5.50.0",
27
+ "@memberjunction/ai-vector-dupe": "5.50.0",
28
+ "@memberjunction/ai-vector-sync": "5.50.0",
29
+ "@memberjunction/aiengine": "5.50.0",
30
+ "@memberjunction/context-crush": "5.50.0",
31
+ "@memberjunction/core": "5.50.0",
32
+ "@memberjunction/core-entities": "5.50.0",
33
+ "@memberjunction/global": "5.50.0",
34
+ "@memberjunction/search-engine": "5.50.0",
35
+ "@memberjunction/storage": "5.50.0",
36
+ "@memberjunction/templates": "5.50.0",
37
37
  "dotenv": "^17.2.4",
38
38
  "exceljs": "^4.4.0",
39
39
  "lodash": "^4.17.23",