sidekick-shared 0.26.5 → 0.27.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 +49 -0
- package/README.md +98 -59
- 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/humanPrompt.d.ts +27 -0
- package/dist/humanPrompt.js +93 -0
- package/dist/index.d.ts +31 -10
- package/dist/index.js +72 -13
- package/dist/keepAlive.d.ts +44 -0
- package/dist/keepAlive.js +106 -0
- package/dist/modelContext.js +4 -0
- package/dist/modelInfo.js +26 -1
- package/dist/node.d.ts +4 -0
- package/dist/node.js +9 -2
- package/dist/processDetection.d.ts +32 -0
- package/dist/processDetection.js +210 -0
- package/dist/promptHistory.d.ts +108 -0
- package/dist/promptHistory.js +616 -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/sessionEvent.d.ts +25 -0
- package/dist/schemas/sessionEvent.js +3 -0
- package/dist/schemas/stateFile.d.ts +5 -5
- package/dist/terminalSync.d.ts +5 -5
- package/dist/terminalSync.js +7 -112
- package/dist/transcript.d.ts +6 -0
- package/dist/transcript.js +3 -0
- package/dist/types/sessionEvent.d.ts +8 -0
- package/dist/writers/atomic.d.ts +2 -0
- package/dist/writers/atomic.js +49 -2
- package/package.json +1 -1
package/dist/transcript.js
CHANGED
|
@@ -41,6 +41,9 @@ function projectSessionTranscript(events, options = {}) {
|
|
|
41
41
|
entrypoint: event.entrypoint,
|
|
42
42
|
isMeta: event.isMeta,
|
|
43
43
|
isSidechain: event.isSidechain,
|
|
44
|
+
...(event.isCompactSummary !== undefined ? { isCompactSummary: event.isCompactSummary } : {}),
|
|
45
|
+
...(event.origin?.kind !== undefined ? { originKind: event.origin.kind } : {}),
|
|
46
|
+
...(event.promptSource !== undefined ? { promptSource: event.promptSource } : {}),
|
|
44
47
|
originalRole: message?.role,
|
|
45
48
|
eventIndex,
|
|
46
49
|
eventType: event.type,
|
|
@@ -65,6 +65,14 @@ export interface SessionEventBase {
|
|
|
65
65
|
isMeta?: boolean;
|
|
66
66
|
/** Whether this is a subagent/sidechain event */
|
|
67
67
|
isSidechain?: boolean;
|
|
68
|
+
/** Whether the provider marks this event as a compaction/continuation summary. */
|
|
69
|
+
isCompactSummary?: boolean;
|
|
70
|
+
/** Provider-reported prompt origin (Claude Code `origin.kind`, e.g. `human`, `task-notification`). */
|
|
71
|
+
origin?: {
|
|
72
|
+
kind?: string;
|
|
73
|
+
};
|
|
74
|
+
/** Provider-reported prompt source (Claude Code `promptSource`, e.g. `typed`, `system`). */
|
|
75
|
+
promptSource?: string;
|
|
68
76
|
/** Provider-reported working directory for this event/session. */
|
|
69
77
|
cwd?: string;
|
|
70
78
|
/** Provider-reported git branch for this event/session. */
|
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) {
|