farseer-cli 1.12.0 → 1.14.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (101) hide show
  1. package/README.md +51 -18
  2. package/dist/commands/login.js +60 -26
  3. package/dist/commands/login.js.map +2 -2
  4. package/dist/commands/logout.js +37 -12
  5. package/dist/commands/logout.js.map +3 -3
  6. package/dist/commands/pipeline.js +158 -0
  7. package/dist/commands/pipeline.js.map +7 -0
  8. package/dist/commands/run.js +10 -27
  9. package/dist/commands/run.js.map +2 -2
  10. package/dist/commands/variables.js +17 -8
  11. package/dist/commands/variables.js.map +2 -2
  12. package/dist/commands/whoami.js +10 -14
  13. package/dist/commands/whoami.js.map +2 -2
  14. package/dist/index.js +40 -46
  15. package/dist/index.js.map +2 -2
  16. package/dist/mcp/prompts/workflows.js +13 -68
  17. package/dist/mcp/prompts/workflows.js.map +2 -2
  18. package/dist/mcp/resources/documentation.js +14 -0
  19. package/dist/mcp/resources/documentation.js.map +2 -2
  20. package/dist/mcp/server.js +14 -2
  21. package/dist/mcp/server.js.map +2 -2
  22. package/dist/mcp/skills.js +59 -0
  23. package/dist/mcp/skills.js.map +7 -0
  24. package/dist/mcp/tools/appTools.js +4 -0
  25. package/dist/mcp/tools/appTools.js.map +2 -2
  26. package/dist/mcp/tools/authTools.js +5 -2
  27. package/dist/mcp/tools/authTools.js.map +2 -2
  28. package/dist/mcp/tools/dataTools.js +2 -0
  29. package/dist/mcp/tools/dataTools.js.map +2 -2
  30. package/dist/mcp/tools/modelTools.js +6 -41
  31. package/dist/mcp/tools/modelTools.js.map +2 -2
  32. package/dist/mcp/tools/pipelineContract.js +317 -0
  33. package/dist/mcp/tools/pipelineContract.js.map +7 -0
  34. package/dist/mcp/tools/pipelineTools.js +111 -0
  35. package/dist/mcp/tools/pipelineTools.js.map +7 -0
  36. package/dist/mcp/tools/runTools.js +7 -18
  37. package/dist/mcp/tools/runTools.js.map +2 -2
  38. package/dist/mcp/tools/syncTools.js +4 -0
  39. package/dist/mcp/tools/syncTools.js.map +2 -2
  40. package/dist/mcp/utils/helpers.js +16 -6
  41. package/dist/mcp/utils/helpers.js.map +3 -3
  42. package/dist/mcp/utils/session.js +14 -9
  43. package/dist/mcp/utils/session.js.map +2 -2
  44. package/dist/pipeline/compatibility.js +53 -0
  45. package/dist/pipeline/compatibility.js.map +7 -0
  46. package/dist/pipeline/connect.js +139 -0
  47. package/dist/pipeline/connect.js.map +7 -0
  48. package/dist/pipeline/create.js +158 -0
  49. package/dist/pipeline/create.js.map +7 -0
  50. package/dist/pipeline/errors.js +45 -0
  51. package/dist/pipeline/errors.js.map +7 -0
  52. package/dist/pipeline/generated-reference.json +115 -0
  53. package/dist/pipeline/guide.js +33 -0
  54. package/dist/pipeline/guide.js.map +7 -0
  55. package/dist/pipeline/init.js +204 -0
  56. package/dist/pipeline/init.js.map +7 -0
  57. package/dist/pipeline/operations.js +103 -0
  58. package/dist/pipeline/operations.js.map +7 -0
  59. package/dist/pipeline/query.js +103 -0
  60. package/dist/pipeline/query.js.map +7 -0
  61. package/dist/pipeline/queryWorker.js +119 -0
  62. package/dist/pipeline/queryWorker.js.map +7 -0
  63. package/dist/pipeline/readiness.js +55 -0
  64. package/dist/pipeline/readiness.js.map +7 -0
  65. package/dist/pipeline/reference.js +72 -0
  66. package/dist/pipeline/reference.js.map +7 -0
  67. package/dist/pipeline/requests.js +122 -0
  68. package/dist/pipeline/requests.js.map +7 -0
  69. package/dist/pipeline/runArguments.js +68 -0
  70. package/dist/pipeline/runArguments.js.map +7 -0
  71. package/dist/pipeline/runtime.js +105 -0
  72. package/dist/pipeline/runtime.js.map +7 -0
  73. package/dist/pipeline/service.js +967 -0
  74. package/dist/pipeline/service.js.map +7 -0
  75. package/dist/services/agentApprovalFetch.js +86 -0
  76. package/dist/services/agentApprovalFetch.js.map +7 -0
  77. package/dist/services/authErrors.js +2 -2
  78. package/dist/services/authErrors.js.map +2 -2
  79. package/dist/services/configService.js +74 -9
  80. package/dist/services/configService.js.map +2 -2
  81. package/dist/services/credentials.js +12 -7
  82. package/dist/services/credentials.js.map +2 -2
  83. package/dist/services/farseerService.js +94 -39
  84. package/dist/services/farseerService.js.map +2 -2
  85. package/dist/services/preflight.js +7 -2
  86. package/dist/services/preflight.js.map +2 -2
  87. package/dist/services/realms.js +67 -0
  88. package/dist/services/realms.js.map +7 -0
  89. package/dist/services/syncService.js +6 -0
  90. package/dist/services/syncService.js.map +2 -2
  91. package/dist/skills/pipeline.js +71 -0
  92. package/dist/skills/pipeline.js.map +7 -0
  93. package/dist/utils/helpers.js +2 -1
  94. package/dist/utils/helpers.js.map +2 -2
  95. package/dist/utils/variableValues.js +78 -0
  96. package/dist/utils/variableValues.js.map +7 -0
  97. package/docs/pipeline-client-guide.md +67 -0
  98. package/docs/pipeline-reference.md +2064 -0
  99. package/package.json +5 -1
  100. package/skills/pipeline-authoring/SKILL.md +95 -0
  101. package/skills/pipeline-authoring/practices.md +325 -0
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../src/mcp/utils/session.ts"],
4
- "sourcesContent": ["/**\n * The tenant guard for MCP tools: the checks a CLI command runs, minus the exit.\n *\n * The pin cannot change for the life of the process, so the verdict is reached\n * once per credential. What is kept is the verdict and the credential, not a\n * built client \u2014 a browser token expires long before a long-lived server does.\n */\n\nimport {\n getCredential,\n getUserAuth,\n isUserAuthValid,\n type CurrentCheckout,\n type UserAuth,\n} from '../../services/configService';\nimport { refreshAuth } from '../../services/credentials';\nimport type { ResolvedAuth } from '../../services/farseerService';\nimport { openTenantSession, sessionFrom, type SessionWarning, type TenantSession } from '../../services/preflight';\nimport { authRequiredResponse, describeSessionFailure, tenantRequiredResponse } from './helpers';\nimport type { McpErrorResponse } from './helpers';\nimport { getTenantPin } from './tenantPin';\n\nexport type SessionResult = { ok: true; session: TenantSession } | { ok: false; response: McpErrorResponse };\n\n// Safe only because each server is a stdio process with a single client, on the\n// same terms as the pin it mirrors.\nlet validated:\n | {\n pin: CurrentCheckout;\n auth: ResolvedAuth;\n credentials: string;\n passedOverLogin: boolean;\n warning?: SessionWarning;\n }\n | undefined;\n\n/**\n * What the credential choice was made from, as one comparable value.\n *\n * A browser login is identified by its Keycloak session (`sid`), which token\n * rotation keeps and a new `farseer login` replaces \u2014 so the ordinary case, a\n * token renewed about once a minute, never re-runs the guard.\n *\n * A login the guard passed over for a key is the exception. Its refresh token\n * already failed, so nothing can rotate it, and a login made to recover can land\n * in the same Keycloak session when the browser still holds one. There the\n * refresh token itself is the identity: only replacing the login changes it.\n *\n * Without both, a key that stops working is reused until the process restarts,\n * while `farseer_whoami`, which reads the config directly, reports the new login\n * as valid.\n */\nfunction credentialState(tenant: string, passedOverLogin: boolean): string {\n const credential = getCredential(tenant);\n const key = credential ? `${credential.basePath}|${credential.tenantId}|${credential.apiKey}` : 'none';\n const login = getUserAuth();\n const who = !login ? 'none' : passedOverLogin ? `unusable:${login.refreshToken}` : `session:${loginSession(login)}`;\n return `${who}|${key}`;\n}\n\n/**\n * Read straight after a decision, when the guard has just tried to renew the\n * login: one that is still expired is one the refresh could not renew.\n */\nfunction passedOver(auth: ResolvedAuth): boolean {\n return auth.kind === 'apiKey' && !!getUserAuth() && !isUserAuthValid();\n}\n\nfunction loginSession(login: UserAuth): string {\n for (const token of [login.refreshToken, login.accessToken]) {\n try {\n const sid = JSON.parse(Buffer.from(token.split('.')[1], 'base64url').toString('utf-8')).sid;\n if (typeof sid === 'string' && sid) {\n return sid;\n }\n } catch {\n // Not a JWT; try the other token.\n }\n }\n // Unreadable, so the token itself: re-decides on every rotation \u2014 more often\n // than needed, never less.\n return login.refreshToken;\n}\n\n/** The gate every tool that talks to a tenant goes through. */\nexport async function requireSession(): Promise<SessionResult> {\n const pin = getTenantPin();\n if (!pin) {\n return { ok: false, response: tenantRequiredResponse() };\n }\n\n // Identity, not value: a different object means a different binding, and an\n // extra check is the safe way to be wrong. The credentials are part of the\n // key for the same reason \u2014 a verdict reached over one says nothing about\n // another. The pin survives either way; only the credential is re-decided.\n if (validated?.pin === pin && validated.credentials === credentialState(pin.tenant, validated.passedOverLogin)) {\n const auth = await refreshAuth(validated.auth);\n if (!auth) {\n // Drop the verdict rather than reuse a credential we can no longer mint.\n validated = undefined;\n return { ok: false, response: authRequiredResponse(pin.tenant) };\n }\n return { ok: true, session: sessionFrom(pin.organisation, pin.tenant, auth) };\n }\n\n const outcome = await openTenantSession(pin.organisation, pin.tenant);\n if (!outcome.ok) {\n return { ok: false, response: describeSessionFailure(outcome.failure, LOCKED_REMEDY) };\n }\n\n remember(pin, outcome.auth, outcome.warning);\n return { ok: true, session: sessionFrom(outcome.organisation, outcome.tenant, outcome.auth) };\n}\n\n/** Adopt a verdict reached elsewhere \u2014 `farseer_select_tenant` validates before it binds. */\nexport function rememberSession(pin: CurrentCheckout, auth: ResolvedAuth, warning?: SessionWarning): void {\n remember(pin, auth, warning);\n}\n\nfunction remember(pin: CurrentCheckout, auth: ResolvedAuth, warning?: SessionWarning): void {\n const passedOverLogin = passedOver(auth);\n validated = { pin, auth, credentials: credentialState(pin.tenant, passedOverLogin), passedOverLogin, warning };\n}\n\n/** Reported by `farseer_whoami`: true about this session, but not a failure. */\nexport function getSessionWarning(): SessionWarning | undefined {\n const pin = getTenantPin();\n return validated?.pin === pin ? validated?.warning : undefined;\n}\n\nexport function resetSessionCache(): void {\n validated = undefined;\n}\n\n// Past the lock there is no in-session fix.\nconst LOCKED_REMEDY =\n 'This session is locked to that pair for its lifetime \u2014 start a new server with the right organisation (--org, or FARSEER_ORG).';\n"],
5
- "mappings": ";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAQA,2BAMO;AACP,yBAA4B;AAE5B,uBAAwF;AACxF,qBAAqF;AAErF,uBAA6B;AAM7B,IAAI;AA0BJ,SAAS,gBAAgB,QAAgB,iBAAkC;AACvE,QAAM,iBAAa,oCAAc,MAAM;AACvC,QAAM,MAAM,aAA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AAE,IAAI,OAAO,cAAU,uCAAuB,QAAQ,SAAS,aAAa,EAAE;AAAA,EACzF;AAEA,WAAS,KAAK,QAAQ,MAAM,QAAQ,OAAO;AAC3C,SAAO,EAAE,IAAI,MAAM,aAAS,8BAAY,QAAQ,cAAc,QAAQ,QAAQ,QAAQ,IAAI,EAAE;AAChG;AAGO,SAAS,gBAAgB,KAAsB,MAAoB,SAAgC;AACtG,WAAS,KAAK,MAAM,OAAO;AAC/B;AAEA,SAAS,SAAS,KAAsB,MAAoB,SAAgC;AACxF,QAAM,kBAAkB,WAAW,IAAI;AACvC,cAAY,EAAE,KAAK,MAAM,aAAa,gBAAgB,IAAI,QAAQ,eAAe,GAAG,iBAAiB,QAAQ;AACjH;AAGO,SAAS,oBAAgD;AAC5D,QAAM,UAAM,+BAAa;AACzB,SAAO,WAAW,QAAQ,MAAM,WAAW,UAAU;AACzD;AAEO,SAAS,oBAA0B;AACtC,cAAY;AAChB;AAGA,MAAM,gBACF;",
4
+ "sourcesContent": ["/**\n * The tenant guard for MCP tools: the checks a CLI command runs, minus the exit.\n *\n * The pin cannot change for the life of the process, so the verdict is reached\n * once per credential. What is kept is the verdict and the credential, not a\n * built client \u2014 a browser token expires long before a long-lived server does.\n */\n\nimport {\n getCredential,\n getUserAuth,\n isUserAuthValid,\n type CurrentCheckout,\n type UserAuth,\n} from '../../services/configService';\nimport { refreshAuth } from '../../services/credentials';\nimport { knownRealmForOrganisation } from '../../services/realms';\nimport type { ResolvedAuth } from '../../services/farseerService';\nimport { openTenantSession, sessionFrom, type SessionWarning, type TenantSession } from '../../services/preflight';\nimport { authRequiredResponse, describeSessionFailure, tenantRequiredResponse } from './helpers';\nimport type { McpErrorResponse } from './helpers';\nimport { getTenantPin } from './tenantPin';\n\nexport type SessionResult = { ok: true; session: TenantSession } | { ok: false; response: McpErrorResponse };\n\n// Safe only because each server is a stdio process with a single client, on the\n// same terms as the pin it mirrors.\nlet validated:\n | {\n pin: CurrentCheckout;\n auth: ResolvedAuth;\n credentials: string;\n passedOverLogin: boolean;\n warning?: SessionWarning;\n }\n | undefined;\n\n/**\n * What the credential choice was made from, as one comparable value.\n *\n * A browser login is identified by its Keycloak session (`sid`), which token\n * rotation keeps and a new `farseer login` replaces \u2014 so the ordinary case, a\n * token renewed about once a minute, never re-runs the guard.\n *\n * A login the guard passed over for a key is the exception. Its refresh token\n * already failed, so nothing can rotate it, and a login made to recover can land\n * in the same Keycloak session when the browser still holds one. There the\n * refresh token itself is the identity: only replacing the login changes it.\n *\n * Without both, a key that stops working is reused until the process restarts,\n * while `farseer_whoami`, which reads the config directly, reports the new login\n * as valid.\n */\nfunction credentialState(pin: CurrentCheckout, passedOverLogin: boolean): string {\n const credential = getCredential(pin.tenant);\n const key = credential ? `${credential.basePath}|${credential.tenantId}|${credential.apiKey}` : 'none';\n const login = getUserAuth(knownRealmForOrganisation(pin.organisation));\n const who = !login ? 'none' : passedOverLogin ? `unusable:${login.refreshToken}` : `session:${loginSession(login)}`;\n return `${who}|${key}`;\n}\n\n/**\n * Read straight after a decision, when the guard has just tried to renew the\n * login: one that is still expired is one the refresh could not renew.\n */\nfunction passedOver(pin: CurrentCheckout, auth: ResolvedAuth): boolean {\n if (auth.kind !== 'apiKey') {\n return false;\n }\n const login = getUserAuth(knownRealmForOrganisation(pin.organisation));\n return !!login && !isUserAuthValid(login);\n}\n\nfunction loginSession(login: UserAuth): string {\n for (const token of [login.refreshToken, login.accessToken]) {\n try {\n const sid = JSON.parse(Buffer.from(token.split('.')[1], 'base64url').toString('utf-8')).sid;\n if (typeof sid === 'string' && sid) {\n return sid;\n }\n } catch {\n // Not a JWT; try the other token.\n }\n }\n // Unreadable, so the token itself: re-decides on every rotation \u2014 more often\n // than needed, never less.\n return login.refreshToken;\n}\n\n/** The gate every tool that talks to a tenant goes through. */\nexport async function requireSession(): Promise<SessionResult> {\n const pin = getTenantPin();\n if (!pin) {\n return { ok: false, response: tenantRequiredResponse() };\n }\n\n // Identity, not value: a different object means a different binding, and an\n // extra check is the safe way to be wrong. The credentials are part of the\n // key for the same reason \u2014 a verdict reached over one says nothing about\n // another. The pin survives either way; only the credential is re-decided.\n if (validated?.pin === pin && validated.credentials === credentialState(pin, validated.passedOverLogin)) {\n const auth = await refreshAuth(validated.auth);\n if (!auth) {\n // Drop the verdict rather than reuse a credential we can no longer mint.\n validated = undefined;\n return { ok: false, response: authRequiredResponse(pin.tenant, pin.organisation) };\n }\n return { ok: true, session: sessionFrom(pin.organisation, pin.tenant, auth) };\n }\n\n const outcome = await openTenantSession(pin.organisation, pin.tenant);\n if (!outcome.ok) {\n return { ok: false, response: describeSessionFailure(outcome.failure, LOCKED_REMEDY) };\n }\n\n remember(pin, outcome.auth, outcome.warning);\n return { ok: true, session: sessionFrom(outcome.organisation, outcome.tenant, outcome.auth) };\n}\n\n/** Adopt a verdict reached elsewhere \u2014 `farseer_select_tenant` validates before it binds. */\nexport function rememberSession(pin: CurrentCheckout, auth: ResolvedAuth, warning?: SessionWarning): void {\n remember(pin, auth, warning);\n}\n\nfunction remember(pin: CurrentCheckout, auth: ResolvedAuth, warning?: SessionWarning): void {\n const passedOverLogin = passedOver(pin, auth);\n validated = { pin, auth, credentials: credentialState(pin, passedOverLogin), passedOverLogin, warning };\n}\n\n/** Reported by `farseer_whoami`: true about this session, but not a failure. */\nexport function getSessionWarning(): SessionWarning | undefined {\n const pin = getTenantPin();\n return validated?.pin === pin ? validated?.warning : undefined;\n}\n\nexport function resetSessionCache(): void {\n validated = undefined;\n}\n\n// Past the lock there is no in-session fix.\nconst LOCKED_REMEDY =\n 'This session is locked to that pair for its lifetime \u2014 start a new server with the right organisation (--org, or FARSEER_ORG).';\n"],
5
+ "mappings": ";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAQA,2BAMO;AACP,yBAA4B;AAC5B,oBAA0C;AAE1C,uBAAwF;AACxF,qBAAqF;AAErF,uBAA6B;AAM7B,IAAI;AA0BJ,SAAS,gBAAg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AAAA,IACrF;AACA,WAAO,EAAE,IAAI,MAAM,aAAS,8BAAY,IAAI,cAAc,IAAI,QAAQ,IAAI,EAAE;AAAA,EAChF;AAEA,QAAM,UAAU,UAAM,oCAAkB,IAAI,cAAc,IAAI,MAAM;AACpE,MAAI,CAAC,QAAQ,IAAI;AACb,WAAO,EAAE,IAAI,OAAO,cAAU,uCAAuB,QAAQ,SAAS,aAAa,EAAE;AAAA,EACzF;AAEA,WAAS,KAAK,QAAQ,MAAM,QAAQ,OAAO;AAC3C,SAAO,EAAE,IAAI,MAAM,aAAS,8BAAY,QAAQ,cAAc,QAAQ,QAAQ,QAAQ,IAAI,EAAE;AAChG;AAGO,SAAS,gBAAgB,KAAsB,MAAoB,SAAgC;AACtG,WAAS,KAAK,MAAM,OAAO;AAC/B;AAEA,SAAS,SAAS,KAAsB,MAAoB,SAAgC;AACxF,QAAM,kBAAkB,WAAW,KAAK,IAAI;AAC5C,cAAY,EAAE,KAAK,MAAM,aAAa,gBAAgB,KAAK,eAAe,GAAG,iBAAiB,QAAQ;AAC1G;AAGO,SAAS,oBAAgD;AAC5D,QAAM,UAAM,+BAAa;AACzB,SAAO,WAAW,QAAQ,MAAM,WAAW,UAAU;AACzD;AAEO,SAAS,oBAA0B;AACtC,cAAY;AAChB;AAGA,MAAM,gBACF;",
6
6
  "names": []
