@kimuson/claude-code-viewer 0.4.6 → 0.4.7
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 +993 -820
- package/dist/main.js.map +4 -4
- package/dist/static/assets/index-C-6yHKgK.css +1 -0
- package/dist/static/assets/{index-Cl49R9Vk.js → index-CEfL1559.js} +20 -20
- package/dist/static/assets/{index-CdW3wSEF.js → index-ChVcZMuL.js} +1 -1
- package/dist/static/assets/index-CsvC5pl6.js +1 -0
- package/dist/static/assets/{label-RSRHgdFZ.js → label-D9NP5l7d.js} +4 -4
- package/dist/static/assets/{session-Bqd0eFgp.js → session-B4u9RwAC.js} +53 -53
- package/dist/static/assets/{session-CqkSC6oA.js → session-aPiwqPra.js} +1 -1
- package/dist/static/index.html +2 -2
- package/package.json +1 -1
- package/dist/static/assets/index-C7tocoDE.js +0 -1
- package/dist/static/assets/index-DuTdxGMm.css +0 -1
package/dist/main.js
CHANGED
|
@@ -6,33 +6,380 @@ import { resolve as resolve6 } from "node:path";
|
|
|
6
6
|
import { NodeContext as NodeContext2 } from "@effect/platform-node";
|
|
7
7
|
import { serve } from "@hono/node-server";
|
|
8
8
|
import { serveStatic } from "@hono/node-server/serve-static";
|
|
9
|
-
import { Effect as
|
|
9
|
+
import { Effect as Effect42 } from "effect";
|
|
10
|
+
|
|
11
|
+
// src/server/core/agent-session/index.ts
|
|
12
|
+
import { Layer as Layer3 } from "effect";
|
|
13
|
+
|
|
14
|
+
// src/server/core/agent-session/infrastructure/AgentSessionRepository.ts
|
|
15
|
+
import { FileSystem, Path } from "@effect/platform";
|
|
16
|
+
import { Context, Effect, Layer } from "effect";
|
|
17
|
+
|
|
18
|
+
// src/lib/conversation-schema/index.ts
|
|
19
|
+
import { z as z16 } from "zod";
|
|
20
|
+
|
|
21
|
+
// src/lib/conversation-schema/entry/AssistantEntrySchema.ts
|
|
22
|
+
import { z as z8 } from "zod";
|
|
23
|
+
|
|
24
|
+
// src/lib/conversation-schema/message/AssistantMessageSchema.ts
|
|
25
|
+
import { z as z6 } from "zod";
|
|
26
|
+
|
|
27
|
+
// src/lib/conversation-schema/content/TextContentSchema.ts
|
|
28
|
+
import { z } from "zod";
|
|
29
|
+
var TextContentSchema = z.object({
|
|
30
|
+
type: z.literal("text"),
|
|
31
|
+
text: z.string()
|
|
32
|
+
});
|
|
33
|
+
|
|
34
|
+
// src/lib/conversation-schema/content/ThinkingContentSchema.ts
|
|
35
|
+
import { z as z2 } from "zod";
|
|
36
|
+
var ThinkingContentSchema = z2.object({
|
|
37
|
+
type: z2.literal("thinking"),
|
|
38
|
+
thinking: z2.string(),
|
|
39
|
+
signature: z2.string().optional()
|
|
40
|
+
});
|
|
41
|
+
|
|
42
|
+
// src/lib/conversation-schema/content/ToolResultContentSchema.ts
|
|
43
|
+
import { z as z4 } from "zod";
|
|
44
|
+
|
|
45
|
+
// src/lib/conversation-schema/content/ImageContentSchema.ts
|
|
46
|
+
import { z as z3 } from "zod";
|
|
47
|
+
var ImageContentSchema = z3.object({
|
|
48
|
+
type: z3.literal("image"),
|
|
49
|
+
source: z3.object({
|
|
50
|
+
type: z3.literal("base64"),
|
|
51
|
+
data: z3.string(),
|
|
52
|
+
media_type: z3.enum(["image/png", "image/jpeg", "image/gif", "image/webp"])
|
|
53
|
+
})
|
|
54
|
+
});
|
|
55
|
+
|
|
56
|
+
// src/lib/conversation-schema/content/ToolResultContentSchema.ts
|
|
57
|
+
var ToolResultContentSchema = z4.object({
|
|
58
|
+
type: z4.literal("tool_result"),
|
|
59
|
+
tool_use_id: z4.string(),
|
|
60
|
+
content: z4.union([
|
|
61
|
+
z4.string(),
|
|
62
|
+
z4.array(z4.union([TextContentSchema, ImageContentSchema]))
|
|
63
|
+
]),
|
|
64
|
+
is_error: z4.boolean().optional()
|
|
65
|
+
});
|
|
66
|
+
|
|
67
|
+
// src/lib/conversation-schema/content/ToolUseContentSchema.ts
|
|
68
|
+
import { z as z5 } from "zod";
|
|
69
|
+
var ToolUseContentSchema = z5.object({
|
|
70
|
+
type: z5.literal("tool_use"),
|
|
71
|
+
id: z5.string(),
|
|
72
|
+
name: z5.string(),
|
|
73
|
+
input: z5.record(z5.string(), z5.unknown())
|
|
74
|
+
});
|
|
75
|
+
|
|
76
|
+
// src/lib/conversation-schema/message/AssistantMessageSchema.ts
|
|
77
|
+
var AssistantMessageContentSchema = z6.union([
|
|
78
|
+
ThinkingContentSchema,
|
|
79
|
+
TextContentSchema,
|
|
80
|
+
ToolUseContentSchema,
|
|
81
|
+
ToolResultContentSchema
|
|
82
|
+
]);
|
|
83
|
+
var AssistantMessageSchema = z6.object({
|
|
84
|
+
id: z6.string(),
|
|
85
|
+
container: z6.null().optional(),
|
|
86
|
+
type: z6.literal("message"),
|
|
87
|
+
role: z6.literal("assistant"),
|
|
88
|
+
model: z6.string(),
|
|
89
|
+
content: z6.array(AssistantMessageContentSchema),
|
|
90
|
+
stop_reason: z6.string().nullable(),
|
|
91
|
+
stop_sequence: z6.string().nullable(),
|
|
92
|
+
usage: z6.object({
|
|
93
|
+
input_tokens: z6.number(),
|
|
94
|
+
cache_creation_input_tokens: z6.number().optional(),
|
|
95
|
+
cache_read_input_tokens: z6.number().optional(),
|
|
96
|
+
cache_creation: z6.object({
|
|
97
|
+
ephemeral_5m_input_tokens: z6.number(),
|
|
98
|
+
ephemeral_1h_input_tokens: z6.number()
|
|
99
|
+
}).optional(),
|
|
100
|
+
output_tokens: z6.number(),
|
|
101
|
+
service_tier: z6.string().nullable().optional(),
|
|
102
|
+
server_tool_use: z6.object({
|
|
103
|
+
web_search_requests: z6.number()
|
|
104
|
+
}).optional()
|
|
105
|
+
})
|
|
106
|
+
});
|
|
107
|
+
|
|
108
|
+
// src/lib/conversation-schema/entry/BaseEntrySchema.ts
|
|
109
|
+
import { z as z7 } from "zod";
|
|
110
|
+
var BaseEntrySchema = z7.object({
|
|
111
|
+
// required
|
|
112
|
+
isSidechain: z7.boolean(),
|
|
113
|
+
userType: z7.enum(["external"]),
|
|
114
|
+
cwd: z7.string(),
|
|
115
|
+
sessionId: z7.string(),
|
|
116
|
+
version: z7.string(),
|
|
117
|
+
uuid: z7.uuid(),
|
|
118
|
+
timestamp: z7.string(),
|
|
119
|
+
// nullable
|
|
120
|
+
parentUuid: z7.uuid().nullable(),
|
|
121
|
+
// optional
|
|
122
|
+
isMeta: z7.boolean().optional(),
|
|
123
|
+
toolUseResult: z7.unknown().optional(),
|
|
124
|
+
// スキーマがツールごとに異なりすぎるし利用もしなそうなので unknown
|
|
125
|
+
gitBranch: z7.string().optional(),
|
|
126
|
+
isCompactSummary: z7.boolean().optional()
|
|
127
|
+
});
|
|
128
|
+
|
|
129
|
+
// src/lib/conversation-schema/entry/AssistantEntrySchema.ts
|
|
130
|
+
var AssistantEntrySchema = BaseEntrySchema.extend({
|
|
131
|
+
// discriminator
|
|
132
|
+
type: z8.literal("assistant"),
|
|
133
|
+
// required
|
|
134
|
+
message: AssistantMessageSchema,
|
|
135
|
+
// optional
|
|
136
|
+
requestId: z8.string().optional(),
|
|
137
|
+
isApiErrorMessage: z8.boolean().optional()
|
|
138
|
+
});
|
|
139
|
+
|
|
140
|
+
// src/lib/conversation-schema/entry/FileHIstorySnapshotEntrySchema.ts
|
|
141
|
+
import { z as z9 } from "zod";
|
|
142
|
+
var FileHistorySnapshotEntrySchema = z9.object({
|
|
143
|
+
// discriminator
|
|
144
|
+
type: z9.literal("file-history-snapshot"),
|
|
145
|
+
// required
|
|
146
|
+
messageId: z9.string(),
|
|
147
|
+
snapshot: z9.object({
|
|
148
|
+
messageId: z9.string(),
|
|
149
|
+
trackedFileBackups: z9.record(z9.string(), z9.unknown()),
|
|
150
|
+
timestamp: z9.string()
|
|
151
|
+
}),
|
|
152
|
+
isSnapshotUpdate: z9.boolean()
|
|
153
|
+
});
|
|
154
|
+
|
|
155
|
+
// src/lib/conversation-schema/entry/QueueOperationEntrySchema.ts
|
|
156
|
+
import { z as z11 } from "zod";
|
|
157
|
+
|
|
158
|
+
// src/lib/conversation-schema/content/DocumentContentSchema.ts
|
|
159
|
+
import { z as z10 } from "zod";
|
|
160
|
+
var DocumentContentSchema = z10.object({
|
|
161
|
+
type: z10.literal("document"),
|
|
162
|
+
source: z10.union([
|
|
163
|
+
z10.object({
|
|
164
|
+
media_type: z10.literal("text/plain"),
|
|
165
|
+
type: z10.literal("text"),
|
|
166
|
+
data: z10.string()
|
|
167
|
+
}),
|
|
168
|
+
z10.object({
|
|
169
|
+
media_type: z10.enum(["application/pdf"]),
|
|
170
|
+
type: z10.literal("base64"),
|
|
171
|
+
data: z10.string()
|
|
172
|
+
})
|
|
173
|
+
])
|
|
174
|
+
});
|
|
175
|
+
|
|
176
|
+
// src/lib/conversation-schema/entry/QueueOperationEntrySchema.ts
|
|
177
|
+
var QueueOperationContentSchema = z11.union([
|
|
178
|
+
z11.string(),
|
|
179
|
+
TextContentSchema,
|
|
180
|
+
ToolResultContentSchema,
|
|
181
|
+
ImageContentSchema,
|
|
182
|
+
DocumentContentSchema
|
|
183
|
+
]);
|
|
184
|
+
var QueueOperationEntrySchema = z11.union([
|
|
185
|
+
z11.object({
|
|
186
|
+
type: z11.literal("queue-operation"),
|
|
187
|
+
operation: z11.literal("enqueue"),
|
|
188
|
+
content: z11.union([
|
|
189
|
+
z11.string(),
|
|
190
|
+
z11.array(z11.union([z11.string(), QueueOperationContentSchema]))
|
|
191
|
+
]),
|
|
192
|
+
sessionId: z11.string(),
|
|
193
|
+
timestamp: z11.iso.datetime()
|
|
194
|
+
}),
|
|
195
|
+
z11.object({
|
|
196
|
+
type: z11.literal("queue-operation"),
|
|
197
|
+
operation: z11.literal("dequeue"),
|
|
198
|
+
sessionId: z11.string(),
|
|
199
|
+
timestamp: z11.iso.datetime()
|
|
200
|
+
})
|
|
201
|
+
]);
|
|
202
|
+
|
|
203
|
+
// src/lib/conversation-schema/entry/SummaryEntrySchema.ts
|
|
204
|
+
import { z as z12 } from "zod";
|
|
205
|
+
var SummaryEntrySchema = z12.object({
|
|
206
|
+
type: z12.literal("summary"),
|
|
207
|
+
summary: z12.string(),
|
|
208
|
+
leafUuid: z12.string().uuid()
|
|
209
|
+
});
|
|
210
|
+
|
|
211
|
+
// src/lib/conversation-schema/entry/SystemEntrySchema.ts
|
|
212
|
+
import { z as z13 } from "zod";
|
|
213
|
+
var SystemEntrySchema = BaseEntrySchema.extend({
|
|
214
|
+
// discriminator
|
|
215
|
+
type: z13.literal("system"),
|
|
216
|
+
// required
|
|
217
|
+
content: z13.string(),
|
|
218
|
+
toolUseID: z13.string(),
|
|
219
|
+
level: z13.enum(["info"])
|
|
220
|
+
});
|
|
221
|
+
|
|
222
|
+
// src/lib/conversation-schema/entry/UserEntrySchema.ts
|
|
223
|
+
import { z as z15 } from "zod";
|
|
224
|
+
|
|
225
|
+
// src/lib/conversation-schema/message/UserMessageSchema.ts
|
|
226
|
+
import { z as z14 } from "zod";
|
|
227
|
+
var UserMessageContentSchema = z14.union([
|
|
228
|
+
z14.string(),
|
|
229
|
+
TextContentSchema,
|
|
230
|
+
ToolResultContentSchema,
|
|
231
|
+
ImageContentSchema,
|
|
232
|
+
DocumentContentSchema
|
|
233
|
+
]);
|
|
234
|
+
var UserMessageSchema = z14.object({
|
|
235
|
+
role: z14.literal("user"),
|
|
236
|
+
content: z14.union([
|
|
237
|
+
z14.string(),
|
|
238
|
+
z14.array(z14.union([z14.string(), UserMessageContentSchema]))
|
|
239
|
+
])
|
|
240
|
+
});
|
|
241
|
+
|
|
242
|
+
// src/lib/conversation-schema/entry/UserEntrySchema.ts
|
|
243
|
+
var UserEntrySchema = BaseEntrySchema.extend({
|
|
244
|
+
// discriminator
|
|
245
|
+
type: z15.literal("user"),
|
|
246
|
+
// required
|
|
247
|
+
message: UserMessageSchema
|
|
248
|
+
});
|
|
249
|
+
|
|
250
|
+
// src/lib/conversation-schema/index.ts
|
|
251
|
+
var ConversationSchema = z16.union([
|
|
252
|
+
UserEntrySchema,
|
|
253
|
+
AssistantEntrySchema,
|
|
254
|
+
SummaryEntrySchema,
|
|
255
|
+
SystemEntrySchema,
|
|
256
|
+
FileHistorySnapshotEntrySchema,
|
|
257
|
+
QueueOperationEntrySchema
|
|
258
|
+
]);
|
|
259
|
+
|
|
260
|
+
// src/server/core/claude-code/functions/parseJsonl.ts
|
|
261
|
+
var parseJsonl = (content) => {
|
|
262
|
+
const lines = content.trim().split("\n").filter((line) => line.trim() !== "");
|
|
263
|
+
return lines.map((line, index) => {
|
|
264
|
+
const parsed = ConversationSchema.safeParse(JSON.parse(line));
|
|
265
|
+
if (!parsed.success) {
|
|
266
|
+
const errorData = {
|
|
267
|
+
type: "x-error",
|
|
268
|
+
line,
|
|
269
|
+
lineNumber: index + 1
|
|
270
|
+
};
|
|
271
|
+
return errorData;
|
|
272
|
+
}
|
|
273
|
+
return parsed.data;
|
|
274
|
+
});
|
|
275
|
+
};
|
|
276
|
+
|
|
277
|
+
// src/server/core/project/functions/id.ts
|
|
278
|
+
import { dirname } from "node:path";
|
|
279
|
+
var encodeProjectId = (fullPath) => {
|
|
280
|
+
return Buffer.from(fullPath).toString("base64url");
|
|
281
|
+
};
|
|
282
|
+
var decodeProjectId = (id) => {
|
|
283
|
+
return Buffer.from(id, "base64url").toString("utf-8");
|
|
284
|
+
};
|
|
285
|
+
var encodeProjectIdFromSessionFilePath = (sessionFilePath) => {
|
|
286
|
+
return encodeProjectId(dirname(sessionFilePath));
|
|
287
|
+
};
|
|
288
|
+
|
|
289
|
+
// src/server/core/agent-session/infrastructure/AgentSessionRepository.ts
|
|
290
|
+
var LayerImpl = Effect.gen(function* () {
|
|
291
|
+
const fs = yield* FileSystem.FileSystem;
|
|
292
|
+
const path = yield* Path.Path;
|
|
293
|
+
const getAgentSessionByAgentId = (projectId, agentId) => Effect.gen(function* () {
|
|
294
|
+
const projectPath = decodeProjectId(projectId);
|
|
295
|
+
const agentFilePath = path.resolve(projectPath, `agent-${agentId}.jsonl`);
|
|
296
|
+
const exists = yield* fs.exists(agentFilePath);
|
|
297
|
+
if (!exists) {
|
|
298
|
+
return null;
|
|
299
|
+
}
|
|
300
|
+
const content = yield* fs.readFileString(agentFilePath);
|
|
301
|
+
const conversations = parseJsonl(content);
|
|
302
|
+
return conversations;
|
|
303
|
+
});
|
|
304
|
+
return {
|
|
305
|
+
getAgentSessionByAgentId
|
|
306
|
+
};
|
|
307
|
+
});
|
|
308
|
+
var AgentSessionRepository = class extends Context.Tag(
|
|
309
|
+
"AgentSessionRepository"
|
|
310
|
+
)() {
|
|
311
|
+
static {
|
|
312
|
+
this.Live = Layer.effect(this, LayerImpl);
|
|
313
|
+
}
|
|
314
|
+
};
|
|
315
|
+
|
|
316
|
+
// 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* () {
|
|
319
|
+
const repository = yield* AgentSessionRepository;
|
|
320
|
+
const getAgentSession = (params) => Effect2.gen(function* () {
|
|
321
|
+
const { projectId, agentId } = params;
|
|
322
|
+
const conversations = yield* repository.getAgentSessionByAgentId(
|
|
323
|
+
projectId,
|
|
324
|
+
agentId
|
|
325
|
+
);
|
|
326
|
+
if (conversations === null) {
|
|
327
|
+
return {
|
|
328
|
+
status: 200,
|
|
329
|
+
response: {
|
|
330
|
+
agentSessionId: null,
|
|
331
|
+
conversations: []
|
|
332
|
+
}
|
|
333
|
+
};
|
|
334
|
+
}
|
|
335
|
+
return {
|
|
336
|
+
status: 200,
|
|
337
|
+
response: {
|
|
338
|
+
agentSessionId: agentId,
|
|
339
|
+
conversations
|
|
340
|
+
}
|
|
341
|
+
};
|
|
342
|
+
});
|
|
343
|
+
return {
|
|
344
|
+
getAgentSession
|
|
345
|
+
};
|
|
346
|
+
});
|
|
347
|
+
var AgentSessionController = class extends Context2.Tag(
|
|
348
|
+
"AgentSessionController"
|
|
349
|
+
)() {
|
|
350
|
+
static {
|
|
351
|
+
this.Live = Layer2.effect(this, LayerImpl2);
|
|
352
|
+
}
|
|
353
|
+
};
|
|
354
|
+
|
|
355
|
+
// src/server/core/agent-session/index.ts
|
|
356
|
+
var AgentSessionLayer = Layer3.mergeAll(AgentSessionRepository.Live);
|
|
10
357
|
|
|
11
358
|
// src/server/core/claude-code/presentation/ClaudeCodeController.ts
|
|
12
|
-
import { FileSystem as
|
|
13
|
-
import { Context as
|
|
359
|
+
import { FileSystem as FileSystem6, Path as Path8 } from "@effect/platform";
|
|
360
|
+
import { Context as Context9, Effect as Effect12, Layer as Layer11 } from "effect";
|
|
14
361
|
|
|
15
362
|
// src/server/core/platform/services/ApplicationContext.ts
|
|
16
363
|
import { homedir } from "node:os";
|
|
17
|
-
import { Path } from "@effect/platform";
|
|
18
|
-
import { Effect as
|
|
364
|
+
import { Path as Path2 } from "@effect/platform";
|
|
365
|
+
import { Effect as Effect4, Context as EffectContext, Layer as Layer5 } from "effect";
|
|
19
366
|
|
|
20
367
|
// src/server/core/platform/services/EnvService.ts
|
|
21
|
-
import { Context, Effect, Layer, Ref } from "effect";
|
|
368
|
+
import { Context as Context3, Effect as Effect3, Layer as Layer4, Ref } from "effect";
|
|
22
369
|
|
|
23
370
|
// src/server/core/platform/schema.ts
|
|
24
|
-
import { z } from "zod";
|
|
25
|
-
var envSchema =
|
|
26
|
-
NODE_ENV:
|
|
27
|
-
CLAUDE_CODE_VIEWER_CC_EXECUTABLE_PATH:
|
|
28
|
-
GLOBAL_CLAUDE_DIR:
|
|
29
|
-
NEXT_PHASE:
|
|
30
|
-
PORT:
|
|
31
|
-
PATH:
|
|
371
|
+
import { z as z17 } from "zod";
|
|
372
|
+
var envSchema = z17.object({
|
|
373
|
+
NODE_ENV: z17.enum(["development", "production", "test"]).optional().default("development"),
|
|
374
|
+
CLAUDE_CODE_VIEWER_CC_EXECUTABLE_PATH: z17.string().optional(),
|
|
375
|
+
GLOBAL_CLAUDE_DIR: z17.string().optional(),
|
|
376
|
+
NEXT_PHASE: z17.string().optional(),
|
|
377
|
+
PORT: z17.string().optional().default("3000").transform((val) => parseInt(val, 10)),
|
|
378
|
+
PATH: z17.string().optional()
|
|
32
379
|
});
|
|
33
380
|
|
|
34
381
|
// src/server/core/platform/services/EnvService.ts
|
|
35
|
-
var
|
|
382
|
+
var LayerImpl3 = Effect3.gen(function* () {
|
|
36
383
|
const envRef = yield* Ref.make(void 0);
|
|
37
384
|
const parseEnv = () => {
|
|
38
385
|
const parsed = envSchema.safeParse(process.env);
|
|
@@ -43,7 +390,7 @@ var LayerImpl = Effect.gen(function* () {
|
|
|
43
390
|
return parsed.data;
|
|
44
391
|
};
|
|
45
392
|
const getEnv = (key) => {
|
|
46
|
-
return
|
|
393
|
+
return Effect3.gen(function* () {
|
|
47
394
|
yield* Ref.update(envRef, (existingEnv) => {
|
|
48
395
|
if (existingEnv === void 0) {
|
|
49
396
|
return parseEnv();
|
|
@@ -63,18 +410,18 @@ var LayerImpl = Effect.gen(function* () {
|
|
|
63
410
|
getEnv
|
|
64
411
|
};
|
|
65
412
|
});
|
|
66
|
-
var EnvService = class extends
|
|
413
|
+
var EnvService = class extends Context3.Tag("EnvService")() {
|
|
67
414
|
static {
|
|
68
|
-
this.Live =
|
|
415
|
+
this.Live = Layer4.effect(this, LayerImpl3);
|
|
69
416
|
}
|
|
70
417
|
};
|
|
71
418
|
|
|
72
419
|
// src/server/core/platform/services/ApplicationContext.ts
|
|
73
|
-
var
|
|
74
|
-
const path = yield*
|
|
420
|
+
var LayerImpl4 = Effect4.gen(function* () {
|
|
421
|
+
const path = yield* Path2.Path;
|
|
75
422
|
const envService = yield* EnvService;
|
|
76
423
|
const globalClaudeDirectoryPath = yield* envService.getEnv("GLOBAL_CLAUDE_DIR").pipe(
|
|
77
|
-
|
|
424
|
+
Effect4.map(
|
|
78
425
|
(envVar) => envVar === void 0 ? path.resolve(homedir(), ".claude") : path.resolve(envVar)
|
|
79
426
|
)
|
|
80
427
|
);
|
|
@@ -89,38 +436,26 @@ var LayerImpl2 = Effect2.gen(function* () {
|
|
|
89
436
|
});
|
|
90
437
|
var ApplicationContext = class extends EffectContext.Tag("ApplicationContext")() {
|
|
91
438
|
static {
|
|
92
|
-
this.Live =
|
|
439
|
+
this.Live = Layer5.effect(this, LayerImpl4);
|
|
93
440
|
}
|
|
94
441
|
};
|
|
95
442
|
|
|
96
443
|
// src/server/core/project/infrastructure/ProjectRepository.ts
|
|
97
|
-
import { FileSystem as
|
|
98
|
-
import { Context as
|
|
99
|
-
|
|
100
|
-
// src/server/core/project/functions/id.ts
|
|
101
|
-
import { dirname } from "node:path";
|
|
102
|
-
var encodeProjectId = (fullPath) => {
|
|
103
|
-
return Buffer.from(fullPath).toString("base64url");
|
|
104
|
-
};
|
|
105
|
-
var decodeProjectId = (id) => {
|
|
106
|
-
return Buffer.from(id, "base64url").toString("utf-8");
|
|
107
|
-
};
|
|
108
|
-
var encodeProjectIdFromSessionFilePath = (sessionFilePath) => {
|
|
109
|
-
return encodeProjectId(dirname(sessionFilePath));
|
|
110
|
-
};
|
|
444
|
+
import { FileSystem as FileSystem4, Path as Path5 } from "@effect/platform";
|
|
445
|
+
import { Context as Context7, Effect as Effect8, Layer as Layer9, Option as Option2 } from "effect";
|
|
111
446
|
|
|
112
447
|
// src/server/core/project/services/ProjectMetaService.ts
|
|
113
|
-
import { FileSystem as
|
|
114
|
-
import { Context as
|
|
448
|
+
import { FileSystem as FileSystem3, Path as Path4 } from "@effect/platform";
|
|
449
|
+
import { Context as Context6, Effect as Effect7, Layer as Layer8, Option, Ref as Ref3 } from "effect";
|
|
115
450
|
import { z as z19 } from "zod";
|
|
116
451
|
|
|
117
452
|
// src/server/lib/storage/FileCacheStorage/index.ts
|
|
118
|
-
import { Context as
|
|
453
|
+
import { Context as Context5, Effect as Effect6, Layer as Layer7, Ref as Ref2, Runtime } from "effect";
|
|
119
454
|
|
|
120
455
|
// src/server/lib/storage/FileCacheStorage/PersistentService.ts
|
|
121
|
-
import { FileSystem, Path as
|
|
122
|
-
import { Context as
|
|
123
|
-
import { z as
|
|
456
|
+
import { FileSystem as FileSystem2, Path as Path3 } from "@effect/platform";
|
|
457
|
+
import { Context as Context4, Effect as Effect5, Layer as Layer6 } from "effect";
|
|
458
|
+
import { z as z18 } from "zod";
|
|
124
459
|
|
|
125
460
|
// src/server/lib/config/paths.ts
|
|
126
461
|
import { homedir as homedir2 } from "node:os";
|
|
@@ -132,14 +467,14 @@ var claudeCodeViewerCacheDirPath = resolve(
|
|
|
132
467
|
);
|
|
133
468
|
|
|
134
469
|
// src/server/lib/storage/FileCacheStorage/PersistentService.ts
|
|
135
|
-
var saveSchema =
|
|
136
|
-
var
|
|
137
|
-
const path = yield*
|
|
470
|
+
var saveSchema = z18.array(z18.tuple([z18.string(), z18.unknown()]));
|
|
471
|
+
var LayerImpl5 = Effect5.gen(function* () {
|
|
472
|
+
const path = yield* Path3.Path;
|
|
138
473
|
const getCacheFilePath = (key) => path.resolve(claudeCodeViewerCacheDirPath, `${key}.json`);
|
|
139
474
|
const load = (key) => {
|
|
140
475
|
const cacheFilePath = getCacheFilePath(key);
|
|
141
|
-
return
|
|
142
|
-
const fs = yield*
|
|
476
|
+
return Effect5.gen(function* () {
|
|
477
|
+
const fs = yield* FileSystem2.FileSystem;
|
|
143
478
|
if (!(yield* fs.exists(claudeCodeViewerCacheDirPath))) {
|
|
144
479
|
yield* fs.makeDirectory(claudeCodeViewerCacheDirPath, {
|
|
145
480
|
recursive: true
|
|
@@ -169,8 +504,8 @@ var LayerImpl3 = Effect3.gen(function* () {
|
|
|
169
504
|
};
|
|
170
505
|
const save = (key, entries) => {
|
|
171
506
|
const cacheFilePath = getCacheFilePath(key);
|
|
172
|
-
return
|
|
173
|
-
const fs = yield*
|
|
507
|
+
return Effect5.gen(function* () {
|
|
508
|
+
const fs = yield* FileSystem2.FileSystem;
|
|
174
509
|
yield* fs.writeFileString(cacheFilePath, JSON.stringify(entries));
|
|
175
510
|
});
|
|
176
511
|
};
|
|
@@ -179,20 +514,20 @@ var LayerImpl3 = Effect3.gen(function* () {
|
|
|
179
514
|
save
|
|
180
515
|
};
|
|
181
516
|
});
|
|
182
|
-
var PersistentService = class extends
|
|
517
|
+
var PersistentService = class extends Context4.Tag("PersistentService")() {
|
|
183
518
|
static {
|
|
184
|
-
this.Live =
|
|
519
|
+
this.Live = Layer6.effect(this, LayerImpl5);
|
|
185
520
|
}
|
|
186
521
|
};
|
|
187
522
|
|
|
188
523
|
// src/server/lib/storage/FileCacheStorage/index.ts
|
|
189
|
-
var FileCacheStorage = () =>
|
|
190
|
-
var makeFileCacheStorageLayer = (storageKey, schema) =>
|
|
524
|
+
var FileCacheStorage = () => Context5.GenericTag("FileCacheStorage");
|
|
525
|
+
var makeFileCacheStorageLayer = (storageKey, schema) => Layer7.effect(
|
|
191
526
|
FileCacheStorage(),
|
|
192
|
-
|
|
527
|
+
Effect6.gen(function* () {
|
|
193
528
|
const persistentService = yield* PersistentService;
|
|
194
|
-
const runtime = yield*
|
|
195
|
-
const storageRef = yield*
|
|
529
|
+
const runtime = yield* Effect6.runtime();
|
|
530
|
+
const storageRef = yield* Effect6.gen(function* () {
|
|
196
531
|
const persistedData = yield* persistentService.load(storageKey);
|
|
197
532
|
const initialMap = /* @__PURE__ */ new Map();
|
|
198
533
|
for (const [key, value] of persistedData) {
|
|
@@ -207,11 +542,11 @@ var makeFileCacheStorageLayer = (storageKey, schema) => Layer4.effect(
|
|
|
207
542
|
Runtime.runFork(runtime)(persistentService.save(storageKey, entries));
|
|
208
543
|
};
|
|
209
544
|
return {
|
|
210
|
-
get: (key) =>
|
|
545
|
+
get: (key) => Effect6.gen(function* () {
|
|
211
546
|
const storage = yield* Ref2.get(storageRef);
|
|
212
547
|
return storage.get(key);
|
|
213
548
|
}),
|
|
214
|
-
set: (key, value) =>
|
|
549
|
+
set: (key, value) => Effect6.gen(function* () {
|
|
215
550
|
const before = yield* Ref2.get(storageRef);
|
|
216
551
|
const beforeString = JSON.stringify(Array.from(before.entries()));
|
|
217
552
|
yield* Ref2.update(storageRef, (map) => {
|
|
@@ -224,7 +559,7 @@ var makeFileCacheStorageLayer = (storageKey, schema) => Layer4.effect(
|
|
|
224
559
|
syncToFile(Array.from(after.entries()));
|
|
225
560
|
}
|
|
226
561
|
}),
|
|
227
|
-
invalidate: (key) =>
|
|
562
|
+
invalidate: (key) => Effect6.gen(function* () {
|
|
228
563
|
const before = yield* Ref2.get(storageRef);
|
|
229
564
|
if (!before.has(key)) {
|
|
230
565
|
return;
|
|
@@ -236,7 +571,7 @@ var makeFileCacheStorageLayer = (storageKey, schema) => Layer4.effect(
|
|
|
236
571
|
const after = yield* Ref2.get(storageRef);
|
|
237
572
|
syncToFile(Array.from(after.entries()));
|
|
238
573
|
}),
|
|
239
|
-
getAll: () =>
|
|
574
|
+
getAll: () => Effect6.gen(function* () {
|
|
240
575
|
const storage = yield* Ref2.get(storageRef);
|
|
241
576
|
return new Map(storage);
|
|
242
577
|
})
|
|
@@ -244,273 +579,14 @@ var makeFileCacheStorageLayer = (storageKey, schema) => Layer4.effect(
|
|
|
244
579
|
})
|
|
245
580
|
);
|
|
246
581
|
|
|
247
|
-
// src/lib/conversation-schema/index.ts
|
|
248
|
-
import { z as z18 } from "zod";
|
|
249
|
-
|
|
250
|
-
// src/lib/conversation-schema/entry/AssistantEntrySchema.ts
|
|
251
|
-
import { z as z10 } from "zod";
|
|
252
|
-
|
|
253
|
-
// src/lib/conversation-schema/message/AssistantMessageSchema.ts
|
|
254
|
-
import { z as z8 } from "zod";
|
|
255
|
-
|
|
256
|
-
// src/lib/conversation-schema/content/TextContentSchema.ts
|
|
257
|
-
import { z as z3 } from "zod";
|
|
258
|
-
var TextContentSchema = z3.object({
|
|
259
|
-
type: z3.literal("text"),
|
|
260
|
-
text: z3.string()
|
|
261
|
-
});
|
|
262
|
-
|
|
263
|
-
// src/lib/conversation-schema/content/ThinkingContentSchema.ts
|
|
264
|
-
import { z as z4 } from "zod";
|
|
265
|
-
var ThinkingContentSchema = z4.object({
|
|
266
|
-
type: z4.literal("thinking"),
|
|
267
|
-
thinking: z4.string(),
|
|
268
|
-
signature: z4.string().optional()
|
|
269
|
-
});
|
|
270
|
-
|
|
271
|
-
// src/lib/conversation-schema/content/ToolResultContentSchema.ts
|
|
272
|
-
import { z as z6 } from "zod";
|
|
273
|
-
|
|
274
|
-
// src/lib/conversation-schema/content/ImageContentSchema.ts
|
|
275
|
-
import { z as z5 } from "zod";
|
|
276
|
-
var ImageContentSchema = z5.object({
|
|
277
|
-
type: z5.literal("image"),
|
|
278
|
-
source: z5.object({
|
|
279
|
-
type: z5.literal("base64"),
|
|
280
|
-
data: z5.string(),
|
|
281
|
-
media_type: z5.enum(["image/png", "image/jpeg", "image/gif", "image/webp"])
|
|
282
|
-
})
|
|
283
|
-
});
|
|
284
|
-
|
|
285
|
-
// src/lib/conversation-schema/content/ToolResultContentSchema.ts
|
|
286
|
-
var ToolResultContentSchema = z6.object({
|
|
287
|
-
type: z6.literal("tool_result"),
|
|
288
|
-
tool_use_id: z6.string(),
|
|
289
|
-
content: z6.union([
|
|
290
|
-
z6.string(),
|
|
291
|
-
z6.array(z6.union([TextContentSchema, ImageContentSchema]))
|
|
292
|
-
]),
|
|
293
|
-
is_error: z6.boolean().optional()
|
|
294
|
-
});
|
|
295
|
-
|
|
296
|
-
// src/lib/conversation-schema/content/ToolUseContentSchema.ts
|
|
297
|
-
import { z as z7 } from "zod";
|
|
298
|
-
var ToolUseContentSchema = z7.object({
|
|
299
|
-
type: z7.literal("tool_use"),
|
|
300
|
-
id: z7.string(),
|
|
301
|
-
name: z7.string(),
|
|
302
|
-
input: z7.record(z7.string(), z7.unknown())
|
|
303
|
-
});
|
|
304
|
-
|
|
305
|
-
// src/lib/conversation-schema/message/AssistantMessageSchema.ts
|
|
306
|
-
var AssistantMessageContentSchema = z8.union([
|
|
307
|
-
ThinkingContentSchema,
|
|
308
|
-
TextContentSchema,
|
|
309
|
-
ToolUseContentSchema,
|
|
310
|
-
ToolResultContentSchema
|
|
311
|
-
]);
|
|
312
|
-
var AssistantMessageSchema = z8.object({
|
|
313
|
-
id: z8.string(),
|
|
314
|
-
container: z8.null().optional(),
|
|
315
|
-
type: z8.literal("message"),
|
|
316
|
-
role: z8.literal("assistant"),
|
|
317
|
-
model: z8.string(),
|
|
318
|
-
content: z8.array(AssistantMessageContentSchema),
|
|
319
|
-
stop_reason: z8.string().nullable(),
|
|
320
|
-
stop_sequence: z8.string().nullable(),
|
|
321
|
-
usage: z8.object({
|
|
322
|
-
input_tokens: z8.number(),
|
|
323
|
-
cache_creation_input_tokens: z8.number().optional(),
|
|
324
|
-
cache_read_input_tokens: z8.number().optional(),
|
|
325
|
-
cache_creation: z8.object({
|
|
326
|
-
ephemeral_5m_input_tokens: z8.number(),
|
|
327
|
-
ephemeral_1h_input_tokens: z8.number()
|
|
328
|
-
}).optional(),
|
|
329
|
-
output_tokens: z8.number(),
|
|
330
|
-
service_tier: z8.string().nullable().optional(),
|
|
331
|
-
server_tool_use: z8.object({
|
|
332
|
-
web_search_requests: z8.number()
|
|
333
|
-
}).optional()
|
|
334
|
-
})
|
|
335
|
-
});
|
|
336
|
-
|
|
337
|
-
// src/lib/conversation-schema/entry/BaseEntrySchema.ts
|
|
338
|
-
import { z as z9 } from "zod";
|
|
339
|
-
var BaseEntrySchema = z9.object({
|
|
340
|
-
// required
|
|
341
|
-
isSidechain: z9.boolean(),
|
|
342
|
-
userType: z9.enum(["external"]),
|
|
343
|
-
cwd: z9.string(),
|
|
344
|
-
sessionId: z9.string(),
|
|
345
|
-
version: z9.string(),
|
|
346
|
-
uuid: z9.uuid(),
|
|
347
|
-
timestamp: z9.string(),
|
|
348
|
-
// nullable
|
|
349
|
-
parentUuid: z9.uuid().nullable(),
|
|
350
|
-
// optional
|
|
351
|
-
isMeta: z9.boolean().optional(),
|
|
352
|
-
toolUseResult: z9.unknown().optional(),
|
|
353
|
-
// スキーマがツールごとに異なりすぎるし利用もしなそうなので unknown
|
|
354
|
-
gitBranch: z9.string().optional(),
|
|
355
|
-
isCompactSummary: z9.boolean().optional()
|
|
356
|
-
});
|
|
357
|
-
|
|
358
|
-
// src/lib/conversation-schema/entry/AssistantEntrySchema.ts
|
|
359
|
-
var AssistantEntrySchema = BaseEntrySchema.extend({
|
|
360
|
-
// discriminator
|
|
361
|
-
type: z10.literal("assistant"),
|
|
362
|
-
// required
|
|
363
|
-
message: AssistantMessageSchema,
|
|
364
|
-
// optional
|
|
365
|
-
requestId: z10.string().optional(),
|
|
366
|
-
isApiErrorMessage: z10.boolean().optional()
|
|
367
|
-
});
|
|
368
|
-
|
|
369
|
-
// src/lib/conversation-schema/entry/FileHIstorySnapshotEntrySchema.ts
|
|
370
|
-
import { z as z11 } from "zod";
|
|
371
|
-
var FileHistorySnapshotEntrySchema = z11.object({
|
|
372
|
-
// discriminator
|
|
373
|
-
type: z11.literal("file-history-snapshot"),
|
|
374
|
-
// required
|
|
375
|
-
messageId: z11.string(),
|
|
376
|
-
snapshot: z11.object({
|
|
377
|
-
messageId: z11.string(),
|
|
378
|
-
trackedFileBackups: z11.record(z11.string(), z11.unknown()),
|
|
379
|
-
timestamp: z11.string()
|
|
380
|
-
}),
|
|
381
|
-
isSnapshotUpdate: z11.boolean()
|
|
382
|
-
});
|
|
383
|
-
|
|
384
|
-
// src/lib/conversation-schema/entry/QueueOperationEntrySchema.ts
|
|
385
|
-
import { z as z13 } from "zod";
|
|
386
|
-
|
|
387
|
-
// src/lib/conversation-schema/content/DocumentContentSchema.ts
|
|
388
|
-
import { z as z12 } from "zod";
|
|
389
|
-
var DocumentContentSchema = z12.object({
|
|
390
|
-
type: z12.literal("document"),
|
|
391
|
-
source: z12.union([
|
|
392
|
-
z12.object({
|
|
393
|
-
media_type: z12.literal("text/plain"),
|
|
394
|
-
type: z12.literal("text"),
|
|
395
|
-
data: z12.string()
|
|
396
|
-
}),
|
|
397
|
-
z12.object({
|
|
398
|
-
media_type: z12.enum(["application/pdf"]),
|
|
399
|
-
type: z12.literal("base64"),
|
|
400
|
-
data: z12.string()
|
|
401
|
-
})
|
|
402
|
-
])
|
|
403
|
-
});
|
|
404
|
-
|
|
405
|
-
// src/lib/conversation-schema/entry/QueueOperationEntrySchema.ts
|
|
406
|
-
var QueueOperationContentSchema = z13.union([
|
|
407
|
-
z13.string(),
|
|
408
|
-
TextContentSchema,
|
|
409
|
-
ToolResultContentSchema,
|
|
410
|
-
ImageContentSchema,
|
|
411
|
-
DocumentContentSchema
|
|
412
|
-
]);
|
|
413
|
-
var QueueOperationEntrySchema = z13.union([
|
|
414
|
-
z13.object({
|
|
415
|
-
type: z13.literal("queue-operation"),
|
|
416
|
-
operation: z13.literal("enqueue"),
|
|
417
|
-
content: z13.union([
|
|
418
|
-
z13.string(),
|
|
419
|
-
z13.array(z13.union([z13.string(), QueueOperationContentSchema]))
|
|
420
|
-
]),
|
|
421
|
-
sessionId: z13.string(),
|
|
422
|
-
timestamp: z13.iso.datetime()
|
|
423
|
-
}),
|
|
424
|
-
z13.object({
|
|
425
|
-
type: z13.literal("queue-operation"),
|
|
426
|
-
operation: z13.literal("dequeue"),
|
|
427
|
-
sessionId: z13.string(),
|
|
428
|
-
timestamp: z13.iso.datetime()
|
|
429
|
-
})
|
|
430
|
-
]);
|
|
431
|
-
|
|
432
|
-
// src/lib/conversation-schema/entry/SummaryEntrySchema.ts
|
|
433
|
-
import { z as z14 } from "zod";
|
|
434
|
-
var SummaryEntrySchema = z14.object({
|
|
435
|
-
type: z14.literal("summary"),
|
|
436
|
-
summary: z14.string(),
|
|
437
|
-
leafUuid: z14.string().uuid()
|
|
438
|
-
});
|
|
439
|
-
|
|
440
|
-
// src/lib/conversation-schema/entry/SystemEntrySchema.ts
|
|
441
|
-
import { z as z15 } from "zod";
|
|
442
|
-
var SystemEntrySchema = BaseEntrySchema.extend({
|
|
443
|
-
// discriminator
|
|
444
|
-
type: z15.literal("system"),
|
|
445
|
-
// required
|
|
446
|
-
content: z15.string(),
|
|
447
|
-
toolUseID: z15.string(),
|
|
448
|
-
level: z15.enum(["info"])
|
|
449
|
-
});
|
|
450
|
-
|
|
451
|
-
// src/lib/conversation-schema/entry/UserEntrySchema.ts
|
|
452
|
-
import { z as z17 } from "zod";
|
|
453
|
-
|
|
454
|
-
// src/lib/conversation-schema/message/UserMessageSchema.ts
|
|
455
|
-
import { z as z16 } from "zod";
|
|
456
|
-
var UserMessageContentSchema = z16.union([
|
|
457
|
-
z16.string(),
|
|
458
|
-
TextContentSchema,
|
|
459
|
-
ToolResultContentSchema,
|
|
460
|
-
ImageContentSchema,
|
|
461
|
-
DocumentContentSchema
|
|
462
|
-
]);
|
|
463
|
-
var UserMessageSchema = z16.object({
|
|
464
|
-
role: z16.literal("user"),
|
|
465
|
-
content: z16.union([
|
|
466
|
-
z16.string(),
|
|
467
|
-
z16.array(z16.union([z16.string(), UserMessageContentSchema]))
|
|
468
|
-
])
|
|
469
|
-
});
|
|
470
|
-
|
|
471
|
-
// src/lib/conversation-schema/entry/UserEntrySchema.ts
|
|
472
|
-
var UserEntrySchema = BaseEntrySchema.extend({
|
|
473
|
-
// discriminator
|
|
474
|
-
type: z17.literal("user"),
|
|
475
|
-
// required
|
|
476
|
-
message: UserMessageSchema
|
|
477
|
-
});
|
|
478
|
-
|
|
479
|
-
// src/lib/conversation-schema/index.ts
|
|
480
|
-
var ConversationSchema = z18.union([
|
|
481
|
-
UserEntrySchema,
|
|
482
|
-
AssistantEntrySchema,
|
|
483
|
-
SummaryEntrySchema,
|
|
484
|
-
SystemEntrySchema,
|
|
485
|
-
FileHistorySnapshotEntrySchema,
|
|
486
|
-
QueueOperationEntrySchema
|
|
487
|
-
]);
|
|
488
|
-
|
|
489
|
-
// src/server/core/claude-code/functions/parseJsonl.ts
|
|
490
|
-
var parseJsonl = (content) => {
|
|
491
|
-
const lines = content.trim().split("\n").filter((line) => line.trim() !== "");
|
|
492
|
-
return lines.map((line, index) => {
|
|
493
|
-
const parsed = ConversationSchema.safeParse(JSON.parse(line));
|
|
494
|
-
if (!parsed.success) {
|
|
495
|
-
const errorData = {
|
|
496
|
-
type: "x-error",
|
|
497
|
-
line,
|
|
498
|
-
lineNumber: index + 1
|
|
499
|
-
};
|
|
500
|
-
return errorData;
|
|
501
|
-
}
|
|
502
|
-
return parsed.data;
|
|
503
|
-
});
|
|
504
|
-
};
|
|
505
|
-
|
|
506
582
|
// src/server/core/project/services/ProjectMetaService.ts
|
|
507
583
|
var ProjectPathSchema = z19.string().nullable();
|
|
508
|
-
var
|
|
509
|
-
const fs = yield*
|
|
510
|
-
const path = yield*
|
|
584
|
+
var LayerImpl6 = Effect7.gen(function* () {
|
|
585
|
+
const fs = yield* FileSystem3.FileSystem;
|
|
586
|
+
const path = yield* Path4.Path;
|
|
511
587
|
const projectPathCache = yield* FileCacheStorage();
|
|
512
588
|
const projectMetaCacheRef = yield* Ref3.make(/* @__PURE__ */ new Map());
|
|
513
|
-
const extractProjectPathFromJsonl = (filePath) =>
|
|
589
|
+
const extractProjectPathFromJsonl = (filePath) => Effect7.gen(function* () {
|
|
514
590
|
const cached = yield* projectPathCache.get(filePath);
|
|
515
591
|
if (cached !== void 0) {
|
|
516
592
|
return cached;
|
|
@@ -531,7 +607,7 @@ var LayerImpl4 = Effect5.gen(function* () {
|
|
|
531
607
|
}
|
|
532
608
|
return cwd;
|
|
533
609
|
});
|
|
534
|
-
const getProjectMeta = (projectId) =>
|
|
610
|
+
const getProjectMeta = (projectId) => Effect7.gen(function* () {
|
|
535
611
|
const metaCache = yield* Ref3.get(projectMetaCacheRef);
|
|
536
612
|
const cached = metaCache.get(projectId);
|
|
537
613
|
if (cached !== void 0) {
|
|
@@ -539,9 +615,9 @@ var LayerImpl4 = Effect5.gen(function* () {
|
|
|
539
615
|
}
|
|
540
616
|
const claudeProjectPath = decodeProjectId(projectId);
|
|
541
617
|
const dirents = yield* fs.readDirectory(claudeProjectPath);
|
|
542
|
-
const fileEntries = yield*
|
|
618
|
+
const fileEntries = yield* Effect7.all(
|
|
543
619
|
dirents.filter((name) => name.endsWith(".jsonl")).map(
|
|
544
|
-
(name) =>
|
|
620
|
+
(name) => Effect7.gen(function* () {
|
|
545
621
|
const fullPath = path.resolve(claudeProjectPath, name);
|
|
546
622
|
const stat = yield* fs.stat(fullPath);
|
|
547
623
|
const mtime = Option.getOrElse(stat.mtime, () => /* @__PURE__ */ new Date(0));
|
|
@@ -575,7 +651,7 @@ var LayerImpl4 = Effect5.gen(function* () {
|
|
|
575
651
|
});
|
|
576
652
|
return projectMeta;
|
|
577
653
|
});
|
|
578
|
-
const invalidateProject = (projectId) =>
|
|
654
|
+
const invalidateProject = (projectId) => Effect7.gen(function* () {
|
|
579
655
|
yield* Ref3.update(projectMetaCacheRef, (cache) => {
|
|
580
656
|
cache.delete(projectId);
|
|
581
657
|
return cache;
|
|
@@ -586,28 +662,28 @@ var LayerImpl4 = Effect5.gen(function* () {
|
|
|
586
662
|
invalidateProject
|
|
587
663
|
};
|
|
588
664
|
});
|
|
589
|
-
var ProjectMetaService = class extends
|
|
665
|
+
var ProjectMetaService = class extends Context6.Tag("ProjectMetaService")() {
|
|
590
666
|
static {
|
|
591
|
-
this.Live =
|
|
592
|
-
|
|
667
|
+
this.Live = Layer8.effect(this, LayerImpl6).pipe(
|
|
668
|
+
Layer8.provide(
|
|
593
669
|
makeFileCacheStorageLayer("project-path-cache", ProjectPathSchema)
|
|
594
670
|
),
|
|
595
|
-
|
|
671
|
+
Layer8.provide(PersistentService.Live)
|
|
596
672
|
);
|
|
597
673
|
}
|
|
598
674
|
};
|
|
599
675
|
|
|
600
676
|
// src/server/core/project/infrastructure/ProjectRepository.ts
|
|
601
|
-
var
|
|
602
|
-
const fs = yield*
|
|
603
|
-
const path = yield*
|
|
677
|
+
var LayerImpl7 = Effect8.gen(function* () {
|
|
678
|
+
const fs = yield* FileSystem4.FileSystem;
|
|
679
|
+
const path = yield* Path5.Path;
|
|
604
680
|
const projectMetaService = yield* ProjectMetaService;
|
|
605
681
|
const context = yield* ApplicationContext;
|
|
606
|
-
const getProject = (projectId) =>
|
|
682
|
+
const getProject = (projectId) => Effect8.gen(function* () {
|
|
607
683
|
const fullPath = decodeProjectId(projectId);
|
|
608
684
|
const exists = yield* fs.exists(fullPath);
|
|
609
685
|
if (!exists) {
|
|
610
|
-
return yield*
|
|
686
|
+
return yield* Effect8.fail(new Error("Project not found"));
|
|
611
687
|
}
|
|
612
688
|
const stat = yield* fs.stat(fullPath);
|
|
613
689
|
const meta = yield* projectMetaService.getProjectMeta(projectId);
|
|
@@ -620,7 +696,7 @@ var LayerImpl5 = Effect6.gen(function* () {
|
|
|
620
696
|
}
|
|
621
697
|
};
|
|
622
698
|
});
|
|
623
|
-
const getProjects = () =>
|
|
699
|
+
const getProjects = () => Effect8.gen(function* () {
|
|
624
700
|
const dirExists = yield* fs.exists(
|
|
625
701
|
context.claudeCodePaths.claudeProjectsDirPath
|
|
626
702
|
);
|
|
@@ -634,14 +710,14 @@ var LayerImpl5 = Effect6.gen(function* () {
|
|
|
634
710
|
context.claudeCodePaths.claudeProjectsDirPath
|
|
635
711
|
);
|
|
636
712
|
const projectEffects = entries.map(
|
|
637
|
-
(entry) =>
|
|
713
|
+
(entry) => Effect8.gen(function* () {
|
|
638
714
|
const fullPath = path.resolve(
|
|
639
715
|
context.claudeCodePaths.claudeProjectsDirPath,
|
|
640
716
|
entry
|
|
641
717
|
);
|
|
642
|
-
const stat = yield*
|
|
643
|
-
() => fs.stat(fullPath).pipe(
|
|
644
|
-
).pipe(
|
|
718
|
+
const stat = yield* Effect8.tryPromise(
|
|
719
|
+
() => fs.stat(fullPath).pipe(Effect8.runPromise)
|
|
720
|
+
).pipe(Effect8.catchAll(() => Effect8.succeed(null)));
|
|
645
721
|
if (!stat || stat.type !== "Directory") {
|
|
646
722
|
return null;
|
|
647
723
|
}
|
|
@@ -655,7 +731,7 @@ var LayerImpl5 = Effect6.gen(function* () {
|
|
|
655
731
|
};
|
|
656
732
|
})
|
|
657
733
|
);
|
|
658
|
-
const projectsWithNulls = yield*
|
|
734
|
+
const projectsWithNulls = yield* Effect8.all(projectEffects, {
|
|
659
735
|
concurrency: "unbounded"
|
|
660
736
|
});
|
|
661
737
|
const projects = projectsWithNulls.filter(
|
|
@@ -671,12 +747,57 @@ var LayerImpl5 = Effect6.gen(function* () {
|
|
|
671
747
|
getProjects
|
|
672
748
|
};
|
|
673
749
|
});
|
|
674
|
-
var ProjectRepository = class extends
|
|
750
|
+
var ProjectRepository = class extends Context7.Tag("ProjectRepository")() {
|
|
675
751
|
static {
|
|
676
|
-
this.Live =
|
|
752
|
+
this.Live = Layer9.effect(this, LayerImpl7);
|
|
677
753
|
}
|
|
678
754
|
};
|
|
679
755
|
|
|
756
|
+
// src/server/core/claude-code/functions/scanCommandFiles.ts
|
|
757
|
+
import { FileSystem as FileSystem5, Path as Path6 } from "@effect/platform";
|
|
758
|
+
import { Effect as Effect9 } from "effect";
|
|
759
|
+
var pathToCommandName = (filePath, baseDir) => {
|
|
760
|
+
const normalizedBaseDir = baseDir.endsWith("/") ? baseDir.slice(0, -1) : baseDir;
|
|
761
|
+
const relativePath = filePath.startsWith(normalizedBaseDir) ? filePath.slice(normalizedBaseDir.length + 1) : filePath;
|
|
762
|
+
return relativePath.replace(/\.md$/, "").replace(/\//g, ":");
|
|
763
|
+
};
|
|
764
|
+
var scanCommandFilesRecursively = (dirPath) => Effect9.gen(function* () {
|
|
765
|
+
const fs = yield* FileSystem5.FileSystem;
|
|
766
|
+
const path = yield* Path6.Path;
|
|
767
|
+
const scanDirectory = (currentPath) => Effect9.gen(function* () {
|
|
768
|
+
const exists = yield* fs.exists(currentPath);
|
|
769
|
+
if (!exists) {
|
|
770
|
+
return [];
|
|
771
|
+
}
|
|
772
|
+
const items = yield* fs.readDirectory(currentPath);
|
|
773
|
+
const results = yield* Effect9.forEach(
|
|
774
|
+
items,
|
|
775
|
+
(item) => Effect9.gen(function* () {
|
|
776
|
+
if (item.startsWith(".")) {
|
|
777
|
+
return [];
|
|
778
|
+
}
|
|
779
|
+
const itemPath = path.join(currentPath, item);
|
|
780
|
+
const info = yield* fs.stat(itemPath);
|
|
781
|
+
if (info.type === "Directory") {
|
|
782
|
+
return yield* scanDirectory(itemPath);
|
|
783
|
+
}
|
|
784
|
+
if (info.type === "File" && item.endsWith(".md")) {
|
|
785
|
+
return [pathToCommandName(itemPath, dirPath)];
|
|
786
|
+
}
|
|
787
|
+
return [];
|
|
788
|
+
}),
|
|
789
|
+
{ concurrency: "unbounded" }
|
|
790
|
+
);
|
|
791
|
+
return results.flat();
|
|
792
|
+
});
|
|
793
|
+
return yield* scanDirectory(dirPath).pipe(
|
|
794
|
+
Effect9.match({
|
|
795
|
+
onSuccess: (items) => items,
|
|
796
|
+
onFailure: () => []
|
|
797
|
+
})
|
|
798
|
+
);
|
|
799
|
+
});
|
|
800
|
+
|
|
680
801
|
// src/server/core/claude-code/models/ClaudeCodeVersion.ts
|
|
681
802
|
import { z as z20 } from "zod";
|
|
682
803
|
var versionRegex = /^(?<major>\d+)\.(?<minor>\d+)\.(?<patch>\d+)/;
|
|
@@ -704,7 +825,7 @@ var greaterThan = (a, b) => a.major > b.major || a.major === b.major && (a.minor
|
|
|
704
825
|
var greaterThanOrEqual = (a, b) => equals(a, b) || greaterThan(a, b);
|
|
705
826
|
|
|
706
827
|
// src/server/core/claude-code/services/ClaudeCodeService.ts
|
|
707
|
-
import { Context as
|
|
828
|
+
import { Context as Context8, Data as Data2, Effect as Effect11, Layer as Layer10 } from "effect";
|
|
708
829
|
|
|
709
830
|
// src/server/core/claude-code/functions/parseMcpListOutput.ts
|
|
710
831
|
var parseMcpListOutput = (output) => {
|
|
@@ -732,14 +853,14 @@ import { query as agentSdkQuery } from "@anthropic-ai/claude-agent-sdk";
|
|
|
732
853
|
import {
|
|
733
854
|
query as claudeCodeQuery
|
|
734
855
|
} from "@anthropic-ai/claude-code";
|
|
735
|
-
import { Command, Path as
|
|
736
|
-
import { Data, Effect as
|
|
856
|
+
import { Command, Path as Path7 } from "@effect/platform";
|
|
857
|
+
import { Data, Effect as Effect10 } from "effect";
|
|
737
858
|
var ClaudeCodePathNotFoundError = class extends Data.TaggedError(
|
|
738
859
|
"ClaudeCodePathNotFoundError"
|
|
739
860
|
) {
|
|
740
861
|
};
|
|
741
|
-
var resolveClaudeCodePath =
|
|
742
|
-
const path = yield*
|
|
862
|
+
var resolveClaudeCodePath = Effect10.gen(function* () {
|
|
863
|
+
const path = yield* Path7.Path;
|
|
743
864
|
const envService = yield* EnvService;
|
|
744
865
|
const specifiedExecutablePath = yield* envService.getEnv(
|
|
745
866
|
"CLAUDE_CODE_VIEWER_CC_EXECUTABLE_PATH"
|
|
@@ -756,15 +877,15 @@ var resolveClaudeCodePath = Effect7.gen(function* () {
|
|
|
756
877
|
Command.runInShell(true)
|
|
757
878
|
)
|
|
758
879
|
).pipe(
|
|
759
|
-
|
|
760
|
-
|
|
880
|
+
Effect10.map((output) => output.trim()),
|
|
881
|
+
Effect10.map((output) => output === "" ? null : output),
|
|
761
882
|
// 存在しない時、空文字になる模様
|
|
762
|
-
|
|
883
|
+
Effect10.catchAll(() => Effect10.succeed(null))
|
|
763
884
|
);
|
|
764
885
|
if (whichClaude !== null) {
|
|
765
886
|
return whichClaude;
|
|
766
887
|
}
|
|
767
|
-
const projectClaudeCode = yield*
|
|
888
|
+
const projectClaudeCode = yield* Effect10.try(() => {
|
|
768
889
|
const parts = __dirname.split("/");
|
|
769
890
|
const packagePath = parts.slice(0, parts.indexOf("claude-code-viewer") + 1).join("/");
|
|
770
891
|
return path.join(
|
|
@@ -775,8 +896,8 @@ var resolveClaudeCodePath = Effect7.gen(function* () {
|
|
|
775
896
|
"cli.js"
|
|
776
897
|
);
|
|
777
898
|
}).pipe(
|
|
778
|
-
|
|
779
|
-
return
|
|
899
|
+
Effect10.catchAll(() => {
|
|
900
|
+
return Effect10.fail(
|
|
780
901
|
new ClaudeCodePathNotFoundError({
|
|
781
902
|
message: "Claude Code CLI not found in any location"
|
|
782
903
|
})
|
|
@@ -785,7 +906,7 @@ var resolveClaudeCodePath = Effect7.gen(function* () {
|
|
|
785
906
|
);
|
|
786
907
|
return projectClaudeCode;
|
|
787
908
|
});
|
|
788
|
-
var Config =
|
|
909
|
+
var Config = Effect10.gen(function* () {
|
|
789
910
|
const claudeCodeExecutablePath = yield* resolveClaudeCodePath;
|
|
790
911
|
const claudeCodeVersion = fromCLIString(
|
|
791
912
|
yield* Command.string(Command.make(claudeCodeExecutablePath, "--version"))
|
|
@@ -795,7 +916,7 @@ var Config = Effect7.gen(function* () {
|
|
|
795
916
|
claudeCodeVersion
|
|
796
917
|
};
|
|
797
918
|
});
|
|
798
|
-
var getMcpListOutput = (projectCwd) =>
|
|
919
|
+
var getMcpListOutput = (projectCwd) => Effect10.gen(function* () {
|
|
799
920
|
const { claudeCodeExecutablePath } = yield* Config;
|
|
800
921
|
const output = yield* Command.string(
|
|
801
922
|
Command.make(
|
|
@@ -825,11 +946,17 @@ var getAvailableFeatures = (claudeCodeVersion) => ({
|
|
|
825
946
|
minor: 0,
|
|
826
947
|
patch: 125
|
|
827
948
|
// ClaudeCodeAgentSDK is available since v1.0.125
|
|
949
|
+
}) : false,
|
|
950
|
+
sidechainSeparation: claudeCodeVersion !== null ? greaterThanOrEqual(claudeCodeVersion, {
|
|
951
|
+
major: 2,
|
|
952
|
+
minor: 0,
|
|
953
|
+
patch: 28
|
|
954
|
+
// Sidechain conversations stored in agent-*.jsonl since v2.0.28
|
|
828
955
|
}) : false
|
|
829
956
|
});
|
|
830
957
|
var query = (prompt, options) => {
|
|
831
958
|
const { canUseTool, permissionMode, ...baseOptions } = options;
|
|
832
|
-
return
|
|
959
|
+
return Effect10.gen(function* () {
|
|
833
960
|
const { claudeCodeExecutablePath, claudeCodeVersion } = yield* Config;
|
|
834
961
|
const availableFeatures = getAvailableFeatures(claudeCodeVersion);
|
|
835
962
|
const options2 = {
|
|
@@ -879,23 +1006,23 @@ var ProjectPathNotFoundError = class extends Data2.TaggedError(
|
|
|
879
1006
|
"ProjectPathNotFoundError"
|
|
880
1007
|
) {
|
|
881
1008
|
};
|
|
882
|
-
var
|
|
1009
|
+
var LayerImpl8 = Effect11.gen(function* () {
|
|
883
1010
|
const projectRepository = yield* ProjectRepository;
|
|
884
|
-
const getClaudeCodeMeta = () =>
|
|
1011
|
+
const getClaudeCodeMeta = () => Effect11.gen(function* () {
|
|
885
1012
|
const config = yield* Config;
|
|
886
1013
|
return config;
|
|
887
1014
|
});
|
|
888
|
-
const getAvailableFeatures2 = () =>
|
|
1015
|
+
const getAvailableFeatures2 = () => Effect11.gen(function* () {
|
|
889
1016
|
const config = yield* Config;
|
|
890
1017
|
const features = getAvailableFeatures(
|
|
891
1018
|
config.claudeCodeVersion
|
|
892
1019
|
);
|
|
893
1020
|
return features;
|
|
894
1021
|
});
|
|
895
|
-
const getMcpList = (projectId) =>
|
|
1022
|
+
const getMcpList = (projectId) => Effect11.gen(function* () {
|
|
896
1023
|
const { project } = yield* projectRepository.getProject(projectId);
|
|
897
1024
|
if (project.meta.projectPath === null) {
|
|
898
|
-
return yield*
|
|
1025
|
+
return yield* Effect11.fail(new ProjectPathNotFoundError({ projectId }));
|
|
899
1026
|
}
|
|
900
1027
|
const output = yield* getMcpListOutput(
|
|
901
1028
|
project.meta.projectPath
|
|
@@ -908,47 +1035,27 @@ var LayerImpl6 = Effect8.gen(function* () {
|
|
|
908
1035
|
getAvailableFeatures: getAvailableFeatures2
|
|
909
1036
|
};
|
|
910
1037
|
});
|
|
911
|
-
var ClaudeCodeService = class extends
|
|
1038
|
+
var ClaudeCodeService = class extends Context8.Tag("ClaudeCodeService")() {
|
|
912
1039
|
static {
|
|
913
|
-
this.Live =
|
|
1040
|
+
this.Live = Layer10.effect(this, LayerImpl8);
|
|
914
1041
|
}
|
|
915
1042
|
};
|
|
916
1043
|
|
|
917
1044
|
// src/server/core/claude-code/presentation/ClaudeCodeController.ts
|
|
918
|
-
var
|
|
1045
|
+
var LayerImpl9 = Effect12.gen(function* () {
|
|
919
1046
|
const projectRepository = yield* ProjectRepository;
|
|
920
1047
|
const claudeCodeService = yield* ClaudeCodeService;
|
|
921
1048
|
const context = yield* ApplicationContext;
|
|
922
|
-
|
|
923
|
-
const path = yield*
|
|
924
|
-
const getClaudeCommands = (options) =>
|
|
1049
|
+
yield* FileSystem6.FileSystem;
|
|
1050
|
+
const path = yield* Path8.Path;
|
|
1051
|
+
const getClaudeCommands = (options) => Effect12.gen(function* () {
|
|
925
1052
|
const { projectId } = options;
|
|
926
1053
|
const { project } = yield* projectRepository.getProject(projectId);
|
|
927
|
-
const globalCommands = yield*
|
|
928
|
-
|
|
929
|
-
(items) => items.filter((item) => item.endsWith(".md")).map((item) => item.replace(/\.md$/, ""))
|
|
930
|
-
)
|
|
931
|
-
).pipe(
|
|
932
|
-
Effect9.match({
|
|
933
|
-
onSuccess: (items) => items,
|
|
934
|
-
onFailure: () => {
|
|
935
|
-
return [];
|
|
936
|
-
}
|
|
937
|
-
})
|
|
1054
|
+
const globalCommands = yield* scanCommandFilesRecursively(
|
|
1055
|
+
context.claudeCodePaths.claudeCommandsDirPath
|
|
938
1056
|
);
|
|
939
|
-
const projectCommands = project.meta.projectPath === null ? [] : yield*
|
|
1057
|
+
const projectCommands = project.meta.projectPath === null ? [] : yield* scanCommandFilesRecursively(
|
|
940
1058
|
path.resolve(project.meta.projectPath, ".claude", "commands")
|
|
941
|
-
).pipe(
|
|
942
|
-
Effect9.map(
|
|
943
|
-
(items) => items.filter((item) => item.endsWith(".md")).map((item) => item.replace(/\.md$/, ""))
|
|
944
|
-
)
|
|
945
|
-
).pipe(
|
|
946
|
-
Effect9.match({
|
|
947
|
-
onSuccess: (items) => items,
|
|
948
|
-
onFailure: () => {
|
|
949
|
-
return [];
|
|
950
|
-
}
|
|
951
|
-
})
|
|
952
1059
|
);
|
|
953
1060
|
return {
|
|
954
1061
|
response: {
|
|
@@ -959,7 +1066,7 @@ var LayerImpl7 = Effect9.gen(function* () {
|
|
|
959
1066
|
status: 200
|
|
960
1067
|
};
|
|
961
1068
|
});
|
|
962
|
-
const getMcpListRoute = (options) =>
|
|
1069
|
+
const getMcpListRoute = (options) => Effect12.gen(function* () {
|
|
963
1070
|
const { projectId } = options;
|
|
964
1071
|
const servers = yield* claudeCodeService.getMcpList(projectId);
|
|
965
1072
|
return {
|
|
@@ -967,7 +1074,7 @@ var LayerImpl7 = Effect9.gen(function* () {
|
|
|
967
1074
|
status: 200
|
|
968
1075
|
};
|
|
969
1076
|
});
|
|
970
|
-
const getClaudeCodeMeta = () =>
|
|
1077
|
+
const getClaudeCodeMeta = () => Effect12.gen(function* () {
|
|
971
1078
|
const config = yield* claudeCodeService.getClaudeCodeMeta();
|
|
972
1079
|
return {
|
|
973
1080
|
response: {
|
|
@@ -977,7 +1084,7 @@ var LayerImpl7 = Effect9.gen(function* () {
|
|
|
977
1084
|
status: 200
|
|
978
1085
|
};
|
|
979
1086
|
});
|
|
980
|
-
const getAvailableFeatures2 = () =>
|
|
1087
|
+
const getAvailableFeatures2 = () => Effect12.gen(function* () {
|
|
981
1088
|
const features = yield* claudeCodeService.getAvailableFeatures();
|
|
982
1089
|
const featuresList = Object.entries(features).flatMap(([key, value]) => {
|
|
983
1090
|
return [
|
|
@@ -999,22 +1106,22 @@ var LayerImpl7 = Effect9.gen(function* () {
|
|
|
999
1106
|
getAvailableFeatures: getAvailableFeatures2
|
|
1000
1107
|
};
|
|
1001
1108
|
});
|
|
1002
|
-
var ClaudeCodeController = class extends
|
|
1109
|
+
var ClaudeCodeController = class extends Context9.Tag("ClaudeCodeController")() {
|
|
1003
1110
|
static {
|
|
1004
|
-
this.Live =
|
|
1111
|
+
this.Live = Layer11.effect(this, LayerImpl9);
|
|
1005
1112
|
}
|
|
1006
1113
|
};
|
|
1007
1114
|
|
|
1008
1115
|
// src/server/core/claude-code/presentation/ClaudeCodePermissionController.ts
|
|
1009
|
-
import { Context as
|
|
1116
|
+
import { Context as Context12, Effect as Effect15, Layer as Layer14 } from "effect";
|
|
1010
1117
|
|
|
1011
1118
|
// src/server/core/claude-code/services/ClaudeCodePermissionService.ts
|
|
1012
|
-
import { Context as
|
|
1119
|
+
import { Context as Context11, Effect as Effect14, Layer as Layer13, Ref as Ref4 } from "effect";
|
|
1013
1120
|
import { ulid } from "ulid";
|
|
1014
1121
|
|
|
1015
1122
|
// src/server/core/events/services/EventBus.ts
|
|
1016
|
-
import { Context as
|
|
1017
|
-
var layerImpl =
|
|
1123
|
+
import { Context as Context10, Effect as Effect13, Layer as Layer12 } from "effect";
|
|
1124
|
+
var layerImpl = Effect13.gen(function* () {
|
|
1018
1125
|
const listenersMap = /* @__PURE__ */ new Map();
|
|
1019
1126
|
const getListeners = (event) => {
|
|
1020
1127
|
if (!listenersMap.has(event)) {
|
|
@@ -1022,7 +1129,7 @@ var layerImpl = Effect10.gen(function* () {
|
|
|
1022
1129
|
}
|
|
1023
1130
|
return listenersMap.get(event);
|
|
1024
1131
|
};
|
|
1025
|
-
const emit = (event, data) =>
|
|
1132
|
+
const emit = (event, data) => Effect13.gen(function* () {
|
|
1026
1133
|
const listeners = getListeners(event);
|
|
1027
1134
|
void Promise.allSettled(
|
|
1028
1135
|
Array.from(listeners).map(async (listener) => {
|
|
@@ -1030,11 +1137,11 @@ var layerImpl = Effect10.gen(function* () {
|
|
|
1030
1137
|
})
|
|
1031
1138
|
);
|
|
1032
1139
|
});
|
|
1033
|
-
const on = (event, listener) =>
|
|
1140
|
+
const on = (event, listener) => Effect13.sync(() => {
|
|
1034
1141
|
const listeners = getListeners(event);
|
|
1035
1142
|
listeners.add(listener);
|
|
1036
1143
|
});
|
|
1037
|
-
const off = (event, listener) =>
|
|
1144
|
+
const off = (event, listener) => Effect13.sync(() => {
|
|
1038
1145
|
const listeners = getListeners(event);
|
|
1039
1146
|
listeners.delete(listener);
|
|
1040
1147
|
});
|
|
@@ -1044,18 +1151,18 @@ var layerImpl = Effect10.gen(function* () {
|
|
|
1044
1151
|
off
|
|
1045
1152
|
};
|
|
1046
1153
|
});
|
|
1047
|
-
var EventBus = class extends
|
|
1154
|
+
var EventBus = class extends Context10.Tag("EventBus")() {
|
|
1048
1155
|
static {
|
|
1049
|
-
this.Live =
|
|
1156
|
+
this.Live = Layer12.effect(this, layerImpl);
|
|
1050
1157
|
}
|
|
1051
1158
|
};
|
|
1052
1159
|
|
|
1053
1160
|
// src/server/core/claude-code/services/ClaudeCodePermissionService.ts
|
|
1054
|
-
var
|
|
1161
|
+
var LayerImpl10 = Effect14.gen(function* () {
|
|
1055
1162
|
const pendingPermissionRequestsRef = yield* Ref4.make(/* @__PURE__ */ new Map());
|
|
1056
1163
|
const permissionResponsesRef = yield* Ref4.make(/* @__PURE__ */ new Map());
|
|
1057
1164
|
const eventBus = yield* EventBus;
|
|
1058
|
-
const waitPermissionResponse = (request, options) =>
|
|
1165
|
+
const waitPermissionResponse = (request, options) => Effect14.gen(function* () {
|
|
1059
1166
|
yield* Ref4.update(pendingPermissionRequestsRef, (requests) => {
|
|
1060
1167
|
requests.set(request.id, request);
|
|
1061
1168
|
return requests;
|
|
@@ -1071,14 +1178,14 @@ var LayerImpl8 = Effect11.gen(function* () {
|
|
|
1071
1178
|
if (response !== null) {
|
|
1072
1179
|
break;
|
|
1073
1180
|
}
|
|
1074
|
-
yield*
|
|
1181
|
+
yield* Effect14.sleep(1e3);
|
|
1075
1182
|
passedMs += 1e3;
|
|
1076
1183
|
}
|
|
1077
1184
|
return response;
|
|
1078
1185
|
});
|
|
1079
1186
|
const createCanUseToolRelatedOptions = (options) => {
|
|
1080
1187
|
const { taskId, userConfig, sessionId } = options;
|
|
1081
|
-
return
|
|
1188
|
+
return Effect14.gen(function* () {
|
|
1082
1189
|
const claudeCodeConfig = yield* Config;
|
|
1083
1190
|
if (!getAvailableFeatures(claudeCodeConfig.claudeCodeVersion).canUseTool) {
|
|
1084
1191
|
return {
|
|
@@ -1107,7 +1214,7 @@ var LayerImpl8 = Effect11.gen(function* () {
|
|
|
1107
1214
|
toolInput,
|
|
1108
1215
|
timestamp: Date.now()
|
|
1109
1216
|
};
|
|
1110
|
-
const response = await
|
|
1217
|
+
const response = await Effect14.runPromise(
|
|
1111
1218
|
waitPermissionResponse(permissionRequest, { timeoutMs: 6e4 })
|
|
1112
1219
|
);
|
|
1113
1220
|
if (response === null) {
|
|
@@ -1134,7 +1241,7 @@ var LayerImpl8 = Effect11.gen(function* () {
|
|
|
1134
1241
|
};
|
|
1135
1242
|
});
|
|
1136
1243
|
};
|
|
1137
|
-
const respondToPermissionRequest = (response) =>
|
|
1244
|
+
const respondToPermissionRequest = (response) => Effect14.gen(function* () {
|
|
1138
1245
|
yield* Ref4.update(permissionResponsesRef, (responses) => {
|
|
1139
1246
|
responses.set(response.permissionRequestId, response);
|
|
1140
1247
|
return responses;
|
|
@@ -1149,20 +1256,20 @@ var LayerImpl8 = Effect11.gen(function* () {
|
|
|
1149
1256
|
respondToPermissionRequest
|
|
1150
1257
|
};
|
|
1151
1258
|
});
|
|
1152
|
-
var ClaudeCodePermissionService = class extends
|
|
1259
|
+
var ClaudeCodePermissionService = class extends Context11.Tag(
|
|
1153
1260
|
"ClaudeCodePermissionService"
|
|
1154
1261
|
)() {
|
|
1155
1262
|
static {
|
|
1156
|
-
this.Live =
|
|
1263
|
+
this.Live = Layer13.effect(this, LayerImpl10);
|
|
1157
1264
|
}
|
|
1158
1265
|
};
|
|
1159
1266
|
|
|
1160
1267
|
// src/server/core/claude-code/presentation/ClaudeCodePermissionController.ts
|
|
1161
|
-
var
|
|
1268
|
+
var LayerImpl11 = Effect15.gen(function* () {
|
|
1162
1269
|
const claudeCodePermissionService = yield* ClaudeCodePermissionService;
|
|
1163
|
-
const permissionResponse = (options) =>
|
|
1270
|
+
const permissionResponse = (options) => Effect15.sync(() => {
|
|
1164
1271
|
const { permissionResponse: permissionResponse2 } = options;
|
|
1165
|
-
|
|
1272
|
+
Effect15.runFork(
|
|
1166
1273
|
claudeCodePermissionService.respondToPermissionRequest(
|
|
1167
1274
|
permissionResponse2
|
|
1168
1275
|
)
|
|
@@ -1178,19 +1285,19 @@ var LayerImpl9 = Effect12.gen(function* () {
|
|
|
1178
1285
|
permissionResponse
|
|
1179
1286
|
};
|
|
1180
1287
|
});
|
|
1181
|
-
var ClaudeCodePermissionController = class extends
|
|
1288
|
+
var ClaudeCodePermissionController = class extends Context12.Tag(
|
|
1182
1289
|
"ClaudeCodePermissionController"
|
|
1183
1290
|
)() {
|
|
1184
1291
|
static {
|
|
1185
|
-
this.Live =
|
|
1292
|
+
this.Live = Layer14.effect(this, LayerImpl11);
|
|
1186
1293
|
}
|
|
1187
1294
|
};
|
|
1188
1295
|
|
|
1189
1296
|
// src/server/core/claude-code/presentation/ClaudeCodeSessionProcessController.ts
|
|
1190
|
-
import { Context as
|
|
1297
|
+
import { Context as Context19, Effect as Effect23, Layer as Layer21 } from "effect";
|
|
1191
1298
|
|
|
1192
1299
|
// src/server/core/platform/services/UserConfigService.ts
|
|
1193
|
-
import { Context as
|
|
1300
|
+
import { Context as Context13, Effect as Effect16, Layer as Layer15, Ref as Ref5 } from "effect";
|
|
1194
1301
|
|
|
1195
1302
|
// src/lib/i18n/localeDetection.ts
|
|
1196
1303
|
var DEFAULT_LOCALE = "en";
|
|
@@ -1242,7 +1349,7 @@ var detectLocaleFromAcceptLanguage = (header) => {
|
|
|
1242
1349
|
};
|
|
1243
1350
|
|
|
1244
1351
|
// src/server/core/platform/services/UserConfigService.ts
|
|
1245
|
-
var
|
|
1352
|
+
var LayerImpl12 = Effect16.gen(function* () {
|
|
1246
1353
|
const configRef = yield* Ref5.make({
|
|
1247
1354
|
hideNoUserMessageSession: true,
|
|
1248
1355
|
unifySameTitleSession: false,
|
|
@@ -1251,10 +1358,10 @@ var LayerImpl10 = Effect13.gen(function* () {
|
|
|
1251
1358
|
locale: DEFAULT_LOCALE,
|
|
1252
1359
|
theme: "system"
|
|
1253
1360
|
});
|
|
1254
|
-
const setUserConfig = (newConfig) =>
|
|
1361
|
+
const setUserConfig = (newConfig) => Effect16.gen(function* () {
|
|
1255
1362
|
yield* Ref5.update(configRef, () => newConfig);
|
|
1256
1363
|
});
|
|
1257
|
-
const getUserConfig = () =>
|
|
1364
|
+
const getUserConfig = () => Effect16.gen(function* () {
|
|
1258
1365
|
const config = yield* Ref5.get(configRef);
|
|
1259
1366
|
return config;
|
|
1260
1367
|
});
|
|
@@ -1263,14 +1370,14 @@ var LayerImpl10 = Effect13.gen(function* () {
|
|
|
1263
1370
|
setUserConfig
|
|
1264
1371
|
};
|
|
1265
1372
|
});
|
|
1266
|
-
var UserConfigService = class extends
|
|
1373
|
+
var UserConfigService = class extends Context13.Tag("UserConfigService")() {
|
|
1267
1374
|
static {
|
|
1268
|
-
this.Live =
|
|
1375
|
+
this.Live = Layer15.effect(this, LayerImpl12);
|
|
1269
1376
|
}
|
|
1270
1377
|
};
|
|
1271
1378
|
|
|
1272
1379
|
// src/server/core/claude-code/services/ClaudeCodeLifeCycleService.ts
|
|
1273
|
-
import { Context as
|
|
1380
|
+
import { Context as Context18, Effect as Effect22, Layer as Layer20, Runtime as Runtime2 } from "effect";
|
|
1274
1381
|
import { ulid as ulid2 } from "ulid";
|
|
1275
1382
|
|
|
1276
1383
|
// src/lib/controllablePromise.ts
|
|
@@ -1300,8 +1407,8 @@ var controllablePromise = () => {
|
|
|
1300
1407
|
};
|
|
1301
1408
|
|
|
1302
1409
|
// src/server/core/session/infrastructure/SessionRepository.ts
|
|
1303
|
-
import { FileSystem as
|
|
1304
|
-
import { Context as
|
|
1410
|
+
import { FileSystem as FileSystem8, Path as Path9 } from "@effect/platform";
|
|
1411
|
+
import { Context as Context16, Effect as Effect19, Layer as Layer18, Option as Option3 } from "effect";
|
|
1305
1412
|
|
|
1306
1413
|
// src/server/core/claude-code/functions/parseUserMessage.ts
|
|
1307
1414
|
import { z as z21 } from "zod";
|
|
@@ -1377,29 +1484,32 @@ var decodeSessionId = (projectId, sessionId) => {
|
|
|
1377
1484
|
return resolve2(projectPath, `${sessionId}.jsonl`);
|
|
1378
1485
|
};
|
|
1379
1486
|
|
|
1487
|
+
// src/server/core/session/functions/isRegularSessionFile.ts
|
|
1488
|
+
var isRegularSessionFile = (filename) => filename.endsWith(".jsonl") && !filename.startsWith("agent-");
|
|
1489
|
+
|
|
1380
1490
|
// src/server/core/session/infrastructure/VirtualConversationDatabase.ts
|
|
1381
|
-
import { Context as
|
|
1382
|
-
var VirtualConversationDatabase = class extends
|
|
1491
|
+
import { Context as Context14, Effect as Effect17, Layer as Layer16, Ref as Ref6 } from "effect";
|
|
1492
|
+
var VirtualConversationDatabase = class extends Context14.Tag(
|
|
1383
1493
|
"VirtualConversationDatabase"
|
|
1384
1494
|
)() {
|
|
1385
1495
|
static {
|
|
1386
|
-
this.Live =
|
|
1496
|
+
this.Live = Layer16.effect(
|
|
1387
1497
|
this,
|
|
1388
|
-
|
|
1498
|
+
Effect17.gen(function* () {
|
|
1389
1499
|
const storageRef = yield* Ref6.make([]);
|
|
1390
|
-
const getProjectVirtualConversations = (projectId) =>
|
|
1500
|
+
const getProjectVirtualConversations = (projectId) => Effect17.gen(function* () {
|
|
1391
1501
|
const conversations = yield* Ref6.get(storageRef);
|
|
1392
1502
|
return conversations.filter(
|
|
1393
1503
|
(conversation) => conversation.projectId === projectId
|
|
1394
1504
|
);
|
|
1395
1505
|
});
|
|
1396
|
-
const getSessionVirtualConversation = (sessionId) =>
|
|
1506
|
+
const getSessionVirtualConversation = (sessionId) => Effect17.gen(function* () {
|
|
1397
1507
|
const conversations = yield* Ref6.get(storageRef);
|
|
1398
1508
|
return conversations.find(
|
|
1399
1509
|
(conversation) => conversation.sessionId === sessionId
|
|
1400
1510
|
) ?? null;
|
|
1401
1511
|
});
|
|
1402
|
-
const createVirtualConversation2 = (projectId, sessionId, createConversations) =>
|
|
1512
|
+
const createVirtualConversation2 = (projectId, sessionId, createConversations) => Effect17.gen(function* () {
|
|
1403
1513
|
yield* Ref6.update(storageRef, (conversations) => {
|
|
1404
1514
|
const existingRecord = conversations.find(
|
|
1405
1515
|
(record) => record.projectId === projectId && record.sessionId === sessionId
|
|
@@ -1418,7 +1528,7 @@ var VirtualConversationDatabase = class extends Context12.Tag(
|
|
|
1418
1528
|
return conversations;
|
|
1419
1529
|
});
|
|
1420
1530
|
});
|
|
1421
|
-
const deleteVirtualConversations = (sessionId) =>
|
|
1531
|
+
const deleteVirtualConversations = (sessionId) => Effect17.gen(function* () {
|
|
1422
1532
|
yield* Ref6.update(storageRef, (conversations) => {
|
|
1423
1533
|
return conversations.filter((c) => c.sessionId !== sessionId);
|
|
1424
1534
|
});
|
|
@@ -1435,8 +1545,8 @@ var VirtualConversationDatabase = class extends Context12.Tag(
|
|
|
1435
1545
|
};
|
|
1436
1546
|
|
|
1437
1547
|
// src/server/core/session/services/SessionMetaService.ts
|
|
1438
|
-
import { FileSystem as
|
|
1439
|
-
import { Context as
|
|
1548
|
+
import { FileSystem as FileSystem7 } from "@effect/platform";
|
|
1549
|
+
import { Context as Context15, Effect as Effect18, Layer as Layer17, Ref as Ref7 } from "effect";
|
|
1440
1550
|
|
|
1441
1551
|
// src/server/core/session/constants/pricing.ts
|
|
1442
1552
|
var MODEL_PRICING = {
|
|
@@ -1582,17 +1692,17 @@ var extractFirstUserMessage = (conversation) => {
|
|
|
1582
1692
|
|
|
1583
1693
|
// src/server/core/session/services/SessionMetaService.ts
|
|
1584
1694
|
var parsedUserMessageOrNullSchema = parsedUserMessageSchema.nullable();
|
|
1585
|
-
var SessionMetaService = class extends
|
|
1695
|
+
var SessionMetaService = class extends Context15.Tag("SessionMetaService")() {
|
|
1586
1696
|
static {
|
|
1587
|
-
this.Live =
|
|
1697
|
+
this.Live = Layer17.effect(
|
|
1588
1698
|
this,
|
|
1589
|
-
|
|
1590
|
-
const fs = yield*
|
|
1699
|
+
Effect18.gen(function* () {
|
|
1700
|
+
const fs = yield* FileSystem7.FileSystem;
|
|
1591
1701
|
const firstUserMessageCache = yield* FileCacheStorage();
|
|
1592
1702
|
const sessionMetaCacheRef = yield* Ref7.make(
|
|
1593
1703
|
/* @__PURE__ */ new Map()
|
|
1594
1704
|
);
|
|
1595
|
-
const getFirstUserMessage = (jsonlFilePath, lines) =>
|
|
1705
|
+
const getFirstUserMessage = (jsonlFilePath, lines) => Effect18.gen(function* () {
|
|
1596
1706
|
const cached = yield* firstUserMessageCache.get(jsonlFilePath);
|
|
1597
1707
|
if (cached !== void 0) {
|
|
1598
1708
|
return cached;
|
|
@@ -1677,7 +1787,7 @@ var SessionMetaService = class extends Context13.Tag("SessionMetaService")() {
|
|
|
1677
1787
|
modelName: lastModelName
|
|
1678
1788
|
};
|
|
1679
1789
|
};
|
|
1680
|
-
const getSessionMeta = (projectId, sessionId) =>
|
|
1790
|
+
const getSessionMeta = (projectId, sessionId) => Effect18.gen(function* () {
|
|
1681
1791
|
const metaCache = yield* Ref7.get(sessionMetaCacheRef);
|
|
1682
1792
|
const cached = metaCache.get(sessionId);
|
|
1683
1793
|
if (cached !== void 0) {
|
|
@@ -1706,7 +1816,7 @@ var SessionMetaService = class extends Context13.Tag("SessionMetaService")() {
|
|
|
1706
1816
|
});
|
|
1707
1817
|
return sessionMeta;
|
|
1708
1818
|
});
|
|
1709
|
-
const invalidateSession = (_projectId, sessionId) =>
|
|
1819
|
+
const invalidateSession = (_projectId, sessionId) => Effect18.gen(function* () {
|
|
1710
1820
|
yield* Ref7.update(sessionMetaCacheRef, (cache) => {
|
|
1711
1821
|
cache.delete(sessionId);
|
|
1712
1822
|
return cache;
|
|
@@ -1718,30 +1828,30 @@ var SessionMetaService = class extends Context13.Tag("SessionMetaService")() {
|
|
|
1718
1828
|
};
|
|
1719
1829
|
})
|
|
1720
1830
|
).pipe(
|
|
1721
|
-
|
|
1831
|
+
Layer17.provide(
|
|
1722
1832
|
makeFileCacheStorageLayer(
|
|
1723
1833
|
"first-user-message-cache",
|
|
1724
1834
|
parsedUserMessageOrNullSchema
|
|
1725
1835
|
)
|
|
1726
1836
|
),
|
|
1727
|
-
|
|
1837
|
+
Layer17.provide(PersistentService.Live)
|
|
1728
1838
|
);
|
|
1729
1839
|
}
|
|
1730
1840
|
};
|
|
1731
1841
|
|
|
1732
1842
|
// src/server/core/session/infrastructure/SessionRepository.ts
|
|
1733
|
-
var
|
|
1734
|
-
const fs = yield*
|
|
1735
|
-
const path = yield*
|
|
1843
|
+
var LayerImpl13 = Effect19.gen(function* () {
|
|
1844
|
+
const fs = yield* FileSystem8.FileSystem;
|
|
1845
|
+
const path = yield* Path9.Path;
|
|
1736
1846
|
const sessionMetaService = yield* SessionMetaService;
|
|
1737
1847
|
const virtualConversationDatabase = yield* VirtualConversationDatabase;
|
|
1738
|
-
const getSession = (projectId, sessionId) =>
|
|
1848
|
+
const getSession = (projectId, sessionId) => Effect19.gen(function* () {
|
|
1739
1849
|
const sessionPath = decodeSessionId(projectId, sessionId);
|
|
1740
1850
|
const virtualConversation = yield* virtualConversationDatabase.getSessionVirtualConversation(
|
|
1741
1851
|
sessionId
|
|
1742
1852
|
);
|
|
1743
1853
|
const exists = yield* fs.exists(sessionPath);
|
|
1744
|
-
const sessionDetail = yield* exists ?
|
|
1854
|
+
const sessionDetail = yield* exists ? Effect19.gen(function* () {
|
|
1745
1855
|
const content = yield* fs.readFileString(sessionPath);
|
|
1746
1856
|
const allLines = content.split("\n").filter((line) => line.trim());
|
|
1747
1857
|
const conversations = parseJsonl(allLines.join("\n"));
|
|
@@ -1779,7 +1889,7 @@ var LayerImpl11 = Effect16.gen(function* () {
|
|
|
1779
1889
|
return sessionDetail2;
|
|
1780
1890
|
}) : (() => {
|
|
1781
1891
|
if (virtualConversation === null) {
|
|
1782
|
-
return
|
|
1892
|
+
return Effect19.succeed(null);
|
|
1783
1893
|
}
|
|
1784
1894
|
const lastConversation = virtualConversation.conversations.filter(
|
|
1785
1895
|
(conversation) => conversation.type === "user" || conversation.type === "assistant" || conversation.type === "system"
|
|
@@ -1809,13 +1919,13 @@ var LayerImpl11 = Effect16.gen(function* () {
|
|
|
1809
1919
|
conversations: virtualConversation.conversations,
|
|
1810
1920
|
lastModifiedAt: lastConversation !== void 0 ? new Date(lastConversation.timestamp) : /* @__PURE__ */ new Date()
|
|
1811
1921
|
};
|
|
1812
|
-
return
|
|
1922
|
+
return Effect19.succeed(virtualSession);
|
|
1813
1923
|
})();
|
|
1814
1924
|
return {
|
|
1815
1925
|
session: sessionDetail
|
|
1816
1926
|
};
|
|
1817
1927
|
});
|
|
1818
|
-
const getSessions = (projectId, options) =>
|
|
1928
|
+
const getSessions = (projectId, options) => Effect19.gen(function* () {
|
|
1819
1929
|
const { maxCount = 20, cursor } = options ?? {};
|
|
1820
1930
|
const claudeProjectPath = decodeProjectId(projectId);
|
|
1821
1931
|
const dirExists = yield* fs.exists(claudeProjectPath);
|
|
@@ -1823,8 +1933,8 @@ var LayerImpl11 = Effect16.gen(function* () {
|
|
|
1823
1933
|
console.warn(`Project directory not found at ${claudeProjectPath}`);
|
|
1824
1934
|
return { sessions: [] };
|
|
1825
1935
|
}
|
|
1826
|
-
const dirents = yield*
|
|
1827
|
-
try: () => fs.readDirectory(claudeProjectPath).pipe(
|
|
1936
|
+
const dirents = yield* Effect19.tryPromise({
|
|
1937
|
+
try: () => fs.readDirectory(claudeProjectPath).pipe(Effect19.runPromise),
|
|
1828
1938
|
catch: (error) => {
|
|
1829
1939
|
console.warn(
|
|
1830
1940
|
`Failed to read sessions for project ${projectId}:`,
|
|
@@ -1832,14 +1942,14 @@ var LayerImpl11 = Effect16.gen(function* () {
|
|
|
1832
1942
|
);
|
|
1833
1943
|
return new Error("Failed to read directory");
|
|
1834
1944
|
}
|
|
1835
|
-
}).pipe(
|
|
1836
|
-
const sessionEffects = dirents.filter(
|
|
1837
|
-
(entry) =>
|
|
1945
|
+
}).pipe(Effect19.catchAll(() => Effect19.succeed([])));
|
|
1946
|
+
const sessionEffects = dirents.filter(isRegularSessionFile).map(
|
|
1947
|
+
(entry) => Effect19.gen(function* () {
|
|
1838
1948
|
const fullPath = path.resolve(claudeProjectPath, entry);
|
|
1839
1949
|
const sessionId = encodeSessionId(fullPath);
|
|
1840
|
-
const stat = yield*
|
|
1841
|
-
() => fs.stat(fullPath).pipe(
|
|
1842
|
-
).pipe(
|
|
1950
|
+
const stat = yield* Effect19.tryPromise(
|
|
1951
|
+
() => fs.stat(fullPath).pipe(Effect19.runPromise)
|
|
1952
|
+
).pipe(Effect19.catchAll(() => Effect19.succeed(null)));
|
|
1843
1953
|
if (!stat) {
|
|
1844
1954
|
return null;
|
|
1845
1955
|
}
|
|
@@ -1850,7 +1960,7 @@ var LayerImpl11 = Effect16.gen(function* () {
|
|
|
1850
1960
|
};
|
|
1851
1961
|
})
|
|
1852
1962
|
);
|
|
1853
|
-
const sessionsWithNulls = yield*
|
|
1963
|
+
const sessionsWithNulls = yield* Effect19.all(sessionEffects, {
|
|
1854
1964
|
concurrency: "unbounded"
|
|
1855
1965
|
});
|
|
1856
1966
|
const sessions = sessionsWithNulls.filter((s) => s !== null).sort(
|
|
@@ -1865,9 +1975,9 @@ var LayerImpl11 = Effect16.gen(function* () {
|
|
|
1865
1975
|
index + 1,
|
|
1866
1976
|
Math.min(index + 1 + maxCount, sessions.length)
|
|
1867
1977
|
);
|
|
1868
|
-
const sessionsWithMeta2 = yield*
|
|
1978
|
+
const sessionsWithMeta2 = yield* Effect19.all(
|
|
1869
1979
|
sessionsToReturn2.map(
|
|
1870
|
-
(item) =>
|
|
1980
|
+
(item) => Effect19.gen(function* () {
|
|
1871
1981
|
const meta = yield* sessionMetaService.getSessionMeta(
|
|
1872
1982
|
projectId,
|
|
1873
1983
|
item.id
|
|
@@ -1930,9 +2040,9 @@ var LayerImpl11 = Effect16.gen(function* () {
|
|
|
1930
2040
|
0,
|
|
1931
2041
|
Math.min(maxCount, sessions.length)
|
|
1932
2042
|
);
|
|
1933
|
-
const sessionsWithMeta = yield*
|
|
2043
|
+
const sessionsWithMeta = yield* Effect19.all(
|
|
1934
2044
|
sessionsToReturn.map(
|
|
1935
|
-
(item) =>
|
|
2045
|
+
(item) => Effect19.gen(function* () {
|
|
1936
2046
|
const meta = yield* sessionMetaService.getSessionMeta(
|
|
1937
2047
|
projectId,
|
|
1938
2048
|
item.id
|
|
@@ -1954,9 +2064,9 @@ var LayerImpl11 = Effect16.gen(function* () {
|
|
|
1954
2064
|
getSessions
|
|
1955
2065
|
};
|
|
1956
2066
|
});
|
|
1957
|
-
var SessionRepository = class extends
|
|
2067
|
+
var SessionRepository = class extends Context16.Tag("SessionRepository")() {
|
|
1958
2068
|
static {
|
|
1959
|
-
this.Live =
|
|
2069
|
+
this.Live = Layer18.effect(this, LayerImpl13);
|
|
1960
2070
|
}
|
|
1961
2071
|
};
|
|
1962
2072
|
|
|
@@ -2056,7 +2166,7 @@ var fallbackSdkMessage = (message) => {
|
|
|
2056
2166
|
};
|
|
2057
2167
|
|
|
2058
2168
|
// src/server/core/claude-code/models/CCSessionProcess.ts
|
|
2059
|
-
import { Effect as
|
|
2169
|
+
import { Effect as Effect20 } from "effect";
|
|
2060
2170
|
var isPublic = (process2) => {
|
|
2061
2171
|
return process2.type === "initialized" || process2.type === "file_created" || process2.type === "paused";
|
|
2062
2172
|
};
|
|
@@ -2067,7 +2177,7 @@ var getAliveTasks = (process2) => {
|
|
|
2067
2177
|
};
|
|
2068
2178
|
var createVirtualConversation = (process2, ctx) => {
|
|
2069
2179
|
const timestamp = (/* @__PURE__ */ new Date()).toISOString();
|
|
2070
|
-
return
|
|
2180
|
+
return Effect20.gen(function* () {
|
|
2071
2181
|
const config = yield* Config;
|
|
2072
2182
|
const virtualConversation = {
|
|
2073
2183
|
type: "user",
|
|
@@ -2089,7 +2199,7 @@ var createVirtualConversation = (process2, ctx) => {
|
|
|
2089
2199
|
};
|
|
2090
2200
|
|
|
2091
2201
|
// src/server/core/claude-code/services/ClaudeCodeSessionProcessService.ts
|
|
2092
|
-
import { Context as
|
|
2202
|
+
import { Context as Context17, Data as Data3, Effect as Effect21, Layer as Layer19, Ref as Ref8 } from "effect";
|
|
2093
2203
|
var SessionProcessNotFoundError = class extends Data3.TaggedError(
|
|
2094
2204
|
"SessionProcessNotFoundError"
|
|
2095
2205
|
) {
|
|
@@ -2108,12 +2218,12 @@ var IllegalStateChangeError = class extends Data3.TaggedError(
|
|
|
2108
2218
|
};
|
|
2109
2219
|
var TaskNotFoundError = class extends Data3.TaggedError("TaskNotFoundError") {
|
|
2110
2220
|
};
|
|
2111
|
-
var
|
|
2221
|
+
var LayerImpl14 = Effect21.gen(function* () {
|
|
2112
2222
|
const processesRef = yield* Ref8.make([]);
|
|
2113
2223
|
const eventBus = yield* EventBus;
|
|
2114
2224
|
const startSessionProcess = (options) => {
|
|
2115
2225
|
const { sessionDef, taskDef } = options;
|
|
2116
|
-
return
|
|
2226
|
+
return Effect21.gen(function* () {
|
|
2117
2227
|
const task = {
|
|
2118
2228
|
def: taskDef,
|
|
2119
2229
|
status: "pending"
|
|
@@ -2136,10 +2246,10 @@ var LayerImpl12 = Effect18.gen(function* () {
|
|
|
2136
2246
|
};
|
|
2137
2247
|
const continueSessionProcess = (options) => {
|
|
2138
2248
|
const { sessionProcessId } = options;
|
|
2139
|
-
return
|
|
2249
|
+
return Effect21.gen(function* () {
|
|
2140
2250
|
const process2 = yield* getSessionProcess(sessionProcessId);
|
|
2141
2251
|
if (process2.type !== "paused") {
|
|
2142
|
-
return yield*
|
|
2252
|
+
return yield* Effect21.fail(
|
|
2143
2253
|
new SessionProcessNotPausedError({
|
|
2144
2254
|
sessionProcessId
|
|
2145
2255
|
})
|
|
@@ -2147,7 +2257,7 @@ var LayerImpl12 = Effect18.gen(function* () {
|
|
|
2147
2257
|
}
|
|
2148
2258
|
const [firstAliveTask] = getAliveTasks(process2);
|
|
2149
2259
|
if (firstAliveTask !== void 0) {
|
|
2150
|
-
return yield*
|
|
2260
|
+
return yield* Effect21.fail(
|
|
2151
2261
|
new SessionProcessAlreadyAliveError({
|
|
2152
2262
|
sessionProcessId,
|
|
2153
2263
|
aliveTaskId: firstAliveTask.def.taskId,
|
|
@@ -2177,13 +2287,13 @@ var LayerImpl12 = Effect18.gen(function* () {
|
|
|
2177
2287
|
});
|
|
2178
2288
|
};
|
|
2179
2289
|
const getSessionProcess = (sessionProcessId) => {
|
|
2180
|
-
return
|
|
2290
|
+
return Effect21.gen(function* () {
|
|
2181
2291
|
const processes = yield* Ref8.get(processesRef);
|
|
2182
2292
|
const result = processes.find(
|
|
2183
2293
|
(p) => p.def.sessionProcessId === sessionProcessId
|
|
2184
2294
|
);
|
|
2185
2295
|
if (result === void 0) {
|
|
2186
|
-
return yield*
|
|
2296
|
+
return yield* Effect21.fail(
|
|
2187
2297
|
new SessionProcessNotFoundError({ sessionProcessId })
|
|
2188
2298
|
);
|
|
2189
2299
|
}
|
|
@@ -2191,13 +2301,13 @@ var LayerImpl12 = Effect18.gen(function* () {
|
|
|
2191
2301
|
});
|
|
2192
2302
|
};
|
|
2193
2303
|
const getSessionProcesses = () => {
|
|
2194
|
-
return
|
|
2304
|
+
return Effect21.gen(function* () {
|
|
2195
2305
|
const processes = yield* Ref8.get(processesRef);
|
|
2196
2306
|
return processes;
|
|
2197
2307
|
});
|
|
2198
2308
|
};
|
|
2199
2309
|
const getTask = (taskId) => {
|
|
2200
|
-
return
|
|
2310
|
+
return Effect21.gen(function* () {
|
|
2201
2311
|
const processes = yield* Ref8.get(processesRef);
|
|
2202
2312
|
const result = processes.flatMap((p) => {
|
|
2203
2313
|
const found = p.tasks.find((t) => t.def.taskId === taskId);
|
|
@@ -2212,14 +2322,14 @@ var LayerImpl12 = Effect18.gen(function* () {
|
|
|
2212
2322
|
];
|
|
2213
2323
|
}).at(0);
|
|
2214
2324
|
if (result === void 0) {
|
|
2215
|
-
return yield*
|
|
2325
|
+
return yield* Effect21.fail(new TaskNotFoundError({ taskId }));
|
|
2216
2326
|
}
|
|
2217
2327
|
return result;
|
|
2218
2328
|
});
|
|
2219
2329
|
};
|
|
2220
2330
|
const dangerouslyChangeProcessState = (options) => {
|
|
2221
2331
|
const { sessionProcessId, nextState } = options;
|
|
2222
|
-
return
|
|
2332
|
+
return Effect21.gen(function* () {
|
|
2223
2333
|
const processes = yield* Ref8.get(processesRef);
|
|
2224
2334
|
const targetProcess = processes.find(
|
|
2225
2335
|
(p) => p.def.sessionProcessId === sessionProcessId
|
|
@@ -2248,7 +2358,7 @@ var LayerImpl12 = Effect18.gen(function* () {
|
|
|
2248
2358
|
};
|
|
2249
2359
|
const changeTaskState = (options) => {
|
|
2250
2360
|
const { sessionProcessId, taskId, nextTask } = options;
|
|
2251
|
-
return
|
|
2361
|
+
return Effect21.gen(function* () {
|
|
2252
2362
|
const { task } = yield* getTask(taskId);
|
|
2253
2363
|
yield* Ref8.update(processesRef, (processes) => {
|
|
2254
2364
|
return processes.map(
|
|
@@ -2269,10 +2379,10 @@ var LayerImpl12 = Effect18.gen(function* () {
|
|
|
2269
2379
|
};
|
|
2270
2380
|
const toNotInitializedState = (options) => {
|
|
2271
2381
|
const { sessionProcessId, rawUserMessage } = options;
|
|
2272
|
-
return
|
|
2382
|
+
return Effect21.gen(function* () {
|
|
2273
2383
|
const currentProcess = yield* getSessionProcess(sessionProcessId);
|
|
2274
2384
|
if (currentProcess.type !== "pending") {
|
|
2275
|
-
return yield*
|
|
2385
|
+
return yield* Effect21.fail(
|
|
2276
2386
|
new IllegalStateChangeError({
|
|
2277
2387
|
from: currentProcess.type,
|
|
2278
2388
|
to: "not_initialized"
|
|
@@ -2305,10 +2415,10 @@ var LayerImpl12 = Effect18.gen(function* () {
|
|
|
2305
2415
|
};
|
|
2306
2416
|
const toInitializedState = (options) => {
|
|
2307
2417
|
const { sessionProcessId, initContext } = options;
|
|
2308
|
-
return
|
|
2418
|
+
return Effect21.gen(function* () {
|
|
2309
2419
|
const currentProcess = yield* getSessionProcess(sessionProcessId);
|
|
2310
2420
|
if (currentProcess.type !== "not_initialized") {
|
|
2311
|
-
return yield*
|
|
2421
|
+
return yield* Effect21.fail(
|
|
2312
2422
|
new IllegalStateChangeError({
|
|
2313
2423
|
from: currentProcess.type,
|
|
2314
2424
|
to: "initialized"
|
|
@@ -2334,10 +2444,10 @@ var LayerImpl12 = Effect18.gen(function* () {
|
|
|
2334
2444
|
};
|
|
2335
2445
|
const toFileCreatedState = (options) => {
|
|
2336
2446
|
const { sessionProcessId } = options;
|
|
2337
|
-
return
|
|
2447
|
+
return Effect21.gen(function* () {
|
|
2338
2448
|
const currentProcess = yield* getSessionProcess(sessionProcessId);
|
|
2339
2449
|
if (currentProcess.type !== "initialized") {
|
|
2340
|
-
return yield*
|
|
2450
|
+
return yield* Effect21.fail(
|
|
2341
2451
|
new IllegalStateChangeError({
|
|
2342
2452
|
from: currentProcess.type,
|
|
2343
2453
|
to: "file_created"
|
|
@@ -2363,10 +2473,10 @@ var LayerImpl12 = Effect18.gen(function* () {
|
|
|
2363
2473
|
};
|
|
2364
2474
|
const toPausedState = (options) => {
|
|
2365
2475
|
const { sessionProcessId, resultMessage } = options;
|
|
2366
|
-
return
|
|
2476
|
+
return Effect21.gen(function* () {
|
|
2367
2477
|
const currentProcess = yield* getSessionProcess(sessionProcessId);
|
|
2368
2478
|
if (currentProcess.type !== "file_created") {
|
|
2369
|
-
return yield*
|
|
2479
|
+
return yield* Effect21.fail(
|
|
2370
2480
|
new IllegalStateChangeError({
|
|
2371
2481
|
from: currentProcess.type,
|
|
2372
2482
|
to: "paused"
|
|
@@ -2400,7 +2510,7 @@ var LayerImpl12 = Effect18.gen(function* () {
|
|
|
2400
2510
|
};
|
|
2401
2511
|
const toCompletedState = (options) => {
|
|
2402
2512
|
const { sessionProcessId, error } = options;
|
|
2403
|
-
return
|
|
2513
|
+
return Effect21.gen(function* () {
|
|
2404
2514
|
const currentProcess = yield* getSessionProcess(sessionProcessId);
|
|
2405
2515
|
const currentTask = currentProcess.type === "not_initialized" || currentProcess.type === "initialized" || currentProcess.type === "file_created" ? currentProcess.currentTask : void 0;
|
|
2406
2516
|
const newTask = currentTask !== void 0 ? error !== void 0 ? {
|
|
@@ -2453,25 +2563,25 @@ var LayerImpl12 = Effect18.gen(function* () {
|
|
|
2453
2563
|
changeTaskState
|
|
2454
2564
|
};
|
|
2455
2565
|
});
|
|
2456
|
-
var ClaudeCodeSessionProcessService = class extends
|
|
2566
|
+
var ClaudeCodeSessionProcessService = class extends Context17.Tag(
|
|
2457
2567
|
"ClaudeCodeSessionProcessService"
|
|
2458
2568
|
)() {
|
|
2459
2569
|
static {
|
|
2460
|
-
this.Live =
|
|
2570
|
+
this.Live = Layer19.effect(this, LayerImpl14);
|
|
2461
2571
|
}
|
|
2462
2572
|
};
|
|
2463
2573
|
|
|
2464
2574
|
// src/server/core/claude-code/services/ClaudeCodeLifeCycleService.ts
|
|
2465
|
-
var
|
|
2575
|
+
var LayerImpl15 = Effect22.gen(function* () {
|
|
2466
2576
|
const eventBusService = yield* EventBus;
|
|
2467
2577
|
const sessionRepository = yield* SessionRepository;
|
|
2468
2578
|
const sessionProcessService = yield* ClaudeCodeSessionProcessService;
|
|
2469
2579
|
const virtualConversationDatabase = yield* VirtualConversationDatabase;
|
|
2470
2580
|
const permissionService = yield* ClaudeCodePermissionService;
|
|
2471
|
-
const runtime = yield*
|
|
2581
|
+
const runtime = yield* Effect22.runtime();
|
|
2472
2582
|
const continueTask = (options) => {
|
|
2473
2583
|
const { sessionProcessId, baseSessionId, input } = options;
|
|
2474
|
-
return
|
|
2584
|
+
return Effect22.gen(function* () {
|
|
2475
2585
|
const { sessionProcess, task } = yield* sessionProcessService.continueSessionProcess({
|
|
2476
2586
|
sessionProcessId,
|
|
2477
2587
|
taskDef: {
|
|
@@ -2499,7 +2609,7 @@ var LayerImpl13 = Effect19.gen(function* () {
|
|
|
2499
2609
|
};
|
|
2500
2610
|
const startTask = (options) => {
|
|
2501
2611
|
const { baseSession, input, userConfig } = options;
|
|
2502
|
-
return
|
|
2612
|
+
return Effect22.gen(function* () {
|
|
2503
2613
|
const {
|
|
2504
2614
|
generateMessages,
|
|
2505
2615
|
setNextMessage,
|
|
@@ -2527,7 +2637,7 @@ var LayerImpl13 = Effect19.gen(function* () {
|
|
|
2527
2637
|
const sessionFileCreatedPromise = controllablePromise();
|
|
2528
2638
|
setMessageGeneratorHooks({
|
|
2529
2639
|
onNewUserMessageResolved: async (input2) => {
|
|
2530
|
-
|
|
2640
|
+
Effect22.runFork(
|
|
2531
2641
|
sessionProcessService.toNotInitializedState({
|
|
2532
2642
|
sessionProcessId: sessionProcess.def.sessionProcessId,
|
|
2533
2643
|
rawUserMessage: input2.text
|
|
@@ -2535,7 +2645,7 @@ var LayerImpl13 = Effect19.gen(function* () {
|
|
|
2535
2645
|
);
|
|
2536
2646
|
}
|
|
2537
2647
|
});
|
|
2538
|
-
const handleMessage = (message) =>
|
|
2648
|
+
const handleMessage = (message) => Effect22.gen(function* () {
|
|
2539
2649
|
const processState = yield* sessionProcessService.getSessionProcess(
|
|
2540
2650
|
sessionProcess.def.sessionProcessId
|
|
2541
2651
|
);
|
|
@@ -2543,7 +2653,7 @@ var LayerImpl13 = Effect19.gen(function* () {
|
|
|
2543
2653
|
return "break";
|
|
2544
2654
|
}
|
|
2545
2655
|
if (processState.type === "paused") {
|
|
2546
|
-
yield*
|
|
2656
|
+
yield* Effect22.die(
|
|
2547
2657
|
new Error("Illegal state: paused is not expected")
|
|
2548
2658
|
);
|
|
2549
2659
|
}
|
|
@@ -2615,7 +2725,7 @@ var LayerImpl13 = Effect19.gen(function* () {
|
|
|
2615
2725
|
});
|
|
2616
2726
|
const handleSessionProcessDaemon = async () => {
|
|
2617
2727
|
const messageIter = await Runtime2.runPromise(runtime)(
|
|
2618
|
-
|
|
2728
|
+
Effect22.gen(function* () {
|
|
2619
2729
|
const permissionOptions = yield* permissionService.createCanUseToolRelatedOptions({
|
|
2620
2730
|
taskId: task.def.taskId,
|
|
2621
2731
|
userConfig,
|
|
@@ -2636,7 +2746,7 @@ var LayerImpl13 = Effect19.gen(function* () {
|
|
|
2636
2746
|
const result = await Runtime2.runPromise(runtime)(
|
|
2637
2747
|
handleMessage(fallbackMessage)
|
|
2638
2748
|
).catch((error) => {
|
|
2639
|
-
|
|
2749
|
+
Effect22.runFork(
|
|
2640
2750
|
sessionProcessService.changeTaskState({
|
|
2641
2751
|
sessionProcessId: sessionProcess.def.sessionProcessId,
|
|
2642
2752
|
taskId: task.def.taskId,
|
|
@@ -2667,7 +2777,7 @@ var LayerImpl13 = Effect19.gen(function* () {
|
|
|
2667
2777
|
if (sessionFileCreatedPromise.status === "pending") {
|
|
2668
2778
|
sessionFileCreatedPromise.reject(error);
|
|
2669
2779
|
}
|
|
2670
|
-
await
|
|
2780
|
+
await Effect22.runPromise(
|
|
2671
2781
|
sessionProcessService.changeTaskState({
|
|
2672
2782
|
sessionProcessId: sessionProcess.def.sessionProcessId,
|
|
2673
2783
|
taskId: task.def.taskId,
|
|
@@ -2690,8 +2800,8 @@ var LayerImpl13 = Effect19.gen(function* () {
|
|
|
2690
2800
|
}
|
|
2691
2801
|
throw error;
|
|
2692
2802
|
}).finally(() => {
|
|
2693
|
-
|
|
2694
|
-
|
|
2803
|
+
Effect22.runFork(
|
|
2804
|
+
Effect22.gen(function* () {
|
|
2695
2805
|
const currentProcess = yield* sessionProcessService.getSessionProcess(
|
|
2696
2806
|
sessionProcess.def.sessionProcessId
|
|
2697
2807
|
);
|
|
@@ -2707,16 +2817,16 @@ var LayerImpl13 = Effect19.gen(function* () {
|
|
|
2707
2817
|
daemonPromise,
|
|
2708
2818
|
awaitSessionInitialized: async () => await sessionInitializedPromise.promise,
|
|
2709
2819
|
awaitSessionFileCreated: async () => await sessionFileCreatedPromise.promise,
|
|
2710
|
-
yieldSessionInitialized: () =>
|
|
2711
|
-
yieldSessionFileCreated: () =>
|
|
2820
|
+
yieldSessionInitialized: () => Effect22.promise(() => sessionInitializedPromise.promise),
|
|
2821
|
+
yieldSessionFileCreated: () => Effect22.promise(() => sessionFileCreatedPromise.promise)
|
|
2712
2822
|
};
|
|
2713
2823
|
});
|
|
2714
2824
|
};
|
|
2715
|
-
const getPublicSessionProcesses = () =>
|
|
2825
|
+
const getPublicSessionProcesses = () => Effect22.gen(function* () {
|
|
2716
2826
|
const processes = yield* sessionProcessService.getSessionProcesses();
|
|
2717
2827
|
return processes.filter((process2) => isPublic(process2));
|
|
2718
2828
|
});
|
|
2719
|
-
const abortTask = (sessionProcessId) =>
|
|
2829
|
+
const abortTask = (sessionProcessId) => Effect22.gen(function* () {
|
|
2720
2830
|
const currentProcess = yield* sessionProcessService.getSessionProcess(sessionProcessId);
|
|
2721
2831
|
currentProcess.def.abortController.abort();
|
|
2722
2832
|
yield* sessionProcessService.toCompletedState({
|
|
@@ -2724,7 +2834,7 @@ var LayerImpl13 = Effect19.gen(function* () {
|
|
|
2724
2834
|
error: new Error("Task aborted")
|
|
2725
2835
|
});
|
|
2726
2836
|
});
|
|
2727
|
-
const abortAllTasks = () =>
|
|
2837
|
+
const abortAllTasks = () => Effect22.gen(function* () {
|
|
2728
2838
|
const processes = yield* sessionProcessService.getSessionProcesses();
|
|
2729
2839
|
for (const process2 of processes) {
|
|
2730
2840
|
yield* sessionProcessService.toCompletedState({
|
|
@@ -2741,20 +2851,20 @@ var LayerImpl13 = Effect19.gen(function* () {
|
|
|
2741
2851
|
getPublicSessionProcesses
|
|
2742
2852
|
};
|
|
2743
2853
|
});
|
|
2744
|
-
var ClaudeCodeLifeCycleService = class extends
|
|
2854
|
+
var ClaudeCodeLifeCycleService = class extends Context18.Tag(
|
|
2745
2855
|
"ClaudeCodeLifeCycleService"
|
|
2746
2856
|
)() {
|
|
2747
2857
|
static {
|
|
2748
|
-
this.Live =
|
|
2858
|
+
this.Live = Layer20.effect(this, LayerImpl15);
|
|
2749
2859
|
}
|
|
2750
2860
|
};
|
|
2751
2861
|
|
|
2752
2862
|
// src/server/core/claude-code/presentation/ClaudeCodeSessionProcessController.ts
|
|
2753
|
-
var
|
|
2863
|
+
var LayerImpl16 = Effect23.gen(function* () {
|
|
2754
2864
|
const projectRepository = yield* ProjectRepository;
|
|
2755
2865
|
const claudeCodeLifeCycleService = yield* ClaudeCodeLifeCycleService;
|
|
2756
2866
|
const userConfigService = yield* UserConfigService;
|
|
2757
|
-
const getSessionProcesses = () =>
|
|
2867
|
+
const getSessionProcesses = () => Effect23.gen(function* () {
|
|
2758
2868
|
const publicSessionProcesses = yield* claudeCodeLifeCycleService.getPublicSessionProcesses();
|
|
2759
2869
|
return {
|
|
2760
2870
|
response: {
|
|
@@ -2770,7 +2880,7 @@ var LayerImpl14 = Effect20.gen(function* () {
|
|
|
2770
2880
|
status: 200
|
|
2771
2881
|
};
|
|
2772
2882
|
});
|
|
2773
|
-
const createSessionProcess = (options) =>
|
|
2883
|
+
const createSessionProcess = (options) => Effect23.gen(function* () {
|
|
2774
2884
|
const { projectId, input, baseSessionId } = options;
|
|
2775
2885
|
const { project } = yield* projectRepository.getProject(projectId);
|
|
2776
2886
|
const userConfig = yield* userConfigService.getUserConfig();
|
|
@@ -2801,7 +2911,7 @@ var LayerImpl14 = Effect20.gen(function* () {
|
|
|
2801
2911
|
}
|
|
2802
2912
|
};
|
|
2803
2913
|
});
|
|
2804
|
-
const continueSessionProcess = (options) =>
|
|
2914
|
+
const continueSessionProcess = (options) => Effect23.gen(function* () {
|
|
2805
2915
|
const { projectId, input, baseSessionId, sessionProcessId } = options;
|
|
2806
2916
|
const { project } = yield* projectRepository.getProject(projectId);
|
|
2807
2917
|
if (project.meta.projectPath === null) {
|
|
@@ -2832,16 +2942,16 @@ var LayerImpl14 = Effect20.gen(function* () {
|
|
|
2832
2942
|
continueSessionProcess
|
|
2833
2943
|
};
|
|
2834
2944
|
});
|
|
2835
|
-
var ClaudeCodeSessionProcessController = class extends
|
|
2945
|
+
var ClaudeCodeSessionProcessController = class extends Context19.Tag(
|
|
2836
2946
|
"ClaudeCodeSessionProcessController"
|
|
2837
2947
|
)() {
|
|
2838
2948
|
static {
|
|
2839
|
-
this.Live =
|
|
2949
|
+
this.Live = Layer21.effect(this, LayerImpl16);
|
|
2840
2950
|
}
|
|
2841
2951
|
};
|
|
2842
2952
|
|
|
2843
2953
|
// src/server/core/events/presentation/SSEController.ts
|
|
2844
|
-
import { Context as
|
|
2954
|
+
import { Context as Context21, Effect as Effect25, Layer as Layer23 } from "effect";
|
|
2845
2955
|
|
|
2846
2956
|
// src/server/core/events/functions/adaptInternalEventToSSE.ts
|
|
2847
2957
|
var adaptInternalEventToSSE = (rawStream, options) => {
|
|
@@ -2868,12 +2978,12 @@ var adaptInternalEventToSSE = (rawStream, options) => {
|
|
|
2868
2978
|
};
|
|
2869
2979
|
|
|
2870
2980
|
// src/server/core/events/functions/typeSafeSSE.ts
|
|
2871
|
-
import { Context as
|
|
2981
|
+
import { Context as Context20, Effect as Effect24, Layer as Layer22 } from "effect";
|
|
2872
2982
|
import { ulid as ulid3 } from "ulid";
|
|
2873
|
-
var TypeSafeSSE = class extends
|
|
2983
|
+
var TypeSafeSSE = class extends Context20.Tag("TypeSafeSSE")() {
|
|
2874
2984
|
static {
|
|
2875
|
-
this.make = (stream) =>
|
|
2876
|
-
writeSSE: (event, data) =>
|
|
2985
|
+
this.make = (stream) => Layer22.succeed(this, {
|
|
2986
|
+
writeSSE: (event, data) => Effect24.tryPromise({
|
|
2877
2987
|
try: async () => {
|
|
2878
2988
|
const id = ulid3();
|
|
2879
2989
|
await stream.writeSSE({
|
|
@@ -2898,44 +3008,52 @@ var TypeSafeSSE = class extends Context18.Tag("TypeSafeSSE")() {
|
|
|
2898
3008
|
};
|
|
2899
3009
|
|
|
2900
3010
|
// src/server/core/events/presentation/SSEController.ts
|
|
2901
|
-
var
|
|
3011
|
+
var LayerImpl17 = Effect25.gen(function* () {
|
|
2902
3012
|
const eventBus = yield* EventBus;
|
|
2903
|
-
const handleSSE = (rawStream) =>
|
|
3013
|
+
const handleSSE = (rawStream) => Effect25.gen(function* () {
|
|
2904
3014
|
const typeSafeSSE = yield* TypeSafeSSE;
|
|
2905
3015
|
yield* typeSafeSSE.writeSSE("connect", {
|
|
2906
3016
|
timestamp: (/* @__PURE__ */ new Date()).toISOString()
|
|
2907
3017
|
});
|
|
2908
3018
|
const onHeartbeat = () => {
|
|
2909
|
-
|
|
3019
|
+
Effect25.runFork(
|
|
2910
3020
|
typeSafeSSE.writeSSE("heartbeat", {
|
|
2911
3021
|
timestamp: (/* @__PURE__ */ new Date()).toISOString()
|
|
2912
3022
|
})
|
|
2913
3023
|
);
|
|
2914
3024
|
};
|
|
2915
3025
|
const onSessionListChanged = (event) => {
|
|
2916
|
-
|
|
3026
|
+
Effect25.runFork(
|
|
2917
3027
|
typeSafeSSE.writeSSE("sessionListChanged", {
|
|
2918
3028
|
projectId: event.projectId
|
|
2919
3029
|
})
|
|
2920
3030
|
);
|
|
2921
3031
|
};
|
|
2922
3032
|
const onSessionChanged = (event) => {
|
|
2923
|
-
|
|
3033
|
+
Effect25.runFork(
|
|
2924
3034
|
typeSafeSSE.writeSSE("sessionChanged", {
|
|
2925
3035
|
projectId: event.projectId,
|
|
2926
3036
|
sessionId: event.sessionId
|
|
2927
3037
|
})
|
|
2928
3038
|
);
|
|
2929
3039
|
};
|
|
3040
|
+
const onAgentSessionChanged = (event) => {
|
|
3041
|
+
Effect25.runFork(
|
|
3042
|
+
typeSafeSSE.writeSSE("agentSessionChanged", {
|
|
3043
|
+
projectId: event.projectId,
|
|
3044
|
+
agentSessionId: event.agentSessionId
|
|
3045
|
+
})
|
|
3046
|
+
);
|
|
3047
|
+
};
|
|
2930
3048
|
const onSessionProcessChanged = (event) => {
|
|
2931
|
-
|
|
3049
|
+
Effect25.runFork(
|
|
2932
3050
|
typeSafeSSE.writeSSE("sessionProcessChanged", {
|
|
2933
3051
|
processes: event.processes
|
|
2934
3052
|
})
|
|
2935
3053
|
);
|
|
2936
3054
|
};
|
|
2937
3055
|
const onPermissionRequested = (event) => {
|
|
2938
|
-
|
|
3056
|
+
Effect25.runFork(
|
|
2939
3057
|
typeSafeSSE.writeSSE("permissionRequested", {
|
|
2940
3058
|
permissionRequest: event.permissionRequest
|
|
2941
3059
|
})
|
|
@@ -2943,16 +3061,18 @@ var LayerImpl15 = Effect22.gen(function* () {
|
|
|
2943
3061
|
};
|
|
2944
3062
|
yield* eventBus.on("sessionListChanged", onSessionListChanged);
|
|
2945
3063
|
yield* eventBus.on("sessionChanged", onSessionChanged);
|
|
3064
|
+
yield* eventBus.on("agentSessionChanged", onAgentSessionChanged);
|
|
2946
3065
|
yield* eventBus.on("sessionProcessChanged", onSessionProcessChanged);
|
|
2947
3066
|
yield* eventBus.on("heartbeat", onHeartbeat);
|
|
2948
3067
|
yield* eventBus.on("permissionRequested", onPermissionRequested);
|
|
2949
3068
|
const { connectionPromise } = adaptInternalEventToSSE(rawStream, {
|
|
2950
3069
|
timeout: 5 * 60 * 1e3,
|
|
2951
3070
|
cleanUp: async () => {
|
|
2952
|
-
await
|
|
2953
|
-
|
|
3071
|
+
await Effect25.runPromise(
|
|
3072
|
+
Effect25.gen(function* () {
|
|
2954
3073
|
yield* eventBus.off("sessionListChanged", onSessionListChanged);
|
|
2955
3074
|
yield* eventBus.off("sessionChanged", onSessionChanged);
|
|
3075
|
+
yield* eventBus.off("agentSessionChanged", onAgentSessionChanged);
|
|
2956
3076
|
yield* eventBus.off(
|
|
2957
3077
|
"sessionProcessChanged",
|
|
2958
3078
|
onSessionProcessChanged
|
|
@@ -2963,34 +3083,64 @@ var LayerImpl15 = Effect22.gen(function* () {
|
|
|
2963
3083
|
);
|
|
2964
3084
|
}
|
|
2965
3085
|
});
|
|
2966
|
-
yield*
|
|
3086
|
+
yield* Effect25.promise(() => connectionPromise);
|
|
2967
3087
|
});
|
|
2968
3088
|
return {
|
|
2969
3089
|
handleSSE
|
|
2970
3090
|
};
|
|
2971
3091
|
});
|
|
2972
|
-
var SSEController = class extends
|
|
3092
|
+
var SSEController = class extends Context21.Tag("SSEController")() {
|
|
2973
3093
|
static {
|
|
2974
|
-
this.Live =
|
|
3094
|
+
this.Live = Layer23.effect(this, LayerImpl17);
|
|
2975
3095
|
}
|
|
2976
3096
|
};
|
|
2977
3097
|
|
|
2978
3098
|
// src/server/core/events/services/fileWatcher.ts
|
|
2979
3099
|
import { watch } from "node:fs";
|
|
2980
|
-
import { Path as
|
|
2981
|
-
import { Context as
|
|
3100
|
+
import { Path as Path10 } from "@effect/platform";
|
|
3101
|
+
import { Context as Context22, Effect as Effect26, Layer as Layer24, Ref as Ref9 } from "effect";
|
|
3102
|
+
|
|
3103
|
+
// src/server/core/events/functions/parseSessionFilePath.ts
|
|
2982
3104
|
import z22 from "zod";
|
|
2983
|
-
var
|
|
2984
|
-
var
|
|
3105
|
+
var sessionFileRegExp = /(?<projectId>.*?)\/(?<sessionId>.*?)\.jsonl$/;
|
|
3106
|
+
var agentFileRegExp = /(?<projectId>.*?)\/agent-(?<agentSessionId>.*?)\.jsonl$/;
|
|
3107
|
+
var sessionFileGroupSchema = z22.object({
|
|
2985
3108
|
projectId: z22.string(),
|
|
2986
3109
|
sessionId: z22.string()
|
|
2987
3110
|
});
|
|
2988
|
-
var
|
|
3111
|
+
var agentFileGroupSchema = z22.object({
|
|
3112
|
+
projectId: z22.string(),
|
|
3113
|
+
agentSessionId: z22.string()
|
|
3114
|
+
});
|
|
3115
|
+
var parseSessionFilePath = (filePath) => {
|
|
3116
|
+
const agentMatch = filePath.match(agentFileRegExp);
|
|
3117
|
+
const agentGroups = agentFileGroupSchema.safeParse(agentMatch?.groups);
|
|
3118
|
+
if (agentGroups.success) {
|
|
3119
|
+
return {
|
|
3120
|
+
type: "agent",
|
|
3121
|
+
projectId: agentGroups.data.projectId,
|
|
3122
|
+
agentSessionId: agentGroups.data.agentSessionId
|
|
3123
|
+
};
|
|
3124
|
+
}
|
|
3125
|
+
const sessionMatch = filePath.match(sessionFileRegExp);
|
|
3126
|
+
const sessionGroups = sessionFileGroupSchema.safeParse(sessionMatch?.groups);
|
|
3127
|
+
if (sessionGroups.success) {
|
|
3128
|
+
return {
|
|
3129
|
+
type: "session",
|
|
3130
|
+
projectId: sessionGroups.data.projectId,
|
|
3131
|
+
sessionId: sessionGroups.data.sessionId
|
|
3132
|
+
};
|
|
3133
|
+
}
|
|
3134
|
+
return null;
|
|
3135
|
+
};
|
|
3136
|
+
|
|
3137
|
+
// src/server/core/events/services/fileWatcher.ts
|
|
3138
|
+
var FileWatcherService = class extends Context22.Tag("FileWatcherService")() {
|
|
2989
3139
|
static {
|
|
2990
|
-
this.Live =
|
|
3140
|
+
this.Live = Layer24.effect(
|
|
2991
3141
|
this,
|
|
2992
|
-
|
|
2993
|
-
const path = yield*
|
|
3142
|
+
Effect26.gen(function* () {
|
|
3143
|
+
const path = yield* Path10.Path;
|
|
2994
3144
|
const eventBus = yield* EventBus;
|
|
2995
3145
|
const context = yield* ApplicationContext;
|
|
2996
3146
|
const isWatchingRef = yield* Ref9.make(false);
|
|
@@ -2999,11 +3149,11 @@ var FileWatcherService = class extends Context20.Tag("FileWatcherService")() {
|
|
|
2999
3149
|
/* @__PURE__ */ new Map()
|
|
3000
3150
|
);
|
|
3001
3151
|
const debounceTimersRef = yield* Ref9.make(/* @__PURE__ */ new Map());
|
|
3002
|
-
const startWatching = () =>
|
|
3152
|
+
const startWatching = () => Effect26.gen(function* () {
|
|
3003
3153
|
const isWatching = yield* Ref9.get(isWatchingRef);
|
|
3004
3154
|
if (isWatching) return;
|
|
3005
3155
|
yield* Ref9.set(isWatchingRef, true);
|
|
3006
|
-
yield*
|
|
3156
|
+
yield* Effect26.tryPromise({
|
|
3007
3157
|
try: async () => {
|
|
3008
3158
|
console.log(
|
|
3009
3159
|
"Starting file watcher on:",
|
|
@@ -3014,38 +3164,44 @@ var FileWatcherService = class extends Context20.Tag("FileWatcherService")() {
|
|
|
3014
3164
|
{ persistent: false, recursive: true },
|
|
3015
3165
|
(_eventType, filename) => {
|
|
3016
3166
|
if (!filename) return;
|
|
3017
|
-
const
|
|
3018
|
-
|
|
3019
|
-
);
|
|
3020
|
-
if (!groups.success) return;
|
|
3021
|
-
const { sessionId } = groups.data;
|
|
3167
|
+
const fileMatch = parseSessionFilePath(filename);
|
|
3168
|
+
if (fileMatch === null) return;
|
|
3022
3169
|
const fullPath = path.join(
|
|
3023
3170
|
context.claudeCodePaths.claudeProjectsDirPath,
|
|
3024
3171
|
filename
|
|
3025
3172
|
);
|
|
3026
3173
|
const encodedProjectId = encodeProjectIdFromSessionFilePath(fullPath);
|
|
3027
|
-
const debounceKey = `${encodedProjectId}/${sessionId}`;
|
|
3028
|
-
|
|
3029
|
-
|
|
3174
|
+
const debounceKey = fileMatch.type === "agent" ? `${encodedProjectId}/agent-${fileMatch.agentSessionId}` : `${encodedProjectId}/${fileMatch.sessionId}`;
|
|
3175
|
+
Effect26.runPromise(
|
|
3176
|
+
Effect26.gen(function* () {
|
|
3030
3177
|
const timers = yield* Ref9.get(debounceTimersRef);
|
|
3031
3178
|
const existingTimer = timers.get(debounceKey);
|
|
3032
3179
|
if (existingTimer) {
|
|
3033
3180
|
clearTimeout(existingTimer);
|
|
3034
3181
|
}
|
|
3035
3182
|
const newTimer = setTimeout(() => {
|
|
3036
|
-
|
|
3037
|
-
|
|
3038
|
-
|
|
3039
|
-
|
|
3040
|
-
|
|
3041
|
-
|
|
3042
|
-
|
|
3043
|
-
|
|
3044
|
-
|
|
3045
|
-
|
|
3046
|
-
|
|
3047
|
-
|
|
3048
|
-
|
|
3183
|
+
if (fileMatch.type === "agent") {
|
|
3184
|
+
Effect26.runFork(
|
|
3185
|
+
eventBus.emit("agentSessionChanged", {
|
|
3186
|
+
projectId: encodedProjectId,
|
|
3187
|
+
agentSessionId: fileMatch.agentSessionId
|
|
3188
|
+
})
|
|
3189
|
+
);
|
|
3190
|
+
} else {
|
|
3191
|
+
Effect26.runFork(
|
|
3192
|
+
eventBus.emit("sessionChanged", {
|
|
3193
|
+
projectId: encodedProjectId,
|
|
3194
|
+
sessionId: fileMatch.sessionId
|
|
3195
|
+
})
|
|
3196
|
+
);
|
|
3197
|
+
Effect26.runFork(
|
|
3198
|
+
eventBus.emit("sessionListChanged", {
|
|
3199
|
+
projectId: encodedProjectId
|
|
3200
|
+
})
|
|
3201
|
+
);
|
|
3202
|
+
}
|
|
3203
|
+
Effect26.runPromise(
|
|
3204
|
+
Effect26.gen(function* () {
|
|
3049
3205
|
const currentTimers = yield* Ref9.get(debounceTimersRef);
|
|
3050
3206
|
currentTimers.delete(debounceKey);
|
|
3051
3207
|
yield* Ref9.set(debounceTimersRef, currentTimers);
|
|
@@ -3058,7 +3214,7 @@ var FileWatcherService = class extends Context20.Tag("FileWatcherService")() {
|
|
|
3058
3214
|
);
|
|
3059
3215
|
}
|
|
3060
3216
|
);
|
|
3061
|
-
await
|
|
3217
|
+
await Effect26.runPromise(Ref9.set(watcherRef, watcher));
|
|
3062
3218
|
console.log("File watcher initialization completed");
|
|
3063
3219
|
},
|
|
3064
3220
|
catch: (error) => {
|
|
@@ -3069,10 +3225,10 @@ var FileWatcherService = class extends Context20.Tag("FileWatcherService")() {
|
|
|
3069
3225
|
}
|
|
3070
3226
|
}).pipe(
|
|
3071
3227
|
// エラーが発生しても続行する
|
|
3072
|
-
|
|
3228
|
+
Effect26.catchAll(() => Effect26.void)
|
|
3073
3229
|
);
|
|
3074
3230
|
});
|
|
3075
|
-
const stop = () =>
|
|
3231
|
+
const stop = () => Effect26.gen(function* () {
|
|
3076
3232
|
const timers = yield* Ref9.get(debounceTimersRef);
|
|
3077
3233
|
for (const [, timer] of timers) {
|
|
3078
3234
|
clearTimeout(timer);
|
|
@@ -3080,12 +3236,12 @@ var FileWatcherService = class extends Context20.Tag("FileWatcherService")() {
|
|
|
3080
3236
|
yield* Ref9.set(debounceTimersRef, /* @__PURE__ */ new Map());
|
|
3081
3237
|
const watcher = yield* Ref9.get(watcherRef);
|
|
3082
3238
|
if (watcher) {
|
|
3083
|
-
yield*
|
|
3239
|
+
yield* Effect26.sync(() => watcher.close());
|
|
3084
3240
|
yield* Ref9.set(watcherRef, null);
|
|
3085
3241
|
}
|
|
3086
3242
|
const projectWatchers = yield* Ref9.get(projectWatchersRef);
|
|
3087
3243
|
for (const [, projectWatcher] of projectWatchers) {
|
|
3088
|
-
yield*
|
|
3244
|
+
yield* Effect26.sync(() => projectWatcher.close());
|
|
3089
3245
|
}
|
|
3090
3246
|
yield* Ref9.set(projectWatchersRef, /* @__PURE__ */ new Map());
|
|
3091
3247
|
yield* Ref9.set(isWatchingRef, false);
|
|
@@ -3100,10 +3256,10 @@ var FileWatcherService = class extends Context20.Tag("FileWatcherService")() {
|
|
|
3100
3256
|
};
|
|
3101
3257
|
|
|
3102
3258
|
// src/server/core/feature-flag/presentation/FeatureFlagController.ts
|
|
3103
|
-
import { Context as
|
|
3104
|
-
var
|
|
3259
|
+
import { Context as Context23, Effect as Effect27, Layer as Layer25 } from "effect";
|
|
3260
|
+
var LayerImpl18 = Effect27.gen(function* () {
|
|
3105
3261
|
const claudeCodeService = yield* ClaudeCodeService;
|
|
3106
|
-
const getFlags = () =>
|
|
3262
|
+
const getFlags = () => Effect27.gen(function* () {
|
|
3107
3263
|
const claudeCodeFeatures = yield* claudeCodeService.getAvailableFeatures();
|
|
3108
3264
|
return {
|
|
3109
3265
|
response: {
|
|
@@ -3115,6 +3271,10 @@ var LayerImpl16 = Effect24.gen(function* () {
|
|
|
3115
3271
|
{
|
|
3116
3272
|
name: "agent-sdk",
|
|
3117
3273
|
enabled: claudeCodeFeatures.agentSdk
|
|
3274
|
+
},
|
|
3275
|
+
{
|
|
3276
|
+
name: "sidechain-separation",
|
|
3277
|
+
enabled: claudeCodeFeatures.sidechainSeparation
|
|
3118
3278
|
}
|
|
3119
3279
|
]
|
|
3120
3280
|
},
|
|
@@ -3125,15 +3285,15 @@ var LayerImpl16 = Effect24.gen(function* () {
|
|
|
3125
3285
|
getFlags
|
|
3126
3286
|
};
|
|
3127
3287
|
});
|
|
3128
|
-
var FeatureFlagController = class extends
|
|
3288
|
+
var FeatureFlagController = class extends Context23.Tag("FeatureFlagController")() {
|
|
3129
3289
|
static {
|
|
3130
|
-
this.Live =
|
|
3290
|
+
this.Live = Layer25.effect(this, LayerImpl18);
|
|
3131
3291
|
}
|
|
3132
3292
|
};
|
|
3133
3293
|
|
|
3134
3294
|
// src/server/core/file-system/presentation/FileSystemController.ts
|
|
3135
3295
|
import { homedir as homedir3 } from "node:os";
|
|
3136
|
-
import { Context as
|
|
3296
|
+
import { Context as Context24, Effect as Effect28, Layer as Layer26 } from "effect";
|
|
3137
3297
|
|
|
3138
3298
|
// src/server/core/file-system/functions/getDirectoryListing.ts
|
|
3139
3299
|
import { existsSync } from "node:fs";
|
|
@@ -3266,9 +3426,9 @@ var getFileCompletion = async (projectPath, basePath = "/") => {
|
|
|
3266
3426
|
};
|
|
3267
3427
|
|
|
3268
3428
|
// src/server/core/file-system/presentation/FileSystemController.ts
|
|
3269
|
-
var
|
|
3429
|
+
var LayerImpl19 = Effect28.gen(function* () {
|
|
3270
3430
|
const projectRepository = yield* ProjectRepository;
|
|
3271
|
-
const getFileCompletionRoute = (options) =>
|
|
3431
|
+
const getFileCompletionRoute = (options) => Effect28.gen(function* () {
|
|
3272
3432
|
const { projectId, basePath } = options;
|
|
3273
3433
|
const { project } = yield* projectRepository.getProject(projectId);
|
|
3274
3434
|
if (project.meta.projectPath === null) {
|
|
@@ -3279,7 +3439,7 @@ var LayerImpl17 = Effect25.gen(function* () {
|
|
|
3279
3439
|
}
|
|
3280
3440
|
const projectPath = project.meta.projectPath;
|
|
3281
3441
|
try {
|
|
3282
|
-
const result = yield*
|
|
3442
|
+
const result = yield* Effect28.promise(
|
|
3283
3443
|
() => getFileCompletion(projectPath, basePath)
|
|
3284
3444
|
);
|
|
3285
3445
|
return {
|
|
@@ -3294,7 +3454,7 @@ var LayerImpl17 = Effect25.gen(function* () {
|
|
|
3294
3454
|
};
|
|
3295
3455
|
}
|
|
3296
3456
|
});
|
|
3297
|
-
const getDirectoryListingRoute = (options) =>
|
|
3457
|
+
const getDirectoryListingRoute = (options) => Effect28.promise(async () => {
|
|
3298
3458
|
const { currentPath, showHidden = false } = options;
|
|
3299
3459
|
const rootPath = "/";
|
|
3300
3460
|
const defaultPath = homedir3();
|
|
@@ -3323,14 +3483,14 @@ var LayerImpl17 = Effect25.gen(function* () {
|
|
|
3323
3483
|
getDirectoryListingRoute
|
|
3324
3484
|
};
|
|
3325
3485
|
});
|
|
3326
|
-
var FileSystemController = class extends
|
|
3486
|
+
var FileSystemController = class extends Context24.Tag("FileSystemController")() {
|
|
3327
3487
|
static {
|
|
3328
|
-
this.Live =
|
|
3488
|
+
this.Live = Layer26.effect(this, LayerImpl19);
|
|
3329
3489
|
}
|
|
3330
3490
|
};
|
|
3331
3491
|
|
|
3332
3492
|
// src/server/core/git/presentation/GitController.ts
|
|
3333
|
-
import { Context as
|
|
3493
|
+
import { Context as Context26, Effect as Effect30, Either as Either2, Layer as Layer28 } from "effect";
|
|
3334
3494
|
|
|
3335
3495
|
// src/server/core/git/functions/getDiff.ts
|
|
3336
3496
|
import { readFile } from "node:fs/promises";
|
|
@@ -3669,8 +3829,8 @@ var getDiff = async (cwd, fromRefText, toRefText) => {
|
|
|
3669
3829
|
};
|
|
3670
3830
|
|
|
3671
3831
|
// src/server/core/git/services/GitService.ts
|
|
3672
|
-
import { Command as Command2, FileSystem as
|
|
3673
|
-
import { Context as
|
|
3832
|
+
import { Command as Command2, FileSystem as FileSystem9, Path as Path11 } from "@effect/platform";
|
|
3833
|
+
import { Context as Context25, Data as Data4, Duration, Effect as Effect29, Either, Layer as Layer27 } from "effect";
|
|
3674
3834
|
|
|
3675
3835
|
// src/server/core/git/functions/parseGitBranchesOutput.ts
|
|
3676
3836
|
var parseGitBranchesOutput = (output) => {
|
|
@@ -3747,14 +3907,14 @@ var GitCommandError = class extends Data4.TaggedError("GitCommandError") {
|
|
|
3747
3907
|
};
|
|
3748
3908
|
var DetachedHeadError = class extends Data4.TaggedError("DetachedHeadError") {
|
|
3749
3909
|
};
|
|
3750
|
-
var
|
|
3751
|
-
const fs = yield*
|
|
3752
|
-
const path = yield*
|
|
3910
|
+
var LayerImpl20 = Effect29.gen(function* () {
|
|
3911
|
+
const fs = yield* FileSystem9.FileSystem;
|
|
3912
|
+
const path = yield* Path11.Path;
|
|
3753
3913
|
const envService = yield* EnvService;
|
|
3754
|
-
const execGitCommand = (args, cwd) =>
|
|
3914
|
+
const execGitCommand = (args, cwd) => Effect29.gen(function* () {
|
|
3755
3915
|
const absoluteCwd = path.resolve(cwd);
|
|
3756
3916
|
if (!(yield* fs.exists(absoluteCwd))) {
|
|
3757
|
-
return yield*
|
|
3917
|
+
return yield* Effect29.fail(
|
|
3758
3918
|
new NotARepositoryError({ cwd: absoluteCwd })
|
|
3759
3919
|
);
|
|
3760
3920
|
}
|
|
@@ -3764,9 +3924,9 @@ var LayerImpl18 = Effect26.gen(function* () {
|
|
|
3764
3924
|
PATH: yield* envService.getEnv("PATH")
|
|
3765
3925
|
})
|
|
3766
3926
|
);
|
|
3767
|
-
const result = yield*
|
|
3927
|
+
const result = yield* Effect29.either(Command2.string(command));
|
|
3768
3928
|
if (Either.isLeft(result)) {
|
|
3769
|
-
return yield*
|
|
3929
|
+
return yield* Effect29.fail(
|
|
3770
3930
|
new GitCommandError({
|
|
3771
3931
|
cwd: absoluteCwd,
|
|
3772
3932
|
command: `git ${args.join(" ")}`
|
|
@@ -3775,22 +3935,22 @@ var LayerImpl18 = Effect26.gen(function* () {
|
|
|
3775
3935
|
}
|
|
3776
3936
|
return result.right;
|
|
3777
3937
|
});
|
|
3778
|
-
const getBranches = (cwd) =>
|
|
3938
|
+
const getBranches = (cwd) => Effect29.gen(function* () {
|
|
3779
3939
|
const result = yield* execGitCommand(["branch", "-vv", "--all"], cwd);
|
|
3780
3940
|
return parseGitBranchesOutput(result);
|
|
3781
3941
|
});
|
|
3782
|
-
const getCurrentBranch = (cwd) =>
|
|
3942
|
+
const getCurrentBranch = (cwd) => Effect29.gen(function* () {
|
|
3783
3943
|
const currentBranch = yield* execGitCommand(
|
|
3784
3944
|
["branch", "--show-current"],
|
|
3785
3945
|
cwd
|
|
3786
|
-
).pipe(
|
|
3946
|
+
).pipe(Effect29.map((result) => result.trim()));
|
|
3787
3947
|
if (currentBranch === "") {
|
|
3788
|
-
return yield*
|
|
3948
|
+
return yield* Effect29.fail(new DetachedHeadError({ cwd }));
|
|
3789
3949
|
}
|
|
3790
3950
|
return currentBranch;
|
|
3791
3951
|
});
|
|
3792
|
-
const branchExists = (cwd, branchName) =>
|
|
3793
|
-
const result = yield*
|
|
3952
|
+
const branchExists = (cwd, branchName) => Effect29.gen(function* () {
|
|
3953
|
+
const result = yield* Effect29.either(
|
|
3794
3954
|
execGitCommand(["branch", "--exists", branchName], cwd)
|
|
3795
3955
|
);
|
|
3796
3956
|
if (Either.isLeft(result)) {
|
|
@@ -3798,7 +3958,7 @@ var LayerImpl18 = Effect26.gen(function* () {
|
|
|
3798
3958
|
}
|
|
3799
3959
|
return true;
|
|
3800
3960
|
});
|
|
3801
|
-
const getCommits = (cwd) =>
|
|
3961
|
+
const getCommits = (cwd) => Effect29.gen(function* () {
|
|
3802
3962
|
const result = yield* execGitCommand(
|
|
3803
3963
|
[
|
|
3804
3964
|
"log",
|
|
@@ -3812,9 +3972,9 @@ var LayerImpl18 = Effect26.gen(function* () {
|
|
|
3812
3972
|
);
|
|
3813
3973
|
return parseGitCommitsOutput(result);
|
|
3814
3974
|
});
|
|
3815
|
-
const stageFiles = (cwd, files) =>
|
|
3975
|
+
const stageFiles = (cwd, files) => Effect29.gen(function* () {
|
|
3816
3976
|
if (files.length === 0) {
|
|
3817
|
-
return yield*
|
|
3977
|
+
return yield* Effect29.fail(
|
|
3818
3978
|
new GitCommandError({
|
|
3819
3979
|
cwd,
|
|
3820
3980
|
command: "git add (no files)"
|
|
@@ -3824,10 +3984,10 @@ var LayerImpl18 = Effect26.gen(function* () {
|
|
|
3824
3984
|
const result = yield* execGitCommand(["add", ...files], cwd);
|
|
3825
3985
|
return result;
|
|
3826
3986
|
});
|
|
3827
|
-
const commit = (cwd, message) =>
|
|
3987
|
+
const commit = (cwd, message) => Effect29.gen(function* () {
|
|
3828
3988
|
const trimmedMessage = message.trim();
|
|
3829
3989
|
if (trimmedMessage.length === 0) {
|
|
3830
|
-
return yield*
|
|
3990
|
+
return yield* Effect29.fail(
|
|
3831
3991
|
new GitCommandError({
|
|
3832
3992
|
cwd,
|
|
3833
3993
|
command: "git commit (empty message)"
|
|
@@ -3864,7 +4024,7 @@ var LayerImpl18 = Effect26.gen(function* () {
|
|
|
3864
4024
|
);
|
|
3865
4025
|
return sha.trim();
|
|
3866
4026
|
});
|
|
3867
|
-
const push = (cwd) =>
|
|
4027
|
+
const push = (cwd) => Effect29.gen(function* () {
|
|
3868
4028
|
const branch = yield* getCurrentBranch(cwd);
|
|
3869
4029
|
const absoluteCwd = path.resolve(cwd);
|
|
3870
4030
|
const command = Command2.make("git", "push", "origin", "HEAD").pipe(
|
|
@@ -3873,12 +4033,12 @@ var LayerImpl18 = Effect26.gen(function* () {
|
|
|
3873
4033
|
PATH: yield* envService.getEnv("PATH")
|
|
3874
4034
|
})
|
|
3875
4035
|
);
|
|
3876
|
-
const exitCodeResult = yield*
|
|
3877
|
-
Command2.exitCode(command).pipe(
|
|
4036
|
+
const exitCodeResult = yield* Effect29.either(
|
|
4037
|
+
Command2.exitCode(command).pipe(Effect29.timeout(Duration.seconds(60)))
|
|
3878
4038
|
);
|
|
3879
4039
|
if (Either.isLeft(exitCodeResult)) {
|
|
3880
4040
|
console.log("[GitService.push] Command failed or timeout");
|
|
3881
|
-
return yield*
|
|
4041
|
+
return yield* Effect29.fail(
|
|
3882
4042
|
new GitCommandError({
|
|
3883
4043
|
cwd: absoluteCwd,
|
|
3884
4044
|
command: "git push origin HEAD (timeout after 60s)"
|
|
@@ -3896,10 +4056,10 @@ var LayerImpl18 = Effect26.gen(function* () {
|
|
|
3896
4056
|
}),
|
|
3897
4057
|
Command2.stderr("inherit")
|
|
3898
4058
|
)
|
|
3899
|
-
).pipe(
|
|
4059
|
+
).pipe(Effect29.orElse(() => Effect29.succeed([])));
|
|
3900
4060
|
const stderr = Array.from(stderrLines).join("\n");
|
|
3901
4061
|
console.log("[GitService.push] Failed with stderr:", stderr);
|
|
3902
|
-
return yield*
|
|
4062
|
+
return yield* Effect29.fail(
|
|
3903
4063
|
new GitCommandError({
|
|
3904
4064
|
cwd: absoluteCwd,
|
|
3905
4065
|
command: `git push origin HEAD - ${stderr}`
|
|
@@ -3909,20 +4069,20 @@ var LayerImpl18 = Effect26.gen(function* () {
|
|
|
3909
4069
|
console.log("[GitService.push] Push succeeded");
|
|
3910
4070
|
return { branch, output: "success" };
|
|
3911
4071
|
});
|
|
3912
|
-
const getBranchHash = (cwd, branchName) =>
|
|
4072
|
+
const getBranchHash = (cwd, branchName) => Effect29.gen(function* () {
|
|
3913
4073
|
const result = yield* execGitCommand(["rev-parse", branchName], cwd).pipe(
|
|
3914
|
-
|
|
4074
|
+
Effect29.map((output) => output.trim().split("\n")[0] ?? null)
|
|
3915
4075
|
);
|
|
3916
4076
|
return result;
|
|
3917
4077
|
});
|
|
3918
|
-
const getBranchNamesByCommitHash = (cwd, hash) =>
|
|
4078
|
+
const getBranchNamesByCommitHash = (cwd, hash) => Effect29.gen(function* () {
|
|
3919
4079
|
const result = yield* execGitCommand(
|
|
3920
4080
|
["branch", "--contains", hash, "--format=%(refname:short)"],
|
|
3921
4081
|
cwd
|
|
3922
4082
|
);
|
|
3923
4083
|
return result.split("\n").map((line) => line.trim()).filter((line) => line !== "");
|
|
3924
4084
|
});
|
|
3925
|
-
const compareCommitHash = (cwd, targetHash, compareHash) =>
|
|
4085
|
+
const compareCommitHash = (cwd, targetHash, compareHash) => Effect29.gen(function* () {
|
|
3926
4086
|
const aheadResult = yield* execGitCommand(
|
|
3927
4087
|
["rev-list", `${targetHash}..${compareHash}`],
|
|
3928
4088
|
cwd
|
|
@@ -3944,7 +4104,7 @@ var LayerImpl18 = Effect26.gen(function* () {
|
|
|
3944
4104
|
}
|
|
3945
4105
|
return "un-related";
|
|
3946
4106
|
});
|
|
3947
|
-
const getCommitsWithParent = (cwd, options) =>
|
|
4107
|
+
const getCommitsWithParent = (cwd, options) => Effect29.gen(function* () {
|
|
3948
4108
|
const { offset, limit } = options;
|
|
3949
4109
|
const result = yield* execGitCommand(
|
|
3950
4110
|
[
|
|
@@ -3971,7 +4131,7 @@ var LayerImpl18 = Effect26.gen(function* () {
|
|
|
3971
4131
|
}
|
|
3972
4132
|
return commits;
|
|
3973
4133
|
});
|
|
3974
|
-
const findBaseBranch = (cwd, targetBranch) =>
|
|
4134
|
+
const findBaseBranch = (cwd, targetBranch) => Effect29.gen(function* () {
|
|
3975
4135
|
let offset = 0;
|
|
3976
4136
|
const limit = 20;
|
|
3977
4137
|
while (offset < 100) {
|
|
@@ -4005,7 +4165,7 @@ var LayerImpl18 = Effect26.gen(function* () {
|
|
|
4005
4165
|
}
|
|
4006
4166
|
return null;
|
|
4007
4167
|
});
|
|
4008
|
-
const getCommitsBetweenBranches = (cwd, baseBranch, targetBranch) =>
|
|
4168
|
+
const getCommitsBetweenBranches = (cwd, baseBranch, targetBranch) => Effect29.gen(function* () {
|
|
4009
4169
|
const result = yield* execGitCommand(
|
|
4010
4170
|
[
|
|
4011
4171
|
"log",
|
|
@@ -4033,17 +4193,17 @@ var LayerImpl18 = Effect26.gen(function* () {
|
|
|
4033
4193
|
getCommitsBetweenBranches
|
|
4034
4194
|
};
|
|
4035
4195
|
});
|
|
4036
|
-
var GitService = class extends
|
|
4196
|
+
var GitService = class extends Context25.Tag("GitService")() {
|
|
4037
4197
|
static {
|
|
4038
|
-
this.Live =
|
|
4198
|
+
this.Live = Layer27.effect(this, LayerImpl20);
|
|
4039
4199
|
}
|
|
4040
4200
|
};
|
|
4041
4201
|
|
|
4042
4202
|
// src/server/core/git/presentation/GitController.ts
|
|
4043
|
-
var
|
|
4203
|
+
var LayerImpl21 = Effect30.gen(function* () {
|
|
4044
4204
|
const gitService = yield* GitService;
|
|
4045
4205
|
const projectRepository = yield* ProjectRepository;
|
|
4046
|
-
const getGitDiff = (options) =>
|
|
4206
|
+
const getGitDiff = (options) => Effect30.gen(function* () {
|
|
4047
4207
|
const { projectId, fromRef, toRef } = options;
|
|
4048
4208
|
const { project } = yield* projectRepository.getProject(projectId);
|
|
4049
4209
|
try {
|
|
@@ -4054,7 +4214,7 @@ var LayerImpl19 = Effect27.gen(function* () {
|
|
|
4054
4214
|
};
|
|
4055
4215
|
}
|
|
4056
4216
|
const projectPath = project.meta.projectPath;
|
|
4057
|
-
const result = yield*
|
|
4217
|
+
const result = yield* Effect30.promise(
|
|
4058
4218
|
() => getDiff(projectPath, fromRef, toRef)
|
|
4059
4219
|
);
|
|
4060
4220
|
return {
|
|
@@ -4075,7 +4235,7 @@ var LayerImpl19 = Effect27.gen(function* () {
|
|
|
4075
4235
|
};
|
|
4076
4236
|
}
|
|
4077
4237
|
});
|
|
4078
|
-
const commitFiles = (options) =>
|
|
4238
|
+
const commitFiles = (options) => Effect30.gen(function* () {
|
|
4079
4239
|
const { projectId, files, message } = options;
|
|
4080
4240
|
const { project } = yield* projectRepository.getProject(projectId);
|
|
4081
4241
|
if (project.meta.projectPath === null) {
|
|
@@ -4088,7 +4248,7 @@ var LayerImpl19 = Effect27.gen(function* () {
|
|
|
4088
4248
|
const projectPath = project.meta.projectPath;
|
|
4089
4249
|
console.log("[GitController.commitFiles] Project path:", projectPath);
|
|
4090
4250
|
console.log("[GitController.commitFiles] Staging files...");
|
|
4091
|
-
const stageResult = yield*
|
|
4251
|
+
const stageResult = yield* Effect30.either(
|
|
4092
4252
|
gitService.stageFiles(projectPath, files)
|
|
4093
4253
|
);
|
|
4094
4254
|
if (Either2.isLeft(stageResult)) {
|
|
@@ -4108,7 +4268,7 @@ var LayerImpl19 = Effect27.gen(function* () {
|
|
|
4108
4268
|
}
|
|
4109
4269
|
console.log("[GitController.commitFiles] Stage succeeded");
|
|
4110
4270
|
console.log("[GitController.commitFiles] Committing...");
|
|
4111
|
-
const commitResult = yield*
|
|
4271
|
+
const commitResult = yield* Effect30.either(
|
|
4112
4272
|
gitService.commit(projectPath, message)
|
|
4113
4273
|
);
|
|
4114
4274
|
if (Either2.isLeft(commitResult)) {
|
|
@@ -4143,7 +4303,7 @@ var LayerImpl19 = Effect27.gen(function* () {
|
|
|
4143
4303
|
status: 200
|
|
4144
4304
|
};
|
|
4145
4305
|
});
|
|
4146
|
-
const pushCommits = (options) =>
|
|
4306
|
+
const pushCommits = (options) => Effect30.gen(function* () {
|
|
4147
4307
|
const { projectId } = options;
|
|
4148
4308
|
console.log("[GitController.pushCommits] Request:", { projectId });
|
|
4149
4309
|
const { project } = yield* projectRepository.getProject(projectId);
|
|
@@ -4157,7 +4317,7 @@ var LayerImpl19 = Effect27.gen(function* () {
|
|
|
4157
4317
|
const projectPath = project.meta.projectPath;
|
|
4158
4318
|
console.log("[GitController.pushCommits] Project path:", projectPath);
|
|
4159
4319
|
console.log("[GitController.pushCommits] Pushing...");
|
|
4160
|
-
const pushResult = yield*
|
|
4320
|
+
const pushResult = yield* Effect30.either(gitService.push(projectPath));
|
|
4161
4321
|
if (Either2.isLeft(pushResult)) {
|
|
4162
4322
|
console.log(
|
|
4163
4323
|
"[GitController.pushCommits] Push failed:",
|
|
@@ -4186,7 +4346,7 @@ var LayerImpl19 = Effect27.gen(function* () {
|
|
|
4186
4346
|
status: 200
|
|
4187
4347
|
};
|
|
4188
4348
|
});
|
|
4189
|
-
const commitAndPush = (options) =>
|
|
4349
|
+
const commitAndPush = (options) => Effect30.gen(function* () {
|
|
4190
4350
|
const { projectId, files, message } = options;
|
|
4191
4351
|
console.log("[GitController.commitAndPush] Request:", {
|
|
4192
4352
|
projectId,
|
|
@@ -4237,7 +4397,7 @@ var LayerImpl19 = Effect27.gen(function* () {
|
|
|
4237
4397
|
status: 200
|
|
4238
4398
|
};
|
|
4239
4399
|
});
|
|
4240
|
-
const getCurrentRevisions = (options) =>
|
|
4400
|
+
const getCurrentRevisions = (options) => Effect30.gen(function* () {
|
|
4241
4401
|
const { projectId } = options;
|
|
4242
4402
|
const { project } = yield* projectRepository.getProject(projectId);
|
|
4243
4403
|
if (project.meta.projectPath === null) {
|
|
@@ -4247,7 +4407,7 @@ var LayerImpl19 = Effect27.gen(function* () {
|
|
|
4247
4407
|
};
|
|
4248
4408
|
}
|
|
4249
4409
|
const projectPath = project.meta.projectPath;
|
|
4250
|
-
const currentBranchResult = yield*
|
|
4410
|
+
const currentBranchResult = yield* Effect30.either(
|
|
4251
4411
|
gitService.getCurrentBranch(projectPath)
|
|
4252
4412
|
);
|
|
4253
4413
|
if (Either2.isLeft(currentBranchResult)) {
|
|
@@ -4259,10 +4419,10 @@ var LayerImpl19 = Effect27.gen(function* () {
|
|
|
4259
4419
|
};
|
|
4260
4420
|
}
|
|
4261
4421
|
const currentBranch = currentBranchResult.right;
|
|
4262
|
-
const baseBranchResult = yield*
|
|
4422
|
+
const baseBranchResult = yield* Effect30.either(
|
|
4263
4423
|
gitService.findBaseBranch(projectPath, currentBranch)
|
|
4264
4424
|
);
|
|
4265
|
-
const allBranchesResult = yield*
|
|
4425
|
+
const allBranchesResult = yield* Effect30.either(
|
|
4266
4426
|
gitService.getBranches(projectPath)
|
|
4267
4427
|
);
|
|
4268
4428
|
if (Either2.isLeft(allBranchesResult)) {
|
|
@@ -4287,7 +4447,7 @@ var LayerImpl19 = Effect27.gen(function* () {
|
|
|
4287
4447
|
let commits = [];
|
|
4288
4448
|
if (Either2.isRight(baseBranchResult) && baseBranchResult.right !== null) {
|
|
4289
4449
|
const baseBranchHash = baseBranchResult.right.hash;
|
|
4290
|
-
const commitsResult = yield*
|
|
4450
|
+
const commitsResult = yield* Effect30.either(
|
|
4291
4451
|
gitService.getCommitsBetweenBranches(
|
|
4292
4452
|
projectPath,
|
|
4293
4453
|
baseBranchHash,
|
|
@@ -4350,21 +4510,21 @@ function getPushErrorMessage(code) {
|
|
|
4350
4510
|
};
|
|
4351
4511
|
return messages[code];
|
|
4352
4512
|
}
|
|
4353
|
-
var GitController = class extends
|
|
4513
|
+
var GitController = class extends Context26.Tag("GitController")() {
|
|
4354
4514
|
static {
|
|
4355
|
-
this.Live =
|
|
4515
|
+
this.Live = Layer28.effect(this, LayerImpl21);
|
|
4356
4516
|
}
|
|
4357
4517
|
};
|
|
4358
4518
|
|
|
4359
4519
|
// src/server/core/project/presentation/ProjectController.ts
|
|
4360
|
-
import { FileSystem as
|
|
4361
|
-
import { Context as
|
|
4520
|
+
import { FileSystem as FileSystem10, Path as Path13 } from "@effect/platform";
|
|
4521
|
+
import { Context as Context27, Effect as Effect32, Layer as Layer29 } from "effect";
|
|
4362
4522
|
|
|
4363
4523
|
// src/server/core/claude-code/functions/computeClaudeProjectFilePath.ts
|
|
4364
|
-
import { Path as
|
|
4365
|
-
import { Effect as
|
|
4366
|
-
var computeClaudeProjectFilePath = (options) =>
|
|
4367
|
-
const path = yield*
|
|
4524
|
+
import { Path as Path12 } from "@effect/platform";
|
|
4525
|
+
import { Effect as Effect31 } from "effect";
|
|
4526
|
+
var computeClaudeProjectFilePath = (options) => Effect31.gen(function* () {
|
|
4527
|
+
const path = yield* Path12.Path;
|
|
4368
4528
|
const { projectPath, claudeProjectsDirPath } = options;
|
|
4369
4529
|
return path.join(
|
|
4370
4530
|
claudeProjectsDirPath,
|
|
@@ -4373,22 +4533,22 @@ var computeClaudeProjectFilePath = (options) => Effect28.gen(function* () {
|
|
|
4373
4533
|
});
|
|
4374
4534
|
|
|
4375
4535
|
// src/server/core/project/presentation/ProjectController.ts
|
|
4376
|
-
var
|
|
4536
|
+
var LayerImpl22 = Effect32.gen(function* () {
|
|
4377
4537
|
const projectRepository = yield* ProjectRepository;
|
|
4378
4538
|
const claudeCodeLifeCycleService = yield* ClaudeCodeLifeCycleService;
|
|
4379
4539
|
const userConfigService = yield* UserConfigService;
|
|
4380
4540
|
const sessionRepository = yield* SessionRepository;
|
|
4381
4541
|
const context = yield* ApplicationContext;
|
|
4382
|
-
const fileSystem = yield*
|
|
4383
|
-
const path = yield*
|
|
4384
|
-
const getProjects = () =>
|
|
4542
|
+
const fileSystem = yield* FileSystem10.FileSystem;
|
|
4543
|
+
const path = yield* Path13.Path;
|
|
4544
|
+
const getProjects = () => Effect32.gen(function* () {
|
|
4385
4545
|
const { projects } = yield* projectRepository.getProjects();
|
|
4386
4546
|
return {
|
|
4387
4547
|
status: 200,
|
|
4388
4548
|
response: { projects }
|
|
4389
4549
|
};
|
|
4390
4550
|
});
|
|
4391
|
-
const getProject = (options) =>
|
|
4551
|
+
const getProject = (options) => Effect32.gen(function* () {
|
|
4392
4552
|
const { projectId, cursor } = options;
|
|
4393
4553
|
const userConfig = yield* userConfigService.getUserConfig();
|
|
4394
4554
|
const { project } = yield* projectRepository.getProject(projectId);
|
|
@@ -4442,7 +4602,7 @@ var LayerImpl20 = Effect29.gen(function* () {
|
|
|
4442
4602
|
}
|
|
4443
4603
|
};
|
|
4444
4604
|
});
|
|
4445
|
-
const getProjectLatestSession = (options) =>
|
|
4605
|
+
const getProjectLatestSession = (options) => Effect32.gen(function* () {
|
|
4446
4606
|
const { projectId } = options;
|
|
4447
4607
|
const { sessions } = yield* sessionRepository.getSessions(projectId, {
|
|
4448
4608
|
maxCount: 1
|
|
@@ -4454,7 +4614,7 @@ var LayerImpl20 = Effect29.gen(function* () {
|
|
|
4454
4614
|
}
|
|
4455
4615
|
};
|
|
4456
4616
|
});
|
|
4457
|
-
const createProject = (options) =>
|
|
4617
|
+
const createProject = (options) => Effect32.gen(function* () {
|
|
4458
4618
|
const { projectPath } = options;
|
|
4459
4619
|
const claudeProjectFilePath = yield* computeClaudeProjectFilePath({
|
|
4460
4620
|
projectPath,
|
|
@@ -4491,16 +4651,16 @@ var LayerImpl20 = Effect29.gen(function* () {
|
|
|
4491
4651
|
createProject
|
|
4492
4652
|
};
|
|
4493
4653
|
});
|
|
4494
|
-
var ProjectController = class extends
|
|
4654
|
+
var ProjectController = class extends Context27.Tag("ProjectController")() {
|
|
4495
4655
|
static {
|
|
4496
|
-
this.Live =
|
|
4656
|
+
this.Live = Layer29.effect(this, LayerImpl22);
|
|
4497
4657
|
}
|
|
4498
4658
|
};
|
|
4499
4659
|
|
|
4500
4660
|
// src/server/core/scheduler/config.ts
|
|
4501
4661
|
import { homedir as homedir4 } from "node:os";
|
|
4502
|
-
import { FileSystem as
|
|
4503
|
-
import { Context as
|
|
4662
|
+
import { FileSystem as FileSystem11, Path as Path14 } from "@effect/platform";
|
|
4663
|
+
import { Context as Context28, Data as Data5, Effect as Effect33, Layer as Layer30 } from "effect";
|
|
4504
4664
|
|
|
4505
4665
|
// src/server/core/scheduler/schema.ts
|
|
4506
4666
|
import { z as z23 } from "zod";
|
|
@@ -4561,29 +4721,29 @@ var ConfigParseError = class extends Data5.TaggedError("ConfigParseError") {
|
|
|
4561
4721
|
};
|
|
4562
4722
|
var CONFIG_DIR = "scheduler";
|
|
4563
4723
|
var CONFIG_FILE = "schedules.json";
|
|
4564
|
-
var SchedulerConfigBaseDir = class extends
|
|
4724
|
+
var SchedulerConfigBaseDir = class extends Context28.Tag(
|
|
4565
4725
|
"SchedulerConfigBaseDir"
|
|
4566
4726
|
)() {
|
|
4567
4727
|
static {
|
|
4568
|
-
this.Live =
|
|
4728
|
+
this.Live = Layer30.succeed(this, `${homedir4()}/.claude-code-viewer`);
|
|
4569
4729
|
}
|
|
4570
4730
|
};
|
|
4571
|
-
var getConfigPath =
|
|
4572
|
-
const path = yield*
|
|
4731
|
+
var getConfigPath = Effect33.gen(function* () {
|
|
4732
|
+
const path = yield* Path14.Path;
|
|
4573
4733
|
const baseDir = yield* SchedulerConfigBaseDir;
|
|
4574
4734
|
return path.join(baseDir, CONFIG_DIR, CONFIG_FILE);
|
|
4575
4735
|
});
|
|
4576
|
-
var readConfig =
|
|
4577
|
-
const fs = yield*
|
|
4736
|
+
var readConfig = Effect33.gen(function* () {
|
|
4737
|
+
const fs = yield* FileSystem11.FileSystem;
|
|
4578
4738
|
const configPath = yield* getConfigPath;
|
|
4579
4739
|
const exists = yield* fs.exists(configPath);
|
|
4580
4740
|
if (!exists) {
|
|
4581
|
-
return yield*
|
|
4741
|
+
return yield* Effect33.fail(
|
|
4582
4742
|
new ConfigFileNotFoundError({ path: configPath })
|
|
4583
4743
|
);
|
|
4584
4744
|
}
|
|
4585
4745
|
const content = yield* fs.readFileString(configPath);
|
|
4586
|
-
const jsonResult = yield*
|
|
4746
|
+
const jsonResult = yield* Effect33.try({
|
|
4587
4747
|
try: () => JSON.parse(content),
|
|
4588
4748
|
catch: (error) => new ConfigParseError({
|
|
4589
4749
|
path: configPath,
|
|
@@ -4592,7 +4752,7 @@ var readConfig = Effect30.gen(function* () {
|
|
|
4592
4752
|
});
|
|
4593
4753
|
const parsed = schedulerConfigSchema.safeParse(jsonResult);
|
|
4594
4754
|
if (!parsed.success) {
|
|
4595
|
-
return yield*
|
|
4755
|
+
return yield* Effect33.fail(
|
|
4596
4756
|
new ConfigParseError({
|
|
4597
4757
|
path: configPath,
|
|
4598
4758
|
cause: parsed.error
|
|
@@ -4601,24 +4761,24 @@ var readConfig = Effect30.gen(function* () {
|
|
|
4601
4761
|
}
|
|
4602
4762
|
return parsed.data;
|
|
4603
4763
|
});
|
|
4604
|
-
var writeConfig = (config) =>
|
|
4605
|
-
const fs = yield*
|
|
4606
|
-
const path = yield*
|
|
4764
|
+
var writeConfig = (config) => Effect33.gen(function* () {
|
|
4765
|
+
const fs = yield* FileSystem11.FileSystem;
|
|
4766
|
+
const path = yield* Path14.Path;
|
|
4607
4767
|
const configPath = yield* getConfigPath;
|
|
4608
4768
|
const configDir = path.dirname(configPath);
|
|
4609
4769
|
yield* fs.makeDirectory(configDir, { recursive: true });
|
|
4610
4770
|
const content = JSON.stringify(config, null, 2);
|
|
4611
4771
|
yield* fs.writeFileString(configPath, content);
|
|
4612
4772
|
});
|
|
4613
|
-
var initializeConfig =
|
|
4773
|
+
var initializeConfig = Effect33.gen(function* () {
|
|
4614
4774
|
const result = yield* readConfig.pipe(
|
|
4615
|
-
|
|
4616
|
-
ConfigFileNotFoundError: () =>
|
|
4775
|
+
Effect33.catchTags({
|
|
4776
|
+
ConfigFileNotFoundError: () => Effect33.gen(function* () {
|
|
4617
4777
|
const initialConfig = { jobs: [] };
|
|
4618
4778
|
yield* writeConfig(initialConfig);
|
|
4619
4779
|
return initialConfig;
|
|
4620
4780
|
}),
|
|
4621
|
-
ConfigParseError: () =>
|
|
4781
|
+
ConfigParseError: () => Effect33.gen(function* () {
|
|
4622
4782
|
const initialConfig = { jobs: [] };
|
|
4623
4783
|
yield* writeConfig(initialConfig);
|
|
4624
4784
|
return initialConfig;
|
|
@@ -4630,21 +4790,21 @@ var initializeConfig = Effect30.gen(function* () {
|
|
|
4630
4790
|
|
|
4631
4791
|
// src/server/core/scheduler/domain/Scheduler.ts
|
|
4632
4792
|
import {
|
|
4633
|
-
Context as
|
|
4793
|
+
Context as Context29,
|
|
4634
4794
|
Cron,
|
|
4635
4795
|
Data as Data6,
|
|
4636
4796
|
Duration as Duration2,
|
|
4637
|
-
Effect as
|
|
4797
|
+
Effect as Effect35,
|
|
4638
4798
|
Fiber,
|
|
4639
|
-
Layer as
|
|
4799
|
+
Layer as Layer31,
|
|
4640
4800
|
Ref as Ref10,
|
|
4641
4801
|
Schedule
|
|
4642
4802
|
} from "effect";
|
|
4643
4803
|
import { ulid as ulid4 } from "ulid";
|
|
4644
4804
|
|
|
4645
4805
|
// src/server/core/scheduler/domain/Job.ts
|
|
4646
|
-
import { Effect as
|
|
4647
|
-
var executeJob = (job) =>
|
|
4806
|
+
import { Effect as Effect34 } from "effect";
|
|
4807
|
+
var executeJob = (job) => Effect34.gen(function* () {
|
|
4648
4808
|
const lifeCycleService = yield* ClaudeCodeLifeCycleService;
|
|
4649
4809
|
const projectRepository = yield* ProjectRepository;
|
|
4650
4810
|
const userConfigService = yield* UserConfigService;
|
|
@@ -4652,7 +4812,7 @@ var executeJob = (job) => Effect31.gen(function* () {
|
|
|
4652
4812
|
const { project } = yield* projectRepository.getProject(message.projectId);
|
|
4653
4813
|
const userConfig = yield* userConfigService.getUserConfig();
|
|
4654
4814
|
if (project.meta.projectPath === null) {
|
|
4655
|
-
return yield*
|
|
4815
|
+
return yield* Effect34.fail(
|
|
4656
4816
|
new Error(`Project path not found for projectId: ${message.projectId}`)
|
|
4657
4817
|
);
|
|
4658
4818
|
}
|
|
@@ -4686,15 +4846,15 @@ var InvalidCronExpressionError = class extends Data6.TaggedError(
|
|
|
4686
4846
|
"InvalidCronExpressionError"
|
|
4687
4847
|
) {
|
|
4688
4848
|
};
|
|
4689
|
-
var
|
|
4849
|
+
var LayerImpl23 = Effect35.gen(function* () {
|
|
4690
4850
|
const fibersRef = yield* Ref10.make(/* @__PURE__ */ new Map());
|
|
4691
4851
|
const runningJobsRef = yield* Ref10.make(/* @__PURE__ */ new Set());
|
|
4692
|
-
const startJob = (job) =>
|
|
4852
|
+
const startJob = (job) => Effect35.gen(function* () {
|
|
4693
4853
|
const now = /* @__PURE__ */ new Date();
|
|
4694
4854
|
if (job.schedule.type === "cron") {
|
|
4695
4855
|
const cronResult = Cron.parse(job.schedule.expression);
|
|
4696
4856
|
if (cronResult._tag === "Left") {
|
|
4697
|
-
return yield*
|
|
4857
|
+
return yield* Effect35.fail(
|
|
4698
4858
|
new InvalidCronExpressionError({
|
|
4699
4859
|
expression: job.schedule.expression,
|
|
4700
4860
|
cause: cronResult.left
|
|
@@ -4702,12 +4862,12 @@ var LayerImpl21 = Effect32.gen(function* () {
|
|
|
4702
4862
|
);
|
|
4703
4863
|
}
|
|
4704
4864
|
const cronSchedule = Schedule.cron(cronResult.right);
|
|
4705
|
-
const fiber = yield*
|
|
4865
|
+
const fiber = yield* Effect35.gen(function* () {
|
|
4706
4866
|
const nextTime = Cron.next(cronResult.right, /* @__PURE__ */ new Date());
|
|
4707
4867
|
const nextDelay = Math.max(0, nextTime.getTime() - Date.now());
|
|
4708
|
-
yield*
|
|
4709
|
-
yield*
|
|
4710
|
-
}).pipe(
|
|
4868
|
+
yield* Effect35.sleep(Duration2.millis(nextDelay));
|
|
4869
|
+
yield* Effect35.repeat(runJobWithConcurrencyControl(job), cronSchedule);
|
|
4870
|
+
}).pipe(Effect35.forkDaemon);
|
|
4711
4871
|
yield* Ref10.update(
|
|
4712
4872
|
fibersRef,
|
|
4713
4873
|
(fibers) => new Map(fibers).set(job.id, fiber)
|
|
@@ -4718,17 +4878,17 @@ var LayerImpl21 = Effect32.gen(function* () {
|
|
|
4718
4878
|
}
|
|
4719
4879
|
const delay = calculateReservedDelay(job, now);
|
|
4720
4880
|
const delayDuration = Duration2.millis(delay);
|
|
4721
|
-
const fiber = yield*
|
|
4881
|
+
const fiber = yield* Effect35.delay(
|
|
4722
4882
|
runJobWithConcurrencyControl(job),
|
|
4723
4883
|
delayDuration
|
|
4724
|
-
).pipe(
|
|
4884
|
+
).pipe(Effect35.forkDaemon);
|
|
4725
4885
|
yield* Ref10.update(
|
|
4726
4886
|
fibersRef,
|
|
4727
4887
|
(fibers) => new Map(fibers).set(job.id, fiber)
|
|
4728
4888
|
);
|
|
4729
4889
|
}
|
|
4730
4890
|
});
|
|
4731
|
-
const runJobWithConcurrencyControl = (job) =>
|
|
4891
|
+
const runJobWithConcurrencyControl = (job) => Effect35.gen(function* () {
|
|
4732
4892
|
if (job.schedule.type === "cron" && job.schedule.concurrencyPolicy === "skip") {
|
|
4733
4893
|
const runningJobs = yield* Ref10.get(runningJobsRef);
|
|
4734
4894
|
if (runningJobs.has(job.id)) {
|
|
@@ -4738,9 +4898,9 @@ var LayerImpl21 = Effect32.gen(function* () {
|
|
|
4738
4898
|
yield* Ref10.update(runningJobsRef, (jobs) => new Set(jobs).add(job.id));
|
|
4739
4899
|
if (job.schedule.type === "reserved") {
|
|
4740
4900
|
const result2 = yield* executeJob(job).pipe(
|
|
4741
|
-
|
|
4742
|
-
onSuccess: () =>
|
|
4743
|
-
onFailure: () =>
|
|
4901
|
+
Effect35.matchEffect({
|
|
4902
|
+
onSuccess: () => Effect35.void,
|
|
4903
|
+
onFailure: () => Effect35.void
|
|
4744
4904
|
})
|
|
4745
4905
|
);
|
|
4746
4906
|
yield* Ref10.update(runningJobsRef, (jobs) => {
|
|
@@ -4749,18 +4909,18 @@ var LayerImpl21 = Effect32.gen(function* () {
|
|
|
4749
4909
|
return newJobs;
|
|
4750
4910
|
});
|
|
4751
4911
|
yield* deleteJobFromConfig(job.id).pipe(
|
|
4752
|
-
|
|
4912
|
+
Effect35.catchAll((error) => {
|
|
4753
4913
|
console.error(
|
|
4754
4914
|
`[Scheduler] Failed to delete reserved job ${job.id}:`,
|
|
4755
4915
|
error
|
|
4756
4916
|
);
|
|
4757
|
-
return
|
|
4917
|
+
return Effect35.void;
|
|
4758
4918
|
})
|
|
4759
4919
|
);
|
|
4760
4920
|
return result2;
|
|
4761
4921
|
}
|
|
4762
4922
|
const result = yield* executeJob(job).pipe(
|
|
4763
|
-
|
|
4923
|
+
Effect35.matchEffect({
|
|
4764
4924
|
onSuccess: () => updateJobStatus(job.id, "success", (/* @__PURE__ */ new Date()).toISOString()),
|
|
4765
4925
|
onFailure: () => updateJobStatus(job.id, "failed", (/* @__PURE__ */ new Date()).toISOString())
|
|
4766
4926
|
})
|
|
@@ -4772,7 +4932,7 @@ var LayerImpl21 = Effect32.gen(function* () {
|
|
|
4772
4932
|
});
|
|
4773
4933
|
return result;
|
|
4774
4934
|
});
|
|
4775
|
-
const updateJobStatus = (jobId, status, runAt) =>
|
|
4935
|
+
const updateJobStatus = (jobId, status, runAt) => Effect35.gen(function* () {
|
|
4776
4936
|
const config = yield* readConfig;
|
|
4777
4937
|
const job = config.jobs.find((j) => j.id === jobId);
|
|
4778
4938
|
if (job === void 0) {
|
|
@@ -4788,7 +4948,7 @@ var LayerImpl21 = Effect32.gen(function* () {
|
|
|
4788
4948
|
};
|
|
4789
4949
|
yield* writeConfig(updatedConfig);
|
|
4790
4950
|
});
|
|
4791
|
-
const stopJob = (jobId) =>
|
|
4951
|
+
const stopJob = (jobId) => Effect35.gen(function* () {
|
|
4792
4952
|
const fibers = yield* Ref10.get(fibersRef);
|
|
4793
4953
|
const fiber = fibers.get(jobId);
|
|
4794
4954
|
if (fiber !== void 0) {
|
|
@@ -4800,7 +4960,7 @@ var LayerImpl21 = Effect32.gen(function* () {
|
|
|
4800
4960
|
});
|
|
4801
4961
|
}
|
|
4802
4962
|
});
|
|
4803
|
-
const startScheduler =
|
|
4963
|
+
const startScheduler = Effect35.gen(function* () {
|
|
4804
4964
|
yield* initializeConfig;
|
|
4805
4965
|
const config = yield* readConfig;
|
|
4806
4966
|
for (const job of config.jobs) {
|
|
@@ -4809,27 +4969,27 @@ var LayerImpl21 = Effect32.gen(function* () {
|
|
|
4809
4969
|
}
|
|
4810
4970
|
}
|
|
4811
4971
|
});
|
|
4812
|
-
const stopScheduler =
|
|
4972
|
+
const stopScheduler = Effect35.gen(function* () {
|
|
4813
4973
|
const fibers = yield* Ref10.get(fibersRef);
|
|
4814
4974
|
for (const fiber of fibers.values()) {
|
|
4815
4975
|
yield* Fiber.interrupt(fiber);
|
|
4816
4976
|
}
|
|
4817
4977
|
yield* Ref10.set(fibersRef, /* @__PURE__ */ new Map());
|
|
4818
4978
|
});
|
|
4819
|
-
const getJobs = () =>
|
|
4979
|
+
const getJobs = () => Effect35.gen(function* () {
|
|
4820
4980
|
const config = yield* readConfig.pipe(
|
|
4821
|
-
|
|
4822
|
-
ConfigFileNotFoundError: () => initializeConfig.pipe(
|
|
4823
|
-
ConfigParseError: () => initializeConfig.pipe(
|
|
4981
|
+
Effect35.catchTags({
|
|
4982
|
+
ConfigFileNotFoundError: () => initializeConfig.pipe(Effect35.map(() => ({ jobs: [] }))),
|
|
4983
|
+
ConfigParseError: () => initializeConfig.pipe(Effect35.map(() => ({ jobs: [] })))
|
|
4824
4984
|
})
|
|
4825
4985
|
);
|
|
4826
4986
|
return config.jobs;
|
|
4827
4987
|
});
|
|
4828
|
-
const addJob = (newJob) =>
|
|
4988
|
+
const addJob = (newJob) => Effect35.gen(function* () {
|
|
4829
4989
|
const config = yield* readConfig.pipe(
|
|
4830
|
-
|
|
4831
|
-
ConfigFileNotFoundError: () => initializeConfig.pipe(
|
|
4832
|
-
ConfigParseError: () => initializeConfig.pipe(
|
|
4990
|
+
Effect35.catchTags({
|
|
4991
|
+
ConfigFileNotFoundError: () => initializeConfig.pipe(Effect35.map(() => ({ jobs: [] }))),
|
|
4992
|
+
ConfigParseError: () => initializeConfig.pipe(Effect35.map(() => ({ jobs: [] })))
|
|
4833
4993
|
})
|
|
4834
4994
|
);
|
|
4835
4995
|
const job = {
|
|
@@ -4848,16 +5008,16 @@ var LayerImpl21 = Effect32.gen(function* () {
|
|
|
4848
5008
|
}
|
|
4849
5009
|
return job;
|
|
4850
5010
|
});
|
|
4851
|
-
const updateJob = (jobId, updates) =>
|
|
5011
|
+
const updateJob = (jobId, updates) => Effect35.gen(function* () {
|
|
4852
5012
|
const config = yield* readConfig.pipe(
|
|
4853
|
-
|
|
4854
|
-
ConfigFileNotFoundError: () => initializeConfig.pipe(
|
|
4855
|
-
ConfigParseError: () => initializeConfig.pipe(
|
|
5013
|
+
Effect35.catchTags({
|
|
5014
|
+
ConfigFileNotFoundError: () => initializeConfig.pipe(Effect35.map(() => ({ jobs: [] }))),
|
|
5015
|
+
ConfigParseError: () => initializeConfig.pipe(Effect35.map(() => ({ jobs: [] })))
|
|
4856
5016
|
})
|
|
4857
5017
|
);
|
|
4858
5018
|
const job = config.jobs.find((j) => j.id === jobId);
|
|
4859
5019
|
if (job === void 0) {
|
|
4860
|
-
return yield*
|
|
5020
|
+
return yield* Effect35.fail(new SchedulerJobNotFoundError({ jobId }));
|
|
4861
5021
|
}
|
|
4862
5022
|
yield* stopJob(jobId);
|
|
4863
5023
|
const updatedJob = {
|
|
@@ -4873,32 +5033,32 @@ var LayerImpl21 = Effect32.gen(function* () {
|
|
|
4873
5033
|
}
|
|
4874
5034
|
return updatedJob;
|
|
4875
5035
|
});
|
|
4876
|
-
const deleteJobFromConfig = (jobId) =>
|
|
5036
|
+
const deleteJobFromConfig = (jobId) => Effect35.gen(function* () {
|
|
4877
5037
|
const config = yield* readConfig.pipe(
|
|
4878
|
-
|
|
4879
|
-
ConfigFileNotFoundError: () => initializeConfig.pipe(
|
|
4880
|
-
ConfigParseError: () => initializeConfig.pipe(
|
|
5038
|
+
Effect35.catchTags({
|
|
5039
|
+
ConfigFileNotFoundError: () => initializeConfig.pipe(Effect35.map(() => ({ jobs: [] }))),
|
|
5040
|
+
ConfigParseError: () => initializeConfig.pipe(Effect35.map(() => ({ jobs: [] })))
|
|
4881
5041
|
})
|
|
4882
5042
|
);
|
|
4883
5043
|
const job = config.jobs.find((j) => j.id === jobId);
|
|
4884
5044
|
if (job === void 0) {
|
|
4885
|
-
return yield*
|
|
5045
|
+
return yield* Effect35.fail(new SchedulerJobNotFoundError({ jobId }));
|
|
4886
5046
|
}
|
|
4887
5047
|
const updatedConfig = {
|
|
4888
5048
|
jobs: config.jobs.filter((j) => j.id !== jobId)
|
|
4889
5049
|
};
|
|
4890
5050
|
yield* writeConfig(updatedConfig);
|
|
4891
5051
|
});
|
|
4892
|
-
const deleteJob = (jobId) =>
|
|
5052
|
+
const deleteJob = (jobId) => Effect35.gen(function* () {
|
|
4893
5053
|
const config = yield* readConfig.pipe(
|
|
4894
|
-
|
|
4895
|
-
ConfigFileNotFoundError: () => initializeConfig.pipe(
|
|
4896
|
-
ConfigParseError: () => initializeConfig.pipe(
|
|
5054
|
+
Effect35.catchTags({
|
|
5055
|
+
ConfigFileNotFoundError: () => initializeConfig.pipe(Effect35.map(() => ({ jobs: [] }))),
|
|
5056
|
+
ConfigParseError: () => initializeConfig.pipe(Effect35.map(() => ({ jobs: [] })))
|
|
4897
5057
|
})
|
|
4898
5058
|
);
|
|
4899
5059
|
const job = config.jobs.find((j) => j.id === jobId);
|
|
4900
5060
|
if (job === void 0) {
|
|
4901
|
-
return yield*
|
|
5061
|
+
return yield* Effect35.fail(new SchedulerJobNotFoundError({ jobId }));
|
|
4902
5062
|
}
|
|
4903
5063
|
yield* stopJob(jobId);
|
|
4904
5064
|
yield* deleteJobFromConfig(jobId);
|
|
@@ -4912,24 +5072,24 @@ var LayerImpl21 = Effect32.gen(function* () {
|
|
|
4912
5072
|
deleteJob
|
|
4913
5073
|
};
|
|
4914
5074
|
});
|
|
4915
|
-
var SchedulerService = class extends
|
|
5075
|
+
var SchedulerService = class extends Context29.Tag("SchedulerService")() {
|
|
4916
5076
|
static {
|
|
4917
|
-
this.Live =
|
|
5077
|
+
this.Live = Layer31.effect(this, LayerImpl23);
|
|
4918
5078
|
}
|
|
4919
5079
|
};
|
|
4920
5080
|
|
|
4921
5081
|
// src/server/core/scheduler/presentation/SchedulerController.ts
|
|
4922
|
-
import { Context as
|
|
4923
|
-
var
|
|
5082
|
+
import { Context as Context30, Effect as Effect36, Layer as Layer32 } from "effect";
|
|
5083
|
+
var LayerImpl24 = Effect36.gen(function* () {
|
|
4924
5084
|
const schedulerService = yield* SchedulerService;
|
|
4925
|
-
const getJobs = () =>
|
|
5085
|
+
const getJobs = () => Effect36.gen(function* () {
|
|
4926
5086
|
const jobs = yield* schedulerService.getJobs();
|
|
4927
5087
|
return {
|
|
4928
5088
|
response: jobs,
|
|
4929
5089
|
status: 200
|
|
4930
5090
|
};
|
|
4931
5091
|
});
|
|
4932
|
-
const addJob = (options) =>
|
|
5092
|
+
const addJob = (options) => Effect36.gen(function* () {
|
|
4933
5093
|
const { job } = options;
|
|
4934
5094
|
const result = yield* schedulerService.addJob(job);
|
|
4935
5095
|
return {
|
|
@@ -4937,12 +5097,12 @@ var LayerImpl22 = Effect33.gen(function* () {
|
|
|
4937
5097
|
status: 201
|
|
4938
5098
|
};
|
|
4939
5099
|
});
|
|
4940
|
-
const updateJob = (options) =>
|
|
5100
|
+
const updateJob = (options) => Effect36.gen(function* () {
|
|
4941
5101
|
const { id, job } = options;
|
|
4942
5102
|
const result = yield* schedulerService.updateJob(id, job).pipe(
|
|
4943
|
-
|
|
5103
|
+
Effect36.catchTag(
|
|
4944
5104
|
"SchedulerJobNotFoundError",
|
|
4945
|
-
() =>
|
|
5105
|
+
() => Effect36.succeed(null)
|
|
4946
5106
|
)
|
|
4947
5107
|
);
|
|
4948
5108
|
if (result === null) {
|
|
@@ -4956,14 +5116,14 @@ var LayerImpl22 = Effect33.gen(function* () {
|
|
|
4956
5116
|
status: 200
|
|
4957
5117
|
};
|
|
4958
5118
|
});
|
|
4959
|
-
const deleteJob = (options) =>
|
|
5119
|
+
const deleteJob = (options) => Effect36.gen(function* () {
|
|
4960
5120
|
const { id } = options;
|
|
4961
5121
|
const result = yield* schedulerService.deleteJob(id).pipe(
|
|
4962
|
-
|
|
5122
|
+
Effect36.catchTag(
|
|
4963
5123
|
"SchedulerJobNotFoundError",
|
|
4964
|
-
() =>
|
|
5124
|
+
() => Effect36.succeed(false)
|
|
4965
5125
|
),
|
|
4966
|
-
|
|
5126
|
+
Effect36.map(() => true)
|
|
4967
5127
|
);
|
|
4968
5128
|
if (!result) {
|
|
4969
5129
|
return {
|
|
@@ -4983,17 +5143,17 @@ var LayerImpl22 = Effect33.gen(function* () {
|
|
|
4983
5143
|
deleteJob
|
|
4984
5144
|
};
|
|
4985
5145
|
});
|
|
4986
|
-
var SchedulerController = class extends
|
|
5146
|
+
var SchedulerController = class extends Context30.Tag("SchedulerController")() {
|
|
4987
5147
|
static {
|
|
4988
|
-
this.Live =
|
|
5148
|
+
this.Live = Layer32.effect(this, LayerImpl24);
|
|
4989
5149
|
}
|
|
4990
5150
|
};
|
|
4991
5151
|
|
|
4992
5152
|
// src/server/core/session/presentation/SessionController.ts
|
|
4993
|
-
import { Context as
|
|
5153
|
+
import { Context as Context31, Effect as Effect38, Layer as Layer33 } from "effect";
|
|
4994
5154
|
|
|
4995
5155
|
// src/server/core/session/services/ExportService.ts
|
|
4996
|
-
import { Effect as
|
|
5156
|
+
import { Effect as Effect37 } from "effect";
|
|
4997
5157
|
var escapeHtml = (text) => {
|
|
4998
5158
|
const map = {
|
|
4999
5159
|
"&": "&",
|
|
@@ -5252,7 +5412,7 @@ var renderGroupedAssistantEntries = (entries) => {
|
|
|
5252
5412
|
</div>
|
|
5253
5413
|
`;
|
|
5254
5414
|
};
|
|
5255
|
-
var generateSessionHtml = (session, projectId) =>
|
|
5415
|
+
var generateSessionHtml = (session, projectId) => Effect37.gen(function* () {
|
|
5256
5416
|
const grouped = groupConsecutiveAssistantMessages(session.conversations);
|
|
5257
5417
|
const conversationsHtml = grouped.map((group) => {
|
|
5258
5418
|
if (group.type === "grouped") {
|
|
@@ -5772,9 +5932,9 @@ var generateSessionHtml = (session, projectId) => Effect34.gen(function* () {
|
|
|
5772
5932
|
});
|
|
5773
5933
|
|
|
5774
5934
|
// src/server/core/session/presentation/SessionController.ts
|
|
5775
|
-
var
|
|
5935
|
+
var LayerImpl25 = Effect38.gen(function* () {
|
|
5776
5936
|
const sessionRepository = yield* SessionRepository;
|
|
5777
|
-
const getSession = (options) =>
|
|
5937
|
+
const getSession = (options) => Effect38.gen(function* () {
|
|
5778
5938
|
const { projectId, sessionId } = options;
|
|
5779
5939
|
const { session } = yield* sessionRepository.getSession(
|
|
5780
5940
|
projectId,
|
|
@@ -5785,7 +5945,7 @@ var LayerImpl23 = Effect35.gen(function* () {
|
|
|
5785
5945
|
response: { session }
|
|
5786
5946
|
};
|
|
5787
5947
|
});
|
|
5788
|
-
const exportSessionHtml = (options) =>
|
|
5948
|
+
const exportSessionHtml = (options) => Effect38.gen(function* () {
|
|
5789
5949
|
const { projectId, sessionId } = options;
|
|
5790
5950
|
const { session } = yield* sessionRepository.getSession(
|
|
5791
5951
|
projectId,
|
|
@@ -5808,9 +5968,9 @@ var LayerImpl23 = Effect35.gen(function* () {
|
|
|
5808
5968
|
exportSessionHtml
|
|
5809
5969
|
};
|
|
5810
5970
|
});
|
|
5811
|
-
var SessionController = class extends
|
|
5971
|
+
var SessionController = class extends Context31.Tag("SessionController")() {
|
|
5812
5972
|
static {
|
|
5813
|
-
this.Live =
|
|
5973
|
+
this.Live = Layer33.effect(this, LayerImpl25);
|
|
5814
5974
|
}
|
|
5815
5975
|
};
|
|
5816
5976
|
|
|
@@ -5819,12 +5979,12 @@ import { Hono } from "hono";
|
|
|
5819
5979
|
var honoApp = new Hono();
|
|
5820
5980
|
|
|
5821
5981
|
// src/server/hono/initialize.ts
|
|
5822
|
-
import { Context as
|
|
5823
|
-
var InitializeService = class extends
|
|
5982
|
+
import { Context as Context32, Effect as Effect39, Layer as Layer34, Ref as Ref11, Schedule as Schedule2 } from "effect";
|
|
5983
|
+
var InitializeService = class extends Context32.Tag("InitializeService")() {
|
|
5824
5984
|
static {
|
|
5825
|
-
this.Live =
|
|
5985
|
+
this.Live = Layer34.effect(
|
|
5826
5986
|
this,
|
|
5827
|
-
|
|
5987
|
+
Effect39.gen(function* () {
|
|
5828
5988
|
const eventBus = yield* EventBus;
|
|
5829
5989
|
const fileWatcher = yield* FileWatcherService;
|
|
5830
5990
|
const projectRepository = yield* ProjectRepository;
|
|
@@ -5834,20 +5994,20 @@ var InitializeService = class extends Context30.Tag("InitializeService")() {
|
|
|
5834
5994
|
const virtualConversationDatabase = yield* VirtualConversationDatabase;
|
|
5835
5995
|
const listenersRef = yield* Ref11.make({});
|
|
5836
5996
|
const startInitialization = () => {
|
|
5837
|
-
return
|
|
5997
|
+
return Effect39.gen(function* () {
|
|
5838
5998
|
yield* fileWatcher.startWatching();
|
|
5839
|
-
const daemon =
|
|
5999
|
+
const daemon = Effect39.repeat(
|
|
5840
6000
|
eventBus.emit("heartbeat", {}),
|
|
5841
6001
|
Schedule2.fixed("10 seconds")
|
|
5842
6002
|
);
|
|
5843
6003
|
console.log("start heartbeat");
|
|
5844
|
-
yield*
|
|
6004
|
+
yield* Effect39.forkDaemon(daemon);
|
|
5845
6005
|
console.log("after starting heartbeat fork");
|
|
5846
6006
|
const onSessionChanged = (event) => {
|
|
5847
|
-
|
|
6007
|
+
Effect39.runFork(
|
|
5848
6008
|
projectMetaService.invalidateProject(event.projectId)
|
|
5849
6009
|
);
|
|
5850
|
-
|
|
6010
|
+
Effect39.runFork(
|
|
5851
6011
|
sessionMetaService.invalidateSession(
|
|
5852
6012
|
event.projectId,
|
|
5853
6013
|
event.sessionId
|
|
@@ -5856,7 +6016,7 @@ var InitializeService = class extends Context30.Tag("InitializeService")() {
|
|
|
5856
6016
|
};
|
|
5857
6017
|
const onSessionProcessChanged = (event) => {
|
|
5858
6018
|
if ((event.changed.type === "completed" || event.changed.type === "paused") && event.changed.sessionId !== void 0) {
|
|
5859
|
-
|
|
6019
|
+
Effect39.runFork(
|
|
5860
6020
|
virtualConversationDatabase.deleteVirtualConversations(
|
|
5861
6021
|
event.changed.sessionId
|
|
5862
6022
|
)
|
|
@@ -5870,12 +6030,12 @@ var InitializeService = class extends Context30.Tag("InitializeService")() {
|
|
|
5870
6030
|
});
|
|
5871
6031
|
yield* eventBus.on("sessionChanged", onSessionChanged);
|
|
5872
6032
|
yield* eventBus.on("sessionProcessChanged", onSessionProcessChanged);
|
|
5873
|
-
yield*
|
|
6033
|
+
yield* Effect39.gen(function* () {
|
|
5874
6034
|
console.log("Initializing projects cache");
|
|
5875
6035
|
const { projects } = yield* projectRepository.getProjects();
|
|
5876
6036
|
console.log(`${projects.length} projects cache initialized`);
|
|
5877
6037
|
console.log("Initializing sessions cache");
|
|
5878
|
-
const results = yield*
|
|
6038
|
+
const results = yield* Effect39.all(
|
|
5879
6039
|
projects.map(
|
|
5880
6040
|
(project) => sessionRepository.getSessions(project.id)
|
|
5881
6041
|
),
|
|
@@ -5887,12 +6047,12 @@ var InitializeService = class extends Context30.Tag("InitializeService")() {
|
|
|
5887
6047
|
);
|
|
5888
6048
|
console.log(`${totalSessions} sessions cache initialized`);
|
|
5889
6049
|
}).pipe(
|
|
5890
|
-
|
|
5891
|
-
|
|
6050
|
+
Effect39.catchAll(() => Effect39.void),
|
|
6051
|
+
Effect39.withSpan("initialize-cache")
|
|
5892
6052
|
);
|
|
5893
|
-
}).pipe(
|
|
6053
|
+
}).pipe(Effect39.withSpan("start-initialization"));
|
|
5894
6054
|
};
|
|
5895
|
-
const stopCleanup = () =>
|
|
6055
|
+
const stopCleanup = () => Effect39.gen(function* () {
|
|
5896
6056
|
const listeners = yield* Ref11.get(listenersRef);
|
|
5897
6057
|
if (listeners.sessionChanged) {
|
|
5898
6058
|
yield* eventBus.off("sessionChanged", listeners.sessionChanged);
|
|
@@ -5917,7 +6077,7 @@ var InitializeService = class extends Context30.Tag("InitializeService")() {
|
|
|
5917
6077
|
|
|
5918
6078
|
// src/server/hono/route.ts
|
|
5919
6079
|
import { zValidator } from "@hono/zod-validator";
|
|
5920
|
-
import { Effect as
|
|
6080
|
+
import { Effect as Effect41, Runtime as Runtime3 } from "effect";
|
|
5921
6081
|
import { setCookie as setCookie2 } from "hono/cookie";
|
|
5922
6082
|
import { streamSSE } from "hono/streaming";
|
|
5923
6083
|
import prexit from "prexit";
|
|
@@ -5926,7 +6086,7 @@ import { z as z28 } from "zod";
|
|
|
5926
6086
|
// package.json
|
|
5927
6087
|
var package_default = {
|
|
5928
6088
|
name: "@kimuson/claude-code-viewer",
|
|
5929
|
-
version: "0.4.
|
|
6089
|
+
version: "0.4.7",
|
|
5930
6090
|
type: "module",
|
|
5931
6091
|
license: "MIT",
|
|
5932
6092
|
repository: {
|
|
@@ -6191,9 +6351,9 @@ var userConfigSchema = z27.object({
|
|
|
6191
6351
|
var defaultUserConfig = userConfigSchema.parse({});
|
|
6192
6352
|
|
|
6193
6353
|
// src/server/lib/effect/toEffectResponse.ts
|
|
6194
|
-
import { Effect as
|
|
6354
|
+
import { Effect as Effect40 } from "effect";
|
|
6195
6355
|
var effectToResponse = async (ctx, effect) => {
|
|
6196
|
-
const result = await
|
|
6356
|
+
const result = await Effect40.runPromise(effect);
|
|
6197
6357
|
const result2 = ctx.json(result.response, result.status);
|
|
6198
6358
|
return result2;
|
|
6199
6359
|
};
|
|
@@ -6236,9 +6396,10 @@ var configMiddleware = createMiddleware(
|
|
|
6236
6396
|
);
|
|
6237
6397
|
|
|
6238
6398
|
// src/server/hono/route.ts
|
|
6239
|
-
var routes = (app) =>
|
|
6399
|
+
var routes = (app) => Effect41.gen(function* () {
|
|
6240
6400
|
const projectController = yield* ProjectController;
|
|
6241
6401
|
const sessionController = yield* SessionController;
|
|
6402
|
+
const agentSessionController = yield* AgentSessionController;
|
|
6242
6403
|
const gitController = yield* GitController;
|
|
6243
6404
|
const claudeCodeSessionProcessController = yield* ClaudeCodeSessionProcessController;
|
|
6244
6405
|
const claudeCodePermissionController = yield* ClaudeCodePermissionController;
|
|
@@ -6251,7 +6412,7 @@ var routes = (app) => Effect38.gen(function* () {
|
|
|
6251
6412
|
const userConfigService = yield* UserConfigService;
|
|
6252
6413
|
const claudeCodeLifeCycleService = yield* ClaudeCodeLifeCycleService;
|
|
6253
6414
|
const initializeService = yield* InitializeService;
|
|
6254
|
-
const runtime = yield*
|
|
6415
|
+
const runtime = yield* Effect41.runtime();
|
|
6255
6416
|
if ((yield* envService.getEnv("NEXT_PHASE")) !== "phase-production-build") {
|
|
6256
6417
|
yield* initializeService.startInitialization();
|
|
6257
6418
|
prexit(async () => {
|
|
@@ -6259,7 +6420,7 @@ var routes = (app) => Effect38.gen(function* () {
|
|
|
6259
6420
|
});
|
|
6260
6421
|
}
|
|
6261
6422
|
return app.use(configMiddleware).use(async (c, next) => {
|
|
6262
|
-
await
|
|
6423
|
+
await Effect41.runPromise(
|
|
6263
6424
|
userConfigService.setUserConfig({
|
|
6264
6425
|
...c.get("userConfig")
|
|
6265
6426
|
})
|
|
@@ -6294,7 +6455,7 @@ var routes = (app) => Effect38.gen(function* () {
|
|
|
6294
6455
|
projectController.getProject({
|
|
6295
6456
|
...c.req.param(),
|
|
6296
6457
|
...c.req.valid("query")
|
|
6297
|
-
}).pipe(
|
|
6458
|
+
}).pipe(Effect41.provide(runtime))
|
|
6298
6459
|
);
|
|
6299
6460
|
return response;
|
|
6300
6461
|
}
|
|
@@ -6311,7 +6472,7 @@ var routes = (app) => Effect38.gen(function* () {
|
|
|
6311
6472
|
c,
|
|
6312
6473
|
projectController.createProject({
|
|
6313
6474
|
...c.req.valid("json")
|
|
6314
|
-
}).pipe(
|
|
6475
|
+
}).pipe(Effect41.provide(runtime))
|
|
6315
6476
|
);
|
|
6316
6477
|
return response;
|
|
6317
6478
|
}
|
|
@@ -6320,13 +6481,13 @@ var routes = (app) => Effect38.gen(function* () {
|
|
|
6320
6481
|
c,
|
|
6321
6482
|
projectController.getProjectLatestSession({
|
|
6322
6483
|
...c.req.param()
|
|
6323
|
-
}).pipe(
|
|
6484
|
+
}).pipe(Effect41.provide(runtime))
|
|
6324
6485
|
);
|
|
6325
6486
|
return response;
|
|
6326
6487
|
}).get("/api/projects/:projectId/sessions/:sessionId", async (c) => {
|
|
6327
6488
|
const response = await effectToResponse(
|
|
6328
6489
|
c,
|
|
6329
|
-
sessionController.getSession({ ...c.req.param() }).pipe(
|
|
6490
|
+
sessionController.getSession({ ...c.req.param() }).pipe(Effect41.provide(runtime))
|
|
6330
6491
|
);
|
|
6331
6492
|
return response;
|
|
6332
6493
|
}).get(
|
|
@@ -6334,16 +6495,26 @@ var routes = (app) => Effect38.gen(function* () {
|
|
|
6334
6495
|
async (c) => {
|
|
6335
6496
|
const response = await effectToResponse(
|
|
6336
6497
|
c,
|
|
6337
|
-
sessionController.exportSessionHtml({ ...c.req.param() }).pipe(
|
|
6498
|
+
sessionController.exportSessionHtml({ ...c.req.param() }).pipe(Effect41.provide(runtime))
|
|
6338
6499
|
);
|
|
6339
6500
|
return response;
|
|
6340
6501
|
}
|
|
6341
|
-
).get("/api/projects/:projectId/
|
|
6502
|
+
).get("/api/projects/:projectId/agent-sessions/:agentId", async (c) => {
|
|
6503
|
+
const { projectId, agentId } = c.req.param();
|
|
6504
|
+
const response = await effectToResponse(
|
|
6505
|
+
c,
|
|
6506
|
+
agentSessionController.getAgentSession({
|
|
6507
|
+
projectId,
|
|
6508
|
+
agentId
|
|
6509
|
+
}).pipe(Effect41.provide(runtime))
|
|
6510
|
+
);
|
|
6511
|
+
return response;
|
|
6512
|
+
}).get("/api/projects/:projectId/git/current-revisions", async (c) => {
|
|
6342
6513
|
const response = await effectToResponse(
|
|
6343
6514
|
c,
|
|
6344
6515
|
gitController.getCurrentRevisions({
|
|
6345
6516
|
...c.req.param()
|
|
6346
|
-
}).pipe(
|
|
6517
|
+
}).pipe(Effect41.provide(runtime))
|
|
6347
6518
|
);
|
|
6348
6519
|
return response;
|
|
6349
6520
|
}).post(
|
|
@@ -6361,7 +6532,7 @@ var routes = (app) => Effect38.gen(function* () {
|
|
|
6361
6532
|
gitController.getGitDiff({
|
|
6362
6533
|
...c.req.param(),
|
|
6363
6534
|
...c.req.valid("json")
|
|
6364
|
-
}).pipe(
|
|
6535
|
+
}).pipe(Effect41.provide(runtime))
|
|
6365
6536
|
);
|
|
6366
6537
|
return response;
|
|
6367
6538
|
}
|
|
@@ -6374,7 +6545,7 @@ var routes = (app) => Effect38.gen(function* () {
|
|
|
6374
6545
|
gitController.commitFiles({
|
|
6375
6546
|
...c.req.param(),
|
|
6376
6547
|
...c.req.valid("json")
|
|
6377
|
-
}).pipe(
|
|
6548
|
+
}).pipe(Effect41.provide(runtime))
|
|
6378
6549
|
);
|
|
6379
6550
|
return response;
|
|
6380
6551
|
}
|
|
@@ -6387,7 +6558,7 @@ var routes = (app) => Effect38.gen(function* () {
|
|
|
6387
6558
|
gitController.pushCommits({
|
|
6388
6559
|
...c.req.param(),
|
|
6389
6560
|
...c.req.valid("json")
|
|
6390
|
-
}).pipe(
|
|
6561
|
+
}).pipe(Effect41.provide(runtime))
|
|
6391
6562
|
);
|
|
6392
6563
|
return response;
|
|
6393
6564
|
}
|
|
@@ -6400,7 +6571,7 @@ var routes = (app) => Effect38.gen(function* () {
|
|
|
6400
6571
|
gitController.commitAndPush({
|
|
6401
6572
|
...c.req.param(),
|
|
6402
6573
|
...c.req.valid("json")
|
|
6403
|
-
}).pipe(
|
|
6574
|
+
}).pipe(Effect41.provide(runtime))
|
|
6404
6575
|
);
|
|
6405
6576
|
return response;
|
|
6406
6577
|
}
|
|
@@ -6409,7 +6580,7 @@ var routes = (app) => Effect38.gen(function* () {
|
|
|
6409
6580
|
c,
|
|
6410
6581
|
claudeCodeController.getClaudeCommands({
|
|
6411
6582
|
...c.req.param()
|
|
6412
|
-
})
|
|
6583
|
+
}).pipe(Effect41.provide(runtime))
|
|
6413
6584
|
);
|
|
6414
6585
|
return response;
|
|
6415
6586
|
}).get("/api/projects/:projectId/mcp/list", async (c) => {
|
|
@@ -6417,19 +6588,19 @@ var routes = (app) => Effect38.gen(function* () {
|
|
|
6417
6588
|
c,
|
|
6418
6589
|
claudeCodeController.getMcpListRoute({
|
|
6419
6590
|
...c.req.param()
|
|
6420
|
-
}).pipe(
|
|
6591
|
+
}).pipe(Effect41.provide(runtime))
|
|
6421
6592
|
);
|
|
6422
6593
|
return response;
|
|
6423
6594
|
}).get("/api/cc/meta", async (c) => {
|
|
6424
6595
|
const response = await effectToResponse(
|
|
6425
6596
|
c,
|
|
6426
|
-
claudeCodeController.getClaudeCodeMeta().pipe(
|
|
6597
|
+
claudeCodeController.getClaudeCodeMeta().pipe(Effect41.provide(runtime))
|
|
6427
6598
|
);
|
|
6428
6599
|
return response;
|
|
6429
6600
|
}).get("/api/cc/features", async (c) => {
|
|
6430
6601
|
const response = await effectToResponse(
|
|
6431
6602
|
c,
|
|
6432
|
-
claudeCodeController.getAvailableFeatures().pipe(
|
|
6603
|
+
claudeCodeController.getAvailableFeatures().pipe(Effect41.provide(runtime))
|
|
6433
6604
|
);
|
|
6434
6605
|
return response;
|
|
6435
6606
|
}).get("/api/cc/session-processes", async (c) => {
|
|
@@ -6473,7 +6644,7 @@ var routes = (app) => Effect38.gen(function* () {
|
|
|
6473
6644
|
claudeCodeSessionProcessController.continueSessionProcess({
|
|
6474
6645
|
...c.req.param(),
|
|
6475
6646
|
...c.req.valid("json")
|
|
6476
|
-
}).pipe(
|
|
6647
|
+
}).pipe(Effect41.provide(runtime))
|
|
6477
6648
|
);
|
|
6478
6649
|
return response;
|
|
6479
6650
|
}
|
|
@@ -6482,7 +6653,7 @@ var routes = (app) => Effect38.gen(function* () {
|
|
|
6482
6653
|
zValidator("json", z28.object({ projectId: z28.string() })),
|
|
6483
6654
|
async (c) => {
|
|
6484
6655
|
const { sessionProcessId } = c.req.param();
|
|
6485
|
-
void
|
|
6656
|
+
void Effect41.runFork(
|
|
6486
6657
|
claudeCodeLifeCycleService.abortTask(sessionProcessId)
|
|
6487
6658
|
);
|
|
6488
6659
|
return c.json({ message: "Task aborted" });
|
|
@@ -6510,7 +6681,7 @@ var routes = (app) => Effect38.gen(function* () {
|
|
|
6510
6681
|
c,
|
|
6511
6682
|
async (rawStream) => {
|
|
6512
6683
|
await Runtime3.runPromise(runtime)(
|
|
6513
|
-
sseController.handleSSE(rawStream).pipe(
|
|
6684
|
+
sseController.handleSSE(rawStream).pipe(Effect41.provide(TypeSafeSSE.make(rawStream)))
|
|
6514
6685
|
);
|
|
6515
6686
|
},
|
|
6516
6687
|
async (err) => {
|
|
@@ -6520,7 +6691,7 @@ var routes = (app) => Effect38.gen(function* () {
|
|
|
6520
6691
|
}).get("/api/scheduler/jobs", async (c) => {
|
|
6521
6692
|
const response = await effectToResponse(
|
|
6522
6693
|
c,
|
|
6523
|
-
schedulerController.getJobs().pipe(
|
|
6694
|
+
schedulerController.getJobs().pipe(Effect41.provide(runtime))
|
|
6524
6695
|
);
|
|
6525
6696
|
return response;
|
|
6526
6697
|
}).post(
|
|
@@ -6531,7 +6702,7 @@ var routes = (app) => Effect38.gen(function* () {
|
|
|
6531
6702
|
c,
|
|
6532
6703
|
schedulerController.addJob({
|
|
6533
6704
|
job: c.req.valid("json")
|
|
6534
|
-
}).pipe(
|
|
6705
|
+
}).pipe(Effect41.provide(runtime))
|
|
6535
6706
|
);
|
|
6536
6707
|
return response;
|
|
6537
6708
|
}
|
|
@@ -6544,7 +6715,7 @@ var routes = (app) => Effect38.gen(function* () {
|
|
|
6544
6715
|
schedulerController.updateJob({
|
|
6545
6716
|
id: c.req.param("id"),
|
|
6546
6717
|
job: c.req.valid("json")
|
|
6547
|
-
}).pipe(
|
|
6718
|
+
}).pipe(Effect41.provide(runtime))
|
|
6548
6719
|
);
|
|
6549
6720
|
return response;
|
|
6550
6721
|
}
|
|
@@ -6553,7 +6724,7 @@ var routes = (app) => Effect38.gen(function* () {
|
|
|
6553
6724
|
c,
|
|
6554
6725
|
schedulerController.deleteJob({
|
|
6555
6726
|
id: c.req.param("id")
|
|
6556
|
-
}).pipe(
|
|
6727
|
+
}).pipe(Effect41.provide(runtime))
|
|
6557
6728
|
);
|
|
6558
6729
|
return response;
|
|
6559
6730
|
}).get(
|
|
@@ -6595,7 +6766,7 @@ var routes = (app) => Effect38.gen(function* () {
|
|
|
6595
6766
|
).get("/api/flags", async (c) => {
|
|
6596
6767
|
const response = await effectToResponse(
|
|
6597
6768
|
c,
|
|
6598
|
-
featureFlagController.getFlags().pipe(
|
|
6769
|
+
featureFlagController.getFlags().pipe(Effect41.provide(runtime))
|
|
6599
6770
|
);
|
|
6600
6771
|
return response;
|
|
6601
6772
|
});
|
|
@@ -6603,13 +6774,13 @@ var routes = (app) => Effect38.gen(function* () {
|
|
|
6603
6774
|
|
|
6604
6775
|
// src/server/lib/effect/layers.ts
|
|
6605
6776
|
import { NodeContext } from "@effect/platform-node";
|
|
6606
|
-
import { Layer as
|
|
6607
|
-
var platformLayer =
|
|
6777
|
+
import { Layer as Layer35 } from "effect";
|
|
6778
|
+
var platformLayer = Layer35.mergeAll(
|
|
6608
6779
|
ApplicationContext.Live,
|
|
6609
6780
|
UserConfigService.Live,
|
|
6610
6781
|
EventBus.Live,
|
|
6611
6782
|
EnvService.Live
|
|
6612
|
-
).pipe(
|
|
6783
|
+
).pipe(Layer35.provide(EnvService.Live), Layer35.provide(NodeContext.layer));
|
|
6613
6784
|
|
|
6614
6785
|
// src/server/main.ts
|
|
6615
6786
|
var isDevelopment = process.env.NODE_ENV === "development";
|
|
@@ -6632,42 +6803,44 @@ if (!isDevelopment) {
|
|
|
6632
6803
|
}
|
|
6633
6804
|
var program = routes(honoApp).pipe(
|
|
6634
6805
|
/** Presentation */
|
|
6635
|
-
|
|
6636
|
-
|
|
6637
|
-
|
|
6638
|
-
|
|
6639
|
-
|
|
6640
|
-
|
|
6641
|
-
|
|
6642
|
-
|
|
6643
|
-
|
|
6644
|
-
|
|
6806
|
+
Effect42.provide(ProjectController.Live),
|
|
6807
|
+
Effect42.provide(SessionController.Live),
|
|
6808
|
+
Effect42.provide(AgentSessionController.Live),
|
|
6809
|
+
Effect42.provide(GitController.Live),
|
|
6810
|
+
Effect42.provide(ClaudeCodeController.Live),
|
|
6811
|
+
Effect42.provide(ClaudeCodeSessionProcessController.Live),
|
|
6812
|
+
Effect42.provide(ClaudeCodePermissionController.Live),
|
|
6813
|
+
Effect42.provide(FileSystemController.Live),
|
|
6814
|
+
Effect42.provide(SSEController.Live),
|
|
6815
|
+
Effect42.provide(SchedulerController.Live),
|
|
6816
|
+
Effect42.provide(FeatureFlagController.Live)
|
|
6645
6817
|
).pipe(
|
|
6646
6818
|
/** Application */
|
|
6647
|
-
|
|
6648
|
-
|
|
6819
|
+
Effect42.provide(InitializeService.Live),
|
|
6820
|
+
Effect42.provide(FileWatcherService.Live)
|
|
6649
6821
|
).pipe(
|
|
6650
6822
|
/** Domain */
|
|
6651
|
-
|
|
6652
|
-
|
|
6653
|
-
|
|
6654
|
-
|
|
6655
|
-
|
|
6656
|
-
|
|
6657
|
-
|
|
6823
|
+
Effect42.provide(ClaudeCodeLifeCycleService.Live),
|
|
6824
|
+
Effect42.provide(ClaudeCodePermissionService.Live),
|
|
6825
|
+
Effect42.provide(ClaudeCodeSessionProcessService.Live),
|
|
6826
|
+
Effect42.provide(ClaudeCodeService.Live),
|
|
6827
|
+
Effect42.provide(GitService.Live),
|
|
6828
|
+
Effect42.provide(SchedulerService.Live),
|
|
6829
|
+
Effect42.provide(SchedulerConfigBaseDir.Live)
|
|
6658
6830
|
).pipe(
|
|
6659
6831
|
/** Infrastructure */
|
|
6660
|
-
|
|
6661
|
-
|
|
6662
|
-
|
|
6663
|
-
|
|
6664
|
-
|
|
6832
|
+
Effect42.provide(ProjectRepository.Live),
|
|
6833
|
+
Effect42.provide(SessionRepository.Live),
|
|
6834
|
+
Effect42.provide(ProjectMetaService.Live),
|
|
6835
|
+
Effect42.provide(SessionMetaService.Live),
|
|
6836
|
+
Effect42.provide(VirtualConversationDatabase.Live),
|
|
6837
|
+
Effect42.provide(AgentSessionLayer)
|
|
6665
6838
|
).pipe(
|
|
6666
6839
|
/** Platform */
|
|
6667
|
-
|
|
6668
|
-
|
|
6840
|
+
Effect42.provide(platformLayer),
|
|
6841
|
+
Effect42.provide(NodeContext2.layer)
|
|
6669
6842
|
);
|
|
6670
|
-
await
|
|
6843
|
+
await Effect42.runPromise(program);
|
|
6671
6844
|
var port = isDevelopment ? (
|
|
6672
6845
|
// biome-ignore lint/style/noProcessEnv: allow only here
|
|
6673
6846
|
process.env.DEV_BE_PORT ?? "3401"
|