scream-code 0.10.13 → 0.11.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{app-DBxlfmut.mjs → app-CuAxNnOv.mjs} +67 -17
- package/dist/main.mjs +1 -1
- package/dist/public/assets/index-2xNGacMZ.js +91 -0
- package/dist/public/assets/index-2xNGacMZ.js.map +1 -0
- package/dist/public/assets/index-CufIY2bi.css +1 -0
- package/dist/public/index.html +2 -2
- package/package.json +1 -1
- package/dist/public/assets/index-DDxNjEwB.css +0 -1
- package/dist/public/assets/index-Dh3SHY7E.js +0 -93
- package/dist/public/assets/index-Dh3SHY7E.js.map +0 -1
|
@@ -120184,7 +120184,7 @@ function optionalBuildString(value) {
|
|
|
120184
120184
|
return typeof value === "string" && value.length > 0 ? value : void 0;
|
|
120185
120185
|
}
|
|
120186
120186
|
const SCREAM_BUILD_INFO = {
|
|
120187
|
-
version: optionalBuildString("0.
|
|
120187
|
+
version: optionalBuildString("0.11.0"),
|
|
120188
120188
|
channel: optionalBuildString(""),
|
|
120189
120189
|
commit: optionalBuildString(""),
|
|
120190
120190
|
buildTarget: optionalBuildString("darwin-arm64")
|
|
@@ -146334,11 +146334,21 @@ const contentTypes = {
|
|
|
146334
146334
|
function readJsonBody(req) {
|
|
146335
146335
|
return new Promise((resolve, reject) => {
|
|
146336
146336
|
let data = "";
|
|
146337
|
+
let size = 0;
|
|
146338
|
+
let rejected = false;
|
|
146337
146339
|
req.on("data", (chunk) => {
|
|
146340
|
+
if (rejected) return;
|
|
146341
|
+
size += chunk.length;
|
|
146342
|
+
if (size > 64 * 1024) {
|
|
146343
|
+
rejected = true;
|
|
146344
|
+
data = "";
|
|
146345
|
+
reject(new HttpError(413, "Request body too large"));
|
|
146346
|
+
return;
|
|
146347
|
+
}
|
|
146338
146348
|
data += chunk.toString("utf-8");
|
|
146339
|
-
if (data.length > 64 * 1024) reject(new HttpError(413, "Request body too large"));
|
|
146340
146349
|
});
|
|
146341
146350
|
req.on("end", () => {
|
|
146351
|
+
if (rejected) return;
|
|
146342
146352
|
if (!data) {
|
|
146343
146353
|
resolve({});
|
|
146344
146354
|
return;
|
|
@@ -146544,6 +146554,8 @@ var WebSession = class {
|
|
|
146544
146554
|
heartbeatTimer = null;
|
|
146545
146555
|
unsubscribe = null;
|
|
146546
146556
|
busy = false;
|
|
146557
|
+
/** pendingMsgId awaiting compaction completion/cancellation event. */
|
|
146558
|
+
pendingCompactionMsgId = null;
|
|
146547
146559
|
homeDir;
|
|
146548
146560
|
yolo;
|
|
146549
146561
|
/** Fork hook supplied by SessionManager; absent in standalone mode. */
|
|
@@ -146586,7 +146598,8 @@ var WebSession = class {
|
|
|
146586
146598
|
for (const um of this.userMessages) entries.push({
|
|
146587
146599
|
type: "user_message",
|
|
146588
146600
|
text: um.msg.content,
|
|
146589
|
-
beforeSeq: um.beforeSeq
|
|
146601
|
+
beforeSeq: um.beforeSeq,
|
|
146602
|
+
clientMessageId: um.msg.clientMessageId
|
|
146590
146603
|
});
|
|
146591
146604
|
return entries;
|
|
146592
146605
|
}
|
|
@@ -146598,11 +146611,12 @@ var WebSession = class {
|
|
|
146598
146611
|
});
|
|
146599
146612
|
await appendJournalLine(this.homeDir, this.sessionId, line);
|
|
146600
146613
|
}
|
|
146601
|
-
async persistUserMessage(text, beforeSeq) {
|
|
146614
|
+
async persistUserMessage(text, beforeSeq, clientMessageId) {
|
|
146602
146615
|
this.userMessages.push({
|
|
146603
146616
|
msg: {
|
|
146604
146617
|
role: "user",
|
|
146605
146618
|
content: text,
|
|
146619
|
+
clientMessageId,
|
|
146606
146620
|
tools: []
|
|
146607
146621
|
},
|
|
146608
146622
|
beforeSeq
|
|
@@ -146611,7 +146625,8 @@ var WebSession = class {
|
|
|
146611
146625
|
const line = JSON.stringify({
|
|
146612
146626
|
type: "user_message",
|
|
146613
146627
|
text,
|
|
146614
|
-
beforeSeq
|
|
146628
|
+
beforeSeq,
|
|
146629
|
+
clientMessageId
|
|
146615
146630
|
});
|
|
146616
146631
|
await appendJournalLine(this.homeDir, this.sessionId, line);
|
|
146617
146632
|
}
|
|
@@ -146622,6 +146637,7 @@ var WebSession = class {
|
|
|
146622
146637
|
msg: {
|
|
146623
146638
|
role: "user",
|
|
146624
146639
|
content: um.text,
|
|
146640
|
+
clientMessageId: um.clientMessageId,
|
|
146625
146641
|
tools: []
|
|
146626
146642
|
},
|
|
146627
146643
|
beforeSeq: um.beforeSeq
|
|
@@ -146679,6 +146695,28 @@ var WebSession = class {
|
|
|
146679
146695
|
epoch: entry.epoch,
|
|
146680
146696
|
payload: event
|
|
146681
146697
|
}, entry.volatile);
|
|
146698
|
+
if (event.type === "compaction.completed") {
|
|
146699
|
+
const msgId = this.pendingCompactionMsgId;
|
|
146700
|
+
this.pendingCompactionMsgId = null;
|
|
146701
|
+
this.refreshStatus().then(() => this.broadcastStatus());
|
|
146702
|
+
if (msgId) this.broadcast({
|
|
146703
|
+
type: "command_result",
|
|
146704
|
+
command: "compact",
|
|
146705
|
+
ok: true,
|
|
146706
|
+
message: "会话上下文已压缩。",
|
|
146707
|
+
pendingMsgId: msgId
|
|
146708
|
+
}, false);
|
|
146709
|
+
} else if (event.type === "compaction.cancelled") {
|
|
146710
|
+
const msgId = this.pendingCompactionMsgId;
|
|
146711
|
+
this.pendingCompactionMsgId = null;
|
|
146712
|
+
if (msgId) this.broadcast({
|
|
146713
|
+
type: "command_result",
|
|
146714
|
+
command: "compact",
|
|
146715
|
+
ok: false,
|
|
146716
|
+
message: `压缩已取消${event.reason ? `:${event.reason}` : "。"}`,
|
|
146717
|
+
pendingMsgId: msgId
|
|
146718
|
+
}, false);
|
|
146719
|
+
}
|
|
146682
146720
|
});
|
|
146683
146721
|
}
|
|
146684
146722
|
async refreshStatus() {
|
|
@@ -146766,7 +146804,8 @@ var WebSession = class {
|
|
|
146766
146804
|
this.send(ws, {
|
|
146767
146805
|
type: "error",
|
|
146768
146806
|
code: "session.inactive",
|
|
146769
|
-
message: "Session is archived (read-only)"
|
|
146807
|
+
message: "Session is archived (read-only)",
|
|
146808
|
+
clientMessageId
|
|
146770
146809
|
});
|
|
146771
146810
|
return;
|
|
146772
146811
|
}
|
|
@@ -146774,18 +146813,21 @@ var WebSession = class {
|
|
|
146774
146813
|
this.send(ws, {
|
|
146775
146814
|
type: "error",
|
|
146776
146815
|
code: "session.busy",
|
|
146777
|
-
message: "Session is busy"
|
|
146816
|
+
message: "Session is busy",
|
|
146817
|
+
clientMessageId
|
|
146778
146818
|
});
|
|
146779
146819
|
return;
|
|
146780
146820
|
}
|
|
146781
|
-
this.
|
|
146821
|
+
this.busy = true;
|
|
146822
|
+
this.persistUserMessage(text, this.nextSeq, clientMessageId);
|
|
146782
146823
|
this.broadcast({
|
|
146783
146824
|
type: "user_message",
|
|
146784
146825
|
clientMessageId,
|
|
146785
146826
|
text
|
|
146786
146827
|
}, false);
|
|
146787
146828
|
this.session.prompt(text).catch((error) => {
|
|
146788
|
-
this.
|
|
146829
|
+
this.busy = false;
|
|
146830
|
+
this.sendError(ws, error, clientMessageId);
|
|
146789
146831
|
});
|
|
146790
146832
|
break;
|
|
146791
146833
|
}
|
|
@@ -146856,11 +146898,12 @@ var WebSession = class {
|
|
|
146856
146898
|
payload: entry.payload
|
|
146857
146899
|
});
|
|
146858
146900
|
}
|
|
146859
|
-
sendError(ws, error) {
|
|
146901
|
+
sendError(ws, error, clientMessageId) {
|
|
146860
146902
|
const message = error instanceof Error ? error.message : String(error);
|
|
146861
146903
|
this.send(ws, {
|
|
146862
146904
|
type: "error",
|
|
146863
|
-
message
|
|
146905
|
+
message,
|
|
146906
|
+
clientMessageId
|
|
146864
146907
|
});
|
|
146865
146908
|
}
|
|
146866
146909
|
async handleCommand(ws, command, args, pendingMsgId) {
|
|
@@ -146893,13 +146936,15 @@ var WebSession = class {
|
|
|
146893
146936
|
fail("会话忙碌中,无法压缩,请稍后再试。");
|
|
146894
146937
|
return;
|
|
146895
146938
|
}
|
|
146896
|
-
|
|
146939
|
+
if (this.pendingCompactionMsgId !== null) {
|
|
146940
|
+
fail("正在压缩中,请稍候。");
|
|
146941
|
+
return;
|
|
146942
|
+
}
|
|
146943
|
+
this.pendingCompactionMsgId = pendingMsgId ?? null;
|
|
146897
146944
|
try {
|
|
146898
146945
|
await this.session.compact();
|
|
146899
|
-
await this.refreshStatus();
|
|
146900
|
-
this.broadcastStatus();
|
|
146901
|
-
ok("会话上下文已压缩。");
|
|
146902
146946
|
} catch (error) {
|
|
146947
|
+
this.pendingCompactionMsgId = null;
|
|
146903
146948
|
fail(`压缩失败:${errMsg(error)}`);
|
|
146904
146949
|
}
|
|
146905
146950
|
return;
|
|
@@ -147029,6 +147074,8 @@ var WebSession = class {
|
|
|
147029
147074
|
return {
|
|
147030
147075
|
sessionId: this.sessionId,
|
|
147031
147076
|
workDir: this.workDir,
|
|
147077
|
+
seq: this.nextSeq - 1,
|
|
147078
|
+
epoch: this.epoch,
|
|
147032
147079
|
model: this.cachedStatus?.model ?? "unknown",
|
|
147033
147080
|
permission: this.cachedStatus?.permission ?? this.permission,
|
|
147034
147081
|
messages: this.buildMessages(),
|
|
@@ -147439,7 +147486,10 @@ async function runWebServer(opts) {
|
|
|
147439
147486
|
yolo: opts.yolo
|
|
147440
147487
|
});
|
|
147441
147488
|
await manager.init();
|
|
147442
|
-
if (!manager.list().some((s) => s.active))
|
|
147489
|
+
if (!manager.list().some((s) => s.active)) {
|
|
147490
|
+
const recent = manager.list().find((s) => s.workDir === workDir);
|
|
147491
|
+
if (recent) await manager.activateSession(recent.sessionId);
|
|
147492
|
+
}
|
|
147443
147493
|
const baseDir = import.meta.dirname;
|
|
147444
147494
|
const prodPublicDir = join(baseDir, "public");
|
|
147445
147495
|
const devPublicDir = join(baseDir, "frontend", "dist");
|
|
@@ -147668,7 +147718,7 @@ async function runWebServer(opts) {
|
|
|
147668
147718
|
return;
|
|
147669
147719
|
}
|
|
147670
147720
|
}
|
|
147671
|
-
ws.
|
|
147721
|
+
ws.send(JSON.stringify({ type: "server_empty" }));
|
|
147672
147722
|
});
|
|
147673
147723
|
await new Promise((resolve) => {
|
|
147674
147724
|
httpServer.listen(opts.port, "127.0.0.1", resolve);
|
package/dist/main.mjs
CHANGED
|
@@ -6,7 +6,7 @@ const __dirname = __cjsShimDirname(__filename);
|
|
|
6
6
|
import "./suppress-sqlite-warning-C2VB0doZ.mjs";
|
|
7
7
|
//#region src/main.ts
|
|
8
8
|
try {
|
|
9
|
-
(await import("./app-
|
|
9
|
+
(await import("./app-CuAxNnOv.mjs")).main();
|
|
10
10
|
} catch (error) {
|
|
11
11
|
process.stderr.write(`${error instanceof Error ? error.stack ?? error.message : String(error)}\n`);
|
|
12
12
|
process.exit(1);
|