@akshar5/cohall 0.12.0 → 0.12.2

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,22 @@
1
1
  # Changelog
2
2
 
3
+ ## [0.12.2](https://github.com/AksharP5/cohall/compare/v0.12.1...v0.12.2) (2026-10-15)
4
+
5
+
6
+ ### Bug Fixes
7
+
8
+ * **providers:** show why a Codex turn failed ([#198](https://github.com/AksharP5/cohall/issues/198)) ([14b4df2](https://github.com/AksharP5/cohall/commit/14b4df241d3e091dba5924bbfff5d896739caf01))
9
+ * **relay:** reject updates from closing connections ([#199](https://github.com/AksharP5/cohall/issues/199)) ([110645c](https://github.com/AksharP5/cohall/commit/110645cbad2e271fa6764f868ef6abe0885442c2))
10
+
11
+ ## [0.12.1](https://github.com/AksharP5/cohall/compare/v0.12.0...v0.12.1) (2026-10-13)
12
+
13
+
14
+ ### Bug Fixes
15
+
16
+ * **providers:** preserve the real error when a command fails ([#194](https://github.com/AksharP5/cohall/issues/194)) ([a58c44e](https://github.com/AksharP5/cohall/commit/a58c44e5a5f4185f75201242fb1f11732e4151bb))
17
+ * **tasks:** keep simultaneous follow-ups in submission order ([#195](https://github.com/AksharP5/cohall/issues/195)) ([5f6c487](https://github.com/AksharP5/cohall/commit/5f6c4875fa598ee3e8b2e632e84dab11d5387015))
18
+ * **upgrade:** resolve runnable commands and preserve root prefixes ([#196](https://github.com/AksharP5/cohall/issues/196)) ([cefbe66](https://github.com/AksharP5/cohall/commit/cefbe66b885fccdd86441ec57f4e1dc82112437a))
19
+
3
20
  ## [0.12.0](https://github.com/AksharP5/cohall/compare/v0.11.3...v0.12.0) (2026-10-08)
4
21
 
5
22
 
package/bin/cohall.js CHANGED
@@ -17,7 +17,7 @@ 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.0", 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.2", 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$/, {
21
21
  expected: "an ISO-8601 UTC timestamp"
22
22
  })).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
23
  const match = /^v?(\d+)\.(\d+)\.(\d+)(-[0-9A-Za-z.-]+)?(?:\+[0-9A-Za-z.-]+)?$/.exec(value);
@@ -540,6 +540,9 @@ class Hub {
540
540
  return true;
541
541
  }
542
542
  isAuthorized(socket) {
543
+ if (socket.readyState !== WebSocket3.OPEN) {
544
+ return false;
545
+ }
543
546
  const principal = this.#principals.get(socket);
544
547
  if (principal === undefined) {
545
548
  return false;
@@ -1519,13 +1522,13 @@ var PersistenceError, TaskProgressError, TaskInputError, TaskDeadlineError, Task
1519
1522
  const [messageRows, taskRows] = yield* Effect15.try({
1520
1523
  try: () => [
1521
1524
  db.query(`SELECT * FROM (
1522
- SELECT * FROM messages WHERE thread_id = ?
1523
- ORDER BY created_at DESC, id DESC LIMIT 21
1524
- ) ORDER BY created_at, id`).all(threadId),
1525
+ SELECT *, rowid AS sequence FROM messages WHERE thread_id = ?
1526
+ ORDER BY created_at DESC, rowid DESC LIMIT 21
1527
+ ) ORDER BY created_at, sequence`).all(threadId),
1525
1528
  db.query(`SELECT * FROM (
1526
- SELECT * FROM tasks WHERE thread_id = ?
1527
- ORDER BY created_at DESC, id DESC LIMIT 21
1528
- ) ORDER BY created_at, id`).all(threadId)
1529
+ SELECT *, rowid AS sequence FROM tasks WHERE thread_id = ?
1530
+ ORDER BY created_at DESC, rowid DESC LIMIT 21
1531
+ ) ORDER BY created_at, sequence`).all(threadId)
1529
1532
  ],
1530
1533
  catch: operationError("RelayStore.threadContext.items")
1531
1534
  });
@@ -1547,7 +1550,7 @@ var PersistenceError, TaskProgressError, TaskInputError, TaskDeadlineError, Task
1547
1550
  const rows = yield* Effect15.try({
1548
1551
  try: () => db.query(`SELECT * FROM tasks WHERE target_device_id = ?
1549
1552
  AND status IN ('queued', 'cancelling')
1550
- ORDER BY dispatched_at IS NULL, created_at, id LIMIT 100`).all(deviceId),
1553
+ ORDER BY dispatched_at IS NULL, created_at, rowid LIMIT 100`).all(deviceId),
1551
1554
  catch: operationError("RelayStore.pendingTasksFor")
1552
1555
  });
1553
1556
  return yield* Effect15.forEach(rows, (row) => taskFromRow(db, row));
@@ -3536,7 +3539,7 @@ var captureText = (stream, limit) => new Promise((resolve2, reject) => {
3536
3539
  stream.once("error", reject);
3537
3540
  });
3538
3541
  var failureMessage = (command, stderr, exitCode) => {
3539
- const fallback = `${command} exited with status ${exitCode}`;
3542
+ const fallback = exitCode === undefined ? `${command} failed` : `${command} exited with status ${exitCode}`;
3540
3543
  const suffix = stderr.truncated ? `
3541
3544
  [stderr truncated after 64 KiB]` : "";
3542
3545
  const available2 = 16384 - suffix.length;
@@ -3662,6 +3665,12 @@ var parseCodex = async (stdout, existingSession) => {
3662
3665
  let sessionId = existingSession;
3663
3666
  let discardedEvent = false;
3664
3667
  await forEachJsonEvent(stdout, (event) => {
3668
+ if (text(event.type) === "turn.failed") {
3669
+ throw new ProviderRunError({
3670
+ provider: "codex",
3671
+ message: (text(record(event.error)?.message) || "Codex turn failed").slice(0, 16384)
3672
+ });
3673
+ }
3665
3674
  if (text(event.type) === "thread.started") {
3666
3675
  sessionId = text(event.thread_id) ?? sessionId;
3667
3676
  }
@@ -3695,6 +3704,19 @@ var parseClaude = (stdout, existingSession) => {
3695
3704
  const sessionId = text(value?.session_id) ?? text(value?.sessionId) ?? existingSession;
3696
3705
  return { result, ...sessionId === undefined ? {} : { sessionId } };
3697
3706
  };
3707
+ var claudeFailureMessage = (stdout) => {
3708
+ try {
3709
+ const value = record(JSON.parse(stdout));
3710
+ const result = text(value?.result) ?? text(value?.content);
3711
+ if (result?.trim())
3712
+ return result;
3713
+ const errors = value?.errors;
3714
+ return Array.isArray(errors) ? errors.map(text).filter((error) => error !== undefined).join(`
3715
+ `) || undefined : text(errors);
3716
+ } catch {
3717
+ return;
3718
+ }
3719
+ };
3698
3720
  var textFromPart = (value) => {
3699
3721
  const part = record(value);
3700
3722
  if (part === undefined) {
@@ -3732,7 +3754,7 @@ var parseOpenCode = async (stdout, existingSession) => {
3732
3754
  await forEachJsonEvent(stdout, (event) => {
3733
3755
  const failure = openCodeError(event);
3734
3756
  if (failure !== undefined) {
3735
- throw new Error(failure);
3757
+ throw new ProviderRunError({ provider: "opencode", message: failure });
3736
3758
  }
3737
3759
  sessionId = text(event.sessionID) ?? text(event.sessionId) ?? text(event.session_id) ?? text(record(event.info)?.sessionID) ?? sessionId;
3738
3760
  const part = record(event.part);
@@ -3786,13 +3808,13 @@ var parseOpenCode = async (stdout, existingSession) => {
3786
3808
  }
3787
3809
  return { result, ...sessionId === undefined ? {} : { sessionId } };
3788
3810
  };
3789
- var parse = async (options, stdout, onFailure) => {
3811
+ var readOutput = async (options, stdout, onFailure) => {
3790
3812
  try {
3791
3813
  switch (options.provider) {
3792
3814
  case "codex":
3793
3815
  return await parseCodex(stdout, options.sessionId);
3794
3816
  case "claude-code":
3795
- return parseClaude(await boundedText(stdout, maxJsonBytes, onFailure), options.sessionId);
3817
+ return await boundedText(stdout, maxJsonBytes, onFailure);
3796
3818
  case "opencode":
3797
3819
  return await parseOpenCode(stdout, options.sessionId);
3798
3820
  }
@@ -3846,6 +3868,7 @@ var terminateProcessTree = async (pid) => {
3846
3868
  process.kill(-pid, "SIGKILL");
3847
3869
  await waitForProcessGroup(pid, 1000);
3848
3870
  };
3871
+ var settlePromise = (promise) => promise.then((value) => ({ _tag: "Success", value }), (error) => ({ _tag: "Failure", error }));
3849
3872
  var run = (options) => Effect3.callback((resume, signal) => {
3850
3873
  const running = (async () => {
3851
3874
  const executable = findExecutable(executables[options.provider]);
@@ -3904,19 +3927,34 @@ var run = (options) => Effect3.callback((resume, signal) => {
3904
3927
  child.stdin.once("error", reject);
3905
3928
  child.stdin.end(prepared.input, (cause) => cause === undefined || cause === null ? resolve2() : reject(cause));
3906
3929
  });
3907
- const [result, stderr, exitCode] = await Promise.all([
3908
- parse(options, child.stdout, terminate),
3930
+ const [output, stderr, exit] = await Promise.all([
3931
+ settlePromise(readOutput(options, child.stdout, terminate)),
3909
3932
  captureText(child.stderr, 64 * 1024),
3910
- exited,
3933
+ settlePromise(exited),
3911
3934
  written
3912
3935
  ]);
3936
+ if (output._tag === "Failure" && output.error instanceof ProviderRunError)
3937
+ throw output.error;
3938
+ if (exit._tag === "Failure" && (output._tag === "Success" || child.pid === undefined)) {
3939
+ throw exit.error;
3940
+ }
3941
+ const exitCode = exit._tag === "Success" ? exit.value : undefined;
3913
3942
  if (exitCode !== 0) {
3943
+ let diagnostic = stderr;
3944
+ if (stderr.text.trim().length === 0) {
3945
+ const message = output._tag === "Failure" ? output.error instanceof Error ? output.error.message : String(output.error) : typeof output.value === "string" ? claudeFailureMessage(output.value) : undefined;
3946
+ if (message !== undefined)
3947
+ diagnostic = { text: message, truncated: false };
3948
+ }
3914
3949
  throw new ProviderRunError({
3915
3950
  provider: options.provider,
3916
- message: failureMessage(executables[options.provider], stderr, exitCode),
3917
- exitCode
3951
+ message: failureMessage(executables[options.provider], diagnostic, exitCode),
3952
+ ...exitCode === undefined ? {} : { exitCode }
3918
3953
  });
3919
3954
  }
3955
+ if (output._tag === "Failure")
3956
+ throw output.error;
3957
+ const result = typeof output.value === "string" ? parseClaude(output.value, options.sessionId) : output.value;
3920
3958
  if (byteLength(result.result) > maxResultBytes) {
3921
3959
  throw new ProviderRunError({
3922
3960
  provider: options.provider,
@@ -5527,7 +5565,7 @@ import {
5527
5565
  stat as stat2,
5528
5566
  writeFile as writeFile3
5529
5567
  } from "node:fs/promises";
5530
- import { delimiter as delimiter2, dirname as dirname3, extname as extname2, isAbsolute as isAbsolute3, join as join4, relative, resolve as resolve3 } from "node:path";
5568
+ import { delimiter as delimiter2, dirname as dirname3, extname as extname2, isAbsolute as isAbsolute3, join as join4, relative, resolve as resolve3, sep } from "node:path";
5531
5569
  import { platform as operatingSystem } from "node:os";
5532
5570
  var packageName = "@akshar5/cohall";
5533
5571
  var minimumBunLookupVersion = "1.2.15";
@@ -5624,7 +5662,7 @@ var packageInstallation = (canonicalEntrypoint, entrypoint = canonicalEntrypoint
5624
5662
  return { manager: "pnpm", entrypoint };
5625
5663
  }
5626
5664
  const nodeModulesParent = path.slice(0, packageIndex);
5627
- const prefix = runtimePlatform !== "win32" && nodeModulesParent.endsWith("/lib") ? nodeModulesParent.slice(0, -"/lib".length) : nodeModulesParent;
5665
+ const prefix = runtimePlatform !== "win32" && nodeModulesParent.endsWith("/lib") ? nodeModulesParent.slice(0, -"/lib".length) || "/" : runtimePlatform === "win32" && nodeModulesParent.endsWith(":") ? `${nodeModulesParent}/` : nodeModulesParent;
5628
5666
  return { manager: "npm", prefix, entrypoint };
5629
5667
  };
5630
5668
  var resolvePackageInstallation = async (entrypoint, options = {}) => {
@@ -5763,7 +5801,7 @@ var executableNames = (command) => {
5763
5801
  };
5764
5802
  var containsPath = (root, path) => {
5765
5803
  const child = relative(root, path);
5766
- return child === "" || !child.startsWith("..") && !isAbsolute3(child);
5804
+ return child !== ".." && !child.startsWith(`..${sep}`) && !isAbsolute3(child);
5767
5805
  };
5768
5806
  var linuxSystemExecutableRoots = [
5769
5807
  "/bin",
@@ -5822,6 +5860,8 @@ var trustedExecutable = async (command, options = {}) => {
5822
5860
  if (!available2)
5823
5861
  continue;
5824
5862
  try {
5863
+ if (!(await stat2(path)).isFile())
5864
+ continue;
5825
5865
  return await validateExecutable(path, options.writableRoot, options.preserveSymlink);
5826
5866
  } catch (cause) {
5827
5867
  failure ??= cause;
@@ -8237,7 +8277,7 @@ import { Effect as Effect12, Schedule as Schedule4, Schema as Schema14 } from "e
8237
8277
  import { constants as constants6 } from "node:fs";
8238
8278
  import { open as open6, realpath as realpath4, stat as stat5 } from "node:fs/promises";
8239
8279
  import { arch, hostname as hostname3, platform as platform4 } from "node:os";
8240
- import { basename as basename3, isAbsolute as isAbsolute5, relative as relative2, sep } from "node:path";
8280
+ import { basename as basename3, isAbsolute as isAbsolute5, relative as relative2, sep as sep2 } from "node:path";
8241
8281
  import { WebSocket as WebSocket2 } from "ws";
8242
8282
  var maxQueuedRelayMessages = 8;
8243
8283
 
@@ -8319,7 +8359,7 @@ var allowedWorkspace = async (configuration, requested) => {
8319
8359
  const candidate = await realpath4(selected);
8320
8360
  const allowed = configuration.workspaces.some((root) => {
8321
8361
  const child = relative2(root, candidate);
8322
- return child !== ".." && !child.startsWith(`..${sep}`) && !isAbsolute5(child);
8362
+ return child !== ".." && !child.startsWith(`..${sep2}`) && !isAbsolute5(child);
8323
8363
  });
8324
8364
  if (!allowed) {
8325
8365
  throw new Error(`Workspace ${candidate} is outside this device's configured workspace roots`);
@@ -9135,4 +9175,4 @@ await main().catch((cause) => {
9135
9175
  process.exitCode = 1;
9136
9176
  });
9137
9177
 
9138
- //# debugId=FBAE2BAE92FD7FC964756E2164756E21
9178
+ //# debugId=4B3B01B78A1B929E64756E2164756E21