@ashlr/hub 3.8.0 → 3.9.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/CHANGELOG.md +201 -0
- package/dist/build-identity.json +2 -2
- package/dist/cli/resource-profile.js +95 -21
- package/dist/cli/resource-profile.js.map +1 -1
- package/dist/core/resources/native-profile.d.ts +56 -0
- package/dist/core/resources/native-profile.js +368 -6
- package/dist/core/resources/native-profile.js.map +1 -1
- package/dist/core/run/model-catalog.js +8 -1
- package/dist/core/run/model-catalog.js.map +1 -1
- package/dist/core/universe/builtins/preparation/manifest.json +1 -1
- package/dist/core/universe/builtins/preparation/preparation-bridge.mjs +9 -2
- package/dist/core/universe/builtins/preparation/preparation-verification-fixtures.mjs +8 -1
- package/dist/core/verse/adapters/claude.d.ts +49 -2
- package/dist/core/verse/adapters/claude.js +317 -56
- package/dist/core/verse/adapters/claude.js.map +1 -1
- package/dist/core/verse/adapters/codex.d.ts +81 -5
- package/dist/core/verse/adapters/codex.js +409 -47
- package/dist/core/verse/adapters/codex.js.map +1 -1
- package/dist/core/verse/adapters/grok.d.ts +13 -1
- package/dist/core/verse/adapters/grok.js +28 -2
- package/dist/core/verse/adapters/grok.js.map +1 -1
- package/dist/core/verse/adapters/index.d.ts +32 -0
- package/dist/core/verse/adapters/index.js +2 -0
- package/dist/core/verse/adapters/index.js.map +1 -1
- package/dist/core/verse/codex-rollout.d.ts +284 -0
- package/dist/core/verse/codex-rollout.js +786 -0
- package/dist/core/verse/codex-rollout.js.map +1 -0
- package/dist/core/verse/context-fit.d.ts +63 -0
- package/dist/core/verse/context-fit.js +355 -0
- package/dist/core/verse/context-fit.js.map +1 -0
- package/dist/core/verse/context-math.d.ts +215 -0
- package/dist/core/verse/context-math.js +365 -0
- package/dist/core/verse/context-math.js.map +1 -0
- package/dist/core/verse/local-models.d.ts +137 -1
- package/dist/core/verse/local-models.js +209 -5
- package/dist/core/verse/local-models.js.map +1 -1
- package/dist/core/verse/model-windows.d.ts +217 -0
- package/dist/core/verse/model-windows.js +616 -0
- package/dist/core/verse/model-windows.js.map +1 -0
- package/dist/core/verse/preferences.d.ts +123 -0
- package/dist/core/verse/preferences.js +403 -0
- package/dist/core/verse/preferences.js.map +1 -0
- package/dist/core/verse/project-memory.d.ts +112 -0
- package/dist/core/verse/project-memory.js +295 -0
- package/dist/core/verse/project-memory.js.map +1 -0
- package/dist/core/verse/seats.d.ts +106 -4
- package/dist/core/verse/seats.js +291 -89
- package/dist/core/verse/seats.js.map +1 -1
- package/dist/core/verse/session-engine.d.ts +76 -2
- package/dist/core/verse/session-engine.js +684 -63
- package/dist/core/verse/session-engine.js.map +1 -1
- package/dist/core/verse/session-handoff.d.ts +94 -0
- package/dist/core/verse/session-handoff.js +551 -0
- package/dist/core/verse/session-handoff.js.map +1 -0
- package/dist/core/verse/session-search.d.ts +63 -0
- package/dist/core/verse/session-search.js +213 -0
- package/dist/core/verse/session-search.js.map +1 -0
- package/dist/core/verse/session-store.d.ts +16 -2
- package/dist/core/verse/session-store.js +80 -6
- package/dist/core/verse/session-store.js.map +1 -1
- package/dist/core/verse/types.d.ts +333 -1
- package/dist/core/verse/types.js +54 -2
- package/dist/core/verse/types.js.map +1 -1
- package/dist/core/verse/verse-api.d.ts +40 -5
- package/dist/core/verse/verse-api.js +724 -25
- package/dist/core/verse/verse-api.js.map +1 -1
- package/dist/core/web/api.d.ts +14 -4
- package/dist/core/web/api.js +26 -11
- package/dist/core/web/api.js.map +1 -1
- package/dist/core/web/public/next/assets/{App-BsbJFA2j.js → App-XURmiAAp.js} +5 -5
- package/dist/core/web/public/next/assets/{App-BsbJFA2j.js.map → App-XURmiAAp.js.map} +1 -1
- package/dist/core/web/public/next/assets/{ApprovalsSection-2CCSoBTJ.js → ApprovalsSection-BriUzoZc.js} +2 -2
- package/dist/core/web/public/next/assets/{ApprovalsSection-2CCSoBTJ.js.map → ApprovalsSection-BriUzoZc.js.map} +1 -1
- package/dist/core/web/public/next/assets/AutonomySection-C4GBsQVc.js +2 -0
- package/dist/core/web/public/next/assets/{AutonomySection-yeNNUPur.js.map → AutonomySection-C4GBsQVc.js.map} +1 -1
- package/dist/core/web/public/next/assets/ChatSection-BpOBOUvg.css +1 -0
- package/dist/core/web/public/next/assets/ChatSection-hlgPBRco.js +84 -0
- package/dist/core/web/public/next/assets/ChatSection-hlgPBRco.js.map +1 -0
- package/dist/core/web/public/next/assets/ConfirmDialog-BdQYI-Ng.js +2 -0
- package/dist/core/web/public/next/assets/ConfirmDialog-BdQYI-Ng.js.map +1 -0
- package/dist/core/web/public/next/assets/{Dialog-nK15L1M0.js → Dialog-BxdIfmFH.js} +2 -2
- package/dist/core/web/public/next/assets/{Dialog-nK15L1M0.js.map → Dialog-BxdIfmFH.js.map} +1 -1
- package/dist/core/web/public/next/assets/{DiffViewer-D369eZe8.js → DiffViewer-DmeRWuc4.js} +2 -2
- package/dist/core/web/public/next/assets/{DiffViewer-D369eZe8.js.map → DiffViewer-DmeRWuc4.js.map} +1 -1
- package/dist/core/web/public/next/assets/{McpSection-DVgiSYG1.js → McpSection-q34T7Tho.js} +2 -2
- package/dist/core/web/public/next/assets/{McpSection-DVgiSYG1.js.map → McpSection-q34T7Tho.js.map} +1 -1
- package/dist/core/web/public/next/assets/{MutationTokenDialog-B9I4PAcp.js → MutationTokenDialog-CFAkwOEt.js} +2 -2
- package/dist/core/web/public/next/assets/{MutationTokenDialog-B9I4PAcp.js.map → MutationTokenDialog-CFAkwOEt.js.map} +1 -1
- package/dist/core/web/public/next/assets/{ResourcePoolConsoleApp-z6tJj3s9.js → ResourcePoolConsoleApp-DHc8GFOY.js} +4 -4
- package/dist/core/web/public/next/assets/{ResourcePoolConsoleApp-z6tJj3s9.js.map → ResourcePoolConsoleApp-DHc8GFOY.js.map} +1 -1
- package/dist/core/web/public/next/assets/{RouteErrorBoundary-OSajL45F.js → RouteErrorBoundary-ZL9F4qUn.js} +2 -2
- package/dist/core/web/public/next/assets/{RouteErrorBoundary-OSajL45F.js.map → RouteErrorBoundary-ZL9F4qUn.js.map} +1 -1
- package/dist/core/web/public/next/assets/{Meter-CLcr-4wS.css → Segmented-8cf0Fypn.css} +1 -1
- package/dist/core/web/public/next/assets/{Meter-Cmo1pLbk.js → Segmented-DbRjVye3.js} +2 -2
- package/dist/core/web/public/next/assets/Segmented-DbRjVye3.js.map +1 -0
- package/dist/core/web/public/next/assets/SettingsSection-nJGGGYqv.js +2 -0
- package/dist/core/web/public/next/assets/{SettingsSection-B3YH2Npi.js.map → SettingsSection-nJGGGYqv.js.map} +1 -1
- package/dist/core/web/public/next/assets/UniverseConsoleApp-6GJydgo4.js +2 -0
- package/dist/core/web/public/next/assets/{UniverseConsoleApp-wEKIzl1M.js.map → UniverseConsoleApp-6GJydgo4.js.map} +1 -1
- package/dist/core/web/public/next/assets/{UniverseView-CQVpJqqI.js → UniverseView-DLDtNYL8.js} +2 -2
- package/dist/core/web/public/next/assets/{UniverseView-CQVpJqqI.js.map → UniverseView-DLDtNYL8.js.map} +1 -1
- package/dist/core/web/public/next/assets/UsageSection-Cf9d9iFH.js +2 -0
- package/dist/core/web/public/next/assets/UsageSection-Cf9d9iFH.js.map +1 -0
- package/dist/core/web/public/next/assets/VerseConsoleApp-DsdKQoTH.css +1 -0
- package/dist/core/web/public/next/assets/VerseConsoleApp-y0uOHixd.js +3 -0
- package/dist/core/web/public/next/assets/VerseConsoleApp-y0uOHixd.js.map +1 -0
- package/dist/core/web/public/next/assets/{charts-BopViIha.js → charts-CVooqJWN.js} +2 -2
- package/dist/core/web/public/next/assets/{charts-BopViIha.js.map → charts-CVooqJWN.js.map} +1 -1
- package/dist/core/web/public/next/assets/context-model-Bqv8DVuH.js +2 -0
- package/dist/core/web/public/next/assets/context-model-Bqv8DVuH.js.map +1 -0
- package/dist/core/web/public/next/assets/global-eaY9GyX3.js +2 -0
- package/dist/core/web/public/next/assets/global-eaY9GyX3.js.map +1 -0
- package/dist/core/web/public/next/assets/{icons-L06pQH6j.js → icons-vex8rclC.js} +2 -2
- package/dist/core/web/public/next/assets/{icons-L06pQH6j.js.map → icons-vex8rclC.js.map} +1 -1
- package/dist/core/web/public/next/assets/{index-CXgVQHek.js → index-D2Eik-zt.js} +3 -3
- package/dist/core/web/public/next/assets/{index-CXgVQHek.js.map → index-D2Eik-zt.js.map} +1 -1
- package/dist/core/web/public/next/assets/{queries-D3sSlan1.js → queries-bAYU0VNy.js} +2 -2
- package/dist/core/web/public/next/assets/{queries-D3sSlan1.js.map → queries-bAYU0VNy.js.map} +1 -1
- package/dist/core/web/public/next/assets/use-guarded-action-C7QrP7Yp.js +2 -0
- package/dist/core/web/public/next/assets/{use-guarded-action-BxfJ9E-n.js.map → use-guarded-action-C7QrP7Yp.js.map} +1 -1
- package/dist/core/web/public/next/assets/verse-model-TfDk9cky.js +2 -0
- package/dist/core/web/public/next/assets/verse-model-TfDk9cky.js.map +1 -0
- package/dist/core/web/public/next/assets/{workspace-model-v0a1gl-C.js → workspace-model-CHol5RVp.js} +2 -2
- package/dist/core/web/public/next/assets/{workspace-model-v0a1gl-C.js.map → workspace-model-CHol5RVp.js.map} +1 -1
- package/dist/core/web/public/next/index.html +1 -1
- package/dist/release-dependency-inventory.json +1 -1
- package/docs/README.md +1 -0
- package/package.json +1 -1
- package/dist/core/web/public/next/assets/AutonomySection-yeNNUPur.js +0 -2
- package/dist/core/web/public/next/assets/ChatSection-BfnLe5dT.css +0 -1
- package/dist/core/web/public/next/assets/ChatSection-DwDDnCZQ.js +0 -80
- package/dist/core/web/public/next/assets/ChatSection-DwDDnCZQ.js.map +0 -1
- package/dist/core/web/public/next/assets/ConfirmDialog-C363ty_c.js +0 -2
- package/dist/core/web/public/next/assets/ConfirmDialog-C363ty_c.js.map +0 -1
- package/dist/core/web/public/next/assets/Meter-Cmo1pLbk.js.map +0 -1
- package/dist/core/web/public/next/assets/SettingsSection-B3YH2Npi.js +0 -2
- package/dist/core/web/public/next/assets/UniverseConsoleApp-wEKIzl1M.js +0 -2
- package/dist/core/web/public/next/assets/UsageSection-dToBThXe.js +0 -2
- package/dist/core/web/public/next/assets/UsageSection-dToBThXe.js.map +0 -1
- package/dist/core/web/public/next/assets/VerseConsoleApp-CMkCizvL.css +0 -1
- package/dist/core/web/public/next/assets/VerseConsoleApp-DHU32JCQ.js +0 -3
- package/dist/core/web/public/next/assets/VerseConsoleApp-DHU32JCQ.js.map +0 -1
- package/dist/core/web/public/next/assets/global-DMWakEhP.js +0 -2
- package/dist/core/web/public/next/assets/global-DMWakEhP.js.map +0 -1
- package/dist/core/web/public/next/assets/use-guarded-action-BxfJ9E-n.js +0 -2
- package/dist/core/web/public/next/assets/verse-model-CvtK6vP6.js +0 -2
- package/dist/core/web/public/next/assets/verse-model-CvtK6vP6.js.map +0 -1
|
@@ -11,20 +11,42 @@
|
|
|
11
11
|
* Parse: NDJSON in the Anthropic Messages API wire format (message_start,
|
|
12
12
|
* content_block_start/delta/stop, message_delta{usage}, message_stop). The
|
|
13
13
|
* parser is the shared Anthropic-stream parser, which also accepts claude's
|
|
14
|
-
* `stream_event` wrapper and whole-message envelopes.
|
|
14
|
+
* `stream_event` wrapper and whole-message envelopes. Grok's terminal `result`
|
|
15
|
+
* carries `modelUsage.<key>.contextWindow` on the current model's row only
|
|
16
|
+
* (the key can differ from the CLI id — `grok-4.6-build` for `grok-4.6`), and
|
|
17
|
+
* a `system/compact_boundary` line marks an auto-compaction; the shared parser
|
|
18
|
+
* turns both into the usage event's window and a `compaction` event.
|
|
19
|
+
*
|
|
20
|
+
* V3.9 context. Grok has no per-invocation compaction budget flag, so there
|
|
21
|
+
* are no mode flags: it always runs its catalog budget (80% of 500k). Shared
|
|
22
|
+
* project memory reaches it as `--rules=<block>` — `--rules <RULES>` "Extra
|
|
23
|
+
* rules to append to the system prompt" (alias `--append-system-prompt`) is in
|
|
24
|
+
* `grok --help` on the pinned 0.2.118 binary. Grok can reach only `--cwd`, so
|
|
25
|
+
* the memory directory itself is never granted; the block carries the file's
|
|
26
|
+
* contents and says this seat may only read it (`writable: false`).
|
|
15
27
|
*/
|
|
28
|
+
import { canonicalModelId } from '../context-math.js';
|
|
16
29
|
import { createAnthropicStreamParser } from './claude.js';
|
|
30
|
+
/** The launch record's memory block, when the snapshot is well-formed; anything else means memory off. */
|
|
31
|
+
function launchMemoryBlock(launch) {
|
|
32
|
+
const memory = launch.memory;
|
|
33
|
+
if (typeof memory !== 'object' || memory === null)
|
|
34
|
+
return null;
|
|
35
|
+
const block = memory.block;
|
|
36
|
+
return typeof block === 'string' && block.trim().length > 0 ? block : null;
|
|
37
|
+
}
|
|
17
38
|
function buildGrokLaunch(session, text, launch) {
|
|
18
39
|
if (!session.nativeSessionId) {
|
|
19
40
|
throw new Error('grok session is missing its native session id');
|
|
20
41
|
}
|
|
21
42
|
const prefix = launch.launcher ? [...launch.launcher] : ['grok'];
|
|
43
|
+
const memoryBlock = launchMemoryBlock(launch);
|
|
22
44
|
const argv = [
|
|
23
45
|
...prefix,
|
|
24
46
|
'--output-format', 'streaming-messages-json',
|
|
25
47
|
'--include-partial-messages',
|
|
26
48
|
'--cwd', session.projectPath,
|
|
27
|
-
'--model', session.model,
|
|
49
|
+
'--model', canonicalModelId(session.model),
|
|
28
50
|
// NOT 'acceptEdits'. Grok's acceptEdits auto-approves edits but NOT
|
|
29
51
|
// `run_terminal_command`, and there is no interactive approver in a seat, so
|
|
30
52
|
// the first shell command cancels the turn: measured
|
|
@@ -46,6 +68,10 @@ function buildGrokLaunch(session, text, launch) {
|
|
|
46
68
|
// `workspaces.ts engineSupportsExtraRoots()` returns false for grok, so
|
|
47
69
|
// the roots view marks the extras unreachable and says why, instead of
|
|
48
70
|
// letting the operator believe the agent can see them.
|
|
71
|
+
// Shared project memory, the SAME snapshotted block every turn (cache-
|
|
72
|
+
// stable). The `=` spelling is the one clap accepts for a value that
|
|
73
|
+
// starts with `-`, exactly as for `--single` below.
|
|
74
|
+
...(memoryBlock !== null ? [`--rules=${memoryBlock}`] : []),
|
|
49
75
|
...(session.turnCount > 0 ? ['--resume', session.nativeSessionId] : ['--session-id', session.nativeSessionId]),
|
|
50
76
|
`--single=${text}`,
|
|
51
77
|
];
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"grok.js","sourceRoot":"","sources":["../../../../src/core/verse/adapters/grok.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"grok.js","sourceRoot":"","sources":["../../../../src/core/verse/adapters/grok.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;AAEH,OAAO,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AAItD,OAAO,EAAE,2BAA2B,EAAE,MAAM,aAAa,CAAC;AAE1D,0GAA0G;AAC1G,SAAS,iBAAiB,CAAC,MAAuB;IAChD,MAAM,MAAM,GAAY,MAAM,CAAC,MAAM,CAAC;IACtC,IAAI,OAAO,MAAM,KAAK,QAAQ,IAAI,MAAM,KAAK,IAAI;QAAE,OAAO,IAAI,CAAC;IAC/D,MAAM,KAAK,GAAI,MAA8B,CAAC,KAAK,CAAC;IACpD,OAAO,OAAO,KAAK,KAAK,QAAQ,IAAI,KAAK,CAAC,IAAI,EAAE,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,IAAI,CAAC;AAC7E,CAAC;AAED,SAAS,eAAe,CAAC,OAAqB,EAAE,IAAY,EAAE,MAAuB;IACnF,IAAI,CAAC,OAAO,CAAC,eAAe,EAAE,CAAC;QAC7B,MAAM,IAAI,KAAK,CAAC,+CAA+C,CAAC,CAAC;IACnE,CAAC;IACD,MAAM,MAAM,GAAG,MAAM,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,GAAG,MAAM,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC;IACjE,MAAM,WAAW,GAAG,iBAAiB,CAAC,MAAM,CAAC,CAAC;IAC9C,MAAM,IAAI,GAAG;QACX,GAAG,MAAM;QACT,iBAAiB,EAAE,yBAAyB;QAC5C,4BAA4B;QAC5B,OAAO,EAAE,OAAO,CAAC,WAAW;QAC5B,SAAS,EAAE,gBAAgB,CAAC,OAAO,CAAC,KAAK,CAAC;QAC1C,oEAAoE;QACpE,6EAA6E;QAC7E,qDAAqD;QACrD,0EAA0E;QAC1E,uEAAuE;QACvE,qEAAqE;QACrE,4EAA4E;QAC5E,mBAAmB,EAAE,SAAS;QAC9B,2EAA2E;QAC3E,sDAAsD;QACtD,EAAE;QACF,sEAAsE;QACtE,0EAA0E;QAC1E,yEAAyE;QACzE,2EAA2E;QAC3E,uEAAuE;QACvE,kDAAkD;QAClD,EAAE;QACF,wEAAwE;QACxE,uEAAuE;QACvE,uDAAuD;QAEvD,uEAAuE;QACvE,qEAAqE;QACrE,oDAAoD;QACpD,GAAG,CAAC,WAAW,KAAK,IAAI,CAAC,CAAC,CAAC,CAAC,WAAW,WAAW,EAAE,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC;QAC3D,GAAG,CAAC,OAAO,CAAC,SAAS,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,UAAU,EAAE,OAAO,CAAC,eAAe,CAAC,CAAC,CAAC,CAAC,CAAC,cAAc,EAAE,OAAO,CAAC,eAAe,CAAC,CAAC;QAC9G,YAAY,IAAI,EAAE;KACnB,CAAC;IACF,OAAO,EAAE,IAAI,EAAE,GAAG,EAAE,OAAO,CAAC,WAAW,EAAE,GAAG,EAAE,EAAE,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC;AAClE,CAAC;AAED,MAAM,CAAC,MAAM,WAAW,GAAiB;IACvC,WAAW,EAAE,eAAe;IAC5B,YAAY,EAAE,CAAC,MAAc,EAAE,EAAE,CAAC,2BAA2B,CAAC,MAAM,EAAE,MAAM,CAAC;CAC9E,CAAC"}
|
|
@@ -25,9 +25,41 @@ export interface VerseTurnParser {
|
|
|
25
25
|
/** Vendor conversation id observed in the output (codex thread id, claude session id), or null. */
|
|
26
26
|
nativeSessionId(): string | null;
|
|
27
27
|
}
|
|
28
|
+
/**
|
|
29
|
+
* V3.9 — what a telemetry hook gets. Hooks are the ONE place an adapter may
|
|
30
|
+
* read the filesystem: some CLIs (codex) never put exact per-call context on
|
|
31
|
+
* stdout, only in their own session files. Hooks must be bounded (tail reads,
|
|
32
|
+
* size caps), synchronous, fast, and must never throw.
|
|
33
|
+
*/
|
|
34
|
+
export interface VerseAdapterTurnContext {
|
|
35
|
+
session: VerseSession;
|
|
36
|
+
launch: VerseSeatLaunch;
|
|
37
|
+
turnId: string;
|
|
38
|
+
/** Epoch ms when the process was spawned. */
|
|
39
|
+
startedAt: number;
|
|
40
|
+
/** Native id observed so far this turn (parser), else the session's. */
|
|
41
|
+
nativeSessionId: string | null;
|
|
42
|
+
/** This turn's parser, for hooks that need what it captured. */
|
|
43
|
+
parser: VerseTurnParser;
|
|
44
|
+
/** Per-turn scratch the hooks own (e.g. a file offset); starts empty. */
|
|
45
|
+
state: Record<string, unknown>;
|
|
46
|
+
}
|
|
28
47
|
export interface VerseAdapter {
|
|
29
48
|
buildLaunch(session: VerseSession, text: string, launch: VerseSeatLaunch): VerseTurnLaunch;
|
|
30
49
|
createParser(turnId: string): VerseTurnParser;
|
|
50
|
+
/**
|
|
51
|
+
* V3.9, optional. Polled every VERSE_TELEMETRY_POLL_MS while a turn runs
|
|
52
|
+
* (live meter). Typically returns `context` events.
|
|
53
|
+
*/
|
|
54
|
+
pollTelemetry?(ctx: VerseAdapterTurnContext): VerseParsedEvent[];
|
|
55
|
+
/**
|
|
56
|
+
* V3.9, optional. Called once after the process exits and AFTER the
|
|
57
|
+
* parser's `finish()` events were applied. Typically returns `context` and
|
|
58
|
+
* `compaction` events read from the CLI's own session files.
|
|
59
|
+
*/
|
|
60
|
+
afterTurn?(ctx: VerseAdapterTurnContext): VerseParsedEvent[];
|
|
31
61
|
}
|
|
62
|
+
/** V3.9 — live telemetry poll interval for adapters that implement `pollTelemetry`. */
|
|
63
|
+
export declare const VERSE_TELEMETRY_POLL_MS = 2000;
|
|
32
64
|
export declare function adapterFor(engine: VerseEngine): VerseAdapter;
|
|
33
65
|
export {};
|
|
@@ -14,6 +14,8 @@
|
|
|
14
14
|
import { claudeAdapter } from './claude.js';
|
|
15
15
|
import { codexAdapter } from './codex.js';
|
|
16
16
|
import { grokAdapter } from './grok.js';
|
|
17
|
+
/** V3.9 — live telemetry poll interval for adapters that implement `pollTelemetry`. */
|
|
18
|
+
export const VERSE_TELEMETRY_POLL_MS = 2_000;
|
|
17
19
|
export function adapterFor(engine) {
|
|
18
20
|
switch (engine) {
|
|
19
21
|
case 'claude':
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/core/verse/adapters/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAIH,OAAO,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAC5C,OAAO,EAAE,YAAY,EAAE,MAAM,YAAY,CAAC;AAC1C,OAAO,EAAE,WAAW,EAAE,MAAM,WAAW,CAAC;
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/core/verse/adapters/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAIH,OAAO,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAC5C,OAAO,EAAE,YAAY,EAAE,MAAM,YAAY,CAAC;AAC1C,OAAO,EAAE,WAAW,EAAE,MAAM,WAAW,CAAC;AAqDxC,uFAAuF;AACvF,MAAM,CAAC,MAAM,uBAAuB,GAAG,KAAK,CAAC;AAE7C,MAAM,UAAU,UAAU,CAAC,MAAmB;IAC5C,QAAQ,MAAM,EAAE,CAAC;QACf,KAAK,QAAQ,CAAC;QACd,KAAK,OAAO;YACV,OAAO,aAAa,CAAC;QACvB,KAAK,OAAO;YACV,OAAO,YAAY,CAAC;QACtB,KAAK,MAAM;YACT,OAAO,WAAW,CAAC;QACrB,OAAO,CAAC,CAAC,CAAC;YACR,MAAM,KAAK,GAAU,MAAM,CAAC;YAC5B,MAAM,IAAI,KAAK,CAAC,yBAAyB,MAAM,CAAC,KAAK,CAAC,EAAE,CAAC,CAAC;QAC5D,CAAC;IACH,CAAC;AACH,CAAC"}
|
|
@@ -0,0 +1,284 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Codex rollout reader — the ONLY place Verse learns a codex turn's exact
|
|
3
|
+
* context occupancy, its window, its compactions and its true per-turn usage.
|
|
4
|
+
*
|
|
5
|
+
* WHY THIS EXISTS. `codex exec --json` never prints per-call usage or the
|
|
6
|
+
* window: its `turn.completed.usage` is a SUM over every model call in the
|
|
7
|
+
* turn (a 20-call turn reports ~20× the live prompt), and codex seeds that sum
|
|
8
|
+
* from the rollout when a thread is resumed, so on `exec resume` it is the
|
|
9
|
+
* THREAD's running total rather than the turn's. The CLI's own session file
|
|
10
|
+
* does carry the truth, one `token_count` per model call:
|
|
11
|
+
*
|
|
12
|
+
* <CODEX_HOME>/sessions/YYYY/MM/DD/rollout-<local ts>-<thread id>.jsonl
|
|
13
|
+
* {"timestamp":…,"type":"event_msg","payload":{"type":"token_count","info":{
|
|
14
|
+
* "total_token_usage":{…cumulative…},"last_token_usage":{…this call…},
|
|
15
|
+
* "model_context_window":258400}}}
|
|
16
|
+
* {"timestamp":…,"type":"event_msg","payload":{"type":"task_started","model_context_window":258400}}
|
|
17
|
+
* {"timestamp":…,"type":"compacted","payload":{…replacement history, often MEGABYTES…}}
|
|
18
|
+
* {"timestamp":…,"type":"token_usage_record","payload":{"thread_id":…,"turn_token_usage":{…}}} (0.149+)
|
|
19
|
+
*
|
|
20
|
+
* (Shapes verified against 4,001 rollouts on this machine, CLI 0.136 – 0.155.)
|
|
21
|
+
*
|
|
22
|
+
* WHAT "OCCUPANCY" MEANS HERE. `last_token_usage.total_tokens` — the last
|
|
23
|
+
* call's prompt plus its reply. That is the quantity codex itself compares to
|
|
24
|
+
* its auto-compaction limit (no uncompacted call ever exceeded 244,800 = 90% of
|
|
25
|
+
* the raw 272k window, across 62,104 calls), and it is what the NEXT call's
|
|
26
|
+
* prompt starts from, so the meter and the compaction tick share one unit.
|
|
27
|
+
* Right after a compaction codex writes a `token_count` whose cumulative total
|
|
28
|
+
* is unchanged but whose `last_token_usage` is the post-compaction size — so a
|
|
29
|
+
* reading is taken from EVERY token_count, while usage is only summed for
|
|
30
|
+
* records whose cumulative total moved (a real model call).
|
|
31
|
+
*
|
|
32
|
+
* BOUNDS. A `compacted` line is routinely 2–17 MB (it embeds the replacement
|
|
33
|
+
* history), so nothing here ever holds a whole line in memory: lines are
|
|
34
|
+
* scanned in chunks and only their first CODEX_ROLLOUT_LINE_HEAD_BYTES are
|
|
35
|
+
* kept. The small records (token_count ≤ 1 KB) are parsed whole; an oversized
|
|
36
|
+
* line is classified from its head alone. First reads look at most
|
|
37
|
+
* CODEX_ROLLOUT_TAIL_BYTES back from EOF (doubling to a hard cap only when the
|
|
38
|
+
* turn's start is not in that window); incremental reads scan at most
|
|
39
|
+
* CODEX_ROLLOUT_MAX_SCAN_BYTES. A missing, pruned, rewritten or unreadable file
|
|
40
|
+
* yields null / "no reading" — nothing here throws.
|
|
41
|
+
*
|
|
42
|
+
* PRIVACY. Paths computed here name native-profile directories (account
|
|
43
|
+
* identity). They are used to read files and are never returned in events,
|
|
44
|
+
* logged, or persisted.
|
|
45
|
+
*/
|
|
46
|
+
/** First read of a rollout: at most this much from EOF (spec: ≤ 2 MB). */
|
|
47
|
+
export declare const CODEX_ROLLOUT_TAIL_BYTES: number;
|
|
48
|
+
/**
|
|
49
|
+
* When the turn's first record is not inside the first tail window (a turn
|
|
50
|
+
* that wrote megabytes before the first poll — i.e. an early compaction), the
|
|
51
|
+
* window doubles up to this cap. Past it the turn is accounted as partial.
|
|
52
|
+
*/
|
|
53
|
+
export declare const CODEX_ROLLOUT_MAX_TAIL_BYTES: number;
|
|
54
|
+
/** One incremental read scans at most this much; beyond it the reader jumps to the tail and records a gap. */
|
|
55
|
+
export declare const CODEX_ROLLOUT_MAX_SCAN_BYTES: number;
|
|
56
|
+
/** Bytes of each line retained for classification. Every record we parse whole is far smaller. */
|
|
57
|
+
export declare const CODEX_ROLLOUT_LINE_HEAD_BYTES: number;
|
|
58
|
+
/** One usage block as codex writes it. `inputTokens` INCLUDES the cached portion. */
|
|
59
|
+
export interface CodexTokenTotals {
|
|
60
|
+
inputTokens: number;
|
|
61
|
+
cachedInputTokens: number;
|
|
62
|
+
/** 0.155+ only; 0 when absent. */
|
|
63
|
+
cacheWriteInputTokens: number;
|
|
64
|
+
outputTokens: number;
|
|
65
|
+
reasoningOutputTokens: number;
|
|
66
|
+
totalTokens: number;
|
|
67
|
+
}
|
|
68
|
+
export type CodexRolloutRecord = {
|
|
69
|
+
kind: 'token-count';
|
|
70
|
+
/** Byte offset of the line — a stable identity for "already seen". */
|
|
71
|
+
offset: number;
|
|
72
|
+
/** Epoch ms from the record's `timestamp`, or null when absent/unparsable. */
|
|
73
|
+
at: number | null;
|
|
74
|
+
total: CodexTokenTotals;
|
|
75
|
+
last: CodexTokenTotals;
|
|
76
|
+
modelContextWindow: number | null;
|
|
77
|
+
} | {
|
|
78
|
+
kind: 'task-started';
|
|
79
|
+
offset: number;
|
|
80
|
+
at: number | null;
|
|
81
|
+
modelContextWindow: number | null;
|
|
82
|
+
} | {
|
|
83
|
+
kind: 'compacted';
|
|
84
|
+
offset: number;
|
|
85
|
+
at: number | null;
|
|
86
|
+
} | {
|
|
87
|
+
kind: 'token-usage-record';
|
|
88
|
+
offset: number;
|
|
89
|
+
at: number | null;
|
|
90
|
+
threadId: string | null;
|
|
91
|
+
turn: CodexTokenTotals | null;
|
|
92
|
+
};
|
|
93
|
+
export interface CodexRolloutRead {
|
|
94
|
+
/** File size when the read started. */
|
|
95
|
+
size: number;
|
|
96
|
+
/** First byte the read considered. */
|
|
97
|
+
start: number;
|
|
98
|
+
/** Offset just past the last COMPLETE line consumed — where an incremental read resumes. */
|
|
99
|
+
end: number;
|
|
100
|
+
records: CodexRolloutRecord[];
|
|
101
|
+
/** True when bytes between `start` and `size` were skipped for the scan budget. */
|
|
102
|
+
skipped: boolean;
|
|
103
|
+
}
|
|
104
|
+
export declare const ZERO_CODEX_TOTALS: Readonly<CodexTokenTotals>;
|
|
105
|
+
/** A codex usage block → totals, or null when it is not one. `total_tokens` falls back to input + output. */
|
|
106
|
+
export declare function codexTotals(value: unknown): CodexTokenTotals | null;
|
|
107
|
+
export declare function addCodexTotals(a: CodexTokenTotals, b: CodexTokenTotals): CodexTokenTotals;
|
|
108
|
+
/** a − b, each bucket clamped at 0 (a counter that went backwards is a reset, never negative usage). */
|
|
109
|
+
export declare function subtractCodexTotals(a: CodexTokenTotals, b: CodexTokenTotals): CodexTokenTotals;
|
|
110
|
+
/**
|
|
111
|
+
* The live occupancy one `token_count` describes: its last call's
|
|
112
|
+
* `total_tokens` (prompt + reply), the figure codex compacts against.
|
|
113
|
+
*/
|
|
114
|
+
export declare function codexOccupancy(last: CodexTokenTotals): number;
|
|
115
|
+
/**
|
|
116
|
+
* Complete records from the last `maxBytes` of a rollout (never more than
|
|
117
|
+
* CODEX_ROLLOUT_MAX_TAIL_BYTES). A line cut by the window start is dropped.
|
|
118
|
+
* Null when the file is missing or unreadable.
|
|
119
|
+
*/
|
|
120
|
+
export declare function readCodexRolloutTail(file: string, maxBytes?: number): CodexRolloutRead | null;
|
|
121
|
+
/**
|
|
122
|
+
* Complete records from byte `from` to EOF, scanning at most `maxScanBytes`.
|
|
123
|
+
* Null when the file is missing, unreadable, or SHORTER than `from` (rewritten
|
|
124
|
+
* or truncated — the caller must start over rather than trust its offset).
|
|
125
|
+
*/
|
|
126
|
+
export declare function readCodexRolloutFrom(file: string, from: number, maxScanBytes?: number): CodexRolloutRead | null;
|
|
127
|
+
/** What one read of a rollout says, in the shape the spec names. */
|
|
128
|
+
export interface CodexRolloutSummary {
|
|
129
|
+
/** The LAST `token_count` in the window: occupancy and the window codex measured it against. */
|
|
130
|
+
lastTokenCount: {
|
|
131
|
+
/** `last_token_usage.total_tokens` — live occupancy (see file header). */
|
|
132
|
+
lastTotalTokens: number;
|
|
133
|
+
/** `last_token_usage.input_tokens` — that call's prompt alone. */
|
|
134
|
+
lastInputTokens: number;
|
|
135
|
+
modelContextWindow: number | null;
|
|
136
|
+
/** Cumulative `total_token_usage` at that point. */
|
|
137
|
+
total: CodexTokenTotals;
|
|
138
|
+
} | null;
|
|
139
|
+
/** `model_context_window` of the last `task_started` in the window. */
|
|
140
|
+
taskStartedWindow: number | null;
|
|
141
|
+
/** `compacted` records at or after `afterOffset`. */
|
|
142
|
+
compactions: number;
|
|
143
|
+
size: number;
|
|
144
|
+
end: number;
|
|
145
|
+
}
|
|
146
|
+
/**
|
|
147
|
+
* One-shot extraction from a rollout's tail (or from `afterOffset`, when
|
|
148
|
+
* given). Missing or pruned file → null; never throws.
|
|
149
|
+
*/
|
|
150
|
+
export declare function summarizeCodexRollout(file: string, opts?: {
|
|
151
|
+
afterOffset?: number;
|
|
152
|
+
maxBytes?: number;
|
|
153
|
+
}): CodexRolloutSummary | null;
|
|
154
|
+
/**
|
|
155
|
+
* The CODEX_HOME a seat's launcher pins, derived from the launcher argv the
|
|
156
|
+
* session was created with — the same `<profile>/launcher.mjs` ⇒
|
|
157
|
+
* `<profile>/native-state` relation `accounts.ts` (codexSessionRoots) and
|
|
158
|
+
* `mcp-seat-view.ts` use, preferring the profile's own `profile.json`
|
|
159
|
+
* `nativeStatePath` when it is readable.
|
|
160
|
+
*
|
|
161
|
+
* Null for a launcher-less seat: Verse never reads the unpinned global
|
|
162
|
+
* `~/.codex`, whose rollouts belong to other tools and other accounts.
|
|
163
|
+
*/
|
|
164
|
+
export declare function codexNativeStatePath(launcher: readonly string[] | null | undefined): string | null;
|
|
165
|
+
export declare function isCodexThreadId(value: unknown): value is string;
|
|
166
|
+
/** Creation time embedded in a UUIDv7 (first 48 bits, epoch ms), else null. */
|
|
167
|
+
export declare function uuidV7Millis(id: string): number | null;
|
|
168
|
+
export interface LocateCodexRolloutOptions {
|
|
169
|
+
/**
|
|
170
|
+
* Also run the bounded newest-first scan of every day directory when the
|
|
171
|
+
* id's own date does not hold the file. Callers polling every few seconds
|
|
172
|
+
* pass false after their first attempt so a missing file costs three
|
|
173
|
+
* `readdir`s, not hundreds.
|
|
174
|
+
*/
|
|
175
|
+
fullScan?: boolean;
|
|
176
|
+
}
|
|
177
|
+
/**
|
|
178
|
+
* Path of the rollout for `threadId` under `<nativeStatePath>/sessions`, or
|
|
179
|
+
* null when there is none (never run, pruned, `--ephemeral`, unreadable).
|
|
180
|
+
*
|
|
181
|
+
* Cheap path first: a UUIDv7 id carries its creation instant, so the file is
|
|
182
|
+
* in that LOCAL day's directory (±1 day for a timezone change or a thread
|
|
183
|
+
* created just before midnight). Otherwise a bounded newest-first descent.
|
|
184
|
+
* If several files match (never observed), the most recently written wins.
|
|
185
|
+
*/
|
|
186
|
+
export declare function locateCodexRollout(nativeStatePath: string, threadId: string, opts?: LocateCodexRolloutOptions): string | null;
|
|
187
|
+
/** Test seam: forget cached profile and rollout paths. */
|
|
188
|
+
export declare function resetCodexRolloutCaches(): void;
|
|
189
|
+
export interface CodexCompactionObservation {
|
|
190
|
+
/** Occupancy at the last reading before the compaction (this turn's or the previous turn's). */
|
|
191
|
+
preTokens: number | null;
|
|
192
|
+
/** Occupancy of the first reading after it; null until one is seen. */
|
|
193
|
+
postTokens: number | null;
|
|
194
|
+
}
|
|
195
|
+
/**
|
|
196
|
+
* Everything one turn has learned from its thread's rollout. Plain data, held
|
|
197
|
+
* in the adapter hook's per-turn `ctx.state`, advanced by
|
|
198
|
+
* `advanceCodexTurnTracker` on every poll and once more after the turn.
|
|
199
|
+
*/
|
|
200
|
+
export interface CodexTurnTracker {
|
|
201
|
+
file: string | null;
|
|
202
|
+
ino: number | null;
|
|
203
|
+
/** Where the next incremental read starts. */
|
|
204
|
+
offset: number;
|
|
205
|
+
/** `offset` lands inside a line (a skipped oversized line); drop up to the next newline. */
|
|
206
|
+
midLine: boolean;
|
|
207
|
+
/** The first read (turn-start discovery) has happened. */
|
|
208
|
+
initialized: boolean;
|
|
209
|
+
/** This turn's first record was located, so everything it wrote has been seen. */
|
|
210
|
+
regionFound: boolean;
|
|
211
|
+
/** Some bytes this turn wrote were skipped (scan budget / tail cap). Sums are then partial. */
|
|
212
|
+
gap: boolean;
|
|
213
|
+
/** Cumulative totals just before this turn; `ZERO` when the thread had none; null when unknown. */
|
|
214
|
+
baseline: CodexTokenTotals | null;
|
|
215
|
+
/** Cumulative `total_tokens` of the latest token_count seen — a record that repeats it is not a new call. */
|
|
216
|
+
prevTotalTokens: number | null;
|
|
217
|
+
/** Model calls this turn and the sum of their `last_token_usage`. */
|
|
218
|
+
calls: number;
|
|
219
|
+
callSum: CodexTokenTotals;
|
|
220
|
+
/** Cumulative totals at this turn's first and latest call (the first call's own usage alongside). */
|
|
221
|
+
firstCall: {
|
|
222
|
+
total: CodexTokenTotals;
|
|
223
|
+
last: CodexTokenTotals;
|
|
224
|
+
} | null;
|
|
225
|
+
lastTotals: CodexTokenTotals | null;
|
|
226
|
+
/** The CLI's own per-turn figure (0.149+ `token_usage_record.turn_token_usage`), when written. */
|
|
227
|
+
turnUsage: CodexTokenTotals | null;
|
|
228
|
+
/** The latest occupancy reading, and whether this turn produced it. */
|
|
229
|
+
reading: {
|
|
230
|
+
tokens: number;
|
|
231
|
+
window: number | null;
|
|
232
|
+
inTurn: boolean;
|
|
233
|
+
offset: number;
|
|
234
|
+
} | null;
|
|
235
|
+
/** `task_started.model_context_window` of this turn. */
|
|
236
|
+
taskStartedWindow: number | null;
|
|
237
|
+
compactions: CodexCompactionObservation[];
|
|
238
|
+
}
|
|
239
|
+
export declare function createCodexTurnTracker(): CodexTurnTracker;
|
|
240
|
+
/**
|
|
241
|
+
* Bring a turn's tracker up to date with `file`. Returns false when the file
|
|
242
|
+
* cannot be read (the tracker keeps what it had). Bounded: one discovery of
|
|
243
|
+
* ≤ CODEX_ROLLOUT_MAX_TAIL_BYTES, then ≤ CODEX_ROLLOUT_MAX_SCAN_BYTES per call.
|
|
244
|
+
*/
|
|
245
|
+
export declare function advanceCodexTurnTracker(tracker: CodexTurnTracker, file: string, startedAtMs: number, threadId?: string | null): boolean;
|
|
246
|
+
export type CodexTurnUsageSource =
|
|
247
|
+
/** The CLI's own per-turn record (0.149+). */
|
|
248
|
+
'turn-record'
|
|
249
|
+
/** Sum of every call this turn made, all of which were seen. */
|
|
250
|
+
| 'calls'
|
|
251
|
+
/** `turn.completed.usage` as printed (a first turn, or a per-turn figure). */
|
|
252
|
+
| 'reported'
|
|
253
|
+
/** `turn.completed.usage` was the thread's running total; the pre-turn total was subtracted. */
|
|
254
|
+
| 'reported-delta'
|
|
255
|
+
/** Only part of the turn was seen; the calls that were. A lower bound. */
|
|
256
|
+
| 'calls-partial';
|
|
257
|
+
export interface CodexTurnUsage {
|
|
258
|
+
totals: CodexTokenTotals;
|
|
259
|
+
source: CodexTurnUsageSource;
|
|
260
|
+
}
|
|
261
|
+
/**
|
|
262
|
+
* This turn's true usage, from the best evidence available.
|
|
263
|
+
*
|
|
264
|
+
* WHY `turn.completed` IS NOT TRUSTED ON ITS OWN: codex prints its session's
|
|
265
|
+
* `total_token_usage` there, and on `exec resume` that session is seeded from
|
|
266
|
+
* the rollout — so turn 5 reports turns 1–5. Summing it per turn (which is
|
|
267
|
+
* what the engine does with `usage` events) would count turn 1 five times.
|
|
268
|
+
* The rollout's per-call records are the ground truth either way; the printed
|
|
269
|
+
* figure is used only when the rollout cannot answer, and even then a figure
|
|
270
|
+
* that equals the rollout's running total is converted to a delta.
|
|
271
|
+
*
|
|
272
|
+
* Verified on this machine's rollouts (221 turns with a CLI per-turn record):
|
|
273
|
+
* the per-call sum equals codex's own `turn_token_usage` exactly on every
|
|
274
|
+
* fully observed turn WITHOUT a compaction; with one, the record is larger by
|
|
275
|
+
* that compaction request's usage, which codex never writes as a
|
|
276
|
+
* `token_count` (its running total does not move either). The record is
|
|
277
|
+
* therefore preferred when present (0.149+); on older CLIs no codex surface —
|
|
278
|
+
* rollout or stdout — counts compaction requests, and neither does this.
|
|
279
|
+
*
|
|
280
|
+
* @param reported `turn.completed.usage` (null when the turn printed none)
|
|
281
|
+
* @param firstTurn true when this turn STARTED the thread — its printed
|
|
282
|
+
* figure is per-turn by construction
|
|
283
|
+
*/
|
|
284
|
+
export declare function codexTurnUsage(tracker: CodexTurnTracker | null, reported: CodexTokenTotals | null, firstTurn: boolean): CodexTurnUsage | null;
|