@yuriai/web 0.2.27-beta.6 → 0.2.27
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/README.md +8 -0
- package/dist/assets/{AgentAvatar-Bi1vvWPC.js → AgentAvatar-DNm_jMna.js} +1 -1
- package/dist/assets/AssistantContactStatus-BPRpgMFh.js +3 -0
- package/dist/assets/{AssistantUnreadBadge-DdJyySwn.js → AssistantUnreadBadge-BssH-RvV.js} +1 -1
- package/dist/assets/AssistantView-CxQv-9Ms.js +1 -0
- package/dist/assets/{DiagramView-CI4bTtxy.js → DiagramView-DPpG0fwx.js} +1 -1
- package/dist/assets/{FadeInOnReveal-BB4qEnAn.js → FadeInOnReveal-S6UbimjB.js} +1 -1
- package/dist/assets/{GuiPluginSurface-CguxFUbM.js → GuiPluginSurface-BOf0JA1T.js} +1 -1
- package/dist/assets/{GuiPluginWindow-DOJ7wuRH.js → GuiPluginWindow-OrYkfQ4m.js} +1 -1
- package/dist/assets/{Icon-t2xvbAyN.js → Icon-BE4mEwzV.js} +1 -1
- package/dist/assets/{ImageLoadingPlaceholder-D1L13TK0.js → ImageLoadingPlaceholder-CBFJC_KD.js} +1 -1
- package/dist/assets/{LoadingImage-5rY_edNm.js → LoadingImage-NLq7_P-i.js} +1 -1
- package/dist/assets/MarkdownRenderer-BaMotAOQ.js +2 -0
- package/dist/assets/{MarkdownRendererImpl-cE-0AYRg.js → MarkdownRendererImpl-Cv6UnGG7.js} +1 -1
- package/dist/assets/{MarkstreamRendererImpl-BZyqDl82.js → MarkstreamRendererImpl-Rb9O6wkW.js} +1 -1
- package/dist/assets/{MobileDetailNavigation-tbfsMfB-.js → MobileDetailNavigation-CK4KbkeS.js} +1 -1
- package/dist/assets/{MobileResizableSheet-BeRmT6_x.js → MobileResizableSheet-Deidw1br.js} +1 -1
- package/dist/assets/{MobileShareBridge-C3Equ3P_.js → MobileShareBridge-CO_OWEfq.js} +2 -2
- package/dist/assets/MobileTabPageHeader-DbC8L6A4.js +2 -0
- package/dist/assets/{MultiRunWindow-CAM2XPII.js → MultiRunWindow-DtVW9NTV.js} +1 -1
- package/dist/assets/{OnboardingScreen-4ftRerP5.js → OnboardingScreen-C8ld4wO7.js} +1 -1
- package/dist/assets/{OverlayScrollbar-CF0PCvQz.js → OverlayScrollbar-B3auC2WH.js} +1 -1
- package/dist/assets/{SettingsView-2tk4WH7R.js → SettingsView-Cm7woZWl.js} +15 -15
- package/dist/assets/{SettingsWindow-B9zbeJaW.js → SettingsWindow-CdL4PFxW.js} +1 -1
- package/dist/assets/{TerminalView-DfxvTHye.js → TerminalView-CwRB6Yyr.js} +1 -1
- package/dist/assets/{ToolOutputDialog-CrjDIhru.js → ToolOutputDialog-B4BfmoVH.js} +1 -1
- package/dist/assets/{YuriLogo-QvS1ZEHi.js → YuriLogo-BOx0s0Ue.js} +1 -1
- package/dist/assets/{appThemeRegistry-Bb_DtiV9.js → appThemeRegistry-B6woJIX5.js} +1 -1
- package/dist/assets/{assistant-attachment-cache-B9iHLlm2.js → assistant-attachment-cache-B_qRvy-k.js} +1 -1
- package/dist/assets/{button-DinGM3tu.js → button-BXxwtxsG.js} +1 -1
- package/dist/assets/{capgoAdapter-DufzjXRs.js → capgoAdapter-C5HFS-rx.js} +1 -1
- package/dist/assets/{collapsible-Bh1GLNYV.js → collapsible-BEm0787p.js} +1 -1
- package/dist/assets/context-menu-DUwvVUDY.js +1 -0
- package/dist/assets/{desktopRelayRestore-CoLLVJw8.js → desktopRelayRestore-D1UX7HW2.js} +1 -1
- package/dist/assets/device-BcRP6Tjd.js +2 -0
- package/dist/assets/{diagram-BmG-7Jb4.js → diagram-DyY8dxjZ.js} +1 -1
- package/dist/assets/{dialog-BXssfGXA.js → dialog-CLca6ojn.js} +1 -1
- package/dist/assets/dropdown-menu.styles-DGaALKP0.js +1 -0
- package/dist/assets/{es-HP_Ise0X.js → es-CrsHvgue.js} +2 -2
- package/dist/assets/feishu-Ct1ZxlzQ.svg +6 -0
- package/dist/assets/fileMentionAutocompleteState-BZJqfgae.js +2 -0
- package/dist/assets/{fileMentionTouchSelection-DSl0tj2r.js → fileMentionTouchSelection-C4dvP8GY.js} +2 -2
- package/dist/assets/{fileQueries-5a1jkme2.js → fileQueries-BeXkd3o6.js} +1 -1
- package/dist/assets/{fileReferenceActions-CGpBSFq4.js → fileReferenceActions-CrIAce3K.js} +1 -1
- package/dist/assets/{fr-D0kJXJ6U.js → fr-CEgiRlfa.js} +2 -2
- package/dist/assets/{gitApi-Wo0IZow9.js → gitApi-D2G9ny2O.js} +1 -1
- package/dist/assets/{gitApiHttp-De9liKnG.js → gitApiHttp-B7vYwgBh.js} +4 -4
- package/dist/assets/{gui-9enrif_1.js → gui-CJjEj3l4.js} +1 -1
- package/dist/assets/host-CnVx34Dh.js +1 -0
- package/dist/assets/{image-loading-Dq1g_wpm.js → image-loading-D5UhMj7Z.js} +1 -1
- package/dist/assets/{input-v8-rVbo-.js → input-D59Q2pm8.js} +1 -1
- package/dist/assets/insertionBoundaries-CedfTSM5.js +1 -0
- package/dist/assets/{ja-BjHKXazE.js → ja-CX-_p9jZ.js} +2 -2
- package/dist/assets/{ko-Llwnl876.js → ko-D5xlLYJM.js} +2 -2
- package/dist/assets/main-CxpUooVS.js +2 -0
- package/dist/assets/main-Dpm4KxWX.js +169 -0
- package/dist/assets/{markdownHeightCache-BVV2dktw.js → markdownHeightCache-D2VWb_4E.js} +1 -1
- package/dist/assets/{mcpQueries-BoBrB4a4.js → mcpQueries-DQ3KthDF.js} +1 -1
- package/dist/assets/miniChat-CTdj8Ug9.js +2 -0
- package/dist/assets/mobile-ChbA3Q8j.js +2 -0
- package/dist/assets/{mobileBackNavigation-DMSzAvb6.js → mobileBackNavigation-BJqt3oHk.js} +1 -1
- package/dist/assets/{multirun-BhWttsRQ.js → multirun-BILeETbd.js} +1 -1
- package/dist/assets/{native-DSvNnKAm.js → native-BYMhr-xH.js} +1 -1
- package/dist/assets/{native-config-DjdrW_9n.js → native-config-BIY0Cr-l.js} +1 -1
- package/dist/assets/{persistence-CfrHIiIS.js → persistence-CWuLIq1J.js} +2 -2
- package/dist/assets/{pl-BOd_idqn.js → pl-BjH81A_q.js} +2 -2
- package/dist/assets/projectMeta-B9_Uh8YH.js +1 -0
- package/dist/assets/{pt-BR-B8djxMsl.js → pt-BR-Dp5oK2x3.js} +2 -2
- package/dist/assets/{queryRuntime-Dkpnq3Z1.js → queryRuntime-CTcigFdj.js} +1 -1
- package/dist/assets/queue-abort-optimistic-CS5jTJq-.js +1 -0
- package/dist/assets/react-DRe85o5s.js +1 -0
- package/dist/assets/readiness-BNIgH81X.js +1 -0
- package/dist/assets/renderElectronMiniChatApp-asOqV7FB.js +2 -0
- package/dist/assets/renderMobileApp-DAfque7-.js +28 -0
- package/dist/assets/runtime-fetch-D0YWp3FJ.js +1 -0
- package/dist/assets/{runtime-file-download-CcNIVp7u.js → runtime-file-download-Cf1WxfeW.js} +1 -1
- package/dist/assets/{runtime-file-resource-6np6lzoV.js → runtime-file-resource-UJjHUF2C.js} +1 -1
- package/dist/assets/runtimeConfig-BX8JirIc.js +2 -0
- package/dist/assets/runtimeEndpointReset-CFQgUiUr.js +149 -0
- package/dist/assets/scheduledTaskNavigation-EomDNVu2.js +1 -0
- package/dist/assets/sessionLookup-BxAaxPOw.js +1 -0
- package/dist/assets/{sortable-tabs-strip-yKyqsqut.js → sortable-tabs-strip-DpbW5MqX.js} +1 -1
- package/dist/assets/speechSettingsQueries-CC0fusUo.js +4 -0
- package/dist/assets/src-BMKjN2ip.css +2 -0
- package/dist/assets/{store-CUBymvAC.js → store-CkIHVrmT.js} +4 -3
- package/dist/assets/{terminalApi-BblSkqch.js → terminalApi-rl9mZAlB.js} +1 -1
- package/dist/assets/{textarea-B39OCNPV.js → textarea-7eTptEtD.js} +1 -1
- package/dist/assets/{tooltip-d8TNN4lx.js → tooltip-BPwoSTzO.js} +1 -1
- package/dist/assets/types-CUtSV1V8.js +2 -0
- package/dist/assets/{uk-BNd7CjVO.js → uk-BEfkaLtM.js} +2 -2
- package/dist/assets/{useAppFontEffects-BVoVpJYO.js → useAppFontEffects-Ck2PdQRx.js} +52 -52
- package/dist/assets/{useAssistantUIStore-Bp6TxG5E.js → useAssistantUIStore-CfaQV3ID.js} +1 -1
- package/dist/assets/useDesktopWindowControlsLayout-DxxOUZj1.js +1 -0
- package/dist/assets/useEffectiveDirectory-CNCQfN_x.js +1 -0
- package/dist/assets/{useFontPreferences-BFyBjtQ6.js → useFontPreferences-DeqW9nRx.js} +1 -1
- package/dist/assets/useMobileNavigationStore-BmVr5a5c.js +17 -0
- package/dist/assets/useUIStore-C6CE42oh.js +1 -0
- package/dist/assets/{useWorkerHighlightedLines-CPxG8Fya.js → useWorkerHighlightedLines-CN_RGaSw.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-CgKz9Hcy.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-BkTAEOZG.js → zh-CN-DipfA56P.js} +2 -2
- package/dist/assets/{zh-TW-x8SfMzfc.js → zh-TW-B7pXMVjt.js} +2 -2
- package/dist/index.html +18 -18
- package/dist/mini-chat.html +18 -18
- package/dist/mobile.html +18 -18
- package/package.json +6 -1
- package/server/index.js +2 -145
- package/server/lib/assistants/DOCUMENTATION.md +69 -11
- 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 +114 -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 +329 -0
- package/server/lib/assistants/channels/PROTOCOLS.md +250 -0
- package/server/lib/assistants/channels/dingtalk-chat-adapter.js +645 -0
- package/server/lib/assistants/channels/dingtalk-chat-adapter.test.js +423 -0
- package/server/lib/assistants/channels/integration.test.js +44 -0
- package/server/lib/assistants/channels/routes.js +59 -0
- package/server/lib/assistants/channels/routes.test.js +139 -0
- package/server/lib/assistants/channels/runtime.js +958 -0
- package/server/lib/assistants/channels/runtime.test.js +897 -0
- package/server/lib/assistants/channels/sdk-adapters.js +383 -0
- package/server/lib/assistants/channels/sdk-adapters.test.js +384 -0
- package/server/lib/assistants/channels/store.js +249 -0
- package/server/lib/assistants/channels/store.test.js +296 -0
- package/server/lib/assistants/channels/transport.js +42 -0
- package/server/lib/assistants/channels/transport.test.js +23 -0
- package/server/lib/assistants/channels/wecom-chat-adapter.js +703 -0
- package/server/lib/assistants/channels/wecom-chat-adapter.test.js +130 -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 +79 -34
- package/server/lib/assistants/harness.test.js +52 -20
- package/server/lib/assistants/message-channel-origin.js +7 -0
- package/server/lib/assistants/resource-reference.integration.test.js +284 -0
- package/server/lib/assistants/routes.js +14 -4
- package/server/lib/assistants/service.js +116 -69
- package/server/lib/assistants/service.test.js +31 -17
- package/server/lib/assistants/weixin/DOCUMENTATION.md +121 -14
- package/server/lib/assistants/weixin/api.js +45 -1
- package/server/lib/assistants/weixin/api.test.js +28 -0
- package/server/lib/assistants/weixin/chat-adapter.js +113 -0
- package/server/lib/assistants/weixin/chat-adapter.test.js +62 -0
- package/server/lib/assistants/weixin/inbound.js +149 -0
- package/server/lib/assistants/weixin/inbound.test.js +141 -0
- package/server/lib/assistants/weixin/media.js +79 -0
- package/server/lib/assistants/weixin/media.test.js +66 -0
- package/server/lib/assistants/weixin/runtime.js +105 -74
- package/server/lib/assistants/weixin/runtime.test.js +192 -4
- package/server/lib/assistants/weixin/store.js +16 -8
- package/server/lib/assistants/weixin/store.test.js +93 -0
- package/server/lib/assistants/weixin/toon.js +49 -0
- package/server/lib/assistants/weixin/toon.test.js +25 -0
- package/server/lib/assistants/yuri-project.http.test.js +9 -3
- package/server/lib/github/DOCUMENTATION.md +9 -8
- package/server/lib/llm/bridge-plugin.bundle.js +188 -188
- 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 +10 -1
- 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-CWq-PDz6.js +0 -3
- package/dist/assets/AssistantView-Br1iETTs.js +0 -1
- package/dist/assets/MarkdownRenderer-BlGxjOei.js +0 -2
- package/dist/assets/MobileTabPageHeader-DQRqAAEf.js +0 -2
- package/dist/assets/context-menu-DpbkRkk1.js +0 -1
- package/dist/assets/device-BjRYYXNT.js +0 -2
- package/dist/assets/host-FR_grJxM.js +0 -1
- package/dist/assets/insertionBoundaries-CZz7TWJv.js +0 -1
- package/dist/assets/main-Bp9HHqTr.js +0 -2
- package/dist/assets/main-DOwAfmxJ.js +0 -169
- package/dist/assets/miniChat-BJDgCrfF.js +0 -2
- package/dist/assets/mobile-GM9931J_.js +0 -2
- package/dist/assets/projectMeta-31PobC-M.js +0 -1
- package/dist/assets/react-B9v0P7kT.js +0 -1
- package/dist/assets/readiness-CYNnsekT.js +0 -1
- package/dist/assets/renderElectronMiniChatApp-N2r999Bf.js +0 -2
- package/dist/assets/renderMobileApp-CU1ec6Ak.js +0 -28
- package/dist/assets/runtime-fetch-D4ja813o.js +0 -1
- package/dist/assets/runtimeConfig-Db7yfo6L.js +0 -2
- package/dist/assets/runtimeEndpointReset-DO5WVetV.js +0 -149
- package/dist/assets/scheduledTaskNavigation-Bsrhv3Ow.js +0 -1
- package/dist/assets/sessionLookup-DRVy7LM1.js +0 -1
- package/dist/assets/speechSettingsQueries-DU25rmGc.js +0 -4
- package/dist/assets/src-Bckdo2XS.css +0 -2
- package/dist/assets/types-BqFQhQTt.js +0 -2
- package/dist/assets/useDesktopWindowControlsLayout-CYx1LNO5.js +0 -1
- package/dist/assets/useEffectiveDirectory-D8FFE5Yn.js +0 -1
- package/dist/assets/useMobileNavigationStore-BHMFeMjo.js +0 -23
- package/dist/assets/useUIStore-BbYD420L.js +0 -1
- package/dist/assets/vendor-opencode-client-UL_TecvQ.js +0 -12
- package/dist/assets/vendor-solid-js-0T254UHG.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
|
@@ -3,11 +3,13 @@ import fs from 'node:fs';
|
|
|
3
3
|
import { createRequire } from 'node:module';
|
|
4
4
|
import path from 'node:path';
|
|
5
5
|
import { makeOpenCodeV2Client } from '../opencode/v2-client.js';
|
|
6
|
+
import { getNativeSessionGoal } from '../opencode/native-goal.js';
|
|
6
7
|
import { validAssistantDeliveryParts } from '../assistant-delivery-parts.js';
|
|
7
8
|
import { createContactMemoryReader } from './memory.js';
|
|
8
9
|
import { getContactGreeting } from './contact-greeting.js';
|
|
10
|
+
import { loadChannelImage } from './channel-image.js';
|
|
9
11
|
import { getWorktrees as defaultListWorktrees } from '../git/service.js';
|
|
10
|
-
import { contactCardIdentity, parseContactCard, parseContactPart } from './cards.js';
|
|
12
|
+
import { contactCardIdentity, createAssistantCardPart, createScheduleCardPart, createSessionCardPart, parseContactCard, parseContactPart } from './cards.js';
|
|
11
13
|
import { ensureContactSummary } from './summary.js';
|
|
12
14
|
import {
|
|
13
15
|
CONTACT_PAGE_DEFAULT_LIMIT,
|
|
@@ -47,6 +49,7 @@ import {
|
|
|
47
49
|
canonicalDescriptorFromRow,
|
|
48
50
|
ensureContactAttachmentSchema,
|
|
49
51
|
getContactAttachmentRow,
|
|
52
|
+
getContactAttachmentByUploadID,
|
|
50
53
|
ingestDataUrlFilePart,
|
|
51
54
|
isSafeInlineImageMime,
|
|
52
55
|
materializeContactHistory,
|
|
@@ -152,8 +155,8 @@ const isMissingError = (error) => {
|
|
|
152
155
|
};
|
|
153
156
|
const ASSISTANT_SUCCESS_FINISH = new Set(['stop']);
|
|
154
157
|
const ASSISTANT_ERROR_FINISH = new Set(['error', 'length', 'content-filter']);
|
|
155
|
-
const GOAL_ACTIVE_STATUSES = new Set(['active'
|
|
156
|
-
const GOAL_ERROR_STATUSES = new Set(['
|
|
158
|
+
const GOAL_ACTIVE_STATUSES = new Set(['active']);
|
|
159
|
+
const GOAL_ERROR_STATUSES = new Set(['paused']);
|
|
157
160
|
const isTransientMessagesFailure = (result, error) => {
|
|
158
161
|
if (error) {
|
|
159
162
|
if (error instanceof AssistantError) return false;
|
|
@@ -626,7 +629,6 @@ export const createAssistantsService = ({ dbPath, dataDir, buildOpenCodeUrl, get
|
|
|
626
629
|
return null;
|
|
627
630
|
};
|
|
628
631
|
// Stash assign delivery message IDs until the session card watch is written.
|
|
629
|
-
const pendingAssignMessageIDs = new Map();
|
|
630
632
|
// Assigned-session complete/error/cancelled resumes the contact LLM (no canned settle bubble).
|
|
631
633
|
// Assigned after inContactTurnLane exists; reportAssignedSession only schedules via this ref.
|
|
632
634
|
const assignedSessionResumeRef = { schedule: null };
|
|
@@ -795,12 +797,6 @@ export const createAssistantsService = ({ dbPath, dataDir, buildOpenCodeUrl, get
|
|
|
795
797
|
void assignedCompletion.observe({ kind: 'complete', sessionId: sessionID }, { sessionID, options });
|
|
796
798
|
return true;
|
|
797
799
|
};
|
|
798
|
-
const goalOfSession = (session) => {
|
|
799
|
-
const goal = session?.metadata?.yuri?.goal;
|
|
800
|
-
if (!goal || typeof goal !== 'object') return null;
|
|
801
|
-
const status = typeof goal.status === 'string' ? goal.status.trim() : '';
|
|
802
|
-
return status ? { status } : null;
|
|
803
|
-
};
|
|
804
800
|
/** Messages that belong to this delivery watermark (assign prompt messageID). */
|
|
805
801
|
const messagesOwnedByDelivery = (messages, deliveryMessageID) => {
|
|
806
802
|
if (!Array.isArray(messages)) return [];
|
|
@@ -865,7 +861,7 @@ export const createAssistantsService = ({ dbPath, dataDir, buildOpenCodeUrl, get
|
|
|
865
861
|
if (!finish && !assistantInfo.time?.completed) return null;
|
|
866
862
|
return null;
|
|
867
863
|
};
|
|
868
|
-
const inferAssignedSessionSettleStatus = (getResult, messagesResult, { deliveryMessageID = null, activeBusy = null } = {}) => {
|
|
864
|
+
const inferAssignedSessionSettleStatus = (getResult, messagesResult, { deliveryMessageID = null, activeBusy = null, goal = null } = {}) => {
|
|
869
865
|
// Another Host may share this watch store but use a different OpenCode database.
|
|
870
866
|
// Absence there is not an authoritative terminal result for the owning worker.
|
|
871
867
|
if (isMissing(getResult)) return null;
|
|
@@ -874,8 +870,7 @@ export const createAssistantsService = ({ dbPath, dataDir, buildOpenCodeUrl, get
|
|
|
874
870
|
if (activeBusy === true) return null;
|
|
875
871
|
const session = sessionRecord(getResult);
|
|
876
872
|
if (session?.error) return isUserAbort(session.error) ? 'cancelled' : 'error';
|
|
877
|
-
|
|
878
|
-
// Goal settle is owned by the session-goal reporter — never invent success.
|
|
873
|
+
// Goal completion comes only from OpenCode's native plugin state.
|
|
879
874
|
if (goal && GOAL_ACTIVE_STATUSES.has(goal.status)) return null;
|
|
880
875
|
if (goal && GOAL_ERROR_STATUSES.has(goal.status)) return 'error';
|
|
881
876
|
if (goal && goal.status === 'complete') return 'complete';
|
|
@@ -952,9 +947,11 @@ export const createAssistantsService = ({ dbPath, dataDir, buildOpenCodeUrl, get
|
|
|
952
947
|
else messagesResult = null;
|
|
953
948
|
}
|
|
954
949
|
if (closed) return;
|
|
950
|
+
const goal = await getNativeSessionGoal(client(), watch.sessionID, directory);
|
|
955
951
|
const status = inferAssignedSessionSettleStatus(getResult, messagesResult, {
|
|
956
952
|
deliveryMessageID: watch.messageID,
|
|
957
953
|
activeBusy,
|
|
954
|
+
goal,
|
|
958
955
|
});
|
|
959
956
|
if (status) reportAssignedSession(watch.sessionID, status);
|
|
960
957
|
} catch {
|
|
@@ -972,6 +969,11 @@ export const createAssistantsService = ({ dbPath, dataDir, buildOpenCodeUrl, get
|
|
|
972
969
|
payload,
|
|
973
970
|
);
|
|
974
971
|
const body = eventBody(payload);
|
|
972
|
+
if (payload.type === 'rpc.opencode.goal.changed' && nonEmptyString(body?.sessionID)) {
|
|
973
|
+
if (body.goal?.status === 'complete') return reportAssignedSession(body.sessionID, 'complete');
|
|
974
|
+
if (body.goal?.status === 'paused') return reportAssignedSession(body.sessionID, 'error');
|
|
975
|
+
return false;
|
|
976
|
+
}
|
|
975
977
|
// Message lifecycle still requires a body; execution/status may carry sessionID on body only.
|
|
976
978
|
if (payload.type === 'message.updated') {
|
|
977
979
|
if (!plainObject(body)) return false;
|
|
@@ -1705,14 +1707,18 @@ export const createAssistantsService = ({ dbPath, dataDir, buildOpenCodeUrl, get
|
|
|
1705
1707
|
|
|
1706
1708
|
const persistPublishedContactCard = (assistantID, { userMessageID, turnID, index, card: cardInput }) => {
|
|
1707
1709
|
const card = parseContactCard({ type: 'card', cardType: cardInput?.cardType || 'session', ...cardInput });
|
|
1708
|
-
if (!card)
|
|
1710
|
+
if (!card) throw new AssignError(ASSIGN_CODES.VALIDATION, 'Invalid resource reference.');
|
|
1709
1711
|
const cardID = contactCardMessageID(userMessageID, index);
|
|
1710
|
-
if (getContactMessage(db, cardID)) return false;
|
|
1711
1712
|
db.exec('BEGIN IMMEDIATE');
|
|
1712
1713
|
try {
|
|
1713
|
-
|
|
1714
|
+
editable(assistantID);
|
|
1715
|
+
if (!getContactMessage(db, userMessageID)) throw new AssignError(ASSIGN_CODES.VALIDATION, 'This turn no longer belongs to the transcript.');
|
|
1716
|
+
const existing = getContactMessage(db, cardID);
|
|
1717
|
+
if (existing) {
|
|
1718
|
+
const published = existing.parts.find((part) => part.type === 'card');
|
|
1719
|
+
if (!published || contactCardIdentity(published) !== contactCardIdentity(card)) throw new AssignError(ASSIGN_CODES.VALIDATION, 'Reference slot already belongs to another resource.');
|
|
1714
1720
|
db.exec('COMMIT');
|
|
1715
|
-
return
|
|
1721
|
+
return published;
|
|
1716
1722
|
}
|
|
1717
1723
|
insertContactMessage(db, {
|
|
1718
1724
|
messageID: cardID,
|
|
@@ -1725,23 +1731,9 @@ export const createAssistantsService = ({ dbPath, dataDir, buildOpenCodeUrl, get
|
|
|
1725
1731
|
status: 'complete',
|
|
1726
1732
|
parts: [card],
|
|
1727
1733
|
});
|
|
1728
|
-
if (card.cardType === 'session' && card.sessionID) {
|
|
1729
|
-
const deliveryMessageID = pendingAssignMessageIDs.get(card.sessionID)
|
|
1730
|
-
|| (nonEmptyString(card.messageID) ? card.messageID : null);
|
|
1731
|
-
if (pendingAssignMessageIDs.has(card.sessionID)) pendingAssignMessageIDs.delete(card.sessionID);
|
|
1732
|
-
upsertContactWatch(db, {
|
|
1733
|
-
assistantID,
|
|
1734
|
-
sessionID: card.sessionID,
|
|
1735
|
-
directory: card.directory,
|
|
1736
|
-
status: card.status === 'error' || card.status === 'question' || card.status === 'complete' ? card.status : 'busy',
|
|
1737
|
-
updatedAt: now(),
|
|
1738
|
-
messageID: deliveryMessageID || null,
|
|
1739
|
-
});
|
|
1740
|
-
if (deliveryMessageID) void assignedCompletion.observe({ kind: 'running', sessionId: card.sessionID });
|
|
1741
|
-
}
|
|
1742
1734
|
bump();
|
|
1743
1735
|
db.exec('COMMIT');
|
|
1744
|
-
return
|
|
1736
|
+
return card;
|
|
1745
1737
|
} catch (error) {
|
|
1746
1738
|
db.exec('ROLLBACK');
|
|
1747
1739
|
throw error;
|
|
@@ -1775,17 +1767,12 @@ export const createAssistantsService = ({ dbPath, dataDir, buildOpenCodeUrl, get
|
|
|
1775
1767
|
};
|
|
1776
1768
|
|
|
1777
1769
|
const rememberPublishedContactCard = (assistantID, { userMessageID, turnID, assignedCards, card }) => {
|
|
1778
|
-
assignedCards.
|
|
1779
|
-
|
|
1780
|
-
|
|
1781
|
-
|
|
1782
|
-
|
|
1783
|
-
|
|
1784
|
-
card,
|
|
1785
|
-
});
|
|
1786
|
-
} catch {
|
|
1787
|
-
// Publishing a card must not abort the live turn.
|
|
1788
|
-
}
|
|
1770
|
+
const index = assignedCards.findIndex((item) => contactCardIdentity(item) === contactCardIdentity(card));
|
|
1771
|
+
const published = persistPublishedContactCard(assistantID, {
|
|
1772
|
+
userMessageID, turnID, index: index < 0 ? assignedCards.length : index, card,
|
|
1773
|
+
});
|
|
1774
|
+
if (index < 0) assignedCards.push(published);
|
|
1775
|
+
return published;
|
|
1789
1776
|
};
|
|
1790
1777
|
|
|
1791
1778
|
/** Persist remaining assistant bubbles/cards for an already-admitted user turn (no user row). */
|
|
@@ -1833,20 +1820,6 @@ export const createAssistantsService = ({ dbPath, dataDir, buildOpenCodeUrl, get
|
|
|
1833
1820
|
parts: [card],
|
|
1834
1821
|
});
|
|
1835
1822
|
ordinal += 1;
|
|
1836
|
-
if (card.cardType === 'session' && card.sessionID) {
|
|
1837
|
-
const deliveryMessageID = pendingAssignMessageIDs.get(card.sessionID)
|
|
1838
|
-
|| (nonEmptyString(card.messageID) ? card.messageID : null);
|
|
1839
|
-
if (pendingAssignMessageIDs.has(card.sessionID)) pendingAssignMessageIDs.delete(card.sessionID);
|
|
1840
|
-
upsertContactWatch(db, {
|
|
1841
|
-
assistantID,
|
|
1842
|
-
sessionID: card.sessionID,
|
|
1843
|
-
directory: card.directory,
|
|
1844
|
-
status: card.status === 'error' || card.status === 'question' || card.status === 'complete' ? card.status : 'busy',
|
|
1845
|
-
updatedAt: now(),
|
|
1846
|
-
messageID: deliveryMessageID || null,
|
|
1847
|
-
});
|
|
1848
|
-
if (deliveryMessageID) void assignedCompletion.observe({ kind: 'running', sessionId: card.sessionID });
|
|
1849
|
-
}
|
|
1850
1823
|
});
|
|
1851
1824
|
bump();
|
|
1852
1825
|
db.exec('COMMIT');
|
|
@@ -2459,14 +2432,26 @@ export const createAssistantsService = ({ dbPath, dataDir, buildOpenCodeUrl, get
|
|
|
2459
2432
|
lookupMessage: (lookup) => lookupAssignMessage({ ...lookup, signal }),
|
|
2460
2433
|
messageID: params?.messageID || `msg_assign_${id()}`,
|
|
2461
2434
|
});
|
|
2462
|
-
//
|
|
2435
|
+
// Watch admission belongs to assignment, independently of whether a card is sent.
|
|
2463
2436
|
if (nonEmptyString(assigned?.sessionID) && nonEmptyString(assigned?.messageID)) {
|
|
2464
|
-
|
|
2437
|
+
try {
|
|
2438
|
+
db.transaction(() => {
|
|
2439
|
+
upsertContactWatch(db, {
|
|
2440
|
+
assistantID: row.assistant_id, sessionID: assigned.sessionID,
|
|
2441
|
+
directory: assigned.directory, status: assigned.status || 'busy',
|
|
2442
|
+
updatedAt: now(), messageID: assigned.messageID,
|
|
2443
|
+
});
|
|
2444
|
+
bump();
|
|
2445
|
+
}).immediate();
|
|
2446
|
+
} catch {
|
|
2447
|
+
return { ...assigned, watchError: 'watch_registration_failed' };
|
|
2448
|
+
}
|
|
2449
|
+
void assignedCompletion.observe({ kind: 'running', sessionId: assigned.sessionID });
|
|
2465
2450
|
}
|
|
2466
2451
|
return assigned;
|
|
2467
2452
|
};
|
|
2468
2453
|
/** Watch an existing session only — no prompt. Baseline status avoids false settle resume. */
|
|
2469
|
-
const watchSessionWork = async (
|
|
2454
|
+
const watchSessionWork = async (row, params = {}) => {
|
|
2470
2455
|
const sessionID = typeof params.sessionID === 'string' ? params.sessionID.trim() : '';
|
|
2471
2456
|
if (!sessionID) {
|
|
2472
2457
|
throw new AssignError(ASSIGN_CODES.VALIDATION, 'watch_session requires sessionID.');
|
|
@@ -2488,6 +2473,14 @@ export const createAssistantsService = ({ dbPath, dataDir, buildOpenCodeUrl, get
|
|
|
2488
2473
|
status = 'busy';
|
|
2489
2474
|
}
|
|
2490
2475
|
}
|
|
2476
|
+
params.signal?.throwIfAborted();
|
|
2477
|
+
db.transaction(() => {
|
|
2478
|
+
upsertContactWatch(db, {
|
|
2479
|
+
assistantID: row.assistant_id, sessionID: resolved.sessionID,
|
|
2480
|
+
directory: resolved.directory, status, updatedAt: now(), messageID: null,
|
|
2481
|
+
});
|
|
2482
|
+
bump();
|
|
2483
|
+
}).immediate();
|
|
2491
2484
|
return {
|
|
2492
2485
|
sessionID: resolved.sessionID,
|
|
2493
2486
|
directory: resolved.directory,
|
|
@@ -2779,6 +2772,33 @@ export const createAssistantsService = ({ dbPath, dataDir, buildOpenCodeUrl, get
|
|
|
2779
2772
|
}
|
|
2780
2773
|
return { tasks, ...(failed.length > 0 ? { partial: true, failed } : {}) };
|
|
2781
2774
|
};
|
|
2775
|
+
const resolveContactResource = async (input, signal) => {
|
|
2776
|
+
signal?.throwIfAborted();
|
|
2777
|
+
if (input.cardType === 'session') {
|
|
2778
|
+
const resolved = await resolveReferencedSession({ sessionID: input.sessionID, signal, includeMessages: false });
|
|
2779
|
+
return createSessionCardPart(resolved);
|
|
2780
|
+
}
|
|
2781
|
+
if (input.cardType === 'assistant') {
|
|
2782
|
+
const target = output(editable(input.assistantID));
|
|
2783
|
+
return createAssistantCardPart({ ...target, assistantID: target.id });
|
|
2784
|
+
}
|
|
2785
|
+
const projects = await listProjects();
|
|
2786
|
+
if (!Array.isArray(projects)) throw new AssignError(ASSIGN_CODES.UPSTREAM, 'Project lookup failed.');
|
|
2787
|
+
if (!normalizeRegisteredProjects(projects).some((project) => project.id === input.projectID)) throw new AssignError(ASSIGN_CODES.PROJECT_REQUIRED, 'The task project is not registered.');
|
|
2788
|
+
if (typeof listScheduledTasks !== 'function') throw new AssignError(ASSIGN_CODES.UPSTREAM, 'Task lookup is unavailable.');
|
|
2789
|
+
const tasks = await listScheduledTasks(input.projectID);
|
|
2790
|
+
signal?.throwIfAborted();
|
|
2791
|
+
if (!Array.isArray(tasks)) throw new AssignError(ASSIGN_CODES.UPSTREAM, 'Task lookup failed.');
|
|
2792
|
+
const task = tasks.find((task) => task?.id === input.taskID);
|
|
2793
|
+
if (!task) throw new AssignError(ASSIGN_CODES.NOT_FOUND, 'The scheduled task no longer exists.');
|
|
2794
|
+
return createScheduleCardPart({
|
|
2795
|
+
taskID: task.id, projectID: input.projectID, name: task.name,
|
|
2796
|
+
kind: task.schedule?.kind, time: task.schedule?.time || task.schedule?.times?.[0],
|
|
2797
|
+
timezone: task.schedule?.timezone, prompt: task.execution?.prompt,
|
|
2798
|
+
cron: task.schedule?.cron ?? null, date: task.schedule?.date ?? null,
|
|
2799
|
+
times: task.schedule?.times ?? null, weekdays: task.schedule?.weekdays ?? null,
|
|
2800
|
+
});
|
|
2801
|
+
};
|
|
2782
2802
|
const updateScheduledTaskWork = async (row, params, signal) => {
|
|
2783
2803
|
signal?.throwIfAborted();
|
|
2784
2804
|
if (typeof patchScheduledTask !== 'function') throw new AssignError(ASSIGN_CODES.UPSTREAM, 'Updating a scheduled task is unavailable.');
|
|
@@ -3224,9 +3244,12 @@ export const createAssistantsService = ({ dbPath, dataDir, buildOpenCodeUrl, get
|
|
|
3224
3244
|
return output(editable(targetID));
|
|
3225
3245
|
},
|
|
3226
3246
|
currentAssistant: assistantSnapshot,
|
|
3247
|
+
resolveResource: resolveContactResource,
|
|
3227
3248
|
onCard: (card) => {
|
|
3228
|
-
|
|
3229
|
-
|
|
3249
|
+
controller.signal.throwIfAborted();
|
|
3250
|
+
if (contactResetThisTurn) throw new AssignError(ASSIGN_CODES.VALIDATION, 'This turn reset its context.');
|
|
3251
|
+
editable(assistantID);
|
|
3252
|
+
return rememberPublishedContactCard(assistantID, {
|
|
3230
3253
|
userMessageID: messageID, turnID, assignedCards, card,
|
|
3231
3254
|
});
|
|
3232
3255
|
},
|
|
@@ -3568,9 +3591,13 @@ export const createAssistantsService = ({ dbPath, dataDir, buildOpenCodeUrl, get
|
|
|
3568
3591
|
},
|
|
3569
3592
|
updateAssistantSettings: (patch) => updateContactSettings(row.assistant_id, patch),
|
|
3570
3593
|
currentAssistant: assistantSnapshot,
|
|
3594
|
+
resolveResource: resolveContactResource,
|
|
3571
3595
|
onCard: (card) => {
|
|
3572
|
-
|
|
3573
|
-
|
|
3596
|
+
controller.signal.throwIfAborted();
|
|
3597
|
+
if (contactResetThisTurn) throw new AssignError(ASSIGN_CODES.VALIDATION, 'This turn reset its context.');
|
|
3598
|
+
editable(row.assistant_id);
|
|
3599
|
+
if (!getContactMessage(db, messageID)) throw new AssignError(ASSIGN_CODES.VALIDATION, 'This turn no longer belongs to the transcript.');
|
|
3600
|
+
return rememberPublishedContactCard(row.assistant_id, {
|
|
3574
3601
|
userMessageID: messageID, turnID, assignedCards, card,
|
|
3575
3602
|
});
|
|
3576
3603
|
},
|
|
@@ -3862,9 +3889,7 @@ export const createAssistantsService = ({ dbPath, dataDir, buildOpenCodeUrl, get
|
|
|
3862
3889
|
parts: [card],
|
|
3863
3890
|
});
|
|
3864
3891
|
if (card.cardType === 'session' && card.sessionID) {
|
|
3865
|
-
const deliveryMessageID =
|
|
3866
|
-
|| (nonEmptyString(card.messageID) ? card.messageID : null);
|
|
3867
|
-
if (pendingAssignMessageIDs.has(card.sessionID)) pendingAssignMessageIDs.delete(card.sessionID);
|
|
3892
|
+
const deliveryMessageID = nonEmptyString(card.messageID) ? card.messageID : null;
|
|
3868
3893
|
upsertContactWatch(db, {
|
|
3869
3894
|
assistantID: row.assistant_id,
|
|
3870
3895
|
sessionID: card.sessionID,
|
|
@@ -4108,11 +4133,33 @@ export const createAssistantsService = ({ dbPath, dataDir, buildOpenCodeUrl, get
|
|
|
4108
4133
|
active(assistantID);
|
|
4109
4134
|
return readContactChannelPage(db, assistantID, options);
|
|
4110
4135
|
};
|
|
4111
|
-
|
|
4136
|
+
const prepareChannelImage = async (assistantID, source, { generation, uploadID, signal }) => {
|
|
4137
|
+
const row = active(assistantID);
|
|
4138
|
+
const assertGeneration = () => {
|
|
4139
|
+
signal?.throwIfAborted();
|
|
4140
|
+
if (channelPage(assistantID, { tipOnly: true }).generation !== generation) fail('cancelled');
|
|
4141
|
+
};
|
|
4142
|
+
assertGeneration();
|
|
4143
|
+
const existing = getContactAttachmentByUploadID(db, assistantID, uploadID);
|
|
4144
|
+
if (existing && existing.generation === generation) return canonicalDescriptorFromRow(existing);
|
|
4145
|
+
const { buffer, mime, filename } = await loadChannelImage(source, {
|
|
4146
|
+
cwd: resolveAssistantCwd({ workspacePath: row.workspace_path, effectiveWorkspacePath: effectiveWorkspace(row) }),
|
|
4147
|
+
allowedRoots: getAllowedRoots(), signal,
|
|
4148
|
+
readAttachment: (attachmentID) => getAssistantContactAttachment(assistantID, attachmentID),
|
|
4149
|
+
});
|
|
4150
|
+
assertGeneration();
|
|
4151
|
+
const image = await putAssistantContactAttachment(assistantID, uploadID, {
|
|
4152
|
+
stream: { body: buffer }, signal,
|
|
4153
|
+
headers: { 'content-type': mime, 'x-attachment-filename': filename,
|
|
4154
|
+
'x-content-size': String(buffer.length), 'x-content-sha256': crypto.createHash('sha256').update(buffer).digest('hex') },
|
|
4155
|
+
});
|
|
4156
|
+
assertGeneration();
|
|
4157
|
+
return image;
|
|
4158
|
+
};
|
|
4159
|
+
return { capability: async () => ({ supported: true, enabled: enabled(), revision: revision(), serverInstanceID: await getServerId(), sharingAvailable: false, archiveMetadataAvailable: typeof archiveSessionHost === 'function', sessionMetadataAvailable: false }), snapshot, channelPage, prepareChannelImage, ensureDefaultAssistant, createAssistant, updateAssistant, setEnabled: (input) => { if (!plainObject(input) || typeof input.enabled !== 'boolean' || input.expectedRevision !== revision()) fail('revision_conflict'); return { enabled: true, revision: revision() }; }, removeAssistant, ensure, createNew, compact, send, whenContactTurnSettled, abort, captureQueueDeliveryTarget, sendWithCapturedConfig, share, shareOperation, historicalMessages, contactMessages, clearContactMemory, resetContact, markContactRead, appendContactCard, deliverPeerMessage, listAssistantScheduledTasks, reportScheduledTaskResult, putAssistantContactAttachment, getAssistantContactAttachment, migrateContactAttachments, processEvent, reportAssignedSessionSettle: reportAssignedSession, reconcile, close: () => {
|
|
4112
4160
|
assignedCompletion.dispose();
|
|
4113
4161
|
cancelAssignedResumes({});
|
|
4114
4162
|
sessionAbortInflight.clear();
|
|
4115
|
-
pendingAssignMessageIDs.clear();
|
|
4116
4163
|
for (const turn of contactControllers.values()) turn.controller.abort();
|
|
4117
4164
|
if (!closed) {
|
|
4118
4165
|
closed = true;
|
|
@@ -2,7 +2,7 @@ import fs from 'node:fs';
|
|
|
2
2
|
import os from 'node:os';
|
|
3
3
|
import path from 'node:path';
|
|
4
4
|
import crypto from 'node:crypto';
|
|
5
|
-
import { describe, expect, it, vi } from 'vitest';
|
|
5
|
+
import { beforeEach, describe, expect, it, vi } from 'vitest';
|
|
6
6
|
import { createRequire } from 'node:module';
|
|
7
7
|
import { assignedSessionResumeMessageID, createAssistantsService } from './service.js';
|
|
8
8
|
import { assistantContractFixtures } from './contracts.js';
|
|
@@ -12,6 +12,9 @@ import {
|
|
|
12
12
|
} from './contact-tools.js';
|
|
13
13
|
import { runContactTurn as realRunContactTurn } from './harness.js';
|
|
14
14
|
import { AVATAR_COLORS, resolveAssistantAvatar } from '../../../../ui/src/lib/assistant-avatar/recipe.ts';
|
|
15
|
+
vi.mock('../opencode/native-goal.js', () => ({ getNativeSessionGoal: vi.fn(async () => null) }));
|
|
16
|
+
import { getNativeSessionGoal } from '../opencode/native-goal.js';
|
|
17
|
+
beforeEach(() => { getNativeSessionGoal.mockReset().mockResolvedValue(null); });
|
|
15
18
|
|
|
16
19
|
const require = createRequire(import.meta.url);
|
|
17
20
|
const root = () => fs.mkdtempSync(path.join(os.tmpdir(), 'assistants-'));
|
|
@@ -121,6 +124,11 @@ const assistantInput = { name: 'A', providerID: 'p', modelID: 'm' };
|
|
|
121
124
|
const greetingText = "Hi, I'm A. How can I help you?";
|
|
122
125
|
const toolBatch = (calls, content = '') => ({ completion: { choices: [{ message: { content, tool_calls: calls.map(([name, args, id = `call_${name}`]) => ({ id, type: 'function', function: { name, arguments: JSON.stringify(args) } })) } }] } });
|
|
123
126
|
const sayThen = (text, name, args) => toolBatch([['notify_user', { text }], [name, args]]);
|
|
127
|
+
const referenceResult = async (tools, result) => {
|
|
128
|
+
const reference = await tools.find((tool) => tool.name === 'reference_resource').execute('reference', JSON.parse(result.content[0].text).reference);
|
|
129
|
+
expect(reference.isError).not.toBe(true);
|
|
130
|
+
return reference.details.card;
|
|
131
|
+
};
|
|
124
132
|
|
|
125
133
|
describe('assistants service', () => {
|
|
126
134
|
it('persists pins across clients and restarts without changing catalog, session or share-default order', async () => {
|
|
@@ -2771,9 +2779,11 @@ describe('assistants service', () => {
|
|
|
2771
2779
|
toolBatch([['load_tools', { domain: 'yuri.projects' }]]),
|
|
2772
2780
|
toolBatch([['register_project', { path: workspace }]]),
|
|
2773
2781
|
toolBatch([['assign_session', { projectPath: workspace, prompt: 'hello' }]]),
|
|
2782
|
+
toolBatch([['reference_resource', { cardType: 'session', sessionID: 'ses_registered' }]]),
|
|
2774
2783
|
];
|
|
2775
2784
|
const service = setup(directory, {
|
|
2776
2785
|
create: async (input) => { creates.push(input); return { id: 'ses_registered' }; },
|
|
2786
|
+
get: async ({ sessionID }) => ({ id: sessionID, directory: workspace, title: 'Hello', status: { type: 'busy' } }),
|
|
2777
2787
|
prompt: async (input) => { prompts.push(input); return { id: 'inbox_hello', type: 'user' }; },
|
|
2778
2788
|
}, {
|
|
2779
2789
|
getAllowedRoots: () => projects.map((project) => project.path),
|
|
@@ -2827,6 +2837,7 @@ describe('assistants service', () => {
|
|
|
2827
2837
|
const prompts = [];
|
|
2828
2838
|
const archives = [];
|
|
2829
2839
|
const service = setup(directory, {
|
|
2840
|
+
get: async ({ sessionID }) => ({ id: sessionID, directory: project, title: 'Login', status: { type: 'busy' } }),
|
|
2830
2841
|
create: async (input) => {
|
|
2831
2842
|
creates.push(input);
|
|
2832
2843
|
return { data: { id: `ses_${creates.length}` } };
|
|
@@ -2846,7 +2857,7 @@ describe('assistants service', () => {
|
|
|
2846
2857
|
return {
|
|
2847
2858
|
text: 'Opened the login session.',
|
|
2848
2859
|
bubbles: ['Opened the login session.'],
|
|
2849
|
-
cards:
|
|
2860
|
+
cards: [await referenceResult(tools, result)],
|
|
2850
2861
|
tools,
|
|
2851
2862
|
};
|
|
2852
2863
|
},
|
|
@@ -2889,6 +2900,7 @@ describe('assistants service', () => {
|
|
|
2889
2900
|
fs.mkdirSync(project, { recursive: true });
|
|
2890
2901
|
const creates = [];
|
|
2891
2902
|
const service = setup(directory, {
|
|
2903
|
+
get: async ({ sessionID }) => ({ id: sessionID, directory: project, title: 'Once', status: { type: 'busy' } }),
|
|
2892
2904
|
create: async (input) => {
|
|
2893
2905
|
creates.push(input);
|
|
2894
2906
|
return { data: { id: `ses_${creates.length}` } };
|
|
@@ -2908,7 +2920,7 @@ describe('assistants service', () => {
|
|
|
2908
2920
|
return {
|
|
2909
2921
|
text: first.content[0].text,
|
|
2910
2922
|
bubbles: [first.content[0].text],
|
|
2911
|
-
cards:
|
|
2923
|
+
cards: [await referenceResult(tools, first), await referenceResult(tools, second)],
|
|
2912
2924
|
tools,
|
|
2913
2925
|
};
|
|
2914
2926
|
},
|
|
@@ -3449,7 +3461,7 @@ describe('assistants service', () => {
|
|
|
3449
3461
|
return {
|
|
3450
3462
|
text: '在听',
|
|
3451
3463
|
bubbles: ['在听'],
|
|
3452
|
-
cards:
|
|
3464
|
+
cards: [await referenceResult(tools, result)],
|
|
3453
3465
|
};
|
|
3454
3466
|
},
|
|
3455
3467
|
});
|
|
@@ -3493,7 +3505,7 @@ describe('assistants service', () => {
|
|
|
3493
3505
|
return {
|
|
3494
3506
|
text: '盯着',
|
|
3495
3507
|
bubbles: ['盯着'],
|
|
3496
|
-
cards:
|
|
3508
|
+
cards: [await referenceResult(tools, result)],
|
|
3497
3509
|
};
|
|
3498
3510
|
},
|
|
3499
3511
|
});
|
|
@@ -3532,7 +3544,7 @@ describe('assistants service', () => {
|
|
|
3532
3544
|
}
|
|
3533
3545
|
const result = await tools.find((tool) => tool.name === 'watch_session').execute('watch', { sessionID: 'ses_once' });
|
|
3534
3546
|
expect(result.isError).not.toBe(true);
|
|
3535
|
-
return { text: '在听', bubbles: ['在听'], cards: [result
|
|
3547
|
+
return { text: '在听', bubbles: ['在听'], cards: [await referenceResult(tools, result)] };
|
|
3536
3548
|
},
|
|
3537
3549
|
};
|
|
3538
3550
|
const client = { get: async ({ sessionID }) => ({ data: { id: sessionID, directory, status: { type: 'busy' } } }) };
|
|
@@ -3796,7 +3808,7 @@ describe('assistants service', () => {
|
|
|
3796
3808
|
return {
|
|
3797
3809
|
text: 'Created FlowQA.',
|
|
3798
3810
|
bubbles: ['Created FlowQA.'],
|
|
3799
|
-
cards:
|
|
3811
|
+
cards: [await referenceResult(tools, result)],
|
|
3800
3812
|
tools,
|
|
3801
3813
|
};
|
|
3802
3814
|
},
|
|
@@ -4061,7 +4073,8 @@ describe('assistants service', () => {
|
|
|
4061
4073
|
expect(missing.details.error).toBe('model_not_found');
|
|
4062
4074
|
expect(patches).toEqual([{ projectID: 'proj_a', taskID: 'task_a', patch: { execution: { providerID: 'new-provider', modelID: 'new-model' } } }]);
|
|
4063
4075
|
expect(synced).toEqual(['proj_a']);
|
|
4064
|
-
expect(updated.details.card).
|
|
4076
|
+
expect(updated.details.card).toBeUndefined();
|
|
4077
|
+
expect(JSON.parse(updated.content[0].text).reference).toEqual({ cardType: 'schedule', projectID: 'proj_a', taskID: 'task_a' });
|
|
4065
4078
|
service.close();
|
|
4066
4079
|
});
|
|
4067
4080
|
|
|
@@ -4070,6 +4083,7 @@ describe('assistants service', () => {
|
|
|
4070
4083
|
const upserts = [];
|
|
4071
4084
|
const service = setup(directory, {}, {
|
|
4072
4085
|
listProjects: async () => [{ id: 'proj_app', path: directory }],
|
|
4086
|
+
listScheduledTasks: async () => upserts.map(({ task }) => ({ ...task, id: 'task_ping' })),
|
|
4073
4087
|
upsertScheduledTask: async (projectID, task) => {
|
|
4074
4088
|
upserts.push({ projectID, task });
|
|
4075
4089
|
return {
|
|
@@ -4095,7 +4109,7 @@ describe('assistants service', () => {
|
|
|
4095
4109
|
return {
|
|
4096
4110
|
text: 'Scheduled the ping.',
|
|
4097
4111
|
bubbles: ['Scheduled the ping.'],
|
|
4098
|
-
cards:
|
|
4112
|
+
cards: [await referenceResult(tools, result)],
|
|
4099
4113
|
tools,
|
|
4100
4114
|
};
|
|
4101
4115
|
},
|
|
@@ -4132,7 +4146,7 @@ describe('assistants service', () => {
|
|
|
4132
4146
|
assistantID: host.id,
|
|
4133
4147
|
projectID: 'proj_app',
|
|
4134
4148
|
taskID: 'task_ping',
|
|
4135
|
-
task:
|
|
4149
|
+
task: expect.objectContaining({ id: 'task_ping' }),
|
|
4136
4150
|
})]);
|
|
4137
4151
|
service.close();
|
|
4138
4152
|
});
|
|
@@ -6644,12 +6658,12 @@ describe('read_session referenced conversation', () => {
|
|
|
6644
6658
|
if (userText === 'watch') {
|
|
6645
6659
|
const watch = tools.find((tool) => tool.name === 'watch_session');
|
|
6646
6660
|
const result = await watch.execute('call_w', { sessionID: 'ses_abort_race' });
|
|
6647
|
-
return { text: '盯着', bubbles: ['盯着'], cards:
|
|
6661
|
+
return { text: '盯着', bubbles: ['盯着'], cards: [await referenceResult(tools, result)] };
|
|
6648
6662
|
}
|
|
6649
6663
|
if (userText === 'peer watch') {
|
|
6650
6664
|
const watch = tools.find((tool) => tool.name === 'watch_session');
|
|
6651
6665
|
const result = await watch.execute('call_peer_w', { sessionID: 'ses_abort_race' });
|
|
6652
|
-
return { text: 'peer盯', bubbles: ['peer盯'], cards:
|
|
6666
|
+
return { text: 'peer盯', bubbles: ['peer盯'], cards: [await referenceResult(tools, result)] };
|
|
6653
6667
|
}
|
|
6654
6668
|
const stop = tools.find((tool) => tool.name === 'stop_session');
|
|
6655
6669
|
const stopPromise = stop.execute('call_s', { sessionID: 'ses_abort_race' });
|
|
@@ -6721,13 +6735,13 @@ describe('read_session referenced conversation', () => {
|
|
|
6721
6735
|
}
|
|
6722
6736
|
if (userText === 'watch both') {
|
|
6723
6737
|
const watch = tools.find((tool) => tool.name === 'watch_session');
|
|
6724
|
-
await watch.execute('w1', { sessionID: 'ses_fail_abort' });
|
|
6725
|
-
await watch.execute('w2', { sessionID: 'ses_other_worker' });
|
|
6738
|
+
await referenceResult(tools, await watch.execute('w1', { sessionID: 'ses_fail_abort' }));
|
|
6739
|
+
await referenceResult(tools, await watch.execute('w2', { sessionID: 'ses_other_worker' }));
|
|
6726
6740
|
return { text: '双盯', bubbles: ['双盯'], cards: [] };
|
|
6727
6741
|
}
|
|
6728
6742
|
if (userText === 'peer watch fail') {
|
|
6729
6743
|
const watch = tools.find((tool) => tool.name === 'watch_session');
|
|
6730
|
-
await watch.execute('peer_w', { sessionID: 'ses_fail_abort' });
|
|
6744
|
+
await referenceResult(tools, await watch.execute('peer_w', { sessionID: 'ses_fail_abort' }));
|
|
6731
6745
|
return { text: 'peer盯', bubbles: ['peer盯'], cards: [] };
|
|
6732
6746
|
}
|
|
6733
6747
|
const stop = tools.find((tool) => tool.name === 'stop_session');
|
|
@@ -6797,12 +6811,12 @@ describe('read_session referenced conversation', () => {
|
|
|
6797
6811
|
if (userText === 'watch') {
|
|
6798
6812
|
const watch = tools.find((tool) => tool.name === 'watch_session');
|
|
6799
6813
|
const result = await watch.execute('w', { sessionID: 'ses_silent' });
|
|
6800
|
-
return { text: '盯', bubbles: ['盯'], cards:
|
|
6814
|
+
return { text: '盯', bubbles: ['盯'], cards: [await referenceResult(tools, result)] };
|
|
6801
6815
|
}
|
|
6802
6816
|
if (userText === 'peer silent watch') {
|
|
6803
6817
|
const watch = tools.find((tool) => tool.name === 'watch_session');
|
|
6804
6818
|
const result = await watch.execute('peer_silent', { sessionID: 'ses_silent' });
|
|
6805
|
-
return { text: 'peer盯', bubbles: ['peer盯'], cards:
|
|
6819
|
+
return { text: 'peer盯', bubbles: ['peer盯'], cards: [await referenceResult(tools, result)] };
|
|
6806
6820
|
}
|
|
6807
6821
|
const stop = tools.find((tool) => tool.name === 'stop_session');
|
|
6808
6822
|
const result = await stop.execute('s', { sessionID: 'ses_silent' });
|