@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
|
@@ -0,0 +1,200 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Git identity handlers — CRUD for Settings, binding for a project, and the
|
|
3
|
+
* "who will this be committed as" read the Git panel shows.
|
|
4
|
+
*
|
|
5
|
+
* Every response is a DTO from `backend/git/identity/service`, so no private
|
|
6
|
+
* key, passphrase or token can reach a client from here. The public key is the
|
|
7
|
+
* one piece of key material that crosses, and it is public by definition.
|
|
8
|
+
*
|
|
9
|
+
* Identities are owned per user, and every handler resolves the owner from the
|
|
10
|
+
* connection rather than from the payload. A client cannot name whose
|
|
11
|
+
* identities it wants to read or change.
|
|
12
|
+
*/
|
|
13
|
+
|
|
14
|
+
import { t } from 'elysia';
|
|
15
|
+
import { createRouter } from '$shared/utils/ws-server';
|
|
16
|
+
import { gitIdentityService, describeIdentity } from '$backend/git/identity';
|
|
17
|
+
import { requireProjectWorkspace } from '../access';
|
|
18
|
+
import { ws } from '$backend/utils/ws';
|
|
19
|
+
import { gitService } from '$backend/git/git-service';
|
|
20
|
+
import { debug } from '$shared/utils/logger';
|
|
21
|
+
import type { GitIdentityAuthMethod } from '$shared/types/git-identity';
|
|
22
|
+
|
|
23
|
+
const AUTH_METHOD = t.Union([
|
|
24
|
+
t.Literal('none'),
|
|
25
|
+
t.Literal('ssh-key'),
|
|
26
|
+
t.Literal('https-token'),
|
|
27
|
+
t.Literal('https-account')
|
|
28
|
+
]);
|
|
29
|
+
|
|
30
|
+
/** The DTO shape, mirrored for the wire schema. */
|
|
31
|
+
const IDENTITY = t.Object({
|
|
32
|
+
id: t.String(),
|
|
33
|
+
label: t.String(),
|
|
34
|
+
name: t.String(),
|
|
35
|
+
email: t.String(),
|
|
36
|
+
authMethod: AUTH_METHOD,
|
|
37
|
+
hosts: t.Array(t.String()),
|
|
38
|
+
sshPublicKey: t.Union([t.String(), t.Null()]),
|
|
39
|
+
hasSshKey: t.Boolean(),
|
|
40
|
+
hasSshPassphrase: t.Boolean(),
|
|
41
|
+
hasHttpsToken: t.Boolean(),
|
|
42
|
+
httpsUsername: t.Union([t.String(), t.Null()]),
|
|
43
|
+
integrationAccountId: t.Union([t.String(), t.Null()]),
|
|
44
|
+
isDefault: t.Boolean(),
|
|
45
|
+
source: t.Union([t.Literal('manual'), t.Literal('local-machine')]),
|
|
46
|
+
canDelete: t.Boolean(),
|
|
47
|
+
createdAt: t.String(),
|
|
48
|
+
updatedAt: t.String()
|
|
49
|
+
});
|
|
50
|
+
|
|
51
|
+
/**
|
|
52
|
+
* Write fields.
|
|
53
|
+
*
|
|
54
|
+
* Secrets are `Optional` AND nullable on purpose, and the distinction is
|
|
55
|
+
* load-bearing: absent means "keep what is stored", explicit `null` means
|
|
56
|
+
* "clear it". Anything else would force the browser to hold a private key just
|
|
57
|
+
* to rename an identity.
|
|
58
|
+
*/
|
|
59
|
+
const INPUT = t.Object({
|
|
60
|
+
label: t.String({ minLength: 1 }),
|
|
61
|
+
name: t.String({ minLength: 1 }),
|
|
62
|
+
email: t.String({ minLength: 1 }),
|
|
63
|
+
authMethod: AUTH_METHOD,
|
|
64
|
+
hosts: t.Array(t.String()),
|
|
65
|
+
sshPrivateKey: t.Optional(t.Union([t.String(), t.Null()])),
|
|
66
|
+
sshPublicKey: t.Optional(t.Union([t.String(), t.Null()])),
|
|
67
|
+
sshPassphrase: t.Optional(t.Union([t.String(), t.Null()])),
|
|
68
|
+
httpsUsername: t.Optional(t.Union([t.String(), t.Null()])),
|
|
69
|
+
httpsToken: t.Optional(t.Union([t.String(), t.Null()])),
|
|
70
|
+
integrationAccountId: t.Optional(t.Union([t.String(), t.Null()])),
|
|
71
|
+
isDefault: t.Optional(t.Boolean())
|
|
72
|
+
});
|
|
73
|
+
|
|
74
|
+
/** The owner of this connection. Throws when unauthenticated. */
|
|
75
|
+
function requireUserId(conn: Parameters<typeof ws.getUserId>[0]): string {
|
|
76
|
+
const userId = ws.getUserId(conn);
|
|
77
|
+
if (!userId) throw new Error('Authentication required');
|
|
78
|
+
return userId;
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
export const gitIdentityHandler = createRouter()
|
|
82
|
+
.http('git:identities', {
|
|
83
|
+
data: t.Object({}),
|
|
84
|
+
response: t.Object({ identities: t.Array(IDENTITY) })
|
|
85
|
+
}, async ({ conn }) => {
|
|
86
|
+
return { identities: await gitIdentityService.list(requireUserId(conn)) };
|
|
87
|
+
})
|
|
88
|
+
|
|
89
|
+
.http('git:identity-create', {
|
|
90
|
+
data: INPUT,
|
|
91
|
+
response: t.Object({ identity: IDENTITY })
|
|
92
|
+
}, async ({ data, conn }) => {
|
|
93
|
+
const identity = await gitIdentityService.create(requireUserId(conn), {
|
|
94
|
+
...data,
|
|
95
|
+
authMethod: data.authMethod as GitIdentityAuthMethod
|
|
96
|
+
});
|
|
97
|
+
return { identity };
|
|
98
|
+
})
|
|
99
|
+
|
|
100
|
+
.http('git:identity-update', {
|
|
101
|
+
data: t.Intersect([INPUT, t.Object({ id: t.String() })]),
|
|
102
|
+
response: t.Object({ identity: IDENTITY })
|
|
103
|
+
}, async ({ data, conn }) => {
|
|
104
|
+
const { id, ...input } = data;
|
|
105
|
+
const identity = await gitIdentityService.update(requireUserId(conn), id, {
|
|
106
|
+
...input,
|
|
107
|
+
authMethod: input.authMethod as GitIdentityAuthMethod
|
|
108
|
+
});
|
|
109
|
+
return { identity };
|
|
110
|
+
})
|
|
111
|
+
|
|
112
|
+
.http('git:identity-delete', {
|
|
113
|
+
data: t.Object({ id: t.String() }),
|
|
114
|
+
response: t.Object({ ok: t.Boolean() })
|
|
115
|
+
}, async ({ data, conn }) => {
|
|
116
|
+
await gitIdentityService.remove(requireUserId(conn), data.id);
|
|
117
|
+
return { ok: true };
|
|
118
|
+
})
|
|
119
|
+
|
|
120
|
+
.http('git:identity-set-default', {
|
|
121
|
+
data: t.Object({ id: t.String() }),
|
|
122
|
+
response: t.Object({ identity: IDENTITY })
|
|
123
|
+
}, async ({ data, conn }) => {
|
|
124
|
+
return { identity: await gitIdentityService.setDefault(requireUserId(conn), data.id) };
|
|
125
|
+
})
|
|
126
|
+
|
|
127
|
+
/**
|
|
128
|
+
* Generate a keypair for an identity.
|
|
129
|
+
*
|
|
130
|
+
* Returns the public half and its fingerprint. The private key never leaves
|
|
131
|
+
* the server — it goes straight into the sealed column and the 0600 file.
|
|
132
|
+
*/
|
|
133
|
+
.http('git:identity-generate-key', {
|
|
134
|
+
data: t.Object({ id: t.String() }),
|
|
135
|
+
response: t.Object({ publicKey: t.String(), fingerprint: t.String() })
|
|
136
|
+
}, async ({ data, conn }) => {
|
|
137
|
+
return await gitIdentityService.generateKey(requireUserId(conn), data.id);
|
|
138
|
+
})
|
|
139
|
+
|
|
140
|
+
/** How many projects would lose their binding if this identity went away. */
|
|
141
|
+
.http('git:identity-usage', {
|
|
142
|
+
data: t.Object({ id: t.String() }),
|
|
143
|
+
response: t.Object({ projectCount: t.Number() })
|
|
144
|
+
}, async ({ data, conn }) => {
|
|
145
|
+
requireUserId(conn);
|
|
146
|
+
return { projectCount: gitIdentityService.bindingCount(data.id) };
|
|
147
|
+
})
|
|
148
|
+
|
|
149
|
+
/** Bind this project to an identity, or clear the binding with `null`. */
|
|
150
|
+
.http('git:identity-bind', {
|
|
151
|
+
data: t.Object({
|
|
152
|
+
projectId: t.String(),
|
|
153
|
+
identityId: t.Union([t.String(), t.Null()])
|
|
154
|
+
}),
|
|
155
|
+
response: t.Object({ ok: t.Boolean() })
|
|
156
|
+
}, async ({ data, conn }) => {
|
|
157
|
+
// Access is the project's call, exactly as for every other git operation.
|
|
158
|
+
requireProjectWorkspace(conn, data.projectId);
|
|
159
|
+
await gitIdentityService.bind(requireUserId(conn), data.projectId, data.identityId);
|
|
160
|
+
return { ok: true };
|
|
161
|
+
})
|
|
162
|
+
|
|
163
|
+
/**
|
|
164
|
+
* Who the next commit in this project will be attributed to.
|
|
165
|
+
*
|
|
166
|
+
* Drives the line above the commit box. `source` distinguishes an identity
|
|
167
|
+
* chosen for this project from one inherited as the user's default, which is
|
|
168
|
+
* the difference between "this is right" and "check this before you push".
|
|
169
|
+
*/
|
|
170
|
+
.http('git:identity-resolved', {
|
|
171
|
+
data: t.Object({
|
|
172
|
+
projectId: t.String(),
|
|
173
|
+
/** Remote to resolve the credential against. Defaults to origin. */
|
|
174
|
+
remote: t.Optional(t.String())
|
|
175
|
+
}),
|
|
176
|
+
response: t.Object({
|
|
177
|
+
identity: t.Union([IDENTITY, t.Null()]),
|
|
178
|
+
source: t.Union([t.Literal('project'), t.Literal('user-default'), t.Literal('none')]),
|
|
179
|
+
credentialIdentity: t.Union([IDENTITY, t.Null()])
|
|
180
|
+
})
|
|
181
|
+
}, async ({ data, conn }) => {
|
|
182
|
+
const { root } = requireProjectWorkspace(conn, data.projectId);
|
|
183
|
+
const userId = requireUserId(conn);
|
|
184
|
+
|
|
185
|
+
// The remote URL decides which identity's credential answers, so it is
|
|
186
|
+
// resolved here too — a fork whose origin and upstream sit on different
|
|
187
|
+
// accounts is exactly what the panel needs to be able to show.
|
|
188
|
+
let remoteUrl: string | null = null;
|
|
189
|
+
try {
|
|
190
|
+
const remotes = await gitService.getRemotes(root);
|
|
191
|
+
const wanted = data.remote ?? 'origin';
|
|
192
|
+
const match = remotes.find((r) => r.name === wanted) ?? (remotes.length === 1 ? remotes[0] : undefined);
|
|
193
|
+
remoteUrl = match ? match.pushUrl || match.fetchUrl : null;
|
|
194
|
+
} catch (error) {
|
|
195
|
+
// A project that is not a repo yet still has an identity to report.
|
|
196
|
+
debug.log('git', 'No remotes to resolve an identity credential against:', error);
|
|
197
|
+
}
|
|
198
|
+
|
|
199
|
+
return describeIdentity(data.projectId, userId, remoteUrl);
|
|
200
|
+
});
|
package/backend/ws/git/index.ts
CHANGED
|
@@ -15,6 +15,7 @@ import { conflictHandler } from './conflict';
|
|
|
15
15
|
import { commitMessageHandler } from './commit-message';
|
|
16
16
|
import { branchNameHandler } from './branch-name';
|
|
17
17
|
import { ignoredHandler } from './ignored';
|
|
18
|
+
import { gitIdentityHandler } from './identity';
|
|
18
19
|
|
|
19
20
|
export const gitRouter = createRouter()
|
|
20
21
|
.merge(statusHandler)
|
|
@@ -27,4 +28,5 @@ export const gitRouter = createRouter()
|
|
|
27
28
|
.merge(conflictHandler)
|
|
28
29
|
.merge(commitMessageHandler)
|
|
29
30
|
.merge(branchNameHandler)
|
|
30
|
-
.merge(ignoredHandler)
|
|
31
|
+
.merge(ignoredHandler)
|
|
32
|
+
.merge(gitIdentityHandler);
|
package/backend/ws/git/remote.ts
CHANGED
|
@@ -7,6 +7,7 @@ import path from 'node:path';
|
|
|
7
7
|
import { createRouter } from '$shared/utils/ws-server';
|
|
8
8
|
import { gitService } from '../../git/git-service';
|
|
9
9
|
import { requireProjectWorkspace } from '../access';
|
|
10
|
+
import { identityEnvFor, identityEnvForRemote } from './identity-context';
|
|
10
11
|
import { debug } from '$shared/utils/logger';
|
|
11
12
|
|
|
12
13
|
/**
|
|
@@ -54,7 +55,11 @@ export const remoteHandler = createRouter()
|
|
|
54
55
|
}, async ({ data, conn }) => {
|
|
55
56
|
const { root } = requireProjectWorkspace(conn, data.projectId);
|
|
56
57
|
const cwd = resolveRepoCwd(root, data.repoPath);
|
|
57
|
-
const message = await gitService.fetch(
|
|
58
|
+
const message = await gitService.fetch(
|
|
59
|
+
cwd,
|
|
60
|
+
data.remote,
|
|
61
|
+
await identityEnvForRemote(conn, data.projectId, cwd, data.remote)
|
|
62
|
+
);
|
|
58
63
|
return { message };
|
|
59
64
|
})
|
|
60
65
|
|
|
@@ -73,7 +78,13 @@ export const remoteHandler = createRouter()
|
|
|
73
78
|
}, async ({ data, conn }) => {
|
|
74
79
|
const { root } = requireProjectWorkspace(conn, data.projectId);
|
|
75
80
|
const cwd = resolveRepoCwd(root, data.repoPath);
|
|
76
|
-
return await gitService.pull(
|
|
81
|
+
return await gitService.pull(
|
|
82
|
+
cwd,
|
|
83
|
+
data.remote,
|
|
84
|
+
data.branch,
|
|
85
|
+
data.rebase,
|
|
86
|
+
await identityEnvForRemote(conn, data.projectId, cwd, data.remote)
|
|
87
|
+
);
|
|
77
88
|
})
|
|
78
89
|
|
|
79
90
|
.http('git:push-advanced', {
|
|
@@ -96,7 +107,13 @@ export const remoteHandler = createRouter()
|
|
|
96
107
|
}, async ({ data, conn }) => {
|
|
97
108
|
const { root } = requireProjectWorkspace(conn, data.projectId);
|
|
98
109
|
const cwd = resolveRepoCwd(root, data.repoPath);
|
|
99
|
-
return await gitService.pushAdvanced(
|
|
110
|
+
return await gitService.pushAdvanced(
|
|
111
|
+
cwd,
|
|
112
|
+
data.mode,
|
|
113
|
+
data.remote,
|
|
114
|
+
data.branch,
|
|
115
|
+
await identityEnvForRemote(conn, data.projectId, cwd, data.remote)
|
|
116
|
+
);
|
|
100
117
|
})
|
|
101
118
|
|
|
102
119
|
.http('git:fetch-all', {
|
|
@@ -110,7 +127,10 @@ export const remoteHandler = createRouter()
|
|
|
110
127
|
}, async ({ data, conn }) => {
|
|
111
128
|
const { root } = requireProjectWorkspace(conn, data.projectId);
|
|
112
129
|
const cwd = resolveRepoCwd(root, data.repoPath);
|
|
113
|
-
const message = await gitService.fetchAll(
|
|
130
|
+
const message = await gitService.fetchAll(
|
|
131
|
+
cwd,
|
|
132
|
+
await identityEnvForRemote(conn, data.projectId, cwd)
|
|
133
|
+
);
|
|
114
134
|
return { message };
|
|
115
135
|
})
|
|
116
136
|
|
|
@@ -134,9 +154,14 @@ export const remoteHandler = createRouter()
|
|
|
134
154
|
}, async ({ data, conn }) => {
|
|
135
155
|
const { root } = requireProjectWorkspace(conn, data.projectId);
|
|
136
156
|
const cwd = resolveRepoCwd(root, data.repoPath);
|
|
137
|
-
return await gitService.push(
|
|
138
|
-
|
|
139
|
-
|
|
157
|
+
return await gitService.push(
|
|
158
|
+
cwd,
|
|
159
|
+
data.remote,
|
|
160
|
+
data.branch,
|
|
161
|
+
data.force,
|
|
162
|
+
{ useUpstream: data.useUpstream ?? true },
|
|
163
|
+
await identityEnvForRemote(conn, data.projectId, cwd, data.remote)
|
|
164
|
+
);
|
|
140
165
|
})
|
|
141
166
|
|
|
142
167
|
/** Where a push would actually land — drives the Push button's label. */
|
|
@@ -278,7 +303,12 @@ export const remoteHandler = createRouter()
|
|
|
278
303
|
}, async ({ data, conn }) => {
|
|
279
304
|
const { root } = requireProjectWorkspace(conn, data.projectId);
|
|
280
305
|
const cwd = resolveRepoCwd(root, data.repoPath);
|
|
281
|
-
await gitService.deleteRemoteBranch(
|
|
306
|
+
await gitService.deleteRemoteBranch(
|
|
307
|
+
cwd,
|
|
308
|
+
data.remote,
|
|
309
|
+
data.branch,
|
|
310
|
+
await identityEnvForRemote(conn, data.projectId, cwd, data.remote)
|
|
311
|
+
);
|
|
282
312
|
return { ok: true };
|
|
283
313
|
})
|
|
284
314
|
|
|
@@ -309,7 +339,12 @@ export const remoteHandler = createRouter()
|
|
|
309
339
|
}, async ({ data, conn }) => {
|
|
310
340
|
const { root } = requireProjectWorkspace(conn, data.projectId);
|
|
311
341
|
const cwd = resolveRepoCwd(root, data.repoPath);
|
|
312
|
-
await gitService.stashSave(
|
|
342
|
+
await gitService.stashSave(
|
|
343
|
+
cwd,
|
|
344
|
+
data.message,
|
|
345
|
+
data.staged,
|
|
346
|
+
identityEnvFor(conn, data.projectId)
|
|
347
|
+
);
|
|
313
348
|
return { ok: true };
|
|
314
349
|
})
|
|
315
350
|
|
|
@@ -422,7 +457,13 @@ export const remoteHandler = createRouter()
|
|
|
422
457
|
}, async ({ data, conn }) => {
|
|
423
458
|
const { root } = requireProjectWorkspace(conn, data.projectId);
|
|
424
459
|
const cwd = resolveRepoCwd(root, data.repoPath);
|
|
425
|
-
await gitService.createTag(
|
|
460
|
+
await gitService.createTag(
|
|
461
|
+
cwd,
|
|
462
|
+
data.name,
|
|
463
|
+
data.message,
|
|
464
|
+
data.commitHash,
|
|
465
|
+
identityEnvFor(conn, data.projectId)
|
|
466
|
+
);
|
|
426
467
|
return { ok: true };
|
|
427
468
|
})
|
|
428
469
|
|
|
@@ -454,5 +495,10 @@ export const remoteHandler = createRouter()
|
|
|
454
495
|
}, async ({ data, conn }) => {
|
|
455
496
|
const { root } = requireProjectWorkspace(conn, data.projectId);
|
|
456
497
|
const cwd = resolveRepoCwd(root, data.repoPath);
|
|
457
|
-
return await gitService.pushTag(
|
|
498
|
+
return await gitService.pushTag(
|
|
499
|
+
cwd,
|
|
500
|
+
data.name,
|
|
501
|
+
data.remote,
|
|
502
|
+
await identityEnvForRemote(conn, data.projectId, cwd, data.remote)
|
|
503
|
+
);
|
|
458
504
|
});
|
package/backend/ws/index.ts
CHANGED
|
@@ -37,7 +37,6 @@ import { containersRouter } from './containers';
|
|
|
37
37
|
import { mcpRouter } from './mcp';
|
|
38
38
|
import { integrationsRouter } from './integrations';
|
|
39
39
|
import { skillsRouter } from './skills';
|
|
40
|
-
import { commandsRouter } from './commands';
|
|
41
40
|
import { subagentsRouter } from './subagents';
|
|
42
41
|
import { instructionsRouter } from './instructions';
|
|
43
42
|
import { permissionsRouter } from './permissions';
|
|
@@ -104,11 +103,11 @@ export const wsRouter = createRouter()
|
|
|
104
103
|
.merge(mcpRouter)
|
|
105
104
|
.merge(integrationsRouter)
|
|
106
105
|
|
|
107
|
-
// Agent Skills management
|
|
106
|
+
// Agent Skills management — model-invoked skills AND user-invoked `/slash`
|
|
107
|
+
// prompts are one feature (create, import, install from a marketplace)
|
|
108
108
|
.merge(skillsRouter)
|
|
109
109
|
|
|
110
|
-
//
|
|
111
|
-
.merge(commandsRouter)
|
|
110
|
+
// Subagents and Project Instructions (artifact framework)
|
|
112
111
|
.merge(subagentsRouter)
|
|
113
112
|
.merge(instructionsRouter)
|
|
114
113
|
.merge(permissionsRouter)
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Browsing Data WebSocket Handler
|
|
3
|
+
*
|
|
4
|
+
* The preview keeps a Chrome profile per workspace, so a login made in a
|
|
5
|
+
* preview tab outlives the tab, the panel and the server. That is the point —
|
|
6
|
+
* and it is also why there has to be a way to take it back. These are the
|
|
7
|
+
* preview's equivalent of a browser's "clear browsing data": one site, or all
|
|
8
|
+
* of them.
|
|
9
|
+
*
|
|
10
|
+
* **PROJECT ISOLATION**: the profile is the project's, and so is the clear.
|
|
11
|
+
*/
|
|
12
|
+
|
|
13
|
+
import { t } from 'elysia';
|
|
14
|
+
import { createRouter } from '$shared/utils/ws-server';
|
|
15
|
+
import { requireBrowserPreviewAccess } from '../access';
|
|
16
|
+
|
|
17
|
+
export const browsingDataPreviewHandler = createRouter()
|
|
18
|
+
// Sites this workspace's preview browser holds data for
|
|
19
|
+
.http(
|
|
20
|
+
'preview:browser-data-list',
|
|
21
|
+
{
|
|
22
|
+
data: t.Object({}),
|
|
23
|
+
response: t.Object({
|
|
24
|
+
sites: t.Array(
|
|
25
|
+
t.Object({
|
|
26
|
+
domain: t.String(),
|
|
27
|
+
origin: t.String(),
|
|
28
|
+
cookies: t.Number(),
|
|
29
|
+
open: t.Boolean()
|
|
30
|
+
})
|
|
31
|
+
)
|
|
32
|
+
})
|
|
33
|
+
},
|
|
34
|
+
async ({ conn }) => {
|
|
35
|
+
const { previewService } = requireBrowserPreviewAccess(conn);
|
|
36
|
+
return { sites: await previewService.listBrowsingData() };
|
|
37
|
+
}
|
|
38
|
+
)
|
|
39
|
+
|
|
40
|
+
// Forget one site, or everything
|
|
41
|
+
.http(
|
|
42
|
+
'preview:browser-data-clear',
|
|
43
|
+
{
|
|
44
|
+
data: t.Object({
|
|
45
|
+
/**
|
|
46
|
+
* Origin to clear. Omitted means every site — including ones
|
|
47
|
+
* whose tab has long been closed, which is the case the
|
|
48
|
+
* per-origin call cannot reach.
|
|
49
|
+
*/
|
|
50
|
+
origin: t.Optional(t.String())
|
|
51
|
+
}),
|
|
52
|
+
response: t.Object({
|
|
53
|
+
success: t.Boolean()
|
|
54
|
+
})
|
|
55
|
+
},
|
|
56
|
+
async ({ data, conn }) => {
|
|
57
|
+
const { previewService } = requireBrowserPreviewAccess(conn);
|
|
58
|
+
return { success: await previewService.clearBrowsingData(data.origin) };
|
|
59
|
+
}
|
|
60
|
+
);
|
|
@@ -116,6 +116,12 @@ export const interactPreviewHandler = createRouter()
|
|
|
116
116
|
// Mark tab activity to prevent automatic cleanup
|
|
117
117
|
previewService.markActiveTabActivity();
|
|
118
118
|
|
|
119
|
+
// A tab nobody was watching is frozen: its task queues are suspended,
|
|
120
|
+
// so an input event dispatched now would sit unprocessed until the
|
|
121
|
+
// page happened to be woken by something else. Awaited rather than
|
|
122
|
+
// nudged — the click has to land on a running page, not the next one.
|
|
123
|
+
await previewService.ensureTabAwake(tabId);
|
|
124
|
+
|
|
119
125
|
// Execute the interaction based on type with navigation-safe error handling
|
|
120
126
|
try {
|
|
121
127
|
switch (action.type) {
|
|
@@ -27,7 +27,8 @@ export const tabInfoPreviewHandler = createRouter()
|
|
|
27
27
|
rotation: t.String(),
|
|
28
28
|
isActive: t.Boolean(),
|
|
29
29
|
canGoBack: t.Boolean(),
|
|
30
|
-
canGoForward: t.Boolean()
|
|
30
|
+
canGoForward: t.Boolean(),
|
|
31
|
+
isSleeping: t.Optional(t.Boolean())
|
|
31
32
|
})
|
|
32
33
|
}, async ({ data, conn }) => {
|
|
33
34
|
const { tabId } = data;
|
|
@@ -63,6 +64,12 @@ export const tabInfoPreviewHandler = createRouter()
|
|
|
63
64
|
isActive: t.Boolean(),
|
|
64
65
|
canGoBack: t.Boolean(),
|
|
65
66
|
canGoForward: t.Boolean(),
|
|
67
|
+
/**
|
|
68
|
+
* Whether the page is frozen for want of an audience. Recovered
|
|
69
|
+
* with everything else so a reload does not paint a suspended
|
|
70
|
+
* page as a running one.
|
|
71
|
+
*/
|
|
72
|
+
isSleeping: t.Optional(t.Boolean()),
|
|
66
73
|
isMcpControlled: t.Boolean(),
|
|
67
74
|
/** Whether an agent is acting on this tab right now. */
|
|
68
75
|
isMcpFocused: t.Boolean(),
|
|
@@ -119,6 +126,7 @@ export const tabInfoPreviewHandler = createRouter()
|
|
|
119
126
|
isActive: tab.isActive,
|
|
120
127
|
canGoBack: tab.canGoBack,
|
|
121
128
|
canGoForward: tab.canGoForward,
|
|
129
|
+
isSleeping: tab.isSleeping,
|
|
122
130
|
isMcpControlled: browserMcpControl.isTabControlled(tab.id, projectId),
|
|
123
131
|
isMcpFocused: browserMcpControl.isTabFocused(tab.id),
|
|
124
132
|
mcpActivity: browserMcpControl.getActivity(tab.id) ?? undefined,
|
|
@@ -8,6 +8,7 @@ import { t } from 'elysia';
|
|
|
8
8
|
import { createRouter } from '$shared/utils/ws-server';
|
|
9
9
|
import { debug } from '$shared/utils/logger';
|
|
10
10
|
import { requireBrowserPreviewAccess, requireBrowserTabAccess } from '../access';
|
|
11
|
+
import { LaunchCancelledError } from '../../../preview/browser/browser-tab-manager';
|
|
11
12
|
|
|
12
13
|
// Timeout for browser tab open (60 seconds)
|
|
13
14
|
const OPEN_TIMEOUT = 60000;
|
|
@@ -27,13 +28,27 @@ export const tabPreviewHandler = createRouter()
|
|
|
27
28
|
t.Literal('portrait'),
|
|
28
29
|
t.Literal('landscape')
|
|
29
30
|
])),
|
|
31
|
+
/**
|
|
32
|
+
* Client-minted name for this launch.
|
|
33
|
+
*
|
|
34
|
+
* The tab does not exist until the navigation finishes, so this is
|
|
35
|
+
* the only handle Stop has on a load in progress — and the only way
|
|
36
|
+
* the client can recognise the tab that comes back as the one it
|
|
37
|
+
* asked for.
|
|
38
|
+
*/
|
|
39
|
+
launchId: t.Optional(t.String())
|
|
30
40
|
}),
|
|
31
41
|
response: t.Object({
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
42
|
+
/**
|
|
43
|
+
* Whether the launch was stopped before its page loaded. There is no
|
|
44
|
+
* tab in that case — the page never committed, so nothing was kept.
|
|
45
|
+
*/
|
|
46
|
+
cancelled: t.Boolean(),
|
|
47
|
+
tabId: t.Optional(t.String()),
|
|
48
|
+
quality: t.Optional(t.String()),
|
|
49
|
+
url: t.Optional(t.String()),
|
|
50
|
+
title: t.Optional(t.String()),
|
|
51
|
+
isActive: t.Optional(t.Boolean()),
|
|
37
52
|
message: t.String()
|
|
38
53
|
})
|
|
39
54
|
}, async ({ data, conn }) => {
|
|
@@ -44,7 +59,8 @@ export const tabPreviewHandler = createRouter()
|
|
|
44
59
|
const {
|
|
45
60
|
url,
|
|
46
61
|
deviceSize = 'laptop',
|
|
47
|
-
rotation = 'portrait'
|
|
62
|
+
rotation = 'portrait',
|
|
63
|
+
launchId
|
|
48
64
|
} = data;
|
|
49
65
|
|
|
50
66
|
debug.log('preview', `📥 Tab open params - URL: ${url || 'about:blank'}, deviceSize: ${deviceSize}, rotation: ${rotation}`);
|
|
@@ -53,20 +69,35 @@ export const tabPreviewHandler = createRouter()
|
|
|
53
69
|
const tabPromise = previewService.createTab(
|
|
54
70
|
url, // Can be undefined for blank tab
|
|
55
71
|
deviceSize as 'desktop' | 'laptop' | 'tablet' | 'mobile',
|
|
56
|
-
rotation as 'portrait' | 'landscape'
|
|
72
|
+
rotation as 'portrait' | 'landscape',
|
|
73
|
+
launchId
|
|
57
74
|
);
|
|
58
75
|
const timeoutPromise = new Promise((_, reject) => {
|
|
59
76
|
setTimeout(() => reject(new Error('Browser tab open timeout - took longer than 60 seconds')), OPEN_TIMEOUT);
|
|
60
77
|
});
|
|
61
78
|
|
|
62
79
|
debug.log('preview', `⏳ Opening browser tab (timeout: ${OPEN_TIMEOUT}ms)...`);
|
|
63
|
-
|
|
80
|
+
|
|
81
|
+
let tab: Awaited<typeof tabPromise>;
|
|
82
|
+
try {
|
|
83
|
+
tab = await Promise.race([tabPromise, timeoutPromise]) as Awaited<typeof tabPromise>;
|
|
84
|
+
} catch (error) {
|
|
85
|
+
// The user pressed Stop and nothing had loaded. Reported as an
|
|
86
|
+
// outcome rather than thrown: it is what they asked for, and the
|
|
87
|
+
// client has a slot waiting that should simply go back to idle.
|
|
88
|
+
if (error instanceof LaunchCancelledError) {
|
|
89
|
+
debug.log('preview', `🛑 Tab open cancelled for project: ${projectId}`);
|
|
90
|
+
return { cancelled: true, message: 'Launch cancelled' };
|
|
91
|
+
}
|
|
92
|
+
throw error;
|
|
93
|
+
}
|
|
64
94
|
|
|
65
95
|
debug.log('preview', `✅ Browser tab opened successfully - tabId: ${tab.id}, URL: ${tab.url}, project: ${projectId}`);
|
|
66
96
|
|
|
67
97
|
// Tab activity is marked automatically in tab-manager
|
|
68
98
|
|
|
69
99
|
return {
|
|
100
|
+
cancelled: false,
|
|
70
101
|
tabId: tab.id,
|
|
71
102
|
quality: tab.quality,
|
|
72
103
|
url: tab.url,
|
|
@@ -150,6 +181,31 @@ export const tabPreviewHandler = createRouter()
|
|
|
150
181
|
})
|
|
151
182
|
|
|
152
183
|
// Close browser tab
|
|
184
|
+
/**
|
|
185
|
+
* Stop a launch that has not produced a tab yet.
|
|
186
|
+
*
|
|
187
|
+
* Separate from the `stop` interaction, which needs a tab to address: for
|
|
188
|
+
* the length of the first navigation there is no tab, which is exactly the
|
|
189
|
+
* window in which the Stop button used to do nothing at all.
|
|
190
|
+
*/
|
|
191
|
+
.http('preview:browser-tab-open-cancel', {
|
|
192
|
+
data: t.Object({
|
|
193
|
+
launchId: t.String({ minLength: 1 })
|
|
194
|
+
}),
|
|
195
|
+
response: t.Object({
|
|
196
|
+
/**
|
|
197
|
+
* That the cancel was recorded — not that a load was interrupted.
|
|
198
|
+
* A Stop can legitimately arrive before its own launch has reached
|
|
199
|
+
* the tab manager, and it is honoured when the launch gets there.
|
|
200
|
+
*/
|
|
201
|
+
accepted: t.Boolean()
|
|
202
|
+
})
|
|
203
|
+
}, async ({ data, conn }) => {
|
|
204
|
+
const { previewService } = requireBrowserPreviewAccess(conn);
|
|
205
|
+
await previewService.cancelLaunch(data.launchId);
|
|
206
|
+
return { accepted: true };
|
|
207
|
+
})
|
|
208
|
+
|
|
153
209
|
.http('preview:browser-tab-close', {
|
|
154
210
|
data: t.Object({
|
|
155
211
|
tabId: t.Optional(t.String()) // If not provided, close active tab
|
|
@@ -14,11 +14,13 @@
|
|
|
14
14
|
* - cleanup.ts: Admin cleanup endpoints (status, perform)
|
|
15
15
|
* - webcodecs.ts: WebCodecs streaming handlers
|
|
16
16
|
* - native-ui.ts: Native UI handlers (dialogs, print, select, context menu)
|
|
17
|
+
* - data.ts: Browsing data (list sites, clear one or all)
|
|
17
18
|
* - mcp.ts: MCP tab coordination response handlers
|
|
18
19
|
* - host.ts: Viewer-answered capabilities (geolocation, camera, clipboard, files)
|
|
19
20
|
*
|
|
20
21
|
* Available endpoints:
|
|
21
22
|
* - preview:browser-tab-open - Open new browser tab (with optional URL)
|
|
23
|
+
* - preview:browser-tab-open-cancel - Stop a launch that has no tab yet
|
|
22
24
|
* - preview:browser-tab-close - Close browser tab
|
|
23
25
|
* - preview:browser-tab-navigate - Navigate tab to new URL
|
|
24
26
|
* - preview:browser-tab-history-go - Walk the tab's history (back/forward)
|
|
@@ -31,6 +33,8 @@
|
|
|
31
33
|
* - preview:browser-console-clear - Clear console logs
|
|
32
34
|
* - preview:browser-console-execute - Execute console command
|
|
33
35
|
* - preview:browser-console-toggle - Toggle console logging
|
|
36
|
+
* - preview:browser-data-list - List sites the workspace profile holds data for
|
|
37
|
+
* - preview:browser-data-clear - Clear one site's data, or all of it
|
|
34
38
|
* - preview:browser-cleanup-status - Get cleanup status
|
|
35
39
|
* - preview:browser-cleanup-perform - Perform cleanup
|
|
36
40
|
* - preview:browser-stream-start - Start streaming
|
|
@@ -48,6 +52,7 @@ import { tabInfoPreviewHandler } from './browser/tab-info';
|
|
|
48
52
|
import { statsPreviewHandler } from './browser/stats';
|
|
49
53
|
import { consolePreviewHandler } from './browser/console';
|
|
50
54
|
import { cleanupPreviewHandler } from './browser/cleanup';
|
|
55
|
+
import { browsingDataPreviewHandler } from './browser/data';
|
|
51
56
|
import { streamPreviewHandler } from './browser/webcodecs';
|
|
52
57
|
import { nativeUIPreviewHandler } from './browser/native-ui';
|
|
53
58
|
import { mcpPreviewHandler } from './browser/mcp';
|
|
@@ -59,6 +64,7 @@ export const previewRouter = createRouter()
|
|
|
59
64
|
.merge(tabInfoPreviewHandler)
|
|
60
65
|
.merge(statsPreviewHandler)
|
|
61
66
|
.merge(consolePreviewHandler)
|
|
67
|
+
.merge(browsingDataPreviewHandler)
|
|
62
68
|
.merge(cleanupPreviewHandler)
|
|
63
69
|
.merge(streamPreviewHandler)
|
|
64
70
|
.merge(nativeUIPreviewHandler)
|
|
@@ -73,6 +79,11 @@ export const previewRouter = createRouter()
|
|
|
73
79
|
url: t.String(),
|
|
74
80
|
title: t.String(),
|
|
75
81
|
isActive: t.Boolean(),
|
|
82
|
+
/**
|
|
83
|
+
* The launch this tab came from, when a client started it. Absent for
|
|
84
|
+
* tabs the backend opened on its own (an agent, a popup).
|
|
85
|
+
*/
|
|
86
|
+
launchId: t.Optional(t.String()),
|
|
76
87
|
timestamp: t.Number()
|
|
77
88
|
}))
|
|
78
89
|
.emit('preview:browser-tab-closed', t.Object({
|
|
@@ -87,6 +98,16 @@ export const previewRouter = createRouter()
|
|
|
87
98
|
newTabId: t.String(),
|
|
88
99
|
timestamp: t.Number()
|
|
89
100
|
}))
|
|
101
|
+
.emit('preview:browser-tab-lifecycle', t.Object({
|
|
102
|
+
projectId: t.String(),
|
|
103
|
+
tabId: t.String(),
|
|
104
|
+
/**
|
|
105
|
+
* Whether the page is frozen. A sleeping tab runs no script at all —
|
|
106
|
+
* the strip says so rather than showing it as a page still working.
|
|
107
|
+
*/
|
|
108
|
+
sleeping: t.Boolean(),
|
|
109
|
+
timestamp: t.Number()
|
|
110
|
+
}))
|
|
90
111
|
.emit('preview:browser-tab-navigated', t.Object({
|
|
91
112
|
projectId: t.String(),
|
|
92
113
|
tabId: t.String(),
|
|
@@ -24,7 +24,6 @@ import type { EngineType } from '$shared/types/unified';
|
|
|
24
24
|
|
|
25
25
|
const ITEMS_SCHEMA = t.Object({
|
|
26
26
|
skill: t.Array(t.String()),
|
|
27
|
-
command: t.Array(t.String()),
|
|
28
27
|
subagent: t.Array(t.String()),
|
|
29
28
|
mcp: t.Array(t.String())
|
|
30
29
|
});
|
|
@@ -41,7 +40,7 @@ const PROFILE_SCHEMA = t.Object({
|
|
|
41
40
|
});
|
|
42
41
|
|
|
43
42
|
const ITEM_INPUT_SCHEMA = t.Array(t.Object({
|
|
44
|
-
artifactType: t.Union([t.Literal('skill'), t.Literal('
|
|
43
|
+
artifactType: t.Union([t.Literal('skill'), t.Literal('subagent'), t.Literal('mcp')]),
|
|
45
44
|
ref: t.String()
|
|
46
45
|
}));
|
|
47
46
|
|
|
@@ -72,7 +71,7 @@ export const profilesCrudHandler = createRouter()
|
|
|
72
71
|
})
|
|
73
72
|
.http('profiles:inventory', {
|
|
74
73
|
data: t.Object({}),
|
|
75
|
-
response: t.Object({ skill: INVENTORY_ENTRY,
|
|
74
|
+
response: t.Object({ skill: INVENTORY_ENTRY, subagent: INVENTORY_ENTRY, mcp: INVENTORY_ENTRY })
|
|
76
75
|
}, () => {
|
|
77
76
|
debug.log('path', 'profiles:inventory');
|
|
78
77
|
return profileService.inventory();
|