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.
Files changed (100) hide show
  1. package/README.md +29 -7
  2. package/dist/artifact-manifest.js +219 -0
  3. package/dist/artifacts.js +21 -1
  4. package/dist/doctor/checks/cwd-context.js +4 -3
  5. package/dist/doctor/checks/env-diagnostics.js +193 -71
  6. package/dist/doctor/checks/flow-readiness.js +212 -203
  7. package/dist/doctor/index.js +1 -1
  8. package/dist/doctor/orchestrator.js +18 -7
  9. package/dist/doctor/runner.js +9 -8
  10. package/dist/doctor/types.js +12 -0
  11. package/dist/flow-state.js +75 -15
  12. package/dist/index.js +499 -199
  13. package/dist/interactive/blessed-session.js +361 -0
  14. package/dist/interactive/controller.js +1293 -0
  15. package/dist/interactive/create-interactive-session.js +5 -0
  16. package/dist/interactive/ink/index.js +576 -0
  17. package/dist/interactive/progress.js +245 -0
  18. package/dist/interactive/selectors.js +14 -0
  19. package/dist/interactive/session.js +1 -0
  20. package/dist/interactive/state.js +34 -0
  21. package/dist/interactive/tree.js +155 -0
  22. package/dist/interactive/types.js +1 -0
  23. package/dist/interactive/view-model.js +1 -0
  24. package/dist/interactive-ui.js +159 -194
  25. package/dist/pipeline/context.js +1 -0
  26. package/dist/pipeline/declarative-flow-runner.js +212 -6
  27. package/dist/pipeline/declarative-flows.js +27 -0
  28. package/dist/pipeline/execution-routing-config.js +15 -0
  29. package/dist/pipeline/flow-catalog.js +23 -3
  30. package/dist/pipeline/flow-run-resume.js +29 -0
  31. package/dist/pipeline/flow-specs/auto-common.json +89 -360
  32. package/dist/pipeline/flow-specs/auto-golang.json +58 -363
  33. package/dist/pipeline/flow-specs/auto-simple.json +141 -0
  34. package/dist/pipeline/flow-specs/bugz/bug-analyze.json +2 -0
  35. package/dist/pipeline/flow-specs/bugz/bug-fix.json +1 -0
  36. package/dist/pipeline/flow-specs/design-review/design-review-loop.json +304 -0
  37. package/dist/pipeline/flow-specs/design-review.json +249 -0
  38. package/dist/pipeline/flow-specs/gitlab/gitlab-diff-review.json +11 -0
  39. package/dist/pipeline/flow-specs/gitlab/gitlab-review.json +2 -0
  40. package/dist/pipeline/flow-specs/gitlab/mr-description.json +1 -0
  41. package/dist/pipeline/flow-specs/go/run-go-linter-loop.json +2 -0
  42. package/dist/pipeline/flow-specs/go/run-go-tests-loop.json +2 -0
  43. package/dist/pipeline/flow-specs/implement.json +24 -5
  44. package/dist/pipeline/flow-specs/instant-task.json +177 -0
  45. package/dist/pipeline/flow-specs/normalize-task-source.json +311 -0
  46. package/dist/pipeline/flow-specs/plan-revise.json +267 -0
  47. package/dist/pipeline/flow-specs/plan.json +48 -70
  48. package/dist/pipeline/flow-specs/review/review-fix.json +24 -4
  49. package/dist/pipeline/flow-specs/review/review-loop.json +351 -45
  50. package/dist/pipeline/flow-specs/review/review-project-loop.json +590 -0
  51. package/dist/pipeline/flow-specs/review/review-project.json +12 -0
  52. package/dist/pipeline/flow-specs/review/review.json +37 -31
  53. package/dist/pipeline/flow-specs/task-describe.json +62 -2
  54. package/dist/pipeline/flow-specs/task-source/jira-fetch.json +70 -0
  55. package/dist/pipeline/flow-specs/task-source/manual-input.json +216 -0
  56. package/dist/pipeline/node-registry.js +49 -1
  57. package/dist/pipeline/node-runner.js +3 -2
  58. package/dist/pipeline/nodes/build-review-fix-prompt-node.js +5 -1
  59. package/dist/pipeline/nodes/clear-ready-to-merge-node.js +11 -0
  60. package/dist/pipeline/nodes/commit-message-form-node.js +8 -0
  61. package/dist/pipeline/nodes/design-review-verdict-node.js +36 -0
  62. package/dist/pipeline/nodes/ensure-summary-json-node.js +70 -0
  63. package/dist/pipeline/nodes/fetch-gitlab-diff-node.js +19 -2
  64. package/dist/pipeline/nodes/fetch-gitlab-review-node.js +19 -2
  65. package/dist/pipeline/nodes/flow-run-node.js +226 -7
  66. package/dist/pipeline/nodes/git-commit-form-node.js +8 -0
  67. package/dist/pipeline/nodes/gitlab-review-artifacts-node.js +19 -2
  68. package/dist/pipeline/nodes/jira-fetch-node.js +50 -4
  69. package/dist/pipeline/nodes/llm-prompt-node.js +32 -12
  70. package/dist/pipeline/nodes/planning-bundle-node.js +10 -0
  71. package/dist/pipeline/nodes/review-verdict-node.js +86 -0
  72. package/dist/pipeline/nodes/select-files-form-node.js +8 -0
  73. package/dist/pipeline/nodes/structured-summary-node.js +24 -0
  74. package/dist/pipeline/nodes/user-input-node.js +38 -3
  75. package/dist/pipeline/nodes/write-selection-file-node.js +20 -4
  76. package/dist/pipeline/prompt-registry.js +5 -1
  77. package/dist/pipeline/prompt-runtime.js +4 -1
  78. package/dist/pipeline/review-iteration.js +26 -0
  79. package/dist/pipeline/spec-compiler.js +2 -0
  80. package/dist/pipeline/spec-types.js +5 -0
  81. package/dist/pipeline/spec-validator.js +14 -0
  82. package/dist/pipeline/value-resolver.js +84 -1
  83. package/dist/prompts.js +82 -13
  84. package/dist/review-severity.js +45 -0
  85. package/dist/runtime/artifact-registry.js +402 -0
  86. package/dist/runtime/design-review-input-contract.js +113 -0
  87. package/dist/runtime/env-loader.js +3 -0
  88. package/dist/runtime/execution-routing-store.js +134 -0
  89. package/dist/runtime/execution-routing.js +227 -0
  90. package/dist/runtime/interactive-execution-routing.js +462 -0
  91. package/dist/runtime/plan-revise-input-contract.js +147 -0
  92. package/dist/runtime/planning-bundle.js +123 -0
  93. package/dist/runtime/ready-to-merge.js +31 -0
  94. package/dist/runtime/review-input-contract.js +100 -0
  95. package/dist/scope.js +11 -2
  96. package/dist/structured-artifact-schema-registry.js +10 -0
  97. package/dist/structured-artifact-schemas.json +257 -1
  98. package/dist/structured-artifacts.js +83 -6
  99. package/dist/user-input.js +70 -3
  100. package/package.json +6 -3
@@ -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
- const FLOW_STATE_SCHEMA_VERSION = 1;
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
- ...(launchProfile ? { launchProfile } : {}),
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
- if (!raw || typeof raw !== "object") {
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 { finishedAt: _finishedAt, outputs: _outputs, value: _value, stopFlow: _stopFlow, ...rest } = step;
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
  };