@xopcai/xopc 0.0.218 → 0.0.220

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 (342) hide show
  1. package/dist/browser-ext/manifest.json +1 -1
  2. package/dist/extensions/telegram/xopc.extension.json +1 -1
  3. package/dist/gateway/static/root/assets/{activity-store-DF2dYXG1.js → activity-store-DeKZ36Jy.js} +1 -1
  4. package/dist/gateway/static/root/assets/{agent-avatar-dicebear-Dw9rF5o1.js → agent-avatar-dicebear-D0hZfdkn.js} +1 -1
  5. package/dist/gateway/static/root/assets/agents-Bu0NfWuh.js +68 -0
  6. package/dist/gateway/static/root/assets/{api-_H0Bam-t.js → api-yLnYUedB.js} +1 -1
  7. package/dist/gateway/static/root/assets/app-management-settings-panel-C2kZNEHz.js +1 -0
  8. package/dist/gateway/static/root/assets/appearance-settings-DQ7H35sN.js +1 -0
  9. package/dist/gateway/static/root/assets/apps-page-Tty2xaUG.js +1 -0
  10. package/dist/gateway/static/root/assets/{archive-plugin-DZCOhXch.js → archive-plugin-CBArbTPH.js} +1 -1
  11. package/dist/gateway/static/root/assets/{attachment-load-Bjb0FH2B.js → attachment-load-oc6DRj4G.js} +1 -1
  12. package/dist/gateway/static/root/assets/{automations-page-D4N3ZDhu.js → automations-page-CHPEUpz8.js} +1 -1
  13. package/dist/gateway/static/root/assets/automations-workspace-9uYkHmdI.js +6 -0
  14. package/dist/gateway/static/root/assets/{binary-plugins-uXPt0s47.js → binary-plugins-BRBd0X7_.js} +1 -1
  15. package/dist/gateway/static/root/assets/{block-editor-gukkIEro.js → block-editor-ZgM-Z4Qv.js} +47 -47
  16. package/dist/gateway/static/root/assets/browser-settings-page-BT3mEm00.js +8 -0
  17. package/dist/gateway/static/root/assets/{browser-workflow-inputs-DAhdS-XZ.js → browser-workflow-inputs-DxD74a4c.js} +1 -1
  18. package/dist/gateway/static/root/assets/{browser-workflows-page-LKjYzXS_.js → browser-workflows-page-Dpc7NqZf.js} +2 -2
  19. package/dist/gateway/static/root/assets/capabilities-settings-panel-DHlfRj4M.js +7 -0
  20. package/dist/gateway/static/root/assets/{capability-presets-api-BBUkH833.js → capability-presets-api-B9ID97j6.js} +1 -1
  21. package/dist/gateway/static/root/assets/capability-presets-settings-panel-D2FkREUX.js +3 -0
  22. package/dist/gateway/static/root/assets/{channel-recipient-api-E5mo8M3a.js → channel-recipient-api-DCNn6MWL.js} +1 -1
  23. package/dist/gateway/static/root/assets/channels-settings-D4YcKMtf.js +1 -0
  24. package/dist/gateway/static/root/assets/channels-status-swr-B8XWrzKM.js +1 -0
  25. package/dist/gateway/static/root/assets/chat-terminal-dock-MvNpjcUs.js +36 -0
  26. package/dist/gateway/static/root/assets/connectors-page-Bd6K9bDk.js +2 -0
  27. package/dist/gateway/static/root/assets/{cron-expression-BGNuaqvI.js → cron-expression-BSXX9uY0.js} +1 -1
  28. package/dist/gateway/static/root/assets/{date-picker-k7mkklMU.js → date-picker-CiHNkkIS.js} +1 -1
  29. package/dist/gateway/static/root/assets/dependency-picker-DQyh2ZXE.js +1 -0
  30. package/dist/gateway/static/root/assets/{desktop-pet-p9EZyGzV.js → desktop-pet-DnAHU-zA.js} +1 -1
  31. package/dist/gateway/static/root/assets/desktop-pet-settings-DUdhIBBB.js +1 -0
  32. package/dist/gateway/static/root/assets/directory-picker-path-field-B3gFQt8x.js +1 -0
  33. package/dist/gateway/static/root/assets/ellipsis-0k4rZLoy.js +1 -0
  34. package/dist/gateway/static/root/assets/{extension-debug-page-Cd4BMKm_.js → extension-debug-page-Lq-gRApw.js} +1 -1
  35. package/dist/gateway/static/root/assets/{extension-page-CzEGCkOa.js → extension-page-D0ROxJmY.js} +1 -1
  36. package/dist/gateway/static/root/assets/extension-settings-page-B2tS6mFy.js +1 -0
  37. package/dist/gateway/static/root/assets/eye-CABVeTq0.js +1 -0
  38. package/dist/gateway/static/root/assets/eye-off-DEAzt3g1.js +1 -0
  39. package/dist/gateway/static/root/assets/file-code-corner-byQA1VfD.js +1 -0
  40. package/dist/gateway/static/root/assets/form-field-width-DJw_jULe.js +1 -0
  41. package/dist/gateway/static/root/assets/gateway-config-api-DJqWfVi6.js +1 -0
  42. package/dist/gateway/static/root/assets/{gateway-config-swr-DNrttVr2.js → gateway-config-swr-CnwF9Vso.js} +1 -1
  43. package/dist/gateway/static/root/assets/gateway-settings-B3thenPX.js +1 -0
  44. package/dist/gateway/static/root/assets/{gateway-startup-retry-B1vD3vRb.js → gateway-startup-retry-DdJJZR8M.js} +1 -1
  45. package/dist/gateway/static/root/assets/heartbeat-settings-C_g-ZGSE.js +1 -0
  46. package/dist/gateway/static/root/assets/home-page-Cgwx66kc.js +1 -0
  47. package/dist/gateway/static/root/assets/{image-generation-api-BTR0Wk_k.js → image-generation-api-Dtt9M5qz.js} +1 -1
  48. package/dist/gateway/static/root/assets/index-Cf0qTkBK.css +2 -0
  49. package/dist/gateway/static/root/assets/index-V9g9-SWT.js +108 -0
  50. package/dist/gateway/static/root/assets/interaction-BmQogeqz.js +1 -0
  51. package/dist/gateway/static/root/assets/is-masked-secret-DOkL5b_X.js +1 -0
  52. package/dist/gateway/static/root/assets/{keyboard-shortcuts-settings-CYlS4RGA.js → keyboard-shortcuts-settings-cJqkmQdP.js} +1 -1
  53. package/dist/gateway/static/root/assets/local-app-workbench-page-CmjLMdly.js +2 -0
  54. package/dist/gateway/static/root/assets/{local-apps-page-CNppYVew.js → local-apps-page-BiuP2pkl.js} +1 -1
  55. package/dist/gateway/static/root/assets/{locale-store-gf9Bg2gb.js → locale-store-D3Q2yEAb.js} +1 -1
  56. package/dist/gateway/static/root/assets/logs-page-BTlxGPho.js +2 -0
  57. package/dist/gateway/static/root/assets/{management-settings-IYk9xLgt.js → management-settings-Z1gJUwP_.js} +1 -1
  58. package/dist/gateway/static/root/assets/{markdown-split-D8e6pRMH.js → markdown-split-DuOmpGgE.js} +1 -1
  59. package/dist/gateway/static/root/assets/{markdown-view-D0fiJjBQ.js → markdown-view-WYArkdrc.js} +1 -1
  60. package/dist/gateway/static/root/assets/{media-plugins-CCq6TtEf.js → media-plugins-DKPh3Mud.js} +1 -1
  61. package/dist/gateway/static/root/assets/messages-BQHpB4VI.js +3 -0
  62. package/dist/gateway/static/root/assets/{notes-api-BBtWnlUU.js → notes-api-DMEon7Zv.js} +1 -1
  63. package/dist/gateway/static/root/assets/{notes-page-BKe1xa3U.js → notes-page-BG4gV8WG.js} +1 -1
  64. package/dist/gateway/static/root/assets/notes-workbench-D3LMBO2X.js +4 -0
  65. package/dist/gateway/static/root/assets/page-tabs-BaEQMYm_.js +1 -0
  66. package/dist/gateway/static/root/assets/preview-open-alternatives-CsNVTKC0.js +1 -0
  67. package/dist/gateway/static/root/assets/{product-open-page-DXe5iWI6.js → product-open-page-BjJf4QOB.js} +1 -1
  68. package/dist/gateway/static/root/assets/project-detail-page-C59tYJG-.js +1 -0
  69. package/dist/gateway/static/root/assets/projects-page-Di7W-Fg8.js +1 -0
  70. package/dist/gateway/static/root/assets/{registry-api-xj5gOva_.js → registry-api-DRyvynb5.js} +1 -1
  71. package/dist/gateway/static/root/assets/remote-access-hub-BYOKveWT.js +1 -0
  72. package/dist/gateway/static/root/assets/rotate-cw-LIg3Am9S.js +1 -0
  73. package/dist/gateway/static/root/assets/{runtime-tools-settings-panel-BJTvmBCA.js → runtime-tools-settings-panel-DC6t_-db.js} +2 -2
  74. package/dist/gateway/static/root/assets/{schema-form-DvGBa_7R.js → schema-form-DSTWtpjp.js} +1 -1
  75. package/dist/gateway/static/root/assets/search-DA7gz22f.js +1 -0
  76. package/dist/gateway/static/root/assets/sessions-page-CJMNQsxK.js +1 -0
  77. package/dist/gateway/static/root/assets/settings-advanced-gate-FJxZw08y.js +1 -0
  78. package/dist/gateway/static/root/assets/settings-form-section-ZzEMNLYS.js +1 -0
  79. package/dist/gateway/static/root/assets/{settings-loading-skeleton-sbef7GTm.js → settings-loading-skeleton-D7-bkbcW.js} +1 -1
  80. package/dist/gateway/static/root/assets/{settings-page-BNGxxXZe.js → settings-page-PaTpLbmi.js} +1 -1
  81. package/dist/gateway/static/root/assets/setup-status-panel-Bnpim6NY.js +1 -0
  82. package/dist/gateway/static/root/assets/{share-preview-page-C1523ij3.js → share-preview-page-Cxcw0ksa.js} +1 -1
  83. package/dist/gateway/static/root/assets/shares-settings-DBqmV7ZY.js +1 -0
  84. package/dist/gateway/static/root/assets/skill-reload-api-UgLQaWoz.js +1 -0
  85. package/dist/gateway/static/root/assets/skills-page-Dby4iAYe.js +2 -0
  86. package/dist/gateway/static/root/assets/{skills-page.utils-Ditgz7Vo.js → skills-page.utils-nlzJ5Y1V.js} +1 -1
  87. package/dist/gateway/static/root/assets/system-settings-panel-vOsgnzDl.js +1 -0
  88. package/dist/gateway/static/root/assets/task-detail-page-CRy8Wl5g.js +1 -0
  89. package/dist/gateway/static/root/assets/{theme-store-DgSjes3O.js → theme-store-CvnEHGyP.js} +1 -1
  90. package/dist/gateway/static/root/assets/typed-models-lib-q5-Vfqd8.js +1 -0
  91. package/dist/gateway/static/root/assets/{use-autosave-Bp_qFZkl.js → use-autosave-BTNZHulv.js} +1 -1
  92. package/dist/gateway/static/root/assets/user-context-page-BT8F4mh5.js +1 -0
  93. package/dist/gateway/static/root/assets/{voice-api-key-field-hbzDfErG.js → voice-api-key-field-DDJ2-3Tx.js} +1 -1
  94. package/dist/gateway/static/root/assets/{work-discovery-overlay-DZVib-04.js → work-discovery-overlay-DV_qiKSD.js} +1 -1
  95. package/dist/gateway/static/root/assets/{workflow-run-setup-panel-C2RKay1p.js → workflow-run-setup-panel--AcvRw1w.js} +2 -2
  96. package/dist/gateway/static/root/assets/workflows-page-CwvskVvU.js +5 -0
  97. package/dist/gateway/static/root/index.html +21 -12
  98. package/dist/package.js +1 -1
  99. package/dist/packages/gateway-contract/src/new-session.js +99 -0
  100. package/dist/packages/gateway-contract/src/tasks.js +5 -0
  101. package/dist/packages/gateway-contract/src/user-message-display.js +55 -0
  102. package/dist/src/agent/agent-manager.js +5 -4
  103. package/dist/src/agent/background-review/prompts.d.ts +1 -1
  104. package/dist/src/agent/background-review/prompts.js +2 -2
  105. package/dist/src/agent/background-review/run-background-review.js +144 -16
  106. package/dist/src/agent/embedded/model-runtime.js +1 -1
  107. package/dist/src/agent/embedded/run-for-session.js +1 -1
  108. package/dist/src/agent/image/tool-model-config.js +1 -1
  109. package/dist/src/agent/inbound/turn-dispatcher.d.ts +3 -1
  110. package/dist/src/agent/inbound/turn-dispatcher.js +2 -1
  111. package/dist/src/agent/ipc/inbox.js +1 -1
  112. package/dist/src/agent/memory/context/types.d.ts +1 -1
  113. package/dist/src/agent/memory/manager.d.ts +2 -1
  114. package/dist/src/agent/memory/manager.js +2 -6
  115. package/dist/src/agent/memory/understanding/service.d.ts +1 -0
  116. package/dist/src/agent/memory/understanding/service.js +179 -36
  117. package/dist/src/agent/memory/understanding/types.d.ts +6 -0
  118. package/dist/src/agent/messaging/command-handler.d.ts +2 -0
  119. package/dist/src/agent/messaging/command-handler.js +3 -1
  120. package/dist/src/agent/service/direct-turn-helpers.d.ts +3 -0
  121. package/dist/src/agent/service/direct-turn-helpers.js +13 -3
  122. package/dist/src/agent/service/process-direct-streaming.d.ts +2 -1
  123. package/dist/src/agent/service/process-direct-streaming.js +12 -11
  124. package/dist/src/agent/service.js +2 -2
  125. package/dist/src/agent/session/session-config-service.d.ts +1 -0
  126. package/dist/src/agent/session/session-config-service.js +11 -0
  127. package/dist/src/agent/session/session-inspector.d.ts +1 -0
  128. package/dist/src/agent/session/session-inspector.js +2 -1
  129. package/dist/src/agent/skills/hub-lock.js +1 -1
  130. package/dist/src/agent/source-context/budget.d.ts +3 -0
  131. package/dist/src/agent/source-context/budget.js +21 -0
  132. package/dist/src/agent/source-context/index.js +3 -3
  133. package/dist/src/agent/source-context/injector.d.ts +2 -2
  134. package/dist/src/agent/source-context/injector.js +19 -9
  135. package/dist/src/agent/source-context/types.d.ts +16 -0
  136. package/dist/src/agent/source-context/types.js +25 -1
  137. package/dist/src/agent/tasks/task-judge-service.js +3 -3
  138. package/dist/src/agent/tool-manuals/xopc-use.d.ts +1 -1
  139. package/dist/src/agent/tool-manuals/xopc-use.js +19 -2
  140. package/dist/src/agent/tools/xopc-use-tool.js +62 -2
  141. package/dist/src/ai-assist/text-assist.js +1 -1
  142. package/dist/src/auth/credentials.js +2 -2
  143. package/dist/src/auth/profiles/store.js +1 -1
  144. package/dist/src/auth/sync-provider-auth.js +2 -2
  145. package/dist/src/browser/backend-from-config.d.ts +8 -0
  146. package/dist/src/browser/backend-from-config.js +16 -1
  147. package/dist/src/browser/providers/browser-ext-install.d.ts +3 -2
  148. package/dist/src/browser/providers/browser-ext-install.js +5 -3
  149. package/dist/src/chat-commands/builtins/review.js +11 -2
  150. package/dist/src/chat-commands/builtins/understanding.js +11 -4
  151. package/dist/src/chat-commands/types.d.ts +4 -0
  152. package/dist/src/cli/commands/doctor/checks/database-schema.js +1 -1
  153. package/dist/src/cli/commands/doctor/checks/provider-auth.js +1 -1
  154. package/dist/src/cli/commands/models.js +1 -1
  155. package/dist/src/config/index.js +4 -4
  156. package/dist/src/config/loader.js +1 -1
  157. package/dist/src/config/models-json.d.ts +20 -20
  158. package/dist/src/config/models-json.js +1 -1
  159. package/dist/src/connectors/connected-source-understanding.d.ts +1 -0
  160. package/dist/src/connectors/connected-source-understanding.js +87 -38
  161. package/dist/src/connectors/learning-coordinator.js +68 -13
  162. package/dist/src/extensions/lockfile.js +1 -1
  163. package/dist/src/gateway/agents-admin.js +1 -1
  164. package/dist/src/gateway/chat-stream/mapper.js +18 -0
  165. package/dist/src/gateway/file-path-classifier.js +1 -1
  166. package/dist/src/gateway/hono/lib/config-payload.js +1 -1
  167. package/dist/src/gateway/hono/routes/agent-stream.js +12 -2
  168. package/dist/src/gateway/hono/routes/commands-skills.js +1 -0
  169. package/dist/src/gateway/hono/routes/models.js +1 -1
  170. package/dist/src/gateway/hono/routes/session-input-handler.d.ts +46 -2
  171. package/dist/src/gateway/hono/routes/session-input-handler.js +23 -3
  172. package/dist/src/gateway/hono/routes/sessions.js +17 -20
  173. package/dist/src/gateway/hono/routes/tasks.js +25 -0
  174. package/dist/src/gateway/hono/routes/understanding-sources.d.ts +18 -0
  175. package/dist/src/gateway/hono/routes/understanding-sources.js +165 -36
  176. package/dist/src/gateway/hono/routes/work-discovery.js +13 -3
  177. package/dist/src/gateway/hono/routes/workflows.js +2 -2
  178. package/dist/src/gateway/hono/routes/you.js +71 -4
  179. package/dist/src/gateway/service/agent-runner.d.ts +11 -2
  180. package/dist/src/gateway/service/agent-runner.js +27 -1
  181. package/dist/src/gateway/service/config-coordinator.js +1 -1
  182. package/dist/src/gateway/service/run-gateway-agent.d.ts +2 -0
  183. package/dist/src/gateway/service/run-gateway-agent.js +15 -9
  184. package/dist/src/gateway/service/session-input-coordinator.d.ts +8 -2
  185. package/dist/src/gateway/service/session-input-coordinator.js +62 -3
  186. package/dist/src/gateway/service/sessions-api.d.ts +10 -0
  187. package/dist/src/gateway/service/sessions-api.js +3 -0
  188. package/dist/src/gateway/service.d.ts +3 -2
  189. package/dist/src/gateway/service.js +27 -16
  190. package/dist/src/gateway/user-turn-input.d.ts +2 -0
  191. package/dist/src/gateway/xopc-cloud-capability-setup.d.ts +3 -2
  192. package/dist/src/gateway/xopc-cloud-capability-setup.js +16 -3
  193. package/dist/src/knowledge/connected-knowledge-pipeline.d.ts +6 -0
  194. package/dist/src/knowledge/connected-knowledge-pipeline.js +35 -4
  195. package/dist/src/knowledge/connected-understanding-pipeline.d.ts +1 -1
  196. package/dist/src/knowledge/connected-understanding-pipeline.js +4 -2
  197. package/dist/src/providers/auth-runtime/resolve-auth.js +1 -1
  198. package/dist/src/providers/index.js +2 -2
  199. package/dist/src/providers/model-registry.js +1 -1
  200. package/dist/src/providers/register-runtime-providers.js +1 -1
  201. package/dist/src/retrieval/queryProfile.d.ts +3 -0
  202. package/dist/src/retrieval/queryProfile.js +20 -2
  203. package/dist/src/session/client-history.d.ts +11 -0
  204. package/dist/src/session/client-history.js +24 -2
  205. package/dist/src/session/config-types.d.ts +1 -1
  206. package/dist/src/session/session-title.js +2 -3
  207. package/dist/src/session/store.js +1 -0
  208. package/dist/src/session/transcript-outline.js +5 -2
  209. package/dist/src/session/types.d.ts +1 -0
  210. package/dist/src/session/user-message-display.d.ts +4 -0
  211. package/dist/src/session/user-message-display.js +22 -0
  212. package/dist/src/storage/sqlite/context-extraction-repository.d.ts +57 -0
  213. package/dist/src/storage/sqlite/context-extraction-repository.js +119 -0
  214. package/dist/src/storage/sqlite/context-relation-repository.d.ts +50 -0
  215. package/dist/src/storage/sqlite/context-relation-repository.js +97 -0
  216. package/dist/src/storage/sqlite/index.d.ts +6 -4
  217. package/dist/src/storage/sqlite/index.js +7 -5
  218. package/dist/src/storage/sqlite/knowledge-repository.d.ts +5 -1
  219. package/dist/src/storage/sqlite/knowledge-repository.js +16 -1
  220. package/dist/src/storage/sqlite/memory-records-repository.d.ts +2 -0
  221. package/dist/src/storage/sqlite/memory-records-repository.js +21 -1
  222. package/dist/src/storage/sqlite/migrations/126_focus_context_governance.sql +72 -0
  223. package/dist/src/storage/sqlite/migrations/127_context_object_origin.sql +36 -0
  224. package/dist/src/storage/sqlite/migrations/128_context_extraction.sql +73 -0
  225. package/dist/src/storage/sqlite/migrations/129_focus_versions.sql +51 -0
  226. package/dist/src/storage/sqlite/migrations/130_context_evidence_provenance.sql +18 -0
  227. package/dist/src/storage/sqlite/migrations/131_session_input_contexts.sql +2 -0
  228. package/dist/src/storage/sqlite/migrations/132_transcript_source_context_metadata.sql +34 -0
  229. package/dist/src/storage/sqlite/migrations/133_archive_legacy_work_discovery_profile_facts.sql +11 -0
  230. package/dist/src/storage/sqlite/migrations/runner.d.ts +1 -1
  231. package/dist/src/storage/sqlite/migrations/runner.js +3 -3
  232. package/dist/src/storage/sqlite/migrations/runner.ts +1 -1
  233. package/dist/src/storage/sqlite/schema.js +1 -1
  234. package/dist/src/storage/sqlite/session-input-repository.d.ts +8 -0
  235. package/dist/src/storage/sqlite/session-input-repository.js +19 -7
  236. package/dist/src/storage/sqlite/session-repository.js +2 -2
  237. package/dist/src/storage/sqlite/session-turn-replace-repository.d.ts +3 -0
  238. package/dist/src/storage/sqlite/session-turn-replace-repository.js +3 -2
  239. package/dist/src/storage/sqlite/transcript-repository.js +29 -3
  240. package/dist/src/storage/sqlite/user-context-repository.d.ts +4 -1
  241. package/dist/src/storage/sqlite/user-context-repository.js +65 -29
  242. package/dist/src/tasks/home-query-service.d.ts +14 -0
  243. package/dist/src/tasks/home-query-service.js +19 -2
  244. package/dist/src/tasks/index.d.ts +1 -0
  245. package/dist/src/tasks/index.js +2 -1
  246. package/dist/src/tasks/task-deletion-service.d.ts +21 -0
  247. package/dist/src/tasks/task-deletion-service.js +35 -0
  248. package/dist/src/tasks/task-repository.js +22 -1
  249. package/dist/src/tui/backends/embedded-backend.js +5 -3
  250. package/dist/src/tui/backends/gateway-realtime-backend.js +5 -3
  251. package/dist/src/tui/chat-history.js +2 -1
  252. package/dist/src/tui/tui-agent-events.js +4 -2
  253. package/dist/src/tui/tui-commands.d.ts +1 -0
  254. package/dist/src/tui/tui-commands.js +8 -3
  255. package/dist/src/tui/tui-empty-session-cleanup.d.ts +0 -1
  256. package/dist/src/tui/tui-empty-session-cleanup.js +1 -11
  257. package/dist/src/tui/tui-new-session-preferences.d.ts +10 -0
  258. package/dist/src/tui/tui-new-session-preferences.js +32 -0
  259. package/dist/src/tui/tui-session-actions.d.ts +1 -0
  260. package/dist/src/tui/tui-session-actions.js +2 -1
  261. package/dist/src/tui/tui-settings.d.ts +2 -0
  262. package/dist/src/tui/tui-settings.js +4 -1
  263. package/dist/src/tui/tui-startup-resources.js +1 -1
  264. package/dist/src/tui/tui-types.d.ts +1 -0
  265. package/dist/src/tui/tui.js +58 -5
  266. package/dist/src/tunnel/frpc-process.js +3 -0
  267. package/dist/src/tunnel/tunnel-service.d.ts +2 -0
  268. package/dist/src/tunnel/tunnel-service.js +40 -28
  269. package/dist/src/user-context/consolidation.d.ts +1 -0
  270. package/dist/src/user-context/consolidation.js +62 -2
  271. package/dist/src/user-context/context-objects.d.ts +17 -0
  272. package/dist/src/user-context/context-objects.js +99 -0
  273. package/dist/src/user-context/domain.d.ts +13 -1
  274. package/dist/src/user-context/evaluation/harness.d.ts +13 -0
  275. package/dist/src/user-context/evaluation/harness.js +31 -0
  276. package/dist/src/user-context/extraction/registry.d.ts +26 -0
  277. package/dist/src/user-context/extraction/registry.js +113 -0
  278. package/dist/src/user-context/extraction/repair.d.ts +19 -0
  279. package/dist/src/user-context/extraction/repair.js +68 -0
  280. package/dist/src/user-context/focus-lifecycle.d.ts +2 -0
  281. package/dist/src/user-context/focus-lifecycle.js +26 -0
  282. package/dist/src/user-context/planner.js +252 -62
  283. package/dist/src/user-context/retriever.js +69 -9
  284. package/dist/src/user-context/sources/index.js +2 -2
  285. package/dist/src/user-context/sources/processing-policy.d.ts +2 -0
  286. package/dist/src/user-context/sources/processing-policy.js +7 -0
  287. package/dist/src/user-context/sources/repository.d.ts +23 -4
  288. package/dist/src/user-context/sources/repository.js +122 -12
  289. package/dist/src/user-context/sources/types.d.ts +10 -1
  290. package/dist/src/user-context/understanding.js +1 -1
  291. package/dist/src/work-discovery/analyzer.js +6 -4
  292. package/dist/src/work-discovery/index.js +2 -2
  293. package/dist/src/work-discovery/service.d.ts +12 -3
  294. package/dist/src/work-discovery/service.js +183 -86
  295. package/dist/src/work-discovery/source-repository.d.ts +1 -0
  296. package/dist/src/work-discovery/source-repository.js +10 -4
  297. package/dist/src/work-discovery/types.d.ts +2 -1
  298. package/dist/src/workflows/service/workflow-run-service.js +1 -1
  299. package/package.json +3 -3
  300. package/dist/gateway/static/root/assets/agents-Dj86bHkl.js +0 -68
  301. package/dist/gateway/static/root/assets/app-management-settings-panel-D-M6GN-8.js +0 -1
  302. package/dist/gateway/static/root/assets/appearance-settings-XDhmzdIc.js +0 -1
  303. package/dist/gateway/static/root/assets/apps-page-sfO835uz.js +0 -1
  304. package/dist/gateway/static/root/assets/automations-workspace-PptuZgoo.js +0 -6
  305. package/dist/gateway/static/root/assets/browser-settings-page-BoCmzMFV.js +0 -8
  306. package/dist/gateway/static/root/assets/capabilities-settings-panel-DhkJsU8Z.js +0 -7
  307. package/dist/gateway/static/root/assets/capability-presets-settings-panel-Dm7T61fE.js +0 -3
  308. package/dist/gateway/static/root/assets/channels-settings-dG6UFVqt.js +0 -1
  309. package/dist/gateway/static/root/assets/channels-status-swr-DgJxfNyK.js +0 -1
  310. package/dist/gateway/static/root/assets/chat-terminal-dock-CT5yoSMD.js +0 -36
  311. package/dist/gateway/static/root/assets/connectors-page-BC6Ft9SU.js +0 -2
  312. package/dist/gateway/static/root/assets/dependency-picker-DZVSgLXH.js +0 -1
  313. package/dist/gateway/static/root/assets/desktop-pet-settings-Bw4cCFzI.js +0 -1
  314. package/dist/gateway/static/root/assets/directory-picker-path-field-Cbst7IXR.js +0 -1
  315. package/dist/gateway/static/root/assets/extension-settings-page-C1PAKSy2.js +0 -1
  316. package/dist/gateway/static/root/assets/gateway-config-api-Bch9vO6t.js +0 -1
  317. package/dist/gateway/static/root/assets/gateway-settings-DkDxZFGG.js +0 -1
  318. package/dist/gateway/static/root/assets/heartbeat-settings-DXNMxy5b.js +0 -1
  319. package/dist/gateway/static/root/assets/home-page-CYcpVFNT.js +0 -1
  320. package/dist/gateway/static/root/assets/index-Dgb1R07E.css +0 -2
  321. package/dist/gateway/static/root/assets/index-DlOYwVFK.js +0 -108
  322. package/dist/gateway/static/root/assets/local-app-workbench-page-BFrgPwGE.js +0 -2
  323. package/dist/gateway/static/root/assets/logs-page-CPweLw3k.js +0 -2
  324. package/dist/gateway/static/root/assets/messages-B9WQcZ1V.js +0 -3
  325. package/dist/gateway/static/root/assets/notes-workbench-wieRAd1y.js +0 -4
  326. package/dist/gateway/static/root/assets/page-tabs-Bsluqyfb.js +0 -1
  327. package/dist/gateway/static/root/assets/preview-open-alternatives-BrpTWv44.js +0 -1
  328. package/dist/gateway/static/root/assets/project-detail-page-Cww6V7HJ.js +0 -1
  329. package/dist/gateway/static/root/assets/projects-page-D0LKhCCw.js +0 -1
  330. package/dist/gateway/static/root/assets/remote-access-hub-Sf4Pde6Z.js +0 -1
  331. package/dist/gateway/static/root/assets/sessions-page-S5gvgfu5.js +0 -1
  332. package/dist/gateway/static/root/assets/settings-advanced-gate-B3XvdEy8.js +0 -1
  333. package/dist/gateway/static/root/assets/settings-form-section-CiGFtdD8.js +0 -1
  334. package/dist/gateway/static/root/assets/setup-status-panel-CGU_Mxjr.js +0 -1
  335. package/dist/gateway/static/root/assets/shares-settings-k0UQ8WxO.js +0 -1
  336. package/dist/gateway/static/root/assets/skill-reload-api-DQ1GvL1w.js +0 -1
  337. package/dist/gateway/static/root/assets/skills-page-OuHd9GcN.js +0 -2
  338. package/dist/gateway/static/root/assets/system-settings-panel-CERqCsz2.js +0 -1
  339. package/dist/gateway/static/root/assets/task-detail-page-BnRNL2sn.js +0 -1
  340. package/dist/gateway/static/root/assets/typed-models-lib-abEJNkCO.js +0 -1
  341. package/dist/gateway/static/root/assets/user-context-page-Cnkaiky5.js +0 -1
  342. package/dist/gateway/static/root/assets/workflows-page-B_VlcKiK.js +0 -5
