@uipath/maestro-builder-sdk 6.117.1 → 6.117.3
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/core/agent-sidecar.d.ts +36 -2
- package/dist/core/agent-sidecar.js +35 -5
- package/dist/core/refusals.d.ts +1 -0
- package/dist/core/refusals.js +1 -0
- package/dist/merge-cli.js +3 -0
- package/dist/merge-embedded-agent.d.ts +46 -10
- package/dist/merge-embedded-agent.js +180 -25
- package/dist/merge-sidecars.d.ts +8 -0
- package/dist/merge-sidecars.js +24 -29
- package/dist/merge.d.ts +9 -4
- package/dist/merge.js +27 -19
- package/dist/nodes/agent/flow/builtin-tool-lift.d.ts +2 -0
- package/dist/nodes/agent/flow/builtin-tool-lift.js +3 -0
- package/dist/nodes/agent/flow/check.d.ts +9 -0
- package/dist/nodes/agent/flow/check.js +22 -6
- package/dist/nodes/agent/flow/inline-agent-lift.d.ts +1 -0
- package/dist/nodes/agent/flow/inline-agent-lift.js +14 -6
- package/dist/nodes/agent/flow/inline-agent.d.ts +2 -1
- package/dist/nodes/agent/flow/inline-agent.js +6 -6
- package/dist/nodes/agent/flow/node-type.js +5 -4
- package/dist/nodes/agent/flow/resources.d.ts +3 -2
- package/dist/nodes/agent/flow/resources.js +10 -4
- package/dist/registry/curated-overlay.d.ts +1 -0
- package/dist/registry/curated-overlay.js +5 -0
- package/package.json +2 -2
|
@@ -71,6 +71,20 @@ export declare function agentInputPlan(inputs: Record<string, unknown>, render:
|
|
|
71
71
|
flatName: string;
|
|
72
72
|
binding: string;
|
|
73
73
|
}>): AgentInputPlan;
|
|
74
|
+
/**
|
|
75
|
+
* Render an agent prompt for the SIDECAR — the author's placeholders rewritten to
|
|
76
|
+
* the names the runtime will actually have.
|
|
77
|
+
*
|
|
78
|
+
* The three cases mirror {@link AgentInputBinding}; the fourth (a placeholder
|
|
79
|
+
* naming nothing `inputs` declares) is left ALONE rather than deleted, exactly as
|
|
80
|
+
* the node's renderer leaves it, so it reaches the model as visible literal text
|
|
81
|
+
* and `check`'s `INLINE_AGENT_UNDECLARED_PLACEHOLDER` can name it.
|
|
82
|
+
*
|
|
83
|
+
* `contentTokens` is NOT rewritten separately — {@link promptTokens} runs over the
|
|
84
|
+
* rewritten string, so the designer's chips and the runtime's template can't
|
|
85
|
+
* disagree about a name.
|
|
86
|
+
*/
|
|
87
|
+
export declare function renderAgentSidecarPrompt(template: string, plan: Map<string, AgentInputBinding>): string;
|
|
74
88
|
/**
|
|
75
89
|
* The `agent.json` sidecar for a text CONVERSATIONAL agent.
|
|
76
90
|
*
|
|
@@ -155,16 +169,36 @@ export declare function inlineAgentJson(spec: {
|
|
|
155
169
|
/** The agent's display name (the step's label). */
|
|
156
170
|
name: string;
|
|
157
171
|
}): any;
|
|
172
|
+
/**
|
|
173
|
+
* The text of a query compile reads `{{input.<name>}}` tokens in: a string that
|
|
174
|
+
* is not an expression, or the `prompt` of a `{ prompt }` task. Undefined for
|
|
175
|
+
* every other query.
|
|
176
|
+
*/
|
|
177
|
+
export declare function queryPromptText(query: unknown): string | undefined;
|
|
158
178
|
/**
|
|
159
179
|
* The input names an agent's prompts reference as `{{input.<name>}}`, system
|
|
160
|
-
* prompt first, in order (repeats kept)
|
|
161
|
-
*
|
|
180
|
+
* prompt first, in order (repeats kept), then its context queries and its
|
|
181
|
+
* built-in tools' task prompts. Both prompts are searched, because flow-v1's
|
|
182
|
+
* pre-pass scans both. For instance `{ systemPrompt: 'Use {{input.a}}',
|
|
162
183
|
* userPrompt: '{{input.b}} and {{input.a}}' }` gives `['a', 'b', 'a']`.
|
|
163
184
|
*/
|
|
164
185
|
export declare function promptPlaceholders(s: {
|
|
165
186
|
systemPrompt?: unknown;
|
|
166
187
|
userPrompt?: unknown;
|
|
188
|
+
context?: unknown;
|
|
189
|
+
tools?: unknown;
|
|
167
190
|
}): string[];
|
|
191
|
+
/**
|
|
192
|
+
* The nested `{{input.<a>.<b>}}` tokens in the same texts `promptPlaceholders` reads, repeats dropped.
|
|
193
|
+
* A token whose head `isFlatName` accepts is left out: the head is already an input's flat name,
|
|
194
|
+
* which conversion resolves.
|
|
195
|
+
*/
|
|
196
|
+
export declare function nestedPlaceholders(s: {
|
|
197
|
+
systemPrompt?: unknown;
|
|
198
|
+
userPrompt?: unknown;
|
|
199
|
+
context?: unknown;
|
|
200
|
+
tools?: unknown;
|
|
201
|
+
}, isFlatName?: (head: string) => boolean): string[];
|
|
168
202
|
/** Which writer produced an `agent.json`: the inline, conversational or voice agent's. */
|
|
169
203
|
export type AgentSidecarDialect = 'inline' | 'conversational' | 'voice';
|
|
170
204
|
/**
|
|
@@ -83,7 +83,7 @@ export function agentInputPlan(inputs, render, toolRefs = []) {
|
|
|
83
83
|
* rewritten string, so the designer's chips and the runtime's template can't
|
|
84
84
|
* disagree about a name.
|
|
85
85
|
*/
|
|
86
|
-
function renderAgentSidecarPrompt(template, plan) {
|
|
86
|
+
export function renderAgentSidecarPrompt(template, plan) {
|
|
87
87
|
return template.replace(INPUT_PLACEHOLDER, (whole, name) => {
|
|
88
88
|
const b = plan.get(name);
|
|
89
89
|
if (!b)
|
|
@@ -284,15 +284,45 @@ export function inlineAgentJson(spec) {
|
|
|
284
284
|
}
|
|
285
285
|
/** `{{input.<name>}}` — the agent-template placeholder, in both prompt directions. */
|
|
286
286
|
const INPUT_PLACEHOLDER = /\{\{\s*input\.([A-Za-z_$][A-Za-z0-9_$]*)\s*\}\}/g;
|
|
287
|
+
/**
|
|
288
|
+
* The text of a query compile reads `{{input.<name>}}` tokens in: a string that
|
|
289
|
+
* is not an expression, or the `prompt` of a `{ prompt }` task. Undefined for
|
|
290
|
+
* every other query.
|
|
291
|
+
*/
|
|
292
|
+
export function queryPromptText(query) {
|
|
293
|
+
const text = typeof query === 'object' && query !== null && Object.keys(query).join() === 'prompt'
|
|
294
|
+
&& Object.getPrototypeOf(query) === Object.prototype ? query.prompt : query;
|
|
295
|
+
return typeof text === 'string' && !text.startsWith('=js:') ? text : undefined;
|
|
296
|
+
}
|
|
287
297
|
/**
|
|
288
298
|
* The input names an agent's prompts reference as `{{input.<name>}}`, system
|
|
289
|
-
* prompt first, in order (repeats kept)
|
|
290
|
-
*
|
|
299
|
+
* prompt first, in order (repeats kept), then its context queries and its
|
|
300
|
+
* built-in tools' task prompts. Both prompts are searched, because flow-v1's
|
|
301
|
+
* pre-pass scans both. For instance `{ systemPrompt: 'Use {{input.a}}',
|
|
291
302
|
* userPrompt: '{{input.b}} and {{input.a}}' }` gives `['a', 'b', 'a']`.
|
|
292
303
|
*/
|
|
293
304
|
export function promptPlaceholders(s) {
|
|
294
|
-
|
|
295
|
-
|
|
305
|
+
return [...placeholderText(s).matchAll(INPUT_PLACEHOLDER)].map((m) => m[1]);
|
|
306
|
+
}
|
|
307
|
+
/** `{{input.<a>.<b>}}`: a token with a selector tail, which neither compile nor lowering resolves. */
|
|
308
|
+
const NESTED_INPUT_PLACEHOLDER = /\{\{\s*input\.([A-Za-z_$][A-Za-z0-9_$]*)(?:\.[A-Za-z_$][A-Za-z0-9_$]*)+\s*\}\}/g;
|
|
309
|
+
/**
|
|
310
|
+
* The nested `{{input.<a>.<b>}}` tokens in the same texts `promptPlaceholders` reads, repeats dropped.
|
|
311
|
+
* A token whose head `isFlatName` accepts is left out: the head is already an input's flat name,
|
|
312
|
+
* which conversion resolves.
|
|
313
|
+
*/
|
|
314
|
+
export function nestedPlaceholders(s, isFlatName = () => false) {
|
|
315
|
+
const tokens = [...placeholderText(s).matchAll(NESTED_INPUT_PLACEHOLDER)]
|
|
316
|
+
.filter((m) => !isFlatName(m[1])).map((m) => m[0]);
|
|
317
|
+
return [...new Set(tokens)];
|
|
318
|
+
}
|
|
319
|
+
function placeholderText(s) {
|
|
320
|
+
const list = (v) => (v === undefined ? [] : Array.isArray(v) ? v : [v]).filter((x) => typeof x === 'object' && x !== null);
|
|
321
|
+
const queries = [
|
|
322
|
+
...list(s.context).map((c) => (typeof c.query === 'string' ? queryPromptText(c.query) : undefined)),
|
|
323
|
+
...list(s.tools).filter((t) => t.kind === 'builtin').map((t) => queryPromptText(t.query)),
|
|
324
|
+
];
|
|
325
|
+
return [String(s.systemPrompt ?? ''), String(s.userPrompt ?? ''), ...queries].join('\n');
|
|
296
326
|
}
|
|
297
327
|
/**
|
|
298
328
|
* Split an agent prompt into the `contentTokens` the designer renders it from.
|
package/dist/core/refusals.d.ts
CHANGED
|
@@ -532,6 +532,7 @@ export declare const REFUSALS: {
|
|
|
532
532
|
readonly FLOW_AGENT_TOOL_NO_RESOURCE_ID: "lint";
|
|
533
533
|
readonly FLOW_AGENT_TOOL_UNKNOWN_BUILTIN: "lowering";
|
|
534
534
|
readonly FLOW_AGENT_TOOL_UNKNOWN_KIND: "lowering";
|
|
535
|
+
readonly INLINE_AGENT_NESTED_PLACEHOLDER: "lint";
|
|
535
536
|
readonly INLINE_AGENT_UNDECLARED_PLACEHOLDER: "lint";
|
|
536
537
|
readonly INLINE_AGENT_UNREFERENCED_INPUT: "lint";
|
|
537
538
|
readonly IN_SOLUTION_KEY_MISMATCH: "lowering";
|
package/dist/core/refusals.js
CHANGED
|
@@ -608,6 +608,7 @@ export const REFUSALS = {
|
|
|
608
608
|
FLOW_AGENT_TOOL_NO_RESOURCE_ID: 'lint',
|
|
609
609
|
FLOW_AGENT_TOOL_UNKNOWN_BUILTIN: 'lowering',
|
|
610
610
|
FLOW_AGENT_TOOL_UNKNOWN_KIND: 'lowering',
|
|
611
|
+
INLINE_AGENT_NESTED_PLACEHOLDER: 'lint',
|
|
611
612
|
INLINE_AGENT_UNDECLARED_PLACEHOLDER: 'lint',
|
|
612
613
|
INLINE_AGENT_UNREFERENCED_INPUT: 'lint',
|
|
613
614
|
IN_SOLUTION_KEY_MISMATCH: 'lowering',
|
package/dist/merge-cli.js
CHANGED
|
@@ -641,6 +641,9 @@ export async function run(argv) {
|
|
|
641
641
|
writeJsonFile(target, sidecar.json);
|
|
642
642
|
console.log(`flow-merge: wrote ${sidecar.path} (carries ${sidecar.carried.join(', ')})`);
|
|
643
643
|
}
|
|
644
|
+
for (const { nodeId, inputs } of merged.onNodes) {
|
|
645
|
+
console.log(`flow-merge: carried the agent.json edit onto embedded agent "${nodeId}" (${inputs.map((k) => `inputs.${k}`).join(', ')})`);
|
|
646
|
+
}
|
|
644
647
|
const originalDir = dirOf(originalPath);
|
|
645
648
|
// A resource another `.flow` in the project still names stays (compile's prune
|
|
646
649
|
// has the same guard): a decompiled canvas agent keeps its `source` directory,
|
|
@@ -29,12 +29,14 @@
|
|
|
29
29
|
* merge), the edited node is taken, and every key the original has that the
|
|
30
30
|
* shell does not (the configuration) is put back.
|
|
31
31
|
*
|
|
32
|
-
* A prompt or model edit in the source
|
|
33
|
-
*
|
|
34
|
-
*
|
|
35
|
-
*
|
|
36
|
-
*
|
|
37
|
-
*
|
|
32
|
+
* A prompt or model edit in the source lands in the edited `<source>/agent.json`,
|
|
33
|
+
* which the embedded node shadows. For an inline agent, whose `agent.json` the
|
|
34
|
+
* SDK writes from the same options the node carries, merge writes the author's
|
|
35
|
+
* change to that file (baseline compile to edited compile) onto the node
|
|
36
|
+
* instead ({@link carryAgentJsonEdit}). What it cannot carry is reported, and
|
|
37
|
+
* `strict` refuses any merged node that would no longer carry the original's
|
|
38
|
+
* embedded configuration, apart from what the author changed, or whose prompt
|
|
39
|
+
* names an input the node no longer declares ({@link embeddedAgentFindings}).
|
|
38
40
|
*/
|
|
39
41
|
import type { MergeFinding } from './merge-roundtrip.js';
|
|
40
42
|
interface AgentNode {
|
|
@@ -62,29 +64,63 @@ export declare function isEmbeddedAgent(node: {
|
|
|
62
64
|
* @returns The original node with the edit's changed structural inputs and changed top-level keys applied.
|
|
63
65
|
*/
|
|
64
66
|
export declare function mergeEmbeddedAgentNode<N extends AgentNode>(orig: N, edited: N, base: N | undefined): N;
|
|
67
|
+
/**
|
|
68
|
+
* Write the author's `agent.json` edit onto an embedded inline agent node, which
|
|
69
|
+
* is read before its `agent.json` and so would never see it.
|
|
70
|
+
*
|
|
71
|
+
* `changed` are the paths that differ from `baseline` to `edited` (both
|
|
72
|
+
* compiled). A prompt is written as the edited file has it, with each input in
|
|
73
|
+
* the name the node declares it by ({@link inNodeInputNames}). A removed
|
|
74
|
+
* setting is not carried: the original `agent.json`, which merge keeps, still
|
|
75
|
+
* has it, and decompile would read it back from there. The schemas are
|
|
76
|
+
* not carried here: the node's descriptor arrays hold them, and merge applied
|
|
77
|
+
* that node change already. Anything else (a conversational or voice agent's
|
|
78
|
+
* file, a message list compile does not write, a setting the node has no input
|
|
79
|
+
* for) is returned as not carried.
|
|
80
|
+
*
|
|
81
|
+
* For example a baseline system prompt `"Triage"` edited to `"Triage and rank"`
|
|
82
|
+
* sets `inputs.systemPrompt` to `"Triage and rank"` and returns
|
|
83
|
+
* `{ inputs: ['systemPrompt'], notCarried: [] }`.
|
|
84
|
+
*
|
|
85
|
+
* @param node - The merged node, still embedded; its `inputs` are changed in place.
|
|
86
|
+
* @param baseline - The baseline compile's `agent.json`.
|
|
87
|
+
* @param edited - The edited compile's `agent.json`.
|
|
88
|
+
* @param changed - The paths from `baseline` to `edited`, as `mergeJson3` names them.
|
|
89
|
+
*/
|
|
90
|
+
export declare function carryAgentJsonEdit(node: {
|
|
91
|
+
type?: string;
|
|
92
|
+
inputs?: Record<string, unknown>;
|
|
93
|
+
}, baseline: unknown, edited: unknown, changed: readonly string[]): {
|
|
94
|
+
inputs: string[];
|
|
95
|
+
notCarried: string[];
|
|
96
|
+
};
|
|
65
97
|
/**
|
|
66
98
|
* What a merged embedded agent needs said, per original embedded agent (root
|
|
67
99
|
* and subflows, matched by scope and node id):
|
|
68
100
|
*
|
|
69
101
|
* - `agent-storage` (refuses): the merged node no longer carries the original's
|
|
70
102
|
* embedded configuration, so the runtime would read `<source>/agent.json`
|
|
71
|
-
* instead — a model or prompt change the author never wrote.
|
|
103
|
+
* instead — a model or prompt change the author never wrote. The inputs merge
|
|
104
|
+
* carried from the author's `agent.json` edit ({@link carryAgentJsonEdit}) are
|
|
105
|
+
* the author's, not lost.
|
|
72
106
|
* - `agent-prompt-input` (refuses): a kept prompt names `{{input.X}}` but the
|
|
73
107
|
* merged node declares no input `X` (the edit removed or renamed it), so the
|
|
74
108
|
* prompt would render the placeholder empty.
|
|
75
109
|
* - `agent-embedded-edit` (warns): the author edited the node; merge applied the
|
|
76
|
-
* node change and kept the original's prompts, model and settings
|
|
77
|
-
*
|
|
110
|
+
* node change and kept the original's prompts, model and settings apart from
|
|
111
|
+
* what it carried, so any other configuration edit did not reach this agent.
|
|
78
112
|
*
|
|
79
113
|
* @param hasBaseline - Whether the merge had a baseline. Without one, merge
|
|
80
114
|
* cannot tell the author's change from the round trip's, so the
|
|
81
115
|
* `agent-embedded-edit` warning says the node may have been edited.
|
|
82
116
|
* @param scopes - Per scope (`''` = root, otherwise the subflow key): the original, merged and edited-node-ids.
|
|
117
|
+
* @param authored - Per merged node, the inputs {@link carryAgentJsonEdit} wrote onto it. Absent when the
|
|
118
|
+
* merge read no `agent.json` sidecars (`mergeFlow`), so nothing could be carried and the warning says so.
|
|
83
119
|
*/
|
|
84
120
|
export declare function embeddedAgentFindings(hasBaseline: boolean, scopes: Array<{
|
|
85
121
|
scope: string;
|
|
86
122
|
original: AgentNode[];
|
|
87
123
|
merged: AgentNode[];
|
|
88
124
|
edited: ReadonlySet<string>;
|
|
89
|
-
}>): MergeFinding[];
|
|
125
|
+
}>, authored?: ReadonlyMap<object, readonly string[]>): MergeFinding[];
|
|
90
126
|
export {};
|
|
@@ -29,23 +29,44 @@
|
|
|
29
29
|
* merge), the edited node is taken, and every key the original has that the
|
|
30
30
|
* shell does not (the configuration) is put back.
|
|
31
31
|
*
|
|
32
|
-
* A prompt or model edit in the source
|
|
33
|
-
*
|
|
34
|
-
*
|
|
35
|
-
*
|
|
36
|
-
*
|
|
37
|
-
*
|
|
32
|
+
* A prompt or model edit in the source lands in the edited `<source>/agent.json`,
|
|
33
|
+
* which the embedded node shadows. For an inline agent, whose `agent.json` the
|
|
34
|
+
* SDK writes from the same options the node carries, merge writes the author's
|
|
35
|
+
* change to that file (baseline compile to edited compile) onto the node
|
|
36
|
+
* instead ({@link carryAgentJsonEdit}). What it cannot carry is reported, and
|
|
37
|
+
* `strict` refuses any merged node that would no longer carry the original's
|
|
38
|
+
* embedded configuration, apart from what the author changed, or whose prompt
|
|
39
|
+
* names an input the node no longer declares ({@link embeddedAgentFindings}).
|
|
38
40
|
*/
|
|
41
|
+
import { agentInputRef } from './core/agent-sidecar.js';
|
|
39
42
|
import { jsonClone } from './core/json-clone.js';
|
|
43
|
+
import { wireExprBody } from './core/wire-expr.js';
|
|
40
44
|
/**
|
|
41
45
|
* The agent node types whose configuration can live on the node or in
|
|
42
46
|
* `<source>/agent.json`, and whether a `voice` settings object on the node
|
|
43
47
|
* counts as embedded configuration (flow-schema counts it on the voice node only).
|
|
44
48
|
*/
|
|
45
49
|
const SIDECAR_AGENT_TYPES = new Map([
|
|
46
|
-
['uipath.agent.autonomous', { voiceSettings: false }],
|
|
47
|
-
['uipath.agent.conversational', { voiceSettings: false }],
|
|
48
|
-
['uipath.agent.voice', { voiceSettings: true }],
|
|
50
|
+
['uipath.agent.autonomous', { voiceSettings: false, inlineAgentJson: true }],
|
|
51
|
+
['uipath.agent.conversational', { voiceSettings: false, inlineAgentJson: false }],
|
|
52
|
+
['uipath.agent.voice', { voiceSettings: true, inlineAgentJson: false }],
|
|
53
|
+
]);
|
|
54
|
+
/**
|
|
55
|
+
* The inline agent's `agent.json` settings an embedded node carries as inputs,
|
|
56
|
+
* by setting: `inlineAgentJson` writes each from the option of the input's
|
|
57
|
+
* name, and decompile lifts the node's input to that option.
|
|
58
|
+
*/
|
|
59
|
+
const SETTINGS_ON_THE_NODE = new Map([
|
|
60
|
+
['model', 'model'],
|
|
61
|
+
['temperature', 'temperature'],
|
|
62
|
+
['maxTokens', 'maxTokenPerResponse'],
|
|
63
|
+
['maxIterations', 'maxIterations'],
|
|
64
|
+
['mode', 'mode'],
|
|
65
|
+
]);
|
|
66
|
+
/** The inline agent's `agent.json` messages an embedded node carries as inputs, by role. */
|
|
67
|
+
const PROMPTS_ON_THE_NODE = new Map([
|
|
68
|
+
['system', 'systemPrompt'],
|
|
69
|
+
['user', 'userPrompt'],
|
|
49
70
|
]);
|
|
50
71
|
/**
|
|
51
72
|
* The agent-node inputs that are flow-level and survive Studio Web's shell
|
|
@@ -177,6 +198,108 @@ export function mergeEmbeddedAgentNode(orig, edited, base) {
|
|
|
177
198
|
out.inputs = inputs;
|
|
178
199
|
return out;
|
|
179
200
|
}
|
|
201
|
+
const isDict = (v) => !!v && typeof v === 'object' && !Array.isArray(v);
|
|
202
|
+
/** An inline agent's prompts by role, when its messages are one system and one user message, as compile writes them. */
|
|
203
|
+
function promptsOf(agentJson) {
|
|
204
|
+
const messages = agentJson.messages;
|
|
205
|
+
if (!Array.isArray(messages) || messages.length !== PROMPTS_ON_THE_NODE.size)
|
|
206
|
+
return undefined;
|
|
207
|
+
const out = new Map();
|
|
208
|
+
for (const m of messages) {
|
|
209
|
+
if (!isDict(m) || typeof m.role !== 'string' || !PROMPTS_ON_THE_NODE.has(m.role) || typeof m.content !== 'string')
|
|
210
|
+
return undefined;
|
|
211
|
+
out.set(m.role, m.content);
|
|
212
|
+
}
|
|
213
|
+
return out.size === PROMPTS_ON_THE_NODE.size ? out : undefined;
|
|
214
|
+
}
|
|
215
|
+
/**
|
|
216
|
+
* A prompt compile wrote, in the input names an embedded node declares. Compile
|
|
217
|
+
* writes each input's FLAT NAME (`{{input.prep1__output__ticket}}`); an
|
|
218
|
+
* embedded node may declare that input under another id (`ticket`), which its
|
|
219
|
+
* prompts use. A flat name the node also declares as an id is left as it is.
|
|
220
|
+
*/
|
|
221
|
+
function inNodeInputNames(prompt, agentInputVariables) {
|
|
222
|
+
const vars = (Array.isArray(agentInputVariables) ? agentInputVariables : []).filter(isDict);
|
|
223
|
+
const ids = new Set(vars.map((v) => v.id));
|
|
224
|
+
let out = prompt;
|
|
225
|
+
for (const v of vars) {
|
|
226
|
+
if (typeof v.id !== 'string' || typeof v.binding !== 'string')
|
|
227
|
+
continue;
|
|
228
|
+
const flatName = agentInputRef(`=js:${wireExprBody(v.binding)}`)?.flatName;
|
|
229
|
+
if (flatName === undefined || ids.has(flatName))
|
|
230
|
+
continue;
|
|
231
|
+
out = out.split(`{{input.${flatName}}}`).join(`{{input.${v.id}}}`);
|
|
232
|
+
}
|
|
233
|
+
return out;
|
|
234
|
+
}
|
|
235
|
+
/**
|
|
236
|
+
* Write the author's `agent.json` edit onto an embedded inline agent node, which
|
|
237
|
+
* is read before its `agent.json` and so would never see it.
|
|
238
|
+
*
|
|
239
|
+
* `changed` are the paths that differ from `baseline` to `edited` (both
|
|
240
|
+
* compiled). A prompt is written as the edited file has it, with each input in
|
|
241
|
+
* the name the node declares it by ({@link inNodeInputNames}). A removed
|
|
242
|
+
* setting is not carried: the original `agent.json`, which merge keeps, still
|
|
243
|
+
* has it, and decompile would read it back from there. The schemas are
|
|
244
|
+
* not carried here: the node's descriptor arrays hold them, and merge applied
|
|
245
|
+
* that node change already. Anything else (a conversational or voice agent's
|
|
246
|
+
* file, a message list compile does not write, a setting the node has no input
|
|
247
|
+
* for) is returned as not carried.
|
|
248
|
+
*
|
|
249
|
+
* For example a baseline system prompt `"Triage"` edited to `"Triage and rank"`
|
|
250
|
+
* sets `inputs.systemPrompt` to `"Triage and rank"` and returns
|
|
251
|
+
* `{ inputs: ['systemPrompt'], notCarried: [] }`.
|
|
252
|
+
*
|
|
253
|
+
* @param node - The merged node, still embedded; its `inputs` are changed in place.
|
|
254
|
+
* @param baseline - The baseline compile's `agent.json`.
|
|
255
|
+
* @param edited - The edited compile's `agent.json`.
|
|
256
|
+
* @param changed - The paths from `baseline` to `edited`, as `mergeJson3` names them.
|
|
257
|
+
*/
|
|
258
|
+
export function carryAgentJsonEdit(node, baseline, edited, changed) {
|
|
259
|
+
const onTheNode = changed.filter((p) => !/^(inputSchema|outputSchema)(\.|\[|$)/.test(p));
|
|
260
|
+
const kind = node.type === undefined ? undefined : SIDECAR_AGENT_TYPES.get(node.type);
|
|
261
|
+
if (!kind?.inlineAgentJson || !isDict(baseline) || !isDict(edited))
|
|
262
|
+
return { inputs: [], notCarried: onTheNode };
|
|
263
|
+
const inputs = { ...(node.inputs ?? {}) };
|
|
264
|
+
const carried = new Set();
|
|
265
|
+
const notCarried = [];
|
|
266
|
+
const set = (key, value, path) => {
|
|
267
|
+
if (value === undefined) {
|
|
268
|
+
notCarried.push(path);
|
|
269
|
+
return;
|
|
270
|
+
}
|
|
271
|
+
inputs[key] = jsonClone(value);
|
|
272
|
+
carried.add(key);
|
|
273
|
+
};
|
|
274
|
+
const settings = isDict(edited.settings) ? edited.settings : {};
|
|
275
|
+
let messages = false;
|
|
276
|
+
for (const p of onTheNode) {
|
|
277
|
+
const setting = /^settings\.([A-Za-z]+)$/.exec(p)?.[1];
|
|
278
|
+
const input = setting === undefined ? undefined : SETTINGS_ON_THE_NODE.get(setting);
|
|
279
|
+
if (input !== undefined)
|
|
280
|
+
set(input, settings[setting], p);
|
|
281
|
+
else if (/^guardrails(\.|\[|$)/.test(p))
|
|
282
|
+
set('guardrails', edited.guardrails, p);
|
|
283
|
+
else if (/^messages(\.|\[|$)/.test(p))
|
|
284
|
+
messages = true;
|
|
285
|
+
else
|
|
286
|
+
notCarried.push(p);
|
|
287
|
+
}
|
|
288
|
+
if (messages) {
|
|
289
|
+
const before = promptsOf(baseline);
|
|
290
|
+
const after = promptsOf(edited);
|
|
291
|
+
if (before === undefined || after === undefined)
|
|
292
|
+
notCarried.push('messages');
|
|
293
|
+
else {
|
|
294
|
+
for (const [role, key] of PROMPTS_ON_THE_NODE) {
|
|
295
|
+
if (before.get(role) !== after.get(role))
|
|
296
|
+
set(key, inNodeInputNames(after.get(role), inputs.agentInputVariables), 'messages');
|
|
297
|
+
}
|
|
298
|
+
}
|
|
299
|
+
}
|
|
300
|
+
node.inputs = inputs;
|
|
301
|
+
return { inputs: [...carried], notCarried };
|
|
302
|
+
}
|
|
180
303
|
/** `{{input.<name>}}` placeholders in a prompt string. */
|
|
181
304
|
function promptInputs(prompt) {
|
|
182
305
|
if (typeof prompt !== 'string')
|
|
@@ -189,20 +312,24 @@ function promptInputs(prompt) {
|
|
|
189
312
|
*
|
|
190
313
|
* - `agent-storage` (refuses): the merged node no longer carries the original's
|
|
191
314
|
* embedded configuration, so the runtime would read `<source>/agent.json`
|
|
192
|
-
* instead — a model or prompt change the author never wrote.
|
|
315
|
+
* instead — a model or prompt change the author never wrote. The inputs merge
|
|
316
|
+
* carried from the author's `agent.json` edit ({@link carryAgentJsonEdit}) are
|
|
317
|
+
* the author's, not lost.
|
|
193
318
|
* - `agent-prompt-input` (refuses): a kept prompt names `{{input.X}}` but the
|
|
194
319
|
* merged node declares no input `X` (the edit removed or renamed it), so the
|
|
195
320
|
* prompt would render the placeholder empty.
|
|
196
321
|
* - `agent-embedded-edit` (warns): the author edited the node; merge applied the
|
|
197
|
-
* node change and kept the original's prompts, model and settings
|
|
198
|
-
*
|
|
322
|
+
* node change and kept the original's prompts, model and settings apart from
|
|
323
|
+
* what it carried, so any other configuration edit did not reach this agent.
|
|
199
324
|
*
|
|
200
325
|
* @param hasBaseline - Whether the merge had a baseline. Without one, merge
|
|
201
326
|
* cannot tell the author's change from the round trip's, so the
|
|
202
327
|
* `agent-embedded-edit` warning says the node may have been edited.
|
|
203
328
|
* @param scopes - Per scope (`''` = root, otherwise the subflow key): the original, merged and edited-node-ids.
|
|
329
|
+
* @param authored - Per merged node, the inputs {@link carryAgentJsonEdit} wrote onto it. Absent when the
|
|
330
|
+
* merge read no `agent.json` sidecars (`mergeFlow`), so nothing could be carried and the warning says so.
|
|
204
331
|
*/
|
|
205
|
-
export function embeddedAgentFindings(hasBaseline, scopes) {
|
|
332
|
+
export function embeddedAgentFindings(hasBaseline, scopes, authored) {
|
|
206
333
|
const out = [];
|
|
207
334
|
for (const { scope, original, merged, edited } of scopes) {
|
|
208
335
|
const where = scope === '' ? '' : ` in subflow "${scope}"`;
|
|
@@ -213,8 +340,9 @@ export function embeddedAgentFindings(hasBaseline, scopes) {
|
|
|
213
340
|
const m = mergedById.get(o.id);
|
|
214
341
|
if (m === undefined || m.type !== o.type)
|
|
215
342
|
continue; // deleted or replaced by the author
|
|
343
|
+
const byAuthor = new Set(authored?.get(m) ?? []);
|
|
216
344
|
const lost = Object.entries(configInputs(o))
|
|
217
|
-
.filter(([k, v]) => !same(m.inputs?.[k], v))
|
|
345
|
+
.filter(([k, v]) => !byAuthor.has(k) && !same(m.inputs?.[k], v))
|
|
218
346
|
.map(([k]) => k);
|
|
219
347
|
if (!isEmbeddedAgent(m) || lost.length > 0) {
|
|
220
348
|
out.push({
|
|
@@ -228,17 +356,36 @@ export function embeddedAgentFindings(hasBaseline, scopes) {
|
|
|
228
356
|
const declared = new Set((Array.isArray(m.inputs?.agentInputVariables) ? m.inputs.agentInputVariables : [])
|
|
229
357
|
.map((v) => v?.id)
|
|
230
358
|
.filter((id) => typeof id === 'string'));
|
|
231
|
-
const missing = [...new Set([...promptInputs(m.inputs?.systemPrompt), ...promptInputs(m.inputs?.userPrompt)])]
|
|
232
|
-
.filter((name) => !declared.has(name));
|
|
233
359
|
const origDeclared = new Set((Array.isArray(o.inputs?.agentInputVariables) ? o.inputs.agentInputVariables : []).map((v) => v?.id));
|
|
234
|
-
//
|
|
235
|
-
|
|
236
|
-
|
|
360
|
+
// Prompt by prompt, a placeholder the node does not declare: one the edit
|
|
361
|
+
// removed or renamed, or one the author's carried prompt added. One the
|
|
362
|
+
// original prompt already left undeclared is not the merge's doing.
|
|
363
|
+
const kept = new Set();
|
|
364
|
+
const added = new Set();
|
|
365
|
+
for (const key of ['systemPrompt', 'userPrompt']) {
|
|
366
|
+
const before = new Set(promptInputs(o.inputs?.[key]));
|
|
367
|
+
for (const name of promptInputs(m.inputs?.[key])) {
|
|
368
|
+
if (declared.has(name))
|
|
369
|
+
continue;
|
|
370
|
+
if (byAuthor.has(key) && !before.has(name))
|
|
371
|
+
added.add(name);
|
|
372
|
+
else if (origDeclared.has(name))
|
|
373
|
+
kept.add(name);
|
|
374
|
+
}
|
|
375
|
+
}
|
|
376
|
+
const placeholders = (names) => [...names].map((n) => `{{input.${n}}}`).join(', ');
|
|
377
|
+
if (added.size > 0) {
|
|
378
|
+
out.push({
|
|
379
|
+
kind: 'agent-prompt-input', refuses: true,
|
|
380
|
+
message: `agent "${o.id}"${where}: the edited prompt uses ${placeholders(added)}, but the node declares no `
|
|
381
|
+
+ 'such input, so the prompt would render it empty. Declare it in the agent\'s inputs.',
|
|
382
|
+
});
|
|
383
|
+
}
|
|
384
|
+
if (kept.size > 0) {
|
|
237
385
|
out.push({
|
|
238
386
|
kind: 'agent-prompt-input', refuses: true,
|
|
239
|
-
message: `agent "${o.id}"${where} keeps
|
|
240
|
-
+
|
|
241
|
-
+ 'An embedded agent\'s prompts are not taken from the source; change the prompt on the canvas too.',
|
|
387
|
+
message: `agent "${o.id}"${where} keeps a prompt that uses ${placeholders(kept)}, but the edit removed or `
|
|
388
|
+
+ 'renamed that input. Change the prompt in the source too, so merge carries it onto the node.',
|
|
242
389
|
});
|
|
243
390
|
}
|
|
244
391
|
if (edited.has(o.id)) {
|
|
@@ -249,9 +396,17 @@ export function embeddedAgentFindings(hasBaseline, scopes) {
|
|
|
249
396
|
? 'your change to the node'
|
|
250
397
|
: 'the edited node\'s inputs and outputs (with no baseline it cannot tell your change from the round trip\'s, '
|
|
251
398
|
+ 'so this node may not have been edited)')
|
|
252
|
-
+
|
|
253
|
-
|
|
254
|
-
|
|
399
|
+
+ (byAuthor.size > 0
|
|
400
|
+
? `, wrote your ${[...byAuthor].sort().map((k) => `inputs.${k}`).join(', ')} edit onto the node, and kept the rest `
|
|
401
|
+
+ 'of its configuration as the original has it.'
|
|
402
|
+
: ' and kept those as the original has them.')
|
|
403
|
+
+ (!hasBaseline
|
|
404
|
+
? ' With no baseline, a prompt, model or settings edit in the source is not carried for an embedded agent '
|
|
405
|
+
+ '(it would land in <source>/agent.json, which the node shadows); pass --baseline to carry it.'
|
|
406
|
+
: authored === undefined
|
|
407
|
+
? ' This merge read no agent.json, so a prompt, model or settings edit in the source is not carried for '
|
|
408
|
+
+ 'an embedded agent; merge with the sidecars (flow-merge, or mergeFlowWithSidecars) to carry it.'
|
|
409
|
+
: ''),
|
|
255
410
|
});
|
|
256
411
|
}
|
|
257
412
|
}
|
package/dist/merge-sidecars.d.ts
CHANGED
|
@@ -66,6 +66,13 @@ export declare function agentSources(flow: {
|
|
|
66
66
|
* `{a: 3, b: 2}` and `changed = ["a"]`.
|
|
67
67
|
*/
|
|
68
68
|
export declare function mergeJson3(original: unknown, baseline: unknown, edited: unknown, changed: string[], path?: string): unknown;
|
|
69
|
+
/** One embedded agent node merge wrote the author's `agent.json` edit onto. */
|
|
70
|
+
export interface NodeCarry {
|
|
71
|
+
/** The merged node, changed in place. */
|
|
72
|
+
node: AnyNode;
|
|
73
|
+
/** The `inputs` keys written. */
|
|
74
|
+
inputs: string[];
|
|
75
|
+
}
|
|
69
76
|
/**
|
|
70
77
|
* The sidecar files the merged flow needs written beside it, and what merge could
|
|
71
78
|
* not carry. `merged` is `mergeFlow`'s result. An agent is new when the
|
|
@@ -82,5 +89,6 @@ export declare function mergeAgentSidecars(merged: {
|
|
|
82
89
|
removals: string[];
|
|
83
90
|
findings: MergeFinding[];
|
|
84
91
|
missing: MergeFinding[];
|
|
92
|
+
onNodes: NodeCarry[];
|
|
85
93
|
};
|
|
86
94
|
export {};
|
package/dist/merge-sidecars.js
CHANGED
|
@@ -66,7 +66,7 @@
|
|
|
66
66
|
*/
|
|
67
67
|
import { builtinResourceDirectory } from './core/agent-resource-identity.js';
|
|
68
68
|
import { jsonClone } from './core/json-clone.js';
|
|
69
|
-
import { isEmbeddedAgent } from './merge-embedded-agent.js';
|
|
69
|
+
import { carryAgentJsonEdit, isEmbeddedAgent } from './merge-embedded-agent.js';
|
|
70
70
|
/** The `{ path, json }` list `serializeWithSidecars` returns, as a {@link SidecarSet}. */
|
|
71
71
|
export function sidecarSetFromList(list) {
|
|
72
72
|
return (source) => {
|
|
@@ -268,13 +268,6 @@ function carryResources(source, files, flows) {
|
|
|
268
268
|
}
|
|
269
269
|
return { writes, removals, unmatched };
|
|
270
270
|
}
|
|
271
|
-
/**
|
|
272
|
-
* The `agent.json` keys an embedded node carries itself, in its descriptor
|
|
273
|
-
* arrays (`agentInputVariables` / `agentOutputVariables`). An input or output
|
|
274
|
-
* edit changes them in the compiled `agent.json` and on the node; merge applies
|
|
275
|
-
* the node change (#1220), so their delta is not an edit the node shadows.
|
|
276
|
-
*/
|
|
277
|
-
const SCHEMA_ON_THE_NODE = /^(inputSchema|outputSchema)(\.|$)/;
|
|
278
271
|
const finding = (message) => ({ kind: 'agent-sidecar', message, refuses: true });
|
|
279
272
|
/**
|
|
280
273
|
* The sidecar files the merged flow needs written beside it, and what merge could
|
|
@@ -286,6 +279,7 @@ const finding = (message) => ({ kind: 'agent-sidecar', message, refuses: true })
|
|
|
286
279
|
*/
|
|
287
280
|
export function mergeAgentSidecars(merged, sources, flows) {
|
|
288
281
|
const writes = [];
|
|
282
|
+
const onNodes = [];
|
|
289
283
|
const removals = [];
|
|
290
284
|
const findings = [];
|
|
291
285
|
const missing = [];
|
|
@@ -297,6 +291,23 @@ export function mergeAgentSidecars(merged, sources, flows) {
|
|
|
297
291
|
const orig = sources.original(source);
|
|
298
292
|
const agentPath = `${source}/agent.json`;
|
|
299
293
|
const originalNode = originalAgents.get(source);
|
|
294
|
+
const base = sources.baseline?.(source);
|
|
295
|
+
// An embedded node (prompts or voice settings on the node) is read before
|
|
296
|
+
// agent.json, so the author's agent.json edit is written onto the node, and
|
|
297
|
+
// what cannot be is reported. `node` is the merged node: for an embedded
|
|
298
|
+
// original, the original plus the author's node change (#1220), still embedded.
|
|
299
|
+
if (base !== undefined && isEmbeddedAgent(node)) {
|
|
300
|
+
const changed = [];
|
|
301
|
+
mergeJson3(base[agentPath], base[agentPath], edited[agentPath], changed);
|
|
302
|
+
const { inputs, notCarried } = carryAgentJsonEdit(node, base[agentPath], edited[agentPath], changed);
|
|
303
|
+
if (inputs.length > 0)
|
|
304
|
+
onNodes.push({ node, inputs });
|
|
305
|
+
if (notCarried.length > 0) {
|
|
306
|
+
findings.push(finding(`agent "${node.id}": its ${agentPath} was edited (${notCarried.join(', ')}), but the original node carries its `
|
|
307
|
+
+ 'own configuration (embedded), which is read before agent.json, so the edit would not reach the agent. That '
|
|
308
|
+
+ 'change is NOT carried. Make it on the canvas, or save the agent with its prompts in agent.json only.'));
|
|
309
|
+
}
|
|
310
|
+
}
|
|
300
311
|
if (orig === undefined && originalNode !== undefined && !isEmbeddedAgent(originalNode)) {
|
|
301
312
|
missing.push(finding(`agent "${node.id}": the original flow has this agent, but ${agentPath} is not beside --original, or does not `
|
|
302
313
|
+ `parse. Nothing is written. Pass the project's own <Name>.flow as --original, with ${agentPath} beside it `
|
|
@@ -310,7 +321,6 @@ export function mergeAgentSidecars(merged, sources, flows) {
|
|
|
310
321
|
writes.push({ path, json: jsonClone(json), carried: ['new agent'] });
|
|
311
322
|
continue;
|
|
312
323
|
}
|
|
313
|
-
const base = sources.baseline?.(source);
|
|
314
324
|
if (base === undefined) {
|
|
315
325
|
if (stable(orig[agentPath]) !== stable(edited[agentPath])) {
|
|
316
326
|
const why = sources.baselineMissing
|
|
@@ -333,25 +343,10 @@ export function mergeAgentSidecars(merged, sources, flows) {
|
|
|
333
343
|
// agent.json: the author's delta, applied onto the original.
|
|
334
344
|
const changed = [];
|
|
335
345
|
const next = mergeJson3(orig[agentPath], base[agentPath], edited[agentPath], changed);
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
// An embedded node (prompts or voice settings on the node) is read before
|
|
341
|
-
// agent.json, so an agent.json edit does not reach it. Its input and
|
|
342
|
-
// output schemas are the exception: the node's descriptor arrays carry
|
|
343
|
-
// them, and merge applied that node change already.
|
|
344
|
-
if (isEmbeddedAgent(node)) {
|
|
345
|
-
const shadowed = changed.filter((p) => !SCHEMA_ON_THE_NODE.test(p));
|
|
346
|
-
if (shadowed.length > 0) {
|
|
347
|
-
findings.push(finding(`agent "${node.id}": its ${agentPath} was edited (${shadowed.join(', ')}), but the original node carries its `
|
|
348
|
-
+ 'own configuration (embedded), which is read before agent.json, so the edit would not reach the agent. The '
|
|
349
|
-
+ 'change is NOT carried. Make the change on the canvas, or save the agent with its prompts in agent.json only.'));
|
|
350
|
-
}
|
|
351
|
-
}
|
|
352
|
-
else if (stable(next) !== stable(orig[agentPath])) {
|
|
353
|
-
writes.push({ path: agentPath, json: next, carried: changed });
|
|
354
|
-
}
|
|
346
|
+
// An embedded node's edit went onto the node above; its agent.json, which
|
|
347
|
+
// the node shadows, stays the original's.
|
|
348
|
+
if (changed.length > 0 && !isEmbeddedAgent(node) && stable(next) !== stable(orig[agentPath])) {
|
|
349
|
+
writes.push({ path: agentPath, json: next, carried: changed });
|
|
355
350
|
}
|
|
356
351
|
// Resources: carried by identity (#1221), when the three flows are known.
|
|
357
352
|
if (flows === undefined) {
|
|
@@ -372,5 +367,5 @@ export function mergeAgentSidecars(merged, sources, flows) {
|
|
|
372
367
|
+ 'stay as they are. Make that change on the canvas.'));
|
|
373
368
|
}
|
|
374
369
|
}
|
|
375
|
-
return { writes, removals, findings, missing };
|
|
370
|
+
return { writes, removals, findings, missing, onNodes };
|
|
376
371
|
}
|
package/dist/merge.d.ts
CHANGED
|
@@ -139,13 +139,18 @@ export declare function mergeFlow(original: AnyFlow, edited: AnyFlow, options?:
|
|
|
139
139
|
* `mergeFlow`, plus the agent sidecar files the merged flow needs written beside
|
|
140
140
|
* it (#1207). An inline agent's prompts and settings live only in
|
|
141
141
|
* `<source>/agent.json`, so an edit to them changes no node; this carries the
|
|
142
|
-
* author's change to that file onto the original's copy
|
|
143
|
-
*
|
|
144
|
-
*
|
|
145
|
-
*
|
|
142
|
+
* author's change to that file onto the original's copy, or, for an embedded
|
|
143
|
+
* agent, which reads its prompts and settings from the node, onto the node
|
|
144
|
+
* (`onNodes`). What it cannot carry becomes a finding: warned, and refused
|
|
145
|
+
* under `strict`, with the flow's own findings. One that would replace the
|
|
146
|
+
* project's `agent.json` is refused in every mode. See merge-sidecars.ts.
|
|
146
147
|
*/
|
|
147
148
|
export declare function mergeFlowWithSidecars(original: AnyFlow, edited: AnyFlow, sidecars: MergeSidecarSources, options?: MergeOptions): {
|
|
148
149
|
flow: AnyFlow;
|
|
149
150
|
sidecars: SidecarWrite[];
|
|
150
151
|
removals: string[];
|
|
152
|
+
onNodes: Array<{
|
|
153
|
+
nodeId: string;
|
|
154
|
+
inputs: string[];
|
|
155
|
+
}>;
|
|
151
156
|
};
|
package/dist/merge.js
CHANGED
|
@@ -384,24 +384,32 @@ function positionStoreOf(f) {
|
|
|
384
384
|
return nodes && Object.keys(nodes).length > 0 ? nodes : undefined;
|
|
385
385
|
}
|
|
386
386
|
export function mergeFlow(original, edited, options = {}) {
|
|
387
|
-
const { result, findings } = mergeFlowFindings(original, edited, options);
|
|
388
|
-
reportOrRefuse(findings, options);
|
|
387
|
+
const { result, findings, agentFindings } = mergeFlowFindings(original, edited, options);
|
|
388
|
+
reportOrRefuse([...findings, ...agentFindings()], options);
|
|
389
389
|
return result;
|
|
390
390
|
}
|
|
391
391
|
/**
|
|
392
392
|
* `mergeFlow`, plus the agent sidecar files the merged flow needs written beside
|
|
393
393
|
* it (#1207). An inline agent's prompts and settings live only in
|
|
394
394
|
* `<source>/agent.json`, so an edit to them changes no node; this carries the
|
|
395
|
-
* author's change to that file onto the original's copy
|
|
396
|
-
*
|
|
397
|
-
*
|
|
398
|
-
*
|
|
395
|
+
* author's change to that file onto the original's copy, or, for an embedded
|
|
396
|
+
* agent, which reads its prompts and settings from the node, onto the node
|
|
397
|
+
* (`onNodes`). What it cannot carry becomes a finding: warned, and refused
|
|
398
|
+
* under `strict`, with the flow's own findings. One that would replace the
|
|
399
|
+
* project's `agent.json` is refused in every mode. See merge-sidecars.ts.
|
|
399
400
|
*/
|
|
400
401
|
export function mergeFlowWithSidecars(original, edited, sidecars, options = {}) {
|
|
401
|
-
const { result, findings } = mergeFlowFindings(original, edited, options);
|
|
402
|
+
const { result, findings, agentFindings } = mergeFlowFindings(original, edited, options);
|
|
402
403
|
const carried = mergeAgentSidecars(result, sidecars, { original, baseline: options.baseline, edited });
|
|
403
|
-
|
|
404
|
-
|
|
404
|
+
// After the carry: what it wrote onto an embedded node is the author's.
|
|
405
|
+
const authored = new Map(carried.onNodes.map((c) => [c.node, c.inputs]));
|
|
406
|
+
reportOrRefuse([...findings, ...agentFindings(authored), ...carried.findings], options, carried.missing);
|
|
407
|
+
return {
|
|
408
|
+
flow: result,
|
|
409
|
+
sidecars: carried.writes,
|
|
410
|
+
removals: carried.removals,
|
|
411
|
+
onNodes: carried.onNodes.map((c) => ({ nodeId: c.node.id, inputs: c.inputs })),
|
|
412
|
+
};
|
|
405
413
|
}
|
|
406
414
|
/** Refused with or without `strict`: merging would replace the project's `agent.json`. */
|
|
407
415
|
class SidecarOverwriteError extends MergeRefusedError {
|
|
@@ -621,17 +629,17 @@ function mergeFlowFindings(original, edited, options) {
|
|
|
621
629
|
const findings = [
|
|
622
630
|
...(options.baseline ? roundTripFindings(original, options.baseline, result) : []),
|
|
623
631
|
...mergedFileFindings(result, original),
|
|
624
|
-
...embeddedAgentFindings(!!options.baseline, [
|
|
625
|
-
{ scope: '', original: original.nodes ?? [], merged: finalNodes, edited: editedIds },
|
|
626
|
-
...Object.entries(original.subflows ?? {}).map(([key, sf]) => ({
|
|
627
|
-
scope: key,
|
|
628
|
-
original: sf?.nodes ?? [],
|
|
629
|
-
merged: result.subflows?.[key]?.nodes ?? [],
|
|
630
|
-
edited: subflowEdited.get(key) ?? new Set(),
|
|
631
|
-
})),
|
|
632
|
-
]),
|
|
633
632
|
];
|
|
634
|
-
|
|
633
|
+
const agentFindings = (authored) => embeddedAgentFindings(!!options.baseline, [
|
|
634
|
+
{ scope: '', original: original.nodes ?? [], merged: finalNodes, edited: editedIds },
|
|
635
|
+
...Object.entries(original.subflows ?? {}).map(([key, sf]) => ({
|
|
636
|
+
scope: key,
|
|
637
|
+
original: sf?.nodes ?? [],
|
|
638
|
+
merged: result.subflows?.[key]?.nodes ?? [],
|
|
639
|
+
edited: subflowEdited.get(key) ?? new Set(),
|
|
640
|
+
})),
|
|
641
|
+
], authored);
|
|
642
|
+
return { result, findings, agentFindings };
|
|
635
643
|
}
|
|
636
644
|
/**
|
|
637
645
|
* Whether the merged node for `orig` must be built from the original rather than
|
|
@@ -13,6 +13,8 @@ export interface LiftedBatchTransform {
|
|
|
13
13
|
entries: Array<[string, string | Printed | undefined]>;
|
|
14
14
|
/** The resource directory the node names (`inputs.source`, else `inputs.id`), to keep as the tool's `source`. */
|
|
15
15
|
dir: string | undefined;
|
|
16
|
+
/** The task's Prompt text as lifted, which a `{{input.<name>}}` token in it reads an agent input from. */
|
|
17
|
+
prompt: string | undefined;
|
|
16
18
|
}
|
|
17
19
|
/**
|
|
18
20
|
* The Batch Transform tool node `t` on agent `agent`, as its `tools` entry's
|
|
@@ -102,6 +102,7 @@ export function liftBatchTransformTool(agent, t, ctx, variable) {
|
|
|
102
102
|
? tsLiteral(description) : undefined;
|
|
103
103
|
// The task.
|
|
104
104
|
let querySrc;
|
|
105
|
+
let promptText;
|
|
105
106
|
const query = pick('query');
|
|
106
107
|
if (query !== undefined) {
|
|
107
108
|
const read = query.from === 'node' ? nodeQuery(query.value) : sidecarQuery(query.value);
|
|
@@ -110,6 +111,7 @@ export function liftBatchTransformTool(agent, t, ctx, variable) {
|
|
|
110
111
|
else if (read.kind === 'prompt') {
|
|
111
112
|
// A bare `=js:` string compiles as a static query (D3), so a Prompt with
|
|
112
113
|
// that prefix keeps its `{ prompt }` tag.
|
|
114
|
+
promptText = read.text;
|
|
113
115
|
querySrc = read.text === '' ? undefined
|
|
114
116
|
: read.text.startsWith('=js:') ? objLit([['prompt', tsLiteral(read.text)]]) : tsLiteral(read.text);
|
|
115
117
|
}
|
|
@@ -188,6 +190,7 @@ export function liftBatchTransformTool(agent, t, ctx, variable) {
|
|
|
188
190
|
['webSearchGrounding', groundingSrc],
|
|
189
191
|
],
|
|
190
192
|
dir,
|
|
193
|
+
prompt: promptText,
|
|
191
194
|
};
|
|
192
195
|
}
|
|
193
196
|
/** The node's mode-tagged `query` (or a pre-1.2 bare string); undefined when it is neither. */
|
|
@@ -69,6 +69,15 @@ export declare function jsonTextDirective(text: string, returnKeys?: readonly st
|
|
|
69
69
|
* one string field. See {@link jsonTextDirective}.
|
|
70
70
|
*/
|
|
71
71
|
export declare function checkInlineAgent(inputs: InlineAgentInputs | undefined, ctx: FlowCheckContext): void;
|
|
72
|
+
/**
|
|
73
|
+
* `{{input.<a>.<b>}}` is not rewritten, so conversion reads `<a>` as a global that
|
|
74
|
+
* does not exist and throws. A head that is already an input's flat name resolves.
|
|
75
|
+
*/
|
|
76
|
+
export declare function checkNestedPlaceholders(inputs: (AgentResources & {
|
|
77
|
+
inputs?: Record<string, unknown>;
|
|
78
|
+
systemPrompt?: unknown;
|
|
79
|
+
userPrompt?: unknown;
|
|
80
|
+
}) | undefined, ctx: FlowCheckContext, who: AgentKindLabel): void;
|
|
72
81
|
/**
|
|
73
82
|
* The resource rules an agent's `context`, `tools` and `escalation` share,
|
|
74
83
|
* whichever agent attaches them: the inline agent, and the voice and
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { agentInputRef } from '../../../core/agent-sidecar.js';
|
|
2
2
|
import { Expr } from '../../../core/expr.js';
|
|
3
3
|
import { GUID_RE } from '../../../core/binding-messages.js';
|
|
4
|
-
import { promptPlaceholders } from '../../../core/agent-sidecar.js';
|
|
4
|
+
import { nestedPlaceholders, promptPlaceholders } from '../../../core/agent-sidecar.js';
|
|
5
5
|
import { prepareCommand } from '../../../core/cli-spelling.js';
|
|
6
6
|
import { nearestName } from '../../../core/edit-distance.js';
|
|
7
7
|
import { FLAT_SEP, flatNameSegmentsOf } from '../../../core/expr.js';
|
|
@@ -75,6 +75,7 @@ export const AGENT_DIAGNOSTICS = {
|
|
|
75
75
|
FLOW_AGENT_TOOL_NO_RESOURCE_ID: { severity: 'error', summary: 'a process tool with no name or folderPath' },
|
|
76
76
|
FLOW_AGENT_TOOL_UNKNOWN_BUILTIN: { severity: 'error', summary: 'a builtin tool that is not one of the three' },
|
|
77
77
|
FLOW_AGENT_TOOL_UNKNOWN_KIND: { severity: 'error', summary: 'a tool of an unknown kind' },
|
|
78
|
+
INLINE_AGENT_NESTED_PLACEHOLDER: { severity: 'error', summary: 'a prompt placeholder with a selector tail, like {{input.a.b}}' },
|
|
78
79
|
INLINE_AGENT_UNDECLARED_PLACEHOLDER: { severity: 'error', summary: 'a prompt placeholder naming no declared input' },
|
|
79
80
|
INLINE_AGENT_UNREFERENCED_INPUT: { severity: 'warning', summary: 'an inline agent input no prompt references' },
|
|
80
81
|
VOICE_AGENT_ITERATIONS: { severity: 'error', summary: 'a voice agent whose maxIterations is outside 1 to 8' },
|
|
@@ -634,21 +635,21 @@ export function checkInlineAgent(inputs, ctx) {
|
|
|
634
635
|
const unreferenced = declaredInputs.filter((k) => !placeholders.includes(k) && !boundForTool(k));
|
|
635
636
|
if (declaredInputs.length && unreferenced.length === declaredInputs.length) {
|
|
636
637
|
warn('INLINE_AGENT_UNREFERENCED_INPUT', `Inline agent step "${step}" declares input(s) ${unreferenced.map((u) => `\`${u}\``).join(', ')} that `
|
|
637
|
-
+ `
|
|
638
|
+
+ `no prompt, context query or built-in task references as \`{{input.<name>}}\` and no tool argument or tool's task binds as its \`variable\` — so `
|
|
638
639
|
+ `NONE of them is referenced. Deployed, the `
|
|
639
640
|
+ `authored list is not necessarily what the platform sends: flow-v1's `
|
|
640
641
|
+ `\`preDeriveAgentInputDefinitions\` pre-pass builds the input list by scanning the node's prompts for `
|
|
641
642
|
+ `variable references, merges what it finds with the authored list, and DROPS an entry no reference `
|
|
642
643
|
+ `points at when its caller asks for pruning. A referenced input survives every path; an unreferenced `
|
|
643
644
|
+ `one survives only some, and the failure mode is an agent that arrives with no arguments at all. `
|
|
644
|
-
+ `Write \`{{input.${declaredInputs[0]}}}\` in a prompt — which is also how the agent gets told what it `
|
|
645
|
+
+ `Write \`{{input.${declaredInputs[0]}}}\` in a prompt, context query or built-in task — which is also how the agent gets told what it `
|
|
645
646
|
+ `is looking at.`);
|
|
646
647
|
}
|
|
647
648
|
else if (unreferenced.length) {
|
|
648
649
|
warn('INLINE_AGENT_UNREFERENCED_INPUT', `Inline agent step "${step}" declares input(s) ${unreferenced.map((u) => `\`${u}\``).join(', ')} that `
|
|
649
|
-
+ `
|
|
650
|
+
+ `no prompt, context query or built-in task references as \`{{input.<name>}}\` and no tool argument or tool's task binds as its \`variable\`. `
|
|
650
651
|
+ `The platform may prune an unreferenced input, so `
|
|
651
|
-
+ `it is not reliably sent — and an input
|
|
652
|
+
+ `it is not reliably sent — and an input none of them mentions is one the agent cannot use anyway.`);
|
|
652
653
|
}
|
|
653
654
|
// Direction 2: a placeholder naming an input that does not exist. The compiler
|
|
654
655
|
// leaves it alone rather than deleting it, so it reaches the model as the literal
|
|
@@ -656,12 +657,13 @@ export function checkInlineAgent(inputs, ctx) {
|
|
|
656
657
|
const undeclared = [...new Set(placeholders.filter((p) => !declaredInputs.includes(p)))];
|
|
657
658
|
if (undeclared.length) {
|
|
658
659
|
at('INLINE_AGENT_UNDECLARED_PLACEHOLDER', `Inline agent step "${step}" references ${undeclared.map((u) => `\`{{input.${u}}}\``).join(', ')} in a `
|
|
659
|
-
+ `prompt, but \`inputs\` declares ${declaredInputs.length ? declaredInputs.map((d) => `\`${d}\``).join(', ') : 'nothing'}. `
|
|
660
|
+
+ `prompt, context query or built-in task, but \`inputs\` declares ${declaredInputs.length ? declaredInputs.map((d) => `\`${d}\``).join(', ') : 'nothing'}. `
|
|
660
661
|
+ `An unmatched placeholder is not substituted — it reaches the model as that literal text, and the `
|
|
661
662
|
+ `value it was meant to carry never arrives.`, declaredInputs.length
|
|
662
663
|
? `inputs: { ${undeclared[0]}: input('${undeclared[0]}'), … }`
|
|
663
664
|
: `inputs: { ${undeclared[0]}: input('${undeclared[0]}') }`);
|
|
664
665
|
}
|
|
666
|
+
checkNestedPlaceholders(inputs, ctx, 'Inline agent');
|
|
665
667
|
// Direction 3, an input bound to a COMPUTED EXPRESSION that a prompt
|
|
666
668
|
// references, is the serializer's INLINE_AGENT_COMPOSITE_INPUT
|
|
667
669
|
// (`compositeInputRefusal`, inline-agent.ts): the binding has no argument
|
|
@@ -744,6 +746,20 @@ export function checkInlineAgent(inputs, ctx) {
|
|
|
744
746
|
}
|
|
745
747
|
checkAgentResources(inputs, ctx, 'Inline agent');
|
|
746
748
|
}
|
|
749
|
+
/**
|
|
750
|
+
* `{{input.<a>.<b>}}` is not rewritten, so conversion reads `<a>` as a global that
|
|
751
|
+
* does not exist and throws. A head that is already an input's flat name resolves.
|
|
752
|
+
*/
|
|
753
|
+
export function checkNestedPlaceholders(inputs, ctx, who) {
|
|
754
|
+
const declared = inputs?.inputs ?? {};
|
|
755
|
+
const isFlatName = (head) => agentInputRef(rendered(declared[head]))?.flatName === head;
|
|
756
|
+
const nested = nestedPlaceholders(inputs ?? {}, isFlatName);
|
|
757
|
+
if (nested.length === 0)
|
|
758
|
+
return;
|
|
759
|
+
ctx.report('INLINE_AGENT_NESTED_PLACEHOLDER', `${who} step "${ctx.step}" references ${nested.map((n) => `\`${n}\``).join(', ')} in a `
|
|
760
|
+
+ `prompt, context query or built-in task. A placeholder takes an input name only, so a selector tail `
|
|
761
|
+
+ `is not rewritten, and converting the flow to BPMN throws on it.`, `declare the field as its own input and write \`{{input.<name>}}\``);
|
|
762
|
+
}
|
|
747
763
|
/**
|
|
748
764
|
* The resource rules an agent's `context`, `tools` and `escalation` share,
|
|
749
765
|
* whichever agent attaches them: the inline agent, and the voice and
|
|
@@ -68,6 +68,7 @@ export declare function liftAgentResources(node: FlowNode, ctx: FlowDeserializeC
|
|
|
68
68
|
escalation: string | undefined;
|
|
69
69
|
memory: string | undefined;
|
|
70
70
|
toolVariables: ToolVariable[];
|
|
71
|
+
queryTexts: string[];
|
|
71
72
|
};
|
|
72
73
|
export declare function printInlineAgent(spec: LiftedInlineAgent, ctx: FlowPrintContext): {
|
|
73
74
|
factory: string;
|
|
@@ -185,7 +185,7 @@ const CONTEXT_SETTINGS_KEYS = new Set([
|
|
|
185
185
|
* a warning, or an error under `--strict`. Compile would write the SDK's
|
|
186
186
|
* value instead, so it is never dropped silently.
|
|
187
187
|
*/
|
|
188
|
-
function contextIndexSettings(agent, c, sidecar, ctx) {
|
|
188
|
+
function contextIndexSettings(agent, c, sidecar, ctx, queryTexts) {
|
|
189
189
|
const settings = sidecar?.settings && typeof sidecar.settings === 'object' && !Array.isArray(sidecar.settings)
|
|
190
190
|
? sidecar.settings : undefined;
|
|
191
191
|
const ni = (c.inputs ?? {});
|
|
@@ -238,8 +238,10 @@ function contextIndexSettings(agent, c, sidecar, ctx) {
|
|
|
238
238
|
})();
|
|
239
239
|
const query = sidecarQuery ?? nodeQuery;
|
|
240
240
|
let querySrc;
|
|
241
|
-
if (query?.kind === 'prompt' && query.text !== '')
|
|
241
|
+
if (query?.kind === 'prompt' && query.text !== '') {
|
|
242
242
|
querySrc = tsLiteral(query.text);
|
|
243
|
+
queryTexts.push(query.text);
|
|
244
|
+
}
|
|
243
245
|
else if (query?.kind === 'text' && query.text.startsWith('=js:'))
|
|
244
246
|
querySrc = tsLiteral(query.text);
|
|
245
247
|
else if (query?.kind === 'text' && query.text !== '')
|
|
@@ -636,7 +638,9 @@ export function liftInlineAgent(node, ctx) {
|
|
|
636
638
|
// would; otherwise every input is printed, and a tool reference one of them
|
|
637
639
|
// binds is still one input, `refs` being deduped by flat name.
|
|
638
640
|
const prompt = (p) => (plain(p) === undefined ? undefined : unrender(plain(p)));
|
|
639
|
-
const placeholders = new Set(promptPlaceholders({
|
|
641
|
+
const placeholders = new Set(promptPlaceholders({
|
|
642
|
+
systemPrompt: prompt(i.systemPrompt), userPrompt: prompt(i.userPrompt), context: resources.queryTexts.map((query) => ({ query })),
|
|
643
|
+
}));
|
|
640
644
|
const toolOnly = new Set(toolVariables.map((v) => v.id).filter((id) => !placeholders.has(id)));
|
|
641
645
|
/** The flat names compile plans from `declared` and the tools' references, deduped as `agentInputPlan` does. */
|
|
642
646
|
const planned = (declared) => JSON.stringify([...new Set([
|
|
@@ -742,6 +746,8 @@ export function liftAgentResources(node, ctx, withMemory, agentInputs = []) {
|
|
|
742
746
|
};
|
|
743
747
|
/** The agent inputs the tools' Variables bind (a process tool's arguments, a built-in's task), in tool and argument order. */
|
|
744
748
|
const toolVariables = [];
|
|
749
|
+
/** The query texts the agent's context indexes and batch transform tools lift, which can hold `{{input.<name>}}` tokens. */
|
|
750
|
+
const queryTexts = [];
|
|
745
751
|
/**
|
|
746
752
|
* A built-in tool's task Variable, as the reference of the agent input it
|
|
747
753
|
* names: by its `{{<flatName>}}` in the sidecar, by `$agent.<flatName>`, or by
|
|
@@ -815,7 +821,9 @@ export function liftAgentResources(node, ctx, withMemory, agentInputs = []) {
|
|
|
815
821
|
// docs/INLINE_AGENT_BATCH_TRANSFORM_DESIGN.md). The directory is the node's
|
|
816
822
|
// `source`, or the canvas's `inputs.id` when `source` is empty or a file
|
|
817
823
|
// binding: kept as the tool's `source`, so a recompile writes back into it.
|
|
818
|
-
const { entries, dir } = liftBatchTransformTool(node, t, ctx, taskVariable);
|
|
824
|
+
const { entries, dir, prompt } = liftBatchTransformTool(node, t, ctx, taskVariable);
|
|
825
|
+
if (prompt !== undefined)
|
|
826
|
+
queryTexts.push(prompt);
|
|
819
827
|
const derived = derivedToolSource(ctx.flowId, node.id, { kind: 'builtin', tool: 'batchtransform' });
|
|
820
828
|
const all = [
|
|
821
829
|
...entries,
|
|
@@ -889,7 +897,7 @@ export function liftAgentResources(node, ctx, withMemory, agentInputs = []) {
|
|
|
889
897
|
['folderPath', folderPath !== undefined ? tsLiteral(folderPath) : undefined],
|
|
890
898
|
['folderKey', rPlain(c, 'folderKey') !== undefined ? tsLiteral(rPlain(c, 'folderKey')) : undefined],
|
|
891
899
|
// `query` and the retrieval settings, from resource.json or the node (#1183).
|
|
892
|
-
...contextIndexSettings(node, c, sidecar, ctx),
|
|
900
|
+
...contextIndexSettings(node, c, sidecar, ctx, queryTexts),
|
|
893
901
|
['label', label !== undefined ? tsLiteral(label) : undefined],
|
|
894
902
|
...placement(c, derivedContextSource(ctx.flowId, node.id, id)),
|
|
895
903
|
]);
|
|
@@ -968,7 +976,7 @@ export function liftAgentResources(node, ctx, withMemory, agentInputs = []) {
|
|
|
968
976
|
const tools = !toolSrc.length ? undefined
|
|
969
977
|
: toolSrc.every((x) => typeof x === 'string') ? list(toolSrc)
|
|
970
978
|
: (print) => `[${toolSrc.map((x) => (typeof x === 'function' ? x(print) : x)).join(', ')}]`;
|
|
971
|
-
return { context: list(contextSrc), tools, escalation: list(escalationSrc), memory: memorySrc, toolVariables };
|
|
979
|
+
return { context: list(contextSrc), tools, escalation: list(escalationSrc), memory: memorySrc, toolVariables, queryTexts };
|
|
972
980
|
}
|
|
973
981
|
export function printInlineAgent(spec, ctx) {
|
|
974
982
|
const { inputRows, options } = spec.inputs;
|
|
@@ -7,6 +7,7 @@
|
|
|
7
7
|
* definitions, bindings and files unchanged.
|
|
8
8
|
*/
|
|
9
9
|
import type { AgentResources, InlineAgentInputs } from './spec.js';
|
|
10
|
+
import { type AgentInputBinding } from '../../../core/agent-sidecar.js';
|
|
10
11
|
import { toolVariableRefs } from '../../../core/tool-argument.js';
|
|
11
12
|
import type { FlowNodeContribution, FlowSerializeContext } from '../../../flow-node-type.js';
|
|
12
13
|
import { CompileRefusal } from '../../../core/compile-refusal.js';
|
|
@@ -55,7 +56,7 @@ export declare function toolArguments(s: AgentResources, step: string, who: Agen
|
|
|
55
56
|
*/
|
|
56
57
|
export declare function attachAgentResources(s: AgentResources, ctx: FlowSerializeContext, source: string, who: AgentKindLabel, toolVariables?: ReadonlyMap<object, Record<string, {
|
|
57
58
|
flatName: string;
|
|
58
|
-
}
|
|
59
|
+
}>>, inputs?: Map<string, AgentInputBinding>): {
|
|
59
60
|
attach: Attached[];
|
|
60
61
|
libraryRequired?: CompileRefusal;
|
|
61
62
|
};
|
|
@@ -135,7 +135,7 @@ export function serializeInlineAgent(s, ctx) {
|
|
|
135
135
|
// not exist yet: the `properties` object is filled in place when the scope
|
|
136
136
|
// closes.
|
|
137
137
|
ctx.typeAgentInputs(agentJson.inputSchema, plan.refs);
|
|
138
|
-
const { attach, libraryRequired } = attachAgentResources(s, ctx, source, 'Inline agent', toolVariables);
|
|
138
|
+
const { attach, libraryRequired } = attachAgentResources(s, ctx, source, 'Inline agent', toolVariables, plan.byName);
|
|
139
139
|
// MEMORY — one episodic-memory resource on the agent's `memory` handle (the
|
|
140
140
|
// 1.4 definition selected above). Same artifact shape as context.
|
|
141
141
|
if (s.memory !== undefined) {
|
|
@@ -275,7 +275,7 @@ function taskVariableRefusal(who, where, query, render) {
|
|
|
275
275
|
* `toolVariables` holds each process tool's Variable arguments, already bound
|
|
276
276
|
* to agent inputs by the caller's input plan (`toolVariableRefs`).
|
|
277
277
|
*/
|
|
278
|
-
export function attachAgentResources(s, ctx, source, who, toolVariables = new Map()) {
|
|
278
|
+
export function attachAgentResources(s, ctx, source, who, toolVariables = new Map(), inputs) {
|
|
279
279
|
const step = ctx.step;
|
|
280
280
|
const render = (v) => ctx.render(v);
|
|
281
281
|
const attach = [];
|
|
@@ -313,7 +313,7 @@ export function attachAgentResources(s, ctx, source, who, toolVariables = new Ma
|
|
|
313
313
|
// platform validator says so in its own refusal text — *"the resource id
|
|
314
314
|
// from the parent inline agent's `resources[]`"*.
|
|
315
315
|
const contextResourceId = cx.source ?? derivedContextSource(ctx.flowId, step, cx.id);
|
|
316
|
-
const contextQuery = renderContextQuery(cx.query, render);
|
|
316
|
+
const contextQuery = renderContextQuery(cx.query, render, inputs);
|
|
317
317
|
// The index's own configuration; the platform's `inputDefaults` are the
|
|
318
318
|
// shape a designer-placed node has, so an omitted option emits the
|
|
319
319
|
// designer's value rather than nothing.
|
|
@@ -398,7 +398,7 @@ export function attachAgentResources(s, ctx, source, who, toolVariables = new Ma
|
|
|
398
398
|
if (tr.description !== undefined)
|
|
399
399
|
extraInputs.description = tr.description;
|
|
400
400
|
if ('query' in extraInputs && tr.query !== undefined) {
|
|
401
|
-
extraInputs.query = renderBuiltinToolQuery(tr.query, render);
|
|
401
|
+
extraInputs.query = renderBuiltinToolQuery(tr.query, render, inputs);
|
|
402
402
|
}
|
|
403
403
|
// batchtransform's columns and grounding, as the canvas's form writes them:
|
|
404
404
|
// the rows as given, and the select's lowercase value (the resource
|
|
@@ -707,7 +707,7 @@ function unknownToolKind(step, kind, who) {
|
|
|
707
707
|
+ "'clientside', 'httpRequest'.");
|
|
708
708
|
}
|
|
709
709
|
/**
|
|
710
|
-
* The refusal for an input bound to a COMPUTED EXPRESSION that a prompt references as
|
|
710
|
+
* The refusal for an input bound to a COMPUTED EXPRESSION that a prompt, context query or built-in task references as
|
|
711
711
|
* `{{input.<name>}}` (#1518). The platform names each agent argument after the
|
|
712
712
|
* reference path it is bound to (`agentInputPlan`), so an expression spanning
|
|
713
713
|
* zero or several references gets no argument: writing the flow anyway would
|
|
@@ -725,7 +725,7 @@ function compositeInputRefusal(s, byName, step) {
|
|
|
725
725
|
continue;
|
|
726
726
|
const js = val instanceof Expr ? val.js : String(val).replace(/^=js:/, '');
|
|
727
727
|
return new CompileRefusal('INLINE_AGENT_COMPOSITE_INPUT', `Inline agent step "${step}"'s input \`${name}\` is bound to a computed expression `
|
|
728
|
-
+ `(\`${js.length > 60 ? `${js.slice(0, 60)}…` : js}\`), and a prompt references it as `
|
|
728
|
+
+ `(\`${js.length > 60 ? `${js.slice(0, 60)}…` : js}\`), and a prompt, context query or built-in task references it as `
|
|
729
729
|
+ `\`{{input.${name}}}\`. The platform does not send the agent the names you declared: it names each `
|
|
730
730
|
+ `argument after the REFERENCE PATH the input is bound to (\`$vars.a.output.b\` → \`a__output__b\`). `
|
|
731
731
|
+ `A computed expression is not one reference, so it gets no argument: its value does not reach the `
|
|
@@ -14,7 +14,7 @@
|
|
|
14
14
|
import { agentInputPlan, agentSidecarInputs, conversationalAgentJson, voiceAgentJson } from '../../../core/agent-sidecar.js';
|
|
15
15
|
import { Expr, toExpr } from '../../../core/expr.js';
|
|
16
16
|
import { wireExprBody } from '../../../core/wire-expr.js';
|
|
17
|
-
import { checkAgentResources, checkConversationalAgent, checkInlineAgent, checkInlineAgentRead, checkVoice } from './check.js';
|
|
17
|
+
import { checkAgentResources, checkConversationalAgent, checkNestedPlaceholders, checkInlineAgent, checkInlineAgentRead, checkVoice } from './check.js';
|
|
18
18
|
import { INLINE_AGENT_DEFAULT_VERSION, INLINE_AGENT_VERSIONS, attachAgentResources, toolArguments, serializeInlineAgent, } from './inline-agent.js';
|
|
19
19
|
import { liftAgentResources, liftInlineAgent, printInlineAgent } from './inline-agent-lift.js';
|
|
20
20
|
import { INLINE_AGENT } from './resources.js';
|
|
@@ -121,18 +121,18 @@ function serializeVoiceAgent(s, ctx) {
|
|
|
121
121
|
ctx.typeAgentInputs(json.inputSchema, plan.refs);
|
|
122
122
|
// The resource model lives on the definition (its `model.source: true` is
|
|
123
123
|
// what makes `source` an input), as on the inline agent.
|
|
124
|
-
return { model: 'omit', port: SHELL_FORWARD_PORT, inputs, attach: shellResources(s, ctx, source, 'Voice agent') };
|
|
124
|
+
return { model: 'omit', port: SHELL_FORWARD_PORT, inputs, attach: shellResources(s, ctx, source, 'Voice agent', plan.byName) };
|
|
125
125
|
}
|
|
126
126
|
/**
|
|
127
127
|
* A shell agent's tools, context indexes and escalations: the inline agent's
|
|
128
128
|
* resource nodes and `resource.json` files, under this agent's `source` (#1670).
|
|
129
129
|
*/
|
|
130
|
-
function shellResources(s, ctx, source, who) {
|
|
130
|
+
function shellResources(s, ctx, source, who, inputs) {
|
|
131
131
|
// A process tool argument compile cannot write, a Variable included, or a
|
|
132
132
|
// built-in task it cannot write, is held until the resources are judged, and
|
|
133
133
|
// thrown before LIBRARY_REQUIRED, which `check` drops, as on the inline agent.
|
|
134
134
|
const { toolArgument } = toolArguments(s, ctx.step, who, (v) => ctx.render(v), false);
|
|
135
|
-
const { attach, libraryRequired } = attachAgentResources(s, ctx, source, who);
|
|
135
|
+
const { attach, libraryRequired } = attachAgentResources(s, ctx, source, who, undefined, inputs);
|
|
136
136
|
if (toolArgument)
|
|
137
137
|
throw toolArgument;
|
|
138
138
|
if (libraryRequired)
|
|
@@ -418,6 +418,7 @@ function voiceAgentAt(version) {
|
|
|
418
418
|
check: (spec, ctx) => {
|
|
419
419
|
checkVoice('voiceAgent', spec.inputs, ctx);
|
|
420
420
|
checkAgentResources(spec.inputs, ctx, 'Voice agent');
|
|
421
|
+
checkNestedPlaceholders(spec.inputs, ctx, 'Voice agent');
|
|
421
422
|
},
|
|
422
423
|
expressions: () => [],
|
|
423
424
|
output: opaque,
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import type { ContextIndexRef, EscalationRef, ProcessToolKind, ToolArgument } from '../../../core/actions.js';
|
|
2
|
+
import { type AgentInputBinding } from '../../../core/agent-sidecar.js';
|
|
2
3
|
import { CompileRefusal } from '../../../core/compile-refusal.js';
|
|
3
4
|
import type { ResolvedConnector } from '../../../core/library.js';
|
|
4
5
|
import type { ProcessResourceSubType } from '../../../core/process-resource.js';
|
|
@@ -55,7 +56,7 @@ export declare function contextIndexDef(spec: {
|
|
|
55
56
|
* `folderPathPrefix` field uses, and the reason that field ships with
|
|
56
57
|
* `mode: 'text-builder'` by default.
|
|
57
58
|
*/
|
|
58
|
-
export declare function renderContextQuery(query: unknown, render: (value: unknown) => unknown): Record<string, unknown>;
|
|
59
|
+
export declare function renderContextQuery(query: unknown, render: (value: unknown) => unknown, inputs?: Map<string, AgentInputBinding>): Record<string, unknown>;
|
|
59
60
|
/**
|
|
60
61
|
* Render a built-in tool's task (`summarize`, `batchtransform`) into the node's
|
|
61
62
|
* MODE-TAGGED `query`, from the canvas's sources (`BuiltinToolQuery`):
|
|
@@ -80,7 +81,7 @@ export declare function renderContextQuery(query: unknown, render: (value: unkno
|
|
|
80
81
|
* throws before anything is written; they render here as Empty, so the tool
|
|
81
82
|
* is attached like any other while the rest of the agent is judged.
|
|
82
83
|
*/
|
|
83
|
-
export declare function renderBuiltinToolQuery(query: unknown, render: (value: unknown) => unknown): Record<string, unknown>;
|
|
84
|
+
export declare function renderBuiltinToolQuery(query: unknown, render: (value: unknown) => unknown, inputs?: Map<string, AgentInputBinding>): Record<string, unknown>;
|
|
84
85
|
/**
|
|
85
86
|
* The agent input a built-in tool's task Variable binds: the single reference in
|
|
86
87
|
* `{ variable }`, under its flat name, as `agentInputPlan` takes a tool's
|
|
@@ -7,7 +7,7 @@
|
|
|
7
7
|
* definition and file is unchanged.
|
|
8
8
|
*/
|
|
9
9
|
import ixpDefinition from '../../../core/ixp-definition.json' with { type: 'json' };
|
|
10
|
-
import { JOB_ATTACHMENT_REF, agentInputRef, jobAttachmentDefinition } from '../../../core/agent-sidecar.js';
|
|
10
|
+
import { JOB_ATTACHMENT_REF, agentInputRef, jobAttachmentDefinition, renderAgentSidecarPrompt, } from '../../../core/agent-sidecar.js';
|
|
11
11
|
import { BUILTIN_TOOL_TYPE, CONNECTOR_TOOL_RESOURCE_TYPE, HTTP_REQUEST_TOOL_TYPE, INTERNAL_TOOL_RESOURCE_TYPE, TOOL_RESOURCE_TYPE, } from '../../../core/agent-tool-resources.js';
|
|
12
12
|
import { CompileRefusal } from '../../../core/compile-refusal.js';
|
|
13
13
|
import { buildConfiguration } from '../../../core/connector-configuration.js';
|
|
@@ -127,11 +127,14 @@ export function contextIndexDef(spec) {
|
|
|
127
127
|
* `folderPathPrefix` field uses, and the reason that field ships with
|
|
128
128
|
* `mode: 'text-builder'` by default.
|
|
129
129
|
*/
|
|
130
|
-
export function renderContextQuery(query, render) {
|
|
130
|
+
export function renderContextQuery(query, render, inputs) {
|
|
131
131
|
const base = { mode: 'prompt', textValue: '', promptValue: '', argumentPath: '' };
|
|
132
132
|
if (query === undefined || query === null)
|
|
133
133
|
return base;
|
|
134
134
|
const rendered = render(query);
|
|
135
|
+
if (inputs && typeof rendered === 'string' && !rendered.startsWith('=js:')) {
|
|
136
|
+
return { ...base, promptValue: renderAgentSidecarPrompt(rendered, inputs) };
|
|
137
|
+
}
|
|
135
138
|
const asText = typeof rendered === 'string' ? rendered : JSON.stringify(rendered);
|
|
136
139
|
if (typeof rendered === 'string' && rendered.startsWith('=js:')) {
|
|
137
140
|
return { ...base, mode: 'text-builder', textValue: asText };
|
|
@@ -162,10 +165,10 @@ export function renderContextQuery(query, render) {
|
|
|
162
165
|
* throws before anything is written; they render here as Empty, so the tool
|
|
163
166
|
* is attached like any other while the rest of the agent is judged.
|
|
164
167
|
*/
|
|
165
|
-
export function renderBuiltinToolQuery(query, render) {
|
|
168
|
+
export function renderBuiltinToolQuery(query, render, inputs) {
|
|
166
169
|
const named = namedQuerySource(query);
|
|
167
170
|
if (named === undefined)
|
|
168
|
-
return renderContextQuery(isPlainObject(query) ? undefined : query, render);
|
|
171
|
+
return renderContextQuery(isPlainObject(query) ? undefined : query, render, inputs);
|
|
169
172
|
const base = { mode: 'prompt', textValue: '', promptValue: '', argumentPath: '' };
|
|
170
173
|
if (named.source === 'variable') {
|
|
171
174
|
const ref = agentInputRef(render(named.text));
|
|
@@ -175,6 +178,9 @@ export function renderBuiltinToolQuery(query, render) {
|
|
|
175
178
|
}
|
|
176
179
|
const rendered = render(named.text);
|
|
177
180
|
const text = typeof rendered === 'string' ? rendered : JSON.stringify(rendered);
|
|
181
|
+
if (named.source === 'prompt' && inputs && typeof rendered === 'string' && !rendered.startsWith('=js:')) {
|
|
182
|
+
return { ...base, promptValue: renderAgentSidecarPrompt(rendered, inputs) };
|
|
183
|
+
}
|
|
178
184
|
return named.source === 'value'
|
|
179
185
|
? { ...base, mode: 'text-builder', textValue: text }
|
|
180
186
|
: { ...base, promptValue: text };
|
|
@@ -114,5 +114,6 @@ export declare function checkCuratedOverlay(libraryPath: string, overlayPath?: s
|
|
|
114
114
|
* (`registry/fetch/`), where {@link applyCuratedOverlay} would be wrong: it also
|
|
115
115
|
* adds every definition this directory carries, and those are fixtures, not
|
|
116
116
|
* operations the tenant was asked about. Returns the corrected entry paths.
|
|
117
|
+
* An `overlayPath` that does not exist, as in a bundled SDK, contributes nothing.
|
|
117
118
|
*/
|
|
118
119
|
export declare function applyCorrectionsAndSideTables(libraryPath: string, sideTablesTo: string, overlayPath?: string): Promise<string[]>;
|
|
@@ -453,6 +453,7 @@ export async function checkCuratedOverlay(libraryPath, overlayPath = bundledOver
|
|
|
453
453
|
* (`registry/fetch/`), where {@link applyCuratedOverlay} would be wrong: it also
|
|
454
454
|
* adds every definition this directory carries, and those are fixtures, not
|
|
455
455
|
* operations the tenant was asked about. Returns the corrected entry paths.
|
|
456
|
+
* An `overlayPath` that does not exist, as in a bundled SDK, contributes nothing.
|
|
456
457
|
*/
|
|
457
458
|
export async function applyCorrectionsAndSideTables(libraryPath, sideTablesTo, overlayPath = bundledOverlayPath()) {
|
|
458
459
|
const corrected = [];
|
|
@@ -466,6 +467,10 @@ export async function applyCorrectionsAndSideTables(libraryPath, sideTablesTo, o
|
|
|
466
467
|
const target = join(sideTablesTo, table);
|
|
467
468
|
if (await exists(target))
|
|
468
469
|
continue;
|
|
470
|
+
// A bundled SDK (Studio Web's sandbox) runs without its lib/ directory, so
|
|
471
|
+
// there is no copy to give: a reader takes an absent table as an empty one.
|
|
472
|
+
if (!(await exists(join(overlayPath, table))))
|
|
473
|
+
continue;
|
|
469
474
|
await mkdir(sideTablesTo, { recursive: true });
|
|
470
475
|
await cp(join(overlayPath, table), target);
|
|
471
476
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@uipath/maestro-builder-sdk",
|
|
3
|
-
"version": "6.117.
|
|
3
|
+
"version": "6.117.3",
|
|
4
4
|
"description": "Build UiPath Flow, Case, and BPMN artifacts by writing TypeScript.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"homepage": "https://docs.uipath.com/maestro",
|
|
@@ -124,5 +124,5 @@
|
|
|
124
124
|
"@types/node": "^22.7.0",
|
|
125
125
|
"esbuild": "^0.28.1"
|
|
126
126
|
},
|
|
127
|
-
"gitref": "
|
|
127
|
+
"gitref": "2f1c37585eefb238a5ee2c95533b12b07e3f9a9a"
|
|
128
128
|
}
|