farseer-cli 1.18.0 → 1.19.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (155) hide show
  1. package/README.md +2 -2
  2. package/dist/commands/app.js.map +0 -1
  3. package/dist/commands/apps.js.map +0 -1
  4. package/dist/commands/cells.js.map +0 -1
  5. package/dist/commands/code.js.map +0 -1
  6. package/dist/commands/config.js.map +0 -1
  7. package/dist/commands/dashboards.js.map +0 -1
  8. package/dist/commands/diff.js.map +0 -1
  9. package/dist/commands/dimensions.js.map +0 -1
  10. package/dist/commands/files.js.map +0 -1
  11. package/dist/commands/formula.js.map +0 -1
  12. package/dist/commands/install.js.map +0 -1
  13. package/dist/commands/list.js.map +0 -1
  14. package/dist/commands/login.js +3 -3
  15. package/dist/commands/login.js.map +1 -2
  16. package/dist/commands/logout.js.map +0 -1
  17. package/dist/commands/mcp-server.js.map +0 -1
  18. package/dist/commands/model.js.map +0 -1
  19. package/dist/commands/pipeline.js.map +0 -1
  20. package/dist/commands/pull.js +1 -1
  21. package/dist/commands/pull.js.map +1 -2
  22. package/dist/commands/push.js +2 -2
  23. package/dist/commands/push.js.map +1 -2
  24. package/dist/commands/refresh.js.map +0 -1
  25. package/dist/commands/run.js.map +0 -1
  26. package/dist/commands/sheets.js.map +0 -1
  27. package/dist/commands/status.js.map +0 -1
  28. package/dist/commands/tool.js.map +0 -1
  29. package/dist/commands/variables.js.map +0 -1
  30. package/dist/commands/whoami.js.map +0 -1
  31. package/dist/index.js +24 -10
  32. package/dist/index.js.map +1 -2
  33. package/dist/mcp/index.js.map +0 -1
  34. package/dist/mcp/prompts/workflows.js.map +0 -1
  35. package/dist/mcp/resources/documentation.js.map +0 -1
  36. package/dist/mcp/server.js.map +0 -1
  37. package/dist/mcp/skills.js.map +0 -1
  38. package/dist/mcp/tools/appTools.js.map +0 -1
  39. package/dist/mcp/tools/authTools.js +1 -1
  40. package/dist/mcp/tools/authTools.js.map +1 -2
  41. package/dist/mcp/tools/cellTools.js.map +0 -1
  42. package/dist/mcp/tools/dashboardTools.js.map +0 -1
  43. package/dist/mcp/tools/dataTools.js.map +0 -1
  44. package/dist/mcp/tools/folderTools.js.map +0 -1
  45. package/dist/mcp/tools/modelTools.js.map +0 -1
  46. package/dist/mcp/tools/pipelineContract.js.map +0 -1
  47. package/dist/mcp/tools/pipelineTools.js.map +0 -1
  48. package/dist/mcp/tools/runTools.js.map +0 -1
  49. package/dist/mcp/tools/sheetTools.js.map +0 -1
  50. package/dist/mcp/tools/syncTools.js +2 -2
  51. package/dist/mcp/tools/syncTools.js.map +1 -2
  52. package/dist/mcp/utils/helpers.js.map +0 -1
  53. package/dist/mcp/utils/launchPin.js.map +0 -1
  54. package/dist/mcp/utils/registerTool.js.map +0 -1
  55. package/dist/mcp/utils/session.js.map +0 -1
  56. package/dist/mcp/utils/tenantPin.js.map +0 -1
  57. package/dist/pipeline/compatibility.js.map +0 -1
  58. package/dist/pipeline/connect.js.map +0 -1
  59. package/dist/pipeline/create.js.map +0 -1
  60. package/dist/pipeline/errors.js.map +0 -1
  61. package/dist/pipeline/generated-reference.json +22 -10
  62. package/dist/pipeline/guide.js.map +0 -1
  63. package/dist/pipeline/init.js.map +0 -1
  64. package/dist/pipeline/operations.js.map +0 -1
  65. package/dist/pipeline/query.js.map +0 -1
  66. package/dist/pipeline/queryDownloads.js.map +0 -1
  67. package/dist/pipeline/queryWorker.js.map +0 -1
  68. package/dist/pipeline/readiness.js.map +0 -1
  69. package/dist/pipeline/reference.js.map +0 -1
  70. package/dist/pipeline/requests.js.map +0 -1
  71. package/dist/pipeline/runArguments.js.map +0 -1
  72. package/dist/pipeline/runtime.js.map +0 -1
  73. package/dist/pipeline/service.js.map +0 -1
  74. package/dist/services/agentApprovalFetch.js +7 -3
  75. package/dist/services/agentApprovalFetch.js.map +1 -2
  76. package/dist/services/appSyncService.js.map +0 -1
  77. package/dist/services/apps.js.map +0 -1
  78. package/dist/services/authErrors.js.map +0 -1
  79. package/dist/services/codefirst/api.js +38 -5
  80. package/dist/services/codefirst/api.js.map +1 -2
  81. package/dist/services/codefirst/binaryDisk.js.map +0 -1
  82. package/dist/services/codefirst/byteHashes.js +5 -0
  83. package/dist/services/codefirst/byteHashes.js.map +1 -2
  84. package/dist/services/codefirst/documents.js +41 -15
  85. package/dist/services/codefirst/documents.js.map +1 -2
  86. package/dist/services/codefirst/layoutBinaryProjection.js +24 -13
  87. package/dist/services/codefirst/layoutBinaryProjection.js.map +1 -2
  88. package/dist/services/codefirst/layoutCompose.js +44 -38
  89. package/dist/services/codefirst/layoutCompose.js.map +1 -2
  90. package/dist/services/codefirst/layoutCore.js +14 -1
  91. package/dist/services/codefirst/layoutCore.js.map +1 -2
  92. package/dist/services/codefirst/layoutPaths.js +80 -4
  93. package/dist/services/codefirst/layoutPaths.js.map +1 -2
  94. package/dist/services/codefirst/layoutProjection.js +73 -39
  95. package/dist/services/codefirst/layoutProjection.js.map +1 -2
  96. package/dist/services/codefirst/layoutReadback.js +357 -130
  97. package/dist/services/codefirst/layoutReadback.js.map +2 -3
  98. package/dist/services/codefirst/layoutReadbackPlacement.js +94 -57
  99. package/dist/services/codefirst/layoutReadbackPlacement.js.map +2 -3
  100. package/dist/services/codefirst/layoutReceipt.js +283 -243
  101. package/dist/services/codefirst/layoutReceipt.js.map +2 -3
  102. package/dist/services/codefirst/layoutScan.js +208 -110
  103. package/dist/services/codefirst/layoutScan.js.map +1 -2
  104. package/dist/services/codefirst/output.js +76 -10
  105. package/dist/services/codefirst/output.js.map +1 -2
  106. package/dist/services/codefirst/types.js.map +0 -1
  107. package/dist/services/codefirst/workflow.js +65 -29
  108. package/dist/services/codefirst/workflow.js.map +2 -3
  109. package/dist/services/codefirst/workspace.js.map +0 -1
  110. package/dist/services/codefirst/workspaceLock.js.map +0 -1
  111. package/dist/services/codefirst/workspaceRoot.js +2 -1
  112. package/dist/services/codefirst/workspaceRoot.js.map +1 -2
  113. package/dist/services/configService.js.map +0 -1
  114. package/dist/services/credentials.js.map +0 -1
  115. package/dist/services/farseerService.js +3 -1
  116. package/dist/services/farseerService.js.map +1 -2
  117. package/dist/services/httpError.js.map +0 -1
  118. package/dist/services/modelExport.js.map +0 -1
  119. package/dist/services/organisation.js.map +0 -1
  120. package/dist/services/preflight.js.map +0 -1
  121. package/dist/services/realms.js.map +0 -1
  122. package/dist/services/syncService.js +3 -3
  123. package/dist/services/syncService.js.map +1 -2
  124. package/dist/skills/pipeline.js.map +0 -1
  125. package/dist/utils/agentSandbox.js.map +0 -1
  126. package/dist/utils/cliOptions.js.map +0 -1
  127. package/dist/utils/constants.js.map +0 -1
  128. package/dist/utils/entityResolver.js.map +0 -1
  129. package/dist/utils/errorFormatter.js +59 -11
  130. package/dist/utils/errorFormatter.js.map +1 -2
  131. package/dist/utils/fileLogger.js.map +0 -1
  132. package/dist/utils/fileValidation.js.map +0 -1
  133. package/dist/utils/folderMatch.js.map +0 -1
  134. package/dist/utils/formulaFilters.js.map +0 -1
  135. package/dist/utils/helpers.js.map +0 -1
  136. package/dist/utils/logger.js.map +0 -1
  137. package/dist/utils/nameResolver.js.map +0 -1
  138. package/dist/utils/packageManager.js.map +0 -1
  139. package/dist/utils/syncReporting.js.map +0 -1
  140. package/dist/utils/syncScope.js.map +0 -1
  141. package/dist/utils/updateCheck.js.map +0 -1
  142. package/dist/utils/variableValues.js.map +0 -1
  143. package/dist/utils/workspace.js.map +0 -1
  144. package/docs/cli-guide.md +1 -1
  145. package/docs/import-workflows.md +14 -14
  146. package/docs/new-app-template.md +1 -1
  147. package/docs/pipeline-client-guide.md +1 -1
  148. package/docs/pipeline-reference.md +292 -3
  149. package/package.json +2 -2
  150. package/skills/farseer-analysis/SKILL.md +132 -0
  151. package/skills/farseer-dashboards/SKILL.md +40 -0
  152. package/skills/farseer-formulas/SKILL.md +165 -0
  153. package/skills/farseer-model/SKILL.md +119 -0
  154. package/skills/pipeline-authoring/SKILL.md +6 -4
  155. package/skills/pipeline-authoring/practices.md +6 -5
