@livx.cc/agentx 0.99.53 → 0.99.54
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/cli.js +52 -6
- package/dist/cli.js.map +1 -1
- package/dist/index.js +12 -2
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/cli.js
CHANGED
|
@@ -3031,15 +3031,25 @@ var askUserQuestionTool = {
|
|
|
3031
3031
|
multiSelect: { type: "boolean" }
|
|
3032
3032
|
}
|
|
3033
3033
|
},
|
|
3034
|
-
async run(
|
|
3034
|
+
async run(input, ctx) {
|
|
3035
|
+
const args = normalizeQuestion(input);
|
|
3036
|
+
if (typeof args === "string") return args;
|
|
3035
3037
|
if (!ctx.host?.ask) {
|
|
3036
3038
|
ctx.needsInput = args;
|
|
3037
3039
|
return "PAUSED \u2014 no interactive user is reachable from this run, so your question has been raised to the caller that delegated this task. The run stops here; do not guess and do not continue. Their answer will arrive as the next user message when the run resumes.";
|
|
3038
3040
|
}
|
|
3039
3041
|
const answer = ctx.host.ask(args);
|
|
3040
|
-
return ctx.parkHuman ? ctx.parkHuman(answer) : answer;
|
|
3042
|
+
return String(await (ctx.parkHuman ? ctx.parkHuman(answer) : answer) ?? "");
|
|
3041
3043
|
}
|
|
3042
3044
|
};
|
|
3045
|
+
function normalizeQuestion(input) {
|
|
3046
|
+
const raw = input?.questions?.[0] ?? input;
|
|
3047
|
+
const q2 = raw ?? {};
|
|
3048
|
+
const options = (Array.isArray(q2.options) ? q2.options : []).map((o) => typeof o === "string" ? { label: o } : { label: String(o?.label ?? ""), description: o?.description }).filter((o) => o.label.trim());
|
|
3049
|
+
if (typeof q2.question !== "string" || !q2.question.trim() || !options.length)
|
|
3050
|
+
return "Error: AskUserQuestion needs {question: string, options: [{label, description?}] (non-empty)}.";
|
|
3051
|
+
return { question: q2.question, header: typeof q2.header === "string" ? q2.header : void 0, options, multiSelect: q2.multiSelect === true };
|
|
3052
|
+
}
|
|
3043
3053
|
|
|
3044
3054
|
// src/relevance.ts
|
|
3045
3055
|
var STOP = /* @__PURE__ */ new Set([
|
|
@@ -8188,8 +8198,8 @@ ${nowLine()}. Anchor every relative or time-sensitive reference \u2014 "today",
|
|
|
8188
8198
|
this.emitHost({ ...ev, message: safe });
|
|
8189
8199
|
return;
|
|
8190
8200
|
}
|
|
8191
|
-
const
|
|
8192
|
-
const partial =
|
|
8201
|
+
const held2 = this.reflexBuf.length - this.reflexForwarded;
|
|
8202
|
+
const partial = held2 > 0 && /\[\s*t?a?s?k?$/i.test(this.reflexBuf.slice(-Math.min(held2, 6)));
|
|
8193
8203
|
let upto = partial ? this.reflexBuf.length - this.reflexBuf.slice(-6).match(/\[\s*t?a?s?k?$/i)[0].length : this.reflexBuf.length;
|
|
8194
8204
|
const paren = this.reflexBuf.lastIndexOf("(");
|
|
8195
8205
|
if (paren >= this.reflexForwarded && !this.reflexBuf.includes(")", paren) && this.reflexBuf.length - paren <= 80)
|
|
@@ -13006,8 +13016,37 @@ function createLineEditor(out, input = keyInput) {
|
|
|
13006
13016
|
}
|
|
13007
13017
|
var menusOpen = 0;
|
|
13008
13018
|
var isMenuActive = () => menusOpen > 0;
|
|
13009
|
-
|
|
13010
|
-
|
|
13019
|
+
var held = null;
|
|
13020
|
+
function holdOutput() {
|
|
13021
|
+
if (held) return;
|
|
13022
|
+
const h = { orig: /* @__PURE__ */ new Map(), queue: [] };
|
|
13023
|
+
for (const s of [process.stdout, process.stderr]) {
|
|
13024
|
+
h.orig.set(s, s.write);
|
|
13025
|
+
s.write = ((...a) => {
|
|
13026
|
+
h.queue.push([s, a]);
|
|
13027
|
+
const cb = a.find((x) => typeof x === "function");
|
|
13028
|
+
cb?.();
|
|
13029
|
+
return true;
|
|
13030
|
+
});
|
|
13031
|
+
}
|
|
13032
|
+
held = h;
|
|
13033
|
+
process.once("exit", releaseOutput);
|
|
13034
|
+
}
|
|
13035
|
+
function releaseOutput() {
|
|
13036
|
+
if (!held) return;
|
|
13037
|
+
const h = held;
|
|
13038
|
+
held = null;
|
|
13039
|
+
process.off("exit", releaseOutput);
|
|
13040
|
+
for (const [s, w] of h.orig) s.write = w;
|
|
13041
|
+
for (const [s, a] of h.queue) s.write(...a.filter((x) => typeof x !== "function"));
|
|
13042
|
+
}
|
|
13043
|
+
function selectMenu(stream, opts) {
|
|
13044
|
+
if (!stream.isTTY || !process.stdin.isTTY || !opts.items.length) return Promise.resolve(null);
|
|
13045
|
+
holdOutput();
|
|
13046
|
+
const raw = held.orig.get(stream);
|
|
13047
|
+
const out = { get columns() {
|
|
13048
|
+
return stream.columns;
|
|
13049
|
+
}, write: (x) => raw ? raw.call(stream, x) : stream.write(x) };
|
|
13011
13050
|
const maxVisible = opts.maxVisible ?? 10;
|
|
13012
13051
|
const dim2 = (x) => `\x1B[2m${x}\x1B[0m`;
|
|
13013
13052
|
const inverse = (x) => `\x1B[7m${x}\x1B[0m`;
|
|
@@ -13075,6 +13114,7 @@ function selectMenu(out, opts) {
|
|
|
13075
13114
|
keyInput.off("keypress", onKey);
|
|
13076
13115
|
if (prevLines > 1) out.write(`\x1B[${prevLines - 1}A`);
|
|
13077
13116
|
out.write("\r\x1B[J");
|
|
13117
|
+
if (!menusOpen) releaseOutput();
|
|
13078
13118
|
if (!wasRaw) {
|
|
13079
13119
|
try {
|
|
13080
13120
|
keyInput.setRawMode(false);
|
|
@@ -13640,6 +13680,7 @@ var spinner = /* @__PURE__ */ (() => {
|
|
|
13640
13680
|
if (!tty || timer) return;
|
|
13641
13681
|
t0 = this.turnStart || Date.now();
|
|
13642
13682
|
timer = setInterval(() => {
|
|
13683
|
+
if (isMenuActive()) return;
|
|
13643
13684
|
const secs2 = Math.round((Date.now() - t0) / 1e3);
|
|
13644
13685
|
const tail = this.tail?.();
|
|
13645
13686
|
err("\r\x1B[2K" + dim(` ${frames[i = (i + 1) % frames.length]} ${label} ${secs2 ? `${secs2}s \xB7 ` : ""}esc to interrupt`) + (tail ? " " + tail : ""));
|
|
@@ -14001,6 +14042,10 @@ function makeHost(format = "text", opts) {
|
|
|
14001
14042
|
process.stdout.write(JSON.stringify({ type: "tool_activity", id: a.id, name: a.name, input: a.input, output: a.output, status: a.status }) + "\n");
|
|
14002
14043
|
return;
|
|
14003
14044
|
}
|
|
14045
|
+
if (a.input?.providerIdentifier === "custom-user-tools") {
|
|
14046
|
+
spinner.start();
|
|
14047
|
+
return;
|
|
14048
|
+
}
|
|
14004
14049
|
const clip = (s) => s.length > 200 ? s.slice(0, 200) + "\u2026" : s;
|
|
14005
14050
|
const terminal = a.status === "completed" || a.status === "error";
|
|
14006
14051
|
if (!terminal || !a.id || !activitySeen.has(a.id)) {
|
|
@@ -14054,6 +14099,7 @@ function makeHost(format = "text", opts) {
|
|
|
14054
14099
|
...canPrompt ? {
|
|
14055
14100
|
async ask(q2) {
|
|
14056
14101
|
const title = `? ${q2.header ? "[" + q2.header + "] " : ""}${q2.question}`;
|
|
14102
|
+
spinner.stop();
|
|
14057
14103
|
const v = await selectMenu(process.stderr, { title, items: q2.options.map((o) => ({ label: o.label, value: o.label, desc: o.description })) });
|
|
14058
14104
|
if (v !== null) return v;
|
|
14059
14105
|
const io = createInterface({ input: keyInput, output: process.stderr });
|