@yuriai/web 0.2.40-beta.5 → 0.2.40-beta.6
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-B7KbxN8Y.js → AgentAvatar-XDXiFZvA.js} +1 -1
- package/dist/assets/AssistantConversationSurface-B59k-lXE.css +1 -0
- package/dist/assets/AssistantConversationSurface-CQnJaKTn.js +3 -0
- package/dist/assets/AssistantSessionCard-DXY8-wyP.js +2 -0
- package/dist/assets/{AssistantUnreadBadge-vu4ZhTft.js → AssistantUnreadBadge-B-G015yE.js} +1 -1
- package/dist/assets/{AssistantView-CEfEWUIr.js → AssistantView-CasyQbii.js} +1 -1
- package/dist/assets/{DiagramView-Dlzr08J_.js → DiagramView-DhWnsM9v.js} +1 -1
- package/dist/assets/{FadeInOnReveal-DMRmNsau.js → FadeInOnReveal-Ca9EVP3a.js} +1 -1
- package/dist/assets/{GuiPluginPage-DVug4z_p.js → GuiPluginPage-DKOsUpVL.js} +1 -1
- package/dist/assets/{GuiPluginSurface-L43o6Xv8.js → GuiPluginSurface-BfXMBqdD.js} +1 -1
- package/dist/assets/{GuiPluginWindow-tHXkS18H.js → GuiPluginWindow-Dmg2Qui6.js} +1 -1
- package/dist/assets/{Icon-DizeYahT.js → Icon-ChyA050P.js} +1 -1
- package/dist/assets/{ImageLoadingPlaceholder-BZC5m_km.js → ImageLoadingPlaceholder-C8QUF5aV.js} +1 -1
- package/dist/assets/{LoadingImage-Csw4L-Dr.js → LoadingImage-BxRq1dMQ.js} +1 -1
- package/dist/assets/{MarkdownRenderer-D_0iKhQN.js → MarkdownRenderer-CvWLikEO.js} +2 -2
- package/dist/assets/{MarkdownRendererImpl-BZ0XgjS0.js → MarkdownRendererImpl-CcNsQOEn.js} +1 -1
- package/dist/assets/{MarkstreamRendererImpl-DBd6Glg9.js → MarkstreamRendererImpl-D9W5XXPo.js} +1 -1
- package/dist/assets/MobileDetailNavigation-CnwIZn5g.js +1 -0
- package/dist/assets/{MobileResizableSheet-CQQ7O-2X.js → MobileResizableSheet-Bpp079l7.js} +1 -1
- package/dist/assets/{MobileShareBridge-IO45gM2G.js → MobileShareBridge-C-GpJfF6.js} +1 -1
- package/dist/assets/MobileSurface-CrNI8cYQ.js +2 -0
- package/dist/assets/{MultiRunWindow-fJ3XfntS.js → MultiRunWindow-DvywQkz9.js} +1 -1
- package/dist/assets/{OnboardingScreen-MJS5T5rL.js → OnboardingScreen-BvueSxVk.js} +1 -1
- package/dist/assets/{OverlayScrollbar-jtMYTn1y.js → OverlayScrollbar-CPaH_j8g.js} +1 -1
- package/dist/assets/RemoteAssistantSessionCard-CFWE00xD.js +1 -0
- package/dist/assets/{SettingsView-ZWFLpPSI.js → SettingsView-Df6GCFPI.js} +10 -10
- package/dist/assets/{SettingsWindow-DGRmrIWz.js → SettingsWindow-BpaRjeR-.js} +1 -1
- package/dist/assets/{SetupTourDialog-BYbAubwA.js → SetupTourDialog-DD_4qiTz.js} +1 -1
- package/dist/assets/{TerminalView-CoJ6_9P1.js → TerminalView-CRTtNAfA.js} +1 -1
- package/dist/assets/{ToolOutputDialog-5xBwOJ6a.js → ToolOutputDialog-omGmWntf.js} +1 -1
- package/dist/assets/{VoiceSettings-CN33koSc.js → VoiceSettings-Du-Yd5MF.js} +2 -2
- package/dist/assets/{YuriWordmark-DnFAS-Ko.js → YuriWordmark-B7lmpLRB.js} +1 -1
- package/dist/assets/{capgoAdapter-CCLtBZL1.js → capgoAdapter-CqMX4zC-.js} +1 -1
- package/dist/assets/{checkbox-rOV6DjeG.js → checkbox-KNAgqjPZ.js} +1 -1
- package/dist/assets/{client-uz8O6TPX.js → client-1Fk5IbQR.js} +3 -3
- package/dist/assets/{collapsible-CKswuqAw.js → collapsible-CdiLY07j.js} +1 -1
- package/dist/assets/{context-menu-B4njwT_M.js → context-menu-CO_VRWeV.js} +1 -1
- package/dist/assets/{diagram-BppQ_USn.js → diagram-9b-Aaful.js} +1 -1
- package/dist/assets/{dialog-Bg8MJnOV.js → dialog-8YYmYPFP.js} +1 -1
- package/dist/assets/{fileMentionTouchSelection-D-AdTJVr.js → fileMentionTouchSelection-CLQBqWR8.js} +1 -1
- package/dist/assets/{gitApi-DVx_V1x6.js → gitApi-uhoLUa-e.js} +1 -1
- package/dist/assets/gitApiHttp-B0FJaIhU.js +3 -0
- package/dist/assets/{gui-DN2sVP96.js → gui-BMN3-WPc.js} +1 -1
- package/dist/assets/{host-DrGjjO6K.js → host-D9EDWNmx.js} +1 -1
- package/dist/assets/{input-DRjuZMeA.js → input-DK8VTvJw.js} +1 -1
- package/dist/assets/{input-store-CjUOfpyA.js → input-store-CsY-uaSj.js} +1 -1
- package/dist/assets/insertionBoundaries-rYqUxuB-.js +1 -0
- package/dist/assets/{main-D2s9J_jN.js → main-BMx-2MjO.js} +14 -14
- package/dist/assets/main-DzqojuZ1.js +2 -0
- package/dist/assets/{markdownHeightCache-BL99DlhC.js → markdownHeightCache-DAvnT6xF.js} +1 -1
- package/dist/assets/{mcpQueries-HzYMEVWd.js → mcpQueries-CpH8vPf1.js} +1 -1
- package/dist/assets/miniChat-BTE_XpRk.js +2 -0
- package/dist/assets/mobile-BBZOulQ1.js +2 -0
- package/dist/assets/{mobileBackNavigation--ZdrI-Yj.js → mobileBackNavigation-Cq08UPxZ.js} +1 -1
- package/dist/assets/{mobileConnections-C3eGEOPy.js → mobileConnections-ZehAozpe.js} +2 -2
- package/dist/assets/{multirun-CDYNyLBH.js → multirun-Cll2Meol.js} +1 -1
- package/dist/assets/{native-DsqzO52u.js → native-CDqNKjmz.js} +1 -1
- package/dist/assets/{native-config-DOawZfln.js → native-config-DtUZFauV.js} +1 -1
- package/dist/assets/{navigation-Ibk_Pw-q.js → navigation-J3d8PQcs.js} +2 -2
- package/dist/assets/openRemoteProjectSession-oJZpCDPT.js +1 -0
- package/dist/assets/{projectMeta-D1Ytss9U.js → projectMeta-BBpfOmij.js} +1 -1
- package/dist/assets/prompt-attachment-upload-9fjmgafL.js +1 -0
- package/dist/assets/{pwa-CXupOTsD.js → pwa-C8B1Mf_t.js} +1 -1
- package/dist/assets/{queue-abort-optimistic-CQXpIlq6.js → queue-abort-optimistic-B1Uskf6F.js} +1 -1
- package/dist/assets/{react-CgRToPwO.js → react-45rBMaUm.js} +1 -1
- package/dist/assets/{readiness-BfuZm6Yw.js → readiness-CrjBrUa_.js} +2 -2
- package/dist/assets/reference-history-DqfMBWzF.js +1 -0
- package/dist/assets/{remote-input-store-BOdCWpQY.js → remote-input-store-84i8uDyM.js} +1 -1
- package/dist/assets/remoteProjectQueries-B6lrEDMq.js +1 -0
- package/dist/assets/remoteSessionReference-YiGvdabX.js +1 -0
- package/dist/assets/renderElectronMiniChatApp-BuHQB0V8.js +2 -0
- package/dist/assets/renderMobileApp-D_VswCi0.js +29 -0
- package/dist/assets/{runtimeConfig-tHm7o_0I.js → runtimeConfig-CMbNyYbK.js} +1 -1
- package/dist/assets/runtimeEndpointReset-zo-HZQgX.js +151 -0
- package/dist/assets/scheduledTaskNavigation-y5g8D2ee.js +1 -0
- package/dist/assets/{select-B1On-Y4Z.js → select-VWoGVTBZ.js} +1 -1
- package/dist/assets/sessionLookup-JAf5UU7-.js +1 -0
- package/dist/assets/{sortable-tabs-strip-nD1Me06z.js → sortable-tabs-strip-Dbt3TTAs.js} +1 -1
- package/dist/assets/{speechSettingsQueries-BYhNpzDJ.js → speechSettingsQueries-Bidfcv0W.js} +1 -1
- package/dist/assets/{terminalApi-madXrfqA.js → terminalApi-Cq0vjFe1.js} +1 -1
- package/dist/assets/{textarea-Qt06OhhX.js → textarea-vyMsAV5p.js} +1 -1
- package/dist/assets/{tooltip-D382RCy1.js → tooltip-DWqHWi4N.js} +1 -1
- package/dist/assets/{types-CHszLAS3.js → types-DeOkRCgE.js} +1 -1
- package/dist/assets/{useAppFontEffects-CqXrCJVt.js → useAppFontEffects-z382Lhm_.js} +60 -60
- package/dist/assets/useDesktopWindowControlsLayout-BEs7i5qj.js +1 -0
- package/dist/assets/{useDictation-Bs7TWO9r.js → useDictation-e68rFA6y.js} +1 -1
- package/dist/assets/{useEffectiveDirectory-CCKRdyK9.js → useEffectiveDirectory-CcM3S1OQ.js} +1 -1
- package/dist/assets/{useFontPreferences-CPrl1_3z.js → useFontPreferences-CO-L-Gd7.js} +1 -1
- package/dist/assets/{useMobileNavigationStore-BNtVrnSw.js → useMobileNavigationStore-BA0IaUi_.js} +9 -9
- package/dist/assets/{usePluginsStore-bMuGciUE.js → usePluginsStore-BG5MW5LR.js} +1 -1
- package/dist/assets/{useProjectRuntimeAPIs-BFCXBu2J.js → useProjectRuntimeAPIs-Be4gXG7P.js} +1 -1
- package/dist/assets/{useStreamingTextThrottle-C8xAqcgP.js → useStreamingTextThrottle-DylP9HFC.js} +1 -1
- package/dist/assets/{vendor-opencode-client-cQ47ywrT.js → vendor-opencode-client-BM2r1f0o.js} +3 -3
- package/dist/assets/{vendor-opencode-plugin-BmdTE4Te.js → vendor-opencode-plugin-ZhpPgHCL.js} +1 -1
- package/dist/assets/{vendor-solid-js-D98iXT7C.js → vendor-solid-js-BBVUd3Hw.js} +1 -1
- package/dist/index.html +10 -10
- package/dist/mini-chat.html +10 -10
- package/dist/mobile.html +1 -1
- package/package.json +1 -1
- package/server/index.js +1 -0
- package/server/lib/assistants/DOCUMENTATION.md +87 -0
- package/server/lib/assistants/assign.js +10 -7
- package/server/lib/assistants/builtin-skills.js +1 -0
- package/server/lib/assistants/builtin-skills.test.js +1 -1
- package/server/lib/assistants/cards.js +6 -1
- package/server/lib/assistants/contact-store.js +22 -5
- package/server/lib/assistants/contact-tools.js +46 -26
- package/server/lib/assistants/execution-target.js +136 -0
- package/server/lib/assistants/opencode-tools.js +22 -9
- package/server/lib/assistants/remote-execution.test.js +378 -0
- package/server/lib/assistants/remote-watch-reconciler.js +43 -0
- package/server/lib/assistants/remote-watch-reconciler.test.js +88 -0
- package/server/lib/assistants/routes.js +1 -0
- package/server/lib/assistants/service.js +302 -99
- package/server/lib/assistants/yuri-project.http.test.js +2 -2
- package/server/lib/gui-customization/DOCUMENTATION.md +8 -2
- package/server/lib/gui-customization/projects-client.mjs +10 -8
- package/server/lib/gui-customization/projects-remote.js +101 -0
- package/server/lib/gui-customization/projects-remote.test.js +125 -0
- package/server/lib/gui-customization/projects.js +30 -6
- package/server/lib/gui-customization/projects.test.js +66 -1
- package/server/lib/gui-customization/session-skill.js +2 -2
- package/server/lib/gui-customization/session-skill.test.js +4 -0
- package/server/lib/gui-customization/skill/SKILL.md +3 -1
- package/server/lib/gui-customization/skill/references/projects.md +30 -3
- package/server/lib/gui-customization/skill/references/remote-connections.md +2 -0
- package/server/lib/opencode/DOCUMENTATION.md +6 -0
- package/server/lib/opencode/feature-routes-runtime.js +2 -0
- package/server/lib/opencode/v2-client.js +9 -4
- package/server/lib/remote-hosts/DOCUMENTATION.md +52 -0
- package/server/lib/remote-hosts/gateway.js +136 -36
- package/server/lib/remote-hosts/json-lifecycle.test.js +35 -0
- package/server/lib/remote-hosts/routes.js +10 -13
- package/server/lib/remote-hosts/routes.test.js +251 -0
- package/server/lib/remote-hosts/store.js +17 -3
- package/server/lib/remote-hosts/store.test.js +19 -0
- package/server/lib/remote-hosts/task-client.js +25 -0
- package/server/lib/remote-hosts/task-client.test.js +60 -0
- package/server/lib/remote-hosts/transport.js +7 -2
- package/server/lib/request-cors.js +1 -1
- package/server/lib/request-cors.test.js +1 -0
- package/server/lib/scheduled-tasks/session-skill.test.js +33 -2
- package/dist/assets/AssistantConversationSurface-BnK_KTBO.js +0 -3
- package/dist/assets/AssistantConversationSurface-n9w_Av0k.css +0 -1
- package/dist/assets/MobileDetailNavigation-xgwvsQuR.js +0 -1
- package/dist/assets/MobileSurface-DmYgZONB.js +0 -2
- package/dist/assets/gitApiHttp-DvTBxvX8.js +0 -3
- package/dist/assets/insertionBoundaries-DZtQt2Ah.js +0 -1
- package/dist/assets/main-BMFY9mtb.js +0 -2
- package/dist/assets/miniChat-BbJ0GKpk.js +0 -2
- package/dist/assets/mobile-_zUth69Z.js +0 -2
- package/dist/assets/prompt-attachment-upload-BNhDXymd.js +0 -1
- package/dist/assets/remoteProjectQueries-CkxdZNw4.js +0 -1
- package/dist/assets/renderElectronMiniChatApp-pJ59iC34.js +0 -2
- package/dist/assets/renderMobileApp-BQFC-gOA.js +0 -29
- package/dist/assets/runtimeEndpointReset-BhHWFNvo.js +0 -150
- package/dist/assets/scheduledTaskNavigation-BIDtQ4wN.js +0 -1
- package/dist/assets/sessionLookup-RcyTTDOy.js +0 -1
- package/dist/assets/useDesktopWindowControlsLayout-KH4UP7Gj.js +0 -1
- /package/dist/assets/{sessionLookup-8C8nv-EP.css → reference-history-8C8nv-EP.css} +0 -0
|
@@ -3,6 +3,8 @@ 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 { createAssistantExecutionAccessor, executionTargetKey, executionSessionKey, remoteDirectoryContained } from './execution-target.js';
|
|
7
|
+
import { createRemoteWatchReconciler } from './remote-watch-reconciler.js';
|
|
6
8
|
import { getNativeSessionGoal } from '../opencode/native-goal.js';
|
|
7
9
|
import { validAssistantDeliveryParts } from '../assistant-delivery-parts.js';
|
|
8
10
|
import { createContactMemoryReader } from './memory.js';
|
|
@@ -34,6 +36,7 @@ import {
|
|
|
34
36
|
listContactMessages,
|
|
35
37
|
listInFlightWatches,
|
|
36
38
|
listWatchesBySession,
|
|
39
|
+
listPendingRemoteWatchResumes,
|
|
37
40
|
migrateContactReadStateDefaultRead,
|
|
38
41
|
nextContactOrdinal,
|
|
39
42
|
projectActiveContactTurn,
|
|
@@ -235,6 +238,8 @@ export const assignedSessionResumeMessageID = (assistantID, sessionID, status, u
|
|
|
235
238
|
`resume_${assistantID}_${sessionID}_${status}_${updatedAt}`
|
|
236
239
|
);
|
|
237
240
|
const assignedSessionResumeStatus = (status) => status === 'complete' || status === 'error' || status === 'cancelled';
|
|
241
|
+
const resumeWorkerIdentity = (sessionID, target) => target
|
|
242
|
+
? crypto.createHash('sha256').update(executionSessionKey(sessionID, target)).digest('hex') : sessionID;
|
|
238
243
|
const awaitWithDeadline = async (work, ms = CONTACT_CATALOG_DEADLINE_MS, code = 'upstream_error') => {
|
|
239
244
|
let timer = null;
|
|
240
245
|
try {
|
|
@@ -253,7 +258,10 @@ const awaitWithDeadline = async (work, ms = CONTACT_CATALOG_DEADLINE_MS, code =
|
|
|
253
258
|
}
|
|
254
259
|
};
|
|
255
260
|
|
|
256
|
-
export const createAssistantsService = ({ dbPath, dataDir, buildOpenCodeUrl, getOpenCodeAuthHeaders, getServerId = async () => null, getAllowedRoots = () => [], listProjects = async () => [], registerProject = null, readModelPreferences = async () => null, listScheduledTasks = null, sessionIndexService = null, upsertScheduledTask = null, patchScheduledTask = null, syncScheduledTaskProject = null, globalEventHub = null, onRevisionTip = null, onContactTurnEvent = null, onContactTurnComplete = null, /** Host archive op: ({ sessionID, directory, archivedAt }) => Promise */ archiveSessionHost = null, /** Idempotent Host metadata drop after successful SDK delete */ forgetSessionHost = null, /** Host store write: (sessionId, patch) => Promise */ persistSessionMetadata = null, /** After Host isolation metadata is committed. */ onSystemSessionPersisted = null, clock = () => Date.now(), setIntervalFn = setInterval, clearIntervalFn = clearInterval, setImmediateFn = setImmediate, setTimeoutFn = setTimeout, clearTimeoutFn = clearTimeout, reconcileIntervalMs = 60_000, clientFactory, fetchImpl, createChatCompletion = null, runContactTurn = defaultRunContactTurn, listWorktrees = defaultListWorktrees } = {}) => {
|
|
261
|
+
export const createAssistantsService = ({ dbPath, dataDir, buildOpenCodeUrl, getOpenCodeAuthHeaders, getServerId = async () => null, getAllowedRoots = () => [], listProjects = async () => [], registerProject = null, readModelPreferences = async () => null, listScheduledTasks = null, sessionIndexService = null, upsertScheduledTask = null, patchScheduledTask = null, syncScheduledTaskProject = null, globalEventHub = null, onRevisionTip = null, onContactTurnEvent = null, onContactTurnComplete = null, /** Host archive op: ({ sessionID, directory, archivedAt }) => Promise */ archiveSessionHost = null, /** Idempotent Host metadata drop after successful SDK delete */ forgetSessionHost = null, /** Host store write: (sessionId, patch) => Promise */ persistSessionMetadata = null, /** After Host isolation metadata is committed. */ onSystemSessionPersisted = null, clock = () => Date.now(), setIntervalFn = setInterval, clearIntervalFn = clearInterval, setImmediateFn = setImmediate, setTimeoutFn = setTimeout, clearTimeoutFn = clearTimeout, reconcileIntervalMs = 60_000, clientFactory, fetchImpl, remoteHostGateway = null, createChatCompletion = null, runContactTurn = defaultRunContactTurn, listWorktrees = defaultListWorktrees } = {}) => {
|
|
262
|
+
const execution = createAssistantExecutionAccessor(remoteHostGateway);
|
|
263
|
+
const targetFields = () => execution.current() ? { target: execution.current().target } : {};
|
|
264
|
+
const scopedWork = (params, work) => execution.run(params, work);
|
|
257
265
|
if (!dbPath || !dataDir) return null;
|
|
258
266
|
const Database = require('better-sqlite3');
|
|
259
267
|
fs.mkdirSync(path.dirname(dbPath), { recursive: true });
|
|
@@ -430,6 +438,7 @@ export const createAssistantsService = ({ dbPath, dataDir, buildOpenCodeUrl, get
|
|
|
430
438
|
historySessionIDs: historyIDs(row.assistant_id),
|
|
431
439
|
historySessionCount: historyCount(row.assistant_id),
|
|
432
440
|
assignedSessionIDs: watches.map((watch) => watch.sessionID),
|
|
441
|
+
assignedSessions: watches.map(({ sessionID, directory, target }) => ({ sessionID, directory, ...(target ? { target } : {}) })),
|
|
433
442
|
// Grok-Bot list green dot: contact turn only. Assigned-session busy stays
|
|
434
443
|
// on the session card / assignedSessionIDs and must not keep the avatar lit.
|
|
435
444
|
working: activeContactTurn != null,
|
|
@@ -449,12 +458,12 @@ export const createAssistantsService = ({ dbPath, dataDir, buildOpenCodeUrl, get
|
|
|
449
458
|
};
|
|
450
459
|
};
|
|
451
460
|
const binding = (row) => ({ sessionID: row.current_session_id, directory: effectiveWorkspace(row), sessionGeneration: row.session_generation });
|
|
452
|
-
const client = () => clientFactory
|
|
461
|
+
const client = () => execution.current()?.api || (clientFactory
|
|
453
462
|
? clientFactory()
|
|
454
463
|
: makeOpenCodeV2Client({
|
|
455
464
|
baseUrl: buildOpenCodeUrl('/', '').replace(/\/$/, ''),
|
|
456
465
|
authHeaders: getOpenCodeAuthHeaders(),
|
|
457
|
-
});
|
|
466
|
+
}));
|
|
458
467
|
const metadata = (row) => buildAssistantSessionMetadata({
|
|
459
468
|
assistantID: row.assistant_id,
|
|
460
469
|
name: row.name,
|
|
@@ -572,9 +581,10 @@ export const createAssistantsService = ({ dbPath, dataDir, buildOpenCodeUrl, get
|
|
|
572
581
|
// Last UI locale seen from a client per assistant. Background notifications
|
|
573
582
|
// (assigned-session settle) have no request locale, so they recall this value.
|
|
574
583
|
const contactTurnLanguages = new Map();
|
|
575
|
-
const cancelAssignedResumes = ({ sessionID, assistantID, statuses } = {}) => {
|
|
584
|
+
const cancelAssignedResumes = ({ sessionID, assistantID, statuses, target } = {}) => {
|
|
576
585
|
for (const resume of assignedResumes.values()) {
|
|
577
586
|
if (sessionID && resume.sessionID !== sessionID) continue;
|
|
587
|
+
if (sessionID && executionTargetKey(resume.target) !== executionTargetKey(target)) continue;
|
|
578
588
|
if (assistantID && resume.assistantID !== assistantID) continue;
|
|
579
589
|
if (statuses && !statuses.includes(resume.status)) continue;
|
|
580
590
|
resume.controller.abort();
|
|
@@ -632,13 +642,101 @@ export const createAssistantsService = ({ dbPath, dataDir, buildOpenCodeUrl, get
|
|
|
632
642
|
// Assigned-session complete/error/cancelled resumes the contact LLM (no canned settle bubble).
|
|
633
643
|
// Assigned after inContactTurnLane exists; reportAssignedSession only schedules via this ref.
|
|
634
644
|
const assignedSessionResumeRef = { schedule: null };
|
|
645
|
+
const remoteWatchLeases = new Map();
|
|
646
|
+
const releaseRemoteWatch = (sessionID, target) => {
|
|
647
|
+
const key = executionSessionKey(sessionID, target);
|
|
648
|
+
const entry = remoteWatchLeases.get(key);
|
|
649
|
+
remoteWatchLeases.delete(key);
|
|
650
|
+
entry?.controller.abort();
|
|
651
|
+
entry?.lease?.release();
|
|
652
|
+
};
|
|
653
|
+
const pruneRemoteWatchLeases = () => {
|
|
654
|
+
const activeKeys = new Set(listInFlightWatches(db).filter((watch) => watch.target).map((watch) => executionSessionKey(watch.sessionID, watch.target)));
|
|
655
|
+
for (const [key, entry] of remoteWatchLeases) if (!activeKeys.has(key)) {
|
|
656
|
+
remoteWatchLeases.delete(key); entry.controller.abort(); entry.lease?.release();
|
|
657
|
+
}
|
|
658
|
+
};
|
|
659
|
+
const remoteWatchReconciler = createRemoteWatchReconciler(async (batch, isCurrent) => {
|
|
660
|
+
if (closed) return;
|
|
661
|
+
const watches = batch.filter((watch) => {
|
|
662
|
+
if (listWatchesBySession(db, watch.sessionID, watch.target).some((item) => item.active)) return true;
|
|
663
|
+
releaseRemoteWatch(watch.sessionID, watch.target);
|
|
664
|
+
return false;
|
|
665
|
+
});
|
|
666
|
+
if (!watches.length) return;
|
|
667
|
+
await scopedWork(watches[0], async () => {
|
|
668
|
+
const { activeRoots } = await readSessionFamilyActivity(assignedFamilyAuthority);
|
|
669
|
+
for (const watch of watches) {
|
|
670
|
+
if (closed) return;
|
|
671
|
+
if (!isCurrent(watch)) continue;
|
|
672
|
+
if (activeRoots.has(watch.sessionID)) {
|
|
673
|
+
commitAssignedSession(watch.sessionID, 'busy', { target: watch.target, resume: false });
|
|
674
|
+
continue;
|
|
675
|
+
}
|
|
676
|
+
try {
|
|
677
|
+
const getResult = await invokeSession(() => client().session.get({ sessionID: watch.sessionID }));
|
|
678
|
+
if (closed) return;
|
|
679
|
+
if (!isCurrent(watch)) continue;
|
|
680
|
+
if (isMissing(getResult)) {
|
|
681
|
+
commitAssignedSession(watch.sessionID, 'cancelled', { target: watch.target, resume: false });
|
|
682
|
+
continue;
|
|
683
|
+
}
|
|
684
|
+
const messagesResult = await invokeSession(() => client().message.list({ sessionID: watch.sessionID, limit: 100, order: 'desc' }));
|
|
685
|
+
const goal = await getNativeSessionGoal(client(), watch.sessionID, watch.directory);
|
|
686
|
+
if (closed) return;
|
|
687
|
+
if (!isCurrent(watch)) continue;
|
|
688
|
+
for (const current of listWatchesBySession(db, watch.sessionID, watch.target).filter((item) => item.active)) {
|
|
689
|
+
if (current.status === 'complete' || current.status === 'error' || current.status === 'cancelled') continue;
|
|
690
|
+
const status = inferAssignedSessionSettleStatus(getResult, messagesResult, { deliveryMessageID: current.messageID, activeBusy: false, goal });
|
|
691
|
+
if (status) commitAssignedSession(watch.sessionID, status, { target: watch.target });
|
|
692
|
+
}
|
|
693
|
+
} catch { /* Preserve this watch without blocking unrelated workers on the same machine. */ }
|
|
694
|
+
}
|
|
695
|
+
});
|
|
696
|
+
});
|
|
697
|
+
const reconcileRemoteWatch = (watch, changed = false) => remoteWatchReconciler.reconcile(watch, changed);
|
|
698
|
+
const retainRemoteWatch = async (watch, { reconcile = true } = {}) => {
|
|
699
|
+
const key = executionSessionKey(watch.sessionID, watch.target);
|
|
700
|
+
if (remoteWatchLeases.has(key) || closed) return;
|
|
701
|
+
const controller = new AbortController();
|
|
702
|
+
const entry = { controller, lease: null };
|
|
703
|
+
remoteWatchLeases.set(key, entry);
|
|
704
|
+
try {
|
|
705
|
+
const lease = await execution.acquire(watch.target, {
|
|
706
|
+
signal: controller.signal,
|
|
707
|
+
onEvent: (event) => {
|
|
708
|
+
const payload = event?.payload?.payload ?? event?.payload ?? event;
|
|
709
|
+
const body = eventBody(payload);
|
|
710
|
+
const sessionID = eventSessionID(body) || (payload?.type === 'session.deleted' && nonEmptyString(body?.id) ? body.id : '');
|
|
711
|
+
if (sessionID === watch.sessionID && !closed) {
|
|
712
|
+
if (payload.type === 'session.deleted') {
|
|
713
|
+
commitAssignedSession(sessionID, 'cancelled', { target: watch.target, resume: false });
|
|
714
|
+
return;
|
|
715
|
+
}
|
|
716
|
+
const status = settleStatusFromEvent(payload, body);
|
|
717
|
+
if (status === 'cancelled' || status === 'error' || status === 'busy' || status === 'question') {
|
|
718
|
+
remoteWatchReconciler.invalidate(watch);
|
|
719
|
+
commitAssignedSession(sessionID, status, { target: watch.target });
|
|
720
|
+
if (status !== 'question') return;
|
|
721
|
+
}
|
|
722
|
+
}
|
|
723
|
+
if (sessionID === watch.sessionID || payload?.type === 'server.connected' || payload?.type === 'yuri:session-index-changed'
|
|
724
|
+
|| (payload?.type === 'yuri:host-status' && body.host?.state === 'connected')) void reconcileRemoteWatch(watch, true);
|
|
725
|
+
},
|
|
726
|
+
});
|
|
727
|
+
if (closed || remoteWatchLeases.get(key) !== entry) { lease.release(); return; }
|
|
728
|
+
entry.lease = lease;
|
|
729
|
+
if (reconcile) void reconcileRemoteWatch(watch);
|
|
730
|
+
} catch (error) { releaseRemoteWatch(watch.sessionID, watch.target); throw error; }
|
|
731
|
+
};
|
|
635
732
|
const commitAssignedSession = (sessionID, status, resumeOrOpts = true) => {
|
|
636
733
|
const opts = plainObject(resumeOrOpts)
|
|
637
734
|
? resumeOrOpts
|
|
638
735
|
: { resume: resumeOrOpts !== false };
|
|
639
736
|
const resume = opts.resume !== false;
|
|
737
|
+
const target = opts.target;
|
|
640
738
|
const requireExecutionOwned = opts.requireExecutionOwned === true;
|
|
641
|
-
const inflight = sessionAbortInflight.get(sessionID);
|
|
739
|
+
const inflight = sessionAbortInflight.get(executionSessionKey(sessionID, target));
|
|
642
740
|
if (inflight) {
|
|
643
741
|
// Defer watch terminal + continuation until stop_session abort settles.
|
|
644
742
|
stashSessionAbortTerminal(inflight, status, resume);
|
|
@@ -650,20 +748,20 @@ export const createAssistantsService = ({ dbPath, dataDir, buildOpenCodeUrl, get
|
|
|
650
748
|
const interruptedAssistants = new Set();
|
|
651
749
|
if (status === 'cancelled') {
|
|
652
750
|
for (const item of assignedResumes.values()) {
|
|
653
|
-
if (item.sessionID === sessionID && (item.status === 'complete' || item.status === 'error') && !item.controller.signal.aborted) {
|
|
751
|
+
if (item.sessionID === sessionID && executionTargetKey(item.target) === executionTargetKey(target) && (item.status === 'complete' || item.status === 'error') && !item.controller.signal.aborted) {
|
|
654
752
|
interruptedAssistants.add(item.assistantID);
|
|
655
753
|
}
|
|
656
754
|
}
|
|
657
|
-
cancelAssignedResumes({ sessionID, statuses: ['complete', 'error'] });
|
|
755
|
+
cancelAssignedResumes({ sessionID, target, statuses: ['complete', 'error'] });
|
|
658
756
|
}
|
|
659
|
-
if (listWatchesBySession(db, sessionID).length === 0) return false;
|
|
757
|
+
if (listWatchesBySession(db, sessionID, target).length === 0) return false;
|
|
660
758
|
let changed = false;
|
|
661
759
|
const resumes = [];
|
|
662
760
|
db.exec('BEGIN IMMEDIATE');
|
|
663
761
|
try {
|
|
664
762
|
// Read under the write lock: another Host process sharing this SQLite file
|
|
665
763
|
// may have settled the same watch, and only one transition may resume.
|
|
666
|
-
const watches = listWatchesBySession(db, sessionID);
|
|
764
|
+
const watches = listWatchesBySession(db, sessionID, target);
|
|
667
765
|
for (const watch of watches) {
|
|
668
766
|
// A terminal report consumes the watch. Only a still-pending result may
|
|
669
767
|
// be corrected to a user interruption; later executions need a new watch.
|
|
@@ -675,10 +773,11 @@ export const createAssistantsService = ({ dbPath, dataDir, buildOpenCodeUrl, get
|
|
|
675
773
|
// session.idle can race a reuse assign. Formal execution.* owns that path.
|
|
676
774
|
if (requireExecutionOwned && status === 'complete' && watch.messageID) continue;
|
|
677
775
|
const updatedAt = now();
|
|
678
|
-
updateSessionCardStatus(db, { assistantID: watch.assistantID, sessionID, status });
|
|
776
|
+
updateSessionCardStatus(db, { assistantID: watch.assistantID, sessionID, status, target });
|
|
679
777
|
upsertContactWatch(db, {
|
|
680
778
|
assistantID: watch.assistantID,
|
|
681
779
|
sessionID,
|
|
780
|
+
...(target ? { target } : {}),
|
|
682
781
|
directory: watch.directory,
|
|
683
782
|
status,
|
|
684
783
|
updatedAt,
|
|
@@ -686,13 +785,15 @@ export const createAssistantsService = ({ dbPath, dataDir, buildOpenCodeUrl, get
|
|
|
686
785
|
active: !assignedSessionResumeStatus(status),
|
|
687
786
|
...(watch.messageID ? { messageID: watch.messageID } : {}),
|
|
688
787
|
});
|
|
788
|
+
if (target) db.prepare('UPDATE assistant_contact_watch SET remote_resume_pending=? WHERE assistant_id=? AND session_id=?')
|
|
789
|
+
.run(resume && watch.resumeAllowed && assignedSessionResumeStatus(status) ? 1 : 0, watch.assistantID, executionSessionKey(sessionID, target));
|
|
689
790
|
if (status === 'complete' && resume && watch.resumeAllowed) {
|
|
690
|
-
const card = findAssignedSessionCard(watch.assistantID, sessionID);
|
|
791
|
+
const card = findAssignedSessionCard(watch.assistantID, sessionID, target);
|
|
691
792
|
if (card) insertContactMessage(db, {
|
|
692
|
-
messageID: `${assignedSessionResumeMessageID(watch.assistantID, sessionID, status, updatedAt)}:receipt`,
|
|
793
|
+
messageID: `${assignedSessionResumeMessageID(watch.assistantID, resumeWorkerIdentity(sessionID, target), status, updatedAt)}:receipt`,
|
|
693
794
|
assistantID: watch.assistantID,
|
|
694
795
|
role: 'assistant',
|
|
695
|
-
turnID: assignedSessionResumeMessageID(watch.assistantID, sessionID, status, updatedAt),
|
|
796
|
+
turnID: assignedSessionResumeMessageID(watch.assistantID, resumeWorkerIdentity(sessionID, target), status, updatedAt),
|
|
696
797
|
createdAt: updatedAt,
|
|
697
798
|
ordinal: nextContactOrdinal(db, watch.assistantID),
|
|
698
799
|
status: 'complete',
|
|
@@ -706,6 +807,7 @@ export const createAssistantsService = ({ dbPath, dataDir, buildOpenCodeUrl, get
|
|
|
706
807
|
resumes.push({
|
|
707
808
|
assistantID: watch.assistantID,
|
|
708
809
|
sessionID,
|
|
810
|
+
...(target ? { target } : {}),
|
|
709
811
|
status,
|
|
710
812
|
directory: watch.directory,
|
|
711
813
|
updatedAt,
|
|
@@ -723,6 +825,7 @@ export const createAssistantsService = ({ dbPath, dataDir, buildOpenCodeUrl, get
|
|
|
723
825
|
if (typeof assignedSessionResumeRef.schedule === 'function') {
|
|
724
826
|
for (const item of resumes) assignedSessionResumeRef.schedule(item);
|
|
725
827
|
}
|
|
828
|
+
if (target && assignedSessionResumeStatus(status)) releaseRemoteWatch(sessionID, target);
|
|
726
829
|
return changed;
|
|
727
830
|
};
|
|
728
831
|
const sessionStatusType = (session) => {
|
|
@@ -782,6 +885,8 @@ export const createAssistantsService = ({ dbPath, dataDir, buildOpenCodeUrl, get
|
|
|
782
885
|
},
|
|
783
886
|
});
|
|
784
887
|
const reportAssignedSession = (sessionID, status, resumeOrOpts = true) => {
|
|
888
|
+
const target = plainObject(resumeOrOpts) ? resumeOrOpts.target : undefined;
|
|
889
|
+
if (target) return commitAssignedSession(sessionID, status, resumeOrOpts);
|
|
785
890
|
if (status !== 'complete' || sessionAbortInflight.has(sessionID)) {
|
|
786
891
|
if (status === 'busy') void assignedCompletion.observe({ kind: 'running', sessionId: sessionID });
|
|
787
892
|
if (status === 'error' || status === 'cancelled') {
|
|
@@ -916,6 +1021,21 @@ export const createAssistantsService = ({ dbPath, dataDir, buildOpenCodeUrl, get
|
|
|
916
1021
|
return;
|
|
917
1022
|
}
|
|
918
1023
|
if (watches.length === 0) return;
|
|
1024
|
+
const remoteHosts = new Map();
|
|
1025
|
+
for (const watch of watches) if (watch.target) {
|
|
1026
|
+
const key = executionTargetKey(watch.target);
|
|
1027
|
+
if (!remoteHosts.has(key)) remoteHosts.set(key, new Map());
|
|
1028
|
+
remoteHosts.get(key).set(watch.sessionID, watch);
|
|
1029
|
+
}
|
|
1030
|
+
await Promise.all([...remoteHosts.values()].map(async (workers) => {
|
|
1031
|
+
const batch = [...workers.values()];
|
|
1032
|
+
await Promise.all(batch.map(async (watch) => {
|
|
1033
|
+
try { await retainRemoteWatch(watch, { reconcile: false }); } catch { /* Keep offline watches retryable. */ }
|
|
1034
|
+
}));
|
|
1035
|
+
await Promise.all(batch.map((watch) => reconcileRemoteWatch(watch)));
|
|
1036
|
+
}));
|
|
1037
|
+
watches = watches.filter((watch) => !watch.target);
|
|
1038
|
+
if (watches.length === 0) return;
|
|
919
1039
|
// One family snapshot per reconcile, shared by every watched worker.
|
|
920
1040
|
let activeSessions;
|
|
921
1041
|
try {
|
|
@@ -1956,15 +2076,16 @@ export const createAssistantsService = ({ dbPath, dataDir, buildOpenCodeUrl, get
|
|
|
1956
2076
|
throw wrapped;
|
|
1957
2077
|
}
|
|
1958
2078
|
};
|
|
1959
|
-
const loadContactModelContext = async (signal) => {
|
|
2079
|
+
const loadContactModelContext = async (signal, params = {}) => scopedWork({ ...params, signal }, async () => {
|
|
1960
2080
|
const [catalogResult, preferencesResult] = await Promise.allSettled([
|
|
1961
2081
|
loadAssignCatalog(signal),
|
|
1962
|
-
awaitWithDeadline(Promise.resolve().then(() => readModelPreferences()), CONTACT_CATALOG_DEADLINE_MS, 'upstream_error'),
|
|
2082
|
+
execution.current() ? Promise.resolve(null) : awaitWithDeadline(Promise.resolve().then(() => readModelPreferences()), CONTACT_CATALOG_DEADLINE_MS, 'upstream_error'),
|
|
1963
2083
|
]);
|
|
1964
2084
|
const catalog = catalogResult.status === 'fulfilled' ? catalogResult.value : null;
|
|
1965
2085
|
const providerNames = new Map((catalog?.providers || []).map((provider) => [provider.id, provider.name]));
|
|
1966
2086
|
const preferences = preferencesResult.status === 'fulfilled' ? preferencesResult.value : null;
|
|
1967
2087
|
return {
|
|
2088
|
+
...targetFields(),
|
|
1968
2089
|
connectedModels: normalizeConnectedModels((catalog?.models || []).map((model) => ({ ...model, providerName: providerNames.get(model.providerID) }))),
|
|
1969
2090
|
modelCatalogAvailable: catalog !== null,
|
|
1970
2091
|
modelPreferences: preferences && typeof preferences === 'object' ? {
|
|
@@ -1972,14 +2093,18 @@ export const createAssistantsService = ({ dbPath, dataDir, buildOpenCodeUrl, get
|
|
|
1972
2093
|
recentModels: Array.isArray(preferences.recentModels) ? preferences.recentModels.slice(0, 16) : [],
|
|
1973
2094
|
} : null,
|
|
1974
2095
|
};
|
|
1975
|
-
};
|
|
1976
|
-
const loadRegisteredProjects = async () => {
|
|
2096
|
+
});
|
|
2097
|
+
const loadRegisteredProjects = async (params) => scopedWork(params, async () => {
|
|
2098
|
+
if (execution.current()) return execution.current().projects();
|
|
1977
2099
|
const listed = await awaitWithDeadline(listProjects(), CONTACT_CATALOG_DEADLINE_MS, 'upstream_error');
|
|
1978
2100
|
if (!Array.isArray(listed)) {
|
|
1979
2101
|
throw new AssignError(ASSIGN_CODES.UPSTREAM, 'Registered project catalog failed to load.');
|
|
1980
2102
|
}
|
|
1981
|
-
|
|
1982
|
-
|
|
2103
|
+
const remote = await execution.discover({ probe: params !== undefined, signal: params?.signal });
|
|
2104
|
+
const projects = [...listed, ...remote];
|
|
2105
|
+
projects.failed = remote.failed || [];
|
|
2106
|
+
return projects;
|
|
2107
|
+
});
|
|
1983
2108
|
/**
|
|
1984
2109
|
* Confirm whether an assign prompt message was admitted on the worker session.
|
|
1985
2110
|
* Prefer SDK exact lookup (v2.session.message → session.message), then bounded messages list.
|
|
@@ -2125,7 +2250,7 @@ export const createAssistantsService = ({ dbPath, dataDir, buildOpenCodeUrl, get
|
|
|
2125
2250
|
throw new AssignError(ASSIGN_CODES.VALIDATION, 'sessionID is required.');
|
|
2126
2251
|
}
|
|
2127
2252
|
const options = signal ? { signal } : undefined;
|
|
2128
|
-
const indexRow = findSessionInIndex(sessionID);
|
|
2253
|
+
const indexRow = execution.current() ? null : findSessionInIndex(sessionID);
|
|
2129
2254
|
const hint = typeof directoryHint === 'string' && directoryHint.trim()
|
|
2130
2255
|
? directoryHint.trim()
|
|
2131
2256
|
: null;
|
|
@@ -2185,6 +2310,7 @@ export const createAssistantsService = ({ dbPath, dataDir, buildOpenCodeUrl, get
|
|
|
2185
2310
|
}
|
|
2186
2311
|
const sessionPayload = getResult.data ?? getResult;
|
|
2187
2312
|
const metaDirectory = extractSessionDirectory(sessionPayload);
|
|
2313
|
+
if (execution.current() && (sessionPayload.id !== sessionID || !metaDirectory)) throw new AssignError('upstream_error', 'Remote session identity or directory was not confirmed.');
|
|
2188
2314
|
const directoryRaw = metaDirectory || indexRow?.directory || usedDirectoryHint;
|
|
2189
2315
|
if (!directoryRaw) {
|
|
2190
2316
|
throw new AssignError(
|
|
@@ -2196,7 +2322,7 @@ export const createAssistantsService = ({ dbPath, dataDir, buildOpenCodeUrl, get
|
|
|
2196
2322
|
// Reject managed assistant-workspaces and paths outside Settings projects.
|
|
2197
2323
|
let directory;
|
|
2198
2324
|
try {
|
|
2199
|
-
directory = resolveAssignDirectory({
|
|
2325
|
+
directory = await (execution.current()?.resolveDirectory || resolveAssignDirectory)({
|
|
2200
2326
|
projectPath: directoryRaw,
|
|
2201
2327
|
directory: directoryRaw,
|
|
2202
2328
|
branch: null,
|
|
@@ -2245,11 +2371,12 @@ export const createAssistantsService = ({ dbPath, dataDir, buildOpenCodeUrl, get
|
|
|
2245
2371
|
directory,
|
|
2246
2372
|
title,
|
|
2247
2373
|
status,
|
|
2374
|
+
...targetFields(),
|
|
2248
2375
|
session: sessionPayload,
|
|
2249
2376
|
messages: messageRows,
|
|
2250
2377
|
};
|
|
2251
2378
|
};
|
|
2252
|
-
const readSessionWork = async (params = {}) => {
|
|
2379
|
+
const readSessionWork = async (params = {}) => scopedWork(params, async () => {
|
|
2253
2380
|
const limit = params.limit === undefined ? 20 : params.limit;
|
|
2254
2381
|
if (!Number.isInteger(limit) || limit < 1 || limit > 50) throw new AssignError(ASSIGN_CODES.VALIDATION, 'limit must be an integer from 1 to 50.');
|
|
2255
2382
|
if (params.before !== undefined && (typeof params.before !== 'string' || !params.before || params.before.length > 2048)) throw new AssignError(ASSIGN_CODES.VALIDATION, 'before must be an opaque cursor.');
|
|
@@ -2260,7 +2387,7 @@ export const createAssistantsService = ({ dbPath, dataDir, buildOpenCodeUrl, get
|
|
|
2260
2387
|
const result = await invokeSession(() => client().message.list({
|
|
2261
2388
|
sessionID: resolved.sessionID, limit,
|
|
2262
2389
|
...(params.before ? { cursor: params.before } : { order: 'desc' }),
|
|
2263
|
-
}));
|
|
2390
|
+
}, signal ? { signal } : undefined));
|
|
2264
2391
|
signal?.throwIfAborted();
|
|
2265
2392
|
if (isMissing(result)) throw new AssignError(ASSIGN_CODES.NOT_FOUND, 'That session no longer exists.');
|
|
2266
2393
|
const projected = result?.error ? null : projectionEntries(result, resolved.sessionID);
|
|
@@ -2293,9 +2420,9 @@ export const createAssistantsService = ({ dbPath, dataDir, buildOpenCodeUrl, get
|
|
|
2293
2420
|
return { messageID: info.id, role: info.role, parts };
|
|
2294
2421
|
});
|
|
2295
2422
|
const nextCursor = projectionCursor(result);
|
|
2296
|
-
return { sessionID: resolved.sessionID, directory: resolved.directory, title: resolved.title.slice(0, 500), messages, nextCursor, partial: partial || nextCursor !== null };
|
|
2297
|
-
};
|
|
2298
|
-
const assignWork = async (row, params = {}) => {
|
|
2423
|
+
return { ...targetFields(), sessionID: resolved.sessionID, directory: resolved.directory, title: resolved.title.slice(0, 500), messages, nextCursor, partial: partial || nextCursor !== null };
|
|
2424
|
+
});
|
|
2425
|
+
const assignWork = async (row, params = {}) => scopedWork(params, async () => {
|
|
2299
2426
|
const fileParts = sanitizeAssignFileParts(params.fileParts || params.parts || []);
|
|
2300
2427
|
const signal = params.signal;
|
|
2301
2428
|
const sdkOptions = signal ? { signal } : undefined;
|
|
@@ -2356,7 +2483,8 @@ export const createAssistantsService = ({ dbPath, dataDir, buildOpenCodeUrl, get
|
|
|
2356
2483
|
});
|
|
2357
2484
|
}
|
|
2358
2485
|
}
|
|
2359
|
-
const
|
|
2486
|
+
const useTargetDefaults = Boolean(execution.current() && !explicitModel);
|
|
2487
|
+
const workerModel = useTargetDefaults ? { source: 'target-default', acceptsImages: null } : resolveAssignWorkerModel({
|
|
2360
2488
|
providerID: params.providerID,
|
|
2361
2489
|
modelID: params.modelID,
|
|
2362
2490
|
model: params.model,
|
|
@@ -2375,6 +2503,7 @@ export const createAssistantsService = ({ dbPath, dataDir, buildOpenCodeUrl, get
|
|
|
2375
2503
|
// Forward tool variant + AbortSignal; lookupMessage uses real SDK exact/list paths.
|
|
2376
2504
|
const assigned = await assignSession({
|
|
2377
2505
|
...params,
|
|
2506
|
+
useTargetDefaults,
|
|
2378
2507
|
...(reuseScope ? {
|
|
2379
2508
|
sessionID: reuseScope.sessionID,
|
|
2380
2509
|
directory: reuseScope.directory,
|
|
@@ -2395,22 +2524,23 @@ export const createAssistantsService = ({ dbPath, dataDir, buildOpenCodeUrl, get
|
|
|
2395
2524
|
acceptsImages,
|
|
2396
2525
|
},
|
|
2397
2526
|
acceptsImages,
|
|
2398
|
-
assistant: output(row),
|
|
2399
|
-
defaultProjectPath: row.workspace_path,
|
|
2527
|
+
assistant: execution.current() ? { id: row.assistant_id, name: row.name } : output(row),
|
|
2528
|
+
defaultProjectPath: execution.current() ? null : row.workspace_path,
|
|
2529
|
+
...(execution.current() ? { resolveDirectory: execution.current().resolveDirectory } : {}),
|
|
2400
2530
|
allowedRoots: getAllowedRoots(),
|
|
2401
2531
|
managedWorkspaceRoot: path.resolve(dataDir, 'assistant-workspaces'),
|
|
2402
|
-
listWorktrees,
|
|
2532
|
+
listWorktrees: execution.current()?.worktrees || listWorktrees,
|
|
2403
2533
|
createSession: (created) => client().session.create({
|
|
2404
2534
|
title: created?.title,
|
|
2405
2535
|
...(created?.directory ? { location: { directory: created.directory } } : {}),
|
|
2406
2536
|
...(created?.agent ? { agent: created.agent } : {}),
|
|
2407
2537
|
...(created?.model ? { model: created.model } : {}),
|
|
2408
2538
|
...(created?.metadata ? { metadata: created.metadata } : {}),
|
|
2409
|
-
}),
|
|
2539
|
+
}, sdkOptions),
|
|
2410
2540
|
promptExisting: async (prompted) => {
|
|
2411
2541
|
const api = client();
|
|
2412
2542
|
if (typeof api.session.switchAgent === 'function' && prompted.agent) {
|
|
2413
|
-
await api.session.switchAgent({ sessionID: prompted.sessionID, agent: prompted.agent });
|
|
2543
|
+
await api.session.switchAgent({ sessionID: prompted.sessionID, agent: prompted.agent }, sdkOptions);
|
|
2414
2544
|
}
|
|
2415
2545
|
if (typeof api.session.switchModel === 'function' && prompted.model) {
|
|
2416
2546
|
await api.session.switchModel({
|
|
@@ -2420,9 +2550,9 @@ export const createAssistantsService = ({ dbPath, dataDir, buildOpenCodeUrl, get
|
|
|
2420
2550
|
providerID: prompted.model.providerID,
|
|
2421
2551
|
...(prompted.variant ? { variant: prompted.variant } : {}),
|
|
2422
2552
|
},
|
|
2423
|
-
});
|
|
2553
|
+
}, sdkOptions);
|
|
2424
2554
|
}
|
|
2425
|
-
return api.session.prompt(toV2PromptInput(prompted.sessionID, prompted.parts, prompted.messageID));
|
|
2555
|
+
return api.session.prompt(toV2PromptInput(prompted.sessionID, prompted.parts, prompted.messageID), sdkOptions);
|
|
2426
2556
|
},
|
|
2427
2557
|
deleteSession: (deleted) => (
|
|
2428
2558
|
typeof client().session.remove === 'function'
|
|
@@ -2439,19 +2569,23 @@ export const createAssistantsService = ({ dbPath, dataDir, buildOpenCodeUrl, get
|
|
|
2439
2569
|
upsertContactWatch(db, {
|
|
2440
2570
|
assistantID: row.assistant_id, sessionID: assigned.sessionID,
|
|
2441
2571
|
directory: assigned.directory, status: assigned.status || 'busy',
|
|
2442
|
-
updatedAt: now(), messageID: assigned.messageID,
|
|
2572
|
+
updatedAt: now(), messageID: assigned.messageID, ...targetFields(),
|
|
2443
2573
|
});
|
|
2444
2574
|
bump();
|
|
2445
2575
|
}).immediate();
|
|
2446
2576
|
} catch {
|
|
2447
|
-
return { ...assigned, watchError: 'watch_registration_failed' };
|
|
2577
|
+
return { ...assigned, ...targetFields(), watchError: 'watch_registration_failed' };
|
|
2448
2578
|
}
|
|
2449
|
-
|
|
2579
|
+
if (execution.current()) {
|
|
2580
|
+
try { await retainRemoteWatch({ sessionID: assigned.sessionID, directory: assigned.directory, ...targetFields() }); }
|
|
2581
|
+
catch { return { ...assigned, ...targetFields(), watchError: 'watch_connection_pending_recovery' }; }
|
|
2582
|
+
}
|
|
2583
|
+
else void assignedCompletion.observe({ kind: 'running', sessionId: assigned.sessionID });
|
|
2450
2584
|
}
|
|
2451
|
-
return assigned;
|
|
2452
|
-
};
|
|
2585
|
+
return { ...assigned, ...targetFields() };
|
|
2586
|
+
});
|
|
2453
2587
|
/** Watch an existing session only — no prompt. Baseline status avoids false settle resume. */
|
|
2454
|
-
const watchSessionWork = async (row, params = {}) => {
|
|
2588
|
+
const watchSessionWork = async (row, params = {}) => scopedWork(params, async () => {
|
|
2455
2589
|
const sessionID = typeof params.sessionID === 'string' ? params.sessionID.trim() : '';
|
|
2456
2590
|
if (!sessionID) {
|
|
2457
2591
|
throw new AssignError(ASSIGN_CODES.VALIDATION, 'watch_session requires sessionID.');
|
|
@@ -2477,11 +2611,18 @@ export const createAssistantsService = ({ dbPath, dataDir, buildOpenCodeUrl, get
|
|
|
2477
2611
|
db.transaction(() => {
|
|
2478
2612
|
upsertContactWatch(db, {
|
|
2479
2613
|
assistantID: row.assistant_id, sessionID: resolved.sessionID,
|
|
2480
|
-
directory: resolved.directory, status, updatedAt: now(), messageID: null,
|
|
2614
|
+
directory: resolved.directory, status, updatedAt: now(), messageID: null, ...targetFields(),
|
|
2481
2615
|
});
|
|
2482
2616
|
bump();
|
|
2483
2617
|
}).immediate();
|
|
2618
|
+
let watchError;
|
|
2619
|
+
if (execution.current()) {
|
|
2620
|
+
try { await retainRemoteWatch({ sessionID, directory: resolved.directory, ...targetFields() }); }
|
|
2621
|
+
catch { watchError = 'watch_connection_pending_recovery'; }
|
|
2622
|
+
}
|
|
2484
2623
|
return {
|
|
2624
|
+
...targetFields(),
|
|
2625
|
+
...(watchError ? { watchError } : {}),
|
|
2485
2626
|
sessionID: resolved.sessionID,
|
|
2486
2627
|
directory: resolved.directory,
|
|
2487
2628
|
title: resolved.title,
|
|
@@ -2489,9 +2630,9 @@ export const createAssistantsService = ({ dbPath, dataDir, buildOpenCodeUrl, get
|
|
|
2489
2630
|
watched: true,
|
|
2490
2631
|
reused: true,
|
|
2491
2632
|
};
|
|
2492
|
-
};
|
|
2633
|
+
});
|
|
2493
2634
|
/** Abort an existing coding session via real OpenCode session.interrupt. */
|
|
2494
|
-
const stopSessionWork = async (_row, params = {}) => {
|
|
2635
|
+
const stopSessionWork = async (_row, params = {}) => scopedWork(params, async () => {
|
|
2495
2636
|
const sessionID = typeof params.sessionID === 'string' ? params.sessionID.trim() : '';
|
|
2496
2637
|
if (!sessionID) {
|
|
2497
2638
|
throw new AssignError(ASSIGN_CODES.VALIDATION, 'stop_session requires sessionID.');
|
|
@@ -2508,14 +2649,14 @@ export const createAssistantsService = ({ dbPath, dataDir, buildOpenCodeUrl, get
|
|
|
2508
2649
|
if (typeof client().session.interrupt !== 'function') {
|
|
2509
2650
|
throw new AssignError(ASSIGN_CODES.UPSTREAM, 'Session interrupt is unavailable.');
|
|
2510
2651
|
}
|
|
2511
|
-
const targetID = resolved.sessionID;
|
|
2652
|
+
const targetID = executionSessionKey(resolved.sessionID, execution.current()?.target);
|
|
2512
2653
|
// Share one abort lifecycle per worker session (register before await abort).
|
|
2513
2654
|
const existing = sessionAbortInflight.get(targetID);
|
|
2514
2655
|
if (existing?.promise) {
|
|
2515
2656
|
const shared = await existing.promise;
|
|
2516
2657
|
if (shared?.ok) {
|
|
2517
2658
|
return {
|
|
2518
|
-
sessionID:
|
|
2659
|
+
sessionID: resolved.sessionID, ...targetFields(),
|
|
2519
2660
|
directory: resolved.directory,
|
|
2520
2661
|
title: resolved.title,
|
|
2521
2662
|
aborted: true,
|
|
@@ -2535,12 +2676,12 @@ export const createAssistantsService = ({ dbPath, dataDir, buildOpenCodeUrl, get
|
|
|
2535
2676
|
try {
|
|
2536
2677
|
signal?.throwIfAborted();
|
|
2537
2678
|
result = await invokeSession(() => client().session.interrupt({
|
|
2538
|
-
|
|
2539
|
-
|
|
2679
|
+
sessionID: resolved.sessionID,
|
|
2680
|
+
}, sdkOptions));
|
|
2540
2681
|
} catch (error) {
|
|
2541
2682
|
const observed = entry.observed;
|
|
2542
2683
|
if (sessionAbortInflight.get(targetID) === entry) sessionAbortInflight.delete(targetID);
|
|
2543
|
-
if (observed) reportAssignedSession(
|
|
2684
|
+
if (observed) reportAssignedSession(resolved.sessionID, observed.status, { resume: observed.resume !== false, ...targetFields() });
|
|
2544
2685
|
const wrapped = error?.name === 'AbortError' || signal?.aborted
|
|
2545
2686
|
? error
|
|
2546
2687
|
: failAbort(
|
|
@@ -2552,13 +2693,13 @@ export const createAssistantsService = ({ dbPath, dataDir, buildOpenCodeUrl, get
|
|
|
2552
2693
|
if (isMissing(result)) {
|
|
2553
2694
|
const observed = entry.observed;
|
|
2554
2695
|
if (sessionAbortInflight.get(targetID) === entry) sessionAbortInflight.delete(targetID);
|
|
2555
|
-
if (observed) reportAssignedSession(
|
|
2696
|
+
if (observed) reportAssignedSession(resolved.sessionID, observed.status, { resume: observed.resume !== false, ...targetFields() });
|
|
2556
2697
|
return { ok: false, error: failAbort(ASSIGN_CODES.NOT_FOUND, `No coding session ${targetID} was found.`) };
|
|
2557
2698
|
}
|
|
2558
2699
|
if (result?.error || result?.data === false) {
|
|
2559
2700
|
const observed = entry.observed;
|
|
2560
2701
|
if (sessionAbortInflight.get(targetID) === entry) sessionAbortInflight.delete(targetID);
|
|
2561
|
-
if (observed) reportAssignedSession(
|
|
2702
|
+
if (observed) reportAssignedSession(resolved.sessionID, observed.status, { resume: observed.resume !== false, ...targetFields() });
|
|
2562
2703
|
return {
|
|
2563
2704
|
ok: false,
|
|
2564
2705
|
error: failAbort(
|
|
@@ -2569,16 +2710,16 @@ export const createAssistantsService = ({ dbPath, dataDir, buildOpenCodeUrl, get
|
|
|
2569
2710
|
}
|
|
2570
2711
|
// Success (including silent abort with no SSE): release map first so reporter applies.
|
|
2571
2712
|
if (sessionAbortInflight.get(targetID) === entry) sessionAbortInflight.delete(targetID);
|
|
2572
|
-
cancelAssignedResumes({ sessionID:
|
|
2713
|
+
cancelAssignedResumes({ sessionID: resolved.sessionID, ...targetFields() });
|
|
2573
2714
|
// Assistant already owns this user turn; do not schedule a second cancelled notify.
|
|
2574
|
-
reportAssignedSession(
|
|
2715
|
+
reportAssignedSession(resolved.sessionID, 'cancelled', { resume: false, ...targetFields() });
|
|
2575
2716
|
return { ok: true };
|
|
2576
2717
|
})();
|
|
2577
2718
|
try {
|
|
2578
2719
|
const outcome = await entry.promise;
|
|
2579
2720
|
if (outcome?.ok) {
|
|
2580
2721
|
return {
|
|
2581
|
-
sessionID:
|
|
2722
|
+
sessionID: resolved.sessionID, ...targetFields(),
|
|
2582
2723
|
directory: resolved.directory,
|
|
2583
2724
|
title: resolved.title,
|
|
2584
2725
|
aborted: true,
|
|
@@ -2588,9 +2729,9 @@ export const createAssistantsService = ({ dbPath, dataDir, buildOpenCodeUrl, get
|
|
|
2588
2729
|
} finally {
|
|
2589
2730
|
if (sessionAbortInflight.get(targetID) === entry) sessionAbortInflight.delete(targetID);
|
|
2590
2731
|
}
|
|
2591
|
-
};
|
|
2732
|
+
});
|
|
2592
2733
|
// Resolve scope from the authoritative session, never model-supplied directories.
|
|
2593
|
-
const mutateSessionWork = async (operation, params = {}) => {
|
|
2734
|
+
const mutateSessionWork = async (operation, params = {}) => scopedWork(params, async () => {
|
|
2594
2735
|
const sessionID = typeof params.sessionID === 'string' ? params.sessionID.trim() : '';
|
|
2595
2736
|
if (!sessionID) throw new AssignError(ASSIGN_CODES.VALIDATION, `${operation} requires sessionID.`);
|
|
2596
2737
|
if (operation === 'steer' && (typeof params.text !== 'string' || !params.text.trim())) {
|
|
@@ -2604,20 +2745,22 @@ export const createAssistantsService = ({ dbPath, dataDir, buildOpenCodeUrl, get
|
|
|
2604
2745
|
if (operation === 'steer') {
|
|
2605
2746
|
const messageID = `msg_steer_${id()}`;
|
|
2606
2747
|
const parts = [{ type: 'text', text: params.text.trim() }];
|
|
2607
|
-
result = await invokeSession(() => api.session.prompt(toV2PromptInput(sessionID, parts, messageID)));
|
|
2748
|
+
result = await invokeSession(() => api.session.prompt(toV2PromptInput(sessionID, parts, messageID), params.signal ? { signal: params.signal } : undefined));
|
|
2608
2749
|
if (isMissing(result)) throw new AssignError(ASSIGN_CODES.NOT_FOUND, `No coding session ${sessionID} was found.`);
|
|
2609
2750
|
if (result?.error || !promptAdmitted(result)) {
|
|
2610
2751
|
throw new AssignError(ASSIGN_CODES.UPSTREAM, `Session ${operation} was not confirmed. Do not resend automatically.`);
|
|
2611
2752
|
}
|
|
2612
|
-
return { sessionID, directory: resolved.directory, operation, messageID, admitted: true };
|
|
2753
|
+
return { ...targetFields(), sessionID, directory: resolved.directory, operation, messageID, admitted: true };
|
|
2613
2754
|
}
|
|
2614
2755
|
if (operation === 'archive') {
|
|
2615
2756
|
// OC2: Host owns archive stamps (yuri.archive.archivedAt). Do not
|
|
2616
2757
|
// call upstream session.update time.archived — it is unavailable.
|
|
2617
|
-
if (typeof archiveSessionHost !== 'function') {
|
|
2758
|
+
if (!execution.current() && typeof archiveSessionHost !== 'function') {
|
|
2618
2759
|
throw new AssignError(ASSIGN_CODES.UPSTREAM, 'Session archive is unavailable.');
|
|
2619
2760
|
}
|
|
2620
|
-
result = await
|
|
2761
|
+
result = execution.current() ? await execution.current().json(`/api/yuri/sessions/${encodeURIComponent(sessionID)}/archive`, {
|
|
2762
|
+
method: 'PUT', headers: { 'content-type': 'application/json' }, body: JSON.stringify({ directory: resolved.directory, archivedAt: now() }), signal: params.signal,
|
|
2763
|
+
}) : await archiveSessionHost({
|
|
2621
2764
|
sessionID,
|
|
2622
2765
|
directory: resolved.directory,
|
|
2623
2766
|
archivedAt: now(),
|
|
@@ -2626,7 +2769,7 @@ export const createAssistantsService = ({ dbPath, dataDir, buildOpenCodeUrl, get
|
|
|
2626
2769
|
if (typeof api.session.remove !== 'function') {
|
|
2627
2770
|
throw new AssignError(ASSIGN_CODES.UPSTREAM, 'Session delete is unavailable.');
|
|
2628
2771
|
}
|
|
2629
|
-
result = await invokeSession(() => api.session.remove({ sessionID }));
|
|
2772
|
+
result = await invokeSession(() => api.session.remove({ sessionID }, params.signal ? { signal: params.signal } : undefined));
|
|
2630
2773
|
} else {
|
|
2631
2774
|
throw new AssignError(ASSIGN_CODES.VALIDATION, `Unknown session operation ${operation}.`);
|
|
2632
2775
|
}
|
|
@@ -2638,8 +2781,8 @@ export const createAssistantsService = ({ dbPath, dataDir, buildOpenCodeUrl, get
|
|
|
2638
2781
|
if (!result?.session?.id) {
|
|
2639
2782
|
throw new AssignError(ASSIGN_CODES.UPSTREAM, `Session ${operation} was not confirmed. Do not resend automatically.`);
|
|
2640
2783
|
}
|
|
2641
|
-
reportAssignedSession(sessionID, 'cancelled', false);
|
|
2642
|
-
return { sessionID, directory: resolved.directory, operation, archived: true };
|
|
2784
|
+
reportAssignedSession(sessionID, 'cancelled', { resume: false, ...targetFields() });
|
|
2785
|
+
return { ...targetFields(), sessionID, directory: resolved.directory, operation, archived: true };
|
|
2643
2786
|
}
|
|
2644
2787
|
if (isMissing(result)) throw new AssignError(ASSIGN_CODES.NOT_FOUND, `No coding session ${sessionID} was found.`);
|
|
2645
2788
|
if (result?.error || result?.data === false) {
|
|
@@ -2647,7 +2790,7 @@ export const createAssistantsService = ({ dbPath, dataDir, buildOpenCodeUrl, get
|
|
|
2647
2790
|
}
|
|
2648
2791
|
// Successful delete: direct idempotent Host metadata cleanup; session.deleted
|
|
2649
2792
|
// events remain compensatory. Upstream failure never reaches here.
|
|
2650
|
-
if (typeof forgetSessionHost === 'function') {
|
|
2793
|
+
if (!execution.current() && typeof forgetSessionHost === 'function') {
|
|
2651
2794
|
try {
|
|
2652
2795
|
const cleanup = forgetSessionHost(sessionID);
|
|
2653
2796
|
if (cleanup && typeof cleanup.catch === 'function') {
|
|
@@ -2659,9 +2802,9 @@ export const createAssistantsService = ({ dbPath, dataDir, buildOpenCodeUrl, get
|
|
|
2659
2802
|
console.warn('[assistants] metadata cleanup after delete failed (retry via event):', error?.message ?? error);
|
|
2660
2803
|
}
|
|
2661
2804
|
}
|
|
2662
|
-
reportAssignedSession(sessionID, 'cancelled', false);
|
|
2663
|
-
return { sessionID, directory: resolved.directory, operation, deleted: true };
|
|
2664
|
-
};
|
|
2805
|
+
reportAssignedSession(sessionID, 'cancelled', { resume: false, ...targetFields() });
|
|
2806
|
+
return { ...targetFields(), sessionID, directory: resolved.directory, operation, deleted: true };
|
|
2807
|
+
});
|
|
2665
2808
|
const matchRegisteredProject = async (directory) => {
|
|
2666
2809
|
const projects = await listProjects();
|
|
2667
2810
|
const resolved = path.resolve(directory);
|
|
@@ -2772,7 +2915,7 @@ export const createAssistantsService = ({ dbPath, dataDir, buildOpenCodeUrl, get
|
|
|
2772
2915
|
}
|
|
2773
2916
|
return { tasks, ...(failed.length > 0 ? { partial: true, failed } : {}) };
|
|
2774
2917
|
};
|
|
2775
|
-
const resolveContactResource = async (input, signal) => {
|
|
2918
|
+
const resolveContactResource = async (input, signal) => scopedWork({ ...input, signal }, async () => {
|
|
2776
2919
|
signal?.throwIfAborted();
|
|
2777
2920
|
if (input.cardType === 'session') {
|
|
2778
2921
|
const resolved = await resolveReferencedSession({ sessionID: input.sessionID, signal, includeMessages: false });
|
|
@@ -2798,7 +2941,7 @@ export const createAssistantsService = ({ dbPath, dataDir, buildOpenCodeUrl, get
|
|
|
2798
2941
|
cron: task.schedule?.cron ?? null, date: task.schedule?.date ?? null,
|
|
2799
2942
|
times: task.schedule?.times ?? null, weekdays: task.schedule?.weekdays ?? null,
|
|
2800
2943
|
});
|
|
2801
|
-
};
|
|
2944
|
+
});
|
|
2802
2945
|
const updateScheduledTaskWork = async (row, params, signal) => {
|
|
2803
2946
|
signal?.throwIfAborted();
|
|
2804
2947
|
if (typeof patchScheduledTask !== 'function') throw new AssignError(ASSIGN_CODES.UPSTREAM, 'Updating a scheduled task is unavailable.');
|
|
@@ -2834,13 +2977,13 @@ export const createAssistantsService = ({ dbPath, dataDir, buildOpenCodeUrl, get
|
|
|
2834
2977
|
}
|
|
2835
2978
|
return { task: patched.task, projectID: params.projectID };
|
|
2836
2979
|
};
|
|
2837
|
-
const listSessionsFromIndex = (params = {}) => {
|
|
2838
|
-
if (!sessionIndexService || typeof sessionIndexService.snapshot !== 'function') {
|
|
2980
|
+
const listSessionsFromIndex = (params = {}, remoteSnapshot = null) => {
|
|
2981
|
+
if (!remoteSnapshot && (!sessionIndexService || typeof sessionIndexService.snapshot !== 'function')) {
|
|
2839
2982
|
throw new AssignError(ASSIGN_CODES.UPSTREAM, 'Session index is unavailable.');
|
|
2840
2983
|
}
|
|
2841
2984
|
let snapshot;
|
|
2842
2985
|
try {
|
|
2843
|
-
snapshot = sessionIndexService.snapshot();
|
|
2986
|
+
snapshot = remoteSnapshot || sessionIndexService.snapshot();
|
|
2844
2987
|
} catch (error) {
|
|
2845
2988
|
throw new AssignError(
|
|
2846
2989
|
ASSIGN_CODES.UPSTREAM,
|
|
@@ -2867,7 +3010,7 @@ export const createAssistantsService = ({ dbPath, dataDir, buildOpenCodeUrl, get
|
|
|
2867
3010
|
for (const directory of snapshot.directories) {
|
|
2868
3011
|
const dir = typeof directory?.directory === 'string' ? directory.directory : '';
|
|
2869
3012
|
if (!dir) continue;
|
|
2870
|
-
if (scopeRoots.length > 0 && !scopeRoots.some((root) => directoryContained(dir, root))) continue;
|
|
3013
|
+
if (scopeRoots.length > 0 && !scopeRoots.some((root) => (execution.current() ? remoteDirectoryContained : directoryContained)(dir, root))) continue;
|
|
2871
3014
|
for (const session of Array.isArray(directory.sessions) ? directory.sessions : []) {
|
|
2872
3015
|
if (!session || typeof session.id !== 'string' || !session.id) continue;
|
|
2873
3016
|
const title = typeof session.title === 'string' ? session.title : '';
|
|
@@ -2875,6 +3018,7 @@ export const createAssistantsService = ({ dbPath, dataDir, buildOpenCodeUrl, get
|
|
|
2875
3018
|
? session.time.updated
|
|
2876
3019
|
: (typeof session.updatedAt === 'number' ? session.updatedAt : 0);
|
|
2877
3020
|
const row = {
|
|
3021
|
+
...targetFields(),
|
|
2878
3022
|
sessionID: session.id,
|
|
2879
3023
|
title,
|
|
2880
3024
|
directory: dir,
|
|
@@ -2893,7 +3037,43 @@ export const createAssistantsService = ({ dbPath, dataDir, buildOpenCodeUrl, get
|
|
|
2893
3037
|
...(projectID ? { projectID } : {}),
|
|
2894
3038
|
};
|
|
2895
3039
|
};
|
|
2896
|
-
const listSessionsWork = async (params = {}) => {
|
|
3040
|
+
const listSessionsWork = async (params = {}) => scopedWork(params, async () => {
|
|
3041
|
+
if (execution.current()) {
|
|
3042
|
+
const projects = await execution.current().projects();
|
|
3043
|
+
const project = params.projectID ? projects.find((item) => item.id === params.projectID) : null;
|
|
3044
|
+
if (params.projectID && !project) throw new AssignError('project_required', 'Remote project not found.');
|
|
3045
|
+
const roots = project ? [project.path] : params.projectPath
|
|
3046
|
+
? [await execution.current().resolveDirectory({ directory: params.projectPath })] : projects.map((item) => item.path);
|
|
3047
|
+
if (roots.length === 0) return { sessions: [], truncated: false, source: 'session-index', ...targetFields() };
|
|
3048
|
+
const linkedRoots = roots.slice();
|
|
3049
|
+
if (!params.before) for (const root of roots) linkedRoots.push(...(await execution.current().worktrees(root)).map((tree) => tree.path));
|
|
3050
|
+
if (params.before !== undefined && (typeof params.before !== 'string' || !params.before || !params.projectPath || params.before.length > 2048)) throw new AssignError('validation_error', 'Remote pagination requires the exact nextPages projectPath and before cursor.');
|
|
3051
|
+
const limit = boundSessionListLimit(params.limit);
|
|
3052
|
+
const directories = [], failed = [], nextPages = [], seen = new Set();
|
|
3053
|
+
for (const directory of new Set(linkedRoots)) {
|
|
3054
|
+
try {
|
|
3055
|
+
const response = await client().session.list({ directory, limit,
|
|
3056
|
+
...(params.before ? { cursor: params.before } : { order: 'desc' }),
|
|
3057
|
+
}, params.signal ? { signal: params.signal } : undefined);
|
|
3058
|
+
if (!Array.isArray(response?.data)) throw new Error('Invalid remote sessions');
|
|
3059
|
+
const sessions = response.data;
|
|
3060
|
+
if (sessions.some((session) => !nonEmptyString(session?.id) || !extractSessionDirectory(session))) throw new Error('Invalid remote session identity');
|
|
3061
|
+
for (const session of sessions) {
|
|
3062
|
+
const actualDirectory = extractSessionDirectory(session);
|
|
3063
|
+
if (!remoteDirectoryContained(actualDirectory, directory)) continue;
|
|
3064
|
+
const key = JSON.stringify([session.id, actualDirectory]);
|
|
3065
|
+
if (seen.has(key)) continue;
|
|
3066
|
+
seen.add(key);
|
|
3067
|
+
directories.push({ directory: actualDirectory, sessions: [session] });
|
|
3068
|
+
}
|
|
3069
|
+
const cursor = projectionCursor(response);
|
|
3070
|
+
if (sessions.length >= limit && cursor) nextPages.push({ projectPath: directory, before: cursor, ...targetFields() });
|
|
3071
|
+
} catch { params.signal?.throwIfAborted(); failed.push({ directory, error: 'remote_sessions_unavailable', ...targetFields() }); }
|
|
3072
|
+
}
|
|
3073
|
+
if (failed.length && !directories.length) throw new AssignError('upstream_error', 'Remote sessions are unavailable, not an empty result.');
|
|
3074
|
+
const result = listSessionsFromIndex({ ...params, projectRoots: linkedRoots }, { directories });
|
|
3075
|
+
return { ...result, source: 'opencode', ...targetFields(), ...(failed.length || nextPages.length ? { partial: true, failed, nextPages } : {}) };
|
|
3076
|
+
}
|
|
2897
3077
|
const projectPath = typeof params.projectPath === 'string' ? params.projectPath.trim() : '';
|
|
2898
3078
|
const projectID = typeof params.projectID === 'string' ? params.projectID.trim() : '';
|
|
2899
3079
|
let projectRoots = [];
|
|
@@ -2931,7 +3111,7 @@ export const createAssistantsService = ({ dbPath, dataDir, buildOpenCodeUrl, get
|
|
|
2931
3111
|
projectRoots,
|
|
2932
3112
|
projectID: projectID || undefined,
|
|
2933
3113
|
});
|
|
2934
|
-
};
|
|
3114
|
+
});
|
|
2935
3115
|
const listAssistantScheduledTasks = async (assistantID) => {
|
|
2936
3116
|
editable(assistantID);
|
|
2937
3117
|
const mappings = db.prepare(
|
|
@@ -2978,17 +3158,20 @@ export const createAssistantsService = ({ dbPath, dataDir, buildOpenCodeUrl, get
|
|
|
2978
3158
|
}),
|
|
2979
3159
|
};
|
|
2980
3160
|
};
|
|
2981
|
-
const findAssignedSessionCard = (assistantID, sessionID) => {
|
|
3161
|
+
const findAssignedSessionCard = (assistantID, sessionID, target) => {
|
|
2982
3162
|
const row = db.prepare(`
|
|
2983
3163
|
SELECT p.part_json FROM assistant_contact_part p
|
|
2984
3164
|
JOIN assistant_contact_message m ON m.message_id=p.message_id
|
|
2985
3165
|
WHERE m.assistant_id=? AND json_extract(p.part_json, '$.cardType')='session'
|
|
2986
3166
|
AND json_extract(p.part_json, '$.sessionID')=?
|
|
3167
|
+
AND COALESCE(json_extract(p.part_json, '$.target.hubId'), '')=?
|
|
3168
|
+
AND COALESCE(json_extract(p.part_json, '$.target.hostId'), '')=?
|
|
3169
|
+
AND COALESCE(json_extract(p.part_json, '$.target.instanceId'), '')=?
|
|
2987
3170
|
ORDER BY m.ordinal DESC LIMIT 1
|
|
2988
|
-
`).get(assistantID, sessionID);
|
|
3171
|
+
`).get(assistantID, sessionID, target?.hubId || '', target?.hostId || '', target?.instanceId || '');
|
|
2989
3172
|
return row ? parseContactPart(parse(row.part_json)) : null;
|
|
2990
3173
|
};
|
|
2991
|
-
const findAssignedSessionCardTitle = (assistantID, sessionID) => findAssignedSessionCard(assistantID, sessionID)?.title ?? null;
|
|
3174
|
+
const findAssignedSessionCardTitle = (assistantID, sessionID, target) => findAssignedSessionCard(assistantID, sessionID, target)?.title ?? null;
|
|
2992
3175
|
const extractLastWorkerAssistantText = (messages, maxChars = ASSIGNED_SESSION_RESUME_WORKER_TEXT_MAX) => {
|
|
2993
3176
|
if (!Array.isArray(messages)) return '';
|
|
2994
3177
|
const limit = Number.isFinite(maxChars) && maxChars > 0 ? Math.floor(maxChars) : ASSIGNED_SESSION_RESUME_WORKER_TEXT_MAX;
|
|
@@ -3014,10 +3197,11 @@ export const createAssistantsService = ({ dbPath, dataDir, buildOpenCodeUrl, get
|
|
|
3014
3197
|
}
|
|
3015
3198
|
return '';
|
|
3016
3199
|
};
|
|
3017
|
-
const buildAssignedSessionResumeUserText = ({ sessionID, status, title, workerText }) => {
|
|
3200
|
+
const buildAssignedSessionResumeUserText = ({ sessionID, status, title, workerText, target }) => {
|
|
3018
3201
|
const lines = [
|
|
3019
3202
|
'[Internal assigned-session resume — not a user message. Do not quote this block.]',
|
|
3020
3203
|
`sessionID: ${sessionID}`,
|
|
3204
|
+
...(target ? [`target: ${JSON.stringify(target)}`] : []),
|
|
3021
3205
|
`status: ${status}`,
|
|
3022
3206
|
'watchState: released',
|
|
3023
3207
|
'watchMode: one_shot',
|
|
@@ -3060,24 +3244,29 @@ export const createAssistantsService = ({ dbPath, dataDir, buildOpenCodeUrl, get
|
|
|
3060
3244
|
* After assigned worker complete/error/cancelled: async contact-lane continuation.
|
|
3061
3245
|
* No user transcript row — only internal runContactTurn userText + assistant bubbles/cards.
|
|
3062
3246
|
*/
|
|
3063
|
-
const scheduleAssignedSessionResume = ({ assistantID, sessionID, status, directory, updatedAt, scheduledRun = null }) => {
|
|
3247
|
+
const scheduleAssignedSessionResume = ({ assistantID, sessionID, status, directory, updatedAt, target, scheduledRun = null }) => {
|
|
3064
3248
|
if (closed) return;
|
|
3065
3249
|
if (!assignedSessionResumeStatus(status)) return;
|
|
3066
3250
|
const row = assistant(assistantID);
|
|
3067
3251
|
if (!row || row.tombstone_at) return;
|
|
3068
|
-
const messageID = scheduledRun ? `scheduled_${assistantID}_${scheduledRun.id}` : assignedSessionResumeMessageID(assistantID, sessionID, status, updatedAt);
|
|
3252
|
+
const messageID = scheduledRun ? `scheduled_${assistantID}_${scheduledRun.id}` : assignedSessionResumeMessageID(assistantID, resumeWorkerIdentity(sessionID, target), status, updatedAt);
|
|
3069
3253
|
const capturedAssistant = scheduledRun ? output(row) : null;
|
|
3070
3254
|
const turnID = messageID;
|
|
3255
|
+
const acknowledgeRemoteResult = () => {
|
|
3256
|
+
if (target && !closed) db.prepare('UPDATE assistant_contact_watch SET remote_resume_pending=0 WHERE assistant_id=? AND session_id=? AND updated_at=?')
|
|
3257
|
+
.run(assistantID, executionSessionKey(sessionID, target), updatedAt);
|
|
3258
|
+
};
|
|
3071
3259
|
// Idempotent: same watch status already resumed with published output.
|
|
3072
3260
|
if (
|
|
3073
3261
|
getContactMessage(db, `${messageID}:bubble:1`)
|
|
3074
|
-
|| getContactMessage(db, `${messageID}:error`)
|
|
3075
|
-
) return;
|
|
3262
|
+
|| (!target && getContactMessage(db, `${messageID}:error`))
|
|
3263
|
+
) { acknowledgeRemoteResult(); return; }
|
|
3076
3264
|
|
|
3077
3265
|
if (assignedResumes.has(messageID)) return;
|
|
3078
3266
|
const controller = new AbortController();
|
|
3079
|
-
assignedResumes.set(messageID, { assistantID, sessionID, status, controller });
|
|
3267
|
+
assignedResumes.set(messageID, { assistantID, sessionID, status, controller, ...(target ? { target } : {}) });
|
|
3080
3268
|
const finishCancelled = () => {
|
|
3269
|
+
acknowledgeRemoteResult();
|
|
3081
3270
|
if (!closed) {
|
|
3082
3271
|
settleActiveContactTurn(assistantID, turnID, { bumpRevision: true });
|
|
3083
3272
|
emitContactTurnEvent('yuri:contact-turn-end', { assistantID, turnID, status: 'cancelled' });
|
|
@@ -3115,8 +3304,9 @@ export const createAssistantsService = ({ dbPath, dataDir, buildOpenCodeUrl, get
|
|
|
3115
3304
|
}
|
|
3116
3305
|
if (
|
|
3117
3306
|
getContactMessage(db, `${messageID}:bubble:1`)
|
|
3118
|
-
|| getContactMessage(db, `${messageID}:error`)
|
|
3307
|
+
|| (!target && getContactMessage(db, `${messageID}:error`))
|
|
3119
3308
|
) {
|
|
3309
|
+
acknowledgeRemoteResult();
|
|
3120
3310
|
settleActiveContactTurn(assistantID, turnID, { bumpRevision: true });
|
|
3121
3311
|
resolveContactTurnSettlement(messageID, { status: 'complete', replayed: true });
|
|
3122
3312
|
return;
|
|
@@ -3132,7 +3322,7 @@ export const createAssistantsService = ({ dbPath, dataDir, buildOpenCodeUrl, get
|
|
|
3132
3322
|
|
|
3133
3323
|
let workerText = '';
|
|
3134
3324
|
try {
|
|
3135
|
-
const watchDirectory = nonEmptyString(directory)
|
|
3325
|
+
const watchDirectory = target ? directory : nonEmptyString(directory)
|
|
3136
3326
|
? (() => {
|
|
3137
3327
|
try { return workspace(directory, assistantID); } catch { return null; }
|
|
3138
3328
|
})()
|
|
@@ -3141,11 +3331,9 @@ export const createAssistantsService = ({ dbPath, dataDir, buildOpenCodeUrl, get
|
|
|
3141
3331
|
try { return effectiveWorkspace(live); } catch { return null; }
|
|
3142
3332
|
})();
|
|
3143
3333
|
if (resolvedDirectory && sessionID) {
|
|
3144
|
-
const messagesResult = await invokeSession(() => client().message.list({
|
|
3145
|
-
sessionID,
|
|
3146
|
-
|
|
3147
|
-
order: 'desc',
|
|
3148
|
-
}));
|
|
3334
|
+
const messagesResult = await scopedWork({ target, signal: controller.signal }, () => invokeSession(() => client().message.list({
|
|
3335
|
+
sessionID, limit: 100, order: 'desc',
|
|
3336
|
+
}, { signal: controller.signal })));
|
|
3149
3337
|
if (!messagesResult?.error) {
|
|
3150
3338
|
const rows = Array.isArray(messagesResult?.data)
|
|
3151
3339
|
? messagesResult.data
|
|
@@ -3153,7 +3341,7 @@ export const createAssistantsService = ({ dbPath, dataDir, buildOpenCodeUrl, get
|
|
|
3153
3341
|
// complete/error that discovers a user abort becomes cancelled + notify.
|
|
3154
3342
|
// A cancelled resume must still run with reason: user_interrupted.
|
|
3155
3343
|
if (!scheduledRun && status !== 'cancelled' && isUserAbort(lastAssistantInfo(rows)?.error)) {
|
|
3156
|
-
reportAssignedSession(sessionID, 'cancelled');
|
|
3344
|
+
reportAssignedSession(sessionID, 'cancelled', { ...(target ? { target } : {}) });
|
|
3157
3345
|
finishCancelled();
|
|
3158
3346
|
return;
|
|
3159
3347
|
}
|
|
@@ -3161,11 +3349,12 @@ export const createAssistantsService = ({ dbPath, dataDir, buildOpenCodeUrl, get
|
|
|
3161
3349
|
}
|
|
3162
3350
|
}
|
|
3163
3351
|
} catch {
|
|
3352
|
+
if (target) throw new AssignError('upstream_error', 'Remote worker result is unavailable; the durable result review will retry.');
|
|
3164
3353
|
workerText = '';
|
|
3165
3354
|
}
|
|
3166
3355
|
|
|
3167
3356
|
if (controller.signal.aborted) { finishCancelled(); return; }
|
|
3168
|
-
|
|
3357
|
+
const title = scheduledRun?.taskName || findAssignedSessionCardTitle(assistantID, sessionID, target);
|
|
3169
3358
|
const userText = scheduledRun ? [
|
|
3170
3359
|
'[Internal scheduled-task result review — not a user message.]',
|
|
3171
3360
|
`runID: ${scheduledRun.id}`,
|
|
@@ -3182,6 +3371,7 @@ export const createAssistantsService = ({ dbPath, dataDir, buildOpenCodeUrl, get
|
|
|
3182
3371
|
status,
|
|
3183
3372
|
title,
|
|
3184
3373
|
workerText,
|
|
3374
|
+
target,
|
|
3185
3375
|
});
|
|
3186
3376
|
const history = contactHistoryForLlm(db, assistantID, {});
|
|
3187
3377
|
const assignedCards = [];
|
|
@@ -3204,12 +3394,12 @@ export const createAssistantsService = ({ dbPath, dataDir, buildOpenCodeUrl, get
|
|
|
3204
3394
|
const memory = createContactMemoryReader(db, assistantID, { assertAvailable: () => editable(assistantID) });
|
|
3205
3395
|
const tools = createContactTools({
|
|
3206
3396
|
searchMemory: memory.search,
|
|
3207
|
-
listModels: () => loadContactModelContext(controller.signal),
|
|
3397
|
+
listModels: (params) => loadContactModelContext(params?.signal || controller.signal, params),
|
|
3208
3398
|
readMemory: memory.read,
|
|
3209
3399
|
assignWork: (params) => assignWork(live, params),
|
|
3210
3400
|
watchSession: (params) => {
|
|
3211
3401
|
controller.signal.throwIfAborted();
|
|
3212
|
-
if (scheduledRun || status === 'cancelled' || params?.sessionID !== sessionID) {
|
|
3402
|
+
if (scheduledRun || status === 'cancelled' || params?.sessionID !== sessionID || executionTargetKey(params?.target) !== executionTargetKey(target)) {
|
|
3213
3403
|
throw new AssignError(ASSIGN_CODES.VALIDATION, 'A result review may only rewatch its own non-interrupted worker.');
|
|
3214
3404
|
}
|
|
3215
3405
|
return watchSessionWork(live, params);
|
|
@@ -3234,9 +3424,12 @@ export const createAssistantsService = ({ dbPath, dataDir, buildOpenCodeUrl, get
|
|
|
3234
3424
|
return result;
|
|
3235
3425
|
},
|
|
3236
3426
|
listAssistants: () => db.prepare('SELECT * FROM assistant_v2 WHERE tombstone_at IS NULL ORDER BY created_at').all().map(output),
|
|
3237
|
-
listProjects: async () => loadRegisteredProjects(),
|
|
3427
|
+
listProjects: async (params) => loadRegisteredProjects(params),
|
|
3238
3428
|
listSessions: (params) => listSessionsWork(params),
|
|
3239
|
-
readSession: (params) =>
|
|
3429
|
+
readSession: (params) => {
|
|
3430
|
+
if (target && executionTargetKey(params?.target) !== executionTargetKey(target)) throw new AssignError('validation_error', 'Read this worker with its exact remote target.');
|
|
3431
|
+
return readSessionWork(params);
|
|
3432
|
+
},
|
|
3240
3433
|
readAssistantSettings: (input = {}) => {
|
|
3241
3434
|
const targetID = typeof input?.assistantID === 'string' && input.assistantID.trim()
|
|
3242
3435
|
? input.assistantID.trim()
|
|
@@ -3289,6 +3482,7 @@ export const createAssistantsService = ({ dbPath, dataDir, buildOpenCodeUrl, get
|
|
|
3289
3482
|
if (!current || current.tombstone_at) { finishCancelled(); return; }
|
|
3290
3483
|
}
|
|
3291
3484
|
if (generated?.silent === true) {
|
|
3485
|
+
acknowledgeRemoteResult();
|
|
3292
3486
|
if (scheduledRun) db.prepare('INSERT OR IGNORE INTO assistant_scheduled_result(assistant_id, run_id, status) VALUES (?,?,?)').run(assistantID, scheduledRun.id, 'silent');
|
|
3293
3487
|
settleActiveContactTurn(assistantID, turnID, { bumpRevision: true });
|
|
3294
3488
|
emitContactTurnEvent('yuri:contact-turn-end', { assistantID, turnID, status: 'complete' });
|
|
@@ -3332,6 +3526,7 @@ export const createAssistantsService = ({ dbPath, dataDir, buildOpenCodeUrl, get
|
|
|
3332
3526
|
turnID,
|
|
3333
3527
|
reset: resetThisTurn,
|
|
3334
3528
|
});
|
|
3529
|
+
acknowledgeRemoteResult();
|
|
3335
3530
|
settleActiveContactTurn(assistantID, turnID);
|
|
3336
3531
|
emitContactTurnEvent('yuri:contact-turn-end', {
|
|
3337
3532
|
assistantID,
|
|
@@ -3543,7 +3738,7 @@ export const createAssistantsService = ({ dbPath, dataDir, buildOpenCodeUrl, get
|
|
|
3543
3738
|
});
|
|
3544
3739
|
const tools = createContactTools({
|
|
3545
3740
|
searchMemory: memory.search,
|
|
3546
|
-
listModels: () => loadContactModelContext(controller.signal),
|
|
3741
|
+
listModels: (params) => loadContactModelContext(params?.signal || controller.signal, params),
|
|
3547
3742
|
readMemory: memory.read,
|
|
3548
3743
|
assignWork: (params) => assignWork(row, params),
|
|
3549
3744
|
watchSession: (params) => watchSessionWork(row, params),
|
|
@@ -3575,7 +3770,7 @@ export const createAssistantsService = ({ dbPath, dataDir, buildOpenCodeUrl, get
|
|
|
3575
3770
|
return result;
|
|
3576
3771
|
},
|
|
3577
3772
|
listAssistants: () => db.prepare('SELECT * FROM assistant_v2 WHERE tombstone_at IS NULL ORDER BY created_at').all().map(output),
|
|
3578
|
-
listProjects: async () => loadRegisteredProjects(),
|
|
3773
|
+
listProjects: async (params) => loadRegisteredProjects(params),
|
|
3579
3774
|
listSessions: (params) => listSessionsWork(params),
|
|
3580
3775
|
readSession: (params) => readSessionWork(params),
|
|
3581
3776
|
// Live DB read — not the turn-start assistantSnapshot.
|
|
@@ -3624,7 +3819,7 @@ export const createAssistantsService = ({ dbPath, dataDir, buildOpenCodeUrl, get
|
|
|
3624
3819
|
userParts: executionParts,
|
|
3625
3820
|
language,
|
|
3626
3821
|
createChatCompletion,
|
|
3627
|
-
tools: [...tools, ...createOpenCodeContactTools({ resolveClient: client, directory: resolveAssistantCwd(assistantSnapshot) })],
|
|
3822
|
+
tools: [...tools, ...createOpenCodeContactTools({ resolveClient: client, acquireExecution: execution.acquire, directory: resolveAssistantCwd(assistantSnapshot) })],
|
|
3628
3823
|
projects: registeredProjects,
|
|
3629
3824
|
globalEventHub,
|
|
3630
3825
|
onBubbleDelta: (bubbleIndex, delta, done) => {
|
|
@@ -3819,6 +4014,7 @@ export const createAssistantsService = ({ dbPath, dataDir, buildOpenCodeUrl, get
|
|
|
3819
4014
|
// dot while the clearing turn is still running.
|
|
3820
4015
|
bump();
|
|
3821
4016
|
db.exec('COMMIT');
|
|
4017
|
+
pruneRemoteWatchLeases();
|
|
3822
4018
|
return { assistantID: row.assistant_id, reset: true, historyCleared: true, generation };
|
|
3823
4019
|
} catch (error) {
|
|
3824
4020
|
db.exec('ROLLBACK');
|
|
@@ -4030,6 +4226,8 @@ export const createAssistantsService = ({ dbPath, dataDir, buildOpenCodeUrl, get
|
|
|
4030
4226
|
const reconcile = async () => {
|
|
4031
4227
|
if (closed) return;
|
|
4032
4228
|
try {
|
|
4229
|
+
for (const watch of listPendingRemoteWatchResumes(db)) scheduleAssignedSessionResume(watch);
|
|
4230
|
+
pruneRemoteWatchLeases();
|
|
4033
4231
|
await reconcileShareOperations();
|
|
4034
4232
|
if (closed) return;
|
|
4035
4233
|
await reconcileInFlightWatches();
|
|
@@ -4119,6 +4317,7 @@ export const createAssistantsService = ({ dbPath, dataDir, buildOpenCodeUrl, get
|
|
|
4119
4317
|
contactTurnLanguages.delete(assistantID);
|
|
4120
4318
|
bump();
|
|
4121
4319
|
db.exec('COMMIT');
|
|
4320
|
+
pruneRemoteWatchLeases();
|
|
4122
4321
|
return { assistantID, tombstoneAt: now() };
|
|
4123
4322
|
} catch (error) {
|
|
4124
4323
|
db.exec('ROLLBACK');
|
|
@@ -4155,6 +4354,10 @@ export const createAssistantsService = ({ dbPath, dataDir, buildOpenCodeUrl, get
|
|
|
4155
4354
|
};
|
|
4156
4355
|
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: () => {
|
|
4157
4356
|
assignedCompletion.dispose();
|
|
4357
|
+
remoteWatchReconciler.close();
|
|
4358
|
+
execution.close();
|
|
4359
|
+
for (const entry of remoteWatchLeases.values()) { entry.controller.abort(); entry.lease?.release(); }
|
|
4360
|
+
remoteWatchLeases.clear();
|
|
4158
4361
|
cancelAssignedResumes({});
|
|
4159
4362
|
sessionAbortInflight.clear();
|
|
4160
4363
|
for (const turn of contactControllers.values()) turn.controller.abort();
|