@myrialabs/clopen 0.4.40 → 0.4.41
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 +42 -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/index.ts +21 -0
- package/backend/database/queries/file-share-queries.ts +163 -0
- package/backend/database/queries/index.ts +6 -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/stream.ts +2 -1
- package/backend/engine/adapters/cline/stream.ts +3 -3
- package/backend/engine/adapters/codex/stream.ts +3 -3
- package/backend/engine/adapters/copilot/stream.ts +3 -3
- package/backend/engine/adapters/cursor/stream.ts +25 -3
- package/backend/engine/adapters/opencode/stream.ts +4 -6
- package/backend/engine/adapters/pi/stream.ts +2 -2
- package/backend/engine/adapters/qwen/stream.ts +2 -2
- 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/files/file-shares.ts +369 -0
- package/backend/files/path-browsing.ts +27 -21
- 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 +8 -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/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/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/commit-message.ts +2 -2
- package/backend/ws/index.ts +3 -4
- 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/dist/assets/{index-D4igjF6e.js → index-CeNKKSDR.js} +1 -1
- package/dist/assets/{index-DONNwiXm.js → index-DW89566K.js} +1 -1
- package/dist/assets/{main-BrfXH1bL.js → main-Cy5DXWPT.js} +592 -590
- package/dist/assets/main-DJKj_4By.css +1 -0
- package/dist/index.html +7 -2
- package/dist/sw.js +112 -0
- package/package.json +1 -1
- package/shared/constants/engine-tools.ts +31 -6
- package/shared/constants/notification-messages.ts +142 -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
|
@@ -9,7 +9,7 @@
|
|
|
9
9
|
|
|
10
10
|
import { subagentQueries } from '$backend/database/queries';
|
|
11
11
|
import { debug } from '$shared/utils/logger';
|
|
12
|
-
import { materializeArtifacts, resolveArtifact, isPromptScopedEngine, parseDoc, serializeDoc, parseEngineMap, artifactEngineToType, type ManagedArtifact, type ArtifactEngine } from '$backend/artifacts';
|
|
12
|
+
import { materializeArtifacts, resolveArtifact, isPromptScopedEngine, canDelegateSubagents, parseDoc, serializeDoc, parseEngineMap, artifactEngineToType, ARTIFACT_ENGINES, type ManagedArtifact, type ArtifactEngine } from '$backend/artifacts';
|
|
13
13
|
import { artifactFilter } from '$backend/profiles';
|
|
14
14
|
import { readSubagentMd } from './store';
|
|
15
15
|
|
|
@@ -56,11 +56,17 @@ function resolveEnabledSubagentsMeta(profileId?: number): ManagedArtifact[] {
|
|
|
56
56
|
|
|
57
57
|
/**
|
|
58
58
|
* The profile-scoped subagents preamble for PER-SESSION injection into a
|
|
59
|
-
* prompt-scoped engine's prompt
|
|
60
|
-
*
|
|
61
|
-
*
|
|
59
|
+
* prompt-scoped engine's prompt. Returns '' when none apply. Advisory: it steers
|
|
60
|
+
* which subagents the model delegates to, on top of whatever the engine's own
|
|
61
|
+
* (possibly stale/shared) agent registry exposes.
|
|
62
|
+
*
|
|
63
|
+
* Engines with no way to delegate (Codex, Copilot, Qwen) are told nothing. They
|
|
64
|
+
* used to receive the same "you can delegate matching tasks to these" preamble
|
|
65
|
+
* as engines that can, which described a capability they do not have — the model
|
|
66
|
+
* could only respond by inventing the delegation or ignoring the block.
|
|
62
67
|
*/
|
|
63
|
-
export function buildSubagentsPromptContext(profileId?: number): string {
|
|
68
|
+
export function buildSubagentsPromptContext(engine: ArtifactEngine, profileId?: number): string {
|
|
69
|
+
if (!canDelegateSubagents(engine)) return '';
|
|
64
70
|
return buildSubagentsPreamble(resolveEnabledSubagentsMeta(profileId));
|
|
65
71
|
}
|
|
66
72
|
|
|
@@ -111,7 +117,9 @@ export async function syncSubagents(engine: ArtifactEngine, profileId?: number):
|
|
|
111
117
|
// In both cases materialize an EMPTY set so any stale dir/block is stripped.
|
|
112
118
|
// Claude keeps its native filtered files; Qwen (per-query) keeps its preamble.
|
|
113
119
|
const synthetic = resolveArtifact('subagent', { engine, scope: 'global' }).format === 'preamble-region';
|
|
114
|
-
|
|
120
|
+
// An engine that cannot delegate gets an empty set too: no files, no block,
|
|
121
|
+
// no advertisement anywhere (see {@link buildSubagentsPromptContext}).
|
|
122
|
+
const viaPrompt = (synthetic && isPromptScopedEngine(engine)) || engine === 'opencode' || !canDelegateSubagents(engine);
|
|
115
123
|
const filter = artifactFilter(profileId, 'subagent');
|
|
116
124
|
// A profile activates the subagents it references even if globally disabled;
|
|
117
125
|
// with no profile filter, only the enabled set applies (unchanged).
|
|
@@ -139,6 +147,5 @@ export async function syncSubagents(engine: ArtifactEngine, profileId?: number):
|
|
|
139
147
|
}
|
|
140
148
|
|
|
141
149
|
export async function syncSubagentsAllEngines(): Promise<void> {
|
|
142
|
-
|
|
143
|
-
await Promise.all(engines.map(syncSubagents));
|
|
150
|
+
await Promise.all(ARTIFACT_ENGINES.map(engine => syncSubagents(engine)));
|
|
144
151
|
}
|
|
@@ -14,7 +14,7 @@ import { execGit } from '$backend/git/git-executor';
|
|
|
14
14
|
import { gitService } from '$backend/git/git-service';
|
|
15
15
|
import { workLinkQueries } from '$backend/database/queries';
|
|
16
16
|
import { initializeEngine } from '$backend/engine';
|
|
17
|
-
import { resolveGenerationTarget } from '$backend/engine/resolve-model';
|
|
17
|
+
import { resolveGenerationTarget, GENERATION_SETTINGS } from '$backend/engine/resolve-model';
|
|
18
18
|
import { buildBudgetedDiff, PR_DESCRIPTION_BUDGET, rangeScope } from '$backend/ws/git/diff-budget';
|
|
19
19
|
import type { EngineType } from '$shared/types/unified';
|
|
20
20
|
import type { GitBranchInfo } from '$shared/types/git';
|
|
@@ -226,7 +226,7 @@ export async function draftPullRequestDescription(input: {
|
|
|
226
226
|
diffTruncated: diff.truncated
|
|
227
227
|
});
|
|
228
228
|
|
|
229
|
-
const target = await resolveGenerationTarget(engine, input.modelId, input.providerSlug);
|
|
229
|
+
const target = await resolveGenerationTarget(engine, input.modelId, input.providerSlug, GENERATION_SETTINGS.commit);
|
|
230
230
|
debug.log('work', `Drafting a PR description via ${input.engine}/${target.providerSlug}/${target.modelId}`);
|
|
231
231
|
|
|
232
232
|
const result = await engine.generateStructured<GeneratedDescription>({
|
|
@@ -15,10 +15,39 @@ import { debug } from '$shared/utils/logger';
|
|
|
15
15
|
import { trimSubAgentForWire } from '$shared/utils/subagent-wire-trim';
|
|
16
16
|
import { ws } from '$backend/utils/ws';
|
|
17
17
|
import { broadcastPresence } from '../projects/status';
|
|
18
|
-
import { sessionQueries, messageQueries } from '../../database/queries';
|
|
18
|
+
import { projectQueries, sessionQueries, messageQueries } from '../../database/queries';
|
|
19
|
+
import { sendPushToUser } from '../../push/sender';
|
|
20
|
+
import { chatStreamPushTag, waitingInputPushTag } from '../../push/tags';
|
|
21
|
+
import {
|
|
22
|
+
chatNotificationMessage,
|
|
23
|
+
type ChatNotificationContext
|
|
24
|
+
} from '$shared/constants/notification-messages';
|
|
19
25
|
import { requireSessionAccess } from '../access';
|
|
20
26
|
import { resolveSessionPath } from '../../worktrees';
|
|
21
27
|
|
|
28
|
+
/**
|
|
29
|
+
* Where a notification-worthy event happened, resolved once on the server.
|
|
30
|
+
*
|
|
31
|
+
* The browser cannot do this itself: the sessions store only holds the project
|
|
32
|
+
* currently open, and these notifications exist precisely for the chats the
|
|
33
|
+
* user is *not* looking at. Shipping the resolved names in the event payload
|
|
34
|
+
* also keeps the tab's local toast worded identically to the server push that
|
|
35
|
+
* replaces it — they share a tag, so any difference would read as the
|
|
36
|
+
* notification rewriting itself.
|
|
37
|
+
*
|
|
38
|
+
* Missing rows yield `undefined`, never a placeholder: the composer drops an
|
|
39
|
+
* absent segment, which says more than the word "Unknown" did.
|
|
40
|
+
*/
|
|
41
|
+
function resolveNotificationContext(
|
|
42
|
+
projectId: string,
|
|
43
|
+
chatSessionId: string | undefined
|
|
44
|
+
): ChatNotificationContext {
|
|
45
|
+
return {
|
|
46
|
+
projectName: projectQueries.getById(projectId)?.name || undefined,
|
|
47
|
+
sessionTitle: chatSessionId ? sessionQueries.getById(chatSessionId)?.title || undefined : undefined
|
|
48
|
+
};
|
|
49
|
+
}
|
|
50
|
+
|
|
22
51
|
/**
|
|
23
52
|
* Broadcast presence + notify project members when a chat message may flip the
|
|
24
53
|
* stream's waiting-for-input state (an AskUserQuestion tool_use arrives, or a
|
|
@@ -52,12 +81,31 @@ function handleWaitingInputChange(
|
|
|
52
81
|
|
|
53
82
|
// Notify all project members when AskUserQuestion arrives (sound + push)
|
|
54
83
|
if (askToolUse && projectId) {
|
|
84
|
+
const context = resolveNotificationContext(projectId, chatSessionId);
|
|
85
|
+
|
|
55
86
|
ws.emit.projectMembers(projectId, 'chat:waiting-input', {
|
|
56
87
|
projectId,
|
|
57
88
|
chatSessionId,
|
|
58
89
|
toolUseId: askToolUse.id,
|
|
59
|
-
timestamp: event.data?.timestamp || new Date().toISOString()
|
|
90
|
+
timestamp: event.data?.timestamp || new Date().toISOString(),
|
|
91
|
+
...context
|
|
60
92
|
});
|
|
93
|
+
|
|
94
|
+
// Background route: reach the requester's devices even when Chrome is
|
|
95
|
+
// closed. Deterministic tag replaces (not stacks with) the local toast
|
|
96
|
+
// the open tab shows for the same question.
|
|
97
|
+
const requestedByUserId = streamManager.getSessionStream(
|
|
98
|
+
chatSessionId,
|
|
99
|
+
projectId
|
|
100
|
+
)?.requestedByUserId;
|
|
101
|
+
if (requestedByUserId) {
|
|
102
|
+
void sendPushToUser(requestedByUserId, {
|
|
103
|
+
...chatNotificationMessage('waiting-input', context),
|
|
104
|
+
tag: waitingInputPushTag(askToolUse.id)
|
|
105
|
+
}).catch((error) => {
|
|
106
|
+
debug.warn('notification', 'Background waiting-input push failed:', error);
|
|
107
|
+
});
|
|
108
|
+
}
|
|
61
109
|
}
|
|
62
110
|
}
|
|
63
111
|
|
|
@@ -68,8 +116,8 @@ function handleWaitingInputChange(
|
|
|
68
116
|
// exists (e.g., after browser refresh when user is on a different project).
|
|
69
117
|
// Ensures cross-project notifications (presence update, sound, push) always work.
|
|
70
118
|
// ============================================================================
|
|
71
|
-
streamManager.on('stream:lifecycle', (event: { status: string; streamId: string; projectId?: string; chatSessionId?: string; timestamp: string; reason?: string }) => {
|
|
72
|
-
const { status, projectId, chatSessionId, timestamp, reason } = event;
|
|
119
|
+
streamManager.on('stream:lifecycle', (event: { status: string; streamId: string; projectId?: string; chatSessionId?: string; requestedByUserId?: string; timestamp: string; reason?: string }) => {
|
|
120
|
+
const { status, streamId, projectId, chatSessionId, requestedByUserId, timestamp, reason } = event;
|
|
73
121
|
if (!projectId) return;
|
|
74
122
|
|
|
75
123
|
debug.log('chat', `Stream lifecycle: ${status} for project ${projectId} session ${chatSessionId}${reason ? ` (reason: ${reason})` : ''}`);
|
|
@@ -83,15 +131,39 @@ streamManager.on('stream:lifecycle', (event: { status: string; streamId: string;
|
|
|
83
131
|
}
|
|
84
132
|
}
|
|
85
133
|
|
|
134
|
+
// Resolved once and shared: the payload below carries it to the open tab,
|
|
135
|
+
// and the background push below that reuses the very same values, so the
|
|
136
|
+
// two copies of one event cannot word themselves differently.
|
|
137
|
+
const context = resolveNotificationContext(projectId, chatSessionId);
|
|
138
|
+
|
|
86
139
|
// Notify all project members (cross-project notification for sound + push)
|
|
87
140
|
ws.emit.projectMembers(projectId, 'chat:stream-finished', {
|
|
88
141
|
projectId,
|
|
89
142
|
chatSessionId: chatSessionId || '',
|
|
143
|
+
streamId,
|
|
90
144
|
status: status as 'completed' | 'error' | 'cancelled',
|
|
91
145
|
timestamp,
|
|
92
|
-
reason
|
|
146
|
+
reason,
|
|
147
|
+
...context
|
|
93
148
|
});
|
|
94
149
|
|
|
150
|
+
// Background route: the open tab notifies locally via the WS event above;
|
|
151
|
+
// this reaches the requester's devices when Chrome is closed. The shared
|
|
152
|
+
// deterministic tag means an open tab's local toast is replaced, never
|
|
153
|
+
// duplicated. Never throws — chat completion must not depend on push.
|
|
154
|
+
if (requestedByUserId && reason !== 'session-deleted') {
|
|
155
|
+
// `cancelled` gets its own title. Filing it under a "complete" heading
|
|
156
|
+
// with an "interrupted" body made the notification contradict itself.
|
|
157
|
+
const notificationEvent =
|
|
158
|
+
status === 'error' ? 'error' : status === 'cancelled' ? 'cancelled' : 'completed';
|
|
159
|
+
void sendPushToUser(requestedByUserId, {
|
|
160
|
+
...chatNotificationMessage(notificationEvent, context),
|
|
161
|
+
tag: chatStreamPushTag(streamId)
|
|
162
|
+
}).catch((error) => {
|
|
163
|
+
debug.warn('notification', 'Background stream-finished push failed:', error);
|
|
164
|
+
});
|
|
165
|
+
}
|
|
166
|
+
|
|
95
167
|
// Broadcast updated presence (status indicators for all projects)
|
|
96
168
|
broadcastPresence().catch((err) => {
|
|
97
169
|
debug.warn('chat', 'Presence broadcast error after stream lifecycle:', err);
|
|
@@ -241,6 +313,16 @@ export const streamHandler = createRouter()
|
|
|
241
313
|
workingRoot
|
|
242
314
|
});
|
|
243
315
|
|
|
316
|
+
// The WS user id is server-trusted (unlike the client-supplied sender)
|
|
317
|
+
// and routes background Web Push to the requester's devices. Missing
|
|
318
|
+
// context must not break the stream — push is best-effort.
|
|
319
|
+
let requestedByUserId: string | undefined;
|
|
320
|
+
try {
|
|
321
|
+
requestedByUserId = ws.getUserId(conn);
|
|
322
|
+
} catch {
|
|
323
|
+
requestedByUserId = undefined;
|
|
324
|
+
}
|
|
325
|
+
|
|
244
326
|
// Start background stream
|
|
245
327
|
const streamId = await streamManager.startStream({
|
|
246
328
|
projectPath: workingRoot,
|
|
@@ -250,7 +332,8 @@ export const streamHandler = createRouter()
|
|
|
250
332
|
engine: data.engine,
|
|
251
333
|
sender: data.sender,
|
|
252
334
|
profileId: data.profileId,
|
|
253
|
-
reasoningEffort: data.reasoningEffort
|
|
335
|
+
reasoningEffort: data.reasoningEffort,
|
|
336
|
+
requestedByUserId
|
|
254
337
|
});
|
|
255
338
|
|
|
256
339
|
debug.log('chat', 'Stream started with ID:', streamId);
|
|
@@ -1085,19 +1168,28 @@ export const streamHandler = createRouter()
|
|
|
1085
1168
|
timestamp: t.String()
|
|
1086
1169
|
}))
|
|
1087
1170
|
|
|
1171
|
+
// `projectName` / `sessionTitle` are resolved server-side and carried here
|
|
1172
|
+
// so the tab can word its local notification exactly like the background
|
|
1173
|
+
// push that replaces it. Optional because either row may be gone, and
|
|
1174
|
+
// because a tab left open across a server upgrade will not send them.
|
|
1088
1175
|
.emit('chat:stream-finished', t.Object({
|
|
1089
1176
|
projectId: t.String(),
|
|
1090
1177
|
chatSessionId: t.String(),
|
|
1178
|
+
streamId: t.Optional(t.String()),
|
|
1091
1179
|
status: t.Union([t.Literal('completed'), t.Literal('error'), t.Literal('cancelled')]),
|
|
1092
1180
|
timestamp: t.String(),
|
|
1093
|
-
reason: t.Optional(t.String())
|
|
1181
|
+
reason: t.Optional(t.String()),
|
|
1182
|
+
projectName: t.Optional(t.String()),
|
|
1183
|
+
sessionTitle: t.Optional(t.String())
|
|
1094
1184
|
}))
|
|
1095
1185
|
|
|
1096
1186
|
.emit('chat:waiting-input', t.Object({
|
|
1097
1187
|
projectId: t.String(),
|
|
1098
1188
|
chatSessionId: t.String(),
|
|
1099
1189
|
toolUseId: t.String(),
|
|
1100
|
-
timestamp: t.String()
|
|
1190
|
+
timestamp: t.String(),
|
|
1191
|
+
projectName: t.Optional(t.String()),
|
|
1192
|
+
sessionTitle: t.Optional(t.String())
|
|
1101
1193
|
}))
|
|
1102
1194
|
|
|
1103
1195
|
.emit('snapshot:captured', t.Object({
|
|
@@ -19,6 +19,7 @@ import { revealHandler } from './reveal';
|
|
|
19
19
|
import { clipboardHandler } from './clipboard';
|
|
20
20
|
import { imageEditHandler } from './image-edit';
|
|
21
21
|
import { fileSearchHandler } from './search';
|
|
22
|
+
import { fileShareHandler } from './share';
|
|
22
23
|
import { watchHandler } from './watch';
|
|
23
24
|
import { filesStateHandler } from './state';
|
|
24
25
|
|
|
@@ -41,6 +42,9 @@ export const filesRouter = createRouter()
|
|
|
41
42
|
// Search Operations (HTTP)
|
|
42
43
|
.merge(fileSearchHandler)
|
|
43
44
|
|
|
45
|
+
// Single-file share links (HTTP)
|
|
46
|
+
.merge(fileShareHandler)
|
|
47
|
+
|
|
44
48
|
// Watch Operations (Events)
|
|
45
49
|
.merge(watchHandler)
|
|
46
50
|
|
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* File share-link WebSocket handlers (File Explorer → "Share Link…").
|
|
3
|
+
*
|
|
4
|
+
* - files:create-share — authenticated user mints a link for one file, with
|
|
5
|
+
* its one-time / deadline options. The raw token is embedded in the share
|
|
6
|
+
* URL; only its hash is stored, and the row id comes back alongside it so
|
|
7
|
+
* the link stays manageable afterwards.
|
|
8
|
+
* - files:list-shares — live links: every user's for an admin, your own
|
|
9
|
+
* otherwise. Carries no token material, so it can never rebuild a URL.
|
|
10
|
+
* - files:revoke-share — creator (or admin) invalidates a link by row id.
|
|
11
|
+
* - files:shares-changed — broadcast whenever that list moves, so every open
|
|
12
|
+
* management view reflects a mint, a revoke or an open without polling.
|
|
13
|
+
*
|
|
14
|
+
* Reachability (how another device can open the link) is NOT handled here —
|
|
15
|
+
* the frontend builds the URL against the Remote Access public origin
|
|
16
|
+
* (`share:ensure-origin`), reusing that system instead of a new one.
|
|
17
|
+
*/
|
|
18
|
+
|
|
19
|
+
import { t } from 'elysia';
|
|
20
|
+
import { createRouter } from '$shared/utils/ws-server';
|
|
21
|
+
import { ws } from '$backend/utils/ws';
|
|
22
|
+
import {
|
|
23
|
+
createFileShareLink,
|
|
24
|
+
listFileShares,
|
|
25
|
+
revokeFileShareLink,
|
|
26
|
+
MAX_FILE_SHARE_TTL_MINUTES
|
|
27
|
+
} from '../../files/file-shares';
|
|
28
|
+
|
|
29
|
+
const shareSummary = t.Object({
|
|
30
|
+
id: t.String(),
|
|
31
|
+
filePath: t.String(),
|
|
32
|
+
fileName: t.String(),
|
|
33
|
+
projectName: t.Union([t.String(), t.Null()]),
|
|
34
|
+
worktreeName: t.Union([t.String(), t.Null()]),
|
|
35
|
+
relativePath: t.String(),
|
|
36
|
+
createdBy: t.String(),
|
|
37
|
+
createdByName: t.Union([t.String(), t.Null()]),
|
|
38
|
+
createdAt: t.String(),
|
|
39
|
+
oneTime: t.Boolean(),
|
|
40
|
+
expiresAt: t.Union([t.String(), t.Null()]),
|
|
41
|
+
openCount: t.Number(),
|
|
42
|
+
lastOpenedAt: t.Union([t.String(), t.Null()]),
|
|
43
|
+
consumedAt: t.Union([t.String(), t.Null()])
|
|
44
|
+
});
|
|
45
|
+
|
|
46
|
+
export const fileShareHandler = createRouter()
|
|
47
|
+
.http('files:create-share', {
|
|
48
|
+
data: t.Object({
|
|
49
|
+
file_path: t.String({ minLength: 1 }),
|
|
50
|
+
/** Burn on the first open. Defaults to true. */
|
|
51
|
+
oneTime: t.Optional(t.Boolean()),
|
|
52
|
+
/** Minutes until it lapses, or null for "until revoked". */
|
|
53
|
+
expiresInMinutes: t.Optional(
|
|
54
|
+
t.Union([t.Number({ minimum: 1, maximum: MAX_FILE_SHARE_TTL_MINUTES }), t.Null()])
|
|
55
|
+
)
|
|
56
|
+
}),
|
|
57
|
+
response: t.Object({
|
|
58
|
+
shareId: t.String(),
|
|
59
|
+
shareToken: t.String(),
|
|
60
|
+
oneTime: t.Boolean(),
|
|
61
|
+
expiresAt: t.Union([t.String(), t.Null()])
|
|
62
|
+
})
|
|
63
|
+
}, async ({ data, conn }) => {
|
|
64
|
+
const result = await createFileShareLink(data.file_path, ws.getRole(conn), ws.getUserId(conn), {
|
|
65
|
+
oneTime: data.oneTime,
|
|
66
|
+
expiresInMinutes: data.expiresInMinutes
|
|
67
|
+
});
|
|
68
|
+
ws.emit.global('files:shares-changed', { kind: 'created' });
|
|
69
|
+
return result;
|
|
70
|
+
})
|
|
71
|
+
|
|
72
|
+
.http('files:list-shares', {
|
|
73
|
+
data: t.Object({}),
|
|
74
|
+
response: t.Object({ shares: t.Array(shareSummary) })
|
|
75
|
+
}, async ({ conn }) => {
|
|
76
|
+
return { shares: listFileShares(ws.getRole(conn), ws.getUserId(conn)) };
|
|
77
|
+
})
|
|
78
|
+
|
|
79
|
+
.http('files:revoke-share', {
|
|
80
|
+
data: t.Object({
|
|
81
|
+
shareId: t.String({ minLength: 1 })
|
|
82
|
+
}),
|
|
83
|
+
response: t.Object({ success: t.Boolean() })
|
|
84
|
+
}, async ({ data, conn }) => {
|
|
85
|
+
const success = revokeFileShareLink(data.shareId, ws.getRole(conn), ws.getUserId(conn));
|
|
86
|
+
if (success) ws.emit.global('files:shares-changed', { kind: 'revoked' });
|
|
87
|
+
return { success };
|
|
88
|
+
})
|
|
89
|
+
|
|
90
|
+
// Broadcast-only: the payload says nothing about whose link moved, because
|
|
91
|
+
// every listener re-reads its own role-scoped list. A global ping cannot
|
|
92
|
+
// leak what a user is not allowed to see.
|
|
93
|
+
.emit('files:shares-changed', t.Object({
|
|
94
|
+
kind: t.String()
|
|
95
|
+
}));
|
|
@@ -9,7 +9,7 @@ import { createRouter } from '$shared/utils/ws-server';
|
|
|
9
9
|
import { execGit } from '../../git/git-executor';
|
|
10
10
|
import { buildBudgetedStagedDiff, BRANCH_NAME_BUDGET } from './diff-budget';
|
|
11
11
|
import { initializeEngine } from '../../engine';
|
|
12
|
-
import { resolveGenerationTarget } from '../../engine/resolve-model';
|
|
12
|
+
import { resolveGenerationTarget, GENERATION_SETTINGS } from '../../engine/resolve-model';
|
|
13
13
|
import type { EngineType } from '$shared/types/unified';
|
|
14
14
|
import type { GeneratedBranchName } from '$shared/types/git';
|
|
15
15
|
import {
|
|
@@ -171,7 +171,7 @@ export const branchNameHandler = createRouter()
|
|
|
171
171
|
const prompt = `${instructions}${extra ? `\n\nAdditional constraints:\n${extra}` : ''}\n\n${diff.text}`;
|
|
172
172
|
|
|
173
173
|
// The caller's providerSlug/account can be stale (see resolve-model.ts).
|
|
174
|
-
const target = await resolveGenerationTarget(engine, data.modelId, data.providerSlug);
|
|
174
|
+
const target = await resolveGenerationTarget(engine, data.modelId, data.providerSlug, GENERATION_SETTINGS.commit);
|
|
175
175
|
|
|
176
176
|
debug.log('git', `Generating branch name via ${engineType}/${target.providerSlug}/${target.modelId}`);
|
|
177
177
|
|
|
@@ -8,7 +8,7 @@ import { t } from 'elysia';
|
|
|
8
8
|
import { createRouter } from '$shared/utils/ws-server';
|
|
9
9
|
import { buildBudgetedStagedDiff, COMMIT_MESSAGE_BUDGET } from './diff-budget';
|
|
10
10
|
import { initializeEngine } from '../../engine';
|
|
11
|
-
import { resolveGenerationTarget } from '../../engine/resolve-model';
|
|
11
|
+
import { resolveGenerationTarget, GENERATION_SETTINGS } from '../../engine/resolve-model';
|
|
12
12
|
import type { EngineType } from '$shared/types/unified';
|
|
13
13
|
import type { GeneratedCommitMessage } from '$shared/types/git';
|
|
14
14
|
import { debug } from '$shared/utils/logger';
|
|
@@ -116,7 +116,7 @@ ${diff.text}`;
|
|
|
116
116
|
: defaultPrompt;
|
|
117
117
|
|
|
118
118
|
// The caller's providerSlug/account can be stale (see resolve-model.ts).
|
|
119
|
-
const target = await resolveGenerationTarget(engine, data.modelId, data.providerSlug);
|
|
119
|
+
const target = await resolveGenerationTarget(engine, data.modelId, data.providerSlug, GENERATION_SETTINGS.commit);
|
|
120
120
|
|
|
121
121
|
debug.log('git', `Generating commit message via ${engineType}/${target.providerSlug}/${target.modelId}`);
|
|
122
122
|
|
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)
|
|
@@ -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();
|
|
@@ -10,7 +10,7 @@
|
|
|
10
10
|
import { t } from 'elysia';
|
|
11
11
|
import { createRouter } from '$shared/utils/ws-server';
|
|
12
12
|
import { debug } from '$shared/utils/logger';
|
|
13
|
-
import { listMarketplaceSkills, skillService } from '$backend/skills';
|
|
13
|
+
import { listMarketplaceSkills, skillService, syncSkillsAllEngines } from '$backend/skills';
|
|
14
14
|
|
|
15
15
|
const MARKETPLACE_SKILL_SCHEMA = t.Object({
|
|
16
16
|
ref: t.String(),
|
|
@@ -31,6 +31,9 @@ const SKILL_SCHEMA = t.Object({
|
|
|
31
31
|
marketplaceRef: t.Union([t.String(), t.Null()]),
|
|
32
32
|
version: t.Union([t.String(), t.Null()]),
|
|
33
33
|
license: t.Union([t.String(), t.Null()]),
|
|
34
|
+
triggers: t.Array(t.Union([t.Literal('auto'), t.Literal('slash')])),
|
|
35
|
+
argumentHint: t.Union([t.String(), t.Null()]),
|
|
36
|
+
uses: t.Array(t.String()),
|
|
34
37
|
enabled: t.Boolean(),
|
|
35
38
|
present: t.Boolean(),
|
|
36
39
|
createdAt: t.String()
|
|
@@ -75,5 +78,6 @@ export const skillCatalogHandler = createRouter()
|
|
|
75
78
|
debug.log('path', `skills:install ${data.ref}`);
|
|
76
79
|
const { ref, ...override } = data;
|
|
77
80
|
const skill = await skillService.install(ref, override);
|
|
81
|
+
await syncSkillsAllEngines();
|
|
78
82
|
return { skill };
|
|
79
83
|
});
|