@yuriai/web 0.2.40-beta.3 → 0.2.40-beta.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (108) hide show
  1. package/dist/assets/{AgentAvatar-kQhfwlay.js → AgentAvatar-BmT_6apW.js} +1 -1
  2. package/dist/assets/{AssistantConversationSurface-CW3U6Lhp.js → AssistantConversationSurface-B-D-mLgs.js} +3 -3
  3. package/dist/assets/{AssistantUnreadBadge-B2SY-_-u.js → AssistantUnreadBadge-C34eOGCL.js} +1 -1
  4. package/dist/assets/{AssistantView-C_hiAuTd.js → AssistantView-0nXkM9VG.js} +1 -1
  5. package/dist/assets/{DiagramView-CzhdZEw4.js → DiagramView-BU6jWxKJ.js} +1 -1
  6. package/dist/assets/{FadeInOnReveal-CMeIdEKz.js → FadeInOnReveal-CCVdl9Vt.js} +1 -1
  7. package/dist/assets/{GuiPluginPage-WXqykPAg.js → GuiPluginPage-BMt5AMqg.js} +1 -1
  8. package/dist/assets/{GuiPluginSurface-BG3hENTt.js → GuiPluginSurface-kxAcgmf1.js} +1 -1
  9. package/dist/assets/{GuiPluginWindow-BLzchKn7.js → GuiPluginWindow-BVvzrnp1.js} +1 -1
  10. package/dist/assets/{Icon-DygEqfgq.js → Icon-B5nBc6dO.js} +1 -1
  11. package/dist/assets/{ImageLoadingPlaceholder-kbBRpDSD.js → ImageLoadingPlaceholder-Bv5mmf2U.js} +1 -1
  12. package/dist/assets/{LoadingImage-DmucvXdY.js → LoadingImage-BzBw_1lI.js} +1 -1
  13. package/dist/assets/{MarkdownRenderer-BkOMcK8x.js → MarkdownRenderer-CoMohPOZ.js} +2 -2
  14. package/dist/assets/{MarkdownRendererImpl-B5vJtPoa.js → MarkdownRendererImpl-DoZW1UKH.js} +1 -1
  15. package/dist/assets/{MarkstreamRendererImpl-1J-Gu2M2.js → MarkstreamRendererImpl-B3zd5x2O.js} +1 -1
  16. package/dist/assets/{MobileDetailNavigation-48o8aG28.js → MobileDetailNavigation-bEZ_NA03.js} +1 -1
  17. package/dist/assets/{MobileResizableSheet-Dt2U0JHY.js → MobileResizableSheet-D5PcZMuI.js} +1 -1
  18. package/dist/assets/{MobileShareBridge-DnYT3Dbz.js → MobileShareBridge-Cjukxazk.js} +1 -1
  19. package/dist/assets/{MobileTabPageHeader-D6kqRFm0.js → MobileTabPageHeader-Da1maXx-.js} +1 -1
  20. package/dist/assets/{MultiRunWindow-BuRo90Ma.js → MultiRunWindow-rMqP99ID.js} +1 -1
  21. package/dist/assets/{OnboardingScreen-Bn0RgrJU.js → OnboardingScreen-CZhqHzAj.js} +1 -1
  22. package/dist/assets/{OverlayScrollbar-B0X61qR-.js → OverlayScrollbar-Byx2H3pc.js} +1 -1
  23. package/dist/assets/{SettingsView-Bla2lVqS.js → SettingsView-7Bea2DvF.js} +1 -1
  24. package/dist/assets/{SettingsWindow-kCbf8IoB.js → SettingsWindow-U-RDDOS7.js} +1 -1
  25. package/dist/assets/{SetupTourDialog-GDRS3gDa.js → SetupTourDialog-CKec5tUy.js} +1 -1
  26. package/dist/assets/{TerminalView-B1u3s7IN.js → TerminalView-CS1oSAuY.js} +1 -1
  27. package/dist/assets/{ToolOutputDialog-CYUPmbtq.js → ToolOutputDialog-BWhrFvvI.js} +1 -1
  28. package/dist/assets/{VoiceSettings-Dy6-nkQo.js → VoiceSettings-7aFmJq9Z.js} +1 -1
  29. package/dist/assets/{appThemeRegistry--G1XaYmo.js → appThemeRegistry-LyWTE-mT.js} +1 -1
  30. package/dist/assets/{capgoAdapter-DO1rEVQf.js → capgoAdapter-B5NImlKh.js} +1 -1
  31. package/dist/assets/{checkbox-BW80bcK5.js → checkbox-Bdj4n5cI.js} +1 -1
  32. package/dist/assets/{collapsible-BOL5Wx2J.js → collapsible-D1JZOgJZ.js} +1 -1
  33. package/dist/assets/{context-menu-CiFnjP1q.js → context-menu-DDX0ZFhc.js} +1 -1
  34. package/dist/assets/{diagram-DRn8iIs1.js → diagram-C72TQWfh.js} +1 -1
  35. package/dist/assets/{dialog-DQp289fr.js → dialog-CIKJalI5.js} +1 -1
  36. package/dist/assets/{fileMentionTouchSelection-582p0uCX.js → fileMentionTouchSelection-tnd9RDDh.js} +1 -1
  37. package/dist/assets/{gitApi-vYBmQIuU.js → gitApi-BI8OG_ts.js} +1 -1
  38. package/dist/assets/{input-B281XcMR.js → input-gVHSS0EB.js} +1 -1
  39. package/dist/assets/{insertionBoundaries-CB4gv9rr.js → insertionBoundaries-B-yZI6iY.js} +1 -1
  40. package/dist/assets/{main-Caf-6KmT.js → main-BfAN93rT.js} +4 -4
  41. package/dist/assets/{main-B1KrAdkh.js → main-DYWwmI_W.js} +2 -2
  42. package/dist/assets/{markdownHeightCache-BgYJswDy.js → markdownHeightCache-B-FoaQ1U.js} +1 -1
  43. package/dist/assets/{mcpQueries-CQyOFjX2.js → mcpQueries-CehWHIB1.js} +1 -1
  44. package/dist/assets/{miniChat-zEoOVjOQ.js → miniChat-BlkcLQBr.js} +2 -2
  45. package/dist/assets/{mobile-Dt8wAkc4.js → mobile-I3Xe5NtO.js} +2 -2
  46. package/dist/assets/{mobileBackNavigation-BbKMa0Jb.js → mobileBackNavigation-BFUH-c-G.js} +1 -1
  47. package/dist/assets/{mobileConnections-CXYj4P9M.js → mobileConnections-BFvtbJXX.js} +2 -2
  48. package/dist/assets/{multirun-9v2r_beX.js → multirun-DdEjp77z.js} +1 -1
  49. package/dist/assets/{native-config-BOaqa45X.js → native-config-DqDXViVx.js} +1 -1
  50. package/dist/assets/{projectMeta-ZouOo-T_.js → projectMeta-BKgum5WN.js} +1 -1
  51. package/dist/assets/{pwa-syKJBLoe.js → pwa-BvKUY4Hk.js} +1 -1
  52. package/dist/assets/{queue-abort-optimistic-BYH5yLM2.js → queue-abort-optimistic-BcbiNk8t.js} +1 -1
  53. package/dist/assets/{react-DPhQUTaH.js → react-DeB-Vc_L.js} +1 -1
  54. package/dist/assets/{readiness-BpVAjFhF.js → readiness-CIlvQ-aQ.js} +2 -2
  55. package/dist/assets/{renderElectronMiniChatApp-DprABvit.js → renderElectronMiniChatApp-DIjWdFHu.js} +2 -2
  56. package/dist/assets/{renderMobileApp-DQmX6iak.js → renderMobileApp-CE0QyOH0.js} +4 -4
  57. package/dist/assets/{runtimeConfig-7Umh9QWi.js → runtimeConfig-uhjQn4kK.js} +1 -1
  58. package/dist/assets/{runtimeEndpointReset-BYtLmSuX.js → runtimeEndpointReset-DezNESKT.js} +3 -3
  59. package/dist/assets/{select-CyPxbnW8.js → select-BwCKwnTH.js} +1 -1
  60. package/dist/assets/{sessionLookup-D_fPlqqT.js → sessionLookup-DzKZsy-W.js} +1 -1
  61. package/dist/assets/{sortable-tabs-strip-BclS0Hnd.js → sortable-tabs-strip-m5JQrTx4.js} +1 -1
  62. package/dist/assets/{speechSettingsQueries-CTsBn-Ib.js → speechSettingsQueries-C5mPRWIv.js} +1 -1
  63. package/dist/assets/{textarea-CjJsstUF.js → textarea-CaTDyZrS.js} +1 -1
  64. package/dist/assets/{tooltip-Di_DSZ8p.js → tooltip-BvZzoiqg.js} +1 -1
  65. package/dist/assets/{types-wnqkJWYs.js → types-Bm8kDgSv.js} +1 -1
  66. package/dist/assets/{useAppFontEffects-BRMf55oN.js → useAppFontEffects-C9IaiJgF.js} +5 -5
  67. package/dist/assets/{useDesktopWindowControlsLayout-Bq9DFNYn.js → useDesktopWindowControlsLayout-C3M12PjJ.js} +1 -1
  68. package/dist/assets/{useEffectiveDirectory-5RwQ_nuK.js → useEffectiveDirectory-Do4UqfZR.js} +1 -1
  69. package/dist/assets/{useMobileNavigationStore-ePbEoQwb.js → useMobileNavigationStore-InwdmuDX.js} +5 -5
  70. package/dist/assets/{usePluginsStore-HJJZ65gd.js → usePluginsStore-BH4-CNcj.js} +1 -1
  71. package/dist/assets/{useStreamingTextThrottle-CjMALEr7.js → useStreamingTextThrottle-CeKHHK13.js} +1 -1
  72. package/dist/assets/{useWorkerHighlightedLines-6x1R4afJ.js → useWorkerHighlightedLines-0XahwAbS.js} +1 -1
  73. package/dist/index.html +5 -5
  74. package/dist/mini-chat.html +5 -5
  75. package/dist/mobile.html +1 -1
  76. package/package.json +1 -1
  77. package/server/lib/assistants/builtin-skills.js +1 -1
  78. package/server/lib/assistants/builtin-skills.test.js +2 -0
  79. package/server/lib/gui-customization/DOCUMENTATION.md +25 -1
  80. package/server/lib/gui-customization/projects-client.mjs +59 -0
  81. package/server/lib/gui-customization/projects.js +43 -0
  82. package/server/lib/gui-customization/projects.test.js +103 -0
  83. package/server/lib/gui-customization/remote-connections-client.mjs +2 -8
  84. package/server/lib/gui-customization/session-skill-command.mjs +8 -0
  85. package/server/lib/gui-customization/session-skill.js +15 -10
  86. package/server/lib/gui-customization/session-skill.test.js +21 -2
  87. package/server/lib/gui-customization/skill/SKILL.md +3 -1
  88. package/server/lib/gui-customization/skill/references/projects.md +63 -0
  89. package/server/lib/notifications/DOCUMENTATION.md +12 -0
  90. package/server/lib/notifications/runtime.js +20 -2
  91. package/server/lib/notifications/runtime.test.js +21 -0
  92. package/server/lib/notifications/session-unread-runtime.js +51 -13
  93. package/server/lib/notifications/session-unread.test.js +113 -1
  94. package/server/lib/opencode/core-routes.js +2 -1
  95. package/server/lib/opencode/feature-routes-runtime.js +6 -0
  96. package/server/lib/opencode/feature-routes-runtime.test.js +4 -0
  97. package/server/lib/projects/DOCUMENTATION.md +6 -3
  98. package/server/lib/scheduled-tasks/session-skill.js +2 -1
  99. package/server/lib/scheduled-tasks/session-skill.test.js +34 -1
  100. package/server/lib/session-index/DOCUMENTATION.md +4 -1
  101. package/server/lib/session-index/event-ingest.js +8 -0
  102. package/server/lib/session-index/event-ingest.test.js +16 -0
  103. package/server/lib/session-index/service.js +1 -0
  104. package/server/lib/session-index/service.test.js +3 -1
  105. package/server/lib/session-metadata/DOCUMENTATION.md +18 -1
  106. package/server/lib/session-title/DOCUMENTATION.md +3 -0
  107. package/server/lib/session-title/runtime.js +1 -0
  108. package/server/lib/session-title/runtime.test.js +2 -0
