@capybara-hq/kernel 0.1.0-rc.68 → 0.1.0-rc.69

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 (215) hide show
  1. package/dist/admin/admin.module.js +2 -0
  2. package/dist/admin/health.service.d.ts +11 -4
  3. package/dist/admin/health.service.js +33 -17
  4. package/dist/background/poll.job.js +2 -2
  5. package/dist/background/tasks.service.d.ts +5 -5
  6. package/dist/background/tasks.service.js +9 -8
  7. package/dist/catalog/marketplaces.service.d.ts +1 -1
  8. package/dist/catalog/requests.service.js +1 -1
  9. package/dist/config/schema.d.ts +1 -1
  10. package/dist/config/schema.js +9 -9
  11. package/dist/conversations/conversations.controller.d.ts +8 -3
  12. package/dist/conversations/conversations.controller.js +8 -3
  13. package/dist/conversations/conversations.service.d.ts +33 -15
  14. package/dist/conversations/conversations.service.js +60 -10
  15. package/dist/conversations/events.d.ts +21 -41
  16. package/dist/conversations/events.js +57 -31
  17. package/dist/conversations/permission-profiles.controller.d.ts +6 -4
  18. package/dist/conversations/permission-profiles.service.d.ts +6 -4
  19. package/dist/ctx/create-ctx.d.ts +20 -1
  20. package/dist/ctx/create-ctx.js +77 -6
  21. package/dist/ctx/device-provider-check.d.ts +6 -2
  22. package/dist/ctx/device-provider-check.js +17 -2
  23. package/dist/db/kernel-schema.d.ts +10 -48
  24. package/dist/devices/access.d.ts +3 -4
  25. package/dist/devices/access.js +3 -4
  26. package/dist/devices/conversation-devices.d.ts +1 -3
  27. package/dist/devices/conversation-devices.js +2 -7
  28. package/dist/devices/device-projects.service.js +24 -29
  29. package/dist/devices/device-provider-selection.d.ts +5 -6
  30. package/dist/devices/device-provider-selection.js +8 -9
  31. package/dist/devices/devices.controller.d.ts +8 -21
  32. package/dist/devices/devices.controller.js +9 -34
  33. package/dist/devices/devices.module.js +6 -4
  34. package/dist/devices/devices.schemas.d.ts +1 -5
  35. package/dist/devices/devices.schemas.js +1 -5
  36. package/dist/devices/devices.service.d.ts +84 -147
  37. package/dist/devices/devices.service.js +134 -229
  38. package/dist/devices/dto.d.ts +5 -32
  39. package/dist/devices/dto.js +5 -37
  40. package/dist/devices/errors.d.ts +6 -5
  41. package/dist/devices/errors.js +7 -8
  42. package/dist/devices/project-rules.d.ts +9 -11
  43. package/dist/devices/project-rules.js +7 -7
  44. package/dist/devices/working-root.d.ts +3 -6
  45. package/dist/devices/working-root.js +3 -8
  46. package/dist/dial-in/access.d.ts +23 -0
  47. package/dist/dial-in/access.js +64 -0
  48. package/dist/{local-devices/device-auth.controller.d.ts → dial-in/auth.controller.d.ts} +12 -6
  49. package/dist/{local-devices/device-auth.controller.js → dial-in/auth.controller.js} +30 -15
  50. package/dist/dial-in/auth.module.d.ts +7 -0
  51. package/dist/dial-in/auth.module.js +27 -0
  52. package/dist/{local-devices/device-auth.d.ts → dial-in/auth.service.d.ts} +42 -13
  53. package/dist/{local-devices/device-auth.js → dial-in/auth.service.js} +83 -32
  54. package/dist/dial-in/dial-in.module.d.ts +9 -0
  55. package/dist/dial-in/dial-in.module.js +37 -0
  56. package/dist/{local-devices → dial-in}/dto.d.ts +17 -2
  57. package/dist/{local-devices → dial-in}/dto.js +14 -2
  58. package/dist/dial-in/envelope.d.ts +95 -0
  59. package/dist/dial-in/envelope.js +89 -0
  60. package/dist/dial-in/gateway.d.ts +214 -0
  61. package/dist/{local-devices/local-device-gateway.js → dial-in/gateway.js} +337 -181
  62. package/dist/dial-in/handlers.d.ts +47 -0
  63. package/dist/dial-in/handlers.js +84 -0
  64. package/dist/dial-in/machines.d.ts +155 -0
  65. package/dist/dial-in/machines.js +383 -0
  66. package/dist/dial-in/relay.d.ts +135 -0
  67. package/dist/dial-in/relay.js +444 -0
  68. package/dist/dial-in/relay.module.d.ts +7 -0
  69. package/dist/dial-in/relay.module.js +24 -0
  70. package/dist/{local-devices/device-routes.d.ts → dial-in/routes.d.ts} +19 -11
  71. package/dist/{local-devices/device-routes.js → dial-in/routes.js} +45 -25
  72. package/dist/{local-devices → dial-in}/targets.d.ts +3 -18
  73. package/dist/{local-devices → dial-in}/targets.js +3 -48
  74. package/dist/errors.d.ts +8 -27
  75. package/dist/errors.js +8 -27
  76. package/dist/extensions/bootstrap.d.ts +5 -0
  77. package/dist/extensions/bootstrap.js +10 -1
  78. package/dist/extensions/extensions.module.js +6 -0
  79. package/dist/extensions/host.d.ts +6 -0
  80. package/dist/extensions/host.js +12 -2
  81. package/dist/extensions/permission-set.d.ts +15 -1
  82. package/dist/extensions/permission-set.js +11 -1
  83. package/dist/extensions/permission-view.d.ts +1 -1
  84. package/dist/extensions/permission-view.js +4 -1
  85. package/dist/http/api.module.js +4 -4
  86. package/dist/http/gateway-routes.d.ts +1 -1
  87. package/dist/http/gateway-routes.js +1 -1
  88. package/dist/http/meta.controller.js +1 -1
  89. package/dist/identity/settings.d.ts +1 -1
  90. package/dist/identity/settings.js +6 -8
  91. package/dist/infra/config/kernel-config.service.js +2 -2
  92. package/dist/infra/outbox/registry.d.ts +0 -14
  93. package/dist/infra/outbox/registry.js +0 -15
  94. package/dist/infra/throttler/named-throttlers.d.ts +1 -1
  95. package/dist/infra/throttler/named-throttlers.js +1 -1
  96. package/dist/kernel.module.js +0 -3
  97. package/dist/orgs/settings.service.js +5 -10
  98. package/dist/overrides.d.ts +0 -4
  99. package/dist/overrides.js +0 -2
  100. package/dist/platform/exclusions.js +5 -5
  101. package/dist/platform/ops/admin.ops.js +1 -1
  102. package/dist/platform/ops/conversations.ops.js +5 -2
  103. package/dist/platform/ops/devices.ops.js +11 -24
  104. package/dist/platform/ops/inbox.ops.js +1 -1
  105. package/dist/roles/gateway-role.d.ts +3 -3
  106. package/dist/roles/gateway-role.js +4 -4
  107. package/dist/roles/gateway.module.d.ts +1 -1
  108. package/dist/roles/gateway.module.js +5 -5
  109. package/dist/runtime/context/device-paths.d.ts +4 -1
  110. package/dist/runtime/context/permission-profile.js +5 -5
  111. package/dist/runtime/maintenance.d.ts +2 -5
  112. package/dist/runtime/maintenance.js +9 -19
  113. package/dist/runtime/project/knowledge.js +4 -5
  114. package/dist/runtime/project/knowledge.service.js +2 -1
  115. package/dist/sandbox/cloud-permission-snapshot.d.ts +1 -1
  116. package/dist/sandbox/cloud-permission-snapshot.js +1 -3
  117. package/dist/sandbox/device-reports.d.ts +74 -14
  118. package/dist/sandbox/device-reports.js +190 -33
  119. package/dist/sandbox/device-reports.module.d.ts +7 -0
  120. package/dist/sandbox/device-reports.module.js +25 -0
  121. package/dist/sandbox/device-sandbox.d.ts +39 -41
  122. package/dist/sandbox/device-sandbox.js +44 -83
  123. package/dist/sandbox/kernel-read.d.ts +2 -2
  124. package/dist/sandbox/legacy-retirement.d.ts +11 -59
  125. package/dist/sandbox/legacy-retirement.js +34 -186
  126. package/dist/sandbox/legacy-retirement.module.d.ts +2 -2
  127. package/dist/sandbox/legacy-retirement.module.js +2 -2
  128. package/dist/sandbox/managed-device-context.d.ts +16 -4
  129. package/dist/sandbox/managed-device-context.js +25 -8
  130. package/dist/sandbox/managed-device-context.module.js +4 -0
  131. package/dist/sandbox/modes.d.ts +3 -12
  132. package/dist/sandbox/modes.js +2 -14
  133. package/dist/{local-devices → sandbox}/network-grants.d.ts +2 -21
  134. package/dist/{local-devices → sandbox}/network-grants.js +4 -49
  135. package/dist/sandbox/operation-authority-types.d.ts +2 -1
  136. package/dist/sandbox/operation-authority.d.ts +6 -20
  137. package/dist/sandbox/operation-authority.js +43 -104
  138. package/dist/sandbox/operation-authority.module.js +1 -1
  139. package/dist/sandbox/operation-intents.d.ts +4 -1
  140. package/dist/sandbox/operation-intents.js +11 -2
  141. package/dist/sandbox/operation-reconcile.job.js +2 -4
  142. package/dist/sandbox/permission-availability.d.ts +6 -7
  143. package/dist/sandbox/permission-availability.js +7 -10
  144. package/dist/sandbox/permission-call-grants.d.ts +2 -1
  145. package/dist/sandbox/permission-call-grants.js +1 -7
  146. package/dist/sandbox/permission-call-types.d.ts +4 -4
  147. package/dist/sandbox/permission-ceiling-writes.d.ts +7 -23
  148. package/dist/sandbox/permission-ceiling-writes.js +8 -35
  149. package/dist/sandbox/permission-config-publication.d.ts +9 -1
  150. package/dist/sandbox/permission-config-publication.js +29 -21
  151. package/dist/sandbox/permission-context-types.d.ts +17 -10
  152. package/dist/sandbox/permission-facts.d.ts +98 -95
  153. package/dist/sandbox/permission-facts.js +160 -314
  154. package/dist/sandbox/permission-instance-writes.d.ts +23 -37
  155. package/dist/sandbox/permission-instance-writes.js +44 -121
  156. package/dist/sandbox/permission-runtime-reports.d.ts +38 -30
  157. package/dist/sandbox/permission-runtime-reports.js +105 -122
  158. package/dist/sandbox/providers.d.ts +26 -38
  159. package/dist/sandbox/providers.js +36 -18
  160. package/dist/sandbox/request-not-sent.d.ts +2 -13
  161. package/dist/sandbox/request-not-sent.js +2 -13
  162. package/dist/sandbox/review/permission-candidate.d.ts +13 -8
  163. package/dist/sandbox/review/permission-candidate.js +38 -48
  164. package/dist/sandbox/sandbox.module.js +7 -3
  165. package/dist/sandbox/sandbox.service.d.ts +49 -59
  166. package/dist/sandbox/sandbox.service.js +139 -259
  167. package/dist/schedules/fire.d.ts +15 -6
  168. package/dist/schedules/fire.js +27 -13
  169. package/dist/schedules/grant-rules.js +1 -1
  170. package/dist/schedules/scheduled-tasks.service.d.ts +0 -7
  171. package/dist/schedules/scheduled-tasks.service.js +1 -4
  172. package/dist/schedules/schedules.module.js +5 -3
  173. package/dist/skills/invoke.d.ts +1 -1
  174. package/dist/skills/invoke.js +2 -3
  175. package/dist/tools/approvals.service.d.ts +8 -5
  176. package/dist/tools/approvals.service.js +5 -5
  177. package/dist/tools/builtins/sandbox/bash.js +1 -2
  178. package/dist/tools/builtins/sandbox/common.d.ts +15 -9
  179. package/dist/tools/builtins/sandbox/common.js +37 -38
  180. package/dist/tools/network-asks.d.ts +19 -22
  181. package/dist/tools/network-asks.js +15 -21
  182. package/dist/tools/pipeline.d.ts +6 -7
  183. package/dist/tools/pipeline.js +17 -21
  184. package/dist/tools/tools.module.js +3 -7
  185. package/package.json +3 -4
  186. package/src/migrations/0177_dial_in_contract.sql +32 -0
  187. package/dist/local-devices/device-auth.module.d.ts +0 -7
  188. package/dist/local-devices/device-auth.module.js +0 -25
  189. package/dist/local-devices/device-policy.service.d.ts +0 -213
  190. package/dist/local-devices/device-policy.service.js +0 -605
  191. package/dist/local-devices/instance-bindings.d.ts +0 -82
  192. package/dist/local-devices/instance-bindings.js +0 -307
  193. package/dist/local-devices/local-device-gateway.d.ts +0 -153
  194. package/dist/local-devices/local-device-provider.d.ts +0 -122
  195. package/dist/local-devices/local-device-provider.js +0 -326
  196. package/dist/local-devices/local-devices.module.d.ts +0 -31
  197. package/dist/local-devices/local-devices.module.js +0 -100
  198. package/dist/local-devices/machines.d.ts +0 -211
  199. package/dist/local-devices/machines.js +0 -766
  200. package/dist/local-devices/owner-report.d.ts +0 -81
  201. package/dist/local-devices/owner-report.js +0 -150
  202. package/dist/local-devices/owner-reports.d.ts +0 -48
  203. package/dist/local-devices/owner-reports.js +0 -208
  204. package/dist/local-devices/policy-op-jobs.d.ts +0 -15
  205. package/dist/local-devices/policy-op-jobs.js +0 -12
  206. package/dist/local-devices/policy-summary.d.ts +0 -102
  207. package/dist/local-devices/policy-summary.js +0 -155
  208. package/dist/local-devices/relay.d.ts +0 -166
  209. package/dist/local-devices/relay.js +0 -559
  210. package/dist/tools/device-op-resolver.d.ts +0 -34
  211. package/dist/tools/device-op-resolver.js +0 -120
  212. /package/dist/{local-devices → dial-in}/keys.d.ts +0 -0
  213. /package/dist/{local-devices → dial-in}/keys.js +0 -0
  214. /package/dist/{local-devices → sandbox}/network-grants.module.d.ts +0 -0
  215. /package/dist/{local-devices → sandbox}/network-grants.module.js +0 -0
