@lalalic/neoy-core 0.1.9 → 0.1.10
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/package.json +1 -1
- package/src/core/tools/xchat.mjs +6 -1
package/package.json
CHANGED
package/src/core/tools/xchat.mjs
CHANGED
|
@@ -20,6 +20,7 @@ const XCHAT_COMMAND_TOOLS = [
|
|
|
20
20
|
thread_id: { type: "string", description: "Stable current ChatGPT thread ID." },
|
|
21
21
|
message: { type: "string", description: "Continuation/handoff message for the next turn." },
|
|
22
22
|
mode: { type: "string", enum: ["async", "sync"], description: "async is the default durable queue; sync waits for submission and requires caller-owned session_id." },
|
|
23
|
+
mergeable: { type: "boolean", description: "Default false. Append to the same thread's pending mergeable turn." },
|
|
23
24
|
session_id: { type: "string", description: "Required for sync only. Caller creates and closes this WebHelm Session." },
|
|
24
25
|
reason: { type: "string", description: "Optional diagnostic reason for the control transfer." },
|
|
25
26
|
},
|
|
@@ -91,6 +92,9 @@ function validate(args, name) {
|
|
|
91
92
|
}
|
|
92
93
|
const mode = name === "xchat.turn.new" ? (args.mode === undefined ? "async" : args.mode) : null;
|
|
93
94
|
if (name === "xchat.turn.new" && !["async", "sync"].includes(mode)) throw new Error("mode must be async or sync");
|
|
95
|
+
const mergeable = name === "xchat.turn.new" ? (args.mergeable ?? false) : false;
|
|
96
|
+
if (typeof mergeable !== "boolean") throw new Error("mergeable must be a boolean");
|
|
97
|
+
if (mergeable && mode !== "async") throw new Error("mergeable requires async mode");
|
|
94
98
|
const sessionId = args.session_id;
|
|
95
99
|
if (name === "xchat.turn.new") {
|
|
96
100
|
if (mode === "sync" && (typeof sessionId !== "string" || !sessionId.trim())) {
|
|
@@ -99,7 +103,7 @@ function validate(args, name) {
|
|
|
99
103
|
if (mode === "async" && sessionId !== undefined) throw new Error("mode async does not accept session_id");
|
|
100
104
|
}
|
|
101
105
|
const reason = typeof args.reason === "string" && args.reason.trim() ? args.reason.trim().slice(0, 2000) : null;
|
|
102
|
-
return { projectId, threadId, sourceThreadId, temporary, message, reason, mode, sessionId };
|
|
106
|
+
return { projectId, threadId, sourceThreadId, temporary, message, reason, mode, sessionId, mergeable };
|
|
103
107
|
}
|
|
104
108
|
|
|
105
109
|
function resultText(payload) {
|
|
@@ -148,6 +152,7 @@ export function scheduleXChatLifecycle(name, input, options = {}) {
|
|
|
148
152
|
reason: parsed.reason,
|
|
149
153
|
...(parsed.threadId ? { thread_id: parsed.threadId } : {}),
|
|
150
154
|
...(action === "new-turn" ? { mode: parsed.mode } : {}),
|
|
155
|
+
...(action === "new-turn" ? { mergeable: parsed.mergeable } : {}),
|
|
151
156
|
...(parsed.sourceThreadId ? { source_thread_id: parsed.sourceThreadId } : {}),
|
|
152
157
|
};
|
|
153
158
|
const dir = fs.mkdtempSync(path.join(options.tmpDir || process.env.TMPDIR || "/tmp", "neoy-chatgpt-"));
|