@@ -1,14 +1,14 @@
1
1
  {
2
2
  "formatVersion": 1,
3
- "engineVersion": "3.0.0",
4
- "engineProfile": "3.0",
5
- "runnerImage": "runner-python-simple-pipelines:1.14.0",
3
+ "engineVersion": "3.2.1",
4
+ "engineProfile": "3.2",
5
+ "runnerImage": "runner-python-simple-pipelines:1.17.0",
6
6
  "sourceHashes": {
7
- "data-platform/packages/simple-pipelines/src/farseer_simple_pipelines/schema.py": "f2b6408e74e1312bd7cc105df7055a08a1cf5fc8fadcf3b8e8897ac704758706",
8
- "data-platform/packages/simple-pipelines/pyproject.toml": "13e888969318f6fbac59d31f65d3295e075f004bbde6991fa0b24af1093fa608",
7
+ "data-platform/packages/simple-pipelines/src/farseer_simple_pipelines/schema.py": "290c529c594e529d14225577160aff1a256e8ae2dc3daf9422964ff2e0ade863",
8
+ "data-platform/packages/simple-pipelines/pyproject.toml": "39e2ffc934371952369c12ab4702accdca399afefa4fe6f65019cc6041cc09ab",
9
9
  "tools/pipeline/generate_docs.py": "3a3639b1421f06ed816a35def8861fc42104324eff3c38892ae8367bf877e4cc",
10
- "runner-images/VERSION": "bb0df1bd902faba507c15975eb9973e695f2732f760d851b4f9c7ba17068f5ff",
11
- "runner-images/python-simple-pipelines/pyproject.toml": "3b99503f425c7f0941a432d813b16c5bb5a0f9260ed2c0f7c00d697b7d950c45",
10
+ "runner-images/VERSION": "00afc49f1599e59129a59b64c2b019de3fe35300c05bb9d96cb25002576ff43b",
11
+ "runner-images/python-simple-pipelines/pyproject.toml": "a2da7943744a782bab55f3b7866eea9138e3636d858944258d84f0fd52e119d2",
12
12
  "tools/pipeline/examples/FarseerFilesExtractConfig.yaml": "20950da2f5413833dcaa1e700f13dd0597530c5a17d75ed96e35d6e3ca87eaa4",
13
13
  "tools/pipeline/examples/LoadCellsConfig.yaml": "2b56bd84e35765b616916c21c98fd306e2b93127358979777a77083991ac8bf1",
14
14
  "tools/pipeline/examples/ParseConfig.yaml": "c5b2deada46ba2edbe29410a37d4b3fd53ffd231d506417a5990cdd3c2d7f8ac",
@@ -24,8 +24,10 @@
24
24
  "Connection": "## Connection\n\nMaps a source column to a target dimension table (foreign key).\n\nUnknown fields are rejected.\n\n| YAML field | Type | Required | Default | Constraints / description |\n| --- | --- | --- | --- | --- |\n| `source_column` | string | yes | none | |\n| `target_dimension_table` | string | yes | none | |\n",
25
25
  "CsvParseOptions": "## CsvParseOptions\n\nHow to read a csv payload.\n\nUnknown fields are rejected.\n\n| YAML field | Type | Required | Default | Constraints / description |\n| --- | --- | --- | --- | --- |\n| `encoding` | string | no | `\"utf-8\"` | |\n| `separator` | string or null | no | `null` | |\n| `decimal` | string or null | no | `null` | |\n| `has_header` | boolean | no | `true` | |\n| `columns` | string or null | no | `null` | |\n",
26
26
  "CsvWriteOptions": "## CsvWriteOptions\n\nOptions for DataFrame → CSV serialization on export.\n\nUnknown fields are rejected.\n\n| YAML field | Type | Required | Default | Constraints / description |\n| --- | --- | --- | --- | --- |\n| `separator` | string | no | `\",\"` | |\n| `decimal` | string | no | `\".\"` | |\n| `encoding` | string | no | `\"utf-8\"` | |\n| `include_header` | boolean | no | `true` | |\n| `lineterminator` | string | no | `\"\\n\"` | minLength=`1` |\n",
27
+ "CustomExtractConfig": "## CustomExtractConfig\n\n`extract.type: custom` -- an extract an author writes, as an `@extractor` function in `Code/`.\n\nFor a source no built-in type reaches: an odd authentication, a SOAP\nservice, a flow of several calls. `script` is a file under `Code/`, in the\nfolder mirroring the step's own under `Models/`, and `function` names the\nfunction in it, the dataset's own name when omitted -- the binding\n`transform` and `parse` scripts follow.\n\n extract:\n type: custom\n custom:\n script: invoices.py\n args: {base_url: \"https://api.example.com/v1\"}\n secrets: {token: \"{{ pipeline_args.SHOP_TOKEN }}\"}\n\nThe function takes keyword-only `args` (a dict), `secrets` (a mapping\nthat prints itself masked), `http` (a client with retries and the\nnetwork guard of the `http` extract, sending `headers` with every\nrequest) and `logger`, each optional. Every value under `secrets` is\nmasked in the run's output, what the function prints included; a\ncredential put under `args` or `headers` is not.\n\nWhat the function returns is what lands: a file it wrote into the\ndirectory it was handed (the file's extension is the payload's format),\nrecords (a list or generator of dicts, landed as one JSON object per line),\nor a table (a DataFrame or Arrow table, landed as parquet). The parse step\nreading this extract interprets it, as for any other source, and\n`optional: true` skips only when the function raises\n`ExtractionSourceMissing`.\n\nUnknown fields are rejected.\n\n| YAML field | Type | Required | Default | Constraints / description |\n| --- | --- | --- | --- | --- |\n| `script` | string | yes | none | |\n| `function` | string or null | no | `null` | |\n| `args` | object | no | none | |\n| `secrets` | map of string | no | none | |\n| `headers` | map of string | no | none | Headers the `http` client sends with every request, to any host, such as a `User-Agent` a source's firewall expects. Not credentials: those go under `secrets:`. |\n| `timeout` | number | no | `120.0` | maximum=`3600`; exclusiveMinimum=`0`; Seconds per request the `http` client handed to the function makes. |\n| `private_network` | boolean | no | `false` | |\n",
27
28
  "CustomField": "## CustomField\n\nMaps a DataFrame column to a CUSTOM column meta.\n\nEach imported cell receives the column's value in a per-cell JSON blob,\nkeyed by the column's header name (= `source_column`). Typical uses:\nsource-system IDs, processing notes, confidence scores.\n\nUnknown fields are rejected.\n\n| YAML field | Type | Required | Default | Constraints / description |\n| --- | --- | --- | --- | --- |\n| `source_column` | string | yes | none | |\n",
28
- "DataSchema": "## DataSchema\n\nTop-level `schema:` block in a dataset YAML.\n\nUnknown fields are rejected.\n\n| YAML field | Type | Required | Default | Constraints / description |\n| --- | --- | --- | --- | --- |\n| `columns` | array of [ColumnSchema](#columnschema) | yes | none | minItems=`1` |\n",
29
+ "DataFormat": "## DataFormat\n\nThe extension a stored file may carry, which is all a store needs.\n\nNot \"a format the framework can interpret\" -- every step writes parquet, and\n`parse:` decides how a payload is read. This is the narrower question of\nwhat a file at rest may be *called*, which the Farseer Files store answers\nby writing `<leaf>.<value>` and probing these in order to find it again.\n\nThe set mirrors the backend's upload allow-list exactly, so any file that\nstore accepts can be landed. A subset would be a second, narrower policy\nfor someone to keep in sync, and it would fail the first time a source\nhands back a type nobody trimmed for.\n\nA folder there can hold more than one file under a dataset's name -- the\nworkbook an extract reads sits beside the parquet it writes, and a\n`sales.csv` written before parquet became the only output stays until\nsomeone removes it -- because the store writes its own file and touches no\nother. A name the store wrote in this run is read under the extension it\nwas written with; the probe, which takes the first extension present, is\nfor files from earlier runs, so `PARQUET` is first: a step's own output is\nthe one found.\n\nValues: `\"parquet\"`, `\"csv\"`, `\"json\"`, `\"xlsx\"`, `\"xls\"`, `\"xml\"`, `\"zip\"`, `\"txt\"`, `\"html\"`, `\"pdf\"`, `\"docx\"`, `\"md\"`, `\"yaml\"`, `\"yml\"`, `\"css\"`, `\"scss\"`, `\"js\"`, `\"jsx\"`, `\"ts\"`, `\"tsx\"`, `\"py\"`, `\"jpg\"`, `\"jpeg\"`, `\"png\"`, `\"svg\"`, `\"gif\"`, `\"webp\"`\n",
30
+ "DataSchema": "## DataSchema\n\nTop-level `schema:` block in a dataset YAML: the columns the dataset keeps.\n\nA parse step or transform with a `schema:` writes exactly these columns, in\nthis order. A column its output has and this does not declare is dropped and\nnamed in a warning, so declare every column a reader needs; a declared column\nthe output lacks fails validation. Without a `schema:` every column is kept.\n\nUnknown fields are rejected.\n\n| YAML field | Type | Required | Default | Constraints / description |\n| --- | --- | --- | --- | --- |\n| `columns` | array of [ColumnSchema](#columnschema) | yes | none | minItems=`1` |\n",
29
31
  "DateColumn": "## DateColumn\n\nMaps a DataFrame column to a DATE attribute column on a RAMA dim table.\n\nValues are converted to Excel serial numbers at load time via\n`farseer_client.date_utils.to_excel_serial`.\n\nUnknown fields are rejected.\n\n| YAML field | Type | Required | Default | Constraints / description |\n| --- | --- | --- | --- | --- |\n| `source_column` | string | yes | none | |\n| `target_dimension_table_column` | string | yes | none | |\n",
30
32
  "DimensionTableEntryOptions": "## DimensionTableEntryOptions\n\nPer-entry options for one dimension-table sync (this table only).\n\nDistinct from `DimensionTableOptions`, which carries options for the\nwhole `model.load` call (all tables at once); these govern a single\ntable's source frame.\n\nUnknown fields are rejected.\n\n| YAML field | Type | Required | Default | Constraints / description |\n| --- | --- | --- | --- | --- |\n| `allow_empty` | boolean | no | `false` | |\n",
31
33
  "DimensionTableOptions": "## DimensionTableOptions\n\nShared options for dimension table sync (applies to all tables in one API call).\n\nUnknown fields are rejected.\n\n| YAML field | Type | Required | Default | Constraints / description |\n| --- | --- | --- | --- | --- |\n| `delete_missing` | boolean | no | `false` | |\n",
@@ -33,8 +35,8 @@
33
35
  "ExportConfig": "## ExportConfig\n\nConfiguration for a `type: export` dataset step.\n\n`target` selects the destination system. The target-specific\nconfig block must match (e.g. `target: sharepoint` requires a\n`sharepoint:` section). Export steps are terminal sinks — no\ndownstream dataset depends on their output.\n\nUnknown fields are rejected.\n\n| YAML field | Type | Required | Default | Constraints / description |\n| --- | --- | --- | --- | --- |\n| `target` | [ExportTarget](#exporttarget) | yes | none | |\n| `sharepoint` | [SharePointExportConfig](#sharepointexportconfig) or null | no | `null` | |\n| `farseer_files` | [FarseerFilesExportConfig](#farseerfilesexportconfig) or null | no | `null` | |\n| `allow_empty` | boolean | no | `false` | |\n",
34
36
  "ExportFormat": "## ExportFormat\n\nValues: `\"csv\"`, `\"xlsx\"`, `\"parquet\"`\n",
35
37
  "ExportTarget": "## ExportTarget\n\nValues: `\"sharepoint\"`, `\"farseer_files\"`\n",
36
- "ExtractConfig": "## ExtractConfig\n\nConfiguration for a `type: extract` dataset step.\n\nUnknown fields are rejected.\n\n| YAML field | Type | Required | Default | Constraints / description |\n| --- | --- | --- | --- | --- |\n| `type` | [ExtractType](#extracttype) | yes | none | |\n| `google_drive_public` | [GoogleDrivePublicExtractConfig](#googledrivepublicextractconfig) or null | no | `null` | |\n| `google_drive` | [GoogleDriveExtractConfig](#googledriveextractconfig) or null | no | `null` | |\n| `sharepoint` | [SharePointExtractConfig](#sharepointextractconfig) or null | no | `null` | |\n| `sql_database` | [SqlDatabaseExtractConfig](#sqldatabaseextractconfig) or null | no | `null` | |\n| `farseer` | [FarseerExtractConfig](#farseerextractconfig) or null | no | `null` | |\n| `business_central` | [BusinessCentralExtractConfig](#businesscentralextractconfig) or null | no | `null` | |\n| `tldv` | [TldvExtractConfig](#tldvextractconfig) or null | no | `null` | |\n| `intercom` | [IntercomExtractConfig](#intercomextractconfig) or null | no | `null` | |\n| `notion` | [NotionExtractConfig](#notionextractconfig) or null | no | `null` | |\n| `hubspot` | [HubspotExtractConfig](#hubspotextractconfig) or null | no | `null` | |\n| `sap_odata` | [SapOdataExtractConfig](#sapodataextractconfig) or null | no | `null` | |\n| `s3` | [S3ExtractConfig](#s3extractconfig) or null | no | `null` | |\n| `optional` | boolean | no | `false` | When true, a source that does not exist (404, no such table, no such file) skips this extract instead of failing the run. The skip propagates to the parse step reading it and every step that depends on that, loads and exports included, and the run still finishes successfully. Network errors, authentication failures, timeouts and 5xx responses still fail the run. |\n",
37
- "ExtractType": "## ExtractType\n\nValues: `\"google_drive_public\"`, `\"google_drive\"`, `\"sharepoint\"`, `\"sql_database\"`, `\"farseer\"`, `\"business_central\"`, `\"tldv\"`, `\"intercom\"`, `\"notion\"`, `\"hubspot\"`, `\"sap_odata\"`, `\"s3\"`\n",
38
+ "ExtractConfig": "## ExtractConfig\n\nConfiguration for a `type: extract` dataset step.\n\nUnknown fields are rejected.\n\n| YAML field | Type | Required | Default | Constraints / description |\n| --- | --- | --- | --- | --- |\n| `type` | [ExtractType](#extracttype) | yes | none | |\n| `google_drive_public` | [GoogleDrivePublicExtractConfig](#googledrivepublicextractconfig) or null | no | `null` | |\n| `google_drive` | [GoogleDriveExtractConfig](#googledriveextractconfig) or null | no | `null` | |\n| `sharepoint` | [SharePointExtractConfig](#sharepointextractconfig) or null | no | `null` | |\n| `sql_database` | [SqlDatabaseExtractConfig](#sqldatabaseextractconfig) or null | no | `null` | |\n| `farseer` | [FarseerExtractConfig](#farseerextractconfig) or null | no | `null` | |\n| `business_central` | [BusinessCentralExtractConfig](#businesscentralextractconfig) or null | no | `null` | |\n| `tldv` | [TldvExtractConfig](#tldvextractconfig) or null | no | `null` | |\n| `intercom` | [IntercomExtractConfig](#intercomextractconfig) or null | no | `null` | |\n| `notion` | [NotionExtractConfig](#notionextractconfig) or null | no | `null` | |\n| `hubspot` | [HubspotExtractConfig](#hubspotextractconfig) or null | no | `null` | |\n| `sap_odata` | [SapOdataExtractConfig](#sapodataextractconfig) or null | no | `null` | |\n| `s3` | [S3ExtractConfig](#s3extractconfig) or null | no | `null` | |\n| `http` | [HttpExtractConfig](#httpextractconfig) or null | no | `null` | |\n| `custom` | [CustomExtractConfig](#customextractconfig) or null | no | `null` | |\n| `optional` | boolean | no | `false` | When true, a source that does not exist (404, no such table, no such file) skips this extract instead of failing the run. The skip propagates to the parse step reading it and every step that depends on that, loads and exports included, and the run still finishes successfully. Network errors, authentication failures, timeouts and 5xx responses still fail the run. |\n",
39
+ "ExtractType": "## ExtractType\n\nValues: `\"google_drive_public\"`, `\"google_drive\"`, `\"sharepoint\"`, `\"sql_database\"`, `\"farseer\"`, `\"business_central\"`, `\"tldv\"`, `\"intercom\"`, `\"notion\"`, `\"hubspot\"`, `\"sap_odata\"`, `\"s3\"`, `\"http\"`, `\"custom\"`\n",
38
40
  "FarseerDatasetsExtractConfig": "## FarseerDatasetsExtractConfig\n\n`extract.farseer.source: datasets` — read a versioned dataset.\n\nReads from the Labs Datasets API: the symmetric counterpart to\n`DatasetDataStore` writes — same control-plane API, same GCS data-plane,\njust the read half.\n\n`qualified_name` is the dataset's registered name (the writer's\nqualified name maps 1:1 to the API `name` field). `version_id`\npins the read to a specific completed version for reproducibility;\nwhen omitted the extractor reads the dataset's currently promoted\nversion. An unpromoted dataset (created but never promoted) is\ntreated as a missing source so `optional: true` can absorb it.\n\nUnknown fields are rejected.\n\n| YAML field | Type | Required | Default | Constraints / description |\n| --- | --- | --- | --- | --- |\n| `qualified_name` | string | yes | none | |\n| `version_id` | string or null | no | `null` | |\n",
39
41
  "FarseerDimensionsConnection": "## FarseerDimensionsConnection\n\nProjects a foreign-key column on a dim table to a DataFrame column.\n\nInverse of the load side's `dimension_tables.tables[].mapping.connections`.\nThe DataFrame cell receives a list of connected-member names\n(`/model/export` resolves FK ids to names server-side via\n`PK_MEMBER_EXTRACTOR`).\n\nUnknown fields are rejected.\n\n| YAML field | Type | Required | Default | Constraints / description |\n| --- | --- | --- | --- | --- |\n| `source_dimension_table` | string | yes | none | |\n| `target_column` | string | yes | none | |\n",
40
42
  "FarseerDimensionsDateColumn": "## FarseerDimensionsDateColumn\n\nProjects a DATE attribute column on a dim table to a DataFrame column.\n\nThe DataFrame value is the raw Excel serial number Rama stores — days\nsince 1899-12-30 with the 1900 leap-year bug preserved. See\n`clients/python/src/farseer_client/date_utils.py` for the formula\n(only the forward conversion `to_excel_serial` ships in the client\ntoday) if a downstream transform needs a Python date.\n\nUnknown fields are rejected.\n\n| YAML field | Type | Required | Default | Constraints / description |\n| --- | --- | --- | --- | --- |\n| `source_dimension_table_column` | string | yes | none | |\n| `target_column` | string | yes | none | |\n",
@@ -56,6 +58,16 @@
56
58
  "FixedDimension": "## FixedDimension\n\nPin a dimension member for a variable column.\n\nUnknown fields are rejected.\n\n| YAML field | Type | Required | Default | Constraints / description |\n| --- | --- | --- | --- | --- |\n| `dimension_table` | string | yes | none | |\n| `dimension_member` | string | yes | none | |\n",
57
59
  "GoogleDriveExtractConfig": "## GoogleDriveExtractConfig\n\nExtraction settings for private Google Drive files (service account).\n\nAuthenticates as a Google Cloud service account; the client shares the\nfolder (or Shared Drive) with the service account's e-mail as a Viewer,\nso no domain-wide delegation and no per-user OAuth is involved.\n\n`service_account_json` is the service account's full JSON key,\ntemplated via `{{ pipeline_args.NAME }}` so a Remote Job's secret\n`expectedArguments` flow through at discovery time. Its shape is\nvalidated at extract time, not here — a schema-load error would echo\nthe offending input back into logs (`hide_input_in_errors` guards\nthe pydantic side of that).\n\nTwo addressing modes, mutually exclusive:\n\n- `file_id` — opaque Drive file ID.\n- `folder_id` + `file_path` — anchor folder ID (the folder the\n client shared) plus a slash-separated path below it, resolved one\n segment at a time. Folder IDs are stable across renames, so the\n anchor survives the client tidying up folder names. The final\n segment may contain `*` wildcards (e.g. `REPORT2502AC.*` for a\n source whose extension flips between `.xlsx` and `.xls` across\n periods); exactly one file must match.\n\nUnknown fields are rejected.\n\n| YAML field | Type | Required | Default | Constraints / description |\n| --- | --- | --- | --- | --- |\n| `service_account_json` | string or null | no | `null` | |\n| `file_id` | string or null | no | `null` | |\n| `folder_id` | string or null | no | `null` | |\n| `file_path` | string or null | no | `null` | |\n",
58
60
  "GoogleDrivePublicExtractConfig": "## GoogleDrivePublicExtractConfig\n\nExtraction settings for public Google Drive files.\n\nOnly works with files shared as \"Anyone with the link\" — no auth required.\n\nUnknown fields are rejected.\n\n| YAML field | Type | Required | Default | Constraints / description |\n| --- | --- | --- | --- | --- |\n| `file_id` | string | yes | none | |\n",
61
+ "HttpBasicAuth": "## HttpBasicAuth\n\nHTTP Basic authentication with a username and a password.\n\nUnknown fields are rejected.\n\n| YAML field | Type | Required | Default | Constraints / description |\n| --- | --- | --- | --- | --- |\n| `type` | `\"basic\"` | yes | none | |\n| `username` | string | yes | none | |\n| `password` | string | yes | none | From a secret run argument: `{{ pipeline_args.NAME }}`. |\n",
62
+ "HttpBearerAuth": "## HttpBearerAuth\n\n`Authorization: Bearer <token>` on every request to the configured origin.\n\nUnknown fields are rejected.\n\n| YAML field | Type | Required | Default | Constraints / description |\n| --- | --- | --- | --- | --- |\n| `type` | `\"bearer\"` | yes | none | |\n| `token` | string | yes | none | The token, from a secret run argument: `{{ pipeline_args.NAME }}`. |\n",
63
+ "HttpCursorPagination": "## HttpCursorPagination\n\nSend the cursor from each page as a query parameter, until a page returns none.\n\nA page that hands back the cursor it was asked with fails the step rather\nthan looping.\n\nUnknown fields are rejected.\n\n| YAML field | Type | Required | Default | Constraints / description |\n| --- | --- | --- | --- | --- |\n| `type` | `\"cursor\"` | yes | none | |\n| `cursor` | string | yes | none | JSON Pointer to the next cursor in the body, e.g. `/meta/next_cursor`. |\n| `param` | string | yes | none | The query parameter the cursor is sent in. |\n| `max_pages` | integer | no | `1000` | exclusiveMinimum=`0`; A ceiling on pages, so a crawl that never ends fails instead of running until the job's time limit. A source with more pages fails the step; it never truncates. The empty page that ends a page or offset crawl does not count. |\n",
64
+ "HttpExtractConfig": "## HttpExtractConfig\n\n`extract.type: http` -- one HTTP(S) source, configured rather than coded.\n\nA single request lands the response body as it came, under `format` (or\nthe extension its `Content-Type` names), for the parse step reading this\nextract to interpret: an ECB `csvdata` response is read by\n`parse: {format: csv}` with no code at all.\n\nWith `records`, or with `pagination`, the body is JSON and what lands is\nthe records: the array `records` points at, from every page, one JSON\nobject per line, as the source sent each one. A `format: json` parse step\nreads them when the fields it declares are flat; nested ones need an\n`@parse` function.\n\n extract:\n type: http\n http:\n url: https://api.example.com/v1/orders\n params: {status: open}\n auth: {type: bearer, token: \"{{ pipeline_args.SHOP_TOKEN }}\"}\n records: /data\n pagination: {type: cursor, cursor: /meta/next_cursor, param: cursor}\n\nCredentials go in `auth:` and nowhere else, templated from secret run\narguments. They are sent only to the origin of `url`, masked in every\nmessage, and dropped on a redirect to another origin.\n\n`not_found` and `empty` say whether a 404, or a response with no body (no\nrecords, in record mode), means the data is not there -- the signal\n`optional: true` skips on -- or that something is wrong. Both default to\nfailing: the ECB answers 404 for a misspelled series key, which must not\nread as an absent month.\n\nDestinations other than public `https://` hosts are refused -- loopback,\nlink-local, private ranges and plain `http://` -- unless\n`private_network: true`, which is how a source behind the tenant's VPN is\nreached. That catches a wrong URL; it is not a sandbox.\n\nUnknown fields are rejected.\n\n| YAML field | Type | Required | Default | Constraints / description |\n| --- | --- | --- | --- | --- |\n| `url` | string | yes | none | |\n| `method` | `\"GET\"`, `\"POST\"` | no | `\"GET\"` | |\n| `params` | map of string or integer or number or boolean | no | none | Query parameters, added to `url`'s own. |\n| `headers` | map of string | no | none | Headers that are not credentials; credentials go in `auth:`. |\n| `json` | any | no | `null` | A JSON request body, for `POST` only. |\n| `auth` | [HttpBearerAuth](#httpbearerauth) or [HttpBasicAuth](#httpbasicauth) or [HttpHeaderAuth](#httpheaderauth) or [HttpQueryAuth](#httpqueryauth) or [HttpOAuth2ClientCredentialsAuth](#httpoauth2clientcredentialsauth) or null | no | `null` | |\n| `format` | [DataFormat](#dataformat) or null | no | `null` | What the body is, which is the extension the payload is stored under. Omit it to take the one the `Content-Type` names. Record mode always lands `json`. |\n| `records` | string or null | no | `null` | JSON Pointer to the array of records in the body, e.g. `/data` or `/value`. Omit it for a body that is the array itself. |\n| `pagination` | [HttpNextUrlPagination](#httpnexturlpagination) or [HttpCursorPagination](#httpcursorpagination) or [HttpPagePagination](#httppagepagination) or [HttpOffsetPagination](#httpoffsetpagination) or null | no | `null` | |\n| `not_found` | `\"fail\"`, `\"missing\"` | no | `\"fail\"` | |\n| `empty` | `\"fail\"`, `\"missing\"` | no | `\"fail\"` | |\n| `timeout` | number | no | `120.0` | maximum=`3600`; exclusiveMinimum=`0`; Seconds per request. |\n| `private_network` | boolean | no | `false` | |\n",
65
+ "HttpHeaderAuth": "## HttpHeaderAuth\n\nOne or more headers carrying a key, such as `X-Api-Key`.\n\nEvery value here is treated as a secret: masked in messages and logs, and\nnever sent to another origin.\n\nUnknown fields are rejected.\n\n| YAML field | Type | Required | Default | Constraints / description |\n| --- | --- | --- | --- | --- |\n| `type` | `\"header\"` | yes | none | |\n| `headers` | map of string | yes | none | |\n",
66
+ "HttpNextUrlPagination": "## HttpNextUrlPagination\n\nFollow each page's link to the next one, until a page has none.\n\n`next_url` points at the link in the body (`/@odata.nextLink`,\n`/links/next`). Without it the `Link` response header is read for\n`rel=\"next\"`. A relative link is resolved against the page it came from;\na link to another origin is refused, because the request carries the\nstep's credentials.\n\nUnknown fields are rejected.\n\n| YAML field | Type | Required | Default | Constraints / description |\n| --- | --- | --- | --- | --- |\n| `type` | `\"next_url\"` | yes | none | |\n| `next_url` | string or null | no | `null` | JSON Pointer to the next page's URL in the body. Omit it to read the `Link` header. |\n| `max_pages` | integer | no | `1000` | exclusiveMinimum=`0`; A ceiling on pages, so a crawl that never ends fails instead of running until the job's time limit. A source with more pages fails the step; it never truncates. The empty page that ends a page or offset crawl does not count. |\n",
67
+ "HttpOAuth2ClientCredentialsAuth": "## HttpOAuth2ClientCredentialsAuth\n\nOAuth 2.0 client credentials: a token from `token_url`, then `Bearer` on every request.\n\nThe token is requested once per run and is not refreshed, so a crawl that\noutlives it fails with a 401 rather than continuing on a stale grant.\n`params` adds form fields some servers require, such as `audience` or\n`resource`.\n\nUnknown fields are rejected.\n\n| YAML field | Type | Required | Default | Constraints / description |\n| --- | --- | --- | --- | --- |\n| `type` | `\"oauth2_client_credentials\"` | yes | none | |\n| `token_url` | string | yes | none | |\n| `client_id` | string | yes | none | |\n| `client_secret` | string | yes | none | From a secret run argument: `{{ pipeline_args.NAME }}`. |\n| `scope` | string or null | no | `null` | |\n| `params` | map of string | no | none | |\n",
68
+ "HttpOffsetPagination": "## HttpOffsetPagination\n\nMove an offset by the records each page returned, until a page returns none.\n\nIt asks for `limit` records a page but moves by what arrived, so a server\nthat caps its pages below `limit` is still read whole. It stops on an\nempty page for the reason page numbering does.\n\nUnknown fields are rejected.\n\n| YAML field | Type | Required | Default | Constraints / description |\n| --- | --- | --- | --- | --- |\n| `type` | `\"offset\"` | yes | none | |\n| `param` | string | no | `\"offset\"` | |\n| `limit_param` | string | no | `\"limit\"` | |\n| `limit` | integer | yes | none | exclusiveMinimum=`0` |\n| `start` | integer | no | `0` | minimum=`0` |\n| `max_pages` | integer | no | `1000` | exclusiveMinimum=`0`; A ceiling on pages, so a crawl that never ends fails instead of running until the job's time limit. A source with more pages fails the step; it never truncates. The empty page that ends a page or offset crawl does not count. |\n",
69
+ "HttpPagePagination": "## HttpPagePagination\n\nNumber the pages in a query parameter, until a page returns no records.\n\nIt stops on the first empty page rather than the first short one: an API\nthat caps its page size below the one asked for returns short pages long\nbefore the end, and stopping there would drop the rest without a word.\n\nUnknown fields are rejected.\n\n| YAML field | Type | Required | Default | Constraints / description |\n| --- | --- | --- | --- | --- |\n| `type` | `\"page\"` | yes | none | |\n| `param` | string | no | `\"page\"` | |\n| `start` | integer | no | `1` | |\n| `size_param` | string or null | no | `null` | |\n| `size` | integer or null | no | `null` | integer: exclusiveMinimum=`0` |\n| `max_pages` | integer | no | `1000` | exclusiveMinimum=`0`; A ceiling on pages, so a crawl that never ends fails instead of running until the job's time limit. A source with more pages fails the step; it never truncates. The empty page that ends a page or offset crawl does not count. |\n",
70
+ "HttpQueryAuth": "## HttpQueryAuth\n\nA key sent as a query parameter, such as `?api_key=...`.\n\nEvery value here is treated as a secret and masked wherever the URL is\nshown. Prefer a header where the API accepts one: a query string is more\nlikely to be logged on the server side.\n\nUnknown fields are rejected.\n\n| YAML field | Type | Required | Default | Constraints / description |\n| --- | --- | --- | --- | --- |\n| `type` | `\"query\"` | yes | none | |\n| `params` | map of string | yes | none | |\n",
59
71
  "HubspotAssociationsExtractConfig": "## HubspotAssociationsExtractConfig\n\nOne row per (record of `object_type`, associated record) pair.\n\nThe link table between two HubSpot object types -- which company a deal\nbelongs to, which contacts a note was logged against. A record extract\ncarries no such information: HubSpot keeps associations beside the\nrecord, not on it, and reports them only when a crawl asks for the\n`to_object_types` by name. This grain does that ask over the same record\ncrawl `objects` uses, and explodes what comes back to one row per pair.\n\n`association_type` is HubSpot's own label for the link\n(`deal_to_company`, `note_to_contact`, ...). The same pair often arrives\ntwice, once as the typed link and once as its `_unlabeled` twin, which is\nHubSpot's representation of an unlabelled association rather than a\nduplicate; keep both or dedupe in a transform, as the model needs.\n\nUnknown fields are rejected.\n\n| YAML field | Type | Required | Default | Constraints / description |\n| --- | --- | --- | --- | --- |\n| `object_type` | string | yes | none | |\n| `to_object_types` | array of string | yes | none | minItems=`1` |\n| `archived` | boolean | no | `false` | |\n| `page_size` | integer | no | `100` | maximum=`100`; exclusiveMinimum=`0` |\n",
60
72
  "HubspotExtractConfig": "## HubspotExtractConfig\n\n`extract.type: hubspot` — multi-source family over the HubSpot CRM API.\n\nAuthentication is a `pat-<region>-...` bearer token — either an\n**account service key** (the current developer platform's credential\nfor single-account API access) or a **legacy private app token**. Both\nare account-level, carry the same object-specific scopes, and go over\nthe wire identically, so `access_token` is validated only for presence\nand not for shape: a token format check here would reject a\nHubSpot-issued credential the moment they add a fourth variant. The\ntoken is supplied as a YAML field, typically templated via\n`{{ pipeline_args.HUBSPOT_ACCESS_TOKEN }}` so a Remote Job's secret\n`expectedArguments` flow through at discovery time.\n\n`source:` picks the grain; the matching inner block carries its\nconfig. One token covers every source, so it lives out here.\n\nEvery source stores a parquet payload, which a parse step reads with\n`format: parquet` — same as `business_central` and `sql_database`. A\n`schema:` goes on that parse step, where it checks the result rather than\ninstructing the read.\n\nHubSpot serializes every record property as a JSON *string*, including\nnumbers, booleans and dates. The extractor reads the object's property\ncatalog and coerces each column to the type HubSpot declares for it,\nbecause leaving it alone would make `amount` a text column that sums\nby concatenation, and `\"false\"` a truthy value. Record ids stay\nstrings deliberately: they exceed 2^53 in some portals, so any numeric\ndtype would corrupt them.\n\nTimestamps land as timezone-naive UTC. HubSpot documents every time as\nUTC and date-only properties as midnight UTC; dropping the marker\nrather than converting keeps the values as HubSpot stated them and\nmatches the physical type the platform's `type: datetime` declares.\nLocalizing them to a negative-offset zone downstream would move a\nclose date — and its revenue — into the previous month.\n\nUnknown fields are rejected.\n\n| YAML field | Type | Required | Default | Constraints / description |\n| --- | --- | --- | --- | --- |\n| `source` | [HubspotSource](#hubspotsource) | yes | none | |\n| `access_token` | string or null | no | `null` | |\n| `objects` | [HubspotObjectsExtractConfig](#hubspotobjectsextractconfig) or null | no | `null` | |\n| `pipelines` | [HubspotPipelinesExtractConfig](#hubspotpipelinesextractconfig) or null | no | `null` | |\n| `properties` | [HubspotPropertyCatalogConfig](#hubspotpropertycatalogconfig) or null | no | `null` | |\n| `property_options` | [HubspotPropertyCatalogConfig](#hubspotpropertycatalogconfig) or null | no | `null` | |\n| `associations` | [HubspotAssociationsExtractConfig](#hubspotassociationsextractconfig) or null | no | `null` | |\n| `owners` | [HubspotOwnersExtractConfig](#hubspotownersextractconfig) or null | no | `null` | |\n",
61
73
  "HubspotObjectsExtractConfig": "## HubspotObjectsExtractConfig\n\nOne row per CRM record of `object_type`, one column per requested property.\n\n`object_type` is HubSpot's own plural object name as it appears in the\nAPI path (`deals`, `companies`, `contacts`, `line_items`, `tickets`),\nor a custom object's `p<portalId>_<name>` / `2-xxxxxxx` identifier.\n\n`properties` is required and has no wildcard form, which is the single\nmost consequential choice in this config. HubSpot returns only about\neight default properties when the parameter is omitted — a portal with\n400 deal properties answers a propertyless request with eight columns\nand no warning — so an implicit \"everything\" would make the dataset's\ncolumn set a function of whatever a HubSpot admin last added, silently\nfor undeclared columns and as a hard failure for anything downstream\ndeclaring a `schema:`. Declaring the list keeps the frame's shape owned\nby the pipeline. Extract `source: properties` first to discover what the\nportal actually has, then name the ones the model needs.\n\nProperty names are checked against the portal's own catalog before the\ncrawl starts: HubSpot ignores an unknown property rather than\nrejecting it, so a typo would otherwise land a frame quietly missing\nthat column.\n\n`archived` selects HubSpot's archived (soft-deleted, recoverable)\nrecords *instead of* the live ones — it is the API's own parameter, not\na union. Reading both means two datasets.\n\n`page_size` is HubSpot's `limit`. It defaults to the documented\nmaximum rather than HubSpot's own default of 10, which would make ten\ntimes as many requests for the same data.\n\nUnknown fields are rejected.\n\n| YAML field | Type | Required | Default | Constraints / description |\n| --- | --- | --- | --- | --- |\n| `object_type` | string | yes | none | |\n| `properties` | array of string | yes | none | minItems=`1` |\n| `archived` | boolean | no | `false` | |\n| `page_size` | integer | no | `100` | maximum=`100`; exclusiveMinimum=`0` |\n",
@@ -1,7 +1,6 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../src/pipeline/guide.ts"],
4
- "sourcesContent": ["import { pipelineSkill } from '../skills/pipeline';\n\n// CLI and MCP guide callers read the same method and practices as native skill clients.\nexport const PIPELINE_GUIDE = pipelineSkill.body;\nexport const PIPELINE_PRACTICES = pipelineSkill.practices;\n"],
5
4
  "mappings": ";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,sBAA8B;AAGvB,MAAM,iBAAiB,8BAAc;AACrC,MAAM,qBAAqB,8BAAc;",
6
5
  "names": []
7
6
  }
@@ -1,7 +1,6 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../src/pipeline/init.ts"],
4
- "sourcesContent": ["import * as fs from 'fs';\nimport * as path from 'path';\nimport { randomUUID } from 'crypto';\nimport type { RemoteApp, SourceFolderResolution } from '../services/apps';\nimport { profileFile, type PipelinePaths } from './connect';\nimport { PIPELINE_ENGINE_PROFILE } from './reference';\nimport { assertPipelineRuntime, compareRuntime } from './runtime';\nimport {\n BLANK_SETUP,\n PipelineClient,\n PipelineProfile,\n PipelineService,\n profileSchema,\n readPipelineProfileFile,\n redact,\n SCHEDULE_NOTE,\n} from './service';\n\nconst { load: loadYaml }: { load: (source: string) => unknown } = require('js-yaml');\n\n/** What the skill's starter layout uses and what check expects when the job names no script. */\nconst CONVENTIONAL_ENTRYPOINT = 'main.py';\n// Mirrors the engine's charset for a rendered dataset name; anything else is templated or invalid.\nconst DATASET_NAME = /^[A-Za-z0-9_-]+$/;\n\nexport interface InitOptions {\n organisation: string;\n tenant: string;\n jobId: number;\n workspace?: string;\n force?: boolean;\n}\ninterface Definition {\n file: string;\n qualifiedName: string;\n}\ninterface SkippedDefinition {\n file: string;\n reason: string;\n}\nexport interface InitResult {\n file: string;\n profile: PipelineProfile;\n datasets: { name: string; id: string; file: string }[];\n /** Declared under Models/ but not created yet; the engine creates a dataset on its first write. */\n pendingDatasets: { name: string; file: string }[];\n skippedDefinitions: SkippedDefinition[];\n warnings: string[];\n nextSteps: string[];\n}\ntype Job = RemoteApp & { sourceFolderId: number; runnerImage: string };\n\n/** Derive a profile from the prepared job and write it. Reads only; never changes remote state. */\nexport async function initPipelineProfile(\n options: InitOptions,\n client: PipelineClient,\n paths: PipelinePaths,\n): Promise<InitResult> {\n const warnings: string[] = [];\n const job = await readJob(client, options.jobId);\n const workspace = options.workspace ?? (await locateWorkspace(client, job));\n const folder = await resolveFolder(client, job, workspace);\n const file = targetFile(paths.profileDir, workspace, options.force ?? false);\n const identity = {\n organisation: options.organisation,\n tenant: options.tenant,\n jobId: job.id,\n sourceFolderId: job.sourceFolderId,\n workspace,\n };\n const kept = writtenByPeople(file, identity, warnings);\n const draft = profileSchema.parse({\n ...identity,\n author: kept?.author,\n configFiles: kept?.configFiles,\n entrypoint: entrypointFor(job, folder, warnings),\n engine: PIPELINE_ENGINE_PROFILE,\n schedule: job.schedule ?? null,\n });\n const runtime = compareRuntime(job.runnerImage);\n if (runtime.status !== 'match') warnings.push(runtime.nextAction);\n if (job.schedule)\n warnings.push(`Job runs on schedule \"${job.schedule}\" (recorded in the profile). ${SCHEDULE_NOTE}`);\n const service = new PipelineService(draft, client, paths.filesDir, paths.stateRoot);\n const { definitions, skipped } = await scanDefinitions(service, paths.filesDir, warnings);\n const resolved = await resolveDatasets(client, definitions);\n const profile = profileSchema.parse({\n ...draft,\n datasetIds: [...new Set(resolved.datasets.map((d) => d.id))],\n setup: kept?.setup ?? BLANK_SETUP,\n });\n writeProfile(file, profile);\n return {\n file,\n profile,\n ...resolved,\n skippedDefinitions: skipped,\n warnings,\n nextSteps: [\n 'Fill the setup record: owner, checkedAt (ISO datetime), evidence, retentionDays, otherWritersExcluded=true and runtimeVerified=true. These are owner statements; check reports the record as pending until all are filled.',\n ...(resolved.pendingDatasets.length\n ? [\n `Pending datasets (${resolved.pendingDatasets.map((d) => d.name).join(', ')}) are created on the first run; rerun init jobId=${job.id} force=true after it to record their IDs.`,\n ]\n : []),\n 'Run check to see what is verified and what is still pending.',\n ],\n };\n}\n\nasync function readJob(client: PipelineClient, jobId: number): Promise<Job> {\n const job = await client.getApp(String(jobId));\n if (!job) throw new Error(`Job ${jobId} was not found on this tenant`);\n const runnerImage = job.runnerImage ?? '';\n assertPipelineRuntime(runnerImage);\n if (!job.sourceFolderId) throw new Error(`Job ${jobId} has no source folder; set one in the web app first`);\n return { ...job, sourceFolderId: job.sourceFolderId, runnerImage };\n}\n\n/** The job stores a folder ID, not a path; the path comes from where its main script lives. */\nasync function locateWorkspace(client: PipelineClient, job: Job): Promise<string> {\n const advice = 'give the workspace folder (workspace=<dir>, the tenant-relative source folder path)';\n if (!job.mainScriptFileId) throw new Error(`Job ${job.id} has no main script; ${advice}`);\n const script = (await client.listFiles(['Files'])).find((f) => f.reference === job.mainScriptFileId);\n if (!script) throw new Error(`Main script of job ${job.id} was not found under Files; ${advice}`);\n const workspace = path.posix.dirname(script.path);\n if (workspace === '.') throw new Error(`Main script of job ${job.id} sits at the Files root; ${advice}`);\n return workspace;\n}\n\nasync function resolveFolder(client: PipelineClient, job: Job, workspace: string): Promise<SourceFolderResolution> {\n const folder = await client.resolveSourceFolder(workspace);\n if (!folder) throw new Error(`Workspace folder \"${workspace}\" does not exist under Files`);\n if (folder.id !== job.sourceFolderId)\n throw new Error(\n `Workspace folder \"${workspace}\" (id ${folder.id}) is not the source folder of job ${job.id} (id ${job.sourceFolderId})`,\n );\n return folder;\n}\n\nfunction entrypointFor(job: Job, folder: SourceFolderResolution, warnings: string[]): string {\n const script = folder.scripts.find((s) => s.id === job.mainScriptFileId);\n if (script) return script.name;\n warnings.push(\n `Job ${job.id} names no main script inside its source folder; wrote the conventional entrypoint ${CONVENTIONAL_ENTRYPOINT}. Until the job's main script is set to it, check reports prepared-job as failed and run refuses.`,\n );\n return CONVENTIONAL_ENTRYPOINT;\n}\n\n/**\n * What people wrote into the existing profile, kept when it belongs to the same job and folder: a\n * rerun with force refreshes only what init reads from the job. A profile for anything else, or one\n * that cannot be read, is replaced by a fresh one.\n */\nfunction writtenByPeople(\n file: string,\n identity: Pick<PipelineProfile, 'organisation' | 'tenant' | 'jobId' | 'sourceFolderId' | 'workspace'>,\n warnings: string[],\n): Pick<PipelineProfile, 'author' | 'configFiles' | 'setup'> | undefined {\n if (!fs.existsSync(file)) return undefined;\n let existing: PipelineProfile;\n try {\n existing = readPipelineProfileFile(file);\n } catch (error) {\n warnings.push(\n `The existing profile could not be read, so its setup record, config files and author were not kept: ${redact(error instanceof Error ? error.message : String(error))}`,\n );\n return undefined;\n }\n const same = (Object.keys(identity) as (keyof typeof identity)[]).every((key) => existing[key] === identity[key]);\n return same ? { author: existing.author, configFiles: existing.configFiles, setup: existing.setup } : undefined;\n}\n\n/** Named after the pipeline folder, so one tenant can hold a profile per pipeline. */\nfunction targetFile(profileDir: string, workspace: string, force: boolean): string {\n const file = profileFile(profileDir, path.posix.basename(workspace));\n if (fs.existsSync(file) && !force)\n throw new Error(`Profile ${file} already exists for workspace ${workspace}; set force=true to overwrite it`);\n return file;\n}\n\n/** Dataset YAML in the local Models/ tree, pulled first when the workspace has no local source. */\nasync function scanDefinitions(\n service: PipelineService,\n filesDir: string,\n warnings: string[],\n): Promise<{ definitions: Definition[]; skipped: SkippedDefinition[] }> {\n if (!service.localSources().length) {\n try {\n await service.syncSources('pull');\n } catch (error) {\n warnings.push(\n `No local source and the pull failed, so no datasets were derived: ${redact(String(error))}. Fix the job, pull, then rerun init jobId=${service.profile.jobId} force=true.`,\n );\n }\n }\n const prefix = `${service.profile.workspace}/Models/`;\n const definitions: Definition[] = [];\n const skipped: SkippedDefinition[] = [];\n for (const file of service\n .localSources()\n .filter((f) => f.startsWith(prefix) && /\\.ya?ml$/.test(f))\n .sort()) {\n const parsed = readDefinition(path.join(filesDir, file), file.slice(prefix.length));\n if ('reason' in parsed) skipped.push({ file, reason: parsed.reason });\n else definitions.push({ file, qualifiedName: parsed.qualifiedName });\n }\n return { definitions, skipped };\n}\n\n/** Same rule as the engine: folders under Models/ form the namespace, the YAML name is the last segment. */\nfunction readDefinition(absolute: string, relativeToModels: string): { qualifiedName: string } | { reason: string } {\n let data: unknown;\n try {\n data = loadYaml(fs.readFileSync(absolute, 'utf8'));\n } catch {\n return { reason: 'invalid YAML syntax' };\n }\n const name = (data as { name?: unknown } | null)?.name;\n if (typeof name !== 'string') return { reason: 'no string name field' };\n if (!DATASET_NAME.test(name)) return { reason: `name \"${name}\" is templated or not a plain dataset name` };\n const namespace = path.posix\n .dirname(relativeToModels)\n .split('/')\n .filter((p) => p !== '.');\n return { qualifiedName: [...namespace, name].join('.') };\n}\n\nasync function resolveDatasets(client: PipelineClient, definitions: Definition[]) {\n // A newly scaffolded pipeline (or a plain script job) has no dataset names\n // to resolve. It must be initializable before dataset storage is configured.\n if (definitions.length === 0) return { datasets: [], pendingDatasets: [] };\n const remote = await client.pipelineRequest<{ id: string; name: string }[]>('GET', '/labs/datasets');\n const byName = new Map(remote.map((d) => [d.name, d.id]));\n const datasets: InitResult['datasets'] = [];\n const pendingDatasets: InitResult['pendingDatasets'] = [];\n for (const { file, qualifiedName: name } of definitions) {\n const id = byName.get(name);\n if (id) datasets.push({ name, id, file });\n else pendingDatasets.push({ name, file });\n }\n return { datasets, pendingDatasets };\n}\n\nfunction writeProfile(file: string, profile: PipelineProfile) {\n fs.mkdirSync(path.dirname(file), { recursive: true });\n const tmp = `${file}.${randomUUID()}`;\n fs.writeFileSync(tmp, JSON.stringify(profile, null, 2) + '\\n', { mode: 0o600 });\n fs.renameSync(tmp, file);\n}\n"],
5
4
  "mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,SAAoB;AACpB,WAAsB;AACtB,oBAA2B;AAE3B,qBAAgD;AAChD,uBAAwC;AACxC,qBAAsD;AACtD,qBASO;AAEP,MAAM,EAAE,MAAM,SAAS,IAA2C,QAAQ,SAAS;AAGnF,MAAM,0BAA0B;AAEhC,MAAM,eAAe;AA8BrB,eAAsB,oBAClB,SACA,QACA,OACmB;AACnB,QAAM,WAAqB,CAAC;AAC5B,QAAM,MAAM,MAAM,QAAQ,QAAQ,QAAQ,KAAK;AAC/C,QAAM,YAAY,QAAQ,aAAc,MAAM,gBAAgB,QAAQ,GAAG;AACzE,QAAM,SAAS,MAAM,cAAc,QAAQ,K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CAAC,EAAE,MAAM,EAAE,EAAE,CAAC,CAAC;AACxD,QAAM,WAAmC,CAAC;AAC1C,QAAM,kBAAiD,CAAC;AACxD,aAAW,EAAE,MAAM,eAAe,KAAK,KAAK,aAAa;AACrD,UAAM,KAAK,OAAO,IAAI,IAAI;AAC1B,QAAI,GAAI,UAAS,KAAK,EAAE,MAAM,IAAI,KAAK,CAAC;AAAA,QACnC,iBAAgB,KAAK,EAAE,MAAM,KAAK,CAAC;AAAA,EAC5C;AACA,SAAO,EAAE,UAAU,gBAAgB;AACvC;AAEA,SAAS,aAAa,MAAc,SAA0B;AAC1D,KAAG,UAAU,KAAK,QAAQ,IAAI,GAAG,EAAE,WAAW,KAAK,CAAC;AACpD,QAAM,MAAM,GAAG,IAAI,QAAI,0BAAW,CAAC;AACnC,KAAG,cAAc,KAAK,KAAK,UAAU,SAAS,MAAM,CAAC,IAAI,MAAM,EAAE,MAAM,IAAM,CAAC;AAC9E,KAAG,WAAW,KAAK,IAAI;AAC3B;",
6
5
  "names": []
7
6
  }
