farseer-cli 1.11.2 → 1.12.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.
@@ -28,29 +28,141 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
28
28
  var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
29
29
  var apps_exports = {};
30
30
  __export(apps_exports, {
31
+ APP_COMPUTE_CHOICES: () => APP_COMPUTE_CHOICES,
32
+ APP_COMPUTE_SIZES: () => APP_COMPUTE_SIZES,
31
33
  AppDeleteRefusedError: () => AppDeleteRefusedError,
34
+ CLEAR_SETTING: () => CLEAR_SETTING,
32
35
  REMOTE_JOB_ITEM_TYPE: () => REMOTE_JOB_ITEM_TYPE,
36
+ SECRET_PLACEHOLDER: () => SECRET_PLACEHOLDER,
37
+ applyRunSettings: () => applyRunSettings,
33
38
  applySourceFolderChange: () => applySourceFolderChange,
34
39
  findScriptInFolder: () => findScriptInFolder,
40
+ formatCompute: () => formatCompute,
35
41
  mergeAppUpdate: () => mergeAppUpdate,
42
+ parseComputeChoice: () => parseComputeChoice,
43
+ redactActionValues: () => redactActionValues,
36
44
  remoteJobReverseReferences: () => remoteJobReverseReferences,
37
- resolveAppItemNodeId: () => resolveAppItemNodeId
45
+ resolveAppItemNodeId: () => resolveAppItemNodeId,
46
+ resolveRunnerImage: () => resolveRunnerImage,
47
+ restoreRedactedValues: () => restoreRedactedValues
38
48
  });
39
49
  module.exports = __toCommonJS(apps_exports);
40
50
  var import_chalk = __toESM(require("chalk"));
41
51
  var farseer = __toESM(require("farseer-client"));
