@uipath/maestro-builder-sdk 6.93.9 → 6.94.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.
@@ -531,6 +531,15 @@ export const REFUSALS = {
531
531
  HTTP_TIMEOUT_NOT_DURATION: 'lint',
532
532
  HTTP_V1_RETIRED: 'lint',
533
533
  IMPLICIT_SPLIT: 'lint',
534
+ FLOW_AGENT_BATCH_TRANSFORM_COLUMN_DESCRIPTION: 'lint',
535
+ FLOW_AGENT_BATCH_TRANSFORM_COLUMN_NAME: 'lint',
536
+ FLOW_AGENT_BATCH_TRANSFORM_GROUNDING: 'lowering',
537
+ FLOW_AGENT_BATCH_TRANSFORM_NO_COLUMNS: 'lint',
538
+ FLOW_AGENT_BATCH_TRANSFORM_TOO_MANY_COLUMNS: 'lint',
539
+ FLOW_AGENT_BUILTIN_COMPOSITE_REF: 'lowering',
540
+ FLOW_AGENT_BUILTIN_QUERY_SOURCE: 'lowering',
541
+ FLOW_AGENT_BUILTIN_SETTING_NOT_APPLICABLE: 'lowering',
542
+ FLOW_AGENT_BUILTIN_TASK_VARIABLE: 'lowering',
534
543
  INLINE_AGENT_COMPOSITE_INPUT: 'lowering',
535
544
  INLINE_AGENT_EMPTY_RETURNS: 'lint',
536
545
  FLOW_AGENT_ESCALATION_APP_KEY_NOT_GUID: 'lint',
@@ -147,7 +147,10 @@ export interface DecompileOptions {
147
147
  * A context index placed by the canvas or the CLI keeps its real name,
148
148
  * folder and retrieval `settings` (mode, query, threshold, result count, file
149
149
  * extension) only in `<agent source>/resources/<inputs.source>/resource.json`,
150
- * which is read the same way. A setting `context: [...]` cannot express is
150
+ * which is read the same way. A Batch Transform tool reads its settings from
151
+ * its node first, and from `<agent source>/resources/<dir>/resource.json`
152
+ * (`<dir>` its `inputs.source`, else its `inputs.id`) for any the node does
153
+ * not carry. A setting `context: [...]` or `tools: [...]` cannot express is
151
154
  * reported through `warn` (an error when `bestEffort` is false).
152
155
  */
153
156
  readSidecar?: (relativePath: string) => string | undefined;
@@ -64,6 +64,7 @@
64
64
  *
65
65
  * Pure: the caller reads the files ({@link SidecarSet}) and writes the result.
66
66
  */
67
+ import { builtinResourceDirectory } from './core/agent-resource-identity.js';
67
68
  import { jsonClone } from './core/json-clone.js';
68
69
  import { isEmbeddedAgent } from './merge-embedded-agent.js';
69
70
  /** The `{ path, json }` list `serializeWithSidecars` returns, as a {@link SidecarSet}. */
@@ -173,15 +174,23 @@ function resourceDir(source, path) {
173
174
  const dir = path.slice(prefix.length, -'/resource.json'.length);
174
175
  return /^[A-Za-z0-9][A-Za-z0-9._-]*$/.test(dir) ? dir : undefined;
175
176
  }
176
- /** Every node of a flow, root and subflows, by the `inputs.source` it names. */
177
+ /**
178
+ * Every node of a flow, root and subflows, by the resource directory it names:
179
+ * its `inputs.source`, or its `inputs.id` when `source` is empty or binds a
180
+ * value (`builtinResourceDirectory`, the rule decompile reads the sidecar by).
181
+ * The second is how the canvas keys a built-in tool whose `source` is left for
182
+ * the tool's file (empty, an expression object or a binding string), as the reference
183
+ * Batch Transform solution is (docs/INLINE_AGENT_BATCH_TRANSFORM_DESIGN.md,
184
+ * "Finding the sidecar").
185
+ */
177
186
  function nodeIdsBySource(flow) {
178
187
  const out = new Map();
179
188
  const walk = (scope) => {
180
189
  const sc = scope;
181
190
  for (const n of Array.isArray(sc?.nodes) ? sc.nodes : []) {
182
- const src = n?.inputs?.source;
183
- if (typeof src === 'string' && !out.has(src))
184
- out.set(src, n.id);
191
+ const { dir } = builtinResourceDirectory(n?.inputs ?? {});
192
+ if (dir !== undefined && !out.has(dir))
193
+ out.set(dir, n.id);
185
194
  }
186
195
  if (sc?.subflows && typeof sc.subflows === 'object')
187
196
  Object.values(sc.subflows).forEach(walk);
@@ -0,0 +1,60 @@
1
+ import type { Expr } from '../../../core/expr.js';
2
+ import type { FlowDeserializeContext } from '../../../flow-node-type.js';
3
+ import type { Printed } from './inline-agent-lift.js';
4
+ /** The part of a `.flow` node the lift reads. */
5
+ interface FlowNode {
6
+ id: string;
7
+ type: string;
8
+ inputs?: Record<string, unknown>;
9
+ }
10
+ /** The lifted tool: its option rows (placement excluded), and the directory its resource lives in. */
11
+ export interface LiftedBatchTransform {
12
+ /** A task Variable's entry is `Printed`: its reference is an `Expr`, written once the print context is known. */
13
+ entries: Array<[string, string | Printed | undefined]>;
14
+ /** The resource directory the node names (`inputs.source`, else `inputs.id`), to keep as the tool's `source`. */
15
+ dir: string | undefined;
16
+ }
17
+ /**
18
+ * The Batch Transform tool node `t` on agent `agent`, as its `tools` entry's
19
+ * option rows: `description`, `query`, `outputColumns` and
20
+ * `webSearchGrounding`, each left out when it is what compile writes anyway.
21
+ *
22
+ * The query is mode-tagged on the node and variant-tagged in the sidecar:
23
+ * - `prompt` / `dynamic` → a string, left out when empty (the canvas's Empty),
24
+ * or `{ prompt }` when the text starts with `=js:`, which a bare string would
25
+ * turn static;
26
+ * - `text-builder` / `static` → `{ value }`; one holding a `=js:` expression is
27
+ * printed as that bare expression, which compile reads as the same static
28
+ * query (D3);
29
+ * - `variable` / `argument` → `{ variable }`, the reference being the binding
30
+ * of the agent input the task names (`argumentPath` on the node, `{{name}}`
31
+ * in the sidecar), which `variable` resolves; a name that matches no agent
32
+ * input is reported.
33
+ *
34
+ * Reported as lossy: a file binding (an expression or binding `inputs.source`
35
+ * on the node, or `argumentProperties` in the sidecar, D5), a `fileExtension`
36
+ * other than `csv`, a non-empty `folderPathPrefix`, a `contextType` other than
37
+ * `attachments`, settings keys it does not know, an output column key other
38
+ * than `name`/`description`, and a grounding or query it cannot read.
39
+ */
40
+ export declare function liftBatchTransformTool(agent: FlowNode, t: FlowNode, ctx: FlowDeserializeContext, variable: (task: TaskVariable) => Expr | undefined): LiftedBatchTransform;
41
+ /**
42
+ * A task's Variable as the tool holds it, for the agent lift to resolve to the
43
+ * reference it binds: the node's `argumentPath` (`$vars.<path>`, the canvas's
44
+ * form) or the sidecar's `{{<flatName>}}`.
45
+ */
46
+ export interface TaskVariable {
47
+ from: 'node' | 'sidecar';
48
+ text: string;
49
+ }
50
+ /**
51
+ * A built-in tool's task that decompile does not read back: the generic
52
+ * built-in branch prints only `kind`, `tool` and `description`, so a Summarize
53
+ * task (D3: decompiling it is out of scope) would otherwise vanish, and with it
54
+ * the agent input a Variable task binds would come back as an `inputs` row.
55
+ * Reported as lossy when the node's mode-tagged `query`, or the sidecar's
56
+ * variant-tagged one, is anything but Empty (a Prompt with no text). A
57
+ * built-in whose definition has no task (`analyzefiles`) has nothing to report.
58
+ */
59
+ export declare function reportUnreadBuiltinTask(agent: FlowNode, t: FlowNode, tool: string, ctx: FlowDeserializeContext): void;
60
+ export {};
@@ -0,0 +1,255 @@
1
+ /**
2
+ * An inline agent's Batch Transform tool, read back as its `tools: [...]` entry
3
+ * (docs/INLINE_AGENT_BATCH_TRANSFORM_DESIGN.md, "Decompile", D8): the inverse of
4
+ * what compile writes onto the tool node and into its `resource.json`
5
+ * (`batchTransformResourceJson`, resources.ts).
6
+ *
7
+ * **Node first, per field.** Each setting is read from the tool node when the
8
+ * node carries that input, whatever its value, and from `resource.json` only
9
+ * when it does not. That is the agent lift's own rule ("a key on the node wins
10
+ * over the sidecar's copy of it"), and it is right for every writer:
11
+ *
12
+ * - SDK compile: the node carries every input, and the sidecar agrees;
13
+ * - the canvas, self-contained: the node carries every input and is
14
+ * authoritative, while the sidecar is stale after a failed flush;
15
+ * - the canvas shell form (`uip agent refresh --inline-in-flow`): the node is
16
+ * cut to `source`, so the sidecar is the only copy.
17
+ *
18
+ * A setting `tools: [...]` cannot carry is reported through `ctx.lossy` (a
19
+ * warning, an error under `--strict`), because a plain recompile writes the
20
+ * SDK's value in its place; `merge --baseline` keeps the original file.
21
+ */
22
+ import { tsLiteral, tsObject as objLit } from '../../../core/ts-literal.js';
23
+ import { isRecord } from '../../../core/node-envelope.js';
24
+ import { ownEntry } from '../../../core/own-entry.js';
25
+ import { builtinResourceDirectory } from '../../../core/agent-resource-identity.js';
26
+ import { resourceSidecar } from './resource-sidecar.js';
27
+ import { BUILTIN_TOOL_DEFS } from './resources.js';
28
+ /** The `properties.settings` keys of a batch-transform `resource.json` this lift reads or checks. */
29
+ const BATCH_TRANSFORM_SETTINGS_KEYS = new Set([
30
+ 'contextType', 'query', 'folderPathPrefix', 'fileExtension', 'outputColumns', 'webSearchGrounding',
31
+ ]);
32
+ /** The keys of one output column; any other is reported. */
33
+ const COLUMN_KEYS = new Set(['name', 'description']);
34
+ const textOf = (v) => (typeof v === 'string' ? v : undefined);
35
+ const field = (v, k) => (isRecord(v) ? textOf(v[k]) : undefined);
36
+ /**
37
+ * The Batch Transform tool node `t` on agent `agent`, as its `tools` entry's
38
+ * option rows: `description`, `query`, `outputColumns` and
39
+ * `webSearchGrounding`, each left out when it is what compile writes anyway.
40
+ *
41
+ * The query is mode-tagged on the node and variant-tagged in the sidecar:
42
+ * - `prompt` / `dynamic` → a string, left out when empty (the canvas's Empty),
43
+ * or `{ prompt }` when the text starts with `=js:`, which a bare string would
44
+ * turn static;
45
+ * - `text-builder` / `static` → `{ value }`; one holding a `=js:` expression is
46
+ * printed as that bare expression, which compile reads as the same static
47
+ * query (D3);
48
+ * - `variable` / `argument` → `{ variable }`, the reference being the binding
49
+ * of the agent input the task names (`argumentPath` on the node, `{{name}}`
50
+ * in the sidecar), which `variable` resolves; a name that matches no agent
51
+ * input is reported.
52
+ *
53
+ * Reported as lossy: a file binding (an expression or binding `inputs.source`
54
+ * on the node, or `argumentProperties` in the sidecar, D5), a `fileExtension`
55
+ * other than `csv`, a non-empty `folderPathPrefix`, a `contextType` other than
56
+ * `attachments`, settings keys it does not know, an output column key other
57
+ * than `name`/`description`, and a grounding or query it cannot read.
58
+ */
59
+ export function liftBatchTransformTool(agent, t, ctx, variable) {
60
+ const ni = (t.inputs ?? {});
61
+ const has = (k) => Object.prototype.hasOwnProperty.call(ni, k);
62
+ const where = `batch transform tool "${t.id}" on agent "${agent.id}"`;
63
+ const lossy = (what) => {
64
+ ctx.lossy(`${where}: ${what}, which \`tools: [...]\` cannot express, so compile writes the SDK's value instead. `
65
+ + `Edit that setting in the canvas after merging, or merge with --baseline to keep the original resource.json.`);
66
+ };
67
+ const { dir, binding } = builtinResourceDirectory(ni);
68
+ const sidecar = resourceSidecar(agent, dir, ctx, where, 'its settings decompile from the node alone');
69
+ const props = isRecord(sidecar?.properties) ? sidecar.properties : undefined;
70
+ const settings = isRecord(props?.settings) ? props.settings : undefined;
71
+ /** Node first: the node's input when it carries the key, else the sidecar's. */
72
+ const pick = (nodeKey, settingsKey = nodeKey) => has(nodeKey) ? { from: 'node', value: ni[nodeKey] }
73
+ : settings !== undefined && Object.prototype.hasOwnProperty.call(settings, settingsKey)
74
+ ? { from: 'sidecar', value: settings[settingsKey] } : undefined;
75
+ // A shell node (cut to `source`) keeps its settings only in the sidecar; when
76
+ // that could not be read, the entry would silently fall back to the defaults.
77
+ // An SDK or self-contained canvas node always carries these keys.
78
+ if (sidecar === undefined && !has('query') && !has('outputColumns') && !has('webSearchGrounding')) {
79
+ const agentSource = ctx.sourceText(agent.inputs?.source);
80
+ const missing = dir === undefined
81
+ ? 'its settings live in a resource.json, but the node names no resource directory (no `source` directory or `id`)'
82
+ : !agentSource
83
+ ? `its settings live in resources/${dir}/resource.json, but the agent has no source directory to read it from`
84
+ : `its settings live in ${agentSource}/resources/${dir}/resource.json, which decompile could not read`;
85
+ lossy(missing);
86
+ }
87
+ // The file. The SDK cannot bind it yet (D5): the model passes it.
88
+ if (binding !== undefined) {
89
+ const text = ctx.sourceText(binding);
90
+ lossy(`its file source is bound to ${text !== undefined ? JSON.stringify(text) : 'a value'}`);
91
+ }
92
+ const argumentProps = sidecar?.argumentProperties;
93
+ if (isRecord(argumentProps)) {
94
+ for (const k of Object.keys(argumentProps))
95
+ lossy(`its resource.json binds the tool argument ${JSON.stringify(k)}`);
96
+ }
97
+ // Description: compile writes the definition's when it is omitted.
98
+ const defaultDescription = textOf(ownEntry(BUILTIN_TOOL_DEFS, 'batchtransform')?.inputDefaults?.description);
99
+ const description = has('description') ? textOf(ni.description) : textOf(sidecar?.description);
100
+ // An explicit '' is kept: compile writes the default only when it is omitted.
101
+ const descriptionSrc = description !== undefined && description !== defaultDescription
102
+ ? tsLiteral(description) : undefined;
103
+ // The task.
104
+ let querySrc;
105
+ const query = pick('query');
106
+ if (query !== undefined) {
107
+ const read = query.from === 'node' ? nodeQuery(query.value) : sidecarQuery(query.value);
108
+ if (read === undefined)
109
+ lossy(`its task (query) is ${JSON.stringify(query.value)}`);
110
+ else if (read.kind === 'prompt') {
111
+ // A bare `=js:` string compiles as a static query (D3), so a Prompt with
112
+ // that prefix keeps its `{ prompt }` tag.
113
+ querySrc = read.text === '' ? undefined
114
+ : read.text.startsWith('=js:') ? objLit([['prompt', tsLiteral(read.text)]]) : tsLiteral(read.text);
115
+ }
116
+ else if (read.kind === 'value') {
117
+ querySrc = read.text.startsWith('=js:') ? tsLiteral(read.text) : objLit([['value', tsLiteral(read.text)]]);
118
+ }
119
+ else {
120
+ const ref = variable({ from: query.from, text: read.text });
121
+ if (ref !== undefined)
122
+ querySrc = (print) => objLit([['variable', print.value(ref)]]);
123
+ else
124
+ lossy(`its task (query) is the agent argument ${JSON.stringify(read.text)}, which names no agent input`);
125
+ }
126
+ }
127
+ // The output columns, in order.
128
+ let columnsSrc;
129
+ const columns = pick('outputColumns');
130
+ if (columns !== undefined && columns.value !== undefined && columns.value !== null) {
131
+ if (!Array.isArray(columns.value)) {
132
+ lossy(`its output columns are ${JSON.stringify(columns.value)}, not a list`);
133
+ }
134
+ else {
135
+ const rows = columns.value.map((c, n) => {
136
+ if (!isRecord(c)) {
137
+ lossy(`its output column ${n + 1} is ${JSON.stringify(c)}`);
138
+ return undefined;
139
+ }
140
+ const extra = Object.keys(c).filter((k) => !COLUMN_KEYS.has(k));
141
+ if (extra.length > 0)
142
+ lossy(`its output column ${n + 1} carries ${extra.map((k) => JSON.stringify(k)).join(', ')}`);
143
+ return objLit([['name', tsLiteral(textOf(c.name) ?? '')], ['description', tsLiteral(textOf(c.description) ?? '')]]);
144
+ }).filter((r) => r !== undefined);
145
+ columnsSrc = rows.length > 0 ? `[${rows.join(', ')}]` : undefined;
146
+ }
147
+ }
148
+ // Web search grounding: lowercase on the node, capitalized in the file.
149
+ let groundingSrc;
150
+ const grounding = pick('webSearchGrounding');
151
+ if (grounding !== undefined) {
152
+ const raw = field(grounding.value, 'value');
153
+ const g = raw?.toLowerCase();
154
+ if (g === 'disabled')
155
+ groundingSrc = tsLiteral('disabled');
156
+ else if (g !== 'enabled')
157
+ lossy(`its web search grounding is ${JSON.stringify(grounding.value)}`);
158
+ }
159
+ // What compile writes as constants; anything else has no field.
160
+ const extension = pick('fileExtension');
161
+ if (extension !== undefined) {
162
+ const ext = field(extension.value, 'value') ?? textOf(extension.value);
163
+ if (ext?.toLowerCase() !== 'csv')
164
+ lossy(`its file extension is ${JSON.stringify(ext ?? extension.value)}`);
165
+ }
166
+ const prefix = pick('folderPathPrefix');
167
+ if (prefix !== undefined) {
168
+ const text = prefix.from === 'node'
169
+ ? field(prefix.value, 'textValue') || field(prefix.value, 'promptValue') || ''
170
+ : field(prefix.value, 'value') || field(prefix.value, 'description') || '';
171
+ if (text !== '')
172
+ lossy(`its folder-path prefix is ${JSON.stringify(text)}`);
173
+ }
174
+ const contextType = settings?.contextType;
175
+ if (contextType !== undefined && contextType !== 'attachments')
176
+ lossy(`its context type is ${JSON.stringify(contextType)}`);
177
+ for (const k of Object.keys(settings ?? {})) {
178
+ if (!BATCH_TRANSFORM_SETTINGS_KEYS.has(k))
179
+ lossy(`its resource.json settings carry ${JSON.stringify(k)}`);
180
+ }
181
+ return {
182
+ entries: [
183
+ ['kind', tsLiteral('builtin')],
184
+ ['tool', tsLiteral('batchtransform')],
185
+ ['description', descriptionSrc],
186
+ ['query', querySrc],
187
+ ['outputColumns', columnsSrc],
188
+ ['webSearchGrounding', groundingSrc],
189
+ ],
190
+ dir,
191
+ };
192
+ }
193
+ /** The node's mode-tagged `query` (or a pre-1.2 bare string); undefined when it is neither. */
194
+ function nodeQuery(q) {
195
+ if (q === undefined || q === null)
196
+ return { kind: 'prompt', text: '' };
197
+ if (typeof q === 'string')
198
+ return { kind: q.startsWith('=js:') ? 'value' : 'prompt', text: q };
199
+ if (!isRecord(q))
200
+ return undefined;
201
+ if (q.mode === 'text-builder')
202
+ return { kind: 'value', text: textOf(q.textValue) ?? '' };
203
+ if (q.mode === 'variable')
204
+ return { kind: 'argument', text: textOf(q.argumentPath) ?? '' };
205
+ if (q.mode === 'prompt' || q.mode === undefined)
206
+ return { kind: 'prompt', text: textOf(q.promptValue) ?? '' };
207
+ return undefined;
208
+ }
209
+ /** The sidecar's variant-tagged `query`; undefined for a variant it does not know. */
210
+ function sidecarQuery(q) {
211
+ if (q === undefined || q === null)
212
+ return { kind: 'prompt', text: '' };
213
+ if (!isRecord(q))
214
+ return undefined;
215
+ if (q.variant === 'dynamic')
216
+ return { kind: 'prompt', text: textOf(q.description) ?? '' };
217
+ if (q.variant === 'static')
218
+ return { kind: 'value', text: textOf(q.value) ?? '' };
219
+ if (q.variant === 'argument')
220
+ return { kind: 'argument', text: textOf(q.value) ?? '' };
221
+ return undefined;
222
+ }
223
+ /**
224
+ * A built-in tool's task that decompile does not read back: the generic
225
+ * built-in branch prints only `kind`, `tool` and `description`, so a Summarize
226
+ * task (D3: decompiling it is out of scope) would otherwise vanish, and with it
227
+ * the agent input a Variable task binds would come back as an `inputs` row.
228
+ * Reported as lossy when the node's mode-tagged `query`, or the sidecar's
229
+ * variant-tagged one, is anything but Empty (a Prompt with no text). A
230
+ * built-in whose definition has no task (`analyzefiles`) has nothing to report.
231
+ */
232
+ export function reportUnreadBuiltinTask(agent, t, tool, ctx) {
233
+ const defaults = ownEntry(BUILTIN_TOOL_DEFS, tool)?.inputDefaults;
234
+ if (defaults?.query === undefined)
235
+ return;
236
+ const ni = (t.inputs ?? {});
237
+ const where = `${tool} tool "${t.id}" on agent "${agent.id}"`;
238
+ const { dir } = builtinResourceDirectory(ni);
239
+ const sidecar = resourceSidecar(agent, dir, ctx, where, 'its task is read from the node alone');
240
+ const props = isRecord(sidecar?.properties) ? sidecar.properties : undefined;
241
+ const settings = isRecord(props?.settings) ? props.settings : undefined;
242
+ const tasks = [];
243
+ if (Object.prototype.hasOwnProperty.call(ni, 'query'))
244
+ tasks.push(nodeQuery(ni.query));
245
+ if (settings !== undefined && Object.prototype.hasOwnProperty.call(settings, 'query'))
246
+ tasks.push(sidecarQuery(settings.query));
247
+ const task = tasks.find((x) => x === undefined || x.kind !== 'prompt' || x.text !== '');
248
+ if (tasks.length === 0 || (task === undefined && tasks.every((x) => x !== undefined)))
249
+ return;
250
+ const label = { prompt: 'the Prompt', value: 'the Fixed value', argument: 'the Variable' };
251
+ const what = task === undefined ? 'a task decompile cannot read' : `${label[task.kind]} ${JSON.stringify(task.text)}`;
252
+ ctx.lossy(`${where}: its task (query) is ${what}. Decompile does not read a ${tool} tool's task back, so `
253
+ + `the printed tool has none and compile writes an Empty task instead. Merge with --baseline to keep the `
254
+ + `original task, or set it again in the canvas after merging.`);
255
+ }
@@ -58,7 +58,7 @@ export declare function jsonTextDirective(text: string, returnKeys?: readonly st
58
58
  * - `INLINE_AGENT_UNREFERENCED_INPUT` — flow-v1 derives the deployed input list by
59
59
  * scanning the PROMPTS for `$vars.*` references and only falls back to the
60
60
  * authored `agentInputVariables` when that pre-pass did not run. So a declared
61
- * input the prompts never mention, and no tool argument binds as its
61
+ * input the prompts never mention, and no tool argument or built-in's task binds as its
62
62
  * `variable`, is pruned deployed while arriving locally: a
63
63
  * disagreement between rungs and the platform, which is the one class that has to
64
64
  * be said out loud rather than left to a run.
@@ -28,6 +28,10 @@ export const AGENT_DIAGNOSTICS = {
28
28
  GUARDRAIL_NO_SCOPE: { severity: 'error', summary: 'a guardrail whose selector names no scope' },
29
29
  GUARDRAIL_NO_VALIDATOR: { severity: 'error', summary: 'a built-in validator guardrail with no validatorType' },
30
30
  GUARDRAIL_TYPE_UNKNOWN: { severity: 'error', summary: 'a guardrail whose type is unknown' },
31
+ FLOW_AGENT_BATCH_TRANSFORM_COLUMN_DESCRIPTION: { severity: 'error', summary: 'a Batch Transform output column whose description is empty or over 20,000 characters' },
32
+ FLOW_AGENT_BATCH_TRANSFORM_COLUMN_NAME: { severity: 'error', summary: 'a Batch Transform output column whose name the canvas does not accept' },
33
+ FLOW_AGENT_BATCH_TRANSFORM_NO_COLUMNS: { severity: 'error', summary: 'a Batch Transform tool with no output columns' },
34
+ FLOW_AGENT_BATCH_TRANSFORM_TOO_MANY_COLUMNS: { severity: 'error', summary: 'a Batch Transform tool with more than 10 output columns' },
31
35
  INLINE_AGENT_COMPOSITE_INPUT: { severity: 'error', summary: 'an inline agent input bound to a computed expression' },
32
36
  INLINE_AGENT_EMPTY_RETURNS: { severity: 'warning', summary: 'an inline agent with returns: {}' },
33
37
  FLOW_AGENT_ESCALATION_APP_KEY_NOT_GUID: { severity: 'error', summary: 'an app escalation whose app key is not a GUID' },
@@ -375,6 +379,106 @@ function checkToolArguments(tool, args, ctx, who) {
375
379
  }
376
380
  }
377
381
  }
382
+ // ─── a built-in tool's settings ──────────────────────────────────────────────────
383
+ /** The canvas's Output columns editor: `maxColumns`, and the name and description fields' limits. */
384
+ const BATCH_TRANSFORM_MAX_COLUMNS = 10;
385
+ const COLUMN_NAME_MAX = 64;
386
+ const COLUMN_NAME_RE = /^[a-zA-Z0-9_-]+$/;
387
+ const COLUMN_DESCRIPTION_MAX = 20_000;
388
+ const COLUMN_DESCRIPTION_MAX_TEXT = '20,000';
389
+ /** The built-ins whose definition has a task (`inputs.query`). */
390
+ const BUILTIN_TOOLS_WITH_QUERY = ['summarize', 'batchtransform'];
391
+ /** A `{ … }` literal, the only value a named task source can be; an `Expr`, an array or a string is not one. */
392
+ const isPlainObject = (v) => typeof v === 'object' && v !== null && !Array.isArray(v)
393
+ && (Object.getPrototypeOf(v) === Object.prototype || Object.getPrototypeOf(v) === null);
394
+ /**
395
+ * The flat names of the agent inputs a tool's Variables bind: a process tool's
396
+ * arguments (`toolVariableRefs`), or a built-in's task, `{ variable: <one
397
+ * reference> }`. Both go through `agentInputRef`, as `agentInputPlan` names them,
398
+ * so a declared input bound to the same reference is that one input.
399
+ */
400
+ function toolVariableNames(tool) {
401
+ const t = tool;
402
+ if (isProcessToolKind(t?.kind))
403
+ return Object.values(toolVariableRefs(t.inputs, rendered)).map((r) => r.flatName);
404
+ if (t?.kind !== 'builtin' || !BUILTIN_TOOLS_WITH_QUERY.includes(t.tool) || !isPlainObject(t.query))
405
+ return [];
406
+ const keys = Object.keys(t.query);
407
+ if (keys.length !== 1 || keys[0] !== 'variable')
408
+ return [];
409
+ const ref = agentInputRef(rendered(t.query.variable));
410
+ return ref === undefined ? [] : [ref.flatName];
411
+ }
412
+ /**
413
+ * A built-in tool's settings (docs/INLINE_AGENT_BATCH_TRANSFORM_DESIGN.md,
414
+ * "What `check` reports"). Compile writes them as given, into the tool node and
415
+ * its `resource.json`, and nothing downstream reads them before a run: the
416
+ * node's definition types `outputColumns` only as an array, and the storage
417
+ * schema refines none of them. The column rules are the canvas's Output
418
+ * columns editor's. Where the canvas drops a bad column on save, `check`
419
+ * refuses it, because a column the author wrote and the tool never fills is
420
+ * worse than an error. Like the canvas, it does not require distinct names.
421
+ *
422
+ * What compile refuses is not judged here: a task object it cannot write
423
+ * (`FLOW_AGENT_BUILTIN_QUERY_SOURCE`), a task Variable that is no single
424
+ * reference (`FLOW_AGENT_BUILTIN_COMPOSITE_REF`) or that the agent cannot bind
425
+ * (`FLOW_AGENT_BUILTIN_TASK_VARIABLE`), a grounding the select does not offer
426
+ * (`FLOW_AGENT_BATCH_TRANSFORM_GROUNDING`) and a Batch Transform setting on
427
+ * another built-in (`FLOW_AGENT_BUILTIN_SETTING_NOT_APPLICABLE`) are held by
428
+ * `toolArguments` and reported from there in collect mode, so they are skipped
429
+ * here, as `checkToolArguments` skips a process argument's.
430
+ */
431
+ function checkBuiltinTool(t, ctx, who) {
432
+ const tool = t.tool;
433
+ const where = `${who} step "${ctx.step}"'s ${String(tool)} tool`;
434
+ if (tool === 'batchtransform')
435
+ checkBatchTransformColumns(t.outputColumns, where, ctx);
436
+ }
437
+ /** Batch Transform's `outputColumns`, under the canvas's Output columns editor's rules. */
438
+ function checkBatchTransformColumns(columns, where, ctx) {
439
+ const example = `outputColumns: [{ name: 'Category', description: 'One of: Utility, Software, Travel, Other' }]`;
440
+ if (!Array.isArray(columns) || columns.length === 0) {
441
+ ctx.report('FLOW_AGENT_BATCH_TRANSFORM_NO_COLUMNS', `${where} ${columns === undefined ? 'has no `outputColumns`'
442
+ : Array.isArray(columns) ? 'has an empty `outputColumns`'
443
+ : `has \`outputColumns\` ${JSON.stringify(columns) ?? String(columns)}, which is not a list`}. `
444
+ + `The columns are what the tool adds to each row of the file — without one it has nothing to fill. `
445
+ + `The canvas's definition requires at least one ("At least one output column is required").`, example);
446
+ return;
447
+ }
448
+ if (columns.length > BATCH_TRANSFORM_MAX_COLUMNS) {
449
+ ctx.report('FLOW_AGENT_BATCH_TRANSFORM_TOO_MANY_COLUMNS', `${where} has ${columns.length} \`outputColumns\`. The canvas allows at most ${BATCH_TRANSFORM_MAX_COLUMNS} `
450
+ + `(its Add button is disabled past that), so a flow with more is one the canvas cannot have written, and `
451
+ + `cannot edit. Keep the ${BATCH_TRANSFORM_MAX_COLUMNS} that matter, or split the work over two tools.`);
452
+ }
453
+ // `Array.from`, not `forEach`: every index, so a hole in a sparse list is
454
+ // read as `undefined` and reported like the `null` compile's clone writes there.
455
+ Array.from(columns).forEach((c, i) => {
456
+ const col = (c ?? {});
457
+ const label = typeof col.name === 'string' && col.name !== '' ? `"${col.name}"` : `outputColumns[${i}]`;
458
+ const name = col.name;
459
+ const nameProblem = typeof name !== 'string' || name.trim() === '' ? 'has no name'
460
+ : name.length > COLUMN_NAME_MAX ? `has a name of ${name.length} characters, over the ${COLUMN_NAME_MAX} the canvas allows`
461
+ : !COLUMN_NAME_RE.test(name)
462
+ ? `has a name with ${/^\s|\s$/.test(name) ? 'spaces around it' : 'a character other than a letter, a digit, `_` or `-`'}`
463
+ : undefined;
464
+ if (nameProblem !== undefined) {
465
+ const fixed = typeof name === 'string' ? name.trim().replace(/[^a-zA-Z0-9_-]+/g, '_').slice(0, COLUMN_NAME_MAX) : '';
466
+ ctx.report('FLOW_AGENT_BATCH_TRANSFORM_COLUMN_NAME', `${where}'s column ${label} ${nameProblem}. The name is the new column's header, and the canvas accepts `
467
+ + `only 1 to ${COLUMN_NAME_MAX} letters (a-z, A-Z), digits, underscores or hyphens: it drops any other `
468
+ + `column when it saves, so the tool would never fill it.`, `{ name: '${fixed || 'Category'}', description: … }`);
469
+ }
470
+ const d = col.description;
471
+ const descriptionProblem = typeof d !== 'string' || d.trim() === '' ? 'has no description'
472
+ : d.length > COLUMN_DESCRIPTION_MAX
473
+ ? `has a description of ${d.length} characters, over the ${COLUMN_DESCRIPTION_MAX_TEXT} the canvas allows`
474
+ : undefined;
475
+ if (descriptionProblem !== undefined) {
476
+ ctx.report('FLOW_AGENT_BATCH_TRANSFORM_COLUMN_DESCRIPTION', `${where}'s column ${label} ${descriptionProblem}. The description is what the model is told to put in `
477
+ + `the column, and the canvas requires one of 1 to ${COLUMN_DESCRIPTION_MAX_TEXT} characters `
478
+ + `("Description is required").`, `{ name: ${typeof name === 'string' ? JSON.stringify(name) : `'Category'`}, description: 'One of: Utility, Software, Travel, Other' }`);
479
+ }
480
+ });
481
+ }
378
482
  /**
379
483
  * Check an `inlineAgent(...)` call.
380
484
  *
@@ -392,7 +496,7 @@ function checkToolArguments(tool, args, ctx, who) {
392
496
  * - `INLINE_AGENT_UNREFERENCED_INPUT` — flow-v1 derives the deployed input list by
393
497
  * scanning the PROMPTS for `$vars.*` references and only falls back to the
394
498
  * authored `agentInputVariables` when that pre-pass did not run. So a declared
395
- * input the prompts never mention, and no tool argument binds as its
499
+ * input the prompts never mention, and no tool argument or built-in's task binds as its
396
500
  * `variable`, is pruned deployed while arriving locally: a
397
501
  * disagreement between rungs and the platform, which is the one class that has to
398
502
  * be said out loud rather than left to a run.
@@ -503,25 +607,22 @@ export function checkInlineAgent(inputs, ctx) {
503
607
  // searched, because flow-v1's pre-pass scans both.
504
608
  const placeholders = promptPlaceholders(inputs ?? {});
505
609
  const declaredInputs = Object.keys(inputs?.inputs ?? {});
506
- // The agent inputs a process tool's Variable arguments bind, by flat name. A
507
- // declared input bound to the same reference is that one input
508
- // (`agentInputPlan`), so a tool argument reads it.
610
+ // The agent inputs the tools' Variables bind (a process tool's arguments, a
611
+ // built-in's task), by flat name. A declared input bound to the same
612
+ // reference is that one input (`agentInputPlan`), so a tool reads it.
509
613
  const tools = inputs?.tools === undefined ? [] : Array.isArray(inputs.tools) ? inputs.tools : [inputs.tools];
510
- const toolBound = new Set(tools
511
- .filter((t) => isProcessToolKind(t?.kind))
512
- .flatMap((t) => Object.values(toolVariableRefs(t.inputs, rendered)))
513
- .map((r) => r.flatName));
614
+ const toolBound = new Set(tools.flatMap(toolVariableNames));
514
615
  const boundForTool = (k) => {
515
616
  const ref = agentInputRef(rendered(inputs?.inputs?.[k]));
516
617
  return ref !== undefined && toolBound.has(ref.flatName);
517
618
  };
518
- // Direction 1: a declared input no prompt references and no tool argument
619
+ // Direction 1: a declared input no prompt references and no tool's Variable
519
620
  // binds. The platform may prune it, in which case the agent receives nothing
520
621
  // and the authored list sits unused.
521
622
  const unreferenced = declaredInputs.filter((k) => !placeholders.includes(k) && !boundForTool(k));
522
623
  if (declaredInputs.length && unreferenced.length === declaredInputs.length) {
523
624
  warn('INLINE_AGENT_UNREFERENCED_INPUT', `Inline agent step "${step}" declares input(s) ${unreferenced.map((u) => `\`${u}\``).join(', ')} that `
524
- + `neither prompt references as \`{{input.<name>}}\` and no tool argument binds as its \`variable\` — so `
625
+ + `neither prompt references as \`{{input.<name>}}\` and no tool argument or tool's task binds as its \`variable\` — so `
525
626
  + `NONE of them is referenced. Deployed, the `
526
627
  + `authored list is not necessarily what the platform sends: flow-v1's `
527
628
  + `\`preDeriveAgentInputDefinitions\` pre-pass builds the input list by scanning the node's prompts for `
@@ -533,7 +634,7 @@ export function checkInlineAgent(inputs, ctx) {
533
634
  }
534
635
  else if (unreferenced.length) {
535
636
  warn('INLINE_AGENT_UNREFERENCED_INPUT', `Inline agent step "${step}" declares input(s) ${unreferenced.map((u) => `\`${u}\``).join(', ')} that `
536
- + `neither prompt references as \`{{input.<name>}}\` and no tool argument binds as its \`variable\`. `
637
+ + `neither prompt references as \`{{input.<name>}}\` and no tool argument or tool's task binds as its \`variable\`. `
537
638
  + `The platform may prune an unreferenced input, so `
538
639
  + `it is not reliably sent — and an input the prompts never mention is one the agent cannot use anyway.`);
539
640
  }
@@ -780,6 +881,9 @@ export function checkAgentResources(inputs, ctx, who) {
780
881
  + `calling application dispatches on it.`);
781
882
  }
782
883
  }
884
+ else if (kind === 'builtin') {
885
+ checkBuiltinTool(t, ctx, who);
886
+ }
783
887
  else if (kind === 'httpRequest') {
784
888
  const h = t;
785
889
  const m = h.method === undefined ? undefined : String(h.method).toUpperCase();