@kimuson/claude-code-viewer 0.4.15 → 0.5.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/main.js CHANGED
@@ -1,19 +1,233 @@
1
1
  #!/usr/bin/env node
2
2
 
3
3
  // src/server/main.ts
4
+ import { Command as Command3 } from "commander";
5
+ import { Effect as Effect49 } from "effect";
6
+
7
+ // package.json
8
+ var package_default = {
9
+ name: "@kimuson/claude-code-viewer",
10
+ version: "0.5.1",
11
+ description: "A full-featured web-based Claude Code client that provides complete interactive functionality for managing Claude Code projects.",
12
+ type: "module",
13
+ license: "MIT",
14
+ repository: {
15
+ type: "git",
16
+ url: "https://github.com/d-kimuson/claude-code-viewer.git"
17
+ },
18
+ homepage: "https://github.com/d-kimuson/claude-code-viewer",
19
+ files: [
20
+ "dist"
21
+ ],
22
+ engines: {
23
+ node: ">=20.19.0"
24
+ },
25
+ bin: {
26
+ "claude-code-viewer": "./dist/main.js"
27
+ },
28
+ scripts: {
29
+ dev: "run-p 'dev:*'",
30
+ "dev:frontend": "vite",
31
+ "dev:backend": "NODE_ENV=development tsx watch src/server/main.ts --env-file-if-exists=.env.local",
32
+ start: "node dist/main.js",
33
+ build: "./scripts/build.sh",
34
+ "build:frontend": "vite build",
35
+ "build:backend": "esbuild src/server/main.ts --format=esm --bundle --packages=external --sourcemap --platform=node --outfile=dist/main.js",
36
+ lint: "run-s 'lint:*'",
37
+ "lint:biome-format": "biome format .",
38
+ "lint:biome-lint": "biome check .",
39
+ fix: "run-s 'fix:*'",
40
+ "fix:biome-format": "biome format --write .",
41
+ "fix:biome-lint": "biome check --write --unsafe .",
42
+ typecheck: "tsc --noEmit",
43
+ test: "vitest --run",
44
+ "test:watch": "vitest",
45
+ e2e: "./scripts/e2e/exec_e2e.sh",
46
+ "e2e:start-server": "./scripts/e2e/start_server.sh",
47
+ "e2e:capture-snapshots": "./scripts/e2e/capture_snapshots.sh",
48
+ "lingui:extract": "lingui extract --clean && node ./scripts/lingui-sort.js",
49
+ "lingui:compile": "lingui compile --typescript",
50
+ prepack: "pnpm build",
51
+ prepare: "lefthook install"
52
+ },
53
+ dependencies: {
54
+ "@anthropic-ai/claude-agent-sdk": "0.1.30",
55
+ "@anthropic-ai/claude-code": "2.0.24",
56
+ "@anthropic-ai/sdk": "0.67.0",
57
+ "@effect/cluster": "0.55.0",
58
+ "@effect/experimental": "0.57.11",
59
+ "@effect/platform": "0.93.6",
60
+ "@effect/platform-node": "0.103.0",
61
+ "@effect/rpc": "0.72.2",
62
+ "@effect/sql": "0.48.6",
63
+ "@effect/workflow": "0.15.1",
64
+ "@hono/node-server": "1.19.5",
65
+ "@hono/zod-validator": "0.7.4",
66
+ "@lingui/core": "5.5.1",
67
+ "@lingui/react": "5.5.1",
68
+ "@radix-ui/react-avatar": "1.1.10",
69
+ "@radix-ui/react-checkbox": "1.3.3",
70
+ "@radix-ui/react-collapsible": "1.1.12",
71
+ "@radix-ui/react-dialog": "1.1.15",
72
+ "@radix-ui/react-hover-card": "1.1.15",
73
+ "@radix-ui/react-popover": "1.1.15",
74
+ "@radix-ui/react-select": "2.2.6",
75
+ "@radix-ui/react-slot": "1.2.3",
76
+ "@radix-ui/react-tabs": "1.1.13",
77
+ "@radix-ui/react-tooltip": "1.2.8",
78
+ "@tailwindcss/vite": "4.1.16",
79
+ "@tanstack/react-devtools": "0.7.8",
80
+ "@tanstack/react-query": "5.90.5",
81
+ "@tanstack/react-router": "1.133.32",
82
+ "@tanstack/react-router-devtools": "1.133.32",
83
+ "class-variance-authority": "0.7.1",
84
+ clsx: "2.1.1",
85
+ commander: "^14.0.2",
86
+ "date-fns": "4.1.0",
87
+ effect: "3.19.9",
88
+ "es-toolkit": "1.41.0",
89
+ hono: "4.10.3",
90
+ jotai: "2.15.0",
91
+ "lucide-react": "0.548.0",
92
+ minisearch: "7.2.0",
93
+ "parse-git-diff": "0.0.19",
94
+ prexit: "2.3.0",
95
+ react: "19.2.0",
96
+ "react-dom": "19.2.0",
97
+ "react-error-boundary": "6.0.0",
98
+ "react-helmet-async": "2.0.5",
99
+ "react-markdown": "10.1.0",
100
+ "react-syntax-highlighter": "15.6.6",
101
+ "remark-gfm": "4.0.1",
102
+ sonner: "2.0.7",
103
+ "tailwind-merge": "3.3.1",
104
+ ulid: "3.0.1",
105
+ zod: "4.1.13"
106
+ },
107
+ devDependencies: {
108
+ "@biomejs/biome": "2.3.1",
109
+ "@effect/language-service": "0.60.0",
110
+ "@lingui/cli": "5.5.1",
111
+ "@lingui/conf": "5.5.1",
112
+ "@lingui/format-json": "5.5.1",
113
+ "@lingui/loader": "5.5.1",
114
+ "@lingui/vite-plugin": "5.5.1",
115
+ "@tailwindcss/postcss": "4.1.16",
116
+ "@tanstack/router-plugin": "1.133.32",
117
+ "@tsconfig/strictest": "2.0.6",
118
+ "@types/node": "24.9.1",
119
+ "@types/react": "19.2.2",
120
+ "@types/react-dom": "19.2.2",
121
+ "@types/react-syntax-highlighter": "15.5.13",
122
+ "@vitejs/plugin-react-swc": "4.2.0",
123
+ dotenv: "17.2.3",
124
+ esbuild: "0.25.11",
125
+ lefthook: "2.0.8",
126
+ "npm-run-all2": "8.0.4",
127
+ playwright: "1.56.1",
128
+ "release-it": "19.0.5",
129
+ "release-it-pnpm": "4.6.6",
130
+ tailwindcss: "4.1.16",
131
+ tsx: "4.20.6",
132
+ "tw-animate-css": "1.4.0",
133
+ typescript: "5.9.3",
134
+ vite: "7.1.12",
135
+ vitest: "4.0.3"
136
+ },
137
+ packageManager: "pnpm@10.18.3+sha512.bbd16e6d7286fd7e01f6b3c0b3c932cda2965c06a908328f74663f10a9aea51f1129eea615134bf992831b009eabe167ecb7008b597f40ff9bc75946aadfb08d"
138
+ };
139
+
140
+ // src/server/core/platform/services/DeprecatedEnvDetector.ts
141
+ import { Console, Effect } from "effect";
142
+ var DEPRECATED_ENVS = {
143
+ // Removed in PR #101
144
+ CLAUDE_CODE_VIEWER_AUTH_PASSWORD: {
145
+ type: "removed",
146
+ newEnv: "CCV_PASSWORD",
147
+ cliOption: "--password"
148
+ },
149
+ CLAUDE_CODE_VIEWER_CC_EXECUTABLE_PATH: {
150
+ type: "removed",
151
+ newEnv: "CCV_CC_EXECUTABLE_PATH",
152
+ cliOption: "--executable"
153
+ }
154
+ };
155
+ var getOptionalEnv = (key) => {
156
+ return process.env[key] ?? void 0;
157
+ };
158
+ var detectDeprecatedEnvs = () => {
159
+ const warnings = [];
160
+ for (const [envKey, config] of Object.entries(DEPRECATED_ENVS)) {
161
+ const value = getOptionalEnv(envKey);
162
+ if (value !== void 0) {
163
+ if (config.type === "removed") {
164
+ warnings.push({
165
+ type: "removed",
166
+ envKey,
167
+ message: `Environment variable ${envKey} has been removed.`,
168
+ suggestion: config.newEnv ? `Please use ${config.newEnv} environment variable or ${config.cliOption} CLI option instead.` : `Please use ${config.cliOption} CLI option instead.`
169
+ });
170
+ } else {
171
+ warnings.push({
172
+ type: "deprecated",
173
+ envKey,
174
+ message: `Environment variable ${envKey} is deprecated and will be removed in a future release.`,
175
+ suggestion: config.newEnv ? `Please migrate to ${config.newEnv} environment variable or ${config.cliOption} CLI option.` : `Please use ${config.cliOption} CLI option instead.`
176
+ });
177
+ }
178
+ }
179
+ }
180
+ return warnings;
181
+ };
182
+ var formatWarning = (warning) => {
183
+ const prefix = warning.type === "removed" ? "\u274C REMOVED" : "\u26A0\uFE0F DEPRECATED";
184
+ return `${prefix}: ${warning.message}
185
+ \u2192 ${warning.suggestion}`;
186
+ };
187
+ var checkDeprecatedEnvs = Effect.gen(function* () {
188
+ const warnings = detectDeprecatedEnvs();
189
+ if (warnings.length === 0) {
190
+ return;
191
+ }
192
+ const hasRemovedEnvs = warnings.some((warning) => warning.type === "removed");
193
+ yield* Console.log("");
194
+ yield* Console.log("\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501");
195
+ yield* Console.log(" Migration Guide");
196
+ yield* Console.log("\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501");
197
+ yield* Console.log("");
198
+ for (const warning of warnings) {
199
+ yield* Console.log(formatWarning(warning));
200
+ yield* Console.log("");
201
+ }
202
+ yield* Console.log("For more details, see:");
203
+ yield* Console.log(
204
+ " https://github.com/d-kimuson/claude-code-viewer#configuration"
205
+ );
206
+ yield* Console.log("\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501");
207
+ yield* Console.log("");
208
+ if (hasRemovedEnvs) {
209
+ yield* Effect.fail(
210
+ new Error(
211
+ "Cannot start server: removed environment variables detected. Please update your configuration."
212
+ )
213
+ );
214
+ }
215
+ });
216
+
217
+ // src/server/startServer.ts
4
218
  import { readFile as readFile2 } from "node:fs/promises";
5
219
  import { resolve as resolve6 } from "node:path";
6
220
  import { NodeContext as NodeContext2 } from "@effect/platform-node";
7
221
  import { serve } from "@hono/node-server";
8
222
  import { serveStatic } from "@hono/node-server/serve-static";
9
- import { Effect as Effect46 } from "effect";
223
+ import { Effect as Effect48 } from "effect";
10
224
 
11
225
  // src/server/core/agent-session/index.ts
12
226
  import { Layer as Layer3 } from "effect";
13
227
 
14
228
  // src/server/core/agent-session/infrastructure/AgentSessionRepository.ts
15
229
  import { FileSystem, Path } from "@effect/platform";
16
- import { Context, Effect, Layer } from "effect";
230
+ import { Context, Effect as Effect2, Layer } from "effect";
17
231
 
18
232
  // src/lib/conversation-schema/index.ts
19
233
  import { z as z16 } from "zod";
@@ -197,6 +411,12 @@ var QueueOperationEntrySchema = z11.union([
197
411
  operation: z11.literal("dequeue"),
198
412
  sessionId: z11.string(),
199
413
  timestamp: z11.iso.datetime()
414
+ }),
415
+ z11.object({
416
+ type: z11.literal("queue-operation"),
417
+ operation: z11.literal("remove"),
418
+ sessionId: z11.string(),
419
+ timestamp: z11.iso.datetime()
200
420
  })
201
421
  ]);
202
422
 
