@yuriai/web 0.2.32-beta.5 → 0.2.32-beta.7

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 (173) hide show
  1. package/README.md +19 -0
  2. package/dist/assets/{AgentAvatar-DG1RbFtI.js → AgentAvatar-BPGtFSJl.js} +1 -1
  3. package/dist/assets/{AssistantContactStatus-CzPxX6kn.js → AssistantContactStatus-BkJX1aHJ.js} +3 -3
  4. package/dist/assets/{AssistantUnreadBadge-BoimAuZB.js → AssistantUnreadBadge-BLrhZtX4.js} +1 -1
  5. package/dist/assets/{AssistantView-DRa5_WqV.js → AssistantView-CRNRm9ix.js} +1 -1
  6. package/dist/assets/{DiagramView-DBNv9eLT.js → DiagramView-IJdm6V-I.js} +1 -1
  7. package/dist/assets/{FadeInOnReveal-Bmxvkrf4.js → FadeInOnReveal-DoQ1DHcy.js} +1 -1
  8. package/dist/assets/{GuiPluginSurface-o7Ay34vJ.js → GuiPluginSurface-UzIcyfzu.js} +1 -1
  9. package/dist/assets/{GuiPluginWindow-CwP_vUoC.js → GuiPluginWindow-CWjwMY19.js} +1 -1
  10. package/dist/assets/Icon-wD7peplo.js +1 -0
  11. package/dist/assets/{ImageLoadingPlaceholder-DlosWH_9.js → ImageLoadingPlaceholder-cfSg1uO0.js} +1 -1
  12. package/dist/assets/{LoadingImage-D9r0ukc0.js → LoadingImage-DTlBKb0t.js} +1 -1
  13. package/dist/assets/{MarkdownRenderer-Bq8Gj6CE.js → MarkdownRenderer-42mR-hfP.js} +2 -2
  14. package/dist/assets/{MarkdownRendererImpl-CVRLtLB1.js → MarkdownRendererImpl-BrgFhad9.js} +1 -1
  15. package/dist/assets/{MarkstreamRendererImpl-BOmhW47N.js → MarkstreamRendererImpl-BwwP423b.js} +1 -1
  16. package/dist/assets/{MobileDetailNavigation-HZ6caX7w.js → MobileDetailNavigation-BzA3RUQf.js} +1 -1
  17. package/dist/assets/{MobileResizableSheet-vAenroLZ.js → MobileResizableSheet-3pSxhm6y.js} +1 -1
  18. package/dist/assets/{MobileShareBridge-DTCxgcOl.js → MobileShareBridge-8D1mAnQX.js} +1 -1
  19. package/dist/assets/MobileTabPageHeader-2brOJZ7v.js +2 -0
  20. package/dist/assets/{MultiRunWindow-DgpwdrOT.js → MultiRunWindow-yr2T2JVO.js} +1 -1
  21. package/dist/assets/{OnboardingScreen-DNlK3zfZ.js → OnboardingScreen-DOcfewzl.js} +1 -1
  22. package/dist/assets/{OverlayScrollbar-W17unuIx.js → OverlayScrollbar-C1VJiQk-.js} +1 -1
  23. package/dist/assets/{SettingsView-BCCVFcMo.js → SettingsView-D57_z9Xp.js} +12 -12
  24. package/dist/assets/{SettingsWindow-J6K3qs_9.js → SettingsWindow-eITkM9xO.js} +1 -1
  25. package/dist/assets/SetupTourDialog-Da8-sYBw.js +1 -0
  26. package/dist/assets/SetupTourDialog-DrL_4ODI.css +1 -0
  27. package/dist/assets/{TerminalView-DvRoa8my.js → TerminalView-DWlRf5cO.js} +1 -1
  28. package/dist/assets/{ToolOutputDialog-cf_VcwJk.js → ToolOutputDialog-BkNK7SlB.js} +1 -1
  29. package/dist/assets/{VoiceSettings-Sm4gB-j5.js → VoiceSettings-BvfsAx5q.js} +2 -2
  30. package/dist/assets/{YuriLogo-XH6UGXtF.js → YuriLogo-kLl6rb2d.js} +1 -1
  31. package/dist/assets/YuriWordmark-DHYo0FlR.js +1 -0
  32. package/dist/assets/{appThemeRegistry-zoeqTiCb.js → appThemeRegistry-C5KVFrEF.js} +1 -1
  33. package/dist/assets/{button-CyJvQsp5.js → button-DSfiaJr4.js} +1 -1
  34. package/dist/assets/{capgoAdapter-Doqr12Eo.js → capgoAdapter-DjN9N4r_.js} +1 -1
  35. package/dist/assets/checkbox-cWs92MsM.js +1 -0
  36. package/dist/assets/{collapsible-CXjDO6DW.js → collapsible-AUQp4jpe.js} +1 -1
  37. package/dist/assets/{context-menu-BajfnPcW.js → context-menu-DwQvyFO2.js} +1 -1
  38. package/dist/assets/desktopHosts-BLU1tGSX.js +1 -0
  39. package/dist/assets/{desktopRelayRestore-DS44uXtb.js → desktopRelayRestore-2BIIs8mZ.js} +1 -1
  40. package/dist/assets/{diagram-_Js3imTf.js → diagram-BTa5MQro.js} +1 -1
  41. package/dist/assets/{dialog-Bapd6e10.js → dialog-gWs6IrfL.js} +1 -1
  42. package/dist/assets/{es-CBhZ80Z7.js → es-mX3KOqnq.js} +1 -1
  43. package/dist/assets/{fileMentionTouchSelection-BqGxOZhB.js → fileMentionTouchSelection-plcnc8He.js} +1 -1
  44. package/dist/assets/{fr-D9s0sHDF.js → fr-DpWAkfly.js} +1 -1
  45. package/dist/assets/{gitApi-BZT4-6oC.js → gitApi-kn04hIXc.js} +1 -1
  46. package/dist/assets/historyImportQueries-C8VK9R5_.js +1 -0
  47. package/dist/assets/host-z9PU8q1e.js +1 -0
  48. package/dist/assets/{input-SCAHBeSU.js → input-D2qPeIPD.js} +1 -1
  49. package/dist/assets/insertionBoundaries-BdWZv7B4.js +1 -0
  50. package/dist/assets/{ja-BXQ3ox8H.js → ja-BBtK3t8l.js} +1 -1
  51. package/dist/assets/{ko-DlUti1wK.js → ko-Cwp3wC4W.js} +1 -1
  52. package/dist/assets/main-ATy6IXYq.js +169 -0
  53. package/dist/assets/main-Dand3vGy.js +2 -0
  54. package/dist/assets/{markdownHeightCache-B3MTnGA8.js → markdownHeightCache-Cinxvo8I.js} +1 -1
  55. package/dist/assets/{mcpQueries-BV_4aVO7.js → mcpQueries-BSIq-bmc.js} +1 -1
  56. package/dist/assets/miniChat-CbZmjfi9.js +2 -0
  57. package/dist/assets/mobile-C-QjhwpF.js +2 -0
  58. package/dist/assets/{mobileBackNavigation-dXm_DT4M.js → mobileBackNavigation-D6Ezv4DB.js} +1 -1
  59. package/dist/assets/multirun-DPdy1ssR.js +3 -0
  60. package/dist/assets/{native-config-DPhDkRHe.js → native-config-B7y8szbY.js} +1 -1
  61. package/dist/assets/{pl-B7LIbV2C.js → pl-Ccedjy5w.js} +1 -1
  62. package/dist/assets/{projectMeta-DOi5DwXK.js → projectMeta-BsemqAiZ.js} +1 -1
  63. package/dist/assets/{pt-BR-DyusczdZ.js → pt-BR-M2O45bRx.js} +1 -1
  64. package/dist/assets/{pwa-CEIk_CAR.js → pwa-PejIrv63.js} +1 -1
  65. package/dist/assets/{queue-abort-optimistic-m5rVgHjT.js → queue-abort-optimistic-DCcbcwcW.js} +1 -1
  66. package/dist/assets/react-a6PrrNTm.js +1 -0
  67. package/dist/assets/{readiness-DcxDHTFv.js → readiness-C3MT55zn.js} +1 -1
  68. package/dist/assets/{renderElectronMiniChatApp-DMHtUbjY.js → renderElectronMiniChatApp-B2nWy82v.js} +2 -2
  69. package/dist/assets/{renderMobileApp-C4tIs0O8.js → renderMobileApp-DsA7NB8t.js} +7 -7
  70. package/dist/assets/{runtimeConfig-zOTrRG4k.js → runtimeConfig-DcZhB_ik.js} +1 -1
  71. package/dist/assets/runtimeEndpointReset-DNh8Buqk.js +149 -0
  72. package/dist/assets/{select-CeddPgN5.js → select-BOlDxL_9.js} +1 -1
  73. package/dist/assets/sessionLookup-Csi0w1FF.js +1 -0
  74. package/dist/assets/{sortable-tabs-strip-D474PwS8.js → sortable-tabs-strip-CtkfOIVC.js} +1 -1
  75. package/dist/assets/{speechSettingsQueries-BnEpSqr1.js → speechSettingsQueries-Q5HncdmE.js} +1 -1
  76. package/dist/assets/src-C5Lsul_L.css +2 -0
  77. package/dist/assets/{store-Diaywtmi.js → store-BMijqCTE.js} +3 -3
  78. package/dist/assets/{textarea-CWQIq-Mn.js → textarea-Cspgldlr.js} +1 -1
  79. package/dist/assets/{tooltip-D3WmiZ7G.js → tooltip-DBb-UCMU.js} +1 -1
  80. package/dist/assets/tour-DzjTres6.js +1 -0
  81. package/dist/assets/{types-C1kMTm4R.js → types-4dZMFk7b.js} +1 -1
  82. package/dist/assets/{uk-BrwM67Dh.js → uk-skNzlwtr.js} +1 -1
  83. package/dist/assets/{useAppFontEffects-C_bov7Lj.js → useAppFontEffects-BKeEcImc.js} +54 -54
  84. package/dist/assets/useDesktopWindowControlsLayout-BIk3m2yD.js +1 -0
  85. package/dist/assets/{useDictation-C-waWdAq.js → useDictation-CwZ6a6i7.js} +1 -1
  86. package/dist/assets/{useEffectiveDirectory-53AP8Okc.js → useEffectiveDirectory-DPfMFs3U.js} +1 -1
  87. package/dist/assets/{useMobileNavigationStore-B2WlZQtk.js → useMobileNavigationStore-Cf5Q0tIq.js} +13 -13
  88. package/dist/assets/{usePluginsStore-BB0d0oJj.js → usePluginsStore-HsFoS5tV.js} +1 -1
  89. package/dist/assets/{useWorkerHighlightedLines-BfnQF-od.js → useWorkerHighlightedLines-DKLFgD2u.js} +1 -1
  90. package/dist/assets/{zh-CN-D9NAFloZ.js → zh-CN-KsbHpHjS.js} +1 -1
  91. package/dist/assets/{zh-TW-tuUKOuhs.js → zh-TW-SdNEiQ7a.js} +1 -1
  92. package/dist/index.html +8 -8
  93. package/dist/mini-chat.html +8 -8
  94. package/dist/mobile.html +8 -8
  95. package/package.json +1 -1
  96. package/server/index.js +2 -0
  97. package/server/lib/client-auth/pairing.js +2 -0
  98. package/server/lib/client-auth/pairing.test.js +29 -0
  99. package/server/lib/content-search/DOCUMENTATION.md +9 -0
  100. package/server/lib/content-search/routes.js +18 -1
  101. package/server/lib/content-search/routes.test.js +21 -0
  102. package/server/lib/content-search/runtime.js +7 -3
  103. package/server/lib/content-search/runtime.test.js +26 -0
  104. package/server/lib/gui-customization/DOCUMENTATION.md +21 -1
  105. package/server/lib/gui-customization/session-skill.js +2 -2
  106. package/server/lib/gui-customization/session-skill.test.js +3 -1
  107. package/server/lib/gui-customization/skill/SKILL.md +5 -1
  108. package/server/lib/gui-customization/skill/references/global-pages.md +1 -1
  109. package/server/lib/gui-customization/skill/references/gui-api.md +4 -1
  110. package/server/lib/gui-customization/skill/references/icons.md +134 -0
  111. package/server/lib/gui-customization/skill/references/plugin-styles.md +112 -0
  112. package/server/lib/gui-customization/skill/references/ui-surfaces.md +2 -0
  113. package/server/lib/gui-customization/skill/references/work-status.md +110 -0
  114. package/server/lib/history-import/AGENT_CONNECT_LICENSE +21 -0
  115. package/server/lib/history-import/DOCUMENTATION.md +223 -0
  116. package/server/lib/history-import/dev-proxy.integration.test.js +56 -0
  117. package/server/lib/history-import/events.js +322 -0
  118. package/server/lib/history-import/events.test.js +110 -0
  119. package/server/lib/history-import/installations.js +39 -0
  120. package/server/lib/history-import/installations.test.js +24 -0
  121. package/server/lib/history-import/native.js +49 -0
  122. package/server/lib/history-import/native.test.js +42 -0
  123. package/server/lib/history-import/routes.js +48 -0
  124. package/server/lib/history-import/routes.test.js +55 -0
  125. package/server/lib/history-import/service.js +374 -0
  126. package/server/lib/history-import/service.test.js +538 -0
  127. package/server/lib/history-import/settings.js +146 -0
  128. package/server/lib/history-import/settings.test.js +88 -0
  129. package/server/lib/history-import/sources.js +184 -0
  130. package/server/lib/history-import/sources.test.js +190 -0
  131. package/server/lib/history-import/sqlite.js +187 -0
  132. package/server/lib/history-import/store.js +58 -0
  133. package/server/lib/history-import/store.test.js +84 -0
  134. package/server/lib/history-import/targets.js +24 -0
  135. package/server/lib/host-update/DOCUMENTATION.md +6 -0
  136. package/server/lib/host-update/routes.test.js +1 -1
  137. package/server/lib/notifications/native-stream.relay.test.js +1 -0
  138. package/server/lib/opencode/DOCUMENTATION.md +3 -0
  139. package/server/lib/opencode/core-routes.js +1 -0
  140. package/server/lib/opencode/feature-routes-runtime.js +11 -1
  141. package/server/lib/opencode/yuri-routes.js +1 -1
  142. package/server/lib/relay/DOCUMENTATION.md +1 -1
  143. package/server/lib/relay/host-client.js +3 -1
  144. package/server/lib/relay/host-client.test.js +1 -0
  145. package/server/lib/relay/reasoning-projection.e2e.test.ts +1 -0
  146. package/server/lib/relay/relay-server.e2e.test.ts +32 -17
  147. package/server/lib/relay/service.js +2 -0
  148. package/server/lib/relay/tunnel-host.js +26 -1
  149. package/server/lib/relay/tunnel-host.test.js +27 -3
  150. package/server/lib/remote-desktop/runtime.test.js +2 -2
  151. package/server/lib/ui-auth/DOCUMENTATION.md +3 -0
  152. package/server/lib/ui-auth/ui-auth.js +27 -0
  153. package/server/lib/ui-auth/ui-auth.test.js +42 -1
  154. package/server/plugin-gui-proxy.test.js +1 -1
  155. package/dist/assets/Icon-BOYrvHyJ.js +0 -1
  156. package/dist/assets/MobileTabPageHeader-B8ywFvz3.js +0 -2
  157. package/dist/assets/SetupTourDialog-CUzqT2sw.css +0 -1
  158. package/dist/assets/SetupTourDialog-D1CePVNG.js +0 -1
  159. package/dist/assets/YuriWordmark-Cr1vkcue.js +0 -1
  160. package/dist/assets/desktopHosts-CMglnUdS.js +0 -1
  161. package/dist/assets/host-CBfSyi4l.js +0 -1
  162. package/dist/assets/insertionBoundaries-B2xOQ5Hz.js +0 -1
  163. package/dist/assets/main-CrVkVfn6.js +0 -169
  164. package/dist/assets/main-DjDRinlx.js +0 -2
  165. package/dist/assets/miniChat-D4MjHmAR.js +0 -2
  166. package/dist/assets/mobile-COK8gAf5.js +0 -2
  167. package/dist/assets/multirun-BZjeyzhb.js +0 -3
  168. package/dist/assets/react-Bwr5-XPi.js +0 -1
  169. package/dist/assets/runtimeEndpointReset-Cv_6vk4X.js +0 -149
  170. package/dist/assets/sessionLookup-SonNO2fE.js +0 -1
  171. package/dist/assets/src-BmVsUiOI.css +0 -2
  172. package/dist/assets/tour-DeA0Ksvj.js +0 -1
  173. package/dist/assets/useDesktopWindowControlsLayout-3tcqC97e.js +0 -1
