akm-cli 0.9.2-alpha.4 → 0.9.2
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/CHANGELOG.md +493 -0
- package/STABILITY.md +23 -5
- package/dist/assets/hints/cli-hints-full.md +12 -7
- package/dist/assets/tasks/core/extract.yml +3 -5
- package/dist/assets/tasks/core/improve.yml +3 -5
- package/dist/assets/tasks/core/index-refresh.yml +3 -5
- package/dist/assets/tasks/core/sync.yml +3 -5
- package/dist/assets/tasks/core/version-check.yml +3 -5
- package/dist/assets/tasks/improve/akm-graph-refresh-weekly.yml +3 -5
- package/dist/assets/tasks/improve/akm-improve-catchup.yml +6 -6
- package/dist/assets/tasks/improve/akm-improve-consolidate.yml +3 -5
- package/dist/assets/tasks/improve/akm-improve-frequent.yml +3 -5
- package/dist/assets/tasks/improve/akm-improve-nightly.yml +3 -5
- package/dist/cli/unknown-flags.js +12 -1
- package/dist/cli.js +8 -1
- package/dist/commands/command/command-execution.js +23 -2
- package/dist/commands/health/improve-metrics.js +38 -0
- package/dist/commands/health/windows.js +8 -4
- package/dist/commands/health.js +8 -4
- package/dist/commands/lint/index.js +1 -1
- package/dist/commands/migrate-cli.js +130 -24
- package/dist/commands/proposal/validators/proposal-validators.js +7 -2
- package/dist/commands/tasks/explain.js +304 -0
- package/dist/commands/tasks/tasks-cli.js +185 -3
- package/dist/commands/tasks/tasks.js +265 -52
- package/dist/commands/workflow/plan.js +159 -0
- package/dist/commands/workflow-cli.js +94 -2
- package/dist/core/activation-policy.js +2 -12
- package/dist/core/adapter/adapters/akm-lint.js +7 -4
- package/dist/core/adapter/adapters/akm-metadata.js +26 -14
- package/dist/core/adapter/adapters/akm-task-adapter.js +13 -10
- package/dist/core/errors.js +45 -0
- package/dist/core/json-schema.js +15 -5
- package/dist/core/state/migrations.js +57 -0
- package/dist/core/state-db.js +16 -14
- package/dist/core/subprocess.js +47 -13
- package/dist/execution/guarded-source.js +44 -0
- package/dist/execution/input-contract.js +250 -0
- package/dist/execution/target-ref.js +63 -0
- package/dist/indexer/usage/usage-events.js +14 -3
- package/dist/integrations/agent/execution-lowering.js +12 -1
- package/dist/output/shapes/passthrough.js +2 -0
- package/dist/output/text/helpers.js +1 -1
- package/dist/output/text/migrate.js +12 -3
- package/dist/output/text/workflow-format.js +192 -10
- package/dist/output/text/workflow.js +2 -1
- package/dist/runtime.js +1 -0
- package/dist/scripts/akm-migrate-node.js +11838 -10118
- package/dist/scripts/akm-migrate.js +11828 -10117
- package/dist/setup/steps/tasks.js +34 -17
- package/dist/storage/repositories/task-history-repository.js +5 -1
- package/dist/storage/repositories/workflow-runs-repository.js +144 -6
- package/dist/tasks/backends/launchd.js +31 -84
- package/dist/tasks/embedded.js +13 -7
- package/dist/tasks/model/invocation.js +4 -0
- package/dist/tasks/prepare/prepare-script-target.js +9 -0
- package/dist/tasks/prepare/prepare-support.js +154 -0
- package/dist/tasks/prepare/prepare.js +117 -0
- package/dist/tasks/prepare/prepared-execution.js +4 -0
- package/dist/tasks/prepare/script-capture.js +80 -0
- package/dist/tasks/run/attempt-lifecycle.js +165 -0
- package/dist/tasks/run/load-task.js +117 -0
- package/dist/tasks/run/provenance.js +20 -0
- package/dist/tasks/run/run-command-task.js +92 -0
- package/dist/tasks/run/run-native-task.js +222 -0
- package/dist/tasks/run/run-task.js +99 -0
- package/dist/tasks/run/run-workflow-task.js +222 -0
- package/dist/tasks/run/task-history.js +134 -0
- package/dist/tasks/run/task-log.js +179 -0
- package/dist/tasks/run/task-result.js +19 -0
- package/dist/tasks/scheduler-binding.js +66 -2
- package/dist/tasks/scheduler-invocation.js +63 -3
- package/dist/tasks/scheduler-sync.js +77 -14
- package/dist/tasks/source/bounded-document.js +455 -0
- package/dist/tasks/source/parse-task-source.js +59 -0
- package/dist/tasks/source/project-v4.js +62 -0
- package/dist/tasks/source/task-input-diagnostics.js +36 -0
- package/dist/tasks/source/task-source-v4.js +626 -0
- package/dist/tasks/source-v3.js +10 -733
- package/dist/tasks/task-run-reserved-flags.js +79 -0
- package/dist/workflows/authoring/authoring.js +17 -8
- package/dist/workflows/exec/child-invocation.js +34 -0
- package/dist/workflows/exec/child-workflow.js +370 -0
- package/dist/workflows/exec/exec-unit.js +50 -170
- package/dist/workflows/exec/frozen-judge.js +19 -2
- package/dist/workflows/exec/native-executor.js +49 -27
- package/dist/workflows/exec/param-secrets.js +12 -0
- package/dist/workflows/exec/run-workflow.js +48 -59
- package/dist/workflows/exec/step-work.js +222 -80
- package/dist/workflows/exec/unit-dispatch.js +72 -0
- package/dist/workflows/freeze/child-output-references.js +94 -0
- package/dist/workflows/freeze/environment.js +174 -0
- package/dist/workflows/freeze/identity.js +22 -0
- package/dist/workflows/freeze/resolve-steps.js +78 -0
- package/dist/workflows/freeze/source-freeze.js +57 -0
- package/dist/workflows/freeze/step-values.js +68 -0
- package/dist/workflows/freeze/targets/child-workflow.js +206 -0
- package/dist/workflows/freeze/targets/command.js +81 -0
- package/dist/workflows/freeze/targets/script.js +57 -0
- package/dist/workflows/freeze/targets/shell.js +31 -0
- package/dist/workflows/freeze/targets/task.js +179 -0
- package/dist/workflows/freeze/task-bindings.js +180 -0
- package/dist/workflows/ir/compile.js +59 -11
- package/dist/workflows/ir/environment-v4.js +3 -3
- package/dist/workflows/ir/freeze-v4.js +41 -7
- package/dist/workflows/ir/params.js +58 -131
- package/dist/workflows/ir/plan-hash.js +3 -3
- package/dist/workflows/ir/schema-v4.js +246 -17
- package/dist/workflows/parser.js +74 -2
- package/dist/workflows/program/schema.js +5 -2
- package/dist/workflows/resource-limits.js +20 -0
- package/dist/workflows/runtime/plan-classifier.js +24 -7
- package/dist/workflows/runtime/run-outputs.js +103 -0
- package/dist/workflows/runtime/runs.js +114 -9
- package/dist/workflows/runtime/workflow-asset-loader.js +14 -6
- package/dist/workflows/source-files.js +5 -5
- package/dist/workflows/source-ir/compare.js +17 -0
- package/dist/workflows/source-ir/compile.js +7 -3
- package/dist/workflows/source-ir/github-yaml.js +64 -17
- package/dist/workflows/source-ir/schema.js +69 -21
- package/dist/workflows/source-ir/semantics.js +7 -25
- package/dist/workflows/source-ir/triggers.js +79 -0
- package/dist/workflows/source-ir/uses.js +33 -7
- package/docs/migration/README.md +1 -1
- package/docs/migration/release-notes/0.9.2.md +87 -11
- package/docs/migration/release-notes/README.md +3 -2
- package/docs/migration/v0.8-to-v0.9.md +13 -11
- package/docs/migration/v0.9.0-troubleshooting.md +20 -13
- package/docs/migration/v0.9.1-to-v0.9.2.md +598 -49
- package/docs/reference/README.md +1 -1
- package/docs/reference/cli.md +140 -46
- package/docs/reference/configuration.md +6 -5
- package/docs/reference/supported-formats.md +9 -5
- package/docs/reference/tasks.md +338 -75
- package/docs/reference/workflow-schema.md +290 -16
- package/docs/reference/workflows.md +57 -7
- package/package.json +1 -1
- package/schemas/akm-task.json +173 -118
- package/schemas/akm-workflow.json +28 -0
- package/dist/tasks/runner.js +0 -941
- package/dist/tasks/runtime-v3.js +0 -281
- package/dist/workflows/ir/source-freeze-v4.js +0 -506
- package/dist/workflows/source-ir/ordering.js +0 -38
package/dist/tasks/runtime-v3.js
DELETED
|
@@ -1,281 +0,0 @@
|
|
|
1
|
-
// This Source Code Form is subject to the terms of the Mozilla Public
|
|
2
|
-
// License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
3
|
-
// file, You can obtain one at https://mozilla.org/MPL/2.0/.
|
|
4
|
-
/**
|
|
5
|
-
* Pure task-v3 runtime projection.
|
|
6
|
-
*
|
|
7
|
-
* This is the only bridge from authored task-v3 source into executable work.
|
|
8
|
-
* It performs all source/config/asset reads before the task runner reserves a
|
|
9
|
-
* durable attempt and returns immutable snapshots. In particular, script work
|
|
10
|
-
* contains frozen bytes and their digest, never a path that can be reread when
|
|
11
|
-
* a delayed or resumed dispatch begins.
|
|
12
|
-
*/
|
|
13
|
-
import { createHash } from "node:crypto";
|
|
14
|
-
import fs from "node:fs";
|
|
15
|
-
import path from "node:path";
|
|
16
|
-
import { prepareCommandInvocation, } from "../commands/command/command-execution.js";
|
|
17
|
-
import { makeBundleRef, parseBundleRef } from "../core/asset/asset-ref.js";
|
|
18
|
-
import { ConfigError, NotFoundError, UsageError } from "../core/errors.js";
|
|
19
|
-
import { DURATION_UNITS, parseDuration } from "../core/time.js";
|
|
20
|
-
import { captureFrozenDirectoryIdentity } from "../execution/directory-identity.js";
|
|
21
|
-
import { isPortableExecutionAgentSelector } from "../execution/source.js";
|
|
22
|
-
import { requireAuthorizedExecutionPlan } from "../integrations/agent/execution-cascade.js";
|
|
23
|
-
import { lowerResolvedExecutionRequest } from "../integrations/agent/execution-lowering.js";
|
|
24
|
-
import { resolveAssetPath } from "../sources/resolve.js";
|
|
25
|
-
import { detectSecretShapedParams } from "../workflows/exec/param-secrets.js";
|
|
26
|
-
import { compileWorkflowPlan } from "../workflows/ir/compile.js";
|
|
27
|
-
import { compileWorkflowSource } from "../workflows/source-ir/compile.js";
|
|
28
|
-
import { isInferredSecretName } from "./log-redaction.js";
|
|
29
|
-
import { isBunStandaloneMain } from "./resolve-akm-bin.js";
|
|
30
|
-
import { SCHEDULED_TASK_CONTEXT_KEYS } from "./scheduler-invocation.js";
|
|
31
|
-
const SCRIPT_INTERPRETERS = Object.freeze({
|
|
32
|
-
".sh": "sh",
|
|
33
|
-
".ts": "bun",
|
|
34
|
-
".js": "bun",
|
|
35
|
-
".ps1": "powershell",
|
|
36
|
-
".cmd": "cmd",
|
|
37
|
-
".bat": "cmd",
|
|
38
|
-
".py": "python",
|
|
39
|
-
".rb": "ruby",
|
|
40
|
-
".go": "go",
|
|
41
|
-
".pl": "perl",
|
|
42
|
-
".php": "php",
|
|
43
|
-
".lua": "lua",
|
|
44
|
-
".r": "rscript",
|
|
45
|
-
".swift": "swift",
|
|
46
|
-
".kt": "kotlin",
|
|
47
|
-
".kts": "kotlin",
|
|
48
|
-
});
|
|
49
|
-
function own(value, key) {
|
|
50
|
-
return value !== undefined && Object.hasOwn(value, key);
|
|
51
|
-
}
|
|
52
|
-
function environmentSnapshot(environment) {
|
|
53
|
-
const out = Object.create(null);
|
|
54
|
-
for (const key of Object.keys(environment ?? {}).sort()) {
|
|
55
|
-
const raw = environment?.[key];
|
|
56
|
-
if (raw === undefined)
|
|
57
|
-
continue;
|
|
58
|
-
const value = String(raw);
|
|
59
|
-
if (isInferredSecretName(key) || detectSecretShapedParams({ [key]: value }).length > 0) {
|
|
60
|
-
throw new UsageError(`Task v3 env.${key} is a secret-shaped literal env value. Store credentials in a secret/env binding rather than durable task source.`, "INVALID_FLAG_VALUE");
|
|
61
|
-
}
|
|
62
|
-
Object.defineProperty(out, key, { value, enumerable: true, configurable: false, writable: false });
|
|
63
|
-
}
|
|
64
|
-
return Object.freeze(out);
|
|
65
|
-
}
|
|
66
|
-
/** Merge source env with the authoritative, closed scheduler directory context. */
|
|
67
|
-
function commandEnvironmentSnapshot(environment, schedulerContext) {
|
|
68
|
-
const out = Object.create(null);
|
|
69
|
-
for (const key of Object.keys(environment)) {
|
|
70
|
-
Object.defineProperty(out, key, { value: environment[key], enumerable: true, configurable: true, writable: true });
|
|
71
|
-
}
|
|
72
|
-
for (const key of SCHEDULED_TASK_CONTEXT_KEYS) {
|
|
73
|
-
const value = schedulerContext?.[key];
|
|
74
|
-
if (!value)
|
|
75
|
-
continue;
|
|
76
|
-
Object.defineProperty(out, key, { value, enumerable: true, configurable: true, writable: true });
|
|
77
|
-
}
|
|
78
|
-
return Object.freeze(out);
|
|
79
|
-
}
|
|
80
|
-
function normalizeTimeout(value) {
|
|
81
|
-
if (value === undefined || value === null || typeof value === "number")
|
|
82
|
-
return value;
|
|
83
|
-
const parsed = parseDuration(value, DURATION_UNITS);
|
|
84
|
-
if (parsed === null)
|
|
85
|
-
throw new UsageError(`Invalid task timeout ${JSON.stringify(value)}.`, "INVALID_FLAG_VALUE");
|
|
86
|
-
return parsed;
|
|
87
|
-
}
|
|
88
|
-
function qualifyOwnedRef(ref, context) {
|
|
89
|
-
const parsed = parseBundleRef(ref);
|
|
90
|
-
const bundle = parsed.bundle ?? context.bundleName;
|
|
91
|
-
return { parsed, qualified: makeBundleRef(bundle, parsed.conceptId) };
|
|
92
|
-
}
|
|
93
|
-
function currentExecutionValues(document, context, environment) {
|
|
94
|
-
const akm = document.akm;
|
|
95
|
-
const agent = akm?.agent;
|
|
96
|
-
return Object.freeze({
|
|
97
|
-
...(own(akm, "agent")
|
|
98
|
-
? {
|
|
99
|
-
agent: typeof agent === "string" && isPortableExecutionAgentSelector(agent)
|
|
100
|
-
? qualifyOwnedRef(agent, context).qualified
|
|
101
|
-
: agent,
|
|
102
|
-
}
|
|
103
|
-
: {}),
|
|
104
|
-
...(own(akm, "engine") ? { engine: akm?.engine } : {}),
|
|
105
|
-
...(own(akm, "model") ? { model: akm?.model } : {}),
|
|
106
|
-
...(own(akm, "inference") ? { inference: akm?.inference } : {}),
|
|
107
|
-
...(own(akm, "outputSchema") ? { outputSchema: akm?.outputSchema } : {}),
|
|
108
|
-
...(own(akm, "tools") ? { tools: akm?.tools } : {}),
|
|
109
|
-
...(own(akm, "timeout") ? { timeout: akm?.timeout } : {}),
|
|
110
|
-
workspace: context.bundleRoot,
|
|
111
|
-
environment,
|
|
112
|
-
});
|
|
113
|
-
}
|
|
114
|
-
function base(document, context, environment) {
|
|
115
|
-
const timeoutMs = normalizeTimeout(document.akm?.timeout);
|
|
116
|
-
return Object.freeze({
|
|
117
|
-
taskId: context.taskId,
|
|
118
|
-
taskRef: context.taskRef,
|
|
119
|
-
enabled: document.akm?.enabled !== false,
|
|
120
|
-
environment,
|
|
121
|
-
...(timeoutMs !== undefined ? { timeoutMs } : {}),
|
|
122
|
-
redact: Object.freeze([...(document.akm?.redact ?? [])]),
|
|
123
|
-
});
|
|
124
|
-
}
|
|
125
|
-
async function resolvedOwnedAsset(qualified, type, context) {
|
|
126
|
-
const parsed = parseBundleRef(qualified);
|
|
127
|
-
const prefix = `${type}s/`;
|
|
128
|
-
const name = parsed.conceptId.slice(prefix.length);
|
|
129
|
-
if (context.resolveAsset) {
|
|
130
|
-
const resolved = await context.resolveAsset({ bundle: parsed.bundle, type, name, ref: qualified });
|
|
131
|
-
return typeof resolved === "string"
|
|
132
|
-
? Object.freeze({ file: resolved, bundleRoot: context.bundleRoot })
|
|
133
|
-
: Object.freeze({ file: resolved.file, bundleRoot: resolved.bundleRoot });
|
|
134
|
-
}
|
|
135
|
-
if (parsed.bundle !== context.bundleName) {
|
|
136
|
-
throw new NotFoundError(`Task target ${JSON.stringify(qualified)} names bundle ${JSON.stringify(parsed.bundle)}, but no bundle resolver was provided.`, "ASSET_NOT_FOUND");
|
|
137
|
-
}
|
|
138
|
-
return Object.freeze({
|
|
139
|
-
file: await resolveAssetPath(context.bundleRoot, type, name),
|
|
140
|
-
bundleRoot: context.bundleRoot,
|
|
141
|
-
});
|
|
142
|
-
}
|
|
143
|
-
function scriptInterpreter(extension, ref) {
|
|
144
|
-
const interpreter = SCRIPT_INTERPRETERS[extension];
|
|
145
|
-
if (!interpreter) {
|
|
146
|
-
throw new UsageError(`Task v3 script target ${JSON.stringify(ref)} has no closed runtime interpreter for extension ${JSON.stringify(extension)}.`, "INVALID_FLAG_VALUE");
|
|
147
|
-
}
|
|
148
|
-
if (interpreter !== "bun")
|
|
149
|
-
return interpreter;
|
|
150
|
-
if (!process.versions.bun) {
|
|
151
|
-
throw new UsageError(`Task v3 script target ${JSON.stringify(ref)} requires Bun for ${extension} execution, but this runtime cannot provide it.`, "INVALID_FLAG_VALUE");
|
|
152
|
-
}
|
|
153
|
-
return isBunStandaloneMain() ? "bun-standalone" : "bun";
|
|
154
|
-
}
|
|
155
|
-
function captureDirectoryIdentity(bundleRoot, workingDirectory) {
|
|
156
|
-
try {
|
|
157
|
-
return captureFrozenDirectoryIdentity(bundleRoot, workingDirectory);
|
|
158
|
-
}
|
|
159
|
-
catch (cause) {
|
|
160
|
-
if (cause instanceof UsageError)
|
|
161
|
-
throw cause;
|
|
162
|
-
throw new UsageError(`Task working directory ${JSON.stringify(workingDirectory ?? ".")} cannot be physically verified: ${cause instanceof Error ? cause.message : String(cause)}`, "INVALID_FLAG_VALUE");
|
|
163
|
-
}
|
|
164
|
-
}
|
|
165
|
-
function defaultTaskShell(platform) {
|
|
166
|
-
return platform === "win32" ? "powershell" : "sh";
|
|
167
|
-
}
|
|
168
|
-
function validatePreparedCommand(invocation, context) {
|
|
169
|
-
const request = requireAuthorizedExecutionPlan(invocation.plan);
|
|
170
|
-
if (!request.engine.name) {
|
|
171
|
-
throw new ConfigError(`Task ${JSON.stringify(context.taskRef)} has no resolved execution engine. Configure defaults.engine or akm.engine before running it.`, "INVALID_CONFIG_FILE");
|
|
172
|
-
}
|
|
173
|
-
// Lowering is pure. Running it before the durable-attempt boundary proves
|
|
174
|
-
// the selected target is transport-projectable; dispatch repeats the same
|
|
175
|
-
// deterministic projection from this frozen request/config snapshot.
|
|
176
|
-
lowerResolvedExecutionRequest(request, invocation.config);
|
|
177
|
-
return invocation;
|
|
178
|
-
}
|
|
179
|
-
function validateWorkflowRuntimeSource(file, workspaceRoot, readFile) {
|
|
180
|
-
const source = new TextDecoder("utf-8", { fatal: true, ignoreBOM: true }).decode(readFile(file, workspaceRoot));
|
|
181
|
-
const compiled = compileWorkflowSource(source, { path: file, workspaceRoot });
|
|
182
|
-
if (!compiled.ok) {
|
|
183
|
-
const detail = compiled.errors.map((error) => `${error.path}:${error.line}: ${error.message}`).join("; ");
|
|
184
|
-
throw new UsageError(`Task workflow target is not projectable: ${detail}`, "INVALID_FLAG_VALUE");
|
|
185
|
-
}
|
|
186
|
-
const planned = compileWorkflowPlan(compiled.ir, path.basename(file, path.extname(file)));
|
|
187
|
-
if (!planned.ok) {
|
|
188
|
-
const detail = planned.errors.map((error) => `${file}:${error.line}: ${error.message}`).join("; ");
|
|
189
|
-
throw new UsageError(`Task workflow target is not projectable: ${detail}`, "INVALID_FLAG_VALUE");
|
|
190
|
-
}
|
|
191
|
-
}
|
|
192
|
-
/** Project one canonical task-v3 source into immutable executable work. */
|
|
193
|
-
export async function prepareTaskV3Execution(document, context) {
|
|
194
|
-
const environment = environmentSnapshot(document.env);
|
|
195
|
-
const commandEnvironment = commandEnvironmentSnapshot(environment, context.schedulerContext);
|
|
196
|
-
const common = base(document, context, environment);
|
|
197
|
-
if (document.target.kind === "run") {
|
|
198
|
-
const cwdIdentity = captureDirectoryIdentity(context.bundleRoot, document.target.workingDirectory);
|
|
199
|
-
return Object.freeze({
|
|
200
|
-
...common,
|
|
201
|
-
kind: "shell",
|
|
202
|
-
command: document.target.run,
|
|
203
|
-
shell: document.target.shell ?? defaultTaskShell(context.platform ?? process.platform),
|
|
204
|
-
cwd: cwdIdentity.realCwd,
|
|
205
|
-
cwdIdentity,
|
|
206
|
-
});
|
|
207
|
-
}
|
|
208
|
-
const target = document.target.uses;
|
|
209
|
-
if (target.kind === "github-action") {
|
|
210
|
-
throw new UsageError(`GitHub action ${JSON.stringify(target.ref)} is recognized but remote action acquisition is unsupported in 0.9.2.`, "INVALID_FLAG_VALUE");
|
|
211
|
-
}
|
|
212
|
-
if (target.kind === "builtin-command") {
|
|
213
|
-
const command = document.target.command;
|
|
214
|
-
if (!command)
|
|
215
|
-
throw new Error("invariant: parsed built-in command target has no command action");
|
|
216
|
-
const action = command.kind === "stored"
|
|
217
|
-
? {
|
|
218
|
-
ref: qualifyOwnedRef(command.ref, context).qualified,
|
|
219
|
-
...(command.arguments !== undefined ? { arguments: command.arguments } : {}),
|
|
220
|
-
}
|
|
221
|
-
: { content: command.content, ...(command.arguments !== undefined ? { arguments: command.arguments } : {}) };
|
|
222
|
-
const invocation = validatePreparedCommand(await (context.prepareCommand ?? prepareCommandInvocation)({
|
|
223
|
-
action,
|
|
224
|
-
config: context.config,
|
|
225
|
-
invocationKind: "task",
|
|
226
|
-
current: currentExecutionValues(document, context, commandEnvironment),
|
|
227
|
-
...(context.commandSourceLoader ? { sourceLoader: context.commandSourceLoader } : {}),
|
|
228
|
-
}), context);
|
|
229
|
-
return Object.freeze({ ...common, kind: "command", invocation });
|
|
230
|
-
}
|
|
231
|
-
const { qualified } = qualifyOwnedRef(target.ref, context);
|
|
232
|
-
if (target.kind === "command") {
|
|
233
|
-
if (document.target.with !== undefined) {
|
|
234
|
-
throw new UsageError("Task v3 command refs do not accept with; use akm/command with {ref, arguments} for portable arguments.", "INVALID_FLAG_VALUE");
|
|
235
|
-
}
|
|
236
|
-
const invocation = validatePreparedCommand(await (context.prepareCommand ?? prepareCommandInvocation)({
|
|
237
|
-
action: { ref: qualified },
|
|
238
|
-
config: context.config,
|
|
239
|
-
invocationKind: "task",
|
|
240
|
-
current: currentExecutionValues(document, context, commandEnvironment),
|
|
241
|
-
...(context.commandSourceLoader ? { sourceLoader: context.commandSourceLoader } : {}),
|
|
242
|
-
}), context);
|
|
243
|
-
return Object.freeze({ ...common, kind: "command", invocation });
|
|
244
|
-
}
|
|
245
|
-
if (target.kind === "workflow") {
|
|
246
|
-
if (Object.keys(environment).length > 0) {
|
|
247
|
-
throw new UsageError("Task v3 workflow env cannot be consumed by the durable workflow runtime in 0.9.2; remove env or use a command target.", "INVALID_FLAG_VALUE");
|
|
248
|
-
}
|
|
249
|
-
const resolved = await resolvedOwnedAsset(qualified, "workflow", context);
|
|
250
|
-
validateWorkflowRuntimeSource(resolved.file, resolved.bundleRoot, context.readFile ?? ((targetPath) => fs.readFileSync(targetPath)));
|
|
251
|
-
return Object.freeze({
|
|
252
|
-
...common,
|
|
253
|
-
kind: "workflow",
|
|
254
|
-
ref: qualified,
|
|
255
|
-
params: Object.freeze({ ...(document.target.with ?? {}) }),
|
|
256
|
-
...(document.akm?.maxSteps !== undefined ? { maxSteps: document.akm.maxSteps } : {}),
|
|
257
|
-
...(document.akm?.maxRetries !== undefined ? { maxRetries: document.akm.maxRetries } : {}),
|
|
258
|
-
});
|
|
259
|
-
}
|
|
260
|
-
if (document.target.with !== undefined) {
|
|
261
|
-
throw new UsageError("Task v3 script refs do not accept with.", "INVALID_FLAG_VALUE");
|
|
262
|
-
}
|
|
263
|
-
const resolved = await resolvedOwnedAsset(qualified, "script", context);
|
|
264
|
-
const file = resolved.file;
|
|
265
|
-
const extension = path.extname(file).toLowerCase();
|
|
266
|
-
const raw = (context.readFile ?? ((targetPath) => fs.readFileSync(targetPath)))(file, resolved.bundleRoot);
|
|
267
|
-
const bytes = Uint8Array.from(raw);
|
|
268
|
-
const cwdIdentity = captureDirectoryIdentity(resolved.bundleRoot);
|
|
269
|
-
return Object.freeze({
|
|
270
|
-
...common,
|
|
271
|
-
kind: "script",
|
|
272
|
-
sourceRef: qualified,
|
|
273
|
-
interpreter: scriptInterpreter(extension, qualified),
|
|
274
|
-
extension,
|
|
275
|
-
bytesBase64: Buffer.from(bytes).toString("base64"),
|
|
276
|
-
byteLength: bytes.byteLength,
|
|
277
|
-
sha256: createHash("sha256").update(bytes).digest("hex"),
|
|
278
|
-
cwd: cwdIdentity.realCwd,
|
|
279
|
-
cwdIdentity,
|
|
280
|
-
});
|
|
281
|
-
}
|