@memberjunction/ai-agents 6.2.0-edge.1 → 6.2.0-edge.2

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 (99) hide show
  1. package/README.md +18 -0
  2. package/dist/AgentDecisionService.d.ts +83 -0
  3. package/dist/AgentDecisionService.d.ts.map +1 -0
  4. package/dist/AgentDecisionService.js +155 -0
  5. package/dist/AgentDecisionService.js.map +1 -0
  6. package/dist/AgentRunner.d.ts +7 -0
  7. package/dist/AgentRunner.d.ts.map +1 -1
  8. package/dist/AgentRunner.js +16 -5
  9. package/dist/AgentRunner.js.map +1 -1
  10. package/dist/KnowledgeAgent.d.ts.map +1 -1
  11. package/dist/KnowledgeAgent.js +6 -6
  12. package/dist/KnowledgeAgent.js.map +1 -1
  13. package/dist/PayloadFeedbackManager.d.ts +113 -14
  14. package/dist/PayloadFeedbackManager.d.ts.map +1 -1
  15. package/dist/PayloadFeedbackManager.js +228 -88
  16. package/dist/PayloadFeedbackManager.js.map +1 -1
  17. package/dist/agent-context-injector.d.ts +47 -3
  18. package/dist/agent-context-injector.d.ts.map +1 -1
  19. package/dist/agent-context-injector.js +77 -10
  20. package/dist/agent-context-injector.js.map +1 -1
  21. package/dist/agent-memory-context-builder.d.ts +13 -0
  22. package/dist/agent-memory-context-builder.d.ts.map +1 -1
  23. package/dist/agent-memory-context-builder.js +24 -5
  24. package/dist/agent-memory-context-builder.js.map +1 -1
  25. package/dist/agent-types/flow-agent-type.d.ts +97 -0
  26. package/dist/agent-types/flow-agent-type.d.ts.map +1 -1
  27. package/dist/agent-types/flow-agent-type.js +281 -24
  28. package/dist/agent-types/flow-agent-type.js.map +1 -1
  29. package/dist/agent-types/flow-graph-executor.d.ts +12 -1
  30. package/dist/agent-types/flow-graph-executor.d.ts.map +1 -1
  31. package/dist/agent-types/flow-graph-executor.js +25 -1
  32. package/dist/agent-types/flow-graph-executor.js.map +1 -1
  33. package/dist/agent-types/loop-agent-prompt-params.d.ts +239 -66
  34. package/dist/agent-types/loop-agent-prompt-params.d.ts.map +1 -1
  35. package/dist/agent-types/loop-agent-prompt-params.js +47 -2
  36. package/dist/agent-types/loop-agent-prompt-params.js.map +1 -1
  37. package/dist/agent-types/loop-agent-response-type.d.ts +12 -1
  38. package/dist/agent-types/loop-agent-response-type.d.ts.map +1 -1
  39. package/dist/agent-types/loop-agent-response-type.js.map +1 -1
  40. package/dist/agent-types/loop-agent-type.d.ts +6 -0
  41. package/dist/agent-types/loop-agent-type.d.ts.map +1 -1
  42. package/dist/agent-types/loop-agent-type.js +42 -3
  43. package/dist/agent-types/loop-agent-type.js.map +1 -1
  44. package/dist/base-agent.d.ts +492 -2
  45. package/dist/base-agent.d.ts.map +1 -1
  46. package/dist/base-agent.js +1686 -95
  47. package/dist/base-agent.js.map +1 -1
  48. package/dist/catalog-narrowing.d.ts +136 -0
  49. package/dist/catalog-narrowing.d.ts.map +1 -0
  50. package/dist/catalog-narrowing.js +212 -0
  51. package/dist/catalog-narrowing.js.map +1 -0
  52. package/dist/decision-discovery.d.ts +401 -0
  53. package/dist/decision-discovery.d.ts.map +1 -0
  54. package/dist/decision-discovery.js +511 -0
  55. package/dist/decision-discovery.js.map +1 -0
  56. package/dist/finish-if-mode-warnings.d.ts +39 -0
  57. package/dist/finish-if-mode-warnings.d.ts.map +1 -0
  58. package/dist/finish-if-mode-warnings.js +78 -0
  59. package/dist/finish-if-mode-warnings.js.map +1 -0
  60. package/dist/finish-if-state.d.ts +72 -0
  61. package/dist/finish-if-state.d.ts.map +1 -0
  62. package/dist/finish-if-state.js +109 -0
  63. package/dist/finish-if-state.js.map +1 -0
  64. package/dist/index.d.ts +6 -0
  65. package/dist/index.d.ts.map +1 -1
  66. package/dist/index.js +7 -0
  67. package/dist/index.js.map +1 -1
  68. package/dist/memory-manager-agent.d.ts +108 -2
  69. package/dist/memory-manager-agent.d.ts.map +1 -1
  70. package/dist/memory-manager-agent.js +172 -9
  71. package/dist/memory-manager-agent.js.map +1 -1
  72. package/dist/memory-note-gate.d.ts +208 -0
  73. package/dist/memory-note-gate.d.ts.map +1 -0
  74. package/dist/memory-note-gate.js +294 -0
  75. package/dist/memory-note-gate.js.map +1 -0
  76. package/dist/realtime/bridge-realtime-session-factory.d.ts +5 -2
  77. package/dist/realtime/bridge-realtime-session-factory.d.ts.map +1 -1
  78. package/dist/realtime/bridge-realtime-session-factory.js +7 -4
  79. package/dist/realtime/bridge-realtime-session-factory.js.map +1 -1
  80. package/dist/realtime/bridge-room-transcript-sink.d.ts.map +1 -1
  81. package/dist/realtime/bridge-room-transcript-sink.js +15 -9
  82. package/dist/realtime/bridge-room-transcript-sink.js.map +1 -1
  83. package/dist/realtime/realtime-client-session-service.d.ts +54 -12
  84. package/dist/realtime/realtime-client-session-service.d.ts.map +1 -1
  85. package/dist/realtime/realtime-client-session-service.js +76 -25
  86. package/dist/realtime/realtime-client-session-service.js.map +1 -1
  87. package/dist/realtime/realtime-vendor-resolution.d.ts +8 -3
  88. package/dist/realtime/realtime-vendor-resolution.d.ts.map +1 -1
  89. package/dist/realtime/realtime-vendor-resolution.js +3 -3
  90. package/dist/realtime/realtime-vendor-resolution.js.map +1 -1
  91. package/dist/rubric-evaluation-agent-runner.d.ts +2 -0
  92. package/dist/rubric-evaluation-agent-runner.d.ts.map +1 -0
  93. package/dist/rubric-evaluation-agent-runner.js +38 -0
  94. package/dist/rubric-evaluation-agent-runner.js.map +1 -0
  95. package/dist/self-check.d.ts +98 -0
  96. package/dist/self-check.d.ts.map +1 -0
  97. package/dist/self-check.js +74 -0
  98. package/dist/self-check.js.map +1 -0
  99. package/package.json +19 -18
