@executioncontrolprotocol/cli 0.14.0 → 0.50.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/README.md +68 -79
- package/dist/commands.d.ts +7 -0
- package/dist/commands.d.ts.map +1 -0
- package/dist/commands.js +9 -0
- package/dist/commands.js.map +1 -0
- package/dist/hooks/command-not-found.d.ts +8 -0
- package/dist/hooks/command-not-found.d.ts.map +1 -0
- package/dist/hooks/command-not-found.js +72 -0
- package/dist/hooks/command-not-found.js.map +1 -0
- package/dist/hooks/init-host.d.ts +8 -0
- package/dist/hooks/init-host.d.ts.map +1 -0
- package/dist/hooks/init-host.js +45 -0
- package/dist/hooks/init-host.js.map +1 -0
- package/dist/hooks/jit-install.d.ts +8 -0
- package/dist/hooks/jit-install.d.ts.map +1 -0
- package/dist/hooks/jit-install.js +32 -0
- package/dist/hooks/jit-install.js.map +1 -0
- package/dist/hooks/trust.d.ts +9 -0
- package/dist/hooks/trust.d.ts.map +1 -0
- package/dist/hooks/trust.js +32 -0
- package/dist/hooks/trust.js.map +1 -0
- package/dist/lib/argv.d.ts +11 -0
- package/dist/lib/argv.d.ts.map +1 -0
- package/dist/lib/argv.js +30 -0
- package/dist/lib/argv.js.map +1 -0
- package/dist/lib/confirm.d.ts +16 -0
- package/dist/lib/confirm.d.ts.map +1 -0
- package/dist/lib/confirm.js +49 -0
- package/dist/lib/confirm.js.map +1 -0
- package/dist/lib/ensure-plugins.d.ts +17 -0
- package/dist/lib/ensure-plugins.d.ts.map +1 -0
- package/dist/lib/ensure-plugins.js +38 -0
- package/dist/lib/ensure-plugins.js.map +1 -0
- package/dist/lib/evaluate-trust.d.ts +26 -0
- package/dist/lib/evaluate-trust.d.ts.map +1 -0
- package/dist/lib/evaluate-trust.js +87 -0
- package/dist/lib/evaluate-trust.js.map +1 -0
- package/dist/lib/format-output.d.ts +17 -0
- package/dist/lib/format-output.d.ts.map +1 -0
- package/dist/lib/format-output.js +63 -0
- package/dist/lib/format-output.js.map +1 -0
- package/dist/lib/installed-plugins.d.ts +25 -0
- package/dist/lib/installed-plugins.d.ts.map +1 -0
- package/dist/lib/installed-plugins.js +22 -0
- package/dist/lib/installed-plugins.js.map +1 -0
- package/dist/lib/jit-plugins.d.ts +13 -0
- package/dist/lib/jit-plugins.d.ts.map +1 -0
- package/dist/lib/jit-plugins.js +25 -0
- package/dist/lib/jit-plugins.js.map +1 -0
- package/dist/lib/layer-environment.d.ts +29 -0
- package/dist/lib/layer-environment.d.ts.map +1 -0
- package/dist/lib/layer-environment.js +96 -0
- package/dist/lib/layer-environment.js.map +1 -0
- package/dist/lib/load-ecp.d.ts +17 -0
- package/dist/lib/load-ecp.d.ts.map +1 -0
- package/dist/lib/load-ecp.js +39 -0
- package/dist/lib/load-ecp.js.map +1 -0
- package/dist/lib/missing-plugins.d.ts +24 -0
- package/dist/lib/missing-plugins.d.ts.map +1 -0
- package/dist/lib/missing-plugins.js +53 -0
- package/dist/lib/missing-plugins.js.map +1 -0
- package/dist/lib/npm-registry.d.ts +40 -0
- package/dist/lib/npm-registry.d.ts.map +1 -0
- package/dist/lib/npm-registry.js +68 -0
- package/dist/lib/npm-registry.js.map +1 -0
- package/dist/lib/plugin-bindings.d.ts +13 -0
- package/dist/lib/plugin-bindings.d.ts.map +1 -0
- package/dist/lib/plugin-bindings.js +49 -0
- package/dist/lib/plugin-bindings.js.map +1 -0
- package/dist/lib/plugin-source.d.ts +11 -0
- package/dist/lib/plugin-source.d.ts.map +1 -0
- package/dist/lib/plugin-source.js +32 -0
- package/dist/lib/plugin-source.js.map +1 -0
- package/dist/lib/prepare-workflow.d.ts +27 -0
- package/dist/lib/prepare-workflow.d.ts.map +1 -0
- package/dist/lib/prepare-workflow.js +76 -0
- package/dist/lib/prepare-workflow.js.map +1 -0
- package/dist/lib/runs-io.d.ts +30 -0
- package/dist/lib/runs-io.d.ts.map +1 -0
- package/dist/lib/runs-io.js +154 -0
- package/dist/lib/runs-io.js.map +1 -0
- package/dist/lib/secrets/store.d.ts +2 -1
- package/dist/lib/secrets/store.d.ts.map +1 -1
- package/dist/lib/secrets/store.js +1 -1
- package/dist/lib/secrets/store.js.map +1 -1
- package/dist/lib/trust-store.d.ts +12 -0
- package/dist/lib/trust-store.d.ts.map +1 -0
- package/dist/lib/trust-store.js +33 -0
- package/dist/lib/trust-store.js.map +1 -0
- package/dist/operations/catalog.d.ts +7 -0
- package/dist/operations/catalog.d.ts.map +1 -0
- package/dist/operations/catalog.js +108 -0
- package/dist/operations/catalog.js.map +1 -0
- package/dist/operations/discover.d.ts +3 -0
- package/dist/operations/discover.d.ts.map +1 -0
- package/dist/operations/discover.js +61 -0
- package/dist/operations/discover.js.map +1 -0
- package/dist/operations/index.d.ts +4 -0
- package/dist/operations/index.d.ts.map +1 -0
- package/dist/operations/index.js +38 -0
- package/dist/operations/index.js.map +1 -0
- package/dist/operations/init.d.ts +3 -0
- package/dist/operations/init.d.ts.map +1 -0
- package/dist/operations/init.js +46 -0
- package/dist/operations/init.js.map +1 -0
- package/dist/operations/install.d.ts +3 -0
- package/dist/operations/install.d.ts.map +1 -0
- package/dist/operations/install.js +34 -0
- package/dist/operations/install.js.map +1 -0
- package/dist/operations/plugins.d.ts +7 -0
- package/dist/operations/plugins.d.ts.map +1 -0
- package/dist/operations/plugins.js +64 -0
- package/dist/operations/plugins.js.map +1 -0
- package/dist/operations/rollback.d.ts +3 -0
- package/dist/operations/rollback.d.ts.map +1 -0
- package/dist/operations/rollback.js +25 -0
- package/dist/operations/rollback.js.map +1 -0
- package/dist/operations/runs.d.ts +11 -0
- package/dist/operations/runs.d.ts.map +1 -0
- package/dist/operations/runs.js +205 -0
- package/dist/operations/runs.js.map +1 -0
- package/dist/operations/secrets.d.ts +11 -0
- package/dist/operations/secrets.d.ts.map +1 -0
- package/dist/operations/secrets.js +134 -0
- package/dist/operations/secrets.js.map +1 -0
- package/dist/operations/update.d.ts +3 -0
- package/dist/operations/update.d.ts.map +1 -0
- package/dist/operations/update.js +64 -0
- package/dist/operations/update.js.map +1 -0
- package/dist/operations/workflow.d.ts +7 -0
- package/dist/operations/workflow.d.ts.map +1 -0
- package/dist/operations/workflow.js +144 -0
- package/dist/operations/workflow.js.map +1 -0
- package/package.json +38 -13
- package/dist/commands/compile.d.ts +0 -15
- package/dist/commands/compile.d.ts.map +0 -1
- package/dist/commands/compile.js +0 -44
- package/dist/commands/compile.js.map +0 -1
- package/dist/commands/config/secrets/add.d.ts +0 -15
- package/dist/commands/config/secrets/add.d.ts.map +0 -1
- package/dist/commands/config/secrets/add.js +0 -51
- package/dist/commands/config/secrets/add.js.map +0 -1
- package/dist/commands/config/secrets/get.d.ts +0 -13
- package/dist/commands/config/secrets/get.d.ts.map +0 -1
- package/dist/commands/config/secrets/get.js +0 -39
- package/dist/commands/config/secrets/get.js.map +0 -1
- package/dist/commands/config/secrets/list.d.ts +0 -7
- package/dist/commands/config/secrets/list.d.ts.map +0 -1
- package/dist/commands/config/secrets/list.js +0 -22
- package/dist/commands/config/secrets/list.js.map +0 -1
- package/dist/commands/config/secrets/remove.d.ts +0 -10
- package/dist/commands/config/secrets/remove.d.ts.map +0 -1
- package/dist/commands/config/secrets/remove.js +0 -25
- package/dist/commands/config/secrets/remove.js.map +0 -1
- package/dist/commands/config/secrets.d.ts +0 -9
- package/dist/commands/config/secrets.d.ts.map +0 -1
- package/dist/commands/config/secrets.js +0 -31
- package/dist/commands/config/secrets.js.map +0 -1
- package/dist/commands/decode.d.ts +0 -18
- package/dist/commands/decode.d.ts.map +0 -1
- package/dist/commands/decode.js +0 -66
- package/dist/commands/decode.js.map +0 -1
- package/dist/commands/describe.d.ts +0 -15
- package/dist/commands/describe.d.ts.map +0 -1
- package/dist/commands/describe.js +0 -62
- package/dist/commands/describe.js.map +0 -1
- package/dist/commands/encode.d.ts +0 -18
- package/dist/commands/encode.d.ts.map +0 -1
- package/dist/commands/encode.js +0 -63
- package/dist/commands/encode.js.map +0 -1
- package/dist/commands/init.d.ts +0 -14
- package/dist/commands/init.d.ts.map +0 -1
- package/dist/commands/init.js +0 -91
- package/dist/commands/init.js.map +0 -1
- package/dist/commands/invoke.d.ts +0 -17
- package/dist/commands/invoke.d.ts.map +0 -1
- package/dist/commands/invoke.js +0 -47
- package/dist/commands/invoke.js.map +0 -1
- package/dist/commands/run.d.ts +0 -17
- package/dist/commands/run.d.ts.map +0 -1
- package/dist/commands/run.js +0 -53
- package/dist/commands/run.js.map +0 -1
- package/dist/commands/search.d.ts +0 -12
- package/dist/commands/search.d.ts.map +0 -1
- package/dist/commands/search.js +0 -26
- package/dist/commands/search.js.map +0 -1
- package/dist/commands/serve.d.ts +0 -15
- package/dist/commands/serve.d.ts.map +0 -1
- package/dist/commands/serve.js +0 -53
- package/dist/commands/serve.js.map +0 -1
- package/dist/commands/test/rerun.d.ts +0 -16
- package/dist/commands/test/rerun.d.ts.map +0 -1
- package/dist/commands/test/rerun.js +0 -38
- package/dist/commands/test/rerun.js.map +0 -1
- package/dist/commands/test/run.d.ts +0 -14
- package/dist/commands/test/run.d.ts.map +0 -1
- package/dist/commands/test/run.js +0 -36
- package/dist/commands/test/run.js.map +0 -1
- package/dist/commands/test/start.d.ts +0 -17
- package/dist/commands/test/start.d.ts.map +0 -1
- package/dist/commands/test/start.js +0 -43
- package/dist/commands/test/start.js.map +0 -1
- package/dist/commands/test/status.d.ts +0 -12
- package/dist/commands/test/status.d.ts.map +0 -1
- package/dist/commands/test/status.js +0 -24
- package/dist/commands/test/status.js.map +0 -1
- package/dist/commands/test.d.ts +0 -9
- package/dist/commands/test.d.ts.map +0 -1
- package/dist/commands/test.js +0 -32
- package/dist/commands/test.js.map +0 -1
- package/dist/commands/up.d.ts +0 -19
- package/dist/commands/up.d.ts.map +0 -1
- package/dist/commands/up.js +0 -103
- package/dist/commands/up.js.map +0 -1
- package/dist/commands/validate.d.ts +0 -12
- package/dist/commands/validate.d.ts.map +0 -1
- package/dist/commands/validate.js +0 -26
- package/dist/commands/validate.js.map +0 -1
- package/dist/lib/env-module-command.d.ts +0 -37
- package/dist/lib/env-module-command.d.ts.map +0 -1
- package/dist/lib/env-module-command.js +0 -59
- package/dist/lib/env-module-command.js.map +0 -1
- package/dist/lib/format-cli.d.ts +0 -13
- package/dist/lib/format-cli.d.ts.map +0 -1
- package/dist/lib/format-cli.js +0 -25
- package/dist/lib/format-cli.js.map +0 -1
- package/dist/lib/http/create-serve-handler.d.ts +0 -15
- package/dist/lib/http/create-serve-handler.d.ts.map +0 -1
- package/dist/lib/http/create-serve-handler.js +0 -40
- package/dist/lib/http/create-serve-handler.js.map +0 -1
- package/dist/lib/http/create-serve.d.ts +0 -30
- package/dist/lib/http/create-serve.d.ts.map +0 -1
- package/dist/lib/http/create-serve.js +0 -43
- package/dist/lib/http/create-serve.js.map +0 -1
- package/dist/lib/http/handle-artifact.d.ts +0 -15
- package/dist/lib/http/handle-artifact.d.ts.map +0 -1
- package/dist/lib/http/handle-artifact.js +0 -78
- package/dist/lib/http/handle-artifact.js.map +0 -1
- package/dist/lib/http/handle-invoke.d.ts +0 -59
- package/dist/lib/http/handle-invoke.d.ts.map +0 -1
- package/dist/lib/http/handle-invoke.js +0 -108
- package/dist/lib/http/handle-invoke.js.map +0 -1
- package/dist/lib/http/read-body.d.ts +0 -7
- package/dist/lib/http/read-body.d.ts.map +0 -1
- package/dist/lib/http/read-body.js +0 -12
- package/dist/lib/http/read-body.js.map +0 -1
- package/dist/lib/http/write-json.d.ts +0 -7
- package/dist/lib/http/write-json.d.ts.map +0 -1
- package/dist/lib/http/write-json.js +0 -11
- package/dist/lib/http/write-json.js.map +0 -1
- package/dist/lib/test-session-io.d.ts +0 -12
- package/dist/lib/test-session-io.d.ts.map +0 -1
- package/dist/lib/test-session-io.js +0 -36
- package/dist/lib/test-session-io.js.map +0 -1
- package/dist/lib/up/constants.d.ts +0 -15
- package/dist/lib/up/constants.d.ts.map +0 -1
- package/dist/lib/up/constants.js +0 -21
- package/dist/lib/up/constants.js.map +0 -1
- package/dist/lib/up/cors.d.ts +0 -12
- package/dist/lib/up/cors.d.ts.map +0 -1
- package/dist/lib/up/cors.js +0 -28
- package/dist/lib/up/cors.js.map +0 -1
- package/dist/lib/up/create-daemon.d.ts +0 -55
- package/dist/lib/up/create-daemon.d.ts.map +0 -1
- package/dist/lib/up/create-daemon.js +0 -94
- package/dist/lib/up/create-daemon.js.map +0 -1
- package/dist/lib/up/handle-request.d.ts +0 -19
- package/dist/lib/up/handle-request.d.ts.map +0 -1
- package/dist/lib/up/handle-request.js +0 -71
- package/dist/lib/up/handle-request.js.map +0 -1
- package/dist/lib/up/open-browser.d.ts +0 -28
- package/dist/lib/up/open-browser.d.ts.map +0 -1
- package/dist/lib/up/open-browser.js +0 -56
- package/dist/lib/up/open-browser.js.map +0 -1
- package/dist/lib/up/read-body.d.ts +0 -3
- package/dist/lib/up/read-body.d.ts.map +0 -1
- package/dist/lib/up/read-body.js +0 -3
- package/dist/lib/up/read-body.js.map +0 -1
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"load-ecp.js","sourceRoot":"","sources":["../../src/lib/load-ecp.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,qBAAqB,EAAE,mBAAmB,EAAE,MAAM,gCAAgC,CAAA;AAExG,OAAO,EAAE,OAAO,EAAgB,MAAM,sCAAsC,CAAA;AAE5E;;;;GAIG;AACH,MAAM,CAAC,KAAK,UAAU,cAAc,CAClC,OAA2B,EAC3B,IAAc;IAEd,IAAI,OAAO,EAAE,CAAC;QACZ,MAAM,GAAG,GAAG,MAAM,qBAAqB,CAAC,OAAO,CAAC,CAAA;QAChD,MAAM,GAAG,GAAG,MAAM,GAAG,CAAC,IAAI,EAAE,CAAA;QAC5B,OAAO,EAAE,GAAG,EAAE,SAAS,EAAE,IAAI,EAAE,CAAA;IACjC,CAAC;IACD,IAAI,IAAI;QAAE,OAAO,EAAE,GAAG,EAAE,IAAI,CAAC,GAAG,EAAE,SAAS,EAAE,KAAK,EAAE,CAAA;IACpD,IAAI,CAAC;QACH,OAAO,EAAE,GAAG,EAAE,OAAO,EAAE,CAAC,GAAG,EAAE,SAAS,EAAE,KAAK,EAAE,CAAA;IACjD,CAAC;IAAC,MAAM,CAAC;QACP,MAAM,GAAG,GAAG,WAAW,CAAC,mBAAmB,EAAE,KAAK,CAAC,CAAA;QACnD,MAAM,GAAG,GAAG,MAAM,GAAG,CAAC,IAAI,EAAE,CAAA;QAC5B,OAAO,EAAE,GAAG,EAAE,SAAS,EAAE,IAAI,EAAE,CAAA;IACjC,CAAC;AACH,CAAC;AAED;;;GAGG;AACH,MAAM,CAAC,KAAK,UAAU,iBAAiB,CAAC,GAAQ,EAAE,SAAkB;IAClE,IAAI,CAAC,SAAS;QAAE,OAAM;IACtB,IAAI,CAAC;QACH,MAAM,GAAG,CAAC,SAAS,EAAE,CAAA;IACvB,CAAC;IAAC,MAAM,CAAC;QACP,YAAY;IACd,CAAC;AACH,CAAC"}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import type { Interfaces } from "@oclif/core";
|
|
2
|
+
import { type RequirementsDocument } from "@executioncontrolprotocol/core";
|
|
3
|
+
/** Why a required plugin is not usable. @category CLI */
|
|
4
|
+
export type MissingPluginReason = "missing" | "version";
|
|
5
|
+
/** One missing or out-of-range plugin. @category CLI */
|
|
6
|
+
export interface MissingPlugin {
|
|
7
|
+
/** Extension or policy id. */
|
|
8
|
+
id: string;
|
|
9
|
+
/** npm package to install. */
|
|
10
|
+
package: string;
|
|
11
|
+
/** Requested semver range, when pinned. */
|
|
12
|
+
range?: string;
|
|
13
|
+
/** Why it is missing. */
|
|
14
|
+
reason: MissingPluginReason;
|
|
15
|
+
/** Exact install command. */
|
|
16
|
+
command: string;
|
|
17
|
+
}
|
|
18
|
+
/**
|
|
19
|
+
* Requirements that are not satisfied by currently installed plugins.
|
|
20
|
+
* Built-ins are skipped. Missing `package` rows are skipped (nothing to install).
|
|
21
|
+
* @category CLI
|
|
22
|
+
*/
|
|
23
|
+
export declare function findMissingPlugins(requirements: RequirementsDocument, config: Interfaces.Config): MissingPlugin[];
|
|
24
|
+
//# sourceMappingURL=missing-plugins.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"missing-plugins.d.ts","sourceRoot":"","sources":["../../src/lib/missing-plugins.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,aAAa,CAAA;AAC7C,OAAO,EAIL,KAAK,oBAAoB,EAC1B,MAAM,gCAAgC,CAAA;AAGvC,yDAAyD;AACzD,MAAM,MAAM,mBAAmB,GAAG,SAAS,GAAG,SAAS,CAAA;AAEvD,wDAAwD;AACxD,MAAM,WAAW,aAAa;IAC5B,8BAA8B;IAC9B,EAAE,EAAE,MAAM,CAAA;IACV,8BAA8B;IAC9B,OAAO,EAAE,MAAM,CAAA;IACf,2CAA2C;IAC3C,KAAK,CAAC,EAAE,MAAM,CAAA;IACd,yBAAyB;IACzB,MAAM,EAAE,mBAAmB,CAAA;IAC3B,6BAA6B;IAC7B,OAAO,EAAE,MAAM,CAAA;CAChB;AAeD;;;;GAIG;AACH,wBAAgB,kBAAkB,CAChC,YAAY,EAAE,oBAAoB,EAClC,MAAM,EAAE,UAAU,CAAC,MAAM,GACxB,aAAa,EAAE,CAsBjB"}
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
import { isBuiltinRequirementId, satisfiesRange, } from "@executioncontrolprotocol/core";
|
|
2
|
+
import { listInstalledPlugins } from "./installed-plugins.js";
|
|
3
|
+
function pluginProvidesId(plugin, id) {
|
|
4
|
+
const ecp = plugin.pjson.ecp;
|
|
5
|
+
if (ecp?.id === id)
|
|
6
|
+
return true;
|
|
7
|
+
const name = plugin.name;
|
|
8
|
+
const mapped = name.replace(/\/plugin-/, "/");
|
|
9
|
+
return mapped === id;
|
|
10
|
+
}
|
|
11
|
+
function installCommand(pkg, range) {
|
|
12
|
+
const spec = range ? `${pkg}@${range}` : pkg;
|
|
13
|
+
return `ecp plugins install ${spec}`;
|
|
14
|
+
}
|
|
15
|
+
/**
|
|
16
|
+
* Requirements that are not satisfied by currently installed plugins.
|
|
17
|
+
* Built-ins are skipped. Missing `package` rows are skipped (nothing to install).
|
|
18
|
+
* @category CLI
|
|
19
|
+
*/
|
|
20
|
+
export function findMissingPlugins(requirements, config) {
|
|
21
|
+
const installed = listInstalledPlugins(config);
|
|
22
|
+
const missing = [];
|
|
23
|
+
const seen = new Set();
|
|
24
|
+
for (const row of requirements.requirements) {
|
|
25
|
+
if (isBuiltinRequirementId(row.id))
|
|
26
|
+
continue;
|
|
27
|
+
if (!row.package)
|
|
28
|
+
continue;
|
|
29
|
+
const key = `${row.id}:${row.package}`;
|
|
30
|
+
if (seen.has(key))
|
|
31
|
+
continue;
|
|
32
|
+
seen.add(key);
|
|
33
|
+
const hit = installed.find((plugin) => plugin.name === row.package || pluginProvidesId(plugin, row.id));
|
|
34
|
+
if (!hit) {
|
|
35
|
+
missing.push(toMissing(row, "missing"));
|
|
36
|
+
continue;
|
|
37
|
+
}
|
|
38
|
+
if (row.range && hit.version && !satisfiesRange(hit.version, row.range)) {
|
|
39
|
+
missing.push(toMissing(row, "version"));
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
return missing;
|
|
43
|
+
}
|
|
44
|
+
function toMissing(row, reason) {
|
|
45
|
+
return {
|
|
46
|
+
id: row.id,
|
|
47
|
+
package: row.package ?? "",
|
|
48
|
+
...(row.range ? { range: row.range } : {}),
|
|
49
|
+
reason,
|
|
50
|
+
command: installCommand(row.package ?? "", row.range),
|
|
51
|
+
};
|
|
52
|
+
}
|
|
53
|
+
//# sourceMappingURL=missing-plugins.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"missing-plugins.js","sourceRoot":"","sources":["../../src/lib/missing-plugins.ts"],"names":[],"mappings":"AACA,OAAO,EACL,sBAAsB,EACtB,cAAc,GAGf,MAAM,gCAAgC,CAAA;AACvC,OAAO,EAAE,oBAAoB,E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AAE,CAAC,MAAM,CAAC,IAAI,KAAK,GAAG,CAAC,OAAO,IAAI,gBAAgB,CAAC,MAAM,EAAE,GAAG,CAAC,EAAE,CAAC,CAC5E,CAAA;QACD,IAAI,CAAC,GAAG,EAAE,CAAC;YACT,OAAO,CAAC,IAAI,CAAC,SAAS,CAAC,GAAG,EAAE,SAAS,CAAC,CAAC,CAAA;YACvC,SAAQ;QACV,CAAC;QACD,IAAI,GAAG,CAAC,KAAK,IAAI,GAAG,CAAC,OAAO,IAAI,CAAC,cAAc,CAAC,GAAG,CAAC,OAAO,EAAE,GAAG,CAAC,KAAK,CAAC,EAAE,CAAC;YACxE,OAAO,CAAC,IAAI,CAAC,SAAS,CAAC,GAAG,EAAE,SAAS,CAAC,CAAC,CAAA;QACzC,CAAC;IACH,CAAC;IACD,OAAO,OAAO,CAAA;AAChB,CAAC;AAED,SAAS,SAAS,CAAC,GAAqB,EAAE,MAA2B;IACnE,OAAO;QACL,EAAE,EAAE,GAAG,CAAC,EAAE;QACV,OAAO,EAAE,GAAG,CAAC,OAAO,IAAI,EAAE;QAC1B,GAAG,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC,CAAC,EAAE,KAAK,EAAE,GAAG,CAAC,KAAK,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;QAC1C,MAAM;QACN,OAAO,EAAE,cAAc,CAAC,GAAG,CAAC,OAAO,IAAI,EAAE,EAAE,GAAG,CAAC,KAAK,CAAC;KACtD,CAAA;AACH,CAAC"}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
/** Default npm registry origin. @category CLI */
|
|
2
|
+
export declare const DEFAULT_NPM_REGISTRY = "https://registry.npmjs.org";
|
|
3
|
+
/**
|
|
4
|
+
* npm registry origin, overridable with `ECP_NPM_REGISTRY` for tests.
|
|
5
|
+
* @category CLI
|
|
6
|
+
*/
|
|
7
|
+
export declare function npmRegistryOrigin(): string;
|
|
8
|
+
/** One hit from the npm search API. @category CLI */
|
|
9
|
+
export interface NpmSearchHit {
|
|
10
|
+
/** Package name. */
|
|
11
|
+
name: string;
|
|
12
|
+
/** Latest version. */
|
|
13
|
+
version: string;
|
|
14
|
+
/** Package description. */
|
|
15
|
+
description?: string;
|
|
16
|
+
/** npm modified date. */
|
|
17
|
+
date?: string;
|
|
18
|
+
/** Keywords. */
|
|
19
|
+
keywords?: string[];
|
|
20
|
+
}
|
|
21
|
+
/**
|
|
22
|
+
* Search npm for `ecosystem:ecp-plugin` packages.
|
|
23
|
+
* @category CLI
|
|
24
|
+
*/
|
|
25
|
+
export declare function searchEcpPlugins(query?: string): Promise<NpmSearchHit[]>;
|
|
26
|
+
/**
|
|
27
|
+
* True when the package exists on the registry.
|
|
28
|
+
* @category CLI
|
|
29
|
+
*/
|
|
30
|
+
export declare function npmPackageExists(name: string): Promise<boolean>;
|
|
31
|
+
/**
|
|
32
|
+
* Latest version string from the registry, or undefined when missing.
|
|
33
|
+
* @category CLI
|
|
34
|
+
*/
|
|
35
|
+
export declare function npmLatestVersion(name: string): Promise<string | undefined>;
|
|
36
|
+
/**
|
|
37
|
+
* First-party packages live under `@executioncontrolprotocol/`.
|
|
38
|
+
* @category CLI */
|
|
39
|
+
export declare function isFirstPartyPackage(name: string): boolean;
|
|
40
|
+
//# sourceMappingURL=npm-registry.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"npm-registry.d.ts","sourceRoot":"","sources":["../../src/lib/npm-registry.ts"],"names":[],"mappings":"AAAA,iDAAiD;AACjD,eAAO,MAAM,oBAAoB,+BAA+B,CAAA;AAEhE;;;GAGG;AACH,wBAAgB,iBAAiB,IAAI,MAAM,CAE1C;AAED,qDAAqD;AACrD,MAAM,WAAW,YAAY;IAC3B,oBAAoB;IACpB,IAAI,EAAE,MAAM,CAAA;IACZ,sBAAsB;IACtB,OAAO,EAAE,MAAM,CAAA;IACf,2BAA2B;IAC3B,WAAW,CAAC,EAAE,MAAM,CAAA;IACpB,yBAAyB;IACzB,IAAI,CAAC,EAAE,MAAM,CAAA;IACb,gBAAgB;IAChB,QAAQ,CAAC,EAAE,MAAM,EAAE,CAAA;CACpB;AAcD;;;GAGG;AACH,wBAAsB,gBAAgB,CAAC,KAAK,SAAK,GAAG,OAAO,CAAC,YAAY,EAAE,CAAC,CAkB1E;AAED;;;GAGG;AACH,wBAAsB,gBAAgB,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC,CAUrE;AAED;;;GAGG;AACH,wBAAsB,gBAAgB,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,GAAG,SAAS,CAAC,CAMhF;AAED;;mBAEmB;AACnB,wBAAgB,mBAAmB,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAEzD"}
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
/** Default npm registry origin. @category CLI */
|
|
2
|
+
export const DEFAULT_NPM_REGISTRY = "https://registry.npmjs.org";
|
|
3
|
+
/**
|
|
4
|
+
* npm registry origin, overridable with `ECP_NPM_REGISTRY` for tests.
|
|
5
|
+
* @category CLI
|
|
6
|
+
*/
|
|
7
|
+
export function npmRegistryOrigin() {
|
|
8
|
+
return (process.env.ECP_NPM_REGISTRY ?? DEFAULT_NPM_REGISTRY).replace(/\/$/, "");
|
|
9
|
+
}
|
|
10
|
+
/**
|
|
11
|
+
* Search npm for `ecosystem:ecp-plugin` packages.
|
|
12
|
+
* @category CLI
|
|
13
|
+
*/
|
|
14
|
+
export async function searchEcpPlugins(query = "") {
|
|
15
|
+
const text = ["keywords:ecosystem:ecp-plugin", query.trim()].filter(Boolean).join(" ");
|
|
16
|
+
const url = `${npmRegistryOrigin()}/-/v1/search?text=${encodeURIComponent(text)}&size=250`;
|
|
17
|
+
const response = await fetch(url);
|
|
18
|
+
if (!response.ok) {
|
|
19
|
+
throw new Error(`npm search failed (${response.status})`);
|
|
20
|
+
}
|
|
21
|
+
const body = (await response.json());
|
|
22
|
+
return (body.objects ?? [])
|
|
23
|
+
.map((entry) => entry.package)
|
|
24
|
+
.filter((pkg) => Boolean(pkg?.name))
|
|
25
|
+
.map((pkg) => ({
|
|
26
|
+
name: String(pkg.name),
|
|
27
|
+
version: String(pkg.version ?? ""),
|
|
28
|
+
description: pkg.description,
|
|
29
|
+
date: pkg.date,
|
|
30
|
+
keywords: pkg.keywords,
|
|
31
|
+
}));
|
|
32
|
+
}
|
|
33
|
+
/**
|
|
34
|
+
* True when the package exists on the registry.
|
|
35
|
+
* @category CLI
|
|
36
|
+
*/
|
|
37
|
+
export async function npmPackageExists(name) {
|
|
38
|
+
const url = `${npmRegistryOrigin()}/${name.replace("/", "%2f")}`;
|
|
39
|
+
const response = await fetch(url, { method: "HEAD" });
|
|
40
|
+
if (response.status === 404)
|
|
41
|
+
return false;
|
|
42
|
+
if (response.ok)
|
|
43
|
+
return true;
|
|
44
|
+
if (response.status === 405 || response.status === 400) {
|
|
45
|
+
const get = await fetch(url);
|
|
46
|
+
return get.ok;
|
|
47
|
+
}
|
|
48
|
+
return false;
|
|
49
|
+
}
|
|
50
|
+
/**
|
|
51
|
+
* Latest version string from the registry, or undefined when missing.
|
|
52
|
+
* @category CLI
|
|
53
|
+
*/
|
|
54
|
+
export async function npmLatestVersion(name) {
|
|
55
|
+
const url = `${npmRegistryOrigin()}/${name.replace("/", "%2f")}`;
|
|
56
|
+
const response = await fetch(url);
|
|
57
|
+
if (!response.ok)
|
|
58
|
+
return undefined;
|
|
59
|
+
const body = (await response.json());
|
|
60
|
+
return body["dist-tags"]?.latest;
|
|
61
|
+
}
|
|
62
|
+
/**
|
|
63
|
+
* First-party packages live under `@executioncontrolprotocol/`.
|
|
64
|
+
* @category CLI */
|
|
65
|
+
export function isFirstPartyPackage(name) {
|
|
66
|
+
return name.startsWith("@executioncontrolprotocol/");
|
|
67
|
+
}
|
|
68
|
+
//# sourceMappingURL=npm-registry.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"npm-registry.js","sourceRoot":"","sources":["../../src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;;mBAEmB;AACnB,MAAM,UAAU,mBAAmB,CAAC,IAAY;IAC9C,OAAO,IAAI,CAAC,UAAU,CAAC,4BAA4B,CAAC,CAAA;AACtD,CAAC"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import type { Interfaces } from "@oclif/core";
|
|
2
|
+
import { type EnvironmentBinding } from "@executioncontrolprotocol/core";
|
|
3
|
+
/**
|
|
4
|
+
* Bindings from installed oclif plugins that declare `ecp.extension`.
|
|
5
|
+
* @category CLI
|
|
6
|
+
*/
|
|
7
|
+
export declare function bindingsFromInstalledPlugins(config: Interfaces.Config): Promise<EnvironmentBinding[]>;
|
|
8
|
+
/**
|
|
9
|
+
* Built-in Node environment plus installed plugin bindings.
|
|
10
|
+
* @category CLI
|
|
11
|
+
*/
|
|
12
|
+
export declare function createProcessEnvironment(config: Interfaces.Config): Promise<import("@executioncontrolprotocol/core").Environment>;
|
|
13
|
+
//# sourceMappingURL=plugin-bindings.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"plugin-bindings.d.ts","sourceRoot":"","sources":["../../src/lib/plugin-bindings.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,aAAa,CAAA;AAC7C,OAAO,EAGL,KAAK,kBAAkB,EAGxB,MAAM,gCAAgC,CAAA;AAiBvC;;;GAGG;AACH,wBAAsB,4BAA4B,CAChD,MAAM,EAAE,UAAU,CAAC,MAAM,GACxB,OAAO,CAAC,kBAAkB,EAAE,CAAC,CAiB/B;AAED;;;GAGG;AACH,wBAAsB,wBAAwB,CAAC,MAAM,EAAE,UAAU,CAAC,MAAM,iEAGvE"}
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import { join } from "node:path";
|
|
2
|
+
import { pathToFileURL } from "node:url";
|
|
3
|
+
import { extension, policy, } from "@executioncontrolprotocol/core";
|
|
4
|
+
import { environment, NODE_ENVIRONMENT_ID } from "@executioncontrolprotocol/node";
|
|
5
|
+
import { listInstalledPlugins } from "./installed-plugins.js";
|
|
6
|
+
function isPolicy(def) {
|
|
7
|
+
return (typeof def === "object" &&
|
|
8
|
+
def !== null &&
|
|
9
|
+
"hooks" in def &&
|
|
10
|
+
!("capabilities" in def));
|
|
11
|
+
}
|
|
12
|
+
function isExtension(def) {
|
|
13
|
+
return typeof def === "object" && def !== null && "capabilities" in def;
|
|
14
|
+
}
|
|
15
|
+
/**
|
|
16
|
+
* Bindings from installed oclif plugins that declare `ecp.extension`.
|
|
17
|
+
* @category CLI
|
|
18
|
+
*/
|
|
19
|
+
export async function bindingsFromInstalledPlugins(config) {
|
|
20
|
+
const bindings = [];
|
|
21
|
+
for (const plugin of listInstalledPlugins(config)) {
|
|
22
|
+
const ecp = plugin.pjson.ecp;
|
|
23
|
+
const entry = ecp?.extension;
|
|
24
|
+
if (!entry)
|
|
25
|
+
continue;
|
|
26
|
+
try {
|
|
27
|
+
const href = pathToFileURL(join(plugin.root, entry)).href;
|
|
28
|
+
const mod = (await import(href));
|
|
29
|
+
const def = mod.default;
|
|
30
|
+
if (isExtension(def))
|
|
31
|
+
bindings.push(extension(def));
|
|
32
|
+
else if (isPolicy(def))
|
|
33
|
+
bindings.push(policy(def));
|
|
34
|
+
}
|
|
35
|
+
catch {
|
|
36
|
+
/* skip plugins whose definition cannot load */
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
return bindings;
|
|
40
|
+
}
|
|
41
|
+
/**
|
|
42
|
+
* Built-in Node environment plus installed plugin bindings.
|
|
43
|
+
* @category CLI
|
|
44
|
+
*/
|
|
45
|
+
export async function createProcessEnvironment(config) {
|
|
46
|
+
const bindings = await bindingsFromInstalledPlugins(config);
|
|
47
|
+
return environment(NODE_ENVIRONMENT_ID, "cli").with(bindings);
|
|
48
|
+
}
|
|
49
|
+
//# sourceMappingURL=plugin-bindings.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"plugin-bindings.js","sourceRoot":"","sources":["../../src/lib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E,QAAQ,CAAC,IAAI,CAAC,SAAS,CAAC,GAAG,CAAC,CAAC,CAAA;iBAC9C,IAAI,QAAQ,CAAC,GAAG,CAAC;gBAAE,QAAQ,CAAC,IAAI,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,CAAA;QACpD,CAAC;QAAC,MAAM,CAAC;YACP,+CAA+C;QACjD,CAAC;IACH,CAAC;IACD,OAAO,QAAQ,CAAA;AACjB,CAAC;AAED;;;GAGG;AACH,MAAM,CAAC,KAAK,UAAU,wBAAwB,CAAC,MAAyB;IACtE,MAAM,QAAQ,GAAG,MAAM,4BAA4B,CAAC,MAAM,CAAC,CAAA;IAC3D,OAAO,WAAW,CAAC,mBAAmB,EAAE,KAAK,CAAC,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAA;AAC/D,CAAC"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Classify a plugin install target as npm, git, or a local path.
|
|
3
|
+
* @category CLI
|
|
4
|
+
*/
|
|
5
|
+
export declare function pluginSourceKind(spec: string): "npm" | "git" | "path";
|
|
6
|
+
/**
|
|
7
|
+
* Package name from an install spec (`@scope/name@version` or a bare name).
|
|
8
|
+
* @category CLI
|
|
9
|
+
*/
|
|
10
|
+
export declare function pluginNameFromSpec(spec: string): string;
|
|
11
|
+
//# sourceMappingURL=plugin-source.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"plugin-source.d.ts","sourceRoot":"","sources":["../../src/lib/plugin-source.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,wBAAgB,gBAAgB,CAAC,IAAI,EAAE,MAAM,GAAG,KAAK,GAAG,KAAK,GAAG,MAAM,CAarE;AAED;;;GAGG;AACH,wBAAgB,kBAAkB,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CASvD"}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Classify a plugin install target as npm, git, or a local path.
|
|
3
|
+
* @category CLI
|
|
4
|
+
*/
|
|
5
|
+
export function pluginSourceKind(spec) {
|
|
6
|
+
if (/^git(\+ssh|\+https)?:/i.test(spec) || /github\.com[:/]/i.test(spec) || spec.endsWith(".git")) {
|
|
7
|
+
return "git";
|
|
8
|
+
}
|
|
9
|
+
if (spec.startsWith(".") ||
|
|
10
|
+
spec.startsWith("/") ||
|
|
11
|
+
spec.startsWith("file:") ||
|
|
12
|
+
/^[a-zA-Z]:[\\/]/.test(spec)) {
|
|
13
|
+
return "path";
|
|
14
|
+
}
|
|
15
|
+
return "npm";
|
|
16
|
+
}
|
|
17
|
+
/**
|
|
18
|
+
* Package name from an install spec (`@scope/name@version` or a bare name).
|
|
19
|
+
* @category CLI
|
|
20
|
+
*/
|
|
21
|
+
export function pluginNameFromSpec(spec) {
|
|
22
|
+
if (pluginSourceKind(spec) !== "npm")
|
|
23
|
+
return spec;
|
|
24
|
+
if (spec.startsWith("@")) {
|
|
25
|
+
const rest = spec.slice(1);
|
|
26
|
+
const at = rest.lastIndexOf("@");
|
|
27
|
+
return at > 0 ? `@${rest.slice(0, at)}` : spec;
|
|
28
|
+
}
|
|
29
|
+
const at = spec.lastIndexOf("@");
|
|
30
|
+
return at > 0 ? spec.slice(0, at) : spec;
|
|
31
|
+
}
|
|
32
|
+
//# sourceMappingURL=plugin-source.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"plugin-source.js","sourceRoot":"","sources":["../../src/lib/plugin-source.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,MAAM,UAAU,gBAAgB,CAAC,IAAY;IAC3C,IAAI,wBAAwB,CAAC,IAAI,CAAC,IAAI,CAAC,IAAI,kBAAkB,CAAC,IAAI,CAAC,IAAI,CAAC,IAAI,IAAI,CAAC,QAAQ,CAAC,MAAM,CAAC,EAAE,CAAC;QAClG,OAAO,KAAK,CAAA;IACd,CAAC;IACD,IACE,IAAI,CAAC,UAAU,CAAC,GAAG,CAAC;QACpB,IAAI,CAAC,UAAU,CAAC,GAAG,CAAC;QACpB,IAAI,CAAC,UAAU,CAAC,OAAO,CAAC;QACxB,iBAAiB,CAAC,IAAI,CAAC,IAAI,CAAC,EAC5B,CAAC;QACD,OAAO,MAAM,CAAA;IACf,CAAC;IACD,OAAO,KAAK,CAAA;AACd,CAAC;AAED;;;GAGG;AACH,MAAM,UAAU,kBAAkB,CAAC,IAAY;IAC7C,IAAI,gBAAgB,CAAC,IAAI,CAAC,KAAK,KAAK;QAAE,OAAO,IAAI,CAAA;IACjD,IAAI,IAAI,CAAC,UAAU,CAAC,GAAG,CAAC,EAAE,CAAC;QACzB,MAAM,IAAI,GAAG,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,CAAA;QAC1B,MAAM,EAAE,GAAG,IAAI,CAAC,WAAW,CAAC,GAAG,CAAC,CAAA;QAChC,OAAO,EAAE,GAAG,CAAC,CAAC,CAAC,CAAC,IAAI,IAAI,CAAC,KAAK,CAAC,CAAC,EAAE,EAAE,CAAC,EAAE,CAAC,CAAC,CAAC,IAAI,CAAA;IAChD,CAAC;IACD,MAAM,EAAE,GAAG,IAAI,CAAC,WAAW,CAAC,GAAG,CAAC,CAAA;IAChC,OAAO,EAAE,GAAG,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,CAAC,IAAI,CAAA;AAC1C,CAAC"}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import type { Interfaces } from "@oclif/core";
|
|
2
|
+
import type { Ecp, LoadedWorkflow } from "@executioncontrolprotocol/core";
|
|
3
|
+
import { type RunResult } from "@executioncontrolprotocol/core/types";
|
|
4
|
+
import { type EcpHost } from "@executioncontrolprotocol/plugin-sdk";
|
|
5
|
+
/**
|
|
6
|
+
* Load a workflow file, optionally install missing plugins, and layer the environment.
|
|
7
|
+
* @category CLI
|
|
8
|
+
*/
|
|
9
|
+
export declare function prepareWorkflowRun(options: {
|
|
10
|
+
workflowPath: string;
|
|
11
|
+
envFlag?: string;
|
|
12
|
+
config: Interfaces.Config;
|
|
13
|
+
argv: string[];
|
|
14
|
+
json: boolean;
|
|
15
|
+
host?: EcpHost;
|
|
16
|
+
install: boolean;
|
|
17
|
+
}): Promise<{
|
|
18
|
+
loaded: LoadedWorkflow;
|
|
19
|
+
ecp: Ecp;
|
|
20
|
+
terminate: boolean;
|
|
21
|
+
}>;
|
|
22
|
+
/**
|
|
23
|
+
* Map a non-completed run to a CLI error. `stopped` is success (Phase 4 PR 2).
|
|
24
|
+
* @category CLI
|
|
25
|
+
*/
|
|
26
|
+
export declare function throwIfRunFailed(result: RunResult): RunResult;
|
|
27
|
+
//# sourceMappingURL=prepare-workflow.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"prepare-workflow.d.ts","sourceRoot":"","sources":["../../src/lib/prepare-workflow.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,aAAa,CAAA;AAC7C,OAAO,KAAK,EAAE,GAAG,EAAE,cAAc,EAAE,MAAM,gCAAgC,CAAA;AACzE,OAAO,EAKL,KAAK,SAAS,EACf,MAAM,sCAAsC,CAAA;AAE7C,OAAO,EAKL,KAAK,OAAO,EACb,MAAM,sCAAsC,CAAA;AAiB7C;;;GAGG;AACH,wBAAsB,kBAAkB,CAAC,OAAO,EAAE;IAChD,YAAY,EAAE,MAAM,CAAA;IACpB,OAAO,CAAC,EAAE,MAAM,CAAA;IAChB,MAAM,EAAE,UAAU,CAAC,MAAM,CAAA;IACzB,IAAI,EAAE,MAAM,EAAE,CAAA;IACd,IAAI,EAAE,OAAO,CAAA;IACb,IAAI,CAAC,EAAE,OAAO,CAAA;IACd,OAAO,EAAE,OAAO,CAAA;CACjB,GAAG,OAAO,CAAC;IAAE,MAAM,EAAE,cAAc,CAAC;IAAC,GAAG,EAAE,GAAG,CAAC;IAAC,SAAS,EAAE,OAAO,CAAA;CAAE,CAAC,CA0BpE;AAED;;;GAGG;AACH,wBAAgB,gBAAgB,CAAC,MAAM,EAAE,SAAS,GAAG,SAAS,CAwB7D"}
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
import { ECP_RUN_PAUSED, ECP_STEP_FAILED, ECP_WORKFLOW_LOAD, EcpError, } from "@executioncontrolprotocol/core/types";
|
|
2
|
+
import { loadWorkflowFile } from "@executioncontrolprotocol/node";
|
|
3
|
+
import { EcpCliError, EXIT_FAILED, EXIT_PAUSED, EXIT_USAGE, } from "@executioncontrolprotocol/plugin-sdk";
|
|
4
|
+
import { ensurePluginsInstalled } from "./ensure-plugins.js";
|
|
5
|
+
import { layerRunEnvironment } from "./layer-environment.js";
|
|
6
|
+
function asCliError(err) {
|
|
7
|
+
if (err instanceof EcpCliError)
|
|
8
|
+
throw err;
|
|
9
|
+
if (err instanceof EcpError) {
|
|
10
|
+
throw new EcpCliError(err.code, err.message, {
|
|
11
|
+
path: err.path,
|
|
12
|
+
suggestions: err.suggestions,
|
|
13
|
+
exitCode: err.code === ECP_WORKFLOW_LOAD ? EXIT_USAGE : EXIT_FAILED,
|
|
14
|
+
details: err.details,
|
|
15
|
+
});
|
|
16
|
+
}
|
|
17
|
+
throw err;
|
|
18
|
+
}
|
|
19
|
+
/**
|
|
20
|
+
* Load a workflow file, optionally install missing plugins, and layer the environment.
|
|
21
|
+
* @category CLI
|
|
22
|
+
*/
|
|
23
|
+
export async function prepareWorkflowRun(options) {
|
|
24
|
+
let loaded;
|
|
25
|
+
try {
|
|
26
|
+
loaded = await loadWorkflowFile(options.workflowPath);
|
|
27
|
+
}
|
|
28
|
+
catch (err) {
|
|
29
|
+
asCliError(err);
|
|
30
|
+
}
|
|
31
|
+
const host = await ensurePluginsInstalled({
|
|
32
|
+
requirements: loaded.requirements,
|
|
33
|
+
config: options.config,
|
|
34
|
+
argv: options.argv,
|
|
35
|
+
json: options.json,
|
|
36
|
+
install: options.install,
|
|
37
|
+
host: options.host,
|
|
38
|
+
});
|
|
39
|
+
try {
|
|
40
|
+
const layered = await layerRunEnvironment({
|
|
41
|
+
envFlag: options.envFlag,
|
|
42
|
+
workflowBindings: loaded.builder?.getBindings(),
|
|
43
|
+
config: options.config,
|
|
44
|
+
host: host ?? options.host,
|
|
45
|
+
});
|
|
46
|
+
return { loaded, ...layered };
|
|
47
|
+
}
|
|
48
|
+
catch (err) {
|
|
49
|
+
asCliError(err);
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
/**
|
|
53
|
+
* Map a non-completed run to a CLI error. `stopped` is success (Phase 4 PR 2).
|
|
54
|
+
* @category CLI
|
|
55
|
+
*/
|
|
56
|
+
export function throwIfRunFailed(result) {
|
|
57
|
+
const status = result.run.status;
|
|
58
|
+
if (status === "completed" || status === "stopped")
|
|
59
|
+
return result;
|
|
60
|
+
if (status === "paused") {
|
|
61
|
+
const diagnostic = Object.values(result.history ?? {})
|
|
62
|
+
.flatMap((step) => step.diagnostics ?? [])
|
|
63
|
+
.find((issue) => issue.code === ECP_RUN_PAUSED) ?? {
|
|
64
|
+
code: ECP_RUN_PAUSED,
|
|
65
|
+
message: `Workflow run paused. Resume with ecp runs resume ${result.run.id}`,
|
|
66
|
+
};
|
|
67
|
+
throw new EcpCliError(diagnostic.code ?? ECP_RUN_PAUSED, diagnostic.message, {
|
|
68
|
+
path: diagnostic.path,
|
|
69
|
+
suggestions: diagnostic.suggestions ?? [`ecp runs resume ${result.run.id}`],
|
|
70
|
+
exitCode: EXIT_PAUSED,
|
|
71
|
+
});
|
|
72
|
+
}
|
|
73
|
+
const diagnostic = Object.values(result.history ?? {}).flatMap((step) => step.diagnostics ?? [])[0];
|
|
74
|
+
throw new EcpCliError(diagnostic?.code ?? ECP_STEP_FAILED, diagnostic?.message ?? `Workflow run did not complete (status: ${status})`, { path: diagnostic?.path, suggestions: diagnostic?.suggestions, exitCode: EXIT_FAILED });
|
|
75
|
+
}
|
|
76
|
+
//# sourceMappingURL=prepare-workflow.js.map
|
|
@@ -0,0 +1 @@
|
|
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,CAAC,UAAU,CAAC,IAAI,IAAI,cAAc,EAAE,UAAU,CAAC,OAAO,EAAE;YAC3E,IAAI,EAAE,UAAU,CAAC,IAAI;YACrB,WAAW,EAAE,UAAU,CAAC,WAAW,IAAI,CAAC,mBAAmB,MAAM,CAAC,GAAG,CAAC,EAAE,EAAE,CAAC;YAC3E,QAAQ,EAAE,WAAW;SACtB,CAAC,CAAA;IACJ,CAAC;IACD,MAAM,UAAU,GAAG,MAAM,CAAC,MAAM,CAAC,MAAM,CAAC,OAAO,IAAI,EAAE,CAAC,CAAC,OAAO,CAC5D,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,CAAC,WAAW,IAAI,EAAE,CACjC,CAAC,CAAC,CAAC,CAAA;IACJ,MAAM,IAAI,WAAW,CACnB,UAAU,EAAE,IAAI,IAAI,eAAe,EACnC,UAAU,EAAE,OAAO,IAAI,0CAA0C,MAAM,GAAG,EAC1E,EAAE,IAAI,EAAE,UAAU,EAAE,IAAI,EAAE,WAAW,EAAE,UAAU,EAAE,WAAW,EAAE,QAAQ,EAAE,WAAW,EAAE,CACxF,CAAA;AACH,CAAC"}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import type { Interfaces } from "@oclif/core";
|
|
2
|
+
import { type RunOptions } from "@executioncontrolprotocol/core";
|
|
3
|
+
import { type JournalRunDocument, type WorkflowManifest } from "@executioncontrolprotocol/core/types";
|
|
4
|
+
import { listRunJournals, readRunJournal, readStepJournal, runsRoot } from "@executioncontrolprotocol/node";
|
|
5
|
+
/**
|
|
6
|
+
* SHA-256 of a workflow file's bytes.
|
|
7
|
+
* @category CLI
|
|
8
|
+
*/
|
|
9
|
+
export declare function hashWorkflowSource(source: string): string;
|
|
10
|
+
/**
|
|
11
|
+
* Installed plugin versions from the oclif config.
|
|
12
|
+
* @category CLI
|
|
13
|
+
*/
|
|
14
|
+
export declare function pluginVersions(config: Interfaces.Config): Record<string, string>;
|
|
15
|
+
/**
|
|
16
|
+
* Build resume/rerun `ecp.run` options from a parent journal.
|
|
17
|
+
* @category CLI
|
|
18
|
+
*/
|
|
19
|
+
export declare function runOptionsFromJournal(options: {
|
|
20
|
+
parent: JournalRunDocument;
|
|
21
|
+
workflow: WorkflowManifest;
|
|
22
|
+
fromStepId?: string;
|
|
23
|
+
toStepId?: string;
|
|
24
|
+
approve?: boolean;
|
|
25
|
+
mode: "resume" | "rerun";
|
|
26
|
+
}): Promise<Pick<RunOptions, "seedState" | "seedHistory" | "stopAfterStepId" | "onlyStepId" | "approvals" | "input">>;
|
|
27
|
+
export { listRunJournals, readRunJournal, readStepJournal, runsRoot };
|
|
28
|
+
/** Re-export for tests. @category CLI */
|
|
29
|
+
export declare function loadParentRun(runId: string): Promise<JournalRunDocument>;
|
|
30
|
+
//# sourceMappingURL=runs-io.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"runs-io.d.ts","sourceRoot":"","sources":["../../src/lib/runs-io.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,aAAa,CAAA;AAC7C,OAAO,EAA8B,KAAK,UAAU,EAAE,MAAM,gCAAgC,CAAA;AAC5F,OAAO,EAGL,KAAK,kBAAkB,EAIvB,KAAK,gBAAgB,EACtB,MAAM,sCAAsC,CAAA;AAC7C,OAAO,EAEL,eAAe,EACf,cAAc,EACd,eAAe,EAEf,QAAQ,EACT,MAAM,gCAAgC,CAAA;AAGvC;;;GAGG;AACH,wBAAgB,kBAAkB,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,CAEzD;AAED;;;GAGG;AACH,wBAAgB,cAAc,CAAC,MAAM,EAAE,UAAU,CAAC,MAAM,GAAG,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAMhF;AAuED;;;GAGG;AACH,wBAAsB,qBAAqB,CAAC,OAAO,EAAE;IACnD,MAAM,EAAE,kBAAkB,CAAA;IAC1B,QAAQ,EAAE,gBAAgB,CAAA;IAC1B,UAAU,CAAC,EAAE,MAAM,CAAA;IACnB,QAAQ,CAAC,EAAE,MAAM,CAAA;IACjB,OAAO,CAAC,EAAE,OAAO,CAAA;IACjB,IAAI,EAAE,QAAQ,GAAG,OAAO,CAAA;CACzB,GAAG,OAAO,CAAC,IAAI,CACd,UAAU,EACR,WAAW,GACX,aAAa,GACb,iBAAiB,GACjB,YAAY,GACZ,WAAW,GACX,OAAO,CACV,CAAC,CAoED;AAED,OAAO,EAAE,eAAe,EAAE,cAAc,EAAE,eAAe,EAAE,QAAQ,EAAE,CAAA;AAErE,yCAAyC;AACzC,wBAAsB,aAAa,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO,CAAC,kBAAkB,CAAC,CAQ9E"}
|
|
@@ -0,0 +1,154 @@
|
|
|
1
|
+
import { readdir } from "node:fs/promises";
|
|
2
|
+
import { createHash } from "node:crypto";
|
|
3
|
+
import { join } from "node:path";
|
|
4
|
+
import { findStep, flattenStepOrder } from "@executioncontrolprotocol/core";
|
|
5
|
+
import { ECP_RERUN_INCOMPATIBLE, EcpError, } from "@executioncontrolprotocol/core/types";
|
|
6
|
+
import { hashStepDefinition, listRunJournals, readRunJournal, readStepJournal, runDir, runsRoot, } from "@executioncontrolprotocol/node";
|
|
7
|
+
import { EcpCliError, EXIT_USAGE } from "@executioncontrolprotocol/plugin-sdk";
|
|
8
|
+
/**
|
|
9
|
+
* SHA-256 of a workflow file's bytes.
|
|
10
|
+
* @category CLI
|
|
11
|
+
*/
|
|
12
|
+
export function hashWorkflowSource(source) {
|
|
13
|
+
return createHash("sha256").update(source).digest("hex");
|
|
14
|
+
}
|
|
15
|
+
/**
|
|
16
|
+
* Installed plugin versions from the oclif config.
|
|
17
|
+
* @category CLI
|
|
18
|
+
*/
|
|
19
|
+
export function pluginVersions(config) {
|
|
20
|
+
const out = {};
|
|
21
|
+
for (const plugin of config.getPluginsList()) {
|
|
22
|
+
if (plugin.version)
|
|
23
|
+
out[plugin.name] = plugin.version;
|
|
24
|
+
}
|
|
25
|
+
return out;
|
|
26
|
+
}
|
|
27
|
+
async function loadStepDocs(runId) {
|
|
28
|
+
const dir = runDir(runId);
|
|
29
|
+
let names;
|
|
30
|
+
try {
|
|
31
|
+
names = await readdir(joinSteps(dir));
|
|
32
|
+
}
|
|
33
|
+
catch {
|
|
34
|
+
return [];
|
|
35
|
+
}
|
|
36
|
+
const docs = [];
|
|
37
|
+
for (const name of names) {
|
|
38
|
+
if (!name.endsWith(".json"))
|
|
39
|
+
continue;
|
|
40
|
+
docs.push(await readStepJournal(runId, name.replace(/\.json$/, "")));
|
|
41
|
+
}
|
|
42
|
+
return docs;
|
|
43
|
+
}
|
|
44
|
+
function joinSteps(dir) {
|
|
45
|
+
return join(dir, "steps");
|
|
46
|
+
}
|
|
47
|
+
function restoredHistory(workflow, steps, beforeStepId) {
|
|
48
|
+
const order = flattenStepOrder(workflow.steps);
|
|
49
|
+
const cut = beforeStepId ? order.findIndex((s) => s.id === beforeStepId) : order.length;
|
|
50
|
+
const history = {};
|
|
51
|
+
let state = {};
|
|
52
|
+
for (let i = 0; i < cut; i++) {
|
|
53
|
+
const step = order[i];
|
|
54
|
+
const doc = steps.find((s) => s.stepId === step.id && s.status === "completed");
|
|
55
|
+
if (!doc)
|
|
56
|
+
continue;
|
|
57
|
+
history[step.id] = {
|
|
58
|
+
status: "completed",
|
|
59
|
+
output: doc.output,
|
|
60
|
+
};
|
|
61
|
+
if (doc.committedState && typeof doc.committedState === "object") {
|
|
62
|
+
state = { ...doc.committedState };
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
return { history, state };
|
|
66
|
+
}
|
|
67
|
+
function assertCompatible(workflow, steps, restoredIds) {
|
|
68
|
+
for (const id of restoredIds) {
|
|
69
|
+
const current = findStep(workflow, id);
|
|
70
|
+
const recorded = steps.find((s) => s.stepId === id);
|
|
71
|
+
if (!current || !recorded) {
|
|
72
|
+
throw new EcpError(ECP_RERUN_INCOMPATIBLE, `Step ${id} cannot be restored from the journal`, { suggestions: ["Run the workflow from the start", "Use an earlier --from"] });
|
|
73
|
+
}
|
|
74
|
+
if (recorded.definitionHash && recorded.definitionHash !== hashStepDefinition(current)) {
|
|
75
|
+
throw new EcpError(ECP_RERUN_INCOMPATIBLE, `Step ${id} changed since the journal was written`, { suggestions: ["Run the workflow from the start", `Use --from before ${id}`] });
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
/**
|
|
80
|
+
* Build resume/rerun `ecp.run` options from a parent journal.
|
|
81
|
+
* @category CLI
|
|
82
|
+
*/
|
|
83
|
+
export async function runOptionsFromJournal(options) {
|
|
84
|
+
const steps = await loadStepDocs(options.parent.runId);
|
|
85
|
+
if (options.mode === "resume") {
|
|
86
|
+
if (options.parent.status !== "stopped" && options.parent.status !== "paused") {
|
|
87
|
+
throw new EcpCliError("ECP_INPUT_INVALID", `Run ${options.parent.runId} is ${options.parent.status}; resume needs stopped or paused`, { exitCode: EXIT_USAGE });
|
|
88
|
+
}
|
|
89
|
+
const restoredIds = flattenStepOrder(options.workflow.steps)
|
|
90
|
+
.filter((s) => steps.some((d) => d.stepId === s.id && d.status === "completed"))
|
|
91
|
+
.map((s) => s.id);
|
|
92
|
+
assertCompatible(options.workflow, steps, restoredIds);
|
|
93
|
+
const { history, state } = restoredHistory(options.workflow, steps);
|
|
94
|
+
const pausedStepId = options.parent.cursor ??
|
|
95
|
+
steps.find((s) => s.status === "paused")?.stepId ??
|
|
96
|
+
restoredIds[restoredIds.length - 1] ??
|
|
97
|
+
"";
|
|
98
|
+
const approvals = options.approve
|
|
99
|
+
? [
|
|
100
|
+
{
|
|
101
|
+
stepId: pausedStepId,
|
|
102
|
+
approvedBy: "cli",
|
|
103
|
+
at: new Date().toISOString(),
|
|
104
|
+
},
|
|
105
|
+
]
|
|
106
|
+
: options.parent.approvals;
|
|
107
|
+
return {
|
|
108
|
+
input: options.parent.input,
|
|
109
|
+
seedState: state,
|
|
110
|
+
seedHistory: history,
|
|
111
|
+
stopAfterStepId: options.toStepId,
|
|
112
|
+
approvals,
|
|
113
|
+
};
|
|
114
|
+
}
|
|
115
|
+
const order = flattenStepOrder(options.workflow.steps);
|
|
116
|
+
const fromId = options.fromStepId ??
|
|
117
|
+
order.find((s) => steps.find((d) => d.stepId === s.id)?.status === "failed")?.id;
|
|
118
|
+
if (!fromId) {
|
|
119
|
+
throw new EcpCliError("ECP_INPUT_INVALID", "No failed step to rerun; pass --from", {
|
|
120
|
+
exitCode: EXIT_USAGE,
|
|
121
|
+
});
|
|
122
|
+
}
|
|
123
|
+
if (!findStep(options.workflow, fromId)) {
|
|
124
|
+
throw new EcpCliError("ECP_INPUT_INVALID", `Unknown step id: ${fromId}`, {
|
|
125
|
+
exitCode: EXIT_USAGE,
|
|
126
|
+
});
|
|
127
|
+
}
|
|
128
|
+
const restoredIds = order
|
|
129
|
+
.slice(0, order.findIndex((s) => s.id === fromId))
|
|
130
|
+
.map((s) => s.id);
|
|
131
|
+
assertCompatible(options.workflow, steps, restoredIds);
|
|
132
|
+
const { history, state } = restoredHistory(options.workflow, steps, fromId);
|
|
133
|
+
const only = options.toStepId && options.toStepId === fromId ? fromId : undefined;
|
|
134
|
+
return {
|
|
135
|
+
input: options.parent.input,
|
|
136
|
+
seedState: state,
|
|
137
|
+
seedHistory: history,
|
|
138
|
+
stopAfterStepId: only ? undefined : options.toStepId,
|
|
139
|
+
onlyStepId: only,
|
|
140
|
+
};
|
|
141
|
+
}
|
|
142
|
+
export { listRunJournals, readRunJournal, readStepJournal, runsRoot };
|
|
143
|
+
/** Re-export for tests. @category CLI */
|
|
144
|
+
export async function loadParentRun(runId) {
|
|
145
|
+
try {
|
|
146
|
+
return await readRunJournal(runId);
|
|
147
|
+
}
|
|
148
|
+
catch {
|
|
149
|
+
throw new EcpCliError("ECP_INPUT_INVALID", `Unknown run id: ${runId}`, {
|
|
150
|
+
exitCode: EXIT_USAGE,
|
|
151
|
+
});
|
|
152
|
+
}
|
|
153
|
+
}
|
|
154
|
+
//# sourceMappingURL=runs-io.js.map
|