@wrongstack/core 0.155.0 → 0.236.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/dist/{agent-bridge-BbZU5TPN.d.ts → agent-bridge-Cimv7bK7.d.ts} +1 -1
- package/dist/{agent-subagent-runner-Bsueu0J2.d.ts → agent-subagent-runner-C658wj_c.d.ts} +9 -8
- package/dist/{brain-CS_B0vIE.d.ts → brain-sCZ3lCjq.d.ts} +26 -2
- package/dist/{compactor-BueGt7LG.d.ts → compactor-BRfg3QPd.d.ts} +1 -1
- package/dist/{config-BaVThgnT.d.ts → config-Koq6f3fs.d.ts} +2 -2
- package/dist/{context-C7G_MtLV.d.ts → context-CLz3z_E8.d.ts} +126 -2
- package/dist/coordination/index.d.ts +70 -13
- package/dist/coordination/index.js +1983 -145
- package/dist/coordination/index.js.map +1 -1
- package/dist/defaults/index.d.ts +26 -26
- package/dist/defaults/index.js +1105 -289
- package/dist/defaults/index.js.map +1 -1
- package/dist/execution/index.d.ts +45 -16
- package/dist/execution/index.js +224 -53
- package/dist/execution/index.js.map +1 -1
- package/dist/execution/prompt-enhancer.d.ts +86 -0
- package/dist/execution/prompt-enhancer.js +125 -0
- package/dist/execution/prompt-enhancer.js.map +1 -0
- package/dist/extension/index.d.ts +6 -6
- package/dist/extension/index.js +3 -1
- package/dist/extension/index.js.map +1 -1
- package/dist/{goal-preamble-CbV8pXLD.d.ts → goal-preamble-CnbzyVvl.d.ts} +19 -10
- package/dist/{index-CI1hRfPt.d.ts → index-BlMqh5GO.d.ts} +8 -8
- package/dist/{index-B5wz-GXm.d.ts → index-C2eSNPsB.d.ts} +7 -5
- package/dist/index.d.ts +438 -128
- package/dist/index.js +4974 -836
- package/dist/index.js.map +1 -1
- package/dist/infrastructure/index.d.ts +7 -7
- package/dist/infrastructure/index.js +61 -13
- package/dist/infrastructure/index.js.map +1 -1
- package/dist/kernel/index.d.ts +9 -9
- package/dist/kernel/index.js +7 -1
- package/dist/kernel/index.js.map +1 -1
- package/dist/{llm-selector-CP72f1lC.d.ts → llm-selector-D22R4AFz.d.ts} +2 -2
- package/dist/logger-DmmQhf4P.d.ts +65 -0
- package/dist/{mcp-servers-CPERR2De.d.ts → mcp-servers-DFbirBv6.d.ts} +3 -3
- package/dist/models/index.d.ts +5 -5
- package/dist/models/index.js +89 -9
- package/dist/models/index.js.map +1 -1
- package/dist/{models-registry-D90K9UnM.d.ts → models-registry-CnJRjTXc.d.ts} +1 -1
- package/dist/{multi-agent-coordinator-BSKSFNhv.d.ts → multi-agent-coordinator-60weDZoA.d.ts} +8 -8
- package/dist/{null-fleet-bus-CGOez8Le.d.ts → null-fleet-bus-1068dEnr.d.ts} +7 -7
- package/dist/observability/index.d.ts +2 -2
- package/dist/package-outdated-watcher-pzJ5w7y8.d.ts +560 -0
- package/dist/{parallel-eternal-engine-CYoTKjsz.d.ts → parallel-eternal-engine-DtG1fjc9.d.ts} +13 -9
- package/dist/{path-resolver-DuhlmPil.d.ts → path-resolver-CA1ULU0J.d.ts} +3 -3
- package/dist/{permission-B7nKnEvQ.d.ts → permission-DbWPbuoA.d.ts} +1 -1
- package/dist/{permission-policy-8-6zBmfA.d.ts → permission-policy-AOk0LVsV.d.ts} +2 -2
- package/dist/pipeline-DsmlwTXu.d.ts +493 -0
- package/dist/{plan-templates-DbH7lg-t.d.ts → plan-templates-DPABrDvy.d.ts} +18 -7
- package/dist/{provider-runner-Cocq0O9E.d.ts → provider-runner-D0HgUqwV.d.ts} +3 -3
- package/dist/{retry-policy-rutAfVeR.d.ts → retry-policy-BVnkbMET.d.ts} +1 -1
- package/dist/sdd/index.d.ts +8 -8
- package/dist/sdd/index.js +215 -79
- package/dist/sdd/index.js.map +1 -1
- package/dist/{secret-vault-w8MbUe2Q.d.ts → secret-vault-CeVNiy_f.d.ts} +3 -2
- package/dist/security/index.d.ts +5 -4
- package/dist/security/index.js +155 -13
- package/dist/security/index.js.map +1 -1
- package/dist/{selector-4vDFZKt3.d.ts → selector-Cb4_9-hf.d.ts} +1 -1
- package/dist/{session-event-bridge-DWlvglC2.d.ts → session-event-bridge-BhtkkFFy.d.ts} +4 -2
- package/dist/{session-reader-BAtCxdaw.d.ts → session-reader-CCOssnBS.d.ts} +1 -1
- package/dist/skills/index.js +171 -21
- package/dist/skills/index.js.map +1 -1
- package/dist/storage/index.d.ts +150 -12
- package/dist/storage/index.js +1041 -214
- package/dist/storage/index.js.map +1 -1
- package/dist/types/index.d.ts +67 -20
- package/dist/types/index.js +557 -52
- package/dist/types/index.js.map +1 -1
- package/dist/utils/expect-defined.js +3 -1
- package/dist/utils/expect-defined.js.map +1 -1
- package/dist/utils/index.d.ts +16 -4
- package/dist/utils/index.js +40 -14
- package/dist/utils/index.js.map +1 -1
- package/dist/{wstack-paths-DD50Omgn.d.ts → wstack-paths-CJjEwPXn.d.ts} +14 -1
- package/package.json +7 -3
- package/skills/chimera/SKILL.md +105 -0
- package/skills/research-web/SKILL.md +342 -0
- package/dist/logger-B9J5puGM.d.ts +0 -32
- package/dist/pipeline-BG7UgbDc.d.ts +0 -239
package/dist/sdd/index.js
CHANGED
|
@@ -617,6 +617,81 @@ function topologicalSort(graph) {
|
|
|
617
617
|
return result;
|
|
618
618
|
}
|
|
619
619
|
|
|
620
|
+
// src/types/errors.ts
|
|
621
|
+
var ERROR_CODES = {
|
|
622
|
+
// Provider
|
|
623
|
+
PROVIDER_RATE_LIMITED: "PROVIDER_RATE_LIMITED",
|
|
624
|
+
PROVIDER_AUTH_FAILED: "PROVIDER_AUTH_FAILED",
|
|
625
|
+
PROVIDER_OVERLOADED: "PROVIDER_OVERLOADED",
|
|
626
|
+
PROVIDER_INVALID_REQUEST: "PROVIDER_INVALID_REQUEST",
|
|
627
|
+
PROVIDER_SERVER_ERROR: "PROVIDER_SERVER_ERROR",
|
|
628
|
+
PROVIDER_NETWORK_ERROR: "PROVIDER_NETWORK_ERROR",
|
|
629
|
+
// Agent
|
|
630
|
+
AGENT_ITERATION_LIMIT: "AGENT_ITERATION_LIMIT",
|
|
631
|
+
AGENT_ABORTED: "AGENT_ABORTED",
|
|
632
|
+
AGENT_RUN_FAILED: "AGENT_RUN_FAILED",
|
|
633
|
+
// SDD (Spec-Driven Development)
|
|
634
|
+
SDD_VALIDATION_FAILED: "SDD_VALIDATION_FAILED",
|
|
635
|
+
SDD_PARSE_FAILED: "SDD_PARSE_FAILED",
|
|
636
|
+
SDD_INVALID_STATE: "SDD_INVALID_STATE",
|
|
637
|
+
SDD_NOT_READY: "SDD_NOT_READY"};
|
|
638
|
+
var WrongStackError = class extends Error {
|
|
639
|
+
code;
|
|
640
|
+
subsystem;
|
|
641
|
+
severity;
|
|
642
|
+
recoverable;
|
|
643
|
+
context;
|
|
644
|
+
constructor(opts) {
|
|
645
|
+
super(opts.message, { cause: opts.cause });
|
|
646
|
+
this.name = "WrongStackError";
|
|
647
|
+
this.code = opts.code;
|
|
648
|
+
this.subsystem = opts.subsystem;
|
|
649
|
+
this.severity = opts.severity ?? "error";
|
|
650
|
+
this.recoverable = opts.recoverable ?? false;
|
|
651
|
+
this.context = opts.context;
|
|
652
|
+
}
|
|
653
|
+
/**
|
|
654
|
+
* Render a one-line user-facing description.
|
|
655
|
+
* Subclasses should override for domain-specific formatting.
|
|
656
|
+
*/
|
|
657
|
+
describe() {
|
|
658
|
+
const ctx = this.context ? ` ${formatContext(this.context)}` : "";
|
|
659
|
+
return `${this.code}: ${this.message}${ctx}`;
|
|
660
|
+
}
|
|
661
|
+
};
|
|
662
|
+
function formatContext(ctx) {
|
|
663
|
+
const parts = Object.entries(ctx).filter(([, v]) => v !== void 0).slice(0, 3).map(([k, v]) => `${k}=${String(v)}`);
|
|
664
|
+
return parts.length > 0 ? `[${parts.join(" ")}]` : "";
|
|
665
|
+
}
|
|
666
|
+
var AgentError = class extends WrongStackError {
|
|
667
|
+
constructor(opts) {
|
|
668
|
+
super({
|
|
669
|
+
message: opts.message,
|
|
670
|
+
code: opts.code,
|
|
671
|
+
subsystem: "agent",
|
|
672
|
+
severity: opts.code === ERROR_CODES.AGENT_ABORTED ? "warning" : "error",
|
|
673
|
+
recoverable: opts.recoverable ?? opts.code === ERROR_CODES.AGENT_ITERATION_LIMIT,
|
|
674
|
+
context: opts.context,
|
|
675
|
+
cause: opts.cause
|
|
676
|
+
});
|
|
677
|
+
this.name = "AgentError";
|
|
678
|
+
}
|
|
679
|
+
};
|
|
680
|
+
var SddError = class extends WrongStackError {
|
|
681
|
+
constructor(opts) {
|
|
682
|
+
super({
|
|
683
|
+
message: opts.message,
|
|
684
|
+
code: opts.code,
|
|
685
|
+
subsystem: "sdd",
|
|
686
|
+
severity: opts.code === ERROR_CODES.SDD_PARSE_FAILED ? "warning" : "error",
|
|
687
|
+
recoverable: opts.code === ERROR_CODES.SDD_NOT_READY,
|
|
688
|
+
context: opts.context,
|
|
689
|
+
cause: opts.cause
|
|
690
|
+
});
|
|
691
|
+
this.name = "SddError";
|
|
692
|
+
}
|
|
693
|
+
};
|
|
694
|
+
|
|
620
695
|
// src/sdd/task-tracker.ts
|
|
621
696
|
var TaskTracker = class {
|
|
622
697
|
constructor(opts) {
|
|
@@ -651,7 +726,10 @@ var TaskTracker = class {
|
|
|
651
726
|
return this.graph;
|
|
652
727
|
}
|
|
653
728
|
addNode(node) {
|
|
654
|
-
if (!this.graph) throw new
|
|
729
|
+
if (!this.graph) throw new SddError({
|
|
730
|
+
message: "No graph loaded",
|
|
731
|
+
code: ERROR_CODES.SDD_INVALID_STATE
|
|
732
|
+
});
|
|
655
733
|
const now = Date.now();
|
|
656
734
|
const newNode = {
|
|
657
735
|
...node,
|
|
@@ -669,7 +747,10 @@ var TaskTracker = class {
|
|
|
669
747
|
return newNode;
|
|
670
748
|
}
|
|
671
749
|
addEdge(from, to, type = "depends_on") {
|
|
672
|
-
if (!this.graph) throw new
|
|
750
|
+
if (!this.graph) throw new SddError({
|
|
751
|
+
message: "No graph loaded",
|
|
752
|
+
code: ERROR_CODES.SDD_INVALID_STATE
|
|
753
|
+
});
|
|
673
754
|
this.graph.edges.push({
|
|
674
755
|
id: crypto.randomUUID(),
|
|
675
756
|
from,
|
|
@@ -680,9 +761,16 @@ var TaskTracker = class {
|
|
|
680
761
|
this.persist();
|
|
681
762
|
}
|
|
682
763
|
updateNodeStatus(id, status, reason) {
|
|
683
|
-
if (!this.graph) throw new
|
|
764
|
+
if (!this.graph) throw new SddError({
|
|
765
|
+
message: "No graph loaded",
|
|
766
|
+
code: ERROR_CODES.SDD_INVALID_STATE
|
|
767
|
+
});
|
|
684
768
|
const node = this.graph.nodes.get(id);
|
|
685
|
-
if (!node) throw new
|
|
769
|
+
if (!node) throw new SddError({
|
|
770
|
+
message: `Node ${id} not found`,
|
|
771
|
+
code: ERROR_CODES.SDD_NOT_READY,
|
|
772
|
+
context: { nodeId: id }
|
|
773
|
+
});
|
|
686
774
|
const from = node.status;
|
|
687
775
|
const now = Date.now();
|
|
688
776
|
node.status = status;
|
|
@@ -705,9 +793,16 @@ var TaskTracker = class {
|
|
|
705
793
|
this.persist();
|
|
706
794
|
}
|
|
707
795
|
updateNode(id, patch) {
|
|
708
|
-
if (!this.graph) throw new
|
|
796
|
+
if (!this.graph) throw new SddError({
|
|
797
|
+
message: "No graph loaded",
|
|
798
|
+
code: ERROR_CODES.SDD_INVALID_STATE
|
|
799
|
+
});
|
|
709
800
|
const node = this.graph.nodes.get(id);
|
|
710
|
-
if (!node) throw new
|
|
801
|
+
if (!node) throw new SddError({
|
|
802
|
+
message: `Node ${id} not found`,
|
|
803
|
+
code: ERROR_CODES.SDD_NOT_READY,
|
|
804
|
+
context: { nodeId: id }
|
|
805
|
+
});
|
|
711
806
|
if (patch.title !== void 0) node.title = patch.title;
|
|
712
807
|
if (patch.description !== void 0) node.description = patch.description;
|
|
713
808
|
if (patch.priority !== void 0) node.priority = patch.priority;
|
|
@@ -826,7 +921,12 @@ var TaskTracker = class {
|
|
|
826
921
|
persist() {
|
|
827
922
|
if (!this.graph) return;
|
|
828
923
|
this.opts.store.saveGraph(this.graph).catch((err) => {
|
|
829
|
-
this.opts.onPersistError ? this.opts.onPersistError(err) : console.warn(
|
|
924
|
+
this.opts.onPersistError ? this.opts.onPersistError(err) : console.warn(JSON.stringify({
|
|
925
|
+
level: "warn",
|
|
926
|
+
event: "task_tracker.save_graph_failed",
|
|
927
|
+
message: err instanceof Error ? err.message : String(err),
|
|
928
|
+
timestamp: (/* @__PURE__ */ new Date()).toISOString()
|
|
929
|
+
}));
|
|
830
930
|
});
|
|
831
931
|
}
|
|
832
932
|
};
|
|
@@ -879,12 +979,14 @@ var TaskFlow = class {
|
|
|
879
979
|
const analysis = parser.analyze(this.spec);
|
|
880
980
|
this.emit("spec.analyzed", { analysis });
|
|
881
981
|
if (analysis.completeness < 50) {
|
|
882
|
-
|
|
883
|
-
|
|
884
|
-
|
|
982
|
+
const err = new SddError({
|
|
983
|
+
message: `Spec completeness too low: ${analysis.completeness}%`,
|
|
984
|
+
code: ERROR_CODES.SDD_VALIDATION_FAILED,
|
|
985
|
+
context: { completeness: analysis.completeness }
|
|
885
986
|
});
|
|
987
|
+
this.emit("error", { phase: "analyzing", error: err });
|
|
886
988
|
this.setPhase("failed");
|
|
887
|
-
throw
|
|
989
|
+
throw err;
|
|
888
990
|
}
|
|
889
991
|
this.setPhase("generating");
|
|
890
992
|
const generator = new TaskGenerator({ taskTracker: this.opts.tracker });
|
|
@@ -892,7 +994,11 @@ var TaskFlow = class {
|
|
|
892
994
|
return this.graph;
|
|
893
995
|
}
|
|
894
996
|
async execute(ctx) {
|
|
895
|
-
if (!this.graph) throw new
|
|
997
|
+
if (!this.graph) throw new SddError({
|
|
998
|
+
message: "No graph loaded. Call fromSpec first.",
|
|
999
|
+
code: ERROR_CODES.SDD_INVALID_STATE,
|
|
1000
|
+
context: { phase: this.phase }
|
|
1001
|
+
});
|
|
896
1002
|
this.setPhase("executing");
|
|
897
1003
|
this.stopped = false;
|
|
898
1004
|
const pendingTasks = this.getExecutableTasks();
|
|
@@ -932,7 +1038,11 @@ var TaskFlow = class {
|
|
|
932
1038
|
}
|
|
933
1039
|
async reviewTask(taskId, approved, comment) {
|
|
934
1040
|
const task = this.opts.tracker.getNode(taskId);
|
|
935
|
-
if (!task) throw new
|
|
1041
|
+
if (!task) throw new SddError({
|
|
1042
|
+
message: `Task ${taskId} not found`,
|
|
1043
|
+
code: ERROR_CODES.SDD_NOT_READY,
|
|
1044
|
+
context: { taskId }
|
|
1045
|
+
});
|
|
936
1046
|
if (approved) {
|
|
937
1047
|
this.opts.tracker.updateNodeStatus(taskId, "completed", comment);
|
|
938
1048
|
this.emit("task.completed", { taskId });
|
|
@@ -1246,7 +1356,9 @@ var TaskGraphStore = class {
|
|
|
1246
1356
|
// src/utils/expect-defined.ts
|
|
1247
1357
|
function expectDefined(value, label) {
|
|
1248
1358
|
if (value === null || value === void 0) {
|
|
1249
|
-
|
|
1359
|
+
const err = new Error("Expected value to be defined");
|
|
1360
|
+
err.name = "ExpectDefinedError";
|
|
1361
|
+
throw err;
|
|
1250
1362
|
}
|
|
1251
1363
|
return value;
|
|
1252
1364
|
}
|
|
@@ -1584,7 +1696,11 @@ var AISpecBuilder = class {
|
|
|
1584
1696
|
switch (this.session.phase) {
|
|
1585
1697
|
case "questioning":
|
|
1586
1698
|
if (!this.session.spec) {
|
|
1587
|
-
throw new
|
|
1699
|
+
throw new SddError({
|
|
1700
|
+
message: "Cannot approve: no spec generated yet.",
|
|
1701
|
+
code: ERROR_CODES.SDD_INVALID_STATE,
|
|
1702
|
+
context: { phase: "questioning", sessionId: this.session.id }
|
|
1703
|
+
});
|
|
1588
1704
|
}
|
|
1589
1705
|
this.session.phase = "spec_review";
|
|
1590
1706
|
break;
|
|
@@ -1642,7 +1758,11 @@ var AISpecBuilder = class {
|
|
|
1642
1758
|
*/
|
|
1643
1759
|
async saveSpec() {
|
|
1644
1760
|
if (!this.session.spec) {
|
|
1645
|
-
throw new
|
|
1761
|
+
throw new SddError({
|
|
1762
|
+
message: "No spec to save.",
|
|
1763
|
+
code: ERROR_CODES.SDD_NOT_READY,
|
|
1764
|
+
context: { sessionId: this.session.id }
|
|
1765
|
+
});
|
|
1646
1766
|
}
|
|
1647
1767
|
await this.store.save(this.session.spec);
|
|
1648
1768
|
return this.session.spec;
|
|
@@ -1657,17 +1777,30 @@ var AISpecBuilder = class {
|
|
|
1657
1777
|
try {
|
|
1658
1778
|
parsed = JSON.parse(jsonStr);
|
|
1659
1779
|
} catch (e) {
|
|
1660
|
-
throw new
|
|
1780
|
+
throw new SddError({
|
|
1781
|
+
message: "Invalid JSON for spec",
|
|
1782
|
+
code: ERROR_CODES.SDD_PARSE_FAILED,
|
|
1783
|
+
cause: e,
|
|
1784
|
+
context: { detail: e instanceof Error ? e.message : "parse error" }
|
|
1785
|
+
});
|
|
1661
1786
|
}
|
|
1662
1787
|
if (!parsed || typeof parsed !== "object") {
|
|
1663
|
-
throw new
|
|
1788
|
+
throw new SddError({
|
|
1789
|
+
message: "Spec JSON must be an object",
|
|
1790
|
+
code: ERROR_CODES.SDD_VALIDATION_FAILED,
|
|
1791
|
+
context: { actualType: typeof parsed }
|
|
1792
|
+
});
|
|
1664
1793
|
}
|
|
1665
1794
|
const raw = parsed;
|
|
1666
1795
|
const now = Date.now();
|
|
1667
1796
|
const title = String(raw.title ?? this.session.title ?? "Untitled");
|
|
1668
1797
|
const overview = String(raw.overview ?? "");
|
|
1669
1798
|
if (!overview || overview === "undefined") {
|
|
1670
|
-
throw new
|
|
1799
|
+
throw new SddError({
|
|
1800
|
+
message: "Spec must have an overview",
|
|
1801
|
+
code: ERROR_CODES.SDD_VALIDATION_FAILED,
|
|
1802
|
+
context: { field: "overview", title }
|
|
1803
|
+
});
|
|
1671
1804
|
}
|
|
1672
1805
|
const rawSections = Array.isArray(raw.sections) ? raw.sections : [];
|
|
1673
1806
|
const sections = rawSections.filter((s) => s && typeof s === "object").map((s) => ({
|
|
@@ -2211,9 +2344,11 @@ function computeParallelGroups(graph, blockedByMap) {
|
|
|
2211
2344
|
|
|
2212
2345
|
// src/utils/assert-never.ts
|
|
2213
2346
|
function assertNever(x, message) {
|
|
2214
|
-
|
|
2347
|
+
const err = new Error(
|
|
2215
2348
|
`Unhandled case: ${JSON.stringify(x)}`
|
|
2216
2349
|
);
|
|
2350
|
+
err.name = "AssertNeverError";
|
|
2351
|
+
throw err;
|
|
2217
2352
|
}
|
|
2218
2353
|
|
|
2219
2354
|
// src/sdd/spec-versioning.ts
|
|
@@ -3136,21 +3271,40 @@ function makeAgentSubagentRunner(opts) {
|
|
|
3136
3271
|
if (budgetError) throw budgetError;
|
|
3137
3272
|
}
|
|
3138
3273
|
if (result.status === "failed") {
|
|
3139
|
-
throw result.error instanceof
|
|
3274
|
+
throw result.error instanceof AgentError ? result.error : new AgentError({
|
|
3275
|
+
message: result.error instanceof Error ? result.error.message : String(result.error ?? "agent failed"),
|
|
3276
|
+
code: ERROR_CODES.AGENT_RUN_FAILED,
|
|
3277
|
+
cause: result.error
|
|
3278
|
+
});
|
|
3140
3279
|
}
|
|
3141
3280
|
if (result.status === "aborted") {
|
|
3142
|
-
throw new
|
|
3281
|
+
throw new AgentError({
|
|
3282
|
+
message: "agent aborted",
|
|
3283
|
+
code: ERROR_CODES.AGENT_ABORTED
|
|
3284
|
+
});
|
|
3143
3285
|
}
|
|
3144
3286
|
if (result.status === "max_iterations") {
|
|
3145
|
-
throw new
|
|
3287
|
+
throw new AgentError({
|
|
3288
|
+
message: "agent exhausted iteration limit",
|
|
3289
|
+
code: ERROR_CODES.AGENT_ITERATION_LIMIT,
|
|
3290
|
+
recoverable: true
|
|
3291
|
+
});
|
|
3146
3292
|
}
|
|
3147
3293
|
const usage = ctx.budget.usage();
|
|
3148
3294
|
const finalText = (result.finalText ?? "").trim();
|
|
3149
3295
|
if (finalText.length === 0 && usage.toolCalls === 0) {
|
|
3150
|
-
throw new
|
|
3296
|
+
throw new AgentError({
|
|
3297
|
+
message: "empty response \u2014 agent produced no text and no tool calls",
|
|
3298
|
+
code: ERROR_CODES.AGENT_RUN_FAILED,
|
|
3299
|
+
context: { iterations: result.iterations }
|
|
3300
|
+
});
|
|
3151
3301
|
}
|
|
3152
3302
|
if (finalText.length === 0 && lastToolFailed !== null) {
|
|
3153
|
-
throw new
|
|
3303
|
+
throw new AgentError({
|
|
3304
|
+
message: `unrecovered tool failure: ${lastToolFailed} \u2014 agent ended turn without acknowledging the error`,
|
|
3305
|
+
code: ERROR_CODES.AGENT_RUN_FAILED,
|
|
3306
|
+
context: { tool: lastToolFailed, iterations: result.iterations }
|
|
3307
|
+
});
|
|
3154
3308
|
}
|
|
3155
3309
|
return {
|
|
3156
3310
|
result: result.finalText,
|
|
@@ -3163,44 +3317,6 @@ function defaultFormatTaskInput(task) {
|
|
|
3163
3317
|
return task.description ?? "";
|
|
3164
3318
|
}
|
|
3165
3319
|
|
|
3166
|
-
// src/types/errors.ts
|
|
3167
|
-
var ERROR_CODES = {
|
|
3168
|
-
// Provider
|
|
3169
|
-
PROVIDER_RATE_LIMITED: "PROVIDER_RATE_LIMITED",
|
|
3170
|
-
PROVIDER_AUTH_FAILED: "PROVIDER_AUTH_FAILED",
|
|
3171
|
-
PROVIDER_OVERLOADED: "PROVIDER_OVERLOADED",
|
|
3172
|
-
PROVIDER_INVALID_REQUEST: "PROVIDER_INVALID_REQUEST",
|
|
3173
|
-
PROVIDER_SERVER_ERROR: "PROVIDER_SERVER_ERROR",
|
|
3174
|
-
PROVIDER_NETWORK_ERROR: "PROVIDER_NETWORK_ERROR"};
|
|
3175
|
-
var WrongStackError = class extends Error {
|
|
3176
|
-
code;
|
|
3177
|
-
subsystem;
|
|
3178
|
-
severity;
|
|
3179
|
-
recoverable;
|
|
3180
|
-
context;
|
|
3181
|
-
constructor(opts) {
|
|
3182
|
-
super(opts.message, { cause: opts.cause });
|
|
3183
|
-
this.name = "WrongStackError";
|
|
3184
|
-
this.code = opts.code;
|
|
3185
|
-
this.subsystem = opts.subsystem;
|
|
3186
|
-
this.severity = opts.severity ?? "error";
|
|
3187
|
-
this.recoverable = opts.recoverable ?? false;
|
|
3188
|
-
this.context = opts.context;
|
|
3189
|
-
}
|
|
3190
|
-
/**
|
|
3191
|
-
* Render a one-line user-facing description.
|
|
3192
|
-
* Subclasses should override for domain-specific formatting.
|
|
3193
|
-
*/
|
|
3194
|
-
describe() {
|
|
3195
|
-
const ctx = this.context ? ` ${formatContext(this.context)}` : "";
|
|
3196
|
-
return `${this.code}: ${this.message}${ctx}`;
|
|
3197
|
-
}
|
|
3198
|
-
};
|
|
3199
|
-
function formatContext(ctx) {
|
|
3200
|
-
const parts = Object.entries(ctx).filter(([, v]) => v !== void 0).slice(0, 3).map(([k, v]) => `${k}=${String(v)}`);
|
|
3201
|
-
return parts.length > 0 ? `[${parts.join(" ")}]` : "";
|
|
3202
|
-
}
|
|
3203
|
-
|
|
3204
3320
|
// src/types/provider.ts
|
|
3205
3321
|
var ProviderError = class extends WrongStackError {
|
|
3206
3322
|
status;
|
|
@@ -3275,6 +3391,9 @@ function providerStatusToCode(status, type) {
|
|
|
3275
3391
|
|
|
3276
3392
|
// src/coordination/coordinator/error-classifier.ts
|
|
3277
3393
|
function classifySubagentError(err, hints = {}) {
|
|
3394
|
+
if (err instanceof AgentError && err.cause) {
|
|
3395
|
+
return classifySubagentError(err.cause, hints);
|
|
3396
|
+
}
|
|
3278
3397
|
const cause = err instanceof Error ? { name: err.name, message: err.message, stack: err.stack } : void 0;
|
|
3279
3398
|
if (err instanceof ProviderError) {
|
|
3280
3399
|
const baseMessage2 = err.describe();
|
|
@@ -3307,7 +3426,7 @@ function classifySubagentError(err, hints = {}) {
|
|
|
3307
3426
|
if (/agent exhausted iteration limit$/i.test(baseMessage)) {
|
|
3308
3427
|
return { kind: "budget_iterations", message: baseMessage, retryable: false, cause };
|
|
3309
3428
|
}
|
|
3310
|
-
if (/empty response
|
|
3429
|
+
if (/empty response/i.test(baseMessage)) {
|
|
3311
3430
|
return { kind: "empty_response", message: baseMessage, retryable: false, cause };
|
|
3312
3431
|
}
|
|
3313
3432
|
if (/^tool failed: /i.test(baseMessage)) {
|
|
@@ -3357,11 +3476,11 @@ var HEAVY_BUDGET = {
|
|
|
3357
3476
|
};
|
|
3358
3477
|
var TOOLS = {
|
|
3359
3478
|
/** Pure read/inspect — safe for analysis and review agents. */
|
|
3360
|
-
read: ["read", "grep", "glob", "search", "tree"],
|
|
3479
|
+
read: ["read", "grep", "glob", "search", "tree", "mailbox"],
|
|
3361
3480
|
/** Read + structured inspection (logs, diffs, json, dependency audit). */
|
|
3362
|
-
inspect: ["read", "grep", "glob", "search", "tree", "json", "diff", "logs", "audit"],
|
|
3481
|
+
inspect: ["read", "grep", "glob", "search", "tree", "json", "diff", "logs", "audit", "mailbox"],
|
|
3363
3482
|
/** Read + edit (no shell). For agents that write code/docs but don't run it. */
|
|
3364
|
-
write: ["read", "grep", "glob", "search", "tree", "write", "edit", "replace", "patch"],
|
|
3483
|
+
write: ["read", "grep", "glob", "search", "tree", "write", "edit", "replace", "patch", "mailbox"],
|
|
3365
3484
|
/** Full build loop: edit + run (lint/format/typecheck/test/bash). */
|
|
3366
3485
|
build: [
|
|
3367
3486
|
"read",
|
|
@@ -3378,16 +3497,17 @@ var TOOLS = {
|
|
|
3378
3497
|
"lint",
|
|
3379
3498
|
"format",
|
|
3380
3499
|
"typecheck",
|
|
3381
|
-
"test"
|
|
3500
|
+
"test",
|
|
3501
|
+
"mailbox"
|
|
3382
3502
|
],
|
|
3383
3503
|
/** Version control. */
|
|
3384
3504
|
vcs: ["read", "grep", "glob", "git", "diff"],
|
|
3385
3505
|
/** Dependency management + CVE audit. */
|
|
3386
|
-
deps: ["read", "grep", "glob", "install", "outdated", "audit", "json"],
|
|
3506
|
+
deps: ["read", "grep", "glob", "install", "outdated", "audit", "json", "mailbox"],
|
|
3387
3507
|
/** Documentation authoring. */
|
|
3388
|
-
docs: ["read", "grep", "glob", "search", "tree", "write", "edit", "document"],
|
|
3508
|
+
docs: ["read", "grep", "glob", "search", "tree", "write", "edit", "document", "mailbox"],
|
|
3389
3509
|
/** Web research. */
|
|
3390
|
-
research: ["read", "grep", "glob", "search", "fetch"]
|
|
3510
|
+
research: ["read", "grep", "glob", "search", "fetch", "mailbox"]
|
|
3391
3511
|
};
|
|
3392
3512
|
|
|
3393
3513
|
// src/coordination/agents/phase1-discovery.ts
|
|
@@ -5800,7 +5920,7 @@ Working rules:
|
|
|
5800
5920
|
id: "tech-stack",
|
|
5801
5921
|
name: "Tech Stack Validator",
|
|
5802
5922
|
role: "tech-stack",
|
|
5803
|
-
tools: ["search", "fetch", "read", "grep", "glob", "outdated", "audit", "json"],
|
|
5923
|
+
tools: ["search", "fetch", "read", "grep", "glob", "outdated", "audit", "json", "mailbox"],
|
|
5804
5924
|
prompt: `You are the Tech Stack Validator \u2014 a single-shot validation agent that fires
|
|
5805
5925
|
before any package, library, or framework choice is committed.
|
|
5806
5926
|
|
|
@@ -5808,6 +5928,16 @@ Your ONLY job: verify that a technology choice is current, real, and not obsolet
|
|
|
5808
5928
|
You are the "this isn't code, this is 10-year-old technology" agent. Intervene
|
|
5809
5929
|
hard when the LLM hallucinates a version number or suggests dead tech.
|
|
5810
5930
|
|
|
5931
|
+
## Before you begin
|
|
5932
|
+
|
|
5933
|
+
Check the inter-agent mailbox for pending tasks. Other agents or the file-watcher
|
|
5934
|
+
may have left assign messages with dependency files to audit:
|
|
5935
|
+
- mailbox action=check
|
|
5936
|
+
|
|
5937
|
+
If you find an assign message, use the specified file path and packages.
|
|
5938
|
+
When done, post results back:
|
|
5939
|
+
- mailbox action=send to=<sender> type=result subject="Tech stack audit results" body="..."
|
|
5940
|
+
|
|
5811
5941
|
## Critical rules
|
|
5812
5942
|
|
|
5813
5943
|
1. **Verify existence.** Search npm registry (fetch https://registry.npmjs.org/<pkg>/latest)
|
|
@@ -5866,11 +5996,11 @@ When APPROVED:
|
|
|
5866
5996
|
**Install**: pnpm add <name>@^<major>.<minor>.0`
|
|
5867
5997
|
},
|
|
5868
5998
|
budget: {
|
|
5869
|
-
timeoutMs:
|
|
5870
|
-
maxIterations:
|
|
5871
|
-
maxToolCalls:
|
|
5872
|
-
maxTokens:
|
|
5873
|
-
maxCostUsd: 0.
|
|
5999
|
+
timeoutMs: 12e4,
|
|
6000
|
+
maxIterations: 10,
|
|
6001
|
+
maxToolCalls: 40,
|
|
6002
|
+
maxTokens: 6e4,
|
|
6003
|
+
maxCostUsd: 0.25
|
|
5874
6004
|
},
|
|
5875
6005
|
capability: {
|
|
5876
6006
|
phase: "meta",
|
|
@@ -6911,7 +7041,10 @@ var SddParallelRun = class {
|
|
|
6911
7041
|
"\u2022 Do not ask before routine in-project tool use; if a permission gate appears, wait for that flow.",
|
|
6912
7042
|
"\u2022 Keep output concise \u2014 summarize changes, do not transcribe files."
|
|
6913
7043
|
].join("\n");
|
|
6914
|
-
if (!this.coordinator) throw new
|
|
7044
|
+
if (!this.coordinator) throw new SddError({
|
|
7045
|
+
message: "SDD parallel runner requires a coordinator",
|
|
7046
|
+
code: ERROR_CODES.SDD_INVALID_STATE
|
|
7047
|
+
});
|
|
6915
7048
|
const coordinator = this.coordinator;
|
|
6916
7049
|
const spawns = subagentIds.map(
|
|
6917
7050
|
(subagentId) => coordinator.spawn({
|
|
@@ -6923,7 +7056,10 @@ var SddParallelRun = class {
|
|
|
6923
7056
|
);
|
|
6924
7057
|
const spawnResults = await Promise.all(spawns);
|
|
6925
7058
|
if (!spawnResults.every((r) => Boolean(r.subagentId))) {
|
|
6926
|
-
throw new
|
|
7059
|
+
throw new SddError({
|
|
7060
|
+
message: "One or more subagent spawns failed",
|
|
7061
|
+
code: ERROR_CODES.SDD_INVALID_STATE
|
|
7062
|
+
});
|
|
6927
7063
|
}
|
|
6928
7064
|
const assignPromises = tasks.map((task, i) => {
|
|
6929
7065
|
const spec = {
|