monomind 2.0.3 → 2.1.3

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 (113) hide show
  1. package/README.md +74 -92
  2. package/package.json +11 -7
  3. package/packages/@monomind/cli/.claude/helpers/control-start.cjs +13 -20
  4. package/packages/@monomind/cli/.claude/helpers/event-logger.cjs +109 -6
  5. package/packages/@monomind/cli/.claude/helpers/graphify-freshen.cjs +19 -17
  6. package/packages/@monomind/cli/.claude/helpers/handlers/agent-start-handler.cjs +60 -28
  7. package/packages/@monomind/cli/.claude/helpers/handlers/capture-handler.cjs +99 -28
  8. package/packages/@monomind/cli/.claude/helpers/handlers/edit-handler.cjs +27 -9
  9. package/packages/@monomind/cli/.claude/helpers/handlers/gates-handler.cjs +18 -9
  10. package/packages/@monomind/cli/.claude/helpers/handlers/loops-status-handler.cjs +1 -1
  11. package/packages/@monomind/cli/.claude/helpers/handlers/route-handler.cjs +33 -4
  12. package/packages/@monomind/cli/.claude/helpers/handlers/session-handler.cjs +75 -45
  13. package/packages/@monomind/cli/.claude/helpers/handlers/session-restore-handler.cjs +0 -12
  14. package/packages/@monomind/cli/.claude/helpers/handlers/task-handler.cjs +53 -22
  15. package/packages/@monomind/cli/.claude/helpers/hook-handler.cjs +75 -4
  16. package/packages/@monomind/cli/.claude/helpers/intelligence.cjs +94 -15
  17. package/packages/@monomind/cli/.claude/helpers/session.cjs +6 -1
  18. package/packages/@monomind/cli/.claude/helpers/statusline.cjs +10 -10
  19. package/packages/@monomind/cli/.claude/helpers/token-tracker.cjs +3 -3
  20. package/packages/@monomind/cli/.claude/helpers/utils/agent-registrations.cjs +41 -0
  21. package/packages/@monomind/cli/.claude/helpers/utils/fs-helpers.cjs +183 -0
  22. package/packages/@monomind/cli/.claude/helpers/utils/micro-agents.cjs +10 -6
  23. package/packages/@monomind/cli/.claude/helpers/utils/monograph.cjs +73 -2
  24. package/packages/@monomind/cli/.claude/helpers/utils/telemetry.cjs +35 -19
  25. package/packages/@monomind/cli/README.md +74 -92
  26. package/packages/@monomind/cli/bin/cli.js +10 -1
  27. package/packages/@monomind/cli/dist/src/browser/workflow/store.d.ts +2 -2
  28. package/packages/@monomind/cli/dist/src/commands/agent-ops.js +9 -15
  29. package/packages/@monomind/cli/dist/src/commands/browse.d.ts +1 -1
  30. package/packages/@monomind/cli/dist/src/commands/cleanup.js +20 -4
  31. package/packages/@monomind/cli/dist/src/commands/completions.js +66 -261
  32. package/packages/@monomind/cli/dist/src/commands/doctor-env-checks.js +5 -0
  33. package/packages/@monomind/cli/dist/src/commands/doctor.js +7 -2
  34. package/packages/@monomind/cli/dist/src/commands/hooks-workers.js +7 -0
  35. package/packages/@monomind/cli/dist/src/commands/index.js +3 -0
  36. package/packages/@monomind/cli/dist/src/commands/mcp.js +11 -6
  37. package/packages/@monomind/cli/dist/src/commands/memory-admin.js +12 -6
  38. package/packages/@monomind/cli/dist/src/commands/memory-transfer.js +6 -13
  39. package/packages/@monomind/cli/dist/src/commands/monograph.js +3 -3
  40. package/packages/@monomind/cli/dist/src/commands/org.d.ts +3 -1
  41. package/packages/@monomind/cli/dist/src/commands/org.js +321 -127
  42. package/packages/@monomind/cli/dist/src/commands/platforms.d.ts +1 -1
  43. package/packages/@monomind/cli/dist/src/commands/start.js +142 -37
  44. package/packages/@monomind/cli/dist/src/commands/tokens.js +21 -3
  45. package/packages/@monomind/cli/dist/src/config-adapter.js +37 -17
  46. package/packages/@monomind/cli/dist/src/index.js +64 -28
  47. package/packages/@monomind/cli/dist/src/init/claudemd-generator.js +44 -11
  48. package/packages/@monomind/cli/dist/src/init/executor.js +93 -55
  49. package/packages/@monomind/cli/dist/src/mcp-client.d.ts +8 -3
  50. package/packages/@monomind/cli/dist/src/mcp-client.js +37 -3
  51. package/packages/@monomind/cli/dist/src/mcp-server.js +8 -2
  52. package/packages/@monomind/cli/dist/src/mcp-tools/agent-tools.d.ts +20 -0
  53. package/packages/@monomind/cli/dist/src/mcp-tools/agent-tools.js +10 -5
  54. package/packages/@monomind/cli/dist/src/mcp-tools/auto-install.d.ts +8 -8
  55. package/packages/@monomind/cli/dist/src/mcp-tools/coherence/types.d.ts +31 -31
  56. package/packages/@monomind/cli/dist/src/mcp-tools/github-tools.js +30 -8
  57. package/packages/@monomind/cli/dist/src/mcp-tools/graphify-tools.js +11 -2
  58. package/packages/@monomind/cli/dist/src/mcp-tools/hive-mind-tools.js +56 -35
  59. package/packages/@monomind/cli/dist/src/mcp-tools/knowledge-tools.js +9 -1
  60. package/packages/@monomind/cli/dist/src/mcp-tools/monograph-compat.js +56 -14
  61. package/packages/@monomind/cli/dist/src/mcp-tools/monograph-tools.js +88 -41
  62. package/packages/@monomind/cli/dist/src/mcp-tools/quality/coverage-analysis/prioritize-gaps.d.ts +36 -36
  63. package/packages/@monomind/cli/dist/src/mcp-tools/quality/security-compliance/detect-secrets.d.ts +4 -4
  64. package/packages/@monomind/cli/dist/src/mcp-tools/swarm-tools.js +6 -4
  65. package/packages/@monomind/cli/dist/src/mcp-tools/system-tools.js +4 -4
  66. package/packages/@monomind/cli/dist/src/mcp-tools/types.d.ts +20 -0
  67. package/packages/@monomind/cli/dist/src/mcp-tools/types.js +36 -1
  68. package/packages/@monomind/cli/dist/src/memory/ewc-consolidation.d.ts +12 -0
  69. package/packages/@monomind/cli/dist/src/memory/hnsw-operations.d.ts +13 -1
  70. package/packages/@monomind/cli/dist/src/memory/hnsw-operations.js +66 -14
  71. package/packages/@monomind/cli/dist/src/memory/intelligence.js +99 -3
  72. package/packages/@monomind/cli/dist/src/memory/memory-bridge.d.ts +7 -0
  73. package/packages/@monomind/cli/dist/src/memory/memory-bridge.js +20 -0
  74. package/packages/@monomind/cli/dist/src/memory/sona-optimizer.d.ts +12 -0
  75. package/packages/@monomind/cli/dist/src/orgrt/broker.d.ts +26 -0
  76. package/packages/@monomind/cli/dist/src/orgrt/broker.js +73 -0
  77. package/packages/@monomind/cli/dist/src/orgrt/bus.d.ts +5 -1
  78. package/packages/@monomind/cli/dist/src/orgrt/bus.js +5 -1
  79. package/packages/@monomind/cli/dist/src/orgrt/daemon.d.ts +46 -0
  80. package/packages/@monomind/cli/dist/src/orgrt/daemon.js +201 -18
  81. package/packages/@monomind/cli/dist/src/orgrt/forwarder.d.ts +10 -5
  82. package/packages/@monomind/cli/dist/src/orgrt/forwarder.js +138 -8
  83. package/packages/@monomind/cli/dist/src/orgrt/inbox.d.ts +11 -0
  84. package/packages/@monomind/cli/dist/src/orgrt/inbox.js +56 -0
  85. package/packages/@monomind/cli/dist/src/orgrt/policy.d.ts +5 -1
  86. package/packages/@monomind/cli/dist/src/orgrt/policy.js +58 -5
  87. package/packages/@monomind/cli/dist/src/orgrt/provider.js +1 -0
  88. package/packages/@monomind/cli/dist/src/orgrt/scheduler.d.ts +13 -0
  89. package/packages/@monomind/cli/dist/src/orgrt/scheduler.js +48 -0
  90. package/packages/@monomind/cli/dist/src/orgrt/server.d.ts +9 -0
  91. package/packages/@monomind/cli/dist/src/orgrt/server.js +39 -0
  92. package/packages/@monomind/cli/dist/src/orgrt/session.d.ts +10 -1
  93. package/packages/@monomind/cli/dist/src/orgrt/session.js +24 -1
  94. package/packages/@monomind/cli/dist/src/orgrt/test-loop.d.ts +12 -0
  95. package/packages/@monomind/cli/dist/src/orgrt/test-loop.js +108 -0
  96. package/packages/@monomind/cli/dist/src/orgrt/types.d.ts +52 -52
  97. package/packages/@monomind/cli/dist/src/output.d.ts +29 -29
  98. package/packages/@monomind/cli/dist/src/output.js +22 -7
  99. package/packages/@monomind/cli/dist/src/parser.d.ts +32 -0
  100. package/packages/@monomind/cli/dist/src/parser.js +130 -5
  101. package/packages/@monomind/cli/dist/src/routing/embed-worker.js +13 -1
  102. package/packages/@monomind/cli/dist/src/routing/route-layer-factory.js +31 -0
  103. package/packages/@monomind/cli/dist/src/services/config-file-manager.d.ts +21 -0
  104. package/packages/@monomind/cli/dist/src/services/config-file-manager.js +60 -7
  105. package/packages/@monomind/cli/dist/src/services/crash-reporter.js +2 -1
  106. package/packages/@monomind/cli/dist/src/types.d.ts +2 -2
  107. package/packages/@monomind/cli/dist/src/ui/dashboard.html +243 -49
  108. package/packages/@monomind/cli/dist/src/ui/orgs-files.js +192 -0
  109. package/packages/@monomind/cli/dist/src/ui/orgs.html +79 -11
  110. package/packages/@monomind/cli/dist/src/ui/server.mjs +346 -139
  111. package/packages/@monomind/cli/dist/src/utils/input-guards.d.ts +9 -0
  112. package/packages/@monomind/cli/dist/src/utils/input-guards.js +39 -5
  113. package/packages/@monomind/cli/package.json +15 -15
