@yuriai/web 0.2.39-beta.1 → 0.2.39
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/dist/assets/{AgentAvatar-qwoC8op7.js → AgentAvatar-BPihSrmD.js} +1 -1
- package/dist/assets/AssistantConversationSurface-B60CYrok.css +1 -0
- package/dist/assets/AssistantConversationSurface-CjY5PL5-.js +3 -0
- package/dist/assets/{AssistantUnreadBadge-Hnqqug3k.js → AssistantUnreadBadge-Cqm9s7su.js} +1 -1
- package/dist/assets/AssistantView-DQYpQy2m.js +1 -0
- package/dist/assets/{DiagramView-D1g_U1Ve.js → DiagramView-B0BtdArn.js} +1 -1
- package/dist/assets/{FadeInOnReveal-DLWVDmNr.js → FadeInOnReveal-tft8IuZn.js} +1 -1
- package/dist/assets/{GuiPluginPage-DGrpzWyU.js → GuiPluginPage-DbRaxEMz.js} +1 -1
- package/dist/assets/{GuiPluginSurface-CU2-fLdm.js → GuiPluginSurface-slfiNhjw.js} +1 -1
- package/dist/assets/{GuiPluginWindow-Cear_hK6.js → GuiPluginWindow-CncIyWAp.js} +1 -1
- package/dist/assets/{Icon-D6eeecf3.js → Icon-CGEMyGrr.js} +1 -1
- package/dist/assets/{ImageLoadingPlaceholder-BJguSRQf.js → ImageLoadingPlaceholder-DPV84_Pj.js} +1 -1
- package/dist/assets/{LoadingImage-C0ebLsVf.js → LoadingImage-C54k9D10.js} +1 -1
- package/dist/assets/MarkdownRenderer-DBZS1O3m.js +2 -0
- package/dist/assets/{MarkdownRendererImpl-CRMSm9zP.js → MarkdownRendererImpl-QZCYT1B1.js} +1 -1
- package/dist/assets/{MarkstreamRendererImpl-Cz3f0w5O.js → MarkstreamRendererImpl-CH0XdDB8.js} +1 -1
- package/dist/assets/MobileDetailNavigation-doWZ3QnX.js +1 -0
- package/dist/assets/{MobileResizableSheet-CSHVXdcc.js → MobileResizableSheet-DmBfNDpy.js} +1 -1
- package/dist/assets/{MobileShareBridge-CrnmSDpN.js → MobileShareBridge-CCRDZ5at.js} +1 -1
- package/dist/assets/{MobileTabPageHeader-CwAiYIiK.js → MobileTabPageHeader-RIJ0Tv9a.js} +1 -1
- package/dist/assets/{MultiRunWindow-A7FOh3y9.js → MultiRunWindow-FISLdCRZ.js} +1 -1
- package/dist/assets/{OnboardingScreen-C4aWPE5g.js → OnboardingScreen-D4OnZuHF.js} +1 -1
- package/dist/assets/{OverlayScrollbar-BDmFJvuO.js → OverlayScrollbar-B5tpZ8bV.js} +1 -1
- package/dist/assets/{SettingsView-YvxmCurl.js → SettingsView-B9qVD3Y-.js} +6 -6
- package/dist/assets/{SettingsWindow-C6sp5FCT.js → SettingsWindow-DUlTQkFw.js} +1 -1
- package/dist/assets/{SetupTourDialog-DAbtAImS.js → SetupTourDialog-Cfc1h-8p.js} +1 -1
- package/dist/assets/{TerminalView-bFqYE6E8.js → TerminalView-D0nGaGQc.js} +1 -1
- package/dist/assets/{ToolOutputDialog-BfKFoRx6.js → ToolOutputDialog-RBSVUj7J.js} +1 -1
- package/dist/assets/{VoiceSettings-BFJoynNT.js → VoiceSettings-B6L3hyGL.js} +1 -1
- package/dist/assets/{YuriLogo-DcoYyXzq.js → YuriLogo-B58GIl2v.js} +1 -1
- package/dist/assets/{YuriWordmark-Dlsq3scd.js → YuriWordmark--S-QEpRp.js} +1 -1
- package/dist/assets/{appThemeRegistry-DzF1KyRO.js → appThemeRegistry-CvThoPJW.js} +1 -1
- package/dist/assets/{capgoAdapter-DomoN2dQ.js → capgoAdapter-Bj8RLSP5.js} +1 -1
- package/dist/assets/{checkbox-ClSxDwlM.js → checkbox-CnTrXcOT.js} +1 -1
- package/dist/assets/{collapsible-Dhf2eN1l.js → collapsible-Brxkw3Ad.js} +1 -1
- package/dist/assets/{context-menu-DQz7Hocu.js → context-menu-V40RXF6h.js} +1 -1
- package/dist/assets/{diagram-BaIvxWpH.js → diagram-DmtDqCEH.js} +1 -1
- package/dist/assets/{dialog-B1Rrafoy.js → dialog-wNy9dklb.js} +1 -1
- package/dist/assets/{es-30Wqm-Bx.js → es-D0Q_CV0t.js} +1 -1
- package/dist/assets/{fileMentionTouchSelection-CUUCXrKA.js → fileMentionTouchSelection-B35c9M1S.js} +1 -1
- package/dist/assets/{fileReferenceActions-BRF8f7uA.js → fileReferenceActions-BmquJskG.js} +1 -1
- package/dist/assets/{fr-BbWLXNYa.js → fr-DrO5SAKl.js} +1 -1
- package/dist/assets/{gitApi-L3nS1oNJ.js → gitApi-B6T5guw-.js} +1 -1
- package/dist/assets/{gitApiHttp-B1mApXwC.js → gitApiHttp-D4d-rgcR.js} +1 -1
- package/dist/assets/{i18n-BU14awhU.js → i18n-UaLestuf.js} +1 -1
- package/dist/assets/{image-loading-D9Z_BASK.css → image-loading-DA9JEHD8.css} +1 -1
- package/dist/assets/{input-el2PLKbt.js → input-DKLf8ixL.js} +1 -1
- package/dist/assets/{insertionBoundaries-DyPQrOsg.js → insertionBoundaries-BT7QMdXR.js} +1 -1
- package/dist/assets/{ja-BI7m9bgW.js → ja-BNeP9_GU.js} +1 -1
- package/dist/assets/{ko-B89SVFZa.js → ko-DRRFD_7l.js} +1 -1
- package/dist/assets/{main-BPnfMzuY.js → main-Bto3lVGC.js} +2 -2
- package/dist/assets/{main-5mNQIc25.js → main-wQpnkA8l.js} +21 -21
- package/dist/assets/{markdownHeightCache-DUGTouXi.js → markdownHeightCache-CDLGxKMx.js} +1 -1
- package/dist/assets/{mcpQueries-B2gQBmMk.js → mcpQueries-W4pdjGH6.js} +1 -1
- package/dist/assets/{miniChat-DkaYsaSY.js → miniChat-5-Hv0t6L.js} +2 -2
- package/dist/assets/mobile-CIfJVgvD.js +2 -0
- package/dist/assets/{mobileBackNavigation-CXTWT9pL.js → mobileBackNavigation-DEYDDBvo.js} +1 -1
- package/dist/assets/{mobileConnections-NoXReTUi.js → mobileConnections-Ciduwjrk.js} +2 -2
- package/dist/assets/{multirun-DizITQa8.js → multirun-DH5YM6eW.js} +1 -1
- package/dist/assets/{native-config--mmoJe_H.js → native-config-tZKBxKlJ.js} +1 -1
- package/dist/assets/{pl-B55Lf3HE.js → pl-BnW5wJrl.js} +1 -1
- package/dist/assets/{projectMeta-BzvXAJMC.js → projectMeta-ByznasuE.js} +1 -1
- package/dist/assets/{pt-BR-CFZj-ECy.js → pt-BR-fZW8CCVQ.js} +1 -1
- package/dist/assets/pwa-6LwD5mEU.js +2 -0
- package/dist/assets/{queue-abort-optimistic-BZ-uX9Xl.js → queue-abort-optimistic-BxQHPU5z.js} +1 -1
- package/dist/assets/{react-CnKEwma7.js → react-KWIP7CQs.js} +1 -1
- package/dist/assets/readiness-aRoinILZ.js +2 -0
- package/dist/assets/{renderElectronMiniChatApp-CGDnFkRT.js → renderElectronMiniChatApp-CZScT8zj.js} +2 -2
- package/dist/assets/renderMobileApp-DuXuzELH.js +29 -0
- package/dist/assets/{runtimeConfig-CBsnA3T3.js → runtimeConfig-D6tyDSf2.js} +1 -1
- package/dist/assets/runtimeEndpointReset-BOdd_mJM.css +1 -0
- package/dist/assets/{runtimeEndpointReset-Co74Bqfs.js → runtimeEndpointReset-CTScNTQk.js} +15 -15
- package/dist/assets/{scheduledTaskNavigation-PH-etFzZ.js → scheduledTaskNavigation-FMDNRUnX.js} +1 -1
- package/dist/assets/{select-Bn8U3CWh.js → select-CM7BZ8sO.js} +1 -1
- package/dist/assets/{sessionLookup-14_73BfN.js → sessionLookup-BU5wx0-q.js} +1 -1
- package/dist/assets/{sortable-tabs-strip-DdP1ALtI.js → sortable-tabs-strip-DucBEuLZ.js} +1 -1
- package/dist/assets/{speechSettingsQueries-D4ZaI_pC.js → speechSettingsQueries-BP-b2-GN.js} +1 -1
- package/dist/assets/src-CCKR0Tmd.css +2 -0
- package/dist/assets/{store-BNNIbb4k.js → store-CzVMz42v.js} +2 -2
- package/dist/assets/{terminalApi-BXKIVBPo.js → terminalApi-DK4KmfFn.js} +1 -1
- package/dist/assets/{textarea-CI1VKA2e.js → textarea-C8G6xLAC.js} +1 -1
- package/dist/assets/{tooltip-Bjzgrs1l.js → tooltip-CeCFnNNR.js} +1 -1
- package/dist/assets/types-Zl9uYRiX.js +2 -0
- package/dist/assets/{uk-CS2c4Dtj.js → uk-C4OKsNRv.js} +1 -1
- package/dist/assets/{useAppFontEffects-DtgrP7dP.js → useAppFontEffects-B2DfbicL.js} +58 -58
- package/dist/assets/{useAssistantUIStore-Du8puXWz.js → useAssistantUIStore-nNYL140o.js} +1 -1
- package/dist/assets/{useDesktopWindowControlsLayout-H91TGqj1.js → useDesktopWindowControlsLayout-CD1Nr6Ms.js} +1 -1
- package/dist/assets/{useDictation-CyWtsxSn.js → useDictation-Sk20Gi0T.js} +1 -1
- package/dist/assets/{useEffectiveDirectory-C_NYC9Sb.js → useEffectiveDirectory-DT950TGk.js} +1 -1
- package/dist/assets/{useFontPreferences-CAdw6cBK.js → useFontPreferences-DxzruDDQ.js} +1 -1
- package/dist/assets/{useMobileNavigationStore-BoZDstLm.js → useMobileNavigationStore-CXnVqWpM.js} +7 -7
- package/dist/assets/{usePluginsStore-B3hliD_2.js → usePluginsStore-DIah6ngo.js} +1 -1
- package/dist/assets/{useStreamingTextThrottle-BA4aJ24a.js → useStreamingTextThrottle-BrP3Yc-q.js} +1 -1
- package/dist/assets/useUIStore-vvNwcOk3.js +1 -0
- package/dist/assets/{useWorkerHighlightedLines-CEl8asH9.js → useWorkerHighlightedLines-tpb9bWVl.js} +1 -1
- package/dist/assets/{zh-CN-BpiwUUs4.js → zh-CN-ieAs59w6.js} +1 -1
- package/dist/assets/{zh-TW-Bl9CnlGi.js → zh-TW-WWTW1fkP.js} +1 -1
- package/dist/index.html +9 -9
- package/dist/mini-chat.html +9 -9
- package/dist/mobile.html +2 -3
- package/package.json +1 -1
- package/server/index.d.ts +6 -0
- package/server/index.js +1 -0
- package/server/lib/config-sync/DOCUMENTATION.md +12 -0
- package/server/lib/config-sync/magpie.js +26 -0
- package/server/lib/config-sync/magpie.test.js +38 -0
- package/server/lib/config-sync/receiver.js +1 -0
- package/server/lib/config-sync/routes.js +5 -0
- package/server/lib/config-sync/routes.test.js +12 -0
- package/server/lib/gui-customization/DOCUMENTATION.md +44 -2
- package/server/lib/gui-customization/remote-connections-client.mjs +65 -0
- package/server/lib/gui-customization/remote-connections.js +43 -0
- package/server/lib/gui-customization/remote-connections.test.js +30 -0
- package/server/lib/gui-customization/session-skill.js +14 -11
- package/server/lib/gui-customization/session-skill.test.js +12 -2
- package/server/lib/gui-customization/skill/SKILL.md +2 -2
- package/server/lib/gui-customization/skill/references/remote-connections.md +30 -0
- package/server/lib/opencode/DOCUMENTATION.md +7 -1
- package/server/lib/opencode/core-routes.js +2 -1
- package/server/lib/opencode/feature-routes-runtime.js +7 -0
- package/server/lib/opencode/feature-routes-runtime.test.js +8 -0
- package/server/lib/scheduled-tasks/session-skill.js +2 -1
- package/server/lib/scheduled-tasks/session-skill.test.js +50 -1
- package/dist/assets/AssistantConversationSurface-BmOHENhF.css +0 -1
- package/dist/assets/AssistantConversationSurface-CyJGN78Z.js +0 -3
- package/dist/assets/AssistantView-CFadOGiW.js +0 -1
- package/dist/assets/MarkdownRenderer-Bibq6sQR.js +0 -2
- package/dist/assets/MobileDetailNavigation-BfTbzw3E.js +0 -1
- package/dist/assets/mobile-B-ZWpOj6.js +0 -2
- package/dist/assets/mobile-html-network-dTGXQKw0.js +0 -2
- package/dist/assets/mobile-network-bridge-B_h92A-9.js +0 -1
- package/dist/assets/pwa-BZGtwuiQ.js +0 -2
- package/dist/assets/readiness-NhPYDe48.js +0 -1
- package/dist/assets/renderMobileApp-DgTlrPpr.js +0 -29
- package/dist/assets/runtimeEndpointReset-6jhYadQt.css +0 -1
- package/dist/assets/src-D-W1MV14.css +0 -2
- package/dist/assets/types-ChrzXO9y.js +0 -2
- package/dist/assets/useUIStore-BF882_0b.js +0 -1
- /package/dist/assets/{image-loading-DEXNCcCm.js → image-loading-BrDob6MW.js} +0 -0
|
@@ -3,6 +3,7 @@ import os from 'node:os';
|
|
|
3
3
|
import path from 'node:path';
|
|
4
4
|
import { spawn } from 'node:child_process';
|
|
5
5
|
import { createHash, randomBytes } from 'node:crypto';
|
|
6
|
+
import { setTimeout as delay } from 'node:timers/promises';
|
|
6
7
|
import { collectMagpieAuth, restoreMagpieAuth, validateMagpieAuth, verifyMagpieAuth } from './magpie-auth.js';
|
|
7
8
|
|
|
8
9
|
const MAX_BYTES = 64 * 1024 * 1024;
|
|
@@ -234,6 +235,31 @@ export function createMagpieSync({
|
|
|
234
235
|
return {
|
|
235
236
|
inventory,
|
|
236
237
|
repairInstallation,
|
|
238
|
+
ensureGateway: () => exclusive(async () => {
|
|
239
|
+
const binary = await ensure();
|
|
240
|
+
const help = await run(binary, ['serve', '--help'], { env, timeout: 10_000 });
|
|
241
|
+
if (!/\bserve\b/.test(help)) throw new Error('Installed Magpie does not support the gateway');
|
|
242
|
+
const healthy = async () => {
|
|
243
|
+
try { await run(binary, ['healthcheck'], { env, timeout: 5_000 }); return true; }
|
|
244
|
+
catch { return false; }
|
|
245
|
+
};
|
|
246
|
+
if (await healthy()) return { ready: true };
|
|
247
|
+
if (platform === 'win32') throw new Error('Automatic Magpie gateway startup requires a POSIX host with tmux');
|
|
248
|
+
let running = false;
|
|
249
|
+
try { await run('tmux', ['has-session', '-t', '=yuri-magpie'], { env, timeout: 5_000 }); running = true; }
|
|
250
|
+
catch { /* Missing sessions are created; existing sessions are never replaced. */ }
|
|
251
|
+
if (!running) {
|
|
252
|
+
const quoted = `'${binary.replaceAll("'", "'\\''")}'`;
|
|
253
|
+
const environment = ['HOME', 'XDG_CONFIG_HOME'].filter((key) => typeof env[key] === 'string')
|
|
254
|
+
.flatMap((key) => ['-e', `${key}=${env[key]}`]);
|
|
255
|
+
await run('tmux', ['new-session', '-d', '-s', 'yuri-magpie', ...environment, `${quoted} serve`], { env, timeout: 10_000 });
|
|
256
|
+
}
|
|
257
|
+
for (let attempt = 0; attempt < 20; attempt++) {
|
|
258
|
+
if (await healthy()) return { ready: true };
|
|
259
|
+
await delay(250);
|
|
260
|
+
}
|
|
261
|
+
throw new Error('Magpie gateway did not become healthy; check the yuri-magpie tmux session');
|
|
262
|
+
}),
|
|
237
263
|
download: () => exclusive(async () => {
|
|
238
264
|
if (!(await inventory()).available) throw new Error('No Magpie configuration found on source');
|
|
239
265
|
const binary = await ensure();
|
|
@@ -23,6 +23,44 @@ const write = async (file, content = '{}') => {
|
|
|
23
23
|
afterEach(async () => { await Promise.all(dirs.splice(0).map((dir) => fs.rm(dir, { recursive: true, force: true }))); });
|
|
24
24
|
|
|
25
25
|
describe('Magpie discovery and native transfer', () => {
|
|
26
|
+
it.each([true, false])('upserts a headless gateway, reusing healthy processes: %s', async (alreadyHealthy) => {
|
|
27
|
+
const { home, options } = await machine();
|
|
28
|
+
await write(path.join(home, '.local/bin/magpie'), 'fixture');
|
|
29
|
+
let healthy = alreadyHealthy;
|
|
30
|
+
const run = vi.fn(async (binary, args) => {
|
|
31
|
+
if (args[0] === '--version') return 'magpie 0.1.0';
|
|
32
|
+
if (args[0] === 'serve') return 'magpie serve — gateway';
|
|
33
|
+
if (args[0] === 'healthcheck') { if (!healthy) throw new Error('offline'); return ''; }
|
|
34
|
+
expect(binary).toBe('tmux');
|
|
35
|
+
if (args[0] === 'has-session') throw new Error('missing');
|
|
36
|
+
expect(args.slice(0, 4)).toEqual(['new-session', '-d', '-s', 'yuri-magpie']);
|
|
37
|
+
expect(args.at(-1)).toContain('magpie\' serve');
|
|
38
|
+
expect(args).toContain(`XDG_CONFIG_HOME=${options.env.XDG_CONFIG_HOME}`);
|
|
39
|
+
healthy = true;
|
|
40
|
+
return '';
|
|
41
|
+
});
|
|
42
|
+
const sync = createMagpieSync({ ...options, run });
|
|
43
|
+
expect(await sync.ensureGateway()).toEqual({ ready: true });
|
|
44
|
+
expect(await sync.ensureGateway()).toEqual({ ready: true });
|
|
45
|
+
expect(run.mock.calls.filter(([binary]) => binary === 'tmux')).toHaveLength(alreadyHealthy ? 0 : 2);
|
|
46
|
+
});
|
|
47
|
+
|
|
48
|
+
it('never replaces an existing tmux gateway and refuses unsupported CLI server capability', async () => {
|
|
49
|
+
const { home, options } = await machine();
|
|
50
|
+
await write(path.join(home, '.local/bin/magpie'), 'fixture');
|
|
51
|
+
let checks = 0;
|
|
52
|
+
const run = vi.fn(async (_binary, args) => {
|
|
53
|
+
if (args[0] === '--version') return 'magpie 0.1.0';
|
|
54
|
+
if (args[0] === 'serve') return 'magpie serve';
|
|
55
|
+
if (args[0] === 'healthcheck' && checks++ === 0) throw new Error('starting');
|
|
56
|
+
return '';
|
|
57
|
+
});
|
|
58
|
+
expect(await createMagpieSync({ ...options, run }).ensureGateway()).toEqual({ ready: true });
|
|
59
|
+
expect(run.mock.calls.some(([, args]) => args[0] === 'new-session')).toBe(false);
|
|
60
|
+
const old = vi.fn(async (_binary, args) => args[0] === '--version' ? 'magpie 0.0.1' : 'old CLI');
|
|
61
|
+
await expect(createMagpieSync({ ...options, run: old }).ensureGateway()).rejects.toThrow('does not support');
|
|
62
|
+
});
|
|
63
|
+
|
|
26
64
|
it('recovers accounts JSON when plugin diagnostics precede the array on merged streams', () => {
|
|
27
65
|
expect(parseMagpieAccountsJson('2026/10/28 10:45:30 plugin [error]: Grok is not signed in\n[{"agent":"cursor","user":"a@example.invalid"}]'))
|
|
28
66
|
.toEqual([{ agent: 'cursor', user: 'a@example.invalid' }]);
|
|
@@ -275,6 +275,7 @@ export const createConfigSyncReceiver = (deps = {}) => {
|
|
|
275
275
|
buildInventory,
|
|
276
276
|
credentialInventory: () => credentials.inventory(),
|
|
277
277
|
magpieInventory: () => magpie.inventory(),
|
|
278
|
+
ensureMagpieGateway: () => magpie.ensureGateway(),
|
|
278
279
|
importMagpie: async (stream) => magpie.import(await readStreamToBuffer(stream, { maxBytes: OPENCODE_CONFIG_SYNC_MAX_BYTES })),
|
|
279
280
|
importCredentials: async (stream) => credentials.import(await readStreamToBuffer(stream, { maxBytes: OPENCODE_CONFIG_SYNC_MAX_BYTES })),
|
|
280
281
|
};
|
|
@@ -84,6 +84,11 @@ export const registerConfigSyncRoutes = (app, deps = {}) => {
|
|
|
84
84
|
catch (error) { sendError(res, error); }
|
|
85
85
|
});
|
|
86
86
|
|
|
87
|
+
app.post('/api/yuri/config-sync/magpie/gateway', async (_req, res) => {
|
|
88
|
+
try { res.json(await receiver.ensureMagpieGateway()); }
|
|
89
|
+
catch { res.status(503).json({ code: 'magpie_gateway_failed', error: 'Magpie gateway could not be prepared' }); }
|
|
90
|
+
});
|
|
91
|
+
|
|
87
92
|
app.get('/api/yuri/config-sync/credentials/inventory', async (_req, res) => {
|
|
88
93
|
try { res.json({ providerCredentials: await receiver.credentialInventory() }); }
|
|
89
94
|
catch (error) { sendError(res, error); }
|
|
@@ -46,6 +46,18 @@ const createApp = async (credentials, magpie) => {
|
|
|
46
46
|
};
|
|
47
47
|
|
|
48
48
|
describe('config-sync HTTP routes', () => {
|
|
49
|
+
it('prepares the headless gateway explicitly and sanitizes failure output', async () => {
|
|
50
|
+
let failed = false;
|
|
51
|
+
const { app } = await createApp(undefined, {
|
|
52
|
+
ensureGateway: async () => { if (failed) throw new Error('private raw child output'); return { ready: true }; },
|
|
53
|
+
});
|
|
54
|
+
expect((await request(app).post('/api/yuri/config-sync/magpie/gateway').expect(200)).body).toEqual({ ready: true });
|
|
55
|
+
failed = true;
|
|
56
|
+
const result = await request(app).post('/api/yuri/config-sync/magpie/gateway').expect(503);
|
|
57
|
+
expect(result.body.code).toBe('magpie_gateway_failed');
|
|
58
|
+
expect(result.text).not.toContain('private raw');
|
|
59
|
+
});
|
|
60
|
+
|
|
49
61
|
it('discovers Magpie without import and requires a selected transfer before finalizing', async () => {
|
|
50
62
|
const payload = Buffer.from('fixture-magpie-payload');
|
|
51
63
|
const received = [];
|
|
@@ -60,7 +60,44 @@ real host. The reference is included in the immutable staged resource inventory.
|
|
|
60
60
|
this Host's filesystem. GUI plugin contracts themselves remain available on
|
|
61
61
|
their supported clients. Existing sessions do not gain the pointer retroactively.
|
|
62
62
|
|
|
63
|
-
|
|
63
|
+
## Remote connection capability
|
|
64
|
+
|
|
65
|
+
The same skill routes SSH/config-sync/Relay requests to `references/remote-connections.md`.
|
|
66
|
+
For shared-service sessions only, an injected Electron `remoteConnectionsAdapter`
|
|
67
|
+
adds a bound helper command to the existing pointer. The immutable inventory also
|
|
68
|
+
stages `remote-connections-client.mjs` as `remote-connections.mjs` only for bound
|
|
69
|
+
sessions; no credential is written into the instructions or helper. Bound and
|
|
70
|
+
unbound resource sets have separate content fingerprints and preparation caches.
|
|
71
|
+
Other admission modes retain the reference, but no executable helper or local
|
|
72
|
+
desktop command. A staged script or another capability's binding is not admission.
|
|
73
|
+
The pointer states this unavailable branch explicitly. The connection reference
|
|
74
|
+
stops on a missing/denied helper instead of falling back to settings/credential
|
|
75
|
+
reads, direct HTTP or source-derived access; successful fallback is not evidence
|
|
76
|
+
that the session capability worked. This is authoring guidance, not an OS sandbox
|
|
77
|
+
for agents that already have local shell access.
|
|
78
|
+
The helper marks HTTP 401/403/501 and unusable bindings as `terminal: true`,
|
|
79
|
+
with a stop/re-admission receipt rather than recommending `list` after an auth
|
|
80
|
+
failure. Other failures return operation-specific recovery. All remote operations
|
|
81
|
+
share the same gate; successful `describe` is the workflow's entry condition.
|
|
82
|
+
|
|
83
|
+
`remote-connections.js` owns `/api/yuri/session-skills/remote-connections`.
|
|
84
|
+
The global API gate and route both require loopback POST, no Origin and the
|
|
85
|
+
shared service Basic credential. The route re-reads the session's admission-owned
|
|
86
|
+
`metadata.yuri.scheduledTaskSkill.hostOrigin` binding before dispatch. This reuses
|
|
87
|
+
the shared-service admission identity, not scheduled-task domain operations.
|
|
88
|
+
Browser bearer/Relay clients cannot use the bridge. There is no generic IPC,
|
|
89
|
+
shell, filesystem, credential-read or settings-write operation. Requests have
|
|
90
|
+
bounded allowlisted input; results contain metadata and explicit one-time pairing
|
|
91
|
+
links, never long-lived credentials or raw upstream errors. Pairing responses and
|
|
92
|
+
all bridge responses use `Cache-Control: no-store`.
|
|
93
|
+
|
|
94
|
+
Electron owns atomic SSH upsert and per-target asynchronous setup; the Host route
|
|
95
|
+
is a narrow dispatcher. Agent callers start each target and poll `list`, so a
|
|
96
|
+
short tool deadline does not strand other targets. Repeated active requests join
|
|
97
|
+
the target operation. Saved instances survive restart; setup receipts do not.
|
|
98
|
+
The pairing operation calls the existing authenticated Host pairing API, never
|
|
99
|
+
writes pairing stores or grants SSH-only connections Relay provenance.
|
|
100
|
+
|
|
64
101
|
Package publishing includes the entire web `server` directory, so the Markdown
|
|
65
102
|
resources ship with the backend and resolve relative to this module in packaged
|
|
66
103
|
Electron as well as web installs. Fingerprinted resources remain readable by old
|
|
@@ -71,7 +108,12 @@ sessions across backend upgrades.
|
|
|
71
108
|
`session-skill.test.js` exercises staging, complete resource availability, short
|
|
72
109
|
per-session pointers, managed admission/rollback/adopted sessions and external
|
|
73
110
|
ownership. Shared-service admission is covered by
|
|
74
|
-
`../scheduled-tasks/session-skill.test.js
|
|
111
|
+
`../scheduled-tasks/session-skill.test.js`, including execution of the exact
|
|
112
|
+
staged remote helper through the real API auth gate and rejection after a Host
|
|
113
|
+
binding change. `remote-connections.test.js` covers unsupported runtimes and
|
|
114
|
+
origin rejection. Electron's `session-connections.test.mjs` covers per-target
|
|
115
|
+
partial failure, active-operation reuse, source selection and pairing payloads;
|
|
116
|
+
Magpie gateway and HTTP tests live in `../config-sync/`. The UI test
|
|
75
117
|
`packages/ui/src/lib/gui-plugins/skill-examples.test.ts` transpiles the shipped
|
|
76
118
|
global-page and custom-file templates and runs them through the real GUI host,
|
|
77
119
|
plugin context, navigation, file read, mount and cleanup. These are contract
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
import { readFile } from 'node:fs/promises';
|
|
2
|
+
import { realpathSync } from 'node:fs';
|
|
3
|
+
import { pathToFileURL } from 'node:url';
|
|
4
|
+
|
|
5
|
+
export const remoteConnectionsCommand = (executable, script, encoded, operation) => {
|
|
6
|
+
const args = [executable, script, encoded, operation];
|
|
7
|
+
const quote = (value) => `'${String(value).replaceAll("'", "'\\''")}'`;
|
|
8
|
+
if (process.platform !== 'win32') return `ELECTRON_RUN_AS_NODE=1 ${args.map(quote).join(' ')}`;
|
|
9
|
+
const psQuote = (value) => `'${String(value).replaceAll("'", "''")}'`;
|
|
10
|
+
const ps = `$env:ELECTRON_RUN_AS_NODE='1'; & ${args.map(psQuote).join(' ')}`;
|
|
11
|
+
return `powershell.exe -NoProfile -NonInteractive -WindowStyle Hidden -EncodedCommand ${Buffer.from(ps, 'utf16le').toString('base64')}`;
|
|
12
|
+
};
|
|
13
|
+
|
|
14
|
+
async function main() {
|
|
15
|
+
try {
|
|
16
|
+
const [encoded, operation] = process.argv.slice(2);
|
|
17
|
+
const binding = JSON.parse(Buffer.from(encoded, 'base64url').toString());
|
|
18
|
+
if (!['describe', 'list', 'setup', 'pair'].includes(operation)) throw new Error();
|
|
19
|
+
const origin = new URL(binding.hostOrigin);
|
|
20
|
+
if (origin.protocol !== 'http:' || !['127.0.0.1', '[::1]'].includes(origin.hostname) || origin.username || origin.password) throw new Error();
|
|
21
|
+
const registration = JSON.parse(await readFile(binding.registrationFile, 'utf8'));
|
|
22
|
+
if (new URL(registration.url).origin !== binding.upstreamOrigin || typeof registration.password !== 'string' || !registration.password) throw new Error();
|
|
23
|
+
let input = {};
|
|
24
|
+
if (operation === 'setup' || operation === 'pair') {
|
|
25
|
+
let text = '';
|
|
26
|
+
for await (const chunk of process.stdin) {
|
|
27
|
+
text += chunk;
|
|
28
|
+
if (Buffer.byteLength(text) > 16 * 1024) throw new Error();
|
|
29
|
+
}
|
|
30
|
+
input = text.trim() ? JSON.parse(text) : {};
|
|
31
|
+
}
|
|
32
|
+
const response = await fetch(new URL('/api/yuri/session-skills/remote-connections', origin), {
|
|
33
|
+
method: 'POST', redirect: 'error', signal: AbortSignal.timeout(operation === 'pair' ? 250_000 : 30_000),
|
|
34
|
+
headers: { 'content-type': 'application/json', authorization: `Basic ${Buffer.from(`opencode:${registration.password}`).toString('base64')}` },
|
|
35
|
+
body: JSON.stringify({ sessionID: binding.sessionID, operation, input }),
|
|
36
|
+
});
|
|
37
|
+
const result = await response.json();
|
|
38
|
+
if (!response.ok) {
|
|
39
|
+
const terminal = [401, 403, 501].includes(response.status);
|
|
40
|
+
console.error(JSON.stringify({ error: 'Remote connection operation failed', status: response.status,
|
|
41
|
+
...(['invalid_input', 'instance_not_found', 'external_instance', 'instance_not_ready', 'remote_connection_failed', 'remote_connections_unsupported'].includes(result?.code) ? { code: result.code } : {}),
|
|
42
|
+
terminal,
|
|
43
|
+
recovery: terminal
|
|
44
|
+
? 'Stop this workflow. All operations share this admission gate. Resume only after a supported local desktop session is available and its bound describe command succeeds.'
|
|
45
|
+
: operation === 'setup' ? 'Use the bound list command to check saved instances before retrying setup.'
|
|
46
|
+
: operation === 'pair' ? 'Pairing was not confirmed. Retrying creates a new one-time link.'
|
|
47
|
+
: 'Report the failed check; no authoritative connection list was returned.',
|
|
48
|
+
}));
|
|
49
|
+
process.exitCode = 1;
|
|
50
|
+
return;
|
|
51
|
+
}
|
|
52
|
+
console.log(JSON.stringify(operation === 'describe' ? { ...result,
|
|
53
|
+
commands: Object.fromEntries(['list', 'setup', 'pair'].map((op) => [op, remoteConnectionsCommand(process.execPath, process.argv[1], encoded, op)])),
|
|
54
|
+
} : result));
|
|
55
|
+
} catch {
|
|
56
|
+
console.error(JSON.stringify({ error: 'Bound remote connection helper unavailable; reload a local Yuri session', terminal: true,
|
|
57
|
+
recovery: 'Stop this workflow. Resume with the new session\'s bound describe command; the previous result is unconfirmed.' }));
|
|
58
|
+
process.exitCode = 1;
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
let directEntry = false;
|
|
63
|
+
try { directEntry = Boolean(process.argv[1] && pathToFileURL(realpathSync(process.argv[1])).href === import.meta.url); }
|
|
64
|
+
catch { /* Imports and Electron flags need not name a script. */ }
|
|
65
|
+
if (directEntry) await main();
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import { authorizeScheduledTaskSkillRequest } from '../scheduled-tasks/session-skill-contract.js';
|
|
2
|
+
|
|
3
|
+
export const REMOTE_CONNECTIONS_SKILL_PATH = '/api/yuri/session-skills/remote-connections';
|
|
4
|
+
|
|
5
|
+
const validInput = (operation, input) => {
|
|
6
|
+
if (!input || typeof input !== 'object' || Array.isArray(input)) return false;
|
|
7
|
+
const allowed = operation === 'setup' ? ['id', 'sshCommand', 'nickname'] : operation === 'pair' ? ['id', 'relayUrl', 'label'] : [];
|
|
8
|
+
if (Object.keys(input).some((key) => !allowed.includes(key))) return false;
|
|
9
|
+
if (Object.values(input).some((value) => typeof value !== 'string' || !value.trim() || value.length > 1024 || /[\x00-\x1f]/.test(value))) return false;
|
|
10
|
+
if (operation === 'setup' && (Boolean(input.id) === Boolean(input.sshCommand) || (input.id && input.nickname))) return false;
|
|
11
|
+
if (input.relayUrl) {
|
|
12
|
+
try {
|
|
13
|
+
const url = new URL(input.relayUrl);
|
|
14
|
+
if (!['ws:', 'wss:'].includes(url.protocol) || url.username || url.password || url.search || url.hash) return false;
|
|
15
|
+
} catch { return false; }
|
|
16
|
+
}
|
|
17
|
+
return true;
|
|
18
|
+
};
|
|
19
|
+
|
|
20
|
+
/** Loopback + service credential + admitted-session binding, never browser/native IPC. */
|
|
21
|
+
export function registerRemoteConnectionsSkill(app, { express, adapter, getIsSharedOpenCodeService, getOpenCodeAuthHeaders, createClient }) {
|
|
22
|
+
app.post(REMOTE_CONNECTIONS_SKILL_PATH, express.json({ limit: '16kb' }), async (req, res) => {
|
|
23
|
+
res.setHeader('Cache-Control', 'no-store');
|
|
24
|
+
if (!getIsSharedOpenCodeService() || !authorizeScheduledTaskSkillRequest(req, getOpenCodeAuthHeaders())) return res.status(403).json({ error: 'Forbidden' });
|
|
25
|
+
if (!adapter) return res.status(501).json({ code: 'remote_connections_unsupported', error: 'Requires the local desktop Host' });
|
|
26
|
+
const { sessionID, operation, input = {} } = req.body ?? {};
|
|
27
|
+
if (typeof sessionID !== 'string' || !sessionID || !['describe', 'list', 'setup', 'pair'].includes(operation) || !validInput(operation, input)) return res.status(400).json({ code: 'invalid_input', error: 'Invalid connection input' });
|
|
28
|
+
try {
|
|
29
|
+
const session = await createClient().session.get({ sessionID });
|
|
30
|
+
const hostOrigin = `http://${req.socket.localAddress === '::1' ? '[::1]' : '127.0.0.1'}:${req.socket.localPort}`;
|
|
31
|
+
if (session.metadata?.yuri?.scheduledTaskSkill?.hostOrigin !== hostOrigin) return res.status(403).json({ error: 'Session is not bound to this Host' });
|
|
32
|
+
if (operation === 'describe') return res.json({ supported: true,
|
|
33
|
+
inputs: { setup: '{sshCommand, nickname?} or {id}', pair: '{id?, relayUrl?, label?}; omitted id means this local desktop', list: '{}' },
|
|
34
|
+
completion: 'setup starts asynchronous SSH installation and config sync. Poll list until running=false; phase=ready alone does not confirm sync or Magpie gateway. Warnings mean partial completion.',
|
|
35
|
+
});
|
|
36
|
+
return res.json(await adapter[operation](input));
|
|
37
|
+
} catch (error) {
|
|
38
|
+
const status = { invalid_input: 400, instance_not_found: 404, external_instance: 409, instance_not_ready: 409 }[error?.message];
|
|
39
|
+
if (Number.isInteger(status)) return res.status(status).json({ code: error.message, error: 'Check the connection input or saved instance status' });
|
|
40
|
+
return res.status(503).json({ code: 'remote_connection_failed', error: 'Connection operation unavailable; check saved instance status before retrying' });
|
|
41
|
+
}
|
|
42
|
+
});
|
|
43
|
+
}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { describe, expect, it, vi } from 'vitest';
|
|
2
|
+
import express from 'express';
|
|
3
|
+
import request from 'supertest';
|
|
4
|
+
import { registerRemoteConnectionsSkill, REMOTE_CONNECTIONS_SKILL_PATH } from './remote-connections.js';
|
|
5
|
+
|
|
6
|
+
describe('remote connection bridge availability', () => {
|
|
7
|
+
const auth = { Authorization: `Basic ${Buffer.from('opencode:fixture').toString('base64')}` };
|
|
8
|
+
it.each([true, false])('has no native capability outside a shared desktop: shared=%s', async (shared) => {
|
|
9
|
+
const app = express();
|
|
10
|
+
const createClient = vi.fn();
|
|
11
|
+
registerRemoteConnectionsSkill(app, { express, adapter: null,
|
|
12
|
+
getIsSharedOpenCodeService: () => shared, getOpenCodeAuthHeaders: () => auth, createClient });
|
|
13
|
+
const response = await request(app).post(REMOTE_CONNECTIONS_SKILL_PATH).set(auth).send({ sessionID: 'ses_one', operation: 'list' });
|
|
14
|
+
expect(response.status).toBe(shared ? 501 : 403);
|
|
15
|
+
expect(createClient).not.toHaveBeenCalled();
|
|
16
|
+
});
|
|
17
|
+
|
|
18
|
+
it('never resolves a session or native adapter for a browser-origin request', async () => {
|
|
19
|
+
const app = express();
|
|
20
|
+
const createClient = vi.fn();
|
|
21
|
+
const adapter = { list: vi.fn() };
|
|
22
|
+
registerRemoteConnectionsSkill(app, { express, adapter, getIsSharedOpenCodeService: () => true,
|
|
23
|
+
getOpenCodeAuthHeaders: () => auth, createClient });
|
|
24
|
+
const response = await request(app).post(REMOTE_CONNECTIONS_SKILL_PATH).set(auth)
|
|
25
|
+
.set('Origin', 'http://127.0.0.1').send({ sessionID: 'ses_one', operation: 'list' });
|
|
26
|
+
expect(response.status).toBe(403);
|
|
27
|
+
expect(createClient).not.toHaveBeenCalled();
|
|
28
|
+
expect(adapter.list).not.toHaveBeenCalled();
|
|
29
|
+
});
|
|
30
|
+
});
|
|
@@ -1,32 +1,35 @@
|
|
|
1
1
|
import { readFile, mkdir, writeFile, rename, rm } from 'node:fs/promises';
|
|
2
2
|
import { createHash, randomUUID } from 'node:crypto';
|
|
3
3
|
import path from 'node:path';
|
|
4
|
+
import { remoteConnectionsCommand } from './remote-connections-client.mjs';
|
|
4
5
|
|
|
5
|
-
const files = ['SKILL.md', 'references/appearance.md', 'references/ui-surfaces.md', 'references/plugin-styles.md', 'references/gui-api.md', 'references/workflow.md', 'references/global-pages.md', 'references/work-status.md', 'references/icons.md', 'references/file-previews.md', 'references/preview-exports.md'];
|
|
6
|
+
const files = ['SKILL.md', 'references/appearance.md', 'references/ui-surfaces.md', 'references/plugin-styles.md', 'references/gui-api.md', 'references/workflow.md', 'references/global-pages.md', 'references/work-status.md', 'references/icons.md', 'references/file-previews.md', 'references/preview-exports.md', 'references/remote-connections.md', 'remote-connections.mjs'];
|
|
6
7
|
|
|
7
8
|
/** Stage immutable, shipped instructions; never edit the user's global skills/config. */
|
|
8
9
|
export function createCustomizationSkillInstaller({ yuriDataDir }) {
|
|
9
|
-
|
|
10
|
-
const prepare = () => {
|
|
11
|
-
resources
|
|
12
|
-
const
|
|
10
|
+
const resources = new Map();
|
|
11
|
+
const prepare = (withRemote) => {
|
|
12
|
+
if (!resources.has(withRemote)) resources.set(withRemote, (async () => {
|
|
13
|
+
const stagedFiles = withRemote ? files : files.filter((name) => name !== 'remote-connections.mjs');
|
|
14
|
+
const contents = await Promise.all(stagedFiles.map((name) => readFile(new URL(name === 'remote-connections.mjs' ? './remote-connections-client.mjs' : `./skill/${name}`, import.meta.url), 'utf8')));
|
|
13
15
|
const hash = createHash('sha256').update(contents.join('\0')).digest('hex').slice(0, 16);
|
|
14
16
|
const directory = path.join(yuriDataDir, 'session-skills', `yuri-customization-${hash}`);
|
|
15
17
|
await mkdir(path.join(directory, 'references'), { recursive: true, mode: 0o700 });
|
|
16
|
-
await Promise.all(
|
|
18
|
+
await Promise.all(stagedFiles.map(async (name, index) => {
|
|
17
19
|
const target = path.join(directory, name);
|
|
18
20
|
const temporary = `${target}.${randomUUID()}.tmp`;
|
|
19
21
|
try { await writeFile(temporary, contents[index], { mode: 0o600 }); await rename(temporary, target); }
|
|
20
22
|
finally { await rm(temporary, { force: true }); }
|
|
21
23
|
}));
|
|
22
24
|
return path.join(directory, 'SKILL.md');
|
|
23
|
-
})().catch((error) => { resources
|
|
24
|
-
return resources;
|
|
25
|
+
})().catch((error) => { resources.delete(withRemote); throw error; }));
|
|
26
|
+
return resources.get(withRemote);
|
|
25
27
|
};
|
|
26
|
-
return async (client, sessionID) => {
|
|
27
|
-
const file = await prepare();
|
|
28
|
+
return async (client, sessionID, remoteBinding) => {
|
|
29
|
+
const file = await prepare(Boolean(remoteBinding));
|
|
30
|
+
const remote = remoteBinding ? ` For SSH setup/config sync or Relay pairing, use only this bound helper after reading references/remote-connections.md. Bound local desktop helper: ${remoteConnectionsCommand(process.execPath, path.join(path.dirname(file), 'remote-connections.mjs'), Buffer.from(JSON.stringify({ ...remoteBinding, sessionID })).toString('base64url'), 'describe')}` : ' No bound SSH/Relay command is provided: these operations are unavailable in this session. Report that limit and stop this branch; use native Settings or a new supported local desktop session. A script or another capability\'s binding does not enable it. There is no credential/filesystem fallback for this capability.';
|
|
28
31
|
await client.session.instructions.entry.put({ sessionID, key: 'yuri.customization',
|
|
29
|
-
value: `Yuri customization: for appearance (themes, CSS/layout, Logo, macOS Dock), work-status widgets, global pages/tabs, custom file parsing/previews, preview exports, or GUI panels/commands/settings, read ${JSON.stringify(file)}
|
|
32
|
+
value: `Yuri customization: for SSH connections, configuration sync, Relay pairing, appearance (themes, CSS/layout, Logo, macOS Dock), work-status widgets, global pages/tabs, custom file parsing/previews, preview exports, or GUI panels/commands/settings, read ${JSON.stringify(file)} first. Use the matching reference and apply changes only when requested.${remote}`,
|
|
30
33
|
});
|
|
31
34
|
};
|
|
32
35
|
}
|
|
@@ -21,13 +21,23 @@ describe('built-in customization instructions', () => {
|
|
|
21
21
|
const entry = put.mock.calls[0][0];
|
|
22
22
|
expect(entry).toMatchObject({ sessionID: 'ses_one', key: 'yuri.customization' });
|
|
23
23
|
expect(entry.value.length).toBeLessThan(1500);
|
|
24
|
-
const file = JSON.parse(entry.value.match(/read (".*?")
|
|
24
|
+
const file = JSON.parse(entry.value.match(/read (".*?") first/)[1]);
|
|
25
25
|
expect(await fs.readFile(file, 'utf8')).toContain('name: yuri-customization');
|
|
26
|
-
for (const name of ['appearance', 'ui-surfaces', 'plugin-styles', 'gui-api', 'workflow', 'global-pages', 'work-status', 'icons', 'file-previews', 'preview-exports']) expect((await fs.readFile(path.join(path.dirname(file), 'references', `${name}.md`), 'utf8')).length).toBeGreaterThan(500);
|
|
26
|
+
for (const name of ['appearance', 'ui-surfaces', 'plugin-styles', 'gui-api', 'workflow', 'global-pages', 'work-status', 'icons', 'file-previews', 'preview-exports', 'remote-connections']) expect((await fs.readFile(path.join(path.dirname(file), 'references', `${name}.md`), 'utf8')).length).toBeGreaterThan(500);
|
|
27
|
+
expect(entry.value).not.toContain('Bound local desktop helper');
|
|
28
|
+
expect(entry.value).toContain('No bound SSH/Relay command is provided');
|
|
29
|
+
expect(entry.value).toContain('There is no credential/filesystem fallback');
|
|
30
|
+
await expect(fs.stat(path.join(path.dirname(file), 'remote-connections.mjs'))).rejects.toMatchObject({ code: 'ENOENT' });
|
|
27
31
|
expect(await fs.readFile(file, 'utf8')).toContain('(references/icons.md)');
|
|
28
32
|
expect(await fs.readFile(path.join(path.dirname(file), 'references', 'global-pages.md'), 'utf8')).toContain('(icons.md)');
|
|
29
33
|
expect(await fs.readFile(path.join(path.dirname(file), 'references', 'appearance.md'), 'utf8')).toContain('yuri.branding');
|
|
30
34
|
expect(put.mock.calls[1][0].value).toBe(entry.value);
|
|
35
|
+
await install(client, 'ses_bound', { hostOrigin: 'http://127.0.0.1:4000', upstreamOrigin: 'http://127.0.0.1:4096', registrationFile: path.join(root, 'service.json') });
|
|
36
|
+
const bound = put.mock.calls[2][0].value;
|
|
37
|
+
const boundFile = JSON.parse(bound.match(/read (".*?") first/)[1]);
|
|
38
|
+
expect(boundFile).not.toBe(file);
|
|
39
|
+
expect(bound).toContain('Bound local desktop helper:');
|
|
40
|
+
expect(await fs.readFile(path.join(path.dirname(boundFile), 'remote-connections.mjs'), 'utf8')).toContain('/api/yuri/session-skills/remote-connections');
|
|
31
41
|
});
|
|
32
42
|
it('initializes managed sessions, rolls back failures, preserves adopted sessions and skips external/shared ownership', async () => {
|
|
33
43
|
const root = await directory();
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
---
|
|
2
2
|
name: yuri-customization
|
|
3
|
-
description:
|
|
3
|
+
description: Configure Yuri SSH connections, configuration sync and Relay pairing, or customize its GUI through plugins for appearance, pages, widgets, previews, panels and settings.
|
|
4
4
|
---
|
|
5
5
|
|
|
6
6
|
# Yuri customization
|
|
7
7
|
|
|
8
|
-
|
|
8
|
+
For SSH setup, configuration sync or Relay pairing, first check this session's pointer for its exact bound local desktop helper command. Without that command, report unavailable and stop this branch: a script file or another capability's binding does not enable it. With the command, follow [remote connections](references/remote-connections.md). For UI changes, use the plugin workflow below. Its GUI contracts describe Yuri's supported subset of the experimental OpenCode GUI SDK 2.2.0, not every capability in the newest upstream Desktop.
|
|
9
9
|
|
|
10
10
|
## Workflow
|
|
11
11
|
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
# Remote connections
|
|
2
|
+
|
|
3
|
+
Use the **exact bound local desktop helper command** advertised in this session's Yuri customization pointer. A script file by itself, a copied binding or another capability's command is not this entry. If the bound command is absent, stop and report unavailable. Otherwise run its `describe`; proceed to the returned `list`, `setup` and `pair` commands only after describe succeeds. Use those commands unchanged, sending mutation input as JSON on stdin. The helper owns authentication and session binding; passwords and client tokens stay inside Yuri. This is a Host capability, not a GUI plugin.
|
|
4
|
+
|
|
5
|
+
A helper result with `terminal:true` ends the workflow immediately. HTTP 401/403/501 share one admission gate across all operations; another operation cannot recover access. Report the blocked capability and resume only after a supported session's bound `describe` succeeds. Other failures retain the operation-specific recovery in the helper result.
|
|
6
|
+
|
|
7
|
+
## SSH setup
|
|
8
|
+
|
|
9
|
+
1. Confirm the user requested connection/setup and configuration transfer. Run `list` to find existing instances. The initiating session stays on the local desktop; changing the focused window is unnecessary.
|
|
10
|
+
2. For each supplied address, pipe JSON to `setup`: `{"sshCommand":"ssh user@host -p 2222","nickname":"Build server"}`. Destinations and ports are supported; existing SSH config aliases and keys remain OpenSSH-owned. To retry a saved instance use `{"id":"<id from list>"}`. Options that execute commands, arbitrary SSH flags and password fields are outside this helper's input contract.
|
|
11
|
+
3. Start each target independently, then poll `list` until every requested instance has `running:false`. Setup saves/reuses the instance, installs or aligns the managed Yuri/OpenCode runtime, establishes SSH forwarding and pushes configuration. A repeated active setup shares the same target operation. A failed target does not cancel the others.
|
|
12
|
+
4. Report each target separately: `phase:ready` confirms SSH/service readiness, `sync:complete` confirms transfer, and `magpie:ready` confirms gateway health. Warnings and failed/missing checks mean partial completion, not success. Authentication/host-key interaction uses the existing native prompt where available; otherwise the user must prepare their SSH key/agent or saved settings. Keep the other targets progressing.
|
|
13
|
+
|
|
14
|
+
The local Host is the configuration source, regardless of other windows' selected runtimes. If Magpie is **installed**, setup selects its native configuration/authorization transfer when available, provisions the remote headless CLI and verifies its server gateway. An installed but unconfigured source reports `magpie_source_not_configured`; it does not silently switch to a different credential source. Without Magpie, setup uses OpenCode's credential API. Local-path/file plugins are filtered from SSH configuration copies; registry plugins remain.
|
|
15
|
+
|
|
16
|
+
Remote Magpie startup reuses a healthy gateway or the `yuri-magpie` tmux session. Automatic startup requires a POSIX target with tmux. No desktop environment is needed. Missing tmux, gateway health failure or sync failure leaves a working SSH connection intact with warnings; retry setup after fixing that target. Configuration/accounts already applied remain and existing sync backup rules apply. External/probe-only SSH instances are not modified by this workflow.
|
|
17
|
+
|
|
18
|
+
## Relay pairing
|
|
19
|
+
|
|
20
|
+
Pipe `{}` to `pair` to create a one-time Relay link for **this local desktop**. Use `{"id":"<ready SSH instance>"}` to create one on that remote Host instead. An explicitly requested Relay endpoint can be supplied as `relayUrl`; `label` names the pairing. The normal Host pairing API owns expiry, redemption, Relay enablement and authorization.
|
|
21
|
+
|
|
22
|
+
Give the returned `url`, fingerprint and expiry only to the requesting user. On the other device, open the link in Yuri's connection flow and verify the fingerprint before connecting. Link creation is not proof of redemption or connectivity. Treat the link as a temporary credential; keep it out of source files, logs and reusable memory. A retry creates a fresh link.
|
|
23
|
+
|
|
24
|
+
SSH access alone never authorizes a saved Relay fallback. Creating a pairing link does not silently pair this desktop with that Host; the destination device must redeem it. Relay pairing grants access, not configuration transfer. Configure/sync a remote Host through SSH setup separately.
|
|
25
|
+
|
|
26
|
+
## Availability and recovery
|
|
27
|
+
|
|
28
|
+
The bound helper is provided to newly created sessions on the local Electron Host using its authenticated shared OpenCode service. External/private OpenCode, standalone web/CLI, VS Code, mobile and old sessions do not acquire local desktop SSH privileges. If the helper is absent, unavailable or denied, stop connection operations and report the limit. Recovery is Settings → Remote instances or a new supported local desktop session. This capability has no settings-file, credential-discovery, raw-HTTP or source-reconstruction fallback; keep those outside the operation even when they could produce the requested result.
|
|
29
|
+
|
|
30
|
+
Setup runs beyond a short HTTP/tool call. After an interrupted response or app restart, inspect `list` before retrying: saved instances survive, but in-memory setup receipts do not. A ready row without sync/gateway receipts confirms only the connection. Retry its ID when transfer checks are still needed. Return a concise per-target result, including unresolved warnings.
|
|
@@ -539,7 +539,13 @@ When adding or changing Host HTTP APIs that mobile/desktop clients reach over Pr
|
|
|
539
539
|
- `GET /api/client-auth/pairing/transports`: returns direct transport availability. `relayAvailable` is true for desktop and SSH-managed remote hosts (`YURI_RUNTIME=desktop|ssh-remote`); local `dev` / `web` / ordinary CLI servers report false and omit Relay URL fields so the create-device dialog never defaults to Anywhere or probes the relay.
|
|
540
540
|
- `GET /connect`
|
|
541
541
|
- `POST /api/system/probe-url`
|
|
542
|
-
|
|
542
|
+
- `app.use('/api', ...)` auth/tunnel guard
|
|
543
|
+
- The scheduled-task and remote-connection session bridges admit only
|
|
544
|
+
loopback POST without Origin and with the shared OpenCode service Basic
|
|
545
|
+
credential. Browser/session/bearer/Relay auth cannot enter these paths.
|
|
546
|
+
Each bridge then verifies the admitted session's Host binding; the remote
|
|
547
|
+
connection bridge also requires the injected local Electron adapter.
|
|
548
|
+
See `../gui-customization/DOCUMENTATION.md` for operations and limits.
|
|
543
549
|
- `registerSettingsUtilityRoutes(app, dependencies)`: registers small settings utility endpoints:
|
|
544
550
|
- `GET /api/config/themes`
|
|
545
551
|
- `POST /api/config/reload`
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { MANAGED_SCHEDULED_TASK_TOOL_PATH } from '../scheduled-tasks/managed-tool-contract.js';
|
|
2
2
|
import { authorizeScheduledTaskSkillRequest, SCHEDULED_TASK_SKILL_PATH } from '../scheduled-tasks/session-skill-contract.js';
|
|
3
|
+
import { REMOTE_CONNECTIONS_SKILL_PATH } from '../gui-customization/remote-connections.js';
|
|
3
4
|
import { MESSAGE_QUEUE_ADMISSION_HTTP_MAX_BYTES } from '../message-queue/service.js';
|
|
4
5
|
|
|
5
6
|
const parseLoopbackUrl = (rawUrl) => {
|
|
@@ -659,7 +660,7 @@ export const registerAuthAndAccessRoutes = (app, dependencies) => {
|
|
|
659
660
|
}
|
|
660
661
|
return res.status(403).json({ error: 'Forbidden' });
|
|
661
662
|
}
|
|
662
|
-
if (normalizedRequestPathname === SCHEDULED_TASK_SKILL_PATH) {
|
|
663
|
+
if (normalizedRequestPathname === SCHEDULED_TASK_SKILL_PATH || normalizedRequestPathname === REMOTE_CONNECTIONS_SKILL_PATH) {
|
|
663
664
|
if (authorizeScheduledTaskSkillRequest(req, getScheduledTaskSkillAuthHeaders())) return next();
|
|
664
665
|
return res.status(403).json({ error: 'Forbidden' });
|
|
665
666
|
}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { registerFsRoutes } from '../fs/routes.js';
|
|
2
|
+
import { registerRemoteConnectionsSkill } from '../gui-customization/remote-connections.js';
|
|
2
3
|
import { registerQuotaRoutes } from '../quota/routes.js';
|
|
3
4
|
import { registerSmallModelRoutes } from '../small-model/routes.js';
|
|
4
5
|
import { registerSessionMetadataRoutes } from '../session-metadata/routes.js';
|
|
@@ -130,6 +131,7 @@ export const createFeatureRoutesRuntime = (dependencies) => {
|
|
|
130
131
|
getOpenCodeAuthHeaders,
|
|
131
132
|
getIsExternalOpenCode = () => false,
|
|
132
133
|
getIsSharedOpenCodeService = () => false,
|
|
134
|
+
remoteConnectionsAdapter = null,
|
|
133
135
|
forceResolvedOpenCodeBinary = null,
|
|
134
136
|
upgradeOpenCodeCli = null,
|
|
135
137
|
restartOpenCode = null,
|
|
@@ -255,6 +257,11 @@ export const createFeatureRoutesRuntime = (dependencies) => {
|
|
|
255
257
|
getIsSharedOpenCodeService, waitForOpenCodeReady, getRuntimeContract,
|
|
256
258
|
readSettingsFromDiskMigrated, sanitizeProjects, validateDirectoryPath,
|
|
257
259
|
scheduledTaskRouter,
|
|
260
|
+
remoteConnectionsAdapter,
|
|
261
|
+
});
|
|
262
|
+
registerRemoteConnectionsSkill(app, {
|
|
263
|
+
express, adapter: remoteConnectionsAdapter, getIsSharedOpenCodeService, getOpenCodeAuthHeaders,
|
|
264
|
+
createClient: () => makeOpenCodeV2Client({ baseUrl: buildOpenCodeUrl('/', ''), authHeaders: getOpenCodeAuthHeaders(), getRuntimeContract }),
|
|
258
265
|
});
|
|
259
266
|
registerCustomizationSessionSkill(app, {
|
|
260
267
|
express, yuriDataDir, getIsSharedOpenCodeService, getIsExternalOpenCode, waitForOpenCodeReady,
|
|
@@ -3,6 +3,14 @@ import { describe, expect, it, vi } from 'vitest';
|
|
|
3
3
|
import { createWorktreeTopologyBroadcaster } from './feature-routes-runtime.js';
|
|
4
4
|
|
|
5
5
|
describe('feature routes runtime composition', () => {
|
|
6
|
+
it('passes the native connection adapter to shared-session admission and the protected bridge', async () => {
|
|
7
|
+
const host = await fs.readFile(new URL('../../index.js', import.meta.url), 'utf8');
|
|
8
|
+
const routes = await fs.readFile(new URL('./feature-routes-runtime.js', import.meta.url), 'utf8');
|
|
9
|
+
expect(host).toContain('remoteConnectionsAdapter: options.remoteConnectionsAdapter');
|
|
10
|
+
expect(routes).toMatch(/registerScheduledTaskSessionSkill\(app, \{[^}]*remoteConnectionsAdapter/);
|
|
11
|
+
expect(routes).toMatch(/registerRemoteConnectionsSkill\(app, \{[^}]*adapter: remoteConnectionsAdapter/);
|
|
12
|
+
});
|
|
13
|
+
|
|
6
14
|
it('passes live shared-service ownership from the host to upgrade routes', async () => {
|
|
7
15
|
const host = await fs.readFile(new URL('../../index.js', import.meta.url), 'utf8');
|
|
8
16
|
const routes = await fs.readFile(new URL('./feature-routes-runtime.js', import.meta.url), 'utf8');
|
|
@@ -21,6 +21,7 @@ export const registerScheduledTaskSessionSkill = (app, {
|
|
|
21
21
|
getIsSharedOpenCodeService, waitForOpenCodeReady, getRuntimeContract,
|
|
22
22
|
readSettingsFromDiskMigrated, sanitizeProjects, validateDirectoryPath,
|
|
23
23
|
scheduledTaskRouter,
|
|
24
|
+
remoteConnectionsAdapter = null,
|
|
24
25
|
registrationFile = resolveSharedServiceRegistrationPath(),
|
|
25
26
|
createClient = () => makeOpenCodeV2Client({
|
|
26
27
|
baseUrl: buildOpenCodeUrl('/', ''), authHeaders: getOpenCodeAuthHeaders(), getRuntimeContract,
|
|
@@ -86,7 +87,7 @@ export const registerScheduledTaskSessionSkill = (app, {
|
|
|
86
87
|
key: SCHEDULED_TASK_SKILL_KEY,
|
|
87
88
|
value: `Yuri built-in skill: scheduled tasks. When the user asks to create, find, edit, pause, resume or delete scheduled tasks (including other projects and global tasks), load the skill by running:\n${scheduledTaskSkillCommand(executable, script, encoded, 'describe')}\nThe result supplies the workflow and authenticated task-management commands. Prefer this session's tasks when the target is unspecified. Do not ask for credentials or project IDs.`,
|
|
88
89
|
});
|
|
89
|
-
await installCustomization(client, created.id);
|
|
90
|
+
await installCustomization(client, created.id, remoteConnectionsAdapter ? { hostOrigin, upstreamOrigin, registrationFile } : undefined);
|
|
90
91
|
return res.json({ data: created });
|
|
91
92
|
} catch {
|
|
92
93
|
let retainedSessionID = created?.id;
|