@shipers-dev/multi 0.44.0 → 0.44.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/index.js +77 -15
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -33352,12 +33352,24 @@ ${c.newText || ""}`.slice(0, 4000);
|
|
|
33352
33352
|
break;
|
|
33353
33353
|
}
|
|
33354
33354
|
case "plan": {
|
|
33355
|
-
const
|
|
33355
|
+
const rawEntries = u.entries || [];
|
|
33356
|
+
if (!rawEntries.length)
|
|
33357
|
+
break;
|
|
33358
|
+
if (o.onPlanUpdate) {
|
|
33359
|
+
const entries2 = rawEntries.map((e) => ({
|
|
33360
|
+
status: String(e?.status ?? "pending"),
|
|
33361
|
+
content: String(e?.content ?? "")
|
|
33362
|
+
}));
|
|
33363
|
+
await o.onPlanUpdate(entries2);
|
|
33364
|
+
} else {
|
|
33365
|
+
const text = rawEntries.map((e, i) => `${i + 1}. [${e.status || "pending"}] ${e.content}`).join(`
|
|
33356
33366
|
`);
|
|
33357
|
-
if (entries2)
|
|
33358
33367
|
await o.onEvent({ event_type: "assistant_text", payload: { text: `**Plan**
|
|
33359
33368
|
|
|
33360
|
-
${
|
|
33369
|
+
${text}
|
|
33370
|
+
|
|
33371
|
+
` } });
|
|
33372
|
+
}
|
|
33361
33373
|
break;
|
|
33362
33374
|
}
|
|
33363
33375
|
case "current_mode_update": {
|
|
@@ -33521,7 +33533,7 @@ async function runAcpx(opts) {
|
|
|
33521
33533
|
dlog(`[acpx stdout] ${line.slice(0, 500)}`);
|
|
33522
33534
|
const events = parseAcpLine(line, (r) => {
|
|
33523
33535
|
stopReason = r;
|
|
33524
|
-
});
|
|
33536
|
+
}, opts);
|
|
33525
33537
|
for (const ev of events)
|
|
33526
33538
|
await opts.onEvent(ev);
|
|
33527
33539
|
}
|
|
@@ -33530,7 +33542,7 @@ async function runAcpx(opts) {
|
|
|
33530
33542
|
if (buf.trim()) {
|
|
33531
33543
|
const events = parseAcpLine(buf.trim(), (r) => {
|
|
33532
33544
|
stopReason = r;
|
|
33533
|
-
});
|
|
33545
|
+
}, opts);
|
|
33534
33546
|
for (const ev of events)
|
|
33535
33547
|
await opts.onEvent(ev);
|
|
33536
33548
|
}
|
|
@@ -33540,7 +33552,7 @@ async function runAcpx(opts) {
|
|
|
33540
33552
|
}
|
|
33541
33553
|
return { stopReason };
|
|
33542
33554
|
}
|
|
33543
|
-
function parseAcpLine(line, setStop) {
|
|
33555
|
+
function parseAcpLine(line, setStop, opts) {
|
|
33544
33556
|
let msg;
|
|
33545
33557
|
try {
|
|
33546
33558
|
msg = JSON.parse(line);
|
|
@@ -33549,7 +33561,7 @@ function parseAcpLine(line, setStop) {
|
|
|
33549
33561
|
}
|
|
33550
33562
|
const out = [];
|
|
33551
33563
|
if (msg.method === "session/update" && msg.params?.update?.sessionUpdate) {
|
|
33552
|
-
return handleSessionUpdate(msg.params);
|
|
33564
|
+
return handleSessionUpdate(msg.params, opts);
|
|
33553
33565
|
}
|
|
33554
33566
|
if (msg.id && msg.result && typeof msg.result === "object" && "stopReason" in msg.result) {
|
|
33555
33567
|
setStop(msg.result.stopReason);
|
|
@@ -33562,7 +33574,7 @@ function parseAcpLine(line, setStop) {
|
|
|
33562
33574
|
}
|
|
33563
33575
|
return out;
|
|
33564
33576
|
}
|
|
33565
|
-
function handleSessionUpdate(params) {
|
|
33577
|
+
function handleSessionUpdate(params, opts) {
|
|
33566
33578
|
const u = params.update || {};
|
|
33567
33579
|
const kind = u.sessionUpdate;
|
|
33568
33580
|
const out = [];
|
|
@@ -33602,12 +33614,24 @@ ${c.newText || ""}`.slice(0, 4000);
|
|
|
33602
33614
|
break;
|
|
33603
33615
|
}
|
|
33604
33616
|
case "plan": {
|
|
33605
|
-
const
|
|
33617
|
+
const rawEntries = u.entries || [];
|
|
33618
|
+
if (!rawEntries.length)
|
|
33619
|
+
break;
|
|
33620
|
+
if (opts.onPlanUpdate) {
|
|
33621
|
+
const entries2 = rawEntries.map((e) => ({
|
|
33622
|
+
status: String(e?.status ?? "pending"),
|
|
33623
|
+
content: String(e?.content ?? "")
|
|
33624
|
+
}));
|
|
33625
|
+
Promise.resolve(opts.onPlanUpdate(entries2));
|
|
33626
|
+
} else {
|
|
33627
|
+
const text = rawEntries.map((e, i) => `${i + 1}. [${e.status || "pending"}] ${e.content}`).join(`
|
|
33606
33628
|
`);
|
|
33607
|
-
if (entries2)
|
|
33608
33629
|
out.push({ event_type: "assistant_text", payload: { text: `**Plan**
|
|
33609
33630
|
|
|
33610
|
-
${
|
|
33631
|
+
${text}
|
|
33632
|
+
|
|
33633
|
+
` } });
|
|
33634
|
+
}
|
|
33611
33635
|
break;
|
|
33612
33636
|
}
|
|
33613
33637
|
}
|
|
@@ -33990,7 +34014,7 @@ var init_plans = __esm(() => {
|
|
|
33990
34014
|
});
|
|
33991
34015
|
|
|
33992
34016
|
// ../lib/chat.ts
|
|
33993
|
-
var ChatScopeSchema, ChatMetaSchema, ChatAuthorKindSchema, ChatAuthorSchema, ChatAttachmentSchema, ChatMessageKindSchema, ChatToolKindSchema, ChatMessageSchema, CHAT_DOC, CreateChatBodySchema, UpdateChatBodySchema;
|
|
34017
|
+
var ChatScopeSchema, ChatMetaSchema, ChatAuthorKindSchema, ChatAuthorSchema, ChatAttachmentSchema, ChatMessageKindSchema, ChatToolKindSchema, ChatPlanEntryStatusSchema, ChatPlanEntrySchema, ChatMessageSchema, CHAT_DOC, CreateChatBodySchema, UpdateChatBodySchema;
|
|
33994
34018
|
var init_chat = __esm(() => {
|
|
33995
34019
|
init_zod();
|
|
33996
34020
|
ChatScopeSchema = exports_external.enum(["project", "workspace"]);
|
|
@@ -34018,8 +34042,13 @@ var init_chat = __esm(() => {
|
|
|
34018
34042
|
size: exports_external.number().optional(),
|
|
34019
34043
|
url: exports_external.string().optional()
|
|
34020
34044
|
});
|
|
34021
|
-
ChatMessageKindSchema = exports_external.enum(["text", "tool_call", "tool_result"]);
|
|
34045
|
+
ChatMessageKindSchema = exports_external.enum(["text", "tool_call", "tool_result", "plan"]);
|
|
34022
34046
|
ChatToolKindSchema = exports_external.enum(["edit", "read", "write", "bash", "search", "other"]);
|
|
34047
|
+
ChatPlanEntryStatusSchema = exports_external.enum(["pending", "in_progress", "completed"]);
|
|
34048
|
+
ChatPlanEntrySchema = exports_external.object({
|
|
34049
|
+
status: ChatPlanEntryStatusSchema.default("pending"),
|
|
34050
|
+
content: exports_external.string()
|
|
34051
|
+
});
|
|
34023
34052
|
ChatMessageSchema = exports_external.object({
|
|
34024
34053
|
id: exports_external.string(),
|
|
34025
34054
|
author: ChatAuthorSchema,
|
|
@@ -34034,7 +34063,9 @@ var init_chat = __esm(() => {
|
|
|
34034
34063
|
status: exports_external.enum(["pending", "in_progress", "completed", "failed"]).optional(),
|
|
34035
34064
|
input: exports_external.unknown().optional(),
|
|
34036
34065
|
tool_call_id: exports_external.string().optional(),
|
|
34037
|
-
content: exports_external.string().optional()
|
|
34066
|
+
content: exports_external.string().optional(),
|
|
34067
|
+
plan_entries: exports_external.array(ChatPlanEntrySchema).optional(),
|
|
34068
|
+
dispatched_at: exports_external.number().optional()
|
|
34038
34069
|
});
|
|
34039
34070
|
CHAT_DOC = {
|
|
34040
34071
|
MESSAGES_LIST: "messages",
|
|
@@ -35845,6 +35876,8 @@ function appendMessage(doc2, msg) {
|
|
|
35845
35876
|
map20.set("tool_call_id", msg.tool_call_id);
|
|
35846
35877
|
if (msg.content !== undefined)
|
|
35847
35878
|
map20.set("content", msg.content);
|
|
35879
|
+
if (msg.plan_entries !== undefined)
|
|
35880
|
+
map20.set("plan_entries", msg.plan_entries);
|
|
35848
35881
|
const mentions = map20.setContainer("mentions", new LoroList);
|
|
35849
35882
|
for (const x of msg.mentions ?? [])
|
|
35850
35883
|
mentions.push(x);
|
|
@@ -35979,6 +36012,28 @@ class ChatPeer {
|
|
|
35979
36012
|
this.flush();
|
|
35980
36013
|
return containerId;
|
|
35981
36014
|
}
|
|
36015
|
+
upsertPlan(authorAgentId, authorName, entries2, containerId) {
|
|
36016
|
+
if (containerId) {
|
|
36017
|
+
patchMessage(this.doc, containerId, { plan_entries: entries2 });
|
|
36018
|
+
this.flush();
|
|
36019
|
+
return containerId;
|
|
36020
|
+
}
|
|
36021
|
+
const msg = {
|
|
36022
|
+
id: crypto.randomUUID(),
|
|
36023
|
+
author: { kind: "agent", id: authorAgentId, name: authorName },
|
|
36024
|
+
kind: "plan",
|
|
36025
|
+
text: "",
|
|
36026
|
+
ts: Math.floor(Date.now() / 1000),
|
|
36027
|
+
mentions: [],
|
|
36028
|
+
attachments: [],
|
|
36029
|
+
partial: false,
|
|
36030
|
+
plan_entries: entries2
|
|
36031
|
+
};
|
|
36032
|
+
const cid = appendMessage(this.doc, msg);
|
|
36033
|
+
this.seenIds.add(msg.id);
|
|
36034
|
+
this.flush();
|
|
36035
|
+
return cid;
|
|
36036
|
+
}
|
|
35982
36037
|
patchMessage(containerId, patch9) {
|
|
35983
36038
|
patchMessage(this.doc, containerId, patch9);
|
|
35984
36039
|
this.flush();
|
|
@@ -36128,6 +36183,7 @@ ${opts.prompt}`;
|
|
|
36128
36183
|
prompt,
|
|
36129
36184
|
cwd: opts.cwd,
|
|
36130
36185
|
sessionName: `chat-${opts.chatId}`,
|
|
36186
|
+
onPlanUpdate: opts.onPlanUpdate,
|
|
36131
36187
|
onEvent: (ev) => {
|
|
36132
36188
|
if (ev.event_type === "assistant_text") {
|
|
36133
36189
|
const text = ev.payload?.text;
|
|
@@ -36180,6 +36236,7 @@ ${opts.prompt}`;
|
|
|
36180
36236
|
onSession: (sid) => {
|
|
36181
36237
|
chatSessions.set(opts.chatId, sid);
|
|
36182
36238
|
},
|
|
36239
|
+
onPlanUpdate: opts.onPlanUpdate,
|
|
36183
36240
|
onEvent: (ev) => {
|
|
36184
36241
|
if (ev.event_type === "assistant_text") {
|
|
36185
36242
|
const text = ev.payload?.text;
|
|
@@ -36647,6 +36704,7 @@ async function processUserMessage(chat2, userMsg, peer, ctx) {
|
|
|
36647
36704
|
let lastFlush = Date.now();
|
|
36648
36705
|
let agentReplyText = "";
|
|
36649
36706
|
const toolMsgByCallId = new Map;
|
|
36707
|
+
let planContainerId = null;
|
|
36650
36708
|
const flushText = (force = false) => {
|
|
36651
36709
|
const now = Date.now();
|
|
36652
36710
|
if (!buffered || textContainerId == null)
|
|
@@ -36782,6 +36840,10 @@ async function processUserMessage(chat2, userMsg, peer, ctx) {
|
|
|
36782
36840
|
if (cid)
|
|
36783
36841
|
peer.patchMessage(cid, { partial: false, status: "completed" });
|
|
36784
36842
|
},
|
|
36843
|
+
onPlanUpdate: (entries2) => {
|
|
36844
|
+
closeText();
|
|
36845
|
+
planContainerId = peer.upsertPlan(agentAuthorId, agentDisplayName, entries2, planContainerId);
|
|
36846
|
+
},
|
|
36785
36847
|
onDone: (stopReason) => {
|
|
36786
36848
|
closeText();
|
|
36787
36849
|
for (const cid of toolMsgByCallId.values()) {
|
|
@@ -37553,7 +37615,7 @@ import { parseArgs } from "util";
|
|
|
37553
37615
|
// package.json
|
|
37554
37616
|
var package_default = {
|
|
37555
37617
|
name: "@shipers-dev/multi",
|
|
37556
|
-
version: "0.44.
|
|
37618
|
+
version: "0.44.1",
|
|
37557
37619
|
type: "module",
|
|
37558
37620
|
bin: {
|
|
37559
37621
|
"multi-agent": "./dist/index.js"
|