chatroom-cli 1.0.72 → 1.0.74

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 +337 -10
  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 || "";
@@ -10598,7 +10707,6 @@ var init_new_feature = () => {};
10598
10707
  var init_classification = __esm(() => {
10599
10708
  init_new_feature();
10600
10709
  });
10601
-
10602
10710
  // ../../services/backend/prompts/base/cli/task-started/main-prompt.ts
10603
10711
  var init_main_prompt = () => {};
10604
10712
 
@@ -10684,15 +10792,15 @@ var init_utils = __esm(() => {
10684
10792
  init_env();
10685
10793
  });
10686
10794
 
10687
- // ../../services/backend/prompts/base/cli/init/context-gaining.ts
10688
- var init_context_gaining = __esm(() => {
10795
+ // ../../services/backend/prompts/base/shared/getting-started-content.ts
10796
+ var init_getting_started_content = __esm(() => {
10689
10797
  init_utils();
10690
10798
  });
10691
10799
 
10692
10800
  // ../../services/backend/prompts/base/cli/index.ts
10693
10801
  var init_cli = __esm(() => {
10694
10802
  init_task_started();
10695
- init_context_gaining();
10803
+ init_getting_started_content();
10696
10804
  });
10697
10805
 
10698
10806
  // ../../services/backend/prompts/base/cli/wait-for-task/command.ts
@@ -11007,12 +11115,35 @@ Classification types: question, new_feature, follow_up`);
11007
11115
  <!-- CONTEXT: Available Actions & Role Instructions`);
11008
11116
  console.log(taskDeliveryPrompt.humanReadable);
11009
11117
  console.log(`-->`);
11118
+ const currentContext = taskDeliveryPrompt.json?.contextWindow?.currentContext;
11010
11119
  const originMessage = taskDeliveryPrompt.json?.contextWindow?.originMessage;
11011
11120
  console.log(`
11012
11121
  ${"=".repeat(60)}`);
11013
11122
  console.log(`\uD83D\uDCCD PINNED - Work on this immediately`);
11014
11123
  console.log(`${"=".repeat(60)}`);
11015
- if (originMessage && originMessage.senderRole.toLowerCase() === "user") {
11124
+ if (currentContext) {
11125
+ console.log(`
11126
+ ## Context`);
11127
+ console.log(`<context>`);
11128
+ console.log(currentContext.content);
11129
+ const messagesSinceContext = currentContext.messagesSinceContext ?? 0;
11130
+ const elapsedHours = currentContext.elapsedHours ?? 0;
11131
+ if (messagesSinceContext >= 10) {
11132
+ console.log(`
11133
+ ⚠️ WARNING: ${messagesSinceContext} messages since this context was set.`);
11134
+ console.log(` Consider updating the context with a summary of recent developments.`);
11135
+ console.log(` Create a new context with:`);
11136
+ console.log(` ${cliEnvPrefix}chatroom context new --chatroom-id=${chatroomId} --role=${role} --content="<summary>"`);
11137
+ }
11138
+ if (elapsedHours >= 24) {
11139
+ const ageDays = Math.floor(elapsedHours / 24);
11140
+ console.log(`
11141
+ ⚠️ WARNING: This context is ${ageDays} day(s) old.`);
11142
+ console.log(` Consider creating a new context with updated summary.`);
11143
+ console.log(` ${cliEnvPrefix}chatroom context new --chatroom-id=${chatroomId} --role=${role} --content="<summary>"`);
11144
+ }
11145
+ console.log(`</context>`);
11146
+ } else if (originMessage && originMessage.senderRole.toLowerCase() === "user") {
11016
11147
  console.log(`
11017
11148
  ## User Message`);
11018
11149
  console.log(`<user-message>`);
@@ -11030,7 +11161,8 @@ ATTACHED BACKLOG (${originMessage.attachedTasks.length})`);
11030
11161
  console.log(`
11031
11162
  ⚠️ WARNING: ${followUpCount} follow-up messages since this pinned message.`);
11032
11163
  console.log(` The user may have moved on to a different topic.`);
11033
- console.log(` Consider asking if this context is still relevant.`);
11164
+ console.log(` Consider creating a context with:`);
11165
+ console.log(` ${cliEnvPrefix}chatroom context new --chatroom-id=${chatroomId} --role=${role} --content="<summary>"`);
11034
11166
  }
11035
11167
  if (originCreatedAt) {
11036
11168
  const ageMs = Date.now() - originCreatedAt;
@@ -11039,7 +11171,8 @@ ATTACHED BACKLOG (${originMessage.attachedTasks.length})`);
11039
11171
  const ageDays = Math.floor(ageHours / 24);
11040
11172
  console.log(`
11041
11173
  ⚠️ WARNING: This pinned message is ${ageDays} day(s) old.`);
11042
- console.log(` The context may be outdated.`);
11174
+ console.log(` Consider creating a context with:`);
11175
+ console.log(` ${cliEnvPrefix}chatroom context new --chatroom-id=${chatroomId} --role=${role} --content="<summary>"`);
11043
11176
  }
11044
11177
  }