7
7
  }
@@ -0,0 +1,53 @@
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 compatibility_exports = {};
20
+ __export(compatibility_exports, {
21
+ checkPipelineCompatibility: () => checkPipelineCompatibility
22
+ });
23
+ module.exports = __toCommonJS(compatibility_exports);
24
+ var import_zod = require("zod");
25
+ var import_reference = require("./reference");
26
+ const compatibilitySchema = import_zod.z.object({
27
+ protocolVersion: import_zod.z.literal(3),
28
+ minimumCliVersion: import_zod.z.string().regex(/^\d+\.\d+\.\d+$/)
29
+ });
30
+ async function checkPipelineCompatibility(client) {
31
+ let response;
32
+ try {
33
+ response = await client.pipelineRequest("GET", "/pipelineAuthoring");
34
+ } catch (error) {
35
+ const status = error.response?.status ?? /^HTTP (\d+):/.exec(error.message ?? "")?.[1];
36
+ if (Number(status) === 404)
37
+ throw new Error(
38
+ "Pipeline authoring compatibility is unavailable on this tenant. Ask the pipeline setup owner to enable the matching backend."
39
+ );
40
+ if (Number(status) === 426)
41
+ throw new Error(`This tenant requires an updated pipeline CLI. ${import_reference.CLI_UPDATE_INSTRUCTION}`);
42
+ throw error;
43
+ }
44
+ if (!compatibilitySchema.safeParse(response).success)
45
+ throw new Error(
46
+ `This backend's pipeline authoring protocol is unknown to this CLI. ${import_reference.CLI_UPDATE_INSTRUCTION} If it persists, ask the pipeline setup owner to check the backend.`
47
+ );
48
+ }
49
+ // Annotate the CommonJS export names for ESM import in node:
50
+ 0 && (module.exports = {
51
+ checkPipelineCompatibility
52
+ });
53
+ //# sourceMappingURL=compatibility.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../src/pipeline/compatibility.ts"],
4
+ "sourcesContent": ["import { z } from 'zod';\nimport type { PipelineClient } from './service';\nimport { CLI_UPDATE_INSTRUCTION } from './reference';\n\nconst compatibilitySchema = z.object({\n protocolVersion: z.literal(3),\n minimumCliVersion: z.string().regex(/^\\d+\\.\\d+\\.\\d+$/),\n});\n\nexport async function checkPipelineCompatibility(client: PipelineClient): Promise<void> {\n let response: unknown;\n try {\n // The backend compares our version header before returning this contract.\n response = await client.pipelineRequest('GET', '/pipelineAuthoring');\n } catch (error: any) {\n const status = error.response?.status ?? /^HTTP (\\d+):/.exec(error.message ?? '')?.[1];\n if (Number(status) === 404)\n throw new Error(\n 'Pipeline authoring compatibility is unavailable on this tenant. Ask the pipeline setup owner to enable the matching backend.',\n );\n if (Number(status) === 426)\n throw new Error(`This tenant requires an updated pipeline CLI. ${CLI_UPDATE_INSTRUCTION}`);\n throw error;\n }\n if (!compatibilitySchema.safeParse(response).success)\n throw new Error(\n `This backend's pipeline authoring protocol is unknown to this CLI. ${CLI_UPDATE_INSTRUCTION} If it persists, ask the pipeline setup owner to check the backend.`,\n );\n}\n"],
5
+ "mappings": ";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,iBAAkB;AAElB,uBAAuC;AAEvC,MAAM,sBAAsB,aAAE,OAAO;AAAA,EACjC,iBAAiB,aAAE,QAAQ,CAAC;AAAA,EAC5B,mBAAmB,aAAE,OAAO,EAAE,MAAM,iBAAiB;AACzD,CAAC;AAED,eAAsB,2BAA2B,QAAuC;AACpF,MAAI;AACJ,MAAI;AAEA,eAAW,MAAM,OAAO,gBAAgB,OAAO,oBAAoB;AAAA,EACvE,SAAS,OAAY;AACjB,UAAM,SAAS,MAAM,UAAU,UAAU,eAAe,KAAK,MAAM,WAAW,EAAE,IAAI,CAAC;AACrF,QAAI,OAAO,MAAM,MAAM;AACnB,YAAM,IAAI;AAAA,QACN;AAAA,MACJ;AACJ,QAAI,OAAO,MAAM,MAAM;AACnB,YAAM,IAAI,MAAM,iDAAiD,uCAAsB,EAAE;AAC7F,UAAM;AAAA,EACV;AACA,MAAI,CAAC,oBAAoB,UAAU,QAAQ,EAAE;AACzC,UAAM,IAAI;AAAA,MACN,sEAAsE,uCAAsB;AAAA,IAChG;AACR;",
6
+ "names": []
7
+ }
@@ -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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;AAC7E,MAAI,CAAC,QAAQ;AACT,UAAM,UAAU,UAAM,qCAAoB,UAAM,oCAAkB,cAAc,MAAM,CAAC;AACvF,QAAI,CAAC,QAAQ;AACT,YAAM,IAAI;AAAA,QACN;AAAA,QACA;AAAA,QACA,qBAAqB,YAAY,IAAI,MAAM,KAAK,QAAQ,QAAQ,MAAM;AAAA,QACtE;AAAA,MACJ;AACJ,iBAAS,8BAAY,QAAQ,cAAc,QAAQ,QAAQ,QAAQ,IAAI;AAAA,EAC3E;AACA,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,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AAG,UAAU,KAAK,KAAK,cAAc,QAAQ,GAAG,EAAE,WAAW,KAAK,CAAC;AACnE,KAAG,UAAU,KAAK,KAAK,cAAc,MAAM,GAAG,EAAE,WAAW,KAAK,CAAC;AACjE,aAAW,QAAQ,MAAO,IAAG,cAAc,KAAK,KAAK,cAAc,GAAG,KAAK,QAAQ,KAAK,IAAI,GAAG,KAAK,OAAO;AAC3G,KAAG,cAAc,KAAK,KAAK,cAAc,QAAQ,UAAU,GAAG,EAAE;AACpE;",
6
+ "names": []
7
+ }
@@ -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
+ }