chompyy 0.5.0 → 0.7.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.
- package/README.md +14 -1
- package/dist/advice.js +98 -1
- package/dist/agentlimits.js +77 -0
- package/dist/agentusage.js +96 -0
- package/dist/approvals.js +129 -0
- package/dist/appstate.js +73 -3
- package/dist/away.js +48 -5
- package/dist/blueprint.js +3 -7
- package/dist/board.js +1 -0
- package/dist/cli.js +343 -18
- package/dist/codexquota.js +106 -0
- package/dist/codexusage.js +10 -0
- package/dist/config.js +2 -0
- package/dist/context.js +30 -0
- package/dist/costs.js +41 -2
- package/dist/demon.js +20 -0
- package/dist/detect.js +38 -6
- package/dist/didwork.js +26 -0
- package/dist/label.js +33 -0
- package/dist/menu.js +17 -0
- package/dist/nightcap.js +72 -0
- package/dist/nudge.js +70 -24
- package/dist/pacing.js +16 -1
- package/dist/punchcard.js +39 -0
- package/dist/questions.js +71 -0
- package/dist/recap.js +74 -0
- package/dist/receipt.js +48 -0
- package/dist/recipe.js +79 -0
- package/dist/savings.js +111 -0
- package/dist/stamps.js +14 -0
- package/dist/suggest.js +15 -5
- package/dist/triggers.js +5 -0
- package/dist/usage.js +21 -1
- package/dist/vendor/codeburn/antigravity.js +309 -0
- package/dist/vendor/codeburn/codex.js +429 -0
- package/dist/vendor/codeburn/copilot.js +292 -0
- package/dist/vendor/codeburn/gemini.js +195 -0
- package/dist/vendor/codeburn/grokbot.js +182 -0
- package/dist/vendor/codeburn/kimi.js +178 -0
- package/dist/vendor/codeburn/shims/chalk.js +14 -0
- package/dist/vendor/codeburn/shims/strip-ansi.js +6 -0
- package/dist/vendor/codeburn/src/act/backup.js +83 -0
- package/dist/vendor/codeburn/src/act/model-defaults.js +151 -0
- package/dist/vendor/codeburn/src/act/types.js +37 -0
- package/dist/vendor/codeburn/src/bash-utils.js +204 -0
- package/dist/vendor/codeburn/src/behavioral-weight.js +47 -0
- package/dist/vendor/codeburn/src/cache-dir.js +26 -0
- package/dist/vendor/codeburn/src/cache-refresh-lock.js +543 -0
- package/dist/vendor/codeburn/src/cache-sweep.js +67 -0
- package/dist/vendor/codeburn/src/classifier.js +209 -0
- package/dist/vendor/codeburn/src/claude-identity.js +223 -0
- package/dist/vendor/codeburn/src/codex-cache.js +377 -0
- package/dist/vendor/codeburn/src/codex-fork-replay.js +232 -0
- package/dist/vendor/codeburn/src/codex-jsonl-fields.js +99 -0
- package/dist/vendor/codeburn/src/codex-session-index.js +113 -0
- package/dist/vendor/codeburn/src/codex-throughput.js +544 -0
- package/dist/vendor/codeburn/src/compare-stats.js +405 -0
- package/dist/vendor/codeburn/src/config.js +145 -0
- package/dist/vendor/codeburn/src/content-utils.js +56 -0
- package/dist/vendor/codeburn/src/context-tree-codex.js +329 -0
- package/dist/vendor/codeburn/src/context-tree.js +664 -0
- package/dist/vendor/codeburn/src/copilot-aiu.js +16 -0
- package/dist/vendor/codeburn/src/currency.js +189 -0
- package/dist/vendor/codeburn/src/cursor-cache.js +238 -0
- package/dist/vendor/codeburn/src/cursor-import.js +402 -0
- package/dist/vendor/codeburn/src/cursor-sync.js +256 -0
- package/dist/vendor/codeburn/src/daily-cache.js +2036 -0
- package/dist/vendor/codeburn/src/data/litellm-snapshot.json +1 -0
- package/dist/vendor/codeburn/src/data/pricing-fallback.json +1 -0
- package/dist/vendor/codeburn/src/day-aggregator.js +327 -0
- package/dist/vendor/codeburn/src/editor-data-dir.js +11 -0
- package/dist/vendor/codeburn/src/fetch-utils.js +18 -0
- package/dist/vendor/codeburn/src/format.js +118 -0
- package/dist/vendor/codeburn/src/fs-utils.js +270 -0
- package/dist/vendor/codeburn/src/git-origin.js +334 -0
- package/dist/vendor/codeburn/src/granular-history.js +328 -0
- package/dist/vendor/codeburn/src/hermes-session-ledger.js +512 -0
- package/dist/vendor/codeburn/src/launcher-homes.js +142 -0
- package/dist/vendor/codeburn/src/live-sessions.js +358 -0
- package/dist/vendor/codeburn/src/math-utils.js +8 -0
- package/dist/vendor/codeburn/src/menubar-json.js +294 -0
- package/dist/vendor/codeburn/src/models.js +1879 -0
- package/dist/vendor/codeburn/src/optimize-one-hour-cache.js +92 -0
- package/dist/vendor/codeburn/src/optimize.js +4110 -0
- package/dist/vendor/codeburn/src/parse-workers.js +219 -0
- package/dist/vendor/codeburn/src/parser.js +6955 -0
- package/dist/vendor/codeburn/src/path-privacy.js +26 -0
- package/dist/vendor/codeburn/src/plans.js +135 -0
- package/dist/vendor/codeburn/src/pr-signals.js +132 -0
- package/dist/vendor/codeburn/src/project-filter-warnings.js +33 -0
- package/dist/vendor/codeburn/src/provider-issues.js +30 -0
- package/dist/vendor/codeburn/src/providers/amp.js +286 -0
- package/dist/vendor/codeburn/src/providers/antigravity.js +1731 -0
- package/dist/vendor/codeburn/src/providers/claude.js +551 -0
- package/dist/vendor/codeburn/src/providers/cline-cli.js +401 -0
- package/dist/vendor/codeburn/src/providers/cline.js +63 -0
- package/dist/vendor/codeburn/src/providers/codebuff.js +336 -0
- package/dist/vendor/codeburn/src/providers/codewhale.js +442 -0
- package/dist/vendor/codeburn/src/providers/codex.js +1720 -0
- package/dist/vendor/codeburn/src/providers/command-code.js +196 -0
- package/dist/vendor/codeburn/src/providers/copilot.js +3278 -0
- package/dist/vendor/codeburn/src/providers/crush.js +226 -0
- package/dist/vendor/codeburn/src/providers/cursor-agent.js +837 -0
- package/dist/vendor/codeburn/src/providers/cursor.js +1163 -0
- package/dist/vendor/codeburn/src/providers/devin.js +569 -0
- package/dist/vendor/codeburn/src/providers/droid.js +324 -0
- package/dist/vendor/codeburn/src/providers/dsh.js +690 -0
- package/dist/vendor/codeburn/src/providers/forge.js +245 -0
- package/dist/vendor/codeburn/src/providers/gemini.js +230 -0
- package/dist/vendor/codeburn/src/providers/goose.js +252 -0
- package/dist/vendor/codeburn/src/providers/grok.js +581 -0
- package/dist/vendor/codeburn/src/providers/grokbot.js +290 -0
- package/dist/vendor/codeburn/src/providers/hermes.js +771 -0
- package/dist/vendor/codeburn/src/providers/ibm-bob.js +53 -0
- package/dist/vendor/codeburn/src/providers/index.js +360 -0
- package/dist/vendor/codeburn/src/providers/kilo-code.js +50 -0
- package/dist/vendor/codeburn/src/providers/kimi.js +363 -0
- package/dist/vendor/codeburn/src/providers/kimicode.js +402 -0
- package/dist/vendor/codeburn/src/providers/kiro.js +1174 -0
- package/dist/vendor/codeburn/src/providers/lingtai-tui.js +372 -0
- package/dist/vendor/codeburn/src/providers/mistral-vibe-unified.js +236 -0
- package/dist/vendor/codeburn/src/providers/mistral-vibe.js +405 -0
- package/dist/vendor/codeburn/src/providers/mux.js +242 -0
- package/dist/vendor/codeburn/src/providers/open-design.js +217 -0
- package/dist/vendor/codeburn/src/providers/openclaude.js +309 -0
- package/dist/vendor/codeburn/src/providers/openclaw.js +442 -0
- package/dist/vendor/codeburn/src/providers/opencode-file-parser.js +131 -0
- package/dist/vendor/codeburn/src/providers/opencode.js +91 -0
- package/dist/vendor/codeburn/src/providers/pi.js +429 -0
- package/dist/vendor/codeburn/src/providers/quickdesk.js +491 -0
- package/dist/vendor/codeburn/src/providers/qwen.js +193 -0
- package/dist/vendor/codeburn/src/providers/session-message.js +118 -0
- package/dist/vendor/codeburn/src/providers/sqlite-session-parser.js +457 -0
- package/dist/vendor/codeburn/src/providers/types.js +5 -0
- package/dist/vendor/codeburn/src/providers/vercel-gateway.js +135 -0
- package/dist/vendor/codeburn/src/providers/vscode-cline-parser.js +212 -0
- package/dist/vendor/codeburn/src/providers/warp.js +575 -0
- package/dist/vendor/codeburn/src/providers/zcode.js +249 -0
- package/dist/vendor/codeburn/src/providers/zed.js +187 -0
- package/dist/vendor/codeburn/src/providers/zerostack.js +139 -0
- package/dist/vendor/codeburn/src/quota/antigravity.js +310 -0
- package/dist/vendor/codeburn/src/quota/claude.js +244 -0
- package/dist/vendor/codeburn/src/quota/cursor.js +301 -0
- package/dist/vendor/codeburn/src/quota/security.js +299 -0
- package/dist/vendor/codeburn/src/quota/types.js +1 -0
- package/dist/vendor/codeburn/src/scan-facts.js +99 -0
- package/dist/vendor/codeburn/src/session-cache.js +3040 -0
- package/dist/vendor/codeburn/src/session-count-label.js +14 -0
- package/dist/vendor/codeburn/src/session-output.js +139 -0
- package/dist/vendor/codeburn/src/session-population.js +30 -0
- package/dist/vendor/codeburn/src/sessions-report.js +1342 -0
- package/dist/vendor/codeburn/src/sqlite.js +528 -0
- package/dist/vendor/codeburn/src/sync/otlp.js +420 -0
- package/dist/vendor/codeburn/src/telemetry-snapshot.js +244 -0
- package/dist/vendor/codeburn/src/token-estimate.js +5 -0
- package/dist/vendor/codeburn/src/types.js +16 -0
- package/dist/vendor/codeburn/src/work-units.js +126 -0
- package/dist/vendor/codeburn/src/workflow-insights.js +228 -0
- package/dist/vendor/codeburn/src/wsl.js +198 -0
- package/dist/vendor/codeburn/src/yield.js +666 -0
- package/dist/wastechecks.js +233 -0
- package/package.json +1 -1
|
@@ -0,0 +1,290 @@
|
|
|
1
|
+
// @ts-nocheck: codeburn type-checks this under its own tsconfig; Chompyy adds noUncheckedIndexedAccess (see UPSTREAM.md)
|
|
2
|
+
import { readdir } from 'fs/promises';
|
|
3
|
+
import { homedir } from 'os';
|
|
4
|
+
import { basename, join } from 'path';
|
|
5
|
+
import { FS_SCAN_CONCURRENCY, mapWithConcurrency, readSessionFile } from '../fs-utils.js';
|
|
6
|
+
import { calculateCost, getShortModelName } from '../models.js';
|
|
7
|
+
import { estimateTokensFromChars } from '../token-estimate.js';
|
|
8
|
+
import { importSource, importSourceParser } from '../cursor-import.js';
|
|
9
|
+
// Grok Bot is xAI's Electron desktop agent app (bundle id com.anysphere.sand),
|
|
10
|
+
// not Grok Build — xAI's coding CLI, which is the separate `grok` provider.
|
|
11
|
+
//
|
|
12
|
+
// Mapped against app version 0.30.0. The authoritative agent store lives on the
|
|
13
|
+
// remote box (`/home/box/sand-data/agents/<id>/store.db`); the app mirrors a
|
|
14
|
+
// sliding window of roughly the last 200 transcript entries per bot into its
|
|
15
|
+
// Electron userData directory as `sand-client-persistence/<base32 key>.blob`,
|
|
16
|
+
// plain UTF-8 JSON. `~/.grokbot` (the `$SAND_DATA_ROOT` marked by
|
|
17
|
+
// `.grokbot-data-root-v1`) holds host plumbing, settings and secrets — on 0.30
|
|
18
|
+
// its `agents/*/store.db` transcript tables are empty, so nothing is read there.
|
|
19
|
+
//
|
|
20
|
+
// The mirror records no token counts, no cost and no model id, so every figure
|
|
21
|
+
// here is estimated from message text and every cost is marked estimated.
|
|
22
|
+
// Unknown entry kinds and unknown fields are ignored rather than rejected: the
|
|
23
|
+
// app self-updates and the schema moves with it.
|
|
24
|
+
const PERSISTENCE_DIR = 'sand-client-persistence';
|
|
25
|
+
const TRANSCRIPT_SLICE = /^sand\.client\.slice\.account\.(.+)\.transcript\.replicas\.(.+)$/;
|
|
26
|
+
const ROSTER_SLICE = /^sand\.client\.slice\.account\.(.+)\.roster\.last-roster$/;
|
|
27
|
+
// The app's own synthetic model id: Grok Bot serves opaque `sand-*` aliases and
|
|
28
|
+
// never records which one answered, so there is no real id to report.
|
|
29
|
+
const MODEL_ID = 'grokbot-auto';
|
|
30
|
+
const BASE32_ALPHABET = 'abcdefghijklmnopqrstuvwxyz234567';
|
|
31
|
+
/** RFC 4648 base32, lowercase and unpadded — how the app names its slice files. */
|
|
32
|
+
function decodeBase32(name) {
|
|
33
|
+
const bytes = [];
|
|
34
|
+
let value = 0;
|
|
35
|
+
let bits = 0;
|
|
36
|
+
for (const char of name) {
|
|
37
|
+
const index = BASE32_ALPHABET.indexOf(char);
|
|
38
|
+
if (index < 0)
|
|
39
|
+
return null;
|
|
40
|
+
value = (value << 5) | index;
|
|
41
|
+
bits += 5;
|
|
42
|
+
if (bits >= 8) {
|
|
43
|
+
bits -= 8;
|
|
44
|
+
bytes.push((value >>> bits) & 0xff);
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
try {
|
|
48
|
+
return Buffer.from(bytes).toString('utf-8');
|
|
49
|
+
}
|
|
50
|
+
catch {
|
|
51
|
+
return null;
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
/** A mirror transcript slice: discovery marks every one durable on its own. */
|
|
55
|
+
export function isGrokbotMirrorPath(path) {
|
|
56
|
+
const name = basename(path);
|
|
57
|
+
if (!name.endsWith('.blob'))
|
|
58
|
+
return false;
|
|
59
|
+
const key = decodeBase32(name.slice(0, -'.blob'.length));
|
|
60
|
+
return key !== null && TRANSCRIPT_SLICE.test(key);
|
|
61
|
+
}
|
|
62
|
+
export function grokbotPersistenceDir(platform = process.platform, home = homedir()) {
|
|
63
|
+
const configured = process.env['CODEBURN_GROKBOT_DIR']?.trim();
|
|
64
|
+
if (configured)
|
|
65
|
+
return configured;
|
|
66
|
+
if (platform === 'darwin')
|
|
67
|
+
return join(home, 'Library', 'Application Support', 'Grok Bot', PERSISTENCE_DIR);
|
|
68
|
+
if (platform === 'win32') {
|
|
69
|
+
const appData = process.env['APPDATA']?.trim() || join(home, 'AppData', 'Roaming');
|
|
70
|
+
return join(appData, 'Grok Bot', PERSISTENCE_DIR);
|
|
71
|
+
}
|
|
72
|
+
return join(home, '.config', 'Grok Bot', PERSISTENCE_DIR);
|
|
73
|
+
}
|
|
74
|
+
function isRecord(value) {
|
|
75
|
+
return typeof value === 'object' && value !== null && !Array.isArray(value);
|
|
76
|
+
}
|
|
77
|
+
function nonEmptyString(value) {
|
|
78
|
+
return typeof value === 'string' && value.length > 0 ? value : undefined;
|
|
79
|
+
}
|
|
80
|
+
async function readSlice(path) {
|
|
81
|
+
const content = await readSessionFile(path);
|
|
82
|
+
if (content === null)
|
|
83
|
+
return null;
|
|
84
|
+
try {
|
|
85
|
+
const parsed = JSON.parse(content);
|
|
86
|
+
if (!isRecord(parsed))
|
|
87
|
+
return null;
|
|
88
|
+
return isRecord(parsed['value']) ? parsed['value'] : null;
|
|
89
|
+
}
|
|
90
|
+
catch {
|
|
91
|
+
return null;
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
/** agentId -> the bot name shown in the app's sidebar ("Reddit Bot"). */
|
|
95
|
+
async function readRoster(path) {
|
|
96
|
+
const names = new Map();
|
|
97
|
+
const value = await readSlice(path);
|
|
98
|
+
const rows = value?.['rows'];
|
|
99
|
+
if (!Array.isArray(rows))
|
|
100
|
+
return names;
|
|
101
|
+
for (const row of rows) {
|
|
102
|
+
if (!isRecord(row))
|
|
103
|
+
continue;
|
|
104
|
+
const id = nonEmptyString(row['id']);
|
|
105
|
+
const name = nonEmptyString(row['name']);
|
|
106
|
+
if (id && name)
|
|
107
|
+
names.set(id, name);
|
|
108
|
+
}
|
|
109
|
+
return names;
|
|
110
|
+
}
|
|
111
|
+
// The app writes ms since the epoch. Anything outside a plausible range is a
|
|
112
|
+
// schema change or a corrupt row, not a date worth reporting.
|
|
113
|
+
const MIN_TIMESTAMP_MS = Date.UTC(2020, 0, 1);
|
|
114
|
+
const MAX_TIMESTAMP_MS = Date.UTC(2100, 0, 1);
|
|
115
|
+
function timestampOf(value) {
|
|
116
|
+
if (typeof value !== 'number' || !Number.isFinite(value))
|
|
117
|
+
return null;
|
|
118
|
+
// Some slices could plausibly gain a seconds-scale stamp; promote it.
|
|
119
|
+
const ms = value < MIN_TIMESTAMP_MS ? value * 1000 : value;
|
|
120
|
+
return ms >= MIN_TIMESTAMP_MS && ms < MAX_TIMESTAMP_MS ? ms : null;
|
|
121
|
+
}
|
|
122
|
+
function textOf(value) {
|
|
123
|
+
if (typeof value === 'string')
|
|
124
|
+
return value;
|
|
125
|
+
if (!isRecord(value))
|
|
126
|
+
return '';
|
|
127
|
+
const content = value['content'];
|
|
128
|
+
return typeof content === 'string' ? content : '';
|
|
129
|
+
}
|
|
130
|
+
/**
|
|
131
|
+
* One request is one `requestId`: the app stamps a prompt and every message the
|
|
132
|
+
* bot emits in reply with the same id. `message` entries arrive at the bot
|
|
133
|
+
* (from the person, or from another bot via `fromAgent`); `send-message`
|
|
134
|
+
* entries are the bot's own output.
|
|
135
|
+
*/
|
|
136
|
+
function groupRequests(entries) {
|
|
137
|
+
const requests = new Map();
|
|
138
|
+
for (const entry of entries) {
|
|
139
|
+
if (!isRecord(entry))
|
|
140
|
+
continue;
|
|
141
|
+
const kind = entry['kind'];
|
|
142
|
+
if (kind !== 'message' && kind !== 'send-message')
|
|
143
|
+
continue;
|
|
144
|
+
const timestampMs = timestampOf(entry['timestampMs']);
|
|
145
|
+
if (timestampMs === null)
|
|
146
|
+
continue;
|
|
147
|
+
const key = nonEmptyString(entry['requestId']) ?? nonEmptyString(entry['id']);
|
|
148
|
+
if (!key)
|
|
149
|
+
continue;
|
|
150
|
+
let request = requests.get(key);
|
|
151
|
+
if (!request) {
|
|
152
|
+
request = { key, inputChars: 0, outputChars: 0, firstTimestampMs: timestampMs, userMessage: '' };
|
|
153
|
+
requests.set(key, request);
|
|
154
|
+
}
|
|
155
|
+
if (timestampMs < request.firstTimestampMs)
|
|
156
|
+
request.firstTimestampMs = timestampMs;
|
|
157
|
+
if (kind === 'send-message') {
|
|
158
|
+
request.outputChars += textOf(entry['message']).length;
|
|
159
|
+
continue;
|
|
160
|
+
}
|
|
161
|
+
const content = textOf(entry['content']);
|
|
162
|
+
// Direction comes from `role`, not from the entry kind: a `message` with
|
|
163
|
+
// role assistant is this bot's own text on its way out, usually addressed
|
|
164
|
+
// to another bot via `toAgent`. Role user is what arrived here — from the
|
|
165
|
+
// person, or from another bot via `fromAgent`.
|
|
166
|
+
if (entry['role'] === 'assistant') {
|
|
167
|
+
request.outputChars += content.length;
|
|
168
|
+
continue;
|
|
169
|
+
}
|
|
170
|
+
request.inputChars += content.length;
|
|
171
|
+
// A `message` carrying `fromAgent` was sent by another bot, so only a bare
|
|
172
|
+
// user message makes this a human turn. Routine and background-revival runs
|
|
173
|
+
// keep an empty userMessage, which is what stops the task classifier from
|
|
174
|
+
// reading them as something a person asked for.
|
|
175
|
+
if (!request.userMessage && entry['role'] === 'user' && !isRecord(entry['fromAgent'])) {
|
|
176
|
+
request.userMessage = content;
|
|
177
|
+
}
|
|
178
|
+
}
|
|
179
|
+
return [...requests.values()];
|
|
180
|
+
}
|
|
181
|
+
function createParser(source, seenKeys) {
|
|
182
|
+
return {
|
|
183
|
+
async *parse() {
|
|
184
|
+
const value = await readSlice(source.path);
|
|
185
|
+
const entries = value?.['entries'];
|
|
186
|
+
if (!Array.isArray(entries))
|
|
187
|
+
return;
|
|
188
|
+
const sessionId = source.sourceId ?? source.project;
|
|
189
|
+
for (const request of groupRequests(entries)) {
|
|
190
|
+
const inputTokens = estimateTokensFromChars(request.inputChars);
|
|
191
|
+
const outputTokens = estimateTokensFromChars(request.outputChars);
|
|
192
|
+
if (inputTokens + outputTokens === 0)
|
|
193
|
+
continue;
|
|
194
|
+
const deduplicationKey = `grokbot:${sessionId}:${request.key}`;
|
|
195
|
+
if (seenKeys.has(deduplicationKey))
|
|
196
|
+
continue;
|
|
197
|
+
seenKeys.add(deduplicationKey);
|
|
198
|
+
yield {
|
|
199
|
+
provider: 'grokbot',
|
|
200
|
+
model: MODEL_ID,
|
|
201
|
+
inputTokens,
|
|
202
|
+
outputTokens,
|
|
203
|
+
cacheCreationInputTokens: 0,
|
|
204
|
+
cacheReadInputTokens: 0,
|
|
205
|
+
cachedInputTokens: 0,
|
|
206
|
+
reasoningTokens: 0,
|
|
207
|
+
webSearchRequests: 0,
|
|
208
|
+
costUSD: calculateCost(MODEL_ID, inputTokens, outputTokens, 0, 0, 0),
|
|
209
|
+
costIsEstimated: true,
|
|
210
|
+
// The mirror carries chat entries only: no tool call and no shell
|
|
211
|
+
// command the bot ran on its box reaches this machine.
|
|
212
|
+
tools: [],
|
|
213
|
+
bashCommands: [],
|
|
214
|
+
timestamp: new Date(request.firstTimestampMs).toISOString(),
|
|
215
|
+
speed: 'standard',
|
|
216
|
+
deduplicationKey,
|
|
217
|
+
userMessage: request.userMessage,
|
|
218
|
+
sessionId,
|
|
219
|
+
project: source.project,
|
|
220
|
+
};
|
|
221
|
+
}
|
|
222
|
+
},
|
|
223
|
+
};
|
|
224
|
+
}
|
|
225
|
+
async function discoverSessions(dir) {
|
|
226
|
+
let files;
|
|
227
|
+
try {
|
|
228
|
+
files = await readdir(dir);
|
|
229
|
+
}
|
|
230
|
+
catch {
|
|
231
|
+
return [];
|
|
232
|
+
}
|
|
233
|
+
const slices = files
|
|
234
|
+
.filter(file => file.endsWith('.blob'))
|
|
235
|
+
.map(file => ({ file, key: decodeBase32(file.slice(0, -'.blob'.length)) }))
|
|
236
|
+
.filter((slice) => slice.key !== null);
|
|
237
|
+
const rosterFiles = slices.filter(slice => ROSTER_SLICE.test(slice.key));
|
|
238
|
+
const rosters = await mapWithConcurrency(rosterFiles, FS_SCAN_CONCURRENCY, slice => readRoster(join(dir, slice.file)));
|
|
239
|
+
const names = new Map();
|
|
240
|
+
for (const roster of rosters)
|
|
241
|
+
for (const [id, name] of roster)
|
|
242
|
+
names.set(id, name);
|
|
243
|
+
const sources = [];
|
|
244
|
+
for (const slice of slices) {
|
|
245
|
+
const match = TRANSCRIPT_SLICE.exec(slice.key);
|
|
246
|
+
if (!match)
|
|
247
|
+
continue;
|
|
248
|
+
const agentId = match[2];
|
|
249
|
+
const botName = names.get(agentId);
|
|
250
|
+
sources.push({
|
|
251
|
+
path: join(dir, slice.file),
|
|
252
|
+
// Grok Bot has no project: work is organised by bot, so the bot's own
|
|
253
|
+
// name is what the report groups by, with the same name as the agent
|
|
254
|
+
// label for surfaces that show both.
|
|
255
|
+
project: botName ?? agentId,
|
|
256
|
+
provider: 'grokbot',
|
|
257
|
+
sourceId: agentId,
|
|
258
|
+
// The mirror is a sliding window: requests that slid out of it stay
|
|
259
|
+
// cached, or the bot's history would shrink as it works.
|
|
260
|
+
durable: true,
|
|
261
|
+
...(botName ? { sourceLabel: botName, agentName: botName } : {}),
|
|
262
|
+
});
|
|
263
|
+
}
|
|
264
|
+
return sources;
|
|
265
|
+
}
|
|
266
|
+
export function createGrokbotProvider(persistenceDir) {
|
|
267
|
+
// Resolved per call, not at import, so CODEBURN_GROKBOT_DIR set after the
|
|
268
|
+
// module loads still moves discovery.
|
|
269
|
+
const resolveDir = () => persistenceDir ?? grokbotPersistenceDir();
|
|
270
|
+
return {
|
|
271
|
+
name: 'grokbot',
|
|
272
|
+
displayName: 'Grok Bot',
|
|
273
|
+
async probeRoots() {
|
|
274
|
+
return [{ path: resolveDir(), label: 'client persistence' }];
|
|
275
|
+
},
|
|
276
|
+
modelDisplayName(model) {
|
|
277
|
+
return getShortModelName(model);
|
|
278
|
+
},
|
|
279
|
+
toolDisplayName(rawTool) {
|
|
280
|
+
return rawTool;
|
|
281
|
+
},
|
|
282
|
+
async discoverSessions() {
|
|
283
|
+
return [...await discoverSessions(resolveDir()), ...importSource('grokbot')];
|
|
284
|
+
},
|
|
285
|
+
createSessionParser(source, seenKeys) {
|
|
286
|
+
return importSourceParser(source, seenKeys, 'grokbot') ?? createParser(source, seenKeys);
|
|
287
|
+
},
|
|
288
|
+
};
|
|
289
|
+
}
|
|
290
|
+
export const grokbot = createGrokbotProvider();
|