chatroom-cli 1.55.2 → 1.55.4

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.js CHANGED
@@ -76248,6 +76248,9 @@ To reconnect, run:`);
76248
76248
  case "superseded":
76249
76249
  this.handleSuperseded();
76250
76250
  return;
76251
+ case "connection_closed":
76252
+ await this.handleConnectionClosed(response);
76253
+ return;
76251
76254
  case "grace_period":
76252
76255
  this.handleGracePeriod(response);
76253
76256
  return;
@@ -76265,6 +76268,18 @@ To reconnect, run:`);
76265
76268
  handleSuperseded() {
76266
76269
  this.logAndExit(0, "superseded", "Another get-next-task process started for this role.", `Impact: This process is being replaced by the newer connection.
76267
76270
  ` + "Action: This is expected if you started a new get-next-task session.");
76271
+ }
76272
+ async handleConnectionClosed(response) {
76273
+ try {
76274
+ await this.client.mutation(api.connections.confirmConnectionClosed, {
76275
+ sessionId: this.sessionId,
76276
+ chatroomId: this.chatroomId,
76277
+ role: this.role,
76278
+ connectionId: this.connectionId
76279
+ });
76280
+ } catch {}
76281
+ this.logAndExit(0, "connection_closed", `This get-next-task connection was closed by request (${response.reason}).`, `Impact: This connection has been terminated (superseded or explicitly closed).
76282
+ ` + "Action: This is expected. Reconnect only if you intend to resume listening for tasks.");
76268
76283
  }
