@threadbase-sh/streamer 1.69.1 → 1.69.3
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/api/handlers/sessions.handlers.d.ts.map +1 -1
- package/dist/cli.cjs +46 -43
- package/dist/cli.cjs.map +1 -1
- package/dist/codex-pty-runner.d.ts.map +1 -1
- package/dist/index.cjs +46 -43
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +46 -43
- package/dist/index.js.map +1 -1
- package/dist/pty-manager.d.ts.map +1 -1
- package/dist/pty-shared.d.ts +0 -1
- package/dist/pty-shared.d.ts.map +1 -1
- package/package.json +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"codex-pty-runner.d.ts","sourceRoot":"","sources":["../src/codex-pty-runner.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"codex-pty-runner.d.ts","sourceRoot":"","sources":["../src/codex-pty-runner.ts"],"names":[],"mappings":"AAmCA,OAAO,KAAK,EAEV,cAAc,EACd,iBAAiB,EACjB,aAAa,EACb,uBAAuB,EACvB,wBAAwB,EACxB,mBAAmB,EAEnB,WAAW,EACZ,MAAM,SAAS,CAAC;AA+CjB,qBAAa,cAAe,YAAW,aAAa;IAClD,OAAO,CAAC,QAAQ,CAAsC;IACtD,OAAO,CAAC,QAAQ,CAAgC;IAChD,OAAO,CAAC,cAAc,CAAsC;IAC5D,OAAO,CAAC,aAAa,CAAqC;IAC1D,OAAO,CAAC,OAAO,CAA+B;IAa9C,OAAO,CAAC,kBAAkB,CAA0C;IACpE,OAAO,CAAC,aAAa,CAAqC;IAC1D,OAAO,CAAC,GAAG,CAAS;IAGpB,OAAO,CAAC,YAAY,CAAqB;IAGzC,OAAO,CAAC,YAAY,CAA+B;IAInD,OAAO,CAAC,QAAQ,CAAoC;IAGpD,OAAO,CAAC,YAAY,CAAqB;IAGzC,OAAO,CAAC,aAAa,CAAsD;IAE3E,OAAO,CAAC,mBAAmB,CA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AAC,MAAM,EAAE,CAAC,CAc3E;IAED,eAAe,CAAC,SAAS,EAAE,MAAM,GAAG,WAAW,EAAE,CAEhD;IAID,MAAM,CAAC,SAAS,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI,CAEvC;IAID,OAAO,CAAC,iBAAiB;IASzB,UAAU,CAAC,SAAS,EAAE,MAAM,GAAG,cAAc,GAAG,IAAI,CAGnD;IAED,UAAU,CAAC,SAAS,EAAE,MAAM,GAAG,OAAO,CAErC;IAED,YAAY,IAAI,cAAc,EAAE,CAE/B;IAED,OAAO,IAAI,IAAI,CA+Bd;IAED,OAAO,CAAC,YAAY;YA2DN,iBAAiB;IA6J/B,OAAO,CAAC,oBAAoB;IA4B5B,OAAO,CAAC,qBAAqB;IAc7B,OAAO,CAAC,UAAU;IAgClB;;;;;;OAMG;IACH,OAAO,CAAC,QAAQ;IAOhB,OAAO,CAAC,SAAS;IAsCjB;;;;;;;;;OASG;IACH,OAAO,CAAC,WAAW;IAoCnB,OAAO,CAAC,UAAU;CAyBnB"}
|
package/dist/index.cjs
CHANGED
|
@@ -1099,11 +1099,6 @@ var PTY_COLS = 120;
|
|
|
1099
1099
|
var PTY_ROWS = 40;
|
|
1100
1100
|
var SCREEN_SCROLLBACK = 1e3;
|
|
1101
1101
|
var REPLAY_MAX_LINES = SCREEN_SCROLLBACK + PTY_ROWS;
|
|
1102
|
-
function digestBytes(s) {
|
|
1103
|
-
const escaped = s.replace(new RegExp(String.fromCharCode(27), "g"), "\\x1b").replace(/\r/g, "\\r").replace(/\n/g, "\\n").replace(/\t/g, "\\t");
|
|
1104
|
-
if (escaped.length <= 200) return escaped;
|
|
1105
|
-
return `${escaped.slice(0, 100)}\u2026[${escaped.length - 200}B omitted]\u2026${escaped.slice(-100)}`;
|
|
1106
|
-
}
|
|
1107
1102
|
var pty = null;
|
|
1108
1103
|
async function loadPty() {
|
|
1109
1104
|
if (pty) return pty;
|
|
@@ -1538,17 +1533,12 @@ var CodexPtyRunner = class {
|
|
|
1538
1533
|
const lines = await this.getOutputLines(sessionId, PTY_ROWS);
|
|
1539
1534
|
if (!this.pendingReady.has(sessionId)) return;
|
|
1540
1535
|
const busy = codexScreenBlocksComposer(lines);
|
|
1541
|
-
|
|
1542
|
-
|
|
1543
|
-
|
|
1544
|
-
|
|
1545
|
-
|
|
1546
|
-
|
|
1547
|
-
busy,
|
|
1548
|
-
hasReady: codexScreenShowsReady(lines),
|
|
1549
|
-
statusBar: bar.slice(0, 160)
|
|
1550
|
-
}
|
|
1551
|
-
);
|
|
1536
|
+
this.log.info(`[codex.ready_fallback] ${sessionId.slice(0, 8)} busy=${busy}`, {
|
|
1537
|
+
event: "codex.ready_fallback",
|
|
1538
|
+
sessionId,
|
|
1539
|
+
busy,
|
|
1540
|
+
hasReady: codexScreenShowsReady(lines)
|
|
1541
|
+
});
|
|
1552
1542
|
if (busy) {
|
|
1553
1543
|
this.armReadyFallback(sessionId);
|
|
1554
1544
|
return;
|
|
@@ -1583,10 +1573,11 @@ var CodexPtyRunner = class {
|
|
|
1583
1573
|
const gate = this.openGate.get(sessionId);
|
|
1584
1574
|
const digit = gate ? /^([0-9])\r?$/.exec(keys)?.[1] : void 0;
|
|
1585
1575
|
const out = gate && digit ? this.resolveGateAnswer(sessionId, gate, digit) : keys;
|
|
1586
|
-
this.log.info(
|
|
1587
|
-
|
|
1588
|
-
|
|
1589
|
-
|
|
1576
|
+
this.log.info(`[codex.keys.write] ${sessionId.slice(0, 8)} bytes=${out.length}`, {
|
|
1577
|
+
event: "codex.keys_write",
|
|
1578
|
+
sessionId,
|
|
1579
|
+
byteLen: out.length
|
|
1580
|
+
});
|
|
1590
1581
|
session.process.write(out);
|
|
1591
1582
|
session.lastActivityAt = /* @__PURE__ */ new Date();
|
|
1592
1583
|
}
|
|
@@ -1665,13 +1656,12 @@ var CodexPtyRunner = class {
|
|
|
1665
1656
|
writeSubmit(sessionId, session, input, path, promptCount) {
|
|
1666
1657
|
this.recordUserMessage(session, input);
|
|
1667
1658
|
this.log.info(
|
|
1668
|
-
`[codex.input.write] ${sessionId.slice(0, 8)} promptCount=${promptCount} bytes=${input.length}
|
|
1659
|
+
`[codex.input.write] ${sessionId.slice(0, 8)} promptCount=${promptCount} bytes=${input.length}`,
|
|
1669
1660
|
{
|
|
1670
1661
|
event: "codex.input_write",
|
|
1671
1662
|
sessionId,
|
|
1672
1663
|
promptCount,
|
|
1673
1664
|
byteLen: input.length,
|
|
1674
|
-
digest: digestBytes(input),
|
|
1675
1665
|
path,
|
|
1676
1666
|
phase: "input"
|
|
1677
1667
|
}
|
|
@@ -1735,8 +1725,7 @@ var CodexPtyRunner = class {
|
|
|
1735
1725
|
}
|
|
1736
1726
|
this.log.info(`[codex.submit_stale] ${sessionId.slice(0, 8)} recovering`, {
|
|
1737
1727
|
event: "codex.submit_stale",
|
|
1738
|
-
sessionId
|
|
1739
|
-
statusBar: codexStatusBarLine(lines).slice(0, 160)
|
|
1728
|
+
sessionId
|
|
1740
1729
|
});
|
|
1741
1730
|
this.markReady(sessionId, session, "quiet-fallback", "submit-stale");
|
|
1742
1731
|
} catch (err) {
|
|
@@ -2019,7 +2008,7 @@ var CodexPtyRunner = class {
|
|
|
2019
2008
|
if (this.lastScreenLog.get(sessionId) !== screenFp) {
|
|
2020
2009
|
this.lastScreenLog.set(sessionId, screenFp);
|
|
2021
2010
|
this.log.info(
|
|
2022
|
-
`[codex.screen] ${sessionId.slice(0, 8)} pending=${this.pendingReady.has(sessionId)} status=${session.status} ready=${hasReady} busy=${busy} usage=${Boolean(blocking)}
|
|
2011
|
+
`[codex.screen] ${sessionId.slice(0, 8)} pending=${this.pendingReady.has(sessionId)} status=${session.status} ready=${hasReady} busy=${busy} usage=${Boolean(blocking)}`,
|
|
2023
2012
|
{
|
|
2024
2013
|
event: "codex.screen",
|
|
2025
2014
|
sessionId,
|
|
@@ -2029,8 +2018,7 @@ var CodexPtyRunner = class {
|
|
|
2029
2018
|
hasReady,
|
|
2030
2019
|
busy,
|
|
2031
2020
|
usageHit: Boolean(blocking),
|
|
2032
|
-
usageSoft: Boolean(blocking?.soft)
|
|
2033
|
-
statusBar: bar.slice(0, 160)
|
|
2021
|
+
usageSoft: Boolean(blocking?.soft)
|
|
2034
2022
|
}
|
|
2035
2023
|
);
|
|
2036
2024
|
}
|
|
@@ -2065,8 +2053,7 @@ var CodexPtyRunner = class {
|
|
|
2065
2053
|
session.failureReason = blocking.detail ? `${blocking.prompt} ${blocking.detail}` : blocking.prompt;
|
|
2066
2054
|
this.log.info(`[codex.usage_limit] ${sessionId.slice(0, 8)}`, {
|
|
2067
2055
|
event: "codex.usage_limit",
|
|
2068
|
-
sessionId
|
|
2069
|
-
prompt: blocking.prompt
|
|
2056
|
+
sessionId
|
|
2070
2057
|
});
|
|
2071
2058
|
this.onPermissionChange?.(sessionId, blocking);
|
|
2072
2059
|
}
|
|
@@ -2112,8 +2099,7 @@ var CodexPtyRunner = class {
|
|
|
2112
2099
|
this.log.info(`[codex.gate_prompt] ${sessionId.slice(0, 8)} ${gate}`, {
|
|
2113
2100
|
event: "codex.gate_prompt",
|
|
2114
2101
|
sessionId,
|
|
2115
|
-
gate
|
|
2116
|
-
prompt: card.prompt
|
|
2102
|
+
gate
|
|
2117
2103
|
});
|
|
2118
2104
|
this.onPermissionChange?.(sessionId, card);
|
|
2119
2105
|
}
|
|
@@ -3131,10 +3117,11 @@ var PTYManager = class {
|
|
|
3131
3117
|
session.statusUpdatedAt = /* @__PURE__ */ new Date();
|
|
3132
3118
|
this.onStatusChange?.(toPublicSession2(session));
|
|
3133
3119
|
}
|
|
3134
|
-
this.log.info(
|
|
3135
|
-
|
|
3136
|
-
|
|
3137
|
-
|
|
3120
|
+
this.log.info(`[pty.keys.write] ${sessionId.slice(0, 8)} bytes=${keys.length}`, {
|
|
3121
|
+
event: "pty.keys_write",
|
|
3122
|
+
sessionId,
|
|
3123
|
+
byteLen: keys.length
|
|
3124
|
+
});
|
|
3138
3125
|
session.process.write(keys);
|
|
3139
3126
|
session.lastActivityAt = /* @__PURE__ */ new Date();
|
|
3140
3127
|
const openGate = this.permissionOpen.get(sessionId);
|
|
@@ -3196,13 +3183,12 @@ var PTYManager = class {
|
|
|
3196
3183
|
this.recordUserMessage(session, input);
|
|
3197
3184
|
const pasteBytes = buildPasteBytes(input);
|
|
3198
3185
|
this.log.info(
|
|
3199
|
-
`[pty.input.write] ${sessionId.slice(0, 8)} promptCount=${promptCount} bytes=${pasteBytes.length}
|
|
3186
|
+
`[pty.input.write] ${sessionId.slice(0, 8)} promptCount=${promptCount} bytes=${pasteBytes.length}`,
|
|
3200
3187
|
{
|
|
3201
3188
|
event: "pty.input_write",
|
|
3202
3189
|
sessionId,
|
|
3203
3190
|
promptCount,
|
|
3204
3191
|
byteLen: pasteBytes.length,
|
|
3205
|
-
digest: digestBytes(pasteBytes),
|
|
3206
3192
|
path,
|
|
3207
3193
|
phase: "paste"
|
|
3208
3194
|
}
|
|
@@ -3402,7 +3388,7 @@ var PTYManager = class {
|
|
|
3402
3388
|
this.lastChunkAt.set(sessionId, now);
|
|
3403
3389
|
const gapMs = last == null ? 0 : now - last;
|
|
3404
3390
|
this.log.info(
|
|
3405
|
-
`[pty.chunk] ${sessionId.slice(0, 8)} #${idx} +${chunk.length}B gap=${gapMs}ms status=${session.status}
|
|
3391
|
+
`[pty.chunk] ${sessionId.slice(0, 8)} #${idx} +${chunk.length}B gap=${gapMs}ms status=${session.status}`,
|
|
3406
3392
|
{
|
|
3407
3393
|
event: "pty.chunk",
|
|
3408
3394
|
sessionId,
|
|
@@ -3410,8 +3396,7 @@ var PTYManager = class {
|
|
|
3410
3396
|
chunkBytes: chunk.length,
|
|
3411
3397
|
gapMs,
|
|
3412
3398
|
status: session.status,
|
|
3413
|
-
pendingReady: this.pendingReady.has(sessionId)
|
|
3414
|
-
digest: digestBytes(data)
|
|
3399
|
+
pendingReady: this.pendingReady.has(sessionId)
|
|
3415
3400
|
}
|
|
3416
3401
|
);
|
|
3417
3402
|
session.outputBuffer = Buffer.concat([session.outputBuffer, chunk]);
|
|
@@ -3475,15 +3460,18 @@ var PTYManager = class {
|
|
|
3475
3460
|
}
|
|
3476
3461
|
const askFooterOnScreen = lines.some((l) => /Enter to select/i.test(l));
|
|
3477
3462
|
if (oscPermission || hasAskFooter || askFooterOnScreen) {
|
|
3463
|
+
const permGate = oscPermission && !askFooterOnScreen ? scrapePermissionGate(lines) : null;
|
|
3464
|
+
const askQuestion = askFooterOnScreen ? detectQuestionFromScreen(lines) : null;
|
|
3478
3465
|
this.log.debug?.(`[pty.prompt_detect] ${sessionId.slice(0, 8)} trigger`, {
|
|
3479
3466
|
event: "pty.prompt_detect",
|
|
3480
3467
|
sessionId,
|
|
3481
3468
|
oscPermission,
|
|
3482
3469
|
hasAskFooter,
|
|
3483
3470
|
askFooterOnScreen,
|
|
3484
|
-
|
|
3485
|
-
|
|
3486
|
-
|
|
3471
|
+
permGateDetected: permGate !== null,
|
|
3472
|
+
permGateOptionCount: permGate?.options.length ?? 0,
|
|
3473
|
+
askQuestionDetected: askQuestion !== null,
|
|
3474
|
+
askQuestionCount: askQuestion?.questions.length ?? 0
|
|
3487
3475
|
});
|
|
3488
3476
|
}
|
|
3489
3477
|
if (oscPermission && !askFooterOnScreen) {
|
|
@@ -10482,6 +10470,21 @@ var SessionHandlers = class {
|
|
|
10482
10470
|
json(res, 400, { error: "Missing input field" });
|
|
10483
10471
|
return;
|
|
10484
10472
|
}
|
|
10473
|
+
const openPrompt = this.pendingPermission.has(sessionId) ? "permission" : this.pendingQuestions.has(sessionId) ? "question" : null;
|
|
10474
|
+
if (openPrompt) {
|
|
10475
|
+
this.log.info(`[input.prompt_pending] ${sessionId.slice(0, 8)} kind=${openPrompt}`, {
|
|
10476
|
+
event: "input.prompt_pending",
|
|
10477
|
+
sessionId,
|
|
10478
|
+
promptKind: openPrompt
|
|
10479
|
+
});
|
|
10480
|
+
json(res, 409, {
|
|
10481
|
+
ok: false,
|
|
10482
|
+
reason: "prompt_pending",
|
|
10483
|
+
promptKind: openPrompt,
|
|
10484
|
+
error: "A prompt is waiting for an answer; answer or dismiss it before sending text"
|
|
10485
|
+
});
|
|
10486
|
+
return;
|
|
10487
|
+
}
|
|
10485
10488
|
try {
|
|
10486
10489
|
const promptCount = this.ptyManager.sendInput(sessionId, input);
|
|
10487
10490
|
this.sessionStore.updateManaged(sessionId, { promptCount });
|