sidekick-shared 0.25.0 → 0.26.1

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.
Files changed (119) hide show
  1. package/CHANGELOG.md +65 -0
  2. package/README.md +50 -3
  3. package/dist/accountChanges.js +22 -3
  4. package/dist/accountRegistry.d.ts +22 -1
  5. package/dist/accountRegistry.js +37 -14
  6. package/dist/accountStatus.d.ts +9 -1
  7. package/dist/accountStatus.js +3 -3
  8. package/dist/accounts.d.ts +3 -1
  9. package/dist/accounts.js +84 -64
  10. package/dist/aggregation/EventAggregator.d.ts +15 -2
  11. package/dist/aggregation/EventAggregator.js +54 -9
  12. package/dist/aggregation/costProvenance.d.ts +14 -0
  13. package/dist/aggregation/costProvenance.js +35 -0
  14. package/dist/aggregation/snapshot.d.ts +13 -2
  15. package/dist/aggregation/snapshot.js +57 -6
  16. package/dist/aggregation/types.d.ts +30 -1
  17. package/dist/analytics/compactionLedger.js +15 -5
  18. package/dist/analytics/qualityScore.js +2 -1
  19. package/dist/browser.d.ts +11 -1
  20. package/dist/browser.js +29 -1
  21. package/dist/codexProfiles.d.ts +3 -1
  22. package/dist/codexProfiles.js +4 -2
  23. package/dist/codexQuota.d.ts +2 -0
  24. package/dist/codexQuota.js +11 -66
  25. package/dist/failingTools.d.ts +37 -0
  26. package/dist/failingTools.js +70 -0
  27. package/dist/formatters/sessionDump.js +13 -7
  28. package/dist/formatting.d.ts +13 -0
  29. package/dist/formatting.js +35 -0
  30. package/dist/historicalStore.d.ts +47 -0
  31. package/dist/historicalStore.js +312 -0
  32. package/dist/index.d.ts +46 -12
  33. package/dist/index.js +112 -24
  34. package/dist/modelContext.js +8 -3
  35. package/dist/modelInfo.js +45 -27
  36. package/dist/node.d.ts +19 -0
  37. package/dist/node.js +47 -1
  38. package/dist/observedContextWindows.d.ts +7 -0
  39. package/dist/observedContextWindows.js +17 -2
  40. package/dist/observedSessionCollector.d.ts +3 -8
  41. package/dist/observedSessionCollector.js +10 -27
  42. package/dist/parsers/sessionActivityDetector.d.ts +24 -2
  43. package/dist/parsers/sessionActivityDetector.js +95 -17
  44. package/dist/parsers/sessionPathResolver.d.ts +11 -0
  45. package/dist/parsers/sessionPathResolver.js +13 -10
  46. package/dist/peakHours.d.ts +34 -3
  47. package/dist/peakHours.js +92 -7
  48. package/dist/pricingCatalog.d.ts +7 -0
  49. package/dist/pricingCatalog.js +8 -5
  50. package/dist/providers/claudeCode.js +11 -96
  51. package/dist/providers/codex.d.ts +2 -0
  52. package/dist/providers/codex.js +94 -259
  53. package/dist/providers/detect.d.ts +2 -0
  54. package/dist/providers/detect.js +29 -24
  55. package/dist/providers/factory.d.ts +6 -0
  56. package/dist/providers/openCode.d.ts +2 -0
  57. package/dist/providers/openCode.js +105 -121
  58. package/dist/providers/rolloutWalker.d.ts +53 -0
  59. package/dist/providers/rolloutWalker.js +209 -0
  60. package/dist/providers/types.d.ts +30 -0
  61. package/dist/quota.d.ts +30 -3
  62. package/dist/quota.js +35 -3
  63. package/dist/quotaHistory.d.ts +1 -1
  64. package/dist/quotaHistory.js +36 -35
  65. package/dist/quotaPresentation.js +17 -5
  66. package/dist/quotaResolver.d.ts +83 -0
  67. package/dist/quotaResolver.js +234 -0
  68. package/dist/quotaSnapshots.d.ts +15 -2
  69. package/dist/quotaSnapshots.js +25 -3
  70. package/dist/quotaThresholds.d.ts +60 -0
  71. package/dist/quotaThresholds.js +90 -0
  72. package/dist/report/htmlReportGenerator.js +10 -4
  73. package/dist/report/sessionReportInputs.d.ts +23 -0
  74. package/dist/report/sessionReportInputs.js +34 -0
  75. package/dist/schemas/index.d.ts +2 -0
  76. package/dist/schemas/index.js +10 -1
  77. package/dist/schemas/quota.d.ts +139 -0
  78. package/dist/schemas/quota.js +17 -2
  79. package/dist/schemas/quotaHistory.d.ts +1 -0
  80. package/dist/schemas/quotaHistory.js +1 -1
  81. package/dist/schemas/sessionEvent.d.ts +6 -0
  82. package/dist/schemas/sessionEvent.js +1 -0
  83. package/dist/schemas/stateFile.d.ts +198 -0
  84. package/dist/schemas/stateFile.js +77 -0
  85. package/dist/schemas/transcript.js +2 -0
  86. package/dist/sessionFingerprint.d.ts +25 -0
  87. package/dist/sessionFingerprint.js +46 -0
  88. package/dist/sessionPreviews.d.ts +7 -1
  89. package/dist/sessionPreviews.js +15 -3
  90. package/dist/sessionStats.d.ts +51 -0
  91. package/dist/sessionStats.js +166 -0
  92. package/dist/stateFile.d.ts +113 -0
  93. package/dist/stateFile.js +160 -0
  94. package/dist/statusline/claudeStatuslinePayload.d.ts +89 -0
  95. package/dist/statusline/claudeStatuslinePayload.js +152 -0
  96. package/dist/statusline/formatter.d.ts +13 -0
  97. package/dist/statusline/formatter.js +48 -6
  98. package/dist/statusline/index.d.ts +10 -2
  99. package/dist/statusline/index.js +19 -1
  100. package/dist/tokenSummary.d.ts +62 -0
  101. package/dist/tokenSummary.js +72 -0
  102. package/dist/transcript.d.ts +5 -0
  103. package/dist/transcript.js +2 -0
  104. package/dist/types/observedSessionV1.d.ts +2 -0
  105. package/dist/types/observedSessionV1.js +75 -18
  106. package/dist/types/sessionEvent.d.ts +2 -0
  107. package/dist/usage/billingBlocks.d.ts +85 -0
  108. package/dist/usage/billingBlocks.js +153 -0
  109. package/dist/usage/importSessionHistory.d.ts +53 -0
  110. package/dist/usage/importSessionHistory.js +88 -0
  111. package/dist/usage/usageEvents.d.ts +92 -0
  112. package/dist/usage/usageEvents.js +322 -0
  113. package/dist/usage/usageReports.d.ts +76 -0
  114. package/dist/usage/usageReports.js +208 -0
  115. package/dist/watchers/factory.d.ts +6 -0
  116. package/dist/watchers/factory.js +30 -25
  117. package/dist/zaiQuotaApi.d.ts +2 -0
  118. package/dist/zaiQuotaApi.js +2 -0
  119. package/package.json +1 -1
