@yuriai/web 0.1.20 → 0.1.22

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.
Files changed (79) hide show
  1. package/dist/assets/{AgentAvatar-Dn3d91Bp.js → AgentAvatar-C2p8G_Xw.js} +1 -1
  2. package/dist/assets/{AssistantView-Mu5sPh2W.js → AssistantView-B-vEm0jN.js} +3 -3
  3. package/dist/assets/{DiagramView-bzCP60wE.js → DiagramView-DT5CPdtn.js} +1 -1
  4. package/dist/assets/{FadeInOnReveal-D7ifJQAw.js → FadeInOnReveal-DhAYqopy.js} +1 -1
  5. package/dist/assets/{Icon-DZmADJWp.js → Icon-DKFfVCeK.js} +1 -1
  6. package/dist/assets/{ImageLoadingPlaceholder-Dw4P79Ms.js → ImageLoadingPlaceholder-DD2g7FjK.js} +1 -1
  7. package/dist/assets/{LoadingImage-CCKvcYRc.js → LoadingImage-Dc7hnEQ7.js} +1 -1
  8. package/dist/assets/{MarkdownRenderer-IKfW9Cjc.js → MarkdownRenderer-kDYymiH3.js} +2 -2
  9. package/dist/assets/{MarkdownRendererImpl-CjP0s7aP.js → MarkdownRendererImpl-cS5FXxon.js} +1 -1
  10. package/dist/assets/{MarkstreamRendererImpl-DwlqEaFC.js → MarkstreamRendererImpl-CO1AzJsB.js} +1 -1
  11. package/dist/assets/{MobileDetailNavigation-B8LAq0IX.js → MobileDetailNavigation-RLH6AQBN.js} +1 -1
  12. package/dist/assets/{MobileShareBridge-Dr13-74t.js → MobileShareBridge-CijqYDMo.js} +1 -1
  13. package/dist/assets/{MobileTabPageHeader-a9_X2cyT.js → MobileTabPageHeader-BZKymEeY.js} +1 -1
  14. package/dist/assets/{MultiRunWindow-Cy2N-jeD.js → MultiRunWindow-BBADn01m.js} +1 -1
  15. package/dist/assets/{OnboardingScreen-DE2iB21m.js → OnboardingScreen-Dau5R5ew.js} +1 -1
  16. package/dist/assets/{OverlayScrollbar-BlzvB3ct.js → OverlayScrollbar-Dxdkid6A.js} +1 -1
  17. package/dist/assets/{SettingsView-DJz1My_v.js → SettingsView-BDw1UGgS.js} +3 -3
  18. package/dist/assets/{SettingsWindow-ClpYdemG.js → SettingsWindow-DQz1f-kO.js} +1 -1
  19. package/dist/assets/{TerminalView-CI09r9y5.js → TerminalView-CpGeHiw4.js} +1 -1
  20. package/dist/assets/{ToolOutputDialog-UMcI4Zho.js → ToolOutputDialog-qF2onmML.js} +1 -1
  21. package/dist/assets/{YuriLogo-Dm011NCM.js → YuriLogo-CgTkNYZf.js} +1 -1
  22. package/dist/assets/{appThemeRegistry-2SvgJE7r.js → appThemeRegistry-DmRKfJL3.js} +1 -1
  23. package/dist/assets/{button-CEcZQm-B.js → button-LPikURUk.js} +1 -1
  24. package/dist/assets/{capgoAdapter-D9f3CiJN.js → capgoAdapter-BmTEnR2_.js} +1 -1
  25. package/dist/assets/{collapsible-B6ON5Mai.js → collapsible-CbQmi7qt.js} +1 -1
  26. package/dist/assets/{diagram-9xxUjDb_.js → diagram-DWkoS1Uc.js} +1 -1
  27. package/dist/assets/{dialog-CjPdvmr0.js → dialog-D8AYQa70.js} +1 -1
  28. package/dist/assets/{dropdown-menu.styles-Cm3A3LAl.js → dropdown-menu.styles-BXRbrWW5.js} +1 -1
  29. package/dist/assets/{es-CqWNlkik.js → es-Le3f45R2.js} +1 -1
  30. package/dist/assets/{fileMentionTouchSelection-CFWWsHMy.js → fileMentionTouchSelection-FDObhofW.js} +1 -1
  31. package/dist/assets/{fr-CpxexYkk.js → fr-Knp2_Wkz.js} +1 -1
  32. package/dist/assets/{gitApi-BoCv5QK2.js → gitApi-D8IPglEo.js} +1 -1
  33. package/dist/assets/{input-yYSzMq8L.js → input-CAhwlkOT.js} +1 -1
  34. package/dist/assets/{insertionBoundaries-CecUkYvp.js → insertionBoundaries-DE8RyJf4.js} +1 -1
  35. package/dist/assets/{ja-ByTgQPSi.js → ja-_KJ_VLgM.js} +1 -1
  36. package/dist/assets/{ko-BGfRP-3B.js → ko-CmWIeRHF.js} +1 -1
  37. package/dist/assets/{main-CjoDtGqO.js → main-BLMeK7Ed.js} +4 -4
  38. package/dist/assets/{main-BtKG4Oot.js → main-Bh0kUjiw.js} +2 -2
  39. package/dist/assets/{markdownHeightCache-w0HDCLwk.js → markdownHeightCache-CylzGsAe.js} +1 -1
  40. package/dist/assets/{mcpQueries-CwkJ4NQA.js → mcpQueries-BFkB-7V_.js} +1 -1
  41. package/dist/assets/{miniChat-CW0R2U5t.js → miniChat-Ciy0u8ci.js} +2 -2
  42. package/dist/assets/{mobile-ClKyarOu.js → mobile-Bm0sCDXq.js} +2 -2
  43. package/dist/assets/{mobileBackNavigation-6jBA1pR0.js → mobileBackNavigation-BwxOTY4b.js} +1 -1
  44. package/dist/assets/{multirun-DJWMunGf.js → multirun-CyHj2_Qf.js} +1 -1
  45. package/dist/assets/{native-config-DPmta_0r.js → native-config-BDst1Okm.js} +1 -1
  46. package/dist/assets/{pl-DIwCzbXW.js → pl-BoXY-ki3.js} +1 -1
  47. package/dist/assets/{projectMeta-R1cugLKq.js → projectMeta-C75m7wMM.js} +1 -1
  48. package/dist/assets/{pt-BR-4MjIbbWQ.js → pt-BR-C3gsTrhe.js} +1 -1
  49. package/dist/assets/{renderElectronMiniChatApp-Dof7xxix.js → renderElectronMiniChatApp-BSX59NyD.js} +2 -2
  50. package/dist/assets/{renderMobileApp-CMWkdtmy.js → renderMobileApp-BM8Bg3sb.js} +5 -5
  51. package/dist/assets/{runtimeConfig-HmoxZCZV.js → runtimeConfig-D0UDGecm.js} +1 -1
  52. package/dist/assets/{runtimeEndpointReset-DRv3nf7i.js → runtimeEndpointReset-Df4Jlmne.js} +2 -2
  53. package/dist/assets/{scheduledTaskNavigation-BhsUww-K.js → scheduledTaskNavigation-BE3Okq7X.js} +1 -1
  54. package/dist/assets/{sessionChangeSummary-w0goW1R2.js → sessionChangeSummary-DkIJkqeG.js} +1 -1
  55. package/dist/assets/{sessionLookup-Clh1wb_a.js → sessionLookup-DhcUVJQR.js} +1 -1
  56. package/dist/assets/{sortable-tabs-strip-MyKMqyvw.js → sortable-tabs-strip-CQR5TsUS.js} +1 -1
  57. package/dist/assets/speechSettingsQueries-BWIoMe5c.js +4 -0
  58. package/dist/assets/src-DlJVKekb.css +2 -0
  59. package/dist/assets/{store-JjNwX_aQ.js → store-CnVXA4NH.js} +2 -2
  60. package/dist/assets/{textarea-CO8JEdzP.js → textarea-pQCq-iLS.js} +1 -1
  61. package/dist/assets/{tooltip-Dmw1nU2I.js → tooltip-CFuO3PUH.js} +1 -1
  62. package/dist/assets/{types-DeOBiX60.js → types-2CUEL3Ja.js} +1 -1
  63. package/dist/assets/{uk-D9WsfZqn.js → uk-VUOVH9qH.js} +1 -1
  64. package/dist/assets/{useAppFontEffects-DGB_WT2K.js → useAppFontEffects-C9CPKD-1.js} +6 -6
  65. package/dist/assets/{useDesktopWindowControlsLayout-vZizIuQt.js → useDesktopWindowControlsLayout-Cw3ZRPXc.js} +1 -1
  66. package/dist/assets/{useEffectiveDirectory-Cy8aGhAH.js → useEffectiveDirectory-Cw-vfohq.js} +1 -1
  67. package/dist/assets/{useMobileNavigationStore-D-RlKHiM.js → useMobileNavigationStore-K23K6qFK.js} +6 -6
  68. package/dist/assets/{useWorkerHighlightedLines-DH3kJulm.js → useWorkerHighlightedLines-U3DE5CRZ.js} +1 -1
  69. package/dist/assets/{zh-CN-CAIBZPD7.js → zh-CN-CqOn122C.js} +1 -1
  70. package/dist/assets/{zh-TW-IpFLeeKe.js → zh-TW-53yr6Fdj.js} +1 -1
  71. package/dist/index.html +6 -6
  72. package/dist/mini-chat.html +6 -6
  73. package/dist/mobile.html +6 -6
  74. package/package.json +1 -1
  75. package/server/lib/config-sync/DOCUMENTATION.md +6 -2
  76. package/server/lib/config-sync/magpie.js +31 -6
  77. package/server/lib/config-sync/magpie.test.js +94 -1
  78. package/dist/assets/speechSettingsQueries-JZkjbbR5.js +0 -4
  79. package/dist/assets/src-Cyw451UY.css +0 -2
