chompyy 0.4.7 → 0.6.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 (161) hide show
  1. package/README.md +40 -6
  2. package/dist/advice.js +2 -1
  3. package/dist/agentlimits.js +77 -0
  4. package/dist/agentusage.js +96 -0
  5. package/dist/appstate.js +72 -5
  6. package/dist/away.js +44 -5
  7. package/dist/blueprint.js +3 -7
  8. package/dist/board.js +4 -0
  9. package/dist/cli.js +328 -15
  10. package/dist/codexquota.js +106 -0
  11. package/dist/codexusage.js +10 -0
  12. package/dist/config.js +2 -0
  13. package/dist/context.js +30 -0
  14. package/dist/costs.js +1 -0
  15. package/dist/daytime.js +68 -0
  16. package/dist/demon.js +20 -0
  17. package/dist/didwork.js +46 -0
  18. package/dist/label.js +33 -0
  19. package/dist/learning.js +35 -0
  20. package/dist/menu.js +17 -0
  21. package/dist/nightcap.js +60 -0
  22. package/dist/nudge.js +47 -18
  23. package/dist/pacing.js +16 -1
  24. package/dist/questions.js +71 -0
  25. package/dist/recap.js +74 -0
  26. package/dist/receipt.js +48 -0
  27. package/dist/recipe.js +79 -0
  28. package/dist/send.js +46 -20
  29. package/dist/stamps.js +14 -0
  30. package/dist/taste.js +67 -7
  31. package/dist/triggers.js +5 -0
  32. package/dist/unkeep.js +220 -0
  33. package/dist/usage.js +21 -1
  34. package/dist/vendor/codeburn/antigravity.js +309 -0
  35. package/dist/vendor/codeburn/codex.js +429 -0
  36. package/dist/vendor/codeburn/copilot.js +292 -0
  37. package/dist/vendor/codeburn/gemini.js +195 -0
  38. package/dist/vendor/codeburn/grokbot.js +182 -0
  39. package/dist/vendor/codeburn/kimi.js +178 -0
  40. package/dist/vendor/codeburn/shims/chalk.js +14 -0
  41. package/dist/vendor/codeburn/shims/strip-ansi.js +6 -0
  42. package/dist/vendor/codeburn/src/act/backup.js +83 -0
  43. package/dist/vendor/codeburn/src/act/model-defaults.js +151 -0
  44. package/dist/vendor/codeburn/src/act/types.js +37 -0
  45. package/dist/vendor/codeburn/src/bash-utils.js +204 -0
  46. package/dist/vendor/codeburn/src/behavioral-weight.js +47 -0
  47. package/dist/vendor/codeburn/src/cache-dir.js +26 -0
  48. package/dist/vendor/codeburn/src/cache-refresh-lock.js +543 -0
  49. package/dist/vendor/codeburn/src/cache-sweep.js +67 -0
  50. package/dist/vendor/codeburn/src/classifier.js +209 -0
  51. package/dist/vendor/codeburn/src/claude-identity.js +223 -0
  52. package/dist/vendor/codeburn/src/codex-cache.js +377 -0
  53. package/dist/vendor/codeburn/src/codex-fork-replay.js +232 -0
  54. package/dist/vendor/codeburn/src/codex-jsonl-fields.js +99 -0
  55. package/dist/vendor/codeburn/src/codex-session-index.js +113 -0
  56. package/dist/vendor/codeburn/src/codex-throughput.js +544 -0
  57. package/dist/vendor/codeburn/src/compare-stats.js +405 -0
  58. package/dist/vendor/codeburn/src/config.js +145 -0
  59. package/dist/vendor/codeburn/src/content-utils.js +56 -0
  60. package/dist/vendor/codeburn/src/context-tree-codex.js +329 -0
  61. package/dist/vendor/codeburn/src/context-tree.js +664 -0
  62. package/dist/vendor/codeburn/src/copilot-aiu.js +16 -0
  63. package/dist/vendor/codeburn/src/currency.js +189 -0
  64. package/dist/vendor/codeburn/src/cursor-cache.js +238 -0
  65. package/dist/vendor/codeburn/src/cursor-import.js +402 -0
  66. package/dist/vendor/codeburn/src/cursor-sync.js +256 -0
  67. package/dist/vendor/codeburn/src/daily-cache.js +2036 -0
  68. package/dist/vendor/codeburn/src/data/litellm-snapshot.json +1 -0
  69. package/dist/vendor/codeburn/src/data/pricing-fallback.json +1 -0
  70. package/dist/vendor/codeburn/src/day-aggregator.js +327 -0
  71. package/dist/vendor/codeburn/src/editor-data-dir.js +11 -0
  72. package/dist/vendor/codeburn/src/fetch-utils.js +18 -0
  73. package/dist/vendor/codeburn/src/format.js +118 -0
  74. package/dist/vendor/codeburn/src/fs-utils.js +270 -0
  75. package/dist/vendor/codeburn/src/git-origin.js +334 -0
  76. package/dist/vendor/codeburn/src/granular-history.js +328 -0
  77. package/dist/vendor/codeburn/src/hermes-session-ledger.js +512 -0
  78. package/dist/vendor/codeburn/src/launcher-homes.js +142 -0
  79. package/dist/vendor/codeburn/src/live-sessions.js +358 -0
  80. package/dist/vendor/codeburn/src/math-utils.js +8 -0
  81. package/dist/vendor/codeburn/src/menubar-json.js +294 -0
  82. package/dist/vendor/codeburn/src/models.js +1879 -0
  83. package/dist/vendor/codeburn/src/optimize-one-hour-cache.js +92 -0
  84. package/dist/vendor/codeburn/src/optimize.js +4110 -0
  85. package/dist/vendor/codeburn/src/parse-workers.js +219 -0
  86. package/dist/vendor/codeburn/src/parser.js +6953 -0
  87. package/dist/vendor/codeburn/src/path-privacy.js +26 -0
  88. package/dist/vendor/codeburn/src/plans.js +135 -0
  89. package/dist/vendor/codeburn/src/pr-signals.js +132 -0
  90. package/dist/vendor/codeburn/src/project-filter-warnings.js +33 -0
  91. package/dist/vendor/codeburn/src/provider-issues.js +30 -0
  92. package/dist/vendor/codeburn/src/providers/amp.js +286 -0
  93. package/dist/vendor/codeburn/src/providers/antigravity.js +1731 -0
  94. package/dist/vendor/codeburn/src/providers/claude.js +551 -0
  95. package/dist/vendor/codeburn/src/providers/cline-cli.js +401 -0
  96. package/dist/vendor/codeburn/src/providers/cline.js +63 -0
  97. package/dist/vendor/codeburn/src/providers/codebuff.js +336 -0
  98. package/dist/vendor/codeburn/src/providers/codewhale.js +442 -0
  99. package/dist/vendor/codeburn/src/providers/codex.js +1720 -0
  100. package/dist/vendor/codeburn/src/providers/command-code.js +196 -0
  101. package/dist/vendor/codeburn/src/providers/copilot.js +3278 -0
  102. package/dist/vendor/codeburn/src/providers/crush.js +226 -0
  103. package/dist/vendor/codeburn/src/providers/cursor-agent.js +837 -0
  104. package/dist/vendor/codeburn/src/providers/cursor.js +1163 -0
  105. package/dist/vendor/codeburn/src/providers/devin.js +569 -0
  106. package/dist/vendor/codeburn/src/providers/droid.js +324 -0
  107. package/dist/vendor/codeburn/src/providers/dsh.js +690 -0
  108. package/dist/vendor/codeburn/src/providers/forge.js +245 -0
  109. package/dist/vendor/codeburn/src/providers/gemini.js +230 -0
  110. package/dist/vendor/codeburn/src/providers/goose.js +252 -0
  111. package/dist/vendor/codeburn/src/providers/grok.js +581 -0
  112. package/dist/vendor/codeburn/src/providers/grokbot.js +290 -0
  113. package/dist/vendor/codeburn/src/providers/hermes.js +771 -0
  114. package/dist/vendor/codeburn/src/providers/ibm-bob.js +53 -0
  115. package/dist/vendor/codeburn/src/providers/index.js +360 -0
  116. package/dist/vendor/codeburn/src/providers/kilo-code.js +50 -0
  117. package/dist/vendor/codeburn/src/providers/kimi.js +363 -0
  118. package/dist/vendor/codeburn/src/providers/kimicode.js +402 -0
  119. package/dist/vendor/codeburn/src/providers/kiro.js +1174 -0
  120. package/dist/vendor/codeburn/src/providers/lingtai-tui.js +372 -0
  121. package/dist/vendor/codeburn/src/providers/mistral-vibe-unified.js +236 -0
  122. package/dist/vendor/codeburn/src/providers/mistral-vibe.js +405 -0
  123. package/dist/vendor/codeburn/src/providers/mux.js +242 -0
  124. package/dist/vendor/codeburn/src/providers/open-design.js +217 -0
  125. package/dist/vendor/codeburn/src/providers/openclaude.js +309 -0
  126. package/dist/vendor/codeburn/src/providers/openclaw.js +442 -0
  127. package/dist/vendor/codeburn/src/providers/opencode-file-parser.js +131 -0
  128. package/dist/vendor/codeburn/src/providers/opencode.js +91 -0
  129. package/dist/vendor/codeburn/src/providers/pi.js +429 -0
  130. package/dist/vendor/codeburn/src/providers/quickdesk.js +491 -0
  131. package/dist/vendor/codeburn/src/providers/qwen.js +193 -0
  132. package/dist/vendor/codeburn/src/providers/session-message.js +118 -0
  133. package/dist/vendor/codeburn/src/providers/sqlite-session-parser.js +457 -0
  134. package/dist/vendor/codeburn/src/providers/types.js +5 -0
  135. package/dist/vendor/codeburn/src/providers/vercel-gateway.js +135 -0
  136. package/dist/vendor/codeburn/src/providers/vscode-cline-parser.js +212 -0
  137. package/dist/vendor/codeburn/src/providers/warp.js +575 -0
  138. package/dist/vendor/codeburn/src/providers/zcode.js +249 -0
  139. package/dist/vendor/codeburn/src/providers/zed.js +187 -0
  140. package/dist/vendor/codeburn/src/providers/zerostack.js +139 -0
  141. package/dist/vendor/codeburn/src/quota/antigravity.js +310 -0
  142. package/dist/vendor/codeburn/src/quota/claude.js +244 -0
  143. package/dist/vendor/codeburn/src/quota/cursor.js +301 -0
  144. package/dist/vendor/codeburn/src/quota/security.js +299 -0
  145. package/dist/vendor/codeburn/src/quota/types.js +1 -0
  146. package/dist/vendor/codeburn/src/scan-facts.js +99 -0
  147. package/dist/vendor/codeburn/src/session-cache.js +3040 -0
  148. package/dist/vendor/codeburn/src/session-count-label.js +14 -0
  149. package/dist/vendor/codeburn/src/session-output.js +139 -0
  150. package/dist/vendor/codeburn/src/session-population.js +30 -0
  151. package/dist/vendor/codeburn/src/sessions-report.js +1342 -0
  152. package/dist/vendor/codeburn/src/sqlite.js +528 -0
  153. package/dist/vendor/codeburn/src/sync/otlp.js +420 -0
  154. package/dist/vendor/codeburn/src/telemetry-snapshot.js +244 -0
  155. package/dist/vendor/codeburn/src/token-estimate.js +5 -0
  156. package/dist/vendor/codeburn/src/types.js +16 -0
  157. package/dist/vendor/codeburn/src/work-units.js +126 -0
  158. package/dist/vendor/codeburn/src/workflow-insights.js +228 -0
  159. package/dist/vendor/codeburn/src/wsl.js +198 -0
  160. package/dist/vendor/codeburn/src/yield.js +666 -0
  161. package/package.json +11 -3
