replicas-cli 0.2.535 → 0.2.537

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.
Files changed (2) hide show
  1. package/dist/index.cjs +115 -84
  2. package/package.json +1 -1
package/dist/index.cjs CHANGED
@@ -22385,6 +22385,8 @@ var DEFAULT_CODEX_MODEL = GPT_5_6_SOL_MODEL;
22385
22385
  var DEFAULT_OPENCODE_MODEL = "z-ai/glm-5.2";
22386
22386
  var OPENROUTER_MODELS = [
22387
22387
  DEFAULT_OPENCODE_MODEL,
22388
+ "deepseek/deepseek-v4-pro",
22389
+ "deepseek/deepseek-v4-flash",
22388
22390
  "minimax/minimax-m3",
22389
22391
  "xiaomi/mimo-v2.5-pro",
22390
22392
  "moonshotai/kimi-k2.6"
@@ -22479,6 +22481,8 @@ var MODEL_LABELS = {
22479
22481
  [GPT_5_6_LUNA_MODEL]: "GPT-5.6 Luna",
22480
22482
  "gpt-5.5": "GPT-5.5",
22481
22483
  [DEFAULT_OPENCODE_MODEL]: "GLM 5.2 via OpenRouter",
22484
+ "deepseek/deepseek-v4-pro": "DeepSeek V4 Pro via OpenRouter",
22485
+ "deepseek/deepseek-v4-flash": "DeepSeek V4 Flash via OpenRouter",
22482
22486
  "minimax/minimax-m3": "MiniMax M3 via OpenRouter",
22483
22487
  "xiaomi/mimo-v2.5-pro": "MiMo V2.5 Pro via OpenRouter",
22484
22488
  "moonshotai/kimi-k2.6": "Kimi K2.6 via OpenRouter",
@@ -24349,7 +24353,7 @@ var headlessFilesystemAgentResultSchema = external_exports.object({
24349
24353
  });
24350
24354
 
24351
24355
  // ../shared/src/cli-version.ts
24352
- var CLI_VERSION = "0.2.535";
24356
+ var CLI_VERSION = "0.2.537";
24353
24357
 
24354
24358
  // ../shared/src/version.ts
24355
24359
  function compareVersions(v1, v2) {
@@ -25429,11 +25433,14 @@ function parseDeepseekEvents(events) {
25429
25433
  continue;
25430
25434
  }
25431
25435
  if (event.type === "tool/result") {
25432
- const callId = typeof data.callId === "string" ? data.callId : String(seq);
25433
- const existing = messages.find((message) => message.id === `deepseek-tool-${callId}` && message.type === "tool_call");
25436
+ const message = isRecord(data.message) ? data.message : {};
25437
+ const messageSource = isRecord(message.source) ? message.source : {};
25438
+ const result = Array.isArray(message.content) && isRecord(message.content[0]) ? message.content[0] : {};
25439
+ const callId = typeof messageSource.callId === "string" ? messageSource.callId : typeof data.callId === "string" ? data.callId : String(seq);
25440
+ const existing = messages.find((message2) => message2.id === `deepseek-tool-${callId}` && message2.type === "tool_call");
25434
25441
  if (existing?.type === "tool_call") {
25435
- existing.output = stringifyDisplayValue(data.message ?? data.result);
25436
- existing.status = data.isError === true ? "failed" : "completed";
25442
+ existing.output = stringifyDisplayValue(result.content ?? data.result);
25443
+ existing.status = result.isError === true || data.isError === true ? "failed" : "completed";
25437
25444
  }
25438
25445
  continue;
25439
25446
  }
@@ -26728,6 +26735,11 @@ var EMAIL_KEYS = [
26728
26735
  var MANUAL_EMAIL_TEMPLATE_KEYS = ["product_update"];
26729
26736
  var EMAIL_TEMPLATE_KEYS = [...EMAIL_KEYS, ...MANUAL_EMAIL_TEMPLATE_KEYS];
26730
26737
 
26738
+ // ../shared/src/chat-transcript-pages.ts
26739
+ var decoder = new TextDecoder("utf-8", { fatal: true });
26740
+ var MAX_SOURCE_PAGE_BYTES = 4 * 1024 * 1024;
26741
+ var SOURCE_RANGE_BYTES = 256 * 1024;
26742
+
26731
26743
  // ../shared/src/object-store/types.ts
26732
26744
  var MEDIA_KIND = {
26733
26745
  IMAGE: "image",
@@ -26802,9 +26814,6 @@ async function readSseStream(body, onEvent, shouldContinue = () => true) {
26802
26814
  }
26803
26815
  }
26804
26816
 
26805
- // ../shared/src/chat-transcript-pages.ts
26806
- var decoder = new TextDecoder("utf-8", { fatal: true });
26807
-
26808
26817
  // src/lib/monolith-url.ts
26809
26818
  var MONOLITH_URL = process.env.REPLICAS_MONOLITH_URL || process.env.MONOLITH_URL || "https://api.tryreplicas.com";
26810
26819
 
@@ -30570,19 +30579,18 @@ async function envFilesDeleteCommand(envIdOrName, pathOrId, options) {
30570
30579
  Deleted file ${pathOrId}.
30571
30580
  `));
30572
30581
  }
30573
- async function envStartHookGetCommand(envIdOrName) {
30582
+ async function envHookGetCommand(envIdOrName, kind) {
30574
30583
  ensureOrgApiAuthenticated();
30575
30584
  const id = await resolveEnvironmentId(envIdOrName);
30576
- const response = await orgAuthenticatedFetch(
30577
- `/v1/environments/${id}/start-hooks`
30578
- );
30579
- if (!response.start_hook) {
30580
- console.log(import_chalk21.default.yellow("\nNo start hook configured.\n"));
30585
+ const hook = kind === "warm" ? (await orgAuthenticatedFetch(`/v1/environments/${id}/warm-hooks`)).warm_hook : (await orgAuthenticatedFetch(`/v1/environments/${id}/start-hooks`)).start_hook;
30586
+ if (!hook) {
30587
+ console.log(import_chalk21.default.yellow(`
30588
+ No ${kind} hook configured.
30589
+ `));
30581
30590
  return;
30582
30591
  }
30583
- const hook = response.start_hook;
30584
30592
  console.log(import_chalk21.default.green(`
30585
- Start hook (v${hook.version}, ${hook.is_active ? "active" : "inactive"}):
30593
+ ${kind === "warm" ? "Warm" : "Start"} hook (v${hook.version}, ${hook.is_active ? "active" : "inactive"}):
30586
30594
  `));
30587
30595
  console.log(import_chalk21.default.gray(` ID: ${hook.id}`));
30588
30596
  console.log(import_chalk21.default.gray(` Created: ${formatDate2(hook.created_at)}
@@ -30590,24 +30598,31 @@ Start hook (v${hook.version}, ${hook.is_active ? "active" : "inactive"}):
30590
30598
  console.log(hook.content);
30591
30599
  console.log();
30592
30600
  }
30593
- async function envStartHookSaveCommand(envIdOrName, options) {
30601
+ async function envHookSaveCommand(envIdOrName, options, kind) {
30594
30602
  ensureOrgApiAuthenticated();
30595
30603
  const id = await resolveEnvironmentId(envIdOrName);
30596
30604
  const content = readFileContent(options);
30605
+ if (kind === "warm") {
30606
+ const body2 = { environment_id: id, content };
30607
+ const response2 = await orgAuthenticatedFetch(
30608
+ `/v1/environments/${id}/warm-hooks/save`,
30609
+ { method: "POST", body: body2 }
30610
+ );
30611
+ console.log(import_chalk21.default.green(`
30612
+ Saved warm hook v${response2.warm_hook.version}.
30613
+ `));
30614
+ return;
30615
+ }
30597
30616
  const body = { content };
30598
30617
  const response = await orgAuthenticatedFetch(
30599
30618
  `/v1/environments/${id}/start-hooks/save`,
30600
30619
  { method: "POST", body }
30601
30620
  );
30602
- if (!response.start_hook) {
30603
- console.log(import_chalk21.default.green("\nCleared start hook.\n"));
30604
- return;
30605
- }
30606
- console.log(import_chalk21.default.green(`
30621
+ console.log(import_chalk21.default.green(response.start_hook ? `
30607
30622
  Saved start hook v${response.start_hook.version}.
30608
- `));
30623
+ ` : "\nCleared start hook.\n"));
30609
30624
  }
30610
- async function envStartHookTestCommand(envIdOrName, options) {
30625
+ async function envHookTestCommand(envIdOrName, options, kind) {
30611
30626
  ensureOrgApiAuthenticated();
30612
30627
  const id = await resolveEnvironmentId(envIdOrName);
30613
30628
  const content = readFileContent(options);
@@ -30615,9 +30630,9 @@ async function envStartHookTestCommand(envIdOrName, options) {
30615
30630
  let timedOut = false;
30616
30631
  let errorMessage = null;
30617
30632
  await orgAuthenticatedSseStream(
30618
- `/v1/environments/${id}/start-hooks/test/stream`,
30633
+ `/v1/environments/${id}/${kind}-hooks/${kind === "warm" ? "save-test/stream" : "test/stream"}`,
30619
30634
  {
30620
- body: { content },
30635
+ body: kind === "warm" ? { content, mode: options.save ? "save_test" : "test_only" } : { content },
30621
30636
  onEvent: (event) => {
30622
30637
  if (event.type === "progress" && event.message) {
30623
30638
  console.log(import_chalk21.default.gray(event.message));
@@ -30639,49 +30654,77 @@ ${errorMessage}
30639
30654
  process.exit(1);
30640
30655
  }
30641
30656
  if (timedOut) {
30642
- console.log(import_chalk21.default.yellow("\nStart hook timed out.\n"));
30657
+ console.log(import_chalk21.default.yellow(`
30658
+ ${kind === "warm" ? "Warm" : "Start"} hook timed out.
30659
+ `));
30643
30660
  process.exit(1);
30644
30661
  }
30645
30662
  if (exitCode === 0) {
30646
30663
  console.log(import_chalk21.default.green(`
30647
- Start hook passed (exit code ${exitCode}).
30664
+ ${kind === "warm" ? "Warm" : "Start"} hook passed${options.save ? " and was saved" : ""} (exit code ${exitCode}).
30648
30665
  `));
30649
30666
  } else {
30650
30667
  console.log(import_chalk21.default.red(`
30651
- Start hook failed (exit code ${exitCode ?? "unknown"}).
30668
+ ${kind === "warm" ? "Warm" : "Start"} hook failed (exit code ${exitCode ?? "unknown"}).
30652
30669
  `));
30653
30670
  process.exit(1);
30654
30671
  }
30655
30672
  }
30656
- async function envStartHookRepositoryHooksCommand(envIdOrName) {
30673
+ async function envHookRepositoryHooksCommand(envIdOrName, kind) {
30657
30674
  ensureOrgApiAuthenticated();
30658
30675
  const id = await resolveEnvironmentId(envIdOrName);
30659
- const response = await orgAuthenticatedFetch(
30676
+ const repositories = kind === "warm" ? (await orgAuthenticatedFetch(
30677
+ `/v1/environments/${id}/warm-hooks/repository-hooks`
30678
+ )).repositories.map((repository) => ({ ...repository, hook: repository.warm_hook })) : (await orgAuthenticatedFetch(
30660
30679
  `/v1/environments/${id}/start-hooks/repository-hooks`
30661
- );
30662
- if (response.repositories.length === 0) {
30680
+ )).repositories.map((repository) => ({ ...repository, hook: repository.start_hook }));
30681
+ if (repositories.length === 0) {
30663
30682
  console.log(import_chalk21.default.yellow("\nNo repositories bound to this environment.\n"));
30664
30683
  return;
30665
30684
  }
30666
30685
  console.log(import_chalk21.default.green(`
30667
- Repository start hooks (${response.repositories.length}):
30686
+ Repository ${kind} hooks (${repositories.length}):
30668
30687
  `));
30669
- for (const repo of response.repositories) {
30688
+ for (const repo of repositories) {
30670
30689
  console.log(import_chalk21.default.white(` ${repo.repository_name} @${repo.default_branch}`));
30671
30690
  if (repo.error) {
30672
30691
  console.log(import_chalk21.default.red(` Error: ${repo.error}`));
30673
- } else if (repo.start_hook) {
30692
+ } else if (repo.hook) {
30674
30693
  console.log(import_chalk21.default.gray(` Source: ${repo.filename ?? "(unknown)"}`));
30675
- console.log(import_chalk21.default.gray(` Commands (${repo.start_hook.commands.length}):`));
30676
- for (const cmd of repo.start_hook.commands) {
30694
+ console.log(import_chalk21.default.gray(` Commands (${repo.hook.commands.length}):`));
30695
+ for (const cmd of repo.hook.commands) {
30677
30696
  console.log(import_chalk21.default.gray(` ${cmd}`));
30678
30697
  }
30679
30698
  } else {
30680
- console.log(import_chalk21.default.gray(` No startHook defined.`));
30699
+ console.log(import_chalk21.default.gray(` No ${kind}Hook defined.`));
30681
30700
  }
30682
30701
  console.log();
30683
30702
  }
30684
30703
  }
30704
+ async function envWarmHookGetCommand(envIdOrName) {
30705
+ return envHookGetCommand(envIdOrName, "warm");
30706
+ }
30707
+ async function envWarmHookSaveCommand(envIdOrName, options) {
30708
+ return envHookSaveCommand(envIdOrName, options, "warm");
30709
+ }
30710
+ async function envWarmHookTestCommand(envIdOrName, options) {
30711
+ return envHookTestCommand(envIdOrName, options, "warm");
30712
+ }
30713
+ async function envWarmHookRepositoryHooksCommand(envIdOrName) {
30714
+ return envHookRepositoryHooksCommand(envIdOrName, "warm");
30715
+ }
30716
+ async function envStartHookGetCommand(envIdOrName) {
30717
+ return envHookGetCommand(envIdOrName, "start");
30718
+ }
30719
+ async function envStartHookSaveCommand(envIdOrName, options) {
30720
+ return envHookSaveCommand(envIdOrName, options, "start");
30721
+ }
30722
+ async function envStartHookTestCommand(envIdOrName, options) {
30723
+ return envHookTestCommand(envIdOrName, options, "start");
30724
+ }
30725
+ async function envStartHookRepositoryHooksCommand(envIdOrName) {
30726
+ return envHookRepositoryHooksCommand(envIdOrName, "start");
30727
+ }
30685
30728
 
30686
30729
  // src/index.ts
30687
30730
  function parseBooleanOption(value) {
@@ -31210,54 +31253,42 @@ envFiles.command("delete <env> <path-or-id>").description("Delete a file by dest
31210
31253
  process.exit(1);
31211
31254
  }
31212
31255
  });
31213
- var envStartHooks = environment.command("start-hooks").description("Manage env-level start hooks (run on every workspace boot, before repo-level start hooks)");
31214
- envStartHooks.command("get <env>").description("Show the active start hook for an environment").action(async (env) => {
31215
- try {
31216
- await envStartHookGetCommand(env);
31217
- } catch (error51) {
31218
- if (error51 instanceof Error) {
31219
- console.error(import_chalk22.default.red(`
31220
- \u2717 ${error51.message}
31221
- `));
31222
- }
31223
- process.exit(1);
31224
- }
31225
- });
31226
- 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) => {
31227
- try {
31228
- await envStartHookSaveCommand(env, options);
31229
- } catch (error51) {
31230
- if (error51 instanceof Error) {
31231
- console.error(import_chalk22.default.red(`
31232
- \u2717 ${error51.message}
31233
- `));
31234
- }
31235
- process.exit(1);
31236
- }
31237
- });
31238
- 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) => {
31239
- try {
31240
- await envStartHookTestCommand(env, options);
31241
- } catch (error51) {
31242
- if (error51 instanceof Error) {
31243
- console.error(import_chalk22.default.red(`
31244
- \u2717 ${error51.message}
31245
- `));
31246
- }
31247
- process.exit(1);
31248
- }
31249
- });
31250
- envStartHooks.command("repository-hooks <env>").description("List per-repo start hooks defined in replicas.json / replicas.yaml").action(async (env) => {
31251
- try {
31252
- await envStartHookRepositoryHooksCommand(env);
31253
- } catch (error51) {
31254
- if (error51 instanceof Error) {
31255
- console.error(import_chalk22.default.red(`
31256
+ function registerEnvironmentHookCommands(parent, config3) {
31257
+ const label = `${config3.kind} hook`;
31258
+ const run = async (command) => {
31259
+ try {
31260
+ await command();
31261
+ } catch (error51) {
31262
+ if (error51 instanceof Error) console.error(import_chalk22.default.red(`
31256
31263
  \u2717 ${error51.message}
31257
31264
  `));
31265
+ process.exit(1);
31258
31266
  }
31259
- process.exit(1);
31260
- }
31267
+ };
31268
+ 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)");
31269
+ hooks.command("get <env>").description(`Show the active ${label} for an environment`).action((env) => run(() => config3.get(env)));
31270
+ 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)));
31271
+ 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)));
31272
+ if (config3.saveTest) {
31273
+ const saveTest = config3.saveTest;
31274
+ 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)));
31275
+ }
31276
+ hooks.command("repository-hooks <env>").description(`List per-repo ${config3.kind} hooks defined in replicas.json / replicas.yaml`).action((env) => run(() => config3.repositoryHooks(env)));
31277
+ }
31278
+ registerEnvironmentHookCommands(environment, {
31279
+ kind: "warm",
31280
+ get: envWarmHookGetCommand,
31281
+ save: envWarmHookSaveCommand,
31282
+ test: envWarmHookTestCommand,
31283
+ saveTest: (env, options) => envWarmHookTestCommand(env, { ...options, save: true }),
31284
+ repositoryHooks: envWarmHookRepositoryHooksCommand
31285
+ });
31286
+ registerEnvironmentHookCommands(environment, {
31287
+ kind: "start",
31288
+ get: envStartHookGetCommand,
31289
+ save: envStartHookSaveCommand,
31290
+ test: envStartHookTestCommand,
31291
+ repositoryHooks: envStartHookRepositoryHooksCommand
31261
31292
  });
31262
31293
  environment.action(async () => {
31263
31294
  try {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "replicas-cli",
3
- "version": "0.2.535",
3
+ "version": "0.2.537",
4
4
  "description": "CLI for managing Replicas workspaces - SSH into cloud dev environments with automatic port forwarding",
5
5
  "main": "dist/index.cjs",
6
6
  "bin": {