@kimuson/claude-code-viewer 0.4.14 → 0.5.0

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