package/dist/index.html CHANGED
@@ -560,7 +560,7 @@
560
560
  opacity: 0.72;
561
561
  }
562
562
  </style>
563
- <script type="module" crossorigin src="/assets/main-BtKG4Oot.js"></script>
563
+ <script type="module" crossorigin src="/assets/main-Bh0kUjiw.js"></script>
564
564
  <link rel="modulepreload" crossorigin href="/assets/rolldown-runtime-hePW80VL.js">
565
565
  <link rel="modulepreload" crossorigin href="/assets/runtime-auth-ef9W7A43.js">
566
566
  <link rel="modulepreload" crossorigin href="/assets/runtime-switch-CAZiOV2G.js">
@@ -583,11 +583,11 @@
583
583
  <link rel="modulepreload" crossorigin href="/assets/platform-7bX6qtBV.js">
584
584
  <link rel="modulepreload" crossorigin href="/assets/terminalApi-BHXvha-U.js">
585
585
  <link rel="modulepreload" crossorigin href="/assets/runtime-file-download-DAOam_oV.js">
586
- <link rel="modulepreload" crossorigin href="/assets/types-DeOBiX60.js">
587
- <link rel="modulepreload" crossorigin href="/assets/capgoAdapter-D9f3CiJN.js">
588
- <link rel="modulepreload" crossorigin href="/assets/native-config-DPmta_0r.js">
589
- <link rel="modulepreload" crossorigin href="/assets/runtimeConfig-HmoxZCZV.js">
590
- <link rel="stylesheet" crossorigin href="/assets/src-Cyw451UY.css">
586
+ <link rel="modulepreload" crossorigin href="/assets/types-2CUEL3Ja.js">
587
+ <link rel="modulepreload" crossorigin href="/assets/capgoAdapter-BmTEnR2_.js">
588
+ <link rel="modulepreload" crossorigin href="/assets/native-config-BDst1Okm.js">
589
+ <link rel="modulepreload" crossorigin href="/assets/runtimeConfig-D0UDGecm.js">
590
+ <link rel="stylesheet" crossorigin href="/assets/src-DlJVKekb.css">
591
591
  </head>
