@wrongstack/core 0.1.10 → 0.2.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.
Files changed (42) hide show
  1. package/dist/{agent-bridge-6KPqsFx6.d.ts → agent-bridge-DmBiCipY.d.ts} +1 -1
  2. package/dist/{compactor-B4mQZXf2.d.ts → compactor-DSl2FK7a.d.ts} +1 -1
  3. package/dist/{config-BU9f_5yH.d.ts → config-DXrqb41m.d.ts} +1 -1
  4. package/dist/{context-BmM2xGUZ.d.ts → context-u0bryklF.d.ts} +8 -0
  5. package/dist/coordination/index.d.ts +210 -12
  6. package/dist/coordination/index.js +941 -67
  7. package/dist/coordination/index.js.map +1 -1
  8. package/dist/defaults/index.d.ts +18 -18
  9. package/dist/defaults/index.js +953 -41
  10. package/dist/defaults/index.js.map +1 -1
  11. package/dist/{events-BMNaEFZl.d.ts → events-B6Q03pTu.d.ts} +73 -1
  12. package/dist/execution/index.d.ts +11 -11
  13. package/dist/index.d.ts +61 -28
  14. package/dist/index.js +1077 -48
  15. package/dist/index.js.map +1 -1
  16. package/dist/infrastructure/index.d.ts +6 -6
  17. package/dist/kernel/index.d.ts +9 -9
  18. package/dist/kernel/index.js.map +1 -1
  19. package/dist/{mcp-servers-Dzgg4x1w.d.ts → mcp-servers-BA1Ofmfj.d.ts} +3 -3
  20. package/dist/models/index.d.ts +2 -2
  21. package/dist/{multi-agent-fmkRHtof.d.ts → multi-agent-BDfkxL5C.d.ts} +71 -3
  22. package/dist/observability/index.d.ts +2 -2
  23. package/dist/{path-resolver-DBjaoXFq.d.ts → path-resolver-Crkt8wTQ.d.ts} +2 -2
  24. package/dist/{plugin-DJk6LL8B.d.ts → plugin-CoYYZKdn.d.ts} +19 -6
  25. package/dist/{renderer-rk_1Swwc.d.ts → renderer-0A2ZEtca.d.ts} +1 -1
  26. package/dist/sdd/index.d.ts +3 -3
  27. package/dist/{secret-scrubber-CicHLN4G.d.ts → secret-scrubber-3TLUkiCV.d.ts} +1 -1
  28. package/dist/{secret-scrubber-DF88luOe.d.ts → secret-scrubber-CwYliRWd.d.ts} +1 -1
  29. package/dist/security/index.d.ts +20 -4
  30. package/dist/security/index.js +13 -1
  31. package/dist/security/index.js.map +1 -1
  32. package/dist/{selector-BbJqiEP4.d.ts → selector-BRqzvugb.d.ts} +1 -1
  33. package/dist/{session-reader-Drq8RvJu.d.ts → session-reader-C3x96CDR.d.ts} +1 -1
  34. package/dist/{skill-DhfSizKv.d.ts → skill-Bx8jxznf.d.ts} +1 -1
  35. package/dist/storage/index.d.ts +164 -6
  36. package/dist/storage/index.js +273 -1
  37. package/dist/storage/index.js.map +1 -1
  38. package/dist/{system-prompt-BC_8ypCG.d.ts → system-prompt-CG9jU5-5.d.ts} +9 -1
  39. package/dist/{tool-executor-CpuJPYm9.d.ts → tool-executor-CYdZdtno.d.ts} +4 -4
  40. package/dist/types/index.d.ts +15 -15
  41. package/dist/utils/index.d.ts +1 -1
  42. package/package.json +1 -1
@@ -284,6 +284,12 @@ var FileSessionWriter = class {
284
284
  tokenIn = 0;
285
285
  tokenOut = 0;
286
286
  filePath;
287
+ /** Public accessor for the JSONL path — required by SessionWriter so
288
+ * observability surfaces (`/fleet log`, FleetPanel) can locate the
289
+ * transcript without recomputing the path from session metadata. */
290
+ get transcriptPath() {
291
+ return this.filePath || void 0;
292
+ }
287
293
  initDone = false;
288
294
  resumed;
289
295
  appendFailCount = 0;
@@ -1524,7 +1530,273 @@ var SessionAnalyzer = class {
1524
1530
  return last - first;
1525
1531
  }
1526
1532
  };
