replicas-cli 0.2.204 → 0.2.206
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.mjs +90 -21
- package/package.json +1 -1
package/dist/index.mjs
CHANGED
|
@@ -7491,6 +7491,11 @@ async function getCurrentUser() {
|
|
|
7491
7491
|
};
|
|
7492
7492
|
}
|
|
7493
7493
|
|
|
7494
|
+
// ../shared/src/type-guards.ts
|
|
7495
|
+
function isRecord(value) {
|
|
7496
|
+
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
7497
|
+
}
|
|
7498
|
+
|
|
7494
7499
|
// ../shared/src/agent.ts
|
|
7495
7500
|
var VALID_AGENT_PROVIDERS = ["claude", "codex", "relay"];
|
|
7496
7501
|
function isValidAgentProvider(value) {
|
|
@@ -9093,7 +9098,51 @@ var GITHUB_TRIGGER = {
|
|
|
9093
9098
|
]
|
|
9094
9099
|
};
|
|
9095
9100
|
|
|
9096
|
-
// ../shared/src/display-message/
|
|
9101
|
+
// ../shared/src/display-message/types.ts
|
|
9102
|
+
var BACKGROUND_TASK_SUBTYPES = /* @__PURE__ */ new Set([
|
|
9103
|
+
"task_started",
|
|
9104
|
+
"task_progress",
|
|
9105
|
+
"task_updated",
|
|
9106
|
+
"task_notification"
|
|
9107
|
+
]);
|
|
9108
|
+
function isBackgroundTaskSubtype(subtype) {
|
|
9109
|
+
return typeof subtype === "string" && BACKGROUND_TASK_SUBTYPES.has(subtype);
|
|
9110
|
+
}
|
|
9111
|
+
function optionalString(value) {
|
|
9112
|
+
return typeof value === "string" ? value : void 0;
|
|
9113
|
+
}
|
|
9114
|
+
function coerceBackgroundTaskPayload(payload) {
|
|
9115
|
+
if (!isRecord(payload)) return null;
|
|
9116
|
+
const subtype = payload.subtype;
|
|
9117
|
+
if (!isBackgroundTaskSubtype(subtype)) return null;
|
|
9118
|
+
const taskId = payload.task_id;
|
|
9119
|
+
if (typeof taskId !== "string" || !taskId) return null;
|
|
9120
|
+
const patch = isRecord(payload.patch) ? {
|
|
9121
|
+
status: optionalString(payload.patch.status),
|
|
9122
|
+
description: optionalString(payload.patch.description),
|
|
9123
|
+
error: optionalString(payload.patch.error)
|
|
9124
|
+
} : void 0;
|
|
9125
|
+
return {
|
|
9126
|
+
subtype,
|
|
9127
|
+
taskId,
|
|
9128
|
+
description: optionalString(payload.description),
|
|
9129
|
+
summary: optionalString(payload.summary),
|
|
9130
|
+
outputFile: optionalString(payload.output_file),
|
|
9131
|
+
status: optionalString(payload.status),
|
|
9132
|
+
patch
|
|
9133
|
+
};
|
|
9134
|
+
}
|
|
9135
|
+
function normalizeBackgroundTaskStatus(status) {
|
|
9136
|
+
if (status === "completed" || status === "failed" || status === "stopped") {
|
|
9137
|
+
return status;
|
|
9138
|
+
}
|
|
9139
|
+
if (status === "killed") {
|
|
9140
|
+
return "stopped";
|
|
9141
|
+
}
|
|
9142
|
+
return "in_progress";
|
|
9143
|
+
}
|
|
9144
|
+
|
|
9145
|
+
// ../shared/src/json.ts
|
|
9097
9146
|
function safeJsonParse(str, fallback) {
|
|
9098
9147
|
try {
|
|
9099
9148
|
return JSON.parse(str);
|
|
@@ -9101,6 +9150,8 @@ function safeJsonParse(str, fallback) {
|
|
|
9101
9150
|
return fallback;
|
|
9102
9151
|
}
|
|
9103
9152
|
}
|
|
9153
|
+
|
|
9154
|
+
// ../shared/src/display-message/parsers/codex-parser.ts
|
|
9104
9155
|
function getStatusFromExitCode(exitCode) {
|
|
9105
9156
|
return exitCode === 0 ? "completed" : "failed";
|
|
9106
9157
|
}
|
|
@@ -9347,13 +9398,6 @@ function parseMcpToolName(name) {
|
|
|
9347
9398
|
}
|
|
9348
9399
|
|
|
9349
9400
|
// ../shared/src/display-message/parsers/claude-parser.ts
|
|
9350
|
-
function safeJsonParse2(str, fallback) {
|
|
9351
|
-
try {
|
|
9352
|
-
return JSON.parse(str);
|
|
9353
|
-
} catch {
|
|
9354
|
-
return fallback;
|
|
9355
|
-
}
|
|
9356
|
-
}
|
|
9357
9401
|
function extractToolResultContent(content) {
|
|
9358
9402
|
if (!content) return "";
|
|
9359
9403
|
if (typeof content === "string") return content;
|
|
@@ -9365,10 +9409,12 @@ function extractToolResultContent(content) {
|
|
|
9365
9409
|
function parseClaudeEvents(events, parentToolUseId) {
|
|
9366
9410
|
const messages = [];
|
|
9367
9411
|
const filterValue = parentToolUseId !== void 0 ? parentToolUseId : null;
|
|
9368
|
-
const filteredEvents = events.filter(
|
|
9369
|
-
|
|
9370
|
-
|
|
9412
|
+
const filteredEvents = events.filter((e) => {
|
|
9413
|
+
const eventParentToolUseId = e.payload.parent_tool_use_id ?? null;
|
|
9414
|
+
return eventParentToolUseId === filterValue;
|
|
9415
|
+
});
|
|
9371
9416
|
const toolCallMap = /* @__PURE__ */ new Map();
|
|
9417
|
+
const taskMessageMap = /* @__PURE__ */ new Map();
|
|
9372
9418
|
filteredEvents.forEach((event) => {
|
|
9373
9419
|
if (event.type === "claude-user") {
|
|
9374
9420
|
const content = event.payload.message?.content || [];
|
|
@@ -9428,7 +9474,7 @@ function parseClaudeEvents(events, parentToolUseId) {
|
|
|
9428
9474
|
input: toolInput
|
|
9429
9475
|
});
|
|
9430
9476
|
if (toolName === "Task" || toolName === "Agent") {
|
|
9431
|
-
const inputObj = typeof toolInput === "string" ?
|
|
9477
|
+
const inputObj = typeof toolInput === "string" ? safeJsonParse(toolInput, {}) : toolInput;
|
|
9432
9478
|
const nestedEvents = events.filter((e) => e.payload.parent_tool_use_id === toolUseId).map((e) => ({
|
|
9433
9479
|
timestamp: e.timestamp,
|
|
9434
9480
|
type: e.type,
|
|
@@ -9447,7 +9493,7 @@ function parseClaudeEvents(events, parentToolUseId) {
|
|
|
9447
9493
|
timestamp: event.timestamp
|
|
9448
9494
|
});
|
|
9449
9495
|
} else if (toolName === "Bash" || toolName === "bash" || toolName === "shell") {
|
|
9450
|
-
const inputObj = typeof toolInput === "string" ?
|
|
9496
|
+
const inputObj = typeof toolInput === "string" ? safeJsonParse(toolInput, {}) : toolInput;
|
|
9451
9497
|
const command = inputObj.command || "";
|
|
9452
9498
|
messages.push({
|
|
9453
9499
|
id: `command-${event.timestamp}-${messages.length}`,
|
|
@@ -9458,7 +9504,7 @@ function parseClaudeEvents(events, parentToolUseId) {
|
|
|
9458
9504
|
timestamp: event.timestamp
|
|
9459
9505
|
});
|
|
9460
9506
|
} else if (toolName === "Write" || toolName === "Edit") {
|
|
9461
|
-
const inputObj = typeof toolInput === "string" ?
|
|
9507
|
+
const inputObj = typeof toolInput === "string" ? safeJsonParse(toolInput, {}) : toolInput;
|
|
9462
9508
|
const filePath = inputObj.file_path || "";
|
|
9463
9509
|
const action = toolName === "Write" ? "add" : "update";
|
|
9464
9510
|
let diff;
|
|
@@ -9495,7 +9541,7 @@ function parseClaudeEvents(events, parentToolUseId) {
|
|
|
9495
9541
|
timestamp: event.timestamp
|
|
9496
9542
|
});
|
|
9497
9543
|
} else if (toolName === "TodoWrite") {
|
|
9498
|
-
const inputObj = typeof toolInput === "string" ?
|
|
9544
|
+
const inputObj = typeof toolInput === "string" ? safeJsonParse(toolInput, {}) : toolInput;
|
|
9499
9545
|
const todos = Array.isArray(inputObj.todos) ? inputObj.todos : [];
|
|
9500
9546
|
const todoItems = todos.map((todo) => ({
|
|
9501
9547
|
text: todo.content,
|
|
@@ -9511,7 +9557,7 @@ function parseClaudeEvents(events, parentToolUseId) {
|
|
|
9511
9557
|
});
|
|
9512
9558
|
}
|
|
9513
9559
|
} else if (toolName === "WebSearch") {
|
|
9514
|
-
const inputObj = typeof toolInput === "string" ?
|
|
9560
|
+
const inputObj = typeof toolInput === "string" ? safeJsonParse(toolInput, {}) : toolInput;
|
|
9515
9561
|
const query = inputObj.query || "";
|
|
9516
9562
|
messages.push({
|
|
9517
9563
|
id: `search-${event.timestamp}-${messages.length}`,
|
|
@@ -9521,7 +9567,7 @@ function parseClaudeEvents(events, parentToolUseId) {
|
|
|
9521
9567
|
timestamp: event.timestamp
|
|
9522
9568
|
});
|
|
9523
9569
|
} else if (toolName === "Skill") {
|
|
9524
|
-
const inputObj = typeof toolInput === "string" ?
|
|
9570
|
+
const inputObj = typeof toolInput === "string" ? safeJsonParse(toolInput, {}) : toolInput;
|
|
9525
9571
|
messages.push({
|
|
9526
9572
|
id: `skill-${event.timestamp}-${messages.length}`,
|
|
9527
9573
|
type: "skill",
|
|
@@ -9531,7 +9577,7 @@ function parseClaudeEvents(events, parentToolUseId) {
|
|
|
9531
9577
|
timestamp: event.timestamp
|
|
9532
9578
|
});
|
|
9533
9579
|
} else if (toolName === "mcp__relay-subagent-tools__spawn_agent") {
|
|
9534
|
-
const inputObj = typeof toolInput === "string" ?
|
|
9580
|
+
const inputObj = typeof toolInput === "string" ? safeJsonParse(toolInput, {}) : toolInput;
|
|
9535
9581
|
messages.push({
|
|
9536
9582
|
id: `subagent-${event.timestamp}-${messages.length}`,
|
|
9537
9583
|
type: "subagent",
|
|
@@ -9546,7 +9592,7 @@ function parseClaudeEvents(events, parentToolUseId) {
|
|
|
9546
9592
|
timestamp: event.timestamp
|
|
9547
9593
|
});
|
|
9548
9594
|
} else if (toolName === "mcp__relay-subagent-tools__delete_agent") {
|
|
9549
|
-
const inputObj = typeof toolInput === "string" ?
|
|
9595
|
+
const inputObj = typeof toolInput === "string" ? safeJsonParse(toolInput, {}) : toolInput;
|
|
9550
9596
|
const mcp = parseMcpToolName(toolName);
|
|
9551
9597
|
messages.push({
|
|
9552
9598
|
id: `toolcall-${event.timestamp}-${messages.length}`,
|
|
@@ -9584,6 +9630,29 @@ function parseClaudeEvents(events, parentToolUseId) {
|
|
|
9584
9630
|
});
|
|
9585
9631
|
}
|
|
9586
9632
|
}
|
|
9633
|
+
if (event.type === "claude-system") {
|
|
9634
|
+
const payload = coerceBackgroundTaskPayload(event.payload);
|
|
9635
|
+
if (payload) {
|
|
9636
|
+
const existing = taskMessageMap.get(payload.taskId);
|
|
9637
|
+
const nextStatus = payload.subtype === "task_notification" ? normalizeBackgroundTaskStatus(payload.status) : payload.subtype === "task_updated" ? normalizeBackgroundTaskStatus(payload.patch?.status) : existing?.status ?? "in_progress";
|
|
9638
|
+
const nextMessage = {
|
|
9639
|
+
id: existing?.id ?? `task-${event.timestamp}-${messages.length}`,
|
|
9640
|
+
type: "background_task",
|
|
9641
|
+
taskId: payload.taskId,
|
|
9642
|
+
status: nextStatus,
|
|
9643
|
+
description: payload.description ?? payload.patch?.description ?? existing?.description,
|
|
9644
|
+
summary: payload.summary ?? payload.patch?.error ?? existing?.summary,
|
|
9645
|
+
outputFile: payload.outputFile ?? existing?.outputFile,
|
|
9646
|
+
timestamp: existing?.timestamp ?? event.timestamp
|
|
9647
|
+
};
|
|
9648
|
+
if (existing) {
|
|
9649
|
+
Object.assign(existing, nextMessage);
|
|
9650
|
+
} else {
|
|
9651
|
+
taskMessageMap.set(payload.taskId, nextMessage);
|
|
9652
|
+
messages.push(nextMessage);
|
|
9653
|
+
}
|
|
9654
|
+
}
|
|
9655
|
+
}
|
|
9587
9656
|
});
|
|
9588
9657
|
filteredEvents.forEach((event) => {
|
|
9589
9658
|
if (event.type === "replicas-tool-input-request") {
|
|
@@ -9650,7 +9719,7 @@ function parseClaudeEvents(events, parentToolUseId) {
|
|
|
9650
9719
|
message.output = resultContent;
|
|
9651
9720
|
message.status = status;
|
|
9652
9721
|
if (!message.chatId && resultContent) {
|
|
9653
|
-
const parsed =
|
|
9722
|
+
const parsed = safeJsonParse(resultContent, {});
|
|
9654
9723
|
if (parsed.chatId) {
|
|
9655
9724
|
message.chatId = parsed.chatId;
|
|
9656
9725
|
}
|
|
@@ -16731,7 +16800,7 @@ Repository start hooks (${response.repositories.length}):
|
|
|
16731
16800
|
}
|
|
16732
16801
|
|
|
16733
16802
|
// src/index.ts
|
|
16734
|
-
var CLI_VERSION = "0.2.
|
|
16803
|
+
var CLI_VERSION = "0.2.206";
|
|
16735
16804
|
function parseBooleanOption(value) {
|
|
16736
16805
|
if (value === "true") return true;
|
|
16737
16806
|
if (value === "false") return false;
|