@0xmaxma/claude-gateway 2.1.15 → 2.1.16

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (41) hide show
  1. package/dist/agent/runner.js +1 -1
  2. package/dist/agent/runner.js.map +1 -1
  3. package/dist/build-provenance.json +4 -4
  4. package/dist/history/types.d.ts +1 -1
  5. package/dist/history/types.js +1 -1
  6. package/dist/orchestration/agent-cli-session.d.ts +58 -6
  7. package/dist/orchestration/agent-cli-session.d.ts.map +1 -1
  8. package/dist/orchestration/agent-cli-session.js +207 -27
  9. package/dist/orchestration/agent-cli-session.js.map +1 -1
  10. package/dist/orchestration/context-delivery.d.ts +2 -0
  11. package/dist/orchestration/context-delivery.d.ts.map +1 -1
  12. package/dist/orchestration/context-delivery.js +8 -0
  13. package/dist/orchestration/context-delivery.js.map +1 -1
  14. package/dist/orchestration/gateway-tasks/computer.d.ts +2 -0
  15. package/dist/orchestration/gateway-tasks/computer.d.ts.map +1 -1
  16. package/dist/orchestration/gateway-tasks/computer.js +4 -2
  17. package/dist/orchestration/gateway-tasks/computer.js.map +1 -1
  18. package/dist/orchestration/input-images.d.ts +4 -0
  19. package/dist/orchestration/input-images.d.ts.map +1 -1
  20. package/dist/orchestration/input-images.js +28 -0
  21. package/dist/orchestration/input-images.js.map +1 -1
  22. package/dist/orchestration/runtime.d.ts +3 -0
  23. package/dist/orchestration/runtime.d.ts.map +1 -1
  24. package/dist/orchestration/runtime.js +103 -44
  25. package/dist/orchestration/runtime.js.map +1 -1
  26. package/dist/orchestration/session-compaction.d.ts.map +1 -1
  27. package/dist/orchestration/session-compaction.js +16 -6
  28. package/dist/orchestration/session-compaction.js.map +1 -1
  29. package/dist/orchestration/tasks/driver.d.ts.map +1 -1
  30. package/dist/orchestration/tasks/driver.js +8 -1
  31. package/dist/orchestration/tasks/driver.js.map +1 -1
  32. package/dist/orchestration/tasks/pool.d.ts +3 -2
  33. package/dist/orchestration/tasks/pool.d.ts.map +1 -1
  34. package/dist/orchestration/tasks/pool.js +4 -3
  35. package/dist/orchestration/tasks/pool.js.map +1 -1
  36. package/dist/ui/memory-activity.js +1 -1
  37. package/package.json +1 -1
  38. package/dist/session/compactor.d.ts +0 -53
  39. package/dist/session/compactor.d.ts.map +0 -1
  40. package/dist/session/compactor.js +0 -274
  41. package/dist/session/compactor.js.map +0 -1
