replicas-cli 0.2.682 → 0.2.683
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.cjs +62 -33
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -7648,6 +7648,15 @@ function isRecord(value) {
|
|
|
7648
7648
|
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
7649
7649
|
}
|
|
7650
7650
|
|
|
7651
|
+
// ../shared/src/json.ts
|
|
7652
|
+
function safeJsonParse(str, fallback) {
|
|
7653
|
+
try {
|
|
7654
|
+
return JSON.parse(str);
|
|
7655
|
+
} catch {
|
|
7656
|
+
return fallback;
|
|
7657
|
+
}
|
|
7658
|
+
}
|
|
7659
|
+
|
|
7651
7660
|
// ../shared/src/api-request.ts
|
|
7652
7661
|
var REDIRECT_STATUSES = /* @__PURE__ */ new Set([301, 302, 303, 307, 308]);
|
|
7653
7662
|
var MAX_REDIRECTS = 5;
|
|
@@ -22972,6 +22981,21 @@ function coerceBackgroundTaskPayload(payload) {
|
|
|
22972
22981
|
toolUses: optionalNumber(payload.usage.tool_uses),
|
|
22973
22982
|
durationMs: optionalNumber(payload.usage.duration_ms)
|
|
22974
22983
|
} : void 0;
|
|
22984
|
+
const workflowAgents = Array.isArray(payload.workflow_progress) ? payload.workflow_progress.flatMap((entry) => {
|
|
22985
|
+
if (!isRecord(entry) || entry.type !== "workflow_agent") return [];
|
|
22986
|
+
const agentId = optionalString(entry.agentId);
|
|
22987
|
+
const label = optionalString(entry.label);
|
|
22988
|
+
if (!agentId || !label) return [];
|
|
22989
|
+
return [{
|
|
22990
|
+
agentId,
|
|
22991
|
+
label,
|
|
22992
|
+
model: optionalString(entry.model),
|
|
22993
|
+
state: optionalString(entry.state),
|
|
22994
|
+
promptPreview: optionalString(entry.promptPreview),
|
|
22995
|
+
lastToolSummary: optionalString(entry.lastToolSummary),
|
|
22996
|
+
resultPreview: optionalString(entry.resultPreview)
|
|
22997
|
+
}];
|
|
22998
|
+
}) : void 0;
|
|
22975
22999
|
return {
|
|
22976
23000
|
subtype,
|
|
22977
23001
|
taskId,
|
|
@@ -22988,6 +23012,7 @@ function coerceBackgroundTaskPayload(payload) {
|
|
|
22988
23012
|
lastToolName: optionalString(payload.last_tool_name),
|
|
22989
23013
|
usage,
|
|
22990
23014
|
ambient: optionalBoolean(payload.ambient),
|
|
23015
|
+
workflowAgents,
|
|
22991
23016
|
patch
|
|
22992
23017
|
};
|
|
22993
23018
|
}
|
|
@@ -23010,15 +23035,6 @@ function normalizeBackgroundTaskStatus(status) {
|
|
|
23010
23035
|
// ../shared/src/display-message/constants.ts
|
|
23011
23036
|
var USER_MESSAGE_MATCH_GRACE_PERIOD_MS = 3e4;
|
|
23012
23037
|
|
|
23013
|
-
// ../shared/src/json.ts
|
|
23014
|
-
function safeJsonParse(str, fallback) {
|
|
23015
|
-
try {
|
|
23016
|
-
return JSON.parse(str);
|
|
23017
|
-
} catch {
|
|
23018
|
-
return fallback;
|
|
23019
|
-
}
|
|
23020
|
-
}
|
|
23021
|
-
|
|
23022
23038
|
// ../shared/src/display-message/parsers/utils.ts
|
|
23023
23039
|
var INTERRUPTED_MESSAGE_REGEX = /^\[Request interrupted by user.*\]$/;
|
|
23024
23040
|
function userMessageImages(value) {
|
|
@@ -23039,6 +23055,7 @@ function upsertDisplayMessage(messages, message) {
|
|
|
23039
23055
|
const index = messages.findIndex((candidate) => candidate.id === message.id);
|
|
23040
23056
|
if (index === -1) messages.push(message);
|
|
23041
23057
|
else messages[index] = message;
|
|
23058
|
+
return message;
|
|
23042
23059
|
}
|
|
23043
23060
|
function applyToolInputEvent(event, messages, provider, state, questionFilter) {
|
|
23044
23061
|
if (event.type === "replicas-tool-input-request" && typeof event.payload.toolUseId === "string" && typeof event.payload.requestId === "string" && (Array.isArray(event.payload.options) || Array.isArray(event.payload.questions))) {
|
|
@@ -26144,6 +26161,13 @@ function areUserMessagesWithinMatchWindow(a, b) {
|
|
|
26144
26161
|
|
|
26145
26162
|
// ../shared/src/display-message/parsers/claude-parser.ts
|
|
26146
26163
|
var ABORTED_TERMINAL_REASONS = /* @__PURE__ */ new Set(["aborted_streaming", "aborted_tools"]);
|
|
26164
|
+
function createSubagentMessage(messageIndex, timestamp, fields) {
|
|
26165
|
+
const { id = `subagent-${timestamp}-${messageIndex}`, ...message } = fields;
|
|
26166
|
+
return { id, type: "subagent", ...message, timestamp };
|
|
26167
|
+
}
|
|
26168
|
+
function collectNestedEvents(events, toolUseId) {
|
|
26169
|
+
return events.filter((e) => e.payload.parent_tool_use_id === toolUseId).map(({ timestamp, type, payload }) => ({ timestamp, type, payload }));
|
|
26170
|
+
}
|
|
26147
26171
|
function coerceClaudeResultPayload(payload) {
|
|
26148
26172
|
return {
|
|
26149
26173
|
is_error: typeof payload.is_error === "boolean" ? payload.is_error : void 0,
|
|
@@ -26170,6 +26194,7 @@ function parseClaudeEvents(events, parentToolUseId) {
|
|
|
26170
26194
|
});
|
|
26171
26195
|
const toolCallMap = /* @__PURE__ */ new Map();
|
|
26172
26196
|
const taskMessageMap = /* @__PURE__ */ new Map();
|
|
26197
|
+
const workflowAgentMessageMap = /* @__PURE__ */ new Map();
|
|
26173
26198
|
const ambientTaskIds = /* @__PURE__ */ new Set();
|
|
26174
26199
|
const partialIndexes = /* @__PURE__ */ new Map();
|
|
26175
26200
|
const completedStreamIds = /* @__PURE__ */ new Set();
|
|
@@ -26365,23 +26390,16 @@ function parseClaudeEvents(events, parentToolUseId) {
|
|
|
26365
26390
|
});
|
|
26366
26391
|
if (toolName === "Task" || toolName === "Agent") {
|
|
26367
26392
|
const inputObj = typeof toolInput === "string" ? safeJsonParse(toolInput, {}) : toolInput;
|
|
26368
|
-
const nestedEvents = events
|
|
26369
|
-
|
|
26370
|
-
type: e.type,
|
|
26371
|
-
payload: e.payload
|
|
26372
|
-
}));
|
|
26373
|
-
messages.push({
|
|
26374
|
-
id: `subagent-${event.timestamp}-${messages.length}`,
|
|
26375
|
-
type: "subagent",
|
|
26393
|
+
const nestedEvents = collectNestedEvents(events, toolUseId);
|
|
26394
|
+
messages.push(createSubagentMessage(messages.length, event.timestamp, {
|
|
26376
26395
|
toolUseId,
|
|
26377
26396
|
description: inputObj.description || "Subagent Task",
|
|
26378
26397
|
prompt: inputObj.prompt || "",
|
|
26379
26398
|
subagentType: inputObj.subagent_type || "general",
|
|
26380
26399
|
model: inputObj.model,
|
|
26381
26400
|
status: "in_progress",
|
|
26382
|
-
nestedEvents
|
|
26383
|
-
|
|
26384
|
-
});
|
|
26401
|
+
nestedEvents
|
|
26402
|
+
}));
|
|
26385
26403
|
} else if (toolName === "Bash" || toolName === "bash" || toolName === "shell") {
|
|
26386
26404
|
const inputObj = typeof toolInput === "string" ? safeJsonParse(toolInput, {}) : toolInput;
|
|
26387
26405
|
const command = inputObj.command || "";
|
|
@@ -26470,9 +26488,7 @@ function parseClaudeEvents(events, parentToolUseId) {
|
|
|
26470
26488
|
const prompt = typeof inputObj.prompt === "string" ? inputObj.prompt : "";
|
|
26471
26489
|
const model = typeof inputObj.model === "string" ? inputObj.model : void 0;
|
|
26472
26490
|
const title = typeof inputObj.title === "string" ? inputObj.title : void 0;
|
|
26473
|
-
messages.push({
|
|
26474
|
-
id: `subagent-${event.timestamp}-${messages.length}`,
|
|
26475
|
-
type: "subagent",
|
|
26491
|
+
messages.push(createSubagentMessage(messages.length, event.timestamp, {
|
|
26476
26492
|
toolUseId,
|
|
26477
26493
|
description: title || `Relay subagent (${provider})`,
|
|
26478
26494
|
prompt,
|
|
@@ -26481,9 +26497,8 @@ function parseClaudeEvents(events, parentToolUseId) {
|
|
|
26481
26497
|
thinkingLevel: isValidThinkingLevel(inputObj.thinking_level) ? inputObj.thinking_level : void 0,
|
|
26482
26498
|
status: "in_progress",
|
|
26483
26499
|
nestedEvents: [],
|
|
26484
|
-
isChatBased: true
|
|
26485
|
-
|
|
26486
|
-
});
|
|
26500
|
+
isChatBased: true
|
|
26501
|
+
}));
|
|
26487
26502
|
} else if (toolName === "mcp__relay-subagent-tools__message_agent") {
|
|
26488
26503
|
const inputObj = typeof toolInput === "string" ? safeJsonParse(toolInput, {}) : toolInput;
|
|
26489
26504
|
messages.push({
|
|
@@ -26539,6 +26554,25 @@ function parseClaudeEvents(events, parentToolUseId) {
|
|
|
26539
26554
|
const payload = coerceBackgroundTaskPayload(event.payload);
|
|
26540
26555
|
if (payload?.ambient) ambientTaskIds.add(payload.taskId);
|
|
26541
26556
|
if (payload && !ambientTaskIds.has(payload.taskId)) {
|
|
26557
|
+
for (const workflowAgent of payload.workflowAgents ?? []) {
|
|
26558
|
+
const existingWorkflowAgent = workflowAgentMessageMap.get(workflowAgent.agentId);
|
|
26559
|
+
const nextWorkflowAgent = createSubagentMessage(
|
|
26560
|
+
messages.length,
|
|
26561
|
+
existingWorkflowAgent?.timestamp ?? event.timestamp,
|
|
26562
|
+
{
|
|
26563
|
+
id: existingWorkflowAgent?.id,
|
|
26564
|
+
toolUseId: workflowAgent.agentId,
|
|
26565
|
+
description: workflowAgent.label,
|
|
26566
|
+
prompt: workflowAgent.promptPreview ?? existingWorkflowAgent?.prompt ?? "",
|
|
26567
|
+
subagentType: "general",
|
|
26568
|
+
model: workflowAgent.model ?? existingWorkflowAgent?.model,
|
|
26569
|
+
status: workflowAgent.state === "done" ? "completed" : workflowAgent.state === "error" ? "failed" : "in_progress",
|
|
26570
|
+
output: workflowAgent.resultPreview ?? workflowAgent.lastToolSummary ?? existingWorkflowAgent?.output,
|
|
26571
|
+
nestedEvents: existingWorkflowAgent?.nestedEvents ?? collectNestedEvents(events, workflowAgent.agentId)
|
|
26572
|
+
}
|
|
26573
|
+
);
|
|
26574
|
+
workflowAgentMessageMap.set(workflowAgent.agentId, upsertDisplayMessage(messages, nextWorkflowAgent));
|
|
26575
|
+
}
|
|
26542
26576
|
const existing = taskMessageMap.get(payload.taskId);
|
|
26543
26577
|
const nextStatus = payload.subtype === "task_notification" ? normalizeBackgroundTaskStatus(payload.status) : payload.subtype === "task_updated" && payload.patch?.status !== void 0 ? normalizeBackgroundTaskStatus(payload.patch?.status) : existing?.status ?? "in_progress";
|
|
26544
26578
|
const nextMessage = {
|
|
@@ -26560,12 +26594,7 @@ function parseClaudeEvents(events, parentToolUseId) {
|
|
|
26560
26594
|
isBackgrounded: payload.isBackgrounded ?? payload.patch?.isBackgrounded ?? existing?.isBackgrounded,
|
|
26561
26595
|
timestamp: existing?.timestamp ?? event.timestamp
|
|
26562
26596
|
};
|
|
26563
|
-
|
|
26564
|
-
Object.assign(existing, nextMessage);
|
|
26565
|
-
} else {
|
|
26566
|
-
taskMessageMap.set(payload.taskId, nextMessage);
|
|
26567
|
-
messages.push(nextMessage);
|
|
26568
|
-
}
|
|
26597
|
+
taskMessageMap.set(payload.taskId, upsertDisplayMessage(messages, nextMessage));
|
|
26569
26598
|
}
|
|
26570
26599
|
}
|
|
26571
26600
|
});
|
|
@@ -27329,7 +27358,7 @@ var headlessFilesystemAgentResultSchema = external_exports.object({
|
|
|
27329
27358
|
});
|
|
27330
27359
|
|
|
27331
27360
|
// ../shared/src/cli-version.ts
|
|
27332
|
-
var CLI_VERSION = "0.2.
|
|
27361
|
+
var CLI_VERSION = "0.2.683";
|
|
27333
27362
|
|
|
27334
27363
|
// ../shared/src/version.ts
|
|
27335
27364
|
function compareVersions(v1, v2) {
|