replicas-cli 0.2.536 → 0.2.538
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 +112 -82
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -22301,7 +22301,8 @@ config(en_default());
|
|
|
22301
22301
|
// ../shared/src/analytics/types.ts
|
|
22302
22302
|
var agentCredentialSnapshotSchema = external_exports.object({
|
|
22303
22303
|
method: external_exports.enum(CREDENTIAL_METHOD),
|
|
22304
|
-
scope: external_exports.enum(CREDENTIAL_SCOPE)
|
|
22304
|
+
scope: external_exports.enum(CREDENTIAL_SCOPE),
|
|
22305
|
+
revision: external_exports.string().optional()
|
|
22305
22306
|
});
|
|
22306
22307
|
function isAuthMethod(value) {
|
|
22307
22308
|
return typeof value === "string" && Object.values(CREDENTIAL_METHOD).some((method) => method === value);
|
|
@@ -22385,6 +22386,8 @@ var DEFAULT_CODEX_MODEL = GPT_5_6_SOL_MODEL;
|
|
|
22385
22386
|
var DEFAULT_OPENCODE_MODEL = "z-ai/glm-5.2";
|
|
22386
22387
|
var OPENROUTER_MODELS = [
|
|
22387
22388
|
DEFAULT_OPENCODE_MODEL,
|
|
22389
|
+
"deepseek/deepseek-v4-pro",
|
|
22390
|
+
"deepseek/deepseek-v4-flash",
|
|
22388
22391
|
"minimax/minimax-m3",
|
|
22389
22392
|
"xiaomi/mimo-v2.5-pro",
|
|
22390
22393
|
"moonshotai/kimi-k2.6"
|
|
@@ -22479,6 +22482,8 @@ var MODEL_LABELS = {
|
|
|
22479
22482
|
[GPT_5_6_LUNA_MODEL]: "GPT-5.6 Luna",
|
|
22480
22483
|
"gpt-5.5": "GPT-5.5",
|
|
22481
22484
|
[DEFAULT_OPENCODE_MODEL]: "GLM 5.2 via OpenRouter",
|
|
22485
|
+
"deepseek/deepseek-v4-pro": "DeepSeek V4 Pro via OpenRouter",
|
|
22486
|
+
"deepseek/deepseek-v4-flash": "DeepSeek V4 Flash via OpenRouter",
|
|
22482
22487
|
"minimax/minimax-m3": "MiniMax M3 via OpenRouter",
|
|
22483
22488
|
"xiaomi/mimo-v2.5-pro": "MiMo V2.5 Pro via OpenRouter",
|
|
22484
22489
|
"moonshotai/kimi-k2.6": "Kimi K2.6 via OpenRouter",
|
|
@@ -24349,7 +24354,7 @@ var headlessFilesystemAgentResultSchema = external_exports.object({
|
|
|
24349
24354
|
});
|
|
24350
24355
|
|
|
24351
24356
|
// ../shared/src/cli-version.ts
|
|
24352
|
-
var CLI_VERSION = "0.2.
|
|
24357
|
+
var CLI_VERSION = "0.2.538";
|
|
24353
24358
|
|
|
24354
24359
|
// ../shared/src/version.ts
|
|
24355
24360
|
function compareVersions(v1, v2) {
|
|
@@ -25429,11 +25434,14 @@ function parseDeepseekEvents(events) {
|
|
|
25429
25434
|
continue;
|
|
25430
25435
|
}
|
|
25431
25436
|
if (event.type === "tool/result") {
|
|
25432
|
-
const
|
|
25433
|
-
const
|
|
25437
|
+
const message = isRecord(data.message) ? data.message : {};
|
|
25438
|
+
const messageSource = isRecord(message.source) ? message.source : {};
|
|
25439
|
+
const result = Array.isArray(message.content) && isRecord(message.content[0]) ? message.content[0] : {};
|
|
25440
|
+
const callId = typeof messageSource.callId === "string" ? messageSource.callId : typeof data.callId === "string" ? data.callId : String(seq);
|
|
25441
|
+
const existing = messages.find((message2) => message2.id === `deepseek-tool-${callId}` && message2.type === "tool_call");
|
|
25434
25442
|
if (existing?.type === "tool_call") {
|
|
25435
|
-
existing.output = stringifyDisplayValue(
|
|
25436
|
-
existing.status = data.isError === true ? "failed" : "completed";
|
|
25443
|
+
existing.output = stringifyDisplayValue(result.content ?? data.result);
|
|
25444
|
+
existing.status = result.isError === true || data.isError === true ? "failed" : "completed";
|
|
25437
25445
|
}
|
|
25438
25446
|
continue;
|
|
25439
25447
|
}
|
|
@@ -30572,19 +30580,18 @@ async function envFilesDeleteCommand(envIdOrName, pathOrId, options) {
|
|
|
30572
30580
|
Deleted file ${pathOrId}.
|
|
30573
30581
|
`));
|
|
30574
30582
|
}
|
|
30575
|
-
async function
|
|
30583
|
+
async function envHookGetCommand(envIdOrName, kind) {
|
|
30576
30584
|
ensureOrgApiAuthenticated();
|
|
30577
30585
|
const id = await resolveEnvironmentId(envIdOrName);
|
|
30578
|
-
const
|
|
30579
|
-
|
|
30580
|
-
|
|
30581
|
-
|
|
30582
|
-
|
|
30586
|
+
const hook = kind === "warm" ? (await orgAuthenticatedFetch(`/v1/environments/${id}/warm-hooks`)).warm_hook : (await orgAuthenticatedFetch(`/v1/environments/${id}/start-hooks`)).start_hook;
|
|
30587
|
+
if (!hook) {
|
|
30588
|
+
console.log(import_chalk21.default.yellow(`
|
|
30589
|
+
No ${kind} hook configured.
|
|
30590
|
+
`));
|
|
30583
30591
|
return;
|
|
30584
30592
|
}
|
|
30585
|
-
const hook = response.start_hook;
|
|
30586
30593
|
console.log(import_chalk21.default.green(`
|
|
30587
|
-
Start hook (v${hook.version}, ${hook.is_active ? "active" : "inactive"}):
|
|
30594
|
+
${kind === "warm" ? "Warm" : "Start"} hook (v${hook.version}, ${hook.is_active ? "active" : "inactive"}):
|
|
30588
30595
|
`));
|
|
30589
30596
|
console.log(import_chalk21.default.gray(` ID: ${hook.id}`));
|
|
30590
30597
|
console.log(import_chalk21.default.gray(` Created: ${formatDate2(hook.created_at)}
|
|
@@ -30592,24 +30599,31 @@ Start hook (v${hook.version}, ${hook.is_active ? "active" : "inactive"}):
|
|
|
30592
30599
|
console.log(hook.content);
|
|
30593
30600
|
console.log();
|
|
30594
30601
|
}
|
|
30595
|
-
async function
|
|
30602
|
+
async function envHookSaveCommand(envIdOrName, options, kind) {
|
|
30596
30603
|
ensureOrgApiAuthenticated();
|
|
30597
30604
|
const id = await resolveEnvironmentId(envIdOrName);
|
|
30598
30605
|
const content = readFileContent(options);
|
|
30606
|
+
if (kind === "warm") {
|
|
30607
|
+
const body2 = { environment_id: id, content };
|
|
30608
|
+
const response2 = await orgAuthenticatedFetch(
|
|
30609
|
+
`/v1/environments/${id}/warm-hooks/save`,
|
|
30610
|
+
{ method: "POST", body: body2 }
|
|
30611
|
+
);
|
|
30612
|
+
console.log(import_chalk21.default.green(`
|
|
30613
|
+
Saved warm hook v${response2.warm_hook.version}.
|
|
30614
|
+
`));
|
|
30615
|
+
return;
|
|
30616
|
+
}
|
|
30599
30617
|
const body = { content };
|
|
30600
30618
|
const response = await orgAuthenticatedFetch(
|
|
30601
30619
|
`/v1/environments/${id}/start-hooks/save`,
|
|
30602
30620
|
{ method: "POST", body }
|
|
30603
30621
|
);
|
|
30604
|
-
|
|
30605
|
-
console.log(import_chalk21.default.green("\nCleared start hook.\n"));
|
|
30606
|
-
return;
|
|
30607
|
-
}
|
|
30608
|
-
console.log(import_chalk21.default.green(`
|
|
30622
|
+
console.log(import_chalk21.default.green(response.start_hook ? `
|
|
30609
30623
|
Saved start hook v${response.start_hook.version}.
|
|
30610
|
-
`));
|
|
30624
|
+
` : "\nCleared start hook.\n"));
|
|
30611
30625
|
}
|
|
30612
|
-
async function
|
|
30626
|
+
async function envHookTestCommand(envIdOrName, options, kind) {
|
|
30613
30627
|
ensureOrgApiAuthenticated();
|
|
30614
30628
|
const id = await resolveEnvironmentId(envIdOrName);
|
|
30615
30629
|
const content = readFileContent(options);
|
|
@@ -30617,9 +30631,9 @@ async function envStartHookTestCommand(envIdOrName, options) {
|
|
|
30617
30631
|
let timedOut = false;
|
|
30618
30632
|
let errorMessage = null;
|
|
30619
30633
|
await orgAuthenticatedSseStream(
|
|
30620
|
-
`/v1/environments/${id}
|
|
30634
|
+
`/v1/environments/${id}/${kind}-hooks/${kind === "warm" ? "save-test/stream" : "test/stream"}`,
|
|
30621
30635
|
{
|
|
30622
|
-
body: { content },
|
|
30636
|
+
body: kind === "warm" ? { content, mode: options.save ? "save_test" : "test_only" } : { content },
|
|
30623
30637
|
onEvent: (event) => {
|
|
30624
30638
|
if (event.type === "progress" && event.message) {
|
|
30625
30639
|
console.log(import_chalk21.default.gray(event.message));
|
|
@@ -30641,49 +30655,77 @@ ${errorMessage}
|
|
|
30641
30655
|
process.exit(1);
|
|
30642
30656
|
}
|
|
30643
30657
|
if (timedOut) {
|
|
30644
|
-
console.log(import_chalk21.default.yellow(
|
|
30658
|
+
console.log(import_chalk21.default.yellow(`
|
|
30659
|
+
${kind === "warm" ? "Warm" : "Start"} hook timed out.
|
|
30660
|
+
`));
|
|
30645
30661
|
process.exit(1);
|
|
30646
30662
|
}
|
|
30647
30663
|
if (exitCode === 0) {
|
|
30648
30664
|
console.log(import_chalk21.default.green(`
|
|
30649
|
-
Start hook passed (exit code ${exitCode}).
|
|
30665
|
+
${kind === "warm" ? "Warm" : "Start"} hook passed${options.save ? " and was saved" : ""} (exit code ${exitCode}).
|
|
30650
30666
|
`));
|
|
30651
30667
|
} else {
|
|
30652
30668
|
console.log(import_chalk21.default.red(`
|
|
30653
|
-
Start hook failed (exit code ${exitCode ?? "unknown"}).
|
|
30669
|
+
${kind === "warm" ? "Warm" : "Start"} hook failed (exit code ${exitCode ?? "unknown"}).
|
|
30654
30670
|
`));
|
|
30655
30671
|
process.exit(1);
|
|
30656
30672
|
}
|
|
30657
30673
|
}
|
|
30658
|
-
async function
|
|
30674
|
+
async function envHookRepositoryHooksCommand(envIdOrName, kind) {
|
|
30659
30675
|
ensureOrgApiAuthenticated();
|
|
30660
30676
|
const id = await resolveEnvironmentId(envIdOrName);
|
|
30661
|
-
const
|
|
30677
|
+
const repositories = kind === "warm" ? (await orgAuthenticatedFetch(
|
|
30678
|
+
`/v1/environments/${id}/warm-hooks/repository-hooks`
|
|
30679
|
+
)).repositories.map((repository) => ({ ...repository, hook: repository.warm_hook })) : (await orgAuthenticatedFetch(
|
|
30662
30680
|
`/v1/environments/${id}/start-hooks/repository-hooks`
|
|
30663
|
-
);
|
|
30664
|
-
if (
|
|
30681
|
+
)).repositories.map((repository) => ({ ...repository, hook: repository.start_hook }));
|
|
30682
|
+
if (repositories.length === 0) {
|
|
30665
30683
|
console.log(import_chalk21.default.yellow("\nNo repositories bound to this environment.\n"));
|
|
30666
30684
|
return;
|
|
30667
30685
|
}
|
|
30668
30686
|
console.log(import_chalk21.default.green(`
|
|
30669
|
-
Repository
|
|
30687
|
+
Repository ${kind} hooks (${repositories.length}):
|
|
30670
30688
|
`));
|
|
30671
|
-
for (const repo of
|
|
30689
|
+
for (const repo of repositories) {
|
|
30672
30690
|
console.log(import_chalk21.default.white(` ${repo.repository_name} @${repo.default_branch}`));
|
|
30673
30691
|
if (repo.error) {
|
|
30674
30692
|
console.log(import_chalk21.default.red(` Error: ${repo.error}`));
|
|
30675
|
-
} else if (repo.
|
|
30693
|
+
} else if (repo.hook) {
|
|
30676
30694
|
console.log(import_chalk21.default.gray(` Source: ${repo.filename ?? "(unknown)"}`));
|
|
30677
|
-
console.log(import_chalk21.default.gray(` Commands (${repo.
|
|
30678
|
-
for (const cmd of repo.
|
|
30695
|
+
console.log(import_chalk21.default.gray(` Commands (${repo.hook.commands.length}):`));
|
|
30696
|
+
for (const cmd of repo.hook.commands) {
|
|
30679
30697
|
console.log(import_chalk21.default.gray(` ${cmd}`));
|
|
30680
30698
|
}
|
|
30681
30699
|
} else {
|
|
30682
|
-
console.log(import_chalk21.default.gray(` No
|
|
30700
|
+
console.log(import_chalk21.default.gray(` No ${kind}Hook defined.`));
|
|
30683
30701
|
}
|
|
30684
30702
|
console.log();
|
|
30685
30703
|
}
|
|
30686
30704
|
}
|
|
30705
|
+
async function envWarmHookGetCommand(envIdOrName) {
|
|
30706
|
+
return envHookGetCommand(envIdOrName, "warm");
|
|
30707
|
+
}
|
|
30708
|
+
async function envWarmHookSaveCommand(envIdOrName, options) {
|
|
30709
|
+
return envHookSaveCommand(envIdOrName, options, "warm");
|
|
30710
|
+
}
|
|
30711
|
+
async function envWarmHookTestCommand(envIdOrName, options) {
|
|
30712
|
+
return envHookTestCommand(envIdOrName, options, "warm");
|
|
30713
|
+
}
|
|
30714
|
+
async function envWarmHookRepositoryHooksCommand(envIdOrName) {
|
|
30715
|
+
return envHookRepositoryHooksCommand(envIdOrName, "warm");
|
|
30716
|
+
}
|
|
30717
|
+
async function envStartHookGetCommand(envIdOrName) {
|
|
30718
|
+
return envHookGetCommand(envIdOrName, "start");
|
|
30719
|
+
}
|
|
30720
|
+
async function envStartHookSaveCommand(envIdOrName, options) {
|
|
30721
|
+
return envHookSaveCommand(envIdOrName, options, "start");
|
|
30722
|
+
}
|
|
30723
|
+
async function envStartHookTestCommand(envIdOrName, options) {
|
|
30724
|
+
return envHookTestCommand(envIdOrName, options, "start");
|
|
30725
|
+
}
|
|
30726
|
+
async function envStartHookRepositoryHooksCommand(envIdOrName) {
|
|
30727
|
+
return envHookRepositoryHooksCommand(envIdOrName, "start");
|
|
30728
|
+
}
|
|
30687
30729
|
|
|
30688
30730
|
// src/index.ts
|
|
30689
30731
|
function parseBooleanOption(value) {
|
|
@@ -31212,54 +31254,42 @@ envFiles.command("delete <env> <path-or-id>").description("Delete a file by dest
|
|
|
31212
31254
|
process.exit(1);
|
|
31213
31255
|
}
|
|
31214
31256
|
});
|
|
31215
|
-
|
|
31216
|
-
|
|
31217
|
-
|
|
31218
|
-
|
|
31219
|
-
|
|
31220
|
-
|
|
31221
|
-
console.error(import_chalk22.default.red(`
|
|
31222
|
-
\u2717 ${error51.message}
|
|
31223
|
-
`));
|
|
31224
|
-
}
|
|
31225
|
-
process.exit(1);
|
|
31226
|
-
}
|
|
31227
|
-
});
|
|
31228
|
-
envStartHooks.command("save <env>").description("Save and activate a start hook (provide --content or --file)").option("-c, --content <content>", "Inline hook script").option("-f, --file <local-path>", "Read hook script from a local file").action(async (env, options) => {
|
|
31229
|
-
try {
|
|
31230
|
-
await envStartHookSaveCommand(env, options);
|
|
31231
|
-
} catch (error51) {
|
|
31232
|
-
if (error51 instanceof Error) {
|
|
31233
|
-
console.error(import_chalk22.default.red(`
|
|
31234
|
-
\u2717 ${error51.message}
|
|
31235
|
-
`));
|
|
31236
|
-
}
|
|
31237
|
-
process.exit(1);
|
|
31238
|
-
}
|
|
31239
|
-
});
|
|
31240
|
-
envStartHooks.command("test <env>").description("Run a start hook in an isolated sandbox without saving it").option("-c, --content <content>", "Inline hook script").option("-f, --file <local-path>", "Read hook script from a local file").action(async (env, options) => {
|
|
31241
|
-
try {
|
|
31242
|
-
await envStartHookTestCommand(env, options);
|
|
31243
|
-
} catch (error51) {
|
|
31244
|
-
if (error51 instanceof Error) {
|
|
31245
|
-
console.error(import_chalk22.default.red(`
|
|
31246
|
-
\u2717 ${error51.message}
|
|
31247
|
-
`));
|
|
31248
|
-
}
|
|
31249
|
-
process.exit(1);
|
|
31250
|
-
}
|
|
31251
|
-
});
|
|
31252
|
-
envStartHooks.command("repository-hooks <env>").description("List per-repo start hooks defined in replicas.json / replicas.yaml").action(async (env) => {
|
|
31253
|
-
try {
|
|
31254
|
-
await envStartHookRepositoryHooksCommand(env);
|
|
31255
|
-
} catch (error51) {
|
|
31256
|
-
if (error51 instanceof Error) {
|
|
31257
|
-
console.error(import_chalk22.default.red(`
|
|
31257
|
+
function registerEnvironmentHookCommands(parent, config3) {
|
|
31258
|
+
const label = `${config3.kind} hook`;
|
|
31259
|
+
const run = async (command) => {
|
|
31260
|
+
try {
|
|
31261
|
+
await command();
|
|
31262
|
+
} catch (error51) {
|
|
31263
|
+
if (error51 instanceof Error) console.error(import_chalk22.default.red(`
|
|
31258
31264
|
\u2717 ${error51.message}
|
|
31259
31265
|
`));
|
|
31266
|
+
process.exit(1);
|
|
31260
31267
|
}
|
|
31261
|
-
|
|
31262
|
-
}
|
|
31268
|
+
};
|
|
31269
|
+
const hooks = parent.command(`${config3.kind}-hooks`).description(config3.kind === "warm" ? "Manage env-level warm hooks (run while pre-warming workspaces)" : "Manage env-level start hooks (run on every workspace boot, before repo-level start hooks)");
|
|
31270
|
+
hooks.command("get <env>").description(`Show the active ${label} for an environment`).action((env) => run(() => config3.get(env)));
|
|
31271
|
+
hooks.command("save <env>").description(`Save and activate a ${label}${config3.kind === "warm" ? " without testing it" : ""}`).option("-c, --content <content>", "Inline hook script").option("-f, --file <local-path>", "Read hook script from a local file").action((env, options) => run(() => config3.save(env, options)));
|
|
31272
|
+
hooks.command("test <env>").description(`Run a ${label} in an isolated sandbox without saving it`).option("-c, --content <content>", "Inline hook script").option("-f, --file <local-path>", "Read hook script from a local file").action((env, options) => run(() => config3.test(env, options)));
|
|
31273
|
+
if (config3.saveTest) {
|
|
31274
|
+
const saveTest = config3.saveTest;
|
|
31275
|
+
hooks.command("save-test <env>").description(`Test a ${label} and save it only if the test passes`).option("-c, --content <content>", "Inline hook script").option("-f, --file <local-path>", "Read hook script from a local file").action((env, options) => run(() => saveTest(env, options)));
|
|
31276
|
+
}
|
|
31277
|
+
hooks.command("repository-hooks <env>").description(`List per-repo ${config3.kind} hooks defined in replicas.json / replicas.yaml`).action((env) => run(() => config3.repositoryHooks(env)));
|
|
31278
|
+
}
|
|
31279
|
+
registerEnvironmentHookCommands(environment, {
|
|
31280
|
+
kind: "warm",
|
|
31281
|
+
get: envWarmHookGetCommand,
|
|
31282
|
+
save: envWarmHookSaveCommand,
|
|
31283
|
+
test: envWarmHookTestCommand,
|
|
31284
|
+
saveTest: (env, options) => envWarmHookTestCommand(env, { ...options, save: true }),
|
|
31285
|
+
repositoryHooks: envWarmHookRepositoryHooksCommand
|
|
31286
|
+
});
|
|
31287
|
+
registerEnvironmentHookCommands(environment, {
|
|
31288
|
+
kind: "start",
|
|
31289
|
+
get: envStartHookGetCommand,
|
|
31290
|
+
save: envStartHookSaveCommand,
|
|
31291
|
+
test: envStartHookTestCommand,
|
|
31292
|
+
repositoryHooks: envStartHookRepositoryHooksCommand
|
|
31263
31293
|
});
|
|
31264
31294
|
environment.action(async () => {
|
|
31265
31295
|
try {
|