@@ -1,274 +0,0 @@
1
- "use strict";
2
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
- if (k2 === undefined) k2 = k;
4
- var desc = Object.getOwnPropertyDescriptor(m, k);
5
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
- desc = { enumerable: true, get: function() { return m[k]; } };
7
- }
8
- Object.defineProperty(o, k2, desc);
9
- }) : (function(o, m, k, k2) {
10
- if (k2 === undefined) k2 = k;
11
- o[k2] = m[k];
12
- }));
13
- var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
- Object.defineProperty(o, "default", { enumerable: true, value: v });
15
- }) : function(o, v) {
16
- o["default"] = v;
17
- });
18
- var __importStar = (this && this.__importStar) || (function () {
19
- var ownKeys = function(o) {
20
- ownKeys = Object.getOwnPropertyNames || function (o) {
21
- var ar = [];
22
- for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
23
- return ar;
24
- };
25
- return ownKeys(o);
26
- };
27
- return function (mod) {
28
- if (mod && mod.__esModule) return mod;
29
- var result = {};
30
- if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
31
- __setModuleDefault(result, mod);
32
- return result;
33
- };
34
- })();
35
- Object.defineProperty(exports, "__esModule", { value: true });
36
- exports.SessionCompactor = exports.NotEnoughMessagesError = void 0;
37
- exports.defaultSpawnClaude = defaultSpawnClaude;
38
- const fs = __importStar(require("fs"));
39
- const path = __importStar(require("path"));
40
- const child_process_1 = require("child_process");
41
- const claude_bin_1 = require("./claude-bin");
42
- const plugin_info_1 = require("../pstack/plugin-info");
43
- class NotEnoughMessagesError extends Error {
44
- constructor(count) {
45
- super(`Not enough messages to compact (${count} messages, minimum 5 required)`);
46
- this.name = 'NotEnoughMessagesError';
47
- }
48
- }
49
- exports.NotEnoughMessagesError = NotEnoughMessagesError;
50
- // Max characters per chunk sent to claude CLI (~100K chars ≈ ~25K tokens, well within 200K limit)
51
- const CHUNK_CHARS = 100000;
52
- // Number of recent messages to keep verbatim; older messages are summarized
53
- const KEEP_LAST_MESSAGES = 45;
54
- // Prompt used to merge multiple chunk summaries into one
55
- const MERGE_SUMMARIES_PROMPT = 'These are summaries of sequential parts of a conversation. Merge them into a single concise summary preserving key facts, decisions, context, and any open tasks.';
56
- // Default instruction for summarizing a single conversation or chunk
57
- const SINGLE_SUMMARY_INSTRUCTION = 'Summarize this conversation concisely, preserving key facts, decisions, context the assistant should remember, and any open questions or unfinished tasks.';
58
- // System prompt prepended to every claude CLI summarization call
59
- const COMPACTOR_SYSTEM_PROMPT = 'You are a conversation archiver. Your ONLY task is to produce a concise summary of the conversation transcript below. Do NOT respond to the conversation. Do NOT ask questions. Output ONLY the summary.';
60
- // Max concurrent `claude --print` chunk-summary calls in flight at once. Bounded
61
- // (not "all N chunks at once") to cap worst-case concurrent model calls/memory,
62
- // while still cutting sequential wall time roughly by this factor on large sessions.
63
- const CHUNK_CONCURRENCY = 4;
64
- // Attempts per chunk (1 initial + retries) before degrading to a truncated raw
65
- // excerpt instead of failing the whole compact job over one bad chunk.
66
- const CHUNK_MAX_ATTEMPTS = 2;
67
- // Raw-excerpt length used when a chunk exhausts its summarization attempts.
68
- const DEGRADED_EXCERPT_CHARS = 2000;
69
- // Hard ceiling on a single `claude --print` summarization spawn — mirrors the
70
- // prior spawnSync timeout, but non-blocking (see defaultSpawnClaude below).
71
- const SUMMARY_TIMEOUT_MS = 300000;
72
- // Rough token estimate: ~4 chars per token
73
- function estimateTokens(messages) {
74
- return Math.round(messages.reduce((acc, m) => acc + m.content.length, 0) / 4);
75
- }
76
- /**
77
- * Async `claude` CLI spawn. Replaces the prior `spawnSync` call: `spawnSync`
78
- * blocks the daemon's single event loop for the full duration of the call — and
79
- * every agent shares one process, so one compaction call froze ALL agents/
80
- * channels until it returned (up to SUMMARY_TIMEOUT_MS, x N chunks sequentially
81
- * on large sessions). `spawn` yields the event loop while the child runs.
82
- * Mirrors the sync `{status, stdout, stderr, error}` contract so callers'
83
- * existing error handling is unchanged.
84
- */
85
- function defaultSpawnClaude(bin, args, input) {
86
- return new Promise((resolve) => {
87
- let settled = false;
88
- let stdout = '';
89
- let stderr = '';
90
- const settle = (r) => {
91
- if (settled)
92
- return;
93
- settled = true;
94
- clearTimeout(timer);
95
- resolve(r);
96
- };
97
- const timer = setTimeout(() => {
98
- try {
99
- child.kill('SIGKILL');
100
- }
101
- catch {
102
- /* already gone */
103
- }
104
- settle({ status: null, stdout: '', stderr, error: new Error(`claude CLI timed out after ${SUMMARY_TIMEOUT_MS}ms`) });
105
- }, SUMMARY_TIMEOUT_MS);
106
- const child = (0, child_process_1.spawn)(bin, args, {
107
- stdio: ['pipe', 'pipe', 'pipe'],
108
- env: { ...process.env, PATH: (0, claude_bin_1.pathWithNativeBin)() },
109
- });
110
- child.stdout?.on('data', (d) => {
111
- stdout += String(d);
112
- });
113
- child.stderr?.on('data', (d) => {
114
- stderr += String(d);
115
- });
116
- child.on('error', (err) => settle({ status: null, stdout: '', stderr, error: err }));
117
- child.on('close', (code) => settle({ status: code, stdout, stderr }));
118
- // stdin emits its own async 'error' (e.g. EPIPE if the child exits before we
119
- // finish writing) separate from the child's 'error' event — must be handled
120
- // or an unhandled stream error crashes the daemon.
121
- child.stdin?.on('error', () => { });
122
- try {
123
- child.stdin?.write(input);
124
- child.stdin?.end();
125
- }
126
- catch (err) {
127
- settle({ status: null, stdout: '', stderr, error: err });
128
- }
129
- });
130
- }
131
- class SessionCompactor {
132
- constructor(sessionStore, spawnClaude = defaultSpawnClaude) {
133
- this.sessionStore = sessionStore;
134
- this.spawnClaude = spawnClaude;
135
- }
136
- async compact(agentId, chatId, sessionId, model, contextWindow, channel = 'telegram', onProgress) {
137
- // Load current history
138
- const messages = await this.sessionStore.loadTelegramSession(agentId, chatId, sessionId, channel);
139
- if (messages.length < 5) {
140
- throw new NotEnoughMessagesError(messages.length);
141
- }
142
- const beforeMessages = messages.length;
143
- const beforeTokens = estimateTokens(messages);
144
- // Archive original before compaction
145
- const agentsBaseDir = this.sessionStore.getAgentsBaseDir();
146
- const sessionDir = path.join(agentsBaseDir, agentId, 'sessions', `${channel}-${chatId}`);
147
- fs.mkdirSync(sessionDir, { recursive: true });
148
- const archivePath = path.join(sessionDir, `${sessionId}.pre-compact-${Date.now()}.json`);
149
- fs.writeFileSync(archivePath, JSON.stringify(messages, null, 2), 'utf-8');
150
- // Keep last N messages verbatim; summarize only the older portion (or all if < N)
151
- const tail = messages.slice(-KEEP_LAST_MESSAGES);
152
- const toSummarize = messages.length > KEEP_LAST_MESSAGES ? messages.slice(0, -KEEP_LAST_MESSAGES) : messages;
153
- const historyText = toSummarize
154
- .map(m => `${m.role === 'user' ? 'User' : 'Assistant'}: ${m.content}`)
155
- .join('\n\n');
156
- const summaryText = await this.summarizeWithChunking(historyText, model, onProgress);
157
- const compacted = [
158
- { role: 'system', content: `[Conversation Summary]\n${summaryText}`, ts: Date.now() },
159
- ...tail,
160
- ];
161
- // Save compacted history (original already archived above)
162
- await this.sessionStore.saveTelegramSession(agentId, chatId, sessionId, compacted, channel);
163
- const afterMessages = compacted.length;
164
- const afterTokens = estimateTokens(compacted);
165
- const reductionPct = beforeTokens > 0 ? Math.max(0, Math.round((1 - afterTokens / beforeTokens) * 100)) : 0;
166
- const contextPctBefore = Math.round((beforeTokens / contextWindow) * 100);
167
- const contextPctAfter = Math.round((afterTokens / contextWindow) * 100);
168
- return { beforeMessages, afterMessages, beforeTokens, afterTokens, reductionPct, contextPctBefore, contextPctAfter };
169
- }
170
- async summarizeWithChunking(historyText, model, onProgress) {
171
- // If small enough, summarize directly. No chunking → no chunk to retry/degrade
172
- // against, so a failure here still fails the compact job (original behavior).
173
- if (historyText.length <= CHUNK_CHARS) {
174
- return this.callClaudeForSummary(historyText, model);
175
- }
176
- // Split into chunks and summarize with bounded concurrency; a single bad
177
- // chunk degrades to a raw excerpt instead of failing the whole job.
178
- const chunks = this.splitIntoChunks(historyText, CHUNK_CHARS);
179
- const chunkSummaries = await this.summarizeChunksConcurrently(chunks, model, onProgress);
180
- // Merge chunk summaries into final summary. If the merge call itself can't
181
- // be completed, fall back to the concatenated per-part summaries rather than
182
- // losing the whole compaction — still far smaller than the raw history.
183
- const mergedText = chunkSummaries.join('\n\n');
184
- return this.mergeChunkSummaries(mergedText, model);
185
- }
186
- /** Bounded worker pool (mirrors the pattern in apps/installer.ts restoreRunningApps): at
187
- * most CHUNK_CONCURRENCY `claude --print` calls in flight; results land by index so
188
- * output order matches chunk order regardless of completion order. */
189
- async summarizeChunksConcurrently(chunks, model, onProgress) {
190
- const results = new Array(chunks.length);
191
- let completed = 0;
192
- let cursor = 0;
193
- const worker = async () => {
194
- while (cursor < chunks.length) {
195
- const i = cursor++;
196
- results[i] = await this.summarizeChunkWithFallback(chunks[i], model, i, chunks.length);
197
- completed++;
198
- onProgress?.(completed, chunks.length);
199
- }
200
- };
201
- const poolSize = Math.min(CHUNK_CONCURRENCY, chunks.length);
202
- await Promise.all(Array.from({ length: poolSize }, () => worker()));
203
- return results;
204
- }
205
- /** Summarize one chunk; after CHUNK_MAX_ATTEMPTS failures, degrade to a truncated raw
206
- * excerpt instead of throwing, so one bad chunk can't fail the whole compact job. */
207
- async summarizeChunkWithFallback(chunk, model, index, total) {
208
- const instruction = `This is part ${index + 1} of ${total} of a longer conversation. Summarize this segment concisely.`;
209
- let lastErr;
210
- for (let attempt = 1; attempt <= CHUNK_MAX_ATTEMPTS; attempt++) {
211
- try {
212
- const summary = await this.callClaudeForSummary(chunk, model, instruction);
213
- return `[Part ${index + 1}/${total}]\n${summary}`;
214
- }
215
- catch (err) {
216
- lastErr = err;
217
- }
218
- }
219
- const excerpt = chunk.length > DEGRADED_EXCERPT_CHARS ? `${chunk.slice(0, DEGRADED_EXCERPT_CHARS)}…(truncated)` : chunk;
220
- console.error(`[SessionCompactor] Chunk ${index + 1}/${total} summarization failed after ${CHUNK_MAX_ATTEMPTS} attempts (${lastErr?.message ?? 'unknown error'}); using truncated raw excerpt.`);
221
- return `[Part ${index + 1}/${total} — summarization failed after ${CHUNK_MAX_ATTEMPTS} attempts (${lastErr?.message ?? 'unknown error'}); showing truncated raw excerpt]\n${excerpt}`;
222
- }
223
- /** Merge per-chunk summaries into one; degrade to the unmerged concatenation on repeated failure. */
224
- async mergeChunkSummaries(mergedText, model) {
225
- let lastErr;
226
- for (let attempt = 1; attempt <= CHUNK_MAX_ATTEMPTS; attempt++) {
227
- try {
228
- return await this.callClaudeForSummary(mergedText, model, MERGE_SUMMARIES_PROMPT);
229
- }
230
- catch (err) {
231
- lastErr = err;
232
- }
233
- }
234
- console.error(`[SessionCompactor] Merge-summaries call failed after ${CHUNK_MAX_ATTEMPTS} attempts (${lastErr?.message ?? 'unknown error'}); using unmerged per-chunk summaries.`);
235
- return mergedText;
236
- }
237
- splitIntoChunks(text, maxChars) {
238
- const chunks = [];
239
- let start = 0;
240
- while (start < text.length) {
241
- let end = start + maxChars;
242
- if (end < text.length) {
243
- // Break at a newline boundary to avoid splitting mid-message
244
- const boundary = text.lastIndexOf('\n\n', end);
245
- if (boundary > start)
246
- end = boundary;
247
- }
248
- chunks.push(text.slice(start, end));
249
- start = end;
250
- }
251
- return chunks;
252
- }
253
- async callClaudeForSummary(text, model, instruction = SINGLE_SUMMARY_INSTRUCTION) {
254
- // Wrap content in XML tags so claude treats it as data to analyze, not an active conversation
255
- const prompt = `${COMPACTOR_SYSTEM_PROMPT}\n\n${instruction}\n\n<transcript>\n${text}\n</transcript>\n\nWrite a concise summary of the above transcript now:`;
256
- // Resolve claude the same way the session subprocess does: honor CLAUDE_BIN
257
- // (which may carry args), else probe PATH and the native/legacy install
258
- // locations. This runs in the gateway's own (possibly minimal) PATH, so
259
- // without resolution `claude --print` would fail identically to a session
260
- // spawn after the native-installer migration.
261
- const { command: claudeBin, args: claudeBinArgs } = (0, claude_bin_1.claudeCommand)();
262
- const result = await this.spawnClaude(claudeBin, [...claudeBinArgs, '--print', '--model', model, '--settings', JSON.stringify(plugin_info_1.PSTACK_OFF_SETTINGS)], prompt);
263
- if (result.error) {
264
- throw new Error(`claude CLI error: ${result.error.message}`);
265
- }
266
- if (result.status !== 0) {
267
- const stderr = result.stderr?.trim() ?? '';
268
- throw new Error(`claude CLI exited with status ${result.status}: ${stderr}`);
269
- }
270
- return result.stdout?.trim() ?? '';
271
- }
272
- }
273
- exports.SessionCompactor = SessionCompactor;
274
- //# sourceMappingURL=compactor.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"compactor.js","sourceRoot":"","sources":["../../src/session/compactor.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAgFA,gDA2CC;AA3HD,uCAAyB;AACzB,2CAA6B;AAC7B,iDAAsC;AAItC,6CAAgE;AAChE,uDAA4D;AAY5D,MAAa,sBAAuB,SAAQ,KAAK;IAC/C,YAAY,KAAa;QACvB,KAAK,CAAC,mCAAmC,KAAK,gCAAgC,CAAC,CAAC;QAChF,IAAI,CAAC,IAAI,GAAG,wBAAwB,CAAC;IACvC,CAAC;CACF;AALD,wDAKC;AAED,kGAAkG;AAClG,MAAM,WAAW,GAAG,MAAO,CAAC;AAC5B,4EAA4E;AAC5E,MAAM,kBAAkB,GAAG,EAAE,CAAC;AAC9B,yDAAyD;AACzD,MAAM,sBAAsB,GAC1B,mKAAmK,CAAC;AACtK,qEAAqE;AACrE,MAAM,0BAA0B,GAC9B,4JAA4J,CAAC;AAC/J,iEAAiE;AACjE,MAAM,uBAAuB,GAC3B,0MAA0M,CAAC;AAE7M,iFAAiF;AACjF,g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