@@ -1,7 +1,6 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../src/pipeline/operations.ts"],
4
- "sourcesContent": ["import type { PipelinePaths } from './connect';\nimport { createPipeline } from './create';\nimport { initPipelineProfile } from './init';\nimport type { PipelineClient, PipelineService } from './service';\n\n/**\n * The operations every surface (CLI command, MCP tool) exposes on a connected pipeline.\n * recover and unlock stay CLI-only: they resolve local state after a crash and are not\n * offered to a model.\n */\nexport const PIPELINE_OPERATIONS = [\n 'check',\n 'pull',\n 'push',\n 'run',\n 'runs',\n 'inspect',\n 'inspect-import',\n 'query',\n 'versions',\n 'restore',\n 'terminate',\n 'upgrade-runtime',\n] as const;\nexport type PipelineOperation = (typeof PIPELINE_OPERATIONS)[number];\n\nexport interface PipelineOperationArgs {\n /** Exact run UUID: for inspect (the local receipt's run when absent) and terminate (required). */\n uuid?: string;\n datasetId?: string;\n versionId?: string;\n /** The current version observed before restore; a stale value is refused by the backend. */\n expectedCurrent?: string;\n importId?: number;\n /** Log offset for inspect, from a previous page's nextOffset. */\n offset?: number;\n /** Ordered job arguments for run. */\n args?: string[];\n /** Version bindings {name, datasetId, versionId} or file bindings {name, file} for query. */\n bindings?: unknown[];\n sql?: string;\n /** Runs to list, newest first. */\n limit?: number;\n}\n\nexport interface PipelineInitSelection {\n organisation: string;\n tenant: string;\n /** Attach to a job somebody prepared; reads only. */\n jobId?: number;\n /** Create folder, job and profile for a new pipeline named after its folder. */\n name?: string;\n workspace?: string;\n force?: boolean;\n}\n\nfunction required<T>(name: keyof PipelineOperationArgs, value: T | undefined): T {\n if (value === undefined) throw new Error(`${name} is required`);\n return value;\n}\n\n/** One dispatcher for every surface, so an operation means the same call everywhere. */\nexport async function runPipelineOperation(\n service: PipelineService,\n operation: PipelineOperation,\n args: PipelineOperationArgs,\n signal?: AbortSignal,\n): Promise<unknown> {\n switch (operation) {\n case 'check':\n return service.check(signal);\n case 'pull':\n case 'push':\n return service.syncSources(operation);\n case 'run':\n return service.submit(args.args ?? []);\n case 'runs':\n return service.runs(args.limit);\n case 'inspect':\n return service.inspect(args.uuid, args.offset ?? 0);\n case 'inspect-import':\n return service.inspectImport(required('importId', args.importId));\n case 'versions':\n return service.versions(required('datasetId', args.datasetId));\n case 'restore':\n return service.restore(\n required('datasetId', args.datasetId),\n required('versionId', args.versionId),\n required('expectedCurrent', args.expectedCurrent),\n );\n case 'terminate':\n return service.terminate(required('uuid', args.uuid));\n case 'upgrade-runtime':\n return service.upgradeRuntime();\n case 'query': {\n const bindings = required('bindings', args.bindings);\n const sql = required('sql', args.sql);\n // A binding naming a dataset version reads immutable history; a file binding\n // reads the current mutable Farseer File. The first binding decides the mode.\n const versioned = (bindings[0] as { datasetId?: unknown } | undefined)?.datasetId !== undefined;\n return versioned\n ? service.queryVersions(bindings as Parameters<PipelineService['queryVersions']>[0], sql, signal)\n : service.query(bindings as Parameters<PipelineService['query']>[0], sql, signal);\n }\n default:\n throw new Error(\n `Unknown operation \"${String(operation)}\". Supported operations: ${PIPELINE_OPERATIONS.join(', ')}`,\n );\n }\n}\n\n/**\n * Attach to a prepared job or create a pipeline from nothing; exactly one of the two.\n * The selection is validated before the client is opened, so a bad call never touches the tenant.\n */\nexport async function runPipelineInit(\n selection: PipelineInitSelection,\n openClient: () => Promise<PipelineClient>,\n paths: PipelinePaths,\n) {\n const { organisation, tenant, jobId, name, workspace, force } = selection;\n if ((jobId === undefined) === (name === undefined))\n throw new Error('Pass either a prepared jobId or a new name, not both and not neither');\n if (name !== undefined) {\n if (workspace !== undefined || force !== undefined)\n throw new Error('workspace and force only apply when attaching to a prepared jobId');\n return createPipeline({ organisation, tenant, name }, await openClient(), paths);\n }\n return initPipelineProfile(\n { organisation, tenant, jobId: jobId as number, workspace, force },\n await openClient(),\n paths,\n );\n}\n"],
5
4
  "mappings": ";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AACA,oBAA+B;AAC/B,kBAAoC;AAQ7B,MAAM,sBAAsB;AAAA,EAC/B;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACJ;AAiCA,SAAS,SAAY,MAAmC,OAAyB;AAC7E,MAAI,UAAU,OAAW,OAAM,IAAI,MAAM,GAAG,IAAI,cAAc;AAC9D,SAAO;AACX;AAGA,eAAsB,qBAClB,SACA,WACA,MACA,QACgB;AAChB,UAAQ,WAAW;AAAA,IACf,KAAK;AACD,aAAO,QAAQ,MAAM,MAAM;AAAA,IAC/B,KAAK;AAAA,IACL,KAAK;AACD,aAAO,QAAQ,YAAY,SAAS;AAAA,IACxC,KAAK;AACD,aAAO,QAAQ,OAAO,KAAK,QAAQ,CAAC,CAAC;AAAA,IACzC,KAAK;AACD,aAAO,QAAQ,KAAK,KAAK,KAAK;AAAA,IAClC,KAAK;AACD,aAAO,QAAQ,QAAQ,K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jE,MAAM,WAAW;AAAA,IACjB;AAAA,EACJ;AACJ;",
