@uipath/maestro-builder-sdk 6.120.31 → 6.120.33

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/check.js CHANGED
@@ -19,6 +19,7 @@ import { compareSchemaVersions, schemaVersionRefusal } from './schema-version.js
19
19
  import { planFlowGlobals, planSharedInputs, sharedInputRoots } from './flow-variables.js';
20
20
  import { backedOutputs } from './flow-output-backing.js';
21
21
  import { childStepLists } from './flow-step-tree.js';
22
+ import { unsatisfiableJoins } from './core/exclusive-join.js';
22
23
  import { VARS_READ_RE } from './core/vars-read.js';
23
24
  import { FLOW_METADATA_KEYS, unknownMetadataKeys } from './core/flow-metadata.js';
24
25
  import { endContentKey } from './flow-end-content.js';
@@ -60,8 +61,10 @@ export function checkCompiled(built, opts = {}) {
60
61
  }
61
62
  const serialized = opts.serializer !== false
62
63
  ? serializerRefusals(built, { library: opts.library, bindings: opts.bindings, resources: opts.resources, nodeCatalog: opts.nodeCatalog, ...(opts.solution !== undefined ? { solution: opts.solution } : {}) }, diags)
63
- : { diagnostics: [], flow: undefined };
64
+ : { diagnostics: [], flow: undefined, scopes: [] };
64
65
  diags.push(...serialized.diagnostics);
66
+ if (serialized.flow !== undefined)
67
+ diags.push(...mergeNeverCompletes(serialized.flow, serialized.scopes ?? []));
65
68
  const placed = serialized.flow !== undefined ? placeDiagnostics(diags, serialized.flow) : undefined;
