@uipath/project-executor 1.206.0-preview.306 → 1.207.0-preview.307

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/index.js CHANGED
@@ -1,7 +1,176 @@
1
+ // ../jit-debug-contract/src/index.ts
2
+ var FPS_DEBUG_MASTER = "debug.master";
3
+ var FPS_DEBUG_EXECUTOR = "debug.executor";
4
+ var FPS_DEBUG_SOURCE = "debug.source";
5
+ var FPS_DEBUG_SESSION_ID = "debug.sessionId";
6
+ var DEBUG_SOURCE_STUDIO_WEB = "studioweb";
7
+ var JIT_DEBUG_VERSION = "1.0.0-debug";
8
+ var DEVELOPMENT_RUNTIME_TYPE = "Development";
9
+ var MAX_JIT_PROCESSES = 64;
10
+ var ORCHESTRATOR_PROJECT_TYPES = [
11
+ "Undefined",
12
+ "Process",
13
+ "ProcessLibrary",
14
+ "BusinessProcess",
15
+ "BusinessProcessLibrary",
16
+ "TestAutomationProcess",
17
+ "ProcessOrchestration",
18
+ "BusinessProcessOrchestration",
19
+ "WebApp",
20
+ "BusinessWebApp",
21
+ "Agent",
22
+ "BusinessAgent",
23
+ "Api",
24
+ "MCPServer",
25
+ "BusinessRules",
26
+ "CaseManagement",
27
+ "Flow",
28
+ "Function",
29
+ "FlowAutomate"
30
+ ];
31
+ var READABLE_PROJECT_TYPES = new Set(ORCHESTRATOR_PROJECT_TYPES.map((type) => type.toLowerCase()));
32
+
33
+ class JitAssemblyError extends Error {
34
+ code;
35
+ projectName;
36
+ constructor(code, message, projectName) {
37
+ super(message);
38
+ this.code = code;
39
+ this.projectName = projectName;
40
+ this.name = "JitAssemblyError";
41
+ }
42
+ }
43
+ function assembleJitFpsProperties(options) {
44
+ const siblings = options.siblingEntries ?? [];
45
+ const total = siblings.length + 1;
46
+ if (total > MAX_JIT_PROCESSES) {
47
+ throw new JitAssemblyError("TooManyProcesses", `Solution '${options.solutionName}' has ${total} JIT processes; the limit is ${MAX_JIT_PROCESSES}.`);
48
+ }
49
+ for (const entry of [options.leadEntry, ...siblings]) {
50
+ assertPlacementIsEffective(entry);
51
+ }
52
+ for (const sibling of siblings) {
53
+ assertSiblingIsResolvable(sibling);
54
+ }
55
+ const master = {
56
+ solutionName: options.solutionName,
57
+ version: JIT_DEBUG_VERSION,
58
+ processes: [options.leadEntry, ...siblings].map(toWireEntry)
59
+ };
60
+ assignDefined(master, "projectId", options.leadEntry.projectId);
61
+ const bag = {
62
+ [FPS_DEBUG_MASTER]: JSON.stringify(master),
63
+ [FPS_DEBUG_SOURCE]: DEBUG_SOURCE_STUDIO_WEB
64
+ };
65
+ if (options.leadEntry.executorInfo) {
66
+ bag[FPS_DEBUG_EXECUTOR] = options.leadEntry.executorInfo;
67
+ }
68
+ if (options.sessionId) {
69
+ bag[FPS_DEBUG_SESSION_ID] = options.sessionId;
70
+ }
71
+ return JSON.stringify(bag);
72
+ }
73
+ function mergeJitProcessEntries(fpsProperties, entries) {
74
+ if (entries.length === 0) {
75
+ return fpsProperties ?? "{}";
76
+ }
77
+ const described = `Cannot add ${entries.length} process entr${entries.length === 1 ? "y" : "ies"}`;
78
+ const {
79
+ outer,
80
+ master,
81
+ processes: existing
82
+ } = parseFpsEnvelope(fpsProperties, described);
83
+ const total = existing.length + entries.length;
84
+ if (total > MAX_JIT_PROCESSES) {
85
+ throw new JitAssemblyError("TooManyProcesses", `${described}: the bag would hold ${total} processes; the limit is ${MAX_JIT_PROCESSES}.`);
86
+ }
87
+ master.processes = [...existing, ...entries.map(toWireEntry)];
88
+ outer[FPS_DEBUG_MASTER] = JSON.stringify(master);
89
+ if (!(FPS_DEBUG_SOURCE in outer)) {
90
+ outer[FPS_DEBUG_SOURCE] = DEBUG_SOURCE_STUDIO_WEB;
91
+ }
92
+ return JSON.stringify(outer);
93
+ }
94
+ function parseFpsEnvelope(fpsProperties, described) {
95
+ const envelopeLength = (fpsProperties ?? "").length;
96
+ let outer;
97
+ let master;
98
+ try {
99
+ outer = fpsProperties ? JSON.parse(fpsProperties) : {};
100
+ const masterRaw = isJsonObject(outer) ? outer[FPS_DEBUG_MASTER] : undefined;
101
+ master = typeof masterRaw === "string" ? JSON.parse(masterRaw) : masterRaw === undefined ? {} : masterRaw;
102
+ } catch (error) {
103
+ throw new JitAssemblyError("MalformedFpsProperties", `${described}: the FpsProperties envelope (${envelopeLength} chars) is not valid JSON. ` + `Parse error: ${error instanceof Error ? error.name : "unknown"}.`);
104
+ }
105
+ if (!isJsonObject(outer) || !isJsonObject(master)) {
106
+ throw new JitAssemblyError("MalformedFpsProperties", `${described}: the FpsProperties envelope (${envelopeLength} chars) must be a JSON ` + `object whose ${FPS_DEBUG_MASTER} is also an object.`);
107
+ }
108
+ if (!(master.processes === undefined || Array.isArray(master.processes))) {
109
+ throw new JitAssemblyError("MalformedFpsProperties", `${described}: the ${FPS_DEBUG_MASTER} processes in the FpsProperties envelope ` + `(${envelopeLength} chars) must be an array.`);
110
+ }
111
+ return { outer, master, processes: master.processes ?? [] };
112
+ }
113
+ function assertSiblingIsResolvable(sibling) {
114
+ if (!sibling.executorInfo) {
115
+ throw new JitAssemblyError("UnresolvableSibling", `Project '${sibling.name}' takes part in the run but carries no executorInfo, so ` + "Orchestrator would read it as a deployed process and start whatever is deployed " + "under that name instead of this project's source. Give it the executorInfo its " + "executor builds.", sibling.name);
116
+ }
117
+ if (sibling.projectId || sibling.executionSettings?.machineTemplateName) {
118
+ return;
119
+ }
120
+ throw new JitAssemblyError("UnresolvableSibling", `Project '${sibling.name}' takes part in the run but declares neither a cloud project id ` + "nor a machine to run on, so whichever robot picks it up would have nothing to execute. " + "Give it executionSettings.machineTemplateName to run it from local disk, or a projectId " + "to let it run anywhere.", sibling.name);
121
+ }
122
+ function assertPlacementIsEffective(entry) {
123
+ const settings = entry.executionSettings;
124
+ if (!settings || settings.machineTemplateName) {
125
+ return;
126
+ }
127
+ throw new JitAssemblyError("IneffectivePlacement", `Project '${entry.name}' carries executionSettings without machineTemplateName, which ` + "Orchestrator does not pin to any machine — the job would go to any machine of that runtime, not this one.", entry.name);
128
+ }
129
+ function toWireEntry(entry) {
130
+ if (!READABLE_PROJECT_TYPES.has(entry.projectType.toLowerCase())) {
131
+ throw new JitAssemblyError("UnknownProjectType", `Project '${entry.name}' has project type '${entry.projectType}', which Orchestrator ` + "cannot read, so a Run Job that targets it would start an ordinary job instead of " + "this project. Translate it to one of: " + `${ORCHESTRATOR_PROJECT_TYPES.join(", ")}.`, entry.name);
132
+ }
133
+ const wire = {
134
+ name: entry.name,
135
+ projectType: entry.projectType
136
+ };
137
+ assignDefined(wire, "executorInfo", entry.executorInfo);
138
+ assignDefined(wire, "folderKey", entry.folderKey);
139
+ assignDefined(wire, "entryPointPath", entry.entryPointPath);
140
+ assignDefined(wire, "requiresUserInteraction", entry.requiresUserInteraction);
141
+ assignDefined(wire, "targetFramework", entry.targetFramework);
142
+ assignDefined(wire, "remoteControlAccess", entry.remoteControlAccess);
143
+ assignDefined(wire, "targetRuntime", entry.targetRuntime);
144
+ assignDefined(wire, "isConversational", entry.isConversational);
145
+ const settings = toWireExecutionSettings(entry.executionSettings);
146
+ assignDefined(wire, "executionSettings", settings);
147
+ return wire;
148
+ }
149
+ function toWireExecutionSettings(settings) {
150
+ if (!settings) {
151
+ return;
152
+ }
153
+ const wire = {};
154
+ assignDefined(wire, "runtimeType", settings.runtimeType);
155
+ assignDefined(wire, "machineTemplateName", settings.machineTemplateName);
156
+ assignDefined(wire, "hostMachineName", settings.hostMachineName);
157
+ assignDefined(wire, "serviceUserName", settings.serviceUserName);
158
+ assignDefined(wire, "runAsMe", settings.runAsMe);
159
+ return Object.keys(wire).length > 0 ? wire : undefined;
160
+ }
161
+ function isJsonObject(value) {
162
+ return typeof value === "object" && value !== null && !Array.isArray(value);
163
+ }
164
+ function assignDefined(target, key, value) {
165
+ if (value !== undefined) {
166
+ target[key] = value;
167
+ }
168
+ }
1
169
  // src/models/run-options.ts
