farseer-cli 1.12.0 → 1.14.1

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.
Files changed (101) hide show
  1. package/README.md +51 -18
  2. package/dist/commands/login.js +60 -26
  3. package/dist/commands/login.js.map +2 -2
  4. package/dist/commands/logout.js +37 -12
  5. package/dist/commands/logout.js.map +3 -3
  6. package/dist/commands/pipeline.js +158 -0
  7. package/dist/commands/pipeline.js.map +7 -0
  8. package/dist/commands/run.js +10 -27
  9. package/dist/commands/run.js.map +2 -2
  10. package/dist/commands/variables.js +17 -8
  11. package/dist/commands/variables.js.map +2 -2
  12. package/dist/commands/whoami.js +10 -14
  13. package/dist/commands/whoami.js.map +2 -2
  14. package/dist/index.js +40 -46
  15. package/dist/index.js.map +2 -2
  16. package/dist/mcp/prompts/workflows.js +13 -68
  17. package/dist/mcp/prompts/workflows.js.map +2 -2
  18. package/dist/mcp/resources/documentation.js +14 -0
  19. package/dist/mcp/resources/documentation.js.map +2 -2
  20. package/dist/mcp/server.js +14 -2
  21. package/dist/mcp/server.js.map +2 -2
  22. package/dist/mcp/skills.js +59 -0
  23. package/dist/mcp/skills.js.map +7 -0
  24. package/dist/mcp/tools/appTools.js +4 -0
  25. package/dist/mcp/tools/appTools.js.map +2 -2
  26. package/dist/mcp/tools/authTools.js +5 -2
  27. package/dist/mcp/tools/authTools.js.map +2 -2
  28. package/dist/mcp/tools/dataTools.js +2 -0
  29. package/dist/mcp/tools/dataTools.js.map +2 -2
  30. package/dist/mcp/tools/modelTools.js +6 -41
  31. package/dist/mcp/tools/modelTools.js.map +2 -2
  32. package/dist/mcp/tools/pipelineContract.js +317 -0
  33. package/dist/mcp/tools/pipelineContract.js.map +7 -0
  34. package/dist/mcp/tools/pipelineTools.js +111 -0
  35. package/dist/mcp/tools/pipelineTools.js.map +7 -0
  36. package/dist/mcp/tools/runTools.js +7 -18
  37. package/dist/mcp/tools/runTools.js.map +2 -2
  38. package/dist/mcp/tools/syncTools.js +4 -0
  39. package/dist/mcp/tools/syncTools.js.map +2 -2
  40. package/dist/mcp/utils/helpers.js +16 -6
  41. package/dist/mcp/utils/helpers.js.map +3 -3
  42. package/dist/mcp/utils/session.js +14 -9
  43. package/dist/mcp/utils/session.js.map +2 -2
  44. package/dist/pipeline/compatibility.js +53 -0
  45. package/dist/pipeline/compatibility.js.map +7 -0
  46. package/dist/pipeline/connect.js +139 -0
  47. package/dist/pipeline/connect.js.map +7 -0
  48. package/dist/pipeline/create.js +158 -0
  49. package/dist/pipeline/create.js.map +7 -0
  50. package/dist/pipeline/errors.js +45 -0
  51. package/dist/pipeline/errors.js.map +7 -0
  52. package/dist/pipeline/generated-reference.json +115 -0
  53. package/dist/pipeline/guide.js +33 -0
  54. package/dist/pipeline/guide.js.map +7 -0
  55. package/dist/pipeline/init.js +204 -0
  56. package/dist/pipeline/init.js.map +7 -0
  57. package/dist/pipeline/operations.js +103 -0
  58. package/dist/pipeline/operations.js.map +7 -0
  59. package/dist/pipeline/query.js +103 -0
  60. package/dist/pipeline/query.js.map +7 -0
  61. package/dist/pipeline/queryWorker.js +119 -0
  62. package/dist/pipeline/queryWorker.js.map +7 -0
  63. package/dist/pipeline/readiness.js +55 -0
  64. package/dist/pipeline/readiness.js.map +7 -0
  65. package/dist/pipeline/reference.js +72 -0
  66. package/dist/pipeline/reference.js.map +7 -0
  67. package/dist/pipeline/requests.js +122 -0
  68. package/dist/pipeline/requests.js.map +7 -0
  69. package/dist/pipeline/runArguments.js +68 -0
  70. package/dist/pipeline/runArguments.js.map +7 -0
  71. package/dist/pipeline/runtime.js +105 -0
  72. package/dist/pipeline/runtime.js.map +7 -0
  73. package/dist/pipeline/service.js +967 -0
  74. package/dist/pipeline/service.js.map +7 -0
  75. package/dist/services/agentApprovalFetch.js +86 -0
  76. package/dist/services/agentApprovalFetch.js.map +7 -0
  77. package/dist/services/authErrors.js +2 -2
  78. package/dist/services/authErrors.js.map +2 -2
  79. package/dist/services/configService.js +74 -9
  80. package/dist/services/configService.js.map +2 -2
  81. package/dist/services/credentials.js +12 -7
  82. package/dist/services/credentials.js.map +2 -2
  83. package/dist/services/farseerService.js +94 -39
  84. package/dist/services/farseerService.js.map +2 -2
  85. package/dist/services/preflight.js +7 -2
  86. package/dist/services/preflight.js.map +2 -2
  87. package/dist/services/realms.js +67 -0
  88. package/dist/services/realms.js.map +7 -0
  89. package/dist/services/syncService.js +6 -0
  90. package/dist/services/syncService.js.map +2 -2
  91. package/dist/skills/pipeline.js +71 -0
  92. package/dist/skills/pipeline.js.map +7 -0
  93. package/dist/utils/helpers.js +2 -1
  94. package/dist/utils/helpers.js.map +2 -2
  95. package/dist/utils/variableValues.js +78 -0
  96. package/dist/utils/variableValues.js.map +7 -0
  97. package/docs/pipeline-client-guide.md +67 -0
  98. package/docs/pipeline-reference.md +2064 -0
  99. package/package.json +5 -1
  100. package/skills/pipeline-authoring/SKILL.md +95 -0
  101. package/skills/pipeline-authoring/practices.md +325 -0
