@shipfox/api-definitions 7.1.0 → 8.0.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.
- package/.turbo/turbo-build.log +4 -4
- package/CHANGELOG.md +14 -0
- package/dist/config.d.ts +0 -4
- package/dist/config.d.ts.map +1 -1
- package/dist/config.js +1 -14
- package/dist/config.js.map +1 -1
- package/dist/core/index.d.ts +1 -1
- package/dist/core/index.d.ts.map +1 -1
- package/dist/core/index.js.map +1 -1
- package/dist/core/integrations.d.ts +1 -1
- package/dist/core/integrations.d.ts.map +1 -1
- package/dist/core/integrations.js +1 -1
- package/dist/core/integrations.js.map +1 -1
- package/dist/core/parse-definition.d.ts +3 -3
- package/dist/core/parse-definition.d.ts.map +1 -1
- package/dist/core/parse-definition.js.map +1 -1
- package/dist/core/sync-definitions.d.ts +2 -0
- package/dist/core/sync-definitions.d.ts.map +1 -1
- package/dist/core/sync-definitions.js +9 -3
- package/dist/core/sync-definitions.js.map +1 -1
- package/dist/core/validate-definition.d.ts +3 -3
- package/dist/core/validate-definition.d.ts.map +1 -1
- package/dist/core/validate-definition.js +3 -3
- package/dist/core/validate-definition.js.map +1 -1
- package/dist/core/workflow-model/normalize-jobs.d.ts +2 -2
- package/dist/core/workflow-model/normalize-jobs.d.ts.map +1 -1
- package/dist/core/workflow-model/normalize-jobs.js +9 -11
- package/dist/core/workflow-model/normalize-jobs.js.map +1 -1
- package/dist/core/workflow-model/normalize-workflow-document.d.ts +3 -3
- package/dist/core/workflow-model/normalize-workflow-document.d.ts.map +1 -1
- package/dist/core/workflow-model/normalize-workflow-document.js +2 -4
- package/dist/core/workflow-model/normalize-workflow-document.js.map +1 -1
- package/dist/index.d.ts +5 -3
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +3 -2
- package/dist/index.js.map +1 -1
- package/dist/presentation/routes/create-definition.d.ts +4 -2
- package/dist/presentation/routes/create-definition.d.ts.map +1 -1
- package/dist/presentation/routes/create-definition.js +5 -1
- package/dist/presentation/routes/create-definition.js.map +1 -1
- package/dist/presentation/routes/get-definition.d.ts +1 -1
- package/dist/presentation/routes/get-definition.d.ts.map +1 -1
- package/dist/presentation/routes/get-definition.js.map +1 -1
- package/dist/presentation/routes/index.js +2 -2
- package/dist/presentation/routes/index.js.map +1 -1
- package/dist/presentation/routes/list-definitions.d.ts +1 -1
- package/dist/presentation/routes/list-definitions.d.ts.map +1 -1
- package/dist/presentation/routes/list-definitions.js.map +1 -1
- package/dist/presentation/routes/project-access.d.ts +1 -1
- package/dist/presentation/routes/project-access.d.ts.map +1 -1
- package/dist/presentation/routes/project-access.js.map +1 -1
- package/dist/presentation/routes/validate-definition.d.ts +2 -1
- package/dist/presentation/routes/validate-definition.d.ts.map +1 -1
- package/dist/presentation/routes/validate-definition.js +26 -22
- package/dist/presentation/routes/validate-definition.js.map +1 -1
- package/dist/temporal/activities/sync-activities.d.ts +3 -2
- package/dist/temporal/activities/sync-activities.d.ts.map +1 -1
- package/dist/temporal/activities/sync-activities.js +4 -3
- package/dist/temporal/activities/sync-activities.js.map +1 -1
- package/dist/tsconfig.test.tsbuildinfo +1 -1
- package/package.json +4 -4
- package/src/config.ts +1 -19
- package/src/core/index.ts +4 -1
- package/src/core/integrations.ts +1 -1
- package/src/core/parse-definition.test.ts +6 -1
- package/src/core/parse-definition.ts +3 -3
- package/src/core/sync-definitions.test.ts +9 -2
- package/src/core/sync-definitions.ts +13 -6
- package/src/core/validate-definition.test.ts +18 -4
- package/src/core/validate-definition.ts +5 -6
- package/src/core/workflow-model/normalize-jobs.ts +22 -23
- package/src/core/workflow-model/normalize-workflow-document.test.ts +37 -18
- package/src/core/workflow-model/normalize-workflow-document.ts +4 -9
- package/src/db/definitions.test.ts +2 -1
- package/src/db/schema/definitions.test.ts +2 -1
- package/src/index.ts +7 -4
- package/src/presentation/dto/definition.test.ts +2 -1
- package/src/presentation/routes/create-definition.test.ts +10 -3
- package/src/presentation/routes/create-definition.ts +7 -3
- package/src/presentation/routes/get-definition.test.ts +1 -1
- package/src/presentation/routes/get-definition.ts +1 -1
- package/src/presentation/routes/index.test.ts +6 -2
- package/src/presentation/routes/index.ts +2 -2
- package/src/presentation/routes/list-definitions.test.ts +1 -1
- package/src/presentation/routes/list-definitions.ts +1 -1
- package/src/presentation/routes/project-access.ts +1 -1
- package/src/presentation/routes/validate-definition.test.ts +8 -2
- package/src/presentation/routes/validate-definition.ts +27 -22
- package/src/temporal/activities/sync-activities.test.ts +14 -8
- package/src/temporal/activities/sync-activities.ts +10 -2
- package/test/agent-validation-catalog.ts +25 -0
- package/test/factories/definition.ts +2 -1
- package/tsconfig.build.tsbuildinfo +1 -1
package/.turbo/turbo-build.log
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
$ shipfox-swc && shipfox-temporal-bundle dist/temporal/workflows/index.js
|
|
2
|
-
Successfully compiled: 72 files with swc (
|
|
3
|
-
2026-07-
|
|
2
|
+
Successfully compiled: 72 files with swc (648.06ms)
|
|
3
|
+
2026-07-22T14:53:26.245Z [INFO] asset workflow-bundle-2e2f2f4d6c035dc8e198.js 3.18 MiB [emitted] [immutable] (name: main)
|
|
4
4
|
orphan modules 33.5 KiB [orphan] 21 modules
|
|
5
5
|
runtime modules 1.13 KiB 5 modules
|
|
6
6
|
modules by path ../../../node_modules/.pnpm/ 970 KiB 196 modules
|
|
@@ -14,6 +14,6 @@ optional modules 30 bytes [optional]
|
|
|
14
14
|
__temporal_custom_payload_converter (ignored) 15 bytes [optional] [built] [code generated]
|
|
15
15
|
__temporal_custom_failure_converter (ignored) 15 bytes [optional] [built] [code generated]
|
|
16
16
|
../../shared/node/temporal/dist/workflow-error-interceptor.js 1.21 KiB [built] [code generated]
|
|
17
|
-
webpack 5.107.2 compiled successfully in
|
|
18
|
-
2026-07-
|
|
17
|
+
webpack 5.107.2 compiled successfully in 8316 ms
|
|
18
|
+
2026-07-22T14:53:26.264Z [INFO] Workflow bundle created { size: '3.18MB' }
|
|
19
19
|
/home/runner/work/shipfox/shipfox/libs/api/definitions/dist/temporal/workflows/index.js: 3332889 bytes
|
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,19 @@
|
|
|
1
1
|
# @shipfox/api-definitions
|
|
2
2
|
|
|
3
|
+
## 8.0.0
|
|
4
|
+
|
|
5
|
+
### Major Changes
|
|
6
|
+
|
|
7
|
+
- de559bb: Moves Agent validation policy behind a versioned inter-module catalog and injects it into Definitions normalization.
|
|
8
|
+
|
|
9
|
+
### Patch Changes
|
|
10
|
+
|
|
11
|
+
- Updated dependencies [de559bb]
|
|
12
|
+
- Updated dependencies [7f227c6]
|
|
13
|
+
- @shipfox/api-agent-dto@8.0.0
|
|
14
|
+
- @shipfox/api-integration-core-dto@8.0.0
|
|
15
|
+
- @shipfox/api-projects-dto@8.0.0
|
|
16
|
+
|
|
3
17
|
## 7.1.0
|
|
4
18
|
|
|
5
19
|
### Patch Changes
|
package/dist/config.d.ts
CHANGED
|
@@ -1,10 +1,6 @@
|
|
|
1
|
-
import { type HarnessToolDeploymentConfig } from '@shipfox/api-agent-dto';
|
|
2
1
|
export declare const config: Readonly<{
|
|
3
2
|
DEFINITION_DEFAULT_RUNNER_LABEL: string;
|
|
4
|
-
AGENT_PI_ENABLED_TOOL_PACKAGES: string;
|
|
5
|
-
AGENT_PI_WEB_SEARCH_ENABLED: boolean;
|
|
6
3
|
} & import("@shipfox/config").CleanedEnvAccessors>;
|
|
7
4
|
export declare function parseDefinitionDefaultRunnerLabels(value: string): readonly string[];
|
|
8
5
|
export declare const definitionDefaultRunnerLabels: readonly string[];
|
|
9
|
-
export declare const definitionHarnessToolDeploymentConfig: HarnessToolDeploymentConfig;
|
|
10
6
|
//# sourceMappingURL=config.d.ts.map
|
package/dist/config.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../src/config.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../src/config.ts"],"names":[],"mappings":"AAGA,eAAO,MAAM,MAAM;;kDAKjB,CAAC;AAEH,wBAAgB,kCAAkC,CAAC,KAAK,EAAE,MAAM,GAAG,SAAS,MAAM,EAAE,CAiBnF;AAED,eAAO,MAAM,6BAA6B,mBAEzC,CAAC"}
|
package/dist/config.js
CHANGED
|
@@ -1,18 +1,9 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { bool, createConfig, str } from '@shipfox/config';
|
|
1
|
+
import { createConfig, str } from '@shipfox/config';
|
|
3
2
|
import { findInvalidLabels, MAX_RUNNER_LABELS, parseLabelList } from '@shipfox/runner-labels';
|
|
4
3
|
export const config = createConfig({
|
|
5
4
|
DEFINITION_DEFAULT_RUNNER_LABEL: str({
|
|
6
5
|
desc: 'Default runner label(s) applied to workflow jobs that do not declare a "runner" at the job or workflow level. Set it to a comma-separated list, for example ubuntu-latest or ubuntu-latest,node-22. Leave it empty to require every workflow job to declare runner labels explicitly; with no value set, a job without a runner fails definition validation.',
|
|
7
6
|
default: ''
|
|
8
|
-
}),
|
|
9
|
-
AGENT_PI_ENABLED_TOOL_PACKAGES: str({
|
|
10
|
-
desc: 'Comma-separated optional Pi tool packages enabled for this deployment. Defaults to pi-web-access so Pi web access is available. Set it to an empty value to enable only Pi built-in tools. Accepted values: pi-web-access.',
|
|
11
|
-
default: 'pi-web-access'
|
|
12
|
-
}),
|
|
13
|
-
AGENT_PI_WEB_SEARCH_ENABLED: bool({
|
|
14
|
-
desc: 'Enables Pi web search tools when pi-web-access is enabled. Set it to false to disable web_search and get_search_content while keeping fetch_content available.',
|
|
15
|
-
default: true
|
|
16
7
|
})
|
|
17
8
|
});
|
|
18
9
|
export function parseDefinitionDefaultRunnerLabels(value) {
|
|
@@ -27,9 +18,5 @@ export function parseDefinitionDefaultRunnerLabels(value) {
|
|
|
27
18
|
return labels;
|
|
28
19
|
}
|
|
29
20
|
export const definitionDefaultRunnerLabels = parseDefinitionDefaultRunnerLabels(config.DEFINITION_DEFAULT_RUNNER_LABEL);
|
|
30
|
-
export const definitionHarnessToolDeploymentConfig = buildHarnessToolDeploymentConfig({
|
|
31
|
-
piEnabledToolPackages: config.AGENT_PI_ENABLED_TOOL_PACKAGES,
|
|
32
|
-
piWebSearchEnabled: config.AGENT_PI_WEB_SEARCH_ENABLED
|
|
33
|
-
});
|
|
34
21
|
|
|
35
22
|
//# sourceMappingURL=config.js.map
|
package/dist/config.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/config.ts"],"sourcesContent":["import {
|
|
1
|
+
{"version":3,"sources":["../src/config.ts"],"sourcesContent":["import {createConfig, str} from '@shipfox/config';\nimport {findInvalidLabels, MAX_RUNNER_LABELS, parseLabelList} from '@shipfox/runner-labels';\n\nexport const config = createConfig({\n DEFINITION_DEFAULT_RUNNER_LABEL: str({\n desc: 'Default runner label(s) applied to workflow jobs that do not declare a \"runner\" at the job or workflow level. Set it to a comma-separated list, for example ubuntu-latest or ubuntu-latest,node-22. Leave it empty to require every workflow job to declare runner labels explicitly; with no value set, a job without a runner fails definition validation.',\n default: '',\n }),\n});\n\nexport function parseDefinitionDefaultRunnerLabels(value: string): readonly string[] {\n const labels = parseLabelList(value);\n const invalid = findInvalidLabels(labels);\n\n if (invalid.length > 0) {\n throw new Error(\n `DEFINITION_DEFAULT_RUNNER_LABEL contains invalid runner label(s): ${invalid.join(', ')}`,\n );\n }\n\n if (labels.length > MAX_RUNNER_LABELS) {\n throw new Error(\n `DEFINITION_DEFAULT_RUNNER_LABEL contains ${labels.length} runner labels; the maximum is ${MAX_RUNNER_LABELS}`,\n );\n }\n\n return labels;\n}\n\nexport const definitionDefaultRunnerLabels = parseDefinitionDefaultRunnerLabels(\n config.DEFINITION_DEFAULT_RUNNER_LABEL,\n);\n"],"names":["createConfig","str","findInvalidLabels","MAX_RUNNER_LABELS","parseLabelList","config","DEFINITION_DEFAULT_RUNNER_LABEL","desc","default","parseDefinitionDefaultRunnerLabels","value","labels","invalid","length","Error","join","definitionDefaultRunnerLabels"],"mappings":"AAAA,SAAQA,YAAY,EAAEC,GAAG,QAAO,kBAAkB;AAClD,SAAQC,iBAAiB,EAAEC,iBAAiB,EAAEC,cAAc,QAAO,yBAAyB;AAE5F,OAAO,MAAMC,SAASL,aAAa;IACjCM,iCAAiCL,IAAI;QACnCM,MAAM;QACNC,SAAS;IACX;AACF,GAAG;AAEH,OAAO,SAASC,mCAAmCC,KAAa;IAC9D,MAAMC,SAASP,eAAeM;IAC9B,MAAME,UAAUV,kBAAkBS;IAElC,IAAIC,QAAQC,MAAM,GAAG,GAAG;QACtB,MAAM,IAAIC,MACR,CAAC,kEAAkE,EAAEF,QAAQG,IAAI,CAAC,OAAO;IAE7F;IAEA,IAAIJ,OAAOE,MAAM,GAAGV,mBAAmB;QACrC,MAAM,IAAIW,MACR,CAAC,yCAAyC,EAAEH,OAAOE,MAAM,CAAC,+BAA+B,EAAEV,mBAAmB;IAElH;IAEA,OAAOQ;AACT;AAEA,OAAO,MAAMK,gCAAgCP,mCAC3CJ,OAAOC,+BAA+B,EACtC"}
|
package/dist/core/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
export type * from './entities/index.js';
|
|
2
|
-
export { DefinitionParseError, DefinitionSyncPermanentError } from './errors.js';
|
|
2
|
+
export { DefinitionParseError, DefinitionSyncPermanentError, } from './errors.js';
|
|
3
3
|
export { parseDefinition } from './parse-definition.js';
|
|
4
4
|
export { classifySyncFailure, type DiscoverWorkflowFilesParams, discoverWorkflowFiles, type FetchAndParseWorkflowsParams, FILE_FETCH_CONCURRENCY, fetchAndParseWorkflows, MAX_WORKFLOW_FILES, type ParsedWorkflow, type ResolvedSyncSource, resolveSyncSource, type SyncFailureClassification, type SyncSourceContext, UNRESOLVED_SYNC_REF, WORKFLOW_PREFIX, } from './sync-definitions.js';
|
|
5
5
|
export { DEFAULT_RUN_TIMEOUT_MS } from './workflow-model/constants.js';
|
package/dist/core/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/core/index.ts"],"names":[],"mappings":"AAAA,mBAAmB,qBAAqB,CAAC;AACzC,OAAO,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/core/index.ts"],"names":[],"mappings":"AAAA,mBAAmB,qBAAqB,CAAC;AACzC,OAAO,EACL,oBAAoB,EACpB,4BAA4B,GAC7B,MAAM,aAAa,CAAC;AACrB,OAAO,EAAC,eAAe,EAAC,MAAM,uBAAuB,CAAC;AACtD,OAAO,EACL,mBAAmB,EACnB,KAAK,2BAA2B,EAChC,qBAAqB,EACrB,KAAK,4BAA4B,EACjC,sBAAsB,EACtB,sBAAsB,EACtB,kBAAkB,EAClB,KAAK,cAAc,EACnB,KAAK,kBAAkB,EACvB,iBAAiB,EACjB,KAAK,yBAAyB,EAC9B,KAAK,iBAAiB,EACtB,mBAAmB,EACnB,eAAe,GAChB,MAAM,uBAAuB,CAAC;AAC/B,OAAO,EAAC,sBAAsB,EAAC,MAAM,+BAA+B,CAAC;AACrE,OAAO,EAAC,yBAAyB,EAAC,MAAM,2BAA2B,CAAC;AACpE,OAAO,EAAC,oBAAoB,EAAC,MAAM,4CAA4C,CAAC;AAChF,OAAO,EAAC,mBAAmB,EAAC,MAAM,2CAA2C,CAAC"}
|
package/dist/core/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/core/index.ts"],"sourcesContent":["export type * from './entities/index.js';\nexport {DefinitionParseError
|
|
1
|
+
{"version":3,"sources":["../../src/core/index.ts"],"sourcesContent":["export type * from './entities/index.js';\nexport {\n DefinitionParseError,\n DefinitionSyncPermanentError,\n} from './errors.js';\nexport {parseDefinition} from './parse-definition.js';\nexport {\n classifySyncFailure,\n type DiscoverWorkflowFilesParams,\n discoverWorkflowFiles,\n type FetchAndParseWorkflowsParams,\n FILE_FETCH_CONCURRENCY,\n fetchAndParseWorkflows,\n MAX_WORKFLOW_FILES,\n type ParsedWorkflow,\n type ResolvedSyncSource,\n resolveSyncSource,\n type SyncFailureClassification,\n type SyncSourceContext,\n UNRESOLVED_SYNC_REF,\n WORKFLOW_PREFIX,\n} from './sync-definitions.js';\nexport {DEFAULT_RUN_TIMEOUT_MS} from './workflow-model/constants.js';\nexport {normalizeWorkflowDocument} from './workflow-model/index.js';\nexport {DEFAULT_JOB_CHECKOUT} from './workflow-model/normalize-job-checkout.js';\nexport {DEFAULT_JOB_SUCCESS} from './workflow-model/normalize-job-success.js';\n"],"names":["DefinitionParseError","DefinitionSyncPermanentError","parseDefinition","classifySyncFailure","discoverWorkflowFiles","FILE_FETCH_CONCURRENCY","fetchAndParseWorkflows","MAX_WORKFLOW_FILES","resolveSyncSource","UNRESOLVED_SYNC_REF","WORKFLOW_PREFIX","DEFAULT_RUN_TIMEOUT_MS","normalizeWorkflowDocument","DEFAULT_JOB_CHECKOUT","DEFAULT_JOB_SUCCESS"],"mappings":"AACA,SACEA,oBAAoB,EACpBC,4BAA4B,QACvB,cAAc;AACrB,SAAQC,eAAe,QAAO,wBAAwB;AACtD,SACEC,mBAAmB,EAEnBC,qBAAqB,EAErBC,sBAAsB,EACtBC,sBAAsB,EACtBC,kBAAkB,EAGlBC,iBAAiB,EAGjBC,mBAAmB,EACnBC,eAAe,QACV,wBAAwB;AAC/B,SAAQC,sBAAsB,QAAO,gCAAgC;AACrE,SAAQC,yBAAyB,QAAO,4BAA4B;AACpE,SAAQC,oBAAoB,QAAO,6CAA6C;AAChF,SAAQC,mBAAmB,QAAO,4CAA4C"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { type IntegrationsModuleClient, integrationsInterModuleContract } from '@shipfox/api-integration-core-dto';
|
|
1
|
+
import { type IntegrationsModuleClient, integrationsInterModuleContract } from '@shipfox/api-integration-core-dto/inter-module';
|
|
2
2
|
export type DefinitionsSourceControl = {
|
|
3
3
|
resolveRepository: IntegrationsModuleClient['resolveSourceRepository'];
|
|
4
4
|
listFiles: IntegrationsModuleClient['listSourceFiles'];
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"integrations.d.ts","sourceRoot":"","sources":["../../src/core/integrations.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,KAAK,wBAAwB,EAC7B,+BAA+B,EAChC,MAAM,
|
|
1
|
+
{"version":3,"file":"integrations.d.ts","sourceRoot":"","sources":["../../src/core/integrations.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,KAAK,wBAAwB,EAC7B,+BAA+B,EAChC,MAAM,gDAAgD,CAAC;AAExD,MAAM,MAAM,wBAAwB,GAAG;IACrC,iBAAiB,EAAE,wBAAwB,CAAC,yBAAyB,CAAC,CAAC;IACvE,SAAS,EAAE,wBAAwB,CAAC,iBAAiB,CAAC,CAAC;IACvD,SAAS,EAAE,wBAAwB,CAAC,iBAAiB,CAAC,CAAC;CACxD,CAAC;AAEF,wBAAgB,8BAA8B,CAC5C,YAAY,EAAE,wBAAwB,GACrC,wBAAwB,CAM1B;AAED,wBAAsB,gCAAgC,CACpD,YAAY,EAAE,wBAAwB,EACtC,WAAW,EAAE,MAAM,EACnB,mBAAmB,EAAE,MAAM;;;;;;;;;;;;;;;GAY5B;AAED,OAAO,EAAC,+BAA+B,EAAC,CAAC"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { integrationsInterModuleContract } from '@shipfox/api-integration-core-dto';
|
|
1
|
+
import { integrationsInterModuleContract } from '@shipfox/api-integration-core-dto/inter-module';
|
|
2
2
|
export function createDefinitionsSourceControl(integrations) {
|
|
3
3
|
return {
|
|
4
4
|
resolveRepository: integrations.resolveSourceRepository,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/core/integrations.ts"],"sourcesContent":["import {\n type IntegrationsModuleClient,\n integrationsInterModuleContract,\n} from '@shipfox/api-integration-core-dto';\n\nexport type DefinitionsSourceControl = {\n resolveRepository: IntegrationsModuleClient['resolveSourceRepository'];\n listFiles: IntegrationsModuleClient['listSourceFiles'];\n fetchFile: IntegrationsModuleClient['fetchSourceFile'];\n};\n\nexport function createDefinitionsSourceControl(\n integrations: IntegrationsModuleClient,\n): DefinitionsSourceControl {\n return {\n resolveRepository: integrations.resolveSourceRepository,\n listFiles: integrations.listSourceFiles,\n fetchFile: integrations.fetchSourceFile,\n };\n}\n\nexport async function loadIntegrationValidationContext(\n integrations: IntegrationsModuleClient,\n workspaceId: string,\n defaultConnectionId: string,\n) {\n const context = await integrations.getAgentToolsContext({workspaceId, defaultConnectionId});\n return {\n agentToolSelectionCatalogs: new Map(\n context.selectionCatalogs.map(({provider, selectors}) => [provider, {selectors}]),\n ),\n workspaceConnectionSnapshot: new Map(\n context.workspaceConnections.map(({slug, ...connection}) => [slug, connection]),\n ),\n defaultConnectionSlug: context.defaultConnection?.slug,\n };\n}\n\nexport {integrationsInterModuleContract};\n"],"names":["integrationsInterModuleContract","createDefinitionsSourceControl","integrations","resolveRepository","resolveSourceRepository","listFiles","listSourceFiles","fetchFile","fetchSourceFile","loadIntegrationValidationContext","workspaceId","defaultConnectionId","context","getAgentToolsContext","agentToolSelectionCatalogs","Map","selectionCatalogs","map","provider","selectors","workspaceConnectionSnapshot","workspaceConnections","slug","connection","defaultConnectionSlug","defaultConnection"],"mappings":"AAAA,SAEEA,+BAA+B,QAC1B,
|
|
1
|
+
{"version":3,"sources":["../../src/core/integrations.ts"],"sourcesContent":["import {\n type IntegrationsModuleClient,\n integrationsInterModuleContract,\n} from '@shipfox/api-integration-core-dto/inter-module';\n\nexport type DefinitionsSourceControl = {\n resolveRepository: IntegrationsModuleClient['resolveSourceRepository'];\n listFiles: IntegrationsModuleClient['listSourceFiles'];\n fetchFile: IntegrationsModuleClient['fetchSourceFile'];\n};\n\nexport function createDefinitionsSourceControl(\n integrations: IntegrationsModuleClient,\n): DefinitionsSourceControl {\n return {\n resolveRepository: integrations.resolveSourceRepository,\n listFiles: integrations.listSourceFiles,\n fetchFile: integrations.fetchSourceFile,\n };\n}\n\nexport async function loadIntegrationValidationContext(\n integrations: IntegrationsModuleClient,\n workspaceId: string,\n defaultConnectionId: string,\n) {\n const context = await integrations.getAgentToolsContext({workspaceId, defaultConnectionId});\n return {\n agentToolSelectionCatalogs: new Map(\n context.selectionCatalogs.map(({provider, selectors}) => [provider, {selectors}]),\n ),\n workspaceConnectionSnapshot: new Map(\n context.workspaceConnections.map(({slug, ...connection}) => [slug, connection]),\n ),\n defaultConnectionSlug: context.defaultConnection?.slug,\n };\n}\n\nexport {integrationsInterModuleContract};\n"],"names":["integrationsInterModuleContract","createDefinitionsSourceControl","integrations","resolveRepository","resolveSourceRepository","listFiles","listSourceFiles","fetchFile","fetchSourceFile","loadIntegrationValidationContext","workspaceId","defaultConnectionId","context","getAgentToolsContext","agentToolSelectionCatalogs","Map","selectionCatalogs","map","provider","selectors","workspaceConnectionSnapshot","workspaceConnections","slug","connection","defaultConnectionSlug","defaultConnection"],"mappings":"AAAA,SAEEA,+BAA+B,QAC1B,iDAAiD;AAQxD,OAAO,SAASC,+BACdC,YAAsC;IAEtC,OAAO;QACLC,mBAAmBD,aAAaE,uBAAuB;QACvDC,WAAWH,aAAaI,eAAe;QACvCC,WAAWL,aAAaM,eAAe;IACzC;AACF;AAEA,OAAO,eAAeC,iCACpBP,YAAsC,EACtCQ,WAAmB,EACnBC,mBAA2B;IAE3B,MAAMC,UAAU,MAAMV,aAAaW,oBAAoB,CAAC;QAACH;QAAaC;IAAmB;IACzF,OAAO;QACLG,4BAA4B,IAAIC,IAC9BH,QAAQI,iBAAiB,CAACC,GAAG,CAAC,CAAC,EAACC,QAAQ,EAAEC,SAAS,EAAC,GAAK;gBAACD;gBAAU;oBAACC;gBAAS;aAAE;QAElFC,6BAA6B,IAAIL,IAC/BH,QAAQS,oBAAoB,CAACJ,GAAG,CAAC,CAAC,EAACK,IAAI,EAAE,GAAGC,YAAW,GAAK;gBAACD;gBAAMC;aAAW;QAEhFC,uBAAuBZ,QAAQa,iBAAiB,EAAEH;IACpD;AACF;AAEA,SAAQtB,+BAA+B,GAAE"}
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { AgentValidationCatalog } from '@shipfox/api-agent-dto/inter-module';
|
|
2
2
|
import type { IntegrationValidationContext } from './entities/integration-context.js';
|
|
3
3
|
import type { WorkflowDefinitionPayload } from './entities/workflow-definition.js';
|
|
4
|
-
export declare function parseDefinition(yamlString: string, options
|
|
4
|
+
export declare function parseDefinition(yamlString: string, options: {
|
|
5
5
|
defaultRunnerLabels?: readonly string[];
|
|
6
|
-
|
|
6
|
+
agentValidationCatalog: AgentValidationCatalog;
|
|
7
7
|
integrationValidationContext?: IntegrationValidationContext;
|
|
8
8
|
}): WorkflowDefinitionPayload;
|
|
9
9
|
//# sourceMappingURL=parse-definition.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"parse-definition.d.ts","sourceRoot":"","sources":["../../src/core/parse-definition.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAC,
|
|
1
|
+
{"version":3,"file":"parse-definition.d.ts","sourceRoot":"","sources":["../../src/core/parse-definition.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAC,sBAAsB,EAAC,MAAM,qCAAqC,CAAC;AAChF,OAAO,KAAK,EAAC,4BAA4B,EAAC,MAAM,mCAAmC,CAAC;AACpF,OAAO,KAAK,EAAC,yBAAyB,EAAC,MAAM,mCAAmC,CAAC;AAIjF,wBAAgB,eAAe,CAC7B,UAAU,EAAE,MAAM,EAClB,OAAO,EAAE;IACP,mBAAmB,CAAC,EAAE,SAAS,MAAM,EAAE,CAAC;IACxC,sBAAsB,EAAE,sBAAsB,CAAC;IAC/C,4BAA4B,CAAC,EAAE,4BAA4B,CAAC;CAC7D,GACA,yBAAyB,CAc3B"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/core/parse-definition.ts"],"sourcesContent":["import type {
|
|
1
|
+
{"version":3,"sources":["../../src/core/parse-definition.ts"],"sourcesContent":["import type {AgentValidationCatalog} from '@shipfox/api-agent-dto/inter-module';\nimport type {IntegrationValidationContext} from './entities/integration-context.js';\nimport type {WorkflowDefinitionPayload} from './entities/workflow-definition.js';\nimport {DefinitionParseError} from './errors.js';\nimport {validateDefinition} from './validate-definition.js';\n\nexport function parseDefinition(\n yamlString: string,\n options: {\n defaultRunnerLabels?: readonly string[];\n agentValidationCatalog: AgentValidationCatalog;\n integrationValidationContext?: IntegrationValidationContext;\n },\n): WorkflowDefinitionPayload {\n const result = validateDefinition(yamlString, options);\n\n if (!result.valid) {\n throw new DefinitionParseError(\n result.errors[0]?.message ?? 'Invalid definition',\n result.errors,\n );\n }\n\n return {\n ...result.definition,\n sourceSnapshot: {content: yamlString, format: 'yaml'},\n };\n}\n"],"names":["DefinitionParseError","validateDefinition","parseDefinition","yamlString","options","result","valid","errors","message","definition","sourceSnapshot","content","format"],"mappings":"AAGA,SAAQA,oBAAoB,QAAO,cAAc;AACjD,SAAQC,kBAAkB,QAAO,2BAA2B;AAE5D,OAAO,SAASC,gBACdC,UAAkB,EAClBC,OAIC;IAED,MAAMC,SAASJ,mBAAmBE,YAAYC;IAE9C,IAAI,CAACC,OAAOC,KAAK,EAAE;QACjB,MAAM,IAAIN,qBACRK,OAAOE,MAAM,CAAC,EAAE,EAAEC,WAAW,sBAC7BH,OAAOE,MAAM;IAEjB;IAEA,OAAO;QACL,GAAGF,OAAOI,UAAU;QACpBC,gBAAgB;YAACC,SAASR;YAAYS,QAAQ;QAAM;IACtD;AACF"}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import type { AgentValidationCatalog } from '@shipfox/api-agent-dto/inter-module';
|
|
1
2
|
import type { IntegrationValidationContext } from './entities/integration-context.js';
|
|
2
3
|
import type { DefinitionSyncErrorCode } from './entities/sync-state.js';
|
|
3
4
|
import type { WorkflowDefinitionPayload } from './entities/workflow-definition.js';
|
|
@@ -32,6 +33,7 @@ export interface FetchAndParseWorkflowsParams extends SyncSourceContext {
|
|
|
32
33
|
ref: string;
|
|
33
34
|
paths: string[];
|
|
34
35
|
onProgress?: ((path: string) => void) | undefined;
|
|
36
|
+
agentValidationCatalog: AgentValidationCatalog;
|
|
35
37
|
loadIntegrationValidationContext?: (() => Promise<IntegrationValidationContext>) | undefined;
|
|
36
38
|
}
|
|
37
39
|
export declare function fetchAndParseWorkflows(params: FetchAndParseWorkflowsParams): Promise<ParsedWorkflow[]>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sync-definitions.d.ts","sourceRoot":"","sources":["../../src/core/sync-definitions.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"sync-definitions.d.ts","sourceRoot":"","sources":["../../src/core/sync-definitions.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAC,sBAAsB,EAAC,MAAM,qCAAqC,CAAC;AAKhF,OAAO,KAAK,EAAC,4BAA4B,EAAC,MAAM,mCAAmC,CAAC;AACpF,OAAO,KAAK,EAAC,uBAAuB,EAAC,MAAM,0BAA0B,CAAC;AACtE,OAAO,KAAK,EAAC,yBAAyB,EAAC,MAAM,mCAAmC,CAAC;AAGjF,OAAO,KAAK,EAAC,wBAAwB,EAAC,MAAM,mBAAmB,CAAC;AAGhE,eAAO,MAAM,eAAe,wBAAwB,CAAC;AACrD,eAAO,MAAM,kBAAkB,MAAM,CAAC;AACtC,eAAO,MAAM,sBAAsB,IAAI,CAAC;AACxC,eAAO,MAAM,mBAAmB,mBAAmB,CAAC;AAEpD,MAAM,WAAW,iBAAiB;IAChC,WAAW,EAAE,MAAM,CAAC;IACpB,kBAAkB,EAAE,MAAM,CAAC;IAC3B,0BAA0B,EAAE,MAAM,CAAC;IACnC,aAAa,EAAE,wBAAwB,CAAC;CACzC;AAED,MAAM,WAAW,kBAAkB;IACjC,GAAG,EAAE,MAAM,CAAC;CACb;AAED,wBAAsB,iBAAiB,CAAC,MAAM,EAAE,iBAAiB,GAAG,OAAO,CAAC,kBAAkB,CAAC,CAO9F;AAED,MAAM,WAAW,2BAA4B,SAAQ,iBAAiB;IACpE,GAAG,EAAE,MAAM,CAAC;CACb;AAED,wBAAsB,qBAAqB,CACzC,MAAM,EAAE,2BAA2B,GAClC,OAAO,CAAC;IAAC,KAAK,EAAE,MAAM,EAAE,CAAA;CAAC,CAAC,CA2B5B;AAED,MAAM,WAAW,cAAc;IAC7B,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,CAAC;IACb,UAAU,EAAE,yBAAyB,CAAC;IACtC,WAAW,EAAE,MAAM,CAAC;CACrB;AAED,MAAM,WAAW,4BAA6B,SAAQ,iBAAiB;IACrE,GAAG,EAAE,MAAM,CAAC;IACZ,KAAK,EAAE,MAAM,EAAE,CAAC;IAChB,UAAU,CAAC,EAAE,CAAC,CAAC,IAAI,EAAE,MAAM,KAAK,IAAI,CAAC,GAAG,SAAS,CAAC;IAClD,sBAAsB,EAAE,sBAAsB,CAAC;IAC/C,gCAAgC,CAAC,EAAE,CAAC,MAAM,OAAO,CAAC,4BAA4B,CAAC,CAAC,GAAG,SAAS,CAAC;CAC9F;AAED,wBAAsB,sBAAsB,CAC1C,MAAM,EAAE,4BAA4B,GACnC,OAAO,CAAC,cAAc,EAAE,CAAC,CAkD3B;AA6BD,MAAM,WAAW,yBAAyB;IACxC,IAAI,EAAE,uBAAuB,CAAC;IAC9B,OAAO,EAAE,MAAM,CAAC;IAChB,SAAS,EAAE,OAAO,CAAC;CACpB;AAED,wBAAgB,mBAAmB,CAAC,KAAK,EAAE,OAAO,GAAG,yBAAyB,CA+B7E"}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { createHash } from 'node:crypto';
|
|
2
|
-
import {
|
|
2
|
+
import { MAX_REPOSITORY_FILE_BYTES } from '@shipfox/api-integration-core-dto';
|
|
3
|
+
import { integrationsInterModuleContract } from '@shipfox/api-integration-core-dto/inter-module';
|
|
3
4
|
import { isInterModuleKnownError } from '@shipfox/inter-module';
|
|
4
5
|
import { boundedMap } from '@shipfox/node-module';
|
|
5
6
|
import { DefinitionParseError, DefinitionSyncPermanentError } from './errors.js';
|
|
@@ -55,7 +56,8 @@ export async function fetchAndParseWorkflows(params) {
|
|
|
55
56
|
return {
|
|
56
57
|
...parseWorkflowSnapshot({
|
|
57
58
|
path: snapshot.path,
|
|
58
|
-
content: snapshot.content
|
|
59
|
+
content: snapshot.content,
|
|
60
|
+
agentValidationCatalog: params.agentValidationCatalog
|
|
59
61
|
}),
|
|
60
62
|
rawContent: snapshot.content
|
|
61
63
|
};
|
|
@@ -69,12 +71,16 @@ export async function fetchAndParseWorkflows(params) {
|
|
|
69
71
|
return parsed.map((entry)=>parseWorkflowSnapshot({
|
|
70
72
|
path: entry.path,
|
|
71
73
|
content: entry.rawContent,
|
|
74
|
+
agentValidationCatalog: params.agentValidationCatalog,
|
|
72
75
|
integrationValidationContext
|
|
73
76
|
}));
|
|
74
77
|
}
|
|
75
78
|
function parseWorkflowSnapshot(params) {
|
|
76
79
|
try {
|
|
77
|
-
const definition = params.integrationValidationContext === undefined ? parseDefinition(params.content
|
|
80
|
+
const definition = params.integrationValidationContext === undefined ? parseDefinition(params.content, {
|
|
81
|
+
agentValidationCatalog: params.agentValidationCatalog
|
|
82
|
+
}) : parseDefinition(params.content, {
|
|
83
|
+
agentValidationCatalog: params.agentValidationCatalog,
|
|
78
84
|
integrationValidationContext: params.integrationValidationContext
|
|
79
85
|
});
|
|
80
86
|
const contentHash = sha256Hex(params.content);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/core/sync-definitions.ts"],"sourcesContent":["import {createHash} from 'node:crypto';\nimport {\n integrationsInterModuleContract,\n MAX_REPOSITORY_FILE_BYTES,\n} from '@shipfox/api-integration-core-dto';\nimport {isInterModuleKnownError} from '@shipfox/inter-module';\nimport {boundedMap} from '@shipfox/node-module';\nimport type {IntegrationValidationContext} from './entities/integration-context.js';\nimport type {DefinitionSyncErrorCode} from './entities/sync-state.js';\nimport type {WorkflowDefinitionPayload} from './entities/workflow-definition.js';\nimport {DefinitionParseError, DefinitionSyncPermanentError} from './errors.js';\nimport {hasAgentStepIntegrations} from './has-agent-step-integrations.js';\nimport type {DefinitionsSourceControl} from './integrations.js';\nimport {parseDefinition} from './parse-definition.js';\n\nexport const WORKFLOW_PREFIX = '.shipfox/workflows/';\nexport const MAX_WORKFLOW_FILES = 100;\nexport const FILE_FETCH_CONCURRENCY = 4;\nexport const UNRESOLVED_SYNC_REF = '__unresolved__';\n\nexport interface SyncSourceContext {\n workspaceId: string;\n sourceConnectionId: string;\n sourceExternalRepositoryId: string;\n sourceControl: DefinitionsSourceControl;\n}\n\nexport interface ResolvedSyncSource {\n ref: string;\n}\n\nexport async function resolveSyncSource(params: SyncSourceContext): Promise<ResolvedSyncSource> {\n const source = await params.sourceControl.resolveRepository({\n workspaceId: params.workspaceId,\n connectionId: params.sourceConnectionId,\n externalRepositoryId: params.sourceExternalRepositoryId,\n });\n return {ref: source.repository.defaultBranch};\n}\n\nexport interface DiscoverWorkflowFilesParams extends SyncSourceContext {\n ref: string;\n}\n\nexport async function discoverWorkflowFiles(\n params: DiscoverWorkflowFilesParams,\n): Promise<{paths: string[]}> {\n const page = await params.sourceControl.listFiles({\n workspaceId: params.workspaceId,\n connectionId: params.sourceConnectionId,\n externalRepositoryId: params.sourceExternalRepositoryId,\n ref: params.ref,\n prefix: WORKFLOW_PREFIX,\n limit: MAX_WORKFLOW_FILES,\n });\n if (page.nextCursor) {\n throw new DefinitionSyncPermanentError(\n 'too-many-files',\n `More than ${MAX_WORKFLOW_FILES} workflow files were found`,\n );\n }\n\n const paths = page.files\n .filter((file) => file.path.endsWith('.yml') || file.path.endsWith('.yaml'))\n .map((file) => file.path);\n if (paths.length === 0) {\n throw new DefinitionSyncPermanentError(\n 'no-workflow-files',\n `No workflow files were found under ${WORKFLOW_PREFIX}`,\n );\n }\n\n return {paths};\n}\n\nexport interface ParsedWorkflow {\n path: string;\n name: string;\n definition: WorkflowDefinitionPayload;\n contentHash: string;\n}\n\nexport interface FetchAndParseWorkflowsParams extends SyncSourceContext {\n ref: string;\n paths: string[];\n onProgress?: ((path: string) => void) | undefined;\n loadIntegrationValidationContext?: (() => Promise<IntegrationValidationContext>) | undefined;\n}\n\nexport async function fetchAndParseWorkflows(\n params: FetchAndParseWorkflowsParams,\n): Promise<ParsedWorkflow[]> {\n const parsed = await boundedMap(\n params.paths,\n FILE_FETCH_CONCURRENCY,\n async (path) => {\n params.onProgress?.(path);\n\n const snapshot = await params.sourceControl.fetchFile({\n workspaceId: params.workspaceId,\n connectionId: params.sourceConnectionId,\n externalRepositoryId: params.sourceExternalRepositoryId,\n ref: params.ref,\n path,\n });\n\n if (Buffer.byteLength(snapshot.content, 'utf8') > MAX_REPOSITORY_FILE_BYTES) {\n throw new DefinitionSyncPermanentError(\n 'content-too-large',\n `Workflow file is larger than ${MAX_REPOSITORY_FILE_BYTES} bytes: ${snapshot.path}`,\n );\n }\n\n return {\n ...parseWorkflowSnapshot({path: snapshot.path, content: snapshot.content}),\n rawContent: snapshot.content,\n };\n },\n {stopOnError: true},\n );\n\n if (\n !params.loadIntegrationValidationContext ||\n !parsed.some((entry) => hasAgentStepIntegrations(entry.definition.document))\n ) {\n return parsed.map(({rawContent: _rawContent, ...entry}) => entry);\n }\n\n const integrationValidationContext = await params.loadIntegrationValidationContext();\n return parsed.map((entry) =>\n parseWorkflowSnapshot({\n path: entry.path,\n content: entry.rawContent,\n integrationValidationContext,\n }),\n );\n}\n\nfunction parseWorkflowSnapshot(params: {\n path: string;\n content: string;\n integrationValidationContext?: IntegrationValidationContext | undefined;\n}): ParsedWorkflow {\n try {\n const definition =\n params.integrationValidationContext === undefined\n ? parseDefinition(params.content)\n : parseDefinition(params.content, {\n integrationValidationContext: params.integrationValidationContext,\n });\n const contentHash = sha256Hex(params.content);\n return {path: params.path, name: definition.document.name, definition, contentHash};\n } catch (error) {\n if (error instanceof DefinitionParseError) {\n throw new DefinitionSyncPermanentError(\n 'invalid-definition',\n `Invalid workflow definition at ${params.path}: ${error.message}`,\n );\n }\n throw error;\n }\n}\n\nexport interface SyncFailureClassification {\n code: DefinitionSyncErrorCode;\n message: string;\n retryable: boolean;\n}\n\nexport function classifySyncFailure(error: unknown): SyncFailureClassification {\n if (error instanceof DefinitionSyncPermanentError) {\n return {code: error.code, message: error.message, retryable: false};\n }\n const methods = [\n integrationsInterModuleContract.methods.resolveSourceRepository,\n integrationsInterModuleContract.methods.listSourceFiles,\n integrationsInterModuleContract.methods.fetchSourceFile,\n ] as const;\n for (const method of methods) {\n if (!isInterModuleKnownError(method, error)) continue;\n if (\n error.code === 'connection-not-found' ||\n error.code === 'connection-inactive' ||\n error.code === 'connection-workspace-mismatch'\n ) {\n return {code: 'connection-unavailable', message: error.message, retryable: false};\n }\n if (error.code === 'provider-failure') {\n return {\n code: providerErrorCode(error.details.reason),\n message: error.message,\n retryable: isProviderReasonRetryable(error.details.reason),\n };\n }\n }\n return {\n code: 'unknown',\n message: error instanceof Error ? error.message : String(error),\n retryable: true,\n };\n}\n\nfunction isProviderReasonRetryable(reason: string): boolean {\n return reason === 'rate-limited' || reason === 'timeout' || reason === 'provider-unavailable';\n}\n\nfunction providerErrorCode(reason: string): DefinitionSyncErrorCode {\n if (reason === 'repository-not-found') return 'provider-repository-not-found';\n if (reason === 'file-not-found') return 'provider-file-not-found';\n if (reason === 'access-denied') return 'provider-access-denied';\n if (reason === 'rate-limited') return 'provider-rate-limited';\n if (reason === 'timeout') return 'provider-timeout';\n if (reason === 'provider-unavailable') return 'provider-unavailable';\n if (reason === 'malformed-provider-response') return 'provider-malformed-response';\n if (reason === 'content-too-large') return 'content-too-large';\n if (reason === 'too-many-files') return 'too-many-files';\n return 'unknown';\n}\n\nfunction sha256Hex(content: string): string {\n return createHash('sha256').update(content, 'utf8').digest('hex');\n}\n"],"names":["createHash","integrationsInterModuleContract","MAX_REPOSITORY_FILE_BYTES","isInterModuleKnownError","boundedMap","DefinitionParseError","DefinitionSyncPermanentError","hasAgentStepIntegrations","parseDefinition","WORKFLOW_PREFIX","MAX_WORKFLOW_FILES","FILE_FETCH_CONCURRENCY","UNRESOLVED_SYNC_REF","resolveSyncSource","params","source","sourceControl","resolveRepository","workspaceId","connectionId","sourceConnectionId","externalRepositoryId","sourceExternalRepositoryId","ref","repository","defaultBranch","discoverWorkflowFiles","page","listFiles","prefix","limit","nextCursor","paths","files","filter","file","path","endsWith","map","length","fetchAndParseWorkflows","parsed","onProgress","snapshot","fetchFile","Buffer","byteLength","content","parseWorkflowSnapshot","rawContent","stopOnError","loadIntegrationValidationContext","some","entry","definition","document","_rawContent","integrationValidationContext","undefined","contentHash","sha256Hex","name","error","message","classifySyncFailure","code","retryable","methods","resolveSourceRepository","listSourceFiles","fetchSourceFile","method","providerErrorCode","details","reason","isProviderReasonRetryable","Error","String","update","digest"],"mappings":"AAAA,SAAQA,UAAU,QAAO,cAAc;AACvC,SACEC,+BAA+B,EAC/BC,yBAAyB,QACpB,oCAAoC;AAC3C,SAAQC,uBAAuB,QAAO,wBAAwB;AAC9D,SAAQC,UAAU,QAAO,uBAAuB;AAIhD,SAAQC,oBAAoB,EAAEC,4BAA4B,QAAO,cAAc;AAC/E,SAAQC,wBAAwB,QAAO,mCAAmC;AAE1E,SAAQC,eAAe,QAAO,wBAAwB;AAEtD,OAAO,MAAMC,kBAAkB,sBAAsB;AACrD,OAAO,MAAMC,qBAAqB,IAAI;AACtC,OAAO,MAAMC,yBAAyB,EAAE;AACxC,OAAO,MAAMC,sBAAsB,iBAAiB;AAapD,OAAO,eAAeC,kBAAkBC,MAAyB;IAC/D,MAAMC,SAAS,MAAMD,OAAOE,aAAa,CAACC,iBAAiB,CAAC;QAC1DC,aAAaJ,OAAOI,WAAW;QAC/BC,cAAcL,OAAOM,kBAAkB;QACvCC,sBAAsBP,OAAOQ,0BAA0B;IACzD;IACA,OAAO;QAACC,KAAKR,OAAOS,UAAU,CAACC,aAAa;IAAA;AAC9C;AAMA,OA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../src/core/sync-definitions.ts"],"sourcesContent":["import {createHash} from 'node:crypto';\nimport type {AgentValidationCatalog} from '@shipfox/api-agent-dto/inter-module';\nimport {MAX_REPOSITORY_FILE_BYTES} from '@shipfox/api-integration-core-dto';\nimport {integrationsInterModuleContract} from '@shipfox/api-integration-core-dto/inter-module';\nimport {isInterModuleKnownError} from '@shipfox/inter-module';\nimport {boundedMap} from '@shipfox/node-module';\nimport type {IntegrationValidationContext} from './entities/integration-context.js';\nimport type {DefinitionSyncErrorCode} from './entities/sync-state.js';\nimport type {WorkflowDefinitionPayload} from './entities/workflow-definition.js';\nimport {DefinitionParseError, DefinitionSyncPermanentError} from './errors.js';\nimport {hasAgentStepIntegrations} from './has-agent-step-integrations.js';\nimport type {DefinitionsSourceControl} from './integrations.js';\nimport {parseDefinition} from './parse-definition.js';\n\nexport const WORKFLOW_PREFIX = '.shipfox/workflows/';\nexport const MAX_WORKFLOW_FILES = 100;\nexport const FILE_FETCH_CONCURRENCY = 4;\nexport const UNRESOLVED_SYNC_REF = '__unresolved__';\n\nexport interface SyncSourceContext {\n workspaceId: string;\n sourceConnectionId: string;\n sourceExternalRepositoryId: string;\n sourceControl: DefinitionsSourceControl;\n}\n\nexport interface ResolvedSyncSource {\n ref: string;\n}\n\nexport async function resolveSyncSource(params: SyncSourceContext): Promise<ResolvedSyncSource> {\n const source = await params.sourceControl.resolveRepository({\n workspaceId: params.workspaceId,\n connectionId: params.sourceConnectionId,\n externalRepositoryId: params.sourceExternalRepositoryId,\n });\n return {ref: source.repository.defaultBranch};\n}\n\nexport interface DiscoverWorkflowFilesParams extends SyncSourceContext {\n ref: string;\n}\n\nexport async function discoverWorkflowFiles(\n params: DiscoverWorkflowFilesParams,\n): Promise<{paths: string[]}> {\n const page = await params.sourceControl.listFiles({\n workspaceId: params.workspaceId,\n connectionId: params.sourceConnectionId,\n externalRepositoryId: params.sourceExternalRepositoryId,\n ref: params.ref,\n prefix: WORKFLOW_PREFIX,\n limit: MAX_WORKFLOW_FILES,\n });\n if (page.nextCursor) {\n throw new DefinitionSyncPermanentError(\n 'too-many-files',\n `More than ${MAX_WORKFLOW_FILES} workflow files were found`,\n );\n }\n\n const paths = page.files\n .filter((file) => file.path.endsWith('.yml') || file.path.endsWith('.yaml'))\n .map((file) => file.path);\n if (paths.length === 0) {\n throw new DefinitionSyncPermanentError(\n 'no-workflow-files',\n `No workflow files were found under ${WORKFLOW_PREFIX}`,\n );\n }\n\n return {paths};\n}\n\nexport interface ParsedWorkflow {\n path: string;\n name: string;\n definition: WorkflowDefinitionPayload;\n contentHash: string;\n}\n\nexport interface FetchAndParseWorkflowsParams extends SyncSourceContext {\n ref: string;\n paths: string[];\n onProgress?: ((path: string) => void) | undefined;\n agentValidationCatalog: AgentValidationCatalog;\n loadIntegrationValidationContext?: (() => Promise<IntegrationValidationContext>) | undefined;\n}\n\nexport async function fetchAndParseWorkflows(\n params: FetchAndParseWorkflowsParams,\n): Promise<ParsedWorkflow[]> {\n const parsed = await boundedMap(\n params.paths,\n FILE_FETCH_CONCURRENCY,\n async (path) => {\n params.onProgress?.(path);\n\n const snapshot = await params.sourceControl.fetchFile({\n workspaceId: params.workspaceId,\n connectionId: params.sourceConnectionId,\n externalRepositoryId: params.sourceExternalRepositoryId,\n ref: params.ref,\n path,\n });\n\n if (Buffer.byteLength(snapshot.content, 'utf8') > MAX_REPOSITORY_FILE_BYTES) {\n throw new DefinitionSyncPermanentError(\n 'content-too-large',\n `Workflow file is larger than ${MAX_REPOSITORY_FILE_BYTES} bytes: ${snapshot.path}`,\n );\n }\n\n return {\n ...parseWorkflowSnapshot({\n path: snapshot.path,\n content: snapshot.content,\n agentValidationCatalog: params.agentValidationCatalog,\n }),\n rawContent: snapshot.content,\n };\n },\n {stopOnError: true},\n );\n\n if (\n !params.loadIntegrationValidationContext ||\n !parsed.some((entry) => hasAgentStepIntegrations(entry.definition.document))\n ) {\n return parsed.map(({rawContent: _rawContent, ...entry}) => entry);\n }\n\n const integrationValidationContext = await params.loadIntegrationValidationContext();\n return parsed.map((entry) =>\n parseWorkflowSnapshot({\n path: entry.path,\n content: entry.rawContent,\n agentValidationCatalog: params.agentValidationCatalog,\n integrationValidationContext,\n }),\n );\n}\n\nfunction parseWorkflowSnapshot(params: {\n path: string;\n content: string;\n integrationValidationContext?: IntegrationValidationContext | undefined;\n agentValidationCatalog: AgentValidationCatalog;\n}): ParsedWorkflow {\n try {\n const definition =\n params.integrationValidationContext === undefined\n ? parseDefinition(params.content, {agentValidationCatalog: params.agentValidationCatalog})\n : parseDefinition(params.content, {\n agentValidationCatalog: params.agentValidationCatalog,\n integrationValidationContext: params.integrationValidationContext,\n });\n const contentHash = sha256Hex(params.content);\n return {path: params.path, name: definition.document.name, definition, contentHash};\n } catch (error) {\n if (error instanceof DefinitionParseError) {\n throw new DefinitionSyncPermanentError(\n 'invalid-definition',\n `Invalid workflow definition at ${params.path}: ${error.message}`,\n );\n }\n throw error;\n }\n}\n\nexport interface SyncFailureClassification {\n code: DefinitionSyncErrorCode;\n message: string;\n retryable: boolean;\n}\n\nexport function classifySyncFailure(error: unknown): SyncFailureClassification {\n if (error instanceof DefinitionSyncPermanentError) {\n return {code: error.code, message: error.message, retryable: false};\n }\n const methods = [\n integrationsInterModuleContract.methods.resolveSourceRepository,\n integrationsInterModuleContract.methods.listSourceFiles,\n integrationsInterModuleContract.methods.fetchSourceFile,\n ] as const;\n for (const method of methods) {\n if (!isInterModuleKnownError(method, error)) continue;\n if (\n error.code === 'connection-not-found' ||\n error.code === 'connection-inactive' ||\n error.code === 'connection-workspace-mismatch'\n ) {\n return {code: 'connection-unavailable', message: error.message, retryable: false};\n }\n if (error.code === 'provider-failure') {\n return {\n code: providerErrorCode(error.details.reason),\n message: error.message,\n retryable: isProviderReasonRetryable(error.details.reason),\n };\n }\n }\n return {\n code: 'unknown',\n message: error instanceof Error ? error.message : String(error),\n retryable: true,\n };\n}\n\nfunction isProviderReasonRetryable(reason: string): boolean {\n return reason === 'rate-limited' || reason === 'timeout' || reason === 'provider-unavailable';\n}\n\nfunction providerErrorCode(reason: string): DefinitionSyncErrorCode {\n if (reason === 'repository-not-found') return 'provider-repository-not-found';\n if (reason === 'file-not-found') return 'provider-file-not-found';\n if (reason === 'access-denied') return 'provider-access-denied';\n if (reason === 'rate-limited') return 'provider-rate-limited';\n if (reason === 'timeout') return 'provider-timeout';\n if (reason === 'provider-unavailable') return 'provider-unavailable';\n if (reason === 'malformed-provider-response') return 'provider-malformed-response';\n if (reason === 'content-too-large') return 'content-too-large';\n if (reason === 'too-many-files') return 'too-many-files';\n return 'unknown';\n}\n\nfunction sha256Hex(content: string): string {\n return createHash('sha256').update(content, 'utf8').digest('hex');\n}\n"],"names":["createHash","MAX_REPOSITORY_FILE_BYTES","integrationsInterModuleContract","isInterModuleKnownError","boundedMap","DefinitionParseError","DefinitionSyncPermanentError","hasAgentStepIntegrations","parseDefinition","WORKFLOW_PREFIX","MAX_WORKFLOW_FILES","FILE_FETCH_CONCURRENCY","UNRESOLVED_SYNC_REF","resolveSyncSource","params","source","sourceControl","resolveRepository","workspaceId","connectionId","sourceConnectionId","externalRepositoryId","sourceExternalRepositoryId","ref","repository","defaultBranch","discoverWorkflowFiles","page","listFiles","prefix","limit","nextCursor","paths","files","filter","file","path","endsWith","map","length","fetchAndParseWorkflows","parsed","onProgress","snapshot","fetchFile","Buffer","byteLength","content","parseWorkflowSnapshot","agentValidationCatalog","rawContent","stopOnError","loadIntegrationValidationContext","some","entry","definition","document","_rawContent","integrationValidationContext","undefined","contentHash","sha256Hex","name","error","message","classifySyncFailure","code","retryable","methods","resolveSourceRepository","listSourceFiles","fetchSourceFile","method","providerErrorCode","details","reason","isProviderReasonRetryable","Error","String","update","digest"],"mappings":"AAAA,SAAQA,UAAU,QAAO,cAAc;AAEvC,SAAQC,yBAAyB,QAAO,oCAAoC;AAC5E,SAAQC,+BAA+B,QAAO,iDAAiD;AAC/F,SAAQC,uBAAuB,QAAO,wBAAwB;AAC9D,SAAQC,UAAU,QAAO,uBAA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AAM;YAC3D;QACF;IACF;IACA,OAAO;QACLT,MAAM;QACNF,SAASD,iBAAiBc,QAAQd,MAAMC,OAAO,GAAGc,OAAOf;QACzDI,WAAW;IACb;AACF;AAEA,SAASS,0BAA0BD,MAAc;IAC/C,OAAOA,WAAW,kBAAkBA,WAAW,aAAaA,WAAW;AACzE;AAEA,SAASF,kBAAkBE,MAAc;IACvC,IAAIA,WAAW,wBAAwB,OAAO;IAC9C,IAAIA,WAAW,kBAAkB,OAAO;IACxC,IAAIA,WAAW,iBAAiB,OAAO;IACvC,IAAIA,WAAW,gBAAgB,OAAO;IACtC,IAAIA,WAAW,WAAW,OAAO;IACjC,IAAIA,WAAW,wBAAwB,OAAO;IAC9C,IAAIA,WAAW,+BAA+B,OAAO;IACrD,IAAIA,WAAW,qBAAqB,OAAO;IAC3C,IAAIA,WAAW,kBAAkB,OAAO;IACxC,OAAO;AACT;AAEA,SAASd,UAAUd,OAAe;IAChC,OAAO/C,WAAW,UAAU+E,MAAM,CAAChC,SAAS,QAAQiC,MAAM,CAAC;AAC7D"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { AgentValidationCatalog } from '@shipfox/api-agent-dto/inter-module';
|
|
2
2
|
import type { IntegrationValidationContext } from './entities/integration-context.js';
|
|
3
3
|
import type { WorkflowDefinitionPayload } from './entities/workflow-definition.js';
|
|
4
4
|
export type ValidationError = {
|
|
@@ -12,9 +12,9 @@ export type ValidationResult = {
|
|
|
12
12
|
valid: false;
|
|
13
13
|
errors: ValidationError[];
|
|
14
14
|
};
|
|
15
|
-
export declare function validateDefinition(yamlContent: string, options
|
|
15
|
+
export declare function validateDefinition(yamlContent: string, options: {
|
|
16
16
|
defaultRunnerLabels?: readonly string[];
|
|
17
|
-
|
|
17
|
+
agentValidationCatalog: AgentValidationCatalog;
|
|
18
18
|
integrationValidationContext?: IntegrationValidationContext;
|
|
19
19
|
}): ValidationResult;
|
|
20
20
|
//# sourceMappingURL=validate-definition.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"validate-definition.d.ts","sourceRoot":"","sources":["../../src/core/validate-definition.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAC,
|
|
1
|
+
{"version":3,"file":"validate-definition.d.ts","sourceRoot":"","sources":["../../src/core/validate-definition.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAC,sBAAsB,EAAC,MAAM,qCAAqC,CAAC;AAGhF,OAAO,KAAK,EAAC,4BAA4B,EAAC,MAAM,mCAAmC,CAAC;AACpF,OAAO,KAAK,EAAC,yBAAyB,EAAC,MAAM,mCAAmC,CAAC;AAIjF,MAAM,MAAM,eAAe,GAAG;IAAC,OAAO,EAAE,MAAM,CAAC;IAAC,IAAI,CAAC,EAAE,MAAM,GAAG,SAAS,CAAA;CAAC,CAAC;AAE3E,MAAM,MAAM,gBAAgB,GACxB;IAAC,KAAK,EAAE,IAAI,CAAC;IAAC,UAAU,EAAE,yBAAyB,CAAA;CAAC,GACpD;IAAC,KAAK,EAAE,KAAK,CAAC;IAAC,MAAM,EAAE,eAAe,EAAE,CAAA;CAAC,CAAC;AAE9C,wBAAgB,kBAAkB,CAChC,WAAW,EAAE,MAAM,EACnB,OAAO,EAAE;IACP,mBAAmB,CAAC,EAAE,SAAS,MAAM,EAAE,CAAC;IACxC,sBAAsB,EAAE,sBAAsB,CAAC;IAC/C,4BAA4B,CAAC,EAAE,4BAA4B,CAAC;CAC7D,GACA,gBAAgB,CAalB"}
|
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
import { InvalidWorkflowDocumentError } from '@shipfox/workflow-document';
|
|
2
|
-
import { definitionDefaultRunnerLabels
|
|
2
|
+
import { definitionDefaultRunnerLabels } from '../config.js';
|
|
3
3
|
import { InvalidWorkflowModelError, normalizeWorkflowDocument } from './workflow-model/index.js';
|
|
4
4
|
import { InvalidWorkflowYamlError, parseWorkflowYamlWithLocations } from './workflow-yaml/index.js';
|
|
5
|
-
export function validateDefinition(yamlContent, options
|
|
5
|
+
export function validateDefinition(yamlContent, options) {
|
|
6
6
|
try {
|
|
7
7
|
const { document, stepSourceLocations } = parseWorkflowYamlWithLocations(yamlContent);
|
|
8
8
|
const model = normalizeWorkflowDocument(document, {
|
|
9
9
|
defaultRunnerLabels: options.defaultRunnerLabels ?? definitionDefaultRunnerLabels,
|
|
10
|
-
|
|
10
|
+
agentValidationCatalog: options.agentValidationCatalog,
|
|
11
11
|
integrationValidationContext: options.integrationValidationContext,
|
|
12
12
|
stepSourceLocations
|
|
13
13
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/core/validate-definition.ts"],"sourcesContent":["import type {
|
|
1
|
+
{"version":3,"sources":["../../src/core/validate-definition.ts"],"sourcesContent":["import type {AgentValidationCatalog} from '@shipfox/api-agent-dto/inter-module';\nimport {InvalidWorkflowDocumentError} from '@shipfox/workflow-document';\nimport {definitionDefaultRunnerLabels} from '../config.js';\nimport type {IntegrationValidationContext} from './entities/integration-context.js';\nimport type {WorkflowDefinitionPayload} from './entities/workflow-definition.js';\nimport {InvalidWorkflowModelError, normalizeWorkflowDocument} from './workflow-model/index.js';\nimport {InvalidWorkflowYamlError, parseWorkflowYamlWithLocations} from './workflow-yaml/index.js';\n\nexport type ValidationError = {message: string; path?: string | undefined};\n\nexport type ValidationResult =\n | {valid: true; definition: WorkflowDefinitionPayload}\n | {valid: false; errors: ValidationError[]};\n\nexport function validateDefinition(\n yamlContent: string,\n options: {\n defaultRunnerLabels?: readonly string[];\n agentValidationCatalog: AgentValidationCatalog;\n integrationValidationContext?: IntegrationValidationContext;\n },\n): ValidationResult {\n try {\n const {document, stepSourceLocations} = parseWorkflowYamlWithLocations(yamlContent);\n const model = normalizeWorkflowDocument(document, {\n defaultRunnerLabels: options.defaultRunnerLabels ?? definitionDefaultRunnerLabels,\n agentValidationCatalog: options.agentValidationCatalog,\n integrationValidationContext: options.integrationValidationContext,\n stepSourceLocations,\n });\n return {valid: true, definition: {document, model}};\n } catch (error) {\n return {valid: false, errors: validationErrorsFor(error)};\n }\n}\n\nfunction validationErrorsFor(error: unknown): ValidationError[] {\n if (error instanceof InvalidWorkflowYamlError) {\n return [\n validationError({\n message: error.message,\n path:\n error.location === undefined\n ? undefined\n : `${error.location.line}:${error.location.column}`,\n }),\n ];\n }\n\n if (error instanceof InvalidWorkflowDocumentError) {\n return error.validationError.issues.map((issue) =>\n validationError({\n message: issue.message,\n path: issue.path.join('.') || undefined,\n }),\n );\n }\n\n if (error instanceof InvalidWorkflowModelError) {\n return error.issues.map((issue) =>\n validationError({message: issue.message, path: issue.path.join('.')}),\n );\n }\n\n throw error;\n}\n\nfunction validationError(params: {message: string; path?: string | undefined}): ValidationError {\n if (params.path === undefined) return {message: params.message};\n return {message: params.message, path: params.path};\n}\n"],"names":["InvalidWorkflowDocumentError","definitionDefaultRunnerLabels","InvalidWorkflowModelError","normalizeWorkflowDocument","InvalidWorkflowYamlError","parseWorkflowYamlWithLocations","validateDefinition","yamlContent","options","document","stepSourceLocations","model","defaultRunnerLabels","agentValidationCatalog","integrationValidationContext","valid","definition","error","errors","validationErrorsFor","validationError","message","path","location","undefined","line","column","issues","map","issue","join","params"],"mappings":"AACA,SAAQA,4BAA4B,QAAO,6BAA6B;AACxE,SAAQC,6BAA6B,QAAO,eAAe;AAG3D,SAAQC,yBAAyB,EAAEC,yBAAyB,QAAO,4BAA4B;AAC/F,SAAQC,wBAAwB,EAAEC,8BAA8B,QAAO,2BAA2B;AAQlG,OAAO,SAASC,mBACdC,WAAmB,EACnBC,OAIC;IAED,IAAI;QACF,MAAM,EAACC,QAAQ,EAAEC,mBAAmB,EAAC,GAAGL,+BAA+BE;QACvE,MAAMI,QAAQR,0BAA0BM,UAAU;YAChDG,qBAAqBJ,QAAQI,mBAAmB,IAAIX;YACpDY,wBAAwBL,QAAQK,sBAAsB;YACtDC,8BAA8BN,QAAQM,4BAA4B;YAClEJ;QACF;QACA,OAAO;YAACK,OAAO;YAAMC,YAAY;gBAACP;gBAAUE;YAAK;QAAC;IACpD,EAAE,OAAOM,OAAO;QACd,OAAO;YAACF,OAAO;YAAOG,QAAQC,oBAAoBF;QAAM;IAC1D;AACF;AAEA,SAASE,oBAAoBF,KAAc;IACzC,IAAIA,iBAAiBb,0BAA0B;QAC7C,OAAO;YACLgB,gBAAgB;gBACdC,SAASJ,MAAMI,OAAO;gBACtBC,MACEL,MAAMM,QAAQ,KAAKC,YACfA,YACA,GAAGP,MAAMM,QAAQ,CAACE,IAAI,CAAC,CAAC,EAAER,MAAMM,QAAQ,CAACG,MAAM,EAAE;YACzD;SACD;IACH;IAEA,IAAIT,iBAAiBjB,8BAA8B;QACjD,OAAOiB,MAAMG,eAAe,CAACO,MAAM,CAACC,GAAG,CAAC,CAACC,QACvCT,gBAAgB;gBACdC,SAASQ,MAAMR,OAAO;gBACtBC,MAAMO,MAAMP,IAAI,CAACQ,IAAI,CAAC,QAAQN;YAChC;IAEJ;IAEA,IAAIP,iBAAiBf,2BAA2B;QAC9C,OAAOe,MAAMU,MAAM,CAACC,GAAG,CAAC,CAACC,QACvBT,gBAAgB;gBAACC,SAASQ,MAAMR,OAAO;gBAAEC,MAAMO,MAAMP,IAAI,CAACQ,IAAI,CAAC;YAAI;IAEvE;IAEA,MAAMb;AACR;AAEA,SAASG,gBAAgBW,MAAoD;IAC3E,IAAIA,OAAOT,IAAI,KAAKE,WAAW,OAAO;QAACH,SAASU,OAAOV,OAAO;IAAA;IAC9D,OAAO;QAACA,SAASU,OAAOV,OAAO;QAAEC,MAAMS,OAAOT,IAAI;IAAA;AACpD"}
|
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import type { AgentValidationCatalog } from '@shipfox/api-agent-dto/inter-module';
|
|
2
2
|
import type { WorkflowDocument } from '@shipfox/workflow-document';
|
|
3
3
|
import type { IntegrationValidationContext } from '../entities/integration-context.js';
|
|
4
4
|
import type { WorkflowModelJob, WorkflowStepSourceLocationMap } from '../entities/workflow-model.js';
|
|
5
5
|
import type { WorkflowModelValidationIssue } from './invalid-workflow-model-error.js';
|
|
6
6
|
export interface NormalizeContext {
|
|
7
7
|
readonly defaultRunnerLabels: readonly string[];
|
|
8
|
-
readonly
|
|
8
|
+
readonly agentValidationCatalog: AgentValidationCatalog;
|
|
9
9
|
readonly integrationValidationContext?: IntegrationValidationContext | undefined;
|
|
10
10
|
}
|
|
11
11
|
export declare function normalizeJobs(document: WorkflowDocument, jobIdBySourceName: ReadonlyMap<string, string>, issues: WorkflowModelValidationIssue[], stepSourceLocations: WorkflowStepSourceLocationMap | undefined, context: NormalizeContext): readonly WorkflowModelJob[];
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"normalize-jobs.d.ts","sourceRoot":"","sources":["../../../src/core/workflow-model/normalize-jobs.ts"],"names":[],"mappings":"AAAA,OAAO,
|
|
1
|
+
{"version":3,"file":"normalize-jobs.d.ts","sourceRoot":"","sources":["../../../src/core/workflow-model/normalize-jobs.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAC,sBAAsB,EAAC,MAAM,qCAAqC,CAAC;AAgBhF,OAAO,KAAK,EACV,gBAAgB,EAGjB,MAAM,4BAA4B,CAAC;AACpC,OAAO,KAAK,EAAC,4BAA4B,EAAC,MAAM,oCAAoC,CAAC;AACrF,OAAO,KAAK,EAIV,gBAAgB,EAIhB,6BAA6B,EAC9B,MAAM,+BAA+B,CAAC;AACvC,OAAO,KAAK,EAAC,4BAA4B,EAAC,MAAM,mCAAmC,CAAC;AAepF,MAAM,WAAW,gBAAgB;IAC/B,QAAQ,CAAC,mBAAmB,EAAE,SAAS,MAAM,EAAE,CAAC;IAChD,QAAQ,CAAC,sBAAsB,EAAE,sBAAsB,CAAC;IACxD,QAAQ,CAAC,4BAA4B,CAAC,EAAE,4BAA4B,GAAG,SAAS,CAAC;CAClF;AAED,wBAAgB,aAAa,CAC3B,QAAQ,EAAE,gBAAgB,EAC1B,iBAAiB,EAAE,WAAW,CAAC,MAAM,EAAE,MAAM,CAAC,EAC9C,MAAM,EAAE,4BAA4B,EAAE,EACtC,mBAAmB,EAAE,6BAA6B,GAAG,SAAS,EAC9D,OAAO,EAAE,gBAAgB,GACxB,SAAS,gBAAgB,EAAE,CA6D7B"}
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import { agentThinkingByHarness, getHarnessDescriptor, getModelProviderEntry, listEnabledHarnessTools } from '@shipfox/api-agent-dto';
|
|
2
1
|
import { buildTypedRootsEnvironment } from '@shipfox/expression';
|
|
3
2
|
import { canonicalizeLabels, findInvalidLabels, MAX_RUNNER_LABEL_LENGTH, MAX_RUNNER_LABELS, RUNNER_LABEL_PATTERN } from '@shipfox/runner-labels';
|
|
4
3
|
import { normalizeAgentIntegrations } from './normalize-agent-integrations.js';
|
|
@@ -645,7 +644,7 @@ function normalizeAgentStep(params) {
|
|
|
645
644
|
stepIndex: params.stepIndex,
|
|
646
645
|
issues: params.issues,
|
|
647
646
|
validateLiteralProvider: providerTemplate === undefined,
|
|
648
|
-
|
|
647
|
+
agentValidationCatalog: params.context.agentValidationCatalog
|
|
649
648
|
});
|
|
650
649
|
const integrations = normalizeAgentIntegrations({
|
|
651
650
|
integrations: params.step.integrations,
|
|
@@ -693,7 +692,7 @@ function validateAgentStep(params) {
|
|
|
693
692
|
if (!params.validateLiteralProvider) return;
|
|
694
693
|
const providerId = params.step.provider;
|
|
695
694
|
if (providerId === undefined) return;
|
|
696
|
-
const provider =
|
|
695
|
+
const provider = params.agentValidationCatalog.providers.find((entry)=>entry.id === providerId);
|
|
697
696
|
const harness = params.step.harness;
|
|
698
697
|
if (provider === undefined && harness === 'pi') return;
|
|
699
698
|
if (provider === undefined || provider.support_status !== 'supported') {
|
|
@@ -714,11 +713,11 @@ function validateAgentStep(params) {
|
|
|
714
713
|
return;
|
|
715
714
|
}
|
|
716
715
|
if (harness === undefined) return;
|
|
717
|
-
const descriptor =
|
|
718
|
-
if (descriptor.
|
|
716
|
+
const descriptor = params.agentValidationCatalog.harnesses.find((entry)=>entry.id === harness);
|
|
717
|
+
if (descriptor?.supported_provider_ids.includes(providerId)) return;
|
|
719
718
|
params.issues.push(issue({
|
|
720
719
|
code: 'harness-provider-incompatible',
|
|
721
|
-
message: `Harness "${harness}" does not support provider: ${providerId}. Supported providers: ${descriptor.
|
|
720
|
+
message: `Harness "${harness}" does not support provider: ${providerId}. Supported providers: ${descriptor?.supported_provider_ids.join(', ') ?? ''}.`,
|
|
722
721
|
path: [
|
|
723
722
|
'jobs',
|
|
724
723
|
params.sourceName,
|
|
@@ -729,7 +728,7 @@ function validateAgentStep(params) {
|
|
|
729
728
|
details: {
|
|
730
729
|
harness,
|
|
731
730
|
provider: providerId,
|
|
732
|
-
supportedProviders: descriptor
|
|
731
|
+
supportedProviders: descriptor?.supported_provider_ids ?? []
|
|
733
732
|
}
|
|
734
733
|
}));
|
|
735
734
|
}
|
|
@@ -753,7 +752,7 @@ function validateHarnessTools(params) {
|
|
|
753
752
|
}));
|
|
754
753
|
return;
|
|
755
754
|
}
|
|
756
|
-
const supportedTools =
|
|
755
|
+
const supportedTools = params.agentValidationCatalog.harnesses.find((entry)=>entry.id === harness)?.effective_tools ?? [];
|
|
757
756
|
const supportedToolSet = new Set(supportedTools);
|
|
758
757
|
tools.forEach((tool, toolIndex)=>{
|
|
759
758
|
if (supportedToolSet.has(tool)) return;
|
|
@@ -779,9 +778,8 @@ function validateHarnessTools(params) {
|
|
|
779
778
|
function validateHarnessThinking(params) {
|
|
780
779
|
const { harness, thinking } = params.step;
|
|
781
780
|
if (harness === undefined || thinking === undefined) return;
|
|
782
|
-
const
|
|
783
|
-
if (
|
|
784
|
-
const supportedLevels = thinkingSchema.options;
|
|
781
|
+
const supportedLevels = params.agentValidationCatalog.harnesses.find((entry)=>entry.id === harness)?.thinking_levels ?? [];
|
|
782
|
+
if (supportedLevels.includes(thinking)) return;
|
|
785
783
|
params.issues.push(issue({
|
|
786
784
|
code: 'harness-thinking-incompatible',
|
|
787
785
|
message: `Harness "${harness}" does not support thinking: ${thinking}. Supported levels: ${supportedLevels.join(', ')}.`,
|