chatroom-cli 1.0.71 → 1.0.73

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.js +211 -4
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -10568,6 +10568,115 @@ var init_update = __esm(() => {
10568
10568
  execAsync = promisify(exec);
10569
10569
  log = console.log.bind(console);
10570
10570
  });
10571
+
10572
+ // src/commands/register-agent.ts
10573
+ var exports_register_agent = {};
10574
+ __export(exports_register_agent, {
10575
+ registerAgent: () => registerAgent
10576
+ });
10577
+ async function registerAgent(chatroomId, options) {
10578
+ const client2 = await getConvexClient();
10579
+ const { role, type } = options;
10580
+ const sessionId = getSessionId();
10581
+ if (!sessionId) {
10582
+ const otherUrls = getOtherSessionUrls();
10583
+ const currentUrl = getConvexUrl();
10584
+ console.error(`❌ Not authenticated for: ${currentUrl}`);
10585
+ if (otherUrls.length > 0) {
10586
+ console.error(`
10587
+ \uD83D\uDCA1 You have sessions for other environments:`);
10588
+ for (const url of otherUrls) {
10589
+ console.error(` • ${url}`);
10590
+ }
10591
+ console.error(`
10592
+ To use a different environment, set CHATROOM_CONVEX_URL:`);
10593
+ console.error(` CHATROOM_CONVEX_URL=${otherUrls[0]} chatroom register-agent ...`);
10594
+ console.error(`
10595
+ Or to authenticate for the current environment:`);
10596
+ }
10597
+ console.error(` chatroom auth login`);
10598
+ process.exit(1);
10599
+ }
10600
+ if (!chatroomId || typeof chatroomId !== "string" || chatroomId.length < 20 || chatroomId.length > 40) {
10601
+ console.error(`❌ Invalid chatroom ID format: ID must be 20-40 characters (got ${chatroomId?.length || 0})`);
10602
+ process.exit(1);
10603
+ }
10604
+ if (!/^[a-zA-Z0-9_]+$/.test(chatroomId)) {
10605
+ console.error(`❌ Invalid chatroom ID format: ID must contain only alphanumeric characters and underscores`);
10606
+ process.exit(1);
10607
+ }
10608
+ const chatroom = await client2.query(api.chatrooms.get, {
10609
+ sessionId,
10610
+ chatroomId
10611
+ });
10612
+ if (!chatroom) {
10613
+ console.error(`❌ Chatroom ${chatroomId} not found or access denied`);
10614
+ process.exit(1);
10615
+ }
10616
+ if (type === "remote") {
10617
+ try {
10618
+ const machineInfo = ensureMachineRegistered();
10619
+ let availableModels = [];
10620
+ try {
10621
+ const registry = getDriverRegistry();
10622
+ for (const driver of registry.all()) {
10623
+ if (driver.capabilities.dynamicModelDiscovery) {
10624
+ const models = await driver.listModels();
10625
+ availableModels = availableModels.concat(models);
10626
+ }
10627
+ }
10628
+ } catch {}
10629
+ await client2.mutation(api.machines.register, {
10630
+ sessionId,
10631
+ machineId: machineInfo.machineId,
10632
+ hostname: machineInfo.hostname,
10633
+ os: machineInfo.os,
10634
+ availableHarnesses: machineInfo.availableHarnesses,
10635
+ harnessVersions: machineInfo.harnessVersions,
10636
+ availableModels
10637
+ });
10638
+ const agentHarness = machineInfo.availableHarnesses.length > 0 ? machineInfo.availableHarnesses[0] : undefined;
10639
+ await client2.mutation(api.machines.saveTeamAgentConfig, {
10640
+ sessionId,
10641
+ chatroomId,
10642
+ role,
10643
+ type: "remote",
10644
+ machineId: machineInfo.machineId,
10645
+ agentHarness,
10646
+ workingDir: process.cwd()
10647
+ });
10648
+ console.log(`✅ Registered as remote agent for role "${role}"`);
10649
+ console.log(` Machine: ${machineInfo.hostname} (${machineInfo.machineId})`);
10650
+ console.log(` Working directory: ${process.cwd()}`);
10651
+ if (agentHarness) {
10652
+ console.log(` Agent harness: ${agentHarness}`);
10653
+ }
10654
+ } catch (error) {
10655
+ console.error(`❌ Registration failed: ${error.message}`);
10656
+ process.exit(1);
10657
+ }
10658
+ } else {
10659
+ try {
10660
+ await client2.mutation(api.machines.saveTeamAgentConfig, {
10661
+ sessionId,
10662
+ chatroomId,
10663
+ role,
10664
+ type: "custom"
10665
+ });
10666
+ console.log(`✅ Registered as custom agent for role "${role}"`);
10667
+ } catch (error) {
10668
+ console.error(`❌ Registration failed: ${error.message}`);
10669
+ process.exit(1);
10670
+ }
10671
+ }
10672
+ }
10673
+ var init_register_agent = __esm(() => {
10674
+ init_api3();
10675
+ init_agent_drivers();
10676
+ init_storage();
10677
+ init_client2();
10678
+ init_machine();
10679
+ });
10571
10680
  // ../../services/backend/prompts/base/cli/task-started/command.ts
