@shipers-dev/multi 0.38.0 → 0.38.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/index.js +100 -85
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -33220,7 +33220,11 @@ async function runAcp(opts) {
|
|
|
33220
33220
|
} catch (e) {
|
|
33221
33221
|
throw new Error(`writeTextFile failed: ${fmtErr(e)}`);
|
|
33222
33222
|
}
|
|
33223
|
-
}
|
|
33223
|
+
},
|
|
33224
|
+
async extMethod(_method, _params) {
|
|
33225
|
+
return {};
|
|
33226
|
+
},
|
|
33227
|
+
async extNotification(_method, _params) {}
|
|
33224
33228
|
};
|
|
33225
33229
|
const conn = new ClientSideConnection(() => client, stream2);
|
|
33226
33230
|
try {
|
|
@@ -33289,8 +33293,7 @@ async function runAcp(opts) {
|
|
|
33289
33293
|
const u = params.update;
|
|
33290
33294
|
const kind = u.sessionUpdate;
|
|
33291
33295
|
switch (kind) {
|
|
33292
|
-
case "agent_message_chunk":
|
|
33293
|
-
case "agent_thought_chunk": {
|
|
33296
|
+
case "agent_message_chunk": {
|
|
33294
33297
|
const text = extractText(u.content);
|
|
33295
33298
|
if (text) {
|
|
33296
33299
|
chunkCount++;
|
|
@@ -33298,6 +33301,9 @@ async function runAcp(opts) {
|
|
|
33298
33301
|
}
|
|
33299
33302
|
break;
|
|
33300
33303
|
}
|
|
33304
|
+
case "agent_thought_chunk": {
|
|
33305
|
+
break;
|
|
33306
|
+
}
|
|
33301
33307
|
case "tool_call":
|
|
33302
33308
|
case "tool_call_update": {
|
|
33303
33309
|
chunkCount++;
|
|
@@ -33540,13 +33546,15 @@ function handleSessionUpdate(params) {
|
|
|
33540
33546
|
const kind = u.sessionUpdate;
|
|
33541
33547
|
const out = [];
|
|
33542
33548
|
switch (kind) {
|
|
33543
|
-
case "agent_message_chunk":
|
|
33544
|
-
case "agent_thought_chunk": {
|
|
33549
|
+
case "agent_message_chunk": {
|
|
33545
33550
|
const text = extractText2(u.content);
|
|
33546
33551
|
if (text)
|
|
33547
33552
|
out.push({ event_type: "assistant_text", payload: { text } });
|
|
33548
33553
|
break;
|
|
33549
33554
|
}
|
|
33555
|
+
case "agent_thought_chunk": {
|
|
33556
|
+
break;
|
|
33557
|
+
}
|
|
33550
33558
|
case "tool_call":
|
|
33551
33559
|
case "tool_call_update": {
|
|
33552
33560
|
out.push({ event_type: "tool_call", payload: {
|
|
@@ -33758,6 +33766,25 @@ var init_agent_workspaces = __esm(() => {
|
|
|
33758
33766
|
});
|
|
33759
33767
|
|
|
33760
33768
|
// ../lib/plans.ts
|
|
33769
|
+
function parseUiBlocks(text) {
|
|
33770
|
+
const blocks = [];
|
|
33771
|
+
const errors3 = [];
|
|
33772
|
+
if (!text)
|
|
33773
|
+
return { blocks, errors: errors3 };
|
|
33774
|
+
let i = 0;
|
|
33775
|
+
let m;
|
|
33776
|
+
UI_FENCE_RE.lastIndex = 0;
|
|
33777
|
+
while ((m = UI_FENCE_RE.exec(text)) !== null) {
|
|
33778
|
+
i++;
|
|
33779
|
+
try {
|
|
33780
|
+
const parsed = UiBlockSchema.parse(JSON.parse(m[1]));
|
|
33781
|
+
blocks.push(parsed);
|
|
33782
|
+
} catch (e) {
|
|
33783
|
+
errors3.push({ index: i, type: "multi-ui", message: e?.message || "invalid ui block" });
|
|
33784
|
+
}
|
|
33785
|
+
}
|
|
33786
|
+
return { blocks, errors: errors3 };
|
|
33787
|
+
}
|
|
33761
33788
|
function parsePlanBlocks(text) {
|
|
33762
33789
|
const actions = [];
|
|
33763
33790
|
const errors3 = [];
|
|
@@ -33807,52 +33834,13 @@ function parsePlanBlocks(text) {
|
|
|
33807
33834
|
}
|
|
33808
33835
|
return { actions, errors: errors3 };
|
|
33809
33836
|
}
|
|
33810
|
-
|
|
33811
|
-
const blocks = [];
|
|
33812
|
-
const spans = [];
|
|
33813
|
-
const errors3 = [];
|
|
33814
|
-
if (!text)
|
|
33815
|
-
return { blocks, spans, errors: errors3 };
|
|
33816
|
-
let i = 0;
|
|
33817
|
-
let m;
|
|
33818
|
-
UI_FENCE_RE.lastIndex = 0;
|
|
33819
|
-
while ((m = UI_FENCE_RE.exec(text)) !== null) {
|
|
33820
|
-
i += 1;
|
|
33821
|
-
const start3 = m.index;
|
|
33822
|
-
const end3 = m.index + m[0].length;
|
|
33823
|
-
let parsed;
|
|
33824
|
-
try {
|
|
33825
|
-
parsed = JSON.parse(m[1]);
|
|
33826
|
-
} catch (e) {
|
|
33827
|
-
errors3.push({ index: i, type: "multi-ui", message: `block ${i}: invalid JSON (${e.message})` });
|
|
33828
|
-
continue;
|
|
33829
|
-
}
|
|
33830
|
-
const r = UiBlockSchema.safeParse(parsed);
|
|
33831
|
-
if (!r.success) {
|
|
33832
|
-
const issues = r.error.issues.map((iss) => `${iss.path.join(".") || "<root>"}: ${iss.message}`);
|
|
33833
|
-
errors3.push({ index: i, type: "multi-ui", message: `block ${i}: ${issues.join("; ")}` });
|
|
33834
|
-
continue;
|
|
33835
|
-
}
|
|
33836
|
-
blocks.push(r.data);
|
|
33837
|
-
spans.push({ block: r.data, start: start3, end: end3 });
|
|
33838
|
-
}
|
|
33839
|
-
return { blocks, spans, errors: errors3 };
|
|
33840
|
-
}
|
|
33841
|
-
var PLAN_SCHEMA_VERSION = 4, EvalPolicy, Priority, AssigneeType, IssueStatus, SessionRole, Capabilities, HandoffExpect, SkillFile, PlanActionSchema, PlanEnvelopeSchema, FENCE_RE, UiBlockSchema, UI_FENCE_RE;
|
|
33837
|
+
var PLAN_SCHEMA_VERSION = 1, Priority, AssigneeType, IssueStatus, SessionRole, SkillFile, PlanActionSchema, PlanEnvelopeSchema, UiBlockSchema, UI_FENCE_RE, FENCE_RE;
|
|
33842
33838
|
var init_plans = __esm(() => {
|
|
33843
33839
|
init_zod();
|
|
33844
|
-
EvalPolicy = exports_external.object({
|
|
33845
|
-
evaluator_agent_id: exports_external.string().min(1),
|
|
33846
|
-
threshold: exports_external.number().min(0).max(1),
|
|
33847
|
-
on_fail: exports_external.enum(["retry", "reroute", "escalate"]).optional(),
|
|
33848
|
-
max_retries: exports_external.number().int().min(0).max(10).optional()
|
|
33849
|
-
});
|
|
33850
33840
|
Priority = exports_external.enum(["low", "medium", "high"]);
|
|
33851
33841
|
AssigneeType = exports_external.enum(["human", "agent"]);
|
|
33852
33842
|
IssueStatus = exports_external.enum(["todo", "in_progress", "done", "failed", "stopped", "cancelled"]);
|
|
33853
33843
|
SessionRole = exports_external.enum(["implementer", "reviewer", "test-fixer"]);
|
|
33854
|
-
Capabilities = exports_external.record(exports_external.string(), exports_external.unknown());
|
|
33855
|
-
HandoffExpect = exports_external.enum(["summary", "json", "none"]);
|
|
33856
33844
|
SkillFile = exports_external.object({ path: exports_external.string().min(1), content: exports_external.string() });
|
|
33857
33845
|
PlanActionSchema = exports_external.discriminatedUnion("type", [
|
|
33858
33846
|
exports_external.object({
|
|
@@ -33864,9 +33852,7 @@ var init_plans = __esm(() => {
|
|
|
33864
33852
|
assignee_type: AssigneeType.optional(),
|
|
33865
33853
|
assignee_id: exports_external.string().optional(),
|
|
33866
33854
|
parent_id: exports_external.string().optional(),
|
|
33867
|
-
blocked_by: exports_external.array(exports_external.string().min(1)).optional()
|
|
33868
|
-
eval_policy: EvalPolicy.optional(),
|
|
33869
|
-
await_children: exports_external.boolean().optional()
|
|
33855
|
+
blocked_by: exports_external.array(exports_external.string().min(1)).optional()
|
|
33870
33856
|
}),
|
|
33871
33857
|
exports_external.object({
|
|
33872
33858
|
type: exports_external.literal("update"),
|
|
@@ -33877,22 +33863,13 @@ var init_plans = __esm(() => {
|
|
|
33877
33863
|
priority: Priority.optional(),
|
|
33878
33864
|
assignee_type: AssigneeType.optional(),
|
|
33879
33865
|
assignee_id: exports_external.string().optional(),
|
|
33880
|
-
blocked_by: exports_external.array(exports_external.string().min(1)).optional()
|
|
33881
|
-
eval_policy: EvalPolicy.nullable().optional()
|
|
33866
|
+
blocked_by: exports_external.array(exports_external.string().min(1)).optional()
|
|
33882
33867
|
}),
|
|
33883
33868
|
exports_external.object({
|
|
33884
33869
|
type: exports_external.literal("delegate"),
|
|
33885
33870
|
id: exports_external.string().min(1),
|
|
33886
33871
|
assignee_id: exports_external.string().min(1)
|
|
33887
33872
|
}),
|
|
33888
|
-
exports_external.object({
|
|
33889
|
-
type: exports_external.literal("handoff"),
|
|
33890
|
-
target_agent_id: exports_external.string().min(1),
|
|
33891
|
-
prompt: exports_external.string().min(1),
|
|
33892
|
-
expect: HandoffExpect.optional(),
|
|
33893
|
-
return_to: exports_external.string().optional(),
|
|
33894
|
-
title: exports_external.string().min(1).max(500).optional()
|
|
33895
|
-
}),
|
|
33896
33873
|
exports_external.object({
|
|
33897
33874
|
type: exports_external.literal("issue.delete"),
|
|
33898
33875
|
id: exports_external.string().min(1)
|
|
@@ -33923,16 +33900,14 @@ var init_plans = __esm(() => {
|
|
|
33923
33900
|
agent_type: exports_external.string().min(1),
|
|
33924
33901
|
prompt: exports_external.string().optional(),
|
|
33925
33902
|
skill_ids: exports_external.array(exports_external.string()).optional(),
|
|
33926
|
-
allowed_tools: exports_external.array(exports_external.string()).optional()
|
|
33927
|
-
capabilities: Capabilities.optional()
|
|
33903
|
+
allowed_tools: exports_external.array(exports_external.string()).optional()
|
|
33928
33904
|
}),
|
|
33929
33905
|
exports_external.object({
|
|
33930
33906
|
type: exports_external.literal("agent.update"),
|
|
33931
33907
|
id: exports_external.string().min(1),
|
|
33932
33908
|
name: exports_external.string().min(1).max(120).optional(),
|
|
33933
33909
|
prompt: exports_external.string().nullable().optional(),
|
|
33934
|
-
allowed_tools: exports_external.array(exports_external.string()).nullable().optional()
|
|
33935
|
-
capabilities: Capabilities.nullable().optional()
|
|
33910
|
+
allowed_tools: exports_external.array(exports_external.string()).nullable().optional()
|
|
33936
33911
|
}),
|
|
33937
33912
|
exports_external.object({
|
|
33938
33913
|
type: exports_external.literal("skill.create"),
|
|
@@ -33958,25 +33933,18 @@ var init_plans = __esm(() => {
|
|
|
33958
33933
|
agent_id: exports_external.string().min(1),
|
|
33959
33934
|
role: SessionRole,
|
|
33960
33935
|
device_id: exports_external.string().optional()
|
|
33961
|
-
}),
|
|
33962
|
-
exports_external.object({
|
|
33963
|
-
type: exports_external.literal("eval.submit"),
|
|
33964
|
-
id: exports_external.string().min(1).optional(),
|
|
33965
|
-
score: exports_external.number().min(0).max(1),
|
|
33966
|
-
feedback: exports_external.string().min(1).max(8000),
|
|
33967
|
-
scores: exports_external.record(exports_external.string(), exports_external.number().min(0).max(1)).optional()
|
|
33968
33936
|
})
|
|
33969
33937
|
]);
|
|
33970
33938
|
PlanEnvelopeSchema = exports_external.object({
|
|
33971
33939
|
actions: exports_external.array(exports_external.unknown())
|
|
33972
33940
|
});
|
|
33973
|
-
FENCE_RE = /```multi-plan\s*\n([\s\S]*?)\n```/g;
|
|
33974
33941
|
UiBlockSchema = exports_external.object({
|
|
33975
33942
|
template: exports_external.string().min(1).max(20000),
|
|
33976
33943
|
data: exports_external.unknown().optional(),
|
|
33977
33944
|
height: exports_external.number().int().min(40).max(1200).optional()
|
|
33978
33945
|
});
|
|
33979
33946
|
UI_FENCE_RE = /```multi-ui\s*\n([\s\S]*?)\n```/g;
|
|
33947
|
+
FENCE_RE = /```multi-plan\s*\n([\s\S]*?)\n```/g;
|
|
33980
33948
|
});
|
|
33981
33949
|
|
|
33982
33950
|
// ../lib/chat.ts
|
|
@@ -33991,6 +33959,7 @@ var init_chat = __esm(() => {
|
|
|
33991
33959
|
title: exports_external.string(),
|
|
33992
33960
|
primary_agent_id: exports_external.string().nullable(),
|
|
33993
33961
|
device_id: exports_external.string().nullable(),
|
|
33962
|
+
runtime: exports_external.string().nullable(),
|
|
33994
33963
|
created_at: exports_external.number(),
|
|
33995
33964
|
updated_at: exports_external.number()
|
|
33996
33965
|
});
|
|
@@ -34032,12 +34001,14 @@ var init_chat = __esm(() => {
|
|
|
34032
34001
|
CreateChatBodySchema = exports_external.object({
|
|
34033
34002
|
title: exports_external.string().min(1).max(200),
|
|
34034
34003
|
primary_agent_id: exports_external.string().nullable().optional(),
|
|
34035
|
-
device_id: exports_external.string().nullable().optional()
|
|
34004
|
+
device_id: exports_external.string().nullable().optional(),
|
|
34005
|
+
runtime: exports_external.string().nullable().optional()
|
|
34036
34006
|
});
|
|
34037
34007
|
UpdateChatBodySchema = exports_external.object({
|
|
34038
34008
|
title: exports_external.string().min(1).max(200).optional(),
|
|
34039
34009
|
primary_agent_id: exports_external.string().nullable().optional(),
|
|
34040
|
-
device_id: exports_external.string().nullable().optional()
|
|
34010
|
+
device_id: exports_external.string().nullable().optional(),
|
|
34011
|
+
runtime: exports_external.string().nullable().optional()
|
|
34041
34012
|
});
|
|
34042
34013
|
});
|
|
34043
34014
|
|
|
@@ -40384,12 +40355,6 @@ async function handleChatTurn(opts) {
|
|
|
40384
40355
|
return;
|
|
40385
40356
|
}
|
|
40386
40357
|
const chosen = opts.preferredRuntime && detected.find((d) => d.type === opts.preferredRuntime) || detected.find((d) => d.type === "claude-code") || detected[0];
|
|
40387
|
-
const adapter = await resolveAcpAdapter(chosen.type, chosen.path);
|
|
40388
|
-
if (!adapter) {
|
|
40389
|
-
opts.onDone(`error: no ACP adapter for ${chosen.type}`);
|
|
40390
|
-
return;
|
|
40391
|
-
}
|
|
40392
|
-
const sessionId = chatSessions.get(opts.chatId) || null;
|
|
40393
40358
|
let prompt = opts.prompt;
|
|
40394
40359
|
if (opts.systemPreamble && !chatPreambleSent.has(opts.chatId)) {
|
|
40395
40360
|
prompt = `${opts.systemPreamble}
|
|
@@ -40399,6 +40364,52 @@ async function handleChatTurn(opts) {
|
|
|
40399
40364
|
${opts.prompt}`;
|
|
40400
40365
|
chatPreambleSent.add(opts.chatId);
|
|
40401
40366
|
}
|
|
40367
|
+
if (ACPX_RUNTIMES.has(chosen.type)) {
|
|
40368
|
+
try {
|
|
40369
|
+
const { stopReason } = await runAcpx({
|
|
40370
|
+
agentType: chosen.type,
|
|
40371
|
+
prompt,
|
|
40372
|
+
cwd: opts.cwd,
|
|
40373
|
+
sessionName: `chat-${opts.chatId}`,
|
|
40374
|
+
onEvent: (ev) => {
|
|
40375
|
+
if (ev.event_type === "assistant_text") {
|
|
40376
|
+
const text = ev.payload?.text;
|
|
40377
|
+
if (typeof text === "string" && text.length)
|
|
40378
|
+
opts.onChunk(text);
|
|
40379
|
+
} else if (ev.event_type === "tool_call") {
|
|
40380
|
+
const p = ev.payload;
|
|
40381
|
+
opts.onToolCall?.({
|
|
40382
|
+
id: String(p?.id ?? ""),
|
|
40383
|
+
tool: String(p?.tool ?? "tool"),
|
|
40384
|
+
kind: p?.kind ? String(p.kind) : undefined,
|
|
40385
|
+
status: p?.status ? String(p.status) : undefined,
|
|
40386
|
+
input: p?.input
|
|
40387
|
+
});
|
|
40388
|
+
} else if (ev.event_type === "tool_result") {
|
|
40389
|
+
const p = ev.payload;
|
|
40390
|
+
opts.onToolResult?.({
|
|
40391
|
+
tool_call_id: String(p?.tool_use_id ?? p?.id ?? ""),
|
|
40392
|
+
content: typeof p?.content === "string" ? p.content : JSON.stringify(p?.content ?? "")
|
|
40393
|
+
});
|
|
40394
|
+
} else if (ev.event_type === "error") {
|
|
40395
|
+
const m = String(ev.payload?.message ?? "agent error");
|
|
40396
|
+
opts.onDone(`error: ${m}`);
|
|
40397
|
+
}
|
|
40398
|
+
}
|
|
40399
|
+
});
|
|
40400
|
+
opts.onDone(stopReason || "ok");
|
|
40401
|
+
} catch (e) {
|
|
40402
|
+
opts.log(`[chat-turn] ${opts.chatId} acpx crash: ${e.message}`);
|
|
40403
|
+
opts.onDone(`error: ${e.message}`);
|
|
40404
|
+
}
|
|
40405
|
+
return;
|
|
40406
|
+
}
|
|
40407
|
+
const adapter = await resolveAcpAdapter(chosen.type, chosen.path);
|
|
40408
|
+
if (!adapter) {
|
|
40409
|
+
opts.onDone(`error: no ACP adapter for ${chosen.type}`);
|
|
40410
|
+
return;
|
|
40411
|
+
}
|
|
40412
|
+
const sessionId = chatSessions.get(opts.chatId) || null;
|
|
40402
40413
|
try {
|
|
40403
40414
|
await runAcp({
|
|
40404
40415
|
apiUrl: "",
|
|
@@ -40445,11 +40456,13 @@ ${opts.prompt}`;
|
|
|
40445
40456
|
opts.onDone(`error: ${e.message}`);
|
|
40446
40457
|
}
|
|
40447
40458
|
}
|
|
40448
|
-
var chatSessions, chatPreambleSent;
|
|
40459
|
+
var ACPX_RUNTIMES, chatSessions, chatPreambleSent;
|
|
40449
40460
|
var init_chat_turn = __esm(() => {
|
|
40450
40461
|
init_acp_runner();
|
|
40462
|
+
init_acpx_runner();
|
|
40451
40463
|
init_run_task();
|
|
40452
40464
|
init_detect();
|
|
40465
|
+
ACPX_RUNTIMES = new Set(["pi", "codex", "openclaw"]);
|
|
40453
40466
|
chatSessions = new Map;
|
|
40454
40467
|
chatPreambleSent = new Set;
|
|
40455
40468
|
});
|
|
@@ -40826,8 +40839,10 @@ class ChatSupervisor {
|
|
|
40826
40839
|
return;
|
|
40827
40840
|
}
|
|
40828
40841
|
}
|
|
40829
|
-
async resolveAgentRuntime(agentId) {
|
|
40830
|
-
if (
|
|
40842
|
+
async resolveAgentRuntime(chat2, agentId) {
|
|
40843
|
+
if (chat2.runtime)
|
|
40844
|
+
return chat2.runtime;
|
|
40845
|
+
if (!agentId || typeof agentId !== "string")
|
|
40831
40846
|
return null;
|
|
40832
40847
|
const headers = { authorization: `Bearer ${this.opts.authToken}` };
|
|
40833
40848
|
try {
|
|
@@ -40866,7 +40881,7 @@ class ChatSupervisor {
|
|
|
40866
40881
|
const mentionAgent = this.resolveAgentFromMention(allAgents, mentioned);
|
|
40867
40882
|
const resolvedAgentId = mentionAgent?.id ?? chat2.primary_agent_id ?? null;
|
|
40868
40883
|
const agentAuthorId = resolvedAgentId || mentioned || "agent";
|
|
40869
|
-
const runtime4 = await this.resolveAgentRuntime(resolvedAgentId);
|
|
40884
|
+
const runtime4 = await this.resolveAgentRuntime(chat2, resolvedAgentId);
|
|
40870
40885
|
const cwd = await this.resolveCwd(chat2);
|
|
40871
40886
|
if (cwd)
|
|
40872
40887
|
this.opts.log(`[chat ${chat2.id}] cwd=${cwd}`);
|
|
@@ -40894,7 +40909,7 @@ class ChatSupervisor {
|
|
|
40894
40909
|
peer.finalizePartialMessage(textContainerId);
|
|
40895
40910
|
textContainerId = null;
|
|
40896
40911
|
};
|
|
40897
|
-
const agentDisplayName = mentionAgent?.name ?? allAgents.find((a) => a.id === resolvedAgentId)?.name ?? undefined;
|
|
40912
|
+
const agentDisplayName = mentionAgent?.name ?? allAgents.find((a) => a.id === resolvedAgentId)?.name ?? runtime4 ?? undefined;
|
|
40898
40913
|
const ensureTextOpen = () => {
|
|
40899
40914
|
if (textContainerId == null) {
|
|
40900
40915
|
textContainerId = peer.beginPartialAgentMessage(agentAuthorId, agentDisplayName).containerId;
|
|
@@ -41064,7 +41079,7 @@ class ChatSupervisor {
|
|
|
41064
41079
|
}
|
|
41065
41080
|
}
|
|
41066
41081
|
async autoTitle(chat2, userMsg, agentReply) {
|
|
41067
|
-
const runtime4 = await this.resolveAgentRuntime(chat2);
|
|
41082
|
+
const runtime4 = await this.resolveAgentRuntime(chat2, chat2.primary_agent_id);
|
|
41068
41083
|
const trimUser = userMsg.slice(0, 800);
|
|
41069
41084
|
const trimAgent = agentReply.slice(0, 1200);
|
|
41070
41085
|
const prompt = `Reply with ONLY a 3-6 word title for this conversation. No quotes, no punctuation, no explanation. Capitalize each word.
|
|
@@ -41730,7 +41745,7 @@ import { parseArgs } from "util";
|
|
|
41730
41745
|
// package.json
|
|
41731
41746
|
var package_default = {
|
|
41732
41747
|
name: "@shipers-dev/multi",
|
|
41733
|
-
version: "0.38.
|
|
41748
|
+
version: "0.38.5",
|
|
41734
41749
|
type: "module",
|
|
41735
41750
|
bin: {
|
|
41736
41751
|
"multi-agent": "./dist/index.js"
|