2
170
  var RunTarget;
3
171
  ((RunTarget) => {
4
172
  RunTarget["Local"] = "Local";
173
+ RunTarget["Online"] = "Online";
5
174
  })(RunTarget ||= {});
6
175
  // src/models/run-status.ts
7
176
  var RunStatus;
@@ -190,6 +359,146 @@ var noopExecutorLogger = {
190
359
  warn: () => {},
191
360
  error: () => {}
192
361
  };
362
+ // src/services/jit-entry-collector.ts
363
+ class JitContributorError extends Error {
364
+ code;
365
+ projectName;
366
+ constructor(code, message, projectName) {
367
+ super(message);
368
+ this.code = code;
369
+ this.projectName = projectName;
370
+ this.name = "JitContributorError";
371
+ }
372
+ }
373
+ var DEFAULT_JIT_CONTRIBUTOR_TIMEOUT_MS = 30000;
374
+
375
+ class JitEntryCollector {
376
+ fileSystem;
377
+ logger;
378
+ registry;
379
+ timeoutMs;
380
+ constructor(deps) {
381
+ this.fileSystem = deps.fileSystem;
382
+ this.logger = deps.logger ?? noopExecutorLogger;
383
+ this.registry = deps.registry ?? executorsFactoryRepository;
384
+ this.timeoutMs = deps.timeoutMs ?? DEFAULT_JIT_CONTRIBUTOR_TIMEOUT_MS;
385
+ }
386
+ async collectAsync(context, cancellationToken) {
387
+ const { name, projectType } = context.project;
388
+ cancellationToken?.throwIfAborted();
389
+ let contributed;
390
+ if (this.registry.canHandleProject(projectType)) {
391
+ contributed = await this.askContributorAsync(context, cancellationToken);
392
+ } else {
393
+ this.logger.info(`No executor is registered for '${projectType}', so project '${name}' ` + "is described by name only in the solution's debug map.");
394
+ }
395
+ cancellationToken?.throwIfAborted();
396
+ if (!contributed?.length) {
397
+ this.assertDefaultCanRun(context);
398
+ }
399
+ const entries = contributed?.length ? contributed : [this.defaultEntry(context)];
400
+ return entries.map((entry, index) => this.withPlacement(entry, context, index));
401
+ }
402
+ async askContributorAsync(context, cancellationToken) {
403
+ const { accessToken: _token, ...connection } = context.connection;
404
+ return this.askExecutorAsync(context.project, {
405
+ action: "describe itself for the solution's debug map",
406
+ purpose: "collecting JIT entries"
407
+ }, (executor, signal) => executor.buildJitProcessEntriesAsync({ ...context, connection }, signal), cancellationToken);
408
+ }
409
+ async collectProcessCallsAsync(project, cancellationToken) {
410
+ cancellationToken?.throwIfAborted();
411
+ if (!this.registry.canHandleProject(project.projectType)) {
412
+ return {
413
+ status: "unknown",
414
+ reason: `no executor is registered for the project type '${project.projectType}'`
415
+ };
416
+ }
417
+ const answer = await this.askExecutorAsync(project, {
418
+ action: "list its process calls",
419
+ purpose: "listing process calls"
420
+ }, (executor, signal) => typeof executor.getProcessCallsAsync === "function" ? executor.getProcessCallsAsync(project, signal) : Promise.resolve({
421
+ status: "unknown",
422
+ reason: `the ${project.projectType} executor does not list the process calls of a project`
423
+ }), cancellationToken);
424
+ cancellationToken?.throwIfAborted();
425
+ return isProcessCallsResult(answer) ? answer : {
426
+ status: "unknown",
427
+ reason: `the ${project.projectType} executor gave its process calls in a shape that this CLI cannot read`
428
+ };
429
+ }
430
+ async askExecutorAsync(project, wording, ask, cancellationToken) {
431
+ const { name, projectType } = project;
432
+ const budget = new AbortController;
433
+ const signal = cancellationToken ? AbortSignal.any([cancellationToken, budget.signal]) : budget.signal;
434
+ const work = this.runContributorAsync(projectType, wording.purpose, (executor) => ask(executor, signal));
435
+ try {
436
+ return await this.withinBudget(work, project, wording, budget);
437
+ } catch (error) {
438
+ if (error instanceof JitContributorError) {
439
+ throw error;
440
+ }
441
+ throw new JitContributorError("Failed", `Project '${name}' (${projectType}) could not ${wording.action}: ` + `${error instanceof Error ? error.message : String(error)}`, name);
442
+ }
443
+ }
444
+ async runContributorAsync(projectType, purpose, ask) {
445
+ let executor;
446
+ try {
447
+ const factory = this.registry.getProjectExecutorFactory(projectType);
448
+ executor = await factory.createAsync(this.logger, this.fileSystem);
449
+ return executor ? await ask(executor) : undefined;
450
+ } finally {
451
+ try {
452
+ await executor?.dispose();
453
+ } catch (error) {
454
+ this.logger.warn(`Failed to dispose the ${projectType} executor after ${purpose}: ` + `${error instanceof Error ? error.message : String(error)}`);
455
+ }
456
+ }
457
+ }
458
+ withinBudget(pending, project, wording, budget) {
459
+ const { name, projectType } = project;
460
+ let timer;
461
+ const expiry = new Promise((_resolve, reject) => {
462
+ timer = setTimeout(() => {
463
+ budget.abort();
464
+ reject(new JitContributorError("Timeout", `Project '${name}' (${projectType}) did not ${wording.action} ` + `within ${this.timeoutMs}ms.`, name));
465
+ }, this.timeoutMs);
466
+ });
467
+ return Promise.race([pending, expiry]).finally(() => {
468
+ clearTimeout(timer);
469
+ });
470
+ }
471
+ withPlacement(entry, context, index) {
472
+ const isLeadEntry = context.isLead && index === 0;
473
+ if (isLeadEntry || !context.placement || entry.executionSettings) {
474
+ return entry;
475
+ }
476
+ return { ...entry, executionSettings: context.placement };
477
+ }
478
+ assertDefaultCanRun(context) {
479
+ const { name, projectType, cloudProjectId } = context.project;
480
+ if (!context.placement || cloudProjectId) {
481
+ return;
482
+ }
483
+ throw new JitContributorError("Undescribed", `Project '${name}' (${projectType}) did not describe itself for the solution's ` + "debug map, and with no cloud project id a default entry names no source, so " + "its job would start with nothing to run.", name);
484
+ }
485
+ defaultEntry(context) {
486
+ const { name, projectType, cloudProjectId } = context.project;
487
+ const executorInfo = cloudProjectId ? JSON.stringify({ projectId: cloudProjectId }) : "{}";
488
+ const entry = { name, projectType, executorInfo };
489
+ return cloudProjectId ? { ...entry, projectId: cloudProjectId } : entry;
490
+ }
491
+ }
492
+ function isProcessCallsResult(value) {
493
+ if (typeof value !== "object" || value === null) {
494
+ return false;
495
+ }
496
+ const answer = value;
497
+ if (answer.status === "known") {
498
+ return Array.isArray(answer.calls);
499
+ }
500
+ return answer.status === "unknown" && typeof answer.reason === "string";
501
+ }
193
502
  // src/services/project-executor.ts
