@openchamber/web 1.14.0 → 1.14.1
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/{DiagramView-CIaZCGUT.js → DiagramView-Cb58svCq.js} +1 -1
- package/dist/assets/MarkdownRendererImpl-D2yCDL5A.js +7 -0
- package/dist/assets/{MultiRunWindow-Bsbr3i8y.js → MultiRunWindow-BPSxV_B7.js} +1 -1
- package/dist/assets/{OnboardingScreen-3IAKkM5k.js → OnboardingScreen-Sl-6JgaP.js} +1 -1
- package/dist/assets/{SessionSwitcherDropdown-CLm6tF5n.js → SessionSwitcherDropdown-4FWg9xMC.js} +1 -1
- package/dist/assets/{SettingsWindow-K-ErjehP.js → SettingsWindow-CY8q4msv.js} +1 -1
- package/dist/assets/{TerminalView-DF7-jlam.js → TerminalView-fTYjnQkh.js} +1 -1
- package/dist/assets/{es-DQIFCjC2.js → es-bWcuDy_2.js} +1 -1
- package/dist/assets/{fr-CJRav0LS.js → fr-DzRs3OzV.js} +2 -2
- package/dist/assets/index-KnWk9fmM.css +1 -0
- package/dist/assets/index-ZJTzZ0_U.js +2 -0
- package/dist/assets/{ja-CjAaqvHO.js → ja-BqUX_UD3.js} +2 -2
- package/dist/assets/{ko-BEbFxvrd.js → ko-BQo10SNx.js} +2 -2
- package/dist/assets/main-BDoqLlQB.js +236 -0
- package/dist/assets/{main-C2put7uQ.js → main-DUGyTrDt.js} +2 -2
- package/dist/assets/miniChat-DNDiX8GA.js +2 -0
- package/dist/assets/mobile-DnghtOCb.js +2 -0
- package/dist/assets/pl-Bgx_ATJT.js +15 -0
- package/dist/assets/{pt-BR-9Sk3esQZ.js → pt-BR-B1yXRvoX.js} +1 -1
- package/dist/assets/{renderElectronMiniChatApp-CdDj0ms1.js → renderElectronMiniChatApp-BB4C1K7t.js} +2 -2
- package/dist/assets/renderMobileApp-CZgaXKi5.js +16 -0
- package/dist/assets/runtimeEndpointReset-By39StyB.js +167 -0
- package/dist/assets/{uk-DW_dTfoO.js → uk-C9k8SP8q.js} +1 -1
- package/dist/assets/{useAppFontEffects-DTO332li.js → useAppFontEffects-BUUJYbAZ.js} +129 -117
- package/dist/assets/{zh-CN-r2_euV7U.js → zh-CN-Bri-Vo5y.js} +1 -1
- package/dist/assets/{zh-TW-BdPx3NWh.js → zh-TW-DAUGzmYG.js} +1 -1
- package/dist/index.html +3 -3
- package/dist/mini-chat.html +3 -3
- package/dist/mobile.html +3 -3
- package/package.json +1 -1
- package/server/index.js +27 -5
- package/server/lib/opencode/core-routes.js +1 -0
- package/server/lib/opencode/feature-routes-runtime.js +10 -0
- package/server/lib/opencode/models-metadata.js +61 -0
- package/server/lib/opencode/openchamber-routes.js +7 -40
- package/server/lib/opencode/settings-helpers.js +13 -0
- package/server/lib/opencode/shutdown-runtime.js +2 -0
- package/server/lib/session-assist/DOCUMENTATION.md +66 -0
- package/server/lib/session-assist/runtime.js +394 -0
- package/server/lib/small-model/DOCUMENTATION.md +78 -0
- package/server/lib/small-model/call.js +380 -0
- package/server/lib/small-model/catalog.js +13 -0
- package/server/lib/small-model/index.js +167 -0
- package/server/lib/small-model/resolve.js +131 -0
- package/server/lib/small-model/resolve.test.js +197 -0
- package/server/lib/small-model/routes.js +44 -0
- package/dist/assets/MarkdownRendererImpl-DWgOeIpO.js +0 -7
- package/dist/assets/index-5eUDDB6w.js +0 -2
- package/dist/assets/index-CgpE7F8T.css +0 -1
- package/dist/assets/main-DuQEoz31.js +0 -214
- package/dist/assets/miniChat-o3AAQ-8r.js +0 -2
- package/dist/assets/mobile-X0421aWz.js +0 -2
- package/dist/assets/pl-D4kzai5T.js +0 -15
- package/dist/assets/renderMobileApp-cZ_HZKSe.js +0 -16
- package/dist/assets/runtimeEndpointReset-BYLVW9e7.js +0 -167
package/dist/index.html
CHANGED
|
@@ -515,11 +515,11 @@
|
|
|
515
515
|
pointer-events: none;
|
|
516
516
|
}
|
|
517
517
|
</style>
|
|
518
|
-
<script type="module" crossorigin src="/assets/main-
|
|
518
|
+
<script type="module" crossorigin src="/assets/main-DUGyTrDt.js"></script>
|
|
519
519
|
<link rel="modulepreload" crossorigin href="/assets/vendor-.bun-C6iL44L9.js">
|
|
520
|
-
<link rel="modulepreload" crossorigin href="/assets/index-
|
|
520
|
+
<link rel="modulepreload" crossorigin href="/assets/index-ZJTzZ0_U.js">
|
|
521
521
|
<link rel="modulepreload" crossorigin href="/assets/mobileLayoutPreference-Dio-WWkI.js">
|
|
522
|
-
<link rel="stylesheet" crossorigin href="/assets/index-
|
|
522
|
+
<link rel="stylesheet" crossorigin href="/assets/index-KnWk9fmM.css">
|
|
523
523
|
</head>
|
|
524
524
|
<body class="h-full bg-background text-foreground">
|
|
525
525
|
<div id="root" class="h-full">
|
package/dist/mini-chat.html
CHANGED
|
@@ -74,10 +74,10 @@
|
|
|
74
74
|
}
|
|
75
75
|
</style>
|
|
76
76
|
|
|
77
|
-
<script type="module" crossorigin src="/assets/miniChat-
|
|
77
|
+
<script type="module" crossorigin src="/assets/miniChat-DNDiX8GA.js"></script>
|
|
78
78
|
<link rel="modulepreload" crossorigin href="/assets/vendor-.bun-C6iL44L9.js">
|
|
79
|
-
<link rel="modulepreload" crossorigin href="/assets/index-
|
|
80
|
-
<link rel="stylesheet" crossorigin href="/assets/index-
|
|
79
|
+
<link rel="modulepreload" crossorigin href="/assets/index-ZJTzZ0_U.js">
|
|
80
|
+
<link rel="stylesheet" crossorigin href="/assets/index-KnWk9fmM.css">
|
|
81
81
|
</head>
|
|
82
82
|
<body class="h-full bg-background text-foreground">
|
|
83
83
|
<div id="root" class="h-full">
|
package/dist/mobile.html
CHANGED
|
@@ -63,10 +63,10 @@
|
|
|
63
63
|
})();
|
|
64
64
|
</script>
|
|
65
65
|
|
|
66
|
-
<script type="module" crossorigin src="/assets/mobile-
|
|
66
|
+
<script type="module" crossorigin src="/assets/mobile-DnghtOCb.js"></script>
|
|
67
67
|
<link rel="modulepreload" crossorigin href="/assets/vendor-.bun-C6iL44L9.js">
|
|
68
|
-
<link rel="modulepreload" crossorigin href="/assets/index-
|
|
69
|
-
<link rel="stylesheet" crossorigin href="/assets/index-
|
|
68
|
+
<link rel="modulepreload" crossorigin href="/assets/index-ZJTzZ0_U.js">
|
|
69
|
+
<link rel="stylesheet" crossorigin href="/assets/index-KnWk9fmM.css">
|
|
70
70
|
</head>
|
|
71
71
|
<body class="h-full bg-background text-foreground">
|
|
72
72
|
<div id="root" class="h-full"></div>
|
package/package.json
CHANGED
package/server/index.js
CHANGED
|
@@ -72,6 +72,7 @@ import { createOpenCodeResolutionRuntime } from './lib/opencode/opencode-resolut
|
|
|
72
72
|
import { createBootstrapRuntime } from './lib/opencode/bootstrap-runtime.js';
|
|
73
73
|
import { createSessionRuntime } from './lib/opencode/session-runtime.js';
|
|
74
74
|
import { createOpenCodeWatcherRuntime } from './lib/opencode/watcher.js';
|
|
75
|
+
import { createSessionAssistRuntime } from './lib/session-assist/runtime.js';
|
|
75
76
|
import { createScheduledTasksRuntime } from './lib/scheduled-tasks/runtime.js';
|
|
76
77
|
import { createServerStartupRuntime } from './lib/opencode/server-startup-runtime.js';
|
|
77
78
|
import { createTunnelWiringRuntime } from './lib/opencode/tunnel-wiring-runtime.js';
|
|
@@ -713,6 +714,12 @@ const maybeSendPushForTrigger = (...args) => notificationTriggerRuntime.maybeSen
|
|
|
713
714
|
const setAutoAcceptSession = (...args) => notificationTriggerRuntime.setAutoAcceptSession(...args);
|
|
714
715
|
clearPendingPushBadge = () => notificationTriggerRuntime.clearPendingPushBadge();
|
|
715
716
|
|
|
717
|
+
const sessionAssistRuntime = createSessionAssistRuntime({
|
|
718
|
+
buildOpenCodeUrl,
|
|
719
|
+
getOpenCodeAuthHeaders,
|
|
720
|
+
getSmallModelService: async () => import('./lib/small-model/index.js'),
|
|
721
|
+
});
|
|
722
|
+
|
|
716
723
|
const globalMessageStreamHub = createGlobalMessageStreamHub({
|
|
717
724
|
buildOpenCodeUrl,
|
|
718
725
|
getOpenCodeAuthHeaders,
|
|
@@ -732,6 +739,19 @@ const openCodeWatcherRuntime = createOpenCodeWatcherRuntime({
|
|
|
732
739
|
},
|
|
733
740
|
});
|
|
734
741
|
|
|
742
|
+
// Session-assist subscribes to the hub directly: it needs the envelope's
|
|
743
|
+
// directory to route its own OpenCode calls to the right instance.
|
|
744
|
+
console.log('[session-assist] listening for session events');
|
|
745
|
+
globalMessageStreamHub.subscribeEvent((event) => {
|
|
746
|
+
const raw = event?.payload;
|
|
747
|
+
const payload = raw?.payload && typeof raw.payload === 'object' ? raw.payload : raw;
|
|
748
|
+
if (!payload || typeof payload !== 'object') return;
|
|
749
|
+
const directory = typeof event?.directory === 'string' && event.directory && event.directory !== 'global'
|
|
750
|
+
? event.directory
|
|
751
|
+
: '';
|
|
752
|
+
sessionAssistRuntime.processPayload(payload, directory);
|
|
753
|
+
});
|
|
754
|
+
|
|
735
755
|
const processForwardedEventPayload = (payload, emitSyntheticEvent) => {
|
|
736
756
|
if (!payload || typeof payload !== 'object' || typeof emitSyntheticEvent !== 'function') {
|
|
737
757
|
return;
|
|
@@ -1014,11 +1034,12 @@ const bootstrapOpenCodeAtStartup = async (...args) => {
|
|
|
1014
1034
|
if (openCodeLifecycleState.openCodeProcess && !openCodeLifecycleState.isExternalOpenCode) {
|
|
1015
1035
|
startHealthMonitoring();
|
|
1016
1036
|
}
|
|
1017
|
-
|
|
1018
|
-
|
|
1019
|
-
|
|
1020
|
-
|
|
1021
|
-
|
|
1037
|
+
// The global watcher used to start only for desktop notifications; the
|
|
1038
|
+
// session-assist runtime also rides its event hub, so it now starts
|
|
1039
|
+
// unconditionally once OpenCode is up.
|
|
1040
|
+
void ensureGlobalWatcherStarted().catch((error) => {
|
|
1041
|
+
console.warn(`Global event watcher startup failed: ${error?.message || error}`);
|
|
1042
|
+
});
|
|
1022
1043
|
};
|
|
1023
1044
|
const killProcessOnPort = (...args) => openCodeLifecycleRuntime.killProcessOnPort(...args);
|
|
1024
1045
|
const waitForPortRelease = (...args) => openCodeLifecycleRuntime.waitForPortRelease(...args);
|
|
@@ -1037,6 +1058,7 @@ const gracefulShutdownRuntime = createGracefulShutdownRuntime({
|
|
|
1037
1058
|
},
|
|
1038
1059
|
syncToHmrState,
|
|
1039
1060
|
openCodeWatcherRuntime,
|
|
1061
|
+
sessionAssistRuntime,
|
|
1040
1062
|
sessionRuntime,
|
|
1041
1063
|
getHealthCheckInterval: () => healthCheckInterval,
|
|
1042
1064
|
clearHealthCheckInterval: (value) => clearInterval(value),
|
|
@@ -759,6 +759,7 @@ export const registerCommonRequestMiddleware = (app, dependencies) => {
|
|
|
759
759
|
req.path.startsWith('/api/push') ||
|
|
760
760
|
req.path.startsWith('/api/notifications') ||
|
|
761
761
|
req.path.startsWith('/api/session-folders') ||
|
|
762
|
+
req.path.startsWith('/api/small-model') ||
|
|
762
763
|
req.path.startsWith('/api/text') ||
|
|
763
764
|
req.path.startsWith('/api/voice') ||
|
|
764
765
|
req.path.startsWith('/api/tts') ||
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { registerFsRoutes } from '../fs/routes.js';
|
|
2
2
|
import { registerQuotaRoutes } from '../quota/routes.js';
|
|
3
|
+
import { registerSmallModelRoutes } from '../small-model/routes.js';
|
|
3
4
|
import { registerGitHubRoutes } from '../github/routes.js';
|
|
4
5
|
import { registerGitRoutes } from '../git/routes.js';
|
|
5
6
|
import { registerMagicPromptRoutes } from '../magic-prompts/routes.js';
|
|
@@ -54,6 +55,14 @@ export const createFeatureRoutesRuntime = (dependencies) => {
|
|
|
54
55
|
return quotaProviders;
|
|
55
56
|
};
|
|
56
57
|
|
|
58
|
+
let smallModelService = null;
|
|
59
|
+
const getSmallModelService = async () => {
|
|
60
|
+
if (!smallModelService) {
|
|
61
|
+
smallModelService = await import('../small-model/index.js');
|
|
62
|
+
}
|
|
63
|
+
return smallModelService;
|
|
64
|
+
};
|
|
65
|
+
|
|
57
66
|
const registerRoutes = async (app, routeDependencies) => {
|
|
58
67
|
const {
|
|
59
68
|
crypto,
|
|
@@ -226,6 +235,7 @@ export const createFeatureRoutesRuntime = (dependencies) => {
|
|
|
226
235
|
});
|
|
227
236
|
|
|
228
237
|
registerQuotaRoutes(app, { getQuotaProviders });
|
|
238
|
+
registerSmallModelRoutes(app, { getSmallModelService });
|
|
229
239
|
registerGitHubRoutes(app);
|
|
230
240
|
registerGitRoutes(app);
|
|
231
241
|
registerMagicPromptRoutes(app, {
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
const MODELS_DEV_API_URL = 'https://models.dev/api.json';
|
|
2
|
+
const DEFAULT_TTL_MS = 10 * 60 * 1000;
|
|
3
|
+
const DEFAULT_TIMEOUT_MS = 8000;
|
|
4
|
+
|
|
5
|
+
// Shared in-process cache of the models.dev catalog. Used by the
|
|
6
|
+
// /api/openchamber/models-metadata route and the small-model resolver so the
|
|
7
|
+
// server fetches the catalog once, not per consumer.
|
|
8
|
+
let cachedMetadata = null;
|
|
9
|
+
let cachedAt = 0;
|
|
10
|
+
let inflight = null;
|
|
11
|
+
|
|
12
|
+
const fetchCatalog = async (url, timeoutMs) => {
|
|
13
|
+
const response = await fetch(url, {
|
|
14
|
+
headers: { Accept: 'application/json' },
|
|
15
|
+
signal: AbortSignal.timeout(timeoutMs),
|
|
16
|
+
});
|
|
17
|
+
if (!response.ok) {
|
|
18
|
+
throw new Error(`models.dev responded with status ${response.status}`);
|
|
19
|
+
}
|
|
20
|
+
const metadata = await response.json();
|
|
21
|
+
if (!metadata || typeof metadata !== 'object') {
|
|
22
|
+
throw new Error('models.dev returned an unexpected payload');
|
|
23
|
+
}
|
|
24
|
+
return metadata;
|
|
25
|
+
};
|
|
26
|
+
|
|
27
|
+
/**
|
|
28
|
+
* Returns the models.dev catalog, serving the in-memory copy while fresh.
|
|
29
|
+
* On fetch failure a stale cached copy is returned when available; otherwise
|
|
30
|
+
* the error propagates.
|
|
31
|
+
*/
|
|
32
|
+
export async function getModelsMetadata({
|
|
33
|
+
url = MODELS_DEV_API_URL,
|
|
34
|
+
ttlMs = DEFAULT_TTL_MS,
|
|
35
|
+
timeoutMs = DEFAULT_TIMEOUT_MS,
|
|
36
|
+
} = {}) {
|
|
37
|
+
const now = Date.now();
|
|
38
|
+
if (cachedMetadata && now - cachedAt < ttlMs) {
|
|
39
|
+
return { metadata: cachedMetadata, fromCache: true };
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
if (!inflight) {
|
|
43
|
+
inflight = fetchCatalog(url, timeoutMs).finally(() => {
|
|
44
|
+
inflight = null;
|
|
45
|
+
});
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
try {
|
|
49
|
+
const metadata = await inflight;
|
|
50
|
+
cachedMetadata = metadata;
|
|
51
|
+
cachedAt = Date.now();
|
|
52
|
+
return { metadata, fromCache: false };
|
|
53
|
+
} catch (error) {
|
|
54
|
+
if (cachedMetadata) {
|
|
55
|
+
return { metadata: cachedMetadata, fromCache: true, stale: true };
|
|
56
|
+
}
|
|
57
|
+
throw error;
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
export { MODELS_DEV_API_URL };
|
|
@@ -13,9 +13,6 @@ export const registerOpenChamberRoutes = (app, dependencies) => {
|
|
|
13
13
|
getCachedZenModels,
|
|
14
14
|
} = dependencies;
|
|
15
15
|
|
|
16
|
-
let cachedModelsMetadata = null;
|
|
17
|
-
let cachedModelsMetadataTimestamp = 0;
|
|
18
|
-
|
|
19
16
|
app.get('/api/openchamber/update-check', async (req, res) => {
|
|
20
17
|
try {
|
|
21
18
|
const { checkForUpdates } = await import('../package-manager.js');
|
|
@@ -254,48 +251,18 @@ export const registerOpenChamberRoutes = (app, dependencies) => {
|
|
|
254
251
|
});
|
|
255
252
|
|
|
256
253
|
app.get('/api/openchamber/models-metadata', async (_req, res) => {
|
|
257
|
-
const now = Date.now();
|
|
258
|
-
|
|
259
|
-
if (cachedModelsMetadata && now - cachedModelsMetadataTimestamp < modelsMetadataCacheTtl) {
|
|
260
|
-
res.setHeader('Cache-Control', 'public, max-age=60');
|
|
261
|
-
return res.json(cachedModelsMetadata);
|
|
262
|
-
}
|
|
263
|
-
|
|
264
|
-
const controller = typeof AbortController !== 'undefined' ? new AbortController() : null;
|
|
265
|
-
const timeout = controller ? setTimeout(() => controller.abort(), 8000) : null;
|
|
266
|
-
|
|
267
254
|
try {
|
|
268
|
-
const
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
}
|
|
255
|
+
const { getModelsMetadata } = await import('./models-metadata.js');
|
|
256
|
+
const { metadata, fromCache, stale } = await getModelsMetadata({
|
|
257
|
+
url: modelsDevApiUrl,
|
|
258
|
+
ttlMs: modelsMetadataCacheTtl,
|
|
273
259
|
});
|
|
274
|
-
|
|
275
|
-
if (!response.ok) {
|
|
276
|
-
throw new Error(`models.dev responded with status ${response.status}`);
|
|
277
|
-
}
|
|
278
|
-
|
|
279
|
-
const metadata = await response.json();
|
|
280
|
-
cachedModelsMetadata = metadata;
|
|
281
|
-
cachedModelsMetadataTimestamp = Date.now();
|
|
282
|
-
|
|
283
|
-
res.setHeader('Cache-Control', 'public, max-age=300');
|
|
260
|
+
res.setHeader('Cache-Control', fromCache && !stale ? 'public, max-age=60' : 'public, max-age=300');
|
|
284
261
|
res.json(metadata);
|
|
285
262
|
} catch (error) {
|
|
286
263
|
console.warn('Failed to fetch models.dev metadata via server:', error);
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
res.setHeader('Cache-Control', 'public, max-age=60');
|
|
290
|
-
res.json(cachedModelsMetadata);
|
|
291
|
-
} else {
|
|
292
|
-
const statusCode = error?.name === 'AbortError' ? 504 : 502;
|
|
293
|
-
res.status(statusCode).json({ error: 'Failed to retrieve model metadata' });
|
|
294
|
-
}
|
|
295
|
-
} finally {
|
|
296
|
-
if (timeout) {
|
|
297
|
-
clearTimeout(timeout);
|
|
298
|
-
}
|
|
264
|
+
const statusCode = error?.name === 'TimeoutError' || error?.name === 'AbortError' ? 504 : 502;
|
|
265
|
+
res.status(statusCode).json({ error: 'Failed to retrieve model metadata' });
|
|
299
266
|
}
|
|
300
267
|
});
|
|
301
268
|
|
|
@@ -245,6 +245,12 @@ export const createSettingsHelpers = (dependencies) => {
|
|
|
245
245
|
if (typeof candidate.showReasoningTraces === 'boolean') {
|
|
246
246
|
result.showReasoningTraces = candidate.showReasoningTraces;
|
|
247
247
|
}
|
|
248
|
+
if (typeof candidate.sessionRecapEnabled === 'boolean') {
|
|
249
|
+
result.sessionRecapEnabled = candidate.sessionRecapEnabled;
|
|
250
|
+
}
|
|
251
|
+
if (typeof candidate.sessionSuggestionEnabled === 'boolean') {
|
|
252
|
+
result.sessionSuggestionEnabled = candidate.sessionSuggestionEnabled;
|
|
253
|
+
}
|
|
248
254
|
if (typeof candidate.collapsibleThinkingBlocks === 'boolean') {
|
|
249
255
|
result.collapsibleThinkingBlocks = candidate.collapsibleThinkingBlocks;
|
|
250
256
|
}
|
|
@@ -374,6 +380,13 @@ export const createSettingsHelpers = (dependencies) => {
|
|
|
374
380
|
const trimmed = candidate.defaultAgent.trim();
|
|
375
381
|
result.defaultAgent = trimmed.length > 0 ? trimmed : undefined;
|
|
376
382
|
}
|
|
383
|
+
if (typeof candidate.smallModelUseDefault === 'boolean') {
|
|
384
|
+
result.smallModelUseDefault = candidate.smallModelUseDefault;
|
|
385
|
+
}
|
|
386
|
+
if (typeof candidate.smallModelOverride === 'string') {
|
|
387
|
+
const trimmed = candidate.smallModelOverride.trim();
|
|
388
|
+
result.smallModelOverride = trimmed.length > 0 ? trimmed : undefined;
|
|
389
|
+
}
|
|
377
390
|
if (typeof candidate.defaultGitIdentityId === 'string') {
|
|
378
391
|
const trimmed = candidate.defaultGitIdentityId.trim();
|
|
379
392
|
result.defaultGitIdentityId = trimmed.length > 0 ? trimmed : undefined;
|
|
@@ -8,6 +8,7 @@ export const createGracefulShutdownRuntime = (dependencies) => {
|
|
|
8
8
|
syncToHmrState,
|
|
9
9
|
openCodeWatcherRuntime,
|
|
10
10
|
sessionRuntime,
|
|
11
|
+
sessionAssistRuntime,
|
|
11
12
|
scheduledTasksRuntime,
|
|
12
13
|
getHealthCheckInterval,
|
|
13
14
|
clearHealthCheckInterval,
|
|
@@ -41,6 +42,7 @@ export const createGracefulShutdownRuntime = (dependencies) => {
|
|
|
41
42
|
|
|
42
43
|
openCodeWatcherRuntime.stop();
|
|
43
44
|
sessionRuntime.dispose();
|
|
45
|
+
sessionAssistRuntime?.stop?.();
|
|
44
46
|
scheduledTasksRuntime?.stop?.();
|
|
45
47
|
|
|
46
48
|
const healthCheckInterval = getHealthCheckInterval();
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
# Session Assist
|
|
2
|
+
|
|
3
|
+
Server-side watcher that generates a short recap of the agent's last reply
|
|
4
|
+
and one suggested user follow-up with the small model
|
|
5
|
+
(`lib/small-model`), storing both on the session's metadata under
|
|
6
|
+
`metadata.openchamber.assist`.
|
|
7
|
+
|
|
8
|
+
## Flow
|
|
9
|
+
|
|
10
|
+
1. `createSessionAssistRuntime` is a consumer of the server's global SSE
|
|
11
|
+
fan-out (`index.js` → `onPayload`), riding the same upstream connection as
|
|
12
|
+
notifications. Purely event-driven — dormant sessions never generate
|
|
13
|
+
anything, there is no backfill and no session scanning.
|
|
14
|
+
2. `session.status: idle` arms a 60-second per-session timer; any `busy`/
|
|
15
|
+
`retry` status or a user `message.updated` clears it (the "1 minute of
|
|
16
|
+
quiet" rule).
|
|
17
|
+
3. On fire: fetch the session (skip sub-agent sessions with `parentID`),
|
|
18
|
+
take the LAST exchange only — the final assistant reply plus the user
|
|
19
|
+
message it answered (assistant `parentID` → user id) — and call
|
|
20
|
+
`generateSmallModelText` with the
|
|
21
|
+
session's own provider/model taken from the last assistant message — so
|
|
22
|
+
the utility call spends the same subscription as the conversation.
|
|
23
|
+
`restrictToPreferredProvider` forbids the resolver's global fallback:
|
|
24
|
+
conversation content never goes to a provider the user didn't pick for
|
|
25
|
+
the session, unless the small model was chosen explicitly (settings
|
|
26
|
+
override or opencode config). A resolver 404 is silently skipped.
|
|
27
|
+
4. The requested JSON fields (`recap`, `suggestion`, or both) are clamped and
|
|
28
|
+
PATCHed onto the session metadata together with `forMessageID` (the last
|
|
29
|
+
assistant message id) and `generatedAt`. Before writing, the session tail is
|
|
30
|
+
re-checked (a stale result is dropped) and the metadata is merged from a
|
|
31
|
+
fresh session read so concurrent metadata writes made during generation are
|
|
32
|
+
preserved.
|
|
33
|
+
|
|
34
|
+
## Settings gate
|
|
35
|
+
|
|
36
|
+
`sessionRecapEnabled` and `sessionSuggestionEnabled` in OpenChamber settings
|
|
37
|
+
(Settings → Chat, default on) are hard generation switches checked at fire
|
|
38
|
+
time. When both are off, no small-model calls run and nothing is written. When
|
|
39
|
+
one is on, the runtime still makes at most one small-model call and asks only
|
|
40
|
+
for that field. The UI also hides disabled payload types immediately.
|
|
41
|
+
|
|
42
|
+
## Freshness contract (no clearing writes)
|
|
43
|
+
|
|
44
|
+
Clients do not need the payload to be deleted: they render it only while
|
|
45
|
+
`assist.forMessageID` still equals the session's last assistant message id
|
|
46
|
+
(and the session is idle). Any new message invalidates the payload
|
|
47
|
+
everywhere instantly and offline; the next idle cycle overwrites it.
|
|
48
|
+
|
|
49
|
+
## UI consumers (packages/ui)
|
|
50
|
+
|
|
51
|
+
- `lib/sessionAssistMetadata.ts` — payload parsing.
|
|
52
|
+
- `hooks/useSessionAssist.ts` — freshness gating + the 1-minute quiet window
|
|
53
|
+
for the recap (single timeout to the boundary, no polling).
|
|
54
|
+
- `components/chat/SessionRecapSpacer.tsx` — renders the recap inside the
|
|
55
|
+
fixed-height reserved gap under the last message (height never changes).
|
|
56
|
+
- `components/chat/SessionSuggestionChip.tsx` — one tappable suggestion chip
|
|
57
|
+
near the composer (desktop chips row + above the mobile pill); hidden as
|
|
58
|
+
soon as the composer has any content. Tap fills the input, never sends.
|
|
59
|
+
|
|
60
|
+
## Limitations
|
|
61
|
+
|
|
62
|
+
- The watcher lives in the web server, so VS Code (extension-only, no web
|
|
63
|
+
server) does not generate assists; it still renders payloads produced by a
|
|
64
|
+
web/desktop instance of the same OpenCode server via `session.updated`.
|
|
65
|
+
- Metadata payloads ride every `session.updated` event — keep the clamps
|
|
66
|
+
(`RECAP_CHAR_LIMIT`, `SUGGESTION_CHAR_LIMIT`) small.
|