@kimuson/claude-code-viewer 0.6.0-beta.1 → 0.6.0-beta.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +11 -0
- package/dist/main.js +771 -573
- package/dist/main.js.map +4 -4
- package/dist/static/assets/ProtectedRoute-edQHkSob.js +1 -0
- package/dist/static/assets/{eye-B778x9yq.js → eye-9sEkIEDN.js} +1 -1
- package/dist/static/assets/{index-oaJjtYYB.js → index-C6F_DxvV.js} +1 -1
- package/dist/static/assets/index-DwUYpLCb.js +101 -0
- package/dist/static/assets/{index-Bku-MhbL.js → index-mNk1AK9F.js} +1 -1
- package/dist/static/assets/{label-NirMm8Yi.js → label-CkiWXRUG.js} +1 -1
- package/dist/static/assets/{login-BP3UU3Ko.js → login-DJTmdJXo.js} +1 -1
- package/dist/static/assets/session-Cb2uALII.js +58 -0
- package/dist/static/assets/{session-C9vbFKQy.js → session-CdGXKJhs.js} +1 -1
- package/dist/static/assets/session-DDGTF8rc.css +1 -0
- package/dist/static/index.html +1 -1
- package/package.json +49 -48
- package/dist/static/assets/ProtectedRoute-CZEcJAz0.js +0 -1
- package/dist/static/assets/index-BrH8eRF1.js +0 -101
- package/dist/static/assets/session-BRgfW03O.js +0 -51
- package/dist/static/assets/session-DFuMZ0ql.css +0 -1
package/dist/main.js
CHANGED
|
@@ -7,7 +7,7 @@ import { Effect as Effect65 } from "effect";
|
|
|
7
7
|
// package.json
|
|
8
8
|
var package_default = {
|
|
9
9
|
name: "@kimuson/claude-code-viewer",
|
|
10
|
-
version: "0.6.0-beta.
|
|
10
|
+
version: "0.6.0-beta.3",
|
|
11
11
|
description: "A full-featured web-based Claude Code client that provides complete interactive functionality for managing Claude Code projects.",
|
|
12
12
|
type: "module",
|
|
13
13
|
license: "MIT",
|
|
@@ -39,7 +39,7 @@ var package_default = {
|
|
|
39
39
|
fix: "run-s 'fix:*'",
|
|
40
40
|
"fix:biome-format": "biome format --write .",
|
|
41
41
|
"fix:biome-lint": "biome check --write --unsafe .",
|
|
42
|
-
typecheck: "
|
|
42
|
+
typecheck: "tsgo --noEmit",
|
|
43
43
|
test: "vitest --run",
|
|
44
44
|
"test:watch": "vitest",
|
|
45
45
|
e2e: "./scripts/e2e/exec_e2e.sh",
|
|
@@ -51,21 +51,21 @@ var package_default = {
|
|
|
51
51
|
prepare: "lefthook install"
|
|
52
52
|
},
|
|
53
53
|
dependencies: {
|
|
54
|
-
"@anthropic-ai/claude-agent-sdk": "0.2.
|
|
55
|
-
"@anthropic-ai/claude-code": "2.1.
|
|
56
|
-
"@anthropic-ai/sdk": "0.
|
|
57
|
-
"@effect/cluster": "0.56.
|
|
54
|
+
"@anthropic-ai/claude-agent-sdk": "0.2.42",
|
|
55
|
+
"@anthropic-ai/claude-code": "2.1.42",
|
|
56
|
+
"@anthropic-ai/sdk": "0.74.0",
|
|
57
|
+
"@effect/cluster": "0.56.4",
|
|
58
58
|
"@effect/experimental": "0.58.0",
|
|
59
|
-
"@effect/platform": "0.94.
|
|
59
|
+
"@effect/platform": "0.94.5",
|
|
60
60
|
"@effect/platform-node": "0.104.1",
|
|
61
|
-
"@effect/rpc": "0.73.
|
|
61
|
+
"@effect/rpc": "0.73.1",
|
|
62
62
|
"@effect/sql": "0.49.0",
|
|
63
63
|
"@effect/workflow": "0.16.0",
|
|
64
64
|
"@hono/node-server": "1.19.9",
|
|
65
65
|
"@hono/zod-validator": "0.7.6",
|
|
66
|
-
"@hookform/resolvers": "
|
|
67
|
-
"@lingui/core": "5.9.
|
|
68
|
-
"@lingui/react": "5.9.
|
|
66
|
+
"@hookform/resolvers": "5.2.2",
|
|
67
|
+
"@lingui/core": "5.9.1",
|
|
68
|
+
"@lingui/react": "5.9.1",
|
|
69
69
|
"@radix-ui/react-avatar": "1.1.11",
|
|
70
70
|
"@radix-ui/react-checkbox": "1.3.3",
|
|
71
71
|
"@radix-ui/react-collapsible": "1.1.12",
|
|
@@ -76,63 +76,64 @@ var package_default = {
|
|
|
76
76
|
"@radix-ui/react-slot": "1.2.4",
|
|
77
77
|
"@radix-ui/react-tabs": "1.1.13",
|
|
78
78
|
"@radix-ui/react-tooltip": "1.2.8",
|
|
79
|
+
"@replit/ruspty": "3.6.0",
|
|
79
80
|
"@tailwindcss/vite": "4.1.18",
|
|
80
|
-
"@tanstack/react-devtools": "0.9.
|
|
81
|
-
"@tanstack/react-query": "5.90.
|
|
82
|
-
"@tanstack/react-router": "1.
|
|
83
|
-
"@tanstack/react-router-devtools": "1.
|
|
84
|
-
"@xterm/addon-fit": "0.
|
|
85
|
-
"@xterm/xterm": "
|
|
81
|
+
"@tanstack/react-devtools": "0.9.5",
|
|
82
|
+
"@tanstack/react-query": "5.90.21",
|
|
83
|
+
"@tanstack/react-router": "1.160.0",
|
|
84
|
+
"@tanstack/react-router-devtools": "1.160.0",
|
|
85
|
+
"@xterm/addon-fit": "0.11.0",
|
|
86
|
+
"@xterm/xterm": "6.0.0",
|
|
86
87
|
"class-variance-authority": "0.7.1",
|
|
87
88
|
clsx: "2.1.1",
|
|
88
|
-
cmdk: "
|
|
89
|
-
commander: "
|
|
89
|
+
cmdk: "1.1.1",
|
|
90
|
+
commander: "14.0.3",
|
|
90
91
|
"date-fns": "4.1.0",
|
|
91
|
-
effect: "3.19.
|
|
92
|
+
effect: "3.19.17",
|
|
92
93
|
"es-toolkit": "1.44.0",
|
|
93
|
-
hono: "4.11.
|
|
94
|
-
jotai: "2.
|
|
95
|
-
"lucide-react": "0.
|
|
94
|
+
hono: "4.11.9",
|
|
95
|
+
jotai: "2.17.1",
|
|
96
|
+
"lucide-react": "0.564.0",
|
|
96
97
|
minisearch: "7.2.0",
|
|
97
|
-
"parse-git-diff": "0.0.
|
|
98
|
+
"parse-git-diff": "0.0.20",
|
|
98
99
|
prexit: "2.3.0",
|
|
99
|
-
"radix-ui": "
|
|
100
|
-
react: "19.2.
|
|
101
|
-
"react-dom": "19.2.
|
|
102
|
-
"react-error-boundary": "6.1.
|
|
103
|
-
"react-hook-form": "
|
|
100
|
+
"radix-ui": "1.4.3",
|
|
101
|
+
react: "19.2.4",
|
|
102
|
+
"react-dom": "19.2.4",
|
|
103
|
+
"react-error-boundary": "6.1.1",
|
|
104
|
+
"react-hook-form": "7.71.1",
|
|
104
105
|
"react-markdown": "10.1.0",
|
|
105
106
|
"react-syntax-highlighter": "16.1.0",
|
|
106
107
|
"remark-gfm": "4.0.1",
|
|
107
108
|
sonner: "2.0.7",
|
|
108
|
-
"tailwind-merge": "3.4.
|
|
109
|
+
"tailwind-merge": "3.4.1",
|
|
109
110
|
ulid: "3.0.2",
|
|
110
|
-
|
|
111
|
-
ws: "8.18.3",
|
|
111
|
+
ws: "8.19.0",
|
|
112
112
|
zod: "4.3.6"
|
|
113
113
|
},
|
|
114
114
|
devDependencies: {
|
|
115
|
-
"@biomejs/biome": "2.
|
|
116
|
-
"@effect/language-service": "0.
|
|
117
|
-
"@lingui/cli": "5.9.
|
|
118
|
-
"@lingui/conf": "5.9.
|
|
119
|
-
"@lingui/format-json": "5.9.
|
|
120
|
-
"@lingui/loader": "5.9.
|
|
121
|
-
"@lingui/vite-plugin": "5.9.
|
|
115
|
+
"@biomejs/biome": "2.4.0",
|
|
116
|
+
"@effect/language-service": "0.73.1",
|
|
117
|
+
"@lingui/cli": "5.9.1",
|
|
118
|
+
"@lingui/conf": "5.9.1",
|
|
119
|
+
"@lingui/format-json": "5.9.1",
|
|
120
|
+
"@lingui/loader": "5.9.1",
|
|
121
|
+
"@lingui/vite-plugin": "5.9.1",
|
|
122
122
|
"@tailwindcss/postcss": "4.1.18",
|
|
123
|
-
"@tanstack/router-plugin": "1.
|
|
123
|
+
"@tanstack/router-plugin": "1.160.0",
|
|
124
124
|
"@tsconfig/strictest": "2.0.8",
|
|
125
|
-
"@types/node": "25.
|
|
126
|
-
"@types/react": "19.2.
|
|
125
|
+
"@types/node": "25.2.3",
|
|
126
|
+
"@types/react": "19.2.14",
|
|
127
127
|
"@types/react-dom": "19.2.3",
|
|
128
128
|
"@types/react-syntax-highlighter": "15.5.13",
|
|
129
|
-
"@types/ws": "8.18.
|
|
130
|
-
"@
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
129
|
+
"@types/ws": "8.18.1",
|
|
130
|
+
"@typescript/native-preview": "7.0.0-dev.20260215.1",
|
|
131
|
+
"@vitejs/plugin-react-swc": "4.2.3",
|
|
132
|
+
dotenv: "17.3.1",
|
|
133
|
+
esbuild: "0.27.3",
|
|
134
|
+
lefthook: "2.1.1",
|
|
134
135
|
"npm-run-all2": "8.0.4",
|
|
135
|
-
playwright: "1.58.
|
|
136
|
+
playwright: "1.58.2",
|
|
136
137
|
"release-it": "19.2.4",
|
|
137
138
|
"release-it-pnpm": "4.6.6",
|
|
138
139
|
tailwindcss: "4.1.18",
|
|
@@ -238,294 +239,310 @@ import { FileSystem, Path } from "@effect/platform";
|
|
|
238
239
|
import { Context, Effect as Effect2, Layer } from "effect";
|
|
239
240
|
|
|
240
241
|
// src/lib/conversation-schema/index.ts
|
|
241
|
-
import { z as
|
|
242
|
+
import { z as z19 } from "zod";
|
|
243
|
+
|
|
244
|
+
// src/lib/conversation-schema/entry/AgentNameEntrySchema.ts
|
|
245
|
+
import { z } from "zod";
|
|
246
|
+
var AgentNameEntrySchema = z.object({
|
|
247
|
+
type: z.literal("agent-name"),
|
|
248
|
+
agentName: z.string(),
|
|
249
|
+
sessionId: z.string()
|
|
250
|
+
});
|
|
242
251
|
|
|
243
252
|
// src/lib/conversation-schema/entry/AssistantEntrySchema.ts
|
|
244
|
-
import { z as
|
|
253
|
+
import { z as z9 } from "zod";
|
|
245
254
|
|
|
246
255
|
// src/lib/conversation-schema/message/AssistantMessageSchema.ts
|
|
247
|
-
import { z as
|
|
256
|
+
import { z as z7 } from "zod";
|
|
248
257
|
|
|
249
258
|
// src/lib/conversation-schema/content/TextContentSchema.ts
|
|
250
|
-
import { z } from "zod";
|
|
251
|
-
var TextContentSchema =
|
|
252
|
-
type:
|
|
253
|
-
text:
|
|
259
|
+
import { z as z2 } from "zod";
|
|
260
|
+
var TextContentSchema = z2.object({
|
|
261
|
+
type: z2.literal("text"),
|
|
262
|
+
text: z2.string()
|
|
254
263
|
});
|
|
255
264
|
|
|
256
265
|
// src/lib/conversation-schema/content/ThinkingContentSchema.ts
|
|
257
|
-
import { z as
|
|
258
|
-
var ThinkingContentSchema =
|
|
259
|
-
type:
|
|
260
|
-
thinking:
|
|
261
|
-
signature:
|
|
266
|
+
import { z as z3 } from "zod";
|
|
267
|
+
var ThinkingContentSchema = z3.object({
|
|
268
|
+
type: z3.literal("thinking"),
|
|
269
|
+
thinking: z3.string(),
|
|
270
|
+
signature: z3.string().optional()
|
|
262
271
|
});
|
|
263
272
|
|
|
264
273
|
// src/lib/conversation-schema/content/ToolResultContentSchema.ts
|
|
265
|
-
import { z as
|
|
274
|
+
import { z as z5 } from "zod";
|
|
266
275
|
|
|
267
276
|
// src/lib/conversation-schema/content/ImageContentSchema.ts
|
|
268
|
-
import { z as
|
|
269
|
-
var ImageContentSchema =
|
|
270
|
-
type:
|
|
271
|
-
source:
|
|
272
|
-
type:
|
|
273
|
-
data:
|
|
274
|
-
media_type:
|
|
277
|
+
import { z as z4 } from "zod";
|
|
278
|
+
var ImageContentSchema = z4.object({
|
|
279
|
+
type: z4.literal("image"),
|
|
280
|
+
source: z4.object({
|
|
281
|
+
type: z4.literal("base64"),
|
|
282
|
+
data: z4.string(),
|
|
283
|
+
media_type: z4.enum(["image/png", "image/jpeg", "image/gif", "image/webp"])
|
|
275
284
|
})
|
|
276
285
|
});
|
|
277
286
|
|
|
278
287
|
// src/lib/conversation-schema/content/ToolResultContentSchema.ts
|
|
279
|
-
var ToolResultContentSchema =
|
|
280
|
-
type:
|
|
281
|
-
tool_use_id:
|
|
282
|
-
content:
|
|
283
|
-
|
|
284
|
-
|
|
288
|
+
var ToolResultContentSchema = z5.object({
|
|
289
|
+
type: z5.literal("tool_result"),
|
|
290
|
+
tool_use_id: z5.string(),
|
|
291
|
+
content: z5.union([
|
|
292
|
+
z5.string(),
|
|
293
|
+
z5.array(z5.union([TextContentSchema, ImageContentSchema]))
|
|
285
294
|
]),
|
|
286
|
-
is_error:
|
|
295
|
+
is_error: z5.boolean().optional()
|
|
287
296
|
});
|
|
288
297
|
|
|
289
298
|
// src/lib/conversation-schema/content/ToolUseContentSchema.ts
|
|
290
|
-
import { z as
|
|
291
|
-
var ToolUseContentSchema =
|
|
292
|
-
type:
|
|
293
|
-
id:
|
|
294
|
-
name:
|
|
295
|
-
input:
|
|
299
|
+
import { z as z6 } from "zod";
|
|
300
|
+
var ToolUseContentSchema = z6.object({
|
|
301
|
+
type: z6.literal("tool_use"),
|
|
302
|
+
id: z6.string(),
|
|
303
|
+
name: z6.string(),
|
|
304
|
+
input: z6.record(z6.string(), z6.unknown())
|
|
296
305
|
});
|
|
297
306
|
|
|
298
307
|
// src/lib/conversation-schema/message/AssistantMessageSchema.ts
|
|
299
|
-
var AssistantMessageContentSchema =
|
|
308
|
+
var AssistantMessageContentSchema = z7.union([
|
|
300
309
|
ThinkingContentSchema,
|
|
301
310
|
TextContentSchema,
|
|
302
311
|
ToolUseContentSchema,
|
|
303
312
|
ToolResultContentSchema
|
|
304
313
|
]);
|
|
305
|
-
var AssistantMessageSchema =
|
|
306
|
-
id:
|
|
307
|
-
container:
|
|
308
|
-
type:
|
|
309
|
-
role:
|
|
310
|
-
model:
|
|
311
|
-
content:
|
|
312
|
-
stop_reason:
|
|
313
|
-
stop_sequence:
|
|
314
|
-
usage:
|
|
315
|
-
input_tokens:
|
|
316
|
-
cache_creation_input_tokens:
|
|
317
|
-
cache_read_input_tokens:
|
|
318
|
-
cache_creation:
|
|
319
|
-
ephemeral_5m_input_tokens:
|
|
320
|
-
ephemeral_1h_input_tokens:
|
|
314
|
+
var AssistantMessageSchema = z7.object({
|
|
315
|
+
id: z7.string(),
|
|
316
|
+
container: z7.null().optional(),
|
|
317
|
+
type: z7.literal("message"),
|
|
318
|
+
role: z7.literal("assistant"),
|
|
319
|
+
model: z7.string(),
|
|
320
|
+
content: z7.array(AssistantMessageContentSchema),
|
|
321
|
+
stop_reason: z7.string().nullable(),
|
|
322
|
+
stop_sequence: z7.string().nullable(),
|
|
323
|
+
usage: z7.object({
|
|
324
|
+
input_tokens: z7.number(),
|
|
325
|
+
cache_creation_input_tokens: z7.number().optional(),
|
|
326
|
+
cache_read_input_tokens: z7.number().optional(),
|
|
327
|
+
cache_creation: z7.object({
|
|
328
|
+
ephemeral_5m_input_tokens: z7.number(),
|
|
329
|
+
ephemeral_1h_input_tokens: z7.number()
|
|
321
330
|
}).optional(),
|
|
322
|
-
output_tokens:
|
|
323
|
-
service_tier:
|
|
324
|
-
server_tool_use:
|
|
325
|
-
web_search_requests:
|
|
331
|
+
output_tokens: z7.number(),
|
|
332
|
+
service_tier: z7.string().nullable().optional(),
|
|
333
|
+
server_tool_use: z7.object({
|
|
334
|
+
web_search_requests: z7.number()
|
|
326
335
|
}).optional()
|
|
327
336
|
})
|
|
328
337
|
});
|
|
329
338
|
|
|
330
339
|
// src/lib/conversation-schema/entry/BaseEntrySchema.ts
|
|
331
|
-
import { z as
|
|
332
|
-
var BaseEntrySchema =
|
|
340
|
+
import { z as z8 } from "zod";
|
|
341
|
+
var BaseEntrySchema = z8.object({
|
|
333
342
|
// required
|
|
334
|
-
isSidechain:
|
|
335
|
-
userType:
|
|
336
|
-
cwd:
|
|
337
|
-
sessionId:
|
|
338
|
-
version:
|
|
339
|
-
uuid:
|
|
340
|
-
timestamp:
|
|
343
|
+
isSidechain: z8.boolean(),
|
|
344
|
+
userType: z8.enum(["external"]),
|
|
345
|
+
cwd: z8.string(),
|
|
346
|
+
sessionId: z8.string(),
|
|
347
|
+
version: z8.string(),
|
|
348
|
+
uuid: z8.uuid(),
|
|
349
|
+
timestamp: z8.string(),
|
|
341
350
|
// nullable
|
|
342
|
-
parentUuid:
|
|
351
|
+
parentUuid: z8.uuid().nullable(),
|
|
343
352
|
// optional
|
|
344
|
-
isMeta:
|
|
345
|
-
toolUseResult:
|
|
353
|
+
isMeta: z8.boolean().optional(),
|
|
354
|
+
toolUseResult: z8.unknown().optional(),
|
|
346
355
|
// スキーマがツールごとに異なりすぎるし利用もしなそうなので unknown
|
|
347
|
-
gitBranch:
|
|
348
|
-
isCompactSummary:
|
|
349
|
-
agentId:
|
|
356
|
+
gitBranch: z8.string().optional(),
|
|
357
|
+
isCompactSummary: z8.boolean().optional(),
|
|
358
|
+
agentId: z8.string().optional()
|
|
350
359
|
});
|
|
351
360
|
|
|
352
361
|
// src/lib/conversation-schema/entry/AssistantEntrySchema.ts
|
|
353
362
|
var AssistantEntrySchema = BaseEntrySchema.extend({
|
|
354
363
|
// discriminator
|
|
355
|
-
type:
|
|
364
|
+
type: z9.literal("assistant"),
|
|
356
365
|
// required
|
|
357
366
|
message: AssistantMessageSchema,
|
|
358
367
|
// optional
|
|
359
|
-
requestId:
|
|
360
|
-
isApiErrorMessage:
|
|
368
|
+
requestId: z9.string().optional(),
|
|
369
|
+
isApiErrorMessage: z9.boolean().optional()
|
|
370
|
+
});
|
|
371
|
+
|
|
372
|
+
// src/lib/conversation-schema/entry/CustomTitleEntrySchema.ts
|
|
373
|
+
import { z as z10 } from "zod";
|
|
374
|
+
var CustomTitleEntrySchema = z10.object({
|
|
375
|
+
type: z10.literal("custom-title"),
|
|
376
|
+
customTitle: z10.string(),
|
|
377
|
+
sessionId: z10.string()
|
|
361
378
|
});
|
|
362
379
|
|
|
363
380
|
// src/lib/conversation-schema/entry/FileHIstorySnapshotEntrySchema.ts
|
|
364
|
-
import { z as
|
|
365
|
-
var FileHistorySnapshotEntrySchema =
|
|
381
|
+
import { z as z11 } from "zod";
|
|
382
|
+
var FileHistorySnapshotEntrySchema = z11.object({
|
|
366
383
|
// discriminator
|
|
367
|
-
type:
|
|
384
|
+
type: z11.literal("file-history-snapshot"),
|
|
368
385
|
// required
|
|
369
|
-
messageId:
|
|
370
|
-
snapshot:
|
|
371
|
-
messageId:
|
|
372
|
-
trackedFileBackups:
|
|
373
|
-
timestamp:
|
|
386
|
+
messageId: z11.string(),
|
|
387
|
+
snapshot: z11.object({
|
|
388
|
+
messageId: z11.string(),
|
|
389
|
+
trackedFileBackups: z11.record(z11.string(), z11.unknown()),
|
|
390
|
+
timestamp: z11.string()
|
|
374
391
|
}),
|
|
375
|
-
isSnapshotUpdate:
|
|
392
|
+
isSnapshotUpdate: z11.boolean()
|
|
376
393
|
});
|
|
377
394
|
|
|
378
395
|
// src/lib/conversation-schema/entry/ProgressEntrySchema.ts
|
|
379
|
-
import { z as
|
|
396
|
+
import { z as z12 } from "zod";
|
|
380
397
|
var ProgressEntrySchema = BaseEntrySchema.extend({
|
|
381
398
|
// discriminator
|
|
382
|
-
type:
|
|
399
|
+
type: z12.literal("progress"),
|
|
383
400
|
// required
|
|
384
|
-
data:
|
|
385
|
-
toolUseID:
|
|
386
|
-
parentToolUseID:
|
|
401
|
+
data: z12.record(z12.string(), z12.any()),
|
|
402
|
+
toolUseID: z12.string().optional(),
|
|
403
|
+
parentToolUseID: z12.string().optional()
|
|
387
404
|
});
|
|
388
405
|
|
|
389
406
|
// src/lib/conversation-schema/entry/QueueOperationEntrySchema.ts
|
|
390
|
-
import { z as
|
|
407
|
+
import { z as z14 } from "zod";
|
|
391
408
|
|
|
392
409
|
// src/lib/conversation-schema/content/DocumentContentSchema.ts
|
|
393
|
-
import { z as
|
|
394
|
-
var DocumentContentSchema =
|
|
395
|
-
type:
|
|
396
|
-
source:
|
|
397
|
-
|
|
398
|
-
media_type:
|
|
399
|
-
type:
|
|
400
|
-
data:
|
|
410
|
+
import { z as z13 } from "zod";
|
|
411
|
+
var DocumentContentSchema = z13.object({
|
|
412
|
+
type: z13.literal("document"),
|
|
413
|
+
source: z13.union([
|
|
414
|
+
z13.object({
|
|
415
|
+
media_type: z13.literal("text/plain"),
|
|
416
|
+
type: z13.literal("text"),
|
|
417
|
+
data: z13.string()
|
|
401
418
|
}),
|
|
402
|
-
|
|
403
|
-
media_type:
|
|
404
|
-
type:
|
|
405
|
-
data:
|
|
419
|
+
z13.object({
|
|
420
|
+
media_type: z13.enum(["application/pdf"]),
|
|
421
|
+
type: z13.literal("base64"),
|
|
422
|
+
data: z13.string()
|
|
406
423
|
})
|
|
407
424
|
])
|
|
408
425
|
});
|
|
409
426
|
|
|
410
427
|
// src/lib/conversation-schema/entry/QueueOperationEntrySchema.ts
|
|
411
|
-
var QueueOperationContentSchema =
|
|
412
|
-
|
|
428
|
+
var QueueOperationContentSchema = z14.union([
|
|
429
|
+
z14.string(),
|
|
413
430
|
TextContentSchema,
|
|
414
431
|
ToolResultContentSchema,
|
|
415
432
|
ImageContentSchema,
|
|
416
433
|
DocumentContentSchema
|
|
417
434
|
]);
|
|
418
|
-
var QueueOperationEntrySchema =
|
|
419
|
-
|
|
420
|
-
type:
|
|
421
|
-
operation:
|
|
422
|
-
content:
|
|
423
|
-
|
|
424
|
-
|
|
435
|
+
var QueueOperationEntrySchema = z14.union([
|
|
436
|
+
z14.object({
|
|
437
|
+
type: z14.literal("queue-operation"),
|
|
438
|
+
operation: z14.literal("enqueue"),
|
|
439
|
+
content: z14.union([
|
|
440
|
+
z14.string(),
|
|
441
|
+
z14.array(z14.union([z14.string(), QueueOperationContentSchema]))
|
|
425
442
|
]),
|
|
426
|
-
sessionId:
|
|
427
|
-
timestamp:
|
|
443
|
+
sessionId: z14.string(),
|
|
444
|
+
timestamp: z14.iso.datetime()
|
|
428
445
|
}),
|
|
429
|
-
|
|
430
|
-
type:
|
|
431
|
-
operation:
|
|
432
|
-
sessionId:
|
|
433
|
-
timestamp:
|
|
446
|
+
z14.object({
|
|
447
|
+
type: z14.literal("queue-operation"),
|
|
448
|
+
operation: z14.literal("dequeue"),
|
|
449
|
+
sessionId: z14.string(),
|
|
450
|
+
timestamp: z14.iso.datetime()
|
|
434
451
|
}),
|
|
435
|
-
|
|
436
|
-
type:
|
|
437
|
-
operation:
|
|
438
|
-
sessionId:
|
|
439
|
-
timestamp:
|
|
452
|
+
z14.object({
|
|
453
|
+
type: z14.literal("queue-operation"),
|
|
454
|
+
operation: z14.literal("remove"),
|
|
455
|
+
sessionId: z14.string(),
|
|
456
|
+
timestamp: z14.iso.datetime()
|
|
440
457
|
}),
|
|
441
|
-
|
|
442
|
-
type:
|
|
443
|
-
operation:
|
|
444
|
-
sessionId:
|
|
445
|
-
timestamp:
|
|
446
|
-
content:
|
|
458
|
+
z14.object({
|
|
459
|
+
type: z14.literal("queue-operation"),
|
|
460
|
+
operation: z14.literal("popAll"),
|
|
461
|
+
sessionId: z14.string(),
|
|
462
|
+
timestamp: z14.iso.datetime(),
|
|
463
|
+
content: z14.string().optional()
|
|
447
464
|
})
|
|
448
465
|
]);
|
|
449
466
|
|
|
450
467
|
// src/lib/conversation-schema/entry/SummaryEntrySchema.ts
|
|
451
|
-
import { z as
|
|
452
|
-
var SummaryEntrySchema =
|
|
453
|
-
type:
|
|
454
|
-
summary:
|
|
455
|
-
leafUuid:
|
|
468
|
+
import { z as z15 } from "zod";
|
|
469
|
+
var SummaryEntrySchema = z15.object({
|
|
470
|
+
type: z15.literal("summary"),
|
|
471
|
+
summary: z15.string(),
|
|
472
|
+
leafUuid: z15.string().uuid()
|
|
456
473
|
});
|
|
457
474
|
|
|
458
475
|
// src/lib/conversation-schema/entry/SystemEntrySchema.ts
|
|
459
|
-
import { z as
|
|
460
|
-
var HookInfoSchema =
|
|
461
|
-
command:
|
|
476
|
+
import { z as z16 } from "zod";
|
|
477
|
+
var HookInfoSchema = z16.object({
|
|
478
|
+
command: z16.string()
|
|
462
479
|
});
|
|
463
480
|
var SystemEntryWithContentSchema = BaseEntrySchema.extend({
|
|
464
|
-
type:
|
|
465
|
-
content:
|
|
466
|
-
toolUseID:
|
|
467
|
-
level:
|
|
468
|
-
subtype:
|
|
481
|
+
type: z16.literal("system"),
|
|
482
|
+
content: z16.string(),
|
|
483
|
+
toolUseID: z16.string(),
|
|
484
|
+
level: z16.enum(["info"]),
|
|
485
|
+
subtype: z16.undefined().optional()
|
|
469
486
|
});
|
|
470
487
|
var StopHookSummaryEntrySchema = BaseEntrySchema.extend({
|
|
471
|
-
type:
|
|
472
|
-
subtype:
|
|
473
|
-
toolUseID:
|
|
474
|
-
level:
|
|
475
|
-
slug:
|
|
476
|
-
hookCount:
|
|
477
|
-
hookInfos:
|
|
478
|
-
hookErrors:
|
|
479
|
-
preventedContinuation:
|
|
480
|
-
stopReason:
|
|
481
|
-
hasOutput:
|
|
488
|
+
type: z16.literal("system"),
|
|
489
|
+
subtype: z16.literal("stop_hook_summary"),
|
|
490
|
+
toolUseID: z16.string(),
|
|
491
|
+
level: z16.enum(["info", "suggestion"]),
|
|
492
|
+
slug: z16.string().optional(),
|
|
493
|
+
hookCount: z16.number(),
|
|
494
|
+
hookInfos: z16.array(HookInfoSchema),
|
|
495
|
+
hookErrors: z16.array(z16.unknown()),
|
|
496
|
+
preventedContinuation: z16.boolean(),
|
|
497
|
+
stopReason: z16.string(),
|
|
498
|
+
hasOutput: z16.boolean()
|
|
482
499
|
});
|
|
483
500
|
var LocalCommandEntrySchema = BaseEntrySchema.extend({
|
|
484
|
-
type:
|
|
485
|
-
subtype:
|
|
486
|
-
content:
|
|
487
|
-
level:
|
|
501
|
+
type: z16.literal("system"),
|
|
502
|
+
subtype: z16.literal("local_command"),
|
|
503
|
+
content: z16.string(),
|
|
504
|
+
level: z16.enum(["info"])
|
|
488
505
|
});
|
|
489
506
|
var TurnDurationEntrySchema = BaseEntrySchema.extend({
|
|
490
|
-
type:
|
|
491
|
-
subtype:
|
|
492
|
-
durationMs:
|
|
493
|
-
slug:
|
|
507
|
+
type: z16.literal("system"),
|
|
508
|
+
subtype: z16.literal("turn_duration"),
|
|
509
|
+
durationMs: z16.number(),
|
|
510
|
+
slug: z16.string().optional()
|
|
494
511
|
});
|
|
495
512
|
var CompactBoundaryEntrySchema = BaseEntrySchema.extend({
|
|
496
|
-
type:
|
|
497
|
-
subtype:
|
|
498
|
-
content:
|
|
499
|
-
level:
|
|
500
|
-
slug:
|
|
501
|
-
logicalParentUuid:
|
|
502
|
-
compactMetadata:
|
|
503
|
-
trigger:
|
|
504
|
-
preTokens:
|
|
513
|
+
type: z16.literal("system"),
|
|
514
|
+
subtype: z16.literal("compact_boundary"),
|
|
515
|
+
content: z16.string(),
|
|
516
|
+
level: z16.enum(["info"]),
|
|
517
|
+
slug: z16.string().optional(),
|
|
518
|
+
logicalParentUuid: z16.string().optional(),
|
|
519
|
+
compactMetadata: z16.object({
|
|
520
|
+
trigger: z16.string(),
|
|
521
|
+
preTokens: z16.number()
|
|
505
522
|
}).optional()
|
|
506
523
|
});
|
|
507
524
|
var ApiErrorEntrySchema = BaseEntrySchema.extend({
|
|
508
|
-
type:
|
|
509
|
-
subtype:
|
|
510
|
-
level:
|
|
511
|
-
error:
|
|
512
|
-
status:
|
|
513
|
-
headers:
|
|
514
|
-
requestID:
|
|
515
|
-
error:
|
|
516
|
-
type:
|
|
517
|
-
error:
|
|
518
|
-
type:
|
|
519
|
-
message:
|
|
525
|
+
type: z16.literal("system"),
|
|
526
|
+
subtype: z16.literal("api_error"),
|
|
527
|
+
level: z16.enum(["error", "warning", "info"]),
|
|
528
|
+
error: z16.object({
|
|
529
|
+
status: z16.number().optional(),
|
|
530
|
+
headers: z16.record(z16.string(), z16.unknown()).optional(),
|
|
531
|
+
requestID: z16.string().nullable().optional(),
|
|
532
|
+
error: z16.object({
|
|
533
|
+
type: z16.string(),
|
|
534
|
+
error: z16.object({
|
|
535
|
+
type: z16.string(),
|
|
536
|
+
message: z16.string()
|
|
520
537
|
}).optional(),
|
|
521
|
-
message:
|
|
538
|
+
message: z16.string().optional()
|
|
522
539
|
}).optional()
|
|
523
540
|
}),
|
|
524
|
-
retryInMs:
|
|
525
|
-
retryAttempt:
|
|
526
|
-
maxRetries:
|
|
541
|
+
retryInMs: z16.number().optional(),
|
|
542
|
+
retryAttempt: z16.number().optional(),
|
|
543
|
+
maxRetries: z16.number().optional()
|
|
527
544
|
});
|
|
528
|
-
var SystemEntrySchema =
|
|
545
|
+
var SystemEntrySchema = z16.union([
|
|
529
546
|
StopHookSummaryEntrySchema,
|
|
530
547
|
LocalCommandEntrySchema,
|
|
531
548
|
TurnDurationEntrySchema,
|
|
@@ -536,42 +553,44 @@ var SystemEntrySchema = z14.union([
|
|
|
536
553
|
]);
|
|
537
554
|
|
|
538
555
|
// src/lib/conversation-schema/entry/UserEntrySchema.ts
|
|
539
|
-
import { z as
|
|
556
|
+
import { z as z18 } from "zod";
|
|
540
557
|
|
|
541
558
|
// src/lib/conversation-schema/message/UserMessageSchema.ts
|
|
542
|
-
import { z as
|
|
543
|
-
var UserMessageContentSchema =
|
|
544
|
-
|
|
559
|
+
import { z as z17 } from "zod";
|
|
560
|
+
var UserMessageContentSchema = z17.union([
|
|
561
|
+
z17.string(),
|
|
545
562
|
TextContentSchema,
|
|
546
563
|
ToolResultContentSchema,
|
|
547
564
|
ImageContentSchema,
|
|
548
565
|
DocumentContentSchema
|
|
549
566
|
]);
|
|
550
|
-
var UserMessageSchema =
|
|
551
|
-
role:
|
|
552
|
-
content:
|
|
553
|
-
|
|
554
|
-
|
|
567
|
+
var UserMessageSchema = z17.object({
|
|
568
|
+
role: z17.literal("user"),
|
|
569
|
+
content: z17.union([
|
|
570
|
+
z17.string(),
|
|
571
|
+
z17.array(z17.union([z17.string(), UserMessageContentSchema]))
|
|
555
572
|
])
|
|
556
573
|
});
|
|
557
574
|
|
|
558
575
|
// src/lib/conversation-schema/entry/UserEntrySchema.ts
|
|
559
576
|
var UserEntrySchema = BaseEntrySchema.extend({
|
|
560
577
|
// discriminator
|
|
561
|
-
type:
|
|
578
|
+
type: z18.literal("user"),
|
|
562
579
|
// required
|
|
563
580
|
message: UserMessageSchema
|
|
564
581
|
});
|
|
565
582
|
|
|
566
583
|
// src/lib/conversation-schema/index.ts
|
|
567
|
-
var ConversationSchema =
|
|
584
|
+
var ConversationSchema = z19.union([
|
|
568
585
|
UserEntrySchema,
|
|
569
586
|
AssistantEntrySchema,
|
|
570
587
|
SummaryEntrySchema,
|
|
571
588
|
SystemEntrySchema,
|
|
572
589
|
FileHistorySnapshotEntrySchema,
|
|
573
590
|
QueueOperationEntrySchema,
|
|
574
|
-
ProgressEntrySchema
|
|
591
|
+
ProgressEntrySchema,
|
|
592
|
+
CustomTitleEntrySchema,
|
|
593
|
+
AgentNameEntrySchema
|
|
575
594
|
]);
|
|
576
595
|
|
|
577
596
|
// src/server/core/claude-code/functions/parseJsonl.ts
|
|
@@ -603,6 +622,21 @@ var encodeProjectIdFromSessionFilePath = (sessionFilePath) => {
|
|
|
603
622
|
return encodeProjectId(dirname(sessionFilePath));
|
|
604
623
|
};
|
|
605
624
|
|
|
625
|
+
// src/server/core/session/functions/extractFirstUserText.ts
|
|
626
|
+
var extractFirstUserText = (conversation) => {
|
|
627
|
+
if (conversation.type !== "user") {
|
|
628
|
+
return null;
|
|
629
|
+
}
|
|
630
|
+
const firstUserText = typeof conversation.message.content === "string" ? conversation.message.content : (() => {
|
|
631
|
+
const firstContent = conversation.message.content.at(0);
|
|
632
|
+
if (firstContent === void 0) return null;
|
|
633
|
+
if (typeof firstContent === "string") return firstContent;
|
|
634
|
+
if (firstContent.type === "text") return firstContent.text;
|
|
635
|
+
return null;
|
|
636
|
+
})();
|
|
637
|
+
return firstUserText;
|
|
638
|
+
};
|
|
639
|
+
|
|
606
640
|
// src/server/core/agent-session/infrastructure/AgentSessionRepository.ts
|
|
607
641
|
var LayerImpl = Effect2.gen(function* () {
|
|
608
642
|
const fs = yield* FileSystem.FileSystem;
|
|
@@ -630,8 +664,65 @@ var LayerImpl = Effect2.gen(function* () {
|
|
|
630
664
|
const conversations = parseJsonl(content);
|
|
631
665
|
return conversations;
|
|
632
666
|
});
|
|
667
|
+
const listAgentSessionsForSession = (projectId, sessionId) => Effect2.gen(function* () {
|
|
668
|
+
const projectPath = decodeProjectId(projectId);
|
|
669
|
+
const results = [];
|
|
670
|
+
const extractAgentId = (filename) => {
|
|
671
|
+
const match = /^agent-(.+)\.jsonl$/.exec(filename);
|
|
672
|
+
return match ? match[1] ?? null : null;
|
|
673
|
+
};
|
|
674
|
+
const processFile = (filePath, filename) => Effect2.gen(function* () {
|
|
675
|
+
const agentId = extractAgentId(filename);
|
|
676
|
+
if (agentId === null) return;
|
|
677
|
+
const content = yield* fs.readFileString(filePath);
|
|
678
|
+
const firstLine = content.split("\n")[0];
|
|
679
|
+
if (!firstLine || firstLine.trim() === "") return;
|
|
680
|
+
try {
|
|
681
|
+
const conversations = parseJsonl(firstLine);
|
|
682
|
+
const firstConv = conversations[0];
|
|
683
|
+
const firstMessage = firstConv ? extractFirstUserText(firstConv) : null;
|
|
684
|
+
results.push({ agentId, firstMessage });
|
|
685
|
+
} catch {
|
|
686
|
+
results.push({ agentId, firstMessage: null });
|
|
687
|
+
}
|
|
688
|
+
});
|
|
689
|
+
const subagentsDir = path.join(projectPath, sessionId, "subagents");
|
|
690
|
+
const subagentsDirExists = yield* fs.exists(subagentsDir);
|
|
691
|
+
if (subagentsDirExists) {
|
|
692
|
+
const entries = yield* fs.readDirectory(subagentsDir).pipe(Effect2.catchAll(() => Effect2.succeed([])));
|
|
693
|
+
const agentFiles = entries.filter(
|
|
694
|
+
(f) => f.startsWith("agent-") && f.endsWith(".jsonl")
|
|
695
|
+
);
|
|
696
|
+
for (const filename of agentFiles) {
|
|
697
|
+
yield* processFile(path.join(subagentsDir, filename), filename).pipe(
|
|
698
|
+
Effect2.catchAll(() => Effect2.void)
|
|
699
|
+
);
|
|
700
|
+
}
|
|
701
|
+
}
|
|
702
|
+
const rootEntries = yield* fs.readDirectory(projectPath).pipe(Effect2.catchAll(() => Effect2.succeed([])));
|
|
703
|
+
const rootAgentFiles = rootEntries.filter(
|
|
704
|
+
(f) => f.startsWith("agent-") && f.endsWith(".jsonl")
|
|
705
|
+
);
|
|
706
|
+
for (const filename of rootAgentFiles) {
|
|
707
|
+
const filePath = path.join(projectPath, filename);
|
|
708
|
+
const content = yield* fs.readFileString(filePath).pipe(Effect2.catchAll(() => Effect2.succeed("")));
|
|
709
|
+
const firstLine = content.split("\n")[0];
|
|
710
|
+
if (!firstLine || firstLine.trim() === "") continue;
|
|
711
|
+
try {
|
|
712
|
+
const parsed = JSON.parse(firstLine);
|
|
713
|
+
if (typeof parsed === "object" && parsed !== null && "sessionId" in parsed && parsed.sessionId === sessionId) {
|
|
714
|
+
yield* processFile(filePath, filename).pipe(
|
|
715
|
+
Effect2.catchAll(() => Effect2.void)
|
|
716
|
+
);
|
|
717
|
+
}
|
|
718
|
+
} catch {
|
|
719
|
+
}
|
|
720
|
+
}
|
|
721
|
+
return results;
|
|
722
|
+
});
|
|
633
723
|
return {
|
|
634
|
-
getAgentSessionByAgentId
|
|
724
|
+
getAgentSessionByAgentId,
|
|
725
|
+
listAgentSessionsForSession
|
|
635
726
|
};
|
|
636
727
|
});
|
|
637
728
|
var AgentSessionRepository = class extends Context.Tag(
|
|
@@ -670,8 +761,22 @@ var LayerImpl2 = Effect3.gen(function* () {
|
|
|
670
761
|
}
|
|
671
762
|
};
|
|
672
763
|
});
|
|
764
|
+
const listAgentSessions = (params) => Effect3.gen(function* () {
|
|
765
|
+
const { projectId, sessionId } = params;
|
|
766
|
+
const agentSessions = yield* repository.listAgentSessionsForSession(
|
|
767
|
+
projectId,
|
|
768
|
+
sessionId
|
|
769
|
+
);
|
|
770
|
+
return {
|
|
771
|
+
status: 200,
|
|
772
|
+
response: {
|
|
773
|
+
agentSessions
|
|
774
|
+
}
|
|
775
|
+
};
|
|
776
|
+
});
|
|
673
777
|
return {
|
|
674
|
-
getAgentSession
|
|
778
|
+
getAgentSession,
|
|
779
|
+
listAgentSessions
|
|
675
780
|
};
|
|
676
781
|
});
|
|
677
782
|
var AgentSessionController = class extends Context2.Tag(
|
|
@@ -719,7 +824,8 @@ var LayerImpl3 = Effect4.gen(function* () {
|
|
|
719
824
|
claudeDir: cliOptions.claudeDir ?? getOptionalEnv2("CCV_GLOBAL_CLAUDE_DIR"),
|
|
720
825
|
terminalDisabled: cliOptions.terminalDisabled ?? (isFlagEnabled(getOptionalEnv2("CCV_TERMINAL_DISABLED")) ? true : void 0),
|
|
721
826
|
terminalShell: cliOptions.terminalShell ?? getOptionalEnv2("CCV_TERMINAL_SHELL") ?? void 0,
|
|
722
|
-
terminalUnrestricted: cliOptions.terminalUnrestricted ?? (isFlagEnabled(getOptionalEnv2("CCV_TERMINAL_UNRESTRICTED")) ? true : void 0)
|
|
827
|
+
terminalUnrestricted: cliOptions.terminalUnrestricted ?? (isFlagEnabled(getOptionalEnv2("CCV_TERMINAL_UNRESTRICTED")) ? true : void 0),
|
|
828
|
+
apiOnly: cliOptions.apiOnly ?? (isFlagEnabled(getOptionalEnv2("CCV_API_ONLY")) ? true : void 0)
|
|
723
829
|
};
|
|
724
830
|
});
|
|
725
831
|
});
|
|
@@ -784,7 +890,7 @@ import { Context as Context7, Effect as Effect9, Layer as Layer9, Option as Opti
|
|
|
784
890
|
// src/server/core/project/services/ProjectMetaService.ts
|
|
785
891
|
import { FileSystem as FileSystem3, Path as Path4 } from "@effect/platform";
|
|
786
892
|
import { Context as Context6, Effect as Effect8, Layer as Layer8, Option, Ref as Ref3 } from "effect";
|
|
787
|
-
import { z as
|
|
893
|
+
import { z as z21 } from "zod";
|
|
788
894
|
|
|
789
895
|
// src/server/lib/storage/FileCacheStorage/index.ts
|
|
790
896
|
import { Context as Context5, Effect as Effect7, Layer as Layer7, Ref as Ref2, Runtime } from "effect";
|
|
@@ -792,7 +898,7 @@ import { Context as Context5, Effect as Effect7, Layer as Layer7, Ref as Ref2, R
|
|
|
792
898
|
// src/server/lib/storage/FileCacheStorage/PersistentService.ts
|
|
793
899
|
import { FileSystem as FileSystem2, Path as Path3 } from "@effect/platform";
|
|
794
900
|
import { Context as Context4, Effect as Effect6, Layer as Layer6 } from "effect";
|
|
795
|
-
import { z as
|
|
901
|
+
import { z as z20 } from "zod";
|
|
796
902
|
|
|
797
903
|
// src/server/lib/config/paths.ts
|
|
798
904
|
import { homedir as homedir2 } from "node:os";
|
|
@@ -804,7 +910,7 @@ var claudeCodeViewerCacheDirPath = resolve(
|
|
|
804
910
|
);
|
|
805
911
|
|
|
806
912
|
// src/server/lib/storage/FileCacheStorage/PersistentService.ts
|
|
807
|
-
var saveSchema =
|
|
913
|
+
var saveSchema = z20.array(z20.tuple([z20.string(), z20.unknown()]));
|
|
808
914
|
var LayerImpl5 = Effect6.gen(function* () {
|
|
809
915
|
const path = yield* Path3.Path;
|
|
810
916
|
const getCacheFilePath = (key) => path.resolve(claudeCodeViewerCacheDirPath, `${key}.json`);
|
|
@@ -917,7 +1023,7 @@ var makeFileCacheStorageLayer = (storageKey, schema) => Layer7.effect(
|
|
|
917
1023
|
);
|
|
918
1024
|
|
|
919
1025
|
// src/server/core/project/services/ProjectMetaService.ts
|
|
920
|
-
var ProjectPathSchema =
|
|
1026
|
+
var ProjectPathSchema = z21.string().nullable();
|
|
921
1027
|
var LayerImpl6 = Effect8.gen(function* () {
|
|
922
1028
|
const fs = yield* FileSystem3.FileSystem;
|
|
923
1029
|
const path = yield* Path4.Path;
|
|
@@ -933,7 +1039,7 @@ var LayerImpl6 = Effect8.gen(function* () {
|
|
|
933
1039
|
let cwd = null;
|
|
934
1040
|
for (const line of lines) {
|
|
935
1041
|
const conversation = parseJsonl(line).at(0);
|
|
936
|
-
if (conversation === void 0 || conversation.type === "summary" || conversation.type === "x-error" || conversation.type === "file-history-snapshot" || conversation.type === "queue-operation") {
|
|
1042
|
+
if (conversation === void 0 || conversation.type === "summary" || conversation.type === "x-error" || conversation.type === "file-history-snapshot" || conversation.type === "queue-operation" || conversation.type === "custom-title" || conversation.type === "agent-name") {
|
|
937
1043
|
continue;
|
|
938
1044
|
}
|
|
939
1045
|
cwd = conversation.cwd;
|
|
@@ -1200,12 +1306,12 @@ var scanSkillFilesWithMetadata = (dirPath) => Effect10.gen(function* () {
|
|
|
1200
1306
|
});
|
|
1201
1307
|
|
|
1202
1308
|
// src/server/core/claude-code/models/ClaudeCodeVersion.ts
|
|
1203
|
-
import { z as
|
|
1309
|
+
import { z as z22 } from "zod";
|
|
1204
1310
|
var versionRegex = /^(?<major>\d+)\.(?<minor>\d+)\.(?<patch>\d+)/;
|
|
1205
|
-
var versionSchema =
|
|
1206
|
-
major:
|
|
1207
|
-
minor:
|
|
1208
|
-
patch:
|
|
1311
|
+
var versionSchema = z22.object({
|
|
1312
|
+
major: z22.string().transform((value) => Number.parseInt(value, 10)),
|
|
1313
|
+
minor: z22.string().transform((value) => Number.parseInt(value, 10)),
|
|
1314
|
+
patch: z22.string().transform((value) => Number.parseInt(value, 10))
|
|
1209
1315
|
}).refine(
|
|
1210
1316
|
(data) => [data.major, data.minor, data.patch].every((value) => !Number.isNaN(value))
|
|
1211
1317
|
);
|
|
@@ -1868,26 +1974,26 @@ import { FileSystem as FileSystem9, Path as Path11 } from "@effect/platform";
|
|
|
1868
1974
|
import { Context as Context16, Effect as Effect21, Layer as Layer18, Option as Option3 } from "effect";
|
|
1869
1975
|
|
|
1870
1976
|
// src/server/core/claude-code/functions/parseUserMessage.ts
|
|
1871
|
-
import { z as
|
|
1977
|
+
import { z as z23 } from "zod";
|
|
1872
1978
|
var regExp = /<(?<tag>[^>]+)>(?<content>[\s\S]*?)<\/\k<tag>>/g;
|
|
1873
|
-
var matchSchema =
|
|
1874
|
-
tag:
|
|
1875
|
-
content:
|
|
1979
|
+
var matchSchema = z23.object({
|
|
1980
|
+
tag: z23.string(),
|
|
1981
|
+
content: z23.string()
|
|
1876
1982
|
});
|
|
1877
|
-
var parsedUserMessageSchema =
|
|
1878
|
-
|
|
1879
|
-
kind:
|
|
1880
|
-
commandName:
|
|
1881
|
-
commandArgs:
|
|
1882
|
-
commandMessage:
|
|
1983
|
+
var parsedUserMessageSchema = z23.union([
|
|
1984
|
+
z23.object({
|
|
1985
|
+
kind: z23.literal("command"),
|
|
1986
|
+
commandName: z23.string(),
|
|
1987
|
+
commandArgs: z23.string().optional(),
|
|
1988
|
+
commandMessage: z23.string().optional()
|
|
1883
1989
|
}),
|
|
1884
|
-
|
|
1885
|
-
kind:
|
|
1886
|
-
stdout:
|
|
1990
|
+
z23.object({
|
|
1991
|
+
kind: z23.literal("local-command"),
|
|
1992
|
+
stdout: z23.string()
|
|
1887
1993
|
}),
|
|
1888
|
-
|
|
1889
|
-
kind:
|
|
1890
|
-
content:
|
|
1994
|
+
z23.object({
|
|
1995
|
+
kind: z23.literal("text"),
|
|
1996
|
+
content: z23.string()
|
|
1891
1997
|
})
|
|
1892
1998
|
]);
|
|
1893
1999
|
var parseUserMessage = (content) => {
|
|
@@ -2232,21 +2338,6 @@ var getAgentSessionFilesForSession = (projectPath, sessionId) => Effect19.gen(fu
|
|
|
2232
2338
|
return matchingFilePaths;
|
|
2233
2339
|
});
|
|
2234
2340
|
|
|
2235
|
-
// src/server/core/session/functions/extractFirstUserText.ts
|
|
2236
|
-
var extractFirstUserText = (conversation) => {
|
|
2237
|
-
if (conversation.type !== "user") {
|
|
2238
|
-
return null;
|
|
2239
|
-
}
|
|
2240
|
-
const firstUserText = typeof conversation.message.content === "string" ? conversation.message.content : (() => {
|
|
2241
|
-
const firstContent = conversation.message.content.at(0);
|
|
2242
|
-
if (firstContent === void 0) return null;
|
|
2243
|
-
if (typeof firstContent === "string") return firstContent;
|
|
2244
|
-
if (firstContent.type === "text") return firstContent.text;
|
|
2245
|
-
return null;
|
|
2246
|
-
})();
|
|
2247
|
-
return firstUserText;
|
|
2248
|
-
};
|
|
2249
|
-
|
|
2250
2341
|
// src/server/core/session/functions/isValidFirstMessage.ts
|
|
2251
2342
|
var ignoreCommands = [
|
|
2252
2343
|
"/clear",
|
|
@@ -2282,6 +2373,9 @@ var extractFirstUserMessage = (conversation) => {
|
|
|
2282
2373
|
if (command.kind === "command" && ignoreCommands.includes(command.commandName)) {
|
|
2283
2374
|
return void 0;
|
|
2284
2375
|
}
|
|
2376
|
+
if (command.kind === "local-command" && command.stdout.trim() === "") {
|
|
2377
|
+
return void 0;
|
|
2378
|
+
}
|
|
2285
2379
|
return command;
|
|
2286
2380
|
};
|
|
2287
2381
|
|
|
@@ -2301,8 +2395,8 @@ var SessionMetaService = class extends Context15.Tag("SessionMetaService")() {
|
|
|
2301
2395
|
const getFirstUserMessage = (jsonlFilePath, lines) => Effect20.gen(function* () {
|
|
2302
2396
|
const cached = yield* firstUserMessageCache.get(jsonlFilePath);
|
|
2303
2397
|
if (cached !== void 0) {
|
|
2304
|
-
|
|
2305
|
-
|
|
2398
|
+
const isStale = cached !== null && (cached.kind === "text" && isLocalCommandCaveat(cached.content) || cached.kind === "local-command" && cached.stdout.trim() === "");
|
|
2399
|
+
if (!isStale) {
|
|
2306
2400
|
return cached;
|
|
2307
2401
|
}
|
|
2308
2402
|
}
|
|
@@ -3679,16 +3773,16 @@ import { Path as Path12 } from "@effect/platform";
|
|
|
3679
3773
|
import { Context as Context22, Effect as Effect28, Layer as Layer24, Ref as Ref9 } from "effect";
|
|
3680
3774
|
|
|
3681
3775
|
// src/server/core/events/functions/parseSessionFilePath.ts
|
|
3682
|
-
import
|
|
3776
|
+
import z24 from "zod";
|
|
3683
3777
|
var sessionFileRegExp = /(?<projectId>.*?)\/(?<sessionId>.*?)\.jsonl$/;
|
|
3684
3778
|
var agentFileRegExp = /(?<projectId>.*?)\/agent-(?<agentSessionId>.*?)\.jsonl$/;
|
|
3685
|
-
var sessionFileGroupSchema =
|
|
3686
|
-
projectId:
|
|
3687
|
-
sessionId:
|
|
3779
|
+
var sessionFileGroupSchema = z24.object({
|
|
3780
|
+
projectId: z24.string(),
|
|
3781
|
+
sessionId: z24.string()
|
|
3688
3782
|
});
|
|
3689
|
-
var agentFileGroupSchema =
|
|
3690
|
-
projectId:
|
|
3691
|
-
agentSessionId:
|
|
3783
|
+
var agentFileGroupSchema = z24.object({
|
|
3784
|
+
projectId: z24.string(),
|
|
3785
|
+
agentSessionId: z24.string()
|
|
3692
3786
|
});
|
|
3693
3787
|
var parseSessionFilePath = (filePath) => {
|
|
3694
3788
|
const agentMatch = filePath.match(agentFileRegExp);
|
|
@@ -4720,16 +4814,16 @@ import { Context as Context26, Data as Data4, Duration, Effect as Effect32, Eith
|
|
|
4720
4814
|
import { Context as Context25, Effect as Effect31, Layer as Layer27, Ref as Ref10 } from "effect";
|
|
4721
4815
|
|
|
4722
4816
|
// src/server/core/platform/schema.ts
|
|
4723
|
-
import { z as
|
|
4724
|
-
var envSchema =
|
|
4817
|
+
import { z as z25 } from "zod";
|
|
4818
|
+
var envSchema = z25.object({
|
|
4725
4819
|
// Frameworks
|
|
4726
|
-
CCV_ENV:
|
|
4727
|
-
NEXT_PHASE:
|
|
4728
|
-
PATH:
|
|
4729
|
-
SHELL:
|
|
4730
|
-
CCV_TERMINAL_SHELL:
|
|
4731
|
-
CCV_TERMINAL_UNRESTRICTED:
|
|
4732
|
-
CCV_TERMINAL_DISABLED:
|
|
4820
|
+
CCV_ENV: z25.enum(["development", "production", "test"]).optional().default("development"),
|
|
4821
|
+
NEXT_PHASE: z25.string().optional(),
|
|
4822
|
+
PATH: z25.string().optional(),
|
|
4823
|
+
SHELL: z25.string().optional(),
|
|
4824
|
+
CCV_TERMINAL_SHELL: z25.string().optional(),
|
|
4825
|
+
CCV_TERMINAL_UNRESTRICTED: z25.string().optional(),
|
|
4826
|
+
CCV_TERMINAL_DISABLED: z25.string().optional()
|
|
4733
4827
|
});
|
|
4734
4828
|
|
|
4735
4829
|
// src/server/core/platform/services/EnvService.ts
|
|
@@ -5686,49 +5780,49 @@ import { FileSystem as FileSystem12, Path as Path16 } from "@effect/platform";
|
|
|
5686
5780
|
import { Context as Context29, Data as Data5, Effect as Effect36, Layer as Layer31 } from "effect";
|
|
5687
5781
|
|
|
5688
5782
|
// src/server/core/scheduler/schema.ts
|
|
5689
|
-
import { z as
|
|
5690
|
-
var concurrencyPolicySchema =
|
|
5691
|
-
var cronScheduleSchema =
|
|
5692
|
-
type:
|
|
5693
|
-
expression:
|
|
5783
|
+
import { z as z26 } from "zod";
|
|
5784
|
+
var concurrencyPolicySchema = z26.enum(["skip", "run"]);
|
|
5785
|
+
var cronScheduleSchema = z26.object({
|
|
5786
|
+
type: z26.literal("cron"),
|
|
5787
|
+
expression: z26.string(),
|
|
5694
5788
|
concurrencyPolicy: concurrencyPolicySchema
|
|
5695
5789
|
});
|
|
5696
|
-
var reservedScheduleSchema =
|
|
5697
|
-
type:
|
|
5698
|
-
reservedExecutionTime:
|
|
5790
|
+
var reservedScheduleSchema = z26.object({
|
|
5791
|
+
type: z26.literal("reserved"),
|
|
5792
|
+
reservedExecutionTime: z26.iso.datetime()
|
|
5699
5793
|
});
|
|
5700
|
-
var scheduleSchema =
|
|
5794
|
+
var scheduleSchema = z26.discriminatedUnion("type", [
|
|
5701
5795
|
cronScheduleSchema,
|
|
5702
5796
|
reservedScheduleSchema
|
|
5703
5797
|
]);
|
|
5704
|
-
var messageConfigSchema =
|
|
5705
|
-
content:
|
|
5706
|
-
projectId:
|
|
5707
|
-
baseSession:
|
|
5708
|
-
|
|
5709
|
-
|
|
5710
|
-
type:
|
|
5711
|
-
sessionId:
|
|
5798
|
+
var messageConfigSchema = z26.object({
|
|
5799
|
+
content: z26.string(),
|
|
5800
|
+
projectId: z26.string(),
|
|
5801
|
+
baseSession: z26.union([
|
|
5802
|
+
z26.null(),
|
|
5803
|
+
z26.object({
|
|
5804
|
+
type: z26.literal("fork"),
|
|
5805
|
+
sessionId: z26.string()
|
|
5712
5806
|
}),
|
|
5713
|
-
|
|
5714
|
-
type:
|
|
5715
|
-
sessionId:
|
|
5807
|
+
z26.object({
|
|
5808
|
+
type: z26.literal("resume"),
|
|
5809
|
+
sessionId: z26.string()
|
|
5716
5810
|
})
|
|
5717
5811
|
])
|
|
5718
5812
|
});
|
|
5719
|
-
var jobStatusSchema =
|
|
5720
|
-
var schedulerJobSchema =
|
|
5721
|
-
id:
|
|
5722
|
-
name:
|
|
5813
|
+
var jobStatusSchema = z26.enum(["success", "failed"]);
|
|
5814
|
+
var schedulerJobSchema = z26.object({
|
|
5815
|
+
id: z26.string(),
|
|
5816
|
+
name: z26.string(),
|
|
5723
5817
|
schedule: scheduleSchema,
|
|
5724
5818
|
message: messageConfigSchema,
|
|
5725
|
-
enabled:
|
|
5726
|
-
createdAt:
|
|
5727
|
-
lastRunAt:
|
|
5819
|
+
enabled: z26.boolean(),
|
|
5820
|
+
createdAt: z26.string().datetime(),
|
|
5821
|
+
lastRunAt: z26.string().datetime().nullable(),
|
|
5728
5822
|
lastRunStatus: jobStatusSchema.nullable()
|
|
5729
5823
|
});
|
|
5730
|
-
var schedulerConfigSchema =
|
|
5731
|
-
jobs:
|
|
5824
|
+
var schedulerConfigSchema = z26.object({
|
|
5825
|
+
jobs: z26.array(schedulerJobSchema)
|
|
5732
5826
|
});
|
|
5733
5827
|
var newSchedulerJobSchema = schedulerJobSchema.omit({
|
|
5734
5828
|
id: true,
|
|
@@ -5736,7 +5830,7 @@ var newSchedulerJobSchema = schedulerJobSchema.omit({
|
|
|
5736
5830
|
lastRunAt: true,
|
|
5737
5831
|
lastRunStatus: true
|
|
5738
5832
|
}).extend({
|
|
5739
|
-
enabled:
|
|
5833
|
+
enabled: z26.boolean().default(true)
|
|
5740
5834
|
});
|
|
5741
5835
|
var updateSchedulerJobSchema = schedulerJobSchema.partial().pick({
|
|
5742
5836
|
name: true,
|
|
@@ -6110,17 +6204,17 @@ var SchedulerService = class extends Context30.Tag("SchedulerService")() {
|
|
|
6110
6204
|
};
|
|
6111
6205
|
|
|
6112
6206
|
// src/server/core/rate-limit/schema.ts
|
|
6113
|
-
import { z as
|
|
6114
|
-
var RateLimitEntrySchema =
|
|
6115
|
-
type:
|
|
6116
|
-
error:
|
|
6117
|
-
isApiErrorMessage:
|
|
6118
|
-
sessionId:
|
|
6119
|
-
message:
|
|
6120
|
-
content:
|
|
6121
|
-
|
|
6122
|
-
type:
|
|
6123
|
-
text:
|
|
6207
|
+
import { z as z27 } from "zod";
|
|
6208
|
+
var RateLimitEntrySchema = z27.object({
|
|
6209
|
+
type: z27.literal("assistant"),
|
|
6210
|
+
error: z27.literal("rate_limit"),
|
|
6211
|
+
isApiErrorMessage: z27.literal(true),
|
|
6212
|
+
sessionId: z27.string(),
|
|
6213
|
+
message: z27.object({
|
|
6214
|
+
content: z27.array(
|
|
6215
|
+
z27.object({
|
|
6216
|
+
type: z27.literal("text"),
|
|
6217
|
+
text: z27.string()
|
|
6124
6218
|
})
|
|
6125
6219
|
)
|
|
6126
6220
|
})
|
|
@@ -6505,6 +6599,12 @@ var extractSearchableText = (conversation) => {
|
|
|
6505
6599
|
if (conversation.type === "assistant") {
|
|
6506
6600
|
return extractAssistantText(conversation);
|
|
6507
6601
|
}
|
|
6602
|
+
if (conversation.type === "custom-title") {
|
|
6603
|
+
return conversation.customTitle;
|
|
6604
|
+
}
|
|
6605
|
+
if (conversation.type === "agent-name") {
|
|
6606
|
+
return null;
|
|
6607
|
+
}
|
|
6508
6608
|
return null;
|
|
6509
6609
|
};
|
|
6510
6610
|
var extractUserText = (entry) => {
|
|
@@ -6972,7 +7072,7 @@ var hasAgentId = (toolUseResult) => {
|
|
|
6972
7072
|
};
|
|
6973
7073
|
var buildSidechainData = (conversations) => {
|
|
6974
7074
|
const sidechainConversations = conversations.filter(
|
|
6975
|
-
(conv) => conv.type !== "summary" && conv.type !== "file-history-snapshot" && conv.type !== "queue-operation" && conv.type !== "progress" && conv.isSidechain === true
|
|
7075
|
+
(conv) => conv.type !== "summary" && conv.type !== "file-history-snapshot" && conv.type !== "queue-operation" && conv.type !== "progress" && conv.type !== "custom-title" && conv.type !== "agent-name" && conv.isSidechain === true
|
|
6976
7076
|
);
|
|
6977
7077
|
const uuidMap = new Map(
|
|
6978
7078
|
sidechainConversations.map((conv) => [conv.uuid, conv])
|
|
@@ -7441,7 +7541,7 @@ var generateSessionHtml = (session, projectId, agentSessionRepo) => Effect44.gen
|
|
|
7441
7541
|
const existingAgentIds = /* @__PURE__ */ new Set();
|
|
7442
7542
|
for (const conv of session.conversations) {
|
|
7443
7543
|
if (conv.type === "x-error") continue;
|
|
7444
|
-
if (conv.type !== "summary" && conv.type !== "file-history-snapshot" && conv.type !== "queue-operation" && conv.type !== "progress" && conv.isSidechain === true && conv.agentId !== void 0) {
|
|
7544
|
+
if (conv.type !== "summary" && conv.type !== "file-history-snapshot" && conv.type !== "queue-operation" && conv.type !== "progress" && conv.type !== "custom-title" && conv.type !== "agent-name" && conv.isSidechain === true && conv.agentId !== void 0) {
|
|
7445
7545
|
existingAgentIds.add(conv.agentId);
|
|
7446
7546
|
}
|
|
7447
7547
|
}
|
|
@@ -8427,40 +8527,40 @@ import { FileSystem as FileSystem17, Path as Path19 } from "@effect/platform";
|
|
|
8427
8527
|
import { Context as Context36, Effect as Effect46, Layer as Layer38, Option as Option4 } from "effect";
|
|
8428
8528
|
|
|
8429
8529
|
// src/server/core/tasks/schema.ts
|
|
8430
|
-
import { z as
|
|
8431
|
-
var TaskStatusSchema =
|
|
8530
|
+
import { z as z28 } from "zod";
|
|
8531
|
+
var TaskStatusSchema = z28.enum([
|
|
8432
8532
|
"pending",
|
|
8433
8533
|
"in_progress",
|
|
8434
8534
|
"completed",
|
|
8435
8535
|
"failed"
|
|
8436
8536
|
]);
|
|
8437
|
-
var TaskSchema =
|
|
8438
|
-
id:
|
|
8439
|
-
subject:
|
|
8440
|
-
description:
|
|
8537
|
+
var TaskSchema = z28.object({
|
|
8538
|
+
id: z28.string(),
|
|
8539
|
+
subject: z28.string(),
|
|
8540
|
+
description: z28.string().optional(),
|
|
8441
8541
|
status: TaskStatusSchema,
|
|
8442
|
-
owner:
|
|
8443
|
-
blocks:
|
|
8444
|
-
blockedBy:
|
|
8445
|
-
metadata:
|
|
8446
|
-
activeForm:
|
|
8542
|
+
owner: z28.string().optional(),
|
|
8543
|
+
blocks: z28.array(z28.string()).optional(),
|
|
8544
|
+
blockedBy: z28.array(z28.string()).optional(),
|
|
8545
|
+
metadata: z28.record(z28.string(), z28.any()).optional(),
|
|
8546
|
+
activeForm: z28.string().optional()
|
|
8447
8547
|
});
|
|
8448
|
-
var TaskCreateSchema =
|
|
8449
|
-
subject:
|
|
8450
|
-
description:
|
|
8451
|
-
activeForm:
|
|
8452
|
-
metadata:
|
|
8548
|
+
var TaskCreateSchema = z28.object({
|
|
8549
|
+
subject: z28.string(),
|
|
8550
|
+
description: z28.string().optional(),
|
|
8551
|
+
activeForm: z28.string().optional(),
|
|
8552
|
+
metadata: z28.record(z28.string(), z28.any()).optional()
|
|
8453
8553
|
});
|
|
8454
|
-
var TaskUpdateSchema =
|
|
8455
|
-
taskId:
|
|
8554
|
+
var TaskUpdateSchema = z28.object({
|
|
8555
|
+
taskId: z28.string(),
|
|
8456
8556
|
status: TaskStatusSchema.optional(),
|
|
8457
|
-
subject:
|
|
8458
|
-
description:
|
|
8459
|
-
activeForm:
|
|
8460
|
-
owner:
|
|
8461
|
-
addBlockedBy:
|
|
8462
|
-
addBlocks:
|
|
8463
|
-
metadata:
|
|
8557
|
+
subject: z28.string().optional(),
|
|
8558
|
+
description: z28.string().optional(),
|
|
8559
|
+
activeForm: z28.string().optional(),
|
|
8560
|
+
owner: z28.string().optional(),
|
|
8561
|
+
addBlockedBy: z28.array(z28.string()).optional(),
|
|
8562
|
+
addBlocks: z28.array(z28.string()).optional(),
|
|
8563
|
+
metadata: z28.record(z28.string(), z28.any()).optional()
|
|
8464
8564
|
});
|
|
8465
8565
|
|
|
8466
8566
|
// src/server/core/tasks/services/TasksService.ts
|
|
@@ -8758,6 +8858,41 @@ var TasksController = class extends Context37.Tag("TasksController")() {
|
|
|
8758
8858
|
// src/server/core/terminal/TerminalService.ts
|
|
8759
8859
|
import { Context as Context38, Effect as Effect48, Layer as Layer40 } from "effect";
|
|
8760
8860
|
import { ulid as ulid5 } from "ulid";
|
|
8861
|
+
|
|
8862
|
+
// src/server/core/terminal/normalizePtyChunk.ts
|
|
8863
|
+
var normalizePtyChunk = (chunk) => {
|
|
8864
|
+
if (typeof chunk === "string") {
|
|
8865
|
+
return chunk;
|
|
8866
|
+
}
|
|
8867
|
+
if (chunk instanceof Uint8Array) {
|
|
8868
|
+
return Buffer.from(chunk).toString("utf8");
|
|
8869
|
+
}
|
|
8870
|
+
if (chunk instanceof ArrayBuffer) {
|
|
8871
|
+
return Buffer.from(chunk).toString("utf8");
|
|
8872
|
+
}
|
|
8873
|
+
return null;
|
|
8874
|
+
};
|
|
8875
|
+
|
|
8876
|
+
// src/server/core/terminal/rusptyAdapter.ts
|
|
8877
|
+
var createRusptySession = (ruspty, options) => {
|
|
8878
|
+
const pty = new ruspty.Pty(options);
|
|
8879
|
+
return {
|
|
8880
|
+
process: {
|
|
8881
|
+
write: (data) => {
|
|
8882
|
+
pty.write.write(data);
|
|
8883
|
+
},
|
|
8884
|
+
resize: (cols, rows) => {
|
|
8885
|
+
pty.resize({ cols, rows });
|
|
8886
|
+
},
|
|
8887
|
+
kill: () => {
|
|
8888
|
+
pty.close();
|
|
8889
|
+
}
|
|
8890
|
+
},
|
|
8891
|
+
read: pty.read
|
|
8892
|
+
};
|
|
8893
|
+
};
|
|
8894
|
+
|
|
8895
|
+
// src/server/core/terminal/TerminalService.ts
|
|
8761
8896
|
var DEFAULT_COLS = 80;
|
|
8762
8897
|
var DEFAULT_ROWS = 24;
|
|
8763
8898
|
var MAX_BUFFER_BYTES = 1024 * 1024 * 2;
|
|
@@ -8794,9 +8929,9 @@ var LayerImpl30 = Effect48.gen(function* () {
|
|
|
8794
8929
|
snapshotSince: () => Effect48.succeed(void 0)
|
|
8795
8930
|
};
|
|
8796
8931
|
};
|
|
8797
|
-
const
|
|
8798
|
-
try: () => import("
|
|
8799
|
-
catch: (error) => new Error(`Failed to load
|
|
8932
|
+
const ruspty = yield* Effect48.tryPromise({
|
|
8933
|
+
try: () => import("@replit/ruspty"),
|
|
8934
|
+
catch: (error) => new Error(`Failed to load @replit/ruspty: ${String(error)}`)
|
|
8800
8935
|
}).pipe(
|
|
8801
8936
|
Effect48.catchAll(
|
|
8802
8937
|
(error) => Effect48.sync(() => {
|
|
@@ -8805,10 +8940,9 @@ var LayerImpl30 = Effect48.gen(function* () {
|
|
|
8805
8940
|
})
|
|
8806
8941
|
)
|
|
8807
8942
|
);
|
|
8808
|
-
if (!
|
|
8809
|
-
return disabledService("
|
|
8943
|
+
if (!ruspty) {
|
|
8944
|
+
return disabledService("@replit/ruspty failed to load");
|
|
8810
8945
|
}
|
|
8811
|
-
const { spawn } = nodePty;
|
|
8812
8946
|
const trimBuffer = (session) => {
|
|
8813
8947
|
while (session.bufferBytes > MAX_BUFFER_BYTES && session.buffer.length > 0) {
|
|
8814
8948
|
const removed = session.buffer.shift();
|
|
@@ -8864,16 +8998,26 @@ var LayerImpl30 = Effect48.gen(function* () {
|
|
|
8864
8998
|
options.fallbackShell,
|
|
8865
8999
|
options.unrestrictedFlag
|
|
8866
9000
|
);
|
|
8867
|
-
const
|
|
8868
|
-
|
|
8869
|
-
|
|
8870
|
-
|
|
8871
|
-
|
|
8872
|
-
|
|
9001
|
+
const { process: ptyProcess, read } = createRusptySession(ruspty, {
|
|
9002
|
+
command: shell.command,
|
|
9003
|
+
args: shell.args,
|
|
9004
|
+
envs: options.env,
|
|
9005
|
+
dir: options.cwd,
|
|
9006
|
+
size: { cols: DEFAULT_COLS, rows: DEFAULT_ROWS },
|
|
9007
|
+
onExit: (_error, exitCode) => {
|
|
9008
|
+
const current = sessions.get(id);
|
|
9009
|
+
if (!current) return;
|
|
9010
|
+
current.exited = true;
|
|
9011
|
+
current.lastActivity = Date.now();
|
|
9012
|
+
broadcast(current, { type: "exit", code: exitCode });
|
|
9013
|
+
if (current.clients.size === 0) {
|
|
9014
|
+
destroySession(current.id);
|
|
9015
|
+
}
|
|
9016
|
+
}
|
|
8873
9017
|
});
|
|
8874
9018
|
const session = {
|
|
8875
9019
|
id,
|
|
8876
|
-
pty,
|
|
9020
|
+
pty: ptyProcess,
|
|
8877
9021
|
seq: 0,
|
|
8878
9022
|
buffer: [],
|
|
8879
9023
|
bufferBytes: 0,
|
|
@@ -8882,27 +9026,22 @@ var LayerImpl30 = Effect48.gen(function* () {
|
|
|
8882
9026
|
exited: false,
|
|
8883
9027
|
inputBuffer: ""
|
|
8884
9028
|
};
|
|
8885
|
-
|
|
8886
|
-
|
|
8887
|
-
|
|
8888
|
-
session.
|
|
8889
|
-
|
|
8890
|
-
|
|
8891
|
-
|
|
8892
|
-
|
|
9029
|
+
read.on("data", (chunk) => {
|
|
9030
|
+
const data = normalizePtyChunk(chunk);
|
|
9031
|
+
if (data === null) return;
|
|
9032
|
+
const current = sessions.get(session.id);
|
|
9033
|
+
if (!current || current.exited) return;
|
|
9034
|
+
current.lastActivity = Date.now();
|
|
9035
|
+
current.seq += 1;
|
|
9036
|
+
current.buffer.push({ seq: current.seq, data });
|
|
9037
|
+
current.bufferBytes += Buffer.byteLength(data, "utf8");
|
|
9038
|
+
trimBuffer(current);
|
|
9039
|
+
broadcast(current, {
|
|
8893
9040
|
type: "output",
|
|
8894
|
-
seq:
|
|
9041
|
+
seq: current.seq,
|
|
8895
9042
|
data
|
|
8896
9043
|
});
|
|
8897
9044
|
});
|
|
8898
|
-
pty.onExit((event) => {
|
|
8899
|
-
session.exited = true;
|
|
8900
|
-
session.lastActivity = Date.now();
|
|
8901
|
-
broadcast(session, { type: "exit", code: event.exitCode });
|
|
8902
|
-
if (session.clients.size === 0) {
|
|
8903
|
-
destroySession(session.id);
|
|
8904
|
-
}
|
|
8905
|
-
});
|
|
8906
9045
|
sessions.set(id, session);
|
|
8907
9046
|
return session;
|
|
8908
9047
|
};
|
|
@@ -9139,7 +9278,15 @@ var generateSessionToken = (password) => {
|
|
|
9139
9278
|
if (!password) return "";
|
|
9140
9279
|
return Buffer.from(`ccv-session:${password}`).toString("base64");
|
|
9141
9280
|
};
|
|
9142
|
-
var
|
|
9281
|
+
var getBearerToken = (authorization) => {
|
|
9282
|
+
if (!authorization) return void 0;
|
|
9283
|
+
const [scheme, token] = authorization.split(" ");
|
|
9284
|
+
if (!scheme || !token) return void 0;
|
|
9285
|
+
if (scheme.toLowerCase() !== "bearer") return void 0;
|
|
9286
|
+
const trimmedToken = token.trim();
|
|
9287
|
+
return trimmedToken.length > 0 ? trimmedToken : void 0;
|
|
9288
|
+
};
|
|
9289
|
+
var createAuthRequiredMiddleware = (authEnabled, validSessionToken, authPassword) => {
|
|
9143
9290
|
return createMiddleware(async (c, next) => {
|
|
9144
9291
|
if (!c.req.path.startsWith("/api")) {
|
|
9145
9292
|
return next();
|
|
@@ -9148,7 +9295,10 @@ var createAuthRequiredMiddleware = (authEnabled, validSessionToken) => {
|
|
|
9148
9295
|
return next();
|
|
9149
9296
|
}
|
|
9150
9297
|
const sessionToken = getCookie(c, "ccv-session");
|
|
9151
|
-
|
|
9298
|
+
const bearerToken = getBearerToken(c.req.header("Authorization"));
|
|
9299
|
+
const cookieAuthorized = sessionToken === validSessionToken;
|
|
9300
|
+
const bearerAuthorized = authPassword !== void 0 && bearerToken === authPassword;
|
|
9301
|
+
if (!cookieAuthorized && !bearerAuthorized) {
|
|
9152
9302
|
return c.json({ error: "Unauthorized" }, 401);
|
|
9153
9303
|
}
|
|
9154
9304
|
await next();
|
|
@@ -9170,11 +9320,12 @@ var LayerImpl31 = Effect50.gen(function* () {
|
|
|
9170
9320
|
if (!c.req.path.startsWith("/api")) {
|
|
9171
9321
|
return next();
|
|
9172
9322
|
}
|
|
9173
|
-
const { authEnabled, validSessionToken } = await runPromise(getAuthState);
|
|
9174
|
-
return createAuthRequiredMiddleware(
|
|
9175
|
-
|
|
9176
|
-
|
|
9177
|
-
|
|
9323
|
+
const { authEnabled, validSessionToken, authPassword } = await runPromise(getAuthState);
|
|
9324
|
+
return createAuthRequiredMiddleware(
|
|
9325
|
+
authEnabled,
|
|
9326
|
+
validSessionToken,
|
|
9327
|
+
authPassword
|
|
9328
|
+
)(c, next);
|
|
9178
9329
|
}
|
|
9179
9330
|
);
|
|
9180
9331
|
return {
|
|
@@ -9193,25 +9344,26 @@ var AuthMiddleware = class extends Context40.Tag("AuthMiddleware")() {
|
|
|
9193
9344
|
import { zValidator as zValidator8 } from "@hono/zod-validator";
|
|
9194
9345
|
import { Effect as Effect62, Runtime as Runtime5 } from "effect";
|
|
9195
9346
|
import { setCookie as setCookie3 } from "hono/cookie";
|
|
9347
|
+
import { createMiddleware as createMiddleware3 } from "hono/factory";
|
|
9196
9348
|
import prexit from "prexit";
|
|
9197
9349
|
|
|
9198
9350
|
// src/server/lib/config/config.ts
|
|
9199
|
-
import
|
|
9351
|
+
import z30 from "zod";
|
|
9200
9352
|
|
|
9201
9353
|
// src/lib/i18n/schema.ts
|
|
9202
|
-
import
|
|
9203
|
-
var localeSchema =
|
|
9354
|
+
import z29 from "zod";
|
|
9355
|
+
var localeSchema = z29.enum(["ja", "en", "zh_CN"]);
|
|
9204
9356
|
|
|
9205
9357
|
// src/server/lib/config/config.ts
|
|
9206
|
-
var userConfigSchema =
|
|
9207
|
-
hideNoUserMessageSession:
|
|
9208
|
-
unifySameTitleSession:
|
|
9209
|
-
enterKeyBehavior:
|
|
9210
|
-
permissionMode:
|
|
9358
|
+
var userConfigSchema = z30.object({
|
|
9359
|
+
hideNoUserMessageSession: z30.boolean().optional().default(true),
|
|
9360
|
+
unifySameTitleSession: z30.boolean().optional().default(false),
|
|
9361
|
+
enterKeyBehavior: z30.enum(["shift-enter-send", "enter-send", "command-enter-send"]).optional().default("shift-enter-send"),
|
|
9362
|
+
permissionMode: z30.enum(["acceptEdits", "bypassPermissions", "default", "plan"]).optional().default("default"),
|
|
9211
9363
|
locale: localeSchema.optional().default("en"),
|
|
9212
|
-
theme:
|
|
9213
|
-
searchHotkey:
|
|
9214
|
-
autoScheduleContinueOnRateLimit:
|
|
9364
|
+
theme: z30.enum(["light", "dark", "system"]).optional().default("system"),
|
|
9365
|
+
searchHotkey: z30.enum(["ctrl-k", "command-k"]).optional().default("command-k"),
|
|
9366
|
+
autoScheduleContinueOnRateLimit: z30.boolean().optional().default(false)
|
|
9215
9367
|
});
|
|
9216
9368
|
var defaultUserConfig = userConfigSchema.parse({});
|
|
9217
9369
|
|
|
@@ -9261,13 +9413,13 @@ import { zValidator } from "@hono/zod-validator";
|
|
|
9261
9413
|
import { Effect as Effect52 } from "effect";
|
|
9262
9414
|
import { Hono as Hono2 } from "hono";
|
|
9263
9415
|
import { deleteCookie, getCookie as getCookie3, setCookie as setCookie2 } from "hono/cookie";
|
|
9264
|
-
import { z as
|
|
9416
|
+
import { z as z31 } from "zod";
|
|
9265
9417
|
var authRoutes = Effect52.gen(function* () {
|
|
9266
9418
|
const { getAuthState } = yield* AuthMiddleware;
|
|
9267
9419
|
const { validSessionToken, authEnabled, authPassword } = yield* getAuthState;
|
|
9268
9420
|
return new Hono2().post(
|
|
9269
9421
|
"/login",
|
|
9270
|
-
zValidator("json",
|
|
9422
|
+
zValidator("json", z31.object({ password: z31.string() })),
|
|
9271
9423
|
async (c) => {
|
|
9272
9424
|
const { password } = c.req.valid("json");
|
|
9273
9425
|
if (!authEnabled) {
|
|
@@ -9306,75 +9458,75 @@ var authRoutes = Effect52.gen(function* () {
|
|
|
9306
9458
|
import { zValidator as zValidator2 } from "@hono/zod-validator";
|
|
9307
9459
|
import { Effect as Effect54 } from "effect";
|
|
9308
9460
|
import { Hono as Hono3 } from "hono";
|
|
9309
|
-
import { z as
|
|
9461
|
+
import { z as z33 } from "zod";
|
|
9310
9462
|
|
|
9311
9463
|
// src/server/core/claude-code/schema.ts
|
|
9312
|
-
import { z as
|
|
9313
|
-
var mediaTypeSchema =
|
|
9464
|
+
import { z as z32 } from "zod";
|
|
9465
|
+
var mediaTypeSchema = z32.enum([
|
|
9314
9466
|
"image/png",
|
|
9315
9467
|
"image/jpeg",
|
|
9316
9468
|
"image/gif",
|
|
9317
9469
|
"image/webp"
|
|
9318
9470
|
]);
|
|
9319
|
-
var imageBlockSchema =
|
|
9320
|
-
type:
|
|
9321
|
-
source:
|
|
9322
|
-
type:
|
|
9471
|
+
var imageBlockSchema = z32.object({
|
|
9472
|
+
type: z32.literal("image"),
|
|
9473
|
+
source: z32.object({
|
|
9474
|
+
type: z32.literal("base64"),
|
|
9323
9475
|
media_type: mediaTypeSchema,
|
|
9324
|
-
data:
|
|
9476
|
+
data: z32.string()
|
|
9325
9477
|
})
|
|
9326
9478
|
});
|
|
9327
|
-
var documentBlockSchema =
|
|
9328
|
-
type:
|
|
9329
|
-
source:
|
|
9330
|
-
|
|
9331
|
-
type:
|
|
9332
|
-
media_type:
|
|
9333
|
-
data:
|
|
9479
|
+
var documentBlockSchema = z32.object({
|
|
9480
|
+
type: z32.literal("document"),
|
|
9481
|
+
source: z32.union([
|
|
9482
|
+
z32.object({
|
|
9483
|
+
type: z32.literal("text"),
|
|
9484
|
+
media_type: z32.enum(["text/plain"]),
|
|
9485
|
+
data: z32.string()
|
|
9334
9486
|
}),
|
|
9335
|
-
|
|
9336
|
-
type:
|
|
9337
|
-
media_type:
|
|
9338
|
-
data:
|
|
9487
|
+
z32.object({
|
|
9488
|
+
type: z32.literal("base64"),
|
|
9489
|
+
media_type: z32.enum(["application/pdf"]),
|
|
9490
|
+
data: z32.string()
|
|
9339
9491
|
})
|
|
9340
9492
|
])
|
|
9341
9493
|
});
|
|
9342
|
-
var userMessageInputSchema =
|
|
9343
|
-
text:
|
|
9344
|
-
images:
|
|
9345
|
-
documents:
|
|
9494
|
+
var userMessageInputSchema = z32.object({
|
|
9495
|
+
text: z32.string().min(1),
|
|
9496
|
+
images: z32.array(imageBlockSchema).optional(),
|
|
9497
|
+
documents: z32.array(documentBlockSchema).optional()
|
|
9346
9498
|
});
|
|
9347
|
-
var sandboxNetworkConfigSchema =
|
|
9348
|
-
allowedDomains:
|
|
9349
|
-
allowUnixSockets:
|
|
9350
|
-
allowAllUnixSockets:
|
|
9351
|
-
allowLocalBinding:
|
|
9352
|
-
httpProxyPort:
|
|
9353
|
-
socksProxyPort:
|
|
9499
|
+
var sandboxNetworkConfigSchema = z32.object({
|
|
9500
|
+
allowedDomains: z32.array(z32.string()).optional(),
|
|
9501
|
+
allowUnixSockets: z32.array(z32.string()).optional(),
|
|
9502
|
+
allowAllUnixSockets: z32.boolean().optional(),
|
|
9503
|
+
allowLocalBinding: z32.boolean().optional(),
|
|
9504
|
+
httpProxyPort: z32.number().optional(),
|
|
9505
|
+
socksProxyPort: z32.number().optional()
|
|
9354
9506
|
});
|
|
9355
|
-
var sandboxSettingsSchema =
|
|
9356
|
-
enabled:
|
|
9357
|
-
autoAllowBashIfSandboxed:
|
|
9358
|
-
allowUnsandboxedCommands:
|
|
9507
|
+
var sandboxSettingsSchema = z32.object({
|
|
9508
|
+
enabled: z32.boolean().optional(),
|
|
9509
|
+
autoAllowBashIfSandboxed: z32.boolean().optional(),
|
|
9510
|
+
allowUnsandboxedCommands: z32.boolean().optional(),
|
|
9359
9511
|
network: sandboxNetworkConfigSchema.optional()
|
|
9360
9512
|
});
|
|
9361
|
-
var ccOptionsSchema =
|
|
9362
|
-
disallowedTools:
|
|
9363
|
-
settingSources:
|
|
9364
|
-
systemPrompt:
|
|
9365
|
-
|
|
9366
|
-
|
|
9367
|
-
type:
|
|
9368
|
-
preset:
|
|
9369
|
-
append:
|
|
9513
|
+
var ccOptionsSchema = z32.object({
|
|
9514
|
+
disallowedTools: z32.array(z32.string()).optional(),
|
|
9515
|
+
settingSources: z32.array(z32.enum(["user", "project", "local"])).optional(),
|
|
9516
|
+
systemPrompt: z32.union([
|
|
9517
|
+
z32.string(),
|
|
9518
|
+
z32.object({
|
|
9519
|
+
type: z32.literal("preset"),
|
|
9520
|
+
preset: z32.literal("claude_code"),
|
|
9521
|
+
append: z32.string().optional()
|
|
9370
9522
|
})
|
|
9371
9523
|
]).optional(),
|
|
9372
|
-
model:
|
|
9524
|
+
model: z32.string().optional(),
|
|
9373
9525
|
sandbox: sandboxSettingsSchema.optional(),
|
|
9374
|
-
maxTurns:
|
|
9375
|
-
maxThinkingTokens:
|
|
9376
|
-
env:
|
|
9377
|
-
maxBudgetUsd:
|
|
9526
|
+
maxTurns: z32.number().optional(),
|
|
9527
|
+
maxThinkingTokens: z32.number().optional(),
|
|
9528
|
+
env: z32.record(z32.string(), z32.string().optional()).optional(),
|
|
9529
|
+
maxBudgetUsd: z32.number().optional()
|
|
9378
9530
|
});
|
|
9379
9531
|
|
|
9380
9532
|
// src/server/lib/effect/toEffectResponse.ts
|
|
@@ -9434,18 +9586,18 @@ var claudeCodeRoutes = Effect54.gen(function* () {
|
|
|
9434
9586
|
"/session-processes",
|
|
9435
9587
|
zValidator2(
|
|
9436
9588
|
"json",
|
|
9437
|
-
|
|
9438
|
-
projectId:
|
|
9589
|
+
z33.object({
|
|
9590
|
+
projectId: z33.string(),
|
|
9439
9591
|
input: userMessageInputSchema,
|
|
9440
|
-
baseSession:
|
|
9441
|
-
|
|
9442
|
-
|
|
9443
|
-
type:
|
|
9444
|
-
sessionId:
|
|
9592
|
+
baseSession: z33.union([
|
|
9593
|
+
z33.undefined(),
|
|
9594
|
+
z33.object({
|
|
9595
|
+
type: z33.literal("fork"),
|
|
9596
|
+
sessionId: z33.string()
|
|
9445
9597
|
}),
|
|
9446
|
-
|
|
9447
|
-
type:
|
|
9448
|
-
sessionId:
|
|
9598
|
+
z33.object({
|
|
9599
|
+
type: z33.literal("resume"),
|
|
9600
|
+
sessionId: z33.string()
|
|
9449
9601
|
})
|
|
9450
9602
|
]),
|
|
9451
9603
|
ccOptions: ccOptionsSchema.optional()
|
|
@@ -9469,10 +9621,10 @@ var claudeCodeRoutes = Effect54.gen(function* () {
|
|
|
9469
9621
|
"/session-processes/:sessionProcessId/continue",
|
|
9470
9622
|
zValidator2(
|
|
9471
9623
|
"json",
|
|
9472
|
-
|
|
9473
|
-
projectId:
|
|
9624
|
+
z33.object({
|
|
9625
|
+
projectId: z33.string(),
|
|
9474
9626
|
input: userMessageInputSchema,
|
|
9475
|
-
baseSessionId:
|
|
9627
|
+
baseSessionId: z33.string()
|
|
9476
9628
|
})
|
|
9477
9629
|
),
|
|
9478
9630
|
async (c) => {
|
|
@@ -9490,7 +9642,7 @@ var claudeCodeRoutes = Effect54.gen(function* () {
|
|
|
9490
9642
|
}
|
|
9491
9643
|
).post(
|
|
9492
9644
|
"/session-processes/:sessionProcessId/abort",
|
|
9493
|
-
zValidator2("json",
|
|
9645
|
+
zValidator2("json", z33.object({ projectId: z33.string() })),
|
|
9494
9646
|
async (c) => {
|
|
9495
9647
|
const { sessionProcessId } = c.req.param();
|
|
9496
9648
|
void Effect54.runFork(
|
|
@@ -9502,9 +9654,9 @@ var claudeCodeRoutes = Effect54.gen(function* () {
|
|
|
9502
9654
|
"/permission-response",
|
|
9503
9655
|
zValidator2(
|
|
9504
9656
|
"json",
|
|
9505
|
-
|
|
9506
|
-
permissionRequestId:
|
|
9507
|
-
decision:
|
|
9657
|
+
z33.object({
|
|
9658
|
+
permissionRequestId: z33.string(),
|
|
9659
|
+
decision: z33.enum(["allow", "deny"])
|
|
9508
9660
|
})
|
|
9509
9661
|
),
|
|
9510
9662
|
async (c) => {
|
|
@@ -9538,16 +9690,16 @@ var featureFlagRoutes = Effect55.gen(function* () {
|
|
|
9538
9690
|
import { zValidator as zValidator3 } from "@hono/zod-validator";
|
|
9539
9691
|
import { Effect as Effect56 } from "effect";
|
|
9540
9692
|
import { Hono as Hono5 } from "hono";
|
|
9541
|
-
import { z as
|
|
9693
|
+
import { z as z34 } from "zod";
|
|
9542
9694
|
var fileSystemRoutes = Effect56.gen(function* () {
|
|
9543
9695
|
const fileSystemController = yield* FileSystemController;
|
|
9544
9696
|
return new Hono5().get(
|
|
9545
9697
|
"/file-completion",
|
|
9546
9698
|
zValidator3(
|
|
9547
9699
|
"query",
|
|
9548
|
-
|
|
9549
|
-
projectId:
|
|
9550
|
-
basePath:
|
|
9700
|
+
z34.object({
|
|
9701
|
+
projectId: z34.string(),
|
|
9702
|
+
basePath: z34.string().optional().default("/api/")
|
|
9551
9703
|
})
|
|
9552
9704
|
),
|
|
9553
9705
|
async (c) => {
|
|
@@ -9563,9 +9715,9 @@ var fileSystemRoutes = Effect56.gen(function* () {
|
|
|
9563
9715
|
"/directory-browser",
|
|
9564
9716
|
zValidator3(
|
|
9565
9717
|
"query",
|
|
9566
|
-
|
|
9567
|
-
currentPath:
|
|
9568
|
-
showHidden:
|
|
9718
|
+
z34.object({
|
|
9719
|
+
currentPath: z34.string().optional(),
|
|
9720
|
+
showHidden: z34.string().optional().transform((val) => val === "true")
|
|
9569
9721
|
})
|
|
9570
9722
|
),
|
|
9571
9723
|
async (c) => {
|
|
@@ -9584,24 +9736,24 @@ var fileSystemRoutes = Effect56.gen(function* () {
|
|
|
9584
9736
|
import { zValidator as zValidator4 } from "@hono/zod-validator";
|
|
9585
9737
|
import { Effect as Effect57 } from "effect";
|
|
9586
9738
|
import { Hono as Hono6 } from "hono";
|
|
9587
|
-
import { z as
|
|
9739
|
+
import { z as z36 } from "zod";
|
|
9588
9740
|
|
|
9589
9741
|
// src/server/core/git/schema.ts
|
|
9590
|
-
import { z as
|
|
9591
|
-
var CommitRequestSchema =
|
|
9592
|
-
files:
|
|
9593
|
-
message:
|
|
9742
|
+
import { z as z35 } from "zod";
|
|
9743
|
+
var CommitRequestSchema = z35.object({
|
|
9744
|
+
files: z35.array(z35.string().min(1)).min(1),
|
|
9745
|
+
message: z35.string().trim().min(1)
|
|
9594
9746
|
});
|
|
9595
|
-
var CommitResultSuccessSchema =
|
|
9596
|
-
success:
|
|
9597
|
-
commitSha:
|
|
9598
|
-
filesCommitted:
|
|
9599
|
-
message:
|
|
9747
|
+
var CommitResultSuccessSchema = z35.object({
|
|
9748
|
+
success: z35.literal(true),
|
|
9749
|
+
commitSha: z35.string().length(40),
|
|
9750
|
+
filesCommitted: z35.number().int().positive(),
|
|
9751
|
+
message: z35.string()
|
|
9600
9752
|
});
|
|
9601
|
-
var CommitResultErrorSchema =
|
|
9602
|
-
success:
|
|
9603
|
-
error:
|
|
9604
|
-
errorCode:
|
|
9753
|
+
var CommitResultErrorSchema = z35.object({
|
|
9754
|
+
success: z35.literal(false),
|
|
9755
|
+
error: z35.string(),
|
|
9756
|
+
errorCode: z35.enum([
|
|
9605
9757
|
"EMPTY_MESSAGE",
|
|
9606
9758
|
"NO_FILES",
|
|
9607
9759
|
"PROJECT_NOT_FOUND",
|
|
@@ -9609,22 +9761,22 @@ var CommitResultErrorSchema = z33.object({
|
|
|
9609
9761
|
"HOOK_FAILED",
|
|
9610
9762
|
"GIT_COMMAND_ERROR"
|
|
9611
9763
|
]),
|
|
9612
|
-
details:
|
|
9764
|
+
details: z35.string().optional()
|
|
9613
9765
|
});
|
|
9614
|
-
var CommitResultSchema =
|
|
9766
|
+
var CommitResultSchema = z35.discriminatedUnion("success", [
|
|
9615
9767
|
CommitResultSuccessSchema,
|
|
9616
9768
|
CommitResultErrorSchema
|
|
9617
9769
|
]);
|
|
9618
|
-
var PushResultSuccessSchema =
|
|
9619
|
-
success:
|
|
9620
|
-
remote:
|
|
9621
|
-
branch:
|
|
9622
|
-
objectsPushed:
|
|
9770
|
+
var PushResultSuccessSchema = z35.object({
|
|
9771
|
+
success: z35.literal(true),
|
|
9772
|
+
remote: z35.string(),
|
|
9773
|
+
branch: z35.string(),
|
|
9774
|
+
objectsPushed: z35.number().int().optional()
|
|
9623
9775
|
});
|
|
9624
|
-
var PushResultErrorSchema =
|
|
9625
|
-
success:
|
|
9626
|
-
error:
|
|
9627
|
-
errorCode:
|
|
9776
|
+
var PushResultErrorSchema = z35.object({
|
|
9777
|
+
success: z35.literal(false),
|
|
9778
|
+
error: z35.string(),
|
|
9779
|
+
errorCode: z35.enum([
|
|
9628
9780
|
"PROJECT_NOT_FOUND",
|
|
9629
9781
|
"NOT_A_REPOSITORY",
|
|
9630
9782
|
"NO_UPSTREAM",
|
|
@@ -9634,26 +9786,26 @@ var PushResultErrorSchema = z33.object({
|
|
|
9634
9786
|
"TIMEOUT",
|
|
9635
9787
|
"GIT_COMMAND_ERROR"
|
|
9636
9788
|
]),
|
|
9637
|
-
details:
|
|
9789
|
+
details: z35.string().optional()
|
|
9638
9790
|
});
|
|
9639
|
-
var PushResultSchema =
|
|
9791
|
+
var PushResultSchema = z35.discriminatedUnion("success", [
|
|
9640
9792
|
PushResultSuccessSchema,
|
|
9641
9793
|
PushResultErrorSchema
|
|
9642
9794
|
]);
|
|
9643
|
-
var CommitAndPushResultSuccessSchema =
|
|
9644
|
-
success:
|
|
9645
|
-
commitSha:
|
|
9646
|
-
filesCommitted:
|
|
9647
|
-
message:
|
|
9648
|
-
remote:
|
|
9649
|
-
branch:
|
|
9795
|
+
var CommitAndPushResultSuccessSchema = z35.object({
|
|
9796
|
+
success: z35.literal(true),
|
|
9797
|
+
commitSha: z35.string().length(40),
|
|
9798
|
+
filesCommitted: z35.number().int().positive(),
|
|
9799
|
+
message: z35.string(),
|
|
9800
|
+
remote: z35.string(),
|
|
9801
|
+
branch: z35.string()
|
|
9650
9802
|
});
|
|
9651
|
-
var CommitAndPushResultErrorSchema =
|
|
9652
|
-
success:
|
|
9653
|
-
commitSucceeded:
|
|
9654
|
-
commitSha:
|
|
9655
|
-
error:
|
|
9656
|
-
errorCode:
|
|
9803
|
+
var CommitAndPushResultErrorSchema = z35.object({
|
|
9804
|
+
success: z35.literal(false),
|
|
9805
|
+
commitSucceeded: z35.boolean(),
|
|
9806
|
+
commitSha: z35.string().length(40).optional(),
|
|
9807
|
+
error: z35.string(),
|
|
9808
|
+
errorCode: z35.enum([
|
|
9657
9809
|
"EMPTY_MESSAGE",
|
|
9658
9810
|
"NO_FILES",
|
|
9659
9811
|
"PROJECT_NOT_FOUND",
|
|
@@ -9666,9 +9818,9 @@ var CommitAndPushResultErrorSchema = z33.object({
|
|
|
9666
9818
|
"NETWORK_ERROR",
|
|
9667
9819
|
"TIMEOUT"
|
|
9668
9820
|
]),
|
|
9669
|
-
details:
|
|
9821
|
+
details: z35.string().optional()
|
|
9670
9822
|
});
|
|
9671
|
-
var CommitAndPushResultSchema =
|
|
9823
|
+
var CommitAndPushResultSchema = z35.discriminatedUnion("success", [
|
|
9672
9824
|
CommitAndPushResultSuccessSchema,
|
|
9673
9825
|
CommitAndPushResultErrorSchema
|
|
9674
9826
|
]);
|
|
@@ -9690,7 +9842,7 @@ var projectRoutes = Effect57.gen(function* () {
|
|
|
9690
9842
|
return response;
|
|
9691
9843
|
}).get(
|
|
9692
9844
|
"/:projectId",
|
|
9693
|
-
zValidator4("query",
|
|
9845
|
+
zValidator4("query", z36.object({ cursor: z36.string().optional() })),
|
|
9694
9846
|
async (c) => {
|
|
9695
9847
|
const response = await effectToResponse(
|
|
9696
9848
|
c,
|
|
@@ -9705,8 +9857,8 @@ var projectRoutes = Effect57.gen(function* () {
|
|
|
9705
9857
|
"/",
|
|
9706
9858
|
zValidator4(
|
|
9707
9859
|
"json",
|
|
9708
|
-
|
|
9709
|
-
projectPath:
|
|
9860
|
+
z36.object({
|
|
9861
|
+
projectPath: z36.string().min(1, "Project path is required")
|
|
9710
9862
|
})
|
|
9711
9863
|
),
|
|
9712
9864
|
async (c) => {
|
|
@@ -9750,15 +9902,35 @@ var projectRoutes = Effect57.gen(function* () {
|
|
|
9750
9902
|
sessionController.deleteSession({ projectId, sessionId }).pipe(Effect57.provide(runtime))
|
|
9751
9903
|
);
|
|
9752
9904
|
return response;
|
|
9753
|
-
}).get("/:projectId/agent-sessions
|
|
9905
|
+
}).get("/:projectId/sessions/:sessionId/agent-sessions", async (c) => {
|
|
9754
9906
|
const projectId = c.req.param("projectId");
|
|
9755
|
-
const
|
|
9907
|
+
const sessionId = c.req.param("sessionId");
|
|
9756
9908
|
const response = await effectToResponse(
|
|
9757
9909
|
c,
|
|
9758
|
-
agentSessionController.
|
|
9910
|
+
agentSessionController.listAgentSessions({
|
|
9911
|
+
projectId,
|
|
9912
|
+
sessionId
|
|
9913
|
+
})
|
|
9759
9914
|
);
|
|
9760
9915
|
return response;
|
|
9761
|
-
}).get(
|
|
9916
|
+
}).get(
|
|
9917
|
+
"/:projectId/agent-sessions/:agentId",
|
|
9918
|
+
zValidator4("query", z36.object({ sessionId: z36.string().optional() })),
|
|
9919
|
+
async (c) => {
|
|
9920
|
+
const projectId = c.req.param("projectId");
|
|
9921
|
+
const agentId = c.req.param("agentId");
|
|
9922
|
+
const { sessionId } = c.req.valid("query");
|
|
9923
|
+
const response = await effectToResponse(
|
|
9924
|
+
c,
|
|
9925
|
+
agentSessionController.getAgentSession({
|
|
9926
|
+
projectId,
|
|
9927
|
+
agentId,
|
|
9928
|
+
sessionId
|
|
9929
|
+
})
|
|
9930
|
+
);
|
|
9931
|
+
return response;
|
|
9932
|
+
}
|
|
9933
|
+
).get("/:projectId/claude-commands", async (c) => {
|
|
9762
9934
|
const response = await effectToResponse(
|
|
9763
9935
|
c,
|
|
9764
9936
|
claudeCodeController.getClaudeCommands({
|
|
@@ -9778,8 +9950,8 @@ var projectRoutes = Effect57.gen(function* () {
|
|
|
9778
9950
|
"/:projectId/files",
|
|
9779
9951
|
zValidator4(
|
|
9780
9952
|
"query",
|
|
9781
|
-
|
|
9782
|
-
filePath:
|
|
9953
|
+
z36.object({
|
|
9954
|
+
filePath: z36.string().min(1, "filePath is required")
|
|
9783
9955
|
})
|
|
9784
9956
|
),
|
|
9785
9957
|
async (c) => {
|
|
@@ -9807,9 +9979,9 @@ var projectRoutes = Effect57.gen(function* () {
|
|
|
9807
9979
|
"/:projectId/git/diff",
|
|
9808
9980
|
zValidator4(
|
|
9809
9981
|
"json",
|
|
9810
|
-
|
|
9811
|
-
fromRef:
|
|
9812
|
-
toRef:
|
|
9982
|
+
z36.object({
|
|
9983
|
+
fromRef: z36.string().min(1, "fromRef is required"),
|
|
9984
|
+
toRef: z36.string().min(1, "toRef is required")
|
|
9813
9985
|
})
|
|
9814
9986
|
),
|
|
9815
9987
|
async (c) => {
|
|
@@ -9873,8 +10045,8 @@ var projectRoutes = Effect57.gen(function* () {
|
|
|
9873
10045
|
"/:projectId/git/checkout",
|
|
9874
10046
|
zValidator4(
|
|
9875
10047
|
"json",
|
|
9876
|
-
|
|
9877
|
-
branchName:
|
|
10048
|
+
z36.object({
|
|
10049
|
+
branchName: z36.string().min(1, "branchName is required")
|
|
9878
10050
|
})
|
|
9879
10051
|
),
|
|
9880
10052
|
async (c) => {
|
|
@@ -9940,7 +10112,7 @@ var schedulerRoutes = Effect58.gen(function* () {
|
|
|
9940
10112
|
import { zValidator as zValidator6 } from "@hono/zod-validator";
|
|
9941
10113
|
import { Effect as Effect59 } from "effect";
|
|
9942
10114
|
import { Hono as Hono8 } from "hono";
|
|
9943
|
-
import { z as
|
|
10115
|
+
import { z as z37 } from "zod";
|
|
9944
10116
|
var searchRoutes = Effect59.gen(function* () {
|
|
9945
10117
|
const searchController = yield* SearchController;
|
|
9946
10118
|
const runtime = yield* getHonoRuntime;
|
|
@@ -9948,10 +10120,10 @@ var searchRoutes = Effect59.gen(function* () {
|
|
|
9948
10120
|
"/",
|
|
9949
10121
|
zValidator6(
|
|
9950
10122
|
"query",
|
|
9951
|
-
|
|
9952
|
-
q:
|
|
9953
|
-
limit:
|
|
9954
|
-
projectId:
|
|
10123
|
+
z37.object({
|
|
10124
|
+
q: z37.string().min(2),
|
|
10125
|
+
limit: z37.string().optional().transform((val) => val ? parseInt(val, 10) : void 0),
|
|
10126
|
+
projectId: z37.string().optional()
|
|
9955
10127
|
})
|
|
9956
10128
|
),
|
|
9957
10129
|
async (c) => {
|
|
@@ -9972,7 +10144,7 @@ import { streamSSE } from "hono/streaming";
|
|
|
9972
10144
|
var sseRoutes = Effect60.gen(function* () {
|
|
9973
10145
|
const sseController = yield* SSEController;
|
|
9974
10146
|
const runtime = yield* getHonoRuntime;
|
|
9975
|
-
return new Hono9().get("/
|
|
10147
|
+
return new Hono9().get("/", async (c) => {
|
|
9976
10148
|
return streamSSE(
|
|
9977
10149
|
c,
|
|
9978
10150
|
async (rawStream) => {
|
|
@@ -9991,7 +10163,7 @@ var sseRoutes = Effect60.gen(function* () {
|
|
|
9991
10163
|
import { zValidator as zValidator7 } from "@hono/zod-validator";
|
|
9992
10164
|
import { Effect as Effect61 } from "effect";
|
|
9993
10165
|
import { Hono as Hono10 } from "hono";
|
|
9994
|
-
import { z as
|
|
10166
|
+
import { z as z38 } from "zod";
|
|
9995
10167
|
var tasksRoutes = Effect61.gen(function* () {
|
|
9996
10168
|
const tasksController = yield* TasksController;
|
|
9997
10169
|
const runtime = yield* getHonoRuntime;
|
|
@@ -9999,9 +10171,9 @@ var tasksRoutes = Effect61.gen(function* () {
|
|
|
9999
10171
|
"/",
|
|
10000
10172
|
zValidator7(
|
|
10001
10173
|
"query",
|
|
10002
|
-
|
|
10003
|
-
projectId:
|
|
10004
|
-
sessionId:
|
|
10174
|
+
z38.object({
|
|
10175
|
+
projectId: z38.string(),
|
|
10176
|
+
sessionId: z38.string().optional()
|
|
10005
10177
|
})
|
|
10006
10178
|
),
|
|
10007
10179
|
async (c) => {
|
|
@@ -10024,9 +10196,9 @@ var tasksRoutes = Effect61.gen(function* () {
|
|
|
10024
10196
|
"/",
|
|
10025
10197
|
zValidator7(
|
|
10026
10198
|
"query",
|
|
10027
|
-
|
|
10028
|
-
projectId:
|
|
10029
|
-
sessionId:
|
|
10199
|
+
z38.object({
|
|
10200
|
+
projectId: z38.string(),
|
|
10201
|
+
sessionId: z38.string().optional()
|
|
10030
10202
|
})
|
|
10031
10203
|
),
|
|
10032
10204
|
zValidator7("json", TaskCreateSchema),
|
|
@@ -10051,9 +10223,9 @@ var tasksRoutes = Effect61.gen(function* () {
|
|
|
10051
10223
|
"/:taskId",
|
|
10052
10224
|
zValidator7(
|
|
10053
10225
|
"query",
|
|
10054
|
-
|
|
10055
|
-
projectId:
|
|
10056
|
-
sessionId:
|
|
10226
|
+
z38.object({
|
|
10227
|
+
projectId: z38.string(),
|
|
10228
|
+
sessionId: z38.string().optional()
|
|
10057
10229
|
})
|
|
10058
10230
|
),
|
|
10059
10231
|
zValidator7("json", TaskUpdateSchema.omit({ taskId: true })),
|
|
@@ -10079,6 +10251,26 @@ var tasksRoutes = Effect61.gen(function* () {
|
|
|
10079
10251
|
});
|
|
10080
10252
|
|
|
10081
10253
|
// src/server/hono/routes/index.ts
|
|
10254
|
+
var API_ONLY_ALLOWED_PREFIXES = [
|
|
10255
|
+
"/api/version",
|
|
10256
|
+
"/api/config",
|
|
10257
|
+
"/api/projects",
|
|
10258
|
+
"/api/claude-code",
|
|
10259
|
+
"/api/search",
|
|
10260
|
+
"/api/sse"
|
|
10261
|
+
];
|
|
10262
|
+
var createApiOnlyMiddleware = (apiOnly) => createMiddleware3(async (c, next) => {
|
|
10263
|
+
if (apiOnly) {
|
|
10264
|
+
const path = c.req.path;
|
|
10265
|
+
const allowed = API_ONLY_ALLOWED_PREFIXES.some(
|
|
10266
|
+
(prefix) => path === prefix || path.startsWith(`${prefix}/`)
|
|
10267
|
+
);
|
|
10268
|
+
if (!allowed) {
|
|
10269
|
+
return c.json({ error: "Not Found" }, 404);
|
|
10270
|
+
}
|
|
10271
|
+
}
|
|
10272
|
+
return next();
|
|
10273
|
+
});
|
|
10082
10274
|
var routes = (app, options) => Effect62.gen(function* () {
|
|
10083
10275
|
const ccvOptionsService = yield* CcvOptionsService;
|
|
10084
10276
|
yield* ccvOptionsService.loadCliOptions(options);
|
|
@@ -10086,6 +10278,8 @@ var routes = (app, options) => Effect62.gen(function* () {
|
|
|
10086
10278
|
const userConfigService = yield* UserConfigService;
|
|
10087
10279
|
const initializeService = yield* InitializeService;
|
|
10088
10280
|
const { authRequiredMiddleware } = yield* AuthMiddleware;
|
|
10281
|
+
const apiOnly = (yield* ccvOptionsService.getCcvOptions("apiOnly")) === true;
|
|
10282
|
+
const apiOnlyMiddleware = createApiOnlyMiddleware(apiOnly);
|
|
10089
10283
|
const runtime = yield* getHonoRuntime;
|
|
10090
10284
|
if ((yield* envService.getEnv("NEXT_PHASE")) !== "phase-production-build") {
|
|
10091
10285
|
yield* initializeService.startInitialization();
|
|
@@ -10093,7 +10287,7 @@ var routes = (app, options) => Effect62.gen(function* () {
|
|
|
10093
10287
|
await Runtime5.runPromise(runtime)(initializeService.stopCleanup());
|
|
10094
10288
|
});
|
|
10095
10289
|
}
|
|
10096
|
-
return app.use(configMiddleware).use(async (c, next) => {
|
|
10290
|
+
return app.use(configMiddleware).use(apiOnlyMiddleware).use(async (c, next) => {
|
|
10097
10291
|
await Runtime5.runPromise(
|
|
10098
10292
|
runtime,
|
|
10099
10293
|
userConfigService.setUserConfig({
|
|
@@ -10267,7 +10461,8 @@ var setupTerminalWebSocket = (server) => Effect63.gen(function* () {
|
|
|
10267
10461
|
// src/server/startServer.ts
|
|
10268
10462
|
var startServer = async (options) => {
|
|
10269
10463
|
const isDevelopment = isDevelopmentEnv(process.env.CCV_ENV);
|
|
10270
|
-
|
|
10464
|
+
const apiOnly = options.apiOnly === true;
|
|
10465
|
+
if (!isDevelopment && !apiOnly) {
|
|
10271
10466
|
const staticPath = resolve7(import.meta.dirname, "static");
|
|
10272
10467
|
console.log("Serving static files from ", staticPath);
|
|
10273
10468
|
honoApp.use(
|
|
@@ -10289,7 +10484,9 @@ var startServer = async (options) => {
|
|
|
10289
10484
|
});
|
|
10290
10485
|
const program2 = Effect64.gen(function* () {
|
|
10291
10486
|
yield* routes(honoApp, options);
|
|
10292
|
-
|
|
10487
|
+
if (!apiOnly) {
|
|
10488
|
+
yield* setupTerminalWebSocket(server);
|
|
10489
|
+
}
|
|
10293
10490
|
}).pipe(Effect64.provide(MainLayer), Effect64.scoped);
|
|
10294
10491
|
await Effect64.runPromise(program2);
|
|
10295
10492
|
const port = isDevelopment ? (
|
|
@@ -10303,7 +10500,8 @@ var startServer = async (options) => {
|
|
|
10303
10500
|
server.listen(parseInt(port, 10), hostname, () => {
|
|
10304
10501
|
const info = server.address();
|
|
10305
10502
|
const serverPort = typeof info === "object" && info !== null ? info.port : port;
|
|
10306
|
-
|
|
10503
|
+
const mode = apiOnly ? " (API-only mode)" : "";
|
|
10504
|
+
console.log(`Server is running on http://${hostname}:${serverPort}${mode}`);
|
|
10307
10505
|
});
|
|
10308
10506
|
};
|
|
10309
10507
|
var PlatformLayer = Layer44.mergeAll(platformLayer, NodeContext2.layer);
|
|
@@ -10370,7 +10568,7 @@ program.option("-p, --port <port>", "port to listen on").option("-h, --hostname
|
|
|
10370
10568
|
).option("--terminal-shell <path>", "shell executable for terminal sessions").option(
|
|
10371
10569
|
"--terminal-unrestricted",
|
|
10372
10570
|
"disable restricted shell flags for bash sessions"
|
|
10373
|
-
).action(async (options) => {
|
|
10571
|
+
).option("--api-only", "run in API-only mode without Web UI").action(async (options) => {
|
|
10374
10572
|
await Effect65.runPromise(checkDeprecatedEnvs);
|
|
10375
10573
|
await startServer(options);
|
|
10376
10574
|
});
|