6
5
  "names": []
7
6
  }
@@ -1,7 +1,6 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../src/pipeline/query.ts"],
4
- "sourcesContent": ["import { fork } from 'child_process';\nimport * as fs from 'fs';\nimport * as os from 'os';\nimport * as path from 'path';\nimport { downloadQueryFiles } from './queryDownloads';\n\nexport interface QueryLimits {\n memoryMb: number;\n spillMb: number;\n threads: number;\n timeMs: number;\n inputBytes: number;\n rows: number;\n resultBytes: number;\n}\nexport const DEFAULT_LIMITS: Readonly<QueryLimits> = Object.freeze({\n memoryMb: 256,\n spillMb: 256,\n threads: 2,\n timeMs: 30_000,\n inputBytes: 256 * 1024 * 1024,\n rows: 1000,\n resultBytes: 256 * 1024,\n});\nexport interface QueryRequest {\n bindings: { name: string; url?: string; urls?: string[] }[];\n sql: string;\n limits: QueryLimits;\n /** Local test harness only; not an MCP/CLI argument. */\n loopbackTest?: boolean;\n}\nexport interface QueryResult {\n columns: string[];\n rows: unknown[][];\n truncated: boolean;\n complete: boolean;\n downloadedBytes: number;\n resultBytes: number;\n}\n\nexport async function queryFiles(\n request: QueryRequest,\n signal?: AbortSignal,\n download?: (binding: number, file: number, signal: AbortSignal) => Promise<Response>,\n): Promise<QueryResult> {\n if (signal?.aborted) throw new Error('Query cancelled');\n for (const value of Object.values(request.limits))\n if (!Number.isSafeInteger(value) || value <= 0) throw new Error('Invalid query limits');\n if (!request.bindings.length || request.bindings.length > 16 || request.sql.length > 100_000)\n throw new Error('Invalid query size or bindings');\n const directory = fs.mkdtempSync(path.join(os.tmpdir(), 'farseer-pipeline-query-'));\n fs.chmodSync(directory, 0o700);\n const timeout = new AbortController();\n const querySignal = signal ? AbortSignal.any([signal, timeout.signal]) : timeout.signal;\n const cancelled = () => new Error(timeout.signal.aborted ? 'Query time limit exceeded' : 'Query cancelled');\n const timer = setTimeout(() => timeout.abort(), request.limits.timeMs);\n try {\n // The sandbox parent downloads through its authenticated backend connection. Only local\n // files reach the disposable SQL worker; it receives no credential or authenticated URL.\n const prepared = download\n ? await downloadQueryFiles(request, directory, (_address, binding, file) =>\n download(binding, file, querySignal),\n )\n : undefined;\n if (querySignal.aborted) throw cancelled();\n const worker = path.join(__dirname, 'queryWorker.js');\n const child = fork(worker, [], {\n stdio: ['ignore', 'ignore', 'ignore', 'ipc'],\n execArgv: [],\n // A laptop behind a TLS-inspecting proxy needs its extra CA for signed storage reads.\n env: {\n HOME: directory,\n TMPDIR: directory,\n LANG: 'en_US.UTF-8',\n ...(process.env.NODE_EXTRA_CA_CERTS ? { NODE_EXTRA_CA_CERTS: process.env.NODE_EXTRA_CA_CERTS } : {}),\n },\n });\n return await new Promise((resolve, reject) => {\n let outcome: { value?: QueryResult; error?: Error } | undefined;\n const finish = (next: typeof outcome) => {\n if (!outcome) {\n outcome = next;\n child.kill('SIGKILL');\n }\n };\n const cancel = () => finish({ error: cancelled() });\n querySignal.addEventListener('abort', cancel, { once: true });\n child.once('message', (message: any) =>\n finish(message.ok ? { value: message.result } : { error: new Error(message.error) }),\n );\n child.once('error', (error) => finish({ error }));\n child.once('exit', () => {\n querySignal.removeEventListener('abort', cancel);\n if (outcome?.value) resolve(outcome.value);\n else reject(outcome?.error ?? new Error('Query worker exited without a result'));\n });\n child.send({\n ...request,\n ...(prepared ? { bindings: request.bindings.map(({ name }) => ({ name })) } : {}),\n directory,\n prepared,\n });\n if (querySignal.aborted) cancel();\n });\n } catch (error) {\n if (querySignal.aborted) throw cancelled();\n throw error;\n } finally {\n clearTimeout(timer);\n fs.rmSync(directory, { recursive: true, force: true });\n }\n}\n"],
5
4
  "mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,2BAAqB;AACrB,SAAoB;AACpB,SAAoB;AACpB,WAAsB;AACtB,4BAAmC;AAW5B,MAAM,iBAAwC,OAAO,OAAO;AAAA,EAC/D,UAAU;AAAA,EACV,S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,EACzD;AACJ;",
