@uipath/maestro-builder-sdk 6.117.1 → 6.117.2

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/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 does NOT reach an embedded agent: it
33
- * lands in the edited `<source>/agent.json`, which the embedded node shadows.
34
- * Merge reports that ({@link embeddedAgentFindings}), and refuses under
35
- * `strict` any merged node that would no longer carry the original's embedded
36
- * configuration, or whose kept prompt names an input the node no longer
37
- * declares.
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, so a
77
- * prompt or model edit in the source did not reach this agent.
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 does NOT reach an embedded agent: it
33
- * lands in the edited `<source>/agent.json`, which the embedded node shadows.
34
- * Merge reports that ({@link embeddedAgentFindings}), and refuses under
35
- * `strict` any merged node that would no longer carry the original's embedded
36
- * configuration, or whose kept prompt names an input the node no longer
37
- * declares.
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, so a
198
- * prompt or model edit in the source did not reach this agent.
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
- // A placeholder the original already left undeclared is not the merge's doing.
235
- const newlyMissing = missing.filter((name) => origDeclared.has(name));
236
- if (newlyMissing.length > 0) {
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 its original embedded prompt, which uses `
240
- + `${newlyMissing.map((n) => `{{input.${n}}}`).join(', ')}, but the edit removed or renamed that input. `
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
- + ' and kept those as the original has them. A prompt, model or settings edit in the '
253
- + 'source is not carried for an embedded agent (it would land in <source>/agent.json, which the node '
254
- + 'shadows); make that change on the canvas.',
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
  }
@@ -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 {};
@@ -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
- if (changed.length > 0) {
337
- // `node` is the merged node: the original's when merge kept it; when the
338
- // author changed the node too, the edited shell, or, for an embedded
339
- // original, the original plus that change (#1220), still embedded.
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. What it cannot carry
143
- * becomes a finding: warned, and refused under `strict`, with the flow's own
144
- * findings. One that would replace the project's `agent.json` is refused in
145
- * every mode. See merge-sidecars.ts.
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. What it cannot carry
396
- * becomes a finding: warned, and refused under `strict`, with the flow's own
397
- * findings. One that would replace the project's `agent.json` is refused in
398
- * every mode. See merge-sidecars.ts.
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
- reportOrRefuse([...findings, ...carried.findings], options, carried.missing);
404
- return { flow: result, sidecars: carried.writes, removals: carried.removals };
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
- return { result, findings };
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
@@ -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.1",
3
+ "version": "6.117.2",
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": "eacce228a15703bf2725ea4513eaedb88d6f7663"
127
+ "gitref": "f07017fda4361782d6c91a42e2d4c64d945d4442"
128
128
  }