@memberjunction/ai-prompts 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.
- package/README.md +54 -2
- package/dist/AIModelRunner.d.ts +4 -0
- package/dist/AIModelRunner.d.ts.map +1 -1
- package/dist/AIModelRunner.js +7 -1
- package/dist/AIModelRunner.js.map +1 -1
- package/dist/AIPromptRunner.d.ts +51 -6
- package/dist/AIPromptRunner.d.ts.map +1 -1
- package/dist/AIPromptRunner.js +285 -125
- package/dist/AIPromptRunner.js.map +1 -1
- package/dist/AIPromptTimeoutError.d.ts +7 -1
- package/dist/AIPromptTimeoutError.d.ts.map +1 -1
- package/dist/AIPromptTimeoutError.js +5 -0
- package/dist/AIPromptTimeoutError.js.map +1 -1
- package/dist/BaseModelRunner.d.ts +106 -13
- package/dist/BaseModelRunner.d.ts.map +1 -1
- package/dist/BaseModelRunner.js +379 -74
- package/dist/BaseModelRunner.js.map +1 -1
- package/dist/PromptRunDataCapture.d.ts +54 -0
- package/dist/PromptRunDataCapture.d.ts.map +1 -0
- package/dist/PromptRunDataCapture.js +181 -0
- package/dist/PromptRunDataCapture.js.map +1 -0
- package/dist/audio/AISpeechToTextRunner.d.ts +2 -1
- package/dist/audio/AISpeechToTextRunner.d.ts.map +1 -1
- package/dist/audio/AISpeechToTextRunner.js +5 -3
- package/dist/audio/AISpeechToTextRunner.js.map +1 -1
- package/dist/audio/AITextToSpeechRunner.js +1 -1
- package/dist/audio/AITextToSpeechRunner.js.map +1 -1
- package/dist/decision/AIDecisionRunner.d.ts.map +1 -1
- package/dist/decision/AIDecisionRunner.js +8 -3
- package/dist/decision/AIDecisionRunner.js.map +1 -1
- package/dist/embedding/AIEmbeddingRunner.d.ts +24 -1
- package/dist/embedding/AIEmbeddingRunner.d.ts.map +1 -1
- package/dist/embedding/AIEmbeddingRunner.js +80 -21
- package/dist/embedding/AIEmbeddingRunner.js.map +1 -1
- package/dist/embedding/embedding-runner.types.d.ts +14 -0
- package/dist/embedding/embedding-runner.types.d.ts.map +1 -1
- package/dist/image/AIImageGenerationRunner.d.ts +31 -5
- package/dist/image/AIImageGenerationRunner.d.ts.map +1 -1
- package/dist/image/AIImageGenerationRunner.js +75 -13
- package/dist/image/AIImageGenerationRunner.js.map +1 -1
- package/dist/image/image-runner.types.d.ts +14 -0
- package/dist/image/image-runner.types.d.ts.map +1 -1
- package/dist/media/BaseMediaRunner.d.ts +20 -18
- package/dist/media/BaseMediaRunner.d.ts.map +1 -1
- package/dist/media/BaseMediaRunner.js +35 -51
- package/dist/media/BaseMediaRunner.js.map +1 -1
- package/dist/media/media-runner.types.d.ts +9 -6
- package/dist/media/media-runner.types.d.ts.map +1 -1
- package/dist/video/AIVideoRunner.js +1 -1
- package/dist/video/AIVideoRunner.js.map +1 -1
- package/package.json +13 -12
package/README.md
CHANGED
|
@@ -185,7 +185,59 @@ Every prompt execution creates an `AIPromptRun` record with:
|
|
|
185
185
|
- Parent/child relationships for hierarchical prompts
|
|
186
186
|
- Agent run linkage via `agentRunId`
|
|
187
187
|
|
|
188
|
-
**Persistence is fire-and-forget.** The initial `Running` INSERT and the final `Completed`/`Failed` UPDATE are queued
|
|
188
|
+
**Persistence is fire-and-forget (`BaseEntitySaveQueue`).** The initial `Running` INSERT (`CreateRunRecord`) and the final `Completed`/`Failed`/`Cancelled` UPDATE (`FinalizeRunRecord`) are queued on `_promptRunQueue`, not awaited on the hot path, so model calls are never blocked on database round-trips:
|
|
189
|
+
- **Synchronous in-memory finalization + reload-safe queued UPDATE**: `FinalizeRunRecord` mutates `CompletedAt`, `ExecutionTimeMS`, `Success`, `Status`, failover counters, `TotalCost`, token rollups, and `applyResultFields(promptRun)` synchronously in memory before enqueueing the UPDATE, so callers inspecting `result.promptRun` immediately see finalized state. The queued UPDATE callback also re-applies the captured finalized snapshot so an in-flight `INSERT` reload (`BaseEntity.Save()` reloading server fields when `INSERT` completes) cannot revert the finalized columns back to `Running`.
|
|
190
|
+
- **Parent-child FK ordering (`FK_AIPromptRun_ParentID`)**: When a child prompt run (`params.parentPromptRunId`) is created while its parent `AIPromptRun`'s `INSERT` is still in flight (`!parentRun.IsSaved`), `CreateRunRecord` chains the child via `_promptRunQueue.InsertAfter(promptRun, parentRun)` so the parent row is guaranteed to exist in the database before the child `INSERT` executes.
|
|
191
|
+
- **Terminal settlement (`FlushPendingSaves()` / `WaitForPendingPromptRunSaves()`)**: Callers that need all queued `AIPromptRun` INSERTs and UPDATEs durably written before continuing (such as `BaseAgent` on run completion, failure, cancellation, or post-turn compaction) can `await runner.FlushPendingSaves()` (or `await runner.WaitForPendingPromptRunSaves()`). Save failures are logged via `LogError` and surfaced in the returned `BaseEntitySaveQueueFlushResult`, never failing the prompt itself.
|
|
192
|
+
|
|
193
|
+
### Template data capture
|
|
194
|
+
|
|
195
|
+
`AIPromptRun.Messages` stores the messages the model received. The template inputs (`data` and `templateData`) can be large, so a capture mode sets how much of them the run stores:
|
|
196
|
+
|
|
197
|
+
| Mode | What `Messages` stores for `data` and `templateData` |
|
|
198
|
+
|---|---|
|
|
199
|
+
| `None` (default) | A `dataShape` record. For each input: the key count, the total byte size of the values, and the UTF-8 byte length of each top-level value's JSON. It lists at most 25 keys per input (the largest; `keysElided: true` when there are more). It never stores values. |
|
|
200
|
+
| `Referenced` | Only the top-level keys that the run's templates read: the prompt's template, every child prompt template, and the templates they pull in by literal name. If the analysis cannot finish (for example, a template name is an expression or a template is not found), the run stores all keys, with `dataCapture: 'Full'` and a `dataCaptureNote` that gives the reason. |
|
|
201
|
+
| `Full` | All keys. |
|
|
202
|
+
|
|
203
|
+
The run uses the first setting that is present:
|
|
204
|
+
|
|
205
|
+
1. `AIPromptParams.TemplateDataCapture` (the call)
|
|
206
|
+
2. `AIPrompt.TemplateDataCapture` on the run's child prompts (`AIPromptParams.childPrompts`), depth first: each child prompt, then its own child prompts. The first value that is not `NULL` applies.
|
|
207
|
+
3. `AIPrompt.TemplateDataCapture` on the main prompt (`NULL` uses the next setting)
|
|
208
|
+
4. `aiPromptRuns.templateDataCapture` in `mj.config.cjs` (the server default)
|
|
209
|
+
5. `'None'`
|
|
210
|
+
|
|
211
|
+
So the most specific prompt wins. For a Loop or Harness agent, the main prompt is the agent-type system prompt, which all agents of that type share, and the agent's own prompt is a child prompt. A value on the agent's prompt applies to that agent only. A value on the agent-type prompt applies to every agent of that type that has no value on its own prompt. A Flow agent has no agent-type prompt, so its own prompt is the main prompt.
|
|
212
|
+
|
|
213
|
+
```js
|
|
214
|
+
// mj.config.cjs
|
|
215
|
+
module.exports = {
|
|
216
|
+
aiPromptRuns: { templateDataCapture: 'None' }, // 'None' | 'Referenced' | 'Full'
|
|
217
|
+
};
|
|
218
|
+
```
|
|
219
|
+
|
|
220
|
+
The runner reads the server default once per process, from the `mj.config.cjs` it finds from the working directory. If the value is not valid, the runner logs a warning and uses `'None'`. MJServer also checks the value when it starts, so a typo stops MJAPI.
|
|
221
|
+
|
|
222
|
+
No mode stores `_CURRENT_PAYLOAD` (the agent payload). The agent run steps already store it.
|
|
223
|
+
|
|
224
|
+
`data` and `templateData` are normally objects. An input that is not a key/value object (a string, number, boolean, `null` or array) has no keys: `None` records only its size (`keyCount: 0` and the byte length of its JSON), and `Referenced` and `Full` store it as passed. A `Referenced` run with no key/value input does not run the template analysis.
|
|
225
|
+
|
|
226
|
+
The capture step never fails a run. If it throws, the runner logs the error and the run stores `dataCapture: 'None'` with the note `Template data was not stored: the capture step failed. See the server log.`, the messages and (on a consolidated parallel run) the `parallelExecution` summary, and no template data.
|
|
227
|
+
|
|
228
|
+
Example (`None`):
|
|
229
|
+
|
|
230
|
+
```json
|
|
231
|
+
{
|
|
232
|
+
"dataCapture": "None",
|
|
233
|
+
"dataShape": {
|
|
234
|
+
"data": { "keyCount": 2, "totalBytes": 419840, "keys": { "compositionContext": 266240, "componentCatalog": 153600 } }
|
|
235
|
+
},
|
|
236
|
+
"messages": [ { "role": "system", "content": "…" } ]
|
|
237
|
+
}
|
|
238
|
+
```
|
|
239
|
+
|
|
240
|
+
A consolidated parallel run (`RunType = 'ParallelParent'`) also stores a `parallelExecution` summary. `StoredPromptRunMessages` in `@memberjunction/ai-core-plus` is the type of the stored object. Rows written before this setting existed have no `dataCapture` key and store `data` and `templateData` in full.
|
|
189
241
|
|
|
190
242
|
### Credential Resolution
|
|
191
243
|
|
|
@@ -232,7 +284,7 @@ Whether a failed call fails over is `ErrorAnalyzer`'s decision, as it is for cha
|
|
|
232
284
|
|
|
233
285
|
A driver that reports only `errorMessage` is classified from the message, which recognizes rate limits, outages and a few malformed requests; any other message reads as `Unknown`, which fails over. A driver should set `errorInfo` with `ErrorAnalyzer.AnalyzeError(error)` on the error it caught.
|
|
234
286
|
|
|
235
|
-
`TimeoutMS` and `CancellationToken` bound each driver call as `timeoutMS` and `cancellationToken` bound a chat call. A call that exceeds `TimeoutMS` fails with an `AIPromptTimeoutError` and fails over. A cancelled call ends at once, never fails over, and its run row is recorded as `Cancelled`. The
|
|
287
|
+
`TimeoutMS` and `CancellationToken` bound each driver call as `timeoutMS` and `cancellationToken` bound a chat call. A call that exceeds `TimeoutMS` fails with an `AIPromptTimeoutError` and fails over. A cancelled call ends at once, never fails over, and its run row is recorded as `Cancelled`. Each driver call is handed the bound's signal (the caller's token composed with the timeout) as its params' `CancellationToken`. The shipped drivers pass it to their request (OpenAI and Groq transcription, which also send no further piece once it aborts; OpenAI and ElevenLabs speech; HeyGen avatar video), so the request already sent is torn down. A driver that ignores the signal is abandoned instead: the runner stops waiting and ignores its result.
|
|
236
288
|
|
|
237
289
|
Video generation is asynchronous at the provider, and the primitive offers no status call, so `AIVideoRunner` does not wait for a render. A successful run means the provider accepted the request; the row records the video ID (for HeyGen, the render job's ID) and records the video's length only if a driver reports it.
|
|
238
290
|
|
package/dist/AIModelRunner.d.ts
CHANGED
|
@@ -22,6 +22,10 @@ export declare class AIModelRunner {
|
|
|
22
22
|
* @returns Result with vectors, run ID, and usage metrics
|
|
23
23
|
*/
|
|
24
24
|
RunEmbedding(params: EmbeddingRunParams): Promise<EmbeddingRunResult>;
|
|
25
|
+
/**
|
|
26
|
+
* Awaits all in-flight prompt-run saves queued by this runner.
|
|
27
|
+
*/
|
|
28
|
+
FlushPendingSaves(): Promise<void>;
|
|
25
29
|
/**
|
|
26
30
|
* Awaits all in-flight prompt-run saves queued by this runner.
|
|
27
31
|
*/
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"AIModelRunner.d.ts","sourceRoot":"","sources":["../src/AIModelRunner.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,MAAM,sBAAsB,CAAC;AAEzD,OAAO,EAAE,kBAAkB,EAAE,kBAAkB,EAAE,MAAM,oCAAoC,CAAC;AAE5F,YAAY,EAAE,kBAAkB,EAAE,kBAAkB,EAAE,MAAM,oCAAoC,CAAC;AAEjG;;;;;GAKG;AACH,qBAAa,aAAa;IACtB,OAAO,CAAC,gBAAgB,CAA2B;IAEnD;;OAEG;IACH,IAAW,QAAQ,IAAI,iBAAiB,CAEvC;IACD,IAAW,QAAQ,CAAC,KAAK,EAAE,iBAAiB,GAAG,IAAI,EAElD;IAED;;;;;;OAMG;IACU,YAAY,CAAC,MAAM,EAAE,kBAAkB,GAAG,OAAO,CAAC,kBAAkB,CAAC;IAIlF;;OAEG;IACU,4BAA4B,IAAI,OAAO,CAAC,IAAI,CAAC;CAG7D"}
|
|
1
|
+
{"version":3,"file":"AIModelRunner.d.ts","sourceRoot":"","sources":["../src/AIModelRunner.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,MAAM,sBAAsB,CAAC;AAEzD,OAAO,EAAE,kBAAkB,EAAE,kBAAkB,EAAE,MAAM,oCAAoC,CAAC;AAE5F,YAAY,EAAE,kBAAkB,EAAE,kBAAkB,EAAE,MAAM,oCAAoC,CAAC;AAEjG;;;;;GAKG;AACH,qBAAa,aAAa;IACtB,OAAO,CAAC,gBAAgB,CAA2B;IAEnD;;OAEG;IACH,IAAW,QAAQ,IAAI,iBAAiB,CAEvC;IACD,IAAW,QAAQ,CAAC,KAAK,EAAE,iBAAiB,GAAG,IAAI,EAElD;IAED;;;;;;OAMG;IACU,YAAY,CAAC,MAAM,EAAE,kBAAkB,GAAG,OAAO,CAAC,kBAAkB,CAAC;IAIlF;;OAEG;IACU,iBAAiB,IAAI,OAAO,CAAC,IAAI,CAAC;IAI/C;;OAEG;IACU,4BAA4B,IAAI,OAAO,CAAC,IAAI,CAAC;CAG7D"}
|
package/dist/AIModelRunner.js
CHANGED
|
@@ -28,11 +28,17 @@ export class AIModelRunner {
|
|
|
28
28
|
async RunEmbedding(params) {
|
|
29
29
|
return this._embeddingRunner.RunEmbedding(params);
|
|
30
30
|
}
|
|
31
|
+
/**
|
|
32
|
+
* Awaits all in-flight prompt-run saves queued by this runner.
|
|
33
|
+
*/
|
|
34
|
+
async FlushPendingSaves() {
|
|
35
|
+
await this._embeddingRunner.FlushPendingSaves();
|
|
36
|
+
}
|
|
31
37
|
/**
|
|
32
38
|
* Awaits all in-flight prompt-run saves queued by this runner.
|
|
33
39
|
*/
|
|
34
40
|
async WaitForPendingPromptRunSaves() {
|
|
35
|
-
await this.
|
|
41
|
+
await this.FlushPendingSaves();
|
|
36
42
|
}
|
|
37
43
|
}
|
|
38
44
|
//# sourceMappingURL=AIModelRunner.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"AIModelRunner.js","sourceRoot":"","sources":["../src/AIModelRunner.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,iBAAiB,EAAE,MAAM,+BAA+B,CAAC;AAKlE;;;;;GAKG;AACH,MAAM,OAAO,aAAa;IAA1B;QACY,qBAAgB,GAAG,IAAI,iBAAiB,EAAE,CAAC;
|
|
1
|
+
{"version":3,"file":"AIModelRunner.js","sourceRoot":"","sources":["../src/AIModelRunner.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,iBAAiB,EAAE,MAAM,+BAA+B,CAAC;AAKlE;;;;;GAKG;AACH,MAAM,OAAO,aAAa;IAA1B;QACY,qBAAgB,GAAG,IAAI,iBAAiB,EAAE,CAAC;IAoCvD,CAAC;IAlCG;;OAEG;IACH,IAAW,QAAQ;QACf,OAAO,IAAI,CAAC,gBAAgB,CAAC,QAAQ,CAAC;IAC1C,CAAC;IACD,IAAW,QAAQ,CAAC,KAA+B;QAC/C,IAAI,CAAC,gBAAgB,CAAC,QAAQ,GAAG,KAAK,CAAC;IAC3C,CAAC;IAED;;;;;;OAMG;IACI,KAAK,CAAC,YAAY,CAAC,MAA0B;QAChD,OAAO,IAAI,CAAC,gBAAgB,CAAC,YAAY,CAAC,MAAM,CAAC,CAAC;IACtD,CAAC;IAED;;OAEG;IACI,KAAK,CAAC,iBAAiB;QAC1B,MAAM,IAAI,CAAC,gBAAgB,CAAC,iBAAiB,EAAE,CAAC;IACpD,CAAC;IAED;;OAEG;IACI,KAAK,CAAC,4BAA4B;QACrC,MAAM,IAAI,CAAC,iBAAiB,EAAE,CAAC;IACnC,CAAC;CACJ"}
|
package/dist/AIPromptRunner.d.ts
CHANGED
|
@@ -5,8 +5,9 @@ import { AIModelRunner } from './AIModelRunner.js';
|
|
|
5
5
|
import { AIPromptRunResult, AIModelSelectionInfo } from '@memberjunction/ai-core-plus';
|
|
6
6
|
import { UserInfo } from '@memberjunction/core';
|
|
7
7
|
import { MJAIModelEntityExtended, MJAIPromptEntityExtended, MJAIPromptRunEntityExtended } from "@memberjunction/ai-core-plus";
|
|
8
|
+
import { type TemplateRenderOptions } from '@memberjunction/templates-base-types';
|
|
8
9
|
import { type IParallelExecutionCoordinator } from './ParallelExecution.js';
|
|
9
|
-
import { TemplateMessageRole, ChildPromptParam, AIPromptParams } from '@memberjunction/ai-core-plus';
|
|
10
|
+
import { TemplateMessageRole, ChildPromptParam, AIPromptParams, type TemplateDataCaptureMode } from '@memberjunction/ai-core-plus';
|
|
10
11
|
export type { ExecutionBound, FailoverConfiguration } from './BaseModelRunner.js';
|
|
11
12
|
/**
|
|
12
13
|
* Advanced AI Prompt execution engine with comprehensive template support, hierarchical template composition,
|
|
@@ -92,6 +93,8 @@ export interface ModelSelectionResult {
|
|
|
92
93
|
credentialAvailability?: Map<string, boolean>;
|
|
93
94
|
}
|
|
94
95
|
export declare class AIPromptRunner extends BaseModelRunner {
|
|
96
|
+
/** The render options a prompt asks for: a raw render when `templateAutoescape` is false, else the engine's default. */
|
|
97
|
+
static RenderOptions(params: AIPromptParams): TemplateRenderOptions | undefined;
|
|
95
98
|
/**
|
|
96
99
|
* The model type this runner requires. Returns 'LLM' for AIPromptRunner.
|
|
97
100
|
*/
|
|
@@ -118,6 +121,8 @@ export declare class AIPromptRunner extends BaseModelRunner {
|
|
|
118
121
|
* already been selected. See the DECISION note in {@link selectModelWithAPIKeyTracked}.
|
|
119
122
|
*/
|
|
120
123
|
private static readonly NOT_EVALUATED_REASON;
|
|
124
|
+
/** Server default capture mode, read from mj.config once per process. */
|
|
125
|
+
private static serverTemplateDataCaptureDefault;
|
|
121
126
|
constructor();
|
|
122
127
|
/** ClassFactory key the parallel coordinator self-registers under (see {@link ParallelCoordinator}). */
|
|
123
128
|
private static readonly PARALLEL_COORDINATOR_KEY;
|
|
@@ -321,6 +326,21 @@ export declare class AIPromptRunner extends BaseModelRunner {
|
|
|
321
326
|
* otherwise succeed, so any configuration problem resolves to the path that has always worked.
|
|
322
327
|
*/
|
|
323
328
|
ResolveNativeToolCallingDecision(prompt: MJAIPromptEntityExtended, params: AIPromptParams, model: MJAIModelEntityExtended, vendorId: string | null, promptModelConfiguration?: AIPromptConfiguration | null): NativeToolCallingDecision;
|
|
329
|
+
/**
|
|
330
|
+
* The prompt layer of the native tool-calling cascade, with a hierarchical run's child prompt
|
|
331
|
+
* merged over its parent.
|
|
332
|
+
*
|
|
333
|
+
* An agent runs its agent type's system prompt as `prompt` and its own prompt as the first
|
|
334
|
+
* child, so the parent's bag alone describes the agent TYPE, not the agent. Native tool calling
|
|
335
|
+
* is a property of the agent's own prompt, so the child's bag sits between the parent and the
|
|
336
|
+
* selected `AIPromptModel` row: parent → child → row. The merge is per key, so an explicit value
|
|
337
|
+
* in the child (including `false`) overrides the parent, and an absent key inherits.
|
|
338
|
+
*
|
|
339
|
+
* @param prompt The prompt being run (the parent on a hierarchical run)
|
|
340
|
+
* @param params The caller's params — supplies the child prompts, if any
|
|
341
|
+
* @returns The merged prompt configuration, or null when neither layer sets one
|
|
342
|
+
*/
|
|
343
|
+
protected ResolveEffectivePromptConfiguration(prompt: MJAIPromptEntityExtended, params: AIPromptParams): AIPromptConfiguration | null;
|
|
324
344
|
/**
|
|
325
345
|
* Returns the template data with `_NATIVE_TOOL_CALLING` and `_NATIVE_CONTROL_FLOW` set.
|
|
326
346
|
*
|
|
@@ -345,6 +365,11 @@ export declare class AIPromptRunner extends BaseModelRunner {
|
|
|
345
365
|
*/
|
|
346
366
|
private catalogConfigurationFor;
|
|
347
367
|
private applyNativeToolCalling;
|
|
368
|
+
/**
|
|
369
|
+
* Whether an error ended a prompt run because the caller cancelled it: the caller's token is aborted,
|
|
370
|
+
* or the error is classified as a cancellation.
|
|
371
|
+
*/
|
|
372
|
+
private isCancellation;
|
|
348
373
|
/**
|
|
349
374
|
* Whether a failed result failed for a TOOLS-specific reason, and so is worth one retry with the
|
|
350
375
|
* declarations stripped.
|
|
@@ -377,9 +402,9 @@ export declare class AIPromptRunner extends BaseModelRunner {
|
|
|
377
402
|
* as a rejected promise the caller's failover/retry logic can act on.
|
|
378
403
|
*
|
|
379
404
|
* A timeout rejects with a typed {@link AIPromptTimeoutError} (classified by ErrorAnalyzer as a
|
|
380
|
-
* retriable NetworkError); a caller cancellation rejects with
|
|
381
|
-
*
|
|
382
|
-
*
|
|
405
|
+
* retriable NetworkError); a caller cancellation rejects with a `'Chat completion was cancelled'`
|
|
406
|
+
* error classified as a cancellation (see {@link BaseModelRunner.BuildCancellationError}), so
|
|
407
|
+
* failover stops instead of trying the next candidate.
|
|
383
408
|
*
|
|
384
409
|
* NOTE: `Promise.race` ignores the losing `ChatCompletion()` promise's eventual result, but the
|
|
385
410
|
* underlying request IS torn down — the composed signal is on `ChatParams.cancellationToken`, and
|
|
@@ -390,7 +415,7 @@ export declare class AIPromptRunner extends BaseModelRunner {
|
|
|
390
415
|
private runChatCompletionBounded;
|
|
391
416
|
/**
|
|
392
417
|
* Builds the rejection error for an aborted model call — a typed {@link AIPromptTimeoutError} when
|
|
393
|
-
* the prompt's TimeoutMS fired, otherwise
|
|
418
|
+
* the prompt's TimeoutMS fired, otherwise a caller cancellation that is not eligible for failover.
|
|
394
419
|
*/
|
|
395
420
|
private buildAbortError;
|
|
396
421
|
/**
|
|
@@ -405,8 +430,12 @@ export declare class AIPromptRunner extends BaseModelRunner {
|
|
|
405
430
|
* No-op when the driver's GetFileCapabilities() returns non-null AND the
|
|
406
431
|
* block's MIME matches the supported list. The driver baseclass returns
|
|
407
432
|
* null by default; only providers that declare vision/file support override
|
|
408
|
-
* it (currently
|
|
433
|
+
* it (currently Anthropic, OpenAI and Gemini; drivers built on the OpenAI
|
|
434
|
+
* driver inherit its list). For everyone else, every media block falls back
|
|
409
435
|
* to text — exactly what you want when running a text-only model.
|
|
436
|
+
*
|
|
437
|
+
* A changed message is replaced by a new object in chatParams.messages; the
|
|
438
|
+
* caller's message objects stay as they were.
|
|
410
439
|
*/
|
|
411
440
|
private stripUnsupportedMediaBlocks;
|
|
412
441
|
/**
|
|
@@ -641,6 +670,22 @@ export declare class AIPromptRunner extends BaseModelRunner {
|
|
|
641
670
|
* {@link BaseModelRunner.CreateRunRecord} just before the INSERT is queued.
|
|
642
671
|
*/
|
|
643
672
|
private applyChatRequestFields;
|
|
673
|
+
/** The server default template-data capture mode (`aiPromptRuns.templateDataCapture` in mj.config). */
|
|
674
|
+
protected GetServerTemplateDataCaptureDefault(): TemplateDataCaptureMode;
|
|
675
|
+
/**
|
|
676
|
+
* Serializes what this run stores in `AIPromptRun.Messages`, applying the template-data capture mode.
|
|
677
|
+
* A capture error never fails the run: it is logged, and the run stores `None` with a fixed note and no template data.
|
|
678
|
+
*/
|
|
679
|
+
private buildStoredMessagesJSON;
|
|
680
|
+
/** The child prompts rendered in a run, depth first: each child prompt, then its own child prompts. */
|
|
681
|
+
private childPromptsDepthFirst;
|
|
682
|
+
/**
|
|
683
|
+
* `TemplateDataCapture` of each prompt in the run, most specific first: the child prompts depth first, then the
|
|
684
|
+
* main prompt. For a Loop or Harness agent, the agent's own prompt is a child prompt of the agent-type system prompt.
|
|
685
|
+
*/
|
|
686
|
+
private promptTemplateDataCaptureSettings;
|
|
687
|
+
/** Variables read by the prompt's template and by every child prompt template rendered in the same run. */
|
|
688
|
+
private collectReferencedVariables;
|
|
644
689
|
/**
|
|
645
690
|
* Updates the AIPromptRun entity with execution results
|
|
646
691
|
*/
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"AIPromptRunner.d.ts","sourceRoot":"","sources":["../src/AIPromptRunner.ts"],"names":[],"mappings":"AAAA,OAAO,EAAuB,UAAU,EAAmB,WAAW,
|
|
1
|
+
{"version":3,"file":"AIPromptRunner.d.ts","sourceRoot":"","sources":["../src/AIPromptRunner.ts"],"names":[],"mappings":"AAAA,OAAO,EAAuB,UAAU,EAAmB,WAAW,EAAiF,qBAAqB,EAAkI,MAAM,oBAAoB,CAAC;AACzU,OAAO,EACL,eAAe,EAEf,KAAK,oBAAoB,EAG1B,MAAM,mBAAmB,CAAC;AAC3B,OAAO,EAA8C,yBAAyB,EAA2G,MAAM,yBAAyB,CAAC;AACzN,OAAO,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAChD,OAAO,EAAqB,iBAAiB,EAAE,oBAAoB,EAA4B,MAAM,8BAA8B,CAAC;AACpI,OAAO,EAA0D,QAAQ,EAAE,MAAM,sBAAsB,CAAC;AAGxG,OAAO,EAAE,uBAAuB,EAAE,wBAAwB,EAAE,2BAA2B,EAAE,MAAM,8BAA8B,CAAC;AAE9H,OAAO,EAAwB,KAAK,qBAAqB,EAA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