@@ -23,6 +23,7 @@ export function resolveProviderEnv(cfg, parentEnv = process.env) {
23
23
  if (!key)
24
24
  throw new Error(`provider api-key: env var ${name} is not set`);
25
25
  env[KEY_VAR] = key;
26
+ delete env.ANTHROPIC_AUTH_TOKEN; // leftover parent token would override the key in the engine
26
27
  break;
27
28
  }
28
29
  case 'base-url': {
@@ -0,0 +1,13 @@
1
+ /** "15m" | "2h" | "45s" | minutes as number | null → interval ms or null */
2
+ export declare function parseSchedule(s: string | number | null | undefined): number | null;
3
+ /** Fires runFn(name, intervalMs) every intervalMs per org. Real timer loop — no ScheduleWakeup, no prompts. */
4
+ export declare class OrgScheduler {
5
+ private runFn;
6
+ private timers;
7
+ private running;
8
+ constructor(runFn: (name: string, intervalMs: number) => Promise<void>);
9
+ add(name: string, intervalMs: number): void;
10
+ remove(name: string): void;
11
+ stop(): void;
12
+ }
13
+ //# sourceMappingURL=scheduler.d.ts.map
@@ -0,0 +1,48 @@
1
+ // packages/@monomind/cli/src/orgrt/scheduler.ts
2
+ /** "15m" | "2h" | "45s" | minutes as number | null → interval ms or null */
3
+ export function parseSchedule(s) {
4
+ if (s == null)
5
+ return null;
6
+ if (typeof s === 'number')
7
+ return s * 60_000;
8
+ const m = /^(\d+)\s*(s|m|h)$/.exec(s.trim());
9
+ if (!m)
10
+ return null;
11
+ const n = Number(m[1]);
12
+ return m[2] === 's' ? n * 1000 : m[2] === 'm' ? n * 60_000 : n * 3_600_000;
13
+ }
14
+ /** Fires runFn(name, intervalMs) every intervalMs per org. Real timer loop — no ScheduleWakeup, no prompts. */
15
+ export class OrgScheduler {
16
+ runFn;
17
+ timers = new Map();
18
+ running = new Set();
19
+ constructor(runFn) {
20
+ this.runFn = runFn;
21
+ }
22
+ add(name, intervalMs) {
23
+ this.remove(name);
24
+ this.timers.set(name, setInterval(async () => {
25
+ if (this.running.has(name))
26
+ return; // skip if previous iteration still running
27
+ this.running.add(name);
28
+ try {
29
+ await this.runFn(name, intervalMs);
30
+ }
31
+ catch (err) {
32
+ console.error(`[org-scheduler] ${name}: scheduled run failed:`, err);
33
+ }
34
+ finally {
35
+ this.running.delete(name);
36
+ }
37
+ }, intervalMs));
38
+ }
39
+ remove(name) {
40
+ const t = this.timers.get(name);
41
+ if (t)
42
+ clearInterval(t);
43
+ this.timers.delete(name);
44
+ }
45
+ stop() { for (const name of [...this.timers.keys()])
46
+ this.remove(name); }
47
+ }
48
+ //# sourceMappingURL=scheduler.js.map
@@ -0,0 +1,9 @@
1
+ import type { OrgDaemon } from './daemon.js';
2
+ export interface OrgServer {
3
+ port: number;
4
+ close: () => void;
5
+ }
6
+ /** Minimal HTTP listener for cross-process org message delivery.
7
+ * Binds an ephemeral port (pass 0) so the daemon can register it with the broker. */
8
+ export declare function startOrgServer(daemon: OrgDaemon, port?: number): Promise<OrgServer>;
9
+ //# sourceMappingURL=server.d.ts.map
@@ -0,0 +1,39 @@
1
+ // packages/@monomind/cli/src/orgrt/server.ts
2
+ // monolean: stripped to xdeliver-only — live UI, WS fanout, and redundant REST
3
+ // endpoints deleted; the control server at :4242 handles all of those.
4
+ import http from 'node:http';
5
+ /** Minimal HTTP listener for cross-process org message delivery.
6
+ * Binds an ephemeral port (pass 0) so the daemon can register it with the broker. */
7
+ export async function startOrgServer(daemon, port = 0) {
8
+ const server = http.createServer((req, res) => {
9
+ if (req.method === 'POST' && req.url === '/api/xdeliver') {
10
+ let body = '';
11
+ req.on('data', c => { body += c; });
12
+ req.on('end', () => {
13
+ try {
14
+ const payload = JSON.parse(body || '{}');
15
+ if (!payload.toOrg || !payload.toRole || !payload.fromOrg || !payload.fromRole) {
16
+ res.writeHead(400, { 'Content-Type': 'application/json' });
17
+ res.end(JSON.stringify({ ok: false, error: 'toOrg, toRole, fromOrg, fromRole are required' }));
18
+ return;
19
+ }
20
+ const result = daemon.receiveRemote(payload.toOrg, payload.toRole, `${payload.fromOrg}:${payload.fromRole}`, payload.subject ?? '', payload.body ?? '');
21
+ res.writeHead(result.ok ? 200 : 404, { 'Content-Type': 'application/json' });
22
+ res.end(JSON.stringify(result));
23
+ }
24
+ catch (err) {
25
+ res.writeHead(400, { 'Content-Type': 'application/json' });
26
+ res.end(JSON.stringify({ ok: false, error: err instanceof Error ? err.message : 'bad request' }));
27
+ }
28
+ });
29
+ }
30
+ else {
31
+ res.writeHead(404);
32
+ res.end('not found');
33
+ }
34
+ });
35
+ await new Promise(r => server.listen(port, r));
36
+ const actual = server.address().port;
37
+ return { port: actual, close: () => { server.close(); } };
38
+ }
39
+ //# sourceMappingURL=server.js.map
@@ -18,6 +18,15 @@ export interface SessionOpts {
18
18
  }
19
19
  /** Role briefing given to each agent session (SDK systemPrompt option). */
20
20
  export declare function buildRolePrompt(role: OrgRole, def: Pick<OrgDef, 'name' | 'goal'>, roster: string[]): string;
21
- /** Runs one persistent agent session; resolves when the mailbox closes and the SDK stream ends. */
21
+ /**
22
+ * Runs a role for the life of the org, transparently restarting the
23
+ * underlying SDK session whenever it ends on its own (`maxTurns` reached)
24
+ * while the mailbox is still open. `maxTurns` bounds a single SDK query()
25
+ * call's TOTAL turns, not "turns per incoming message" — since one query()
26
+ * call stays open across every mailbox message for as long as the mailbox
27
+ * itself stays open, without a restart the role would go permanently silent
28
+ * (no crash, no alert) once its lifetime turn count crossed the limit, while
29
+ * deliver() kept queuing new messages into a mailbox nobody was reading.
30
+ */
22
31
  export declare function runAgentSession(opts: SessionOpts): Promise<void>;
23
32
  //# sourceMappingURL=session.d.ts.map
@@ -16,8 +16,31 @@ export function buildRolePrompt(role, def, roster) {
16
16
  `When your current work is complete and no reply is needed, end your turn without further tool calls.`,
17
17
  ].filter(Boolean).join('\n\n');
18
18
  }
