@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.
- package/dist/assets/{AgentAvatar-BJ42lGZD.js → AgentAvatar-BybF1ayP.js} +1 -1
- package/dist/assets/AssistantContactStatus-BwpxTn0d.js +3 -0
- package/dist/assets/{AssistantUnreadBadge-QwhBfXpC.js → AssistantUnreadBadge-DqThZdCe.js} +1 -1
- package/dist/assets/{AssistantView-D7ryIKL0.js → AssistantView-DPUDCXoY.js} +1 -1
- package/dist/assets/{DiagramView-ERrGEBDp.js → DiagramView-CHVLoYrV.js} +1 -1
- package/dist/assets/{FadeInOnReveal-Bu2GvaM9.js → FadeInOnReveal-Cj3JXYvE.js} +1 -1
- package/dist/assets/{GuiPluginSurface-MzQgEZNr.js → GuiPluginSurface-CBZYeKHb.js} +1 -1
- package/dist/assets/{GuiPluginWindow-DZMmlQzx.js → GuiPluginWindow-_Z5wycnH.js} +1 -1
- package/dist/assets/{Icon-Dj4CCqCP.js → Icon-CeRMtJa8.js} +1 -1
- package/dist/assets/{ImageLoadingPlaceholder-BnFXgUuO.js → ImageLoadingPlaceholder-DjLaKB4o.js} +1 -1
- package/dist/assets/{LoadingImage-PBnivDKv.js → LoadingImage-DG3otL5V.js} +1 -1
- package/dist/assets/MarkdownRenderer-C8rv6z7p.js +2 -0
- package/dist/assets/{MarkdownRendererImpl-CfyXL4rg.js → MarkdownRendererImpl-_plqOlsV.js} +1 -1
- package/dist/assets/{MarkstreamRendererImpl-BGadklK1.js → MarkstreamRendererImpl-bs8HZ4Ra.js} +1 -1
- package/dist/assets/{MobileDetailNavigation-DqajQdB4.js → MobileDetailNavigation-SeT764Ps.js} +1 -1
- package/dist/assets/{MobileResizableSheet-BvdUgwA3.js → MobileResizableSheet-BY1-oo_E.js} +1 -1
- package/dist/assets/{MobileShareBridge-3oPoYnry.js → MobileShareBridge-Dw8gLtJD.js} +2 -2
- package/dist/assets/MobileTabPageHeader-EsrOCLyg.js +2 -0
- package/dist/assets/{MultiRunWindow-yhs0Ih5_.js → MultiRunWindow-C-Qw_g7N.js} +1 -1
- package/dist/assets/{OnboardingScreen-Bi1VWFQC.js → OnboardingScreen-CGqabMbp.js} +1 -1
- package/dist/assets/{OverlayScrollbar-BBDwGvGO.js → OverlayScrollbar-AGSWQKg-.js} +1 -1
- package/dist/assets/{SettingsView-BSf-SJUA.js → SettingsView-BLfFnnnX.js} +14 -14
- package/dist/assets/{SettingsWindow-BvSXVMTm.js → SettingsWindow-lyYO8Byy.js} +1 -1
- package/dist/assets/{TerminalView-DhL01N7e.js → TerminalView-OHqpkHzz.js} +1 -1
- package/dist/assets/{ToolOutputDialog-C8lnH4Ky.js → ToolOutputDialog-DU4Pb1s0.js} +1 -1
- package/dist/assets/{YuriLogo-D8asj1CS.js → YuriLogo-Bb6yHagP.js} +1 -1
- package/dist/assets/{appThemeRegistry-C-maYSdv.js → appThemeRegistry-9j-rCSlE.js} +1 -1
- package/dist/assets/{button-vXOdzd8x.js → button-Bjh2BSXh.js} +1 -1
- package/dist/assets/{capgoAdapter-DJ_h2x5D.js → capgoAdapter-DERfot6h.js} +1 -1
- package/dist/assets/{collapsible-DwDQs3Wa.js → collapsible-BEAHoxNi.js} +1 -1
- package/dist/assets/{context-menu-BabBujQ-.js → context-menu-BxLcot-3.js} +1 -1
- package/dist/assets/device-BcRP6Tjd.js +2 -0
- package/dist/assets/{diagram-HwgrQxY5.js → diagram-CXVm2vzI.js} +1 -1
- package/dist/assets/{dialog-Dnf626tb.js → dialog-nshKUSE5.js} +1 -1
- package/dist/assets/{dropdown-menu.styles-CBc_a-Nv.js → dropdown-menu.styles-M78xpvb2.js} +1 -1
- package/dist/assets/{es-BQkO-Odr.js → es-N9ZkQwG9.js} +2 -2
- package/dist/assets/fileMentionAutocompleteState-BZJqfgae.js +2 -0
- package/dist/assets/{fileMentionTouchSelection-CKPnEetl.js → fileMentionTouchSelection-B9NbPN9D.js} +2 -2
- package/dist/assets/{fileReferenceActions-g7KZLi_G.js → fileReferenceActions-CrIAce3K.js} +1 -1
- package/dist/assets/{fr-C852roK5.js → fr-CIGqV46N.js} +2 -2
- package/dist/assets/{gitApi-CVq5oKCd.js → gitApi-CY3D5CF0.js} +1 -1
- package/dist/assets/{gitApiHttp-BYOIbYIh.js → gitApiHttp-B7vYwgBh.js} +4 -4
- package/dist/assets/{gui-M_Rbwkyu.js → gui-CJjEj3l4.js} +1 -1
- package/dist/assets/host-CnVx34Dh.js +1 -0
- package/dist/assets/{image-loading-D5UhMj7Z.js → image-loading-D6kOgU4w.js} +1 -1
- package/dist/assets/{input-BtM712b1.js → input-3Re4pmHm.js} +1 -1
- package/dist/assets/insertionBoundaries-DK7XYF8d.js +1 -0
- package/dist/assets/{ja-BqC39qK6.js → ja-DAhnTq6V.js} +2 -2
- package/dist/assets/{ko-BMaChAWh.js → ko-FbMgNKcI.js} +2 -2
- package/dist/assets/main-B_THXYMs.js +2 -0
- package/dist/assets/main-CpcudEZb.js +169 -0
- package/dist/assets/{markdownHeightCache-Bf8iisO4.js → markdownHeightCache-DVWGXtAX.js} +1 -1
- package/dist/assets/{mcpQueries-DpXqegX5.js → mcpQueries-CdOYmUdO.js} +1 -1
- package/dist/assets/miniChat-DxZiTnAZ.js +2 -0
- package/dist/assets/mobile-BJuATiaC.js +2 -0
- package/dist/assets/{mobileBackNavigation-DZcI7aZg.js → mobileBackNavigation-CgZndzFA.js} +1 -1
- package/dist/assets/{multirun-hzspPepd.js → multirun-BlaYsQi2.js} +1 -1
- package/dist/assets/{native-H7K64Ulc.js → native-BYMhr-xH.js} +1 -1
- package/dist/assets/{native-config-CddZtLQ1.js → native-config-BpsFKLGl.js} +1 -1
- package/dist/assets/{persistence-BT8045Ue.js → persistence-CWuLIq1J.js} +2 -2
- package/dist/assets/{pl-Ubs8p28T.js → pl-DzX0cbiQ.js} +2 -2
- package/dist/assets/{projectMeta-CEf0QPmD.js → projectMeta-CnXHTolN.js} +1 -1
- package/dist/assets/{pt-BR-8rAOjJrs.js → pt-BR-C5yvwyDK.js} +2 -2
- package/dist/assets/queue-abort-optimistic-DCLBpirg.js +1 -0
- package/dist/assets/{readiness-Dyr7314z.js → readiness-U16Qor79.js} +1 -1
- package/dist/assets/renderElectronMiniChatApp-n-nhgy1V.js +2 -0
- package/dist/assets/renderMobileApp-DBj_7RlD.js +28 -0
- package/dist/assets/{runtimeConfig-B8VHHNxj.js → runtimeConfig-BBgkLVr_.js} +1 -1
- package/dist/assets/runtimeEndpointReset-BvSQVFfx.js +149 -0
- package/dist/assets/{scheduledTaskNavigation-Zm87Nydi.js → scheduledTaskNavigation-EomDNVu2.js} +1 -1
- package/dist/assets/sessionLookup-C_CCp7MJ.js +1 -0
- package/dist/assets/{sortable-tabs-strip-D4pVoodN.js → sortable-tabs-strip-p16Pn6Zz.js} +1 -1
- package/dist/assets/{speechSettingsQueries-RlCLMBtr.js → speechSettingsQueries-CBSEAKyj.js} +2 -2
- package/dist/assets/src-u-YDfCVw.css +2 -0
- package/dist/assets/{store-ME7oHni1.js → store-DVfZQktm.js} +4 -3
- package/dist/assets/{terminalApi-BSaclMDJ.js → terminalApi-rl9mZAlB.js} +1 -1
- package/dist/assets/{textarea-B98rsLs7.js → textarea-C6VQ7dHH.js} +1 -1
- package/dist/assets/{tooltip-B9810jbK.js → tooltip-Dnc6GA-X.js} +1 -1
- package/dist/assets/types-DnZw0gLD.js +2 -0
- package/dist/assets/{uk-LzwzUApL.js → uk-zbDcUpBy.js} +2 -2
- package/dist/assets/{useAppFontEffects-D2C1sBYM.js → useAppFontEffects-CEgDiZHu.js} +49 -49
- package/dist/assets/{useAssistantUIStore-TUN_ycy5.js → useAssistantUIStore-CfaQV3ID.js} +1 -1
- package/dist/assets/useDesktopWindowControlsLayout-B2o4IFmd.js +1 -0
- package/dist/assets/useEffectiveDirectory-BOYMJ6k7.js +1 -0
- package/dist/assets/{useFontPreferences-BlhlCJCX.js → useFontPreferences-DeqW9nRx.js} +1 -1
- package/dist/assets/useMobileNavigationStore-DlvrZQ49.js +17 -0
- package/dist/assets/{useUIStore-DRx6OgCp.js → useUIStore-C6CE42oh.js} +1 -1
- package/dist/assets/{useWorkerHighlightedLines-D093jNsH.js → useWorkerHighlightedLines-EcJThS4x.js} +1 -1
- package/dist/assets/{vendor-effect-DV9F8PTZ.js → vendor-effect-X1Hqc7ba.js} +13 -13
- package/dist/assets/vendor-opencode-client-cQ47ywrT.js +23 -0
- package/dist/assets/{vendor-opencode-plugin-BBOP6WNx.js → vendor-opencode-plugin-BmdTE4Te.js} +1 -1
- package/dist/assets/vendor-opencode-schema-DWT45VBX.js +1 -0
- package/dist/assets/vendor-solid-js-D98iXT7C.js +1 -0
- package/dist/assets/vendor-zod-DZzbCm1s.js +55 -0
- package/dist/assets/{zh-CN-D-FVCeks.js → zh-CN-BHRJ7CF3.js} +2 -2
- package/dist/assets/{zh-TW-B9iH_NXL.js → zh-TW-BFI_YFd-.js} +2 -2
- package/dist/index.html +12 -12
- package/dist/mini-chat.html +12 -12
- package/dist/mobile.html +12 -12
- package/package.json +1 -1
- package/server/index.js +2 -145
- package/server/lib/assistants/DOCUMENTATION.md +63 -10
- package/server/lib/assistants/cards.js +1 -1
- package/server/lib/assistants/channel-image.js +92 -0
- package/server/lib/assistants/channel-image.test.js +76 -0
- package/server/lib/assistants/channel-output-store.test.js +41 -0
- package/server/lib/assistants/channel-output.integration.test.js +128 -0
- package/server/lib/assistants/channel-output.js +90 -0
- package/server/lib/assistants/channel-output.test.js +79 -0
- package/server/lib/assistants/channels/DOCUMENTATION.md +52 -14
- package/server/lib/assistants/channels/PROTOCOLS.md +23 -1
- package/server/lib/assistants/channels/dingtalk-chat-adapter.js +19 -7
- package/server/lib/assistants/channels/dingtalk-chat-adapter.test.js +8 -0
- package/server/lib/assistants/channels/routes.js +12 -0
- package/server/lib/assistants/channels/routes.test.js +34 -0
- package/server/lib/assistants/channels/runtime.js +117 -26
- package/server/lib/assistants/channels/runtime.test.js +179 -5
- package/server/lib/assistants/channels/sdk-adapters.js +15 -3
- package/server/lib/assistants/channels/sdk-adapters.test.js +17 -0
- package/server/lib/assistants/channels/store.js +9 -6
- package/server/lib/assistants/channels/store.test.js +21 -11
- package/server/lib/assistants/channels/transport.js +2 -1
- package/server/lib/assistants/channels/wecom-chat-adapter.js +16 -2
- package/server/lib/assistants/channels/wecom-chat-adapter.test.js +21 -0
- package/server/lib/assistants/contact-store.js +9 -3
- package/server/lib/assistants/contact-store.test.js +27 -0
- package/server/lib/assistants/contact-tools.js +65 -75
- package/server/lib/assistants/contact-tools.test.js +114 -22
- package/server/lib/assistants/harness.js +80 -34
- package/server/lib/assistants/harness.test.js +68 -20
- package/server/lib/assistants/resource-reference.integration.test.js +284 -0
- package/server/lib/assistants/routes.js +0 -3
- package/server/lib/assistants/service.js +116 -69
- package/server/lib/assistants/service.test.js +31 -17
- package/server/lib/assistants/weixin/DOCUMENTATION.md +34 -9
- package/server/lib/assistants/weixin/api.js +43 -1
- package/server/lib/assistants/weixin/api.test.js +28 -0
- package/server/lib/assistants/weixin/chat-adapter.js +8 -2
- package/server/lib/assistants/weixin/inbound.js +5 -3
- package/server/lib/assistants/weixin/inbound.test.js +20 -0
- package/server/lib/assistants/weixin/runtime.js +27 -18
- package/server/lib/assistants/weixin/runtime.test.js +36 -0
- package/server/lib/assistants/weixin/store.js +8 -4
- package/server/lib/assistants/weixin/store.test.js +21 -0
- package/server/lib/assistants/yuri-project.http.test.js +9 -3
- package/server/lib/notifications/DOCUMENTATION.md +6 -0
- package/server/lib/notifications/runtime.js +26 -15
- package/server/lib/notifications/runtime.test.js +14 -13
- package/server/lib/opencode/DOCUMENTATION.md +9 -0
- package/server/lib/opencode/auth.d.ts +6 -2
- package/server/lib/opencode/core-routes.js +0 -1
- package/server/lib/opencode/feature-routes-runtime.js +0 -24
- package/server/lib/opencode/location-release.d.ts +5 -1
- package/server/lib/opencode/managed-capabilities/scheduled-task.js +1 -1
- package/server/lib/opencode/managed-capabilities-runtime.test.js +1 -1
- package/server/lib/opencode/native-goal.js +15 -0
- package/server/lib/opencode/native-goal.test.js +17 -0
- package/server/lib/opencode/settings-helpers.js +0 -6
- package/server/lib/opencode/shutdown-runtime.js +0 -2
- package/server/lib/projects/project-config.js +3 -6
- package/server/lib/scheduled-tasks/DOCUMENTATION.md +10 -35
- package/server/lib/scheduled-tasks/managed-tool-route.js +1 -30
- package/server/lib/scheduled-tasks/routes.js +0 -26
- package/server/lib/scheduled-tasks/runtime.js +33 -257
- package/server/lib/scheduled-tasks/runtime.test.js +24 -65
- package/server/lib/session-metadata/DOCUMENTATION.md +9 -12
- package/server/lib/session-metadata/routes.js +4 -38
- package/server/lib/session-metadata/routes.test.js +2 -2
- package/dist/assets/AssistantContactStatus-dtkObamV.js +0 -3
- package/dist/assets/MarkdownRenderer-BajF4gUU.js +0 -2
- package/dist/assets/MobileTabPageHeader-B6cRyIRH.js +0 -2
- package/dist/assets/device-BjRYYXNT.js +0 -2
- package/dist/assets/host-BW3FEJdU.js +0 -1
- package/dist/assets/insertionBoundaries-Dx3WAY6i.js +0 -1
- package/dist/assets/main-9uP2z1qT.js +0 -2
- package/dist/assets/main-Mey7bCWf.js +0 -169
- package/dist/assets/miniChat-DqZvVkme.js +0 -2
- package/dist/assets/mobile-DXAWjYcN.js +0 -2
- package/dist/assets/renderElectronMiniChatApp-DoOq8Cuo.js +0 -2
- package/dist/assets/renderMobileApp-TTxtOb8b.js +0 -28
- package/dist/assets/runtimeEndpointReset-BC6XWntz.js +0 -149
- package/dist/assets/sessionLookup-De53jDwM.js +0 -1
- package/dist/assets/src-lE4uqaHS.css +0 -2
- package/dist/assets/types-DFf9vd1b.js +0 -2
- package/dist/assets/useDesktopWindowControlsLayout-BjKaHN0x.js +0 -1
- package/dist/assets/useEffectiveDirectory-TEvyiQSC.js +0 -1
- package/dist/assets/useMobileNavigationStore-DTvJV9s-.js +0 -23
- package/dist/assets/vendor-opencode-client-ZeOZ4Efz.js +0 -23
- package/dist/assets/vendor-solid-js-9wmPZH9g.js +0 -1
- package/dist/assets/vendor-zod-Dzk5kdUU.js +0 -39
- package/server/lib/session-goal/DOCUMENTATION.md +0 -371
- package/server/lib/session-goal/capability.js +0 -57
- package/server/lib/session-goal/capability.test.js +0 -33
- package/server/lib/session-goal/objectives.js +0 -61
- package/server/lib/session-goal/routes.js +0 -274
- package/server/lib/session-goal/routes.test.js +0 -211
- package/server/lib/session-goal/runtime.js +0 -2452
- package/server/lib/session-goal/runtime.test.js +0 -2125
|
@@ -17,6 +17,27 @@ const bind = (store, assistant_id = 'bot') => store.bind({ assistant_id, account
|
|
|
17
17
|
base_url: 'https://ilinkai.weixin.qq.com', language: 'zh-CN', generation: 0, ordinal: 0, updated_at: 1 });
|
|
18
18
|
|
|
19
19
|
describe('WeChat structured receipt persistence', () => {
|
|
20
|
+
it('bypasses failed/unknown sends across restart without dropping them or changing pending order', () => {
|
|
21
|
+
const dir = directory();
|
|
22
|
+
let store = createWeixinStore(dir);
|
|
23
|
+
cleanup.push(() => store.close());
|
|
24
|
+
const binding = bind(store);
|
|
25
|
+
for (const id of ['unknown', 'blocked', 'second', 'third']) store.enqueue(binding.epoch, id, id);
|
|
26
|
+
store.markDelivery('unknown', 'unknown');
|
|
27
|
+
store.markDelivery('blocked', 'blocked');
|
|
28
|
+
store.close();
|
|
29
|
+
store = createWeixinStore(dir);
|
|
30
|
+
expect(store.nextDelivery(binding.epoch)).toMatchObject({ id: 'second', state: 'pending' });
|
|
31
|
+
store.sent('second');
|
|
32
|
+
expect(store.nextDelivery(binding.epoch)).toMatchObject({ id: 'third', state: 'pending' });
|
|
33
|
+
expect(store.hasUnknown(binding.epoch)).toBe(true);
|
|
34
|
+
expect(store.hasBlocked(binding.epoch)).toBe(true);
|
|
35
|
+
store.retry(binding.epoch);
|
|
36
|
+
expect(store.nextDelivery(binding.epoch)).toMatchObject({ id: 'unknown', state: 'pending' });
|
|
37
|
+
store.sent('unknown');
|
|
38
|
+
expect(store.nextDelivery(binding.epoch)).toMatchObject({ id: 'blocked', state: 'pending' });
|
|
39
|
+
});
|
|
40
|
+
|
|
20
41
|
it('adds the payload column to an existing text-only database without losing cursor, receipts or binding', () => {
|
|
21
42
|
const dir = directory();
|
|
22
43
|
let store = createWeixinStore(dir);
|
|
@@ -61,7 +61,7 @@ describe('HTTP → real contact Agent → project registry → worker admission'
|
|
|
61
61
|
expect(createWorker).not.toHaveBeenCalled();
|
|
62
62
|
expect(promptWorker).not.toHaveBeenCalled();
|
|
63
63
|
} finally {
|
|
64
|
-
runtime.close(); server.closeAllConnections();
|
|
64
|
+
await runtime.close(); server.closeAllConnections();
|
|
65
65
|
await new Promise((resolve) => server.close(resolve));
|
|
66
66
|
external.complete = null; external.client = null;
|
|
67
67
|
await fs.rm(directory, { recursive: true, force: true });
|
|
@@ -86,7 +86,7 @@ describe('HTTP → real contact Agent → project registry → worker admission'
|
|
|
86
86
|
provider: { list: async () => ({ data: [{ id: 'p' }] }) },
|
|
87
87
|
model: { list: async () => ({ data: [{ id: 'm', providerID: 'p' }] }) },
|
|
88
88
|
skill: { list: async () => ({ data: [] }) },
|
|
89
|
-
session: { create: creates, prompt: prompts, active: async () => ({}) },
|
|
89
|
+
session: { create: creates, prompt: prompts, active: async () => ({}), get: async ({ sessionID }) => ({ id: sessionID, directory: canonical, title: 'Hello', status: { type: 'busy' } }) },
|
|
90
90
|
};
|
|
91
91
|
const roots = [];
|
|
92
92
|
const refresh = async () => {
|
|
@@ -113,6 +113,12 @@ describe('HTTP → real contact Agent → project registry → worker admission'
|
|
|
113
113
|
expect(body.messages.find((message) => message.name === 'register_project')?.content).toContain(canonical);
|
|
114
114
|
return call('assign_session', { projectPath: canonical, prompt: 'hello' });
|
|
115
115
|
}
|
|
116
|
+
if (round === 5) {
|
|
117
|
+
expect(body.tools.map((tool) => tool.function.name)).toEqual(['reference_resource']);
|
|
118
|
+
expect(body.messages.find((message) => message.name === 'assign_session')?.content).toContain('ses_hello');
|
|
119
|
+
return call('reference_resource', { cardType: 'session', sessionID: 'ses_hello' });
|
|
120
|
+
}
|
|
121
|
+
expect(body.messages.find((message) => message.name === 'reference_resource')?.content).toContain('sent');
|
|
116
122
|
return { text: '已在这个项目里创建会话并发送 hello。' };
|
|
117
123
|
};
|
|
118
124
|
const app = express(); app.use(express.json());
|
|
@@ -164,7 +170,7 @@ describe('HTTP → real contact Agent → project registry → worker admission'
|
|
|
164
170
|
expect(prompts.mock.calls.at(-1)[0]).toEqual({ sessionID: 'ses_hello', id: 'ordinary-session', text: 'ordinary hello', delivery: 'steer' });
|
|
165
171
|
expect(round).toBe(modelRounds);
|
|
166
172
|
} finally {
|
|
167
|
-
runtime.close(); server.closeAllConnections();
|
|
173
|
+
await runtime.close(); server.closeAllConnections();
|
|
168
174
|
await new Promise((resolve) => server.close(resolve));
|
|
169
175
|
external.complete = null; external.client = null;
|
|
170
176
|
await fs.rm(directory, { recursive: true, force: true });
|
|
@@ -59,6 +59,12 @@ Android notification-only subscriptions send the App locale in `Accept-Language`
|
|
|
59
59
|
|
|
60
60
|
### Trigger runtime API (runtime.js)
|
|
61
61
|
|
|
62
|
+
Native Goal completion notifications consume `rpc.opencode.goal.changed` with the
|
|
63
|
+
official Goal schema. Only native `complete` triggers goal-completion push;
|
|
64
|
+
active/paused/cleared or malformed snapshots do not. Ordinary per-turn completion
|
|
65
|
+
suppression reads native Goal RPC, never legacy `yuri.goal` metadata. No Host Goal
|
|
66
|
+
auditor, token budget, objective file or continuation loop remains.
|
|
67
|
+
|
|
62
68
|
Ordinary completion means the whole root-session family has stopped. An assistant `finish: stop`, `session.idle`, or `session.execution.succeeded` is only a candidate. Before fanout, the barrier reads successful process-wide `session.active` membership and resolves active IDs' authoritative parent chains, including nested descendants and idle intermediate parents. It never depends on focused UI, loaded transcripts, or a cached tool's apparent completion. A candidate root remains pending while it or any descendant runs; child terminals recheck the pending root rather than sending a separate child notification. Metadata lookup concurrency is capped at four per check, with per-check parent-read deduplication and the Host's existing identity cache.
|
|
63
69
|
|
|
64
70
|
Failed/malformed activity or unknown/cyclic ancestry defers completion rather than treating it as empty. While candidates exist, a single two-second retry timer recovers failed reads and missed child terminal events; no candidates means no polling. Execution/retry/step starts invalidate in-flight eligibility, and a new root run cancels its older candidate. Parent failures, deletion and user interruption cancel success. Event revisions fence stale reads and notification-template enrichment. Successful handling deduplicates terminal events for that root until a new execution starts, replacing the old five-second cooldown so a legitimate short next task can notify. Pending/dedup state is in-memory for the runtime lifetime; historical completions are not replayed after Host restart. `dispose()` clears completion retries and question/permission timers; VS Code also resets its gate on runtime switches.
|
|
@@ -1,5 +1,9 @@
|
|
|
1
1
|
import { readNotificationSessionRecord } from './template-runtime.js';
|
|
2
2
|
import { completionEvent, createFamilyCompletionGate } from './family-completion-gate.js';
|
|
3
|
+
import { makeOpenCodeV2Client } from '../opencode/v2-client.js';
|
|
4
|
+
import { getNativeSessionGoal } from '../opencode/native-goal.js';
|
|
5
|
+
import { Goal } from '@opencode/schema/goal';
|
|
6
|
+
import { Schema } from 'effect';
|
|
3
7
|
|
|
4
8
|
const trimmedText = (value) => (typeof value === 'string' && value.trim() ? value.trim() : '');
|
|
5
9
|
|
|
@@ -445,22 +449,12 @@ export const createNotificationTriggerRuntime = (deps) => {
|
|
|
445
449
|
return trimmedText(meta?.title);
|
|
446
450
|
};
|
|
447
451
|
|
|
448
|
-
//
|
|
449
|
-
// the session-goal runtime sends its own notification when the goal
|
|
450
|
-
// settles. Fetch failures fall through to normal notification behavior.
|
|
452
|
+
// The native goal remains active until OpenCode's own reviewer settles it.
|
|
451
453
|
const hasActiveSessionGoal = async (sessionId, directory) => {
|
|
452
454
|
if (!sessionId) return false;
|
|
453
455
|
try {
|
|
454
|
-
const
|
|
455
|
-
const
|
|
456
|
-
const response = await fetch(url, {
|
|
457
|
-
method: 'GET',
|
|
458
|
-
headers: { Accept: 'application/json', ...getOpenCodeAuthHeaders() },
|
|
459
|
-
signal: AbortSignal.timeout(2000),
|
|
460
|
-
});
|
|
461
|
-
if (!response.ok) return false;
|
|
462
|
-
const session = readNotificationSessionRecord(await response.json().catch(() => null));
|
|
463
|
-
const goal = session?.metadata?.yuri?.goal;
|
|
456
|
+
const client = makeOpenCodeV2Client({ baseUrl: buildOpenCodeUrl('/', '').replace(/\/$/, ''), authHeaders: getOpenCodeAuthHeaders() });
|
|
457
|
+
const goal = await getNativeSessionGoal(client, sessionId, directory, AbortSignal.timeout(2000));
|
|
464
458
|
return Boolean(goal && typeof goal === 'object' && goal.status === 'active');
|
|
465
459
|
} catch {
|
|
466
460
|
return false;
|
|
@@ -555,7 +549,7 @@ export const createNotificationTriggerRuntime = (deps) => {
|
|
|
555
549
|
|
|
556
550
|
// While a goal drives the session, per-turn "ready" notifications are
|
|
557
551
|
// noise produced by the goal loop itself — the goal's own settle
|
|
558
|
-
// notification
|
|
552
|
+
// notification comes from OpenCode's native Goal changed event instead.
|
|
559
553
|
if (await hasActiveSessionGoal(sessionId, notificationDirectory)) {
|
|
560
554
|
return;
|
|
561
555
|
}
|
|
@@ -883,6 +877,18 @@ export const createNotificationTriggerRuntime = (deps) => {
|
|
|
883
877
|
const nativeFailures = new Map();
|
|
884
878
|
const maybeSendPushForTrigger = async (payload) => {
|
|
885
879
|
maybeCacheSessionMetaFromPayload(payload);
|
|
880
|
+
if (payload.type === 'rpc.opencode.goal.changed') {
|
|
881
|
+
const parsed = Schema.decodeUnknownExit(Goal.Definition.events.changed.schema)(payload.properties ?? payload.data);
|
|
882
|
+
if (parsed._tag === 'Failure' || parsed.value.goal?.status !== 'complete') return;
|
|
883
|
+
const { sessionID, goal } = parsed.value;
|
|
884
|
+
const directory = extractDirectoryFromPayload(payload);
|
|
885
|
+
if (await shouldSkipSystemSessionNotification(sessionID, directory)) return;
|
|
886
|
+
await sendGoalSettlePush({
|
|
887
|
+
sessionId: sessionID, directory, status: 'complete', title: 'Goal complete',
|
|
888
|
+
body: [goal.objective, goal.reason].filter(Boolean).join(' — ').slice(0, 240),
|
|
889
|
+
});
|
|
890
|
+
return;
|
|
891
|
+
}
|
|
886
892
|
const event = completionEvent(payload);
|
|
887
893
|
if (event) {
|
|
888
894
|
if (event.kind === 'running' || payload.type === 'session.deleted') nativeFailures.delete(event.sessionId);
|
|
@@ -920,6 +926,11 @@ export const createNotificationTriggerRuntime = (deps) => {
|
|
|
920
926
|
const sendGoalSettlePush = async ({ sessionId, directory, status, title, body }) => {
|
|
921
927
|
const settings = await readSettingsFromDisk();
|
|
922
928
|
if (settings.notifyOnGoals === false) return;
|
|
929
|
+
if (settings.nativeNotificationsEnabled && (settings.notificationMode === 'always' || !getIsWindowFocused?.())) {
|
|
930
|
+
const notification = { title, body, tag: `goal-${sessionId}`, kind: 'goal', sessionId, directory };
|
|
931
|
+
const desktopNotificationDelivered = emitDesktopNotification(notification);
|
|
932
|
+
broadcastUiNotification(notification, { desktopNotificationDelivered });
|
|
933
|
+
}
|
|
923
934
|
let sessionName = '';
|
|
924
935
|
try {
|
|
925
936
|
const base = buildOpenCodeUrl(`/session/${encodeURIComponent(sessionId)}`, '');
|
|
@@ -936,7 +947,7 @@ export const createNotificationTriggerRuntime = (deps) => {
|
|
|
936
947
|
} catch {
|
|
937
948
|
// Session name is presentation sugar for the mobile push — never block on it.
|
|
938
949
|
}
|
|
939
|
-
const type = status === 'complete' ? 'goal_complete' :
|
|
950
|
+
const type = status === 'complete' ? 'goal_complete' : 'goal_blocked';
|
|
940
951
|
await fanoutPush(
|
|
941
952
|
{
|
|
942
953
|
title,
|
|
@@ -51,6 +51,14 @@ const jsonResponse = (body, status = 200) => new Response(JSON.stringify(body),
|
|
|
51
51
|
headers: { 'Content-Type': 'application/json' },
|
|
52
52
|
});
|
|
53
53
|
|
|
54
|
+
const nativeGoalEvent = (status = 'complete') => ({
|
|
55
|
+
type: 'rpc.opencode.goal.changed', location: { directory: '/repo' },
|
|
56
|
+
data: { sessionID: 'ses_goal', goal: {
|
|
57
|
+
id: 'g1', objective: 'Verify native Goal', status, reason: 'Verified',
|
|
58
|
+
rounds: 1, maxRounds: 50, boot: 'boot', updatedAt: 1,
|
|
59
|
+
} },
|
|
60
|
+
});
|
|
61
|
+
|
|
54
62
|
afterEach(() => {
|
|
55
63
|
runtimes.splice(0).forEach(runtime => runtime.dispose());
|
|
56
64
|
vi.unstubAllGlobals();
|
|
@@ -718,12 +726,7 @@ describe('notification event toggles', () => {
|
|
|
718
726
|
const { runtime, sendPushToAllUiSessions } = createRuntime({
|
|
719
727
|
readSettingsFromDisk: vi.fn(async () => ({ ...defaultSettings, notifyOnGoals: false })),
|
|
720
728
|
});
|
|
721
|
-
await runtime.
|
|
722
|
-
sessionId: 'ses_goal',
|
|
723
|
-
status: 'complete',
|
|
724
|
-
title: 'Goal completed',
|
|
725
|
-
body: 'all done',
|
|
726
|
-
});
|
|
729
|
+
await runtime.maybeSendPushForTrigger(nativeGoalEvent());
|
|
727
730
|
expect(sendPushToAllUiSessions).not.toHaveBeenCalled();
|
|
728
731
|
});
|
|
729
732
|
|
|
@@ -818,15 +821,13 @@ describe('notification event toggles', () => {
|
|
|
818
821
|
);
|
|
819
822
|
});
|
|
820
823
|
|
|
821
|
-
it('
|
|
824
|
+
it('sends goal completion from the native changed event, not from Host metadata', async () => {
|
|
822
825
|
vi.stubGlobal('fetch', vi.fn(async () => jsonResponse({ id: 'ses_goal', title: 'Goal run' })));
|
|
823
826
|
const { runtime, sendPushToAllUiSessions } = createRuntime();
|
|
824
|
-
await runtime.
|
|
825
|
-
|
|
826
|
-
|
|
827
|
-
|
|
828
|
-
body: 'all done',
|
|
829
|
-
});
|
|
827
|
+
await runtime.maybeSendPushForTrigger(nativeGoalEvent('active'));
|
|
828
|
+
await runtime.maybeSendPushForTrigger(nativeGoalEvent('paused'));
|
|
829
|
+
expect(sendPushToAllUiSessions).not.toHaveBeenCalled();
|
|
830
|
+
await runtime.maybeSendPushForTrigger(nativeGoalEvent());
|
|
830
831
|
expect(sendPushToAllUiSessions).toHaveBeenCalledTimes(1);
|
|
831
832
|
expect(sendPushToAllUiSessions.mock.calls[0][0]).toMatchObject({ tag: 'goal-ses_goal' });
|
|
832
833
|
expect(sendPushToAllUiSessions.mock.calls[0][0].data).toMatchObject({ sessionName: 'Goal run' });
|
|
@@ -10,6 +10,10 @@ diagnostics use provider/location/session-active V2 routes and location query
|
|
|
10
10
|
encoding, not removed V1 endpoints.
|
|
11
11
|
|
|
12
12
|
## Entrypoints and structure
|
|
13
|
+
- `native-goal.js`: official `@opencode/schema/goal` RPC read adapter shared by
|
|
14
|
+
scheduled tasks, Assistant reconciliation and notification suppression. It
|
|
15
|
+
validates native state and distinguishes an absent plugin from transport/auth
|
|
16
|
+
failure. It owns no Goal persistence, auditing, objective files or continuation.
|
|
13
17
|
- Pairing transport discovery includes the serving host's `serverName` (OS
|
|
14
18
|
hostname), not the browser's machine name. The pairing form uses it as an
|
|
15
19
|
editable default and preserves edits made while discovery is pending. The
|
|
@@ -90,6 +94,11 @@ encoding, not removed V1 endpoints.
|
|
|
90
94
|
- `packages/web/server/lib/ui-auth/ui-passkeys.js`: UI passkey storage and WebAuthn registration/authentication helpers (outside OpenCode module).
|
|
91
95
|
|
|
92
96
|
## Public exports (auth.js)
|
|
97
|
+
Shared credential and location-release declarations require only the SDK resources
|
|
98
|
+
they consume (`credential`, `config.get`, and `debug.location.evict`), not the entire
|
|
99
|
+
generated client. VS Code and Web may resolve compatible client patch versions;
|
|
100
|
+
unrelated new SDK resources must not invalidate these host integration seams.
|
|
101
|
+
|
|
93
102
|
- `configureOpenCodeCredentials(resolveClient)`: host composition injects a call-time SDK client resolver; `null` detaches it. Web/Electron share server wiring; VS Code wires its manager in extension activation. Mobile clients use their host.
|
|
94
103
|
- `currentClient()`: trusted host-only client resolver used by config-sync to retain full V2 credential account records instead of the active-account quota projection.
|
|
95
104
|
- `openCodeCredentialSource({ buildOpenCodeUrl, getOpenCodeAuthHeaders })`: resolves the current endpoint/auth at each read rather than capturing a previous runtime.
|
|
@@ -1,10 +1,14 @@
|
|
|
1
1
|
import type { OpenCodeClient } from '@opencode/client';
|
|
2
2
|
|
|
3
|
+
type CredentialClient = Pick<OpenCodeClient, 'credential'> & {
|
|
4
|
+
config: Pick<OpenCodeClient['config'], 'get'>;
|
|
5
|
+
};
|
|
6
|
+
|
|
3
7
|
export type ProviderCredential =
|
|
4
8
|
| { type: 'api'; key: string }
|
|
5
9
|
| { type: 'oauth'; access: string; refresh: string; expires: number; accountId?: string; enterpriseUrl?: string };
|
|
6
|
-
export function configureOpenCodeCredentials(resolveClient: (() =>
|
|
7
|
-
export function currentClient():
|
|
10
|
+
export function configureOpenCodeCredentials(resolveClient: (() => CredentialClient) | null): void;
|
|
11
|
+
export function currentClient(): CredentialClient;
|
|
8
12
|
export function openCodeCredentialSource(deps: {
|
|
9
13
|
buildOpenCodeUrl: (path: string, prefix?: string) => string;
|
|
10
14
|
getOpenCodeAuthHeaders: () => Record<string, string>;
|
|
@@ -1228,7 +1228,6 @@ export const registerCommonRequestMiddleware = (app, dependencies) => {
|
|
|
1228
1228
|
req.path.startsWith('/api/question') ||
|
|
1229
1229
|
req.path.startsWith('/api/session-folders') ||
|
|
1230
1230
|
req.path.startsWith('/api/small-model') ||
|
|
1231
|
-
req.path.startsWith('/api/goals') ||
|
|
1232
1231
|
req.path.startsWith('/api/text') ||
|
|
1233
1232
|
req.path.startsWith('/api/voice') ||
|
|
1234
1233
|
req.path.startsWith('/api/tts')
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import { registerFsRoutes } from '../fs/routes.js';
|
|
2
2
|
import { registerQuotaRoutes } from '../quota/routes.js';
|
|
3
3
|
import { registerSmallModelRoutes } from '../small-model/routes.js';
|
|
4
|
-
import { registerSessionGoalRoutes } from '../session-goal/routes.js';
|
|
5
4
|
import { registerSessionMetadataRoutes } from '../session-metadata/routes.js';
|
|
6
5
|
import { registerGitHubRoutes } from '../github/routes.js';
|
|
7
6
|
import { registerGitRoutes } from '../git/routes.js';
|
|
@@ -153,7 +152,6 @@ export const createFeatureRoutesRuntime = (dependencies) => {
|
|
|
153
152
|
sessionMetadataStore = null,
|
|
154
153
|
sessionArchiveService = null,
|
|
155
154
|
onSessionMetadataWritten = null,
|
|
156
|
-
persistSessionGoal = null,
|
|
157
155
|
persistSessionMetadata = null,
|
|
158
156
|
onSystemSessionPersisted = null,
|
|
159
157
|
readSessionMetadata = null,
|
|
@@ -456,28 +454,6 @@ export const createFeatureRoutesRuntime = (dependencies) => {
|
|
|
456
454
|
throw new Error('Small model service is not configured');
|
|
457
455
|
});
|
|
458
456
|
registerSmallModelRoutes(app, { getSmallModelService });
|
|
459
|
-
registerSessionGoalRoutes(app, {
|
|
460
|
-
// Reuse the index-provided store seam — do not invent a second store.
|
|
461
|
-
persistSessionGoal: typeof persistSessionGoal === 'function'
|
|
462
|
-
? persistSessionGoal
|
|
463
|
-
: (sessionMetadataStore
|
|
464
|
-
? async (sessionId, _directory, goal) => {
|
|
465
|
-
const metadata = await sessionMetadataStore.setSessionMetadata(sessionId, {
|
|
466
|
-
yuri: { goal },
|
|
467
|
-
});
|
|
468
|
-
return metadata;
|
|
469
|
-
}
|
|
470
|
-
: null),
|
|
471
|
-
readSessionMetadata: typeof readSessionMetadata === 'function'
|
|
472
|
-
? readSessionMetadata
|
|
473
|
-
: (sessionMetadataStore
|
|
474
|
-
? (sessionId) => sessionMetadataStore.get(sessionId)
|
|
475
|
-
: null),
|
|
476
|
-
// Same arm path as PUT /api/yuri/sessions/:id/metadata.
|
|
477
|
-
onGoalPersisted: typeof onSessionMetadataWritten === 'function'
|
|
478
|
-
? onSessionMetadataWritten
|
|
479
|
-
: null,
|
|
480
|
-
});
|
|
481
457
|
if (sessionMetadataStore) {
|
|
482
458
|
registerSessionMetadataRoutes(app, {
|
|
483
459
|
sessionMetadataStore,
|
|
@@ -1,8 +1,12 @@
|
|
|
1
1
|
import type { OpenCodeClient } from '@opencode/client';
|
|
2
2
|
|
|
3
|
+
type LocationReleaseClient = {
|
|
4
|
+
debug: { location: Pick<OpenCodeClient['debug']['location'], 'evict'> };
|
|
5
|
+
};
|
|
6
|
+
|
|
3
7
|
export type LocationReleaseResult = { state: 'released' | 'timeout' | 'failed' | 'unavailable' };
|
|
4
8
|
export function releaseDeletedWorktreeLocation(input: {
|
|
5
|
-
getClient: () =>
|
|
9
|
+
getClient: () => LocationReleaseClient | null;
|
|
6
10
|
directory: string;
|
|
7
11
|
timeoutMs?: number;
|
|
8
12
|
}): Promise<LocationReleaseResult>;
|
|
@@ -32,7 +32,7 @@ export default async function scheduledTaskPlugin() {
|
|
|
32
32
|
description: 'Scheduled prompt and execution settings. providerID and modelID default to the current session model.',
|
|
33
33
|
additionalProperties: false,
|
|
34
34
|
properties: {
|
|
35
|
-
prompt: { type: 'string' }, providerID: { type: 'string' }, modelID: { type: 'string' }, agent: { type: 'string' }, variant: { type: 'string' }, goalEnabled: { type: 'boolean' },
|
|
35
|
+
prompt: { type: 'string' }, providerID: { type: 'string' }, modelID: { type: 'string' }, agent: { type: 'string' }, variant: { type: 'string' }, goalEnabled: { type: 'boolean' },
|
|
36
36
|
},
|
|
37
37
|
},
|
|
38
38
|
},
|
|
@@ -88,7 +88,7 @@ describe('scheduled_task plugin', () => {
|
|
|
88
88
|
expect(runSchema.required).toEqual(['operation', 'taskId']);
|
|
89
89
|
expect(plugin.tool.scheduled_task.args.request.properties.schedule.properties).toEqual(expect.objectContaining({ kind: expect.any(Object), time: expect.any(Object), times: expect.any(Object), weekdays: expect.any(Object), date: expect.any(Object), cron: expect.any(Object), timezone: expect.any(Object) }));
|
|
90
90
|
expect(plugin.tool.scheduled_task.args.request.properties.schedule.properties.at).toBeUndefined();
|
|
91
|
-
expect(plugin.tool.scheduled_task.args.request.properties.execution).toMatchObject({ additionalProperties: false, properties: expect.objectContaining({ prompt: expect.any(Object), providerID: expect.any(Object), modelID: expect.any(Object), agent: expect.any(Object), variant: expect.any(Object), goalEnabled: expect.any(Object)
|
|
91
|
+
expect(plugin.tool.scheduled_task.args.request.properties.execution).toMatchObject({ additionalProperties: false, properties: expect.objectContaining({ prompt: expect.any(Object), providerID: expect.any(Object), modelID: expect.any(Object), agent: expect.any(Object), variant: expect.any(Object), goalEnabled: expect.any(Object) }) });
|
|
92
92
|
const defaultConfig = {};
|
|
93
93
|
await plugin.config(defaultConfig);
|
|
94
94
|
expect(defaultConfig.permission).toEqual({ scheduled_task: 'ask' });
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { Goal } from '@opencode/schema/goal';
|
|
2
|
+
import { Schema } from 'effect';
|
|
3
|
+
|
|
4
|
+
const decodeGoal = Schema.decodeUnknownSync(Schema.NullOr(Goal.State));
|
|
5
|
+
|
|
6
|
+
export async function getNativeSessionGoal(client, sessionID, directory, signal) {
|
|
7
|
+
try {
|
|
8
|
+
const goal = await client.rpc(Goal.Definition).get({ sessionID }, { ...(directory ? { location: { directory } } : {}), ...(signal ? { signal } : {}) });
|
|
9
|
+
return decodeGoal(goal);
|
|
10
|
+
} catch (error) {
|
|
11
|
+
// A server without this plugin cannot own a goal. Transport/auth failures remain unknown.
|
|
12
|
+
if (error?.type === 'rpc.unavailable' || error?.type === 'rpc.method_not_found') return null;
|
|
13
|
+
throw error;
|
|
14
|
+
}
|
|
15
|
+
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { OpenCode } from '@opencode/client';
|
|
2
|
+
import { expect, test } from 'vitest';
|
|
3
|
+
import { getNativeSessionGoal } from './native-goal.js';
|
|
4
|
+
|
|
5
|
+
test('native goal adapter uses the official RPC envelope and scoped request, with no Host state', async () => {
|
|
6
|
+
const requests = [];
|
|
7
|
+
const goal = { id: 'g', objective: 'ship', status: 'complete', rounds: 2, maxRounds: 50, boot: 'boot', updatedAt: 1 };
|
|
8
|
+
const client = OpenCode.make({ baseUrl: 'http://native.test', fetch: async (input, init) => {
|
|
9
|
+
const request = new Request(input, init);
|
|
10
|
+
requests.push({ url: request.url, body: await request.json() });
|
|
11
|
+
return Response.json({ output: goal });
|
|
12
|
+
} });
|
|
13
|
+
expect(await getNativeSessionGoal(client, 'ses_a', '/repo', new AbortController().signal)).toEqual(goal);
|
|
14
|
+
expect(requests).toHaveLength(1);
|
|
15
|
+
expect(new URL(requests[0].url).pathname).toBe('/api/rpc/opencode.goal/get');
|
|
16
|
+
expect(requests[0].body).toMatchObject({ input: { sessionID: 'ses_a' } });
|
|
17
|
+
});
|
|
@@ -330,12 +330,6 @@ export const createSettingsHelpers = (dependencies) => {
|
|
|
330
330
|
if (typeof candidate.questionAutoDelegateEnabled === 'boolean') {
|
|
331
331
|
result.questionAutoDelegateEnabled = candidate.questionAutoDelegateEnabled;
|
|
332
332
|
}
|
|
333
|
-
if (typeof candidate.sessionGoalDefaultBudgetEnabled === 'boolean') {
|
|
334
|
-
result.sessionGoalDefaultBudgetEnabled = candidate.sessionGoalDefaultBudgetEnabled;
|
|
335
|
-
}
|
|
336
|
-
if (typeof candidate.sessionGoalDefaultBudget === 'number' && Number.isFinite(candidate.sessionGoalDefaultBudget) && candidate.sessionGoalDefaultBudget > 0) {
|
|
337
|
-
result.sessionGoalDefaultBudget = Math.floor(candidate.sessionGoalDefaultBudget);
|
|
338
|
-
}
|
|
339
333
|
if (typeof candidate.collapsibleThinkingBlocks === 'boolean') {
|
|
340
334
|
result.collapsibleThinkingBlocks = candidate.collapsibleThinkingBlocks;
|
|
341
335
|
}
|
|
@@ -11,7 +11,6 @@ export const createGracefulShutdownRuntime = (dependencies) => {
|
|
|
11
11
|
openCodeWatcherRuntime,
|
|
12
12
|
sessionRuntime,
|
|
13
13
|
sessionTitleRuntime,
|
|
14
|
-
sessionGoalRuntime,
|
|
15
14
|
questionAutoDelegateRuntime,
|
|
16
15
|
scheduledTasksRuntime,
|
|
17
16
|
getHealthCheckInterval,
|
|
@@ -45,7 +44,6 @@ export const createGracefulShutdownRuntime = (dependencies) => {
|
|
|
45
44
|
openCodeWatcherRuntime.stop();
|
|
46
45
|
sessionRuntime.dispose();
|
|
47
46
|
sessionTitleRuntime?.stop?.();
|
|
48
|
-
sessionGoalRuntime?.stop?.();
|
|
49
47
|
questionAutoDelegateRuntime?.dispose?.();
|
|
50
48
|
// Stop timers/queue only. Keep the process-lifetime run history store open so
|
|
51
49
|
// in-flight attach/finalize can still write, and so exitProcess:false restarts
|
|
@@ -282,15 +282,13 @@ const normalizeExecution = (value) => {
|
|
|
282
282
|
const variant = asNonEmptyString(value.variant);
|
|
283
283
|
const agent = asNonEmptyString(value.agent);
|
|
284
284
|
const goalEnabled = value.goalEnabled === true;
|
|
285
|
-
const goalTokenBudget = typeof value.goalTokenBudget === 'number'
|
|
286
|
-
&& Number.isFinite(value.goalTokenBudget)
|
|
287
|
-
&& value.goalTokenBudget > 0
|
|
288
|
-
? Math.floor(value.goalTokenBudget)
|
|
289
|
-
: undefined;
|
|
290
285
|
|
|
291
286
|
if (!prompt) {
|
|
292
287
|
throw new Error('execution.prompt is required');
|
|
293
288
|
}
|
|
289
|
+
if (goalEnabled && (prompt.length > 4000 || ['pause', 'resume', 'clear'].includes(prompt.toLowerCase()))) {
|
|
290
|
+
throw new Error('execution.prompt is invalid for a native goal (1–4000 characters, not pause/resume/clear)');
|
|
291
|
+
}
|
|
294
292
|
if (!providerID) {
|
|
295
293
|
throw new Error('execution.providerID is required');
|
|
296
294
|
}
|
|
@@ -305,7 +303,6 @@ const normalizeExecution = (value) => {
|
|
|
305
303
|
...(variant ? { variant } : {}),
|
|
306
304
|
...(agent ? { agent } : {}),
|
|
307
305
|
...(goalEnabled ? { goalEnabled: true } : {}),
|
|
308
|
-
...(goalEnabled && goalTokenBudget ? { goalTokenBudget } : {}),
|
|
309
306
|
};
|
|
310
307
|
};
|
|
311
308
|
|
|
@@ -329,17 +329,10 @@ Every actual run (timer or manual):
|
|
|
329
329
|
- metadata: `yuri.scheduledTask = { projectID, taskID, runID, name }`
|
|
330
330
|
- SDK/HTTP calls receive `{ signal }` as the second request-options argument
|
|
331
331
|
(`client.session.create(params, { signal })`, same for `prompt` /
|
|
332
|
-
`command` / `command.list
|
|
333
|
-
pass `signal` in `RequestInit`).
|
|
332
|
+
`command` / `command.list` and native goal RPC reads).
|
|
334
333
|
5. `attachSession(runID, sessionID)` immediately after create.
|
|
335
334
|
- If attach fails, the runtime fails the run without prompting.
|
|
336
|
-
6. When `goalEnabled
|
|
337
|
-
`persistSessionGoal` is not injected; otherwise write objective file,
|
|
338
|
-
persist an active goal into the Host session-metadata store, optionally
|
|
339
|
-
notify `onGoalPersisted` to arm the goal loop, then command or
|
|
340
|
-
`session.prompt`. Non-cancellable async gaps (small-model distill,
|
|
341
|
-
objective file write) check `signal.throwIfAborted()` before continuing so
|
|
342
|
-
a timed-out run never prompts.
|
|
335
|
+
6. When `goalEnabled`, validate the native objective (1–4000 characters, not a control word), then execute `session.command({ sessionID, name: 'goal', text: prompt })`. No objective file, Host goal metadata, small-model distillation or extra prompt is written. OpenCode owns kickoff, auditing and continuation.
|
|
343
336
|
**Admission is not completion:** `session.prompt` / command return when the
|
|
344
337
|
turn is accepted, not when the agent finishes.
|
|
345
338
|
7. Wait for the real session outcome (bounded by the same watchdog):
|
|
@@ -379,9 +372,9 @@ Every actual run (timer or manual):
|
|
|
379
372
|
deleted sessions. Transport failures never match.
|
|
380
373
|
- Assistant `error` (and terminal finish `error` / `length` /
|
|
381
374
|
`content-filter`) finalizes as `error`.
|
|
382
|
-
- Goal-enabled runs:
|
|
383
|
-
|
|
384
|
-
|
|
375
|
+
- Goal-enabled runs: read native `opencode.goal` state. Only `complete`
|
|
376
|
+
succeeds; `paused` fails with its native reason. Failed or absent reads
|
|
377
|
+
stay unknown, never first-turn success.
|
|
385
378
|
- `durationMs` / `finishedAt` are wall-clock from run start through this
|
|
386
379
|
settlement — not the prompt admission latency.
|
|
387
380
|
8. On watchdog timeout after a session exists: immediately throw the canonical
|
|
@@ -476,24 +469,9 @@ is already `success`, or if the snapshot is still error/busy/unknown
|
|
|
476
469
|
(`session.active` failure and goal-unsupported goal tasks stay unknown).
|
|
477
470
|
Observer failures are logged and must not throw out of the event bus.
|
|
478
471
|
|
|
479
|
-
## Goal
|
|
472
|
+
## Native Goal execution
|
|
480
473
|
|
|
481
|
-
|
|
482
|
-
`packages/web/server/lib/session-goal/capability.js` as `{ supported: true }`.
|
|
483
|
-
Goal records live in the Yuri session-metadata store (same seam as
|
|
484
|
-
manual UI / `session-goal` runtime). Scheduled runs inject
|
|
485
|
-
`persistSessionGoal`, `readSessionMetadata`, and optional `onGoalPersisted`
|
|
486
|
-
from `server/index.js`.
|
|
487
|
-
|
|
488
|
-
| Path | Behavior |
|
|
489
|
-
|---|---|
|
|
490
|
-
| `PUT` scheduled task / managed-tool create·update with `execution.goalEnabled` | Allowed when capability supported |
|
|
491
|
-
| Existing `goalEnabled` task due or manual run | Requires `persistSessionGoal`; without it fail **before** OpenCode ready / session create / objective write / prompt; with it write objective + active goal then prompt |
|
|
492
|
-
| Ordinary non-goal task | Unchanged |
|
|
493
|
-
| Post-run observer on a goal-enabled task | Prefer Host store goal terminal status; never invent success from assistant-tail idle alone when goal is active |
|
|
494
|
-
|
|
495
|
-
Do not treat objective-file hints or first-turn assistant idle as a registered
|
|
496
|
-
goal success without a store-backed goal record.
|
|
474
|
+
Goal runs use OpenCode's `goal` command and `client.rpc(Goal.Definition).get` via `opencode/native-goal.js`. Once live execution is inactive, native `complete` means success and `paused` means error with the native reason; active, absent or failed goal reads never become first-turn assistant success. Recovery and post-run observation use the same native authority. Old task Token-budget fields are no longer emitted or enforced; OpenCode owns its round limits. Existing `goalEnabled` tasks retain their setting and use the native command on their next run. Old Host goal metadata and objective files are not imported or executed.
|
|
497
475
|
|
|
498
476
|
Run start also emits `scheduled-task-ran` with `status: running` as soon as
|
|
499
477
|
task state is persisted, so the outer task list can show in-progress before
|
|
@@ -504,12 +482,11 @@ the session is attached.
|
|
|
504
482
|
- Timeout path: abort the per-run signal → cancel in-flight cancellable
|
|
505
483
|
SDK/HTTP → start best-effort OpenCode `session.interrupt` via the create-time
|
|
506
484
|
abort listener (independent of whether the current await is cancellable) →
|
|
507
|
-
|
|
508
|
-
`writeObjective`) to finish → history and task state finalize as `error`
|
|
485
|
+
**do not wait** for non-cancellable work to finish → history and task state finalize as `error`
|
|
509
486
|
with `schedule run timed out` within the watchdog bound. The detached
|
|
510
487
|
`runPromise` is settled with a catch so late rejections are not unhandled.
|
|
511
488
|
- When uncancellable helper work eventually finishes, post-await
|
|
512
|
-
`throwIfAborted` gates stop
|
|
489
|
+
`throwIfAborted` gates stop command / `session.prompt`.
|
|
513
490
|
- Non-timeout failures: no timeout abort; no forced `session.interrupt` from the
|
|
514
491
|
watchdog.
|
|
515
492
|
- Runtime `stop()` clears timers, project-sync retries, and the queue, and aborts
|
|
@@ -517,9 +494,7 @@ the session is attached.
|
|
|
517
494
|
- Remaining non-cancellable edges: work already fully admitted and completed
|
|
518
495
|
HTTP-wise before timeout cannot be rolled back by aborting the HTTP request
|
|
519
496
|
alone; `session.interrupt` is the upstream stop for admitted command/prompt
|
|
520
|
-
execution.
|
|
521
|
-
a signal; the watchdog does not await them, and abort gates block later
|
|
522
|
-
stages after they complete.
|
|
497
|
+
execution. The Host no longer performs Goal distillation or objective-file writes.
|
|
523
498
|
|
|
524
499
|
## Shutdown
|
|
525
500
|
|
|
@@ -1,8 +1,3 @@
|
|
|
1
|
-
import {
|
|
2
|
-
getSessionGoalCapability,
|
|
3
|
-
isSessionGoalSupported,
|
|
4
|
-
sessionGoalUnavailableMessage,
|
|
5
|
-
} from '../session-goal/capability.js';
|
|
6
1
|
import { MANAGED_SCHEDULED_TASK_TOOL_PATH } from './managed-tool-contract.js';
|
|
7
2
|
|
|
8
3
|
const MAX_ID_LENGTH = 512;
|
|
@@ -157,12 +152,11 @@ const validateTaskInputFields = (input) => {
|
|
|
157
152
|
}
|
|
158
153
|
if (input.execution !== undefined) {
|
|
159
154
|
const execution = asObject(input.execution, 'input.execution');
|
|
160
|
-
hasOnlyKeys(execution, new Set(['prompt', 'providerID', 'modelID', 'agent', 'variant', 'goalEnabled'
|
|
155
|
+
hasOnlyKeys(execution, new Set(['prompt', 'providerID', 'modelID', 'agent', 'variant', 'goalEnabled']), 'input.execution');
|
|
161
156
|
for (const key of ['prompt', 'providerID', 'modelID', 'agent', 'variant']) {
|
|
162
157
|
if (execution[key] !== undefined) asString(execution[key], `input.execution.${key}`, key === 'prompt' ? MAX_PROMPT_LENGTH : MAX_ID_LENGTH);
|
|
163
158
|
}
|
|
164
159
|
if (execution.goalEnabled !== undefined && typeof execution.goalEnabled !== 'boolean') throw new Error('input.execution.goalEnabled is invalid');
|
|
165
|
-
if (execution.goalTokenBudget !== undefined && (!Number.isFinite(execution.goalTokenBudget) || execution.goalTokenBudget <= 0)) throw new Error('input.execution.goalTokenBudget is invalid');
|
|
166
160
|
}
|
|
167
161
|
};
|
|
168
162
|
|
|
@@ -268,17 +262,6 @@ export const registerScheduledTaskToolRoute = (app, dependencies) => {
|
|
|
268
262
|
: new Set(['taskId', 'name', 'enabled', 'schedule', 'execution']), 'input');
|
|
269
263
|
validateTaskInputFields(input);
|
|
270
264
|
|
|
271
|
-
const refuseGoalExecution = (execution) => {
|
|
272
|
-
if (execution?.goalEnabled !== true || isSessionGoalSupported()) {
|
|
273
|
-
return null;
|
|
274
|
-
}
|
|
275
|
-
const capability = getSessionGoalCapability();
|
|
276
|
-
const error = new Error(sessionGoalUnavailableMessage(capability));
|
|
277
|
-
error.statusCode = 501;
|
|
278
|
-
error.capability = capability;
|
|
279
|
-
return error;
|
|
280
|
-
};
|
|
281
|
-
|
|
282
265
|
if (operation === 'update') {
|
|
283
266
|
const patch = {
|
|
284
267
|
...(input.name === undefined ? {} : { name: input.name }),
|
|
@@ -286,8 +269,6 @@ export const registerScheduledTaskToolRoute = (app, dependencies) => {
|
|
|
286
269
|
...(input.schedule === undefined ? {} : { schedule: input.schedule }),
|
|
287
270
|
...(input.execution === undefined ? {} : { execution: input.execution }),
|
|
288
271
|
};
|
|
289
|
-
const goalRefusal = refuseGoalExecution(patch.execution);
|
|
290
|
-
if (goalRefusal) throw goalRefusal;
|
|
291
272
|
const patched = await projectConfigRuntime.patchScheduledTask(project.id, taskID, patch);
|
|
292
273
|
if (!patched?.task) return res.status(404).json({ error: 'Schedule not found' });
|
|
293
274
|
const schedulerSynced = await syncAfterMutation(project.id, operation);
|
|
@@ -303,8 +284,6 @@ export const registerScheduledTaskToolRoute = (app, dependencies) => {
|
|
|
303
284
|
if (operation === 'create' && (!execution.providerID || !execution.modelID)) {
|
|
304
285
|
throw new Error('execution.providerID and execution.modelID are required from the user message or input');
|
|
305
286
|
}
|
|
306
|
-
const goalRefusal = refuseGoalExecution(execution);
|
|
307
|
-
if (goalRefusal) throw goalRefusal;
|
|
308
287
|
const taskInput = {
|
|
309
288
|
...(input.name === undefined ? {} : { name: input.name }),
|
|
310
289
|
...(input.enabled === undefined ? {} : { enabled: input.enabled }),
|
|
@@ -319,14 +298,6 @@ export const registerScheduledTaskToolRoute = (app, dependencies) => {
|
|
|
319
298
|
if (statusCode >= 500 && statusCode !== 501) {
|
|
320
299
|
logger.error?.('[ScheduledTaskTool] request failed', { operation: req.body?.operation, statusCode });
|
|
321
300
|
}
|
|
322
|
-
if (statusCode === 501) {
|
|
323
|
-
const capability = error?.capability || getSessionGoalCapability();
|
|
324
|
-
return res.status(501).json({
|
|
325
|
-
error: error?.message || sessionGoalUnavailableMessage(capability),
|
|
326
|
-
reason: capability.reason,
|
|
327
|
-
capability,
|
|
328
|
-
});
|
|
329
|
-
}
|
|
330
301
|
return res.status(statusCode).json({ error: statusCode >= 500 ? 'Failed to manage schedule' : (error?.message || 'Invalid schedule request') });
|
|
331
302
|
}
|
|
332
303
|
});
|