shadok-ai 0.19.1 → 0.19.2
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/server.js +8 -6
- package/dist/server.js.map +1 -1
- package/dist/usage.d.ts +26 -19
- package/dist/usage.js +90 -58
- package/dist/usage.js.map +1 -1
- package/package.json +1 -1
package/dist/server.js
CHANGED
|
@@ -49,7 +49,7 @@ import { windowStats } from "./token-stats.js";
|
|
|
49
49
|
import { strandedWorktreePlan } from "./worktree-relocate.js";
|
|
50
50
|
import { detectFork, rootIdOfFile } from "./forktrace.js";
|
|
51
51
|
import { computePace, paceBlock, WINDOW_SEC } from "./pace.js";
|
|
52
|
-
import { getUsage,
|
|
52
|
+
import { getUsage, readOAuthToken } from "./usage.js";
|
|
53
53
|
import { loadChannels, loadGroups, saveGroups, normalizeGroups, ensureMainGroup, mainGroupHeal, upsertChannel, removeChannel, mergeClientChannels, channelWriteAllowed, profilePatch, loadTgGroup, saveTgGroup, saveTgOperators, isHomeChannel, homeAdoptionTarget, resolveSessionTarget, resolveResumeId, resumeTarget, } from "./channels.js";
|
|
54
54
|
import { deliverWithRetry } from "./reload.js";
|
|
55
55
|
import { startTelegram, renameTelegramTopic, closeTelegramTopic, probeToken, isStalePreface, announceLoggedOut, resetLoggedOutNotice, attachmentPrompt, pasteFileName, mediaDir, } from "./telegram.js";
|
|
@@ -177,11 +177,13 @@ function instanceLongLivedToken() {
|
|
|
177
177
|
const t = vault[MAIN_GROUP_ID]?.[MT_CLAUDE_OAUTH_TOKEN_NAME]?.value;
|
|
178
178
|
return typeof t === "string" && t.trim() ? t.trim() : null;
|
|
179
179
|
}
|
|
180
|
-
// The
|
|
181
|
-
// run on (the vault long-lived token)
|
|
182
|
-
//
|
|
183
|
-
//
|
|
184
|
-
|
|
180
|
+
// The candidate Bearers for the usage gauge, in preference order: the account
|
|
181
|
+
// the agents actually run on (the vault long-lived token) FIRST, then the CLI's
|
|
182
|
+
// live store / env. `getUsage` takes the first that actually reports a window —
|
|
183
|
+
// so a long-lived `setup-token` (which authenticates agents but reports no usage)
|
|
184
|
+
// falls through to the env token instead of blanking the gauge. Shared by the
|
|
185
|
+
// /usage endpoint and both pace-guard checks so all three measure one account.
|
|
186
|
+
const usageToken = () => [instanceLongLivedToken(), readOAuthToken()];
|
|
185
187
|
// The server drives channels it manages over its OWN loopback WS (cron fires,
|
|
186
188
|
// parent notifications, the reload nudge — all through `driveChannel`). Those
|
|
187
189
|
// deliveries authenticate as the bootstrap admin, but in multi-tenant the
|