@qvac/core 0.2.2 → 0.3.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/skills/compaction/SKILL.md +15 -11
- package/.claude/skills/js-house-style/SKILL.md +1 -0
- package/.claude/skills/pr-create/SKILL.md +42 -0
- package/.claude/skills/pr-review/SKILL.md +4 -0
- package/.claude/skills/release/SKILL.md +122 -0
- package/CLAUDE.md +7 -2
- package/dist-lib/lib/api/agents.js +2 -3
- package/dist-lib/lib/api/chat.js +3 -3
- package/dist-lib/lib/api/chunks.d.ts +1 -1
- package/dist-lib/lib/api/chunks.js +5 -15
- package/dist-lib/lib/api/current-mesh.d.ts +16 -1
- package/dist-lib/lib/api/current-mesh.js +18 -0
- package/dist-lib/lib/api/devices.js +6 -3
- package/dist-lib/lib/api/index.js +1 -1
- package/dist-lib/lib/api/knowledge.js +11 -7
- package/dist-lib/lib/api/members.js +2 -3
- package/dist-lib/lib/api/sync.d.ts +1 -1
- package/dist-lib/lib/api/sync.js +2 -1
- package/dist-lib/lib/api/tool-activity.js +2 -2
- package/dist-lib/lib/api/tool-configs.js +2 -2
- package/dist-lib/lib/api/watchable.d.ts +6 -1
- package/dist-lib/lib/api/watchable.js +13 -2
- package/dist-lib/lib/assistant/history.d.ts +1 -2
- package/dist-lib/lib/assistant/history.js +0 -6
- package/dist-lib/lib/assistant.d.ts +3 -7
- package/dist-lib/lib/assistant.js +65 -110
- package/dist-lib/lib/core/chunk.d.ts +1 -0
- package/dist-lib/lib/core/chunk.js +27 -0
- package/dist-lib/lib/core/contract/devices.js +3 -2
- package/dist-lib/lib/core/harness-loan.js +1 -1
- package/dist-lib/lib/core/local/index.js +6 -0
- package/dist-lib/lib/core.d.ts +1 -0
- package/dist-lib/lib/core.js +20 -12
- package/dist-lib/lib/fs-drive-bridge.js +1 -1
- package/dist-lib/lib/mesh-scoped-engine.js +5 -0
- package/dist-lib/lib/model-download.d.ts +2 -0
- package/dist-lib/lib/model-download.js +20 -5
- package/dist-lib/lib/oauth/keys.js +1 -0
- package/dist-lib/lib/oauth/spotify.js +1 -0
- package/dist-lib/lib/oauth/verify.d.ts +8 -0
- package/dist-lib/lib/oauth/verify.js +58 -0
- package/dist-lib/lib/oauth.d.ts +1 -0
- package/dist-lib/lib/oauth.js +1 -0
- package/dist-lib/schema/qvac.d.ts +3 -0
- package/dist-lib/schema/qvac.js +7 -0
- package/package.json +4 -4
- package/tui/app.mjs +327 -46
- package/tui/lib/render.mjs +17 -1
- package/tui/lib/selection.mjs +16 -0
- package/tui/lib/usage.mjs +54 -0
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
// What the run itself reported, and nothing counted here: `ctxSize` is the window the device
|
|
2
|
+
// that ran the turn had loaded, `cacheTokens` the SDK's occupancy reading, `usage` the
|
|
3
|
+
// harness's attribution of the prompt it sent (docs/decisions in @qvac/harness).
|
|
4
|
+
const PROMPT_ROWS = [
|
|
5
|
+
['systemPrompt', 'System prompt'],
|
|
6
|
+
['agentInstructions', 'Agent instructions'],
|
|
7
|
+
['activeSkills', 'Active skills'],
|
|
8
|
+
['tools', 'Tools']
|
|
9
|
+
]
|
|
10
|
+
|
|
11
|
+
export function usageReport(statuses, folds = []) {
|
|
12
|
+
// one row per run, its latest status — as turnsFromChunks reads them — so a run can never count twice
|
|
13
|
+
const latest = new Map()
|
|
14
|
+
for (const chunk of statuses) latest.set(chunk.runId, chunk)
|
|
15
|
+
const completed = [...latest.values()].filter(
|
|
16
|
+
(chunk) => chunk.runStatus?.state === 'completed' && chunk.runStatus.metrics
|
|
17
|
+
)
|
|
18
|
+
if (!completed.length) return null
|
|
19
|
+
const last = completed[completed.length - 1]
|
|
20
|
+
const metrics = last.runStatus.metrics
|
|
21
|
+
return {
|
|
22
|
+
runs: completed.length,
|
|
23
|
+
generated: completed.reduce(
|
|
24
|
+
(sum, chunk) => sum + (chunk.runStatus.metrics.totalTokens ?? 0),
|
|
25
|
+
0
|
|
26
|
+
),
|
|
27
|
+
folds: folds.length,
|
|
28
|
+
window: metrics.ctxSize ?? null,
|
|
29
|
+
occupied: metrics.cacheTokens ?? null,
|
|
30
|
+
rows: promptRows(metrics.usage, metrics.cacheTokens),
|
|
31
|
+
last: {
|
|
32
|
+
deviceId: last.originDeviceId?.toString('hex') ?? null,
|
|
33
|
+
totalTokens: metrics.totalTokens ?? null,
|
|
34
|
+
tokensPerSecond: metrics.tokensPerSecond ?? null,
|
|
35
|
+
timeToFirstToken: metrics.timeToFirstToken ?? null,
|
|
36
|
+
stopReason: metrics.stopReason ?? null
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
// Conversation is the remainder of the occupancy once the reported prompt rows are taken out,
|
|
42
|
+
// so a cost no row authors — the template's turn wrappers, the reply just generated — lands on
|
|
43
|
+
// the turns rather than skewing a prompt row; the rows shrink to fit when they exceed it.
|
|
44
|
+
function promptRows(usage, occupied) {
|
|
45
|
+
if (!usage || !occupied) return null
|
|
46
|
+
const reported = PROMPT_ROWS.reduce((sum, [key]) => sum + usage[key], 0)
|
|
47
|
+
const scale = reported > occupied ? occupied / reported : 1
|
|
48
|
+
const rows = PROMPT_ROWS.map(([key, label]) => ({
|
|
49
|
+
label,
|
|
50
|
+
tokens: Math.floor(usage[key] * scale)
|
|
51
|
+
}))
|
|
52
|
+
const known = rows.reduce((sum, row) => sum + row.tokens, 0)
|
|
53
|
+
return [{ label: 'Conversation', tokens: occupied - known }, ...rows]
|
|
54
|
+
}
|