farseer-cli 1.13.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.
- package/README.md +23 -8
- package/dist/commands/pipeline.js +158 -0
- package/dist/commands/pipeline.js.map +7 -0
- package/dist/commands/variables.js +17 -8
- package/dist/commands/variables.js.map +2 -2
- package/dist/index.js +40 -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/dataTools.js +2 -0
- package/dist/mcp/tools/dataTools.js.map +2 -2
- package/dist/mcp/tools/modelTools.js +6 -41
- package/dist/mcp/tools/modelTools.js.map +2 -2
- package/dist/mcp/tools/pipelineContract.js +317 -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 +2 -0
- package/dist/mcp/tools/runTools.js.map +2 -2
- package/dist/mcp/tools/syncTools.js +4 -0
- package/dist/mcp/tools/syncTools.js.map +2 -2
- 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 +103 -0
- package/dist/pipeline/operations.js.map +7 -0
- package/dist/pipeline/query.js +103 -0
- package/dist/pipeline/query.js.map +7 -0
- package/dist/pipeline/queryWorker.js +119 -0
- package/dist/pipeline/queryWorker.js.map +7 -0
- package/dist/pipeline/readiness.js +55 -0
- package/dist/pipeline/readiness.js.map +7 -0
- package/dist/pipeline/reference.js +72 -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 +105 -0
- package/dist/pipeline/runtime.js.map +7 -0
- package/dist/pipeline/service.js +967 -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/configService.js +29 -0
- 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 +10 -3
- package/dist/services/farseerService.js.map +2 -2
- 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/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,139 @@
|
|
|
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 connect_exports = {};
|
|
30
|
+
__export(connect_exports, {
|
|
31
|
+
connectPipeline: () => connectPipeline,
|
|
32
|
+
openPipelineConnection: () => openPipelineConnection,
|
|
33
|
+
pipelinePaths: () => pipelinePaths,
|
|
34
|
+
profileFile: () => profileFile,
|
|
35
|
+
readPipelineProfile: () => readPipelineProfile,
|
|
36
|
+
resolveProfileFile: () => resolveProfileFile
|
|
37
|
+
});
|
|
38
|
+
module.exports = __toCommonJS(connect_exports);
|
|
39
|
+
var fs = __toESM(require("fs"));
|
|
40
|
+
var path = __toESM(require("path"));
|
|
41
|
+
var import_preflight = require("../services/preflight");
|
|
42
|
+
var import_helpers = require("../utils/helpers");
|
|
43
|
+
var import_service = require("./service");
|
|
44
|
+
var import_compatibility = require("./compatibility");
|
|
45
|
+
var import_requests = require("./requests");
|
|
46
|
+
var import_errors = require("./errors");
|
|
47
|
+
const LEGACY_PROFILE = ".pipeline.json";
|
|
48
|
+
const PROFILES_DIR = ".pipelines";
|
|
49
|
+
function pipelinePaths(tenant) {
|
|
50
|
+
const profileDir = (0, import_helpers.getTenantDir)(tenant);
|
|
51
|
+
return { profileDir, filesDir: (0, import_helpers.getTenantFilesDir)(tenant), stateRoot: path.join(profileDir, ".pipeline-runs") };
|
|
52
|
+
}
|
|
53
|
+
function profileFile(profileDir, name) {
|
|
54
|
+
if (!name || name.includes("/") || name.includes("\\") || name === "." || name === "..")
|
|
55
|
+
throw new Error(`"${name}" is not a pipeline folder name`);
|
|
56
|
+
return path.join(profileDir, PROFILES_DIR, `${name}.json`);
|
|
57
|
+
}
|
|
58
|
+
function namedProfiles(profileDir) {
|
|
59
|
+
const dir = path.join(profileDir, PROFILES_DIR);
|
|
60
|
+
if (!fs.existsSync(dir)) return [];
|
|
61
|
+
return fs.readdirSync(dir).filter((f) => f.endsWith(".json")).map((f) => f.slice(0, -".json".length)).sort();
|
|
62
|
+
}
|
|
63
|
+
function resolveProfileFile(profileDir, selection) {
|
|
64
|
+
if (selection.profile && selection.pipeline)
|
|
65
|
+
throw new import_errors.PipelineError(
|
|
66
|
+
"refused",
|
|
67
|
+
"PIPELINE_SELECTION",
|
|
68
|
+
"Select the pipeline by name (pipeline=<name>) or give a profile file (profile=<path>), not both",
|
|
69
|
+
"Pass one selector only."
|
|
70
|
+
);
|
|
71
|
+
if (selection.profile) return selection.profile;
|
|
72
|
+
if (selection.pipeline) {
|
|
73
|
+
const file = profileFile(profileDir, selection.pipeline);
|
|
74
|
+
if (!fs.existsSync(file)) throw setupRequired(`No profile for pipeline "${selection.pipeline}" at ${file}`);
|
|
75
|
+
return file;
|
|
76
|
+
}
|
|
77
|
+
const names = namedProfiles(profileDir);
|
|
78
|
+
if (names.length === 1) return profileFile(profileDir, names[0]);
|
|
79
|
+
if (names.length > 1)
|
|
80
|
+
throw new import_errors.PipelineError(
|
|
81
|
+
"refused",
|
|
82
|
+
"PIPELINE_SELECTION",
|
|
83
|
+
`Several pipelines have profiles: ${names.join(", ")}. Select the pipeline by name (pipeline=<name>)`,
|
|
84
|
+
"Pass pipeline=<name> naming one of the listed pipelines."
|
|
85
|
+
);
|
|
86
|
+
const legacy = path.join(profileDir, LEGACY_PROFILE);
|
|
87
|
+
if (fs.existsSync(legacy)) return legacy;
|
|
88
|
+
throw setupRequired(`No pipeline profile under ${profileDir}`);
|
|
89
|
+
}
|
|
90
|
+
function setupRequired(detail) {
|
|
91
|
+
return new import_errors.PipelineError(
|
|
92
|
+
"refused",
|
|
93
|
+
"SETUP_REQUIRED",
|
|
94
|
+
`${detail}; initialise the pipeline first (pipeline init)`,
|
|
95
|
+
"Run init with a prepared jobId or a new name, or ask the setup owner to prepare the job, source and output datasets. Do not substitute a local app or direct import."
|
|
96
|
+
);
|
|
97
|
+
}
|
|
98
|
+
async function openPipelineConnection(organisation, tenant, validatedSession) {
|
|
99
|
+
let result = validatedSession;
|
|
100
|
+
if (result && (result.organisation !== organisation || result.tenant !== tenant))
|
|
101
|
+
throw new Error("Validated connection does not match the selected tenant");
|
|
102
|
+
if (!result) {
|
|
103
|
+
const outcome = await (0, import_requests.boundedPipelineCall)(() => (0, import_preflight.openTenantSession)(organisation, tenant));
|
|
104
|
+
if (!outcome.ok)
|
|
105
|
+
throw new import_errors.PipelineError(
|
|
106
|
+
"refused",
|
|
107
|
+
"TENANT_CONNECTION_REFUSED",
|
|
108
|
+
`Cannot connect to ${organisation}/${tenant}: ${outcome.failure.reason}. Check the tenant and sign in.`,
|
|
109
|
+
"Check the tenant selection and sign in before retrying."
|
|
110
|
+
);
|
|
111
|
+
result = (0, import_preflight.sessionFrom)(outcome.organisation, outcome.tenant, outcome.auth);
|
|
112
|
+
}
|
|
113
|
+
const client = result.client;
|
|
114
|
+
await (0, import_compatibility.checkPipelineCompatibility)((0, import_requests.boundedPipelineClient)(client));
|
|
115
|
+
return client;
|
|
116
|
+
}
|
|
117
|
+
function readPipelineProfile(file) {
|
|
118
|
+
return (0, import_service.readPipelineProfileFile)(file);
|
|
119
|
+
}
|
|
120
|
+
async function connectPipeline(organisation, tenant, selection, validatedSession) {
|
|
121
|
+
const paths = pipelinePaths(tenant);
|
|
122
|
+
const profile = readPipelineProfile(resolveProfileFile(paths.profileDir, selection));
|
|
123
|
+
if (profile.organisation !== organisation || profile.tenant !== tenant)
|
|
124
|
+
throw new Error(
|
|
125
|
+
`Pipeline profile belongs to ${profile.organisation}/${profile.tenant}, not ${organisation}/${tenant}. If the pipeline was copied from another tenant, delete the copied .pipelines/ entry and run init name=<folder> here; only files/<name>/ moves between tenants.`
|
|
126
|
+
);
|
|
127
|
+
const client = await openPipelineConnection(organisation, tenant, validatedSession);
|
|
128
|
+
return new import_service.PipelineService(profile, client, paths.filesDir, paths.stateRoot, void 0);
|
|
129
|
+
}
|
|
130
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
131
|
+
0 && (module.exports = {
|
|
132
|
+
connectPipeline,
|
|
133
|
+
openPipelineConnection,
|
|
134
|
+
pipelinePaths,
|
|
135
|
+
profileFile,
|
|
136
|
+
readPipelineProfile,
|
|
137
|
+
resolveProfileFile
|
|
138
|
+
});
|
|
139
|
+
//# sourceMappingURL=connect.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../src/pipeline/connect.ts"],
|
|
4
|
+
"sourcesContent": ["import * as fs from 'fs';\nimport * as path from 'path';\nimport { openTenantSession, sessionFrom, type TenantSession } from '../services/preflight';\nimport { getTenantDir, getTenantFilesDir } from '../utils/helpers';\nimport { PipelineClient, PipelineProfile, PipelineService, readPipelineProfileFile } from './service';\nimport { checkPipelineCompatibility } from './compatibility';\nimport { boundedPipelineCall, boundedPipelineClient } from './requests';\nimport { PipelineError } from './errors';\n\nexport interface PipelinePaths {\n /** Holds .pipelines/<name>.json, the legacy .pipeline.json and the local run state. */\n profileDir: string;\n filesDir: string;\n stateRoot: string;\n}\n/** Which profile a command works on: an explicit file, a pipeline name, or neither. */\nexport interface ProfileSelection {\n profile?: string;\n pipeline?: string;\n}\n\nconst LEGACY_PROFILE = '.pipeline.json';\nconst PROFILES_DIR = '.pipelines';\n\nexport function pipelinePaths(tenant: string): PipelinePaths {\n const profileDir = getTenantDir(tenant);\n return { profileDir, filesDir: getTenantFilesDir(tenant), stateRoot: path.join(profileDir, '.pipeline-runs') };\n}\n\n/** A profile is named after its pipeline folder, the last segment of the workspace path. */\nexport function profileFile(profileDir: string, name: string): string {\n if (!name || name.includes('/') || name.includes('\\\\') || name === '.' || name === '..')\n throw new Error(`\"${name}\" is not a pipeline folder name`);\n return path.join(profileDir, PROFILES_DIR, `${name}.json`);\n}\n\nfunction namedProfiles(profileDir: string): string[] {\n const dir = path.join(profileDir, PROFILES_DIR);\n if (!fs.existsSync(dir)) return [];\n return fs\n .readdirSync(dir)\n .filter((f) => f.endsWith('.json'))\n .map((f) => f.slice(0, -'.json'.length))\n .sort();\n}\n\n/**\n * The one rule every command uses to find its profile. Exactly one named profile is\n * taken without being asked; the legacy single .pipeline.json still works on its own.\n */\nexport function resolveProfileFile(profileDir: string, selection: ProfileSelection): string {\n if (selection.profile && selection.pipeline)\n throw new PipelineError(\n 'refused',\n 'PIPELINE_SELECTION',\n 'Select the pipeline by name (pipeline=<name>) or give a profile file (profile=<path>), not both',\n 'Pass one selector only.',\n );\n if (selection.profile) return selection.profile;\n if (selection.pipeline) {\n const file = profileFile(profileDir, selection.pipeline);\n if (!fs.existsSync(file)) throw setupRequired(`No profile for pipeline \"${selection.pipeline}\" at ${file}`);\n return file;\n }\n const names = namedProfiles(profileDir);\n if (names.length === 1) return profileFile(profileDir, names[0]);\n if (names.length > 1)\n throw new PipelineError(\n 'refused',\n 'PIPELINE_SELECTION',\n `Several pipelines have profiles: ${names.join(', ')}. Select the pipeline by name (pipeline=<name>)`,\n 'Pass pipeline=<name> naming one of the listed pipelines.',\n );\n const legacy = path.join(profileDir, LEGACY_PROFILE);\n if (fs.existsSync(legacy)) return legacy;\n throw setupRequired(`No pipeline profile under ${profileDir}`);\n}\n\nfunction setupRequired(detail: string): PipelineError {\n return new PipelineError(\n 'refused',\n 'SETUP_REQUIRED',\n `${detail}; initialise the pipeline first (pipeline init)`,\n 'Run init with a prepared jobId or a new name, or ask the setup owner to prepare the job, source and output datasets. Do not substitute a local app or direct import.',\n );\n}\n\n/** Sign in (unless a validated session is supplied) and confirm protocol compatibility. */\nexport async function openPipelineConnection(\n organisation: string,\n tenant: string,\n validatedSession?: TenantSession,\n): Promise<PipelineClient> {\n let result = validatedSession;\n if (result && (result.organisation !== organisation || result.tenant !== tenant))\n throw new Error('Validated connection does not match the selected tenant');\n if (!result) {\n const outcome = await boundedPipelineCall(() => openTenantSession(organisation, tenant));\n if (!outcome.ok)\n throw new PipelineError(\n 'refused',\n 'TENANT_CONNECTION_REFUSED',\n `Cannot connect to ${organisation}/${tenant}: ${outcome.failure.reason}. Check the tenant and sign in.`,\n 'Check the tenant selection and sign in before retrying.',\n );\n result = sessionFrom(outcome.organisation, outcome.tenant, outcome.auth);\n }\n const client = result.client as PipelineClient;\n await checkPipelineCompatibility(boundedPipelineClient(client));\n return client;\n}\n\nexport function readPipelineProfile(file: string): PipelineProfile {\n return readPipelineProfileFile(file);\n}\n\nexport async function connectPipeline(\n organisation: string,\n tenant: string,\n selection: ProfileSelection,\n validatedSession?: TenantSession,\n) {\n const paths = pipelinePaths(tenant);\n const profile = readPipelineProfile(resolveProfileFile(paths.profileDir, selection));\n if (profile.organisation !== organisation || profile.tenant !== tenant)\n throw new Error(\n `Pipeline profile belongs to ${profile.organisation}/${profile.tenant}, not ${organisation}/${tenant}. If the pipeline was copied from another tenant, delete the copied .pipelines/ entry and run init name=<folder> here; only files/<name>/ moves between tenants.`,\n );\n const client = await openPipelineConnection(organisation, tenant, validatedSession);\n return new PipelineService(profile, client, paths.filesDir, paths.stateRoot, undefined);\n}\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,SAAoB;AACpB,WAAsB;AACtB,uBAAmE;AACnE,qBAAgD;AAChD,qBAA0F;AAC1F,2BAA2C;AAC3C,sBAA2D;AAC3D,oBAA8B;AAc9B,MAAM,iBAAiB;AACvB,MAAM,eAAe;AAEd,SAAS,cAAc,QAA+B;AACzD,QAAM,iBAAa,6BAAa,MAAM;AACtC,SAAO,EAAE,YAAY,cAAU,kCAAkB,MAAM,GAAG,WAAW,KAAK,KAAK,YAAY,gBAAgB,EAAE;AACjH;AAGO,SAAS,YAAY,YAAoB,MAAsB;AAClE,MAAI,CAAC,QAAQ,KAAK,SAAS,GAAG,KAAK,KAAK,SAAS,IAAI,KAAK,SAAS,OAAO,SAAS;AAC/E,UAAM,IAAI,MAAM,IAAI,IAAI,iCAAiC;AAC7D,SAAO,KAAK,KAAK,YAAY,cAAc,GAAG,IAAI,OAAO;AAC7D;AAEA,SAAS,cAAc,YAA8B;AACjD,QAAM,MAAM,KAAK,KAAK,YAAY,YAAY;AAC9C,MAAI,CAAC,GAAG,WAAW,GAAG,EAAG,QAAO,CAAC;AACjC,SAAO,GACF,YAAY,GAAG,EACf,OAAO,CAAC,MAAM,EAAE,SAAS,OAAO,CAAC,EACjC,IAAI,CAAC,MAAM,EAAE,MAAM,GAAG,CAAC,QAAQ,MAAM,CAAC,EACtC,KAAK;AACd;AAMO,SAAS,mBAAmB,YAAoB,WAAqC;AACxF,MAAI,UAAU,WAAW,UAA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,QAAM,SAAS,OAAO;AACtB,YAAM,qDAA2B,uCAAsB,MAAM,CAAC;AAC9D,SAAO;AACX;AAEO,SAAS,oBAAoB,MAA+B;AAC/D,aAAO,wCAAwB,IAAI;AACvC;AAEA,eAAsB,gBAClB,cACA,QACA,WACA,kBACF;AACE,QAAM,QAAQ,cAAc,MAAM;AAClC,QAAM,UAAU,oBAAoB,mBAAmB,MAAM,YAAY,SAAS,CAAC;AACnF,MAAI,QAAQ,iBAAiB,gBAAgB,QAAQ,WAAW;AAC5D,UAAM,IAAI;AAAA,MACN,+BAA+B,QAAQ,YAAY,IAAI,QAAQ,MAAM,SAAS,YAAY,IAAI,MAAM;AAAA,IACxG;AACJ,QAAM,SAAS,MAAM,uBAAuB,cAAc,QAAQ,gBAAgB;AAClF,SAAO,IAAI,+BAAgB,SAAS,QAAQ,MAAM,UAAU,MAAM,WAAW,MAAS;AAC1F;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
@@ -0,0 +1,158 @@
|
|
|
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 create_exports = {};
|
|
30
|
+
__export(create_exports, {
|
|
31
|
+
createPipeline: () => createPipeline
|
|
32
|
+
});
|
|
33
|
+
module.exports = __toCommonJS(create_exports);
|
|
34
|
+
var fs = __toESM(require("fs"));
|
|
35
|
+
var path = __toESM(require("path"));
|
|
36
|
+
var import_apps = require("../services/apps");
|
|
37
|
+
var import_connect = require("./connect");
|
|
38
|
+
var import_init = require("./init");
|
|
39
|
+
var import_service = require("./service");
|
|
40
|
+
var import_runtime = require("./runtime");
|
|
41
|
+
const ENTRYPOINT = "main.py";
|
|
42
|
+
const STARTER_MAIN = `from farseer_simple_pipelines.runner import run_pipeline
|
|
43
|
+
from farseer_simple_pipelines.storage import StoreType
|
|
44
|
+
from farseer_simple_pipelines.authoring import PipelinePolicy
|
|
45
|
+
run_pipeline(store_type=StoreType.DATASETS, pipeline_policy=PipelinePolicy(), experimental__emit_pipeline_visualization_markers=True)
|
|
46
|
+
`;
|
|
47
|
+
const FOLDER_NAME = /^[A-Za-z0-9][A-Za-z0-9._ -]*$/;
|
|
48
|
+
async function createPipeline(options, client, paths) {
|
|
49
|
+
const { name } = options;
|
|
50
|
+
if (!FOLDER_NAME.test(name)) throw new Error(`"${name}" is not a plain pipeline folder name`);
|
|
51
|
+
const workspaceDir = path.join(paths.filesDir, name);
|
|
52
|
+
const adopting = fs.existsSync(workspaceDir);
|
|
53
|
+
const scope = { workspace: name, entrypoint: ENTRYPOINT, configFiles: [] };
|
|
54
|
+
const entry = `${name}/${ENTRYPOINT}`;
|
|
55
|
+
const sources = adopting ? (0, import_service.localSourceFiles)(scope, paths.filesDir).sort(
|
|
56
|
+
(a, b) => a === entry ? -1 : b === entry ? 1 : a.localeCompare(b)
|
|
57
|
+
) : [];
|
|
58
|
+
if (adopting && !sources.includes(entry))
|
|
59
|
+
throw new Error(
|
|
60
|
+
`Local folder ${workspaceDir} exists but has no ${ENTRYPOINT}; it is not a pipeline folder. Pick another name or add the entrypoint.`
|
|
61
|
+
);
|
|
62
|
+
refuseForeignProfile((0, import_connect.profileFile)(paths.profileDir, name), options);
|
|
63
|
+
if ((await client.listApps()).some((app) => app.name === name))
|
|
64
|
+
throw new Error(
|
|
65
|
+
`Job "${name}" already exists on ${options.tenant}; pick another name or attach to that job (init jobId=<id>)`
|
|
66
|
+
);
|
|
67
|
+
if (await client.resolveSourceFolder(name))
|
|
68
|
+
throw new Error(
|
|
69
|
+
`Folder "${name}" already exists under Files on ${options.tenant}; attach to its prepared job (init jobId=<id>) or pick another name`
|
|
70
|
+
);
|
|
71
|
+
const image = (0, import_apps.resolveRunnerImage)(import_runtime.PIPELINE_RUNNER_IMAGE, await client.getRunnerImageRepositories());
|
|
72
|
+
if ("error" in image) throw new Error(image.error);
|
|
73
|
+
if (!await client.getFolderByPath(["Apps"]))
|
|
74
|
+
throw new Error(
|
|
75
|
+
`This user cannot see the Apps folder on ${options.tenant}, so init cannot create the job. Ask the tenant admin for the remote jobs feature (FEATURE.REMOTE_JOBS), then rerun init.`
|
|
76
|
+
);
|
|
77
|
+
const files = adopting ? sources.map((file) => {
|
|
78
|
+
const inner = file.slice(name.length + 1).split("/");
|
|
79
|
+
return {
|
|
80
|
+
name: inner[inner.length - 1],
|
|
81
|
+
folder: inner.slice(0, -1),
|
|
82
|
+
content: fs.readFileSync(path.join(paths.filesDir, file), "utf8")
|
|
83
|
+
};
|
|
84
|
+
}) : [{ name: ENTRYPOINT, folder: [], content: STARTER_MAIN }];
|
|
85
|
+
if (!adopting) writeScaffold(workspaceDir, files);
|
|
86
|
+
const created = [];
|
|
87
|
+
try {
|
|
88
|
+
for (const file of files) {
|
|
89
|
+
await client.createFile(file.content, file.name, ["Files", name, ...file.folder]);
|
|
90
|
+
created.push([name, ...file.folder, file.name].join("/"));
|
|
91
|
+
}
|
|
92
|
+
const folder = await client.resolveSourceFolder(name);
|
|
93
|
+
const script = folder?.scripts.find((s) => s.name === ENTRYPOINT);
|
|
94
|
+
if (!folder || !script) throw new Error(`Uploaded ${ENTRYPOINT} was not found in the new folder "${name}"`);
|
|
95
|
+
const job = await client.createApp(name);
|
|
96
|
+
created.push(`job ${job.id}`);
|
|
97
|
+
await client.updateApp(
|
|
98
|
+
String(job.id),
|
|
99
|
+
{ sourceFolderId: folder.id, mainScriptFileId: script.id, runnerImage: image.image },
|
|
100
|
+
job
|
|
101
|
+
);
|
|
102
|
+
const init = await (0, import_init.initPipelineProfile)(
|
|
103
|
+
{ organisation: options.organisation, tenant: options.tenant, jobId: job.id, workspace: name },
|
|
104
|
+
client,
|
|
105
|
+
paths
|
|
106
|
+
);
|
|
107
|
+
await new import_service.PipelineService(init.profile, client, paths.filesDir, paths.stateRoot).syncSources("pull");
|
|
108
|
+
return {
|
|
109
|
+
organisation: options.organisation,
|
|
110
|
+
tenant: options.tenant,
|
|
111
|
+
jobId: job.id,
|
|
112
|
+
name,
|
|
113
|
+
workspace: name,
|
|
114
|
+
profile: init.file,
|
|
115
|
+
source: adopting ? "adopted" : "scaffold",
|
|
116
|
+
created: {
|
|
117
|
+
folder: { id: folder.id, path: name },
|
|
118
|
+
job: { id: job.id, name },
|
|
119
|
+
files: created.filter((c) => !c.startsWith("job "))
|
|
120
|
+
},
|
|
121
|
+
pendingDatasets: init.pendingDatasets,
|
|
122
|
+
warnings: init.warnings
|
|
123
|
+
};
|
|
124
|
+
} catch (error) {
|
|
125
|
+
const remoteFolder = await client.resolveSourceFolder(name).then(
|
|
126
|
+
(folder) => folder ? "present" : "absent",
|
|
127
|
+
() => "unknown"
|
|
128
|
+
);
|
|
129
|
+
const leftover = [
|
|
130
|
+
...remoteFolder === "present" ? [`folder Files/${name}`] : [],
|
|
131
|
+
...remoteFolder === "unknown" ? [`possibly folder Files/${name} (could not check)`] : [],
|
|
132
|
+
...created
|
|
133
|
+
];
|
|
134
|
+
throw new Error(
|
|
135
|
+
`${String(error)}. Created before the failure and left in place: ${leftover.length ? leftover.join(", ") : "nothing remote"}; local scaffold ${workspaceDir}`
|
|
136
|
+
);
|
|
137
|
+
}
|
|
138
|
+
}
|
|
139
|
+
function refuseForeignProfile(file, options) {
|
|
140
|
+
if (!fs.existsSync(file)) return;
|
|
141
|
+
const existing = (0, import_service.readPipelineProfileFile)(file);
|
|
142
|
+
if (existing.organisation !== options.organisation || existing.tenant !== options.tenant)
|
|
143
|
+
throw new Error(
|
|
144
|
+
`Profile ${file} belongs to ${existing.organisation}/${existing.tenant}, not ${options.organisation}/${options.tenant}. It was copied along with the pipeline; delete it and rerun init. Only files/<name>/ moves between tenants.`
|
|
145
|
+
);
|
|
146
|
+
throw new Error(`Profile ${file} already exists; this pipeline is initialised on ${options.tenant}`);
|
|
147
|
+
}
|
|
148
|
+
function writeScaffold(workspaceDir, files) {
|
|
149
|
+
fs.mkdirSync(path.join(workspaceDir, "Models"), { recursive: true });
|
|
150
|
+
fs.mkdirSync(path.join(workspaceDir, "Code"), { recursive: true });
|
|
151
|
+
for (const file of files) fs.writeFileSync(path.join(workspaceDir, ...file.folder, file.name), file.content);
|
|
152
|
+
fs.writeFileSync(path.join(workspaceDir, "Code", ".gitkeep"), "");
|
|
153
|
+
}
|
|
154
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
155
|
+
0 && (module.exports = {
|
|
156
|
+
createPipeline
|
|
157
|
+
});
|
|
158
|
+
//# sourceMappingURL=create.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../src/pipeline/create.ts"],
|
|
4
|
+
"sourcesContent": ["import * as fs from 'fs';\nimport * as path from 'path';\nimport { resolveRunnerImage } from '../services/apps';\nimport { profileFile, type PipelinePaths } from './connect';\nimport { initPipelineProfile, type InitResult } from './init';\nimport { localSourceFiles, PipelineService, readPipelineProfileFile, type PipelineClient } from './service';\nimport { PIPELINE_RUNNER_IMAGE } from './runtime';\n\nconst ENTRYPOINT = 'main.py';\n// The skill's starter for complete replacement outputs, with no destination arguments.\nconst STARTER_MAIN = `from farseer_simple_pipelines.runner import run_pipeline\nfrom farseer_simple_pipelines.storage import StoreType\nfrom farseer_simple_pipelines.authoring import PipelinePolicy\nrun_pipeline(store_type=StoreType.DATASETS, pipeline_policy=PipelinePolicy(), experimental__emit_pipeline_visualization_markers=True)\n`;\nconst FOLDER_NAME = /^[A-Za-z0-9][A-Za-z0-9._ -]*$/;\n\nexport interface CreateOptions {\n organisation: string;\n tenant: string;\n name: string;\n}\nexport interface CreateResult {\n organisation: string;\n tenant: string;\n jobId: number;\n name: string;\n workspace: string;\n profile: string;\n /** 'scaffold' wrote the starter files; 'adopted' uploaded the local folder that was already there. */\n source: 'scaffold' | 'adopted';\n created: { folder: { id: number; path: string }; job: { id: number; name: string }; files: string[] };\n pendingDatasets: InitResult['pendingDatasets'];\n warnings: string[];\n}\n\n/**\n * Start a pipeline on this tenant: the remote source folder, a job configured to run it, and\n * the profile init derives from that job. With no local folder the starter `main.py` is written\n * first; with one already there (a pipeline copied from another tenant, say) its source files\n * are uploaded as they are. Every refusal happens before the first remote write.\n */\nexport async function createPipeline(\n options: CreateOptions,\n client: PipelineClient,\n paths: PipelinePaths,\n): Promise<CreateResult> {\n const { name } = options;\n if (!FOLDER_NAME.test(name)) throw new Error(`\"${name}\" is not a plain pipeline folder name`);\n const workspaceDir = path.join(paths.filesDir, name);\n const adopting = fs.existsSync(workspaceDir);\n const scope = { workspace: name, entrypoint: ENTRYPOINT, configFiles: [] };\n // Entrypoint first, then a stable order, so the upload log reads the same on every machine.\n const entry = `${name}/${ENTRYPOINT}`;\n const sources = adopting\n ? localSourceFiles(scope, paths.filesDir).sort((a, b) =>\n a === entry ? -1 : b === entry ? 1 : a.localeCompare(b),\n )\n : [];\n if (adopting && !sources.includes(entry))\n throw new Error(\n `Local folder ${workspaceDir} exists but has no ${ENTRYPOINT}; it is not a pipeline folder. Pick another name or add the entrypoint.`,\n );\n refuseForeignProfile(profileFile(paths.profileDir, name), options);\n if ((await client.listApps()).some((app) => app.name === name))\n throw new Error(\n `Job \"${name}\" already exists on ${options.tenant}; pick another name or attach to that job (init jobId=<id>)`,\n );\n if (await client.resolveSourceFolder(name))\n throw new Error(\n `Folder \"${name}\" already exists under Files on ${options.tenant}; attach to its prepared job (init jobId=<id>) or pick another name`,\n );\n const image = resolveRunnerImage(PIPELINE_RUNNER_IMAGE, await client.getRunnerImageRepositories());\n if ('error' in image) throw new Error(image.error);\n // The backend hides Apps from a user without the remote jobs feature, super user or not, and\n // createApp then fails after the source folder is uploaded, leaving a folder that blocks a retry.\n if (!(await client.getFolderByPath(['Apps'])))\n throw new Error(\n `This user cannot see the Apps folder on ${options.tenant}, so init cannot create the job. Ask the tenant admin for the remote jobs feature (FEATURE.REMOTE_JOBS), then rerun init.`,\n );\n\n // Uploaded in this order into the new source folder. Models/ and Code/ stay local until they\n // hold a file. There is no starter model: every run would publish it as a dataset that only a\n // super user can delete.\n const files: { name: string; folder: string[]; content: string }[] = adopting\n ? sources.map((file) => {\n const inner = file.slice(name.length + 1).split('/');\n return {\n name: inner[inner.length - 1],\n folder: inner.slice(0, -1),\n content: fs.readFileSync(path.join(paths.filesDir, file), 'utf8'),\n };\n })\n : [{ name: ENTRYPOINT, folder: [], content: STARTER_MAIN }];\n if (!adopting) writeScaffold(workspaceDir, files);\n const created: string[] = [];\n try {\n for (const file of files) {\n await client.createFile(file.content, file.name, ['Files', name, ...file.folder]);\n created.push([name, ...file.folder, file.name].join('/'));\n }\n const folder = await client.resolveSourceFolder(name);\n const script = folder?.scripts.find((s) => s.name === ENTRYPOINT);\n if (!folder || !script) throw new Error(`Uploaded ${ENTRYPOINT} was not found in the new folder \"${name}\"`);\n const job = await client.createApp(name);\n created.push(`job ${job.id}`);\n await client.updateApp(\n String(job.id),\n { sourceFolderId: folder.id, mainScriptFileId: script.id, runnerImage: image.image },\n job,\n );\n const init = await initPipelineProfile(\n { organisation: options.organisation, tenant: options.tenant, jobId: job.id, workspace: name },\n client,\n paths,\n );\n // Local and remote are identical right now; one pull records that as the sync baseline,\n // so the first edit is a plain local change rather than a conflict with init's own upload.\n await new PipelineService(init.profile, client, paths.filesDir, paths.stateRoot).syncSources('pull');\n return {\n organisation: options.organisation,\n tenant: options.tenant,\n jobId: job.id,\n name,\n workspace: name,\n profile: init.file,\n source: adopting ? 'adopted' : 'scaffold',\n created: {\n folder: { id: folder.id, path: name },\n job: { id: job.id, name },\n files: created.filter((c) => !c.startsWith('job ')),\n },\n pendingDatasets: init.pendingDatasets,\n warnings: init.warnings,\n };\n } catch (error) {\n // The backend creates Files/<name> while storing the first file, so the folder can\n // exist even when no upload succeeded. Ask, rather than infer it from `created`.\n const remoteFolder = await client.resolveSourceFolder(name).then(\n (folder) => (folder ? 'present' : 'absent'),\n () => 'unknown',\n );\n const leftover = [\n ...(remoteFolder === 'present' ? [`folder Files/${name}`] : []),\n ...(remoteFolder === 'unknown' ? [`possibly folder Files/${name} (could not check)`] : []),\n ...created,\n ];\n throw new Error(\n `${String(error)}. Created before the failure and left in place: ${leftover.length ? leftover.join(', ') : 'nothing remote'}; local scaffold ${workspaceDir}`,\n );\n }\n}\n\n/**\n * A profile under this tenant that names another tenant is a copied .pipelines/ folder, the\n * mishap this guards against: it would make every later command talk about the wrong job.\n */\nfunction refuseForeignProfile(file: string, options: CreateOptions) {\n if (!fs.existsSync(file)) return;\n const existing = readPipelineProfileFile(file);\n if (existing.organisation !== options.organisation || existing.tenant !== options.tenant)\n throw new Error(\n `Profile ${file} belongs to ${existing.organisation}/${existing.tenant}, not ${options.organisation}/${options.tenant}. It was copied along with the pipeline; delete it and rerun init. Only files/<name>/ moves between tenants.`,\n );\n throw new Error(`Profile ${file} already exists; this pipeline is initialised on ${options.tenant}`);\n}\n\nfunction writeScaffold(workspaceDir: string, files: { name: string; folder: string[]; content: string }[]) {\n fs.mkdirSync(path.join(workspaceDir, 'Models'), { recursive: true });\n fs.mkdirSync(path.join(workspaceDir, 'Code'), { recursive: true });\n for (const file of files) fs.writeFileSync(path.join(workspaceDir, ...file.folder, file.name), file.content);\n fs.writeFileSync(path.join(workspaceDir, 'Code', '.gitkeep'), '');\n}\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,SAAoB;AACpB,WAAsB;AACtB,kBAAmC;AACnC,qBAAgD;AAChD,kBAAqD;AACrD,qBAAgG;AAChG,qBAAsC;AAEtC,MAAM,aAAa;AAEnB,MAAM,eAAe;AAAA;AAAA;AAAA;AAAA;AAKrB,MAAM,cAAc;AA2BpB,eAAsB,eAClB,SACA,QACA,OACqB;AACrB,QAAM,EAAE,KAAK,IAAI;AACjB,MAAI,CAAC,YAAY,KAAK,IAAI,EAAG,OAAM,IAAI,MAAM,IAAI,IAAI,uCAAuC;AAC5F,QAAM,eAAe,KAAK,KAAK,MAAM,UAAU,IAAI;AACnD,QAAM,WAAW,GAAG,WAAW,YAAY;AAC3C,QAAM,QAAQ,EAAE,WAAW,MAAM,YAAY,YAAY,aAAa,CAAC,EAAE;AAEzE,QAAM,QAAQ,GAAG,IAAI,IAAI,UAAU;AACnC,QAAM,UAAU,eACV,iCAAiB,OAAO,MAAM,QAAQ,EAAE;AAAA,IAAK,CAAC,GAAG,MAC7C,MAAM,QAAQ,KAAK,MAAM,QAAQ,IAAI,EAAE,cAAc,CAAC;AAAA,EAC1D,IACA,CAAC;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 -0,0 +1,45 @@
|
|
|
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 errors_exports = {};
|
|
20
|
+
__export(errors_exports, {
|
|
21
|
+
PipelineError: () => PipelineError,
|
|
22
|
+
httpStatus: () => httpStatus
|
|
23
|
+
});
|
|
24
|
+
module.exports = __toCommonJS(errors_exports);
|
|
25
|
+
class PipelineError extends Error {
|
|
26
|
+
constructor(outcome, code, message, nextAction, runUuid) {
|
|
27
|
+
super(message);
|
|
28
|
+
this.outcome = outcome;
|
|
29
|
+
this.code = code;
|
|
30
|
+
this.nextAction = nextAction;
|
|
31
|
+
this.runUuid = runUuid;
|
|
32
|
+
this.name = "PipelineError";
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
function httpStatus(error) {
|
|
36
|
+
const value = error;
|
|
37
|
+
const status = Number(value?.response?.status ?? /^HTTP (\d+):/.exec(value?.message ?? "")?.[1]);
|
|
38
|
+
return Number.isFinite(status) ? status : void 0;
|
|
39
|
+
}
|
|
40
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
41
|
+
0 && (module.exports = {
|
|
42
|
+
PipelineError,
|
|
43
|
+
httpStatus
|
|
44
|
+
});
|
|
45
|
+
//# sourceMappingURL=errors.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../src/pipeline/errors.ts"],
|
|
4
|
+
"sourcesContent": ["/** Known pipeline outcomes; callers must not infer write acceptance from a transport error. */\nexport class PipelineError extends Error {\n constructor(\n readonly outcome: 'refused' | 'failed' | 'unknown',\n readonly code: string,\n message: string,\n readonly nextAction: string,\n readonly runUuid?: string,\n ) {\n super(message);\n this.name = 'PipelineError';\n }\n}\n\nexport function httpStatus(error: unknown): number | undefined {\n const value = error as { response?: { status?: number }; message?: string } | undefined;\n const status = Number(value?.response?.status ?? /^HTTP (\\d+):/.exec(value?.message ?? '')?.[1]);\n return Number.isFinite(status) ? status : undefined;\n}\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AACO,MAAM,sBAAsB,MAAM;AAAA,EACrC,YACa,SACA,MACT,SACS,YACA,SACX;AACE,UAAM,OAAO;AANJ;AACA;AAEA;AACA;AAGT,SAAK,OAAO;AAAA,EAChB;AACJ;AAEO,SAAS,WAAW,OAAoC;AAC3D,QAAM,QAAQ;AACd,QAAM,SAAS,OAAO,OAAO,UAAU,UAAU,eAAe,KAAK,OAAO,WAAW,EAAE,IAAI,CAAC,CAAC;AAC/F,SAAO,OAAO,SAAS,MAAM,IAAI,SAAS;AAC9C;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|