@uipath/maestro-builder-sdk 6.16.9 → 6.16.10

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.
@@ -21,7 +21,7 @@ import { reportDiagnostics, reportResult } from './cli-result.js';
21
21
  import { writeFileSync, existsSync, mkdirSync, readdirSync, readFileSync, rmSync } from 'node:fs';
22
22
  import { basename, dirname, join, resolve } from 'node:path';
23
23
  import { resolveFlowFile, loadBuiltFlow } from './load.js';
24
- import { serializeWithSidecars, connectorInputErrors } from './serialize.js';
24
+ import { serializeWithSidecars, connectorInputErrors, compileOwnsResource } from './serialize.js';
25
25
  import { check } from './check.js';
26
26
  import { byoaCheckOpts, eventResolveErrorFor, openCliLibrary } from './cli-library.js';
27
27
  import { Bindings } from './bindings.js';
@@ -31,32 +31,6 @@ import { ensureTypeScriptRuntime } from './node-runtime.js';
31
31
  import { defaultBindingsFile } from './workdir.js';
32
32
  import { BindingRefusal } from './core/binding-messages.js';
33
33
  import { ByoaRefusal } from './core/byoa.js';
34
- /**
35
- * The tool `type` values `compile` writes. NOT every `$resourceType: 'tool'`:
36
- * the designer writes kinds the SDK cannot derive into the same directory, so
37
- * pruning by `$resourceType` alone would delete theirs.
38
- *
39
- * `integration` (connector tools) is compile's since #867: compile writes the
40
- * file under the tool node's own `source` id, the same id and content `uip agent
41
- * refresh --inline-in-flow` derives from that node, so a file under any other id
42
- * belongs to a tool node the flow no longer has.
43
- */
44
- const COMPILE_OWNED_TOOL_TYPES = new Set([
45
- 'process', 'api', 'processOrchestration', 'flow', 'agent', 'function', 'integration',
46
- ]);
47
- /**
48
- * Does `compile` own this resource file — i.e. would this run have written it,
49
- * so an unwritten one is stale rather than someone else's?
50
- *
51
- * Everything it says no to belongs to the designer (escalation, mcp, and the
52
- * kinds the SDK cannot derive).
53
- */
54
- function compileOwnsResource(body) {
55
- const kind = body?.$resourceType;
56
- if (kind === 'context')
57
- return true;
58
- return kind === 'tool' && COMPILE_OWNED_TOOL_TYPES.has(String(body?.type));
59
- }
60
34
  export async function run(argv) {
61
35
  if (argv.length === 0 || argv[0] === '-h' || argv[0] === '--help') {
62
36
  console.error('usage: compile <flow.ts | BaseName> [-o out.flow] [--library <dir>] [--bindings <file>]');
@@ -201,10 +175,11 @@ export async function run(argv) {
201
175
  // gone. Measured 2026-09-25 — compile with a context, remove it, recompile:
202
176
  // the file survives and refresh still reports `Resources: 1`.
203
177
  //
204
- // Only the types THIS compile emits are pruned. `uip agent refresh` generates
205
- // connector-tool resources into the same directory, and the designer writes
206
- // the families the SDK cannot, so anything else found there is someone else's
207
- // and is left alone.
178
+ // Only the types THIS compile emits are pruned — `compileOwnsResource`, which
179
+ // lives beside the writers and reads their tables. The designer writes the
180
+ // families the SDK cannot into the same directory (including `internal`
181
+ // built-ins such as `load-attachments`), so anything else found there is
182
+ // someone else's and is left alone.
208
183
  const staleBindings = [];
209
184
  const owned = new Set(sidecars
210
185
  .filter((s) => /\/resources\/[^/]+\/resource\.json$/.test(s.path))
@@ -238,7 +213,9 @@ export async function run(argv) {
238
213
  const key = typeof named === 'string' && named !== '' ? named : undefined;
239
214
  // A connector tool's binding is a `connection` row, and `mergeBindingsV2`
240
215
  // re-derives every connection row from the flow below — nothing to retract.
241
- if (key !== undefined && body?.type !== 'integration') {
216
+ // A built-in (`internal`) tool binds nothing at all: retracting a `process`
217
+ // row under its label could only remove a real process tool's binding.
218
+ if (key !== undefined && body?.type !== 'integration' && body?.type !== 'internal') {
242
219
  // Keyed the way refresh keys it: an index by its name, a deployed-resource
243
220
  // tool under `process` whatever its own type says.
244
221
  staleBindings.push({ resource: resourceType === 'context' ? 'index' : 'process', key });
@@ -11,6 +11,31 @@ import { connectorInputErrors as coreConnectorInputErrors } from './core/connect
11
11
  * dropping it would make `check` quietly accept what `compile` throws on.
12
12
  */
13
13
  export declare function connectorInputErrors(rc: Parameters<typeof coreConnectorInputErrors>[0], inputs: Record<string, unknown>, resolutions?: Parameters<typeof coreConnectorInputErrors>[2], lookups?: Parameters<typeof coreConnectorInputErrors>[3]): string | undefined;
14
+ /**
15
+ * Every tool resource identity `compile` writes, read off the tables its
16
+ * writers use — so a tool kind cannot be written without being owned, or owned
17
+ * without being written (#935: the #920 built-in files were written as
18
+ * `internal` and never pruned, because ownership was a hand-kept list in
19
+ * `compile-cli.ts` that did not have them).
20
+ *
21
+ * * `types` — the resource `type`s compile owns OUTRIGHT: every deployed-resource
22
+ * kind's, and `integration` (connector tools, since #867).
23
+ * * `internalToolTypes` — `internal` is shared with designer-only built-ins
24
+ * (`load-attachments`, `create-file`, `jev-classifier`), so for it ownership
25
+ * is the `properties.toolType`, and only the ones compile writes.
26
+ */
27
+ export declare const COMPILE_WRITTEN_TOOL_RESOURCES: {
28
+ readonly types: ReadonlySet<string>;
29
+ readonly internalToolTypes: ReadonlySet<string>;
30
+ };
31
+ /**
32
+ * Does `compile` own this `resources/<id>/resource.json` — would a compile have
33
+ * written it, so one this compile did not write is stale rather than someone
34
+ * else's? Everything it says no to belongs to the designer or to `uip agent
35
+ * refresh` (escalation, mcp, designer-only built-ins, the kinds the SDK cannot
36
+ * derive), and is never deleted.
37
+ */
38
+ export declare function compileOwnsResource(body: Record<string, unknown> | undefined): boolean;
14
39
  /**
15
40
  * A compile-time observation that does not stop emission. `check()` has its
16
41
  * diagnostics; this is the serializer's own channel for things it can only see
package/dist/serialize.js CHANGED
@@ -976,6 +976,16 @@ const TOOL_RESOURCE_TYPE = {
976
976
  process: 'process', api: 'api', maestro: 'processOrchestration',
977
977
  flow: 'flow', agent: 'agent', function: 'function',
978
978
  };
979
+ /** The resource `type` of a connector tool's file ({@link connectorToolResourceJson}). */
980
+ const CONNECTOR_TOOL_RESOURCE_TYPE = 'integration';
981
+ /**
982
+ * The resource `type` of every platform built-in tool. Shared with tools the
983
+ * DESIGNER writes and the SDK cannot (`load-attachments`, `create-file`, …), so
984
+ * on its own it says nothing about who owns a file: `properties.toolType` does.
985
+ */
986
+ const INTERNAL_TOOL_RESOURCE_TYPE = 'internal';
987
+ /** The `properties.toolType` of the built-in HTTP-request tool's file (#935). */
988
+ const HTTP_REQUEST_TOOL_TYPE = 'http-request';
979
989
  /**
980
990
  * The `resources/<id>/resource.json` a DEPLOYED-RESOURCE tool needs — the tool
981
991
  * half of what `contextResourceJson` does for an index, and inert for the same
@@ -1005,8 +1015,12 @@ const TOOL_RESOURCE_TYPE = {
1005
1015
  * card, which are tenant reads.
1006
1016
  * * `builtin` — has its own writer, {@link builtinToolResourceJson}: its
1007
1017
  * `toolType` is a fixed per-tool constant, so the file is derivable offline.
1008
- * * `httpRequest` — its `http-request` toolType carries no request config in
1009
- * the file, while the node carries all of it; not measured, so not written.
1018
+ * * `httpRequest` — has its own writer, {@link httpRequestToolResourceJson}:
1019
+ * the file carries the request config as static `argumentProperties` and the
1020
+ * model-facing `inputSchema`, both derivable from the node (#935).
1021
+ *
1022
+ * Which `type`/`toolType` values compile writes — and so owns and may prune —
1023
+ * is {@link compileOwnsResource}, read off the same tables these writers use.
1010
1024
  */
1011
1025
  function toolResourceJson(tr, spec) {
1012
1026
  const common = {
@@ -1107,7 +1121,7 @@ function builtinToolResourceJson(tool, label, inputs, spec) {
1107
1121
  // Null, not absent: what identifies a built-in as NOT an external tool.
1108
1122
  referenceKey: null,
1109
1123
  name: label,
1110
- type: 'internal',
1124
+ type: INTERNAL_TOOL_RESOURCE_TYPE,
1111
1125
  description: String(inputs.description ?? ''),
1112
1126
  isEnabled: true,
1113
1127
  settings: {},
@@ -1197,6 +1211,102 @@ function builtinToolResourceJson(tool, label, inputs, spec) {
1197
1211
  },
1198
1212
  };
1199
1213
  }
1214
+ /**
1215
+ * The six request fields of the HTTP-request tool, in the node's (and the
1216
+ * designer's file's) order, with the JSON Schema each takes in the file's
1217
+ * model-facing `inputSchema`. `headers`/`params` are name/value rows and
1218
+ * `timeout` is a number — the same normalization the node's text-builder
1219
+ * values already carry.
1220
+ */
1221
+ const HTTP_REQUEST_FIELDS = [
1222
+ ['url', { type: 'string' }],
1223
+ ['method', { type: 'string' }],
1224
+ ['headers', { type: 'array', items: { type: 'object', properties: { name: { type: 'string' }, value: { type: 'string' } } } }],
1225
+ ['params', { type: 'array', items: { type: 'object', properties: { name: { type: 'string' }, value: { type: 'string' } } } }],
1226
+ ['body', { type: 'string' }],
1227
+ ['timeout', { type: 'number' }],
1228
+ ];
1229
+ /**
1230
+ * The `resources/<id>/resource.json` of the built-in HTTP-request tool (#935) —
1231
+ * without it the deployed agent is never offered the tool (measured: one LLM
1232
+ * call, no tool span), and `uip agent refresh --inline-in-flow` strips the node
1233
+ * to `{source}`, so the request config is lost entirely.
1234
+ *
1235
+ * Derived from the node's own mode-tagged inputs, so the two halves cannot
1236
+ * disagree. The rules are the ones Studio Web's own file follows (measured by
1237
+ * saving the agent once in the designer; a file built by these rules is
1238
+ * JSON-equal to it, and a debug run with only this file showed the tool spans):
1239
+ *
1240
+ * * `inputSchema` declares all six fields, each with the node's `promptValue`
1241
+ * as its description — the text the model reads when it fills the field;
1242
+ * * `argumentProperties` pins every field NOT in `prompt` mode as
1243
+ * `$['<field>']: {variant: 'static', value: <textValue>}` — a fixed value the
1244
+ * model does not get to choose. The SDK writes only `prompt` and
1245
+ * `text-builder` fields; a `text-builder` value is the literal.
1246
+ */
1247
+ function httpRequestToolResourceJson(label, inputs, spec) {
1248
+ const properties = {};
1249
+ const argumentProperties = {};
1250
+ for (const [field, schema] of HTTP_REQUEST_FIELDS) {
1251
+ const row = (inputs[field] ?? {});
1252
+ properties[field] = { ...schema, description: String(row.promptValue ?? '') };
1253
+ if (row.mode !== undefined && row.mode !== 'prompt') {
1254
+ argumentProperties[`$['${field}']`] = { variant: 'static', value: row.textValue, isSensitive: false };
1255
+ }
1256
+ }
1257
+ return {
1258
+ $resourceType: 'tool',
1259
+ id: spec.id,
1260
+ canvasNodeId: spec.canvasNodeId,
1261
+ name: label,
1262
+ type: INTERNAL_TOOL_RESOURCE_TYPE,
1263
+ description: String(inputs.description ?? ''),
1264
+ isEnabled: true,
1265
+ inputSchema: { type: 'object', properties, required: ['url'] },
1266
+ outputSchema: { type: 'object', properties: {} },
1267
+ settings: {},
1268
+ guardrail: { policies: [] },
1269
+ argumentProperties,
1270
+ properties: { toolType: HTTP_REQUEST_TOOL_TYPE },
1271
+ };
1272
+ }
1273
+ /**
1274
+ * Every tool resource identity `compile` writes, read off the tables its
1275
+ * writers use — so a tool kind cannot be written without being owned, or owned
1276
+ * without being written (#935: the #920 built-in files were written as
1277
+ * `internal` and never pruned, because ownership was a hand-kept list in
1278
+ * `compile-cli.ts` that did not have them).
1279
+ *
1280
+ * * `types` — the resource `type`s compile owns OUTRIGHT: every deployed-resource
1281
+ * kind's, and `integration` (connector tools, since #867).
1282
+ * * `internalToolTypes` — `internal` is shared with designer-only built-ins
1283
+ * (`load-attachments`, `create-file`, `jev-classifier`), so for it ownership
1284
+ * is the `properties.toolType`, and only the ones compile writes.
1285
+ */
1286
+ export const COMPILE_WRITTEN_TOOL_RESOURCES = {
1287
+ types: new Set([...Object.values(TOOL_RESOURCE_TYPE), CONNECTOR_TOOL_RESOURCE_TYPE]),
1288
+ internalToolTypes: new Set([...Object.values(BUILTIN_TOOL_TYPE), HTTP_REQUEST_TOOL_TYPE]),
1289
+ };
1290
+ /**
1291
+ * Does `compile` own this `resources/<id>/resource.json` — would a compile have
1292
+ * written it, so one this compile did not write is stale rather than someone
1293
+ * else's? Everything it says no to belongs to the designer or to `uip agent
1294
+ * refresh` (escalation, mcp, designer-only built-ins, the kinds the SDK cannot
1295
+ * derive), and is never deleted.
1296
+ */
1297
+ export function compileOwnsResource(body) {
1298
+ const kind = body?.$resourceType;
1299
+ if (kind === 'context')
1300
+ return true;
1301
+ if (kind !== 'tool')
1302
+ return false;
1303
+ const type = String(body?.type);
1304
+ if (type === INTERNAL_TOOL_RESOURCE_TYPE) {
1305
+ const toolType = body?.properties?.toolType;
1306
+ return COMPILE_WRITTEN_TOOL_RESOURCES.internalToolTypes.has(String(toolType));
1307
+ }
1308
+ return COMPILE_WRITTEN_TOOL_RESOURCES.types.has(type);
1309
+ }
1200
1310
  /**
1201
1311
  * The .NET type an Action Center app argument of each field type carries. Studio
1202
1312
  * Web serializes the task payload through `inputSchemaDotnetTypeMapping`, which
@@ -1654,7 +1764,7 @@ function connectorToolResourceJson(ctx, id) {
1654
1764
  name: ctx.name,
1655
1765
  description: ctx.description,
1656
1766
  location: 'external',
1657
- type: 'integration',
1767
+ type: CONNECTOR_TOOL_RESOURCE_TYPE,
1658
1768
  inputSchema,
1659
1769
  outputSchema,
1660
1770
  settings: {},
@@ -5335,8 +5445,10 @@ export function serialize(built, opts = {}) {
5335
5445
  fix('body', tr.body);
5336
5446
  if (tr.timeout !== undefined)
5337
5447
  fix('timeout', tr.timeout);
5338
- if (tr.description !== undefined)
5339
- extraInputs.description = tr.description;
5448
+ // Always set, falling back to the definition's own text: the resource
5449
+ // file hands this to the MODEL as the tool's description, and the node
5450
+ // must carry the same one (#935).
5451
+ extraInputs.description = tr.description ?? String(tdef.description ?? '');
5340
5452
  }
5341
5453
  else {
5342
5454
  const meta = PROCESS_TOOL_META[tr.kind];
@@ -5390,7 +5502,9 @@ export function serialize(built, opts = {}) {
5390
5502
  ? connectorToolResourceJson(connectorTool, toolResourceId)
5391
5503
  : tr.kind === 'builtin'
5392
5504
  ? builtinToolResourceJson(tr.tool, label, tnode.inputs, { id: toolResourceId })
5393
- : toolResourceJson(tr, { id: toolResourceId });
5505
+ : tr.kind === 'httpRequest'
5506
+ ? httpRequestToolResourceJson(label, tnode.inputs, { id: toolResourceId, canvasNodeId: tid })
5507
+ : toolResourceJson(tr, { id: toolResourceId });
5394
5508
  if (toolResource !== undefined) {
5395
5509
  sidecars.push({
5396
5510
  path: `${source}/resources/${toolResourceId}/resource.json`,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@uipath/maestro-builder-sdk",
3
- "version": "6.16.9",
3
+ "version": "6.16.10",
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",
@@ -92,5 +92,5 @@
92
92
  "@types/node": "^22.7.0",
93
93
  "esbuild": "^0.28.1"
94
94
  },
95
- "gitref": "dd5b33d6640e176c10be173688ee2767cdd3f251"
95
+ "gitref": "2e666ec2dd9e7baa4716a2a0d21ee86484b0de89"
96
96
  }