@openchamber/web 1.14.1 → 1.16.0
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 +8 -0
- package/bin/lib/DOCUMENTATION.md +3 -0
- package/bin/lib/cli-args.js +10 -0
- package/bin/lib/commands-connect-url.js +169 -22
- package/dist/assets/{DiagramView-Cb58svCq.js → DiagramView-he_RFVx5.js} +1 -1
- package/dist/assets/MarkdownRendererImpl-CdBIHSPZ.js +11 -0
- package/dist/assets/{MultiRunWindow-BPSxV_B7.js → MultiRunWindow-B_C-tvVq.js} +1 -1
- package/dist/assets/OnboardingScreen-BBnTt-9w.js +1 -0
- package/dist/assets/SessionSwitcherDropdown-CWWrCFzr.js +1 -0
- package/dist/assets/SettingsWindow-CjqLdpTE.js +1 -0
- package/dist/assets/{TerminalView-fTYjnQkh.js → TerminalView-DQcdegHp.js} +1 -1
- package/dist/assets/es-r0_jT91q.js +15 -0
- package/dist/assets/fr-Bo8rtAJ1.js +13 -0
- package/dist/assets/index-8J6waVO6.js +2 -0
- package/dist/assets/index-DEMqM4Lz.css +1 -0
- package/dist/assets/ja-BPWtkG-c.js +15 -0
- package/dist/assets/ko-Bv0k-0E3.js +15 -0
- package/dist/assets/main-B-GA5Tg5.js +237 -0
- package/dist/assets/main-Dfm-VKZ9.js +2 -0
- package/dist/assets/miniChat-CfmCFFfu.js +2 -0
- package/dist/assets/mobile-CXJqeDlm.js +2 -0
- package/dist/assets/pl-CiTP50bz.js +15 -0
- package/dist/assets/pt-BR-DadIjX5L.js +15 -0
- package/dist/assets/renderElectronMiniChatApp-DS7Dy2ii.js +2 -0
- package/dist/assets/renderMobileApp-o7Fs9EBx.js +16 -0
- package/dist/assets/runtimeEndpointReset-MTaPPm4F.js +167 -0
- package/dist/assets/uk-2RpsWGoZ.js +15 -0
- package/dist/assets/{useAppFontEffects-BUUJYbAZ.js → useAppFontEffects-DkPuAMXD.js} +196 -133
- package/dist/assets/{vendor-.bun-C6iL44L9.js → vendor-.bun-BE757pvp.js} +1 -1
- package/dist/assets/zh-CN-BwKWaTuz.js +15 -0
- package/dist/assets/zh-TW--f_BqBpD.js +15 -0
- package/dist/index.html +4 -4
- package/dist/mini-chat.html +4 -4
- package/dist/mobile.html +4 -4
- package/package.json +2 -2
- package/server/index.js +236 -2
- package/server/lib/client-auth/pairing.js +308 -0
- package/server/lib/client-auth/pairing.test.js +142 -0
- package/server/lib/client-auth/remote-clients.js +65 -3
- package/server/lib/notifications/DOCUMENTATION.md +1 -1
- package/server/lib/notifications/apns-runtime.js +11 -16
- 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 +15 -0
- package/server/lib/opencode/core-routes.js +321 -8
- package/server/lib/opencode/core-routes.test.js +329 -9
- package/server/lib/opencode/feature-routes-runtime.js +6 -0
- package/server/lib/opencode/network-runtime.js +14 -1
- package/server/lib/opencode/network-runtime.test.js +29 -9
- package/server/lib/opencode/proxy.js +47 -6
- package/server/lib/opencode/settings-helpers.js +24 -0
- package/server/lib/opencode/settings-helpers.test.js +25 -0
- package/server/lib/opencode/settings-normalization-runtime.js +21 -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 +18 -5
- 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 +98 -0
- package/server/lib/relay/cross-compat.test.js +135 -0
- package/server/lib/relay/e2ee.js +341 -0
- package/server/lib/relay/e2ee.test.js +124 -0
- package/server/lib/relay/host-client.js +389 -0
- package/server/lib/relay/host-client.test.js +280 -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 +93 -0
- package/server/lib/relay/identity.test.js +78 -0
- package/server/lib/relay/service.js +334 -0
- package/server/lib/relay/signing-key.js +73 -0
- package/server/lib/relay/tunnel-codec.js +373 -0
- package/server/lib/relay/tunnel-codec.test.js +58 -0
- package/server/lib/relay/tunnel-host.js +462 -0
- 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/ui-auth/DOCUMENTATION.md +6 -0
- package/server/lib/ui-auth/ui-auth.js +10 -0
- package/server/opencode-proxy.test.js +38 -0
- package/dist/assets/MarkdownRendererImpl-D2yCDL5A.js +0 -7
- package/dist/assets/OnboardingScreen-Sl-6JgaP.js +0 -1
- package/dist/assets/SessionSwitcherDropdown-4FWg9xMC.js +0 -1
- package/dist/assets/SettingsWindow-CY8q4msv.js +0 -1
- package/dist/assets/es-bWcuDy_2.js +0 -15
- package/dist/assets/fr-DzRs3OzV.js +0 -13
- package/dist/assets/index-KnWk9fmM.css +0 -1
- package/dist/assets/index-ZJTzZ0_U.js +0 -2
- package/dist/assets/ja-BqUX_UD3.js +0 -15
- package/dist/assets/ko-BQo10SNx.js +0 -15
- package/dist/assets/main-BDoqLlQB.js +0 -236
- package/dist/assets/main-DUGyTrDt.js +0 -2
- package/dist/assets/miniChat-DNDiX8GA.js +0 -2
- package/dist/assets/mobile-DnghtOCb.js +0 -2
- package/dist/assets/pl-Bgx_ATJT.js +0 -15
- package/dist/assets/pt-BR-B1yXRvoX.js +0 -15
- package/dist/assets/renderElectronMiniChatApp-BB4C1K7t.js +0 -2
- package/dist/assets/renderMobileApp-CZgaXKi5.js +0 -16
- package/dist/assets/runtimeEndpointReset-By39StyB.js +0 -167
- package/dist/assets/uk-C9k8SP8q.js +0 -15
- package/dist/assets/zh-CN-Bri-Vo5y.js +0 -15
- package/dist/assets/zh-TW-DAUGzmYG.js +0 -15
|
@@ -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) {
|
|
@@ -22,6 +22,13 @@ export const createBootstrapRuntime = (dependencies) => {
|
|
|
22
22
|
uiPassword,
|
|
23
23
|
tunnelAuthController,
|
|
24
24
|
remoteClientAuthRuntime,
|
|
25
|
+
clientPairingRuntime,
|
|
26
|
+
getRelayPairingCandidate,
|
|
27
|
+
reconcileRelay,
|
|
28
|
+
getPairingTransports,
|
|
29
|
+
getDirectCandidateUrls,
|
|
30
|
+
getServerId,
|
|
31
|
+
getServerLabel,
|
|
25
32
|
readSettingsFromDiskMigrated,
|
|
26
33
|
normalizeTunnelSessionTtlMs,
|
|
27
34
|
sayTTSCapability,
|
|
@@ -71,6 +78,7 @@ export const createBootstrapRuntime = (dependencies) => {
|
|
|
71
78
|
serverStartedAt,
|
|
72
79
|
gracefulShutdown,
|
|
73
80
|
getHealthSnapshot,
|
|
81
|
+
getServerId,
|
|
74
82
|
tunnelAuthController,
|
|
75
83
|
uiAuthController,
|
|
76
84
|
});
|
|
@@ -82,6 +90,13 @@ export const createBootstrapRuntime = (dependencies) => {
|
|
|
82
90
|
tunnelAuthController,
|
|
83
91
|
uiAuthController,
|
|
84
92
|
remoteClientAuthRuntime,
|
|
93
|
+
clientPairingRuntime,
|
|
94
|
+
getRelayPairingCandidate,
|
|
95
|
+
reconcileRelay,
|
|
96
|
+
getPairingTransports,
|
|
97
|
+
getDirectCandidateUrls,
|
|
98
|
+
getServerId,
|
|
99
|
+
getServerLabel,
|
|
85
100
|
readSettingsFromDiskMigrated,
|
|
86
101
|
normalizeTunnelSessionTtlMs,
|
|
87
102
|
});
|