@openchamber/web 2.3.2 → 2.3.3
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/{AboutDialog-MZbHWRua.js → AboutDialog-Ctk2zvrv.js} +1 -1
- package/dist/assets/{ArchiveView-CkeSWPcI.js → ArchiveView-sbNreasJ.js} +1 -1
- package/dist/assets/{CommandPalette-CtKzNzwW.js → CommandPalette-BICwnwAZ.js} +2 -2
- package/dist/assets/{DiffView-DaXjHTAq.js → DiffView-B5yeuxv8.js} +1 -1
- package/dist/assets/{FilesView-DMNYEydF.js → FilesView-ni2zfAwL.js} +7 -7
- package/dist/assets/{GitView-HXttTpUw.js → GitView-C0QgeC9O.js} +3 -3
- package/dist/assets/{GuestSurfacePane-KzguENQG.js → GuestSurfacePane-D1gLktSj.js} +1 -1
- package/dist/assets/{HelpDialog-9YZGhBgT.js → HelpDialog-CxC6qTaS.js} +1 -1
- package/dist/assets/{InProgressOperationBanner-DzGIwGH2.js → InProgressOperationBanner-JFV70YFh.js} +1 -1
- package/dist/assets/{JsonTreeView-D9rP8jM8.js → JsonTreeView-RsbV4Usa.js} +1 -1
- package/dist/assets/MarkdownRendererImpl-CZK5DoOX.js +1 -0
- package/dist/assets/{MemoryDebugPanel-Ct0h3RWh.js → MemoryDebugPanel-caUWOKiz.js} +1 -1
- package/dist/assets/{OnboardingScreen-B5Zzb1Mp.js → OnboardingScreen-BDT-J2JP.js} +1 -1
- package/dist/assets/{OpenCodeStatusDialog-CXBWWRh8.js → OpenCodeStatusDialog-Cxa2yqOB.js} +1 -1
- package/dist/assets/{PatchDiff-DhDAQ5em.js → PatchDiff-C1pnbAsJ.js} +1 -1
- package/dist/assets/{PierreDiffViewer-DPa08AmN.js → PierreDiffViewer-D0zX2Msu.js} +1 -1
- package/dist/assets/PlanView-BxRCMuGe.js +5 -0
- package/dist/assets/{ProjectActionsDialog-DATu0aBc.js → ProjectActionsDialog-D660By4K.js} +1 -1
- package/dist/assets/{RunOverview-D6xy_vME.js → RunOverview-C1uTMnQS.js} +2 -2
- package/dist/assets/{ScheduledTasksDialog-BWXVnfrf.js → ScheduledTasksDialog-S-gAgo7Z.js} +5 -5
- package/dist/assets/SettingsView-CVpfbdob.js +30 -0
- package/dist/assets/{SettingsWindow-Cx6TrtY0.js → SettingsWindow-Dd1hHvgh.js} +1 -1
- package/dist/assets/SourceBoardView-DbGWAxtS.js +1 -0
- package/dist/assets/SpaceAccessDialog-muTSsEJ9.js +1 -0
- package/dist/assets/{SpaceApplyDialog-BtuwtlaG.js → SpaceApplyDialog-Dsf6MNGm.js} +1 -1
- package/dist/assets/{SpaceRow-MXqvd-dr.js → SpaceRow-7Z6ebRtm.js} +1 -1
- package/dist/assets/{SpaceSetupOutput-Uo5LS7Jy.js → SpaceSetupOutput-BytPfCOC.js} +1 -1
- package/dist/assets/{SpacesView-DvoOh4sM.js → SpacesView-CYCrlp0D.js} +1 -1
- package/dist/assets/{SubmoduleDiffSummary-CyMwDeoP.js → SubmoduleDiffSummary-VrNUbIqF.js} +1 -1
- package/dist/assets/{ToolOutputDialog-BaUZIVzc.js → ToolOutputDialog-DHORjBND.js} +7 -7
- package/dist/assets/{ToolPartDiffPreview-DmMwdcF4.js → ToolPartDiffPreview-BLAXe7C5.js} +1 -1
- package/dist/assets/{UsageStatsView-D7WrDBTC.js → UsageStatsView-BxtYEAa0.js} +1 -1
- package/dist/assets/{Virtualizer-CnU8pYMb.js → Virtualizer-Bl4Cf-H-.js} +1 -1
- package/dist/assets/{WalkthroughView-r0Ho9F4Z.js → WalkthroughView-B2BJJ4u5.js} +2 -2
- package/dist/assets/{WorktreesView-C-t7uxq1.js → WorktreesView-Dv0AO9dF.js} +1 -1
- package/dist/assets/{appThemeRegistry-BUY7Ge9i.js → appThemeRegistry-xm_W0svA.js} +1 -1
- package/dist/assets/{ar-HauNhDvN.js → ar-Cj8UF12m.js} +4 -4
- package/dist/assets/{computeVirtualFileMetrics-CUof18z3.js → computeVirtualFileMetrics-Cx05cmWI.js} +2 -2
- package/dist/assets/{de-fEoJ_Yyp.js → de-fSQ1ho01.js} +4 -4
- package/dist/assets/{decorate-BkTSGAlD.js → decorate-jpF7GA6t.js} +2 -2
- package/dist/assets/{es-CKNTBsZW.js → es-DrdzhSlK.js} +5 -5
- package/dist/assets/{fileContentPoller-BJWgy1fX.js → fileContentPoller-C0f20jNG.js} +3 -3
- package/dist/assets/{flexokiTheme-BArobfXV.js → flexokiTheme-DKNCYSqL.js} +1 -1
- package/dist/assets/{fr-C23655Pi.js → fr-Cmz6Da4q.js} +4 -4
- package/dist/assets/{he-CphXS_Fv.js → he-COJRUNy4.js} +4 -4
- package/dist/assets/{index-B27cSA9V.js → index-C8Mw8uvl.js} +1 -1
- package/dist/assets/{initializeSharedPreferences-CucsmDMw.js → initializeSharedPreferences-U9-v9mfq.js} +1 -1
- package/dist/assets/{isDiffPlainText-DSCjvV0m.js → isDiffPlainText-DW43IghW.js} +1 -1
- package/dist/assets/{isFilePlainText-C7g4UPox.js → isFilePlainText-Duq5CiuG.js} +1 -1
- package/dist/assets/{ja-BmsU2iQe.js → ja-Ce0NvDHZ.js} +4 -4
- package/dist/assets/katex-BZNCT55U.css +1 -0
- package/dist/assets/katex.min-EZjpSwGK.js +65 -0
- package/dist/assets/{ko-CxISpkje.js → ko-BGFcCLLq.js} +4 -4
- package/dist/assets/main-BUetg9hg.js +1048 -0
- package/dist/assets/{main-CGPiw9fS.js → main-Be_jmIlF.js} +2 -2
- package/dist/assets/markdownCore-BkTeS4gA.js +10 -0
- package/dist/assets/{miniChat-DVEKVYKe.js → miniChat-g1RgiLLS.js} +2 -2
- package/dist/assets/{mobile-Q_FVBe4I.js → mobile-DBli3U-T.js} +2 -2
- package/dist/assets/{moveWorkspacePath-CyZJ-2aD.js → moveWorkspacePath-CnYc96Xo.js} +1 -1
- package/dist/assets/{nl-jnTBQ_gU.js → nl-Cu1nxo5t.js} +4 -4
- package/dist/assets/{parseDiffFromFile-OHXXXyzL.js → parseDiffFromFile-DEjkjYod.js} +3 -3
- package/dist/assets/{patchFileDiff-BZrb6h2u.js → patchFileDiff-D__42sau.js} +5 -5
- package/dist/assets/{pierreDiffTint-DHf2xvyt.js → pierreDiffTint-3oatL635.js} +4 -4
- package/dist/assets/pl-4LdEMgWI.js +20 -0
- package/dist/assets/{pt-BR-BfpsFrHv.js → pt-BR-2UbEBNgC.js} +5 -5
- package/dist/assets/{relocateRestoredSession-DInneXVI.js → relocateRestoredSession-pkxyd_lV.js} +1 -1
- package/dist/assets/renderElectronMiniChatApp-D0tKJFBB.js +2 -0
- package/dist/assets/renderMobileApp-D6bOYHuP.js +25 -0
- package/dist/assets/{restartOpenCode-DwBaMPJK.js → restartOpenCode-FYqjpaWc.js} +1 -1
- package/dist/assets/runtimeEndpointReset-6CNNzem4.js +74 -0
- package/dist/assets/{scheduledTasksApi-ClJplEhR.js → scheduledTasksApi-BbnQ4W-W.js} +1 -1
- package/dist/assets/{selectionMarkdown-BuveYuup.js → selectionMarkdown-D8QAxC44.js} +1 -1
- package/dist/assets/sessionOwnership-BBuf0UCB.js +1 -0
- package/dist/assets/{shikiHighlight-DJAESrna.js → shikiHighlight-CweIj1cL.js} +1 -1
- package/dist/assets/{space-apply-DWFLwXbI.js → space-apply-CEi013sa.js} +1 -1
- package/dist/assets/{space-close-BYDbwdWc.js → space-close-BuStkLrZ.js} +1 -1
- package/dist/assets/{spaceNetwork-DHrhfbKM.js → spaceNetwork-tH2d5Mgs.js} +1 -1
- package/dist/assets/{textMateThemeFromAppTheme-DcAZmUlv.js → textMateThemeFromAppTheme-DLJBL6al.js} +1 -1
- package/dist/assets/tr-Bg0Qt-mG.js +11 -0
- package/dist/assets/{uk-C82aEtvs.js → uk-vcnOugr0.js} +5 -5
- package/dist/assets/useAppFontEffects-Cs6k0JKv.js +773 -0
- package/dist/assets/{useCallableModelProviders-BU_455MN.js → useCallableModelProviders-BsGEzsl2.js} +1 -1
- package/dist/assets/{useInlineCommentController-AuUrVz9U.js → useInlineCommentController-CVYaPzfO.js} +2 -2
- package/dist/assets/{useRootScrollLock-Cpk7NmBa.js → useRootScrollLock-Dov-44ov.js} +2 -2
- package/dist/assets/{vendor-codemirror-language-data-BYGweLoh.js → vendor-codemirror-language-data-DBekkZIx.js} +2 -2
- package/dist/assets/vendor-tanstack-react-virtual-Dozz-7fb.js +1 -0
- package/dist/assets/vendor-tanstack-virtual-core-DKBj55Em.js +1 -0
- package/dist/assets/{vendor-yaml-3778uTud.js → vendor-yaml-CE-D_49-.js} +1 -1
- package/dist/assets/{zh-CN-DEq7j9I5.js → zh-CN-C3UhwFsk.js} +5 -5
- package/dist/assets/{zh-TW-DgCN99T-.js → zh-TW-D0CmmMvp.js} +5 -5
- package/dist/index.html +3 -3
- package/dist/mini-chat.html +3 -3
- package/dist/mobile.html +3 -3
- package/package.json +5 -5
- package/server/index.js +13 -1
- package/server/lib/agent-memory/actions.js +22 -9
- package/server/lib/agent-memory/actions.test.js +57 -0
- package/server/lib/agent-memory/runtime.js +8 -5
- package/server/lib/agent-tool/DOCUMENTATION.md +17 -1
- package/server/lib/agent-tool/runtime.js +41 -7
- package/server/lib/agent-tool/runtime.test.js +11 -0
- package/server/lib/git/DOCUMENTATION.md +17 -5
- package/server/lib/git/lfs-discovery.js +7 -4
- package/server/lib/git/lfs-discovery.test.js +60 -0
- package/server/lib/git/network-operations.js +9 -3
- package/server/lib/git/network-operations.test.js +31 -2
- package/server/lib/git/service.js +72 -12
- package/server/lib/git/service.test.js +65 -0
- package/server/lib/github/DOCUMENTATION.md +1 -0
- package/server/lib/github/reference-search.js +49 -18
- package/server/lib/github/reference-search.test.js +28 -6
- package/server/lib/github/routes.js +87 -1
- package/server/lib/github/routes.mutations.test.js +38 -0
- package/server/lib/github/routes.test.js +1 -0
- package/server/lib/gitlab/DOCUMENTATION.md +4 -0
- package/server/lib/gitlab/client.js +23 -0
- package/server/lib/gitlab/client.test.js +28 -1
- package/server/lib/gitlab/mappers.js +9 -0
- package/server/lib/gitlab/resources.js +153 -4
- package/server/lib/gitlab/resources.test.js +107 -0
- package/server/lib/gitlab/routes.js +120 -1
- package/server/lib/gitlab/routes.test.js +59 -0
- package/server/lib/markdown-image-grants/DOCUMENTATION.md +4 -0
- package/server/lib/markdown-image-grants/routes.js +14 -2
- package/server/lib/markdown-image-grants/routes.test.js +23 -0
- package/server/lib/notifications/APNS.md +24 -23
- package/server/lib/notifications/DOCUMENTATION.md +2 -2
- package/server/lib/notifications/apns-runtime.js +8 -5
- package/server/lib/notifications/apns-runtime.test.js +26 -0
- package/server/lib/notifications/message.js +5 -3
- package/server/lib/notifications/message.test.js +9 -0
- package/server/lib/notifications/runtime.js +44 -9
- package/server/lib/notifications/trigger-runtime.test.js +84 -0
- package/server/lib/openchamber-control/DOCUMENTATION.md +6 -1
- package/server/lib/openchamber-control/actions.js +18 -2
- package/server/lib/openchamber-control/project-knowledge.js +17 -3
- package/server/lib/openchamber-control/project-knowledge.test.js +14 -0
- package/server/lib/openchamber-control/render-page.js +58 -0
- package/server/lib/openchamber-control/service.js +9 -0
- package/server/lib/openchamber-control/service.test.js +43 -0
- package/server/lib/openchamber-sessions/routes.js +1 -0
- package/server/lib/openchamber-sessions/worktree-move.js +26 -10
- package/server/lib/openchamber-sessions/worktree-move.test.js +36 -0
- package/server/lib/opencode/DOCUMENTATION.md +1 -1
- package/server/lib/opencode/managed-config-file.js +3 -2
- package/server/lib/opencode/managed-config-file.test.js +20 -6
- package/server/lib/opencode/settings-helpers.js +3 -0
- package/server/lib/opencode/settings-helpers.test.js +1 -1
- package/server/lib/opencode/settings-registry.json +3 -0
- package/server/lib/opencode/settings-runtime.js +1 -0
- package/server/lib/project-context/DOCUMENTATION.md +25 -1
- package/server/lib/project-context/plan-progress.js +69 -0
- package/server/lib/project-context/plan-progress.test.js +58 -0
- package/server/lib/project-context/routes.http.test.js +22 -0
- package/server/lib/project-context/routes.js +20 -0
- package/server/lib/project-context/runtime.js +132 -18
- package/server/lib/project-context/runtime.test.js +58 -0
- package/server/lib/provider-read-cache/index.js +7 -1
- package/server/lib/provider-read-cache/index.test.js +12 -0
- package/server/lib/relay/DOCUMENTATION.md +17 -1
- package/server/lib/session-knowledge/DOCUMENTATION.md +17 -0
- package/server/lib/session-knowledge/runtime.js +29 -6
- package/server/lib/session-knowledge/runtime.test.js +26 -1
- package/server/lib/source-control/audit-storage.js +1 -0
- package/server/lib/source-control/mutation-storage.js +3 -0
- package/server/lib/spaces/DOCUMENTATION.md +14 -9
- package/server/lib/spaces/code-out.js +13 -4
- package/server/lib/spaces/code-out.test.js +5 -3
- package/server/lib/spaces/dispatcher.js +12 -5
- package/server/lib/spaces/dispatcher.test.js +19 -1
- package/server/lib/spaces/gatekeeper-channel.js +8 -7
- package/server/lib/spaces/gatekeeper-channel.test.js +10 -0
- package/server/lib/spaces/gatekeeper-program.cjs +38 -3
- package/server/lib/spaces/gatekeeper-program.test.js +20 -0
- package/server/lib/spaces/hardening.js +14 -1
- package/server/lib/spaces/hardening.test.js +5 -0
- package/server/lib/spaces/host-providers.js +165 -0
- package/server/lib/spaces/host-providers.test.js +100 -0
- package/server/lib/spaces/host.js +16 -4
- package/server/lib/spaces/journey.js +87 -17
- package/server/lib/spaces/journey.test.js +90 -2
- package/server/lib/spaces/layout.js +15 -5
- package/server/lib/spaces/places/docker-live-support.js +2 -0
- package/server/lib/spaces/places/docker.test.js +2 -0
- package/server/lib/spaces/places/fake-docker.js +3 -0
- package/server/lib/spaces/places/grants.docker.live.test.js +71 -7
- package/server/lib/spaces/routes.js +9 -0
- package/server/lib/spaces/routes.test.js +4 -2
- package/server/lib/spaces/space-opencode.js +31 -14
- package/server/lib/spaces/space-opencode.test.js +15 -2
- package/server/lib/spaces/space-records.js +8 -0
- package/server/lib/spaces/space-records.test.js +7 -3
- package/server/lib/spaces/websocket.test.js +13 -1
- package/server/lib/ui-auth/ui-auth.js +28 -3
- package/server/lib/ui-auth/ui-auth.test.js +31 -0
- package/dist/assets/MarkdownRendererImpl-B2LsA09C.js +0 -1
- package/dist/assets/PlanView-Dt5EN_JK.js +0 -5
- package/dist/assets/SettingsView-BolP_tuu.js +0 -30
- package/dist/assets/SourceBoardView-yca1qvgB.js +0 -1
- package/dist/assets/SpaceAccessDialog-CZ-u75py.js +0 -1
- package/dist/assets/katex-rNcbfUj4.css +0 -1
- package/dist/assets/katex.min-DQ8qF6NR.js +0 -65
- package/dist/assets/main-CVHM3_8W.js +0 -1048
- package/dist/assets/markdownCore-D5ZOJXeO.js +0 -9
- package/dist/assets/pl-Bj-Hy0X5.js +0 -20
- package/dist/assets/renderElectronMiniChatApp-B_5BeSF6.js +0 -2
- package/dist/assets/renderMobileApp-DGEXUTk-.js +0 -25
- package/dist/assets/runtimeEndpointReset-CIpvn8QG.js +0 -59
- package/dist/assets/sessionOwnership-BZoGed9N.js +0 -1
- package/dist/assets/tr-qMRMBQ8r.js +0 -11
- package/dist/assets/useAppFontEffects-Bih1DxXi.js +0 -745
- package/dist/assets/vendor-tanstack-react-virtual-CvuLsk7D.js +0 -1
- package/dist/assets/vendor-tanstack-virtual-core-DPaNcJcT.js +0 -1
|
@@ -225,6 +225,32 @@ describe('apns runtime relay mode (default)', () => {
|
|
|
225
225
|
expect(plain.data.enc).toBeUndefined();
|
|
226
226
|
});
|
|
227
227
|
|
|
228
|
+
it('seals the richer phone text when one is given, and sends it nowhere else', async () => {
|
|
229
|
+
const fetchMock = vi.fn(async () => jsonResponse({ ok: true, results: [] }));
|
|
230
|
+
vi.stubGlobal('fetch', fetchMock);
|
|
231
|
+
process.env.OPENCHAMBER_PUSH_RELAY_URL = 'https://relay.test/v1/push/send';
|
|
232
|
+
const pushKey = crypto.randomBytes(32).toString('base64');
|
|
233
|
+
|
|
234
|
+
const runtime = createApnsRuntime(makeDeps());
|
|
235
|
+
await runtime.addOrUpdateApnsToken('s1', 'tokenSealed', undefined, 'ios', 'production', pushKey);
|
|
236
|
+
await runtime.addOrUpdateApnsToken('s2', 'tokenPlain', undefined, 'ios', 'production');
|
|
237
|
+
|
|
238
|
+
fetchMock.mockClear();
|
|
239
|
+
await runtime.sendApnsToAllUiSessions({
|
|
240
|
+
title: 'Agent response is ready',
|
|
241
|
+
body: 'Fix the login bug',
|
|
242
|
+
sealed: { title: 'Fix the login bug', body: 'Done, the redirect loop is gone' },
|
|
243
|
+
data: { sessionId: 'ses_1' },
|
|
244
|
+
});
|
|
245
|
+
|
|
246
|
+
const sends = fetchMock.mock.calls.filter(isSend).map(([, init]) => JSON.parse(init.body));
|
|
247
|
+
const sealed = sends.find((send) => send.tokens.includes('tokenSealed'));
|
|
248
|
+
const plain = sends.find((send) => send.tokens.includes('tokenPlain'));
|
|
249
|
+
expect(openPushContent(pushKey, sealed.data.enc)).toEqual({ title: 'Fix the login bug', body: 'Done, the redirect loop is gone' });
|
|
250
|
+
expect(JSON.stringify(sends)).not.toContain('redirect loop');
|
|
251
|
+
expect(plain).toMatchObject({ title: 'Agent response is ready', body: 'Fix the login bug' });
|
|
252
|
+
});
|
|
253
|
+
|
|
228
254
|
it('no-ops (no relay call) when no tokens are registered', async () => {
|
|
229
255
|
const fetchMock = vi.fn();
|
|
230
256
|
vi.stubGlobal('fetch', fetchMock);
|
|
@@ -18,9 +18,11 @@ const normalizeNotificationPlainText = (text) => {
|
|
|
18
18
|
.replace(/^[\t ]*[-*+]\s+/gm, '')
|
|
19
19
|
.replace(/^#{1,6}\s+/gm, '')
|
|
20
20
|
.replace(/\*\*(.*?)\*\*/g, '$1')
|
|
21
|
-
|
|
22
|
-
.
|
|
23
|
-
.replace(/
|
|
21
|
+
// Underscore and single-star emphasis only at word edges, so `user_id`,
|
|
22
|
+
// `snake_case` and `2 * 3` survive.
|
|
23
|
+
.replace(/(^|\W)__(?!\s)(.+?)__(?=\W|$)/g, '$1$2')
|
|
24
|
+
.replace(/(^|\W)\*(?!\s)(.+?)\*(?=\W|$)/g, '$1$2')
|
|
25
|
+
.replace(/(^|\W)_(?!\s)(.+?)_(?=\W|$)/g, '$1$2')
|
|
24
26
|
.replace(/\[(.*?)\]\((.*?)\)/g, '$1')
|
|
25
27
|
.replace(/\s*\n\s*/g, ' ')
|
|
26
28
|
.replace(/\s+/g, ' ')
|
|
@@ -31,4 +31,13 @@ describe('notification message helpers', () => {
|
|
|
31
31
|
|
|
32
32
|
expect(result).toBe('Committed. Commit: 85924b9d Message: fix desktop notifications');
|
|
33
33
|
});
|
|
34
|
+
|
|
35
|
+
it('keeps underscores and stars inside words and math', async () => {
|
|
36
|
+
const result = await prepareNotificationLastMessage({
|
|
37
|
+
message: 'Renamed `user_id` to session_id, kept 2 * 3 * 4, and _really_ fixed *it*.',
|
|
38
|
+
settings: {},
|
|
39
|
+
});
|
|
40
|
+
|
|
41
|
+
expect(result).toBe('Renamed user_id to session_id, kept 2 * 3 * 4, and really fixed it.');
|
|
42
|
+
});
|
|
34
43
|
});
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { unwrapOpenCodeResponse } from '../opencode/response-envelope.js';
|
|
2
2
|
import { createSessionActivityProbe } from '../opencode/session-activity.js';
|
|
3
3
|
import { isEnterpriseMode } from '../enterprise-mode.js';
|
|
4
|
+
import { truncateNotificationText } from './message.js';
|
|
4
5
|
|
|
5
6
|
/** The session id OpenCode gives an MCP elicitation form, which no session owns. */
|
|
6
7
|
const LOCATION_SCOPED_FORM_SESSION_ID = 'global';
|
|
@@ -69,7 +70,8 @@ export const createNotificationTriggerRuntime = (deps) => {
|
|
|
69
70
|
};
|
|
70
71
|
|
|
71
72
|
// Generic notification for native push (per the mobile design): a fixed, scenario-based
|
|
72
|
-
// title + the session name as the body. No model/project/message content crosses the relay
|
|
73
|
+
// title + the session name as the body. No model/project/message content crosses the relay
|
|
74
|
+
// in the clear; a phone with a push key gets what happened sealed (`sealed` below).
|
|
73
75
|
const APNS_TITLE_BY_TYPE = {
|
|
74
76
|
ready: 'Agent response is ready',
|
|
75
77
|
error: 'Agent hit an error',
|
|
@@ -84,13 +86,19 @@ export const createNotificationTriggerRuntime = (deps) => {
|
|
|
84
86
|
|
|
85
87
|
const toApnsGenericPayload = (payload) => {
|
|
86
88
|
const data = payload?.data && typeof payload.data === 'object' ? payload.data : {};
|
|
87
|
-
const
|
|
88
|
-
|
|
89
|
-
|
|
89
|
+
const knownSessionName = typeof data.sessionName === 'string' ? data.sessionName.trim() : '';
|
|
90
|
+
const sessionName = knownSessionName || 'Session';
|
|
91
|
+
const phoneBody = payload?.phoneBody ?? '';
|
|
90
92
|
return {
|
|
91
93
|
title: genericTitleOf(payload),
|
|
92
94
|
// A session name is derived from the conversation.
|
|
93
95
|
body: isEnterpriseMode() ? '' : sessionName,
|
|
96
|
+
// A phone with a push key opens this on the device; the relay and the
|
|
97
|
+
// push service see only the title above. Enterprise mode keeps the
|
|
98
|
+
// generic text even sealed: the push service is outside its boundary.
|
|
99
|
+
sealed: phoneBody && !isEnterpriseMode()
|
|
100
|
+
? { title: knownSessionName || genericTitleOf(payload), body: phoneBody }
|
|
101
|
+
: undefined,
|
|
94
102
|
badge: trackPushAndCountBadge(typeof payload?.tag === 'string' ? payload.tag : undefined),
|
|
95
103
|
tag: payload?.tag,
|
|
96
104
|
// sessionId is forwarded so a tapped push can deep-link; it is an opaque id, not content.
|
|
@@ -98,6 +106,20 @@ export const createNotificationTriggerRuntime = (deps) => {
|
|
|
98
106
|
};
|
|
99
107
|
};
|
|
100
108
|
|
|
109
|
+
// The body a phone shows: what happened, after a word that says which kind
|
|
110
|
+
// of event it is. A finished turn needs no word, its reply says it.
|
|
111
|
+
const phoneBodyOf = (prefix, text) => {
|
|
112
|
+
const detail = truncateNotificationText((text ?? '').trim());
|
|
113
|
+
if (!detail) return '';
|
|
114
|
+
return prefix ? `${prefix}: ${detail}` : detail;
|
|
115
|
+
};
|
|
116
|
+
|
|
117
|
+
const PERMISSION_PREFIX_BY_ACTION = {
|
|
118
|
+
bash: 'Wants to run',
|
|
119
|
+
edit: 'Wants to edit',
|
|
120
|
+
read: 'Wants to read',
|
|
121
|
+
};
|
|
122
|
+
|
|
101
123
|
// Fan a notification out to every delivery channel: browser web-push (full templated
|
|
102
124
|
// payload) and native iOS APNs (generic model-based text). Both share the dedup tag and
|
|
103
125
|
// `requireNoSse` focus gate; a failure in one channel must not block the other.
|
|
@@ -111,7 +133,7 @@ export const createNotificationTriggerRuntime = (deps) => {
|
|
|
111
133
|
return { ...payload, title: genericTitleOf(payload), body: '', data: rest };
|
|
112
134
|
};
|
|
113
135
|
|
|
114
|
-
const fanoutPush = (payload, options) => {
|
|
136
|
+
const fanoutPush = ({ phoneBody, ...payload }, options) => {
|
|
115
137
|
// Presence-aware routing: if any interactive (non-mobile) client — desktop/web/vscode — is
|
|
116
138
|
// currently visible, it already shows the in-app notification, so skip the native push to the
|
|
117
139
|
// phone. Gated on the desktop's visibility (reliable), never the phone's own. When we skip we
|
|
@@ -123,7 +145,7 @@ export const createNotificationTriggerRuntime = (deps) => {
|
|
|
123
145
|
}),
|
|
124
146
|
interactiveVisible
|
|
125
147
|
? Promise.resolve()
|
|
126
|
-
: Promise.resolve(sendApnsToAllUiSessions?.(toApnsGenericPayload(payload), options)).catch((error) => {
|
|
148
|
+
: Promise.resolve(sendApnsToAllUiSessions?.(toApnsGenericPayload({ ...payload, phoneBody }), options)).catch((error) => {
|
|
127
149
|
console.warn('[APNs] fanout failed:', error?.message ?? error);
|
|
128
150
|
}),
|
|
129
151
|
]);
|
|
@@ -463,6 +485,7 @@ export const createNotificationTriggerRuntime = (deps) => {
|
|
|
463
485
|
let title = `${formatMode(info?.mode)} agent is ready`;
|
|
464
486
|
let body = `${formatModelId(info?.modelID)} completed the task`;
|
|
465
487
|
let sessionName = '';
|
|
488
|
+
let reply = '';
|
|
466
489
|
|
|
467
490
|
try {
|
|
468
491
|
const templates = settings.notificationTemplates || {};
|
|
@@ -484,6 +507,7 @@ export const createNotificationTriggerRuntime = (deps) => {
|
|
|
484
507
|
message: lastMessage,
|
|
485
508
|
settings,
|
|
486
509
|
});
|
|
510
|
+
reply = variables.last_message;
|
|
487
511
|
|
|
488
512
|
const resolvedTitle = resolveNotificationTemplate(completionTemplate.title, variables);
|
|
489
513
|
const resolvedBody = resolveNotificationTemplate(completionTemplate.message, variables);
|
|
@@ -511,6 +535,7 @@ export const createNotificationTriggerRuntime = (deps) => {
|
|
|
511
535
|
{
|
|
512
536
|
title,
|
|
513
537
|
body,
|
|
538
|
+
phoneBody: phoneBodyOf('', reply),
|
|
514
539
|
tag: `ready-${sessionId}`,
|
|
515
540
|
data: {
|
|
516
541
|
url: buildSessionDeepLinkUrl(sessionId),
|
|
@@ -539,6 +564,7 @@ export const createNotificationTriggerRuntime = (deps) => {
|
|
|
539
564
|
let title = 'Tool error';
|
|
540
565
|
let body = 'An error occurred';
|
|
541
566
|
let sessionName = '';
|
|
567
|
+
let errorText = '';
|
|
542
568
|
|
|
543
569
|
try {
|
|
544
570
|
const variables = await buildTemplateVariables(payload, sessionId);
|
|
@@ -553,6 +579,7 @@ export const createNotificationTriggerRuntime = (deps) => {
|
|
|
553
579
|
message: lastMessage,
|
|
554
580
|
settings,
|
|
555
581
|
});
|
|
582
|
+
errorText = variables.last_message;
|
|
556
583
|
|
|
557
584
|
const errorTemplate = (settings.notificationTemplates || {}).error || { title: 'Tool error', message: '{last_message}' };
|
|
558
585
|
const resolvedTitle = resolveNotificationTemplate(errorTemplate.title, variables);
|
|
@@ -581,6 +608,7 @@ export const createNotificationTriggerRuntime = (deps) => {
|
|
|
581
608
|
{
|
|
582
609
|
title,
|
|
583
610
|
body,
|
|
611
|
+
phoneBody: phoneBodyOf('Error', errorText),
|
|
584
612
|
tag: `error-${sessionId}`,
|
|
585
613
|
data: {
|
|
586
614
|
url: buildSessionDeepLinkUrl(sessionId),
|
|
@@ -669,6 +697,7 @@ export const createNotificationTriggerRuntime = (deps) => {
|
|
|
669
697
|
{
|
|
670
698
|
title,
|
|
671
699
|
body,
|
|
700
|
+
phoneBody: phoneBodyOf('Question', questionText || header),
|
|
672
701
|
tag: `question-${sessionId}`,
|
|
673
702
|
data: {
|
|
674
703
|
url: buildSessionDeepLinkUrl(formSessionId),
|
|
@@ -714,6 +743,9 @@ export const createNotificationTriggerRuntime = (deps) => {
|
|
|
714
743
|
const permissionMessage = typeof payload.properties?.message === 'string' ? payload.properties.message.trim() : '';
|
|
715
744
|
const permission = permissionMessage
|
|
716
745
|
|| (permissionAction && permissionResource ? `${permissionAction}: ${permissionResource}` : permissionAction);
|
|
746
|
+
const permissionPhoneBody = PERMISSION_PREFIX_BY_ACTION[permissionAction] && permissionResource
|
|
747
|
+
? phoneBodyOf(PERMISSION_PREFIX_BY_ACTION[permissionAction], permissionResource)
|
|
748
|
+
: phoneBodyOf('Wants permission', permission);
|
|
717
749
|
const requestKey = typeof requestId === 'string' ? `${sessionId}:${requestId}` : null;
|
|
718
750
|
if (requestKey && notifiedPermissionRequests.has(requestKey)) {
|
|
719
751
|
return;
|
|
@@ -754,9 +786,10 @@ export const createNotificationTriggerRuntime = (deps) => {
|
|
|
754
786
|
|
|
755
787
|
const sessionTitle = payload.properties?.sessionTitle;
|
|
756
788
|
const permissionText = typeof permission === 'string' && permission.length > 0 ? permission : '';
|
|
757
|
-
|
|
758
|
-
|
|
759
|
-
|
|
789
|
+
// What the agent wants to do decides the answer, so it comes before the session name.
|
|
790
|
+
const fallbackMessage = permissionText
|
|
791
|
+
|| (typeof sessionTitle === 'string' && sessionTitle.trim().length > 0 ? sessionTitle.trim() : '')
|
|
792
|
+
|| 'Agent is waiting for your approval';
|
|
760
793
|
|
|
761
794
|
let title = 'Permission required';
|
|
762
795
|
let body = fallbackMessage;
|
|
@@ -800,6 +833,7 @@ export const createNotificationTriggerRuntime = (deps) => {
|
|
|
800
833
|
{
|
|
801
834
|
title,
|
|
802
835
|
body,
|
|
836
|
+
phoneBody: permissionPhoneBody,
|
|
803
837
|
tag: `permission-${sessionId}`,
|
|
804
838
|
data: {
|
|
805
839
|
url: buildSessionDeepLinkUrl(sessionId),
|
|
@@ -841,6 +875,7 @@ export const createNotificationTriggerRuntime = (deps) => {
|
|
|
841
875
|
{
|
|
842
876
|
title,
|
|
843
877
|
body,
|
|
878
|
+
phoneBody: phoneBodyOf(title, body) || title,
|
|
844
879
|
tag: `goal-${sessionId}`,
|
|
845
880
|
data: {
|
|
846
881
|
url: buildSessionDeepLinkUrl(sessionId),
|
|
@@ -164,12 +164,96 @@ describe('push content in enterprise mode', () => {
|
|
|
164
164
|
expect(web).toMatchObject({ title: 'Agent response is ready', body: '', data: { sessionId: 'ses_e', type: 'ready' } });
|
|
165
165
|
expect(web.data.sessionName).toBeUndefined();
|
|
166
166
|
expect(sendApnsToAllUiSessions.mock.calls[0][0]).toMatchObject({ title: 'Agent response is ready', body: '' });
|
|
167
|
+
expect(sendApnsToAllUiSessions.mock.calls[0][0].sealed).toBeUndefined();
|
|
167
168
|
expect(JSON.stringify([web, sendApnsToAllUiSessions.mock.calls[0][0]])).not.toMatch(/billing|customer/);
|
|
168
169
|
} finally {
|
|
169
170
|
delete process.env.OPENCHAMBER_ENTERPRISE_MODE;
|
|
170
171
|
vi.unstubAllGlobals();
|
|
171
172
|
}
|
|
172
173
|
});
|
|
174
|
+
|
|
175
|
+
it('gives a phone with a push key the session name and the reply', async () => {
|
|
176
|
+
vi.spyOn(console, 'warn').mockImplementation(() => {});
|
|
177
|
+
vi.stubGlobal('fetch', vi.fn(async () => Response.json({ data: {} })));
|
|
178
|
+
try {
|
|
179
|
+
const { runtime, sendPushToAllUiSessions, sendApnsToAllUiSessions } = makePushRuntime();
|
|
180
|
+
await runtime.maybeSendPushForTrigger(stepStarted('ses_p', 'msg_p'));
|
|
181
|
+
await runtime.maybeSendPushForTrigger(turnEnded('ses_p'));
|
|
182
|
+
|
|
183
|
+
const apns = sendApnsToAllUiSessions.mock.calls[0][0];
|
|
184
|
+
// The clear text stays generic; the reply rides only in `sealed`.
|
|
185
|
+
expect(apns).toMatchObject({ title: 'Agent response is ready', body: 'Fix the billing export' });
|
|
186
|
+
expect(apns.sealed).toEqual({ title: 'Fix the billing export', body: 'The customer table is migrated' });
|
|
187
|
+
expect(sendPushToAllUiSessions.mock.calls[0][0].phoneBody).toBeUndefined();
|
|
188
|
+
} finally {
|
|
189
|
+
vi.unstubAllGlobals();
|
|
190
|
+
}
|
|
191
|
+
});
|
|
192
|
+
});
|
|
193
|
+
|
|
194
|
+
describe('phone text for permissions and questions', () => {
|
|
195
|
+
const makeAskRuntime = () => {
|
|
196
|
+
const sendApnsToAllUiSessions = vi.fn(async () => undefined);
|
|
197
|
+
const emitDesktopNotification = vi.fn(() => true);
|
|
198
|
+
const runtime = createNotificationTriggerRuntime({
|
|
199
|
+
readSettingsFromDisk: async () => ({ nativeNotificationsEnabled: true, notificationMode: 'always', notifyOnQuestion: true }),
|
|
200
|
+
buildTemplateVariables: async () => ({ session_name: 'Fix login redirect loop' }),
|
|
201
|
+
resolveNotificationTemplate: (template, variables) => template.replace('{last_message}', variables.last_message ?? ''),
|
|
202
|
+
shouldApplyResolvedTemplateMessage: () => true,
|
|
203
|
+
emitDesktopNotification,
|
|
204
|
+
broadcastUiNotification: vi.fn(),
|
|
205
|
+
sendPushToAllUiSessions: vi.fn(async () => undefined),
|
|
206
|
+
sendApnsToAllUiSessions,
|
|
207
|
+
isAnyInteractiveClientVisible: () => false,
|
|
208
|
+
getIsSessionAutoAccepting: async () => false,
|
|
209
|
+
});
|
|
210
|
+
return { runtime, sendApnsToAllUiSessions, emitDesktopNotification };
|
|
211
|
+
};
|
|
212
|
+
|
|
213
|
+
const permissionAsked = (id, action, resources) => ({
|
|
214
|
+
type: 'permission.asked',
|
|
215
|
+
properties: { sessionID: 'ses_1', id, action, resources },
|
|
216
|
+
});
|
|
217
|
+
|
|
218
|
+
it('names the command or file the agent wants, on the phone and on desktop', async () => {
|
|
219
|
+
vi.useFakeTimers();
|
|
220
|
+
const { runtime, sendApnsToAllUiSessions, emitDesktopNotification } = makeAskRuntime();
|
|
221
|
+
|
|
222
|
+
await runtime.maybeSendPushForTrigger(permissionAsked('per_1', 'bash', ['git push origin bohdan/dev']));
|
|
223
|
+
await vi.advanceTimersByTimeAsync(600);
|
|
224
|
+
await runtime.maybeSendPushForTrigger(permissionAsked('per_2', 'edit', ['~/.ssh/config']));
|
|
225
|
+
await vi.advanceTimersByTimeAsync(600);
|
|
226
|
+
await runtime.maybeSendPushForTrigger(permissionAsked('per_3', 'webfetch', ['https://example.com']));
|
|
227
|
+
await vi.advanceTimersByTimeAsync(600);
|
|
228
|
+
vi.useRealTimers();
|
|
229
|
+
|
|
230
|
+
expect(sendApnsToAllUiSessions.mock.calls.map(([payload]) => payload.sealed)).toEqual([
|
|
231
|
+
{ title: 'Fix login redirect loop', body: 'Wants to run: git push origin bohdan/dev' },
|
|
232
|
+
{ title: 'Fix login redirect loop', body: 'Wants to edit: ~/.ssh/config' },
|
|
233
|
+
{ title: 'Fix login redirect loop', body: 'Wants permission: webfetch: https://example.com' },
|
|
234
|
+
]);
|
|
235
|
+
expect(emitDesktopNotification.mock.calls[0][0].body).toBe('bash: git push origin bohdan/dev');
|
|
236
|
+
});
|
|
237
|
+
|
|
238
|
+
it('puts the question on the phone', async () => {
|
|
239
|
+
vi.useFakeTimers();
|
|
240
|
+
const { runtime, sendApnsToAllUiSessions } = makeAskRuntime();
|
|
241
|
+
|
|
242
|
+
await runtime.maybeSendPushForTrigger({
|
|
243
|
+
type: 'form.created',
|
|
244
|
+
properties: {
|
|
245
|
+
sessionID: 'ses_1',
|
|
246
|
+
form: { id: 'frm_1', sessionID: 'ses_1', title: 'Logout', fields: [{ key: 'q', type: 'string', title: 'Should logout also forget the remembered device?' }] },
|
|
247
|
+
},
|
|
248
|
+
});
|
|
249
|
+
await vi.advanceTimersByTimeAsync(600);
|
|
250
|
+
vi.useRealTimers();
|
|
251
|
+
|
|
252
|
+
expect(sendApnsToAllUiSessions.mock.calls[0][0].sealed).toEqual({
|
|
253
|
+
title: 'Fix login redirect loop',
|
|
254
|
+
body: 'Question: Should logout also forget the remembered device?',
|
|
255
|
+
});
|
|
256
|
+
});
|
|
173
257
|
});
|
|
174
258
|
|
|
175
259
|
describe('subagent finish with subagent notifications off', () => {
|
|
@@ -42,6 +42,10 @@ other.
|
|
|
42
42
|
knowledge Plans list does: in place in the panel on desktop and web, in the
|
|
43
43
|
drawer's plan viewer on mobile. No
|
|
44
44
|
window reached is `503`.
|
|
45
|
+
- `render-page.js` runs `render.page` for the `openchamber_render` agent tool.
|
|
46
|
+
The chat draws the page from the call's own input, so the action stores
|
|
47
|
+
nothing: it checks `html` (at most 200,000 characters) and `title` (at most
|
|
48
|
+
120) and answers `403` while `agentRenderToolEnabled` is `false`.
|
|
45
49
|
- `routes.js` is the authenticated CLI HTTP adapter. It forwards one action,
|
|
46
50
|
preserves service status and partial-result details, and propagates request
|
|
47
51
|
cancellation.
|
|
@@ -99,7 +103,8 @@ other.
|
|
|
99
103
|
(`../openchamber-sessions/worktree-move.js`). The session defaults to the
|
|
100
104
|
caller, the source directory to where that session lives (the global
|
|
101
105
|
session list, else the call's directory), `worktree` names the folder and
|
|
102
|
-
is required, `branch` and `startRef` are optional
|
|
106
|
+
is required, `branch` and `startRef` are optional, and `existingBranch`
|
|
107
|
+
checks out a branch that already exists in place of both. The worktree is made by
|
|
103
108
|
the same `createWorktree` pipeline as `session.create`, waits for the same
|
|
104
109
|
bootstrap, then the checkout's uncommitted changes travel in one git stash
|
|
105
110
|
applied by hash, and the session is moved last through OpenCode's
|
|
@@ -16,7 +16,7 @@ export const OPENCHAMBER_CONTROL_ACTION_DEFINITIONS = Object.freeze([
|
|
|
16
16
|
{ action: 'session.fork', title: 'Fork a session', description: 'Fork sessionId; messageId selects the boundary; prompt is optional' },
|
|
17
17
|
{ action: 'session.status', title: 'Check session status', description: 'Check sessionId status; directory defaults to the current session' },
|
|
18
18
|
{ action: 'session.messages', title: 'Read session messages', description: 'Read text-only messages and current sessionStatus for sessionId; directory and limit 10 are defaults' },
|
|
19
|
-
{ action: 'session.moveToWorktree', title: 'Move a session into a new worktree', description: 'Move sessionId (default: this session) into a new worktree of its repository and continue there: the worktree is made the way the New worktree dialog makes one, branching from startRef (default: the repository\'s default branch), every uncommitted change in the checkout travels with the session, and nothing moves when those changes cannot be carried over. The changes always come from where the session lives; directory is ignored. Requires worktree, a short folder name for the task; branch defaults to it' },
|
|
19
|
+
{ action: 'session.moveToWorktree', title: 'Move a session into a new worktree', description: 'Move sessionId (default: this session) into a new worktree of its repository and continue there: the worktree is made the way the New worktree dialog makes one, branching from startRef (default: the repository\'s default branch), every uncommitted change in the checkout travels with the session, and nothing moves when those changes cannot be carried over. The changes always come from where the session lives; directory is ignored. Requires worktree, a short folder name for the task; branch defaults to it. existingBranch checks out a branch that already exists instead, local or remote such as origin/feature' },
|
|
20
20
|
{ action: 'session.link', title: 'Link a change or issue to a session', description: 'Link a change under review (pull or merge request) or an issue, on any service, to a session; requires link, sessionId defaults to the current session. Each link is added beside the others; linking one that is already there updates its title instead of adding it twice. Links are only added; the user removes them' },
|
|
21
21
|
{ action: 'schedule.status', title: 'Check scheduler status', description: 'Check scheduler status; no parameters', agentExposed: false },
|
|
22
22
|
{ action: 'schedule.list', title: 'List scheduled tasks', description: 'List tasks and scheduler status; scope with projectId or directory' },
|
|
@@ -71,7 +71,7 @@ export const OPENCHAMBER_WEB_ACTIONS = Object.freeze(
|
|
|
71
71
|
export const OPENCHAMBER_MEMORY_ACTION_DEFINITIONS = Object.freeze([
|
|
72
72
|
{ action: 'memory.read', title: 'Read a stored memory', description: 'Read the full text of one memory listed in the session index. The index shows titles only, and a title omits the conditions that decide how the memory applies, so read before acting rather than working from the title. Once read, an entry stays in your context; do not read it again in the same conversation. Requires title (as the index spells it) or memoryId; scope is optional and both stores are searched without it' },
|
|
73
73
|
{ action: 'memory.list', title: 'List stored memories', description: 'List stored memory titles when the session index is missing or stale; scope is global, project, or both (default)' },
|
|
74
|
-
{ action: 'memory.save', title: 'Remember something', description: 'Store a durable fact, preference, or reference; requires title and body, plus scope global (about the user) or project (about this codebase). Restating something already stored updates it. Do not store secrets, one-off task state, or anything the user asked you not to keep; when the user explicitly asks you to remember something, store it unless it is a secret' },
|
|
74
|
+
{ action: 'memory.save', title: 'Remember something', description: 'Store a durable fact, preference, or reference; requires title and body, plus scope global (about the user) or project (about this codebase). Restating something already stored updates it; pass memoryId to rewrite that exact entry, which is how to correct one or merge several into it. Do not store secrets, one-off task state, or anything the user asked you not to keep; when the user explicitly asks you to remember something, store it unless it is a secret' },
|
|
75
75
|
{ action: 'memory.delete', title: 'Forget a memory', description: 'Delete a memory that turned out to be wrong or obsolete; requires memoryId and scope' },
|
|
76
76
|
]);
|
|
77
77
|
|
|
@@ -110,6 +110,20 @@ export const OPENCHAMBER_NOTIFY_ACTIONS = Object.freeze(
|
|
|
110
110
|
OPENCHAMBER_NOTIFY_ACTION_DEFINITIONS.map(({ action }) => action),
|
|
111
111
|
);
|
|
112
112
|
|
|
113
|
+
/**
|
|
114
|
+
* Render is its own tool: a page drawn into the chat is a distinct intent from
|
|
115
|
+
* any of the others, and its long layout guidance should cost context only for
|
|
116
|
+
* users who keep it on. The page itself travels in the call's input, which the
|
|
117
|
+
* chat already stores and syncs, so the action only checks it.
|
|
118
|
+
*/
|
|
119
|
+
export const OPENCHAMBER_RENDER_ACTION_DEFINITIONS = Object.freeze([
|
|
120
|
+
{ action: 'render.page', title: 'Show a page', description: 'Show one finished, self-contained HTML page to the user inline in the chat; requires html and title' },
|
|
121
|
+
]);
|
|
122
|
+
|
|
123
|
+
export const OPENCHAMBER_RENDER_ACTIONS = Object.freeze(
|
|
124
|
+
OPENCHAMBER_RENDER_ACTION_DEFINITIONS.map(({ action }) => action),
|
|
125
|
+
);
|
|
126
|
+
|
|
113
127
|
/**
|
|
114
128
|
* Which actions each managed tool may ask for.
|
|
115
129
|
*
|
|
@@ -126,6 +140,7 @@ const ACTIONS_BY_TOOL = Object.freeze({
|
|
|
126
140
|
openchamber_memory: OPENCHAMBER_MEMORY_ACTIONS,
|
|
127
141
|
openchamber_knowledge: OPENCHAMBER_KNOWLEDGE_ACTIONS,
|
|
128
142
|
openchamber_notify: OPENCHAMBER_NOTIFY_ACTIONS,
|
|
143
|
+
openchamber_render: OPENCHAMBER_RENDER_ACTIONS,
|
|
129
144
|
});
|
|
130
145
|
|
|
131
146
|
const bareName = (action) => {
|
|
@@ -174,4 +189,5 @@ export const OPENCHAMBER_ALL_ACTIONS = Object.freeze([
|
|
|
174
189
|
...OPENCHAMBER_MEMORY_ACTIONS,
|
|
175
190
|
...OPENCHAMBER_KNOWLEDGE_ACTIONS,
|
|
176
191
|
...OPENCHAMBER_NOTIFY_ACTIONS,
|
|
192
|
+
...OPENCHAMBER_RENDER_ACTIONS,
|
|
177
193
|
]);
|
|
@@ -2,6 +2,7 @@ import path from 'node:path';
|
|
|
2
2
|
import { z } from 'zod';
|
|
3
3
|
import { asNonEmptyString } from '../shared/guards.js';
|
|
4
4
|
import { parsePlanMarkdown } from '../project-context/runtime.js';
|
|
5
|
+
import { parsePlanProgress } from '../project-context/plan-progress.js';
|
|
5
6
|
import { OpenChamberControlError } from './error.js';
|
|
6
7
|
|
|
7
8
|
const stringInput = z.string();
|
|
@@ -75,7 +76,20 @@ export const createProjectKnowledgeActions = ({ projectContextRuntime: runtime,
|
|
|
75
76
|
|
|
76
77
|
// A plan is a markdown file: the agent reads and edits it with its own file
|
|
77
78
|
// tools, so the knowledge tool hands out where it lives, never its text.
|
|
78
|
-
const planEntry = ({ id, title, source, createdAt }, filePath) =>
|
|
79
|
+
const planEntry = ({ id, title, source, createdAt, progress }, filePath) => {
|
|
80
|
+
const entry = { id, title, source, createdAt, path: filePath };
|
|
81
|
+
if (progress) entry.progress = progress;
|
|
82
|
+
return entry;
|
|
83
|
+
};
|
|
84
|
+
|
|
85
|
+
/**
|
|
86
|
+
* The panel shows a plan's progress from its `## Steps` checklist, so a plan
|
|
87
|
+
* saved without one is answered with a warning the agent can act on in the
|
|
88
|
+
* same turn rather than a plan whose progress nobody can see.
|
|
89
|
+
*/
|
|
90
|
+
const withStepsCheck = (result, body) => (parsePlanProgress(body)
|
|
91
|
+
? result
|
|
92
|
+
: { ...result, warning: 'This plan has no "## Steps" checklist ("- [ ] step" lines under a "## Steps" heading), so its progress cannot be shown. Add one with the plan\'s coarse steps.' });
|
|
79
93
|
|
|
80
94
|
const list = async (projectId) => {
|
|
81
95
|
const context = await runtime.readContext(projectId);
|
|
@@ -136,13 +150,13 @@ export const createProjectKnowledgeActions = ({ projectContextRuntime: runtime,
|
|
|
136
150
|
// The first heading is the title, as it is when the user edits a plan.
|
|
137
151
|
const { plan } = await runtime.createPlan(projectId, parsePlanMarkdown(body));
|
|
138
152
|
const stored = found(await runtime.readPlan(projectId, plan.id), 'Plan', plan.id);
|
|
139
|
-
return { projectId, plan: planEntry(plan, stored.path) };
|
|
153
|
+
return withStepsCheck({ projectId, plan: planEntry(plan, stored.path) }, body);
|
|
140
154
|
}
|
|
141
155
|
const id = idOf(input);
|
|
142
156
|
const expected = expectedOf(input);
|
|
143
157
|
const saved = found(await runtime.updatePlan(projectId, id, { raw: body }, expected === undefined ? {} : { expectedRaw: expected }), 'Plan', id);
|
|
144
158
|
const stored = found(await runtime.readPlan(projectId, id), 'Plan', id);
|
|
145
|
-
return { projectId, plan: planEntry(saved.plan, stored.path) };
|
|
159
|
+
return withStepsCheck({ projectId, plan: planEntry(saved.plan, stored.path) }, body);
|
|
146
160
|
};
|
|
147
161
|
|
|
148
162
|
const remove = async (projectId, input) => {
|
|
@@ -40,6 +40,20 @@ const setup = (overrides = {}) => {
|
|
|
40
40
|
};
|
|
41
41
|
|
|
42
42
|
describe('project knowledge control actions', () => {
|
|
43
|
+
it('warns when a saved plan has no Steps checklist, so the agent adds one', async () => {
|
|
44
|
+
const { service } = setup();
|
|
45
|
+
const bare = await service.execute('knowledge.save', { kind: 'plan', body: '# Release\n\nShip it' }, '/repo');
|
|
46
|
+
expect(bare.warning).toContain('## Steps');
|
|
47
|
+
const stepped = await service.execute('knowledge.save', { kind: 'plan', id: 'plan-1', body: '# Release\n\n## Steps\n- [ ] ship' }, '/repo');
|
|
48
|
+
expect(stepped).not.toHaveProperty('warning');
|
|
49
|
+
});
|
|
50
|
+
|
|
51
|
+
it('lists a plan with its progress', async () => {
|
|
52
|
+
const { service, context } = setup();
|
|
53
|
+
context.plans[0].progress = { done: 1, total: 3 };
|
|
54
|
+
expect((await service.execute('knowledge.list', {}, '/repo')).plans[0].progress).toEqual({ done: 1, total: 3 });
|
|
55
|
+
});
|
|
56
|
+
|
|
43
57
|
it.each([
|
|
44
58
|
[{}, '/worktree', '/repo'],
|
|
45
59
|
[{ projectId: 'configured-repo' }, '/other', '/repo'],
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
import { isString } from '../shared/guards.js';
|
|
2
|
+
import { OpenChamberControlError } from './error.js';
|
|
3
|
+
|
|
4
|
+
// The page travels in the tool call's input, which OpenCode stores with the
|
|
5
|
+
// message and streams to every client, and through the callback request, whose
|
|
6
|
+
// JSON body is capped at 1 MB. 200,000 characters stays under that cap even for
|
|
7
|
+
// text that encodes to several bytes per character, and is far more than a
|
|
8
|
+
// chart or table page needs.
|
|
9
|
+
export const RENDER_PAGE_MAX_HTML_LENGTH = 200_000;
|
|
10
|
+
export const RENDER_PAGE_MAX_TITLE_LENGTH = 120;
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* When a page beats prose, and when it does not. Both the tool description
|
|
14
|
+
* and the line every session carries (../session-knowledge/runtime.js) state
|
|
15
|
+
* it. Stated only in the tool description, it went unread: asked for a
|
|
16
|
+
* breakdown of lines of code per package, an agent answered with a list and
|
|
17
|
+
* drew the chart only when asked. Interface mockups are named on their own:
|
|
18
|
+
* listed only as data, the cases read to a literal model as "charts only",
|
|
19
|
+
* while a proposed UI change is where a page helps most. The limits matter as
|
|
20
|
+
* much as the cases: a page for two numbers is worse than a sentence.
|
|
21
|
+
*/
|
|
22
|
+
export const RENDER_PAGE_WHEN = "Use it when the answer is mostly data or structure the user would otherwise have to picture:"
|
|
23
|
+
+ " numbers compared across several items (sizes, counts, timings, costs, test or benchmark results),"
|
|
24
|
+
+ " a breakdown or share of a whole, a trend over time, options compared on several criteria,"
|
|
25
|
+
+ " a timeline of events, or how components connect."
|
|
26
|
+
+ " Use it too when the answer is about how something looks: a proposed interface change shown as it would appear,"
|
|
27
|
+
+ " before and after side by side, or layout options to choose between."
|
|
28
|
+
+ " Do not use it for a few numbers or a short list that reads fine as text, for code, or when the user asked for plain text."
|
|
29
|
+
+ " At most one page per answer.";
|
|
30
|
+
|
|
31
|
+
const SHOWN_NOTE = "Shown to the user in the chat above your reply. Don't announce, describe or restate the page; reply with only what it doesn't already say.";
|
|
32
|
+
|
|
33
|
+
/**
|
|
34
|
+
* `render.page`: the chat draws the page straight from the call's input, so
|
|
35
|
+
* this only checks that the input is a page the chat will draw and that the
|
|
36
|
+
* tool is still on (a plugin generated before it was switched off must not keep
|
|
37
|
+
* drawing).
|
|
38
|
+
*/
|
|
39
|
+
export const createRenderPageAction = ({ isEnabled }) => async (input) => {
|
|
40
|
+
if (!await isEnabled()) {
|
|
41
|
+
throw new OpenChamberControlError('The render tool is turned off in OpenChamber settings', 403);
|
|
42
|
+
}
|
|
43
|
+
const html = isString(input.html) ? input.html : '';
|
|
44
|
+
if (!html.trim()) {
|
|
45
|
+
throw new OpenChamberControlError('html is required: one complete, self-contained HTML document', 400);
|
|
46
|
+
}
|
|
47
|
+
if (html.length > RENDER_PAGE_MAX_HTML_LENGTH) {
|
|
48
|
+
throw new OpenChamberControlError(`html is ${html.length} characters; the limit is ${RENDER_PAGE_MAX_HTML_LENGTH}. Make the page smaller, for example by drawing data with a script instead of writing out every element`, 400);
|
|
49
|
+
}
|
|
50
|
+
const title = isString(input.title) ? input.title.trim() : '';
|
|
51
|
+
if (!title) {
|
|
52
|
+
throw new OpenChamberControlError('title is required: a short name for the page', 400);
|
|
53
|
+
}
|
|
54
|
+
if (title.length > RENDER_PAGE_MAX_TITLE_LENGTH) {
|
|
55
|
+
throw new OpenChamberControlError(`title is ${title.length} characters; the limit is ${RENDER_PAGE_MAX_TITLE_LENGTH}`, 400);
|
|
56
|
+
}
|
|
57
|
+
return { shown: true, title, note: SHOWN_NOTE };
|
|
58
|
+
};
|
|
@@ -5,6 +5,7 @@ import { OpenChamberControlError, asControlError } from './error.js';
|
|
|
5
5
|
import { OPENCHAMBER_ALL_ACTIONS, OPENCHAMBER_KNOWLEDGE_ACTIONS } from './actions.js';
|
|
6
6
|
import { writeScreenshot } from './screenshots.js';
|
|
7
7
|
import { createProjectKnowledgeActions } from './project-knowledge.js';
|
|
8
|
+
import { createRenderPageAction } from './render-page.js';
|
|
8
9
|
|
|
9
10
|
const DEFAULT_WAIT_TIMEOUT_SECONDS = 600;
|
|
10
11
|
const MAX_WAIT_TIMEOUT_SECONDS = 86_400;
|
|
@@ -222,6 +223,7 @@ export const createOpenChamberControlService = (dependencies) => {
|
|
|
222
223
|
projectContextRuntime = null,
|
|
223
224
|
resolveProjectContextId = null,
|
|
224
225
|
isKnowledgeToolEnabled = async () => true,
|
|
226
|
+
isRenderToolEnabled = async () => true,
|
|
225
227
|
// Puts a plan in front of the user; answers how many windows it reached.
|
|
226
228
|
showPlan = null,
|
|
227
229
|
// Delivers a dispatched session's result back to the session that asked
|
|
@@ -309,6 +311,8 @@ export const createOpenChamberControlService = (dependencies) => {
|
|
|
309
311
|
resolveDirectory: (input) => sessionService.resolveDirectory(input),
|
|
310
312
|
});
|
|
311
313
|
|
|
314
|
+
const renderPage = createRenderPageAction({ isEnabled: isRenderToolEnabled });
|
|
315
|
+
|
|
312
316
|
const models = async () => {
|
|
313
317
|
const settings = await readSettingsFromDiskMigrated();
|
|
314
318
|
return {
|
|
@@ -742,6 +746,9 @@ export const createOpenChamberControlService = (dependencies) => {
|
|
|
742
746
|
}
|
|
743
747
|
return result.body;
|
|
744
748
|
}
|
|
749
|
+
if (action === 'render.page') {
|
|
750
|
+
return await renderPage(input);
|
|
751
|
+
}
|
|
745
752
|
if (action === 'file.open') {
|
|
746
753
|
if (!fileOpen) {
|
|
747
754
|
throw new OpenChamberControlError('The file viewer is not available on this server', 503);
|
|
@@ -829,6 +836,8 @@ export const createOpenChamberControlService = (dependencies) => {
|
|
|
829
836
|
if (branch) worktree.branchName = branch.trim();
|
|
830
837
|
const startRef = asNonEmptyString(input.startRef);
|
|
831
838
|
if (startRef) worktree.startRef = startRef.trim();
|
|
839
|
+
const existingBranch = asNonEmptyString(input.existingBranch);
|
|
840
|
+
if (existingBranch) worktree.existingBranch = existingBranch.trim();
|
|
832
841
|
const payload = { worktree };
|
|
833
842
|
if (directory) payload.directory = directory;
|
|
834
843
|
return sessionService.moveToWorktree(sessionID, payload);
|
|
@@ -247,6 +247,18 @@ describe('OpenChamber control service', () => {
|
|
|
247
247
|
});
|
|
248
248
|
});
|
|
249
249
|
|
|
250
|
+
it('passes a branch that already exists through to the move', async () => {
|
|
251
|
+
const moveToWorktree = vi.fn(async () => ({}));
|
|
252
|
+
const { service } = createService({ sessionService: { moveToWorktree } });
|
|
253
|
+
|
|
254
|
+
await service.execute('session.moveToWorktree', { worktree: 'review', existingBranch: ' origin/review ' }, '/repo', { contextSessionId: 'ses_me' });
|
|
255
|
+
|
|
256
|
+
expect(moveToWorktree).toHaveBeenCalledWith('ses_me', {
|
|
257
|
+
directory: '/repo',
|
|
258
|
+
worktree: { name: 'review', existingBranch: 'origin/review' },
|
|
259
|
+
});
|
|
260
|
+
});
|
|
261
|
+
|
|
250
262
|
it('moves a named session from where that session lives', async () => {
|
|
251
263
|
const moveToWorktree = vi.fn(async () => ({}));
|
|
252
264
|
const { service, client } = createService({ sessionService: { moveToWorktree } });
|
|
@@ -607,6 +619,37 @@ describe('notify.send', () => {
|
|
|
607
619
|
});
|
|
608
620
|
});
|
|
609
621
|
|
|
622
|
+
describe('render.page', () => {
|
|
623
|
+
const page = '<!doctype html><p>Hi</p>';
|
|
624
|
+
|
|
625
|
+
it('accepts a page with a title and tells the agent not to restate it', async () => {
|
|
626
|
+
const { service } = createService();
|
|
627
|
+
|
|
628
|
+
const result = await service.execute('render.page', { html: page, title: ' Coverage ' }, '/repo');
|
|
629
|
+
|
|
630
|
+
expect(result).toMatchObject({ shown: true, title: 'Coverage' });
|
|
631
|
+
expect(result.note).toContain("Don't announce");
|
|
632
|
+
});
|
|
633
|
+
|
|
634
|
+
it.each([
|
|
635
|
+
[{ title: 'Coverage' }, 'html is required'],
|
|
636
|
+
[{ html: ' ', title: 'Coverage' }, 'html is required'],
|
|
637
|
+
[{ html: 'x'.repeat(200_001), title: 'Coverage' }, 'the limit is 200000'],
|
|
638
|
+
[{ html: page }, 'title is required'],
|
|
639
|
+
[{ html: page, title: 't'.repeat(121) }, 'the limit is 120'],
|
|
640
|
+
])('refuses %o with a reason the agent can act on', async (input, reason) => {
|
|
641
|
+
const { service } = createService();
|
|
642
|
+
await expect(service.execute('render.page', input, '/repo'))
|
|
643
|
+
.rejects.toMatchObject({ statusCode: 400, message: expect.stringContaining(reason) });
|
|
644
|
+
});
|
|
645
|
+
|
|
646
|
+
it('refuses while the tool is switched off, so a stale plugin cannot keep drawing', async () => {
|
|
647
|
+
const { service } = createService({ isRenderToolEnabled: async () => false });
|
|
648
|
+
await expect(service.execute('render.page', { html: page, title: 'Coverage' }, '/repo'))
|
|
649
|
+
.rejects.toMatchObject({ statusCode: 403 });
|
|
650
|
+
});
|
|
651
|
+
});
|
|
652
|
+
|
|
610
653
|
describe('browser capture', () => {
|
|
611
654
|
const pixel = 'iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAADUlEQVR42mP8z8BQDwAEhQGAhKmMIQAAAABJRU5ErkJggg==';
|
|
612
655
|
|
|
@@ -1138,6 +1138,7 @@ export const createOpenChamberSessionService = (dependencies) => {
|
|
|
1138
1138
|
name: asNonEmptyString(payload.worktree?.name),
|
|
1139
1139
|
branchName: asNonEmptyString(payload.worktree?.branchName),
|
|
1140
1140
|
startRef: asNonEmptyString(payload.worktree?.startRef),
|
|
1141
|
+
existingBranch: asNonEmptyString(payload.worktree?.existingBranch),
|
|
1141
1142
|
});
|
|
1142
1143
|
};
|
|
1143
1144
|
|