package/README.md CHANGED
@@ -138,6 +138,21 @@ Abstract base that all agent types extend. Defines the `DetermineNextStep()` int
138
138
 
139
139
  Conversational agent that runs in a loop: prompt -> decide -> act -> repeat. Best for interactive, chat-based agents. The LLM decides the next step at each iteration by producing a structured JSON response.
140
140
 
141
+ ##### Decision models
142
+
143
+ An agent can ask a fast decision model typed questions in six places on its own. One master switch governs all of them: the Loop prompt param **`decisionsEnabled`**, `false` by default. Unless it is `true`, the agent never asks a decision model on its own, whatever the other settings say: their docs stay out of the prompt and the runtime refuses the call. With it `true`, each use still needs its own setting, and each of those is off by default too:
144
+
145
+ | Use | Its own setting |
146
+ |---|---|
147
+ | Inline `decisions` on a turn | `includeDecisionsDocs: true` |
148
+ | `finishIf` gates on an Actions or Sub-Agent step | `finishIfMode: 'shadow'` or `'on'` |
149
+ | Decision discovery (suggest an agent before the first prompt) | `decisionDiscovery: true` |
150
+ | Payload change check | `payloadFeedbackCheck: true` |
151
+ | Catalog narrowing | `maxActionsInPrompt` / `maxSubAgentsInPrompt` > 0 |
152
+ | Memory Manager note gate | run `data.enableDecisionGate: true` |
153
+
154
+ Set it in an agent's `AgentTypePromptParams` (`{"decisionsEnabled": true, "finishIfMode": "shadow"}`) or for one run in `data.__agentTypePromptParams`. Uses someone placed explicitly do not read it: a Flow or task-graph Decision step, the Run Decision action, and other direct callers of `AgentDecisionService`. See the [Decision Models guide](./docs/loop-agent-decisions.md).
155
+
141
156
  #### FlowAgentType