1533
+ async function loadTodosCheckpoint(filePath) {
1534
+ let raw;
1535
+ try {
1536
+ raw = await fsp.readFile(filePath, "utf8");
1537
+ } catch {
1538
+ return null;
1539
+ }
1540
+ try {
1541
+ const parsed = JSON.parse(raw);
1542
+ if (parsed?.version !== 1 || !Array.isArray(parsed.todos)) return null;
1543
+ return parsed.todos.filter(
1544
+ (t) => !!t && typeof t.id === "string" && typeof t.content === "string" && typeof t.status === "string"
1545
+ );
1546
+ } catch {
1547
+ return null;
1548
+ }
1549
+ }
1550
+ async function saveTodosCheckpoint(filePath, sessionId, todos) {
1551
+ const payload = {
1552
+ version: 1,
1553
+ sessionId,
1554
+ updatedAt: (/* @__PURE__ */ new Date()).toISOString(),
1555
+ todos: [...todos]
1556
+ };
1557
+ try {
1558
+ await atomicWrite(filePath, JSON.stringify(payload, null, 2), { mode: 384 });
1559
+ } catch (err) {
1560
+ console.warn(
1561
+ "[todos-checkpoint] save failed:",
1562
+ err instanceof Error ? err.message : String(err)
1563
+ );
1564
+ }
1565
+ }
1566
+ function attachTodosCheckpoint(state, filePath, sessionId) {
1567
+ let timer = null;
1568
+ let pending = null;
1569
+ const flush = () => {
1570
+ timer = null;
1571
+ if (pending) {
1572
+ void saveTodosCheckpoint(filePath, sessionId, pending);
1573
+ pending = null;
1574
+ }
1575
+ };
1576
+ const unsubscribe = state.onChange((change) => {
1577
+ if (change.kind !== "todos_replaced") return;
1578
+ pending = change.todos;
1579
+ if (timer) clearTimeout(timer);
1580
+ timer = setTimeout(flush, 150);
1581
+ });
1582
+ return () => {
1583
+ unsubscribe();
1584
+ if (timer) {
1585
+ clearTimeout(timer);
1586
+ flush();
1587
+ }
1588
+ };
1589
+ }
1590
+ async function loadPlan(filePath) {
1591
+ let raw;
1592
+ try {
1593
+ raw = await fsp.readFile(filePath, "utf8");
1594
+ } catch {
1595
+ return null;
1596
+ }
1597
+ try {
1598
+ const parsed = JSON.parse(raw);
1599
+ if (parsed?.version !== 1 || !Array.isArray(parsed.items)) return null;
1600
+ return parsed;
1601
+ } catch {
1602
+ return null;
1603
+ }
1604
+ }
1605
+ async function savePlan(filePath, plan) {
1606
+ try {
1607
+ await atomicWrite(filePath, JSON.stringify(plan, null, 2), { mode: 384 });
1608
+ } catch (err) {
1609
+ console.warn(
1610
+ "[plan-store] save failed:",
1611
+ err instanceof Error ? err.message : String(err)
1612
+ );
1613
+ }
1614
+ }
1615
+ function emptyPlan(sessionId, title) {
1616
+ return {
1617
+ version: 1,
1618
+ sessionId,
1619
+ title,
1620
+ updatedAt: (/* @__PURE__ */ new Date()).toISOString(),
1621
+ items: []
1622
+ };
1623
+ }
1624
+ function addPlanItem(plan, title, details) {
1625
+ const now = (/* @__PURE__ */ new Date()).toISOString();
1626
+ const item = {
1627
+ id: `plan_${Date.now()}_${randomUUID().slice(0, 6)}`,
1628
+ title,
1629
+ details,
1630
+ status: "open",
1631
+ createdAt: now,
1632
+ updatedAt: now
1633
+ };
1634
+ return {
1635
+ plan: { ...plan, items: [...plan.items, item], updatedAt: now },
1636
+ item
1637
+ };
1638
+ }
1639
+ function removePlanItem(plan, idOrIndex) {
1640
+ const idx = matchIndex(plan, idOrIndex);
1641
+ if (idx === -1) return plan;
1642
+ return {
1643
+ ...plan,
1644
+ items: plan.items.filter((_, i) => i !== idx),
1645
+ updatedAt: (/* @__PURE__ */ new Date()).toISOString()
1646
+ };
1647
+ }
1648
+ function setPlanItemStatus(plan, idOrIndex, status) {
1649
+ const idx = matchIndex(plan, idOrIndex);
1650
+ if (idx === -1) return plan;
1651
+ const now = (/* @__PURE__ */ new Date()).toISOString();
1652
+ const items = plan.items.map(
1653
+ (it, i) => i === idx ? { ...it, status, updatedAt: now } : it
1654
+ );
1655
+ return { ...plan, items, updatedAt: now };
1656
+ }
1657
+ function clearPlan(plan) {
1658
+ return { ...plan, items: [], updatedAt: (/* @__PURE__ */ new Date()).toISOString() };
1659
+ }
1660
+ function formatPlan(plan) {
1661
+ if (plan.items.length === 0) return "Plan is empty.";
1662
+ const lines = [];
1663
+ if (plan.title) lines.push(`# ${plan.title}`);
1664
+ plan.items.forEach((it, i) => {
1665
+ const mark = it.status === "done" ? "[x]" : it.status === "in_progress" ? "[~]" : "[ ]";
1666
+ lines.push(`${i + 1}. ${mark} ${it.title}`);
1667
+ if (it.details) {
1668
+ for (const line of it.details.split("\n")) lines.push(` ${line}`);
1669
+ }
1670
+ });
1671
+ return lines.join("\n");
1672
+ }
1673
+ function matchIndex(plan, idOrIndex) {
1674
+ const asNum = Number.parseInt(idOrIndex, 10);
1675
+ if (!Number.isNaN(asNum) && asNum >= 1 && asNum <= plan.items.length) return asNum - 1;
1676
+ const byId = plan.items.findIndex((it) => it.id === idOrIndex);
1677
+ if (byId !== -1) return byId;
1678
+ const lower = idOrIndex.toLowerCase();
1679
+ return plan.items.findIndex((it) => it.title.toLowerCase().includes(lower));
1680
+ }
1681
+ function attachPlanCheckpoint(_state, _filePath, _sessionId) {
1682
+ return () => void 0;
1683
+ }
1684
+ async function loadDirectorState(filePath) {
1685
+ let raw;
1686
+ try {
1687
+ raw = await fsp.readFile(filePath, "utf8");
1688
+ } catch {
1689
+ return null;
1690
+ }
1691
+ try {
1692
+ const parsed = JSON.parse(raw);
1693
+ if (parsed?.version !== 1) return null;
1694
+ return parsed;
1695
+ } catch {
1696
+ return null;
1697
+ }
1698
+ }
1699
+ var DirectorStateCheckpoint = class {
1700
+ snapshot;
1701
+ filePath;
1702
+ timer = null;
1703
+ debounceMs;
1704
+ writing = false;
1705
+ rewriteRequested = false;
1706
+ constructor(filePath, init, debounceMs = 250) {
1707
+ this.filePath = filePath;
1708
+ this.debounceMs = debounceMs;
1709
+ this.snapshot = {
1710
+ version: 1,
1711
+ directorRunId: init.directorRunId,
1712
+ updatedAt: (/* @__PURE__ */ new Date()).toISOString(),
1713
+ spawnCount: 0,
1714
+ maxSpawns: init.maxSpawns,
1715
+ spawnDepth: init.spawnDepth,
1716
+ maxSpawnDepth: init.maxSpawnDepth,
1717
+ subagents: [],
1718
+ tasks: []
1719
+ };
1720
+ }
1721
+ current() {
1722
+ return this.snapshot;
1723
+ }
1724
+ recordSpawn(sub, spawnCount) {
1725
+ this.snapshot = {
1726
+ ...this.snapshot,
1727
+ spawnCount,
1728
+ subagents: [...this.snapshot.subagents.filter((s) => s.id !== sub.id), sub]
1729
+ };
1730
+ this.bumpUpdatedAt();
1731
+ this.schedule();
1732
+ }
1733
+ recordTaskAssigned(task) {
1734
+ const exists = this.snapshot.tasks.some((t) => t.taskId === task.taskId);
1735
+ this.snapshot = {
1736
+ ...this.snapshot,
1737
+ tasks: exists ? this.snapshot.tasks.map((t) => t.taskId === task.taskId ? { ...t, ...task } : t) : [...this.snapshot.tasks, task]
1738
+ };
1739
+ this.bumpUpdatedAt();
1740
+ this.schedule();
1741
+ }
1742
+ recordTaskStatus(taskId, patch) {
1743
+ this.snapshot = {
1744
+ ...this.snapshot,
1745
+ tasks: this.snapshot.tasks.map(
1746
+ (t) => t.taskId === taskId ? { ...t, ...patch } : t
1747
+ )
1748
+ };
1749
+ this.bumpUpdatedAt();
1750
+ this.schedule();
1751
+ }
1752
+ setUsage(usage) {
1753
+ this.snapshot = { ...this.snapshot, usage };
1754
+ this.bumpUpdatedAt();
1755
+ this.schedule();
1756
+ }
1757
+ /** Force a synchronous flush — used by Director.shutdown(). */
1758
+ async flush() {
1759
+ if (this.timer) {
1760
+ clearTimeout(this.timer);
1761
+ this.timer = null;
1762
+ }
1763
+ await this.persist();
1764
+ }
1765
+ bumpUpdatedAt() {
1766
+ this.snapshot = { ...this.snapshot, updatedAt: (/* @__PURE__ */ new Date()).toISOString() };
1767
+ }
1768
+ schedule() {
1769
+ if (this.timer) return;
1770
+ this.timer = setTimeout(() => {
1771
+ this.timer = null;
1772
+ void this.persist();
1773
+ }, this.debounceMs);
1774
+ }
1775
+ async persist() {
1776
+ if (this.writing) {
1777
+ this.rewriteRequested = true;
1778
+ return;
1779
+ }
1780
+ this.writing = true;
1781
+ try {
1782
+ await atomicWrite(this.filePath, JSON.stringify(this.snapshot, null, 2), {
1783
+ mode: 384
1784
+ });
1785
+ } catch (err) {
1786
+ console.warn(
1787
+ "[director-state] checkpoint write failed:",
1788
+ err instanceof Error ? err.message : String(err)
1789
+ );
1790
+ } finally {
1791
+ this.writing = false;
1792
+ if (this.rewriteRequested) {
1793
+ this.rewriteRequested = false;
1794
+ this.schedule();
1795
+ }
1796
+ }
1797
+ }
1798
+ };
1527
1799
 
1528
- export { ConfigMigrationError, DEFAULT_CONFIG_MIGRATIONS, DefaultAttachmentStore, DefaultConfigLoader, DefaultConfigStore, DefaultMemoryStore, DefaultSessionReader, DefaultSessionStore, QueueStore, RecoveryLock, SessionAnalyzer, runConfigMigrations };
1800
+ export { ConfigMigrationError, DEFAULT_CONFIG_MIGRATIONS, DefaultAttachmentStore, DefaultConfigLoader, DefaultConfigStore, DefaultMemoryStore, DefaultSessionReader, DefaultSessionStore, DirectorStateCheckpoint, QueueStore, RecoveryLock, SessionAnalyzer, addPlanItem, attachPlanCheckpoint, attachTodosCheckpoint, clearPlan, emptyPlan, formatPlan, loadDirectorState, loadPlan, loadTodosCheckpoint, removePlanItem, runConfigMigrations, savePlan, saveTodosCheckpoint, setPlanItemStatus };
1529
1801
  //# sourceMappingURL=index.js.map
1530
1802
  //# sourceMappingURL=index.js.map