chatroom-cli 1.37.2 → 1.37.3

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
@@ -11035,7 +11035,13 @@ class CopilotStreamReader {
11035
11035
  }
11036
11036
  var DONE_MARKER = "Done.", SKIP_PREFIXES;
11037
11037
  var init_copilot_stream_reader = __esm(() => {
11038
- SKIP_PREFIXES = ["Total usage est:", "API time spent:", "Total session time:", "Total code changes:", "Breakdown by AI model:"];
11038
+ SKIP_PREFIXES = [
11039
+ "Total usage est:",
11040
+ "API time spent:",
11041
+ "Total session time:",
11042
+ "Total code changes:",
11043
+ "Breakdown by AI model:"
11044
+ ];
11039
11045
  });
11040
11046
 
11041
11047
  // src/infrastructure/services/remote-agents/copilot/copilot-agent-service.ts
@@ -14048,11 +14054,21 @@ function getErrorMessage(error) {
14048
14054
  }
14049
14055
  if (error.data !== null && typeof error.data === "object") {
14050
14056
  const data = error.data;
14051
- return data.message ?? data.code ?? String(error.data);
14057
+ const base = data.message ?? data.code ?? String(error.data);
14058
+ const parts = [base];
14059
+ if (Array.isArray(data.fields) && data.fields.length > 0) {
14060
+ parts.push(` offending fields: ${data.fields.join(", ")}`);
14061
+ }
14062
+ return parts.join(`
14063
+ `);
14052
14064
  }
14053
14065
  return String(error.data);
14054
14066
  }
14055
14067
  if (error instanceof Error) {
14068
+ if (error.message.includes("Server Error")) {
14069
+ return `${error.message}
14070
+ hint: ${SERVER_ERROR_HINT}`;
14071
+ }
14056
14072
  return error.message;
14057
14073
  }
14058
14074
  if (error === null || error === undefined) {
@@ -14060,8 +14076,10 @@ function getErrorMessage(error) {
14060
14076
  }
14061
14077
  return String(error);
14062
14078
  }
14079
+ var SERVER_ERROR_HINT;
14063
14080
  var init_convex_error = __esm(() => {
14064
14081
  init_values();
14082
+ SERVER_ERROR_HINT = "This is a generic server error — likely a backend arg-validator rejection or a CLI/backend version mismatch." + " Verify the CLI and backend are on the same commit (run `pnpm install` and check `git log -1 origin/master`).";
14065
14083
  });
14066
14084
 
14067
14085
  // src/commands/auth-status/index.ts