592
592
  <body class="h-full bg-background text-foreground">
593
593
  <!-- Keep the startup layer outside #root. React replaces every child of
@@ -74,7 +74,7 @@
74
74
  }
75
75
  </style>
76
76
 
77
- <script type="module" crossorigin src="/assets/miniChat-CW0R2U5t.js"></script>
77
+ <script type="module" crossorigin src="/assets/miniChat-Ciy0u8ci.js"></script>
78
78
  <link rel="modulepreload" crossorigin href="/assets/rolldown-runtime-hePW80VL.js">
79
79
  <link rel="modulepreload" crossorigin href="/assets/runtime-auth-ef9W7A43.js">
80
80
  <link rel="modulepreload" crossorigin href="/assets/runtime-switch-CAZiOV2G.js">
@@ -97,11 +97,11 @@
97
97
  <link rel="modulepreload" crossorigin href="/assets/platform-7bX6qtBV.js">
98
98
  <link rel="modulepreload" crossorigin href="/assets/terminalApi-BHXvha-U.js">
99
99
  <link rel="modulepreload" crossorigin href="/assets/runtime-file-download-DAOam_oV.js">
100
- <link rel="modulepreload" crossorigin href="/assets/types-DeOBiX60.js">
101
- <link rel="modulepreload" crossorigin href="/assets/capgoAdapter-D9f3CiJN.js">
102
- <link rel="modulepreload" crossorigin href="/assets/native-config-DPmta_0r.js">
103
- <link rel="modulepreload" crossorigin href="/assets/runtimeConfig-HmoxZCZV.js">
104
- <link rel="stylesheet" crossorigin href="/assets/src-Cyw451UY.css">
100
+ <link rel="modulepreload" crossorigin href="/assets/types-2CUEL3Ja.js">
101
+ <link rel="modulepreload" crossorigin href="/assets/capgoAdapter-BmTEnR2_.js">
102
+ <link rel="modulepreload" crossorigin href="/assets/native-config-BDst1Okm.js">
103
+ <link rel="modulepreload" crossorigin href="/assets/runtimeConfig-D0UDGecm.js">
104
+ <link rel="stylesheet" crossorigin href="/assets/src-DlJVKekb.css">
105
105
  </head>
106
106
  <body class="h-full bg-background text-foreground">
107
107
  <div id="root" class="h-full">
package/dist/mobile.html CHANGED
@@ -63,7 +63,7 @@
63
63
  })();
64
64
  </script>
65
65
 
66
- <script type="module" crossorigin src="/assets/mobile-ClKyarOu.js"></script>
66
+ <script type="module" crossorigin src="/assets/mobile-Bm0sCDXq.js"></script>
67
67
  <link rel="modulepreload" crossorigin href="/assets/rolldown-runtime-hePW80VL.js">