76269
76284
  handleGracePeriod(response) {
76270
76285
  const remainingSec = Math.ceil(response.remainingMs / 1000);
@@ -76427,6 +76442,7 @@ async function getNextTask(chatroomId, options) {
76427
76442
  process.exit(1);
76428
76443
  }
76429
76444
  const connectionId = `${Date.now()}-${Math.random().toString(36).substring(2, 9)}`;
76445
+ const machineId = await getMachineId() ?? undefined;
76430
76446
  let participantAgentType;
76431
76447
  try {
76432
76448
  const teamConfigs = await client4.query(api.machines.getTeamAgentConfigs, {
@@ -76442,6 +76458,7 @@ async function getNextTask(chatroomId, options) {
76442
76458
  role,
76443
76459
  action: "get-next-task:connecting",
76444
76460
  connectionId,
76461
+ machineId,
76445
76462
  agentType: participantAgentType
76446
76463
  });
76447
76464
  const connectionTime = new Date().toISOString().replace("T", " ").substring(0, 19);
@@ -76500,6 +76517,7 @@ var init_get_next_task = __esm(() => {
76500
76517
  init_api3();
76501
76518
  init_storage();
76502
76519
  init_client2();
76520
+ init_machine();
76503
76521
  init_error_formatting();
76504
76522
  init_session();
76505
76523
  });
@@ -77428,17 +77446,6 @@ ${error instanceof Error ? error.message : String(error)}`);
77428
77446
  }
77429
77447
  console.error(`
77430
77448
  \uD83D\uDCA1 Check your team's workflow in the system prompt for valid handoff paths.`);
77431
- } else if (result.error.code === "WORKFLOW_REQUIRED") {
77432
- console.error("");
77433
- console.error("All tasks delegated to builder must use a workflow.");
77434
- console.error("Create one before handing off:");
77435
- console.error("");
77436
- console.error(" 1. Activate the workflow skill:");
77437
- console.error(` ${cliEnvPrefix}chatroom skill activate workflow --chatroom-id=${chatroomId} --role=${role}`);
77438
- console.error("");
77439
- console.error(" 2. Create a workflow:");
77440
- console.error(` ${cliEnvPrefix}chatroom workflow create --chatroom-id=${chatroomId} --role=${role} ...`);
77441
- console.error("");
77442
77449
  } else if (result.error.suggestedTarget) {
77443
77450
  console.error(`
77444
77451
  \uD83D\uDCA1 Try this instead:`);
@@ -79890,11 +79897,12 @@ var init_featureFlags = __esm(() => {
79890
79897
  });
79891
79898
 
79892
79899
  // ../../services/backend/config/reliability.ts
79893
- var DAEMON_HEARTBEAT_INTERVAL_MS = 30000, AGENT_REQUEST_DEADLINE_MS = 120000, OBSERVATION_TTL_MS = 60000, OBSERVED_FULL_PUSH_INTERVAL_MS, OBSERVED_SAFETY_POLL_MS = 30000, WORKSPACE_RECENCY_WINDOW_MS, WORKSPACE_LIST_RECONCILE_MS;
79900
+ var DAEMON_HEARTBEAT_INTERVAL_MS = 30000, AGENT_REQUEST_DEADLINE_MS = 120000, OBSERVATION_TTL_MS = 60000, OBSERVED_FULL_PUSH_INTERVAL_MS, OBSERVED_SAFETY_POLL_MS = 30000, WORKSPACE_RECENCY_WINDOW_MS, WORKSPACE_LIST_RECONCILE_MS, CONNECTION_CLOSE_REQUEST_TTL_MS;
79894
79901
  var init_reliability = __esm(() => {
79895
79902
  OBSERVED_FULL_PUSH_INTERVAL_MS = 5 * 60000;
79896
79903
  WORKSPACE_RECENCY_WINDOW_MS = 7 * 24 * 60 * 60 * 1000;
79897
79904
  WORKSPACE_LIST_RECONCILE_MS = 60 * 60 * 1000;
79905
+ CONNECTION_CLOSE_REQUEST_TTL_MS = 10 * 60000;
79898
79906
  });
79899
79907
 
79900
79908
  // src/events/daemon/agent/on-request-start-agent.ts
@@ -85040,11 +85048,13 @@ var init_file_content_subscription = __esm(() => {
85040
85048
 
85041
85049
  // src/infrastructure/services/workspace/file-tree-scanner.ts
85042
85050
  import { exec as exec6 } from "node:child_process";
85051
+ import { promises as fsPromises } from "node:fs";
85052
+ import path3 from "node:path";
85043
85053
  import { promisify as promisify5 } from "node:util";
85044
85054
  async function scanFileTree(rootDir, options) {
85045
85055
  const maxEntries = options?.maxEntries ?? DEFAULT_MAX_ENTRIES;
85046
85056
  const scannedAt = Date.now();
85047
- const filePaths = await getGitFiles(rootDir);
85057
+ const filePaths = await isGitRepo2(rootDir) ? await getGitFiles(rootDir) : await walkFsFallback(rootDir, maxEntries, FS_FALLBACK_MAX_SUBTREE_BYTES);
85048
85058
  const filteredPaths = filePaths.filter((p) => !isExcluded(p) && !matchesExcludePattern(p));
85049
85059
  const entries2 = buildEntries(filteredPaths, rootDir, maxEntries);
85050
85060
  return {
@@ -85053,6 +85063,70 @@ async function scanFileTree(rootDir, options) {
85053
85063
  rootDir
85054
85064
  };
85055
85065
  }
85066
+ async function isGitRepo2(rootDir) {
85067
+ try {
85068
+ const { stdout } = await execAsync4("git rev-parse --is-inside-work-tree", {
85069
+ cwd: rootDir,
85070
+ env: { ...process.env, GIT_TERMINAL_PROMPT: "0", GIT_PAGER: "cat", NO_COLOR: "1" },
85071
+ maxBuffer: 1024 * 1024
85072
+ });
85073
+ return stdout.trim() === "true";
85074
+ } catch {
85075
+ return false;
85076
+ }
85077
+ }
85078
+ async function walkFsFallback(rootDir, maxEntries, maxSubtreeBytes) {
85079
+ const collected = [];
85080
+ await walkSubtree(rootDir, "", collected, maxEntries, maxSubtreeBytes);
85081
+ return collected;
85082
+ }
85083
+ async function walkSubtree(absRoot, relDir, collected, maxEntries, maxSubtreeBytes) {
85084
+ if (collected.length >= maxEntries)
85085
+ return 0;
85086
+ const absDir = relDir ? path3.join(absRoot, relDir) : absRoot;
85087
+ let dirents;
85088
+ try {
85089
+ dirents = await fsPromises.readdir(absDir, { withFileTypes: true });
85090
+ } catch {
85091
+ return 0;
85092
+ }
85093
+ const staged = [];
85094
+ let subtreeBytes = 0;
85095
+ for (const ent of dirents) {
85096
+ if (collected.length + staged.length >= maxEntries)
85097
+ break;
85098
+ if (ALWAYS_EXCLUDE.has(ent.name))
85099
+ continue;
85100
+ const childRel = relDir ? `${relDir}/${ent.name}` : ent.name;
85101
+ if (ent.isDirectory()) {
85102
+ const subCollected = [];
85103
+ const subSize = await walkSubtree(absRoot, childRel, subCollected, maxEntries - collected.length - staged.length, maxSubtreeBytes);
85104
+ if (subSize === null) {
85105
+ continue;
85106
+ }
85107
+ subtreeBytes += subSize;
85108
+ if (subtreeBytes > maxSubtreeBytes) {
85109
+ return null;
85110
+ }
85111
+ staged.push(...subCollected);
85112
+ } else if (ent.isFile()) {
85113
+ try {
85114
+ const st = await fsPromises.stat(path3.join(absRoot, childRel));
85115
+ subtreeBytes += st.size;
85116
+ if (subtreeBytes > maxSubtreeBytes) {
85117
+ return null;
85118
+ }
85119
+ staged.push(childRel);
85120
+ } catch {}
85121
+ }
85122
+ }
85123
+ for (const p of staged) {
85124
+ if (collected.length >= maxEntries)
85125
+ break;
85126
+ collected.push(p);
85127
+ }
85128
+ return subtreeBytes;
85129
+ }
85056
85130
  async function getGitFiles(rootDir) {
85057
85131
  const env2 = {
85058
85132
  ...process.env,
@@ -85113,9 +85187,10 @@ function buildEntries(filePaths, rootDir, maxEntries) {
85113
85187
  }
85114
85188
  return entries2;
85115
85189
  }
85116
- var execAsync4, DEFAULT_MAX_ENTRIES = 1e4, ALWAYS_EXCLUDE, EXCLUDE_PATTERNS;
85190
+ var execAsync4, DEFAULT_MAX_ENTRIES = 1e4, FS_FALLBACK_MAX_SUBTREE_BYTES, ALWAYS_EXCLUDE, EXCLUDE_PATTERNS;
85117
85191
  var init_file_tree_scanner = __esm(() => {
85118
85192
  execAsync4 = promisify5(exec6);
85193
+ FS_FALLBACK_MAX_SUBTREE_BYTES = 50 * 1024 * 1024;
85119
85194
  ALWAYS_EXCLUDE = new Set([
85120
85195
  "node_modules",
85121
85196
  ".git",
@@ -87872,11 +87947,11 @@ async function installTool(options = {}, deps) {
87872
87947
  const d = deps ?? await createDefaultDeps22();
87873
87948
  const { checkExisting = true } = options;
87874
87949
  const os2 = await import("os");
87875
- const path3 = await import("path");
87950
+ const path4 = await import("path");
87876
87951
  const homeDir = os2.homedir();
87877
- const toolDir = path3.join(homeDir, ".config", "opencode", "tool");
87878
- const toolPath = path3.join(toolDir, "chatroom.ts");
87879
- const handoffToolPath = path3.join(toolDir, "chatroom-handoff.ts");
87952
+ const toolDir = path4.join(homeDir, ".config", "opencode", "tool");
87953
+ const toolPath = path4.join(toolDir, "chatroom.ts");
87954
+ const handoffToolPath = path4.join(toolDir, "chatroom-handoff.ts");
87880
87955
  const toolContent = `import { tool } from "@opencode-ai/plugin";
87881
87956
 
87882
87957
  /**
@@ -88864,4 +88939,4 @@ program2.hook("preAction", async (_thisCommand, actionCommand) => {
88864
88939
  });
88865
88940
  program2.parse();
88866
88941
 
88867
- //# debugId=E81362A1D620F90E64756E2164756E21
88942
+ //# debugId=4112CAEC73861F5764756E2164756E21