19
- /** Runs one persistent agent session; resolves when the mailbox closes and the SDK stream ends. */
19
+ /**
20
+ * Runs a role for the life of the org, transparently restarting the
21
+ * underlying SDK session whenever it ends on its own (`maxTurns` reached)
22
+ * while the mailbox is still open. `maxTurns` bounds a single SDK query()
23
+ * call's TOTAL turns, not "turns per incoming message" — since one query()
24
+ * call stays open across every mailbox message for as long as the mailbox
25
+ * itself stays open, without a restart the role would go permanently silent
26
+ * (no crash, no alert) once its lifetime turn count crossed the limit, while
27
+ * deliver() kept queuing new messages into a mailbox nobody was reading.
28
+ */
20
29
  export async function runAgentSession(opts) {
30
+ const { mailbox } = opts;
31
+ // Always run at least once: a mailbox can be closed with queued items still
32
+ // pending (stream() drains the queue before honoring `closed`), which is a
33
+ // normal, valid starting state — checking isClosed before the first run
34
+ // would skip that drain entirely.
35
+ while (true) {
36
+ await runOneSession(opts);
37
+ if (mailbox.isClosed)
38
+ return;
39
+ opts.bus.emit({ type: 'status', from: opts.role.id, msg: 'session restarting (turn limit reached, mailbox still open)' });
40
+ }
41
+ }
42
+ /** One bounded SDK session for a role; resolves when the SDK stream ends (mailbox closed or maxTurns reached). */
43
+ async function runOneSession(opts) {
21
44
  const { org, role, bus, policy, mailbox, cwd, deliver } = opts;
22
45
  const queryFn = opts.queryFn ?? query;
23
46
  const orgServer = createSdkMcpServer({
@@ -0,0 +1,12 @@
1
+ interface IterationResult {
2
+ checks: Record<string, boolean>;
3
+ events: number;
4
+ }
5
+ export interface LoopReport {
6
+ iterations: IterationResult[];
7
+ failed: number;
8
+ summary: string;
9
+ }
10
+ export declare function runTestLoop(root: string, times: number): Promise<LoopReport>;
11
+ export {};
12
+ //# sourceMappingURL=test-loop.d.ts.map
@@ -0,0 +1,108 @@
1
+ // packages/@monomind/cli/src/orgrt/test-loop.ts
2
+ import { mkdirSync, writeFileSync } from 'node:fs';
3
+ import { join } from 'node:path';
4
+ import { OrgDaemon } from './daemon.js';
5
+ import { startOrgServer } from './server.js';
6
+ import { OrgBus } from './bus.js';
7
+ import { queueMessage } from './inbox.js';
8
+ import { ORG_DIR } from './types.js';
9
+ /**
10
+ * Scripted fake SDK used by the verification loop (no API cost, deterministic).
11
+ * boss: on kickoff, delegates to coder, then pings the partner org's boss.
12
+ * coder: "writes" a report (Write allowed by policy), attempts Bash (denied), replies to boss.
13
+ * It drives the SAME production code paths via the _orgTest seam:
14
+ * callTool → policy.decide → bus; deliver → daemon.deliver → mailboxes + bus;
15
+ * assistant/result → chat/usage events.
16
+ */
17
+ const scriptedQuery = (roleId) => ({ prompt, options }) => (async function* () {
18
+ const seam = options._orgTest;
19
+ for await (const m of prompt) {
20
+ const text = String(m.message.content);
21
+ // Trigger ONLY on the daemon kickoff message (starts with `Org "`). A bare
22
+ // includes('started') also matches the xorg body "alpha started its run",
23
+ // making the partner boss re-deliver to itself forever — an unbroken
24
+ // microtask chain that starves the event loop (waitFor's timer never fires).
25
+ if (roleId === 'boss' && text.startsWith('Org "') && text.includes('started')) {
26
+ yield { type: 'assistant', message: { content: [{ type: 'text', text: 'Kicking off: delegating to coder.' }] } };
27
+ await seam.deliver('coder', 'task', 'produce out/report.md');
28
+ await seam.deliver('partner:boss', 'fyi', 'alpha started its run');
29
+ }
30
+ else if (roleId === 'coder') {
31
+ await seam.callTool('Write', { file_path: join(options.cwd, 'out/report.md'), content: '# report' });
32
+ await seam.callTool('Bash', { command: 'echo should-be-denied' }); // policy MUST deny
33
+ yield { type: 'assistant', message: { content: [{ type: 'text', text: 'Report written.' }] } };
34
+ await seam.deliver('boss', 're: task', 'done — out/report.md');
35
+ }
36
+ else {
37
+ yield { type: 'assistant', message: { content: [{ type: 'text', text: `ack: ${text.slice(0, 40)}` }] } };
38
+ }
39
+ yield { type: 'result', subtype: 'success', usage: { input_tokens: 5, output_tokens: 5 } };
40
+ }
41
+ })();
42
+ function writeFixtures(root) {
43
+ const dir = join(root, ORG_DIR);
44
+ mkdirSync(dir, { recursive: true });
45
+ writeFileSync(join(dir, 'alpha.json'), JSON.stringify({
46
+ name: 'alpha', goal: 'produce a report',
47
+ roles: [
48
+ { id: 'boss', title: 'Boss', type: 'boss', reports_to: null },
49
+ { id: 'coder', title: 'Coder', type: 'specialist', reports_to: 'boss',
50
+ policy: { denyTools: ['Bash'], fileWrite: ['out/**'] } },
51
+ ],
52
+ }));
53
+ writeFileSync(join(dir, 'partner.json'), JSON.stringify({
54
+ name: 'partner', goal: 'receive handoffs',
55
+ roles: [{ id: 'boss', title: 'Boss', type: 'boss', reports_to: null }],
56
+ }));
57
+ }
58
+ async function waitFor(pred, ms = 5000) {
59
+ const t0 = Date.now();
60
+ while (Date.now() - t0 < ms) {
61
+ if (pred())
62
+ return true;
63
+ await new Promise(r => setTimeout(r, 50));
64
+ }
65
+ return pred();
66
+ }
67
+ export async function runTestLoop(root, times) {
68
+ writeFixtures(root);
69
+ const iterations = [];
70
+ for (let i = 0; i < times; i++) {
71
+ const queryFn = (args) => {
72
+ const roleId = /You are agent "([^"]+)"/.exec(args.options.systemPrompt)?.[1] ?? 'unknown';
73
+ return scriptedQuery(roleId)(args);
74
+ };
75
+ const daemon = new OrgDaemon(root, { queryFn: queryFn, forward: false });
76
+ // xdeliver server for cross-process delivery (tested via the xorg check)
77
+ const srv = await startOrgServer(daemon, 0);
78
+ daemon.setInboxUrl(`http://127.0.0.1:${srv.port}`);
79
+ // Queue a message for partner:boss BEFORE starting it — verifies inbox drain on startup
80
+ queueMessage(root, 'partner', { fromQualified: 'external:system', toRole: 'boss', subject: 'pre-start', body: 'queued while offline', ts: Date.now() });
81
+ const alpha = await daemon.startOrg('alpha');
82
+ const partner = await daemon.startOrg('partner');
83
+ await waitFor(() => alpha.busEvents().some(e => e.type === 'message' && e.from === 'coder' && e.to === 'boss'));
84
+ await daemon.stopAll();
85
+ srv.close();
86
+ const evs = alpha.busEvents();
87
+ const has = (pred) => evs.some(pred);
88
+ const persistedCount = OrgBus.readHistory(join(root, ORG_DIR, 'alpha', alpha.run)).length;
89
+ const partnerEvs = partner.busEvents();
90
+ const checks = {
91
+ chat: has(e => e.type === 'chat'),
92
+ message: has(e => e.type === 'message' && e.from === 'boss' && e.to === 'coder'),
93
+ tool: has(e => e.type === 'tool' && e.decision === 'allow' && e.tool === 'Write'),
94
+ policyDeny: has(e => e.type === 'tool' && e.decision === 'deny' && e.tool === 'Bash'),
95
+ asset: has(e => e.type === 'asset' && (e.path ?? '').endsWith('out/report.md')),
96
+ xorg: has(e => e.type === 'xorg' && e.to === 'partner:boss'),
97
+ usage: has(e => e.type === 'usage'),
98
+ persisted: persistedCount === evs.length,
99
+ inboxDrain: partnerEvs.some(e => e.type === 'xorg' && e.from === 'external:system' && e.subject === 'pre-start'),
100
+ };
101
+ iterations.push({ checks, events: evs.length });
102
+ }
103
+ const failed = iterations.filter(it => Object.values(it.checks).some(v => !v)).length;
104
+ const summary = `org e2e: ${times - failed}/${times} passed` +
105
+ (failed ? ` — failing checks: ${JSON.stringify(iterations.filter(it => Object.values(it.checks).some(v => !v)).map(it => it.checks))}` : '');
106
+ return { iterations, failed, summary };
107
+ }
108
+ //# sourceMappingURL=test-loop.js.map
@@ -8,14 +8,14 @@ export declare const ProviderSchema: z.ZodObject<{
8
8
  /** env var NAME holding the auth token for base-url providers */
9
9
  authTokenEnv: z.ZodOptional<z.ZodString>;
10
10
  }, "strict", z.ZodTypeAny, {
11
- kind: "api-key" | "subscription" | "base-url" | "bedrock" | "vertex";
12
- baseUrl?: string | undefined;
11
+ kind: "api-key" | "base-url" | "bedrock" | "subscription" | "vertex";
13
12
  apiKeyEnv?: string | undefined;
13
+ baseUrl?: string | undefined;
14
14
  authTokenEnv?: string | undefined;
15
15
  }, {
16
- baseUrl?: string | undefined;
17
- kind?: "api-key" | "subscription" | "base-url" | "bedrock" | "vertex" | undefined;
16
+ kind?: "api-key" | "base-url" | "bedrock" | "subscription" | "vertex" | undefined;
18
17
  apiKeyEnv?: string | undefined;
18
+ baseUrl?: string | undefined;
19
19
  authTokenEnv?: string | undefined;
20
20
  }>;
21
21
  export declare const RolePolicySchema: z.ZodObject<{
@@ -65,14 +65,14 @@ export declare const RoleSchema: z.ZodObject<{
65
65
  /** env var NAME holding the auth token for base-url providers */
66
66
  authTokenEnv: z.ZodOptional<z.ZodString>;
67
67
  }, "strict", z.ZodTypeAny, {
68
- kind: "api-key" | "subscription" | "base-url" | "bedrock" | "vertex";
69
- baseUrl?: string | undefined;
68
+ kind: "api-key" | "base-url" | "bedrock" | "subscription" | "vertex";
70
69
  apiKeyEnv?: string | undefined;
70
+ baseUrl?: string | undefined;
71
71
  authTokenEnv?: string | undefined;
72
72
  }, {
73
- baseUrl?: string | undefined;
74
- kind?: "api-key" | "subscription" | "base-url" | "bedrock" | "vertex" | undefined;
73
+ kind?: "api-key" | "base-url" | "bedrock" | "subscription" | "vertex" | undefined;
75
74
  apiKeyEnv?: string | undefined;
75
+ baseUrl?: string | undefined;
76
76
  authTokenEnv?: string | undefined;
77
77
  }>>;
78
78
  policy: z.ZodOptional<z.ZodObject<{
@@ -122,14 +122,14 @@ export declare const RoleSchema: z.ZodObject<{
122
122
  /** env var NAME holding the auth token for base-url providers */
123
123
  authTokenEnv: z.ZodOptional<z.ZodString>;
124
124
  }, "strict", z.ZodTypeAny, {
125
- kind: "api-key" | "subscription" | "base-url" | "bedrock" | "vertex";
126
- baseUrl?: string | undefined;
125
+ kind: "api-key" | "base-url" | "bedrock" | "subscription" | "vertex";
127
126
  apiKeyEnv?: string | undefined;
127
+ baseUrl?: string | undefined;
128
128
  authTokenEnv?: string | undefined;
129
129
  }, {
130
- baseUrl?: string | undefined;
131
- kind?: "api-key" | "subscription" | "base-url" | "bedrock" | "vertex" | undefined;
130
+ kind?: "api-key" | "base-url" | "bedrock" | "subscription" | "vertex" | undefined;
132
131
  apiKeyEnv?: string | undefined;
132
+ baseUrl?: string | undefined;
133
133
  authTokenEnv?: string | undefined;
134
134
  }>>;
135
135
  policy: z.ZodOptional<z.ZodObject<{
@@ -179,14 +179,14 @@ export declare const RoleSchema: z.ZodObject<{
179
179
  /** env var NAME holding the auth token for base-url providers */
180
180
  authTokenEnv: z.ZodOptional<z.ZodString>;
181
181
  }, "strict", z.ZodTypeAny, {
182
- kind: "api-key" | "subscription" | "base-url" | "bedrock" | "vertex";
183
- baseUrl?: string | undefined;
182
+ kind: "api-key" | "base-url" | "bedrock" | "subscription" | "vertex";
184
183
  apiKeyEnv?: string | undefined;
184
+ baseUrl?: string | undefined;
185
185
  authTokenEnv?: string | undefined;
186
186
  }, {
187
- baseUrl?: string | undefined;
188
- kind?: "api-key" | "subscription" | "base-url" | "bedrock" | "vertex" | undefined;
187
+ kind?: "api-key" | "base-url" | "bedrock" | "subscription" | "vertex" | undefined;
189
188
  apiKeyEnv?: string | undefined;
189
+ baseUrl?: string | undefined;
190
190
  authTokenEnv?: string | undefined;
191
191
  }>>;
192
192
  policy: z.ZodOptional<z.ZodObject<{
@@ -268,14 +268,14 @@ export declare const OrgDefSchema: z.ZodObject<{
268
268
  /** env var NAME holding the auth token for base-url providers */
269
269
  authTokenEnv: z.ZodOptional<z.ZodString>;
270
270
  }, "strict", z.ZodTypeAny, {
271
- kind: "api-key" | "subscription" | "base-url" | "bedrock" | "vertex";
272
- baseUrl?: string | undefined;
271
+ kind: "api-key" | "base-url" | "bedrock" | "subscription" | "vertex";
273
272
  apiKeyEnv?: string | undefined;
273
+ baseUrl?: string | undefined;
274
274
  authTokenEnv?: string | undefined;
275
275
  }, {
276
- baseUrl?: string | undefined;
277
- kind?: "api-key" | "subscription" | "base-url" | "bedrock" | "vertex" | undefined;
276
+ kind?: "api-key" | "base-url" | "bedrock" | "subscription" | "vertex" | undefined;
278
277
  apiKeyEnv?: string | undefined;
278
+ baseUrl?: string | undefined;
279
279
  authTokenEnv?: string | undefined;
280
280
  }>>;
281
281
  policy: z.ZodOptional<z.ZodObject<{
@@ -325,14 +325,14 @@ export declare const OrgDefSchema: z.ZodObject<{
325
325
  /** env var NAME holding the auth token for base-url providers */
326
326
  authTokenEnv: z.ZodOptional<z.ZodString>;
327
327
  }, "strict", z.ZodTypeAny, {
328
- kind: "api-key" | "subscription" | "base-url" | "bedrock" | "vertex";
329
- baseUrl?: string | undefined;
328
+ kind: "api-key" | "base-url" | "bedrock" | "subscription" | "vertex";
330
329
  apiKeyEnv?: string | undefined;
330
+ baseUrl?: string | undefined;
331
331
  authTokenEnv?: string | undefined;
332
332
  }, {
333
- baseUrl?: string | undefined;
334
- kind?: "api-key" | "subscription" | "base-url" | "bedrock" | "vertex" | undefined;
333
+ kind?: "api-key" | "base-url" | "bedrock" | "subscription" | "vertex" | undefined;
335
334
  apiKeyEnv?: string | undefined;
335
+ baseUrl?: string | undefined;
336
336
  authTokenEnv?: string | undefined;
337
337
  }>>;
338
338
  policy: z.ZodOptional<z.ZodObject<{
@@ -382,14 +382,14 @@ export declare const OrgDefSchema: z.ZodObject<{
382
382
  /** env var NAME holding the auth token for base-url providers */
383
383
  authTokenEnv: z.ZodOptional<z.ZodString>;
384
384
  }, "strict", z.ZodTypeAny, {
385
- kind: "api-key" | "subscription" | "base-url" | "bedrock" | "vertex";
386
- baseUrl?: string | undefined;
385
+ kind: "api-key" | "base-url" | "bedrock" | "subscription" | "vertex";
387
386
  apiKeyEnv?: string | undefined;
387
+ baseUrl?: string | undefined;
388
388
  authTokenEnv?: string | undefined;
389
389
  }, {
390
- baseUrl?: string | undefined;
391
- kind?: "api-key" | "subscription" | "base-url" | "bedrock" | "vertex" | undefined;
390
+ kind?: "api-key" | "base-url" | "bedrock" | "subscription" | "vertex" | undefined;
392
391
  apiKeyEnv?: string | undefined;
392
+ baseUrl?: string | undefined;
393
393
  authTokenEnv?: string | undefined;
394
394
  }>>;
395
395
  policy: z.ZodOptional<z.ZodObject<{
@@ -471,14 +471,14 @@ export declare const OrgDefSchema: z.ZodObject<{
471
471
  /** env var NAME holding the auth token for base-url providers */
472
472
  authTokenEnv: z.ZodOptional<z.ZodString>;
473
473
  }, "strict", z.ZodTypeAny, {
474
- kind: "api-key" | "subscription" | "base-url" | "bedrock" | "vertex";
475
- baseUrl?: string | undefined;
474
+ kind: "api-key" | "base-url" | "bedrock" | "subscription" | "vertex";
476
475
  apiKeyEnv?: string | undefined;
476
+ baseUrl?: string | undefined;
477
477
  authTokenEnv?: string | undefined;
478
478
  }, {
479
- baseUrl?: string | undefined;
480
- kind?: "api-key" | "subscription" | "base-url" | "bedrock" | "vertex" | undefined;
479
+ kind?: "api-key" | "base-url" | "bedrock" | "subscription" | "vertex" | undefined;
481
480
  apiKeyEnv?: string | undefined;
481
+ baseUrl?: string | undefined;
482
482
  authTokenEnv?: string | undefined;
483
483
  }>>;
484
484
  policy: z.ZodOptional<z.ZodObject<{
@@ -528,14 +528,14 @@ export declare const OrgDefSchema: z.ZodObject<{
528
528
  /** env var NAME holding the auth token for base-url providers */
529
529
  authTokenEnv: z.ZodOptional<z.ZodString>;
530
530
  }, "strict", z.ZodTypeAny, {
531
- kind: "api-key" | "subscription" | "base-url" | "bedrock" | "vertex";
532
- baseUrl?: string | undefined;
531
+ kind: "api-key" | "base-url" | "bedrock" | "subscription" | "vertex";
533
532
  apiKeyEnv?: string | undefined;
533
+ baseUrl?: string | undefined;
534
534
  authTokenEnv?: string | undefined;
535
535
  }, {
536
- baseUrl?: string | undefined;
537
- kind?: "api-key" | "subscription" | "base-url" | "bedrock" | "vertex" | undefined;
536
+ kind?: "api-key" | "base-url" | "bedrock" | "subscription" | "vertex" | undefined;
538
537
  apiKeyEnv?: string | undefined;
538
+ baseUrl?: string | undefined;
539
539
  authTokenEnv?: string | undefined;
540
540
  }>>;
541
541
  policy: z.ZodOptional<z.ZodObject<{
@@ -585,14 +585,14 @@ export declare const OrgDefSchema: z.ZodObject<{
585
585
  /** env var NAME holding the auth token for base-url providers */
586
586
  authTokenEnv: z.ZodOptional<z.ZodString>;
587
587
  }, "strict", z.ZodTypeAny, {
588
- kind: "api-key" | "subscription" | "base-url" | "bedrock" | "vertex";
589
- baseUrl?: string | undefined;
588
+ kind: "api-key" | "base-url" | "bedrock" | "subscription" | "vertex";
590
589
  apiKeyEnv?: string | undefined;
590
+ baseUrl?: string | undefined;
591
591
  authTokenEnv?: string | undefined;
592
592
  }, {
593
- baseUrl?: string | undefined;
594
- kind?: "api-key" | "subscription" | "base-url" | "bedrock" | "vertex" | undefined;
593
+ kind?: "api-key" | "base-url" | "bedrock" | "subscription" | "vertex" | undefined;
595
594
  apiKeyEnv?: string | undefined;
595
+ baseUrl?: string | undefined;
596
596
  authTokenEnv?: string | undefined;
597
597
  }>>;
598
598
  policy: z.ZodOptional<z.ZodObject<{
@@ -674,14 +674,14 @@ export declare const OrgDefSchema: z.ZodObject<{
674
674
  /** env var NAME holding the auth token for base-url providers */
675
675
  authTokenEnv: z.ZodOptional<z.ZodString>;
676
676
  }, "strict", z.ZodTypeAny, {
677
- kind: "api-key" | "subscription" | "base-url" | "bedrock" | "vertex";
678
- baseUrl?: string | undefined;
677
+ kind: "api-key" | "base-url" | "bedrock" | "subscription" | "vertex";
679
678
  apiKeyEnv?: string | undefined;
679
+ baseUrl?: string | undefined;
680
680
  authTokenEnv?: string | undefined;
681
681
  }, {
682
- baseUrl?: string | undefined;
683
- kind?: "api-key" | "subscription" | "base-url" | "bedrock" | "vertex" | undefined;
682
+ kind?: "api-key" | "base-url" | "bedrock" | "subscription" | "vertex" | undefined;
684
683
  apiKeyEnv?: string | undefined;
684
+ baseUrl?: string | undefined;
685
685
  authTokenEnv?: string | undefined;
686
686
  }>>;
687
687
  policy: z.ZodOptional<z.ZodObject<{
@@ -731,14 +731,14 @@ export declare const OrgDefSchema: z.ZodObject<{
731
731
  /** env var NAME holding the auth token for base-url providers */
732
732
  authTokenEnv: z.ZodOptional<z.ZodString>;
733
733
  }, "strict", z.ZodTypeAny, {
734
- kind: "api-key" | "subscription" | "base-url" | "bedrock" | "vertex";
735
- baseUrl?: string | undefined;
734
+ kind: "api-key" | "base-url" | "bedrock" | "subscription" | "vertex";
736
735
  apiKeyEnv?: string | undefined;
736
+ baseUrl?: string | undefined;
737
737
  authTokenEnv?: string | undefined;
738
738
  }, {
739
- baseUrl?: string | undefined;
740
- kind?: "api-key" | "subscription" | "base-url" | "bedrock" | "vertex" | undefined;
739
+ kind?: "api-key" | "base-url" | "bedrock" | "subscription" | "vertex" | undefined;
741
740
  apiKeyEnv?: string | undefined;
741
+ baseUrl?: string | undefined;
742
742
  authTokenEnv?: string | undefined;
743
743
  }>>;
744
744
  policy: z.ZodOptional<z.ZodObject<{
@@ -788,14 +788,14 @@ export declare const OrgDefSchema: z.ZodObject<{
788
788
  /** env var NAME holding the auth token for base-url providers */
789
789
  authTokenEnv: z.ZodOptional<z.ZodString>;
790
790
  }, "strict", z.ZodTypeAny, {
791
- kind: "api-key" | "subscription" | "base-url" | "bedrock" | "vertex";
792
- baseUrl?: string | undefined;
791
+ kind: "api-key" | "base-url" | "bedrock" | "subscription" | "vertex";
793
792
  apiKeyEnv?: string | undefined;
793
+ baseUrl?: string | undefined;
794
794
  authTokenEnv?: string | undefined;
795
795
  }, {
796
- baseUrl?: string | undefined;
797
- kind?: "api-key" | "subscription" | "base-url" | "bedrock" | "vertex" | undefined;
796
+ kind?: "api-key" | "base-url" | "bedrock" | "subscription" | "vertex" | undefined;
798
797
  apiKeyEnv?: string | undefined;
798
+ baseUrl?: string | undefined;
799
799
  authTokenEnv?: string | undefined;
800
800
  }>>;
801
801
  policy: z.ZodOptional<z.ZodObject<{
@@ -4,35 +4,35 @@
4
4
  */
5
5
  import type { TableOptions, ProgressOptions, SpinnerOptions } from './types.js';
6
6
  declare const COLORS: {
7
- readonly reset: "\u001B[0m";
8
- readonly bold: "\u001B[1m";
9
- readonly dim: "\u001B[2m";
10
- readonly italic: "\u001B[3m";
11
- readonly underline: "\u001B[4m";
12
- readonly black: "\u001B[30m";
13
- readonly red: "\u001B[31m";
14
- readonly green: "\u001B[32m";
15
- readonly yellow: "\u001B[33m";
16
- readonly blue: "\u001B[34m";
17
- readonly magenta: "\u001B[35m";
18
- readonly cyan: "\u001B[36m";
19
- readonly white: "\u001B[37m";
20
- readonly gray: "\u001B[90m";
21
- readonly brightRed: "\u001B[91m";
22
- readonly brightGreen: "\u001B[92m";
23
- readonly brightYellow: "\u001B[93m";
24
- readonly brightBlue: "\u001B[94m";
25
- readonly brightMagenta: "\u001B[95m";
26
- readonly brightCyan: "\u001B[96m";
27
- readonly brightWhite: "\u001B[97m";
28
- readonly bgBlack: "\u001B[40m";
29
- readonly bgRed: "\u001B[41m";
30
- readonly bgGreen: "\u001B[42m";
31
- readonly bgYellow: "\u001B[43m";
32
- readonly bgBlue: "\u001B[44m";
33
- readonly bgMagenta: "\u001B[45m";
34
- readonly bgCyan: "\u001B[46m";
35
- readonly bgWhite: "\u001B[47m";
7
+ readonly reset: '\u001B[0m';
8
+ readonly bold: '\u001B[1m';
9
+ readonly dim: '\u001B[2m';
10
+ readonly italic: '\u001B[3m';
11
+ readonly underline: '\u001B[4m';
12
+ readonly black: '\u001B[30m';
13
+ readonly red: '\u001B[31m';
14
+ readonly green: '\u001B[32m';
15
+ readonly yellow: '\u001B[33m';
16
+ readonly blue: '\u001B[34m';
17
+ readonly magenta: '\u001B[35m';
18
+ readonly cyan: '\u001B[36m';
19
+ readonly white: '\u001B[37m';
20
+ readonly gray: '\u001B[90m';
21
+ readonly brightRed: '\u001B[91m';
22
+ readonly brightGreen: '\u001B[92m';
23
+ readonly brightYellow: '\u001B[93m';
24
+ readonly brightBlue: '\u001B[94m';
25
+ readonly brightMagenta: '\u001B[95m';
26
+ readonly brightCyan: '\u001B[96m';
27
+ readonly brightWhite: '\u001B[97m';
28
+ readonly bgBlack: '\u001B[40m';
29
+ readonly bgRed: '\u001B[41m';
30
+ readonly bgGreen: '\u001B[42m';
31
+ readonly bgYellow: '\u001B[43m';
32
+ readonly bgBlue: '\u001B[44m';
33
+ readonly bgMagenta: '\u001B[45m';
34
+ readonly bgCyan: '\u001B[46m';
35
+ readonly bgWhite: '\u001B[47m';
36
36
  };
37
37
  type ColorName = keyof typeof COLORS;
38
38
  export type VerbosityLevel = 'quiet' | 'normal' | 'verbose' | 'debug';