68
68
  <link rel="modulepreload" crossorigin href="/assets/runtime-auth-ef9W7A43.js">
69
69
  <link rel="modulepreload" crossorigin href="/assets/runtime-switch-CAZiOV2G.js">
@@ -86,11 +86,11 @@
86
86
  <link rel="modulepreload" crossorigin href="/assets/platform-7bX6qtBV.js">
87
87
  <link rel="modulepreload" crossorigin href="/assets/terminalApi-BHXvha-U.js">
88
88
  <link rel="modulepreload" crossorigin href="/assets/runtime-file-download-DAOam_oV.js">
89
- <link rel="modulepreload" crossorigin href="/assets/types-DeOBiX60.js">
90
- <link rel="modulepreload" crossorigin href="/assets/capgoAdapter-D9f3CiJN.js">
91
- <link rel="modulepreload" crossorigin href="/assets/native-config-DPmta_0r.js">
92
- <link rel="modulepreload" crossorigin href="/assets/runtimeConfig-HmoxZCZV.js">
93
- <link rel="stylesheet" crossorigin href="/assets/src-Cyw451UY.css">
89
+ <link rel="modulepreload" crossorigin href="/assets/types-2CUEL3Ja.js">
90
+ <link rel="modulepreload" crossorigin href="/assets/capgoAdapter-BmTEnR2_.js">
91
+ <link rel="modulepreload" crossorigin href="/assets/native-config-BDst1Okm.js">
92
+ <link rel="modulepreload" crossorigin href="/assets/runtimeConfig-D0UDGecm.js">
93
+ <link rel="stylesheet" crossorigin href="/assets/src-DlJVKekb.css">
94
94
  </head>
95
95
  <body class="h-full bg-background text-foreground">
96
96
  <div id="root" class="h-full"></div>
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@yuriai/web",
3
- "version": "0.1.20",
3
+ "version": "0.1.22",
4
4
  "private": false,
5
5
  "type": "module",
6
6
  "main": "./server/index.js",
@@ -41,6 +41,8 @@ Own the direction-agnostic OpenCode config sync contract: allowlist planning on
41
41
 
42
42
  Switching direction in the wizard **must** discard the previous preview and re-call preview IPC (no client-side flip of an old plan).
43
43
 
44
+ Within one direction, scope changes retain the displayed preview and discovered options while refreshing. Preview requests are serialized, superseded queued selections are skipped, and stale completions cannot replace the latest review. Apply stays disabled until the latest selection snapshot is confirmed. Closing or changing the target invalidates pending results. The dialog expands naturally with its content, without a fixed height or nested scrolling body/list; only the shared dialog's viewport overflow protection remains. Static help and the footer do not depend on preview loading.
45
+
44
46
  ## Invariants
45
47
 
46
48
  - Plan is computed on the source filesystem/inventory snapshot; destination executors never re-walk the source.
@@ -89,12 +91,14 @@ Discovery checks `MAGPIE_BINARY`, PATH, the user's `.local/bin`, macOS applicati
89
91
 
90
92
  Selecting Magpie uses its native `backup` / `restore` with configuration, API keys, profiles, agent models, library and portable plugin declarations. Native provider/group restore merges by ID and does not propagate deletions; settings and library follow Magpie's own restore semantics, retaining machine-local settings. This is a full native bundle, not a provider-only restore.
91
93
 
92
- The v2 envelope additionally carries recognized plugin API/OAuth accounts and self-contained saved Codex credentials. The source CLI account inventory limits export to recognized providers; hidden and orphaned plugin sign-ins are excluded. Plugin accounts merge by their native account key into `plugin-auth.json` under Magpie's exclusive-create lock, using a private atomic replacement. Destination-only accounts remain; repeated transfers do not append duplicates. Codex uses native `accounts import codex --yes`, which owns account identity/deduplication and the OS-level `logins.json` lock. Yuri never writes `logins.json` or copies machine-local account homes. Other subscription formats and accounts discovered only from external clients are not inferred or silently treated as transferred: unsupported active source accounts produce `sign_in_required`. An import re-reads `accounts --json` and requires all transferred plugin account counts and Codex identities to be recognized before returning success. Plugin diagnostics on stderr are ignored when recovering the top-level JSON array from the merged CLI streams. This checks discovery, not successful model inference or future token renewal; revoked credentials still require login.
94
+ The v2 envelope additionally carries recognized plugin API/OAuth accounts and self-contained saved Codex credentials. The source CLI account inventory limits export to recognized providers; hidden and orphaned plugin sign-ins are excluded. Plugin accounts merge by their native account key into `plugin-auth.json` under Magpie's exclusive-create lock, using a private atomic replacement. Destination-only accounts remain; repeated transfers do not append duplicates. Codex uses native `accounts import codex --yes`, which owns account identity/deduplication and the OS-level `logins.json` lock. Yuri never writes `logins.json` or copies machine-local account homes. A spent or expired ChatGPT refresh token can make the native Codex import exit non-zero even when the destination already holds that account; import then continues and the post-transfer `accounts --json` inventory decides success. Other subscription formats and accounts discovered only from external clients are not inferred or silently treated as transferred: unsupported active source accounts produce `sign_in_required`. An import re-reads `accounts --json` and requires all transferred plugin account counts and Codex identities to be recognized before returning success. Plugin diagnostics on stderr are ignored when recovering the top-level JSON array from the merged CLI streams. This checks discovery, not successful model inference or future token renewal; revoked credentials still require login.
95
+
96
+ Codex rejection exception: only exit code 1 with the native `ChatGPT didn't take the refresh token` diagnostic is skippable. That account is excluded from required identity verification, subsequent accounts continue, and the receipt always includes `sign_in_required`, even if the destination already recognizes the account. All other import failures (including network errors, timeouts and filesystem errors) still abort. Raw CLI output is never included in the classified error. This exception supersedes the inventory-only success rule above; all non-rejected accounts still require verification.
93
97
 