66
69
  const diagnostics = diags.map((d, i) => {
67
70
  const nodeId = d.nodeId ?? (placed?.[i].nodeId || undefined);
@@ -144,6 +147,75 @@ export function scopeToEdit(edited, baseline) {
144
147
  const PRE_EXISTING_LOWERING_NOTE = 'This node is unchanged from the baseline, so this is probably an SDK defect: '
145
148
  + 'the SDK cannot read what the designer wrote. `compile` refuses this node; `merge --baseline-from` keeps it as saved. '
146
149
  + 'Report it: https://github.com/UiPath/builder-sdk/issues';
150
+ /**
151
+ * MERGE_NEVER_COMPLETES, on each graph level the serializer pass emitted
152
+ * (`core/exclusive-join.ts`). Nodes map to steps through the ids that pass
153
+ * gave them (`EmittedScope.stepNodeId`), since a subflow's ids can be prefixed.
154
+ */
155
+ function mergeNeverCompletes(flow, scopes) {
156
+ const out = [];
157
+ const definitions = Array.isArray(flow?.definitions) ? flow.definitions : [];
158
+ for (const scope of scopes) {
159
+ const graph = scope.subflow === undefined ? flow : flow?.subflows?.[scope.subflow];
160
+ if (graph === undefined || graph === null)
161
+ continue;
162
+ const named = new Map();
163
+ const visit = (list) => {
164
+ for (const st of list) {
165
+ if ('name' in st && st.kind !== 'return' && !named.has(st.name))
166
+ named.set(st.name, st);
167
+ for (const child of childStepLists(st))
168
+ visit(child);
169
+ }
170
+ };
171
+ visit(scope.steps);
172
+ const byNode = new Map();
173
+ for (const [name, id] of scope.stepNodeId) {
174
+ const st = named.get(name);
175
+ if (st)
176
+ byNode.set(id, st);
177
+ }
178
+ const splitOf = (n, model) => {
179
+ const kind = byNode.get(n.id)?.kind;
180
+ if (kind === 'branch')
181
+ return 'Decision';
182
+ if (kind === 'switch')
183
+ return 'Switch';
184
+ return model === 'bpmn:ExclusiveGateway' ? 'Decision' : undefined;
185
+ };
186
+ const nameOf = (id, label) => { const st = byNode.get(id); return st && 'name' in st ? st.name : label; };
187
+ for (const j of unsatisfiableJoins({ nodes: graph.nodes, edges: graph.edges, definitions }, splitOf)) {
188
+ const name = nameOf(j.joinId, j.joinLabel);
189
+ const splitName = nameOf(j.splitId, j.splitLabel);
190
+ const ports = j.ports.map((p) => `"${p}"`).join(', ');
191
+ const isParallel = byNode.get(j.joinId)?.kind === 'parallel';
192
+ const method = j.splitKind === 'Switch' ? 'switch' : 'branch';
193
+ const prefix = scope.callers.map((c) => `In subflow "${c}": `).join('');
194
+ // The step the Merge hands on to: where the arms should meet instead.
195
+ const nextId = (graph.edges ?? []).find((e) => e?.sourceNodeId === j.joinId)?.targetNodeId;
196
+ const nextStep = nextId !== undefined ? byNode.get(nextId) : undefined;
197
+ const next = nextStep && 'name' in nextStep ? nextStep.name : undefined;
198
+ out.push({
199
+ level: 'error', code: 'MERGE_NEVER_COMPLETES',
200
+ message: `${prefix}${isParallel ? `.parallel("${name}")'s Merge` : `Merge "${name}"`} can never complete: every path into it `
201
+ + `comes from a different branch of ${j.splitKind} "${splitName}" (ports ${ports}). A Merge is a parallel join that `
202
+ + `waits for ALL its incoming paths, but a ${j.splitKind} takes exactly one branch, so the run stops at "${name}" `
203
+ + `and never reaches an End (\`uip maestro flow validate\` refuses the file for the same reason). `
204
+ + (isParallel
205
+ ? `Add a step after the .${method}("${splitName}") inside the arm, so its paths meet there and the arm hands the `
206
+ + `join one edge; or, if no other arm reaches the join, drop the .parallel and chain the steps.`
207
+ : `Remove the Merge step: the .${method}'s arms meet at ${next !== undefined ? `"${next}"` : 'the next step'} on their `
208
+ + `own, since a step accepts several incoming edges. Use a Merge only to join arms that run at the same time (.parallel).`),
209
+ suggestion: isParallel
210
+ ? `.parallel('${name}', [(a) => a.${method}('${splitName}', …).step('meet', …), …])`
211
+ : `.${method}('${splitName}', …)${next !== undefined ? `.step('${next}', …)` : ''}`,
212
+ step: [...scope.callers, name].join(' › '),
213
+ ...(scope.callers.length === 0 ? { nodeId: j.joinId } : {}),
214
+ });
215
+ }
216
+ }
217
+ return out;
218
+ }
147
219
  /** The error-level diagnostics a custom node's own `diagnostics()` reported (see `serializerRefusals`). */
148
220
  const OWN_NODE_ERRORS = new WeakSet();
149
221
  /**
@@ -163,13 +235,14 @@ const OWN_NODE_ERRORS = new WeakSet();
163
235
  */
164
236
  function serializerRefusals(built, compile, found) {
165
237
  const collected = [];
238
+ const scopes = [];
166
239
  const warned = [];
167
240
  let flow;
168
241
  let stoppedAt;
169
242
  try {
170
243
  // A stale `.layout()` key is the one serializer warning `check` repeats: compile
171
244
  // drops the entry, and the author can only see that here (#1994).
172
- flow = serialize(built, { ...compile, collect: (r) => collected.push(r), warn: (w) => { if (w.code === 'LAYOUT_UNKNOWN_KEY')
245
+ flow = serialize(built, { ...compile, collect: (r) => collected.push(r), scopes: (sc) => scopes.push(sc), warn: (w) => { if (w.code === 'LAYOUT_UNKNOWN_KEY')
173
246
  warned.push(w); } });
174
247
  // Collection stopped: the refusal that stopped it is the last one reported.
175
248
  const stop = collected[collected.length - 1];
@@ -217,7 +290,7 @@ function serializerRefusals(built, compile, found) {
217
290
  seen.add(key);
218
291
  out.push({ level: 'warning', code: w.code, message: w.message });
219
292
  }
220
- return { diagnostics: out, flow, ...(stoppedAt ? { stoppedAt } : {}) };
293
+ return { diagnostics: out, flow, scopes, ...(stoppedAt ? { stoppedAt } : {}) };
221
294
  }
222
295
  /**
223
296
  * `ancestors` is the chain of child flows currently being checked, innermost
@@ -2333,8 +2406,8 @@ const OUTPUT_READ_RULES = {
2333
2406
  * that was not taken, and the run stays Running with no incident. That was
2334
2407
  * measured live on 09-01 (a Merge fed by a Decision's two ports). An older note
2335
2408
  * here said such flows "deploy and run"; they deploy, and they do not finish.
2336
- * This function does NOT refuse that general shape yet — it predates the human
2337
- * task rule below and is tracked as its own SDK issue. It does refuse it when a
2409
+ * MERGE_NEVER_COMPLETES (`mergeNeverCompletes`) judges that shape on the
2410
+ * compiled graph. This function refuses it when a
2338
2411
  * human task's outcome edge is among the arm's alternative edges into the join
2339
2412
  * — a fan-out task at the arm's end, one empty `.stepSwitch` arm beside a body
2340
2413
  * arm, a task on one side of a `.branch` (HITL_FAN_OUT_INTO_JOIN) — and an
@@ -694,6 +694,22 @@ export interface ConnectorToolRef {
694
694
  version?: string;
695
695
  /** Disambiguate a generic operation by OBJECT, exactly as `connector()` does. */
696
696
  object?: string;
697
+ /**
698
+ * Values for the operation's fields, by field name, written over what compile
699
+ * derives for each: a body field the model decides (a `{{prompt: "..."}}`
700
+ * chip), a single-value enum's one value, or a query parameter's default. A
701
+ * value is written as given, so a fixed value pins the field, and a chip with
702
+ * other text changes what the model is told.
703
+ *
704
+ * ```ts
705
+ * { kind: 'connector', connector: 'uipath-uipath-airdk', operation: 'web-search',
706
+ * inputs: { num: 10 }, connection: 'genai', folder: 'shared' }
707
+ * ```
708
+ *
709
+ * A name the operation has no field for is refused
710
+ * (`FLOW_AGENT_TOOL_CONNECTOR_INPUT`).
711
+ */
712
+ inputs?: Record<string, unknown>;
697
713
  /** Display label; defaults to the library's own (e.g. `'Create Issue'`). */
698
714
  name?: string;
699
715
  /**
@@ -186,3 +186,18 @@ export interface ConfigurationIdentity {
186
186
  * @returns The object name and activity type, each only when it is a string.
187
187
  */
188
188
  export declare function readConfigurationIdentity(configuration: unknown): ConfigurationIdentity;
189
+ /**
190
+ * The object a connector node (a `connector()` step, or an agent's connector
191
+ * tool, which saves the same `inputs.detail`) addresses, when it is the author's choice: a
192
+ * GENERIC operation (`get-record` on `curated_issue`) names only the verb in its
193
+ * node type, so `compile` needs the object back as the `object` option
194
+ * (CONNECTOR_OBJECT_REQUIRED without it, #1614). A CURATED operation's node type
195
+ * is its object, so it gets none. A node whose configuration records no
196
+ * activity type keeps the object it names: compile accepts an object that
197
+ * matches a curated entry, and refuses one that does not, by name.
198
+ *
199
+ * The configuration is read by `readConfigurationIdentity`, which lives beside
200
+ * the writer (`buildConfiguration`); the node's sibling `objectName` is the
201
+ * fallback, as compile writes both.
202
+ */
203
+ export declare function liftedObject(detail: Record<string, unknown>): string | undefined;
@@ -433,3 +433,25 @@ export function readConfigurationIdentity(configuration) {
433
433
  ...(activityType !== undefined ? { activityType } : {}),
434
434
  };
435
435
  }
436
+ /**
437
+ * The object a connector node (a `connector()` step, or an agent's connector
438
+ * tool, which saves the same `inputs.detail`) addresses, when it is the author's choice: a
439
+ * GENERIC operation (`get-record` on `curated_issue`) names only the verb in its
440
+ * node type, so `compile` needs the object back as the `object` option
441
+ * (CONNECTOR_OBJECT_REQUIRED without it, #1614). A CURATED operation's node type
442
+ * is its object, so it gets none. A node whose configuration records no
443
+ * activity type keeps the object it names: compile accepts an object that
444
+ * matches a curated entry, and refuses one that does not, by name.
445
+ *
446
+ * The configuration is read by `readConfigurationIdentity`, which lives beside
447
+ * the writer (`buildConfiguration`); the node's sibling `objectName` is the
448
+ * fallback, as compile writes both.
449
+ */
450
+ export function liftedObject(detail) {
451
+ const identity = readConfigurationIdentity(detail.configuration);
452
+ if (identity.activityType === 'Curated')
453
+ return undefined;
454
+ if (identity.objectName !== undefined)
455
+ return identity.objectName;
456
+ return typeof detail.objectName === 'string' && detail.objectName !== '' ? detail.objectName : undefined;
457
+ }
@@ -0,0 +1,59 @@
1
+ /**
2
+ * MERGE_NEVER_COMPLETES: a Merge (a `bpmn:ParallelGateway`) waits for a token
3
+ * on every incoming edge, so when every edge into it comes from a different
4
+ * branch of one Decision or Switch, which sends one token, it never completes.
5
+ *
6
+ * d --true--> A --> join
7
+ * d --false-------> join `join` waits for two tokens; `d` sends one.
8
+ *
9
+ * The same walk as `uip maestro flow validate` (maestro-tool
10
+ * `flow-validate-service` `findUnsatisfiableJoin`), so check and validate
11
+ * refuse the same files.
12
+ */
13
+ export interface JoinNode {
14
+ id: string;
15
+ type?: string;
16
+ model?: {
17
+ type?: unknown;
18
+ };
19
+ display?: {
20
+ label?: unknown;
21
+ };
22
+ }
23
+ interface JoinEdge {
24
+ sourceNodeId: string;
25
+ sourcePort?: string;
26
+ targetNodeId: string;
27
+ }
28
+ /** One graph level: the root flow's nodes and edges, or one subflow's, with the file's definitions. */
29
+ export interface JoinGraph {
30
+ nodes?: readonly JoinNode[];
31
+ edges?: readonly JoinEdge[];
32
+ definitions?: ReadonlyArray<{
33
+ nodeType?: string;
34
+ model?: {
35
+ type?: unknown;
36
+ };
37
+ }>;
38
+ }
39
+ /** A Merge that can never complete, and the split whose branches all feed it. */
40
+ export interface UnsatisfiableJoin {
41
+ /** The Merge node's id and label (its id when it has none). */
42
+ joinId: string;
43
+ joinLabel: string;
44
+ /** The Decision or Switch node's id and label. */
45
+ splitId: string;
46
+ splitLabel: string;
47
+ splitKind: 'Decision' | 'Switch';
48
+ /** The split's ports the Merge's incoming paths leave by, sorted. */
49
+ ports: string[];
50
+ }
51
+ /** Whether a node is a Decision or a Switch, and which; `undefined` for any other node. */
52
+ export type SplitOf = (node: JoinNode, modelType: unknown) => 'Decision' | 'Switch' | undefined;
53
+ /**
54
+ * Every Merge of one graph level that can never complete, in node order.
55
+ * `splitOf` names the exclusive splits; by default only a `bpmn:ExclusiveGateway`
56
+ * model type is one (reported as a Decision, as validate words it).
57
+ */
58
+ export declare function unsatisfiableJoins(graph: JoinGraph, splitOf?: SplitOf): UnsatisfiableJoin[];
59
+ export {};
@@ -0,0 +1,78 @@
1
+ /**
2
+ * MERGE_NEVER_COMPLETES: a Merge (a `bpmn:ParallelGateway`) waits for a token
3
+ * on every incoming edge, so when every edge into it comes from a different
4
+ * branch of one Decision or Switch, which sends one token, it never completes.
5
+ *
6
+ * d --true--> A --> join
7
+ * d --false-------> join `join` waits for two tokens; `d` sends one.
8
+ *
9
+ * The same walk as `uip maestro flow validate` (maestro-tool
10
+ * `flow-validate-service` `findUnsatisfiableJoin`), so check and validate
11
+ * refuse the same files.
12
+ */
13
+ /**
14
+ * Every Merge of one graph level that can never complete, in node order.
15
+ * `splitOf` names the exclusive splits; by default only a `bpmn:ExclusiveGateway`
16
+ * model type is one (reported as a Decision, as validate words it).
17
+ */
18
+ export function unsatisfiableJoins(graph, splitOf = (_n, model) => (model === 'bpmn:ExclusiveGateway' ? 'Decision' : undefined)) {
19
+ const nodes = Array.isArray(graph.nodes) ? graph.nodes : [];
20
+ const edges = Array.isArray(graph.edges) ? graph.edges : [];
21
+ const modelByType = new Map();
22
+ for (const def of Array.isArray(graph.definitions) ? graph.definitions : []) {
23
+ if (typeof def?.nodeType === 'string' && typeof def.model?.type === 'string')
24
+ modelByType.set(def.nodeType, def.model.type);
25
+ }
26
+ const modelType = (n) => (typeof n.model?.type === 'string' ? n.model.type : modelByType.get(n.type ?? ''));
27
+ const byId = new Map(nodes.map((n) => [n.id, n]));
28
+ const incoming = new Map();
29
+ for (const e of edges) {
30
+ const list = incoming.get(e.targetNodeId) ?? [];
31
+ list.push(e);
32
+ incoming.set(e.targetNodeId, list);
33
+ }
34
+ const isJoin = (n) => modelType(n) === 'bpmn:ParallelGateway';
35
+ const isSplit = (n) => splitOf(n, modelType(n)) !== undefined;
36
+ /** The split this edge's path leaves, and by which port, when the walk reaches one. */
37
+ const originOf = (edge) => {
38
+ let current = edge;
39
+ const seen = new Set();
40
+ while (current !== undefined && !seen.has(current.sourceNodeId)) {
41
+ const source = byId.get(current.sourceNodeId);
42
+ if (!source)
43
+ return undefined;
44
+ seen.add(source.id);
45
+ if (isSplit(source))
46
+ return { splitId: source.id, port: current.sourcePort };
47
+ const up = incoming.get(source.id) ?? [];
48
+ current = up.length === 1 ? up[0] : undefined;
49
+ }
50
+ return undefined;
51
+ };
52
+ const found = [];
53
+ for (const node of nodes) {
54
+ if (!isJoin(node))
55
+ continue;
56
+ const into = incoming.get(node.id) ?? [];
57
+ if (into.length < 2)
58
+ continue;
59
+ const origins = into.map(originOf);
60
+ if (origins.some((o) => o === undefined))
61
+ continue;
62
+ const resolved = origins;
63
+ if (new Set(resolved.map((o) => o.splitId)).size !== 1)
64
+ continue;
65
+ const ports = [...new Set(resolved.map((o) => String(o.port)))].sort((a, b) => a.localeCompare(b));
66
+ if (ports.length < 2)
67
+ continue;
68
+ const split = byId.get(resolved[0].splitId);
69
+ const label = (n) => (typeof n.display?.label === 'string' ? n.display.label : n.id);
70
+ found.push({
71
+ joinId: node.id, joinLabel: label(node),
72
+ splitId: split.id, splitLabel: label(split),
73
+ splitKind: splitOf(split, modelType(split)) ?? 'Decision',
74
+ ports,
75
+ });
76
+ }
77
+ return found;
78
+ }
@@ -542,6 +542,7 @@ export declare const REFUSALS: {
542
542
  readonly FLOW_AGENT_TOOL_CLIENTSIDE_NO_NAME: "lint";
543
543
  readonly FLOW_AGENT_TOOL_CLIENTSIDE_SCHEMA_TWICE: "lowering";
544
544
  readonly FLOW_AGENT_TOOL_CONNECTOR_NO_CONNECTION: "lint";
545
+ readonly FLOW_AGENT_TOOL_CONNECTOR_INPUT: "lowering";
545
546
  readonly FLOW_AGENT_TOOL_HTTP_METHOD: "lint";
546
547
  readonly FLOW_AGENT_TOOL_IXP_NO_NAME: "lint";
547
548
  readonly FLOW_AGENT_TOOL_IXP_PROJECT_NOT_GUID: "lint";
@@ -617,6 +618,7 @@ export declare const REFUSALS: {
617
618
  readonly LOOP_PARALLEL_LEGACY: "lint";
618
619
  readonly LOOP_VERSION_UNSUPPORTED: "lowering";
619
620
  readonly MANAGED_HTTP_ABSOLUTE_URL: "lint";
621
+ readonly MERGE_NEVER_COMPLETES: "lint";
620
622
  readonly METHOD_MISSING_PARENTHESES: "lint";
621
623
  readonly MISSING_CONDITION_EXPRESSION: "lint";
622
624
  readonly MISSING_RESOURCE: "lint";
@@ -618,6 +618,7 @@ export const REFUSALS = {
618
618
  FLOW_AGENT_TOOL_CLIENTSIDE_NO_NAME: 'lint',
619
619
  FLOW_AGENT_TOOL_CLIENTSIDE_SCHEMA_TWICE: 'lowering',
620
620
  FLOW_AGENT_TOOL_CONNECTOR_NO_CONNECTION: 'lint',
621
+ FLOW_AGENT_TOOL_CONNECTOR_INPUT: 'lowering',
621
622
  FLOW_AGENT_TOOL_HTTP_METHOD: 'lint',
622
623
  FLOW_AGENT_TOOL_IXP_NO_NAME: 'lint',
623
624
  FLOW_AGENT_TOOL_IXP_PROJECT_NOT_GUID: 'lint',
@@ -693,6 +694,7 @@ export const REFUSALS = {
693
694
  LOOP_PARALLEL_LEGACY: 'lint',
694
695
  LOOP_VERSION_UNSUPPORTED: 'lowering',
695
696
  MANAGED_HTTP_ABSOLUTE_URL: 'lint',
697
+ MERGE_NEVER_COMPLETES: 'lint',
696
698
  METHOD_MISSING_PARENTHESES: 'lint',
697
699
  MISSING_CONDITION_EXPRESSION: 'lint',
698
700
  MISSING_RESOURCE: 'lint',
package/dist/decompile.js CHANGED
@@ -827,6 +827,16 @@ function liftRegistered(node, impl = registeredImpl(node), graph) {
827
827
  flowId: runFlowId,
828
828
  definitionOf: (n) => runDefs.get(`${n.type}@${n.typeVersion}`) ?? runDefs.get(n.type),
829
829
  carriesOperation: () => runCarriedOperations.has(`${node.type}@${version}`),
830
+ connectorOperation: (key, action, v, object) => {
831
+ if (runLibrary === undefined || !runLibrary.indexes(`uipath.connector.${key}.${action}`, object))
832
+ return undefined;
833
+ try {
834
+ return runLibrary.resolve(key, action, v, object);
835
+ }
836
+ catch {
837
+ return undefined;
838
+ }
839
+ },
830
840
  attached: (port, limit = Infinity, accept = () => true) => {
831
841
  const found = [];
832
842
  for (const e of graph?.outEdges(node.id) ?? []) {
@@ -19,6 +19,7 @@ import type { CheckOpts } from './check.js';
19
19
  import type { SerializeOpts } from './serialize.js';
20
20
  import type { DeclaredExit, ExitRouting, NoExits } from './core/step-ports.js';
21
21
  import type { EventEmitEnv } from './core/event-subscription.js';
22
+ import type { ResolvedConnector } from './core/library.js';
22
23
  /**
23
24
  * What a Flow node type's `serialize` returns: the node's type-owned fields.
24
25
  *
@@ -352,6 +353,14 @@ export interface FlowDeserializeContext {
352
353
  * other node.
353
354
  */
354
355
  carriesOperation(): boolean;
356
+ /**
357
+ * The connector operation decompile's library resolves `key` / `action` to,
358
+ * at `version` and for `object`: the entry compile resolves the same names
359
+ * against. `undefined` when decompile has no library, or the library has no
360
+ * such entry. For instance an agent's connector tool lift reads which field
361
+ * values compile derives, to print only the ones the file changed.
362
+ */
363
+ connectorOperation?(key: string, action: string, version?: string, object?: string): ResolvedConnector | undefined;
355
364
  /**
356
365
  * The nodes attached to this one on an artifact handle (`tool`, `context`,
357
366
  * `escalation`, `memory`), in edge order, at most `limit` of them. Their edges
@@ -66,6 +66,7 @@ export const AGENT_DIAGNOSTICS = {
66
66
  FLOW_AGENT_TOOL_CLIENTSIDE_NO_NAME: { severity: 'error', summary: 'a client-side tool with no name' },
67
67
  FLOW_AGENT_TOOL_CLIENTSIDE_SCHEMA_TWICE: { severity: 'error', summary: 'a client-side tool given both inputs and inputSchema (or returns and outputSchema)' },
68
68
  FLOW_AGENT_TOOL_CONNECTOR_NO_CONNECTION: { severity: 'error', summary: 'a connector tool with no connection or folder' },
69
+ FLOW_AGENT_TOOL_CONNECTOR_INPUT: { severity: 'error', summary: 'a connector tool input naming a field the operation does not have' },
69
70
  FLOW_AGENT_TOOL_HTTP_METHOD: { severity: 'error', summary: 'an HTTP-request tool with an unknown method' },
70
71
  FLOW_AGENT_TOOL_IXP_NO_NAME: { severity: 'error', summary: 'an IxP tool with no name' },
71
72
  FLOW_AGENT_TOOL_IXP_PROJECT_NOT_GUID: { severity: 'error', summary: 'an IxP tool whose projectId is not a uuid' },
@@ -18,16 +18,49 @@ import { derivedContextSource, derivedEscalationSource, derivedResourceNodeId, d
18
18
  import { CONTEXT_INDEX_DEFAULTS, CONTEXT_INDEX_DEFAULT_FILE_EXTENSION, contextIndexSlug, parseContextIndexType, } from '../../../core/context-index.js';
19
19
  import { Expr, flatNameOf, flatNameReference } from '../../../core/expr.js';
20
20
  import { formFieldRowExtra, formFieldRowLoss, formFieldRowLossMessage, formFieldSettingsSource, liftFormFieldSettings, sourceFormFieldType, } from '../../../core/form-field-type.js';
21
+ import { missingBindingLabels } from '../../../core/binding-messages.js';
22
+ import { prepareCommand } from '../../../core/cli-spelling.js';
23
+ import { liftedObject } from '../../../core/connector-configuration.js';
21
24
  import { ownEntry } from '../../../core/own-entry.js';
22
25
  import { isInlineAgentFieldType, jsonPathKey, jsonPathSegments } from '../../../core/tool-argument.js';
23
26
  import { tsKey as key, tsLiteral, tsNumber, tsObject as objLit, tsOptions as opts, tsText } from '../../../core/ts-literal.js';
24
27
  import { wireExprBody } from '../../../core/wire-expr.js';
25
28
  import { liftBatchTransformTool, reportUnreadBuiltinTask } from './builtin-tool-lift.js';
26
29
  import { resourceSidecar } from './resource-sidecar.js';
27
- import { BUILTIN_TOOL_DEFS, builtinToolRevision, escalationDef, voiceAgentRevision } from './resources.js';
30
+ import { BUILTIN_TOOL_DEFS, builtinToolRevision, connectorToolDetail, escalationDef, voiceAgentRevision } from './resources.js';
28
31
  /** Where the agent's own `inputs` go in the option list: the printer writes them, as expressions. */
29
32
  const INPUT_ROWS = Symbol('inputs');
30
33
  const isObject = (v) => !!v && typeof v === 'object' && !Array.isArray(v);
34
+ /**
35
+ * A connector tool's `inputs`: the field values in its saved `inputs.detail`
36
+ * that compile would not write on its own. With the library entry compile
37
+ * resolves (`rc`), only the values that differ from what it derives
38
+ * (`connectorToolDetail`) are printed, so a compile-written tool prints none.
39
+ * Without one every saved value is printed, so nothing is lost. A saved field
40
+ * the entry does not have is reported, since compile refuses it.
41
+ * For instance a Web Search saved with `num: 10` prints `inputs: { num: 10 }`.
42
+ */
43
+ function connectorToolInputs(t, detail, rc, ctx) {
44
+ const derived = rc === undefined ? undefined : connectorToolDetail(rc, undefined, undefined, '');
45
+ const entries = [];
46
+ for (const bucket of ['bodyParameters', 'queryParameters', 'pathParameters']) {
47
+ const saved = detail[bucket];
48
+ if (!saved || typeof saved !== 'object' || Array.isArray(saved))
49
+ continue;
50
+ const own = derived?.[bucket];
51
+ for (const [name, value] of Object.entries(saved)) {
52
+ if (derived !== undefined && (own === undefined || !Object.prototype.hasOwnProperty.call(own, name))) {
53
+ ctx.lossy(`connector tool ${JSON.stringify(t.id)} sets ${bucket}.${name}, a field its library entry does not have; `
54
+ + 'the source leaves it out, and a recompile drops it.');
55
+ continue;
56
+ }
57
+ if (own !== undefined && JSON.stringify(own[name]) === JSON.stringify(value))
58
+ continue;
59
+ entries.push([name, dataSource(value)]);
60
+ }
61
+ }
62
+ return entries.length === 0 ? undefined : objLit(entries);
63
+ }
31
64
  /** The per-instance resource tool kinds (process / api / flow / maestro / agent / function), by node-type prefix. */
32
65
  const PROCESS_NS = [
33
66
  ['uipath.agent.resource.tool.processorchestration.', 'maestro'],
@@ -56,6 +89,7 @@ function liftableToolFor(agentType) {
56
89
  return def !== undefined && builtinToolRevision(def, hostOf(agentType), String(n.typeVersion ?? '')) !== undefined;
57
90
  }
58
91
  return t === 'uipath.agent.resource.tool.clientside'
92
+ || connectorToolOperation(t) !== undefined
59
93
  || ['mcp.', 'a2a.', 'ixp.'].some((k) => t.startsWith(`uipath.agent.resource.tool.${k}`))
60
94
  || PROCESS_NS.some(([prefix]) => t.startsWith(prefix));
61
95
  };
@@ -76,6 +110,21 @@ function liftableEscalationFor(agentType) {
76
110
  };
77
111
  }
78
112
  const QUICK_FORM_ESCALATION = 'uipath.agent.resource.escalation.quick-form';
113
+ const CONNECTOR_TOOL_PREFIX = 'uipath.agent.resource.tool.connector.';
114
+ /**
115
+ * The connector key and operation a connector tool's node type names, the
116
+ * inverse of `connectorToolDef` (`uipath.agent.resource.tool.connector.<key>.<op>`,
117
+ * the same tail as a `connector()` step's `uipath.connector.<key>.<op>`). For
118
+ * instance `….connector.uipath-uipath-airdk.web-search` is
119
+ * `{ connector: 'uipath-uipath-airdk', operation: 'web-search' }`.
120
+ */
121
+ function connectorToolOperation(type) {
122
+ if (!type.startsWith(CONNECTOR_TOOL_PREFIX))
123
+ return undefined;
124
+ const rest = type.slice(CONNECTOR_TOOL_PREFIX.length);
125
+ const dot = rest.lastIndexOf('.');
126
+ return dot <= 0 || dot === rest.length - 1 ? undefined : { connector: rest.slice(0, dot), operation: rest.slice(dot + 1) };
127
+ }
79
128
  const BUILTIN_PREFIX = 'uipath.agent.resource.tool.builtin.';
80
129
  const VOICE_AGENT_TYPE = 'uipath.agent.voice';
81
130
  /** The resource host an agent of node type `agentType` is. */
@@ -860,6 +909,50 @@ export function liftAgentResources(node, ctx, withMemory, agentInputs = []) {
860
909
  ['name', tsLiteral(rPlain(t, 'name') ?? '')],
861
910
  ]);
862
911
  }
912
+ const op = connectorToolOperation(type);
913
+ if (op !== undefined) {
914
+ // A connector tool: the operation is the node type's tail, the revision its
915
+ // `typeVersion`, and the connection and folder the ones its `inputs.detail`
916
+ // names, read as a `connector()` step's lift reads them.
917
+ const detail = (ti.detail !== null && typeof ti.detail === 'object' && !Array.isArray(ti.detail)
918
+ ? ti.detail : {});
919
+ const label = (v) => (typeof v === 'string' && v !== '' ? v : undefined);
920
+ const connection = label(detail.connectionId);
921
+ const folder = label(detail.connectionFolderKey);
922
+ const missing = missingBindingLabels({ connection, folder });
923
+ if (missing.length > 0) {
924
+ ctx.warn(`connector tool ${JSON.stringify(t.id)} on agent ${JSON.stringify(node.id)} has no ${missing.join(' or ')} `
925
+ + `in the .flow. The source leaves ${missing.length > 1 ? 'them' : 'it'} out, and check refuses the tool `
926
+ + `(FLOW_AGENT_TOOL_CONNECTOR_NO_CONNECTION) until it names both labels: run `
927
+ + `\`${prepareCommand(op.connector, op.operation)}\`, then pass \`connection\` and \`folder\`.`);
928
+ }
929
+ // Compile labels the node with the library's label and describes it with
930
+ // the library's text (`connectorToolDef`, `connectorToolDescription`); the
931
+ // definition the file carries for the node is that library entry, so a
932
+ // label or description that differs from it is the author's.
933
+ const def = ctx.definitionOf(t);
934
+ const defLabel = label(def?.display?.label);
935
+ const defDescription = label(def?.display?.description)?.replace(/^\([^)]*\) /, '');
936
+ const name = label(t.display?.label);
937
+ const description = label(t.display?.description);
938
+ // Always pinned: compile resolves an unpinned tool against the library's
939
+ // current revision, which need not be the one the file saved.
940
+ const version = label(t.typeVersion);
941
+ const object = liftedObject(detail);
942
+ const inputs = connectorToolInputs(t, detail, ctx.connectorOperation?.(op.connector, op.operation, version, object), ctx);
943
+ return toolOpts(t, { kind: 'connector', ...op }, [
944
+ ['kind', tsLiteral('connector')],
945
+ ['connector', tsLiteral(op.connector)],
946
+ ['operation', tsLiteral(op.operation)],
947
+ ['version', version !== undefined ? tsLiteral(version) : undefined],
948
+ ['object', object !== undefined ? tsLiteral(object) : undefined],
949
+ ['inputs', inputs],
950
+ ['name', name !== undefined && name !== defLabel ? tsLiteral(name) : undefined],
951
+ ['description', description !== undefined && description !== defDescription ? tsLiteral(description) : undefined],
952
+ ['connection', connection !== undefined ? tsLiteral(connection) : undefined],
953
+ ['folder', folder !== undefined ? tsLiteral(folder) : undefined],
954
+ ]);
955
+ }
863
956
  // The per-instance resource kinds (process / api / flow / maestro / agent /
864
957
  // function): the key is the node type's tail, the rest is a binding pair.
865
958
  const ns = PROCESS_NS.find(([prefix]) => type.startsWith(prefix));
@@ -182,6 +182,27 @@ export function serializeInlineAgent(s, ctx) {
182
182
  attach,
183
183
  };
184
184
  }
185
+ /**
186
+ * Write a connector tool's `inputs` over the request buckets compile derived
187
+ * (`connectorToolDetail`), each into the bucket its field lives in. A name no
188
+ * bucket holds is a field the operation does not have, refused rather than
189
+ * dropped. For instance `{ num: 10 }` on Web Search sets
190
+ * `detail.bodyParameters.num` to `10` in place of its prompt chip.
191
+ */
192
+ function applyConnectorToolInputs(detail, inputs, where) {
193
+ if (inputs === undefined)
194
+ return;
195
+ const buckets = ['bodyParameters', 'queryParameters', 'pathParameters'].filter((b) => detail[b] && typeof detail[b] === 'object');
196
+ for (const [name, value] of Object.entries(inputs)) {
197
+ const bucket = buckets.find((b) => Object.prototype.hasOwnProperty.call(detail[b], name));
198
+ if (bucket === undefined) {
199
+ const known = buckets.flatMap((b) => Object.keys(detail[b]));
200
+ throw new CompileRefusal('FLOW_AGENT_TOOL_CONNECTOR_INPUT', `${where} sets input ${JSON.stringify(name)}, which the operation has no field for. `
201
+ + `Its fields: ${known.length ? known.map((k) => JSON.stringify(k)).join(', ') : '(none)'}.`);
202
+ }
203
+ detail[bucket][name] = jsonClone(value);
204
+ }
205
+ }
185
206
  /**
186
207
  * Each process tool's arguments, and each built-in's task and settings, judged
187
208
  * before the agent's resources are attached: `toolArgument` is the first one
@@ -480,6 +501,7 @@ export function attachAgentResources(s, ctx, source, who, toolVariables = new Ma
480
501
  ...(folder !== undefined ? { folderKey: folder } : {}),
481
502
  });
482
503
  const detail = connectorToolDetail(rc, conn, folder, `${step}Tool`);
504
+ applyConnectorToolInputs(detail, tr.inputs, where);
483
505
  extraInputs = { detail };
484
506
  connectorTool = {
485
507
  rc, detail, name: label,
@@ -2,7 +2,7 @@ import { CONNECTOR_OPTION_KEYS } from '../../../core/connector-option-keys.js';
2
2
  import { BindingRefusal, bindingMissingMessage, missingBindingLabels } from '../../../core/binding-messages.js';
3
3
  import { PULL_COMMAND, prepareCommand } from '../../../core/cli-spelling.js';
4
4
  import { carriedConnector, carriedDefinitionMismatch, carriedOperationOf, carriedOperationRefusal, } from '../../../core/carried-connector-operation.js';
5
- import { buildConfiguration, readConfigurationIdentity } from '../../../core/connector-configuration.js';
5
+ import { buildConfiguration, liftedObject } from '../../../core/connector-configuration.js';
6
6
  import { libraryExecution } from '../../../core/external-execution.js';
7
7
  import { CONNECTOR_INPUT_MISSING, FLOW_EXPR_DIALECT, buildConnectorInputs, replayInputsOf, transportHttpMethod } from '../../../core/connector-inputs.js';
8
8
  import { ConnectorResolveError } from '../../../core/connector-resolve-error.js';
@@ -297,27 +297,6 @@ function liftValue(v, ctx) {
297
297
  return v;
298
298
  return raw.startsWith('=js:') ? new Expr(raw.slice(4)) : raw;
299
299
  }
300
- /**
301
- * The object a connector node addresses, when it is the author's choice: a
302
- * GENERIC operation (`get-record` on `curated_issue`) names only the verb in its
303
- * node type, so `compile` needs the object back as the `object` option
304
- * (CONNECTOR_OBJECT_REQUIRED without it, #1614). A CURATED operation's node type
305
- * is its object, so it gets none. A node whose configuration records no
306
- * activity type keeps the object it names: compile accepts an object that
307
- * matches a curated entry, and refuses one that does not, by name.
308
- *
309
- * The configuration is read by `readConfigurationIdentity`, which lives beside
310
- * the writer (`buildConfiguration`); the node's sibling `objectName` is the
311
- * fallback, as compile writes both.
312
- */
313
- function liftedObject(detail) {
314
- const identity = readConfigurationIdentity(detail.configuration);
315
- if (identity.activityType === 'Curated')
316
- return undefined;
317
- if (identity.objectName !== undefined)
318
- return identity.objectName;
319
- return typeof detail.objectName === 'string' && detail.objectName !== '' ? detail.objectName : undefined;
320
- }
321
300
  function liftConnector(node, ctx) {
322
301
  const n = node;
323
302
  const split = splitOperation(n.type);