@akshar5/cohall 0.12.15 → 0.12.16
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 +18 -0
- package/README.md +7 -3
- package/bin/{chunk-0ajk2xqb.js → chunk-1g070msv.js} +2 -2
- package/bin/{chunk-7yrw7mgj.js → chunk-493yyvk1.js} +12 -12
- package/bin/{chunk-7yrw7mgj.js.map → chunk-493yyvk1.js.map} +3 -3
- package/bin/{chunk-07aet48k.js → chunk-64wa9ewn.js} +29 -13
- package/bin/chunk-64wa9ewn.js.map +14 -0
- package/bin/{chunk-468xtafr.js → chunk-74r9b64p.js} +18 -15
- package/bin/chunk-74r9b64p.js.map +10 -0
- package/bin/{chunk-q8a2yv07.js → chunk-bmqppgkt.js} +4 -4
- package/bin/{chunk-5gvgk5pb.js → chunk-ccjb19pq.js} +12 -9
- package/bin/chunk-ccjb19pq.js.map +13 -0
- package/bin/{chunk-g4087sz3.js → chunk-ftwpnc02.js} +1 -1
- package/bin/{chunk-9rgw9hk3.js → chunk-htjaf4nz.js} +1 -1
- package/bin/{chunk-yger1pfj.js → chunk-kz5zz6an.js} +2 -2
- package/bin/{chunk-yger1pfj.js.map → chunk-kz5zz6an.js.map} +1 -1
- package/bin/{chunk-kf3vv88y.js → chunk-sfwrp4wh.js} +1 -1
- package/bin/{chunk-mmbenn43.js → chunk-z33xa36t.js} +1 -1
- package/bin/cohall.js +13 -11
- package/bin/cohall.js.map +3 -3
- package/docs/install.md +5 -2
- package/docs/services.md +4 -3
- package/package.json +1 -1
- package/bin/chunk-07aet48k.js.map +0 -14
- package/bin/chunk-468xtafr.js.map +0 -10
- package/bin/chunk-5gvgk5pb.js.map +0 -13
- /package/bin/{chunk-0ajk2xqb.js.map → chunk-1g070msv.js.map} +0 -0
- /package/bin/{chunk-q8a2yv07.js.map → chunk-bmqppgkt.js.map} +0 -0
- /package/bin/{chunk-g4087sz3.js.map → chunk-ftwpnc02.js.map} +0 -0
- /package/bin/{chunk-9rgw9hk3.js.map → chunk-htjaf4nz.js.map} +0 -0
- /package/bin/{chunk-kf3vv88y.js.map → chunk-sfwrp4wh.js.map} +0 -0
- /package/bin/{chunk-mmbenn43.js.map → chunk-z33xa36t.js.map} +0 -0
|
@@ -65,7 +65,7 @@ import {
|
|
|
65
65
|
import {
|
|
66
66
|
__export,
|
|
67
67
|
version
|
|
68
|
-
} from "./chunk-
|
|
68
|
+
} from "./chunk-kz5zz6an.js";
|
|
69
69
|
|
|
70
70
|
// apps/relay/src/main.ts
|
|
71
71
|
import { Effect as Effect3, ManagedRuntime, Schema as Schema3, Schedule } from "effect";
|
|
@@ -689,8 +689,7 @@ var makeService = (db, retainedTerminalTasks = 1000) => {
|
|
|
689
689
|
const acknowledgeCompletion = Effect2.fn("RelayStore.acknowledgeCompletion")(function* (taskId, principal) {
|
|
690
690
|
const requesterId = principal === "owner" ? "owner" : principal.id;
|
|
691
691
|
const row = yield* Effect2.try({
|
|
692
|
-
try: () => db.query(`SELECT ${inboxColumns} FROM tasks WHERE id = ? AND requester_id =
|
|
693
|
-
AND status IN ('completed', 'failed', 'cancelled')`).get(taskId, requesterId),
|
|
692
|
+
try: () => db.query(`SELECT ${inboxColumns} FROM tasks WHERE id = ? AND requester_id = ?`).get(taskId, requesterId),
|
|
694
693
|
catch: operationError("RelayStore.acknowledgeCompletion.read")
|
|
695
694
|
});
|
|
696
695
|
if (row === null) {
|
|
@@ -699,6 +698,12 @@ var makeService = (db, retainedTerminalTasks = 1000) => {
|
|
|
699
698
|
message: `Unknown inbox task ${taskId}`
|
|
700
699
|
});
|
|
701
700
|
}
|
|
701
|
+
if (!["completed", "failed", "cancelled"].includes(row.status)) {
|
|
702
|
+
return yield* new TaskInputError({
|
|
703
|
+
status: 409,
|
|
704
|
+
message: row.status === "needs_input" ? `Task ${taskId} is waiting for an answer; answer or cancel it instead of acknowledging it` : `Task ${taskId} has not finished; acknowledge it after it completes`
|
|
705
|
+
});
|
|
706
|
+
}
|
|
702
707
|
yield* Effect2.try({
|
|
703
708
|
try: () => db.query("UPDATE tasks SET completion_seen_at = COALESCE(completion_seen_at, ?) WHERE id = ?").run(now(), taskId),
|
|
704
709
|
catch: operationError("RelayStore.acknowledgeCompletion.write")
|
|
@@ -1022,12 +1027,21 @@ var makeService = (db, retainedTerminalTasks = 1000) => {
|
|
|
1022
1027
|
if (device.status !== "offline") {
|
|
1023
1028
|
throw new Error(`Device ${deviceId} must be offline before it can be forgotten`);
|
|
1024
1029
|
}
|
|
1025
|
-
const outstanding = db.query(`SELECT
|
|
1026
|
-
WHERE target_device_id = ? AND status NOT IN ('completed', 'failed', 'cancelled')`).
|
|
1027
|
-
|
|
1028
|
-
|
|
1030
|
+
const outstanding = db.query(`SELECT id, status, error FROM tasks
|
|
1031
|
+
WHERE target_device_id = ? AND status NOT IN ('completed', 'failed', 'cancelled')`).all(deviceId);
|
|
1032
|
+
const unsettled = outstanding.filter((task) => task.status !== "cancelling");
|
|
1033
|
+
if (unsettled.length > 0) {
|
|
1034
|
+
throw new Error(`Device ${deviceId} still has outstanding tasks; cancel them first: ${unsettled.map((task) => task.id).join(", ")}`);
|
|
1029
1035
|
}
|
|
1030
1036
|
const timestamp = now();
|
|
1037
|
+
for (const task of outstanding) {
|
|
1038
|
+
const status = task.error === taskDeadlineError ? "failed" : "cancelled";
|
|
1039
|
+
db.query(`UPDATE tasks SET status = ?, completed_at = ?, updated_at = ?,
|
|
1040
|
+
progress_note = NULL, progress_at = NULL WHERE id = ?`).run(status, timestamp, timestamp, task.id);
|
|
1041
|
+
recordTaskTraceEvent(task.id, status, "Target device was forgotten by the relay owner", timestamp);
|
|
1042
|
+
}
|
|
1043
|
+
if (outstanding.length > 0)
|
|
1044
|
+
pruneTerminalHistory();
|
|
1031
1045
|
db.query(`UPDATE device_operations
|
|
1032
1046
|
SET status = 'failed', error = ?, updated_at = ?, completed_at = ?
|
|
1033
1047
|
WHERE target_device_id = ? AND status IN ('queued', 'assigned', 'running')`).run("Target device was forgotten by the relay owner", timestamp, timestamp, deviceId);
|
|
@@ -1492,7 +1506,8 @@ var makeService = (db, retainedTerminalTasks = 1000) => {
|
|
|
1492
1506
|
}
|
|
1493
1507
|
if (taskDeadlinePassed(current) && status !== "cancelled")
|
|
1494
1508
|
return yield* expireTask(current);
|
|
1495
|
-
const
|
|
1509
|
+
const workerDeadline = status === "cancelled" && current.status !== "cancelling" && current.expiresAt !== undefined;
|
|
1510
|
+
const deadlineExpired = workerDeadline || taskDeadlinePassed(current) && (current.status !== "cancelling" || current.error === taskDeadlineError);
|
|
1496
1511
|
const finalStatus = status === "cancelled" && deadlineExpired ? "failed" : status;
|
|
1497
1512
|
const finalError = finalStatus === "failed" && deadlineExpired ? taskDeadlineError : error;
|
|
1498
1513
|
const timestamp = now();
|
|
@@ -1627,12 +1642,13 @@ var makeService = (db, retainedTerminalTasks = 1000) => {
|
|
|
1627
1642
|
});
|
|
1628
1643
|
return row?.session_id;
|
|
1629
1644
|
});
|
|
1630
|
-
const threadTurn = Effect2.fn("RelayStore.threadTurn")(function* (threadId) {
|
|
1645
|
+
const threadTurn = Effect2.fn("RelayStore.threadTurn")(function* (threadId, provider) {
|
|
1631
1646
|
return yield* Effect2.try({
|
|
1632
1647
|
try: () => {
|
|
1633
1648
|
const row = db.query(`SELECT target_device_id, provider FROM tasks
|
|
1634
|
-
WHERE thread_id = ? AND parent_task_id IS NULL AND provider <> 'grok-bot'
|
|
1635
|
-
|
|
1649
|
+
WHERE thread_id = ?1 AND parent_task_id IS NULL AND provider <> 'grok-bot'
|
|
1650
|
+
AND (?2 IS NULL OR provider = ?2)
|
|
1651
|
+
ORDER BY created_at DESC, rowid DESC LIMIT 1`).get(threadId, provider ?? null);
|
|
1636
1652
|
return row === null ? undefined : {
|
|
1637
1653
|
deviceId: row.target_device_id,
|
|
1638
1654
|
provider: Schema2.decodeUnknownSync(Provider)(row.provider)
|
|
@@ -2119,7 +2135,7 @@ var resolveDelegation = (input, sourceDeviceId) => Effect3.gen(function* () {
|
|
|
2119
2135
|
message: "The parent task has been cancelled"
|
|
2120
2136
|
});
|
|
2121
2137
|
const devices = yield* store.listDevices().pipe(Effect3.mapError((cause) => new RequestError({ status: 500, message: cause.message })));
|
|
2122
|
-
const threadTurn = parent === undefined && input.threadId !== undefined && input.botId === undefined ? yield* store.threadTurn(input.threadId).pipe(Effect3.mapError((cause) => new RequestError({ status: 500, message: cause.message }))) : undefined;
|
|
2138
|
+
const threadTurn = parent === undefined && input.threadId !== undefined && input.botId === undefined ? yield* store.threadTurn(input.threadId, input.provider).pipe(Effect3.mapError((cause) => new RequestError({ status: 500, message: cause.message }))) : undefined;
|
|
2123
2139
|
const provider = input.provider ?? (input.botId === undefined ? threadTurn?.provider ?? "codex" : "grok-bot");
|
|
2124
2140
|
if (input.expiresAt !== undefined && provider === "grok-bot")
|
|
2125
2141
|
return yield* new RequestError({
|
|
@@ -2883,4 +2899,4 @@ export {
|
|
|
2883
2899
|
canDispatchTaskToDevice
|
|
2884
2900
|
};
|
|
2885
2901
|
|
|
2886
|
-
//# debugId=
|
|
2902
|
+
//# debugId=4D3364FC6F15DA1764756E2164756E21
|