scream-code 0.16.3 → 0.16.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{app-C1foLjDE.mjs → app-F12Iraus.mjs} +154 -109
- package/dist/{dispatch-BGLqpKHG.mjs → dispatch-BNVgLsrQ.mjs} +1 -1
- package/dist/{dispatch-ChDxIz0h.mjs → dispatch-VY-K2oXV.mjs} +1020 -288
- package/dist/main.mjs +1 -1
- package/dist/{text-input-dialog-DAQfJdHu.mjs → text-input-dialog-CQ6R2lns.mjs} +1 -1
- package/dist/{text-input-dialog-GajpxjyL.mjs → text-input-dialog-KaFgI_Ko.mjs} +8 -4
- package/package.json +2 -2
|
@@ -4,8 +4,8 @@ import { dirname as __cjsShimDirname } from 'node:path';
|
|
|
4
4
|
const __filename = __cjsShimFileURLToPath(import.meta.url);
|
|
5
5
|
const __dirname = __cjsShimDirname(__filename);
|
|
6
6
|
import "./suppress-sqlite-warning-C2VB0doZ.mjs";
|
|
7
|
-
import { $n as readSessionIndex, $t as SubagentSlots, A as langFromPath, An as startManualEmbeddingDownload, At as toggleEmptySessionHint, B as charsForTokenBudget, Bn as getLogDir, Bt as OSC11_QUERY, C as getDaemonInstructions, Cn as buildSkillSlashCommands, D as renderDiffLines, Dn as setExperimentalFlags, Dt as createMarkdownTheme, E as ToolCallComponent, En as isExperimentalFlagEnabled, Et as createEditorTheme, F as replaceTabs, Fn as loadTuiConfig, Ft as parseOsc11BackgroundTheme, G as WelcomeComponent, Gn as PRODUCT_NAME, Gt as TERMINAL_FOCUS_IN, H as getSharedSpeedTracker, Hn as CLI_COMMAND_NAME, Ht as OSC11_RESPONSE_PREFIX, I as sanitizeShellOutput, In as saveTuiConfig, It as DISABLE_TERMINAL_FOCUS_REPORTING, J as resetBreathingClock, Jn as saveCatalogCache, Jt as TERMINAL_THEME_LIGHT, K as BREATHE_CYCLE_MS, Kn as DEFAULT_CATALOG_URL, Kt as TERMINAL_FOCUS_OUT, L as SkillActivationComponent, Ln as detectShellEnvironment, Lt as DISABLE_TERMINAL_THEME_REPORTING, M as ThinkingComponent, Mn as PULSE_WAVE_FRAMES, Mt as contrastTextHex, N as NoticeMessageComponent, Nn as TuiConfigParseError, Nt as getColorPalette, O as renderDiffLinesClustered, On as getKnowledgeStore, Ot as isEmptySessionHintDismissed, P as StatusMessageComponent, Pn as TuiLikePreferencesSchema, Pt as detectTerminalTheme, Qn as appendSessionIndexEntry, Qt as lerpGradient, R as AssistantMessageComponent, Rn as getDataDir, Rt as ENABLE_TERMINAL_FOCUS_REPORTING, Sn as getNoActiveSessionMessage, St as clearInfoPanelState, T as UserMessageComponent, Tn as sortSlashCommands, Tt as resolveThemeSync, U as BackgroundAgentStatusComponent, Un as CLI_UI_MODE, Ut as OSC11_RESPONSE_PREFIX_NO_ESC, V as estimateTokens, Vn as detectInstallSource, Vt as OSC11_RESPONSE, W as AgentGroupComponent, Wn as CLI_USER_AGENT_PRODUCT, Wt as QUERY_TERMINAL_THEME, X as clearGoalState, Xn as encodeWorkDirKey, Xt as isStreaming, Y as CompactionComponent, Yn as ScreamHarness, Yt as isBusy, Z as refineGoal, Zn as normalizeWorkDir, Zt as FooterComponent, _ as selectUpdateTarget, _n as SESSION_TIPS, an as STATUS_BULLET, ar as log, at as changeThinkingLevel, b as appendJsonlLine, bn as getCtrlDHint, bt as refreshProviderBalance, c as hasDispose, cn as formatErrorMessage, cr as isOrphanedToolCallError, d as MoonLoader, dn as serializeToolResultOutput, dt as handleFusionPlanCommand, er as removeSessionIndexEntry, f as formatMemoryMemoForInjection, fn as stringValue, gn as MAIN_AGENT_ID, hn as EXIT_CONFIRM_WINDOW_MS, i as buildRoleAdditionalText, in as printableChar, ir as flushDiagnosticLogs, it as toTerminalHyperlink, j as CachedContainer, jn as PIXEL_PULSE_FRAMES, jt as createThemeStyles, k as highlightLines, kn as isEmbeddingModelCached, kt as isTurnElapsedEnabled, l as isExpandable, ln as isTodoItemShape, lr as ErrorCodes, mn as EMPTY_SESSION_HINT_URL, n as clearEvalPanelState, nr as resolveScreamHome, on as appendStreamingArgsPreview, or as resolveGlobalLogPath, ot as getModelCycleLevel, pn as truncateErrorMessage, pt as handlePlanCommand, q as getBreathingFrame, qn as fetchCatalog, qt as TERMINAL_THEME_DARK, r as openUrl, rr as MemoryMemoStore, rt as isInternalMessage, s as disposeChildren, sn as argsRecord, sr as isScreamError, t as dispatchInput, u as isPlanExpandable, un as parseStreamingArgs, ur as SCREAM_ERROR_INFO, v as refreshUpdateCache, vn as TIP_ROTATION_INTERVAL_MS, wn as BUILTIN_SLASH_COMMANDS, x as readJsonlFile, xn as getLlmNotSetMessage, xt as supportsBalance, y as readUpdateCache, yn as getCtrlCHint, z as ActivityGroupComponent, zn as getInputHistoryFile, zt as ENABLE_TERMINAL_THEME_REPORTING } from "./dispatch-
|
|
8
|
-
import { a as setLocale, i as getLocale, o as t } from "./text-input-dialog-
|
|
7
|
+
import { $n as readSessionIndex, $t as SubagentSlots, A as langFromPath, An as startManualEmbeddingDownload, At as toggleEmptySessionHint, B as charsForTokenBudget, Bn as getLogDir, Bt as OSC11_QUERY, C as getDaemonInstructions, Cn as buildSkillSlashCommands, D as renderDiffLines, Dn as setExperimentalFlags, Dt as createMarkdownTheme, E as ToolCallComponent, En as isExperimentalFlagEnabled, Et as createEditorTheme, F as replaceTabs, Fn as loadTuiConfig, Ft as parseOsc11BackgroundTheme, G as WelcomeComponent, Gn as PRODUCT_NAME, Gt as TERMINAL_FOCUS_IN, H as getSharedSpeedTracker, Hn as CLI_COMMAND_NAME, Ht as OSC11_RESPONSE_PREFIX, I as sanitizeShellOutput, In as saveTuiConfig, It as DISABLE_TERMINAL_FOCUS_REPORTING, J as resetBreathingClock, Jn as saveCatalogCache, Jt as TERMINAL_THEME_LIGHT, K as BREATHE_CYCLE_MS, Kn as DEFAULT_CATALOG_URL, Kt as TERMINAL_FOCUS_OUT, L as SkillActivationComponent, Ln as detectShellEnvironment, Lt as DISABLE_TERMINAL_THEME_REPORTING, M as ThinkingComponent, Mn as PULSE_WAVE_FRAMES, Mt as contrastTextHex, N as NoticeMessageComponent, Nn as TuiConfigParseError, Nt as getColorPalette, O as renderDiffLinesClustered, On as getKnowledgeStore, Ot as isEmptySessionHintDismissed, P as StatusMessageComponent, Pn as TuiLikePreferencesSchema, Pt as detectTerminalTheme, Qn as appendSessionIndexEntry, Qt as lerpGradient, R as AssistantMessageComponent, Rn as getDataDir, Rt as ENABLE_TERMINAL_FOCUS_REPORTING, Sn as getNoActiveSessionMessage, St as clearInfoPanelState, T as UserMessageComponent, Tn as sortSlashCommands, Tt as resolveThemeSync, U as BackgroundAgentStatusComponent, Un as CLI_UI_MODE, Ut as OSC11_RESPONSE_PREFIX_NO_ESC, V as estimateTokens, Vn as detectInstallSource, Vt as OSC11_RESPONSE, W as AgentGroupComponent, Wn as CLI_USER_AGENT_PRODUCT, Wt as QUERY_TERMINAL_THEME, X as clearGoalState, Xn as encodeWorkDirKey, Xt as isStreaming, Y as CompactionComponent, Yn as ScreamHarness, Yt as isBusy, Z as refineGoal, Zn as normalizeWorkDir, Zt as FooterComponent, _ as selectUpdateTarget, _n as SESSION_TIPS, an as STATUS_BULLET, ar as log, at as changeThinkingLevel, b as appendJsonlLine, bn as getCtrlDHint, bt as refreshProviderBalance, c as hasDispose, cn as formatErrorMessage, cr as isOrphanedToolCallError, d as MoonLoader, dn as serializeToolResultOutput, dt as handleFusionPlanCommand, er as removeSessionIndexEntry, f as formatMemoryMemoForInjection, fn as stringValue, gn as MAIN_AGENT_ID, hn as EXIT_CONFIRM_WINDOW_MS, i as buildRoleAdditionalText, in as printableChar, ir as flushDiagnosticLogs, it as toTerminalHyperlink, j as CachedContainer, jn as PIXEL_PULSE_FRAMES, jt as createThemeStyles, k as highlightLines, kn as isEmbeddingModelCached, kt as isTurnElapsedEnabled, l as isExpandable, ln as isTodoItemShape, lr as ErrorCodes, mn as EMPTY_SESSION_HINT_URL, n as clearEvalPanelState, nr as resolveScreamHome, on as appendStreamingArgsPreview, or as resolveGlobalLogPath, ot as getModelCycleLevel, pn as truncateErrorMessage, pt as handlePlanCommand, q as getBreathingFrame, qn as fetchCatalog, qt as TERMINAL_THEME_DARK, r as openUrl, rr as MemoryMemoStore, rt as isInternalMessage, s as disposeChildren, sn as argsRecord, sr as isScreamError, t as dispatchInput, u as isPlanExpandable, un as parseStreamingArgs, ur as SCREAM_ERROR_INFO, v as refreshUpdateCache, vn as TIP_ROTATION_INTERVAL_MS, wn as BUILTIN_SLASH_COMMANDS, x as readJsonlFile, xn as getLlmNotSetMessage, xt as supportsBalance, y as readUpdateCache, yn as getCtrlCHint, z as ActivityGroupComponent, zn as getInputHistoryFile, zt as ENABLE_TERMINAL_THEME_REPORTING } from "./dispatch-VY-K2oXV.mjs";
|
|
8
|
+
import { a as setLocale, i as getLocale, o as t } from "./text-input-dialog-KaFgI_Ko.mjs";
|
|
9
9
|
import { createRequire } from "node:module";
|
|
10
10
|
import { randomBytes, randomUUID, scryptSync, timingSafeEqual } from "node:crypto";
|
|
11
11
|
import { access, appendFile, chmod, mkdir, mkdtemp, readFile, readdir, realpath, rename, rm, stat, unlink, writeFile } from "node:fs/promises";
|
|
@@ -32,7 +32,7 @@ function optionalBuildString(value) {
|
|
|
32
32
|
return typeof value === "string" && value.length > 0 ? value : void 0;
|
|
33
33
|
}
|
|
34
34
|
const SCREAM_BUILD_INFO = {
|
|
35
|
-
version: optionalBuildString("0.16.
|
|
35
|
+
version: optionalBuildString("0.16.5"),
|
|
36
36
|
channel: optionalBuildString(""),
|
|
37
37
|
commit: optionalBuildString(""),
|
|
38
38
|
buildTarget: optionalBuildString("darwin-arm64")
|
|
@@ -3974,6 +3974,17 @@ var SessionReplayRenderer = class {
|
|
|
3974
3974
|
this.renderApprovalResult(context, record.record);
|
|
3975
3975
|
return;
|
|
3976
3976
|
case "config_updated": return;
|
|
3977
|
+
case "stream_draft_partial": {
|
|
3978
|
+
this.flushAssistant(context);
|
|
3979
|
+
const draftText = record.text.trim();
|
|
3980
|
+
if (draftText.length > 0) collectReplayMessageContent(context.assistant, [{
|
|
3981
|
+
type: "text",
|
|
3982
|
+
text: draftText
|
|
3983
|
+
}]);
|
|
3984
|
+
this.flushAssistant(context);
|
|
3985
|
+
this.host.appendTranscriptEntry(replayEntry(context, "status", t("replay.streamDraftPartial"), "notice"));
|
|
3986
|
+
return;
|
|
3987
|
+
}
|
|
3977
3988
|
}
|
|
3978
3989
|
}
|
|
3979
3990
|
renderMessage(context, message) {
|
|
@@ -13882,7 +13893,7 @@ var ScreamTUI = class {
|
|
|
13882
13893
|
const card = new OnboardingCardComponent({
|
|
13883
13894
|
colors: this.state.theme.colors,
|
|
13884
13895
|
onConfigure: () => {
|
|
13885
|
-
import("./dispatch-
|
|
13896
|
+
import("./dispatch-BNVgLsrQ.mjs").then(({ handleConnectCommand }) => handleConnectCommand(this, "")).finally(() => {
|
|
13886
13897
|
this.restoreEditor();
|
|
13887
13898
|
onDone?.();
|
|
13888
13899
|
});
|
|
@@ -18343,6 +18354,143 @@ var SessionManager = class {
|
|
|
18343
18354
|
}
|
|
18344
18355
|
};
|
|
18345
18356
|
/**
|
|
18357
|
+
* Session-backed data routes: snapshot, message history / thinking entries,
|
|
18358
|
+
* git status and single-file diff, plus the read-only file gate. Returns true
|
|
18359
|
+
* when the request was handled (including the not-found arms).
|
|
18360
|
+
*/
|
|
18361
|
+
async function handleSessionDataRoutes(req, res, url, method, resolveSession, workDir, fileGate) {
|
|
18362
|
+
const snapshotMatch = new RegExp(`^${API_PREFIX}/sessions/([^/]+)/snapshot(\\?|$)`).exec(url);
|
|
18363
|
+
if (snapshotMatch && method === "GET") {
|
|
18364
|
+
let sessionId;
|
|
18365
|
+
try {
|
|
18366
|
+
sessionId = decodeURIComponent(snapshotMatch[1]);
|
|
18367
|
+
} catch {
|
|
18368
|
+
res.writeHead(404, { "Content-Type": "application/json" });
|
|
18369
|
+
res.end(JSON.stringify({
|
|
18370
|
+
code: 404,
|
|
18371
|
+
message: "Session not found"
|
|
18372
|
+
}));
|
|
18373
|
+
return true;
|
|
18374
|
+
}
|
|
18375
|
+
const ws = resolveSession(sessionId);
|
|
18376
|
+
if (!ws) {
|
|
18377
|
+
res.writeHead(404, { "Content-Type": "application/json" });
|
|
18378
|
+
res.end(JSON.stringify({
|
|
18379
|
+
code: 404,
|
|
18380
|
+
message: "Session not found"
|
|
18381
|
+
}));
|
|
18382
|
+
return true;
|
|
18383
|
+
}
|
|
18384
|
+
try {
|
|
18385
|
+
await ws.ready;
|
|
18386
|
+
const query = new URLSearchParams(url.split("?")[1] ?? "");
|
|
18387
|
+
const tail = Number(query.get("tail") ?? "");
|
|
18388
|
+
sendJson(res, 200, Number.isFinite(tail) && tail > 0 ? ws.getSnapshot({ tail }) : ws.getSnapshot());
|
|
18389
|
+
} catch (error) {
|
|
18390
|
+
sendHttpError(res, error);
|
|
18391
|
+
}
|
|
18392
|
+
return true;
|
|
18393
|
+
}
|
|
18394
|
+
const olderMatch = new RegExp(`^${API_PREFIX}/sessions/([^/?]+)/messages(\\?|$)`).exec(url);
|
|
18395
|
+
if (olderMatch && method === "GET") {
|
|
18396
|
+
let sessionId;
|
|
18397
|
+
try {
|
|
18398
|
+
sessionId = decodeURIComponent(olderMatch[1]);
|
|
18399
|
+
} catch {
|
|
18400
|
+
res.writeHead(404, { "Content-Type": "application/json" });
|
|
18401
|
+
res.end(JSON.stringify({
|
|
18402
|
+
code: 404,
|
|
18403
|
+
message: "Session not found"
|
|
18404
|
+
}));
|
|
18405
|
+
return true;
|
|
18406
|
+
}
|
|
18407
|
+
const ws = resolveSession(sessionId);
|
|
18408
|
+
if (!ws) {
|
|
18409
|
+
res.writeHead(404, { "Content-Type": "application/json" });
|
|
18410
|
+
res.end(JSON.stringify({
|
|
18411
|
+
code: 404,
|
|
18412
|
+
message: "Session not found"
|
|
18413
|
+
}));
|
|
18414
|
+
return true;
|
|
18415
|
+
}
|
|
18416
|
+
try {
|
|
18417
|
+
await ws.ready;
|
|
18418
|
+
const query = new URLSearchParams(url.split("?")[1] ?? "");
|
|
18419
|
+
const seq = Number(query.get("seq") ?? "0");
|
|
18420
|
+
const tool = query.get("tool") ?? "";
|
|
18421
|
+
if (Number.isFinite(seq) && seq > 0 && tool) {
|
|
18422
|
+
sendJson(res, 200, { output: ws.getThinkingEntry(seq, tool) });
|
|
18423
|
+
return true;
|
|
18424
|
+
}
|
|
18425
|
+
const before = Number(query.get("before") ?? "0");
|
|
18426
|
+
const tail = Number(query.get("tail") ?? "50");
|
|
18427
|
+
sendJson(res, 200, Number.isFinite(before) && before > 0 ? ws.getMessagesOlder(before, Number.isFinite(tail) && tail > 0 ? tail : 50) : {
|
|
18428
|
+
messages: [],
|
|
18429
|
+
hasMore: false
|
|
18430
|
+
});
|
|
18431
|
+
} catch (error) {
|
|
18432
|
+
sendHttpError(res, error);
|
|
18433
|
+
}
|
|
18434
|
+
return true;
|
|
18435
|
+
}
|
|
18436
|
+
if (url === `${API_PREFIX}/git/status` && method === "GET") {
|
|
18437
|
+
const gs = await getGitStatus(workDir);
|
|
18438
|
+
res.writeHead(200, { "Content-Type": "application/json" });
|
|
18439
|
+
res.end(JSON.stringify(gs));
|
|
18440
|
+
return true;
|
|
18441
|
+
}
|
|
18442
|
+
if (url.startsWith(`${API_PREFIX}/git/diff?`) && method === "GET") {
|
|
18443
|
+
const relPath = new URLSearchParams(url.split("?")[1] ?? "").get("path") ?? "";
|
|
18444
|
+
try {
|
|
18445
|
+
const result = await getGitFileDiff(workDir, relPath);
|
|
18446
|
+
res.writeHead(200, { "Content-Type": "application/json" });
|
|
18447
|
+
res.end(JSON.stringify({
|
|
18448
|
+
path: relPath,
|
|
18449
|
+
patch: result?.patch ?? ""
|
|
18450
|
+
}));
|
|
18451
|
+
} catch (error) {
|
|
18452
|
+
sendHttpError(res, error);
|
|
18453
|
+
}
|
|
18454
|
+
return true;
|
|
18455
|
+
}
|
|
18456
|
+
if (await handleFilesRoutes(req, res, url, method, API_PREFIX, fileGate)) return true;
|
|
18457
|
+
return false;
|
|
18458
|
+
}
|
|
18459
|
+
/**
|
|
18460
|
+
* SPA shell (`no-store`, so a reload never serves a stale bundle), content-
|
|
18461
|
+
* hashed `/assets/` with long-term caching, and the terminal 404. Always ends
|
|
18462
|
+
* the request, so it must be the last handler in the chain.
|
|
18463
|
+
*/
|
|
18464
|
+
async function handleStaticRoutes(res, url, publicDir) {
|
|
18465
|
+
if (url === "/" || url === "/index.html") {
|
|
18466
|
+
try {
|
|
18467
|
+
const html = await readFile(join(publicDir, "index.html"), "utf-8");
|
|
18468
|
+
res.writeHead(200, {
|
|
18469
|
+
"Content-Type": "text/html; charset=utf-8",
|
|
18470
|
+
"Cache-Control": "no-store"
|
|
18471
|
+
});
|
|
18472
|
+
res.end(html);
|
|
18473
|
+
} catch {
|
|
18474
|
+
res.writeHead(500, { "Content-Type": "text/plain" });
|
|
18475
|
+
res.end("Failed to load web UI. Did you run pnpm web:build?");
|
|
18476
|
+
}
|
|
18477
|
+
return;
|
|
18478
|
+
}
|
|
18479
|
+
const safeUrl = url.replaceAll(/\?.*$/g, "").replaceAll(/\.{2,}/g, "");
|
|
18480
|
+
try {
|
|
18481
|
+
const filePath = join(publicDir, safeUrl);
|
|
18482
|
+
const contentType = contentTypes[filePath.split(".").pop() ?? ""] ?? "application/octet-stream";
|
|
18483
|
+
const data = await readFile(filePath);
|
|
18484
|
+
const headers = { "Content-Type": contentType };
|
|
18485
|
+
if (safeUrl.startsWith("/assets/")) headers["Cache-Control"] = "public, max-age=31536000, immutable";
|
|
18486
|
+
res.writeHead(200, headers);
|
|
18487
|
+
res.end(data);
|
|
18488
|
+
} catch {
|
|
18489
|
+
res.writeHead(404, { "Content-Type": "text/plain" });
|
|
18490
|
+
res.end("Not found");
|
|
18491
|
+
}
|
|
18492
|
+
}
|
|
18493
|
+
/**
|
|
18346
18494
|
* Watchdog shared by both web entry points. Detects "nobody is using the UI"
|
|
18347
18495
|
* as: zero WebSocket connections AND no HTTP request for `idleMs`, with an
|
|
18348
18496
|
* in-flight agent turn (`busy()`) deferring the exit so background work is
|
|
@@ -18894,84 +19042,7 @@ async function runWebServer(opts) {
|
|
|
18894
19042
|
if (await handleSessionControlRoutes(req, res, url, method, manager)) return;
|
|
18895
19043
|
if (await handleResourceRoutes(req, res, url, method, manager)) return;
|
|
18896
19044
|
if (await handleGlobalRoutes(req, res, url, method, manager)) return;
|
|
18897
|
-
|
|
18898
|
-
if (snapshotMatch && method === "GET") {
|
|
18899
|
-
const sessionId = decodeURIComponent(snapshotMatch[1]);
|
|
18900
|
-
const ws = manager.get(sessionId);
|
|
18901
|
-
if (!ws) {
|
|
18902
|
-
res.writeHead(404, { "Content-Type": "application/json" });
|
|
18903
|
-
res.end(JSON.stringify({
|
|
18904
|
-
code: 404,
|
|
18905
|
-
message: "Session not found"
|
|
18906
|
-
}));
|
|
18907
|
-
return;
|
|
18908
|
-
}
|
|
18909
|
-
try {
|
|
18910
|
-
await ws.ready;
|
|
18911
|
-
const query = new URLSearchParams(url.split("?")[1] ?? "");
|
|
18912
|
-
const tail = Number(query.get("tail") ?? "");
|
|
18913
|
-
sendJson(res, 200, Number.isFinite(tail) && tail > 0 ? ws.getSnapshot({ tail }) : ws.getSnapshot());
|
|
18914
|
-
} catch (error) {
|
|
18915
|
-
sendHttpError(res, error);
|
|
18916
|
-
}
|
|
18917
|
-
return;
|
|
18918
|
-
}
|
|
18919
|
-
const olderMatch = /^\/api\/v1\/sessions\/([^/?]+)\/messages(\?|$)/.exec(url);
|
|
18920
|
-
if (olderMatch && method === "GET") {
|
|
18921
|
-
const sessionId = decodeURIComponent(olderMatch[1]);
|
|
18922
|
-
const ws = manager.get(sessionId);
|
|
18923
|
-
if (!ws) {
|
|
18924
|
-
res.writeHead(404, { "Content-Type": "application/json" });
|
|
18925
|
-
res.end(JSON.stringify({
|
|
18926
|
-
code: 404,
|
|
18927
|
-
message: "Session not found"
|
|
18928
|
-
}));
|
|
18929
|
-
return;
|
|
18930
|
-
}
|
|
18931
|
-
try {
|
|
18932
|
-
await ws.ready;
|
|
18933
|
-
const query = new URLSearchParams(url.split("?")[1] ?? "");
|
|
18934
|
-
const seq = Number(query.get("seq") ?? "0");
|
|
18935
|
-
const tool = query.get("tool") ?? "";
|
|
18936
|
-
if (Number.isFinite(seq) && seq > 0 && tool) {
|
|
18937
|
-
sendJson(res, 200, { output: ws.getThinkingEntry(seq, tool) });
|
|
18938
|
-
return;
|
|
18939
|
-
}
|
|
18940
|
-
const before = Number(query.get("before") ?? "0");
|
|
18941
|
-
const tail = Number(query.get("tail") ?? "50");
|
|
18942
|
-
sendJson(res, 200, Number.isFinite(before) && before > 0 ? ws.getMessagesOlder(before, Number.isFinite(tail) && tail > 0 ? tail : 50) : {
|
|
18943
|
-
messages: [],
|
|
18944
|
-
hasMore: false
|
|
18945
|
-
});
|
|
18946
|
-
} catch (error) {
|
|
18947
|
-
sendHttpError(res, error);
|
|
18948
|
-
}
|
|
18949
|
-
return;
|
|
18950
|
-
}
|
|
18951
|
-
if (url === `${API_PREFIX}/git/status` && method === "GET") {
|
|
18952
|
-
const gs = await getGitStatus(workDir);
|
|
18953
|
-
res.writeHead(200, { "Content-Type": "application/json" });
|
|
18954
|
-
res.end(JSON.stringify(gs));
|
|
18955
|
-
return;
|
|
18956
|
-
}
|
|
18957
|
-
if (url.startsWith(`${API_PREFIX}/git/diff?`) && method === "GET") {
|
|
18958
|
-
const relPath = new URLSearchParams(url.split("?")[1] ?? "").get("path") ?? "";
|
|
18959
|
-
try {
|
|
18960
|
-
const result = await getGitFileDiff(workDir, relPath);
|
|
18961
|
-
res.writeHead(200, { "Content-Type": "application/json" });
|
|
18962
|
-
res.end(JSON.stringify({
|
|
18963
|
-
path: relPath,
|
|
18964
|
-
patch: result?.patch ?? ""
|
|
18965
|
-
}));
|
|
18966
|
-
} catch (error) {
|
|
18967
|
-
sendHttpError(res, error);
|
|
18968
|
-
}
|
|
18969
|
-
return;
|
|
18970
|
-
}
|
|
18971
|
-
function makeFileGate() {
|
|
18972
|
-
return new FileGate(() => manager.list().map((s) => s.workDir));
|
|
18973
|
-
}
|
|
18974
|
-
if (await handleFilesRoutes(req, res, url, method, API_PREFIX, makeFileGate())) return;
|
|
19045
|
+
if (await handleSessionDataRoutes(req, res, url, method, (sessionId) => manager.get(sessionId), workDir, new FileGate(() => manager.list().map((s) => s.workDir)))) return;
|
|
18975
19046
|
if (url === `${API_PREFIX}/like` && method === "GET") {
|
|
18976
19047
|
try {
|
|
18977
19048
|
sendJson(res, 200, await loadLikePreferences());
|
|
@@ -19179,33 +19250,7 @@ async function runWebServer(opts) {
|
|
|
19179
19250
|
}
|
|
19180
19251
|
return;
|
|
19181
19252
|
}
|
|
19182
|
-
|
|
19183
|
-
try {
|
|
19184
|
-
const html = await readFile(join(publicDir, "index.html"), "utf-8");
|
|
19185
|
-
res.writeHead(200, {
|
|
19186
|
-
"Content-Type": "text/html; charset=utf-8",
|
|
19187
|
-
"Cache-Control": "no-store"
|
|
19188
|
-
});
|
|
19189
|
-
res.end(html);
|
|
19190
|
-
} catch {
|
|
19191
|
-
res.writeHead(500, { "Content-Type": "text/plain" });
|
|
19192
|
-
res.end("Failed to load web UI. Did you run pnpm web:build?");
|
|
19193
|
-
}
|
|
19194
|
-
return;
|
|
19195
|
-
}
|
|
19196
|
-
const safeUrl = url.replaceAll(/\?.*$/g, "").replaceAll(/\.{2,}/g, "");
|
|
19197
|
-
try {
|
|
19198
|
-
const filePath = join(publicDir, safeUrl);
|
|
19199
|
-
const contentType = contentTypes[filePath.split(".").pop() ?? ""] ?? "application/octet-stream";
|
|
19200
|
-
const data = await readFile(filePath);
|
|
19201
|
-
const headers = { "Content-Type": contentType };
|
|
19202
|
-
if (safeUrl.startsWith("/assets/")) headers["Cache-Control"] = "public, max-age=31536000, immutable";
|
|
19203
|
-
res.writeHead(200, headers);
|
|
19204
|
-
res.end(data);
|
|
19205
|
-
} catch {
|
|
19206
|
-
res.writeHead(404, { "Content-Type": "text/plain" });
|
|
19207
|
-
res.end("Not found");
|
|
19208
|
-
}
|
|
19253
|
+
await handleStaticRoutes(res, url, publicDir);
|
|
19209
19254
|
});
|
|
19210
19255
|
const wss = new WebSocketServer({ server: httpServer });
|
|
19211
19256
|
wss.on("error", () => {});
|
|
@@ -3,5 +3,5 @@ import { fileURLToPath as __cjsShimFileURLToPath } from 'node:url';
|
|
|
3
3
|
import { dirname as __cjsShimDirname } from 'node:path';
|
|
4
4
|
const __filename = __cjsShimFileURLToPath(import.meta.url);
|
|
5
5
|
const __dirname = __cjsShimDirname(__filename);
|
|
6
|
-
import { nn as handleConnectCommand } from "./dispatch-
|
|
6
|
+
import { nn as handleConnectCommand } from "./dispatch-VY-K2oXV.mjs";
|
|
7
7
|
export { handleConnectCommand };
|