@myrialabs/clopen 0.4.40 → 0.4.42
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/.env.example +1 -1
- package/backend/artifacts/detect.ts +15 -3
- package/backend/artifacts/generate.ts +2 -2
- package/backend/artifacts/index.ts +12 -4
- package/backend/artifacts/markers.ts +24 -1
- package/backend/artifacts/matrix.ts +47 -3
- package/backend/artifacts/sync.test.ts +3 -3
- package/backend/artifacts/sync.ts +8 -20
- package/backend/artifacts/types.ts +9 -3
- package/backend/auth/permissions.ts +6 -11
- package/backend/auth/session-cleanup.ts +10 -1
- package/backend/auth/tokens.ts +9 -1
- package/backend/chat/stream-manager.ts +50 -0
- package/backend/database/crypto/secret-columns.ts +5 -1
- package/backend/database/index.ts +18 -0
- package/backend/database/migrations/079_merge_commands_into_skills.ts +222 -0
- package/backend/database/migrations/080_create_file_shares.ts +111 -0
- package/backend/database/migrations/081_create_push_subscriptions.ts +32 -0
- package/backend/database/migrations/082_create_git_identities.test.ts +186 -0
- package/backend/database/migrations/082_create_git_identities.ts +122 -0
- package/backend/database/migrations/index.ts +28 -0
- package/backend/database/queries/file-share-queries.ts +163 -0
- package/backend/database/queries/git-identity-queries.ts +290 -0
- package/backend/database/queries/index.ts +8 -4
- package/backend/database/queries/profile-queries.ts +5 -3
- package/backend/database/queries/push-subscription-queries.test.ts +90 -0
- package/backend/database/queries/push-subscription-queries.ts +99 -0
- package/backend/database/queries/skill-queries.ts +96 -18
- package/backend/engine/adapters/claude/environment.ts +11 -1
- package/backend/engine/adapters/claude/stream.ts +3 -2
- package/backend/engine/adapters/cline/stream.ts +3 -3
- package/backend/engine/adapters/codex/stream.ts +38 -6
- package/backend/engine/adapters/copilot/stream.ts +3 -3
- package/backend/engine/adapters/cursor/stream.ts +25 -3
- package/backend/engine/adapters/opencode/server.ts +26 -2
- package/backend/engine/adapters/opencode/stream.ts +8 -7
- package/backend/engine/adapters/pi/stream.ts +2 -2
- package/backend/engine/adapters/qwen/stream.ts +5 -3
- package/backend/engine/artifact-sync.ts +26 -20
- package/backend/engine/docs/artifacts.md +81 -22
- package/backend/engine/docs/quick-reference.md +2 -1
- package/backend/engine/resolve-model.test.ts +108 -0
- package/backend/engine/resolve-model.ts +53 -10
- package/backend/engine/structured-helpers.ts +22 -0
- package/backend/engine/types.ts +10 -0
- package/backend/files/file-shares.ts +369 -0
- package/backend/files/path-browsing.ts +27 -21
- package/backend/git/git-executor.ts +28 -2
- package/backend/git/git-service.ts +59 -40
- package/backend/git/identity/cli.test.ts +58 -0
- package/backend/git/identity/cli.ts +201 -0
- package/backend/git/identity/credential-helper.test.ts +242 -0
- package/backend/git/identity/env.test.ts +214 -0
- package/backend/git/identity/env.ts +193 -0
- package/backend/git/identity/import-local.test.ts +199 -0
- package/backend/git/identity/import-local.ts +141 -0
- package/backend/git/identity/index.ts +78 -0
- package/backend/git/identity/keys.ts +183 -0
- package/backend/git/identity/resolve.ts +140 -0
- package/backend/git/identity/scope-config.test.ts +145 -0
- package/backend/git/identity/scope-config.ts +175 -0
- package/backend/git/identity/service.ts +297 -0
- package/backend/http/files-shared.test.ts +505 -0
- package/backend/http/files-shared.ts +351 -0
- package/backend/http/push.ts +150 -0
- package/backend/index.ts +24 -0
- package/backend/instructions/index.ts +1 -1
- package/backend/instructions/sync.ts +30 -6
- package/backend/memory/compose.ts +2 -2
- package/backend/memory/consolidate.ts +2 -2
- package/backend/memory/extract/episodic.ts +2 -2
- package/backend/memory/judge.ts +2 -2
- package/backend/preview/browser/browser-console-manager.ts +214 -34
- package/backend/preview/browser/browser-pool.ts +526 -123
- package/backend/preview/browser/browser-preview-service.ts +192 -8
- package/backend/preview/browser/browser-tab-lifecycle.test.ts +240 -0
- package/backend/preview/browser/browser-tab-lifecycle.ts +495 -0
- package/backend/preview/browser/browser-tab-manager.ts +291 -65
- package/backend/preview/browser/capture-profile.ts +15 -1
- package/backend/preview/browser/types.ts +26 -1
- package/backend/profiles/service.ts +7 -6
- package/backend/push/sender.ts +172 -0
- package/backend/push/tags.ts +25 -0
- package/backend/push/vapid-keys.ts +77 -0
- package/backend/push/webpush-crypto.test.ts +200 -0
- package/backend/push/webpush-crypto.ts +231 -0
- package/backend/skills/detect.ts +28 -0
- package/backend/skills/index.ts +22 -4
- package/backend/skills/invoke.test.ts +114 -0
- package/backend/skills/invoke.ts +222 -0
- package/backend/skills/service.ts +194 -44
- package/backend/skills/spec.ts +35 -0
- package/backend/skills/sync.ts +85 -55
- package/backend/subagents/detect.ts +2 -3
- package/backend/subagents/sync.ts +15 -8
- package/backend/terminal/ptykit.ts +24 -0
- package/backend/work/pull-requests.ts +2 -2
- package/backend/ws/chat/stream.ts +100 -8
- package/backend/ws/files/index.ts +4 -0
- package/backend/ws/files/share.ts +95 -0
- package/backend/ws/git/branch-name.ts +2 -2
- package/backend/ws/git/branch.ts +17 -6
- package/backend/ws/git/commit-message.ts +2 -2
- package/backend/ws/git/commit.ts +6 -5
- package/backend/ws/git/conflict.ts +3 -2
- package/backend/ws/git/identity-context.ts +91 -0
- package/backend/ws/git/identity.ts +200 -0
- package/backend/ws/git/index.ts +3 -1
- package/backend/ws/git/remote.ts +57 -11
- package/backend/ws/index.ts +3 -4
- package/backend/ws/preview/browser/data.ts +60 -0
- package/backend/ws/preview/browser/interact.ts +6 -0
- package/backend/ws/preview/browser/tab-info.ts +9 -1
- package/backend/ws/preview/browser/tab.ts +64 -8
- package/backend/ws/preview/index.ts +21 -0
- package/backend/ws/profiles/crud.ts +2 -3
- package/backend/ws/skills/catalog.ts +5 -1
- package/backend/ws/skills/crud.ts +128 -22
- package/backend/ws/skills/index.ts +4 -1
- package/backend/ws/user/crud.ts +12 -3
- package/bin/clopen.ts +9 -0
- package/dist/assets/{index-D4igjF6e.js → index-BynqyvF4.js} +1 -1
- package/dist/assets/{index-DONNwiXm.js → index-DLoJsmNQ.js} +1 -1
- package/dist/assets/{main-BrfXH1bL.js → main-CUyZAmqt.js} +601 -592
- package/dist/assets/main-DVCW3cfr.css +1 -0
- package/dist/index.html +7 -2
- package/dist/sw.js +112 -0
- package/package.json +2 -2
- package/shared/constants/engine-tools.ts +31 -6
- package/shared/constants/notification-messages.ts +142 -0
- package/shared/types/git-identity.ts +112 -0
- package/shared/types/unified/stream.ts +7 -0
- package/backend/commands/detect.ts +0 -25
- package/backend/commands/index.ts +0 -9
- package/backend/commands/service.ts +0 -178
- package/backend/commands/store.ts +0 -45
- package/backend/commands/sync.ts +0 -94
- package/backend/database/queries/command-queries.ts +0 -82
- package/backend/ws/commands/crud.ts +0 -157
- package/backend/ws/commands/index.ts +0 -8
- package/dist/assets/main-CT1PygsW.css +0 -1
package/dist/index.html
CHANGED
|
@@ -10,6 +10,11 @@
|
|
|
10
10
|
content="Clopen - Modern web UI for Claude Code & OpenCode with real browser preview, git management, multi-account support, file management, checkpoints, collaboration, and integrated terminal. Built with Bun and Svelte 5."
|
|
11
11
|
/>
|
|
12
12
|
<meta name="theme-color" content="#0e172b" />
|
|
13
|
+
<!-- PWA installability: iOS only delivers web notifications to an
|
|
14
|
+
installed web app opened from the home screen. -->
|
|
15
|
+
<meta name="mobile-web-app-capable" content="yes" />
|
|
16
|
+
<meta name="apple-mobile-web-app-capable" content="yes" />
|
|
17
|
+
<meta name="apple-mobile-web-app-status-bar-style" content="black-translucent" />
|
|
13
18
|
<title>Clopen</title>
|
|
14
19
|
|
|
15
20
|
<!-- DM Sans - Local self-hosted font -->
|
|
@@ -58,8 +63,8 @@
|
|
|
58
63
|
}
|
|
59
64
|
})();
|
|
60
65
|
</script>
|
|
61
|
-
<script type="module" crossorigin src="/assets/main-
|
|
62
|
-
<link rel="stylesheet" crossorigin href="/assets/main-
|
|
66
|
+
<script type="module" crossorigin src="/assets/main-CUyZAmqt.js"></script>
|
|
67
|
+
<link rel="stylesheet" crossorigin href="/assets/main-DVCW3cfr.css">
|
|
63
68
|
</head>
|
|
64
69
|
<body
|
|
65
70
|
class="min-h-dvh bg-white text-slate-900 dark:bg-slate-950 dark:text-slate-100 transition-colors duration-200"
|
package/dist/sw.js
ADDED
|
@@ -0,0 +1,112 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Clopen service worker.
|
|
3
|
+
*
|
|
4
|
+
* Exists for one reason: mobile notifications. Chrome on Android does not
|
|
5
|
+
* support `new Notification()` from a page — construction throws — and only
|
|
6
|
+
* a service worker's `registration.showNotification()` can raise a native
|
|
7
|
+
* toast there. iOS (16.4+) likewise only displays web notifications for an
|
|
8
|
+
* installed web app via its service worker. Desktop keeps using
|
|
9
|
+
* `new Notification()` directly and never touches this file.
|
|
10
|
+
*
|
|
11
|
+
* This worker has no fetch handler and caches nothing of its own. It only:
|
|
12
|
+
* - raises a toast for a server-sent `push` (the one path that works with
|
|
13
|
+
* the tab closed) and for explicit `showNotification()` calls from the page,
|
|
14
|
+
* - focuses or opens the app when a notification is tapped,
|
|
15
|
+
* - dismisses cleanly on swipe.
|
|
16
|
+
*/
|
|
17
|
+
|
|
18
|
+
self.addEventListener('notificationclick', (event) => {
|
|
19
|
+
event.notification.close();
|
|
20
|
+
|
|
21
|
+
const url = (event.notification.data && event.notification.data.url) || '/';
|
|
22
|
+
|
|
23
|
+
event.waitUntil(
|
|
24
|
+
(async () => {
|
|
25
|
+
const allClients = await self.clients.matchAll({ type: 'window', includeUncontrolled: true });
|
|
26
|
+
for (const client of allClients) {
|
|
27
|
+
// Reuse the open tab instead of spawning a duplicate.
|
|
28
|
+
if ('focus' in client) {
|
|
29
|
+
try {
|
|
30
|
+
await client.focus();
|
|
31
|
+
} catch {
|
|
32
|
+
// A closed or detached client — try the next one.
|
|
33
|
+
continue;
|
|
34
|
+
}
|
|
35
|
+
if ('navigate' in client && client.url !== url) {
|
|
36
|
+
try {
|
|
37
|
+
await client.navigate(url);
|
|
38
|
+
} catch {
|
|
39
|
+
// Navigation is best-effort; the focused tab is enough.
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
return;
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
if (self.clients.openWindow) {
|
|
46
|
+
await self.clients.openWindow(url);
|
|
47
|
+
}
|
|
48
|
+
})()
|
|
49
|
+
);
|
|
50
|
+
});
|
|
51
|
+
|
|
52
|
+
self.addEventListener('notificationclose', () => {
|
|
53
|
+
// No bookkeeping to do — present so a dismissed toast settles quietly.
|
|
54
|
+
});
|
|
55
|
+
|
|
56
|
+
/**
|
|
57
|
+
* The notification icon, as a PNG data URL the page rasterised and left in
|
|
58
|
+
* the Cache API.
|
|
59
|
+
*
|
|
60
|
+
* `/favicon.svg` cannot be used directly: Chromium decodes notification
|
|
61
|
+
* images with its raster decoders, which have no SVG support, so an Android
|
|
62
|
+
* push would arrive with no icon — the same gap `notification-icon.ts`
|
|
63
|
+
* already closes for desktop. Reading it here (rather than holding it in a
|
|
64
|
+
* variable) is deliberate: the worker is torn down between push events, so
|
|
65
|
+
* in-memory state would never survive to the one delivery that matters.
|
|
66
|
+
*/
|
|
67
|
+
async function notificationIconUrl() {
|
|
68
|
+
try {
|
|
69
|
+
const cached = await caches.match('/__clopen/notification-icon');
|
|
70
|
+
if (!cached) return '/favicon.svg';
|
|
71
|
+
const dataUrl = await cached.text();
|
|
72
|
+
return dataUrl.startsWith('data:') ? dataUrl : '/favicon.svg';
|
|
73
|
+
} catch {
|
|
74
|
+
return '/favicon.svg';
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
self.addEventListener('push', (event) => {
|
|
79
|
+
// Server-sent push (chat completions, waiting-for-input, test pushes).
|
|
80
|
+
// This is what wakes the device when Chrome is closed: the page is gone,
|
|
81
|
+
// but the worker still runs and raises the native toast. A malformed
|
|
82
|
+
// payload must never crash the worker.
|
|
83
|
+
let data = null;
|
|
84
|
+
try {
|
|
85
|
+
data = event.data ? event.data.json() : null;
|
|
86
|
+
} catch {
|
|
87
|
+
return;
|
|
88
|
+
}
|
|
89
|
+
if (!data || typeof data.title !== 'string' || !data.title) return;
|
|
90
|
+
|
|
91
|
+
// The tag is identity: it matches the local toast the open tab shows for
|
|
92
|
+
// the same event, so the two collapse into one instead of stacking.
|
|
93
|
+
const tag =
|
|
94
|
+
typeof data.tag === 'string' && data.tag ? data.tag : `push-${Date.now()}`;
|
|
95
|
+
|
|
96
|
+
event.waitUntil(
|
|
97
|
+
(async () => {
|
|
98
|
+
const icon = await notificationIconUrl();
|
|
99
|
+
await self.registration.showNotification(data.title, {
|
|
100
|
+
body: typeof data.body === 'string' ? data.body : '',
|
|
101
|
+
tag,
|
|
102
|
+
icon,
|
|
103
|
+
badge: icon,
|
|
104
|
+
// Buzz on Android; silently ignored where unsupported (iOS/desktop).
|
|
105
|
+
vibrate: [100, 50, 100],
|
|
106
|
+
renotify: false,
|
|
107
|
+
requireInteraction: false,
|
|
108
|
+
data: { url: typeof data.url === 'string' && data.url ? data.url : '/' }
|
|
109
|
+
});
|
|
110
|
+
})()
|
|
111
|
+
);
|
|
112
|
+
});
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@myrialabs/clopen",
|
|
3
|
-
"version": "0.4.
|
|
3
|
+
"version": "0.4.42",
|
|
4
4
|
"description": "All-in-one web workspace for AI coding agents — Claude Code, OpenCode, Codex, Copilot, Qwen Code, Pi, Cline, and Cursor — with chat, terminal, git, browser preview, database client, checkpoints, and real-time collaboration",
|
|
5
5
|
"author": "Myria Labs",
|
|
6
6
|
"license": "MIT",
|
|
@@ -119,7 +119,7 @@
|
|
|
119
119
|
"@iconify-json/material-icon-theme": "1.2.55",
|
|
120
120
|
"@modelcontextprotocol/sdk": "1.29.0",
|
|
121
121
|
"@monaco-editor/loader": "1.7.0",
|
|
122
|
-
"@myrialabs/ptykit": "0.0.
|
|
122
|
+
"@myrialabs/ptykit": "0.0.7",
|
|
123
123
|
"@myrialabs/tunnelkit": "0.0.15",
|
|
124
124
|
"@myrialabs/zipkit": "0.0.11",
|
|
125
125
|
"@sinclair/typebox": "0.34.48",
|
|
@@ -46,14 +46,38 @@ export const ENGINE_BUILTIN_TOOLS: Record<EngineType, string[]> = {
|
|
|
46
46
|
// Cline — @cline/sdk default tool names, enforced via `toolPolicies` (a denied
|
|
47
47
|
// tool is set `{ enabled: false }`, hiding it from the model entirely).
|
|
48
48
|
cline: ['read_files', 'search_codebase', 'run_commands', 'fetch_web_content', 'apply_patch', 'editor', 'skills', 'ask_question'],
|
|
49
|
-
// Cursor — @cursor/sdk
|
|
50
|
-
//
|
|
51
|
-
|
|
49
|
+
// Cursor — names from @cursor/sdk's public tool vocabulary (`ToolName`),
|
|
50
|
+
// enforced by passing the blocked set as `disallowedTools` on Agent
|
|
51
|
+
// create/resume. The SDK REJECTS unknown names with a ConfigurationError, so
|
|
52
|
+
// these must stay spelled exactly as the SDK spells them (`webSearch`, not
|
|
53
|
+
// `web_search`). `mcp` is deliberately absent: it is a capability group whose
|
|
54
|
+
// removal would also kill Clopen's in-process custom tools (AskUserQuestion),
|
|
55
|
+
// so it is not offered as a per-tool target.
|
|
56
|
+
cursor: [
|
|
57
|
+
'shell',
|
|
58
|
+
'read',
|
|
59
|
+
'edit',
|
|
60
|
+
'delete',
|
|
61
|
+
'ls',
|
|
62
|
+
'glob',
|
|
63
|
+
'grep',
|
|
64
|
+
'semSearch',
|
|
65
|
+
'task',
|
|
66
|
+
'webSearch',
|
|
67
|
+
'webFetch',
|
|
68
|
+
'readLints',
|
|
69
|
+
'updateTodos',
|
|
70
|
+
'readTodos',
|
|
71
|
+
'generateImage',
|
|
72
|
+
'applyAgentDiff'
|
|
73
|
+
]
|
|
52
74
|
};
|
|
53
75
|
|
|
54
76
|
/**
|
|
55
77
|
* Engines whose permission enforcement is best-effort. Only Codex — it has no
|
|
56
|
-
* per-call permission hook
|
|
78
|
+
* per-call permission hook; every other engine enforces at runtime, either at a
|
|
79
|
+
* per-call surface (Claude/Qwen/Copilot/OpenCode/Pi) or by withholding the tool
|
|
80
|
+
* from the model entirely (Cline `toolPolicies`, Cursor `disallowedTools`).
|
|
57
81
|
*/
|
|
58
82
|
export const ENGINE_TOOLS_BEST_EFFORT: Record<EngineType, boolean> = {
|
|
59
83
|
'claude-code': false,
|
|
@@ -65,6 +89,7 @@ export const ENGINE_TOOLS_BEST_EFFORT: Record<EngineType, boolean> = {
|
|
|
65
89
|
pi: false,
|
|
66
90
|
// Cline enforces allow/deny via `toolPolicies` (`{ enabled: false }` = real).
|
|
67
91
|
cline: false,
|
|
68
|
-
// Cursor
|
|
69
|
-
|
|
92
|
+
// Cursor enforces allow/deny through `AgentOptions.disallowedTools` (a blocked
|
|
93
|
+
// tool is never offered to the model) — real, not best-effort.
|
|
94
|
+
cursor: false
|
|
70
95
|
};
|
|
@@ -0,0 +1,142 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Notification wording — the single source of truth for every notification
|
|
3
|
+
* Clopen raises, on both sides of the wire.
|
|
4
|
+
*
|
|
5
|
+
* Every chat event is announced twice: the open tab raises a local toast, and
|
|
6
|
+
* the server pushes to the user's registered devices so the notice survives a
|
|
7
|
+
* closed tab. The two copies share a tag, which means the server copy
|
|
8
|
+
* *replaces* the local one rather than stacking beside it — and a replacement
|
|
9
|
+
* is only invisible when both say exactly the same thing. Four separate
|
|
10
|
+
* copies of these strings (two per side) is what let them drift apart before.
|
|
11
|
+
*/
|
|
12
|
+
|
|
13
|
+
/** Chat lifecycle moments worth interrupting the user for. */
|
|
14
|
+
export type ChatNotificationEvent = 'completed' | 'cancelled' | 'error' | 'waiting-input';
|
|
15
|
+
|
|
16
|
+
/**
|
|
17
|
+
* Where the event happened. Both fields are optional because both can be
|
|
18
|
+
* genuinely unknown — a project row deleted mid-stream, a session whose title
|
|
19
|
+
* has not been derived from the first message yet.
|
|
20
|
+
*/
|
|
21
|
+
export interface ChatNotificationContext {
|
|
22
|
+
projectName?: string;
|
|
23
|
+
sessionTitle?: string;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
/**
|
|
27
|
+
* How long a push service holds a notification for a device it cannot reach.
|
|
28
|
+
*
|
|
29
|
+
* This is the whole mechanism behind "notify me even though I closed the
|
|
30
|
+
* browser". A phone with the screen off, or a laptop whose browser is not
|
|
31
|
+
* running, is simply unreachable: the push service queues the message and
|
|
32
|
+
* replays it the moment that device reconnects. A TTL shorter than the gap
|
|
33
|
+
* throws the notification away instead — which is the one outcome this
|
|
34
|
+
* feature exists to prevent.
|
|
35
|
+
*
|
|
36
|
+
* Twelve hours covers a laptop closed overnight or a phone left face-down
|
|
37
|
+
* through a working day, and still expires before a completion notice turns
|
|
38
|
+
* into archaeology.
|
|
39
|
+
*
|
|
40
|
+
* Lives here rather than with the sender because the settings panel quotes the
|
|
41
|
+
* duration back to the user; two hand-maintained copies of "12 hours" is a
|
|
42
|
+
* promise the code can silently stop keeping.
|
|
43
|
+
*/
|
|
44
|
+
export const PUSH_TTL_SECONDS = 12 * 3600;
|
|
45
|
+
|
|
46
|
+
/** Human form of {@link PUSH_TTL_SECONDS}, for prose that quotes it. */
|
|
47
|
+
export function pushTtlLabel(): string {
|
|
48
|
+
const hours = Math.round(PUSH_TTL_SECONDS / 3600);
|
|
49
|
+
return hours === 1 ? '1 hour' : `${hours} hours`;
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
/**
|
|
53
|
+
* A session title is free text from the user's first message, so it is
|
|
54
|
+
* unbounded. Notification centres give the body a line or two before they
|
|
55
|
+
* truncate, and they truncate the *end* — which is where the project name
|
|
56
|
+
* would be if the title ran long.
|
|
57
|
+
*/
|
|
58
|
+
const MAX_SESSION_TITLE_CHARS = 40;
|
|
59
|
+
|
|
60
|
+
/**
|
|
61
|
+
* The title states what happened; the body states where.
|
|
62
|
+
*
|
|
63
|
+
* Titles used to name the engine ("Claude Response Complete") on a product
|
|
64
|
+
* that runs eight of them, and the cancelled case contradicted its own body by
|
|
65
|
+
* announcing a completion. They also never truncate: every OS clips the title
|
|
66
|
+
* around forty characters, and a title that leads with an unbounded project
|
|
67
|
+
* name loses the status first — the one thing the notification exists to say.
|
|
68
|
+
*/
|
|
69
|
+
const CHAT_TITLES: Record<ChatNotificationEvent, string> = {
|
|
70
|
+
completed: 'Response ready',
|
|
71
|
+
cancelled: 'Response stopped',
|
|
72
|
+
error: 'Response failed',
|
|
73
|
+
'waiting-input': 'Needs your input'
|
|
74
|
+
};
|
|
75
|
+
|
|
76
|
+
/**
|
|
77
|
+
* What the body says when neither the project nor the session could be
|
|
78
|
+
* resolved. Never empty: a notification with no body renders as a bare title
|
|
79
|
+
* strip on most platforms.
|
|
80
|
+
*/
|
|
81
|
+
const CHAT_FALLBACK_BODIES: Record<ChatNotificationEvent, string> = {
|
|
82
|
+
completed: 'Your chat response is ready.',
|
|
83
|
+
cancelled: 'The response stopped before it finished.',
|
|
84
|
+
error: 'The engine reported an error.',
|
|
85
|
+
'waiting-input': 'A question is waiting for your answer.'
|
|
86
|
+
};
|
|
87
|
+
|
|
88
|
+
function truncate(value: string, max: number): string {
|
|
89
|
+
return value.length <= max ? value : `${value.slice(0, max - 1).trimEnd()}…`;
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
/**
|
|
93
|
+
* Compose the body from whatever context resolved.
|
|
94
|
+
*
|
|
95
|
+
* An absent segment is dropped rather than filled in: the old `"Unknown"`
|
|
96
|
+
* placeholder was shown to the user as though it were a project name, and told
|
|
97
|
+
* them strictly less than leaving it out.
|
|
98
|
+
*/
|
|
99
|
+
function chatNotificationBody(
|
|
100
|
+
event: ChatNotificationEvent,
|
|
101
|
+
context: ChatNotificationContext
|
|
102
|
+
): string {
|
|
103
|
+
const project = context.projectName?.trim();
|
|
104
|
+
const session = context.sessionTitle?.trim();
|
|
105
|
+
const quotedSession = session ? `"${truncate(session, MAX_SESSION_TITLE_CHARS)}"` : '';
|
|
106
|
+
|
|
107
|
+
if (project && quotedSession) return `${project} — ${quotedSession}`;
|
|
108
|
+
if (project) return project;
|
|
109
|
+
if (quotedSession) return quotedSession;
|
|
110
|
+
return CHAT_FALLBACK_BODIES[event];
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
/** Title and body for one chat event. Identical on the server and in the tab. */
|
|
114
|
+
export function chatNotificationMessage(
|
|
115
|
+
event: ChatNotificationEvent,
|
|
116
|
+
context: ChatNotificationContext = {}
|
|
117
|
+
): { title: string; body: string } {
|
|
118
|
+
return {
|
|
119
|
+
title: CHAT_TITLES[event],
|
|
120
|
+
body: chatNotificationBody(event, context)
|
|
121
|
+
};
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
/**
|
|
125
|
+
* Test Push wording, split by the route that actually carried it.
|
|
126
|
+
*
|
|
127
|
+
* Both routes end at the same OS notification centre, so an identical body
|
|
128
|
+
* ("Push notifications are working correctly") left the user unable to tell
|
|
129
|
+
* whether the network leg was proven or whether the test had quietly fallen
|
|
130
|
+
* back to a toast the open tab raised itself — which proves nothing about
|
|
131
|
+
* delivery with the tab closed.
|
|
132
|
+
*/
|
|
133
|
+
export const TEST_PUSH_MESSAGES = {
|
|
134
|
+
background: {
|
|
135
|
+
title: 'Test notification',
|
|
136
|
+
body: 'Delivered through the background push service.'
|
|
137
|
+
},
|
|
138
|
+
local: {
|
|
139
|
+
title: 'Test notification',
|
|
140
|
+
body: 'Shown by this browser tab.'
|
|
141
|
+
}
|
|
142
|
+
} as const;
|
|
@@ -0,0 +1,112 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Git identities — shared vocabulary between the server and the UI.
|
|
3
|
+
*
|
|
4
|
+
* An identity answers two questions a git command asks: who authored this, and
|
|
5
|
+
* what proves I may push it. The first half (`name`, `email`) is attribution;
|
|
6
|
+
* the second (`authMethod` and whichever credential it names) is access. They
|
|
7
|
+
* live together because a user thinks of them as one account — "my work
|
|
8
|
+
* GitHub" — even though git keeps them in completely different places.
|
|
9
|
+
*
|
|
10
|
+
* NOTHING SECRET CROSSES THIS LINE. The private key, its passphrase, and the
|
|
11
|
+
* HTTPS token are sealed on the row and never serialised to a client; the DTO
|
|
12
|
+
* carries only whether each is set. The public key is the exception, and is
|
|
13
|
+
* public by definition — the UI needs it so the user can paste it into GitHub.
|
|
14
|
+
*/
|
|
15
|
+
|
|
16
|
+
/** How an identity proves itself to a remote. */
|
|
17
|
+
export type GitIdentityAuthMethod =
|
|
18
|
+
/** Attribution only — pushing falls back to whatever the machine provides. */
|
|
19
|
+
| 'none'
|
|
20
|
+
/** An SSH private key, stored here and written to disk for `ssh -i`. */
|
|
21
|
+
| 'ssh-key'
|
|
22
|
+
/** A token typed into Clopen, served over the git credential protocol. */
|
|
23
|
+
| 'https-token'
|
|
24
|
+
/** A token borrowed from an already-connected integration account. */
|
|
25
|
+
| 'https-account';
|
|
26
|
+
|
|
27
|
+
/**
|
|
28
|
+
* Where an identity came from.
|
|
29
|
+
*
|
|
30
|
+
* `local-machine` is the one mirrored from `git config --global`. It is editable
|
|
31
|
+
* but not deletable — the machine's config is what it reflects, so removing the
|
|
32
|
+
* row would only make it come back.
|
|
33
|
+
*/
|
|
34
|
+
export type GitIdentitySource = 'manual' | 'local-machine';
|
|
35
|
+
|
|
36
|
+
/** An identity as the client sees it — credentials reduced to presence flags. */
|
|
37
|
+
export interface GitIdentityDTO {
|
|
38
|
+
id: string;
|
|
39
|
+
/** What the user calls this account: "Work", "Personal". */
|
|
40
|
+
label: string;
|
|
41
|
+
/** `user.name`. */
|
|
42
|
+
name: string;
|
|
43
|
+
/** `user.email`. */
|
|
44
|
+
email: string;
|
|
45
|
+
authMethod: GitIdentityAuthMethod;
|
|
46
|
+
/**
|
|
47
|
+
* Hostnames this identity's credential is valid for, lowercased
|
|
48
|
+
* (`["github.com"]`). Empty means the identity makes no host claim: it can
|
|
49
|
+
* still author commits, but is never chosen to authenticate a remote.
|
|
50
|
+
*/
|
|
51
|
+
hosts: string[];
|
|
52
|
+
/** Public half of the SSH key, for copying into the host's settings. */
|
|
53
|
+
sshPublicKey: string | null;
|
|
54
|
+
/** True when a private key is stored. The key itself never leaves the server. */
|
|
55
|
+
hasSshKey: boolean;
|
|
56
|
+
/** True when that key needs a passphrase to use. */
|
|
57
|
+
hasSshPassphrase: boolean;
|
|
58
|
+
/** True when an HTTPS token is stored. */
|
|
59
|
+
hasHttpsToken: boolean;
|
|
60
|
+
/** Username sent alongside the HTTPS token. */
|
|
61
|
+
httpsUsername: string | null;
|
|
62
|
+
/** The borrowed integration account, when `authMethod` is `https-account`. */
|
|
63
|
+
integrationAccountId: string | null;
|
|
64
|
+
/** Used when a project names no identity of its own. */
|
|
65
|
+
isDefault: boolean;
|
|
66
|
+
source: GitIdentitySource;
|
|
67
|
+
/** False for the mirrored machine identity — see {@link GitIdentitySource}. */
|
|
68
|
+
canDelete: boolean;
|
|
69
|
+
createdAt: string;
|
|
70
|
+
updatedAt: string;
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
/** Fields a create/update accepts. Secrets are write-only and omitted to keep. */
|
|
74
|
+
export interface GitIdentityInput {
|
|
75
|
+
label: string;
|
|
76
|
+
name: string;
|
|
77
|
+
email: string;
|
|
78
|
+
authMethod: GitIdentityAuthMethod;
|
|
79
|
+
hosts: string[];
|
|
80
|
+
/** PEM private key. `null` clears it; omitted leaves the stored one alone. */
|
|
81
|
+
sshPrivateKey?: string | null;
|
|
82
|
+
sshPublicKey?: string | null;
|
|
83
|
+
sshPassphrase?: string | null;
|
|
84
|
+
httpsUsername?: string | null;
|
|
85
|
+
httpsToken?: string | null;
|
|
86
|
+
integrationAccountId?: string | null;
|
|
87
|
+
isDefault?: boolean;
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
/**
|
|
91
|
+
* Which identity a git command actually ran as, and why.
|
|
92
|
+
*
|
|
93
|
+
* `source` is what the UI shows so a user can tell an inherited identity from a
|
|
94
|
+
* chosen one before they commit, rather than after they push.
|
|
95
|
+
*/
|
|
96
|
+
export interface ResolvedGitIdentity {
|
|
97
|
+
identity: GitIdentityDTO | null;
|
|
98
|
+
source: 'project' | 'user-default' | 'none';
|
|
99
|
+
/**
|
|
100
|
+
* The identity supplying credentials for a given remote host, when the
|
|
101
|
+
* project's own identity does not claim that host. Null when the project
|
|
102
|
+
* identity covers it, or when nothing does.
|
|
103
|
+
*/
|
|
104
|
+
credentialIdentity: GitIdentityDTO | null;
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
/** An SSH keypair generated on the server. The private half is stored, not returned. */
|
|
108
|
+
export interface GeneratedSshKey {
|
|
109
|
+
publicKey: string;
|
|
110
|
+
/** Fingerprint for display, so the user can match it against the host. */
|
|
111
|
+
fingerprint: string;
|
|
112
|
+
}
|
|
@@ -182,6 +182,13 @@ export interface StreamRequest {
|
|
|
182
182
|
prompt: UserMessage;
|
|
183
183
|
engine: MessageEngine;
|
|
184
184
|
sender: MessageSender;
|
|
185
|
+
/**
|
|
186
|
+
* Server-trusted id of the user who started the stream (from the WS
|
|
187
|
+
* connection, never the client-supplied `sender`). Used to route Web Push
|
|
188
|
+
* notifications to the requester's devices when Chrome is closed.
|
|
189
|
+
* Absent for streams started before this field existed.
|
|
190
|
+
*/
|
|
191
|
+
requestedByUserId?: string;
|
|
185
192
|
/**
|
|
186
193
|
* Reasoning/thinking level token chosen for this session (native per engine).
|
|
187
194
|
* `null`/absent → the engine's own default applies. Persisted to
|
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Detect on-disk commands (managed effective copies + adoptable real ones) for
|
|
3
|
-
* the Settings UI. Global scope only for now — project scope is surfaced by the
|
|
4
|
-
* per-project detection path when a project is supplied.
|
|
5
|
-
*/
|
|
6
|
-
|
|
7
|
-
import { detectArtifacts, type DetectedArtifact, type ArtifactEngine } from '$backend/artifacts';
|
|
8
|
-
|
|
9
|
-
export interface DetectedCommandGroup {
|
|
10
|
-
engine: ArtifactEngine;
|
|
11
|
-
detected: DetectedArtifact[];
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
/** Detect commands across all engines for the given scope. */
|
|
15
|
-
export async function detectCommands(projectPath?: string): Promise<DetectedCommandGroup[]> {
|
|
16
|
-
const engines: ArtifactEngine[] = ['claude', 'codex', 'copilot', 'qwen', 'opencode', 'pi'];
|
|
17
|
-
const scope = projectPath ? 'project' : 'global';
|
|
18
|
-
const groups = await Promise.all(
|
|
19
|
-
engines.map(async engine => ({
|
|
20
|
-
engine,
|
|
21
|
-
detected: await detectArtifacts('command', { engine, scope, projectPath })
|
|
22
|
-
}))
|
|
23
|
-
);
|
|
24
|
-
return groups.filter(g => g.detected.length > 0);
|
|
25
|
-
}
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Custom Commands — public facade. Settings → Commands manages reusable slash
|
|
3
|
-
* command prompts, materialized into each engine at stream start.
|
|
4
|
-
*/
|
|
5
|
-
|
|
6
|
-
export { commandService } from './service';
|
|
7
|
-
export type { CommandDTO, CommandInputFields } from './service';
|
|
8
|
-
export { syncCommands, syncCommandsAllEngines, buildCommandsPromptContext } from './sync';
|
|
9
|
-
export { detectCommands } from './detect';
|