@threadbase-sh/streamer 1.70.0 → 1.70.1
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 +20 -13
- package/dist/cli.cjs.map +1 -1
- package/dist/index.cjs +20 -13
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +20 -13
- package/dist/index.js.map +1 -1
- package/dist/server.d.ts.map +1 -1
- package/dist/services/prompts/promptRegistry.d.ts +1 -1
- package/dist/services/prompts/promptRegistry.d.ts.map +1 -1
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -9787,7 +9787,7 @@ var PromptRegistry = class {
|
|
|
9787
9787
|
this.maxRecordsPerSession = options.maxRecordsPerSession ?? PROMPT_MAX_RECORDS_PER_SESSION;
|
|
9788
9788
|
}
|
|
9789
9789
|
open(draft, adapter, promptId = this.createId()) {
|
|
9790
|
-
this.
|
|
9790
|
+
this.sweepExpired(draft.sessionId);
|
|
9791
9791
|
const held = this.byId.get(promptId);
|
|
9792
9792
|
if (held && (held.prompt.state === "open" || held.prompt.state === "updated")) {
|
|
9793
9793
|
throw new Error(`Prompt id already exists: ${promptId}`);
|
|
@@ -9889,17 +9889,17 @@ var PromptRegistry = class {
|
|
|
9889
9889
|
get(promptId) {
|
|
9890
9890
|
const entry = this.byId.get(promptId);
|
|
9891
9891
|
if (!entry) return null;
|
|
9892
|
-
this.
|
|
9892
|
+
this.sweepExpired(entry.prompt.sessionId);
|
|
9893
9893
|
return this.byId.has(promptId) ? copyPrompt(entry.prompt) : null;
|
|
9894
9894
|
}
|
|
9895
9895
|
hasActionable(sessionId) {
|
|
9896
|
-
this.
|
|
9896
|
+
this.sweepExpired(sessionId);
|
|
9897
9897
|
return [...this.bySession.get(sessionId)?.values() ?? []].some(
|
|
9898
9898
|
(entry) => entry.prompt.state === "open" || entry.prompt.state === "updated"
|
|
9899
9899
|
);
|
|
9900
9900
|
}
|
|
9901
9901
|
snapshot(sessionId) {
|
|
9902
|
-
this.
|
|
9902
|
+
this.sweepExpired(sessionId);
|
|
9903
9903
|
return {
|
|
9904
9904
|
type: "prompt_snapshot",
|
|
9905
9905
|
schemaVersion: PROMPT_SCHEMA_VERSION,
|
|
@@ -9914,7 +9914,7 @@ var PromptRegistry = class {
|
|
|
9914
9914
|
for (const entry of this.byId.values()) this.clearExpiration(entry);
|
|
9915
9915
|
}
|
|
9916
9916
|
answer(sessionId, answer) {
|
|
9917
|
-
this.
|
|
9917
|
+
this.sweepExpired(sessionId);
|
|
9918
9918
|
const entry = this.byId.get(answer.promptId);
|
|
9919
9919
|
if (!entry || entry.prompt.sessionId !== sessionId) {
|
|
9920
9920
|
return Promise.resolve({ ok: false, code: "prompt_not_found" });
|
|
@@ -10044,7 +10044,7 @@ var PromptRegistry = class {
|
|
|
10044
10044
|
if (!entry) throw new Error(`Unknown prompt: ${promptId}`);
|
|
10045
10045
|
return entry;
|
|
10046
10046
|
}
|
|
10047
|
-
|
|
10047
|
+
sweepExpired(sessionId) {
|
|
10048
10048
|
const now = this.now();
|
|
10049
10049
|
const session = this.bySession.get(sessionId);
|
|
10050
10050
|
if (!session) return;
|
|
@@ -11068,19 +11068,26 @@ var SessionHandlers = class {
|
|
|
11068
11068
|
json(res, 400, { error: "Missing input field" });
|
|
11069
11069
|
return;
|
|
11070
11070
|
}
|
|
11071
|
-
this.promptRegistry.
|
|
11071
|
+
this.promptRegistry.sweepExpired(sessionId);
|
|
11072
11072
|
const openPrompt = this.pendingPermission.has(sessionId) ? "permission" : this.pendingQuestions.has(sessionId) ? "question" : null;
|
|
11073
11073
|
if (openPrompt) {
|
|
11074
|
-
this.
|
|
11075
|
-
|
|
11076
|
-
|
|
11077
|
-
|
|
11078
|
-
|
|
11074
|
+
const pendingGate = openPrompt === "permission" ? this.pendingPermission.get(sessionId) : void 0;
|
|
11075
|
+
const promptState = pendingGate?.promptId !== void 0 && this.promptRegistry.get(pendingGate.promptId)?.state === "resolved" ? "answered" : "open";
|
|
11076
|
+
this.log.info(
|
|
11077
|
+
`[input.prompt_pending] ${sessionId.slice(0, 8)} kind=${openPrompt} state=${promptState}`,
|
|
11078
|
+
{
|
|
11079
|
+
event: "input.prompt_pending",
|
|
11080
|
+
sessionId,
|
|
11081
|
+
promptKind: openPrompt,
|
|
11082
|
+
promptState
|
|
11083
|
+
}
|
|
11084
|
+
);
|
|
11079
11085
|
json(res, 409, {
|
|
11080
11086
|
ok: false,
|
|
11081
11087
|
reason: "prompt_pending",
|
|
11082
11088
|
promptKind: openPrompt,
|
|
11083
|
-
|
|
11089
|
+
promptState,
|
|
11090
|
+
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"
|
|
11084
11091
|
});
|
|
11085
11092
|
return;
|
|
11086
11093
|
}
|