@yuriai/web 0.2.25 → 0.2.27-beta.3
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/README.md +21 -1
- package/dist/assets/AgentAvatar-kIN4sZMz.js +1 -0
- package/dist/assets/AssistantView-C2KQZ6a4.js +3 -0
- package/dist/assets/{DiagramView-DN_rHdr9.js → DiagramView-DK0iXm9b.js} +1 -1
- package/dist/assets/{FadeInOnReveal-555z1y1N.js → FadeInOnReveal-BJA9Za3T.js} +1 -1
- package/dist/assets/{GuiPluginSurface-BPMATuPa.js → GuiPluginSurface-Dz2CdSUA.js} +1 -1
- package/dist/assets/{GuiPluginWindow-CAmfr79x.js → GuiPluginWindow-l4FYY6S-.js} +1 -1
- package/dist/assets/Icon-BP1sfnHn.js +1 -0
- package/dist/assets/{ImageLoadingPlaceholder-BMsQLN_b.js → ImageLoadingPlaceholder-DCWssLJG.js} +1 -1
- package/dist/assets/{LoadingImage-DI7sb_H_.js → LoadingImage-C_Hryaqe.js} +1 -1
- package/dist/assets/MarkdownRenderer-Y6uQXIFH.js +2 -0
- package/dist/assets/{MarkdownRendererImpl-B9K5q0Lc.js → MarkdownRendererImpl-qKp1tQrP.js} +1 -1
- package/dist/assets/{MarkstreamRendererImpl-9gUEVQck.js → MarkstreamRendererImpl-B_JTod0h.js} +1 -1
- package/dist/assets/MobileDetailNavigation-B3rUx5Ve.js +1 -0
- package/dist/assets/{MobileResizableSheet-_6OvPSMI.js → MobileResizableSheet-F1zSUD1S.js} +1 -1
- package/dist/assets/{MobileShareBridge-BrdOiu_r.js → MobileShareBridge-F70fkIfS.js} +3 -3
- package/dist/assets/MobileTabPageHeader-0esgB2TO.js +2 -0
- package/dist/assets/MultiRunWindow-D8m6R_4x.js +1 -0
- package/dist/assets/{OnboardingScreen-g8PDztN3.js → OnboardingScreen-BAsPVV_W.js} +1 -1
- package/dist/assets/{OverlayScrollbar-COv8rH_z.js → OverlayScrollbar-wiRM4AGj.js} +1 -1
- package/dist/assets/SettingsView-izzjIckv.js +29 -0
- package/dist/assets/SettingsWindow-CSuHDq_c.js +1 -0
- package/dist/assets/{TerminalView-BLer-ZhM.js → TerminalView-BtM5-BVx.js} +1 -1
- package/dist/assets/{ToolOutputDialog-DI-s2TBb.js → ToolOutputDialog-DJs9w1_J.js} +2 -2
- package/dist/assets/{YuriLogo-BP4j1iqV.js → YuriLogo-aBS6wlYU.js} +1 -1
- package/dist/assets/appThemeRegistry-BY5rY9-W.js +1 -0
- package/dist/assets/{assistant-attachment-cache-Cis9yYGt.js → assistant-attachment-cache-B9iHLlm2.js} +1 -1
- package/dist/assets/{button-Be1cqulG.js → button-Dt6Ygbc7.js} +1 -1
- package/dist/assets/{capgoAdapter-B31jIkD8.js → capgoAdapter-MQ1qpf60.js} +1 -1
- package/dist/assets/collapsible-Dm7OHk7m.js +1 -0
- package/dist/assets/{device-hj359GjJ.js → device-BjRYYXNT.js} +1 -1
- package/dist/assets/{diagram-hEIRiKol.js → diagram-DWZaG3_v.js} +1 -1
- package/dist/assets/dialog-CTYD3Sbr.css +1 -0
- package/dist/assets/dialog-CjQeHVOc.js +1 -0
- package/dist/assets/{dropdown-menu.styles-xxM2ofOp.js → dropdown-menu.styles-PdxueXzN.js} +1 -1
- package/dist/assets/{es-Clj7CS2r.js → es-BjI1GHJ5.js} +3 -3
- package/dist/assets/{fileMentionTouchSelection-CTh0Mc2g.js → fileMentionTouchSelection-D7QtVxjI.js} +2 -2
- package/dist/assets/{fileQueries-COS23nLq.js → fileQueries-5a1jkme2.js} +1 -1
- package/dist/assets/{fileReferenceActions-Cus9oSW7.js → fileReferenceActions-BAoEu4z8.js} +1 -1
- package/dist/assets/{fr-dmrFQLCO.js → fr-Bs7ndHkb.js} +4 -4
- package/dist/assets/{gitApi-deADOzlN.js → gitApi-BxQmH8Wg.js} +1 -1
- package/dist/assets/{gitApiHttp-BBRKl9WX.js → gitApiHttp-DHrRqnYh.js} +3 -3
- package/dist/assets/{gui-BHEKelUx.js → gui-9enrif_1.js} +1 -1
- package/dist/assets/{host-DrqLUbqt.js → host-D1EpSUMR.js} +1 -1
- package/dist/assets/image-loading-Dq1g_wpm.js +1 -0
- package/dist/assets/{input-DTdHYZ6r.js → input-Dq4usRDa.js} +1 -1
- package/dist/assets/insertionBoundaries-CKQL85zy.js +1 -0
- package/dist/assets/{ja-Co0dxiN_.js → ja-DkdV26EW.js} +4 -4
- package/dist/assets/{ko-BltElAGq.js → ko-B0qoC5da.js} +4 -4
- package/dist/assets/main-CNwFqQQd.js +2 -0
- package/dist/assets/main-DPhcXanT.js +169 -0
- package/dist/assets/{markdownHeightCache-DnR01ECa.js → markdownHeightCache-C1u0bWDL.js} +1 -1
- package/dist/assets/{markdownTheme-DHoKvD6O.js → markdownTheme-hpURsgju.js} +1 -1
- package/dist/assets/{mcpQueries-Cpb22_60.js → mcpQueries-D2IxTr4k.js} +1 -1
- package/dist/assets/miniChat-CF2vb25D.js +2 -0
- package/dist/assets/mobile-C24qSj44.js +2 -0
- package/dist/assets/{mobileBackNavigation-BibkyIeB.js → mobileBackNavigation-vpCg1S7j.js} +1 -1
- package/dist/assets/{multirun-CPvUnP91.js → multirun-DT-dFXud.js} +2 -2
- package/dist/assets/{native-BMAEg2E6.js → native-De1DIkLZ.js} +1 -1
- package/dist/assets/{native-config-DA8S8EqV.js → native-config-ncdoz9Wl.js} +1 -1
- package/dist/assets/{persistence-CBL0OOdj.js → persistence-JyLTFv27.js} +1 -1
- package/dist/assets/{pl-qd6Wnl7H.js → pl-D27Y_GBs.js} +4 -4
- package/dist/assets/projectMeta-CG8NLahh.js +1 -0
- package/dist/assets/{pt-BR-CsOFfQXS.js → pt-BR-DbocEu4b.js} +3 -3
- package/dist/assets/{react-BYRXYlGz.js → react-CURmDhtB.js} +1 -1
- package/dist/assets/{readiness-RiznV1AX.js → readiness-DSJs_3v4.js} +1 -1
- package/dist/assets/{renderElectronMiniChatApp-DdGqTh4X.js → renderElectronMiniChatApp-ChZCxxH6.js} +2 -2
- package/dist/assets/renderMobileApp-CRv3Il6P.js +28 -0
- package/dist/assets/{runtime-file-download-B_c7JBoS.js → runtime-file-download-CcNIVp7u.js} +1 -1
- package/dist/assets/{runtime-file-resource-DpTxBCsp.js → runtime-file-resource-6np6lzoV.js} +1 -1
- package/dist/assets/runtimeConfig-CZrflo-r.js +2 -0
- package/dist/assets/runtimeEndpointReset-BL9hV6J1.css +1 -0
- package/dist/assets/runtimeEndpointReset-Cx3RE97b.js +149 -0
- package/dist/assets/scheduledTaskNavigation-rhgnZaaj.js +1 -0
- package/dist/assets/sessionChangeSummary-8C8nv-EP.css +1 -0
- package/dist/assets/sessionChangeSummary-CVUA1AFw.js +1 -0
- package/dist/assets/{sessionLookup-B7kUOIpO.js → sessionLookup-C3_vQwLe.js} +1 -1
- package/dist/assets/{sortable-tabs-strip-CQZ16rbO.js → sortable-tabs-strip-C1QmKFdb.js} +1 -1
- package/dist/assets/speechSettingsQueries-BSQ-2JTv.js +4 -0
- package/dist/assets/src-NKCZI3Lg.css +2 -0
- package/dist/assets/{store-7wItZZ7_.js → store-DvN2L3vf.js} +4 -4
- package/dist/assets/{terminalApi-C0_GUlPR.js → terminalApi-B5o8UqWA.js} +1 -1
- package/dist/assets/{textarea-BU8JtaSQ.js → textarea-vtIQM2iP.js} +1 -1
- package/dist/assets/{tooltip-C8DhNU1d.js → tooltip-BpG2mxrT.js} +1 -1
- package/dist/assets/{touch-gestures-zegXCZEP.js → touch-gestures-K2_ZOkKW.js} +1 -1
- package/dist/assets/types-CNTgeeM1.js +2 -0
- package/dist/assets/{uk-BNrdZFvK.js → uk-B_JwElWz.js} +3 -3
- package/dist/assets/{useAppFontEffects-Bs6kVjrE.js → useAppFontEffects-BguV1Hfa.js} +55 -51
- package/dist/assets/useAppFontEffects-RpgNbjA4.css +1 -0
- package/dist/assets/{useAssistantUIStore-NlYBroMc.js → useAssistantUIStore-C9FPlYQz.js} +1 -1
- package/dist/assets/{useDesktopWindowControlsLayout-COBTly74.js → useDesktopWindowControlsLayout-CwgkVw9f.js} +1 -1
- package/dist/assets/useEffectiveDirectory-Ci6Z13kj.js +1 -0
- package/dist/assets/{useFontPreferences-DQAS94Z4.js → useFontPreferences-DMiP_Yy-.js} +1 -1
- package/dist/assets/useMobileNavigationStore-TCj7ZnhV.js +418 -0
- package/dist/assets/{useThemeSystem-8jhE4Zyk.js → useThemeSystem-CGF5jnIh.js} +1 -1
- package/dist/assets/{useUIStore-96W41KFb.js → useUIStore-DI7va1HH.js} +1 -1
- package/dist/assets/{useWorkerHighlightedLines-BZUO0Si5.js → useWorkerHighlightedLines-HKhuYGSj.js} +1 -1
- package/dist/assets/{vendor-base-ui-CdzJ6My_.js → vendor-base-ui-BQjbsJ43.js} +1 -1
- package/dist/assets/{vendor-cmdk-RDxC-9Iz.js → vendor-cmdk-C3oBVL9X.js} +1 -1
- package/dist/assets/{vendor-dnd-kit-accessibility-COSwgjFs.js → vendor-dnd-kit-accessibility-DxpFzZhi.js} +1 -1
- package/dist/assets/{vendor-dnd-kit-core-5pNnzVdw.js → vendor-dnd-kit-core-B3g3zWQd.js} +1 -1
- package/dist/assets/{vendor-dnd-kit-sortable-Dm50I0m7.js → vendor-dnd-kit-sortable-BKewx0Py.js} +1 -1
- package/dist/assets/{vendor-framer-motion-BQ3-sJMO.js → vendor-framer-motion-C1twy-GF.js} +1 -1
- package/dist/assets/{vendor-markstream-react-Bm0cO70Z.js → vendor-markstream-react-BlbOg72y.js} +3 -3
- package/dist/assets/vendor-motion-BmLx2V78.js +1 -0
- package/dist/assets/{vendor-opencode-client-fxfj4IA_.js → vendor-opencode-client-UL_TecvQ.js} +1 -1
- package/dist/assets/{vendor-opencode-plugin-CQ5ogY33.js → vendor-opencode-plugin-Bw7Q6Nv9.js} +1 -1
- package/dist/assets/{vendor-pierre-diffs-DPBtNDJ5.js → vendor-pierre-diffs-Bj9Nqn6w.js} +1 -1
- package/dist/assets/{vendor-react-BP2cRVqX.js → vendor-react-D5d-V1vN.js} +1 -1
- package/dist/assets/{vendor-react-drawio-Ck9ZKdNN.js → vendor-react-drawio-C-iPmmED.js} +1 -1
- package/dist/assets/{vendor-reactuses-core-BJ-jJ4YM.js → vendor-reactuses-core-BcebBLwF.js} +1 -1
- package/dist/assets/{vendor-solid-js-Dmt4_-Zk.js → vendor-solid-js-0T254UHG.js} +1 -1
- package/dist/assets/{vendor-sonner-ZS8XIOVl.js → vendor-sonner-r2EJnfoo.js} +1 -1
- package/dist/assets/{vendor-stream-diffs-TgIdH4lX.js → vendor-stream-diffs-BnLmeqg2.js} +2 -2
- package/dist/assets/{vendor-tanstack-react-query-CdqCAt40.js → vendor-tanstack-react-query-C4SG3JZB.js} +1 -1
- package/dist/assets/vendor-tanstack-react-virtual-BeZn51tF.js +1 -0
- package/dist/assets/{vendor-zustand-o69pgTEK.js → vendor-zustand-B43HCgwC.js} +1 -1
- package/dist/assets/{zh-CN-DMvJXS23.js → zh-CN-DhFFdHQu.js} +4 -4
- package/dist/assets/{zh-TW-D0wsKLs1.js → zh-TW-BvehppXO.js} +4 -4
- package/dist/index.html +18 -18
- package/dist/mini-chat.html +18 -18
- package/dist/mobile.html +18 -18
- package/package.json +1 -1
- package/server/lib/assistants/DOCUMENTATION.md +68 -37
- package/server/lib/assistants/cards.js +4 -0
- package/server/lib/assistants/cards.test.js +11 -1
- package/server/lib/assistants/contact-attachments.http.test.js +31 -7
- package/server/lib/assistants/contact-store.js +70 -27
- package/server/lib/assistants/contact-store.test.js +88 -8
- package/server/lib/assistants/contact-tools.js +68 -84
- package/server/lib/assistants/contact-tools.test.js +85 -42
- package/server/lib/assistants/harness.js +6 -3
- package/server/lib/assistants/harness.test.js +25 -10
- package/server/lib/assistants/routes.js +25 -3
- package/server/lib/assistants/service.js +283 -146
- package/server/lib/assistants/service.test.js +954 -54
- package/server/lib/assistants/weixin/DOCUMENTATION.md +142 -0
- package/server/lib/assistants/weixin/api.js +113 -0
- package/server/lib/assistants/weixin/api.test.js +80 -0
- package/server/lib/assistants/weixin/routes.js +23 -0
- package/server/lib/assistants/weixin/routes.test.js +41 -0
- package/server/lib/assistants/weixin/runtime.js +357 -0
- package/server/lib/assistants/weixin/runtime.test.js +286 -0
- package/server/lib/assistants/weixin/store.js +103 -0
- package/server/lib/assistants/weixin/typing.js +88 -0
- package/server/lib/assistants/weixin/typing.test.js +185 -0
- package/server/lib/assistants/yuri-project.http.test.js +47 -0
- package/server/lib/assistants/yuri-tools.js +1 -1
- package/server/lib/assistants/yuri-tools.test.js +3 -2
- package/server/lib/git/DOCUMENTATION.md +6 -0
- package/server/lib/git/branches.test.js +18 -0
- package/server/lib/git/service.js +6 -3
- package/server/lib/llm/DOCUMENTATION.md +15 -7
- package/server/lib/llm/bridge-client.js +58 -34
- package/server/lib/llm/bridge-client.test.js +123 -16
- package/server/lib/notifications/APNS.md +7 -4
- package/server/lib/notifications/DOCUMENTATION.md +3 -1
- package/server/lib/notifications/apns-runtime.js +14 -8
- package/server/lib/notifications/apns-runtime.test.js +28 -0
- package/server/lib/notifications/family-completion-gate.js +37 -31
- package/server/lib/notifications/family-completion-gate.test.js +32 -0
- package/server/lib/opencode/DOCUMENTATION.md +6 -0
- package/server/lib/opencode/hmr-isolation.test.js +56 -0
- package/server/lib/opencode/lifecycle.js +23 -27
- package/server/lib/opencode/network-runtime.js +8 -14
- package/server/lib/opencode/network-runtime.test.js +4 -4
- package/server/lib/opencode/proxy.js +2 -1
- package/server/lib/opencode/proxy.test.js +1 -0
- package/server/lib/opencode/shutdown-runtime.js +1 -1
- package/server/lib/opencode/shutdown-runtime.test.js +12 -0
- package/server/lib/relay/DOCUMENTATION.md +8 -1
- package/server/lib/relay/relay-server.e2e.test.ts +102 -1
- package/server/lib/relay/service.js +1 -1
- package/server/lib/relay/service.test.js +14 -1
- package/server/lib/request-cors.js +1 -1
- package/server/lib/request-cors.test.js +13 -1
- package/server/lib/session-goal/DOCUMENTATION.md +3 -0
- package/server/lib/session-goal/runtime.js +0 -4
- package/server/lib/session-index/DOCUMENTATION.md +18 -4
- package/server/lib/session-index/event-ingest.js +6 -0
- package/server/lib/session-index/event-ingest.test.js +10 -0
- package/server/lib/session-index/service.js +89 -13
- package/server/lib/session-index/service.test.js +144 -1
- package/server/lib/session-metadata/routes.test.js +44 -0
- package/server/lib/tts/DOCUMENTATION.md +24 -2
- package/server/lib/tts/direct-speech.test.js +28 -3
- package/server/opencode-proxy.test.js +5 -5
- package/dist/assets/AgentAvatar--wjVXk3I.js +0 -1
- package/dist/assets/AssistantView-CSpW-4g6.js +0 -3
- package/dist/assets/Icon-Bn4Eec3Y.js +0 -1
- package/dist/assets/MarkdownRenderer-DP2a0lfG.js +0 -2
- package/dist/assets/MobileDetailNavigation-C9NHt08G.js +0 -1
- package/dist/assets/MobileTabPageHeader-qe23xT2-.js +0 -2
- package/dist/assets/MultiRunWindow-CvHADKf9.js +0 -1
- package/dist/assets/SettingsView-DK8Jkkhd.js +0 -29
- package/dist/assets/SettingsWindow-EP8KZok8.js +0 -1
- package/dist/assets/appThemeRegistry-BnQF2GlY.js +0 -1
- package/dist/assets/collapsible-DqfguRMp.js +0 -1
- package/dist/assets/dialog-BS-KgM5J.js +0 -1
- package/dist/assets/image-loading-DJZLvhMd.js +0 -1
- package/dist/assets/insertionBoundaries-h2be7xbf.js +0 -1
- package/dist/assets/main-BpBrYqtJ.js +0 -169
- package/dist/assets/main-C2QklNP4.js +0 -2
- package/dist/assets/miniChat-C-9deNrt.js +0 -2
- package/dist/assets/mobile-DW7tEL-k.js +0 -2
- package/dist/assets/projectMeta-BwAS96mf.js +0 -1
- package/dist/assets/renderMobileApp-Bipi0hKv.js +0 -28
- package/dist/assets/runtimeConfig-Dx7Y6Yvp.js +0 -2
- package/dist/assets/runtimeEndpointReset-0buInzjw.js +0 -149
- package/dist/assets/runtimeEndpointReset-HYSytKO-.css +0 -1
- package/dist/assets/scheduledTaskNavigation-CYozx15H.js +0 -1
- package/dist/assets/sessionChangeSummary-BGisROOB.js +0 -1
- package/dist/assets/sessionChangeSummary-CRYRvpy7.css +0 -1
- package/dist/assets/speechSettingsQueries-CWXTghOr.js +0 -4
- package/dist/assets/src-BFsc_2gs.css +0 -2
- package/dist/assets/types-C9aO7yfx.js +0 -2
- package/dist/assets/useEffectiveDirectory-Bg0LmEqP.js +0 -1
- package/dist/assets/useMobileNavigationStore-hhiMBg5n.js +0 -418
- package/dist/assets/vendor-motion-B4xmxmaP.js +0 -1
- package/dist/assets/vendor-tanstack-react-virtual-B_EO--9t.js +0 -1
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
import fs from 'node:fs';
|
|
2
|
+
import os from 'node:os';
|
|
3
|
+
import path from 'node:path';
|
|
4
|
+
import { execFile } from 'node:child_process';
|
|
5
|
+
import { fileURLToPath } from 'node:url';
|
|
6
|
+
import { promisify } from 'node:util';
|
|
7
|
+
import { expect, it } from 'vitest';
|
|
8
|
+
|
|
9
|
+
const repoRoot = path.resolve(path.dirname(fileURLToPath(import.meta.url)), '../../../../..');
|
|
10
|
+
const run = promisify(execFile);
|
|
11
|
+
|
|
12
|
+
it.each([false, true])('HMR isolates Yuri state with private OpenCode: %s', async (isolated) => {
|
|
13
|
+
const directory = fs.mkdtempSync(path.join(os.tmpdir(), 'hmr-isolation-'));
|
|
14
|
+
const hmrData = path.join(directory, 'hmr');
|
|
15
|
+
const sharedData = path.join(directory, 'shared-yuri');
|
|
16
|
+
const capture = path.join(directory, 'api-env.json');
|
|
17
|
+
const preload = path.join(directory, 'capture-spawn.cjs');
|
|
18
|
+
fs.writeFileSync(preload, `
|
|
19
|
+
const fs = require('node:fs');
|
|
20
|
+
const { EventEmitter } = require('node:events');
|
|
21
|
+
require('node:child_process').spawn = (_command, args, options) => {
|
|
22
|
+
if (args.includes('dev:server:watch')) {
|
|
23
|
+
fs.writeFileSync(process.env.TEST_HMR_CAPTURE, JSON.stringify({
|
|
24
|
+
yuriData: options.env.YURI_DATA_DIR,
|
|
25
|
+
index: options.env.YURI_SESSION_INDEX_DB_PATH,
|
|
26
|
+
sharedService: options.env.YURI_OPENCODE_SHARED_SERVICE,
|
|
27
|
+
}));
|
|
28
|
+
}
|
|
29
|
+
return new EventEmitter();
|
|
30
|
+
};
|
|
31
|
+
require('node:module').syncBuiltinESMExports();
|
|
32
|
+
`);
|
|
33
|
+
try {
|
|
34
|
+
await run(process.execPath, ['--require', preload, path.join(repoRoot, 'scripts/dev-web-hmr.mjs')], {
|
|
35
|
+
cwd: repoRoot,
|
|
36
|
+
env: {
|
|
37
|
+
...process.env,
|
|
38
|
+
YURI_HMR_ISOLATED_OPENCODE: isolated ? '1' : '0',
|
|
39
|
+
YURI_HMR_DATA_DIR: hmrData,
|
|
40
|
+
YURI_DATA_DIR: sharedData,
|
|
41
|
+
YURI_OPENCODE_SHARED_SERVICE: '1',
|
|
42
|
+
YURI_VITE_FORCE: '0',
|
|
43
|
+
XDG_DATA_HOME: path.join(directory, 'xdg-data'),
|
|
44
|
+
TEST_HMR_CAPTURE: capture,
|
|
45
|
+
},
|
|
46
|
+
});
|
|
47
|
+
expect(JSON.parse(fs.readFileSync(capture, 'utf8'))).toEqual({
|
|
48
|
+
yuriData: isolated ? path.join(hmrData, 'yuri') : sharedData,
|
|
49
|
+
index: path.join(hmrData, 'session-index.sqlite'),
|
|
50
|
+
sharedService: isolated ? '0' : '1',
|
|
51
|
+
});
|
|
52
|
+
expect(fs.existsSync(sharedData)).toBe(false);
|
|
53
|
+
} finally {
|
|
54
|
+
fs.rmSync(directory, { recursive: true, force: true });
|
|
55
|
+
}
|
|
56
|
+
});
|
|
@@ -23,7 +23,6 @@ const HEALTH_CHECK_INTERVAL_OVERRIDE_MS = parsePositiveInt(process.env.YURI_OPEN
|
|
|
23
23
|
const HEALTH_CHECK_RESULT_CACHE_MS = parsePositiveInt(process.env.YURI_OPENCODE_HEALTH_CACHE_MS, 750);
|
|
24
24
|
// Official OpenCode 2.x exposes ServerInfo at GET /api/info (client.server.info).
|
|
25
25
|
const OPENCODE_HEALTH_PATH = '/api/info';
|
|
26
|
-
const OPENCODE_HEALTH_FALLBACK_PATH = '/global/health';
|
|
27
26
|
const DEFAULT_OPENCODE_SERVE_PORT = 4096;
|
|
28
27
|
// Polite SIGTERM window before SIGKILL for managed children (restart/OAuth/reload
|
|
29
28
|
// need enough time for clean flush; do not shorten globally for Quit latency).
|
|
@@ -511,8 +510,7 @@ export const createOpenCodeLifecycleRuntime = (deps) => {
|
|
|
511
510
|
return false;
|
|
512
511
|
};
|
|
513
512
|
|
|
514
|
-
// v2 readiness lives at /api/info (ServerInfo.version)
|
|
515
|
-
// a probe fallback for older sidecars. Both require Basic auth from
|
|
513
|
+
// v2 readiness lives at /api/info (ServerInfo.version), with Basic auth from
|
|
516
514
|
// getOpenCodeAuthHeaders(). Version admission rejects 1.x / missing / noise.
|
|
517
515
|
// Health ok is reachability only — execution semantics live on runtimeContract.
|
|
518
516
|
const fetchOpenCodeHealthResult = async (urlForPath, signal, options = {}) => {
|
|
@@ -526,31 +524,29 @@ export const createOpenCodeLifecycleRuntime = (deps) => {
|
|
|
526
524
|
let lastGate = null;
|
|
527
525
|
for (const headerCandidate of headerCandidates) {
|
|
528
526
|
const { authenticated, ...headers } = headerCandidate;
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
continue;
|
|
539
|
-
}
|
|
540
|
-
if (!response.ok) continue;
|
|
541
|
-
const body = await response.json().catch(() => null);
|
|
542
|
-
const gate = evaluateOpenCodeHealthBody(body);
|
|
543
|
-
lastGate = gate;
|
|
544
|
-
if (gate.ok) {
|
|
545
|
-
return {
|
|
546
|
-
ok: true,
|
|
547
|
-
version: gate.version,
|
|
548
|
-
authenticated: authenticated !== false,
|
|
549
|
-
healthOk: true,
|
|
550
|
-
};
|
|
551
|
-
}
|
|
552
|
-
} catch {
|
|
527
|
+
try {
|
|
528
|
+
const response = await fetch(urlForPath(OPENCODE_HEALTH_PATH), {
|
|
529
|
+
method: 'GET',
|
|
530
|
+
headers,
|
|
531
|
+
signal,
|
|
532
|
+
});
|
|
533
|
+
if (response.status === 401 || response.status === 403) {
|
|
534
|
+
sawUnauthorized = true;
|
|
535
|
+
continue;
|
|
553
536
|
}
|
|
537
|
+
if (!response.ok) continue;
|
|
538
|
+
const body = await response.json().catch(() => null);
|
|
539
|
+
const gate = evaluateOpenCodeHealthBody(body);
|
|
540
|
+
lastGate = gate;
|
|
541
|
+
if (gate.ok) {
|
|
542
|
+
return {
|
|
543
|
+
ok: true,
|
|
544
|
+
version: gate.version,
|
|
545
|
+
authenticated: authenticated !== false,
|
|
546
|
+
healthOk: true,
|
|
547
|
+
};
|
|
548
|
+
}
|
|
549
|
+
} catch {
|
|
554
550
|
}
|
|
555
551
|
}
|
|
556
552
|
if (sawUnauthorized && !lastGate?.ok) {
|
|
@@ -53,20 +53,14 @@ export const createOpenCodeNetworkRuntime = (deps) => {
|
|
|
53
53
|
Accept: 'application/json',
|
|
54
54
|
...getOpenCodeAuthHeaders(),
|
|
55
55
|
};
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
// Official 2.x /api/info is ServerInfo (version, no healthy);
|
|
65
|
-
// /global/health may still return { healthy, version }.
|
|
66
|
-
if (evaluateOpenCodeHealthBody(body).ok) {
|
|
67
|
-
return true;
|
|
68
|
-
}
|
|
69
|
-
}
|
|
56
|
+
const response = await fetch(`${baseUrl}/api/info`, {
|
|
57
|
+
method: 'GET',
|
|
58
|
+
headers,
|
|
59
|
+
signal: controller.signal,
|
|
60
|
+
});
|
|
61
|
+
if (response.ok) {
|
|
62
|
+
const body = await response.json().catch(() => null);
|
|
63
|
+
if (evaluateOpenCodeHealthBody(body).ok) return true;
|
|
70
64
|
}
|
|
71
65
|
} catch {
|
|
72
66
|
} finally {
|
|
@@ -49,7 +49,7 @@ describe('OpenCode network runtime', () => {
|
|
|
49
49
|
expect(String(fetchMock.mock.calls[0][0])).toContain('/api/info');
|
|
50
50
|
});
|
|
51
51
|
|
|
52
|
-
it('falls back to
|
|
52
|
+
it('never falls back to a removed health route when /api/info is unavailable', async () => {
|
|
53
53
|
const fetchMock = vi.fn(async (url) => {
|
|
54
54
|
if (String(url).includes('/api/info')) {
|
|
55
55
|
return new Response('not found', { status: 404 });
|
|
@@ -75,9 +75,9 @@ describe('OpenCode network runtime', () => {
|
|
|
75
75
|
getOpenCodeAuthHeaders: () => ({ Authorization: 'Basic Zml4dHVyZQ==' }),
|
|
76
76
|
});
|
|
77
77
|
|
|
78
|
-
await expect(runtime.waitForReady('http://127.0.0.1:4096',
|
|
79
|
-
expect(
|
|
80
|
-
expect(
|
|
78
|
+
await expect(runtime.waitForReady('http://127.0.0.1:4096', 1)).resolves.toBe(false);
|
|
79
|
+
expect(fetchMock).toHaveBeenCalled();
|
|
80
|
+
expect(fetchMock.mock.calls.every(([url]) => new URL(url).pathname === '/api/info')).toBe(true);
|
|
81
81
|
});
|
|
82
82
|
|
|
83
83
|
it('returns false when readiness fetch rejects', async () => {
|
|
@@ -634,7 +634,8 @@ export const registerOpenCodeProxy = (app, deps) => {
|
|
|
634
634
|
try {
|
|
635
635
|
// Strip includeReasoning before building the upstream OpenCode path.
|
|
636
636
|
const strippedUrl = stripIncludeReasoningParam(requestUrl);
|
|
637
|
-
const
|
|
637
|
+
const eventUrl = new URL(strippedUrl, 'http://yuri.invalid');
|
|
638
|
+
const upstreamPath = `/api/event${eventUrl.search}`;
|
|
638
639
|
const headers = normalizeForwardedDirectoryHeaders(
|
|
639
640
|
collectForwardProxyHeaders(req.headers, getOpenCodeAuthHeaders())
|
|
640
641
|
);
|
|
@@ -118,6 +118,7 @@ describe('Host events on proxied SSE', () => {
|
|
|
118
118
|
}, cancel: async () => {}, releaseLock() {},
|
|
119
119
|
}) } }));
|
|
120
120
|
const response = await request(mountProxy({ subscribeGlobalUiEvent })).get(route).expect(200);
|
|
121
|
+
expect(new URL(globalThis.fetch.mock.calls[0][0]).pathname).toBe('/api/event');
|
|
121
122
|
const events = response.text.trim().split('\n\n').map((block) => JSON.parse(block.slice(6)));
|
|
122
123
|
expect(events).toEqual([{ directory: '/repo', payload: title }, { directory: '/repo', payload: metadata }, upstream]);
|
|
123
124
|
expect(unsubscribe).toHaveBeenCalledTimes(1);
|
|
@@ -51,7 +51,7 @@ export const createGracefulShutdownRuntime = (dependencies) => {
|
|
|
51
51
|
// in-flight attach/finalize can still write, and so exitProcess:false restarts
|
|
52
52
|
// can reuse the same global singleton without reopening a closed SQLite handle.
|
|
53
53
|
scheduledTasksRuntime?.stop?.();
|
|
54
|
-
closeFeatureRoutes?.();
|
|
54
|
+
await closeFeatureRoutes?.();
|
|
55
55
|
|
|
56
56
|
const healthCheckInterval = getHealthCheckInterval();
|
|
57
57
|
if (healthCheckInterval) {
|
|
@@ -31,6 +31,18 @@ const createRuntime = (server, shutdownTimeoutMs = 1000, overrides = {}) => crea
|
|
|
31
31
|
});
|
|
32
32
|
|
|
33
33
|
describe('graceful shutdown runtime', () => {
|
|
34
|
+
it('waits for Host message channels to stop before closing downstream runtimes', async () => {
|
|
35
|
+
let release;
|
|
36
|
+
const closeFeatureRoutes = vi.fn(() => new Promise((resolve) => { release = resolve; }));
|
|
37
|
+
const server = { close: vi.fn((callback) => callback()) };
|
|
38
|
+
const runtime = createRuntime(server, 1000, { closeFeatureRoutes });
|
|
39
|
+
const pending = runtime.gracefulShutdown({ exitProcess: false });
|
|
40
|
+
expect(closeFeatureRoutes).toHaveBeenCalledOnce();
|
|
41
|
+
expect(server.close).not.toHaveBeenCalled();
|
|
42
|
+
release();
|
|
43
|
+
await pending;
|
|
44
|
+
expect(server.close).toHaveBeenCalledOnce();
|
|
45
|
+
});
|
|
34
46
|
afterEach(() => {
|
|
35
47
|
vi.useRealTimers();
|
|
36
48
|
vi.restoreAllMocks();
|
|
@@ -6,6 +6,13 @@ The private relay lets an Yuri client (mobile app, browser, or another desktop)
|
|
|
6
6
|
|
|
7
7
|
Traffic is **end-to-end encrypted between the two endpoints** (client and host instance). The relay infrastructure forwards opaque ciphertext and cannot read application traffic — it is an untrusted transport, not a trusted middlebox.
|
|
8
8
|
|
|
9
|
+
`packages/relay-server/src/core.js` is the common Layer 1 implementation for the
|
|
10
|
+
Node/Docker server and Cloudflare Workers (`src/worker.js`, one Durable Object per
|
|
11
|
+
deployment). Workers preserves the Host/Client wire protocol and E2EE boundary;
|
|
12
|
+
it currently uses ordinary accepted sockets, not Hibernation, and does not host
|
|
13
|
+
APNs Push. See the Relay package README for deployment, separate Push URL and
|
|
14
|
+
Workers-specific billing/backpressure limits.
|
|
15
|
+
|
|
9
16
|
This module (`packages/web/server/lib/relay/`) is the **Host side** of the private relay. **Only the Electron desktop runtime or an SSH-managed remote server may act as a relay host** (`YURI_RUNTIME=desktop` or `ssh-remote`). Electron sets `desktop` before it starts the in-process web server; SSH manager sets `ssh-remote` when launching a managed remote `yuri serve` (optionally with `--relay-host`). Plain `node` / `dev:web:hmr` / ordinary CLI / VS Code web servers must not open the host-control socket, claim `relay-host.lock`, or advertise a host pairing candidate — even when they share the same data dir as desktop. Those processes may still run the API that *clients* use; mobile and other desktops remain **relay clients**. The **Client side** lives in `packages/ui/src/lib/relay/`. Hosted Relay instances may run in a Worker. The self-hosted **Relay server** belongs to `packages/relay-server/` and brokers Layer 1 connections.
|
|
10
17
|
|
|
11
18
|
## The three layers
|
|
@@ -18,7 +25,7 @@ Traffic is modeled as three stacked layers. The relay understands only Layer 1;
|
|
|
18
25
|
|
|
19
26
|
## Entrypoints and structure
|
|
20
27
|
|
|
21
|
-
The Host and pairing UI default to `wss://relay.
|
|
28
|
+
The Host and pairing UI default to `wss://relay.useyuri.top/ws`. Host endpoint precedence is `YURI_RELAY_URL`, saved `privateRelay.relayUrl`, then the product default. Existing saved pairing endpoints remain authoritative for reconnects; the default change does not rewrite saved Host endpoints or client preferences. The default Workers Relay has no APNs Push service: set `YURI_PUSH_RELAY_URL` independently. Custom Relay endpoints retain same-origin Push derivation when that override is absent.
|
|
22
29
|
|
|
23
30
|
Host side (`packages/web/server/lib/relay/`):
|
|
24
31
|
- `service.js` — thin entrypoint: relay config (enabled flag + endpoints), the management routes (`GET/POST /api/yuri/relay/{status,enable,disable}`, `POST /api/yuri/relay/endpoints`), a `getPairingCandidate()` accessor (the relay transport candidate folded into pairing-v2 links when enabled, consumed by the pairing-session route in `core-routes.js`), and lifecycle wiring. **Multi-relay:** `settings.privateRelay = { enabled, relayUrl, extraRelayUrls }` — the host dials EVERY configured endpoint simultaneously with one identity (same serverId); clients treat `serverId + relayUrl` as the instance identity, so the same machine exposed via two domains appears as two separately named instances. The primary (`relayUrl`) owns push registration and stays the default pairing candidate. A pairing link created for an endpoint the host does not have yet APPENDS it as an extra endpoint instead of replacing the primary, so devices paired over the old domain keep working. `POST /relay/endpoints` (owner session / `desktop-local` only) replaces the extra-endpoint list wholesale and starts/stops host connections incrementally. Paired desktop operators may also add an endpoint through pairing creation. Host lifecycle is gated by `isRelayHostRuntime()` (`desktop` or `ssh-remote`): other runtimes (`bun run dev`, `dev:web:hmr`, ordinary CLI `serve`, VS Code, plain `node server`) report `state: 'unavailable'`, refuse `/relay/enable`, `/relay/disable`, `/relay/endpoints`, and relay pairing with 403, never mint a relay identity, never advertise `relayAvailable`, and never call `startRelayHost`. Direct `node server/index.js` forces `YURI_RUNTIME=web` unless it is already `ssh-remote`, so a leftover desktop env cannot open the host-control socket. On host runtimes, started from `packages/web/server/index.js` when demand/opt-in enables the relay. Desktop auto-clears `privateRelay.enabled` when demand drops; `ssh-remote` keeps an explicit opt-in (e.g. `yuri serve --relay-host`) sticky until disabled. The relay endpoint has no hosted default and must be configured in settings or pinned via the `YURI_RELAY_URL` env var; when set it overrides the stored setting for the host connection, the pairing candidate, and status, so paired clients inherit the endpoint automatically. Endpoint identity is scheme/host/path only: accepted schemes are `ws://` and `wss://`; URLs with userinfo are rejected (no silent default fallback); query and fragment are stripped before persistence and pairing candidates. Custom endpoint persistence and Host control-connection switching are explicit authenticated management actions. Pairing creation with `relayUrl` requires an owner UI session, local `desktop-local` shell client, or paired `desktop` operator; `/relay/enable` follows its API auth gate. `derivePushSendUrlFromRelayUrl` maps a canonical Relay `wss://`/`ws://` URL to the same host's `https://`/`http://` `/v1/push/send` path (register is `/v1/push/register-token`); `YURI_PUSH_RELAY_URL` on the Host overrides that derivation. The isolated Push process lives in `packages/relay-server/src/push/` and does not share Layer 1 credentials or tunnel state.
|
|
@@ -39,12 +39,16 @@ import { requestSpeechSession } from '../../../../ui/src/lib/voice/direct-sessio
|
|
|
39
39
|
import { createGuiClient } from '../../../../ui/src/lib/opencode/gui.ts';
|
|
40
40
|
import { createWebFilesAPI } from '../../../src/api/files.ts';
|
|
41
41
|
import { createEventPipeline } from '../../../../ui/src/sync/event-pipeline.ts';
|
|
42
|
+
import { uploadAssistantAttachment } from '../../../../ui/src/lib/assistant-attachment-upload.ts';
|
|
43
|
+
import { registerAssistantRoutes } from '../assistants/routes.js';
|
|
44
|
+
import { registerCommonRequestMiddleware } from '../opencode/core-routes.js';
|
|
42
45
|
|
|
43
46
|
// Web's source aliases are not exported Node package subpaths. Forward them to
|
|
44
47
|
// the real implementations so this Node E2E exercises the same transport singleton.
|
|
45
48
|
vi.mock('@yuriai/ui/lib/runtime-fetch', () => import('../../../../ui/src/lib/runtime-fetch.ts'));
|
|
46
49
|
vi.mock('@yuriai/ui/lib/runtime-file-resource', () => import('../../../../ui/src/lib/runtime-file-resource.ts'));
|
|
47
50
|
vi.mock('@yuriai/ui/lib/runtime-file-download', () => import('../../../../ui/src/lib/runtime-file-download.ts'));
|
|
51
|
+
vi.mock('@yuriai/ui/lib/opencode/client', () => import('../../../../ui/src/lib/opencode/client.ts'));
|
|
48
52
|
|
|
49
53
|
const timeoutMs = 10_000;
|
|
50
54
|
const previewPng = Buffer.from('iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAQAAAC1HAwCAAAAC0lEQVR42mP8/x8AAwMCAO+aD1sAAAAASUVORK5CYII=', 'base64');
|
|
@@ -200,6 +204,16 @@ const startOrigin = async (options: { recoveryEvents?: boolean } = {}) => {
|
|
|
200
204
|
const requestSecurity = createRequestSecurityRuntime({ readSettingsFromDiskMigrated: async () => ({}) });
|
|
201
205
|
const wss = new WebSocketServer({ noServer: true });
|
|
202
206
|
const proxy = express();
|
|
207
|
+
const assistants = express();
|
|
208
|
+
registerCommonRequestMiddleware(assistants, { express });
|
|
209
|
+
const assistantRuntime = registerAssistantRoutes(assistants, {
|
|
210
|
+
dbPath: path.join(mediaDirectory, 'assistants.sqlite'),
|
|
211
|
+
yuriDataDir: mediaDirectory,
|
|
212
|
+
buildOpenCodeUrl: () => 'http://127.0.0.1:1',
|
|
213
|
+
getOpenCodeAuthHeaders: () => ({}),
|
|
214
|
+
getAllowedRoots: () => [mediaDirectory],
|
|
215
|
+
});
|
|
216
|
+
const attachmentAssistant = assistantRuntime.service.createAssistant({ name: 'Relay upload', providerID: 'fixture', modelID: 'fixture' });
|
|
203
217
|
const speech = express();
|
|
204
218
|
speech.use(express.json());
|
|
205
219
|
registerTtsRoutes(speech, { sayTTSCapability: null });
|
|
@@ -260,6 +274,10 @@ const startOrigin = async (options: { recoveryEvents?: boolean } = {}) => {
|
|
|
260
274
|
});
|
|
261
275
|
return;
|
|
262
276
|
}
|
|
277
|
+
if (pathname.startsWith('/api/yuri/assistants/')) {
|
|
278
|
+
await uiAuth.requireAuth(req, res, () => assistants(req, rawRes));
|
|
279
|
+
return;
|
|
280
|
+
}
|
|
263
281
|
if (pathname === '/api/e2e/initialization' && req.method === 'GET') {
|
|
264
282
|
await uiAuth.requireAuth(req, res, () => res.json(initializationSnapshot));
|
|
265
283
|
return;
|
|
@@ -348,9 +366,10 @@ const startOrigin = async (options: { recoveryEvents?: boolean } = {}) => {
|
|
|
348
366
|
await new Promise<void>((resolve) => server.listen(0, '127.0.0.1', resolve));
|
|
349
367
|
const port = (server.address() as net.AddressInfo).port;
|
|
350
368
|
return {
|
|
351
|
-
port, videoPath, previewPath, previewContent, guiBundle, pluginInventory, guiRequests, bearerRequests, observedOrigins, getHostSubscriptions: () => hostSubscriptions,
|
|
369
|
+
port, videoPath, previewPath, previewContent, guiBundle, pluginInventory, guiRequests, bearerRequests, observedOrigins, attachmentAssistant, getHostSubscriptions: () => hostSubscriptions,
|
|
352
370
|
advanceRecoveryRevision: () => { recoveryRevision += 1; return `ses_recovery_${recoveryRevision}`; },
|
|
353
371
|
stop: async () => {
|
|
372
|
+
assistantRuntime.close();
|
|
354
373
|
dictation.stop();
|
|
355
374
|
for (const client of wss.clients) client.terminate();
|
|
356
375
|
for (const socket of sockets) socket.destroy();
|
|
@@ -493,6 +512,56 @@ describe('private relay compiled-process boundary', () => {
|
|
|
493
512
|
socket.close();
|
|
494
513
|
});
|
|
495
514
|
|
|
515
|
+
it.skipIf(!process.env.YURI_RELAY_WORKER_TEST_URL)('carries real encrypted Host/Client HTTP, SSE and authenticated WebSockets across Workers', { timeout: 30_000 }, async () => {
|
|
516
|
+
const relayUrl = process.env.YURI_RELAY_WORKER_TEST_URL;
|
|
517
|
+
if (!relayUrl) throw new Error('Worker test endpoint required');
|
|
518
|
+
const temp = await mkdtemp(path.join(os.tmpdir(), 'yuri-worker-e2e-'));
|
|
519
|
+
vi.stubEnv('YURI_DATA_DIR', temp);
|
|
520
|
+
let origin: Awaited<ReturnType<typeof startOrigin>> | undefined;
|
|
521
|
+
let host: ReturnType<typeof startRelayHost> | undefined;
|
|
522
|
+
let client: ReturnType<typeof createRelayTunnelClient> | undefined;
|
|
523
|
+
cleanup = async () => {
|
|
524
|
+
client?.close(); host?.stop(); await origin?.stop();
|
|
525
|
+
await rm(temp, { recursive: true, force: true });
|
|
526
|
+
};
|
|
527
|
+
origin = await startOrigin();
|
|
528
|
+
const identity = await buildIdentity();
|
|
529
|
+
host = startRelayHost({ relayUrl, identity, getLocalPort: () => origin!.port,
|
|
530
|
+
batchWindowMs: 5, onStatus() {}, logger: { warn() {}, info() {} } });
|
|
531
|
+
client = createRelayTunnelClient({ relayUrl, serverId: identity.serverId, hostEncPubJwk: identity.hostEncPubJwk,
|
|
532
|
+
batchWindowMs: 5, helloRetryMs: 50 });
|
|
533
|
+
await eventually(() => host!.getStatus().state === 'connected' && client!.getStatus().state === 'connected', 'Worker E2EE tunnel did not connect');
|
|
534
|
+
|
|
535
|
+
expect((await client.fetch('/api/event')).status).toBe(401);
|
|
536
|
+
const headers = { authorization: 'Bearer client-token' };
|
|
537
|
+
const httpResponse = await client.fetch('/api/e2e/http', { method: 'POST', headers, body: 'worker-stream-body' });
|
|
538
|
+
expect(await httpResponse.json()).toEqual({ body: 'worker-stream-body', hasRelayConnection: true });
|
|
539
|
+
const snapshot = await client.fetch('/api/e2e/initialization', { headers });
|
|
540
|
+
expect(await snapshot.json()).toEqual(initializationSnapshot);
|
|
541
|
+
const sse = await client.fetch('/api/e2e/sse', { headers });
|
|
542
|
+
const reader = sse.body!.getReader(); const chunks: Uint8Array[] = [];
|
|
543
|
+
while (true) { const item = await reader.read(); if (item.done) break; chunks.push(item.value); }
|
|
544
|
+
expect(chunks.length).toBeGreaterThan(1);
|
|
545
|
+
expect(Buffer.concat(chunks).toString()).toBe('data: one\n\ndata: two\n\ndata: three\n\n');
|
|
546
|
+
|
|
547
|
+
const denied = client.openWebSocket('/api/remote-desktop/ws');
|
|
548
|
+
await expect(waitSocketOpen(denied)).rejects.toThrow();
|
|
549
|
+
const tokenResponse = await client.fetch('/auth/url-token', { method: 'POST', headers });
|
|
550
|
+
const { token } = await tokenResponse.json() as { token: string };
|
|
551
|
+
const socket = client.openWebSocket(`/api/remote-desktop/ws?yuri_url_token=${encodeURIComponent(token)}`);
|
|
552
|
+
await waitSocketOpen(socket);
|
|
553
|
+
const messages: Array<string | ArrayBuffer> = [];
|
|
554
|
+
socket.onmessage = ({ data }) => { messages.push(data); };
|
|
555
|
+
for (let index = 0; index < 50; index += 1) socket.send(`input:${index}`);
|
|
556
|
+
const image = new Uint8Array(1024 * 1024).fill(7);
|
|
557
|
+
socket.send(image); image.fill(0);
|
|
558
|
+
await eventually(() => messages.length === 51, 'Worker dropped or reordered encrypted remote desktop frames');
|
|
559
|
+
expect(messages.slice(0, 50)).toEqual(Array.from({ length: 50 }, (_, index) => `input:${index}`));
|
|
560
|
+
expect(new Uint8Array(messages[50] as ArrayBuffer)).toEqual(new Uint8Array(1024 * 1024).fill(7));
|
|
561
|
+
expect(origin.observedOrigins).toEqual([`http://127.0.0.1:${origin.port}`]);
|
|
562
|
+
socket.close();
|
|
563
|
+
});
|
|
564
|
+
|
|
496
565
|
it('recovers HTTP and the retained SDK event pipeline after phone, Host, and combined disconnects', { timeout: 60_000 }, async () => {
|
|
497
566
|
const temp = await mkdtemp(path.join(os.tmpdir(), 'yuri-relay-recovery-'));
|
|
498
567
|
const binary = path.join(temp, 'yuri-relay');
|
|
@@ -749,6 +818,38 @@ describe('private relay compiled-process boundary', () => {
|
|
|
749
818
|
adoptRelayTunnel({ relayUrl: relay.url, serverId: identity.serverId, hostEncPubJwk: identity.hostEncPubJwk }, client);
|
|
750
819
|
vi.stubGlobal('window', { location: new URL('https://relay-runtime.example'), addEventListener() {}, removeEventListener() {} });
|
|
751
820
|
try {
|
|
821
|
+
const assistantID = origin.attachmentAssistant.id;
|
|
822
|
+
const uploadPath = `/api/yuri/assistants/${assistantID}/contact/attachments`;
|
|
823
|
+
for (const headers of [{}, { authorization: 'Bearer invalid-token' }]) {
|
|
824
|
+
expect((await client.fetch(`${uploadPath}/denied`, { method: 'PUT', headers, body: previewPng })).status).toBe(401);
|
|
825
|
+
}
|
|
826
|
+
const attachmentParts: Awaited<ReturnType<typeof uploadAssistantAttachment>>[] = [];
|
|
827
|
+
for (const [index, file] of [
|
|
828
|
+
new File([previewPng], '截图.png', { type: 'image/png' }),
|
|
829
|
+
new File([JSON.stringify({ text: '附件原始字节', padding: 'x'.repeat(128 * 1024) })], '附件.json', { type: 'application/json' }),
|
|
830
|
+
].entries()) {
|
|
831
|
+
const uploadID = `relay-upload-${index}`;
|
|
832
|
+
const descriptor = await uploadAssistantAttachment(assistantID, file, uploadID);
|
|
833
|
+
attachmentParts.push(descriptor);
|
|
834
|
+
expect(descriptor).toMatchObject({
|
|
835
|
+
type: 'file', filename: file.name, mime: file.type, size: file.size,
|
|
836
|
+
sha256: crypto.createHash('sha256').update(Buffer.from(await file.arrayBuffer())).digest('hex'),
|
|
837
|
+
});
|
|
838
|
+
expect(await uploadAssistantAttachment(assistantID, file, uploadID)).toEqual(descriptor);
|
|
839
|
+
const download = await runtimeFetch(`${uploadPath}/${descriptor.attachmentID}`);
|
|
840
|
+
expect(download.status).toBe(200);
|
|
841
|
+
expect(Buffer.from(await download.arrayBuffer())).toEqual(Buffer.from(await file.arrayBuffer()));
|
|
842
|
+
expect((await client.fetch(`${uploadPath}/${descriptor.attachmentID}`)).status).toBe(401);
|
|
843
|
+
}
|
|
844
|
+
const admission = await runtimeFetch(`/api/yuri/assistants/${assistantID}/messages`, {
|
|
845
|
+
method: 'POST', headers: { 'Content-Type': 'application/json' },
|
|
846
|
+
body: JSON.stringify({ messageID: 'relay-attachment-message', parts: [{ type: 'text', text: 'Check these attachments' }, ...attachmentParts] }),
|
|
847
|
+
});
|
|
848
|
+
expect(admission.status, await admission.text()).toBe(202);
|
|
849
|
+
const contactPage = await runtimeFetch(`/api/yuri/assistants/${assistantID}/contact/messages?messageID=relay-attachment-message`);
|
|
850
|
+
expect(contactPage.status).toBe(200);
|
|
851
|
+
const contactJson = await contactPage.text();
|
|
852
|
+
for (const part of attachmentParts) expect(contactJson).toContain(part.attachmentID);
|
|
752
853
|
const gui = createGuiClient(new AbortController().signal);
|
|
753
854
|
const files = createWebFilesAPI({ getDirectory: () => path.dirname(origin.previewPath) });
|
|
754
855
|
expect(Buffer.byteLength(origin.guiBundle.code)).toBeGreaterThan(2_270_000);
|
|
@@ -23,7 +23,7 @@ import express from 'express';
|
|
|
23
23
|
import { createRelayIdentityRuntime } from './identity.js';
|
|
24
24
|
import { startRelayHost } from './host-client.js';
|
|
25
25
|
|
|
26
|
-
export const DEFAULT_RELAY_URL = 'wss://relay.
|
|
26
|
+
export const DEFAULT_RELAY_URL = 'wss://relay.useyuri.top/ws';
|
|
27
27
|
|
|
28
28
|
export const RELAY_HOST_DESKTOP_ONLY_MESSAGE =
|
|
29
29
|
'Relay host is only available in the Yuri desktop app or an SSH-managed remote server';
|
|
@@ -92,7 +92,7 @@ describe('resolveEffectiveRelayUrl', () => {
|
|
|
92
92
|
|
|
93
93
|
it('prefers a valid env URL, then settings, then the default', () => {
|
|
94
94
|
expect(resolveEffectiveRelayUrl()).toBe(PRODUCT_RELAY_URL);
|
|
95
|
-
expect(PRODUCT_RELAY_URL).toBe('wss://relay.
|
|
95
|
+
expect(PRODUCT_RELAY_URL).toBe('wss://relay.useyuri.top/ws');
|
|
96
96
|
expect(
|
|
97
97
|
resolveEffectiveRelayUrl({
|
|
98
98
|
settings: { privateRelay: { relayUrl: 'wss://settings.example/ws' } },
|
|
@@ -138,6 +138,19 @@ describe('relay service pairing endpoint', () => {
|
|
|
138
138
|
expect(relayMocks.stops).toEqual(relayMocks.starts);
|
|
139
139
|
});
|
|
140
140
|
|
|
141
|
+
it('persists the product default for first pairing when no endpoint was saved', async () => {
|
|
142
|
+
const { service, settings } = createTestRelayService();
|
|
143
|
+
await settings.write({});
|
|
144
|
+
try {
|
|
145
|
+
const candidate = await service.ensureEnabledForPairing();
|
|
146
|
+
expect(candidate.relayUrl).toBe(PRODUCT_RELAY_URL);
|
|
147
|
+
expect(settings.current()).toMatchObject({ privateRelay: { enabled: true, relayUrl: PRODUCT_RELAY_URL } });
|
|
148
|
+
expect(relayMocks.starts).toEqual([PRODUCT_RELAY_URL]);
|
|
149
|
+
} finally {
|
|
150
|
+
service.stop();
|
|
151
|
+
}
|
|
152
|
+
});
|
|
153
|
+
|
|
141
154
|
it('appends a new pairing endpoint (multi-relay) while keeping the primary', async () => {
|
|
142
155
|
const { service, settings } = createTestRelayService();
|
|
143
156
|
|
|
@@ -4,7 +4,7 @@ export const applyRuntimeCorsHeaders = ({ origin, setHeader }) => {
|
|
|
4
4
|
setHeader('Access-Control-Allow-Origin', origin);
|
|
5
5
|
setHeader('Access-Control-Allow-Credentials', 'true');
|
|
6
6
|
setHeader('Access-Control-Allow-Methods', 'GET,POST,PUT,PATCH,DELETE,OPTIONS');
|
|
7
|
-
setHeader('Access-Control-Allow-Headers', 'Content-Type,Authorization,Accept,X-Requested-With,Cache-Control,X-OpenCode-Directory,X-OpenCode-Directory-Encoding,X-Message-Queue-Upload-Token,X-Message-Queue-Sha256,X-Message-Queue-Content-Length,X-Yuri-Content-Length,X-Yuri-Sha256,X-Yuri-Mime,X-Yuri-Filename,X-Yuri-Gui-Revision');
|
|
7
|
+
setHeader('Access-Control-Allow-Headers', 'Content-Type,Authorization,Accept,X-Requested-With,Cache-Control,X-OpenCode-Directory,X-OpenCode-Directory-Encoding,X-Message-Queue-Upload-Token,X-Message-Queue-Sha256,X-Message-Queue-Content-Length,X-Yuri-Content-Length,X-Yuri-Sha256,X-Yuri-Mime,X-Yuri-Filename,X-Yuri-Gui-Revision,X-Content-SHA256,X-Content-Size,X-Attachment-Filename');
|
|
8
8
|
// Packaged clients (Electron yuri-ui://app, Capacitor, Vite HMR) are
|
|
9
9
|
// cross-origin to the runtime API. Without an expose list, browsers hide
|
|
10
10
|
// custom response headers from JS — including the optional-read existence
|
|
@@ -1,8 +1,20 @@
|
|
|
1
|
-
import { describe, expect, it } from '
|
|
1
|
+
import { describe, expect, it } from 'vitest';
|
|
2
2
|
|
|
3
3
|
import { applyRuntimeCorsHeaders } from './request-cors.js';
|
|
4
4
|
|
|
5
5
|
describe('applyRuntimeCorsHeaders', () => {
|
|
6
|
+
it.each(['yuri-ui://app', 'capacitor://localhost', 'http://localhost:5180'])(
|
|
7
|
+
'allows assistant attachment upload preflights from %s', (origin) => {
|
|
8
|
+
const headers = new Map();
|
|
9
|
+
applyRuntimeCorsHeaders({ origin, setHeader: (name, value) => headers.set(name, value) });
|
|
10
|
+
const allowed = headers.get('Access-Control-Allow-Headers').toLowerCase().split(',').map((name) => name.trim());
|
|
11
|
+
expect(headers.get('Access-Control-Allow-Methods').split(',')).toContain('PUT');
|
|
12
|
+
for (const name of ['content-type', 'authorization', 'x-content-sha256', 'x-content-size', 'x-attachment-filename']) {
|
|
13
|
+
expect(allowed, `Browser blocks assistant attachment upload header: ${name}`).toContain(name);
|
|
14
|
+
}
|
|
15
|
+
},
|
|
16
|
+
);
|
|
17
|
+
|
|
6
18
|
it('gives packaged clients a reusable preflight cache window', () => {
|
|
7
19
|
const headers = new Map();
|
|
8
20
|
applyRuntimeCorsHeaders({
|
|
@@ -41,6 +41,9 @@ synthetic `session.updated` so the loop can arm.
|
|
|
41
41
|
|
|
42
42
|
## Goal payload (`metadata.yuri.goal`)
|
|
43
43
|
|
|
44
|
+
Live activity reads the V2 `session.active` client only. A failed active-session
|
|
45
|
+
read remains unknown; it never calls the removed session-status endpoint.
|
|
46
|
+
|
|
44
47
|
```
|
|
45
48
|
{
|
|
46
49
|
id, // opaque per-logical-goal id; stale-write guard
|
|
@@ -825,10 +825,6 @@ export const createSessionGoalRuntime = ({
|
|
|
825
825
|
} catch {
|
|
826
826
|
// Fall through.
|
|
827
827
|
}
|
|
828
|
-
const statusMap = await openCodeFetch('/session/status', { directory }).catch(() => null);
|
|
829
|
-
const status = statusMap?.[sessionId];
|
|
830
|
-
const type = typeof status?.type === 'string' ? status.type.trim() : '';
|
|
831
|
-
if (type === 'idle' || type === 'busy' || type === 'retry') return type;
|
|
832
828
|
return null;
|
|
833
829
|
};
|
|
834
830
|
|
|
@@ -61,8 +61,17 @@ Rows are partitioned by a runtime key derived from the desktop
|
|
|
61
61
|
`apiBaseUrl` (Electron falls back to the local sidecar URL so the key stays
|
|
62
62
|
stable between server listen and window activation).
|
|
63
63
|
`service.js` exclusively owns the WAL database and stores at most the
|
|
64
|
-
newest 20 root-session summaries per runtime and directory. It
|
|
65
|
-
|
|
64
|
+
newest 20 root-session summaries per runtime and directory. It also retains the
|
|
65
|
+
minimal session `model: { providerID, id, variant? }` reference (each string is
|
|
66
|
+
bounded to 512 characters), never messages, attachments, permissions, provider
|
|
67
|
+
configuration, or model catalog metadata. Missing/invalid model fields in light
|
|
68
|
+
refreshes preserve the prior reference. Model columns are added transactionally
|
|
69
|
+
without clearing existing summaries, pins or historical synchronization markers.
|
|
70
|
+
Native `session.model.selected` updates only an existing runtime-scoped model
|
|
71
|
+
reference, not activity, directory recency or session ordering. Persisted event
|
|
72
|
+
sequence/clock fences reject stale events and stale list models; exact event
|
|
73
|
+
repeats are write-free. Alias reconciliation retains the newest known model
|
|
74
|
+
independently of title recency. Snapshot and deep-link lookup both expose it.
|
|
66
75
|
Sessions titled `smartfetch-secondary` are temporary SmartFetch model calls;
|
|
67
76
|
the index excludes them from every snapshot and clears prior summaries when a
|
|
68
77
|
matching session update arrives. Reserved leading tags `[Scheduled]`,
|
|
@@ -134,8 +143,13 @@ committed atomically in SQLite under the runtime key; empty success also records
|
|
|
134
143
|
completion. Subsequent launches perform no upstream history reads after completion.
|
|
135
144
|
Failure/shutdown preserves the last committed cursor for retry. Existing summaries
|
|
136
145
|
win over backfill, and normal create/update/archive/delete events maintain the index.
|
|
137
|
-
|
|
138
|
-
|
|
146
|
+
The model-reference generation uses its own completion marker, so older indexes
|
|
147
|
+
receive one bounded 30-day pass without clearing rows or their prior progress
|
|
148
|
+
marker. Backfill fills only missing model references on existing summaries;
|
|
149
|
+
titles, activity and already-known models win over historical reads. Model writes
|
|
150
|
+
and the page cursor commit or roll back together. Older sessions acquire the
|
|
151
|
+
reference through normal explicit directory refreshes. Manual directory refresh
|
|
152
|
+
remains a separate explicit operation; cards never fetch messages to find models.
|
|
139
153
|
|
|
140
154
|
The runtime processes explicit directory refreshes sequentially. OpenCode 2.x list is cursor-only (no
|
|
141
155
|
`start` incremental); each directory fetches active-only pages (`limit=20`)
|
|
@@ -37,6 +37,12 @@ export const applySessionIndexEvent = (service, event, observedAt = Date.now(),
|
|
|
37
37
|
|
|
38
38
|
const baseType = normalizeSessionEventType(payload.type);
|
|
39
39
|
|
|
40
|
+
if (baseType === 'session.model.selected') {
|
|
41
|
+
if (isHostReady && !isHostReady()) return false;
|
|
42
|
+
const data = payload.data ?? properties;
|
|
43
|
+
return service.updateModel(data.sessionID, data.model, payload.created ?? observedAt, payload.durable?.seq);
|
|
44
|
+
}
|
|
45
|
+
|
|
40
46
|
if (baseType === 'session.renamed') {
|
|
41
47
|
if (isHostReady && !isHostReady()) return false;
|
|
42
48
|
const data = payload.data ?? properties;
|
|
@@ -3,6 +3,16 @@ import { describe, expect, it, vi } from 'vitest';
|
|
|
3
3
|
import { applySessionIndexEvent } from './event-ingest.js';
|
|
4
4
|
|
|
5
5
|
describe('session index event ingest', () => {
|
|
6
|
+
it('ingests native model selection through the existing-row mutation and respects Host readiness', () => {
|
|
7
|
+
const service = { updateModel: vi.fn(() => true) };
|
|
8
|
+
const model = { providerID: 'p', id: 'model', variant: 'high' };
|
|
9
|
+
const event = { payload: { type: 'session.model.selected', created: 20, durable: { seq: 5 }, data: { sessionID: 'session', model } } };
|
|
10
|
+
expect(applySessionIndexEvent(service, event, 30, { isHostReady: () => false })).toBe(false);
|
|
11
|
+
expect(service.updateModel).not.toHaveBeenCalled();
|
|
12
|
+
expect(applySessionIndexEvent(service, event, 30)).toBe(true);
|
|
13
|
+
expect(service.updateModel).toHaveBeenCalledWith('session', model, 20, 5);
|
|
14
|
+
});
|
|
15
|
+
|
|
6
16
|
it('ingests native creation, user input and lifecycle without treating shutdown as completion', () => {
|
|
7
17
|
const service = { upsertAndReportChange: vi.fn(() => true), touchActivity: vi.fn(() => true), updateStatus: vi.fn(() => true) };
|
|
8
18
|
const emit = (type, data = {}) => applySessionIndexEvent(service, { directory: '/repo', payload: { type, created: 20, data: { sessionID: 'ses_native', ...data } } }, 30);
|