@yuriai/web 0.2.27-beta.8 → 0.2.28

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 (198) hide show
  1. package/dist/assets/{AgentAvatar-BJ42lGZD.js → AgentAvatar-BybF1ayP.js} +1 -1
  2. package/dist/assets/AssistantContactStatus-BwpxTn0d.js +3 -0
  3. package/dist/assets/{AssistantUnreadBadge-QwhBfXpC.js → AssistantUnreadBadge-DqThZdCe.js} +1 -1
  4. package/dist/assets/{AssistantView-D7ryIKL0.js → AssistantView-DPUDCXoY.js} +1 -1
  5. package/dist/assets/{DiagramView-ERrGEBDp.js → DiagramView-CHVLoYrV.js} +1 -1
  6. package/dist/assets/{FadeInOnReveal-Bu2GvaM9.js → FadeInOnReveal-Cj3JXYvE.js} +1 -1
  7. package/dist/assets/{GuiPluginSurface-MzQgEZNr.js → GuiPluginSurface-CBZYeKHb.js} +1 -1
  8. package/dist/assets/{GuiPluginWindow-DZMmlQzx.js → GuiPluginWindow-_Z5wycnH.js} +1 -1
  9. package/dist/assets/{Icon-Dj4CCqCP.js → Icon-CeRMtJa8.js} +1 -1
  10. package/dist/assets/{ImageLoadingPlaceholder-BnFXgUuO.js → ImageLoadingPlaceholder-DjLaKB4o.js} +1 -1
  11. package/dist/assets/{LoadingImage-PBnivDKv.js → LoadingImage-DG3otL5V.js} +1 -1
  12. package/dist/assets/MarkdownRenderer-C8rv6z7p.js +2 -0
  13. package/dist/assets/{MarkdownRendererImpl-CfyXL4rg.js → MarkdownRendererImpl-_plqOlsV.js} +1 -1
  14. package/dist/assets/{MarkstreamRendererImpl-BGadklK1.js → MarkstreamRendererImpl-bs8HZ4Ra.js} +1 -1
  15. package/dist/assets/{MobileDetailNavigation-DqajQdB4.js → MobileDetailNavigation-SeT764Ps.js} +1 -1
  16. package/dist/assets/{MobileResizableSheet-BvdUgwA3.js → MobileResizableSheet-BY1-oo_E.js} +1 -1
  17. package/dist/assets/{MobileShareBridge-3oPoYnry.js → MobileShareBridge-Dw8gLtJD.js} +2 -2
  18. package/dist/assets/MobileTabPageHeader-EsrOCLyg.js +2 -0
  19. package/dist/assets/{MultiRunWindow-yhs0Ih5_.js → MultiRunWindow-C-Qw_g7N.js} +1 -1
  20. package/dist/assets/{OnboardingScreen-Bi1VWFQC.js → OnboardingScreen-CGqabMbp.js} +1 -1
  21. package/dist/assets/{OverlayScrollbar-BBDwGvGO.js → OverlayScrollbar-AGSWQKg-.js} +1 -1
  22. package/dist/assets/{SettingsView-BSf-SJUA.js → SettingsView-BLfFnnnX.js} +14 -14
  23. package/dist/assets/{SettingsWindow-BvSXVMTm.js → SettingsWindow-lyYO8Byy.js} +1 -1
  24. package/dist/assets/{TerminalView-DhL01N7e.js → TerminalView-OHqpkHzz.js} +1 -1
  25. package/dist/assets/{ToolOutputDialog-C8lnH4Ky.js → ToolOutputDialog-DU4Pb1s0.js} +1 -1
  26. package/dist/assets/{YuriLogo-D8asj1CS.js → YuriLogo-Bb6yHagP.js} +1 -1
  27. package/dist/assets/{appThemeRegistry-C-maYSdv.js → appThemeRegistry-9j-rCSlE.js} +1 -1
  28. package/dist/assets/{button-vXOdzd8x.js → button-Bjh2BSXh.js} +1 -1
  29. package/dist/assets/{capgoAdapter-DJ_h2x5D.js → capgoAdapter-DERfot6h.js} +1 -1
  30. package/dist/assets/{collapsible-DwDQs3Wa.js → collapsible-BEAHoxNi.js} +1 -1
  31. package/dist/assets/{context-menu-BabBujQ-.js → context-menu-BxLcot-3.js} +1 -1
  32. package/dist/assets/device-BcRP6Tjd.js +2 -0
  33. package/dist/assets/{diagram-HwgrQxY5.js → diagram-CXVm2vzI.js} +1 -1
  34. package/dist/assets/{dialog-Dnf626tb.js → dialog-nshKUSE5.js} +1 -1
  35. package/dist/assets/{dropdown-menu.styles-CBc_a-Nv.js → dropdown-menu.styles-M78xpvb2.js} +1 -1
  36. package/dist/assets/{es-BQkO-Odr.js → es-N9ZkQwG9.js} +2 -2
  37. package/dist/assets/fileMentionAutocompleteState-BZJqfgae.js +2 -0
  38. package/dist/assets/{fileMentionTouchSelection-CKPnEetl.js → fileMentionTouchSelection-B9NbPN9D.js} +2 -2
  39. package/dist/assets/{fileReferenceActions-g7KZLi_G.js → fileReferenceActions-CrIAce3K.js} +1 -1
  40. package/dist/assets/{fr-C852roK5.js → fr-CIGqV46N.js} +2 -2
  41. package/dist/assets/{gitApi-CVq5oKCd.js → gitApi-CY3D5CF0.js} +1 -1
  42. package/dist/assets/{gitApiHttp-BYOIbYIh.js → gitApiHttp-B7vYwgBh.js} +4 -4
  43. package/dist/assets/{gui-M_Rbwkyu.js → gui-CJjEj3l4.js} +1 -1
  44. package/dist/assets/host-CnVx34Dh.js +1 -0
  45. package/dist/assets/{image-loading-D5UhMj7Z.js → image-loading-D6kOgU4w.js} +1 -1
  46. package/dist/assets/{input-BtM712b1.js → input-3Re4pmHm.js} +1 -1
  47. package/dist/assets/insertionBoundaries-DK7XYF8d.js +1 -0
  48. package/dist/assets/{ja-BqC39qK6.js → ja-DAhnTq6V.js} +2 -2
  49. package/dist/assets/{ko-BMaChAWh.js → ko-FbMgNKcI.js} +2 -2
  50. package/dist/assets/main-B_THXYMs.js +2 -0
  51. package/dist/assets/main-CpcudEZb.js +169 -0
  52. package/dist/assets/{markdownHeightCache-Bf8iisO4.js → markdownHeightCache-DVWGXtAX.js} +1 -1
  53. package/dist/assets/{mcpQueries-DpXqegX5.js → mcpQueries-CdOYmUdO.js} +1 -1
  54. package/dist/assets/miniChat-DxZiTnAZ.js +2 -0
  55. package/dist/assets/mobile-BJuATiaC.js +2 -0
  56. package/dist/assets/{mobileBackNavigation-DZcI7aZg.js → mobileBackNavigation-CgZndzFA.js} +1 -1
  57. package/dist/assets/{multirun-hzspPepd.js → multirun-BlaYsQi2.js} +1 -1
  58. package/dist/assets/{native-H7K64Ulc.js → native-BYMhr-xH.js} +1 -1
  59. package/dist/assets/{native-config-CddZtLQ1.js → native-config-BpsFKLGl.js} +1 -1
  60. package/dist/assets/{persistence-BT8045Ue.js → persistence-CWuLIq1J.js} +2 -2
  61. package/dist/assets/{pl-Ubs8p28T.js → pl-DzX0cbiQ.js} +2 -2
  62. package/dist/assets/{projectMeta-CEf0QPmD.js → projectMeta-CnXHTolN.js} +1 -1
  63. package/dist/assets/{pt-BR-8rAOjJrs.js → pt-BR-C5yvwyDK.js} +2 -2
  64. package/dist/assets/queue-abort-optimistic-DCLBpirg.js +1 -0
  65. package/dist/assets/{readiness-Dyr7314z.js → readiness-U16Qor79.js} +1 -1
  66. package/dist/assets/renderElectronMiniChatApp-n-nhgy1V.js +2 -0
  67. package/dist/assets/renderMobileApp-DBj_7RlD.js +28 -0
  68. package/dist/assets/{runtimeConfig-B8VHHNxj.js → runtimeConfig-BBgkLVr_.js} +1 -1
  69. package/dist/assets/runtimeEndpointReset-BvSQVFfx.js +149 -0
  70. package/dist/assets/{scheduledTaskNavigation-Zm87Nydi.js → scheduledTaskNavigation-EomDNVu2.js} +1 -1
  71. package/dist/assets/sessionLookup-C_CCp7MJ.js +1 -0
  72. package/dist/assets/{sortable-tabs-strip-D4pVoodN.js → sortable-tabs-strip-p16Pn6Zz.js} +1 -1
  73. package/dist/assets/{speechSettingsQueries-RlCLMBtr.js → speechSettingsQueries-CBSEAKyj.js} +2 -2
  74. package/dist/assets/src-u-YDfCVw.css +2 -0
  75. package/dist/assets/{store-ME7oHni1.js → store-DVfZQktm.js} +4 -3
  76. package/dist/assets/{terminalApi-BSaclMDJ.js → terminalApi-rl9mZAlB.js} +1 -1
  77. package/dist/assets/{textarea-B98rsLs7.js → textarea-C6VQ7dHH.js} +1 -1
  78. package/dist/assets/{tooltip-B9810jbK.js → tooltip-Dnc6GA-X.js} +1 -1
  79. package/dist/assets/types-DnZw0gLD.js +2 -0
  80. package/dist/assets/{uk-LzwzUApL.js → uk-zbDcUpBy.js} +2 -2
  81. package/dist/assets/{useAppFontEffects-D2C1sBYM.js → useAppFontEffects-CEgDiZHu.js} +49 -49
  82. package/dist/assets/{useAssistantUIStore-TUN_ycy5.js → useAssistantUIStore-CfaQV3ID.js} +1 -1
  83. package/dist/assets/useDesktopWindowControlsLayout-B2o4IFmd.js +1 -0
  84. package/dist/assets/useEffectiveDirectory-BOYMJ6k7.js +1 -0
  85. package/dist/assets/{useFontPreferences-BlhlCJCX.js → useFontPreferences-DeqW9nRx.js} +1 -1
  86. package/dist/assets/useMobileNavigationStore-DlvrZQ49.js +17 -0
  87. package/dist/assets/{useUIStore-DRx6OgCp.js → useUIStore-C6CE42oh.js} +1 -1
  88. package/dist/assets/{useWorkerHighlightedLines-D093jNsH.js → useWorkerHighlightedLines-EcJThS4x.js} +1 -1
  89. package/dist/assets/{vendor-effect-DV9F8PTZ.js → vendor-effect-X1Hqc7ba.js} +13 -13
  90. package/dist/assets/vendor-opencode-client-cQ47ywrT.js +23 -0
  91. package/dist/assets/{vendor-opencode-plugin-BBOP6WNx.js → vendor-opencode-plugin-BmdTE4Te.js} +1 -1
  92. package/dist/assets/vendor-opencode-schema-DWT45VBX.js +1 -0
  93. package/dist/assets/vendor-solid-js-D98iXT7C.js +1 -0
  94. package/dist/assets/vendor-zod-DZzbCm1s.js +55 -0
  95. package/dist/assets/{zh-CN-D-FVCeks.js → zh-CN-BHRJ7CF3.js} +2 -2
  96. package/dist/assets/{zh-TW-B9iH_NXL.js → zh-TW-BFI_YFd-.js} +2 -2
  97. package/dist/index.html +12 -12
  98. package/dist/mini-chat.html +12 -12
  99. package/dist/mobile.html +12 -12
  100. package/package.json +1 -1
  101. package/server/index.js +2 -145
  102. package/server/lib/assistants/DOCUMENTATION.md +63 -10
  103. package/server/lib/assistants/cards.js +1 -1
  104. package/server/lib/assistants/channel-image.js +92 -0
  105. package/server/lib/assistants/channel-image.test.js +76 -0
  106. package/server/lib/assistants/channel-output-store.test.js +41 -0
  107. package/server/lib/assistants/channel-output.integration.test.js +128 -0
  108. package/server/lib/assistants/channel-output.js +90 -0
  109. package/server/lib/assistants/channel-output.test.js +79 -0
  110. package/server/lib/assistants/channels/DOCUMENTATION.md +52 -14
  111. package/server/lib/assistants/channels/PROTOCOLS.md +23 -1
  112. package/server/lib/assistants/channels/dingtalk-chat-adapter.js +19 -7
  113. package/server/lib/assistants/channels/dingtalk-chat-adapter.test.js +8 -0
  114. package/server/lib/assistants/channels/routes.js +12 -0
  115. package/server/lib/assistants/channels/routes.test.js +34 -0
  116. package/server/lib/assistants/channels/runtime.js +117 -26
  117. package/server/lib/assistants/channels/runtime.test.js +179 -5
  118. package/server/lib/assistants/channels/sdk-adapters.js +15 -3
  119. package/server/lib/assistants/channels/sdk-adapters.test.js +17 -0
  120. package/server/lib/assistants/channels/store.js +9 -6
  121. package/server/lib/assistants/channels/store.test.js +21 -11
  122. package/server/lib/assistants/channels/transport.js +2 -1
  123. package/server/lib/assistants/channels/wecom-chat-adapter.js +16 -2
  124. package/server/lib/assistants/channels/wecom-chat-adapter.test.js +21 -0
  125. package/server/lib/assistants/contact-store.js +9 -3
  126. package/server/lib/assistants/contact-store.test.js +27 -0
  127. package/server/lib/assistants/contact-tools.js +65 -75
  128. package/server/lib/assistants/contact-tools.test.js +114 -22
  129. package/server/lib/assistants/harness.js +80 -34
  130. package/server/lib/assistants/harness.test.js +68 -20
  131. package/server/lib/assistants/resource-reference.integration.test.js +284 -0
  132. package/server/lib/assistants/routes.js +0 -3
  133. package/server/lib/assistants/service.js +116 -69
  134. package/server/lib/assistants/service.test.js +31 -17
  135. package/server/lib/assistants/weixin/DOCUMENTATION.md +34 -9
  136. package/server/lib/assistants/weixin/api.js +43 -1
  137. package/server/lib/assistants/weixin/api.test.js +28 -0
  138. package/server/lib/assistants/weixin/chat-adapter.js +8 -2
  139. package/server/lib/assistants/weixin/inbound.js +5 -3
  140. package/server/lib/assistants/weixin/inbound.test.js +20 -0
  141. package/server/lib/assistants/weixin/runtime.js +27 -18
  142. package/server/lib/assistants/weixin/runtime.test.js +36 -0
  143. package/server/lib/assistants/weixin/store.js +8 -4
  144. package/server/lib/assistants/weixin/store.test.js +21 -0
  145. package/server/lib/assistants/yuri-project.http.test.js +9 -3
  146. package/server/lib/notifications/DOCUMENTATION.md +6 -0
  147. package/server/lib/notifications/runtime.js +26 -15
  148. package/server/lib/notifications/runtime.test.js +14 -13
  149. package/server/lib/opencode/DOCUMENTATION.md +9 -0
  150. package/server/lib/opencode/auth.d.ts +6 -2
  151. package/server/lib/opencode/core-routes.js +0 -1
  152. package/server/lib/opencode/feature-routes-runtime.js +0 -24
  153. package/server/lib/opencode/location-release.d.ts +5 -1
  154. package/server/lib/opencode/managed-capabilities/scheduled-task.js +1 -1
  155. package/server/lib/opencode/managed-capabilities-runtime.test.js +1 -1
  156. package/server/lib/opencode/native-goal.js +15 -0
  157. package/server/lib/opencode/native-goal.test.js +17 -0
  158. package/server/lib/opencode/settings-helpers.js +0 -6
  159. package/server/lib/opencode/shutdown-runtime.js +0 -2
  160. package/server/lib/projects/project-config.js +3 -6
  161. package/server/lib/scheduled-tasks/DOCUMENTATION.md +10 -35
  162. package/server/lib/scheduled-tasks/managed-tool-route.js +1 -30
  163. package/server/lib/scheduled-tasks/routes.js +0 -26
  164. package/server/lib/scheduled-tasks/runtime.js +33 -257
  165. package/server/lib/scheduled-tasks/runtime.test.js +24 -65
  166. package/server/lib/session-metadata/DOCUMENTATION.md +9 -12
  167. package/server/lib/session-metadata/routes.js +4 -38
  168. package/server/lib/session-metadata/routes.test.js +2 -2
  169. package/dist/assets/AssistantContactStatus-dtkObamV.js +0 -3
  170. package/dist/assets/MarkdownRenderer-BajF4gUU.js +0 -2
  171. package/dist/assets/MobileTabPageHeader-B6cRyIRH.js +0 -2
  172. package/dist/assets/device-BjRYYXNT.js +0 -2
  173. package/dist/assets/host-BW3FEJdU.js +0 -1
  174. package/dist/assets/insertionBoundaries-Dx3WAY6i.js +0 -1
  175. package/dist/assets/main-9uP2z1qT.js +0 -2
  176. package/dist/assets/main-Mey7bCWf.js +0 -169
  177. package/dist/assets/miniChat-DqZvVkme.js +0 -2
  178. package/dist/assets/mobile-DXAWjYcN.js +0 -2
  179. package/dist/assets/renderElectronMiniChatApp-DoOq8Cuo.js +0 -2
  180. package/dist/assets/renderMobileApp-TTxtOb8b.js +0 -28
  181. package/dist/assets/runtimeEndpointReset-BC6XWntz.js +0 -149
  182. package/dist/assets/sessionLookup-De53jDwM.js +0 -1
  183. package/dist/assets/src-lE4uqaHS.css +0 -2
  184. package/dist/assets/types-DFf9vd1b.js +0 -2
  185. package/dist/assets/useDesktopWindowControlsLayout-BjKaHN0x.js +0 -1
  186. package/dist/assets/useEffectiveDirectory-TEvyiQSC.js +0 -1
  187. package/dist/assets/useMobileNavigationStore-DTvJV9s-.js +0 -23
  188. package/dist/assets/vendor-opencode-client-ZeOZ4Efz.js +0 -23
  189. package/dist/assets/vendor-solid-js-9wmPZH9g.js +0 -1
  190. package/dist/assets/vendor-zod-Dzk5kdUU.js +0 -39
  191. package/server/lib/session-goal/DOCUMENTATION.md +0 -371
  192. package/server/lib/session-goal/capability.js +0 -57
  193. package/server/lib/session-goal/capability.test.js +0 -33
  194. package/server/lib/session-goal/objectives.js +0 -61
  195. package/server/lib/session-goal/routes.js +0 -274
  196. package/server/lib/session-goal/routes.test.js +0 -211
  197. package/server/lib/session-goal/runtime.js +0 -2452
  198. package/server/lib/session-goal/runtime.test.js +0 -2125
