@openchamber/web 1.15.0 → 1.16.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/README.md +5 -5
- package/dist/assets/{DiagramView-HR2xZxJ8.js → DiagramView-Elkp8b4l.js} +1 -1
- package/dist/assets/{MarkdownRendererImpl-sm01Q7R7.js → MarkdownRendererImpl-DLhrL6oX.js} +3 -3
- package/dist/assets/{MultiRunWindow-DlFUaNQK.js → MultiRunWindow-DVpNCqnE.js} +1 -1
- package/dist/assets/{OnboardingScreen-DVRz82mJ.js → OnboardingScreen-CpcR0gyq.js} +1 -1
- package/dist/assets/SessionSwitcherDropdown-DHO5Je6v.js +1 -0
- package/dist/assets/{SettingsWindow-CkInZcj7.js → SettingsWindow-Bewo7vwh.js} +1 -1
- package/dist/assets/{TerminalView-D_9BAjtv.js → TerminalView-D9C7fNLm.js} +3 -3
- package/dist/assets/es-D9nOo8Wx.js +15 -0
- package/dist/assets/fr-DEF71lgt.js +13 -0
- package/dist/assets/index-BklNmnVr.js +2 -0
- package/dist/assets/index-C3uMIExE.css +1 -0
- package/dist/assets/ja-CpNfaEje.js +15 -0
- package/dist/assets/ko-DLS_rnE-.js +15 -0
- package/dist/assets/main-B0CxEOP5.js +237 -0
- package/dist/assets/{main-DzNa8r0N.js → main-Ck3ZNw8-.js} +2 -2
- package/dist/assets/miniChat-BAJj2Ome.js +2 -0
- package/dist/assets/mobile-CJoX4Cdj.js +2 -0
- package/dist/assets/pl-BjtFn5-n.js +15 -0
- package/dist/assets/pt-BR-C0_4Rnzn.js +15 -0
- package/dist/assets/renderElectronMiniChatApp-D4-OXCXM.js +2 -0
- package/dist/assets/renderMobileApp-DHWdI195.js +16 -0
- package/dist/assets/runtimeEndpointReset-B0P2DED1.js +167 -0
- package/dist/assets/uk-BDu4E0s0.js +15 -0
- package/dist/assets/{useAppFontEffects-DzBg8hrC.js → useAppFontEffects-9LFMCKYW.js} +195 -136
- package/dist/assets/zh-CN-BcwMqxIR.js +15 -0
- package/dist/assets/zh-TW-bNDQjKEu.js +15 -0
- 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 +106 -1
- package/server/lib/notifications/DOCUMENTATION.md +1 -1
- package/server/lib/notifications/apns-runtime.js +3 -1
- package/server/lib/notifications/runtime.js +135 -33
- package/server/lib/opencode/DOCUMENTATION.md +1 -0
- package/server/lib/opencode/agents.js +3 -0
- package/server/lib/opencode/bootstrap-runtime.js +5 -0
- package/server/lib/opencode/core-routes.js +75 -2
- package/server/lib/opencode/core-routes.test.js +81 -0
- package/server/lib/opencode/feature-routes-runtime.js +6 -0
- package/server/lib/opencode/settings-helpers.js +30 -0
- package/server/lib/opencode/settings-helpers.test.js +14 -0
- package/server/lib/opencode/settings-normalization-runtime.js +19 -4
- package/server/lib/opencode/settings-normalization-runtime.test.js +21 -0
- package/server/lib/opencode/settings-runtime.js +25 -0
- package/server/lib/opencode/shutdown-runtime.js +2 -0
- package/server/lib/opencode/tunnel-auth.js +4 -9
- package/server/lib/package-manager.js +1 -1
- package/server/lib/permission-auto-accept/DOCUMENTATION.md +34 -0
- package/server/lib/permission-auto-accept/runtime.js +263 -0
- package/server/lib/permission-auto-accept/runtime.test.js +137 -0
- package/server/lib/projects/project-config.js +8 -0
- package/server/lib/quota/DOCUMENTATION.md +5 -2
- package/server/lib/quota/credentials/providers.js +43 -0
- package/server/lib/quota/credentials/store.js +48 -0
- package/server/lib/quota/credentials/store.test.js +26 -0
- package/server/lib/quota/opencode-go-credentials.js +11 -0
- package/server/lib/quota/opencode-go-credentials.test.js +32 -0
- package/server/lib/quota/providers/codex.js +7 -4
- package/server/lib/quota/providers/codex.test.js +48 -0
- package/server/lib/quota/providers/cursor.js +28 -39
- package/server/lib/quota/providers/index.js +7 -0
- package/server/lib/quota/providers/ollama-cloud.js +23 -42
- package/server/lib/quota/providers/ollama-cloud.test.js +12 -0
- package/server/lib/quota/providers/opencode-go.js +70 -0
- package/server/lib/quota/providers/opencode-go.test.js +17 -0
- package/server/lib/quota/routes.js +78 -7
- package/server/lib/quota/routes.test.js +40 -0
- package/server/lib/relay/DOCUMENTATION.md +20 -0
- package/server/lib/relay/host-lock.js +101 -0
- package/server/lib/relay/host-lock.test.js +129 -0
- package/server/lib/relay/identity.js +24 -4
- package/server/lib/relay/service.js +95 -8
- package/server/lib/relay/signing-key.js +30 -7
- package/server/lib/scheduled-tasks/runtime.js +104 -0
- package/server/lib/session-goal/DOCUMENTATION.md +176 -0
- package/server/lib/session-goal/objectives.js +61 -0
- package/server/lib/session-goal/routes.js +36 -0
- package/server/lib/session-goal/runtime.js +764 -0
- package/server/lib/small-model/DOCUMENTATION.md +3 -1
- package/server/lib/small-model/call.js +45 -8
- package/server/lib/small-model/call.test.js +338 -0
- package/server/lib/small-model/index.js +1 -0
- package/dist/assets/SessionSwitcherDropdown-DvoOalMY.js +0 -1
- package/dist/assets/es-cjUissX4.js +0 -15
- package/dist/assets/fr-DqbXnTdK.js +0 -13
- package/dist/assets/index-Dg0nmvQU.css +0 -1
- package/dist/assets/index-ltrmNGAf.js +0 -2
- package/dist/assets/ja-Cetyq6Eg.js +0 -15
- package/dist/assets/ko-DtunWisP.js +0 -15
- package/dist/assets/main-BC0m8s1v.js +0 -236
- package/dist/assets/miniChat-BRYDE-Se.js +0 -2
- package/dist/assets/mobile-C3QJVA97.js +0 -2
- package/dist/assets/pl-DctGLgve.js +0 -15
- package/dist/assets/pt-BR-CXPhf78S.js +0 -15
- package/dist/assets/renderElectronMiniChatApp-CVFbDC5A.js +0 -2
- package/dist/assets/renderMobileApp-wkBjh5WR.js +0 -16
- package/dist/assets/runtimeEndpointReset-C42u8PvG.js +0 -167
- package/dist/assets/uk-Bdrc-kqF.js +0 -15
- package/dist/assets/zh-CN-CeCVKrHP.js +0 -15
- package/dist/assets/zh-TW-CoqiQING.js +0 -15
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-Ck3ZNw8-.js"></script>
|
|
519
519
|
<link rel="modulepreload" crossorigin href="/assets/vendor-.bun-BE757pvp.js">
|
|
520
|
-
<link rel="modulepreload" crossorigin href="/assets/index-
|
|
520
|
+
<link rel="modulepreload" crossorigin href="/assets/index-BklNmnVr.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-C3uMIExE.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-BAJj2Ome.js"></script>
|
|
78
78
|
<link rel="modulepreload" crossorigin href="/assets/vendor-.bun-BE757pvp.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-BklNmnVr.js">
|
|
80
|
+
<link rel="stylesheet" crossorigin href="/assets/index-C3uMIExE.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-CJoX4Cdj.js"></script>
|
|
67
67
|
<link rel="modulepreload" crossorigin href="/assets/vendor-.bun-BE757pvp.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-BklNmnVr.js">
|
|
69
|
+
<link rel="stylesheet" crossorigin href="/assets/index-C3uMIExE.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
|
@@ -73,6 +73,7 @@ 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
75
|
import { createSessionAssistRuntime } from './lib/session-assist/runtime.js';
|
|
76
|
+
import { createSessionGoalRuntime } from './lib/session-goal/runtime.js';
|
|
76
77
|
import { createScheduledTasksRuntime } from './lib/scheduled-tasks/runtime.js';
|
|
77
78
|
import { createServerStartupRuntime } from './lib/opencode/server-startup-runtime.js';
|
|
78
79
|
import { createTunnelWiringRuntime } from './lib/opencode/tunnel-wiring-runtime.js';
|
|
@@ -84,6 +85,7 @@ import { createNotificationTriggerRuntime } from './lib/notifications/runtime.js
|
|
|
84
85
|
import { createPushRuntime } from './lib/notifications/push-runtime.js';
|
|
85
86
|
import { createApnsRuntime } from './lib/notifications/apns-runtime.js';
|
|
86
87
|
import { createNotificationTemplateRuntime } from './lib/notifications/template-runtime.js';
|
|
88
|
+
import { createPermissionAutoAcceptRuntime } from './lib/permission-auto-accept/runtime.js';
|
|
87
89
|
import { createGracefulShutdownRuntime } from './lib/opencode/shutdown-runtime.js';
|
|
88
90
|
import { createProjectConfigRuntime } from './lib/projects/project-config.js';
|
|
89
91
|
import { createRemoteClientAuthRuntime } from './lib/client-auth/remote-clients.js';
|
|
@@ -91,6 +93,7 @@ import { createClientPairingRuntime } from './lib/client-auth/pairing.js';
|
|
|
91
93
|
import { createPreviewProxyRuntime } from './lib/preview/proxy-runtime.js';
|
|
92
94
|
import { attachRealtimeProxy } from './lib/realtime-proxy.js';
|
|
93
95
|
import { createRelayService } from './lib/relay/service.js';
|
|
96
|
+
import { createRelayHostLock } from './lib/relay/host-lock.js';
|
|
94
97
|
import { createProxyMiddleware, responseInterceptor } from 'http-proxy-middleware';
|
|
95
98
|
import webPush from 'web-push';
|
|
96
99
|
|
|
@@ -363,6 +366,7 @@ const settingsRuntime = createSettingsRuntime({
|
|
|
363
366
|
|
|
364
367
|
const readSettingsFromDiskMigrated = (...args) => settingsRuntime.readSettingsFromDiskMigrated(...args);
|
|
365
368
|
const readSettingsFromDisk = (...args) => settingsRuntime.readSettingsFromDisk(...args);
|
|
369
|
+
const readSettingsFromDiskStrict = (...args) => settingsRuntime.readSettingsFromDiskStrict(...args);
|
|
366
370
|
const writeSettingsToDisk = (...args) => settingsRuntime.writeSettingsToDisk(...args);
|
|
367
371
|
const persistSettings = (...args) => settingsRuntime.persistSettings(...args);
|
|
368
372
|
|
|
@@ -407,6 +411,7 @@ const apnsRuntime = createApnsRuntime({
|
|
|
407
411
|
APNS_TOKENS_FILE_PATH,
|
|
408
412
|
readSettingsFromDiskMigrated,
|
|
409
413
|
writeSettingsToDisk,
|
|
414
|
+
readSettingsStrict: readSettingsFromDiskStrict,
|
|
410
415
|
});
|
|
411
416
|
|
|
412
417
|
const addOrUpdateApnsToken = (...args) => apnsRuntime.addOrUpdateApnsToken(...args);
|
|
@@ -715,7 +720,7 @@ const notificationTriggerRuntime = createNotificationTriggerRuntime({
|
|
|
715
720
|
});
|
|
716
721
|
|
|
717
722
|
const maybeSendPushForTrigger = (...args) => notificationTriggerRuntime.maybeSendPushForTrigger(...args);
|
|
718
|
-
const setAutoAcceptSession = (
|
|
723
|
+
const setAutoAcceptSession = (sessionId, enabled) => permissionAutoAcceptRuntime.setSessionPolicy(sessionId, enabled);
|
|
719
724
|
clearPendingPushBadge = () => notificationTriggerRuntime.clearPendingPushBadge();
|
|
720
725
|
|
|
721
726
|
const sessionAssistRuntime = createSessionAssistRuntime({
|
|
@@ -724,12 +729,65 @@ const sessionAssistRuntime = createSessionAssistRuntime({
|
|
|
724
729
|
getSmallModelService: async () => import('./lib/small-model/index.js'),
|
|
725
730
|
});
|
|
726
731
|
|
|
732
|
+
const sessionGoalRuntime = createSessionGoalRuntime({
|
|
733
|
+
buildOpenCodeUrl,
|
|
734
|
+
getOpenCodeAuthHeaders,
|
|
735
|
+
getSmallModelService: async () => import('./lib/small-model/index.js'),
|
|
736
|
+
emitGoalNotification: async ({ sessionId, directory, status, goal }) => {
|
|
737
|
+
// The goal settle notification replaces the per-turn ready notifications
|
|
738
|
+
// (suppressed while the goal is active) — so it obeys the same toggle.
|
|
739
|
+
const settings = await readSettingsFromDisk();
|
|
740
|
+
if (settings.notifyOnCompletion === false) {
|
|
741
|
+
return;
|
|
742
|
+
}
|
|
743
|
+
const title = status === 'complete'
|
|
744
|
+
? 'Goal complete'
|
|
745
|
+
: (status === 'budgetLimited' ? 'Goal reached its token budget' : 'Goal blocked');
|
|
746
|
+
const detail = goal?.statusReason && goal.statusReason !== 'verified by audit' && goal.statusReason !== 'reported by agent'
|
|
747
|
+
? goal.statusReason
|
|
748
|
+
: (goal?.note || '');
|
|
749
|
+
const objective = typeof goal?.objective === 'string' ? goal.objective.slice(0, 140) : '';
|
|
750
|
+
const notificationPayload = {
|
|
751
|
+
title,
|
|
752
|
+
body: [objective, detail].filter(Boolean).join(' — ').slice(0, 240),
|
|
753
|
+
tag: `goal-${sessionId}`,
|
|
754
|
+
kind: 'goal',
|
|
755
|
+
sessionId,
|
|
756
|
+
directory,
|
|
757
|
+
};
|
|
758
|
+
const desktopNotificationDelivered = emitDesktopNotification(notificationPayload);
|
|
759
|
+
broadcastUiNotification(notificationPayload, { desktopNotificationDelivered });
|
|
760
|
+
void notificationTriggerRuntime.sendGoalSettlePush({
|
|
761
|
+
sessionId,
|
|
762
|
+
directory,
|
|
763
|
+
status,
|
|
764
|
+
title,
|
|
765
|
+
body: notificationPayload.body,
|
|
766
|
+
}).catch((error) => {
|
|
767
|
+
console.warn('[session-goal] push fanout failed:', error?.message || error);
|
|
768
|
+
});
|
|
769
|
+
},
|
|
770
|
+
});
|
|
771
|
+
|
|
727
772
|
const globalMessageStreamHub = createGlobalMessageStreamHub({
|
|
728
773
|
buildOpenCodeUrl,
|
|
729
774
|
getOpenCodeAuthHeaders,
|
|
730
775
|
upstreamStallTimeoutMs: getUpstreamStallTimeoutMs,
|
|
731
776
|
});
|
|
732
777
|
|
|
778
|
+
const permissionAutoAcceptRuntime = createPermissionAutoAcceptRuntime({
|
|
779
|
+
globalEventHub: globalMessageStreamHub,
|
|
780
|
+
buildOpenCodeUrl,
|
|
781
|
+
getOpenCodeAuthHeaders,
|
|
782
|
+
readSettingsFromDiskMigrated,
|
|
783
|
+
persistSettings,
|
|
784
|
+
broadcastGlobalUiEvent,
|
|
785
|
+
});
|
|
786
|
+
permissionAutoAcceptRuntime.start();
|
|
787
|
+
notificationTriggerRuntime.setGetIsSessionAutoAccepting(
|
|
788
|
+
(sessionId, directory) => permissionAutoAcceptRuntime.isSessionAutoAccepting(sessionId, directory),
|
|
789
|
+
);
|
|
790
|
+
|
|
733
791
|
const openCodeWatcherRuntime = createOpenCodeWatcherRuntime({
|
|
734
792
|
waitForOpenCodePort: (...args) => waitForOpenCodePort(...args),
|
|
735
793
|
buildOpenCodeUrl,
|
|
@@ -754,6 +812,7 @@ globalMessageStreamHub.subscribeEvent((event) => {
|
|
|
754
812
|
? event.directory
|
|
755
813
|
: '';
|
|
756
814
|
sessionAssistRuntime.processPayload(payload, directory);
|
|
815
|
+
sessionGoalRuntime.processPayload(payload, directory);
|
|
757
816
|
});
|
|
758
817
|
|
|
759
818
|
const processForwardedEventPayload = (payload, emitSyntheticEvent) => {
|
|
@@ -1070,6 +1129,7 @@ const gracefulShutdownRuntime = createGracefulShutdownRuntime({
|
|
|
1070
1129
|
syncToHmrState,
|
|
1071
1130
|
openCodeWatcherRuntime,
|
|
1072
1131
|
sessionAssistRuntime,
|
|
1132
|
+
sessionGoalRuntime,
|
|
1073
1133
|
sessionRuntime,
|
|
1074
1134
|
getHealthCheckInterval: () => healthCheckInterval,
|
|
1075
1135
|
clearHealthCheckInterval: (value) => clearInterval(value),
|
|
@@ -1157,6 +1217,37 @@ async function main(options = {}) {
|
|
|
1157
1217
|
const lan = lanHost ? `http://${lanHost.includes(':') ? `[${lanHost}]` : lanHost}:${activePort}` : null;
|
|
1158
1218
|
return { local, lan, relayAvailable: true };
|
|
1159
1219
|
};
|
|
1220
|
+
// ALL direct LAN URLs this server is currently reachable on, for the
|
|
1221
|
+
// candidates-refresh endpoint: the address the requesting client already
|
|
1222
|
+
// reached us on first (guaranteed routable from its network — over the relay
|
|
1223
|
+
// tunnel this is loopback and yields nothing), then every non-internal IPv4
|
|
1224
|
+
// interface. A client that paired while the machine had a different DHCP
|
|
1225
|
+
// lease uses this to replace its stale LAN candidate.
|
|
1226
|
+
const resolveDirectLanUrls = (req) => {
|
|
1227
|
+
const activePort = tunnelRuntimeContext.getActivePort() || port;
|
|
1228
|
+
const urls = [];
|
|
1229
|
+
const push = (host) => {
|
|
1230
|
+
if (typeof host !== 'string' || !host) return;
|
|
1231
|
+
const url = `http://${host.includes(':') ? `[${host}]` : host}:${activePort}`;
|
|
1232
|
+
if (!urls.includes(url)) urls.push(url);
|
|
1233
|
+
};
|
|
1234
|
+
if (isNetworkExposedBindHost(effectiveBindHost)) {
|
|
1235
|
+
push(requestReachedLanAddress(req));
|
|
1236
|
+
try {
|
|
1237
|
+
for (const list of Object.values(os.networkInterfaces())) {
|
|
1238
|
+
for (const entry of (list || [])) {
|
|
1239
|
+
if (entry.family === 'IPv4' && !entry.internal) push(entry.address);
|
|
1240
|
+
}
|
|
1241
|
+
}
|
|
1242
|
+
} catch {
|
|
1243
|
+
// interface scan failure → whatever we already collected
|
|
1244
|
+
}
|
|
1245
|
+
} else {
|
|
1246
|
+
const h = String(effectiveBindHost || '').toLowerCase();
|
|
1247
|
+
if (h && h !== '127.0.0.1' && h !== 'localhost' && h !== '::1') push(effectiveBindHost);
|
|
1248
|
+
}
|
|
1249
|
+
return urls;
|
|
1250
|
+
};
|
|
1160
1251
|
const uiPassword = typeof options.uiPassword === 'string'
|
|
1161
1252
|
? options.uiPassword
|
|
1162
1253
|
: (typeof process.env.OPENCHAMBER_UI_PASSWORD === 'string' ? process.env.OPENCHAMBER_UI_PASSWORD : null);
|
|
@@ -1317,6 +1408,10 @@ async function main(options = {}) {
|
|
|
1317
1408
|
// redeemed device can flip relay demand on or off).
|
|
1318
1409
|
reconcileRelay: () => (relayServiceInstance ? relayServiceInstance.reconcile() : Promise.resolve()),
|
|
1319
1410
|
getPairingTransports: resolvePairingTransports,
|
|
1411
|
+
getDirectCandidateUrls: resolveDirectLanUrls,
|
|
1412
|
+
// Stable server identity for client-side verification of learned addresses.
|
|
1413
|
+
// Lazily resolved: the relay service is constructed after these routes.
|
|
1414
|
+
getServerId: () => (relayServiceInstance ? relayServiceInstance.getServerId() : Promise.resolve(null)),
|
|
1320
1415
|
// The display name a paired device shows for THIS server. Devices name the
|
|
1321
1416
|
// connection by the issuing machine's hostname, not the per-device pairing
|
|
1322
1417
|
// label typed by the operator.
|
|
@@ -1379,8 +1474,17 @@ async function main(options = {}) {
|
|
|
1379
1474
|
os,
|
|
1380
1475
|
readSettingsFromDiskMigrated,
|
|
1381
1476
|
writeSettingsToDisk,
|
|
1477
|
+
readSettingsStrict: readSettingsFromDiskStrict,
|
|
1382
1478
|
remoteClientAuthRuntime,
|
|
1383
1479
|
getLocalPort: () => tunnelRuntimeContext.getActivePort(),
|
|
1480
|
+
// One relay host per machine: every instance sharing this data dir shares
|
|
1481
|
+
// the relay identity (serverId), so concurrent hosts evict each other at
|
|
1482
|
+
// the relay worker and devices land on a random local instance.
|
|
1483
|
+
hostLock: createRelayHostLock({
|
|
1484
|
+
lockFilePath: path.join(OPENCHAMBER_DATA_DIR, 'relay-host.lock'),
|
|
1485
|
+
fs,
|
|
1486
|
+
process,
|
|
1487
|
+
}),
|
|
1384
1488
|
// Relay demand = any paired device or pending pairing session that uses the
|
|
1385
1489
|
// relay transport. Drives the auto on/off lifecycle.
|
|
1386
1490
|
hasRelayDemand: async () => {
|
|
@@ -1427,6 +1531,7 @@ async function main(options = {}) {
|
|
|
1427
1531
|
scheduledTasksRuntime,
|
|
1428
1532
|
getOpenChamberEventClients: () => uiOpenChamberEventClients,
|
|
1429
1533
|
writeSseEvent,
|
|
1534
|
+
permissionAutoAcceptRuntime,
|
|
1430
1535
|
});
|
|
1431
1536
|
|
|
1432
1537
|
const previewProxyRuntime = createPreviewProxyRuntime({
|
|
@@ -45,7 +45,7 @@ This module provides notification message preparation utilities for the web serv
|
|
|
45
45
|
- Returned API:
|
|
46
46
|
- `maybeSendPushForTrigger(payload)`
|
|
47
47
|
- Owns:
|
|
48
|
-
- completion/error/question/permission trigger routing
|
|
48
|
+
- completion/error/question/permission trigger routing; permission suppression consults the authoritative permission-auto-accept runtime
|
|
49
49
|
- session parent cache for subtask suppression
|
|
50
50
|
- template resolution and fallback behavior
|
|
51
51
|
- native notification fanout and web push payload fanout
|
|
@@ -42,6 +42,8 @@ export const createApnsRuntime = (deps) => {
|
|
|
42
42
|
APNS_TOKENS_FILE_PATH,
|
|
43
43
|
readSettingsFromDiskMigrated,
|
|
44
44
|
writeSettingsToDisk,
|
|
45
|
+
// Strict settings reader gating identity regeneration (see signing-key.js).
|
|
46
|
+
readSettingsStrict,
|
|
45
47
|
} = deps;
|
|
46
48
|
|
|
47
49
|
let persistLock = Promise.resolve();
|
|
@@ -60,7 +62,7 @@ export const createApnsRuntime = (deps) => {
|
|
|
60
62
|
// relay identity — same keypair, same storage, same serverId derivation).
|
|
61
63
|
const getOrCreateRelayKeypair = async () => {
|
|
62
64
|
if (cachedRelayKey) return cachedRelayKey;
|
|
63
|
-
cachedRelayKey = await getOrCreateRelaySigningKeypair({ crypto, readSettingsFromDiskMigrated, writeSettingsToDisk });
|
|
65
|
+
cachedRelayKey = await getOrCreateRelaySigningKeypair({ crypto, readSettingsFromDiskMigrated, writeSettingsToDisk, readSettingsStrict });
|
|
64
66
|
return cachedRelayKey;
|
|
65
67
|
};
|
|
66
68
|
|
|
@@ -15,6 +15,10 @@ export const createNotificationTriggerRuntime = (deps) => {
|
|
|
15
15
|
buildOpenCodeUrl,
|
|
16
16
|
getOpenCodeAuthHeaders,
|
|
17
17
|
} = deps;
|
|
18
|
+
let getIsSessionAutoAccepting = deps.getIsSessionAutoAccepting;
|
|
19
|
+
const setGetIsSessionAutoAccepting = (resolver) => {
|
|
20
|
+
getIsSessionAutoAccepting = typeof resolver === 'function' ? resolver : undefined;
|
|
21
|
+
};
|
|
18
22
|
|
|
19
23
|
// App-icon badge for native push: the set of DISTINCT collapse-ids (the push
|
|
20
24
|
// `tag`, e.g. `ready-<sessionId>` / `permission-<requestKey>`) we've sent since
|
|
@@ -50,6 +54,9 @@ export const createNotificationTriggerRuntime = (deps) => {
|
|
|
50
54
|
error: 'Agent hit an error',
|
|
51
55
|
question: 'Agent needs your input',
|
|
52
56
|
permission: 'Agent needs permission',
|
|
57
|
+
goal_complete: 'Goal complete',
|
|
58
|
+
goal_blocked: 'Goal blocked',
|
|
59
|
+
goal_budget: 'Goal reached its token budget',
|
|
53
60
|
};
|
|
54
61
|
|
|
55
62
|
const toApnsGenericPayload = (payload) => {
|
|
@@ -103,6 +110,7 @@ export const createNotificationTriggerRuntime = (deps) => {
|
|
|
103
110
|
const pushPermissionDebounceTimers = new Map();
|
|
104
111
|
const notifiedPermissionRequests = new Set();
|
|
105
112
|
const lastReadyNotificationAt = new Map();
|
|
113
|
+
const lastErrorNotificationAt = new Map();
|
|
106
114
|
|
|
107
115
|
const sessionParentIdCache = new Map();
|
|
108
116
|
const SESSION_PARENT_CACHE_TTL_MS = 60 * 1000;
|
|
@@ -129,24 +137,26 @@ export const createNotificationTriggerRuntime = (deps) => {
|
|
|
129
137
|
return `/?session=${encodeURIComponent(sessionId)}`;
|
|
130
138
|
};
|
|
131
139
|
|
|
132
|
-
const
|
|
133
|
-
|
|
140
|
+
const getSessionParentCacheKey = (sessionId, directory) => `${directory || ''}\0${sessionId}`;
|
|
141
|
+
|
|
142
|
+
const getCachedSessionParentId = (sessionId, directory) => {
|
|
143
|
+
const cacheKey = getSessionParentCacheKey(sessionId, directory);
|
|
144
|
+
const entry = sessionParentIdCache.get(cacheKey);
|
|
134
145
|
if (!entry) return undefined;
|
|
135
146
|
if (Date.now() - entry.at > SESSION_PARENT_CACHE_TTL_MS) {
|
|
136
|
-
sessionParentIdCache.delete(
|
|
147
|
+
sessionParentIdCache.delete(cacheKey);
|
|
137
148
|
return undefined;
|
|
138
149
|
}
|
|
139
150
|
return entry.parentID;
|
|
140
151
|
};
|
|
141
152
|
|
|
142
|
-
const setCachedSessionParentId = (sessionId, parentID) => {
|
|
143
|
-
|
|
144
|
-
sessionParentIdCache.set(sessionId, { parentID: parentID ?? null, at: Date.now() });
|
|
153
|
+
const setCachedSessionParentId = (sessionId, directory, parentID) => {
|
|
154
|
+
sessionParentIdCache.set(getSessionParentCacheKey(sessionId, directory), { parentID: parentID ?? null, at: Date.now() });
|
|
145
155
|
};
|
|
146
156
|
|
|
147
157
|
const getParentIdFromPayload = (payload) => {
|
|
148
|
-
if (!payload || typeof payload !== 'object') return
|
|
149
|
-
if (payload.type !== 'session.created' && payload.type !== 'session.updated') return
|
|
158
|
+
if (!payload || typeof payload !== 'object') return undefined;
|
|
159
|
+
if (payload.type !== 'session.created' && payload.type !== 'session.updated') return undefined;
|
|
150
160
|
const parentID = payload.properties?.info?.parentID ?? null;
|
|
151
161
|
return typeof parentID === 'string' && parentID.length > 0 ? parentID : null;
|
|
152
162
|
};
|
|
@@ -154,20 +164,22 @@ export const createNotificationTriggerRuntime = (deps) => {
|
|
|
154
164
|
const maybeCacheSessionParentFromPayload = (payload) => {
|
|
155
165
|
const sessionId = extractSessionIdFromPayload(payload);
|
|
156
166
|
if (typeof sessionId !== 'string' || sessionId.length === 0) return;
|
|
167
|
+
const directory = extractDirectoryFromPayload(payload);
|
|
157
168
|
const parentID = getParentIdFromPayload(payload);
|
|
158
|
-
if (parentID)
|
|
159
|
-
|
|
160
|
-
}
|
|
169
|
+
if (parentID === undefined) return;
|
|
170
|
+
setCachedSessionParentId(sessionId, directory, parentID);
|
|
161
171
|
};
|
|
162
172
|
|
|
163
|
-
const fetchSessionParentId = async (sessionId) => {
|
|
173
|
+
const fetchSessionParentId = async (sessionId, directory) => {
|
|
164
174
|
if (!sessionId) return undefined;
|
|
165
175
|
|
|
166
|
-
const cached = getCachedSessionParentId(sessionId);
|
|
176
|
+
const cached = getCachedSessionParentId(sessionId, directory);
|
|
167
177
|
if (cached !== undefined) return cached;
|
|
168
178
|
|
|
169
179
|
try {
|
|
170
|
-
const
|
|
180
|
+
const base = buildOpenCodeUrl(`/session/${encodeURIComponent(sessionId)}`, '');
|
|
181
|
+
const url = directory ? `${base}?directory=${encodeURIComponent(directory)}` : base;
|
|
182
|
+
const response = await fetch(url, {
|
|
171
183
|
method: 'GET',
|
|
172
184
|
headers: {
|
|
173
185
|
Accept: 'application/json',
|
|
@@ -178,21 +190,15 @@ export const createNotificationTriggerRuntime = (deps) => {
|
|
|
178
190
|
if (!response.ok) {
|
|
179
191
|
return undefined;
|
|
180
192
|
}
|
|
181
|
-
const
|
|
182
|
-
|
|
183
|
-
? data
|
|
184
|
-
: Array.isArray(data?.items)
|
|
185
|
-
? data.items
|
|
186
|
-
: Array.isArray(data?.data)
|
|
187
|
-
? data.data
|
|
188
|
-
: null;
|
|
189
|
-
if (!sessions) {
|
|
193
|
+
const session = await response.json().catch(() => null);
|
|
194
|
+
if (!session || typeof session !== 'object') {
|
|
190
195
|
return undefined;
|
|
191
196
|
}
|
|
192
197
|
|
|
193
|
-
const
|
|
194
|
-
|
|
195
|
-
|
|
198
|
+
const parentID = typeof session.parentID === 'string' && session.parentID.length > 0
|
|
199
|
+
? session.parentID
|
|
200
|
+
: null;
|
|
201
|
+
setCachedSessionParentId(sessionId, directory, parentID);
|
|
196
202
|
return parentID;
|
|
197
203
|
} catch {
|
|
198
204
|
return undefined;
|
|
@@ -201,14 +207,14 @@ export const createNotificationTriggerRuntime = (deps) => {
|
|
|
201
207
|
|
|
202
208
|
// Mirrors client-side autoRespondsPermission: a session auto-accepts if it
|
|
203
209
|
// OR any ancestor is flagged. Walks the parent chain via fetchSessionParentId.
|
|
204
|
-
const isSessionAutoAccepting = async (sessionId) => {
|
|
210
|
+
const isSessionAutoAccepting = async (sessionId, directory) => {
|
|
205
211
|
if (!sessionId || autoAcceptingSessions.size === 0) return false;
|
|
206
212
|
let current = sessionId;
|
|
207
213
|
const seen = new Set();
|
|
208
214
|
while (current && !seen.has(current)) {
|
|
209
215
|
if (autoAcceptingSessions.has(current)) return true;
|
|
210
216
|
seen.add(current);
|
|
211
|
-
const parent = await fetchSessionParentId(current);
|
|
217
|
+
const parent = await fetchSessionParentId(current, directory);
|
|
212
218
|
if (!parent) return false;
|
|
213
219
|
current = parent;
|
|
214
220
|
}
|
|
@@ -272,6 +278,28 @@ export const createNotificationTriggerRuntime = (deps) => {
|
|
|
272
278
|
.join(' ');
|
|
273
279
|
};
|
|
274
280
|
|
|
281
|
+
// A session with an ACTIVE goal suppresses per-turn ready notifications;
|
|
282
|
+
// the session-goal runtime sends its own notification when the goal
|
|
283
|
+
// settles. Fetch failures fall through to normal notification behavior.
|
|
284
|
+
const hasActiveSessionGoal = async (sessionId, directory) => {
|
|
285
|
+
if (!sessionId) return false;
|
|
286
|
+
try {
|
|
287
|
+
const base = buildOpenCodeUrl(`/session/${encodeURIComponent(sessionId)}`, '');
|
|
288
|
+
const url = directory ? `${base}?directory=${encodeURIComponent(directory)}` : base;
|
|
289
|
+
const response = await fetch(url, {
|
|
290
|
+
method: 'GET',
|
|
291
|
+
headers: { Accept: 'application/json', ...getOpenCodeAuthHeaders() },
|
|
292
|
+
signal: AbortSignal.timeout(2000),
|
|
293
|
+
});
|
|
294
|
+
if (!response.ok) return false;
|
|
295
|
+
const session = await response.json().catch(() => null);
|
|
296
|
+
const goal = session?.metadata?.openchamber?.goal;
|
|
297
|
+
return Boolean(goal && typeof goal === 'object' && goal.status === 'active');
|
|
298
|
+
} catch {
|
|
299
|
+
return false;
|
|
300
|
+
}
|
|
301
|
+
};
|
|
302
|
+
|
|
275
303
|
const maybeSendPushForTrigger = async (payload) => {
|
|
276
304
|
if (!payload || typeof payload !== 'object') {
|
|
277
305
|
return;
|
|
@@ -281,6 +309,27 @@ export const createNotificationTriggerRuntime = (deps) => {
|
|
|
281
309
|
|
|
282
310
|
const sessionId = extractSessionIdFromPayload(payload);
|
|
283
311
|
const notificationDirectory = extractDirectoryFromPayload(payload);
|
|
312
|
+
if ((payload.type === 'session.idle' || payload.type === 'session.error') && sessionId) {
|
|
313
|
+
const error = payload.properties?.error;
|
|
314
|
+
const errorText = typeof error?.message === 'string'
|
|
315
|
+
? error.message
|
|
316
|
+
: typeof error === 'string' ? error : '';
|
|
317
|
+
await maybeSendPushForTrigger({
|
|
318
|
+
...payload,
|
|
319
|
+
type: 'message.updated',
|
|
320
|
+
properties: {
|
|
321
|
+
...payload.properties,
|
|
322
|
+
info: {
|
|
323
|
+
sessionID: sessionId,
|
|
324
|
+
role: 'assistant',
|
|
325
|
+
finish: payload.type === 'session.error' ? 'error' : 'stop',
|
|
326
|
+
...(errorText ? { parts: [{ type: 'text', text: errorText }] } : {}),
|
|
327
|
+
},
|
|
328
|
+
},
|
|
329
|
+
});
|
|
330
|
+
return;
|
|
331
|
+
}
|
|
332
|
+
|
|
284
333
|
if (payload.type === 'message.updated') {
|
|
285
334
|
const info = payload.properties?.info;
|
|
286
335
|
if (info?.role === 'assistant' && info?.finish === 'stop' && sessionId) {
|
|
@@ -290,9 +339,9 @@ export const createNotificationTriggerRuntime = (deps) => {
|
|
|
290
339
|
const parentIDFromPayload = getParentIdFromPayload(payload);
|
|
291
340
|
const parentID = parentIDFromPayload
|
|
292
341
|
? parentIDFromPayload
|
|
293
|
-
: await fetchSessionParentId(sessionId);
|
|
342
|
+
: await fetchSessionParentId(sessionId, notificationDirectory);
|
|
294
343
|
|
|
295
|
-
if (parentID) {
|
|
344
|
+
if (parentID !== null) {
|
|
296
345
|
return;
|
|
297
346
|
}
|
|
298
347
|
}
|
|
@@ -301,6 +350,13 @@ export const createNotificationTriggerRuntime = (deps) => {
|
|
|
301
350
|
return;
|
|
302
351
|
}
|
|
303
352
|
|
|
353
|
+
// While a goal drives the session, per-turn "ready" notifications are
|
|
354
|
+
// noise produced by the goal loop itself — the goal's own settle
|
|
355
|
+
// notification (complete/blocked/budget) is the final word instead.
|
|
356
|
+
if (await hasActiveSessionGoal(sessionId, notificationDirectory)) {
|
|
357
|
+
return;
|
|
358
|
+
}
|
|
359
|
+
|
|
304
360
|
if (settings.notificationMode !== 'always' && getIsWindowFocused?.()) {
|
|
305
361
|
return;
|
|
306
362
|
}
|
|
@@ -318,7 +374,7 @@ export const createNotificationTriggerRuntime = (deps) => {
|
|
|
318
374
|
|
|
319
375
|
try {
|
|
320
376
|
const templates = settings.notificationTemplates || {};
|
|
321
|
-
const isSubtask = await fetchSessionParentId(sessionId);
|
|
377
|
+
const isSubtask = await fetchSessionParentId(sessionId, notificationDirectory);
|
|
322
378
|
const completionTemplate = isSubtask && settings.notifyOnSubtasks !== false
|
|
323
379
|
? (templates.subtask || templates.completion || { title: '{agent_name} is ready', message: '{model_name} completed the task' })
|
|
324
380
|
: (templates.completion || { title: '{agent_name} is ready', message: '{model_name} completed the task' });
|
|
@@ -379,6 +435,11 @@ export const createNotificationTriggerRuntime = (deps) => {
|
|
|
379
435
|
const settings = await readSettingsFromDisk();
|
|
380
436
|
if (settings.notifyOnError === false) return;
|
|
381
437
|
|
|
438
|
+
const now = Date.now();
|
|
439
|
+
const lastAt = lastErrorNotificationAt.get(sessionId) ?? 0;
|
|
440
|
+
if (now - lastAt < PUSH_READY_COOLDOWN_MS) return;
|
|
441
|
+
lastErrorNotificationAt.set(sessionId, now);
|
|
442
|
+
|
|
382
443
|
if (settings.notificationMode !== 'always' && getIsWindowFocused?.()) {
|
|
383
444
|
return;
|
|
384
445
|
}
|
|
@@ -552,7 +613,8 @@ export const createNotificationTriggerRuntime = (deps) => {
|
|
|
552
613
|
// Client may be in Permission Auto-Accept for this session (or any
|
|
553
614
|
// ancestor). Skip the whole notification path — the client responds
|
|
554
615
|
// directly and the user has opted out of approval prompts.
|
|
555
|
-
if (await
|
|
616
|
+
if (await (getIsSessionAutoAccepting?.(sessionId, notificationDirectory)
|
|
617
|
+
?? isSessionAutoAccepting(sessionId, notificationDirectory))) {
|
|
556
618
|
if (requestKey) notifiedPermissionRequests.add(requestKey);
|
|
557
619
|
return;
|
|
558
620
|
}
|
|
@@ -565,7 +627,8 @@ export const createNotificationTriggerRuntime = (deps) => {
|
|
|
565
627
|
const timer = setTimeout(async () => {
|
|
566
628
|
pushPermissionDebounceTimers.delete(sessionId);
|
|
567
629
|
|
|
568
|
-
if (await
|
|
630
|
+
if (await (getIsSessionAutoAccepting?.(sessionId, notificationDirectory)
|
|
631
|
+
?? isSessionAutoAccepting(sessionId, notificationDirectory))) {
|
|
569
632
|
if (requestKey) notifiedPermissionRequests.add(requestKey);
|
|
570
633
|
return;
|
|
571
634
|
}
|
|
@@ -644,10 +707,49 @@ export const createNotificationTriggerRuntime = (deps) => {
|
|
|
644
707
|
}
|
|
645
708
|
};
|
|
646
709
|
|
|
710
|
+
// Goal settle push: same fanout as the trigger paths (web-push with the
|
|
711
|
+
// full text; APNs with the generic per-type title and the session name as
|
|
712
|
+
// body, so the relay never sees content).
|
|
713
|
+
const sendGoalSettlePush = async ({ sessionId, directory, status, title, body }) => {
|
|
714
|
+
let sessionName = '';
|
|
715
|
+
try {
|
|
716
|
+
const base = buildOpenCodeUrl(`/session/${encodeURIComponent(sessionId)}`, '');
|
|
717
|
+
const url = directory ? `${base}?directory=${encodeURIComponent(directory)}` : base;
|
|
718
|
+
const response = await fetch(url, {
|
|
719
|
+
method: 'GET',
|
|
720
|
+
headers: { Accept: 'application/json', ...getOpenCodeAuthHeaders() },
|
|
721
|
+
signal: AbortSignal.timeout(2000),
|
|
722
|
+
});
|
|
723
|
+
if (response.ok) {
|
|
724
|
+
const session = await response.json().catch(() => null);
|
|
725
|
+
if (typeof session?.title === 'string') sessionName = session.title.trim();
|
|
726
|
+
}
|
|
727
|
+
} catch {
|
|
728
|
+
// Session name is presentation sugar for the mobile push — never block on it.
|
|
729
|
+
}
|
|
730
|
+
const type = status === 'complete' ? 'goal_complete' : (status === 'budgetLimited' ? 'goal_budget' : 'goal_blocked');
|
|
731
|
+
await fanoutPush(
|
|
732
|
+
{
|
|
733
|
+
title,
|
|
734
|
+
body,
|
|
735
|
+
tag: `goal-${sessionId}`,
|
|
736
|
+
data: {
|
|
737
|
+
url: buildSessionDeepLinkUrl(sessionId),
|
|
738
|
+
sessionId,
|
|
739
|
+
sessionName,
|
|
740
|
+
type,
|
|
741
|
+
},
|
|
742
|
+
},
|
|
743
|
+
{ requireNoSse: true },
|
|
744
|
+
);
|
|
745
|
+
};
|
|
746
|
+
|
|
647
747
|
return {
|
|
648
748
|
maybeSendPushForTrigger,
|
|
649
749
|
setAutoAcceptSession,
|
|
650
750
|
setGetIsWindowFocused,
|
|
751
|
+
setGetIsSessionAutoAccepting,
|
|
651
752
|
clearPendingPushBadge,
|
|
753
|
+
sendGoalSettlePush,
|
|
652
754
|
};
|
|
653
755
|
};
|
|
@@ -166,6 +166,7 @@ This module provides OpenCode server integration utilities for the web server ru
|
|
|
166
166
|
- `readSettingsFromDiskMigrated()`
|
|
167
167
|
- `writeSettingsToDisk(settings)`
|
|
168
168
|
- `persistSettings(changes)`
|
|
169
|
+
- Persistent permission auto-accept policy is stored under `permissionAutoAccept`; execution ownership lives in `lib/permission-auto-accept/`.
|
|
169
170
|
|
|
170
171
|
## Public exports (settings-helpers.js)
|
|
171
172
|
- `createSettingsHelpers(dependencies)`: creates settings helper runtime for settings request/response shaping.
|
|
@@ -451,6 +451,9 @@ function updateAgent(agentName, updates, workingDirectory) {
|
|
|
451
451
|
const creatingNewMd = isBuiltinOverride;
|
|
452
452
|
|
|
453
453
|
for (const [field, value] of Object.entries(updates)) {
|
|
454
|
+
// Skip undefined values — they would overwrite existing frontmatter fields with nothing
|
|
455
|
+
if (value === undefined) continue;
|
|
456
|
+
|
|
454
457
|
if (field === 'prompt') {
|
|
455
458
|
if (value === null) {
|
|
456
459
|
if (mdExists || creatingNewMd) {
|
|
@@ -26,6 +26,8 @@ export const createBootstrapRuntime = (dependencies) => {
|
|
|
26
26
|
getRelayPairingCandidate,
|
|
27
27
|
reconcileRelay,
|
|
28
28
|
getPairingTransports,
|
|
29
|
+
getDirectCandidateUrls,
|
|
30
|
+
getServerId,
|
|
29
31
|
getServerLabel,
|
|
30
32
|
readSettingsFromDiskMigrated,
|
|
31
33
|
normalizeTunnelSessionTtlMs,
|
|
@@ -76,6 +78,7 @@ export const createBootstrapRuntime = (dependencies) => {
|
|
|
76
78
|
serverStartedAt,
|
|
77
79
|
gracefulShutdown,
|
|
78
80
|
getHealthSnapshot,
|
|
81
|
+
getServerId,
|
|
79
82
|
tunnelAuthController,
|
|
80
83
|
uiAuthController,
|
|
81
84
|
});
|
|
@@ -91,6 +94,8 @@ export const createBootstrapRuntime = (dependencies) => {
|
|
|
91
94
|
getRelayPairingCandidate,
|
|
92
95
|
reconcileRelay,
|
|
93
96
|
getPairingTransports,
|
|
97
|
+
getDirectCandidateUrls,
|
|
98
|
+
getServerId,
|
|
94
99
|
getServerLabel,
|
|
95
100
|
readSettingsFromDiskMigrated,
|
|
96
101
|
normalizeTunnelSessionTtlMs,
|