6
5
  "names": []
7
6
  }
@@ -1,7 +1,6 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../src/pipeline/queryDownloads.ts"],
4
- "sourcesContent": ["import * as fs from 'fs';\nimport * as path from 'path';\nimport type { QueryRequest } from './query';\n\nexport interface QueryFiles {\n groups: string[][];\n downloadedBytes: number;\n}\n\n/** Shared byte limits for direct signed downloads and authenticated backend downloads. */\nexport async function downloadQueryFiles(\n request: QueryRequest,\n directory: string,\n download: (address: string, binding: number, file: number) => Promise<Response>,\n): Promise<QueryFiles> {\n let downloadedBytes = 0;\n let fileCount = 0;\n const groups: string[][] = [];\n for (const [index, binding] of request.bindings.entries()) {\n const group: string[] = [];\n groups.push(group);\n const urls = binding.urls ?? (binding.url ? [binding.url] : []);\n if (!urls.length || urls.length > 512) throw new Error('Unsupported version file count');\n for (const [fileIndex, address] of urls.entries()) {\n const response = await download(address, index, fileIndex);\n if (!response.ok || !response.body) {\n await response.body?.cancel();\n throw new Error(`Dataset read failed (${response.status}); retry as a new query`);\n }\n const file = path.join(directory, `${fileCount++}.parquet`);\n const handle = await fs.promises.open(file, 'wx', 0o600);\n try {\n for await (const chunk of response.body as any) {\n downloadedBytes += chunk.byteLength;\n if (downloadedBytes > request.limits.inputBytes)\n throw new Error('Input download byte limit exceeded');\n await handle.write(chunk);\n }\n } finally {\n await handle.close();\n }\n group.push(file);\n }\n }\n return { groups, downloadedBytes };\n}\n"],
5
4
  "mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,SAAoB;AACpB,WAAsB;AAStB,eAAsB,mBAClB,SACA,WACA,UACmB;AACnB,MAAI,kBAAkB;AACtB,MAAI,YAAY;AAChB,QAAM,SAAqB,CAAC;AAC5B,aAAW,CAAC,OAAO,OAAO,KAAK,QAAQ,SAAS,QAAQ,GAAG;AACvD,UAAM,QAAkB,CAAC;AACzB,WAAO,KAAK,KAAK;AACjB,UAAM,OAAO,QAAQ,SAAS,QAAQ,MAAM,CAAC,QAAQ,GAAG,IAAI,CAAC;AAC7D,QAAI,CAAC,KAAK,UAAU,KAAK,SAAS,IAAK,OAAM,IAAI,MAAM,gCAAgC;AACvF,eAAW,CAAC,WAAW,OAAO,KAAK,KAAK,QAAQ,GAAG;AAC/C,YAAM,WAAW,MAAM,SAAS,SAAS,OAAO,SAAS;AACzD,UAAI,CAAC,SAAS,MAAM,CAAC,SAAS,MAAM;AAChC,cAAM,SAAS,MAAM,OAAO;AAC5B,cAAM,IAAI,MAAM,wBAAwB,SAAS,MAAM,yBAAyB;AAAA,MACpF;AACA,YAAM,OAAO,KAAK,KAAK,WAAW,GAAG,WAAW,UAAU;AAC1D,YAAM,SAAS,MAAM,GAAG,SAAS,KAAK,MAAM,MAAM,GAAK;AACvD,UAAI;AACA,yBAAiB,SAAS,SAAS,MAAa;AAC5C,6BAAmB,MAAM;AACzB,cAAI,kBAAkB,QAAQ,OAAO;AACjC,kBAAM,IAAI,MAAM,oCAAoC;AACxD,gBAAM,OAAO,MAAM,KAAK;AAAA,QAC5B;AAAA,MACJ,UAAE;AACE,cAAM,OAAO,MAAM;AAAA,MACvB;AACA,YAAM,KAAK,IAAI;AAAA,IACnB;AAAA,EACJ;AACA,SAAO,EAAE,QAAQ,gBAAgB;AACrC;",
