@dirgha/code 1.7.6 → 1.7.7

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 (66) hide show
  1. package/CHANGELOG.md +52 -5
  2. package/CREDITS.md +46 -0
  3. package/LICENSE +101 -21
  4. package/README.md +15 -9
  5. package/dist_v2/cli/config.d.ts +1 -0
  6. package/dist_v2/cli/config.js.map +1 -1
  7. package/dist_v2/cli/main.js +8 -18
  8. package/dist_v2/cli/main.js.map +1 -1
  9. package/dist_v2/cli/slash.js +0 -6
  10. package/dist_v2/cli/slash.js.map +1 -1
  11. package/dist_v2/cli/subcommands/index.js +2 -0
  12. package/dist_v2/cli/subcommands/index.js.map +1 -1
  13. package/dist_v2/cli/subcommands/web.d.ts +13 -0
  14. package/dist_v2/cli/subcommands/web.js +61 -0
  15. package/dist_v2/cli/subcommands/web.js.map +1 -0
  16. package/dist_v2/intelligence/models-dev-sync.d.ts +39 -0
  17. package/dist_v2/intelligence/models-dev-sync.js +103 -0
  18. package/dist_v2/intelligence/models-dev-sync.js.map +1 -0
  19. package/dist_v2/kernel/agent-loop.d.ts +8 -38
  20. package/dist_v2/kernel/agent-loop.js +18 -57
  21. package/dist_v2/kernel/agent-loop.js.map +1 -1
  22. package/dist_v2/kernel/index.d.ts +0 -1
  23. package/dist_v2/kernel/index.js +0 -1
  24. package/dist_v2/kernel/index.js.map +1 -1
  25. package/dist_v2/kernel/message.d.ts +1 -17
  26. package/dist_v2/kernel/message.js +0 -26
  27. package/dist_v2/kernel/message.js.map +1 -1
  28. package/dist_v2/kernel/types.d.ts +0 -29
  29. package/dist_v2/skills/install-npm.d.ts +16 -0
  30. package/dist_v2/skills/install-npm.js +97 -0
  31. package/dist_v2/skills/install-npm.js.map +1 -0
  32. package/dist_v2/tools/browser.js +6 -3
  33. package/dist_v2/tools/browser.js.map +1 -1
  34. package/dist_v2/tools/index.d.ts +1 -3
  35. package/dist_v2/tools/index.js +1 -5
  36. package/dist_v2/tools/index.js.map +1 -1
  37. package/dist_v2/tui/ink/App.d.ts +3 -0
  38. package/dist_v2/tui/ink/App.js +85 -124
  39. package/dist_v2/tui/ink/App.js.map +1 -1
  40. package/dist_v2/tui/ink/components/SlashComplete.d.ts +1 -7
  41. package/dist_v2/tui/ink/components/SlashComplete.js +2 -9
  42. package/dist_v2/tui/ink/components/SlashComplete.js.map +1 -1
  43. package/dist_v2/tui/ink/index.js +4 -0
  44. package/dist_v2/tui/ink/index.js.map +1 -1
  45. package/dist_v2/web/cost.d.ts +35 -0
  46. package/dist_v2/web/cost.js +211 -0
  47. package/dist_v2/web/cost.js.map +1 -0
  48. package/dist_v2/web/ledger.d.ts +25 -0
  49. package/dist_v2/web/ledger.js +156 -0
  50. package/dist_v2/web/ledger.js.map +1 -0
  51. package/dist_v2/web/server.d.ts +30 -0
  52. package/dist_v2/web/server.js +199 -0
  53. package/dist_v2/web/server.js.map +1 -0
  54. package/package.json +32 -52
  55. package/dist_v2/kernel/queues.d.ts +0 -82
  56. package/dist_v2/kernel/queues.js +0 -105
  57. package/dist_v2/kernel/queues.js.map +0 -1
  58. package/dist_v2/providers/faux.d.ts +0 -99
  59. package/dist_v2/providers/faux.js +0 -153
  60. package/dist_v2/providers/faux.js.map +0 -1
  61. package/dist_v2/tools/webfetch.d.ts +0 -11
  62. package/dist_v2/tools/webfetch.js +0 -130
  63. package/dist_v2/tools/webfetch.js.map +0 -1
  64. package/dist_v2/tools/websearch.d.ts +0 -14
  65. package/dist_v2/tools/websearch.js +0 -137
  66. package/dist_v2/tools/websearch.js.map +0 -1