194
503
  class ProjectExecutor {
195
504
  fileSystem;
@@ -230,6 +539,15 @@ class ProjectExecutor {
230
539
  }
231
540
  return;
232
541
  }
542
+ buildJitProcessEntriesAsync(_context, _cancellationToken) {
543
+ return Promise.resolve(undefined);
544
+ }
545
+ getProcessCallsAsync(_project, _cancellationToken) {
546
+ return Promise.resolve({
547
+ status: "unknown",
548
+ reason: `${this.constructor.name} does not list the process calls of a project`
549
+ });
550
+ }
233
551
  dispose() {
234
552
  return Promise.resolve();
235
553
  }
@@ -278,8 +596,21 @@ function messageOf(error) {
278
596
  return error instanceof Error ? error.message : String(error);
279
597
  }
280
598
  export {
599
+ DEBUG_SOURCE_STUDIO_WEB,
600
+ DEFAULT_JIT_CONTRIBUTOR_TIMEOUT_MS,
601
+ DEVELOPMENT_RUNTIME_TYPE,
281
602
  EXECUTOR_FACTORY_EXPORT,
282
603
  ExecutorsFactoryRepository,
604
+ FPS_DEBUG_EXECUTOR,
605
+ FPS_DEBUG_MASTER,
606
+ FPS_DEBUG_SESSION_ID,
607
+ FPS_DEBUG_SOURCE,
608
+ JIT_DEBUG_VERSION,
609
+ JitAssemblyError,
610
+ JitContributorError,
611
+ JitEntryCollector,
612
+ MAX_JIT_PROCESSES,
613
+ ORCHESTRATOR_PROJECT_TYPES,
283
614
  ProjectExecutor,
284
615
  ProjectRunner,
285
616
  RunErrorCode,
@@ -287,15 +618,17 @@ export {
287
618
  RunStatus,
288
619
  RunTarget,
289
620
  TERMINAL_RUN_STATUSES,
621
+ assembleJitFpsProperties,
290
622
  clearExecutorFactoryProvider,
291
623
  ensureExecutorFactory,
292
624
  executorsFactoryRepository,
293
625
  isExecutorFactoryModule,
294
626
  isTerminalRunStatus,
295
627
  mapRunStatus,
628
+ mergeJitProcessEntries,
296
629
  noopExecutorLogger,
297
630
  registerExecutorFactoryFromModule,
298
631
  setExecutorFactoryProvider
299
632
  };
300
633
 
301
- //# debugId=27993063095BCC4C64756E2164756E21
634
+ //# debugId=89D40FF61851A7EF64756E2164756E21
@@ -1,3 +1,5 @@
1
+ export type { JitAssemblyErrorCode, JitEntryContext, JitExecutionSettings, JitFpsPropertiesOptions, JitProcessEntry, ProcessCall, ProcessCallsResult, } from "./models/jit";
2
+ export { assembleJitFpsProperties, DEBUG_SOURCE_STUDIO_WEB, DEVELOPMENT_RUNTIME_TYPE, FPS_DEBUG_EXECUTOR, FPS_DEBUG_MASTER, FPS_DEBUG_SESSION_ID, FPS_DEBUG_SOURCE, JIT_DEBUG_VERSION, JitAssemblyError, MAX_JIT_PROCESSES, mergeJitProcessEntries, ORCHESTRATOR_PROJECT_TYPES, } from "./models/jit";
1
3
  export type { ProjectType } from "./models/project-type";
2
4
  export type { ProjectRunOptions, RunCallbacks, RunConnection, SolutionProjectRef, SolutionRunOptions, } from "./models/run-options";
3
5
  export { RunTarget } from "./models/run-options";
@@ -13,6 +15,8 @@ export type { ExecutorFactoryModule } from "./services/executor-tool-module";
13
15
  export { EXECUTOR_FACTORY_EXPORT, isExecutorFactoryModule, } from "./services/executor-tool-module";
14
16
  export type { IExecutorsFactoryRepository, IExecutorsFactoryRepositoryConfigurator, } from "./services/executors-factory-repository";
15
17
  export { ExecutorsFactoryRepository, executorsFactoryRepository, } from "./services/executors-factory-repository";
18
+ export type { JitContributorErrorCode, JitEntryCollectorDeps, } from "./services/jit-entry-collector";
19
+ export { DEFAULT_JIT_CONTRIBUTOR_TIMEOUT_MS, JitContributorError, JitEntryCollector, } from "./services/jit-entry-collector";
16
20
  export { ProjectExecutor } from "./services/project-executor";
17
21
  export type { ProjectRunnerDeps } from "./services/project-runner";
18
22
  export { ProjectRunner } from "./services/project-runner";
@@ -0,0 +1,92 @@
1
+ /**
2
+ * The executor layer's view of the just-in-time (JIT) debug contract.
3
+ *
4
+ * The wire format itself — key names, the double encoding, which fields reach
5
+ * the wire, and the project types Orchestrator can read — lives in
6
+ * `@uipath/jit-debug-contract`, which carries no dependencies so that every
7
+ * layer that produces this bag can reach it downward. An `*-sdk` producing
8
+ * entries (`@uipath/maestro-sdk`) cannot import an executor package without
9
+ * inverting the stack, which is why the contract is not held here.
10
+ *
11
+ * This module adds the one piece that only makes sense in the executor layer —
12
+ * {@link JitEntryContext}, which names an executor's own run types — and
13
+ * re-exports the contract so an executor has a single import. `@uipath/rpa-tool`
14
+ * (Studio repo) and the in-repo executors implement
15
+ * `ProjectExecutor.buildJitProcessEntriesAsync` against this module.
16
+ */
17
+ import type { JitExecutionSettings } from "@uipath/jit-debug-contract";
18
+ import type { RunConnection, SolutionProjectRef } from "./run-options";
19
+ export * from "@uipath/jit-debug-contract";
20
+ /**
21
+ * One process call that a workflow of a project makes: a Run Job, Start Job or
22
+ * Invoke Process activity, or a Flow process node.
23
+ *
24
+ * Every field is optional and nullable, as on the wire of the Studio project
25
+ * references service. A `processName` that is null, absent or blank is a
26
+ * dynamic call: the name is an expression, so the target is not known before
27
+ * the run. `folderPath` is information only. A just-in-time child matches its
28
+ * entry by name, whatever folder the call names.
29
+ */
30
+ export interface ProcessCall {
31
+ processName?: string | null;
32
+ folderPath?: string | null;
33
+ activityId?: string | null;
34
+ activityDisplayName?: string | null;
35
+ workflowPath?: string | null;
36
+ }
37
+ /**
38
+ * The process calls of one project, or why the project type cannot list them.
39
+ *
40
+ * Only the calls that the workflows of the project make. A job that a
41
+ * dependency package or a direct API call starts is out of scope. "unknown"
42
+ * makes the solution keep every project in the run, so a project type that
43
+ * cannot be sure answers "unknown", never an empty list.
44
+ */
45
+ export type ProcessCallsResult = {
46
+ status: "known";
47
+ calls: readonly ProcessCall[];
48
+ } | {
49
+ status: "unknown";
50
+ reason: string;
51
+ };
52
+ /**
53
+ * What a contributor is told before it describes its own project. Read-only
54
+ * information the solution run already resolved.
55
+ */
56
+ export interface JitEntryContext {
57
+ /** The project this executor is being asked to describe. */
58
+ project: SolutionProjectRef;
59
+ /**
60
+ * True for the project whose entry point the run executes.
61
+ *
62
+ * Worth branching on: a debug session may want breakpoints, tracking and
63
+ * `Trace` logging on the lead and none of it on the siblings, while a plain
64
+ * solution run wants neither anywhere. The contract carries the fact and
65
+ * lets the contributor decide.
66
+ */
67
+ isLead: boolean;
68
+ solutionName: string;
69
+ /** Studio Web solution id, when the solution has been synced. */
70
+ solutionId?: string;
71
+ /**
72
+ * Where the run goes, without its bearer token: whatever a contributor
73
+ * writes into `executorInfo` is persisted on the job, and printed by
74
+ * `uip solution jit-properties get`.
75
+ */
76
+ connection: Omit<RunConnection, "accessToken">;
77
+ /** Entry point the caller named, when they named one. */
78
+ entryPoint?: string;
79
+ inputArguments?: Record<string, unknown>;
80
+ /**
81
+ * Where this project's job will be placed, when the run pinned it.
82
+ *
83
+ * Information, not an instruction to copy: the collector stamps it onto the
84
+ * returned entries itself. It is here because it decides the one thing a
85
+ * contributor cannot work out alone — a pinned child can read its source
86
+ * straight off local disk (`projectStorage: { path }`), an unpinned one is
87
+ * placed wherever and must be fetchable by cloud id.
88
+ */
89
+ placement?: JitExecutionSettings;
90
+ /** See `ProjectRunOptions.providerOptions`. */
91
+ providerOptions?: Record<string, unknown>;
92
+ }
@@ -4,20 +4,23 @@ import type { RunStatus } from "./run-status";
4
4
  /**
5
5
  * Where the run executes.
6
6
  *
7
- * Legacy, and on its way out. Where a project runs is not a caller's choice but
8
- * a fact about the project type — RPA drives the Studio on this machine, a
9
- * low-code agent starts a serverless job because that is the only runtime that
10
- * executes `agent.json` — so no caller has anything to decide here and
11
- * `uip solution run` offers no flag for it.
12
- *
13
- * The field survives because the published RPA executor validates it, so callers
14
- * still pass `Local` and it still means something to exactly one implementation.
15
- * A newer executor ignores it. It becomes optional once no shipped executor
16
- * checks it.
7
+ * Most project types have one answer and ignore this: an API Workflow runs on
8
+ * the engine in this process, a low-code agent starts a serverless job because
9
+ * that is the only runtime executing `agent.json`. The RPA executor is the one
10
+ * with a real choice, and it validates this field.
17
11
  */
18
12
  export declare enum RunTarget {
19
13
  /** Local execution on the developer machine. */
20
- Local = "Local"
14
+ Local = "Local",
15
+ /**
16
+ * An Orchestrator job started against the caller's tenant, running the
17
+ * project from source.
18
+ *
19
+ * What a JIT solution run needs: Orchestrator only consults
20
+ * {@link ProjectRunOptions.fpsProperties} on a job it started, so a run that
21
+ * has a bag to attach has to be a job rather than a local process.
22
+ */
23
+ Online = "Online"
21
24
  }
22
25
  /** Auth/tenant coordinates a project type needs to reach the backends. */
23
26
  export interface RunConnection {
@@ -90,6 +93,37 @@ export interface ProjectRunOptions {
90
93
  * `siblingProjects` alone.
91
94
  */
92
95
  siblingProjects?: SolutionProjectRef[];
96
+ /**
97
+ * The solution's assembled `FpsProperties` bag.
98
+ *
99
+ * A real field rather than a `providerOptions` key because every project
100
+ * type that starts an Orchestrator job attaches the same string, assembled
101
+ * once by the solution-run layer so the double encoding happens in one place
102
+ * (`@uipath/jit-debug-contract`).
103
+ *
104
+ * An executor that starts a job puts this on it verbatim; one that runs in
105
+ * this process ignores it.
106
+ */
107
+ fpsProperties?: string;
108
+ /**
109
+ * The enclosing solution's name, when the run comes from one.
110
+ *
111
+ * A fact the solution layer holds and an executor cannot derive from a
112
+ * project directory. An executor that needs one and is given none falls back
113
+ * to the project's own name.
114
+ */
115
+ solutionName?: string;
116
+ /**
117
+ * The robot session to start the lead on, when the solution layer chose one.
118
+ *
119
+ * Set on a JIT run alongside {@link fpsProperties}. The bag pins every
120
+ * sibling to the session the placement picked, by its machine template,
121
+ * host and service user, so a starter that picks its own on a host with
122
+ * several sessions can run the lead under another user or template than its
123
+ * siblings. An executor that starts the lead as a job passes this as its
124
+ * `MachineSessionIds`, and looks one up itself only when it is absent.
125
+ */
126
+ machineSessionId?: number;
93
127
  /** Milliseconds between status polls. */
94
128
  pollIntervalMs?: number;
95
129
  /** Overall budget for waiting on the run, in milliseconds. */
@@ -42,6 +42,11 @@ export declare class RunResult {
42
42
  errorCode: RunErrorCode;
43
43
  /** The project type's own status string, preserved for diagnostics. */
44
44
  rawStatus?: string;
45
+ /**
46
+ * On a failure, what went wrong. On a success, a next step the caller
47
+ * should show, when the run has one — `uip solution run` prints it as
48
+ * `Instructions`.
49
+ */
45
50
  message?: string;
46
51
  /** Orchestrator job key, when the run went through a job. */
47
52
  jobKey?: string;
@@ -0,0 +1,116 @@
1
+ import type { IFileSystem } from "@uipath/filesystem";
2
+ import type { JitEntryContext, JitProcessEntry, ProcessCallsResult } from "../models/jit";
3
+ import type { SolutionProjectRef } from "../models/run-options";
4
+ import type { IExecutorLogger } from "./executor-logger";
5
+ import type { IExecutorsFactoryRepository } from "./executors-factory-repository";
6
+ /** Why a contributor's entries could not be collected. */
7
+ export type JitContributorErrorCode = "Timeout" | "Failed" | "Undescribed";
8
+ /**
9
+ * A project type's contribution could not be obtained. Always names the
10
+ * project: a solution run touches every project, so the failure is otherwise
11
+ * indistinguishable from a bad bag.
12
+ */
13
+ export declare class JitContributorError extends Error {
14
+ readonly code: JitContributorErrorCode;
15
+ readonly projectName: string;
16
+ constructor(code: JitContributorErrorCode, message: string, projectName: string);
17
+ }
18
+ /** How long one contributor may take before the run gives up on it. */
19
+ export declare const DEFAULT_JIT_CONTRIBUTOR_TIMEOUT_MS = 30000;
20
+ export interface JitEntryCollectorDeps {
21
+ fileSystem: IFileSystem;
22
+ logger?: IExecutorLogger;
23
+ /** Defaults to the shared registry. Injectable for tests. */
24
+ registry?: IExecutorsFactoryRepository;
25
+ /** Per-contributor budget. Defaults to {@link DEFAULT_JIT_CONTRIBUTOR_TIMEOUT_MS}. */
26
+ timeoutMs?: number;
27
+ }
28
+ /**
29
+ * Asks each project type for its own `debug.master` entries: resolves the
30
+ * registered executor, calls its contributor hook inside a budget, and
31
+ * substitutes a default entry for the types with nothing to say. Also asks a
32
+ * project type for the process calls of one project, inside the same budget
33
+ * ({@link JitEntryCollector.collectProcessCallsAsync}).
34
+ *
35
+ * **Rejects rather than degrading, unlike {@link ProjectRunner}.** A runner's
36
+ * caller is reporting a run's outcome, so a failed executor is a result. This
37
+ * caller is building a manifest, and a partial one is not an outcome — it is a
38
+ * bag that looks complete and silently runs the wrong thing.
39
+ *
40
+ * Use one collector per bag, and collect its projects in sequence.
41
+ */
42
+ export declare class JitEntryCollector {
43
+ private readonly fileSystem;
44
+ private readonly logger;
45
+ private readonly registry;
46
+ private readonly timeoutMs;
47
+ constructor(deps: JitEntryCollectorDeps);
48
+ /**
49
+ * The entries describing one project, never fewer than one. A project with no
50
+ * executor, or one whose executor declines, is still described — leaving it out
51
+ * would remove it from the map, and a `Run Job` naming it would then resolve
52
+ * nothing at runtime instead of here.
53
+ *
54
+ * @throws {JitContributorError} when a contributor stalls or throws, or a
55
+ * local project nothing describes would start with nothing to run.
56
+ */
57
+ collectAsync(context: JitEntryContext, cancellationToken?: AbortSignal): Promise<readonly JitProcessEntry[]>;
58
+ /** Ask the contributor inside the budget. */
59
+ private askContributorAsync;
60
+ /**
61
+ * The process calls of one project, from its project type.
62
+ *
63
+ * A project type with no registered executor, and an answer in a shape
64
+ * this contract does not define, are "unknown": the caller then keeps
65
+ * every project of the solution. The RPA executor ships from the Studio
66
+ * repository, so its answer crosses a release boundary.
67
+ *
68
+ * @throws {JitContributorError} when the executor stalls or throws. The
69
+ * caller decides what a failed question means.
70
+ */
71
+ collectProcessCallsAsync(project: SolutionProjectRef, cancellationToken?: AbortSignal): Promise<ProcessCallsResult>;
72
+ /**
73
+ * Ask a fresh executor of the project's type inside the budget, and name
74
+ * the project when it stalls or throws.
75
+ */
76
+ private askExecutorAsync;
77
+ /**
78
+ * Create the executor, ask it, dispose it either way. Disposal waits for the
79
+ * contributor, also one past its budget, so late work never meets a
80
+ * disposed executor.
81
+ */
82
+ private runContributorAsync;
83
+ /**
84
+ * Races the contributor against its budget, and aborts its signal when the
85
+ * budget wins. The race holds even for a contributor that ignores the
86
+ * signal; disposal still waits for it to settle, so late work never meets
87
+ * a disposed executor.
88
+ */
89
+ private withinBudget;
90
+ /**
91
+ * Stamps placement so a contributor cannot forget it — an unpinned sibling gets
92
+ * a serverless child, and a serverless child reading a local path dies on a
93
+ * pod. A placement the entry declared for itself is left alone. Never applied to
94
+ * the lead's own entry, the first one, pinned by the transport that starts it.
95
+ * Every further entry a lead contributes is passed on as a sibling, so it is
96
+ * placed like one.
97
+ */
98
+ private withPlacement;
99
+ /**
100
+ * A default entry starts nothing by itself: with no cloud id its
101
+ * `executorInfo` is `"{}"`, which names no source. That is fine for a
102
+ * project the run does not start from this machine — no placement, as for a
103
+ * lead that runs in the cloud. Pinned here it is not: a sibling would
104
+ * become a child with nothing to execute, and the lead's entry is also its
105
+ * job's `debug.executor`. So it is refused, and the run packs and deploys
106
+ * instead.
107
+ */
108
+ private assertDefaultCanRun;
109
+ /**
110
+ * The entry for a project that described nothing of its own. `executorInfo` is
111
+ * present even with no id to put in it: the consumer reads a *missing* one as
112
+ * "deployed process, take only its execution settings", which would quietly opt
113
+ * the project out of JIT.
114
+ */
115
+ private defaultEntry;
116
+ }
@@ -1,5 +1,6 @@
1
1
  import type { IFileSystem } from "@uipath/filesystem";
2
- import type { ProjectRunOptions } from "../models/run-options";
2
+ import type { JitEntryContext, JitProcessEntry, ProcessCallsResult } from "../models/jit";
3
+ import type { ProjectRunOptions, SolutionProjectRef } from "../models/run-options";
3
4
  import { RunResult } from "../models/run-result";
4
5
  import type { IExecutorLogger } from "./executor-logger";
5
6
  /**
@@ -72,6 +73,45 @@ export declare abstract class ProjectExecutor {
72
73
  * elsewhere reads that itself.
73
74
  */
74
75
  private firstDeclaredEntryPoint;
76
+ /**
77
+ * This project's entries in the solution's JIT `debug.master` process map.
78
+ *
79
+ * Several entries rather than one, because a project can hold more than one
80
+ * runnable process — an agent inside a Flow package is its own entry.
81
+ *
82
+ * `undefined` — the default, the same "opt in" posture as {@link runAsync} —
83
+ * means "no override": the collector substitutes a default entry naming the
84
+ * project. So does an empty array. Neither is a failure; a project type that
85
+ * cannot describe its own start options must still be matchable by name, or
86
+ * a `Run Job` pointing at it resolves nothing.
87
+ *
88
+ * Must not call back into the solution-run layer: nothing stops that from
89
+ * recursing.
90
+ *
91
+ * The solution's invocation graph (`@uipath/solution-sdk/invocation-graph`)
92
+ * matches a process call to a project name only. A call to an entry with
93
+ * another name names no project, so the graph reads it as a call to a
94
+ * process outside the solution and keeps every project in the map.
95
+ *
96
+ * @param context Includes where the child will be placed, which decides
97
+ * whether the project can be read from local disk or fetched by cloud id.
98
+ */
99
+ buildJitProcessEntriesAsync(_context: JitEntryContext, _cancellationToken?: AbortSignal): Promise<readonly JitProcessEntry[] | undefined>;
100
+ /**
101
+ * The process calls that the workflows of this project make, so that the
102
+ * solution can find the projects that a lead reaches.
103
+ *
104
+ * The default is "unknown", the same "opt in" posture as {@link runAsync}.
105
+ * "unknown" keeps every project of the solution in the run, which is
106
+ * always safe. A project type answers "known" only when the list is
107
+ * complete: a call left out removes a project that the run can start.
108
+ *
109
+ * Must not call back into the solution-run layer: nothing stops that from
110
+ * recursing.
111
+ *
112
+ * @param project The project to read, with its absolute directory.
113
+ */
114
+ getProcessCallsAsync(_project: SolutionProjectRef, _cancellationToken?: AbortSignal): Promise<ProcessCallsResult>;
75
115
  /** Release resources. Override when the implementation holds any. */
76
116
  dispose(): Promise<void>;
77
117
  }
package/package.json CHANGED
@@ -2,7 +2,7 @@
2
2
  "name": "@uipath/project-executor",
3
3
  "author": "UiPath",
4
4
  "license": "SEE LICENSE IN LICENSE.txt",
5
- "version": "1.206.0-preview.306",
5
+ "version": "1.207.0-preview.307",
6
6
  "description": "Common run contract implemented by every UiPath project type - the shared ProjectExecutor interface behind 'uip solution run'.",
7
7
  "repository": {
8
8
  "type": "git",
@@ -31,7 +31,8 @@
31
31
  "dist"
32
32
  ],
33
33
  "dependencies": {
34
- "@uipath/filesystem": "1.206.0"
34
+ "@uipath/filesystem": "1.207.0",
35
+ "@uipath/jit-debug-contract": "1.203.0"
35
36
  },
36
- "gitHead": "0b8843ae9b6d2f69a0203f96ab91e5d55e416383"
37
+ "gitHead": "a625ed8ac421089170db3cb8b95c497f3c7b0d62"
37
38
  }