6
5
  "names": []
7
6
  }
@@ -1,7 +1,6 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../src/pipeline/queryWorker.ts"],
4
- "sourcesContent": ["// Runs in a disposable child process. No tenant token or user environment is inherited.\nimport { DuckDBInstance, StatementType } from '@duckdb/node-api';\nimport * as path from 'path';\nimport type { QueryRequest } from './query';\nimport { downloadQueryFiles, type QueryFiles } from './queryDownloads';\n\nconst literal = (s: string) => `'${s.replace(/'/g, \"''\")}'`;\nprocess.once('message', async (request: QueryRequest & { directory: string; prepared?: QueryFiles }) => {\n const { directory, limits } = request;\n try {\n const { groups, downloadedBytes } =\n request.prepared ??\n (await downloadQueryFiles(request, directory, async (address) => {\n const url = new URL(address);\n if (\n url.protocol !== 'https:' &&\n !(request.loopbackTest && url.protocol === 'http:' && url.hostname === '127.0.0.1')\n ) {\n throw new Error('Signed access must use HTTPS');\n }\n // One fixed grant, no credential forwarding, redirects or automatic rebinding.\n return fetch(url, { redirect: 'error' });\n }));\n const files = groups.flat();\n const db = await DuckDBInstance.create(':memory:', {\n memory_limit: `${limits.memoryMb}MB`,\n threads: String(limits.threads),\n temp_directory: path.join(directory, 'spill'),\n max_temp_directory_size: `${limits.spillMb}MB`,\n autoinstall_known_extensions: 'false',\n autoload_known_extensions: 'false',\n allow_unsigned_extensions: 'false',\n });\n const connection = await db.connect();\n await connection.run(`SET allowed_paths = [${files.map(literal).join(',')}]`);\n await connection.run('SET enable_external_access = false');\n for (const [i, binding] of request.bindings.entries()) {\n if (!/^[a-zA-Z_][a-zA-Z0-9_]{0,62}$/.test(binding.name)) throw new Error('Invalid SQL binding name');\n await connection.run(\n `CREATE VIEW \"${binding.name}\" AS SELECT * FROM read_parquet([${groups[i].map(literal).join(',')}])`,\n );\n }\n await connection.run('SET lock_configuration = true');\n const statements = await connection.extractStatements(request.sql);\n if (statements.count !== 1) throw new Error('Exactly one SELECT query is supported');\n const prepared = await statements.prepare(0);\n if (prepared.statementType !== StatementType.SELECT) throw new Error('Only SELECT queries are supported');\n prepared.destroySync();\n // Streaming avoids materializing an unbounded result in JS. Timeout includes downloads.\n const result = await connection.stream(request.sql);\n const rows: unknown[][] = [];\n let bytes = 0;\n let truncated = false;\n outer: for await (const chunk of result.yieldRowsJson()) {\n for (const row of chunk) {\n const size = Buffer.byteLength(JSON.stringify(row));\n if (rows.length >= limits.rows || bytes + size > limits.resultBytes) {\n truncated = true;\n break outer;\n }\n rows.push(row);\n bytes += size;\n }\n }\n process.send?.({\n ok: true,\n result: {\n columns: result.columnNames(),\n rows,\n truncated,\n complete: !truncated,\n downloadedBytes,\n resultBytes: bytes,\n },\n });\n } catch (error) {\n const message = String(error instanceof Error ? error.message : error)\n .replace(/https?:\\/\\/[^\\s'\"<>]+/g, '[signed URL redacted]')\n .split(directory)\n .join('[query temp]');\n process.send?.({ ok: false, error: message.slice(0, 2000) });\n } finally {\n process.disconnect();\n }\n});\n"],
5
4
  "mappings": ";;;;;;;;;;;;;;;;;;;;;;;AACA,sBAA8C;AAC9C,WAAsB;AAEtB,4BAAoD;AAEpD,MAAM,UAAU,CAAC,MAAc,IAAI,EAAE,QAAQ,MAAM,IAAI,CAAC;AACxD,QAAQ,KAAK,WAAW,OAAO,YAAyE;AACpG,QAAM,EAAE,WAAW,OAAO,IAAI;AAC9B,MAAI;AACA,UAAM,EAAE,QAAQ,gBAAgB,IAC5B,QAAQ,YACP,UAAM,0CAAmB,SAAS,WAAW,OAAO,YAAY;AAC7D,YAAM,MAAM,IAAI,IAAI,OAAO;AAC3B,UACI,IAAI,aAAa,YACjB,EAAE,QAAQ,gBAAgB,IAAI,aAAa,WAAW,IAAI,aAAa,cACzE;AACE,cAAM,IAAI,MAAM,8BAA8B;AAAA,MAClD;AAEA,aAAO,MAAM,KAAK,EAAE,UAAU,QAAQ,CAAC;AAAA,IAC3C,CAAC;AACL,UAAM,QAAQ,OAAO,KAAK;AAC1B,UAAM,KAAK,MAAM,+BAAe,OAAO,YAAY;AAAA,MAC/C,cAAc,GAAG,OAAO,QAAQ;AAAA,MAChC,SAAS,OAAO,OAAO,OAAO;AAAA,MAC9B,gBAAgB,KAAK,KAAK,WAAW,OAAO;AAAA,MAC5C,yBAAyB,GAAG,OAAO,OAAO;AAAA,MAC1C,8BAA8B;AAAA,MAC9B,2BAA2B;AAAA,MAC3B,2BAA2B;AAAA,IAC/B,CAAC;AACD,UAAM,aAAa,MAAM,GAAG,QAAQ;AACpC,UAAM,WAAW,IAAI,wBAAwB,MAAM,IAAI,OAAO,EAAE,KAAK,GAAG,CAAC,GAAG;AAC5E,UAAM,WAAW,IAAI,oCAAoC;AACzD,eAAW,CAAC,GAAG,OAAO,KAAK,QAAQ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c;AACxB,YAAQ,OAAO,EAAE,IAAI,OAAO,OAAO,QAAQ,MAAM,GAAG,GAAI,EAAE,CAAC;AAAA,EAC/D,UAAE;AACE,YAAQ,WAAW;AAAA,EACvB;AACJ,CAAC;",
