@deksden-com/dd-flow-cli 0.9.0-beta.8 → 0.9.0-beta.80
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 +396 -0
- package/README.md +65 -0
- package/dist/build-info.json +8 -8
- package/dist/cli/command-inputs.js +300 -0
- package/dist/cli/help.js +81 -9
- package/dist/cli/hook-ingress.js +82 -0
- package/dist/cli/input-preparation.js +115 -0
- package/dist/cli/run-cli.js +1342 -375
- package/dist/cli.js +6 -2
- package/dist/harness-runtime/bin/dd-agy.mjs +37 -0
- package/dist/harness-runtime/bin/dd-codex.mjs +25 -0
- package/dist/harness-runtime/bin/dd-droid.mjs +33 -0
- package/dist/harness-runtime/bin/dd-grok.mjs +30 -0
- package/dist/harness-runtime/bin/dd-opencode.mjs +21 -0
- package/dist/harness-runtime/bin/dd-zcode.mjs +83 -0
- package/dist/harness-runtime/lib/daemon-operations.mjs +215 -0
- package/dist/harness-runtime/lib/dd-agy-daemon.mjs +423 -0
- package/dist/harness-runtime/lib/dd-agy.mjs +59 -0
- package/dist/harness-runtime/lib/dd-codex-daemon.d.mts +1 -0
- package/dist/harness-runtime/lib/dd-codex-daemon.mjs +146 -0
- package/dist/harness-runtime/lib/dd-codex.mjs +562 -0
- package/dist/harness-runtime/lib/dd-droid-daemon.mjs +125 -0
- package/dist/harness-runtime/lib/dd-droid.mjs +471 -0
- package/dist/harness-runtime/lib/dd-grok-daemon.mjs +274 -0
- package/dist/harness-runtime/lib/dd-grok.mjs +174 -0
- package/dist/harness-runtime/lib/dd-opencode-daemon.mjs +198 -0
- package/dist/harness-runtime/lib/dd-opencode.mjs +98 -0
- package/dist/harness-runtime/lib/dd-zcode-daemon.mjs +644 -0
- package/dist/harness-runtime/lib/dd-zcode.mjs +910 -0
- package/dist/harness-runtime/lib/delegation-instructions.d.mts +10 -0
- package/dist/harness-runtime/lib/delegation-instructions.mjs +130 -0
- package/dist/harness-runtime/lib/dispatch-fence.mjs +14 -0
- package/dist/harness-runtime/lib/driver-recovery.mjs +129 -0
- package/dist/harness-runtime/lib/droid-observation.mjs +66 -0
- package/dist/harness-runtime/lib/managed-daemon.mjs +260 -0
- package/dist/harness-runtime/lib/model-observations.mjs +77 -0
- package/dist/harness-runtime/lib/native-hook-command.d.mts +1 -0
- package/dist/harness-runtime/lib/native-hook-command.mjs +34 -0
- package/dist/harness-runtime/lib/observation-clock.mjs +36 -0
- package/dist/harness-runtime/lib/operation-context.mjs +5 -0
- package/dist/harness-runtime/lib/operation-errors.mjs +19 -0
- package/dist/harness-runtime/lib/process-json.mjs +70 -0
- package/dist/harness-runtime/lib/process-snapshot.mjs +10 -0
- package/dist/harness-runtime/lib/runner-events.mjs +200 -0
- package/dist/harness-runtime/lib/runner-lock.mjs +42 -0
- package/dist/harness-runtime/lib/session-settlement.mjs +30 -0
- package/dist/harness-runtime/lib/tool-observations.d.mts +17 -0
- package/dist/harness-runtime/lib/tool-observations.mjs +153 -0
- package/dist/schemas/agent-profile.schema.json +1 -1
- package/dist/schemas/code-review-result.schema.json +2 -2
- package/dist/schemas/code-work-batch.schema.json +4 -3
- package/dist/schemas/code-work-result.schema.json +4 -4
- package/dist/schemas/plan-review-result.schema.json +2 -2
- package/dist/schemas/run-control-receipt.schema.json +99 -0
- package/dist/schemas/run-control-request.schema.json +36 -0
- package/dist/schemas/vnext-protocol-plan.schema.json +2 -2
- package/dist/services/canon.js +11 -8
- package/dist/services/cleanup.js +57 -13
- package/dist/services/cli-operation-classifier.js +22 -24
- package/dist/services/code-checks.js +543 -96
- package/dist/services/codex-hook-delivery.js +28 -0
- package/dist/services/config.js +11 -8
- package/dist/services/controller-fanout.js +116 -0
- package/dist/services/dashboard.js +103 -31
- package/dist/services/engines.js +121 -76
- package/dist/services/eval-snapshots.js +750 -73
- package/dist/services/execution-policy.js +170 -0
- package/dist/services/external-work-launch.js +110 -0
- package/dist/services/harness-adapter.js +147 -24
- package/dist/services/harness-config.js +2 -0
- package/dist/services/hooks.js +553 -285
- package/dist/services/lanes.js +61 -53
- package/dist/services/lifecycle-command.js +87 -7
- package/dist/services/lifecycle-invocations.js +828 -0
- package/dist/services/managed-daemon-binding.js +38 -0
- package/dist/services/managed-processes.js +283 -27
- package/dist/services/merge-queue.js +179 -104
- package/dist/services/merge-server.js +73 -28
- package/dist/services/migrations.js +14 -9
- package/dist/services/native-daemon-history.js +49 -0
- package/dist/services/native-session-control.js +39 -0
- package/dist/services/plan-runtime.js +19 -8
- package/dist/services/plans.js +28 -25
- package/dist/services/projects.js +18 -5
- package/dist/services/prompts.js +23 -16
- package/dist/services/protocols.js +64 -20
- package/dist/services/recovery-observation-budget.js +61 -0
- package/dist/services/recovery-snapshot-database.js +107 -0
- package/dist/services/run-control-receipt.js +56 -0
- package/dist/services/run-control-worker.js +363 -0
- package/dist/services/run-control.js +876 -0
- package/dist/services/run-controller-adapter.js +222 -0
- package/dist/services/run-controller-capture.js +134 -0
- package/dist/services/run-controller-process.js +189 -0
- package/dist/services/run-controller-recovery.js +222 -0
- package/dist/services/run-controller-state.js +36 -0
- package/dist/services/run-controller.js +779 -0
- package/dist/services/run-engine-bindings.js +1 -1
- package/dist/services/run-fork.js +138 -0
- package/dist/services/run-observations.js +112 -0
- package/dist/services/run-recovery-runtime.js +69 -0
- package/dist/services/run-recovery.js +342 -0
- package/dist/services/runs.js +368 -74
- package/dist/services/runtime-budget.js +434 -0
- package/dist/services/runtime-scope-capture.js +50 -0
- package/dist/services/runtime-scope-control.js +450 -0
- package/dist/services/runtime-scope-resume.js +565 -0
- package/dist/services/runtime-scope-stop.js +99 -0
- package/dist/services/runtime-scope-worker.js +243 -0
- package/dist/services/runtime-service.js +97 -0
- package/dist/services/schema-validation.js +10 -8
- package/dist/services/sessions.js +35 -69
- package/dist/services/stage-blocker.js +17 -7
- package/dist/services/stage-context.js +44 -18
- package/dist/services/stage-lifecycle.js +99 -102
- package/dist/services/stage-pause.js +65 -23
- package/dist/services/usage.js +37 -93
- package/dist/services/vnext-code-review.js +189 -85
- package/dist/services/vnext-code.js +257 -243
- package/dist/services/vnext-execution-profile.js +5 -3
- package/dist/services/vnext-fanout.js +134 -19
- package/dist/services/vnext-merge.js +285 -102
- package/dist/services/vnext-plan-review.js +148 -94
- package/dist/services/vnext-plan.js +141 -72
- package/dist/services/vnext-protocolize.js +129 -56
- package/dist/services/vnext-specify.js +87 -64
- package/dist/services/work-registry.js +707 -156
- package/dist/services/workspace-bootstrap.js +76 -0
- package/dist/services/worktrees.js +85 -35
- package/dist/shared/errors.js +12 -0
- package/dist/storage/database.js +444 -32
- package/dist/storage/paths.js +17 -4
- package/dist/storage/writer-contract.js +77 -0
- package/dist/storage/writer-migration.js +102 -0
- package/package.json +11 -4
- package/tools/repair-paused-run-status.mjs +59 -0
|
@@ -0,0 +1,115 @@
|
|
|
1
|
+
import fs from "node:fs";
|
|
2
|
+
import path from "node:path";
|
|
3
|
+
import { AppError, isAppError } from "../shared/errors.js";
|
|
4
|
+
import { validateSchema } from "../services/schema-validation.js";
|
|
5
|
+
export function prepareError(error, input = {}) {
|
|
6
|
+
if (isAppError(error)) {
|
|
7
|
+
// A malformed user input is safely correctable. A broken schema registry,
|
|
8
|
+
// binding, or storage is not; do not disguise infrastructure damage as a
|
|
9
|
+
// retryable command typo.
|
|
10
|
+
const inputErrorCodes = new Set([
|
|
11
|
+
"usage", "validation", "schema_validation", "invalid_json", "not_found",
|
|
12
|
+
"path_escape", "input_file_missing", "input_file_not_regular", "input_file_unreadable",
|
|
13
|
+
"response_file_parent_invalid", "response_file_invalid", "context_checksum_mismatch", "invalid_run_config_state", "invalid_work_state", "invalid_stage_state", "runtime_budget_invalid", "runtime_scope_manifest_invalid", "runtime_scope_resume_invalid",
|
|
14
|
+
"fork_path_conflict", "fork_output_not_empty", "fork_checkpoint_invalid", "fork_engine_unavailable", "snapshot_missing",
|
|
15
|
+
"repair_check_declaration_missing", "review_repair_check_required", "review_check_reference_unknown", "semantic_status_inconsistent", "migration_report_invalid", "controller_context_missing", "snapshot_output_inside_runtime"
|
|
16
|
+
]);
|
|
17
|
+
if (!inputErrorCodes.has(error.code) && error.details.phase !== "prepare")
|
|
18
|
+
throw error;
|
|
19
|
+
throw new AppError(error.code, error.message, 2, {
|
|
20
|
+
...error.details,
|
|
21
|
+
phase: "prepare",
|
|
22
|
+
effect: "no_effect",
|
|
23
|
+
recoverable: true,
|
|
24
|
+
...input
|
|
25
|
+
});
|
|
26
|
+
}
|
|
27
|
+
const code = error?.code;
|
|
28
|
+
if (typeof input.file !== "string" || !["ENOENT", "EACCES", "EPERM", "EISDIR", "ENOTDIR", "ELOOP", "ENAMETOOLONG"].includes(code ?? ""))
|
|
29
|
+
throw error;
|
|
30
|
+
throw new AppError("input_file_unreadable", `Cannot read input file${typeof input.file === "string" ? `: ${input.file}` : ""}`, 2, {
|
|
31
|
+
phase: "prepare", effect: "no_effect", recoverable: true, ...input, cause: code ?? String(error)
|
|
32
|
+
});
|
|
33
|
+
}
|
|
34
|
+
export function prepareTextFile(file, label = "input file") {
|
|
35
|
+
const prepared = prepareFileBytes(file, label);
|
|
36
|
+
return { file: prepared.file, text: prepared.bytes.toString("utf8") };
|
|
37
|
+
}
|
|
38
|
+
export function prepareFileBytes(file, label = "input file") {
|
|
39
|
+
const absolute = path.resolve(file);
|
|
40
|
+
let descriptor;
|
|
41
|
+
try {
|
|
42
|
+
descriptor = fs.openSync(absolute, fs.constants.O_RDONLY | fs.constants.O_NONBLOCK);
|
|
43
|
+
const stat = fs.fstatSync(descriptor);
|
|
44
|
+
if (!stat.isFile()) {
|
|
45
|
+
throw new AppError("input_file_not_regular", `${label} must be a readable regular file: ${absolute}`, 2, { file: absolute, label });
|
|
46
|
+
}
|
|
47
|
+
return { file: absolute, bytes: fs.readFileSync(descriptor) };
|
|
48
|
+
}
|
|
49
|
+
catch (error) {
|
|
50
|
+
if (error?.code === "ENOENT") {
|
|
51
|
+
throw new AppError("input_file_missing", `${label} does not exist: ${absolute}`, 2, {
|
|
52
|
+
phase: "prepare", effect: "no_effect", recoverable: true, file: absolute, label
|
|
53
|
+
});
|
|
54
|
+
}
|
|
55
|
+
return prepareError(error, { file: absolute, label });
|
|
56
|
+
}
|
|
57
|
+
finally {
|
|
58
|
+
if (descriptor !== undefined)
|
|
59
|
+
fs.closeSync(descriptor);
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
export function prepareJsonText(text, input) {
|
|
63
|
+
try {
|
|
64
|
+
return { file: input.file, text, value: JSON.parse(text) };
|
|
65
|
+
}
|
|
66
|
+
catch {
|
|
67
|
+
// Keep the established public code so agents can recognise this as a
|
|
68
|
+
// safe correction-and-retry condition.
|
|
69
|
+
throw new AppError("invalid_json", `Invalid JSON in ${input.label ?? "input"}: ${input.file}`, 2, {
|
|
70
|
+
phase: "prepare", effect: "no_effect", recoverable: true, file: input.file, label: input.label ?? "input",
|
|
71
|
+
cause: "Invalid JSON syntax"
|
|
72
|
+
});
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
export function prepareJsonFile(file, label = "input JSON") {
|
|
76
|
+
const prepared = prepareTextFile(file, label);
|
|
77
|
+
return prepareJsonText(prepared.text, { file: prepared.file, label });
|
|
78
|
+
}
|
|
79
|
+
export function prepareJsonSchema(file, label, schema) {
|
|
80
|
+
const prepared = prepareJsonFile(file, label);
|
|
81
|
+
try {
|
|
82
|
+
validateSchema({ ...schema, file: prepared.file, data: prepared.value });
|
|
83
|
+
}
|
|
84
|
+
catch (error) {
|
|
85
|
+
return prepareError(error, { file: prepared.file, label });
|
|
86
|
+
}
|
|
87
|
+
return prepared;
|
|
88
|
+
}
|
|
89
|
+
/** Read-only destination check; execution still handles filesystem races. */
|
|
90
|
+
export function prepareOutputFile(value) { return prepareOutput(value, false); }
|
|
91
|
+
export function prepareOutputDirectory(value) { return prepareOutput(value, true); }
|
|
92
|
+
function prepareOutput(value, directory) {
|
|
93
|
+
const file = path.resolve(value);
|
|
94
|
+
try {
|
|
95
|
+
let ancestor = directory ? file : path.dirname(file);
|
|
96
|
+
while (!fs.existsSync(ancestor) && path.dirname(ancestor) !== ancestor)
|
|
97
|
+
ancestor = path.dirname(ancestor);
|
|
98
|
+
if (!fs.statSync(ancestor).isDirectory())
|
|
99
|
+
throw new AppError("validation", "Output parent must be a directory", 2);
|
|
100
|
+
fs.accessSync(ancestor, fs.constants.W_OK | fs.constants.X_OK);
|
|
101
|
+
if (fs.existsSync(file)) {
|
|
102
|
+
const stat = fs.statSync(file);
|
|
103
|
+
if (directory ? !stat.isDirectory() : !stat.isFile())
|
|
104
|
+
throw new AppError("validation", directory ? "Output must name a directory" : "Output must name a regular file", 2);
|
|
105
|
+
fs.accessSync(file, fs.constants.W_OK | (directory ? fs.constants.X_OK : 0));
|
|
106
|
+
}
|
|
107
|
+
return file;
|
|
108
|
+
}
|
|
109
|
+
catch (error) {
|
|
110
|
+
const code = error?.code;
|
|
111
|
+
if (["ENOENT", "EACCES", "EPERM", "ENOTDIR", "ELOOP", "ENAMETOOLONG"].includes(code ?? ""))
|
|
112
|
+
return prepareError(new AppError("validation", "Output destination is not writable or has an invalid parent", 2, { cause: code }), { file, parameter: "output" });
|
|
113
|
+
return prepareError(error, { file, parameter: "output" });
|
|
114
|
+
}
|
|
115
|
+
}
|