@uipath/maestro-builder-sdk 6.89.1 → 6.90.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.
- package/dist/api-index.md +24 -23
- package/dist/api-members.md +49 -49
- package/dist/case/check-cli.js +4 -114
- package/dist/case/check.d.ts +0 -7
- package/dist/case/check.js +0 -5
- package/dist/cli/commands/case.js +0 -7
- package/dist/core/actions.d.ts +35 -2
- package/dist/core/agent-sidecar.d.ts +28 -2
- package/dist/core/agent-sidecar.js +29 -8
- package/dist/core/expr.d.ts +19 -0
- package/dist/core/expr.js +25 -0
- package/dist/core/refusals.d.ts +6 -1
- package/dist/core/refusals.js +6 -3
- package/dist/core/tool-argument.d.ts +105 -0
- package/dist/core/tool-argument.js +207 -0
- package/dist/decompile.js +6 -0
- package/dist/flow-node-type.d.ts +7 -0
- package/dist/nodes/agent/flow/check.d.ts +2 -9
- package/dist/nodes/agent/flow/check.js +104 -8
- package/dist/nodes/agent/flow/inline-agent-lift.d.ts +22 -3
- package/dist/nodes/agent/flow/inline-agent-lift.js +333 -56
- package/dist/nodes/agent/flow/inline-agent.d.ts +22 -1
- package/dist/nodes/agent/flow/inline-agent.js +60 -4
- package/dist/nodes/agent/flow/node-type.js +9 -3
- package/dist/nodes/agent/flow/resources.d.ts +10 -2
- package/dist/nodes/agent/flow/resources.js +32 -6
- package/package.json +2 -2
- package/dist/case/registry-resolved.d.ts +0 -121
- package/dist/case/registry-resolved.js +0 -155
|
@@ -0,0 +1,207 @@
|
|
|
1
|
+
import { agentInputRef, classifyAgentInput } from './agent-sidecar.js';
|
|
2
|
+
import { CompileRefusal } from './compile-refusal.js';
|
|
3
|
+
import { Expr } from './expr.js';
|
|
4
|
+
import { ownEntry } from './own-entry.js';
|
|
5
|
+
/**
|
|
6
|
+
* Every {@link InlineAgentFieldType}, in declaration order: what a tool
|
|
7
|
+
* argument's `type`, and a tool's `returns`, can name. Listed as the keys of
|
|
8
|
+
* a record over the type, so a new member does not compile until it is here.
|
|
9
|
+
*/
|
|
10
|
+
export const INLINE_AGENT_FIELD_TYPES = Object.keys({
|
|
11
|
+
string: true, number: true, integer: true, boolean: true, object: true, array: true,
|
|
12
|
+
});
|
|
13
|
+
/** Whether `type` is an {@link InlineAgentFieldType}. */
|
|
14
|
+
export function isInlineAgentFieldType(type) {
|
|
15
|
+
return INLINE_AGENT_FIELD_TYPES.includes(type);
|
|
16
|
+
}
|
|
17
|
+
/**
|
|
18
|
+
* An argument's type: a bare type is its own, an argument object's is its
|
|
19
|
+
* `type`. Anything else is passed through as it is, as the flat map's value
|
|
20
|
+
* always was, for `check` to report.
|
|
21
|
+
*/
|
|
22
|
+
export function typeOf(arg) {
|
|
23
|
+
return typeof arg === 'object' && arg !== null ? arg.type : arg;
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
* A tool's `inputs` as the flat `{ name: type }` map, or `undefined` when it has
|
|
27
|
+
* none. `null` (from a `.flow.ts` run as JavaScript) counts as none, as it did
|
|
28
|
+
* when the writers read the flat map with `?? {}`.
|
|
29
|
+
*/
|
|
30
|
+
export function argumentTypes(inputs) {
|
|
31
|
+
return inputs == null
|
|
32
|
+
? undefined
|
|
33
|
+
: Object.fromEntries(Object.entries(inputs).map(([name, arg]) => [name, typeOf(arg)]));
|
|
34
|
+
}
|
|
35
|
+
/**
|
|
36
|
+
* An `argumentProperties` key: the JSONPath of an argument by name. Each
|
|
37
|
+
* `.`-separated segment is one bracketed key, with backslash and single quote
|
|
38
|
+
* escaped (`accountId` → `$['accountId']`, `order.total` →
|
|
39
|
+
* `$['order']['total']`), as the canvas's `toJsonPathKey` writes it
|
|
40
|
+
* (flow-workbench `agent-storage/tool-field-maps.ts`).
|
|
41
|
+
*/
|
|
42
|
+
export function jsonPathKey(name) {
|
|
43
|
+
const segment = (s) => s.replaceAll('\\', '\\\\').replaceAll("'", "\\'");
|
|
44
|
+
return `$${name.split('.').map((s) => `['${segment(s)}']`).join('')}`;
|
|
45
|
+
}
|
|
46
|
+
/**
|
|
47
|
+
* The keys of a JSONPath of bracketed, single-quoted keys, the inverse of
|
|
48
|
+
* {@link jsonPathKey} (`$['order']['total']` → `['order', 'total']`):
|
|
49
|
+
* an `argumentProperties` key, or an `argument` entry's `argumentPath`.
|
|
50
|
+
* `undefined` for any other spelling.
|
|
51
|
+
*/
|
|
52
|
+
export function jsonPathSegments(path) {
|
|
53
|
+
const segment = /\['((?:[^'\\]|\\.)*)'\]/g;
|
|
54
|
+
if (!/^\$(?:\['(?:[^'\\]|\\.)*'\])+$/.test(path))
|
|
55
|
+
return undefined;
|
|
56
|
+
return Array.from(path.matchAll(segment), (m) => m[1].replace(/\\(.)/g, '$1'));
|
|
57
|
+
}
|
|
58
|
+
/**
|
|
59
|
+
* An argument's Prompt: the text the canvas writes as the argument's
|
|
60
|
+
* `inputSchema` description, or `undefined` for one with no prompt or an empty
|
|
61
|
+
* or whitespace-only one, which the canvas does not save (`check` warns,
|
|
62
|
+
* `FLOW_AGENT_TOOL_ARGUMENT_EMPTY_PROMPT`).
|
|
63
|
+
*/
|
|
64
|
+
export function promptOf(arg) {
|
|
65
|
+
return typeof arg === 'object' && arg !== null && 'prompt' in arg && typeof arg.prompt === 'string'
|
|
66
|
+
&& arg.prompt.trim() !== '' ? arg.prompt : undefined;
|
|
67
|
+
}
|
|
68
|
+
/**
|
|
69
|
+
* The agent input each Variable argument binds, by argument name: its flat name
|
|
70
|
+
* and binding, from the `variable` rendered as an agent's `inputs` value is.
|
|
71
|
+
* Only a single reference binds one; a literal or a composite expression is
|
|
72
|
+
* left out, which compile never writes: {@link toolArgumentRefusal} refuses it
|
|
73
|
+
* (`FLOW_AGENT_TOOL_ARGUMENT_COMPOSITE`).
|
|
74
|
+
*/
|
|
75
|
+
export function toolVariableRefs(inputs, render) {
|
|
76
|
+
const out = {};
|
|
77
|
+
for (const [name, arg] of Object.entries(inputs ?? {})) {
|
|
78
|
+
if (typeof arg !== 'object' || arg === null || !('variable' in arg))
|
|
79
|
+
continue;
|
|
80
|
+
const ref = agentInputRef(render(arg.variable));
|
|
81
|
+
if (ref !== undefined)
|
|
82
|
+
out[name] = ref;
|
|
83
|
+
}
|
|
84
|
+
return out;
|
|
85
|
+
}
|
|
86
|
+
/**
|
|
87
|
+
* A tool's `argumentProperties`: a `static` entry for each argument with a Fixed
|
|
88
|
+
* `value`, written with the JSON type it was authored with, objects and arrays
|
|
89
|
+
* included, and an `argument` entry for each Variable in `variables` (from
|
|
90
|
+
* {@link toolVariableRefs}), whose path is the agent input's flat name
|
|
91
|
+
* (`$['topic']`, `$['node1__output__y']`), as the canvas writes it under its
|
|
92
|
+
* default flat encoding. A Prompt has no entry (its text is the schema
|
|
93
|
+
* description), nor does a bare type, which the model fills.
|
|
94
|
+
*/
|
|
95
|
+
export function toolArgumentProperties(inputs, variables = {}) {
|
|
96
|
+
const out = {};
|
|
97
|
+
for (const [name, arg] of Object.entries(inputs ?? {})) {
|
|
98
|
+
const variable = ownEntry(variables, name);
|
|
99
|
+
if (typeof arg === 'object' && arg !== null && 'value' in arg) {
|
|
100
|
+
out[jsonPathKey(name)] = { variant: 'static', value: arg.value, isSensitive: false };
|
|
101
|
+
}
|
|
102
|
+
else if (variable !== undefined) {
|
|
103
|
+
out[jsonPathKey(name)] = { variant: 'argument', argumentPath: jsonPathKey(variable.flatName), isSensitive: false };
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
return out;
|
|
107
|
+
}
|
|
108
|
+
/** The keys an argument object names its one source by. */
|
|
109
|
+
export const TOOL_ARGUMENT_SOURCES = ['prompt', 'value', 'variable'];
|
|
110
|
+
/** `js`, cut to a length a message can quote. */
|
|
111
|
+
const shortJs = (js) => (js.length > 60 ? `${js.slice(0, 60)}…` : js);
|
|
112
|
+
/**
|
|
113
|
+
* The first SDK expression anywhere in a fixed value: the value itself, or
|
|
114
|
+
* inside an array or object in it (`FLOW_AGENT_TOOL_ARGUMENT_EXPRESSION`).
|
|
115
|
+
*/
|
|
116
|
+
export function exprIn(value) {
|
|
117
|
+
if (value instanceof Expr)
|
|
118
|
+
return value;
|
|
119
|
+
if (typeof value !== 'object' || value === null)
|
|
120
|
+
return undefined;
|
|
121
|
+
for (const item of Object.values(value)) {
|
|
122
|
+
const found = exprIn(item);
|
|
123
|
+
if (found !== undefined)
|
|
124
|
+
return found;
|
|
125
|
+
}
|
|
126
|
+
return undefined;
|
|
127
|
+
}
|
|
128
|
+
/**
|
|
129
|
+
* Refuse a process tool argument that compile cannot write as authored
|
|
130
|
+
* (docs/INLINE_AGENT_TOOL_ARGUMENTS_DESIGN.md, "What `check` reports"). The
|
|
131
|
+
* storage schema takes each of these (except a type outside the six, which it
|
|
132
|
+
* refuses), so the platform would load a tool other than the one authored:
|
|
133
|
+
*
|
|
134
|
+
* * `FLOW_AGENT_TOOL_ARGUMENT_SOURCE`: an argument object with no valid
|
|
135
|
+
* `type`, or with other than exactly one of `prompt`, `value` and `variable`.
|
|
136
|
+
* `{ type }` alone counts: a bare type is how to name none.
|
|
137
|
+
* * `FLOW_AGENT_TOOL_ARGUMENT_COMPOSITE`: a `variable` that is not a single
|
|
138
|
+
* reference, so has no agent input to bind; the model would fill it.
|
|
139
|
+
* * `FLOW_AGENT_TOOL_ARGUMENT_EXPRESSION`: an SDK expression anywhere in a
|
|
140
|
+
* fixed `value`, `lit()` included, which would be written as the SDK's own
|
|
141
|
+
* object rather than evaluated.
|
|
142
|
+
*
|
|
143
|
+
* Returned, not thrown, for the caller to hold: the agent's serialize judges
|
|
144
|
+
* the rest of the agent first, and keeps a refused argument out of the agent's
|
|
145
|
+
* input plan. `render` renders a value as the agent's `inputs` are rendered;
|
|
146
|
+
* `who` and `tool` name the agent kind and the tool in the message
|
|
147
|
+
* (`'Inline agent'`, `'process' tool "Create Account"`).
|
|
148
|
+
*/
|
|
149
|
+
export function toolArgumentRefusal(who, step, tool, name, arg, render) {
|
|
150
|
+
if (typeof arg !== 'object' || arg === null)
|
|
151
|
+
return undefined;
|
|
152
|
+
const a = arg;
|
|
153
|
+
const where = `${who} step "${step}"'s ${tool} gives its argument \`${name}\``;
|
|
154
|
+
const sources = TOOL_ARGUMENT_SOURCES.filter((k) => k in a);
|
|
155
|
+
if (!isInlineAgentFieldType(a.type)) {
|
|
156
|
+
return new CompileRefusal('FLOW_AGENT_TOOL_ARGUMENT_SOURCE', `${where} ${a.type === undefined ? 'no `type`' : `the type ${JSON.stringify(a.type)}`}. An argument object `
|
|
157
|
+
+ `names its type beside its source — ${INLINE_AGENT_FIELD_TYPES.join(', ')} — and compile writes it as the `
|
|
158
|
+
+ `argument's \`inputSchema\` type, which is what the model reads; the platform's resource schema takes no other.`, `${name}: { type: 'string', ${sources[0] ?? 'prompt'}: … }`);
|
|
159
|
+
}
|
|
160
|
+
if (sources.length !== 1) {
|
|
161
|
+
return new CompileRefusal('FLOW_AGENT_TOOL_ARGUMENT_SOURCE', `${where} ${sources.length === 0 ? 'no source' : `${sources.length} sources (${sources.map((k) => `\`${k}\``).join(', ')})`}. `
|
|
162
|
+
+ `An argument object takes exactly one of \`prompt\` (the model fills it, reading the prompt), \`value\` `
|
|
163
|
+
+ `(a fixed value) and \`variable\` (a flow value, read at run time), as the canvas's form offers one per `
|
|
164
|
+
+ `argument. ${sources.length === 0
|
|
165
|
+
? 'To leave an argument to the model with nothing but its name and type, write the bare type.'
|
|
166
|
+
: 'With more, compile would write some of each — a `value` over a `variable` whose agent input nothing '
|
|
167
|
+
+ 'reads, a `prompt` beside either — rather than the one source you meant, so keep that one.'}`, sources.length === 0 ? `${name}: '${a.type}'` : `${name}: { type: '${a.type}', ${sources[0]}: … }`);
|
|
168
|
+
}
|
|
169
|
+
if (sources[0] === 'value') {
|
|
170
|
+
const e = exprIn(a.value);
|
|
171
|
+
if (e === undefined)
|
|
172
|
+
return undefined;
|
|
173
|
+
const nested = e !== a.value;
|
|
174
|
+
return new CompileRefusal('FLOW_AGENT_TOOL_ARGUMENT_EXPRESSION', `${where} a fixed \`value\` that ${nested ? 'holds' : 'is'} ${e.literal
|
|
175
|
+
? `the literal expression \`lit(${JSON.stringify(e.value) ?? String(e.value)})\``
|
|
176
|
+
: `the expression \`${shortJs(e.js)}\``}. A fixed value is a plain JSON constant, written to `
|
|
177
|
+
+ `\`resource.json\` as it stands: an SDK expression there is not evaluated, and the tool would be called `
|
|
178
|
+
+ `with the SDK's own object. ${e.literal
|
|
179
|
+
? 'Write the constant itself.'
|
|
180
|
+
: 'Bind a flow value with `variable`, which reads it at run time.'}`, e.literal
|
|
181
|
+
? `${JSON.stringify(e.value) ?? '…'} in place of lit(${JSON.stringify(e.value) ?? '…'})`
|
|
182
|
+
: nested
|
|
183
|
+
? `build the ${a.type} in a script step first, then bind the step's output: `
|
|
184
|
+
+ `.step('${name}Value', script({ code: 'return …;' })) … ${name}: { type: '${a.type}', variable: out('${name}Value') }`
|
|
185
|
+
: `${name}: { type: '${a.type}', variable: … }`);
|
|
186
|
+
}
|
|
187
|
+
if (sources[0] === 'variable') {
|
|
188
|
+
// INLINE_AGENT_COMPOSITE_INPUT's rule, for a tool: an argument is bound to
|
|
189
|
+
// the agent input named after ONE reference path, and an expression over
|
|
190
|
+
// zero or several, or a constant, has none.
|
|
191
|
+
const rendered = render(a.variable);
|
|
192
|
+
const b = classifyAgentInput(rendered);
|
|
193
|
+
if (b.kind === 'expression') {
|
|
194
|
+
return new CompileRefusal('FLOW_AGENT_TOOL_ARGUMENT_COMPOSITE', `${where} the \`variable\` \`${shortJs(b.binding.slice('=js:'.length))}\`, a computed expression. `
|
|
195
|
+
+ `The platform binds a Variable argument to an agent input named after the REFERENCE PATH it reads `
|
|
196
|
+
+ `(\`$vars.a.output.b\` → \`a__output__b\`), and a computed expression is not one reference, so it `
|
|
197
|
+
+ `gets no input: the argument would be left to the model to fill.`, `compute it in a script step first, then bind the step's output: `
|
|
198
|
+
+ `.step('${name}Value', script({ code: 'return …;' })) … ${name}: { type: '${a.type}', variable: out('${name}Value') }`);
|
|
199
|
+
}
|
|
200
|
+
if (b.kind === 'literal') {
|
|
201
|
+
return new CompileRefusal('FLOW_AGENT_TOOL_ARGUMENT_COMPOSITE', `${where} the \`variable\` ${JSON.stringify(rendered) ?? String(rendered)}, a constant. A Variable reads a `
|
|
202
|
+
+ `flow value at run time, through an agent input named after its reference path, and a constant has no `
|
|
203
|
+
+ `path: the argument would be left to the model to fill. A constant is a fixed \`value\`.`, `${name}: { type: '${a.type}', value: ${JSON.stringify(rendered) ?? '…'} }`);
|
|
204
|
+
}
|
|
205
|
+
}
|
|
206
|
+
return undefined;
|
|
207
|
+
}
|
package/dist/decompile.js
CHANGED
|
@@ -112,6 +112,8 @@ let runAbsorbed = new Map();
|
|
|
112
112
|
* to tell a derived directory from one the file chose.
|
|
113
113
|
*/
|
|
114
114
|
let runFlowId = 'flow';
|
|
115
|
+
/** The ids of the flow's variables (`variables.globals`), for `declaresRoot`. */
|
|
116
|
+
let runGlobalIds = new Set();
|
|
115
117
|
/** `DecompileOptions.readSidecar` for the current run. */
|
|
116
118
|
let runReadSidecar;
|
|
117
119
|
/**
|
|
@@ -840,6 +842,7 @@ function liftRegistered(node, impl = registeredImpl(node), graph) {
|
|
|
840
842
|
outPorts: () => (graph?.outEdges(node.id) ?? []).map((e) => e.sourcePort),
|
|
841
843
|
convergedFanOut: () => graph?.convergedFanOut(node.id) === true,
|
|
842
844
|
reads: () => graph?.readsOf(node.id) ?? [],
|
|
845
|
+
declaresRoot: (root) => graph?.byId.has(root) === true || runGlobalIds.has(root),
|
|
843
846
|
};
|
|
844
847
|
const spec = impl.deserialize(node, ctx);
|
|
845
848
|
return spec === undefined ? undefined : { impl, spec };
|
|
@@ -3039,6 +3042,9 @@ export function decompile(flow, options = {}) {
|
|
|
3039
3042
|
runRawManifests = [];
|
|
3040
3043
|
runAbsorbed = new Map();
|
|
3041
3044
|
runFlowId = slugId(flow);
|
|
3045
|
+
runGlobalIds = new Set((Array.isArray(flow.variables?.globals) ? flow.variables.globals : [])
|
|
3046
|
+
.map((g) => g?.id)
|
|
3047
|
+
.filter((id) => typeof id === 'string'));
|
|
3042
3048
|
for (const d of (flow.definitions ?? [])) {
|
|
3043
3049
|
if (typeof d?.nodeType !== 'string')
|
|
3044
3050
|
continue;
|
package/dist/flow-node-type.d.ts
CHANGED
|
@@ -347,6 +347,13 @@ export interface FlowDeserializeContext {
|
|
|
347
347
|
convergedFanOut(): boolean;
|
|
348
348
|
/** The tails the node's scope reads off `$vars.<nodeId>`, e.g. `.output.body.current`, `.output.body.items[]` for an indexed read. */
|
|
349
349
|
reads(): readonly string[];
|
|
350
|
+
/**
|
|
351
|
+
* Whether `$vars.<root>` names something the flow has: a node of this node's
|
|
352
|
+
* scope (the trigger included) or a flow variable.
|
|
353
|
+
*
|
|
354
|
+
* @internal The inline agent's lift checks a decoded flat name with it.
|
|
355
|
+
*/
|
|
356
|
+
declaresRoot(root: string): boolean;
|
|
350
357
|
}
|
|
351
358
|
/** What `print` may ask of the decompiler. Every method returns source text. */
|
|
352
359
|
export interface FlowPrintContext {
|
|
@@ -1,11 +1,3 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* The agents family's rules: what is decidable from a call to
|
|
3
|
-
* `conversationalAgent()`, `voiceAgent()`, `createOutgoingCall()`, `endCall()`
|
|
4
|
-
* or `inlineAgent()` — the turn wiring, the call's numbers, the `callContext`
|
|
5
|
-
* the voice steps share, and an inline agent's prompts, inputs, guardrails and
|
|
6
|
-
* resources. Moved from check.ts in Phase 4 of
|
|
7
|
-
* docs/NODE_TYPE_ARCHITECTURE_DESIGN.md; codes and messages unchanged.
|
|
8
|
-
*/
|
|
9
1
|
import type { DiagnosticCatalog } from '../../../core/nodes/family.js';
|
|
10
2
|
import type { OutputPathRead } from '../../../core/nodes/node-type.js';
|
|
11
3
|
import type { FlowCheckContext } from '../../../flow-node-type.js';
|
|
@@ -66,7 +58,8 @@ export declare function jsonTextDirective(text: string, returnKeys?: readonly st
|
|
|
66
58
|
* - `INLINE_AGENT_UNREFERENCED_INPUT` — flow-v1 derives the deployed input list by
|
|
67
59
|
* scanning the PROMPTS for `$vars.*` references and only falls back to the
|
|
68
60
|
* authored `agentInputVariables` when that pre-pass did not run. So a declared
|
|
69
|
-
* input the prompts never mention
|
|
61
|
+
* input the prompts never mention, and no tool argument binds as its
|
|
62
|
+
* `variable`, is pruned deployed while arriving locally: a
|
|
70
63
|
* disagreement between rungs and the platform, which is the one class that has to
|
|
71
64
|
* be said out loud rather than left to a run.
|
|
72
65
|
* - `INLINE_AGENT_PROMPT_JSON_TEXT` — the platform returns `returns` as a typed
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { agentInputRef } from '../../../core/agent-sidecar.js';
|
|
1
2
|
import { Expr } from '../../../core/expr.js';
|
|
2
3
|
import { GUID_RE } from '../../../core/binding-messages.js';
|
|
3
4
|
import { promptPlaceholders } from '../../../core/agent-sidecar.js';
|
|
@@ -6,6 +7,8 @@ import { nearestName } from '../../../core/edit-distance.js';
|
|
|
6
7
|
import { FLAT_SEP, flatNameSegmentsOf } from '../../../core/expr.js';
|
|
7
8
|
import { FORM_FIELD_TYPES, formFieldOptionsProblem, formFieldOptionsWhy, formFieldSettingProblems, formFieldTypeHint, formFieldTypeWhy, validFormFieldTypesText, } from '../../../core/form-field-type.js';
|
|
8
9
|
import { ownEntry } from '../../../core/own-entry.js';
|
|
10
|
+
import { TOOL_ARGUMENT_SOURCES, exprIn, isInlineAgentFieldType, toolVariableRefs } from '../../../core/tool-argument.js';
|
|
11
|
+
import { isProcessToolKind } from './resources.js';
|
|
9
12
|
export const AGENT_DIAGNOSTICS = {
|
|
10
13
|
FLOW_AGENT_CONTEXT_NO_FOLDER_PATH: { severity: 'warning', summary: 'a context index with no folderPath' },
|
|
11
14
|
FLOW_AGENT_CONTEXT_NO_ID: { severity: 'error', summary: 'a context index whose id is not a GUID' },
|
|
@@ -53,6 +56,8 @@ export const AGENT_DIAGNOSTICS = {
|
|
|
53
56
|
INLINE_AGENT_SCAFFOLD_MODEL: { severity: 'warning', summary: "an inline agent on the platform scaffold's model" },
|
|
54
57
|
INLINE_AGENT_SOURCE_NOT_GUID: { severity: 'error', summary: 'an inline agent source that is not a uuid' },
|
|
55
58
|
FLOW_AGENT_TOOL_A2A_INCOMPLETE: { severity: 'error', summary: 'an a2a tool missing its name, slug or key' },
|
|
59
|
+
FLOW_AGENT_TOOL_ARGUMENT_EMPTY_PROMPT: { severity: 'warning', summary: 'a process tool argument with an empty prompt' },
|
|
60
|
+
FLOW_AGENT_TOOL_ARGUMENT_TYPE: { severity: 'warning', summary: "a process tool argument's fixed value of another type than its own" },
|
|
56
61
|
FLOW_AGENT_TOOL_CLIENTSIDE_NO_NAME: { severity: 'error', summary: 'a client-side tool with no name' },
|
|
57
62
|
FLOW_AGENT_TOOL_CLIENTSIDE_SCHEMA_TWICE: { severity: 'error', summary: 'a client-side tool given both inputs and inputSchema (or returns and outputSchema)' },
|
|
58
63
|
FLOW_AGENT_TOOL_CONNECTOR_NO_CONNECTION: { severity: 'error', summary: 'a connector tool with no connection or folder' },
|
|
@@ -295,6 +300,81 @@ export function jsonTextDirective(text, returnKeys) {
|
|
|
295
300
|
}
|
|
296
301
|
return undefined;
|
|
297
302
|
}
|
|
303
|
+
// ─── a process tool's argument sources ───────────────────────────────────────────
|
|
304
|
+
/**
|
|
305
|
+
* A value as serialize renders it, for `agentInputRef`. Without the rename
|
|
306
|
+
* map a reused subflow applies, which renames a reference but never makes one
|
|
307
|
+
* of an expression or the reverse.
|
|
308
|
+
*/
|
|
309
|
+
const rendered = (v) => (v instanceof Expr ? (v.literal ? v.value : `=js:${v.js}`) : v);
|
|
310
|
+
/**
|
|
311
|
+
* Whether a fixed `value` has the JSON type its argument declares; `null` has
|
|
312
|
+
* none of them, and neither has `NaN` or an infinity, which JSON writes as `null`.
|
|
313
|
+
*/
|
|
314
|
+
function hasFieldType(value, type) {
|
|
315
|
+
switch (type) {
|
|
316
|
+
case 'string': return typeof value === 'string';
|
|
317
|
+
case 'number': return Number.isFinite(value);
|
|
318
|
+
case 'integer': return Number.isInteger(value);
|
|
319
|
+
case 'boolean': return typeof value === 'boolean';
|
|
320
|
+
case 'array': return Array.isArray(value);
|
|
321
|
+
case 'object': return typeof value === 'object' && value !== null && !Array.isArray(value)
|
|
322
|
+
&& (Object.getPrototypeOf(value) === Object.prototype || Object.getPrototypeOf(value) === null);
|
|
323
|
+
}
|
|
324
|
+
}
|
|
325
|
+
/**
|
|
326
|
+
* Whether `value` is the canvas's text for a scalar of `type`: the canvas saves
|
|
327
|
+
* a Fixed number or boolean as text (D2), so `'42'` and `'true'` are what a
|
|
328
|
+
* canvas-saved flow decompiles to. Only the exact text `String` gives the value
|
|
329
|
+
* counts, so `'1e3'` and `' 42'` are not.
|
|
330
|
+
*/
|
|
331
|
+
function isCanvasText(value, type) {
|
|
332
|
+
if (typeof value !== 'string' || (type !== 'number' && type !== 'integer' && type !== 'boolean'))
|
|
333
|
+
return false;
|
|
334
|
+
let parsed;
|
|
335
|
+
try {
|
|
336
|
+
parsed = JSON.parse(value);
|
|
337
|
+
}
|
|
338
|
+
catch {
|
|
339
|
+
return false;
|
|
340
|
+
}
|
|
341
|
+
return hasFieldType(parsed, type) && String(parsed) === value;
|
|
342
|
+
}
|
|
343
|
+
/**
|
|
344
|
+
* A process tool's argument sources (docs/INLINE_AGENT_TOOL_ARGUMENTS_DESIGN.md,
|
|
345
|
+
* "What `check` reports"): the two that compile writes as authored, and so
|
|
346
|
+
* only warns of. One it cannot write (no valid type, not exactly one source, a
|
|
347
|
+
* `variable` that is no single reference, an expression in a fixed `value`) is
|
|
348
|
+
* refused by the writer, `toolArgumentRefusal`, and reported from there in
|
|
349
|
+
* collect mode, so it is skipped here. A bare type is the model's to fill.
|
|
350
|
+
*/
|
|
351
|
+
function checkToolArguments(tool, args, ctx, who) {
|
|
352
|
+
for (const [name, arg] of Object.entries(args ?? {})) {
|
|
353
|
+
if (typeof arg !== 'object' || arg === null)
|
|
354
|
+
continue;
|
|
355
|
+
const a = arg;
|
|
356
|
+
const sources = TOOL_ARGUMENT_SOURCES.filter((k) => k in a);
|
|
357
|
+
if (!isInlineAgentFieldType(a.type) || sources.length !== 1)
|
|
358
|
+
continue;
|
|
359
|
+
const where = `${who} step "${ctx.step}"'s ${tool} gives its argument \`${name}\``;
|
|
360
|
+
if (sources[0] === 'prompt' && (typeof a.prompt !== 'string' || a.prompt.trim() === '')) {
|
|
361
|
+
ctx.report('FLOW_AGENT_TOOL_ARGUMENT_EMPTY_PROMPT', `${where} the prompt ${JSON.stringify(a.prompt) ?? 'undefined'}, which says nothing. The canvas does not save `
|
|
362
|
+
+ `an empty prompt and compile writes no description, so the model fills the argument from its name and `
|
|
363
|
+
+ `type alone, as for a bare type. Say what the model should put there, or write the bare type.`);
|
|
364
|
+
}
|
|
365
|
+
if (sources[0] === 'value' && exprIn(a.value) === undefined && !hasFieldType(a.value, a.type)
|
|
366
|
+
&& !isCanvasText(a.value, a.type)) {
|
|
367
|
+
// `JSON.stringify` prints `NaN` and an infinity as `null`, so they are shown as written.
|
|
368
|
+
const nonFinite = typeof a.value === 'number' && !Number.isFinite(a.value);
|
|
369
|
+
const shown = nonFinite ? String(a.value) : JSON.stringify(a.value) ?? String(a.value);
|
|
370
|
+
ctx.report('FLOW_AGENT_TOOL_ARGUMENT_TYPE', `${where} the type '${String(a.type)}' and the fixed \`value\` ${shown}, `
|
|
371
|
+
+ (nonFinite
|
|
372
|
+
? 'which JSON cannot hold: `resource.json` writes it as null, so the tool is called with null.'
|
|
373
|
+
: 'which is not of that type. Compile writes a fixed value as authored, so the tool is called with it '
|
|
374
|
+
+ 'whatever its schema declares.'));
|
|
375
|
+
}
|
|
376
|
+
}
|
|
377
|
+
}
|
|
298
378
|
/**
|
|
299
379
|
* Check an `inlineAgent(...)` call.
|
|
300
380
|
*
|
|
@@ -312,7 +392,8 @@ export function jsonTextDirective(text, returnKeys) {
|
|
|
312
392
|
* - `INLINE_AGENT_UNREFERENCED_INPUT` — flow-v1 derives the deployed input list by
|
|
313
393
|
* scanning the PROMPTS for `$vars.*` references and only falls back to the
|
|
314
394
|
* authored `agentInputVariables` when that pre-pass did not run. So a declared
|
|
315
|
-
* input the prompts never mention
|
|
395
|
+
* input the prompts never mention, and no tool argument binds as its
|
|
396
|
+
* `variable`, is pruned deployed while arriving locally: a
|
|
316
397
|
* disagreement between rungs and the platform, which is the one class that has to
|
|
317
398
|
* be said out loud rather than left to a run.
|
|
318
399
|
* - `INLINE_AGENT_PROMPT_JSON_TEXT` — the platform returns `returns` as a typed
|
|
@@ -422,12 +503,26 @@ export function checkInlineAgent(inputs, ctx) {
|
|
|
422
503
|
// searched, because flow-v1's pre-pass scans both.
|
|
423
504
|
const placeholders = promptPlaceholders(inputs ?? {});
|
|
424
505
|
const declaredInputs = Object.keys(inputs?.inputs ?? {});
|
|
425
|
-
//
|
|
426
|
-
//
|
|
427
|
-
|
|
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.
|
|
509
|
+
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));
|
|
514
|
+
const boundForTool = (k) => {
|
|
515
|
+
const ref = agentInputRef(rendered(inputs?.inputs?.[k]));
|
|
516
|
+
return ref !== undefined && toolBound.has(ref.flatName);
|
|
517
|
+
};
|
|
518
|
+
// Direction 1: a declared input no prompt references and no tool argument
|
|
519
|
+
// binds. The platform may prune it, in which case the agent receives nothing
|
|
520
|
+
// and the authored list sits unused.
|
|
521
|
+
const unreferenced = declaredInputs.filter((k) => !placeholders.includes(k) && !boundForTool(k));
|
|
428
522
|
if (declaredInputs.length && unreferenced.length === declaredInputs.length) {
|
|
429
523
|
warn('INLINE_AGENT_UNREFERENCED_INPUT', `Inline agent step "${step}" declares input(s) ${unreferenced.map((u) => `\`${u}\``).join(', ')} that `
|
|
430
|
-
+ `neither prompt references as \`{{input.<name>}}\`
|
|
524
|
+
+ `neither prompt references as \`{{input.<name>}}\` and no tool argument binds as its \`variable\` — so `
|
|
525
|
+
+ `NONE of them is referenced. Deployed, the `
|
|
431
526
|
+ `authored list is not necessarily what the platform sends: flow-v1's `
|
|
432
527
|
+ `\`preDeriveAgentInputDefinitions\` pre-pass builds the input list by scanning the node's prompts for `
|
|
433
528
|
+ `variable references, merges what it finds with the authored list, and DROPS an entry no reference `
|
|
@@ -438,7 +533,8 @@ export function checkInlineAgent(inputs, ctx) {
|
|
|
438
533
|
}
|
|
439
534
|
else if (unreferenced.length) {
|
|
440
535
|
warn('INLINE_AGENT_UNREFERENCED_INPUT', `Inline agent step "${step}" declares input(s) ${unreferenced.map((u) => `\`${u}\``).join(', ')} that `
|
|
441
|
-
+ `neither prompt references as \`{{input.<name>}}
|
|
536
|
+
+ `neither prompt references as \`{{input.<name>}}\` and no tool argument binds as its \`variable\`. `
|
|
537
|
+
+ `The platform may prune an unreferenced input, so `
|
|
442
538
|
+ `it is not reliably sent — and an input the prompts never mention is one the agent cannot use anyway.`);
|
|
443
539
|
}
|
|
444
540
|
// Direction 2: a placeholder naming an input that does not exist. The compiler
|
|
@@ -649,8 +745,7 @@ export function checkAgentResources(inputs, ctx, who) {
|
|
|
649
745
|
+ `carries as both its label and \`inputDefaults.name\`.`);
|
|
650
746
|
}
|
|
651
747
|
}
|
|
652
|
-
else if (kind
|
|
653
|
-
|| kind === 'maestro' || kind === 'function') {
|
|
748
|
+
else if (isProcessToolKind(kind)) {
|
|
654
749
|
const p = t;
|
|
655
750
|
if (blank(p.key) || !GUID_RE.test(String(p.key).trim())) {
|
|
656
751
|
at('FLOW_AGENT_TOOL_KEY_NOT_GUID', `${who} step "${step}"'s '${String(kind)}' tool has \`key\` ${JSON.stringify(p.key)}, which is not a uuid. `
|
|
@@ -661,6 +756,7 @@ export function checkAgentResources(inputs, ctx, who) {
|
|
|
661
756
|
at('FLOW_AGENT_TOOL_NO_RESOURCE_ID', `${who} step "${step}"'s '${String(kind)}' tool needs both \`name\` and \`folderPath\` — they form the `
|
|
662
757
|
+ `binding's resourceKey ("<folderPath>.<name>"), which is how the deployed flow finds the resource.`);
|
|
663
758
|
}
|
|
759
|
+
checkToolArguments(`'${String(kind)}' tool "${String(p.name ?? '')}"`, p.inputs, ctx, who);
|
|
664
760
|
}
|
|
665
761
|
else if (kind === 'mcp') {
|
|
666
762
|
const m = t;
|
|
@@ -12,12 +12,22 @@ interface FlowNode {
|
|
|
12
12
|
}
|
|
13
13
|
/** Where the agent's own `inputs` go in the option list: the printer writes them, as expressions. */
|
|
14
14
|
declare const INPUT_ROWS: unique symbol;
|
|
15
|
+
/** Source that holds an `Expr` (a tool argument's Variable), written once the printer's context is known. */
|
|
16
|
+
export type Printed = (print: FlowPrintContext) => string;
|
|
15
17
|
/** The lifted agent: its options in factory order, as source, and its input rows. */
|
|
16
18
|
export interface LiftedInlineAgent {
|
|
17
19
|
kind: 'inlineAgent';
|
|
18
20
|
inputs: {
|
|
19
21
|
inputRows: Array<[string, Expr]>;
|
|
20
|
-
options: Array<[string, string | undefined | typeof INPUT_ROWS]>;
|
|
22
|
+
options: Array<[string, string | Printed | undefined | typeof INPUT_ROWS]>;
|
|
23
|
+
};
|
|
24
|
+
}
|
|
25
|
+
/** An agent input a tool's Variable binds: its id in the file, and the input compile derives from its binding. */
|
|
26
|
+
interface ToolVariable {
|
|
27
|
+
id: string;
|
|
28
|
+
ref: {
|
|
29
|
+
flatName: string;
|
|
30
|
+
binding: string;
|
|
21
31
|
};
|
|
22
32
|
}
|
|
23
33
|
/**
|
|
@@ -43,12 +53,21 @@ export declare function liftInlineAgent(node: FlowNode, ctx: FlowDeserializeCont
|
|
|
43
53
|
* the voice and conversational agents', which take the same three
|
|
44
54
|
* resources but no memory. With `withMemory` false a `memory` edge is left
|
|
45
55
|
* unclaimed, so decompile reports it as an edge the source cannot spell.
|
|
56
|
+
* `agentInputs` are the agent's inputs in the file's order, which a process
|
|
57
|
+
* tool's Variable argument resolves its `argumentPath` through;
|
|
58
|
+
* `toolVariables` are the inputs those Variables bind, in tool and argument
|
|
59
|
+
* order. A Variable's reference is an `Expr`, so `tools` is then printed once
|
|
60
|
+
* the print context is known.
|
|
46
61
|
*/
|
|
47
|
-
export declare function liftAgentResources(node: FlowNode, ctx: FlowDeserializeContext, withMemory: boolean
|
|
62
|
+
export declare function liftAgentResources(node: FlowNode, ctx: FlowDeserializeContext, withMemory: boolean, agentInputs?: ReadonlyArray<{
|
|
63
|
+
flatName: string;
|
|
64
|
+
binding: string;
|
|
65
|
+
}>): {
|
|
48
66
|
context: string | undefined;
|
|
49
|
-
tools: string | undefined;
|
|
67
|
+
tools: string | Printed | undefined;
|
|
50
68
|
escalation: string | undefined;
|
|
51
69
|
memory: string | undefined;
|
|
70
|
+
toolVariables: ToolVariable[];
|
|
52
71
|
};
|
|
53
72
|
export declare function printInlineAgent(spec: LiftedInlineAgent, ctx: FlowPrintContext): {
|
|
54
73
|
factory: string;
|