94
98
  Missing destination executables are installed only when Magpie is explicitly selected for import, never in preview or ordinary OpenCode sync. The host selects the official pure CLI asset for macOS/Linux/Windows x64/arm64 from `https://usemagpie.ai/api/latest`, verifies SHA-256, checks `--version`, then atomically publishes it under `<YURI_DATA_DIR>/tools/magpie/` (default `~/.config/yuri`). Existing desktop clients and CLIs are reused. Installation is process-local single-flight, needs no global PATH change or desktop environment, and fails explicitly for unsupported platforms or unverifiable downloads.
95
99
 
96
100
  Selected sync also publishes `~/.local/bin/magpie` (`magpie.exe` on Windows), a path searched explicitly by `opencode-magpie-plugin`. POSIX uses a symlink, Windows a hard link for installed-mode data and a symlink for portable data; unsupported linking fails explicitly. Existing valid user commands using the same data directory are retained; conflicting/broken entries are not overwritten. Shared-service and private OpenCode startup repair the command entry for an already managed CLI before launching OpenCode; they never download Magpie just because Yuri starts. SSH/direct/Relay push and pull apply Magpie before OpenCode config archives, preventing a newly synced plugin from loading before its dependency is installed. Native agent settings skipped before sign-in are retried after authorization succeeds.
97
101
 
98
- The `magpie` transfer kind exports a bounded `magpie-sync-v2` JSON envelope containing the encrypted native backup, a random per-transfer passphrase and portable authorizations. The envelope is sensitive and stays in memory on authenticated sync transports; Relay adds its existing E2EE. New receivers accept old `magpie-sync-v1` config-only envelopes with the original warning behavior; old receivers reject v2 rather than silently discarding its accounts. Upgrade both hosts for authorization sync. Validate the entire envelope before installation or restore. Passphrases go to child stdin, never argv, run logs or disk. Private temporary directories hold native encrypted backups and, during native Codex import only, a mode-0600 credential file; both are removed on success/failure. Raw child output is sanitized before reporting. A zero exit with genuinely missing/unsupported sign-ins or unavailable agent settings returns `magpieWarnings` (`sign_in_required`, `agent_settings_skipped`). The sign-in warning is recomputed after authorization transfer, not copied from the pre-transfer native restore. Receipts carry these codes through SSH/direct/Relay and desktop IPC to localized completion warnings. Provider/API-key, plugin-install, library, account import and verification failures remain errors. CLI failure can leave configuration and earlier accounts applied; retry merges idempotently. There is no cross-application rollback, and process termination can interrupt cleanup.
102
+ The `magpie` transfer kind exports a bounded `magpie-sync-v2` JSON envelope containing the encrypted native backup, a random per-transfer passphrase and portable authorizations. The envelope is sensitive and stays in memory on authenticated sync transports; Relay adds its existing E2EE. New receivers accept old `magpie-sync-v1` config-only envelopes with the original warning behavior; old receivers reject v2 rather than silently discarding its accounts. Upgrade both hosts for authorization sync. Validate the entire envelope before installation or restore. Passphrases go to child stdin, never argv, run logs or disk. Private temporary directories hold native encrypted backups and, during native Codex import only, a mode-0600 credential file; both are removed on success/failure. Raw child output is sanitized before reporting. A zero exit with genuinely missing/unsupported sign-ins, unavailable agent settings, or plugins that Magpie could not install returns `magpieWarnings` (`sign_in_required`, `agent_settings_skipped`, `plugin_install_failed`). Plugin-install failures no longer abort the transfer: remaining configuration and accounts continue, verification skips accounts for plugins that never appeared on the destination, and the receipt warns. The sign-in warning is recomputed after authorization transfer, not copied from the pre-transfer native restore. Receipts carry these codes through SSH/direct/Relay and desktop IPC to localized completion warnings. Provider/API-key, library and other account-import failures remain errors. CLI failure can leave configuration and earlier accounts applied; retry merges idempotently. There is no cross-application rollback, and process termination can interrupt cleanup.
99
103
 