52
+ const SECRET_PLACEHOLDER = "<secret>";
53
+ function secretNames(args) {
54
+ return new Set(args.filter((a) => a.secret).map((a) => a.name));
55
+ }
56
+ function redactActionValues(actions, args) {
57
+ const secret = secretNames(args);
58
+ return actions.map((action) => ({
59
+ name: action.name,
60
+ runArguments: Object.fromEntries(
61
+ Object.entries(action.runArguments ?? {}).map(([name, value]) => [
62
+ name,
63
+ secret.has(name) ? SECRET_PLACEHOLDER : value
64
+ ])
65
+ )
66
+ }));
67
+ }
68
+ function restoreRedactedValues(incoming, current) {
69
+ const named = (actions2, name) => actions2.filter((a) => a.name === name);
70
+ const actions = [];
71
+ for (const action of incoming) {
72
+ const stored = named(current, action.name);
73
+ const ambiguous = stored.length > 1 || named(incoming, action.name).length > 1;
74
+ const runArguments = {};
75
+ for (const [name, value] of Object.entries(action.runArguments ?? {})) {
76
+ if (value !== SECRET_PLACEHOLDER) {
77
+ runArguments[name] = value;
78
+ continue;
79
+ }
80
+ if (ambiguous) {
81
+ return {
82
+ error: `Action "${action.name}" sends ${SECRET_PLACEHOLDER} for "${name}", but more than one action is named "${action.name}", so which stored value it stands for is unknown \u2014 give the real value.`
83
+ };
84
+ }
85
+ const kept = stored[0]?.runArguments?.[name];
86
+ if (kept === void 0) {
87
+ return {
88
+ error: `Action "${action.name}" sends ${SECRET_PLACEHOLDER} for "${name}", but no stored action named exactly "${action.name}" has a value for it \u2014 give the real value.`
89
+ };
90
+ }
91
+ runArguments[name] = kept;
92
+ }
93
+ actions.push({ name: action.name, runArguments });
94
+ }
95
+ return { actions };
96
+ }
97
+ const APP_COMPUTE_SIZES = ["s", "m", "l", "xl"];
98
+ const APP_COMPUTE_CHOICES = [
99
+ "local",
100
+ "batch",
101
+ ...APP_COMPUTE_SIZES.map((size) => `batch:${size}`)
102
+ ];
42
103
  function mergeAppUpdate(current, changes) {
43
- return {
104
+ const payload = {
44
105
  name: changes.name ?? current.name,
45
106
  description: changes.description ?? current.description ?? "",
46
107
  expectedArguments: changes.expectedArguments ?? current.expectedArguments ?? [],
47
- mainScriptFileId: changes.mainScriptFileId ?? current.mainScriptFileId ?? null,
48
- sourceFolderId: changes.sourceFolderId ?? current.sourceFolderId ?? null,
49
- schedule: changes.schedule ?? current.schedule ?? null,
50
- runnerName: changes.runnerName ?? current.runnerName ?? null,
51
- runnerImage: changes.runnerImage ?? current.runnerImage ?? null,
52
- predefinedActions: changes.predefinedActions ?? current.predefinedActions ?? []
108
+ mainScriptFileId: ("mainScriptFileId" in changes ? changes.mainScriptFileId : current.mainScriptFileId) ?? null,
109
+ sourceFolderId: ("sourceFolderId" in changes ? changes.sourceFolderId : current.sourceFolderId) ?? null,
110
+ schedule: ("schedule" in changes ? changes.schedule : current.schedule) ?? null,
111
+ runnerName: ("runnerName" in changes ? changes.runnerName : current.runnerName) ?? null,
112
+ runnerImage: ("runnerImage" in changes ? changes.runnerImage : current.runnerImage) ?? null,
113
+ predefinedActions: changes.predefinedActions ?? current.predefinedActions ?? [],
114
+ icon: ("icon" in changes ? changes.icon : current.icon) ?? null
53
115
  };
116
+ const compute = changes.compute ?? current.compute;
117
+ if (compute) {
118
+ payload.compute = compute;
119
+ }
120
+ return payload;
121
+ }
122
+ function parseComputeChoice(value) {
123
+ const choice = value.trim().toLowerCase();
124
+ if (choice === "local") {
125
+ return { type: "local" };
126
+ }
127
+ if (choice === "batch") {
128
+ return { type: "batch" };
129
+ }
130
+ const size = choice.startsWith("batch:") ? choice.slice("batch:".length) : null;
131
+ if (size && APP_COMPUTE_SIZES.includes(size)) {
132
+ return { type: "batch", options: { size } };
133
+ }
134
+ return null;
135
+ }
136
+ function formatCompute(compute) {
137
+ if (compute?.type !== "batch") {
138
+ return "local";
139
+ }
140
+ return compute.options?.size ? `batch:${compute.options.size}` : "batch";
141
+ }
142
+ function resolveRunnerImage(value, registry) {
143
+ const known = registry.repositories.join(", ") || "(none configured)";
144
+ const prefix = registry.registryPrefix ? `${registry.registryPrefix}/` : "";
145
+ const rest = prefix && value.startsWith(prefix) ? value.slice(prefix.length) : value;
146
+ if (rest.includes("/")) {
147
+ return {
148
+ error: `Runner image must be "<repository>:<tag>" or start with ${registry.registryPrefix}/. Available repositories: ${known}`
149
+ };
150
+ }
151
+ const colonIndex = rest.indexOf(":");
152
+ if (colonIndex === -1) {
153
+ return {
154
+ error: `Runner image must include a tag, e.g. "${registry.repositories[0] ?? "runner-typescript"}:latest"`
155
+ };
156
+ }
157
+ const repository = rest.slice(0, colonIndex);
158
+ const tag = rest.slice(colonIndex + 1);
159
+ if (!registry.repositories.includes(repository)) {
160
+ return { error: `Unknown runner image repository "${repository}". Available repositories: ${known}` };
161
+ }
162
+ if (!tag) {
163
+ return { error: `Runner image must include a tag, e.g. "${repository}:latest"` };
164
+ }
165
+ return { image: `${prefix}${repository}:${tag}` };
54
166
  }
55
167
  function findScriptInFolder(folderScripts, name) {
56
168
  return folderScripts.find((s) => s.name === name);
@@ -112,6 +224,74 @@ async function applySourceFolderChange(client, app, changes, options, caller) {
112
224
  }
113
225
  return null;
114
226
  }
227
+ const CLEAR_SETTING = "none";
228
+ function isCleared(value) {
229
+ return value.trim() === "" || value.trim().toLowerCase() === CLEAR_SETTING;
230
+ }
231
+ async function applyRunSettings(client, app, changes, settings) {
232
+ const warnings = [];
233
+ const resolved = {};
234
+ if (settings.schedule !== void 0) {
235
+ resolved.schedule = isCleared(settings.schedule) ? null : settings.schedule.trim();
236
+ }
237
+ if (settings.compute !== void 0) {
238
+ const compute = parseComputeChoice(settings.compute);
239
+ if (!compute) {
240
+ return {
241
+ error: `Unknown compute selection "${settings.compute}". Valid values: ${APP_COMPUTE_CHOICES.join(", ")}.`
242
+ };
243
+ }
244
+ resolved.compute = compute;
245
+ }
246
+ if (settings.runner !== void 0) {
247
+ resolved.runnerName = isCleared(settings.runner) ? null : settings.runner.trim();
248
+ }
249
+ if (settings.runnerImage !== void 0) {
250
+ if (isCleared(settings.runnerImage)) {
251
+ resolved.runnerImage = null;
252
+ } else {
253
+ const registry = await client.getRunnerImageRepositories();
254
+ const outcome = resolveRunnerImage(settings.runnerImage.trim(), registry);
255
+ if ("error" in outcome) {
256
+ return outcome;
257
+ }
258
+ resolved.runnerImage = outcome.image;
259
+ }
260
+ }
261
+ if ("runnerName" in resolved || "compute" in resolved) {
262
+ const runnerName = ("runnerName" in resolved ? resolved.runnerName : app.runnerName) ?? null;
263
+ const compute = "compute" in resolved ? resolved.compute : app.compute;
264
+ warnings.push(...await runnerWarnings(client, runnerName, compute));
265
+ }
266
+ Object.assign(changes, resolved);
267
+ return { warnings };
268
+ }
269
+ async function runnerWarnings(client, runnerName, compute) {
270
+ let runners;
271
+ try {
272
+ runners = await client.getRunners();
273
+ } catch {
274
+ return [];
275
+ }
276
+ if (runnerName && !runners.some((runner) => runner.name === runnerName)) {
277
+ const connected = runners.map((runner) => runner.name).join(", ") || "(none)";
278
+ return [`No jobrunner named "${runnerName}" is connected. Currently connected: ${connected}`];
279
+ }
280
+ if (!compute) {
281
+ return [];
282
+ }
283
+ const answering = runnerName ? runners.filter((runner) => runner.name === runnerName) : runners;
284
+ if (answering.length === 0) {
285
+ return [];
286
+ }
287
+ const engine = compute.type;
288
+ if (answering.some((runner) => (runner.engines ?? ["local"]).includes(engine))) {
289
+ return [];
290
+ }
291
+ const who = runnerName ? `Jobrunner "${runnerName}" does not offer` : "No connected jobrunner offers";
292
+ const what = engine === "batch" ? "a machine per run" : "runs on the shared runner";
293
+ return [`${who} ${what}. The setting is saved; runs will fail until one does.`];
294
+ }
115
295
  const REMOTE_JOB_ITEM_TYPE = farseer.FolderItemType.RemoteJob;
116
296
  function remoteJobReverseReferences(remoteJobIds) {
117
297
  return remoteJobIds.map((reference) => ({ reference, type: REMOTE_JOB_ITEM_TYPE }));
@@ -138,12 +318,22 @@ function resolveAppItemNodeId(remoteJobId, items) {
138
318
  }
139
319
  // Annotate the CommonJS export names for ESM import in node:
140
320
  0 && (module.exports = {
321
+ APP_COMPUTE_CHOICES,
322
+ APP_COMPUTE_SIZES,
141
323
  AppDeleteRefusedError,
324
+ CLEAR_SETTING,
142
325
  REMOTE_JOB_ITEM_TYPE,
326
+ SECRET_PLACEHOLDER,
327
+ applyRunSettings,
143
328
  applySourceFolderChange,
144
329
  findScriptInFolder,
330
+ formatCompute,
145
331
  mergeAppUpdate,
332
+ parseComputeChoice,
333
+ redactActionValues,
146
334
  remoteJobReverseReferences,
147
- resolveAppItemNodeId
335
+ resolveAppItemNodeId,
336
+ resolveRunnerImage,
337
+ restoreRedactedValues
148
338
  });
149
339
  //# sourceMappingURL=apps.js.map
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../src/services/apps.ts"],
4
- "sourcesContent": ["/**\n * Apps (Remote Jobs): their shape, and the rules over it.\n *\n * What belongs here is decided by dependency direction, not by I/O: nothing in\n * this module constructs a client or reads a credential. applySourceFolderChange\n * does make a call, but through an injected one-method resolver, so it stays\n * testable without one.\n */\n\nimport chalk from 'chalk';\nimport * as farseer from 'farseer-client';\n\nexport type AppArgumentDataType = 'string' | 'boolean';\n\nexport interface AppArgument {\n name: string;\n dataType: AppArgumentDataType;\n fixed?: boolean;\n options?: string[];\n defaultValue?: string;\n secret?: boolean;\n}\n\nexport interface AppScriptFile {\n id: string;\n name: string;\n}\n\n// A resolved source folder: its node id (to set on the app) plus the script\n// files it contains (to validate an entrypoint lives inside it).\nexport interface SourceFolderResolution {\n id: number;\n scripts: AppScriptFile[];\n}\n\nexport interface RemoteApp {\n id: number;\n name: string;\n description: string;\n expectedArguments: AppArgument[];\n status: string;\n lastHeartbeat: string;\n mainScriptFileId: string | null;\n scriptFiles?: AppScriptFile[];\n sourceFolderId?: number;\n schedule?: string | null;\n runnerName?: string | null;\n runnerImage?: string | null;\n predefinedActions: unknown[];\n}\n\n// The fields a Remote Job update writes. The backend PUT replaces the whole\n// row, so any field omitted here is reset to its default (args/predefined \u2192\n// empty, the rest \u2192 null). `mergeAppUpdate` exists so a caller that only wants\n// to touch one field doesn't silently wipe the others.\nexport interface UpdateAppPayload {\n name: string;\n description: string;\n expectedArguments: AppArgument[];\n mainScriptFileId: string | null;\n sourceFolderId: number | null;\n schedule: string | null;\n runnerName: string | null;\n runnerImage: string | null;\n predefinedActions: unknown[];\n}\n\n// `scriptFileIds` is accepted from callers for backwards compatibility but is\n// never sent \u2014 the backend ignores it (scripts derive from the source folder).\nexport type AppUpdateChanges = Partial<UpdateAppPayload> & { scriptFileIds?: string[] };\n\n/**\n * Overlay a caller's changes onto an app's current state to build a full,\n * non-destructive update payload. Every field the caller leaves out keeps its\n * current value \u2014 so changing one setting never clears the others.\n */\nexport function mergeAppUpdate(current: RemoteApp, changes: AppUpdateChanges): UpdateAppPayload {\n return {\n name: changes.name ?? current.name,\n description: changes.description ?? current.description ?? '',\n expectedArguments: changes.expectedArguments ?? current.expectedArguments ?? [],\n mainScriptFileId: changes.mainScriptFileId ?? current.mainScriptFileId ?? null,\n sourceFolderId: changes.sourceFolderId ?? current.sourceFolderId ?? null,\n schedule: changes.schedule ?? current.schedule ?? null,\n runnerName: changes.runnerName ?? current.runnerName ?? null,\n runnerImage: changes.runnerImage ?? current.runnerImage ?? null,\n predefinedActions: changes.predefinedActions ?? current.predefinedActions ?? [],\n };\n}\n\n/**\n * Find a script in a source folder's file list by its exact name. Farseer file\n * names are case-sensitive \u2014 two files differing only in case can coexist in a\n * folder \u2014 so matching is exact, never case-folded, to avoid resolving an\n * entrypoint to the wrong file. Resolution is folder-scoped, never tenant-wide,\n * so a same-named file in another folder can't be picked by accident. Returns\n * undefined when the name isn't in the folder.\n */\nexport function findScriptInFolder(folderScripts: AppScriptFile[], name: string): AppScriptFile | undefined {\n return folderScripts.find((s) => s.name === name);\n}\n\n// The one client capability applySourceFolderChange needs. Kept minimal (not the\n// whole client) so it is trivial to unit-test with a fake resolver.\nexport interface SourceFolderResolver {\n resolveSourceFolder(relativePath: string): Promise<SourceFolderResolution | null>;\n}\n\n// Selects only how an error is presented \u2014 dimming, and `--flag` (CLI) vs param\n// (MCP) wording. It is a pure UX knob: the decision, the ids written to `changes`,\n// and the success/failure outcome are identical for both values. Never branch\n// functionality on it.\nexport type ConfigureCaller = 'cli' | 'mcp';\n\n/**\n * Resolve the source-folder / entrypoint settings for an `app configure` and\n * write the resulting ids into `changes`, applying the rule that an app's\n * scripts derive from its source folder and the entrypoint must be a file in\n * that folder. `sourceFolder` (a path under Files/) switches the folder;\n * otherwise the entrypoint is validated against the app's current folder. Moving\n * the folder must not orphan the entrypoint: if the current entrypoint isn't in\n * the new folder and the caller didn't supply one, the request is rejected \u2014 the\n * entrypoint is never silently cleared or relocated.\n *\n * Returns an error message for the caller to surface (and `changes` is left\n * untouched), or null once the ids have been written. The decision lives here so\n * the CLI and MCP paths can't drift.\n */\nexport async function applySourceFolderChange(\n client: SourceFolderResolver,\n app: Pick<RemoteApp, 'scriptFiles' | 'mainScriptFileId'>,\n changes: AppUpdateChanges,\n options: { sourceFolder?: string; entrypoint?: string },\n caller: ConfigureCaller,\n): Promise<string | null> {\n const cli = caller === 'cli';\n // Secondary guidance lines are dimmed in the terminal; plain for the MCP tool.\n const hint = (text: string) => (cli ? chalk.dim(text) : text);\n\n let folderScripts = app.scriptFiles ?? [];\n let sourceFolderId: number | undefined;\n\n if (options.sourceFolder) {\n // A failed request is deliberately not caught: \"no such folder\" is an\n // answer, and a 500 or a dropped connection is not one. Both callers\n // surface the throw with the status intact.\n const resolved = await client.resolveSourceFolder(options.sourceFolder);\n if (!resolved) {\n return [\n `Source folder not found under Files/: ${options.sourceFolder}`,\n hint('Use a path relative to Files/, e.g. \"Scripts/MyApp\".'),\n ].join('\\n');\n }\n sourceFolderId = resolved.id;\n folderScripts = resolved.scripts;\n\n // Moving the folder must not leave the entrypoint pointing outside it.\n if (!options.entrypoint && app.mainScriptFileId) {\n const stillThere = folderScripts.some((s) => s.id === app.mainScriptFileId);\n if (!stillThere) {\n const files = folderScripts.map((s) => s.name).join(', ') || '(none)';\n return [\n \"The app's current entrypoint is not in the new source folder.\",\n hint(\n cli\n ? 'Pass --entrypoint <script> (a file in the new folder) in the same command.'\n : 'Pass \"entrypoint\" (a file in the new folder) in the same call.',\n ),\n hint(`Files in this folder: ${files}`),\n ].join('\\n');\n }\n }\n }\n\n let mainScriptFileId: string | undefined;\n if (options.entrypoint) {\n const match = findScriptInFolder(folderScripts, options.entrypoint);\n if (!match) {\n const files = folderScripts.map((s) => s.name).join(', ') || '(none)';\n const lines = [\n `Entrypoint not found in the source folder: ${options.entrypoint}`,\n hint(`Files in this folder: ${files}`),\n ];\n if (!options.sourceFolder) {\n lines.push(\n hint(\n cli\n ? 'To use a file from another folder, set it first with --source-folder <path>.'\n : 'To use a file from another folder, pass sourceFolder first.',\n ),\n );\n }\n return lines.join('\\n');\n }\n mainScriptFileId = match.id;\n }\n\n // Apply only after every check passes, so a rejected request never partially\n // mutates `changes`.\n if (sourceFolderId !== undefined) {\n changes.sourceFolderId = sourceFolderId;\n }\n if (mainScriptFileId !== undefined) {\n changes.mainScriptFileId = mainScriptFileId;\n }\n return null;\n}\n\n// `reference` (the Remote Job id) is deliberately the only id here \u2014 apps also\n// have a folder-item id, in an overlapping number space, and carrying both is\n// what let `app delete` destroy unrelated objects.\nexport interface AppListItem {\n name: string;\n type: string;\n reference: string;\n}\n\nexport const REMOTE_JOB_ITEM_TYPE = farseer.FolderItemType.RemoteJob;\n\n// A `folders.resolveItems` result: `id` is the folder-item id, `reference` the\n// id in the item's own domain (for REMOTE_JOB, the Remote Job id).\nexport interface ResolvedFolderItem {\n id: number;\n name: string;\n type: string;\n reference: string;\n}\n\nexport function remoteJobReverseReferences(remoteJobIds: readonly string[]): farseer.ReverseReference[] {\n return remoteJobIds.map((reference) => ({ reference, type: REMOTE_JOB_ITEM_TYPE }));\n}\n\n// A deliberate refusal from the delete guard, as distinct from a transport\n// failure. Callers surface it as a validation error, not a retryable one:\n// nothing was deleted and retrying cannot change that.\nexport class AppDeleteRefusedError extends Error {}\n\n/**\n * Pick the folder-item id to delete for an app, from the `resolveItems` response.\n *\n * Remote Job ids and folder-item ids overlap \u2014 the low folder ids are the roots\n * (13 = Files, 15 = Apps) \u2014 so posting a Remote Job id to `deleteItems` deletes\n * whichever unrelated node owns that number. `resolveItems` is type-scoped\n * server-side; these checks make sure a server change can't widen that.\n */\nexport function resolveAppItemNodeId(remoteJobId: string, items: readonly ResolvedFolderItem[]): number {\n const matches = items.filter((item) => item.reference === remoteJobId);\n\n if (matches.length === 0) {\n throw new AppDeleteRefusedError(`No app found for Remote Job id ${remoteJobId} \u2014 nothing was deleted.`);\n }\n if (matches.length > 1) {\n throw new AppDeleteRefusedError(\n `Remote Job id ${remoteJobId} resolved to ${matches.length} folder items \u2014 refusing to delete.`,\n );\n }\n\n const item = matches[0];\n if (item.type !== REMOTE_JOB_ITEM_TYPE) {\n throw new AppDeleteRefusedError(\n `Refusing to delete: Remote Job id ${remoteJobId} resolved to a ${item.type} ` +\n `(\"${item.name}\"), not an app.`,\n );\n }\n\n return item.id;\n}\n"],
5
- "mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AASA,mBAAkB;AAClB,cAAyB;AAkElB,SAAS,eAAe,SAAoB,SAA6C;AAC5F,SAAO;AAAA,IACH,MAAM,QAAQ,QAAQ,QAAQ;AAAA,IAC9B,aAAa,QAAQ,eAAe,QAAQ,eAAe;AAAA,IAC3D,mBAAmB,QAAQ,qBAAqB,QAAQ,qBAAqB,CAAC;AAAA,IAC9E,kBAAkB,QAAQ,oBAAoB,QAAQ,oBAAoB;AAAA,IAC1E,gBAAgB,QAAQ,kBAAkB,QAAQ,kBAAkB;AAAA,IACpE,UAAU,QAAQ,YAAY,QAAQ,YAAY;AAAA,IAClD,YAAY,QAAQ,cAAc,QAAQ,cAAc;AAAA,IACxD,aAAa,QAAQ,eAAe,QAAQ,eAAe;AAAA,IAC3D,mBAAmB,QAAQ,qBAAqB,QAAQ,qBAAqB,CAAC;AAAA,EAClF;AACJ;AAUO,SAAS,mBAAmB,eAAgC,MAAyC;AACxG,SAAO,cAAc,KAAK,CAAC,MAAM,EAAE,SAAS,IAAI;AACpD;AA4BA,eAAsB,wBAClB,QACA,KACA,SACA,SACA,QACsB;AACtB,QAAM,MAAM,WAAW;AAEvB,QAAM,OAAO,CAAC,SAAkB,MAAM,aAAAA,QAAM,I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AiB;AAAA,EAC7B;AACA,MAAI,qBAAqB,QAAW;AAChC,YAAQ,mBAAmB;AAAA,EAC/B;AACA,SAAO;AACX;AAWO,MAAM,uBAAuB,QAAQ,eAAe;AAWpD,SAAS,2BAA2B,cAA6D;AACpG,SAAO,aAAa,IAAI,CAAC,eAAe,EAAE,WAAW,MAAM,qBAAqB,EAAE;AACtF;AAKO,MAAM,8BAA8B,MAAM;AAAC;AAU3C,SAAS,qBAAqB,aAAqB,OAA8C;AACpG,QAAM,UAAU,MAAM,OAAO,CAACC,UAASA,MAAK,cAAc,WAAW;AAErE,MAAI,QAAQ,WAAW,GAAG;AACtB,UAAM,IAAI,sBAAsB,kCAAkC,WAAW,8BAAyB;AAAA,EAC1G;AACA,MAAI,QAAQ,SAAS,GAAG;AACpB,UAAM,IAAI;AAAA,MACN,iBAAiB,WAAW,gBAAgB,QAAQ,MAAM;AAAA,IAC9D;AAAA,EACJ;AAEA,QAAM,OAAO,QAAQ,CAAC;AACtB,MAAI,KAAK,SAAS,sBAAsB;AACpC,UAAM,IAAI;AAAA,MACN,qCAAqC,WAAW,kBAAkB,KAAK,IAAI,MAClE,KAAK,IAAI;AAAA,IACtB;AAAA,EACJ;AAEA,SAAO,KAAK;AAChB;",
6
- "names": ["chalk", "item"]
4
+ "sourcesContent": ["/**\n * Apps (Remote Jobs): their shape, and the rules over it.\n *\n * What belongs here is decided by dependency direction, not by I/O: nothing in\n * this module constructs a client or reads a credential. applySourceFolderChange\n * does make a call, but through an injected one-method resolver, so it stays\n * testable without one.\n */\n\nimport chalk from 'chalk';\nimport * as farseer from 'farseer-client';\n\nexport type AppArgumentDataType = 'string' | 'boolean';\n\nexport interface AppArgument {\n name: string;\n dataType: AppArgumentDataType;\n fixed?: boolean;\n options?: string[];\n defaultValue?: string;\n secret?: boolean;\n}\n\nexport interface AppScriptFile {\n id: string;\n name: string;\n}\n\n// A resolved source folder: its node id (to set on the app) plus the script\n// files it contains (to validate an entrypoint lives inside it).\nexport interface SourceFolderResolution {\n id: number;\n scripts: AppScriptFile[];\n}\n\nexport interface AppPredefinedAction {\n name: string;\n runArguments: Record<string, string>;\n}\n\n/**\n * Shown in place of an action's value for an argument marked secret.\n *\n * The backend returns action values readable even for secret arguments \u2014 its\n * masking covers only defaults \u2014 so every surface that displays an action masks\n * it here. Sent back unchanged in a whole-list update, it means \"keep the value\n * the tenant has\", which is what lets an agent edit one action without having\n * to know, or wipe, another's secret.\n */\nexport const SECRET_PLACEHOLDER = '<secret>';\n\n// Exact names, as the backend holds them: `Token` and `token` are two arguments.\nfunction secretNames(args: AppArgument[]): Set<string> {\n return new Set(args.filter((a) => a.secret).map((a) => a.name));\n}\n\n/** The actions with every secret argument's value replaced by the placeholder. */\nexport function redactActionValues(actions: AppPredefinedAction[], args: AppArgument[]): AppPredefinedAction[] {\n const secret = secretNames(args);\n return actions.map((action) => ({\n name: action.name,\n runArguments: Object.fromEntries(\n Object.entries(action.runArguments ?? {}).map(([name, value]) => [\n name,\n secret.has(name) ? SECRET_PLACEHOLDER : value,\n ]),\n ),\n }));\n}\n\n/**\n * Put the tenant's own values back wherever an incoming action carries the\n * placeholder.\n *\n * Actions have no id, so the stored action a placeholder stands for is the one\n * with exactly its name, and only while that name is unique on both sides: the\n * backend accepts `Daily` beside `daily`, and two actions both named `Daily`,\n * and picking one of those would write its secret into the other. Anything\n * else is refused \u2014 an ambiguous name, a new action, an argument the action\n * did not preset \u2014 since sending the placeholder on would store it as the\n * secret.\n */\nexport function restoreRedactedValues(\n incoming: AppPredefinedAction[],\n current: AppPredefinedAction[],\n): { actions: AppPredefinedAction[] } | { error: string } {\n const named = (actions: AppPredefinedAction[], name: string) => actions.filter((a) => a.name === name);\n const actions: AppPredefinedAction[] = [];\n for (const action of incoming) {\n const stored = named(current, action.name);\n const ambiguous = stored.length > 1 || named(incoming, action.name).length > 1;\n const runArguments: Record<string, string> = {};\n for (const [name, value] of Object.entries(action.runArguments ?? {})) {\n if (value !== SECRET_PLACEHOLDER) {\n runArguments[name] = value;\n continue;\n }\n if (ambiguous) {\n return {\n error: `Action \"${action.name}\" sends ${SECRET_PLACEHOLDER} for \"${name}\", but more than one action is named \"${action.name}\", so which stored value it stands for is unknown \u2014 give the real value.`,\n };\n }\n const kept = stored[0]?.runArguments?.[name];\n if (kept === undefined) {\n return {\n error: `Action \"${action.name}\" sends ${SECRET_PLACEHOLDER} for \"${name}\", but no stored action named exactly \"${action.name}\" has a value for it \u2014 give the real value.`,\n };\n }\n runArguments[name] = kept;\n }\n actions.push({ name: action.name, runArguments });\n }\n return { actions };\n}\n\n// Where a run executes: 'local' is a container on the jobrunner's own machine,\n// 'batch' is a machine created for that one run. Sizes name hardware the\n// jobrunner deployment picks, so 'batch' with no size means its default.\nexport type AppComputeSize = 's' | 'm' | 'l' | 'xl';\n\nexport type AppCompute = { type: 'local' } | { type: 'batch'; options?: { size?: AppComputeSize } | null };\n\n// The same vocabulary the UI's compute selector uses, so one job reads the same\n// whichever surface configured it.\nexport type ComputeChoice = 'local' | 'batch' | `batch:${AppComputeSize}`;\n\n// Hand-written because the generated `RemoteJobComputeSize` enum is not in the\n// client SDK release this CLI pins. The other copy of this vocabulary is\n// `frontend/src/features/remoteJobs/computeChoices.ts`, which does derive from\n// that enum \u2014 a size added to the API reaches the UI and not this list, so add\n// it in both places until the pin can be bumped.\nexport const APP_COMPUTE_SIZES: readonly AppComputeSize[] = ['s', 'm', 'l', 'xl'];\n\nexport const APP_COMPUTE_CHOICES: readonly ComputeChoice[] = [\n 'local',\n 'batch',\n ...APP_COMPUTE_SIZES.map((size) => `batch:${size}` as const),\n];\n\nexport interface RemoteApp {\n id: number;\n name: string;\n description: string;\n expectedArguments: AppArgument[];\n status: string;\n lastHeartbeat: string;\n mainScriptFileId: string | null;\n scriptFiles?: AppScriptFile[];\n sourceFolderId?: number;\n schedule?: string | null;\n runnerName?: string | null;\n runnerImage?: string | null;\n predefinedActions: AppPredefinedAction[];\n compute?: AppCompute;\n /** Base64, as the backend returns it. */\n icon?: string | null;\n}\n\n// The fields a Remote Job update writes. The backend PUT replaces the whole\n// row, so any field omitted here is reset to its default (args/predefined \u2192\n// empty, the rest \u2192 null). `mergeAppUpdate` exists so a caller that only wants\n// to touch one field doesn't silently wipe the others.\n//\n// `compute` is the exception: the backend reads an absent one as \"leave it\" and\n// an explicit null as \"reset to local\", so it is optional here and sent only\n// when there is a value to send.\nexport interface UpdateAppPayload {\n name: string;\n description: string;\n expectedArguments: AppArgument[];\n mainScriptFileId: string | null;\n sourceFolderId: number | null;\n schedule: string | null;\n runnerName: string | null;\n runnerImage: string | null;\n predefinedActions: AppPredefinedAction[];\n compute?: AppCompute;\n icon: string | null;\n}\n\n// `scriptFileIds` is accepted from callers for backwards compatibility but is\n// never sent \u2014 the backend ignores it (scripts derive from the source folder).\nexport type AppUpdateChanges = Partial<UpdateAppPayload> & { scriptFileIds?: string[] };\n\n/**\n * Overlay a caller's changes onto an app's current state to build a full,\n * non-destructive update payload. Every field the caller leaves out keeps its\n * current value \u2014 so changing one setting never clears the others.\n *\n * Nullable fields key off presence, not nullishness: passing `null` is how a\n * caller clears a schedule or a runner, and `??` would read that as \"not\n * specified\" and put the current value straight back.\n */\nexport function mergeAppUpdate(current: RemoteApp, changes: AppUpdateChanges): UpdateAppPayload {\n const payload: UpdateAppPayload = {\n name: changes.name ?? current.name,\n description: changes.description ?? current.description ?? '',\n expectedArguments: changes.expectedArguments ?? current.expectedArguments ?? [],\n mainScriptFileId: ('mainScriptFileId' in changes ? changes.mainScriptFileId : current.mainScriptFileId) ?? null,\n sourceFolderId: ('sourceFolderId' in changes ? changes.sourceFolderId : current.sourceFolderId) ?? null,\n schedule: ('schedule' in changes ? changes.schedule : current.schedule) ?? null,\n runnerName: ('runnerName' in changes ? changes.runnerName : current.runnerName) ?? null,\n runnerImage: ('runnerImage' in changes ? changes.runnerImage : current.runnerImage) ?? null,\n predefinedActions: changes.predefinedActions ?? current.predefinedActions ?? [],\n icon: ('icon' in changes ? changes.icon : current.icon) ?? null,\n };\n\n const compute = changes.compute ?? current.compute;\n if (compute) {\n payload.compute = compute;\n }\n\n return payload;\n}\n\n/**\n * Read a `--compute` value into the shape the API stores. Returns null when the\n * value isn't one of `APP_COMPUTE_CHOICES`, for the caller to report.\n */\nexport function parseComputeChoice(value: string): AppCompute | null {\n const choice = value.trim().toLowerCase();\n if (choice === 'local') {\n return { type: 'local' };\n }\n if (choice === 'batch') {\n return { type: 'batch' };\n }\n const size = choice.startsWith('batch:') ? choice.slice('batch:'.length) : null;\n if (size && (APP_COMPUTE_SIZES as readonly string[]).includes(size)) {\n return { type: 'batch', options: { size: size as AppComputeSize } };\n }\n return null;\n}\n\n/**\n * Render a stored compute selection as the choice a caller would type. An app\n * the backend didn't report one for reads as 'local', which is the default a\n * run gets.\n */\nexport function formatCompute(compute: AppCompute | undefined): ComputeChoice {\n if (compute?.type !== 'batch') {\n return 'local';\n }\n return compute.options?.size ? `batch:${compute.options.size}` : 'batch';\n}\n\nexport interface RunnerImageRepositories {\n registryPrefix: string;\n repositories: string[];\n}\n\n// A jobrunner currently connected to the tenant. `engines` is what it will run:\n// an empty list means it can run nothing for this tenant.\nexport interface ConnectedRunner {\n name: string;\n engines?: AppCompute['type'][];\n}\n\n/**\n * Expand a `--runner-image` value to the full registry reference the backend\n * stores. Accepts `<repository>:<tag>` and expands it with the tenant's registry\n * prefix, or takes an already-prefixed reference as given. Mirrors the backend's\n * own validation so a typo fails here rather than as a 400.\n */\nexport function resolveRunnerImage(\n value: string,\n registry: RunnerImageRepositories,\n): { image: string } | { error: string } {\n const known = registry.repositories.join(', ') || '(none configured)';\n const prefix = registry.registryPrefix ? `${registry.registryPrefix}/` : '';\n const rest = prefix && value.startsWith(prefix) ? value.slice(prefix.length) : value;\n\n if (rest.includes('/')) {\n return {\n error: `Runner image must be \"<repository>:<tag>\" or start with ${registry.registryPrefix}/. Available repositories: ${known}`,\n };\n }\n\n const colonIndex = rest.indexOf(':');\n if (colonIndex === -1) {\n return {\n error: `Runner image must include a tag, e.g. \"${registry.repositories[0] ?? 'runner-typescript'}:latest\"`,\n };\n }\n\n const repository = rest.slice(0, colonIndex);\n const tag = rest.slice(colonIndex + 1);\n if (!registry.repositories.includes(repository)) {\n return { error: `Unknown runner image repository \"${repository}\". Available repositories: ${known}` };\n }\n if (!tag) {\n return { error: `Runner image must include a tag, e.g. \"${repository}:latest\"` };\n }\n\n return { image: `${prefix}${repository}:${tag}` };\n}\n\n/**\n * Find a script in a source folder's file list by its exact name. Farseer file\n * names are case-sensitive \u2014 two files differing only in case can coexist in a\n * folder \u2014 so matching is exact, never case-folded, to avoid resolving an\n * entrypoint to the wrong file. Resolution is folder-scoped, never tenant-wide,\n * so a same-named file in another folder can't be picked by accident. Returns\n * undefined when the name isn't in the folder.\n */\nexport function findScriptInFolder(folderScripts: AppScriptFile[], name: string): AppScriptFile | undefined {\n return folderScripts.find((s) => s.name === name);\n}\n\n// The one client capability applySourceFolderChange needs. Kept minimal (not the\n// whole client) so it is trivial to unit-test with a fake resolver.\nexport interface SourceFolderResolver {\n resolveSourceFolder(relativePath: string): Promise<SourceFolderResolution | null>;\n}\n\n// Selects only how an error is presented \u2014 dimming, and `--flag` (CLI) vs param\n// (MCP) wording. It is a pure UX knob: the decision, the ids written to `changes`,\n// and the success/failure outcome are identical for both values. Never branch\n// functionality on it.\nexport type ConfigureCaller = 'cli' | 'mcp';\n\n/**\n * Resolve the source-folder / entrypoint settings for an `app configure` and\n * write the resulting ids into `changes`, applying the rule that an app's\n * scripts derive from its source folder and the entrypoint must be a file in\n * that folder. `sourceFolder` (a path under Files/) switches the folder;\n * otherwise the entrypoint is validated against the app's current folder. Moving\n * the folder must not orphan the entrypoint: if the current entrypoint isn't in\n * the new folder and the caller didn't supply one, the request is rejected \u2014 the\n * entrypoint is never silently cleared or relocated.\n *\n * Returns an error message for the caller to surface (and `changes` is left\n * untouched), or null once the ids have been written. The decision lives here so\n * the CLI and MCP paths can't drift.\n */\nexport async function applySourceFolderChange(\n client: SourceFolderResolver,\n app: Pick<RemoteApp, 'scriptFiles' | 'mainScriptFileId'>,\n changes: AppUpdateChanges,\n options: { sourceFolder?: string; entrypoint?: string },\n caller: ConfigureCaller,\n): Promise<string | null> {\n const cli = caller === 'cli';\n // Secondary guidance lines are dimmed in the terminal; plain for the MCP tool.\n const hint = (text: string) => (cli ? chalk.dim(text) : text);\n\n let folderScripts = app.scriptFiles ?? [];\n let sourceFolderId: number | undefined;\n\n if (options.sourceFolder) {\n // A failed request is deliberately not caught: \"no such folder\" is an\n // answer, and a 500 or a dropped connection is not one. Both callers\n // surface the throw with the status intact.\n const resolved = await client.resolveSourceFolder(options.sourceFolder);\n if (!resolved) {\n return [\n `Source folder not found under Files/: ${options.sourceFolder}`,\n hint('Use a path relative to Files/, e.g. \"Scripts/MyApp\".'),\n ].join('\\n');\n }\n sourceFolderId = resolved.id;\n folderScripts = resolved.scripts;\n\n // Moving the folder must not leave the entrypoint pointing outside it.\n if (!options.entrypoint && app.mainScriptFileId) {\n const stillThere = folderScripts.some((s) => s.id === app.mainScriptFileId);\n if (!stillThere) {\n const files = folderScripts.map((s) => s.name).join(', ') || '(none)';\n return [\n \"The app's current entrypoint is not in the new source folder.\",\n hint(\n cli\n ? 'Pass --entrypoint <script> (a file in the new folder) in the same command.'\n : 'Pass \"entrypoint\" (a file in the new folder) in the same call.',\n ),\n hint(`Files in this folder: ${files}`),\n ].join('\\n');\n }\n }\n }\n\n let mainScriptFileId: string | undefined;\n if (options.entrypoint) {\n const match = findScriptInFolder(folderScripts, options.entrypoint);\n if (!match) {\n const files = folderScripts.map((s) => s.name).join(', ') || '(none)';\n const lines = [\n `Entrypoint not found in the source folder: ${options.entrypoint}`,\n hint(`Files in this folder: ${files}`),\n ];\n if (!options.sourceFolder) {\n lines.push(\n hint(\n cli\n ? 'To use a file from another folder, set it first with --source-folder <path>.'\n : 'To use a file from another folder, pass sourceFolder first.',\n ),\n );\n }\n return lines.join('\\n');\n }\n mainScriptFileId = match.id;\n }\n\n // Apply only after every check passes, so a rejected request never partially\n // mutates `changes`.\n if (sourceFolderId !== undefined) {\n changes.sourceFolderId = sourceFolderId;\n }\n if (mainScriptFileId !== undefined) {\n changes.mainScriptFileId = mainScriptFileId;\n }\n return null;\n}\n\n// What a caller passes to clear a setting that can be unset. An empty string\n// does the same, so a shell variable that resolved to nothing reads as \"clear\"\n// rather than as a runner named ''.\nexport const CLEAR_SETTING = 'none';\n\nfunction isCleared(value: string): boolean {\n return value.trim() === '' || value.trim().toLowerCase() === CLEAR_SETTING;\n}\n\nexport interface RunSettings {\n schedule?: string;\n runner?: string;\n runnerImage?: string;\n compute?: string;\n}\n\n// The client capabilities applyRunSettings needs, kept minimal so tests can pass\n// a fake in place of a whole client.\nexport interface RunSettingsResolver {\n getRunnerImageRepositories(): Promise<RunnerImageRepositories>;\n getRunners(): Promise<ConnectedRunner[]>;\n}\n\n/**\n * Resolve the where-and-when settings for an `app configure` and write them into\n * `changes`. Returns an error string to report and abort on, or the warnings to\n * print alongside a successful update.\n *\n * Warnings rather than errors for anything that depends on a runner being\n * connected right now: these settings outlive any one connection, so a runner\n * that is merely restarting must not block configuring the job that needs it.\n */\nexport async function applyRunSettings(\n client: RunSettingsResolver,\n app: RemoteApp,\n changes: AppUpdateChanges,\n settings: RunSettings,\n): Promise<{ error: string } | { warnings: string[] }> {\n const warnings: string[] = [];\n const resolved: AppUpdateChanges = {};\n\n // Passed through as written. The CLI is one of three ways to set a schedule\n // and the only one that could check it here, so checking here would make the\n // same expression valid or invalid depending on where it was typed. The check\n // belongs in the backend, which every surface goes through.\n if (settings.schedule !== undefined) {\n resolved.schedule = isCleared(settings.schedule) ? null : settings.schedule.trim();\n }\n\n if (settings.compute !== undefined) {\n const compute = parseComputeChoice(settings.compute);\n if (!compute) {\n return {\n error: `Unknown compute selection \"${settings.compute}\". Valid values: ${APP_COMPUTE_CHOICES.join(', ')}.`,\n };\n }\n resolved.compute = compute;\n }\n\n if (settings.runner !== undefined) {\n resolved.runnerName = isCleared(settings.runner) ? null : settings.runner.trim();\n }\n\n if (settings.runnerImage !== undefined) {\n if (isCleared(settings.runnerImage)) {\n resolved.runnerImage = null;\n } else {\n const registry = await client.getRunnerImageRepositories();\n const outcome = resolveRunnerImage(settings.runnerImage.trim(), registry);\n if ('error' in outcome) {\n return outcome;\n }\n resolved.runnerImage = outcome.image;\n }\n }\n\n if ('runnerName' in resolved || 'compute' in resolved) {\n // Both sides fall back to what the job already holds, so the check sees\n // the configuration the job ends up with rather than only the half of it\n // this call happened to touch.\n const runnerName = ('runnerName' in resolved ? resolved.runnerName : app.runnerName) ?? null;\n const compute = 'compute' in resolved ? resolved.compute : app.compute;\n warnings.push(...(await runnerWarnings(client, runnerName, compute)));\n }\n\n Object.assign(changes, resolved);\n return { warnings };\n}\n\nasync function runnerWarnings(\n client: RunSettingsResolver,\n runnerName: string | null,\n compute: AppCompute | undefined,\n): Promise<string[]> {\n let runners: ConnectedRunner[];\n try {\n runners = await client.getRunners();\n } catch {\n // The settings are still valid; only the reassurance is missing.\n return [];\n }\n\n if (runnerName && !runners.some((runner) => runner.name === runnerName)) {\n const connected = runners.map((runner) => runner.name).join(', ') || '(none)';\n return [`No jobrunner named \"${runnerName}\" is connected. Currently connected: ${connected}`];\n }\n\n if (!compute) {\n return [];\n }\n\n const answering = runnerName ? runners.filter((runner) => runner.name === runnerName) : runners;\n if (answering.length === 0) {\n return [];\n }\n // A runner that reported no engines predates the field and runs in process only.\n const engine = compute.type;\n if (answering.some((runner) => (runner.engines ?? ['local']).includes(engine))) {\n return [];\n }\n\n const who = runnerName ? `Jobrunner \"${runnerName}\" does not offer` : 'No connected jobrunner offers';\n // \"shared runner\" and \"a machine per run\" are the labels the UI's compute\n // selector uses, so one job reads the same whichever surface configured it.\n const what = engine === 'batch' ? 'a machine per run' : 'runs on the shared runner';\n return [`${who} ${what}. The setting is saved; runs will fail until one does.`];\n}\n\n// `reference` (the Remote Job id) is deliberately the only id here \u2014 apps also\n// have a folder-item id, in an overlapping number space, and carrying both is\n// what let `app delete` destroy unrelated objects.\nexport interface AppListItem {\n name: string;\n type: string;\n reference: string;\n}\n\nexport const REMOTE_JOB_ITEM_TYPE = farseer.FolderItemType.RemoteJob;\n\n// A `folders.resolveItems` result: `id` is the folder-item id, `reference` the\n// id in the item's own domain (for REMOTE_JOB, the Remote Job id).\nexport interface ResolvedFolderItem {\n id: number;\n name: string;\n type: string;\n reference: string;\n}\n\nexport function remoteJobReverseReferences(remoteJobIds: readonly string[]): farseer.ReverseReference[] {\n return remoteJobIds.map((reference) => ({ reference, type: REMOTE_JOB_ITEM_TYPE }));\n}\n\n// A deliberate refusal from the delete guard, as distinct from a transport\n// failure. Callers surface it as a validation error, not a retryable one:\n// nothing was deleted and retrying cannot change that.\nexport class AppDeleteRefusedError extends Error {}\n\n/**\n * Pick the folder-item id to delete for an app, from the `resolveItems` response.\n *\n * Remote Job ids and folder-item ids overlap \u2014 the low folder ids are the roots\n * (13 = Files, 15 = Apps) \u2014 so posting a Remote Job id to `deleteItems` deletes\n * whichever unrelated node owns that number. `resolveItems` is type-scoped\n * server-side; these checks make sure a server change can't widen that.\n */\nexport function resolveAppItemNodeId(remoteJobId: string, items: readonly ResolvedFolderItem[]): number {\n const matches = items.filter((item) => item.reference === remoteJobId);\n\n if (matches.length === 0) {\n throw new AppDeleteRefusedError(`No app found for Remote Job id ${remoteJobId} \u2014 nothing was deleted.`);\n }\n if (matches.length > 1) {\n throw new AppDeleteRefusedError(\n `Remote Job id ${remoteJobId} resolved to ${matches.length} folder items \u2014 refusing to delete.`,\n );\n }\n\n const item = matches[0];\n if (item.type !== REMOTE_JOB_ITEM_TYPE) {\n throw new AppDeleteRefusedError(\n `Refusing to delete: Remote Job id ${remoteJobId} resolved to a ${item.type} ` +\n `(\"${item.name}\"), not an app.`,\n );\n }\n\n return item.id;\n}\n"],
5
+ "mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AA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;AACxD,SAAO,CAAC,GAAG,GAAG,IAAI,IAAI,wDAAwD;AAClF;AAWO,MAAM,uBAAuB,QAAQ,eAAe;AAWpD,SAAS,2BAA2B,cAA6D;AACpG,SAAO,aAAa,IAAI,CAAC,eAAe,EAAE,WAAW,MAAM,qBAAqB,EAAE;AACtF;AAKO,MAAM,8BAA8B,MAAM;AAAC;AAU3C,SAAS,qBAAqB,aAAqB,OAA8C;AACpG,QAAM,UAAU,MAAM,OAAO,CAACC,UAASA,MAAK,cAAc,WAAW;AAErE,MAAI,QAAQ,WAAW,GAAG;AACtB,UAAM,IAAI,sBAAsB,kCAAkC,WAAW,8BAAyB;AAAA,EAC1G;AACA,MAAI,QAAQ,SAAS,GAAG;AACpB,UAAM,IAAI;AAAA,MACN,iBAAiB,WAAW,gBAAgB,QAAQ,MAAM;AAAA,IAC9D;AAAA,EACJ;AAEA,QAAM,OAAO,QAAQ,CAAC;AACtB,MAAI,KAAK,SAAS,sBAAsB;AACpC,UAAM,IAAI;AAAA,MACN,qCAAqC,WAAW,kBAAkB,KAAK,IAAI,MAClE,KAAK,IAAI;AAAA,IACtB;AAAA,EACJ;AAEA,SAAO,KAAK;AAChB;",
6
+ "names": ["actions", "chalk", "item"]
7
7
  }
@@ -400,6 +400,17 @@ class FarseerService {
400
400
  }
401
401
  return app;
402
402
  }
403
+ async getRunnerImageRepositories() {
404
+ const response = await this.apiRequest("/remoteJobs/runnerImages", "GET");
405
+ return {
406
+ registryPrefix: response?.registryPrefix ?? "",
407
+ repositories: response?.repositories ?? []
408
+ };
409
+ }
410
+ async getRunners() {
411
+ const response = await this.apiRequest("/remoteJobs/runners", "GET");
412
+ return response?.runners ?? [];
413
+ }
403
414
  // Never swallow a failure into an empty array: `resolveAppItemNodeId` reads
404
415
  // "no match" as "this app doesn't exist".
405
416
  async resolveRemoteJobItems(remoteJobIds) {