@akshar5/cohall 0.12.3 → 0.12.5
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 +14 -0
- package/bin/cohall.js +33 -21
- package/bin/cohall.js.map +7 -7
- package/docs/install.md +6 -0
- package/docs/integrations.md +5 -0
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,19 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## [0.12.5](https://github.com/AksharP5/cohall/compare/v0.12.4...v0.12.5) (2026-10-17)
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
### Bug Fixes
|
|
7
|
+
|
|
8
|
+
* **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))
|
|
9
|
+
|
|
10
|
+
## [0.12.4](https://github.com/AksharP5/cohall/compare/v0.12.3...v0.12.4) (2026-10-17)
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
### Bug Fixes
|
|
14
|
+
|
|
15
|
+
* **relay:** route work using target workspace path rules ([#205](https://github.com/AksharP5/cohall/issues/205)) ([1c5b991](https://github.com/AksharP5/cohall/commit/1c5b991558e0354da07f476df872fae9538d0508))
|
|
16
|
+
|
|
3
17
|
## [0.12.3](https://github.com/AksharP5/cohall/compare/v0.12.2...v0.12.3) (2026-10-15)
|
|
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.
|
|
20
|
+
var version = "0.12.5", 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: {
|
|
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
|
-
|
|
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,
|
|
@@ -2261,6 +2272,7 @@ import { createHash as createHash3, timingSafeEqual } from "node:crypto";
|
|
|
2261
2272
|
import { access as access6, chmod as chmod8 } from "node:fs/promises";
|
|
2262
2273
|
import { createServer } from "node:http";
|
|
2263
2274
|
import { platform as platform6 } from "node:os";
|
|
2275
|
+
import { posix, win32 } from "node:path";
|
|
2264
2276
|
import { WebSocketServer } from "ws";
|
|
2265
2277
|
var RequestError, relayListenOptions = (configuration, environment = process.env, pid = process.pid) => {
|
|
2266
2278
|
const listenPid = Number(environment.LISTEN_PID);
|
|
@@ -2363,7 +2375,13 @@ Content-Length: 0\r
|
|
|
2363
2375
|
const prompt = `${input.prompt} ${input.context ?? ""}`.toLowerCase();
|
|
2364
2376
|
const needsXcode = /\b(xcode|ios|macos|swiftui|app store)\b/.test(prompt);
|
|
2365
2377
|
const needsBrowser = /\b(browser|chrome|youtube|twitter|logged[- ]?in|signed[- ]?in|x\.com)\b/.test(prompt);
|
|
2366
|
-
|
|
2378
|
+
const paths2 = device.platform === "windows" ? win32 : posix;
|
|
2379
|
+
const workspace = input.workspace;
|
|
2380
|
+
const matchesWorkspace = workspace !== undefined && paths2.isAbsolute(workspace) && device.workspaces.some(({ path }) => {
|
|
2381
|
+
const child = paths2.relative(path, workspace);
|
|
2382
|
+
return child !== ".." && !child.startsWith(`..${paths2.sep}`) && !paths2.isAbsolute(child);
|
|
2383
|
+
});
|
|
2384
|
+
return (device.status === "offline" ? 0 : 100) + (matchesWorkspace ? 80 : 0) + (needsXcode && device.capabilities.some((capability) => capability.id === "xcode") ? 60 : 0) + (needsBrowser && device.capabilities.some((capability) => capability.id === "browser-session") ? 40 : 0) + (sourceDeviceId === device.id ? -5 : 0);
|
|
2367
2385
|
}, resolveDelegation = (input, sourceDeviceId) => Effect16.gen(function* () {
|
|
2368
2386
|
const store = yield* exports_store.Service;
|
|
2369
2387
|
const ancestors = [];
|
|
@@ -2998,7 +3016,7 @@ Content-Length: 0\r
|
|
|
2998
3016
|
socket.on("message", (message) => {
|
|
2999
3017
|
if (!hub.isAuthorized(socket)) {
|
|
3000
3018
|
const size = Buffer.byteLength(socketText(message));
|
|
3001
|
-
if (socket.data.preAuthFrameReceived || size >
|
|
3019
|
+
if (socket.data.preAuthFrameReceived || size > maxAuthTokenBytes * 6 + 64) {
|
|
3002
3020
|
socket.close(4003, "Only one authentication frame is allowed");
|
|
3003
3021
|
return;
|
|
3004
3022
|
}
|
|
@@ -4605,9 +4623,7 @@ var loadOwnerConfiguration = Effect4.tryPromise({
|
|
|
4605
4623
|
if (token === undefined || token.length === 0) {
|
|
4606
4624
|
throw new Error("No owner credential. Run this command on the relay host or set COHALL_TOKEN.");
|
|
4607
4625
|
}
|
|
4608
|
-
|
|
4609
|
-
throw new Error("The Cohall relay owner token must be at least 32 characters");
|
|
4610
|
-
}
|
|
4626
|
+
assertOwnerToken(token);
|
|
4611
4627
|
return ClientConfiguration.make({
|
|
4612
4628
|
relayUrl: normalizeRelayUrl(process.env.COHALL_RELAY_URL ?? stored.relayUrl),
|
|
4613
4629
|
token
|
|
@@ -6635,8 +6651,8 @@ var ownerToken = async (dataDirectory) => {
|
|
|
6635
6651
|
if (!await exists(path)) {
|
|
6636
6652
|
throw new Error(`Relay owner token was not found at ${path}`);
|
|
6637
6653
|
}
|
|
6638
|
-
if ((await stat3(path)).size >
|
|
6639
|
-
throw new Error("Relay owner token file exceeds
|
|
6654
|
+
if ((await stat3(path)).size > maxAuthTokenBytes + 2) {
|
|
6655
|
+
throw new Error("Relay owner token file exceeds its size limit");
|
|
6640
6656
|
}
|
|
6641
6657
|
return (await readFile3(path, "utf8")).trim();
|
|
6642
6658
|
};
|
|
@@ -6674,9 +6690,7 @@ var backupRelay = async (destinationInput) => {
|
|
|
6674
6690
|
}
|
|
6675
6691
|
verifyDatabase(databasePath);
|
|
6676
6692
|
const token = await ownerToken(sourceDirectory);
|
|
6677
|
-
|
|
6678
|
-
throw new Error("The relay owner token must contain between 32 and 512 bytes");
|
|
6679
|
-
}
|
|
6693
|
+
assertOwnerToken(token);
|
|
6680
6694
|
await writeFile5(ownerTokenPath, `${token}
|
|
6681
6695
|
`, { mode: 384 });
|
|
6682
6696
|
await Promise.all([chmod6(databasePath, 384), chmod6(ownerTokenPath, 384)]);
|
|
@@ -6715,7 +6729,7 @@ var restoreRelay = async (sourceInput) => {
|
|
|
6715
6729
|
}
|
|
6716
6730
|
await Promise.all([
|
|
6717
6731
|
verifyBackupMember(sourceDatabase),
|
|
6718
|
-
verifyBackupMember(sourceOwnerToken,
|
|
6732
|
+
verifyBackupMember(sourceOwnerToken, maxAuthTokenBytes + 2),
|
|
6719
6733
|
verifyBackupMember(sourceManifest, 16384)
|
|
6720
6734
|
]);
|
|
6721
6735
|
const target = relayDataDirectory();
|
|
@@ -6747,9 +6761,7 @@ var restoreRelay = async (sourceInput) => {
|
|
|
6747
6761
|
}
|
|
6748
6762
|
verifyDatabase(databasePath);
|
|
6749
6763
|
const token = (await readFile3(ownerTokenPath, "utf8")).trim();
|
|
6750
|
-
|
|
6751
|
-
throw new Error("Relay backup contains an invalid owner token");
|
|
6752
|
-
}
|
|
6764
|
+
assertOwnerToken(token);
|
|
6753
6765
|
backupVersion = manifest.cohallVersion;
|
|
6754
6766
|
await rename3(staging, target);
|
|
6755
6767
|
} catch (cause) {
|
|
@@ -9190,4 +9202,4 @@ await main().catch((cause) => {
|
|
|
9190
9202
|
process.exitCode = 1;
|
|
9191
9203
|
});
|
|
9192
9204
|
|
|
9193
|
-
//# debugId=
|
|
9205
|
+
//# debugId=A33BDA8325259EFC64756E2164756E21
|