@uipath/flow-tool 1.0.4 → 1.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,95 @@
1
+ /**
2
+ * Connector-binding shape validator (MST-9810, upstream UiPath/cli#2027).
3
+ *
4
+ * `uip maestro flow validate` historically only checked that `node.type`
5
+ * existed in the definitions[] list. A flow whose nodes are generic Managed
6
+ * HTTP placeholders (`core.action.http.v2`) labelled like connector activities
7
+ * — e.g. `name: "Send Slack Message"`, `display.label: "Create Jira Issue"` —
8
+ * with no `inputs.detail` binding therefore passed validation cleanly, then
9
+ * 404'd at runtime against the unconfigured HTTP endpoint.
10
+ *
11
+ * This module looks at every Managed-HTTP node, derives whether the label is
12
+ * "connector-shaped" (mentions a connector keyword from the cached IS catalog
13
+ * or a static fallback list), and verifies that the node carries either a
14
+ * connector-mode or manual-mode binding. Misses surface as a `warning` by
15
+ * default and as `error` under `--strict-bindings`.
16
+ *
17
+ * Catalog lookup is best-effort: when the registry cache is missing
18
+ * (offline / first-run), a small static keyword list keeps the check active
19
+ * for the most common connectors (Slack, Gmail, Jira, Salesforce, …) rather
20
+ * than going silent — these are the same connectors most likely to be
21
+ * referenced by hallucinating agents.
22
+ */
23
+ import type { ValidationIssue } from "./node-validators/types.js";
24
+ /** Generic Managed HTTP node type — the type that historically slipped through. */
25
+ export declare const MANAGED_HTTP_NODE_TYPE = "core.action.http.v2";
26
+ /**
27
+ * Structural shape of a flow node the binding validator needs. Kept loose so
28
+ * `ParsedWorkflow` nodes satisfy it without a cast — fields beyond this set
29
+ * are ignored.
30
+ */
31
+ export interface ConnectorBindingNode {
32
+ id: string;
33
+ type: string;
34
+ name?: unknown;
35
+ display?: {
36
+ label?: unknown;
37
+ } & Record<string, unknown>;
38
+ inputs?: Record<string, unknown>;
39
+ }
40
+ /** Structural shape of the workflow envelope the validator walks. */
41
+ export interface ConnectorBindingWorkflow {
42
+ nodes: ConnectorBindingNode[];
43
+ subflows?: Record<string, {
44
+ nodes?: ConnectorBindingNode[];
45
+ }>;
46
+ }
47
+ export interface ConnectorBindingValidationOptions {
48
+ /**
49
+ * Promote each emitted issue from `warning` to `error`. Wired to the
50
+ * `--strict-bindings` CLI flag. Useful for CI gates that want a
51
+ * mislabeled HTTP node to fail the build rather than passively warn.
52
+ */
53
+ strict?: boolean;
54
+ /**
55
+ * Test-time injection. When provided, this overrides whatever
56
+ * `loadRegistry()` would return. Lets specs assert behavior against a
57
+ * known catalog without touching the user's real cache.
58
+ */
59
+ catalogOverride?: ConnectorCatalog;
60
+ }
61
+ /**
62
+ * Compact view of the IS catalog the validator actually needs — connector
63
+ * keywords (`key`, `name`) and a flat list of activity display tokens.
64
+ * Built once per `validateFile` from the cached `MaestroRegistry`.
65
+ */
66
+ export interface ConnectorCatalog {
67
+ /**
68
+ * Connector keyword tokens (e.g. "slack" derived from `uipath-uipath-slack`
69
+ * → strip "uipath-" prefix → split by "-"). Lower-cased.
70
+ */
71
+ keywords: Set<string>;
72
+ /**
73
+ * Activity displayName token bags — each entry is the set of lowercase
74
+ * tokens from one activity's displayName. A label whose tokens match
75
+ * any entry (subset or superset) is considered connector-shaped.
76
+ */
77
+ activityTokenBags: Array<{
78
+ connectorKey: string;
79
+ connectorName: string;
80
+ tokens: Set<string>;
81
+ }>;
82
+ }
83
+ /**
84
+ * Build a `ConnectorCatalog` from the cached registry. Returns a catalog with
85
+ * empty `activityTokenBags` (but populated with static keywords) when no
86
+ * cache exists — so the check still fires for offline users.
87
+ */
88
+ export declare function loadConnectorCatalog(): Promise<ConnectorCatalog>;
89
+ /**
90
+ * Walk every node in the flow + every subflow and emit one issue per
91
+ * unbound, connector-shaped Managed HTTP node. Scope mirrors
92
+ * `validateResourceBindings` so the new check stays consistent with the
93
+ * §A4 binding-integrity pass already in `FlowValidateService`.
94
+ */
95
+ export declare function validateConnectorBindings(workflow: ConnectorBindingWorkflow, catalog: ConnectorCatalog, options?: Pick<ConnectorBindingValidationOptions, "strict">): ValidationIssue[];
@@ -1,4 +1,5 @@
1
1
  import type { NodeManifest } from "@uipath/flow-core";