142
157
 
143
158
  Step-based agent that follows a predefined flow graph — steps with explicit conditional paths between them. Best for deterministic workflows where the execution path is known in advance.
@@ -150,6 +165,8 @@ Consequences worth knowing before you debug one:
150
165
  - **A run that needs the result walks the flow in-process.** A sub-agent run (one with `parentRun`) does this automatically, and a top-level caller opts in with `agentTypeParams.executionMode: 'inRun'` (`FlowAgentExecuteParams`). The run returns the flow's final payload, as in 5.x, and `startAtStep` works. A dispatched run that reaches the walker by mistake is refused at its choke point.
151
166
  - **The mode is on the run.** A completed `Decision` step named "Workflow runs in this run" or "Workflow runs on the task-graph dispatcher" records which engine ran it and why.
152
167
  - **A dispatched `Sub-Agent` node starts its own `AIAgentRun`**, linked from `Task.AgentRunID` and parented to the submitting run. If that sub-agent is itself a Flow agent, it runs in-process and returns its result to the task.
168
+ - **A `Decision` step routes the same way in both modes.** Paths read its answers only through `decisions.<key>.<question>`; its `stepResult.result` is the payload, which carries no answers. A flow with a Decision step is compiled and validated before its first step in-run too, so an incomplete Choice fork, a decision read before it can answer, or one read through the payload is refused in both modes. An answer below its `minConfidence` stops an in-run flow (the dispatcher holds the fork, and `Retry` on the step asks again). A failed decision call is a failed step: the paths that read its answers are passed over, and a recovery path such as `stepResult.Success === false` is taken whatever its rank.
169
+ - **Answers live in the run, not the payload.** A run started with `startAtStep` past a Decision step has no answers from it, so every path that reads that decision stops the run with the reason. Start at or before the Decision step to route on it.
153
170
 
154
171
  See the **[Workflows and Task Graphs Guide](../../../guides/WORKFLOW_AND_TASK_GRAPH_GUIDE.md)** for the full model: node kinds, exclusive groups, payload mappings, loops, failure semantics, observability, and a worked configuration example.
155
172
 
@@ -502,6 +519,7 @@ Detailed guides are available in the [`docs/`](./docs/) directory:
502
519
  | Guide | Description |
503
520
  |---|---|
504
521
  | [Actions Guide](./docs/actions-guide.md) | Action discovery, execution, result lifecycle, expiration/compaction, context recovery |
522
+ | [Decision Models](./docs/loop-agent-decisions.md) | The `decisionsEnabled` master switch, then each automatic use: inline decisions, finishIf gates, discovery, the payload change check, catalog narrowing, the Memory Manager note gate |
505
523
  | [Prompt-Cache Performance and Cost Briefing](./docs/PROMPT_CACHE_PERFORMANCE_BRIEFING.md) | Before/after cached share and cost per model and topology for the trailing runtime-state layout; the action circuit breaker's before/after; what to re-measure |
506
524
  | [Agent Prompt Caching Guide](../../../guides/AGENT_PROMPT_CACHING_GUIDE.md) | Repo-level guide: the trailing-state layout, the `PrefixPromptCache` flag from the model catalog, the Anthropic breakpoint seam, specialization placement, the circuit breaker |
507
525
  | [Client Tools Guide](./docs/CLIENT_TOOLS_GUIDE.md) | Browser-side tool invocation, runtime decoration, timeout config, prompt design, security |