@@ -53659,18 +53677,171 @@ var init_cli = __esm(() => {
53659
53677
  var BACKEND_ERROR_CODES, FATAL_ERROR_CODES, NON_FATAL_ERROR_CODES;
53660
53678
  var init_errorCodes = __esm(() => {
53661
53679
  BACKEND_ERROR_CODES = {
53662
- PARTICIPANT_NOT_FOUND: "PARTICIPANT_NOT_FOUND",
53663
- CHATROOM_NOT_FOUND: "CHATROOM_NOT_FOUND",
53664
53680
  SESSION_INVALID: "SESSION_INVALID",
53665
- CONTEXT_NO_HANDOFF_SINCE_LAST_CONTEXT: "CONTEXT_NO_HANDOFF_SINCE_LAST_CONTEXT"
53681
+ FEATURE_DISABLED: "FEATURE_DISABLED",
53682
+ NOT_AUTHENTICATED: "NOT_AUTHENTICATED",
53683
+ UNAUTHORIZED: "UNAUTHORIZED",
53684
+ FORBIDDEN: "FORBIDDEN",
53685
+ ACCESS_DENIED: "ACCESS_DENIED",
53686
+ AUTH_FAILED: "AUTH_FAILED",
53687
+ EMAIL_ALREADY_EXISTS: "EMAIL_ALREADY_EXISTS",
53688
+ NO_GOOGLE_ACCOUNT: "NO_GOOGLE_ACCOUNT",
53689
+ GOOGLE_ACCOUNT_IN_USE: "GOOGLE_ACCOUNT_IN_USE",
53690
+ INVALID_USER_TYPE: "INVALID_USER_TYPE",
53691
+ USER_TYPE_MISMATCH: "USER_TYPE_MISMATCH",
53692
+ USER_NOT_FOUND: "USER_NOT_FOUND",
53693
+ OAUTH_ERROR: "OAUTH_ERROR",
53694
+ LOGIN_ERROR: "LOGIN_ERROR",
53695
+ CHATROOM_NOT_FOUND: "CHATROOM_NOT_FOUND",
53696
+ TEAM_REQUIRED: "TEAM_REQUIRED",
53697
+ CONFIGURATION_ERROR: "CONFIGURATION_ERROR",
53698
+ PARTICIPANT_NOT_FOUND: "PARTICIPANT_NOT_FOUND",
53699
+ CONTEXT_NO_HANDOFF_SINCE_LAST_CONTEXT: "CONTEXT_NO_HANDOFF_SINCE_LAST_CONTEXT",
53700
+ CONTEXT_NOT_FOUND: "CONTEXT_NOT_FOUND",
53701
+ CONTEXT_RESTRICTED: "CONTEXT_RESTRICTED",
53702
+ INVALID_ROLE: "INVALID_ROLE",
53703
+ INVALID_CONTENT: "INVALID_CONTENT",
53704
+ MISSING_CLASSIFICATION: "MISSING_CLASSIFICATION",
53705
+ MESSAGE_NOT_CLASSIFIED: "MESSAGE_NOT_CLASSIFIED",
53706
+ VALIDATION_ERROR: "VALIDATION_ERROR",
53707
+ UNKNOWN_PARAM: "UNKNOWN_PARAM",
53708
+ INVALID_CONVERSION: "INVALID_CONVERSION",
53709
+ INVALID_STATE: "INVALID_STATE",
53710
+ INVALID_STDIN_FORMAT: "INVALID_STDIN_FORMAT",
53711
+ MISSING_STDIN: "MISSING_STDIN",
53712
+ MISSING_SPECIFICATION: "MISSING_SPECIFICATION",
53713
+ TASK_NOT_FOUND: "TASK_NOT_FOUND",
53714
+ INVALID_TASK: "INVALID_TASK",
53715
+ QUEUED_MESSAGE_NOT_FOUND: "QUEUED_MESSAGE_NOT_FOUND",
53716
+ INVALID_TASK_STATUS: "INVALID_TASK_STATUS",
53717
+ TASK_INVALID_TRANSITION: "TASK_INVALID_TRANSITION",
53718
+ TASK_MISSING_REQUIRED_FIELD: "TASK_MISSING_REQUIRED_FIELD",
53719
+ TASK_VALIDATION_FAILED: "TASK_VALIDATION_FAILED",
53720
+ BACKLOG_ITEM_NOT_FOUND: "BACKLOG_ITEM_NOT_FOUND",
53721
+ BACKLOG_ITEM_WRONG_CHATROOM: "BACKLOG_ITEM_WRONG_CHATROOM",
53722
+ BACKLOG_INVALID_TRANSITION: "BACKLOG_INVALID_TRANSITION",
53723
+ BACKLOG_MISSING_REQUIRED_FIELD: "BACKLOG_MISSING_REQUIRED_FIELD",
53724
+ BACKLOG_VALIDATION_FAILED: "BACKLOG_VALIDATION_FAILED",
53725
+ CONTENT_EMPTY: "CONTENT_EMPTY",
53726
+ REASON_EMPTY: "REASON_EMPTY",
53727
+ NOT_AUTHORIZED_MACHINE: "NOT_AUTHORIZED_MACHINE",
53728
+ COMMAND_NOT_FOUND: "COMMAND_NOT_FOUND",
53729
+ COMMAND_NOT_DISCOVERED: "COMMAND_NOT_DISCOVERED",
53730
+ RUN_NOT_FOUND: "RUN_NOT_FOUND",
53731
+ RUN_WRONG_MACHINE: "RUN_WRONG_MACHINE",
53732
+ COMMAND_NOT_RUNNING: "COMMAND_NOT_RUNNING",
53733
+ TOO_MANY_COMMANDS: "TOO_MANY_COMMANDS",
53734
+ INVALID_STATE_TRANSITION: "INVALID_STATE_TRANSITION",
53735
+ OUTPUT_CHUNK_TOO_LARGE: "OUTPUT_CHUNK_TOO_LARGE",
53736
+ NOT_FOUND: "NOT_FOUND",
53737
+ INVALID_BOT_TOKEN: "INVALID_BOT_TOKEN",
53738
+ WEBHOOK_REGISTRATION_FAILED: "WEBHOOK_REGISTRATION_FAILED",
53739
+ WEBHOOK_REMOVAL_FAILED: "WEBHOOK_REMOVAL_FAILED",
53740
+ WORKFLOW_REQUIRED: "WORKFLOW_REQUIRED",
53741
+ ALREADY_CONNECTED: "ALREADY_CONNECTED",
53742
+ CONNECT_ERROR: "CONNECT_ERROR",
53743
+ UNSAFE_DISCONNECT: "UNSAFE_DISCONNECT",
53744
+ HANDOFF_RESTRICTED: "HANDOFF_RESTRICTED",
53745
+ CHATROOM_NO_TEAM_ID: "CHATROOM_NO_TEAM_ID",
53746
+ SKILL_NOT_FOUND_OR_DISABLED: "SKILL_NOT_FOUND_OR_DISABLED",
53747
+ MISSING_FEATURE_METADATA: "MISSING_FEATURE_METADATA",
53748
+ COMMAND_NAME_EMPTY: "COMMAND_NAME_EMPTY",
53749
+ SAVED_COMMAND_NOT_FOUND: "SAVED_COMMAND_NOT_FOUND",
53750
+ COMMAND_TYPE_IMMUTABLE: "COMMAND_TYPE_IMMUTABLE",
53751
+ NAME_REQUIRED: "NAME_REQUIRED",
53752
+ ATTENDANCE_NOT_FOUND: "ATTENDANCE_NOT_FOUND",
53753
+ ATTENDANCE_DELETE_UNAUTHORIZED: "ATTENDANCE_DELETE_UNAUTHORIZED",
53754
+ ITEM_NOT_FOUND: "ITEM_NOT_FOUND",
53755
+ INVALID_ITEM: "INVALID_ITEM",
53756
+ INVALID_ITEM_STATUS: "INVALID_ITEM_STATUS",
53757
+ INVALID_MESSAGE: "INVALID_MESSAGE",
53758
+ MESSAGE_NOT_FOUND: "MESSAGE_NOT_FOUND",
53759
+ CONFLICT: "CONFLICT"
53666
53760
  };
53667
53761
  FATAL_ERROR_CODES = [
53668
53762
  BACKEND_ERROR_CODES.PARTICIPANT_NOT_FOUND,
53669
53763
  BACKEND_ERROR_CODES.CHATROOM_NOT_FOUND,
53670
- BACKEND_ERROR_CODES.SESSION_INVALID
53764
+ BACKEND_ERROR_CODES.SESSION_INVALID,
53765
+ BACKEND_ERROR_CODES.NOT_AUTHENTICATED,
53766
+ BACKEND_ERROR_CODES.UNAUTHORIZED,
53767
+ BACKEND_ERROR_CODES.FORBIDDEN,
53768
+ BACKEND_ERROR_CODES.ACCESS_DENIED,
53769
+ BACKEND_ERROR_CODES.AUTH_FAILED,
53770
+ BACKEND_ERROR_CODES.NO_GOOGLE_ACCOUNT,
53771
+ BACKEND_ERROR_CODES.GOOGLE_ACCOUNT_IN_USE,
53772
+ BACKEND_ERROR_CODES.USER_TYPE_MISMATCH,
53773
+ BACKEND_ERROR_CODES.INVALID_USER_TYPE,
53774
+ BACKEND_ERROR_CODES.FEATURE_DISABLED
53671
53775
  ];
53672
53776
  NON_FATAL_ERROR_CODES = [
53673
- BACKEND_ERROR_CODES.CONTEXT_NO_HANDOFF_SINCE_LAST_CONTEXT
53777
+ BACKEND_ERROR_CODES.CONTEXT_NO_HANDOFF_SINCE_LAST_CONTEXT,
53778
+ BACKEND_ERROR_CODES.CONTEXT_NOT_FOUND,
53779
+ BACKEND_ERROR_CODES.CONTEXT_RESTRICTED,
53780
+ BACKEND_ERROR_CODES.HANDOFF_RESTRICTED,
53781
+ BACKEND_ERROR_CODES.BACKLOG_ITEM_NOT_FOUND,
53782
+ BACKEND_ERROR_CODES.TASK_NOT_FOUND,
53783
+ BACKEND_ERROR_CODES.QUEUED_MESSAGE_NOT_FOUND,
53784
+ BACKEND_ERROR_CODES.ITEM_NOT_FOUND,
53785
+ BACKEND_ERROR_CODES.MESSAGE_NOT_FOUND,
53786
+ BACKEND_ERROR_CODES.CONTEXT_NOT_FOUND,
53787
+ BACKEND_ERROR_CODES.SAVED_COMMAND_NOT_FOUND,
53788
+ BACKEND_ERROR_CODES.RUN_NOT_FOUND,
53789
+ BACKEND_ERROR_CODES.COMMAND_NOT_FOUND,
53790
+ BACKEND_ERROR_CODES.ATTENDANCE_NOT_FOUND,
53791
+ BACKEND_ERROR_CODES.USER_NOT_FOUND,
53792
+ BACKEND_ERROR_CODES.NOT_FOUND,
53793
+ BACKEND_ERROR_CODES.CONTENT_EMPTY,
53794
+ BACKEND_ERROR_CODES.REASON_EMPTY,
53795
+ BACKEND_ERROR_CODES.NAME_REQUIRED,
53796
+ BACKEND_ERROR_CODES.COMMAND_NAME_EMPTY,
53797
+ BACKEND_ERROR_CODES.MISSING_CLASSIFICATION,
53798
+ BACKEND_ERROR_CODES.MESSAGE_NOT_CLASSIFIED,
53799
+ BACKEND_ERROR_CODES.INVALID_CONTENT,
53800
+ BACKEND_ERROR_CODES.INVALID_ROLE,
53801
+ BACKEND_ERROR_CODES.INVALID_TASK,
53802
+ BACKEND_ERROR_CODES.INVALID_TASK_STATUS,
53803
+ BACKEND_ERROR_CODES.INVALID_ITEM,
53804
+ BACKEND_ERROR_CODES.INVALID_ITEM_STATUS,
53805
+ BACKEND_ERROR_CODES.INVALID_MESSAGE,
53806
+ BACKEND_ERROR_CODES.INVALID_STATE,
53807
+ BACKEND_ERROR_CODES.INVALID_CONVERSION,
53808
+ BACKEND_ERROR_CODES.INVALID_STDIN_FORMAT,
53809
+ BACKEND_ERROR_CODES.INVALID_BOT_TOKEN,
53810
+ BACKEND_ERROR_CODES.INVALID_STATE_TRANSITION,
53811
+ BACKEND_ERROR_CODES.TASK_INVALID_TRANSITION,
53812
+ BACKEND_ERROR_CODES.TASK_MISSING_REQUIRED_FIELD,
53813
+ BACKEND_ERROR_CODES.TASK_VALIDATION_FAILED,
53814
+ BACKEND_ERROR_CODES.BACKLOG_INVALID_TRANSITION,
53815
+ BACKEND_ERROR_CODES.BACKLOG_ITEM_WRONG_CHATROOM,
53816
+ BACKEND_ERROR_CODES.BACKLOG_MISSING_REQUIRED_FIELD,
53817
+ BACKEND_ERROR_CODES.BACKLOG_VALIDATION_FAILED,
53818
+ BACKEND_ERROR_CODES.SKILL_NOT_FOUND_OR_DISABLED,
53819
+ BACKEND_ERROR_CODES.MISSING_FEATURE_METADATA,
53820
+ BACKEND_ERROR_CODES.MISSING_SPECIFICATION,
53821
+ BACKEND_ERROR_CODES.MISSING_STDIN,
53822
+ BACKEND_ERROR_CODES.UNKNOWN_PARAM,
53823
+ BACKEND_ERROR_CODES.VALIDATION_ERROR,
53824
+ BACKEND_ERROR_CODES.OUTPUT_CHUNK_TOO_LARGE,
53825
+ BACKEND_ERROR_CODES.TOO_MANY_COMMANDS,
53826
+ BACKEND_ERROR_CODES.COMMAND_NOT_DISCOVERED,
53827
+ BACKEND_ERROR_CODES.COMMAND_NOT_RUNNING,
53828
+ BACKEND_ERROR_CODES.RUN_WRONG_MACHINE,
53829
+ BACKEND_ERROR_CODES.COMMAND_TYPE_IMMUTABLE,
53830
+ BACKEND_ERROR_CODES.NOT_AUTHORIZED_MACHINE,
53831
+ BACKEND_ERROR_CODES.ATTENDANCE_DELETE_UNAUTHORIZED,
53832
+ BACKEND_ERROR_CODES.CONFLICT,
53833
+ BACKEND_ERROR_CODES.EMAIL_ALREADY_EXISTS,
53834
+ BACKEND_ERROR_CODES.ALREADY_CONNECTED,
53835
+ BACKEND_ERROR_CODES.CONNECT_ERROR,
53836
+ BACKEND_ERROR_CODES.UNSAFE_DISCONNECT,
53837
+ BACKEND_ERROR_CODES.CONFIGURATION_ERROR,
53838
+ BACKEND_ERROR_CODES.CHATROOM_NO_TEAM_ID,
53839
+ BACKEND_ERROR_CODES.TEAM_REQUIRED,
53840
+ BACKEND_ERROR_CODES.WEBHOOK_REGISTRATION_FAILED,
53841
+ BACKEND_ERROR_CODES.WEBHOOK_REMOVAL_FAILED,
53842
+ BACKEND_ERROR_CODES.OAUTH_ERROR,
53843
+ BACKEND_ERROR_CODES.LOGIN_ERROR,
53844
+ BACKEND_ERROR_CODES.WORKFLOW_REQUIRED
53674
53845
  ];
53675
53846
  });
53676
53847
 
@@ -55094,6 +55265,7 @@ async function updateBacklog(chatroomId, options, deps) {
55094
55265
  try {
55095
55266
  await d.backend.mutation(api.backlog.updateBacklogItem, {
55096
55267
  sessionId,
55268
+ chatroomId,
55097
55269
  itemId: options.backlogItemId,
55098
55270
  content: options.content.trim()
55099
55271
  });
@@ -55347,7 +55519,11 @@ function parseSections(input, requiredSections, optionalSections) {
55347
55519
  let match;
55348
55520
  while ((match = regex.exec(input)) !== null) {
55349
55521
  const sectionName = match[1].replace(/^---/, "").replace(/---$/, "");
55350
- markers.push({ section: sectionName, index: match.index + match[0].length, matchStart: match.index });
55522
+ markers.push({
55523
+ section: sectionName,
55524
+ index: match.index + match[0].length,
55525
+ matchStart: match.index
55526
+ });
55351
55527
  }
55352
55528
  for (let i2 = 0;i2 < markers.length; i2++) {
55353
55529
  const start = markers[i2].index;
@@ -59302,329 +59478,6 @@ function harnessCapabilitiesFingerprint(harnesses, versions) {
59302
59478
  return `${h}::${v3}`;
59303
59479
  }
59304
59480
 
59305
- // src/infrastructure/local-api/routes/identity.ts
59306
- async function handleIdentity(_req, ctx) {
59307
- const identity = {
59308
- machineId: ctx.machineId,
59309
- hostname: ctx.config?.hostname ?? "unknown",
59310
- os: ctx.config?.os ?? "unknown",
59311
- version: getVersion()
59312
- };
59313
- return {
59314
- status: 200,
59315
- headers: { "Content-Type": "application/json" },
59316
- body: JSON.stringify(identity)
59317
- };
59318
- }
59319
- var identityRoute;
59320
- var init_identity = __esm(() => {
59321
- init_version();
59322
- identityRoute = {
59323
- method: "GET",
59324
- path: "/api/identity",
59325
- handler: handleIdentity
59326
- };
59327
- });
59328
-
59329
- // src/infrastructure/local-api/routes/shared-utils.ts
59330
- import { exec as exec5 } from "node:child_process";
59331
- import { access as access4 } from "node:fs/promises";
59332
- function jsonResponse(status, body) {
59333
- return {
59334
- status,
59335
- headers: { "Content-Type": "application/json" },
59336
- body: JSON.stringify(body)
59337
- };
59338
- }
59339
- async function parseWorkingDir(req) {
59340
- let body = {};
59341
- try {
59342
- if (req.body) {
59343
- body = JSON.parse(req.body);
59344
- }
59345
- } catch {
59346
- return { ok: false, response: jsonResponse(400, { success: false, error: "Invalid JSON body" }) };
59347
- }
59348
- const { workingDir } = body;
59349
- if (!workingDir || typeof workingDir !== "string" || workingDir.trim() === "") {
59350
- return { ok: false, response: jsonResponse(400, { success: false, error: "workingDir is required" }) };
59351
- }
59352
- try {
59353
- await access4(workingDir);
59354
- } catch {
59355
- return {
59356
- ok: false,
59357
- response: jsonResponse(400, { success: false, error: `Directory not found: ${workingDir}` })
59358
- };
59359
- }
59360
- return { ok: true, workingDir };
59361
- }
59362
- function escapeShellArg(arg) {
59363
- return `"${arg.replace(/"/g, "\\\"")}"`;
59364
- }
59365
- function resolveWhichCommand(name) {
59366
- return process.platform === "win32" ? `where ${name}` : `which ${name}`;
59367
- }
59368
- function isCliAvailable(cliName) {
59369
- return new Promise((resolve5) => {
59370
- exec5(resolveWhichCommand(cliName), (err) => {
59371
- resolve5(!err);
59372
- });
59373
- });
59374
- }
59375
- function execFireAndForget(command, logTag) {
59376
- exec5(command, (err) => {
59377
- if (err) {
59378
- console.warn(`[${logTag}] exec failed: ${err.message}`);
59379
- }
59380
- });
59381
- }
59382
- var init_shared_utils = () => {};
59383
-
59384
- // src/infrastructure/local-api/routes/open-finder.ts
59385
- function resolveOpenCommand(platform) {
59386
- switch (platform) {
59387
- case "darwin":
59388
- return "open";
59389
- case "win32":
59390
- return "explorer";
59391
- default:
59392
- return "xdg-open";
59393
- }
59394
- }
59395
- async function handleOpenFinder(req) {
59396
- const parsed = await parseWorkingDir(req);
59397
- if (!parsed.ok)
59398
- return parsed.response;
59399
- const cmd = resolveOpenCommand(process.platform);
59400
- execFireAndForget(`${cmd} ${escapeShellArg(parsed.workingDir)}`, "open-finder");
59401
- return jsonResponse(200, { success: true });
59402
- }
59403
- var openFinderRoute;
59404
- var init_open_finder = __esm(() => {
59405
- init_shared_utils();
59406
- openFinderRoute = {
59407
- method: "POST",
59408
- path: "/api/open-finder",
59409
- handler: (req) => handleOpenFinder(req)
59410
- };
59411
- });
59412
-
59413
- // src/infrastructure/local-api/routes/open-github-desktop.ts
59414
- async function handleOpenGitHubDesktop(req) {
59415
- const parsed = await parseWorkingDir(req);
59416
- if (!parsed.ok)
59417
- return parsed.response;
59418
- const available = await isCliAvailable("github");
59419
- if (!available) {
59420
- return jsonResponse(200, { success: false, error: "GitHub Desktop CLI not found" });
59421
- }
59422
- execFireAndForget(`github ${escapeShellArg(parsed.workingDir)}`, "open-github-desktop");
59423
- return jsonResponse(200, { success: true });
59424
- }
59425
- var openGitHubDesktopRoute;
59426
- var init_open_github_desktop = __esm(() => {
59427
- init_shared_utils();
59428
- openGitHubDesktopRoute = {
59429
- method: "POST",
59430
- path: "/api/open-github-desktop",
59431
- handler: (req) => handleOpenGitHubDesktop(req)
59432
- };
59433
- });
59434
-
59435
- // src/infrastructure/local-api/routes/open-vscode.ts
59436
- async function handleOpenVSCode(req) {
59437
- const parsed = await parseWorkingDir(req);
59438
- if (!parsed.ok)
59439
- return parsed.response;
59440
- const available = await isCliAvailable("code");
59441
- if (!available) {
59442
- return jsonResponse(200, { success: false, error: CODE_CLI_NOT_FOUND });
59443
- }
59444
- execFireAndForget(`code ${escapeShellArg(parsed.workingDir)}`, "open-vscode");
59445
- return jsonResponse(200, { success: true });
59446
- }
59447
- var CODE_CLI_NOT_FOUND = "VS Code CLI (code) not found. Install via: VS Code → Cmd+Shift+P → 'Shell Command: Install code in PATH'", openVSCodeRoute;
59448
- var init_open_vscode = __esm(() => {
59449
- init_shared_utils();
59450
- openVSCodeRoute = {
59451
- method: "POST",
59452
- path: "/api/open-vscode",
59453
- handler: (req) => handleOpenVSCode(req)
59454
- };
59455
- });
59456
-
59457
- // src/infrastructure/local-api/cors.ts
59458
- function applyCorsHeaders(response) {
59459
- return {
59460
- ...response,
59461
- headers: {
59462
- ...CORS_HEADERS,
59463
- ...response.headers ?? {}
59464
- }
59465
- };
59466
- }
59467
- function buildPreflightResponse() {
59468
- return {
59469
- status: 204,
59470
- headers: CORS_HEADERS,
59471
- body: ""
59472
- };
59473
- }
59474
- var CORS_HEADERS;
59475
- var init_cors = __esm(() => {
59476
- CORS_HEADERS = {
59477
- "Access-Control-Allow-Origin": "*",
59478
- "Access-Control-Allow-Methods": "GET, POST, OPTIONS",
59479
- "Access-Control-Allow-Headers": "Content-Type",
59480
- "Access-Control-Allow-Private-Network": "true"
59481
- };
59482
- });
59483
-
59484
- // src/infrastructure/local-api/router.ts
59485
- class LocalApiRouter {
59486
- routes = [];
59487
- registerRoute(route) {
59488
- this.routes.push(route);
59489
- }
59490
- async handleRequest(req, ctx) {
59491
- if (req.method === "OPTIONS") {
59492
- return buildPreflightResponse();
59493
- }
59494
- const pathname = req.url.split("?")[0] ?? req.url;
59495
- const route = this.routes.find((r) => r.method === req.method && r.path === pathname);
59496
- let response;
59497
- if (route) {
59498
- try {
59499
- response = await route.handler(req, ctx);
59500
- } catch (error) {
59501
- response = {
59502
- status: 500,
59503
- headers: { "Content-Type": "application/json" },
59504
- body: JSON.stringify({ error: "Internal server error" })
59505
- };
59506
- }
59507
- } else {
59508
- response = {
59509
- status: 404,
59510
- headers: { "Content-Type": "application/json" },
59511
- body: JSON.stringify({ error: "Not found" })
59512
- };
59513
- }
59514
- return applyCorsHeaders(response);
59515
- }
59516
- }
59517
- var init_router = __esm(() => {
59518
- init_cors();
59519
- });
59520
-
59521
- // src/infrastructure/local-api/server.ts
59522
- import { createServer } from "node:http";
59523
- function readBody(req) {
59524
- return new Promise((resolve5, reject) => {
59525
- const chunks = [];
59526
- req.on("data", (chunk) => chunks.push(chunk));
59527
- req.on("end", () => resolve5(Buffer.concat(chunks).toString("utf-8")));
59528
- req.on("error", reject);
59529
- });
59530
- }
59531
- async function normalizeRequest(req) {
59532
- const body = await readBody(req);
59533
- const headers = {};
59534
- for (const [key, value] of Object.entries(req.headers)) {
59535
- if (typeof value === "string") {
59536
- headers[key] = value;
59537
- } else if (Array.isArray(value)) {
59538
- headers[key] = value.join(", ");
59539
- }
59540
- }
59541
- return {
59542
- method: (req.method ?? "GET").toUpperCase(),
59543
- url: req.url ?? "/",
59544
- headers,
59545
- body: body || undefined
59546
- };
59547
- }
59548
- function writeResponse(res, status, headers, body) {
59549
- res.writeHead(status, headers);
59550
- res.end(body);
59551
- }
59552
- function createRouter() {
59553
- const router = new LocalApiRouter;
59554
- router.registerRoute(identityRoute);
59555
- router.registerRoute(openFinderRoute);
59556
- router.registerRoute(openGitHubDesktopRoute);
59557
- router.registerRoute(openVSCodeRoute);
59558
- return router;
59559
- }
59560
- function resolvePort() {
59561
- const envPort = process.env.CHATROOM_LOCAL_API_PORT;
59562
- if (envPort) {
59563
- const parsed = parseInt(envPort, 10);
59564
- if (!isNaN(parsed) && parsed > 0 && parsed < 65536) {
59565
- return parsed;
59566
- }
59567
- }
59568
- return LOCAL_API_PORT;
59569
- }
59570
- function ts() {
59571
- return new Date().toISOString().replace("T", " ").slice(0, 19);
59572
- }
59573
- async function startLocalApi(ctx, port = resolvePort()) {
59574
- const router = createRouter();
59575
- const server2 = createServer(async (req, res) => {
59576
- try {
59577
- const localReq = await normalizeRequest(req);
59578
- const localRes = await router.handleRequest(localReq, ctx);
59579
- writeResponse(res, localRes.status, { "Content-Type": "application/json", ...localRes.headers ?? {} }, localRes.body);
59580
- } catch {
59581
- writeResponse(res, 500, { "Content-Type": "application/json" }, JSON.stringify({ error: "Internal server error" }));
59582
- }
59583
- });
59584
- await new Promise((resolve5) => {
59585
- server2.listen(port, "127.0.0.1", () => {
59586
- console.log(`[${ts()}] \uD83C\uDF10 Local API started on http://localhost:${port}`);
59587
- resolve5();
59588
- });
59589
- server2.on("error", (err) => {
59590
- if (err.code === "EADDRINUSE") {
59591
- console.warn(`[${ts()}] ⚠️ Local API port ${port} already in use — skipping local API`);
59592
- } else {
59593
- console.warn(`[${ts()}] ⚠️ Local API failed to start: ${err.message}`);
59594
- }
59595
- resolve5();
59596
- });
59597
- });
59598
- const stop2 = () => new Promise((resolve5, reject) => {
59599
- if (!server2.listening) {
59600
- resolve5();
59601
- return;
59602
- }
59603
- server2.close((err) => {
59604
- if (err) {
59605
- reject(err);
59606
- } else {
59607
- console.log(`[${ts()}] \uD83C\uDF10 Local API stopped`);
59608
- resolve5();
59609
- }
59610
- });
59611
- });
59612
- return { stop: stop2 };
59613
- }
59614
- var LOCAL_API_PORT = 19847;
59615
- var init_server3 = __esm(() => {
59616
- init_identity();
59617
- init_open_finder();
59618
- init_open_github_desktop();
59619
- init_open_vscode();
59620
- init_router();
59621
- });
59622
-
59623
- // src/infrastructure/local-api/index.ts
59624
- var init_local_api = __esm(() => {
59625
- init_server3();
59626
- });
59627
-
59628
59481
  // src/events/daemon/event-bus.ts
59629
59482
  class DaemonEventBus {
59630
59483
  listeners = new Map;
@@ -59667,15 +59520,15 @@ function onAgentExited(ctx, payload) {
59667
59520
 
59668
59521
  // src/events/daemon/agent/on-agent-started.ts
59669
59522
  function onAgentStarted(ctx, payload) {
59670
- const ts2 = formatTimestamp();
59671
- console.log(`[${ts2}] \uD83D\uDFE2 Agent started: ${payload.role} (PID: ${payload.pid}, harness: ${payload.harness})`);
59523
+ const ts = formatTimestamp();
59524
+ console.log(`[${ts}] \uD83D\uDFE2 Agent started: ${payload.role} (PID: ${payload.pid}, harness: ${payload.harness})`);
59672
59525
  }
59673
59526
  var init_on_agent_started = () => {};
59674
59527
 
59675
59528
  // src/events/daemon/agent/on-agent-stopped.ts
59676
59529
  function onAgentStopped(ctx, payload) {
59677
- const ts2 = formatTimestamp();
59678
- console.log(`[${ts2}] \uD83D\uDD34 Agent stopped: ${payload.role} (PID: ${payload.pid})`);
59530
+ const ts = formatTimestamp();
59531
+ console.log(`[${ts}] \uD83D\uDD34 Agent stopped: ${payload.role} (PID: ${payload.pid})`);
59679
59532
  }
59680
59533
  var init_on_agent_stopped = () => {};
59681
59534
 
@@ -59804,7 +59657,7 @@ class CrashLoopTracker {
59804
59657
  const key = `${chatroomId}:${role.toLowerCase()}`;
59805
59658
  const windowStart = now - CRASH_LOOP_WINDOW_MS;
59806
59659
  const raw = this.history.get(key) ?? [];
59807
- const recent = raw.filter((ts2) => ts2 >= windowStart);
59660
+ const recent = raw.filter((ts) => ts >= windowStart);
59808
59661
  const restartCount = recent.length;
59809
59662
  if (restartCount >= CRASH_LOOP_MAX_RESTARTS) {
59810
59663
  return {
@@ -59847,7 +59700,7 @@ class CrashLoopTracker {
59847
59700
  const key = `${chatroomId}:${role.toLowerCase()}`;
59848
59701
  const windowStart = now - CRASH_LOOP_WINDOW_MS;
59849
59702
  const raw = this.history.get(key) ?? [];
59850
- return raw.filter((ts2) => ts2 >= windowStart).length;
59703
+ return raw.filter((ts) => ts >= windowStart).length;
59851
59704
  }
59852
59705
  }
59853
59706
  var CRASH_LOOP_MAX_RESTARTS = 10, CRASH_LOOP_WINDOW_MS, BACKOFF_INTERVALS;
@@ -60566,8 +60419,6 @@ async function initDaemon() {
60566
60419
  registerEventListeners(ctx);
60567
60420
  logStartup(ctx, availableModels);
60568
60421
  await recoverState(ctx);
60569
- const localApiHandle = await startLocalApi(ctx);
60570
- ctx.stopLocalApi = localApiHandle.stop;
60571
60422
  return ctx;
60572
60423
  } catch (error) {
60573
60424
  if (isNetworkError(error)) {
@@ -60590,7 +60441,6 @@ var AUTH_POLL_INTERVAL_MS2 = 2000, AUTH_WAIT_TIMEOUT_MS, CONNECTION_RETRY_INTERV
60590
60441
  var init_init2 = __esm(() => {
60591
60442
  init_state_recovery();
60592
60443
  init_api3();
60593
- init_local_api();
60594
60444
  init_register_listeners();
60595
60445
  init_storage();
60596
60446
  init_client2();
@@ -60642,7 +60492,7 @@ var init_on_daemon_shutdown = __esm(() => {
60642
60492
  });
60643
60493
 
60644
60494
  // src/infrastructure/git/git-writer.ts
60645
- import { exec as exec6 } from "node:child_process";
60495
+ import { exec as exec5 } from "node:child_process";
60646
60496
  import { promisify as promisify5 } from "node:util";
60647
60497
  async function runGit2(args, cwd) {
60648
60498
  try {
@@ -60706,7 +60556,7 @@ async function gitPull(workingDir) {
60706
60556
  }
60707
60557
  var execAsync4;
60708
60558
  var init_git_writer = __esm(() => {
60709
- execAsync4 = promisify5(exec6);
60559
+ execAsync4 = promisify5(exec5);
60710
60560
  });
60711
60561
 
60712
60562
  // src/infrastructure/git/index.ts
@@ -60716,8 +60566,29 @@ var init_git = __esm(() => {
60716
60566
  });
60717
60567
 
60718
60568
  // src/infrastructure/local-actions/execute-local-action.ts
60719
- import { access as access5 } from "node:fs/promises";
60720
- function resolveOpenCommand2(platform) {
60569
+ import { exec as exec6 } from "node:child_process";
60570
+ import { access as access4 } from "node:fs/promises";
60571
+ function escapeShellArg(arg) {
60572
+ return `"${arg.replace(/"/g, "\\\"")}"`;
60573
+ }
60574
+ function resolveWhichCommand(name) {
60575
+ return process.platform === "win32" ? `where ${name}` : `which ${name}`;
60576
+ }
60577
+ function isCliAvailable(cliName) {
60578
+ return new Promise((resolve5) => {
60579
+ exec6(resolveWhichCommand(cliName), (err) => {
60580
+ resolve5(!err);
60581
+ });
60582
+ });
60583
+ }
60584
+ function execFireAndForget(command, logTag) {
60585
+ exec6(command, (err) => {
60586
+ if (err) {
60587
+ console.warn(`[${logTag}] exec failed: ${err.message}`);
60588
+ }
60589
+ });
60590
+ }
60591
+ function resolveOpenCommand(platform) {
60721
60592
  switch (platform) {
60722
60593
  case "darwin":
60723
60594
  return "open";
@@ -60729,7 +60600,7 @@ function resolveOpenCommand2(platform) {
60729
60600
  }
60730
60601
  async function executeLocalAction(action, workingDir) {
60731
60602
  try {
60732
- await access5(workingDir);
60603
+ await access4(workingDir);
60733
60604
  } catch {
60734
60605
  return { success: false, error: `Directory not found: ${workingDir}` };
60735
60606
  }
@@ -60746,7 +60617,7 @@ async function executeLocalAction(action, workingDir) {
60746
60617
  return { success: true };
60747
60618
  }
60748
60619
  case "open-finder": {
60749
- const cmd = resolveOpenCommand2(process.platform);
60620
+ const cmd = resolveOpenCommand(process.platform);
60750
60621
  execFireAndForget(`${cmd} ${escapeShellArg(workingDir)}`, "open-finder");
60751
60622
  return { success: true };
60752
60623
  }
@@ -60795,7 +60666,6 @@ async function executeLocalAction(action, workingDir) {
60795
60666
  }
60796
60667
  }
60797
60668
  var init_execute_local_action = __esm(() => {
60798
- init_shared_utils();
60799
60669
  init_git();
60800
60670
  });
60801
60671
 
@@ -60870,32 +60740,32 @@ async function refreshModels(ctx) {
60870
60740
  }
60871
60741
  function evictStaleDedupEntries(tracker) {
60872
60742
  const evictBefore = Date.now() - AGENT_REQUEST_DEADLINE_MS;
60873
- for (const [id, ts2] of tracker.commandIds) {
60874
- if (ts2 < evictBefore)
60743
+ for (const [id, ts] of tracker.commandIds) {
60744
+ if (ts < evictBefore)
60875
60745
  tracker.commandIds.delete(id);
60876
60746
  }
60877
- for (const [id, ts2] of tracker.pingIds) {
60878
- if (ts2 < evictBefore)
60747
+ for (const [id, ts] of tracker.pingIds) {
60748
+ if (ts < evictBefore)
60879
60749
  tracker.pingIds.delete(id);
60880
60750
  }
60881
- for (const [id, ts2] of tracker.gitRefreshIds) {
60882
- if (ts2 < evictBefore)
60751
+ for (const [id, ts] of tracker.gitRefreshIds) {
60752
+ if (ts < evictBefore)
60883
60753
  tracker.gitRefreshIds.delete(id);
60884
60754
  }
60885
- for (const [id, ts2] of tracker.capabilitiesRefreshIds) {
60886
- if (ts2 < evictBefore)
60755
+ for (const [id, ts] of tracker.capabilitiesRefreshIds) {
60756
+ if (ts < evictBefore)
60887
60757
  tracker.capabilitiesRefreshIds.delete(id);
60888
60758
  }
60889
- for (const [id, ts2] of tracker.localActionIds) {
60890
- if (ts2 < evictBefore)
60759
+ for (const [id, ts] of tracker.localActionIds) {
60760
+ if (ts < evictBefore)
60891
60761
  tracker.localActionIds.delete(id);
60892
60762
  }
60893
- for (const [id, ts2] of tracker.commandRunIds) {
60894
- if (ts2 < evictBefore)
60763
+ for (const [id, ts] of tracker.commandRunIds) {
60764
+ if (ts < evictBefore)
60895
60765
  tracker.commandRunIds.delete(id);
60896
60766
  }
60897
- for (const [id, ts2] of tracker.commandStopIds) {
60898
- if (ts2 < evictBefore)
60767
+ for (const [id, ts] of tracker.commandStopIds) {
60768
+ if (ts < evictBefore)
60899
60769
  tracker.commandStopIds.delete(id);
60900
60770
  }
60901
60771
  evictStalePendingStops();
@@ -61031,9 +60901,6 @@ async function startCommandLoop(ctx) {
61031
60901
  if (observedSyncSubscriptionHandle)
61032
60902
  observedSyncSubscriptionHandle.stop();
61033
60903
  await onDaemonShutdown(ctx);
61034
- if (ctx.stopLocalApi) {
61035
- await ctx.stopLocalApi().catch(() => {});
61036
- }
61037
60904
  releaseLock();
61038
60905
  process.exit(0);
61039
60906
  };
@@ -61889,7 +61756,11 @@ backlogCommand.command("update").description("Update the content of an existing
61889
61756
  process.exit(1);
61890
61757
  }
61891
61758
  const { updateBacklog: updateBacklog2 } = await Promise.resolve().then(() => (init_backlog(), exports_backlog));
61892
- await updateBacklog2(options.chatroomId, { role: options.role, backlogItemId: options.backlogItemId, content });
61759
+ await updateBacklog2(options.chatroomId, {
61760
+ role: options.role,
61761
+ backlogItemId: options.backlogItemId,
61762
+ content
61763
+ });
61893
61764
  });
61894
61765
  backlogCommand.command("complete").description("Mark a backlog item as complete. Use --force for stuck in_progress/pending tasks.").requiredOption("--chatroom-id <id>", "Chatroom identifier").requiredOption("--role <role>", "Your role").requiredOption("--backlog-item-id <id>", "Backlog item ID to complete").option("-f, --force", "Force complete a stuck in_progress or pending task").action(async (options) => {
61895
61766
  await maybeRequireAuth();
@@ -62192,5 +62063,5 @@ program2.hook("preAction", async (_thisCommand, actionCommand) => {
62192
62063
  });
62193
62064
  program2.parse();
62194
62065
 
62195
- //# debugId=967EF2E82583BAE364756E2164756E21
62066
+ //# debugId=B38A342DEDB6508164756E2164756E21
62196
62067
  //# sourceMappingURL=index.js.map