@kimuson/claude-code-viewer 0.4.13 → 0.4.15
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +10 -7
- package/dist/main.js +529 -447
- package/dist/main.js.map +4 -4
- package/dist/static/assets/{ProtectedRoute-CdwJtygx.js → ProtectedRoute-C5fRf9hh.js} +1 -1
- package/dist/static/assets/{eye-vRHkOT2Y.js → eye-BpyPAB62.js} +1 -1
- package/dist/static/assets/{index-BENMSEhP.js → index-CGQpot94.js} +1 -1
- package/dist/static/assets/{index-CKGQ--tS.js → index-D07oc57n.js} +1 -1
- package/dist/static/assets/{index-DnV70LdM.js → index-DZukx-uT.js} +36 -36
- package/dist/static/assets/index-XlCGs7Gh.css +1 -0
- package/dist/static/assets/{label-CMEANyku.js → label-BhzS1w7s.js} +1 -1
- package/dist/static/assets/{login-CWyt9fyL.js → login-DpxCwKVk.js} +1 -1
- package/dist/static/assets/messages-Bglth_PW.js +1 -0
- package/dist/static/assets/messages-CI-bn0hx.js +1 -0
- package/dist/static/assets/messages-ny4ztBtq.js +1 -0
- package/dist/static/assets/{session-h5mv6_Wi.js → session-CEMQzyS6.js} +1 -1
- package/dist/static/assets/{session-40GpSLiu.js → session-DmyweLUZ.js} +58 -53
- package/dist/static/index.html +2 -2
- package/package.json +1 -1
- package/dist/static/assets/index-CF6ATi6V.css +0 -1
- package/dist/static/assets/messages-B4nydqXe.js +0 -1
- package/dist/static/assets/messages-DQZZWrCH.js +0 -1
- package/dist/static/assets/messages-DRQIx4IO.js +0 -1
package/dist/main.js
CHANGED
|
@@ -6,7 +6,7 @@ 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 Effect46 } from "effect";
|
|
10
10
|
|
|
11
11
|
// src/server/core/agent-session/index.ts
|
|
12
12
|
import { Layer as Layer3 } from "effect";
|
|
@@ -856,7 +856,20 @@ import {
|
|
|
856
856
|
} from "@anthropic-ai/claude-code";
|
|
857
857
|
import { Command, Path as Path7 } from "@effect/platform";
|
|
858
858
|
import { Data, Effect as Effect10 } from "effect";
|
|
859
|
-
|
|
859
|
+
import { uniq } from "es-toolkit";
|
|
860
|
+
var npxCacheRegExp = /_npx[/\\].*node_modules[\\/]\.bin/;
|
|
861
|
+
var localNodeModulesBinRegExp = new RegExp(
|
|
862
|
+
`${process.cwd()}/node_modules/.bin`
|
|
863
|
+
);
|
|
864
|
+
var claudeCodePathPriority = (path) => {
|
|
865
|
+
if (npxCacheRegExp.test(path)) {
|
|
866
|
+
return 0;
|
|
867
|
+
}
|
|
868
|
+
if (localNodeModulesBinRegExp.test(path)) {
|
|
869
|
+
return 1;
|
|
870
|
+
}
|
|
871
|
+
return 2;
|
|
872
|
+
};
|
|
860
873
|
var ClaudeCodePathNotFoundError = class extends Data.TaggedError(
|
|
861
874
|
"ClaudeCodePathNotFoundError"
|
|
862
875
|
) {
|
|
@@ -870,40 +883,36 @@ var resolveClaudeCodePath = Effect10.gen(function* () {
|
|
|
870
883
|
if (specifiedExecutablePath !== void 0) {
|
|
871
884
|
return path.resolve(specifiedExecutablePath);
|
|
872
885
|
}
|
|
873
|
-
const
|
|
874
|
-
|
|
875
|
-
Command.make("which", "claude").pipe(
|
|
876
|
-
Command.env({
|
|
877
|
-
PATH: pathEnv
|
|
878
|
-
})
|
|
879
|
-
// DO NOT Specify `runInShell(true)` here, it causes resolve node_modules/.bin/claude to be executed.
|
|
880
|
-
)
|
|
886
|
+
const claudePaths = yield* Command.string(
|
|
887
|
+
Command.make("which", "-a", "claude").pipe(Command.runInShell(true))
|
|
881
888
|
).pipe(
|
|
882
|
-
Effect10.map(
|
|
883
|
-
|
|
884
|
-
|
|
885
|
-
|
|
886
|
-
|
|
887
|
-
|
|
888
|
-
|
|
889
|
-
|
|
890
|
-
|
|
891
|
-
|
|
892
|
-
|
|
893
|
-
|
|
894
|
-
|
|
895
|
-
|
|
896
|
-
|
|
897
|
-
|
|
889
|
+
Effect10.map(
|
|
890
|
+
(output) => output.split("\n").map((line) => line.trim()).filter((line) => line !== "") ?? []
|
|
891
|
+
),
|
|
892
|
+
Effect10.map(
|
|
893
|
+
(paths) => uniq(paths).toSorted((a, b) => {
|
|
894
|
+
const aPriority = claudeCodePathPriority(a);
|
|
895
|
+
const bPriority = claudeCodePathPriority(b);
|
|
896
|
+
if (aPriority < bPriority) {
|
|
897
|
+
return 1;
|
|
898
|
+
}
|
|
899
|
+
if (aPriority > bPriority) {
|
|
900
|
+
return -1;
|
|
901
|
+
}
|
|
902
|
+
return 0;
|
|
903
|
+
})
|
|
904
|
+
),
|
|
905
|
+
Effect10.catchAll(() => Effect10.succeed([]))
|
|
898
906
|
);
|
|
899
|
-
|
|
907
|
+
const resolvedClaudePath = claudePaths.at(0);
|
|
908
|
+
if (resolvedClaudePath === void 0) {
|
|
900
909
|
return yield* Effect10.fail(
|
|
901
910
|
new ClaudeCodePathNotFoundError({
|
|
902
911
|
message: "Claude Code CLI not found in any location"
|
|
903
912
|
})
|
|
904
913
|
);
|
|
905
914
|
}
|
|
906
|
-
return
|
|
915
|
+
return resolvedClaudePath;
|
|
907
916
|
});
|
|
908
917
|
var Config = Effect10.gen(function* () {
|
|
909
918
|
const claudeCodeExecutablePath = yield* resolveClaudeCodePath;
|
|
@@ -1293,7 +1302,7 @@ var ClaudeCodePermissionController = class extends Context12.Tag(
|
|
|
1293
1302
|
};
|
|
1294
1303
|
|
|
1295
1304
|
// src/server/core/claude-code/presentation/ClaudeCodeSessionProcessController.ts
|
|
1296
|
-
import { Context as Context19, Effect as
|
|
1305
|
+
import { Context as Context19, Effect as Effect24, Layer as Layer21 } from "effect";
|
|
1297
1306
|
|
|
1298
1307
|
// src/server/core/platform/services/UserConfigService.ts
|
|
1299
1308
|
import { Context as Context13, Effect as Effect16, Layer as Layer15, Ref as Ref5 } from "effect";
|
|
@@ -1376,7 +1385,7 @@ var UserConfigService = class extends Context13.Tag("UserConfigService")() {
|
|
|
1376
1385
|
};
|
|
1377
1386
|
|
|
1378
1387
|
// src/server/core/claude-code/services/ClaudeCodeLifeCycleService.ts
|
|
1379
|
-
import { Context as Context18, Effect as
|
|
1388
|
+
import { Context as Context18, Effect as Effect23, Layer as Layer20, Runtime as Runtime2 } from "effect";
|
|
1380
1389
|
import { ulid as ulid2 } from "ulid";
|
|
1381
1390
|
|
|
1382
1391
|
// src/lib/controllablePromise.ts
|
|
@@ -1406,8 +1415,8 @@ var controllablePromise = () => {
|
|
|
1406
1415
|
};
|
|
1407
1416
|
|
|
1408
1417
|
// src/server/core/session/infrastructure/SessionRepository.ts
|
|
1409
|
-
import { FileSystem as
|
|
1410
|
-
import { Context as Context16, Effect as
|
|
1418
|
+
import { FileSystem as FileSystem9, Path as Path11 } from "@effect/platform";
|
|
1419
|
+
import { Context as Context16, Effect as Effect20, Layer as Layer18, Option as Option3 } from "effect";
|
|
1411
1420
|
|
|
1412
1421
|
// src/server/core/claude-code/functions/parseUserMessage.ts
|
|
1413
1422
|
import { z as z21 } from "zod";
|
|
@@ -1544,8 +1553,8 @@ var VirtualConversationDatabase = class extends Context14.Tag(
|
|
|
1544
1553
|
};
|
|
1545
1554
|
|
|
1546
1555
|
// src/server/core/session/services/SessionMetaService.ts
|
|
1547
|
-
import { FileSystem as
|
|
1548
|
-
import { Context as Context15, Effect as
|
|
1556
|
+
import { FileSystem as FileSystem8, Path as Path10 } from "@effect/platform";
|
|
1557
|
+
import { Context as Context15, Effect as Effect19, Layer as Layer17, Ref as Ref7 } from "effect";
|
|
1549
1558
|
|
|
1550
1559
|
// src/server/core/session/constants/pricing.ts
|
|
1551
1560
|
var MODEL_PRICING = {
|
|
@@ -1638,6 +1647,111 @@ function calculateTokenCost(usage, modelName) {
|
|
|
1638
1647
|
};
|
|
1639
1648
|
}
|
|
1640
1649
|
|
|
1650
|
+
// src/server/core/session/functions/aggregateTokenUsageAndCost.ts
|
|
1651
|
+
var aggregateTokenUsageAndCost = (fileContents) => {
|
|
1652
|
+
let totalInputTokens = 0;
|
|
1653
|
+
let totalOutputTokens = 0;
|
|
1654
|
+
let totalCacheCreationTokens = 0;
|
|
1655
|
+
let totalCacheReadTokens = 0;
|
|
1656
|
+
let totalInputTokensUsd = 0;
|
|
1657
|
+
let totalOutputTokensUsd = 0;
|
|
1658
|
+
let totalCacheCreationUsd = 0;
|
|
1659
|
+
let totalCacheReadUsd = 0;
|
|
1660
|
+
let lastModelName = "claude-3.5-sonnet";
|
|
1661
|
+
for (const content of fileContents) {
|
|
1662
|
+
const conversations = parseJsonl(content);
|
|
1663
|
+
for (const conversation of conversations) {
|
|
1664
|
+
if (conversation.type === "assistant") {
|
|
1665
|
+
const usage = conversation.message.usage;
|
|
1666
|
+
const modelName = conversation.message.model;
|
|
1667
|
+
const messageCost = calculateTokenCost(
|
|
1668
|
+
{
|
|
1669
|
+
input_tokens: usage.input_tokens,
|
|
1670
|
+
output_tokens: usage.output_tokens,
|
|
1671
|
+
cache_creation_input_tokens: usage.cache_creation_input_tokens ?? 0,
|
|
1672
|
+
cache_read_input_tokens: usage.cache_read_input_tokens ?? 0
|
|
1673
|
+
},
|
|
1674
|
+
modelName
|
|
1675
|
+
);
|
|
1676
|
+
totalInputTokens += usage.input_tokens;
|
|
1677
|
+
totalOutputTokens += usage.output_tokens;
|
|
1678
|
+
totalCacheCreationTokens += usage.cache_creation_input_tokens ?? 0;
|
|
1679
|
+
totalCacheReadTokens += usage.cache_read_input_tokens ?? 0;
|
|
1680
|
+
totalInputTokensUsd += messageCost.breakdown.inputTokensUsd;
|
|
1681
|
+
totalOutputTokensUsd += messageCost.breakdown.outputTokensUsd;
|
|
1682
|
+
totalCacheCreationUsd += messageCost.breakdown.cacheCreationUsd;
|
|
1683
|
+
totalCacheReadUsd += messageCost.breakdown.cacheReadUsd;
|
|
1684
|
+
lastModelName = modelName;
|
|
1685
|
+
}
|
|
1686
|
+
}
|
|
1687
|
+
}
|
|
1688
|
+
const totalCost = {
|
|
1689
|
+
totalUsd: totalInputTokensUsd + totalOutputTokensUsd + totalCacheCreationUsd + totalCacheReadUsd,
|
|
1690
|
+
breakdown: {
|
|
1691
|
+
inputTokensUsd: totalInputTokensUsd,
|
|
1692
|
+
outputTokensUsd: totalOutputTokensUsd,
|
|
1693
|
+
cacheCreationUsd: totalCacheCreationUsd,
|
|
1694
|
+
cacheReadUsd: totalCacheReadUsd
|
|
1695
|
+
},
|
|
1696
|
+
tokenUsage: {
|
|
1697
|
+
inputTokens: totalInputTokens,
|
|
1698
|
+
outputTokens: totalOutputTokens,
|
|
1699
|
+
cacheCreationTokens: totalCacheCreationTokens,
|
|
1700
|
+
cacheReadTokens: totalCacheReadTokens
|
|
1701
|
+
}
|
|
1702
|
+
};
|
|
1703
|
+
const aggregatedUsage = {
|
|
1704
|
+
input_tokens: totalInputTokens,
|
|
1705
|
+
output_tokens: totalOutputTokens,
|
|
1706
|
+
cache_creation_input_tokens: totalCacheCreationTokens,
|
|
1707
|
+
cache_read_input_tokens: totalCacheReadTokens
|
|
1708
|
+
};
|
|
1709
|
+
return {
|
|
1710
|
+
totalUsage: aggregatedUsage,
|
|
1711
|
+
totalCost,
|
|
1712
|
+
modelName: lastModelName
|
|
1713
|
+
};
|
|
1714
|
+
};
|
|
1715
|
+
|
|
1716
|
+
// src/server/core/session/functions/getAgentSessionFilesForSession.ts
|
|
1717
|
+
import { FileSystem as FileSystem7, Path as Path9 } from "@effect/platform";
|
|
1718
|
+
import { Effect as Effect18 } from "effect";
|
|
1719
|
+
var getAgentSessionFilesForSession = (projectPath, sessionId) => Effect18.gen(function* () {
|
|
1720
|
+
const fs = yield* FileSystem7.FileSystem;
|
|
1721
|
+
const path = yield* Path9.Path;
|
|
1722
|
+
const entries = yield* fs.readDirectory(projectPath);
|
|
1723
|
+
const agentFiles = entries.filter(
|
|
1724
|
+
(filename) => filename.startsWith("agent-") && filename.endsWith(".jsonl")
|
|
1725
|
+
);
|
|
1726
|
+
const matchingFilePaths = [];
|
|
1727
|
+
for (const agentFile of agentFiles) {
|
|
1728
|
+
const filePath = path.join(projectPath, agentFile);
|
|
1729
|
+
const maybeMatches = yield* Effect18.gen(function* () {
|
|
1730
|
+
const content = yield* fs.readFileString(filePath);
|
|
1731
|
+
const firstLine = content.split("\n")[0];
|
|
1732
|
+
if (!firstLine || firstLine.trim() === "") {
|
|
1733
|
+
return false;
|
|
1734
|
+
}
|
|
1735
|
+
try {
|
|
1736
|
+
const firstLineData = JSON.parse(firstLine);
|
|
1737
|
+
if (typeof firstLineData === "object" && firstLineData !== null && "sessionId" in firstLineData && firstLineData.sessionId === sessionId) {
|
|
1738
|
+
return true;
|
|
1739
|
+
}
|
|
1740
|
+
} catch {
|
|
1741
|
+
return false;
|
|
1742
|
+
}
|
|
1743
|
+
return false;
|
|
1744
|
+
}).pipe(
|
|
1745
|
+
Effect18.catchAll(() => Effect18.succeed(false))
|
|
1746
|
+
// On any error, skip this file
|
|
1747
|
+
);
|
|
1748
|
+
if (maybeMatches) {
|
|
1749
|
+
matchingFilePaths.push(filePath);
|
|
1750
|
+
}
|
|
1751
|
+
}
|
|
1752
|
+
return matchingFilePaths;
|
|
1753
|
+
});
|
|
1754
|
+
|
|
1641
1755
|
// src/server/core/session/functions/extractFirstUserText.ts
|
|
1642
1756
|
var extractFirstUserText = (conversation) => {
|
|
1643
1757
|
if (conversation.type !== "user") {
|
|
@@ -1695,13 +1809,14 @@ var SessionMetaService = class extends Context15.Tag("SessionMetaService")() {
|
|
|
1695
1809
|
static {
|
|
1696
1810
|
this.Live = Layer17.effect(
|
|
1697
1811
|
this,
|
|
1698
|
-
|
|
1699
|
-
const fs = yield*
|
|
1812
|
+
Effect19.gen(function* () {
|
|
1813
|
+
const fs = yield* FileSystem8.FileSystem;
|
|
1814
|
+
const path = yield* Path10.Path;
|
|
1700
1815
|
const firstUserMessageCache = yield* FileCacheStorage();
|
|
1701
1816
|
const sessionMetaCacheRef = yield* Ref7.make(
|
|
1702
1817
|
/* @__PURE__ */ new Map()
|
|
1703
1818
|
);
|
|
1704
|
-
const getFirstUserMessage = (jsonlFilePath, lines) =>
|
|
1819
|
+
const getFirstUserMessage = (jsonlFilePath, lines) => Effect19.gen(function* () {
|
|
1705
1820
|
const cached = yield* firstUserMessageCache.get(jsonlFilePath);
|
|
1706
1821
|
if (cached !== void 0) {
|
|
1707
1822
|
return cached;
|
|
@@ -1724,69 +1839,7 @@ var SessionMetaService = class extends Context15.Tag("SessionMetaService")() {
|
|
|
1724
1839
|
}
|
|
1725
1840
|
return firstUserMessage;
|
|
1726
1841
|
});
|
|
1727
|
-
const
|
|
1728
|
-
let totalInputTokens = 0;
|
|
1729
|
-
let totalOutputTokens = 0;
|
|
1730
|
-
let totalCacheCreationTokens = 0;
|
|
1731
|
-
let totalCacheReadTokens = 0;
|
|
1732
|
-
let totalInputTokensUsd = 0;
|
|
1733
|
-
let totalOutputTokensUsd = 0;
|
|
1734
|
-
let totalCacheCreationUsd = 0;
|
|
1735
|
-
let totalCacheReadUsd = 0;
|
|
1736
|
-
let lastModelName = "claude-3.5-sonnet";
|
|
1737
|
-
const conversations = parseJsonl(content);
|
|
1738
|
-
for (const conversation of conversations) {
|
|
1739
|
-
if (conversation.type === "assistant") {
|
|
1740
|
-
const usage = conversation.message.usage;
|
|
1741
|
-
const modelName = conversation.message.model;
|
|
1742
|
-
const messageCost = calculateTokenCost(
|
|
1743
|
-
{
|
|
1744
|
-
input_tokens: usage.input_tokens,
|
|
1745
|
-
output_tokens: usage.output_tokens,
|
|
1746
|
-
cache_creation_input_tokens: usage.cache_creation_input_tokens ?? 0,
|
|
1747
|
-
cache_read_input_tokens: usage.cache_read_input_tokens ?? 0
|
|
1748
|
-
},
|
|
1749
|
-
modelName
|
|
1750
|
-
);
|
|
1751
|
-
totalInputTokens += usage.input_tokens;
|
|
1752
|
-
totalOutputTokens += usage.output_tokens;
|
|
1753
|
-
totalCacheCreationTokens += usage.cache_creation_input_tokens ?? 0;
|
|
1754
|
-
totalCacheReadTokens += usage.cache_read_input_tokens ?? 0;
|
|
1755
|
-
totalInputTokensUsd += messageCost.breakdown.inputTokensUsd;
|
|
1756
|
-
totalOutputTokensUsd += messageCost.breakdown.outputTokensUsd;
|
|
1757
|
-
totalCacheCreationUsd += messageCost.breakdown.cacheCreationUsd;
|
|
1758
|
-
totalCacheReadUsd += messageCost.breakdown.cacheReadUsd;
|
|
1759
|
-
lastModelName = modelName;
|
|
1760
|
-
}
|
|
1761
|
-
}
|
|
1762
|
-
const totalCost = {
|
|
1763
|
-
totalUsd: totalInputTokensUsd + totalOutputTokensUsd + totalCacheCreationUsd + totalCacheReadUsd,
|
|
1764
|
-
breakdown: {
|
|
1765
|
-
inputTokensUsd: totalInputTokensUsd,
|
|
1766
|
-
outputTokensUsd: totalOutputTokensUsd,
|
|
1767
|
-
cacheCreationUsd: totalCacheCreationUsd,
|
|
1768
|
-
cacheReadUsd: totalCacheReadUsd
|
|
1769
|
-
},
|
|
1770
|
-
tokenUsage: {
|
|
1771
|
-
inputTokens: totalInputTokens,
|
|
1772
|
-
outputTokens: totalOutputTokens,
|
|
1773
|
-
cacheCreationTokens: totalCacheCreationTokens,
|
|
1774
|
-
cacheReadTokens: totalCacheReadTokens
|
|
1775
|
-
}
|
|
1776
|
-
};
|
|
1777
|
-
const aggregatedUsage = {
|
|
1778
|
-
input_tokens: totalInputTokens,
|
|
1779
|
-
output_tokens: totalOutputTokens,
|
|
1780
|
-
cache_creation_input_tokens: totalCacheCreationTokens,
|
|
1781
|
-
cache_read_input_tokens: totalCacheReadTokens
|
|
1782
|
-
};
|
|
1783
|
-
return {
|
|
1784
|
-
totalUsage: aggregatedUsage,
|
|
1785
|
-
totalCost,
|
|
1786
|
-
modelName: lastModelName
|
|
1787
|
-
};
|
|
1788
|
-
};
|
|
1789
|
-
const getSessionMeta = (projectId, sessionId) => Effect18.gen(function* () {
|
|
1842
|
+
const getSessionMeta = (projectId, sessionId) => Effect19.gen(function* () {
|
|
1790
1843
|
const metaCache = yield* Ref7.get(sessionMetaCacheRef);
|
|
1791
1844
|
const cached = metaCache.get(sessionId);
|
|
1792
1845
|
if (cached !== void 0) {
|
|
@@ -1799,7 +1852,34 @@ var SessionMetaService = class extends Context15.Tag("SessionMetaService")() {
|
|
|
1799
1852
|
sessionPath,
|
|
1800
1853
|
lines
|
|
1801
1854
|
);
|
|
1802
|
-
const
|
|
1855
|
+
const projectPath = path.dirname(sessionPath);
|
|
1856
|
+
const firstLine = lines[0];
|
|
1857
|
+
let actualSessionId;
|
|
1858
|
+
if (firstLine && firstLine.trim() !== "") {
|
|
1859
|
+
try {
|
|
1860
|
+
const firstLineData = JSON.parse(firstLine);
|
|
1861
|
+
if (typeof firstLineData === "object" && firstLineData !== null && "sessionId" in firstLineData && typeof firstLineData.sessionId === "string") {
|
|
1862
|
+
actualSessionId = firstLineData.sessionId;
|
|
1863
|
+
}
|
|
1864
|
+
} catch {
|
|
1865
|
+
}
|
|
1866
|
+
}
|
|
1867
|
+
const agentFilePaths = actualSessionId !== void 0 ? yield* getAgentSessionFilesForSession(
|
|
1868
|
+
projectPath,
|
|
1869
|
+
actualSessionId
|
|
1870
|
+
).pipe(
|
|
1871
|
+
Effect19.provide(Layer17.succeed(FileSystem8.FileSystem, fs)),
|
|
1872
|
+
Effect19.provide(Layer17.succeed(Path10.Path, path))
|
|
1873
|
+
) : [];
|
|
1874
|
+
const agentContents = [];
|
|
1875
|
+
for (const agentPath of agentFilePaths) {
|
|
1876
|
+
const agentContent = yield* fs.readFileString(agentPath).pipe(Effect19.catchAll(() => Effect19.succeed("")));
|
|
1877
|
+
if (agentContent !== "") {
|
|
1878
|
+
agentContents.push(agentContent);
|
|
1879
|
+
}
|
|
1880
|
+
}
|
|
1881
|
+
const fileContents = [content, ...agentContents];
|
|
1882
|
+
const { totalCost } = aggregateTokenUsageAndCost(fileContents);
|
|
1803
1883
|
const sessionMeta = {
|
|
1804
1884
|
messageCount: lines.length,
|
|
1805
1885
|
firstUserMessage,
|
|
@@ -1815,7 +1895,7 @@ var SessionMetaService = class extends Context15.Tag("SessionMetaService")() {
|
|
|
1815
1895
|
});
|
|
1816
1896
|
return sessionMeta;
|
|
1817
1897
|
});
|
|
1818
|
-
const invalidateSession = (_projectId, sessionId) =>
|
|
1898
|
+
const invalidateSession = (_projectId, sessionId) => Effect19.gen(function* () {
|
|
1819
1899
|
yield* Ref7.update(sessionMetaCacheRef, (cache) => {
|
|
1820
1900
|
cache.delete(sessionId);
|
|
1821
1901
|
return cache;
|
|
@@ -1839,18 +1919,18 @@ var SessionMetaService = class extends Context15.Tag("SessionMetaService")() {
|
|
|
1839
1919
|
};
|
|
1840
1920
|
|
|
1841
1921
|
// src/server/core/session/infrastructure/SessionRepository.ts
|
|
1842
|
-
var LayerImpl13 =
|
|
1843
|
-
const fs = yield*
|
|
1844
|
-
const path = yield*
|
|
1922
|
+
var LayerImpl13 = Effect20.gen(function* () {
|
|
1923
|
+
const fs = yield* FileSystem9.FileSystem;
|
|
1924
|
+
const path = yield* Path11.Path;
|
|
1845
1925
|
const sessionMetaService = yield* SessionMetaService;
|
|
1846
1926
|
const virtualConversationDatabase = yield* VirtualConversationDatabase;
|
|
1847
|
-
const getSession = (projectId, sessionId) =>
|
|
1927
|
+
const getSession = (projectId, sessionId) => Effect20.gen(function* () {
|
|
1848
1928
|
const sessionPath = decodeSessionId(projectId, sessionId);
|
|
1849
1929
|
const virtualConversation = yield* virtualConversationDatabase.getSessionVirtualConversation(
|
|
1850
1930
|
sessionId
|
|
1851
1931
|
);
|
|
1852
1932
|
const exists = yield* fs.exists(sessionPath);
|
|
1853
|
-
const sessionDetail = yield* exists ?
|
|
1933
|
+
const sessionDetail = yield* exists ? Effect20.gen(function* () {
|
|
1854
1934
|
const content = yield* fs.readFileString(sessionPath);
|
|
1855
1935
|
const allLines = content.split("\n").filter((line) => line.trim());
|
|
1856
1936
|
const conversations = parseJsonl(allLines.join("\n"));
|
|
@@ -1888,7 +1968,7 @@ var LayerImpl13 = Effect19.gen(function* () {
|
|
|
1888
1968
|
return sessionDetail2;
|
|
1889
1969
|
}) : (() => {
|
|
1890
1970
|
if (virtualConversation === null) {
|
|
1891
|
-
return
|
|
1971
|
+
return Effect20.succeed(null);
|
|
1892
1972
|
}
|
|
1893
1973
|
const lastConversation = virtualConversation.conversations.filter(
|
|
1894
1974
|
(conversation) => conversation.type === "user" || conversation.type === "assistant" || conversation.type === "system"
|
|
@@ -1918,13 +1998,13 @@ var LayerImpl13 = Effect19.gen(function* () {
|
|
|
1918
1998
|
conversations: virtualConversation.conversations,
|
|
1919
1999
|
lastModifiedAt: lastConversation !== void 0 ? new Date(lastConversation.timestamp) : /* @__PURE__ */ new Date()
|
|
1920
2000
|
};
|
|
1921
|
-
return
|
|
2001
|
+
return Effect20.succeed(virtualSession);
|
|
1922
2002
|
})();
|
|
1923
2003
|
return {
|
|
1924
2004
|
session: sessionDetail
|
|
1925
2005
|
};
|
|
1926
2006
|
});
|
|
1927
|
-
const getSessions = (projectId, options) =>
|
|
2007
|
+
const getSessions = (projectId, options) => Effect20.gen(function* () {
|
|
1928
2008
|
const { maxCount = 20, cursor } = options ?? {};
|
|
1929
2009
|
const claudeProjectPath = decodeProjectId(projectId);
|
|
1930
2010
|
const dirExists = yield* fs.exists(claudeProjectPath);
|
|
@@ -1932,8 +2012,8 @@ var LayerImpl13 = Effect19.gen(function* () {
|
|
|
1932
2012
|
console.warn(`Project directory not found at ${claudeProjectPath}`);
|
|
1933
2013
|
return { sessions: [] };
|
|
1934
2014
|
}
|
|
1935
|
-
const dirents = yield*
|
|
1936
|
-
try: () => fs.readDirectory(claudeProjectPath).pipe(
|
|
2015
|
+
const dirents = yield* Effect20.tryPromise({
|
|
2016
|
+
try: () => fs.readDirectory(claudeProjectPath).pipe(Effect20.runPromise),
|
|
1937
2017
|
catch: (error) => {
|
|
1938
2018
|
console.warn(
|
|
1939
2019
|
`Failed to read sessions for project ${projectId}:`,
|
|
@@ -1941,14 +2021,14 @@ var LayerImpl13 = Effect19.gen(function* () {
|
|
|
1941
2021
|
);
|
|
1942
2022
|
return new Error("Failed to read directory");
|
|
1943
2023
|
}
|
|
1944
|
-
}).pipe(
|
|
2024
|
+
}).pipe(Effect20.catchAll(() => Effect20.succeed([])));
|
|
1945
2025
|
const sessionEffects = dirents.filter(isRegularSessionFile).map(
|
|
1946
|
-
(entry) =>
|
|
2026
|
+
(entry) => Effect20.gen(function* () {
|
|
1947
2027
|
const fullPath = path.resolve(claudeProjectPath, entry);
|
|
1948
2028
|
const sessionId = encodeSessionId(fullPath);
|
|
1949
|
-
const stat = yield*
|
|
1950
|
-
() => fs.stat(fullPath).pipe(
|
|
1951
|
-
).pipe(
|
|
2029
|
+
const stat = yield* Effect20.tryPromise(
|
|
2030
|
+
() => fs.stat(fullPath).pipe(Effect20.runPromise)
|
|
2031
|
+
).pipe(Effect20.catchAll(() => Effect20.succeed(null)));
|
|
1952
2032
|
if (!stat) {
|
|
1953
2033
|
return null;
|
|
1954
2034
|
}
|
|
@@ -1959,7 +2039,7 @@ var LayerImpl13 = Effect19.gen(function* () {
|
|
|
1959
2039
|
};
|
|
1960
2040
|
})
|
|
1961
2041
|
);
|
|
1962
|
-
const sessionsWithNulls = yield*
|
|
2042
|
+
const sessionsWithNulls = yield* Effect20.all(sessionEffects, {
|
|
1963
2043
|
concurrency: "unbounded"
|
|
1964
2044
|
});
|
|
1965
2045
|
const sessions = sessionsWithNulls.filter((s) => s !== null).sort(
|
|
@@ -1974,9 +2054,9 @@ var LayerImpl13 = Effect19.gen(function* () {
|
|
|
1974
2054
|
index + 1,
|
|
1975
2055
|
Math.min(index + 1 + maxCount, sessions.length)
|
|
1976
2056
|
);
|
|
1977
|
-
const sessionsWithMeta2 = yield*
|
|
2057
|
+
const sessionsWithMeta2 = yield* Effect20.all(
|
|
1978
2058
|
sessionsToReturn2.map(
|
|
1979
|
-
(item) =>
|
|
2059
|
+
(item) => Effect20.gen(function* () {
|
|
1980
2060
|
const meta = yield* sessionMetaService.getSessionMeta(
|
|
1981
2061
|
projectId,
|
|
1982
2062
|
item.id
|
|
@@ -2039,9 +2119,9 @@ var LayerImpl13 = Effect19.gen(function* () {
|
|
|
2039
2119
|
0,
|
|
2040
2120
|
Math.min(maxCount, sessions.length)
|
|
2041
2121
|
);
|
|
2042
|
-
const sessionsWithMeta = yield*
|
|
2122
|
+
const sessionsWithMeta = yield* Effect20.all(
|
|
2043
2123
|
sessionsToReturn.map(
|
|
2044
|
-
(item) =>
|
|
2124
|
+
(item) => Effect20.gen(function* () {
|
|
2045
2125
|
const meta = yield* sessionMetaService.getSessionMeta(
|
|
2046
2126
|
projectId,
|
|
2047
2127
|
item.id
|
|
@@ -2165,7 +2245,7 @@ var fallbackSdkMessage = (message) => {
|
|
|
2165
2245
|
};
|
|
2166
2246
|
|
|
2167
2247
|
// src/server/core/claude-code/models/CCSessionProcess.ts
|
|
2168
|
-
import { Effect as
|
|
2248
|
+
import { Effect as Effect21 } from "effect";
|
|
2169
2249
|
var isPublic = (process2) => {
|
|
2170
2250
|
return process2.type === "initialized" || process2.type === "file_created" || process2.type === "paused";
|
|
2171
2251
|
};
|
|
@@ -2176,7 +2256,7 @@ var getAliveTasks = (process2) => {
|
|
|
2176
2256
|
};
|
|
2177
2257
|
var createVirtualConversation = (process2, ctx) => {
|
|
2178
2258
|
const timestamp = (/* @__PURE__ */ new Date()).toISOString();
|
|
2179
|
-
return
|
|
2259
|
+
return Effect21.gen(function* () {
|
|
2180
2260
|
const config = yield* Config;
|
|
2181
2261
|
const virtualConversation = {
|
|
2182
2262
|
type: "user",
|
|
@@ -2198,7 +2278,7 @@ var createVirtualConversation = (process2, ctx) => {
|
|
|
2198
2278
|
};
|
|
2199
2279
|
|
|
2200
2280
|
// src/server/core/claude-code/services/ClaudeCodeSessionProcessService.ts
|
|
2201
|
-
import { Context as Context17, Data as Data3, Effect as
|
|
2281
|
+
import { Context as Context17, Data as Data3, Effect as Effect22, Layer as Layer19, Ref as Ref8 } from "effect";
|
|
2202
2282
|
var SessionProcessNotFoundError = class extends Data3.TaggedError(
|
|
2203
2283
|
"SessionProcessNotFoundError"
|
|
2204
2284
|
) {
|
|
@@ -2217,12 +2297,12 @@ var IllegalStateChangeError = class extends Data3.TaggedError(
|
|
|
2217
2297
|
};
|
|
2218
2298
|
var TaskNotFoundError = class extends Data3.TaggedError("TaskNotFoundError") {
|
|
2219
2299
|
};
|
|
2220
|
-
var LayerImpl14 =
|
|
2300
|
+
var LayerImpl14 = Effect22.gen(function* () {
|
|
2221
2301
|
const processesRef = yield* Ref8.make([]);
|
|
2222
2302
|
const eventBus = yield* EventBus;
|
|
2223
2303
|
const startSessionProcess = (options) => {
|
|
2224
2304
|
const { sessionDef, taskDef } = options;
|
|
2225
|
-
return
|
|
2305
|
+
return Effect22.gen(function* () {
|
|
2226
2306
|
const task = {
|
|
2227
2307
|
def: taskDef,
|
|
2228
2308
|
status: "pending"
|
|
@@ -2245,10 +2325,10 @@ var LayerImpl14 = Effect21.gen(function* () {
|
|
|
2245
2325
|
};
|
|
2246
2326
|
const continueSessionProcess = (options) => {
|
|
2247
2327
|
const { sessionProcessId } = options;
|
|
2248
|
-
return
|
|
2328
|
+
return Effect22.gen(function* () {
|
|
2249
2329
|
const process2 = yield* getSessionProcess(sessionProcessId);
|
|
2250
2330
|
if (process2.type !== "paused") {
|
|
2251
|
-
return yield*
|
|
2331
|
+
return yield* Effect22.fail(
|
|
2252
2332
|
new SessionProcessNotPausedError({
|
|
2253
2333
|
sessionProcessId
|
|
2254
2334
|
})
|
|
@@ -2256,7 +2336,7 @@ var LayerImpl14 = Effect21.gen(function* () {
|
|
|
2256
2336
|
}
|
|
2257
2337
|
const [firstAliveTask] = getAliveTasks(process2);
|
|
2258
2338
|
if (firstAliveTask !== void 0) {
|
|
2259
|
-
return yield*
|
|
2339
|
+
return yield* Effect22.fail(
|
|
2260
2340
|
new SessionProcessAlreadyAliveError({
|
|
2261
2341
|
sessionProcessId,
|
|
2262
2342
|
aliveTaskId: firstAliveTask.def.taskId,
|
|
@@ -2286,13 +2366,13 @@ var LayerImpl14 = Effect21.gen(function* () {
|
|
|
2286
2366
|
});
|
|
2287
2367
|
};
|
|
2288
2368
|
const getSessionProcess = (sessionProcessId) => {
|
|
2289
|
-
return
|
|
2369
|
+
return Effect22.gen(function* () {
|
|
2290
2370
|
const processes = yield* Ref8.get(processesRef);
|
|
2291
2371
|
const result = processes.find(
|
|
2292
2372
|
(p) => p.def.sessionProcessId === sessionProcessId
|
|
2293
2373
|
);
|
|
2294
2374
|
if (result === void 0) {
|
|
2295
|
-
return yield*
|
|
2375
|
+
return yield* Effect22.fail(
|
|
2296
2376
|
new SessionProcessNotFoundError({ sessionProcessId })
|
|
2297
2377
|
);
|
|
2298
2378
|
}
|
|
@@ -2300,13 +2380,13 @@ var LayerImpl14 = Effect21.gen(function* () {
|
|
|
2300
2380
|
});
|
|
2301
2381
|
};
|
|
2302
2382
|
const getSessionProcesses = () => {
|
|
2303
|
-
return
|
|
2383
|
+
return Effect22.gen(function* () {
|
|
2304
2384
|
const processes = yield* Ref8.get(processesRef);
|
|
2305
2385
|
return processes;
|
|
2306
2386
|
});
|
|
2307
2387
|
};
|
|
2308
2388
|
const getTask = (taskId) => {
|
|
2309
|
-
return
|
|
2389
|
+
return Effect22.gen(function* () {
|
|
2310
2390
|
const processes = yield* Ref8.get(processesRef);
|
|
2311
2391
|
const result = processes.flatMap((p) => {
|
|
2312
2392
|
const found = p.tasks.find((t) => t.def.taskId === taskId);
|
|
@@ -2321,14 +2401,14 @@ var LayerImpl14 = Effect21.gen(function* () {
|
|
|
2321
2401
|
];
|
|
2322
2402
|
}).at(0);
|
|
2323
2403
|
if (result === void 0) {
|
|
2324
|
-
return yield*
|
|
2404
|
+
return yield* Effect22.fail(new TaskNotFoundError({ taskId }));
|
|
2325
2405
|
}
|
|
2326
2406
|
return result;
|
|
2327
2407
|
});
|
|
2328
2408
|
};
|
|
2329
2409
|
const dangerouslyChangeProcessState = (options) => {
|
|
2330
2410
|
const { sessionProcessId, nextState } = options;
|
|
2331
|
-
return
|
|
2411
|
+
return Effect22.gen(function* () {
|
|
2332
2412
|
const processes = yield* Ref8.get(processesRef);
|
|
2333
2413
|
const targetProcess = processes.find(
|
|
2334
2414
|
(p) => p.def.sessionProcessId === sessionProcessId
|
|
@@ -2357,7 +2437,7 @@ var LayerImpl14 = Effect21.gen(function* () {
|
|
|
2357
2437
|
};
|
|
2358
2438
|
const changeTaskState = (options) => {
|
|
2359
2439
|
const { sessionProcessId, taskId, nextTask } = options;
|
|
2360
|
-
return
|
|
2440
|
+
return Effect22.gen(function* () {
|
|
2361
2441
|
const { task } = yield* getTask(taskId);
|
|
2362
2442
|
yield* Ref8.update(processesRef, (processes) => {
|
|
2363
2443
|
return processes.map(
|
|
@@ -2378,10 +2458,10 @@ var LayerImpl14 = Effect21.gen(function* () {
|
|
|
2378
2458
|
};
|
|
2379
2459
|
const toNotInitializedState = (options) => {
|
|
2380
2460
|
const { sessionProcessId, rawUserMessage } = options;
|
|
2381
|
-
return
|
|
2461
|
+
return Effect22.gen(function* () {
|
|
2382
2462
|
const currentProcess = yield* getSessionProcess(sessionProcessId);
|
|
2383
2463
|
if (currentProcess.type !== "pending") {
|
|
2384
|
-
return yield*
|
|
2464
|
+
return yield* Effect22.fail(
|
|
2385
2465
|
new IllegalStateChangeError({
|
|
2386
2466
|
from: currentProcess.type,
|
|
2387
2467
|
to: "not_initialized"
|
|
@@ -2414,10 +2494,10 @@ var LayerImpl14 = Effect21.gen(function* () {
|
|
|
2414
2494
|
};
|
|
2415
2495
|
const toInitializedState = (options) => {
|
|
2416
2496
|
const { sessionProcessId, initContext } = options;
|
|
2417
|
-
return
|
|
2497
|
+
return Effect22.gen(function* () {
|
|
2418
2498
|
const currentProcess = yield* getSessionProcess(sessionProcessId);
|
|
2419
2499
|
if (currentProcess.type !== "not_initialized") {
|
|
2420
|
-
return yield*
|
|
2500
|
+
return yield* Effect22.fail(
|
|
2421
2501
|
new IllegalStateChangeError({
|
|
2422
2502
|
from: currentProcess.type,
|
|
2423
2503
|
to: "initialized"
|
|
@@ -2443,10 +2523,10 @@ var LayerImpl14 = Effect21.gen(function* () {
|
|
|
2443
2523
|
};
|
|
2444
2524
|
const toFileCreatedState = (options) => {
|
|
2445
2525
|
const { sessionProcessId } = options;
|
|
2446
|
-
return
|
|
2526
|
+
return Effect22.gen(function* () {
|
|
2447
2527
|
const currentProcess = yield* getSessionProcess(sessionProcessId);
|
|
2448
2528
|
if (currentProcess.type !== "initialized") {
|
|
2449
|
-
return yield*
|
|
2529
|
+
return yield* Effect22.fail(
|
|
2450
2530
|
new IllegalStateChangeError({
|
|
2451
2531
|
from: currentProcess.type,
|
|
2452
2532
|
to: "file_created"
|
|
@@ -2472,10 +2552,10 @@ var LayerImpl14 = Effect21.gen(function* () {
|
|
|
2472
2552
|
};
|
|
2473
2553
|
const toPausedState = (options) => {
|
|
2474
2554
|
const { sessionProcessId, resultMessage } = options;
|
|
2475
|
-
return
|
|
2555
|
+
return Effect22.gen(function* () {
|
|
2476
2556
|
const currentProcess = yield* getSessionProcess(sessionProcessId);
|
|
2477
2557
|
if (currentProcess.type !== "file_created") {
|
|
2478
|
-
return yield*
|
|
2558
|
+
return yield* Effect22.fail(
|
|
2479
2559
|
new IllegalStateChangeError({
|
|
2480
2560
|
from: currentProcess.type,
|
|
2481
2561
|
to: "paused"
|
|
@@ -2509,7 +2589,7 @@ var LayerImpl14 = Effect21.gen(function* () {
|
|
|
2509
2589
|
};
|
|
2510
2590
|
const toCompletedState = (options) => {
|
|
2511
2591
|
const { sessionProcessId, error } = options;
|
|
2512
|
-
return
|
|
2592
|
+
return Effect22.gen(function* () {
|
|
2513
2593
|
const currentProcess = yield* getSessionProcess(sessionProcessId);
|
|
2514
2594
|
const currentTask = currentProcess.type === "not_initialized" || currentProcess.type === "initialized" || currentProcess.type === "file_created" ? currentProcess.currentTask : void 0;
|
|
2515
2595
|
const newTask = currentTask !== void 0 ? error !== void 0 ? {
|
|
@@ -2571,16 +2651,16 @@ var ClaudeCodeSessionProcessService = class extends Context17.Tag(
|
|
|
2571
2651
|
};
|
|
2572
2652
|
|
|
2573
2653
|
// src/server/core/claude-code/services/ClaudeCodeLifeCycleService.ts
|
|
2574
|
-
var LayerImpl15 =
|
|
2654
|
+
var LayerImpl15 = Effect23.gen(function* () {
|
|
2575
2655
|
const eventBusService = yield* EventBus;
|
|
2576
2656
|
const sessionRepository = yield* SessionRepository;
|
|
2577
2657
|
const sessionProcessService = yield* ClaudeCodeSessionProcessService;
|
|
2578
2658
|
const virtualConversationDatabase = yield* VirtualConversationDatabase;
|
|
2579
2659
|
const permissionService = yield* ClaudeCodePermissionService;
|
|
2580
|
-
const runtime = yield*
|
|
2660
|
+
const runtime = yield* Effect23.runtime();
|
|
2581
2661
|
const continueTask = (options) => {
|
|
2582
2662
|
const { sessionProcessId, baseSessionId, input } = options;
|
|
2583
|
-
return
|
|
2663
|
+
return Effect23.gen(function* () {
|
|
2584
2664
|
const { sessionProcess, task } = yield* sessionProcessService.continueSessionProcess({
|
|
2585
2665
|
sessionProcessId,
|
|
2586
2666
|
taskDef: {
|
|
@@ -2608,7 +2688,7 @@ var LayerImpl15 = Effect22.gen(function* () {
|
|
|
2608
2688
|
};
|
|
2609
2689
|
const startTask = (options) => {
|
|
2610
2690
|
const { baseSession, input, userConfig } = options;
|
|
2611
|
-
return
|
|
2691
|
+
return Effect23.gen(function* () {
|
|
2612
2692
|
const {
|
|
2613
2693
|
generateMessages,
|
|
2614
2694
|
setNextMessage,
|
|
@@ -2636,7 +2716,7 @@ var LayerImpl15 = Effect22.gen(function* () {
|
|
|
2636
2716
|
const sessionFileCreatedPromise = controllablePromise();
|
|
2637
2717
|
setMessageGeneratorHooks({
|
|
2638
2718
|
onNewUserMessageResolved: async (input2) => {
|
|
2639
|
-
|
|
2719
|
+
Effect23.runFork(
|
|
2640
2720
|
sessionProcessService.toNotInitializedState({
|
|
2641
2721
|
sessionProcessId: sessionProcess.def.sessionProcessId,
|
|
2642
2722
|
rawUserMessage: input2.text
|
|
@@ -2644,7 +2724,7 @@ var LayerImpl15 = Effect22.gen(function* () {
|
|
|
2644
2724
|
);
|
|
2645
2725
|
}
|
|
2646
2726
|
});
|
|
2647
|
-
const handleMessage = (message) =>
|
|
2727
|
+
const handleMessage = (message) => Effect23.gen(function* () {
|
|
2648
2728
|
const processState = yield* sessionProcessService.getSessionProcess(
|
|
2649
2729
|
sessionProcess.def.sessionProcessId
|
|
2650
2730
|
);
|
|
@@ -2652,7 +2732,7 @@ var LayerImpl15 = Effect22.gen(function* () {
|
|
|
2652
2732
|
return "break";
|
|
2653
2733
|
}
|
|
2654
2734
|
if (processState.type === "paused") {
|
|
2655
|
-
yield*
|
|
2735
|
+
yield* Effect23.die(
|
|
2656
2736
|
new Error("Illegal state: paused is not expected")
|
|
2657
2737
|
);
|
|
2658
2738
|
}
|
|
@@ -2724,7 +2804,7 @@ var LayerImpl15 = Effect22.gen(function* () {
|
|
|
2724
2804
|
});
|
|
2725
2805
|
const handleSessionProcessDaemon = async () => {
|
|
2726
2806
|
const messageIter = await Runtime2.runPromise(runtime)(
|
|
2727
|
-
|
|
2807
|
+
Effect23.gen(function* () {
|
|
2728
2808
|
const permissionOptions = yield* permissionService.createCanUseToolRelatedOptions({
|
|
2729
2809
|
taskId: task.def.taskId,
|
|
2730
2810
|
userConfig,
|
|
@@ -2745,7 +2825,7 @@ var LayerImpl15 = Effect22.gen(function* () {
|
|
|
2745
2825
|
const result = await Runtime2.runPromise(runtime)(
|
|
2746
2826
|
handleMessage(fallbackMessage)
|
|
2747
2827
|
).catch((error) => {
|
|
2748
|
-
|
|
2828
|
+
Effect23.runFork(
|
|
2749
2829
|
sessionProcessService.changeTaskState({
|
|
2750
2830
|
sessionProcessId: sessionProcess.def.sessionProcessId,
|
|
2751
2831
|
taskId: task.def.taskId,
|
|
@@ -2776,7 +2856,7 @@ var LayerImpl15 = Effect22.gen(function* () {
|
|
|
2776
2856
|
if (sessionFileCreatedPromise.status === "pending") {
|
|
2777
2857
|
sessionFileCreatedPromise.reject(error);
|
|
2778
2858
|
}
|
|
2779
|
-
await
|
|
2859
|
+
await Effect23.runPromise(
|
|
2780
2860
|
sessionProcessService.changeTaskState({
|
|
2781
2861
|
sessionProcessId: sessionProcess.def.sessionProcessId,
|
|
2782
2862
|
taskId: task.def.taskId,
|
|
@@ -2799,8 +2879,8 @@ var LayerImpl15 = Effect22.gen(function* () {
|
|
|
2799
2879
|
}
|
|
2800
2880
|
throw error;
|
|
2801
2881
|
}).finally(() => {
|
|
2802
|
-
|
|
2803
|
-
|
|
2882
|
+
Effect23.runFork(
|
|
2883
|
+
Effect23.gen(function* () {
|
|
2804
2884
|
const currentProcess = yield* sessionProcessService.getSessionProcess(
|
|
2805
2885
|
sessionProcess.def.sessionProcessId
|
|
2806
2886
|
);
|
|
@@ -2816,16 +2896,16 @@ var LayerImpl15 = Effect22.gen(function* () {
|
|
|
2816
2896
|
daemonPromise,
|
|
2817
2897
|
awaitSessionInitialized: async () => await sessionInitializedPromise.promise,
|
|
2818
2898
|
awaitSessionFileCreated: async () => await sessionFileCreatedPromise.promise,
|
|
2819
|
-
yieldSessionInitialized: () =>
|
|
2820
|
-
yieldSessionFileCreated: () =>
|
|
2899
|
+
yieldSessionInitialized: () => Effect23.promise(() => sessionInitializedPromise.promise),
|
|
2900
|
+
yieldSessionFileCreated: () => Effect23.promise(() => sessionFileCreatedPromise.promise)
|
|
2821
2901
|
};
|
|
2822
2902
|
});
|
|
2823
2903
|
};
|
|
2824
|
-
const getPublicSessionProcesses = () =>
|
|
2904
|
+
const getPublicSessionProcesses = () => Effect23.gen(function* () {
|
|
2825
2905
|
const processes = yield* sessionProcessService.getSessionProcesses();
|
|
2826
2906
|
return processes.filter((process2) => isPublic(process2));
|
|
2827
2907
|
});
|
|
2828
|
-
const abortTask = (sessionProcessId) =>
|
|
2908
|
+
const abortTask = (sessionProcessId) => Effect23.gen(function* () {
|
|
2829
2909
|
const currentProcess = yield* sessionProcessService.getSessionProcess(sessionProcessId);
|
|
2830
2910
|
currentProcess.def.abortController.abort();
|
|
2831
2911
|
yield* sessionProcessService.toCompletedState({
|
|
@@ -2833,7 +2913,7 @@ var LayerImpl15 = Effect22.gen(function* () {
|
|
|
2833
2913
|
error: new Error("Task aborted")
|
|
2834
2914
|
});
|
|
2835
2915
|
});
|
|
2836
|
-
const abortAllTasks = () =>
|
|
2916
|
+
const abortAllTasks = () => Effect23.gen(function* () {
|
|
2837
2917
|
const processes = yield* sessionProcessService.getSessionProcesses();
|
|
2838
2918
|
for (const process2 of processes) {
|
|
2839
2919
|
yield* sessionProcessService.toCompletedState({
|
|
@@ -2859,11 +2939,11 @@ var ClaudeCodeLifeCycleService = class extends Context18.Tag(
|
|
|
2859
2939
|
};
|
|
2860
2940
|
|
|
2861
2941
|
// src/server/core/claude-code/presentation/ClaudeCodeSessionProcessController.ts
|
|
2862
|
-
var LayerImpl16 =
|
|
2942
|
+
var LayerImpl16 = Effect24.gen(function* () {
|
|
2863
2943
|
const projectRepository = yield* ProjectRepository;
|
|
2864
2944
|
const claudeCodeLifeCycleService = yield* ClaudeCodeLifeCycleService;
|
|
2865
2945
|
const userConfigService = yield* UserConfigService;
|
|
2866
|
-
const getSessionProcesses = () =>
|
|
2946
|
+
const getSessionProcesses = () => Effect24.gen(function* () {
|
|
2867
2947
|
const publicSessionProcesses = yield* claudeCodeLifeCycleService.getPublicSessionProcesses();
|
|
2868
2948
|
return {
|
|
2869
2949
|
response: {
|
|
@@ -2879,7 +2959,7 @@ var LayerImpl16 = Effect23.gen(function* () {
|
|
|
2879
2959
|
status: 200
|
|
2880
2960
|
};
|
|
2881
2961
|
});
|
|
2882
|
-
const createSessionProcess = (options) =>
|
|
2962
|
+
const createSessionProcess = (options) => Effect24.gen(function* () {
|
|
2883
2963
|
const { projectId, input, baseSessionId } = options;
|
|
2884
2964
|
const { project } = yield* projectRepository.getProject(projectId);
|
|
2885
2965
|
const userConfig = yield* userConfigService.getUserConfig();
|
|
@@ -2910,7 +2990,7 @@ var LayerImpl16 = Effect23.gen(function* () {
|
|
|
2910
2990
|
}
|
|
2911
2991
|
};
|
|
2912
2992
|
});
|
|
2913
|
-
const continueSessionProcess = (options) =>
|
|
2993
|
+
const continueSessionProcess = (options) => Effect24.gen(function* () {
|
|
2914
2994
|
const { projectId, input, baseSessionId, sessionProcessId } = options;
|
|
2915
2995
|
const { project } = yield* projectRepository.getProject(projectId);
|
|
2916
2996
|
if (project.meta.projectPath === null) {
|
|
@@ -2950,7 +3030,7 @@ var ClaudeCodeSessionProcessController = class extends Context19.Tag(
|
|
|
2950
3030
|
};
|
|
2951
3031
|
|
|
2952
3032
|
// src/server/core/events/presentation/SSEController.ts
|
|
2953
|
-
import { Context as Context21, Effect as
|
|
3033
|
+
import { Context as Context21, Effect as Effect26, Layer as Layer23 } from "effect";
|
|
2954
3034
|
|
|
2955
3035
|
// src/server/core/events/functions/adaptInternalEventToSSE.ts
|
|
2956
3036
|
var adaptInternalEventToSSE = (rawStream, options) => {
|
|
@@ -2977,12 +3057,12 @@ var adaptInternalEventToSSE = (rawStream, options) => {
|
|
|
2977
3057
|
};
|
|
2978
3058
|
|
|
2979
3059
|
// src/server/core/events/functions/typeSafeSSE.ts
|
|
2980
|
-
import { Context as Context20, Effect as
|
|
3060
|
+
import { Context as Context20, Effect as Effect25, Layer as Layer22 } from "effect";
|
|
2981
3061
|
import { ulid as ulid3 } from "ulid";
|
|
2982
3062
|
var TypeSafeSSE = class extends Context20.Tag("TypeSafeSSE")() {
|
|
2983
3063
|
static {
|
|
2984
3064
|
this.make = (stream) => Layer22.succeed(this, {
|
|
2985
|
-
writeSSE: (event, data) =>
|
|
3065
|
+
writeSSE: (event, data) => Effect25.tryPromise({
|
|
2986
3066
|
try: async () => {
|
|
2987
3067
|
const id = ulid3();
|
|
2988
3068
|
await stream.writeSSE({
|
|
@@ -3007,29 +3087,29 @@ var TypeSafeSSE = class extends Context20.Tag("TypeSafeSSE")() {
|
|
|
3007
3087
|
};
|
|
3008
3088
|
|
|
3009
3089
|
// src/server/core/events/presentation/SSEController.ts
|
|
3010
|
-
var LayerImpl17 =
|
|
3090
|
+
var LayerImpl17 = Effect26.gen(function* () {
|
|
3011
3091
|
const eventBus = yield* EventBus;
|
|
3012
|
-
const handleSSE = (rawStream) =>
|
|
3092
|
+
const handleSSE = (rawStream) => Effect26.gen(function* () {
|
|
3013
3093
|
const typeSafeSSE = yield* TypeSafeSSE;
|
|
3014
3094
|
yield* typeSafeSSE.writeSSE("connect", {
|
|
3015
3095
|
timestamp: (/* @__PURE__ */ new Date()).toISOString()
|
|
3016
3096
|
});
|
|
3017
3097
|
const onHeartbeat = () => {
|
|
3018
|
-
|
|
3098
|
+
Effect26.runFork(
|
|
3019
3099
|
typeSafeSSE.writeSSE("heartbeat", {
|
|
3020
3100
|
timestamp: (/* @__PURE__ */ new Date()).toISOString()
|
|
3021
3101
|
})
|
|
3022
3102
|
);
|
|
3023
3103
|
};
|
|
3024
3104
|
const onSessionListChanged = (event) => {
|
|
3025
|
-
|
|
3105
|
+
Effect26.runFork(
|
|
3026
3106
|
typeSafeSSE.writeSSE("sessionListChanged", {
|
|
3027
3107
|
projectId: event.projectId
|
|
3028
3108
|
})
|
|
3029
3109
|
);
|
|
3030
3110
|
};
|
|
3031
3111
|
const onSessionChanged = (event) => {
|
|
3032
|
-
|
|
3112
|
+
Effect26.runFork(
|
|
3033
3113
|
typeSafeSSE.writeSSE("sessionChanged", {
|
|
3034
3114
|
projectId: event.projectId,
|
|
3035
3115
|
sessionId: event.sessionId
|
|
@@ -3037,7 +3117,7 @@ var LayerImpl17 = Effect25.gen(function* () {
|
|
|
3037
3117
|
);
|
|
3038
3118
|
};
|
|
3039
3119
|
const onAgentSessionChanged = (event) => {
|
|
3040
|
-
|
|
3120
|
+
Effect26.runFork(
|
|
3041
3121
|
typeSafeSSE.writeSSE("agentSessionChanged", {
|
|
3042
3122
|
projectId: event.projectId,
|
|
3043
3123
|
agentSessionId: event.agentSessionId
|
|
@@ -3045,14 +3125,14 @@ var LayerImpl17 = Effect25.gen(function* () {
|
|
|
3045
3125
|
);
|
|
3046
3126
|
};
|
|
3047
3127
|
const onSessionProcessChanged = (event) => {
|
|
3048
|
-
|
|
3128
|
+
Effect26.runFork(
|
|
3049
3129
|
typeSafeSSE.writeSSE("sessionProcessChanged", {
|
|
3050
3130
|
processes: event.processes
|
|
3051
3131
|
})
|
|
3052
3132
|
);
|
|
3053
3133
|
};
|
|
3054
3134
|
const onPermissionRequested = (event) => {
|
|
3055
|
-
|
|
3135
|
+
Effect26.runFork(
|
|
3056
3136
|
typeSafeSSE.writeSSE("permissionRequested", {
|
|
3057
3137
|
permissionRequest: event.permissionRequest
|
|
3058
3138
|
})
|
|
@@ -3067,8 +3147,8 @@ var LayerImpl17 = Effect25.gen(function* () {
|
|
|
3067
3147
|
const { connectionPromise } = adaptInternalEventToSSE(rawStream, {
|
|
3068
3148
|
timeout: 5 * 60 * 1e3,
|
|
3069
3149
|
cleanUp: async () => {
|
|
3070
|
-
await
|
|
3071
|
-
|
|
3150
|
+
await Effect26.runPromise(
|
|
3151
|
+
Effect26.gen(function* () {
|
|
3072
3152
|
yield* eventBus.off("sessionListChanged", onSessionListChanged);
|
|
3073
3153
|
yield* eventBus.off("sessionChanged", onSessionChanged);
|
|
3074
3154
|
yield* eventBus.off("agentSessionChanged", onAgentSessionChanged);
|
|
@@ -3082,7 +3162,7 @@ var LayerImpl17 = Effect25.gen(function* () {
|
|
|
3082
3162
|
);
|
|
3083
3163
|
}
|
|
3084
3164
|
});
|
|
3085
|
-
yield*
|
|
3165
|
+
yield* Effect26.promise(() => connectionPromise);
|
|
3086
3166
|
});
|
|
3087
3167
|
return {
|
|
3088
3168
|
handleSSE
|
|
@@ -3096,8 +3176,8 @@ var SSEController = class extends Context21.Tag("SSEController")() {
|
|
|
3096
3176
|
|
|
3097
3177
|
// src/server/core/events/services/fileWatcher.ts
|
|
3098
3178
|
import { watch } from "node:fs";
|
|
3099
|
-
import { Path as
|
|
3100
|
-
import { Context as Context22, Effect as
|
|
3179
|
+
import { Path as Path12 } from "@effect/platform";
|
|
3180
|
+
import { Context as Context22, Effect as Effect27, Layer as Layer24, Ref as Ref9 } from "effect";
|
|
3101
3181
|
|
|
3102
3182
|
// src/server/core/events/functions/parseSessionFilePath.ts
|
|
3103
3183
|
import z22 from "zod";
|
|
@@ -3138,8 +3218,8 @@ var FileWatcherService = class extends Context22.Tag("FileWatcherService")() {
|
|
|
3138
3218
|
static {
|
|
3139
3219
|
this.Live = Layer24.effect(
|
|
3140
3220
|
this,
|
|
3141
|
-
|
|
3142
|
-
const path = yield*
|
|
3221
|
+
Effect27.gen(function* () {
|
|
3222
|
+
const path = yield* Path12.Path;
|
|
3143
3223
|
const eventBus = yield* EventBus;
|
|
3144
3224
|
const context = yield* ApplicationContext;
|
|
3145
3225
|
const isWatchingRef = yield* Ref9.make(false);
|
|
@@ -3148,11 +3228,11 @@ var FileWatcherService = class extends Context22.Tag("FileWatcherService")() {
|
|
|
3148
3228
|
/* @__PURE__ */ new Map()
|
|
3149
3229
|
);
|
|
3150
3230
|
const debounceTimersRef = yield* Ref9.make(/* @__PURE__ */ new Map());
|
|
3151
|
-
const startWatching = () =>
|
|
3231
|
+
const startWatching = () => Effect27.gen(function* () {
|
|
3152
3232
|
const isWatching = yield* Ref9.get(isWatchingRef);
|
|
3153
3233
|
if (isWatching) return;
|
|
3154
3234
|
yield* Ref9.set(isWatchingRef, true);
|
|
3155
|
-
yield*
|
|
3235
|
+
yield* Effect27.tryPromise({
|
|
3156
3236
|
try: async () => {
|
|
3157
3237
|
console.log(
|
|
3158
3238
|
"Starting file watcher on:",
|
|
@@ -3171,8 +3251,8 @@ var FileWatcherService = class extends Context22.Tag("FileWatcherService")() {
|
|
|
3171
3251
|
);
|
|
3172
3252
|
const encodedProjectId = encodeProjectIdFromSessionFilePath(fullPath);
|
|
3173
3253
|
const debounceKey = fileMatch.type === "agent" ? `${encodedProjectId}/agent-${fileMatch.agentSessionId}` : `${encodedProjectId}/${fileMatch.sessionId}`;
|
|
3174
|
-
|
|
3175
|
-
|
|
3254
|
+
Effect27.runPromise(
|
|
3255
|
+
Effect27.gen(function* () {
|
|
3176
3256
|
const timers = yield* Ref9.get(debounceTimersRef);
|
|
3177
3257
|
const existingTimer = timers.get(debounceKey);
|
|
3178
3258
|
if (existingTimer) {
|
|
@@ -3180,27 +3260,27 @@ var FileWatcherService = class extends Context22.Tag("FileWatcherService")() {
|
|
|
3180
3260
|
}
|
|
3181
3261
|
const newTimer = setTimeout(() => {
|
|
3182
3262
|
if (fileMatch.type === "agent") {
|
|
3183
|
-
|
|
3263
|
+
Effect27.runFork(
|
|
3184
3264
|
eventBus.emit("agentSessionChanged", {
|
|
3185
3265
|
projectId: encodedProjectId,
|
|
3186
3266
|
agentSessionId: fileMatch.agentSessionId
|
|
3187
3267
|
})
|
|
3188
3268
|
);
|
|
3189
3269
|
} else {
|
|
3190
|
-
|
|
3270
|
+
Effect27.runFork(
|
|
3191
3271
|
eventBus.emit("sessionChanged", {
|
|
3192
3272
|
projectId: encodedProjectId,
|
|
3193
3273
|
sessionId: fileMatch.sessionId
|
|
3194
3274
|
})
|
|
3195
3275
|
);
|
|
3196
|
-
|
|
3276
|
+
Effect27.runFork(
|
|
3197
3277
|
eventBus.emit("sessionListChanged", {
|
|
3198
3278
|
projectId: encodedProjectId
|
|
3199
3279
|
})
|
|
3200
3280
|
);
|
|
3201
3281
|
}
|
|
3202
|
-
|
|
3203
|
-
|
|
3282
|
+
Effect27.runPromise(
|
|
3283
|
+
Effect27.gen(function* () {
|
|
3204
3284
|
const currentTimers = yield* Ref9.get(debounceTimersRef);
|
|
3205
3285
|
currentTimers.delete(debounceKey);
|
|
3206
3286
|
yield* Ref9.set(debounceTimersRef, currentTimers);
|
|
@@ -3213,7 +3293,7 @@ var FileWatcherService = class extends Context22.Tag("FileWatcherService")() {
|
|
|
3213
3293
|
);
|
|
3214
3294
|
}
|
|
3215
3295
|
);
|
|
3216
|
-
await
|
|
3296
|
+
await Effect27.runPromise(Ref9.set(watcherRef, watcher));
|
|
3217
3297
|
console.log("File watcher initialization completed");
|
|
3218
3298
|
},
|
|
3219
3299
|
catch: (error) => {
|
|
@@ -3224,10 +3304,10 @@ var FileWatcherService = class extends Context22.Tag("FileWatcherService")() {
|
|
|
3224
3304
|
}
|
|
3225
3305
|
}).pipe(
|
|
3226
3306
|
// エラーが発生しても続行する
|
|
3227
|
-
|
|
3307
|
+
Effect27.catchAll(() => Effect27.void)
|
|
3228
3308
|
);
|
|
3229
3309
|
});
|
|
3230
|
-
const stop = () =>
|
|
3310
|
+
const stop = () => Effect27.gen(function* () {
|
|
3231
3311
|
const timers = yield* Ref9.get(debounceTimersRef);
|
|
3232
3312
|
for (const [, timer] of timers) {
|
|
3233
3313
|
clearTimeout(timer);
|
|
@@ -3235,12 +3315,12 @@ var FileWatcherService = class extends Context22.Tag("FileWatcherService")() {
|
|
|
3235
3315
|
yield* Ref9.set(debounceTimersRef, /* @__PURE__ */ new Map());
|
|
3236
3316
|
const watcher = yield* Ref9.get(watcherRef);
|
|
3237
3317
|
if (watcher) {
|
|
3238
|
-
yield*
|
|
3318
|
+
yield* Effect27.sync(() => watcher.close());
|
|
3239
3319
|
yield* Ref9.set(watcherRef, null);
|
|
3240
3320
|
}
|
|
3241
3321
|
const projectWatchers = yield* Ref9.get(projectWatchersRef);
|
|
3242
3322
|
for (const [, projectWatcher] of projectWatchers) {
|
|
3243
|
-
yield*
|
|
3323
|
+
yield* Effect27.sync(() => projectWatcher.close());
|
|
3244
3324
|
}
|
|
3245
3325
|
yield* Ref9.set(projectWatchersRef, /* @__PURE__ */ new Map());
|
|
3246
3326
|
yield* Ref9.set(isWatchingRef, false);
|
|
@@ -3255,10 +3335,10 @@ var FileWatcherService = class extends Context22.Tag("FileWatcherService")() {
|
|
|
3255
3335
|
};
|
|
3256
3336
|
|
|
3257
3337
|
// src/server/core/feature-flag/presentation/FeatureFlagController.ts
|
|
3258
|
-
import { Context as Context23, Effect as
|
|
3259
|
-
var LayerImpl18 =
|
|
3338
|
+
import { Context as Context23, Effect as Effect28, Layer as Layer25 } from "effect";
|
|
3339
|
+
var LayerImpl18 = Effect28.gen(function* () {
|
|
3260
3340
|
const claudeCodeService = yield* ClaudeCodeService;
|
|
3261
|
-
const getFlags = () =>
|
|
3341
|
+
const getFlags = () => Effect28.gen(function* () {
|
|
3262
3342
|
const claudeCodeFeatures = yield* claudeCodeService.getAvailableFeatures();
|
|
3263
3343
|
return {
|
|
3264
3344
|
response: {
|
|
@@ -3292,7 +3372,7 @@ var FeatureFlagController = class extends Context23.Tag("FeatureFlagController")
|
|
|
3292
3372
|
|
|
3293
3373
|
// src/server/core/file-system/presentation/FileSystemController.ts
|
|
3294
3374
|
import { homedir as homedir3 } from "node:os";
|
|
3295
|
-
import { Context as Context24, Effect as
|
|
3375
|
+
import { Context as Context24, Effect as Effect29, Layer as Layer26 } from "effect";
|
|
3296
3376
|
|
|
3297
3377
|
// src/server/core/file-system/functions/getDirectoryListing.ts
|
|
3298
3378
|
import { existsSync } from "node:fs";
|
|
@@ -3425,9 +3505,9 @@ var getFileCompletion = async (projectPath, basePath = "/") => {
|
|
|
3425
3505
|
};
|
|
3426
3506
|
|
|
3427
3507
|
// src/server/core/file-system/presentation/FileSystemController.ts
|
|
3428
|
-
var LayerImpl19 =
|
|
3508
|
+
var LayerImpl19 = Effect29.gen(function* () {
|
|
3429
3509
|
const projectRepository = yield* ProjectRepository;
|
|
3430
|
-
const getFileCompletionRoute = (options) =>
|
|
3510
|
+
const getFileCompletionRoute = (options) => Effect29.gen(function* () {
|
|
3431
3511
|
const { projectId, basePath } = options;
|
|
3432
3512
|
const { project } = yield* projectRepository.getProject(projectId);
|
|
3433
3513
|
if (project.meta.projectPath === null) {
|
|
@@ -3438,7 +3518,7 @@ var LayerImpl19 = Effect28.gen(function* () {
|
|
|
3438
3518
|
}
|
|
3439
3519
|
const projectPath = project.meta.projectPath;
|
|
3440
3520
|
try {
|
|
3441
|
-
const result = yield*
|
|
3521
|
+
const result = yield* Effect29.promise(
|
|
3442
3522
|
() => getFileCompletion(projectPath, basePath)
|
|
3443
3523
|
);
|
|
3444
3524
|
return {
|
|
@@ -3453,7 +3533,7 @@ var LayerImpl19 = Effect28.gen(function* () {
|
|
|
3453
3533
|
};
|
|
3454
3534
|
}
|
|
3455
3535
|
});
|
|
3456
|
-
const getDirectoryListingRoute = (options) =>
|
|
3536
|
+
const getDirectoryListingRoute = (options) => Effect29.promise(async () => {
|
|
3457
3537
|
const { currentPath, showHidden = false } = options;
|
|
3458
3538
|
const rootPath = "/";
|
|
3459
3539
|
const defaultPath = homedir3();
|
|
@@ -3489,7 +3569,7 @@ var FileSystemController = class extends Context24.Tag("FileSystemController")()
|
|
|
3489
3569
|
};
|
|
3490
3570
|
|
|
3491
3571
|
// src/server/core/git/presentation/GitController.ts
|
|
3492
|
-
import { Context as Context26, Effect as
|
|
3572
|
+
import { Context as Context26, Effect as Effect31, Either as Either2, Layer as Layer28 } from "effect";
|
|
3493
3573
|
|
|
3494
3574
|
// src/server/core/git/functions/getDiff.ts
|
|
3495
3575
|
import { readFile } from "node:fs/promises";
|
|
@@ -3828,8 +3908,8 @@ var getDiff = async (cwd, fromRefText, toRefText) => {
|
|
|
3828
3908
|
};
|
|
3829
3909
|
|
|
3830
3910
|
// src/server/core/git/services/GitService.ts
|
|
3831
|
-
import { Command as Command2, FileSystem as
|
|
3832
|
-
import { Context as Context25, Data as Data4, Duration, Effect as
|
|
3911
|
+
import { Command as Command2, FileSystem as FileSystem10, Path as Path13 } from "@effect/platform";
|
|
3912
|
+
import { Context as Context25, Data as Data4, Duration, Effect as Effect30, Either, Layer as Layer27 } from "effect";
|
|
3833
3913
|
|
|
3834
3914
|
// src/server/core/git/functions/parseGitBranchesOutput.ts
|
|
3835
3915
|
var parseGitBranchesOutput = (output) => {
|
|
@@ -3906,14 +3986,14 @@ var GitCommandError = class extends Data4.TaggedError("GitCommandError") {
|
|
|
3906
3986
|
};
|
|
3907
3987
|
var DetachedHeadError = class extends Data4.TaggedError("DetachedHeadError") {
|
|
3908
3988
|
};
|
|
3909
|
-
var LayerImpl20 =
|
|
3910
|
-
const fs = yield*
|
|
3911
|
-
const path = yield*
|
|
3989
|
+
var LayerImpl20 = Effect30.gen(function* () {
|
|
3990
|
+
const fs = yield* FileSystem10.FileSystem;
|
|
3991
|
+
const path = yield* Path13.Path;
|
|
3912
3992
|
const envService = yield* EnvService;
|
|
3913
|
-
const execGitCommand = (args, cwd) =>
|
|
3993
|
+
const execGitCommand = (args, cwd) => Effect30.gen(function* () {
|
|
3914
3994
|
const absoluteCwd = path.resolve(cwd);
|
|
3915
3995
|
if (!(yield* fs.exists(absoluteCwd))) {
|
|
3916
|
-
return yield*
|
|
3996
|
+
return yield* Effect30.fail(
|
|
3917
3997
|
new NotARepositoryError({ cwd: absoluteCwd })
|
|
3918
3998
|
);
|
|
3919
3999
|
}
|
|
@@ -3923,9 +4003,9 @@ var LayerImpl20 = Effect29.gen(function* () {
|
|
|
3923
4003
|
PATH: yield* envService.getEnv("PATH")
|
|
3924
4004
|
})
|
|
3925
4005
|
);
|
|
3926
|
-
const result = yield*
|
|
4006
|
+
const result = yield* Effect30.either(Command2.string(command));
|
|
3927
4007
|
if (Either.isLeft(result)) {
|
|
3928
|
-
return yield*
|
|
4008
|
+
return yield* Effect30.fail(
|
|
3929
4009
|
new GitCommandError({
|
|
3930
4010
|
cwd: absoluteCwd,
|
|
3931
4011
|
command: `git ${args.join(" ")}`
|
|
@@ -3934,22 +4014,22 @@ var LayerImpl20 = Effect29.gen(function* () {
|
|
|
3934
4014
|
}
|
|
3935
4015
|
return result.right;
|
|
3936
4016
|
});
|
|
3937
|
-
const getBranches = (cwd) =>
|
|
4017
|
+
const getBranches = (cwd) => Effect30.gen(function* () {
|
|
3938
4018
|
const result = yield* execGitCommand(["branch", "-vv", "--all"], cwd);
|
|
3939
4019
|
return parseGitBranchesOutput(result);
|
|
3940
4020
|
});
|
|
3941
|
-
const getCurrentBranch = (cwd) =>
|
|
4021
|
+
const getCurrentBranch = (cwd) => Effect30.gen(function* () {
|
|
3942
4022
|
const currentBranch = yield* execGitCommand(
|
|
3943
4023
|
["branch", "--show-current"],
|
|
3944
4024
|
cwd
|
|
3945
|
-
).pipe(
|
|
4025
|
+
).pipe(Effect30.map((result) => result.trim()));
|
|
3946
4026
|
if (currentBranch === "") {
|
|
3947
|
-
return yield*
|
|
4027
|
+
return yield* Effect30.fail(new DetachedHeadError({ cwd }));
|
|
3948
4028
|
}
|
|
3949
4029
|
return currentBranch;
|
|
3950
4030
|
});
|
|
3951
|
-
const branchExists = (cwd, branchName) =>
|
|
3952
|
-
const result = yield*
|
|
4031
|
+
const branchExists = (cwd, branchName) => Effect30.gen(function* () {
|
|
4032
|
+
const result = yield* Effect30.either(
|
|
3953
4033
|
execGitCommand(["branch", "--exists", branchName], cwd)
|
|
3954
4034
|
);
|
|
3955
4035
|
if (Either.isLeft(result)) {
|
|
@@ -3957,7 +4037,7 @@ var LayerImpl20 = Effect29.gen(function* () {
|
|
|
3957
4037
|
}
|
|
3958
4038
|
return true;
|
|
3959
4039
|
});
|
|
3960
|
-
const getCommits = (cwd) =>
|
|
4040
|
+
const getCommits = (cwd) => Effect30.gen(function* () {
|
|
3961
4041
|
const result = yield* execGitCommand(
|
|
3962
4042
|
[
|
|
3963
4043
|
"log",
|
|
@@ -3971,9 +4051,9 @@ var LayerImpl20 = Effect29.gen(function* () {
|
|
|
3971
4051
|
);
|
|
3972
4052
|
return parseGitCommitsOutput(result);
|
|
3973
4053
|
});
|
|
3974
|
-
const stageFiles = (cwd, files) =>
|
|
4054
|
+
const stageFiles = (cwd, files) => Effect30.gen(function* () {
|
|
3975
4055
|
if (files.length === 0) {
|
|
3976
|
-
return yield*
|
|
4056
|
+
return yield* Effect30.fail(
|
|
3977
4057
|
new GitCommandError({
|
|
3978
4058
|
cwd,
|
|
3979
4059
|
command: "git add (no files)"
|
|
@@ -3983,10 +4063,10 @@ var LayerImpl20 = Effect29.gen(function* () {
|
|
|
3983
4063
|
const result = yield* execGitCommand(["add", ...files], cwd);
|
|
3984
4064
|
return result;
|
|
3985
4065
|
});
|
|
3986
|
-
const commit = (cwd, message) =>
|
|
4066
|
+
const commit = (cwd, message) => Effect30.gen(function* () {
|
|
3987
4067
|
const trimmedMessage = message.trim();
|
|
3988
4068
|
if (trimmedMessage.length === 0) {
|
|
3989
|
-
return yield*
|
|
4069
|
+
return yield* Effect30.fail(
|
|
3990
4070
|
new GitCommandError({
|
|
3991
4071
|
cwd,
|
|
3992
4072
|
command: "git commit (empty message)"
|
|
@@ -4023,7 +4103,7 @@ var LayerImpl20 = Effect29.gen(function* () {
|
|
|
4023
4103
|
);
|
|
4024
4104
|
return sha.trim();
|
|
4025
4105
|
});
|
|
4026
|
-
const push = (cwd) =>
|
|
4106
|
+
const push = (cwd) => Effect30.gen(function* () {
|
|
4027
4107
|
const branch = yield* getCurrentBranch(cwd);
|
|
4028
4108
|
const absoluteCwd = path.resolve(cwd);
|
|
4029
4109
|
const command = Command2.make("git", "push", "origin", "HEAD").pipe(
|
|
@@ -4032,12 +4112,12 @@ var LayerImpl20 = Effect29.gen(function* () {
|
|
|
4032
4112
|
PATH: yield* envService.getEnv("PATH")
|
|
4033
4113
|
})
|
|
4034
4114
|
);
|
|
4035
|
-
const exitCodeResult = yield*
|
|
4036
|
-
Command2.exitCode(command).pipe(
|
|
4115
|
+
const exitCodeResult = yield* Effect30.either(
|
|
4116
|
+
Command2.exitCode(command).pipe(Effect30.timeout(Duration.seconds(60)))
|
|
4037
4117
|
);
|
|
4038
4118
|
if (Either.isLeft(exitCodeResult)) {
|
|
4039
4119
|
console.log("[GitService.push] Command failed or timeout");
|
|
4040
|
-
return yield*
|
|
4120
|
+
return yield* Effect30.fail(
|
|
4041
4121
|
new GitCommandError({
|
|
4042
4122
|
cwd: absoluteCwd,
|
|
4043
4123
|
command: "git push origin HEAD (timeout after 60s)"
|
|
@@ -4055,10 +4135,10 @@ var LayerImpl20 = Effect29.gen(function* () {
|
|
|
4055
4135
|
}),
|
|
4056
4136
|
Command2.stderr("inherit")
|
|
4057
4137
|
)
|
|
4058
|
-
).pipe(
|
|
4138
|
+
).pipe(Effect30.orElse(() => Effect30.succeed([])));
|
|
4059
4139
|
const stderr = Array.from(stderrLines).join("\n");
|
|
4060
4140
|
console.log("[GitService.push] Failed with stderr:", stderr);
|
|
4061
|
-
return yield*
|
|
4141
|
+
return yield* Effect30.fail(
|
|
4062
4142
|
new GitCommandError({
|
|
4063
4143
|
cwd: absoluteCwd,
|
|
4064
4144
|
command: `git push origin HEAD - ${stderr}`
|
|
@@ -4068,20 +4148,20 @@ var LayerImpl20 = Effect29.gen(function* () {
|
|
|
4068
4148
|
console.log("[GitService.push] Push succeeded");
|
|
4069
4149
|
return { branch, output: "success" };
|
|
4070
4150
|
});
|
|
4071
|
-
const getBranchHash = (cwd, branchName) =>
|
|
4151
|
+
const getBranchHash = (cwd, branchName) => Effect30.gen(function* () {
|
|
4072
4152
|
const result = yield* execGitCommand(["rev-parse", branchName], cwd).pipe(
|
|
4073
|
-
|
|
4153
|
+
Effect30.map((output) => output.trim().split("\n")[0] ?? null)
|
|
4074
4154
|
);
|
|
4075
4155
|
return result;
|
|
4076
4156
|
});
|
|
4077
|
-
const getBranchNamesByCommitHash = (cwd, hash) =>
|
|
4157
|
+
const getBranchNamesByCommitHash = (cwd, hash) => Effect30.gen(function* () {
|
|
4078
4158
|
const result = yield* execGitCommand(
|
|
4079
4159
|
["branch", "--contains", hash, "--format=%(refname:short)"],
|
|
4080
4160
|
cwd
|
|
4081
4161
|
);
|
|
4082
4162
|
return result.split("\n").map((line) => line.trim()).filter((line) => line !== "");
|
|
4083
4163
|
});
|
|
4084
|
-
const compareCommitHash = (cwd, targetHash, compareHash) =>
|
|
4164
|
+
const compareCommitHash = (cwd, targetHash, compareHash) => Effect30.gen(function* () {
|
|
4085
4165
|
const aheadResult = yield* execGitCommand(
|
|
4086
4166
|
["rev-list", `${targetHash}..${compareHash}`],
|
|
4087
4167
|
cwd
|
|
@@ -4103,7 +4183,7 @@ var LayerImpl20 = Effect29.gen(function* () {
|
|
|
4103
4183
|
}
|
|
4104
4184
|
return "un-related";
|
|
4105
4185
|
});
|
|
4106
|
-
const getCommitsWithParent = (cwd, options) =>
|
|
4186
|
+
const getCommitsWithParent = (cwd, options) => Effect30.gen(function* () {
|
|
4107
4187
|
const { offset, limit } = options;
|
|
4108
4188
|
const result = yield* execGitCommand(
|
|
4109
4189
|
[
|
|
@@ -4130,7 +4210,7 @@ var LayerImpl20 = Effect29.gen(function* () {
|
|
|
4130
4210
|
}
|
|
4131
4211
|
return commits;
|
|
4132
4212
|
});
|
|
4133
|
-
const findBaseBranch = (cwd, targetBranch) =>
|
|
4213
|
+
const findBaseBranch = (cwd, targetBranch) => Effect30.gen(function* () {
|
|
4134
4214
|
let offset = 0;
|
|
4135
4215
|
const limit = 20;
|
|
4136
4216
|
while (offset < 100) {
|
|
@@ -4164,7 +4244,7 @@ var LayerImpl20 = Effect29.gen(function* () {
|
|
|
4164
4244
|
}
|
|
4165
4245
|
return null;
|
|
4166
4246
|
});
|
|
4167
|
-
const getCommitsBetweenBranches = (cwd, baseBranch, targetBranch) =>
|
|
4247
|
+
const getCommitsBetweenBranches = (cwd, baseBranch, targetBranch) => Effect30.gen(function* () {
|
|
4168
4248
|
const result = yield* execGitCommand(
|
|
4169
4249
|
[
|
|
4170
4250
|
"log",
|
|
@@ -4199,10 +4279,10 @@ var GitService = class extends Context25.Tag("GitService")() {
|
|
|
4199
4279
|
};
|
|
4200
4280
|
|
|
4201
4281
|
// src/server/core/git/presentation/GitController.ts
|
|
4202
|
-
var LayerImpl21 =
|
|
4282
|
+
var LayerImpl21 = Effect31.gen(function* () {
|
|
4203
4283
|
const gitService = yield* GitService;
|
|
4204
4284
|
const projectRepository = yield* ProjectRepository;
|
|
4205
|
-
const getGitDiff = (options) =>
|
|
4285
|
+
const getGitDiff = (options) => Effect31.gen(function* () {
|
|
4206
4286
|
const { projectId, fromRef, toRef } = options;
|
|
4207
4287
|
const { project } = yield* projectRepository.getProject(projectId);
|
|
4208
4288
|
try {
|
|
@@ -4213,7 +4293,7 @@ var LayerImpl21 = Effect30.gen(function* () {
|
|
|
4213
4293
|
};
|
|
4214
4294
|
}
|
|
4215
4295
|
const projectPath = project.meta.projectPath;
|
|
4216
|
-
const result = yield*
|
|
4296
|
+
const result = yield* Effect31.promise(
|
|
4217
4297
|
() => getDiff(projectPath, fromRef, toRef)
|
|
4218
4298
|
);
|
|
4219
4299
|
return {
|
|
@@ -4234,7 +4314,7 @@ var LayerImpl21 = Effect30.gen(function* () {
|
|
|
4234
4314
|
};
|
|
4235
4315
|
}
|
|
4236
4316
|
});
|
|
4237
|
-
const commitFiles = (options) =>
|
|
4317
|
+
const commitFiles = (options) => Effect31.gen(function* () {
|
|
4238
4318
|
const { projectId, files, message } = options;
|
|
4239
4319
|
const { project } = yield* projectRepository.getProject(projectId);
|
|
4240
4320
|
if (project.meta.projectPath === null) {
|
|
@@ -4247,7 +4327,7 @@ var LayerImpl21 = Effect30.gen(function* () {
|
|
|
4247
4327
|
const projectPath = project.meta.projectPath;
|
|
4248
4328
|
console.log("[GitController.commitFiles] Project path:", projectPath);
|
|
4249
4329
|
console.log("[GitController.commitFiles] Staging files...");
|
|
4250
|
-
const stageResult = yield*
|
|
4330
|
+
const stageResult = yield* Effect31.either(
|
|
4251
4331
|
gitService.stageFiles(projectPath, files)
|
|
4252
4332
|
);
|
|
4253
4333
|
if (Either2.isLeft(stageResult)) {
|
|
@@ -4267,7 +4347,7 @@ var LayerImpl21 = Effect30.gen(function* () {
|
|
|
4267
4347
|
}
|
|
4268
4348
|
console.log("[GitController.commitFiles] Stage succeeded");
|
|
4269
4349
|
console.log("[GitController.commitFiles] Committing...");
|
|
4270
|
-
const commitResult = yield*
|
|
4350
|
+
const commitResult = yield* Effect31.either(
|
|
4271
4351
|
gitService.commit(projectPath, message)
|
|
4272
4352
|
);
|
|
4273
4353
|
if (Either2.isLeft(commitResult)) {
|
|
@@ -4302,7 +4382,7 @@ var LayerImpl21 = Effect30.gen(function* () {
|
|
|
4302
4382
|
status: 200
|
|
4303
4383
|
};
|
|
4304
4384
|
});
|
|
4305
|
-
const pushCommits = (options) =>
|
|
4385
|
+
const pushCommits = (options) => Effect31.gen(function* () {
|
|
4306
4386
|
const { projectId } = options;
|
|
4307
4387
|
console.log("[GitController.pushCommits] Request:", { projectId });
|
|
4308
4388
|
const { project } = yield* projectRepository.getProject(projectId);
|
|
@@ -4316,7 +4396,7 @@ var LayerImpl21 = Effect30.gen(function* () {
|
|
|
4316
4396
|
const projectPath = project.meta.projectPath;
|
|
4317
4397
|
console.log("[GitController.pushCommits] Project path:", projectPath);
|
|
4318
4398
|
console.log("[GitController.pushCommits] Pushing...");
|
|
4319
|
-
const pushResult = yield*
|
|
4399
|
+
const pushResult = yield* Effect31.either(gitService.push(projectPath));
|
|
4320
4400
|
if (Either2.isLeft(pushResult)) {
|
|
4321
4401
|
console.log(
|
|
4322
4402
|
"[GitController.pushCommits] Push failed:",
|
|
@@ -4345,7 +4425,7 @@ var LayerImpl21 = Effect30.gen(function* () {
|
|
|
4345
4425
|
status: 200
|
|
4346
4426
|
};
|
|
4347
4427
|
});
|
|
4348
|
-
const commitAndPush = (options) =>
|
|
4428
|
+
const commitAndPush = (options) => Effect31.gen(function* () {
|
|
4349
4429
|
const { projectId, files, message } = options;
|
|
4350
4430
|
console.log("[GitController.commitAndPush] Request:", {
|
|
4351
4431
|
projectId,
|
|
@@ -4396,7 +4476,7 @@ var LayerImpl21 = Effect30.gen(function* () {
|
|
|
4396
4476
|
status: 200
|
|
4397
4477
|
};
|
|
4398
4478
|
});
|
|
4399
|
-
const getCurrentRevisions = (options) =>
|
|
4479
|
+
const getCurrentRevisions = (options) => Effect31.gen(function* () {
|
|
4400
4480
|
const { projectId } = options;
|
|
4401
4481
|
const { project } = yield* projectRepository.getProject(projectId);
|
|
4402
4482
|
if (project.meta.projectPath === null) {
|
|
@@ -4406,7 +4486,7 @@ var LayerImpl21 = Effect30.gen(function* () {
|
|
|
4406
4486
|
};
|
|
4407
4487
|
}
|
|
4408
4488
|
const projectPath = project.meta.projectPath;
|
|
4409
|
-
const currentBranchResult = yield*
|
|
4489
|
+
const currentBranchResult = yield* Effect31.either(
|
|
4410
4490
|
gitService.getCurrentBranch(projectPath)
|
|
4411
4491
|
);
|
|
4412
4492
|
if (Either2.isLeft(currentBranchResult)) {
|
|
@@ -4418,10 +4498,10 @@ var LayerImpl21 = Effect30.gen(function* () {
|
|
|
4418
4498
|
};
|
|
4419
4499
|
}
|
|
4420
4500
|
const currentBranch = currentBranchResult.right;
|
|
4421
|
-
const baseBranchResult = yield*
|
|
4501
|
+
const baseBranchResult = yield* Effect31.either(
|
|
4422
4502
|
gitService.findBaseBranch(projectPath, currentBranch)
|
|
4423
4503
|
);
|
|
4424
|
-
const allBranchesResult = yield*
|
|
4504
|
+
const allBranchesResult = yield* Effect31.either(
|
|
4425
4505
|
gitService.getBranches(projectPath)
|
|
4426
4506
|
);
|
|
4427
4507
|
if (Either2.isLeft(allBranchesResult)) {
|
|
@@ -4446,7 +4526,7 @@ var LayerImpl21 = Effect30.gen(function* () {
|
|
|
4446
4526
|
let commits = [];
|
|
4447
4527
|
if (Either2.isRight(baseBranchResult) && baseBranchResult.right !== null) {
|
|
4448
4528
|
const baseBranchHash = baseBranchResult.right.hash;
|
|
4449
|
-
const commitsResult = yield*
|
|
4529
|
+
const commitsResult = yield* Effect31.either(
|
|
4450
4530
|
gitService.getCommitsBetweenBranches(
|
|
4451
4531
|
projectPath,
|
|
4452
4532
|
baseBranchHash,
|
|
@@ -4516,14 +4596,14 @@ var GitController = class extends Context26.Tag("GitController")() {
|
|
|
4516
4596
|
};
|
|
4517
4597
|
|
|
4518
4598
|
// src/server/core/project/presentation/ProjectController.ts
|
|
4519
|
-
import { FileSystem as
|
|
4520
|
-
import { Context as Context27, Effect as
|
|
4599
|
+
import { FileSystem as FileSystem11, Path as Path15 } from "@effect/platform";
|
|
4600
|
+
import { Context as Context27, Effect as Effect33, Layer as Layer29 } from "effect";
|
|
4521
4601
|
|
|
4522
4602
|
// src/server/core/claude-code/functions/computeClaudeProjectFilePath.ts
|
|
4523
|
-
import { Path as
|
|
4524
|
-
import { Effect as
|
|
4525
|
-
var computeClaudeProjectFilePath = (options) =>
|
|
4526
|
-
const path = yield*
|
|
4603
|
+
import { Path as Path14 } from "@effect/platform";
|
|
4604
|
+
import { Effect as Effect32 } from "effect";
|
|
4605
|
+
var computeClaudeProjectFilePath = (options) => Effect32.gen(function* () {
|
|
4606
|
+
const path = yield* Path14.Path;
|
|
4527
4607
|
const { projectPath, claudeProjectsDirPath } = options;
|
|
4528
4608
|
return path.join(
|
|
4529
4609
|
claudeProjectsDirPath,
|
|
@@ -4532,22 +4612,22 @@ var computeClaudeProjectFilePath = (options) => Effect31.gen(function* () {
|
|
|
4532
4612
|
});
|
|
4533
4613
|
|
|
4534
4614
|
// src/server/core/project/presentation/ProjectController.ts
|
|
4535
|
-
var LayerImpl22 =
|
|
4615
|
+
var LayerImpl22 = Effect33.gen(function* () {
|
|
4536
4616
|
const projectRepository = yield* ProjectRepository;
|
|
4537
4617
|
const claudeCodeLifeCycleService = yield* ClaudeCodeLifeCycleService;
|
|
4538
4618
|
const userConfigService = yield* UserConfigService;
|
|
4539
4619
|
const sessionRepository = yield* SessionRepository;
|
|
4540
4620
|
const context = yield* ApplicationContext;
|
|
4541
|
-
const fileSystem = yield*
|
|
4542
|
-
const path = yield*
|
|
4543
|
-
const getProjects = () =>
|
|
4621
|
+
const fileSystem = yield* FileSystem11.FileSystem;
|
|
4622
|
+
const path = yield* Path15.Path;
|
|
4623
|
+
const getProjects = () => Effect33.gen(function* () {
|
|
4544
4624
|
const { projects } = yield* projectRepository.getProjects();
|
|
4545
4625
|
return {
|
|
4546
4626
|
status: 200,
|
|
4547
4627
|
response: { projects }
|
|
4548
4628
|
};
|
|
4549
4629
|
});
|
|
4550
|
-
const getProject = (options) =>
|
|
4630
|
+
const getProject = (options) => Effect33.gen(function* () {
|
|
4551
4631
|
const { projectId, cursor } = options;
|
|
4552
4632
|
const userConfig = yield* userConfigService.getUserConfig();
|
|
4553
4633
|
const { project } = yield* projectRepository.getProject(projectId);
|
|
@@ -4601,7 +4681,7 @@ var LayerImpl22 = Effect32.gen(function* () {
|
|
|
4601
4681
|
}
|
|
4602
4682
|
};
|
|
4603
4683
|
});
|
|
4604
|
-
const getProjectLatestSession = (options) =>
|
|
4684
|
+
const getProjectLatestSession = (options) => Effect33.gen(function* () {
|
|
4605
4685
|
const { projectId } = options;
|
|
4606
4686
|
const { sessions } = yield* sessionRepository.getSessions(projectId, {
|
|
4607
4687
|
maxCount: 1
|
|
@@ -4613,7 +4693,7 @@ var LayerImpl22 = Effect32.gen(function* () {
|
|
|
4613
4693
|
}
|
|
4614
4694
|
};
|
|
4615
4695
|
});
|
|
4616
|
-
const createProject = (options) =>
|
|
4696
|
+
const createProject = (options) => Effect33.gen(function* () {
|
|
4617
4697
|
const { projectPath } = options;
|
|
4618
4698
|
const claudeProjectFilePath = yield* computeClaudeProjectFilePath({
|
|
4619
4699
|
projectPath,
|
|
@@ -4658,8 +4738,8 @@ var ProjectController = class extends Context27.Tag("ProjectController")() {
|
|
|
4658
4738
|
|
|
4659
4739
|
// src/server/core/scheduler/config.ts
|
|
4660
4740
|
import { homedir as homedir4 } from "node:os";
|
|
4661
|
-
import { FileSystem as
|
|
4662
|
-
import { Context as Context28, Data as Data5, Effect as
|
|
4741
|
+
import { FileSystem as FileSystem12, Path as Path16 } from "@effect/platform";
|
|
4742
|
+
import { Context as Context28, Data as Data5, Effect as Effect34, Layer as Layer30 } from "effect";
|
|
4663
4743
|
|
|
4664
4744
|
// src/server/core/scheduler/schema.ts
|
|
4665
4745
|
import { z as z23 } from "zod";
|
|
@@ -4727,22 +4807,22 @@ var SchedulerConfigBaseDir = class extends Context28.Tag(
|
|
|
4727
4807
|
this.Live = Layer30.succeed(this, `${homedir4()}/.claude-code-viewer`);
|
|
4728
4808
|
}
|
|
4729
4809
|
};
|
|
4730
|
-
var getConfigPath =
|
|
4731
|
-
const path = yield*
|
|
4810
|
+
var getConfigPath = Effect34.gen(function* () {
|
|
4811
|
+
const path = yield* Path16.Path;
|
|
4732
4812
|
const baseDir = yield* SchedulerConfigBaseDir;
|
|
4733
4813
|
return path.join(baseDir, CONFIG_DIR, CONFIG_FILE);
|
|
4734
4814
|
});
|
|
4735
|
-
var readConfig =
|
|
4736
|
-
const fs = yield*
|
|
4815
|
+
var readConfig = Effect34.gen(function* () {
|
|
4816
|
+
const fs = yield* FileSystem12.FileSystem;
|
|
4737
4817
|
const configPath = yield* getConfigPath;
|
|
4738
4818
|
const exists = yield* fs.exists(configPath);
|
|
4739
4819
|
if (!exists) {
|
|
4740
|
-
return yield*
|
|
4820
|
+
return yield* Effect34.fail(
|
|
4741
4821
|
new ConfigFileNotFoundError({ path: configPath })
|
|
4742
4822
|
);
|
|
4743
4823
|
}
|
|
4744
4824
|
const content = yield* fs.readFileString(configPath);
|
|
4745
|
-
const jsonResult = yield*
|
|
4825
|
+
const jsonResult = yield* Effect34.try({
|
|
4746
4826
|
try: () => JSON.parse(content),
|
|
4747
4827
|
catch: (error) => new ConfigParseError({
|
|
4748
4828
|
path: configPath,
|
|
@@ -4751,7 +4831,7 @@ var readConfig = Effect33.gen(function* () {
|
|
|
4751
4831
|
});
|
|
4752
4832
|
const parsed = schedulerConfigSchema.safeParse(jsonResult);
|
|
4753
4833
|
if (!parsed.success) {
|
|
4754
|
-
return yield*
|
|
4834
|
+
return yield* Effect34.fail(
|
|
4755
4835
|
new ConfigParseError({
|
|
4756
4836
|
path: configPath,
|
|
4757
4837
|
cause: parsed.error
|
|
@@ -4760,24 +4840,24 @@ var readConfig = Effect33.gen(function* () {
|
|
|
4760
4840
|
}
|
|
4761
4841
|
return parsed.data;
|
|
4762
4842
|
});
|
|
4763
|
-
var writeConfig = (config) =>
|
|
4764
|
-
const fs = yield*
|
|
4765
|
-
const path = yield*
|
|
4843
|
+
var writeConfig = (config) => Effect34.gen(function* () {
|
|
4844
|
+
const fs = yield* FileSystem12.FileSystem;
|
|
4845
|
+
const path = yield* Path16.Path;
|
|
4766
4846
|
const configPath = yield* getConfigPath;
|
|
4767
4847
|
const configDir = path.dirname(configPath);
|
|
4768
4848
|
yield* fs.makeDirectory(configDir, { recursive: true });
|
|
4769
4849
|
const content = JSON.stringify(config, null, 2);
|
|
4770
4850
|
yield* fs.writeFileString(configPath, content);
|
|
4771
4851
|
});
|
|
4772
|
-
var initializeConfig =
|
|
4852
|
+
var initializeConfig = Effect34.gen(function* () {
|
|
4773
4853
|
const result = yield* readConfig.pipe(
|
|
4774
|
-
|
|
4775
|
-
ConfigFileNotFoundError: () =>
|
|
4854
|
+
Effect34.catchTags({
|
|
4855
|
+
ConfigFileNotFoundError: () => Effect34.gen(function* () {
|
|
4776
4856
|
const initialConfig = { jobs: [] };
|
|
4777
4857
|
yield* writeConfig(initialConfig);
|
|
4778
4858
|
return initialConfig;
|
|
4779
4859
|
}),
|
|
4780
|
-
ConfigParseError: () =>
|
|
4860
|
+
ConfigParseError: () => Effect34.gen(function* () {
|
|
4781
4861
|
const initialConfig = { jobs: [] };
|
|
4782
4862
|
yield* writeConfig(initialConfig);
|
|
4783
4863
|
return initialConfig;
|
|
@@ -4793,7 +4873,7 @@ import {
|
|
|
4793
4873
|
Cron,
|
|
4794
4874
|
Data as Data6,
|
|
4795
4875
|
Duration as Duration2,
|
|
4796
|
-
Effect as
|
|
4876
|
+
Effect as Effect36,
|
|
4797
4877
|
Fiber,
|
|
4798
4878
|
Layer as Layer31,
|
|
4799
4879
|
Ref as Ref10,
|
|
@@ -4802,8 +4882,8 @@ import {
|
|
|
4802
4882
|
import { ulid as ulid4 } from "ulid";
|
|
4803
4883
|
|
|
4804
4884
|
// src/server/core/scheduler/domain/Job.ts
|
|
4805
|
-
import { Effect as
|
|
4806
|
-
var executeJob = (job) =>
|
|
4885
|
+
import { Effect as Effect35 } from "effect";
|
|
4886
|
+
var executeJob = (job) => Effect35.gen(function* () {
|
|
4807
4887
|
const lifeCycleService = yield* ClaudeCodeLifeCycleService;
|
|
4808
4888
|
const projectRepository = yield* ProjectRepository;
|
|
4809
4889
|
const userConfigService = yield* UserConfigService;
|
|
@@ -4811,7 +4891,7 @@ var executeJob = (job) => Effect34.gen(function* () {
|
|
|
4811
4891
|
const { project } = yield* projectRepository.getProject(message.projectId);
|
|
4812
4892
|
const userConfig = yield* userConfigService.getUserConfig();
|
|
4813
4893
|
if (project.meta.projectPath === null) {
|
|
4814
|
-
return yield*
|
|
4894
|
+
return yield* Effect35.fail(
|
|
4815
4895
|
new Error(`Project path not found for projectId: ${message.projectId}`)
|
|
4816
4896
|
);
|
|
4817
4897
|
}
|
|
@@ -4845,15 +4925,15 @@ var InvalidCronExpressionError = class extends Data6.TaggedError(
|
|
|
4845
4925
|
"InvalidCronExpressionError"
|
|
4846
4926
|
) {
|
|
4847
4927
|
};
|
|
4848
|
-
var LayerImpl23 =
|
|
4928
|
+
var LayerImpl23 = Effect36.gen(function* () {
|
|
4849
4929
|
const fibersRef = yield* Ref10.make(/* @__PURE__ */ new Map());
|
|
4850
4930
|
const runningJobsRef = yield* Ref10.make(/* @__PURE__ */ new Set());
|
|
4851
|
-
const startJob = (job) =>
|
|
4931
|
+
const startJob = (job) => Effect36.gen(function* () {
|
|
4852
4932
|
const now = /* @__PURE__ */ new Date();
|
|
4853
4933
|
if (job.schedule.type === "cron") {
|
|
4854
4934
|
const cronResult = Cron.parse(job.schedule.expression);
|
|
4855
4935
|
if (cronResult._tag === "Left") {
|
|
4856
|
-
return yield*
|
|
4936
|
+
return yield* Effect36.fail(
|
|
4857
4937
|
new InvalidCronExpressionError({
|
|
4858
4938
|
expression: job.schedule.expression,
|
|
4859
4939
|
cause: cronResult.left
|
|
@@ -4861,12 +4941,12 @@ var LayerImpl23 = Effect35.gen(function* () {
|
|
|
4861
4941
|
);
|
|
4862
4942
|
}
|
|
4863
4943
|
const cronSchedule = Schedule.cron(cronResult.right);
|
|
4864
|
-
const fiber = yield*
|
|
4944
|
+
const fiber = yield* Effect36.gen(function* () {
|
|
4865
4945
|
const nextTime = Cron.next(cronResult.right, /* @__PURE__ */ new Date());
|
|
4866
4946
|
const nextDelay = Math.max(0, nextTime.getTime() - Date.now());
|
|
4867
|
-
yield*
|
|
4868
|
-
yield*
|
|
4869
|
-
}).pipe(
|
|
4947
|
+
yield* Effect36.sleep(Duration2.millis(nextDelay));
|
|
4948
|
+
yield* Effect36.repeat(runJobWithConcurrencyControl(job), cronSchedule);
|
|
4949
|
+
}).pipe(Effect36.forkDaemon);
|
|
4870
4950
|
yield* Ref10.update(
|
|
4871
4951
|
fibersRef,
|
|
4872
4952
|
(fibers) => new Map(fibers).set(job.id, fiber)
|
|
@@ -4877,17 +4957,17 @@ var LayerImpl23 = Effect35.gen(function* () {
|
|
|
4877
4957
|
}
|
|
4878
4958
|
const delay = calculateReservedDelay(job, now);
|
|
4879
4959
|
const delayDuration = Duration2.millis(delay);
|
|
4880
|
-
const fiber = yield*
|
|
4960
|
+
const fiber = yield* Effect36.delay(
|
|
4881
4961
|
runJobWithConcurrencyControl(job),
|
|
4882
4962
|
delayDuration
|
|
4883
|
-
).pipe(
|
|
4963
|
+
).pipe(Effect36.forkDaemon);
|
|
4884
4964
|
yield* Ref10.update(
|
|
4885
4965
|
fibersRef,
|
|
4886
4966
|
(fibers) => new Map(fibers).set(job.id, fiber)
|
|
4887
4967
|
);
|
|
4888
4968
|
}
|
|
4889
4969
|
});
|
|
4890
|
-
const runJobWithConcurrencyControl = (job) =>
|
|
4970
|
+
const runJobWithConcurrencyControl = (job) => Effect36.gen(function* () {
|
|
4891
4971
|
if (job.schedule.type === "cron" && job.schedule.concurrencyPolicy === "skip") {
|
|
4892
4972
|
const runningJobs = yield* Ref10.get(runningJobsRef);
|
|
4893
4973
|
if (runningJobs.has(job.id)) {
|
|
@@ -4897,9 +4977,9 @@ var LayerImpl23 = Effect35.gen(function* () {
|
|
|
4897
4977
|
yield* Ref10.update(runningJobsRef, (jobs) => new Set(jobs).add(job.id));
|
|
4898
4978
|
if (job.schedule.type === "reserved") {
|
|
4899
4979
|
const result2 = yield* executeJob(job).pipe(
|
|
4900
|
-
|
|
4901
|
-
onSuccess: () =>
|
|
4902
|
-
onFailure: () =>
|
|
4980
|
+
Effect36.matchEffect({
|
|
4981
|
+
onSuccess: () => Effect36.void,
|
|
4982
|
+
onFailure: () => Effect36.void
|
|
4903
4983
|
})
|
|
4904
4984
|
);
|
|
4905
4985
|
yield* Ref10.update(runningJobsRef, (jobs) => {
|
|
@@ -4908,18 +4988,18 @@ var LayerImpl23 = Effect35.gen(function* () {
|
|
|
4908
4988
|
return newJobs;
|
|
4909
4989
|
});
|
|
4910
4990
|
yield* deleteJobFromConfig(job.id).pipe(
|
|
4911
|
-
|
|
4991
|
+
Effect36.catchAll((error) => {
|
|
4912
4992
|
console.error(
|
|
4913
4993
|
`[Scheduler] Failed to delete reserved job ${job.id}:`,
|
|
4914
4994
|
error
|
|
4915
4995
|
);
|
|
4916
|
-
return
|
|
4996
|
+
return Effect36.void;
|
|
4917
4997
|
})
|
|
4918
4998
|
);
|
|
4919
4999
|
return result2;
|
|
4920
5000
|
}
|
|
4921
5001
|
const result = yield* executeJob(job).pipe(
|
|
4922
|
-
|
|
5002
|
+
Effect36.matchEffect({
|
|
4923
5003
|
onSuccess: () => updateJobStatus(job.id, "success", (/* @__PURE__ */ new Date()).toISOString()),
|
|
4924
5004
|
onFailure: () => updateJobStatus(job.id, "failed", (/* @__PURE__ */ new Date()).toISOString())
|
|
4925
5005
|
})
|
|
@@ -4931,7 +5011,7 @@ var LayerImpl23 = Effect35.gen(function* () {
|
|
|
4931
5011
|
});
|
|
4932
5012
|
return result;
|
|
4933
5013
|
});
|
|
4934
|
-
const updateJobStatus = (jobId, status, runAt) =>
|
|
5014
|
+
const updateJobStatus = (jobId, status, runAt) => Effect36.gen(function* () {
|
|
4935
5015
|
const config = yield* readConfig;
|
|
4936
5016
|
const job = config.jobs.find((j) => j.id === jobId);
|
|
4937
5017
|
if (job === void 0) {
|
|
@@ -4947,7 +5027,7 @@ var LayerImpl23 = Effect35.gen(function* () {
|
|
|
4947
5027
|
};
|
|
4948
5028
|
yield* writeConfig(updatedConfig);
|
|
4949
5029
|
});
|
|
4950
|
-
const stopJob = (jobId) =>
|
|
5030
|
+
const stopJob = (jobId) => Effect36.gen(function* () {
|
|
4951
5031
|
const fibers = yield* Ref10.get(fibersRef);
|
|
4952
5032
|
const fiber = fibers.get(jobId);
|
|
4953
5033
|
if (fiber !== void 0) {
|
|
@@ -4959,7 +5039,7 @@ var LayerImpl23 = Effect35.gen(function* () {
|
|
|
4959
5039
|
});
|
|
4960
5040
|
}
|
|
4961
5041
|
});
|
|
4962
|
-
const startScheduler =
|
|
5042
|
+
const startScheduler = Effect36.gen(function* () {
|
|
4963
5043
|
yield* initializeConfig;
|
|
4964
5044
|
const config = yield* readConfig;
|
|
4965
5045
|
for (const job of config.jobs) {
|
|
@@ -4968,27 +5048,27 @@ var LayerImpl23 = Effect35.gen(function* () {
|
|
|
4968
5048
|
}
|
|
4969
5049
|
}
|
|
4970
5050
|
});
|
|
4971
|
-
const stopScheduler =
|
|
5051
|
+
const stopScheduler = Effect36.gen(function* () {
|
|
4972
5052
|
const fibers = yield* Ref10.get(fibersRef);
|
|
4973
5053
|
for (const fiber of fibers.values()) {
|
|
4974
5054
|
yield* Fiber.interrupt(fiber);
|
|
4975
5055
|
}
|
|
4976
5056
|
yield* Ref10.set(fibersRef, /* @__PURE__ */ new Map());
|
|
4977
5057
|
});
|
|
4978
|
-
const getJobs = () =>
|
|
5058
|
+
const getJobs = () => Effect36.gen(function* () {
|
|
4979
5059
|
const config = yield* readConfig.pipe(
|
|
4980
|
-
|
|
4981
|
-
ConfigFileNotFoundError: () => initializeConfig.pipe(
|
|
4982
|
-
ConfigParseError: () => initializeConfig.pipe(
|
|
5060
|
+
Effect36.catchTags({
|
|
5061
|
+
ConfigFileNotFoundError: () => initializeConfig.pipe(Effect36.map(() => ({ jobs: [] }))),
|
|
5062
|
+
ConfigParseError: () => initializeConfig.pipe(Effect36.map(() => ({ jobs: [] })))
|
|
4983
5063
|
})
|
|
4984
5064
|
);
|
|
4985
5065
|
return config.jobs;
|
|
4986
5066
|
});
|
|
4987
|
-
const addJob = (newJob) =>
|
|
5067
|
+
const addJob = (newJob) => Effect36.gen(function* () {
|
|
4988
5068
|
const config = yield* readConfig.pipe(
|
|
4989
|
-
|
|
4990
|
-
ConfigFileNotFoundError: () => initializeConfig.pipe(
|
|
4991
|
-
ConfigParseError: () => initializeConfig.pipe(
|
|
5069
|
+
Effect36.catchTags({
|
|
5070
|
+
ConfigFileNotFoundError: () => initializeConfig.pipe(Effect36.map(() => ({ jobs: [] }))),
|
|
5071
|
+
ConfigParseError: () => initializeConfig.pipe(Effect36.map(() => ({ jobs: [] })))
|
|
4992
5072
|
})
|
|
4993
5073
|
);
|
|
4994
5074
|
const job = {
|
|
@@ -5007,16 +5087,16 @@ var LayerImpl23 = Effect35.gen(function* () {
|
|
|
5007
5087
|
}
|
|
5008
5088
|
return job;
|
|
5009
5089
|
});
|
|
5010
|
-
const updateJob = (jobId, updates) =>
|
|
5090
|
+
const updateJob = (jobId, updates) => Effect36.gen(function* () {
|
|
5011
5091
|
const config = yield* readConfig.pipe(
|
|
5012
|
-
|
|
5013
|
-
ConfigFileNotFoundError: () => initializeConfig.pipe(
|
|
5014
|
-
ConfigParseError: () => initializeConfig.pipe(
|
|
5092
|
+
Effect36.catchTags({
|
|
5093
|
+
ConfigFileNotFoundError: () => initializeConfig.pipe(Effect36.map(() => ({ jobs: [] }))),
|
|
5094
|
+
ConfigParseError: () => initializeConfig.pipe(Effect36.map(() => ({ jobs: [] })))
|
|
5015
5095
|
})
|
|
5016
5096
|
);
|
|
5017
5097
|
const job = config.jobs.find((j) => j.id === jobId);
|
|
5018
5098
|
if (job === void 0) {
|
|
5019
|
-
return yield*
|
|
5099
|
+
return yield* Effect36.fail(new SchedulerJobNotFoundError({ jobId }));
|
|
5020
5100
|
}
|
|
5021
5101
|
yield* stopJob(jobId);
|
|
5022
5102
|
const updatedJob = {
|
|
@@ -5032,32 +5112,32 @@ var LayerImpl23 = Effect35.gen(function* () {
|
|
|
5032
5112
|
}
|
|
5033
5113
|
return updatedJob;
|
|
5034
5114
|
});
|
|
5035
|
-
const deleteJobFromConfig = (jobId) =>
|
|
5115
|
+
const deleteJobFromConfig = (jobId) => Effect36.gen(function* () {
|
|
5036
5116
|
const config = yield* readConfig.pipe(
|
|
5037
|
-
|
|
5038
|
-
ConfigFileNotFoundError: () => initializeConfig.pipe(
|
|
5039
|
-
ConfigParseError: () => initializeConfig.pipe(
|
|
5117
|
+
Effect36.catchTags({
|
|
5118
|
+
ConfigFileNotFoundError: () => initializeConfig.pipe(Effect36.map(() => ({ jobs: [] }))),
|
|
5119
|
+
ConfigParseError: () => initializeConfig.pipe(Effect36.map(() => ({ jobs: [] })))
|
|
5040
5120
|
})
|
|
5041
5121
|
);
|
|
5042
5122
|
const job = config.jobs.find((j) => j.id === jobId);
|
|
5043
5123
|
if (job === void 0) {
|
|
5044
|
-
return yield*
|
|
5124
|
+
return yield* Effect36.fail(new SchedulerJobNotFoundError({ jobId }));
|
|
5045
5125
|
}
|
|
5046
5126
|
const updatedConfig = {
|
|
5047
5127
|
jobs: config.jobs.filter((j) => j.id !== jobId)
|
|
5048
5128
|
};
|
|
5049
5129
|
yield* writeConfig(updatedConfig);
|
|
5050
5130
|
});
|
|
5051
|
-
const deleteJob = (jobId) =>
|
|
5131
|
+
const deleteJob = (jobId) => Effect36.gen(function* () {
|
|
5052
5132
|
const config = yield* readConfig.pipe(
|
|
5053
|
-
|
|
5054
|
-
ConfigFileNotFoundError: () => initializeConfig.pipe(
|
|
5055
|
-
ConfigParseError: () => initializeConfig.pipe(
|
|
5133
|
+
Effect36.catchTags({
|
|
5134
|
+
ConfigFileNotFoundError: () => initializeConfig.pipe(Effect36.map(() => ({ jobs: [] }))),
|
|
5135
|
+
ConfigParseError: () => initializeConfig.pipe(Effect36.map(() => ({ jobs: [] })))
|
|
5056
5136
|
})
|
|
5057
5137
|
);
|
|
5058
5138
|
const job = config.jobs.find((j) => j.id === jobId);
|
|
5059
5139
|
if (job === void 0) {
|
|
5060
|
-
return yield*
|
|
5140
|
+
return yield* Effect36.fail(new SchedulerJobNotFoundError({ jobId }));
|
|
5061
5141
|
}
|
|
5062
5142
|
yield* stopJob(jobId);
|
|
5063
5143
|
yield* deleteJobFromConfig(jobId);
|
|
@@ -5078,17 +5158,17 @@ var SchedulerService = class extends Context29.Tag("SchedulerService")() {
|
|
|
5078
5158
|
};
|
|
5079
5159
|
|
|
5080
5160
|
// src/server/core/scheduler/presentation/SchedulerController.ts
|
|
5081
|
-
import { Context as Context30, Effect as
|
|
5082
|
-
var LayerImpl24 =
|
|
5161
|
+
import { Context as Context30, Effect as Effect37, Layer as Layer32 } from "effect";
|
|
5162
|
+
var LayerImpl24 = Effect37.gen(function* () {
|
|
5083
5163
|
const schedulerService = yield* SchedulerService;
|
|
5084
|
-
const getJobs = () =>
|
|
5164
|
+
const getJobs = () => Effect37.gen(function* () {
|
|
5085
5165
|
const jobs = yield* schedulerService.getJobs();
|
|
5086
5166
|
return {
|
|
5087
5167
|
response: jobs,
|
|
5088
5168
|
status: 200
|
|
5089
5169
|
};
|
|
5090
5170
|
});
|
|
5091
|
-
const addJob = (options) =>
|
|
5171
|
+
const addJob = (options) => Effect37.gen(function* () {
|
|
5092
5172
|
const { job } = options;
|
|
5093
5173
|
const result = yield* schedulerService.addJob(job);
|
|
5094
5174
|
return {
|
|
@@ -5096,12 +5176,12 @@ var LayerImpl24 = Effect36.gen(function* () {
|
|
|
5096
5176
|
status: 201
|
|
5097
5177
|
};
|
|
5098
5178
|
});
|
|
5099
|
-
const updateJob = (options) =>
|
|
5179
|
+
const updateJob = (options) => Effect37.gen(function* () {
|
|
5100
5180
|
const { id, job } = options;
|
|
5101
5181
|
const result = yield* schedulerService.updateJob(id, job).pipe(
|
|
5102
|
-
|
|
5182
|
+
Effect37.catchTag(
|
|
5103
5183
|
"SchedulerJobNotFoundError",
|
|
5104
|
-
() =>
|
|
5184
|
+
() => Effect37.succeed(null)
|
|
5105
5185
|
)
|
|
5106
5186
|
);
|
|
5107
5187
|
if (result === null) {
|
|
@@ -5115,14 +5195,14 @@ var LayerImpl24 = Effect36.gen(function* () {
|
|
|
5115
5195
|
status: 200
|
|
5116
5196
|
};
|
|
5117
5197
|
});
|
|
5118
|
-
const deleteJob = (options) =>
|
|
5198
|
+
const deleteJob = (options) => Effect37.gen(function* () {
|
|
5119
5199
|
const { id } = options;
|
|
5120
5200
|
const result = yield* schedulerService.deleteJob(id).pipe(
|
|
5121
|
-
|
|
5201
|
+
Effect37.catchTag(
|
|
5122
5202
|
"SchedulerJobNotFoundError",
|
|
5123
|
-
() =>
|
|
5203
|
+
() => Effect37.succeed(false)
|
|
5124
5204
|
),
|
|
5125
|
-
|
|
5205
|
+
Effect37.map(() => true)
|
|
5126
5206
|
);
|
|
5127
5207
|
if (!result) {
|
|
5128
5208
|
return {
|
|
@@ -5149,11 +5229,11 @@ var SchedulerController = class extends Context30.Tag("SchedulerController")() {
|
|
|
5149
5229
|
};
|
|
5150
5230
|
|
|
5151
5231
|
// src/server/core/search/presentation/SearchController.ts
|
|
5152
|
-
import { Context as Context32, Effect as
|
|
5232
|
+
import { Context as Context32, Effect as Effect39, Layer as Layer34 } from "effect";
|
|
5153
5233
|
|
|
5154
5234
|
// src/server/core/search/services/SearchService.ts
|
|
5155
|
-
import { FileSystem as
|
|
5156
|
-
import { Context as Context31, Effect as
|
|
5235
|
+
import { FileSystem as FileSystem13, Path as Path17 } from "@effect/platform";
|
|
5236
|
+
import { Context as Context31, Effect as Effect38, Layer as Layer33, Ref as Ref11 } from "effect";
|
|
5157
5237
|
import MiniSearch from "minisearch";
|
|
5158
5238
|
|
|
5159
5239
|
// src/server/core/search/functions/extractSearchableText.ts
|
|
@@ -5199,12 +5279,12 @@ var createMiniSearchIndex = () => new MiniSearch({
|
|
|
5199
5279
|
boost: { text: 1 }
|
|
5200
5280
|
}
|
|
5201
5281
|
});
|
|
5202
|
-
var LayerImpl25 =
|
|
5203
|
-
const fs = yield*
|
|
5204
|
-
const path = yield*
|
|
5282
|
+
var LayerImpl25 = Effect38.gen(function* () {
|
|
5283
|
+
const fs = yield* FileSystem13.FileSystem;
|
|
5284
|
+
const path = yield* Path17.Path;
|
|
5205
5285
|
const context = yield* ApplicationContext;
|
|
5206
5286
|
const indexCacheRef = yield* Ref11.make(null);
|
|
5207
|
-
const buildIndex = () =>
|
|
5287
|
+
const buildIndex = () => Effect38.gen(function* () {
|
|
5208
5288
|
const { claudeProjectsDirPath } = context.claudeCodePaths;
|
|
5209
5289
|
const dirExists = yield* fs.exists(claudeProjectsDirPath);
|
|
5210
5290
|
if (!dirExists) {
|
|
@@ -5213,22 +5293,22 @@ var LayerImpl25 = Effect37.gen(function* () {
|
|
|
5213
5293
|
const projectEntries = yield* fs.readDirectory(claudeProjectsDirPath);
|
|
5214
5294
|
const miniSearch = createMiniSearchIndex();
|
|
5215
5295
|
const documentEffects = projectEntries.map(
|
|
5216
|
-
(projectEntry) =>
|
|
5296
|
+
(projectEntry) => Effect38.gen(function* () {
|
|
5217
5297
|
const projectPath = path.resolve(claudeProjectsDirPath, projectEntry);
|
|
5218
|
-
const stat = yield* fs.stat(projectPath).pipe(
|
|
5298
|
+
const stat = yield* fs.stat(projectPath).pipe(Effect38.catchAll(() => Effect38.succeed(null)));
|
|
5219
5299
|
if (stat?.type !== "Directory") {
|
|
5220
5300
|
return [];
|
|
5221
5301
|
}
|
|
5222
5302
|
const projectId = encodeProjectId(projectPath);
|
|
5223
5303
|
const projectName = path.basename(projectPath);
|
|
5224
|
-
const sessionEntries = yield* fs.readDirectory(projectPath).pipe(
|
|
5304
|
+
const sessionEntries = yield* fs.readDirectory(projectPath).pipe(Effect38.catchAll(() => Effect38.succeed([])));
|
|
5225
5305
|
const sessionFiles = sessionEntries.filter(isRegularSessionFile);
|
|
5226
|
-
const sessionDocuments = yield*
|
|
5306
|
+
const sessionDocuments = yield* Effect38.all(
|
|
5227
5307
|
sessionFiles.map(
|
|
5228
|
-
(sessionFile) =>
|
|
5308
|
+
(sessionFile) => Effect38.gen(function* () {
|
|
5229
5309
|
const sessionPath = path.resolve(projectPath, sessionFile);
|
|
5230
5310
|
const sessionId = encodeSessionId(sessionPath);
|
|
5231
|
-
const content = yield* fs.readFileString(sessionPath).pipe(
|
|
5311
|
+
const content = yield* fs.readFileString(sessionPath).pipe(Effect38.catchAll(() => Effect38.succeed("")));
|
|
5232
5312
|
if (!content) return [];
|
|
5233
5313
|
const conversations = parseJsonl(content);
|
|
5234
5314
|
const documents = [];
|
|
@@ -5263,7 +5343,7 @@ var LayerImpl25 = Effect37.gen(function* () {
|
|
|
5263
5343
|
return sessionDocuments.flat();
|
|
5264
5344
|
})
|
|
5265
5345
|
);
|
|
5266
|
-
const allDocuments = yield*
|
|
5346
|
+
const allDocuments = yield* Effect38.all(documentEffects, {
|
|
5267
5347
|
concurrency: 10
|
|
5268
5348
|
});
|
|
5269
5349
|
const flatDocuments = allDocuments.flat();
|
|
@@ -5274,7 +5354,7 @@ var LayerImpl25 = Effect37.gen(function* () {
|
|
|
5274
5354
|
}
|
|
5275
5355
|
return { index: miniSearch, documents: documentsMap };
|
|
5276
5356
|
});
|
|
5277
|
-
const getIndex = () =>
|
|
5357
|
+
const getIndex = () => Effect38.gen(function* () {
|
|
5278
5358
|
const cached = yield* Ref11.get(indexCacheRef);
|
|
5279
5359
|
const now = Date.now();
|
|
5280
5360
|
if (cached && now - cached.builtAt < INDEX_TTL_MS) {
|
|
@@ -5284,7 +5364,7 @@ var LayerImpl25 = Effect37.gen(function* () {
|
|
|
5284
5364
|
yield* Ref11.set(indexCacheRef, { index, documents, builtAt: now });
|
|
5285
5365
|
return { index, documents };
|
|
5286
5366
|
});
|
|
5287
|
-
const search = (query2, limit = 20, projectId) =>
|
|
5367
|
+
const search = (query2, limit = 20, projectId) => Effect38.gen(function* () {
|
|
5288
5368
|
const { claudeProjectsDirPath } = context.claudeCodePaths;
|
|
5289
5369
|
const dirExists = yield* fs.exists(claudeProjectsDirPath);
|
|
5290
5370
|
if (!dirExists) {
|
|
@@ -5338,9 +5418,9 @@ var SearchService = class extends Context31.Tag("SearchService")() {
|
|
|
5338
5418
|
};
|
|
5339
5419
|
|
|
5340
5420
|
// src/server/core/search/presentation/SearchController.ts
|
|
5341
|
-
var LayerImpl26 =
|
|
5421
|
+
var LayerImpl26 = Effect39.gen(function* () {
|
|
5342
5422
|
const searchService = yield* SearchService;
|
|
5343
|
-
const search = (options) =>
|
|
5423
|
+
const search = (options) => Effect39.gen(function* () {
|
|
5344
5424
|
const { query: query2, limit, projectId } = options;
|
|
5345
5425
|
if (query2.trim().length < 2) {
|
|
5346
5426
|
return {
|
|
@@ -5371,10 +5451,10 @@ var SearchController = class extends Context32.Tag("SearchController")() {
|
|
|
5371
5451
|
};
|
|
5372
5452
|
|
|
5373
5453
|
// src/server/core/session/presentation/SessionController.ts
|
|
5374
|
-
import { Context as Context33, Effect as
|
|
5454
|
+
import { Context as Context33, Effect as Effect41, Layer as Layer35 } from "effect";
|
|
5375
5455
|
|
|
5376
5456
|
// src/server/core/session/services/ExportService.ts
|
|
5377
|
-
import { Effect as
|
|
5457
|
+
import { Effect as Effect40 } from "effect";
|
|
5378
5458
|
var escapeHtml = (text) => {
|
|
5379
5459
|
const map = {
|
|
5380
5460
|
"&": "&",
|
|
@@ -5633,7 +5713,7 @@ var renderGroupedAssistantEntries = (entries) => {
|
|
|
5633
5713
|
</div>
|
|
5634
5714
|
`;
|
|
5635
5715
|
};
|
|
5636
|
-
var generateSessionHtml = (session, projectId) =>
|
|
5716
|
+
var generateSessionHtml = (session, projectId) => Effect40.gen(function* () {
|
|
5637
5717
|
const grouped = groupConsecutiveAssistantMessages(session.conversations);
|
|
5638
5718
|
const conversationsHtml = grouped.map((group) => {
|
|
5639
5719
|
if (group.type === "grouped") {
|
|
@@ -6153,9 +6233,9 @@ var generateSessionHtml = (session, projectId) => Effect39.gen(function* () {
|
|
|
6153
6233
|
});
|
|
6154
6234
|
|
|
6155
6235
|
// src/server/core/session/presentation/SessionController.ts
|
|
6156
|
-
var LayerImpl27 =
|
|
6236
|
+
var LayerImpl27 = Effect41.gen(function* () {
|
|
6157
6237
|
const sessionRepository = yield* SessionRepository;
|
|
6158
|
-
const getSession = (options) =>
|
|
6238
|
+
const getSession = (options) => Effect41.gen(function* () {
|
|
6159
6239
|
const { projectId, sessionId } = options;
|
|
6160
6240
|
const { session } = yield* sessionRepository.getSession(
|
|
6161
6241
|
projectId,
|
|
@@ -6166,7 +6246,7 @@ var LayerImpl27 = Effect40.gen(function* () {
|
|
|
6166
6246
|
response: { session }
|
|
6167
6247
|
};
|
|
6168
6248
|
});
|
|
6169
|
-
const exportSessionHtml = (options) =>
|
|
6249
|
+
const exportSessionHtml = (options) => Effect41.gen(function* () {
|
|
6170
6250
|
const { projectId, sessionId } = options;
|
|
6171
6251
|
const { session } = yield* sessionRepository.getSession(
|
|
6172
6252
|
projectId,
|
|
@@ -6200,12 +6280,12 @@ import { Hono } from "hono";
|
|
|
6200
6280
|
var honoApp = new Hono();
|
|
6201
6281
|
|
|
6202
6282
|
// src/server/hono/initialize.ts
|
|
6203
|
-
import { Context as Context34, Effect as
|
|
6283
|
+
import { Context as Context34, Effect as Effect42, Layer as Layer36, Ref as Ref12, Schedule as Schedule2 } from "effect";
|
|
6204
6284
|
var InitializeService = class extends Context34.Tag("InitializeService")() {
|
|
6205
6285
|
static {
|
|
6206
6286
|
this.Live = Layer36.effect(
|
|
6207
6287
|
this,
|
|
6208
|
-
|
|
6288
|
+
Effect42.gen(function* () {
|
|
6209
6289
|
const eventBus = yield* EventBus;
|
|
6210
6290
|
const fileWatcher = yield* FileWatcherService;
|
|
6211
6291
|
const projectRepository = yield* ProjectRepository;
|
|
@@ -6215,20 +6295,20 @@ var InitializeService = class extends Context34.Tag("InitializeService")() {
|
|
|
6215
6295
|
const virtualConversationDatabase = yield* VirtualConversationDatabase;
|
|
6216
6296
|
const listenersRef = yield* Ref12.make({});
|
|
6217
6297
|
const startInitialization = () => {
|
|
6218
|
-
return
|
|
6298
|
+
return Effect42.gen(function* () {
|
|
6219
6299
|
yield* fileWatcher.startWatching();
|
|
6220
|
-
const daemon =
|
|
6300
|
+
const daemon = Effect42.repeat(
|
|
6221
6301
|
eventBus.emit("heartbeat", {}),
|
|
6222
6302
|
Schedule2.fixed("10 seconds")
|
|
6223
6303
|
);
|
|
6224
6304
|
console.log("start heartbeat");
|
|
6225
|
-
yield*
|
|
6305
|
+
yield* Effect42.forkDaemon(daemon);
|
|
6226
6306
|
console.log("after starting heartbeat fork");
|
|
6227
6307
|
const onSessionChanged = (event) => {
|
|
6228
|
-
|
|
6308
|
+
Effect42.runFork(
|
|
6229
6309
|
projectMetaService.invalidateProject(event.projectId)
|
|
6230
6310
|
);
|
|
6231
|
-
|
|
6311
|
+
Effect42.runFork(
|
|
6232
6312
|
sessionMetaService.invalidateSession(
|
|
6233
6313
|
event.projectId,
|
|
6234
6314
|
event.sessionId
|
|
@@ -6237,7 +6317,7 @@ var InitializeService = class extends Context34.Tag("InitializeService")() {
|
|
|
6237
6317
|
};
|
|
6238
6318
|
const onSessionProcessChanged = (event) => {
|
|
6239
6319
|
if ((event.changed.type === "completed" || event.changed.type === "paused") && event.changed.sessionId !== void 0) {
|
|
6240
|
-
|
|
6320
|
+
Effect42.runFork(
|
|
6241
6321
|
virtualConversationDatabase.deleteVirtualConversations(
|
|
6242
6322
|
event.changed.sessionId
|
|
6243
6323
|
)
|
|
@@ -6251,12 +6331,12 @@ var InitializeService = class extends Context34.Tag("InitializeService")() {
|
|
|
6251
6331
|
});
|
|
6252
6332
|
yield* eventBus.on("sessionChanged", onSessionChanged);
|
|
6253
6333
|
yield* eventBus.on("sessionProcessChanged", onSessionProcessChanged);
|
|
6254
|
-
yield*
|
|
6334
|
+
yield* Effect42.gen(function* () {
|
|
6255
6335
|
console.log("Initializing projects cache");
|
|
6256
6336
|
const { projects } = yield* projectRepository.getProjects();
|
|
6257
6337
|
console.log(`${projects.length} projects cache initialized`);
|
|
6258
6338
|
console.log("Initializing sessions cache");
|
|
6259
|
-
const results = yield*
|
|
6339
|
+
const results = yield* Effect42.all(
|
|
6260
6340
|
projects.map(
|
|
6261
6341
|
(project) => sessionRepository.getSessions(project.id)
|
|
6262
6342
|
),
|
|
@@ -6268,12 +6348,12 @@ var InitializeService = class extends Context34.Tag("InitializeService")() {
|
|
|
6268
6348
|
);
|
|
6269
6349
|
console.log(`${totalSessions} sessions cache initialized`);
|
|
6270
6350
|
}).pipe(
|
|
6271
|
-
|
|
6272
|
-
|
|
6351
|
+
Effect42.catchAll(() => Effect42.void),
|
|
6352
|
+
Effect42.withSpan("initialize-cache")
|
|
6273
6353
|
);
|
|
6274
|
-
}).pipe(
|
|
6354
|
+
}).pipe(Effect42.withSpan("start-initialization"));
|
|
6275
6355
|
};
|
|
6276
|
-
const stopCleanup = () =>
|
|
6356
|
+
const stopCleanup = () => Effect42.gen(function* () {
|
|
6277
6357
|
const listeners = yield* Ref12.get(listenersRef);
|
|
6278
6358
|
if (listeners.sessionChanged) {
|
|
6279
6359
|
yield* eventBus.off("sessionChanged", listeners.sessionChanged);
|
|
@@ -6297,7 +6377,7 @@ var InitializeService = class extends Context34.Tag("InitializeService")() {
|
|
|
6297
6377
|
};
|
|
6298
6378
|
|
|
6299
6379
|
// src/server/hono/middleware/auth.middleware.ts
|
|
6300
|
-
import { Context as Context35, Effect as
|
|
6380
|
+
import { Context as Context35, Effect as Effect43, Layer as Layer37 } from "effect";
|
|
6301
6381
|
import { getCookie } from "hono/cookie";
|
|
6302
6382
|
import { createMiddleware } from "hono/factory";
|
|
6303
6383
|
var generateSessionToken = (password) => {
|
|
@@ -6312,7 +6392,7 @@ var PUBLIC_API_ROUTES = [
|
|
|
6312
6392
|
// Allow config access for theme/locale loading
|
|
6313
6393
|
"/api/version"
|
|
6314
6394
|
];
|
|
6315
|
-
var LayerImpl28 =
|
|
6395
|
+
var LayerImpl28 = Effect43.gen(function* () {
|
|
6316
6396
|
const envService = yield* EnvService;
|
|
6317
6397
|
const anthPassword = yield* envService.getEnv(
|
|
6318
6398
|
"CLAUDE_CODE_VIEWER_AUTH_PASSWORD"
|
|
@@ -6350,7 +6430,7 @@ var AuthMiddleware = class extends Context35.Tag("AuthMiddleware")() {
|
|
|
6350
6430
|
|
|
6351
6431
|
// src/server/hono/route.ts
|
|
6352
6432
|
import { zValidator } from "@hono/zod-validator";
|
|
6353
|
-
import { Effect as
|
|
6433
|
+
import { Effect as Effect45, Runtime as Runtime3 } from "effect";
|
|
6354
6434
|
import { deleteCookie, getCookie as getCookie3, setCookie as setCookie2 } from "hono/cookie";
|
|
6355
6435
|
import { streamSSE } from "hono/streaming";
|
|
6356
6436
|
import prexit from "prexit";
|
|
@@ -6359,7 +6439,7 @@ import { z as z28 } from "zod";
|
|
|
6359
6439
|
// package.json
|
|
6360
6440
|
var package_default = {
|
|
6361
6441
|
name: "@kimuson/claude-code-viewer",
|
|
6362
|
-
version: "0.4.
|
|
6442
|
+
version: "0.4.15",
|
|
6363
6443
|
type: "module",
|
|
6364
6444
|
license: "MIT",
|
|
6365
6445
|
repository: {
|
|
@@ -6633,9 +6713,9 @@ var userConfigSchema = z27.object({
|
|
|
6633
6713
|
var defaultUserConfig = userConfigSchema.parse({});
|
|
6634
6714
|
|
|
6635
6715
|
// src/server/lib/effect/toEffectResponse.ts
|
|
6636
|
-
import { Effect as
|
|
6716
|
+
import { Effect as Effect44 } from "effect";
|
|
6637
6717
|
var effectToResponse = async (ctx, effect) => {
|
|
6638
|
-
const result = await
|
|
6718
|
+
const result = await Effect44.runPromise(effect);
|
|
6639
6719
|
const result2 = ctx.json(result.response, result.status);
|
|
6640
6720
|
return result2;
|
|
6641
6721
|
};
|
|
@@ -6678,7 +6758,7 @@ var configMiddleware = createMiddleware2(
|
|
|
6678
6758
|
);
|
|
6679
6759
|
|
|
6680
6760
|
// src/server/hono/route.ts
|
|
6681
|
-
var routes = (app) =>
|
|
6761
|
+
var routes = (app) => Effect45.gen(function* () {
|
|
6682
6762
|
const projectController = yield* ProjectController;
|
|
6683
6763
|
const sessionController = yield* SessionController;
|
|
6684
6764
|
const agentSessionController = yield* AgentSessionController;
|
|
@@ -6696,7 +6776,7 @@ var routes = (app) => Effect44.gen(function* () {
|
|
|
6696
6776
|
const claudeCodeLifeCycleService = yield* ClaudeCodeLifeCycleService;
|
|
6697
6777
|
const initializeService = yield* InitializeService;
|
|
6698
6778
|
const { authMiddleware, validSessionToken, authEnabled, anthPassword } = yield* AuthMiddleware;
|
|
6699
|
-
const runtime = yield*
|
|
6779
|
+
const runtime = yield* Effect45.runtime();
|
|
6700
6780
|
if ((yield* envService.getEnv("NEXT_PHASE")) !== "phase-production-build") {
|
|
6701
6781
|
yield* initializeService.startInitialization();
|
|
6702
6782
|
prexit(async () => {
|
|
@@ -6704,7 +6784,7 @@ var routes = (app) => Effect44.gen(function* () {
|
|
|
6704
6784
|
});
|
|
6705
6785
|
}
|
|
6706
6786
|
return app.use(configMiddleware).use(authMiddleware).use(async (c, next) => {
|
|
6707
|
-
await
|
|
6787
|
+
await Effect45.runPromise(
|
|
6708
6788
|
userConfigService.setUserConfig({
|
|
6709
6789
|
...c.get("userConfig")
|
|
6710
6790
|
})
|
|
@@ -6773,7 +6853,7 @@ var routes = (app) => Effect44.gen(function* () {
|
|
|
6773
6853
|
projectController.getProject({
|
|
6774
6854
|
...c.req.param(),
|
|
6775
6855
|
...c.req.valid("query")
|
|
6776
|
-
}).pipe(
|
|
6856
|
+
}).pipe(Effect45.provide(runtime))
|
|
6777
6857
|
);
|
|
6778
6858
|
return response;
|
|
6779
6859
|
}
|
|
@@ -6790,7 +6870,7 @@ var routes = (app) => Effect44.gen(function* () {
|
|
|
6790
6870
|
c,
|
|
6791
6871
|
projectController.createProject({
|
|
6792
6872
|
...c.req.valid("json")
|
|
6793
|
-
}).pipe(
|
|
6873
|
+
}).pipe(Effect45.provide(runtime))
|
|
6794
6874
|
);
|
|
6795
6875
|
return response;
|
|
6796
6876
|
}
|
|
@@ -6799,13 +6879,13 @@ var routes = (app) => Effect44.gen(function* () {
|
|
|
6799
6879
|
c,
|
|
6800
6880
|
projectController.getProjectLatestSession({
|
|
6801
6881
|
...c.req.param()
|
|
6802
|
-
}).pipe(
|
|
6882
|
+
}).pipe(Effect45.provide(runtime))
|
|
6803
6883
|
);
|
|
6804
6884
|
return response;
|
|
6805
6885
|
}).get("/api/projects/:projectId/sessions/:sessionId", async (c) => {
|
|
6806
6886
|
const response = await effectToResponse(
|
|
6807
6887
|
c,
|
|
6808
|
-
sessionController.getSession({ ...c.req.param() }).pipe(
|
|
6888
|
+
sessionController.getSession({ ...c.req.param() }).pipe(Effect45.provide(runtime))
|
|
6809
6889
|
);
|
|
6810
6890
|
return response;
|
|
6811
6891
|
}).get(
|
|
@@ -6813,7 +6893,7 @@ var routes = (app) => Effect44.gen(function* () {
|
|
|
6813
6893
|
async (c) => {
|
|
6814
6894
|
const response = await effectToResponse(
|
|
6815
6895
|
c,
|
|
6816
|
-
sessionController.exportSessionHtml({ ...c.req.param() }).pipe(
|
|
6896
|
+
sessionController.exportSessionHtml({ ...c.req.param() }).pipe(Effect45.provide(runtime))
|
|
6817
6897
|
);
|
|
6818
6898
|
return response;
|
|
6819
6899
|
}
|
|
@@ -6824,7 +6904,7 @@ var routes = (app) => Effect44.gen(function* () {
|
|
|
6824
6904
|
agentSessionController.getAgentSession({
|
|
6825
6905
|
projectId,
|
|
6826
6906
|
agentId
|
|
6827
|
-
}).pipe(
|
|
6907
|
+
}).pipe(Effect45.provide(runtime))
|
|
6828
6908
|
);
|
|
6829
6909
|
return response;
|
|
6830
6910
|
}).get("/api/projects/:projectId/git/current-revisions", async (c) => {
|
|
@@ -6832,7 +6912,7 @@ var routes = (app) => Effect44.gen(function* () {
|
|
|
6832
6912
|
c,
|
|
6833
6913
|
gitController.getCurrentRevisions({
|
|
6834
6914
|
...c.req.param()
|
|
6835
|
-
}).pipe(
|
|
6915
|
+
}).pipe(Effect45.provide(runtime))
|
|
6836
6916
|
);
|
|
6837
6917
|
return response;
|
|
6838
6918
|
}).post(
|
|
@@ -6850,7 +6930,7 @@ var routes = (app) => Effect44.gen(function* () {
|
|
|
6850
6930
|
gitController.getGitDiff({
|
|
6851
6931
|
...c.req.param(),
|
|
6852
6932
|
...c.req.valid("json")
|
|
6853
|
-
}).pipe(
|
|
6933
|
+
}).pipe(Effect45.provide(runtime))
|
|
6854
6934
|
);
|
|
6855
6935
|
return response;
|
|
6856
6936
|
}
|
|
@@ -6863,7 +6943,7 @@ var routes = (app) => Effect44.gen(function* () {
|
|
|
6863
6943
|
gitController.commitFiles({
|
|
6864
6944
|
...c.req.param(),
|
|
6865
6945
|
...c.req.valid("json")
|
|
6866
|
-
}).pipe(
|
|
6946
|
+
}).pipe(Effect45.provide(runtime))
|
|
6867
6947
|
);
|
|
6868
6948
|
return response;
|
|
6869
6949
|
}
|
|
@@ -6876,7 +6956,7 @@ var routes = (app) => Effect44.gen(function* () {
|
|
|
6876
6956
|
gitController.pushCommits({
|
|
6877
6957
|
...c.req.param(),
|
|
6878
6958
|
...c.req.valid("json")
|
|
6879
|
-
}).pipe(
|
|
6959
|
+
}).pipe(Effect45.provide(runtime))
|
|
6880
6960
|
);
|
|
6881
6961
|
return response;
|
|
6882
6962
|
}
|
|
@@ -6889,7 +6969,7 @@ var routes = (app) => Effect44.gen(function* () {
|
|
|
6889
6969
|
gitController.commitAndPush({
|
|
6890
6970
|
...c.req.param(),
|
|
6891
6971
|
...c.req.valid("json")
|
|
6892
|
-
}).pipe(
|
|
6972
|
+
}).pipe(Effect45.provide(runtime))
|
|
6893
6973
|
);
|
|
6894
6974
|
return response;
|
|
6895
6975
|
}
|
|
@@ -6898,7 +6978,7 @@ var routes = (app) => Effect44.gen(function* () {
|
|
|
6898
6978
|
c,
|
|
6899
6979
|
claudeCodeController.getClaudeCommands({
|
|
6900
6980
|
...c.req.param()
|
|
6901
|
-
}).pipe(
|
|
6981
|
+
}).pipe(Effect45.provide(runtime))
|
|
6902
6982
|
);
|
|
6903
6983
|
return response;
|
|
6904
6984
|
}).get("/api/projects/:projectId/mcp/list", async (c) => {
|
|
@@ -6906,19 +6986,19 @@ var routes = (app) => Effect44.gen(function* () {
|
|
|
6906
6986
|
c,
|
|
6907
6987
|
claudeCodeController.getMcpListRoute({
|
|
6908
6988
|
...c.req.param()
|
|
6909
|
-
}).pipe(
|
|
6989
|
+
}).pipe(Effect45.provide(runtime))
|
|
6910
6990
|
);
|
|
6911
6991
|
return response;
|
|
6912
6992
|
}).get("/api/cc/meta", async (c) => {
|
|
6913
6993
|
const response = await effectToResponse(
|
|
6914
6994
|
c,
|
|
6915
|
-
claudeCodeController.getClaudeCodeMeta().pipe(
|
|
6995
|
+
claudeCodeController.getClaudeCodeMeta().pipe(Effect45.provide(runtime))
|
|
6916
6996
|
);
|
|
6917
6997
|
return response;
|
|
6918
6998
|
}).get("/api/cc/features", async (c) => {
|
|
6919
6999
|
const response = await effectToResponse(
|
|
6920
7000
|
c,
|
|
6921
|
-
claudeCodeController.getAvailableFeatures().pipe(
|
|
7001
|
+
claudeCodeController.getAvailableFeatures().pipe(Effect45.provide(runtime))
|
|
6922
7002
|
);
|
|
6923
7003
|
return response;
|
|
6924
7004
|
}).get("/api/cc/session-processes", async (c) => {
|
|
@@ -6962,7 +7042,7 @@ var routes = (app) => Effect44.gen(function* () {
|
|
|
6962
7042
|
claudeCodeSessionProcessController.continueSessionProcess({
|
|
6963
7043
|
...c.req.param(),
|
|
6964
7044
|
...c.req.valid("json")
|
|
6965
|
-
}).pipe(
|
|
7045
|
+
}).pipe(Effect45.provide(runtime))
|
|
6966
7046
|
);
|
|
6967
7047
|
return response;
|
|
6968
7048
|
}
|
|
@@ -6971,7 +7051,7 @@ var routes = (app) => Effect44.gen(function* () {
|
|
|
6971
7051
|
zValidator("json", z28.object({ projectId: z28.string() })),
|
|
6972
7052
|
async (c) => {
|
|
6973
7053
|
const { sessionProcessId } = c.req.param();
|
|
6974
|
-
void
|
|
7054
|
+
void Effect45.runFork(
|
|
6975
7055
|
claudeCodeLifeCycleService.abortTask(sessionProcessId)
|
|
6976
7056
|
);
|
|
6977
7057
|
return c.json({ message: "Task aborted" });
|
|
@@ -6999,7 +7079,7 @@ var routes = (app) => Effect44.gen(function* () {
|
|
|
6999
7079
|
c,
|
|
7000
7080
|
async (rawStream) => {
|
|
7001
7081
|
await Runtime3.runPromise(runtime)(
|
|
7002
|
-
sseController.handleSSE(rawStream).pipe(
|
|
7082
|
+
sseController.handleSSE(rawStream).pipe(Effect45.provide(TypeSafeSSE.make(rawStream)))
|
|
7003
7083
|
);
|
|
7004
7084
|
},
|
|
7005
7085
|
async (err) => {
|
|
@@ -7009,7 +7089,7 @@ var routes = (app) => Effect44.gen(function* () {
|
|
|
7009
7089
|
}).get("/api/scheduler/jobs", async (c) => {
|
|
7010
7090
|
const response = await effectToResponse(
|
|
7011
7091
|
c,
|
|
7012
|
-
schedulerController.getJobs().pipe(
|
|
7092
|
+
schedulerController.getJobs().pipe(Effect45.provide(runtime))
|
|
7013
7093
|
);
|
|
7014
7094
|
return response;
|
|
7015
7095
|
}).post(
|
|
@@ -7020,7 +7100,7 @@ var routes = (app) => Effect44.gen(function* () {
|
|
|
7020
7100
|
c,
|
|
7021
7101
|
schedulerController.addJob({
|
|
7022
7102
|
job: c.req.valid("json")
|
|
7023
|
-
}).pipe(
|
|
7103
|
+
}).pipe(Effect45.provide(runtime))
|
|
7024
7104
|
);
|
|
7025
7105
|
return response;
|
|
7026
7106
|
}
|
|
@@ -7033,7 +7113,7 @@ var routes = (app) => Effect44.gen(function* () {
|
|
|
7033
7113
|
schedulerController.updateJob({
|
|
7034
7114
|
id: c.req.param("id"),
|
|
7035
7115
|
job: c.req.valid("json")
|
|
7036
|
-
}).pipe(
|
|
7116
|
+
}).pipe(Effect45.provide(runtime))
|
|
7037
7117
|
);
|
|
7038
7118
|
return response;
|
|
7039
7119
|
}
|
|
@@ -7042,7 +7122,7 @@ var routes = (app) => Effect44.gen(function* () {
|
|
|
7042
7122
|
c,
|
|
7043
7123
|
schedulerController.deleteJob({
|
|
7044
7124
|
id: c.req.param("id")
|
|
7045
|
-
}).pipe(
|
|
7125
|
+
}).pipe(Effect45.provide(runtime))
|
|
7046
7126
|
);
|
|
7047
7127
|
return response;
|
|
7048
7128
|
}).get(
|
|
@@ -7095,14 +7175,14 @@ var routes = (app) => Effect44.gen(function* () {
|
|
|
7095
7175
|
const { q, limit, projectId } = c.req.valid("query");
|
|
7096
7176
|
const response = await effectToResponse(
|
|
7097
7177
|
c,
|
|
7098
|
-
searchController.search({ query: q, limit, projectId }).pipe(
|
|
7178
|
+
searchController.search({ query: q, limit, projectId }).pipe(Effect45.provide(runtime))
|
|
7099
7179
|
);
|
|
7100
7180
|
return response;
|
|
7101
7181
|
}
|
|
7102
7182
|
).get("/api/flags", async (c) => {
|
|
7103
7183
|
const response = await effectToResponse(
|
|
7104
7184
|
c,
|
|
7105
|
-
featureFlagController.getFlags().pipe(
|
|
7185
|
+
featureFlagController.getFlags().pipe(Effect45.provide(runtime))
|
|
7106
7186
|
);
|
|
7107
7187
|
return response;
|
|
7108
7188
|
});
|
|
@@ -7139,47 +7219,47 @@ if (!isDevelopment) {
|
|
|
7139
7219
|
}
|
|
7140
7220
|
var program = routes(honoApp).pipe(
|
|
7141
7221
|
/** Presentation */
|
|
7142
|
-
|
|
7143
|
-
|
|
7144
|
-
|
|
7145
|
-
|
|
7146
|
-
|
|
7147
|
-
|
|
7148
|
-
|
|
7149
|
-
|
|
7150
|
-
|
|
7151
|
-
|
|
7152
|
-
|
|
7153
|
-
|
|
7222
|
+
Effect46.provide(ProjectController.Live),
|
|
7223
|
+
Effect46.provide(SessionController.Live),
|
|
7224
|
+
Effect46.provide(AgentSessionController.Live),
|
|
7225
|
+
Effect46.provide(GitController.Live),
|
|
7226
|
+
Effect46.provide(ClaudeCodeController.Live),
|
|
7227
|
+
Effect46.provide(ClaudeCodeSessionProcessController.Live),
|
|
7228
|
+
Effect46.provide(ClaudeCodePermissionController.Live),
|
|
7229
|
+
Effect46.provide(FileSystemController.Live),
|
|
7230
|
+
Effect46.provide(SSEController.Live),
|
|
7231
|
+
Effect46.provide(SchedulerController.Live),
|
|
7232
|
+
Effect46.provide(FeatureFlagController.Live),
|
|
7233
|
+
Effect46.provide(SearchController.Live)
|
|
7154
7234
|
).pipe(
|
|
7155
7235
|
/** Application */
|
|
7156
|
-
|
|
7157
|
-
|
|
7158
|
-
|
|
7236
|
+
Effect46.provide(InitializeService.Live),
|
|
7237
|
+
Effect46.provide(FileWatcherService.Live),
|
|
7238
|
+
Effect46.provide(AuthMiddleware.Live)
|
|
7159
7239
|
).pipe(
|
|
7160
7240
|
/** Domain */
|
|
7161
|
-
|
|
7162
|
-
|
|
7163
|
-
|
|
7164
|
-
|
|
7165
|
-
|
|
7166
|
-
|
|
7167
|
-
|
|
7168
|
-
|
|
7241
|
+
Effect46.provide(ClaudeCodeLifeCycleService.Live),
|
|
7242
|
+
Effect46.provide(ClaudeCodePermissionService.Live),
|
|
7243
|
+
Effect46.provide(ClaudeCodeSessionProcessService.Live),
|
|
7244
|
+
Effect46.provide(ClaudeCodeService.Live),
|
|
7245
|
+
Effect46.provide(GitService.Live),
|
|
7246
|
+
Effect46.provide(SchedulerService.Live),
|
|
7247
|
+
Effect46.provide(SchedulerConfigBaseDir.Live),
|
|
7248
|
+
Effect46.provide(SearchService.Live)
|
|
7169
7249
|
).pipe(
|
|
7170
7250
|
/** Infrastructure */
|
|
7171
|
-
|
|
7172
|
-
|
|
7173
|
-
|
|
7174
|
-
|
|
7175
|
-
|
|
7176
|
-
|
|
7251
|
+
Effect46.provide(ProjectRepository.Live),
|
|
7252
|
+
Effect46.provide(SessionRepository.Live),
|
|
7253
|
+
Effect46.provide(ProjectMetaService.Live),
|
|
7254
|
+
Effect46.provide(SessionMetaService.Live),
|
|
7255
|
+
Effect46.provide(VirtualConversationDatabase.Live),
|
|
7256
|
+
Effect46.provide(AgentSessionLayer)
|
|
7177
7257
|
).pipe(
|
|
7178
7258
|
/** Platform */
|
|
7179
|
-
|
|
7180
|
-
|
|
7259
|
+
Effect46.provide(platformLayer),
|
|
7260
|
+
Effect46.provide(NodeContext2.layer)
|
|
7181
7261
|
);
|
|
7182
|
-
await
|
|
7262
|
+
await Effect46.runPromise(program);
|
|
7183
7263
|
var port = isDevelopment ? (
|
|
7184
7264
|
// biome-ignore lint/style/noProcessEnv: allow only here
|
|
7185
7265
|
process.env.DEV_BE_PORT ?? "3401"
|
|
@@ -7187,13 +7267,15 @@ var port = isDevelopment ? (
|
|
|
7187
7267
|
// biome-ignore lint/style/noProcessEnv: allow only here
|
|
7188
7268
|
process.env.PORT ?? "3000"
|
|
7189
7269
|
);
|
|
7270
|
+
var hostname = process.env.HOSTNAME ?? "localhost";
|
|
7190
7271
|
serve(
|
|
7191
7272
|
{
|
|
7192
7273
|
fetch: honoApp.fetch,
|
|
7193
|
-
port: parseInt(port, 10)
|
|
7274
|
+
port: parseInt(port, 10),
|
|
7275
|
+
hostname
|
|
7194
7276
|
},
|
|
7195
7277
|
(info) => {
|
|
7196
|
-
console.log(`Server is running on http
|
|
7278
|
+
console.log(`Server is running on http://${info.address}:${info.port}`);
|
|
7197
7279
|
}
|
|
7198
7280
|
);
|
|
7199
7281
|
//# sourceMappingURL=main.js.map
|