@@ -39,6 +39,7 @@ const fs = __importStar(require("fs"));
39
39
  const path = __importStar(require("path"));
40
40
  const paths_1 = require("./paths");
41
41
  const atomic_1 = require("./writers/atomic");
42
+ const quota_1 = require("./quota");
42
43
  const codex_1 = require("./types/codex");
43
44
  function getQuotaSnapshotPath() {
44
45
  return path.join((0, paths_1.getConfigDir)(), 'quota-snapshots.json');
@@ -113,11 +114,17 @@ function writeQuotaSnapshot(providerId, accountId, quota) {
113
114
  const store = readStore();
114
115
  const index = store.snapshots.findIndex((item) => item.providerId === providerId && item.accountId === accountId);
115
116
  const existingQuota = index >= 0 ? store.snapshots[index].quota : undefined;
117
+ // `ageMs`, `freshness`, `stale`, and `capturedSource` are read-time facts: a
118
+ // sample that came back from `readQuotaSnapshot()` and is written again keeps
119
+ // its original source rather than being stored as `cache`.
120
+ const { capturedSource, ...sample } = quota;
121
+ delete sample.ageMs;
122
+ delete sample.freshness;
116
123
  const snapshot = {
117
- ...quota,
124
+ ...sample,
118
125
  providerId,
119
126
  capturedAt: quota.capturedAt ?? new Date().toISOString(),
120
- source: quota.source ?? 'session',
127
+ source: sample.source && sample.source !== 'cache' ? sample.source : (capturedSource ?? 'session'),
121
128
  stale: false,
122
129
  resetCredits: quota.resetCredits ?? (providerId === 'codex' ? existingQuota?.resetCredits : undefined),
123
130
  };
@@ -131,15 +138,30 @@ function writeQuotaSnapshot(providerId, accountId, quota) {
131
138
  writeStore(store);
132
139
  });
133
140
  }
