claude-code-session-manager 0.138.0 → 0.139.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/.claude-plugin/marketplace.json +1 -1
- package/README.md +339 -82
- package/dist/assets/{AppSettings-CgDhqrsU.js → AppSettings-CUfWY9vN.js} +2 -2
- package/dist/assets/History-DDnqaLyw.js +2 -0
- package/dist/assets/HomeClaudeConfig-CGD2Onjv.js +3 -0
- package/dist/assets/{Panel-CeDiyuNn.js → Panel-Csyd9HbD.js} +1 -1
- package/dist/assets/ProjectClaudeConfig-C-jlYpC_.js +26 -0
- package/dist/assets/{Scheduler-CkhTvG7C.js → Scheduler-NLs08fx7.js} +9 -9
- package/dist/assets/{SkillReferenceGraph-CFMK8NJh.js → SkillReferenceGraph-DcscPXAG.js} +1 -1
- package/dist/assets/Skills-BpGRKOcY.js +67 -0
- package/dist/assets/{TiptapBody-D1kTj-tn.js → TiptapBody-DSU3769X.js} +60 -54
- package/dist/assets/ViewTabs-C0PRZx4_.js +1 -0
- package/dist/assets/{VoiceButton-CZeyPM31.js → VoiceButton-D2rMurNg.js} +1 -1
- package/dist/assets/{historyTotals-B00l64Jw.js → historyTotals-TcIQs2sh.js} +1 -1
- package/dist/assets/{index-62tyjEQB.css → index-BCySPdtU.css} +1 -1
- package/dist/assets/{index-CgCxpunJ.js → index-C-d0DCre.js} +523 -515
- package/dist/index.html +2 -2
- package/dist-web/app.css +1 -1
- package/dist-web/app.js +469 -450
- package/package.json +13 -5
- package/plugins/session-manager-dev/.claude-plugin/plugin.json +1 -1
- package/plugins/session-manager-dev/skills/builder/SKILL.md +12 -4
- package/plugins/session-manager-dev/skills/builder/scripts/publish-preflight.cjs +255 -0
- package/plugins/session-manager-dev/skills/develop/SKILL.md +12 -5
- package/scripts/README.md +1 -0
- package/scripts/scheduler-mcp-server.cjs +161 -18
- package/src/main/build-info.json +4 -4
- package/src/main/chatRunner.cjs +2 -2
- package/src/main/exchanges.cjs +70 -5
- package/src/main/historyAggregator.cjs +84 -58
- package/src/main/historyDashboard.cjs +18 -13
- package/src/main/index.cjs +22 -2
- package/src/main/ipcSchemas.cjs +122 -5
- package/src/main/lib/claude/effectiveModelInfo.cjs +2 -2
- package/src/main/lib/claude/modelPricing.cjs +148 -0
- package/src/main/lib/epic/epicAdminRoutes.cjs +101 -0
- package/src/main/lib/epic/epicJobReceipt.cjs +87 -0
- package/src/main/lib/epic/epicOutsideRead.cjs +306 -0
- package/src/main/lib/epic/epicOutsideState.cjs +233 -0
- package/src/main/lib/epic/epicSettle.cjs +1 -1
- package/src/main/lib/epic/epicStateWatcher.cjs +157 -0
- package/src/main/lib/epic/externalRef.cjs +37 -0
- package/src/main/lib/epic/externalRefIndex.cjs +136 -0
- package/src/main/lib/epic/restorableSessions.cjs +151 -17
- package/src/main/lib/epic/transcriptUsage.cjs +197 -0
- package/src/main/lib/externalContract.cjs +111 -0
- package/src/main/lib/feedback-remote/crossProjectFeedback.cjs +121 -4
- package/src/main/lib/feedback-remote/crossProjectReply.cjs +83 -1
- package/src/main/lib/feedback-remote/customerFeedbackAdminRoutes.cjs +16 -6
- package/src/main/lib/feedback-remote/customerFeedbackClient.cjs +50 -8
- package/src/main/lib/feedback-remote/customerFeedbackInbox.cjs +218 -4
- package/src/main/lib/feedback-remote/customerFeedbackIpc.cjs +19 -3
- package/src/main/lib/feedback-remote/feedbackImages.cjs +171 -0
- package/src/main/lib/feedback-remote/localAdminHttp.cjs +11 -10
- package/src/main/lib/feedback-remote/macroAdminRoutes.cjs +120 -2
- package/src/main/lib/feedback-remote/needsYouAdminRoutes.cjs +133 -0
- package/src/main/lib/feedback-remote/needsYouIpc.cjs +50 -0
- package/src/main/lib/feedback-remote/needsYouStore.cjs +281 -0
- package/src/main/lib/historyRollup.cjs +32 -5
- package/src/main/lib/mcpToolCatalog.cjs +111 -14
- package/src/main/lib/persona-macro/agentAdminRoutes.cjs +121 -0
- package/src/main/lib/promptSessionSchema.cjs +4 -0
- package/src/main/lib/remoteTranscriptTail.cjs +32 -1
- package/src/main/lib/scheduler/schedulerPaths.cjs +9 -0
- package/src/main/lib/telemetry/auditEvents.cjs +176 -0
- package/src/main/lib/telemetry/eventsAdminRoutes.cjs +45 -0
- package/src/main/loopEfficiencyHandlers.cjs +1 -1
- package/src/main/scheduler.cjs +29 -0
- package/src/main/templates/PRD_AUTHORING.md +1 -0
- package/src/main/transcripts.cjs +62 -7
- package/src/main/webRemote.cjs +122 -18
- package/src/preload/api.d.ts +71 -8
- package/src/preload/apiSurface.cjs +7 -0
- package/src/preload/apiSurface.json +408 -83
- package/src/preload/index.cjs +15 -3
- package/dist/assets/AgentLibrary-C1d_D7uQ.js +0 -2
- package/dist/assets/Button-Bk23rEnZ.js +0 -1
- package/dist/assets/DocumentEditorPane-BqY5Nq6W.js +0 -1
- package/dist/assets/Extensions-CXem-uwI.js +0 -2
- package/dist/assets/History-BwO3coo4.js +0 -2
- package/dist/assets/Library-BDV69fSe.js +0 -32
- package/dist/assets/ListDetail-CD-Fm6mh.js +0 -1
- package/dist/assets/ProjectClaudeConfig-NjdKdwe8.js +0 -25
- package/dist/assets/ProvenanceBadge-Bu8NmI_R.js +0 -1
- package/dist/assets/Settings-COT34hBF.js +0 -2
- package/dist/assets/Skills-BgexoUkQ.js +0 -29
- package/dist/assets/SourceChip-BXjcdeb1.js +0 -1
- package/dist/assets/SystemPrompt-CeeH3EeW.js +0 -1
- package/dist/assets/Toggle-CENi19iK.js +0 -1
- package/dist/assets/ViewTabs-DDBb0x96.js +0 -1
- package/dist/assets/claude-settings-schema-COigsajx.js +0 -3
|
@@ -7,6 +7,7 @@ const os = require('node:os');
|
|
|
7
7
|
const { schemas } = require('./ipcSchemas.cjs');
|
|
8
8
|
const historyRollup = require('./lib/historyRollup.cjs');
|
|
9
9
|
const { sendIfAlive } = require('./lib/sendToRenderer.cjs');
|
|
10
|
+
const { costOfUsage } = require('./lib/claude/modelPricing.cjs');
|
|
10
11
|
|
|
11
12
|
const PROJECTS_DIR = path.join(os.homedir(), '.claude', 'projects');
|
|
12
13
|
const PARSE_BUDGET_MS = 2_000;
|
|
@@ -18,37 +19,6 @@ const MAX_FILE_BYTES = 20 * 1024 * 1024;
|
|
|
18
19
|
// range hit cache instead of self-evicting mid-scan and spuriously truncating.
|
|
19
20
|
const CACHE_MAX = 50_000;
|
|
20
21
|
|
|
21
|
-
// Dollars per million tokens (input / output / cache-read). Cache-read
|
|
22
|
-
// tokens are priced far below input because they're served from
|
|
23
|
-
// Anthropic's prompt cache, not re-processed — this is what makes the
|
|
24
|
-
// cache-savings figure in the dashboard real money, not a vanity stat.
|
|
25
|
-
// fable: Claude Fable 5.1 (claude-fable-5-1) — $10/$50 per MTok input/output,
|
|
26
|
-
// cache reads at $0.25/MTok (the `claude-api` skill's model reference and its
|
|
27
|
-
// Claude Fable 5.1 migration notes, both cached 2026-06-24).
|
|
28
|
-
const MODEL_PRICING = {
|
|
29
|
-
opus: { i: 15, o: 75, c: 1.5 },
|
|
30
|
-
sonnet: { i: 3, o: 15, c: 0.3 },
|
|
31
|
-
haiku: { i: 0.8, o: 4, c: 0.08 },
|
|
32
|
-
fable: { i: 10, o: 50, c: 0.25 },
|
|
33
|
-
};
|
|
34
|
-
const DEFAULT_PRICING_KEY = 'sonnet'; // fallback for unrecognized model ids
|
|
35
|
-
|
|
36
|
-
/**
|
|
37
|
-
* Resolve a raw model id (e.g. "claude-opus-4-8-20260115") to a pricing
|
|
38
|
-
* bucket key. Model ids aren't stable enough to match exactly, so this is a
|
|
39
|
-
* case-insensitive substring check. Unrecognized ids fall back to
|
|
40
|
-
* DEFAULT_PRICING_KEY and are flagged so callers can annotate them as
|
|
41
|
-
* estimated rather than exact.
|
|
42
|
-
*/
|
|
43
|
-
function resolvePricingKey(modelId) {
|
|
44
|
-
const id = String(modelId ?? '').toLowerCase();
|
|
45
|
-
if (id.includes('opus')) return { key: 'opus', estimated: false };
|
|
46
|
-
if (id.includes('sonnet')) return { key: 'sonnet', estimated: false };
|
|
47
|
-
if (id.includes('haiku')) return { key: 'haiku', estimated: false };
|
|
48
|
-
if (id.includes('fable')) return { key: 'fable', estimated: false };
|
|
49
|
-
return { key: DEFAULT_PRICING_KEY, estimated: true };
|
|
50
|
-
}
|
|
51
|
-
|
|
52
22
|
// ── LRU cache ─────────────────────────────────────────────────────────────────
|
|
53
23
|
// Shared implementation: lib/util/lruCache.cjs (re-exported below for existing callers).
|
|
54
24
|
const { LRUCache } = require('./lib/util/lruCache.cjs');
|
|
@@ -96,7 +66,10 @@ async function appendRollupAndNotify(entries) {
|
|
|
96
66
|
|
|
97
67
|
/**
|
|
98
68
|
* Cache for parseJSONL results.
|
|
99
|
-
* Entry shape: { mtimeMs: number, size: number, readOffset: number, inode: number,
|
|
69
|
+
* Entry shape: { mtimeMs: number, size: number, readOffset: number, inode: number,
|
|
70
|
+
* recentIds: Map<string, usage>, result: AggrResult }
|
|
71
|
+
* `recentIds` = the last 64 message ids with their counted usage, handed to
|
|
72
|
+
* the next tail parse so a message straddling two reads is counted once.
|
|
100
73
|
* `size` mirrors stat.size (used for exact-hit comparison).
|
|
101
74
|
* `readOffset` is the byte position of the end of the last complete line
|
|
102
75
|
* (≤ size) — the start position for the next tail-read so we never start
|
|
@@ -177,8 +150,17 @@ async function readSlice(filePath, from, to) {
|
|
|
177
150
|
|
|
178
151
|
// ── line scanners ─────────────────────────────────────────────────────────────
|
|
179
152
|
|
|
153
|
+
// cacheCreation1hTokens is the 1-hour part of cacheCreationTokens
|
|
154
|
+
// (usage.cache_creation.ephemeral_1h_input_tokens); it is priced differently
|
|
155
|
+
// from the 5-minute part, so it is kept alongside the sum.
|
|
156
|
+
const USAGE_FIELDS = ['inputTokens', 'outputTokens', 'cacheReadTokens', 'cacheCreationTokens', 'cacheCreation1hTokens'];
|
|
157
|
+
/** How many recent message ids the accumulator (and the cache entry) remembers. */
|
|
158
|
+
const RECENT_IDS_MAX = 64;
|
|
159
|
+
|
|
180
160
|
/**
|
|
181
161
|
* Scan JSONL lines into an aggregate accumulator (mutates acc).
|
|
162
|
+
* acc.recentIds (Map<message.id, counted usage>, created on demand, last
|
|
163
|
+
* RECENT_IDS_MAX ids) makes a repeated message.id count once.
|
|
182
164
|
* Returns { firstTs, lastTs } — firstTs is only captured when
|
|
183
165
|
* captureFirst=true (else null); lastTs is the most recent event timestamp
|
|
184
166
|
* seen in this batch of lines (file order, so simply "last one wins").
|
|
@@ -209,22 +191,48 @@ function scanAggrLines(lines, acc, captureFirst) {
|
|
|
209
191
|
const outT = usage.output_tokens ?? usage.outputTokens;
|
|
210
192
|
const cacheR = usage.cache_read_input_tokens ?? usage.cacheReadInputTokens;
|
|
211
193
|
const cacheC = usage.cache_creation_input_tokens ?? usage.cacheCreationInputTokens;
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
194
|
+
const cacheC1h = usage.cache_creation?.ephemeral_1h_input_tokens;
|
|
195
|
+
const vals = {
|
|
196
|
+
inputTokens: typeof inT === 'number' ? inT : 0,
|
|
197
|
+
outputTokens: typeof outT === 'number' ? outT : 0,
|
|
198
|
+
cacheReadTokens: typeof cacheR === 'number' ? cacheR : 0,
|
|
199
|
+
cacheCreationTokens: typeof cacheC === 'number' ? cacheC : 0,
|
|
200
|
+
cacheCreation1hTokens: typeof cacheC1h === 'number' ? cacheC1h : 0,
|
|
201
|
+
};
|
|
202
|
+
// A transcript writes one line per content block of a message and
|
|
203
|
+
// repeats the message's usage on each (same rule as
|
|
204
|
+
// lib/epic/transcriptUsage.cjs): per message.id, the counted value of
|
|
205
|
+
// each field is the largest seen, so a repeat adds only the increase.
|
|
206
|
+
const msgId = obj.message?.id;
|
|
207
|
+
let add = vals;
|
|
208
|
+
if (typeof msgId === 'string' && msgId) {
|
|
209
|
+
const recent = acc.recentIds ?? (acc.recentIds = new Map());
|
|
210
|
+
const prevVals = recent.get(msgId);
|
|
211
|
+
if (prevVals) {
|
|
212
|
+
add = {};
|
|
213
|
+
const next = {};
|
|
214
|
+
for (const k of USAGE_FIELDS) {
|
|
215
|
+
const prevK = prevVals[k] || 0;
|
|
216
|
+
add[k] = Math.max(0, vals[k] - prevK);
|
|
217
|
+
next[k] = Math.max(vals[k], prevK);
|
|
218
|
+
}
|
|
219
|
+
recent.delete(msgId);
|
|
220
|
+
recent.set(msgId, next);
|
|
221
|
+
} else {
|
|
222
|
+
recent.set(msgId, { ...vals });
|
|
223
|
+
while (recent.size > RECENT_IDS_MAX) recent.delete(recent.keys().next().value);
|
|
224
|
+
}
|
|
225
|
+
}
|
|
226
|
+
for (const k of USAGE_FIELDS) acc[k] = (acc[k] || 0) + add[k];
|
|
216
227
|
|
|
217
228
|
// Only assistant usage lines carry model+usage together in practice;
|
|
218
229
|
// read defensively rather than assuming every usage line has a model.
|
|
219
230
|
const modelId = obj.message?.model;
|
|
220
231
|
if (typeof modelId === 'string' && modelId) {
|
|
221
232
|
const bucket = acc.byModel[modelId] ?? (acc.byModel[modelId] = {
|
|
222
|
-
inputTokens: 0, outputTokens: 0, cacheReadTokens: 0, cacheCreationTokens: 0,
|
|
233
|
+
inputTokens: 0, outputTokens: 0, cacheReadTokens: 0, cacheCreationTokens: 0, cacheCreation1hTokens: 0,
|
|
223
234
|
});
|
|
224
|
-
|
|
225
|
-
if (typeof outT === 'number') bucket.outputTokens += outT;
|
|
226
|
-
if (typeof cacheR === 'number') bucket.cacheReadTokens += cacheR;
|
|
227
|
-
if (typeof cacheC === 'number') bucket.cacheCreationTokens += cacheC;
|
|
235
|
+
for (const k of USAGE_FIELDS) bucket[k] = (bucket[k] || 0) + add[k];
|
|
228
236
|
}
|
|
229
237
|
}
|
|
230
238
|
|
|
@@ -281,6 +289,7 @@ async function parseJSONL(filePath, stat) {
|
|
|
281
289
|
outputTokens: 0,
|
|
282
290
|
cacheReadTokens: 0,
|
|
283
291
|
cacheCreationTokens: 0,
|
|
292
|
+
cacheCreation1hTokens: 0,
|
|
284
293
|
toolCallCount: 0,
|
|
285
294
|
toolBreakdown: {},
|
|
286
295
|
byModel: {},
|
|
@@ -318,6 +327,8 @@ async function parseJSONL(filePath, stat) {
|
|
|
318
327
|
const readFrom = cached.readOffset ?? cached.size;
|
|
319
328
|
const tail = await readSlice(filePath, readFrom, stat.size);
|
|
320
329
|
const delta = emptyAcc();
|
|
330
|
+
// Copy, so a failed tail parse leaves the cached memory untouched.
|
|
331
|
+
delta.recentIds = new Map(cached.recentIds ?? []);
|
|
321
332
|
const { lastTs: deltaLastTs } = scanAggrLines(tail.split('\n'), delta, false);
|
|
322
333
|
const prev = cached.result;
|
|
323
334
|
const merged = {
|
|
@@ -326,6 +337,7 @@ async function parseJSONL(filePath, stat) {
|
|
|
326
337
|
outputTokens: prev.outputTokens + delta.outputTokens,
|
|
327
338
|
cacheReadTokens: prev.cacheReadTokens + delta.cacheReadTokens,
|
|
328
339
|
cacheCreationTokens: prev.cacheCreationTokens + delta.cacheCreationTokens,
|
|
340
|
+
cacheCreation1hTokens: (prev.cacheCreation1hTokens || 0) + delta.cacheCreation1hTokens,
|
|
329
341
|
toolCallCount: prev.toolCallCount + delta.toolCallCount,
|
|
330
342
|
toolBreakdown: { ...prev.toolBreakdown },
|
|
331
343
|
byModel: {},
|
|
@@ -343,19 +355,20 @@ async function parseJSONL(filePath, stat) {
|
|
|
343
355
|
}
|
|
344
356
|
for (const [modelId, deltaBucket] of Object.entries(delta.byModel)) {
|
|
345
357
|
const b = merged.byModel[modelId] ?? (merged.byModel[modelId] = {
|
|
346
|
-
inputTokens: 0, outputTokens: 0, cacheReadTokens: 0, cacheCreationTokens: 0,
|
|
358
|
+
inputTokens: 0, outputTokens: 0, cacheReadTokens: 0, cacheCreationTokens: 0, cacheCreation1hTokens: 0,
|
|
347
359
|
});
|
|
348
360
|
b.inputTokens += deltaBucket.inputTokens;
|
|
349
361
|
b.outputTokens += deltaBucket.outputTokens;
|
|
350
362
|
b.cacheReadTokens += deltaBucket.cacheReadTokens;
|
|
351
363
|
b.cacheCreationTokens += deltaBucket.cacheCreationTokens;
|
|
364
|
+
b.cacheCreation1hTokens = (b.cacheCreation1hTokens || 0) + (deltaBucket.cacheCreation1hTokens || 0);
|
|
352
365
|
}
|
|
353
366
|
// readOffset advances to the last complete newline so the next tail
|
|
354
367
|
// always starts at a line boundary. size stays at stat.size so the
|
|
355
368
|
// exact-hit check works correctly on the next call.
|
|
356
369
|
const lastNl = tail.lastIndexOf('\n');
|
|
357
370
|
const readOffset = lastNl >= 0 ? readFrom + lastNl + 1 : readFrom;
|
|
358
|
-
aggrCache.set(filePath, { mtimeMs: stat.mtimeMs, size: stat.size, readOffset, inode: stat.ino, result: merged });
|
|
371
|
+
aggrCache.set(filePath, { mtimeMs: stat.mtimeMs, size: stat.size, readOffset, inode: stat.ino, recentIds: delta.recentIds, result: merged });
|
|
359
372
|
return { result: merged, cacheHit: false };
|
|
360
373
|
} catch {
|
|
361
374
|
// fall through to full parse
|
|
@@ -373,6 +386,9 @@ async function parseJSONL(filePath, stat) {
|
|
|
373
386
|
|
|
374
387
|
const acc = emptyAcc();
|
|
375
388
|
const { firstTs, lastTs } = scanAggrLines(text.split('\n'), acc, true);
|
|
389
|
+
// The id memory lives on the cache entry, not in the returned result.
|
|
390
|
+
const recentIds = acc.recentIds ?? new Map();
|
|
391
|
+
delete acc.recentIds;
|
|
376
392
|
acc.firstEventTs = firstTs;
|
|
377
393
|
acc.lastEventTs = lastTs;
|
|
378
394
|
|
|
@@ -386,7 +402,7 @@ async function parseJSONL(filePath, stat) {
|
|
|
386
402
|
|
|
387
403
|
const lastNlFull = text.lastIndexOf('\n');
|
|
388
404
|
const readOffsetFull = lastNlFull >= 0 ? lastNlFull + 1 : 0;
|
|
389
|
-
aggrCache.set(filePath, { mtimeMs: stat.mtimeMs, size: stat.size, readOffset: readOffsetFull, inode: stat.ino, result: acc });
|
|
405
|
+
aggrCache.set(filePath, { mtimeMs: stat.mtimeMs, size: stat.size, readOffset: readOffsetFull, inode: stat.ino, recentIds, result: acc });
|
|
390
406
|
return { result: acc, cacheHit: false };
|
|
391
407
|
}
|
|
392
408
|
|
|
@@ -405,6 +421,7 @@ function emptyBucket(sessionDate, encodedCwd) {
|
|
|
405
421
|
outputTokens: 0,
|
|
406
422
|
cacheReadTokens: 0,
|
|
407
423
|
cacheCreationTokens: 0,
|
|
424
|
+
cacheCreation1hTokens: 0,
|
|
408
425
|
toolCallCount: 0,
|
|
409
426
|
toolBreakdown: {},
|
|
410
427
|
byModel: {},
|
|
@@ -421,18 +438,20 @@ function foldParsedIntoBucket(b, parsed) {
|
|
|
421
438
|
b.outputTokens += parsed.outputTokens;
|
|
422
439
|
b.cacheReadTokens += parsed.cacheReadTokens;
|
|
423
440
|
b.cacheCreationTokens += parsed.cacheCreationTokens;
|
|
441
|
+
b.cacheCreation1hTokens = (b.cacheCreation1hTokens || 0) + (parsed.cacheCreation1hTokens || 0);
|
|
424
442
|
b.toolCallCount += parsed.toolCallCount;
|
|
425
443
|
for (const [tool, cnt] of Object.entries(parsed.toolBreakdown)) {
|
|
426
444
|
b.toolBreakdown[tool] = (b.toolBreakdown[tool] ?? 0) + cnt;
|
|
427
445
|
}
|
|
428
446
|
for (const [modelId, srcBucket] of Object.entries(parsed.byModel ?? {})) {
|
|
429
447
|
const dst = b.byModel[modelId] ?? (b.byModel[modelId] = {
|
|
430
|
-
inputTokens: 0, outputTokens: 0, cacheReadTokens: 0, cacheCreationTokens: 0,
|
|
448
|
+
inputTokens: 0, outputTokens: 0, cacheReadTokens: 0, cacheCreationTokens: 0, cacheCreation1hTokens: 0,
|
|
431
449
|
});
|
|
432
450
|
dst.inputTokens += srcBucket.inputTokens;
|
|
433
451
|
dst.outputTokens += srcBucket.outputTokens;
|
|
434
452
|
dst.cacheReadTokens += srcBucket.cacheReadTokens;
|
|
435
453
|
dst.cacheCreationTokens += srcBucket.cacheCreationTokens;
|
|
454
|
+
dst.cacheCreation1hTokens = (dst.cacheCreation1hTokens || 0) + (srcBucket.cacheCreation1hTokens || 0);
|
|
436
455
|
}
|
|
437
456
|
b.sessionCount++;
|
|
438
457
|
b.errorCount += parsed.errorCount;
|
|
@@ -467,6 +486,7 @@ function bucketToRollupLines(b) {
|
|
|
467
486
|
outputTokens: mb.outputTokens,
|
|
468
487
|
cacheReadTokens: mb.cacheReadTokens,
|
|
469
488
|
cacheCreationTokens: mb.cacheCreationTokens,
|
|
489
|
+
cacheCreation1hTokens: mb.cacheCreation1hTokens || 0,
|
|
470
490
|
toolCallCount: 0,
|
|
471
491
|
toolBreakdown: {},
|
|
472
492
|
errorCount: 0,
|
|
@@ -516,11 +536,21 @@ function rollupMapToRows(map, finalizedDates) {
|
|
|
516
536
|
} else {
|
|
517
537
|
const dst = row.byModel[bucket.modelId] ?? (row.byModel[bucket.modelId] = {
|
|
518
538
|
inputTokens: 0, outputTokens: 0, cacheReadTokens: 0, cacheCreationTokens: 0,
|
|
539
|
+
cacheCreation1hTokens: 0, cacheCreationUnknownTokens: 0,
|
|
519
540
|
});
|
|
520
541
|
dst.inputTokens += bucket.inputTokens || 0;
|
|
521
542
|
dst.outputTokens += bucket.outputTokens || 0;
|
|
522
543
|
dst.cacheReadTokens += bucket.cacheReadTokens || 0;
|
|
523
544
|
dst.cacheCreationTokens += bucket.cacheCreationTokens || 0;
|
|
545
|
+
// A line written before v4 has no 1-hour split: its cache writes count
|
|
546
|
+
// as unknown (costOfUsage prices them at the 1-hour rate, estimated).
|
|
547
|
+
// Both parts are plain sums, so several lines in one bucket stay right.
|
|
548
|
+
if (typeof bucket.cacheCreation1hTokens === 'number') {
|
|
549
|
+
dst.cacheCreation1hTokens += bucket.cacheCreation1hTokens;
|
|
550
|
+
row.cacheCreation1hTokens += bucket.cacheCreation1hTokens;
|
|
551
|
+
} else {
|
|
552
|
+
dst.cacheCreationUnknownTokens += bucket.cacheCreationTokens || 0;
|
|
553
|
+
}
|
|
524
554
|
row.inputTokens += bucket.inputTokens || 0;
|
|
525
555
|
row.outputTokens += bucket.outputTokens || 0;
|
|
526
556
|
row.cacheReadTokens += bucket.cacheReadTokens || 0;
|
|
@@ -946,17 +976,13 @@ async function aggregate(req) {
|
|
|
946
976
|
const byModel = {};
|
|
947
977
|
let estimatedCostUsd = 0;
|
|
948
978
|
for (const [modelId, bucket] of Object.entries(b.byModel)) {
|
|
949
|
-
|
|
950
|
-
|
|
951
|
-
|
|
952
|
-
|
|
953
|
-
|
|
954
|
-
|
|
955
|
-
|
|
956
|
-
estimatedCostUsd += costUsd;
|
|
957
|
-
// What those cache-read tokens would have cost at the full input rate,
|
|
958
|
-
// minus what they actually cost at the cache rate.
|
|
959
|
-
cacheSavingsUsd += bucket.cacheReadTokens * (pricing.i - pricing.c) / 1e6;
|
|
979
|
+
// Priced by lib/claude/modelPricing.cjs: the exact model's current rate,
|
|
980
|
+
// cache writes split 5-minute / 1-hour; estimated when the model id or
|
|
981
|
+
// the write split is unknown.
|
|
982
|
+
const cost = costOfUsage(modelId, bucket);
|
|
983
|
+
byModel[modelId] = { ...bucket, costUsd: cost.costUsd, ...(cost.estimated ? { estimated: true } : {}) };
|
|
984
|
+
estimatedCostUsd += cost.costUsd;
|
|
985
|
+
cacheSavingsUsd += cost.cacheSavingsUsd;
|
|
960
986
|
}
|
|
961
987
|
return { ...b, byModel, estimatedCostUsd };
|
|
962
988
|
});
|
|
@@ -1023,7 +1049,6 @@ const remote = { aggregate };
|
|
|
1023
1049
|
module.exports = {
|
|
1024
1050
|
registerHistoryAggregatorHandlers,
|
|
1025
1051
|
remote,
|
|
1026
|
-
MODEL_PRICING,
|
|
1027
1052
|
finalizeClosedDays,
|
|
1028
1053
|
decodeCwd,
|
|
1029
1054
|
refreshIntradayToday,
|
|
@@ -1032,10 +1057,11 @@ module.exports = {
|
|
|
1032
1057
|
// exported for tests
|
|
1033
1058
|
scanAggrLines,
|
|
1034
1059
|
parseJSONL,
|
|
1035
|
-
resolvePricingKey,
|
|
1036
1060
|
CACHE_MAX,
|
|
1037
1061
|
LRUCache,
|
|
1038
1062
|
computeActiveMinutes,
|
|
1063
|
+
bucketToRollupLines,
|
|
1064
|
+
rollupMapToRows,
|
|
1039
1065
|
mapWithConcurrency,
|
|
1040
1066
|
resetIntradayRegistryForTests,
|
|
1041
1067
|
INTRADAY_STAT_CONCURRENCY,
|
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
* instantly regardless of transcript corpus size or retention/cleanup.
|
|
6
6
|
*
|
|
7
7
|
* Only imports historyRollup.cjs (the rollup reader) and pure helpers
|
|
8
|
-
* re-exported from historyAggregator.cjs (
|
|
8
|
+
* re-exported from historyAggregator.cjs (date math) plus lib/claude/modelPricing.cjs (cost) — never
|
|
9
9
|
* fs/promises, never PROJECTS_DIR. See historyDashboard.test.cjs's zero-scan
|
|
10
10
|
* guarantee test.
|
|
11
11
|
*/
|
|
@@ -14,12 +14,8 @@
|
|
|
14
14
|
|
|
15
15
|
const { ipcMain } = require('electron');
|
|
16
16
|
const historyRollup = require('./lib/historyRollup.cjs');
|
|
17
|
-
const {
|
|
18
|
-
|
|
19
|
-
resolvePricingKey,
|
|
20
|
-
localDate,
|
|
21
|
-
subtractDays,
|
|
22
|
-
} = require('./historyAggregator.cjs');
|
|
17
|
+
const { localDate, subtractDays } = require('./historyAggregator.cjs');
|
|
18
|
+
const { costOfUsage } = require('./lib/claude/modelPricing.cjs');
|
|
23
19
|
const { schemas } = require('./ipcSchemas.cjs');
|
|
24
20
|
|
|
25
21
|
// Read range start for rangeDays=0 ("all time"). Rollup dates are always
|
|
@@ -58,11 +54,21 @@ function foldBucketIntoRow(row, bucket) {
|
|
|
58
54
|
} else {
|
|
59
55
|
const dst = row.byModel[bucket.modelId] ?? (row.byModel[bucket.modelId] = {
|
|
60
56
|
inputTokens: 0, outputTokens: 0, cacheReadTokens: 0, cacheCreationTokens: 0,
|
|
57
|
+
cacheCreation1hTokens: 0, cacheCreationUnknownTokens: 0,
|
|
61
58
|
});
|
|
62
59
|
dst.inputTokens += bucket.inputTokens || 0;
|
|
63
60
|
dst.outputTokens += bucket.outputTokens || 0;
|
|
64
61
|
dst.cacheReadTokens += bucket.cacheReadTokens || 0;
|
|
65
62
|
dst.cacheCreationTokens += bucket.cacheCreationTokens || 0;
|
|
63
|
+
// A line written before rollup v4 has no 1-hour split: its cache writes
|
|
64
|
+
// count as unknown, which costOfUsage prices at the 1-hour rate and marks
|
|
65
|
+
// estimated. Both parts are plain sums, so a bucket mixing old and new
|
|
66
|
+
// lines (e.g. the previous-period row) stays right.
|
|
67
|
+
if (typeof bucket.cacheCreation1hTokens === 'number') {
|
|
68
|
+
dst.cacheCreation1hTokens += bucket.cacheCreation1hTokens;
|
|
69
|
+
} else {
|
|
70
|
+
dst.cacheCreationUnknownTokens += bucket.cacheCreationTokens || 0;
|
|
71
|
+
}
|
|
66
72
|
row.inputTokens += bucket.inputTokens || 0;
|
|
67
73
|
row.outputTokens += bucket.outputTokens || 0;
|
|
68
74
|
row.cacheReadTokens += bucket.cacheReadTokens || 0;
|
|
@@ -75,12 +81,7 @@ function computeRowCost(row) {
|
|
|
75
81
|
const byModel = {};
|
|
76
82
|
let estimatedCostUsd = 0;
|
|
77
83
|
for (const [modelId, bucket] of Object.entries(row.byModel)) {
|
|
78
|
-
const {
|
|
79
|
-
const pricing = MODEL_PRICING[key];
|
|
80
|
-
const costUsd =
|
|
81
|
-
(bucket.inputTokens + bucket.cacheCreationTokens) * pricing.i / 1e6 +
|
|
82
|
-
bucket.outputTokens * pricing.o / 1e6 +
|
|
83
|
-
bucket.cacheReadTokens * pricing.c / 1e6;
|
|
84
|
+
const { costUsd, estimated } = costOfUsage(modelId, bucket);
|
|
84
85
|
byModel[modelId] = { ...bucket, costUsd, ...(estimated ? { estimated: true } : {}) };
|
|
85
86
|
estimatedCostUsd += costUsd;
|
|
86
87
|
}
|
|
@@ -197,6 +198,9 @@ async function computeDashboard(req) {
|
|
|
197
198
|
addRowToTotals(prevTotals, computeRowCost(prevRow));
|
|
198
199
|
|
|
199
200
|
const provisionalDates = sortedDates.filter((d) => !finalizedDates.has(d));
|
|
201
|
+
// Days finalized under an older ROLLUP_VERSION that the finalize pass could
|
|
202
|
+
// not recount (transcripts gone) — their rows are still served as-is.
|
|
203
|
+
const legacyDates = historyRollup.legacyFinalizedDates(map).filter((d) => d >= from && d <= to);
|
|
200
204
|
|
|
201
205
|
return {
|
|
202
206
|
from,
|
|
@@ -209,6 +213,7 @@ async function computeDashboard(req) {
|
|
|
209
213
|
toolsByProject,
|
|
210
214
|
generatedAt: Date.now(),
|
|
211
215
|
provisionalDates,
|
|
216
|
+
legacyDates,
|
|
212
217
|
};
|
|
213
218
|
}
|
|
214
219
|
|
package/src/main/index.cjs
CHANGED
|
@@ -102,6 +102,15 @@ macroAdminRoutes.registerAdminRoute(adminHttp, {
|
|
|
102
102
|
isTabBusy: chatRunner.isTabBusy,
|
|
103
103
|
});
|
|
104
104
|
chatRunner.registerAdminRoute(adminHttp);
|
|
105
|
+
// Outside apps' "Needs you" items (lib/feedback-remote/needsYouStore.cjs); changes broadcast `needsYou:changed`.
|
|
106
|
+
function broadcastNeedsYouChanged() {
|
|
107
|
+
sendIfAlive(mainWindow, 'needsYou:changed', {});
|
|
108
|
+
}
|
|
109
|
+
require('./lib/feedback-remote/needsYouAdminRoutes.cjs').registerAdminRoute(adminHttp, {
|
|
110
|
+
onChanged: broadcastNeedsYouChanged,
|
|
111
|
+
});
|
|
112
|
+
// The Dashboard's side: list open items + record the owner's answer (same broadcast).
|
|
113
|
+
require('./lib/feedback-remote/needsYouIpc.cjs').registerNeedsYouIpc({ ipcMain, onChanged: broadcastNeedsYouChanged });
|
|
105
114
|
// Project-to-project feedback conduit — the app is the only process holding
|
|
106
115
|
// several projects' operations roots open, so it performs the cross-folder
|
|
107
116
|
// write (lib/feedback-remote/crossProjectFeedback.cjs).
|
|
@@ -110,6 +119,17 @@ crossProjectFeedback.registerAdminRoute(adminHttp);
|
|
|
110
119
|
// (lib/feedback-remote/crossProjectReply.cjs).
|
|
111
120
|
require('./lib/feedback-remote/crossProjectReply.cjs').registerAdminRoute(adminHttp);
|
|
112
121
|
require('./lib/feedback-remote/customerFeedbackAdminRoutes.cjs').registerAdminRoute(adminHttp);
|
|
122
|
+
// Cursor read over the audit log for outside scripts (read-only).
|
|
123
|
+
require('./lib/telemetry/eventsAdminRoutes.cjs').registerAdminRoute(adminHttp);
|
|
124
|
+
// Outside-facing Epic records for scripts/other projects (read-only).
|
|
125
|
+
require('./lib/epic/epicAdminRoutes.cjs').registerAdminRoute(adminHttp, {
|
|
126
|
+
isTabBusy: chatRunner.isTabBusy,
|
|
127
|
+
listJobs: () => scheduler.remote.listJobs(),
|
|
128
|
+
});
|
|
129
|
+
// Persona roster + per-project effective model/effort for outside apps (read-only).
|
|
130
|
+
require('./lib/persona-macro/agentAdminRoutes.cjs').registerAdminRoute(adminHttp);
|
|
131
|
+
// The scheduler tick turns Epic state changes into epic_state_changed audit rows.
|
|
132
|
+
require('./lib/epic/epicStateWatcher.cjs').configureEpicStateWatcher({ isTabBusy: chatRunner.isTabBusy });
|
|
113
133
|
const supervisor = require('./supervisor.cjs');
|
|
114
134
|
const watchers = require('./watchers.cjs');
|
|
115
135
|
const queueOps = require('./queueOps.cjs');
|
|
@@ -1114,8 +1134,8 @@ ipcMain.handle('epicDelegationStats:get', validated(schemas.epicDelegationStatsG
|
|
|
1114
1134
|
}));
|
|
1115
1135
|
// Renderer Epic lifecycle trace (PRD 940) — append-only, no read/list IPC.
|
|
1116
1136
|
// Kind allowlist enforced by schemas.auditLogAppend, not here.
|
|
1117
|
-
ipcMain.handle('auditLog:append', validated(schemas.auditLogAppend, async ({ kind, cwd, epicId, source }) => {
|
|
1118
|
-
appendAuditEvent(kind, { cwd, epicId, source });
|
|
1137
|
+
ipcMain.handle('auditLog:append', validated(schemas.auditLogAppend, async ({ kind, cwd, epicId, source, fromEpicId }) => {
|
|
1138
|
+
appendAuditEvent(kind, { cwd, epicId, source, ...(fromEpicId ? { fromEpicId } : {}) });
|
|
1119
1139
|
return { ok: true };
|
|
1120
1140
|
}));
|
|
1121
1141
|
git.register(ipcMain);
|
package/src/main/ipcSchemas.cjs
CHANGED
|
@@ -585,11 +585,61 @@ const adminListPrdsQuery = z.object({
|
|
|
585
585
|
fields: z.enum(['compact', 'full']).optional().default('compact'),
|
|
586
586
|
});
|
|
587
587
|
|
|
588
|
+
// GET /admin/events (lib/telemetry/eventsAdminRoutes.cjs) — cursor read over the
|
|
589
|
+
// audit log. `after` is checked by readEventsAfter itself (the route maps its
|
|
590
|
+
// rejection to the same 400); `kinds` is a comma-separated list, each entry one
|
|
591
|
+
// of auditEvents.cjs's OUTSIDE_EVENT_KINDS; `limit` 1..500 (default applied by
|
|
592
|
+
// readEventsAfter when absent).
|
|
593
|
+
const OUTSIDE_EVENT_KIND_ENUM = z.enum(/** @type {[string, ...string[]]} */ ([...require('./lib/telemetry/auditEvents.cjs').OUTSIDE_EVENT_KINDS]));
|
|
594
|
+
const adminListEventsQuery = z.object({
|
|
595
|
+
after: z.string().max(200).optional(),
|
|
596
|
+
kinds: z.string().min(1).max(1000)
|
|
597
|
+
.transform((v) => v.split(',').map((k) => k.trim()))
|
|
598
|
+
.pipe(z.array(OUTSIDE_EVENT_KIND_ENUM).min(1))
|
|
599
|
+
.optional(),
|
|
600
|
+
limit: z.coerce.number().int().min(1).max(500).optional(),
|
|
601
|
+
});
|
|
602
|
+
|
|
588
603
|
const adminGetPrdQuery = z.object({
|
|
589
604
|
slug: z.string().regex(SCHEDULE_SLUG_RE),
|
|
590
605
|
cwd: z.string().min(1).max(4096).optional(),
|
|
591
606
|
});
|
|
592
607
|
|
|
608
|
+
// GET /admin/epics + /admin/epic (lib/epic/epicAdminRoutes.cjs) — read-only
|
|
609
|
+
// outside-facing Epic records (lib/epic/epicOutsideRead.cjs). Query strings
|
|
610
|
+
// arrive as text, so limit/offset coerce before the int/range checks.
|
|
611
|
+
const EPIC_OUTSIDE_STATE_ENUM = z.enum(/** @type {[string, ...string[]]} */ ([...require('./lib/epic/epicOutsideState.cjs').EPIC_OUTSIDE_STATES]));
|
|
612
|
+
const adminListEpicsQuery = z.object({
|
|
613
|
+
cwd: z.string().min(1).max(4096),
|
|
614
|
+
state: EPIC_OUTSIDE_STATE_ENUM.optional(),
|
|
615
|
+
limit: z.coerce.number().int().min(1).max(200).optional().default(50),
|
|
616
|
+
offset: z.coerce.number().int().min(0).optional().default(0),
|
|
617
|
+
});
|
|
618
|
+
|
|
619
|
+
// GET /admin/agents (lib/persona-macro/agentAdminRoutes.cjs) — read-only
|
|
620
|
+
// persona roster; an optional cwd adds each persona's effective model/effort.
|
|
621
|
+
const adminListAgentsQuery = z.object({
|
|
622
|
+
cwd: z.string().min(1).max(4096).optional(),
|
|
623
|
+
});
|
|
624
|
+
|
|
625
|
+
const adminGetEpicQuery = z.object({
|
|
626
|
+
cwd: z.string().min(1).max(4096),
|
|
627
|
+
id: z.string().min(1).max(200).optional(),
|
|
628
|
+
externalRef: z.string().max(1000).optional().transform((v, ctx) => {
|
|
629
|
+
if (v === undefined) return undefined;
|
|
630
|
+
const r = require('./lib/epic/externalRef.cjs').normalizeExternalRef(v);
|
|
631
|
+
if (!r.ok) {
|
|
632
|
+
ctx.addIssue({ code: z.ZodIssueCode.custom, message: r.error });
|
|
633
|
+
return z.NEVER;
|
|
634
|
+
}
|
|
635
|
+
return r.value;
|
|
636
|
+
}),
|
|
637
|
+
// Opt-in cost receipt: only the query values '1' and 'true' turn it on.
|
|
638
|
+
receipt: z.string().max(10).optional().transform((v) => v === '1' || v === 'true'),
|
|
639
|
+
}).refine((v) => (v.id === undefined) !== (v.externalRef === undefined), {
|
|
640
|
+
message: 'exactly one of id or externalRef is required',
|
|
641
|
+
});
|
|
642
|
+
|
|
593
643
|
// Partial frontmatter patch for update-prd — same recognized-key set as
|
|
594
644
|
// prdFrontmatter.cjs's parsePrdFile/serializePrdFile round-trip pair. Every
|
|
595
645
|
// field optional; the route refuses an empty patch+no-body request via the
|
|
@@ -761,6 +811,14 @@ const macrosDispatchJob = z.object({
|
|
|
761
811
|
effort: z.enum(/** @type {[string, ...string[]]} */ ([...PRD_EFFORT_LEVELS])).optional(),
|
|
762
812
|
});
|
|
763
813
|
const macrosJobStatus = z.object({ cwd: z.string().min(1).max(4096) });
|
|
814
|
+
// Dashboard "Needs you" (lib/feedback-remote/needsYouIpc.cjs): list takes no payload; answer
|
|
815
|
+
// names one item + the chosen option. needsYouStore.cjs re-validates app/id and the option.
|
|
816
|
+
const needsYouList = z.object({}).strict().optional();
|
|
817
|
+
const needsYouAnswer = z.object({
|
|
818
|
+
app: z.string().min(1).max(40),
|
|
819
|
+
id: z.string().min(1).max(200),
|
|
820
|
+
answer: z.string().min(1).max(80),
|
|
821
|
+
}).strict();
|
|
764
822
|
|
|
765
823
|
// ──────────────────────────────────────────── Memory tool (Bundle C, cycle 3)
|
|
766
824
|
// Workspace-scoped markdown store at ~/.claude/projects/<ws>/memory/.
|
|
@@ -824,7 +882,7 @@ const memoryStale = z.object({
|
|
|
824
882
|
agent: MEMORY_AGENT,
|
|
825
883
|
}).strict();
|
|
826
884
|
|
|
827
|
-
// memory:verify/archive/restore/listArchived
|
|
885
|
+
// memory:verify/archive/restore/listArchived — Memory Explorer actions (ask/proposeFix wrap memoryNamed below).
|
|
828
886
|
const memoryNamed = z.object({
|
|
829
887
|
workspace: z.string().regex(MEMORY_WORKSPACE_RE).optional(),
|
|
830
888
|
name: z.string().regex(MEMORY_SLUG_RE),
|
|
@@ -834,15 +892,38 @@ const memoryNamed = z.object({
|
|
|
834
892
|
const memoryVerify = memoryNamed;
|
|
835
893
|
const memoryArchive = memoryNamed;
|
|
836
894
|
const memoryRestore = memoryNamed;
|
|
837
|
-
const memoryProposeFix = memoryNamed;
|
|
838
895
|
const memoryListArchived = memoryList;
|
|
839
|
-
|
|
896
|
+
|
|
897
|
+
// memory:ask / memory:proposeFix receive the renderer's raw single object
|
|
898
|
+
// ({ question|name, target, contextName? }) from BOTH the Electron preload and
|
|
899
|
+
// the relay remote (remoteApi.ts forwards positionally). Flatten `target`'s
|
|
900
|
+
// truthy addressing keys onto the top level (target wins) and drop a falsy
|
|
901
|
+
// contextName, so askMemory/proposeFix see the same flat payload as before.
|
|
902
|
+
// A target carrying any other key (or a non-object target) is left in place
|
|
903
|
+
// so the inner .strict() schema rejects it.
|
|
904
|
+
const MEMORY_TARGET_KEYS = ['workspace', 'cwd', 'agent'];
|
|
905
|
+
/** @param {unknown} input */
|
|
906
|
+
function flattenMemoryTarget(input) {
|
|
907
|
+
if (!input || typeof input !== 'object' || Array.isArray(input)) return input;
|
|
908
|
+
const { target, ...rest } = /** @type {Record<string, unknown>} */ (input);
|
|
909
|
+
if (!rest.contextName) delete rest.contextName;
|
|
910
|
+
if (target === undefined || target === null) return rest;
|
|
911
|
+
if (typeof target !== 'object' || Array.isArray(target)
|
|
912
|
+
|| Object.keys(target).some((k) => !MEMORY_TARGET_KEYS.includes(k))) {
|
|
913
|
+
return { ...rest, target };
|
|
914
|
+
}
|
|
915
|
+
const t = /** @type {Record<string, unknown>} */ (target);
|
|
916
|
+
for (const k of MEMORY_TARGET_KEYS) if (t[k]) rest[k] = t[k];
|
|
917
|
+
return rest;
|
|
918
|
+
}
|
|
919
|
+
const memoryProposeFix = z.preprocess(flattenMemoryTarget, memoryNamed);
|
|
920
|
+
const memoryAsk = z.preprocess(flattenMemoryTarget, z.object({
|
|
840
921
|
workspace: z.string().regex(MEMORY_WORKSPACE_RE).optional(),
|
|
841
922
|
question: z.string().min(1).max(4000),
|
|
842
923
|
contextName: z.string().regex(MEMORY_SLUG_RE).optional(),
|
|
843
924
|
cwd: MEMORY_CWD,
|
|
844
925
|
agent: MEMORY_AGENT,
|
|
845
|
-
}).strict();
|
|
926
|
+
}).strict());
|
|
846
927
|
|
|
847
928
|
const memoryAgents = z.object({
|
|
848
929
|
cwd: MEMORY_CWD,
|
|
@@ -1086,7 +1167,7 @@ const epicDelegationStatsGet = z.object({
|
|
|
1086
1167
|
|
|
1087
1168
|
// ──────────────────────────────────────────── Audit log (renderer Epic
|
|
1088
1169
|
// lifecycle trace, PRD 940). Kind allowlist is enforced HERE, main-side — the
|
|
1089
|
-
// renderer cannot write arbitrary kinds through this channel, only the
|
|
1170
|
+
// renderer cannot write arbitrary kinds through this channel, only the
|
|
1090
1171
|
// Epic lifecycle transitions it emits from promptSessions.ts.
|
|
1091
1172
|
const AUDIT_LOG_KIND = z.enum([
|
|
1092
1173
|
'epic_create',
|
|
@@ -1096,12 +1177,15 @@ const AUDIT_LOG_KIND = z.enum([
|
|
|
1096
1177
|
'epic_resume',
|
|
1097
1178
|
'epic_duplicate',
|
|
1098
1179
|
'epic_draft_update',
|
|
1180
|
+
'epic_continue',
|
|
1099
1181
|
]);
|
|
1100
1182
|
const auditLogAppend = z.object({
|
|
1101
1183
|
kind: AUDIT_LOG_KIND,
|
|
1102
1184
|
cwd: z.string().min(1).max(4096),
|
|
1103
1185
|
epicId: z.string().min(1).max(256),
|
|
1104
1186
|
source: z.string().min(1).max(256),
|
|
1187
|
+
/** epic_continue only: the Epic the new session continues from. */
|
|
1188
|
+
fromEpicId: z.string().min(1).max(256).optional(),
|
|
1105
1189
|
}).strict();
|
|
1106
1190
|
|
|
1107
1191
|
// ──────────────────────────────────────────── Exchanges (PRD 324 read path)
|
|
@@ -1195,6 +1279,28 @@ const chatExternalSend = z.object({
|
|
|
1195
1279
|
),
|
|
1196
1280
|
});
|
|
1197
1281
|
|
|
1282
|
+
// Phone remote's cmd:chat:send — chatExternalSend plus up to 6 images (saved
|
|
1283
|
+
// as Epic attachments by epicAttachments.cjs). Prompt may be empty when at
|
|
1284
|
+
// least one image is sent. Deep validation (magic bytes, decoded size) is
|
|
1285
|
+
// saveChatImages' job; this bounds the wire shape.
|
|
1286
|
+
const remoteChatImage = z.object({
|
|
1287
|
+
name: z.string().min(1).max(128),
|
|
1288
|
+
mime: z.enum(['image/png', 'image/jpeg', 'image/gif', 'image/webp']),
|
|
1289
|
+
data: z.string().min(1).max(4200000),
|
|
1290
|
+
});
|
|
1291
|
+
|
|
1292
|
+
const remoteChatSend = z.object({
|
|
1293
|
+
tabId: z.string().min(1).max(128),
|
|
1294
|
+
prompt: z.string().refine(
|
|
1295
|
+
(s) => Buffer.byteLength(s, 'utf8') <= CHAT_PROMPT_MAX_BYTES,
|
|
1296
|
+
`prompt must be ≤ ${CHAT_PROMPT_MAX_BYTES} bytes`,
|
|
1297
|
+
),
|
|
1298
|
+
images: z.array(remoteChatImage).max(6).optional(),
|
|
1299
|
+
}).refine(
|
|
1300
|
+
(v) => v.prompt.trim().length > 0 || (Array.isArray(v.images) && v.images.length > 0),
|
|
1301
|
+
{ message: 'prompt or at least one image is required', path: ['prompt'] },
|
|
1302
|
+
);
|
|
1303
|
+
|
|
1198
1304
|
// Renderer's report of what it did with a `chat:external-send` (mirrors
|
|
1199
1305
|
// ChatExternalSendResult in preload/api.d.ts).
|
|
1200
1306
|
const chatExternalSendResult = z.object({
|
|
@@ -1407,6 +1513,8 @@ const customerFeedbackSubmit = z.object({
|
|
|
1407
1513
|
title: z.string().max(120),
|
|
1408
1514
|
body: z.string().max(4000),
|
|
1409
1515
|
tag: z.enum(['bug', 'feature', 'discussion']),
|
|
1516
|
+
images: z.array(z.object({ dataUrl: z.string().max(35_000_000) })).max(5).optional(),
|
|
1517
|
+
imagePaths: z.array(z.string().max(4096)).max(5).optional(),
|
|
1410
1518
|
});
|
|
1411
1519
|
const customerFeedbackMarkSeen = z.object({ ids: z.array(z.string().max(200)).max(500).optional() });
|
|
1412
1520
|
const customerFeedbackInboxList = z.object({ includeHidden: z.boolean().optional() });
|
|
@@ -1416,6 +1524,7 @@ const customerFeedbackInboxSetStatus = z.object({
|
|
|
1416
1524
|
note: z.string().max(500).optional(),
|
|
1417
1525
|
});
|
|
1418
1526
|
const customerFeedbackInboxLinkEpic = z.object({ id: z.string().max(200), epicId: z.string().max(200) });
|
|
1527
|
+
const customerFeedbackInboxImage = z.object({ id: z.string().min(1).max(200), index: z.number().int().min(0).max(4) }).strict();
|
|
1419
1528
|
|
|
1420
1529
|
/**
|
|
1421
1530
|
* Wrap an IPC handler with schema validation. Returns a new handler that
|
|
@@ -1549,7 +1658,11 @@ module.exports = {
|
|
|
1549
1658
|
scheduleArchivePrd,
|
|
1550
1659
|
scheduleRetagPrd,
|
|
1551
1660
|
adminListPrdsQuery,
|
|
1661
|
+
adminListEventsQuery,
|
|
1552
1662
|
adminGetPrdQuery,
|
|
1663
|
+
adminListEpicsQuery,
|
|
1664
|
+
adminGetEpicQuery,
|
|
1665
|
+
adminListAgentsQuery,
|
|
1553
1666
|
adminUpdatePrd,
|
|
1554
1667
|
adminCancelJob,
|
|
1555
1668
|
setConfigSchema,
|
|
@@ -1630,6 +1743,7 @@ module.exports = {
|
|
|
1630
1743
|
chatCancel,
|
|
1631
1744
|
chatClassifyTicket,
|
|
1632
1745
|
chatExternalSend,
|
|
1746
|
+
remoteChatSend,
|
|
1633
1747
|
chatExternalSendResult,
|
|
1634
1748
|
chatExternalNewSessionResult,
|
|
1635
1749
|
remoteSessionCreate,
|
|
@@ -1649,6 +1763,8 @@ module.exports = {
|
|
|
1649
1763
|
macrosRemoveFromProject,
|
|
1650
1764
|
macrosDispatchJob,
|
|
1651
1765
|
macrosJobStatus,
|
|
1766
|
+
needsYouList,
|
|
1767
|
+
needsYouAnswer,
|
|
1652
1768
|
agentsGetPersonaBody,
|
|
1653
1769
|
agentsResolveModelInfo,
|
|
1654
1770
|
modelsCatalog,
|
|
@@ -1662,6 +1778,7 @@ module.exports = {
|
|
|
1662
1778
|
customerFeedbackInboxList,
|
|
1663
1779
|
customerFeedbackInboxSetStatus,
|
|
1664
1780
|
customerFeedbackInboxLinkEpic,
|
|
1781
|
+
customerFeedbackInboxImage,
|
|
1665
1782
|
},
|
|
1666
1783
|
validated,
|
|
1667
1784
|
};
|
|
@@ -309,8 +309,8 @@ async function resolveEffectiveModelInfo({ cwd, agentType, deps = {} } = {}) {
|
|
|
309
309
|
// Agentless: no per-agent evidence to look up (it would match every agentless job).
|
|
310
310
|
if (!agentType) return result;
|
|
311
311
|
|
|
312
|
-
// Evidence is never derived via
|
|
313
|
-
// (which
|
|
312
|
+
// Evidence is never derived via lib/claude/modelPricing.cjs's priceForModel
|
|
313
|
+
// (which prices any unknown id at a family fallback with estimated:true) —
|
|
314
314
|
// deliberately: that is a pricing heuristic, and borrowing it here would
|
|
315
315
|
// turn "we don't know" into a confident wrong answer.
|
|
316
316
|
const schedulerHit = findLatestSchedulerModel(normalizedCwd, agentType, deps);
|