@threadbase-sh/streamer 1.69.4 → 1.69.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/api/handlers/sessions.handlers.d.ts.map +1 -1
- package/dist/cli.cjs +43 -12
- package/dist/cli.cjs.map +1 -1
- package/dist/index.cjs +43 -12
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +43 -12
- package/dist/index.js.map +1 -1
- package/dist/services/questions/answersToKeystrokes.d.ts +8 -0
- package/dist/services/questions/answersToKeystrokes.d.ts.map +1 -1
- package/dist/services/questions/resolveAnswer.d.ts +1 -1
- package/dist/services/questions/resolveAnswer.d.ts.map +1 -1
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -9623,19 +9623,39 @@ var UnknownOptionError = class extends Error {
|
|
|
9623
9623
|
question;
|
|
9624
9624
|
value;
|
|
9625
9625
|
};
|
|
9626
|
+
var UnsupportedPromptShapeError = class extends Error {
|
|
9627
|
+
constructor(detail) {
|
|
9628
|
+
super(`Unsupported prompt shape: ${detail}`);
|
|
9629
|
+
this.detail = detail;
|
|
9630
|
+
this.name = "UnsupportedPromptShapeError";
|
|
9631
|
+
}
|
|
9632
|
+
detail;
|
|
9633
|
+
};
|
|
9634
|
+
var IncompleteAnswerError = class extends Error {
|
|
9635
|
+
constructor(question) {
|
|
9636
|
+
super(`Missing answer for question "${question}"`);
|
|
9637
|
+
this.question = question;
|
|
9638
|
+
this.name = "IncompleteAnswerError";
|
|
9639
|
+
}
|
|
9640
|
+
question;
|
|
9641
|
+
};
|
|
9626
9642
|
function answersToKeystrokes(questions, answers) {
|
|
9627
|
-
|
|
9628
|
-
|
|
9629
|
-
const raw = answers[q.question];
|
|
9630
|
-
if (raw === void 0) {
|
|
9631
|
-
throw new Error(`Missing answer for question "${q.question}"`);
|
|
9632
|
-
}
|
|
9633
|
-
const label = Array.isArray(raw) ? raw[0] : raw;
|
|
9634
|
-
const target = q.options.findIndex((o) => o.label === label);
|
|
9635
|
-
if (target < 0) throw new UnknownOptionError(q.question, label);
|
|
9636
|
-
out += DOWN.repeat(target) + ENTER3;
|
|
9643
|
+
if (questions.length !== 1) {
|
|
9644
|
+
throw new UnsupportedPromptShapeError(`${questions.length} questions`);
|
|
9637
9645
|
}
|
|
9638
|
-
|
|
9646
|
+
const q = questions[0];
|
|
9647
|
+
if (q.multiSelect) throw new UnsupportedPromptShapeError("multiSelect");
|
|
9648
|
+
const raw = answers[q.question];
|
|
9649
|
+
if (raw === void 0 || Array.isArray(raw) && raw.length === 0) {
|
|
9650
|
+
throw new IncompleteAnswerError(q.question);
|
|
9651
|
+
}
|
|
9652
|
+
if (Array.isArray(raw) && raw.length > 1) {
|
|
9653
|
+
throw new UnsupportedPromptShapeError(`${raw.length} labels for a single-select question`);
|
|
9654
|
+
}
|
|
9655
|
+
const label = Array.isArray(raw) ? raw[0] : raw;
|
|
9656
|
+
const target = q.options.findIndex((o) => o.label === label);
|
|
9657
|
+
if (target < 0) throw new UnknownOptionError(q.question, label);
|
|
9658
|
+
return DOWN.repeat(target) + ENTER3;
|
|
9639
9659
|
}
|
|
9640
9660
|
|
|
9641
9661
|
// src/services/questions/resolveAnswer.ts
|
|
@@ -9649,6 +9669,10 @@ function resolveAnswer(pending, body) {
|
|
|
9649
9669
|
return { ok: true, keys: answersToKeystrokes(pending.questions, answers) };
|
|
9650
9670
|
} catch (e) {
|
|
9651
9671
|
if (e instanceof UnknownOptionError) return { ok: false, reason: "unknown_option" };
|
|
9672
|
+
if (e instanceof UnsupportedPromptShapeError) {
|
|
9673
|
+
return { ok: false, reason: "unsupported_prompt_shape" };
|
|
9674
|
+
}
|
|
9675
|
+
if (e instanceof IncompleteAnswerError) return { ok: false, reason: "incomplete_answer" };
|
|
9652
9676
|
throw e;
|
|
9653
9677
|
}
|
|
9654
9678
|
}
|
|
@@ -10676,7 +10700,14 @@ var SessionHandlers = class {
|
|
|
10676
10700
|
const pending = this.pendingQuestions.get(sessionId);
|
|
10677
10701
|
const resolution = resolveAnswer(pending, body);
|
|
10678
10702
|
if (!resolution.ok) {
|
|
10679
|
-
|
|
10703
|
+
const unanswerable = resolution.reason === "unsupported_prompt_shape" || resolution.reason === "incomplete_answer";
|
|
10704
|
+
json(res, 400, {
|
|
10705
|
+
ok: false,
|
|
10706
|
+
reason: resolution.reason,
|
|
10707
|
+
...unanswerable ? {
|
|
10708
|
+
error: "This prompt needs an answer the app cannot give yet; answer it in the terminal"
|
|
10709
|
+
} : {}
|
|
10710
|
+
});
|
|
10680
10711
|
return;
|
|
10681
10712
|
}
|
|
10682
10713
|
const toolUseId = pending?.toolUseId ?? "";
|