@akshar5/cohall 0.12.14 → 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 +27 -0
- package/README.md +11 -7
- package/bin/{chunk-6r5hdtcx.js → chunk-1g070msv.js} +2 -2
- package/bin/{chunk-dy48ndmb.js → chunk-493yyvk1.js} +14 -14
- package/bin/{chunk-dy48ndmb.js.map → chunk-493yyvk1.js.map} +3 -3
- package/bin/{chunk-vphkssrc.js → chunk-64wa9ewn.js} +32 -15
- package/bin/chunk-64wa9ewn.js.map +14 -0
- package/bin/{chunk-tc7gfcwe.js → chunk-74r9b64p.js} +18 -15
- package/bin/chunk-74r9b64p.js.map +10 -0
- package/bin/{chunk-89z9anfx.js → chunk-bmqppgkt.js} +4 -4
- package/bin/{chunk-kc5awrf4.js → chunk-ccjb19pq.js} +18 -13
- package/bin/chunk-ccjb19pq.js.map +13 -0
- package/bin/{chunk-318jbf1v.js → chunk-ftwpnc02.js} +1 -1
- package/bin/{chunk-t16mw8kv.js → chunk-htjaf4nz.js} +1 -1
- package/bin/{chunk-hg08s7y1.js → chunk-kz5zz6an.js} +2 -2
- package/bin/{chunk-hg08s7y1.js.map → chunk-kz5zz6an.js.map} +1 -1
- package/bin/{chunk-7vn72ejw.js → chunk-sfwrp4wh.js} +1 -1
- package/bin/{chunk-wexfaech.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/integrations.md +11 -11
- package/docs/services.md +4 -3
- package/package.json +1 -1
- package/bin/chunk-kc5awrf4.js.map +0 -13
- package/bin/chunk-tc7gfcwe.js.map +0 -10
- package/bin/chunk-vphkssrc.js.map +0 -14
- /package/bin/{chunk-6r5hdtcx.js.map → chunk-1g070msv.js.map} +0 -0
- /package/bin/{chunk-89z9anfx.js.map → chunk-bmqppgkt.js.map} +0 -0
- /package/bin/{chunk-318jbf1v.js.map → chunk-ftwpnc02.js.map} +0 -0
- /package/bin/{chunk-t16mw8kv.js.map → chunk-htjaf4nz.js.map} +0 -0
- /package/bin/{chunk-7vn72ejw.js.map → chunk-sfwrp4wh.js.map} +0 -0
- /package/bin/{chunk-wexfaech.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);
|
|
@@ -1273,10 +1287,11 @@ var makeService = (db, retainedTerminalTasks = 1000) => {
|
|
|
1273
1287
|
try: () => db.query("SELECT 1 FROM tasks WHERE id = ? AND dispatched_at IS NOT NULL").get(taskId) !== null,
|
|
1274
1288
|
catch: operationError("RelayStore.hasDispatchEvidence")
|
|
1275
1289
|
}));
|
|
1290
|
+
const isUndispatchedTurn = (task, dispatched) => task.status === "queued" && !dispatched && (task.provider === "grok-bot" || task.clarifications?.at(-1)?.answer !== undefined || task.runId === undefined && task.startedAt === undefined);
|
|
1276
1291
|
const expireTask = Effect2.fn("RelayStore.expireTask")(function* (task) {
|
|
1277
1292
|
if (!taskDeadlinePassed(task) || ["cancelling", "completed", "failed", "cancelled"].includes(task.status))
|
|
1278
1293
|
return task;
|
|
1279
|
-
const neverDispatched = task.status === "queued" && task
|
|
1294
|
+
const neverDispatched = task.status === "queued" && isUndispatchedTurn(task, yield* hasDispatchEvidence(task.id));
|
|
1280
1295
|
return yield* transition(task.id, [task.status], {
|
|
1281
1296
|
status: neverDispatched ? "failed" : "cancelling",
|
|
1282
1297
|
error: taskDeadlineError,
|
|
@@ -1491,7 +1506,8 @@ var makeService = (db, retainedTerminalTasks = 1000) => {
|
|
|
1491
1506
|
}
|
|
1492
1507
|
if (taskDeadlinePassed(current) && status !== "cancelled")
|
|
1493
1508
|
return yield* expireTask(current);
|
|
1494
|
-
const
|
|
1509
|
+
const workerDeadline = status === "cancelled" && current.status !== "cancelling" && current.expiresAt !== undefined;
|
|
1510
|
+
const deadlineExpired = workerDeadline || taskDeadlinePassed(current) && (current.status !== "cancelling" || current.error === taskDeadlineError);
|
|
1495
1511
|
const finalStatus = status === "cancelled" && deadlineExpired ? "failed" : status;
|
|
1496
1512
|
const finalError = finalStatus === "failed" && deadlineExpired ? taskDeadlineError : error;
|
|
1497
1513
|
const timestamp = now();
|
|
@@ -1584,7 +1600,7 @@ var makeService = (db, retainedTerminalTasks = 1000) => {
|
|
|
1584
1600
|
return current;
|
|
1585
1601
|
}
|
|
1586
1602
|
const timestamp = now();
|
|
1587
|
-
const neverDispatched = current
|
|
1603
|
+
const neverDispatched = isUndispatchedTurn(current, dispatched);
|
|
1588
1604
|
return neverDispatched || current.status === "needs_input" && current.provider === "grok-bot" ? yield* transition(taskId, ["queued", "needs_input"], { status: "cancelled", completedAt: timestamp }, { kind: "cancelled", detail: "Client cancelled the task before dispatch" }) : yield* transition(taskId, ["queued", "assigned", "running", "needs_input"], {
|
|
1589
1605
|
status: "cancelling"
|
|
1590
1606
|
}, { kind: "cancelling", detail: "Client requested task cancellation" });
|
|
@@ -1626,12 +1642,13 @@ var makeService = (db, retainedTerminalTasks = 1000) => {
|
|
|
1626
1642
|
});
|
|
1627
1643
|
return row?.session_id;
|
|
1628
1644
|
});
|
|
1629
|
-
const threadTurn = Effect2.fn("RelayStore.threadTurn")(function* (threadId) {
|
|
1645
|
+
const threadTurn = Effect2.fn("RelayStore.threadTurn")(function* (threadId, provider) {
|
|
1630
1646
|
return yield* Effect2.try({
|
|
1631
1647
|
try: () => {
|
|
1632
1648
|
const row = db.query(`SELECT target_device_id, provider FROM tasks
|
|
1633
|
-
WHERE thread_id = ? AND parent_task_id IS NULL AND provider <> 'grok-bot'
|
|
1634
|
-
|
|
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);
|
|
1635
1652
|
return row === null ? undefined : {
|
|
1636
1653
|
deviceId: row.target_device_id,
|
|
1637
1654
|
provider: Schema2.decodeUnknownSync(Provider)(row.provider)
|
|
@@ -2118,7 +2135,7 @@ var resolveDelegation = (input, sourceDeviceId) => Effect3.gen(function* () {
|
|
|
2118
2135
|
message: "The parent task has been cancelled"
|
|
2119
2136
|
});
|
|
2120
2137
|
const devices = yield* store.listDevices().pipe(Effect3.mapError((cause) => new RequestError({ status: 500, message: cause.message })));
|
|
2121
|
-
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;
|
|
2122
2139
|
const provider = input.provider ?? (input.botId === undefined ? threadTurn?.provider ?? "codex" : "grok-bot");
|
|
2123
2140
|
if (input.expiresAt !== undefined && provider === "grok-bot")
|
|
2124
2141
|
return yield* new RequestError({
|
|
@@ -2882,4 +2899,4 @@ export {
|
|
|
2882
2899
|
canDispatchTaskToDevice
|
|
2883
2900
|
};
|
|
2884
2901
|
|
|
2885
|
-
//# debugId=
|
|
2902
|
+
//# debugId=4D3364FC6F15DA1764756E2164756E21
|