replicas-cli 0.3.234 → 0.3.236

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 +28 -4
  2. package/package.json +1 -1
package/dist/index.cjs CHANGED
@@ -15840,6 +15840,9 @@ var init_zod = __esm({
15840
15840
  function isWorkspaceSize(value) {
15841
15841
  return WORKSPACE_SIZES.some((size) => size === value);
15842
15842
  }
15843
+ function trimLogTailCommand(file2, maxBytes, keepBytes) {
15844
+ return `size=$(stat -c %s ${file2} 2>/dev/null || echo 0); [ "$size" -gt ${maxBytes} ] && { fallocate --collapse-range --offset 0 --length $(( (size - ${keepBytes}) / 4096 * 4096 )) ${file2} 2>/dev/null || truncate -s 0 ${file2}; }`;
15845
+ }
15843
15846
  var SANDBOX_LIFECYCLE, SANDBOX_PATHS, WORKSPACE_SIZES, DEFAULT_WORKSPACE_SIZE, INVALID_WORKSPACE_SIZE_ERROR;
15844
15847
  var init_sandbox = __esm({
15845
15848
  "../shared/src/sandbox.ts"() {
@@ -17147,13 +17150,21 @@ var init_pull_requests = __esm({
17147
17150
  });
17148
17151
 
17149
17152
  // ../shared/src/routes/mothership.ts
17150
- var SUBAGENT_SERVICE_TIERS, mothershipSubagentSettingsSchema, DEPLOYED_SHOWN_MS, MOTHERSHIP_SHIPPING_LOOKBACK_MS;
17153
+ var mothershipLinearRuleSchema, storedMothershipLinearRuleSchema, SUBAGENT_SERVICE_TIERS, mothershipSubagentSettingsSchema, DEPLOYED_SHOWN_MS, MOTHERSHIP_SHIPPING_LOOKBACK_MS;
17151
17154
  var init_mothership = __esm({
17152
17155
  "../shared/src/routes/mothership.ts"() {
17153
17156
  "use strict";
17154
17157
  init_zod();
17155
17158
  init_agent();
17156
17159
  init_pull_requests();
17160
+ mothershipLinearRuleSchema = external_exports.object({
17161
+ team_id: external_exports.string().min(1),
17162
+ current_cycle: external_exports.boolean().optional(),
17163
+ label_id: external_exports.string().min(1).optional(),
17164
+ project_id: external_exports.string().min(1).optional(),
17165
+ assignee_id: external_exports.string().min(1).optional()
17166
+ }).strict();
17167
+ storedMothershipLinearRuleSchema = mothershipLinearRuleSchema.extend({ linked_at: external_exports.string() });
17157
17168
  SUBAGENT_SERVICE_TIERS = ["default", "fast", "ultrafast"];
17158
17169
  mothershipSubagentSettingsSchema = external_exports.object({
17159
17170
  coding_agent: external_exports.enum(VALID_AGENT_PROVIDERS),
@@ -31415,7 +31426,7 @@ var CLI_VERSION;
31415
31426
  var init_cli_version = __esm({
31416
31427
  "../shared/src/cli-version.ts"() {
31417
31428
  "use strict";
31418
- CLI_VERSION = "0.3.234";
31429
+ CLI_VERSION = "0.3.236";
31419
31430
  }
31420
31431
  });
31421
31432
 
@@ -39056,10 +39067,17 @@ async function killServiceGroup(pid) {
39056
39067
  }
39057
39068
  }
39058
39069
  function tailLog(logFile, lines) {
39070
+ let fd;
39059
39071
  try {
39060
- return tailLines((0, import_node_fs5.readFileSync)(logFile, "utf-8"), lines);
39072
+ fd = (0, import_node_fs5.openSync)(logFile, "r");
39073
+ const { size } = (0, import_node_fs5.fstatSync)(fd);
39074
+ const buffer = Buffer.alloc(Math.min(size, LOG_KEEP_BYTES));
39075
+ const read = (0, import_node_fs5.readSync)(fd, buffer, 0, buffer.length, size - buffer.length);
39076
+ return tailLines(buffer.toString("utf-8", 0, read), lines);
39061
39077
  } catch {
39062
39078
  return "";
39079
+ } finally {
39080
+ if (fd !== void 0) (0, import_node_fs5.closeSync)(fd);
39063
39081
  }
39064
39082
  }
39065
39083
  async function serviceStartCommand(name, commandParts, options) {
@@ -39093,6 +39111,7 @@ async function serviceStartCommand(name, commandParts, options) {
39093
39111
  throw new Error("Failed to spawn service process");
39094
39112
  }
39095
39113
  child.unref();
39114
+ (0, import_node_child_process3.spawn)("bash", ["-c", LOG_TRIM_LOOP, "replicas-service-log-trim", logFile, String(child.pid)], { detached: true, stdio: "ignore" }).unref();
39096
39115
  const state = {
39097
39116
  name,
39098
39117
  command,
@@ -39162,7 +39181,7 @@ async function serviceLogsCommand(name, options) {
39162
39181
  console.log(logs || "(no log output yet)");
39163
39182
  });
39164
39183
  }
39165
- var import_chalk31, import_node_child_process3, import_node_fs5, import_node_os3, import_node_path4, SERVICES_DIR, NAME_PATTERN;
39184
+ var import_chalk31, import_node_child_process3, import_node_fs5, import_node_os3, import_node_path4, SERVICES_DIR, NAME_PATTERN, LOG_KEEP_BYTES, LOG_TRIM_LOOP;
39166
39185
  var init_service = __esm({
39167
39186
  "src/commands/service.ts"() {
39168
39187
  "use strict";
@@ -39171,9 +39190,14 @@ var init_service = __esm({
39171
39190
  import_node_fs5 = require("fs");
39172
39191
  import_node_os3 = require("os");
39173
39192
  import_node_path4 = require("path");
39193
+ init_src();
39174
39194
  init_output();
39175
39195
  SERVICES_DIR = (0, import_node_path4.join)((0, import_node_os3.homedir)(), ".replicas", "services");
39176
39196
  NAME_PATTERN = /^[a-zA-Z0-9][a-zA-Z0-9._-]*$/;
39197
+ LOG_KEEP_BYTES = 5 * 1024 * 1024;
39198
+ LOG_TRIM_LOOP = `trim() { ${trimLogTailCommand('"$1"', 10 * 1024 * 1024, LOG_KEEP_BYTES)}; }
39199
+ while kill -0 -"$2" 2>/dev/null; do trim "$1"; sleep 1; done
39200
+ trim "$1"`;
39177
39201
  }
39178
39202
  });
39179
39203
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "replicas-cli",
3
- "version": "0.3.234",
3
+ "version": "0.3.236",
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": {