6
5
  "names": []
7
6
  }
@@ -1,7 +1,6 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../src/pipeline/readiness.ts"],
4
- "sourcesContent": ["import { boundedPipelineCall, pipelineRequestSignal } from './requests';\n\n/** Probe one fixed grant without tenant credentials, redirects, or a full download. */\nexport async function probeParquetAccess(address: string): Promise<void> {\n if (new URL(address).protocol !== 'https:') throw new Error('Signed read access must use HTTPS');\n await probeParquetPrefix((signal) =>\n fetch(address, {\n headers: { Range: 'bytes=0-3' },\n redirect: 'error',\n signal,\n }),\n );\n}\n\n/** Read a file's first four bytes, confirm the Parquet magic number, and stop the download there. */\nexport async function probeParquetPrefix(open: (signal: AbortSignal) => Promise<Response>): Promise<void> {\n await boundedPipelineCall(async () => {\n // boundedPipelineCall always sets the request signal.\n const response = await open(pipelineRequestSignal()!);\n if (!response.ok || !response.body) {\n await response.body?.cancel();\n throw new Error(`Read probe failed (${response.status})`);\n }\n const reader = response.body.getReader();\n const prefix: number[] = [];\n try {\n while (prefix.length < 4) {\n const next = await reader.read();\n if (next.done) break;\n prefix.push(...next.value.subarray(0, 4 - prefix.length));\n }\n if (Buffer.from(prefix).toString('ascii') !== 'PAR1') throw new Error('Probed file is not Parquet');\n } finally {\n await reader.cancel(); // Also stops servers that ignore Range, as the API's file route does.\n }\n });\n}\n"],
5
4
  "mappings": ";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,sBAA2D;AAG3D,eAAsB,mBAAmB,SAAgC;AACrE,MAAI,IAAI,IAAI,OAAO,EAAE,aAAa,SAAU,OAAM,IAAI,MAAM,mCAAmC;AAC/F,QAAM;AAAA,IAAmB,CAAC,WACtB,MAAM,SAAS;AAAA,MACX,SAAS,EAAE,OAAO,YAAY;AAAA,MAC9B,UAAU;AAAA,MACV;AAAA,IACJ,CAAC;AAAA,EACL;AACJ;AAGA,eAAsB,mBAAmB,MAAiE;AACtG,YAAM,qCAAoB,YAAY;AAElC,UAAM,WAAW,MAAM,SAAK,uCAAsB,CAAE;AACpD,QAAI,CAAC,SAAS,MAAM,CAAC,SAAS,MAAM;AAChC,YAAM,SAAS,MAAM,OAAO;AAC5B,YAAM,IAAI,MAAM,sBAAsB,SAAS,MAAM,GAAG;AAAA,IAC5D;AACA,UAAM,SAAS,SAAS,KAAK,UAAU;AACvC,UAAM,SAAmB,CAAC;AAC1B,QAAI;AACA,aAAO,OAAO,SAAS,GAAG;AACtB,cAAM,OAAO,MAAM,OAAO,KAAK;AAC/B,YAAI,KAAK,KAAM;AACf,eAAO,KAAK,GAAG,KAAK,MAAM,SAAS,GAAG,IAAI,OAAO,MAAM,CAAC;AAAA,MAC5D;AACA,UAAI,OAAO,KAAK,MAAM,EAAE,SAAS,OAAO,MAAM,OAAQ,OAAM,IAAI,MAAM,4BAA4B;AAAA,IACtG,UAAE;AACE,YAAM,OAAO,OAAO;AAAA,IACxB;AAAA,EACJ,CAAC;AACL;",
6
5
  "names": []
7
6
  }
@@ -1,7 +1,6 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../src/pipeline/reference.ts"],
4
- "sourcesContent": ["import reference from './generated-reference.json';\nimport { PIPELINE_GUIDE, PIPELINE_PRACTICES } from './guide';\nimport { CLI_VERSION } from '../utils/constants';\nimport { inAgentSandbox } from '../utils/agentSandbox';\n\n/** The engine line (major.minor) this CLI's grammar describes. Patch releases keep the grammar. */\nexport const PIPELINE_ENGINE_PROFILE = reference.engineProfile;\n\nexport interface EngineReport {\n /** Engine version the run reported at startup, or null when no start marker was inspected. */\n ran: string | null;\n /** Engine line (major.minor) this CLI's bundled grammar describes. */\n expected: string;\n status: 'match' | 'mismatch' | 'unobserved';\n}\n\n/** Compare the engine line a run actually started on against the one this CLI's grammar describes. */\nexport function engineReport(observations: Record<string, unknown>[]): EngineReport {\n const expected = PIPELINE_ENGINE_PROFILE;\n const started = observations.find((o) => o.event === 'pipeline_started');\n const ran = typeof started?.version === 'string' ? started.version : null;\n if (ran === null) return { ran, expected, status: 'unobserved' };\n const line = ran.split('.').slice(0, 2).join('.');\n return { ran, expected, status: line === expected ? 'match' : 'mismatch' };\n}\n// An agent sandbox's CLI is part of its image and the sandbox cannot reach npm; a conversation keeps\n// its image, so only a new chat (on the deployment's current image) can bring a newer CLI.\nexport const CLI_UPDATE_INSTRUCTION = inAgentSandbox()\n ? \"This chat's CLI comes with its sandbox and cannot be updated here; do not try to install one. Tell the user that a new chat starts with the newest CLI this deployment provides, and that if it is still too old, a Labs admin must update the sandbox image.\"\n : 'Update to the latest compatible CLI: npm install -g farseer-cli@latest. Restart the MCP connection in your AI client after updating. Until the matching CLI is published, install the build supplied by the setup owner.';\n\nexport function pipelineGuide(topic = 'method'): string {\n const header =\n `Pipeline authoring reference: engine ${reference.engineVersion}; CLI ${CLI_VERSION}.\\n` +\n 'This is the bundled reference for the prepared pipeline runtime; the engine was not detected from a job.\\n\\n';\n if (topic === 'method')\n return (\n header +\n PIPELINE_GUIDE +\n '\\nRead topic=\"grammar\" for the generated YAML reference, then request the model names it links to.\\n' +\n CLI_UPDATE_INSTRUCTION\n );\n if (topic === 'practices') return header + PIPELINE_PRACTICES;\n const topics: Record<string, string> = reference.topics;\n if (topic === 'grammar')\n return (\n header +\n reference.notice +\n '\\n\\n' +\n topics.DatasetDefinition +\n '\\nAvailable topics (use their exact names as topic):\\n' +\n Object.keys(topics).join(', ')\n );\n if (!Object.prototype.hasOwnProperty.call(topics, topic))\n throw new Error(`Unknown guide topic \"${topic}\". Read topic=\"grammar\" to list supported model names.`);\n return header + reference.notice + '\\n\\n' + topics[topic];\n}\n"],
5
4
  "mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,iCAAsB;AACtB,mBAAmD;AACnD,uBAA4B;AAC5B,0BAA+B;AAGxB,MAAM,0BAA0B,2BAAAA,QAAU;AAW1C,SAAS,aAAa,cAAuD;AAChF,QAAM,WAAW;AACjB,QAAM,UAAU,aAAa,KAAK,CAAC,MAAM,EAAE,UAAU,kBAAkB;AACvE,QAAM,MAAM,OAAO,SAAS,YAAY,WAAW,QAAQ,UAAU;AACrE,MAAI,QAAQ,KAAM,QAAO,EAAE,KAAK,UAAU,QAAQ,aAAa;AAC/D,QAAM,OAAO,IAAI,MAAM,GAAG,EAAE,MAAM,GAAG,CAAC,EAAE,KAAK,GAAG;AAChD,SAAO,EAAE,KAAK,UAAU,QAAQ,SAAS,WAAW,UAAU,WAAW;AAC7E;AAGO,MAAM,6BAAyB,oCAAe,IAC/C,kQACA;AAEC,SAAS,cAAc,QAAQ,UAAkB;AACpD,QAAM,SACF,wCAAwC,2BAAAA,QAAU,aAAa,SAAS,4BAAW;AAAA;AAAA;AAAA;AAEvF,MAAI,UAAU;AACV,WACI,SACA,8BACA,yGACA;AAER,MAAI,UAAU,YAAa,QAAO,SAAS;AAC3C,QAAM,SAAiC,2BAAAA,QAAU;AACjD,MAAI,UAAU;AACV,WACI,SACA,2BAAAA,QAAU,SACV,SACA,OAAO,oBACP,2DACA,OAAO,KAAK,MAAM,EAAE,KAAK,IAAI;AAErC,MAAI,CAAC,OAAO,UAAU,eAAe,KAAK,QAAQ,KAAK;AACnD,UAAM,IAAI,MAAM,wBAAwB,KAAK,wDAAwD;AACzG,SAAO,SAAS,2BAAAA,QAAU,SAAS,SAAS,OAAO,KAAK;AAC5D;",
6
5
  "names": ["reference"]
7
6
  }
@@ -1,7 +1,6 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../src/pipeline/requests.ts"],
4
- "sourcesContent": ["import { AsyncLocalStorage } from 'async_hooks';\n\nexport const PIPELINE_REQUEST_TIMEOUT_MS = 30_000;\ntype RequestContext = { signal?: AbortSignal; timeoutMs: number; parent?: RequestContext; pause?: () => () => void };\nconst context = new AsyncLocalStorage<RequestContext>();\n\n// Only pipeline operations opt in. SDK helpers and authentication share their caller's\n// cancellation without changing the rest of the CLI's networking policy.\nexport function withPipelineRequests<T>(\n fn: () => Promise<T>,\n signal?: AbortSignal,\n timeoutMs = PIPELINE_REQUEST_TIMEOUT_MS,\n) {\n signal?.throwIfAborted();\n return context.run({ signal, timeoutMs }, fn);\n}\n\nexport function pipelineRequestSignal(existing?: AbortSignal | null): AbortSignal | undefined {\n const signal = context.getStore()?.signal;\n signal?.throwIfAborted();\n return signal && existing ? AbortSignal.any([signal, existing]) : (signal ?? existing ?? undefined);\n}\n\nexport function pipelineFetch(fetcher: typeof fetch = (...args) => fetch(...args)): typeof fetch {\n return (input, init) => fetcher(input, { ...init, signal: pipelineRequestSignal(init?.signal) });\n}\n\n/** Human approval is not network time. Cancellation and the turn's own deadline still apply. */\nexport function pausePipelineDeadlines(): () => void {\n const resume: (() => void)[] = [];\n for (let current = context.getStore(); current; current = current.parent)\n if (current.pause) resume.push(current.pause());\n return () => resume.forEach((fn) => fn());\n}\n\nexport async function boundedPipelineCall<T>(fn: () => Promise<T>): Promise<T> {\n const parent = context.getStore();\n const controller = new AbortController();\n const signal = parent?.signal ? AbortSignal.any([parent.signal, controller.signal]) : controller.signal;\n signal.throwIfAborted();\n const timeoutMs = parent?.timeoutMs ?? PIPELINE_REQUEST_TIMEOUT_MS;\n let remaining = timeoutMs;\n let started = Date.now();\n let pauses = 0;\n let finished = false;\n const startTimer = () =>\n setTimeout(\n () =>\n controller.abort(\n new Error(\n 'Pipeline request timed out. A write may have been accepted; inspect its outcome before retrying.',\n ),\n ),\n remaining,\n );\n let timer = startTimer();\n const pause = () => {\n if (pauses++ === 0) {\n clearTimeout(timer);\n remaining = Math.max(0, remaining - (Date.now() - started));\n }\n let resumed = false;\n return () => {\n if (resumed) return;\n resumed = true;\n if (--pauses === 0 && !finished) {\n started = Date.now();\n timer = startTimer();\n }\n };\n };\n let cancel: () => void = () => undefined;\n try {\n // The signal aborts real HTTP I/O. The race also bounds legacy helpers\n // which swallow errors or wait for a shared authentication refresh.\n return await Promise.race([\n context.run({ signal, timeoutMs, parent, pause }, fn),\n new Promise<never>((_, reject) => {\n cancel = () => reject(signal.reason);\n signal.addEventListener('abort', cancel, { once: true });\n if (signal.aborted) cancel();\n }),\n ]);\n } finally {\n finished = true;\n clearTimeout(timer);\n signal.removeEventListener('abort', cancel);\n }\n}\n\nexport function boundedPipelineClient<T extends object>(client: T): T {\n const synchronous = new Set(['updateAccessToken', 'isTextFile', 'isBinaryFile']);\n return new Proxy(client, {\n get(target, key) {\n const value = Reflect.get(target, key);\n if (typeof value !== 'function') return value;\n const call = (...args: unknown[]) => value.apply(target, args);\n return synchronous.has(String(key))\n ? call\n : (...args: unknown[]) => boundedPipelineCall(() => call(...args));\n },\n });\n}\n"],
5
4
  "mappings": ";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,yBAAkC;AAE3B,MAAM,8BAA8B;AAE3C,MAAM,UAAU,IAAI,qCAAkC;AAI/C,SAAS,qBACZ,IACA,QACA,YAAY,6BACd;AACE,UAAQ,eAAe;AACvB,SAAO,QAAQ,IAAI,EAAE,QAAQ,UAAU,GAAG,EAAE;AAChD;AAEO,SAAS,sBAAsB,UAAwD;AAC1F,QAAM,SAAS,QAAQ,SAAS,GAAG;AACnC,UAAQ,eAAe;AACvB,SAAO,UAAU,WAAW,YAAY,IAAI,CAAC,QAAQ,QAAQ,CAAC,IAAK,UAAU,YAAY;AAC7F;AAEO,SAAS,cAAc,UAAwB,IAAI,SAAS,MAAM,GAAG,IAAI,GAAiB;AAC7F,SAAO,CAAC,OAAO,SAAS,QAAQ,OAAO,EAAE,GAAG,MAAM,QAAQ,sBAAsB,MAAM,MAAM,EAAE,CAAC;AACnG;AAGO,SAAS,yBAAqC;AACjD,QAAM,SAAyB,CAAC;AA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,KAAK,CAAC;AACvD,YAAI,OAAO,QAAS,QAAO;AAAA,MAC/B,CAAC;AAAA,IACL,CAAC;AAAA,EACL,UAAE;AACE,eAAW;AACX,iBAAa,KAAK;AAClB,WAAO,oBAAoB,SAAS,MAAM;AAAA,EAC9C;AACJ;AAEO,SAAS,sBAAwC,QAAc;AAClE,QAAM,cAAc,oBAAI,IAAI,CAAC,qBAAqB,cAAc,cAAc,CAAC;AAC/E,SAAO,IAAI,MAAM,QAAQ;AAAA,IACrB,IAAI,QAAQ,KAAK;AACb,YAAM,QAAQ,QAAQ,IAAI,QAAQ,GAAG;AACrC,UAAI,OAAO,UAAU,WAAY,QAAO;AACxC,YAAM,OAAO,IAAI,SAAoB,MAAM,MAAM,QAAQ,IAAI;AAC7D,aAAO,YAAY,IAAI,OAAO,GAAG,CAAC,IAC5B,OACA,IAAI,SAAoB,oBAAoB,MAAM,KAAK,GAAG,IAAI,CAAC;AAAA,IACzE;AAAA,EACJ,CAAC;AACL;",