@@ -0,0 +1,83 @@
1
+ /**
2
+ * @fileoverview Service for executing decision questions on behalf of agents.
3
+ *
4
+ * Wraps AIDecisionRunner and resolves decision prompts from the AIEngine catalog.
5
+ *
6
+ * @module @memberjunction/ai-agents
7
+ * @author MemberJunction.com
8
+ * @since 2.132.0
9
+ */
10
+ import { UserInfo } from '@memberjunction/core';
11
+ import { DecisionQuestion, DecisionAnswer } from '@memberjunction/ai';
12
+ import { AIDecisionRunResult } from '@memberjunction/ai-prompts';
13
+ import { AgentDecisionAnswerSummary } from '@memberjunction/ai-core-plus';
14
+ /**
15
+ * Parameters for the AgentDecisionService.Ask method.
16
+ */
17
+ export interface AgentDecisionAskParams {
18
+ /**
19
+ * The state the questions are asked about.
20
+ */
21
+ State: string | Record<string, unknown>;
22
+ /**
23
+ * Named questions to evaluate.
24
+ */
25
+ Questions: Record<string, DecisionQuestion>;
26
+ /**
27
+ * Context user executing the decision.
28
+ */
29
+ ContextUser: UserInfo;
30
+ /**
31
+ * Optional agent ID initiating the decision.
32
+ */
33
+ AgentID?: string;
34
+ /**
35
+ * Optional prompt name to resolve from AIEngine. Defaults to 'Default Decision'.
36
+ */
37
+ PromptName?: string;
38
+ /**
39
+ * Optional cancellation token to abort execution.
40
+ */
41
+ CancellationToken?: AbortSignal;
42
+ }
43
+ /**
44
+ * The questions of one decision request after their shapes are checked: the valid ones mapped onto
45
+ * BaseDecision's shape, and why each invalid one was dropped.
46
+ */
47
+ export interface DecisionQuestionMapping {
48
+ /** The valid questions, keyed as the agent keyed them, in BaseDecision's (PascalCase) shape. */
49
+ Questions: Record<string, DecisionQuestion>;
50
+ /** One reason per dropped question, naming its key. Empty when every question was valid. */
51
+ Invalid: string[];
52
+ }
53
+ /**
54
+ * Asks decision questions for an agent run through AIDecisionRunner and the configured decision prompt.
55
+ */
56
+ export declare class AgentDecisionService {
57
+ /**
58
+ * The decision prompt used when none is configured.
59
+ */
60
+ static readonly DEFAULT_PROMPT_NAME = "Default Decision";
61
+ /**
62
+ * Evaluates decision questions against the provided state using the configured decision prompt.
63
+ * Never throws: on failure or missing prompt, returns a failed AIDecisionRunResult.
64
+ */
65
+ Ask(args: AgentDecisionAskParams): Promise<AIDecisionRunResult>;
66
+ /**
67
+ * Checks each question's shape and maps the valid ones from the LLM-facing shape (camelCase) onto
68
+ * BaseDecision's (PascalCase). The questions are unchecked model output, so an invalid one is
69
+ * dropped, with its reason, rather than failing the others.
70
+ */
71
+ static ToDecisionQuestions(questions: Record<string, unknown>): DecisionQuestionMapping;
72
+ /** Maps one question, or returns why it is invalid. */
73
+ private static toDecisionQuestion;
74
+ /** A Choice needs a non-empty `options` array of `{ value, description }` strings. */
75
+ private static toChoiceQuestion;
76
+ /** A Score needs a non-empty `levels` array of strings, lowest first. */
77
+ private static toScoreQuestion;
78
+ /**
79
+ * Summarises answers for the model: probability, or value and confidence.
80
+ */
81
+ static SummarizeAnswers(answers: Record<string, DecisionAnswer>): Record<string, AgentDecisionAnswerSummary>;
82
+ }
83
+ //# sourceMappingURL=AgentDecisionService.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"AgentDecisionService.d.ts","sourceRoot":"","sources":["../src/AgentDecisionService.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAGH,OAAO,EAAE,QAAQ,EAAE,MAAM,sBAAsB,CAAC;AAChD,OAAO,EAAE,gBAAgB,EAAE,cAAc,EAAE,MAAM,oBAAoB,CAAC;AACtE,OAAO,EAAsC,mBAAmB,EAAE,MAAM,4BAA4B,CAAC;AACrG,OAAO,EAAE,0BAA0B,EAAE,MAAM,8BAA8B,CAAC;AAE1E;;GAEG;AACH,MAAM,WAAW,sBAAsB;IACnC;;OAEG;IACH,KAAK,EAAE,MAAM,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IAExC;;OAEG;IACH,SAAS,EAAE,MAAM,CAAC,MAAM,EAAE,gBAAgB,CAAC,CAAC;IAE5C;;OAEG;IACH,WAAW,EAAE,QAAQ,CAAC;IAEtB;;OAEG;IACH,OAAO,CAAC,EAAE,MAAM,CAAC;IAEjB;;OAEG;IACH,UAAU,CAAC,EAAE,MAAM,CAAC;IAEpB;;OAEG;IACH,iBAAiB,CAAC,EAAE,WAAW,CAAC;CACnC;AAED;;;GAGG;AACH,MAAM,WAAW,uBAAuB;IACpC,gGAAgG;IAChG,SAAS,EAAE,MAAM,CAAC,MAAM,EAAE,gBAAgB,CAAC,CAAC;IAE5C,4FAA4F;IAC5F,OAAO,EAAE,MAAM,EAAE,CAAC;CACrB;AAqBD;;GAEG;AACH,qBAAa,oBAAoB;IAC7B;;OAEG;IACH,gBAAuB,mBAAmB,sBAAsB;IAEhE;;;OAGG;IACU,GAAG,CAAC,IAAI,EAAE,sBAAsB,GAAG,OAAO,CAAC,mBAAmB,CAAC;IA+B5E;;;;OAIG;WACW,mBAAmB,CAAC,SAAS,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,uBAAuB;IAa9F,uDAAuD;IACvD,OAAO,CAAC,MAAM,CAAC,kBAAkB;IAmBjC,sFAAsF;IACtF,OAAO,CAAC,MAAM,CAAC,gBAAgB;IAc/B,yEAAyE;IACzE,OAAO,CAAC,MAAM,CAAC,eAAe;IAO9B;;OAEG;WACW,gBAAgB,CAAC,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,cAAc,CAAC,GAAG,MAAM,CAAC,MAAM,EAAE,0BAA0B,CAAC;CAyBtH"}
@@ -0,0 +1,155 @@
1
+ /**
2
+ * @fileoverview Service for executing decision questions on behalf of agents.
3
+ *
4
+ * Wraps AIDecisionRunner and resolves decision prompts from the AIEngine catalog.
5
+ *
6
+ * @module @memberjunction/ai-agents
7
+ * @author MemberJunction.com
8
+ * @since 2.132.0
9
+ */
10
+ import { AIEngine } from '@memberjunction/aiengine';
11
+ import { AIDecisionRunner, AIDecisionParams } from '@memberjunction/ai-prompts';
12
+ /** A plain object, as opposed to null, an array or a primitive. */
13
+ function isPlainObject(value) {
14
+ return typeof value === 'object' && value !== null && !Array.isArray(value);
15
+ }
16
+ /** An array whose every item passes `guard`. */
17
+ function isArrayOf(value, guard) {
18
+ return Array.isArray(value) && value.every(item => guard(item));
19
+ }
20
+ function isString(value) {
21
+ return typeof value === 'string';
22
+ }
23
+ /** One option of a Choice question, as the model writes it. */
24
+ function isChoiceOption(value) {
25
+ return isPlainObject(value) && typeof value.value === 'string' && typeof value.description === 'string';
26
+ }
27
+ /**
28
+ * Asks decision questions for an agent run through AIDecisionRunner and the configured decision prompt.
29
+ */
30
+ export class AgentDecisionService {
31
+ /**
32
+ * The decision prompt used when none is configured.
33
+ */
34
+ static { this.DEFAULT_PROMPT_NAME = 'Default Decision'; }
35
+ /**
36
+ * Evaluates decision questions against the provided state using the configured decision prompt.
37
+ * Never throws: on failure or missing prompt, returns a failed AIDecisionRunResult.
38
+ */
39
+ async Ask(args) {
40
+ try {
41
+ await AIEngine.Instance.Config(false, args.ContextUser);
42
+ const targetName = (args.PromptName ?? AgentDecisionService.DEFAULT_PROMPT_NAME).trim().toLowerCase();
43
+ const prompt = AIEngine.Instance.Prompts?.find(p => (p.Name ?? '').trim().toLowerCase() === targetName);
44
+ if (!prompt) {
45
+ return {
46
+ success: false,
47
+ errorMessage: `Decision prompt "${args.PromptName ?? AgentDecisionService.DEFAULT_PROMPT_NAME}" not found`,
48
+ Answers: {},
49
+ };
50
+ }
51
+ const params = new AIDecisionParams();
52
+ params.prompt = prompt;
53
+ params.contextUser = args.ContextUser;
54
+ params.State = args.State;
55
+ params.Questions = args.Questions;
56
+ params.cancellationToken = args.CancellationToken;
57
+ params.agentId = args.AgentID;
58
+ return await new AIDecisionRunner().ExecuteDecision(params);
59
+ }
60
+ catch (error) {
61
+ return {
62
+ success: false,
63
+ errorMessage: `The decision call failed: ${error instanceof Error ? error.message : String(error)}`,
64
+ Answers: {},
65
+ };
66
+ }
67
+ }
68
+ /**
69
+ * Checks each question's shape and maps the valid ones from the LLM-facing shape (camelCase) onto
70
+ * BaseDecision's (PascalCase). The questions are unchecked model output, so an invalid one is
71
+ * dropped, with its reason, rather than failing the others.
72
+ */
73
+ static ToDecisionQuestions(questions) {
74
+ const mapping = { Questions: {}, Invalid: [] };
75
+ for (const [key, candidate] of Object.entries(questions)) {
76
+ const mapped = AgentDecisionService.toDecisionQuestion(candidate);
77
+ if (typeof mapped === 'string') {
78
+ mapping.Invalid.push(`Question "${key}" ${mapped}`);
79
+ }
80
+ else {
81
+ mapping.Questions[key] = mapped;
82
+ }
83
+ }
84
+ return mapping;
85
+ }
86
+ /** Maps one question, or returns why it is invalid. */
87
+ static toDecisionQuestion(candidate) {
88
+ if (!isPlainObject(candidate)) {
89
+ return 'is not an object';
90
+ }
91
+ if (typeof candidate.instructions !== 'string') {
92
+ return 'has no "instructions" string';
93
+ }
94
+ switch (candidate.kind) {
95
+ case 'Likelihood':
96
+ return { Kind: 'Likelihood', Instructions: candidate.instructions };
97
+ case 'Choice':
98
+ return AgentDecisionService.toChoiceQuestion(candidate.instructions, candidate.options);
99
+ case 'Score':
100
+ return AgentDecisionService.toScoreQuestion(candidate.instructions, candidate.levels);
101
+ default:
102
+ return `has an unknown kind "${String(candidate.kind)}" (use Likelihood, Choice or Score)`;
103
+ }
104
+ }
105
+ /** A Choice needs a non-empty `options` array of `{ value, description }` strings. */
106
+ static toChoiceQuestion(instructions, options) {
107
+ if (!isArrayOf(options, isChoiceOption) || options.length === 0) {
108
+ return 'is a Choice without a non-empty "options" array of { value, description } strings';
109
+ }
110
+ return {
111
+ Kind: 'Choice',
112
+ Instructions: instructions,
113
+ Options: options.map(opt => ({
114
+ Value: opt.value,
115
+ Description: opt.description,
116
+ })),
117
+ };
118
+ }
119
+ /** A Score needs a non-empty `levels` array of strings, lowest first. */
120
+ static toScoreQuestion(instructions, levels) {
121
+ if (!isArrayOf(levels, isString) || levels.length === 0) {
122
+ return 'is a Score without a non-empty "levels" array of strings';
123
+ }
124
+ return { Kind: 'Score', Instructions: instructions, Levels: [...levels] };
125
+ }
126
+ /**
127
+ * Summarises answers for the model: probability, or value and confidence.
128
+ */
129
+ static SummarizeAnswers(answers) {
130
+ const result = {};
131
+ for (const [key, a] of Object.entries(answers)) {
132
+ switch (a.Kind) {
133
+ case 'Likelihood':
134
+ result[key] = {
135
+ probability: a.Probability,
136
+ };
137
+ break;
138
+ case 'Choice':
139
+ result[key] = {
140
+ value: a.Value,
141
+ confidence: a.Confidence,
142
+ };
143
+ break;
144
+ case 'Score':
145
+ result[key] = {
146
+ value: a.Value,
147
+ confidence: a.Confidence,
148
+ };
149
+ break;
150
+ }
151
+ }
152
+ return result;
153
+ }
154
+ }
155
+ //# sourceMappingURL=AgentDecisionService.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"AgentDecisionService.js","sourceRoot":"","sources":["../src/AgentDecisionService.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,OAAO,EAAE,QAAQ,EAAE,MAAM,0BAA0B,CAAC;AAGpD,OAAO,EAAE,gBAAgB,EAAE,gBAAgB,EAAuB,MAAM,4BAA4B,CAAC;AAkDrG,mEAAmE;AACnE,SAAS,aAAa,CAAC,KAAc;IACjC,OAAO,OAAO,KAAK,KAAK,QAAQ,IAAI,KAAK,KAAK,IAAI,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC;AAChF,CAAC;AAED,gDAAgD;AAChD,SAAS,SAAS,CAAI,KAAc,EAAE,KAAmC;IACrE,OAAO,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,IAAI,KAAK,CAAC,KAAK,CAAC,IAAI,CAAC,EAAE,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC,CAAC;AACpE,CAAC;AAED,SAAS,QAAQ,CAAC,KAAc;IAC5B,OAAO,OAAO,KAAK,KAAK,QAAQ,CAAC;AACrC,CAAC;AAED,+DAA+D;AAC/D,SAAS,cAAc,CAAC,KAAc;IAClC,OAAO,aAAa,CAAC,KAAK,CAAC,IAAI,OAAO,KAAK,CAAC,KAAK,KAAK,QAAQ,IAAI,OAAO,KAAK,CAAC,WAAW,KAAK,QAAQ,CAAC;AAC5G,CAAC;AAED;;GAEG;AACH,MAAM,OAAO,oBAAoB;IAC7B;;OAEG;aACoB,wBAAmB,GAAG,kBAAkB,CAA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C,QAAQ,CAAC,CAAC,IAAI,EAAE,CAAC;gBACb,KAAK,YAAY;oBACb,MAAM,CAAC,GAAG,CAAC,GAAG;wBACV,WAAW,EAAE,CAAC,CAAC,WAAW;qBAC7B,CAAC;oBACF,MAAM;gBACV,KAAK,QAAQ;oBACT,MAAM,CAAC,GAAG,CAAC,GAAG;wBACV,KAAK,EAAE,CAAC,CAAC,KAAK;wBACd,UAAU,EAAE,CAAC,CAAC,UAAU;qBAC3B,CAAC;oBACF,MAAM;gBACV,KAAK,OAAO;oBACR,MAAM,CAAC,GAAG,CAAC,GAAG;wBACV,KAAK,EAAE,CAAC,CAAC,KAAK;wBACd,UAAU,EAAE,CAAC,CAAC,UAAU;qBAC3B,CAAC;oBACF,MAAM;YACd,CAAC;QACL,CAAC;QACD,OAAO,MAAM,CAAC;IAClB,CAAC"}
@@ -51,6 +51,13 @@ export declare function selectPrimaryArtifact(fileArtifacts: readonly CreatedArt
51
51
  * ```
52
52
  */
53
53
  export declare class AgentRunner {
54
+ /**
55
+ * Why a conversation-detail `Save()` returned false, for an error or log line. The owner gate in
56
+ * `MJConversationDetailEntityExtended` refuses a non-owner's write (e.g. the elevated System user
57
+ * on a widget guest's conversation) and records the reason ONLY on `LatestResult` — it logs
58
+ * nothing itself — so a caller that reports a fixed string loses it (MJ#4791).
59
+ */
60
+ private static saveFailureReason;
54
61
  /** Fallback artifact type for agent payloads when the agent declares no DefaultArtifactTypeID. */
55
62
  private static readonly JSON_ARTIFACT_TYPE_ID;
56
63
  /**
@@ -1 +1 @@
1
- {"version":3,"file":"AgentRunner.d.ts","sourceRoot":"","sources":["../src/AgentRunner.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAGH,OAAO,EAA0F,QAAQ,EAAE,iBAAiB,EAAsC,MAAM,sBAAsB,CAAC;AAG/L,OAAO,EAAE,kBAAkB,EAAE,kBAAkB,EAAE,WAAW,EAAE,aAAa,EAA4D,MAAM,8BAA8B,CAAC;AAC5K,OAAO,EAA+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;;;;;;;OAUG;YACW,2BAA2B;IAwBzC;;;;;;;;;;;;OAYG;IACU,oBAAoB,CAC7B,WAAW,EAAE,aAAa,EAAE,EAC5B,oBAAoB,EAAE,MAAM,EAC5B,WAAW,EAAE,QAAQ,EACrB,wBAAwB,CAAC,EAAE,MAAM,EACjC,QAAQ,CAAC,EAAE,iBAAiB,EAC5B,uBAAuB,CAAC,EAAE,OAAO,GAClC,OAAO,CAAC,mBAAmB,EAAE,CAAC;IAoBjC;0FACsF;YACxE,iBAAiB;IAyB/B;;;;;;OAMG;YACW,qBAAqB;IAmBnC;;;;OAIG;YACW,yBAAyB;IAkHvC;;;;OAIG;YACW,kBAAkB;IAsBhC,0FAA0F;YAC5E,wBAAwB;IAqBtC;;;OAGG;IACH,OAAO,CAAC,oBAAoB;IAkB5B;;;;;;;;;;;;;;;;;;OAkBG;YACW,gCAAgC;IA0C9C;;;;;;;;;;;;;;;;;OAiBG;YACW,4BAA4B;IAY1C;;;OAGG;YACW,qBAAqB;IAYnC;;;;;;;OAOG;YACW,2BAA2B;IAkIzC;;;;;;;;;;;;;;;;OAgBG;YACW,uBAAuB;IAgDrC;;;OAGG;IACH,OAAO,CAAC,qBAAqB;IAS7B;;;;;;;;OAQG;YACW,2BAA2B;CAyC5C"}
@@ -53,6 +53,15 @@ export function selectPrimaryArtifact(fileArtifacts, payloadArtifact) {
53
53
  * ```
54
54
  */
55
55
  export class AgentRunner {
56
+ /**
57
+ * Why a conversation-detail `Save()` returned false, for an error or log line. The owner gate in
58
+ * `MJConversationDetailEntityExtended` refuses a non-owner's write (e.g. the elevated System user
59
+ * on a widget guest's conversation) and records the reason ONLY on `LatestResult` — it logs
60
+ * nothing itself — so a caller that reports a fixed string loses it (MJ#4791).
61
+ */
62
+ static saveFailureReason(entity) {
63
+ return entity.LatestResult?.CompleteMessage?.trim() || 'no failure detail recorded';
64
+ }
56
65
  /** Fallback artifact type for agent payloads when the agent declares no DefaultArtifactTypeID. */
57
66
  static { this.JSON_ARTIFACT_TYPE_ID = 'ae674c7e-ea0d-49ea-89e4-0649f5eb20d4'; }
58
67
  /**
@@ -253,7 +262,7 @@ export class AgentRunner {
253
262
  userMessageDetail.TestRunID = options.testRunId;
254
263
  }
255
264
  if (!(await userMessageDetail.Save())) {
256
- throw new Error('Failed to create user message conversation detail');
265
+ throw new Error(`Failed to create user message conversation detail: ${AgentRunner.saveFailureReason(userMessageDetail)}`);
257
266
  }
258
267
  userMessageDetailId = userMessageDetail.ID;
259
268
  LogStatus(`Created user message detail ${userMessageDetailId}`);
@@ -271,7 +280,7 @@ export class AgentRunner {
271
280
  agentResponseDetail.TestRunID = options.testRunId;
272
281
  }
273
282
  if (!(await agentResponseDetail.Save())) {
274
- throw new Error('Failed to create agent response conversation detail');
283
+ throw new Error(`Failed to create agent response conversation detail: ${AgentRunner.saveFailureReason(agentResponseDetail)}`);
275
284
  }
276
285
  agentResponseDetailId = agentResponseDetail.ID;
277
286
  LogStatus(`Created agent response detail ${agentResponseDetailId}`);
@@ -299,7 +308,7 @@ export class AgentRunner {
299
308
  agentResponseDetail.Message = progress.message;
300
309
  const saved = await agentResponseDetail.Save();
301
310
  if (!saved) {
302
- LogError('Failed to save agent response detail progress update');
311
+ LogError(`Failed to save agent response detail progress update: ${AgentRunner.saveFailureReason(agentResponseDetail)}`);
303
312
  }
304
313
  }
305
314
  // Call original callback if provided
@@ -387,7 +396,7 @@ export class AgentRunner {
387
396
  }
388
397
  const saved = await agentResponseDetail.Save();
389
398
  if (!saved) {
390
- LogError(`Failed to save agent response detail ${agentResponseDetailId} with final status`);
399
+ LogError(`Failed to save agent response detail ${agentResponseDetailId} with final status: ${AgentRunner.saveFailureReason(agentResponseDetail)}`);
391
400
  }
392
401
  LogStatus(`Updated agent response detail ${agentResponseDetailId} with final status: ${agentResponseDetail.Status}`);
393
402
  }
@@ -498,7 +507,9 @@ export class AgentRunner {
498
507
  agentResponseDetail.Status = 'Error';
499
508
  agentResponseDetail.Message = errorMessage;
500
509
  agentResponseDetail.Error = errorMessage;
501
- await agentResponseDetail.Save();
510
+ if (!(await agentResponseDetail.Save())) {
511
+ LogError(`Failed to persist Error on conversation detail ${agentResponseDetail.ID}: ${AgentRunner.saveFailureReason(agentResponseDetail)}`);
512
+ }
502
513
  }
503
514
  catch (persistError) {
504
515
  LogError(`Failed to persist Error on conversation detail after agent crash: ${persistError}`, undefined, persistError);