@memberjunction/ai-agents 5.38.0 → 5.40.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 (91) hide show
  1. package/dist/AgentRunner.d.ts +23 -0
  2. package/dist/AgentRunner.d.ts.map +1 -1
  3. package/dist/AgentRunner.js +81 -26
  4. package/dist/AgentRunner.js.map +1 -1
  5. package/dist/ArtifactToolManager.d.ts +13 -0
  6. package/dist/ArtifactToolManager.d.ts.map +1 -1
  7. package/dist/ArtifactToolManager.js +60 -1
  8. package/dist/ArtifactToolManager.js.map +1 -1
  9. package/dist/agent-run-watchdog.d.ts +109 -0
  10. package/dist/agent-run-watchdog.d.ts.map +1 -0
  11. package/dist/agent-run-watchdog.js +278 -0
  12. package/dist/agent-run-watchdog.js.map +1 -0
  13. package/dist/agent-types/loop-agent-prompt-params.d.ts +13 -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 +3 -1
  16. package/dist/agent-types/loop-agent-prompt-params.js.map +1 -1
  17. package/dist/agent-types/loop-agent-response-type.d.ts +12 -3
  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.map +1 -1
  21. package/dist/agent-types/loop-agent-type.js +41 -2
  22. package/dist/agent-types/loop-agent-type.js.map +1 -1
  23. package/dist/artifact-tools/DataSnapshotToolLibrary.js +2 -2
  24. package/dist/artifact-tools/JSONToolLibrary.d.ts.map +1 -1
  25. package/dist/artifact-tools/JSONToolLibrary.js +7 -1
  26. package/dist/artifact-tools/JSONToolLibrary.js.map +1 -1
  27. package/dist/base-agent.d.ts +69 -1
  28. package/dist/base-agent.d.ts.map +1 -1
  29. package/dist/base-agent.js +294 -24
  30. package/dist/base-agent.js.map +1 -1
  31. package/dist/index.d.ts +2 -0
  32. package/dist/index.d.ts.map +1 -1
  33. package/dist/index.js +2 -0
  34. package/dist/index.js.map +1 -1
  35. package/dist/pipeline/coerce.d.ts +43 -0
  36. package/dist/pipeline/coerce.d.ts.map +1 -0
  37. package/dist/pipeline/coerce.js +92 -0
  38. package/dist/pipeline/coerce.js.map +1 -0
  39. package/dist/pipeline/index.d.ts +20 -0
  40. package/dist/pipeline/index.d.ts.map +1 -0
  41. package/dist/pipeline/index.js +20 -0
  42. package/dist/pipeline/index.js.map +1 -0
  43. package/dist/pipeline/jsonpath-eval.d.ts +29 -0
  44. package/dist/pipeline/jsonpath-eval.d.ts.map +1 -0
  45. package/dist/pipeline/jsonpath-eval.js +144 -0
  46. package/dist/pipeline/jsonpath-eval.js.map +1 -0
  47. package/dist/pipeline/operators.d.ts +15 -0
  48. package/dist/pipeline/operators.d.ts.map +1 -0
  49. package/dist/pipeline/operators.js +332 -0
  50. package/dist/pipeline/operators.js.map +1 -0
  51. package/dist/pipeline/path.d.ts +16 -0
  52. package/dist/pipeline/path.d.ts.map +1 -0
  53. package/dist/pipeline/path.js +34 -0
  54. package/dist/pipeline/path.js.map +1 -0
  55. package/dist/pipeline/pipeline-docs.d.ts +6 -0
  56. package/dist/pipeline/pipeline-docs.d.ts.map +1 -0
  57. package/dist/pipeline/pipeline-docs.js +137 -0
  58. package/dist/pipeline/pipeline-docs.js.map +1 -0
  59. package/dist/pipeline/pipeline-executor.d.ts +72 -0
  60. package/dist/pipeline/pipeline-executor.d.ts.map +1 -0
  61. package/dist/pipeline/pipeline-executor.js +326 -0
  62. package/dist/pipeline/pipeline-executor.js.map +1 -0
  63. package/dist/pipeline/pipeline-registry.d.ts +24 -0
  64. package/dist/pipeline/pipeline-registry.d.ts.map +1 -0
  65. package/dist/pipeline/pipeline-registry.js +28 -0
  66. package/dist/pipeline/pipeline-registry.js.map +1 -0
  67. package/dist/pipeline/pipeline.types.d.ts +89 -0
  68. package/dist/pipeline/pipeline.types.d.ts.map +1 -0
  69. package/dist/pipeline/pipeline.types.js +13 -0
  70. package/dist/pipeline/pipeline.types.js.map +1 -0
  71. package/dist/pipeline/predicate.d.ts +23 -0
  72. package/dist/pipeline/predicate.d.ts.map +1 -0
  73. package/dist/pipeline/predicate.js +306 -0
  74. package/dist/pipeline/predicate.js.map +1 -0
  75. package/dist/pipeline/providers/action-provider.d.ts +21 -0
  76. package/dist/pipeline/providers/action-provider.d.ts.map +1 -0
  77. package/dist/pipeline/providers/action-provider.js +24 -0
  78. package/dist/pipeline/providers/action-provider.js.map +1 -0
  79. package/dist/pipeline/providers/artifact-tool-provider.d.ts +20 -0
  80. package/dist/pipeline/providers/artifact-tool-provider.d.ts.map +1 -0
  81. package/dist/pipeline/providers/artifact-tool-provider.js +27 -0
  82. package/dist/pipeline/providers/artifact-tool-provider.js.map +1 -0
  83. package/dist/pipeline/providers/serialize.d.ts +23 -0
  84. package/dist/pipeline/providers/serialize.d.ts.map +1 -0
  85. package/dist/pipeline/providers/serialize.js +99 -0
  86. package/dist/pipeline/providers/serialize.js.map +1 -0
  87. package/dist/pipeline/template.d.ts +18 -0
  88. package/dist/pipeline/template.d.ts.map +1 -0
  89. package/dist/pipeline/template.js +47 -0
  90. package/dist/pipeline/template.js.map +1 -0
  91. package/package.json +19 -17
