agentweaver 0.1.14 → 0.1.16
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 +29 -7
- package/dist/artifact-manifest.js +219 -0
- package/dist/artifacts.js +21 -1
- package/dist/doctor/checks/cwd-context.js +4 -3
- package/dist/doctor/checks/env-diagnostics.js +193 -71
- package/dist/doctor/checks/flow-readiness.js +212 -203
- package/dist/doctor/index.js +1 -1
- package/dist/doctor/orchestrator.js +18 -7
- package/dist/doctor/runner.js +9 -8
- package/dist/doctor/types.js +12 -0
- package/dist/flow-state.js +75 -15
- package/dist/index.js +499 -199
- package/dist/interactive/blessed-session.js +361 -0
- package/dist/interactive/controller.js +1293 -0
- package/dist/interactive/create-interactive-session.js +5 -0
- package/dist/interactive/ink/index.js +576 -0
- package/dist/interactive/progress.js +245 -0
- package/dist/interactive/selectors.js +14 -0
- package/dist/interactive/session.js +1 -0
- package/dist/interactive/state.js +34 -0
- package/dist/interactive/tree.js +155 -0
- package/dist/interactive/types.js +1 -0
- package/dist/interactive/view-model.js +1 -0
- package/dist/interactive-ui.js +159 -194
- package/dist/pipeline/context.js +1 -0
- package/dist/pipeline/declarative-flow-runner.js +212 -6
- package/dist/pipeline/declarative-flows.js +27 -0
- package/dist/pipeline/execution-routing-config.js +15 -0
- package/dist/pipeline/flow-catalog.js +23 -3
- package/dist/pipeline/flow-run-resume.js +29 -0
- package/dist/pipeline/flow-specs/auto-common.json +89 -360
- package/dist/pipeline/flow-specs/auto-golang.json +58 -363
- package/dist/pipeline/flow-specs/auto-simple.json +141 -0
- package/dist/pipeline/flow-specs/bugz/bug-analyze.json +2 -0
- package/dist/pipeline/flow-specs/bugz/bug-fix.json +1 -0
- package/dist/pipeline/flow-specs/design-review/design-review-loop.json +304 -0
- package/dist/pipeline/flow-specs/design-review.json +249 -0
- package/dist/pipeline/flow-specs/gitlab/gitlab-diff-review.json +11 -0
- package/dist/pipeline/flow-specs/gitlab/gitlab-review.json +2 -0
- package/dist/pipeline/flow-specs/gitlab/mr-description.json +1 -0
- package/dist/pipeline/flow-specs/go/run-go-linter-loop.json +2 -0
- package/dist/pipeline/flow-specs/go/run-go-tests-loop.json +2 -0
- package/dist/pipeline/flow-specs/implement.json +24 -5
- package/dist/pipeline/flow-specs/instant-task.json +177 -0
- package/dist/pipeline/flow-specs/normalize-task-source.json +311 -0
- package/dist/pipeline/flow-specs/plan-revise.json +267 -0
- package/dist/pipeline/flow-specs/plan.json +48 -70
- package/dist/pipeline/flow-specs/review/review-fix.json +24 -4
- package/dist/pipeline/flow-specs/review/review-loop.json +351 -45
- package/dist/pipeline/flow-specs/review/review-project-loop.json +590 -0
- package/dist/pipeline/flow-specs/review/review-project.json +12 -0
- package/dist/pipeline/flow-specs/review/review.json +37 -31
- package/dist/pipeline/flow-specs/task-describe.json +62 -2
- package/dist/pipeline/flow-specs/task-source/jira-fetch.json +70 -0
- package/dist/pipeline/flow-specs/task-source/manual-input.json +216 -0
- package/dist/pipeline/node-registry.js +49 -1
- package/dist/pipeline/node-runner.js +3 -2
- package/dist/pipeline/nodes/build-review-fix-prompt-node.js +5 -1
- package/dist/pipeline/nodes/clear-ready-to-merge-node.js +11 -0
- package/dist/pipeline/nodes/commit-message-form-node.js +8 -0
- package/dist/pipeline/nodes/design-review-verdict-node.js +36 -0
- package/dist/pipeline/nodes/ensure-summary-json-node.js +70 -0
- package/dist/pipeline/nodes/fetch-gitlab-diff-node.js +19 -2
- package/dist/pipeline/nodes/fetch-gitlab-review-node.js +19 -2
- package/dist/pipeline/nodes/flow-run-node.js +226 -7
- package/dist/pipeline/nodes/git-commit-form-node.js +8 -0
- package/dist/pipeline/nodes/gitlab-review-artifacts-node.js +19 -2
- package/dist/pipeline/nodes/jira-fetch-node.js +50 -4
- package/dist/pipeline/nodes/llm-prompt-node.js +32 -12
- package/dist/pipeline/nodes/planning-bundle-node.js +10 -0
- package/dist/pipeline/nodes/review-verdict-node.js +86 -0
- package/dist/pipeline/nodes/select-files-form-node.js +8 -0
- package/dist/pipeline/nodes/structured-summary-node.js +24 -0
- package/dist/pipeline/nodes/user-input-node.js +38 -3
- package/dist/pipeline/nodes/write-selection-file-node.js +20 -4
- package/dist/pipeline/prompt-registry.js +5 -1
- package/dist/pipeline/prompt-runtime.js +4 -1
- package/dist/pipeline/review-iteration.js +26 -0
- package/dist/pipeline/spec-compiler.js +2 -0
- package/dist/pipeline/spec-types.js +5 -0
- package/dist/pipeline/spec-validator.js +14 -0
- package/dist/pipeline/value-resolver.js +84 -1
- package/dist/prompts.js +82 -13
- package/dist/review-severity.js +45 -0
- package/dist/runtime/artifact-registry.js +402 -0
- package/dist/runtime/design-review-input-contract.js +113 -0
- package/dist/runtime/env-loader.js +3 -0
- package/dist/runtime/execution-routing-store.js +134 -0
- package/dist/runtime/execution-routing.js +227 -0
- package/dist/runtime/interactive-execution-routing.js +462 -0
- package/dist/runtime/plan-revise-input-contract.js +147 -0
- package/dist/runtime/planning-bundle.js +123 -0
- package/dist/runtime/ready-to-merge.js +31 -0
- package/dist/runtime/review-input-contract.js +100 -0
- package/dist/scope.js +11 -2
- package/dist/structured-artifact-schema-registry.js +10 -0
- package/dist/structured-artifact-schemas.json +257 -1
- package/dist/structured-artifacts.js +83 -6
- package/dist/user-input.js +70 -3
- package/package.json +6 -3
package/dist/flow-state.js
CHANGED
|
@@ -1,16 +1,27 @@
|
|
|
1
|
+
import { randomUUID } from "node:crypto";
|
|
1
2
|
import { existsSync, readFileSync, rmSync, writeFileSync } from "node:fs";
|
|
2
3
|
import { ensureScopeWorkspaceDir, flowStateFile } from "./artifacts.js";
|
|
3
4
|
import { TaskRunnerError } from "./errors.js";
|
|
4
|
-
|
|
5
|
+
import { isFlowRunResumeEnvelope } from "./pipeline/flow-run-resume.js";
|
|
6
|
+
import { resolveStoredExecutionRoutingSnapshot, singleLaunchProfileExecutionRouting } from "./runtime/execution-routing.js";
|
|
7
|
+
const FLOW_STATE_SCHEMA_VERSION = 2;
|
|
5
8
|
function nowIso8601() {
|
|
6
9
|
return new Date().toISOString();
|
|
7
10
|
}
|
|
11
|
+
function ensurePublicationRunId(executionState) {
|
|
12
|
+
executionState.publicationRunId ??= randomUUID();
|
|
13
|
+
return executionState.publicationRunId;
|
|
14
|
+
}
|
|
8
15
|
export function stripExecutionStatePayload(executionState) {
|
|
16
|
+
ensurePublicationRunId(executionState);
|
|
9
17
|
return {
|
|
18
|
+
...(executionState.runId ? { runId: executionState.runId } : {}),
|
|
19
|
+
...(executionState.publicationRunId ? { publicationRunId: executionState.publicationRunId } : {}),
|
|
10
20
|
flowKind: executionState.flowKind,
|
|
11
21
|
flowVersion: executionState.flowVersion,
|
|
12
22
|
terminated: executionState.terminated,
|
|
13
23
|
...(executionState.terminationReason ? { terminationReason: executionState.terminationReason } : {}),
|
|
24
|
+
...(executionState.terminationOutcome ? { terminationOutcome: executionState.terminationOutcome } : {}),
|
|
14
25
|
phases: executionState.phases.map((phase) => ({
|
|
15
26
|
id: phase.id,
|
|
16
27
|
status: phase.status,
|
|
@@ -22,6 +33,7 @@ export function stripExecutionStatePayload(executionState) {
|
|
|
22
33
|
status: step.status,
|
|
23
34
|
...(step.outputs ? { outputs: step.outputs } : {}),
|
|
24
35
|
...(step.value !== undefined ? { value: step.value } : {}),
|
|
36
|
+
...(step.publishedArtifacts ? { publishedArtifacts: step.publishedArtifacts } : {}),
|
|
25
37
|
...(step.startedAt ? { startedAt: step.startedAt } : {}),
|
|
26
38
|
...(step.finishedAt ? { finishedAt: step.finishedAt } : {}),
|
|
27
39
|
...(step.stopFlow !== undefined ? { stopFlow: step.stopFlow } : {}),
|
|
@@ -29,7 +41,10 @@ export function stripExecutionStatePayload(executionState) {
|
|
|
29
41
|
})),
|
|
30
42
|
};
|
|
31
43
|
}
|
|
32
|
-
export function createFlowRunState(scopeKey, flowId, executionState, jiraRef, launchProfile) {
|
|
44
|
+
export function createFlowRunState(scopeKey, flowId, executionState, jiraRef, launchProfile, executionRouting, selectedRoutingPreset) {
|
|
45
|
+
ensurePublicationRunId(executionState);
|
|
46
|
+
const effectiveExecutionRouting = executionRouting ?? (launchProfile ? singleLaunchProfileExecutionRouting(launchProfile) : undefined);
|
|
47
|
+
const effectiveLaunchProfile = launchProfile ?? effectiveExecutionRouting?.defaultRoute;
|
|
33
48
|
return {
|
|
34
49
|
schemaVersion: FLOW_STATE_SCHEMA_VERSION,
|
|
35
50
|
flowId,
|
|
@@ -38,10 +53,52 @@ export function createFlowRunState(scopeKey, flowId, executionState, jiraRef, la
|
|
|
38
53
|
status: "pending",
|
|
39
54
|
currentStep: null,
|
|
40
55
|
updatedAt: nowIso8601(),
|
|
41
|
-
...(
|
|
56
|
+
...(effectiveLaunchProfile ? { launchProfile: effectiveLaunchProfile } : {}),
|
|
57
|
+
...(effectiveExecutionRouting ? { executionRouting: effectiveExecutionRouting, routingFingerprint: effectiveExecutionRouting.fingerprint } : {}),
|
|
58
|
+
...(selectedRoutingPreset ? { selectedRoutingPreset } : {}),
|
|
42
59
|
executionState: stripExecutionStatePayload(executionState),
|
|
43
60
|
};
|
|
44
61
|
}
|
|
62
|
+
function upgradeFlowRunStateV1(state) {
|
|
63
|
+
const executionRouting = state.launchProfile ? singleLaunchProfileExecutionRouting(state.launchProfile) : undefined;
|
|
64
|
+
return {
|
|
65
|
+
...state,
|
|
66
|
+
schemaVersion: FLOW_STATE_SCHEMA_VERSION,
|
|
67
|
+
...(executionRouting ? { executionRouting, routingFingerprint: executionRouting.fingerprint } : {}),
|
|
68
|
+
...(executionRouting ? { selectedRoutingPreset: { kind: "custom", label: "Legacy launch profile" } } : {}),
|
|
69
|
+
};
|
|
70
|
+
}
|
|
71
|
+
function normalizeFlowRunState(raw, flowId, filePath) {
|
|
72
|
+
if (!raw || typeof raw !== "object") {
|
|
73
|
+
throw new TaskRunnerError(`Invalid flow state file format: ${filePath}`);
|
|
74
|
+
}
|
|
75
|
+
const schemaVersion = raw.schemaVersion;
|
|
76
|
+
let state;
|
|
77
|
+
if (schemaVersion === 1) {
|
|
78
|
+
state = upgradeFlowRunStateV1(raw);
|
|
79
|
+
}
|
|
80
|
+
else if (schemaVersion === FLOW_STATE_SCHEMA_VERSION) {
|
|
81
|
+
state = raw;
|
|
82
|
+
}
|
|
83
|
+
else {
|
|
84
|
+
throw new TaskRunnerError(`Unsupported flow state schema in ${filePath}: ${String(schemaVersion ?? "unknown")}`);
|
|
85
|
+
}
|
|
86
|
+
if (state.flowId !== flowId) {
|
|
87
|
+
throw new TaskRunnerError(`Flow state ${filePath} belongs to flow '${state.flowId}', expected '${flowId}'`);
|
|
88
|
+
}
|
|
89
|
+
if (state.executionRouting) {
|
|
90
|
+
const executionRouting = resolveStoredExecutionRoutingSnapshot(state.executionRouting);
|
|
91
|
+
state.executionRouting = executionRouting;
|
|
92
|
+
state.routingFingerprint = executionRouting.fingerprint;
|
|
93
|
+
state.launchProfile = executionRouting.defaultRoute;
|
|
94
|
+
}
|
|
95
|
+
else if (state.launchProfile) {
|
|
96
|
+
const executionRouting = singleLaunchProfileExecutionRouting(state.launchProfile);
|
|
97
|
+
state.executionRouting = executionRouting;
|
|
98
|
+
state.routingFingerprint = executionRouting.fingerprint;
|
|
99
|
+
}
|
|
100
|
+
return state;
|
|
101
|
+
}
|
|
45
102
|
export function loadFlowRunState(scopeKey, flowId) {
|
|
46
103
|
const filePath = flowStateFile(scopeKey, flowId);
|
|
47
104
|
if (!existsSync(filePath)) {
|
|
@@ -54,20 +111,20 @@ export function loadFlowRunState(scopeKey, flowId) {
|
|
|
54
111
|
catch (error) {
|
|
55
112
|
throw new TaskRunnerError(`Failed to parse flow state file ${filePath}: ${error.message}`);
|
|
56
113
|
}
|
|
57
|
-
|
|
58
|
-
throw new TaskRunnerError(`Invalid flow state file format: ${filePath}`);
|
|
59
|
-
}
|
|
60
|
-
const state = raw;
|
|
61
|
-
if (state.schemaVersion !== FLOW_STATE_SCHEMA_VERSION) {
|
|
62
|
-
throw new TaskRunnerError(`Unsupported flow state schema in ${filePath}: ${state.schemaVersion}`);
|
|
63
|
-
}
|
|
64
|
-
if (state.flowId !== flowId) {
|
|
65
|
-
throw new TaskRunnerError(`Flow state ${filePath} belongs to flow '${state.flowId}', expected '${flowId}'`);
|
|
66
|
-
}
|
|
67
|
-
return state;
|
|
114
|
+
return normalizeFlowRunState(raw, flowId, filePath);
|
|
68
115
|
}
|
|
69
116
|
export function saveFlowRunState(state) {
|
|
70
117
|
state.updatedAt = nowIso8601();
|
|
118
|
+
state.schemaVersion = FLOW_STATE_SCHEMA_VERSION;
|
|
119
|
+
if (state.executionRouting) {
|
|
120
|
+
state.executionRouting = resolveStoredExecutionRoutingSnapshot(state.executionRouting);
|
|
121
|
+
state.routingFingerprint = state.executionRouting.fingerprint;
|
|
122
|
+
state.launchProfile = state.executionRouting.defaultRoute;
|
|
123
|
+
}
|
|
124
|
+
else if (state.launchProfile) {
|
|
125
|
+
state.executionRouting = singleLaunchProfileExecutionRouting(state.launchProfile);
|
|
126
|
+
state.routingFingerprint = state.executionRouting.fingerprint;
|
|
127
|
+
}
|
|
71
128
|
ensureScopeWorkspaceDir(state.scopeKey);
|
|
72
129
|
writeFileSync(flowStateFile(state.scopeKey, state.flowId), `${JSON.stringify({
|
|
73
130
|
...state,
|
|
@@ -101,10 +158,12 @@ function normalizeStepState(step) {
|
|
|
101
158
|
if (step.status !== "running") {
|
|
102
159
|
return step;
|
|
103
160
|
}
|
|
104
|
-
const
|
|
161
|
+
const resumeValue = isFlowRunResumeEnvelope(step.value) ? step.value : undefined;
|
|
162
|
+
const { finishedAt: _finishedAt, outputs: _outputs, value: _value, publishedArtifacts: _publishedArtifacts, stopFlow: _stopFlow, ...rest } = step;
|
|
105
163
|
return {
|
|
106
164
|
...rest,
|
|
107
165
|
status: "pending",
|
|
166
|
+
...(resumeValue ? { value: resumeValue } : {}),
|
|
108
167
|
};
|
|
109
168
|
}
|
|
110
169
|
function normalizePhaseState(phase) {
|
|
@@ -171,6 +230,7 @@ export function prepareFlowStateForResume(state) {
|
|
|
171
230
|
state.currentStep = null;
|
|
172
231
|
state.executionState = {
|
|
173
232
|
...state.executionState,
|
|
233
|
+
publicationRunId: randomUUID(),
|
|
174
234
|
terminated: false,
|
|
175
235
|
phases: state.executionState.phases.map(normalizePhaseState),
|
|
176
236
|
};
|