@akshar5/cohall 0.12.4 → 0.12.6

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/CHANGELOG.md CHANGED
@@ -1,5 +1,19 @@
1
1
  # Changelog
2
2
 
3
+ ## [0.12.6](https://github.com/AksharP5/cohall/compare/v0.12.5...v0.12.6) (2026-10-17)
4
+
5
+
6
+ ### Bug Fixes
7
+
8
+ * **upgrade:** support Homebrew managers with custom global prefixes ([#209](https://github.com/AksharP5/cohall/issues/209)) ([e826403](https://github.com/AksharP5/cohall/commit/e826403db21a9345a804b1929dea6769e648a2a3))
9
+
10
+ ## [0.12.5](https://github.com/AksharP5/cohall/compare/v0.12.4...v0.12.5) (2026-10-17)
11
+
12
+
13
+ ### Bug Fixes
14
+
15
+ * **auth:** keep owner tokens working with devices and backups ([#207](https://github.com/AksharP5/cohall/issues/207)) ([90d8e14](https://github.com/AksharP5/cohall/commit/90d8e142b4adcebfc7108a90f0500048e14c136b))
16
+
3
17
  ## [0.12.4](https://github.com/AksharP5/cohall/compare/v0.12.3...v0.12.4) (2026-10-17)
4
18
 
5
19
 
package/bin/cohall.js CHANGED
@@ -17,7 +17,17 @@ var __esm = (fn, res) => () => (fn && (res = fn(fn = 0)), res);
17
17
 
18
18
  // packages/protocol/src/index.ts
19
19
  import { Effect, Schema } from "effect";
20
- var version = "0.12.4", maxSocketPayloadBytes, maxAttachmentBytes, maxTaskAttachments = 2, maxProgressNoteBytes = 1024, bounded = (maxLength) => Schema.String.check(Schema.isMinLength(1), Schema.isMaxLength(maxLength)), optionalText = (maxLength) => Schema.String.check(Schema.isMaxLength(maxLength)), boundedArray = (schema, maxLength) => Schema.Array(schema).check(Schema.isMaxLength(maxLength)), count, uuid = (name) => Schema.String.check(Schema.isUUID(4)).pipe(Schema.brand(name)), isoTimestamp = (name) => Schema.String.check(Schema.isPattern(/^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}(?:\.\d{1,9})?Z$/, {
20
+ var version = "0.12.6", maxSocketPayloadBytes, maxAuthTokenBytes = 512, maxAttachmentBytes, maxTaskAttachments = 2, maxProgressNoteBytes = 1024, bounded = (maxLength) => Schema.String.check(Schema.isMinLength(1), Schema.isMaxLength(maxLength)), optionalText = (maxLength) => Schema.String.check(Schema.isMaxLength(maxLength)), boundedArray = (schema, maxLength) => Schema.Array(schema).check(Schema.isMaxLength(maxLength)), count, assertOwnerToken = (token) => {
21
+ if (token.length < 32) {
22
+ throw new Error("The Cohall relay owner token must be at least 32 characters");
23
+ }
24
+ if (new TextEncoder().encode(token).byteLength > maxAuthTokenBytes) {
25
+ throw new Error(`The Cohall relay owner token must be at most ${maxAuthTokenBytes} UTF-8 bytes`);
26
+ }
27
+ if (token.trim() !== token || !/^[\t\x20-\x7e\x80-\xff]+$/.test(token)) {
28
+ throw new Error("The Cohall relay owner token must fit an HTTP header without leading or trailing whitespace");
29
+ }
30
+ }, uuid = (name) => Schema.String.check(Schema.isUUID(4)).pipe(Schema.brand(name)), isoTimestamp = (name) => Schema.String.check(Schema.isPattern(/^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}(?:\.\d{1,9})?Z$/, {
21
31
  expected: "an ISO-8601 UTC timestamp"
22
32
  })).pipe(Schema.brand(name)), BotId, Bot, DeviceId, ThreadId, MessageId, TaskId, TaskRequestId, TaskRunId, ClarificationId, AuthSessionId, OperationId, Timestamp, TaskDeadline, taskDeadlineError = "Task deadline exceeded", taskDeadlinePassed = (task, time = Date.now()) => task.expiresAt !== undefined && Date.parse(task.expiresAt) <= time, Platform, Provider, DeviceStatus, TaskStatus, OperationStatus, TaskTraceEventKind, MessageRole, ConnectionRole, AuthSession, CreatePairingInput, PairingCredential, ExchangePairingInput, SessionCredential, PairingResult, Capability, Workspace, Device, DeviceOverview, maxDevicePageDevices = 16, maxDevicePageResponseBytes, DevicePage, minimumDeviceOperationVersion = "0.5.0", parsedVersion = (value) => {
23
33
  const match = /^v?(\d+)\.(\d+)\.(\d+)(-[0-9A-Za-z.-]+)?(?:\+[0-9A-Za-z.-]+)?$/.exec(value);
@@ -377,7 +387,9 @@ var init_src = __esm(() => {
377
387
  attachments: Schema.optionalKey(attachments)
378
388
  }).check(Schema.makeFilter(validBotTarget));
379
389
  SocketEvent = Schema.TaggedUnion({
380
- Authenticate: { token: bounded(256) },
390
+ Authenticate: {
391
+ token: bounded(maxAuthTokenBytes).check(Schema.makeFilter((token) => new TextEncoder().encode(token).byteLength <= maxAuthTokenBytes ? undefined : `Authentication token exceeds ${maxAuthTokenBytes} UTF-8 bytes`))
392
+ },
381
393
  Connected: {
382
394
  serverVersion: bounded(32),
383
395
  connectedAt: Timestamp,
@@ -469,10 +481,11 @@ var RelayConfiguration, defaultDataDirectory = () => {
469
481
  throw new Error(`${name} must be true or false`);
470
482
  }, isLoopback2 = (host) => host === "127.0.0.1" || host === "localhost" || host === "::1", loadEnvironmentConfiguration;
471
483
  var init_config = __esm(() => {
484
+ init_src();
472
485
  RelayConfiguration = Schema16.Struct({
473
486
  host: Schema16.NonEmptyString,
474
487
  port: Schema16.Int.check(Schema16.isBetween({ minimum: 1, maximum: 65535 })),
475
- token: Schema16.String.check(Schema16.isMinLength(32)),
488
+ token: Schema16.String.check(Schema16.isMinLength(32), Schema16.isMaxLength(maxAuthTokenBytes)),
476
489
  dataDirectory: Schema16.NonEmptyString,
477
490
  databasePath: Schema16.NonEmptyString,
478
491
  allowRemote: Schema16.Boolean,
@@ -492,9 +505,7 @@ var init_config = __esm(() => {
492
505
  await chmod7(dataDirectory, 448);
493
506
  }
494
507
  const token = process.env.COHALL_TOKEN ?? await tokenFrom(join10(dataDirectory, "owner-token"));
495
- if (token.length < 32) {
496
- throw new Error("The Cohall relay owner token must be at least 32 characters");
497
- }
508
+ assertOwnerToken(token);
498
509
  const historyTaskLimit = Number(process.env.COHALL_HISTORY_TASK_LIMIT ?? "1000");
499
510
  return Schema16.decodeUnknownSync(RelayConfiguration)({
500
511
  host,
@@ -3005,7 +3016,7 @@ Content-Length: 0\r
3005
3016
  socket.on("message", (message) => {
3006
3017
  if (!hub.isAuthorized(socket)) {
3007
3018
  const size = Buffer.byteLength(socketText(message));
3008
- if (socket.data.preAuthFrameReceived || size > 1024) {
3019
+ if (socket.data.preAuthFrameReceived || size > maxAuthTokenBytes * 6 + 64) {
3009
3020
  socket.close(4003, "Only one authentication frame is allowed");
3010
3021
  return;
3011
3022
  }
@@ -4612,9 +4623,7 @@ var loadOwnerConfiguration = Effect4.tryPromise({
4612
4623
  if (token === undefined || token.length === 0) {
4613
4624
  throw new Error("No owner credential. Run this command on the relay host or set COHALL_TOKEN.");
4614
4625
  }
4615
- if (token.length < 32) {
4616
- throw new Error("The Cohall relay owner token must be at least 32 characters");
4617
- }
4626
+ assertOwnerToken(token);
4618
4627
  return ClientConfiguration.make({
4619
4628
  relayUrl: normalizeRelayUrl(process.env.COHALL_RELAY_URL ?? stored.relayUrl),
4620
4629
  token
@@ -5838,23 +5847,20 @@ var macosHomebrewRoots = ["/opt/homebrew", "/usr/local"];
5838
5847
  var macosAdminGroup = 80;
5839
5848
  var isTrustedSystemPath = (platform4, path) => platform4 === "linux" && (path === "/home" || linuxSystemExecutableRoots.some((root) => containsPath(root, path) || containsPath(path, root)));
5840
5849
  var isTrustedGroupWritablePath = (options) => {
5841
- const writableRoot = options.writableRoot;
5842
- return options.platform === "darwin" && writableRoot !== undefined && options.uid !== undefined && options.ownerUid === options.uid && options.ownerGid === macosAdminGroup && macosHomebrewRoots.some((root) => containsPath(root, writableRoot)) && containsPath(writableRoot, options.canonical) && containsPath(writableRoot, options.path);
5850
+ return options.platform === "darwin" && options.uid !== undefined && options.ownerUid === options.uid && options.ownerGid === macosAdminGroup && macosHomebrewRoots.some((root) => containsPath(root, options.canonical) && containsPath(root, options.path));
5843
5851
  };
5844
- var validateExecutable = async (candidate, installationRoot, preserveSymlink = false) => {
5852
+ var validateExecutable = async (candidate, preserveSymlink = false) => {
5845
5853
  const canonical = await realpath2(candidate);
5846
5854
  if (operatingSystem() === "win32") {
5847
5855
  return preserveSymlink ? resolve3(candidate) : canonical;
5848
5856
  }
5849
5857
  const uid = process.getuid?.();
5850
- const writableRoot = installationRoot === undefined ? undefined : await realpath2(installationRoot);
5851
5858
  for (const executablePath of preserveSymlink ? [canonical, resolve3(candidate)] : [canonical]) {
5852
5859
  for (let path = executablePath;; path = dirname3(path)) {
5853
5860
  const metadata = await stat2(path);
5854
5861
  const trustedGroupWritablePath = isTrustedGroupWritablePath({
5855
5862
  platform: operatingSystem(),
5856
5863
  canonical,
5857
- writableRoot,
5858
5864
  path,
5859
5865
  uid,
5860
5866
  ownerUid: metadata.uid,
@@ -5884,7 +5890,7 @@ var trustedExecutable = async (command, options = {}) => {
5884
5890
  try {
5885
5891
  if (!(await stat2(path)).isFile())
5886
5892
  continue;
5887
- return await validateExecutable(path, options.writableRoot, options.preserveSymlink);
5893
+ return await validateExecutable(path, options.preserveSymlink);
5888
5894
  } catch (cause) {
5889
5895
  failure ??= cause;
5890
5896
  }
@@ -6248,7 +6254,7 @@ var upgrade = async (options) => {
6248
6254
  const resolvePackageManager = () => {
6249
6255
  if (installation.pnpmExecutable !== undefined)
6250
6256
  return Promise.resolve(installation.pnpmExecutable);
6251
- return options.resolveExecutable === undefined ? trustedExecutable(installation.manager, installation.prefix === undefined ? {} : { writableRoot: installation.prefix }) : resolveExecutable(installation.manager);
6257
+ return options.resolveExecutable === undefined ? trustedExecutable(installation.manager) : resolveExecutable(installation.manager);
6252
6258
  };
6253
6259
  let packageManagerExecutable;
6254
6260
  let resolvedTarget = target;
@@ -6642,8 +6648,8 @@ var ownerToken = async (dataDirectory) => {
6642
6648
  if (!await exists(path)) {
6643
6649
  throw new Error(`Relay owner token was not found at ${path}`);
6644
6650
  }
6645
- if ((await stat3(path)).size > 512) {
6646
- throw new Error("Relay owner token file exceeds 512 bytes");
6651
+ if ((await stat3(path)).size > maxAuthTokenBytes + 2) {
6652
+ throw new Error("Relay owner token file exceeds its size limit");
6647
6653
  }
6648
6654
  return (await readFile3(path, "utf8")).trim();
6649
6655
  };
@@ -6681,9 +6687,7 @@ var backupRelay = async (destinationInput) => {
6681
6687
  }
6682
6688
  verifyDatabase(databasePath);
6683
6689
  const token = await ownerToken(sourceDirectory);
6684
- if (token.length < 32 || new TextEncoder().encode(token).byteLength > 512) {
6685
- throw new Error("The relay owner token must contain between 32 and 512 bytes");
6686
- }
6690
+ assertOwnerToken(token);
6687
6691
  await writeFile5(ownerTokenPath, `${token}
6688
6692
  `, { mode: 384 });
6689
6693
  await Promise.all([chmod6(databasePath, 384), chmod6(ownerTokenPath, 384)]);
@@ -6722,7 +6726,7 @@ var restoreRelay = async (sourceInput) => {
6722
6726
  }
6723
6727
  await Promise.all([
6724
6728
  verifyBackupMember(sourceDatabase),
6725
- verifyBackupMember(sourceOwnerToken, 1024),
6729
+ verifyBackupMember(sourceOwnerToken, maxAuthTokenBytes + 2),
6726
6730
  verifyBackupMember(sourceManifest, 16384)
6727
6731
  ]);
6728
6732
  const target = relayDataDirectory();
@@ -6754,9 +6758,7 @@ var restoreRelay = async (sourceInput) => {
6754
6758
  }
6755
6759
  verifyDatabase(databasePath);
6756
6760
  const token = (await readFile3(ownerTokenPath, "utf8")).trim();
6757
- if (token.length < 32 || new TextEncoder().encode(token).byteLength > 512) {
6758
- throw new Error("Relay backup contains an invalid owner token");
6759
- }
6761
+ assertOwnerToken(token);
6760
6762
  backupVersion = manifest.cohallVersion;
6761
6763
  await rename3(staging, target);
6762
6764
  } catch (cause) {
@@ -9197,4 +9199,4 @@ await main().catch((cause) => {
9197
9199
  process.exitCode = 1;
9198
9200
  });
9199
9201
 
9200
- //# debugId=DB1904B0DFF697EC64756E2164756E21
9202
+ //# debugId=0C3787CDC3B3DC7D64756E2164756E21