@@ -0,0 +1,110 @@
1
+ import { describe, expect, test } from 'vitest';
2
+ import { Schema } from 'effect';
3
+ import { SessionMessage } from '@opencode/schema/session-message';
4
+ import { SessionTransfer } from '@opencode/schema/session-transfer';
5
+ import { combineSessions, parseTranscript, toNativeTransfer } from './events.js';
6
+
7
+ const at = '2026-01-01T00:00:00.000Z';
8
+ const claude = (id, parent, type, content, extra = {}) => ({ uuid: id, parentUuid: parent, type, timestamp: at, sessionId: 'chat', cwd: '/project', message: { content }, ...extra });
9
+
10
+ describe('source readers', () => {
11
+ test.each(['parent_thread_id', 'thread_spawn'])('Codex self-parent metadata is detached without losing the transcript (%s)', (field) => {
12
+ const parent = field === 'parent_thread_id' ? { parent_thread_id: 'same-thread' }
13
+ : { source: { subagent: { thread_spawn: { parent_thread_id: 'same-thread' } } } };
14
+ const result = parseTranscript('codex', [
15
+ { type: 'session_meta', payload: { id: 'same-thread', ...parent } },
16
+ { type: 'event_msg', payload: { type: 'user_message', message: 'Keep this conversation' } },
17
+ ], 'fallback');
18
+ expect(result.parentID).toBeUndefined();
19
+ expect(result.events.map((event) => event.text)).toEqual(['Keep this conversation']);
20
+ expect(result.warnings).toContain('parent_detached');
21
+ });
22
+ test('Claude follows the active branch and preserves genuine repeated messages', () => {
23
+ const entries = [claude('u1', null, 'user', 'continue'), claude('a1', 'u1', 'assistant', [{ type: 'text', text: 'old' }]),
24
+ claude('a2', 'u1', 'assistant', [{ type: 'text', text: 'new' }], { timestamp: '2026-01-01T00:00:01Z' }),
25
+ claude('u2', 'a2', 'user', 'continue', { timestamp: '2026-01-01T00:00:02Z' })];
26
+ const result = parseTranscript('claude', entries, 'fallback');
27
+ expect(result.events.map((event) => event.text)).toEqual(['continue', 'new', 'continue']);
28
+ expect(result.warnings).toContain('inactive_branches_omitted');
29
+ });
30
+ test('Claude keeps ordered text/tool/results and never fabricates tool completion', () => {
31
+ const entries = [claude('u', null, 'user', 'hello'), claude('a', 'u', 'assistant', [
32
+ { type: 'text', text: 'before' }, { type: 'tool_use', id: 'call', name: 'Read', input: { file_path: 'x' } }, { type: 'text', text: 'after' },
33
+ { type: 'tool_use', id: 'missing', name: 'Bash', input: { command: 'never run' } },
34
+ ]), claude('r', 'a', 'user', [{ type: 'tool_result', tool_use_id: 'call', content: 'full result' }], { timestamp: '2026-01-01T00:00:02Z' })];
35
+ const result = parseTranscript('claude', entries, 'fallback');
36
+ expect(result.events.map((event) => event.kind)).toEqual(['user', 'assistant-text', 'tool', 'assistant-text', 'tool']);
37
+ expect(result.events[2]).toMatchObject({ output: 'full result', incomplete: false });
38
+ expect(result.events[4]).toMatchObject({ incomplete: true });
39
+ });
40
+ test('parallel Claude tool fragments and snip relinks survive chain recovery', () => {
41
+ const entries = [claude('u', null, 'user', 'hello'),
42
+ claude('a1', 'u', 'assistant', [{ type: 'tool_use', id: 'one', name: 'Read' }], { message: { id: 'shared', content: [{ type: 'tool_use', id: 'one', name: 'Read' }] } }),
43
+ claude('a2', 'u', 'assistant', [], { message: { id: 'shared', content: [{ type: 'tool_use', id: 'two', name: 'Read' }] }, timestamp: '2026-01-01T00:00:01Z' }),
44
+ claude('r1', 'a1', 'user', [{ type: 'tool_result', tool_use_id: 'one', content: 'one' }]),
45
+ claude('r2', 'a2', 'user', [{ type: 'tool_result', tool_use_id: 'two', content: 'two' }], { timestamp: '2026-01-01T00:00:02Z' })];
46
+ expect(parseTranscript('claude', entries, 'fallback').events.filter((event) => event.kind === 'tool').map((event) => event.output).sort()).toEqual(['one', 'two']);
47
+ });
48
+ test.each([false, true])('Codex pairs both dual-track orders without removing repeated turns (%s)', (reverse) => {
49
+ const event = (text) => ({ type: 'event_msg', timestamp: at, payload: { type: 'user_message', message: text } });
50
+ const response = (text) => ({ type: 'response_item', timestamp: at, payload: { type: 'message', role: 'user', content: [{ type: 'input_text', text }] } });
51
+ const pair = (text) => reverse ? [event(text), response(text)] : [response(text), event(text)];
52
+ const assistant = { type: 'response_item', timestamp: at, payload: { type: 'message', role: 'assistant', content: [{ type: 'output_text', text: 'answer' }] } };
53
+ const entries = [{ type: 'session_meta', payload: { id: 'codex', cwd: '/project' } }, ...pair('continue'), assistant, ...pair('continue'), assistant,
54
+ { type: 'event_msg', payload: { type: 'thread_rolled_back', num_turns: 1 } }, ...pair('replacement')];
55
+ const result = parseTranscript('codex', entries, 'fallback');
56
+ expect(result.events.map((item) => item.text)).toEqual(['continue', 'answer', 'replacement']);
57
+ });
58
+ test('Codex includes complete tool outputs without replay payloads', () => {
59
+ const result = parseTranscript('codex', [{ type: 'session_meta', payload: { id: 'id' } },
60
+ { type: 'response_item', payload: { type: 'function_call', call_id: 'c', name: 'shell', arguments: '{"cmd":"echo test"}' } },
61
+ { type: 'response_item', payload: { type: 'function_call_output', call_id: 'c', output: 'x'.repeat(100000) } }], 'fallback');
62
+ expect(result.events[0].output).toHaveLength(100000);
63
+ expect(result.events[0].incomplete).toBe(false);
64
+ });
65
+ test('Codex event-only assistant output survives without duplicating its native encoding or a later repeated turn', () => {
66
+ const user = { type: 'event_msg', payload: { type: 'user_message', message: 'continue' } };
67
+ const answer = { type: 'event_msg', payload: { type: 'agent_message', message: 'answer' } };
68
+ const native = { type: 'response_item', payload: { type: 'message', role: 'assistant', content: [{ type: 'output_text', text: 'answer' }] } };
69
+ const reasoning = { type: 'event_msg', payload: { type: 'agent_reasoning', text: 'historical reasoning' } };
70
+ const result = parseTranscript('codex', [user, answer, native, user, answer, reasoning], 'fixture');
71
+ expect(result.events.map((event) => event.text)).toEqual(['continue', 'answer', 'continue', 'answer', 'historical reasoning']);
72
+ });
73
+ test('DSH surface replacements exclude superseded history and pair tool blocks only once', () => {
74
+ const entries = [{ type: 'session', version: 4, id: 'dsh', cwd: '/project', parentSession: 'parent' },
75
+ { type: 'user/message', seq: 0, time: 1, surfaceOp: 'append', data: { source: { kind: 'user' }, content: [{ type: 'text', text: 'old' }] } },
76
+ { type: 'user/message', seq: 1, time: 2, surfaceOp: { op: 'replace', startSeq: 0, endSeq: 0 }, data: { source: { kind: 'user' }, content: [{ type: 'text', text: 'summary' }] } },
77
+ { type: 'assistant/message', seq: 2, time: 3, surfaceOp: 'append', data: { message: { content: [{ type: 'tool-call', id: 'c', name: 'read', arguments: '{}' }] } } },
78
+ { type: 'tool/call', seq: 3, time: 3, data: { callId: 'c', name: 'read', arguments: '{}' } },
79
+ { type: 'tool/result', seq: 4, time: 4, surfaceOp: 'append', data: { message: { source: { callId: 'c' }, content: [{ type: 'tool-result', toolCallId: 'c', content: [{ type: 'text', text: 'result' }] }] } } }];
80
+ const result = parseTranscript('dsh', entries, 'fallback');
81
+ expect(result.events).toHaveLength(2);
82
+ expect(result.events[0].text).toBe('summary');
83
+ expect(result.events[1]).toMatchObject({ kind: 'tool', name: 'read', input: '{}', output: 'result', incomplete: false });
84
+ expect(result.parentID).toBeUndefined();
85
+ expect(result.warnings).toContain('fork_archived');
86
+ });
87
+ test('DSH unknown versions and broken sequences are explicit errors', () => {
88
+ expect(() => parseTranscript('dsh', [{ type: 'session', version: 99, id: 'd' }], 'fallback')).toThrow('unsupported_source_version');
89
+ expect(() => parseTranscript('dsh', [{ type: 'session', version: 4, id: 'd' }, { type: 'user/message', seq: 10 }], 'fallback')).toThrow('invalid_source');
90
+ });
91
+ });
92
+
93
+ test('native transfer round-trips the installed official schemas, with no permissions or native replay data', () => {
94
+ const session = parseTranscript('claude', [claude('u', null, 'user', [{ type: 'text', text: 'hello' }, { type: 'image', source: { type: 'base64', data: 'aGVsbG8=', media_type: 'image/png' } }]),
95
+ claude('a', 'u', 'assistant', [{ type: 'thinking', thinking: 'historical reasoning' }, { type: 'text', text: 'answer' }], { timestamp: '2026-01-01T00:00:01Z' })], 'fallback');
96
+ const transfer = toNativeTransfer(session, '/project', 'ses_import', { version: 1 });
97
+ const decoded = Schema.decodeUnknownSync(SessionTransfer.Data)({ info: transfer.info, messages: transfer.messages });
98
+ expect(decoded.messages).toHaveLength(3);
99
+ for (const message of transfer.messages) expect(() => Schema.decodeUnknownSync(SessionMessage.Info)(message)).not.toThrow();
100
+ expect(transfer.info.permissions).toBeUndefined();
101
+ expect(transfer.info.model).toBeUndefined();
102
+ expect(transfer.messages[0].files[0].source).toEqual({ type: 'inline' });
103
+ expect(transfer.info.time.updated).toBe(Date.parse('2026-01-01T00:00:01Z'));
104
+ });
105
+
106
+ test('explicit merge deduplicates only a shared prefix and preserves continuation order', () => {
107
+ const u = (text) => ({ kind: 'user', text, time: 1 });
108
+ const result = combineSessions([{ title: 'a', events: [u('hello'), u('continue')] }, { title: 'b', events: [u('hello'), u('different'), u('continue'), u('continue')] }]);
109
+ expect(result.filter((event) => event.kind === 'user').map((event) => event.text)).toEqual(['hello', 'continue', 'different', 'continue', 'continue']);
110
+ });
@@ -0,0 +1,39 @@
1
+ import fs from 'node:fs/promises';
2
+ import { constants } from 'node:fs';
3
+ import path from 'node:path';
4
+ import os from 'node:os';
5
+
6
+ const commands = { claude: ['claude'], codex: ['codex'], cursor: ['cursor', 'cursor-agent'], dsh: ['dsh'] };
7
+
8
+ // Installation evidence is an executable/app binary, never a leftover history
9
+ // directory. Probes do not launch source agents or read their configuration.
10
+ export async function detectSourceInstallations(sources = Object.keys(commands), { home = os.homedir(), env = process.env, platform = process.platform } = {}) {
11
+ const windows = platform === 'win32';
12
+ const paths = [...new Set([...(env.PATH || '').split(windows ? ';' : path.delimiter).filter(Boolean),
13
+ path.join(home, '.local', 'bin'), path.join(home, '.bun', 'bin'), path.join(home, '.npm-global', 'bin')])];
14
+ const extensions = windows ? ['', '.exe', '.cmd', '.bat', '.com'] : [''];
15
+ return Object.fromEntries(await Promise.all(sources.map(async (source) => {
16
+ if (!commands[source]) return [source, null];
17
+ const candidates = paths.flatMap((directory) => commands[source].flatMap((command) => extensions.map((extension) => path.join(directory, `${command}${extension}`))));
18
+ if (source === 'claude') candidates.push(path.join(home, '.claude', 'local', 'claude'));
19
+ if (platform === 'darwin' && ['cursor', 'codex'].includes(source)) {
20
+ const name = source === 'cursor' ? 'Cursor' : 'Codex';
21
+ for (const applications of ['/Applications', path.join(home, 'Applications')]) candidates.push(path.join(applications, `${name}.app`, 'Contents', 'MacOS', name));
22
+ }
23
+ if (windows && source === 'cursor') {
24
+ if (env.LOCALAPPDATA) candidates.push(path.join(env.LOCALAPPDATA, 'Programs', 'cursor', 'Cursor.exe'));
25
+ if (env.ProgramFiles) candidates.push(path.join(env.ProgramFiles, 'Cursor', 'Cursor.exe'));
26
+ }
27
+ let unknown = false;
28
+ for (const candidate of candidates) {
29
+ try {
30
+ if (!(await fs.stat(candidate)).isFile()) continue;
31
+ await fs.access(candidate, windows ? constants.F_OK : constants.X_OK);
32
+ return [source, true];
33
+ } catch (error) {
34
+ if (!['ENOENT', 'ENOTDIR'].includes(error.code)) unknown = true;
35
+ }
36
+ }
37
+ return [source, unknown ? null : false];
38
+ })));
39
+ }
@@ -0,0 +1,24 @@
1
+ import { afterEach, beforeEach, expect, test } from 'vitest';
2
+ import fs from 'node:fs/promises';
3
+ import os from 'node:os';
4
+ import path from 'node:path';
5
+ import { detectSourceInstallations } from './installations.js';
6
+
7
+ let home;
8
+ beforeEach(async () => { home = await fs.mkdtemp(path.join(os.tmpdir(), 'yuri-installation-test-')); });
9
+ afterEach(async () => { await fs.rm(home, { recursive: true, force: true }); });
10
+
11
+ test('installation is detected from executables without executing them; history folders alone are not evidence', async () => {
12
+ const bin = path.join(home, 'bin'); await fs.mkdir(bin);
13
+ await fs.writeFile(path.join(bin, 'claude'), 'this fixture must never execute', { mode: 0o700 });
14
+ await fs.mkdir(path.join(home, '.codex', 'sessions'), { recursive: true });
15
+ await fs.mkdir(path.join(home, '.cursor'), { recursive: true });
16
+ expect(await detectSourceInstallations(undefined, { home, env: { PATH: bin }, platform: 'linux' })).toEqual({ claude: true, codex: false, cursor: false, dsh: false });
17
+ });
18
+ test('user-local executable symlinks count as installed; denied probes remain unknown', async () => {
19
+ const bin = path.join(home, '.local', 'bin'); await fs.mkdir(bin, { recursive: true });
20
+ await fs.writeFile(path.join(home, 'dsh'), 'fixture', { mode: 0o700 });
21
+ await fs.symlink(path.join(home, 'dsh'), path.join(bin, 'dsh'));
22
+ await fs.writeFile(path.join(bin, 'codex'), 'not executable', { mode: 0o600 });
23
+ expect(await detectSourceInstallations(['dsh', 'codex'], { home, env: { PATH: '' }, platform: 'linux' })).toEqual({ dsh: true, codex: null });
24
+ });
@@ -0,0 +1,49 @@
1
+ import { digest, fail } from './events.js';
2
+
3
+ const directoryOf = (session) => session.location?.directory;
4
+ export const nativeRevision = (session, namespace) => ({ source: 'opencode', namespace, id: session.id,
5
+ hash: digest({ id: session.id, directory: directoryOf(session) }), directory: directoryOf(session) });
6
+
7
+ // Only metadata is paged for inventory. Message projection is limited to the
8
+ // visible examples and never used by the in-place project registration job.
9
+ export async function discoverNative(client, namespace, { limitPerSource, includeCounts = false } = {}) {
10
+ const sessions = []; const descriptors = new Map(); const errors = [];
11
+ const seen = new Set(); const cursors = new Set(); const signal = AbortSignal.timeout(10000);
12
+ let cursor; let complete = false;
13
+ try {
14
+ do {
15
+ const page = await client.session.list({ limit: 100, ...(cursor ? { cursor } : { order: 'desc' }) }, { signal });
16
+ if (!Array.isArray(page.data)) fail('invalid_source');
17
+ for (const info of page.data) {
18
+ if (seen.has(info.id)) continue;
19
+ if (seen.size >= 5000) fail('too_many_sessions');
20
+ seen.add(info.id);
21
+ if (limitPerSource !== undefined && sessions.length >= limitPerSource) continue;
22
+ const key = digest(`opencode:${namespace}:${info.id}`);
23
+ const revision = nativeRevision(info, namespace);
24
+ descriptors.set(key, { source: 'opencode', format: 'opencode', sessionID: info.id, namespace, revision });
25
+ sessions.push({ key, source: 'opencode', id: info.id, title: info.title || info.id,
26
+ directory: directoryOf(info) || '', messages: 0, warnings: [], updated: info.time?.updated });
27
+ }
28
+ cursor = page.cursor?.next;
29
+ complete = !cursor;
30
+ if (cursor && cursors.has(cursor)) fail('invalid_source');
31
+ if (cursor) cursors.add(cursor);
32
+ } while (cursor && (limitPerSource === undefined || includeCounts));
33
+ } catch (error) { errors.push({ source: 'opencode', code: error.code ?? 'source_unreadable' }); }
34
+ if (limitPerSource !== undefined) {
35
+ await Promise.all(sessions.map(async (session) => {
36
+ try {
37
+ const page = await client.message.list({ sessionID: session.id, limit: 10, order: 'desc' }, { signal });
38
+ const text = (message) => message.type === 'assistant' ? message.content?.filter((part) => part.type === 'text').map((part) => part.text).join(' ') : message.type === 'user' ? message.text : '';
39
+ const messages = page.data;
40
+ if (!Array.isArray(messages)) fail('invalid_source');
41
+ const excerpt = messages.find((message) => message.type === 'assistant' && text(message)?.trim())
42
+ ?? messages.find((message) => message.type === 'user' && text(message)?.trim());
43
+ session.excerpt = text(excerpt ?? {})?.slice(0, 512).replace(/\s+/g, ' ').trim().slice(0, 180) || '';
44
+ } catch { session.warnings.push('preview_unavailable'); }
45
+ }));
46
+ }
47
+ return { sessions, descriptors, errors,
48
+ counts: includeCounts ? { opencode: { value: complete ? seen.size : null, approximate: false } } : undefined };
49
+ }
@@ -0,0 +1,42 @@
1
+ import { expect, test, vi } from 'vitest';
2
+ import { discoverNative } from './native.js';
3
+
4
+ const info = (id) => ({ id: `ses_${id}`, title: `Conversation ${id}`, location: { directory: '/workspace/example' }, time: { updated: id } });
5
+ const clientFor = (size) => ({ session: { list: vi.fn(async ({ cursor, limit }) => {
6
+ const offset = Number(cursor || 0); const end = Math.min(size, offset + limit);
7
+ return { data: Array.from({ length: end - offset }, (_, index) => info(offset + index)), cursor: end < size ? { next: String(end) } : {} };
8
+ }) }, message: { list: vi.fn(async () => ({ data: [
9
+ { type: 'assistant', content: [{ type: 'reasoning', text: 'private reasoning' }, { type: 'tool', text: 'tool output' }, { type: 'text', text: 'Real\n assistant answer' }] },
10
+ ], cursor: {} })) } });
11
+
12
+ test('5000 native sessions count only metadata, with five bounded message pages and no writes', async () => {
13
+ const client = clientFor(5000);
14
+ const result = await discoverNative(client, 'runtime', { limitPerSource: 5, includeCounts: true });
15
+ expect(result.counts.opencode).toEqual({ value: 5000, approximate: false });
16
+ expect(result.sessions).toHaveLength(5); expect(result.errors).toEqual([]);
17
+ expect(client.session.list).toHaveBeenCalledTimes(50);
18
+ expect(client.message.list).toHaveBeenCalledTimes(5);
19
+ expect(client.message.list.mock.calls.every(([query]) => query.limit === 10)).toBe(true);
20
+ expect(result.sessions[0].excerpt).toBe('Real assistant answer');
21
+ expect(result.descriptors.size).toBe(5);
22
+ });
23
+
24
+ test('full native discovery never reads messages; failed pagination does not claim a partial count', async () => {
25
+ const client = clientFor(101);
26
+ const full = await discoverNative(client, 'runtime');
27
+ expect(full.sessions).toHaveLength(101); expect(client.message.list).not.toHaveBeenCalled();
28
+ client.session.list.mockRejectedValueOnce(new Error('offline'));
29
+ const failed = await discoverNative(client, 'runtime', { limitPerSource: 5, includeCounts: true });
30
+ expect(failed.counts.opencode.value).toBeNull(); expect(failed.errors).toHaveLength(1);
31
+ });
32
+
33
+ test('counting failure keeps readable examples; repeated cursors and oversized catalogs stay bounded', async () => {
34
+ const client = clientFor(5001);
35
+ const result = await discoverNative(client, 'runtime', { limitPerSource: 5, includeCounts: true });
36
+ expect(result.sessions).toHaveLength(5); expect(result.counts.opencode.value).toBeNull();
37
+ expect(result.errors[0].code).toBe('too_many_sessions');
38
+ client.session.list.mockResolvedValue({ data: [info(1)], cursor: { next: 'same' } });
39
+ const repeated = await discoverNative(client, 'runtime', { limitPerSource: 5, includeCounts: true });
40
+ expect(repeated.errors[0].code).toBe('invalid_source');
41
+ expect(repeated.counts.opencode.value).toBeNull();
42
+ });
@@ -0,0 +1,48 @@
1
+ import { createHistoryImportService } from './service.js';
2
+ import { hasPreviewProxyCredential } from '../opencode/core-routes.js';
3
+
4
+ export function registerHistoryImportRoutes(app, { express, uiAuthController, service: provided, ...dependencies }) {
5
+ const service = provided ?? createHistoryImportService(dependencies);
6
+ // All routes inherit the Host UI/client authentication gate. Plans and jobs
7
+ // additionally belong to the authenticated device (or the local owner UI).
8
+ const owner = async (req, res) => {
9
+ if (hasPreviewProxyCredential(req)) throw Object.assign(new Error('forbidden'), { code: 'forbidden' });
10
+ const context = await uiAuthController?.resolveAuthContext(req, res, { allowUrlToken: false });
11
+ if (!context || context.type === 'client' && !context.clientId) throw Object.assign(new Error('authentication_required'), { code: 'authentication_required' });
12
+ return context.type === 'client' ? `client:${context.clientId}` : 'owner';
13
+ };
14
+ const handle = (operation) => async (req, res) => {
15
+ res.setHeader('Cache-Control', 'no-store');
16
+ try { res.json(await operation(req, await owner(req, res))); }
17
+ catch (error) {
18
+ const code = typeof error?.code === 'string' && /^[a-z_]+$/.test(error.code) ? error.code : 'import_failed';
19
+ const status = code === 'authentication_required' ? 401 : code === 'forbidden' ? 403 : ['import_busy', 'plan_expired', 'source_changed', 'target_changed'].includes(code) ? 409
20
+ : ['source_too_large', 'settings_too_large', 'too_many_files', 'too_many_sessions'].includes(code) ? 413
21
+ : code === 'import_failed' ? 500 : 400;
22
+ res.status(status).json({ code });
23
+ }
24
+ };
25
+ const json = express.json({ limit: '2mb' });
26
+ app.post('/api/yuri/history-import/scan', json, handle((req, actor) => service.scan(req.body ?? {}, actor)));
27
+ app.post('/api/yuri/history-import/imported', json, handle((req, actor) => service.imported(req.body ?? {}, actor)));
28
+ app.post('/api/yuri/history-import/preview', json, handle((req, actor) => service.preview(req.body ?? {}, actor)));
29
+ app.post('/api/yuri/history-import/start', json, handle((req, actor) => service.start(req.body ?? {}, actor)));
30
+ app.post('/api/yuri/history-import/resume', json, handle((req, actor) => {
31
+ const origin = req.headers.origin;
32
+ if (actor === 'owner' && (req.headers['sec-fetch-site'] === 'cross-site' || origin && origin !== `${req.protocol}://${req.get('host')}`)) {
33
+ throw Object.assign(new Error('forbidden'), { code: 'forbidden' });
34
+ }
35
+ return service.resume(req.body ?? {}, actor);
36
+ }));
37
+ app.post('/api/yuri/history-import/dismiss', json, handle((req, actor) => {
38
+ const origin = req.headers.origin;
39
+ if (actor === 'owner' && (req.headers['sec-fetch-site'] === 'cross-site' || origin && origin !== `${req.protocol}://${req.get('host')}`)) {
40
+ throw Object.assign(new Error('forbidden'), { code: 'forbidden' });
41
+ }
42
+ return service.dismiss(req.body ?? {}, actor);
43
+ }));
44
+ app.get('/api/yuri/history-import/jobs', handle((_req, actor) => service.jobs(actor)));
45
+ app.get('/api/yuri/history-import/job', handle((req, actor) => service.status(typeof req.query.id === 'string' ? req.query.id : undefined, actor)));
46
+ app.post('/api/yuri/history-import/cancel', json, handle((req, actor) => service.cancel(req.body?.id, actor)));
47
+ return service;
48
+ }
@@ -0,0 +1,55 @@
1
+ import express from 'express';
2
+ import request from 'supertest';
3
+ import { expect, test, vi } from 'vitest';
4
+ import { registerHistoryImportRoutes } from './routes.js';
5
+
6
+ const setup = (context = { type: 'client', clientId: 'device' }) => {
7
+ const app = express();
8
+ const service = { scan: vi.fn(async () => ({ sessions: [] })), imported: vi.fn(async () => ({ states: {} })), preview: vi.fn(), start: vi.fn(), resume: vi.fn(async () => ({ id: 'job' })), dismiss: vi.fn(() => ({ id: 'job' })), jobs: vi.fn(() => []), status: vi.fn(), cancel: vi.fn() };
9
+ const resolveAuthContext = vi.fn(async () => context);
10
+ registerHistoryImportRoutes(app, { express, service, uiAuthController: { resolveAuthContext } });
11
+ return { app, service, resolveAuthContext };
12
+ };
13
+ test('owned routes parse their own body, prohibit URL-token auth and scope requests to the authenticated device', async () => {
14
+ const { app, service, resolveAuthContext } = setup();
15
+ const response = await request(app).post('/api/yuri/history-import/scan').send({ sources: ['claude'] });
16
+ expect(response.status).toBe(200); expect(response.headers['cache-control']).toBe('no-store');
17
+ expect(service.scan).toHaveBeenCalledWith({ sources: ['claude'] }, 'client:device');
18
+ expect(resolveAuthContext.mock.calls[0][2]).toEqual({ allowUrlToken: false });
19
+ const badges = await request(app).post('/api/yuri/history-import/imported').send({ scanID: 'scan', directory: '/workspace' });
20
+ expect(badges.status).toBe(200); expect(badges.headers['cache-control']).toBe('no-store');
21
+ expect(service.imported).toHaveBeenCalledWith({ scanID: 'scan', directory: '/workspace' }, 'client:device');
22
+ expect((await request(app).get('/api/yuri/history-import/jobs')).body).toEqual([]);
23
+ expect(service.jobs).toHaveBeenCalledWith('client:device');
24
+ expect((await request(app).post('/api/yuri/history-import/resume').send({ id: 'job', confirm: true })).body).toEqual({ id: 'job' });
25
+ expect(service.resume).toHaveBeenCalledWith({ id: 'job', confirm: true }, 'client:device');
26
+ expect((await request(app).post('/api/yuri/history-import/dismiss').send({ id: 'job' })).body).toEqual({ id: 'job' });
27
+ expect(service.dismiss).toHaveBeenCalledWith({ id: 'job' }, 'client:device');
28
+ });
29
+ test('unauthenticated requests do not invoke the importer', async () => {
30
+ const { app, service } = setup(null);
31
+ expect((await request(app).post('/api/yuri/history-import/scan').send({})).status).toBe(401);
32
+ expect(service.scan).not.toHaveBeenCalled();
33
+ expect((await request(app).post('/api/yuri/history-import/resume').send({ id: 'job', confirm: true })).status).toBe(401);
34
+ expect((await request(app).get('/api/yuri/history-import/jobs')).status).toBe(401);
35
+ expect(service.resume).not.toHaveBeenCalled();
36
+ expect((await request(app).post('/api/yuri/history-import/dismiss').send({ id: 'job' })).status).toBe(401);
37
+ expect(service.dismiss).not.toHaveBeenCalled();
38
+ });
39
+ test('preview credentials cannot enumerate jobs or resume an import even with an owner cookie', async () => {
40
+ const { app, service } = setup({ type: 'session' });
41
+ expect((await request(app).get('/api/yuri/history-import/jobs?yuri_preview_token=preview')).status).toBe(403);
42
+ expect((await request(app).post('/api/yuri/history-import/resume').set('Cookie', 'yuri_preview_token=preview').send({ id: 'job', confirm: true })).status).toBe(403);
43
+ expect((await request(app).post('/api/yuri/history-import/resume').set('Origin', 'https://other.example').send({ id: 'job', confirm: true })).status).toBe(403);
44
+ expect(service.jobs).not.toHaveBeenCalled(); expect(service.resume).not.toHaveBeenCalled();
45
+ expect((await request(app).post('/api/yuri/history-import/dismiss').set('Origin', 'https://other.example').send({ id: 'job' })).status).toBe(403);
46
+ expect(service.dismiss).not.toHaveBeenCalled();
47
+ });
48
+ test('errors expose only stable codes, never upstream bodies or file contents', async () => {
49
+ const { app, service } = setup();
50
+ service.scan.mockRejectedValue(new Error('private content must never be returned'));
51
+ const response = await request(app).post('/api/yuri/history-import/scan').send({});
52
+ expect(response.status).toBe(500); expect(response.body).toEqual({ code: 'import_failed' });
53
+ service.scan.mockRejectedValue(Object.assign(new Error('private'), { code: 'source_changed' }));
54
+ expect((await request(app).post('/api/yuri/history-import/scan').send({})).status).toBe(409);
55
+ });