6
5
  "names": []
7
6
  }
@@ -1,7 +1,6 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../src/pipeline/runArguments.ts"],
4
- "sourcesContent": ["import type { AppArgument } from '../services/apps';\nimport { PipelineError } from './errors';\n\n/**\n * Run arguments by name. The backend takes a run's arguments by position, in the order the job\n * declares them, and an empty slot keeps that argument's default. A positional value an author\n * meant for a later argument therefore lands silently in the first one, which may be a secret.\n * So the CLI and the MCP tool take `NAME=value` entries only, and this builds the positional list.\n */\nexport function resolveRunArguments(\n declared: readonly AppArgument[],\n entries: readonly string[],\n): { positional: string[]; given: Record<string, string> } {\n const byName = new Map(declared.map((a) => [a.name, a]));\n const values = new Map<string, string>();\n for (const entry of entries) {\n const at = entry.indexOf('=');\n if (at <= 0)\n throw refused(\n declared,\n `Run argument \"${entry}\" must be NAME=value, naming one of this job's arguments (${names(declared)}).`,\n );\n const name = entry.slice(0, at);\n const argument = byName.get(name);\n if (!argument)\n throw refused(declared, `${name} is not an argument of this job. Its arguments are: ${names(declared)}.`);\n if (argument.fixed) throw refused(declared, `${name} is fixed on this job, so a run cannot change it.`);\n if (values.has(name)) throw refused(declared, `${name} is given twice.`);\n const value = entry.slice(at + 1);\n if (value === '')\n throw refused(\n declared,\n `${name} cannot be empty: the backend runs an empty value with the argument's default. Leave ${name} out to keep its default, or give it a value.`,\n );\n values.set(name, value);\n }\n const given: Record<string, string> = {};\n for (const [name, value] of values) given[name] = byName.get(name)?.secret ? '****' : value;\n return { positional: declared.map((a) => values.get(a.name) ?? ''), given };\n}\n\nfunction refused(declared: readonly AppArgument[], message: string): PipelineError {\n return new PipelineError(\n 'refused',\n 'INVALID_ARGUMENTS',\n message,\n `Pass job arguments as NAME=value, naming only this job's arguments (${names(declared)}); nothing was submitted.`,\n );\n}\n\nfunction names(declared: readonly AppArgument[]): string {\n return declared.length ? declared.map((a) => a.name).join(', ') : 'none';\n}\n"],
5
4
  "mappings": ";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AACA,oBAA8B;AAQvB,SAAS,oBACZ,UACA,SACuD;AACvD,QAAM,SAAS,IAAI,IAAI,SAAS,IAAI,CAAC,MAAM,CAAC,EAAE,MAAM,CAAC,CAAC,CAAC;AACvD,QAAM,SAAS,oBAAI,IAAoB;AACvC,aAAW,SAAS,SAAS;AACzB,UAAM,KAAK,MAAM,QAAQ,GAAG;AAC5B,QAAI,MAAM;AACN,YAAM;AAAA,QACF;AAAA,QACA,iBAAiB,KAAK,6DAA6D,MAAM,QAAQ,CAAC;AAAA,MACtG;AACJ,UAAM,OAAO,MAAM,MAAM,GAAG,EAAE;AAC9B,UAAM,WAAW,OAAO,IAAI,IAAI;AAChC,QAAI,CAAC;AACD,YAAM,QAAQ,UAAU,GAAG,IAAI,uDAAuD,MAAM,QAAQ,CAAC,GAAG;AAC5G,QAAI,SAAS,MAAO,OAAM,QAAQ,UAAU,GAAG,IAAI,mDAAmD;AACtG,QAAI,OAAO,IAAI,IAAI,EAAG,OAAM,QAAQ,UAAU,GAAG,IAAI,kBAAkB;AACvE,UAAM,QAAQ,MAAM,MAAM,KAAK,CAAC;AAChC,QAAI,UAAU;AACV,YAAM;AAAA,QACF;AAAA,QACA,GAAG,IAAI,wFAAwF,IAAI;AAAA,MACvG;AACJ,WAAO,IAAI,MAAM,KAAK;AAAA,EAC1B;AACA,QAAM,QAAgC,CAAC;AACvC,aAAW,CAAC,MAAM,KAAK,KAAK,OAAQ,OAAM,IAAI,IAAI,OAAO,IAAI,IAAI,GAAG,SAAS,SAAS;AACtF,SAAO,EAAE,YAAY,SAAS,IAAI,CAAC,MAAM,OAAO,IAAI,EAAE,IAAI,KAAK,EAAE,GAAG,MAAM;AAC9E;AAEA,SAAS,QAAQ,UAAkC,SAAgC;AAC/E,SAAO,IAAI;AAAA,IACP;AAAA,IACA;AAAA,IACA;AAAA,IACA,uEAAuE,MAAM,QAAQ,CAAC;AAAA,EAC1F;AACJ;AAEA,SAAS,MAAM,UAA0C;AACrD,SAAO,SAAS,SAAS,SAAS,IAAI,CAAC,MAAM,EAAE,IAAI,EAAE,KAAK,IAAI,IAAI;AACtE;",
6
5
  "names": []
7
6
  }
@@ -1,7 +1,6 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../src/pipeline/runtime.ts"],
4
- "sourcesContent": ["import reference from './generated-reference.json';\nimport { CLI_UPDATE_INSTRUCTION } from './reference';\nimport { PipelineError } from './errors';\nimport { inAgentSandbox } from '../utils/agentSandbox';\n\n/** The runner image tag this CLI was released in tandem with, as `<repository>:<version>`. */\nexport const PIPELINE_RUNNER_IMAGE: string = reference.runnerImage;\n\nexport interface RuntimeComparison {\n status: 'match' | 'behind' | 'ahead' | 'unversioned' | 'incompatible';\n /** Version parsed from the job's image tag, or null when the tag is not a release version. */\n jobVersion: string | null;\n /** Version this CLI authors for. */\n expected: string;\n nextAction: string;\n}\n\nconst RELEASE_VERSION = /^\\d+\\.\\d+\\.\\d+$/;\n\nfunction split(image: string): { repository: string; tag: string | null } {\n const name = image.slice(image.lastIndexOf('/') + 1);\n if (name.includes('@')) return { repository: name.slice(0, name.indexOf('@')).split(':')[0], tag: null };\n const colon = name.indexOf(':');\n return colon < 0\n ? { repository: name, tag: null }\n : { repository: name.slice(0, colon), tag: name.slice(colon + 1) };\n}\n\n/** Numeric three-part comparison; negative when `a` is older than `b`. */\nexport function compareVersions(a: string, b: string): number {\n const [pa, pb] = [a, b].map((v) => v.split('.').map(Number));\n for (let i = 0; i < 3; i++) if (pa[i] !== pb[i]) return pa[i] < pb[i] ? -1 : 1;\n return 0;\n}\n\n/**\n * The CLI authors for exactly one engine: the one inside the runner image it was\n * released with. It never changes a job's image on its own: a job behind it is moved\n * up only by upgrade-runtime, a CLI behind a job is updated, and nothing moves down.\n */\nexport function compareRuntime(jobImage: string): RuntimeComparison {\n const bundled = split(PIPELINE_RUNNER_IMAGE);\n const expected = bundled.tag ?? '';\n const job = split(jobImage);\n if (job.repository !== bundled.repository)\n return {\n status: 'incompatible',\n jobVersion: null,\n expected,\n nextAction:\n 'Use the existing app tools to inspect, run or maintain this app in its current implementation. Do not change its runner or entrypoint to satisfy pipeline setup. Migration to Simple Pipelines requires an explicit migration request.',\n };\n if (!job.tag || !RELEASE_VERSION.test(job.tag))\n return {\n status: 'unversioned',\n jobVersion: null,\n expected,\n nextAction: `The job's image \"${jobImage}\" is a moving tag or digest, not a released ${bundled.repository} version, so this CLI leaves the image as it is. Each run reports the engine it started on: read engine in inspect.`,\n };\n const order = compareVersions(job.tag, expected);\n if (order === 0) return { status: 'match', jobVersion: job.tag, expected, nextAction: '' };\n if (order < 0)\n return {\n status: 'behind',\n jobVersion: job.tag,\n expected,\n nextAction: `The job runs ${bundled.repository}:${job.tag}; this CLI authors for ${expected}. Run, pull and reads work on the job's image, but push is refused until the job is upgraded: ask the user, then run upgrade-runtime, which moves the job to ${PIPELINE_RUNNER_IMAGE} for everyone on the tenant and for its next scheduled run.${inAgentSandbox() ? '' : ' Or keep the job on its image and author with the CLI release that targets it.'}`,\n };\n return {\n status: 'ahead',\n jobVersion: job.tag,\n expected,\n nextAction: `The job runs ${bundled.repository}:${job.tag}; this CLI authors for ${expected}. Run and push work on the job's image, but this CLI does not describe what the newer engine added. ${CLI_UPDATE_INSTRUCTION}`,\n };\n}\n\n/** Version pinning may upgrade Simple Pipelines, but must never convert another kind of app. */\nexport function assertPipelineRuntime(jobImage: string): RuntimeComparison {\n const runtime = compareRuntime(jobImage);\n if (runtime.status === 'incompatible')\n throw new PipelineError(\n 'refused',\n 'PIPELINE_RUNTIME_UNSUPPORTED',\n `Runner image \"${jobImage || '(tenant default or unknown)'}\" is not a Simple Pipelines runner. The existing app must be preserved.`,\n runtime.nextAction,\n );\n return runtime;\n}\n"],
5
4
  "mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,iCAAsB;AACtB,uBAAuC;AACvC,oBAA8B;AAC9B,0BAA+B;AAGxB,MAAM,wBAAgC,2BAAAA,QAAU;AAWvD,MAAM,kBAAkB;AAExB,SAAS,MAAM,OAA2D;AACtE,QAAM,OAAO,MAAM,MAAM,MAAM,YAAY,GAAG,IAAI,CAAC;AACnD,MAAI,KAAK,SAAS,GAAG,EAAG,QAAO,EAAE,YAAY,KAAK,MAAM,GAAG,KAAK,QAAQ,GAAG,CAAC,EAAE,MAAM,GAAG,EAAE,CAAC,GAAG,KAAK,KAAK;AACvG,QAAM,QAAQ,KAAK,QAAQ,GAAG;AAC9B,SAAO,QAAQ,IACT,EAAE,YAAY,MAAM,KAAK,KAAK,IAC9B,EAAE,YAAY,KAAK,MAAM,GAAG,KAAK,GAAG,KAAK,KAAK,MAAM,QAAQ,CAAC,EAAE;AACzE;AAGO,SAAS,gBAAgB,GAAW,GAAmB;AAC1D,QAAM,CAAC,IAAI,EAAE,IAAI,CAAC,GAAG,CAAC,EAAE,IAAI,CAAC,MAAM,EAAE,MAAM,GAAG,EAAE,IAAI,MA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