@@ -1,11 +1,6 @@
1
1
  import { OpenCode } from '@opencode/client';
2
2
  import { isConnectedModel, loadConnectedCatalog } from '../llm/catalog.js';
3
3
  import { SCHEDULE_CONFLICT_CODE, scheduledTaskWriteGuard } from '../projects/project-config.js';
4
- import {
5
- getSessionGoalCapability,
6
- isSessionGoalSupported,
7
- sessionGoalUnavailableMessage,
8
- } from '../session-goal/capability.js';
9
4
 
10
5
  const asNonEmptyString = (value) => {
11
6
  if (typeof value !== 'string') {
@@ -15,22 +10,6 @@ const asNonEmptyString = (value) => {
15
10
  return trimmed.length > 0 ? trimmed : null;
16
11
  };
17
12
 
18
- /** Reject create/edit that enables goal when Host goal state is unavailable. */
19
- const rejectUnsupportedGoalExecution = (taskInput) => {
20
- if (taskInput?.execution?.goalEnabled !== true) {
21
- return null;
22
- }
23
- if (isSessionGoalSupported()) {
24
- return null;
25
- }
26
- const capability = getSessionGoalCapability();
27
- return {
28
- error: sessionGoalUnavailableMessage(capability),
29
- reason: capability.reason,
30
- capability,
31
- };
32
- };
33
-
34
13
  const parseProjectID = (req) => asNonEmptyString(req?.params?.projectId);
35
14
  const parseTaskID = (req) => asNonEmptyString(req?.params?.taskId);
36
15
 
@@ -281,11 +260,6 @@ export const registerScheduledTaskRoutes = (app, dependencies) => {
281
260
  return res.status(404).json({ error: 'Project not found' });
282
261
  }
283
262
 
284
- const goalRefusal = rejectUnsupportedGoalExecution(taskInput);
285
- if (goalRefusal) {
286
- return res.status(501).json(goalRefusal);
287
- }
288
-
289
263
  const taskID = asNonEmptyString(taskInput.id);
290
264
  const existingTask = taskID ? await readExistingTask(projectID, taskID) : null;
291
265
  const partial = req.method === 'PATCH';
@@ -2,11 +2,7 @@ import crypto from 'node:crypto';
2
2
  import { DateTime } from 'luxon';
3
3
  import parser from 'cron-parser';
4
4
  import { makeOpenCodeV2Client } from '../opencode/v2-client.js';
5
- import {
6
- getSessionGoalCapability,
7
- isSessionGoalSupported,
8
- sessionGoalUnavailableMessage,
9
- } from '../session-goal/capability.js';
5
+ import { getNativeSessionGoal } from '../opencode/native-goal.js';
10
6
  import { buildScheduledTaskMetadata } from '../session-metadata/system-session.js';
11
7
  import { SCHEDULED_SLOT_CLAIMED_CODE } from './run-history-store.js';
12
8
  import {
@@ -34,7 +30,7 @@ const SESSION_SETTLEMENT_POLL_MS = 1_000;
34
30
  */
35
31
  const SESSION_SETTLEMENT_MESSAGE_LIMIT = 50;
36
32
  /** Goal terminal statuses — active/paused mean the run is still open. */
37
- const GOAL_TERMINAL_STATUSES = new Set(['complete', 'blocked', 'budgetLimited']);
33
+ const GOAL_TERMINAL_STATUSES = new Set(['complete', 'paused']);
38
34
  /** Assistant finish values that are real terminal success (not tool-calls mid-loop). */
39
35
  const ASSISTANT_SUCCESS_FINISH = new Set(['stop']);
40
36
  /** Assistant finish values that are terminal failure without an error object. */
@@ -375,27 +371,11 @@ const listLatestMessages = async (client, sessionID, requestOptions) => {
375
371
  return Array.isArray(messagesResult?.data) ? messagesResult.data : null;
376
372
  };
377
373
 
378
- const extractGoalFromSession = (session) => {
379
- const metadata = session?.metadata;
380
- if (!metadata || typeof metadata !== 'object') return null;
381
- const namespace = metadata.yuri;
382
- if (!namespace || typeof namespace !== 'object') return null;
383
- const goal = namespace.goal;
384
- if (!goal || typeof goal !== 'object') return null;
385
- const status = typeof goal.status === 'string' ? goal.status.trim() : '';
386
- if (!status) return null;
387
- return {
388
- status,
389
- note: typeof goal.note === 'string' ? goal.note.trim() : '',
390
- };
391
- };
392
374
 
393
375
  /**
394
376
  * Single-shot session outcome for post-run continuation (no polling).
395
- * Goal-enabled + supported: terminal complete → success; blocked/budgetLimited
396
- * → error; otherwise not-yet-success. Goal unsupported: never invent success.
397
- * Prefer Host `readSessionMetadata` over OpenCode `session.get` (direct clients
398
- * do not see the Host store). Store read failure is never empty-goal success.
377
+ * Native Goal: complete → success; paused → error; all other or failed reads
378
+ * stay unknown. Never infer Goal completion from first-turn assistant history.
399
379
  * Non-goal: session.active failure stays unknown; latest-side assistant tail
400
380
  * must be a real terminal (finish tool-calls / incomplete / model-switch ≠
401
381
  * success). History rows are never rewritten here.
@@ -415,7 +395,6 @@ const snapshotSessionOutcome = async ({
415
395
  projectPath,
416
396
  goalEnabled,
417
397
  signal,
418
- readSessionMetadata = null,
419
398
  }) => {
420
399
  const requestOptions = signal ? { signal } : undefined;
421
400
 
@@ -437,11 +416,6 @@ const snapshotSessionOutcome = async ({
437
416
  }
438
417
 
439
418
  if (goalEnabled) {
440
- if (!isSessionGoalSupported()) {
441
- // Host goal state unavailable — do not promote assistant-tail idle to success.
442
- return { outcome: 'busy' };
443
- }
444
-
445
419
  const classifyGoal = (goal) => {
446
420
  if (goal && GOAL_TERMINAL_STATUSES.has(goal.status)) {
447
421
  if (goal.status === 'complete') {
@@ -449,44 +423,18 @@ const snapshotSessionOutcome = async ({
449
423
  }
450
424
  return {
451
425
  outcome: 'error',
452
- error: goal.note || `goal ${goal.status}`,
426
+ error: goal.reason || `goal ${goal.status}`,
453
427
  };
454
428
  }
455
429
  return null;
456
430
  };
457
431
 
458
- // Prefer Host store: OpenCode session.get cannot see yuri.goal.
459
- if (typeof readSessionMetadata === 'function') {
460
- try {
461
- const metadata = await readSessionMetadata(sessionID);
462
- const classified = classifyGoal(extractGoalFromSession({ metadata }));
463
- if (classified) return classified;
464
- } catch (error) {
465
- if (signal?.aborted) throw error;
466
- // Store read failure must not masquerade as empty goal / success.
467
- return { outcome: 'busy' };
468
- }
469
- return { outcome: 'busy' };
470
- }
471
-
472
- if (typeof client?.session?.get === 'function') {
473
- try {
474
- const sessionResult = await client.session.get({
475
- sessionID,
476
- directory: projectPath,
477
- }, requestOptions);
478
- if (!sessionResult?.error) {
479
- const classified = classifyGoal(
480
- extractGoalFromSession(sessionResult?.data ?? sessionResult),
481
- );
482
- if (classified) return classified;
483
- }
484
- } catch (error) {
485
- if (signal?.aborted) throw error;
486
- if (isSessionNotFoundError(error)) {
487
- return { outcome: 'error', error: SESSION_NOT_FOUND_ERROR };
488
- }
489
- }
432
+ try {
433
+ const classified = classifyGoal(await getNativeSessionGoal(client, sessionID, projectPath, signal));
434
+ if (classified) return classified;
435
+ } catch (error) {
436
+ if (signal?.aborted) throw error;
437
+ if (isSessionNotFoundError(error)) return { outcome: 'error', error: SESSION_NOT_FOUND_ERROR };
490
438
  }
491
439
  return { outcome: 'busy' };
492
440
  }
@@ -553,7 +501,6 @@ export const createScheduledTasksRuntime = (deps) => {
553
501
  listProjects,
554
502
  buildOpenCodeUrl,
555
503
  getOpenCodeAuthHeaders,
556
- getSmallModelService,
557
504
  waitForOpenCodeReady,
558
505
  emitTaskRunEvent,
559
506
  notifyTaskRun,
@@ -564,8 +511,6 @@ export const createScheduledTasksRuntime = (deps) => {
564
511
  maxRunDurationMs = DEFAULT_MAX_RUN_MS,
565
512
  /** Create-phase cap. Clamped below 60s. Watchdog abort still wins. */
566
513
  createPhaseDeadlineMs = CREATE_PHASE_DEADLINE_MS,
567
- /** Host store write: (sessionId, directory, goal) => Promise */
568
- persistSessionGoal = null,
569
514
  /** Host store write: (sessionId, patch) => Promise — required for sidebar isolation */
570
515
  persistSessionMetadata = null,
571
516
  /**
@@ -574,15 +519,6 @@ export const createScheduledTasksRuntime = (deps) => {
574
519
  * @type {null | ((event: { sessionID: string, directory?: string, metadata: object }) => void)}
575
520
  */
576
521
  onSystemSessionPersisted = null,
577
- /** Host store read: (sessionId) => Promise<metadata|null> */
578
- readSessionMetadata = null,
579
- /**
580
- * After a scheduled goal is first persisted, arm the session-goal loop.
581
- * (session-goal runtime's own progress writes only broadcast — do not
582
- * feed those back here.)
583
- * @type {null | ((event: { sessionID: string, directory: string, metadata: object }) => void)}
584
- */
585
- onGoalPersisted = null,
586
522
  } = deps;
587
523
 
588
524
  let started = false;
@@ -847,21 +783,6 @@ export const createScheduledTasksRuntime = (deps) => {
847
783
  return projectRunning < maxProjectConcurrency;
848
784
  };
849
785
 
850
- // Same instruction the composer attaches on an armed goal send: the agent
851
- // must know goal mode is on from turn one, and each turn has to end with a
852
- // factual report for the independent audit.
853
- const buildGoalIntroText = (tokenBudget) => {
854
- const budgetLine = tokenBudget
855
- ? ` A token budget of ${tokenBudget} tokens applies to this goal.`
856
- : '';
857
- return '<system-reminder>\n'
858
- + 'Goal mode is active for this session. The user message above defines the goal objective. '
859
- + 'Work toward it across turns; whenever you stop before the objective is verifiably complete, the system will automatically prompt you to continue. '
860
- + 'Progress is evaluated independently after each turn, so end every turn with a clear, factual statement of what is done, what was verified, and what remains.'
861
- + budgetLine
862
- + '\n</system-reminder>';
863
- };
864
-
865
786
  const buildSessionCreateInput = (task, projectPath, title, metadata) => ({
866
787
  title,
867
788
  location: { directory: projectPath },
@@ -886,146 +807,14 @@ export const createScheduledTasksRuntime = (deps) => {
886
807
  }
887
808
  };
888
809
 
889
- const buildPromptText = (task, projectPath) => {
890
- const promptText = task.execution.prompt;
891
- if (!task.execution.goalEnabled) {
892
- return promptText;
893
- }
894
- return `${promptText}\n${buildGoalIntroText(task.execution.goalTokenBudget)}`;
895
- };
896
-
897
- // Scheduled goal runs: write the file-backed objective, then persist a
898
- // trackable goal record into the Host session-metadata store (same seam as
899
- // manual UI goals). OpenCode SessionInfo has no yuri.goal channel.
900
- const createTaskGoal = async ({
901
- sessionID,
902
- projectPath,
903
- task,
904
- signal,
905
- }) => {
906
- signal?.throwIfAborted?.();
907
- if (typeof persistSessionGoal !== 'function') {
908
- throw new Error('session goal persist is not configured');
909
- }
910
- // File-backed objective keyed by session id: the full expanded prompt
911
- // lives under the Yuri data dir. If the file write fails, fall
912
- // back to an inline objective so parseGoalMetadata still accepts the
913
- // record. Oversized prompts are distilled into audit criteria by the
914
- // small model; on distill failure a head+tail excerpt keeps intent.
915
- let objectiveText = task.execution.prompt;
916
- if (objectiveText.length > 5000) {
917
- let distilled = null;
918
- try {
919
- signal?.throwIfAborted?.();
920
- const service = typeof getSmallModelService === 'function'
921
- ? await getSmallModelService()
922
- : null;
923
- signal?.throwIfAborted?.();
924
- if (!service?.generateSmallModelText) {
925
- throw new Error('Small model service is not configured');
926
- }
927
- const generated = await service.generateSmallModelText({
928
- restrictToPreferredProvider: true,
929
- prompt: objectiveText,
930
- system: [
931
- 'You distill a large task description into the COMPLETION CRITERIA a progress auditor will judge against.',
932
- 'Return ONLY the criteria text — no preamble, no headers, no markdown fences.',
933
- 'Capture: the end goals, what must exist and work when the task is fully done, and how each major part is verified. Omit implementation steps.',
934
- 'Preserve verbatim any file paths, commands, and identifiers that define the task.',
935
- 'Stay under 4000 characters.',
936
- 'Write in the same language as the task text.',
937
- ].join('\n'),
938
- directory: projectPath,
939
- preferredProviderID: task.execution.providerID,
940
- preferredModelID: task.execution.modelID,
941
- });
942
- signal?.throwIfAborted?.();
943
- distilled = typeof generated?.text === 'string' ? generated.text.trim() : null;
944
- } catch (error) {
945
- if (signal?.aborted) {
946
- throw error;
947
- }
948
- console.warn('[scheduled-tasks] goal objective distillation failed:', error?.message || error);
949
- }
950
- if (distilled) {
951
- objectiveText = distilled;
952
- } else {
953
- const marker = '\n\n[… objective trimmed for the auditor — the full prompt was delivered in the chat message …]\n\n';
954
- const half = Math.max(0, Math.floor((5000 - marker.length) / 2));
955
- objectiveText = `${objectiveText.slice(0, half)}${marker}${objectiveText.slice(-half)}`;
956
- }
957
- }
958
- signal?.throwIfAborted?.();
959
- let objectiveFile = false;
960
- try {
961
- const { writeObjective } = await import('../session-goal/objectives.js');
962
- await writeObjective(sessionID, objectiveText);
963
- objectiveFile = true;
964
- signal?.throwIfAborted?.();
965
- } catch (error) {
966
- if (signal?.aborted) {
967
- throw error;
968
- }
969
- console.warn('[scheduled-tasks] goal objective file write failed, continuing with inline objective:', error?.message || error);
970
- }
971
- signal?.throwIfAborted?.();
972
-
973
- const budgetRaw = task.execution?.goalTokenBudget;
974
- const tokenBudget = Number.isFinite(budgetRaw) && budgetRaw > 0
975
- ? Math.floor(budgetRaw)
976
- : null;
977
- const now = Date.now();
978
- const goal = {
979
- id: crypto.randomUUID(),
980
- status: 'active',
981
- // File-backed: flag only (text lives under goals/<sessionId>.md).
982
- // Inline fallback: full objective text when the file write failed.
983
- objective: objectiveFile ? '' : objectiveText,
984
- objectiveFile,
985
- tokenBudget,
986
- tokensUsed: 0,
987
- turnsUsed: 0,
988
- blockedStreak: 0,
989
- note: '',
990
- statusReason: '',
991
- lastAccountedMessageID: '',
992
- executionGeneration: 0,
993
- createdAt: now,
994
- updatedAt: now,
995
- };
996
-
997
- // Persist failure must throw — never prompt as if the goal was registered.
998
- const persisted = await persistSessionGoal(sessionID, projectPath, goal);
999
- signal?.throwIfAborted?.();
1000
-
1001
- if (typeof onGoalPersisted === 'function') {
1002
- try {
1003
- // Prefer full metadata when the seam returns the store object; otherwise
1004
- // synthesize the yuri.goal shape the session-goal loop expects.
1005
- const metadata = persisted
1006
- && typeof persisted === 'object'
1007
- && !Array.isArray(persisted)
1008
- && persisted.yuri
1009
- ? persisted
1010
- : { yuri: { goal } };
1011
- onGoalPersisted({
1012
- sessionID,
1013
- directory: projectPath,
1014
- metadata,
1015
- });
1016
- } catch (error) {
1017
- console.warn('[scheduled-tasks] onGoalPersisted failed:', error?.message || error);
1018
- }
1019
- }
1020
- };
1021
-
1022
810
  const runSessionPrompt = async ({ client, sessionID, projectPath, task, signal }) => {
1023
811
  signal?.throwIfAborted?.();
1024
812
  const requestOptions = signal ? { signal } : undefined;
1025
- await client.session.prompt({
1026
- sessionID,
1027
- text: buildPromptText(task, projectPath),
1028
- }, requestOptions);
813
+ if (task.execution.goalEnabled) {
814
+ await client.session.command({ sessionID, name: 'goal', text: task.execution.prompt }, requestOptions);
815
+ } else {
816
+ await client.session.prompt({ sessionID, text: task.execution.prompt }, requestOptions);
817
+ }
1029
818
  };
1030
819
 
1031
820
  /**
@@ -1042,6 +831,8 @@ export const createScheduledTasksRuntime = (deps) => {
1042
831
  client,
1043
832
  sessionID,
1044
833
  signal,
834
+ projectPath,
835
+ goalEnabled,
1045
836
  }) => {
1046
837
  const requestOptions = signal ? { signal } : undefined;
1047
838
  let emptyIdleProbes = 0;
@@ -1070,6 +861,13 @@ export const createScheduledTasksRuntime = (deps) => {
1070
861
  continue;
1071
862
  }
1072
863
 
864
+ if (goalEnabled) {
865
+ const outcome = await snapshotSessionOutcome({ client, sessionID, projectPath, goalEnabled: true, signal });
866
+ if (outcome.outcome !== 'busy') return outcome;
867
+ await sleep(SESSION_SETTLEMENT_POLL_MS, signal);
868
+ continue;
869
+ }
870
+
1073
871
  try {
1074
872
  const messages = await listLatestMessages(client, sessionID, requestOptions);
1075
873
  if (messages) {
@@ -1104,7 +902,7 @@ export const createScheduledTasksRuntime = (deps) => {
1104
902
 
1105
903
  const runScheduledCommandIfApplicable = async ({ client, projectPath, sessionID, task, signal }) => {
1106
904
  signal?.throwIfAborted?.();
1107
- const parsed = parseScheduledCommandPrompt(task?.execution?.prompt);
905
+ const parsed = task.execution.goalEnabled ? null : parseScheduledCommandPrompt(task?.execution?.prompt);
1108
906
  if (!parsed) {
1109
907
  return false;
1110
908
  }
@@ -1168,18 +966,8 @@ export const createScheduledTasksRuntime = (deps) => {
1168
966
 
1169
967
  signal?.throwIfAborted?.();
1170
968
 
1171
- // Goal-enabled tasks: refuse before session create / objective write /
1172
- // prompt when Host goal state is unavailable OR persist is not wired.
1173
- // Config + run-history stay; only this run is recorded as error (no
1174
- // false first-turn success / no create·distill·prompt side effects).
1175
- if (task.execution?.goalEnabled) {
1176
- const capability = getSessionGoalCapability();
1177
- if (!capability.supported) {
1178
- throw new Error(sessionGoalUnavailableMessage(capability));
1179
- }
1180
- if (typeof persistSessionGoal !== 'function') {
1181
- throw new Error('session goal persist is not configured');
1182
- }
969
+ if (task.execution?.goalEnabled && (task.execution.prompt.length > 4000 || ['pause', 'resume', 'clear'].includes(task.execution.prompt.trim().toLowerCase()))) {
970
+ throw new Error('Invalid native goal objective: use 1–4000 characters, not a goal control word');
1183
971
  }
1184
972
 
1185
973
  if (typeof persistSessionMetadata !== 'function') {
@@ -1279,15 +1067,6 @@ export const createScheduledTasksRuntime = (deps) => {
1279
1067
  } catch {
1280
1068
  }
1281
1069
 
1282
- if (task.execution.goalEnabled) {
1283
- await createTaskGoal({
1284
- sessionID,
1285
- projectPath,
1286
- task,
1287
- signal,
1288
- });
1289
- }
1290
-
1291
1070
  signal?.throwIfAborted?.();
1292
1071
 
1293
1072
  executionErrorsBySession.set(sessionID, null);
@@ -1314,6 +1093,8 @@ export const createScheduledTasksRuntime = (deps) => {
1314
1093
  client,
1315
1094
  sessionID,
1316
1095
  signal,
1096
+ projectPath,
1097
+ goalEnabled: task.execution.goalEnabled || /^\/goal\b/i.test(task.execution.prompt.trim()),
1317
1098
  });
1318
1099
 
1319
1100
  const finishedAt = Date.now();
@@ -1530,7 +1311,7 @@ export const createScheduledTasksRuntime = (deps) => {
1530
1311
  ]);
1531
1312
 
1532
1313
  if (raced.timedOut) {
1533
- // Bound: do not await uncancellable steps (distill / writeObjective).
1314
+ // Bound: do not await uncancellable steps after the deadline.
1534
1315
  // session.interrupt is started by the signal listener on create;
1535
1316
  // later throwIfAborted gates stop goal write / command / prompt.
1536
1317
  throw timeoutError;
@@ -1806,7 +1587,6 @@ export const createScheduledTasksRuntime = (deps) => {
1806
1587
  sessionID,
1807
1588
  projectPath: projectPathByID.get(projectID),
1808
1589
  goalEnabled: Boolean(task.execution?.goalEnabled),
1809
- readSessionMetadata,
1810
1590
  signal,
1811
1591
  });
1812
1592
  if (signal.aborted || runningTaskKeys.has(taskKey) || tasksByProject.get(projectID)?.get(taskID) !== task) continue;
@@ -1849,15 +1629,12 @@ export const createScheduledTasksRuntime = (deps) => {
1849
1629
  if (!run.sessionId || runningTaskKeys.has(buildTaskKey(run.projectId, run.taskId))) continue;
1850
1630
  try {
1851
1631
  if (typeof client?.session?.active !== 'function') continue;
1852
- const metadata = typeof readSessionMetadata === 'function'
1853
- ? await readSessionMetadata(run.sessionId)
1854
- : null;
1632
+ const goal = await getNativeSessionGoal(client, run.sessionId, run.directory, signal);
1855
1633
  const snapshot = await snapshotSessionOutcome({
1856
1634
  client,
1857
1635
  sessionID: run.sessionId,
1858
1636
  projectPath: run.directory,
1859
- goalEnabled: Boolean(extractGoalFromSession({ metadata })),
1860
- readSessionMetadata: typeof readSessionMetadata === 'function' ? async () => metadata : null,
1637
+ goalEnabled: Boolean(goal),
1861
1638
  signal,
1862
1639
  });
1863
1640
  if (signal.aborted || runningTaskKeys.has(buildTaskKey(run.projectId, run.taskId))) continue;
@@ -2019,7 +1796,6 @@ export const createScheduledTasksRuntime = (deps) => {
2019
1796
  sessionID,
2020
1797
  projectPath,
2021
1798
  goalEnabled: Boolean(task.execution?.goalEnabled),
2022
- readSessionMetadata,
2023
1799
  });
2024
1800
  if (snapshot.outcome !== 'success' && snapshot.outcome !== 'error') {
2025
1801
  return;