@threadbase-sh/streamer 1.70.0 → 1.70.2
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 +3 -17
- package/dist/api/handlers/sessions.handlers.d.ts.map +1 -1
- package/dist/cli.cjs +97 -23
- package/dist/cli.cjs.map +1 -1
- package/dist/index.cjs +97 -23
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +97 -23
- package/dist/index.js.map +1 -1
- package/dist/server.d.ts.map +1 -1
- package/dist/services/prompts/promptRegistry.d.ts +34 -1
- package/dist/services/prompts/promptRegistry.d.ts.map +1 -1
- package/package.json +1 -1
|
@@ -12,6 +12,7 @@ import type { Logger } from "../../logger";
|
|
|
12
12
|
import { type ProviderName } from "../../providers";
|
|
13
13
|
import type { ScannerManager } from "../../scanner-manager";
|
|
14
14
|
import type { ResumeFailure, ResumeOutcome } from "../../server";
|
|
15
|
+
import type { PendingPermission, PendingQuestion } from "../../server-wiring";
|
|
15
16
|
import { PromptRegistry } from "../../services/prompts/promptRegistry";
|
|
16
17
|
import type { IdempotencyStore } from "../../services/sessions/idempotency";
|
|
17
18
|
import type { SessionRegistryBoot } from "../../session-registry-boot";
|
|
@@ -48,24 +49,9 @@ export type SessionHandlersDeps = {
|
|
|
48
49
|
sessionStatusBus: EventEmitter;
|
|
49
50
|
sessionFileMap: Map<string, string>;
|
|
50
51
|
promptRegistry: PromptRegistry;
|
|
51
|
-
pendingQuestions: Map<string,
|
|
52
|
-
toolUseId: string;
|
|
53
|
-
questions: AskQuestion[];
|
|
54
|
-
origin: "pty" | "jsonl";
|
|
55
|
-
promptId: string;
|
|
56
|
-
}>;
|
|
52
|
+
pendingQuestions: Map<string, PendingQuestion>;
|
|
57
53
|
pendingQuestionKey: Map<string, string>;
|
|
58
|
-
pendingPermission: Map<string,
|
|
59
|
-
prompt?: string;
|
|
60
|
-
detail?: string;
|
|
61
|
-
options: PermissionOption[];
|
|
62
|
-
cursor?: number;
|
|
63
|
-
/** Server-owned instance id, minted by handlePermissionChange. */
|
|
64
|
-
gateId: string;
|
|
65
|
-
promptId?: string;
|
|
66
|
-
/** Host-owned occurrence id; see PendingPermission in server-wiring.ts. */
|
|
67
|
-
occurrenceId?: string;
|
|
68
|
-
}>;
|
|
54
|
+
pendingPermission: Map<string, PendingPermission>;
|
|
69
55
|
pendingPermissionKey: Map<string, string>;
|
|
70
56
|
contendedSessions: Set<string>;
|
|
71
57
|
selfPtyEndedAt: Map<string, number>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sessions.handlers.d.ts","sourceRoot":"","sources":["../../../src/api/handlers/sessions.handlers.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,QAAQ,CAAC;AAE3C,OAAO,KAAK,EAAE,eAAe,EAAE,cAAc,EAAE,MAAM,MAAM,CAAC;AAE5D,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,IAAI,CAAC;AACpC,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,0BAA0B,CAAC;AAC5D,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,0BAA0B,CAAC;AAI5D,OAAO,KAAK,EAAE,gBAAgB,EAAE,WAAW,EAAE,cAAc,EAAE,MAAM,oBAAoB,CAAC;AACxF,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,0BAA0B,CAAC;AAClE,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,UAAU,CAAC;AAE3C,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,sBAAsB,CAAC;AAChE,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,4BAA4B,CAAC;AACrE,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,cAAc,CAAC;AAE3C,OAAO,EAIL,KAAK,YAAY,EAClB,MAAM,iBAAiB,CAAC;AAEzB,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAC;AAE5D,O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SAAS,EAAE,MAAM,EAAE,GAAG,EAAE,cAAc,GAAG,OAAO,CAAC,IAAI,CAAC,CAuHvE;IAEK,kBAAkB,CAAC,GAAG,EAAE,eAAe,EAAE,GAAG,EAAE,cAAc,GAAG,OAAO,CAAC,IAAI,CAAC,CAwIjF;IAEK,oBAAoB,CACxB,SAAS,EAAE,MAAM,EACjB,GAAG,EAAE,eAAe,EACpB,GAAG,EAAE,cAAc,GAClB,OAAO,CAAC,IAAI,CAAC,CAmBf;IAED,qBAAqB,CAAC,GAAG,EAAE,cAAc,GAAG,IAAI,CAM/C;CACF"}
|
package/dist/cli.cjs
CHANGED
|
@@ -148014,7 +148014,7 @@ var PromptRegistry = class {
|
|
|
148014
148014
|
this.maxRecordsPerSession = options.maxRecordsPerSession ?? PROMPT_MAX_RECORDS_PER_SESSION;
|
|
148015
148015
|
}
|
|
148016
148016
|
open(draft, adapter, promptId = this.createId()) {
|
|
148017
|
-
this.
|
|
148017
|
+
this.sweepExpired(draft.sessionId);
|
|
148018
148018
|
const held = this.byId.get(promptId);
|
|
148019
148019
|
if (held && (held.prompt.state === "open" || held.prompt.state === "updated")) {
|
|
148020
148020
|
throw new Error(`Prompt id already exists: ${promptId}`);
|
|
@@ -148104,6 +148104,58 @@ var PromptRegistry = class {
|
|
|
148104
148104
|
this.publish(entry);
|
|
148105
148105
|
return copyPrompt(entry.prompt);
|
|
148106
148106
|
}
|
|
148107
|
+
/**
|
|
148108
|
+
* The provider's prompt left the screen.
|
|
148109
|
+
*
|
|
148110
|
+
* Distinct from `transition` because the detector cannot tell a teardown it
|
|
148111
|
+
* observed on its own from one OUR OWN write caused. On a screen-scraped gate
|
|
148112
|
+
* the answer keys remove the box, and pty-manager's sendKeys fires the close
|
|
148113
|
+
* synchronously from inside the write — so the close always arrives before
|
|
148114
|
+
* the answer that caused it has settled, and reporting it as a cancel failed
|
|
148115
|
+
* every answer whose bytes had already landed (#720).
|
|
148116
|
+
*
|
|
148117
|
+
* While an answer is writing, the close is deferred and the answer decides:
|
|
148118
|
+
* `resolved` if the write landed, the deferred close if it did not. Success
|
|
148119
|
+
* is the adapter's own result, never the prompt's absence from the screen —
|
|
148120
|
+
* a prompt that does not vanish when answered (a multi-select form) simply
|
|
148121
|
+
* never reaches here, and is settled by the same adapter result (#721).
|
|
148122
|
+
*
|
|
148123
|
+
* ONLY this path defers. `replaced` from a different gate taking the screen,
|
|
148124
|
+
* `unavailable` from invalidateSession and `expired` all still go through
|
|
148125
|
+
* `transition` and still win, because none of them was caused by our write.
|
|
148126
|
+
*/
|
|
148127
|
+
providerClosed(promptId, reason) {
|
|
148128
|
+
const entry = this.byId.get(promptId);
|
|
148129
|
+
if (!entry) return null;
|
|
148130
|
+
if (entry.prompt.state !== "open" && entry.prompt.state !== "updated") return null;
|
|
148131
|
+
if (entry.answering) {
|
|
148132
|
+
entry.deferredClose = reason;
|
|
148133
|
+
return null;
|
|
148134
|
+
}
|
|
148135
|
+
return this.transition(promptId, "cancelled", reason);
|
|
148136
|
+
}
|
|
148137
|
+
/**
|
|
148138
|
+
* Run a provider write that may close the prompt as a side effect, so the
|
|
148139
|
+
* close it causes is deferred rather than applied. For callers outside this
|
|
148140
|
+
* class that write without going through `answer()` — the legacy permission
|
|
148141
|
+
* route. `performAnswer` manages the same two fields directly, because it
|
|
148142
|
+
* needs the deferred value in its own control flow.
|
|
148143
|
+
*
|
|
148144
|
+
* The write's own failure needs no unwinding here: pty-manager fires the
|
|
148145
|
+
* close as the last statement of a successful sendKeys, so a throw means no
|
|
148146
|
+
* close was ever deferred and the record is still open for the caller.
|
|
148147
|
+
*/
|
|
148148
|
+
whileAnswering(promptId, write) {
|
|
148149
|
+
const entry = this.byId.get(promptId);
|
|
148150
|
+
if (!entry) return write();
|
|
148151
|
+
entry.answering = true;
|
|
148152
|
+
try {
|
|
148153
|
+
return write();
|
|
148154
|
+
} finally {
|
|
148155
|
+
entry.answering = false;
|
|
148156
|
+
entry.deferredClose = void 0;
|
|
148157
|
+
}
|
|
148158
|
+
}
|
|
148107
148159
|
invalidateSession(sessionId, reason = "session_ended") {
|
|
148108
148160
|
const transitioned = [];
|
|
148109
148161
|
for (const entry of this.bySession.get(sessionId)?.values() ?? []) {
|
|
@@ -148116,17 +148168,17 @@ var PromptRegistry = class {
|
|
|
148116
148168
|
get(promptId) {
|
|
148117
148169
|
const entry = this.byId.get(promptId);
|
|
148118
148170
|
if (!entry) return null;
|
|
148119
|
-
this.
|
|
148171
|
+
this.sweepExpired(entry.prompt.sessionId);
|
|
148120
148172
|
return this.byId.has(promptId) ? copyPrompt(entry.prompt) : null;
|
|
148121
148173
|
}
|
|
148122
148174
|
hasActionable(sessionId) {
|
|
148123
|
-
this.
|
|
148175
|
+
this.sweepExpired(sessionId);
|
|
148124
148176
|
return [...this.bySession.get(sessionId)?.values() ?? []].some(
|
|
148125
148177
|
(entry) => entry.prompt.state === "open" || entry.prompt.state === "updated"
|
|
148126
148178
|
);
|
|
148127
148179
|
}
|
|
148128
148180
|
snapshot(sessionId) {
|
|
148129
|
-
this.
|
|
148181
|
+
this.sweepExpired(sessionId);
|
|
148130
148182
|
return {
|
|
148131
148183
|
type: "prompt_snapshot",
|
|
148132
148184
|
schemaVersion: PROMPT_SCHEMA_VERSION,
|
|
@@ -148141,7 +148193,7 @@ var PromptRegistry = class {
|
|
|
148141
148193
|
for (const entry of this.byId.values()) this.clearExpiration(entry);
|
|
148142
148194
|
}
|
|
148143
148195
|
answer(sessionId, answer) {
|
|
148144
|
-
this.
|
|
148196
|
+
this.sweepExpired(sessionId);
|
|
148145
148197
|
const entry = this.byId.get(answer.promptId);
|
|
148146
148198
|
if (!entry || entry.prompt.sessionId !== sessionId) {
|
|
148147
148199
|
return Promise.resolve({ ok: false, code: "prompt_not_found" });
|
|
@@ -148181,21 +148233,33 @@ var PromptRegistry = class {
|
|
|
148181
148233
|
const responseError = this.validateResponses(prompt, answer);
|
|
148182
148234
|
if (responseError) return { ok: false, code: responseError };
|
|
148183
148235
|
if (!entry.adapter) return { ok: false, code: "prompt_unavailable" };
|
|
148236
|
+
entry.answering = true;
|
|
148184
148237
|
let adapterResult;
|
|
148238
|
+
let threw = false;
|
|
148185
148239
|
try {
|
|
148186
148240
|
adapterResult = await entry.adapter({ prompt: copyPrompt(prompt), answer });
|
|
148187
148241
|
} catch {
|
|
148188
|
-
|
|
148242
|
+
threw = true;
|
|
148243
|
+
adapterResult = { ok: false, code: "provider_error" };
|
|
148244
|
+
} finally {
|
|
148245
|
+
entry.answering = false;
|
|
148189
148246
|
}
|
|
148247
|
+
const deferred = entry.deferredClose;
|
|
148248
|
+
entry.deferredClose = void 0;
|
|
148249
|
+
const settle = (outcome) => {
|
|
148250
|
+
if (deferred) this.providerClosed(prompt.promptId, deferred);
|
|
148251
|
+
return outcome;
|
|
148252
|
+
};
|
|
148253
|
+
if (threw) return settle({ ok: false, code: "provider_error" });
|
|
148190
148254
|
if (entry.prompt.state !== "open" && entry.prompt.state !== "updated") {
|
|
148191
|
-
return { ok: false, code: terminalError(entry.prompt.state) };
|
|
148255
|
+
return settle({ ok: false, code: terminalError(entry.prompt.state) });
|
|
148192
148256
|
}
|
|
148193
148257
|
if (entry.prompt.revision !== answer.revision) {
|
|
148194
|
-
return {
|
|
148258
|
+
return settle({
|
|
148195
148259
|
ok: false,
|
|
148196
148260
|
code: "prompt_revision_mismatch",
|
|
148197
148261
|
currentRevision: entry.prompt.revision
|
|
148198
|
-
};
|
|
148262
|
+
});
|
|
148199
148263
|
}
|
|
148200
148264
|
if (!adapterResult.ok) {
|
|
148201
148265
|
if (adapterResult.terminal) {
|
|
@@ -148205,7 +148269,7 @@ var PromptRegistry = class {
|
|
|
148205
148269
|
adapterResult.terminal.reason
|
|
148206
148270
|
);
|
|
148207
148271
|
}
|
|
148208
|
-
return { ok: false, code: adapterResult.code };
|
|
148272
|
+
return settle({ ok: false, code: adapterResult.code });
|
|
148209
148273
|
}
|
|
148210
148274
|
return { ok: true, prompt: this.transition(prompt.promptId, "resolved", "answered") };
|
|
148211
148275
|
}
|
|
@@ -148271,7 +148335,7 @@ var PromptRegistry = class {
|
|
|
148271
148335
|
if (!entry) throw new Error(`Unknown prompt: ${promptId}`);
|
|
148272
148336
|
return entry;
|
|
148273
148337
|
}
|
|
148274
|
-
|
|
148338
|
+
sweepExpired(sessionId) {
|
|
148275
148339
|
const now = this.now();
|
|
148276
148340
|
const session = this.bySession.get(sessionId);
|
|
148277
148341
|
if (!session) return;
|
|
@@ -149303,19 +149367,26 @@ var SessionHandlers = class {
|
|
|
149303
149367
|
json2(res, 400, { error: "Missing input field" });
|
|
149304
149368
|
return;
|
|
149305
149369
|
}
|
|
149306
|
-
this.promptRegistry.
|
|
149370
|
+
this.promptRegistry.sweepExpired(sessionId);
|
|
149307
149371
|
const openPrompt = this.pendingPermission.has(sessionId) ? "permission" : this.pendingQuestions.has(sessionId) ? "question" : null;
|
|
149308
149372
|
if (openPrompt) {
|
|
149309
|
-
this.
|
|
149310
|
-
|
|
149311
|
-
|
|
149312
|
-
|
|
149313
|
-
|
|
149373
|
+
const pendingGate = openPrompt === "permission" ? this.pendingPermission.get(sessionId) : void 0;
|
|
149374
|
+
const promptState = pendingGate?.promptId !== void 0 && this.promptRegistry.get(pendingGate.promptId)?.state === "resolved" ? "answered" : "open";
|
|
149375
|
+
this.log.info(
|
|
149376
|
+
`[input.prompt_pending] ${sessionId.slice(0, 8)} kind=${openPrompt} state=${promptState}`,
|
|
149377
|
+
{
|
|
149378
|
+
event: "input.prompt_pending",
|
|
149379
|
+
sessionId,
|
|
149380
|
+
promptKind: openPrompt,
|
|
149381
|
+
promptState
|
|
149382
|
+
}
|
|
149383
|
+
);
|
|
149314
149384
|
json2(res, 409, {
|
|
149315
149385
|
ok: false,
|
|
149316
149386
|
reason: "prompt_pending",
|
|
149317
149387
|
promptKind: openPrompt,
|
|
149318
|
-
|
|
149388
|
+
promptState,
|
|
149389
|
+
error: promptState === "answered" ? "Your answer was sent; wait for the prompt to close before sending text" : "A prompt is waiting for an answer; answer or dismiss it before sending text"
|
|
149319
149390
|
});
|
|
149320
149391
|
return;
|
|
149321
149392
|
}
|
|
@@ -149417,10 +149488,7 @@ var SessionHandlers = class {
|
|
|
149417
149488
|
if (gate === null) {
|
|
149418
149489
|
const prior2 = this.pendingPermission.get(sessionId);
|
|
149419
149490
|
if (!prior2) return;
|
|
149420
|
-
|
|
149421
|
-
if (prompt2?.state === "open" || prompt2?.state === "updated") {
|
|
149422
|
-
this.promptRegistry.transition(prompt2.promptId, "cancelled", "provider_closed");
|
|
149423
|
-
}
|
|
149491
|
+
if (prior2.promptId) this.promptRegistry.providerClosed(prior2.promptId, "provider_closed");
|
|
149424
149492
|
this.pendingPermission.delete(sessionId);
|
|
149425
149493
|
this.pendingPermissionKey.delete(sessionId);
|
|
149426
149494
|
this.broadcastToSession(sessionId, { type: "permission_cancelled", sessionId });
|
|
@@ -149645,7 +149713,13 @@ var SessionHandlers = class {
|
|
|
149645
149713
|
return;
|
|
149646
149714
|
}
|
|
149647
149715
|
try {
|
|
149648
|
-
this.
|
|
149716
|
+
this.promptRegistry.whileAnswering(
|
|
149717
|
+
gate.promptId ?? "",
|
|
149718
|
+
() => this.ptyManager.sendKeys(
|
|
149719
|
+
sessionId,
|
|
149720
|
+
option.answerKeys ?? permissionAnswerKeys(option.index)
|
|
149721
|
+
)
|
|
149722
|
+
);
|
|
149649
149723
|
} catch (err) {
|
|
149650
149724
|
const message = err instanceof Error ? err.message : "Failed to send answer";
|
|
149651
149725
|
json2(res, 400, { ok: false, reason: message });
|