@@ -0,0 +1,326 @@
1
+ import { GetOperator, CONTROL_VERBS } from './operators.js';
2
+ import { resolveParams } from './template.js';
3
+ import { sizeOf, previewOf, describeEmptyMatch } from './coerce.js';
4
+ export const MAX_PIPELINE_STAGES = 20;
5
+ export const MAX_MAP_ELEMENTS = 1000;
6
+ export const MAP_CONCURRENCY = 8;
7
+ /** Default wall-clock budget for an entire pipeline (incl. all map/let sub-pipelines). */
8
+ export const DEFAULT_PIPELINE_DEADLINE_MS = 120_000;
9
+ export class PipelineExecutor {
10
+ constructor(registry, maxStages = MAX_PIPELINE_STAGES, opts = {}) {
11
+ this.registry = registry;
12
+ this.maxStages = maxStages;
13
+ /**
14
+ * Total bytes produced by every stage anywhere in the tree (incl. map/let sub-pipelines).
15
+ * INSTANCE state, not shared: a fresh executor is created per pipeline run (see
16
+ * `base-agent.executePipelineAsStep`), so concurrent agent turns each get their own counter —
17
+ * this is never read/written across parallel runs. Do NOT make PipelineExecutor a singleton.
18
+ */
19
+ this.producedBytes = 0;
20
+ /** Absolute wall-clock deadline (epoch ms) for this run; set at the start of {@link Execute}. */
21
+ this.deadlineAt = Number.POSITIVE_INFINITY;
22
+ this.deadlineMs = opts.deadlineMs ?? DEFAULT_PIPELINE_DEADLINE_MS;
23
+ this.signal = opts.signal;
24
+ }
25
+ /**
26
+ * Throw if the run has been cancelled or has blown its wall-clock budget. Checked between
27
+ * top-level stages, before each `map` batch, and before each sub-pipeline stage — so a long
28
+ * `map` over many elements (or a chain of slow Actions) can't run unbounded. NOTE: this bounds
29
+ * wall-clock *between* stage invocations; it does not interrupt a single in-flight Action mid-call
30
+ * (that needs Action-level cancellation — a follow-up once the Action layer accepts an AbortSignal).
31
+ */
32
+ checkAbort() {
33
+ if (this.signal?.aborted) {
34
+ throw new Error('Pipeline cancelled.');
35
+ }
36
+ if (Date.now() >= this.deadlineAt) {
37
+ throw new Error(`Pipeline exceeded its ${this.deadlineMs}ms time budget. Narrow the work (fewer map elements, smaller fetches) or split across turns.`);
38
+ }
39
+ }
40
+ /** Validate + run a pipeline. Returns a structured result; never throws on stage failure. */
41
+ async Execute(stages) {
42
+ const shapeError = this.validateShape(stages);
43
+ if (shapeError) {
44
+ return { success: false, finalOutput: null, steps: [], error: shapeError, contextBytesSaved: 0 };
45
+ }
46
+ const records = [];
47
+ const scope = {};
48
+ let current = null;
49
+ this.producedBytes = 0;
50
+ this.deadlineAt = Date.now() + this.deadlineMs;
51
+ let firstDiagnostic;
52
+ for (let i = 0; i < stages.length; i++) {
53
+ const inputValue = current;
54
+ const inputSize = sizeOf(current);
55
+ const startedAt = Date.now();
56
+ const outcome = await this.runStage(stages[i], current, scope);
57
+ const durationMs = Date.now() - startedAt;
58
+ // A stage that turns a non-empty array into nothing useful — empty, or all-null
59
+ // elements (the classic `map` clobber: `map` REPLACES the stream with each iteration's
60
+ // final value, so a throwaway last sub-stage nulls every row) — is almost always a logic
61
+ // error. Capture a self-correction hint so the agent fixes it next turn instead of
62
+ // blindly retrying. Purely informational: it NEVER fails or alters the pipeline.
63
+ const diagnostic = outcome.success
64
+ ? stageDegenerationHint(stages[i], inputValue, outcome.output, outcome.toolName, i + 1)
65
+ : undefined;
66
+ if (diagnostic && !firstDiagnostic) {
67
+ firstDiagnostic = diagnostic;
68
+ }
69
+ records.push({
70
+ index: i,
71
+ toolName: outcome.toolName,
72
+ providerKind: outcome.providerKind,
73
+ inputSize,
74
+ outputSize: sizeOf(outcome.output),
75
+ durationMs,
76
+ success: outcome.success,
77
+ error: outcome.error,
78
+ diagnostic,
79
+ logRef: {
80
+ providerKind: outcome.providerKind,
81
+ actionExecutionLogId: outcome.actionExecutionLogId,
82
+ preview: outcome.preview ?? previewOf(outcome.output),
83
+ },
84
+ });
85
+ this.producedBytes += records[records.length - 1].outputSize;
86
+ if (!outcome.success) {
87
+ return this.failure(records, i, outcome.toolName, inputSize, outcome.error);
88
+ }
89
+ current = outcome.output;
90
+ scope['$'] = current;
91
+ }
92
+ return {
93
+ success: true,
94
+ finalOutput: current,
95
+ steps: records,
96
+ contextBytesSaved: this.computeSaved(current),
97
+ // Surface the hint only when the FINAL result is itself degenerate (empty, or all-null
98
+ // elements); a deliberate empty result mid-pipeline that's later repopulated shouldn't nag.
99
+ diagnostic: looksDegenerate(current) ? firstDiagnostic : undefined,
100
+ };
101
+ }
102
+ validateShape(stages) {
103
+ if (!Array.isArray(stages) || stages.length < 1) {
104
+ return 'A pipeline needs at least 1 stage.';
105
+ }
106
+ if (stages.length > this.maxStages) {
107
+ return `A pipeline may have at most ${this.maxStages} stages (got ${stages.length}).`;
108
+ }
109
+ return null;
110
+ }
111
+ /** Dispatch one stage. Never throws — converts errors into a failed outcome. */
112
+ async runStage(stage, current, scope) {
113
+ try {
114
+ this.checkAbort(); // deadline/cancellation → failed outcome (caught below), never an uncaught throw
115
+ if ('tool' in stage) {
116
+ return await this.runToolStage(stage, current, scope);
117
+ }
118
+ if ('map' in stage) {
119
+ return await this.runMapStage(stage, current, scope);
120
+ }
121
+ if ('let' in stage) {
122
+ return await this.runLetStage(stage, current, scope);
123
+ }
124
+ return this.runOperatorStage(stage, current);
125
+ }
126
+ catch (e) {
127
+ return { output: null, success: false, error: e.message, providerKind: 'Transform', toolName: stageVerb(stage) };
128
+ }
129
+ }
130
+ runOperatorStage(stage, current) {
131
+ const verbs = Object.keys(stage).filter((k) => GetOperator(k));
132
+ if (verbs.length === 0) {
133
+ throw new Error(`Stage has no known verb. Keys: ${Object.keys(stage).join(', ')}.`);
134
+ }
135
+ if (verbs.length > 1) {
136
+ throw new Error(`A stage must have exactly one verb, but found: ${verbs.join(', ')}.`);
137
+ }
138
+ const op = GetOperator(verbs[0]);
139
+ const output = op.apply(current, stage[verbs[0]]);
140
+ return { output, success: true, providerKind: 'Transform', toolName: op.name };
141
+ }
142
+ async runToolStage(stage, current, scope) {
143
+ const toolName = String(stage.tool);
144
+ const invocable = this.registry.Resolve(toolName);
145
+ if (!invocable) {
146
+ throw new Error(`Unknown pipeline tool "${toolName}". Available tools: ${this.registry.ToolNames().join(', ')}.`);
147
+ }
148
+ const params = resolveParams(stage.with ?? {}, { ...scope, $: current });
149
+ if (typeof stage.pipeInto === 'string') {
150
+ params[stage.pipeInto] = current;
151
+ }
152
+ const result = await invocable.invoke(current, params);
153
+ return {
154
+ output: result.output,
155
+ success: result.success,
156
+ error: result.error,
157
+ providerKind: invocable.providerKind,
158
+ toolName,
159
+ actionExecutionLogId: result.logRef.actionExecutionLogId,
160
+ preview: result.logRef.preview,
161
+ };
162
+ }
163
+ async runMapStage(stage, current, scope) {
164
+ const cfg = (stage.map ?? {});
165
+ const asName = cfg.as ?? 'item';
166
+ const subStages = cfg.do ?? [];
167
+ if (!Array.isArray(subStages) || subStages.length === 0) {
168
+ throw new Error('"map" requires a non-empty "do" sub-pipeline.');
169
+ }
170
+ if (!Array.isArray(current)) {
171
+ throw new Error(`"map" expects an array to iterate, but the upstream value is ${Array.isArray(current) ? 'an array' : typeof current}.`);
172
+ }
173
+ if (current.length > MAX_MAP_ELEMENTS) {
174
+ throw new Error(`"map" capped at ${MAX_MAP_ELEMENTS} elements (got ${current.length}). Narrow upstream with where/first.`);
175
+ }
176
+ const failFast = cfg.continueOnError === false;
177
+ // KNOWN LIMITATION: every element's final value is buffered here before returning. With
178
+ // MAX_MAP_ELEMENTS=1000 and large per-element outputs this is real memory pressure — keep each
179
+ // element's final sub-stage SMALL (select/count/grep), not whole fetched pages. A streaming /
180
+ // chunked map that doesn't materialize the full array is a v2 candidate.
181
+ const results = new Array(current.length).fill(null);
182
+ let failures = 0;
183
+ let firstError;
184
+ for (let start = 0; start < current.length; start += MAP_CONCURRENCY) {
185
+ this.checkAbort();
186
+ const batch = current.slice(start, start + MAP_CONCURRENCY);
187
+ await Promise.all(batch.map(async (element, j) => {
188
+ const idx = start + j;
189
+ const childScope = { ...scope, [asName]: element };
190
+ const sub = await this.runStages(subStages, element, childScope);
191
+ if (sub.success) {
192
+ results[idx] = sub.value;
193
+ }
194
+ else {
195
+ failures++;
196
+ firstError = firstError ?? sub.error;
197
+ results[idx] = null;
198
+ }
199
+ }));
200
+ if (failFast && failures > 0) {
201
+ throw new Error(`"map" failed on an element: ${firstError}`);
202
+ }
203
+ }
204
+ const summary = failures > 0 ? `${failures} of ${current.length} elements failed (first: ${firstError})` : undefined;
205
+ return {
206
+ output: results,
207
+ success: true,
208
+ error: summary,
209
+ providerKind: 'Transform',
210
+ toolName: `map(${current.length})`,
211
+ preview: previewOf(results),
212
+ };
213
+ }
214
+ async runLetStage(stage, current, scope) {
215
+ const cfg = (stage.let ?? {});
216
+ if (!cfg.name || !Array.isArray(cfg.value) || cfg.value.length === 0) {
217
+ throw new Error('"let" requires { "name": string, "value": [ sub-stages ] }.');
218
+ }
219
+ const sub = await this.runStages(cfg.value, current, { ...scope });
220
+ if (!sub.success) {
221
+ throw new Error(`"let ${cfg.name}" failed: ${sub.error}`);
222
+ }
223
+ scope[cfg.name] = sub.value; // bind for downstream {{name}}; stream passes through unchanged
224
+ return { output: current, success: true, providerKind: 'Transform', toolName: `let ${cfg.name}` };
225
+ }
226
+ /** Run a sub-pipeline (map/let) with no top-level record-keeping; fails fast internally. */
227
+ async runStages(stages, initialValue, scope) {
228
+ let current = initialValue;
229
+ scope['$'] = current;
230
+ for (const stage of stages) {
231
+ const outcome = await this.runStage(stage, current, scope);
232
+ // Every sub-pipeline stage output is processed server-side and never surfaces to the
233
+ // LLM directly (only the top-level final value does) — count it toward bytes saved.
234
+ this.producedBytes += sizeOf(outcome.output);
235
+ if (!outcome.success) {
236
+ return { value: null, success: false, error: outcome.error };
237
+ }
238
+ current = outcome.output;
239
+ scope['$'] = current;
240
+ }
241
+ return { value: current, success: true };
242
+ }
243
+ failure(records, zeroBasedIndex, toolName, inputSize, error) {
244
+ const message = `Pipeline failed at stage ${zeroBasedIndex + 1} (${toolName}).\n` +
245
+ `Upstream value size: ${inputSize} bytes\n` +
246
+ `Error: ${error ?? 'unknown error'}`;
247
+ return {
248
+ success: false,
249
+ finalOutput: null,
250
+ steps: records,
251
+ error: message,
252
+ // 0-based to index straight into `steps` (steps[failedStepIndex] is the failing record).
253
+ // The human-facing `message` above uses 1-based "stage N" since people count from 1.
254
+ failedStepIndex: zeroBasedIndex,
255
+ contextBytesSaved: this.computeSaved(null),
256
+ };
257
+ }
258
+ /**
259
+ * Bytes the LLM never saw: everything produced anywhere in the tree (top-level + every map/let
260
+ * sub-pipeline stage) minus the single final value that is returned. Map/let internal fetches
261
+ * (e.g. full pages fetched per element) are counted here, not just top-level stages.
262
+ */
263
+ computeSaved(finalOutput) {
264
+ return Math.max(0, this.producedBytes - sizeOf(finalOutput));
265
+ }
266
+ }
267
+ /** Whether a value is "no result" — empty array, empty string, or null. */
268
+ function isEmpty(v) {
269
+ if (v == null)
270
+ return true;
271
+ if (Array.isArray(v))
272
+ return v.length === 0;
273
+ if (typeof v === 'string')
274
+ return v.length === 0;
275
+ return false;
276
+ }
277
+ /** An object with keys whose values are ALL null — a hollow row (e.g. `select`-ing absent fields). */
278
+ function isAllNullObject(v) {
279
+ return (v !== null &&
280
+ typeof v === 'object' &&
281
+ !Array.isArray(v) &&
282
+ Object.keys(v).length > 0 &&
283
+ Object.values(v).every((x) => x == null));
284
+ }
285
+ /** Degenerate = empty, OR a non-empty array whose every element is null / a hollow all-null object. */
286
+ function looksDegenerate(v) {
287
+ if (isEmpty(v))
288
+ return true;
289
+ if (Array.isArray(v) && v.length > 0) {
290
+ return v.every((el) => el == null || isAllNullObject(el));
291
+ }
292
+ return false;
293
+ }
294
+ /**
295
+ * Self-correction hint for a stage that took a non-empty array and produced nothing useful — purely
296
+ * informational, never alters execution. Two cases: (1) filtered down to empty (likely a wrong field
297
+ * name / value casing → list the values present); (2) turned every element into null, the classic
298
+ * `map` misuse (map REPLACES the stream with each iteration's final value — it does not add a field).
299
+ */
300
+ function stageDegenerationHint(stage, inputValue, output, toolName, oneBasedIndex) {
301
+ if (!Array.isArray(inputValue) || inputValue.length === 0) {
302
+ return undefined;
303
+ }
304
+ if (isEmpty(output)) {
305
+ return `Stage ${oneBasedIndex} ("${toolName}") ${describeEmptyMatch(inputValue)}`;
306
+ }
307
+ if (Array.isArray(output) && output.length > 0 && output.every((el) => el == null || isAllNullObject(el))) {
308
+ const why = 'map' in stage
309
+ ? ' "map" REPLACES the array with each iteration\'s FINAL sub-stage value — it does NOT add a field to existing rows. Its last sub-stage returned null for every element. To add/keep fields, use select/groupBy directly; use map only for per-element actions.'
310
+ : ' Check the field name/path — it resolved to null for every element (case-sensitive).';
311
+ return `Stage ${oneBasedIndex} ("${toolName}") turned ${inputValue.length} item(s) into all-null.${why}`;
312
+ }
313
+ return undefined;
314
+ }
315
+ /** Best-effort verb label for a stage (for error messages). */
316
+ function stageVerb(stage) {
317
+ if ('tool' in stage)
318
+ return String(stage.tool);
319
+ if ('map' in stage)
320
+ return 'map';
321
+ if ('let' in stage)
322
+ return 'let';
323
+ const verbs = Object.keys(stage).filter((k) => !CONTROL_VERBS.has(k));
324
+ return verbs[0] ?? 'unknown';
325
+ }
326
+ //# sourceMappingURL=pipeline-executor.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"pipeline-executor.js","sourceRoot":"","sources":["../../src/pipeline/pipeline-executor.ts"],"names":[],"mappings":"AAuBA,OAAO,EAAE,WAAW,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AACzD,OAAO,EAAE,aAAa,EAAiB,MAAM,YAAY,CAAC;AAC1D,OAAO,EAAE,MAAM,EAAE,SAAS,EAAE,kBAAkB,EAAE,MAAM,UAAU,CAAC;AAEjE,MAAM,CAAC,MAAM,mBAAmB,GAAG,EAAE,CAAC;AACtC,MAAM,CAAC,MAAM,gBAAgB,GAAG,IAAI,CAAC;AACrC,MAAM,CAAC,MAAM,eAAe,GAAG,CAAC,CAAC;AACjC,0FAA0F;AAC1F,MAAM,CAAC,MAAM,4BAA4B,GAAG,OAAO,CAAC;AAqBpD,MAAM,OAAO,gBAAgB;IAazB,YACqB,QAA8B,EAC9B,YAAoB,mBAAmB,EACxD,OAAgC,EAAE;QAFjB,aAAQ,GAAR,QAAQ,CAAsB;QAC9B,cAAS,GAAT,SAAS,CAA8B;QAd5D;;;;;WAKG;QACK,kBAAa,GAAG,CAAC,CAAC;QAC1B,iGAAiG;QACzF,eAAU,GAAG,MAAM,CAAC,iBAAiB,CAAC;QAS1C,IAAI,CAAC,UAAU,GAAG,IAAI,CAAC,UAAU,IAAI,4BAA4B,CAAC;QAClE,IAAI,CAAC,MAAM,GAAG,IAAI,CAAC,MAAM,CAAC;IAC9B,CAAC;IAED;;;;;;OAMG;IACK,UAAU;QACd,IAAI,IAAI,CAAC,MAAM,EAAE,OAAO,EAAE,CAAC;YACvB,MAAM,IAAI,KAAK,CAAC,qBAAqB,CAAC,CAAC;QAC3C,CAAC;QACD,IAAI,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AC,CAAC,sFAAsF,CAAC;QACjG,OAAO,SAAS,aAAa,MAAM,QAAQ,aAAa,UAAU,CAAC,MAAM,0BAA0B,GAAG,EAAE,CAAC;IAC7G,CAAC;IACD,OAAO,SAAS,CAAC;AACrB,CAAC;AAED,+DAA+D;AAC/D,SAAS,SAAS,CAAC,KAAoB;IACnC,IAAI,MAAM,IAAI,KAAK;QAAE,OAAO,MAAM,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;IAC/C,IAAI,KAAK,IAAI,KAAK;QAAE,OAAO,KAAK,CAAC;IACjC,IAAI,KAAK,IAAI,KAAK;QAAE,OAAO,KAAK,CAAC;IACjC,MAAM,KAAK,GAAG,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,aAAa,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC;IACtE,OAAO,KAAK,CAAC,CAAC,CAAC,IAAI,SAAS,CAAC;AACjC,CAAC"}
@@ -0,0 +1,24 @@
1
+ /**
2
+ * @fileoverview Per-execution registry that resolves a pipeline step's tool name to a
3
+ * {@link PipelineInvocable}. Built fresh for each pipeline run by the agent, which knows
4
+ * the available Actions, artifact tools, and built-in transforms.
5
+ *
6
+ * Lookup is case-insensitive. Names share one namespace across all three substrates, so
7
+ * a collision (e.g. an Action named the same as a transform) is a registration-time error
8
+ * rather than a silent ambiguity at resolve time.
9
+ *
10
+ * @module @memberjunction/ai-agents
11
+ */
12
+ import { PipelineInvocable } from './pipeline.types.js';
13
+ export declare class PipelineToolRegistry {
14
+ private byName;
15
+ /** Register an invocable. Throws if its name collides with an already-registered tool. */
16
+ Register(invocable: PipelineInvocable): void;
17
+ /** Register many invocables (e.g. all built-in transforms). */
18
+ RegisterAll(invocables: readonly PipelineInvocable[]): void;
19
+ /** Resolve a tool name (case-insensitive), or undefined if unknown. */
20
+ Resolve(name: string): PipelineInvocable | undefined;
21
+ /** All registered tool names, in registration order — for error messages / tool docs. */
22
+ ToolNames(): string[];
23
+ }
24
+ //# sourceMappingURL=pipeline-registry.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"pipeline-registry.d.ts","sourceRoot":"","sources":["../../src/pipeline/pipeline-registry.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AACH,OAAO,EAAE,iBAAiB,EAAE,MAAM,kBAAkB,CAAC;AAErD,qBAAa,oBAAoB;IAC7B,OAAO,CAAC,MAAM,CAAwC;IAEtD,0FAA0F;IACnF,QAAQ,CAAC,SAAS,EAAE,iBAAiB,GAAG,IAAI;IAYnD,+DAA+D;IACxD,WAAW,CAAC,UAAU,EAAE,SAAS,iBAAiB,EAAE,GAAG,IAAI;IAIlE,uEAAuE;IAChE,OAAO,CAAC,IAAI,EAAE,MAAM,GAAG,iBAAiB,GAAG,SAAS;IAI3D,yFAAyF;IAClF,SAAS,IAAI,MAAM,EAAE;CAG/B"}
@@ -0,0 +1,28 @@
1
+ export class PipelineToolRegistry {
2
+ constructor() {
3
+ this.byName = new Map();
4
+ }
5
+ /** Register an invocable. Throws if its name collides with an already-registered tool. */
6
+ Register(invocable) {
7
+ const key = invocable.toolName.trim().toLowerCase();
8
+ const existing = this.byName.get(key);
9
+ if (existing) {
10
+ throw new Error(`Pipeline tool name collision: "${invocable.toolName}" is registered by both the ` +
11
+ `${existing.providerKind} and ${invocable.providerKind} providers.`);
12
+ }
13
+ this.byName.set(key, invocable);
14
+ }
15
+ /** Register many invocables (e.g. all built-in transforms). */
16
+ RegisterAll(invocables) {
17
+ invocables.forEach((i) => this.Register(i));
18
+ }
19
+ /** Resolve a tool name (case-insensitive), or undefined if unknown. */
20
+ Resolve(name) {
21
+ return this.byName.get(name.trim().toLowerCase());
22
+ }
23
+ /** All registered tool names, in registration order — for error messages / tool docs. */
24
+ ToolNames() {
25
+ return [...this.byName.values()].map((i) => i.toolName);
26
+ }
27
+ }
28
+ //# sourceMappingURL=pipeline-registry.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"pipeline-registry.js","sourceRoot":"","sources":["../../src/pipeline/pipeline-registry.ts"],"names":[],"mappings":"AAaA,MAAM,OAAO,oBAAoB;IAAjC;QACY,WAAM,GAAG,IAAI,GAAG,EAA6B,CAAC;IA6B1D,CAAC;IA3BG,0FAA0F;IACnF,QAAQ,CAAC,SAA4B;QACxC,MAAM,GAAG,GAAG,SAAS,CAAC,QAAQ,CAAC,IAAI,EAAE,CAAC,WAAW,EAAE,CAAC;QACpD,MAAM,QAAQ,GAAG,IAAI,CAAC,MAAM,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;QACtC,IAAI,QAAQ,EAAE,CAAC;YACX,MAAM,IAAI,KAAK,CACX,kCAAkC,SAAS,CAAC,QAAQ,8BAA8B;gBAC9E,GAAG,QAAQ,CAAC,YAAY,QAAQ,SAAS,CAAC,YAAY,aAAa,CAC1E,CAAC;QACN,CAAC;QACD,IAAI,CAAC,MAAM,CAAC,GAAG,CAAC,GAAG,EAAE,SAAS,CAAC,CAAC;IACpC,CAAC;IAED,+DAA+D;IACxD,WAAW,CAAC,UAAwC;QACvD,UAAU,CAAC,OAAO,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,CAAC;IAChD,CAAC;IAED,uEAAuE;IAChE,OAAO,CAAC,IAAY;QACvB,OAAO,IAAI,CAAC,MAAM,CAAC,GAAG,CAAC,IAAI,CAAC,IAAI,EAAE,CAAC,WAAW,EAAE,CAAC,CAAC;IACtD,CAAC;IAED,yFAAyF;IAClF,SAAS;QACZ,OAAO,CAAC,GAAG,IAAI,CAAC,MAAM,CAAC,MAAM,EAAE,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC;IAC5D,CAAC;CACJ"}
@@ -0,0 +1,89 @@
1
+ /**
2
+ * @fileoverview Core contract for Agent Pipelines — a server-side dataflow the agent authors and
3
+ * the server runs, so intermediate values never enter the LLM context window.
4
+ *
5
+ * The pipe carries a {@link PipeValue} (a JSON value), PowerShell-style, NOT a string: stages bind
6
+ * to object properties instead of re-parsing text. Capabilities (Actions / artifact tools) are
7
+ * effectful async stages behind {@link PipelineInvocable}; pure operators (where/select/sort/…) are
8
+ * synchronous value→value functions; `map`/`let` are control constructs handled by the executor.
9
+ *
10
+ * @module @memberjunction/ai-agents
11
+ */
12
+ /** A JSON value — the medium that flows between pipeline stages. */
13
+ export type PipeValue = null | boolean | number | string | PipeValue[] | {
14
+ [key: string]: PipeValue;
15
+ };
16
+ /** Which substrate produced a step. DB persistence collapses operator/map/let to 'Transform'. */
17
+ export type PipelineProviderKind = 'Action' | 'ArtifactTool' | 'Transform';
18
+ /** Pointer from a step back to its underlying log (polymorphic by substrate). */
19
+ export interface PipelineStepLogRef {
20
+ providerKind: PipelineProviderKind;
21
+ /** ActionExecutionLog row ID for Action steps; undefined otherwise. */
22
+ actionExecutionLogId?: string;
23
+ /** Truncated text preview of the step's output, for steps with no DB log. */
24
+ preview?: string;
25
+ }
26
+ /** Result of invoking a single capability stage. */
27
+ export interface PipelineStepResult {
28
+ output: PipeValue;
29
+ success: boolean;
30
+ error?: string;
31
+ logRef: PipelineStepLogRef;
32
+ }
33
+ /**
34
+ * A capability stage — an Action or artifact tool. Effectful + async. The executor resolves
35
+ * templating and `pipeInto` into `params` before calling `invoke`; the raw upstream `input` is
36
+ * passed too for providers that want it.
37
+ */
38
+ export interface PipelineInvocable {
39
+ readonly toolName: string;
40
+ readonly providerKind: PipelineProviderKind;
41
+ /** Whether this can be a pipeline's first stage (produces data without upstream). */
42
+ readonly isSource: boolean;
43
+ invoke(input: PipeValue, params: Record<string, unknown>): Promise<PipelineStepResult>;
44
+ }
45
+ /** A pure operator — value in, value out. May throw (executor catches and reports the stage). */
46
+ export interface PipelineOperator {
47
+ readonly name: string;
48
+ readonly description: string;
49
+ /** JSON-schema-ish arg description for the tool docs. */
50
+ readonly argsHint: string;
51
+ apply(input: PipeValue, args: unknown): PipeValue;
52
+ }
53
+ /**
54
+ * One stage of a pipeline, exactly one verb key + its args, e.g. `{ "where": "Balance > 0" }`,
55
+ * `{ "tool": "Run View", "with": {...}, "pipeInto": "Body" }`, `{ "map": { "as": "row", "do": [...] } }`.
56
+ */
57
+ export interface PipelineStage {
58
+ [verb: string]: unknown;
59
+ }
60
+ /** Per-stage record emitted by the executor; persisted in the pipeline `Tool` run-step's `OutputData`. */
61
+ export interface PipelineStepRecord {
62
+ index: number;
63
+ toolName: string;
64
+ providerKind: PipelineProviderKind;
65
+ inputSize: number;
66
+ outputSize: number;
67
+ durationMs: number;
68
+ success: boolean;
69
+ error?: string;
70
+ logRef: PipelineStepLogRef;
71
+ /** Non-fatal hint surfaced to the agent (e.g. a stage that filtered a non-empty array to empty). */
72
+ diagnostic?: string;
73
+ }
74
+ /** Outcome of executing a whole pipeline. */
75
+ export interface PipelineExecutionResult {
76
+ success: boolean;
77
+ /** The final stage's value — the ONLY thing returned to the LLM. Null when the pipeline failed. */
78
+ finalOutput: PipeValue | null;
79
+ steps: PipelineStepRecord[];
80
+ /** Agent-facing error message when the pipeline failed (never includes a piped value). */
81
+ error?: string;
82
+ /** 0-based index of the failing top-level stage; `steps[failedStepIndex]` is its record. */
83
+ failedStepIndex?: number;
84
+ /** Sum of intermediate output byte sizes that never reached the LLM. */
85
+ contextBytesSaved: number;
86
+ /** Self-correction hint when the pipeline succeeded but a stage zeroed out a non-empty array. */
87
+ diagnostic?: string;
88
+ }
89
+ //# sourceMappingURL=pipeline.types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"pipeline.types.d.ts","sourceRoot":"","sources":["../../src/pipeline/pipeline.types.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAEH,oEAAoE;AACpE,MAAM,MAAM,SAAS,GAAG,IAAI,GAAG,OAAO,GAAG,MAAM,GAAG,MAAM,GAAG,SAAS,EAAE,GAAG;IAAE,CAAC,GAAG,E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,KAAK,EAAE,MAAM,CAAC;IACd,QAAQ,EAAE,MAAM,CAAC;IACjB,YAAY,EAAE,oBAAoB,CAAC;IACnC,SAAS,EAAE,MAAM,CAAC;IAClB,UAAU,EAAE,MAAM,CAAC;IACnB,UAAU,EAAE,MAAM,CAAC;IACnB,OAAO,EAAE,OAAO,CAAC;IACjB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,MAAM,EAAE,kBAAkB,CAAC;IAC3B,oGAAoG;IACpG,UAAU,CAAC,EAAE,MAAM,CAAC;CACvB;AAED,6CAA6C;AAC7C,MAAM,WAAW,uBAAuB;IACpC,OAAO,EAAE,OAAO,CAAC;IACjB,mGAAmG;IACnG,WAAW,EAAE,SAAS,GAAG,IAAI,CAAC;IAC9B,KAAK,EAAE,kBAAkB,EAAE,CAAC;IAC5B,0FAA0F;IAC1F,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,4FAA4F;IAC5F,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB,wEAAwE;IACxE,iBAAiB,EAAE,MAAM,CAAC;IAC1B,iGAAiG;IACjG,UAAU,CAAC,EAAE,MAAM,CAAC;CACvB"}
@@ -0,0 +1,13 @@
1
+ /**
2
+ * @fileoverview Core contract for Agent Pipelines — a server-side dataflow the agent authors and
3
+ * the server runs, so intermediate values never enter the LLM context window.
4
+ *
5
+ * The pipe carries a {@link PipeValue} (a JSON value), PowerShell-style, NOT a string: stages bind
6
+ * to object properties instead of re-parsing text. Capabilities (Actions / artifact tools) are
7
+ * effectful async stages behind {@link PipelineInvocable}; pure operators (where/select/sort/…) are
8
+ * synchronous value→value functions; `map`/`let` are control constructs handled by the executor.
9
+ *
10
+ * @module @memberjunction/ai-agents
11
+ */
12
+ export {};
13
+ //# sourceMappingURL=pipeline.types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"pipeline.types.js","sourceRoot":"","sources":["../../src/pipeline/pipeline.types.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG"}
@@ -0,0 +1,23 @@
1
+ import { PipeValue } from './pipeline.types.js';
2
+ type Comparison = {
3
+ kind: 'cmp';
4
+ path: string;
5
+ op: string;
6
+ value: PipeValue | PipeValue[];
7
+ };
8
+ type PredicateNode = Comparison | {
9
+ kind: 'and';
10
+ nodes: PredicateNode[];
11
+ } | {
12
+ kind: 'or';
13
+ nodes: PredicateNode[];
14
+ } | {
15
+ kind: 'not';
16
+ node: PredicateNode;
17
+ };
18
+ /** Parse a predicate string into an AST. Throws with a clear message on malformed input. */
19
+ export declare function parsePredicate(src: string): PredicateNode;
20
+ /** Evaluate a parsed predicate against one element. */
21
+ export declare function evaluatePredicate(ast: PredicateNode, element: PipeValue): boolean;
22
+ export {};
23
+ //# sourceMappingURL=predicate.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"predicate.d.ts","sourceRoot":"","sources":["../../src/pipeline/predicate.ts"],"names":[],"mappings":"AAoBA,OAAO,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC;AAS7C,KAAK,UAAU,GAAG;IAAE,IAAI,EAAE,KAAK,CAAC;IAAC,IAAI,EAAE,MAAM,CAAC;IAAC,EAAE,EAAE,MAAM,CAAC;IAAC,KAAK,EAAE,SAAS,GAAG,SAAS,EAAE,CAAA;CAAE,CAAC;AAC5F,KAAK,aAAa,GACZ,UAAU,GACV;IAAE,IAAI,EAAE,KAAK,CAAC;IAAC,KAAK,EAAE,aAAa,EAAE,CAAA;CAAE,GACvC;IAAE,IAAI,EAAE,IAAI,CAAC;IAAC,KAAK,EAAE,aAAa,EAAE,CAAA;CAAE,GACtC;IAAE,IAAI,EAAE,KAAK,CAAC;IAAC,IAAI,EAAE,aAAa,CAAA;CAAE,CAAC;AAM3C,4FAA4F;AAC5F,wBAAgB,cAAc,CAAC,GAAG,EAAE,MAAM,GAAG,aAAa,CAKzD;AAED,uDAAuD;AACvD,wBAAgB,iBAAiB,CAAC,GAAG,EAAE,aAAa,EAAE,OAAO,EAAE,SAAS,GAAG,OAAO,CAWjF"}