replicas-engine 0.1.665 → 0.1.666
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/src/{chunk-SBJ4HUPK.js → chunk-3EPGH6IZ.js} +134 -25
- package/dist/src/headless-agent.js +1 -1
- package/dist/src/index.js +531 -178
- package/package.json +1 -1
|
@@ -7,6 +7,7 @@ var AGENT = {
|
|
|
7
7
|
CURSOR: "cursor",
|
|
8
8
|
DEEPSEEK: "deepseek",
|
|
9
9
|
FX: "fx",
|
|
10
|
+
KIMI: "kimi",
|
|
10
11
|
OPENCODE: "opencode",
|
|
11
12
|
PI: "pi",
|
|
12
13
|
RELAY: "relay"
|
|
@@ -30,6 +31,7 @@ var THINKING_LEVELS_BY_AGENT = {
|
|
|
30
31
|
cursor: STANDARD_THINKING_LEVELS,
|
|
31
32
|
deepseek: STANDARD_THINKING_LEVELS,
|
|
32
33
|
fx: STANDARD_THINKING_LEVELS,
|
|
34
|
+
kimi: STANDARD_THINKING_LEVELS,
|
|
33
35
|
opencode: STANDARD_THINKING_LEVELS,
|
|
34
36
|
pi: STANDARD_THINKING_LEVELS,
|
|
35
37
|
relay: [...STANDARD_THINKING_LEVELS, "ultracode"]
|
|
@@ -302,6 +304,7 @@ var DEFAULT_CHAT_TITLES = {
|
|
|
302
304
|
cursor: "Cursor",
|
|
303
305
|
deepseek: "DeepSeek Harness",
|
|
304
306
|
fx: "fx",
|
|
307
|
+
kimi: "Kimi Code",
|
|
305
308
|
opencode: "Opencode",
|
|
306
309
|
pi: "Pi",
|
|
307
310
|
relay: "Relay"
|
|
@@ -332,6 +335,7 @@ var DEEPSEEK_V4_PRO_MODEL = "deepseek/deepseek-v4-pro-0813";
|
|
|
332
335
|
var DEEPSEEK_V4_FLASH_MODEL = "deepseek/deepseek-v4-flash-0731";
|
|
333
336
|
var DEFAULT_DEEPSEEK_MODEL = DEEPSEEK_V4_PRO_MODEL;
|
|
334
337
|
var DEFAULT_FX_MODEL = "zai/glm-5.2";
|
|
338
|
+
var DEFAULT_KIMI_MODEL = "moonshotai/kimi-k2.6";
|
|
335
339
|
var DEFAULT_PI_MODEL = DEFAULT_OPENCODE_MODEL;
|
|
336
340
|
var OPENROUTER_MODELS = [
|
|
337
341
|
DEFAULT_OPENCODE_MODEL,
|
|
@@ -353,6 +357,7 @@ var FALLBACK_AGENT_MODEL = {
|
|
|
353
357
|
cursor: DEFAULT_CURSOR_MODEL,
|
|
354
358
|
deepseek: DEFAULT_DEEPSEEK_MODEL,
|
|
355
359
|
fx: DEFAULT_FX_MODEL,
|
|
360
|
+
kimi: DEFAULT_KIMI_MODEL,
|
|
356
361
|
opencode: DEFAULT_OPENCODE_MODEL,
|
|
357
362
|
pi: DEFAULT_PI_MODEL,
|
|
358
363
|
relay: DEFAULT_CLAUDE_MODEL
|
|
@@ -441,6 +446,7 @@ var AGENT_MODELS = {
|
|
|
441
446
|
],
|
|
442
447
|
deepseek: prioritizeDeepseekModels(OPENROUTER_MODELS),
|
|
443
448
|
fx: [DEFAULT_FX_MODEL],
|
|
449
|
+
kimi: [DEFAULT_KIMI_MODEL],
|
|
444
450
|
opencode: [...OPENROUTER_MODELS, ...ASTER_MODELS],
|
|
445
451
|
pi: [...OPENROUTER_MODELS, ...ASTER_MODELS],
|
|
446
452
|
relay: [CLAUDE_FABLE_5_MODEL, CLAUDE_OPUS_5_MODEL, CLAUDE_OPUS_4_8_MODEL, CLAUDE_SONNET_5_MODEL]
|
|
@@ -640,6 +646,9 @@ var AGENT_CREDENTIAL_METHODS_IN_ORDER = {
|
|
|
640
646
|
[AGENT.FX]: [
|
|
641
647
|
{ method: CREDENTIAL_METHOD.AI_GATEWAY, credentialType: CREDENTIAL_TYPE.AI_GATEWAY_API_KEY }
|
|
642
648
|
],
|
|
649
|
+
[AGENT.KIMI]: [
|
|
650
|
+
{ method: CREDENTIAL_METHOD.AI_GATEWAY, credentialType: CREDENTIAL_TYPE.AI_GATEWAY_API_KEY }
|
|
651
|
+
],
|
|
643
652
|
[AGENT.OPENCODE]: [
|
|
644
653
|
{ method: CREDENTIAL_METHOD.OPENCODE_GO, credentialType: CREDENTIAL_TYPE.OPENCODE_GO_API_KEY },
|
|
645
654
|
{ method: CREDENTIAL_METHOD.ASTER, credentialType: CREDENTIAL_TYPE.ASTER_API_KEY },
|
|
@@ -1530,7 +1539,7 @@ var SLASH_COMMANDS = [
|
|
|
1530
1539
|
command: "/plan",
|
|
1531
1540
|
description: "Switch to plan mode and optionally send a prompt.",
|
|
1532
1541
|
argumentHint: "[prompt]",
|
|
1533
|
-
providers: ["claude", "codex", "cursor", "deepseek", "fx", "opencode", "pi", "relay"]
|
|
1542
|
+
providers: ["claude", "codex", "cursor", "deepseek", "fx", "kimi", "opencode", "pi", "relay"]
|
|
1534
1543
|
},
|
|
1535
1544
|
{
|
|
1536
1545
|
command: "/fast",
|
|
@@ -3459,6 +3468,24 @@ var CLAUDE_AUTH_ENV_KEYS_BY_METHOD = {
|
|
|
3459
3468
|
]
|
|
3460
3469
|
};
|
|
3461
3470
|
|
|
3471
|
+
// ../shared/src/routes/ai-gateway.ts
|
|
3472
|
+
var AI_GATEWAY_BASE_URL = "https://ai-gateway.vercel.sh/v1";
|
|
3473
|
+
async function fetchAiGatewayModels() {
|
|
3474
|
+
const response = await fetch(`${AI_GATEWAY_BASE_URL}/models`);
|
|
3475
|
+
if (!response.ok) return [];
|
|
3476
|
+
const body = await response.json();
|
|
3477
|
+
return isRecord(body) && Array.isArray(body.data) ? body.data.flatMap((model) => {
|
|
3478
|
+
if (!isRecord(model) || typeof model.id !== "string") return [];
|
|
3479
|
+
return [{
|
|
3480
|
+
id: model.id,
|
|
3481
|
+
displayName: typeof model.name === "string" && model.name ? model.name : model.id,
|
|
3482
|
+
...typeof model.description === "string" && model.description ? { description: model.description } : {},
|
|
3483
|
+
...typeof model.context_window === "number" ? { contextWindow: model.context_window } : {},
|
|
3484
|
+
tags: Array.isArray(model.tags) ? model.tags.filter((tag) => typeof tag === "string") : []
|
|
3485
|
+
}];
|
|
3486
|
+
}) : [];
|
|
3487
|
+
}
|
|
3488
|
+
|
|
3462
3489
|
// ../shared/src/routes/command-protection.ts
|
|
3463
3490
|
var COMMAND_PROTECTION_COMMAND_KEYS = ["command", "cmd", "script", "query", "endpoint", "path", "url", "mutation"];
|
|
3464
3491
|
function stringifyCommandProtectionInput(value) {
|
|
@@ -4500,71 +4527,147 @@ function parseDeepseekEvents(events) {
|
|
|
4500
4527
|
return messages;
|
|
4501
4528
|
}
|
|
4502
4529
|
|
|
4503
|
-
// ../shared/src/display-message/parsers/
|
|
4504
|
-
|
|
4530
|
+
// ../shared/src/display-message/parsers/acp-parser.ts
|
|
4531
|
+
var FX_CONTEXT_DIAGNOSTIC = /^\[context\] skill catalog omitted .*?(?:\r?\n|$)/;
|
|
4532
|
+
function getAcpTextChunk(update, kind) {
|
|
4505
4533
|
if (!isRecord(update) || update.sessionUpdate !== kind || !isRecord(update.content) || update.content.type !== "text") return null;
|
|
4506
|
-
return typeof update.content.text === "string" && update.content.text ? update.content.text : null;
|
|
4534
|
+
return typeof update.content.text === "string" && update.content.text.length > 0 ? update.content.text : null;
|
|
4507
4535
|
}
|
|
4508
|
-
function
|
|
4536
|
+
function isProviderEvent(event, provider, suffix) {
|
|
4537
|
+
return event.type === `acp-${suffix}` && (event.payload.provider === void 0 || event.payload.provider === provider) || event.type === `${provider}-${suffix}`;
|
|
4538
|
+
}
|
|
4539
|
+
function parseAcpEvents(events, provider) {
|
|
4509
4540
|
const messages = [];
|
|
4541
|
+
const activeChunks = {};
|
|
4542
|
+
const resolvedInputs = /* @__PURE__ */ new Map();
|
|
4543
|
+
let chunkSequence = 0;
|
|
4510
4544
|
for (const event of events) {
|
|
4511
|
-
const
|
|
4512
|
-
if (
|
|
4513
|
-
|
|
4545
|
+
const userContent = getUserMessage(event);
|
|
4546
|
+
if (userContent !== null) {
|
|
4547
|
+
activeChunks.agent_message_chunk = void 0;
|
|
4548
|
+
activeChunks.agent_thought_chunk = void 0;
|
|
4549
|
+
if (userContent.trim()) {
|
|
4514
4550
|
messages.push({
|
|
4515
|
-
id: getUserMessageId(event) ??
|
|
4551
|
+
id: getUserMessageId(event) ?? `${provider}-user-${event.timestamp}`,
|
|
4516
4552
|
type: "user",
|
|
4517
|
-
content,
|
|
4553
|
+
content: userContent,
|
|
4518
4554
|
timestamp: event.timestamp
|
|
4519
4555
|
});
|
|
4520
4556
|
}
|
|
4521
4557
|
continue;
|
|
4522
4558
|
}
|
|
4523
|
-
if (event
|
|
4559
|
+
if (isProviderEvent(event, provider, "error")) {
|
|
4524
4560
|
messages.push({
|
|
4525
|
-
id:
|
|
4561
|
+
id: `${provider}-error-${event.timestamp}`,
|
|
4526
4562
|
type: "error",
|
|
4527
|
-
message: typeof event.payload.message === "string" ? event.payload.message :
|
|
4563
|
+
message: typeof event.payload.message === "string" ? event.payload.message : `${provider} failed`,
|
|
4528
4564
|
timestamp: event.timestamp
|
|
4529
4565
|
});
|
|
4530
4566
|
continue;
|
|
4531
4567
|
}
|
|
4532
|
-
if (event
|
|
4568
|
+
if (isProviderEvent(event, provider, "turn-complete")) {
|
|
4533
4569
|
for (const message of messages) {
|
|
4534
4570
|
if (message.type === "reasoning" && message.status === "in_progress") message.status = "completed";
|
|
4535
4571
|
}
|
|
4572
|
+
activeChunks.agent_message_chunk = void 0;
|
|
4573
|
+
activeChunks.agent_thought_chunk = void 0;
|
|
4574
|
+
continue;
|
|
4575
|
+
}
|
|
4576
|
+
if (event.type === "replicas-tool-input-request" && typeof event.payload.toolUseId === "string" && typeof event.payload.requestId === "string") {
|
|
4577
|
+
const message = messages.find((candidate) => candidate.type === "tool_call" && candidate.id === `${provider}-tool-${event.payload.toolUseId}`);
|
|
4578
|
+
if (message && (Array.isArray(event.payload.options) || Array.isArray(event.payload.questions))) {
|
|
4579
|
+
const resolved = resolvedInputs.get(event.payload.toolUseId);
|
|
4580
|
+
message.inputRequest = {
|
|
4581
|
+
requestId: event.payload.requestId,
|
|
4582
|
+
status: resolved?.selectionId === "aborted" ? "aborted" : resolved ? "resolved" : "pending",
|
|
4583
|
+
...Array.isArray(event.payload.options) ? { options: event.payload.options } : {},
|
|
4584
|
+
...Array.isArray(event.payload.questions) ? { questions: event.payload.questions } : {},
|
|
4585
|
+
...resolved ? { selectionId: resolved.selectionId } : {},
|
|
4586
|
+
...resolved?.selectionSummary ? { selectionSummary: resolved.selectionSummary } : {}
|
|
4587
|
+
};
|
|
4588
|
+
}
|
|
4536
4589
|
continue;
|
|
4537
4590
|
}
|
|
4538
|
-
if (event.type
|
|
4591
|
+
if (event.type === "replicas-tool-input-resolved" && typeof event.payload.toolUseId === "string" && typeof event.payload.selectionId === "string") {
|
|
4592
|
+
const resolved = {
|
|
4593
|
+
selectionId: event.payload.selectionId,
|
|
4594
|
+
...typeof event.payload.selectionSummary === "string" ? { selectionSummary: event.payload.selectionSummary } : {}
|
|
4595
|
+
};
|
|
4596
|
+
resolvedInputs.set(event.payload.toolUseId, resolved);
|
|
4597
|
+
const message = messages.find((candidate) => candidate.type === "tool_call" && candidate.id === `${provider}-tool-${event.payload.toolUseId}`);
|
|
4598
|
+
if (message?.inputRequest) {
|
|
4599
|
+
message.inputRequest = {
|
|
4600
|
+
...message.inputRequest,
|
|
4601
|
+
status: resolved.selectionId === "aborted" ? "aborted" : "resolved",
|
|
4602
|
+
...resolved
|
|
4603
|
+
};
|
|
4604
|
+
}
|
|
4605
|
+
continue;
|
|
4606
|
+
}
|
|
4607
|
+
if (!isProviderEvent(event, provider, "session-update") || !isRecord(event.payload.update)) continue;
|
|
4539
4608
|
const update = event.payload.update;
|
|
4540
4609
|
const kind = update.sessionUpdate;
|
|
4541
4610
|
if (kind === "agent_message_chunk" || kind === "agent_thought_chunk") {
|
|
4542
|
-
const
|
|
4543
|
-
if (
|
|
4544
|
-
const
|
|
4611
|
+
const content = getAcpTextChunk(update, kind);
|
|
4612
|
+
if (content === null) continue;
|
|
4613
|
+
const explicitId = typeof update.messageId === "string" && update.messageId.length > 0 ? `${provider}-${kind}-${update.messageId}` : null;
|
|
4614
|
+
const id = explicitId ?? activeChunks[kind] ?? `${provider}-${kind}-${chunkSequence++}`;
|
|
4615
|
+
activeChunks[kind] = id;
|
|
4616
|
+
const otherKind = kind === "agent_message_chunk" ? "agent_thought_chunk" : "agent_message_chunk";
|
|
4617
|
+
if (!explicitId) activeChunks[otherKind] = void 0;
|
|
4545
4618
|
const existing = messages.find((message) => message.id === id);
|
|
4546
|
-
const text = `${existing && "content" in existing && typeof existing.content === "string" ? existing.content : ""}${
|
|
4619
|
+
const text = `${existing && "content" in existing && typeof existing.content === "string" ? existing.content : ""}${content}`.replace(provider === "fx" ? FX_CONTEXT_DIAGNOSTIC : /$^/, "");
|
|
4620
|
+
if (!text) continue;
|
|
4547
4621
|
upsertDisplayMessage(messages, kind === "agent_thought_chunk" ? { id, type: "reasoning", content: text, status: "in_progress", timestamp: existing?.timestamp ?? event.timestamp } : { id, type: "agent", content: text, timestamp: existing?.timestamp ?? event.timestamp });
|
|
4548
4622
|
continue;
|
|
4549
4623
|
}
|
|
4624
|
+
activeChunks.agent_message_chunk = void 0;
|
|
4625
|
+
activeChunks.agent_thought_chunk = void 0;
|
|
4550
4626
|
if ((kind === "tool_call" || kind === "tool_call_update") && typeof update.toolCallId === "string") {
|
|
4551
|
-
const id =
|
|
4627
|
+
const id = `${provider}-tool-${update.toolCallId}`;
|
|
4552
4628
|
const existing = messages.find((message) => message.id === id && message.type === "tool_call");
|
|
4553
4629
|
const status = update.status === "completed" || update.status === "failed" ? update.status === "failed" ? "failed" : "completed" : "in_progress";
|
|
4630
|
+
const contentOutput = Array.isArray(update.content) && update.content.length > 0 ? stringifyDisplayValue(update.content) : void 0;
|
|
4554
4631
|
upsertDisplayMessage(messages, createCallDisplayMessage({
|
|
4555
4632
|
id,
|
|
4556
|
-
server:
|
|
4557
|
-
tool: typeof update.name === "string" ? update.name : typeof update.title === "string" ? update.title : existing?.tool ?? "tool",
|
|
4633
|
+
server: provider,
|
|
4634
|
+
tool: typeof update.name === "string" && update.name ? update.name : typeof update.title === "string" && update.title ? update.title : existing?.tool ?? (typeof update.kind === "string" ? update.kind : "tool"),
|
|
4558
4635
|
input: update.rawInput === void 0 ? existing?.input : isRecord(update.rawInput) ? update.rawInput : stringifyDisplayValue(update.rawInput),
|
|
4559
|
-
output: update.rawOutput === void 0 ? existing?.output : stringifyDisplayValue(update.rawOutput),
|
|
4636
|
+
output: update.rawOutput === void 0 ? contentOutput ?? existing?.output : stringifyDisplayValue(update.rawOutput),
|
|
4560
4637
|
status,
|
|
4561
|
-
timestamp: event.timestamp
|
|
4638
|
+
timestamp: existing?.timestamp ?? event.timestamp
|
|
4562
4639
|
}));
|
|
4640
|
+
continue;
|
|
4641
|
+
}
|
|
4642
|
+
const plan = kind === "plan" ? update : isRecord(update.plan) ? update.plan : void 0;
|
|
4643
|
+
if ((kind === "plan" || kind === "plan_update") && plan && Array.isArray(plan.entries)) {
|
|
4644
|
+
const items = plan.entries.flatMap((entry) => {
|
|
4645
|
+
if (!isRecord(entry) || typeof entry.content !== "string") return [];
|
|
4646
|
+
const itemStatus = entry.status === "completed" || entry.status === "in_progress" ? entry.status : "pending";
|
|
4647
|
+
return [{
|
|
4648
|
+
text: entry.content,
|
|
4649
|
+
completed: entry.status === "completed",
|
|
4650
|
+
itemStatus
|
|
4651
|
+
}];
|
|
4652
|
+
});
|
|
4653
|
+
upsertDisplayMessage(messages, {
|
|
4654
|
+
id: `${provider}-plan-${typeof plan.planId === "string" ? plan.planId : "current"}`,
|
|
4655
|
+
type: "todo_list",
|
|
4656
|
+
items,
|
|
4657
|
+
status: items.every((item) => item.completed) ? "completed" : "in_progress",
|
|
4658
|
+
timestamp: event.timestamp
|
|
4659
|
+
});
|
|
4563
4660
|
}
|
|
4564
4661
|
}
|
|
4565
4662
|
return messages;
|
|
4566
4663
|
}
|
|
4567
4664
|
|
|
4665
|
+
// ../shared/src/display-message/parsers/fx-parser.ts
|
|
4666
|
+
var getFxTextChunk = getAcpTextChunk;
|
|
4667
|
+
function parseFxEvents(events) {
|
|
4668
|
+
return parseAcpEvents(events, "fx");
|
|
4669
|
+
}
|
|
4670
|
+
|
|
4568
4671
|
// ../shared/src/display-message/parsers/opencode-parser.ts
|
|
4569
4672
|
function timestampFromMs(value, fallback) {
|
|
4570
4673
|
return typeof value === "number" && Number.isFinite(value) ? new Date(value).toISOString() : fallback;
|
|
@@ -5734,6 +5837,9 @@ function parseAgentEvents(events, agentType) {
|
|
|
5734
5837
|
if (agentType === "fx") {
|
|
5735
5838
|
return parseFxEvents(events);
|
|
5736
5839
|
}
|
|
5840
|
+
if (agentType === "kimi") {
|
|
5841
|
+
return parseAcpEvents(events, "kimi");
|
|
5842
|
+
}
|
|
5737
5843
|
if (agentType === "opencode") {
|
|
5738
5844
|
return parseOpencodeEvents(events);
|
|
5739
5845
|
}
|
|
@@ -6332,7 +6438,7 @@ var DEFAULT_CODEX_ARGS = [
|
|
|
6332
6438
|
var MIN_CODEX_CLI_VERSION = "0.144.6";
|
|
6333
6439
|
var CODEX_UPGRADE_TIMEOUT_MS = 12e4;
|
|
6334
6440
|
var codexCliVersionEnsured = null;
|
|
6335
|
-
var ENGINE_PACKAGE_VERSION = "0.1.
|
|
6441
|
+
var ENGINE_PACKAGE_VERSION = "0.1.666";
|
|
6336
6442
|
var INITIALIZE_METHOD = "initialize";
|
|
6337
6443
|
var INITIALIZED_NOTIFICATION = "initialized";
|
|
6338
6444
|
var ACCOUNT_LOGIN_START_METHOD = "account/login/start";
|
|
@@ -6598,6 +6704,7 @@ export {
|
|
|
6598
6704
|
DEFAULT_OPENCODE_MODEL,
|
|
6599
6705
|
DEFAULT_DEEPSEEK_MODEL,
|
|
6600
6706
|
DEFAULT_FX_MODEL,
|
|
6707
|
+
DEFAULT_KIMI_MODEL,
|
|
6601
6708
|
DEFAULT_PI_MODEL,
|
|
6602
6709
|
getDefaultAgentModel,
|
|
6603
6710
|
normalizeClaudeModel,
|
|
@@ -6680,6 +6787,8 @@ export {
|
|
|
6680
6787
|
CLAUDE_AUTH_ENV_KEYS,
|
|
6681
6788
|
claudeAuthEnvFromResponse,
|
|
6682
6789
|
CLAUDE_AUTH_ENV_KEYS_BY_METHOD,
|
|
6790
|
+
AI_GATEWAY_BASE_URL,
|
|
6791
|
+
fetchAiGatewayModels,
|
|
6683
6792
|
extractCommandProtectionCommandText,
|
|
6684
6793
|
findPrMergeSignals,
|
|
6685
6794
|
findGitCommitSignals,
|