@akshar5/cohall 0.12.11 → 0.12.12

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.
Files changed (33) hide show
  1. package/CHANGELOG.md +13 -0
  2. package/README.md +2 -1
  3. package/bin/{chunk-t26anmqq.js → chunk-1ekexd73.js} +1 -1
  4. package/bin/{chunk-8662zgwj.js → chunk-1m1566kp.js} +1 -1
  5. package/bin/{chunk-1frv7xwq.js → chunk-4trfnawd.js} +14 -5
  6. package/bin/chunk-4trfnawd.js.map +10 -0
  7. package/bin/{chunk-8w5szr2v.js → chunk-94dpwj2b.js} +2 -2
  8. package/bin/{chunk-mwgjve0a.js → chunk-baep7sfx.js} +16 -14
  9. package/bin/chunk-baep7sfx.js.map +11 -0
  10. package/bin/{chunk-pen1bdmd.js → chunk-bpnafwbg.js} +44 -14
  11. package/bin/{chunk-pen1bdmd.js.map → chunk-bpnafwbg.js.map} +3 -3
  12. package/bin/{chunk-swqxs7nr.js → chunk-c78dff66.js} +16 -5
  13. package/bin/chunk-c78dff66.js.map +14 -0
  14. package/bin/{chunk-cdpcpqte.js → chunk-f8qjez08.js} +16 -9
  15. package/bin/chunk-f8qjez08.js.map +15 -0
  16. package/bin/{chunk-gwqa0ajn.js → chunk-qbcgvhf1.js} +2 -2
  17. package/bin/{chunk-gwqa0ajn.js.map → chunk-qbcgvhf1.js.map} +1 -1
  18. package/bin/{chunk-808wdkdd.js → chunk-vm7gzczr.js} +1 -1
  19. package/bin/{chunk-ydpe597h.js → chunk-zkhqkh0y.js} +4 -4
  20. package/bin/cohall.js +7 -7
  21. package/docs/install.md +2 -2
  22. package/docs/integrations.md +16 -8
  23. package/docs/services.md +22 -6
  24. package/package.json +1 -1
  25. package/bin/chunk-1frv7xwq.js.map +0 -10
  26. package/bin/chunk-cdpcpqte.js.map +0 -15
  27. package/bin/chunk-mwgjve0a.js.map +0 -11
  28. package/bin/chunk-swqxs7nr.js.map +0 -14
  29. /package/bin/{chunk-t26anmqq.js.map → chunk-1ekexd73.js.map} +0 -0
  30. /package/bin/{chunk-8662zgwj.js.map → chunk-1m1566kp.js.map} +0 -0
  31. /package/bin/{chunk-8w5szr2v.js.map → chunk-94dpwj2b.js.map} +0 -0
  32. /package/bin/{chunk-808wdkdd.js.map → chunk-vm7gzczr.js.map} +0 -0
  33. /package/bin/{chunk-ydpe597h.js.map → chunk-zkhqkh0y.js.map} +0 -0
@@ -65,7 +65,7 @@ import {
65
65
  import {
66
66
  __export,
67
67
  version
68
- } from "./chunk-gwqa0ajn.js";
68
+ } from "./chunk-qbcgvhf1.js";
69
69
 
70
70
  // apps/relay/src/main.ts
71
71
  import { Effect as Effect3, ManagedRuntime, Schema as Schema3, Schedule } from "effect";
@@ -1614,6 +1614,15 @@ var makeService = (db, retainedTerminalTasks = 1000) => {
1614
1614
  });
1615
1615
  return row?.session_id;
1616
1616
  });