@@ -210,14 +430,40 @@ var SummaryEntrySchema = z12.object({
210
430
 
211
431
  // src/lib/conversation-schema/entry/SystemEntrySchema.ts
212
432
  import { z as z13 } from "zod";
213
- var SystemEntrySchema = BaseEntrySchema.extend({
214
- // discriminator
433
+ var HookInfoSchema = z13.object({
434
+ command: z13.string()
435
+ });
436
+ var SystemEntryWithContentSchema = BaseEntrySchema.extend({
215
437
  type: z13.literal("system"),
216
- // required
217
438
  content: z13.string(),
218
439
  toolUseID: z13.string(),
440
+ level: z13.enum(["info"]),
441
+ subtype: z13.undefined().optional()
442
+ });
443
+ var StopHookSummaryEntrySchema = BaseEntrySchema.extend({
444
+ type: z13.literal("system"),
445
+ subtype: z13.literal("stop_hook_summary"),
446
+ toolUseID: z13.string(),
447
+ level: z13.enum(["info", "suggestion"]),
448
+ slug: z13.string().optional(),
449
+ hookCount: z13.number(),
450
+ hookInfos: z13.array(HookInfoSchema),
451
+ hookErrors: z13.array(z13.unknown()),
452
+ preventedContinuation: z13.boolean(),
453
+ stopReason: z13.string(),
454
+ hasOutput: z13.boolean()
455
+ });
456
+ var LocalCommandEntrySchema = BaseEntrySchema.extend({
457
+ type: z13.literal("system"),
458
+ subtype: z13.literal("local_command"),
459
+ content: z13.string(),
219
460
  level: z13.enum(["info"])
220
461
  });
462
+ var SystemEntrySchema = z13.union([
463
+ StopHookSummaryEntrySchema,
464
+ LocalCommandEntrySchema,
465
+ SystemEntryWithContentSchema
466
+ ]);
221
467
 
222
468
  // src/lib/conversation-schema/entry/UserEntrySchema.ts
223
469
  import { z as z15 } from "zod";
@@ -287,10 +533,10 @@ var encodeProjectIdFromSessionFilePath = (sessionFilePath) => {
287
533
  };
288
534
 
289
535
  // src/server/core/agent-session/infrastructure/AgentSessionRepository.ts
290
- var LayerImpl = Effect.gen(function* () {
536
+ var LayerImpl = Effect2.gen(function* () {
291
537
  const fs = yield* FileSystem.FileSystem;
292
538
  const path = yield* Path.Path;
293
- const getAgentSessionByAgentId = (projectId, agentId) => Effect.gen(function* () {
539
+ const getAgentSessionByAgentId = (projectId, agentId) => Effect2.gen(function* () {
294
540
  const projectPath = decodeProjectId(projectId);
295
541
  const agentFilePath = path.resolve(projectPath, `agent-${agentId}.jsonl`);
296
542
  const exists = yield* fs.exists(agentFilePath);
@@ -314,10 +560,10 @@ var AgentSessionRepository = class extends Context.Tag(
314
560
  };
315
561
 
316
562
  // src/server/core/agent-session/presentation/AgentSessionController.ts
317
- import { Context as Context2, Effect as Effect2, Layer as Layer2 } from "effect";
318
- var LayerImpl2 = Effect2.gen(function* () {
563
+ import { Context as Context2, Effect as Effect3, Layer as Layer2 } from "effect";
564
+ var LayerImpl2 = Effect3.gen(function* () {
319
565
  const repository = yield* AgentSessionRepository;
320
- const getAgentSession = (params) => Effect2.gen(function* () {
566
+ const getAgentSession = (params) => Effect3.gen(function* () {
321
567
  const { projectId, agentId } = params;
322
568
  const conversations = yield* repository.getAgentSessionByAgentId(
323
569
  projectId,
@@ -357,80 +603,78 @@ var AgentSessionLayer = Layer3.mergeAll(AgentSessionRepository.Live);
357
603
 
358
604
  // src/server/core/claude-code/presentation/ClaudeCodeController.ts
359
605
  import { FileSystem as FileSystem6, Path as Path8 } from "@effect/platform";
360
- import { Context as Context9, Effect as Effect12, Layer as Layer11 } from "effect";
606
+ import { Context as Context9, Effect as Effect13, Layer as Layer11 } from "effect";
361
607
 
362
608
  // src/server/core/platform/services/ApplicationContext.ts
363
609
  import { homedir } from "node:os";
364
610
  import { Path as Path2 } from "@effect/platform";
365
- import { Effect as Effect4, Context as EffectContext, Layer as Layer5 } from "effect";
366
-
367
- // src/server/core/platform/services/EnvService.ts
368
- import { Context as Context3, Effect as Effect3, Layer as Layer4, Ref } from "effect";
369
-
370
- // src/server/core/platform/schema.ts
371
- import { z as z17 } from "zod";
372
- var envSchema = z17.object({
373
- NODE_ENV: z17.enum(["development", "production", "test"]).optional().default("development"),
374
- GLOBAL_CLAUDE_DIR: z17.string().optional(),
375
- NEXT_PHASE: z17.string().optional(),
376
- PORT: z17.string().optional().default("3000").transform((val) => parseInt(val, 10)),
377
- PATH: z17.string().optional(),
378
- CLAUDE_CODE_VIEWER_CC_EXECUTABLE_PATH: z17.string().optional(),
379
- CLAUDE_CODE_VIEWER_AUTH_PASSWORD: z17.string().optional()
380
- });
611
+ import { Effect as Effect5, Context as EffectContext, Layer as Layer5 } from "effect";
381
612
 
382
- // src/server/core/platform/services/EnvService.ts
383
- var LayerImpl3 = Effect3.gen(function* () {
384
- const envRef = yield* Ref.make(void 0);
385
- const parseEnv = () => {
386
- const parsed = envSchema.safeParse(process.env);
387
- if (!parsed.success) {
388
- console.error(parsed.error);
389
- throw new Error(`Invalid environment variables: ${parsed.error.message}`);
390
- }
391
- return parsed.data;
392
- };
393
- const getEnv = (key) => {
394
- return Effect3.gen(function* () {
395
- yield* Ref.update(envRef, (existingEnv) => {
396
- if (existingEnv === void 0) {
397
- return parseEnv();
398
- }
399
- return existingEnv;
613
+ // src/server/core/platform/services/CcvOptionsService.ts
614
+ import { Context as Context3, Effect as Effect4, Layer as Layer4, Ref } from "effect";
615
+ var getOptionalEnv2 = (key) => {
616
+ return process.env[key] ?? void 0;
617
+ };
618
+ var LayerImpl3 = Effect4.gen(function* () {
619
+ const ccvOptionsRef = yield* Ref.make(void 0);
620
+ const loadCliOptions = (cliOptions) => {
621
+ return Effect4.gen(function* () {
622
+ yield* Ref.update(ccvOptionsRef, () => {
623
+ return {
624
+ port: Number.parseInt(
625
+ cliOptions.port ?? getOptionalEnv2("PORT") ?? "3000",
626
+ 10
627
+ ),
628
+ hostname: cliOptions.hostname ?? getOptionalEnv2("HOSTNAME") ?? "localhost",
629
+ password: cliOptions.password ?? getOptionalEnv2("CCV_PASSWORD") ?? void 0,
630
+ executable: cliOptions.executable ?? getOptionalEnv2("CCV_CC_EXECUTABLE_PATH") ?? void 0,
631
+ claudeDir: cliOptions.claudeDir ?? getOptionalEnv2("CCV_GLOBAL_CLAUDE_DIR")
632
+ };
400
633
  });
401
- const env = yield* Ref.get(envRef);
402
- if (env === void 0) {
403
- throw new Error(
404
- "Unexpected error: Environment variables are not loaded"
405
- );
634
+ });
635
+ };
636
+ const getCcvOptions = (key) => {
637
+ return Effect4.gen(function* () {
638
+ const ccvOptions = yield* Ref.get(ccvOptionsRef);
639
+ if (ccvOptions === void 0) {
640
+ throw new Error("Unexpected error: CCV options are not loaded");
406
641
  }
407
- return env[key];
642
+ return ccvOptions[key];
408
643
  });
409
644
  };
410
645
  return {
411
- getEnv
646
+ loadCliOptions,
647
+ getCcvOptions
412
648
  };
413
649
  });
414
- var EnvService = class extends Context3.Tag("EnvService")() {
650
+ var CcvOptionsService = class extends Context3.Tag("CcvOptionsService")() {
415
651
  static {
416
652
  this.Live = Layer4.effect(this, LayerImpl3);
417
653
  }
418
654
  };
419
655
 
420
656
  // src/server/core/platform/services/ApplicationContext.ts
421
- var LayerImpl4 = Effect4.gen(function* () {
657
+ var LayerImpl4 = Effect5.gen(function* () {
422
658
  const path = yield* Path2.Path;
423
- const envService = yield* EnvService;
424
- const globalClaudeDirectoryPath = yield* envService.getEnv("GLOBAL_CLAUDE_DIR").pipe(
425
- Effect4.map(
426
- (envVar) => envVar === void 0 ? path.resolve(homedir(), ".claude") : path.resolve(envVar)
427
- )
428
- );
429
- const claudeCodePaths = {
430
- globalClaudeDirectoryPath,
431
- claudeCommandsDirPath: path.resolve(globalClaudeDirectoryPath, "commands"),
432
- claudeProjectsDirPath: path.resolve(globalClaudeDirectoryPath, "projects")
433
- };
659
+ const ccvOptionsService = yield* CcvOptionsService;
660
+ const claudeCodePaths = Effect5.gen(function* () {
661
+ const globalClaudeDirectoryPath = yield* ccvOptionsService.getCcvOptions("claudeDir").pipe(
662
+ Effect5.map(
663
+ (envVar) => envVar === void 0 ? path.resolve(homedir(), ".claude") : path.resolve(envVar)
664
+ )
665
+ );
666
+ return {
667
+ globalClaudeDirectoryPath,
668
+ claudeCommandsDirPath: path.resolve(
669
+ globalClaudeDirectoryPath,
670
+ "commands"
671
+ ),
672
+ claudeProjectsDirPath: path.resolve(
673
+ globalClaudeDirectoryPath,
674
+ "projects"
675
+ )
676
+ };
677
+ });
434
678
  return {
435
679
  claudeCodePaths
436
680
  };
@@ -443,20 +687,20 @@ var ApplicationContext = class extends EffectContext.Tag("ApplicationContext")()
443
687
 
444
688
  // src/server/core/project/infrastructure/ProjectRepository.ts
445
689
  import { FileSystem as FileSystem4, Path as Path5 } from "@effect/platform";
446
- import { Context as Context7, Effect as Effect8, Layer as Layer9, Option as Option2 } from "effect";
690
+ import { Context as Context7, Effect as Effect9, Layer as Layer9, Option as Option2 } from "effect";
447
691
 
448
692
  // src/server/core/project/services/ProjectMetaService.ts
449
693
  import { FileSystem as FileSystem3, Path as Path4 } from "@effect/platform";
450
- import { Context as Context6, Effect as Effect7, Layer as Layer8, Option, Ref as Ref3 } from "effect";
451
- import { z as z19 } from "zod";
694
+ import { Context as Context6, Effect as Effect8, Layer as Layer8, Option, Ref as Ref3 } from "effect";
695
+ import { z as z18 } from "zod";
452
696
 
453
697
  // src/server/lib/storage/FileCacheStorage/index.ts
454
- import { Context as Context5, Effect as Effect6, Layer as Layer7, Ref as Ref2, Runtime } from "effect";
698
+ import { Context as Context5, Effect as Effect7, Layer as Layer7, Ref as Ref2, Runtime } from "effect";
455
699
 
456
700
  // src/server/lib/storage/FileCacheStorage/PersistentService.ts
457
701
  import { FileSystem as FileSystem2, Path as Path3 } from "@effect/platform";
458
- import { Context as Context4, Effect as Effect5, Layer as Layer6 } from "effect";
459
- import { z as z18 } from "zod";
702
+ import { Context as Context4, Effect as Effect6, Layer as Layer6 } from "effect";
703
+ import { z as z17 } from "zod";
460
704
 
461
705
  // src/server/lib/config/paths.ts
462
706
  import { homedir as homedir2 } from "node:os";
@@ -468,13 +712,13 @@ var claudeCodeViewerCacheDirPath = resolve(
468
712
  );
469
713
 
470
714
  // src/server/lib/storage/FileCacheStorage/PersistentService.ts
471
- var saveSchema = z18.array(z18.tuple([z18.string(), z18.unknown()]));
472
- var LayerImpl5 = Effect5.gen(function* () {
715
+ var saveSchema = z17.array(z17.tuple([z17.string(), z17.unknown()]));
716
+ var LayerImpl5 = Effect6.gen(function* () {
473
717
  const path = yield* Path3.Path;
474
718
  const getCacheFilePath = (key) => path.resolve(claudeCodeViewerCacheDirPath, `${key}.json`);
475
719
  const load = (key) => {
476
720
  const cacheFilePath = getCacheFilePath(key);
477
- return Effect5.gen(function* () {
721
+ return Effect6.gen(function* () {
478
722
  const fs = yield* FileSystem2.FileSystem;
479
723
  if (!(yield* fs.exists(claudeCodeViewerCacheDirPath))) {
480
724
  yield* fs.makeDirectory(claudeCodeViewerCacheDirPath, {
@@ -505,7 +749,7 @@ var LayerImpl5 = Effect5.gen(function* () {
505
749
  };
506
750
  const save = (key, entries) => {
507
751
  const cacheFilePath = getCacheFilePath(key);
508
- return Effect5.gen(function* () {
752
+ return Effect6.gen(function* () {
509
753
  const fs = yield* FileSystem2.FileSystem;
510
754
  yield* fs.writeFileString(cacheFilePath, JSON.stringify(entries));
511
755
  });
@@ -525,10 +769,10 @@ var PersistentService = class extends Context4.Tag("PersistentService")() {
525
769
  var FileCacheStorage = () => Context5.GenericTag("FileCacheStorage");
526
770
  var makeFileCacheStorageLayer = (storageKey, schema) => Layer7.effect(
527
771
  FileCacheStorage(),
528
- Effect6.gen(function* () {
772
+ Effect7.gen(function* () {
529
773
  const persistentService = yield* PersistentService;
530
- const runtime = yield* Effect6.runtime();
531
- const storageRef = yield* Effect6.gen(function* () {
774
+ const runtime = yield* Effect7.runtime();
775
+ const storageRef = yield* Effect7.gen(function* () {
532
776
  const persistedData = yield* persistentService.load(storageKey);
533
777
  const initialMap = /* @__PURE__ */ new Map();
534
778
  for (const [key, value] of persistedData) {
@@ -543,11 +787,11 @@ var makeFileCacheStorageLayer = (storageKey, schema) => Layer7.effect(
543
787
  Runtime.runFork(runtime)(persistentService.save(storageKey, entries));
544
788
  };
545
789
  return {
546
- get: (key) => Effect6.gen(function* () {
790
+ get: (key) => Effect7.gen(function* () {
547
791
  const storage = yield* Ref2.get(storageRef);
548
792
  return storage.get(key);
549
793
  }),
550
- set: (key, value) => Effect6.gen(function* () {
794
+ set: (key, value) => Effect7.gen(function* () {
551
795
  const before = yield* Ref2.get(storageRef);
552
796
  const beforeString = JSON.stringify(Array.from(before.entries()));
553
797
  yield* Ref2.update(storageRef, (map) => {
@@ -560,7 +804,7 @@ var makeFileCacheStorageLayer = (storageKey, schema) => Layer7.effect(
560
804
  syncToFile(Array.from(after.entries()));
561
805
  }
562
806
  }),
563
- invalidate: (key) => Effect6.gen(function* () {
807
+ invalidate: (key) => Effect7.gen(function* () {
564
808
  const before = yield* Ref2.get(storageRef);
565
809
  if (!before.has(key)) {
566
810
  return;
@@ -572,7 +816,7 @@ var makeFileCacheStorageLayer = (storageKey, schema) => Layer7.effect(
572
816
  const after = yield* Ref2.get(storageRef);
573
817
  syncToFile(Array.from(after.entries()));
574
818
  }),
575
- getAll: () => Effect6.gen(function* () {
819
+ getAll: () => Effect7.gen(function* () {
576
820
  const storage = yield* Ref2.get(storageRef);
577
821
  return new Map(storage);
578
822
  })
@@ -581,13 +825,13 @@ var makeFileCacheStorageLayer = (storageKey, schema) => Layer7.effect(
581
825
  );
582
826
 
583
827
  // src/server/core/project/services/ProjectMetaService.ts
584
- var ProjectPathSchema = z19.string().nullable();
585
- var LayerImpl6 = Effect7.gen(function* () {
828
+ var ProjectPathSchema = z18.string().nullable();
829
+ var LayerImpl6 = Effect8.gen(function* () {
586
830
  const fs = yield* FileSystem3.FileSystem;
587
831
  const path = yield* Path4.Path;
588
832
  const projectPathCache = yield* FileCacheStorage();
589
833
  const projectMetaCacheRef = yield* Ref3.make(/* @__PURE__ */ new Map());
590
- const extractProjectPathFromJsonl = (filePath) => Effect7.gen(function* () {
834
+ const extractProjectPathFromJsonl = (filePath) => Effect8.gen(function* () {
591
835
  const cached = yield* projectPathCache.get(filePath);
592
836
  if (cached !== void 0) {
593
837
  return cached;
@@ -608,7 +852,7 @@ var LayerImpl6 = Effect7.gen(function* () {
608
852
  }
609
853
  return cwd;
610
854
  });
611
- const getProjectMeta = (projectId) => Effect7.gen(function* () {
855
+ const getProjectMeta = (projectId) => Effect8.gen(function* () {
612
856
  const metaCache = yield* Ref3.get(projectMetaCacheRef);
613
857
  const cached = metaCache.get(projectId);
614
858
  if (cached !== void 0) {
@@ -616,9 +860,9 @@ var LayerImpl6 = Effect7.gen(function* () {
616
860
  }
617
861
  const claudeProjectPath = decodeProjectId(projectId);
618
862
  const dirents = yield* fs.readDirectory(claudeProjectPath);
619
- const fileEntries = yield* Effect7.all(
863
+ const fileEntries = yield* Effect8.all(
620
864
  dirents.filter((name) => name.endsWith(".jsonl")).map(
621
- (name) => Effect7.gen(function* () {
865
+ (name) => Effect8.gen(function* () {
622
866
  const fullPath = path.resolve(claudeProjectPath, name);
623
867
  const stat = yield* fs.stat(fullPath);
624
868
  const mtime = Option.getOrElse(stat.mtime, () => /* @__PURE__ */ new Date(0));
@@ -652,7 +896,7 @@ var LayerImpl6 = Effect7.gen(function* () {
652
896
  });
653
897
  return projectMeta;
654
898
  });
655
- const invalidateProject = (projectId) => Effect7.gen(function* () {
899
+ const invalidateProject = (projectId) => Effect8.gen(function* () {
656
900
  yield* Ref3.update(projectMetaCacheRef, (cache) => {
657
901
  cache.delete(projectId);
658
902
  return cache;
@@ -675,16 +919,16 @@ var ProjectMetaService = class extends Context6.Tag("ProjectMetaService")() {
675
919
  };
676
920
 
677
921
  // src/server/core/project/infrastructure/ProjectRepository.ts
678
- var LayerImpl7 = Effect8.gen(function* () {
922
+ var LayerImpl7 = Effect9.gen(function* () {
679
923
  const fs = yield* FileSystem4.FileSystem;
680
924
  const path = yield* Path5.Path;
681
925
  const projectMetaService = yield* ProjectMetaService;
682
926
  const context = yield* ApplicationContext;
683
- const getProject = (projectId) => Effect8.gen(function* () {
927
+ const getProject = (projectId) => Effect9.gen(function* () {
684
928
  const fullPath = decodeProjectId(projectId);
685
929
  const exists = yield* fs.exists(fullPath);
686
930
  if (!exists) {
687
- return yield* Effect8.fail(new Error("Project not found"));
931
+ return yield* Effect9.fail(new Error("Project not found"));
688
932
  }
689
933
  const stat = yield* fs.stat(fullPath);
690
934
  const meta = yield* projectMetaService.getProjectMeta(projectId);
@@ -697,28 +941,28 @@ var LayerImpl7 = Effect8.gen(function* () {
697
941
  }
698
942
  };
699
943
  });
700
- const getProjects = () => Effect8.gen(function* () {
944
+ const getProjects = () => Effect9.gen(function* () {
701
945
  const dirExists = yield* fs.exists(
702
- context.claudeCodePaths.claudeProjectsDirPath
946
+ (yield* context.claudeCodePaths).claudeProjectsDirPath
703
947
  );
704
948
  if (!dirExists) {
705
949
  console.warn(
706
- `Claude projects directory not found at ${context.claudeCodePaths.claudeProjectsDirPath}`
950
+ `Claude projects directory not found at ${(yield* context.claudeCodePaths).claudeProjectsDirPath}`
707
951
  );
708
952
  return { projects: [] };
709
953
  }
710
954
  const entries = yield* fs.readDirectory(
711
- context.claudeCodePaths.claudeProjectsDirPath
955
+ (yield* context.claudeCodePaths).claudeProjectsDirPath
712
956
  );
713
957
  const projectEffects = entries.map(
714
- (entry) => Effect8.gen(function* () {
958
+ (entry) => Effect9.gen(function* () {
715
959
  const fullPath = path.resolve(
716
- context.claudeCodePaths.claudeProjectsDirPath,
960
+ (yield* context.claudeCodePaths).claudeProjectsDirPath,
717
961
  entry
718
962
  );
719
- const stat = yield* Effect8.tryPromise(
720
- () => fs.stat(fullPath).pipe(Effect8.runPromise)
721
- ).pipe(Effect8.catchAll(() => Effect8.succeed(null)));
963
+ const stat = yield* Effect9.tryPromise(
964
+ () => fs.stat(fullPath).pipe(Effect9.runPromise)
965
+ ).pipe(Effect9.catchAll(() => Effect9.succeed(null)));
722
966
  if (!stat || stat.type !== "Directory") {
723
967
  return null;
724
968
  }
@@ -732,7 +976,7 @@ var LayerImpl7 = Effect8.gen(function* () {
732
976
  };
733
977
  })
734
978
  );
735
- const projectsWithNulls = yield* Effect8.all(projectEffects, {
979
+ const projectsWithNulls = yield* Effect9.all(projectEffects, {
736
980
  concurrency: "unbounded"
737
981
  });
738
982
  const projects = projectsWithNulls.filter(
@@ -756,24 +1000,24 @@ var ProjectRepository = class extends Context7.Tag("ProjectRepository")() {
756
1000
 
757
1001
  // src/server/core/claude-code/functions/scanCommandFiles.ts
758
1002
  import { FileSystem as FileSystem5, Path as Path6 } from "@effect/platform";
759
- import { Effect as Effect9 } from "effect";
1003
+ import { Effect as Effect10 } from "effect";
760
1004
  var pathToCommandName = (filePath, baseDir) => {
761
1005
  const normalizedBaseDir = baseDir.endsWith("/") ? baseDir.slice(0, -1) : baseDir;
762
1006
  const relativePath = filePath.startsWith(normalizedBaseDir) ? filePath.slice(normalizedBaseDir.length + 1) : filePath;
763
1007
  return relativePath.replace(/\.md$/, "").replace(/\//g, ":");
764
1008
  };
765
- var scanCommandFilesRecursively = (dirPath) => Effect9.gen(function* () {
1009
+ var scanCommandFilesRecursively = (dirPath) => Effect10.gen(function* () {
766
1010
  const fs = yield* FileSystem5.FileSystem;
767
1011
  const path = yield* Path6.Path;
768
- const scanDirectory = (currentPath) => Effect9.gen(function* () {
1012
+ const scanDirectory = (currentPath) => Effect10.gen(function* () {
769
1013
  const exists = yield* fs.exists(currentPath);
770
1014
  if (!exists) {
771
1015
  return [];
772
1016
  }
773
1017
  const items = yield* fs.readDirectory(currentPath);
774
- const results = yield* Effect9.forEach(
1018
+ const results = yield* Effect10.forEach(
775
1019
  items,
776
- (item) => Effect9.gen(function* () {
1020
+ (item) => Effect10.gen(function* () {
777
1021
  if (item.startsWith(".")) {
778
1022
  return [];
779
1023
  }
@@ -792,7 +1036,7 @@ var scanCommandFilesRecursively = (dirPath) => Effect9.gen(function* () {
792
1036
  return results.flat();
793
1037
  });
794
1038
  return yield* scanDirectory(dirPath).pipe(
795
- Effect9.match({
1039
+ Effect10.match({
796
1040
  onSuccess: (items) => items,
797
1041
  onFailure: () => []
798
1042
  })
@@ -800,12 +1044,12 @@ var scanCommandFilesRecursively = (dirPath) => Effect9.gen(function* () {
800
1044
  });
801
1045
 
802
1046
  // src/server/core/claude-code/models/ClaudeCodeVersion.ts
803
- import { z as z20 } from "zod";
1047
+ import { z as z19 } from "zod";
804
1048
  var versionRegex = /^(?<major>\d+)\.(?<minor>\d+)\.(?<patch>\d+)/;
805
- var versionSchema = z20.object({
806
- major: z20.string().transform((value) => Number.parseInt(value, 10)),
807
- minor: z20.string().transform((value) => Number.parseInt(value, 10)),
808
- patch: z20.string().transform((value) => Number.parseInt(value, 10))
1049
+ var versionSchema = z19.object({
1050
+ major: z19.string().transform((value) => Number.parseInt(value, 10)),
1051
+ minor: z19.string().transform((value) => Number.parseInt(value, 10)),
1052
+ patch: z19.string().transform((value) => Number.parseInt(value, 10))
809
1053
  }).refine(
810
1054
  (data) => [data.major, data.minor, data.patch].every((value) => !Number.isNaN(value))
811
1055
  );
@@ -826,7 +1070,7 @@ var greaterThan = (a, b) => a.major > b.major || a.major === b.major && (a.minor
826
1070
  var greaterThanOrEqual = (a, b) => equals(a, b) || greaterThan(a, b);
827
1071
 
828
1072
  // src/server/core/claude-code/services/ClaudeCodeService.ts
829
- import { Context as Context8, Data as Data2, Effect as Effect11, Layer as Layer10 } from "effect";
1073
+ import { Context as Context8, Data as Data2, Effect as Effect12, Layer as Layer10 } from "effect";
830
1074
 
831
1075
  // src/server/core/claude-code/functions/parseMcpListOutput.ts
832
1076
  var parseMcpListOutput = (output) => {
@@ -855,7 +1099,7 @@ import {
855
1099
  query as claudeCodeQuery
856
1100
  } from "@anthropic-ai/claude-code";
857
1101
  import { Command, Path as Path7 } from "@effect/platform";
858
- import { Data, Effect as Effect10 } from "effect";
1102
+ import { Data, Effect as Effect11 } from "effect";
859
1103
  import { uniq } from "es-toolkit";
860
1104
  var npxCacheRegExp = /_npx[/\\].*node_modules[\\/]\.bin/;
861
1105
  var localNodeModulesBinRegExp = new RegExp(
@@ -874,22 +1118,20 @@ var ClaudeCodePathNotFoundError = class extends Data.TaggedError(
874
1118
  "ClaudeCodePathNotFoundError"
875
1119
  ) {
876
1120
  };
877
- var resolveClaudeCodePath = Effect10.gen(function* () {
1121
+ var resolveClaudeCodePath = Effect11.gen(function* () {
878
1122
  const path = yield* Path7.Path;
879
- const envService = yield* EnvService;
880
- const specifiedExecutablePath = yield* envService.getEnv(
881
- "CLAUDE_CODE_VIEWER_CC_EXECUTABLE_PATH"
882
- );
1123
+ const ccvOptionsService = yield* CcvOptionsService;
1124
+ const specifiedExecutablePath = yield* ccvOptionsService.getCcvOptions("executable");
883
1125
  if (specifiedExecutablePath !== void 0) {
884
1126
  return path.resolve(specifiedExecutablePath);
885
1127
  }
886
1128
  const claudePaths = yield* Command.string(
887
1129
  Command.make("which", "-a", "claude").pipe(Command.runInShell(true))
888
1130
  ).pipe(
889
- Effect10.map(
1131
+ Effect11.map(
890
1132
  (output) => output.split("\n").map((line) => line.trim()).filter((line) => line !== "") ?? []
891
1133
  ),
892
- Effect10.map(
1134
+ Effect11.map(
893
1135
  (paths) => uniq(paths).toSorted((a, b) => {
894
1136
  const aPriority = claudeCodePathPriority(a);
895
1137
  const bPriority = claudeCodePathPriority(b);
@@ -902,11 +1144,11 @@ var resolveClaudeCodePath = Effect10.gen(function* () {
902
1144
  return 0;
903
1145
  })
904
1146
  ),
905
- Effect10.catchAll(() => Effect10.succeed([]))
1147
+ Effect11.catchAll(() => Effect11.succeed([]))
906
1148
  );
907
1149
  const resolvedClaudePath = claudePaths.at(0);
908
1150
  if (resolvedClaudePath === void 0) {
909
- return yield* Effect10.fail(
1151
+ return yield* Effect11.fail(
910
1152
  new ClaudeCodePathNotFoundError({
911
1153
  message: "Claude Code CLI not found in any location"
912
1154
  })
@@ -914,7 +1156,7 @@ var resolveClaudeCodePath = Effect10.gen(function* () {
914
1156
  }
915
1157
  return resolvedClaudePath;
916
1158
  });
917
- var Config = Effect10.gen(function* () {
1159
+ var Config = Effect11.gen(function* () {
918
1160
  const claudeCodeExecutablePath = yield* resolveClaudeCodePath;
919
1161
  const claudeCodeVersion = fromCLIString(
920
1162
  yield* Command.string(Command.make(claudeCodeExecutablePath, "--version"))
@@ -924,7 +1166,7 @@ var Config = Effect10.gen(function* () {
924
1166
  claudeCodeVersion
925
1167
  };
926
1168
  });
927
- var getMcpListOutput = (projectCwd) => Effect10.gen(function* () {
1169
+ var getMcpListOutput = (projectCwd) => Effect11.gen(function* () {
928
1170
  const { claudeCodeExecutablePath } = yield* Config;
929
1171
  const output = yield* Command.string(
930
1172
  Command.make(
@@ -964,7 +1206,7 @@ var getAvailableFeatures = (claudeCodeVersion) => ({
964
1206
  });
965
1207
  var query = (prompt, options) => {
966
1208
  const { canUseTool, permissionMode, ...baseOptions } = options;
967
- return Effect10.gen(function* () {
1209
+ return Effect11.gen(function* () {
968
1210
  const { claudeCodeExecutablePath, claudeCodeVersion } = yield* Config;
969
1211
  const availableFeatures = getAvailableFeatures(claudeCodeVersion);
970
1212
  const options2 = {
@@ -1014,23 +1256,23 @@ var ProjectPathNotFoundError = class extends Data2.TaggedError(
1014
1256
  "ProjectPathNotFoundError"
1015
1257
  ) {
1016
1258
  };
1017
- var LayerImpl8 = Effect11.gen(function* () {
1259
+ var LayerImpl8 = Effect12.gen(function* () {
1018
1260
  const projectRepository = yield* ProjectRepository;
1019
- const getClaudeCodeMeta = () => Effect11.gen(function* () {
1261
+ const getClaudeCodeMeta = () => Effect12.gen(function* () {
1020
1262
  const config = yield* Config;
1021
1263
  return config;
1022
1264
  });
1023
- const getAvailableFeatures2 = () => Effect11.gen(function* () {
1265
+ const getAvailableFeatures2 = () => Effect12.gen(function* () {
1024
1266
  const config = yield* Config;
1025
1267
  const features = getAvailableFeatures(
1026
1268
  config.claudeCodeVersion
1027
1269
  );
1028
1270
  return features;
1029
1271
  });
1030
- const getMcpList = (projectId) => Effect11.gen(function* () {
1272
+ const getMcpList = (projectId) => Effect12.gen(function* () {
1031
1273
  const { project } = yield* projectRepository.getProject(projectId);
1032
1274
  if (project.meta.projectPath === null) {
1033
- return yield* Effect11.fail(new ProjectPathNotFoundError({ projectId }));
1275
+ return yield* Effect12.fail(new ProjectPathNotFoundError({ projectId }));
1034
1276
  }
1035
1277
  const output = yield* getMcpListOutput(
1036
1278
  project.meta.projectPath
@@ -1050,17 +1292,17 @@ var ClaudeCodeService = class extends Context8.Tag("ClaudeCodeService")() {
1050
1292
  };
1051
1293
 
1052
1294
  // src/server/core/claude-code/presentation/ClaudeCodeController.ts
1053
- var LayerImpl9 = Effect12.gen(function* () {
1295
+ var LayerImpl9 = Effect13.gen(function* () {
1054
1296
  const projectRepository = yield* ProjectRepository;
1055
1297
  const claudeCodeService = yield* ClaudeCodeService;
1056
1298
  const context = yield* ApplicationContext;
1057
1299
  yield* FileSystem6.FileSystem;
1058
1300
  const path = yield* Path8.Path;
1059
- const getClaudeCommands = (options) => Effect12.gen(function* () {
1301
+ const getClaudeCommands = (options) => Effect13.gen(function* () {
1060
1302
  const { projectId } = options;
1061
1303
  const { project } = yield* projectRepository.getProject(projectId);
1062
1304
  const globalCommands = yield* scanCommandFilesRecursively(
1063
- context.claudeCodePaths.claudeCommandsDirPath
1305
+ (yield* context.claudeCodePaths).claudeCommandsDirPath
1064
1306
  );
1065
1307
  const projectCommands = project.meta.projectPath === null ? [] : yield* scanCommandFilesRecursively(
1066
1308
  path.resolve(project.meta.projectPath, ".claude", "commands")
@@ -1074,7 +1316,7 @@ var LayerImpl9 = Effect12.gen(function* () {
1074
1316
  status: 200
1075
1317
  };
1076
1318
  });
1077
- const getMcpListRoute = (options) => Effect12.gen(function* () {
1319
+ const getMcpListRoute = (options) => Effect13.gen(function* () {
1078
1320
  const { projectId } = options;
1079
1321
  const servers = yield* claudeCodeService.getMcpList(projectId);
1080
1322
  return {
@@ -1082,7 +1324,7 @@ var LayerImpl9 = Effect12.gen(function* () {
1082
1324
  status: 200
1083
1325
  };
1084
1326
  });
1085
- const getClaudeCodeMeta = () => Effect12.gen(function* () {
1327
+ const getClaudeCodeMeta = () => Effect13.gen(function* () {
1086
1328
  const config = yield* claudeCodeService.getClaudeCodeMeta();
1087
1329
  return {
1088
1330
  response: {
@@ -1092,7 +1334,7 @@ var LayerImpl9 = Effect12.gen(function* () {
1092
1334
  status: 200
1093
1335
  };
1094
1336
  });
1095
- const getAvailableFeatures2 = () => Effect12.gen(function* () {
1337
+ const getAvailableFeatures2 = () => Effect13.gen(function* () {
1096
1338
  const features = yield* claudeCodeService.getAvailableFeatures();
1097
1339
  const featuresList = Object.entries(features).flatMap(([key, value]) => {
1098
1340
  return [
@@ -1121,15 +1363,15 @@ var ClaudeCodeController = class extends Context9.Tag("ClaudeCodeController")()
1121
1363
  };
1122
1364
 
1123
1365
  // src/server/core/claude-code/presentation/ClaudeCodePermissionController.ts
1124
- import { Context as Context12, Effect as Effect15, Layer as Layer14 } from "effect";
1366
+ import { Context as Context12, Effect as Effect16, Layer as Layer14 } from "effect";
1125
1367
 
1126
1368
  // src/server/core/claude-code/services/ClaudeCodePermissionService.ts
1127
- import { Context as Context11, Effect as Effect14, Layer as Layer13, Ref as Ref4 } from "effect";
1369
+ import { Context as Context11, Effect as Effect15, Layer as Layer13, Ref as Ref4 } from "effect";
1128
1370
  import { ulid } from "ulid";
1129
1371
 
1130
1372
  // src/server/core/events/services/EventBus.ts
1131
- import { Context as Context10, Effect as Effect13, Layer as Layer12 } from "effect";
1132
- var layerImpl = Effect13.gen(function* () {
1373
+ import { Context as Context10, Effect as Effect14, Layer as Layer12 } from "effect";
1374
+ var layerImpl = Effect14.gen(function* () {
1133
1375
  const listenersMap = /* @__PURE__ */ new Map();
1134
1376
  const getListeners = (event) => {
1135
1377
  if (!listenersMap.has(event)) {
@@ -1137,7 +1379,7 @@ var layerImpl = Effect13.gen(function* () {
1137
1379
  }
1138
1380
  return listenersMap.get(event);
1139
1381
  };
1140
- const emit = (event, data) => Effect13.gen(function* () {
1382
+ const emit = (event, data) => Effect14.gen(function* () {
1141
1383
  const listeners = getListeners(event);
1142
1384
  void Promise.allSettled(
1143
1385
  Array.from(listeners).map(async (listener) => {
@@ -1145,11 +1387,11 @@ var layerImpl = Effect13.gen(function* () {
1145
1387
  })
1146
1388
  );
1147
1389
  });
1148
- const on = (event, listener) => Effect13.sync(() => {
1390
+ const on = (event, listener) => Effect14.sync(() => {
1149
1391
  const listeners = getListeners(event);
1150
1392
  listeners.add(listener);
1151
1393
  });
1152
- const off = (event, listener) => Effect13.sync(() => {
1394
+ const off = (event, listener) => Effect14.sync(() => {
1153
1395
  const listeners = getListeners(event);
1154
1396
  listeners.delete(listener);
1155
1397
  });
@@ -1166,11 +1408,11 @@ var EventBus = class extends Context10.Tag("EventBus")() {
1166
1408
  };
1167
1409
 
1168
1410
  // src/server/core/claude-code/services/ClaudeCodePermissionService.ts
1169
- var LayerImpl10 = Effect14.gen(function* () {
1411
+ var LayerImpl10 = Effect15.gen(function* () {
1170
1412
  const pendingPermissionRequestsRef = yield* Ref4.make(/* @__PURE__ */ new Map());
1171
1413
  const permissionResponsesRef = yield* Ref4.make(/* @__PURE__ */ new Map());
1172
1414
  const eventBus = yield* EventBus;
1173
- const waitPermissionResponse = (request, options) => Effect14.gen(function* () {
1415
+ const waitPermissionResponse = (request, options) => Effect15.gen(function* () {
1174
1416
  yield* Ref4.update(pendingPermissionRequestsRef, (requests) => {
1175
1417
  requests.set(request.id, request);
1176
1418
  return requests;
@@ -1186,14 +1428,14 @@ var LayerImpl10 = Effect14.gen(function* () {
1186
1428
  if (response !== null) {
1187
1429
  break;
1188
1430
  }
1189
- yield* Effect14.sleep(1e3);
1431
+ yield* Effect15.sleep(1e3);
1190
1432
  passedMs += 1e3;
1191
1433
  }
1192
1434
  return response;
1193
1435
  });
1194
1436
  const createCanUseToolRelatedOptions = (options) => {
1195
1437
  const { taskId, userConfig, sessionId } = options;
1196
- return Effect14.gen(function* () {
1438
+ return Effect15.gen(function* () {
1197
1439
  const claudeCodeConfig = yield* Config;
1198
1440
  if (!getAvailableFeatures(claudeCodeConfig.claudeCodeVersion).canUseTool) {
1199
1441
  return {
@@ -1222,7 +1464,7 @@ var LayerImpl10 = Effect14.gen(function* () {
1222
1464
  toolInput,
1223
1465
  timestamp: Date.now()
1224
1466
  };
1225
- const response = await Effect14.runPromise(
1467
+ const response = await Effect15.runPromise(
1226
1468
  waitPermissionResponse(permissionRequest, { timeoutMs: 6e4 })
1227
1469
  );
1228
1470
  if (response === null) {
@@ -1249,7 +1491,7 @@ var LayerImpl10 = Effect14.gen(function* () {
1249
1491
  };
1250
1492
  });
1251
1493
  };
1252
- const respondToPermissionRequest = (response) => Effect14.gen(function* () {
1494
+ const respondToPermissionRequest = (response) => Effect15.gen(function* () {
1253
1495
  yield* Ref4.update(permissionResponsesRef, (responses) => {
1254
1496
  responses.set(response.permissionRequestId, response);
1255
1497
  return responses;
@@ -1273,11 +1515,11 @@ var ClaudeCodePermissionService = class extends Context11.Tag(
1273
1515
  };
1274
1516
 
1275
1517
  // src/server/core/claude-code/presentation/ClaudeCodePermissionController.ts
1276
- var LayerImpl11 = Effect15.gen(function* () {
1518
+ var LayerImpl11 = Effect16.gen(function* () {
1277
1519
  const claudeCodePermissionService = yield* ClaudeCodePermissionService;
1278
- const permissionResponse = (options) => Effect15.sync(() => {
1520
+ const permissionResponse = (options) => Effect16.sync(() => {
1279
1521
  const { permissionResponse: permissionResponse2 } = options;
1280
- Effect15.runFork(
1522
+ Effect16.runFork(
1281
1523
  claudeCodePermissionService.respondToPermissionRequest(
1282
1524
  permissionResponse2
1283
1525
  )
@@ -1302,10 +1544,10 @@ var ClaudeCodePermissionController = class extends Context12.Tag(
1302
1544
  };
1303
1545
 
1304
1546
  // src/server/core/claude-code/presentation/ClaudeCodeSessionProcessController.ts
1305
- import { Context as Context19, Effect as Effect24, Layer as Layer21 } from "effect";
1547
+ import { Context as Context19, Effect as Effect25, Layer as Layer21 } from "effect";
1306
1548
 
1307
1549
  // src/server/core/platform/services/UserConfigService.ts
1308
- import { Context as Context13, Effect as Effect16, Layer as Layer15, Ref as Ref5 } from "effect";
1550
+ import { Context as Context13, Effect as Effect17, Layer as Layer15, Ref as Ref5 } from "effect";
1309
1551
 
1310
1552
  // src/lib/i18n/localeDetection.ts
1311
1553
  var DEFAULT_LOCALE = "en";
@@ -1357,7 +1599,7 @@ var detectLocaleFromAcceptLanguage = (header) => {
1357
1599
  };
1358
1600
 
1359
1601
  // src/server/core/platform/services/UserConfigService.ts
1360
- var LayerImpl12 = Effect16.gen(function* () {
1602
+ var LayerImpl12 = Effect17.gen(function* () {
1361
1603
  const configRef = yield* Ref5.make({
1362
1604
  hideNoUserMessageSession: true,
1363
1605
  unifySameTitleSession: false,
@@ -1366,10 +1608,10 @@ var LayerImpl12 = Effect16.gen(function* () {
1366
1608
  locale: DEFAULT_LOCALE,
1367
1609
  theme: "system"
1368
1610
  });
1369
- const setUserConfig = (newConfig) => Effect16.gen(function* () {
1611
+ const setUserConfig = (newConfig) => Effect17.gen(function* () {
1370
1612
  yield* Ref5.update(configRef, () => newConfig);
1371
1613
  });
1372
- const getUserConfig = () => Effect16.gen(function* () {
1614
+ const getUserConfig = () => Effect17.gen(function* () {
1373
1615
  const config = yield* Ref5.get(configRef);
1374
1616
  return config;
1375
1617
  });
@@ -1385,7 +1627,7 @@ var UserConfigService = class extends Context13.Tag("UserConfigService")() {
1385
1627
  };
1386
1628
 
1387
1629
  // src/server/core/claude-code/services/ClaudeCodeLifeCycleService.ts
1388
- import { Context as Context18, Effect as Effect23, Layer as Layer20, Runtime as Runtime2 } from "effect";
1630
+ import { Context as Context18, Effect as Effect24, Layer as Layer20, Runtime as Runtime2 } from "effect";
1389
1631
  import { ulid as ulid2 } from "ulid";
1390
1632
 
1391
1633
  // src/lib/controllablePromise.ts
@@ -1416,29 +1658,29 @@ var controllablePromise = () => {
1416
1658
 
1417
1659
  // src/server/core/session/infrastructure/SessionRepository.ts
1418
1660
  import { FileSystem as FileSystem9, Path as Path11 } from "@effect/platform";
1419
- import { Context as Context16, Effect as Effect20, Layer as Layer18, Option as Option3 } from "effect";
1661
+ import { Context as Context16, Effect as Effect21, Layer as Layer18, Option as Option3 } from "effect";
1420
1662
 
1421
1663
  // src/server/core/claude-code/functions/parseUserMessage.ts
1422
- import { z as z21 } from "zod";
1664
+ import { z as z20 } from "zod";
1423
1665
  var regExp = /<(?<tag>[^>]+)>(?<content>\s*[^<]*?\s*)<\/\k<tag>>/g;
1424
- var matchSchema = z21.object({
1425
- tag: z21.string(),
1426
- content: z21.string()
1666
+ var matchSchema = z20.object({
1667
+ tag: z20.string(),
1668
+ content: z20.string()
1427
1669
  });
1428
- var parsedUserMessageSchema = z21.union([
1429
- z21.object({
1430
- kind: z21.literal("command"),
1431
- commandName: z21.string(),
1432
- commandArgs: z21.string().optional(),
1433
- commandMessage: z21.string().optional()
1670
+ var parsedUserMessageSchema = z20.union([
1671
+ z20.object({
1672
+ kind: z20.literal("command"),
1673
+ commandName: z20.string(),
1674
+ commandArgs: z20.string().optional(),
1675
+ commandMessage: z20.string().optional()
1434
1676
  }),
1435
- z21.object({
1436
- kind: z21.literal("local-command"),
1437
- stdout: z21.string()
1677
+ z20.object({
1678
+ kind: z20.literal("local-command"),
1679
+ stdout: z20.string()
1438
1680
  }),
1439
- z21.object({
1440
- kind: z21.literal("text"),
1441
- content: z21.string()
1681
+ z20.object({
1682
+ kind: z20.literal("text"),
1683
+ content: z20.string()
1442
1684
  })
1443
1685
  ]);
1444
1686
  var parseUserMessage = (content) => {
@@ -1496,28 +1738,28 @@ var decodeSessionId = (projectId, sessionId) => {
1496
1738
  var isRegularSessionFile = (filename) => filename.endsWith(".jsonl") && !filename.startsWith("agent-");
1497
1739
 
1498
1740
  // src/server/core/session/infrastructure/VirtualConversationDatabase.ts
1499
- import { Context as Context14, Effect as Effect17, Layer as Layer16, Ref as Ref6 } from "effect";
1741
+ import { Context as Context14, Effect as Effect18, Layer as Layer16, Ref as Ref6 } from "effect";
1500
1742
  var VirtualConversationDatabase = class extends Context14.Tag(
1501
1743
  "VirtualConversationDatabase"
1502
1744
  )() {
1503
1745
  static {
1504
1746
  this.Live = Layer16.effect(
1505
1747
  this,
1506
- Effect17.gen(function* () {
1748
+ Effect18.gen(function* () {
1507
1749
  const storageRef = yield* Ref6.make([]);
1508
- const getProjectVirtualConversations = (projectId) => Effect17.gen(function* () {
1750
+ const getProjectVirtualConversations = (projectId) => Effect18.gen(function* () {
1509
1751
  const conversations = yield* Ref6.get(storageRef);
1510
1752
  return conversations.filter(
1511
1753
  (conversation) => conversation.projectId === projectId
1512
1754
  );
1513
1755
  });
1514
- const getSessionVirtualConversation = (sessionId) => Effect17.gen(function* () {
1756
+ const getSessionVirtualConversation = (sessionId) => Effect18.gen(function* () {
1515
1757
  const conversations = yield* Ref6.get(storageRef);
1516
1758
  return conversations.find(
1517
1759
  (conversation) => conversation.sessionId === sessionId
1518
1760
  ) ?? null;
1519
1761
  });
1520
- const createVirtualConversation2 = (projectId, sessionId, createConversations) => Effect17.gen(function* () {
1762
+ const createVirtualConversation2 = (projectId, sessionId, createConversations) => Effect18.gen(function* () {
1521
1763
  yield* Ref6.update(storageRef, (conversations) => {
1522
1764
  const existingRecord = conversations.find(
1523
1765
  (record) => record.projectId === projectId && record.sessionId === sessionId
@@ -1536,7 +1778,7 @@ var VirtualConversationDatabase = class extends Context14.Tag(
1536
1778
  return conversations;
1537
1779
  });
1538
1780
  });
1539
- const deleteVirtualConversations = (sessionId) => Effect17.gen(function* () {
1781
+ const deleteVirtualConversations = (sessionId) => Effect18.gen(function* () {
1540
1782
  yield* Ref6.update(storageRef, (conversations) => {
1541
1783
  return conversations.filter((c) => c.sessionId !== sessionId);
1542
1784
  });
@@ -1554,7 +1796,7 @@ var VirtualConversationDatabase = class extends Context14.Tag(
1554
1796
 
1555
1797
  // src/server/core/session/services/SessionMetaService.ts
1556
1798
  import { FileSystem as FileSystem8, Path as Path10 } from "@effect/platform";
1557
- import { Context as Context15, Effect as Effect19, Layer as Layer17, Ref as Ref7 } from "effect";
1799
+ import { Context as Context15, Effect as Effect20, Layer as Layer17, Ref as Ref7 } from "effect";
1558
1800
 
1559
1801
  // src/server/core/session/constants/pricing.ts
1560
1802
  var MODEL_PRICING = {
@@ -1715,8 +1957,8 @@ var aggregateTokenUsageAndCost = (fileContents) => {
1715
1957
 
1716
1958
  // src/server/core/session/functions/getAgentSessionFilesForSession.ts
1717
1959
  import { FileSystem as FileSystem7, Path as Path9 } from "@effect/platform";
1718
- import { Effect as Effect18 } from "effect";
1719
- var getAgentSessionFilesForSession = (projectPath, sessionId) => Effect18.gen(function* () {
1960
+ import { Effect as Effect19 } from "effect";
1961
+ var getAgentSessionFilesForSession = (projectPath, sessionId) => Effect19.gen(function* () {
1720
1962
  const fs = yield* FileSystem7.FileSystem;
1721
1963
  const path = yield* Path9.Path;
1722
1964
  const entries = yield* fs.readDirectory(projectPath);
@@ -1726,7 +1968,7 @@ var getAgentSessionFilesForSession = (projectPath, sessionId) => Effect18.gen(fu
1726
1968
  const matchingFilePaths = [];
1727
1969
  for (const agentFile of agentFiles) {
1728
1970
  const filePath = path.join(projectPath, agentFile);
1729
- const maybeMatches = yield* Effect18.gen(function* () {
1971
+ const maybeMatches = yield* Effect19.gen(function* () {
1730
1972
  const content = yield* fs.readFileString(filePath);
1731
1973
  const firstLine = content.split("\n")[0];
1732
1974
  if (!firstLine || firstLine.trim() === "") {
@@ -1742,7 +1984,7 @@ var getAgentSessionFilesForSession = (projectPath, sessionId) => Effect18.gen(fu
1742
1984
  }
1743
1985
  return false;
1744
1986
  }).pipe(
1745
- Effect18.catchAll(() => Effect18.succeed(false))
1987
+ Effect19.catchAll(() => Effect19.succeed(false))
1746
1988
  // On any error, skip this file
1747
1989
  );
1748
1990
  if (maybeMatches) {
@@ -1809,14 +2051,14 @@ var SessionMetaService = class extends Context15.Tag("SessionMetaService")() {
1809
2051
  static {
1810
2052
  this.Live = Layer17.effect(
1811
2053
  this,
1812
- Effect19.gen(function* () {
2054
+ Effect20.gen(function* () {
1813
2055
  const fs = yield* FileSystem8.FileSystem;
1814
2056
  const path = yield* Path10.Path;
1815
2057
  const firstUserMessageCache = yield* FileCacheStorage();
1816
2058
  const sessionMetaCacheRef = yield* Ref7.make(
1817
2059
  /* @__PURE__ */ new Map()
1818
2060
  );
1819
- const getFirstUserMessage = (jsonlFilePath, lines) => Effect19.gen(function* () {
2061
+ const getFirstUserMessage = (jsonlFilePath, lines) => Effect20.gen(function* () {
1820
2062
  const cached = yield* firstUserMessageCache.get(jsonlFilePath);
1821
2063
  if (cached !== void 0) {
1822
2064
  return cached;
@@ -1839,7 +2081,7 @@ var SessionMetaService = class extends Context15.Tag("SessionMetaService")() {
1839
2081
  }
1840
2082
  return firstUserMessage;
1841
2083
  });
1842
- const getSessionMeta = (projectId, sessionId) => Effect19.gen(function* () {
2084
+ const getSessionMeta = (projectId, sessionId) => Effect20.gen(function* () {
1843
2085
  const metaCache = yield* Ref7.get(sessionMetaCacheRef);
1844
2086
  const cached = metaCache.get(sessionId);
1845
2087
  if (cached !== void 0) {
@@ -1868,12 +2110,12 @@ var SessionMetaService = class extends Context15.Tag("SessionMetaService")() {
1868
2110
  projectPath,
1869
2111
  actualSessionId
1870
2112
  ).pipe(
1871
- Effect19.provide(Layer17.succeed(FileSystem8.FileSystem, fs)),
1872
- Effect19.provide(Layer17.succeed(Path10.Path, path))
2113
+ Effect20.provide(Layer17.succeed(FileSystem8.FileSystem, fs)),
2114
+ Effect20.provide(Layer17.succeed(Path10.Path, path))
1873
2115
  ) : [];
1874
2116
  const agentContents = [];
1875
2117
  for (const agentPath of agentFilePaths) {
1876
- const agentContent = yield* fs.readFileString(agentPath).pipe(Effect19.catchAll(() => Effect19.succeed("")));
2118
+ const agentContent = yield* fs.readFileString(agentPath).pipe(Effect20.catchAll(() => Effect20.succeed("")));
1877
2119
  if (agentContent !== "") {
1878
2120
  agentContents.push(agentContent);
1879
2121
  }
@@ -1895,7 +2137,7 @@ var SessionMetaService = class extends Context15.Tag("SessionMetaService")() {
1895
2137
  });
1896
2138
  return sessionMeta;
1897
2139
  });
1898
- const invalidateSession = (_projectId, sessionId) => Effect19.gen(function* () {
2140
+ const invalidateSession = (_projectId, sessionId) => Effect20.gen(function* () {
1899
2141
  yield* Ref7.update(sessionMetaCacheRef, (cache) => {
1900
2142
  cache.delete(sessionId);
1901
2143
  return cache;
@@ -1919,18 +2161,18 @@ var SessionMetaService = class extends Context15.Tag("SessionMetaService")() {
1919
2161
  };
1920
2162
 
1921
2163
  // src/server/core/session/infrastructure/SessionRepository.ts
1922
- var LayerImpl13 = Effect20.gen(function* () {
2164
+ var LayerImpl13 = Effect21.gen(function* () {
1923
2165
  const fs = yield* FileSystem9.FileSystem;
1924
2166
  const path = yield* Path11.Path;
1925
2167
  const sessionMetaService = yield* SessionMetaService;
1926
2168
  const virtualConversationDatabase = yield* VirtualConversationDatabase;
1927
- const getSession = (projectId, sessionId) => Effect20.gen(function* () {
2169
+ const getSession = (projectId, sessionId) => Effect21.gen(function* () {
1928
2170
  const sessionPath = decodeSessionId(projectId, sessionId);
1929
2171
  const virtualConversation = yield* virtualConversationDatabase.getSessionVirtualConversation(
1930
2172
  sessionId
1931
2173
  );
1932
2174
  const exists = yield* fs.exists(sessionPath);
1933
- const sessionDetail = yield* exists ? Effect20.gen(function* () {
2175
+ const sessionDetail = yield* exists ? Effect21.gen(function* () {
1934
2176
  const content = yield* fs.readFileString(sessionPath);
1935
2177
  const allLines = content.split("\n").filter((line) => line.trim());
1936
2178
  const conversations = parseJsonl(allLines.join("\n"));
@@ -1968,7 +2210,7 @@ var LayerImpl13 = Effect20.gen(function* () {
1968
2210
  return sessionDetail2;
1969
2211
  }) : (() => {
1970
2212
  if (virtualConversation === null) {
1971
- return Effect20.succeed(null);
2213
+ return Effect21.succeed(null);
1972
2214
  }
1973
2215
  const lastConversation = virtualConversation.conversations.filter(
1974
2216
  (conversation) => conversation.type === "user" || conversation.type === "assistant" || conversation.type === "system"
@@ -1998,13 +2240,13 @@ var LayerImpl13 = Effect20.gen(function* () {
1998
2240
  conversations: virtualConversation.conversations,
1999
2241
  lastModifiedAt: lastConversation !== void 0 ? new Date(lastConversation.timestamp) : /* @__PURE__ */ new Date()
2000
2242
  };
2001
- return Effect20.succeed(virtualSession);
2243
+ return Effect21.succeed(virtualSession);
2002
2244
  })();
2003
2245
  return {
2004
2246
  session: sessionDetail
2005
2247
  };
2006
2248
  });
2007
- const getSessions = (projectId, options) => Effect20.gen(function* () {
2249
+ const getSessions = (projectId, options) => Effect21.gen(function* () {
2008
2250
  const { maxCount = 20, cursor } = options ?? {};
2009
2251
  const claudeProjectPath = decodeProjectId(projectId);
2010
2252
  const dirExists = yield* fs.exists(claudeProjectPath);
@@ -2012,8 +2254,8 @@ var LayerImpl13 = Effect20.gen(function* () {
2012
2254
  console.warn(`Project directory not found at ${claudeProjectPath}`);
2013
2255
  return { sessions: [] };
2014
2256
  }
2015
- const dirents = yield* Effect20.tryPromise({
2016
- try: () => fs.readDirectory(claudeProjectPath).pipe(Effect20.runPromise),
2257
+ const dirents = yield* Effect21.tryPromise({
2258
+ try: () => fs.readDirectory(claudeProjectPath).pipe(Effect21.runPromise),
2017
2259
  catch: (error) => {
2018
2260
  console.warn(
2019
2261
  `Failed to read sessions for project ${projectId}:`,
@@ -2021,14 +2263,14 @@ var LayerImpl13 = Effect20.gen(function* () {
2021
2263
  );
2022
2264
  return new Error("Failed to read directory");
2023
2265
  }
2024
- }).pipe(Effect20.catchAll(() => Effect20.succeed([])));
2266
+ }).pipe(Effect21.catchAll(() => Effect21.succeed([])));
2025
2267
  const sessionEffects = dirents.filter(isRegularSessionFile).map(
2026
- (entry) => Effect20.gen(function* () {
2268
+ (entry) => Effect21.gen(function* () {
2027
2269
  const fullPath = path.resolve(claudeProjectPath, entry);
2028
2270
  const sessionId = encodeSessionId(fullPath);
2029
- const stat = yield* Effect20.tryPromise(
2030
- () => fs.stat(fullPath).pipe(Effect20.runPromise)
2031
- ).pipe(Effect20.catchAll(() => Effect20.succeed(null)));
2271
+ const stat = yield* Effect21.tryPromise(
2272
+ () => fs.stat(fullPath).pipe(Effect21.runPromise)
2273
+ ).pipe(Effect21.catchAll(() => Effect21.succeed(null)));
2032
2274
  if (!stat) {
2033
2275
  return null;
2034
2276
  }
@@ -2039,7 +2281,7 @@ var LayerImpl13 = Effect20.gen(function* () {
2039
2281
  };
2040
2282
  })
2041
2283
  );
2042
- const sessionsWithNulls = yield* Effect20.all(sessionEffects, {
2284
+ const sessionsWithNulls = yield* Effect21.all(sessionEffects, {
2043
2285
  concurrency: "unbounded"
2044
2286
  });
2045
2287
  const sessions = sessionsWithNulls.filter((s) => s !== null).sort(
@@ -2054,9 +2296,9 @@ var LayerImpl13 = Effect20.gen(function* () {
2054
2296
  index + 1,
2055
2297
  Math.min(index + 1 + maxCount, sessions.length)
2056
2298
  );
2057
- const sessionsWithMeta2 = yield* Effect20.all(
2299
+ const sessionsWithMeta2 = yield* Effect21.all(
2058
2300
  sessionsToReturn2.map(
2059
- (item) => Effect20.gen(function* () {
2301
+ (item) => Effect21.gen(function* () {
2060
2302
  const meta = yield* sessionMetaService.getSessionMeta(
2061
2303
  projectId,
2062
2304
  item.id
@@ -2119,9 +2361,9 @@ var LayerImpl13 = Effect20.gen(function* () {
2119
2361
  0,
2120
2362
  Math.min(maxCount, sessions.length)
2121
2363
  );
2122
- const sessionsWithMeta = yield* Effect20.all(
2364
+ const sessionsWithMeta = yield* Effect21.all(
2123
2365
  sessionsToReturn.map(
2124
- (item) => Effect20.gen(function* () {
2366
+ (item) => Effect21.gen(function* () {
2125
2367
  const meta = yield* sessionMetaService.getSessionMeta(
2126
2368
  projectId,
2127
2369
  item.id
@@ -2245,7 +2487,7 @@ var fallbackSdkMessage = (message) => {
2245
2487
  };
2246
2488
 
2247
2489
  // src/server/core/claude-code/models/CCSessionProcess.ts
2248
- import { Effect as Effect21 } from "effect";
2490
+ import { Effect as Effect22 } from "effect";
2249
2491
  var isPublic = (process2) => {
2250
2492
  return process2.type === "initialized" || process2.type === "file_created" || process2.type === "paused";
2251
2493
  };
@@ -2256,7 +2498,7 @@ var getAliveTasks = (process2) => {
2256
2498
  };
2257
2499
  var createVirtualConversation = (process2, ctx) => {
2258
2500
  const timestamp = (/* @__PURE__ */ new Date()).toISOString();
2259
- return Effect21.gen(function* () {
2501
+ return Effect22.gen(function* () {
2260
2502
  const config = yield* Config;
2261
2503
  const virtualConversation = {
2262
2504
  type: "user",
@@ -2278,7 +2520,7 @@ var createVirtualConversation = (process2, ctx) => {
2278
2520
  };
2279
2521
 
2280
2522
  // src/server/core/claude-code/services/ClaudeCodeSessionProcessService.ts
2281
- import { Context as Context17, Data as Data3, Effect as Effect22, Layer as Layer19, Ref as Ref8 } from "effect";
2523
+ import { Context as Context17, Data as Data3, Effect as Effect23, Layer as Layer19, Ref as Ref8 } from "effect";
2282
2524
  var SessionProcessNotFoundError = class extends Data3.TaggedError(
2283
2525
  "SessionProcessNotFoundError"
2284
2526
  ) {
@@ -2297,12 +2539,12 @@ var IllegalStateChangeError = class extends Data3.TaggedError(
2297
2539
  };
2298
2540
  var TaskNotFoundError = class extends Data3.TaggedError("TaskNotFoundError") {
2299
2541
  };
2300
- var LayerImpl14 = Effect22.gen(function* () {
2542
+ var LayerImpl14 = Effect23.gen(function* () {
2301
2543
  const processesRef = yield* Ref8.make([]);
2302
2544
  const eventBus = yield* EventBus;
2303
2545
  const startSessionProcess = (options) => {
2304
2546
  const { sessionDef, taskDef } = options;
2305
- return Effect22.gen(function* () {
2547
+ return Effect23.gen(function* () {
2306
2548
  const task = {
2307
2549
  def: taskDef,
2308
2550
  status: "pending"
@@ -2325,10 +2567,10 @@ var LayerImpl14 = Effect22.gen(function* () {
2325
2567
  };
2326
2568
  const continueSessionProcess = (options) => {
2327
2569
  const { sessionProcessId } = options;
2328
- return Effect22.gen(function* () {
2570
+ return Effect23.gen(function* () {
2329
2571
  const process2 = yield* getSessionProcess(sessionProcessId);
2330
2572
  if (process2.type !== "paused") {
2331
- return yield* Effect22.fail(
2573
+ return yield* Effect23.fail(
2332
2574
  new SessionProcessNotPausedError({
2333
2575
  sessionProcessId
2334
2576
  })
@@ -2336,7 +2578,7 @@ var LayerImpl14 = Effect22.gen(function* () {
2336
2578
  }
2337
2579
  const [firstAliveTask] = getAliveTasks(process2);
2338
2580
  if (firstAliveTask !== void 0) {
2339
- return yield* Effect22.fail(
2581
+ return yield* Effect23.fail(
2340
2582
  new SessionProcessAlreadyAliveError({
2341
2583
  sessionProcessId,
2342
2584
  aliveTaskId: firstAliveTask.def.taskId,
@@ -2366,13 +2608,13 @@ var LayerImpl14 = Effect22.gen(function* () {
2366
2608
  });
2367
2609
  };
2368
2610
  const getSessionProcess = (sessionProcessId) => {
2369
- return Effect22.gen(function* () {
2611
+ return Effect23.gen(function* () {
2370
2612
  const processes = yield* Ref8.get(processesRef);
2371
2613
  const result = processes.find(
2372
2614
  (p) => p.def.sessionProcessId === sessionProcessId
2373
2615
  );
2374
2616
  if (result === void 0) {
2375
- return yield* Effect22.fail(
2617
+ return yield* Effect23.fail(
2376
2618
  new SessionProcessNotFoundError({ sessionProcessId })
2377
2619
  );
2378
2620
  }
@@ -2380,13 +2622,13 @@ var LayerImpl14 = Effect22.gen(function* () {
2380
2622
  });
2381
2623
  };
2382
2624
  const getSessionProcesses = () => {
2383
- return Effect22.gen(function* () {
2625
+ return Effect23.gen(function* () {
2384
2626
  const processes = yield* Ref8.get(processesRef);
2385
2627
  return processes;
2386
2628
  });
2387
2629
  };
2388
2630
  const getTask = (taskId) => {
2389
- return Effect22.gen(function* () {
2631
+ return Effect23.gen(function* () {
2390
2632
  const processes = yield* Ref8.get(processesRef);
2391
2633
  const result = processes.flatMap((p) => {
2392
2634
  const found = p.tasks.find((t) => t.def.taskId === taskId);
@@ -2401,14 +2643,14 @@ var LayerImpl14 = Effect22.gen(function* () {
2401
2643
  ];
2402
2644
  }).at(0);
2403
2645
  if (result === void 0) {
2404
- return yield* Effect22.fail(new TaskNotFoundError({ taskId }));
2646
+ return yield* Effect23.fail(new TaskNotFoundError({ taskId }));
2405
2647
  }
2406
2648
  return result;
2407
2649
  });
2408
2650
  };
2409
2651
  const dangerouslyChangeProcessState = (options) => {
2410
2652
  const { sessionProcessId, nextState } = options;
2411
- return Effect22.gen(function* () {
2653
+ return Effect23.gen(function* () {
2412
2654
  const processes = yield* Ref8.get(processesRef);
2413
2655
  const targetProcess = processes.find(
2414
2656
  (p) => p.def.sessionProcessId === sessionProcessId
@@ -2437,7 +2679,7 @@ var LayerImpl14 = Effect22.gen(function* () {
2437
2679
  };
2438
2680
  const changeTaskState = (options) => {
2439
2681
  const { sessionProcessId, taskId, nextTask } = options;
2440
- return Effect22.gen(function* () {
2682
+ return Effect23.gen(function* () {
2441
2683
  const { task } = yield* getTask(taskId);
2442
2684
  yield* Ref8.update(processesRef, (processes) => {
2443
2685
  return processes.map(
@@ -2458,10 +2700,10 @@ var LayerImpl14 = Effect22.gen(function* () {
2458
2700
  };
2459
2701
  const toNotInitializedState = (options) => {
2460
2702
  const { sessionProcessId, rawUserMessage } = options;
2461
- return Effect22.gen(function* () {
2703
+ return Effect23.gen(function* () {
2462
2704
  const currentProcess = yield* getSessionProcess(sessionProcessId);
2463
2705
  if (currentProcess.type !== "pending") {
2464
- return yield* Effect22.fail(
2706
+ return yield* Effect23.fail(
2465
2707
  new IllegalStateChangeError({
2466
2708
  from: currentProcess.type,
2467
2709
  to: "not_initialized"
@@ -2494,10 +2736,10 @@ var LayerImpl14 = Effect22.gen(function* () {
2494
2736
  };
2495
2737
  const toInitializedState = (options) => {
2496
2738
  const { sessionProcessId, initContext } = options;
2497
- return Effect22.gen(function* () {
2739
+ return Effect23.gen(function* () {
2498
2740
  const currentProcess = yield* getSessionProcess(sessionProcessId);
2499
2741
  if (currentProcess.type !== "not_initialized") {
2500
- return yield* Effect22.fail(
2742
+ return yield* Effect23.fail(
2501
2743
  new IllegalStateChangeError({
2502
2744
  from: currentProcess.type,
2503
2745
  to: "initialized"
@@ -2523,10 +2765,10 @@ var LayerImpl14 = Effect22.gen(function* () {
2523
2765
  };
2524
2766
  const toFileCreatedState = (options) => {
2525
2767
  const { sessionProcessId } = options;
2526
- return Effect22.gen(function* () {
2768
+ return Effect23.gen(function* () {
2527
2769
  const currentProcess = yield* getSessionProcess(sessionProcessId);
2528
2770
  if (currentProcess.type !== "initialized") {
2529
- return yield* Effect22.fail(
2771
+ return yield* Effect23.fail(
2530
2772
  new IllegalStateChangeError({
2531
2773
  from: currentProcess.type,
2532
2774
  to: "file_created"
@@ -2552,10 +2794,10 @@ var LayerImpl14 = Effect22.gen(function* () {
2552
2794
  };
2553
2795
  const toPausedState = (options) => {
2554
2796
  const { sessionProcessId, resultMessage } = options;
2555
- return Effect22.gen(function* () {
2797
+ return Effect23.gen(function* () {
2556
2798
  const currentProcess = yield* getSessionProcess(sessionProcessId);
2557
2799
  if (currentProcess.type !== "file_created") {
2558
- return yield* Effect22.fail(
2800
+ return yield* Effect23.fail(
2559
2801
  new IllegalStateChangeError({
2560
2802
  from: currentProcess.type,
2561
2803
  to: "paused"
@@ -2589,7 +2831,7 @@ var LayerImpl14 = Effect22.gen(function* () {
2589
2831
  };
2590
2832
  const toCompletedState = (options) => {
2591
2833
  const { sessionProcessId, error } = options;
2592
- return Effect22.gen(function* () {
2834
+ return Effect23.gen(function* () {
2593
2835
  const currentProcess = yield* getSessionProcess(sessionProcessId);
2594
2836
  const currentTask = currentProcess.type === "not_initialized" || currentProcess.type === "initialized" || currentProcess.type === "file_created" ? currentProcess.currentTask : void 0;
2595
2837
  const newTask = currentTask !== void 0 ? error !== void 0 ? {
@@ -2651,16 +2893,16 @@ var ClaudeCodeSessionProcessService = class extends Context17.Tag(
2651
2893
  };
2652
2894
 
2653
2895
  // src/server/core/claude-code/services/ClaudeCodeLifeCycleService.ts
2654
- var LayerImpl15 = Effect23.gen(function* () {
2896
+ var LayerImpl15 = Effect24.gen(function* () {
2655
2897
  const eventBusService = yield* EventBus;
2656
2898
  const sessionRepository = yield* SessionRepository;
2657
2899
  const sessionProcessService = yield* ClaudeCodeSessionProcessService;
2658
2900
  const virtualConversationDatabase = yield* VirtualConversationDatabase;
2659
2901
  const permissionService = yield* ClaudeCodePermissionService;
2660
- const runtime = yield* Effect23.runtime();
2902
+ const runtime = yield* Effect24.runtime();
2661
2903
  const continueTask = (options) => {
2662
2904
  const { sessionProcessId, baseSessionId, input } = options;
2663
- return Effect23.gen(function* () {
2905
+ return Effect24.gen(function* () {
2664
2906
  const { sessionProcess, task } = yield* sessionProcessService.continueSessionProcess({
2665
2907
  sessionProcessId,
2666
2908
  taskDef: {
@@ -2688,7 +2930,7 @@ var LayerImpl15 = Effect23.gen(function* () {
2688
2930
  };
2689
2931
  const startTask = (options) => {
2690
2932
  const { baseSession, input, userConfig } = options;
2691
- return Effect23.gen(function* () {
2933
+ return Effect24.gen(function* () {
2692
2934
  const {
2693
2935
  generateMessages,
2694
2936
  setNextMessage,
@@ -2716,7 +2958,7 @@ var LayerImpl15 = Effect23.gen(function* () {
2716
2958
  const sessionFileCreatedPromise = controllablePromise();
2717
2959
  setMessageGeneratorHooks({
2718
2960
  onNewUserMessageResolved: async (input2) => {
2719
- Effect23.runFork(
2961
+ Effect24.runFork(
2720
2962
  sessionProcessService.toNotInitializedState({
2721
2963
  sessionProcessId: sessionProcess.def.sessionProcessId,
2722
2964
  rawUserMessage: input2.text
@@ -2724,7 +2966,7 @@ var LayerImpl15 = Effect23.gen(function* () {
2724
2966
  );
2725
2967
  }
2726
2968
  });
2727
- const handleMessage = (message) => Effect23.gen(function* () {
2969
+ const handleMessage = (message) => Effect24.gen(function* () {
2728
2970
  const processState = yield* sessionProcessService.getSessionProcess(
2729
2971
  sessionProcess.def.sessionProcessId
2730
2972
  );
@@ -2732,7 +2974,7 @@ var LayerImpl15 = Effect23.gen(function* () {
2732
2974
  return "break";
2733
2975
  }
2734
2976
  if (processState.type === "paused") {
2735
- yield* Effect23.die(
2977
+ yield* Effect24.die(
2736
2978
  new Error("Illegal state: paused is not expected")
2737
2979
  );
2738
2980
  }
@@ -2804,7 +3046,7 @@ var LayerImpl15 = Effect23.gen(function* () {
2804
3046
  });
2805
3047
  const handleSessionProcessDaemon = async () => {
2806
3048
  const messageIter = await Runtime2.runPromise(runtime)(
2807
- Effect23.gen(function* () {
3049
+ Effect24.gen(function* () {
2808
3050
  const permissionOptions = yield* permissionService.createCanUseToolRelatedOptions({
2809
3051
  taskId: task.def.taskId,
2810
3052
  userConfig,
@@ -2825,7 +3067,7 @@ var LayerImpl15 = Effect23.gen(function* () {
2825
3067
  const result = await Runtime2.runPromise(runtime)(
2826
3068
  handleMessage(fallbackMessage)
2827
3069
  ).catch((error) => {
2828
- Effect23.runFork(
3070
+ Effect24.runFork(
2829
3071
  sessionProcessService.changeTaskState({
2830
3072
  sessionProcessId: sessionProcess.def.sessionProcessId,
2831
3073
  taskId: task.def.taskId,
@@ -2856,7 +3098,7 @@ var LayerImpl15 = Effect23.gen(function* () {
2856
3098
  if (sessionFileCreatedPromise.status === "pending") {
2857
3099
  sessionFileCreatedPromise.reject(error);
2858
3100
  }
2859
- await Effect23.runPromise(
3101
+ await Effect24.runPromise(
2860
3102
  sessionProcessService.changeTaskState({
2861
3103
  sessionProcessId: sessionProcess.def.sessionProcessId,
2862
3104
  taskId: task.def.taskId,
@@ -2879,8 +3121,8 @@ var LayerImpl15 = Effect23.gen(function* () {
2879
3121
  }
2880
3122
  throw error;
2881
3123
  }).finally(() => {
2882
- Effect23.runFork(
2883
- Effect23.gen(function* () {
3124
+ Effect24.runFork(
3125
+ Effect24.gen(function* () {
2884
3126
  const currentProcess = yield* sessionProcessService.getSessionProcess(
2885
3127
  sessionProcess.def.sessionProcessId
2886
3128
  );
@@ -2896,16 +3138,16 @@ var LayerImpl15 = Effect23.gen(function* () {
2896
3138
  daemonPromise,
2897
3139
  awaitSessionInitialized: async () => await sessionInitializedPromise.promise,
2898
3140
  awaitSessionFileCreated: async () => await sessionFileCreatedPromise.promise,
2899
- yieldSessionInitialized: () => Effect23.promise(() => sessionInitializedPromise.promise),
2900
- yieldSessionFileCreated: () => Effect23.promise(() => sessionFileCreatedPromise.promise)
3141
+ yieldSessionInitialized: () => Effect24.promise(() => sessionInitializedPromise.promise),
3142
+ yieldSessionFileCreated: () => Effect24.promise(() => sessionFileCreatedPromise.promise)
2901
3143
  };
2902
3144
  });
2903
3145
  };
2904
- const getPublicSessionProcesses = () => Effect23.gen(function* () {
3146
+ const getPublicSessionProcesses = () => Effect24.gen(function* () {
2905
3147
  const processes = yield* sessionProcessService.getSessionProcesses();
2906
3148
  return processes.filter((process2) => isPublic(process2));
2907
3149
  });
2908
- const abortTask = (sessionProcessId) => Effect23.gen(function* () {
3150
+ const abortTask = (sessionProcessId) => Effect24.gen(function* () {
2909
3151
  const currentProcess = yield* sessionProcessService.getSessionProcess(sessionProcessId);
2910
3152
  currentProcess.def.abortController.abort();
2911
3153
  yield* sessionProcessService.toCompletedState({
@@ -2913,7 +3155,7 @@ var LayerImpl15 = Effect23.gen(function* () {
2913
3155
  error: new Error("Task aborted")
2914
3156
  });
2915
3157
  });
2916
- const abortAllTasks = () => Effect23.gen(function* () {
3158
+ const abortAllTasks = () => Effect24.gen(function* () {
2917
3159
  const processes = yield* sessionProcessService.getSessionProcesses();
2918
3160
  for (const process2 of processes) {
2919
3161
  yield* sessionProcessService.toCompletedState({
@@ -2939,11 +3181,11 @@ var ClaudeCodeLifeCycleService = class extends Context18.Tag(
2939
3181
  };
2940
3182
 
2941
3183
  // src/server/core/claude-code/presentation/ClaudeCodeSessionProcessController.ts
2942
- var LayerImpl16 = Effect24.gen(function* () {
3184
+ var LayerImpl16 = Effect25.gen(function* () {
2943
3185
  const projectRepository = yield* ProjectRepository;
2944
3186
  const claudeCodeLifeCycleService = yield* ClaudeCodeLifeCycleService;
2945
3187
  const userConfigService = yield* UserConfigService;
2946
- const getSessionProcesses = () => Effect24.gen(function* () {
3188
+ const getSessionProcesses = () => Effect25.gen(function* () {
2947
3189
  const publicSessionProcesses = yield* claudeCodeLifeCycleService.getPublicSessionProcesses();
2948
3190
  return {
2949
3191
  response: {
@@ -2959,7 +3201,7 @@ var LayerImpl16 = Effect24.gen(function* () {
2959
3201
  status: 200
2960
3202
  };
2961
3203
  });
2962
- const createSessionProcess = (options) => Effect24.gen(function* () {
3204
+ const createSessionProcess = (options) => Effect25.gen(function* () {
2963
3205
  const { projectId, input, baseSessionId } = options;
2964
3206
  const { project } = yield* projectRepository.getProject(projectId);
2965
3207
  const userConfig = yield* userConfigService.getUserConfig();
@@ -2990,7 +3232,7 @@ var LayerImpl16 = Effect24.gen(function* () {
2990
3232
  }
2991
3233
  };
2992
3234
  });
2993
- const continueSessionProcess = (options) => Effect24.gen(function* () {
3235
+ const continueSessionProcess = (options) => Effect25.gen(function* () {
2994
3236
  const { projectId, input, baseSessionId, sessionProcessId } = options;
2995
3237
  const { project } = yield* projectRepository.getProject(projectId);
2996
3238
  if (project.meta.projectPath === null) {
@@ -3030,7 +3272,7 @@ var ClaudeCodeSessionProcessController = class extends Context19.Tag(
3030
3272
  };
3031
3273
 
3032
3274
  // src/server/core/events/presentation/SSEController.ts
3033
- import { Context as Context21, Effect as Effect26, Layer as Layer23 } from "effect";
3275
+ import { Context as Context21, Effect as Effect27, Layer as Layer23 } from "effect";
3034
3276
 
3035
3277
  // src/server/core/events/functions/adaptInternalEventToSSE.ts
3036
3278
  var adaptInternalEventToSSE = (rawStream, options) => {
@@ -3057,12 +3299,12 @@ var adaptInternalEventToSSE = (rawStream, options) => {
3057
3299
  };
3058
3300
 
3059
3301
  // src/server/core/events/functions/typeSafeSSE.ts
3060
- import { Context as Context20, Effect as Effect25, Layer as Layer22 } from "effect";
3302
+ import { Context as Context20, Effect as Effect26, Layer as Layer22 } from "effect";
3061
3303
  import { ulid as ulid3 } from "ulid";
3062
3304
  var TypeSafeSSE = class extends Context20.Tag("TypeSafeSSE")() {
3063
3305
  static {
3064
3306
  this.make = (stream) => Layer22.succeed(this, {
3065
- writeSSE: (event, data) => Effect25.tryPromise({
3307
+ writeSSE: (event, data) => Effect26.tryPromise({
3066
3308
  try: async () => {
3067
3309
  const id = ulid3();
3068
3310
  await stream.writeSSE({
@@ -3087,29 +3329,29 @@ var TypeSafeSSE = class extends Context20.Tag("TypeSafeSSE")() {
3087
3329
  };
3088
3330
 
3089
3331
  // src/server/core/events/presentation/SSEController.ts
3090
- var LayerImpl17 = Effect26.gen(function* () {
3332
+ var LayerImpl17 = Effect27.gen(function* () {
3091
3333
  const eventBus = yield* EventBus;
3092
- const handleSSE = (rawStream) => Effect26.gen(function* () {
3334
+ const handleSSE = (rawStream) => Effect27.gen(function* () {
3093
3335
  const typeSafeSSE = yield* TypeSafeSSE;
3094
3336
  yield* typeSafeSSE.writeSSE("connect", {
3095
3337
  timestamp: (/* @__PURE__ */ new Date()).toISOString()
3096
3338
  });
3097
3339
  const onHeartbeat = () => {
3098
- Effect26.runFork(
3340
+ Effect27.runFork(
3099
3341
  typeSafeSSE.writeSSE("heartbeat", {
3100
3342
  timestamp: (/* @__PURE__ */ new Date()).toISOString()
3101
3343
  })
3102
3344
  );
3103
3345
  };
3104
3346
  const onSessionListChanged = (event) => {
3105
- Effect26.runFork(
3347
+ Effect27.runFork(
3106
3348
  typeSafeSSE.writeSSE("sessionListChanged", {
3107
3349
  projectId: event.projectId
3108
3350
  })
3109
3351
  );
3110
3352
  };
3111
3353
  const onSessionChanged = (event) => {
3112
- Effect26.runFork(
3354
+ Effect27.runFork(
3113
3355
  typeSafeSSE.writeSSE("sessionChanged", {
3114
3356
  projectId: event.projectId,
3115
3357
  sessionId: event.sessionId
@@ -3117,7 +3359,7 @@ var LayerImpl17 = Effect26.gen(function* () {
3117
3359
  );
3118
3360
  };
3119
3361
  const onAgentSessionChanged = (event) => {
3120
- Effect26.runFork(
3362
+ Effect27.runFork(
3121
3363
  typeSafeSSE.writeSSE("agentSessionChanged", {
3122
3364
  projectId: event.projectId,
3123
3365
  agentSessionId: event.agentSessionId
@@ -3125,14 +3367,14 @@ var LayerImpl17 = Effect26.gen(function* () {
3125
3367
  );
3126
3368
  };
3127
3369
  const onSessionProcessChanged = (event) => {
3128
- Effect26.runFork(
3370
+ Effect27.runFork(
3129
3371
  typeSafeSSE.writeSSE("sessionProcessChanged", {
3130
3372
  processes: event.processes
3131
3373
  })
3132
3374
  );
3133
3375
  };
3134
3376
  const onPermissionRequested = (event) => {
3135
- Effect26.runFork(
3377
+ Effect27.runFork(
3136
3378
  typeSafeSSE.writeSSE("permissionRequested", {
3137
3379
  permissionRequest: event.permissionRequest
3138
3380
  })
@@ -3147,8 +3389,8 @@ var LayerImpl17 = Effect26.gen(function* () {
3147
3389
  const { connectionPromise } = adaptInternalEventToSSE(rawStream, {
3148
3390
  timeout: 5 * 60 * 1e3,
3149
3391
  cleanUp: async () => {
3150
- await Effect26.runPromise(
3151
- Effect26.gen(function* () {
3392
+ await Effect27.runPromise(
3393
+ Effect27.gen(function* () {
3152
3394
  yield* eventBus.off("sessionListChanged", onSessionListChanged);
3153
3395
  yield* eventBus.off("sessionChanged", onSessionChanged);
3154
3396
  yield* eventBus.off("agentSessionChanged", onAgentSessionChanged);
@@ -3162,7 +3404,7 @@ var LayerImpl17 = Effect26.gen(function* () {
3162
3404
  );
3163
3405
  }
3164
3406
  });
3165
- yield* Effect26.promise(() => connectionPromise);
3407
+ yield* Effect27.promise(() => connectionPromise);
3166
3408
  });
3167
3409
  return {
3168
3410
  handleSSE
@@ -3177,19 +3419,19 @@ var SSEController = class extends Context21.Tag("SSEController")() {
3177
3419
  // src/server/core/events/services/fileWatcher.ts
3178
3420
  import { watch } from "node:fs";
3179
3421
  import { Path as Path12 } from "@effect/platform";
3180
- import { Context as Context22, Effect as Effect27, Layer as Layer24, Ref as Ref9 } from "effect";
3422
+ import { Context as Context22, Effect as Effect28, Layer as Layer24, Ref as Ref9 } from "effect";
3181
3423
 
3182
3424
  // src/server/core/events/functions/parseSessionFilePath.ts
3183
- import z22 from "zod";
3425
+ import z21 from "zod";
3184
3426
  var sessionFileRegExp = /(?<projectId>.*?)\/(?<sessionId>.*?)\.jsonl$/;
3185
3427
  var agentFileRegExp = /(?<projectId>.*?)\/agent-(?<agentSessionId>.*?)\.jsonl$/;
3186
- var sessionFileGroupSchema = z22.object({
3187
- projectId: z22.string(),
3188
- sessionId: z22.string()
3428
+ var sessionFileGroupSchema = z21.object({
3429
+ projectId: z21.string(),
3430
+ sessionId: z21.string()
3189
3431
  });
3190
- var agentFileGroupSchema = z22.object({
3191
- projectId: z22.string(),
3192
- agentSessionId: z22.string()
3432
+ var agentFileGroupSchema = z21.object({
3433
+ projectId: z21.string(),
3434
+ agentSessionId: z21.string()
3193
3435
  });
3194
3436
  var parseSessionFilePath = (filePath) => {
3195
3437
  const agentMatch = filePath.match(agentFileRegExp);
@@ -3218,7 +3460,7 @@ var FileWatcherService = class extends Context22.Tag("FileWatcherService")() {
3218
3460
  static {
3219
3461
  this.Live = Layer24.effect(
3220
3462
  this,
3221
- Effect27.gen(function* () {
3463
+ Effect28.gen(function* () {
3222
3464
  const path = yield* Path12.Path;
3223
3465
  const eventBus = yield* EventBus;
3224
3466
  const context = yield* ApplicationContext;
@@ -3228,31 +3470,32 @@ var FileWatcherService = class extends Context22.Tag("FileWatcherService")() {
3228
3470
  /* @__PURE__ */ new Map()
3229
3471
  );
3230
3472
  const debounceTimersRef = yield* Ref9.make(/* @__PURE__ */ new Map());
3231
- const startWatching = () => Effect27.gen(function* () {
3473
+ const startWatching = () => Effect28.gen(function* () {
3232
3474
  const isWatching = yield* Ref9.get(isWatchingRef);
3233
3475
  if (isWatching) return;
3476
+ const claudeCodePaths = yield* context.claudeCodePaths;
3234
3477
  yield* Ref9.set(isWatchingRef, true);
3235
- yield* Effect27.tryPromise({
3478
+ yield* Effect28.tryPromise({
3236
3479
  try: async () => {
3237
3480
  console.log(
3238
3481
  "Starting file watcher on:",
3239
- context.claudeCodePaths.claudeProjectsDirPath
3482
+ claudeCodePaths.claudeProjectsDirPath
3240
3483
  );
3241
3484
  const watcher = watch(
3242
- context.claudeCodePaths.claudeProjectsDirPath,
3485
+ claudeCodePaths.claudeProjectsDirPath,
3243
3486
  { persistent: false, recursive: true },
3244
3487
  (_eventType, filename) => {
3245
3488
  if (!filename) return;
3246
3489
  const fileMatch = parseSessionFilePath(filename);
3247
3490
  if (fileMatch === null) return;
3248
3491
  const fullPath = path.join(
3249
- context.claudeCodePaths.claudeProjectsDirPath,
3492
+ claudeCodePaths.claudeProjectsDirPath,
3250
3493
  filename
3251
3494
  );
3252
3495
  const encodedProjectId = encodeProjectIdFromSessionFilePath(fullPath);
3253
3496
  const debounceKey = fileMatch.type === "agent" ? `${encodedProjectId}/agent-${fileMatch.agentSessionId}` : `${encodedProjectId}/${fileMatch.sessionId}`;
3254
- Effect27.runPromise(
3255
- Effect27.gen(function* () {
3497
+ Effect28.runPromise(
3498
+ Effect28.gen(function* () {
3256
3499
  const timers = yield* Ref9.get(debounceTimersRef);
3257
3500
  const existingTimer = timers.get(debounceKey);
3258
3501
  if (existingTimer) {
@@ -3260,27 +3503,27 @@ var FileWatcherService = class extends Context22.Tag("FileWatcherService")() {
3260
3503
  }
3261
3504
  const newTimer = setTimeout(() => {
3262
3505
  if (fileMatch.type === "agent") {
3263
- Effect27.runFork(
3506
+ Effect28.runFork(
3264
3507
  eventBus.emit("agentSessionChanged", {
3265
3508
  projectId: encodedProjectId,
3266
3509
  agentSessionId: fileMatch.agentSessionId
3267
3510
  })
3268
3511
  );
3269
3512
  } else {
3270
- Effect27.runFork(
3513
+ Effect28.runFork(
3271
3514
  eventBus.emit("sessionChanged", {
3272
3515
  projectId: encodedProjectId,
3273
3516
  sessionId: fileMatch.sessionId
3274
3517
  })
3275
3518
  );
3276
- Effect27.runFork(
3519
+ Effect28.runFork(
3277
3520
  eventBus.emit("sessionListChanged", {
3278
3521
  projectId: encodedProjectId
3279
3522
  })
3280
3523
  );
3281
3524
  }
3282
- Effect27.runPromise(
3283
- Effect27.gen(function* () {
3525
+ Effect28.runPromise(
3526
+ Effect28.gen(function* () {
3284
3527
  const currentTimers = yield* Ref9.get(debounceTimersRef);
3285
3528
  currentTimers.delete(debounceKey);
3286
3529
  yield* Ref9.set(debounceTimersRef, currentTimers);
@@ -3293,7 +3536,7 @@ var FileWatcherService = class extends Context22.Tag("FileWatcherService")() {
3293
3536
  );
3294
3537
  }
3295
3538
  );
3296
- await Effect27.runPromise(Ref9.set(watcherRef, watcher));
3539
+ await Effect28.runPromise(Ref9.set(watcherRef, watcher));
3297
3540
  console.log("File watcher initialization completed");
3298
3541
  },
3299
3542
  catch: (error) => {
@@ -3304,10 +3547,10 @@ var FileWatcherService = class extends Context22.Tag("FileWatcherService")() {
3304
3547
  }
3305
3548
  }).pipe(
3306
3549
  // エラーが発生しても続行する
3307
- Effect27.catchAll(() => Effect27.void)
3550
+ Effect28.catchAll(() => Effect28.void)
3308
3551
  );
3309
3552
  });
3310
- const stop = () => Effect27.gen(function* () {
3553
+ const stop = () => Effect28.gen(function* () {
3311
3554
  const timers = yield* Ref9.get(debounceTimersRef);
3312
3555
  for (const [, timer] of timers) {
3313
3556
  clearTimeout(timer);
@@ -3315,12 +3558,12 @@ var FileWatcherService = class extends Context22.Tag("FileWatcherService")() {
3315
3558
  yield* Ref9.set(debounceTimersRef, /* @__PURE__ */ new Map());
3316
3559
  const watcher = yield* Ref9.get(watcherRef);
3317
3560
  if (watcher) {
3318
- yield* Effect27.sync(() => watcher.close());
3561
+ yield* Effect28.sync(() => watcher.close());
3319
3562
  yield* Ref9.set(watcherRef, null);
3320
3563
  }
3321
3564
  const projectWatchers = yield* Ref9.get(projectWatchersRef);
3322
3565
  for (const [, projectWatcher] of projectWatchers) {
3323
- yield* Effect27.sync(() => projectWatcher.close());
3566
+ yield* Effect28.sync(() => projectWatcher.close());
3324
3567
  }
3325
3568
  yield* Ref9.set(projectWatchersRef, /* @__PURE__ */ new Map());
3326
3569
  yield* Ref9.set(isWatchingRef, false);
@@ -3335,10 +3578,10 @@ var FileWatcherService = class extends Context22.Tag("FileWatcherService")() {
3335
3578
  };
3336
3579
 
3337
3580
  // src/server/core/feature-flag/presentation/FeatureFlagController.ts
3338
- import { Context as Context23, Effect as Effect28, Layer as Layer25 } from "effect";
3339
- var LayerImpl18 = Effect28.gen(function* () {
3581
+ import { Context as Context23, Effect as Effect29, Layer as Layer25 } from "effect";
3582
+ var LayerImpl18 = Effect29.gen(function* () {
3340
3583
  const claudeCodeService = yield* ClaudeCodeService;
3341
- const getFlags = () => Effect28.gen(function* () {
3584
+ const getFlags = () => Effect29.gen(function* () {
3342
3585
  const claudeCodeFeatures = yield* claudeCodeService.getAvailableFeatures();
3343
3586
  return {
3344
3587
  response: {
@@ -3372,7 +3615,7 @@ var FeatureFlagController = class extends Context23.Tag("FeatureFlagController")
3372
3615
 
3373
3616
  // src/server/core/file-system/presentation/FileSystemController.ts
3374
3617
  import { homedir as homedir3 } from "node:os";
3375
- import { Context as Context24, Effect as Effect29, Layer as Layer26 } from "effect";
3618
+ import { Context as Context24, Effect as Effect30, Layer as Layer26 } from "effect";
3376
3619
 
3377
3620
  // src/server/core/file-system/functions/getDirectoryListing.ts
3378
3621
  import { existsSync } from "node:fs";
@@ -3505,9 +3748,9 @@ var getFileCompletion = async (projectPath, basePath = "/") => {
3505
3748
  };
3506
3749
 
3507
3750
  // src/server/core/file-system/presentation/FileSystemController.ts
3508
- var LayerImpl19 = Effect29.gen(function* () {
3751
+ var LayerImpl19 = Effect30.gen(function* () {
3509
3752
  const projectRepository = yield* ProjectRepository;
3510
- const getFileCompletionRoute = (options) => Effect29.gen(function* () {
3753
+ const getFileCompletionRoute = (options) => Effect30.gen(function* () {
3511
3754
  const { projectId, basePath } = options;
3512
3755
  const { project } = yield* projectRepository.getProject(projectId);
3513
3756
  if (project.meta.projectPath === null) {
@@ -3518,7 +3761,7 @@ var LayerImpl19 = Effect29.gen(function* () {
3518
3761
  }
3519
3762
  const projectPath = project.meta.projectPath;
3520
3763
  try {
3521
- const result = yield* Effect29.promise(
3764
+ const result = yield* Effect30.promise(
3522
3765
  () => getFileCompletion(projectPath, basePath)
3523
3766
  );
3524
3767
  return {
@@ -3533,7 +3776,7 @@ var LayerImpl19 = Effect29.gen(function* () {
3533
3776
  };
3534
3777
  }
3535
3778
  });
3536
- const getDirectoryListingRoute = (options) => Effect29.promise(async () => {
3779
+ const getDirectoryListingRoute = (options) => Effect30.promise(async () => {
3537
3780
  const { currentPath, showHidden = false } = options;
3538
3781
  const rootPath = "/";
3539
3782
  const defaultPath = homedir3();
@@ -3569,7 +3812,7 @@ var FileSystemController = class extends Context24.Tag("FileSystemController")()
3569
3812
  };
3570
3813
 
3571
3814
  // src/server/core/git/presentation/GitController.ts
3572
- import { Context as Context26, Effect as Effect31, Either as Either2, Layer as Layer28 } from "effect";
3815
+ import { Context as Context27, Effect as Effect33, Either as Either2, Layer as Layer29 } from "effect";
3573
3816
 
3574
3817
  // src/server/core/git/functions/getDiff.ts
3575
3818
  import { readFile } from "node:fs/promises";
@@ -3909,7 +4152,57 @@ var getDiff = async (cwd, fromRefText, toRefText) => {
3909
4152
 
3910
4153
  // src/server/core/git/services/GitService.ts
3911
4154
  import { Command as Command2, FileSystem as FileSystem10, Path as Path13 } from "@effect/platform";
3912
- import { Context as Context25, Data as Data4, Duration, Effect as Effect30, Either, Layer as Layer27 } from "effect";
4155
+ import { Context as Context26, Data as Data4, Duration, Effect as Effect32, Either, Layer as Layer28 } from "effect";
4156
+
4157
+ // src/server/core/platform/services/EnvService.ts
4158
+ import { Context as Context25, Effect as Effect31, Layer as Layer27, Ref as Ref10 } from "effect";
4159
+
4160
+ // src/server/core/platform/schema.ts
4161
+ import { z as z22 } from "zod";
4162
+ var envSchema = z22.object({
4163
+ // Frameworks
4164
+ NODE_ENV: z22.enum(["development", "production", "test"]).optional().default("development"),
4165
+ NEXT_PHASE: z22.string().optional(),
4166
+ PATH: z22.string().optional()
4167
+ });
4168
+
4169
+ // src/server/core/platform/services/EnvService.ts
4170
+ var LayerImpl20 = Effect31.gen(function* () {
4171
+ const envRef = yield* Ref10.make(void 0);
4172
+ const parseEnv = () => {
4173
+ const parsed = envSchema.safeParse(process.env);
4174
+ if (!parsed.success) {
4175
+ console.error(parsed.error);
4176
+ throw new Error(`Invalid environment variables: ${parsed.error.message}`);
4177
+ }
4178
+ return parsed.data;
4179
+ };
4180
+ const getEnv = (key) => {
4181
+ return Effect31.gen(function* () {
4182
+ yield* Ref10.update(envRef, (existingEnv) => {
4183
+ if (existingEnv === void 0) {
4184
+ return parseEnv();
4185
+ }
4186
+ return existingEnv;
4187
+ });
4188
+ const env = yield* Ref10.get(envRef);
4189
+ if (env === void 0) {
4190
+ throw new Error(
4191
+ "Unexpected error: Environment variables are not loaded"
4192
+ );
4193
+ }
4194
+ return env[key];
4195
+ });
4196
+ };
4197
+ return {
4198
+ getEnv
4199
+ };
4200
+ });
4201
+ var EnvService = class extends Context25.Tag("EnvService")() {
4202
+ static {
4203
+ this.Live = Layer27.effect(this, LayerImpl20);
4204
+ }
4205
+ };
3913
4206
 
3914
4207
  // src/server/core/git/functions/parseGitBranchesOutput.ts
3915
4208
  var parseGitBranchesOutput = (output) => {
@@ -3986,14 +4279,14 @@ var GitCommandError = class extends Data4.TaggedError("GitCommandError") {
3986
4279
  };
3987
4280
  var DetachedHeadError = class extends Data4.TaggedError("DetachedHeadError") {
3988
4281
  };
3989
- var LayerImpl20 = Effect30.gen(function* () {
4282
+ var LayerImpl21 = Effect32.gen(function* () {
3990
4283
  const fs = yield* FileSystem10.FileSystem;
3991
4284
  const path = yield* Path13.Path;
3992
4285
  const envService = yield* EnvService;
3993
- const execGitCommand = (args, cwd) => Effect30.gen(function* () {
4286
+ const execGitCommand = (args, cwd) => Effect32.gen(function* () {
3994
4287
  const absoluteCwd = path.resolve(cwd);
3995
4288
  if (!(yield* fs.exists(absoluteCwd))) {
3996
- return yield* Effect30.fail(
4289
+ return yield* Effect32.fail(
3997
4290
  new NotARepositoryError({ cwd: absoluteCwd })
3998
4291
  );
3999
4292
  }
@@ -4003,9 +4296,9 @@ var LayerImpl20 = Effect30.gen(function* () {
4003
4296
  PATH: yield* envService.getEnv("PATH")
4004
4297
  })
4005
4298
  );
4006
- const result = yield* Effect30.either(Command2.string(command));
4299
+ const result = yield* Effect32.either(Command2.string(command));
4007
4300
  if (Either.isLeft(result)) {
4008
- return yield* Effect30.fail(
4301
+ return yield* Effect32.fail(
4009
4302
  new GitCommandError({
4010
4303
  cwd: absoluteCwd,
4011
4304
  command: `git ${args.join(" ")}`
@@ -4014,22 +4307,22 @@ var LayerImpl20 = Effect30.gen(function* () {
4014
4307
  }
4015
4308
  return result.right;
4016
4309
  });
4017
- const getBranches = (cwd) => Effect30.gen(function* () {
4310
+ const getBranches = (cwd) => Effect32.gen(function* () {
4018
4311
  const result = yield* execGitCommand(["branch", "-vv", "--all"], cwd);
4019
4312
  return parseGitBranchesOutput(result);
4020
4313
  });
4021
- const getCurrentBranch = (cwd) => Effect30.gen(function* () {
4314
+ const getCurrentBranch = (cwd) => Effect32.gen(function* () {
4022
4315
  const currentBranch = yield* execGitCommand(
4023
4316
  ["branch", "--show-current"],
4024
4317
  cwd
4025
- ).pipe(Effect30.map((result) => result.trim()));
4318
+ ).pipe(Effect32.map((result) => result.trim()));
4026
4319
  if (currentBranch === "") {
4027
- return yield* Effect30.fail(new DetachedHeadError({ cwd }));
4320
+ return yield* Effect32.fail(new DetachedHeadError({ cwd }));
4028
4321
  }
4029
4322
  return currentBranch;
4030
4323
  });
4031
- const branchExists = (cwd, branchName) => Effect30.gen(function* () {
4032
- const result = yield* Effect30.either(
4324
+ const branchExists = (cwd, branchName) => Effect32.gen(function* () {
4325
+ const result = yield* Effect32.either(
4033
4326
  execGitCommand(["branch", "--exists", branchName], cwd)
4034
4327
  );
4035
4328
  if (Either.isLeft(result)) {
@@ -4037,7 +4330,7 @@ var LayerImpl20 = Effect30.gen(function* () {
4037
4330
  }
4038
4331
  return true;
4039
4332
  });
4040
- const getCommits = (cwd) => Effect30.gen(function* () {
4333
+ const getCommits = (cwd) => Effect32.gen(function* () {
4041
4334
  const result = yield* execGitCommand(
4042
4335
  [
4043
4336
  "log",
@@ -4051,9 +4344,9 @@ var LayerImpl20 = Effect30.gen(function* () {
4051
4344
  );
4052
4345
  return parseGitCommitsOutput(result);
4053
4346
  });
4054
- const stageFiles = (cwd, files) => Effect30.gen(function* () {
4347
+ const stageFiles = (cwd, files) => Effect32.gen(function* () {
4055
4348
  if (files.length === 0) {
4056
- return yield* Effect30.fail(
4349
+ return yield* Effect32.fail(
4057
4350
  new GitCommandError({
4058
4351
  cwd,
4059
4352
  command: "git add (no files)"
@@ -4063,10 +4356,10 @@ var LayerImpl20 = Effect30.gen(function* () {
4063
4356
  const result = yield* execGitCommand(["add", ...files], cwd);
4064
4357
  return result;
4065
4358
  });
4066
- const commit = (cwd, message) => Effect30.gen(function* () {
4359
+ const commit = (cwd, message) => Effect32.gen(function* () {
4067
4360
  const trimmedMessage = message.trim();
4068
4361
  if (trimmedMessage.length === 0) {
4069
- return yield* Effect30.fail(
4362
+ return yield* Effect32.fail(
4070
4363
  new GitCommandError({
4071
4364
  cwd,
4072
4365
  command: "git commit (empty message)"
@@ -4103,7 +4396,7 @@ var LayerImpl20 = Effect30.gen(function* () {
4103
4396
  );
4104
4397
  return sha.trim();
4105
4398
  });
4106
- const push = (cwd) => Effect30.gen(function* () {
4399
+ const push = (cwd) => Effect32.gen(function* () {
4107
4400
  const branch = yield* getCurrentBranch(cwd);
4108
4401
  const absoluteCwd = path.resolve(cwd);
4109
4402
  const command = Command2.make("git", "push", "origin", "HEAD").pipe(
@@ -4112,12 +4405,12 @@ var LayerImpl20 = Effect30.gen(function* () {
4112
4405
  PATH: yield* envService.getEnv("PATH")
4113
4406
  })
4114
4407
  );
4115
- const exitCodeResult = yield* Effect30.either(
4116
- Command2.exitCode(command).pipe(Effect30.timeout(Duration.seconds(60)))
4408
+ const exitCodeResult = yield* Effect32.either(
4409
+ Command2.exitCode(command).pipe(Effect32.timeout(Duration.seconds(60)))
4117
4410
  );
4118
4411
  if (Either.isLeft(exitCodeResult)) {
4119
4412
  console.log("[GitService.push] Command failed or timeout");
4120
- return yield* Effect30.fail(
4413
+ return yield* Effect32.fail(
4121
4414
  new GitCommandError({
4122
4415
  cwd: absoluteCwd,
4123
4416
  command: "git push origin HEAD (timeout after 60s)"
@@ -4135,10 +4428,10 @@ var LayerImpl20 = Effect30.gen(function* () {
4135
4428
  }),
4136
4429
  Command2.stderr("inherit")
4137
4430
  )
4138
- ).pipe(Effect30.orElse(() => Effect30.succeed([])));
4431
+ ).pipe(Effect32.orElse(() => Effect32.succeed([])));
4139
4432
  const stderr = Array.from(stderrLines).join("\n");
4140
4433
  console.log("[GitService.push] Failed with stderr:", stderr);
4141
- return yield* Effect30.fail(
4434
+ return yield* Effect32.fail(
4142
4435
  new GitCommandError({
4143
4436
  cwd: absoluteCwd,
4144
4437
  command: `git push origin HEAD - ${stderr}`
@@ -4148,20 +4441,20 @@ var LayerImpl20 = Effect30.gen(function* () {
4148
4441
  console.log("[GitService.push] Push succeeded");
4149
4442
  return { branch, output: "success" };
4150
4443
  });
4151
- const getBranchHash = (cwd, branchName) => Effect30.gen(function* () {
4444
+ const getBranchHash = (cwd, branchName) => Effect32.gen(function* () {
4152
4445
  const result = yield* execGitCommand(["rev-parse", branchName], cwd).pipe(
4153
- Effect30.map((output) => output.trim().split("\n")[0] ?? null)
4446
+ Effect32.map((output) => output.trim().split("\n")[0] ?? null)
4154
4447
  );
4155
4448
  return result;
4156
4449
  });
4157
- const getBranchNamesByCommitHash = (cwd, hash) => Effect30.gen(function* () {
4450
+ const getBranchNamesByCommitHash = (cwd, hash) => Effect32.gen(function* () {
4158
4451
  const result = yield* execGitCommand(
4159
4452
  ["branch", "--contains", hash, "--format=%(refname:short)"],
4160
4453
  cwd
4161
4454
  );
4162
4455
  return result.split("\n").map((line) => line.trim()).filter((line) => line !== "");
4163
4456
  });
4164
- const compareCommitHash = (cwd, targetHash, compareHash) => Effect30.gen(function* () {
4457
+ const compareCommitHash = (cwd, targetHash, compareHash) => Effect32.gen(function* () {
4165
4458
  const aheadResult = yield* execGitCommand(
4166
4459
  ["rev-list", `${targetHash}..${compareHash}`],
4167
4460
  cwd
@@ -4183,7 +4476,7 @@ var LayerImpl20 = Effect30.gen(function* () {
4183
4476
  }
4184
4477
  return "un-related";
4185
4478
  });
4186
- const getCommitsWithParent = (cwd, options) => Effect30.gen(function* () {
4479
+ const getCommitsWithParent = (cwd, options) => Effect32.gen(function* () {
4187
4480
  const { offset, limit } = options;
4188
4481
  const result = yield* execGitCommand(
4189
4482
  [
@@ -4210,7 +4503,7 @@ var LayerImpl20 = Effect30.gen(function* () {
4210
4503
  }
4211
4504
  return commits;
4212
4505
  });
4213
- const findBaseBranch = (cwd, targetBranch) => Effect30.gen(function* () {
4506
+ const findBaseBranch = (cwd, targetBranch) => Effect32.gen(function* () {
4214
4507
  let offset = 0;
4215
4508
  const limit = 20;
4216
4509
  while (offset < 100) {
@@ -4244,7 +4537,7 @@ var LayerImpl20 = Effect30.gen(function* () {
4244
4537
  }
4245
4538
  return null;
4246
4539
  });
4247
- const getCommitsBetweenBranches = (cwd, baseBranch, targetBranch) => Effect30.gen(function* () {
4540
+ const getCommitsBetweenBranches = (cwd, baseBranch, targetBranch) => Effect32.gen(function* () {
4248
4541
  const result = yield* execGitCommand(
4249
4542
  [
4250
4543
  "log",
@@ -4272,17 +4565,17 @@ var LayerImpl20 = Effect30.gen(function* () {
4272
4565
  getCommitsBetweenBranches
4273
4566
  };
4274
4567
  });
4275
- var GitService = class extends Context25.Tag("GitService")() {
4568
+ var GitService = class extends Context26.Tag("GitService")() {
4276
4569
  static {
4277
- this.Live = Layer27.effect(this, LayerImpl20);
4570
+ this.Live = Layer28.effect(this, LayerImpl21);
4278
4571
  }
4279
4572
  };
4280
4573
 
4281
4574
  // src/server/core/git/presentation/GitController.ts
4282
- var LayerImpl21 = Effect31.gen(function* () {
4575
+ var LayerImpl22 = Effect33.gen(function* () {
4283
4576
  const gitService = yield* GitService;
4284
4577
  const projectRepository = yield* ProjectRepository;
4285
- const getGitDiff = (options) => Effect31.gen(function* () {
4578
+ const getGitDiff = (options) => Effect33.gen(function* () {
4286
4579
  const { projectId, fromRef, toRef } = options;
4287
4580
  const { project } = yield* projectRepository.getProject(projectId);
4288
4581
  try {
@@ -4293,7 +4586,7 @@ var LayerImpl21 = Effect31.gen(function* () {
4293
4586
  };
4294
4587
  }
4295
4588
  const projectPath = project.meta.projectPath;
4296
- const result = yield* Effect31.promise(
4589
+ const result = yield* Effect33.promise(
4297
4590
  () => getDiff(projectPath, fromRef, toRef)
4298
4591
  );
4299
4592
  return {
@@ -4314,7 +4607,7 @@ var LayerImpl21 = Effect31.gen(function* () {
4314
4607
  };
4315
4608
  }
4316
4609
  });
4317
- const commitFiles = (options) => Effect31.gen(function* () {
4610
+ const commitFiles = (options) => Effect33.gen(function* () {
4318
4611
  const { projectId, files, message } = options;
4319
4612
  const { project } = yield* projectRepository.getProject(projectId);
4320
4613
  if (project.meta.projectPath === null) {
@@ -4327,7 +4620,7 @@ var LayerImpl21 = Effect31.gen(function* () {
4327
4620
  const projectPath = project.meta.projectPath;
4328
4621
  console.log("[GitController.commitFiles] Project path:", projectPath);
4329
4622
  console.log("[GitController.commitFiles] Staging files...");
4330
- const stageResult = yield* Effect31.either(
4623
+ const stageResult = yield* Effect33.either(
4331
4624
  gitService.stageFiles(projectPath, files)
4332
4625
  );
4333
4626
  if (Either2.isLeft(stageResult)) {
@@ -4347,7 +4640,7 @@ var LayerImpl21 = Effect31.gen(function* () {
4347
4640
  }
4348
4641
  console.log("[GitController.commitFiles] Stage succeeded");
4349
4642
  console.log("[GitController.commitFiles] Committing...");
4350
- const commitResult = yield* Effect31.either(
4643
+ const commitResult = yield* Effect33.either(
4351
4644
  gitService.commit(projectPath, message)
4352
4645
  );
4353
4646
  if (Either2.isLeft(commitResult)) {
@@ -4382,7 +4675,7 @@ var LayerImpl21 = Effect31.gen(function* () {
4382
4675
  status: 200
4383
4676
  };
4384
4677
  });
4385
- const pushCommits = (options) => Effect31.gen(function* () {
4678
+ const pushCommits = (options) => Effect33.gen(function* () {
4386
4679
  const { projectId } = options;
4387
4680
  console.log("[GitController.pushCommits] Request:", { projectId });
4388
4681
  const { project } = yield* projectRepository.getProject(projectId);
@@ -4396,7 +4689,7 @@ var LayerImpl21 = Effect31.gen(function* () {
4396
4689
  const projectPath = project.meta.projectPath;
4397
4690
  console.log("[GitController.pushCommits] Project path:", projectPath);
4398
4691
  console.log("[GitController.pushCommits] Pushing...");
4399
- const pushResult = yield* Effect31.either(gitService.push(projectPath));
4692
+ const pushResult = yield* Effect33.either(gitService.push(projectPath));
4400
4693
  if (Either2.isLeft(pushResult)) {
4401
4694
  console.log(
4402
4695
  "[GitController.pushCommits] Push failed:",
@@ -4425,7 +4718,7 @@ var LayerImpl21 = Effect31.gen(function* () {
4425
4718
  status: 200
4426
4719
  };
4427
4720
  });
4428
- const commitAndPush = (options) => Effect31.gen(function* () {
4721
+ const commitAndPush = (options) => Effect33.gen(function* () {
4429
4722
  const { projectId, files, message } = options;
4430
4723
  console.log("[GitController.commitAndPush] Request:", {
4431
4724
  projectId,
@@ -4476,7 +4769,7 @@ var LayerImpl21 = Effect31.gen(function* () {
4476
4769
  status: 200
4477
4770
  };
4478
4771
  });
4479
- const getCurrentRevisions = (options) => Effect31.gen(function* () {
4772
+ const getCurrentRevisions = (options) => Effect33.gen(function* () {
4480
4773
  const { projectId } = options;
4481
4774
  const { project } = yield* projectRepository.getProject(projectId);
4482
4775
  if (project.meta.projectPath === null) {
@@ -4486,7 +4779,7 @@ var LayerImpl21 = Effect31.gen(function* () {
4486
4779
  };
4487
4780
  }
4488
4781
  const projectPath = project.meta.projectPath;
4489
- const currentBranchResult = yield* Effect31.either(
4782
+ const currentBranchResult = yield* Effect33.either(
4490
4783
  gitService.getCurrentBranch(projectPath)
4491
4784
  );
4492
4785
  if (Either2.isLeft(currentBranchResult)) {
@@ -4498,10 +4791,10 @@ var LayerImpl21 = Effect31.gen(function* () {
4498
4791
  };
4499
4792
  }
4500
4793
  const currentBranch = currentBranchResult.right;
4501
- const baseBranchResult = yield* Effect31.either(
4794
+ const baseBranchResult = yield* Effect33.either(
4502
4795
  gitService.findBaseBranch(projectPath, currentBranch)
4503
4796
  );
4504
- const allBranchesResult = yield* Effect31.either(
4797
+ const allBranchesResult = yield* Effect33.either(
4505
4798
  gitService.getBranches(projectPath)
4506
4799
  );
4507
4800
  if (Either2.isLeft(allBranchesResult)) {
@@ -4526,7 +4819,7 @@ var LayerImpl21 = Effect31.gen(function* () {
4526
4819
  let commits = [];
4527
4820
  if (Either2.isRight(baseBranchResult) && baseBranchResult.right !== null) {
4528
4821
  const baseBranchHash = baseBranchResult.right.hash;
4529
- const commitsResult = yield* Effect31.either(
4822
+ const commitsResult = yield* Effect33.either(
4530
4823
  gitService.getCommitsBetweenBranches(
4531
4824
  projectPath,
4532
4825
  baseBranchHash,
@@ -4589,20 +4882,20 @@ function getPushErrorMessage(code) {
4589
4882
  };
4590
4883
  return messages[code];
4591
4884
  }
4592
- var GitController = class extends Context26.Tag("GitController")() {
4885
+ var GitController = class extends Context27.Tag("GitController")() {
4593
4886
  static {
4594
- this.Live = Layer28.effect(this, LayerImpl21);
4887
+ this.Live = Layer29.effect(this, LayerImpl22);
4595
4888
  }
4596
4889
  };
4597
4890
 
4598
4891
  // src/server/core/project/presentation/ProjectController.ts
4599
4892
  import { FileSystem as FileSystem11, Path as Path15 } from "@effect/platform";
4600
- import { Context as Context27, Effect as Effect33, Layer as Layer29 } from "effect";
4893
+ import { Context as Context28, Effect as Effect35, Layer as Layer30 } from "effect";
4601
4894
 
4602
4895
  // src/server/core/claude-code/functions/computeClaudeProjectFilePath.ts
4603
4896
  import { Path as Path14 } from "@effect/platform";
4604
- import { Effect as Effect32 } from "effect";
4605
- var computeClaudeProjectFilePath = (options) => Effect32.gen(function* () {
4897
+ import { Effect as Effect34 } from "effect";
4898
+ var computeClaudeProjectFilePath = (options) => Effect34.gen(function* () {
4606
4899
  const path = yield* Path14.Path;
4607
4900
  const { projectPath, claudeProjectsDirPath } = options;
4608
4901
  return path.join(
@@ -4612,7 +4905,7 @@ var computeClaudeProjectFilePath = (options) => Effect32.gen(function* () {
4612
4905
  });
4613
4906
 
4614
4907
  // src/server/core/project/presentation/ProjectController.ts
4615
- var LayerImpl22 = Effect33.gen(function* () {
4908
+ var LayerImpl23 = Effect35.gen(function* () {
4616
4909
  const projectRepository = yield* ProjectRepository;
4617
4910
  const claudeCodeLifeCycleService = yield* ClaudeCodeLifeCycleService;
4618
4911
  const userConfigService = yield* UserConfigService;
@@ -4620,14 +4913,14 @@ var LayerImpl22 = Effect33.gen(function* () {
4620
4913
  const context = yield* ApplicationContext;
4621
4914
  const fileSystem = yield* FileSystem11.FileSystem;
4622
4915
  const path = yield* Path15.Path;
4623
- const getProjects = () => Effect33.gen(function* () {
4916
+ const getProjects = () => Effect35.gen(function* () {
4624
4917
  const { projects } = yield* projectRepository.getProjects();
4625
4918
  return {
4626
4919
  status: 200,
4627
4920
  response: { projects }
4628
4921
  };
4629
4922
  });
4630
- const getProject = (options) => Effect33.gen(function* () {
4923
+ const getProject = (options) => Effect35.gen(function* () {
4631
4924
  const { projectId, cursor } = options;
4632
4925
  const userConfig = yield* userConfigService.getUserConfig();
4633
4926
  const { project } = yield* projectRepository.getProject(projectId);
@@ -4681,7 +4974,7 @@ var LayerImpl22 = Effect33.gen(function* () {
4681
4974
  }
4682
4975
  };
4683
4976
  });
4684
- const getProjectLatestSession = (options) => Effect33.gen(function* () {
4977
+ const getProjectLatestSession = (options) => Effect35.gen(function* () {
4685
4978
  const { projectId } = options;
4686
4979
  const { sessions } = yield* sessionRepository.getSessions(projectId, {
4687
4980
  maxCount: 1
@@ -4693,11 +4986,11 @@ var LayerImpl22 = Effect33.gen(function* () {
4693
4986
  }
4694
4987
  };
4695
4988
  });
4696
- const createProject = (options) => Effect33.gen(function* () {
4989
+ const createProject = (options) => Effect35.gen(function* () {
4697
4990
  const { projectPath } = options;
4698
4991
  const claudeProjectFilePath = yield* computeClaudeProjectFilePath({
4699
4992
  projectPath,
4700
- claudeProjectsDirPath: context.claudeCodePaths.claudeProjectsDirPath
4993
+ claudeProjectsDirPath: (yield* context.claudeCodePaths).claudeProjectsDirPath
4701
4994
  });
4702
4995
  const projectId = encodeProjectId(claudeProjectFilePath);
4703
4996
  const userConfig = yield* userConfigService.getUserConfig();
@@ -4730,16 +5023,16 @@ var LayerImpl22 = Effect33.gen(function* () {
4730
5023
  createProject
4731
5024
  };
4732
5025
  });
4733
- var ProjectController = class extends Context27.Tag("ProjectController")() {
5026
+ var ProjectController = class extends Context28.Tag("ProjectController")() {
4734
5027
  static {
4735
- this.Live = Layer29.effect(this, LayerImpl22);
5028
+ this.Live = Layer30.effect(this, LayerImpl23);
4736
5029
  }
4737
5030
  };
4738
5031
 
4739
5032
  // src/server/core/scheduler/config.ts
4740
5033
  import { homedir as homedir4 } from "node:os";
4741
5034
  import { FileSystem as FileSystem12, Path as Path16 } from "@effect/platform";
4742
- import { Context as Context28, Data as Data5, Effect as Effect34, Layer as Layer30 } from "effect";
5035
+ import { Context as Context29, Data as Data5, Effect as Effect36, Layer as Layer31 } from "effect";
4743
5036
 
4744
5037
  // src/server/core/scheduler/schema.ts
4745
5038
  import { z as z23 } from "zod";
@@ -4800,29 +5093,29 @@ var ConfigParseError = class extends Data5.TaggedError("ConfigParseError") {
4800
5093
  };
4801
5094
  var CONFIG_DIR = "scheduler";
4802
5095
  var CONFIG_FILE = "schedules.json";
4803
- var SchedulerConfigBaseDir = class extends Context28.Tag(
5096
+ var SchedulerConfigBaseDir = class extends Context29.Tag(
4804
5097
  "SchedulerConfigBaseDir"
4805
5098
  )() {
4806
5099
  static {
4807
- this.Live = Layer30.succeed(this, `${homedir4()}/.claude-code-viewer`);
5100
+ this.Live = Layer31.succeed(this, `${homedir4()}/.claude-code-viewer`);
4808
5101
  }
4809
5102
  };
4810
- var getConfigPath = Effect34.gen(function* () {
5103
+ var getConfigPath = Effect36.gen(function* () {
4811
5104
  const path = yield* Path16.Path;
4812
5105
  const baseDir = yield* SchedulerConfigBaseDir;
4813
5106
  return path.join(baseDir, CONFIG_DIR, CONFIG_FILE);
4814
5107
  });
4815
- var readConfig = Effect34.gen(function* () {
5108
+ var readConfig = Effect36.gen(function* () {
4816
5109
  const fs = yield* FileSystem12.FileSystem;
4817
5110
  const configPath = yield* getConfigPath;
4818
5111
  const exists = yield* fs.exists(configPath);
4819
5112
  if (!exists) {
4820
- return yield* Effect34.fail(
5113
+ return yield* Effect36.fail(
4821
5114
  new ConfigFileNotFoundError({ path: configPath })
4822
5115
  );
4823
5116
  }
4824
5117
  const content = yield* fs.readFileString(configPath);
4825
- const jsonResult = yield* Effect34.try({
5118
+ const jsonResult = yield* Effect36.try({
4826
5119
  try: () => JSON.parse(content),
4827
5120
  catch: (error) => new ConfigParseError({
4828
5121
  path: configPath,
@@ -4831,7 +5124,7 @@ var readConfig = Effect34.gen(function* () {
4831
5124
  });
4832
5125
  const parsed = schedulerConfigSchema.safeParse(jsonResult);
4833
5126
  if (!parsed.success) {
4834
- return yield* Effect34.fail(
5127
+ return yield* Effect36.fail(
4835
5128
  new ConfigParseError({
4836
5129
  path: configPath,
4837
5130
  cause: parsed.error
@@ -4840,7 +5133,7 @@ var readConfig = Effect34.gen(function* () {
4840
5133
  }
4841
5134
  return parsed.data;
4842
5135
  });
4843
- var writeConfig = (config) => Effect34.gen(function* () {
5136
+ var writeConfig = (config) => Effect36.gen(function* () {
4844
5137
  const fs = yield* FileSystem12.FileSystem;
4845
5138
  const path = yield* Path16.Path;
4846
5139
  const configPath = yield* getConfigPath;
@@ -4849,15 +5142,15 @@ var writeConfig = (config) => Effect34.gen(function* () {
4849
5142
  const content = JSON.stringify(config, null, 2);
4850
5143
  yield* fs.writeFileString(configPath, content);
4851
5144
  });
4852
- var initializeConfig = Effect34.gen(function* () {
5145
+ var initializeConfig = Effect36.gen(function* () {
4853
5146
  const result = yield* readConfig.pipe(
4854
- Effect34.catchTags({
4855
- ConfigFileNotFoundError: () => Effect34.gen(function* () {
5147
+ Effect36.catchTags({
5148
+ ConfigFileNotFoundError: () => Effect36.gen(function* () {
4856
5149
  const initialConfig = { jobs: [] };
4857
5150
  yield* writeConfig(initialConfig);
4858
5151
  return initialConfig;
4859
5152
  }),
4860
- ConfigParseError: () => Effect34.gen(function* () {
5153
+ ConfigParseError: () => Effect36.gen(function* () {
4861
5154
  const initialConfig = { jobs: [] };
4862
5155
  yield* writeConfig(initialConfig);
4863
5156
  return initialConfig;
@@ -4869,21 +5162,21 @@ var initializeConfig = Effect34.gen(function* () {
4869
5162
 
4870
5163
  // src/server/core/scheduler/domain/Scheduler.ts
4871
5164
  import {
4872
- Context as Context29,
5165
+ Context as Context30,
4873
5166
  Cron,
4874
5167
  Data as Data6,
4875
5168
  Duration as Duration2,
4876
- Effect as Effect36,
5169
+ Effect as Effect38,
4877
5170
  Fiber,
4878
- Layer as Layer31,
4879
- Ref as Ref10,
5171
+ Layer as Layer32,
5172
+ Ref as Ref11,
4880
5173
  Schedule
4881
5174
  } from "effect";
4882
5175
  import { ulid as ulid4 } from "ulid";
4883
5176
 
4884
5177
  // src/server/core/scheduler/domain/Job.ts
4885
- import { Effect as Effect35 } from "effect";
4886
- var executeJob = (job) => Effect35.gen(function* () {
5178
+ import { Effect as Effect37 } from "effect";
5179
+ var executeJob = (job) => Effect37.gen(function* () {
4887
5180
  const lifeCycleService = yield* ClaudeCodeLifeCycleService;
4888
5181
  const projectRepository = yield* ProjectRepository;
4889
5182
  const userConfigService = yield* UserConfigService;
@@ -4891,7 +5184,7 @@ var executeJob = (job) => Effect35.gen(function* () {
4891
5184
  const { project } = yield* projectRepository.getProject(message.projectId);
4892
5185
  const userConfig = yield* userConfigService.getUserConfig();
4893
5186
  if (project.meta.projectPath === null) {
4894
- return yield* Effect35.fail(
5187
+ return yield* Effect37.fail(
4895
5188
  new Error(`Project path not found for projectId: ${message.projectId}`)
4896
5189
  );
4897
5190
  }
@@ -4925,15 +5218,15 @@ var InvalidCronExpressionError = class extends Data6.TaggedError(
4925
5218
  "InvalidCronExpressionError"
4926
5219
  ) {
4927
5220
  };
4928
- var LayerImpl23 = Effect36.gen(function* () {
4929
- const fibersRef = yield* Ref10.make(/* @__PURE__ */ new Map());
4930
- const runningJobsRef = yield* Ref10.make(/* @__PURE__ */ new Set());
4931
- const startJob = (job) => Effect36.gen(function* () {
5221
+ var LayerImpl24 = Effect38.gen(function* () {
5222
+ const fibersRef = yield* Ref11.make(/* @__PURE__ */ new Map());
5223
+ const runningJobsRef = yield* Ref11.make(/* @__PURE__ */ new Set());
5224
+ const startJob = (job) => Effect38.gen(function* () {
4932
5225
  const now = /* @__PURE__ */ new Date();
4933
5226
  if (job.schedule.type === "cron") {
4934
5227
  const cronResult = Cron.parse(job.schedule.expression);
4935
5228
  if (cronResult._tag === "Left") {
4936
- return yield* Effect36.fail(
5229
+ return yield* Effect38.fail(
4937
5230
  new InvalidCronExpressionError({
4938
5231
  expression: job.schedule.expression,
4939
5232
  cause: cronResult.left
@@ -4941,13 +5234,13 @@ var LayerImpl23 = Effect36.gen(function* () {
4941
5234
  );
4942
5235
  }
4943
5236
  const cronSchedule = Schedule.cron(cronResult.right);
4944
- const fiber = yield* Effect36.gen(function* () {
5237
+ const fiber = yield* Effect38.gen(function* () {
4945
5238
  const nextTime = Cron.next(cronResult.right, /* @__PURE__ */ new Date());
4946
5239
  const nextDelay = Math.max(0, nextTime.getTime() - Date.now());
4947
- yield* Effect36.sleep(Duration2.millis(nextDelay));
4948
- yield* Effect36.repeat(runJobWithConcurrencyControl(job), cronSchedule);
4949
- }).pipe(Effect36.forkDaemon);
4950
- yield* Ref10.update(
5240
+ yield* Effect38.sleep(Duration2.millis(nextDelay));
5241
+ yield* Effect38.repeat(runJobWithConcurrencyControl(job), cronSchedule);
5242
+ }).pipe(Effect38.forkDaemon);
5243
+ yield* Ref11.update(
4951
5244
  fibersRef,
4952
5245
  (fibers) => new Map(fibers).set(job.id, fiber)
4953
5246
  );
@@ -4957,61 +5250,61 @@ var LayerImpl23 = Effect36.gen(function* () {
4957
5250
  }
4958
5251
  const delay = calculateReservedDelay(job, now);
4959
5252
  const delayDuration = Duration2.millis(delay);
4960
- const fiber = yield* Effect36.delay(
5253
+ const fiber = yield* Effect38.delay(
4961
5254
  runJobWithConcurrencyControl(job),
4962
5255
  delayDuration
4963
- ).pipe(Effect36.forkDaemon);
4964
- yield* Ref10.update(
5256
+ ).pipe(Effect38.forkDaemon);
5257
+ yield* Ref11.update(
4965
5258
  fibersRef,
4966
5259
  (fibers) => new Map(fibers).set(job.id, fiber)
4967
5260
  );
4968
5261
  }
4969
5262
  });
4970
- const runJobWithConcurrencyControl = (job) => Effect36.gen(function* () {
5263
+ const runJobWithConcurrencyControl = (job) => Effect38.gen(function* () {
4971
5264
  if (job.schedule.type === "cron" && job.schedule.concurrencyPolicy === "skip") {
4972
- const runningJobs = yield* Ref10.get(runningJobsRef);
5265
+ const runningJobs = yield* Ref11.get(runningJobsRef);
4973
5266
  if (runningJobs.has(job.id)) {
4974
5267
  return;
4975
5268
  }
4976
5269
  }
4977
- yield* Ref10.update(runningJobsRef, (jobs) => new Set(jobs).add(job.id));
5270
+ yield* Ref11.update(runningJobsRef, (jobs) => new Set(jobs).add(job.id));
4978
5271
  if (job.schedule.type === "reserved") {
4979
5272
  const result2 = yield* executeJob(job).pipe(
4980
- Effect36.matchEffect({
4981
- onSuccess: () => Effect36.void,
4982
- onFailure: () => Effect36.void
5273
+ Effect38.matchEffect({
5274
+ onSuccess: () => Effect38.void,
5275
+ onFailure: () => Effect38.void
4983
5276
  })
4984
5277
  );
4985
- yield* Ref10.update(runningJobsRef, (jobs) => {
5278
+ yield* Ref11.update(runningJobsRef, (jobs) => {
4986
5279
  const newJobs = new Set(jobs);
4987
5280
  newJobs.delete(job.id);
4988
5281
  return newJobs;
4989
5282
  });
4990
5283
  yield* deleteJobFromConfig(job.id).pipe(
4991
- Effect36.catchAll((error) => {
5284
+ Effect38.catchAll((error) => {
4992
5285
  console.error(
4993
5286
  `[Scheduler] Failed to delete reserved job ${job.id}:`,
4994
5287
  error
4995
5288
  );
4996
- return Effect36.void;
5289
+ return Effect38.void;
4997
5290
  })
4998
5291
  );
4999
5292
  return result2;
5000
5293
  }
5001
5294
  const result = yield* executeJob(job).pipe(
5002
- Effect36.matchEffect({
5295
+ Effect38.matchEffect({
5003
5296
  onSuccess: () => updateJobStatus(job.id, "success", (/* @__PURE__ */ new Date()).toISOString()),
5004
5297
  onFailure: () => updateJobStatus(job.id, "failed", (/* @__PURE__ */ new Date()).toISOString())
5005
5298
  })
5006
5299
  );
5007
- yield* Ref10.update(runningJobsRef, (jobs) => {
5300
+ yield* Ref11.update(runningJobsRef, (jobs) => {
5008
5301
  const newJobs = new Set(jobs);
5009
5302
  newJobs.delete(job.id);
5010
5303
  return newJobs;
5011
5304
  });
5012
5305
  return result;
5013
5306
  });
5014
- const updateJobStatus = (jobId, status, runAt) => Effect36.gen(function* () {
5307
+ const updateJobStatus = (jobId, status, runAt) => Effect38.gen(function* () {
5015
5308
  const config = yield* readConfig;
5016
5309
  const job = config.jobs.find((j) => j.id === jobId);
5017
5310
  if (job === void 0) {
@@ -5027,19 +5320,19 @@ var LayerImpl23 = Effect36.gen(function* () {
5027
5320
  };
5028
5321
  yield* writeConfig(updatedConfig);
5029
5322
  });
5030
- const stopJob = (jobId) => Effect36.gen(function* () {
5031
- const fibers = yield* Ref10.get(fibersRef);
5323
+ const stopJob = (jobId) => Effect38.gen(function* () {
5324
+ const fibers = yield* Ref11.get(fibersRef);
5032
5325
  const fiber = fibers.get(jobId);
5033
5326
  if (fiber !== void 0) {
5034
5327
  yield* Fiber.interrupt(fiber);
5035
- yield* Ref10.update(fibersRef, (fibers2) => {
5328
+ yield* Ref11.update(fibersRef, (fibers2) => {
5036
5329
  const newFibers = new Map(fibers2);
5037
5330
  newFibers.delete(jobId);
5038
5331
  return newFibers;
5039
5332
  });
5040
5333
  }
5041
5334
  });
5042
- const startScheduler = Effect36.gen(function* () {
5335
+ const startScheduler = Effect38.gen(function* () {
5043
5336
  yield* initializeConfig;
5044
5337
  const config = yield* readConfig;
5045
5338
  for (const job of config.jobs) {
@@ -5048,27 +5341,27 @@ var LayerImpl23 = Effect36.gen(function* () {
5048
5341
  }
5049
5342
  }
5050
5343
  });
5051
- const stopScheduler = Effect36.gen(function* () {
5052
- const fibers = yield* Ref10.get(fibersRef);
5344
+ const stopScheduler = Effect38.gen(function* () {
5345
+ const fibers = yield* Ref11.get(fibersRef);
5053
5346
  for (const fiber of fibers.values()) {
5054
5347
  yield* Fiber.interrupt(fiber);
5055
5348
  }
5056
- yield* Ref10.set(fibersRef, /* @__PURE__ */ new Map());
5349
+ yield* Ref11.set(fibersRef, /* @__PURE__ */ new Map());
5057
5350
  });
5058
- const getJobs = () => Effect36.gen(function* () {
5351
+ const getJobs = () => Effect38.gen(function* () {
5059
5352
  const config = yield* readConfig.pipe(
5060
- Effect36.catchTags({
5061
- ConfigFileNotFoundError: () => initializeConfig.pipe(Effect36.map(() => ({ jobs: [] }))),
5062
- ConfigParseError: () => initializeConfig.pipe(Effect36.map(() => ({ jobs: [] })))
5353
+ Effect38.catchTags({
5354
+ ConfigFileNotFoundError: () => initializeConfig.pipe(Effect38.map(() => ({ jobs: [] }))),
5355
+ ConfigParseError: () => initializeConfig.pipe(Effect38.map(() => ({ jobs: [] })))
5063
5356
  })
5064
5357
  );
5065
5358
  return config.jobs;
5066
5359
  });
5067
- const addJob = (newJob) => Effect36.gen(function* () {
5360
+ const addJob = (newJob) => Effect38.gen(function* () {
5068
5361
  const config = yield* readConfig.pipe(
5069
- Effect36.catchTags({
5070
- ConfigFileNotFoundError: () => initializeConfig.pipe(Effect36.map(() => ({ jobs: [] }))),
5071
- ConfigParseError: () => initializeConfig.pipe(Effect36.map(() => ({ jobs: [] })))
5362
+ Effect38.catchTags({
5363
+ ConfigFileNotFoundError: () => initializeConfig.pipe(Effect38.map(() => ({ jobs: [] }))),
5364
+ ConfigParseError: () => initializeConfig.pipe(Effect38.map(() => ({ jobs: [] })))
5072
5365
  })
5073
5366
  );
5074
5367
  const job = {
@@ -5087,16 +5380,16 @@ var LayerImpl23 = Effect36.gen(function* () {
5087
5380
  }
5088
5381
  return job;
5089
5382
  });
5090
- const updateJob = (jobId, updates) => Effect36.gen(function* () {
5383
+ const updateJob = (jobId, updates) => Effect38.gen(function* () {
5091
5384
  const config = yield* readConfig.pipe(
5092
- Effect36.catchTags({
5093
- ConfigFileNotFoundError: () => initializeConfig.pipe(Effect36.map(() => ({ jobs: [] }))),
5094
- ConfigParseError: () => initializeConfig.pipe(Effect36.map(() => ({ jobs: [] })))
5385
+ Effect38.catchTags({
5386
+ ConfigFileNotFoundError: () => initializeConfig.pipe(Effect38.map(() => ({ jobs: [] }))),
5387
+ ConfigParseError: () => initializeConfig.pipe(Effect38.map(() => ({ jobs: [] })))
5095
5388
  })
5096
5389
  );
5097
5390
  const job = config.jobs.find((j) => j.id === jobId);
5098
5391
  if (job === void 0) {
5099
- return yield* Effect36.fail(new SchedulerJobNotFoundError({ jobId }));
5392
+ return yield* Effect38.fail(new SchedulerJobNotFoundError({ jobId }));
5100
5393
  }
5101
5394
  yield* stopJob(jobId);
5102
5395
  const updatedJob = {
@@ -5112,32 +5405,32 @@ var LayerImpl23 = Effect36.gen(function* () {
5112
5405
  }
5113
5406
  return updatedJob;
5114
5407
  });
5115
- const deleteJobFromConfig = (jobId) => Effect36.gen(function* () {
5408
+ const deleteJobFromConfig = (jobId) => Effect38.gen(function* () {
5116
5409
  const config = yield* readConfig.pipe(
5117
- Effect36.catchTags({
5118
- ConfigFileNotFoundError: () => initializeConfig.pipe(Effect36.map(() => ({ jobs: [] }))),
5119
- ConfigParseError: () => initializeConfig.pipe(Effect36.map(() => ({ jobs: [] })))
5410
+ Effect38.catchTags({
5411
+ ConfigFileNotFoundError: () => initializeConfig.pipe(Effect38.map(() => ({ jobs: [] }))),
5412
+ ConfigParseError: () => initializeConfig.pipe(Effect38.map(() => ({ jobs: [] })))
5120
5413
  })
5121
5414
  );
5122
5415
  const job = config.jobs.find((j) => j.id === jobId);
5123
5416
  if (job === void 0) {
5124
- return yield* Effect36.fail(new SchedulerJobNotFoundError({ jobId }));
5417
+ return yield* Effect38.fail(new SchedulerJobNotFoundError({ jobId }));
5125
5418
  }
5126
5419
  const updatedConfig = {
5127
5420
  jobs: config.jobs.filter((j) => j.id !== jobId)
5128
5421
  };
5129
5422
  yield* writeConfig(updatedConfig);
5130
5423
  });
5131
- const deleteJob = (jobId) => Effect36.gen(function* () {
5424
+ const deleteJob = (jobId) => Effect38.gen(function* () {
5132
5425
  const config = yield* readConfig.pipe(
5133
- Effect36.catchTags({
5134
- ConfigFileNotFoundError: () => initializeConfig.pipe(Effect36.map(() => ({ jobs: [] }))),
5135
- ConfigParseError: () => initializeConfig.pipe(Effect36.map(() => ({ jobs: [] })))
5426
+ Effect38.catchTags({
5427
+ ConfigFileNotFoundError: () => initializeConfig.pipe(Effect38.map(() => ({ jobs: [] }))),
5428
+ ConfigParseError: () => initializeConfig.pipe(Effect38.map(() => ({ jobs: [] })))
5136
5429
  })
5137
5430
  );
5138
5431
  const job = config.jobs.find((j) => j.id === jobId);
5139
5432
  if (job === void 0) {
5140
- return yield* Effect36.fail(new SchedulerJobNotFoundError({ jobId }));
5433
+ return yield* Effect38.fail(new SchedulerJobNotFoundError({ jobId }));
5141
5434
  }
5142
5435
  yield* stopJob(jobId);
5143
5436
  yield* deleteJobFromConfig(jobId);
@@ -5151,24 +5444,24 @@ var LayerImpl23 = Effect36.gen(function* () {
5151
5444
  deleteJob
5152
5445
  };
5153
5446
  });
5154
- var SchedulerService = class extends Context29.Tag("SchedulerService")() {
5447
+ var SchedulerService = class extends Context30.Tag("SchedulerService")() {
5155
5448
  static {
5156
- this.Live = Layer31.effect(this, LayerImpl23);
5449
+ this.Live = Layer32.effect(this, LayerImpl24);
5157
5450
  }
5158
5451
  };
5159
5452
 
5160
5453
  // src/server/core/scheduler/presentation/SchedulerController.ts
5161
- import { Context as Context30, Effect as Effect37, Layer as Layer32 } from "effect";
5162
- var LayerImpl24 = Effect37.gen(function* () {
5454
+ import { Context as Context31, Effect as Effect39, Layer as Layer33 } from "effect";
5455
+ var LayerImpl25 = Effect39.gen(function* () {
5163
5456
  const schedulerService = yield* SchedulerService;
5164
- const getJobs = () => Effect37.gen(function* () {
5457
+ const getJobs = () => Effect39.gen(function* () {
5165
5458
  const jobs = yield* schedulerService.getJobs();
5166
5459
  return {
5167
5460
  response: jobs,
5168
5461
  status: 200
5169
5462
  };
5170
5463
  });
5171
- const addJob = (options) => Effect37.gen(function* () {
5464
+ const addJob = (options) => Effect39.gen(function* () {
5172
5465
  const { job } = options;
5173
5466
  const result = yield* schedulerService.addJob(job);
5174
5467
  return {
@@ -5176,12 +5469,12 @@ var LayerImpl24 = Effect37.gen(function* () {
5176
5469
  status: 201
5177
5470
  };
5178
5471
  });
5179
- const updateJob = (options) => Effect37.gen(function* () {
5472
+ const updateJob = (options) => Effect39.gen(function* () {
5180
5473
  const { id, job } = options;
5181
5474
  const result = yield* schedulerService.updateJob(id, job).pipe(
5182
- Effect37.catchTag(
5475
+ Effect39.catchTag(
5183
5476
  "SchedulerJobNotFoundError",
5184
- () => Effect37.succeed(null)
5477
+ () => Effect39.succeed(null)
5185
5478
  )
5186
5479
  );
5187
5480
  if (result === null) {
@@ -5195,14 +5488,14 @@ var LayerImpl24 = Effect37.gen(function* () {
5195
5488
  status: 200
5196
5489
  };
5197
5490
  });
5198
- const deleteJob = (options) => Effect37.gen(function* () {
5491
+ const deleteJob = (options) => Effect39.gen(function* () {
5199
5492
  const { id } = options;
5200
5493
  const result = yield* schedulerService.deleteJob(id).pipe(
5201
- Effect37.catchTag(
5494
+ Effect39.catchTag(
5202
5495
  "SchedulerJobNotFoundError",
5203
- () => Effect37.succeed(false)
5496
+ () => Effect39.succeed(false)
5204
5497
  ),
5205
- Effect37.map(() => true)
5498
+ Effect39.map(() => true)
5206
5499
  );
5207
5500
  if (!result) {
5208
5501
  return {
@@ -5222,18 +5515,18 @@ var LayerImpl24 = Effect37.gen(function* () {
5222
5515
  deleteJob
5223
5516
  };
5224
5517
  });
5225
- var SchedulerController = class extends Context30.Tag("SchedulerController")() {
5518
+ var SchedulerController = class extends Context31.Tag("SchedulerController")() {
5226
5519
  static {
5227
- this.Live = Layer32.effect(this, LayerImpl24);
5520
+ this.Live = Layer33.effect(this, LayerImpl25);
5228
5521
  }
5229
5522
  };
5230
5523
 
5231
5524
  // src/server/core/search/presentation/SearchController.ts
5232
- import { Context as Context32, Effect as Effect39, Layer as Layer34 } from "effect";
5525
+ import { Context as Context33, Effect as Effect41, Layer as Layer35 } from "effect";
5233
5526
 
5234
5527
  // src/server/core/search/services/SearchService.ts
5235
5528
  import { FileSystem as FileSystem13, Path as Path17 } from "@effect/platform";
5236
- import { Context as Context31, Effect as Effect38, Layer as Layer33, Ref as Ref11 } from "effect";
5529
+ import { Context as Context32, Effect as Effect40, Layer as Layer34, Ref as Ref12 } from "effect";
5237
5530
  import MiniSearch from "minisearch";
5238
5531
 
5239
5532
  // src/server/core/search/functions/extractSearchableText.ts
@@ -5279,13 +5572,13 @@ var createMiniSearchIndex = () => new MiniSearch({
5279
5572
  boost: { text: 1 }
5280
5573
  }
5281
5574
  });
5282
- var LayerImpl25 = Effect38.gen(function* () {
5575
+ var LayerImpl26 = Effect40.gen(function* () {
5283
5576
  const fs = yield* FileSystem13.FileSystem;
5284
5577
  const path = yield* Path17.Path;
5285
5578
  const context = yield* ApplicationContext;
5286
- const indexCacheRef = yield* Ref11.make(null);
5287
- const buildIndex = () => Effect38.gen(function* () {
5288
- const { claudeProjectsDirPath } = context.claudeCodePaths;
5579
+ const indexCacheRef = yield* Ref12.make(null);
5580
+ const buildIndex = () => Effect40.gen(function* () {
5581
+ const { claudeProjectsDirPath } = yield* context.claudeCodePaths;
5289
5582
  const dirExists = yield* fs.exists(claudeProjectsDirPath);
5290
5583
  if (!dirExists) {
5291
5584
  return { index: createMiniSearchIndex(), documents: /* @__PURE__ */ new Map() };
@@ -5293,22 +5586,22 @@ var LayerImpl25 = Effect38.gen(function* () {
5293
5586
  const projectEntries = yield* fs.readDirectory(claudeProjectsDirPath);
5294
5587
  const miniSearch = createMiniSearchIndex();
5295
5588
  const documentEffects = projectEntries.map(
5296
- (projectEntry) => Effect38.gen(function* () {
5589
+ (projectEntry) => Effect40.gen(function* () {
5297
5590
  const projectPath = path.resolve(claudeProjectsDirPath, projectEntry);
5298
- const stat = yield* fs.stat(projectPath).pipe(Effect38.catchAll(() => Effect38.succeed(null)));
5591
+ const stat = yield* fs.stat(projectPath).pipe(Effect40.catchAll(() => Effect40.succeed(null)));
5299
5592
  if (stat?.type !== "Directory") {
5300
5593
  return [];
5301
5594
  }
5302
5595
  const projectId = encodeProjectId(projectPath);
5303
5596
  const projectName = path.basename(projectPath);
5304
- const sessionEntries = yield* fs.readDirectory(projectPath).pipe(Effect38.catchAll(() => Effect38.succeed([])));
5597
+ const sessionEntries = yield* fs.readDirectory(projectPath).pipe(Effect40.catchAll(() => Effect40.succeed([])));
5305
5598
  const sessionFiles = sessionEntries.filter(isRegularSessionFile);
5306
- const sessionDocuments = yield* Effect38.all(
5599
+ const sessionDocuments = yield* Effect40.all(
5307
5600
  sessionFiles.map(
5308
- (sessionFile) => Effect38.gen(function* () {
5601
+ (sessionFile) => Effect40.gen(function* () {
5309
5602
  const sessionPath = path.resolve(projectPath, sessionFile);
5310
5603
  const sessionId = encodeSessionId(sessionPath);
5311
- const content = yield* fs.readFileString(sessionPath).pipe(Effect38.catchAll(() => Effect38.succeed("")));
5604
+ const content = yield* fs.readFileString(sessionPath).pipe(Effect40.catchAll(() => Effect40.succeed("")));
5312
5605
  if (!content) return [];
5313
5606
  const conversations = parseJsonl(content);
5314
5607
  const documents = [];
@@ -5343,7 +5636,7 @@ var LayerImpl25 = Effect38.gen(function* () {
5343
5636
  return sessionDocuments.flat();
5344
5637
  })
5345
5638
  );
5346
- const allDocuments = yield* Effect38.all(documentEffects, {
5639
+ const allDocuments = yield* Effect40.all(documentEffects, {
5347
5640
  concurrency: 10
5348
5641
  });
5349
5642
  const flatDocuments = allDocuments.flat();
@@ -5354,18 +5647,18 @@ var LayerImpl25 = Effect38.gen(function* () {
5354
5647
  }
5355
5648
  return { index: miniSearch, documents: documentsMap };
5356
5649
  });
5357
- const getIndex = () => Effect38.gen(function* () {
5358
- const cached = yield* Ref11.get(indexCacheRef);
5650
+ const getIndex = () => Effect40.gen(function* () {
5651
+ const cached = yield* Ref12.get(indexCacheRef);
5359
5652
  const now = Date.now();
5360
5653
  if (cached && now - cached.builtAt < INDEX_TTL_MS) {
5361
5654
  return { index: cached.index, documents: cached.documents };
5362
5655
  }
5363
5656
  const { index, documents } = yield* buildIndex();
5364
- yield* Ref11.set(indexCacheRef, { index, documents, builtAt: now });
5657
+ yield* Ref12.set(indexCacheRef, { index, documents, builtAt: now });
5365
5658
  return { index, documents };
5366
5659
  });
5367
- const search = (query2, limit = 20, projectId) => Effect38.gen(function* () {
5368
- const { claudeProjectsDirPath } = context.claudeCodePaths;
5660
+ const search = (query2, limit = 20, projectId) => Effect40.gen(function* () {
5661
+ const { claudeProjectsDirPath } = yield* context.claudeCodePaths;
5369
5662
  const dirExists = yield* fs.exists(claudeProjectsDirPath);
5370
5663
  if (!dirExists) {
5371
5664
  return { results: [] };
@@ -5405,22 +5698,22 @@ var LayerImpl25 = Effect38.gen(function* () {
5405
5698
  }
5406
5699
  return { results };
5407
5700
  });
5408
- const invalidateIndex = () => Ref11.set(indexCacheRef, null);
5701
+ const invalidateIndex = () => Ref12.set(indexCacheRef, null);
5409
5702
  return {
5410
5703
  search,
5411
5704
  invalidateIndex
5412
5705
  };
5413
5706
  });
5414
- var SearchService = class extends Context31.Tag("SearchService")() {
5707
+ var SearchService = class extends Context32.Tag("SearchService")() {
5415
5708
  static {
5416
- this.Live = Layer33.effect(this, LayerImpl25);
5709
+ this.Live = Layer34.effect(this, LayerImpl26);
5417
5710
  }
5418
5711
  };
5419
5712
 
5420
5713
  // src/server/core/search/presentation/SearchController.ts
5421
- var LayerImpl26 = Effect39.gen(function* () {
5714
+ var LayerImpl27 = Effect41.gen(function* () {
5422
5715
  const searchService = yield* SearchService;
5423
- const search = (options) => Effect39.gen(function* () {
5716
+ const search = (options) => Effect41.gen(function* () {
5424
5717
  const { query: query2, limit, projectId } = options;
5425
5718
  if (query2.trim().length < 2) {
5426
5719
  return {
@@ -5444,17 +5737,17 @@ var LayerImpl26 = Effect39.gen(function* () {
5444
5737
  search
5445
5738
  };
5446
5739
  });
5447
- var SearchController = class extends Context32.Tag("SearchController")() {
5740
+ var SearchController = class extends Context33.Tag("SearchController")() {
5448
5741
  static {
5449
- this.Live = Layer34.effect(this, LayerImpl26);
5742
+ this.Live = Layer35.effect(this, LayerImpl27);
5450
5743
  }
5451
5744
  };
5452
5745
 
5453
5746
  // src/server/core/session/presentation/SessionController.ts
5454
- import { Context as Context33, Effect as Effect41, Layer as Layer35 } from "effect";
5747
+ import { Context as Context34, Effect as Effect43, Layer as Layer36 } from "effect";
5455
5748
 
5456
5749
  // src/server/core/session/services/ExportService.ts
5457
- import { Effect as Effect40 } from "effect";
5750
+ import { Effect as Effect42 } from "effect";
5458
5751
  var escapeHtml = (text) => {
5459
5752
  const map = {
5460
5753
  "&": "&amp;",
@@ -5607,7 +5900,18 @@ var renderAssistantEntry = (entry) => {
5607
5900
  </div>
5608
5901
  `;
5609
5902
  };
5903
+ var getSystemEntryContent = (entry) => {
5904
+ if ("content" in entry && typeof entry.content === "string") {
5905
+ return entry.content;
5906
+ }
5907
+ if ("subtype" in entry && entry.subtype === "stop_hook_summary") {
5908
+ const hookNames = entry.hookInfos.map((h) => h.command).join(", ");
5909
+ return `Stop hook executed: ${hookNames}`;
5910
+ }
5911
+ return "System message";
5912
+ };
5610
5913
  var renderSystemEntry = (entry) => {
5914
+ const content = getSystemEntryContent(entry);
5611
5915
  return `
5612
5916
  <div class="conversation-entry system-entry">
5613
5917
  <div class="entry-header">
@@ -5615,7 +5919,7 @@ var renderSystemEntry = (entry) => {
5615
5919
  <span class="entry-timestamp">${formatTimestamp(entry.timestamp)}</span>
5616
5920
  </div>
5617
5921
  <div class="entry-content">
5618
- <div class="system-message">${escapeHtml(entry.content)}</div>
5922
+ <div class="system-message">${escapeHtml(content)}</div>
5619
5923
  </div>
5620
5924
  </div>
5621
5925
  `;
@@ -5713,7 +6017,7 @@ var renderGroupedAssistantEntries = (entries) => {
5713
6017
  </div>
5714
6018
  `;
5715
6019
  };
5716
- var generateSessionHtml = (session, projectId) => Effect40.gen(function* () {
6020
+ var generateSessionHtml = (session, projectId) => Effect42.gen(function* () {
5717
6021
  const grouped = groupConsecutiveAssistantMessages(session.conversations);
5718
6022
  const conversationsHtml = grouped.map((group) => {
5719
6023
  if (group.type === "grouped") {
@@ -6233,9 +6537,9 @@ var generateSessionHtml = (session, projectId) => Effect40.gen(function* () {
6233
6537
  });
6234
6538
 
6235
6539
  // src/server/core/session/presentation/SessionController.ts
6236
- var LayerImpl27 = Effect41.gen(function* () {
6540
+ var LayerImpl28 = Effect43.gen(function* () {
6237
6541
  const sessionRepository = yield* SessionRepository;
6238
- const getSession = (options) => Effect41.gen(function* () {
6542
+ const getSession = (options) => Effect43.gen(function* () {
6239
6543
  const { projectId, sessionId } = options;
6240
6544
  const { session } = yield* sessionRepository.getSession(
6241
6545
  projectId,
@@ -6246,7 +6550,7 @@ var LayerImpl27 = Effect41.gen(function* () {
6246
6550
  response: { session }
6247
6551
  };
6248
6552
  });
6249
- const exportSessionHtml = (options) => Effect41.gen(function* () {
6553
+ const exportSessionHtml = (options) => Effect43.gen(function* () {
6250
6554
  const { projectId, sessionId } = options;
6251
6555
  const { session } = yield* sessionRepository.getSession(
6252
6556
  projectId,
@@ -6269,9 +6573,9 @@ var LayerImpl27 = Effect41.gen(function* () {
6269
6573
  exportSessionHtml
6270
6574
  };
6271
6575
  });
6272
- var SessionController = class extends Context33.Tag("SessionController")() {
6576
+ var SessionController = class extends Context34.Tag("SessionController")() {
6273
6577
  static {
6274
- this.Live = Layer35.effect(this, LayerImpl27);
6578
+ this.Live = Layer36.effect(this, LayerImpl28);
6275
6579
  }
6276
6580
  };
6277
6581
 
@@ -6280,12 +6584,12 @@ import { Hono } from "hono";
6280
6584
  var honoApp = new Hono();
6281
6585
 
6282
6586
  // src/server/hono/initialize.ts
6283
- import { Context as Context34, Effect as Effect42, Layer as Layer36, Ref as Ref12, Schedule as Schedule2 } from "effect";
6284
- var InitializeService = class extends Context34.Tag("InitializeService")() {
6587
+ import { Context as Context35, Effect as Effect44, Layer as Layer37, Ref as Ref13, Schedule as Schedule2 } from "effect";
6588
+ var InitializeService = class extends Context35.Tag("InitializeService")() {
6285
6589
  static {
6286
- this.Live = Layer36.effect(
6590
+ this.Live = Layer37.effect(
6287
6591
  this,
6288
- Effect42.gen(function* () {
6592
+ Effect44.gen(function* () {
6289
6593
  const eventBus = yield* EventBus;
6290
6594
  const fileWatcher = yield* FileWatcherService;
6291
6595
  const projectRepository = yield* ProjectRepository;
@@ -6293,22 +6597,22 @@ var InitializeService = class extends Context34.Tag("InitializeService")() {
6293
6597
  const projectMetaService = yield* ProjectMetaService;
6294
6598
  const sessionMetaService = yield* SessionMetaService;
6295
6599
  const virtualConversationDatabase = yield* VirtualConversationDatabase;
6296
- const listenersRef = yield* Ref12.make({});
6600
+ const listenersRef = yield* Ref13.make({});
6297
6601
  const startInitialization = () => {
6298
- return Effect42.gen(function* () {
6602
+ return Effect44.gen(function* () {
6299
6603
  yield* fileWatcher.startWatching();
6300
- const daemon = Effect42.repeat(
6604
+ const daemon = Effect44.repeat(
6301
6605
  eventBus.emit("heartbeat", {}),
6302
6606
  Schedule2.fixed("10 seconds")
6303
6607
  );
6304
6608
  console.log("start heartbeat");
6305
- yield* Effect42.forkDaemon(daemon);
6609
+ yield* Effect44.forkDaemon(daemon);
6306
6610
  console.log("after starting heartbeat fork");
6307
6611
  const onSessionChanged = (event) => {
6308
- Effect42.runFork(
6612
+ Effect44.runFork(
6309
6613
  projectMetaService.invalidateProject(event.projectId)
6310
6614
  );
6311
- Effect42.runFork(
6615
+ Effect44.runFork(
6312
6616
  sessionMetaService.invalidateSession(
6313
6617
  event.projectId,
6314
6618
  event.sessionId
@@ -6317,7 +6621,7 @@ var InitializeService = class extends Context34.Tag("InitializeService")() {
6317
6621
  };
6318
6622
  const onSessionProcessChanged = (event) => {
6319
6623
  if ((event.changed.type === "completed" || event.changed.type === "paused") && event.changed.sessionId !== void 0) {
6320
- Effect42.runFork(
6624
+ Effect44.runFork(
6321
6625
  virtualConversationDatabase.deleteVirtualConversations(
6322
6626
  event.changed.sessionId
6323
6627
  )
@@ -6325,18 +6629,18 @@ var InitializeService = class extends Context34.Tag("InitializeService")() {
6325
6629
  return;
6326
6630
  }
6327
6631
  };
6328
- yield* Ref12.set(listenersRef, {
6632
+ yield* Ref13.set(listenersRef, {
6329
6633
  sessionChanged: onSessionChanged,
6330
6634
  sessionProcessChanged: onSessionProcessChanged
6331
6635
  });
6332
6636
  yield* eventBus.on("sessionChanged", onSessionChanged);
6333
6637
  yield* eventBus.on("sessionProcessChanged", onSessionProcessChanged);
6334
- yield* Effect42.gen(function* () {
6638
+ yield* Effect44.gen(function* () {
6335
6639
  console.log("Initializing projects cache");
6336
6640
  const { projects } = yield* projectRepository.getProjects();
6337
6641
  console.log(`${projects.length} projects cache initialized`);
6338
6642
  console.log("Initializing sessions cache");
6339
- const results = yield* Effect42.all(
6643
+ const results = yield* Effect44.all(
6340
6644
  projects.map(
6341
6645
  (project) => sessionRepository.getSessions(project.id)
6342
6646
  ),
@@ -6348,13 +6652,13 @@ var InitializeService = class extends Context34.Tag("InitializeService")() {
6348
6652
  );
6349
6653
  console.log(`${totalSessions} sessions cache initialized`);
6350
6654
  }).pipe(
6351
- Effect42.catchAll(() => Effect42.void),
6352
- Effect42.withSpan("initialize-cache")
6655
+ Effect44.catchAll(() => Effect44.void),
6656
+ Effect44.withSpan("initialize-cache")
6353
6657
  );
6354
- }).pipe(Effect42.withSpan("start-initialization"));
6658
+ }).pipe(Effect44.withSpan("start-initialization"));
6355
6659
  };
6356
- const stopCleanup = () => Effect42.gen(function* () {
6357
- const listeners = yield* Ref12.get(listenersRef);
6660
+ const stopCleanup = () => Effect44.gen(function* () {
6661
+ const listeners = yield* Ref13.get(listenersRef);
6358
6662
  if (listeners.sessionChanged) {
6359
6663
  yield* eventBus.off("sessionChanged", listeners.sessionChanged);
6360
6664
  }
@@ -6364,7 +6668,7 @@ var InitializeService = class extends Context34.Tag("InitializeService")() {
6364
6668
  listeners.sessionProcessChanged
6365
6669
  );
6366
6670
  }
6367
- yield* Ref12.set(listenersRef, {});
6671
+ yield* Ref13.set(listenersRef, {});
6368
6672
  yield* fileWatcher.stop();
6369
6673
  });
6370
6674
  return {
@@ -6377,7 +6681,7 @@ var InitializeService = class extends Context34.Tag("InitializeService")() {
6377
6681
  };
6378
6682
 
6379
6683
  // src/server/hono/middleware/auth.middleware.ts
6380
- import { Context as Context35, Effect as Effect43, Layer as Layer37 } from "effect";
6684
+ import { Context as Context36, Effect as Effect45, Layer as Layer38 } from "effect";
6381
6685
  import { getCookie } from "hono/cookie";
6382
6686
  import { createMiddleware } from "hono/factory";
6383
6687
  var generateSessionToken = (password) => {
@@ -6392,180 +6696,50 @@ var PUBLIC_API_ROUTES = [
6392
6696
  // Allow config access for theme/locale loading
6393
6697
  "/api/version"
6394
6698
  ];
6395
- var LayerImpl28 = Effect43.gen(function* () {
6396
- const envService = yield* EnvService;
6397
- const anthPassword = yield* envService.getEnv(
6398
- "CLAUDE_CODE_VIEWER_AUTH_PASSWORD"
6399
- ) ?? void 0;
6400
- const authEnabled = anthPassword !== void 0;
6401
- const validSessionToken = generateSessionToken(anthPassword);
6402
- const authMiddleware = createMiddleware(async (c, next) => {
6403
- if (PUBLIC_API_ROUTES.includes(c.req.path)) {
6404
- return next();
6405
- }
6406
- if (!c.req.path.startsWith("/api")) {
6407
- return next();
6408
- }
6409
- if (!authEnabled) {
6410
- return next();
6411
- }
6412
- const sessionToken = getCookie(c, "ccv-session");
6413
- if (!sessionToken || sessionToken !== validSessionToken) {
6414
- return c.json({ error: "Unauthorized" }, 401);
6415
- }
6416
- await next();
6699
+ var LayerImpl29 = Effect45.gen(function* () {
6700
+ const ccvOptionsService = yield* CcvOptionsService;
6701
+ return Effect45.gen(function* () {
6702
+ const anthPassword = yield* ccvOptionsService.getCcvOptions("password");
6703
+ const authEnabled = anthPassword !== void 0;
6704
+ const validSessionToken = generateSessionToken(anthPassword);
6705
+ const authMiddleware = createMiddleware(async (c, next) => {
6706
+ if (PUBLIC_API_ROUTES.includes(c.req.path)) {
6707
+ return next();
6708
+ }
6709
+ if (!c.req.path.startsWith("/api")) {
6710
+ return next();
6711
+ }
6712
+ if (!authEnabled) {
6713
+ return next();
6714
+ }
6715
+ const sessionToken = getCookie(c, "ccv-session");
6716
+ if (!sessionToken || sessionToken !== validSessionToken) {
6717
+ return c.json({ error: "Unauthorized" }, 401);
6718
+ }
6719
+ await next();
6720
+ });
6721
+ return {
6722
+ authEnabled,
6723
+ anthPassword,
6724
+ validSessionToken,
6725
+ authMiddleware
6726
+ };
6417
6727
  });
6418
- return {
6419
- authEnabled,
6420
- anthPassword,
6421
- validSessionToken,
6422
- authMiddleware
6423
- };
6424
6728
  });
6425
- var AuthMiddleware = class extends Context35.Tag("AuthMiddleware")() {
6729
+ var AuthMiddleware = class extends Context36.Tag("AuthMiddleware")() {
6426
6730
  static {
6427
- this.Live = Layer37.effect(this, LayerImpl28);
6731
+ this.Live = Layer38.effect(this, LayerImpl29);
6428
6732
  }
6429
6733
  };
6430
6734
 
6431
6735
  // src/server/hono/route.ts
6432
6736
  import { zValidator } from "@hono/zod-validator";
6433
- import { Effect as Effect45, Runtime as Runtime3 } from "effect";
6737
+ import { Effect as Effect47, Runtime as Runtime3 } from "effect";
6434
6738
  import { deleteCookie, getCookie as getCookie3, setCookie as setCookie2 } from "hono/cookie";
6435
6739
  import { streamSSE } from "hono/streaming";
6436
6740
  import prexit from "prexit";
6437
6741
  import { z as z28 } from "zod";
6438
6742
 
6439
- // package.json
6440
- var package_default = {
6441
- name: "@kimuson/claude-code-viewer",
6442
- version: "0.4.15",
6443
- type: "module",
6444
- license: "MIT",
6445
- repository: {
6446
- type: "git",
6447
- url: "https://github.com/d-kimuson/claude-code-viewer.git"
6448
- },
6449
- homepage: "https://github.com/d-kimuson/claude-code-viewer",
6450
- files: [
6451
- "dist"
6452
- ],
6453
- engines: {
6454
- node: ">=20.19.0"
6455
- },
6456
- bin: {
6457
- "claude-code-viewer": "./dist/main.js"
6458
- },
6459
- scripts: {
6460
- dev: "run-p 'dev:*'",
6461
- "dev:frontend": "vite",
6462
- "dev:backend": "NODE_ENV=development tsx watch src/server/main.ts --env-file-if-exists=.env.local",
6463
- start: "node dist/index.js",
6464
- build: "./scripts/build.sh",
6465
- "build:frontend": "vite build",
6466
- "build:backend": "esbuild src/server/main.ts --format=esm --bundle --packages=external --sourcemap --platform=node --outfile=dist/main.js",
6467
- lint: "run-s 'lint:*'",
6468
- "lint:biome-format": "biome format .",
6469
- "lint:biome-lint": "biome check .",
6470
- fix: "run-s 'fix:*'",
6471
- "fix:biome-format": "biome format --write .",
6472
- "fix:biome-lint": "biome check --write --unsafe .",
6473
- typecheck: "tsc --noEmit",
6474
- test: "vitest --run",
6475
- "test:watch": "vitest",
6476
- e2e: "./scripts/e2e/exec_e2e.sh",
6477
- "e2e:start-server": "./scripts/e2e/start_server.sh",
6478
- "e2e:capture-snapshots": "./scripts/e2e/capture_snapshots.sh",
6479
- "lingui:extract": "lingui extract --clean && node ./scripts/lingui-sort.js",
6480
- "lingui:compile": "lingui compile --typescript",
6481
- prepare: "lefthook install"
6482
- },
6483
- dependencies: {
6484
- "@anthropic-ai/claude-agent-sdk": "0.1.30",
6485
- "@anthropic-ai/claude-code": "2.0.24",
6486
- "@anthropic-ai/sdk": "0.67.0",
6487
- "@effect/cluster": "0.55.0",
6488
- "@effect/experimental": "0.57.11",
6489
- "@effect/platform": "0.93.6",
6490
- "@effect/platform-node": "0.103.0",
6491
- "@effect/rpc": "0.72.2",
6492
- "@effect/sql": "0.48.6",
6493
- "@effect/workflow": "0.15.1",
6494
- "@hono/node-server": "1.19.5",
6495
- "@hono/zod-validator": "0.7.4",
6496
- "@lingui/core": "5.5.1",
6497
- "@lingui/react": "5.5.1",
6498
- "@radix-ui/react-avatar": "1.1.10",
6499
- "@radix-ui/react-checkbox": "1.3.3",
6500
- "@radix-ui/react-collapsible": "1.1.12",
6501
- "@radix-ui/react-dialog": "1.1.15",
6502
- "@radix-ui/react-hover-card": "1.1.15",
6503
- "@radix-ui/react-popover": "1.1.15",
6504
- "@radix-ui/react-select": "2.2.6",
6505
- "@radix-ui/react-slot": "1.2.3",
6506
- "@radix-ui/react-tabs": "1.1.13",
6507
- "@radix-ui/react-tooltip": "1.2.8",
6508
- "@tailwindcss/vite": "4.1.16",
6509
- "@tanstack/react-devtools": "0.7.8",
6510
- "@tanstack/react-query": "5.90.5",
6511
- "@tanstack/react-router": "1.133.32",
6512
- "@tanstack/react-router-devtools": "1.133.32",
6513
- "class-variance-authority": "0.7.1",
6514
- clsx: "2.1.1",
6515
- "date-fns": "4.1.0",
6516
- effect: "3.19.9",
6517
- "es-toolkit": "1.41.0",
6518
- hono: "4.10.3",
6519
- jotai: "2.15.0",
6520
- "lucide-react": "0.548.0",
6521
- minisearch: "7.2.0",
6522
- "parse-git-diff": "0.0.19",
6523
- prexit: "2.3.0",
6524
- react: "19.2.0",
6525
- "react-dom": "19.2.0",
6526
- "react-error-boundary": "6.0.0",
6527
- "react-helmet-async": "2.0.5",
6528
- "react-markdown": "10.1.0",
6529
- "react-syntax-highlighter": "15.6.6",
6530
- "remark-gfm": "4.0.1",
6531
- sonner: "2.0.7",
6532
- "tailwind-merge": "3.3.1",
6533
- ulid: "3.0.1",
6534
- zod: "4.1.13"
6535
- },
6536
- devDependencies: {
6537
- "@biomejs/biome": "2.3.1",
6538
- "@effect/language-service": "0.60.0",
6539
- "@lingui/cli": "5.5.1",
6540
- "@lingui/conf": "5.5.1",
6541
- "@lingui/format-json": "5.5.1",
6542
- "@lingui/loader": "5.5.1",
6543
- "@lingui/vite-plugin": "5.5.1",
6544
- "@tailwindcss/postcss": "4.1.16",
6545
- "@tanstack/router-plugin": "1.133.32",
6546
- "@tsconfig/strictest": "2.0.6",
6547
- "@types/node": "24.9.1",
6548
- "@types/react": "19.2.2",
6549
- "@types/react-dom": "19.2.2",
6550
- "@types/react-syntax-highlighter": "15.5.13",
6551
- "@vitejs/plugin-react-swc": "4.2.0",
6552
- dotenv: "17.2.3",
6553
- esbuild: "0.25.11",
6554
- lefthook: "2.0.8",
6555
- "npm-run-all2": "8.0.4",
6556
- playwright: "1.56.1",
6557
- "release-it": "19.0.5",
6558
- "release-it-pnpm": "4.6.6",
6559
- tailwindcss: "4.1.16",
6560
- tsx: "4.20.6",
6561
- "tw-animate-css": "1.4.0",
6562
- typescript: "5.9.3",
6563
- vite: "7.1.12",
6564
- vitest: "4.0.3"
6565
- },
6566
- packageManager: "pnpm@10.18.3+sha512.bbd16e6d7286fd7e01f6b3c0b3c932cda2965c06a908328f74663f10a9aea51f1129eea615134bf992831b009eabe167ecb7008b597f40ff9bc75946aadfb08d"
6567
- };
6568
-
6569
6743
  // src/server/core/claude-code/schema.ts
6570
6744
  import { z as z24 } from "zod";
6571
6745
  var mediaTypeSchema = z24.enum([
@@ -6713,9 +6887,9 @@ var userConfigSchema = z27.object({
6713
6887
  var defaultUserConfig = userConfigSchema.parse({});
6714
6888
 
6715
6889
  // src/server/lib/effect/toEffectResponse.ts
6716
- import { Effect as Effect44 } from "effect";
6890
+ import { Effect as Effect46 } from "effect";
6717
6891
  var effectToResponse = async (ctx, effect) => {
6718
- const result = await Effect44.runPromise(effect);
6892
+ const result = await Effect46.runPromise(effect);
6719
6893
  const result2 = ctx.json(result.response, result.status);
6720
6894
  return result2;
6721
6895
  };
@@ -6758,7 +6932,13 @@ var configMiddleware = createMiddleware2(
6758
6932
  );
6759
6933
 
6760
6934
  // src/server/hono/route.ts
6761
- var routes = (app) => Effect45.gen(function* () {
6935
+ var routes = (app, options) => Effect47.gen(function* () {
6936
+ const ccvOptionsService = yield* CcvOptionsService;
6937
+ yield* ccvOptionsService.loadCliOptions(options);
6938
+ const envService = yield* EnvService;
6939
+ const userConfigService = yield* UserConfigService;
6940
+ const claudeCodeLifeCycleService = yield* ClaudeCodeLifeCycleService;
6941
+ const initializeService = yield* InitializeService;
6762
6942
  const projectController = yield* ProjectController;
6763
6943
  const sessionController = yield* SessionController;
6764
6944
  const agentSessionController = yield* AgentSessionController;
@@ -6771,12 +6951,9 @@ var routes = (app) => Effect45.gen(function* () {
6771
6951
  const schedulerController = yield* SchedulerController;
6772
6952
  const featureFlagController = yield* FeatureFlagController;
6773
6953
  const searchController = yield* SearchController;
6774
- const envService = yield* EnvService;
6775
- const userConfigService = yield* UserConfigService;
6776
- const claudeCodeLifeCycleService = yield* ClaudeCodeLifeCycleService;
6777
- const initializeService = yield* InitializeService;
6778
- const { authMiddleware, validSessionToken, authEnabled, anthPassword } = yield* AuthMiddleware;
6779
- const runtime = yield* Effect45.runtime();
6954
+ const authMiddlewareService = yield* AuthMiddleware;
6955
+ const { authMiddleware, validSessionToken, authEnabled, anthPassword } = yield* authMiddlewareService;
6956
+ const runtime = yield* Effect47.runtime();
6780
6957
  if ((yield* envService.getEnv("NEXT_PHASE")) !== "phase-production-build") {
6781
6958
  yield* initializeService.startInitialization();
6782
6959
  prexit(async () => {
@@ -6784,7 +6961,7 @@ var routes = (app) => Effect45.gen(function* () {
6784
6961
  });
6785
6962
  }
6786
6963
  return app.use(configMiddleware).use(authMiddleware).use(async (c, next) => {
6787
- await Effect45.runPromise(
6964
+ await Effect47.runPromise(
6788
6965
  userConfigService.setUserConfig({
6789
6966
  ...c.get("userConfig")
6790
6967
  })
@@ -6853,7 +7030,7 @@ var routes = (app) => Effect45.gen(function* () {
6853
7030
  projectController.getProject({
6854
7031
  ...c.req.param(),
6855
7032
  ...c.req.valid("query")
6856
- }).pipe(Effect45.provide(runtime))
7033
+ }).pipe(Effect47.provide(runtime))
6857
7034
  );
6858
7035
  return response;
6859
7036
  }
@@ -6870,7 +7047,7 @@ var routes = (app) => Effect45.gen(function* () {
6870
7047
  c,
6871
7048
  projectController.createProject({
6872
7049
  ...c.req.valid("json")
6873
- }).pipe(Effect45.provide(runtime))
7050
+ }).pipe(Effect47.provide(runtime))
6874
7051
  );
6875
7052
  return response;
6876
7053
  }
@@ -6879,13 +7056,13 @@ var routes = (app) => Effect45.gen(function* () {
6879
7056
  c,
6880
7057
  projectController.getProjectLatestSession({
6881
7058
  ...c.req.param()
6882
- }).pipe(Effect45.provide(runtime))
7059
+ }).pipe(Effect47.provide(runtime))
6883
7060
  );
6884
7061
  return response;
6885
7062
  }).get("/api/projects/:projectId/sessions/:sessionId", async (c) => {
6886
7063
  const response = await effectToResponse(
6887
7064
  c,
6888
- sessionController.getSession({ ...c.req.param() }).pipe(Effect45.provide(runtime))
7065
+ sessionController.getSession({ ...c.req.param() }).pipe(Effect47.provide(runtime))
6889
7066
  );
6890
7067
  return response;
6891
7068
  }).get(
@@ -6893,7 +7070,7 @@ var routes = (app) => Effect45.gen(function* () {
6893
7070
  async (c) => {
6894
7071
  const response = await effectToResponse(
6895
7072
  c,
6896
- sessionController.exportSessionHtml({ ...c.req.param() }).pipe(Effect45.provide(runtime))
7073
+ sessionController.exportSessionHtml({ ...c.req.param() }).pipe(Effect47.provide(runtime))
6897
7074
  );
6898
7075
  return response;
6899
7076
  }
@@ -6904,7 +7081,7 @@ var routes = (app) => Effect45.gen(function* () {
6904
7081
  agentSessionController.getAgentSession({
6905
7082
  projectId,
6906
7083
  agentId
6907
- }).pipe(Effect45.provide(runtime))
7084
+ }).pipe(Effect47.provide(runtime))
6908
7085
  );
6909
7086
  return response;
6910
7087
  }).get("/api/projects/:projectId/git/current-revisions", async (c) => {
@@ -6912,7 +7089,7 @@ var routes = (app) => Effect45.gen(function* () {
6912
7089
  c,
6913
7090
  gitController.getCurrentRevisions({
6914
7091
  ...c.req.param()
6915
- }).pipe(Effect45.provide(runtime))
7092
+ }).pipe(Effect47.provide(runtime))
6916
7093
  );
6917
7094
  return response;
6918
7095
  }).post(
@@ -6930,7 +7107,7 @@ var routes = (app) => Effect45.gen(function* () {
6930
7107
  gitController.getGitDiff({
6931
7108
  ...c.req.param(),
6932
7109
  ...c.req.valid("json")
6933
- }).pipe(Effect45.provide(runtime))
7110
+ }).pipe(Effect47.provide(runtime))
6934
7111
  );
6935
7112
  return response;
6936
7113
  }
@@ -6943,7 +7120,7 @@ var routes = (app) => Effect45.gen(function* () {
6943
7120
  gitController.commitFiles({
6944
7121
  ...c.req.param(),
6945
7122
  ...c.req.valid("json")
6946
- }).pipe(Effect45.provide(runtime))
7123
+ }).pipe(Effect47.provide(runtime))
6947
7124
  );
6948
7125
  return response;
6949
7126
  }
@@ -6956,7 +7133,7 @@ var routes = (app) => Effect45.gen(function* () {
6956
7133
  gitController.pushCommits({
6957
7134
  ...c.req.param(),
6958
7135
  ...c.req.valid("json")
6959
- }).pipe(Effect45.provide(runtime))
7136
+ }).pipe(Effect47.provide(runtime))
6960
7137
  );
6961
7138
  return response;
6962
7139
  }
@@ -6969,7 +7146,7 @@ var routes = (app) => Effect45.gen(function* () {
6969
7146
  gitController.commitAndPush({
6970
7147
  ...c.req.param(),
6971
7148
  ...c.req.valid("json")
6972
- }).pipe(Effect45.provide(runtime))
7149
+ }).pipe(Effect47.provide(runtime))
6973
7150
  );
6974
7151
  return response;
6975
7152
  }
@@ -6978,7 +7155,7 @@ var routes = (app) => Effect45.gen(function* () {
6978
7155
  c,
6979
7156
  claudeCodeController.getClaudeCommands({
6980
7157
  ...c.req.param()
6981
- }).pipe(Effect45.provide(runtime))
7158
+ }).pipe(Effect47.provide(runtime))
6982
7159
  );
6983
7160
  return response;
6984
7161
  }).get("/api/projects/:projectId/mcp/list", async (c) => {
@@ -6986,19 +7163,19 @@ var routes = (app) => Effect45.gen(function* () {
6986
7163
  c,
6987
7164
  claudeCodeController.getMcpListRoute({
6988
7165
  ...c.req.param()
6989
- }).pipe(Effect45.provide(runtime))
7166
+ }).pipe(Effect47.provide(runtime))
6990
7167
  );
6991
7168
  return response;
6992
7169
  }).get("/api/cc/meta", async (c) => {
6993
7170
  const response = await effectToResponse(
6994
7171
  c,
6995
- claudeCodeController.getClaudeCodeMeta().pipe(Effect45.provide(runtime))
7172
+ claudeCodeController.getClaudeCodeMeta().pipe(Effect47.provide(runtime))
6996
7173
  );
6997
7174
  return response;
6998
7175
  }).get("/api/cc/features", async (c) => {
6999
7176
  const response = await effectToResponse(
7000
7177
  c,
7001
- claudeCodeController.getAvailableFeatures().pipe(Effect45.provide(runtime))
7178
+ claudeCodeController.getAvailableFeatures().pipe(Effect47.provide(runtime))
7002
7179
  );
7003
7180
  return response;
7004
7181
  }).get("/api/cc/session-processes", async (c) => {
@@ -7042,7 +7219,7 @@ var routes = (app) => Effect45.gen(function* () {
7042
7219
  claudeCodeSessionProcessController.continueSessionProcess({
7043
7220
  ...c.req.param(),
7044
7221
  ...c.req.valid("json")
7045
- }).pipe(Effect45.provide(runtime))
7222
+ }).pipe(Effect47.provide(runtime))
7046
7223
  );
7047
7224
  return response;
7048
7225
  }
@@ -7051,7 +7228,7 @@ var routes = (app) => Effect45.gen(function* () {
7051
7228
  zValidator("json", z28.object({ projectId: z28.string() })),
7052
7229
  async (c) => {
7053
7230
  const { sessionProcessId } = c.req.param();
7054
- void Effect45.runFork(
7231
+ void Effect47.runFork(
7055
7232
  claudeCodeLifeCycleService.abortTask(sessionProcessId)
7056
7233
  );
7057
7234
  return c.json({ message: "Task aborted" });
@@ -7079,7 +7256,7 @@ var routes = (app) => Effect45.gen(function* () {
7079
7256
  c,
7080
7257
  async (rawStream) => {
7081
7258
  await Runtime3.runPromise(runtime)(
7082
- sseController.handleSSE(rawStream).pipe(Effect45.provide(TypeSafeSSE.make(rawStream)))
7259
+ sseController.handleSSE(rawStream).pipe(Effect47.provide(TypeSafeSSE.make(rawStream)))
7083
7260
  );
7084
7261
  },
7085
7262
  async (err) => {
@@ -7089,7 +7266,7 @@ var routes = (app) => Effect45.gen(function* () {
7089
7266
  }).get("/api/scheduler/jobs", async (c) => {
7090
7267
  const response = await effectToResponse(
7091
7268
  c,
7092
- schedulerController.getJobs().pipe(Effect45.provide(runtime))
7269
+ schedulerController.getJobs().pipe(Effect47.provide(runtime))
7093
7270
  );
7094
7271
  return response;
7095
7272
  }).post(
@@ -7100,7 +7277,7 @@ var routes = (app) => Effect45.gen(function* () {
7100
7277
  c,
7101
7278
  schedulerController.addJob({
7102
7279
  job: c.req.valid("json")
7103
- }).pipe(Effect45.provide(runtime))
7280
+ }).pipe(Effect47.provide(runtime))
7104
7281
  );
7105
7282
  return response;
7106
7283
  }
@@ -7113,7 +7290,7 @@ var routes = (app) => Effect45.gen(function* () {
7113
7290
  schedulerController.updateJob({
7114
7291
  id: c.req.param("id"),
7115
7292
  job: c.req.valid("json")
7116
- }).pipe(Effect45.provide(runtime))
7293
+ }).pipe(Effect47.provide(runtime))
7117
7294
  );
7118
7295
  return response;
7119
7296
  }
@@ -7122,7 +7299,7 @@ var routes = (app) => Effect45.gen(function* () {
7122
7299
  c,
7123
7300
  schedulerController.deleteJob({
7124
7301
  id: c.req.param("id")
7125
- }).pipe(Effect45.provide(runtime))
7302
+ }).pipe(Effect47.provide(runtime))
7126
7303
  );
7127
7304
  return response;
7128
7305
  }).get(
@@ -7175,14 +7352,14 @@ var routes = (app) => Effect45.gen(function* () {
7175
7352
  const { q, limit, projectId } = c.req.valid("query");
7176
7353
  const response = await effectToResponse(
7177
7354
  c,
7178
- searchController.search({ query: q, limit, projectId }).pipe(Effect45.provide(runtime))
7355
+ searchController.search({ query: q, limit, projectId }).pipe(Effect47.provide(runtime))
7179
7356
  );
7180
7357
  return response;
7181
7358
  }
7182
7359
  ).get("/api/flags", async (c) => {
7183
7360
  const response = await effectToResponse(
7184
7361
  c,
7185
- featureFlagController.getFlags().pipe(Effect45.provide(runtime))
7362
+ featureFlagController.getFlags().pipe(Effect47.provide(runtime))
7186
7363
  );
7187
7364
  return response;
7188
7365
  });
@@ -7190,92 +7367,114 @@ var routes = (app) => Effect45.gen(function* () {
7190
7367
 
7191
7368
  // src/server/lib/effect/layers.ts
7192
7369
  import { NodeContext } from "@effect/platform-node";
7193
- import { Layer as Layer38 } from "effect";
7194
- var platformLayer = Layer38.mergeAll(
7370
+ import { Layer as Layer39 } from "effect";
7371
+ var platformLayer = Layer39.mergeAll(
7195
7372
  ApplicationContext.Live,
7196
7373
  UserConfigService.Live,
7197
7374
  EventBus.Live,
7198
- EnvService.Live
7199
- ).pipe(Layer38.provide(EnvService.Live), Layer38.provide(NodeContext.layer));
7200
-
7201
- // src/server/main.ts
7202
- var isDevelopment = process.env.NODE_ENV === "development";
7203
- if (!isDevelopment) {
7204
- const staticPath = resolve6(import.meta.dirname, "static");
7205
- console.log("Serving static files from ", staticPath);
7206
- honoApp.use(
7207
- "/assets/*",
7208
- serveStatic({
7209
- root: staticPath
7210
- })
7211
- );
7212
- honoApp.use("*", async (c, next) => {
7213
- if (c.req.path.startsWith("/api")) {
7214
- return next();
7215
- }
7216
- const html = await readFile2(resolve6(staticPath, "index.html"), "utf-8");
7217
- return c.html(html);
7218
- });
7219
- }
7220
- var program = routes(honoApp).pipe(
7221
- /** Presentation */
7222
- Effect46.provide(ProjectController.Live),
7223
- Effect46.provide(SessionController.Live),
7224
- Effect46.provide(AgentSessionController.Live),
7225
- Effect46.provide(GitController.Live),
7226
- Effect46.provide(ClaudeCodeController.Live),
7227
- Effect46.provide(ClaudeCodeSessionProcessController.Live),
7228
- Effect46.provide(ClaudeCodePermissionController.Live),
7229
- Effect46.provide(FileSystemController.Live),
7230
- Effect46.provide(SSEController.Live),
7231
- Effect46.provide(SchedulerController.Live),
7232
- Effect46.provide(FeatureFlagController.Live),
7233
- Effect46.provide(SearchController.Live)
7375
+ EnvService.Live,
7376
+ CcvOptionsService.Live
7234
7377
  ).pipe(
7235
- /** Application */
7236
- Effect46.provide(InitializeService.Live),
7237
- Effect46.provide(FileWatcherService.Live),
7238
- Effect46.provide(AuthMiddleware.Live)
7239
- ).pipe(
7240
- /** Domain */
7241
- Effect46.provide(ClaudeCodeLifeCycleService.Live),
7242
- Effect46.provide(ClaudeCodePermissionService.Live),
7243
- Effect46.provide(ClaudeCodeSessionProcessService.Live),
7244
- Effect46.provide(ClaudeCodeService.Live),
7245
- Effect46.provide(GitService.Live),
7246
- Effect46.provide(SchedulerService.Live),
7247
- Effect46.provide(SchedulerConfigBaseDir.Live),
7248
- Effect46.provide(SearchService.Live)
7249
- ).pipe(
7250
- /** Infrastructure */
7251
- Effect46.provide(ProjectRepository.Live),
7252
- Effect46.provide(SessionRepository.Live),
7253
- Effect46.provide(ProjectMetaService.Live),
7254
- Effect46.provide(SessionMetaService.Live),
7255
- Effect46.provide(VirtualConversationDatabase.Live),
7256
- Effect46.provide(AgentSessionLayer)
7257
- ).pipe(
7258
- /** Platform */
7259
- Effect46.provide(platformLayer),
7260
- Effect46.provide(NodeContext2.layer)
7261
- );
7262
- await Effect46.runPromise(program);
7263
- var port = isDevelopment ? (
7264
- // biome-ignore lint/style/noProcessEnv: allow only here
7265
- process.env.DEV_BE_PORT ?? "3401"
7266
- ) : (
7267
- // biome-ignore lint/style/noProcessEnv: allow only here
7268
- process.env.PORT ?? "3000"
7378
+ Layer39.provide(EnvService.Live),
7379
+ Layer39.provide(CcvOptionsService.Live),
7380
+ Layer39.provide(NodeContext.layer)
7269
7381
  );
7270
- var hostname = process.env.HOSTNAME ?? "localhost";
7271
- serve(
7272
- {
7273
- fetch: honoApp.fetch,
7274
- port: parseInt(port, 10),
7275
- hostname
7276
- },
7277
- (info) => {
7278
- console.log(`Server is running on http://${info.address}:${info.port}`);
7382
+
7383
+ // src/server/startServer.ts
7384
+ var startServer = async (options) => {
7385
+ const isDevelopment = process.env.NODE_ENV === "development";
7386
+ if (!isDevelopment) {
7387
+ const staticPath = resolve6(import.meta.dirname, "static");
7388
+ console.log("Serving static files from ", staticPath);
7389
+ honoApp.use(
7390
+ "/assets/*",
7391
+ serveStatic({
7392
+ root: staticPath
7393
+ })
7394
+ );
7395
+ honoApp.use("*", async (c, next) => {
7396
+ if (c.req.path.startsWith("/api")) {
7397
+ return next();
7398
+ }
7399
+ const html = await readFile2(resolve6(staticPath, "index.html"), "utf-8");
7400
+ return c.html(html);
7401
+ });
7279
7402
  }
7280
- );
7403
+ const program2 = routes(honoApp, options).pipe(
7404
+ /** Presentation */
7405
+ Effect48.provide(ProjectController.Live),
7406
+ Effect48.provide(SessionController.Live),
7407
+ Effect48.provide(AgentSessionController.Live),
7408
+ Effect48.provide(GitController.Live),
7409
+ Effect48.provide(ClaudeCodeController.Live),
7410
+ Effect48.provide(ClaudeCodeSessionProcessController.Live),
7411
+ Effect48.provide(ClaudeCodePermissionController.Live),
7412
+ Effect48.provide(FileSystemController.Live),
7413
+ Effect48.provide(SSEController.Live),
7414
+ Effect48.provide(SchedulerController.Live),
7415
+ Effect48.provide(FeatureFlagController.Live),
7416
+ Effect48.provide(SearchController.Live)
7417
+ ).pipe(
7418
+ /** Application */
7419
+ Effect48.provide(InitializeService.Live),
7420
+ Effect48.provide(FileWatcherService.Live),
7421
+ Effect48.provide(AuthMiddleware.Live)
7422
+ ).pipe(
7423
+ /** Domain */
7424
+ Effect48.provide(ClaudeCodeLifeCycleService.Live),
7425
+ Effect48.provide(ClaudeCodePermissionService.Live),
7426
+ Effect48.provide(ClaudeCodeSessionProcessService.Live),
7427
+ Effect48.provide(ClaudeCodeService.Live),
7428
+ Effect48.provide(GitService.Live),
7429
+ Effect48.provide(SchedulerService.Live),
7430
+ Effect48.provide(SchedulerConfigBaseDir.Live),
7431
+ Effect48.provide(SearchService.Live)
7432
+ ).pipe(
7433
+ /** Infrastructure */
7434
+ Effect48.provide(ProjectRepository.Live),
7435
+ Effect48.provide(SessionRepository.Live),
7436
+ Effect48.provide(ProjectMetaService.Live),
7437
+ Effect48.provide(SessionMetaService.Live),
7438
+ Effect48.provide(VirtualConversationDatabase.Live),
7439
+ Effect48.provide(AgentSessionLayer)
7440
+ ).pipe(
7441
+ /** Platform */
7442
+ Effect48.provide(platformLayer),
7443
+ Effect48.provide(NodeContext2.layer)
7444
+ );
7445
+ await Effect48.runPromise(program2);
7446
+ const port = isDevelopment ? (
7447
+ // biome-ignore lint/style/noProcessEnv: allow only here
7448
+ process.env.DEV_BE_PORT ?? "3401"
7449
+ ) : (
7450
+ // biome-ignore lint/style/noProcessEnv: allow only here
7451
+ options.port ?? process.env.PORT ?? "3000"
7452
+ );
7453
+ const hostname = options.hostname ?? process.env.HOSTNAME ?? "localhost";
7454
+ serve(
7455
+ {
7456
+ fetch: honoApp.fetch,
7457
+ port: parseInt(port, 10),
7458
+ hostname
7459
+ },
7460
+ (info) => {
7461
+ console.log(`Server is running on http://${hostname}:${info.port}`);
7462
+ }
7463
+ );
7464
+ };
7465
+
7466
+ // src/server/main.ts
7467
+ var program = new Command3();
7468
+ program.name(package_default.name).version(package_default.version).description(package_default.description);
7469
+ program.option("-p, --port <port>", "port to listen on").option("-h, --hostname <hostname>", "hostname to listen on").option("-P, --password <password>", "password to authenticate").option("-e, --executable <executable>", "path to claude code executable").option("--claude-dir <claude-dir>", "path to claude directory").action(async (options) => {
7470
+ await Effect49.runPromise(checkDeprecatedEnvs);
7471
+ await startServer(options);
7472
+ });
7473
+ var main = async () => {
7474
+ program.parse(process.argv);
7475
+ };
7476
+ main().catch((error) => {
7477
+ console.error(error);
7478
+ process.exit(1);
7479
+ });
7281
7480
  //# sourceMappingURL=main.js.map