sidekick-shared 0.24.4 → 0.24.5
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 +24 -0
- package/README.md +86 -45
- package/dist/accountManager.d.ts +13 -0
- package/dist/accountManager.js +60 -32
- package/dist/accountRegistry.js +59 -41
- package/dist/accounts.js +40 -19
- package/dist/autoSwitch.d.ts +2 -1
- package/dist/autoSwitch.js +32 -7
- package/dist/browser.d.ts +2 -0
- package/dist/browser.js +3 -1
- package/dist/codexProfiles.d.ts +14 -0
- package/dist/codexProfiles.js +268 -116
- package/dist/context/sessionContext.js +2 -4
- package/dist/ensureDefaultAccounts.js +4 -4
- package/dist/index.d.ts +11 -4
- package/dist/index.js +28 -7
- package/dist/node.d.ts +6 -0
- package/dist/node.js +8 -1
- package/dist/observedContextWindows.d.ts +13 -0
- package/dist/observedContextWindows.js +13 -0
- package/dist/parsers/codexHistory.d.ts +30 -0
- package/dist/parsers/codexHistory.js +118 -0
- package/dist/parsers/mcpToolName.d.ts +26 -0
- package/dist/parsers/mcpToolName.js +31 -0
- package/dist/parsers/sessionPathResolver.d.ts +11 -4
- package/dist/parsers/sessionPathResolver.js +11 -4
- package/dist/paths.d.ts +7 -3
- package/dist/paths.js +7 -3
- package/dist/providers/claudeCode.d.ts +2 -1
- package/dist/providers/claudeCode.js +18 -0
- package/dist/providers/codex.d.ts +22 -1
- package/dist/providers/codex.js +58 -0
- package/dist/providers/types.d.ts +5 -0
- package/dist/quotaHistory.d.ts +1 -1
- package/dist/quotaHistory.js +2 -2
- package/dist/quotaSnapshots.js +8 -77
- package/dist/sessionPreviews.d.ts +60 -0
- package/dist/sessionPreviews.js +234 -0
- package/dist/sessionTranscripts.js +10 -4
- package/dist/writers/atomic.d.ts +20 -0
- package/dist/writers/atomic.js +190 -19
- package/package.json +1 -1
package/dist/accountRegistry.js
CHANGED
|
@@ -45,21 +45,36 @@ exports.removeSavedAccountProfile = removeSavedAccountProfile;
|
|
|
45
45
|
const fs = __importStar(require("fs"));
|
|
46
46
|
const path = __importStar(require("path"));
|
|
47
47
|
const paths_1 = require("./paths");
|
|
48
|
+
const atomic_1 = require("./writers/atomic");
|
|
48
49
|
function getAccountsDir() {
|
|
49
50
|
return path.join((0, paths_1.getConfigDir)(), 'accounts');
|
|
50
51
|
}
|
|
51
52
|
function getRegistryPath() {
|
|
52
53
|
return path.join(getAccountsDir(), 'accounts.json');
|
|
53
54
|
}
|
|
55
|
+
function getRegistryLockPath() {
|
|
56
|
+
return getRegistryPath() + '.lock';
|
|
57
|
+
}
|
|
54
58
|
function ensureAccountsDir() {
|
|
55
59
|
fs.mkdirSync(getAccountsDir(), { recursive: true, mode: 0o700 });
|
|
56
60
|
}
|
|
57
|
-
function
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
61
|
+
function writeRegistryUnlocked(registry) {
|
|
62
|
+
(0, atomic_1.atomicWriteJsonSync)(getRegistryPath(), normalizeRegistry(registry));
|
|
63
|
+
}
|
|
64
|
+
/**
|
|
65
|
+
* Serializes registry read-modify-write cycles across processes. Without the
|
|
66
|
+
* lock, two concurrent mutators (CLI, editor extension, external consumers)
|
|
67
|
+
* read the same base state and the second write silently drops the first
|
|
68
|
+
* mutation. Lock ordering: callers that also hold a provider auth-swap lock
|
|
69
|
+
* take that lock first and this one inside it, never the reverse.
|
|
70
|
+
*/
|
|
71
|
+
function mutateSavedAccountRegistry(mutator) {
|
|
72
|
+
ensureAccountsDir();
|
|
73
|
+
return (0, atomic_1.withFileLockSync)(getRegistryLockPath(), () => {
|
|
74
|
+
const next = mutator(readSavedAccountRegistry() ?? createEmptyRegistry());
|
|
75
|
+
writeRegistryUnlocked(next);
|
|
76
|
+
return next;
|
|
77
|
+
});
|
|
63
78
|
}
|
|
64
79
|
function createEmptyRegistry() {
|
|
65
80
|
return {
|
|
@@ -136,7 +151,7 @@ function readSavedAccountRegistry() {
|
|
|
136
151
|
}
|
|
137
152
|
function writeSavedAccountRegistry(registry) {
|
|
138
153
|
ensureAccountsDir();
|
|
139
|
-
|
|
154
|
+
(0, atomic_1.withFileLockSync)(getRegistryLockPath(), () => writeRegistryUnlocked(registry));
|
|
140
155
|
}
|
|
141
156
|
function listSavedAccountProfiles(providerId) {
|
|
142
157
|
const registry = readSavedAccountRegistry();
|
|
@@ -156,44 +171,47 @@ function getActiveSavedAccount(providerId) {
|
|
|
156
171
|
return (registry.accounts.find((account) => account.providerId === providerId && account.id === activeId) ?? null);
|
|
157
172
|
}
|
|
158
173
|
function upsertSavedAccountProfile(profile) {
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
174
|
+
return mutateSavedAccountRegistry((registry) => {
|
|
175
|
+
const index = registry.accounts.findIndex((account) => account.providerId === profile.providerId && account.id === profile.id);
|
|
176
|
+
if (index >= 0) {
|
|
177
|
+
registry.accounts[index] = profile;
|
|
178
|
+
}
|
|
179
|
+
else {
|
|
180
|
+
registry.accounts.push(profile);
|
|
181
|
+
}
|
|
182
|
+
return registry;
|
|
183
|
+
});
|
|
169
184
|
}
|
|
170
185
|
function setActiveSavedAccount(providerId, accountId) {
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
186
|
+
return mutateSavedAccountRegistry((registry) => {
|
|
187
|
+
registry.activeByProvider[providerId] = accountId;
|
|
188
|
+
return registry;
|
|
189
|
+
});
|
|
175
190
|
}
|
|
176
191
|
function replaceSavedAccountProfiles(providerId, accounts, activeId) {
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
192
|
+
return mutateSavedAccountRegistry((registry) => {
|
|
193
|
+
registry.accounts = registry.accounts
|
|
194
|
+
.filter((account) => account.providerId !== providerId)
|
|
195
|
+
.concat(accounts);
|
|
196
|
+
registry.activeByProvider[providerId] = activeId;
|
|
197
|
+
return registry;
|
|
198
|
+
});
|
|
184
199
|
}
|
|
185
200
|
function removeSavedAccountProfile(providerId, accountId) {
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
201
|
+
ensureAccountsDir();
|
|
202
|
+
return (0, atomic_1.withFileLockSync)(getRegistryLockPath(), () => {
|
|
203
|
+
const registry = readSavedAccountRegistry();
|
|
204
|
+
if (!registry)
|
|
205
|
+
return null;
|
|
206
|
+
const index = registry.accounts.findIndex((account) => account.providerId === providerId && account.id === accountId);
|
|
207
|
+
if (index === -1)
|
|
208
|
+
return null;
|
|
209
|
+
const [removed] = registry.accounts.splice(index, 1);
|
|
210
|
+
if (registry.activeByProvider[providerId] === accountId) {
|
|
211
|
+
registry.activeByProvider[providerId] =
|
|
212
|
+
registry.accounts.find((account) => account.providerId === providerId)?.id ?? null;
|
|
213
|
+
}
|
|
214
|
+
writeRegistryUnlocked(registry);
|
|
215
|
+
return removed;
|
|
216
|
+
});
|
|
199
217
|
}
|
package/dist/accounts.js
CHANGED
|
@@ -56,6 +56,7 @@ const fs = __importStar(require("fs"));
|
|
|
56
56
|
const path = __importStar(require("path"));
|
|
57
57
|
const os = __importStar(require("os"));
|
|
58
58
|
const credentialIO_1 = require("./credentialIO");
|
|
59
|
+
const atomic_1 = require("./writers/atomic");
|
|
59
60
|
const accountRegistry_1 = require("./accountRegistry");
|
|
60
61
|
const claudeProfiles_1 = require("./claudeProfiles");
|
|
61
62
|
// ── Paths ────────────────────────────────────────────────────────────────
|
|
@@ -91,16 +92,6 @@ function ensureDirs() {
|
|
|
91
92
|
fs.mkdirSync(dir, { recursive: true, mode: 0o700 });
|
|
92
93
|
}
|
|
93
94
|
}
|
|
94
|
-
// ── Atomic file write ────────────────────────────────────────────────────
|
|
95
|
-
function atomicWriteJson(filePath, data, mode = 0o600) {
|
|
96
|
-
fs.mkdirSync(path.dirname(filePath), { recursive: true, mode: 0o700 });
|
|
97
|
-
const tmp = filePath + '.tmp';
|
|
98
|
-
const json = JSON.stringify(data, null, 2);
|
|
99
|
-
// Validate we can re-parse before writing
|
|
100
|
-
JSON.parse(json);
|
|
101
|
-
fs.writeFileSync(tmp, json, { encoding: 'utf8', mode });
|
|
102
|
-
fs.renameSync(tmp, filePath);
|
|
103
|
-
}
|
|
104
95
|
function readJsonOrNull(filePath) {
|
|
105
96
|
try {
|
|
106
97
|
return JSON.parse(fs.readFileSync(filePath, 'utf8'));
|
|
@@ -114,7 +105,7 @@ function readOauthAccountFromConfigPath(filePath) {
|
|
|
114
105
|
return parsed?.oauthAccount ?? null;
|
|
115
106
|
}
|
|
116
107
|
function writeClaudeProfileConfig(uuid, oauthAccount) {
|
|
117
|
-
|
|
108
|
+
(0, atomic_1.atomicWriteJsonSync)(path.join((0, claudeProfiles_1.getClaudeProfileHome)(uuid), '.claude.json'), { oauthAccount });
|
|
118
109
|
}
|
|
119
110
|
function writeClaudeProfileCredentials(uuid, credentials) {
|
|
120
111
|
(0, credentialIO_1.writeActiveCredentials)(credentials, (0, claudeProfiles_1.getClaudeProfileHome)(uuid));
|
|
@@ -162,7 +153,7 @@ function backupCurrentClaudeLiveHome() {
|
|
|
162
153
|
const originalOauthAccount = readCurrentLiveOauthAccount();
|
|
163
154
|
if (originalCreds) {
|
|
164
155
|
try {
|
|
165
|
-
|
|
156
|
+
(0, atomic_1.atomicWriteJsonSync)(path.join(getCredentialsDir(), `${currentActive.uuid}.credentials.json`), originalCreds);
|
|
166
157
|
writeClaudeProfileCredentials(currentActive.uuid, originalCreds);
|
|
167
158
|
}
|
|
168
159
|
catch {
|
|
@@ -171,7 +162,7 @@ function backupCurrentClaudeLiveHome() {
|
|
|
171
162
|
}
|
|
172
163
|
if (originalOauthAccount) {
|
|
173
164
|
try {
|
|
174
|
-
|
|
165
|
+
(0, atomic_1.atomicWriteJsonSync)(path.join(getConfigsDir(), `${currentActive.uuid}.config.json`), originalOauthAccount);
|
|
175
166
|
writeClaudeProfileConfig(currentActive.uuid, originalOauthAccount);
|
|
176
167
|
}
|
|
177
168
|
catch {
|
|
@@ -188,7 +179,7 @@ function mergeOauthAccountIntoLiveConfig(oauthAccount) {
|
|
|
188
179
|
// File may not exist yet.
|
|
189
180
|
}
|
|
190
181
|
configObj.oauthAccount = oauthAccount;
|
|
191
|
-
|
|
182
|
+
(0, atomic_1.atomicWriteJsonSync)(getClaudeConfigPath(), configObj);
|
|
192
183
|
}
|
|
193
184
|
// ── Registry operations ──────────────────────────────────────────────────
|
|
194
185
|
function readAccountRegistry() {
|
|
@@ -274,8 +265,8 @@ function addCurrentAccount(label) {
|
|
|
274
265
|
if (existing) {
|
|
275
266
|
if (label !== undefined)
|
|
276
267
|
existing.label = label;
|
|
277
|
-
|
|
278
|
-
|
|
268
|
+
(0, atomic_1.atomicWriteJsonSync)(path.join(getCredentialsDir(), `${active.uuid}.credentials.json`), credBlob);
|
|
269
|
+
(0, atomic_1.atomicWriteJsonSync)(path.join(getConfigsDir(), `${active.uuid}.config.json`), configBlob);
|
|
279
270
|
try {
|
|
280
271
|
writeClaudeProfileMirror(active.uuid, credBlob, configBlob);
|
|
281
272
|
}
|
|
@@ -287,8 +278,8 @@ function addCurrentAccount(label) {
|
|
|
287
278
|
return { success: true };
|
|
288
279
|
}
|
|
289
280
|
// 6. New account — back up credentials
|
|
290
|
-
|
|
291
|
-
|
|
281
|
+
(0, atomic_1.atomicWriteJsonSync)(path.join(getCredentialsDir(), `${active.uuid}.credentials.json`), credBlob);
|
|
282
|
+
(0, atomic_1.atomicWriteJsonSync)(path.join(getConfigsDir(), `${active.uuid}.config.json`), configBlob);
|
|
292
283
|
try {
|
|
293
284
|
writeClaudeProfileMirror(active.uuid, credBlob, configBlob);
|
|
294
285
|
}
|
|
@@ -307,7 +298,28 @@ function addCurrentAccount(label) {
|
|
|
307
298
|
return { success: true };
|
|
308
299
|
}
|
|
309
300
|
// ── Switch to account ────────────────────────────────────────────────────
|
|
301
|
+
/**
|
|
302
|
+
* Serializes live Claude credential swaps across processes so two concurrent
|
|
303
|
+
* switchers cannot interleave their backup/write/rollback sequences. It cannot
|
|
304
|
+
* exclude Claude Code's own writes to the live home — only our switchers. Lock
|
|
305
|
+
* ordering: this lock first, the registry lock (inside setActiveSavedAccount)
|
|
306
|
+
* inside it — never the reverse.
|
|
307
|
+
*/
|
|
308
|
+
function withClaudeAuthSwapLock(operation) {
|
|
309
|
+
const lockDir = path.join((0, accountRegistry_1.getAccountsDir)(), 'claude');
|
|
310
|
+
fs.mkdirSync(lockDir, { recursive: true, mode: 0o700 });
|
|
311
|
+
return (0, atomic_1.withFileLockSync)(path.join(lockDir, 'auth-swap.lock'), operation);
|
|
312
|
+
}
|
|
310
313
|
function switchToAccount(uuid) {
|
|
314
|
+
try {
|
|
315
|
+
// Keep the non-throwing result contract when the lock cannot be acquired.
|
|
316
|
+
return withClaudeAuthSwapLock(() => switchToAccountUnlocked(uuid));
|
|
317
|
+
}
|
|
318
|
+
catch (err) {
|
|
319
|
+
return { success: false, error: `Could not acquire the account-switch lock: ${err}` };
|
|
320
|
+
}
|
|
321
|
+
}
|
|
322
|
+
function switchToAccountUnlocked(uuid) {
|
|
311
323
|
const registry = readAccountRegistry();
|
|
312
324
|
if (!registry) {
|
|
313
325
|
return { success: false, error: 'No account registry found. Save an account first.' };
|
|
@@ -338,7 +350,7 @@ function switchToAccount(uuid) {
|
|
|
338
350
|
catch (err) {
|
|
339
351
|
return { success: false, error: `Failed to update account registry: ${err}` };
|
|
340
352
|
}
|
|
341
|
-
const applied =
|
|
353
|
+
const applied = applyActiveClaudeToLiveHomeUnlocked();
|
|
342
354
|
if (!applied.success) {
|
|
343
355
|
try {
|
|
344
356
|
(0, accountRegistry_1.setActiveSavedAccount)('claude-code', registry.activeAccountUuid);
|
|
@@ -373,6 +385,15 @@ function resolveActiveClaudeHome() {
|
|
|
373
385
|
return (0, claudeProfiles_1.getClaudeProfileHome)(active.providerAccountId ?? active.id);
|
|
374
386
|
}
|
|
375
387
|
function applyActiveClaudeToLiveHome() {
|
|
388
|
+
try {
|
|
389
|
+
// Keep the non-throwing result contract when the lock cannot be acquired.
|
|
390
|
+
return withClaudeAuthSwapLock(applyActiveClaudeToLiveHomeUnlocked);
|
|
391
|
+
}
|
|
392
|
+
catch (err) {
|
|
393
|
+
return { success: false, error: `Could not acquire the account-switch lock: ${err}` };
|
|
394
|
+
}
|
|
395
|
+
}
|
|
396
|
+
function applyActiveClaudeToLiveHomeUnlocked() {
|
|
376
397
|
const active = (0, accountRegistry_1.getActiveSavedAccount)('claude-code');
|
|
377
398
|
if (!active) {
|
|
378
399
|
return { success: false, error: 'No active Claude account found.' };
|
package/dist/autoSwitch.d.ts
CHANGED
|
@@ -36,7 +36,7 @@ export interface AutoSwitchControllerOptions {
|
|
|
36
36
|
getCodexAccounts?: () => SavedAccountProfile[];
|
|
37
37
|
getActiveCodexAccount?: () => SavedAccountProfile | null;
|
|
38
38
|
readSnapshot?: (providerId: AccountProviderId, accountId: string) => QuotaState | null;
|
|
39
|
-
switchAccount?: (providerId: AccountProviderId, accountId: string) => AccountManagerResult
|
|
39
|
+
switchAccount?: (providerId: AccountProviderId, accountId: string) => AccountManagerResult | Promise<AccountManagerResult>;
|
|
40
40
|
onTransition?: (event: AutoSwitchTransitionEvent) => void;
|
|
41
41
|
log?: (message: string, error?: unknown) => void;
|
|
42
42
|
cooldownMs?: number;
|
|
@@ -59,6 +59,7 @@ export declare class AutoSwitchController implements Disposable {
|
|
|
59
59
|
private subscription;
|
|
60
60
|
private readonly switchedDuringCrossing;
|
|
61
61
|
private readonly lastSwitchAt;
|
|
62
|
+
private readonly switchInFlight;
|
|
62
63
|
constructor(options: AutoSwitchControllerOptions);
|
|
63
64
|
start(): void;
|
|
64
65
|
stop(): void;
|
package/dist/autoSwitch.js
CHANGED
|
@@ -83,6 +83,7 @@ class AutoSwitchController {
|
|
|
83
83
|
subscription = null;
|
|
84
84
|
switchedDuringCrossing = new Set();
|
|
85
85
|
lastSwitchAt = {};
|
|
86
|
+
switchInFlight = new Set();
|
|
86
87
|
constructor(options) {
|
|
87
88
|
this.quotaService = options.quotaService;
|
|
88
89
|
this.config = mergedConfig(options.config);
|
|
@@ -91,7 +92,7 @@ class AutoSwitchController {
|
|
|
91
92
|
this.getCodexAccounts = options.getCodexAccounts ?? codexProfiles_1.listCodexAccounts;
|
|
92
93
|
this.getActiveCodexAccount = options.getActiveCodexAccount ?? codexProfiles_1.getActiveCodexAccount;
|
|
93
94
|
this.readSnapshot = options.readSnapshot ?? quotaSnapshots_1.readQuotaSnapshot;
|
|
94
|
-
this.switchAccount = options.switchAccount ?? accountManager_1.
|
|
95
|
+
this.switchAccount = options.switchAccount ?? accountManager_1.switchAccountAsync;
|
|
95
96
|
this.onTransition = options.onTransition;
|
|
96
97
|
this.log = options.log;
|
|
97
98
|
this.cooldownMs = options.cooldownMs ?? 0;
|
|
@@ -116,13 +117,22 @@ class AutoSwitchController {
|
|
|
116
117
|
}
|
|
117
118
|
}
|
|
118
119
|
handleUpdate(state) {
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
120
|
+
// Fire-and-forget, but the registry/snapshot reads and the consumer's
|
|
121
|
+
// onTransition can all throw — a rejection here would escape the quota
|
|
122
|
+
// service's per-listener guard as an unhandled promise rejection.
|
|
123
|
+
if (state.claude) {
|
|
124
|
+
this.handleProviderUpdate('claude', state.claude).catch((error) => this.log?.('[AutoSwitch] Update failed for claude.', error));
|
|
125
|
+
}
|
|
126
|
+
if (state.codex) {
|
|
127
|
+
this.handleProviderUpdate('codex', state.codex).catch((error) => this.log?.('[AutoSwitch] Update failed for codex.', error));
|
|
128
|
+
}
|
|
123
129
|
}
|
|
124
|
-
handleProviderUpdate(runtimeProvider, activeQuota) {
|
|
130
|
+
async handleProviderUpdate(runtimeProvider, activeQuota) {
|
|
125
131
|
const providerId = runtimeStateToProvider(runtimeProvider);
|
|
132
|
+
// While a switch is mid-flight the registry's active account is
|
|
133
|
+
// indeterminate, so skip the whole update until it settles.
|
|
134
|
+
if (this.switchInFlight.has(providerId))
|
|
135
|
+
return;
|
|
126
136
|
const activeAccount = providerId === 'claude-code' ? this.getActiveClaudeAccount() : this.getActiveCodexAccount();
|
|
127
137
|
if (!activeAccount)
|
|
128
138
|
return;
|
|
@@ -148,13 +158,28 @@ class AutoSwitchController {
|
|
|
148
158
|
const previousSwitchAt = this.lastSwitchAt[providerId] ?? 0;
|
|
149
159
|
if (this.cooldownMs > 0 && this.now() - previousSwitchAt < this.cooldownMs)
|
|
150
160
|
return;
|
|
151
|
-
|
|
161
|
+
this.switchInFlight.add(providerId);
|
|
162
|
+
let result;
|
|
163
|
+
try {
|
|
164
|
+
result = await this.switchAccount(providerId, decision.switchTo);
|
|
165
|
+
}
|
|
166
|
+
catch (error) {
|
|
167
|
+
this.log?.(`[AutoSwitch] Switch threw for ${providerId} to ${decision.switchTo}.`, error);
|
|
168
|
+
return;
|
|
169
|
+
}
|
|
170
|
+
finally {
|
|
171
|
+
this.switchInFlight.delete(providerId);
|
|
172
|
+
}
|
|
152
173
|
if (!result.success) {
|
|
153
174
|
this.log?.(`[AutoSwitch] Could not switch ${providerId} to ${decision.switchTo}.`, result.error);
|
|
154
175
|
return;
|
|
155
176
|
}
|
|
156
177
|
this.lastSwitchAt[providerId] = this.now();
|
|
157
178
|
this.switchedDuringCrossing.add(providerId);
|
|
179
|
+
// A switch that completes after stop()/dispose() still records its
|
|
180
|
+
// state, but must not fire a transition into a stopped consumer.
|
|
181
|
+
if (!this.subscription)
|
|
182
|
+
return;
|
|
158
183
|
this.onTransition?.({
|
|
159
184
|
provider: providerId,
|
|
160
185
|
from: activeAccountId,
|
package/dist/browser.d.ts
CHANGED
|
@@ -16,6 +16,8 @@ export { projectSessionTranscript } from './transcript';
|
|
|
16
16
|
export type { TranscriptFidelity, TranscriptSourceProvenance, CanonicalTranscriptBlock, CanonicalTranscriptMessage, CanonicalToolCall, CanonicalTranscriptUsageTotals, CanonicalSessionTranscript, ProjectSessionTranscriptOptions, } from './transcript';
|
|
17
17
|
export { formatDurationMs, formatTokenCount } from './formatting';
|
|
18
18
|
export type { FormatDurationMsOptions, FormatTokenCountOptions } from './formatting';
|
|
19
|
+
export { parseMcpToolName } from './parsers/mcpToolName';
|
|
20
|
+
export type { McpToolNameParts } from './parsers/mcpToolName';
|
|
19
21
|
export { buildSessionContextSnapshot, calculateSessionContextPressure, createSessionContextProjector, } from './context/sessionContext';
|
|
20
22
|
export type { BuildSessionContextSnapshotOptions, SessionContextCapabilities, SessionContextLayerBreakdown, SessionContextPressure, SessionContextProjector, SessionContextSnapshot, SessionContextSource, SessionContextSourceType, } from './context/sessionContext';
|
|
21
23
|
export { assistantTurnEventsFromSessionEvents, extractTurnSubagents, isAssistantTurnSubagentTool, reasoningSummary, segmentAssistantTurn, } from './turns/assistantTurn';
|
package/dist/browser.js
CHANGED
|
@@ -9,7 +9,7 @@
|
|
|
9
9
|
* For pricing hydration (LiteLLM catalog refresh), use `sidekick-shared/node`.
|
|
10
10
|
*/
|
|
11
11
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
-
exports.formatCost = exports.sortModelIds = exports.compareModelIds = exports.getModelDisplayInfo = exports.shortModelName = exports.mergeCostSources = exports.calculateCostWithProvenance = exports.calculateCostWithPricing = exports.calculateCost = exports.getModelInfo = exports.getModelPricing = exports.parseModelId = exports.segmentAssistantTurn = exports.reasoningSummary = exports.isAssistantTurnSubagentTool = exports.extractTurnSubagents = exports.assistantTurnEventsFromSessionEvents = exports.createSessionContextProjector = exports.calculateSessionContextPressure = exports.buildSessionContextSnapshot = exports.formatTokenCount = exports.formatDurationMs = exports.projectSessionTranscript = exports.estimateSerializedTokens = exports.estimateTextTokens = exports.calculateNormalizedUsageCost = exports.extractNormalizedUsage = exports.normalizeProviderUsage = exports.DEFAULT_CONTEXT_WINDOW = exports.getModelContextWindowSize = void 0;
|
|
12
|
+
exports.formatCost = exports.sortModelIds = exports.compareModelIds = exports.getModelDisplayInfo = exports.shortModelName = exports.mergeCostSources = exports.calculateCostWithProvenance = exports.calculateCostWithPricing = exports.calculateCost = exports.getModelInfo = exports.getModelPricing = exports.parseModelId = exports.segmentAssistantTurn = exports.reasoningSummary = exports.isAssistantTurnSubagentTool = exports.extractTurnSubagents = exports.assistantTurnEventsFromSessionEvents = exports.createSessionContextProjector = exports.calculateSessionContextPressure = exports.buildSessionContextSnapshot = exports.parseMcpToolName = exports.formatTokenCount = exports.formatDurationMs = exports.projectSessionTranscript = exports.estimateSerializedTokens = exports.estimateTextTokens = exports.calculateNormalizedUsageCost = exports.extractNormalizedUsage = exports.normalizeProviderUsage = exports.DEFAULT_CONTEXT_WINDOW = exports.getModelContextWindowSize = void 0;
|
|
13
13
|
var modelContext_1 = require("./modelContext");
|
|
14
14
|
Object.defineProperty(exports, "getModelContextWindowSize", { enumerable: true, get: function () { return modelContext_1.getModelContextWindowSize; } });
|
|
15
15
|
Object.defineProperty(exports, "DEFAULT_CONTEXT_WINDOW", { enumerable: true, get: function () { return modelContext_1.DEFAULT_CONTEXT_WINDOW; } });
|
|
@@ -25,6 +25,8 @@ Object.defineProperty(exports, "projectSessionTranscript", { enumerable: true, g
|
|
|
25
25
|
var formatting_1 = require("./formatting");
|
|
26
26
|
Object.defineProperty(exports, "formatDurationMs", { enumerable: true, get: function () { return formatting_1.formatDurationMs; } });
|
|
27
27
|
Object.defineProperty(exports, "formatTokenCount", { enumerable: true, get: function () { return formatting_1.formatTokenCount; } });
|
|
28
|
+
var mcpToolName_1 = require("./parsers/mcpToolName");
|
|
29
|
+
Object.defineProperty(exports, "parseMcpToolName", { enumerable: true, get: function () { return mcpToolName_1.parseMcpToolName; } });
|
|
28
30
|
var sessionContext_1 = require("./context/sessionContext");
|
|
29
31
|
Object.defineProperty(exports, "buildSessionContextSnapshot", { enumerable: true, get: function () { return sessionContext_1.buildSessionContextSnapshot; } });
|
|
30
32
|
Object.defineProperty(exports, "calculateSessionContextPressure", { enumerable: true, get: function () { return sessionContext_1.calculateSessionContextPressure; } });
|
package/dist/codexProfiles.d.ts
CHANGED
|
@@ -10,7 +10,11 @@ export declare function getCodexMonitoringHomes(): string[];
|
|
|
10
10
|
export declare function getCodexProfilesDir(): string;
|
|
11
11
|
export declare function getCodexProfileHome(profileId: string): string;
|
|
12
12
|
export declare function readCodexAccountMetadata(codexHome: string): AccountIdentityMetadata;
|
|
13
|
+
/** {@link readCodexAccountMetadata} without blocking the event loop on the CLI probe. */
|
|
14
|
+
export declare function readCodexAccountMetadataAsync(codexHome: string): Promise<AccountIdentityMetadata>;
|
|
13
15
|
export declare function isCodexProfileAuthenticated(codexHome: string): boolean;
|
|
16
|
+
/** {@link isCodexProfileAuthenticated} without blocking the event loop on the CLI probe. */
|
|
17
|
+
export declare function isCodexProfileAuthenticatedAsync(codexHome: string): Promise<boolean>;
|
|
14
18
|
export declare function listCodexAccounts(): SavedAccountProfile[];
|
|
15
19
|
export declare function getActiveCodexAccount(): SavedAccountProfile | null;
|
|
16
20
|
export declare function resolveSidekickCodexHome(): string;
|
|
@@ -30,9 +34,19 @@ export declare function resolveSidekickCodexHome(): string;
|
|
|
30
34
|
export declare function resolveActiveCodexAccount(): ResolvedActiveAccount;
|
|
31
35
|
export declare function getCodexExecutionEnv(baseEnv?: NodeJS.ProcessEnv): NodeJS.ProcessEnv;
|
|
32
36
|
export declare function prepareCodexAccount(label: string): CodexAccountManagerResult;
|
|
37
|
+
/** {@link prepareCodexAccount} without blocking the event loop on CLI probes. */
|
|
38
|
+
export declare function prepareCodexAccountAsync(label: string): Promise<CodexAccountManagerResult>;
|
|
33
39
|
export declare function finalizeCodexAccount(profileId: string, opts?: {
|
|
34
40
|
activate?: boolean;
|
|
35
41
|
}): CodexAccountManagerResult;
|
|
42
|
+
/** {@link finalizeCodexAccount} without blocking the event loop on CLI probes. */
|
|
43
|
+
export declare function finalizeCodexAccountAsync(profileId: string, opts?: {
|
|
44
|
+
activate?: boolean;
|
|
45
|
+
}): Promise<CodexAccountManagerResult>;
|
|
36
46
|
export declare function switchToCodexAccount(profileId: string): CodexAccountManagerResult;
|
|
47
|
+
/** {@link switchToCodexAccount} without blocking the event loop on CLI probes. */
|
|
48
|
+
export declare function switchToCodexAccountAsync(profileId: string): Promise<CodexAccountManagerResult>;
|
|
37
49
|
export declare function reconcileCodexAuthState(): void;
|
|
50
|
+
/** {@link reconcileCodexAuthState} without blocking the event loop on CLI probes. */
|
|
51
|
+
export declare function reconcileCodexAuthStateAsync(): Promise<void>;
|
|
38
52
|
export declare function removeCodexAccount(profileId: string): AccountManagerResult;
|