@agentdeck/bridge 1.0.21 → 1.0.22
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/dist/ble-sync-spawn.d.ts +27 -0
- package/dist/ble-sync-spawn.d.ts.map +1 -1
- package/dist/ble-sync-spawn.js +32 -0
- package/dist/ble-sync-spawn.js.map +1 -1
- package/dist/bridge-core.d.ts +21 -4
- package/dist/bridge-core.d.ts.map +1 -1
- package/dist/bridge-core.js +52 -23
- package/dist/bridge-core.js.map +1 -1
- package/dist/cli.d.ts.map +1 -1
- package/dist/cli.js +13 -0
- package/dist/cli.js.map +1 -1
- package/dist/codex-rate-limits-live.d.ts +58 -9
- package/dist/codex-rate-limits-live.d.ts.map +1 -1
- package/dist/codex-rate-limits-live.js +64 -15
- package/dist/codex-rate-limits-live.js.map +1 -1
- package/dist/codex-rate-limits.d.ts +2 -2
- package/dist/codex-rate-limits.d.ts.map +1 -1
- package/dist/codex-rate-limits.js +34 -16
- package/dist/codex-rate-limits.js.map +1 -1
- package/dist/daemon-server.d.ts +46 -2
- package/dist/daemon-server.d.ts.map +1 -1
- package/dist/daemon-server.js +65 -40
- package/dist/daemon-server.js.map +1 -1
- package/dist/daemon.js +1 -1
- package/dist/hook-server.d.ts.map +1 -1
- package/dist/hook-server.js +17 -0
- package/dist/hook-server.js.map +1 -1
- package/dist/idotmatrix/idotmatrix-daemon-sync.d.ts.map +1 -1
- package/dist/idotmatrix/idotmatrix-daemon-sync.js +13 -1
- package/dist/idotmatrix/idotmatrix-daemon-sync.js.map +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +4 -1
- package/dist/index.js.map +1 -1
- package/dist/python-ble-runtime.d.ts +2 -0
- package/dist/python-ble-runtime.d.ts.map +1 -1
- package/dist/python-ble-runtime.js +101 -7
- package/dist/python-ble-runtime.js.map +1 -1
- package/dist/timebox/timebox-daemon-sync.d.ts.map +1 -1
- package/dist/timebox/timebox-daemon-sync.js +11 -1
- package/dist/timebox/timebox-daemon-sync.js.map +1 -1
- package/dist/usage-api.d.ts +28 -1
- package/dist/usage-api.d.ts.map +1 -1
- package/dist/usage-api.js +74 -33
- package/dist/usage-api.js.map +1 -1
- package/dist/usage-event.d.ts.map +1 -1
- package/dist/usage-event.js +2 -17
- package/dist/usage-event.js.map +1 -1
- package/package.json +3 -3
|
@@ -1,4 +1,26 @@
|
|
|
1
1
|
import type { CodexRateLimits } from '@agentdeck/shared';
|
|
2
|
+
interface RawLiveWindow {
|
|
3
|
+
usedPercent?: number;
|
|
4
|
+
/** The app-server spells the window length differently from the rollout
|
|
5
|
+
* (`windowDurationMins` vs `window_minutes`); accept both. */
|
|
6
|
+
windowDurationMins?: number;
|
|
7
|
+
windowMinutes?: number;
|
|
8
|
+
resetsAt?: number;
|
|
9
|
+
}
|
|
10
|
+
interface RawLiveCredits {
|
|
11
|
+
hasCredits?: boolean;
|
|
12
|
+
unlimited?: boolean;
|
|
13
|
+
balance?: string | number;
|
|
14
|
+
}
|
|
15
|
+
interface RawLiveRateLimits {
|
|
16
|
+
primary?: RawLiveWindow | null;
|
|
17
|
+
secondary?: RawLiveWindow | null;
|
|
18
|
+
planType?: string;
|
|
19
|
+
limitId?: string;
|
|
20
|
+
/** Set only on a limit scoped to one model/feature — see `isModelScopedCodexLimit`. */
|
|
21
|
+
limitName?: string | null;
|
|
22
|
+
credits?: RawLiveCredits | null;
|
|
23
|
+
}
|
|
2
24
|
/**
|
|
3
25
|
* Map an `account/rateLimits/read` result onto the wire shape. `capturedAt` is
|
|
4
26
|
* the instant WE asked — unlike the passive read (which carries the rollout
|
|
@@ -6,6 +28,16 @@ import type { CodexRateLimits } from '@agentdeck/shared';
|
|
|
6
28
|
* what clears the age footnote downstream. Exported for unit testing.
|
|
7
29
|
*/
|
|
8
30
|
export declare function parseLiveCodexRateLimits(result: unknown, capturedAt: string): CodexRateLimits | null;
|
|
31
|
+
/**
|
|
32
|
+
* The account-wide limit block among what `account/rateLimits/read` returned.
|
|
33
|
+
*
|
|
34
|
+
* Prefers the top-level `rateLimits` (what the Codex CLI shows) and falls back
|
|
35
|
+
* to the first unnamed entry of `rateLimitsByLimitId`. Returns null when every
|
|
36
|
+
* family is model-scoped: "no account-wide reading" is the honest answer, and
|
|
37
|
+
* the caller then keeps whatever the rollout path found rather than adopting one
|
|
38
|
+
* model's quota as the account's. Exported for unit testing.
|
|
39
|
+
*/
|
|
40
|
+
export declare function pickAccountWideLiveLimits(top?: RawLiveRateLimits | null, byLimitId?: Record<string, RawLiveRateLimits> | null): RawLiveRateLimits | null;
|
|
9
41
|
/**
|
|
10
42
|
* How to hand the Codex binary to `spawn`.
|
|
11
43
|
*
|
|
@@ -34,27 +66,44 @@ export declare function queryCodexRateLimitsLive(opts?: {
|
|
|
34
66
|
timeoutMs?: number;
|
|
35
67
|
}): Promise<CodexRateLimits | null>;
|
|
36
68
|
/**
|
|
37
|
-
* Choose the
|
|
38
|
-
*
|
|
39
|
-
*
|
|
69
|
+
* Choose between the passive rollout reading and the live app-server reading.
|
|
70
|
+
*
|
|
71
|
+
* Plan agreement first, capture time second (`codexSnapshotOutranks`). Recency
|
|
72
|
+
* alone let the wrong one win in exactly the case the live query exists to
|
|
73
|
+
* cover: a Codex session opened before a plan change keeps writing old-plan
|
|
74
|
+
* rollout snapshots with ever-newer timestamps, so the live answer — correct,
|
|
75
|
+
* current, and the ONLY source carrying the new tier — lost every comparison and
|
|
76
|
+
* was then voided as a mismatch. A snapshot with no `capturedAt` at all loses to
|
|
77
|
+
* a stamped one within its match class; ties keep the passive reading, which is
|
|
78
|
+
* the on-disk ground truth. Exported for unit testing.
|
|
40
79
|
*/
|
|
41
|
-
export declare function
|
|
80
|
+
export declare function pickBestCodexRateLimits(passive: CodexRateLimits | null, live: CodexRateLimits | null, accountPlan?: string): CodexRateLimits | null;
|
|
42
81
|
/** Throttle policy, kept pure so the cadence is testable without spawning. */
|
|
43
82
|
export declare function shouldQueryCodexRateLimitsLive(input: {
|
|
44
83
|
nowMs: number;
|
|
45
84
|
lastAttemptMs: number;
|
|
46
85
|
consecutiveFailures: number;
|
|
47
86
|
passiveCapturedAtMs: number;
|
|
87
|
+
/** False when the passive snapshot is stamped with a plan the account no
|
|
88
|
+
* longer holds — i.e. it is about to be voided and carries no usable number.
|
|
89
|
+
* Defaults to true so callers that know no account tier behave as before. */
|
|
90
|
+
passivePlanMatchesAccount?: boolean;
|
|
48
91
|
}): boolean;
|
|
49
92
|
/** Last live snapshot, or null if none has been obtained. */
|
|
50
93
|
export declare function getLiveCodexRateLimits(): CodexRateLimits | null;
|
|
51
94
|
/**
|
|
52
|
-
* Daemon entry point: return the
|
|
53
|
-
* kick off a throttled background refresh when the passive one has gone quiet
|
|
54
|
-
*
|
|
55
|
-
*
|
|
95
|
+
* Daemon entry point: return the better of the passive and live readings, and
|
|
96
|
+
* kick off a throttled background refresh when the passive one has gone quiet
|
|
97
|
+
* OR has been minted under a plan the account no longer holds. Fire-and-forget
|
|
98
|
+
* by design — the current call is answered from cache so usage building never
|
|
99
|
+
* awaits a subprocess.
|
|
100
|
+
*
|
|
101
|
+
* `accountPlan` is the live tier from `auth.json`. Passing it is what lets both
|
|
102
|
+
* halves of this function tell "old" from "void"; omitting it keeps the previous
|
|
103
|
+
* newest-wins behaviour.
|
|
56
104
|
*/
|
|
57
|
-
export declare function codexRateLimitsWithLiveRefresh(passive: CodexRateLimits | null): CodexRateLimits | null;
|
|
105
|
+
export declare function codexRateLimitsWithLiveRefresh(passive: CodexRateLimits | null, accountPlan?: string): CodexRateLimits | null;
|
|
58
106
|
/** Test hook — clears the module-level cache and throttle state. */
|
|
59
107
|
export declare function __resetCodexRateLimitsLiveForTest(): void;
|
|
108
|
+
export {};
|
|
60
109
|
//# sourceMappingURL=codex-rate-limits-live.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"codex-rate-limits-live.d.ts","sourceRoot":"","sources":["../src/codex-rate-limits-live.ts"],"names":[],"mappings":"
|
|
1
|
+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,MAAM,CAAC;IAAC,KAAK,EAAE,OAAO,CAAA;CAAE,CAGrC;AAED;;;;GAIG;AACH,wBAAsB,wBAAwB,CAC5C,IAAI,GAAE;IAAE,MAAM,CAAC,EAAE,MAAM,CAAC;IAAC,IAAI,CAAC,EAAE,MAAM,EAAE,CAAC;IAAC,SAAS,CAAC,EAAE,MAAM,CAAA;CAAO,GAClE,OAAO,CAAC,eAAe,GAAG,IAAI,CAAC,CAyEjC;AAQD;;;;;;;;;;;GAWG;AACH,wBAAgB,uBAAuB,CACrC,OAAO,EAAE,eAAe,GAAG,IAAI,EAC/B,IAAI,EAAE,eAAe,GAAG,IAAI,EAC5B,WAAW,CAAC,EAAE,MAAM,GACnB,eAAe,GAAG,IAAI,CAUxB;AAED,8EAA8E;AAC9E,wBAAgB,8BAA8B,CAAC,KAAK,EAAE;IACpD,KAAK,EAAE,MAAM,CAAC;IACd,aAAa,EAAE,MAAM,CAAC;IACtB,mBAAmB,EAAE,MAAM,CAAC;IAC5B,mBAAmB,EAAE,MAAM,CAAC;IAC5B;;kFAE8E;IAC9E,yBAAyB,CAAC,EAAE,OAAO,CAAC;CACrC,GAAG,OAAO,CAyBV;AAOD,6DAA6D;AAC7D,wBAAgB,sBAAsB,IAAI,eAAe,GAAG,IAAI,CAE/D;AAED;;;;;;;;;;GAUG;AACH,wBAAgB,8BAA8B,CAC5C,OAAO,EAAE,eAAe,GAAG,IAAI,EAC/B,WAAW,CAAC,EAAE,MAAM,GACnB,eAAe,GAAG,IAAI,CAiCxB;AAED,oEAAoE;AACpE,wBAAgB,iCAAiC,IAAI,IAAI,CAKxD"}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { spawn } from 'child_process';
|
|
2
|
+
import { codexSnapshotMatchesAccountPlan, codexSnapshotOutranks, isModelScopedCodexLimit, } from '@agentdeck/shared';
|
|
2
3
|
/**
|
|
3
4
|
* Active Codex rate-limit read via the local `codex app-server` JSON-RPC.
|
|
4
5
|
*
|
|
@@ -78,7 +79,14 @@ function toCredits(raw) {
|
|
|
78
79
|
* what clears the age footnote downstream. Exported for unit testing.
|
|
79
80
|
*/
|
|
80
81
|
export function parseLiveCodexRateLimits(result, capturedAt) {
|
|
81
|
-
const
|
|
82
|
+
const res = result;
|
|
83
|
+
// The top-level block is the account's today, and that is what the Codex CLI
|
|
84
|
+
// itself presents. But the app-server also returns every family keyed by id,
|
|
85
|
+
// so when the top level is scoped to one model there is still an account-wide
|
|
86
|
+
// answer in the map — take it rather than reporting a single model's quota as
|
|
87
|
+
// the account's. (Not currently reachable; the guard costs one lookup and the
|
|
88
|
+
// alternative is the rollout bug in a place with no second source.)
|
|
89
|
+
const rl = pickAccountWideLiveLimits(res?.rateLimits, res?.rateLimitsByLimitId);
|
|
82
90
|
if (!rl || typeof rl !== 'object')
|
|
83
91
|
return null;
|
|
84
92
|
const primary = toWindow(rl.primary);
|
|
@@ -96,6 +104,24 @@ export function parseLiveCodexRateLimits(result, capturedAt) {
|
|
|
96
104
|
capturedAt,
|
|
97
105
|
};
|
|
98
106
|
}
|
|
107
|
+
/**
|
|
108
|
+
* The account-wide limit block among what `account/rateLimits/read` returned.
|
|
109
|
+
*
|
|
110
|
+
* Prefers the top-level `rateLimits` (what the Codex CLI shows) and falls back
|
|
111
|
+
* to the first unnamed entry of `rateLimitsByLimitId`. Returns null when every
|
|
112
|
+
* family is model-scoped: "no account-wide reading" is the honest answer, and
|
|
113
|
+
* the caller then keeps whatever the rollout path found rather than adopting one
|
|
114
|
+
* model's quota as the account's. Exported for unit testing.
|
|
115
|
+
*/
|
|
116
|
+
export function pickAccountWideLiveLimits(top, byLimitId) {
|
|
117
|
+
if (top && !isModelScopedCodexLimit(top.limitName))
|
|
118
|
+
return top;
|
|
119
|
+
for (const candidate of Object.values(byLimitId ?? {})) {
|
|
120
|
+
if (candidate && !isModelScopedCodexLimit(candidate.limitName))
|
|
121
|
+
return candidate;
|
|
122
|
+
}
|
|
123
|
+
return null;
|
|
124
|
+
}
|
|
99
125
|
function codexBinary() {
|
|
100
126
|
return process.env.AGENTDECK_CODEX_BIN || (process.platform === 'win32' ? 'codex.cmd' : 'codex');
|
|
101
127
|
}
|
|
@@ -204,26 +230,43 @@ function capturedAtMs(rl) {
|
|
|
204
230
|
return isNaN(ms) ? 0 : ms;
|
|
205
231
|
}
|
|
206
232
|
/**
|
|
207
|
-
* Choose the
|
|
208
|
-
*
|
|
209
|
-
*
|
|
233
|
+
* Choose between the passive rollout reading and the live app-server reading.
|
|
234
|
+
*
|
|
235
|
+
* Plan agreement first, capture time second (`codexSnapshotOutranks`). Recency
|
|
236
|
+
* alone let the wrong one win in exactly the case the live query exists to
|
|
237
|
+
* cover: a Codex session opened before a plan change keeps writing old-plan
|
|
238
|
+
* rollout snapshots with ever-newer timestamps, so the live answer — correct,
|
|
239
|
+
* current, and the ONLY source carrying the new tier — lost every comparison and
|
|
240
|
+
* was then voided as a mismatch. A snapshot with no `capturedAt` at all loses to
|
|
241
|
+
* a stamped one within its match class; ties keep the passive reading, which is
|
|
242
|
+
* the on-disk ground truth. Exported for unit testing.
|
|
210
243
|
*/
|
|
211
|
-
export function
|
|
244
|
+
export function pickBestCodexRateLimits(passive, live, accountPlan) {
|
|
212
245
|
if (!live)
|
|
213
246
|
return passive;
|
|
214
247
|
if (!passive)
|
|
215
248
|
return live;
|
|
216
|
-
return
|
|
249
|
+
return codexSnapshotOutranks({ planType: live.planType, capturedAtMs: capturedAtMs(live) }, { planType: passive.planType, capturedAtMs: capturedAtMs(passive) }, accountPlan)
|
|
250
|
+
? live
|
|
251
|
+
: passive;
|
|
217
252
|
}
|
|
218
253
|
/** Throttle policy, kept pure so the cadence is testable without spawning. */
|
|
219
254
|
export function shouldQueryCodexRateLimitsLive(input) {
|
|
220
|
-
const { nowMs, lastAttemptMs, consecutiveFailures, passiveCapturedAtMs } = input;
|
|
255
|
+
const { nowMs, lastAttemptMs, consecutiveFailures, passiveCapturedAtMs, passivePlanMatchesAccount = true, } = input;
|
|
221
256
|
const interval = consecutiveFailures >= MAX_CONSECUTIVE_FAILURES ? FAILURE_BACKOFF_MS : MIN_QUERY_INTERVAL_MS;
|
|
257
|
+
// Spawn throttles are unconditional: a mismatch is a reason to prefer the live
|
|
258
|
+
// read, never a licence to spawn a subprocess on every usage build.
|
|
222
259
|
if (lastAttemptMs > 0 && nowMs - lastAttemptMs < interval)
|
|
223
260
|
return false;
|
|
224
|
-
// Codex is mid-turn: the rollout is already writing fresh readings
|
|
225
|
-
if
|
|
261
|
+
// Codex is mid-turn: the rollout is already writing fresh readings — but only
|
|
262
|
+
// if those readings are usable at all. A snapshot stamped with a retired plan
|
|
263
|
+
// is voided downstream, so "the passive read is fresh" would suppress the one
|
|
264
|
+
// source that still has a number, precisely while Codex is being used hardest.
|
|
265
|
+
if (passivePlanMatchesAccount &&
|
|
266
|
+
passiveCapturedAtMs > 0 &&
|
|
267
|
+
nowMs - passiveCapturedAtMs < PASSIVE_FRESH_MS) {
|
|
226
268
|
return false;
|
|
269
|
+
}
|
|
227
270
|
return true;
|
|
228
271
|
}
|
|
229
272
|
let cachedLive = null;
|
|
@@ -235,12 +278,17 @@ export function getLiveCodexRateLimits() {
|
|
|
235
278
|
return cachedLive;
|
|
236
279
|
}
|
|
237
280
|
/**
|
|
238
|
-
* Daemon entry point: return the
|
|
239
|
-
* kick off a throttled background refresh when the passive one has gone quiet
|
|
240
|
-
*
|
|
241
|
-
*
|
|
281
|
+
* Daemon entry point: return the better of the passive and live readings, and
|
|
282
|
+
* kick off a throttled background refresh when the passive one has gone quiet
|
|
283
|
+
* OR has been minted under a plan the account no longer holds. Fire-and-forget
|
|
284
|
+
* by design — the current call is answered from cache so usage building never
|
|
285
|
+
* awaits a subprocess.
|
|
286
|
+
*
|
|
287
|
+
* `accountPlan` is the live tier from `auth.json`. Passing it is what lets both
|
|
288
|
+
* halves of this function tell "old" from "void"; omitting it keeps the previous
|
|
289
|
+
* newest-wins behaviour.
|
|
242
290
|
*/
|
|
243
|
-
export function codexRateLimitsWithLiveRefresh(passive) {
|
|
291
|
+
export function codexRateLimitsWithLiveRefresh(passive, accountPlan) {
|
|
244
292
|
if (process.env.AGENTDECK_CODEX_LIVE_USAGE !== '0') {
|
|
245
293
|
const nowMs = Date.now();
|
|
246
294
|
if (!inFlight &&
|
|
@@ -249,6 +297,7 @@ export function codexRateLimitsWithLiveRefresh(passive) {
|
|
|
249
297
|
lastAttemptMs,
|
|
250
298
|
consecutiveFailures,
|
|
251
299
|
passiveCapturedAtMs: capturedAtMs(passive),
|
|
300
|
+
passivePlanMatchesAccount: codexSnapshotMatchesAccountPlan(passive?.planType, accountPlan),
|
|
252
301
|
})) {
|
|
253
302
|
inFlight = true;
|
|
254
303
|
lastAttemptMs = nowMs;
|
|
@@ -270,7 +319,7 @@ export function codexRateLimitsWithLiveRefresh(passive) {
|
|
|
270
319
|
});
|
|
271
320
|
}
|
|
272
321
|
}
|
|
273
|
-
return
|
|
322
|
+
return pickBestCodexRateLimits(passive, cachedLive, accountPlan);
|
|
274
323
|
}
|
|
275
324
|
/** Test hook — clears the module-level cache and throttle state. */
|
|
276
325
|
export function __resetCodexRateLimitsLiveForTest() {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"codex-rate-limits-live.js","sourceRoot":"","sources":["../src/codex-rate-limits-live.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,eAAe,CAAC;
|
|
1
|
+
{"version":3,"file":"codex-rate-limits-live.js","sourceRoot":"","sources":["../src/codex-rate-limits-live.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,eAAe,CAAC;AACtC,OAAO,EACL,+BAA+B,EAC/B,qBAAqB,EACrB,uBAAuB,GACxB,MAAM,mBAAmB,CAAC;AAG3B;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6BG;AAEH;oFACoF;AACpF,MAAM,gBAAgB,GAAG,IAAI,CAAC;AAC9B,gFAAgF;AAChF,MAAM,qBAAqB,GAAG,CAAC,GA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,MAAM,UAAU,iCAAiC;IAC/C,UAAU,GAAG,IAAI,CAAC;IAClB,aAAa,GAAG,CAAC,CAAC;IAClB,mBAAmB,GAAG,CAAC,CAAC;IACxB,QAAQ,GAAG,KAAK,CAAC;AACnB,CAAC"}
|
|
@@ -4,7 +4,7 @@ import type { CodexRateLimits } from '@agentdeck/shared';
|
|
|
4
4
|
* Exported (root-injectable) for unit testing; `readCodexRateLimits` wraps this
|
|
5
5
|
* with mtime caching against the live `~/.codex/sessions` tree.
|
|
6
6
|
*/
|
|
7
|
-
export declare function pickCodexRateLimits(root?: string): CodexRateLimits | null;
|
|
7
|
+
export declare function pickCodexRateLimits(root?: string, accountPlan?: string): CodexRateLimits | null;
|
|
8
8
|
/**
|
|
9
9
|
* Parse the newest `rate_limits` snapshot out of a chunk of rollout JSONL text
|
|
10
10
|
* (typically the file tail). Scans lines from the end so the most recent
|
|
@@ -12,5 +12,5 @@ export declare function pickCodexRateLimits(root?: string): CodexRateLimits | nu
|
|
|
12
12
|
* rate-limit line is found.
|
|
13
13
|
*/
|
|
14
14
|
export declare function parseCodexRateLimitsFromText(text: string): CodexRateLimits | null;
|
|
15
|
-
export declare function readCodexRateLimits(root?: string): CodexRateLimits | null;
|
|
15
|
+
export declare function readCodexRateLimits(root?: string, accountPlan?: string): CodexRateLimits | null;
|
|
16
16
|
//# sourceMappingURL=codex-rate-limits.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"codex-rate-limits.d.ts","sourceRoot":"","sources":["../src/codex-rate-limits.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"codex-rate-limits.d.ts","sourceRoot":"","sources":["../src/codex-rate-limits.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAgB,eAAe,EAAwB,MAAM,mBAAmB,CAAC;AAkK7F;;;;GAIG;AACH,wBAAgB,mBAAmB,CACjC,IAAI,GAAE,MAA8B,EACpC,WAAW,CAAC,EAAE,MAAM,GACnB,eAAe,GAAG,IAAI,CAExB;AA0DD;;;;;GAKG;AACH,wBAAgB,4BAA4B,CAAC,IAAI,EAAE,MAAM,GAAG,eAAe,GAAG,IAAI,CAsCjF;AASD,wBAAgB,mBAAmB,CACjC,IAAI,GAAE,MAA8B,EACpC,WAAW,CAAC,EAAE,MAAM,GACnB,eAAe,GAAG,IAAI,CAaxB"}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import fs from 'fs';
|
|
2
2
|
import os from 'os';
|
|
3
3
|
import path from 'path';
|
|
4
|
+
import { codexSnapshotOutranks, isModelScopedCodexLimit } from '@agentdeck/shared';
|
|
4
5
|
const defaultSessionsRoot = () => path.join(os.homedir(), '.codex', 'sessions');
|
|
5
6
|
/** List immediate subdirectory names of `dir`, sorted newest-first (numeric,
|
|
6
7
|
* so "10" > "9"). Returns [] on any read error. */
|
|
@@ -67,17 +68,22 @@ function candidateRolloutFiles(root, maxDays = 3, maxFiles = 6) {
|
|
|
67
68
|
files.sort((a, b) => b.mtime - a.mtime);
|
|
68
69
|
return files.slice(0, maxFiles);
|
|
69
70
|
}
|
|
70
|
-
/** Scan every candidate and return the usable rate-limits snapshot
|
|
71
|
-
* newest CAPTURE timestamp.
|
|
71
|
+
/** Scan every candidate and return the best usable rate-limits snapshot.
|
|
72
72
|
*
|
|
73
73
|
* File mtime only identifies which rollouts are active enough to inspect. It
|
|
74
74
|
* cannot decide which ACCOUNT snapshot is newest when several Codex sessions
|
|
75
75
|
* append concurrently: a reasoning/tool line can make one file newest while
|
|
76
76
|
* its last rate_limits line is older than a snapshot in another file. Choosing
|
|
77
|
-
* the first usable file made usage move backwards or appear frozen.
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
77
|
+
* the first usable file made usage move backwards or appear frozen.
|
|
78
|
+
*
|
|
79
|
+
* `accountPlan` (the live tier from `auth.json`) makes the ranking plan-aware —
|
|
80
|
+
* see `codexSnapshotOutranks`. Without it a Codex session left open across a
|
|
81
|
+
* plan change wins on recency forever with a snapshot that is voided one step
|
|
82
|
+
* later, blanking every gauge while a valid snapshot sits in another rollout.
|
|
83
|
+
* Omitting it (tests, an API-key install with no tier) keeps pure newest-wins. */
|
|
84
|
+
function parseFirstUsable(candidates, accountPlan) {
|
|
85
|
+
let best = null;
|
|
86
|
+
let bestCapturedAtMs = -Infinity;
|
|
81
87
|
for (const { full, mtime } of candidates) {
|
|
82
88
|
const tail = readTail(full);
|
|
83
89
|
const parsed = tail ? parseCodexRateLimitsFromText(tail) : null;
|
|
@@ -89,21 +95,22 @@ function parseFirstUsable(candidates) {
|
|
|
89
95
|
// snapshot this anchor exists to expose. mtime is the fallback.
|
|
90
96
|
parsed.capturedAt = parsed.capturedAt ?? new Date(mtime).toISOString();
|
|
91
97
|
const capturedAtMs = new Date(parsed.capturedAt).getTime();
|
|
92
|
-
if (!
|
|
93
|
-
|
|
94
|
-
|
|
98
|
+
if (!best ||
|
|
99
|
+
codexSnapshotOutranks({ planType: parsed.planType, capturedAtMs }, { planType: best.planType, capturedAtMs: bestCapturedAtMs }, accountPlan)) {
|
|
100
|
+
best = parsed;
|
|
101
|
+
bestCapturedAtMs = capturedAtMs;
|
|
95
102
|
}
|
|
96
103
|
}
|
|
97
104
|
}
|
|
98
|
-
return
|
|
105
|
+
return best;
|
|
99
106
|
}
|
|
100
107
|
/**
|
|
101
108
|
* Read the newest usable Codex rate-limits snapshot from a sessions tree.
|
|
102
109
|
* Exported (root-injectable) for unit testing; `readCodexRateLimits` wraps this
|
|
103
110
|
* with mtime caching against the live `~/.codex/sessions` tree.
|
|
104
111
|
*/
|
|
105
|
-
export function pickCodexRateLimits(root = defaultSessionsRoot()) {
|
|
106
|
-
return parseFirstUsable(candidateRolloutFiles(root));
|
|
112
|
+
export function pickCodexRateLimits(root = defaultSessionsRoot(), accountPlan) {
|
|
113
|
+
return parseFirstUsable(candidateRolloutFiles(root), accountPlan);
|
|
107
114
|
}
|
|
108
115
|
/** Read the trailing bytes of a file without slurping the whole rollout (these
|
|
109
116
|
* can grow to many MB). The newest `rate_limits` line is always near the end. */
|
|
@@ -177,6 +184,13 @@ export function parseCodexRateLimitsFromText(text) {
|
|
|
177
184
|
const rl = obj?.payload?.rate_limits;
|
|
178
185
|
if (!rl)
|
|
179
186
|
continue;
|
|
187
|
+
// A per-model limit is a different QUANTITY, not a staler one, so keep
|
|
188
|
+
// scanning instead of returning it: within one session the family
|
|
189
|
+
// alternates hour to hour, and the account-wide line usually sits further
|
|
190
|
+
// back in this same tail. Returning null for the file would throw that
|
|
191
|
+
// line away along with the scoped one.
|
|
192
|
+
if (isModelScopedCodexLimit(rl.limit_name))
|
|
193
|
+
continue;
|
|
180
194
|
const primary = toWindow(rl.primary);
|
|
181
195
|
const secondary = toWindow(rl.secondary);
|
|
182
196
|
const credits = toCredits(rl.credits);
|
|
@@ -206,12 +220,16 @@ export function parseCodexRateLimitsFromText(text) {
|
|
|
206
220
|
// another candidate remain invisible until the first file changed again.
|
|
207
221
|
let cacheKey = '';
|
|
208
222
|
let cacheValue = null;
|
|
209
|
-
export function readCodexRateLimits(root = defaultSessionsRoot()) {
|
|
223
|
+
export function readCodexRateLimits(root = defaultSessionsRoot(), accountPlan) {
|
|
210
224
|
const candidates = candidateRolloutFiles(root);
|
|
211
|
-
|
|
212
|
-
|
|
225
|
+
// The account tier is part of the key, not just the files: the selection is
|
|
226
|
+
// plan-aware, so the same set of rollouts ranks differently the instant the
|
|
227
|
+
// user's plan changes. Keying on files alone would serve the pre-upgrade
|
|
228
|
+
// winner until some rollout happened to be touched again.
|
|
229
|
+
const key = `${accountPlan ?? ''}|${candidates.map(({ full, mtime }) => `${full}:${mtime}`).join('|')}`;
|
|
230
|
+
if (candidates.length > 0 && key === cacheKey)
|
|
213
231
|
return cacheValue;
|
|
214
|
-
const parsed = parseFirstUsable(candidates);
|
|
232
|
+
const parsed = parseFirstUsable(candidates, accountPlan);
|
|
215
233
|
cacheKey = key;
|
|
216
234
|
cacheValue = parsed;
|
|
217
235
|
return parsed;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"codex-rate-limits.js","sourceRoot":"","sources":["../src/codex-rate-limits.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,IAAI,CAAC;AACpB,OAAO,EAAE,MAAM,IAAI,CAAC;AACpB,OAAO,IAAI,MAAM,MAAM,CAAC;
|
|
1
|
+
{"version":3,"file":"codex-rate-limits.js","sourceRoot":"","sources":["../src/codex-rate-limits.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,IAAI,CAAC;AACpB,OAAO,EAAE,MAAM,IAAI,CAAC;AACpB,OAAO,IAAI,MAAM,MAAM,CAAC;AACxB,OAAO,EAAE,qBAAqB,EAAE,uBAAuB,EAAE,MAAM,mBAAmB,CAAC;AAgDnF,MAAM,mBAAmB,GAAG,GAAW,EAAE,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,CAAC,OAAO,EAAE,EAAE,QAAQ,EAAE,UAAU,CAAC,CAAC;AAOxF;oDACoD;AACpD,SAAS,aAAa,CAAC,GAAW;IAChC,IAAI,CAAC;QACH,OAAO,EAAE;aACN,WAAW,CAAC,GAAG,EAAE,EAAE,aAAa,EAAE,IAAI,EAAE,CAAC;aACzC,MAAM,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,WAAW,EAAE,CAAC;aAC9B,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC;aAClB,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,aAAa,CAAC,CAAC,EAAE,SAAS,EAAE,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC,CAAC,CAAC;IACtE,CAAC;IAAC,MAAM,CAAC;QACP,OAAO,EAAE,CAAC;IACZ,CAAC;AACH,CAAC;AAED;;;2EAG2E;AAC3E,SAAS,aAAa,CAAC,IAAY,EAAE,OAAe;IAClD,MAAM,GAAG,GAAa,EAAE,CAAC;IACzB,KAAK,M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AAG,gBAAgB,CAAC,UAAU,EAAE,WAAW,CAAC,CAAC;IACzD,QAAQ,GAAG,GAAG,CAAC;IACf,UAAU,GAAG,MAAM,CAAC;IACpB,OAAO,MAAM,CAAC;AAChB,CAAC"}
|
package/dist/daemon-server.d.ts
CHANGED
|
@@ -13,7 +13,46 @@
|
|
|
13
13
|
import WebSocket from 'ws';
|
|
14
14
|
import { BridgeCore } from './bridge-core.js';
|
|
15
15
|
import { type DaemonPortSource } from './daemon-port.js';
|
|
16
|
-
import { type
|
|
16
|
+
import { type UsageFetchResult } from './usage-api.js';
|
|
17
|
+
import { FeedPullTracker } from './card-feed.js';
|
|
18
|
+
/** Resolve a stage target (canonical board, registry key, or IP) to the board
|
|
19
|
+
* string the advert is keyed on.
|
|
20
|
+
*
|
|
21
|
+
* This map is read back by `stagedFwAdvert(device_info.board)`, so anything
|
|
22
|
+
* else stored as the key is an advert that can never fire. Staging with an IP
|
|
23
|
+
* is not a misuse to reject — it is the documented way to name one unit when
|
|
24
|
+
* two share a `board` string (see esp32-ota's ambiguity error) — so normalize
|
|
25
|
+
* it here instead. Consequence worth stating: the feed pull carries only a
|
|
26
|
+
* board, so a stage aimed at one unit adverts to every unit of that board.
|
|
27
|
+
* They run the same image, so that is correct rather than merely tolerable.
|
|
28
|
+
*
|
|
29
|
+
* Unlike `findWifiOtaTarget` this must NOT require an open socket: a
|
|
30
|
+
* wake-sync-sleep board holds none by design, which is the entire reason
|
|
31
|
+
* staging exists. An unrecognized target is kept verbatim — staging for a
|
|
32
|
+
* board this daemon has not met yet is legitimate. */
|
|
33
|
+
declare function resolveStagedFwBoard(target: string): string;
|
|
34
|
+
/** Stage a build for a board. Reads the file once to fingerprint it; the file
|
|
35
|
+
* itself is re-read at device download time (a rebuild at the same path is
|
|
36
|
+
* re-fingerprinted by re-staging).
|
|
37
|
+
*
|
|
38
|
+
* `pullSeen` reports whether this daemon has actually observed a feed pull
|
|
39
|
+
* from the board, because "staged" proves neither transfer nor install and a
|
|
40
|
+
* bare success reads as if it did. Only pull-sync firmware fetches a staged
|
|
41
|
+
* image; a board that holds a live WS never asks, so its stage sits forever
|
|
42
|
+
* while the CLI says it is handled. It is daemon-lifetime state, so `false`
|
|
43
|
+
* means "not seen since this daemon started" — not "cannot pull". */
|
|
44
|
+
declare function stageEsp32Fw(target: string, firmwarePath: string): {
|
|
45
|
+
board: string;
|
|
46
|
+
bytes: number;
|
|
47
|
+
md5: string;
|
|
48
|
+
pullSeen: boolean;
|
|
49
|
+
};
|
|
50
|
+
/** The staged advert for a feed response, re-validated against the file on
|
|
51
|
+
* disk so a rebuilt-in-place binary never adverts a stale md5. */
|
|
52
|
+
declare function stagedFwAdvert(board: string | undefined): {
|
|
53
|
+
size: number;
|
|
54
|
+
md5: string;
|
|
55
|
+
} | undefined;
|
|
17
56
|
/**
|
|
18
57
|
* Single-path transport dedup. A physical ESP32 can be reachable over BOTH a
|
|
19
58
|
* USB serial connection and a WiFi WebSocket at once (e.g. inkdeck/ttgo/tc001
|
|
@@ -51,10 +90,15 @@ export declare const __wifiOtaTestApi: {
|
|
|
51
90
|
unregisterWifiEsp32Socket: typeof unregisterWifiEsp32Socket;
|
|
52
91
|
handleEsp32OtaReply: typeof handleEsp32OtaReply;
|
|
53
92
|
performWifiEsp32Ota: typeof performWifiEsp32Ota;
|
|
93
|
+
resolveStagedFwBoard: typeof resolveStagedFwBoard;
|
|
94
|
+
stageEsp32Fw: typeof stageEsp32Fw;
|
|
95
|
+
stagedFwAdvert: typeof stagedFwAdvert;
|
|
96
|
+
feedPulls: FeedPullTracker;
|
|
97
|
+
clearStagedFwForTest: () => void;
|
|
54
98
|
};
|
|
55
99
|
declare function performWifiEsp32Ota(core: BridgeCore, target: string, firmwarePath: string): Promise<Record<string, unknown>>;
|
|
56
100
|
/** @internal Exported for the relay-fallback regression test. */
|
|
57
|
-
export declare function fetchUsageRelayed(selfPort: number): Promise<
|
|
101
|
+
export declare function fetchUsageRelayed(selfPort: number): Promise<UsageFetchResult | null>;
|
|
58
102
|
/**
|
|
59
103
|
* Stamp OpenClaw origin onto a timeline entry emitted by the Gateway adapter.
|
|
60
104
|
*
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"daemon-server.d.ts","sourceRoot":"","sources":["../src/daemon-server.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAIH,OAAO,SAAS,MAAM,IAAI,CAAC;AAC3B,OAAO,EAAE,UAAU,EAA8B,MAAM,kBAAkB,CAAC;AAyH1E,OAAO,EAIL,KAAK,gBAAgB,EACtB,MAAM,kBAAkB,CAAC;AAC1B,OAAO,
|
|
1
|
+
{"version":3,"file":"daemon-server.d.ts","sourceRoot":"","sources":["../src/daemon-server.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAIH,OAAO,SAAS,MAAM,IAAI,CAAC;AAC3B,OAAO,EAAE,UAAU,EAA8B,MAAM,kBAAkB,CAAC;AAyH1E,OAAO,EAIL,KAAK,gBAAgB,EACtB,MAAM,kBAAkB,CAAC;AAC1B,OAAO,EAAiF,KAAK,gBAAgB,EAAE,MAAM,gBAAgB,CAAC;AAuDtI,OAAO,EAC6C,eAAe,EAElE,MAAM,gBAAgB,CAAC;AAkKxB;;;;;;;;;;;;;;uDAcuD;AACvD,iBAAS,oBAAoB,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,CAQpD;AAED;;;;;;;;;sEASsE;AACtE,iBAAS,YAAY,CAAC,MAAM,EAAE,MAAM,EAAE,YAAY,EAAE,MAAM,GAAG;IAAE,KAAK,EAAE,MAAM,CAAC;IAAC,KAAK,EAAE,MAAM,CAAC;IAAC,GAAG,EAAE,MAAM,CAAC;IAAC,QAAQ,EAAE,OAAO,CAAA;CAAE,CAU5H;AAED;mEACmE;AACnE,iBAAS,cAAc,CAAC,KAAK,EAAE,MAAM,GAAG,SAAS,GAAG;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,GAAG,EAAE,MAAM,CAAA;CAAE,GAAG,SAAS,CAg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