@@ -15,7 +15,6 @@ import { inferSuggestedProjectDefaultAgentId } from "../../projects/project-agen
15
15
  import "../../projects/index.js";
16
16
  import { setTuiDefaultAgentConfig } from "../../commands/agents.config.js";
17
17
  import { evictEmbeddedSessionRunner } from "../../agent/embedded/session-runner.js";
18
- import { prependEnvelopeTimestamp } from "../../channels/envelope-timestamp.js";
19
18
  import { buildSessionTimeline } from "../../session/transcript-outline.js";
20
19
  import { transcriptRowsToClientHistory } from "../../session/client-history.js";
21
20
  import { SessionIndex } from "../../session/manager.js";
@@ -24,6 +23,7 @@ import { parseModelRef } from "../../agent/models/selection.js";
24
23
  import { buildReviewContext, resolveGitRoot } from "../../review/review-git.js";
25
24
  import { MessageBus, MessageBusShutdownError } from "../../infra/bus/queue.js";
26
25
  import "../../infra/bus/index.js";
26
+ import { prependEnvelopeTimestamp } from "../../channels/envelope-timestamp.js";
27
27
  import { getWorkspacePath } from "../../config/workspace-path-helpers.js";
28
28
  import "../../config/index.js";
29
29
  import { buildWorkflowChildTools } from "../../agent/workflow/workflow-child-tools.js";