1617
+ const threadDevice = Effect2.fn("RelayStore.threadDevice")(function* (threadId) {
1618
+ const row = yield* Effect2.try({
1619
+ try: () => db.query(`SELECT target_device_id FROM tasks
1620
+ WHERE thread_id = ? AND parent_task_id IS NULL AND provider <> 'grok-bot'
1621
+ ORDER BY created_at DESC, rowid DESC LIMIT 1`).get(threadId),
1622
+ catch: operationError("RelayStore.threadDevice")
1623
+ });
1624
+ return row?.target_device_id;
1625
+ });
1617
1626
  const createPairing = Effect2.fn("RelayStore.createPairing")(function* (input) {
1618
1627
  const roles = [...new Set(input.roles)];
1619
1628
  if (roles.length === 0) {
@@ -1776,6 +1785,7 @@ var makeService = (db, retainedTerminalTasks = 1000) => {
1776
1785
  failOperation,
1777
1786
  requeueOperationsFor,
1778
1787
  sessionFor,
1788
+ threadDevice,
1779
1789
  createPairing,
1780
1790
  exchangePairing,
1781
1791
  authenticateSession,
@@ -2046,7 +2056,7 @@ var body = (request, decode2) => Effect3.tryPromise({
2046
2056
  catch: () => new RequestError({ status: 400, message: "Expected a JSON request body" })
2047
2057
  }).pipe(Effect3.flatMap(decode2), Effect3.mapError((cause) => cause instanceof RequestError ? cause : new RequestError({ status: 400, message: String(cause).slice(0, 2048) })));
2048
2058
  var pathId = (schema, value) => Schema3.decodeUnknownEffect(schema)(value).pipe(Effect3.mapError(() => new RequestError({ status: 400, message: `Invalid identifier: ${value}` })));
2049
- var scoreDevice = (device, input, sourceDeviceId) => {
2059
+ var scoreDevice = (device, input, sourceDeviceId, threadDeviceId) => {
2050
2060
  const prompt = `${input.prompt} ${input.context ?? ""}`.toLowerCase();
2051
2061
  const needsXcode = /\b(xcode|ios|macos|swiftui|app store)\b/.test(prompt);
2052
2062
  const needsBrowser = /\b(browser|chrome|youtube|twitter|logged[- ]?in|signed[- ]?in|x\.com)\b/.test(prompt);
@@ -2056,7 +2066,7 @@ var scoreDevice = (device, input, sourceDeviceId) => {
2056
2066
  const child = paths.relative(path, workspace);
2057
2067
  return child !== ".." && !child.startsWith(`..${paths.sep}`) && !paths.isAbsolute(child);
2058
2068
  });
2059
- 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);
2069
+ 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) + (threadDeviceId === device.id ? 70 : 0) + (sourceDeviceId === device.id ? -5 : 0);
2060
2070
  };
2061
2071
  var resolveDelegation = (input, sourceDeviceId) => Effect3.gen(function* () {
2062
2072
  const store = yield* exports_store.Service;
@@ -2151,7 +2161,8 @@ var resolveDelegation = (input, sourceDeviceId) => Effect3.gen(function* () {
2151
2161
  message: `Bot ${input.botId} is advertised by more than one device; select a device`
2152
2162
  });
2153
2163
  }
2154
- const selected = candidates.filter((device) => !blocked.has(device.id)).sort((left, right) => scoreDevice(right, input, sourceDeviceId) - scoreDevice(left, input, sourceDeviceId))[0];
2164
+ const threadDeviceId = parent === undefined && input.threadId !== undefined && provider !== "grok-bot" ? yield* store.threadDevice(input.threadId).pipe(Effect3.mapError((cause) => new RequestError({ status: 500, message: cause.message }))) : undefined;
2165
+ const selected = candidates.filter((device) => !blocked.has(device.id)).sort((left, right) => scoreDevice(right, input, sourceDeviceId, threadDeviceId) - scoreDevice(left, input, sourceDeviceId, threadDeviceId))[0];
2155
2166
  if (selected === undefined) {
2156
2167
  return yield* new RequestError({
2157
2168
  status: 409,
@@ -2823,4 +2834,4 @@ export {
2823
2834
  canDispatchTaskToDevice
2824
2835
  };
2825
2836
 
2826
- //# debugId=50259372B183E93164756E2164756E21
2837
+ //# debugId=7733522C4FF7C62F64756E2164756E21