10572
10681
  function taskStartedCommand(params) {
10573
10682
  const prefix = params.cliEnvPrefix || "";
@@ -10684,15 +10793,15 @@ var init_utils = __esm(() => {
10684
10793
  init_env();
10685
10794
  });
10686
10795
 
10687
- // ../../services/backend/prompts/base/cli/init/context-gaining.ts
10688
- var init_context_gaining = __esm(() => {
10796
+ // ../../services/backend/prompts/base/shared/getting-started-content.ts
10797
+ var init_getting_started_content = __esm(() => {
10689
10798
  init_utils();
10690
10799
  });
10691
10800
 
10692
10801
  // ../../services/backend/prompts/base/cli/index.ts
10693
10802
  var init_cli = __esm(() => {
10694
10803
  init_task_started();
10695
- init_context_gaining();
10804
+ init_getting_started_content();
10696
10805
  });
10697
10806
 
10698
10807
  // ../../services/backend/prompts/base/cli/wait-for-task/command.ts
@@ -11749,6 +11858,7 @@ var init_report_progress = __esm(() => {
11749
11858
  // src/commands/backlog.ts
11750
11859
  var exports_backlog = {};
11751
11860
  __export(exports_backlog, {
11861
+ scoreBacklog: () => scoreBacklog,
11752
11862
  resetBacklog: () => resetBacklog,
11753
11863
  reopenBacklog: () => reopenBacklog,
11754
11864
  patchBacklog: () => patchBacklog,
@@ -12047,6 +12157,70 @@ async function patchBacklog(chatroomId, options) {
12047
12157
  process.exit(1);
12048
12158
  }
12049
12159
  }
12160
+ async function scoreBacklog(chatroomId, options) {
12161
+ const client2 = await getConvexClient();
12162
+ const sessionId = getSessionId();
12163
+ if (!sessionId) {
12164
+ console.error(`❌ Not authenticated. Please run: chatroom auth login`);
12165
+ process.exit(1);
12166
+ }
12167
+ if (!chatroomId || typeof chatroomId !== "string" || chatroomId.length < 20 || chatroomId.length > 40) {
12168
+ console.error(`❌ Invalid chatroom ID format: ID must be 20-40 characters (got ${chatroomId?.length || 0})`);
12169
+ process.exit(1);
12170
+ }
12171
+ if (!options.taskId || options.taskId.trim().length === 0) {
12172
+ console.error(`❌ Task ID is required`);
12173
+ process.exit(1);
12174
+ }
12175
+ if (options.complexity === undefined && options.value === undefined && options.priority === undefined) {
12176
+ console.error(`❌ At least one of --complexity, --value, or --priority is required`);
12177
+ console.error(` Example: chatroom backlog score --task-id=... --complexity=medium --value=high`);
12178
+ process.exit(1);
12179
+ }
12180
+ const validComplexity = ["low", "medium", "high"];
12181
+ if (options.complexity !== undefined && !validComplexity.includes(options.complexity)) {
12182
+ console.error(`❌ Invalid complexity: ${options.complexity}. Must be one of: ${validComplexity.join(", ")}`);
12183
+ process.exit(1);
12184
+ }
12185
+ const validValue = ["low", "medium", "high"];
12186
+ if (options.value !== undefined && !validValue.includes(options.value)) {
12187
+ console.error(`❌ Invalid value: ${options.value}. Must be one of: ${validValue.join(", ")}`);
12188
+ process.exit(1);
12189
+ }
12190
+ let priorityNum;
12191
+ if (options.priority !== undefined) {
12192
+ priorityNum = parseInt(options.priority, 10);
12193
+ if (isNaN(priorityNum)) {
12194
+ console.error(`❌ Invalid priority: ${options.priority}. Must be a number.`);
12195
+ process.exit(1);
12196
+ }
12197
+ }
12198
+ try {
12199
+ await client2.mutation(api.tasks.patchTask, {
12200
+ sessionId,
12201
+ taskId: options.taskId,
12202
+ complexity: options.complexity,
12203
+ value: options.value,
12204
+ priority: priorityNum
12205
+ });
12206
+ console.log("");
12207
+ console.log("✅ Task scored");
12208
+ console.log(` ID: ${options.taskId}`);
12209
+ if (options.complexity !== undefined) {
12210
+ console.log(` Complexity: ${options.complexity}`);
12211
+ }
12212
+ if (options.value !== undefined) {
12213
+ console.log(` Value: ${options.value}`);
12214
+ }
12215
+ if (priorityNum !== undefined) {
12216
+ console.log(` Priority: ${priorityNum}`);
12217
+ }
12218
+ console.log("");
12219
+ } catch (error) {
12220
+ console.error(`❌ Failed to score task: ${error.message}`);
12221
+ process.exit(1);
12222
+ }
12223
+ }
12050
12224
  async function markForReviewBacklog(chatroomId, options) {
12051
12225
  const client2 = await getConvexClient();
12052
12226
  const sessionId = getSessionId();
@@ -13237,7 +13411,23 @@ Listening for commands...`);
13237
13411
  }, async (result) => {
13238
13412
  if (!result.commands || result.commands.length === 0)
13239
13413
  return;
13240
- const parsed = result.commands.map(parseMachineCommand).filter((c) => c !== null);
13414
+ const parsed = [];
13415
+ for (const raw of result.commands) {
13416
+ const command = parseMachineCommand(raw);
13417
+ if (command !== null) {
13418
+ parsed.push(command);
13419
+ } else {
13420
+ try {
13421
+ await ctx.client.mutation(api.machines.ackCommand, {
13422
+ sessionId: ctx.sessionId,
13423
+ commandId: raw._id,
13424
+ status: "failed",
13425
+ result: `Invalid command: type="${raw.type}" missing required payload fields`
13426
+ });
13427
+ console.warn(`[${formatTimestamp()}] ⚠️ Acked invalid command ${raw._id} (type=${raw.type}) as failed`);
13428
+ } catch {}
13429
+ }
13430
+ }
13241
13431
  enqueueCommands(parsed);
13242
13432
  await drainQueue();
13243
13433
  });
@@ -13770,6 +13960,18 @@ program2.command("update").description("Update the CLI to the latest version").a
13770
13960
  const { update: update2 } = await Promise.resolve().then(() => (init_update(), exports_update));
13771
13961
  await update2();
13772
13962
  });
13963
+ program2.command("register-agent").description("Register agent type for a chatroom role").requiredOption("--chatroom-id <id>", "Chatroom identifier").requiredOption("--role <role>", "Role to register as (e.g., builder, reviewer)").requiredOption("--type <type>", "Agent type: remote or custom").action(async (options) => {
13964
+ await maybeRequireAuth();
13965
+ if (options.type !== "remote" && options.type !== "custom") {
13966
+ console.error(`❌ Invalid agent type: "${options.type}". Must be "remote" or "custom".`);
13967
+ process.exit(1);
13968
+ }
13969
+ const { registerAgent: registerAgent2 } = await Promise.resolve().then(() => (init_register_agent(), exports_register_agent));
13970
+ await registerAgent2(options.chatroomId, {
13971
+ role: options.role,
13972
+ type: options.type
13973
+ });
13974
+ });
13773
13975
  program2.command("wait-for-task").description("Join a chatroom and wait for tasks").requiredOption("--chatroom-id <id>", "Chatroom identifier").requiredOption("--role <role>", "Role to join as (e.g., builder, reviewer)").option("--timeout <ms>", "Optional timeout in milliseconds (deprecated, use --duration)").option("--duration <duration>", 'How long to wait (e.g., "1m", "5m", "30s")').action(async (options) => {
13774
13976
  await maybeRequireAuth();
13775
13977
  const { waitForTask: waitForTask2, parseDuration: parseDuration2 } = await Promise.resolve().then(() => (init_wait_for_task(), exports_wait_for_task));
@@ -13949,6 +14151,11 @@ backlogCommand.command("patch-task").description("Update task scoring fields (co
13949
14151
  const { patchBacklog: patchBacklog2 } = await Promise.resolve().then(() => (init_backlog(), exports_backlog));
13950
14152
  await patchBacklog2(options.chatroomId, options);
13951
14153
  });
14154
+ backlogCommand.command("score").description("Score a backlog task by complexity, value, and priority").requiredOption("--chatroom-id <id>", "Chatroom identifier").requiredOption("--role <role>", "Your role").requiredOption("--task-id <taskId>", "Task ID to score").option("--complexity <level>", "Complexity level: low, medium, high").option("--value <level>", "Value level: low, medium, high").option("--priority <n>", "Priority number (higher = more important)").action(async (options) => {
14155
+ await maybeRequireAuth();
14156
+ const { scoreBacklog: scoreBacklog2 } = await Promise.resolve().then(() => (init_backlog(), exports_backlog));
14157
+ await scoreBacklog2(options.chatroomId, options);
14158
+ });
13952
14159
  backlogCommand.command("reset-task").description("Reset a stuck in_progress task back to pending").requiredOption("--chatroom-id <id>", "Chatroom identifier").requiredOption("--role <role>", "Your role").requiredOption("--task-id <taskId>", "Task ID to reset").action(async (options) => {
13953
14160
  await maybeRequireAuth();
13954
14161
  const { resetBacklog: resetBacklog2 } = await Promise.resolve().then(() => (init_backlog(), exports_backlog));
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "chatroom-cli",
3
- "version": "1.0.71",
3
+ "version": "1.0.73",
4
4
  "description": "CLI for multi-agent chatroom collaboration",
5
5
  "type": "module",
6
6
  "bin": {