sidekick-shared 0.27.5 → 0.28.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 +58 -0
- package/README.md +93 -52
- package/dist/accountHealth.d.ts +14 -0
- package/dist/accountHealth.js +61 -14
- package/dist/accountLaunch.d.ts +6 -0
- package/dist/accountLaunch.js +61 -4
- package/dist/accountLease.d.ts +5 -0
- package/dist/accountLease.js +98 -0
- package/dist/accountManager.d.ts +7 -0
- package/dist/accountManager.js +226 -89
- package/dist/accountSync.d.ts +1 -5
- package/dist/accountSync.js +22 -6
- package/dist/accountSyncTypes.d.ts +9 -0
- package/dist/accounts.d.ts +75 -18
- package/dist/accounts.js +712 -189
- package/dist/browser.d.ts +13 -2
- package/dist/browser.js +30 -2
- package/dist/claudeCredentialDoctor.d.ts +50 -0
- package/dist/claudeCredentialDoctor.js +277 -0
- package/dist/claudeCredentialLedger.d.ts +15 -0
- package/dist/claudeCredentialLedger.js +130 -0
- package/dist/claudeCredentials.d.ts +20 -3
- package/dist/claudeCredentials.js +50 -3
- package/dist/claudeLiveGuard.d.ts +33 -0
- package/dist/claudeLiveGuard.js +46 -0
- package/dist/claudePaths.d.ts +11 -0
- package/dist/claudePaths.js +61 -0
- package/dist/claudeProfiles.d.ts +15 -8
- package/dist/claudeProfiles.js +30 -23
- package/dist/claudeRefreshLock.d.ts +15 -0
- package/dist/claudeRefreshLock.js +145 -0
- package/dist/codexAuth.d.ts +4 -0
- package/dist/codexAuth.js +18 -0
- package/dist/codexCredentialDoctor.d.ts +33 -0
- package/dist/codexCredentialDoctor.js +302 -0
- package/dist/codexCredentialStore.d.ts +29 -0
- package/dist/codexCredentialStore.js +213 -0
- package/dist/codexKeepAlive.d.ts +2 -0
- package/dist/codexKeepAlive.js +116 -0
- package/dist/codexPaths.d.ts +30 -2
- package/dist/codexPaths.js +118 -7
- package/dist/codexProfiles.d.ts +38 -35
- package/dist/codexProfiles.js +848 -715
- package/dist/credentialIO.d.ts +67 -7
- package/dist/credentialIO.js +211 -47
- package/dist/doctor.js +2 -2
- package/dist/ensureDefaultAccounts.js +1 -8
- package/dist/esm/accountChangeSignal.js +15 -0
- package/dist/esm/accountChanges.js +152 -0
- package/dist/esm/accountHealth.js +288 -0
- package/dist/esm/accountLaunch.js +145 -0
- package/dist/esm/accountLease.js +60 -0
- package/dist/esm/accountManager.js +606 -0
- package/dist/esm/accountRegistry.js +214 -0
- package/dist/esm/accountStatus.js +51 -0
- package/dist/esm/accountSwitch.js +74 -0
- package/dist/esm/accountSync.js +156 -0
- package/dist/esm/accountSyncTypes.js +4 -0
- package/dist/esm/accounts.js +1291 -0
- package/dist/esm/aggregation/EventAggregator.js +2034 -0
- package/dist/esm/aggregation/FrequencyTracker.js +69 -0
- package/dist/esm/aggregation/HeatmapTracker.js +89 -0
- package/dist/esm/aggregation/PatternExtractor.js +168 -0
- package/dist/esm/aggregation/costProvenance.js +31 -0
- package/dist/esm/aggregation/snapshot.js +161 -0
- package/dist/esm/aggregation/types.js +5 -0
- package/dist/esm/analytics/codeImpact.js +18 -0
- package/dist/esm/analytics/compactionLedger.js +37 -0
- package/dist/esm/analytics/qualityScore.js +112 -0
- package/dist/esm/autoSwitch.js +185 -0
- package/dist/esm/browser.js +34 -0
- package/dist/esm/claudeCredentialDoctor.js +239 -0
- package/dist/esm/claudeCredentialLedger.js +91 -0
- package/dist/esm/claudeCredentials.js +111 -0
- package/dist/esm/claudeLiveGuard.js +43 -0
- package/dist/esm/claudePaths.js +22 -0
- package/dist/esm/claudeProfiles.js +142 -0
- package/dist/esm/claudeRefreshLock.js +106 -0
- package/dist/esm/codexAuth.js +101 -0
- package/dist/esm/codexCredentialDoctor.js +265 -0
- package/dist/esm/codexCredentialStore.js +164 -0
- package/dist/esm/codexKeepAlive.js +112 -0
- package/dist/esm/codexPaths.js +172 -0
- package/dist/esm/codexProfiles.js +1251 -0
- package/dist/esm/codexQuota.js +564 -0
- package/dist/esm/codexQuotaWatcher.js +363 -0
- package/dist/esm/context/composer.js +71 -0
- package/dist/esm/context/sessionContext.js +546 -0
- package/dist/esm/credentialIO.js +283 -0
- package/dist/esm/credentials.js +49 -0
- package/dist/esm/doctor.js +305 -0
- package/dist/esm/ensureDefaultAccounts.js +62 -0
- package/dist/esm/errorHistory.js +56 -0
- package/dist/esm/extractors/errorTaxonomy.js +43 -0
- package/dist/esm/extractors/gatherAssets.js +32 -0
- package/dist/esm/extractors/sessionAssets.js +176 -0
- package/dist/esm/extractors/sources/claudeAssets.js +158 -0
- package/dist/esm/extractors/sources/codexAssets.js +234 -0
- package/dist/esm/extractors/tokenUsage.js +41 -0
- package/dist/esm/extractors/toolCall.js +142 -0
- package/dist/esm/failingTools.js +65 -0
- package/dist/esm/fileHead.js +27 -0
- package/dist/esm/formatters/eventHighlighter.js +332 -0
- package/dist/esm/formatters/noiseClassifier.js +209 -0
- package/dist/esm/formatters/sessionDump.js +328 -0
- package/dist/esm/formatters/toolSummary.js +226 -0
- package/dist/esm/formatting.js +82 -0
- package/dist/esm/handoffUrl.js +23 -0
- package/dist/esm/historicalStore.js +305 -0
- package/dist/esm/humanPrompt.js +88 -0
- package/dist/esm/index.js +213 -0
- package/dist/esm/keepAlive.js +189 -0
- package/dist/esm/liveCredentialGuard.js +33 -0
- package/dist/esm/modelAliases.js +51 -0
- package/dist/esm/modelCatalog.js +139 -0
- package/dist/esm/modelContext.js +280 -0
- package/dist/esm/modelInfo.js +832 -0
- package/dist/esm/multiProviderQuotaService.js +450 -0
- package/dist/esm/node.js +46 -0
- package/dist/esm/observedContextWindows.js +165 -0
- package/dist/esm/observedSessionCollector.js +939 -0
- package/dist/esm/parsers/changelogParser.js +71 -0
- package/dist/esm/parsers/codexHistory.js +89 -0
- package/dist/esm/parsers/codexParser.js +906 -0
- package/dist/esm/parsers/debugLogParser.js +126 -0
- package/dist/esm/parsers/jsonl.js +66 -0
- package/dist/esm/parsers/mcpToolName.js +28 -0
- package/dist/esm/parsers/openCodeParser.js +625 -0
- package/dist/esm/parsers/planExtractor.js +335 -0
- package/dist/esm/parsers/sessionActivityDetector.js +246 -0
- package/dist/esm/parsers/sessionPathResolver.js +713 -0
- package/dist/esm/parsers/subagentScanner.js +360 -0
- package/dist/esm/parsers/subagentStatsCache.js +45 -0
- package/dist/esm/parsers/subagentTraceParser.js +325 -0
- package/dist/esm/paths.js +134 -0
- package/dist/esm/peakHours.js +194 -0
- package/dist/esm/phrases.js +1330 -0
- package/dist/esm/pricingCatalog.js +247 -0
- package/dist/esm/processDetection.js +200 -0
- package/dist/esm/projectMigration.js +59 -0
- package/dist/esm/promptHistory.js +1221 -0
- package/dist/esm/providerFailure.js +362 -0
- package/dist/esm/providerIds.js +6 -0
- package/dist/esm/providerQuota.js +1 -0
- package/dist/esm/providerServiceStatus.js +145 -0
- package/dist/esm/providerServiceStatusTypes.js +1 -0
- package/dist/esm/providerStatus.js +117 -0
- package/dist/esm/providers/claudeCode.js +575 -0
- package/dist/esm/providers/claudeListing.js +121 -0
- package/dist/esm/providers/codex.js +1034 -0
- package/dist/esm/providers/codexDatabase.js +297 -0
- package/dist/esm/providers/codexRollouts.js +215 -0
- package/dist/esm/providers/detect.js +185 -0
- package/dist/esm/providers/diagnostics.js +83 -0
- package/dist/esm/providers/directoryListingCache.js +206 -0
- package/dist/esm/providers/factory.js +54 -0
- package/dist/esm/providers/openCode.js +2008 -0
- package/dist/esm/providers/openCodeDatabase.js +419 -0
- package/dist/esm/providers/rolloutWalker.js +252 -0
- package/dist/esm/providers/types.js +12 -0
- package/dist/esm/quota.js +182 -0
- package/dist/esm/quotaHistory.js +364 -0
- package/dist/esm/quotaPoller.js +230 -0
- package/dist/esm/quotaPresentation.js +97 -0
- package/dist/esm/quotaResolver.js +231 -0
- package/dist/esm/quotaSnapshots.js +130 -0
- package/dist/esm/quotaThresholds.js +85 -0
- package/dist/esm/readers/decisions.js +24 -0
- package/dist/esm/readers/handoff.js +20 -0
- package/dist/esm/readers/helpers.js +27 -0
- package/dist/esm/readers/history.js +9 -0
- package/dist/esm/readers/notes.js +48 -0
- package/dist/esm/readers/plans.js +225 -0
- package/dist/esm/readers/tasks.js +19 -0
- package/dist/esm/report/htmlHelpers.js +280 -0
- package/dist/esm/report/htmlReportGenerator.js +704 -0
- package/dist/esm/report/index.js +7 -0
- package/dist/esm/report/logo.js +2 -0
- package/dist/esm/report/openBrowser.js +19 -0
- package/dist/esm/report/sessionReportInputs.js +33 -0
- package/dist/esm/report/transcriptParser.js +83 -0
- package/dist/esm/report/types.js +4 -0
- package/dist/esm/schemas/accountManager.js +204 -0
- package/dist/esm/schemas/accountStatus.js +25 -0
- package/dist/esm/schemas/assistantTurn.js +74 -0
- package/dist/esm/schemas/index.js +25 -0
- package/dist/esm/schemas/observedSessionV1.js +77 -0
- package/dist/esm/schemas/providerFailure.js +37 -0
- package/dist/esm/schemas/quota.js +132 -0
- package/dist/esm/schemas/quotaHistory.js +40 -0
- package/dist/esm/schemas/sessionEvent.js +216 -0
- package/dist/esm/schemas/stateFile.js +75 -0
- package/dist/esm/schemas/tokenEstimation.js +7 -0
- package/dist/esm/schemas/transcript.js +86 -0
- package/dist/esm/schemas/usageNormalization.js +38 -0
- package/dist/esm/search/advancedFilter.js +197 -0
- package/dist/esm/search/sessionSearch.js +66 -0
- package/dist/esm/sessionFingerprint.js +40 -0
- package/dist/esm/sessionMonitor.js +198 -0
- package/dist/esm/sessionPreviews.js +522 -0
- package/dist/esm/sessionPromptHistory.js +254 -0
- package/dist/esm/sessionPromptSignals.js +364 -0
- package/dist/esm/sessionStats.js +160 -0
- package/dist/esm/sessionTokenTotals.js +98 -0
- package/dist/esm/sessionTranscripts.js +49 -0
- package/dist/esm/stateFile.js +119 -0
- package/dist/esm/statusline/BurnRateCalculator.js +40 -0
- package/dist/esm/statusline/claudeStatuslinePayload.js +148 -0
- package/dist/esm/statusline/formatter.js +122 -0
- package/dist/esm/statusline/index.js +8 -0
- package/dist/esm/terminalSync.js +95 -0
- package/dist/esm/testing/credentialGuard.js +197 -0
- package/dist/esm/testing/index.js +12 -0
- package/dist/esm/testing/sessionLogFixtures.js +128 -0
- package/dist/esm/tokenEstimation.js +67 -0
- package/dist/esm/tokenSummary.js +113 -0
- package/dist/esm/toolCategory.js +82 -0
- package/dist/esm/transcript.js +257 -0
- package/dist/esm/turns/assistantTurn.js +373 -0
- package/dist/esm/types/codex.js +23 -0
- package/dist/esm/types/decisionLog.js +5 -0
- package/dist/esm/types/historicalData.js +47 -0
- package/dist/esm/types/knowledgeNote.js +15 -0
- package/dist/esm/types/observedSessionV1.js +257 -0
- package/dist/esm/types/opencode.js +12 -0
- package/dist/esm/types/plan.js +7 -0
- package/dist/esm/types/sessionEvent.js +10 -0
- package/dist/esm/types/taskPersistence.js +12 -0
- package/dist/esm/usage/billingBlocks.js +148 -0
- package/dist/esm/usage/claudeUsageDedupe.js +189 -0
- package/dist/esm/usage/importSessionHistory.js +84 -0
- package/dist/esm/usage/subagentUsage.js +18 -0
- package/dist/esm/usage/usageEvents.js +402 -0
- package/dist/esm/usage/usageReports.js +202 -0
- package/dist/esm/usageNormalization.js +95 -0
- package/dist/esm/watchers/eventBridge.js +219 -0
- package/dist/esm/watchers/factory.js +63 -0
- package/dist/esm/watchers/jsonlTail.js +289 -0
- package/dist/esm/watchers/jsonlWatcher.js +435 -0
- package/dist/esm/watchers/providerReaderWatcher.js +118 -0
- package/dist/esm/watchers/sqliteWatcher.js +285 -0
- package/dist/esm/watchers/types.js +4 -0
- package/dist/esm/workspaceRoots.js +56 -0
- package/dist/esm/writers/atomic.js +375 -0
- package/dist/esm/writers/decisions.js +51 -0
- package/dist/esm/writers/notes.js +46 -0
- package/dist/esm/writers/tasks.js +63 -0
- package/dist/esm/zaiQuota.js +323 -0
- package/dist/esm/zaiQuotaApi.js +271 -0
- package/dist/esm/zaiQuotaWatcher.js +265 -0
- package/dist/fileHead.d.ts +22 -0
- package/dist/fileHead.js +33 -0
- package/dist/index.d.ts +30 -11
- package/dist/index.js +72 -15
- package/dist/keepAlive.d.ts +2 -1
- package/dist/keepAlive.js +116 -29
- package/dist/liveCredentialGuard.d.ts +28 -0
- package/dist/liveCredentialGuard.js +36 -0
- package/dist/node.d.ts +13 -1
- package/dist/node.js +43 -2
- package/dist/parsers/codexHistory.js +2 -2
- package/dist/parsers/codexParser.d.ts +12 -0
- package/dist/parsers/codexParser.js +34 -12
- package/dist/parsers/debugLogParser.js +2 -2
- package/dist/parsers/sessionPathResolver.js +5 -4
- package/dist/processDetection.d.ts +10 -3
- package/dist/processDetection.js +44 -11
- package/dist/promptHistory.d.ts +32 -0
- package/dist/promptHistory.js +115 -59
- package/dist/providerFailure.d.ts +12 -6
- package/dist/providerFailure.js +45 -0
- package/dist/providers/claudeCode.js +7 -99
- package/dist/providers/claudeListing.d.ts +22 -0
- package/dist/providers/claudeListing.js +158 -0
- package/dist/providers/codex.d.ts +3 -1
- package/dist/providers/codex.js +26 -227
- package/dist/providers/codexRollouts.d.ts +44 -0
- package/dist/providers/codexRollouts.js +261 -0
- package/dist/providers/detect.js +4 -4
- package/dist/readers/plans.js +3 -3
- package/dist/schemas/accountManager.d.ts +22 -0
- package/dist/schemas/accountManager.js +4 -0
- package/dist/schemas/assistantTurn.d.ts +2 -2
- package/dist/schemas/index.d.ts +2 -0
- package/dist/schemas/index.js +7 -2
- package/dist/schemas/providerFailure.d.ts +154 -0
- package/dist/schemas/providerFailure.js +40 -0
- package/dist/sessionPromptHistory.d.ts +12 -7
- package/dist/sessionPromptHistory.js +15 -3
- package/dist/sessionPromptSignals.d.ts +9 -0
- package/dist/sessionPromptSignals.js +13 -0
- package/dist/terminalSync.d.ts +12 -2
- package/dist/terminalSync.js +27 -2
- package/dist/testing/credentialGuard.d.ts +23 -0
- package/dist/testing/credentialGuard.js +233 -0
- package/dist/testing/index.d.ts +14 -0
- package/dist/testing/index.js +22 -0
- package/dist/testing/sessionLogFixtures.d.ts +28 -0
- package/dist/testing/sessionLogFixtures.js +169 -0
- package/dist/tokenEstimation.d.ts +2 -0
- package/dist/tokenEstimation.js +21 -11
- package/dist/toolCategory.d.ts +18 -0
- package/dist/toolCategory.js +86 -0
- package/dist/types/codex.d.ts +4 -0
- package/dist/usage/usageEvents.d.ts +16 -0
- package/dist/usage/usageEvents.js +53 -9
- package/dist/watchers/jsonlTail.d.ts +26 -1
- package/dist/watchers/jsonlTail.js +136 -28
- package/dist/watchers/jsonlWatcher.js +7 -0
- package/dist/watchers/providerReaderWatcher.js +1 -0
- package/dist/watchers/types.d.ts +6 -0
- package/dist/workspaceRoots.d.ts +23 -0
- package/dist/workspaceRoots.js +93 -0
- package/package.json +22 -2
|
@@ -0,0 +1,265 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Deprecated event-driven watcher that derives a z.ai coding-plan
|
|
3
|
+
* `QuotaState` from observed OpenCode assistant turns.
|
|
4
|
+
*
|
|
5
|
+
* This watcher is retained for compatibility. Product code now uses
|
|
6
|
+
* `zaiQuotaApi.ts` to call z.ai's authoritative quota endpoint. The legacy
|
|
7
|
+
* watcher maintains rolling 5-hour / 7-day windows in memory and recomputes a
|
|
8
|
+
* derived `QuotaState` whenever a new turn arrives. The consumer is
|
|
9
|
+
* responsible for feeding it z.ai-routed assistant turns (and any trapped
|
|
10
|
+
* error events) — typically by subscribing to `SessionMonitor.onSessionEvent`
|
|
11
|
+
* and filtering on `providerID ∈ {zai, zai-coding-plan}`.
|
|
12
|
+
*
|
|
13
|
+
* Optionally writes snapshots + history samples for cross-session cache
|
|
14
|
+
* and trend visualisation, mirroring `CodexQuotaWatcher`.
|
|
15
|
+
*/
|
|
16
|
+
import { appendQuotaHistorySample } from './quotaHistory';
|
|
17
|
+
import { readQuotaSnapshot, writeQuotaSnapshot } from './quotaSnapshots';
|
|
18
|
+
import { accumulateZaiUsage, inferZaiQuotaState, makeUnavailableZaiQuotaState, parseZaiQuotaError, resolveZaiTier, } from './zaiQuota';
|
|
19
|
+
const DEFAULT_ACCOUNT_ID = 'default';
|
|
20
|
+
const DEFAULT_RECOMPUTE_DEBOUNCE_MS = 1_000;
|
|
21
|
+
const DEFAULT_PRUNE_INTERVAL_MS = 60_000;
|
|
22
|
+
const SEVEN_DAY_MS = 7 * 86_400_000;
|
|
23
|
+
function enrichZaiState(state) {
|
|
24
|
+
return {
|
|
25
|
+
...state,
|
|
26
|
+
runtimeProvider: 'zai',
|
|
27
|
+
providerId: 'zai',
|
|
28
|
+
};
|
|
29
|
+
}
|
|
30
|
+
/**
|
|
31
|
+
* Watches z.ai-routed OpenCode activity and emits derived `QuotaState`.
|
|
32
|
+
*
|
|
33
|
+
* The watcher is event-driven (not a poller): call `ingestAssistantTurn`
|
|
34
|
+
* for every observed z.ai assistant turn, and `ingestError` whenever a
|
|
35
|
+
* z.ai business error is observed. The watcher debounces recompute and
|
|
36
|
+
* emits via `onUpdate` / `onQuotaUpdate`.
|
|
37
|
+
*
|
|
38
|
+
* @deprecated Unreachable from every package entrypoint and no longer used by
|
|
39
|
+
* product code. Use `resolveZaiQuota()` from `zaiQuotaApi` instead.
|
|
40
|
+
*/
|
|
41
|
+
export class ZaiQuotaWatcher {
|
|
42
|
+
tier;
|
|
43
|
+
resolveTier;
|
|
44
|
+
readSnapshot;
|
|
45
|
+
writeSnapshot;
|
|
46
|
+
appendHistorySample;
|
|
47
|
+
workspaceId;
|
|
48
|
+
accountId;
|
|
49
|
+
recomputeDebounceMs;
|
|
50
|
+
pruneIntervalMs;
|
|
51
|
+
now;
|
|
52
|
+
listeners = [];
|
|
53
|
+
/** In-memory rolling 7-day buffer of observed turns. */
|
|
54
|
+
turns = [];
|
|
55
|
+
/** Most recent authoritative 5h reset (parsed from a z.ai error event). */
|
|
56
|
+
authoritativeFiveHourResetAt;
|
|
57
|
+
/** Most recent authoritative weekly reset (parsed from a z.ai error event). */
|
|
58
|
+
authoritativeWeeklyResetAt;
|
|
59
|
+
/** Most recent trapped error (so consumers can show "rate-limited until X"). */
|
|
60
|
+
lastError = null;
|
|
61
|
+
lastEmissionKey = null;
|
|
62
|
+
pendingRecomputeTimer;
|
|
63
|
+
pruneTimer;
|
|
64
|
+
running = false;
|
|
65
|
+
constructor(options = {}) {
|
|
66
|
+
this.tier = options.tier ?? 'auto';
|
|
67
|
+
this.resolveTier = options.resolveTier ?? resolveZaiTier;
|
|
68
|
+
this.readSnapshot = options.readSnapshot ?? readQuotaSnapshot;
|
|
69
|
+
this.writeSnapshot = options.writeSnapshot ?? writeQuotaSnapshot;
|
|
70
|
+
this.appendHistorySample = options.appendHistorySample ?? appendQuotaHistorySample;
|
|
71
|
+
this.workspaceId = options.workspaceId;
|
|
72
|
+
this.accountId = options.accountId ?? DEFAULT_ACCOUNT_ID;
|
|
73
|
+
this.recomputeDebounceMs = options.recomputeDebounceMs ?? DEFAULT_RECOMPUTE_DEBOUNCE_MS;
|
|
74
|
+
this.pruneIntervalMs = options.pruneIntervalMs ?? DEFAULT_PRUNE_INTERVAL_MS;
|
|
75
|
+
this.now = options.now ?? Date.now;
|
|
76
|
+
}
|
|
77
|
+
start() {
|
|
78
|
+
if (this.running)
|
|
79
|
+
return;
|
|
80
|
+
this.running = true;
|
|
81
|
+
// Emit cached state immediately so consumers don't show "unavailable"
|
|
82
|
+
// during the gap before the first z.ai turn arrives.
|
|
83
|
+
this.emitCachedOrUnavailable();
|
|
84
|
+
this.pruneTimer = setInterval(() => this.pruneOldTurns(), this.pruneIntervalMs);
|
|
85
|
+
}
|
|
86
|
+
stop() {
|
|
87
|
+
if (!this.running)
|
|
88
|
+
return;
|
|
89
|
+
this.running = false;
|
|
90
|
+
if (this.pendingRecomputeTimer) {
|
|
91
|
+
clearTimeout(this.pendingRecomputeTimer);
|
|
92
|
+
this.pendingRecomputeTimer = undefined;
|
|
93
|
+
}
|
|
94
|
+
if (this.pruneTimer) {
|
|
95
|
+
clearInterval(this.pruneTimer);
|
|
96
|
+
this.pruneTimer = undefined;
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
dispose() {
|
|
100
|
+
this.stop();
|
|
101
|
+
this.listeners.splice(0, this.listeners.length);
|
|
102
|
+
}
|
|
103
|
+
onUpdate(cb) {
|
|
104
|
+
this.listeners.push(cb);
|
|
105
|
+
return {
|
|
106
|
+
dispose: () => {
|
|
107
|
+
const index = this.listeners.indexOf(cb);
|
|
108
|
+
if (index >= 0)
|
|
109
|
+
this.listeners.splice(index, 1);
|
|
110
|
+
},
|
|
111
|
+
};
|
|
112
|
+
}
|
|
113
|
+
onQuotaUpdate(cb) {
|
|
114
|
+
return this.onUpdate(cb);
|
|
115
|
+
}
|
|
116
|
+
/** Feed an observed z.ai assistant turn. Schedules a debounced recompute. */
|
|
117
|
+
ingestAssistantTurn(turn) {
|
|
118
|
+
this.turns.push(turn);
|
|
119
|
+
this.scheduleRecompute();
|
|
120
|
+
}
|
|
121
|
+
/**
|
|
122
|
+
* Feed multiple turns at once (used for cold-start seeding from the DB).
|
|
123
|
+
* Schedules a single debounced recompute.
|
|
124
|
+
*/
|
|
125
|
+
ingestAssistantTurns(turns) {
|
|
126
|
+
for (const turn of turns)
|
|
127
|
+
this.turns.push(turn);
|
|
128
|
+
this.scheduleRecompute();
|
|
129
|
+
}
|
|
130
|
+
/** Feed a z.ai error event. Triggers an immediate recompute + emit. */
|
|
131
|
+
ingestError(error) {
|
|
132
|
+
const parsed = parseZaiQuotaError(error);
|
|
133
|
+
if (!parsed)
|
|
134
|
+
return false;
|
|
135
|
+
this.lastError = parsed;
|
|
136
|
+
if (parsed.resetsAt) {
|
|
137
|
+
// The first observed error after the user crosses a threshold tells
|
|
138
|
+
// us the authoritative window boundary. Apply to whichever window
|
|
139
|
+
// the kind maps to.
|
|
140
|
+
if (parsed.kind === 'exhausted') {
|
|
141
|
+
this.authoritativeFiveHourResetAt = parsed.resetsAt;
|
|
142
|
+
// 1310 is "weekly/monthly exhausted" — also pin the weekly window.
|
|
143
|
+
if (String(parsed.code) === '1310') {
|
|
144
|
+
this.authoritativeWeeklyResetAt = parsed.resetsAt;
|
|
145
|
+
}
|
|
146
|
+
}
|
|
147
|
+
}
|
|
148
|
+
this.scheduleRecompute();
|
|
149
|
+
return true;
|
|
150
|
+
}
|
|
151
|
+
/** Force a recompute+emit now (skipping the debounce). Used by tests. */
|
|
152
|
+
refresh() {
|
|
153
|
+
this.recomputeAndEmit();
|
|
154
|
+
}
|
|
155
|
+
/** Current in-memory turn count (testing/diagnostics). */
|
|
156
|
+
get bufferedTurnCount() {
|
|
157
|
+
return this.turns.length;
|
|
158
|
+
}
|
|
159
|
+
// ── internals ──
|
|
160
|
+
scheduleRecompute() {
|
|
161
|
+
if (!this.running)
|
|
162
|
+
return;
|
|
163
|
+
if (this.pendingRecomputeTimer)
|
|
164
|
+
clearTimeout(this.pendingRecomputeTimer);
|
|
165
|
+
this.pendingRecomputeTimer = setTimeout(() => {
|
|
166
|
+
this.pendingRecomputeTimer = undefined;
|
|
167
|
+
this.recomputeAndEmit();
|
|
168
|
+
}, this.recomputeDebounceMs);
|
|
169
|
+
}
|
|
170
|
+
recomputeAndEmit() {
|
|
171
|
+
const nowMs = this.now();
|
|
172
|
+
if (this.lastError?.resetsAt) {
|
|
173
|
+
const resetsAt = Date.parse(this.lastError.resetsAt);
|
|
174
|
+
if (Number.isFinite(resetsAt) && resetsAt <= nowMs) {
|
|
175
|
+
this.lastError = null;
|
|
176
|
+
}
|
|
177
|
+
}
|
|
178
|
+
const accumulated = accumulateZaiUsage(this.turns, nowMs);
|
|
179
|
+
const tier = this.resolveTier(this.tier, accumulated);
|
|
180
|
+
const state = accumulated.fiveHourTurns > 0 || accumulated.weeklyTurns > 0
|
|
181
|
+
? inferZaiQuotaState(accumulated, tier, {
|
|
182
|
+
capturedAt: new Date(nowMs).toISOString(),
|
|
183
|
+
stale: false,
|
|
184
|
+
authoritativeFiveHourResetAt: this.authoritativeFiveHourResetAt,
|
|
185
|
+
authoritativeWeeklyResetAt: this.authoritativeWeeklyResetAt,
|
|
186
|
+
})
|
|
187
|
+
: makeUnavailableZaiQuotaState(undefined, tier, new Date(nowMs).toISOString());
|
|
188
|
+
// If we recently saw an error, override availability so the UI shows it.
|
|
189
|
+
if (this.lastError) {
|
|
190
|
+
state.error = this.lastError.message;
|
|
191
|
+
state.failureKind = this.lastError.kind === 'expired' ? 'auth' : 'rate_limit';
|
|
192
|
+
state.rateLimitReachedType = this.lastError.kind;
|
|
193
|
+
}
|
|
194
|
+
this.writeSnapshot('zai', this.accountId, state);
|
|
195
|
+
this.maybeAppendHistory(state);
|
|
196
|
+
this.emitState(enrichZaiState(state));
|
|
197
|
+
}
|
|
198
|
+
maybeAppendHistory(state) {
|
|
199
|
+
if (!this.workspaceId)
|
|
200
|
+
return;
|
|
201
|
+
const sample = {
|
|
202
|
+
timestamp: state.capturedAt ?? new Date(this.now()).toISOString(),
|
|
203
|
+
runtimeProvider: 'zai',
|
|
204
|
+
providerId: this.accountId,
|
|
205
|
+
workspaceId: this.workspaceId,
|
|
206
|
+
fiveHour: { utilization: state.fiveHour.utilization, resetsAt: state.fiveHour.resetsAt },
|
|
207
|
+
sevenDay: { utilization: state.sevenDay.utilization, resetsAt: state.sevenDay.resetsAt },
|
|
208
|
+
available: state.available,
|
|
209
|
+
error: state.error,
|
|
210
|
+
source: 'session',
|
|
211
|
+
stale: state.stale,
|
|
212
|
+
};
|
|
213
|
+
try {
|
|
214
|
+
const result = this.appendHistorySample(sample);
|
|
215
|
+
if (result && typeof result.catch === 'function') {
|
|
216
|
+
result.catch(() => {
|
|
217
|
+
// History append must never break the live emission path.
|
|
218
|
+
});
|
|
219
|
+
}
|
|
220
|
+
}
|
|
221
|
+
catch {
|
|
222
|
+
// Synchronous errors swallowed for the same reason.
|
|
223
|
+
}
|
|
224
|
+
}
|
|
225
|
+
emitCachedOrUnavailable() {
|
|
226
|
+
const cached = this.readSnapshot('zai', this.accountId);
|
|
227
|
+
if (cached) {
|
|
228
|
+
this.emitState(enrichZaiState({
|
|
229
|
+
...cached,
|
|
230
|
+
providerId: 'zai',
|
|
231
|
+
source: 'cache',
|
|
232
|
+
stale: true,
|
|
233
|
+
fiveHourLabel: cached.fiveHourLabel ?? '5-Hour',
|
|
234
|
+
sevenDayLabel: cached.sevenDayLabel ?? 'Weekly',
|
|
235
|
+
}));
|
|
236
|
+
return;
|
|
237
|
+
}
|
|
238
|
+
// Initial state with no observations yet.
|
|
239
|
+
const tier = this.tier === 'auto' ? 'lite' : this.tier;
|
|
240
|
+
this.emitState(enrichZaiState(makeUnavailableZaiQuotaState(undefined, tier)));
|
|
241
|
+
}
|
|
242
|
+
emitState(state) {
|
|
243
|
+
const nextKey = JSON.stringify(state);
|
|
244
|
+
if (this.lastEmissionKey === nextKey)
|
|
245
|
+
return;
|
|
246
|
+
this.lastEmissionKey = nextKey;
|
|
247
|
+
for (const listener of this.listeners) {
|
|
248
|
+
try {
|
|
249
|
+
listener(state);
|
|
250
|
+
}
|
|
251
|
+
catch {
|
|
252
|
+
// Listener failures must not stop the watcher.
|
|
253
|
+
}
|
|
254
|
+
}
|
|
255
|
+
}
|
|
256
|
+
pruneOldTurns() {
|
|
257
|
+
const cutoff = this.now() - SEVEN_DAY_MS;
|
|
258
|
+
if (this.turns.length === 0)
|
|
259
|
+
return;
|
|
260
|
+
const next = this.turns.filter((turn) => turn.timestampMs >= cutoff);
|
|
261
|
+
if (next.length !== this.turns.length) {
|
|
262
|
+
this.turns = next;
|
|
263
|
+
}
|
|
264
|
+
}
|
|
265
|
+
}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Rewrite detection shared by the incremental JSONL readers: a file whose
|
|
3
|
+
* first bytes changed, or whose resume point no longer follows a newline,
|
|
4
|
+
* was rewritten rather than appended to.
|
|
5
|
+
*
|
|
6
|
+
* @module fileHead
|
|
7
|
+
*/
|
|
8
|
+
/** How many leading bytes identify a file's content. */
|
|
9
|
+
export declare const HEAD_BYTES = 4096;
|
|
10
|
+
/** The recorded prefix of a file: its length and a hash of it. */
|
|
11
|
+
export interface FileHead {
|
|
12
|
+
bytes: number;
|
|
13
|
+
hash: string;
|
|
14
|
+
}
|
|
15
|
+
export declare function hashHead(buffer: Buffer): string;
|
|
16
|
+
/** Records the prefix just read (at most `HEAD_BYTES`). */
|
|
17
|
+
export declare function fileHeadOf(prefix: Buffer): FileHead;
|
|
18
|
+
/**
|
|
19
|
+
* True when `prefix` (the file's current first bytes) still starts with the
|
|
20
|
+
* recorded head. A file that grew past a short head still matches.
|
|
21
|
+
*/
|
|
22
|
+
export declare function headMatches(known: FileHead, prefix: Buffer): boolean;
|
package/dist/fileHead.js
ADDED
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Rewrite detection shared by the incremental JSONL readers: a file whose
|
|
4
|
+
* first bytes changed, or whose resume point no longer follows a newline,
|
|
5
|
+
* was rewritten rather than appended to.
|
|
6
|
+
*
|
|
7
|
+
* @module fileHead
|
|
8
|
+
*/
|
|
9
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
10
|
+
exports.HEAD_BYTES = void 0;
|
|
11
|
+
exports.hashHead = hashHead;
|
|
12
|
+
exports.fileHeadOf = fileHeadOf;
|
|
13
|
+
exports.headMatches = headMatches;
|
|
14
|
+
const crypto_1 = require("crypto");
|
|
15
|
+
/** How many leading bytes identify a file's content. */
|
|
16
|
+
exports.HEAD_BYTES = 4096;
|
|
17
|
+
function hashHead(buffer) {
|
|
18
|
+
return (0, crypto_1.createHash)('sha256').update(buffer).digest('hex').slice(0, 32);
|
|
19
|
+
}
|
|
20
|
+
/** Records the prefix just read (at most `HEAD_BYTES`). */
|
|
21
|
+
function fileHeadOf(prefix) {
|
|
22
|
+
return { bytes: prefix.length, hash: hashHead(prefix) };
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* True when `prefix` (the file's current first bytes) still starts with the
|
|
26
|
+
* recorded head. A file that grew past a short head still matches.
|
|
27
|
+
*/
|
|
28
|
+
function headMatches(known, prefix) {
|
|
29
|
+
if (!Number.isInteger(known.bytes) || known.bytes < 0 || known.bytes > prefix.length) {
|
|
30
|
+
return false;
|
|
31
|
+
}
|
|
32
|
+
return hashHead(prefix.subarray(0, known.bytes)) === known.hash;
|
|
33
|
+
}
|
package/dist/index.d.ts
CHANGED
|
@@ -5,12 +5,12 @@ export { normalizeProviderUsage, extractNormalizedUsage, calculateNormalizedUsag
|
|
|
5
5
|
export type { UsageProvider, UsageSemantics, UsageNormalizationProvenance, ProviderUsageInput, AnthropicUsageInput, OpenAIUsageInput, SidekickUsageInput, NormalizedUsage, PricingProvenance, NormalizedUsageCostInput, NormalizedUsageCost, } from './usageNormalization';
|
|
6
6
|
export { formatTokenBreakdown, summarizeTokens, sumTokenTotals, TOKEN_CONTEXT_LABEL, TOKEN_MAIN_THREAD_LABEL, TOKEN_SESSION_TOTAL_LABEL, TOKEN_SUBAGENTS_LABEL, TOKEN_TOTAL_LABEL, } from './tokenSummary';
|
|
7
7
|
export type { TokenSummary, TokenTotalsLike } from './tokenSummary';
|
|
8
|
-
export { estimateTextTokens, estimateSerializedTokens } from './tokenEstimation';
|
|
8
|
+
export { ASCII_CHARS_PER_TOKEN, estimateTextTokens, estimateSerializedTokens, } from './tokenEstimation';
|
|
9
9
|
export type { ExactTokenCounterContext, ExactTokenCounter, TokenEstimationMethod, TokenEstimationConfidence, TokenEstimationOptions, TokenEstimate, } from './tokenEstimation';
|
|
10
10
|
export { projectSessionTranscript } from './transcript';
|
|
11
11
|
export type { TranscriptFidelity, TranscriptSourceProvenance, CanonicalTranscriptBlock, CanonicalTranscriptMessage, CanonicalToolCall, CanonicalTranscriptUsageTotals, CanonicalSessionTranscript, ProjectSessionTranscriptOptions, } from './transcript';
|
|
12
12
|
export { listRecentSessions, readSessionTranscript } from './sessionTranscripts';
|
|
13
|
-
export { collectPromptHistory } from './promptHistory';
|
|
13
|
+
export { collectPromptHistory, isPromptHistorySessionSettled, parsePromptHistoryCursor, } from './promptHistory';
|
|
14
14
|
export type { CollectPromptHistoryOptions, PromptHistoryAnswerState, PromptHistoryBound, PromptHistoryBounds, PromptHistoryCursor, PromptHistoryCursorSession, PromptHistoryEntry, PromptHistoryExclusion, PromptHistoryMetadataStatus, PromptHistoryPendingPrompt, PromptHistoryProvider, PromptHistoryResult, PromptHistoryResumeState, PromptHistoryStats, PromptHistoryUsage, } from './promptHistory';
|
|
15
15
|
export { collectSessionPromptHistory } from './sessionPromptHistory';
|
|
16
16
|
export type { CollectSessionPromptHistoryOptions, PromptHistorySession, PromptHistorySessionPrompt, PromptHistorySessionRef, SessionPromptHistoryBound, SessionPromptHistoryBounds, SessionPromptHistoryInclude, SessionPromptHistoryResult, SessionPromptHistoryStats, } from './sessionPromptHistory';
|
|
@@ -88,7 +88,8 @@ export type { FindCodexRolloutFileOptions } from './providers/codex';
|
|
|
88
88
|
export { JsonlParser, TRUNCATION_PATTERNS } from './parsers/jsonl';
|
|
89
89
|
export type { RawSessionEvent, JsonlParserCallbacks, JsonlParserOptions } from './parsers/jsonl';
|
|
90
90
|
export { normalizeToolName, normalizeToolInput, detectPlanModeFromText, convertOpenCodeMessage, parseDbMessageData, parseDbPartData, } from './parsers/openCodeParser';
|
|
91
|
-
export { CodexRolloutParser, extractPatchFilePaths, normalizeCodexToolName, normalizeCodexToolInput, resolveCodexCallUsage, } from './parsers/codexParser';
|
|
91
|
+
export { CodexRolloutParser, DEFAULT_MAX_TRACKED_TOOL_CALLS, extractPatchFilePaths, normalizeCodexToolName, normalizeCodexToolInput, resolveCodexCallUsage, } from './parsers/codexParser';
|
|
92
|
+
export type { CodexRolloutParserOptions } from './parsers/codexParser';
|
|
92
93
|
export { scanSubagentDir, extractTaskInfo, readAgentMeta } from './parsers/subagentScanner';
|
|
93
94
|
export { ClaudeUsageDeduper, SYNTHETIC_MODEL, dedupedRawClaudeUsage, normalizeClaudeUsage, } from './usage/claudeUsageDedupe';
|
|
94
95
|
export { addUsageToSubagent } from './usage/subagentUsage';
|
|
@@ -127,8 +128,8 @@ export type { FollowEvent, FollowEventType, SessionWatcher, SessionWatcherCallba
|
|
|
127
128
|
export { createWatcher, resolveSessionPath } from './watchers/factory';
|
|
128
129
|
export type { CreateWatcherOptions } from './watchers/factory';
|
|
129
130
|
export { toFollowEvents } from './watchers/eventBridge';
|
|
130
|
-
export { createJsonlTail } from './watchers/jsonlTail';
|
|
131
|
-
export type { JsonlTail, JsonlTailBatch, JsonlTailOptions } from './watchers/jsonlTail';
|
|
131
|
+
export { createJsonlTail, DEFAULT_JSONL_TAIL_MAX_LINE_BYTES, DEFAULT_JSONL_TAIL_READ_BYTES, } from './watchers/jsonlTail';
|
|
132
|
+
export type { JsonlTail, JsonlTailBatch, JsonlTailLine, JsonlTailOptions, JsonlTailReset, JsonlTailResetReason, } from './watchers/jsonlTail';
|
|
132
133
|
export { addLocalDays, formatDurationMs, formatLocalDateKey, formatTokenCount, parseLocalDateKey, } from './formatting';
|
|
133
134
|
export type { FormatDurationMsOptions, FormatTokenCountOptions } from './formatting';
|
|
134
135
|
export { formatToolSummary } from './formatters/toolSummary';
|
|
@@ -165,10 +166,17 @@ export { calculateCompactionLedger, formatCompactionLedger } from './analytics/c
|
|
|
165
166
|
export type { CompactionLedger } from './analytics/compactionLedger';
|
|
166
167
|
export { generateHtmlReport, parseTranscript, parseTranscriptFromEvents, openInBrowser, } from './report';
|
|
167
168
|
export type { TranscriptContentBlock, TranscriptEntry, HtmlReportOptions } from './report';
|
|
168
|
-
export { readActiveCredentials, writeActiveCredentials, deleteStoredCredentials, } from './credentialIO';
|
|
169
|
+
export { readActiveCredentials, readClaudeCredentialStore, writeActiveCredentials, deleteStoredCredentials, ClaudeCredentialWriteError, SIDEKICK_KEYCHAIN_COMMENT_PREFIX, } from './credentialIO';
|
|
170
|
+
export type { ClaudeCredentialStoreRead, ClaudeCredentialStoreSource } from './credentialIO';
|
|
171
|
+
export { decideLiveClaudeWrite } from './claudeLiveGuard';
|
|
172
|
+
export type { LiveClaudeStoreState, LiveClaudeWriteDecision, LiveClaudeWriteIntent, LiveClaudeWriteRefusal, LiveClaudeWriteRequest, } from './claudeLiveGuard';
|
|
173
|
+
export { readClaudeCredentialLedger, getClaudeCredentialLedgerPath, } from './claudeCredentialLedger';
|
|
174
|
+
export type { ClaudeCredentialLedgerEntry, ClaudeCredentialHomePurpose, } from './claudeCredentialLedger';
|
|
175
|
+
export { inspectClaudeCredentialStores, repairClaudeCredentialStores, parseKeychainDump, } from './claudeCredentialDoctor';
|
|
176
|
+
export type { ClaudeCredentialFinding, ClaudeCredentialFindingKind, ClaudeCredentialInspection, ClaudeCredentialRepairOutcome, ClaudeCredentialRepairResult, InspectClaudeCredentialStoresOptions, KeychainItemSummary, } from './claudeCredentialDoctor';
|
|
169
177
|
export { readClaudeMaxCredentials, readClaudeMaxCredentialsRaw, readClaudeMaxAccessTokenSync, } from './credentials';
|
|
170
178
|
export type { ClaudeMaxCredentials } from './credentials';
|
|
171
|
-
export { parseClaudeCredentialBlob, claudeCredentialFreshness, isNewerClaudeCredential, resolveClaudeRefreshExpiry, CLAUDE_ACCESS_TOKEN_LIFETIME_MS, CLAUDE_REFRESH_TOKEN_LIFETIME_ESTIMATE_MS, } from './claudeCredentials';
|
|
179
|
+
export { parseClaudeCredentialBlob, claudeCredentialFreshness, isNewerClaudeCredential, resolveClaudeRefreshExpiry, claudeRefreshFingerprint, claudeLoginOnly, mergeClaudeLoginIntoLive, CLAUDE_ACCESS_TOKEN_LIFETIME_MS, CLAUDE_REFRESH_TOKEN_LIFETIME_ESTIMATE_MS, } from './claudeCredentials';
|
|
172
180
|
export type { ClaudeOauthCredentials } from './claudeCredentials';
|
|
173
181
|
export { parseAuthJson as parseCodexAuthJson, readAuthIdentityFromRaw as readCodexAuthIdentity, readLastRefresh as readCodexLastRefresh, readAccessTokenExpiry as readCodexAccessTokenExpiry, identitiesMatch as codexIdentitiesMatch, } from './codexAuth';
|
|
174
182
|
export type { CodexAuthIdentity, CodexAuthJsonFile } from './codexAuth';
|
|
@@ -176,7 +184,7 @@ export { ensureDefaultAccounts } from './ensureDefaultAccounts';
|
|
|
176
184
|
export type { EnsureDefaultAccountStatus, EnsureDefaultAccountsOptions, EnsureDefaultAccountsResult, } from './ensureDefaultAccounts';
|
|
177
185
|
export { readAccountRegistry, writeAccountRegistry, readActiveClaudeAccount, addCurrentAccount, switchToAccount, switchToAccountAsync, syncClaudeLiveState, cleanupAbandonedClaudeLogins, resolveActiveClaudeHome, applyActiveClaudeToLiveHome, reconcileClaudeAuthState, removeAccount, listAccounts, getActiveAccount, resolveActiveClaudeAccount, isMultiAccountEnabled, } from './accounts';
|
|
178
186
|
export type { AccountEntry, AccountRegistry, ActiveAccountInfo, AccountManagerResult, } from './accounts';
|
|
179
|
-
export { beginAccountLogin, getAccountLoginStatus, getAccountLoginStatusAsync, finalizeAccountLogin, finalizeAccountLoginAsync, spawnAccountLogin, switchAccount, switchAccountAsync, undoLastSwitch, getLastSwitch, listAllAccounts, resolveClaudeLoginCommand, } from './accountManager';
|
|
187
|
+
export { beginAccountLogin, getAccountLoginStatus, getAccountLoginStatusAsync, finalizeAccountLogin, finalizeAccountLoginAsync, spawnAccountLogin, switchAccount, switchAccountAsync, undoLastSwitch, getLastSwitch, listAllAccounts, resolveClaudeLoginCommand, discardAccountLogin, } from './accountManager';
|
|
180
188
|
export type { AccountLoginCommand, AccountLoginState, AccountLoginStatus, BeginAccountLoginOptions, BeginAccountLoginResult, BeginAccountLoginSuccess, FinalizeAccountLoginOptions, ListAllAccountsResult, SpawnAccountLoginOptions, } from './accountManager';
|
|
181
189
|
export { readLastSwitch, getLastSwitchPath } from './accountSwitch';
|
|
182
190
|
export type { LastSwitchRecord, SwitchAccountOptions, SwitchAccountResult, SwitchVerification, } from './accountSwitch';
|
|
@@ -198,11 +206,12 @@ export { getActiveAccountStatus } from './accountStatus';
|
|
|
198
206
|
export type { ActiveAccountStatus, ActiveAccountStatusOptions, ActiveProviderAccountStatus, } from './accountStatus';
|
|
199
207
|
export { onAccountsChanged } from './accountChanges';
|
|
200
208
|
export type { AccountsChangedEvent, OnAccountsChangedOptions } from './accountChanges';
|
|
201
|
-
export { getClaudeProfilesDir, getClaudeProfileHome,
|
|
209
|
+
export { getClaudeProfilesDir, getClaudeProfileHome, getClaudeConfigPath, claudeKeychainSuffix, claudeKeychainService, claudeKeychainAccountName, buildClaudeChildEnv, CLAUDE_SECURESTORAGE_CONFIG_DIR_ENV, isClaudeProfileAuthenticated, readClaudeProfileIdentity, readLiveClaudeIdentity, } from './claudeProfiles';
|
|
202
210
|
export type { ClaudeProfileIdentity } from './claudeProfiles';
|
|
211
|
+
export { getLiveClaudeHome, getDefaultClaudeHome, isDefaultClaudeHome, getClaudeProjectsDir, } from './claudePaths';
|
|
203
212
|
export { getCodexProfilesDir, getCodexProfileHome, getCodexMonitoringHomes, getSystemCodexHome, listCodexAccounts, getActiveCodexAccount, resolveActiveCodexAccount, resolveSidekickCodexHome, getCodexExecutionEnv, prepareCodexAccount, prepareCodexAccountAsync, finalizeCodexAccount, finalizeCodexAccountAsync, switchToCodexAccount, switchToCodexAccountAsync, removeCodexAccount, syncCodexLiveState, cleanupAbandonedCodexLogins, getCodexCredentialStoreMode, CODEX_KEYRING_FIX_HINT, } from './codexProfiles';
|
|
204
213
|
export type { CodexAccountManagerResult, CodexCredentialStoreMode } from './codexProfiles';
|
|
205
|
-
export { writeLauncher, removeLauncher } from './terminalSync';
|
|
214
|
+
export { writeAccountLauncher, writeLauncher, removeLauncher } from './terminalSync';
|
|
206
215
|
export { DEFAULT_AUTO_SWITCH_CONFIG, decideAutoSwitch, AutoSwitchController } from './autoSwitch';
|
|
207
216
|
export type { AutoSwitchActiveAccount, AutoSwitchCandidate, AutoSwitchConfig, AutoSwitchControllerOptions, AutoSwitchDecision, AutoSwitchTransitionEvent, } from './autoSwitch';
|
|
208
217
|
export { FIVE_HOUR_WINDOW_MS, QUOTA_PROVIDER_IDS, SEVEN_DAY_WINDOW_MS, fetchQuota, projectQuotaWindow, withQuotaProjections, } from './quota';
|
|
@@ -260,6 +269,7 @@ export type { GatherAssetsOptions, GatherAssetsResult } from './extractors/gathe
|
|
|
260
269
|
export { messageUsageSchema, sessionMessageSchema, sessionEventSchema, permissionModeSchema, extractSessionEvents, } from './schemas/sessionEvent';
|
|
261
270
|
export { quotaWindowSchema, quotaStateSchema, quotaFailureKindSchema, quotaProviderIdSchema, quotaSourceSchema, codexResetCreditSchema, codexResetCreditsSnapshotSchema, peakHoursStateSchema, quotaFailureDescriptorSchema, runtimeQuotaProviderSchema, providerQuotaStateSchema, claudeProviderQuotaStateSchema, codexProviderQuotaStateSchema, zaiProviderQuotaStateSchema, providerQuotaMapSchema, } from './schemas/quota';
|
|
262
271
|
export { quotaHistoryRuntimeProviderSchema, quotaHistorySampleSchema, quotaHistoryDailyBucketSchema, } from './schemas/quotaHistory';
|
|
272
|
+
export { providerAuthenticationEvidenceSchema, providerFailureEvidenceSchema, providerRetryAfterSchema, providerFailureDiagnosisSchema, } from './schemas/providerFailure';
|
|
263
273
|
export { activeProviderAccountStatusSchema, activeAccountStatusSchema, } from './schemas/accountStatus';
|
|
264
274
|
export { accountProviderIdSchema, accountManagerResultSchema, beginAccountLoginResultSchema, accountLoginStatusSchema, accountEntrySchema, savedAccountProfileSchema, listAllAccountsResultSchema, } from './schemas/accountManager';
|
|
265
275
|
export { assistantTurnEventSchema, assistantTurnEventTypeSchema, assistantTurnNarrationStepSchema, assistantTurnProcessSchema, assistantTurnProcessStepSchema, assistantTurnProjectionSchema, assistantTurnReasoningTimelineItemSchema, assistantTurnSubagentSchema, assistantTurnSubagentStatusSchema, assistantTurnTimelineItemSchema, assistantTurnToolGroupStepSchema, assistantTurnToolRefSchema, } from './schemas/assistantTurn';
|
|
@@ -271,7 +281,16 @@ export { _resetPeakHoursCache, createPeakHoursNotApplicableState, DEFAULT_PEAK_H
|
|
|
271
281
|
export type { FetchPeakHoursOptions, PeakHoursState } from './peakHours';
|
|
272
282
|
export { FAILING_TOOL_TREND_ARROWS, failingToolTrend, mergeFailingToolWindows, } from './failingTools';
|
|
273
283
|
export type { FailingToolTrend, FailingToolTrendRow, FailingToolWindow } from './failingTools';
|
|
274
|
-
export { diagnoseProviderFailure } from './providerFailure';
|
|
284
|
+
export { diagnoseProviderFailure, PROVIDER_AUTHENTICATION_SOURCES, PROVIDER_AUTHENTICATION_STATES, PROVIDER_CREDENTIAL_KINDS, PROVIDER_FAILURE_CODES, PROVIDER_FAILURE_EVIDENCE_SOURCES, PROVIDER_RECOVERY_ACTIONS, } from './providerFailure';
|
|
275
285
|
export type { ProviderCredentialKind, ProviderAuthenticationEvidence, ProviderFailureInput, ProviderFailureCode, ProviderRecoveryAction, ProviderRetryAfter, ProviderFailureEvidence, ProviderFailureDiagnosis, } from './providerFailure';
|
|
276
286
|
export type { ProviderServiceSeverity, ProviderServiceComponent, ProviderServiceIncident, ProviderServiceStatusFailureReason, ObservedProviderServiceStatus, UnavailableProviderServiceStatus, ProviderServiceStatus, FetchProviderServiceStatusOptions, } from './providerServiceStatusTypes';
|
|
277
287
|
export { fetchProviderServiceStatus } from './providerServiceStatus';
|
|
288
|
+
export { inspectCodexCredentialStores, repairCodexCredentialStores } from './codexCredentialDoctor';
|
|
289
|
+
export type { CodexCredentialFinding, CodexCredentialInspection, CodexCredentialRepairResult, } from './codexCredentialDoctor';
|
|
290
|
+
export { readStoredCodexAccount, syncCodexLiveStateAsync } from './codexProfiles';
|
|
291
|
+
export { getCodexSessionsDirs, CODEX_SESSIONS_SUBDIR, CODEX_ARCHIVED_SESSIONS_SUBDIR, } from './codexPaths';
|
|
292
|
+
export type { CodexSessionsDirsOptions } from './codexPaths';
|
|
293
|
+
export { classifyTool, TOOL_CATEGORIES } from './toolCategory';
|
|
294
|
+
export type { ClassifyToolOptions, ToolCategory } from './toolCategory';
|
|
295
|
+
export { resolveWorkspaceRoots } from './workspaceRoots';
|
|
296
|
+
export type { ResolveWorkspaceRootsOptions, ResolvedWorkspaceRoots } from './workspaceRoots';
|