@@ -0,0 +1,122 @@
1
+ "use strict";
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __export = (target, all) => {
7
+ for (var name in all)
8
+ __defProp(target, name, { get: all[name], enumerable: true });
9
+ };
10
+ var __copyProps = (to, from, except, desc) => {
11
+ if (from && typeof from === "object" || typeof from === "function") {
12
+ for (let key of __getOwnPropNames(from))
13
+ if (!__hasOwnProp.call(to, key) && key !== except)
14
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
+ }
16
+ return to;
17
+ };
18
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
+ var requests_exports = {};
20
+ __export(requests_exports, {
21
+ PIPELINE_REQUEST_TIMEOUT_MS: () => PIPELINE_REQUEST_TIMEOUT_MS,
22
+ boundedPipelineCall: () => boundedPipelineCall,
23
+ boundedPipelineClient: () => boundedPipelineClient,
24
+ pausePipelineDeadlines: () => pausePipelineDeadlines,
25
+ pipelineFetch: () => pipelineFetch,
26
+ pipelineRequestSignal: () => pipelineRequestSignal,
27
+ withPipelineRequests: () => withPipelineRequests
28
+ });
29
+ module.exports = __toCommonJS(requests_exports);
30
+ var import_async_hooks = require("async_hooks");
31
+ const PIPELINE_REQUEST_TIMEOUT_MS = 3e4;
32
+ const context = new import_async_hooks.AsyncLocalStorage();
33
+ function withPipelineRequests(fn, signal, timeoutMs = PIPELINE_REQUEST_TIMEOUT_MS) {
34
+ signal?.throwIfAborted();
35
+ return context.run({ signal, timeoutMs }, fn);
36
+ }
37
+ function pipelineRequestSignal(existing) {
38
+ const signal = context.getStore()?.signal;
39
+ signal?.throwIfAborted();
40
+ return signal && existing ? AbortSignal.any([signal, existing]) : signal ?? existing ?? void 0;
41
+ }
42
+ function pipelineFetch(fetcher = (...args) => fetch(...args)) {
43
+ return (input, init) => fetcher(input, { ...init, signal: pipelineRequestSignal(init?.signal) });
44
+ }
45
+ function pausePipelineDeadlines() {
46
+ const resume = [];
47
+ for (let current = context.getStore(); current; current = current.parent)
48
+ if (current.pause) resume.push(current.pause());
49
+ return () => resume.forEach((fn) => fn());
50
+ }
51
+ async function boundedPipelineCall(fn) {
52
+ const parent = context.getStore();
53
+ const controller = new AbortController();
54
+ const signal = parent?.signal ? AbortSignal.any([parent.signal, controller.signal]) : controller.signal;
55
+ signal.throwIfAborted();
56
+ const timeoutMs = parent?.timeoutMs ?? PIPELINE_REQUEST_TIMEOUT_MS;
57
+ let remaining = timeoutMs;
58
+ let started = Date.now();
59
+ let pauses = 0;
60
+ let finished = false;
61
+ const startTimer = () => setTimeout(
62
+ () => controller.abort(
63
+ new Error(
64
+ "Pipeline request timed out. A write may have been accepted; inspect its outcome before retrying."
65
+ )
66
+ ),
67
+ remaining
68
+ );
69
+ let timer = startTimer();
70
+ const pause = () => {
71
+ if (pauses++ === 0) {
72
+ clearTimeout(timer);
73
+ remaining = Math.max(0, remaining - (Date.now() - started));
74
+ }
75
+ let resumed = false;
76
+ return () => {
77
+ if (resumed) return;
78
+ resumed = true;
79
+ if (--pauses === 0 && !finished) {
80
+ started = Date.now();
81
+ timer = startTimer();
82
+ }
83
+ };
84
+ };
85
+ let cancel = () => void 0;
86
+ try {
87
+ return await Promise.race([
88
+ context.run({ signal, timeoutMs, parent, pause }, fn),
89
+ new Promise((_, reject) => {
90
+ cancel = () => reject(signal.reason);
91
+ signal.addEventListener("abort", cancel, { once: true });
92
+ if (signal.aborted) cancel();
93
+ })
94
+ ]);
95
+ } finally {
96
+ finished = true;
97
+ clearTimeout(timer);
98
+ signal.removeEventListener("abort", cancel);
99
+ }
100
+ }
101
+ function boundedPipelineClient(client) {
102
+ const synchronous = /* @__PURE__ */ new Set(["updateAccessToken", "isTextFile", "isBinaryFile"]);
103
+ return new Proxy(client, {
104
+ get(target, key) {
105
+ const value = Reflect.get(target, key);
106
+ if (typeof value !== "function") return value;
107
+ const call = (...args) => value.apply(target, args);
108
+ return synchronous.has(String(key)) ? call : (...args) => boundedPipelineCall(() => call(...args));
109
+ }
110
+ });
111
+ }
112
+ // Annotate the CommonJS export names for ESM import in node:
113
+ 0 && (module.exports = {
114
+ PIPELINE_REQUEST_TIMEOUT_MS,
115
+ boundedPipelineCall,
116
+ boundedPipelineClient,
117
+ pausePipelineDeadlines,
118
+ pipelineFetch,
119
+ pipelineRequestSignal,
120
+ withPipelineRequests
121
+ });
122
+ //# sourceMappingURL=requests.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../src/pipeline/requests.ts"],
4
+ "sourcesContent": ["import { AsyncLocalStorage } from 'async_hooks';\n\nexport const PIPELINE_REQUEST_TIMEOUT_MS = 30_000;\ntype RequestContext = { signal?: AbortSignal; timeoutMs: number; parent?: RequestContext; pause?: () => () => void };\nconst context = new AsyncLocalStorage<RequestContext>();\n\n// Only pipeline operations opt in. SDK helpers and authentication share their caller's\n// cancellation without changing the rest of the CLI's networking policy.\nexport function withPipelineRequests<T>(\n fn: () => Promise<T>,\n signal?: AbortSignal,\n timeoutMs = PIPELINE_REQUEST_TIMEOUT_MS,\n) {\n signal?.throwIfAborted();\n return context.run({ signal, timeoutMs }, fn);\n}\n\nexport function pipelineRequestSignal(existing?: AbortSignal | null): AbortSignal | undefined {\n const signal = context.getStore()?.signal;\n signal?.throwIfAborted();\n return signal && existing ? AbortSignal.any([signal, existing]) : (signal ?? existing ?? undefined);\n}\n\nexport function pipelineFetch(fetcher: typeof fetch = (...args) => fetch(...args)): typeof fetch {\n return (input, init) => fetcher(input, { ...init, signal: pipelineRequestSignal(init?.signal) });\n}\n\n/** Human approval is not network time. Cancellation and the turn's own deadline still apply. */\nexport function pausePipelineDeadlines(): () => void {\n const resume: (() => void)[] = [];\n for (let current = context.getStore(); current; current = current.parent)\n if (current.pause) resume.push(current.pause());\n return () => resume.forEach((fn) => fn());\n}\n\nexport async function boundedPipelineCall<T>(fn: () => Promise<T>): Promise<T> {\n const parent = context.getStore();\n const controller = new AbortController();\n const signal = parent?.signal ? AbortSignal.any([parent.signal, controller.signal]) : controller.signal;\n signal.throwIfAborted();\n const timeoutMs = parent?.timeoutMs ?? PIPELINE_REQUEST_TIMEOUT_MS;\n let remaining = timeoutMs;\n let started = Date.now();\n let pauses = 0;\n let finished = false;\n const startTimer = () =>\n setTimeout(\n () =>\n controller.abort(\n new Error(\n 'Pipeline request timed out. A write may have been accepted; inspect its outcome before retrying.',\n ),\n ),\n remaining,\n );\n let timer = startTimer();\n const pause = () => {\n if (pauses++ === 0) {\n clearTimeout(timer);\n remaining = Math.max(0, remaining - (Date.now() - started));\n }\n let resumed = false;\n return () => {\n if (resumed) return;\n resumed = true;\n if (--pauses === 0 && !finished) {\n started = Date.now();\n timer = startTimer();\n }\n };\n };\n let cancel: () => void = () => undefined;\n try {\n // The signal aborts real HTTP I/O. The race also bounds legacy helpers\n // which swallow errors or wait for a shared authentication refresh.\n return await Promise.race([\n context.run({ signal, timeoutMs, parent, pause }, fn),\n new Promise<never>((_, reject) => {\n cancel = () => reject(signal.reason);\n signal.addEventListener('abort', cancel, { once: true });\n if (signal.aborted) cancel();\n }),\n ]);\n } finally {\n finished = true;\n clearTimeout(timer);\n signal.removeEventListener('abort', cancel);\n }\n}\n\nexport function boundedPipelineClient<T extends object>(client: T): T {\n const synchronous = new Set(['updateAccessToken', 'isTextFile', 'isBinaryFile']);\n return new Proxy(client, {\n get(target, key) {\n const value = Reflect.get(target, key);\n if (typeof value !== 'function') return value;\n const call = (...args: unknown[]) => value.apply(target, args);\n return synchronous.has(String(key))\n ? call\n : (...args: unknown[]) => boundedPipelineCall(() => call(...args));\n },\n });\n}\n"],
5
+ "mappings": ";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,yBAAkC;AAE3B,MAAM,8BAA8B;AAE3C,MAAM,UAAU,IAAI,qCAAkC;AAI/C,SAAS,qBACZ,IACA,QACA,YAAY,6BACd;AACE,UAAQ,eAAe;AACvB,SAAO,QAAQ,IAAI,EAAE,QAAQ,UAAU,GAAG,EAAE;AAChD;AAEO,SAAS,sBAAsB,UAAwD;AAC1F,QAAM,SAAS,QAAQ,SAAS,GAAG;AACnC,UAAQ,eAAe;AACvB,SAAO,UAAU,WAAW,YAAY,IAAI,CAAC,QAAQ,QAAQ,CAAC,IAAK,UAAU,YAAY;AAC7F;AAEO,SAAS,cAAc,UAAwB,IAAI,SAAS,MAAM,GAAG,IAAI,GAAiB;AAC7F,SAAO,CAAC,OAAO,SAAS,QAAQ,OAAO,EAAE,GAAG,MAAM,QAAQ,sBAAsB,MAAM,MAAM,EAAE,CAAC;AACnG;AAGO,SAAS,yBAAqC;AACjD,QAAM,SAAyB,CAAC;AAChC,WAAS,UAAU,QAAQ,SAAS,GAAG,SAAS,UAAU,QAAQ;AAC9D,QAAI,QA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ACL,CAAC;AAAA,EACL,UAAE;AACE,eAAW;AACX,iBAAa,KAAK;AAClB,WAAO,oBAAoB,SAAS,MAAM;AAAA,EAC9C;AACJ;AAEO,SAAS,sBAAwC,QAAc;AAClE,QAAM,cAAc,oBAAI,IAAI,CAAC,qBAAqB,cAAc,cAAc,CAAC;AAC/E,SAAO,IAAI,MAAM,QAAQ;AAAA,IACrB,IAAI,QAAQ,KAAK;AACb,YAAM,QAAQ,QAAQ,IAAI,QAAQ,GAAG;AACrC,UAAI,OAAO,UAAU,WAAY,QAAO;AACxC,YAAM,OAAO,IAAI,SAAoB,MAAM,MAAM,QAAQ,IAAI;AAC7D,aAAO,YAAY,IAAI,OAAO,GAAG,CAAC,IAC5B,OACA,IAAI,SAAoB,oBAAoB,MAAM,KAAK,GAAG,IAAI,CAAC;AAAA,IACzE;AAAA,EACJ,CAAC;AACL;",
6
+ "names": []
7
+ }
@@ -0,0 +1,68 @@
1
+ "use strict";
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __export = (target, all) => {
7
+ for (var name in all)
8
+ __defProp(target, name, { get: all[name], enumerable: true });
9
+ };
10
+ var __copyProps = (to, from, except, desc) => {
11
+ if (from && typeof from === "object" || typeof from === "function") {
12
+ for (let key of __getOwnPropNames(from))
13
+ if (!__hasOwnProp.call(to, key) && key !== except)
14
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
+ }
16
+ return to;
17
+ };
18
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
+ var runArguments_exports = {};
20
+ __export(runArguments_exports, {
21
+ resolveRunArguments: () => resolveRunArguments
22
+ });
23
+ module.exports = __toCommonJS(runArguments_exports);
24
+ var import_errors = require("./errors");
25
+ function resolveRunArguments(declared, entries) {
26
+ const byName = new Map(declared.map((a) => [a.name, a]));
27
+ const values = /* @__PURE__ */ new Map();
28
+ for (const entry of entries) {
29
+ const at = entry.indexOf("=");
30
+ if (at <= 0)
31
+ throw refused(
32
+ declared,
33
+ `Run argument "${entry}" must be NAME=value, naming one of this job's arguments (${names(declared)}).`
34
+ );
35
+ const name = entry.slice(0, at);
36
+ const argument = byName.get(name);
37
+ if (!argument)
38
+ throw refused(declared, `${name} is not an argument of this job. Its arguments are: ${names(declared)}.`);
39
+ if (argument.fixed) throw refused(declared, `${name} is fixed on this job, so a run cannot change it.`);
40
+ if (values.has(name)) throw refused(declared, `${name} is given twice.`);
41
+ const value = entry.slice(at + 1);
42
+ if (value === "")
43
+ throw refused(
44
+ declared,
45
+ `${name} cannot be empty: the backend runs an empty value with the argument's default. Leave ${name} out to keep its default, or give it a value.`
46
+ );
47
+ values.set(name, value);
48
+ }
49
+ const given = {};
50
+ for (const [name, value] of values) given[name] = byName.get(name)?.secret ? "****" : value;
51
+ return { positional: declared.map((a) => values.get(a.name) ?? ""), given };
52
+ }
53
+ function refused(declared, message) {
54
+ return new import_errors.PipelineError(
55
+ "refused",
56
+ "INVALID_ARGUMENTS",
57
+ message,
58
+ `Pass job arguments as NAME=value, naming only this job's arguments (${names(declared)}); nothing was submitted.`
59
+ );
60
+ }
61
+ function names(declared) {
62
+ return declared.length ? declared.map((a) => a.name).join(", ") : "none";
63
+ }
64
+ // Annotate the CommonJS export names for ESM import in node:
65
+ 0 && (module.exports = {
66
+ resolveRunArguments
67
+ });
68
+ //# sourceMappingURL=runArguments.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../src/pipeline/runArguments.ts"],
4
+ "sourcesContent": ["import type { AppArgument } from '../services/apps';\nimport { PipelineError } from './errors';\n\n/**\n * Run arguments by name. The backend takes a run's arguments by position, in the order the job\n * declares them, and an empty slot keeps that argument's default. A positional value an author\n * meant for a later argument therefore lands silently in the first one, which may be a secret.\n * So the CLI and the MCP tool take `NAME=value` entries only, and this builds the positional list.\n */\nexport function resolveRunArguments(\n declared: readonly AppArgument[],\n entries: readonly string[],\n): { positional: string[]; given: Record<string, string> } {\n const byName = new Map(declared.map((a) => [a.name, a]));\n const values = new Map<string, string>();\n for (const entry of entries) {\n const at = entry.indexOf('=');\n if (at <= 0)\n throw refused(\n declared,\n `Run argument \"${entry}\" must be NAME=value, naming one of this job's arguments (${names(declared)}).`,\n );\n const name = entry.slice(0, at);\n const argument = byName.get(name);\n if (!argument)\n throw refused(declared, `${name} is not an argument of this job. Its arguments are: ${names(declared)}.`);\n if (argument.fixed) throw refused(declared, `${name} is fixed on this job, so a run cannot change it.`);\n if (values.has(name)) throw refused(declared, `${name} is given twice.`);\n const value = entry.slice(at + 1);\n if (value === '')\n throw refused(\n declared,\n `${name} cannot be empty: the backend runs an empty value with the argument's default. Leave ${name} out to keep its default, or give it a value.`,\n );\n values.set(name, value);\n }\n const given: Record<string, string> = {};\n for (const [name, value] of values) given[name] = byName.get(name)?.secret ? '****' : value;\n return { positional: declared.map((a) => values.get(a.name) ?? ''), given };\n}\n\nfunction refused(declared: readonly AppArgument[], message: string): PipelineError {\n return new PipelineError(\n 'refused',\n 'INVALID_ARGUMENTS',\n message,\n `Pass job arguments as NAME=value, naming only this job's arguments (${names(declared)}); nothing was submitted.`,\n );\n}\n\nfunction names(declared: readonly AppArgument[]): string {\n return declared.length ? declared.map((a) => a.name).join(', ') : 'none';\n}\n"],
5
+ "mappings": ";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AACA,oBAA8B;AAQvB,SAAS,oBACZ,UACA,SACuD;AACvD,QAAM,SAAS,IAAI,IAAI,SAAS,IAAI,CAAC,MAAM,CAAC,EAAE,MAAM,CAAC,CAAC,CAAC;AACvD,QAAM,SAAS,oBAAI,IAAoB;AACvC,aAAW,SAAS,SAAS;AACzB,UAAM,KAAK,MAAM,QAAQ,GAAG;AAC5B,QAAI,MAAM;AACN,YAAM;AAAA,QACF;AAAA,QACA,iBAAiB,KAAK,6DAA6D,MAAM,QAAQ,CAAC;AAAA,MACtG;AACJ,UAAM,OAAO,MAAM,MAAM,GAAG,EAAE;AAC9B,UAAM,WAAW,OAAO,IAAI,IAAI;AAChC,QAAI,CAAC;AACD,YAAM,QAAQ,UAAU,GAAG,IAAI,uDAAuD,MAAM,QAAQ,CAAC,GAAG;AAC5G,QAAI,SAAS,MAAO,OAAM,QAAQ,UAAU,GAAG,IAAI,mDAAmD;AACtG,QAAI,OAAO,IAAI,IAAI,EAAG,OAAM,QAAQ,UAAU,GAAG,IAAI,kBAAkB;AACvE,UAAM,QAAQ,MAAM,MAAM,KAAK,CAAC;AAChC,QAAI,UAAU;AACV,YAAM;AAAA,QACF;AAAA,QACA,GAAG,IAAI,wFAAwF,IAAI;AAAA,MACvG;AACJ,WAAO,IAAI,MAAM,KAAK;AAAA,EAC1B;AACA,QAAM,QAAgC,CAAC;AACvC,aAAW,CAAC,MAAM,KAAK,KAAK,OAAQ,OAAM,IAAI,IAAI,OAAO,IAAI,IAAI,GAAG,SAAS,SAAS;AACtF,SAAO,EAAE,YAAY,SAAS,IAAI,CAAC,MAAM,OAAO,IAAI,EAAE,IAAI,KAAK,EAAE,GAAG,MAAM;AAC9E;AAEA,SAAS,QAAQ,UAAkC,SAAgC;AAC/E,SAAO,IAAI;AAAA,IACP;AAAA,IACA;AAAA,IACA;AAAA,IACA,uEAAuE,MAAM,QAAQ,CAAC;AAAA,EAC1F;AACJ;AAEA,SAAS,MAAM,UAA0C;AACrD,SAAO,SAAS,SAAS,SAAS,IAAI,CAAC,MAAM,EAAE,IAAI,EAAE,KAAK,IAAI,IAAI;AACtE;",
6
+ "names": []
7
+ }
@@ -0,0 +1,105 @@
1
+ "use strict";
2
+ var __create = Object.create;
3
+ var __defProp = Object.defineProperty;
4
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
+ var __getOwnPropNames = Object.getOwnPropertyNames;
6
+ var __getProtoOf = Object.getPrototypeOf;
7
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
8
+ var __export = (target, all) => {
9
+ for (var name in all)
10
+ __defProp(target, name, { get: all[name], enumerable: true });
11
+ };
12
+ var __copyProps = (to, from, except, desc) => {
13
+ if (from && typeof from === "object" || typeof from === "function") {
14
+ for (let key of __getOwnPropNames(from))
15
+ if (!__hasOwnProp.call(to, key) && key !== except)
16
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
17
+ }
18
+ return to;
19
+ };
20
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
21
+ // If the importer is in node compatibility mode or this is not an ESM
22
+ // file that has been converted to a CommonJS file using a Babel-
23
+ // compatible transform (i.e. "__esModule" has not been set), then set
24
+ // "default" to the CommonJS "module.exports" for node compatibility.
25
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
26
+ mod
27
+ ));
28
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
29
+ var runtime_exports = {};
30
+ __export(runtime_exports, {
31
+ PIPELINE_RUNNER_IMAGE: () => PIPELINE_RUNNER_IMAGE,
32
+ assertPipelineRuntime: () => assertPipelineRuntime,
33
+ compareRuntime: () => compareRuntime,
34
+ compareVersions: () => compareVersions
35
+ });
36
+ module.exports = __toCommonJS(runtime_exports);
37
+ var import_generated_reference = __toESM(require("./generated-reference.json"));
38
+ var import_reference = require("./reference");
39
+ var import_errors = require("./errors");
40
+ const PIPELINE_RUNNER_IMAGE = import_generated_reference.default.runnerImage;
41
+ const RELEASE_VERSION = /^\d+\.\d+\.\d+$/;
42
+ function split(image) {
43
+ const name = image.slice(image.lastIndexOf("/") + 1);
44
+ if (name.includes("@")) return { repository: name.slice(0, name.indexOf("@")).split(":")[0], tag: null };
45
+ const colon = name.indexOf(":");
46
+ return colon < 0 ? { repository: name, tag: null } : { repository: name.slice(0, colon), tag: name.slice(colon + 1) };
47
+ }
48
+ function compareVersions(a, b) {
49
+ const [pa, pb] = [a, b].map((v) => v.split(".").map(Number));
50
+ for (let i = 0; i < 3; i++) if (pa[i] !== pb[i]) return pa[i] < pb[i] ? -1 : 1;
51
+ return 0;
52
+ }
53
+ function compareRuntime(jobImage) {
54
+ const bundled = split(PIPELINE_RUNNER_IMAGE);
55
+ const expected = bundled.tag ?? "";
56
+ const job = split(jobImage);
57
+ if (job.repository !== bundled.repository)
58
+ return {
59
+ status: "incompatible",
60
+ jobVersion: null,
61
+ expected,
62
+ nextAction: "Use the existing app tools to inspect, run or maintain this app in its current implementation. Do not change its runner or entrypoint to satisfy pipeline setup. Migration to Simple Pipelines requires an explicit migration request."
63
+ };
64
+ if (!job.tag || !RELEASE_VERSION.test(job.tag))
65
+ return {
66
+ status: "unversioned",
67
+ jobVersion: null,
68
+ expected,
69
+ nextAction: `The job's image "${jobImage}" is not a released ${bundled.repository} version. The next run pins it to ${PIPELINE_RUNNER_IMAGE} before submitting.`
70
+ };
71
+ const order = compareVersions(job.tag, expected);
72
+ if (order === 0) return { status: "match", jobVersion: job.tag, expected, nextAction: "" };
73
+ if (order < 0)
74
+ return {
75
+ status: "behind",
76
+ jobVersion: job.tag,
77
+ expected,
78
+ nextAction: `The job runs ${bundled.repository}:${job.tag}; this CLI authors for ${expected}. The next run moves the job to ${PIPELINE_RUNNER_IMAGE} before submitting; fix what the newer engine's preflight rejects.`
79
+ };
80
+ return {
81
+ status: "ahead",
82
+ jobVersion: job.tag,
83
+ expected,
84
+ nextAction: `The job runs ${bundled.repository}:${job.tag}; this CLI authors for ${expected}. ${import_reference.CLI_UPDATE_INSTRUCTION}`
85
+ };
86
+ }
87
+ function assertPipelineRuntime(jobImage) {
88
+ const runtime = compareRuntime(jobImage);
89
+ if (runtime.status === "incompatible")
90
+ throw new import_errors.PipelineError(
91
+ "refused",
92
+ "PIPELINE_RUNTIME_UNSUPPORTED",
93
+ `Runner image "${jobImage || "(tenant default or unknown)"}" is not a Simple Pipelines runner. The existing app must be preserved.`,
94
+ runtime.nextAction
95
+ );
96
+ return runtime;
97
+ }
98
+ // Annotate the CommonJS export names for ESM import in node:
99
+ 0 && (module.exports = {
100
+ PIPELINE_RUNNER_IMAGE,
101
+ assertPipelineRuntime,
102
+ compareRuntime,
103
+ compareVersions
104
+ });
105
+ //# sourceMappingURL=runtime.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../src/pipeline/runtime.ts"],
4
+ "sourcesContent": ["import reference from './generated-reference.json';\nimport { CLI_UPDATE_INSTRUCTION } from './reference';\nimport { PipelineError } from './errors';\n\n/** The runner image tag this CLI was released in tandem with, as `<repository>:<version>`. */\nexport const PIPELINE_RUNNER_IMAGE: string = reference.runnerImage;\n\nexport interface RuntimeComparison {\n status: 'match' | 'behind' | 'ahead' | 'unversioned' | 'incompatible';\n /** Version parsed from the job's image tag, or null when the tag is not a release version. */\n jobVersion: string | null;\n /** Version this CLI authors for. */\n expected: string;\n nextAction: string;\n}\n\nconst RELEASE_VERSION = /^\\d+\\.\\d+\\.\\d+$/;\n\nfunction split(image: string): { repository: string; tag: string | null } {\n const name = image.slice(image.lastIndexOf('/') + 1);\n if (name.includes('@')) return { repository: name.slice(0, name.indexOf('@')).split(':')[0], tag: null };\n const colon = name.indexOf(':');\n return colon < 0\n ? { repository: name, tag: null }\n : { repository: name.slice(0, colon), tag: name.slice(colon + 1) };\n}\n\n/** Numeric three-part comparison; negative when `a` is older than `b`. */\nexport function compareVersions(a: string, b: string): number {\n const [pa, pb] = [a, b].map((v) => v.split('.').map(Number));\n for (let i = 0; i < 3; i++) if (pa[i] !== pb[i]) return pa[i] < pb[i] ? -1 : 1;\n return 0;\n}\n\n/**\n * The CLI authors for exactly one engine: the one inside the runner image it was\n * released with. A job behind it is moved up on the next run; a CLI behind a job is\n * updated. Nothing moves down.\n */\nexport function compareRuntime(jobImage: string): RuntimeComparison {\n const bundled = split(PIPELINE_RUNNER_IMAGE);\n const expected = bundled.tag ?? '';\n const job = split(jobImage);\n if (job.repository !== bundled.repository)\n return {\n status: 'incompatible',\n jobVersion: null,\n expected,\n nextAction:\n 'Use the existing app tools to inspect, run or maintain this app in its current implementation. Do not change its runner or entrypoint to satisfy pipeline setup. Migration to Simple Pipelines requires an explicit migration request.',\n };\n if (!job.tag || !RELEASE_VERSION.test(job.tag))\n return {\n status: 'unversioned',\n jobVersion: null,\n expected,\n nextAction: `The job's image \"${jobImage}\" is not a released ${bundled.repository} version. The next run pins it to ${PIPELINE_RUNNER_IMAGE} before submitting.`,\n };\n const order = compareVersions(job.tag, expected);\n if (order === 0) return { status: 'match', jobVersion: job.tag, expected, nextAction: '' };\n if (order < 0)\n return {\n status: 'behind',\n jobVersion: job.tag,\n expected,\n nextAction: `The job runs ${bundled.repository}:${job.tag}; this CLI authors for ${expected}. The next run moves the job to ${PIPELINE_RUNNER_IMAGE} before submitting; fix what the newer engine's preflight rejects.`,\n };\n return {\n status: 'ahead',\n jobVersion: job.tag,\n expected,\n nextAction: `The job runs ${bundled.repository}:${job.tag}; this CLI authors for ${expected}. ${CLI_UPDATE_INSTRUCTION}`,\n };\n}\n\n/** Version pinning may upgrade Simple Pipelines, but must never convert another kind of app. */\nexport function assertPipelineRuntime(jobImage: string): RuntimeComparison {\n const runtime = compareRuntime(jobImage);\n if (runtime.status === 'incompatible')\n throw new PipelineError(\n 'refused',\n 'PIPELINE_RUNTIME_UNSUPPORTED',\n `Runner image \"${jobImage || '(tenant default or unknown)'}\" is not a Simple Pipelines runner. The existing app must be preserved.`,\n runtime.nextAction,\n );\n return runtime;\n}\n"],
5
+ "mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,iCAAsB;AACtB,uBAAuC;AACvC,oBAA8B;AAGvB,MAAM,wBAAgC,2BAAAA,QAAU;AAWvD,MAAM,kBAAkB;AAExB,SAAS,MAAM,OAA2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