134
- function readQuotaSnapshot(providerId, accountId) {
141
+ /**
142
+ * Read the persisted snapshot for one provider/account.
143
+ *
144
+ * `stale: true` and `source: 'cache'` mean "not a live fetch"; the age of the
145
+ * sample is reported separately as `ageMs` and `freshness` so a reader can
146
+ * tell a ten-second-old snapshot from a two-day-old one, and the original
147
+ * origin is kept as `capturedSource` (`statusline`, `session`, or `api`).
148
+ */
149
+ function readQuotaSnapshot(providerId, accountId, now = new Date()) {
135
150
  const store = readStore();
136
151
  const snapshot = store.snapshots.find((item) => item.providerId === providerId && item.accountId === accountId);
137
152
  if (!snapshot)
138
153
  return null;
154
+ const capturedMs = snapshotTimeMs(snapshot.quota);
155
+ const ageMs = capturedMs > 0 ? Math.max(0, now.getTime() - capturedMs) : undefined;
156
+ const storedSource = snapshot.quota.capturedSource ?? snapshot.quota.source;
157
+ const capturedSource = storedSource && storedSource !== 'cache' ? storedSource : undefined;
139
158
  return {
140
159
  ...snapshot.quota,
141
160
  providerId,
142
161
  source: 'cache',
162
+ ...(capturedSource ? { capturedSource } : {}),
143
163
  stale: true,
164
+ ...(ageMs !== undefined ? { ageMs } : {}),
165
+ freshness: (0, quota_1.classifyQuotaFreshness)(ageMs),
144
166
  };
145
167
  }
@@ -0,0 +1,60 @@
1
+ /**
2
+ * Threshold-crossing detection for subscription quota windows.
3
+ *
4
+ * Pure and host-neutral: the VS Code extension and the CLI dashboard both
5
+ * feed it every quota sample and raise whatever alerts it returns, so a user
6
+ * hears "your five-hour window is at 80%" the same way in both. Alerts fire
7
+ * once per threshold per reset window, on the rising edge; when a window
8
+ * resets the memory resets with it.
9
+ *
10
+ * @module quotaThresholds
11
+ */
12
+ import type { QuotaState } from './quota';
13
+ export type QuotaThresholdWindow = 'fiveHour' | 'sevenDay';
14
+ export interface QuotaThresholdConfig {
15
+ /** Utilization percentages (0–100) that raise an alert for the five-hour window. */
16
+ fiveHour: readonly number[];
17
+ /** Utilization percentages (0–100) that raise an alert for the seven-day window. */
18
+ sevenDay: readonly number[];
19
+ }
20
+ /**
21
+ * Defaults tuned to the two surprises users report: the afternoon five-hour
22
+ * cutoff (warn at 80%, escalate at 95%) and the mid-week weekly cap (90%).
23
+ */
24
+ export declare const DEFAULT_QUOTA_THRESHOLDS: QuotaThresholdConfig;
25
+ interface WindowMemory {
26
+ resetsAt: string;
27
+ /** Highest threshold already alerted for this reset window (0 = none). */
28
+ level: number;
29
+ }
30
+ /** Opaque per-window state; keep it between samples and pass it back in. */
31
+ export interface QuotaAlertMemory {
32
+ fiveHour?: WindowMemory;
33
+ sevenDay?: WindowMemory;
34
+ }
35
+ export interface QuotaThresholdAlert {
36
+ window: QuotaThresholdWindow;
37
+ /** The threshold that was crossed. */
38
+ threshold: number;
39
+ /** Utilization at the time of the sample. */
40
+ utilization: number;
41
+ /** ISO reset time of the window, when known. */
42
+ resetsAt: string;
43
+ /** Escalation hint: the highest configured threshold is `critical`. */
44
+ severity: 'warning' | 'critical';
45
+ }
46
+ export interface QuotaThresholdEvaluation {
47
+ alerts: QuotaThresholdAlert[];
48
+ memory: QuotaAlertMemory;
49
+ }
50
+ /**
51
+ * Compare a quota sample against the thresholds and the alerts already
52
+ * raised. Unavailable samples produce no alerts and leave the memory alone.
53
+ */
54
+ export declare function evaluateQuotaThresholds(quota: QuotaState, config?: QuotaThresholdConfig, memory?: QuotaAlertMemory): QuotaThresholdEvaluation;
55
+ /** One-line, reset-aware message: `Claude five-hour window at 82% (resets 14:00)`. */
56
+ export declare function describeQuotaThresholdAlert(alert: QuotaThresholdAlert, options?: {
57
+ providerLabel?: string;
58
+ now?: Date;
59
+ }): string;
60
+ export {};
@@ -0,0 +1,90 @@
1
+ "use strict";
2
+ /**
3
+ * Threshold-crossing detection for subscription quota windows.
4
+ *
5
+ * Pure and host-neutral: the VS Code extension and the CLI dashboard both
6
+ * feed it every quota sample and raise whatever alerts it returns, so a user
7
+ * hears "your five-hour window is at 80%" the same way in both. Alerts fire
8
+ * once per threshold per reset window, on the rising edge; when a window
9
+ * resets the memory resets with it.
10
+ *
11
+ * @module quotaThresholds
12
+ */
13
+ Object.defineProperty(exports, "__esModule", { value: true });
14
+ exports.DEFAULT_QUOTA_THRESHOLDS = void 0;
15
+ exports.evaluateQuotaThresholds = evaluateQuotaThresholds;
16
+ exports.describeQuotaThresholdAlert = describeQuotaThresholdAlert;
17
+ /**
18
+ * Defaults tuned to the two surprises users report: the afternoon five-hour
19
+ * cutoff (warn at 80%, escalate at 95%) and the mid-week weekly cap (90%).
20
+ */
21
+ exports.DEFAULT_QUOTA_THRESHOLDS = {
22
+ fiveHour: [80, 95],
23
+ sevenDay: [90],
24
+ };
25
+ function sanitizeThresholds(values) {
26
+ return [...new Set(values.filter((v) => Number.isFinite(v) && v > 0 && v <= 100))].sort((a, b) => a - b);
27
+ }
28
+ function evaluateWindow(window, quota, thresholds, previous) {
29
+ const sorted = sanitizeThresholds(thresholds);
30
+ const utilization = Number.isFinite(quota.utilization) ? quota.utilization : 0;
31
+ const resetsAt = quota.resetsAt ?? '';
32
+ let level = 0;
33
+ for (const threshold of sorted)
34
+ if (utilization >= threshold)
35
+ level = threshold;
36
+ const previousLevel = previous && previous.resetsAt === resetsAt ? previous.level : 0;
37
+ const memory = { resetsAt, level: Math.max(level, previousLevel) };
38
+ if (level <= previousLevel)
39
+ return { alert: null, memory };
40
+ return {
41
+ alert: {
42
+ window,
43
+ threshold: level,
44
+ utilization,
45
+ resetsAt,
46
+ severity: level >= sorted[sorted.length - 1] ? 'critical' : 'warning',
47
+ },
48
+ memory,
49
+ };
50
+ }
51
+ /**
52
+ * Compare a quota sample against the thresholds and the alerts already
53
+ * raised. Unavailable samples produce no alerts and leave the memory alone.
54
+ */
55
+ function evaluateQuotaThresholds(quota, config = exports.DEFAULT_QUOTA_THRESHOLDS, memory = {}) {
56
+ if (!quota.available)
57
+ return { alerts: [], memory };
58
+ const fiveHour = evaluateWindow('fiveHour', quota.fiveHour, config.fiveHour, memory.fiveHour);
59
+ const sevenDay = evaluateWindow('sevenDay', quota.sevenDay, config.sevenDay, memory.sevenDay);
60
+ return {
61
+ alerts: [fiveHour.alert, sevenDay.alert].filter((alert) => alert !== null),
62
+ memory: { fiveHour: fiveHour.memory, sevenDay: sevenDay.memory },
63
+ };
64
+ }
65
+ const WINDOW_LABELS = {
66
+ fiveHour: 'five-hour window',
67
+ sevenDay: 'seven-day window',
68
+ };
69
+ function formatResetTime(resetsAt, now) {
70
+ const ms = Date.parse(resetsAt);
71
+ if (!Number.isFinite(ms))
72
+ return null;
73
+ const reset = new Date(ms);
74
+ const sameDay = reset.getFullYear() === now.getFullYear() &&
75
+ reset.getMonth() === now.getMonth() &&
76
+ reset.getDate() === now.getDate();
77
+ return new Intl.DateTimeFormat(undefined, {
78
+ ...(sameDay ? {} : { weekday: 'short' }),
79
+ hour: '2-digit',
80
+ minute: '2-digit',
81
+ hour12: false,
82
+ }).format(reset);
83
+ }
84
+ /** One-line, reset-aware message: `Claude five-hour window at 82% (resets 14:00)`. */
85
+ function describeQuotaThresholdAlert(alert, options = {}) {
86
+ const provider = options.providerLabel ?? 'Claude';
87
+ const reset = formatResetTime(alert.resetsAt, options.now ?? new Date());
88
+ const suffix = reset ? ` (resets ${reset})` : '';
89
+ return `${provider} ${WINDOW_LABELS[alert.window]} at ${Math.round(alert.utilization)}%${suffix}`;
90
+ }
@@ -6,6 +6,8 @@
6
6
  */
7
7
  Object.defineProperty(exports, "__esModule", { value: true });
8
8
  exports.generateHtmlReport = generateHtmlReport;
9
+ const costProvenance_1 = require("../aggregation/costProvenance");
10
+ const tokenSummary_1 = require("../tokenSummary");
9
11
  const htmlHelpers_1 = require("./htmlHelpers");
10
12
  const logo_1 = require("./logo");
11
13
  /**
@@ -14,7 +16,7 @@ const logo_1 = require("./logo");
14
16
  function generateHtmlReport(metrics, transcript, options = {}) {
15
17
  const { sessionFileName, includeThinking = true, includeToolDetail = true, theme = 'dark', } = options;
16
18
  const duration = (0, htmlHelpers_1.formatDuration)(metrics.sessionStartTime, metrics.lastEventTime);
17
- const totalTokens = metrics.tokens.inputTokens + metrics.tokens.outputTokens;
19
+ const totalTokens = (0, tokenSummary_1.summarizeTokens)(metrics.tokens).total;
18
20
  return `<!DOCTYPE html>
19
21
  <html lang="en" data-theme="${theme}">
20
22
  <head>
@@ -430,7 +432,7 @@ function generateStatsCards(metrics, totalTokens, duration) {
430
432
  sub: metrics.sessionStartTime ? (0, htmlHelpers_1.formatTimestamp)(metrics.sessionStartTime) + ' start' : '',
431
433
  },
432
434
  {
433
- label: 'Total Tokens',
435
+ label: tokenSummary_1.TOKEN_TOTAL_LABEL,
434
436
  value: (0, htmlHelpers_1.fmtTokens)(totalTokens),
435
437
  sub: `${(0, htmlHelpers_1.fmtTokens)(metrics.tokens.inputTokens)} in / ${(0, htmlHelpers_1.fmtTokens)(metrics.tokens.outputTokens)} out`,
436
438
  },
@@ -445,8 +447,12 @@ function generateStatsCards(metrics, totalTokens, duration) {
445
447
  sub: `${metrics.toolStats.length} unique tools`,
446
448
  },
447
449
  ];
448
- if (metrics.tokens.reportedCost > 0) {
449
- cards.push({ label: 'Cost', value: (0, htmlHelpers_1.fmtCost)(metrics.tokens.reportedCost), sub: 'reported' });
450
+ if (metrics.tokens.costUsd > 0 || metrics.tokens.unpricedCalls > 0) {
451
+ cards.push({
452
+ label: 'Cost',
453
+ value: metrics.tokens.costUsd > 0 ? (0, htmlHelpers_1.fmtCost)(metrics.tokens.costUsd) : '—',
454
+ sub: (0, htmlHelpers_1.escapeHtml)((0, costProvenance_1.describeCostProvenance)(metrics.tokens)),
455
+ });
450
456
  }
451
457
  return `<div class="container">
452
458
  <div class="stats-grid">
@@ -0,0 +1,23 @@
1
+ /**
2
+ * Everything an HTML session report needs, from one read of the session.
3
+ *
4
+ * `sidekick report`, the CLI dashboard's report action, and the extension used
5
+ * to replay a session through a watcher for metrics and then parse the file a
6
+ * second time for the transcript. This reads the provider's canonical events
7
+ * once and derives both.
8
+ *
9
+ * @module report/sessionReportInputs
10
+ */
11
+ import type { AggregatedMetrics } from '../aggregation/types';
12
+ import type { SessionProviderBase } from '../providers/types';
13
+ import type { SessionEvent } from '../types/sessionEvent';
14
+ import type { TranscriptEntry } from './types';
15
+ export interface SessionReportInputs {
16
+ sessionPath: string;
17
+ /** Canonical provider events, already flushed. */
18
+ events: SessionEvent[];
19
+ metrics: AggregatedMetrics;
20
+ transcript: TranscriptEntry[];
21
+ }
22
+ /** Read a session once and build the aggregator metrics and report transcript from it. */
23
+ export declare function readSessionReportInputs(provider: SessionProviderBase, sessionPath: string): SessionReportInputs;
@@ -0,0 +1,34 @@
1
+ "use strict";
2
+ /**
3
+ * Everything an HTML session report needs, from one read of the session.
4
+ *
5
+ * `sidekick report`, the CLI dashboard's report action, and the extension used
6
+ * to replay a session through a watcher for metrics and then parse the file a
7
+ * second time for the transcript. This reads the provider's canonical events
8
+ * once and derives both.
9
+ *
10
+ * @module report/sessionReportInputs
11
+ */
12
+ Object.defineProperty(exports, "__esModule", { value: true });
13
+ exports.readSessionReportInputs = readSessionReportInputs;
14
+ const EventAggregator_1 = require("../aggregation/EventAggregator");
15
+ const sessionStats_1 = require("../sessionStats");
16
+ const transcriptParser_1 = require("./transcriptParser");
17
+ /** Read a session once and build the aggregator metrics and report transcript from it. */
18
+ function readSessionReportInputs(provider, sessionPath) {
19
+ const reader = provider.createReader(sessionPath);
20
+ const events = reader.readAll();
21
+ reader.flush();
22
+ const aggregator = new EventAggregator_1.EventAggregator({
23
+ providerId: provider.id,
24
+ computeContextSize: (0, sessionStats_1.providerContextSizeFn)(provider),
25
+ });
26
+ for (const event of events)
27
+ aggregator.processEvent(event);
28
+ return {
29
+ sessionPath,
30
+ events,
31
+ metrics: aggregator.getMetrics(),
32
+ transcript: (0, transcriptParser_1.parseTranscriptFromEvents)(events),
33
+ };
34
+ }
@@ -36,3 +36,5 @@ export type { AccountProviderId, SavedAccountProfile } from '../accountRegistry'
36
36
  export type { AccountLoginStatus, BeginAccountLoginResult, ListAllAccountsResult, } from '../accountManager';
37
37
  export { assistantTurnEventSchema, assistantTurnEventTypeSchema, assistantTurnNarrationStepSchema, assistantTurnProcessSchema, assistantTurnProcessStepSchema, assistantTurnProjectionSchema, assistantTurnReasoningTimelineItemSchema, assistantTurnSubagentSchema, assistantTurnSubagentStatusSchema, assistantTurnTimelineItemSchema, assistantTurnToolGroupStepSchema, assistantTurnToolRefSchema, } from './assistantTurn';
38
38
  export type { AssistantTurnEvent, AssistantTurnEventType, AssistantTurnProcess, AssistantTurnProcessStep, AssistantTurnProjection, AssistantTurnSubagent, AssistantTurnSubagentStatus, AssistantTurnTimelineItem, AssistantTurnToolRef, } from '../turns/assistantTurn';
39
+ export { sidekickStateFileSchema, stateFileAccountSchema, stateFileBillingBlockSchema, stateFileContextSchema, stateFileQuotaSchema, stateFileQuotaWindowSchema, stateFileSessionSchema, stateFileWriterSchema, } from './stateFile';
40
+ export type { SidekickStateFile, StateFileAccount, StateFileBillingBlock, StateFileContext, StateFileQuota, StateFileQuotaWindow, StateFileSession, StateFileWriter, } from '../stateFile';
@@ -13,7 +13,7 @@
13
13
  */
14
14
  Object.defineProperty(exports, "__esModule", { value: true });
15
15
  exports.activeAccountStatusSchema = exports.activeProviderAccountStatusSchema = exports.quotaHistoryDailyBucketSchema = exports.quotaHistorySampleSchema = exports.quotaHistoryRuntimeProviderSchema = exports.providerQuotaMapSchema = exports.zaiProviderQuotaStateSchema = exports.codexProviderQuotaStateSchema = exports.claudeProviderQuotaStateSchema = exports.providerQuotaStateSchema = exports.runtimeQuotaProviderSchema = exports.quotaFailureDescriptorSchema = exports.peakHoursStateSchema = exports.codexResetCreditsSnapshotSchema = exports.codexResetCreditSchema = exports.quotaSourceSchema = exports.quotaProviderIdSchema = exports.quotaFailureKindSchema = exports.quotaStateSchema = exports.quotaWindowSchema = exports.sessionEvidenceRefV1Schema = exports.providerSessionAdapterV1Schema = exports.providerCapabilitiesV1Schema = exports.pendingUserRequestV1Schema = exports.observedValueV1Schema = exports.observedAgentSessionV1Schema = exports.observationProvenanceV1Schema = exports.canonicalSessionTranscriptSchema = exports.canonicalTranscriptMessageSchema = exports.canonicalToolCallSchema = exports.canonicalTranscriptBlockSchema = exports.transcriptSourceProvenanceSchema = exports.tokenEstimateSchema = exports.normalizedUsageCostSchema = exports.normalizedUsageSchema = exports.toolResultSessionEventSchema = exports.toolUseSessionEventSchema = exports.systemSessionEventSchema = exports.summarySessionEventSchema = exports.assistantSessionEventSchema = exports.userSessionEventSchema = exports.extractSessionEvents = exports.permissionModeSchema = exports.sessionEventSchema = exports.sessionMessageSchema = exports.messageUsageSchema = exports.SESSION_PROVIDER_IDS = exports.RUNTIME_QUOTA_PROVIDER_IDS = exports.QUOTA_PROVIDER_IDS = exports.ACCOUNT_PROVIDER_IDS = void 0;
16
- exports.assistantTurnToolRefSchema = exports.assistantTurnToolGroupStepSchema = exports.assistantTurnTimelineItemSchema = exports.assistantTurnSubagentStatusSchema = exports.assistantTurnSubagentSchema = exports.assistantTurnReasoningTimelineItemSchema = exports.assistantTurnProjectionSchema = exports.assistantTurnProcessStepSchema = exports.assistantTurnProcessSchema = exports.assistantTurnNarrationStepSchema = exports.assistantTurnEventTypeSchema = exports.assistantTurnEventSchema = exports.listAllAccountsResultSchema = exports.savedAccountProfileSchema = exports.accountEntrySchema = exports.accountLoginStatusSchema = exports.beginAccountLoginResultSchema = exports.accountManagerResultSchema = exports.accountProviderIdSchema = void 0;
16
+ exports.stateFileWriterSchema = exports.stateFileSessionSchema = exports.stateFileQuotaWindowSchema = exports.stateFileQuotaSchema = exports.stateFileContextSchema = exports.stateFileBillingBlockSchema = exports.stateFileAccountSchema = exports.sidekickStateFileSchema = exports.assistantTurnToolRefSchema = exports.assistantTurnToolGroupStepSchema = exports.assistantTurnTimelineItemSchema = exports.assistantTurnSubagentStatusSchema = exports.assistantTurnSubagentSchema = exports.assistantTurnReasoningTimelineItemSchema = exports.assistantTurnProjectionSchema = exports.assistantTurnProcessStepSchema = exports.assistantTurnProcessSchema = exports.assistantTurnNarrationStepSchema = exports.assistantTurnEventTypeSchema = exports.assistantTurnEventSchema = exports.listAllAccountsResultSchema = exports.savedAccountProfileSchema = exports.accountEntrySchema = exports.accountLoginStatusSchema = exports.beginAccountLoginResultSchema = exports.accountManagerResultSchema = exports.accountProviderIdSchema = void 0;
17
17
  var providerIds_1 = require("../providerIds");
18
18
  Object.defineProperty(exports, "ACCOUNT_PROVIDER_IDS", { enumerable: true, get: function () { return providerIds_1.ACCOUNT_PROVIDER_IDS; } });
19
19
  Object.defineProperty(exports, "QUOTA_PROVIDER_IDS", { enumerable: true, get: function () { return providerIds_1.QUOTA_PROVIDER_IDS; } });
@@ -94,3 +94,12 @@ Object.defineProperty(exports, "assistantTurnSubagentStatusSchema", { enumerable
94
94
  Object.defineProperty(exports, "assistantTurnTimelineItemSchema", { enumerable: true, get: function () { return assistantTurn_1.assistantTurnTimelineItemSchema; } });
95
95
  Object.defineProperty(exports, "assistantTurnToolGroupStepSchema", { enumerable: true, get: function () { return assistantTurn_1.assistantTurnToolGroupStepSchema; } });
96
96
  Object.defineProperty(exports, "assistantTurnToolRefSchema", { enumerable: true, get: function () { return assistantTurn_1.assistantTurnToolRefSchema; } });
97
+ var stateFile_1 = require("./stateFile");
98
+ Object.defineProperty(exports, "sidekickStateFileSchema", { enumerable: true, get: function () { return stateFile_1.sidekickStateFileSchema; } });
99
+ Object.defineProperty(exports, "stateFileAccountSchema", { enumerable: true, get: function () { return stateFile_1.stateFileAccountSchema; } });
100
+ Object.defineProperty(exports, "stateFileBillingBlockSchema", { enumerable: true, get: function () { return stateFile_1.stateFileBillingBlockSchema; } });
101
+ Object.defineProperty(exports, "stateFileContextSchema", { enumerable: true, get: function () { return stateFile_1.stateFileContextSchema; } });
102
+ Object.defineProperty(exports, "stateFileQuotaSchema", { enumerable: true, get: function () { return stateFile_1.stateFileQuotaSchema; } });
103
+ Object.defineProperty(exports, "stateFileQuotaWindowSchema", { enumerable: true, get: function () { return stateFile_1.stateFileQuotaWindowSchema; } });
104
+ Object.defineProperty(exports, "stateFileSessionSchema", { enumerable: true, get: function () { return stateFile_1.stateFileSessionSchema; } });
105
+ Object.defineProperty(exports, "stateFileWriterSchema", { enumerable: true, get: function () { return stateFile_1.stateFileWriterSchema; } });
@@ -29,6 +29,17 @@ export declare const quotaSourceSchema: z.ZodEnum<{
29
29
  api: "api";
30
30
  cache: "cache";
31
31
  session: "session";
32
+ statusline: "statusline";
33
+ }>;
34
+ export declare const quotaCapturedSourceSchema: z.ZodEnum<{
35
+ api: "api";
36
+ session: "session";
37
+ statusline: "statusline";
38
+ }>;
39
+ export declare const quotaFreshnessSchema: z.ZodEnum<{
40
+ fresh: "fresh";
41
+ aging: "aging";
42
+ stale: "stale";
32
43
  }>;
33
44
  export declare const codexResetCreditSchema: z.ZodObject<{
34
45
  title: z.ZodOptional<z.ZodString>;
@@ -84,9 +95,21 @@ export declare const quotaStateSchema: z.ZodObject<{
84
95
  api: "api";
85
96
  cache: "cache";
86
97
  session: "session";
98
+ statusline: "statusline";
99
+ }>>;
100
+ capturedSource: z.ZodOptional<z.ZodEnum<{
101
+ api: "api";
102
+ session: "session";
103
+ statusline: "statusline";
87
104
  }>>;
88
105
  capturedAt: z.ZodOptional<z.ZodString>;
89
106
  stale: z.ZodOptional<z.ZodBoolean>;
107
+ ageMs: z.ZodOptional<z.ZodNumber>;
108
+ freshness: z.ZodOptional<z.ZodEnum<{
109
+ fresh: "fresh";
110
+ aging: "aging";
111
+ stale: "stale";
112
+ }>>;
90
113
  fiveHourLabel: z.ZodOptional<z.ZodString>;
91
114
  sevenDayLabel: z.ZodOptional<z.ZodString>;
92
115
  limitId: z.ZodOptional<z.ZodString>;
@@ -131,6 +154,10 @@ export declare const peakHoursStateSchema: z.ZodObject<{
131
154
  updatedAt: z.ZodString;
132
155
  unavailable: z.ZodBoolean;
133
156
  notApplicable: z.ZodOptional<z.ZodBoolean>;
157
+ source: z.ZodOptional<z.ZodEnum<{
158
+ promoclock: "promoclock";
159
+ schedule: "schedule";
160
+ }>>;
134
161
  }, z.core.$strip>;
135
162
  export declare const quotaFailureDescriptorSchema: z.ZodObject<{
136
163
  severity: z.ZodEnum<{
@@ -180,9 +207,21 @@ export declare const providerQuotaStateSchema: z.ZodObject<{
180
207
  api: "api";
181
208
  cache: "cache";
182
209
  session: "session";
210
+ statusline: "statusline";
211
+ }>>;
212
+ capturedSource: z.ZodOptional<z.ZodEnum<{
213
+ api: "api";
214
+ session: "session";
215
+ statusline: "statusline";
183
216
  }>>;
184
217
  capturedAt: z.ZodOptional<z.ZodString>;
185
218
  stale: z.ZodOptional<z.ZodBoolean>;
219
+ ageMs: z.ZodOptional<z.ZodNumber>;
220
+ freshness: z.ZodOptional<z.ZodEnum<{
221
+ fresh: "fresh";
222
+ aging: "aging";
223
+ stale: "stale";
224
+ }>>;
186
225
  fiveHourLabel: z.ZodOptional<z.ZodString>;
187
226
  sevenDayLabel: z.ZodOptional<z.ZodString>;
188
227
  limitId: z.ZodOptional<z.ZodString>;
@@ -228,6 +267,10 @@ export declare const providerQuotaStateSchema: z.ZodObject<{
228
267
  updatedAt: z.ZodString;
229
268
  unavailable: z.ZodBoolean;
230
269
  notApplicable: z.ZodOptional<z.ZodBoolean>;
270
+ source: z.ZodOptional<z.ZodEnum<{
271
+ promoclock: "promoclock";
272
+ schedule: "schedule";
273
+ }>>;
231
274
  }, z.core.$strip>>>;
232
275
  failure: z.ZodOptional<z.ZodNullable<z.ZodObject<{
233
276
  severity: z.ZodEnum<{
@@ -278,9 +321,21 @@ export declare const claudeProviderQuotaStateSchema: z.ZodObject<{
278
321
  api: "api";
279
322
  cache: "cache";
280
323
  session: "session";
324
+ statusline: "statusline";
325
+ }>>;
326
+ capturedSource: z.ZodOptional<z.ZodEnum<{
327
+ api: "api";
328
+ session: "session";
329
+ statusline: "statusline";
281
330
  }>>;
282
331
  capturedAt: z.ZodOptional<z.ZodString>;
283
332
  stale: z.ZodOptional<z.ZodBoolean>;
333
+ ageMs: z.ZodOptional<z.ZodNumber>;
334
+ freshness: z.ZodOptional<z.ZodEnum<{
335
+ fresh: "fresh";
336
+ aging: "aging";
337
+ stale: "stale";
338
+ }>>;
284
339
  fiveHourLabel: z.ZodOptional<z.ZodString>;
285
340
  sevenDayLabel: z.ZodOptional<z.ZodString>;
286
341
  limitId: z.ZodOptional<z.ZodString>;
@@ -326,6 +381,10 @@ export declare const claudeProviderQuotaStateSchema: z.ZodObject<{
326
381
  updatedAt: z.ZodString;
327
382
  unavailable: z.ZodBoolean;
328
383
  notApplicable: z.ZodOptional<z.ZodBoolean>;
384
+ source: z.ZodOptional<z.ZodEnum<{
385
+ promoclock: "promoclock";
386
+ schedule: "schedule";
387
+ }>>;
329
388
  }, z.core.$strip>>>;
330
389
  failure: z.ZodOptional<z.ZodNullable<z.ZodObject<{
331
390
  severity: z.ZodEnum<{
@@ -372,9 +431,21 @@ export declare const codexProviderQuotaStateSchema: z.ZodObject<{
372
431
  api: "api";
373
432
  cache: "cache";
374
433
  session: "session";
434
+ statusline: "statusline";
435
+ }>>;
436
+ capturedSource: z.ZodOptional<z.ZodEnum<{
437
+ api: "api";
438
+ session: "session";
439
+ statusline: "statusline";
375
440
  }>>;
376
441
  capturedAt: z.ZodOptional<z.ZodString>;
377
442
  stale: z.ZodOptional<z.ZodBoolean>;
443
+ ageMs: z.ZodOptional<z.ZodNumber>;
444
+ freshness: z.ZodOptional<z.ZodEnum<{
445
+ fresh: "fresh";
446
+ aging: "aging";
447
+ stale: "stale";
448
+ }>>;
378
449
  fiveHourLabel: z.ZodOptional<z.ZodString>;
379
450
  sevenDayLabel: z.ZodOptional<z.ZodString>;
380
451
  limitId: z.ZodOptional<z.ZodString>;
@@ -420,6 +491,10 @@ export declare const codexProviderQuotaStateSchema: z.ZodObject<{
420
491
  updatedAt: z.ZodString;
421
492
  unavailable: z.ZodBoolean;
422
493
  notApplicable: z.ZodOptional<z.ZodBoolean>;
494
+ source: z.ZodOptional<z.ZodEnum<{
495
+ promoclock: "promoclock";
496
+ schedule: "schedule";
497
+ }>>;
423
498
  }, z.core.$strip>>>;
424
499
  failure: z.ZodOptional<z.ZodNullable<z.ZodObject<{
425
500
  severity: z.ZodEnum<{
@@ -466,9 +541,21 @@ export declare const zaiProviderQuotaStateSchema: z.ZodObject<{
466
541
  api: "api";
467
542
  cache: "cache";
468
543
  session: "session";
544
+ statusline: "statusline";
545
+ }>>;
546
+ capturedSource: z.ZodOptional<z.ZodEnum<{
547
+ api: "api";
548
+ session: "session";
549
+ statusline: "statusline";
469
550
  }>>;
470
551
  capturedAt: z.ZodOptional<z.ZodString>;
471
552
  stale: z.ZodOptional<z.ZodBoolean>;
553
+ ageMs: z.ZodOptional<z.ZodNumber>;
554
+ freshness: z.ZodOptional<z.ZodEnum<{
555
+ fresh: "fresh";
556
+ aging: "aging";
557
+ stale: "stale";
558
+ }>>;
472
559
  fiveHourLabel: z.ZodOptional<z.ZodString>;
473
560
  sevenDayLabel: z.ZodOptional<z.ZodString>;
474
561
  limitId: z.ZodOptional<z.ZodString>;
@@ -514,6 +601,10 @@ export declare const zaiProviderQuotaStateSchema: z.ZodObject<{
514
601
  updatedAt: z.ZodString;
515
602
  unavailable: z.ZodBoolean;
516
603
  notApplicable: z.ZodOptional<z.ZodBoolean>;
604
+ source: z.ZodOptional<z.ZodEnum<{
605
+ promoclock: "promoclock";
606
+ schedule: "schedule";
607
+ }>>;
517
608
  }, z.core.$strip>>>;
518
609
  failure: z.ZodOptional<z.ZodNullable<z.ZodObject<{
519
610
  severity: z.ZodEnum<{
@@ -561,9 +652,21 @@ export declare const providerQuotaMapSchema: z.ZodObject<{
561
652
  api: "api";
562
653
  cache: "cache";
563
654
  session: "session";
655
+ statusline: "statusline";
656
+ }>>;
657
+ capturedSource: z.ZodOptional<z.ZodEnum<{
658
+ api: "api";
659
+ session: "session";
660
+ statusline: "statusline";
564
661
  }>>;
565
662
  capturedAt: z.ZodOptional<z.ZodString>;
566
663
  stale: z.ZodOptional<z.ZodBoolean>;
664
+ ageMs: z.ZodOptional<z.ZodNumber>;
665
+ freshness: z.ZodOptional<z.ZodEnum<{
666
+ fresh: "fresh";
667
+ aging: "aging";
668
+ stale: "stale";
669
+ }>>;
567
670
  fiveHourLabel: z.ZodOptional<z.ZodString>;
568
671
  sevenDayLabel: z.ZodOptional<z.ZodString>;
569
672
  limitId: z.ZodOptional<z.ZodString>;
@@ -609,6 +712,10 @@ export declare const providerQuotaMapSchema: z.ZodObject<{
609
712
  updatedAt: z.ZodString;
610
713
  unavailable: z.ZodBoolean;
611
714
  notApplicable: z.ZodOptional<z.ZodBoolean>;
715
+ source: z.ZodOptional<z.ZodEnum<{
716
+ promoclock: "promoclock";
717
+ schedule: "schedule";
718
+ }>>;
612
719
  }, z.core.$strip>>>;
613
720
  failure: z.ZodOptional<z.ZodNullable<z.ZodObject<{
614
721
  severity: z.ZodEnum<{
@@ -655,9 +762,21 @@ export declare const providerQuotaMapSchema: z.ZodObject<{
655
762
  api: "api";
656
763
  cache: "cache";
657
764
  session: "session";
765
+ statusline: "statusline";
766
+ }>>;
767
+ capturedSource: z.ZodOptional<z.ZodEnum<{
768
+ api: "api";
769
+ session: "session";
770
+ statusline: "statusline";
658
771
  }>>;
659
772
  capturedAt: z.ZodOptional<z.ZodString>;
660
773
  stale: z.ZodOptional<z.ZodBoolean>;
774
+ ageMs: z.ZodOptional<z.ZodNumber>;
775
+ freshness: z.ZodOptional<z.ZodEnum<{
776
+ fresh: "fresh";
777
+ aging: "aging";
778
+ stale: "stale";
779
+ }>>;
661
780
  fiveHourLabel: z.ZodOptional<z.ZodString>;
662
781
  sevenDayLabel: z.ZodOptional<z.ZodString>;
663
782
  limitId: z.ZodOptional<z.ZodString>;
@@ -703,6 +822,10 @@ export declare const providerQuotaMapSchema: z.ZodObject<{
703
822
  updatedAt: z.ZodString;
704
823
  unavailable: z.ZodBoolean;
705
824
  notApplicable: z.ZodOptional<z.ZodBoolean>;
825
+ source: z.ZodOptional<z.ZodEnum<{
826
+ promoclock: "promoclock";
827
+ schedule: "schedule";
828
+ }>>;
706
829
  }, z.core.$strip>>>;
707
830
  failure: z.ZodOptional<z.ZodNullable<z.ZodObject<{
708
831
  severity: z.ZodEnum<{
@@ -749,9 +872,21 @@ export declare const providerQuotaMapSchema: z.ZodObject<{
749
872
  api: "api";
750
873
  cache: "cache";
751
874
  session: "session";
875
+ statusline: "statusline";
876
+ }>>;
877
+ capturedSource: z.ZodOptional<z.ZodEnum<{
878
+ api: "api";
879
+ session: "session";
880
+ statusline: "statusline";
752
881
  }>>;
753
882
  capturedAt: z.ZodOptional<z.ZodString>;
754
883
  stale: z.ZodOptional<z.ZodBoolean>;
884
+ ageMs: z.ZodOptional<z.ZodNumber>;
885
+ freshness: z.ZodOptional<z.ZodEnum<{
886
+ fresh: "fresh";
887
+ aging: "aging";
888
+ stale: "stale";
889
+ }>>;
755
890
  fiveHourLabel: z.ZodOptional<z.ZodString>;
756
891
  sevenDayLabel: z.ZodOptional<z.ZodString>;
757
892
  limitId: z.ZodOptional<z.ZodString>;
@@ -797,6 +932,10 @@ export declare const providerQuotaMapSchema: z.ZodObject<{
797
932
  updatedAt: z.ZodString;
798
933
  unavailable: z.ZodBoolean;
799
934
  notApplicable: z.ZodOptional<z.ZodBoolean>;
935
+ source: z.ZodOptional<z.ZodEnum<{
936
+ promoclock: "promoclock";
937
+ schedule: "schedule";
938
+ }>>;
800
939
  }, z.core.$strip>>>;
801
940
  failure: z.ZodOptional<z.ZodNullable<z.ZodObject<{
802
941
  severity: z.ZodEnum<{