farseer-cli 1.13.0 → 1.14.2
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/README.md +23 -8
- package/dist/commands/config.js +4 -3
- package/dist/commands/config.js.map +2 -2
- package/dist/commands/install.js +5 -0
- package/dist/commands/install.js.map +2 -2
- package/dist/commands/login.js +2 -2
- package/dist/commands/login.js.map +2 -2
- package/dist/commands/pipeline.js +158 -0
- package/dist/commands/pipeline.js.map +7 -0
- package/dist/commands/pull.js +2 -1
- package/dist/commands/pull.js.map +2 -2
- package/dist/commands/run.js +9 -0
- package/dist/commands/run.js.map +2 -2
- package/dist/commands/variables.js +17 -8
- package/dist/commands/variables.js.map +2 -2
- package/dist/index.js +45 -46
- package/dist/index.js.map +2 -2
- package/dist/mcp/prompts/workflows.js +13 -68
- package/dist/mcp/prompts/workflows.js.map +2 -2
- package/dist/mcp/resources/documentation.js +14 -0
- package/dist/mcp/resources/documentation.js.map +2 -2
- package/dist/mcp/server.js +14 -2
- package/dist/mcp/server.js.map +2 -2
- package/dist/mcp/skills.js +59 -0
- package/dist/mcp/skills.js.map +7 -0
- package/dist/mcp/tools/appTools.js +4 -0
- package/dist/mcp/tools/appTools.js.map +2 -2
- package/dist/mcp/tools/authTools.js +5 -3
- package/dist/mcp/tools/authTools.js.map +2 -2
- package/dist/mcp/tools/cellTools.js +3 -2
- package/dist/mcp/tools/cellTools.js.map +2 -2
- package/dist/mcp/tools/dashboardTools.js +23 -18
- package/dist/mcp/tools/dashboardTools.js.map +2 -2
- package/dist/mcp/tools/dataTools.js +16 -12
- package/dist/mcp/tools/dataTools.js.map +2 -2
- package/dist/mcp/tools/folderTools.js +5 -4
- package/dist/mcp/tools/folderTools.js.map +2 -2
- package/dist/mcp/tools/modelTools.js +33 -58
- package/dist/mcp/tools/modelTools.js.map +2 -2
- package/dist/mcp/tools/pipelineContract.js +320 -0
- package/dist/mcp/tools/pipelineContract.js.map +7 -0
- package/dist/mcp/tools/pipelineTools.js +111 -0
- package/dist/mcp/tools/pipelineTools.js.map +7 -0
- package/dist/mcp/tools/runTools.js +10 -3
- package/dist/mcp/tools/runTools.js.map +2 -2
- package/dist/mcp/tools/sheetTools.js +21 -17
- package/dist/mcp/tools/sheetTools.js.map +2 -2
- package/dist/mcp/tools/syncTools.js +15 -5
- package/dist/mcp/tools/syncTools.js.map +2 -2
- package/dist/mcp/utils/registerTool.js +32 -0
- package/dist/mcp/utils/registerTool.js.map +7 -0
- package/dist/pipeline/compatibility.js +53 -0
- package/dist/pipeline/compatibility.js.map +7 -0
- package/dist/pipeline/connect.js +139 -0
- package/dist/pipeline/connect.js.map +7 -0
- package/dist/pipeline/create.js +158 -0
- package/dist/pipeline/create.js.map +7 -0
- package/dist/pipeline/errors.js +45 -0
- package/dist/pipeline/errors.js.map +7 -0
- package/dist/pipeline/generated-reference.json +115 -0
- package/dist/pipeline/guide.js +33 -0
- package/dist/pipeline/guide.js.map +7 -0
- package/dist/pipeline/init.js +204 -0
- package/dist/pipeline/init.js.map +7 -0
- package/dist/pipeline/operations.js +106 -0
- package/dist/pipeline/operations.js.map +7 -0
- package/dist/pipeline/query.js +121 -0
- package/dist/pipeline/query.js.map +7 -0
- package/dist/pipeline/queryDownloads.js +72 -0
- package/dist/pipeline/queryDownloads.js.map +7 -0
- package/dist/pipeline/queryWorker.js +96 -0
- package/dist/pipeline/queryWorker.js.map +7 -0
- package/dist/pipeline/readiness.js +62 -0
- package/dist/pipeline/readiness.js.map +7 -0
- package/dist/pipeline/reference.js +73 -0
- package/dist/pipeline/reference.js.map +7 -0
- package/dist/pipeline/requests.js +122 -0
- package/dist/pipeline/requests.js.map +7 -0
- package/dist/pipeline/runArguments.js +68 -0
- package/dist/pipeline/runArguments.js.map +7 -0
- package/dist/pipeline/runtime.js +106 -0
- package/dist/pipeline/runtime.js.map +7 -0
- package/dist/pipeline/service.js +1027 -0
- package/dist/pipeline/service.js.map +7 -0
- package/dist/services/agentApprovalFetch.js +86 -0
- package/dist/services/agentApprovalFetch.js.map +7 -0
- package/dist/services/appSyncService.js.map +1 -1
- package/dist/services/configService.js +40 -4
- package/dist/services/configService.js.map +2 -2
- package/dist/services/credentials.js +2 -0
- package/dist/services/credentials.js.map +2 -2
- package/dist/services/farseerService.js +33 -3
- package/dist/services/farseerService.js.map +2 -2
- package/dist/services/modelExport.js.map +1 -1
- package/dist/services/preflight.js +4 -0
- package/dist/services/preflight.js.map +2 -2
- package/dist/services/syncService.js +6 -0
- package/dist/services/syncService.js.map +2 -2
- package/dist/skills/pipeline.js +71 -0
- package/dist/skills/pipeline.js.map +7 -0
- package/dist/utils/agentSandbox.js +35 -0
- package/dist/utils/agentSandbox.js.map +7 -0
- package/dist/utils/helpers.js +2 -1
- package/dist/utils/helpers.js.map +2 -2
- package/dist/utils/variableValues.js +78 -0
- package/dist/utils/variableValues.js.map +7 -0
- package/docs/pipeline-client-guide.md +67 -0
- package/docs/pipeline-reference.md +2064 -0
- package/package.json +5 -1
- package/skills/pipeline-authoring/SKILL.md +95 -0
- package/skills/pipeline-authoring/practices.md +325 -0
|
@@ -0,0 +1,96 @@
|
|
|
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 __copyProps = (to, from, except, desc) => {
|
|
9
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
10
|
+
for (let key of __getOwnPropNames(from))
|
|
11
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
12
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
13
|
+
}
|
|
14
|
+
return to;
|
|
15
|
+
};
|
|
16
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
17
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
18
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
19
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
20
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
21
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
22
|
+
mod
|
|
23
|
+
));
|
|
24
|
+
var import_node_api = require("@duckdb/node-api");
|
|
25
|
+
var path = __toESM(require("path"));
|
|
26
|
+
var import_queryDownloads = require("./queryDownloads");
|
|
27
|
+
const literal = (s) => `'${s.replace(/'/g, "''")}'`;
|
|
28
|
+
process.once("message", async (request) => {
|
|
29
|
+
const { directory, limits } = request;
|
|
30
|
+
try {
|
|
31
|
+
const { groups, downloadedBytes } = request.prepared ?? await (0, import_queryDownloads.downloadQueryFiles)(request, directory, async (address) => {
|
|
32
|
+
const url = new URL(address);
|
|
33
|
+
if (url.protocol !== "https:" && !(request.loopbackTest && url.protocol === "http:" && url.hostname === "127.0.0.1")) {
|
|
34
|
+
throw new Error("Signed access must use HTTPS");
|
|
35
|
+
}
|
|
36
|
+
return fetch(url, { redirect: "error" });
|
|
37
|
+
});
|
|
38
|
+
const files = groups.flat();
|
|
39
|
+
const db = await import_node_api.DuckDBInstance.create(":memory:", {
|
|
40
|
+
memory_limit: `${limits.memoryMb}MB`,
|
|
41
|
+
threads: String(limits.threads),
|
|
42
|
+
temp_directory: path.join(directory, "spill"),
|
|
43
|
+
max_temp_directory_size: `${limits.spillMb}MB`,
|
|
44
|
+
autoinstall_known_extensions: "false",
|
|
45
|
+
autoload_known_extensions: "false",
|
|
46
|
+
allow_unsigned_extensions: "false"
|
|
47
|
+
});
|
|
48
|
+
const connection = await db.connect();
|
|
49
|
+
await connection.run(`SET allowed_paths = [${files.map(literal).join(",")}]`);
|
|
50
|
+
await connection.run("SET enable_external_access = false");
|
|
51
|
+
for (const [i, binding] of request.bindings.entries()) {
|
|
52
|
+
if (!/^[a-zA-Z_][a-zA-Z0-9_]{0,62}$/.test(binding.name)) throw new Error("Invalid SQL binding name");
|
|
53
|
+
await connection.run(
|
|
54
|
+
`CREATE VIEW "${binding.name}" AS SELECT * FROM read_parquet([${groups[i].map(literal).join(",")}])`
|
|
55
|
+
);
|
|
56
|
+
}
|
|
57
|
+
await connection.run("SET lock_configuration = true");
|
|
58
|
+
const statements = await connection.extractStatements(request.sql);
|
|
59
|
+
if (statements.count !== 1) throw new Error("Exactly one SELECT query is supported");
|
|
60
|
+
const prepared = await statements.prepare(0);
|
|
61
|
+
if (prepared.statementType !== import_node_api.StatementType.SELECT) throw new Error("Only SELECT queries are supported");
|
|
62
|
+
prepared.destroySync();
|
|
63
|
+
const result = await connection.stream(request.sql);
|
|
64
|
+
const rows = [];
|
|
65
|
+
let bytes = 0;
|
|
66
|
+
let truncated = false;
|
|
67
|
+
outer: for await (const chunk of result.yieldRowsJson()) {
|
|
68
|
+
for (const row of chunk) {
|
|
69
|
+
const size = Buffer.byteLength(JSON.stringify(row));
|
|
70
|
+
if (rows.length >= limits.rows || bytes + size > limits.resultBytes) {
|
|
71
|
+
truncated = true;
|
|
72
|
+
break outer;
|
|
73
|
+
}
|
|
74
|
+
rows.push(row);
|
|
75
|
+
bytes += size;
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
process.send?.({
|
|
79
|
+
ok: true,
|
|
80
|
+
result: {
|
|
81
|
+
columns: result.columnNames(),
|
|
82
|
+
rows,
|
|
83
|
+
truncated,
|
|
84
|
+
complete: !truncated,
|
|
85
|
+
downloadedBytes,
|
|
86
|
+
resultBytes: bytes
|
|
87
|
+
}
|
|
88
|
+
});
|
|
89
|
+
} catch (error) {
|
|
90
|
+
const message = String(error instanceof Error ? error.message : error).replace(/https?:\/\/[^\s'"<>]+/g, "[signed URL redacted]").split(directory).join("[query temp]");
|
|
91
|
+
process.send?.({ ok: false, error: message.slice(0, 2e3) });
|
|
92
|
+
} finally {
|
|
93
|
+
process.disconnect();
|
|
94
|
+
}
|
|
95
|
+
});
|
|
96
|
+
//# sourceMappingURL=queryWorker.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../src/pipeline/queryWorker.ts"],
|
|
4
|
+
"sourcesContent": ["// Runs in a disposable child process. No tenant token or user environment is inherited.\nimport { DuckDBInstance, StatementType } from '@duckdb/node-api';\nimport * as path from 'path';\nimport type { QueryRequest } from './query';\nimport { downloadQueryFiles, type QueryFiles } from './queryDownloads';\n\nconst literal = (s: string) => `'${s.replace(/'/g, \"''\")}'`;\nprocess.once('message', async (request: QueryRequest & { directory: string; prepared?: QueryFiles }) => {\n const { directory, limits } = request;\n try {\n const { groups, downloadedBytes } =\n request.prepared ??\n (await downloadQueryFiles(request, directory, async (address) => {\n const url = new URL(address);\n if (\n url.protocol !== 'https:' &&\n !(request.loopbackTest && url.protocol === 'http:' && url.hostname === '127.0.0.1')\n ) {\n throw new Error('Signed access must use HTTPS');\n }\n // One fixed grant, no credential forwarding, redirects or automatic rebinding.\n return fetch(url, { redirect: 'error' });\n }));\n const files = groups.flat();\n const db = await DuckDBInstance.create(':memory:', {\n memory_limit: `${limits.memoryMb}MB`,\n threads: String(limits.threads),\n temp_directory: path.join(directory, 'spill'),\n max_temp_directory_size: `${limits.spillMb}MB`,\n autoinstall_known_extensions: 'false',\n autoload_known_extensions: 'false',\n allow_unsigned_extensions: 'false',\n });\n const connection = await db.connect();\n await connection.run(`SET allowed_paths = [${files.map(literal).join(',')}]`);\n await connection.run('SET enable_external_access = false');\n for (const [i, binding] of request.bindings.entries()) {\n if (!/^[a-zA-Z_][a-zA-Z0-9_]{0,62}$/.test(binding.name)) throw new Error('Invalid SQL binding name');\n await connection.run(\n `CREATE VIEW \"${binding.name}\" AS SELECT * FROM read_parquet([${groups[i].map(literal).join(',')}])`,\n );\n }\n await connection.run('SET lock_configuration = true');\n const statements = await connection.extractStatements(request.sql);\n if (statements.count !== 1) throw new Error('Exactly one SELECT query is supported');\n const prepared = await statements.prepare(0);\n if (prepared.statementType !== StatementType.SELECT) throw new Error('Only SELECT queries are supported');\n prepared.destroySync();\n // Streaming avoids materializing an unbounded result in JS. Timeout includes downloads.\n const result = await connection.stream(request.sql);\n const rows: unknown[][] = [];\n let bytes = 0;\n let truncated = false;\n outer: for await (const chunk of result.yieldRowsJson()) {\n for (const row of chunk) {\n const size = Buffer.byteLength(JSON.stringify(row));\n if (rows.length >= limits.rows || bytes + size > limits.resultBytes) {\n truncated = true;\n break outer;\n }\n rows.push(row);\n bytes += size;\n }\n }\n process.send?.({\n ok: true,\n result: {\n columns: result.columnNames(),\n rows,\n truncated,\n complete: !truncated,\n downloadedBytes,\n resultBytes: bytes,\n },\n });\n } catch (error) {\n const message = String(error instanceof Error ? error.message : error)\n .replace(/https?:\\/\\/[^\\s'\"<>]+/g, '[signed URL redacted]')\n .split(directory)\n .join('[query temp]');\n process.send?.({ ok: false, error: message.slice(0, 2000) });\n } finally {\n process.disconnect();\n }\n});\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;AACA,sBAA8C;AAC9C,WAAsB;AAEtB,4BAAoD;AAEpD,MAAM,UAAU,CAAC,MAAc,IAAI,EAAE,QAAQ,MAAM,IAAI,CAAC;AACxD,QAAQ,KAAK,WAAW,OAAO,YAAyE;AACpG,QAAM,EAAE,WAAW,OAAO,IAAI;AAC9B,MAAI;AACA,UAAM,EAAE,QAAQ,gBAAgB,IAC5B,QAAQ,YACP,UAAM,0CAAmB,SAAS,WAAW,OAAO,YAAY;AAC7D,YAAM,MAAM,IAAI,IAAI,OAAO;AAC3B,UACI,IAAI,aAAa,YACjB,EAAE,QAAQ,gBAAgB,IAAI,aAAa,WAAW,IAAI,aAAa,cACzE;AACE,cAAM,IAAI,MAAM,8BAA8B;AAAA,MAClD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cAAc,GAAG;AACrD,iBAAW,OAAO,OAAO;AACrB,cAAM,OAAO,OAAO,WAAW,KAAK,UAAU,GAAG,CAAC;AAClD,YAAI,KAAK,UAAU,OAAO,QAAQ,QAAQ,OAAO,OAAO,aAAa;AACjE,sBAAY;AACZ,gBAAM;AAAA,QACV;AACA,aAAK,KAAK,GAAG;AACb,iBAAS;AAAA,MACb;AAAA,IACJ;AACA,YAAQ,OAAO;AAAA,MACX,IAAI;AAAA,MACJ,QAAQ;AAAA,QACJ,SAAS,OAAO,YAAY;AAAA,QAC5B;AAAA,QACA;AAAA,QACA,UAAU,CAAC;AAAA,QACX;AAAA,QACA,aAAa;AAAA,MACjB;AAAA,IACJ,CAAC;AAAA,EACL,SAAS,OAAO;AACZ,UAAM,UAAU,OAAO,iBAAiB,QAAQ,MAAM,UAAU,KAAK,EAChE,QAAQ,0BAA0B,uBAAuB,EACzD,MAAM,SAAS,EACf,KAAK,cAAc;AACxB,YAAQ,OAAO,EAAE,IAAI,OAAO,OAAO,QAAQ,MAAM,GAAG,GAAI,EAAE,CAAC;AAAA,EAC/D,UAAE;AACE,YAAQ,WAAW;AAAA,EACvB;AACJ,CAAC;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
@@ -0,0 +1,62 @@
|
|
|
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 readiness_exports = {};
|
|
20
|
+
__export(readiness_exports, {
|
|
21
|
+
probeParquetAccess: () => probeParquetAccess,
|
|
22
|
+
probeParquetPrefix: () => probeParquetPrefix
|
|
23
|
+
});
|
|
24
|
+
module.exports = __toCommonJS(readiness_exports);
|
|
25
|
+
var import_requests = require("./requests");
|
|
26
|
+
async function probeParquetAccess(address) {
|
|
27
|
+
if (new URL(address).protocol !== "https:") throw new Error("Signed read access must use HTTPS");
|
|
28
|
+
await probeParquetPrefix(
|
|
29
|
+
(signal) => fetch(address, {
|
|
30
|
+
headers: { Range: "bytes=0-3" },
|
|
31
|
+
redirect: "error",
|
|
32
|
+
signal
|
|
33
|
+
})
|
|
34
|
+
);
|
|
35
|
+
}
|
|
36
|
+
async function probeParquetPrefix(open) {
|
|
37
|
+
await (0, import_requests.boundedPipelineCall)(async () => {
|
|
38
|
+
const response = await open((0, import_requests.pipelineRequestSignal)());
|
|
39
|
+
if (!response.ok || !response.body) {
|
|
40
|
+
await response.body?.cancel();
|
|
41
|
+
throw new Error(`Read probe failed (${response.status})`);
|
|
42
|
+
}
|
|
43
|
+
const reader = response.body.getReader();
|
|
44
|
+
const prefix = [];
|
|
45
|
+
try {
|
|
46
|
+
while (prefix.length < 4) {
|
|
47
|
+
const next = await reader.read();
|
|
48
|
+
if (next.done) break;
|
|
49
|
+
prefix.push(...next.value.subarray(0, 4 - prefix.length));
|
|
50
|
+
}
|
|
51
|
+
if (Buffer.from(prefix).toString("ascii") !== "PAR1") throw new Error("Probed file is not Parquet");
|
|
52
|
+
} finally {
|
|
53
|
+
await reader.cancel();
|
|
54
|
+
}
|
|
55
|
+
});
|
|
56
|
+
}
|
|
57
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
58
|
+
0 && (module.exports = {
|
|
59
|
+
probeParquetAccess,
|
|
60
|
+
probeParquetPrefix
|
|
61
|
+
});
|
|
62
|
+
//# sourceMappingURL=readiness.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../src/pipeline/readiness.ts"],
|
|
4
|
+
"sourcesContent": ["import { boundedPipelineCall, pipelineRequestSignal } from './requests';\n\n/** Probe one fixed grant without tenant credentials, redirects, or a full download. */\nexport async function probeParquetAccess(address: string): Promise<void> {\n if (new URL(address).protocol !== 'https:') throw new Error('Signed read access must use HTTPS');\n await probeParquetPrefix((signal) =>\n fetch(address, {\n headers: { Range: 'bytes=0-3' },\n redirect: 'error',\n signal,\n }),\n );\n}\n\n/** Read a file's first four bytes, confirm the Parquet magic number, and stop the download there. */\nexport async function probeParquetPrefix(open: (signal: AbortSignal) => Promise<Response>): Promise<void> {\n await boundedPipelineCall(async () => {\n // boundedPipelineCall always sets the request signal.\n const response = await open(pipelineRequestSignal()!);\n if (!response.ok || !response.body) {\n await response.body?.cancel();\n throw new Error(`Read probe failed (${response.status})`);\n }\n const reader = response.body.getReader();\n const prefix: number[] = [];\n try {\n while (prefix.length < 4) {\n const next = await reader.read();\n if (next.done) break;\n prefix.push(...next.value.subarray(0, 4 - prefix.length));\n }\n if (Buffer.from(prefix).toString('ascii') !== 'PAR1') throw new Error('Probed file is not Parquet');\n } finally {\n await reader.cancel(); // Also stops servers that ignore Range, as the API's file route does.\n }\n });\n}\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,sBAA2D;AAG3D,eAAsB,mBAAmB,SAAgC;AACrE,MAAI,IAAI,IAAI,OAAO,EAAE,aAAa,SAAU,OAAM,IAAI,MAAM,mCAAmC;AAC/F,QAAM;AAAA,IAAmB,CAAC,WACtB,MAAM,SAAS;AAAA,MACX,SAAS,EAAE,OAAO,YAAY;AAAA,MAC9B,UAAU;AAAA,MACV;AAAA,IACJ,CAAC;AAAA,EACL;AACJ;AAGA,eAAsB,mBAAmB,MAAiE;AACtG,YAAM,qCAAoB,YAAY;AAElC,UAAM,WAAW,MAAM,SAAK,uCAAsB,CAAE;AACpD,QAAI,CAAC,SAAS,MAAM,CAAC,SAAS,MAAM;AAChC,YAAM,SAAS,MAAM,OAAO;AAC5B,YAAM,IAAI,MAAM,sBAAsB,SAAS,MAAM,GAAG;AAAA,IAC5D;AACA,UAAM,SAAS,SAAS,KAAK,UAAU;AACvC,UAAM,SAAmB,CAAC;AAC1B,QAAI;AACA,aAAO,OAAO,SAAS,GAAG;AACtB,cAAM,OAAO,MAAM,OAAO,KAAK;AAC/B,YAAI,KAAK,KAAM;AACf,eAAO,KAAK,GAAG,KAAK,MAAM,SAAS,GAAG,IAAI,OAAO,MAAM,CAAC;AAAA,MAC5D;AACA,UAAI,OAAO,KAAK,MAAM,EAAE,SAAS,OAAO,MAAM,OAAQ,OAAM,IAAI,MAAM,4BAA4B;AAAA,IACtG,UAAE;AACE,YAAM,OAAO,OAAO;AAAA,IACxB;AAAA,EACJ,CAAC;AACL;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
@@ -0,0 +1,73 @@
|
|
|
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 reference_exports = {};
|
|
30
|
+
__export(reference_exports, {
|
|
31
|
+
CLI_UPDATE_INSTRUCTION: () => CLI_UPDATE_INSTRUCTION,
|
|
32
|
+
PIPELINE_ENGINE_PROFILE: () => PIPELINE_ENGINE_PROFILE,
|
|
33
|
+
engineReport: () => engineReport,
|
|
34
|
+
pipelineGuide: () => pipelineGuide
|
|
35
|
+
});
|
|
36
|
+
module.exports = __toCommonJS(reference_exports);
|
|
37
|
+
var import_generated_reference = __toESM(require("./generated-reference.json"));
|
|
38
|
+
var import_guide = require("./guide");
|
|
39
|
+
var import_constants = require("../utils/constants");
|
|
40
|
+
var import_agentSandbox = require("../utils/agentSandbox");
|
|
41
|
+
const PIPELINE_ENGINE_PROFILE = import_generated_reference.default.engineProfile;
|
|
42
|
+
function engineReport(observations) {
|
|
43
|
+
const expected = PIPELINE_ENGINE_PROFILE;
|
|
44
|
+
const started = observations.find((o) => o.event === "pipeline_started");
|
|
45
|
+
const ran = typeof started?.version === "string" ? started.version : null;
|
|
46
|
+
if (ran === null) return { ran, expected, status: "unobserved" };
|
|
47
|
+
const line = ran.split(".").slice(0, 2).join(".");
|
|
48
|
+
return { ran, expected, status: line === expected ? "match" : "mismatch" };
|
|
49
|
+
}
|
|
50
|
+
const CLI_UPDATE_INSTRUCTION = (0, import_agentSandbox.inAgentSandbox)() ? "This chat's CLI comes with its sandbox and cannot be updated here; do not try to install one. Tell the user that a new chat starts with the newest CLI this deployment provides, and that if it is still too old, a Labs admin must update the sandbox image." : "Update to the latest compatible CLI: npm install -g farseer-cli@latest. Restart the MCP connection in your AI client after updating. Until the matching CLI is published, install the build supplied by the setup owner.";
|
|
51
|
+
function pipelineGuide(topic = "method") {
|
|
52
|
+
const header = `Pipeline authoring reference: engine ${import_generated_reference.default.engineVersion}; CLI ${import_constants.CLI_VERSION}.
|
|
53
|
+
This is the bundled reference for the prepared pipeline runtime; the engine was not detected from a job.
|
|
54
|
+
|
|
55
|
+
`;
|
|
56
|
+
if (topic === "method")
|
|
57
|
+
return header + import_guide.PIPELINE_GUIDE + '\nRead topic="grammar" for the generated YAML reference, then request the model names it links to.\n' + CLI_UPDATE_INSTRUCTION;
|
|
58
|
+
if (topic === "practices") return header + import_guide.PIPELINE_PRACTICES;
|
|
59
|
+
const topics = import_generated_reference.default.topics;
|
|
60
|
+
if (topic === "grammar")
|
|
61
|
+
return header + import_generated_reference.default.notice + "\n\n" + topics.DatasetDefinition + "\nAvailable topics (use their exact names as topic):\n" + Object.keys(topics).join(", ");
|
|
62
|
+
if (!Object.prototype.hasOwnProperty.call(topics, topic))
|
|
63
|
+
throw new Error(`Unknown guide topic "${topic}". Read topic="grammar" to list supported model names.`);
|
|
64
|
+
return header + import_generated_reference.default.notice + "\n\n" + topics[topic];
|
|
65
|
+
}
|
|
66
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
67
|
+
0 && (module.exports = {
|
|
68
|
+
CLI_UPDATE_INSTRUCTION,
|
|
69
|
+
PIPELINE_ENGINE_PROFILE,
|
|
70
|
+
engineReport,
|
|
71
|
+
pipelineGuide
|
|
72
|
+
});
|
|
73
|
+
//# sourceMappingURL=reference.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../src/pipeline/reference.ts"],
|
|
4
|
+
"sourcesContent": ["import reference from './generated-reference.json';\nimport { PIPELINE_GUIDE, PIPELINE_PRACTICES } from './guide';\nimport { CLI_VERSION } from '../utils/constants';\nimport { inAgentSandbox } from '../utils/agentSandbox';\n\n/** The engine line (major.minor) this CLI's grammar describes. Patch releases keep the grammar. */\nexport const PIPELINE_ENGINE_PROFILE = reference.engineProfile;\n\nexport interface EngineReport {\n /** Engine version the run reported at startup, or null when no start marker was inspected. */\n ran: string | null;\n /** Engine line (major.minor) this CLI's bundled grammar describes. */\n expected: string;\n status: 'match' | 'mismatch' | 'unobserved';\n}\n\n/** Compare the engine line a run actually started on against the one this CLI's grammar describes. */\nexport function engineReport(observations: Record<string, unknown>[]): EngineReport {\n const expected = PIPELINE_ENGINE_PROFILE;\n const started = observations.find((o) => o.event === 'pipeline_started');\n const ran = typeof started?.version === 'string' ? started.version : null;\n if (ran === null) return { ran, expected, status: 'unobserved' };\n const line = ran.split('.').slice(0, 2).join('.');\n return { ran, expected, status: line === expected ? 'match' : 'mismatch' };\n}\n// An agent sandbox's CLI is part of its image and the sandbox cannot reach npm; a conversation keeps\n// its image, so only a new chat (on the deployment's current image) can bring a newer CLI.\nexport const CLI_UPDATE_INSTRUCTION = inAgentSandbox()\n ? \"This chat's CLI comes with its sandbox and cannot be updated here; do not try to install one. Tell the user that a new chat starts with the newest CLI this deployment provides, and that if it is still too old, a Labs admin must update the sandbox image.\"\n : 'Update to the latest compatible CLI: npm install -g farseer-cli@latest. Restart the MCP connection in your AI client after updating. Until the matching CLI is published, install the build supplied by the setup owner.';\n\nexport function pipelineGuide(topic = 'method'): string {\n const header =\n `Pipeline authoring reference: engine ${reference.engineVersion}; CLI ${CLI_VERSION}.\\n` +\n 'This is the bundled reference for the prepared pipeline runtime; the engine was not detected from a job.\\n\\n';\n if (topic === 'method')\n return (\n header +\n PIPELINE_GUIDE +\n '\\nRead topic=\"grammar\" for the generated YAML reference, then request the model names it links to.\\n' +\n CLI_UPDATE_INSTRUCTION\n );\n if (topic === 'practices') return header + PIPELINE_PRACTICES;\n const topics: Record<string, string> = reference.topics;\n if (topic === 'grammar')\n return (\n header +\n reference.notice +\n '\\n\\n' +\n topics.DatasetDefinition +\n '\\nAvailable topics (use their exact names as topic):\\n' +\n Object.keys(topics).join(', ')\n );\n if (!Object.prototype.hasOwnProperty.call(topics, topic))\n throw new Error(`Unknown guide topic \"${topic}\". Read topic=\"grammar\" to list supported model names.`);\n return header + reference.notice + '\\n\\n' + topics[topic];\n}\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,iCAAsB;AACtB,mBAAmD;AACnD,uBAA4B;AAC5B,0BAA+B;AAGxB,MAAM,0BAA0B,2BAAAA,QAAU;AAW1C,SAAS,aAAa,cAAuD;AAChF,QAAM,WAAW;AACjB,QAAM,UAAU,aAAa,KAAK,CAAC,MAAM,EAAE,UAAU,kBAAkB;AACvE,QAAM,MAAM,OAAO,SAAS,YAAY,WAAW,QAAQ,UAAU;AACrE,MAAI,QAAQ,KAAM,QAAO,EAAE,KAAK,UAAU,QAAQ,aAAa;AAC/D,QAAM,OAAO,IAAI,MAAM,GAAG,EAAE,MAAM,GAAG,CAAC,EAAE,KAAK,GAAG;AAChD,SAAO,EAAE,KAAK,UAAU,QAAQ,SAAS,WAAW,UAAU,WAAW;AAC7E;AAGO,MAAM,6BAAyB,oCAAe,IAC/C,kQACA;AAEC,SAAS,cAAc,QAAQ,UAAkB;AACpD,QAAM,SACF,wCAAwC,2BAAAA,QAAU,aAAa,SAAS,4BAAW;AAAA;AAAA;AAAA;AAEvF,MAAI,UAAU;AACV,WACI,SACA,8BACA,yGACA;AAER,MAAI,UAAU,YAAa,QAAO,SAAS;AAC3C,QAAM,SAAiC,2BAAAA,QAAU;AACjD,MAAI,UAAU;AACV,WACI,SACA,2BAAAA,QAAU,SACV,SACA,OAAO,oBACP,2DACA,OAAO,KAAK,MAAM,EAAE,KAAK,IAAI;AAErC,MAAI,CAAC,OAAO,UAAU,eAAe,KAAK,QAAQ,KAAK;AACnD,UAAM,IAAI,MAAM,wBAAwB,KAAK,wDAAwD;AACzG,SAAO,SAAS,2BAAAA,QAAU,SAAS,SAAS,OAAO,KAAK;AAC5D;",
|
|
6
|
+
"names": ["reference"]
|
|
7
|
+
}
|
|
@@ -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"],
|
|
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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,SAA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
+
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
|
+
var import_agentSandbox = require("../utils/agentSandbox");
|
|
41
|
+
const PIPELINE_RUNNER_IMAGE = import_generated_reference.default.runnerImage;
|
|
42
|
+
const RELEASE_VERSION = /^\d+\.\d+\.\d+$/;
|
|
43
|
+
function split(image) {
|
|
44
|
+
const name = image.slice(image.lastIndexOf("/") + 1);
|
|
45
|
+
if (name.includes("@")) return { repository: name.slice(0, name.indexOf("@")).split(":")[0], tag: null };
|
|
46
|
+
const colon = name.indexOf(":");
|
|
47
|
+
return colon < 0 ? { repository: name, tag: null } : { repository: name.slice(0, colon), tag: name.slice(colon + 1) };
|
|
48
|
+
}
|
|
49
|
+
function compareVersions(a, b) {
|
|
50
|
+
const [pa, pb] = [a, b].map((v) => v.split(".").map(Number));
|
|
51
|
+
for (let i = 0; i < 3; i++) if (pa[i] !== pb[i]) return pa[i] < pb[i] ? -1 : 1;
|
|
52
|
+
return 0;
|
|
53
|
+
}
|
|
54
|
+
function compareRuntime(jobImage) {
|
|
55
|
+
const bundled = split(PIPELINE_RUNNER_IMAGE);
|
|
56
|
+
const expected = bundled.tag ?? "";
|
|
57
|
+
const job = split(jobImage);
|
|
58
|
+
if (job.repository !== bundled.repository)
|
|
59
|
+
return {
|
|
60
|
+
status: "incompatible",
|
|
61
|
+
jobVersion: null,
|
|
62
|
+
expected,
|
|
63
|
+
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."
|
|
64
|
+
};
|
|
65
|
+
if (!job.tag || !RELEASE_VERSION.test(job.tag))
|
|
66
|
+
return {
|
|
67
|
+
status: "unversioned",
|
|
68
|
+
jobVersion: null,
|
|
69
|
+
expected,
|
|
70
|
+
nextAction: `The job's image "${jobImage}" is a moving tag or digest, not a released ${bundled.repository} version, so this CLI leaves the image as it is. Each run reports the engine it started on: read engine in inspect.`
|
|
71
|
+
};
|
|
72
|
+
const order = compareVersions(job.tag, expected);
|
|
73
|
+
if (order === 0) return { status: "match", jobVersion: job.tag, expected, nextAction: "" };
|
|
74
|
+
if (order < 0)
|
|
75
|
+
return {
|
|
76
|
+
status: "behind",
|
|
77
|
+
jobVersion: job.tag,
|
|
78
|
+
expected,
|
|
79
|
+
nextAction: `The job runs ${bundled.repository}:${job.tag}; this CLI authors for ${expected}. Run, pull and reads work on the job's image, but push is refused until the job is upgraded: ask the user, then run upgrade-runtime, which moves the job to ${PIPELINE_RUNNER_IMAGE} for everyone on the tenant and for its next scheduled run.${(0, import_agentSandbox.inAgentSandbox)() ? "" : " Or keep the job on its image and author with the CLI release that targets it."}`
|
|
80
|
+
};
|
|
81
|
+
return {
|
|
82
|
+
status: "ahead",
|
|
83
|
+
jobVersion: job.tag,
|
|
84
|
+
expected,
|
|
85
|
+
nextAction: `The job runs ${bundled.repository}:${job.tag}; this CLI authors for ${expected}. Run and push work on the job's image, but this CLI does not describe what the newer engine added. ${import_reference.CLI_UPDATE_INSTRUCTION}`
|
|
86
|
+
};
|
|
87
|
+
}
|
|
88
|
+
function assertPipelineRuntime(jobImage) {
|
|
89
|
+
const runtime = compareRuntime(jobImage);
|
|
90
|
+
if (runtime.status === "incompatible")
|
|
91
|
+
throw new import_errors.PipelineError(
|
|
92
|
+
"refused",
|
|
93
|
+
"PIPELINE_RUNTIME_UNSUPPORTED",
|
|
94
|
+
`Runner image "${jobImage || "(tenant default or unknown)"}" is not a Simple Pipelines runner. The existing app must be preserved.`,
|
|
95
|
+
runtime.nextAction
|
|
96
|
+
);
|
|
97
|
+
return runtime;
|
|
98
|
+
}
|
|
99
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
100
|
+
0 && (module.exports = {
|
|
101
|
+
PIPELINE_RUNNER_IMAGE,
|
|
102
|
+
assertPipelineRuntime,
|
|
103
|
+
compareRuntime,
|
|
104
|
+
compareVersions
|
|
105
|
+
});
|
|
106
|
+
//# 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';\nimport { inAgentSandbox } from '../utils/agentSandbox';\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. It never changes a job's image on its own: a job behind it is moved\n * up only by upgrade-runtime, a CLI behind a job is updated, and 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 a moving tag or digest, not a released ${bundled.repository} version, so this CLI leaves the image as it is. Each run reports the engine it started on: read engine in inspect.`,\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}. Run, pull and reads work on the job's image, but push is refused until the job is upgraded: ask the user, then run upgrade-runtime, which moves the job to ${PIPELINE_RUNNER_IMAGE} for everyone on the tenant and for its next scheduled run.${inAgentSandbox() ? '' : ' Or keep the job on its image and author with the CLI release that targets it.'}`,\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}. Run and push work on the job's image, but this CLI does not describe what the newer engine added. ${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;AAC9B,0BAA+B;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