sidekick-shared 0.26.5 → 0.26.6
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 +35 -0
- package/README.md +56 -51
- package/dist/accountChanges.js +21 -2
- package/dist/accountHealth.d.ts +72 -0
- package/dist/accountHealth.js +286 -0
- package/dist/accountLaunch.d.ts +30 -0
- package/dist/accountLaunch.js +124 -0
- package/dist/accountManager.d.ts +33 -8
- package/dist/accountManager.js +183 -50
- package/dist/accountRegistry.d.ts +10 -0
- package/dist/accountRegistry.js +42 -22
- package/dist/accountSwitch.d.ts +43 -0
- package/dist/accountSwitch.js +115 -0
- package/dist/accountSync.d.ts +30 -0
- package/dist/accountSync.js +180 -0
- package/dist/accountSyncTypes.d.ts +25 -0
- package/dist/accountSyncTypes.js +7 -0
- package/dist/accounts.d.ts +58 -6
- package/dist/accounts.js +408 -189
- package/dist/claudeCredentials.d.ts +38 -0
- package/dist/claudeCredentials.js +74 -0
- package/dist/claudeProfiles.d.ts +40 -0
- package/dist/claudeProfiles.js +102 -10
- package/dist/codexAuth.d.ts +32 -0
- package/dist/codexAuth.js +127 -0
- package/dist/codexPaths.d.ts +21 -0
- package/dist/codexPaths.js +117 -0
- package/dist/codexProfiles.d.ts +58 -5
- package/dist/codexProfiles.js +574 -289
- package/dist/credentialIO.d.ts +12 -5
- package/dist/credentialIO.js +63 -29
- package/dist/credentials.d.ts +8 -0
- package/dist/credentials.js +28 -32
- package/dist/ensureDefaultAccounts.d.ts +8 -0
- package/dist/ensureDefaultAccounts.js +42 -82
- package/dist/index.d.ts +27 -10
- package/dist/index.js +61 -9
- package/dist/keepAlive.d.ts +44 -0
- package/dist/keepAlive.js +106 -0
- package/dist/processDetection.d.ts +32 -0
- package/dist/processDetection.js +210 -0
- package/dist/schemas/accountManager.d.ts +283 -1
- package/dist/schemas/accountManager.js +122 -1
- package/dist/schemas/assistantTurn.d.ts +2 -2
- package/dist/schemas/index.d.ts +6 -1
- package/dist/schemas/index.js +14 -1
- package/dist/schemas/observedSessionV1.d.ts +21 -21
- package/dist/schemas/quota.d.ts +18 -18
- package/dist/schemas/quotaHistory.d.ts +1 -1
- package/dist/schemas/stateFile.d.ts +5 -5
- package/dist/terminalSync.d.ts +5 -5
- package/dist/terminalSync.js +7 -112
- package/dist/writers/atomic.d.ts +2 -0
- package/dist/writers/atomic.js +49 -2
- package/package.json +1 -1
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { z } from 'zod';
|
|
2
2
|
export declare const observationProvenanceV1Schema: z.ZodEnum<{
|
|
3
|
-
reported: "reported";
|
|
4
3
|
estimated: "estimated";
|
|
4
|
+
reported: "reported";
|
|
5
5
|
inferred: "inferred";
|
|
6
6
|
}>;
|
|
7
7
|
export declare const sessionEvidenceRefV1Schema: z.ZodObject<{
|
|
@@ -20,8 +20,8 @@ export declare const sessionEvidenceRefV1Schema: z.ZodObject<{
|
|
|
20
20
|
export declare const observedValueV1Schema: <T extends z.ZodType>(value: T) => z.ZodObject<{
|
|
21
21
|
value: T;
|
|
22
22
|
provenance: z.ZodEnum<{
|
|
23
|
-
reported: "reported";
|
|
24
23
|
estimated: "estimated";
|
|
24
|
+
reported: "reported";
|
|
25
25
|
inferred: "inferred";
|
|
26
26
|
}>;
|
|
27
27
|
confidence: z.ZodNumber;
|
|
@@ -55,8 +55,8 @@ export declare const pendingUserRequestV1Schema: z.ZodObject<{
|
|
|
55
55
|
tool_approval: "tool_approval";
|
|
56
56
|
}>;
|
|
57
57
|
provenance: z.ZodEnum<{
|
|
58
|
-
reported: "reported";
|
|
59
58
|
estimated: "estimated";
|
|
59
|
+
reported: "reported";
|
|
60
60
|
inferred: "inferred";
|
|
61
61
|
}>;
|
|
62
62
|
confidence: z.ZodNumber;
|
|
@@ -77,8 +77,8 @@ export declare const pendingUserRequestV1Schema: z.ZodObject<{
|
|
|
77
77
|
requestedAt: z.ZodObject<{
|
|
78
78
|
value: z.ZodString;
|
|
79
79
|
provenance: z.ZodEnum<{
|
|
80
|
-
reported: "reported";
|
|
81
80
|
estimated: "estimated";
|
|
81
|
+
reported: "reported";
|
|
82
82
|
inferred: "inferred";
|
|
83
83
|
}>;
|
|
84
84
|
confidence: z.ZodNumber;
|
|
@@ -99,8 +99,8 @@ export declare const pendingUserRequestV1Schema: z.ZodObject<{
|
|
|
99
99
|
prompt: z.ZodObject<{
|
|
100
100
|
value: z.ZodNullable<z.ZodString>;
|
|
101
101
|
provenance: z.ZodEnum<{
|
|
102
|
-
reported: "reported";
|
|
103
102
|
estimated: "estimated";
|
|
103
|
+
reported: "reported";
|
|
104
104
|
inferred: "inferred";
|
|
105
105
|
}>;
|
|
106
106
|
confidence: z.ZodNumber;
|
|
@@ -133,8 +133,8 @@ export declare const observedAgentSessionV1Schema: z.ZodObject<{
|
|
|
133
133
|
cwd: z.ZodObject<{
|
|
134
134
|
value: z.ZodString;
|
|
135
135
|
provenance: z.ZodEnum<{
|
|
136
|
-
reported: "reported";
|
|
137
136
|
estimated: "estimated";
|
|
137
|
+
reported: "reported";
|
|
138
138
|
inferred: "inferred";
|
|
139
139
|
}>;
|
|
140
140
|
confidence: z.ZodNumber;
|
|
@@ -155,8 +155,8 @@ export declare const observedAgentSessionV1Schema: z.ZodObject<{
|
|
|
155
155
|
model: z.ZodObject<{
|
|
156
156
|
value: z.ZodNullable<z.ZodString>;
|
|
157
157
|
provenance: z.ZodEnum<{
|
|
158
|
-
reported: "reported";
|
|
159
158
|
estimated: "estimated";
|
|
159
|
+
reported: "reported";
|
|
160
160
|
inferred: "inferred";
|
|
161
161
|
}>;
|
|
162
162
|
confidence: z.ZodNumber;
|
|
@@ -182,8 +182,8 @@ export declare const observedAgentSessionV1Schema: z.ZodObject<{
|
|
|
182
182
|
idle: "idle";
|
|
183
183
|
}>;
|
|
184
184
|
provenance: z.ZodEnum<{
|
|
185
|
-
reported: "reported";
|
|
186
185
|
estimated: "estimated";
|
|
186
|
+
reported: "reported";
|
|
187
187
|
inferred: "inferred";
|
|
188
188
|
}>;
|
|
189
189
|
confidence: z.ZodNumber;
|
|
@@ -205,8 +205,8 @@ export declare const observedAgentSessionV1Schema: z.ZodObject<{
|
|
|
205
205
|
inputTokens: z.ZodObject<{
|
|
206
206
|
value: z.ZodNumber;
|
|
207
207
|
provenance: z.ZodEnum<{
|
|
208
|
-
reported: "reported";
|
|
209
208
|
estimated: "estimated";
|
|
209
|
+
reported: "reported";
|
|
210
210
|
inferred: "inferred";
|
|
211
211
|
}>;
|
|
212
212
|
confidence: z.ZodNumber;
|
|
@@ -227,8 +227,8 @@ export declare const observedAgentSessionV1Schema: z.ZodObject<{
|
|
|
227
227
|
outputTokens: z.ZodObject<{
|
|
228
228
|
value: z.ZodNumber;
|
|
229
229
|
provenance: z.ZodEnum<{
|
|
230
|
-
reported: "reported";
|
|
231
230
|
estimated: "estimated";
|
|
231
|
+
reported: "reported";
|
|
232
232
|
inferred: "inferred";
|
|
233
233
|
}>;
|
|
234
234
|
confidence: z.ZodNumber;
|
|
@@ -249,8 +249,8 @@ export declare const observedAgentSessionV1Schema: z.ZodObject<{
|
|
|
249
249
|
cacheReadTokens: z.ZodObject<{
|
|
250
250
|
value: z.ZodNumber;
|
|
251
251
|
provenance: z.ZodEnum<{
|
|
252
|
-
reported: "reported";
|
|
253
252
|
estimated: "estimated";
|
|
253
|
+
reported: "reported";
|
|
254
254
|
inferred: "inferred";
|
|
255
255
|
}>;
|
|
256
256
|
confidence: z.ZodNumber;
|
|
@@ -271,8 +271,8 @@ export declare const observedAgentSessionV1Schema: z.ZodObject<{
|
|
|
271
271
|
cacheWriteTokens: z.ZodObject<{
|
|
272
272
|
value: z.ZodNumber;
|
|
273
273
|
provenance: z.ZodEnum<{
|
|
274
|
-
reported: "reported";
|
|
275
274
|
estimated: "estimated";
|
|
275
|
+
reported: "reported";
|
|
276
276
|
inferred: "inferred";
|
|
277
277
|
}>;
|
|
278
278
|
confidence: z.ZodNumber;
|
|
@@ -302,8 +302,8 @@ export declare const observedAgentSessionV1Schema: z.ZodObject<{
|
|
|
302
302
|
totalTokens: z.ZodNumber;
|
|
303
303
|
}, z.core.$strip>;
|
|
304
304
|
provenance: z.ZodEnum<{
|
|
305
|
-
reported: "reported";
|
|
306
305
|
estimated: "estimated";
|
|
306
|
+
reported: "reported";
|
|
307
307
|
inferred: "inferred";
|
|
308
308
|
}>;
|
|
309
309
|
confidence: z.ZodNumber;
|
|
@@ -324,8 +324,8 @@ export declare const observedAgentSessionV1Schema: z.ZodObject<{
|
|
|
324
324
|
costUsd: z.ZodObject<{
|
|
325
325
|
value: z.ZodNullable<z.ZodNumber>;
|
|
326
326
|
provenance: z.ZodEnum<{
|
|
327
|
-
reported: "reported";
|
|
328
327
|
estimated: "estimated";
|
|
328
|
+
reported: "reported";
|
|
329
329
|
inferred: "inferred";
|
|
330
330
|
}>;
|
|
331
331
|
confidence: z.ZodNumber;
|
|
@@ -360,8 +360,8 @@ export declare const observedAgentSessionV1Schema: z.ZodObject<{
|
|
|
360
360
|
tool_approval: "tool_approval";
|
|
361
361
|
}>;
|
|
362
362
|
provenance: z.ZodEnum<{
|
|
363
|
-
reported: "reported";
|
|
364
363
|
estimated: "estimated";
|
|
364
|
+
reported: "reported";
|
|
365
365
|
inferred: "inferred";
|
|
366
366
|
}>;
|
|
367
367
|
confidence: z.ZodNumber;
|
|
@@ -382,8 +382,8 @@ export declare const observedAgentSessionV1Schema: z.ZodObject<{
|
|
|
382
382
|
requestedAt: z.ZodObject<{
|
|
383
383
|
value: z.ZodString;
|
|
384
384
|
provenance: z.ZodEnum<{
|
|
385
|
-
reported: "reported";
|
|
386
385
|
estimated: "estimated";
|
|
386
|
+
reported: "reported";
|
|
387
387
|
inferred: "inferred";
|
|
388
388
|
}>;
|
|
389
389
|
confidence: z.ZodNumber;
|
|
@@ -404,8 +404,8 @@ export declare const observedAgentSessionV1Schema: z.ZodObject<{
|
|
|
404
404
|
prompt: z.ZodObject<{
|
|
405
405
|
value: z.ZodNullable<z.ZodString>;
|
|
406
406
|
provenance: z.ZodEnum<{
|
|
407
|
-
reported: "reported";
|
|
408
407
|
estimated: "estimated";
|
|
408
|
+
reported: "reported";
|
|
409
409
|
inferred: "inferred";
|
|
410
410
|
}>;
|
|
411
411
|
confidence: z.ZodNumber;
|
|
@@ -437,8 +437,8 @@ export declare const providerCapabilitiesV1Schema: z.ZodObject<{
|
|
|
437
437
|
resume: z.ZodObject<{
|
|
438
438
|
value: z.ZodBoolean;
|
|
439
439
|
provenance: z.ZodEnum<{
|
|
440
|
-
reported: "reported";
|
|
441
440
|
estimated: "estimated";
|
|
441
|
+
reported: "reported";
|
|
442
442
|
inferred: "inferred";
|
|
443
443
|
}>;
|
|
444
444
|
confidence: z.ZodNumber;
|
|
@@ -459,8 +459,8 @@ export declare const providerCapabilitiesV1Schema: z.ZodObject<{
|
|
|
459
459
|
forkLineage: z.ZodObject<{
|
|
460
460
|
value: z.ZodBoolean;
|
|
461
461
|
provenance: z.ZodEnum<{
|
|
462
|
-
reported: "reported";
|
|
463
462
|
estimated: "estimated";
|
|
463
|
+
reported: "reported";
|
|
464
464
|
inferred: "inferred";
|
|
465
465
|
}>;
|
|
466
466
|
confidence: z.ZodNumber;
|
|
@@ -486,8 +486,8 @@ export declare const providerCapabilitiesV1Schema: z.ZodObject<{
|
|
|
486
486
|
mixed: "mixed";
|
|
487
487
|
}>;
|
|
488
488
|
provenance: z.ZodEnum<{
|
|
489
|
-
reported: "reported";
|
|
490
489
|
estimated: "estimated";
|
|
490
|
+
reported: "reported";
|
|
491
491
|
inferred: "inferred";
|
|
492
492
|
}>;
|
|
493
493
|
confidence: z.ZodNumber;
|
|
@@ -508,8 +508,8 @@ export declare const providerCapabilitiesV1Schema: z.ZodObject<{
|
|
|
508
508
|
assetExtraction: z.ZodObject<{
|
|
509
509
|
value: z.ZodBoolean;
|
|
510
510
|
provenance: z.ZodEnum<{
|
|
511
|
-
reported: "reported";
|
|
512
511
|
estimated: "estimated";
|
|
512
|
+
reported: "reported";
|
|
513
513
|
inferred: "inferred";
|
|
514
514
|
}>;
|
|
515
515
|
confidence: z.ZodNumber;
|
package/dist/schemas/quota.d.ts
CHANGED
|
@@ -26,8 +26,8 @@ export declare const quotaProviderIdSchema: z.ZodEnum<{
|
|
|
26
26
|
zai: "zai";
|
|
27
27
|
}>;
|
|
28
28
|
export declare const quotaSourceSchema: z.ZodEnum<{
|
|
29
|
-
api: "api";
|
|
30
29
|
cache: "cache";
|
|
30
|
+
api: "api";
|
|
31
31
|
session: "session";
|
|
32
32
|
statusline: "statusline";
|
|
33
33
|
}>;
|
|
@@ -59,8 +59,8 @@ export declare const codexResetCreditsSnapshotSchema: z.ZodObject<{
|
|
|
59
59
|
grantedAt: z.ZodOptional<z.ZodString>;
|
|
60
60
|
}, z.core.$strip>>;
|
|
61
61
|
source: z.ZodOptional<z.ZodEnum<{
|
|
62
|
-
api: "api";
|
|
63
62
|
cache: "cache";
|
|
63
|
+
api: "api";
|
|
64
64
|
}>>;
|
|
65
65
|
capturedAt: z.ZodOptional<z.ZodString>;
|
|
66
66
|
}, z.core.$strip>;
|
|
@@ -92,8 +92,8 @@ export declare const quotaStateSchema: z.ZodObject<{
|
|
|
92
92
|
zai: "zai";
|
|
93
93
|
}>>;
|
|
94
94
|
source: z.ZodOptional<z.ZodEnum<{
|
|
95
|
-
api: "api";
|
|
96
95
|
cache: "cache";
|
|
96
|
+
api: "api";
|
|
97
97
|
session: "session";
|
|
98
98
|
statusline: "statusline";
|
|
99
99
|
}>>;
|
|
@@ -126,8 +126,8 @@ export declare const quotaStateSchema: z.ZodObject<{
|
|
|
126
126
|
grantedAt: z.ZodOptional<z.ZodString>;
|
|
127
127
|
}, z.core.$strip>>;
|
|
128
128
|
source: z.ZodOptional<z.ZodEnum<{
|
|
129
|
-
api: "api";
|
|
130
129
|
cache: "cache";
|
|
130
|
+
api: "api";
|
|
131
131
|
}>>;
|
|
132
132
|
capturedAt: z.ZodOptional<z.ZodString>;
|
|
133
133
|
}, z.core.$strip>>;
|
|
@@ -204,8 +204,8 @@ export declare const providerQuotaStateSchema: z.ZodObject<{
|
|
|
204
204
|
zai: "zai";
|
|
205
205
|
}>>;
|
|
206
206
|
source: z.ZodOptional<z.ZodEnum<{
|
|
207
|
-
api: "api";
|
|
208
207
|
cache: "cache";
|
|
208
|
+
api: "api";
|
|
209
209
|
session: "session";
|
|
210
210
|
statusline: "statusline";
|
|
211
211
|
}>>;
|
|
@@ -238,8 +238,8 @@ export declare const providerQuotaStateSchema: z.ZodObject<{
|
|
|
238
238
|
grantedAt: z.ZodOptional<z.ZodString>;
|
|
239
239
|
}, z.core.$strip>>;
|
|
240
240
|
source: z.ZodOptional<z.ZodEnum<{
|
|
241
|
-
api: "api";
|
|
242
241
|
cache: "cache";
|
|
242
|
+
api: "api";
|
|
243
243
|
}>>;
|
|
244
244
|
capturedAt: z.ZodOptional<z.ZodString>;
|
|
245
245
|
}, z.core.$strip>>;
|
|
@@ -318,8 +318,8 @@ export declare const claudeProviderQuotaStateSchema: z.ZodObject<{
|
|
|
318
318
|
zai: "zai";
|
|
319
319
|
}>>;
|
|
320
320
|
source: z.ZodOptional<z.ZodEnum<{
|
|
321
|
-
api: "api";
|
|
322
321
|
cache: "cache";
|
|
322
|
+
api: "api";
|
|
323
323
|
session: "session";
|
|
324
324
|
statusline: "statusline";
|
|
325
325
|
}>>;
|
|
@@ -352,8 +352,8 @@ export declare const claudeProviderQuotaStateSchema: z.ZodObject<{
|
|
|
352
352
|
grantedAt: z.ZodOptional<z.ZodString>;
|
|
353
353
|
}, z.core.$strip>>;
|
|
354
354
|
source: z.ZodOptional<z.ZodEnum<{
|
|
355
|
-
api: "api";
|
|
356
355
|
cache: "cache";
|
|
356
|
+
api: "api";
|
|
357
357
|
}>>;
|
|
358
358
|
capturedAt: z.ZodOptional<z.ZodString>;
|
|
359
359
|
}, z.core.$strip>>;
|
|
@@ -428,8 +428,8 @@ export declare const codexProviderQuotaStateSchema: z.ZodObject<{
|
|
|
428
428
|
zai: "zai";
|
|
429
429
|
}>>;
|
|
430
430
|
source: z.ZodOptional<z.ZodEnum<{
|
|
431
|
-
api: "api";
|
|
432
431
|
cache: "cache";
|
|
432
|
+
api: "api";
|
|
433
433
|
session: "session";
|
|
434
434
|
statusline: "statusline";
|
|
435
435
|
}>>;
|
|
@@ -462,8 +462,8 @@ export declare const codexProviderQuotaStateSchema: z.ZodObject<{
|
|
|
462
462
|
grantedAt: z.ZodOptional<z.ZodString>;
|
|
463
463
|
}, z.core.$strip>>;
|
|
464
464
|
source: z.ZodOptional<z.ZodEnum<{
|
|
465
|
-
api: "api";
|
|
466
465
|
cache: "cache";
|
|
466
|
+
api: "api";
|
|
467
467
|
}>>;
|
|
468
468
|
capturedAt: z.ZodOptional<z.ZodString>;
|
|
469
469
|
}, z.core.$strip>>;
|
|
@@ -538,8 +538,8 @@ export declare const zaiProviderQuotaStateSchema: z.ZodObject<{
|
|
|
538
538
|
zai: "zai";
|
|
539
539
|
}>>;
|
|
540
540
|
source: z.ZodOptional<z.ZodEnum<{
|
|
541
|
-
api: "api";
|
|
542
541
|
cache: "cache";
|
|
542
|
+
api: "api";
|
|
543
543
|
session: "session";
|
|
544
544
|
statusline: "statusline";
|
|
545
545
|
}>>;
|
|
@@ -572,8 +572,8 @@ export declare const zaiProviderQuotaStateSchema: z.ZodObject<{
|
|
|
572
572
|
grantedAt: z.ZodOptional<z.ZodString>;
|
|
573
573
|
}, z.core.$strip>>;
|
|
574
574
|
source: z.ZodOptional<z.ZodEnum<{
|
|
575
|
-
api: "api";
|
|
576
575
|
cache: "cache";
|
|
576
|
+
api: "api";
|
|
577
577
|
}>>;
|
|
578
578
|
capturedAt: z.ZodOptional<z.ZodString>;
|
|
579
579
|
}, z.core.$strip>>;
|
|
@@ -649,8 +649,8 @@ export declare const providerQuotaMapSchema: z.ZodObject<{
|
|
|
649
649
|
zai: "zai";
|
|
650
650
|
}>>;
|
|
651
651
|
source: z.ZodOptional<z.ZodEnum<{
|
|
652
|
-
api: "api";
|
|
653
652
|
cache: "cache";
|
|
653
|
+
api: "api";
|
|
654
654
|
session: "session";
|
|
655
655
|
statusline: "statusline";
|
|
656
656
|
}>>;
|
|
@@ -683,8 +683,8 @@ export declare const providerQuotaMapSchema: z.ZodObject<{
|
|
|
683
683
|
grantedAt: z.ZodOptional<z.ZodString>;
|
|
684
684
|
}, z.core.$strip>>;
|
|
685
685
|
source: z.ZodOptional<z.ZodEnum<{
|
|
686
|
-
api: "api";
|
|
687
686
|
cache: "cache";
|
|
687
|
+
api: "api";
|
|
688
688
|
}>>;
|
|
689
689
|
capturedAt: z.ZodOptional<z.ZodString>;
|
|
690
690
|
}, z.core.$strip>>;
|
|
@@ -759,8 +759,8 @@ export declare const providerQuotaMapSchema: z.ZodObject<{
|
|
|
759
759
|
zai: "zai";
|
|
760
760
|
}>>;
|
|
761
761
|
source: z.ZodOptional<z.ZodEnum<{
|
|
762
|
-
api: "api";
|
|
763
762
|
cache: "cache";
|
|
763
|
+
api: "api";
|
|
764
764
|
session: "session";
|
|
765
765
|
statusline: "statusline";
|
|
766
766
|
}>>;
|
|
@@ -793,8 +793,8 @@ export declare const providerQuotaMapSchema: z.ZodObject<{
|
|
|
793
793
|
grantedAt: z.ZodOptional<z.ZodString>;
|
|
794
794
|
}, z.core.$strip>>;
|
|
795
795
|
source: z.ZodOptional<z.ZodEnum<{
|
|
796
|
-
api: "api";
|
|
797
796
|
cache: "cache";
|
|
797
|
+
api: "api";
|
|
798
798
|
}>>;
|
|
799
799
|
capturedAt: z.ZodOptional<z.ZodString>;
|
|
800
800
|
}, z.core.$strip>>;
|
|
@@ -869,8 +869,8 @@ export declare const providerQuotaMapSchema: z.ZodObject<{
|
|
|
869
869
|
zai: "zai";
|
|
870
870
|
}>>;
|
|
871
871
|
source: z.ZodOptional<z.ZodEnum<{
|
|
872
|
-
api: "api";
|
|
873
872
|
cache: "cache";
|
|
873
|
+
api: "api";
|
|
874
874
|
session: "session";
|
|
875
875
|
statusline: "statusline";
|
|
876
876
|
}>>;
|
|
@@ -903,8 +903,8 @@ export declare const providerQuotaMapSchema: z.ZodObject<{
|
|
|
903
903
|
grantedAt: z.ZodOptional<z.ZodString>;
|
|
904
904
|
}, z.core.$strip>>;
|
|
905
905
|
source: z.ZodOptional<z.ZodEnum<{
|
|
906
|
-
api: "api";
|
|
907
906
|
cache: "cache";
|
|
907
|
+
api: "api";
|
|
908
908
|
}>>;
|
|
909
909
|
capturedAt: z.ZodOptional<z.ZodString>;
|
|
910
910
|
}, z.core.$strip>>;
|
|
@@ -34,8 +34,8 @@ export declare const quotaHistorySampleSchema: z.ZodObject<{
|
|
|
34
34
|
available: z.ZodBoolean;
|
|
35
35
|
error: z.ZodOptional<z.ZodString>;
|
|
36
36
|
source: z.ZodOptional<z.ZodEnum<{
|
|
37
|
-
api: "api";
|
|
38
37
|
cache: "cache";
|
|
38
|
+
api: "api";
|
|
39
39
|
session: "session";
|
|
40
40
|
statusline: "statusline";
|
|
41
41
|
}>>;
|
|
@@ -27,8 +27,8 @@ export declare const stateFileQuotaSchema: z.ZodObject<{
|
|
|
27
27
|
resetsAt: z.ZodString;
|
|
28
28
|
}, z.core.$strip>;
|
|
29
29
|
source: z.ZodNullable<z.ZodEnum<{
|
|
30
|
-
api: "api";
|
|
31
30
|
cache: "cache";
|
|
31
|
+
api: "api";
|
|
32
32
|
session: "session";
|
|
33
33
|
statusline: "statusline";
|
|
34
34
|
}>>;
|
|
@@ -77,8 +77,8 @@ export declare const stateFileBillingBlockSchema: z.ZodObject<{
|
|
|
77
77
|
costUsd: z.ZodNumber;
|
|
78
78
|
costProvenance: z.ZodEnum<{
|
|
79
79
|
none: "none";
|
|
80
|
-
reported: "reported";
|
|
81
80
|
estimated: "estimated";
|
|
81
|
+
reported: "reported";
|
|
82
82
|
unpriced: "unpriced";
|
|
83
83
|
mixed: "mixed";
|
|
84
84
|
}>;
|
|
@@ -114,8 +114,8 @@ export declare const sidekickStateFileSchema: z.ZodObject<{
|
|
|
114
114
|
resetsAt: z.ZodString;
|
|
115
115
|
}, z.core.$strip>;
|
|
116
116
|
source: z.ZodNullable<z.ZodEnum<{
|
|
117
|
-
api: "api";
|
|
118
117
|
cache: "cache";
|
|
118
|
+
api: "api";
|
|
119
119
|
session: "session";
|
|
120
120
|
statusline: "statusline";
|
|
121
121
|
}>>;
|
|
@@ -142,8 +142,8 @@ export declare const sidekickStateFileSchema: z.ZodObject<{
|
|
|
142
142
|
resetsAt: z.ZodString;
|
|
143
143
|
}, z.core.$strip>;
|
|
144
144
|
source: z.ZodNullable<z.ZodEnum<{
|
|
145
|
-
api: "api";
|
|
146
145
|
cache: "cache";
|
|
146
|
+
api: "api";
|
|
147
147
|
session: "session";
|
|
148
148
|
statusline: "statusline";
|
|
149
149
|
}>>;
|
|
@@ -185,8 +185,8 @@ export declare const sidekickStateFileSchema: z.ZodObject<{
|
|
|
185
185
|
costUsd: z.ZodNumber;
|
|
186
186
|
costProvenance: z.ZodEnum<{
|
|
187
187
|
none: "none";
|
|
188
|
-
reported: "reported";
|
|
189
188
|
estimated: "estimated";
|
|
189
|
+
reported: "reported";
|
|
190
190
|
unpriced: "unpriced";
|
|
191
191
|
mixed: "mixed";
|
|
192
192
|
}>;
|
package/dist/terminalSync.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
1
|
+
import type { AccountProviderId } from './accountRegistry';
|
|
2
|
+
/**
|
|
3
|
+
* Write a POSIX launcher script that runs the provider CLI against a profile
|
|
4
|
+
* home. Unix only; on Windows use `sidekick accounts env --shell powershell`.
|
|
5
|
+
*/
|
|
6
6
|
export declare function writeLauncher(name: string, provider: AccountProviderId, profileHome: string): void;
|
|
7
7
|
export declare function removeLauncher(name: string): void;
|
package/dist/terminalSync.js
CHANGED
|
@@ -33,130 +33,20 @@ var __importStar = (this && this.__importStar) || (function () {
|
|
|
33
33
|
};
|
|
34
34
|
})();
|
|
35
35
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
|
-
exports.setTerminalActiveProfile = setTerminalActiveProfile;
|
|
37
|
-
exports.installShellHook = installShellHook;
|
|
38
|
-
exports.uninstallShellHook = uninstallShellHook;
|
|
39
|
-
exports.isShellHookInstalled = isShellHookInstalled;
|
|
40
36
|
exports.writeLauncher = writeLauncher;
|
|
41
37
|
exports.removeLauncher = removeLauncher;
|
|
42
38
|
const fs = __importStar(require("fs"));
|
|
43
39
|
const os = __importStar(require("os"));
|
|
44
40
|
const path = __importStar(require("path"));
|
|
45
|
-
const
|
|
46
|
-
const HOOK_START = '# >>> sidekick >>>';
|
|
47
|
-
const HOOK_END = '# <<< sidekick <<<';
|
|
41
|
+
const atomic_1 = require("./writers/atomic");
|
|
48
42
|
const LAUNCHER_MARKER = '# sidekick-launcher v1';
|
|
49
43
|
const LAUNCHER_NAME_PATTERN = /^[a-zA-Z0-9_-]+$/;
|
|
50
|
-
function providerPointerName(provider) {
|
|
51
|
-
return provider === 'claude-code' ? 'claude' : 'codex';
|
|
52
|
-
}
|
|
53
44
|
function providerEnvVar(provider) {
|
|
54
45
|
return provider === 'claude-code' ? 'CLAUDE_CONFIG_DIR' : 'CODEX_HOME';
|
|
55
46
|
}
|
|
56
47
|
function providerBinary(provider) {
|
|
57
48
|
return provider === 'claude-code' ? 'claude' : 'codex';
|
|
58
49
|
}
|
|
59
|
-
function getActiveProfilesDir() {
|
|
60
|
-
return path.join((0, accountRegistry_1.getAccountsDir)(), 'active');
|
|
61
|
-
}
|
|
62
|
-
function getActiveProfilePath(provider) {
|
|
63
|
-
return path.join(getActiveProfilesDir(), `${providerPointerName(provider)}.profile`);
|
|
64
|
-
}
|
|
65
|
-
function atomicWriteFile(filePath, content, mode = 0o600) {
|
|
66
|
-
fs.mkdirSync(path.dirname(filePath), { recursive: true, mode: 0o700 });
|
|
67
|
-
const tmp = `${filePath}.tmp`;
|
|
68
|
-
try {
|
|
69
|
-
fs.writeFileSync(tmp, content, { encoding: 'utf8', mode });
|
|
70
|
-
fs.renameSync(tmp, filePath);
|
|
71
|
-
}
|
|
72
|
-
catch (err) {
|
|
73
|
-
try {
|
|
74
|
-
fs.rmSync(tmp, { force: true });
|
|
75
|
-
}
|
|
76
|
-
catch {
|
|
77
|
-
/* nothing to clean up */
|
|
78
|
-
}
|
|
79
|
-
throw err;
|
|
80
|
-
}
|
|
81
|
-
}
|
|
82
|
-
function setTerminalActiveProfile(provider, home) {
|
|
83
|
-
const pointerPath = getActiveProfilePath(provider);
|
|
84
|
-
if (home === null) {
|
|
85
|
-
fs.rmSync(pointerPath, { force: true });
|
|
86
|
-
return;
|
|
87
|
-
}
|
|
88
|
-
atomicWriteFile(pointerPath, `${home}\n`);
|
|
89
|
-
}
|
|
90
|
-
function shellQuote(value) {
|
|
91
|
-
return `'${value.replace(/'/g, `'\\''`)}'`;
|
|
92
|
-
}
|
|
93
|
-
function buildShellHookBlock() {
|
|
94
|
-
const claudePointer = getActiveProfilePath('claude-code');
|
|
95
|
-
const codexPointer = getActiveProfilePath('codex');
|
|
96
|
-
return [
|
|
97
|
-
HOOK_START,
|
|
98
|
-
'sidekick_sync() {',
|
|
99
|
-
` if [ -r ${shellQuote(claudePointer)} ]; then export CLAUDE_CONFIG_DIR="$(cat ${shellQuote(claudePointer)})"; else unset CLAUDE_CONFIG_DIR; fi`,
|
|
100
|
-
` if [ -r ${shellQuote(codexPointer)} ]; then export CODEX_HOME="$(cat ${shellQuote(codexPointer)})"; else unset CODEX_HOME; fi`,
|
|
101
|
-
'}',
|
|
102
|
-
'sidekick_sync >/dev/null 2>&1',
|
|
103
|
-
HOOK_END,
|
|
104
|
-
'',
|
|
105
|
-
].join('\n');
|
|
106
|
-
}
|
|
107
|
-
function getShellRcPaths() {
|
|
108
|
-
const zshrc = path.join(os.homedir(), '.zshrc');
|
|
109
|
-
const bashrc = path.join(os.homedir(), '.bashrc');
|
|
110
|
-
const existing = [zshrc, bashrc].filter((filePath) => fs.existsSync(filePath));
|
|
111
|
-
if (existing.length > 0)
|
|
112
|
-
return existing;
|
|
113
|
-
const shell = path.basename(process.env.SHELL ?? 'zsh');
|
|
114
|
-
return shell === 'bash' ? [bashrc] : [zshrc];
|
|
115
|
-
}
|
|
116
|
-
function resolveShellRcTarget(filePath) {
|
|
117
|
-
if (!fs.existsSync(filePath))
|
|
118
|
-
return { filePath, mode: 0o600 };
|
|
119
|
-
const realPath = fs.realpathSync(filePath);
|
|
120
|
-
return { filePath: realPath, mode: fs.statSync(realPath).mode & 0o777 };
|
|
121
|
-
}
|
|
122
|
-
function stripShellHook(content) {
|
|
123
|
-
const pattern = new RegExp(`${HOOK_START}[\\s\\S]*?${HOOK_END}\\n?`, 'g');
|
|
124
|
-
return content.replace(pattern, '').replace(/\n{3,}/g, '\n\n');
|
|
125
|
-
}
|
|
126
|
-
function installHookInFile(filePath) {
|
|
127
|
-
const target = resolveShellRcTarget(filePath);
|
|
128
|
-
const existing = fs.existsSync(target.filePath) ? fs.readFileSync(target.filePath, 'utf8') : '';
|
|
129
|
-
const cleaned = stripShellHook(existing).replace(/\s*$/, '');
|
|
130
|
-
const next = cleaned ? `${cleaned}\n\n${buildShellHookBlock()}` : buildShellHookBlock();
|
|
131
|
-
atomicWriteFile(target.filePath, next, target.mode);
|
|
132
|
-
}
|
|
133
|
-
function installShellHook() {
|
|
134
|
-
for (const rcPath of getShellRcPaths()) {
|
|
135
|
-
installHookInFile(rcPath);
|
|
136
|
-
}
|
|
137
|
-
}
|
|
138
|
-
function uninstallHookInFile(filePath) {
|
|
139
|
-
if (!fs.existsSync(filePath))
|
|
140
|
-
return;
|
|
141
|
-
const target = resolveShellRcTarget(filePath);
|
|
142
|
-
atomicWriteFile(target.filePath, stripShellHook(fs.readFileSync(target.filePath, 'utf8')), target.mode);
|
|
143
|
-
}
|
|
144
|
-
function uninstallShellHook() {
|
|
145
|
-
for (const rcPath of getShellRcPaths()) {
|
|
146
|
-
uninstallHookInFile(rcPath);
|
|
147
|
-
}
|
|
148
|
-
}
|
|
149
|
-
function isShellHookInstalled() {
|
|
150
|
-
return getShellRcPaths().some((rcPath) => {
|
|
151
|
-
try {
|
|
152
|
-
const content = fs.readFileSync(rcPath, 'utf8');
|
|
153
|
-
return content.includes(HOOK_START) && content.includes(HOOK_END);
|
|
154
|
-
}
|
|
155
|
-
catch {
|
|
156
|
-
return false;
|
|
157
|
-
}
|
|
158
|
-
});
|
|
159
|
-
}
|
|
160
50
|
function getLauncherDir() {
|
|
161
51
|
return path.join(os.homedir(), '.local', 'bin');
|
|
162
52
|
}
|
|
@@ -189,6 +79,10 @@ function assertNoLauncherCollision(name, targetPath) {
|
|
|
189
79
|
}
|
|
190
80
|
}
|
|
191
81
|
}
|
|
82
|
+
/**
|
|
83
|
+
* Write a POSIX launcher script that runs the provider CLI against a profile
|
|
84
|
+
* home. Unix only; on Windows use `sidekick accounts env --shell powershell`.
|
|
85
|
+
*/
|
|
192
86
|
function writeLauncher(name, provider, profileHome) {
|
|
193
87
|
assertValidLauncherName(name);
|
|
194
88
|
const launcherPath = getLauncherPath(name);
|
|
@@ -199,10 +93,11 @@ function writeLauncher(name, provider, profileHome) {
|
|
|
199
93
|
'#!/bin/sh',
|
|
200
94
|
LAUNCHER_MARKER,
|
|
201
95
|
`export ${envVar}=${JSON.stringify(profileHome)}`,
|
|
96
|
+
...(provider === 'claude-code' ? ['unset CLAUDE_SECURESTORAGE_CONFIG_DIR'] : []),
|
|
202
97
|
`exec ${binary} "$@"`,
|
|
203
98
|
'',
|
|
204
99
|
].join('\n');
|
|
205
|
-
|
|
100
|
+
(0, atomic_1.atomicWriteFileSync)(launcherPath, script, 0o755);
|
|
206
101
|
}
|
|
207
102
|
function removeLauncher(name) {
|
|
208
103
|
assertValidLauncherName(name);
|
package/dist/writers/atomic.d.ts
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
export declare function renameSyncWithRetry(from: string, to: string): void;
|
|
2
|
+
export declare function renameWithRetry(from: string, to: string): Promise<void>;
|
|
1
3
|
export declare function atomicWriteJson(filePath: string, value: unknown): Promise<void>;
|
|
2
4
|
export declare function atomicWriteJsonSync(filePath: string, value: unknown): void;
|
|
3
5
|
/** Raw-string sibling of {@link atomicWriteJsonSync} for non-JSON payloads. */
|
package/dist/writers/atomic.js
CHANGED
|
@@ -33,6 +33,8 @@ var __importStar = (this && this.__importStar) || (function () {
|
|
|
33
33
|
};
|
|
34
34
|
})();
|
|
35
35
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
|
+
exports.renameSyncWithRetry = renameSyncWithRetry;
|
|
37
|
+
exports.renameWithRetry = renameWithRetry;
|
|
36
38
|
exports.atomicWriteJson = atomicWriteJson;
|
|
37
39
|
exports.atomicWriteJsonSync = atomicWriteJsonSync;
|
|
38
40
|
exports.atomicWriteFileSync = atomicWriteFileSync;
|
|
@@ -71,6 +73,51 @@ const LOCK_ABANDONED_MS = 120_000;
|
|
|
71
73
|
const SYNC_LOCK_MAX_WAIT_MS = 15_000;
|
|
72
74
|
const LOCK_WAIT_INTERVAL_MS = 15;
|
|
73
75
|
const lockSleepView = new Int32Array(new SharedArrayBuffer(4));
|
|
76
|
+
/**
|
|
77
|
+
* Windows refuses to replace a file another process holds open (antivirus
|
|
78
|
+
* scanners, an editor extension re-reading `auth.json`) with EPERM/EBUSY/EACCES
|
|
79
|
+
* even though the rename would succeed a few milliseconds later. Retry with a
|
|
80
|
+
* short back-off on that platform only; other platforms surface the error.
|
|
81
|
+
*/
|
|
82
|
+
const WIN32_RENAME_RETRY_CODES = new Set(['EPERM', 'EBUSY', 'EACCES']);
|
|
83
|
+
const WIN32_RENAME_MAX_ATTEMPTS = 10;
|
|
84
|
+
function renameRetryDelayMs(attempt) {
|
|
85
|
+
return Math.min(320, 20 * 2 ** attempt);
|
|
86
|
+
}
|
|
87
|
+
function shouldRetryRename(error, attempt) {
|
|
88
|
+
if (process.platform !== 'win32')
|
|
89
|
+
return false;
|
|
90
|
+
if (attempt >= WIN32_RENAME_MAX_ATTEMPTS - 1)
|
|
91
|
+
return false;
|
|
92
|
+
const code = error.code ?? '';
|
|
93
|
+
return WIN32_RENAME_RETRY_CODES.has(code);
|
|
94
|
+
}
|
|
95
|
+
function renameSyncWithRetry(from, to) {
|
|
96
|
+
for (let attempt = 0;; attempt++) {
|
|
97
|
+
try {
|
|
98
|
+
fs.renameSync(from, to);
|
|
99
|
+
return;
|
|
100
|
+
}
|
|
101
|
+
catch (error) {
|
|
102
|
+
if (!shouldRetryRename(error, attempt))
|
|
103
|
+
throw error;
|
|
104
|
+
Atomics.wait(lockSleepView, 0, 0, renameRetryDelayMs(attempt));
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
async function renameWithRetry(from, to) {
|
|
109
|
+
for (let attempt = 0;; attempt++) {
|
|
110
|
+
try {
|
|
111
|
+
await fs.promises.rename(from, to);
|
|
112
|
+
return;
|
|
113
|
+
}
|
|
114
|
+
catch (error) {
|
|
115
|
+
if (!shouldRetryRename(error, attempt))
|
|
116
|
+
throw error;
|
|
117
|
+
await new Promise((resolve) => setTimeout(resolve, renameRetryDelayMs(attempt)));
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
}
|
|
74
121
|
async function syncDirectory(directory) {
|
|
75
122
|
let handle;
|
|
76
123
|
try {
|
|
@@ -112,7 +159,7 @@ async function atomicWriteJson(filePath, value) {
|
|
|
112
159
|
await handle.sync();
|
|
113
160
|
await handle.close();
|
|
114
161
|
handle = undefined;
|
|
115
|
-
await
|
|
162
|
+
await renameWithRetry(tempPath, filePath);
|
|
116
163
|
await syncDirectory(path.dirname(filePath));
|
|
117
164
|
}
|
|
118
165
|
catch (error) {
|
|
@@ -135,7 +182,7 @@ function atomicWriteFileSync(filePath, content, mode = 0o600) {
|
|
|
135
182
|
fs.fsyncSync(descriptor);
|
|
136
183
|
fs.closeSync(descriptor);
|
|
137
184
|
descriptor = undefined;
|
|
138
|
-
|
|
185
|
+
renameSyncWithRetry(tempPath, filePath);
|
|
139
186
|
syncDirectorySync(path.dirname(filePath));
|
|
140
187
|
}
|
|
141
188
|
catch (error) {
|