100
104
  `/put/magpie` requires a selected prepared plan and finalize requires its receipt. Standalone `/magpie` is the corresponding authenticated host operation for SSH and local pull. Both use one host-local import/export lock. Desktop main only moves bytes and resolves the local host at call time; the web host owns process execution and installation, including under backend OTA. Web/mobile hosts can receive this operation; the initiating wizard remains desktop-only. No credential values enter previews or sync-run summaries.
@@ -56,7 +56,14 @@ const runCli = (binary, args, { input = '', env, timeout = 600_000 } = {}) => ne
56
56
  child.on('error', () => { clearTimeout(timer); reject(new Error('Unable to start Magpie CLI')); });
57
57
  child.on('close', (code) => {
58
58
  clearTimeout(timer);
59
- if (code !== 0 || exceeded) reject(new Error('Magpie CLI operation failed or timed out'));
59
+ if (code !== 0 || exceeded) {
60
+ const error = new Error('Magpie CLI operation failed or timed out');
61
+ if (!exceeded && code === 1 && args[0] === 'accounts' && args[1] === 'import' && args[2] === 'codex'
62
+ && /ChatGPT didn't take the refresh token/i.test(output)) {
63
+ error.code = 'magpie_codex_authorization_rejected';
64
+ }
65
+ reject(error);
66
+ }
60
67
  else resolve(output.replace(/\x1b\[[0-9;]*m/g, ''));
61
68
  });
62
69
  child.stdin.end(input);
@@ -254,34 +261,51 @@ export function createMagpieSync({
254
261
  let output;
255
262
  try { output = await run(binary, ['restore', file], { env, input: `${decoded.passphrase}\n` }); }
256
263
  catch { throw new Error('Magpie restore failed; some configuration may already have been applied. Retry to finish.'); }
257
- if (/Couldn't add the plugin/i.test(output)) throw new Error('Magpie restore partially completed: plugin installation failed. Check the target Magpie plugins.');
264
+ // Private/unreachable plugin specs can fail while the rest of restore still applies.
265
+ let pluginInstallFailed = /Couldn't add the plugin/i.test(output);
258
266
  if (/Library:.*couldn't/i.test(output)) throw new Error('Magpie restore partially completed: library application failed. Check the target Magpie library.');
259
267
  if (/Needs a key/i.test(output)) throw new Error('Magpie restore partially completed: some providers still require API keys.');
260
268
  let needsSignIn = /not signed in on this computer/i.test(output);
261
269
  if (decoded.format === 'magpie-sync-v2') {
262
270
  const dir = await dataDir(binary);
271
+ const rejected = new Set();
263
272
  try {
264
273
  await restoreMagpieAuth(dir, decoded.authorization, async (auth) => {
265
274
  const credentialFile = path.join(path.dirname(file), 'codex.json');
266
275
  try {
267
276
  await fs.writeFile(credentialFile, JSON.stringify(auth), { mode: 0o600, flag: 'wx' });
268
- await run(binary, ['accounts', 'import', 'codex', credentialFile, '--yes'], { env });
277
+ try {
278
+ await run(binary, ['accounts', 'import', 'codex', credentialFile, '--yes'], { env });
279
+ } catch (error) {
280
+ if (error.code !== 'magpie_codex_authorization_rejected') throw error;
281
+ rejected.add(auth);
282
+ }
269
283
  } finally { await fs.rm(credentialFile, { force: true }); }
270
284
  });
271
285
  const accounts = parseMagpieAccountsJson(await run(binary, ['accounts', '--json'], { env }));
272
- verifyMagpieAuth(decoded.authorization, accounts);
286
+ const known = new Set(accounts.map((account) => account.agent));
287
+ // Skip verification for plugins that never installed and for spent Codex tokens.
288
+ const expected = {
289
+ ...decoded.authorization,
290
+ plugins: Object.fromEntries(Object.entries(decoded.authorization.plugins)
291
+ .filter(([key]) => !pluginInstallFailed || known.has(key.split('#')[0]))),
292
+ logins: decoded.authorization.logins.filter((row) => !rejected.has(row.auth)
293
+ && (!pluginInstallFailed || known.has(row.agent.replace(/^plugin:/, '')))),
294
+ };
295
+ verifyMagpieAuth(expected, accounts);
273
296
  const configured = JSON.parse(await fs.readFile(path.join(dir, 'providers.json'), 'utf8').catch((error) => {
274
297
  if (error.code === 'ENOENT') return '{"providers":[]}';
275
298
  throw error;
276
299
  }));
277
300
  if (!Array.isArray(configured.providers)) throw new Error();
278
301
  const signedIn = new Set(accounts.map((account) => account.agent));
279
- needsSignIn = decoded.authorization.incomplete || configured.providers.some((provider) =>
302
+ needsSignIn = rejected.size > 0 || decoded.authorization.incomplete || configured.providers.some((provider) =>
280
303
  !provider.hidden && provider.id && !['chat', 'responses', 'anthropic', 'gemini'].some((key) => provider[key])
281
304
  && !signedIn.has(provider.id));
282
305
  if (/Left as they are/i.test(output)) {
283
306
  output = await run(binary, ['restore', file], { env, input: `${decoded.passphrase}\n` });
284
- if (/Couldn't add the plugin|Needs a key|Library:.*couldn't/i.test(output)) throw new Error();
307
+ if (/Couldn't add the plugin/i.test(output)) pluginInstallFailed = true;
308
+ if (/Needs a key|Library:.*couldn't/i.test(output)) throw new Error();
285
309
  }
286
310
  } catch (error) {
287
311
  throw new Error('Magpie authorization sync or verification failed; some configuration and accounts may already be applied. Retry to finish.', { cause: error });
@@ -289,6 +313,7 @@ export function createMagpieSync({
289
313
  }
290
314
  const magpieWarnings = [];
291
315
  if (needsSignIn) magpieWarnings.push('sign_in_required');
316
+ if (pluginInstallFailed) magpieWarnings.push('plugin_install_failed');
292
317
  if (/Left as they are/i.test(output)) magpieWarnings.push('agent_settings_skipped');
293
318
  return { ok: true, ...(magpieWarnings.length ? { magpieWarnings } : {}) };
294
319
  });
@@ -159,6 +159,34 @@ describe('Magpie discovery and native transfer', () => {
159
159
  expect((await fs.readdir(target.home)).filter((name) => name.startsWith('yuri-magpie-'))).toEqual([]);
160
160
  });
161
161
 
162
+ it('treats a spent Codex refresh token as recoverable when the destination already recognizes the account', async () => {
163
+ const source = await machine();
164
+ const target = await machine();
165
+ for (const item of [source, target]) await write(path.join(item.home, '.local/bin/magpie'), 'fixture');
166
+ const sourceDir = path.join(source.home, '.config/magpie');
167
+ const targetDir = path.join(target.home, '.config/magpie');
168
+ await write(path.join(sourceDir, 'providers.json'), '{"providers":[{"id":"codex"}]}');
169
+ await write(path.join(sourceDir, 'logins.json'), JSON.stringify([
170
+ { agent: 'codex', user: 'fixture@example.invalid', auth: { tokens: { refresh_token: 'spent-token' } } },
171
+ ]));
172
+ const payload = await createMagpieSync({ ...source.options, run: async (_binary, args) => {
173
+ if (args[0] === '--version') return 'magpie 0.1.1319';
174
+ if (args[0] === 'accounts') return '[{"agent":"codex","user":"fixture@example.invalid"}]';
175
+ await write(args[1], '{"format":"magpie-backup"}');
176
+ return '';
177
+ } }).download();
178
+ const run = vi.fn(async (_binary, args) => {
179
+ if (args[0] === '--version') return 'magpie 0.1.1319';
180
+ if (args[0] === 'restore') {
181
+ await write(path.join(targetDir, 'providers.json'), await fs.readFile(path.join(sourceDir, 'providers.json')));
182
+ return 'restored';
183
+ }
184
+ if (args[1] === 'import') throw Object.assign(new Error('Magpie CLI operation failed or timed out'), { code: 'magpie_codex_authorization_rejected' });
185
+ return '[{"agent":"codex","user":"fixture@example.invalid"}]';
186
+ });
187
+ await expect(createMagpieSync({ ...target.options, run }).import(payload)).resolves.toEqual({ ok: true, magpieWarnings: ['sign_in_required'] });
188
+ });
189
+
162
190
  it('rejects malformed v2 authorization before installing or restoring', async () => {
163
191
  const { options } = await machine();
164
192
  const run = vi.fn();
@@ -171,6 +199,36 @@ describe('Magpie discovery and native transfer', () => {
171
199
  expect(fetchImpl).not.toHaveBeenCalled();
172
200
  });
173
201
 
202
+ it.each([true, false])('continues only for a confirmed Codex rejection (rejected=%s)', async (rejected) => {
203
+ const { home, options } = await machine();
204
+ const binary = path.join(home, '.local/bin/magpie');
205
+ await write(binary, `#!${process.execPath}
206
+ const fs = require('node:fs');
207
+ const args = process.argv.slice(2);
208
+ if (args[0] === '--version') console.log('magpie 0.1.1820');
209
+ else if (args[1] === 'import') {
210
+ const auth = JSON.parse(fs.readFileSync(args[3], 'utf8'));
211
+ if (auth.tokens.refresh_token === 'fixture-rejected') {
212
+ console.error(${JSON.stringify(rejected ? "ChatGPT didn't take the refresh token — expired or signed out" : 'Network connection failed')});
213
+ process.exitCode = 1;
214
+ }
215
+ } else if (args[0] === 'accounts') console.log(JSON.stringify([{ agent: 'codex', user: 'second@example.invalid' }, { agent: 'astra' }]));
216
+ else console.log('restored');
217
+ `);
218
+ await fs.chmod(binary, 0o700);
219
+ const payload = Buffer.from(JSON.stringify({ format: 'magpie-sync-v2', passphrase: 'a'.repeat(64),
220
+ backup: Buffer.from('{"format":"magpie-backup"}').toString('base64'),
221
+ authorization: { plugins: { astra: { type: 'api', key: 'fixture' } }, incomplete: false, logins: [
222
+ { agent: 'codex', user: 'first@example.invalid', auth: { tokens: { refresh_token: 'fixture-rejected' } } },
223
+ { agent: 'codex', user: 'second@example.invalid', auth: { tokens: { refresh_token: 'fixture-valid' } } },
224
+ ] } }));
225
+ const result = createMagpieSync(options).import(payload);
226
+ if (rejected) await expect(result).resolves.toEqual({ ok: true, magpieWarnings: ['sign_in_required'] });
227
+ else await expect(result).rejects.toThrow('authorization sync or verification failed');
228
+ expect(JSON.parse(await fs.readFile(path.join(home, '.config/magpie/plugin-auth.json'), 'utf8')).astra).toEqual({ type: 'api', key: 'fixture' });
229
+ expect((await fs.readdir(home)).filter((name) => name.startsWith('yuri-magpie-'))).toEqual([]);
230
+ });
231
+
174
232
  it('retries agent settings after authorizations instead of keeping a pre-login skip warning', async () => {
175
233
  const { home, options } = await machine();
176
234
  await write(path.join(home, '.local/bin/magpie'), 'fixture');
@@ -191,7 +249,7 @@ describe('Magpie discovery and native transfer', () => {
191
249
  const { home, options } = await machine();
192
250
  const fetchImpl = vi.fn();
193
251
  const run = vi.fn(async (_binary, args) => args[0] === '--version'
194
- ? 'magpie 0.1.0' : "Couldn't add the plugin private-fixture-value");
252
+ ? 'magpie 0.1.0' : 'Library: fixture-library couldn\'t apply');
195
253
  const sync = createMagpieSync({ ...options, fetchImpl, run });
196
254
  await expect(sync.import(Buffer.from('{}'))).rejects.toThrow('Invalid Magpie sync payload');
197
255
  expect(fetchImpl).not.toHaveBeenCalled();
@@ -202,6 +260,41 @@ describe('Magpie discovery and native transfer', () => {
202
260
  expect((await fs.readdir(home)).filter((name) => name.startsWith('yuri-magpie-'))).toEqual([]);
203
261
  });
204
262
 
263
+ it('continues when a plugin fails to install and warns instead of aborting', async () => {
264
+ const source = await machine();
265
+ const target = await machine();
266
+ for (const item of [source, target]) await write(path.join(item.home, '.local/bin/magpie'), 'fixture');
267
+ const sourceDir = path.join(source.home, '.config/magpie');
268
+ const targetDir = path.join(target.home, '.config/magpie');
269
+ await write(path.join(sourceDir, 'providers.json'), '{"providers":[{"id":"cursor"},{"id":"private-plugin"}]}');
270
+ await write(path.join(sourceDir, 'plugin-auth.json'), JSON.stringify({
271
+ cursor: { type: 'api', key: 'fixture-key' },
272
+ 'private-plugin': { type: 'api', key: 'fixture-private' },
273
+ }));
274
+ await write(path.join(sourceDir, 'logins.json'), JSON.stringify([
275
+ { agent: 'plugin:cursor', user: 'fixture@example.invalid', home: 'cursor', auth: { type: 'api' } },
276
+ { agent: 'plugin:private-plugin', user: 'secret', home: 'private-plugin', auth: { type: 'api' } },
277
+ ]));
278
+ const payload = await createMagpieSync({ ...source.options, run: async (_binary, args) => {
279
+ if (args[0] === '--version') return 'magpie 0.1.1319';
280
+ if (args[0] === 'accounts') return '[{"agent":"cursor","user":"fixture@example.invalid"},{"agent":"private-plugin","user":"secret"}]';
281
+ await write(args[1], '{"format":"magpie-backup"}');
282
+ return '';
283
+ } }).download();
284
+ const run = vi.fn(async (_binary, args) => {
285
+ if (args[0] === '--version') return 'magpie 0.1.1319';
286
+ if (args[0] === 'restore') {
287
+ await write(path.join(targetDir, 'providers.json'), await fs.readFile(path.join(sourceDir, 'providers.json')));
288
+ return "Couldn't add the plugin private-plugin@latest";
289
+ }
290
+ if (args[0] === 'accounts') return '[{"agent":"cursor","user":"fixture@example.invalid"}]';
291
+ return '';
292
+ });
293
+ await expect(createMagpieSync({ ...target.options, run }).import(payload)).resolves.toEqual({
294
+ ok: true, magpieWarnings: ['sign_in_required', 'plugin_install_failed'],
295
+ });
296
+ });
297
+
205
298
  it('reports excluded sign-ins as a warning after a successful native restore', async () => {
206
299
  const { home, options } = await machine();
207
300
  await write(path.join(home, '.local', 'bin', 'magpie'), 'fixture-cli');