@uipath/maestro-builder-sdk 6.93.9 → 6.94.1
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/dist/api-index.md +27 -26
- package/dist/api-members.md +77 -75
- package/dist/case/decompile.js +15 -0
- package/dist/case/preserve.d.ts +19 -12
- package/dist/case/serialize.js +8 -1
- package/dist/core/actions.d.ts +43 -4
- package/dist/core/agent-resource-identity.d.ts +17 -0
- package/dist/core/agent-resource-identity.js +23 -0
- package/dist/core/refusals.d.ts +9 -0
- package/dist/core/refusals.js +9 -0
- package/dist/decompile.d.ts +4 -1
- package/dist/merge-sidecars.js +13 -4
- package/dist/nodes/agent/flow/builtin-tool-lift.d.ts +60 -0
- package/dist/nodes/agent/flow/builtin-tool-lift.js +255 -0
- package/dist/nodes/agent/flow/check.d.ts +1 -1
- package/dist/nodes/agent/flow/check.js +115 -11
- package/dist/nodes/agent/flow/inline-agent-lift.js +52 -40
- package/dist/nodes/agent/flow/inline-agent.d.ts +13 -7
- package/dist/nodes/agent/flow/inline-agent.js +66 -18
- package/dist/nodes/agent/flow/node-type.js +5 -5
- package/dist/nodes/agent/flow/resource-sidecar.d.ts +22 -0
- package/dist/nodes/agent/flow/resource-sidecar.js +25 -0
- package/dist/nodes/agent/flow/resources.d.ts +76 -8
- package/dist/nodes/agent/flow/resources.js +345 -39
- package/dist/nodes/ai-patterns/flow/spec.d.ts +1 -7
- package/package.json +2 -2
package/dist/core/actions.d.ts
CHANGED
|
@@ -587,16 +587,55 @@ export interface BuiltinToolRef {
|
|
|
587
587
|
/** What the agent is told the tool does. Defaults to the platform's own text. */
|
|
588
588
|
description?: string;
|
|
589
589
|
/**
|
|
590
|
-
* `summarize`/`batchtransform` only: the
|
|
591
|
-
*
|
|
592
|
-
*
|
|
590
|
+
* `summarize`/`batchtransform` only: the task, from one of the canvas's four
|
|
591
|
+
* sources ({@link BuiltinToolQuery}). Omitted, it is the canvas's Empty. A
|
|
592
|
+
* bare flow expression keeps its earlier meaning, a static query with the
|
|
593
|
+
* expression's text, so the type stays open beside the named forms.
|
|
593
594
|
*/
|
|
594
|
-
query?: unknown;
|
|
595
|
+
query?: BuiltinToolQuery | unknown;
|
|
596
|
+
/**
|
|
597
|
+
* `batchtransform` only: the columns the tool adds to each row, in order. The
|
|
598
|
+
* canvas requires at least one.
|
|
599
|
+
*/
|
|
600
|
+
outputColumns?: OutputColumn[];
|
|
601
|
+
/**
|
|
602
|
+
* `batchtransform` only: whether the tool may search the web to fill a column.
|
|
603
|
+
* The platform defaults to `'enabled'`.
|
|
604
|
+
*/
|
|
605
|
+
webSearchGrounding?: 'enabled' | 'disabled';
|
|
595
606
|
/** `summarize` only: restrict to one file type. The platform defaults to `'pdf'`. */
|
|
596
607
|
fileExtension?: string;
|
|
597
608
|
/** `summarize` only: citation style. The platform defaults to `'inline'`. */
|
|
598
609
|
citationMode?: string;
|
|
599
610
|
}
|
|
611
|
+
/**
|
|
612
|
+
* Where a built-in tool's task comes from: the canvas's sources, each under the
|
|
613
|
+
* same named key a tool argument takes, since a bare value cannot say which
|
|
614
|
+
* source it is. Leaving `query` out is the fourth, Empty: the model writes the
|
|
615
|
+
* task with no guidance.
|
|
616
|
+
* - a string or `{ prompt }`: Prompt, the model writes the task at run time,
|
|
617
|
+
* guided by this text;
|
|
618
|
+
* - `{ value }`: Fixed value, the task itself;
|
|
619
|
+
* - `{ variable }`: Variable, a single flow reference whose value is the task.
|
|
620
|
+
*/
|
|
621
|
+
export type BuiltinToolQuery = string | {
|
|
622
|
+
prompt: string;
|
|
623
|
+
} | {
|
|
624
|
+
value: string;
|
|
625
|
+
} | {
|
|
626
|
+
variable: unknown;
|
|
627
|
+
};
|
|
628
|
+
/**
|
|
629
|
+
* One column Batch Transform appends to the CSV: of the inline agent's
|
|
630
|
+
* Batch Transform tool ({@link BuiltinToolRef.outputColumns}) and of the
|
|
631
|
+
* Batch Transform step (`BatchTransformInputs.outputColumns`).
|
|
632
|
+
*/
|
|
633
|
+
export interface OutputColumn {
|
|
634
|
+
/** The new column's header, e.g. `'Category'`. */
|
|
635
|
+
name: string;
|
|
636
|
+
/** What the model should put in it, e.g. `'One of: Utility, Software, Travel, Other'`. */
|
|
637
|
+
description: string;
|
|
638
|
+
}
|
|
600
639
|
/**
|
|
601
640
|
* An Integration Service connector operation as a tool — e.g. "create a Jira
|
|
602
641
|
* issue". Resolved from the same curated library as `connector(…)`, so the
|
|
@@ -32,3 +32,20 @@ export declare function toolResourceSeed(tr: ToolRef): string;
|
|
|
32
32
|
export declare function derivedToolSource(flowId: string, agentStep: string, tr: ToolRef): string;
|
|
33
33
|
/** The directory compile derives for an escalation (`name` = the escalation's name). */
|
|
34
34
|
export declare function derivedEscalationSource(flowId: string, agentStep: string, name: string): string;
|
|
35
|
+
/**
|
|
36
|
+
* Where a built-in tool node keeps its resource directory, and whether its
|
|
37
|
+
* `inputs.source` is a file binding instead.
|
|
38
|
+
*
|
|
39
|
+
* The SDK and a shell-form node put the directory uuid in `inputs.source`. The
|
|
40
|
+
* canvas leaves `source` for the tool's file, and keys the resource by
|
|
41
|
+
* `inputs.id` when that is empty or a binding (`canvas-to-storage.ts:1687-1696`
|
|
42
|
+
* in flow-workbench): an expression object (`{ type: 'jsExpression', … }`, what
|
|
43
|
+
* its file editor stores) or a binding string. So the directory is a non-empty,
|
|
44
|
+
* non-binding `source`, else a non-empty `id`. Decompile reads the sidecar
|
|
45
|
+
* there, and `merge --baseline` pairs a resource directory with its node by it,
|
|
46
|
+
* so the two agree on which directory a node owns.
|
|
47
|
+
*/
|
|
48
|
+
export declare function builtinResourceDirectory(inputs: Record<string, unknown>): {
|
|
49
|
+
dir: string | undefined;
|
|
50
|
+
binding: unknown;
|
|
51
|
+
};
|
|
@@ -35,3 +35,26 @@ export function derivedToolSource(flowId, agentStep, tr) {
|
|
|
35
35
|
export function derivedEscalationSource(flowId, agentStep, name) {
|
|
36
36
|
return fnv1aX4Uuid(`${flowId}/${agentStep}/escalation/${name}`);
|
|
37
37
|
}
|
|
38
|
+
/** A string `inputs.source` that binds a value (`=js:…`, `{{ … }}`, `$vars.…`) rather than naming a directory. */
|
|
39
|
+
const isBindingText = (s) => /^\s*(=|\$|\{\{)/.test(s);
|
|
40
|
+
/**
|
|
41
|
+
* Where a built-in tool node keeps its resource directory, and whether its
|
|
42
|
+
* `inputs.source` is a file binding instead.
|
|
43
|
+
*
|
|
44
|
+
* The SDK and a shell-form node put the directory uuid in `inputs.source`. The
|
|
45
|
+
* canvas leaves `source` for the tool's file, and keys the resource by
|
|
46
|
+
* `inputs.id` when that is empty or a binding (`canvas-to-storage.ts:1687-1696`
|
|
47
|
+
* in flow-workbench): an expression object (`{ type: 'jsExpression', … }`, what
|
|
48
|
+
* its file editor stores) or a binding string. So the directory is a non-empty,
|
|
49
|
+
* non-binding `source`, else a non-empty `id`. Decompile reads the sidecar
|
|
50
|
+
* there, and `merge --baseline` pairs a resource directory with its node by it,
|
|
51
|
+
* so the two agree on which directory a node owns.
|
|
52
|
+
*/
|
|
53
|
+
export function builtinResourceDirectory(inputs) {
|
|
54
|
+
const source = inputs.source;
|
|
55
|
+
if (typeof source === 'string' && source !== '' && !isBindingText(source))
|
|
56
|
+
return { dir: source, binding: undefined };
|
|
57
|
+
const id = typeof inputs.id === 'string' && inputs.id !== '' ? inputs.id : undefined;
|
|
58
|
+
const bound = (typeof source === 'string' && source !== '') || (source !== null && typeof source === 'object');
|
|
59
|
+
return { dir: id, binding: bound ? source : undefined };
|
|
60
|
+
}
|
package/dist/core/refusals.d.ts
CHANGED
|
@@ -457,6 +457,15 @@ export declare const REFUSALS: {
|
|
|
457
457
|
readonly HTTP_TIMEOUT_NOT_DURATION: "lint";
|
|
458
458
|
readonly HTTP_V1_RETIRED: "lint";
|
|
459
459
|
readonly IMPLICIT_SPLIT: "lint";
|
|
460
|
+
readonly FLOW_AGENT_BATCH_TRANSFORM_COLUMN_DESCRIPTION: "lint";
|
|
461
|
+
readonly FLOW_AGENT_BATCH_TRANSFORM_COLUMN_NAME: "lint";
|
|
462
|
+
readonly FLOW_AGENT_BATCH_TRANSFORM_GROUNDING: "lowering";
|
|
463
|
+
readonly FLOW_AGENT_BATCH_TRANSFORM_NO_COLUMNS: "lint";
|
|
464
|
+
readonly FLOW_AGENT_BATCH_TRANSFORM_TOO_MANY_COLUMNS: "lint";
|
|
465
|
+
readonly FLOW_AGENT_BUILTIN_COMPOSITE_REF: "lowering";
|
|
466
|
+
readonly FLOW_AGENT_BUILTIN_QUERY_SOURCE: "lowering";
|
|
467
|
+
readonly FLOW_AGENT_BUILTIN_SETTING_NOT_APPLICABLE: "lowering";
|
|
468
|
+
readonly FLOW_AGENT_BUILTIN_TASK_VARIABLE: "lowering";
|
|
460
469
|
readonly INLINE_AGENT_COMPOSITE_INPUT: "lowering";
|
|
461
470
|
readonly INLINE_AGENT_EMPTY_RETURNS: "lint";
|
|
462
471
|
readonly FLOW_AGENT_ESCALATION_APP_KEY_NOT_GUID: "lint";
|
package/dist/core/refusals.js
CHANGED
|
@@ -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',
|
package/dist/decompile.d.ts
CHANGED
|
@@ -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
|
|
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;
|
package/dist/merge-sidecars.js
CHANGED
|
@@ -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
|
-
/**
|
|
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
|
|
183
|
-
if (
|
|
184
|
-
out.set(
|
|
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.
|