@@ -579,7 +579,8 @@ var EmbeddedBackend = class {
579
579
  contextWindow: usage.contextWindow,
580
580
  contextUsagePercent: usage.usagePercent,
581
581
  effectiveWorkspacePath: cfg.effectiveWorkspacePath,
582
- workingDirectoryLocked: cfg.workingDirectoryLocked
582
+ workingDirectoryLocked: cfg.workingDirectoryLocked,
583
+ projectId: getSessionMetadata(sessionKey)?.projectId
583
584
  };
584
585
  } catch (err) {
585
586
  const errorMessage = err instanceof Error ? err.message : String(err);
@@ -609,6 +610,7 @@ var EmbeddedBackend = class {
609
610
  }
610
611
  async patchSession(sessionKey, patch) {
611
612
  const agent = await this.ensureAgent();
613
+ const hasProjectPatch = Object.prototype.hasOwnProperty.call(patch, "projectId");
612
614
  const projectId = typeof patch.projectId === "string" ? patch.projectId.trim() : "";
613
615
  const result = await agent.sessionConfig.patch(sessionKey, {
614
616
  model: typeof patch.model === "string" ? patch.model : void 0,
@@ -622,7 +624,7 @@ var EmbeddedBackend = class {
622
624
  await this.sessionIndexReady;
623
625
  await this.sessionIndex?.getStore().resolveTranscriptPath(sessionKey);
624
626
  new ProjectService().attachSession(sessionKey, projectId);
625
- }
627
+ } else if (hasProjectPatch && patch.projectId === null) new ProjectService().detachSession(sessionKey);
626
628
  const hiddenFromSessionList = typeof patch.hiddenFromSessionList === "boolean" ? patch.hiddenFromSessionList : void 0;
627
629
  const customData = patch.customData && typeof patch.customData === "object" && !Array.isArray(patch.customData) ? patch.customData : void 0;
628
630
  if (hiddenFromSessionList !== void 0 || customData !== void 0) {
@@ -1,8 +1,8 @@
1
1
  import { createLogger } from "../../utils/logger/index.js";
2
2
  import { init_logger } from "../../utils/logger.js";
3
- import { prependEnvelopeTimestamp } from "../../channels/envelope-timestamp.js";
4
3
  import { transcriptRowsToClientHistory } from "../../session/client-history.js";
5
4
  import { parseModelRef } from "../../agent/models/selection.js";
5
+ import { prependEnvelopeTimestamp } from "../../channels/envelope-timestamp.js";
6
6
  import { gatewayCredentialAuthorization } from "../../gateway/credential.js";
7
7
  import { RealtimeClient } from "../../../packages/realtime-client/src/index.js";
8
8
  import { buildTuiTranscriptTree, transcriptTreeEntryIdToRowNumber } from "../tui-transcript-tree.js";
@@ -422,6 +422,7 @@ var GatewayRealtimeBackend = class {
422
422
  if (session) {
423
423
  if (session.name) out.displayName = session.name;
424
424
  if (session.estimatedTokens != null) out.totalTokens = session.estimatedTokens;
425
+ if (session.projectId?.trim()) out.projectId = session.projectId.trim();
425
426
  }
426
427
  }
427
428
  if (agentCfgRes.ok) {
@@ -645,12 +646,13 @@ var GatewayRealtimeBackend = class {
645
646
  });
646
647
  const json = await res.json().catch(() => ({}));
647
648
  if (!res.ok || json.ok === false) throw new Error(json.error ?? `Session config patch failed (${res.status})`);
649
+ const hasProjectPatch = Object.prototype.hasOwnProperty.call(patch, "projectId");
648
650
  const projectId = typeof patch.projectId === "string" ? patch.projectId.trim() : "";
649
651
  const hiddenFromSessionList = typeof patch.hiddenFromSessionList === "boolean" ? patch.hiddenFromSessionList : void 0;
650
652
  const customData = patch.customData && typeof patch.customData === "object" && !Array.isArray(patch.customData) ? patch.customData : void 0;
651
- if (projectId || hiddenFromSessionList !== void 0 || customData !== void 0) {
653
+ if (hasProjectPatch || hiddenFromSessionList !== void 0 || customData !== void 0) {
652
654
  const metadataPatch = {
653
- ...projectId ? { projectId } : {},
655
+ ...hasProjectPatch ? { projectId: projectId || null } : {},
654
656
  ...hiddenFromSessionList !== void 0 ? { hiddenFromSessionList } : {},
655
657
  ...customData ? { customData } : {}
656
658
  };
@@ -1,3 +1,4 @@
1
+ import { stripRuntimeContextFromUserMessage } from "../session/user-message-display.js";
1
2
  import { createAssistantMessageFromText } from "./components/assistant-message.js";
2
3
  //#region src/tui/chat-history.ts
3
4
  function historyMessageKey(message, index) {
@@ -77,7 +78,7 @@ function appendHistoryToChatLog(chatLog, messages, toolsExpanded, showThinking =
77
78
  return;
78
79
  }
79
80
  if (hm.role === "user") {
80
- chatLog.addUser(historyContentText(hm.content), {
81
+ chatLog.addUser(stripRuntimeContextFromUserMessage(historyContentText(hm.content)), {
81
82
  displayIndex,
82
83
  historyIndex,
83
84
  role: "user"
@@ -1,4 +1,5 @@
1
1
  import { formatAgentRunErrorForDisplay } from "../agent/client-error-format.js";
2
+ import { stripRuntimeContextFromUserContent } from "../session/user-message-display.js";
2
3
  import { createAssistantMessageFromText } from "./components/assistant-message.js";
3
4
  import { markRunEvent, markRunIdleAfterCompletion } from "./tui-run-state.js";
4
5
  //#region src/tui/tui-agent-events.ts
@@ -175,12 +176,13 @@ function dispatchAgentEvent(event, data, state, chatLog, tui, setActivityStatus,
175
176
  break;
176
177
  case "user_message": {
177
178
  const message = p.message;
178
- chatLog.addUser(Array.isArray(message?.content) || typeof message?.content === "string" ? message.content : []);
179
+ const content = Array.isArray(message?.content) || typeof message?.content === "string" ? stripRuntimeContextFromUserContent(message.content) : [];
180
+ chatLog.addUser(content);
179
181
  tui.requestRender();
180
182
  break;
181
183
  }
182
184
  case "user_transcript":
183
- chatLog.addUser(String(p.text ?? ""));
185
+ chatLog.addUser(stripRuntimeContextFromUserContent(String(p.text ?? "")));
184
186
  tui.requestRender();
185
187
  break;
186
188
  case "assistant_message_start": {
@@ -109,6 +109,7 @@ export type CommandHandlerDeps = {
109
109
  extensionShortcuts?: TuiHotkeyExtensionShortcut[];
110
110
  currentAgentId?: string;
111
111
  setSession?: (rawKey: string) => Promise<void>;
112
+ newSession?: () => Promise<void>;
112
113
  resetSession?: () => Promise<void>;
113
114
  recoverStream?: () => void | Promise<void>;
114
115
  retryLastMessage?: () => void | Promise<void>;
@@ -584,6 +584,7 @@ function runTuiProjectCommand(state, args) {
584
584
  ...parsed.projectKind ? { projectKind: parsed.projectKind } : {}
585
585
  });
586
586
  projects.attachSession(state.currentSessionKey, project.id);
587
+ state.sessionInfo.projectId = project.id;
587
588
  return `Created and attached project:\n${formatTuiProject(project)}`;
588
589
  }
589
590
  if (subcommand === "switch" || subcommand === "attach") {
@@ -592,10 +593,12 @@ function runTuiProjectCommand(state, args) {
592
593
  const project = resolveTuiProject(projects, ref);
593
594
  if (!project) return `Project not found: ${ref}`;
594
595
  projects.attachSession(state.currentSessionKey, project.id);
596
+ state.sessionInfo.projectId = project.id;
595
597
  return `Attached current session to project: ${project.name}`;
596
598
  }
597
599
  if (subcommand === "detach") {
598
600
  projects.detachSession(state.currentSessionKey);
601
+ state.sessionInfo.projectId = void 0;
599
602
  return "Detached current session from project.";
600
603
  }
601
604
  if (subcommand === "archive") {
@@ -1260,9 +1263,11 @@ function createTuiCommandHandler(deps) {
1260
1263
  (async () => {
1261
1264
  try {
1262
1265
  await abortActive();
1263
- const uniqueKey = `tui-${randomUUID()}`;
1264
- if (setSession) {
1265
- await setSession(uniqueKey);
1266
+ if (deps.newSession) {
1267
+ await deps.newSession();
1268
+ chatLog.addSystem(`new session: ${state.currentSessionKey}`);
1269
+ } else if (setSession) {
1270
+ await setSession(`tui-${randomUUID()}`);
1266
1271
  chatLog.addSystem(`new session: ${state.currentSessionKey}`);
1267
1272
  } else {
1268
1273
  chatLog.clearAll();
@@ -8,4 +8,3 @@ export declare const GENERATED_TUI_SESSION_SHELL_PATCH: {
8
8
  export declare function isGeneratedTuiSessionKey(sessionKey: string): boolean;
9
9
  export declare function deleteGeneratedTuiSessionIfEmpty(client: Pick<TuiBackend, 'getSessionStats' | 'deleteSession'>, sessionKey: string): Promise<boolean>;
10
10
  export declare function cleanupAbandonedTuiSessions(client: Pick<TuiBackend, 'listSessions' | 'getSessionStats' | 'deleteSession'>, currentSessionKey: string, nowMs?: number): Promise<string[]>;
11
- export declare function hideLegacyEmptyTuiSessions(client: Pick<TuiBackend, 'listSessions' | 'patchSession'>): Promise<string[]>;
@@ -23,15 +23,5 @@ async function cleanupAbandonedTuiSessions(client, currentSessionKey, nowMs = Da
23
23
  for (const session of candidates) if (await deleteGeneratedTuiSessionIfEmpty(client, session.key)) deleted.push(session.key);
24
24
  return deleted;
25
25
  }
26
- async function hideLegacyEmptyTuiSessions(client) {
27
- const sessions = await client.listSessions();
28
- const hidden = [];
29
- for (const session of sessions) {
30
- if (session.messageCount !== 0 || !isGeneratedTuiSessionKey(session.key)) continue;
31
- await client.patchSession(session.key, GENERATED_TUI_SESSION_SHELL_PATCH);
32
- hidden.push(session.key);
33
- }
34
- return hidden;
35
- }
36
26
  //#endregion
37
- export { GENERATED_TUI_SESSION_SHELL_PATCH, cleanupAbandonedTuiSessions, deleteGeneratedTuiSessionIfEmpty, hideLegacyEmptyTuiSessions, isGeneratedTuiSessionKey };
27
+ export { GENERATED_TUI_SESSION_SHELL_PATCH, cleanupAbandonedTuiSessions, deleteGeneratedTuiSessionIfEmpty, isGeneratedTuiSessionKey };
@@ -0,0 +1,10 @@
1
+ import { type AgentModelPreference, type NewSessionPreferences, type SessionInitialAgentConfig } from '@xopcai/gateway-contract';
2
+ import type { TuiSettings } from './tui-settings.js';
3
+ export declare function tuiGatewayPreferenceKey(url?: string): string;
4
+ export declare function getTuiNewSessionPreferences(settings: TuiSettings, gatewayKey: string): NewSessionPreferences;
5
+ export declare function rememberTuiSessionContext(settings: TuiSettings, gatewayKey: string, context: {
6
+ agentId: string;
7
+ projectId?: string | null;
8
+ }): TuiSettings;
9
+ export declare function rememberTuiAgentModel(settings: TuiSettings, gatewayKey: string, agentId: string, preference: AgentModelPreference): TuiSettings;
10
+ export declare function tuiInitialAgentConfig(settings: TuiSettings, gatewayKey: string, agentId: string): SessionInitialAgentConfig | undefined;
@@ -0,0 +1,32 @@
1
+ import { createDefaultNewSessionPreferences, modelPreferenceForAgent, withAgentModelPreference, withLastChatScope, withSelectedAgent } from "../../packages/gateway-contract/src/new-session.js";
2
+ //#region src/tui/tui-new-session-preferences.ts
3
+ function tuiGatewayPreferenceKey(url) {
4
+ return url?.trim() || "local";
5
+ }
6
+ function getTuiNewSessionPreferences(settings, gatewayKey) {
7
+ return settings.newSessionPreferencesByGateway[gatewayKey] ?? createDefaultNewSessionPreferences();
8
+ }
9
+ function withPreferences(settings, gatewayKey, preferences) {
10
+ return {
11
+ ...settings,
12
+ newSessionPreferencesByGateway: {
13
+ ...settings.newSessionPreferencesByGateway,
14
+ [gatewayKey]: preferences
15
+ }
16
+ };
17
+ }
18
+ function rememberTuiSessionContext(settings, gatewayKey, context) {
19
+ return withPreferences(settings, gatewayKey, withLastChatScope(withSelectedAgent(getTuiNewSessionPreferences(settings, gatewayKey), context.agentId), context.projectId));
20
+ }
21
+ function rememberTuiAgentModel(settings, gatewayKey, agentId, preference) {
22
+ return withPreferences(settings, gatewayKey, withAgentModelPreference(getTuiNewSessionPreferences(settings, gatewayKey), agentId, preference));
23
+ }
24
+ function tuiInitialAgentConfig(settings, gatewayKey, agentId) {
25
+ const preference = modelPreferenceForAgent(getTuiNewSessionPreferences(settings, gatewayKey), agentId);
26
+ return preference ? {
27
+ model: preference.modelRef,
28
+ ...preference.thinkingLevel ? { thinkingLevel: preference.thinkingLevel } : {}
29
+ } : void 0;
30
+ }
31
+ //#endregion
32
+ export { getTuiNewSessionPreferences, rememberTuiAgentModel, rememberTuiSessionContext, tuiGatewayPreferenceKey, tuiInitialAgentConfig };
@@ -15,6 +15,7 @@ export type SessionActionsContext = {
15
15
  historyLimit?: number;
16
16
  onAgentIdChange?: (agentId: string) => void;
17
17
  sessionSnapshot?: TuiSessionSnapshot;
18
+ onSessionInfoChange?: () => void;
18
19
  };
19
20
  export declare function createSessionActions(context: SessionActionsContext): {
20
21
  refreshSessionInfo: () => Promise<void>;
@@ -6,7 +6,7 @@ import { clearSeenStreamEvents } from "./tui-agent-events.js";
6
6
  //#region src/tui/tui-session-actions.ts
7
7
  init_agent_session_key();
8
8
  function createSessionActions(context) {
9
- const { client, chatLog, tui, state, resolveSessionKey, updateHeader, updateFooter, setActivityStatus, historyLimit = 200, onAgentIdChange, sessionSnapshot } = context;
9
+ const { client, chatLog, tui, state, resolveSessionKey, updateHeader, updateFooter, setActivityStatus, historyLimit = 200, onAgentIdChange, sessionSnapshot, onSessionInfoChange } = context;
10
10
  let refreshSessionInfoPromise = Promise.resolve();
11
11
  let lastHistoryKeys = [];
12
12
  const updateAgentFromSessionKey = (key) => {
@@ -17,6 +17,7 @@ function createSessionActions(context) {
17
17
  const runRefreshSessionInfo = async () => {
18
18
  try {
19
19
  state.sessionInfo = await client.getSessionInfo(state.currentSessionKey);
20
+ onSessionInfoChange?.();
20
21
  updateFooter();
21
22
  tui.requestRender();
22
23
  } catch {}
@@ -1,3 +1,4 @@
1
+ import { type NewSessionPreferences } from '@xopcai/gateway-contract';
1
2
  export type TuiThemeId = 'auto' | 'dark' | 'light' | (string & {});
2
3
  export type DoubleEscapeAction = 'none' | 'tree' | 'fork';
3
4
  export type TreeFilterMode = 'default' | 'no-tools' | 'user-only' | 'labeled-only' | 'all';
@@ -24,6 +25,7 @@ export interface TuiSettings {
24
25
  clearOnShrink: boolean;
25
26
  /** Default transcript filter when opening `/tree`. */
26
27
  treeFilterMode: TreeFilterMode;
28
+ newSessionPreferencesByGateway: Record<string, NewSessionPreferences>;
27
29
  }
28
30
  export declare const DEFAULT_TUI_SETTINGS: TuiSettings;
29
31
  /** Load persisted TUI settings from `~/.xopc/tui-settings.json`. */
@@ -1,5 +1,6 @@
1
1
  import { resolveStateDir } from "../config/paths-state.js";
2
2
  import { init_paths } from "../config/paths.js";
3
+ import { parseNewSessionPreferences } from "../../packages/gateway-contract/src/new-session.js";
3
4
  import { join } from "node:path";
4
5
  import { existsSync, mkdirSync, readFileSync, writeFileSync } from "node:fs";
5
6
  //#region src/tui/tui-settings.ts
@@ -17,7 +18,8 @@ const DEFAULT_TUI_SETTINGS = {
17
18
  editorPaddingX: 0,
18
19
  autocompleteMaxVisible: 5,
19
20
  clearOnShrink: false,
20
- treeFilterMode: "default"
21
+ treeFilterMode: "default",
22
+ newSessionPreferencesByGateway: {}
21
23
  };
22
24
  const SETTINGS_PATH = join(resolveStateDir(), "tui-settings.json");
23
25
  function isDoubleEscapeAction(value) {
@@ -43,6 +45,7 @@ function normalizeSettings(raw) {
43
45
  if (typeof obj.autocompleteMaxVisible === "number" && Number.isFinite(obj.autocompleteMaxVisible)) base.autocompleteMaxVisible = Math.max(3, Math.min(20, Math.floor(obj.autocompleteMaxVisible)));
44
46
  if (typeof obj.clearOnShrink === "boolean") base.clearOnShrink = obj.clearOnShrink;
45
47
  if (isTreeFilterMode(obj.treeFilterMode)) base.treeFilterMode = obj.treeFilterMode;
48
+ if (obj.newSessionPreferencesByGateway && typeof obj.newSessionPreferencesByGateway === "object" && !Array.isArray(obj.newSessionPreferencesByGateway)) base.newSessionPreferencesByGateway = Object.fromEntries(Object.entries(obj.newSessionPreferencesByGateway).map(([gatewayId, preferences]) => [gatewayId, parseNewSessionPreferences(preferences)]));
46
49
  return base;
47
50
  }
48
51
  /** Load persisted TUI settings from `~/.xopc/tui-settings.json`. */
@@ -1,6 +1,6 @@
1
1
  import { resolveStateDir } from "../config/paths-state.js";
2
- import { init_paths, resolveAgentProfileDir, resolveBundledSkillsDir } from "../config/paths.js";
3
2
  import { resolveEffectiveAgentProfileForSession } from "../config/agent-profile.js";
3
+ import { init_paths, resolveAgentProfileDir, resolveBundledSkillsDir } from "../config/paths.js";
4
4
  import { resolveBootstrapFilesSync } from "../agent/bootstrap/bootstrap-files.js";
5
5
  import { createSkillConfigManager, isSkillEnabled } from "../agent/skills/config.js";
6
6
  import { loadSkills } from "../agent/skills/index.js";
@@ -57,6 +57,7 @@ export interface SessionInfo {
57
57
  displayName?: string;
58
58
  effectiveWorkspacePath?: string;
59
59
  workingDirectoryLocked?: boolean;
60
+ projectId?: string;
60
61
  }
61
62
  /** Mutable state bag for the TUI runtime. */
62
63
  export interface TuiState {
@@ -2,10 +2,10 @@ import { version } from "../../package.js";
2
2
  import { resolveStateDir, resolveXopcDatabasePath } from "../config/paths-state.js";
3
3
  import { parseAgentSessionKey } from "../routing/session-key-utils.js";
4
4
  import { init_agent_session_key, normalizeAgentId } from "../routing/agent-session-key.js";
5
+ import { resolveEffectiveAgentProfileForSession } from "../config/agent-profile.js";
5
6
  import { init_paths } from "../config/paths.js";
6
7
  import { loadConfig } from "../config/loader.js";
7
8
  import { getAllModels, getAllProviders, getApiKey, init_providers, isProviderConfiguredSync } from "../providers/index.js";
8
- import { resolveEffectiveAgentProfileForSession } from "../config/agent-profile.js";
9
9
  import { ProjectTrustStore, hasTrustRequiringProjectResources } from "../project-trust/trust-store.js";
10
10
  import { renderWorkflowFinalSummary, renderWorkflowPanel } from "../agent/workflow/snapshot.js";
11
11
  import { ensureStarterAgentsInitialized } from "../agent/starter-agents.js";
@@ -27,13 +27,14 @@ import { transcriptTreeEntryIdToRowNumber } from "./tui-transcript-tree.js";
27
27
  import { formatTuiCompactionResult, formatTuiShareResult } from "./tui-command-formatters.js";
28
28
  import { formatTuiStartupText } from "./tui-startup-text.js";
29
29
  import { createTuiCommandHandler, getSlashCommands } from "./tui-commands.js";
30
- import { GENERATED_TUI_SESSION_SHELL_PATCH, cleanupAbandonedTuiSessions, deleteGeneratedTuiSessionIfEmpty, hideLegacyEmptyTuiSessions, isGeneratedTuiSessionKey } from "./tui-empty-session-cleanup.js";
30
+ import { GENERATED_TUI_SESSION_SHELL_PATCH, cleanupAbandonedTuiSessions, deleteGeneratedTuiSessionIfEmpty, isGeneratedTuiSessionKey } from "./tui-empty-session-cleanup.js";
31
31
  import { extensionCustomMessageContentToText, extensionCustomMessageToTurnText, extensionUserMessageContentToText } from "./tui-extension-user-message.js";
32
32
  import { resolveFdPath } from "./tui-fd-path.js";
33
33
  import { createBackspaceDeduper, drainAndStopTuiSafely, isIgnorableTuiStopError, resolveCtrlCAction, stopTuiSafely } from "./tui-lifecycle.js";
34
34
  import { createLocalShellRunner } from "./tui-local-shell.js";
35
35
  import { filterModelsForCycle, loadScopedModelRefs, saveScopedModelRefs } from "./tui-scoped-models.js";
36
36
  import { openModelPickerOverlay } from "./tui-model-picker.js";
37
+ import { getTuiNewSessionPreferences, rememberTuiAgentModel, rememberTuiSessionContext, tuiGatewayPreferenceKey, tuiInitialAgentConfig } from "./tui-new-session-preferences.js";
37
38
  import { runTuiOAuthLogin } from "./tui-oauth-login.js";
38
39
  import { openAgentPickerOverlay, openProjectTrustOverlay, openReviewLauncherOverlay, openScopedModelsOverlay, openSessionPickerOverlay, openSessionTreeOverlay, openSettingsOverlay, openThinkingSelectorOverlay, openTimelineOverlay, openTranscriptTreeOverlay, openUserMessageForkOverlay } from "./tui-picker-overlay.js";
39
40
  import { formatActiveRunStatus, formatRunDuration } from "./tui-run-status-format.js";
@@ -195,6 +196,7 @@ async function runTui(opts) {
195
196
  sessionMainKey
196
197
  });
197
198
  let tuiSettings = loadTuiSettings();
199
+ const newSessionPreferenceKey = isLocalMode ? tuiGatewayPreferenceKey() : tuiGatewayPreferenceKey(opts.url ?? "http://localhost:3120");
198
200
  initTuiTheme({ themeId: opts.theme ?? tuiSettings.theme });
199
201
  const state = createInitialState(startup.sessionKey);
200
202
  const generatedStartupSessionKey = !opts.session?.trim() && isGeneratedTuiSessionKey(startup.sessionKey) ? startup.sessionKey : null;
@@ -722,7 +724,7 @@ async function runTui(opts) {
722
724
  };
723
725
  const runExtensionNewSession = async (options) => {
724
726
  await abortActive({ clearUi: false });
725
- await setSession(resolveSessionKey(`session-${randomUUID()}`));
727
+ await startPreferredNewSession("session");
726
728
  await options?.setup?.(sessionSnapshot.manager());
727
729
  await runWithReplacementContext(options?.withSession);
728
730
  return { cancelled: false };
@@ -989,8 +991,34 @@ async function runTui(opts) {
989
991
  sessionSnapshot,
990
992
  onAgentIdChange: (agentId) => {
991
993
  currentAgentId = agentId;
992
- }
994
+ },
995
+ onSessionInfoChange: () => persistCurrentNewSessionContext()
993
996
  });
997
+ const persistCurrentNewSessionContext = () => {
998
+ const current = getTuiNewSessionPreferences(tuiSettings, newSessionPreferenceKey);
999
+ const normalizedProjectId = state.sessionInfo.projectId?.trim() || null;
1000
+ const currentProjectId = current.lastChatScope.kind === "project" ? current.lastChatScope.projectId : null;
1001
+ if (current.selectedAgentId === currentAgentId && currentProjectId === normalizedProjectId) return;
1002
+ tuiSettings = rememberTuiSessionContext(tuiSettings, newSessionPreferenceKey, {
1003
+ agentId: currentAgentId,
1004
+ projectId: normalizedProjectId
1005
+ });
1006
+ saveTuiSettings(tuiSettings);
1007
+ };
1008
+ const startPreferredNewSession = async (prefix = "tui") => {
1009
+ const projectId = state.sessionInfo.projectId?.trim() || void 0;
1010
+ await setSession(resolveSessionKey(`${prefix}-${randomUUID()}`));
1011
+ const initialAgentConfig = tuiInitialAgentConfig(tuiSettings, newSessionPreferenceKey, currentAgentId);
1012
+ if (initialAgentConfig || projectId) {
1013
+ await client.patchSession(state.currentSessionKey, {
1014
+ ...initialAgentConfig,
1015
+ ...projectId ? { projectId } : {},
1016
+ ...isGeneratedTuiSessionKey(state.currentSessionKey) ? GENERATED_TUI_SESSION_SHELL_PATCH : {}
1017
+ });
1018
+ await refreshSessionInfo();
1019
+ }
1020
+ persistCurrentNewSessionContext();
1021
+ };
994
1022
  const refreshSessionInfoWithBorder = async () => {
995
1023
  await refreshSessionInfo();
996
1024
  updateEditorBorderColor();
@@ -1115,6 +1143,14 @@ async function runTui(opts) {
1115
1143
  try {
1116
1144
  await client.patchSession(state.currentSessionKey, { thinkingLevel: level });
1117
1145
  state.sessionInfo.thinkingLevel = level;
1146
+ const currentModelRef = state.sessionInfo.modelProvider && state.sessionInfo.model ? `${state.sessionInfo.modelProvider}/${state.sessionInfo.model}` : state.sessionInfo.model;
1147
+ if (currentModelRef) {
1148
+ tuiSettings = rememberTuiAgentModel(tuiSettings, newSessionPreferenceKey, currentAgentId, {
1149
+ modelRef: currentModelRef,
1150
+ thinkingLevel: level
1151
+ });
1152
+ saveTuiSettings(tuiSettings);
1153
+ }
1118
1154
  await refreshSessionInfoWithBorder();
1119
1155
  updateFooter();
1120
1156
  chatLog.addStatus(theme.dim(`Thinking level: ${level}`));
@@ -1250,6 +1286,11 @@ async function runTui(opts) {
1250
1286
  await client.patchSession(state.currentSessionKey, { model: trimmed });
1251
1287
  state.sessionInfo.modelProvider = selected.provider;
1252
1288
  state.sessionInfo.model = selected.id;
1289
+ tuiSettings = rememberTuiAgentModel(tuiSettings, newSessionPreferenceKey, currentAgentId, {
1290
+ modelRef: trimmed,
1291
+ ...state.sessionInfo.thinkingLevel ? { thinkingLevel: state.sessionInfo.thinkingLevel } : {}
1292
+ });
1293
+ saveTuiSettings(tuiSettings);
1253
1294
  if (selected.contextWindow != null) state.sessionInfo.contextWindow = selected.contextWindow;
1254
1295
  await refreshSessionInfoWithBorder();
1255
1296
  updateFooter();
@@ -1706,6 +1747,10 @@ async function runTui(opts) {
1706
1747
  await setSession(rawKey);
1707
1748
  await refreshStartupResources();
1708
1749
  },
1750
+ newSession: async () => {
1751
+ await startPreferredNewSession();
1752
+ await refreshStartupResources();
1753
+ },
1709
1754
  resetSession: resetCurrentSession,
1710
1755
  projectTrust: {
1711
1756
  cwd: process.cwd(),
@@ -2158,7 +2203,15 @@ async function runTui(opts) {
2158
2203
  const errorMessage = err instanceof Error ? err.message : String(err);
2159
2204
  chatLog.addSystem(`Project not selected: ${errorMessage}`);
2160
2205
  }
2206
+ if (!opts.session?.trim() && isGeneratedTuiSessionKey(state.currentSessionKey)) {
2207
+ const initialAgentConfig = tuiInitialAgentConfig(tuiSettings, newSessionPreferenceKey, currentAgentId);
2208
+ if (initialAgentConfig || opts.thinking?.trim()) await client.patchSession(state.currentSessionKey, {
2209
+ ...initialAgentConfig,
2210
+ ...opts.thinking?.trim() ? { thinkingLevel: opts.thinking.trim() } : {}
2211
+ });
2212
+ }
2161
2213
  await refreshSessionInfoWithBorder();
2214
+ persistCurrentNewSessionContext();
2162
2215
  try {
2163
2216
  state.pendingInputCount = countPendingChatInputs((await client.getChatInputState(state.currentSessionKey)).inputs);
2164
2217
  } catch {
@@ -2166,7 +2219,7 @@ async function runTui(opts) {
2166
2219
  }
2167
2220
  await refreshModelChoices();
2168
2221
  await loadSessionHistory({ merge: true });
2169
- cleanupAbandonedTuiSessions(client, state.currentSessionKey).then(() => hideLegacyEmptyTuiSessions(client)).catch(() => {});
2222
+ cleanupAbandonedTuiSessions(client, state.currentSessionKey).catch(() => {});
2170
2223
  showStartupCardOnce();
2171
2224
  refreshStartupResources().then(() => {
2172
2225
  updateFooter();
@@ -45,6 +45,9 @@ function spawnFrpcProcess(frpcBin, configPath) {
45
45
  loginReject = void 0;
46
46
  });
47
47
  child.on("exit", (code, signal) => {
48
+ loginReject?.(/* @__PURE__ */ new Error(`frpc exited before login (code=${code ?? "null"}, signal=${signal ?? "null"})`));
49
+ loginResolve = void 0;
50
+ loginReject = void 0;
48
51
  for (const h of exitHandlers) h(code, signal);
49
52
  });
50
53
  if (!child.pid) throw new Error("Failed to spawn frpc process");
@@ -18,6 +18,7 @@ export declare class TunnelService extends EventEmitter {
18
18
  private lastError;
19
19
  private state;
20
20
  private reconnectAttempt;
21
+ private reconnectTask;
21
22
  private stopping;
22
23
  private startContext;
23
24
  private frpcDownload;
@@ -36,6 +37,7 @@ export declare class TunnelService extends EventEmitter {
36
37
  private resolveRegistration;
37
38
  private spawnAndWait;
38
39
  private scheduleReconnect;
40
+ private runReconnectLoop;
39
41
  private startHeartbeat;
40
42
  private clearHeartbeat;
41
43
  }
@@ -36,6 +36,7 @@ var TunnelService = class extends EventEmitter {
36
36
  lastError = null;
37
37
  state = "disconnected";
38
38
  reconnectAttempt = 0;
39
+ reconnectTask = null;
39
40
  stopping = false;
40
41
  startContext = null;
41
42
  frpcDownload = null;
@@ -240,13 +241,14 @@ var TunnelService = class extends EventEmitter {
240
241
  }
241
242
  async spawnAndWait(frpcBin, configPath, broker, state, heartbeatIntervalMs) {
242
243
  if (this.frpcHandle) {
243
- await this.frpcHandle.kill();
244
+ const previousHandle = this.frpcHandle;
244
245
  this.frpcHandle = null;
246
+ await previousHandle.kill();
245
247
  }
246
248
  const handle = spawnFrpcProcess(frpcBin, configPath);
247
249
  this.frpcHandle = handle;
248
250
  handle.onExit((code, signal) => {
249
- if (this.stopping) return;
251
+ if (this.stopping || this.frpcHandle !== handle) return;
250
252
  log.warn({
251
253
  code,
252
254
  signal,
@@ -261,33 +263,43 @@ var TunnelService = class extends EventEmitter {
261
263
  }
262
264
  async scheduleReconnect(frpcBin, configPath, broker, state, heartbeatIntervalMs) {
263
265
  if (this.stopping) return;
266
+ if (this.reconnectTask) return this.reconnectTask;
267
+ const task = this.runReconnectLoop(frpcBin, configPath, broker, state, heartbeatIntervalMs).finally(() => {
268
+ if (this.reconnectTask === task) this.reconnectTask = null;
269
+ });
270
+ this.reconnectTask = task;
271
+ return task;
272
+ }
273
+ async runReconnectLoop(frpcBin, configPath, broker, state, heartbeatIntervalMs) {
264
274
  const maxAttempts = 5;
265
- this.reconnectAttempt += 1;
266
- if (this.reconnectAttempt > maxAttempts) {
267
- this.state = "error";
268
- this.lastError = "frpc reconnect failed after maximum attempts";
269
- log.error({ attempts: maxAttempts }, this.lastError);
270
- this.emit("tunnel:error", this.lastError);
271
- return;
272
- }
273
- this.state = "reconnecting";
274
- this.setStartPhase("reconnecting_frpc", { publicUrl: state.publicUrl ?? null });
275
- const delayMs = Math.min(16e3, 1e3 * 2 ** (this.reconnectAttempt - 1));
276
- log.info({
277
- attempt: this.reconnectAttempt,
278
- delayMs
279
- }, "Scheduling frpc reconnect");
280
- await new Promise((r) => setTimeout(r, delayMs));
281
- if (this.stopping) return;
282
- try {
283
- await this.spawnAndWait(frpcBin, configPath, broker, state, heartbeatIntervalMs);
284
- this.clearStartProgress();
285
- this.state = "connected";
286
- this.reconnectAttempt = 0;
287
- this.emit("tunnel:connected");
288
- } catch (err) {
289
- this.lastError = err instanceof Error ? err.message : String(err);
290
- this.scheduleReconnect(frpcBin, configPath, broker, state, heartbeatIntervalMs);
275
+ while (!this.stopping) {
276
+ this.reconnectAttempt += 1;
277
+ if (this.reconnectAttempt > maxAttempts) {
278
+ this.state = "error";
279
+ this.lastError = "frpc reconnect failed after maximum attempts";
280
+ log.error({ attempts: maxAttempts }, this.lastError);
281
+ this.emit("tunnel:error", this.lastError);
282
+ return;
283
+ }
284
+ this.state = "reconnecting";
285
+ this.setStartPhase("reconnecting_frpc", { publicUrl: state.publicUrl ?? null });
286
+ const delayMs = Math.min(16e3, 1e3 * 2 ** (this.reconnectAttempt - 1));
287
+ log.info({
288
+ attempt: this.reconnectAttempt,
289
+ delayMs
290
+ }, "Scheduling frpc reconnect");
291
+ await new Promise((resolve) => setTimeout(resolve, delayMs));
292
+ if (this.stopping) return;
293
+ try {
294
+ await this.spawnAndWait(frpcBin, configPath, broker, state, heartbeatIntervalMs);
295
+ this.clearStartProgress();
296
+ this.state = "connected";
297
+ this.reconnectAttempt = 0;
298
+ this.emit("tunnel:connected");
299
+ return;
300
+ } catch (err) {
301
+ this.lastError = err instanceof Error ? err.message : String(err);
302
+ }
291
303
  }
292
304
  }
293
305
  startHeartbeat(broker, state, intervalMs) {
@@ -6,6 +6,7 @@ type ConsolidationMetrics = {
6
6
  scanned: number;
7
7
  needsReview: number;
8
8
  stale: number;
9
+ globalCandidates: number;
9
10
  };
10
11
  export declare function resolveContextConsolidationConfig(config: Config): {
11
12
  enabled: boolean;