11045
11178
  console.log(`</user-message>`);
@@ -12366,7 +12499,10 @@ var init_messages = __esm(() => {
12366
12499
  // src/commands/context.ts
12367
12500
  var exports_context = {};
12368
12501
  __export(exports_context, {
12369
- readContext: () => readContext
12502
+ readContext: () => readContext,
12503
+ newContext: () => newContext,
12504
+ listContexts: () => listContexts,
12505
+ inspectContext: () => inspectContext
12370
12506
  });
12371
12507
  async function readContext(chatroomId, options) {
12372
12508
  const client2 = await getConvexClient();
@@ -12462,6 +12598,136 @@ async function readContext(chatroomId, options) {
12462
12598
  process.exit(1);
12463
12599
  }
12464
12600
  }
12601
+ async function newContext(chatroomId, options) {
12602
+ const client2 = await getConvexClient();
12603
+ const sessionId = getSessionId();
12604
+ if (!sessionId) {
12605
+ console.error(`❌ Not authenticated. Please run: chatroom auth login`);
12606
+ process.exit(1);
12607
+ }
12608
+ if (!chatroomId || typeof chatroomId !== "string" || chatroomId.length < 20 || chatroomId.length > 40) {
12609
+ console.error(`❌ Invalid chatroom ID format: ID must be 20-40 characters (got ${chatroomId?.length || 0})`);
12610
+ process.exit(1);
12611
+ }
12612
+ if (!options.content || options.content.trim().length === 0) {
12613
+ console.error(`❌ Context content cannot be empty`);
12614
+ process.exit(1);
12615
+ }
12616
+ try {
12617
+ const contextId = await client2.mutation(api.contexts.createContext, {
12618
+ sessionId,
12619
+ chatroomId,
12620
+ content: options.content,
12621
+ role: options.role
12622
+ });
12623
+ console.log(`✅ Context created successfully`);
12624
+ console.log(` Context ID: ${contextId}`);
12625
+ console.log(` Created by: ${options.role}`);
12626
+ console.log(`
12627
+ \uD83D\uDCCC This context is now pinned for all agents in this chatroom.`);
12628
+ } catch (err) {
12629
+ console.error(`❌ Failed to create context: ${err.message}`);
12630
+ process.exit(1);
12631
+ }
12632
+ }
12633
+ async function listContexts(chatroomId, options) {
12634
+ const client2 = await getConvexClient();
12635
+ const sessionId = getSessionId();
12636
+ if (!sessionId) {
12637
+ console.error(`❌ Not authenticated. Please run: chatroom auth login`);
12638
+ process.exit(1);
12639
+ }
12640
+ if (!chatroomId || typeof chatroomId !== "string" || chatroomId.length < 20 || chatroomId.length > 40) {
12641
+ console.error(`❌ Invalid chatroom ID format: ID must be 20-40 characters (got ${chatroomId?.length || 0})`);
12642
+ process.exit(1);
12643
+ }
12644
+ try {
12645
+ const contexts = await client2.query(api.contexts.listContexts, {
12646
+ sessionId,
12647
+ chatroomId,
12648
+ limit: options.limit ?? 10
12649
+ });
12650
+ if (contexts.length === 0) {
12651
+ console.log(`
12652
+ \uD83D\uDCED No contexts found for this chatroom`);
12653
+ console.log(`
12654
+ \uD83D\uDCA1 Create a context with:`);
12655
+ console.log(` chatroom context new --chatroom-id=${chatroomId} --role=${options.role} --content="Your context summary"`);
12656
+ return;
12657
+ }
12658
+ console.log(`
12659
+ \uD83D\uDCDA CONTEXTS (${contexts.length} found)`);
12660
+ console.log("═".repeat(60));
12661
+ for (const context of contexts) {
12662
+ const timestamp = new Date(context.createdAt).toLocaleString();
12663
+ console.log(`
12664
+ \uD83D\uDD39 Context ID: ${context._id}`);
12665
+ console.log(` Created by: ${context.createdBy}`);
12666
+ console.log(` Created at: ${timestamp}`);
12667
+ if (context.messageCountAtCreation !== undefined) {
12668
+ console.log(` Messages at creation: ${context.messageCountAtCreation}`);
12669
+ }
12670
+ console.log(` Content:`);
12671
+ const truncatedContent = context.content.length > 200 ? context.content.slice(0, 200) + "..." : context.content;
12672
+ console.log(truncatedContent.split(`
12673
+ `).map((l) => ` ${l}`).join(`
12674
+ `));
12675
+ }
12676
+ console.log(`
12677
+ ` + "═".repeat(60));
12678
+ } catch (err) {
12679
+ console.error(`❌ Failed to list contexts: ${err.message}`);
12680
+ process.exit(1);
12681
+ }
12682
+ }
12683
+ async function inspectContext(chatroomId, options) {
12684
+ const client2 = await getConvexClient();
12685
+ const sessionId = getSessionId();
12686
+ if (!sessionId) {
12687
+ console.error(`❌ Not authenticated. Please run: chatroom auth login`);
12688
+ process.exit(1);
12689
+ }
12690
+ try {
12691
+ const context = await client2.query(api.contexts.getContext, {
12692
+ sessionId,
12693
+ contextId: options.contextId
12694
+ });
12695
+ console.log(`
12696
+ \uD83D\uDCCB CONTEXT DETAILS`);
12697
+ console.log("═".repeat(60));
12698
+ console.log(`
12699
+ \uD83D\uDD39 Context ID: ${context._id}`);
12700
+ console.log(` Created by: ${context.createdBy}`);
12701
+ console.log(` Created at: ${new Date(context.createdAt).toLocaleString()}`);
12702
+ console.log(`
12703
+ \uD83D\uDCCA Staleness:`);
12704
+ console.log(` Messages since context: ${context.messagesSinceContext}`);
12705
+ console.log(` Time elapsed: ${context.elapsedHours.toFixed(1)} hours`);
12706
+ if (context.messagesSinceContext >= 10) {
12707
+ console.log(`
12708
+ ⚠️ Many messages since this context was created.`);
12709
+ console.log(` Consider creating a new context with an updated summary.`);
12710
+ }
12711
+ if (context.elapsedHours >= 24) {
12712
+ console.log(`
12713
+ ⚠️ This context is over 24 hours old.`);
12714
+ console.log(` Consider creating a new context with an updated summary.`);
12715
+ }
12716
+ console.log(`
12717
+ \uD83D\uDCDD Content:`);
12718
+ console.log("─".repeat(60));
12719
+ console.log(context.content);
12720
+ console.log("─".repeat(60));
12721
+ console.log(`
12722
+ \uD83D\uDCA1 To create a new context:`);
12723
+ console.log(` chatroom context new --chatroom-id=${chatroomId} --role=${options.role} --content="Your updated summary"`);
12724
+ console.log(`
12725
+ ` + "═".repeat(60));
12726
+ } catch (err) {
12727
+ console.error(`❌ Failed to inspect context: ${err.message}`);
12728
+ process.exit(1);
12729
+ }
12730
+ }
12465
12731
  var init_context = __esm(() => {
12466
12732
  init_api3();
12467
12733
  init_storage();
@@ -13302,7 +13568,23 @@ Listening for commands...`);
13302
13568
  }, async (result) => {
13303
13569
  if (!result.commands || result.commands.length === 0)
13304
13570
  return;
13305
- const parsed = result.commands.map(parseMachineCommand).filter((c) => c !== null);
13571
+ const parsed = [];
13572
+ for (const raw of result.commands) {
13573
+ const command = parseMachineCommand(raw);
13574
+ if (command !== null) {
13575
+ parsed.push(command);
13576
+ } else {
13577
+ try {
13578
+ await ctx.client.mutation(api.machines.ackCommand, {
13579
+ sessionId: ctx.sessionId,
13580
+ commandId: raw._id,
13581
+ status: "failed",
13582
+ result: `Invalid command: type="${raw.type}" missing required payload fields`
13583
+ });
13584
+ console.warn(`[${formatTimestamp()}] ⚠️ Acked invalid command ${raw._id} (type=${raw.type}) as failed`);
13585
+ } catch {}
13586
+ }
13587
+ }
13306
13588
  enqueueCommands(parsed);
13307
13589
  await drainQueue();
13308
13590
  });
@@ -13835,6 +14117,18 @@ program2.command("update").description("Update the CLI to the latest version").a
13835
14117
  const { update: update2 } = await Promise.resolve().then(() => (init_update(), exports_update));
13836
14118
  await update2();
13837
14119
  });
14120
+ 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) => {
14121
+ await maybeRequireAuth();
14122
+ if (options.type !== "remote" && options.type !== "custom") {
14123
+ console.error(`❌ Invalid agent type: "${options.type}". Must be "remote" or "custom".`);
14124
+ process.exit(1);
14125
+ }
14126
+ const { registerAgent: registerAgent2 } = await Promise.resolve().then(() => (init_register_agent(), exports_register_agent));
14127
+ await registerAgent2(options.chatroomId, {
14128
+ role: options.role,
14129
+ type: options.type
14130
+ });
14131
+ });
13838
14132
  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) => {
13839
14133
  await maybeRequireAuth();
13840
14134
  const { waitForTask: waitForTask2, parseDuration: parseDuration2 } = await Promise.resolve().then(() => (init_wait_for_task(), exports_wait_for_task));
@@ -14057,12 +14351,45 @@ messagesCommand.command("list").description("List messages by sender role or sin
14057
14351
  });
14058
14352
  }
14059
14353
  });
14060
- var contextCommand = program2.command("context").description("Get chatroom context and state");
14354
+ var contextCommand = program2.command("context").description("Manage chatroom context and state (explicit context management)");
14061
14355
  contextCommand.command("read").description("Read context for your role (conversation history, tasks, status)").requiredOption("--chatroom-id <id>", "Chatroom identifier").requiredOption("--role <role>", "Your role").action(async (options) => {
14062
14356
  await maybeRequireAuth();
14063
14357
  const { readContext: readContext2 } = await Promise.resolve().then(() => (init_context(), exports_context));
14064
14358
  await readContext2(options.chatroomId, options);
14065
14359
  });
14360
+ contextCommand.command("new").description("Create a new context and pin it for all agents").requiredOption("--chatroom-id <id>", "Chatroom identifier").requiredOption("--role <role>", "Your role (creator of the context)").option("--content <content>", "Context summary/description (alternative: provide via stdin/heredoc)").action(async (options) => {
14361
+ await maybeRequireAuth();
14362
+ let content;
14363
+ if (options.content && options.content.trim().length > 0) {
14364
+ content = options.content.trim();
14365
+ } else {
14366
+ const stdinContent = await readStdin();
14367
+ if (!stdinContent.trim()) {
14368
+ console.error("❌ Context content cannot be empty.");
14369
+ console.error(' Provide content via --content="..." or stdin (heredoc):');
14370
+ console.error(" chatroom context new --chatroom-id=<id> --role=<role> << 'EOF'");
14371
+ console.error(" Your context summary here");
14372
+ console.error(" EOF");
14373
+ process.exit(1);
14374
+ }
14375
+ content = stdinContent.trim();
14376
+ }
14377
+ const { newContext: newContext2 } = await Promise.resolve().then(() => (init_context(), exports_context));
14378
+ await newContext2(options.chatroomId, { ...options, content });
14379
+ });
14380
+ contextCommand.command("list").description("List recent contexts for a chatroom").requiredOption("--chatroom-id <id>", "Chatroom identifier").requiredOption("--role <role>", "Your role").option("--limit <n>", "Maximum number of contexts to show (default: 10)").action(async (options) => {
14381
+ await maybeRequireAuth();
14382
+ const { listContexts: listContexts2 } = await Promise.resolve().then(() => (init_context(), exports_context));
14383
+ await listContexts2(options.chatroomId, {
14384
+ role: options.role,
14385
+ limit: options.limit ? parseInt(options.limit, 10) : 10
14386
+ });
14387
+ });
14388
+ contextCommand.command("inspect").description("View a specific context with staleness information").requiredOption("--chatroom-id <id>", "Chatroom identifier").requiredOption("--role <role>", "Your role").requiredOption("--context-id <contextId>", "Context ID to inspect").action(async (options) => {
14389
+ await maybeRequireAuth();
14390
+ const { inspectContext: inspectContext2 } = await Promise.resolve().then(() => (init_context(), exports_context));
14391
+ await inspectContext2(options.chatroomId, options);
14392
+ });
14066
14393
  var guidelinesCommand = program2.command("guidelines").description("View review guidelines by type");
14067
14394
  guidelinesCommand.command("view").description("View guidelines for a specific review type").requiredOption("--type <type>", "Guideline type (coding|security|design|performance|all)").action(async (options) => {
14068
14395
  await maybeRequireAuth();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "chatroom-cli",
3
- "version": "1.0.72",
3
+ "version": "1.0.74",
4
4
  "description": "CLI for multi-agent chatroom collaboration",
5
5
  "type": "module",
6
6
  "bin": {