shennian 0.2.77 → 0.2.83

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.
@@ -14,12 +14,6 @@ function normalizeText(text) {
14
14
  function isCodexRolloutPath(filePath) {
15
15
  return filePath.split(/[\\/]+/).includes('.codex');
16
16
  }
17
- function shouldBackfillWindowsCodex(state) {
18
- return process.platform === 'win32' && state.codexWindowsPathParserFixed !== true;
19
- }
20
- function shouldBackfillCodexAppContextWrapper(state) {
21
- return state.codexAppContextWrapperFixed !== true;
22
- }
23
17
  export class NativeSessionFusionService {
24
18
  client;
25
19
  timer = null;
@@ -99,8 +93,6 @@ export class NativeSessionFusionService {
99
93
  this.pruneState();
100
94
  const state = loadNativeScannerState();
101
95
  const nextFilesState = { ...state.files };
102
- const backfillWindowsCodex = shouldBackfillWindowsCodex(state);
103
- const backfillCodexAppContextWrapper = shouldBackfillCodexAppContextWrapper(state);
104
96
  const batches = [];
105
97
  const files = [...listCodexRolloutFiles(), ...listClaudeTranscriptFiles(), ...listOpenCodeSessionFiles()];
106
98
  for (const filePath of files) {
@@ -115,12 +107,9 @@ export class NativeSessionFusionService {
115
107
  }
116
108
  const isCodex = isCodexRolloutPath(filePath);
117
109
  const isOpenCode = filePath.endsWith('.opencode-session.json');
118
- const isCodexRepairBackfillFile = backfillCodexAppContextWrapper && isCodex && current != null;
119
110
  const startOffset = isOpenCode && current?.mtimeMs !== stat.mtimeMs
120
- ? 0
121
- : (backfillWindowsCodex || isCodexRepairBackfillFile) && isCodex
122
- ? 0
123
- : current?.offset ?? 0;
111
+ ? current.offset
112
+ : current?.offset ?? 0;
124
113
  const parsed = isOpenCode
125
114
  ? parseOpenCodeSessionFile(filePath, startOffset)
126
115
  : isCodex
@@ -130,10 +119,7 @@ export class NativeSessionFusionService {
130
119
  offset: parsed.nextOffset,
131
120
  mtimeMs: stat.mtimeMs,
132
121
  };
133
- const parsedEvents = isCodexRepairBackfillFile && startOffset === 0
134
- ? parsed.events.filter((event) => event.repairHint === 'codex_app_context_wrapper')
135
- : parsed.events;
136
- for (const event of parsedEvents) {
122
+ for (const event of parsed.events) {
137
123
  const claimed = this.tryClaimManagedEcho(event);
138
124
  if (claimed) {
139
125
  batches.push(claimed);
@@ -157,12 +143,6 @@ export class NativeSessionFusionService {
157
143
  }, 60_000);
158
144
  }
159
145
  state.files = nextFilesState;
160
- if (backfillWindowsCodex) {
161
- state.codexWindowsPathParserFixed = true;
162
- }
163
- if (backfillCodexAppContextWrapper) {
164
- state.codexAppContextWrapperFixed = true;
165
- }
166
146
  saveNativeScannerState(state);
167
147
  }
168
148
  tryClaimManagedEcho(event) {
@@ -10,6 +10,7 @@ const BACKUP_DIR = resolveShennianPath('backup');
10
10
  const UPGRADE_ATTEMPT_FILE = resolveShennianPath('upgrade-attempt.json');
11
11
  const MAX_CRASH_COUNT = 3;
12
12
  const BACKUP_TTL_DAYS = 7;
13
+ const NPM_REGISTRY_FALLBACK = 'https://registry.npmjs.org';
13
14
  const RETRY_DELAYS_MS = [
14
15
  5 * 60_000,
15
16
  30 * 60_000,
@@ -272,7 +273,7 @@ export async function performUpgrade(targetVersion, onProgress, opts = {}) {
272
273
  // Step 3: npm install new version
273
274
  onProgress({ step: 'installing', version: targetVersion });
274
275
  try {
275
- await exec(`npm install -g shennian@${targetVersion}`, { timeout: 120_000, windowsHide: true });
276
+ await installShennianVersion(targetVersion);
276
277
  }
277
278
  catch (err) {
278
279
  // Restore backup and abort
@@ -318,6 +319,24 @@ export async function performUpgrade(targetVersion, onProgress, opts = {}) {
318
319
  onProgress({ step: 'restarting', from: currentVersion, to: targetVersion });
319
320
  return { ok: true, from: currentVersion, to: targetVersion };
320
321
  }
322
+ async function installShennianVersion(targetVersion) {
323
+ try {
324
+ await exec(`npm install -g shennian@${targetVersion}`, { timeout: 120_000, windowsHide: true });
325
+ }
326
+ catch (error) {
327
+ const firstMessage = error instanceof Error ? error.message : String(error);
328
+ try {
329
+ await exec(`npm install -g shennian@${targetVersion} --registry ${NPM_REGISTRY_FALLBACK}`, {
330
+ timeout: 120_000,
331
+ windowsHide: true,
332
+ });
333
+ }
334
+ catch (fallbackError) {
335
+ const secondMessage = fallbackError instanceof Error ? fallbackError.message : String(fallbackError);
336
+ throw new Error(`${firstMessage}\n--- npmjs fallback ---\n${secondMessage}`);
337
+ }
338
+ }
339
+ }
321
340
  export async function checkForUpdate(currentVersion) {
322
341
  const current = currentVersion ?? getCurrentVersion();
323
342
  const latest = await fetchLatestVersion();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "shennian",
3
- "version": "0.2.77",
3
+ "version": "0.2.83",
4
4
  "description": "Shennian — AI Agent Control Plane CLI",
5
5
  "type": "module",
6
6
  "bin": {
@@ -36,11 +36,11 @@
36
36
  "dependencies": {
37
37
  "@mariozechner/pi-agent-core": "^0.64.0",
38
38
  "@sinclair/typebox": "^0.34.49",
39
- "@shennian/wire": "^0.1.5",
40
39
  "chalk": "^5.4.1",
41
40
  "commander": "^13.1.0",
42
41
  "qrcode-terminal": "^0.12.0",
43
- "ws": "^8.18.1"
42
+ "ws": "^8.18.1",
43
+ "@shennian/wire": "0.1.5"
44
44
  },
45
45
  "devDependencies": {
46
46
  "@types/node": "^20",