@openchamber/web 1.24.1 → 1.24.2
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/bin/cli.test.js +22 -0
- package/bin/lib/commands-status.js +5 -0
- package/dist/assets/{CodeMirrorCommentWidgets-DvUH815P.js → CodeMirrorCommentWidgets-B_vBPQYm.js} +1 -1
- package/dist/assets/DiffView-Ce0oBXXQ.js +4 -0
- package/dist/assets/{FilesView-D0bM9FVB.js → FilesView-DtXueAWP.js} +5 -5
- package/dist/assets/{GitView-Bxuv3dfP.js → GitView-k0hUF8KB.js} +4 -4
- package/dist/assets/{GuestAttachDialog-B0u3Q5uO.js → GuestAttachDialog-DIf2U85Z.js} +1 -1
- package/dist/assets/{JsonTreeView-BBVPFM5K.js → JsonTreeView-4AnJ04Pw.js} +1 -1
- package/dist/assets/KaTeX_AMS-Regular-BQhdFMY1.woff2 +0 -0
- package/dist/assets/KaTeX_AMS-Regular-DMm9YOAa.woff +0 -0
- package/dist/assets/KaTeX_AMS-Regular-DRggAlZN.ttf +0 -0
- package/dist/assets/KaTeX_Caligraphic-Bold-ATXxdsX0.ttf +0 -0
- package/dist/assets/KaTeX_Caligraphic-Bold-BEiXGLvX.woff +0 -0
- package/dist/assets/KaTeX_Caligraphic-Bold-Dq_IR9rO.woff2 +0 -0
- package/dist/assets/KaTeX_Caligraphic-Regular-CTRA-rTL.woff +0 -0
- package/dist/assets/KaTeX_Caligraphic-Regular-Di6jR-x-.woff2 +0 -0
- package/dist/assets/KaTeX_Caligraphic-Regular-wX97UBjC.ttf +0 -0
- package/dist/assets/KaTeX_Fraktur-Bold-BdnERNNW.ttf +0 -0
- package/dist/assets/KaTeX_Fraktur-Bold-BsDP51OF.woff +0 -0
- package/dist/assets/KaTeX_Fraktur-Bold-CL6g_b3V.woff2 +0 -0
- package/dist/assets/KaTeX_Fraktur-Regular-CB_wures.ttf +0 -0
- package/dist/assets/KaTeX_Fraktur-Regular-CTYiF6lA.woff2 +0 -0
- package/dist/assets/KaTeX_Fraktur-Regular-Dxdc4cR9.woff +0 -0
- package/dist/assets/KaTeX_Main-Bold-Cx986IdX.woff2 +0 -0
- package/dist/assets/KaTeX_Main-Bold-Jm3AIy58.woff +0 -0
- package/dist/assets/KaTeX_Main-Bold-waoOVXN0.ttf +0 -0
- package/dist/assets/KaTeX_Main-BoldItalic-DxDJ3AOS.woff2 +0 -0
- package/dist/assets/KaTeX_Main-BoldItalic-DzxPMmG6.ttf +0 -0
- package/dist/assets/KaTeX_Main-BoldItalic-SpSLRI95.woff +0 -0
- package/dist/assets/KaTeX_Main-Italic-3WenGoN9.ttf +0 -0
- package/dist/assets/KaTeX_Main-Italic-BMLOBm91.woff +0 -0
- package/dist/assets/KaTeX_Main-Italic-NWA7e6Wa.woff2 +0 -0
- package/dist/assets/KaTeX_Main-Regular-B22Nviop.woff2 +0 -0
- package/dist/assets/KaTeX_Main-Regular-Dr94JaBh.woff +0 -0
- package/dist/assets/KaTeX_Main-Regular-ypZvNtVU.ttf +0 -0
- package/dist/assets/KaTeX_Math-BoldItalic-B3XSjfu4.ttf +0 -0
- package/dist/assets/KaTeX_Math-BoldItalic-CZnvNsCZ.woff2 +0 -0
- package/dist/assets/KaTeX_Math-BoldItalic-iY-2wyZ7.woff +0 -0
- package/dist/assets/KaTeX_Math-Italic-DA0__PXp.woff +0 -0
- package/dist/assets/KaTeX_Math-Italic-flOr_0UB.ttf +0 -0
- package/dist/assets/KaTeX_Math-Italic-t53AETM-.woff2 +0 -0
- package/dist/assets/KaTeX_SansSerif-Bold-CFMepnvq.ttf +0 -0
- package/dist/assets/KaTeX_SansSerif-Bold-D1sUS0GD.woff2 +0 -0
- package/dist/assets/KaTeX_SansSerif-Bold-DbIhKOiC.woff +0 -0
- package/dist/assets/KaTeX_SansSerif-Italic-C3H0VqGB.woff2 +0 -0
- package/dist/assets/KaTeX_SansSerif-Italic-DN2j7dab.woff +0 -0
- package/dist/assets/KaTeX_SansSerif-Italic-YYjJ1zSn.ttf +0 -0
- package/dist/assets/KaTeX_SansSerif-Regular-BNo7hRIc.ttf +0 -0
- package/dist/assets/KaTeX_SansSerif-Regular-CS6fqUqJ.woff +0 -0
- package/dist/assets/KaTeX_SansSerif-Regular-DDBCnlJ7.woff2 +0 -0
- package/dist/assets/KaTeX_Script-Regular-C5JkGWo-.ttf +0 -0
- package/dist/assets/KaTeX_Script-Regular-D3wIWfF6.woff2 +0 -0
- package/dist/assets/KaTeX_Script-Regular-D5yQViql.woff +0 -0
- package/dist/assets/KaTeX_Size1-Regular-C195tn64.woff +0 -0
- package/dist/assets/KaTeX_Size1-Regular-Dbsnue_I.ttf +0 -0
- package/dist/assets/KaTeX_Size1-Regular-mCD8mA8B.woff2 +0 -0
- package/dist/assets/KaTeX_Size2-Regular-B7gKUWhC.ttf +0 -0
- package/dist/assets/KaTeX_Size2-Regular-Dy4dx90m.woff2 +0 -0
- package/dist/assets/KaTeX_Size2-Regular-oD1tc_U0.woff +0 -0
- package/dist/assets/KaTeX_Size3-Regular-CTq5MqoE.woff +0 -0
- package/dist/assets/KaTeX_Size3-Regular-DgpXs0kz.ttf +0 -0
- package/dist/assets/KaTeX_Size4-Regular-BF-4gkZK.woff +0 -0
- package/dist/assets/KaTeX_Size4-Regular-DWFBv043.ttf +0 -0
- package/dist/assets/KaTeX_Size4-Regular-Dl5lxZxV.woff2 +0 -0
- package/dist/assets/KaTeX_Typewriter-Regular-C0xS9mPB.woff +0 -0
- package/dist/assets/KaTeX_Typewriter-Regular-CO6r4hn1.woff2 +0 -0
- package/dist/assets/KaTeX_Typewriter-Regular-D3Ib7_Hf.ttf +0 -0
- package/dist/assets/{LinearIssuesView-UI1FcSC8.js → LinearIssuesView-z_9p2GuO.js} +1 -1
- package/dist/assets/{MarkdownImageGallery-CUJxH8Le.js → MarkdownImageGallery-BC-BNN-s.js} +1 -1
- package/dist/assets/{MarkdownRendererImpl-D5BZOg8X.js → MarkdownRendererImpl-DyaBTUbH.js} +6 -6
- package/dist/assets/{OnboardingScreen-5Gou9cGD.js → OnboardingScreen-DKU_yTb6.js} +1 -1
- package/dist/assets/{PatchDiff-C4rE5k6z.js → PatchDiff-DpGmHRnV.js} +1 -1
- package/dist/assets/PierreDiffViewer-CgLl_tp7.js +210 -0
- package/dist/assets/{PlanView-u2yi5XGJ.js → PlanView-CrfB4qqY.js} +4 -4
- package/dist/assets/{PluginPane-QxjsKYeO.js → PluginPane-B5cn-jPy.js} +1 -1
- package/dist/assets/{SettingsView-Fo5ZqMaT.js → SettingsView-DMKKwezx.js} +12 -12
- package/dist/assets/{SettingsWindow-HVDVANjJ.js → SettingsWindow-DwbnVzOC.js} +1 -1
- package/dist/assets/{SubmoduleDiffSummary-D3hzkybB.js → SubmoduleDiffSummary-hkGcvs0E.js} +1 -1
- package/dist/assets/{ToolOutputDialog-3J6IRayW.js → ToolOutputDialog-DuoIOc0j.js} +6 -6
- package/dist/assets/{ToolPartDiffPreview-DarxPjSd.js → ToolPartDiffPreview-t1Bvq_2Y.js} +2 -2
- package/dist/assets/{VirtualizedFileDiff-CZgXWHjU.js → VirtualizedFileDiff-BK4aU5qJ.js} +4 -4
- package/dist/assets/{WalkthroughView-wSpED5L4.js → WalkthroughView-Bk6TPNFw.js} +2 -2
- package/dist/assets/{appThemeRegistry-Cf8KitzT.js → appThemeRegistry-DnOVbJjF.js} +1 -1
- package/dist/assets/{commitAndPush-DZnzlhvc.js → commitAndPush-DLWNZkkY.js} +1 -1
- package/dist/assets/{computeVirtualFileMetrics-VYnT_A2h.js → computeVirtualFileMetrics-BVTujWSX.js} +1 -1
- package/dist/assets/{de-BM_8EDD3.js → de-zEHaAIi3.js} +4 -4
- package/dist/assets/{es-CxZjlqpo.js → es-CBDgEzgk.js} +3 -3
- package/dist/assets/{fr-VCixCnMW.js → fr-DjiTptT_.js} +4 -4
- package/dist/assets/{index-B9Hvzjwl.css → index-AgOdanig.css} +1 -1
- package/dist/assets/index-B-2_X4DD.js +40 -0
- package/dist/assets/{index-3U4CtS9b.js → index-CkA4p2IK.js} +1 -1
- package/dist/assets/{isDiffPlainText-ImDG3Uhg.js → isDiffPlainText-D3yX_vx4.js} +1 -1
- package/dist/assets/{isFilePlainText-D_YDVYDb.js → isFilePlainText-CZR9TcHV.js} +1 -1
- package/dist/assets/{ja-CZ5k_GyD.js → ja-CerMgj3r.js} +4 -4
- package/dist/assets/{ko-7YM3A1Xh.js → ko-DHYDAze5.js} +4 -4
- package/dist/assets/main-BDka4W43.js +896 -0
- package/dist/assets/main-Dl7Dyge_.js +2 -0
- package/dist/assets/{markdownCore-DHvqMxPn.js → markdownCore-DFmr0rUR.js} +4 -4
- package/dist/assets/miniChat-CLKQPPpO.js +2 -0
- package/dist/assets/mobile--giD2Q1L.js +2 -0
- package/dist/assets/{patchFileDiff-DDQ6Rq5e.js → patchFileDiff-DRh-AQvd.js} +3 -3
- package/dist/assets/{pl-BcgDO_w5.js → pl-BTB_93bq.js} +4 -4
- package/dist/assets/{pt-BR-CU2u_1q5.js → pt-BR-BwA3oyCK.js} +3 -3
- package/dist/assets/renderElectronMiniChatApp-DmB7zpVK.js +2 -0
- package/dist/assets/{renderMobileApp-D0Y8DtkA.js → renderMobileApp-pMfOuQfl.js} +7 -7
- package/dist/assets/runtimeEndpointReset-Gqhmkm3U.js +25 -0
- package/dist/assets/{scheduledTasksApi-D8pq6gQz.js → scheduledTasksApi-CeRAIUmW.js} +1 -1
- package/dist/assets/{shikiHighlight-1imXsir9.js → shikiHighlight-BfjuB3CD.js} +1 -1
- package/dist/assets/{textMateThemeFromAppTheme-Dgqc63LZ.js → textMateThemeFromAppTheme-BP60t9SX.js} +1 -1
- package/dist/assets/{tr-DuYhOzNe.js → tr-CcPsJoNM.js} +3 -3
- package/dist/assets/{uk-Cuk7-uvq.js → uk-B68WibXi.js} +3 -3
- package/dist/assets/{useAppFontEffects-BItUWdo4.js → useAppFontEffects-DcdrFv2Z.js} +144 -144
- package/dist/assets/{useInlineCommentController-CkbKsm7m.js → useInlineCommentController-Cq4SUjsA.js} +2 -2
- package/dist/assets/{useRootScrollLock-vmzxZjWA.js → useRootScrollLock-CSdR6Wnm.js} +2 -2
- package/dist/assets/{vendor-codemirror-language-data-BDyxuqK4.js → vendor-codemirror-language-data-BFm1Ju2w.js} +2 -2
- package/dist/assets/vendor-katex-Cp579UoJ.css +1 -0
- package/dist/assets/{vendor-zod-fZppILAM.js → vendor-zod-CgAdXWZO.js} +4 -4
- package/dist/assets/{web-components-D7FinaeH.js → web-components-2vo9YsZc.js} +1 -1
- package/dist/assets/{zh-CN-CUWoiRHd.js → zh-CN-DbFHYXwP.js} +3 -3
- package/dist/assets/{zh-TW-CQ8EBSBN.js → zh-TW-DmXAwdty.js} +3 -3
- package/dist/index.html +6 -4
- package/dist/mini-chat.html +6 -4
- package/dist/mobile.html +6 -4
- package/package.json +4 -4
- package/server/index.js +3 -0
- package/server/lib/agent-tool/DOCUMENTATION.md +17 -4
- package/server/lib/agent-tool/runtime.js +62 -15
- package/server/lib/agent-tool/runtime.test.js +88 -2
- package/server/lib/fs/DOCUMENTATION.md +2 -1
- package/server/lib/fs/routes.js +56 -4
- package/server/lib/fs/routes.test.js +116 -0
- package/server/lib/git/DOCUMENTATION.md +2 -2
- package/server/lib/git/service.js +94 -9
- package/server/lib/git/service.test.js +18 -0
- package/server/lib/message-queue/DOCUMENTATION.md +4 -1
- package/server/lib/message-queue/runtime.js +16 -1
- package/server/lib/message-queue/runtime.test.js +21 -5
- package/server/lib/notifications/routes.js +5 -0
- package/server/lib/openchamber-sessions/routes.js +18 -18
- package/server/lib/openchamber-sessions/routes.test.js +49 -0
- package/server/lib/opencode/DOCUMENTATION.md +1 -1
- package/server/lib/opencode/bootstrap-runtime.js +1 -0
- package/server/lib/opencode/session-runtime.js +68 -0
- package/server/lib/opencode/session-runtime.test.js +43 -0
- package/server/lib/projects/project-config.js +2 -2
- package/server/lib/realtime-proxy-terminal.test.js +150 -0
- package/server/lib/realtime-proxy.js +2 -0
- package/server/lib/routing/DOCUMENTATION.md +5 -3
- package/server/lib/scheduled-tasks/runtime.js +2 -2
- package/server/lib/scheduled-tasks/runtime.test.js +14 -0
- package/server/lib/small-model/DOCUMENTATION.md +14 -2
- package/server/lib/small-model/call.js +37 -6
- package/server/lib/small-model/call.test.js +182 -0
- package/server/lib/terminal/DOCUMENTATION.md +21 -2
- package/server/lib/terminal/runtime.js +10 -3
- package/server/lib/terminal/runtime.test.js +22 -0
- package/server/lib/terminal/shutdown.js +106 -0
- package/server/lib/terminal/shutdown.test.js +84 -0
- package/server/lib/tts/service.test.js +78 -0
- package/dist/assets/DiffView-DkC3xlRJ.js +0 -4
- package/dist/assets/PierreDiffViewer-ByRVu6ss.js +0 -161
- package/dist/assets/index-DLHQogv8.js +0 -40
- package/dist/assets/main-CycplCph.js +0 -2
- package/dist/assets/main-DFYTCx5o.js +0 -896
- package/dist/assets/miniChat-DIQKfY2V.js +0 -2
- package/dist/assets/mobile-BMwz5q-m.js +0 -2
- package/dist/assets/renderElectronMiniChatApp-3_d6g6CU.js +0 -2
- package/dist/assets/runtimeEndpointReset-DhC3REb2.js +0 -25
- /package/dist/assets/{vendor-katex-k3Ppq1Ha.js → vendor-katex-CHD9BdDO.js} +0 -0
|
@@ -38,13 +38,76 @@ const extractSessionStatusUpdate = (payload) => {
|
|
|
38
38
|
};
|
|
39
39
|
};
|
|
40
40
|
|
|
41
|
+
const readRequestId = (value) => (typeof value === 'string' && value.trim() ? value.trim() : '');
|
|
42
|
+
|
|
41
43
|
export const createSessionRuntime = ({ writeSseEvent, getNotificationClients, broadcastEvent }) => {
|
|
42
44
|
const sessionActivityPhases = new Map();
|
|
43
45
|
const sessionActivityCooldowns = new Map();
|
|
44
46
|
const sessionStates = new Map();
|
|
45
47
|
const sessionAttentionStates = new Map();
|
|
48
|
+
// Pending permission and question requests per session, kept from the same
|
|
49
|
+
// upstream stream. Clients that do not initialize a directory cannot read
|
|
50
|
+
// its pending list from OpenCode (that read creates an instance), so this
|
|
51
|
+
// map is their seed. Entries live until the matching reply, the session's
|
|
52
|
+
// deletion, or an OpenCode restart, which drops every pending request.
|
|
53
|
+
const pendingRequestsBySession = new Map();
|
|
46
54
|
let activeSessionCount = 0;
|
|
47
55
|
|
|
56
|
+
const getOrCreatePendingRequests = (sessionId) => {
|
|
57
|
+
let entry = pendingRequestsBySession.get(sessionId);
|
|
58
|
+
if (!entry) {
|
|
59
|
+
entry = { permissions: new Map(), questions: new Map() };
|
|
60
|
+
pendingRequestsBySession.set(sessionId, entry);
|
|
61
|
+
}
|
|
62
|
+
return entry;
|
|
63
|
+
};
|
|
64
|
+
|
|
65
|
+
const settlePendingRequest = (kind, sessionId, requestId) => {
|
|
66
|
+
const entry = pendingRequestsBySession.get(sessionId);
|
|
67
|
+
if (!entry) return;
|
|
68
|
+
// OpenCode may omit the request ID on a reply; the session then has no
|
|
69
|
+
// pending request of that kind we can still vouch for.
|
|
70
|
+
if (requestId) entry[kind].delete(requestId);
|
|
71
|
+
else entry[kind].clear();
|
|
72
|
+
if (entry.permissions.size === 0 && entry.questions.size === 0) pendingRequestsBySession.delete(sessionId);
|
|
73
|
+
};
|
|
74
|
+
|
|
75
|
+
const processBlockingRequestPayload = (payload) => {
|
|
76
|
+
if (!payload || typeof payload.type !== 'string') return;
|
|
77
|
+
const properties = payload.properties && typeof payload.properties === 'object' ? payload.properties : {};
|
|
78
|
+
if (payload.type === 'permission.asked' || payload.type === 'question.asked') {
|
|
79
|
+
const sessionId = readRequestId(properties.sessionID);
|
|
80
|
+
const requestId = readRequestId(properties.id);
|
|
81
|
+
if (!sessionId || !requestId) return;
|
|
82
|
+
getOrCreatePendingRequests(sessionId)[payload.type === 'permission.asked' ? 'permissions' : 'questions'].set(requestId, properties);
|
|
83
|
+
return;
|
|
84
|
+
}
|
|
85
|
+
if (payload.type === 'permission.replied') {
|
|
86
|
+
settlePendingRequest('permissions', readRequestId(properties.sessionID), readRequestId(properties.requestID));
|
|
87
|
+
return;
|
|
88
|
+
}
|
|
89
|
+
if (payload.type === 'question.replied' || payload.type === 'question.rejected') {
|
|
90
|
+
settlePendingRequest('questions', readRequestId(properties.sessionID), readRequestId(properties.requestID));
|
|
91
|
+
return;
|
|
92
|
+
}
|
|
93
|
+
if (payload.type === 'session.deleted') {
|
|
94
|
+
const info = properties.info && typeof properties.info === 'object' ? properties.info : {};
|
|
95
|
+
const sessionId = readRequestId(properties.sessionID) || readRequestId(info.id);
|
|
96
|
+
if (sessionId) pendingRequestsBySession.delete(sessionId);
|
|
97
|
+
}
|
|
98
|
+
};
|
|
99
|
+
|
|
100
|
+
const getPendingBlockingRequestsSnapshot = () => {
|
|
101
|
+
const result = {};
|
|
102
|
+
for (const [sessionId, entry] of pendingRequestsBySession) {
|
|
103
|
+
result[sessionId] = {
|
|
104
|
+
permissions: [...entry.permissions.values()],
|
|
105
|
+
questions: [...entry.questions.values()],
|
|
106
|
+
};
|
|
107
|
+
}
|
|
108
|
+
return result;
|
|
109
|
+
};
|
|
110
|
+
|
|
48
111
|
const getOrCreateAttentionState = (sessionId) => {
|
|
49
112
|
if (!sessionId || typeof sessionId !== 'string') return null;
|
|
50
113
|
|
|
@@ -307,6 +370,8 @@ export const createSessionRuntime = ({ writeSseEvent, getNotificationClients, br
|
|
|
307
370
|
}
|
|
308
371
|
}
|
|
309
372
|
|
|
373
|
+
// A restarted OpenCode forgot every pending request with the turns.
|
|
374
|
+
pendingRequestsBySession.clear();
|
|
310
375
|
const eventId = `opencode-restart-${Date.now()}`;
|
|
311
376
|
for (const sessionId of interruptedSessionIds) {
|
|
312
377
|
updateSessionState(sessionId, 'idle', eventId, {
|
|
@@ -354,6 +419,7 @@ export const createSessionRuntime = ({ writeSseEvent, getNotificationClients, br
|
|
|
354
419
|
const cleanupInterval = setInterval(cleanupOldSessionStates, SESSION_STATE_CLEANUP_INTERVAL_MS);
|
|
355
420
|
|
|
356
421
|
const processOpenCodeSsePayload = (payload) => {
|
|
422
|
+
processBlockingRequestPayload(payload);
|
|
357
423
|
const update = extractSessionStatusUpdate(payload);
|
|
358
424
|
if (!update) return;
|
|
359
425
|
|
|
@@ -379,6 +445,7 @@ export const createSessionRuntime = ({ writeSseEvent, getNotificationClients, br
|
|
|
379
445
|
sessionActivityPhases.clear();
|
|
380
446
|
sessionStates.clear();
|
|
381
447
|
sessionAttentionStates.clear();
|
|
448
|
+
pendingRequestsBySession.clear();
|
|
382
449
|
activeSessionCount = 0;
|
|
383
450
|
};
|
|
384
451
|
|
|
@@ -387,6 +454,7 @@ export const createSessionRuntime = ({ writeSseEvent, getNotificationClients, br
|
|
|
387
454
|
getSessionActivitySnapshot,
|
|
388
455
|
getActiveSessionCount,
|
|
389
456
|
getSessionStateSnapshot,
|
|
457
|
+
getPendingBlockingRequestsSnapshot,
|
|
390
458
|
getSessionAttentionSnapshot,
|
|
391
459
|
getSessionState,
|
|
392
460
|
getSessionAttentionState,
|
|
@@ -12,6 +12,49 @@ describe('session runtime', () => {
|
|
|
12
12
|
runtimes.length = 0;
|
|
13
13
|
});
|
|
14
14
|
|
|
15
|
+
it('keeps pending permission and question requests until they are answered', () => {
|
|
16
|
+
const runtime = createSessionRuntime({
|
|
17
|
+
writeSseEvent() {},
|
|
18
|
+
getNotificationClients: () => new Set(),
|
|
19
|
+
broadcastEvent: () => {},
|
|
20
|
+
});
|
|
21
|
+
runtimes.push(runtime);
|
|
22
|
+
const permission = { id: 'perm-1', sessionID: 'session-1', permission: 'bash', patterns: ['rm *'], metadata: {}, always: [] };
|
|
23
|
+
const question = { id: 'q-1', sessionID: 'session-2', questions: [{ header: 'Pick', question: 'Which?', options: [] }] };
|
|
24
|
+
|
|
25
|
+
runtime.processOpenCodeSsePayload({ type: 'permission.asked', properties: permission });
|
|
26
|
+
runtime.processOpenCodeSsePayload({ type: 'permission.asked', properties: permission });
|
|
27
|
+
runtime.processOpenCodeSsePayload({ type: 'question.asked', properties: question });
|
|
28
|
+
expect(runtime.getPendingBlockingRequestsSnapshot()).toEqual({
|
|
29
|
+
'session-1': { permissions: [permission], questions: [] },
|
|
30
|
+
'session-2': { permissions: [], questions: [question] },
|
|
31
|
+
});
|
|
32
|
+
|
|
33
|
+
runtime.processOpenCodeSsePayload({ type: 'permission.replied', properties: { sessionID: 'session-1', requestID: 'perm-1' } });
|
|
34
|
+
runtime.processOpenCodeSsePayload({ type: 'question.rejected', properties: { sessionID: 'session-2' } });
|
|
35
|
+
expect(runtime.getPendingBlockingRequestsSnapshot()).toEqual({});
|
|
36
|
+
});
|
|
37
|
+
|
|
38
|
+
it('drops pending requests when the session is deleted or OpenCode restarts', () => {
|
|
39
|
+
const runtime = createSessionRuntime({
|
|
40
|
+
writeSseEvent() {},
|
|
41
|
+
getNotificationClients: () => new Set(),
|
|
42
|
+
broadcastEvent: () => {},
|
|
43
|
+
});
|
|
44
|
+
runtimes.push(runtime);
|
|
45
|
+
const ask = (sessionID, id) => runtime.processOpenCodeSsePayload({
|
|
46
|
+
type: 'permission.asked', properties: { id, sessionID, permission: 'edit', patterns: [], metadata: {}, always: [] },
|
|
47
|
+
});
|
|
48
|
+
|
|
49
|
+
ask('session-1', 'perm-1');
|
|
50
|
+
ask('session-2', 'perm-2');
|
|
51
|
+
runtime.processOpenCodeSsePayload({ type: 'session.deleted', properties: { info: { id: 'session-1' } } });
|
|
52
|
+
expect(Object.keys(runtime.getPendingBlockingRequestsSnapshot())).toEqual(['session-2']);
|
|
53
|
+
|
|
54
|
+
runtime.interruptBusySessionsAfterRestart();
|
|
55
|
+
expect(runtime.getPendingBlockingRequestsSnapshot()).toEqual({});
|
|
56
|
+
});
|
|
57
|
+
|
|
15
58
|
it('broadcasts attention clears through the shared broadcaster', () => {
|
|
16
59
|
const events = [];
|
|
17
60
|
const runtime = createSessionRuntime({
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { DateTime, IANAZone } from 'luxon';
|
|
2
|
-
import
|
|
2
|
+
import { CronExpressionParser } from 'cron-parser';
|
|
3
3
|
|
|
4
4
|
import { projectConfigFileStemOf, projectPathFromId } from './project-id.js';
|
|
5
5
|
import {
|
|
@@ -145,7 +145,7 @@ const normalizeTimezone = (value, fallback = resolveDefaultTimezone()) => {
|
|
|
145
145
|
|
|
146
146
|
const validateCronExpression = (expression, timezone) => {
|
|
147
147
|
try {
|
|
148
|
-
const iterator =
|
|
148
|
+
const iterator = CronExpressionParser.parse(expression, {
|
|
149
149
|
tz: timezone,
|
|
150
150
|
currentDate: new Date(),
|
|
151
151
|
});
|
|
@@ -0,0 +1,150 @@
|
|
|
1
|
+
import { afterAll, expect, it } from 'vitest';
|
|
2
|
+
import crypto from 'node:crypto';
|
|
3
|
+
import fs from 'node:fs';
|
|
4
|
+
import http from 'node:http';
|
|
5
|
+
import os from 'node:os';
|
|
6
|
+
import path from 'node:path';
|
|
7
|
+
import express from 'express';
|
|
8
|
+
import { WebSocket } from 'ws';
|
|
9
|
+
|
|
10
|
+
import { attachRealtimeProxy, buildRealtimeProxyWsUrl } from './realtime-proxy.js';
|
|
11
|
+
import { createRequestSecurityRuntime } from './security/request-security.js';
|
|
12
|
+
import { createTerminalRuntime } from './terminal/runtime.js';
|
|
13
|
+
import { readTerminalWsControlFrame } from './terminal/terminal-ws-protocol.js';
|
|
14
|
+
|
|
15
|
+
const previousDataDir = process.env.OPENCHAMBER_DATA_DIR;
|
|
16
|
+
const dataDir = fs.mkdtempSync(path.join(os.tmpdir(), 'oc-proxy-terminal-'));
|
|
17
|
+
process.env.OPENCHAMBER_DATA_DIR = dataDir;
|
|
18
|
+
const { createUiAuth } = await import('./ui-auth/ui-auth.js');
|
|
19
|
+
|
|
20
|
+
afterAll(() => {
|
|
21
|
+
if (previousDataDir === undefined) delete process.env.OPENCHAMBER_DATA_DIR;
|
|
22
|
+
else process.env.OPENCHAMBER_DATA_DIR = previousDataDir;
|
|
23
|
+
fs.rmSync(dataDir, { recursive: true, force: true });
|
|
24
|
+
});
|
|
25
|
+
|
|
26
|
+
const listen = async (server) => {
|
|
27
|
+
await new Promise((resolve) => server.listen(0, '127.0.0.1', resolve));
|
|
28
|
+
return `http://127.0.0.1:${server.address().port}`;
|
|
29
|
+
};
|
|
30
|
+
|
|
31
|
+
const login = async (origin, password) => {
|
|
32
|
+
const response = await fetch(`${origin}/auth/session`, {
|
|
33
|
+
method: 'POST',
|
|
34
|
+
headers: { 'Content-Type': 'application/json' },
|
|
35
|
+
body: JSON.stringify({ password }),
|
|
36
|
+
});
|
|
37
|
+
expect(response.status).toBe(200);
|
|
38
|
+
const cookie = response.headers.get('set-cookie').split(';')[0];
|
|
39
|
+
const minted = await fetch(`${origin}/auth/url-token`, {
|
|
40
|
+
method: 'POST',
|
|
41
|
+
headers: { Cookie: cookie, 'Content-Type': 'application/json' },
|
|
42
|
+
body: '{}',
|
|
43
|
+
});
|
|
44
|
+
expect(minted.status).toBe(200);
|
|
45
|
+
const { token } = await minted.json();
|
|
46
|
+
expect(token).toBeTruthy();
|
|
47
|
+
return token;
|
|
48
|
+
};
|
|
49
|
+
|
|
50
|
+
const connect = (url, origin = 'openchamber-ui://app') => new Promise((resolve, reject) => {
|
|
51
|
+
const socket = new WebSocket(url, { origin });
|
|
52
|
+
let hello = null;
|
|
53
|
+
let status = null;
|
|
54
|
+
const timeout = setTimeout(() => {
|
|
55
|
+
socket.terminate();
|
|
56
|
+
reject(new Error('Timed out waiting for terminal handshake'));
|
|
57
|
+
}, 3000);
|
|
58
|
+
socket.on('upgrade', (response) => { status = response.statusCode; });
|
|
59
|
+
socket.on('unexpected-response', (_request, response) => {
|
|
60
|
+
status = response.statusCode;
|
|
61
|
+
response.resume();
|
|
62
|
+
socket.terminate();
|
|
63
|
+
});
|
|
64
|
+
socket.on('message', (raw) => {
|
|
65
|
+
hello = readTerminalWsControlFrame(raw);
|
|
66
|
+
socket.close();
|
|
67
|
+
});
|
|
68
|
+
socket.on('error', () => {});
|
|
69
|
+
socket.on('close', (code) => {
|
|
70
|
+
clearTimeout(timeout);
|
|
71
|
+
resolve({ hello, status, code });
|
|
72
|
+
});
|
|
73
|
+
});
|
|
74
|
+
|
|
75
|
+
it('connects through the desktop proxy to an authenticated terminal without weakening either gate', async () => {
|
|
76
|
+
const password = crypto.randomBytes(24).toString('hex');
|
|
77
|
+
const remoteAuth = createUiAuth({ password });
|
|
78
|
+
const localAuth = createUiAuth({ password });
|
|
79
|
+
const remoteApp = express();
|
|
80
|
+
const localApp = express();
|
|
81
|
+
for (const [app, auth] of [[remoteApp, remoteAuth], [localApp, localAuth]]) {
|
|
82
|
+
app.use(express.json());
|
|
83
|
+
app.post('/auth/session', auth.handleSessionCreate);
|
|
84
|
+
app.post('/auth/url-token', auth.handleUrlAuthToken);
|
|
85
|
+
}
|
|
86
|
+
const remote = http.createServer(remoteApp);
|
|
87
|
+
const local = http.createServer(localApp);
|
|
88
|
+
const security = createRequestSecurityRuntime({ readSettingsFromDiskMigrated: async () => ({}) });
|
|
89
|
+
const received = [];
|
|
90
|
+
remote.on('upgrade', (req) => {
|
|
91
|
+
received.push({ origin: req.headers.origin, custom: req.headers['x-proxy-test'] });
|
|
92
|
+
});
|
|
93
|
+
const rejected = [];
|
|
94
|
+
const terminal = createTerminalRuntime({
|
|
95
|
+
app: remoteApp, server: remote, fs, path, uiAuthController: remoteAuth,
|
|
96
|
+
buildAugmentedPath: () => process.env.PATH || '',
|
|
97
|
+
searchPathFor: () => null,
|
|
98
|
+
isExecutable: () => false,
|
|
99
|
+
isRequestOriginAllowed: security.isRequestOriginAllowed,
|
|
100
|
+
rejectWebSocketUpgrade: (socket, status, reason) => {
|
|
101
|
+
rejected.push(status);
|
|
102
|
+
security.rejectWebSocketUpgrade(socket, status, reason);
|
|
103
|
+
},
|
|
104
|
+
TERMINAL_INPUT_WS_HEARTBEAT_INTERVAL_MS: 30_000,
|
|
105
|
+
});
|
|
106
|
+
let proxy;
|
|
107
|
+
try {
|
|
108
|
+
const remoteOrigin = await listen(remote);
|
|
109
|
+
const localOrigin = await listen(local);
|
|
110
|
+
proxy = attachRealtimeProxy({
|
|
111
|
+
app: localApp, server: local,
|
|
112
|
+
getDesktopRuntimeConfig: () => ({
|
|
113
|
+
apiBaseUrl: remoteOrigin,
|
|
114
|
+
requestHeaders: { 'X-Proxy-Test': 'present' },
|
|
115
|
+
}),
|
|
116
|
+
getUiAuthController: () => localAuth,
|
|
117
|
+
isRequestOriginAllowed: security.isRequestOriginAllowed,
|
|
118
|
+
});
|
|
119
|
+
const remoteToken = await login(remoteOrigin, password);
|
|
120
|
+
const localToken = await login(localOrigin, password);
|
|
121
|
+
const target = new URL('/api/terminal/ws', remoteOrigin);
|
|
122
|
+
target.protocol = 'ws:';
|
|
123
|
+
target.searchParams.set('oc_url_token', remoteToken);
|
|
124
|
+
const proxied = new URL(buildRealtimeProxyWsUrl(localOrigin, target.toString()));
|
|
125
|
+
proxied.searchParams.set('oc_url_token', localToken);
|
|
126
|
+
|
|
127
|
+
expect((await connect(target.toString())).hello).toEqual({ t: 'hello', v: 3 });
|
|
128
|
+
expect((await connect(proxied.toString())).hello).toEqual({ t: 'hello', v: 3 });
|
|
129
|
+
expect(received.at(-1)).toEqual({ origin: remoteOrigin, custom: 'present' });
|
|
130
|
+
expect(rejected).toEqual([]);
|
|
131
|
+
|
|
132
|
+
const beforeRejectedLocal = received.length;
|
|
133
|
+
expect((await connect(proxied.toString(), 'https://untrusted.example')).status).toBe(403);
|
|
134
|
+
const unauthenticatedLocal = new URL(proxied);
|
|
135
|
+
unauthenticatedLocal.searchParams.delete('oc_url_token');
|
|
136
|
+
expect((await connect(unauthenticatedLocal.toString())).status).toBe(401);
|
|
137
|
+
expect(received).toHaveLength(beforeRejectedLocal);
|
|
138
|
+
|
|
139
|
+
target.searchParams.delete('oc_url_token');
|
|
140
|
+
proxied.searchParams.set('url', target.toString());
|
|
141
|
+
expect((await connect(proxied.toString())).hello).toBeNull();
|
|
142
|
+
expect(rejected).toEqual([401]);
|
|
143
|
+
} finally {
|
|
144
|
+
proxy?.stop();
|
|
145
|
+
await terminal.shutdown();
|
|
146
|
+
remoteAuth.dispose();
|
|
147
|
+
localAuth.dispose();
|
|
148
|
+
await Promise.all([remote, local].map((server) => new Promise((resolve) => server.close(resolve))));
|
|
149
|
+
}
|
|
150
|
+
});
|
|
@@ -200,6 +200,8 @@ export const attachRealtimeProxy = ({ app, server, getDesktopRuntimeConfig, getU
|
|
|
200
200
|
|
|
201
201
|
const upstream = new WebSocket(resolved.target.toString(), {
|
|
202
202
|
headers: resolved.requestHeaders,
|
|
203
|
+
// ws does not send Origin by default; protected upstreams require it.
|
|
204
|
+
origin: `${resolved.target.protocol === 'wss:' ? 'https:' : 'http:'}//${resolved.target.host}`,
|
|
203
205
|
});
|
|
204
206
|
const pending = [];
|
|
205
207
|
|
|
@@ -37,9 +37,11 @@ Code has no OpenChamber server and never offers Auto.
|
|
|
37
37
|
|
|
38
38
|
- The sentinel never reaches OpenCode. `resolvePromptBody` rewrites
|
|
39
39
|
`body.model` in place for `POST /api/session/:id/{prompt_async,prompt,command}`
|
|
40
|
-
ahead of the generic proxy (which replays a parsed body)
|
|
41
|
-
message queue's `sendItem
|
|
42
|
-
|
|
40
|
+
ahead of the generic proxy (which replays a parsed body), inside the
|
|
41
|
+
message queue's `sendItem`, and in the OpenChamber session service's own
|
|
42
|
+
dispatch (`openchamber-sessions/routes.js`), which posts to OpenCode directly
|
|
43
|
+
and can pick Auto up from Session Defaults. Without a fallback model it
|
|
44
|
+
throws 400 rather than forwarding.
|
|
43
45
|
- Every failure keeps the user's own behaviour. A Jev error, timeout, unknown
|
|
44
46
|
category or low confidence routes to the fallback model; the decision carries
|
|
45
47
|
the reason. A safety-net failure accepts the permission exactly as auto-accept
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { createOpencodeClient } from '@opencode-ai/sdk/v2';
|
|
2
2
|
import { DateTime } from 'luxon';
|
|
3
|
-
import
|
|
3
|
+
import { CronExpressionParser } from 'cron-parser';
|
|
4
4
|
import { expandSnippets } from '../opencode/snippets.js';
|
|
5
5
|
import { buildGoalIntroText, createSessionGoal } from '../session-goal/create.js';
|
|
6
6
|
import { discoverLoops } from './loops.js';
|
|
@@ -216,7 +216,7 @@ export const computeNextRunAt = (task, nowMs = Date.now()) => {
|
|
|
216
216
|
|
|
217
217
|
if (schedule.kind === 'cron') {
|
|
218
218
|
try {
|
|
219
|
-
const iterator =
|
|
219
|
+
const iterator = CronExpressionParser.parse(schedule.cron, {
|
|
220
220
|
tz: zone,
|
|
221
221
|
currentDate: new Date(nowMs),
|
|
222
222
|
});
|
|
@@ -12,6 +12,20 @@ import {
|
|
|
12
12
|
import { createProjectConfigRuntime } from '../projects/project-config.js';
|
|
13
13
|
|
|
14
14
|
describe('scheduled-tasks runtime helpers', () => {
|
|
15
|
+
it.each([
|
|
16
|
+
['*/15 * * * *', 'UTC', '2026-09-18T08:07:00Z', '2026-09-18T08:15:00Z'],
|
|
17
|
+
['30 */5 * * * *', 'UTC', '2026-09-18T08:07:00Z', '2026-09-18T08:10:30Z'],
|
|
18
|
+
['0 9 * * MON-FRI', 'Europe/Kyiv', '2026-09-18T07:00:00Z', '2026-09-21T06:00:00Z'],
|
|
19
|
+
['0 9 * * *', 'Europe/Kyiv', '2026-03-28T08:00:00Z', '2026-03-29T06:00:00Z'],
|
|
20
|
+
['0 9 * * *', 'Europe/Kyiv', '2026-10-24T08:00:00Z', '2026-10-25T07:00:00Z'],
|
|
21
|
+
['0 0 L * *', 'UTC', '2026-02-01T00:00:00Z', '2026-02-28T00:00:00Z'],
|
|
22
|
+
])('computes cron %s in %s from %s', (cron, timezone, now, expected) => {
|
|
23
|
+
expect(computeNextRunAt({
|
|
24
|
+
enabled: true,
|
|
25
|
+
schedule: { kind: 'cron', cron, timezone },
|
|
26
|
+
}, Date.parse(now))).toBe(Date.parse(expected));
|
|
27
|
+
});
|
|
28
|
+
|
|
15
29
|
it('computes next daily run in timezone', () => {
|
|
16
30
|
const nowUtc = Date.UTC(2025, 0, 1, 8, 0, 0);
|
|
17
31
|
const next = computeNextRunAt({
|
|
@@ -118,14 +118,26 @@ other runtime API.
|
|
|
118
118
|
provider's base URL, resolved from (1) `provider.<id>.options.baseURL`
|
|
119
119
|
in the OpenCode config, (2) the hardcoded `https://api.openai.com/v1`
|
|
120
120
|
endpoint, (3) the selected model's endpoint OpenCode resolved at runtime,
|
|
121
|
-
(4) the provider-level runtime endpoint,
|
|
122
|
-
from the models.dev catalog
|
|
121
|
+
(4) the provider-level runtime endpoint, (5) the provider's `api` field
|
|
122
|
+
from the models.dev catalog, or (6) `SDK_DEFAULT_BASE_URLS` — providers
|
|
123
|
+
such as Groq, xAI, and Mistral keep their endpoint inside a dedicated AI
|
|
124
|
+
SDK package, so neither the catalog nor OpenCode reports one. The
|
|
125
|
+
credential follows
|
|
123
126
|
the same shape: config `options.apiKey`, then the runtime credential, then
|
|
124
127
|
the auth.json entry. `provider.<id>.options.headers` is sent with the
|
|
125
128
|
request and overrides the bearer default, so gateways that authenticate on
|
|
126
129
|
their own header work here exactly as they do in a chat turn. Configured API
|
|
127
130
|
keys and header values honor OpenCode's `{env:NAME}` and `{file:path}`
|
|
128
131
|
substitutions; file contents and resolved credentials remain server-side.
|
|
132
|
+
- `thinking: { type: 'disabled' }` is sent in two cases, mirroring OpenCode's
|
|
133
|
+
`transform.ts`. The GLM switch belongs to the endpoint, not the model
|
|
134
|
+
family: it goes to a provider whose id contains `zai`/`zhipu` or whose
|
|
135
|
+
base URL is on `api.z.ai`/`bigmodel.cn`, because the same GLM model served
|
|
136
|
+
by another provider (OpenCode Go) rejects the unknown field with a 400.
|
|
137
|
+
The MiniMax M3 switch goes only behind the `@ai-sdk/openai-compatible` and
|
|
138
|
+
`@ai-sdk/anthropic` adapters (runtime model, then catalog model, then
|
|
139
|
+
catalog provider `npm`); a provider that reports no adapter counts as
|
|
140
|
+
OpenAI-compatible.
|
|
129
141
|
- The runtime credential is refused for providers listed in
|
|
130
142
|
`OWN_CREDENTIAL_HANDLING`. Their branches need the stored entry rather than
|
|
131
143
|
a bearer token: the clearest case is the ChatGPT-plan `openai` login, whose
|
|
@@ -20,6 +20,25 @@ const DEFAULT_MAX_OUTPUT_TOKENS = 4_000;
|
|
|
20
20
|
|
|
21
21
|
const USER_AGENT = 'opencode/1.0 openchamber';
|
|
22
22
|
|
|
23
|
+
// Providers whose endpoint lives inside their dedicated AI SDK package, so the
|
|
24
|
+
// models.dev catalog carries no `api` URL and OpenCode reports none at runtime.
|
|
25
|
+
// Each of these serves OpenAI-compatible `/chat/completions` at the URL below.
|
|
26
|
+
const SDK_DEFAULT_BASE_URLS = new Map([
|
|
27
|
+
['groq', 'https://api.groq.com/openai/v1'],
|
|
28
|
+
['xai', 'https://api.x.ai/v1'],
|
|
29
|
+
['mistral', 'https://api.mistral.ai/v1'],
|
|
30
|
+
['cerebras', 'https://api.cerebras.ai/v1'],
|
|
31
|
+
['togetherai', 'https://api.together.xyz/v1'],
|
|
32
|
+
['deepinfra', 'https://api.deepinfra.com/v1/openai'],
|
|
33
|
+
['perplexity', 'https://api.perplexity.ai'],
|
|
34
|
+
['cohere', 'https://api.cohere.ai/compatibility/v1'],
|
|
35
|
+
]);
|
|
36
|
+
|
|
37
|
+
// Where `thinking: { type: 'disabled' }` is a real switch rather than an
|
|
38
|
+
// unknown field (mirrors the gates in OpenCode's provider/transform.ts).
|
|
39
|
+
const ZAI_ENDPOINT_HOSTS = ['api.z.ai', 'bigmodel.cn'];
|
|
40
|
+
const MINIMAX_THINKING_ADAPTERS = new Set(['@ai-sdk/openai-compatible', '@ai-sdk/anthropic']);
|
|
41
|
+
|
|
23
42
|
const mergeHeadersCaseInsensitive = (base, overrides) => {
|
|
24
43
|
const merged = { ...base };
|
|
25
44
|
for (const [name, value] of Object.entries(overrides || {})) {
|
|
@@ -765,7 +784,8 @@ export async function callSmallModel({ auth, catalog, workingDirectory, sessionI
|
|
|
765
784
|
// selected model's endpoint OpenCode resolved at runtime, then to the
|
|
766
785
|
// provider-level runtime endpoint. For a plugin provider, the runtime listing
|
|
767
786
|
// is the only place those endpoints exist, and several are local proxies the
|
|
768
|
-
// plugin itself runs.
|
|
787
|
+
// plugin itself runs. Last comes SDK_DEFAULT_BASE_URLS, for providers whose
|
|
788
|
+
// endpoint only their SDK package knows. The openai provider also respects
|
|
769
789
|
// provider.openai.options.baseURL — OpenCode itself uses the same config for
|
|
770
790
|
// all providers including openai.
|
|
771
791
|
const provider = getCatalogProvider(catalog, providerID);
|
|
@@ -779,7 +799,7 @@ export async function callSmallModel({ auth, catalog, workingDirectory, sessionI
|
|
|
779
799
|
?? runtimeProvider?.baseURL
|
|
780
800
|
?? (typeof provider?.api === 'string' && provider.api
|
|
781
801
|
? provider.api
|
|
782
|
-
: null);
|
|
802
|
+
: SDK_DEFAULT_BASE_URLS.get(providerID) ?? null);
|
|
783
803
|
if (!baseURL) {
|
|
784
804
|
throw new Error(`Provider "${providerID}" has no known API base URL`);
|
|
785
805
|
}
|
|
@@ -790,11 +810,22 @@ export async function callSmallModel({ auth, catalog, workingDirectory, sessionI
|
|
|
790
810
|
// parameter: unknown body fields 400 on some providers, so this stays an
|
|
791
811
|
// explicit allowlist. Models without a switch (DeepSeek, Qwen, Kimi, …)
|
|
792
812
|
// just get the generous output budget.
|
|
793
|
-
|
|
794
|
-
|
|
813
|
+
// GLM's switch belongs to the Z.ai/Zhipu endpoints, not to the model: the
|
|
814
|
+
// same GLM served by another provider (OpenCode Go) rejects the field. The
|
|
815
|
+
// host check keeps the switch for a custom-named provider pointed at them.
|
|
816
|
+
const servedByZai = providerID.includes('zai')
|
|
795
817
|
|| providerID.includes('zhipu')
|
|
796
|
-
||
|
|
797
|
-
|
|
818
|
+
|| ZAI_ENDPOINT_HOSTS.some((host) => baseURL.includes(host));
|
|
819
|
+
// MiniMax M3's switch is understood only behind the adapters OpenCode sends
|
|
820
|
+
// it through. An adapter nobody reports (a custom provider) is OpenAI-
|
|
821
|
+
// compatible by OpenCode's own default.
|
|
822
|
+
const adapter = runtimeModel?.api?.npm
|
|
823
|
+
?? provider?.models?.[modelID]?.provider?.npm
|
|
824
|
+
?? provider?.npm
|
|
825
|
+
?? null;
|
|
826
|
+
const minimaxSwitch = modelID.toLowerCase().includes('minimax-m3')
|
|
827
|
+
&& (adapter === null || MINIMAX_THINKING_ADAPTERS.has(adapter));
|
|
828
|
+
const supportsThinkingToggle = servedByZai || minimaxSwitch;
|
|
798
829
|
const extraBody = supportsThinkingToggle ? { thinking: { type: 'disabled' } } : undefined;
|
|
799
830
|
|
|
800
831
|
return callOpenaiCompatible({
|