2
+ import { type ConnectorCatalog } from "./connector-binding-validator.js";
2
3
  import { type FlowNodeValidator, type ValidationIssue } from "./node-validators/index.js";
3
4
  import type { WorkflowGovernanceEnforcements, WorkflowValidationRule } from "./node-validators/workflow-rule-types.js";
4
5
  interface FlowValidateResult {
@@ -51,6 +52,18 @@ export interface FlowValidateOptions {
51
52
  * enables current-manifest validation.
52
53
  */
53
54
  currentManifests?: ManifestForCurrentValidation[];
55
+ /**
56
+ * Promote connector-binding shape warnings (MST-9810) to errors. By
57
+ * default, an unbound Managed HTTP node carrying a connector-shaped label
58
+ * emits a warning so existing flows keep validating green; CI gates
59
+ * opt in via `--strict-bindings` to fail the build instead.
60
+ */
61
+ strictBindings?: boolean;
62
+ /**
63
+ * Test/host override for the connector catalog used by the binding-shape
64
+ * validator. Supplying this skips the `loadRegistry()` cache lookup.
65
+ */
66
+ connectorCatalog?: ConnectorCatalog;
54
67
  }
55
68
  export declare class FlowValidateService {
56
69
  private readonly fs;
@@ -60,7 +73,10 @@ export declare class FlowValidateService {
60
73
  private readonly availableModelNames?;
61
74
  private readonly validateCurrentManifests;
62
75
  private readonly currentManifestOverrides?;
76
+ private readonly strictBindings;
77
+ private readonly connectorCatalogOverride?;
63
78
  private currentManifestCache?;
79
+ private connectorCatalogCache?;
64
80
  constructor(options?: FlowValidateOptions);
65
81
  execute(flowFilePath: string): Promise<number>;
66
82
  private loadCurrentManifestMap;
@@ -100,6 +116,83 @@ export declare class FlowValidateService {
100
116
  private validateUniqueIds;
101
117
  /** Uniqueness check for `variables.globals` IDs; called once per scope (root + each subflow). */
102
118
  private validateGlobalVariableUniqueness;
119
+ /**
120
+ * Resource-node bindings integrity (residual roadmap §A4, [MST-9712]).
121
+ *
122
+ * Every process-typed node (RPA workflow, agent, API workflow, agent-tool
123
+ * process — see PROCESS_NODE_PREFIXES) referenced anywhere in the flow
124
+ * — top-level `nodes[]` AND every subflow's `nodes[]` — must have a
125
+ * corresponding `workflow.bindings` entry whose `resourceKey` covers the
126
+ * node's needs. Without it, the workflow passes `flow validate` today but
127
+ * fails opaquely at runtime as "Failure in the Orchestrator Job".
128
+ *
129
+ * Uses `collectNodeBindingResourceKeys` from `node-service.ts` (the same
130
+ * helper `ensureProcessBindings` uses on the write path) to compute each
131
+ * process node's needed resource keys, then checks each against the
132
+ * declared `bindings[].resourceKey` set.
133
+ */
134
+ private validateResourceBindings;
135
+ /**
136
+ * Cross-node connection ID reuse (residual roadmap §A6, [MST-9714]).
137
+ *
138
+ * Two distinct nodes referencing the same `inputs.detail.connectionResourceId`
139
+ * share runtime connection state. Often that's a bug (a node was duplicated
140
+ * without re-pointing the connection); sometimes it's intentional (two
141
+ * connectors on the same SaaS account, sharing rate-limit headroom).
142
+ *
143
+ * Severity: `warning` — legitimate sharing exists, so don't block validate.
144
+ * Users can investigate or ignore as appropriate.
145
+ *
146
+ * Scope: top-level `workflow.nodes` + every `workflow.subflows[].nodes`
147
+ * (matches A4's iteration shape for consistency).
148
+ */
149
+ private validateConnectionIdReuse;
150
+ /**
151
+ * Connector-binding shape check (MST-9810, upstream UiPath/cli#2027).
152
+ *
153
+ * Lazy-loads the IS connector catalog (cached registry from
154
+ * `~/.uipath/maestro/registry.json`, falling back to a static keyword
155
+ * list when no cache exists) and delegates to
156
+ * `validateConnectorBindings`. Promotes warnings to errors when
157
+ * constructed with `strictBindings: true` (wired to `--strict-bindings`).
158
+ *
159
+ * Catalog loading is best-effort and never throws: when the cache is
160
+ * missing or unreadable, the validator still runs against the static
161
+ * fallback keyword list. That keeps the check active for offline users
162
+ * who would otherwise be the most likely to hit this bug, while
163
+ * letting tests inject deterministic catalogs via
164
+ * `FlowValidateOptions.connectorCatalog`.
165
+ */
166
+ private validateConnectorBindingShapes;
167
+ private loadConnectorCatalogCached;
168
+ /**
169
+ * Project↔solution registration + canonical-path layout (residual roadmap
170
+ * §A3, [MST-9711]). Walks up from the .flow's parent looking for a
171
+ * `.uipx` solution file. When one is found, asserts both:
172
+ *
173
+ * (a) the .flow's project directory is registered in the solution's
174
+ * projects[] list (matched by ProjectRelativePath's directory name),
175
+ * and
176
+ * (b) the canonical layout: <solution>/<projectName>/<projectName>.flow
177
+ * — i.e. the .flow file basename equals its parent directory name.
178
+ *
179
+ * Standalone authoring (no .uipx in any parent) is allowed — the rule
180
+ * stays silent in that case so single-flow workflows aren't penalised.
181
+ *
182
+ * Severity: warning. Both issues are recoverable (`uip solution project add`
183
+ * fixes registration; renaming the file or directory fixes the layout).
184
+ */
185
+ private validateSolutionRegistrationAndLayout;
186
+ /**
187
+ * Best-effort path canonicalization for the registration-comparison
188
+ * call site. Returns `fs.realpath(p)` when the call succeeds, and
189
+ * the original `p` when it fails (e.g., the path doesn't exist).
190
+ * Falling back to the literal path is deliberate: a missing path is
191
+ * exactly the failure mode that the surrounding validator already
192
+ * surfaces via other issues, and canonicalization is an optimization
193
+ * for symlink/case-folding correctness, not a precondition.
194
+ */
195
+ private canonicalizePath;
103
196
  /**
104
197
  * Catch stale embedded OOTB definitions. Studio Web renders against the
105
198
  * current node manifest, while .flow files carry a serialized copy of the
@@ -0,0 +1,94 @@
1
+ import type { NodeInstance, Workflow } from "@uipath/flow-core";
2
+ import { type ConnectorInfo } from "@uipath/maestro-sdk";
3
+ /**
4
+ * Thrown when a node type is genuinely absent from the SDK bundle and the
5
+ * tenant manifest — i.e. a typo or a removed node.
6
+ */
7
+ export declare class NodeTypeNotFoundError extends Error {
8
+ readonly code = "NodeTypeNotFound";
9
+ readonly instructions: string;
10
+ constructor(message: string, instructions: string);
11
+ }
12
+ /**
13
+ * Thrown when a node type IS in the SDK bundle (so it exists as a feature on
14
+ * the platform) but is missing from the loaded tenant manifest — almost always
15
+ * a feature-flag / entitlement gate.
16
+ */
17
+ export declare class NodeTypeNotEnabledError extends Error {
18
+ readonly code = "NodeTypeNotEnabled";
19
+ readonly instructions: string;
20
+ constructor(message: string, instructions: string);
21
+ }
22
+ export interface NodeSummary {
23
+ id: string;
24
+ type: string;
25
+ label: string;
26
+ position: {
27
+ x: number;
28
+ y: number;
29
+ };
30
+ }
31
+ export interface ListNodesResult {
32
+ nodes: NodeSummary[];
33
+ count: number;
34
+ }
35
+ export declare const listNodesInFlow: (filePath: string) => Promise<ListNodesResult>;
36
+ export interface AddNodeOptions {
37
+ position?: {
38
+ x: number;
39
+ y: number;
40
+ };
41
+ label?: string;
42
+ inputs?: Record<string, unknown>;
43
+ source?: string;
44
+ }
45
+ export interface AddNodeResult {
46
+ node: NodeInstance;
47
+ definitionAdded: boolean;
48
+ bindingsCreated: number;
49
+ variableCount: number;
50
+ connectorInfo?: ConnectorInfo;
51
+ }
52
+ export interface DeleteNodeResult {
53
+ deletedNode: NodeSummary;
54
+ edgesRemoved: number;
55
+ bindingsRemoved: number;
56
+ definitionsRemoved: number;
57
+ variablesRemoved: number;
58
+ variableUpdatesRemoved: number;
59
+ }
60
+ /**
61
+ * Node type prefixes that use process-style bindings (GUID as resourceKey).
62
+ * Covers RPA workflows, agent process tools, and agent nodes.
63
+ */
64
+ export declare const PROCESS_NODE_PREFIXES: string[];
65
+ export declare function isProcessNode(manifest: {
66
+ nodeType: string;
67
+ }): boolean;
68
+ /**
69
+ * Safety net: ensure every process/agent node in the workflow has corresponding
70
+ * entries in the workflow `bindings` array and that `<bindings.*>` placeholders
71
+ * in node model.context are resolved to `=bindings.<id>` references.
72
+ *
73
+ * This handles flows authored outside the CLI (e.g. direct file edits or
74
+ * skill-generated files) where `addNodeToFlow` was never called, so the
75
+ * binding creation / resolution step was skipped.
76
+ *
77
+ * Mutates the workflow in place. Safe to call multiple times — already-resolved
78
+ * nodes are skipped.
79
+ */
80
+ export declare function ensureProcessBindings(workflow: Workflow): number;
81
+ /**
82
+ * Collect all binding resourceKeys associated with a node.
83
+ * Handles three binding ownership patterns:
84
+ * 1. Process nodes — resourceKey from the definition's model.bindings.resourceKey,
85
+ * falling back to the process GUID extracted from the node type
86
+ * 2. Connector nodes — resourceKey is the connectionId stored in inputs.detail
87
+ * 3. Input refs — "=bindings.<id>" patterns resolved to resourceKeys
88
+ */
89
+ export declare function collectNodeBindingResourceKeys(node: NodeInstance, bindings: Array<{
90
+ id: string;
91
+ resourceKey: string;
92
+ }>, definitions?: Array<Record<string, unknown>>): Set<string>;
93
+ export declare const addNodeToFlow: (filePath: string, nodeType: string, options?: AddNodeOptions) => Promise<AddNodeResult>;
94
+ export declare const deleteNodeFromFlow: (filePath: string, nodeId: string) => Promise<DeleteNodeResult>;
@@ -1,6 +1,7 @@
1
1
  import type { FlowNodeValidator } from "./types.js";
2
2
  export { connectorNodeValidator } from "./connector-validator.js";
3
3
  export { expressionPrefixValidator } from "./expression-prefix-validator.js";
4
+ export { ixpNodeValidator } from "./ixp-node-validator.js";
4
5
  export { modelSourceValidator } from "./model-source-validator.js";
5
6
  export type { FlowNodeValidator, FlowValidatorContext, FlowValidatorNode, ValidationIssue, ValidationIssueSeverity, } from "./types.js";
6
7
  /**
@@ -0,0 +1,2 @@
1
+ import type { FlowNodeValidator } from "./types.js";
2
+ export declare const ixpNodeValidator: FlowNodeValidator;
@@ -0,0 +1,107 @@
1
+ import type { IFileSystem } from "@uipath/filesystem";
2
+ import { type EntryPoint, type PackagingBinding, type PackagingNode, type PackagingNodeManifest, type PackagingWorkflowVariables } from "@uipath/flow-schema";
3
+ interface FlowFileNode {
4
+ id: string;
5
+ type: string;
6
+ typeVersion?: string;
7
+ display?: Record<string, unknown>;
8
+ inputs?: Record<string, unknown>;
9
+ outputs?: Record<string, unknown>;
10
+ model?: Record<string, unknown>;
11
+ [key: string]: unknown;
12
+ }
13
+ /**
14
+ * Resolve the inline-agent's projectId UUID from a flow node.
15
+ *
16
+ * flow-core 0.2.50 moved the per-instance source UUID from
17
+ * `node.model.source` to `node.inputs.source`. Older `.flow` files (and
18
+ * any saved before the migration ran) still carry the legacy
19
+ * `model.source` shape — `model-source-validator.ts` accepts both, so
20
+ * the packagers must too. Falls back through the same key set
21
+ * flow-workbench's `extractInlineAgents` uses.
22
+ *
23
+ * Note: `packager/packager-tool-flow/src/flow-tool.ts` keeps an inline
24
+ * copy of this rule (`readSource` in `generateFlowPackagingArtifacts`).
25
+ * `flow-tool` already imports `@uipath/packager-tool-flow`, so the
26
+ * reverse import would create a cycle. If the priority list ever
27
+ * changes, update both copies — or lift the helper into
28
+ * `@uipath/flow-schema` (currently an external dep) and delete both.
29
+ */
30
+ export declare function readInlineAgentSource(node: {
31
+ inputs?: Record<string, unknown>;
32
+ model?: Record<string, unknown>;
33
+ }): string | undefined;
34
+ /** Returns true when the node's type is a known inline-agent node type. */
35
+ export declare function isInlineAgentNodeType(type: string | undefined): boolean;
36
+ /** Returns true when the node's type is the conversational agent type. */
37
+ export declare function isConversationalAgentNodeType(type: string | undefined): boolean;
38
+ /**
39
+ * Convert file-format nodes (flat `inputs`/`display`/`outputs`) to the
40
+ * `PackagingNode` shape expected by flow-schema packaging helpers — also
41
+ * flat: `display`, `inputs`, `outputs`, and `model` sit at the top of the
42
+ * node, matching `inputsMatchBinding` and `getConnectionMetadata` in
43
+ * `getBindingResources`. We default `typeVersion` here for legacy file-format
44
+ * nodes that omit it; `toPackagingNodes` from flow-schema is an identity cast
45
+ * and does NOT remap fields, so we do that here.
46
+ */
47
+ export declare function fileNodesToPackagingNodes(nodes: FlowFileNode[]): PackagingNode[];
48
+ /** Packaged inline agent with entry point and file metadata. */
49
+ export interface InlineAgentPackage {
50
+ /** The agent's projectId UUID (directory name). */
51
+ source: string;
52
+ /** Entry point for entry-points.json. */
53
+ entryPoint: EntryPoint;
54
+ /** The raw agent.json content (for .agent-builder/agent.json). */
55
+ agentJson: Record<string, unknown>;
56
+ }
57
+ /**
58
+ * Scan workflow nodes for inline agents, read their agent.json,
59
+ * and build entry points + metadata for packaging.
60
+ *
61
+ * The source UUID may live at `inputs.source` (canonical) or `model.source`
62
+ * (legacy, pre-flow-core 0.2.50). We honour both — see
63
+ * {@link readInlineAgentSource}.
64
+ */
65
+ export declare function packageInlineAgents(fs: IFileSystem, projectDir: string, nodes: Array<{
66
+ type: string;
67
+ inputs?: Record<string, unknown>;
68
+ model?: Record<string, unknown>;
69
+ }>): Promise<InlineAgentPackage[]>;
70
+ /**
71
+ * Build inline-agent descriptors for a debug session's FpsProperties
72
+ * injection. Mirrors flow-workbench's `extractInlineAgents` shape:
73
+ * one entry per agent node with a resolvable source UUID.
74
+ *
75
+ * The runtime resolves each entry by `executorInfo.projectId`, so this
76
+ * walks every agent node — even the ones whose `agent.json` may not be
77
+ * on disk yet — and returns the descriptor list.
78
+ *
79
+ * `entryPointPath` is `<projectId>/agent.json` (no `content/` prefix —
80
+ * runtime resolves against the deployed package root).
81
+ */
82
+ export declare function buildInlineAgentDescriptors(nodes: Array<{
83
+ type: string;
84
+ display?: Record<string, unknown>;
85
+ inputs?: Record<string, unknown>;
86
+ model?: Record<string, unknown>;
87
+ }>): Array<{
88
+ name: string;
89
+ agentProjectId: string;
90
+ isConversational: boolean;
91
+ entryPointPath: string;
92
+ }>;
93
+ /**
94
+ * Write all packaging artifacts (operate.json, entry-points.json, bindings_v2.json,
95
+ * package-descriptor.json) into a directory using @uipath/flow-schema.
96
+ *
97
+ * Returns the computed entry points so callers can derive PIMS entry point paths
98
+ * without calling getEntryPoints again.
99
+ */
100
+ export declare function writePackagingArtifacts(fs: IFileSystem, projectDir: string, projectId: string, packagingNodes: PackagingNode[], bindings: PackagingBinding[], variables: PackagingWorkflowVariables, bpmnFileName: string, startEventId: string, flowFileName?: string, definitions?: PackagingNodeManifest[]): Promise<EntryPoint[]>;
101
+ /**
102
+ * Re-read a .flow file and regenerate bindings_v2.json in the same project directory.
103
+ * Called after `node add` (process nodes), `node delete`, and `node configure` to
104
+ * keep bindings in sync with the .flow file.
105
+ */
106
+ export declare function regenerateBindingsFile(fs: IFileSystem, flowFilePath: string): Promise<void>;
107
+ export {};