sidekick-shared 0.24.5 → 0.26.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 +92 -0
- package/README.md +205 -52
- package/dist/accountChangeSignal.d.ts +3 -0
- package/dist/accountChangeSignal.js +19 -0
- package/dist/accountChanges.d.ts +21 -0
- package/dist/accountChanges.js +170 -0
- package/dist/accountRegistry.d.ts +25 -2
- package/dist/accountRegistry.js +41 -13
- package/dist/accountStatus.d.ts +9 -1
- package/dist/accountStatus.js +3 -3
- package/dist/accounts.d.ts +3 -1
- package/dist/accounts.js +84 -64
- package/dist/aggregation/EventAggregator.d.ts +15 -2
- package/dist/aggregation/EventAggregator.js +54 -9
- package/dist/aggregation/costProvenance.d.ts +14 -0
- package/dist/aggregation/costProvenance.js +35 -0
- package/dist/aggregation/snapshot.d.ts +13 -2
- package/dist/aggregation/snapshot.js +57 -6
- package/dist/aggregation/types.d.ts +30 -1
- package/dist/analytics/compactionLedger.js +15 -5
- package/dist/analytics/qualityScore.js +2 -1
- package/dist/browser.d.ts +19 -4
- package/dist/browser.js +43 -1
- package/dist/codexProfiles.d.ts +3 -1
- package/dist/codexProfiles.js +4 -2
- package/dist/codexQuota.d.ts +2 -0
- package/dist/codexQuota.js +11 -66
- package/dist/codexQuotaWatcher.d.ts +6 -0
- package/dist/codexQuotaWatcher.js +101 -47
- package/dist/failingTools.d.ts +37 -0
- package/dist/failingTools.js +70 -0
- package/dist/formatters/sessionDump.js +13 -7
- package/dist/formatting.d.ts +13 -0
- package/dist/formatting.js +35 -0
- package/dist/historicalStore.d.ts +47 -0
- package/dist/historicalStore.js +312 -0
- package/dist/index.d.ts +67 -23
- package/dist/index.js +138 -26
- package/dist/modelAliases.d.ts +13 -0
- package/dist/modelAliases.js +58 -0
- package/dist/modelCatalog.d.ts +32 -0
- package/dist/modelCatalog.js +145 -0
- package/dist/modelContext.d.ts +36 -3
- package/dist/modelContext.js +109 -34
- package/dist/modelInfo.d.ts +30 -1
- package/dist/modelInfo.js +116 -26
- package/dist/multiProviderQuotaService.d.ts +8 -0
- package/dist/multiProviderQuotaService.js +64 -3
- package/dist/node.d.ts +23 -4
- package/dist/node.js +50 -1
- package/dist/observedContextWindows.d.ts +7 -0
- package/dist/observedContextWindows.js +17 -2
- package/dist/observedSessionCollector.d.ts +72 -6
- package/dist/observedSessionCollector.js +440 -47
- package/dist/parsers/codexHistory.d.ts +4 -2
- package/dist/parsers/codexHistory.js +9 -2
- package/dist/parsers/sessionActivityDetector.d.ts +28 -0
- package/dist/parsers/sessionActivityDetector.js +110 -15
- package/dist/parsers/sessionPathResolver.d.ts +11 -0
- package/dist/parsers/sessionPathResolver.js +13 -10
- package/dist/peakHours.d.ts +34 -3
- package/dist/peakHours.js +92 -7
- package/dist/pricingCatalog.d.ts +7 -0
- package/dist/pricingCatalog.js +8 -5
- package/dist/providerIds.d.ts +11 -0
- package/dist/providerIds.js +9 -0
- package/dist/providerQuota.d.ts +3 -1
- package/dist/providerQuota.js +3 -0
- package/dist/providers/claudeCode.d.ts +10 -1
- package/dist/providers/claudeCode.js +211 -131
- package/dist/providers/codex.d.ts +20 -1
- package/dist/providers/codex.js +308 -244
- package/dist/providers/codexDatabase.d.ts +9 -0
- package/dist/providers/codexDatabase.js +107 -2
- package/dist/providers/detect.d.ts +2 -0
- package/dist/providers/detect.js +29 -24
- package/dist/providers/diagnostics.d.ts +13 -0
- package/dist/providers/diagnostics.js +88 -0
- package/dist/providers/factory.d.ts +20 -0
- package/dist/providers/factory.js +57 -0
- package/dist/providers/openCode.d.ts +22 -1
- package/dist/providers/openCode.js +460 -126
- package/dist/providers/openCodeDatabase.d.ts +10 -0
- package/dist/providers/openCodeDatabase.js +69 -0
- package/dist/providers/rolloutWalker.d.ts +53 -0
- package/dist/providers/rolloutWalker.js +209 -0
- package/dist/providers/types.d.ts +82 -2
- package/dist/providers/types.js +4 -0
- package/dist/quota.d.ts +34 -4
- package/dist/quota.js +37 -9
- package/dist/quotaHistory.d.ts +3 -2
- package/dist/quotaHistory.js +36 -35
- package/dist/quotaPoller.d.ts +13 -1
- package/dist/quotaPoller.js +65 -3
- package/dist/quotaResolver.d.ts +81 -0
- package/dist/quotaResolver.js +213 -0
- package/dist/quotaSnapshots.d.ts +15 -2
- package/dist/quotaSnapshots.js +25 -3
- package/dist/quotaThresholds.d.ts +60 -0
- package/dist/quotaThresholds.js +90 -0
- package/dist/report/htmlReportGenerator.js +10 -4
- package/dist/report/sessionReportInputs.d.ts +23 -0
- package/dist/report/sessionReportInputs.js +34 -0
- package/dist/schemas/accountManager.d.ts +2 -2
- package/dist/schemas/accountManager.js +2 -4
- package/dist/schemas/accountStatus.d.ts +3 -0
- package/dist/schemas/accountStatus.js +1 -0
- package/dist/schemas/index.d.ts +3 -0
- package/dist/schemas/index.js +16 -2
- package/dist/schemas/observedSessionV1.d.ts +27 -26
- package/dist/schemas/observedSessionV1.js +6 -4
- package/dist/schemas/quota.d.ts +141 -2
- package/dist/schemas/quota.js +20 -8
- package/dist/schemas/quotaHistory.d.ts +3 -2
- package/dist/schemas/quotaHistory.js +1 -1
- package/dist/schemas/sessionEvent.d.ts +6 -0
- package/dist/schemas/sessionEvent.js +1 -0
- package/dist/schemas/stateFile.d.ts +198 -0
- package/dist/schemas/stateFile.js +77 -0
- package/dist/schemas/tokenEstimation.d.ts +1 -1
- package/dist/schemas/transcript.js +2 -0
- package/dist/sessionFingerprint.d.ts +25 -0
- package/dist/sessionFingerprint.js +46 -0
- package/dist/sessionMonitor.d.ts +15 -0
- package/dist/sessionMonitor.js +142 -0
- package/dist/sessionPreviews.d.ts +33 -2
- package/dist/sessionPreviews.js +333 -6
- package/dist/sessionStats.d.ts +51 -0
- package/dist/sessionStats.js +166 -0
- package/dist/stateFile.d.ts +113 -0
- package/dist/stateFile.js +160 -0
- package/dist/statusline/claudeStatuslinePayload.d.ts +89 -0
- package/dist/statusline/claudeStatuslinePayload.js +152 -0
- package/dist/statusline/formatter.d.ts +13 -0
- package/dist/statusline/formatter.js +48 -6
- package/dist/statusline/index.d.ts +10 -2
- package/dist/statusline/index.js +19 -1
- package/dist/tokenSummary.d.ts +62 -0
- package/dist/tokenSummary.js +72 -0
- package/dist/transcript.d.ts +5 -0
- package/dist/transcript.js +2 -0
- package/dist/types/observedSessionV1.d.ts +8 -2
- package/dist/types/observedSessionV1.js +88 -25
- package/dist/types/sessionEvent.d.ts +2 -0
- package/dist/usage/billingBlocks.d.ts +85 -0
- package/dist/usage/billingBlocks.js +153 -0
- package/dist/usage/importSessionHistory.d.ts +53 -0
- package/dist/usage/importSessionHistory.js +88 -0
- package/dist/usage/usageEvents.d.ts +92 -0
- package/dist/usage/usageEvents.js +322 -0
- package/dist/usage/usageReports.d.ts +76 -0
- package/dist/usage/usageReports.js +208 -0
- package/dist/watchers/factory.d.ts +6 -0
- package/dist/watchers/factory.js +30 -25
- package/dist/zaiQuotaApi.d.ts +2 -0
- package/dist/zaiQuotaApi.js +2 -0
- package/package.json +22 -1
|
@@ -0,0 +1,208 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Daily, weekly, monthly, and per-session usage rows bucketed from usage
|
|
4
|
+
* events by the time of each event, so a session that crosses midnight is
|
|
5
|
+
* split across the days it actually ran in. Browser-safe: no Node imports.
|
|
6
|
+
*
|
|
7
|
+
* @module usage/usageReports
|
|
8
|
+
*/
|
|
9
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
10
|
+
exports.weekKey = weekKey;
|
|
11
|
+
exports.usageBucketKey = usageBucketKey;
|
|
12
|
+
exports.bucketUsage = bucketUsage;
|
|
13
|
+
exports.summarizeUsageRows = summarizeUsageRows;
|
|
14
|
+
const costProvenance_1 = require("../aggregation/costProvenance");
|
|
15
|
+
const formatting_1 = require("../formatting");
|
|
16
|
+
function dayParts(ms, utc) {
|
|
17
|
+
const date = new Date(ms);
|
|
18
|
+
return utc
|
|
19
|
+
? {
|
|
20
|
+
year: date.getUTCFullYear(),
|
|
21
|
+
month: date.getUTCMonth(),
|
|
22
|
+
day: date.getUTCDate(),
|
|
23
|
+
weekday: date.getUTCDay(),
|
|
24
|
+
}
|
|
25
|
+
: {
|
|
26
|
+
year: date.getFullYear(),
|
|
27
|
+
month: date.getMonth(),
|
|
28
|
+
day: date.getDate(),
|
|
29
|
+
weekday: date.getDay(),
|
|
30
|
+
};
|
|
31
|
+
}
|
|
32
|
+
function pad(value) {
|
|
33
|
+
return String(value).padStart(2, '0');
|
|
34
|
+
}
|
|
35
|
+
/** The `YYYY-MM-DD` key of the week containing `ms`, starting on `weekStartsOn`. */
|
|
36
|
+
function weekKey(ms, options = {}) {
|
|
37
|
+
const utc = options.utc ?? false;
|
|
38
|
+
const start = options.weekStartsOn ?? 1;
|
|
39
|
+
const parts = dayParts(ms, utc);
|
|
40
|
+
const offset = (parts.weekday - start + 7) % 7;
|
|
41
|
+
if (utc) {
|
|
42
|
+
return new Date(Date.UTC(parts.year, parts.month, parts.day - offset))
|
|
43
|
+
.toISOString()
|
|
44
|
+
.slice(0, 10);
|
|
45
|
+
}
|
|
46
|
+
return (0, formatting_1.formatLocalDateKey)(new Date(parts.year, parts.month, parts.day - offset));
|
|
47
|
+
}
|
|
48
|
+
/** The time key for one event at the requested granularity. */
|
|
49
|
+
function usageBucketKey(event, options) {
|
|
50
|
+
const utc = options.utc ?? false;
|
|
51
|
+
switch (options.granularity) {
|
|
52
|
+
case 'session':
|
|
53
|
+
return event.sessionId;
|
|
54
|
+
case 'week':
|
|
55
|
+
return weekKey(event.timestamp, { utc, weekStartsOn: options.weekStartsOn });
|
|
56
|
+
case 'month': {
|
|
57
|
+
const parts = dayParts(event.timestamp, utc);
|
|
58
|
+
return `${parts.year}-${pad(parts.month + 1)}`;
|
|
59
|
+
}
|
|
60
|
+
case 'day':
|
|
61
|
+
default:
|
|
62
|
+
return utc
|
|
63
|
+
? new Date(event.timestamp).toISOString().slice(0, 10)
|
|
64
|
+
: (0, formatting_1.formatLocalDateKey)(event.timestamp);
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
function emptyTokens() {
|
|
68
|
+
return { inputTokens: 0, outputTokens: 0, cacheWriteTokens: 0, cacheReadTokens: 0 };
|
|
69
|
+
}
|
|
70
|
+
function addTokens(target, source) {
|
|
71
|
+
target.inputTokens += source.inputTokens;
|
|
72
|
+
target.outputTokens += source.outputTokens;
|
|
73
|
+
target.cacheWriteTokens += source.cacheWriteTokens;
|
|
74
|
+
target.cacheReadTokens += source.cacheReadTokens;
|
|
75
|
+
}
|
|
76
|
+
/**
|
|
77
|
+
* Group usage events into rows. Rows are sorted by key (sessions by first
|
|
78
|
+
* event), then provider, project, and model, so tables read oldest first.
|
|
79
|
+
*/
|
|
80
|
+
function bucketUsage(events, options) {
|
|
81
|
+
const groupBy = new Set(options.groupBy ?? ['provider']);
|
|
82
|
+
const isSession = options.granularity === 'session';
|
|
83
|
+
const byProvider = isSession || groupBy.has('provider');
|
|
84
|
+
const byProject = isSession || groupBy.has('project');
|
|
85
|
+
const byModel = groupBy.has('model');
|
|
86
|
+
const buckets = new Map();
|
|
87
|
+
for (const event of events) {
|
|
88
|
+
const key = usageBucketKey(event, options);
|
|
89
|
+
const provider = byProvider ? event.provider : null;
|
|
90
|
+
const project = byProject ? event.project : null;
|
|
91
|
+
const model = byModel ? event.model : null;
|
|
92
|
+
const id = [key, provider ?? '', project ?? '', model ?? ''].join('|');
|
|
93
|
+
let acc = buckets.get(id);
|
|
94
|
+
if (!acc) {
|
|
95
|
+
acc = {
|
|
96
|
+
row: {
|
|
97
|
+
key,
|
|
98
|
+
granularity: options.granularity,
|
|
99
|
+
provider,
|
|
100
|
+
project,
|
|
101
|
+
model,
|
|
102
|
+
sessionId: isSession ? event.sessionId : null,
|
|
103
|
+
models: [],
|
|
104
|
+
calls: 0,
|
|
105
|
+
sessions: 0,
|
|
106
|
+
tokens: emptyTokens(),
|
|
107
|
+
totalTokens: 0,
|
|
108
|
+
costUsd: 0,
|
|
109
|
+
costProvenance: 'none',
|
|
110
|
+
unpricedCalls: 0,
|
|
111
|
+
firstTimestamp: event.timestamp,
|
|
112
|
+
lastTimestamp: event.timestamp,
|
|
113
|
+
},
|
|
114
|
+
sessionIds: new Set(),
|
|
115
|
+
modelTokens: new Map(),
|
|
116
|
+
reportedCalls: 0,
|
|
117
|
+
estimatedCalls: 0,
|
|
118
|
+
};
|
|
119
|
+
buckets.set(id, acc);
|
|
120
|
+
}
|
|
121
|
+
const { row } = acc;
|
|
122
|
+
row.calls += 1;
|
|
123
|
+
addTokens(row.tokens, event.tokens);
|
|
124
|
+
row.totalTokens += event.tokens.totalTokens;
|
|
125
|
+
row.firstTimestamp = Math.min(row.firstTimestamp, event.timestamp);
|
|
126
|
+
row.lastTimestamp = Math.max(row.lastTimestamp, event.timestamp);
|
|
127
|
+
acc.sessionIds.add(event.sessionId);
|
|
128
|
+
acc.modelTokens.set(event.model, (acc.modelTokens.get(event.model) ?? 0) + event.tokens.totalTokens);
|
|
129
|
+
if (event.costUsd !== null) {
|
|
130
|
+
row.costUsd += event.costUsd;
|
|
131
|
+
if (event.costProvenance === 'provider-reported')
|
|
132
|
+
acc.reportedCalls += 1;
|
|
133
|
+
else
|
|
134
|
+
acc.estimatedCalls += 1;
|
|
135
|
+
}
|
|
136
|
+
else {
|
|
137
|
+
row.unpricedCalls += 1;
|
|
138
|
+
}
|
|
139
|
+
}
|
|
140
|
+
const rows = [];
|
|
141
|
+
for (const acc of buckets.values()) {
|
|
142
|
+
acc.row.sessions = acc.sessionIds.size;
|
|
143
|
+
acc.row.models = [...acc.modelTokens.entries()]
|
|
144
|
+
.sort((a, b) => b[1] - a[1])
|
|
145
|
+
.map(([model]) => model);
|
|
146
|
+
acc.row.costProvenance = (0, costProvenance_1.classifyCostProvenance)({
|
|
147
|
+
reportedCalls: acc.reportedCalls,
|
|
148
|
+
estimatedCalls: acc.estimatedCalls,
|
|
149
|
+
unpricedCalls: acc.row.unpricedCalls,
|
|
150
|
+
});
|
|
151
|
+
rows.push(acc.row);
|
|
152
|
+
}
|
|
153
|
+
return rows.sort((a, b) => (isSession ? a.firstTimestamp - b.firstTimestamp : a.key.localeCompare(b.key)) ||
|
|
154
|
+
(a.provider ?? '').localeCompare(b.provider ?? '') ||
|
|
155
|
+
(a.project ?? '').localeCompare(b.project ?? '') ||
|
|
156
|
+
(a.model ?? '').localeCompare(b.model ?? ''));
|
|
157
|
+
}
|
|
158
|
+
/**
|
|
159
|
+
* Sum rows that do not overlap (for example every row of one `bucketUsage`
|
|
160
|
+
* call). Pass the events too when rows are not per-session, so distinct
|
|
161
|
+
* sessions are counted once instead of once per row they appear in.
|
|
162
|
+
*/
|
|
163
|
+
function summarizeUsageRows(rows, events) {
|
|
164
|
+
const totals = {
|
|
165
|
+
calls: 0,
|
|
166
|
+
sessions: 0,
|
|
167
|
+
tokens: emptyTokens(),
|
|
168
|
+
totalTokens: 0,
|
|
169
|
+
costUsd: 0,
|
|
170
|
+
costProvenance: 'none',
|
|
171
|
+
unpricedCalls: 0,
|
|
172
|
+
};
|
|
173
|
+
let reportedCalls = 0;
|
|
174
|
+
let estimatedCalls = 0;
|
|
175
|
+
const sessionIds = new Set();
|
|
176
|
+
for (const row of rows) {
|
|
177
|
+
totals.calls += row.calls;
|
|
178
|
+
addTokens(totals.tokens, row.tokens);
|
|
179
|
+
totals.totalTokens += row.totalTokens;
|
|
180
|
+
totals.costUsd += row.costUsd;
|
|
181
|
+
totals.unpricedCalls += row.unpricedCalls;
|
|
182
|
+
const priced = row.calls - row.unpricedCalls;
|
|
183
|
+
if (row.costProvenance === 'reported')
|
|
184
|
+
reportedCalls += priced;
|
|
185
|
+
else if (row.costProvenance === 'estimated')
|
|
186
|
+
estimatedCalls += priced;
|
|
187
|
+
else if (row.costProvenance === 'mixed') {
|
|
188
|
+
reportedCalls += 1;
|
|
189
|
+
estimatedCalls += 1;
|
|
190
|
+
}
|
|
191
|
+
if (row.sessionId)
|
|
192
|
+
sessionIds.add(row.sessionId);
|
|
193
|
+
}
|
|
194
|
+
if (events) {
|
|
195
|
+
for (const event of events)
|
|
196
|
+
sessionIds.add(event.sessionId);
|
|
197
|
+
totals.sessions = sessionIds.size;
|
|
198
|
+
}
|
|
199
|
+
else {
|
|
200
|
+
totals.sessions = sessionIds.size || rows.reduce((sum, row) => sum + row.sessions, 0);
|
|
201
|
+
}
|
|
202
|
+
totals.costProvenance = (0, costProvenance_1.classifyCostProvenance)({
|
|
203
|
+
reportedCalls,
|
|
204
|
+
estimatedCalls,
|
|
205
|
+
unpricedCalls: totals.unpricedCalls,
|
|
206
|
+
});
|
|
207
|
+
return totals;
|
|
208
|
+
}
|
|
@@ -9,6 +9,12 @@ export interface CreateWatcherOptions {
|
|
|
9
9
|
sessionId?: string;
|
|
10
10
|
callbacks: SessionWatcherCallbacks;
|
|
11
11
|
}
|
|
12
|
+
/**
|
|
13
|
+
* Resolve the session a command should act on: an exact or unique-prefix
|
|
14
|
+
* match of `sessionId` among the workspace's sessions, or the most recent
|
|
15
|
+
* session when no id is given. Throws with the available ids on a miss.
|
|
16
|
+
*/
|
|
17
|
+
export declare function resolveSessionPath(provider: SessionProviderBase, workspacePath: string, sessionId?: string): string;
|
|
12
18
|
export declare function createWatcher(options: CreateWatcherOptions): {
|
|
13
19
|
watcher: SessionWatcher;
|
|
14
20
|
sessionPath: string;
|
package/dist/watchers/factory.js
CHANGED
|
@@ -36,6 +36,7 @@ var __importStar = (this && this.__importStar) || (function () {
|
|
|
36
36
|
};
|
|
37
37
|
})();
|
|
38
38
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
39
|
+
exports.resolveSessionPath = resolveSessionPath;
|
|
39
40
|
exports.createWatcher = createWatcher;
|
|
40
41
|
const os = __importStar(require("os"));
|
|
41
42
|
const path = __importStar(require("path"));
|
|
@@ -48,37 +49,41 @@ function getOpenCodeDataDir() {
|
|
|
48
49
|
return path.join(xdg, 'opencode');
|
|
49
50
|
return path.join(os.homedir(), '.local', 'share', 'opencode');
|
|
50
51
|
}
|
|
51
|
-
|
|
52
|
-
|
|
52
|
+
/**
|
|
53
|
+
* Resolve the session a command should act on: an exact or unique-prefix
|
|
54
|
+
* match of `sessionId` among the workspace's sessions, or the most recent
|
|
55
|
+
* session when no id is given. Throws with the available ids on a miss.
|
|
56
|
+
*/
|
|
57
|
+
function resolveSessionPath(provider, workspacePath, sessionId) {
|
|
53
58
|
const sessions = provider.findAllSessions(workspacePath);
|
|
54
59
|
if (sessions.length === 0) {
|
|
55
60
|
throw new Error(`No sessions found for ${provider.displayName} in ${workspacePath}`);
|
|
56
61
|
}
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
}
|
|
71
|
-
if (candidates.length > 1) {
|
|
72
|
-
throw new Error(`Session ${sessionId} is ambiguous. Matches: ${candidates
|
|
73
|
-
.slice(0, 5)
|
|
74
|
-
.map((candidate) => candidate.id)
|
|
75
|
-
.join(', ')}`);
|
|
76
|
-
}
|
|
77
|
-
sessionPath = candidates[0].sessionPath;
|
|
62
|
+
if (!sessionId)
|
|
63
|
+
return sessions[0]; // most recent
|
|
64
|
+
const matches = sessions.map((sessionPath) => ({
|
|
65
|
+
sessionPath,
|
|
66
|
+
id: provider.getSessionId(sessionPath),
|
|
67
|
+
}));
|
|
68
|
+
const exact = matches.filter((candidate) => candidate.id === sessionId);
|
|
69
|
+
const candidates = exact.length > 0 ? exact : matches.filter((candidate) => candidate.id.startsWith(sessionId));
|
|
70
|
+
if (candidates.length === 0) {
|
|
71
|
+
throw new Error(`Session ${sessionId} not found. Available: ${sessions
|
|
72
|
+
.slice(0, 5)
|
|
73
|
+
.map((s) => path.basename(s))
|
|
74
|
+
.join(', ')}`);
|
|
78
75
|
}
|
|
79
|
-
|
|
80
|
-
|
|
76
|
+
if (candidates.length > 1) {
|
|
77
|
+
throw new Error(`Session ${sessionId} is ambiguous. Matches: ${candidates
|
|
78
|
+
.slice(0, 5)
|
|
79
|
+
.map((candidate) => candidate.id)
|
|
80
|
+
.join(', ')}`);
|
|
81
81
|
}
|
|
82
|
+
return candidates[0].sessionPath;
|
|
83
|
+
}
|
|
84
|
+
function createWatcher(options) {
|
|
85
|
+
const { provider, workspacePath, sessionId, callbacks } = options;
|
|
86
|
+
const sessionPath = resolveSessionPath(provider, workspacePath, sessionId);
|
|
82
87
|
const watcher = createWatcherForProvider(provider, sessionPath, callbacks);
|
|
83
88
|
return { watcher, sessionPath };
|
|
84
89
|
}
|
package/dist/zaiQuotaApi.d.ts
CHANGED
|
@@ -29,5 +29,7 @@ export interface ZaiQuotaResolveOptions extends ZaiQuotaApiOptions {
|
|
|
29
29
|
export declare function readZaiCredentials(options?: ReadZaiCredentialsOptions): ZaiCredentials | null;
|
|
30
30
|
export declare function quotaStateFromZaiQuotaLimitPayload(payload: unknown, capturedAt?: string): QuotaState;
|
|
31
31
|
export declare function fetchZaiQuotaFromApi(options?: ZaiQuotaApiOptions): Promise<QuotaState>;
|
|
32
|
+
/** Stamp a z.ai quota sample with its runtime provider, projections, and window labels. */
|
|
33
|
+
export declare function enrichZaiQuota(state: QuotaState): ProviderQuotaState<'zai'>;
|
|
32
34
|
export declare function resolveZaiQuota(options?: ZaiQuotaResolveOptions): Promise<ProviderQuotaState<'zai'>>;
|
|
33
35
|
export {};
|
package/dist/zaiQuotaApi.js
CHANGED
|
@@ -6,6 +6,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
6
6
|
exports.readZaiCredentials = readZaiCredentials;
|
|
7
7
|
exports.quotaStateFromZaiQuotaLimitPayload = quotaStateFromZaiQuotaLimitPayload;
|
|
8
8
|
exports.fetchZaiQuotaFromApi = fetchZaiQuotaFromApi;
|
|
9
|
+
exports.enrichZaiQuota = enrichZaiQuota;
|
|
9
10
|
exports.resolveZaiQuota = resolveZaiQuota;
|
|
10
11
|
const fs_1 = __importDefault(require("fs"));
|
|
11
12
|
const os_1 = __importDefault(require("os"));
|
|
@@ -245,6 +246,7 @@ async function fetchZaiQuotaFromApi(options = {}) {
|
|
|
245
246
|
clearTimeout(timeout);
|
|
246
247
|
}
|
|
247
248
|
}
|
|
249
|
+
/** Stamp a z.ai quota sample with its runtime provider, projections, and window labels. */
|
|
248
250
|
function enrichZaiQuota(state) {
|
|
249
251
|
const withProjections = (0, quota_1.withQuotaProjections)(state);
|
|
250
252
|
return {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "sidekick-shared",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.26.0",
|
|
4
4
|
"description": "Shared data access layer for Sidekick — readers, types, providers, credentials, quota",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"claude-code",
|
|
@@ -35,42 +35,62 @@
|
|
|
35
35
|
"exports": {
|
|
36
36
|
".": {
|
|
37
37
|
"types": "./dist/index.d.ts",
|
|
38
|
+
"import": "./dist/index.js",
|
|
39
|
+
"require": "./dist/index.js",
|
|
38
40
|
"default": "./dist/index.js"
|
|
39
41
|
},
|
|
40
42
|
"./browser": {
|
|
41
43
|
"types": "./dist/browser.d.ts",
|
|
44
|
+
"import": "./dist/browser.js",
|
|
45
|
+
"require": "./dist/browser.js",
|
|
42
46
|
"default": "./dist/browser.js"
|
|
43
47
|
},
|
|
44
48
|
"./node": {
|
|
45
49
|
"types": "./dist/node.d.ts",
|
|
50
|
+
"import": "./dist/node.js",
|
|
51
|
+
"require": "./dist/node.js",
|
|
46
52
|
"default": "./dist/node.js"
|
|
47
53
|
},
|
|
48
54
|
"./schemas": {
|
|
49
55
|
"types": "./dist/schemas/index.d.ts",
|
|
56
|
+
"import": "./dist/schemas/index.js",
|
|
57
|
+
"require": "./dist/schemas/index.js",
|
|
50
58
|
"default": "./dist/schemas/index.js"
|
|
51
59
|
},
|
|
52
60
|
"./phrases": {
|
|
53
61
|
"types": "./dist/phrases.d.ts",
|
|
62
|
+
"import": "./dist/phrases.js",
|
|
63
|
+
"require": "./dist/phrases.js",
|
|
54
64
|
"default": "./dist/phrases.js"
|
|
55
65
|
},
|
|
56
66
|
"./modelContext": {
|
|
57
67
|
"types": "./dist/modelContext.d.ts",
|
|
68
|
+
"import": "./dist/modelContext.js",
|
|
69
|
+
"require": "./dist/modelContext.js",
|
|
58
70
|
"default": "./dist/modelContext.js"
|
|
59
71
|
},
|
|
60
72
|
"./modelInfo": {
|
|
61
73
|
"types": "./dist/modelInfo.d.ts",
|
|
74
|
+
"import": "./dist/modelInfo.js",
|
|
75
|
+
"require": "./dist/modelInfo.js",
|
|
62
76
|
"default": "./dist/modelInfo.js"
|
|
63
77
|
},
|
|
64
78
|
"./formatting": {
|
|
65
79
|
"types": "./dist/formatting.d.ts",
|
|
80
|
+
"import": "./dist/formatting.js",
|
|
81
|
+
"require": "./dist/formatting.js",
|
|
66
82
|
"default": "./dist/formatting.js"
|
|
67
83
|
},
|
|
68
84
|
"./statusline": {
|
|
69
85
|
"types": "./dist/statusline/index.d.ts",
|
|
86
|
+
"import": "./dist/statusline/index.js",
|
|
87
|
+
"require": "./dist/statusline/index.js",
|
|
70
88
|
"default": "./dist/statusline/index.js"
|
|
71
89
|
},
|
|
72
90
|
"./dist/*": {
|
|
73
91
|
"types": "./dist/*.d.ts",
|
|
92
|
+
"import": "./dist/*.js",
|
|
93
|
+
"require": "./dist/*.js",
|
|
74
94
|
"default": "./dist/*.js"
|
|
75
95
|
},
|
|
76
96
|
"./package.json": "./package.json"
|
|
@@ -131,6 +151,7 @@
|
|
|
131
151
|
"prettier": "3.8.4",
|
|
132
152
|
"typescript": "^5.7.0",
|
|
133
153
|
"typescript-eslint": "^8.0.0",
|
|
154
|
+
"vite": "^8.1.0",
|
|
134
155
|
"vitest": "^4.1.9"
|
|
135
156
|
},
|
|
136
157
|
"license": "MIT",
|