@@ -0,0 +1,363 @@
1
+ // @ts-nocheck: codeburn type-checks this under its own tsconfig; Chompyy adds noUncheckedIndexedAccess (see UPSTREAM.md)
2
+ import { createHash } from 'crypto';
3
+ import { readdir, readFile, stat } from 'fs/promises';
4
+ import { basename, dirname, join } from 'path';
5
+ import { homedir } from 'os';
6
+ import { extractBashCommands } from '../bash-utils.js';
7
+ import { readSessionLines } from '../fs-utils.js';
8
+ import { calculateCost, getShortModelName, ownValue, pricingModelAt } from '../models.js';
9
+ const toolNameMap = {
10
+ Shell: 'Bash',
11
+ Bash: 'Bash',
12
+ bash: 'Bash',
13
+ ReadFile: 'Read',
14
+ ReadMediaFile: 'Read',
15
+ WriteFile: 'Write',
16
+ StrReplaceFile: 'Edit',
17
+ Grep: 'Grep',
18
+ Glob: 'Glob',
19
+ SearchWeb: 'WebSearch',
20
+ FetchURL: 'WebFetch',
21
+ Agent: 'Agent',
22
+ AgentTool: 'Agent',
23
+ TaskList: 'Agent',
24
+ TaskOutput: 'Agent',
25
+ TaskStop: 'Agent',
26
+ AskUserQuestion: 'AskUser',
27
+ SetTodoList: 'TodoWrite',
28
+ Think: 'Think',
29
+ EnterPlanMode: 'EnterPlanMode',
30
+ ExitPlanMode: 'ExitPlanMode',
31
+ SendDMail: 'DMail',
32
+ };
33
+ function asObject(value) {
34
+ return value && typeof value === 'object' && !Array.isArray(value) ? value : null;
35
+ }
36
+ function stringField(obj, key) {
37
+ const value = obj?.[key];
38
+ return typeof value === 'string' ? value : undefined;
39
+ }
40
+ function numericField(obj, ...keys) {
41
+ for (const key of keys) {
42
+ const raw = obj[key];
43
+ const n = typeof raw === 'number' ? raw : typeof raw === 'string' ? Number(raw) : NaN;
44
+ if (Number.isFinite(n) && n > 0)
45
+ return Math.trunc(n);
46
+ }
47
+ return 0;
48
+ }
49
+ function getShareDir(overrideDir) {
50
+ return overrideDir ?? process.env['KIMI_SHARE_DIR'] ?? join(homedir(), '.kimi');
51
+ }
52
+ function md5(text) {
53
+ return createHash('md5').update(text, 'utf-8').digest('hex');
54
+ }
55
+ function projectNameFromPath(pathValue) {
56
+ const cleaned = pathValue.replace(/\/+$/, '');
57
+ return basename(cleaned) || cleaned || 'kimi';
58
+ }
59
+ async function loadProjectNames(shareDir) {
60
+ const projects = new Map();
61
+ const raw = await readFile(join(shareDir, 'kimi.json'), 'utf-8').catch(() => null);
62
+ if (!raw)
63
+ return projects;
64
+ let data;
65
+ try {
66
+ data = JSON.parse(raw);
67
+ }
68
+ catch {
69
+ return projects;
70
+ }
71
+ const workDirs = asObject(data)?.['work_dirs'];
72
+ if (!Array.isArray(workDirs))
73
+ return projects;
74
+ for (const entry of workDirs) {
75
+ const obj = asObject(entry);
76
+ const pathValue = stringField(obj, 'path');
77
+ if (!pathValue)
78
+ continue;
79
+ const hash = md5(pathValue);
80
+ const project = projectNameFromPath(pathValue);
81
+ projects.set(hash, project);
82
+ const kaos = stringField(obj, 'kaos');
83
+ if (kaos && kaos !== 'local')
84
+ projects.set(`${kaos}_${hash}`, project);
85
+ }
86
+ return projects;
87
+ }
88
+ function parseTomlString(raw) {
89
+ const value = raw.trim();
90
+ if (!value)
91
+ return null;
92
+ if (value.startsWith('"')) {
93
+ const match = value.match(/^"((?:[^"\\]|\\.)*)"/);
94
+ if (!match)
95
+ return null;
96
+ try {
97
+ return JSON.parse(`"${match[1]}"`);
98
+ }
99
+ catch {
100
+ return match[1] ?? null;
101
+ }
102
+ }
103
+ if (value.startsWith("'")) {
104
+ const match = value.match(/^'([^']*)'/);
105
+ return match?.[1] ?? null;
106
+ }
107
+ const match = value.match(/^([^#\s]+)/);
108
+ return match?.[1] ?? null;
109
+ }
110
+ function parseDefaultModelKey(configToml) {
111
+ for (const line of configToml.split('\n')) {
112
+ const match = line.match(/^\s*default_model\s*=\s*(.+)$/);
113
+ if (!match)
114
+ continue;
115
+ return parseTomlString(match[1]);
116
+ }
117
+ return null;
118
+ }
119
+ function parseModelSectionName(line) {
120
+ const match = line.trim().match(/^\[models\.(?:"([^"]+)"|'([^']+)'|([^\]]+))\]$/);
121
+ if (!match)
122
+ return null;
123
+ return (match[1] ?? match[2] ?? match[3] ?? '').trim() || null;
124
+ }
125
+ function parseModelIdForKey(configToml, modelKey) {
126
+ let inSection = false;
127
+ for (const line of configToml.split('\n')) {
128
+ const section = parseModelSectionName(line);
129
+ if (section !== null) {
130
+ inSection = section === modelKey;
131
+ continue;
132
+ }
133
+ if (!inSection)
134
+ continue;
135
+ if (/^\s*\[/.test(line)) {
136
+ inSection = false;
137
+ continue;
138
+ }
139
+ const match = line.match(/^\s*model\s*=\s*(.+)$/);
140
+ if (!match)
141
+ continue;
142
+ return parseTomlString(match[1]);
143
+ }
144
+ return null;
145
+ }
146
+ async function getConfiguredModel(shareDir) {
147
+ const envModel = process.env['KIMI_MODEL_NAME']?.trim();
148
+ if (envModel)
149
+ return envModel;
150
+ const raw = await readFile(join(shareDir, 'config.toml'), 'utf-8').catch(() => null);
151
+ if (!raw)
152
+ return 'kimi-auto';
153
+ const defaultModel = parseDefaultModelKey(raw);
154
+ if (!defaultModel)
155
+ return 'kimi-auto';
156
+ return parseModelIdForKey(raw, defaultModel) ?? defaultModel;
157
+ }
158
+ function parseJsonObject(text) {
159
+ if (!text)
160
+ return null;
161
+ try {
162
+ return asObject(JSON.parse(text));
163
+ }
164
+ catch {
165
+ return null;
166
+ }
167
+ }
168
+ function extractUserText(value) {
169
+ if (typeof value === 'string')
170
+ return value.slice(0, 500);
171
+ if (!Array.isArray(value))
172
+ return '';
173
+ return value
174
+ .map(part => stringField(asObject(part), 'text') ?? '')
175
+ .filter(Boolean)
176
+ .join(' ')
177
+ .slice(0, 500);
178
+ }
179
+ function timestampToIso(value) {
180
+ if (typeof value === 'string')
181
+ return value;
182
+ if (typeof value !== 'number' || !Number.isFinite(value))
183
+ return '';
184
+ const millis = value > 1_000_000_000_000 ? value : value * 1000;
185
+ const date = new Date(millis);
186
+ return Number.isFinite(date.getTime()) ? date.toISOString() : '';
187
+ }
188
+ function extractEnvelope(record) {
189
+ const message = asObject(record['message']);
190
+ const envelope = message ?? record;
191
+ const type = stringField(envelope, 'type');
192
+ const payload = asObject(envelope['payload']);
193
+ if (!type || !payload)
194
+ return null;
195
+ return { type, payload, timestamp: timestampToIso(record['timestamp']) };
196
+ }
197
+ function extractUsage(payload) {
198
+ const usage = asObject(payload['token_usage']) ?? asObject(payload['usage']);
199
+ if (!usage)
200
+ return null;
201
+ const cacheReadInputTokens = numericField(usage, 'input_cache_read', 'cache_read_input_tokens', 'cached_input_tokens');
202
+ const cacheCreationInputTokens = numericField(usage, 'input_cache_creation', 'cache_creation_input_tokens');
203
+ let inputTokens = numericField(usage, 'input_other', 'input_tokens');
204
+ if (inputTokens === 0) {
205
+ const totalInput = numericField(usage, 'input');
206
+ inputTokens = Math.max(0, totalInput - cacheReadInputTokens - cacheCreationInputTokens);
207
+ }
208
+ const outputTokens = numericField(usage, 'output', 'output_tokens');
209
+ if (inputTokens === 0 && outputTokens === 0 && cacheReadInputTokens === 0 && cacheCreationInputTokens === 0) {
210
+ return null;
211
+ }
212
+ return { inputTokens, outputTokens, cacheReadInputTokens, cacheCreationInputTokens };
213
+ }
214
+ function extractTool(payload) {
215
+ const fn = asObject(payload['function']);
216
+ const rawName = stringField(fn, 'name') ?? stringField(payload, 'name');
217
+ if (!rawName)
218
+ return null;
219
+ const tool = ownValue(toolNameMap, rawName) ?? rawName;
220
+ const argsText = stringField(fn, 'arguments') ?? stringField(payload, 'arguments');
221
+ const args = parseJsonObject(argsText);
222
+ const command = stringField(args, 'command');
223
+ const bashCommands = tool === 'Bash' && command ? extractBashCommands(command) : [];
224
+ return { tool, bashCommands };
225
+ }
226
+ function createParser(source, shareDir, seenKeys) {
227
+ return {
228
+ async *parse() {
229
+ const configuredModel = await getConfiguredModel(shareDir);
230
+ const tools = new Set();
231
+ const bashCommands = new Set();
232
+ let currentUserMessage = '';
233
+ // Subagent dirs (agent-1, ...) repeat across sessions; prefix the parent session.
234
+ const dir = dirname(source.path);
235
+ const sessionId = basename(dirname(dir)) === 'subagents'
236
+ ? `${basename(dirname(dirname(dir)))}/${basename(dir)}`
237
+ : basename(dir);
238
+ let index = 0;
239
+ for await (const line of readSessionLines(source.path)) {
240
+ if (!line.trim())
241
+ continue;
242
+ let record = null;
243
+ try {
244
+ record = asObject(JSON.parse(line));
245
+ }
246
+ catch {
247
+ continue;
248
+ }
249
+ if (!record)
250
+ continue;
251
+ const envelope = extractEnvelope(record);
252
+ if (!envelope || envelope.type === 'metadata')
253
+ continue;
254
+ if (envelope.type === 'TurnBegin' || envelope.type === 'SteerInput') {
255
+ currentUserMessage = extractUserText(envelope.payload['user_input']);
256
+ continue;
257
+ }
258
+ if (envelope.type === 'TurnEnd') {
259
+ currentUserMessage = '';
260
+ tools.clear();
261
+ bashCommands.clear();
262
+ continue;
263
+ }
264
+ if (envelope.type === 'ToolCall' || envelope.type === 'ToolCallRequest') {
265
+ const extracted = extractTool(envelope.payload);
266
+ if (!extracted)
267
+ continue;
268
+ tools.add(extracted.tool);
269
+ for (const command of extracted.bashCommands)
270
+ bashCommands.add(command);
271
+ continue;
272
+ }
273
+ if (envelope.type !== 'StatusUpdate')
274
+ continue;
275
+ const usage = extractUsage(envelope.payload);
276
+ if (!usage)
277
+ continue;
278
+ const rawMessageId = stringField(envelope.payload, 'message_id');
279
+ const dedupKey = `kimi:${sessionId}:${rawMessageId ?? index}`;
280
+ index++;
281
+ if (seenKeys.has(dedupKey))
282
+ continue;
283
+ seenKeys.add(dedupKey);
284
+ const model = stringField(envelope.payload, 'model') ?? stringField(envelope.payload, 'model_name') ?? configuredModel;
285
+ const costUSD = calculateCost(pricingModelAt(model, envelope.timestamp), usage.inputTokens, usage.outputTokens, usage.cacheCreationInputTokens, usage.cacheReadInputTokens, 0);
286
+ yield {
287
+ provider: 'kimi',
288
+ model,
289
+ inputTokens: usage.inputTokens,
290
+ outputTokens: usage.outputTokens,
291
+ cacheCreationInputTokens: usage.cacheCreationInputTokens,
292
+ cacheReadInputTokens: usage.cacheReadInputTokens,
293
+ cachedInputTokens: usage.cacheReadInputTokens,
294
+ reasoningTokens: 0,
295
+ webSearchRequests: 0,
296
+ costUSD,
297
+ tools: [...tools],
298
+ bashCommands: [...bashCommands],
299
+ timestamp: envelope.timestamp,
300
+ speed: 'standard',
301
+ deduplicationKey: dedupKey,
302
+ userMessage: currentUserMessage,
303
+ sessionId,
304
+ };
305
+ tools.clear();
306
+ bashCommands.clear();
307
+ }
308
+ },
309
+ };
310
+ }
311
+ async function addWireSource(sources, filePath, project) {
312
+ const s = await stat(filePath).catch(() => null);
313
+ if (!s?.isFile())
314
+ return;
315
+ sources.push({ path: filePath, project, provider: 'kimi' });
316
+ }
317
+ export function createKimiProvider(overrideDir) {
318
+ const shareDir = getShareDir(overrideDir);
319
+ return {
320
+ name: 'kimi',
321
+ displayName: 'Kimi',
322
+ async probeRoots() {
323
+ return [{ path: join(shareDir, 'sessions'), label: 'sessions' }];
324
+ },
325
+ modelDisplayName(model) {
326
+ return getShortModelName(model);
327
+ },
328
+ toolDisplayName(rawTool) {
329
+ return ownValue(toolNameMap, rawTool) ?? rawTool;
330
+ },
331
+ async discoverSessions() {
332
+ const sources = [];
333
+ const sessionsRoot = join(shareDir, 'sessions');
334
+ const projectNames = await loadProjectNames(shareDir);
335
+ const workDirs = await readdir(sessionsRoot, { withFileTypes: true }).catch(() => []);
336
+ for (const workDir of workDirs) {
337
+ if (!workDir.isDirectory())
338
+ continue;
339
+ const project = projectNames.get(workDir.name) ?? workDir.name;
340
+ const workDirPath = join(sessionsRoot, workDir.name);
341
+ const sessionDirs = await readdir(workDirPath, { withFileTypes: true }).catch(() => []);
342
+ for (const sessionDir of sessionDirs) {
343
+ if (!sessionDir.isDirectory())
344
+ continue;
345
+ const sessionPath = join(workDirPath, sessionDir.name);
346
+ await addWireSource(sources, join(sessionPath, 'wire.jsonl'), project);
347
+ const subagentsPath = join(sessionPath, 'subagents');
348
+ const subagents = await readdir(subagentsPath, { withFileTypes: true }).catch(() => []);
349
+ for (const subagent of subagents) {
350
+ if (!subagent.isDirectory())
351
+ continue;
352
+ await addWireSource(sources, join(subagentsPath, subagent.name, 'wire.jsonl'), project);
353
+ }
354
+ }
355
+ }
356
+ return sources;
357
+ },
358
+ createSessionParser(source, seenKeys) {
359
+ return createParser(source, shareDir, seenKeys);
360
+ },
361
+ };
362
+ }
363
+ export const kimi = createKimiProvider();