@@ -23,7 +23,15 @@ describe('built-in customization instructions', () => {
23
23
  expect(entry.value.length).toBeLessThan(1500);
24
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', 'remote-connections']) expect((await fs.readFile(path.join(path.dirname(file), 'references', `${name}.md`), 'utf8')).length).toBeGreaterThan(500);
26
+ for (const name of ['projects', '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).toContain('adding a directory as a project in Yuri');
28
+ expect(await fs.readFile(file, 'utf8')).toContain('(references/projects.md)');
29
+ const projects = await fs.readFile(path.join(path.dirname(file), 'references', 'projects.md'), 'utf8');
30
+ expect(projects).toContain('POST /api/yuri/session-skills/projects');
31
+ expect(projects).toContain('commands.add');
32
+ expect(projects).not.toContain('open \'yuri://');
33
+ expect(entry.value).toContain('No bound project helper is provided');
34
+ await expect(fs.stat(path.join(path.dirname(file), 'projects.mjs'))).rejects.toMatchObject({ code: 'ENOENT' });
27
35
  expect(entry.value).not.toContain('Bound local desktop helper');
28
36
  expect(entry.value).toContain('No bound SSH/Relay command is provided');
29
37
  expect(entry.value).toContain('There is no credential/filesystem fallback');
@@ -32,12 +40,23 @@ describe('built-in customization instructions', () => {
32
40
  expect(await fs.readFile(path.join(path.dirname(file), 'references', 'global-pages.md'), 'utf8')).toContain('(icons.md)');
33
41
  expect(await fs.readFile(path.join(path.dirname(file), 'references', 'appearance.md'), 'utf8')).toContain('yuri.branding');
34
42
  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') });
43
+ const binding = { hostOrigin: 'http://127.0.0.1:4000', upstreamOrigin: 'http://127.0.0.1:4096', registrationFile: path.join(root, 'service.json') };
44
+ await install(client, 'ses_bound', { remoteBinding: binding });
36
45
  const bound = put.mock.calls[2][0].value;
37
46
  const boundFile = JSON.parse(bound.match(/read (".*?") first/)[1]);
38
47
  expect(boundFile).not.toBe(file);
39
48
  expect(bound).toContain('Bound local desktop helper:');
49
+ expect(await fs.readFile(path.join(path.dirname(boundFile), 'references', 'projects.md'), 'utf8')).toBe(projects);
40
50
  expect(await fs.readFile(path.join(path.dirname(boundFile), 'remote-connections.mjs'), 'utf8')).toContain('/api/yuri/session-skills/remote-connections');
51
+ expect(await fs.readFile(path.join(path.dirname(boundFile), 'session-skill-command.mjs'), 'utf8')).toContain('sessionSkillCommand');
52
+ await install(client, 'ses_project', { projectBinding: binding });
53
+ const projectEntry = put.mock.calls[3][0].value;
54
+ const projectFile = JSON.parse(projectEntry.match(/read (".*?") first/)[1]);
55
+ expect(projectFile).not.toBe(boundFile);
56
+ expect(projectEntry).toContain('Bound project helper:');
57
+ expect(projectEntry).toContain('No bound SSH/Relay command is provided');
58
+ expect(await fs.readFile(path.join(path.dirname(projectFile), 'projects.mjs'), 'utf8')).toContain('/api/yuri/session-skills/projects');
59
+ await expect(fs.stat(path.join(path.dirname(projectFile), 'remote-connections.mjs'))).rejects.toMatchObject({ code: 'ENOENT' });
41
60
  });
42
61
  it('initializes managed sessions, rolls back failures, preserves adopted sessions and skips external/shared ownership', async () => {
43
62
  const root = await directory();
@@ -1,10 +1,12 @@
1
1
  ---
2
2
  name: yuri-customization
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.
3
+ description: Add existing directories as Yuri projects through its API, configure 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
+ For adding an existing directory to Yuri's project list, follow [projects](references/projects.md) using this session's bound project API helper. Registration is separate from creating files, cloning or opening a conversation.
9
+
8
10
  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
11
 
10
12
  ## Workflow
@@ -0,0 +1,63 @@
1
+ # Add a project
2
+
3
+ Register an existing directory through the **bound project API helper** in this
4
+ session's Yuri customization pointer. This is a Host capability, not a GUI plugin
5
+ or a desktop deep link. Registration does not create files, clone a repository,
6
+ open a conversation or switch an existing active project.
7
+
8
+ ## Workflow
9
+
10
+ 1. Resolve the user-requested directory to an absolute path on the bound Yuri
11
+ Host. Reuse a known directory; directory creation/cloning is a separate action
12
+ requiring the user's request. Paths in JSON are literal strings, not
13
+ percent-encoded URL parameters.
14
+ 2. Run this session's exact `Bound project helper` command (`describe`). It returns
15
+ the supported operations and ready-to-run `commands.add` and `commands.list`.
16
+ The helper owns authentication; no credential discovery or browser login is
17
+ needed. If the pointer has no bound project command, report unavailable.
18
+ 3. Run the returned `add` command unchanged, supplying JSON on stdin:
19
+
20
+ ```json
21
+ {"path":"/workspace/my-project","label":"My project"}
22
+ ```
23
+
24
+ `path` is required; `label` is optional (up to 80 characters). The Host validates
25
+ the existing directory and canonicalizes its path, then registers it through
26
+ Yuri's shared project registry and serialized settings writer. Repeat calls
27
+ for the same canonical directory reuse the existing project and preserve its
28
+ name, order and metadata.
29
+ 4. A successful result is `{"project":{"id":"…","path":"…","label":"…"},"created":true}`.
30
+ `created:false` means it was already registered. Both confirm the saved project;
31
+ use the returned canonical `project.path` and report the result briefly. The
32
+ `label` field can be absent. No browser check is required to prove registration.
33
+
34
+ `list` returns `{"projects":[{"id":"…","path":"…","label":"…"}]}` from the
35
+ authoritative settings store. After an interrupted response, list or retry add
36
+ with the same path: registration is idempotent. A failure is unconfirmed, never an
37
+ empty-success result. Missing paths, files and inaccessible directories fail
38
+ without implicit filesystem creation. A `terminal:true` helper error stops this
39
+ workflow until a new supported session's bound describe succeeds.
40
+
41
+ ## Interface and scope
42
+
43
+ The helper calls `POST /api/yuri/session-skills/projects` with
44
+ `{sessionID, operation: "describe" | "list" | "add", input}`. It uses the same
45
+ loopback service authentication and admitted-session Host binding as the other
46
+ built-in session helpers. Only affected project metadata is returned, never full
47
+ settings or credentials. Use the bound command rather than reconstructing auth or
48
+ calling the route with browser tokens.
49
+
50
+ The existing UI API `POST /api/opencode/directory` and this bridge share
51
+ `projects/registry.js`; the UI API additionally activates the directory. The skill
52
+ registers only, preserving an existing active selection (the first project may
53
+ become active through normal settings initialization). Existing project-order
54
+ notifications distribute the saved registry to connected clients.
55
+
56
+ New shared-service sessions admitted by a Yuri Host receive the helper whether
57
+ the UI is Electron, web or connected mobile. The directory belongs to that Host,
58
+ not the phone or another machine. Private/external OpenCode, standalone VS Code,
59
+ old sessions and contacts without a bound command gain no API access from reading
60
+ this file. Contacts may instead have their own granted `yuri.projects` tools;
61
+ those retain their own capability contract. When the helper is unavailable, use
62
+ the intended Host's project UI or start a supported session. Keep desktop deep
63
+ links for their existing navigation purpose, not as an API authorization fallback.
@@ -12,6 +12,18 @@ delivery settings and the legacy in-memory attention/presence endpoints.
12
12
  success/error (including legacy idle/error) increments attention without requiring
13
13
  an online client. Root/system visibility uses the session-index policy and an
14
14
  authoritative session record; child sessions do not create unread badges.
15
+ Explicit CLI-worker ownership (`metadata.yuri.worker.parentSessionID`) uses the
16
+ same exclusion as the session catalog, even if native `parentID` is absent.
17
+ Metadata lifecycle updates remove existing hidden attention without waiting for
18
+ another completion. The first unread GET after Host startup reconciles persisted
19
+ unread rows against current session records, with at most four identity reads in
20
+ flight and one shared reconciliation for concurrent clients. Already-read rows
21
+ are skipped and successful identities are not reread on later GETs. Failed
22
+ identity/cleanup writes retain that row, return retryable 503, and retry only the
23
+ unresolved rows; independent successful cleanup stays committed. No transcript
24
+ scan or title/agent-name heuristic is used. Unmarked CLI roots remain ordinary
25
+ conversations; verified historical workers must first receive their explicit
26
+ ownership marker through the metadata store.
15
27
  Token/part/message deltas do no work. Each session serializes lifecycle boundaries
16
28
  and independently retries failed identity reads/writes with capped backoff.
17
29
  New execution rearms terminal deduplication and clears its previous error marker;
@@ -218,7 +218,8 @@ export const createNotificationTriggerRuntime = (deps) => {
218
218
  );
219
219
 
220
220
  const getCachedSessionMeta = (sessionId, directory) => {
221
- const cacheKey = getSessionMetaCacheKey(sessionId, directory);
221
+ const requestedKey = getSessionMetaCacheKey(sessionId, directory);
222
+ const cacheKey = sessionMetaCache.has(requestedKey) ? requestedKey : getSessionMetaCacheKey(sessionId, undefined);
222
223
  const entry = sessionMetaCache.get(cacheKey);
223
224
  if (!entry) return undefined;
224
225
  if (Date.now() - entry.at > SESSION_META_CACHE_TTL_MS) {
@@ -232,6 +233,8 @@ export const createNotificationTriggerRuntime = (deps) => {
232
233
  const previous = getCachedSessionMeta(sessionId, directory);
233
234
  sessionMetaCache.set(getSessionMetaCacheKey(sessionId, directory), {
234
235
  parentID: meta.parentID !== undefined ? meta.parentID : (previous?.parentID ?? null),
236
+ workerParentSessionID: meta.workerParentSessionID !== undefined
237
+ ? meta.workerParentSessionID : (previous?.workerParentSessionID ?? null),
235
238
  smallModelPurpose: meta.smallModelPurpose !== undefined
236
239
  ? meta.smallModelPurpose
237
240
  : (previous?.smallModelPurpose ?? null),
@@ -254,6 +257,7 @@ export const createNotificationTriggerRuntime = (deps) => {
254
257
  ? yuri.assigned.from
255
258
  : null;
256
259
  return {
260
+ workerParentSessionID: normalizeParentID(yuri?.worker?.parentSessionID),
257
261
  smallModelPurpose: normalizeSmallModelPurpose(yuri?.smallModel?.purpose),
258
262
  // Throwaway LLM gateway sessions (`metadata.yuri.llm.purpose`) share
259
263
  // the same sidebar-hidden contract as small-model system sessions.
@@ -271,6 +275,19 @@ export const createNotificationTriggerRuntime = (deps) => {
271
275
 
272
276
  const maybeCacheSessionMetaFromPayload = (payload) => {
273
277
  if (!payload || typeof payload !== 'object') return;
278
+ if (payload.type === 'session.metadata.updated') {
279
+ const data = payload.data ?? payload.properties;
280
+ if (typeof data?.sessionID === 'string' && data.metadata && typeof data.metadata === 'object') {
281
+ const meta = metaFromYuri(data.metadata.yuri);
282
+ for (const key of sessionMetaCache.keys()) {
283
+ if (key.endsWith(`\0${data.sessionID}`)) {
284
+ setCachedSessionMeta(data.sessionID, key.slice(0, -data.sessionID.length - 1), meta);
285
+ }
286
+ }
287
+ setCachedSessionMeta(data.sessionID, undefined, meta);
288
+ }
289
+ return;
290
+ }
274
291
  if (payload.type !== 'session.created' && payload.type !== 'session.updated') return;
275
292
  const info = payload.properties?.info;
276
293
  if (!info || typeof info !== 'object') return;
@@ -289,7 +306,7 @@ export const createNotificationTriggerRuntime = (deps) => {
289
306
  if (!sessionId) return undefined;
290
307
 
291
308
  const cached = getCachedSessionMeta(sessionId, directory);
292
- if (cached?.complete) return cached;
309
+ if (cached?.complete || isHiddenFromNavSession(cached)) return cached;
293
310
 
294
311
  try {
295
312
  const base = buildOpenCodeUrl(`/session/${encodeURIComponent(sessionId)}`, '');
@@ -347,6 +364,7 @@ export const createNotificationTriggerRuntime = (deps) => {
347
364
  const isHiddenFromNavSession = (meta) => {
348
365
  if (!meta) return false;
349
366
  if (typeof meta.parentID === 'string' && meta.parentID.length > 0) return true;
367
+ if (meta.workerParentSessionID) return true;
350
368
  if (typeof meta.smallModelPurpose === 'string' && meta.smallModelPurpose.length > 0) return true;
351
369
  if (typeof meta.llmPurpose === 'string' && meta.llmPurpose.length > 0) return true;
352
370
  if (typeof meta.assistantID === 'string' && meta.assistantID.length > 0 && meta.assignedFrom !== 'contact') {
@@ -368,6 +368,27 @@ describe('notification trigger runtime llm system-session suppression', () => {
368
368
  expectAllOutletsSilent(outlets);
369
369
  });
370
370
 
371
+ it('skips completion/error outlets for explicitly linked CLI workers without native parentID', async () => {
372
+ vi.stubGlobal('fetch', vi.fn(async () => jsonResponse({
373
+ id: 'worker', title: 'Ordinary title', metadata: { yuri: { worker: { parentSessionID: 'root' } } },
374
+ })));
375
+ const outlets = createRuntime();
376
+ await outlets.runtime.maybeSendPushForTrigger(completionPayload('worker'));
377
+ await outlets.runtime.maybeSendPushForTrigger({ type: 'session.error', properties: { sessionID: 'worker', error: 'boom' } });
378
+ expectAllOutletsSilent(outlets);
379
+ });
380
+
381
+ it('refreshes cached CLI-worker ownership from a native metadata-only event', async () => {
382
+ vi.stubGlobal('fetch', vi.fn(async () => jsonResponse({ id: 'worker', metadata: {} })));
383
+ const outlets = createRuntime();
384
+ await outlets.runtime.maybeSendPushForTrigger({ type: 'session.updated', properties: { info: { id: 'worker' } } });
385
+ await outlets.runtime.maybeSendPushForTrigger({ type: 'session.metadata.updated', data: {
386
+ sessionID: 'worker', metadata: { yuri: { worker: { parentSessionID: 'root' } } },
387
+ } });
388
+ await outlets.runtime.maybeSendPushForTrigger(completionPayload('worker'));
389
+ expectAllOutletsSilent(outlets);
390
+ });
391
+
371
392
  it('skips ready notifications synthesized from session.idle for llm sessions', async () => {
372
393
  vi.stubGlobal('fetch', vi.fn(async () => llmSessionResponse()));
373
394
  const outlets = createRuntime();
@@ -1,17 +1,22 @@
1
1
  import express from 'express';
2
2
  import { isVisibleSession } from '../session-index/service.js';
3
3
 
4
- /** Only lifecycle boundaries do work; token, part and message deltas never read or write. */
4
+ /** Lifecycle boundaries and startup repair do work; streaming deltas never read or write. */
5
5
  export function createSessionUnreadRuntime({ store, loadSession, hub, resolveDirectory = value => value, retryMs = 1000 }) {
6
6
  const flights = new Map();
7
7
  const queues = new Map();
8
+ const unreconciled = new Set(Object.entries(store.snapshot().sessions)
9
+ .filter(([, row]) => row.unreadCount > 0).map(([id]) => id));
10
+ let reconciliation = null;
8
11
  let disposed = false;
9
12
  const directoryOf = session => resolveDirectory(session.location?.directory ?? session.directory ?? '');
10
13
  const visible = session => session && !session.parentID && isVisibleSession(session);
11
14
  const apply = async ({ payload, id, kind }) => {
12
15
  if (kind === 'deleted') { store.remove(id); return; }
13
16
  const session = await loadSession(id);
14
- if (disposed || !visible(session)) return;
17
+ if (disposed) return;
18
+ if (!visible(session)) { store.remove(id); return; }
19
+ if (kind === 'refresh') return;
15
20
  store.observe({ id, directory: directoryOf(session), kind, eventAt: payload.created, sequence: payload.durable?.seq });
16
21
  };
17
22
  const drain = (id, queue) => {
@@ -22,7 +27,16 @@ export function createSessionUnreadRuntime({ store, loadSession, hub, resolveDir
22
27
  await apply(queue.items[0]);
23
28
  queue.items.shift().resolve();
24
29
  queue.attempt = 0;
25
- } catch {
30
+ } catch (error) {
31
+ if (queue.items[0].retry === false) {
32
+ queue.items.shift().reject(error);
33
+ continue;
34
+ }
35
+ queue.items = queue.items.filter(item => {
36
+ if (item.retry !== false) return true;
37
+ item.reject(error);
38
+ return false;
39
+ });
26
40
  // Preserve the failed boundary and its following run boundaries in order.
27
41
  // Other sessions have independent queues and can continue normally.
28
42
  const delay = Math.min(retryMs * 2 ** Math.min(queue.attempt++, 5), 30000);
@@ -41,6 +55,35 @@ export function createSessionUnreadRuntime({ store, loadSession, hub, resolveDir
41
55
  if (pending) drain(id, pending);
42
56
  });
43
57
  };
58
+ const enqueue = (payload, id, kind, retry = true) => {
59
+ const queue = queues.get(id) ?? { items: [], timer: null, attempt: 0 };
60
+ if (!retry && queue.timer) return Promise.reject(new Error('Session identity retry pending'));
61
+ queues.set(id, queue);
62
+ const completion = new Promise((resolve, reject) => {
63
+ queue.items.push({ payload, id, kind, retry, resolve, reject });
64
+ });
65
+ drain(id, queue);
66
+ return completion;
67
+ };
68
+ const reconcileStored = () => {
69
+ if (reconciliation) return reconciliation;
70
+ if (!unreconciled.size) return Promise.resolve();
71
+ const ids = [...unreconciled];
72
+ let cursor = 0;
73
+ let failed = false;
74
+ reconciliation = Promise.all(Array.from({ length: Math.min(4, ids.length) }, async () => {
75
+ while (!disposed && cursor < ids.length) {
76
+ const id = ids[cursor++];
77
+ try {
78
+ await enqueue({}, id, 'refresh', false);
79
+ unreconciled.delete(id);
80
+ } catch { failed = true; }
81
+ }
82
+ })).then(() => {
83
+ if (failed) throw new Error('Stored session identity unavailable');
84
+ }).finally(() => { reconciliation = null; });
85
+ return reconciliation;
86
+ };
44
87
  const processEvent = (envelope) => {
45
88
  const raw = envelope?.payload ?? envelope;
46
89
  const payload = raw?.payload ?? raw;
@@ -51,15 +94,10 @@ export function createSessionUnreadRuntime({ store, loadSession, hub, resolveDir
51
94
  const kind = type === 'session.execution.started' || (type === 'session.status' && body.status?.type === 'busy') ? 'running'
52
95
  : type === 'session.execution.succeeded' || type === 'session.idle' ? 'complete'
53
96
  : type === 'session.execution.failed' || type === 'session.error' ? 'error'
54
- : type === 'session.deleted' ? 'deleted' : null;
97
+ : type === 'session.deleted' ? 'deleted'
98
+ : type === 'session.metadata.updated' || type === 'session.updated' || type === 'yuri:session-metadata' ? 'refresh' : null;
55
99
  if (!kind || disposed) return Promise.resolve();
56
- const queue = queues.get(id) ?? { items: [], timer: null, attempt: 0 };
57
- queues.set(id, queue);
58
- const completion = new Promise(resolve => {
59
- queue.items.push({ payload, id, kind, resolve });
60
- });
61
- drain(id, queue);
62
- return completion;
100
+ return enqueue(payload, id, kind);
63
101
  };
64
102
  const unsubscribe = hub?.subscribeEvent(event => {
65
103
  void processEvent(event).catch(() => console.warn('[session-unread] lifecycle update failed'));
@@ -67,8 +105,8 @@ export function createSessionUnreadRuntime({ store, loadSession, hub, resolveDir
67
105
  return {
68
106
  processEvent,
69
107
  registerRoutes(app) {
70
- app.get('/api/yuri/session-unread', (_req, res) => {
71
- try { res.json(store.snapshot()); }
108
+ app.get('/api/yuri/session-unread', async (_req, res) => {
109
+ try { await reconcileStored(); res.json(store.snapshot()); }
72
110
  catch { res.status(503).json({ error: 'Session unread state unavailable' }); }
73
111
  });
74
112
  app.put('/api/yuri/session-unread/:id', express.json({ limit: '8kb' }), async (req, res) => {
@@ -11,10 +11,12 @@ import { createSessionUnreadRuntime } from './session-unread-runtime.js';
11
11
  const cleanup = [];
12
12
  afterEach(async () => { for (const close of cleanup.splice(0).reverse()) await close(); });
13
13
  const fixture = (options = {}) => {
14
+ const { seed, ...runtimeOptions } = options;
14
15
  const changed = vi.fn();
15
16
  const store = createSessionUnreadStore({ dbPath: ':memory:', onChanged: changed });
17
+ seed?.(store);
16
18
  const loadSession = vi.fn(async id => ({ id, title: 'Conversation', location: { directory: '/project' } }));
17
- const runtime = createSessionUnreadRuntime({ store, loadSession, ...options });
19
+ const runtime = createSessionUnreadRuntime({ store, loadSession, ...runtimeOptions });
18
20
  cleanup.push(() => runtime.close());
19
21
  const event = (type, sessionID = 'one', created = undefined, seq = undefined) => runtime.processEvent({
20
22
  payload: { type, data: { sessionID }, created, ...(seq ? { durable: { seq } } : {}) },
@@ -25,6 +27,116 @@ const fixture = (options = {}) => {
25
27
  };
26
28
 
27
29
  describe('shared session unread', () => {
30
+ it('excludes explicitly linked CLI workers without guessing from titles or agent names', async () => {
31
+ const { store, event, loadSession, app } = fixture();
32
+ loadSession.mockImplementation(async id => ({ id, title: 'Worker', agent: 'general', directory: '/project',
33
+ metadata: { yuri: { worker: { parentSessionID: id === 'worker' ? 'root' : '' } } },
34
+ }));
35
+ await event('session.execution.succeeded', 'worker');
36
+ await event('session.execution.failed', 'worker');
37
+ expect((await request(app).put('/api/yuri/session-unread/worker').send({ unread: true })).status).toBe(400);
38
+ await event('session.execution.succeeded', 'ordinary');
39
+ expect(Object.keys(store.snapshot().sessions)).toEqual(['ordinary']);
40
+ });
41
+
42
+ it('reconciles persisted child/worker attention once and retains unread state for ordinary roots', async () => {
43
+ const { app, store, loadSession } = fixture({ seed: store => {
44
+ for (const id of ['child', 'worker', 'missing', 'root']) store.mark({ id, directory: '/project', unread: true });
45
+ } });
46
+ loadSession.mockImplementation(async id => id === 'missing' ? null : ({ id, directory: '/project',
47
+ ...(id === 'child' ? { parentID: 'root' } : {}),
48
+ ...(id === 'worker' ? { metadata: { yuri: { worker: { parentSessionID: 'root' } } } } : {}),
49
+ }));
50
+ const first = await request(app).get('/api/yuri/session-unread');
51
+ expect(first.status).toBe(200);
52
+ expect(Object.keys(first.body.sessions)).toEqual(['root']);
53
+ expect(first.body.sessions.root).toMatchObject({ unreadCount: 1, manual: true });
54
+ expect(store.snapshot()).toEqual(first.body);
55
+ expect((await request(app).get('/api/yuri/session-unread')).body).toEqual(first.body);
56
+ expect(loadSession).toHaveBeenCalledTimes(4);
57
+ });
58
+
59
+ it('preserves failed startup identities, repairs independent rows, and retries only the failed row', async () => {
60
+ const { app, store, loadSession } = fixture({ seed: store => {
61
+ for (const id of ['child', 'root']) store.mark({ id, unread: true });
62
+ } });
63
+ loadSession.mockImplementation(async id => {
64
+ if (id === 'root') throw new Error('temporarily unavailable');
65
+ return { id, parentID: 'root' };
66
+ });
67
+ expect((await request(app).get('/api/yuri/session-unread')).status).toBe(503);
68
+ expect(Object.keys(store.snapshot().sessions)).toEqual(['root']);
69
+ loadSession.mockResolvedValue({ id: 'root', directory: '/project' });
70
+ expect((await request(app).get('/api/yuri/session-unread')).body.sessions.root.unreadCount).toBe(1);
71
+ expect(loadSession.mock.calls.map(([id]) => id)).toEqual(['child', 'root', 'root']);
72
+ });
73
+
74
+ it('removes prior attention when authoritative metadata makes a session hidden without a new completion', async () => {
75
+ const { event, store, loadSession, changed } = fixture();
76
+ await event('session.execution.succeeded');
77
+ loadSession.mockResolvedValue({ id: 'one', metadata: { yuri: { worker: { parentSessionID: 'root' } } } });
78
+ await event('session.metadata.updated');
79
+ expect(store.snapshot().sessions.one).toBeUndefined();
80
+ expect(changed).toHaveBeenCalledTimes(2);
81
+ await event('session.execution.succeeded');
82
+ expect(store.snapshot().sessions.one).toBeUndefined();
83
+ });
84
+
85
+ it('coalesces startup snapshots, caps identity reads at four, and performs no warm snapshot reads', async () => {
86
+ const { app, loadSession } = fixture({ seed: store => {
87
+ for (let i = 0; i < 24; i++) store.mark({ id: `session-${i}`, unread: true });
88
+ store.mark({ id: 'already-read', unread: true });
89
+ const revision = store.snapshot().sessions['already-read'].revision;
90
+ store.mark({ id: 'already-read', unread: false, expectedRevision: revision });
91
+ } });
92
+ let active = 0;
93
+ let peak = 0;
94
+ loadSession.mockImplementation(async id => {
95
+ peak = Math.max(peak, ++active);
96
+ await new Promise(resolve => setTimeout(resolve, 1));
97
+ active--;
98
+ return { id, directory: '/project' };
99
+ });
100
+ const snapshots = await Promise.all([request(app).get('/api/yuri/session-unread'), request(app).get('/api/yuri/session-unread')]);
101
+ expect(snapshots.map(result => result.status)).toEqual([200, 200]);
102
+ expect(peak).toBe(4);
103
+ expect(loadSession).toHaveBeenCalledTimes(24);
104
+ await request(app).get('/api/yuri/session-unread');
105
+ expect(loadSession).toHaveBeenCalledTimes(24);
106
+ });
107
+
108
+ it('returns retryable snapshot failure rather than waiting forever behind a failed lifecycle boundary', async () => {
109
+ const { app, event, loadSession, store } = fixture({ seed: store => store.mark({ id: 'one', unread: true }) });
110
+ loadSession.mockRejectedValue(new Error('offline'));
111
+ void event('session.execution.started');
112
+ expect((await request(app).get('/api/yuri/session-unread')).status).toBe(503);
113
+ expect(store.snapshot().sessions.one.unreadCount).toBe(1);
114
+ });
115
+
116
+ it('keeps persisted unread and revision on cleanup write failure, then repairs only that row on retry', async () => {
117
+ const dir = fs.mkdtempSync(path.join(os.tmpdir(), 'yuri-unread-repair-'));
118
+ cleanup.push(() => fs.rmSync(dir, { recursive: true, force: true }));
119
+ const dbPath = path.join(dir, 'state.sqlite');
120
+ const store = createSessionUnreadStore({ dbPath });
121
+ store.mark({ id: 'worker', unread: true });
122
+ store.mark({ id: 'root', unread: true });
123
+ const previous = store.snapshot();
124
+ const loadSession = vi.fn(async id => ({ id, ...(id === 'worker' ? { parentID: 'root' } : {}) }));
125
+ const runtime = createSessionUnreadRuntime({ store, loadSession });
126
+ cleanup.push(() => runtime.close());
127
+ const app = express();
128
+ runtime.registerRoutes(app);
129
+ const Database = createRequire(import.meta.url)('better-sqlite3');
130
+ const db = new Database(dbPath);
131
+ cleanup.push(() => db.close());
132
+ db.exec("CREATE TRIGGER reject_cleanup BEFORE DELETE ON session_unread BEGIN SELECT RAISE(ABORT, 'write failed'); END");
133
+ expect((await request(app).get('/api/yuri/session-unread')).status).toBe(503);
134
+ expect(store.snapshot()).toEqual(previous);
135
+ db.exec('DROP TRIGGER reject_cleanup');
136
+ expect(Object.keys((await request(app).get('/api/yuri/session-unread')).body.sessions)).toEqual(['root']);
137
+ expect(loadSession.mock.calls.map(([id]) => id)).toEqual(['worker', 'root', 'worker']);
138
+ });
139
+
28
140
  it('records completion with no clients, deduplicates succeeded/idle, and rearms on a new run', async () => {
29
141
  const { store, event, changed } = fixture();
30
142
  await event('session.execution.succeeded');
@@ -1,6 +1,7 @@
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
3
  import { REMOTE_CONNECTIONS_SKILL_PATH } from '../gui-customization/remote-connections.js';
4
+ import { PROJECTS_SKILL_PATH } from '../gui-customization/projects.js';
4
5
  import { MESSAGE_QUEUE_ADMISSION_HTTP_MAX_BYTES } from '../message-queue/service.js';
5
6
 
6
7
  const parseLoopbackUrl = (rawUrl) => {
@@ -660,7 +661,7 @@ export const registerAuthAndAccessRoutes = (app, dependencies) => {
660
661
  }
661
662
  return res.status(403).json({ error: 'Forbidden' });
662
663
  }
663
- if (normalizedRequestPathname === SCHEDULED_TASK_SKILL_PATH || normalizedRequestPathname === REMOTE_CONNECTIONS_SKILL_PATH) {
664
+ if (normalizedRequestPathname === SCHEDULED_TASK_SKILL_PATH || normalizedRequestPathname === REMOTE_CONNECTIONS_SKILL_PATH || normalizedRequestPathname === PROJECTS_SKILL_PATH) {
664
665
  if (authorizeScheduledTaskSkillRequest(req, getScheduledTaskSkillAuthHeaders())) return next();
665
666
  return res.status(403).json({ error: 'Forbidden' });
666
667
  }
@@ -1,5 +1,6 @@
1
1
  import { registerFsRoutes } from '../fs/routes.js';
2
2
  import { registerRemoteConnectionsSkill } from '../gui-customization/remote-connections.js';
3
+ import { registerProjectsSkill } from '../gui-customization/projects.js';
3
4
  import { registerQuotaRoutes } from '../quota/routes.js';
4
5
  import { registerSmallModelRoutes } from '../small-model/routes.js';
5
6
  import { registerSessionMetadataRoutes } from '../session-metadata/routes.js';
@@ -303,6 +304,11 @@ export const createFeatureRoutesRuntime = (dependencies) => {
303
304
  };
304
305
  await refreshAssistantAllowedRoots();
305
306
  const projectRegistry = createProjectRegistry({ persistSettings, validateDirectoryPath });
307
+ registerProjectsSkill(app, {
308
+ express, getIsSharedOpenCodeService, getOpenCodeAuthHeaders,
309
+ createClient: () => makeOpenCodeV2Client({ baseUrl: buildOpenCodeUrl('/', ''), authHeaders: getOpenCodeAuthHeaders(), getRuntimeContract }),
310
+ registerProject: (input) => projectRegistry.register(input), readSettingsFromDiskStrict, sanitizeProjects,
311
+ });
306
312
  historyImportRuntime = registerHistoryImportRoutes(app, {
307
313
  express, uiAuthController, dataDir: yuriDataDir,
308
314
  createClient: () => makeOpenCodeV2Client({ baseUrl: buildOpenCodeUrl('/', ''), authHeaders: getOpenCodeAuthHeaders(), getRuntimeContract }),
@@ -3,6 +3,10 @@ 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('wires session project registration to the shared registry and strict settings reader', async () => {
7
+ const routes = await fs.readFile(new URL('./feature-routes-runtime.js', import.meta.url), 'utf8');
8
+ expect(routes).toMatch(/registerProjectsSkill\(app, \{[\s\S]*?registerProject: \(input\) => projectRegistry.register\(input\), readSettingsFromDiskStrict, sanitizeProjects/);
9
+ });
6
10
  it('passes the native connection adapter to shared-session admission and the protected bridge', async () => {
7
11
  const host = await fs.readFile(new URL('../../index.js', import.meta.url), 'utf8');
8
12
  const routes = await fs.readFile(new URL('./feature-routes-runtime.js', import.meta.url), 'utf8');
@@ -2,8 +2,8 @@
2
2
 
3
3
  `registry.js` owns registering existing directories. It reuses `validateDirectoryPath`, deterministic
4
4
  path-derived IDs and the settings runtime's serialized persistence. The existing
5
- `POST /api/opencode/directory` API and assistant business tools share this owner.
6
- The HTTP API still selects the active directory; assistant registration does not
5
+ `POST /api/opencode/directory` API, the session-bound project API bridge and assistant business tools share this owner.
6
+ The UI directory API still selects the active directory; session/assistant registration does not
7
7
  change an existing active selection. The first registered project becomes active
8
8
  through the existing settings invariant.
9
9
 
@@ -21,7 +21,10 @@ normalization, migration, atomic write and project-order SSE notification paths.
21
21
  Unlike full-list UI replacement, this form does not sweep other projects for
22
22
  missing directories: callers validate the affected resource. Corrupt reads and
23
23
  failed writes are errors, not empty state or successful registration. No new
24
- database, settings file, HTTP mutation surface or client sync protocol is added.
24
+ database, settings file or client sync protocol is added. The session skill's
25
+ `POST /api/yuri/session-skills/projects` bridge adds authenticated `describe`,
26
+ `list` and `add` operations without exposing the full settings API; its admission
27
+ and result contract live in `../gui-customization/DOCUMENTATION.md`.
25
28
 
26
29
  `registry.test.js` covers canonical alias deduplication, concurrent append/settings
27
30
  writes, persistence, offline-project retention, corrupt
@@ -87,7 +87,8 @@ export const registerScheduledTaskSessionSkill = (app, {
87
87
  key: SCHEDULED_TASK_SKILL_KEY,
88
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.`,
89
89
  });
90
- await installCustomization(client, created.id, remoteConnectionsAdapter ? { hostOrigin, upstreamOrigin, registrationFile } : undefined);
90
+ const projectBinding = { hostOrigin, upstreamOrigin, registrationFile };
91
+ await installCustomization(client, created.id, { projectBinding, ...(remoteConnectionsAdapter ? { remoteBinding: projectBinding } : {}) });
91
92
  return res.json({ data: created });
92
93
  } catch {
93
94
  let retainedSessionID = created?.id;
@@ -13,9 +13,10 @@ import { registerScheduledTaskRoutes } from './routes.js';
13
13
  import { registerScheduledTaskSessionSkill } from './session-skill.js';
14
14
  import { authorizeScheduledTaskSkillRequest, SCHEDULED_TASK_SKILL_PATH } from './session-skill-contract.js';
15
15
  import { registerRemoteConnectionsSkill, REMOTE_CONNECTIONS_SKILL_PATH } from '../gui-customization/remote-connections.js';
16
+ import { registerProjectsSkill, PROJECTS_SKILL_PATH } from '../gui-customization/projects.js';
16
17
 
17
18
  describe('built-in session skill with authenticated Host', () => {
18
- let root, server, origin, ui, sessions, entries, store, password, auth, registrationFile, sdk, sync, failInstructions, failCleanup, connections;
19
+ let root, server, origin, ui, sessions, entries, store, password, auth, registrationFile, sdk, sync, failInstructions, failCleanup, connections, registerProject;
19
20
  const upstreamOrigin = 'http://127.0.0.1:4096';
20
21
  beforeEach(async () => {
21
22
  root = await fs.mkdtemp(path.join(os.tmpdir(), 'session-skill-'));
@@ -66,6 +67,9 @@ describe('built-in session skill with authenticated Host', () => {
66
67
  buildOpenCodeUrl: () => upstreamOrigin, getOpenCodeAuthHeaders: () => auth,
67
68
  };
68
69
  const router = express.Router();
70
+ registerProject = vi.fn(async (input) => ({ project: { id: 'registered', ...input }, created: true, settings: { password } }));
71
+ registerProjectsSkill(app, { express, getIsSharedOpenCodeService: () => true, getOpenCodeAuthHeaders: () => auth, createClient: () => sdk,
72
+ registerProject, readSettingsFromDiskStrict: common.readSettingsFromDiskMigrated, sanitizeProjects: common.sanitizeProjects });
69
73
  connections = { list: vi.fn(async () => ({ instances: [] })), setup: vi.fn(async () => ({ id: 'ssh_one', running: true })),
70
74
  pair: vi.fn(async () => ({ url: 'yuri://connect?v=2&p=fixture', expiresAt: '2099-01-01' })) };
71
75
  registerRemoteConnectionsSkill(app, { express, adapter: connections, getIsSharedOpenCodeService: () => true, getOpenCodeAuthHeaders: () => auth, createClient: () => sdk });
@@ -191,6 +195,35 @@ describe('built-in session skill with authenticated Host', () => {
191
195
  expect(connections.setup).toHaveBeenCalledTimes(1);
192
196
  });
193
197
 
198
+ it('executes the exact staged project API helper and refuses browser credentials or changed Host/service bindings', async () => {
199
+ const session = await create();
200
+ const pointer = entries.get(`${session.id}:customization`);
201
+ const command = pointer.split('Bound project helper: ')[1].split('\n')[0];
202
+ const described = await run(command);
203
+ expect(described.code).toBe(0);
204
+ expect(described.value.supported).toBe(true);
205
+ expect(Object.keys(described.value.commands)).toEqual(['list', 'add']);
206
+ const { commands: cmd } = described.value;
207
+ expect((await run(cmd.list)).value.projects).toHaveLength(2);
208
+ const input = { path: path.join(root, 'project-b'), label: 'Existing project' };
209
+ const added = await run(cmd.add, input);
210
+ expect(added.value).toEqual({ project: { id: 'registered', ...input }, created: true });
211
+ expect(registerProject).toHaveBeenCalledExactlyOnceWith(input);
212
+ expect(added.stdout + pointer).not.toContain(password);
213
+ for (const headers of [{}, { Authorization: 'Bearer test-browser-client' }, { ...auth, Origin: origin }, { Authorization: 'Basic wrong' }]) {
214
+ const response = await fetch(`${origin}${PROJECTS_SKILL_PATH}`, { method: 'POST', headers: { 'content-type': 'application/json', ...headers }, body: JSON.stringify({ sessionID: session.id, operation: 'add', input }) });
215
+ expect(response.status).toBe(403);
216
+ }
217
+ sessions.get(session.id).metadata.yuri.scheduledTaskSkill.hostOrigin = 'http://127.0.0.1:1';
218
+ expect((await run(cmd.add, input)).value).toMatchObject({ status: 403, terminal: true });
219
+ expect(registerProject).toHaveBeenCalledTimes(1);
220
+ await fs.writeFile(registrationFile, JSON.stringify({ url: 'http://127.0.0.1:1', password }));
221
+ const stale = await run(cmd.add, input);
222
+ expect(stale.value.terminal).toBe(true);
223
+ expect(stale.stdout + stale.stderr).not.toContain(password);
224
+ expect(registerProject).toHaveBeenCalledTimes(1);
225
+ });
226
+
194
227
  it('rejects unbounded connection input and sanitizes remote errors', async () => {
195
228
  const session = await create();
196
229
  const request = (operation, input) => fetch(`${origin}${REMOTE_CONNECTIONS_SKILL_PATH}`, { method: 'POST',
@@ -96,7 +96,10 @@ the index excludes them from every snapshot and clears prior summaries when a
96
96
  coding workers the Assistant subscribed to),
97
97
  `metadata.yuri.scheduledTask.taskID`,
98
98
  `metadata.yuri.smallModel.purpose`, or
99
- `metadata.yuri.llm.purpose`. Metadata remains the ownership/isolation signal;
99
+ `metadata.yuri.llm.purpose`, or `metadata.yuri.worker.parentSessionID`.
100
+ Native `session.metadata.updated` removes newly hidden summaries and pins
101
+ immediately; ordinary metadata-only updates do not fabricate partial rows.
102
+ Metadata remains the ownership/isolation signal;
100
103
  reserved title tags are a separate background-list exclusion rule.
101
104
  `time.archived` is archive state (Host authority via
102
105
  `metadata.yuri.archive.archivedAt` when present — see