@@ -20,6 +20,7 @@ import { PushModule } from "../push/push.module.js";
20
20
  import { ProvidersModule } from "../runtime/providers.js";
21
21
  import { RunJobsModule } from "../runtime/run-jobs.js";
22
22
  import { UsageReportModule } from "../runtime/usage-report.js";
23
+ import { SandboxProviderRegistryModule } from "../sandbox/providers.module.js";
23
24
  import { AuditLogService } from "./audit-log.service.js";
24
25
  import { AdminHealthService } from "./health.service.js";
25
26
  import { OrgNetworkAdmin } from "./org-network.service.js";
@@ -39,6 +40,7 @@ let AdminModule = class AdminModule {
39
40
  AdminModule = __decorate([
40
41
  Module({
41
42
  imports: [
43
+ SandboxProviderRegistryModule,
42
44
  IdentityModule,
43
45
  OrgsModule,
44
46
  SetupLockModule,
@@ -3,6 +3,7 @@ import type { Redis } from "ioredis";
3
3
  import { KernelDb } from "../infra/database/kernel-db.js";
4
4
  import { type LiveReplica, ReplicaPresence } from "../infra/presence/replica-presence.js";
5
5
  import type { KernelLogger } from "../log.js";
6
+ import { DeviceProviders } from "../sandbox/providers.js";
6
7
  /** The kernel's own queues, in the order the overview lists them (extension queues are not read). */
7
8
  export declare const KERNEL_QUEUE_NAMES: readonly ["cap-kernel-runs", "cap-kernel-subagent-runs", "cap-kernel-channels", "cap-kernel-maintenance", "cap-kernel-plugin-scope", "cap-kernel-titles", "cap-kernel-suggestions", "cap-kernel-usage-report", "cap-kernel-evals", "cap-kernel-lifecycle", "cap-push-deliver"];
8
9
  /** How long each source's reads may take before the answer marks it unavailable. */
@@ -66,12 +67,17 @@ export interface AdminHealth {
66
67
  error: number | null;
67
68
  };
68
69
  /**
69
- * `local`: local devices (not deleted, org not deleted); `online`: the devices whose connection a
70
- * live replica holds (lease held), at most `local`.
70
+ * Live devices (not deleted, org not deleted) per provider (most first); `dialIn`: those of the
71
+ * providers loaded here that serve their devices over the dial-in channel; `online`: the devices
72
+ * whose connection a live replica holds (lease held), at most `dialIn`.
71
73
  */
72
74
  devices: {
73
75
  online: number | null;
74
- local: number | null;
76
+ dialIn: number | null;
77
+ byProvider: {
78
+ provider: string;
79
+ devices: number;
80
+ }[] | null;
75
81
  };
76
82
  /** Sandbox instances by status, and running ones per provider (most first). */
77
83
  sandboxes: {
@@ -96,8 +102,9 @@ export declare class AdminHealthService {
96
102
  private readonly db;
97
103
  private readonly redis;
98
104
  private readonly log;
105
+ private readonly providers;
99
106
  private readonly queues;
100
- constructor(presence: Pick<ReplicaPresence, "live">, db: KernelDb, redis: Pick<Redis, "zcount" | "status">, log: Pick<KernelLogger, "warn">, runs: Queue, subagentRuns: Queue, channels: Queue, maintenance: Queue, pluginScope: Queue, titles: Queue, suggestions: Queue, usageReport: Queue, evals: Queue, lifecycle: Queue, push: Queue);
107
+ constructor(presence: Pick<ReplicaPresence, "live">, db: KernelDb, redis: Pick<Redis, "zcount" | "status">, log: Pick<KernelLogger, "warn">, providers: Pick<DeviceProviders, "forDevice">, runs: Queue, subagentRuns: Queue, channels: Queue, maintenance: Queue, pluginScope: Queue, titles: Queue, suggestions: Queue, usageReport: Queue, evals: Queue, lifecycle: Queue, push: Queue);
101
108
  read(): Promise<AdminHealth>;
102
109
  private readRedis;
103
110
  private readDb;
@@ -23,6 +23,7 @@ import { PUSH_QUEUE } from "../push/jobs.js";
23
23
  import { MAINTENANCE_QUEUE_NAME } from "../runtime/maintenance-queue.js";
24
24
  import { RUN_QUEUE_NAME, SUBAGENT_RUN_QUEUE_NAME } from "../runtime/run-jobs.js";
25
25
  import { USAGE_REPORT_QUEUE } from "../runtime/usage-report-jobs.js";
26
+ import { DeviceProviders, servesDialIn } from "../sandbox/providers.js";
26
27
  import { KERNEL_VERSION } from "../version.js";
27
28
  /** The kernel's own queues, in the order the overview lists them (extension queues are not read). */
28
29
  export const KERNEL_QUEUE_NAMES = [
@@ -63,12 +64,14 @@ let AdminHealthService = class AdminHealthService {
63
64
  db;
64
65
  redis;
65
66
  log;
67
+ providers;
66
68
  queues;
67
- constructor(presence, db, redis, log, runs, subagentRuns, channels, maintenance, pluginScope, titles, suggestions, usageReport, evals, lifecycle, push) {
69
+ constructor(presence, db, redis, log, providers, runs, subagentRuns, channels, maintenance, pluginScope, titles, suggestions, usageReport, evals, lifecycle, push) {
68
70
  this.presence = presence;
69
71
  this.db = db;
70
72
  this.redis = redis;
71
73
  this.log = log;
74
+ this.providers = providers;
72
75
  // the order of KERNEL_QUEUE_NAMES
73
76
  this.queues = [
74
77
  runs,
@@ -109,7 +112,18 @@ let AdminHealthService = class AdminHealthService {
109
112
  // Each replica counts only the devices whose lease it holds, so a device is online on at most
110
113
  // one; the clamp covers a lease handover in flight and devices deleted while still connected
111
114
  const connected = sum("devicesConnected");
112
- const devicesOnline = connected === null || db === null ? connected : Math.min(connected, db.localDevices);
115
+ const dialIn = db === null
116
+ ? null
117
+ : db.devices.reduce((n, d) => {
118
+ const p = this.providers.forDevice(d.provider);
119
+ return p !== undefined && servesDialIn(p) ? n + d.n : n;
120
+ }, 0);
121
+ const devicesOnline = connected === null || dialIn === null ? connected : Math.min(connected, dialIn);
122
+ const devicesByProvider = db === null
123
+ ? null
124
+ : db.devices
125
+ .flatMap((d) => (d.provider === null ? [] : [{ provider: d.provider, devices: d.n }]))
126
+ .sort((a, b) => b.devices - a.devices || a.provider.localeCompare(b.provider));
113
127
  let sandboxes = null;
114
128
  if (db !== null) {
115
129
  const byProvider = new Map();
@@ -157,7 +171,7 @@ let AdminHealthService = class AdminHealthService {
157
171
  disabled: channelCount((c) => c.status === "disabled"),
158
172
  error: channelCount((c) => c.status === "error"),
159
173
  },
160
- devices: { online: devicesOnline, local: db?.localDevices ?? null },
174
+ devices: { online: devicesOnline, dialIn, byProvider: devicesByProvider },
161
175
  sandboxes,
162
176
  unavailable,
163
177
  };
@@ -209,11 +223,12 @@ let AdminHealthService = class AdminHealthService {
209
223
  db
210
224
  .selectFrom("devices as d")
211
225
  .innerJoin("orgs as o", "o.id", "d.org_id")
226
+ .select(["d.provider as provider"])
212
227
  .select(sql `count(*)`.as("n"))
213
- .where("d.source", "=", "local")
214
228
  .where("d.deleted_at", "is", null)
215
229
  .where("o.deleted_at", "is", null)
216
- .executeTakeFirst(),
230
+ .groupBy("d.provider")
231
+ .execute(),
217
232
  // the partial indexes on device_instances (running / live) serve these statuses; an
218
233
  // instance of a deleted org is left out like its channels and devices
219
234
  db
@@ -228,7 +243,7 @@ let AdminHealthService = class AdminHealthService {
228
243
  ]);
229
244
  return {
230
245
  channels: channels.map((c) => ({ status: c.status, mode: c.mode, n: Number(c.n) })),
231
- localDevices: Number(devices?.n ?? 0),
246
+ devices: devices.map((d) => ({ provider: d.provider, n: Number(d.n) })),
232
247
  instances: instances.map((i) => ({
233
248
  provider: i.provider,
234
249
  status: i.status,
@@ -243,16 +258,17 @@ AdminHealthService = __decorate([
243
258
  __param(1, Inject(KernelDb)),
244
259
  __param(2, Inject(REDIS)),
245
260
  __param(3, Inject(KERNEL_LOGGER)),
246
- __param(4, Inject(getQueueToken(RUN_QUEUE_NAME))),
247
- __param(5, Inject(getQueueToken(SUBAGENT_RUN_QUEUE_NAME))),
248
- __param(6, Inject(getQueueToken(CHANNEL_QUEUE_NAME))),
249
- __param(7, Inject(getQueueToken(MAINTENANCE_QUEUE_NAME))),
250
- __param(8, Inject(getQueueToken(PLUGIN_SCOPE_QUEUE))),
251
- __param(9, Inject(getQueueToken(TITLE_QUEUE))),
252
- __param(10, Inject(getQueueToken(PROMPT_SUGGESTION_QUEUE))),
253
- __param(11, Inject(getQueueToken(USAGE_REPORT_QUEUE))),
254
- __param(12, Inject(getQueueToken(EVAL_QUEUE_NAME))),
255
- __param(13, Inject(getQueueToken(LIFECYCLE_QUEUE))),
256
- __param(14, Inject(getQueueToken(PUSH_QUEUE)))
261
+ __param(4, Inject(DeviceProviders)),
262
+ __param(5, Inject(getQueueToken(RUN_QUEUE_NAME))),
263
+ __param(6, Inject(getQueueToken(SUBAGENT_RUN_QUEUE_NAME))),
264
+ __param(7, Inject(getQueueToken(CHANNEL_QUEUE_NAME))),
265
+ __param(8, Inject(getQueueToken(MAINTENANCE_QUEUE_NAME))),
266
+ __param(9, Inject(getQueueToken(PLUGIN_SCOPE_QUEUE))),
267
+ __param(10, Inject(getQueueToken(TITLE_QUEUE))),
268
+ __param(11, Inject(getQueueToken(PROMPT_SUGGESTION_QUEUE))),
269
+ __param(12, Inject(getQueueToken(USAGE_REPORT_QUEUE))),
270
+ __param(13, Inject(getQueueToken(EVAL_QUEUE_NAME))),
271
+ __param(14, Inject(getQueueToken(LIFECYCLE_QUEUE))),
272
+ __param(15, Inject(getQueueToken(PUSH_QUEUE)))
257
273
  ], AdminHealthService);
258
274
  export { AdminHealthService };
@@ -106,8 +106,8 @@ let BackgroundTaskPollJob = class BackgroundTaskPollJob {
106
106
  if (signal.aborted)
107
107
  break;
108
108
  try {
109
- // the device's provider does not serve its org now (off in the org, not loaded, `@local`
110
- // not registered): its tasks stay as they are until it does. A task without a device
109
+ // the device's provider does not serve its org now (off in the org or not loaded): its
110
+ // tasks stay as they are until it does. A task without a device
111
111
  // needs no provider: pollLegacy finishes it as gone.
112
112
  const first = tasks[0];
113
113
  if (first?.deviceId && !(await this.sandbox.availableFor(first.deviceId, first.orgId))) {
@@ -38,10 +38,10 @@ export interface BackgroundTaskView {
38
38
  * finished legacy one, whose output is never read live).
39
39
  */
40
40
  export type OutputUnavailableReason = "starting" | "not_started" | "device_offline" | "suspended" | "rebuilt" | "output_missing" | "no_access" | "unavailable" | "read_failed";
41
- /** Why the live read failed, and where the task ran: a `local` device or a `cloud` sandbox. */
41
+ /** Why the live read failed, and the provider of the device the task ran on (null: none known). */
42
42
  export interface OutputUnavailable {
43
43
  reason: OutputUnavailableReason;
44
- environment: "local" | "cloud";
44
+ provider: string | null;
45
45
  }
46
46
  export interface BackgroundTaskOutput {
47
47
  text: string;
@@ -94,11 +94,11 @@ export declare class BackgroundTasks {
94
94
  * The end of the task's output, at most `tail` bytes. Read live when the task's device
95
95
  * instance runs (never resuming a suspended one); a finished task that cannot be read live
96
96
  * answers with the last lines its finished event kept and why (`unavailable`). Anything else is
97
- * `background_task.output_unavailable` (409) with `details: [{ reason, environment }]`.
97
+ * `background_task.output_unavailable` (409) with `details: [{ reason, provider }]`.
98
98
  */
99
99
  output(orgId: string, conversationId: string, accountId: string, taskId: string, tail: number): Promise<BackgroundTaskOutput>;
100
- /** Whether the task ran on a local device (its machine) or in a cloud sandbox. */
101
- private environmentOf;
100
+ /** The provider of the device the task ran on (`devices.provider`); null when none is known. */
101
+ private providerOf;
102
102
  /** Reads the output from the task's running instance, or says why it cannot. */
103
103
  private readLive;
104
104
  /**
@@ -7,7 +7,8 @@ var __decorate = (this && this.__decorate) || function (decorators, target, key,
7
7
  var __param = (this && this.__param) || function (paramIndex, decorator) {
8
8
  return function (target, key) { decorator(target, key, paramIndex); }
9
9
  };
10
- import { DeviceProtocolError, isSandboxGoneError, isSandboxPermissionUnsupportedError, isSandboxScopeDeniedError, ToolError, } from "@capybara-hq/plugin-sdk";
10
+ import { isSandboxGoneError, isSandboxPermissionUnsupportedError, isSandboxScopeDeniedError, ToolError, } from "@capybara-hq/plugin-sdk";
11
+ import { DeviceProtocolError } from "@capybara-hq/plugin-sdk/device-protocol";
11
12
  import { Inject, Injectable } from "@nestjs/common";
12
13
  import { ConversationAccess } from "../conversations/access.js";
13
14
  import { EventLog } from "../conversations/event-log.js";
@@ -149,7 +150,7 @@ let BackgroundTasks = class BackgroundTasks {
149
150
  * The end of the task's output, at most `tail` bytes. Read live when the task's device
150
151
  * instance runs (never resuming a suspended one); a finished task that cannot be read live
151
152
  * answers with the last lines its finished event kept and why (`unavailable`). Anything else is
152
- * `background_task.output_unavailable` (409) with `details: [{ reason, environment }]`.
153
+ * `background_task.output_unavailable` (409) with `details: [{ reason, provider }]`.
153
154
  */
154
155
  async output(orgId, conversationId, accountId, taskId, tail) {
155
156
  const task = await this.owned(orgId, conversationId, accountId, taskId);
@@ -158,7 +159,7 @@ let BackgroundTasks = class BackgroundTasks {
158
159
  return { ...read.value, source: "live" };
159
160
  const unavailable = {
160
161
  reason: read.reason,
161
- environment: await this.environmentOf(task.deviceId),
162
+ provider: await this.providerOf(task.deviceId),
162
163
  };
163
164
  if (task.status !== "running") {
164
165
  const ev = await this.eventLog.findByIdem(task.conversationId, finishedEventKey(task.id));
@@ -168,16 +169,16 @@ let BackgroundTasks = class BackgroundTasks {
168
169
  }
169
170
  throw new ApiError("background_task.output_unavailable", `The task's output cannot be read now (${unavailable.reason})`, [unavailable]);
170
171
  }
171
- /** Whether the task ran on a local device (its machine) or in a cloud sandbox. */
172
- async environmentOf(deviceId) {
172
+ /** The provider of the device the task ran on (`devices.provider`); null when none is known. */
173
+ async providerOf(deviceId) {
173
174
  if (deviceId === null)
174
- return "cloud";
175
+ return null;
175
176
  const row = await this.db.db
176
177
  .selectFrom("devices")
177
- .select("source")
178
+ .select("provider")
178
179
  .where("id", "=", deviceId)
179
180
  .executeTakeFirst();
180
- return row?.source === "local" ? "local" : "cloud";
181
+ return row?.provider ?? null;
181
182
  }
182
183
  /** Reads the output from the task's running instance, or says why it cannot. */
183
184
  async readLive(orgId, task, tail) {
@@ -203,7 +203,7 @@ export declare function headsToResolve(entries: readonly MarketplaceEntry[], imp
203
203
  /** The host versions (an entry's `minKernel` is judged against them). */
204
204
  export declare const HOST_VERSIONS: {
205
205
  readonly kernel: string;
206
- readonly sdk: "0.1.0-rc.52";
206
+ readonly sdk: "0.1.0-rc.54";
207
207
  };
208
208
  /** Whether this deployment satisfies the entry's `minKernel`. */
209
209
  export declare const entryCompatible: (e: Pick<MarketplaceEntry, "minKernel">) => boolean;
@@ -21,11 +21,11 @@ import { TransactionHost } from "../infra/database/transaction-host.js";
21
21
  import { Transactional } from "../infra/database/transactional.decorator.js";
22
22
  import { LockService } from "../infra/lock/lock.service.js";
23
23
  import { WithLock } from "../infra/lock/with-lock.decorator.js";
24
- import { orgAllows } from "../local-devices/network-grants.js";
25
24
  import { OrgLock } from "../orgs/org-lock.js";
26
25
  import { roleAtLeast } from "../orgs/roles.js";
27
26
  import { ORG_SANDBOX_ALLOW_HOSTS_MAX, OrgSettingsService, readOrgSettings, } from "../orgs/settings.service.js";
28
27
  import { orgEffectiveHosts, orgHostOutsideCeiling } from "../sandbox/modes.js";
28
+ import { orgAllows } from "../sandbox/network-grants.js";
29
29
  import { CatalogService } from "./catalog.service.js";
30
30
  import { CatalogScopeService } from "./catalog-scope.service.js";
31
31
  import { assertEntryNotDeprecated, loadMarketplaceEntry } from "./marketplaces.service.js";
@@ -295,7 +295,7 @@ export declare const KernelConfigSchema: z.ZodObject<{
295
295
  }>>;
296
296
  }, z.core.$strict>>;
297
297
  maxPersonal: z.ZodDefault<z.ZodNumber>;
298
- local: z.ZodPrefault<z.ZodObject<{
298
+ dialIn: z.ZodPrefault<z.ZodObject<{
299
299
  reconnectGraceSeconds: z.ZodDefault<z.ZodNumber>;
300
300
  leaseTtlMs: z.ZodDefault<z.ZodNumber>;
301
301
  authCodeTtlSeconds: z.ZodDefault<z.ZodNumber>;
@@ -1616,7 +1616,7 @@ export const KernelConfigSchema = z.strictObject({
1616
1616
  })
1617
1617
  .default("allowlist")
1618
1618
  .meta(meta({
1619
- description: "Outbound network kill switch of sandboxed devices: allowlist (the normal setting) or none. none cuts every network the kernel controls: a cloud device reaches no host (an empty allowlist) and a local device in sandbox mode has an empty allowlist; a local device in auto mode uses the machine's own network, which the kernel cannot cut",
1619
+ description: "Outbound network kill switch of sandboxed devices: allowlist (the normal setting) or none. none cuts every network the kernel controls: every device's sandbox reaches no host (an empty allowlist); a command a provider runs outside its sandbox (a per-call escalation) is outside what the kernel cuts",
1620
1620
  })),
1621
1621
  allowHosts: z
1622
1622
  .array(z.string())
@@ -1629,7 +1629,7 @@ export const KernelConfigSchema = z.strictObject({
1629
1629
  });
1630
1630
  })
1631
1631
  .meta(meta({
1632
- description: "Host list of the allowlist: in sandbox mode, the hosts a cloud device instance may reach on allowlist and a local device's allowlist; organizations follow it, adding or dropping hosts of their own (see orgHosts); lowercase hostnames, optional leading '*.', no IPs, ports or internal-only names; applies to instances created after the change",
1632
+ description: "Host list of the allowlist: in sandbox mode, the hosts a device's sandbox may reach on allowlist; organizations follow it, adding or dropping hosts of their own (see orgHosts); lowercase hostnames, optional leading '*.', no IPs, ports or internal-only names; applies to instances created after the change",
1633
1633
  })),
1634
1634
  orgHosts: z
1635
1635
  .enum(["extend", "within"])
@@ -1705,9 +1705,9 @@ export const KernelConfigSchema = z.strictObject({
1705
1705
  .default(10)
1706
1706
  .meta(meta({
1707
1707
  hot: true,
1708
- description: "Most personal devices a member may have in one org, the default one and local devices included; creating one more fails with device.limit_reached",
1708
+ description: "Most personal devices a member may have in one org, the default one and dial-in devices included; creating one more fails with device.limit_reached",
1709
1709
  })),
1710
- local: z
1710
+ dialIn: z
1711
1711
  .strictObject({
1712
1712
  reconnectGraceSeconds: z
1713
1713
  .number()
@@ -1716,7 +1716,7 @@ export const KernelConfigSchema = z.strictObject({
1716
1716
  .default(120)
1717
1717
  .meta(meta({
1718
1718
  hot: true,
1719
- description: "Seconds a local device's machine may stay disconnected before the device is reported offline; also sent to capybara-device at sign-in",
1719
+ description: "Seconds a dial-in device's machine may stay disconnected before the device is reported offline; also sent to the machine's program at sign-in",
1720
1720
  })),
1721
1721
  leaseTtlMs: z
1722
1722
  .number()
@@ -1724,7 +1724,7 @@ export const KernelConfigSchema = z.strictObject({
1724
1724
  .min(6000)
1725
1725
  .default(30000)
1726
1726
  .meta(meta({
1727
- description: "Milliseconds the replica holding a local device's connection keeps its lease without renewing it; at least 6000",
1727
+ description: "Milliseconds the replica holding a dial-in device's connection keeps its lease without renewing it; at least 6000",
1728
1728
  })),
1729
1729
  authCodeTtlSeconds: z
1730
1730
  .number()
@@ -1732,7 +1732,7 @@ export const KernelConfigSchema = z.strictObject({
1732
1732
  .positive()
1733
1733
  .default(600)
1734
1734
  .meta(meta({
1735
- description: "Seconds a device sign-in code stays valid before capybara-device must start over (device_sign_in.expired)",
1735
+ description: "Seconds a device sign-in code stays valid before the machine's program must start over (device_sign_in.expired)",
1736
1736
  })),
1737
1737
  pollIntervalSeconds: z
1738
1738
  .number()
@@ -1740,7 +1740,7 @@ export const KernelConfigSchema = z.strictObject({
1740
1740
  .positive()
1741
1741
  .default(5)
1742
1742
  .meta(meta({
1743
- description: "Seconds capybara-device waits between token polls during sign-in; polling faster gets device_sign_in.slow_down",
1743
+ description: "Seconds the machine's program waits between token polls during sign-in; polling faster gets device_sign_in.slow_down",
1744
1744
  })),
1745
1745
  maxFrameBytes: z
1746
1746
  .number()
@@ -1748,7 +1748,7 @@ export const KernelConfigSchema = z.strictObject({
1748
1748
  .positive()
1749
1749
  .default(16 * 1024 * 1024)
1750
1750
  .meta(meta({
1751
- description: "Largest WebSocket frame in bytes accepted from or sent to a local device's machine",
1751
+ description: "Largest WebSocket frame in bytes accepted from or sent to a dial-in device's machine",
1752
1752
  })),
1753
1753
  })
1754
1754
  .prefault({}),
@@ -8,7 +8,7 @@ import { ConversationToolInfo, type ToolInfo } from "../tools/info.js";
8
8
  import type { AgentTreeNode } from "./agent-tree.js";
9
9
  import { type ArtifactPreview, ConversationArtifacts } from "./artifacts.js";
10
10
  import { CompactBody, EventsQuery, FilesQuery, IdParams, ListQuery, PatchBody, SubagentsQuery } from "./conversations.schemas.js";
11
- import { type ConversationGroup, ConversationsService, type ConversationView, type SubagentView, type UsageTotals } from "./conversations.service.js";
11
+ import { type ConversationGroup, type ConversationListRow, ConversationsService, type ConversationView, type SubagentView, type UsageTotals } from "./conversations.service.js";
12
12
  import { ConversationDeviceStatus } from "./device-status.js";
13
13
  import type { ConversationEvent } from "./events.js";
14
14
  import { ConversationFiles, type FileOutput } from "./files.js";
@@ -160,10 +160,15 @@ export declare class ConversationsController {
160
160
  }>;
161
161
  /** Soft delete (owner only): stops an active run and hides the conversation everywhere. */
162
162
  remove(principal: Principal, org: OrgContext, { id }: z.infer<typeof IdParams>): Promise<void>;
163
- /** 我的会话,最近更新的在前:`next` 为下一页游标(作为 `after` 传回),没有更多时为 null。 */
163
+ /**
164
+ * My conversations, most recently updated first, each with its agent: `next` is the next page's
165
+ * cursor (passed back as `after`), null when there are no more; `total` counts every match of
166
+ * the filters and comes on the first page (no `after`) only.
167
+ */
164
168
  list(principal: Principal, org: OrgContext, q: z.infer<typeof ListQuery>): Promise<{
165
- conversations: ConversationView[];
169
+ conversations: ConversationListRow[];
166
170
  next: string | null;
171
+ total?: number;
167
172
  }>;
168
173
  /**
169
174
  * My conversations grouped by agent, for the sidebar: groups by latest activity, `perGroup`
@@ -246,11 +246,16 @@ let ConversationsController = class ConversationsController {
246
246
  const p = requireUser(principal);
247
247
  await this.conversations.remove(org.orgId, id, p.account.id);
248
248
  }
249
- /** 我的会话,最近更新的在前:`next` 为下一页游标(作为 `after` 传回),没有更多时为 null。 */
249
+ /**
250
+ * My conversations, most recently updated first, each with its agent: `next` is the next page's
251
+ * cursor (passed back as `after`), null when there are no more; `total` counts every match of
252
+ * the filters and comes on the first page (no `after`) only.
253
+ */
250
254
  async list(principal, org, q) {
251
255
  const p = requireUser(principal);
252
- const rows = await this.conversations.listMine(org.orgId, p.account.id, {
256
+ const { conversations: rows, total } = await this.conversations.listMine(org.orgId, p.account.id, {
253
257
  limit: q.limit + 1,
258
+ total: q.after === undefined,
254
259
  ...(q.after !== undefined && { after: q.after }),
255
260
  ...(q.agentId !== undefined && { agentId: q.agentId }),
256
261
  ...(q.q !== undefined && { q: q.q }),
@@ -259,7 +264,7 @@ let ConversationsController = class ConversationsController {
259
264
  });
260
265
  const conversations = rows.slice(0, q.limit);
261
266
  const next = rows.length > q.limit ? (conversations.at(-1)?.id ?? null) : null;
262
- return { conversations, next };
267
+ return { conversations, next, ...(total !== undefined && { total }) };
263
268
  }
264
269
  /**
265
270
  * My conversations grouped by agent, for the sidebar: groups by latest activity, `perGroup`
@@ -87,20 +87,26 @@ export type ProjectState = {
87
87
  };
88
88
  /** Escapes `\`, `%` and `_` so user text is matched literally by `LIKE … ESCAPE '\'`. */
89
89
  export declare function escapeLike(s: string): string;
90
+ /**
91
+ * An agent as the conversation lists carry it: its name and the avatar half of its profile, in the
92
+ * agents API's shape (the web draws it without reading the agents list).
93
+ */
94
+ export interface ConversationAgent {
95
+ id: string;
96
+ name: string;
97
+ profile: {
98
+ avatar: AgentAvatarView;
99
+ updatedAt: string;
100
+ };
101
+ }
102
+ /** One row of {@link ConversationsService.listMine}: the conversation and its agent. */
103
+ export interface ConversationListRow extends ConversationView {
104
+ /** Null only when the agent stopped being visible between the page read and the agent read. */
105
+ agent: ConversationAgent | null;
106
+ }
90
107
  /** One agent's group in the sidebar list: the caller's newest conversations with that agent. */
91
108
  export interface ConversationGroup {
92
- /**
93
- * The agent's name and the avatar half of its profile, in the agents API's shape (the sidebar
94
- * draws the group title from it without reading the agents list).
95
- */
96
- agent: {
97
- id: string;
98
- name: string;
99
- profile: {
100
- avatar: AgentAvatarView;
101
- updatedAt: string;
102
- };
103
- };
109
+ agent: ConversationAgent;
104
110
  /** max(updated_at) of the group's conversations. */
105
111
  latestAt: Date;
106
112
  /** At most `perGroup`, updated_at DESC, id DESC. */
@@ -424,8 +430,11 @@ export declare class ConversationsService {
424
430
  /** The stream's visibility check ({@link ConversationAccess.isAccessible}). */
425
431
  isAccessible(orgId: string, conversationId: string, viewerAccountId: string): Promise<boolean>;
426
432
  /**
427
- * 我的会话,最近更新的在前;只含 agent 仍可用的会话。`after` 为上一页最后一个会话的 id,
428
- * 从它当前的 (updated_at, id) 之后继续;游标会话已不存在时返回空页。
433
+ * My conversations, most recently updated first; only those whose agent is in this org, not
434
+ * deleted and visible to me. `after` is the previous page's last conversation id, continued after
435
+ * its current (updated_at, id); a cursor that no longer exists gives an empty page. Each row
436
+ * carries its agent (one batch read for the page). With `total`, also counts every conversation
437
+ * matching the same filters (the cursor aside) in the same statement.
429
438
  */
430
439
  listMine(orgId: string, accountId: string, opts: {
431
440
  after?: string;
@@ -434,7 +443,16 @@ export declare class ConversationsService {
434
443
  archived?: boolean;
435
444
  q?: string;
436
445
  state?: "running" | "waiting";
437
- }): Promise<ConversationView[]>;
446
+ total?: boolean;
447
+ }): Promise<{
448
+ conversations: ConversationListRow[];
449
+ total?: number;
450
+ }>;
451
+ /**
452
+ * The agents of `ids` that are in this org, not deleted and visible to the viewer, by id, in one
453
+ * statement (the same visibility as the agents read path).
454
+ */
455
+ private listAgents;
438
456
  /**
439
457
  * My chat conversations grouped by agent (the sidebar, UI refresh spec §5.9), in one statement.
440
458
  * Only agents that are not deleted and still visible to me (as {@link listMine}). Groups are
@@ -83,6 +83,17 @@ function activitySql(ref) {
83
83
  ORDER BY lr.created_at DESC, lr.id DESC LIMIT 1
84
84
  )`;
85
85
  }
86
+ /** A {@link ConversationAgent} from an agent row and its current definition's name. */
87
+ function toConversationAgent(r) {
88
+ return {
89
+ id: r.id,
90
+ name: r.name ?? "",
91
+ profile: {
92
+ avatar: avatarView(r.profile_avatar),
93
+ updatedAt: r.profile_updated_at.toISOString(),
94
+ },
95
+ };
96
+ }
86
97
  const notFound = () => new ApiError("conversation.not_found", "Conversation not found");
87
98
  export const NO_REPLY_SKIPS = { questions: [], network: [], seqs: new Map() };
88
99
  export { userMessageIdemKey } from "./idem-keys.js";
@@ -569,14 +580,21 @@ let ConversationsService = class ConversationsService {
569
580
  return this.access.isAccessible(orgId, conversationId, viewerAccountId);
570
581
  }
571
582
  /**
572
- * 我的会话,最近更新的在前;只含 agent 仍可用的会话。`after` 为上一页最后一个会话的 id,
573
- * 从它当前的 (updated_at, id) 之后继续;游标会话已不存在时返回空页。
583
+ * My conversations, most recently updated first; only those whose agent is in this org, not
584
+ * deleted and visible to me. `after` is the previous page's last conversation id, continued after
585
+ * its current (updated_at, id); a cursor that no longer exists gives an empty page. Each row
586
+ * carries its agent (one batch read for the page). With `total`, also counts every conversation
587
+ * matching the same filters (the cursor aside) in the same statement.
574
588
  */
575
589
  async listMine(orgId, accountId, opts) {
576
590
  let q = this.db
577
591
  .selectFrom("conversations")
578
592
  .select(COLUMNS)
579
593
  .select(activitySql("conversations").as("activity"))
594
+ // The total of every match, computed before LIMIT in this same statement. It costs
595
+ // O(matches) (the window reads every matching row instead of stopping at the page), which
596
+ // is why only the first page asks for it.
597
+ .$if(opts.total === true, (qb) => qb.select(sql `count(*) OVER ()`.as("total_count")))
580
598
  .where("org_id", "=", orgId)
581
599
  .where("account_id", "=", accountId)
582
600
  // 评测回放的隐藏对话(kind = 'eval')不在「我的对话」里
@@ -587,6 +605,7 @@ let ConversationsService = class ConversationsService {
587
605
  .selectFrom("agents")
588
606
  .select(sql `1`.as("one"))
589
607
  .whereRef("agents.id", "=", "conversations.agent_id")
608
+ .where("agents.org_id", "=", orgId)
590
609
  .where("agents.deleted_at", "is", null)
591
610
  .where(visibleTo(accountId))))
592
611
  .orderBy("updated_at", "desc")
@@ -607,7 +626,40 @@ let ConversationsService = class ConversationsService {
607
626
  WHERE c.id = ${after} AND c.org_id = ${orgId} AND c.account_id = ${accountId}
608
627
  )`);
609
628
  }
610
- return (await q.execute()).map(toView);
629
+ const rows = await q.execute();
630
+ const agents = await this.listAgents(orgId, accountId, [
631
+ ...new Set(rows.map((r) => r.agent_id)),
632
+ ]);
633
+ const conversations = rows.map((r) => ({
634
+ ...toView(r),
635
+ agent: agents.get(r.agent_id) ?? null,
636
+ }));
637
+ if (opts.total !== true)
638
+ return { conversations };
639
+ return { conversations, total: Number(rows[0]?.total_count ?? 0) };
640
+ }
641
+ /**
642
+ * The agents of `ids` that are in this org, not deleted and visible to the viewer, by id, in one
643
+ * statement (the same visibility as the agents read path).
644
+ */
645
+ async listAgents(orgId, viewerAccountId, ids) {
646
+ if (ids.length === 0)
647
+ return new Map();
648
+ const rows = await this.db
649
+ .selectFrom("agents")
650
+ .innerJoin("agent_versions as v", (j) => j.onRef("v.agent_id", "=", "agents.id").onRef("v.version", "=", "agents.current_version"))
651
+ .select([
652
+ "agents.id",
653
+ "agents.profile_avatar",
654
+ "agents.profile_updated_at",
655
+ sql `v.definition ->> 'name'`.as("name"),
656
+ ])
657
+ .where("agents.id", "in", ids)
658
+ .where("agents.org_id", "=", orgId)
659
+ .where("agents.deleted_at", "is", null)
660
+ .where(visibleTo(viewerAccountId))
661
+ .execute();
662
+ return new Map(rows.map((r) => [r.id, toConversationAgent(r)]));
611
663
  }
612
664
  /**
613
665
  * My chat conversations grouped by agent (the sidebar, UI refresh spec §5.9), in one statement.
@@ -674,14 +726,12 @@ let ConversationsService = class ConversationsService {
674
726
  for (const r of rows) {
675
727
  if (current?.agent.id !== r.agent_id) {
676
728
  current = {
677
- agent: {
729
+ agent: toConversationAgent({
678
730
  id: r.agent_id,
679
- name: r.agent_name ?? "",
680
- profile: {
681
- avatar: avatarView(r.profile_avatar),
682
- updatedAt: r.profile_updated_at.toISOString(),
683
- },
684
- },
731
+ name: r.agent_name,
732
+ profile_avatar: r.profile_avatar,
733
+ profile_updated_at: r.profile_updated_at,
734
+ }),
685
735
  latestAt: r.latest_at,
686
736
  conversations: [],
687
737
  more: false,