@@ -0,0 +1,199 @@
1
+ // scope: S19a
2
+ import { createServer } from 'node:http';
3
+ import { readFile } from 'node:fs/promises';
4
+ import path from 'node:path';
5
+ import os from 'node:os';
6
+ import { aggregateCost, renderCostPage } from './cost.js';
7
+ import { collectLedger, renderLedgerPage } from './ledger.js';
8
+ function escapeHtml(text) {
9
+ return text
10
+ .replace(/&/g, '&')
11
+ .replace(/</g, '&lt;')
12
+ .replace(/>/g, '&gt;')
13
+ .replace(/"/g, '&quot;')
14
+ .replace(/'/g, '&#39;');
15
+ }
16
+ export function renderAuditPage(entries, opts) {
17
+ const limit = opts?.limit;
18
+ const data = limit ? entries.slice(0, limit) : entries;
19
+ const rows = data.map(entry => {
20
+ const ts = escapeHtml(entry.ts);
21
+ const kind = escapeHtml(entry.kind);
22
+ const actor = entry.actor ? escapeHtml(entry.actor) : '';
23
+ const summaryRaw = entry.summary ? entry.summary.slice(0, 120) : '';
24
+ const summary = escapeHtml(summaryRaw);
25
+ return `<tr>
26
+ <td class="ts">${ts}</td>
27
+ <td class="kind">${kind}</td>
28
+ <td>${actor}</td>
29
+ <td class="summary">${summary}</td>
30
+ </tr>`;
31
+ }).join('\n');
32
+ return `<!DOCTYPE html>
33
+ <html lang="en">
34
+ <head>
35
+ <meta charset="utf-8">
36
+ <meta name="viewport" content="width=device-width, initial-scale=1">
37
+ <title>Dirgha Audit Dashboard</title>
38
+ <style>
39
+ :root { color-scheme: dark; }
40
+ body {
41
+ font-family: system-ui, sans-serif;
42
+ background: #1e1e1e;
43
+ color: #d4d4d4;
44
+ margin: 0;
45
+ padding: 1rem;
46
+ }
47
+ h1 { margin-top: 0; }
48
+ table {
49
+ border-collapse: collapse;
50
+ width: 100%;
51
+ }
52
+ th, td {
53
+ text-align: left;
54
+ padding: 0.5rem;
55
+ border-bottom: 1px solid #333;
56
+ }
57
+ th { background: #252525; }
58
+ td.ts, td.kind {
59
+ font-family: monospace;
60
+ white-space: nowrap;
61
+ }
62
+ td.summary {
63
+ max-width: 40rem;
64
+ overflow: hidden;
65
+ text-overflow: ellipsis;
66
+ white-space: nowrap;
67
+ }
68
+ </style>
69
+ </head>
70
+ <body>
71
+ <h1>Dirgha Audit Events</h1>
72
+ <table>
73
+ <thead>
74
+ <tr>
75
+ <th>Timestamp</th>
76
+ <th>Kind</th>
77
+ <th>Actor</th>
78
+ <th>Summary</th>
79
+ </tr>
80
+ </thead>
81
+ <tbody>
82
+ ${rows}
83
+ </tbody>
84
+ </table>
85
+ </body>
86
+ </html>`;
87
+ }
88
+ export async function readAuditEntries(file, limit) {
89
+ let content;
90
+ try {
91
+ content = await readFile(file, 'utf-8');
92
+ }
93
+ catch {
94
+ return [];
95
+ }
96
+ const lines = content.split('\n');
97
+ const entries = [];
98
+ for (const line of lines) {
99
+ const trimmed = line.trim();
100
+ if (!trimmed)
101
+ continue;
102
+ try {
103
+ const parsed = JSON.parse(trimmed);
104
+ if (typeof parsed === 'object' && parsed !== null && 'ts' in parsed && 'kind' in parsed) {
105
+ entries.push(parsed);
106
+ }
107
+ }
108
+ catch {
109
+ // swallow malformed line
110
+ }
111
+ }
112
+ entries.sort((a, b) => {
113
+ const aTime = new Date(a.ts).getTime();
114
+ const bTime = new Date(b.ts).getTime();
115
+ return bTime - aTime; // newest first
116
+ });
117
+ if (limit !== undefined && limit > 0) {
118
+ return entries.slice(0, limit);
119
+ }
120
+ return entries;
121
+ }
122
+ export async function startWebServer(opts) {
123
+ const host = (() => {
124
+ const h = opts?.host ?? '127.0.0.1';
125
+ if (h === '0.0.0.0')
126
+ return '127.0.0.1';
127
+ return h;
128
+ })();
129
+ const portFromEnv = process.env.DIRGHA_WEB_PORT ? parseInt(process.env.DIRGHA_WEB_PORT, 10) : undefined;
130
+ const port = opts?.port ?? (isNaN(portFromEnv) ? 7878 : portFromEnv) ?? 7878;
131
+ const resolvedPort = isNaN(port) ? 7878 : port;
132
+ const auditFile = opts?.auditFile ?? path.join(os.homedir(), '.dirgha', 'audit', 'events.jsonl');
133
+ const HTML_HEADERS = {
134
+ 'Content-Type': 'text/html; charset=utf-8',
135
+ 'Cache-Control': 'no-store',
136
+ };
137
+ const server = createServer(async (req, res) => {
138
+ if (req.method !== 'GET') {
139
+ res.writeHead(405, { 'Content-Type': 'text/plain; charset=utf-8' });
140
+ res.end('Method Not Allowed');
141
+ return;
142
+ }
143
+ try {
144
+ if (req.url === '/') {
145
+ const entries = await readAuditEntries(auditFile, 100);
146
+ res.writeHead(200, HTML_HEADERS);
147
+ res.end(renderAuditPage(entries));
148
+ return;
149
+ }
150
+ if (req.url === '/cost') {
151
+ const entries = await readAuditEntries(auditFile);
152
+ // CostAuditEntry is structurally compatible — just retype.
153
+ const summary = aggregateCost(entries);
154
+ res.writeHead(200, HTML_HEADERS);
155
+ res.end(renderCostPage(summary));
156
+ return;
157
+ }
158
+ if (req.url === '/ledger') {
159
+ const summary = await collectLedger();
160
+ res.writeHead(200, HTML_HEADERS);
161
+ res.end(renderLedgerPage(summary));
162
+ return;
163
+ }
164
+ res.writeHead(404, { 'Content-Type': 'text/plain; charset=utf-8' });
165
+ res.end('Not Found');
166
+ }
167
+ catch {
168
+ res.writeHead(500, { 'Content-Type': 'text/plain; charset=utf-8' });
169
+ res.end('Internal Server Error');
170
+ }
171
+ });
172
+ await new Promise((resolve, reject) => {
173
+ server.listen(resolvedPort, host, () => resolve());
174
+ server.on('error', reject);
175
+ });
176
+ const addr = server.address();
177
+ let url;
178
+ if (typeof addr === 'string') {
179
+ url = addr;
180
+ }
181
+ else if (addr) {
182
+ url = `http://${addr.address}:${addr.port}`;
183
+ }
184
+ else {
185
+ url = `http://${host}:${resolvedPort}`;
186
+ }
187
+ return {
188
+ url,
189
+ close: () => new Promise((resolve, reject) => {
190
+ server.close((err) => {
191
+ if (err)
192
+ reject(err);
193
+ else
194
+ resolve();
195
+ });
196
+ }),
197
+ };
198
+ }
199
+ //# sourceMappingURL=server.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"server.js","sourceRoot":"","sources":["../../src_v2/web/server.ts"],"names":[],"mappings":"AAAA,cAAc;AAEd,OAAO,EAAE,YAAY,EAAE,MAAM,WAAW,CAAC;AACzC,OAAO,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AAC5C,OAAO,IAAI,MAAM,WAAW,CAAC;AAC7B,OAAO,EAAE,MAAM,SAAS,CAAC;AACzB,OAAO,EAAE,aAAa,EAAE,cAAc,EAAuB,MAAM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,CAAC;YACP,GAAG,CAAC,SAAS,CAAC,GAAG,EAAE,EAAE,cAAc,EAAE,2BAA2B,EAAE,CAAC,CAAC;YACpE,GAAG,CAAC,GAAG,CAAC,uBAAuB,CAAC,CAAC;QACnC,CAAC;IACH,CAAC,CAAC,CAAC;IAEH,MAAM,IAAI,OAAO,CAAO,CAAC,OAAO,EAAE,MAAM,EAAE,EAAE;QAC1C,MAAM,CAAC,MAAM,CAAC,YAAY,EAAE,IAAI,EAAE,GAAG,EAAE,CAAC,OAAO,EAAE,CAAC,CAAC;QACnD,MAAM,CAAC,EAAE,CAAC,OAAO,EAAE,MAAM,CAAC,CAAC;IAC7B,CAAC,CAAC,CAAC;IAEH,MAAM,IAAI,GAAG,MAAM,CAAC,OAAO,EAAE,CAAC;IAC9B,IAAI,GAAW,CAAC;IAChB,IAAI,OAAO,IAAI,KAAK,QAAQ,EAAE,CAAC;QAC7B,GAAG,GAAG,IAAI,CAAC;IACb,CAAC;SAAM,IAAI,IAAI,EAAE,CAAC;QAChB,GAAG,GAAG,UAAU,IAAI,CAAC,OAAO,IAAI,IAAI,CAAC,IAAI,EAAE,CAAC;IAC9C,CAAC;SAAM,CAAC;QACN,GAAG,GAAG,UAAU,IAAI,IAAI,YAAY,EAAE,CAAC;IACzC,CAAC;IAED,OAAO;QACL,GAAG;QACH,KAAK,EAAE,GAAG,EAAE,CAAC,IAAI,OAAO,CAAO,CAAC,OAAO,EAAE,MAAM,EAAE,EAAE;YACjD,MAAM,CAAC,KAAK,CAAC,CAAC,GAAG,EAAE,EAAE;gBACnB,IAAI,GAAG;oBAAE,MAAM,CAAC,GAAG,CAAC,CAAC;;oBAChB,OAAO,EAAE,CAAC;YACjB,CAAC,CAAC,CAAC;QACL,CAAC,CAAC;KACH,CAAC;AACJ,CAAC"}
package/package.json CHANGED
@@ -1,13 +1,12 @@
1
1
  {
2
2
  "name": "@dirgha/code",
3
- "version": "1.7.6",
4
- "description": "Dirgha — local-first coding agent for the terminal",
3
+ "version": "1.7.7",
4
+ "description": "CLI coding agent for complex agentic workflows and long-horizon development. Local models (llama.cpp / Ollama), BYOK across 17 providers, parallel agents, persistent memory, scanned skills.",
5
5
  "type": "module",
6
6
  "main": "./dist_v2/index.js",
7
7
  "types": "./dist_v2/index.d.ts",
8
8
  "bin": {
9
- "dirgha": "./dist_v2/cli/main.js",
10
- "dirgha-v1": "./dist/cli.js"
9
+ "dirgha": "./dist_v2/cli/main.js"
11
10
  },
12
11
  "files": [
13
12
  "dist_v2/",
@@ -17,59 +16,27 @@
17
16
  "CHANGELOG.md"
18
17
  ],
19
18
  "scripts": {
20
- "build": "tsc --build",
21
- "build:watch": "tsc --build --watch",
22
- "build:v2": "tsc -p tsconfig.v2.json && cp src_v2/context/default-soul.md dist_v2/context/default-soul.md",
23
- "build:v2:watch": "tsc -p tsconfig.v2.json --watch",
24
- "clean": "rm -rf ./dist ./dist_v2",
25
- "test": "vitest run",
26
- "test:watch": "vitest",
27
- "test:coverage": "vitest run --coverage",
28
- "test:v2": "vitest run --dir src_v2",
19
+ "build": "tsc -p tsconfig.v2.json && cp src_v2/context/default-soul.md dist_v2/context/default-soul.md",
20
+ "build:watch": "tsc -p tsconfig.v2.json --watch",
21
+ "clean": "rm -rf ./dist_v2",
22
+ "test": "vitest run --dir src_v2",
29
23
  "test:cli": "node scripts/qa-app/run-all.mjs",
30
- "test:cli:quick": "node scripts/qa-app/run-all.mjs --quick",
31
24
  "test:cli:offline": "node scripts/qa-app/run-all.mjs --offline",
32
- "lint": "eslint src --ext .ts",
33
- "typecheck": "tsc --noEmit",
34
- "typecheck:v2": "tsc -p tsconfig.v2.json --noEmit",
35
- "v2": "node dist_v2/cli/main.js",
36
- "prepublishOnly": "npm run build"
25
+ "test:tui": "bash scripts/qa-app/picker-flow.sh",
26
+ "test:smoke": "bash scripts/smoke-matrix.sh all",
27
+ "typecheck": "tsc -p tsconfig.v2.json --noEmit",
28
+ "verify-install": "bash scripts/verify-install.sh",
29
+ "prepublish-guard": "bash scripts/prepublish-guard.sh",
30
+ "prepublishOnly": "npm run prepublish-guard && npm run build && npm run verify-install"
37
31
  },
38
32
  "dependencies": {
39
- "@ai-sdk/google": "^0.0.48",
40
- "@ai-sdk/openai": "^0.0.66",
41
- "@anthropic-ai/sdk": "^0.24.0",
42
- "@dirgha/pricing": "workspace:*",
43
- "ai": "^3.0.0",
44
- "better-sqlite3": "^11.3.0",
45
- "chalk": "^5.3.0",
46
- "cli-markdown": "^1.0.0",
47
- "commander": "^12.0.0",
48
- "dotenv": "^16.4.1",
49
- "express": "^4.18.2",
50
- "figlet": "^1.7.0",
51
33
  "ink": "^5.0.0",
52
34
  "ink-text-input": "^6.0.0",
53
- "inquirer": "^9.2.12",
54
- "ora": "^7.0.1",
55
- "pino": "^8.19.0",
56
- "pino-pretty": "^10.3.1",
57
- "playwright": "^1.47.0",
58
- "react": "^18.3.0",
59
- "readline": "^1.3.0",
60
- "uuid": "^9.0.1",
61
- "yaml": "^2.3.4",
62
- "zod": "^3.22.4"
35
+ "react": "^18.3.0"
63
36
  },
64
37
  "devDependencies": {
65
- "@types/express": "^4.17.21",
66
- "@types/figlet": "^1.5.8",
67
38
  "@types/node": "^20.11.5",
68
- "@types/uuid": "^9.0.7",
69
- "@typescript-eslint/eslint-plugin": "^6.19.1",
70
- "@typescript-eslint/parser": "^6.19.1",
71
- "@vitest/coverage-v8": "^1.2.2",
72
- "eslint": "^8.56.0",
39
+ "@types/react": "^18.3.0",
73
40
  "typescript": "^5.3.3",
74
41
  "vitest": "^1.2.2"
75
42
  },
@@ -77,12 +44,25 @@
77
44
  "node": ">=18.0.0"
78
45
  },
79
46
  "keywords": [
80
- "ai",
81
47
  "cli",
82
- "agent",
48
+ "coding-agent",
83
49
  "llm",
84
- "tool-calling"
50
+ "byok",
51
+ "ai",
52
+ "agent",
53
+ "tool-calling",
54
+ "openrouter",
55
+ "anthropic",
56
+ "openai"
85
57
  ],
58
+ "homepage": "https://github.com/Dirgha-AI/dirgha-code",
59
+ "repository": {
60
+ "type": "git",
61
+ "url": "git+https://github.com/Dirgha-AI/dirgha-code.git"
62
+ },
63
+ "bugs": {
64
+ "url": "https://github.com/Dirgha-AI/dirgha-code/issues"
65
+ },
86
66
  "author": "Dirgha AI Team",
87
- "license": "MIT"
67
+ "license": "SEE LICENSE IN LICENSE"
88
68
  }
@@ -1,82 +0,0 @@
1
- /**
2
- * Steering and follow-up queues for mid-flight agent control.
3
- *
4
- * Two queue types with different drain semantics:
5
- *
6
- * - SteeringQueue: drain mode 'all'. Every queued message replaces the
7
- * current turn's prompt mid-flight. Used for "stop and do this instead".
8
- * When drained, all queued messages are returned and the queue is cleared.
9
- *
10
- * - FollowUpQueue: drain mode 'one-at-a-time'. Each queued message becomes
11
- * the next turn after the current one completes. When drained, only one
12
- * message is returned (if any), leaving the rest for subsequent drains.
13
- *
14
- * Both queues accept `AgentMessage` (user messages to inject into the
15
- * conversation) and expose the standard queue operations: enqueue, drain,
16
- * peek, and clear.
17
- */
18
- import type { AgentMessage } from './types.js';
19
- /**
20
- * Drain mode determines how many messages are removed on drain.
21
- * - 'all': drain removes every queued message.
22
- * - 'one': drain removes at most one message.
23
- */
24
- type DrainMode = 'all' | 'one';
25
- /**
26
- * Base queue implementation with configurable drain behaviour.
27
- */
28
- declare class MessageQueue {
29
- protected readonly messages: AgentMessage[];
30
- protected readonly mode: DrainMode;
31
- constructor(mode: DrainMode);
32
- /**
33
- * Append a message to the end of the queue.
34
- */
35
- enqueue(msg: AgentMessage): void;
36
- /**
37
- * Remove and return messages according to the drain mode.
38
- *
39
- * - 'all': returns all messages (or null if empty), clears the queue.
40
- * - 'one': returns the oldest message as a single-element array (or null
41
- * if empty), removes only that message.
42
- */
43
- drain(): AgentMessage[] | null;
44
- /**
45
- * Peek at queued messages without removing them.
46
- *
47
- * - 'all': returns all messages (or null if empty).
48
- * - 'one': returns the oldest message as a single-element array (or null
49
- * if empty).
50
- */
51
- peek(): AgentMessage[] | null;
52
- /**
53
- * Remove all messages from the queue.
54
- */
55
- clear(): void;
56
- /**
57
- * Number of messages currently in the queue.
58
- */
59
- get length(): number;
60
- }
61
- /**
62
- * SteeringQueue: drain mode 'all'.
63
- *
64
- * Used for mid-flight steering — "stop and do this instead". When drained,
65
- * all queued messages are returned and the queue is cleared. The agent loop
66
- * should push these messages into history and continue looping (i.e. not
67
- * break on end_turn).
68
- */
69
- export declare class SteeringQueue extends MessageQueue {
70
- constructor();
71
- }
72
- /**
73
- * FollowUpQueue: drain mode 'one-at-a-time'.
74
- *
75
- * Used for scheduling follow-up turns. Each queued message becomes the next
76
- * turn after the current one completes. When drained, only one message is
77
- * returned (if any), leaving the rest for subsequent drains.
78
- */
79
- export declare class FollowUpQueue extends MessageQueue {
80
- constructor();
81
- }
82
- export {};
@@ -1,105 +0,0 @@
1
- /**
2
- * Steering and follow-up queues for mid-flight agent control.
3
- *
4
- * Two queue types with different drain semantics:
5
- *
6
- * - SteeringQueue: drain mode 'all'. Every queued message replaces the
7
- * current turn's prompt mid-flight. Used for "stop and do this instead".
8
- * When drained, all queued messages are returned and the queue is cleared.
9
- *
10
- * - FollowUpQueue: drain mode 'one-at-a-time'. Each queued message becomes
11
- * the next turn after the current one completes. When drained, only one
12
- * message is returned (if any), leaving the rest for subsequent drains.
13
- *
14
- * Both queues accept `AgentMessage` (user messages to inject into the
15
- * conversation) and expose the standard queue operations: enqueue, drain,
16
- * peek, and clear.
17
- */
18
- /**
19
- * Base queue implementation with configurable drain behaviour.
20
- */
21
- class MessageQueue {
22
- messages = [];
23
- mode;
24
- constructor(mode) {
25
- this.mode = mode;
26
- }
27
- /**
28
- * Append a message to the end of the queue.
29
- */
30
- enqueue(msg) {
31
- this.messages.push(msg);
32
- }
33
- /**
34
- * Remove and return messages according to the drain mode.
35
- *
36
- * - 'all': returns all messages (or null if empty), clears the queue.
37
- * - 'one': returns the oldest message as a single-element array (or null
38
- * if empty), removes only that message.
39
- */
40
- drain() {
41
- if (this.messages.length === 0)
42
- return null;
43
- if (this.mode === 'all') {
44
- const drained = [...this.messages];
45
- this.messages.length = 0;
46
- return drained;
47
- }
48
- // mode === 'one'
49
- return [this.messages.shift()];
50
- }
51
- /**
52
- * Peek at queued messages without removing them.
53
- *
54
- * - 'all': returns all messages (or null if empty).
55
- * - 'one': returns the oldest message as a single-element array (or null
56
- * if empty).
57
- */
58
- peek() {
59
- if (this.messages.length === 0)
60
- return null;
61
- if (this.mode === 'all') {
62
- return [...this.messages];
63
- }
64
- // mode === 'one'
65
- return [this.messages[0]];
66
- }
67
- /**
68
- * Remove all messages from the queue.
69
- */
70
- clear() {
71
- this.messages.length = 0;
72
- }
73
- /**
74
- * Number of messages currently in the queue.
75
- */
76
- get length() {
77
- return this.messages.length;
78
- }
79
- }
80
- /**
81
- * SteeringQueue: drain mode 'all'.
82
- *
83
- * Used for mid-flight steering — "stop and do this instead". When drained,
84
- * all queued messages are returned and the queue is cleared. The agent loop
85
- * should push these messages into history and continue looping (i.e. not
86
- * break on end_turn).
87
- */
88
- export class SteeringQueue extends MessageQueue {
89
- constructor() {
90
- super('all');
91
- }
92
- }
93
- /**
94
- * FollowUpQueue: drain mode 'one-at-a-time'.
95
- *
96
- * Used for scheduling follow-up turns. Each queued message becomes the next
97
- * turn after the current one completes. When drained, only one message is
98
- * returned (if any), leaving the rest for subsequent drains.
99
- */
100
- export class FollowUpQueue extends MessageQueue {
101
- constructor() {
102
- super('one');
103
- }
104
- }
105
- //# sourceMappingURL=queues.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"queues.js","sourceRoot":"","sources":["../../src_v2/kernel/queues.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AAWH;;GAEG;AACH,MAAM,YAAY;IACG,QAAQ,GAAmB,EAAE,CAAC;IAC9B,IAAI,CAAY;IAEnC,YAAY,IAAe;QACzB,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;IACnB,CAAC;IAED;;OAEG;IACH,OAAO,CAAC,GAAiB;QACvB,IAAI,CAAC,QAAQ,CAAC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terministic, in-process Provider for testing the agent loop.
3
- *
4
- * Implements the same `Provider` contract as real providers (anthropic.ts,
5
- * openai.ts, etc.) but consumes a pre-baked script of step descriptors
6
- * instead of talking to a network. Each call to `stream()` consumes the
7
- * NEXT step from the script and emits the corresponding `AgentEvent`s.
8
- *
9
- * Use it to drive `runAgentLoop` end-to-end without any I/O.
10
- *
11
- * const provider = new FauxProvider([
12
- * { kind: 'tool-call', id: 'c1', name: 'shell', input: { cmd: 'ls' } },
13
- * { kind: 'text', chunks: ['done'] },
14
- * ]);
15
- *
16
- * The provider also records `callCount` and `lastMessages` so tests can
17
- * assert what the loop sent to the LLM (post-projection from AgentMessage[]).
18
- */
19
- import type { AgentEvent, Message } from '../kernel/types.js';
20
- import type { Provider, StreamRequest } from './iface.js';
21
- export type FauxScriptStep = {
22
- kind: 'text';
23
- chunks: string[];
24
- usage?: {
25
- inputTokens: number;
26
- outputTokens: number;
27
- cachedTokens?: number;
28
- };
29
- } | {
30
- kind: 'tool-call';
31
- id: string;
32
- name: string;
33
- input: unknown;
34
- usage?: {
35
- inputTokens: number;
36
- outputTokens: number;
37
- cachedTokens?: number;
38
- };
39
- } | {
40
- kind: 'mixed';
41
- text?: string;
42
- toolCalls: {
43
- id: string;
44
- name: string;
45
- input: unknown;
46
- }[];
47
- usage?: {
48
- inputTokens: number;
49
- outputTokens: number;
50
- cachedTokens?: number;
51
- };
52
- } | {
53
- kind: 'error';
54
- error: Error;
55
- } | {
56
- kind: 'abort';
57
- afterMs?: number;
58
- } | {
59
- kind: 'wait';
60
- ms: number;
61
- };
62
- export interface FauxProviderOptions {
63
- /** Provider id reported via `provider.id`. Defaults to `'faux'`. */
64
- id?: string;
65
- /** Whether `supportsTools` returns true (default: true). */
66
- supportsTools?: boolean;
67
- /** Whether `supportsThinking` returns true (default: false). */
68
- supportsThinking?: boolean;
69
- }
70
- /**
71
- * Synchronous-throwing AbortError. Mirrors the shape Node/undici fetch
72
- * rejects with when an AbortSignal fires mid-request — `.name === 'AbortError'`
73
- * is the discriminator real providers and the loop's error path see.
74
- */
75
- export declare class FauxAbortError extends Error {
76
- readonly name = "AbortError";
77
- constructor(message?: string);
78
- }
79
- export declare class FauxProvider implements Provider {
80
- readonly id: string;
81
- private readonly script;
82
- private cursor;
83
- private readonly _toolsSupported;
84
- private readonly _thinkingSupported;
85
- /** Total number of times `stream()` has been called. */
86
- callCount: number;
87
- /** The `messages` argument from the most recent `stream()` call. */
88
- lastMessages: Message[];
89
- /** All `messages` arguments captured across every `stream()` call, in order. */
90
- callHistory: Message[][];
91
- constructor(script: FauxScriptStep[], opts?: FauxProviderOptions);
92
- supportsTools(_modelId: string): boolean;
93
- supportsThinking(_modelId: string): boolean;
94
- /** Number of script steps not yet consumed. */
95
- get remaining(): number;
96
- /** Reset call counters and cursor. Useful between assertions in one test. */
97
- reset(): void;
98
- stream(req: StreamRequest): AsyncIterable<AgentEvent>;
99
- }