@capybara-hq/kernel 0.1.0-rc.142 → 0.1.0-rc.144

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 (238) hide show
  1. package/dist/admin/admin-agents.controller.d.ts +3 -5
  2. package/dist/admin/admin-agents.controller.js +1 -1
  3. package/dist/admin/admin-connectors.controller.d.ts +3 -5
  4. package/dist/admin/admin-connectors.controller.js +1 -1
  5. package/dist/admin/admin-items.schemas.d.ts +6 -6
  6. package/dist/admin/admin-items.schemas.js +5 -9
  7. package/dist/admin/admin.controller.d.ts +18 -12
  8. package/dist/admin/admin.controller.js +29 -15
  9. package/dist/admin/admin.schemas.d.ts +12 -3
  10. package/dist/admin/admin.schemas.js +17 -6
  11. package/dist/agents/admin-agents.d.ts +10 -8
  12. package/dist/agents/admin-agents.js +13 -9
  13. package/dist/agents/agents.module.js +3 -0
  14. package/dist/agents/agents.service.js +1 -1
  15. package/dist/agents/org-templates.d.ts +3 -1
  16. package/dist/agents/org-templates.js +7 -3
  17. package/dist/agents/pending-connector-requests.d.ts +10 -4
  18. package/dist/agents/pending-connector-requests.js +29 -7
  19. package/dist/automations/automations.controller.d.ts +9 -5
  20. package/dist/automations/automations.controller.js +21 -4
  21. package/dist/automations/automations.schemas.d.ts +19 -0
  22. package/dist/automations/automations.schemas.js +9 -0
  23. package/dist/automations/automations.service.d.ts +25 -8
  24. package/dist/automations/automations.service.js +40 -34
  25. package/dist/automations/events/acceptance.d.ts +6 -1
  26. package/dist/automations/events/acceptance.js +30 -11
  27. package/dist/automations/store.d.ts +17 -0
  28. package/dist/automations/store.js +35 -0
  29. package/dist/catalog/admin-catalog.controller.d.ts +64 -2
  30. package/dist/catalog/admin-catalog.controller.js +17 -0
  31. package/dist/catalog/catalog-import.module.js +3 -0
  32. package/dist/catalog/catalog-scope.service.d.ts +3 -1
  33. package/dist/catalog/catalog-scope.service.js +11 -7
  34. package/dist/catalog/catalog.module.js +3 -0
  35. package/dist/catalog/catalog.service.d.ts +3 -1
  36. package/dist/catalog/catalog.service.js +8 -4
  37. package/dist/catalog/cli.js +2 -2
  38. package/dist/catalog/component-promotion.d.ts +3 -1
  39. package/dist/catalog/component-promotion.js +7 -3
  40. package/dist/catalog/component-scope.service.d.ts +3 -1
  41. package/dist/catalog/component-scope.service.js +7 -3
  42. package/dist/catalog/enable-requests.d.ts +10 -8
  43. package/dist/catalog/enable-requests.js +40 -21
  44. package/dist/catalog/marketplaces.service.d.ts +1 -1
  45. package/dist/catalog/owned-items.d.ts +3 -1
  46. package/dist/catalog/owned-items.js +13 -9
  47. package/dist/catalog/platform-components.d.ts +6 -1
  48. package/dist/catalog/platform-components.js +9 -3
  49. package/dist/catalog/plugin-connectors.d.ts +8 -4
  50. package/dist/catalog/plugin-connectors.js +12 -6
  51. package/dist/catalog/plugin-import.d.ts +3 -1
  52. package/dist/catalog/plugin-import.js +14 -5
  53. package/dist/catalog/plugin-install.d.ts +3 -1
  54. package/dist/catalog/plugin-install.js +8 -4
  55. package/dist/catalog/plugin-package.js +2 -1
  56. package/dist/catalog/plugin-upgrade.d.ts +3 -1
  57. package/dist/catalog/plugin-upgrade.js +8 -4
  58. package/dist/catalog/request-hints.d.ts +19 -0
  59. package/dist/catalog/request-hints.js +34 -0
  60. package/dist/catalog/request-rules.d.ts +9 -5
  61. package/dist/catalog/request-rules.js +16 -9
  62. package/dist/catalog/requests.service.d.ts +3 -1
  63. package/dist/catalog/requests.service.js +28 -9
  64. package/dist/catalog/scope-orgs.d.ts +2 -1
  65. package/dist/catalog/scope-orgs.js +2 -2
  66. package/dist/catalog/scope-sync.d.ts +3 -1
  67. package/dist/catalog/scope-sync.js +12 -2
  68. package/dist/catalog/scope-writer.d.ts +6 -3
  69. package/dist/catalog/scope-writer.js +28 -10
  70. package/dist/catalog/unshare.d.ts +3 -2
  71. package/dist/catalog/unshare.js +4 -4
  72. package/dist/client/client-access.service.js +29 -1
  73. package/dist/config/schema.d.ts +12 -0
  74. package/dist/config/schema.js +56 -0
  75. package/dist/ctx/create-ctx.d.ts +2 -19
  76. package/dist/ctx/create-ctx.js +3 -93
  77. package/dist/ctx/durable-relay.d.ts +2 -5
  78. package/dist/ctx/durable-relay.js +56 -29
  79. package/dist/db/extension-handoff-schema.js +5 -0
  80. package/dist/db/kernel-schema.d.ts +74 -0
  81. package/dist/db/migrator.js +36 -0
  82. package/dist/erasure/account-batches.js +2 -0
  83. package/dist/erasure/account-residual.js +1 -0
  84. package/dist/erasure/org-catalog.js +8 -3
  85. package/dist/erasure/org-rules.js +1 -0
  86. package/dist/evals/evals.schemas.d.ts +15 -5
  87. package/dist/evals/evals.schemas.js +17 -10
  88. package/dist/evals/runs.controller.d.ts +4 -12
  89. package/dist/evals/runs.controller.js +14 -11
  90. package/dist/evals/runs.service.d.ts +29 -25
  91. package/dist/evals/runs.service.js +73 -61
  92. package/dist/evals/trajectory.controller.d.ts +10 -6
  93. package/dist/evals/trajectory.controller.js +11 -4
  94. package/dist/evals/trajectory.service.d.ts +17 -9
  95. package/dist/evals/trajectory.service.js +52 -35
  96. package/dist/extensions/admin-ops.d.ts +6 -1
  97. package/dist/extensions/admin-ops.js +21 -7
  98. package/dist/extensions/blobs.d.ts +2 -0
  99. package/dist/extensions/blobs.js +11 -0
  100. package/dist/extensions/deployment-config.d.ts +6 -1
  101. package/dist/extensions/deployment-config.js +13 -2
  102. package/dist/extensions/enabled.d.ts +5 -0
  103. package/dist/extensions/extensions.module.js +3 -0
  104. package/dist/extensions/grant-epoch.d.ts +108 -0
  105. package/dist/extensions/grant-epoch.js +214 -0
  106. package/dist/extensions/host.d.ts +29 -9
  107. package/dist/extensions/host.js +148 -42
  108. package/dist/extensions/instance.d.ts +3 -3
  109. package/dist/extensions/instance.js +1 -1
  110. package/dist/extensions/isolated/authorization.d.ts +54 -2
  111. package/dist/extensions/isolated/authorization.js +148 -35
  112. package/dist/extensions/isolated/child-session.js +0 -1
  113. package/dist/extensions/isolated/revision.js +1 -1
  114. package/dist/extensions/org-config.d.ts +3 -1
  115. package/dist/extensions/org-config.js +13 -4
  116. package/dist/extensions/org-overrides.d.ts +6 -1
  117. package/dist/extensions/org-overrides.js +13 -2
  118. package/dist/extensions/package-digest.job.d.ts +34 -0
  119. package/dist/extensions/package-digest.job.js +121 -0
  120. package/dist/extensions/package.js +10 -6
  121. package/dist/extensions/permission-set.d.ts +14 -78
  122. package/dist/extensions/permission-set.js +17 -143
  123. package/dist/extensions/permission-view.d.ts +13 -1
  124. package/dist/extensions/permission-view.js +20 -0
  125. package/dist/extensions/registry.js +4 -1
  126. package/dist/extensions/resolve.d.ts +7 -8
  127. package/dist/extensions/resolve.js +7 -8
  128. package/dist/extensions/revision-approvals.d.ts +167 -0
  129. package/dist/extensions/revision-approvals.js +353 -0
  130. package/dist/extensions/revision-grants.d.ts +197 -0
  131. package/dist/extensions/revision-grants.js +584 -0
  132. package/dist/extensions/state.module.js +12 -1
  133. package/dist/identity/accounts.d.ts +10 -4
  134. package/dist/identity/accounts.js +18 -5
  135. package/dist/inbox/inbox-items.service.d.ts +6 -1
  136. package/dist/inbox/inbox-items.service.js +29 -10
  137. package/dist/inbox/inbox.module.js +3 -0
  138. package/dist/inbox/inbox.service.d.ts +3 -1
  139. package/dist/inbox/inbox.service.js +9 -2
  140. package/dist/inbox/org-notices.d.ts +4 -3
  141. package/dist/inbox/org-notices.js +9 -6
  142. package/dist/inbox/platform-inbox.service.d.ts +3 -1
  143. package/dist/inbox/platform-inbox.service.js +11 -3
  144. package/dist/inbox/platform-notices.d.ts +3 -2
  145. package/dist/inbox/platform-notices.js +10 -4
  146. package/dist/infra/config/kernel-config.service.js +4 -1
  147. package/dist/infra/database/extension-effect-key-lock.js +7 -0
  148. package/dist/infra/paging/paged-read.d.ts +34 -4
  149. package/dist/infra/paging/paged-read.js +38 -1
  150. package/dist/invalidation/audiences.d.ts +32 -0
  151. package/dist/invalidation/audiences.js +43 -0
  152. package/dist/invalidation/hints.d.ts +6 -0
  153. package/dist/invalidation/hints.js +7 -1
  154. package/dist/invalidation/invalidation-hints.d.ts +12 -1
  155. package/dist/invalidation/invalidation-hints.js +46 -5
  156. package/dist/invalidation/invalidation-hints.module.d.ts +2 -0
  157. package/dist/invalidation/invalidation-hints.module.js +4 -1
  158. package/dist/invalidation/me-stream.d.ts +1 -11
  159. package/dist/invalidation/me-stream.js +12 -41
  160. package/dist/invalidation/org-intent-bridge.d.ts +18 -0
  161. package/dist/invalidation/org-intent-bridge.js +46 -0
  162. package/dist/models/enablement.d.ts +3 -1
  163. package/dist/models/enablement.js +25 -5
  164. package/dist/orgs/invitations.controller.d.ts +4 -7
  165. package/dist/orgs/invitations.controller.js +8 -5
  166. package/dist/orgs/invitations.service.d.ts +17 -3
  167. package/dist/orgs/invitations.service.js +35 -13
  168. package/dist/orgs/members.service.d.ts +35 -0
  169. package/dist/orgs/members.service.js +52 -3
  170. package/dist/orgs/offboarding.d.ts +3 -1
  171. package/dist/orgs/offboarding.js +7 -3
  172. package/dist/orgs/orgs.controller.d.ts +11 -4
  173. package/dist/orgs/orgs.controller.js +25 -5
  174. package/dist/orgs/orgs.module.js +3 -0
  175. package/dist/orgs/orgs.schemas.d.ts +14 -0
  176. package/dist/orgs/orgs.schemas.js +19 -2
  177. package/dist/orgs/orgs.service.d.ts +24 -2
  178. package/dist/orgs/orgs.service.js +47 -4
  179. package/dist/orgs/security-settings.service.d.ts +14 -6
  180. package/dist/orgs/security-settings.service.js +18 -13
  181. package/dist/orgs/settings.controller.d.ts +7 -4
  182. package/dist/platform/exclusions.js +15 -0
  183. package/dist/platform/ops/accounts.ops.js +7 -16
  184. package/dist/platform/ops/admin-items.ops.js +7 -7
  185. package/dist/platform/ops/automations.ops.js +6 -4
  186. package/dist/platform/ops/evals.ops.js +30 -15
  187. package/dist/platform/ops/org-settings.ops.js +2 -2
  188. package/dist/platform/ops/orgs.ops.js +44 -27
  189. package/dist/push/delivery.d.ts +3 -1
  190. package/dist/push/delivery.js +7 -3
  191. package/dist/push/push-processor.js +8 -1
  192. package/dist/roles/worker.module.js +3 -0
  193. package/dist/runtime/step-log.d.ts +1 -1
  194. package/dist/runtime/step-log.js +5 -4
  195. package/dist/runtime/stream-limit.d.ts +13 -0
  196. package/dist/runtime/stream-limit.js +40 -0
  197. package/dist/runtime/stream.controller.d.ts +2 -0
  198. package/dist/runtime/stream.controller.js +2 -0
  199. package/dist/runtime/stream.d.ts +1 -0
  200. package/dist/runtime/stream.js +15 -6
  201. package/dist/sandbox/permission-authority.module.js +6 -1
  202. package/dist/sandbox/permission-transitions.d.ts +3 -1
  203. package/dist/sandbox/permission-transitions.js +17 -2
  204. package/dist/setup/kernel-checks.d.ts +3 -3
  205. package/dist/setup/kernel-checks.js +4 -4
  206. package/dist/setup/setup-check-registry.d.ts +16 -5
  207. package/dist/setup/setup-check-registry.js +11 -3
  208. package/dist/setup/setup-checks.service.d.ts +1 -2
  209. package/dist/setup/setup-checks.service.js +7 -6
  210. package/dist/skills/agent-skills.service.d.ts +6 -1
  211. package/dist/skills/agent-skills.service.js +12 -3
  212. package/dist/skills/changes.service.d.ts +6 -1
  213. package/dist/skills/changes.service.js +11 -3
  214. package/dist/skills/conversation-catalog.d.ts +3 -0
  215. package/dist/skills/conversation-catalog.js +2 -0
  216. package/dist/skills/skills.module.js +3 -0
  217. package/dist/skills/skills.service.d.ts +3 -1
  218. package/dist/skills/skills.service.js +8 -4
  219. package/dist/tools/admin-connectors.d.ts +10 -8
  220. package/dist/tools/admin-connectors.js +12 -10
  221. package/dist/tools/approvals.service.d.ts +12 -1
  222. package/dist/tools/approvals.service.js +36 -9
  223. package/dist/tools/builtins/automations.d.ts +1 -1
  224. package/dist/tools/builtins/automations.js +1 -1
  225. package/dist/tools/connectors.service.d.ts +3 -1
  226. package/dist/tools/connectors.service.js +29 -7
  227. package/dist/tools/tools.module.js +3 -0
  228. package/dist/ui/admin-ui.controller.d.ts +3 -1
  229. package/dist/ui/admin-ui.controller.js +3 -1
  230. package/dist/ui/ui-stream.d.ts +2 -0
  231. package/dist/ui/ui-stream.js +20 -6
  232. package/dist/ui/views.controller.d.ts +4 -2
  233. package/dist/ui/views.controller.js +4 -2
  234. package/package.json +3 -3
  235. package/src/migrations/0234_extension_grant_epoch.sql +141 -0
  236. package/src/migrations/0235_extension_revision_grants.sql +166 -0
  237. package/src/migrations/0236_paged_table_idx.sql +33 -0
  238. package/src/migrations/0237_extension_handoff_health.sql +18 -0
@@ -31,6 +31,8 @@ import { Transactional } from "../infra/database/transactional.decorator.js";
31
31
  import { XactLock } from "../infra/database/xact-lock.js";
32
32
  import { KernelEvents } from "../infra/events/kernel-events.js";
33
33
  import { OutboxService } from "../infra/outbox/outbox.service.js";
34
+ import { assertReadablePage, cappedCount, PAGED_TOTAL_CAP, pageOf, pageOffset, } from "../infra/paging/paged-read.js";
35
+ import { InvalidationHints } from "../invalidation/invalidation-hints.js";
34
36
  import { MAINTENANCE_QUEUE_NAME } from "../runtime/maintenance-queue.js";
35
37
  import { STOP_DELETED_ORG_JOB } from "../runtime/run-deletion.js";
36
38
  import { USAGE_REPORT_QUEUE } from "../runtime/usage-report-jobs.js";
@@ -104,6 +106,7 @@ let OrgsService = class OrgsService {
104
106
  ceilings;
105
107
  erasure;
106
108
  storage;
109
+ hints;
107
110
  constructor(db, outbox, txHost, settings, apiTokens, orgLock, events,
108
111
  /** Cancels the deleted org's running eval runs (in the delete's transaction). */
109
112
  evalBudget,
@@ -112,7 +115,7 @@ let OrgsService = class OrgsService {
112
115
  /** What the deleted org owns is transferred or removed in the delete's transaction (P3-20). */
113
116
  ownedItems,
114
117
  /** Records `org.deleted` for the subscribing plugins in the delete's transaction. */
115
- lifecycle, ceilings, erasure, storage) {
118
+ lifecycle, ceilings, erasure, storage, hints) {
116
119
  this.db = db;
117
120
  this.outbox = outbox;
118
121
  this.txHost = txHost;
@@ -128,6 +131,7 @@ let OrgsService = class OrgsService {
128
131
  this.ceilings = ceilings;
129
132
  this.erasure = erasure;
130
133
  this.storage = storage;
134
+ this.hints = hints;
131
135
  }
132
136
  /**
133
137
  * Creates an org with the actor as owner, in the caller's transaction when there is one (the
@@ -185,7 +189,7 @@ let OrgsService = class OrgsService {
185
189
  .execute());
186
190
  return rows.map((r) => ({ ...toOrg(r), role: r.role }));
187
191
  }
188
- /** 全部(未软删除的)组织及成员数(超级管理员用)。 */
192
+ /** Every live org with its member count, oldest first (internal callers that need them all). */
189
193
  async listAll() {
190
194
  const rows = await this.db
191
195
  .selectFrom("orgs")
@@ -199,6 +203,44 @@ let OrgsService = class OrgsService {
199
203
  .execute();
200
204
  return rows.map((r) => ({ ...toOrg(r), memberCount: Number(r.member_count) }));
201
205
  }
206
+ /**
207
+ * Every live org in the compact directory shape, oldest first (the super admin's org filters,
208
+ * pickers and names; the orgs table reads {@link page}).
209
+ */
210
+ async directory() {
211
+ // listAll's order without its member counts (and so without reading memberships)
212
+ return this.db
213
+ .selectFrom("orgs")
214
+ .select(["id", "slug", "name"])
215
+ .where("deleted_at", "is", null)
216
+ .orderBy("created_at")
217
+ .orderBy("id")
218
+ .execute();
219
+ }
220
+ /**
221
+ * One page of the live orgs with their member counts (the super admin's orgs list), newest first
222
+ * (`created_at`, then id), by page number without a snapshot (table pagination spec §2.3: orgs
223
+ * are edited in place); `q` keeps those whose name or slug contains it (case-insensitive).
224
+ */
225
+ async page(q) {
226
+ assertReadablePage(q.page, q.size);
227
+ let matching = this.db.selectFrom("orgs").where("orgs.deleted_at", "is", null);
228
+ // an empty search (the route trims it) is no search
229
+ if (q.q !== undefined && q.q !== "") {
230
+ const like = `%${q.q.replace(/[\\%_]/g, (ch) => `\\${ch}`)}%`;
231
+ matching = matching.where(sql `(orgs.name ILIKE ${like} ESCAPE '\\' OR orgs.slug ILIKE ${like} ESCAPE '\\')`);
232
+ }
233
+ const counted = await cappedCount(this.db.db, matching, PAGED_TOTAL_CAP);
234
+ const rows = await matching
235
+ .select(["orgs.id", "orgs.slug", "orgs.name", "orgs.created_at"])
236
+ .select(sql `(SELECT count(*) FROM capybara.memberships m WHERE m.org_id = orgs.id)`.as("member_count"))
237
+ .orderBy("orgs.created_at", "desc")
238
+ .orderBy("orgs.id", "desc")
239
+ .offset(pageOffset(q.page, q.size))
240
+ .limit(q.size)
241
+ .execute();
242
+ return pageOf(rows.map((r) => ({ ...toOrg(r), memberCount: Number(r.member_count) })), q, counted);
243
+ }
202
244
  /** 未软删除的组织;不存在或已软删除为 undefined。 */
203
245
  async get(orgId) {
204
246
  const row = await this.db
@@ -323,7 +365,7 @@ let OrgsService = class OrgsService {
323
365
  // eval runs of a deleted org stop spending: cancelled explicitly (audited with the reason)
324
366
  await this.evalBudget.cancelRuns({ orgId }, { accountId: actor.id, ...(actorTokenId !== undefined && { tokenId: actorTokenId }) }, "org_deleted");
325
367
  // pending catalog requests (including those passed to super admins) are cancelled too
326
- await cancelPendingRequests(this.db.db, { orgId }, actor.id, "org_deleted", actorTokenId !== undefined ? { actorTokenId } : {});
368
+ await cancelPendingRequests(this.db.db, this.hints, { orgId }, actor.id, "org_deleted", actorTokenId !== undefined ? { actorTokenId } : {});
327
369
  await this.db
328
370
  .updateTable("sessions")
329
371
  .set({ current_org_id: null })
@@ -374,6 +416,7 @@ OrgsService = __decorate([
374
416
  __param(11, Inject(LifecycleHooks)),
375
417
  __param(12, Inject(PermissionCeilingWrites)),
376
418
  __param(13, Inject(ErasureRequests)),
377
- __param(14, Inject(StorageService))
419
+ __param(14, Inject(StorageService)),
420
+ __param(15, Inject(InvalidationHints))
378
421
  ], OrgsService);
379
422
  export { OrgsService };
@@ -8,9 +8,14 @@ import { ToolRegistry } from "../tools/registry.js";
8
8
  import { OrgLock } from "./org-lock.js";
9
9
  import { OrgSettingsService } from "./settings.service.js";
10
10
  type ToolSource = "builtin" | "connector" | "extension" | "operation" | "unavailable";
11
+ /**
12
+ * The ceilings and one page of the tool policies, by tool key, by page number without a snapshot
13
+ * (table pagination spec §2.3: the tool list follows the loaded extensions and the policies are
14
+ * edited in place).
15
+ */
11
16
  export declare const OrgSecurityQuerySchema: z.ZodObject<{
12
- cursor: z.ZodOptional<z.ZodString>;
13
- limit: z.ZodDefault<z.ZodCoercedNumber<unknown>>;
17
+ page: z.ZodDefault<z.ZodCoercedNumber<unknown>>;
18
+ size: z.ZodDefault<z.ZodCoercedNumber<unknown>>;
14
19
  }, z.core.$strict>;
15
20
  export declare const OrgSecurityPatchSchema: z.ZodObject<{
16
21
  expectedRevision: z.ZodString;
@@ -58,15 +63,18 @@ export declare class OrgSecuritySettingsService {
58
63
  private snapshot;
59
64
  private toolSources;
60
65
  view(orgId: string, query: OrgSecurityQuery): Promise<{
61
- gitPushDenials: string[];
62
- revision: string;
63
- tools: {
66
+ items: {
64
67
  toolKey: string;
65
68
  source: ToolSource;
66
69
  policy: import("../tools/org-tool-policies.js").OrgToolPolicy;
67
70
  unattendedPolicy: import("../tools/org-tool-policies.js").OrgToolPolicy;
68
71
  }[];
69
- nextCursor: string | null;
72
+ page: number;
73
+ size: number;
74
+ total: number;
75
+ totalCapped: boolean;
76
+ gitPushDenials: string[];
77
+ revision: string;
70
78
  allowedProfiles: {
71
79
  configured: ("approve-for-me" | "full-access" | "request-approval")[] | null;
72
80
  platform: import("@capybara-hq/plugin-sdk").PermissionProfile[];
@@ -16,6 +16,7 @@ import { audit } from "../identity/audit.js";
16
16
  import { KernelDb } from "../infra/database/kernel-db.js";
17
17
  import { TransactionHost, withOrderedLocks } from "../infra/database/transaction-host.js";
18
18
  import { Transactional } from "../infra/database/transactional.decorator.js";
19
+ import { assertReadablePage, PAGED_TOTAL_CAP, PageQueryFields, pageOf, pageOffset, } from "../infra/paging/paged-read.js";
19
20
  import { PlatformOperations } from "../platform/registry.js";
20
21
  import { PermissionCeilingWrites } from "../sandbox/permission-ceiling-writes.js";
21
22
  import { readOrgGitPushDenials, readOrgToolPolicies, writeOrgGitPushDenial, writeOrgToolPolicy, } from "../tools/org-tool-policies.js";
@@ -33,12 +34,12 @@ const GitTarget = z
33
34
  .max(200)
34
35
  .transform((value) => (value.trim() === "*" ? "*" : normalizeGitRepo(value)))
35
36
  .pipe(z.string());
36
- export const OrgSecurityQuerySchema = z
37
- .object({
38
- cursor: ToolKey.optional(),
39
- limit: z.coerce.number().int().min(1).max(100).default(50),
40
- })
41
- .strict();
37
+ /**
38
+ * The ceilings and one page of the tool policies, by tool key, by page number without a snapshot
39
+ * (table pagination spec §2.3: the tool list follows the loaded extensions and the policies are
40
+ * edited in place).
41
+ */
42
+ export const OrgSecurityQuerySchema = z.object({ ...PageQueryFields }).strict();
42
43
  export const OrgSecurityPatchSchema = OrgSecurityCeilingsPatchSchema.extend({
43
44
  expectedRevision: Revision,
44
45
  confirmation: Revision.optional(),
@@ -118,19 +119,23 @@ let OrgSecuritySettingsService = class OrgSecuritySettingsService {
118
119
  for (const { toolKey } of policies)
119
120
  if (!sources.has(toolKey))
120
121
  sources.set(toolKey, "unavailable");
121
- const keys = [...sources.keys()]
122
- .filter((key) => query.cursor === undefined || key > query.cursor)
123
- .sort();
124
- const page = keys.slice(0, query.limit);
122
+ assertReadablePage(query.page, query.size);
123
+ // the list is built in memory (the registry's tools and the Platform operations), so it is
124
+ // counted here, with the same cap as a counted query
125
+ const keys = [...sources.keys()].sort();
126
+ const start = pageOffset(query.page, query.size);
127
+ const page = keys.slice(start, start + query.size);
125
128
  return {
126
129
  ...snapshot,
127
- tools: page.map((toolKey) => ({
130
+ ...pageOf(page.map((toolKey) => ({
128
131
  toolKey,
129
132
  source: sources.get(toolKey) ?? "unavailable",
130
133
  policy: rows.get(toolKey)?.policy ?? "allow",
131
134
  unattendedPolicy: rows.get(toolKey)?.unattendedPolicy ?? "allow",
132
- })),
133
- nextCursor: keys.length > page.length ? (page.at(-1) ?? null) : null,
135
+ })), query, {
136
+ count: Math.min(keys.length, PAGED_TOTAL_CAP),
137
+ capped: keys.length > PAGED_TOTAL_CAP,
138
+ }),
134
139
  };
135
140
  }
136
141
  async update(orgId, patch, actor, options) {
@@ -14,15 +14,18 @@ export declare class OrgSecuritySettingsController {
14
14
  private readonly security;
15
15
  constructor(security: OrgSecuritySettingsService);
16
16
  get(org: OrgContext, query: OrgSecurityQuery): Promise<{
17
- gitPushDenials: string[];
18
- revision: string;
19
- tools: {
17
+ items: {
20
18
  toolKey: string;
21
19
  source: "builtin" | "connector" | "extension" | "operation" | "unavailable";
22
20
  policy: import("../tools/org-tool-policies.js").OrgToolPolicy;
23
21
  unattendedPolicy: import("../tools/org-tool-policies.js").OrgToolPolicy;
24
22
  }[];
25
- nextCursor: string | null;
23
+ page: number;
24
+ size: number;
25
+ total: number;
26
+ totalCapped: boolean;
27
+ gitPushDenials: string[];
28
+ revision: string;
26
29
  allowedProfiles: {
27
30
  configured: ("approve-for-me" | "full-access" | "request-approval")[] | null;
28
31
  platform: import("@capybara-hq/plugin-sdk").PermissionProfile[];
@@ -618,6 +618,21 @@ export const PLATFORM_EXCLUSIONS = [
618
618
  category: "human-only",
619
619
  reason: "Creates an org and makes the caller its owner",
620
620
  },
621
+ {
622
+ route: "GET /api/v1/orgs/:orgId/members/directory",
623
+ category: "internal",
624
+ reason: "The web's whole member list for owner pickers and member names; orgs.members gives an agent the same members page by page",
625
+ },
626
+ {
627
+ route: "GET /api/v1/admin/orgs/directory",
628
+ category: "internal",
629
+ reason: "The super admin console's whole org list for org filters, pickers and names; orgs.list gives an agent the same orgs page by page",
630
+ },
631
+ {
632
+ route: "GET /api/v1/orgs/:orgId/automations/next-runs",
633
+ category: "internal",
634
+ reason: "The web calendar's whole task list reduced to status and next run for its empty state; automations.list gives an agent the same tasks page by page",
635
+ },
621
636
  {
622
637
  route: "GET /api/v1/orgs",
623
638
  category: "internal",
@@ -20,7 +20,6 @@ import { defineOperation } from "../operation.js";
20
20
  import { PlatformOperations } from "../registry.js";
21
21
  import { precheckBy, viaAgent } from "./errors.js";
22
22
  import { named } from "./summary.js";
23
- const PAGE = 50;
24
23
  const AccountId = AccountParams.shape.accountId.describe("The account id (accounts.list).");
25
24
  /** What the tool result says instead of the password (model-visible English). */
26
25
  export const INITIAL_PASSWORD_NOTE = "The kernel generated a one-time initial password. It is shown once, on the web, to the person this call was made for, under the tool call in this conversation, and never to you. The account must change it at first sign-in.";
@@ -124,25 +123,18 @@ let AccountsOperations = class AccountsOperations {
124
123
  this.registry.register([
125
124
  defineOperation({
126
125
  id: "accounts.list",
127
- description: "List the platform's accounts (super admin), one compact row each: id, display name, state (active or disabled), login, email and whether it is a super admin. Ordered by id; pages by 50: pass the returned next as params.after. Details come from accounts.get.",
128
- input: z
129
- .object({ after: AccountListQuery.shape.after.unwrap().max(100).optional() })
130
- .strict(),
131
- example: {},
126
+ description: "List the platform's accounts (super admin), one compact row each: id, display name, state (active or disabled), login, email and whether it is a super admin. Newest first; paged by page number: page (1-based) and size (20, 50 or 100); the answer has items, page, size and total (capped at 10000, totalCapped true above). Pages beyond the first 10000 accounts are refused. Details come from accounts.get.",
127
+ input: AccountListQuery.strict(),
128
+ example: { page: 1, size: 50 },
132
129
  authz: { superAdmin: true },
133
130
  mirrors: ["GET /api/v1/admin/accounts"],
134
- // the page size is fixed at 50 (compact rows)
135
- omits: ["limit"],
136
131
  confirm: "read",
137
132
  run: async (input) => {
138
- const rows = await this.accounts.list({
139
- limit: PAGE + 1,
140
- ...(input.after !== undefined && { after: input.after }),
141
- });
142
- const page = rows.slice(0, PAGE);
143
- const logins = await this.accounts.localLogins(page.map((a) => a.id));
133
+ const page = await this.accounts.list(input);
134
+ const logins = await this.accounts.localLogins(page.items.map((a) => a.id));
144
135
  return {
145
- items: page.map((a) => ({
136
+ ...page,
137
+ items: page.items.map((a) => ({
146
138
  id: a.id,
147
139
  name: a.displayName,
148
140
  state: a.status,
@@ -150,7 +142,6 @@ let AccountsOperations = class AccountsOperations {
150
142
  email: a.email,
151
143
  superAdmin: a.isSuperAdmin,
152
144
  })),
153
- next: rows.length > PAGE ? (page.at(-1)?.id ?? null) : null,
154
145
  };
155
146
  },
156
147
  }),
@@ -86,9 +86,9 @@ let AdminItemsOperations = class AdminItemsOperations {
86
86
  this.registry.register([
87
87
  defineOperation({
88
88
  id: "admin.agents-list",
89
- description: "List this org's agents as the admin console shows them (super admin): private ones too, with owner, visibility, whether the agent needs a new owner and the template it was created from. q searches the name; pages by limit (default 50), pass the returned next as after. Other orgs' agents are only in the admin console.",
90
- input: AdminAgentListQuery.pick({ q: true, after: true, limit: true }).strict(),
91
- example: { limit: 50 },
89
+ description: "List this org's agents as the admin console shows them (super admin): private ones too, with owner, visibility, whether the agent needs a new owner and the template it was created from. q searches the name. Newest first; paged by page number: page (1-based) and size (20, 50 or 100); the answer has items, page, size and total (capped at 10000, totalCapped true above). Other orgs' agents are only in the admin console.",
90
+ input: AdminAgentListQuery.pick({ q: true, page: true, size: true }).strict(),
91
+ example: { page: 1, size: 50 },
92
92
  authz: { superAdmin: true },
93
93
  mirrors: ["GET /api/v1/admin/agents"],
94
94
  confirm: "read",
@@ -153,14 +153,14 @@ let AdminItemsOperations = class AdminItemsOperations {
153
153
  }),
154
154
  defineOperation({
155
155
  id: "admin.connectors-list",
156
- description: "List this org's connectors as the admin console shows them (super admin): name, protocol, status, tool count, who created it and from which template. Never an endpoint, credential or whether anyone has one. status and q (name search) filter; pages by limit (default 50), pass the returned next as after. Other orgs' connectors are only in the admin console.",
156
+ description: "List this org's connectors as the admin console shows them (super admin): name, protocol, status, tool count, who created it and from which template. Never an endpoint, credential or whether anyone has one. status and q (name search) filter. Newest first; paged by page number: page (1-based) and size (20, 50 or 100); the answer has items, page, size and total (capped at 10000, totalCapped true above). Other orgs' connectors are only in the admin console.",
157
157
  input: AdminConnectorListQuery.pick({
158
158
  status: true,
159
159
  q: true,
160
- after: true,
161
- limit: true,
160
+ page: true,
161
+ size: true,
162
162
  }).strict(),
163
- example: { limit: 50 },
163
+ example: { page: 1, size: 50 },
164
164
  authz: { superAdmin: true },
165
165
  mirrors: ["GET /api/v1/admin/connectors"],
166
166
  confirm: "read",
@@ -92,9 +92,9 @@ let AutomationsOperations = class AutomationsOperations {
92
92
  this.registry.register([
93
93
  defineOperation({
94
94
  id: "automations.list",
95
- description: "List your automations: one compact row each (name, agent, status and why it is paused, schedule with its time zone, where runs post, next run, last settled run). all=true lists every task of the org and needs the org admin role; conversationId keeps the tasks that post into that conversation.",
95
+ description: "List your automations: one compact row each (name, agent, status and why it is paused, schedule with its time zone, where runs post, next run, last settled run). all=true lists every task of the org and needs the org admin role; conversationId keeps the tasks that post into that conversation. Newest first; paged by page number: page (1-based) and size (20, 50 or 100); the answer has items, page, size and total (capped at 10000, totalCapped true above).",
96
96
  input: ListQuery,
97
- example: {},
97
+ example: { page: 1, size: 20 },
98
98
  // a creator demoted to guest still lists their own tasks (to pause or delete them)
99
99
  authz: { orgAction: "org.read" },
100
100
  mirrors: ["GET /api/v1/orgs/:orgId/automations"],
@@ -106,11 +106,13 @@ let AutomationsOperations = class AutomationsOperations {
106
106
  },
107
107
  ],
108
108
  run: async (input, ctx) => {
109
- const items = await this.tasks.list(ctx.orgId, this.actor(ctx), {
109
+ const page = await this.tasks.list(ctx.orgId, this.actor(ctx), {
110
110
  all: input.all === "true",
111
+ page: input.page,
112
+ size: input.size,
111
113
  ...(input.conversationId !== undefined && { conversationId: input.conversationId }),
112
114
  });
113
- return { items: items.map(row) };
115
+ return { ...page, items: page.items.map(row) };
114
116
  },
115
117
  }),
116
118
  defineOperation({
@@ -11,7 +11,7 @@ import { Inject, Injectable } from "@nestjs/common";
11
11
  import { z } from "zod";
12
12
  import { ModelRef } from "../../agents/definition.js";
13
13
  import { ApiError } from "../../errors.js";
14
- import { EvalAddCaseBody, EvalCandidateSchema, EvalCaseParams, EvalLabelBody, EvalResultParams, EvalRunEstimateBody, EvalRunParams, EvalRunResultsQuery, EvalSampleBody, EvalSetCreateBody, EvalSetParams, EvalSetPatchBody, } from "../../evals/evals.schemas.js";
14
+ import { EvalAddCaseBody, EvalCandidateSchema, EvalCaseParams, EvalLabelBody, EvalResultParams, EvalRunEstimateBody, EvalRunParams, EvalRunResultsQuery, EvalSampleBody, EvalSetCreateBody, EvalSetParams, EvalSetPatchBody, EvalSetRunsQuery, } from "../../evals/evals.schemas.js";
15
15
  import { EvalRunsService } from "../../evals/runs.service.js";
16
16
  import { EvalSetsService } from "../../evals/sets.service.js";
17
17
  import { KernelConfigService } from "../../infra/config/kernel-config.service.js";
@@ -546,17 +546,23 @@ let EvalsOperations = class EvalsOperations {
546
546
  }),
547
547
  defineOperation({
548
548
  id: "evals.list-runs",
549
- description: "List the runs of one eval set, newest first (org admins): id, mode, state and progress. Read one with evals.get-run. Pages by 50: pass the returned next as params.cursor.",
550
- input: z.object({ setId: SetId, cursor: Cursor.optional() }).strict(),
551
- example: { setId: "3b1f0c52-8d2a-4a57-9a43-6f1d2c9e7a10" },
549
+ description: "List the runs of one eval set, newest first (org admins): id, mode, state and progress. Read one with evals.get-run. Paged by page number: page (1-based) and size (20, 50 or 100); the answer has items, total (capped at 10000, totalCapped true above), asOf and newer. Pass the returned asOf with the next pages so they stay the same while new runs start; newer counts runs started after asOf.",
550
+ input: EvalSetRunsQuery.extend({ setId: SetId }).strict(),
551
+ example: { setId: "3b1f0c52-8d2a-4a57-9a43-6f1d2c9e7a10", page: 1, size: 20 },
552
552
  authz: { orgAction: "evals.manage" },
553
553
  mirrors: ["GET /api/v1/orgs/:orgId/eval-sets/:setId/runs"],
554
- extras: ["cursor"],
555
554
  confirm: "read",
556
555
  errors: [
557
556
  { code: "eval.set_not_found", next: "Check the eval set id with evals.list-sets." },
558
557
  ],
559
- run: async (input, ctx) => pageOf((await this.runs.listForSet(ctx.orgId, input.setId)).map(runRow), startOf(input.cursor), PAGE),
558
+ run: async (input, ctx) => {
559
+ const page = await this.runs.listForSet(ctx.orgId, input.setId, {
560
+ page: input.page,
561
+ size: input.size,
562
+ ...(input.asOf !== undefined && { asOf: input.asOf }),
563
+ });
564
+ return { ...page, items: page.items.map(runRow) };
565
+ },
560
566
  }),
561
567
  defineOperation({
562
568
  id: "evals.get-run",
@@ -571,21 +577,31 @@ let EvalsOperations = class EvalsOperations {
571
577
  }),
572
578
  defineOperation({
573
579
  id: "evals.list-results",
574
- description: "List the results of one eval run without their content (org admins): state, judge verdict, your label, drift and error code per case step. Pages by 50: pass the returned next as params.after. Read one result's scalar fields with evals.get-result.",
575
- input: EvalRunResultsQuery.pick({ after: true, limit: true })
576
- .extend({ runId: RunId, limit: z.number().int().min(1).max(50).default(50) })
580
+ description: "List the results of one eval run without their content (org admins): state, judge verdict, your label, drift and error code per case step. Paged by page number: page (1-based) and size (20 or 50); the answer has items, page, size and total (capped at 10000, totalCapped true above). Read one result's scalar fields with evals.get-result.",
581
+ // model-visible: at most 50 rows a call (the route's tables also offer 100)
582
+ input: EvalRunResultsQuery.pick({ page: true, size: true })
583
+ .extend({
584
+ runId: RunId,
585
+ size: z.coerce
586
+ .number()
587
+ .int()
588
+ .refine((v) => v === 20 || v === 50, "size must be 20 or 50")
589
+ .default(20)
590
+ .describe("Rows per page: 20 or 50 (default 20)."),
591
+ })
577
592
  .strict(),
578
- example: { runId: "2c3d4e5f-6a7b-4c8d-9e0f-1a2b3c4d5e6f", limit: 50 },
593
+ example: { runId: "2c3d4e5f-6a7b-4c8d-9e0f-1a2b3c4d5e6f", page: 1, size: 50 },
579
594
  authz: { orgAction: "evals.manage" },
580
595
  mirrors: ["GET /api/v1/orgs/:orgId/eval-runs/:runId/results"],
581
- // the light view only; polling by `updatedSince` is the web's
582
- omits: ["view", "updatedSince"],
596
+ // the light view only
597
+ omits: ["view"],
583
598
  confirm: "read",
584
599
  errors: [{ code: "eval.run_not_found", next: "Check the run id with evals.list-runs." }],
585
600
  run: async (input, ctx) => {
586
- const out = await this.runs.resultsLight(ctx.orgId, ctx.actorAccountId, input.runId, { limit: input.limit, ...(input.after !== undefined && { after: input.after }) }, undefined, viaAgent("evals.list-results", ctx));
601
+ const out = await this.runs.resultsLight(ctx.orgId, ctx.actorAccountId, input.runId, { page: input.page, size: input.size }, undefined, viaAgent("evals.list-results", ctx));
587
602
  return {
588
- items: out.results.map((r) => ({
603
+ ...out,
604
+ items: out.items.map((r) => ({
589
605
  id: r.id,
590
606
  name: r.step === null ? "whole run" : `step ${r.step}`,
591
607
  state: r.status,
@@ -594,7 +610,6 @@ let EvalsOperations = class EvalsOperations {
594
610
  verdict: r.label ?? r.verdict,
595
611
  toolCallsMatch: r.toolCallsMatch,
596
612
  })),
597
- next: out.next,
598
613
  };
599
614
  },
600
615
  }),
@@ -48,9 +48,9 @@ let OrgSettingsOperations = class OrgSettingsOperations {
48
48
  this.registry.register([
49
49
  defineOperation({
50
50
  id: "org-security.get",
51
- description: "Read organization security ceilings and a page of canonical tool policies. Pass nextCursor as cursor to continue.",
51
+ description: "Read organization security ceilings and a page of canonical tool policies (items), by tool key. Paged by page number: page (1-based) and size (20, 50 or 100); the answer has items, page, size and total.",
52
52
  input: OrgSecurityQuerySchema,
53
- example: { limit: 50 },
53
+ example: { page: 1, size: 50 },
54
54
  authz: { orgAction: "org.update" },
55
55
  mirrors: ["GET /api/v1/orgs/:orgId/settings/security"],
56
56
  confirm: "read",
@@ -9,6 +9,7 @@ var __param = (this && this.__param) || function (paramIndex, decorator) {
9
9
  };
10
10
  import { Inject, Injectable } from "@nestjs/common";
11
11
  import { z } from "zod";
12
+ import { AdminOrgListQuery } from "../../admin/admin.schemas.js";
12
13
  import { OrgAuditActorsQuery, OrgAuditListQuery } from "../../admin/audit.schemas.js";
13
14
  import { AuditLogService } from "../../admin/audit-log.service.js";
14
15
  import { limitDefaults } from "../../admin/limit-defaults.js";
@@ -23,17 +24,15 @@ import { MemberBudgetBody } from "../../models/budget-policy.js";
23
24
  import { InvitationsService } from "../../orgs/invitations.service.js";
24
25
  import { MembersService } from "../../orgs/members.service.js";
25
26
  import { OrgNetworkAllowances } from "../../orgs/network-allowances.service.js";
26
- import { InvitationCreateBody, InvitationIdParams, MemberParams, MemberRoleBody, networkAllowanceView, OrgUpdateBody, } from "../../orgs/orgs.schemas.js";
27
+ import { InvitationCreateBody, InvitationIdParams, InvitationListQuery, MemberListQuery, MemberParams, MemberRoleBody, networkAllowanceView, OrgUpdateBody, } from "../../orgs/orgs.schemas.js";
27
28
  import { OrgsService } from "../../orgs/orgs.service.js";
28
29
  import { roleAtLeast } from "../../orgs/roles.js";
29
30
  import { defineOperation } from "../operation.js";
30
31
  import { PlatformOperations } from "../registry.js";
31
32
  import { SEALED_REVEAL_TTL_MS, SealedReveals } from "../sealed-reveals.js";
32
33
  import { precheckBy, viaAgent } from "./errors.js";
33
- import { Cursor, pageOf, startOf } from "./paging.js";
34
34
  import { roleOf } from "./role.js";
35
35
  import { named, orElse } from "./summary.js";
36
- const PAGE = 50;
37
36
  const OrgId = z.string().min(1).max(100).describe("The org id (orgs.list).");
38
37
  /** The value types of the per-org override records of `PUT /api/v1/admin/settings`. */
39
38
  const OVERRIDES = DEPLOYMENT_SETTINGS_PATCH.shape;
@@ -189,26 +188,33 @@ let OrgsOperations = class OrgsOperations {
189
188
  this.registry.register([
190
189
  defineOperation({
191
190
  id: "orgs.list",
192
- description: "List every org on the platform (super admin), one compact row each: id, name, slug, member count and whether it has limits of its own. Also returns the deployment's default limits. Pages by 50: pass the returned next as params.cursor. Details and limits of one org come from orgs.get.",
193
- input: z.object({ cursor: Cursor.optional() }).strict(),
194
- example: {},
191
+ description: "List the orgs on the platform (super admin), one compact row each: id, name, slug, member count and whether it has limits of its own; newest first. q keeps the orgs whose name or slug contains it. Also returns the deployment's default limits. Paged by page number: page (1-based) and size (20, 50 or 100); the answer has items, page, size and total (capped at 10000, totalCapped true above). Details and limits of one org come from orgs.get.",
192
+ input: AdminOrgListQuery.strict(),
193
+ example: { page: 1, size: 50 },
195
194
  authz: { superAdmin: true },
196
195
  mirrors: ["GET /api/v1/admin/orgs"],
197
- extras: ["cursor"],
198
196
  confirm: "read",
199
197
  run: async (input) => {
200
- const [orgs, s] = await Promise.all([this.orgs.listAll(), this.settings.get()]);
198
+ const [page, s] = await Promise.all([
199
+ this.orgs.page({
200
+ page: input.page,
201
+ size: input.size,
202
+ ...(input.q !== undefined && { q: input.q }),
203
+ }),
204
+ this.settings.get(),
205
+ ]);
201
206
  const own = (id) => id in s.runConcurrencyOverrides ||
202
207
  id in s.sandboxLimitOverrides ||
203
208
  id in s.subagentLimitOverrides;
204
209
  return {
205
- ...pageOf(orgs.map((o) => ({
210
+ ...page,
211
+ items: page.items.map((o) => ({
206
212
  id: o.id,
207
213
  name: o.name,
208
214
  slug: o.slug,
209
215
  memberCount: o.memberCount,
210
216
  ownLimits: own(o.id),
211
- })), startOf(input.cursor), PAGE),
217
+ })),
212
218
  limitDefaults: limitDefaults(this.config),
213
219
  };
214
220
  },
@@ -493,32 +499,43 @@ let OrgsOperations = class OrgsOperations {
493
499
  }),
494
500
  defineOperation({
495
501
  id: "orgs.members",
496
- description: "List the members of this conversation's org, one compact row each: account id, display name, role, email and when they joined. Org admins change roles with orgs.set-member-role and remove members with orgs.remove-member. Pages by 50: pass the returned next as params.cursor.",
497
- input: z.object({ cursor: Cursor.optional() }).strict(),
498
- example: {},
502
+ description: "List the members of this conversation's org, one compact row each: account id, display name, role, email and when they joined, by join time. q keeps the members whose display name or email contains it. Org admins change roles with orgs.set-member-role and remove members with orgs.remove-member. Paged by page number: page (1-based) and size (20, 50 or 100); the answer has items, page, size and total (capped at 10000, totalCapped true above).",
503
+ input: MemberListQuery.strict(),
504
+ example: { page: 1, size: 50 },
499
505
  authz: { orgAction: "org.members.read" },
500
506
  mirrors: ["GET /api/v1/orgs/:orgId/members"],
501
- extras: ["cursor"],
502
507
  confirm: "read",
503
- run: async (input, ctx) => pageOf((await this.members.list(ctx.orgId)).map((m) => ({
504
- id: m.account.id,
505
- name: m.account.displayName,
506
- state: m.role,
507
- email: m.account.email,
508
- joinedAt: m.joinedAt,
509
- ...(m.anonymous && { anonymous: true }),
510
- })), startOf(input.cursor), PAGE),
508
+ run: async (input, ctx) => {
509
+ const page = await this.members.page(ctx.orgId, {
510
+ page: input.page,
511
+ size: input.size,
512
+ ...(input.q !== undefined && { q: input.q }),
513
+ });
514
+ return {
515
+ ...page,
516
+ items: page.items.map((m) => ({
517
+ id: m.account.id,
518
+ name: m.account.displayName,
519
+ state: m.role,
520
+ email: m.account.email,
521
+ joinedAt: m.joinedAt,
522
+ ...(m.anonymous && { anonymous: true }),
523
+ })),
524
+ };
525
+ },
511
526
  }),
512
527
  defineOperation({
513
528
  id: "orgs.invitations",
514
- description: "List the invitations of this conversation's org (org admins), oldest first: id, role, status (pending, accepted, expired or revoked), who created it and when, when it expires. Never the link: an invitation's link is shown only once, to the person who approved its creation.",
515
- input: z.object({ cursor: Cursor.optional() }).strict(),
516
- example: {},
529
+ description: "List the invitations of this conversation's org (org admins), every one ever made, newest first: id, role, status (pending, accepted, expired or revoked), who created it and when, when it expires. Never the link: an invitation's link is shown only once, to the person who approved its creation. Paged by page number: page (1-based) and size (20, 50 or 100); the answer has items, page, size and total (capped at 10000, totalCapped true above).",
530
+ input: InvitationListQuery.strict(),
531
+ example: { page: 1, size: 20 },
517
532
  authz: { orgAction: "org.invitations.manage" },
518
533
  mirrors: ["GET /api/v1/orgs/:orgId/invitations"],
519
- extras: ["cursor"],
520
534
  confirm: "read",
521
- run: async (input, ctx) => pageOf((await this.invitations.list(ctx.orgId)).map(invitationView), startOf(input.cursor), PAGE),
535
+ run: async (input, ctx) => {
536
+ const page = await this.invitations.page(ctx.orgId, input);
537
+ return { ...page, items: page.items.map(invitationView) };
538
+ },
522
539
  }),
523
540
  defineOperation({
524
541
  id: "orgs.invite",
@@ -2,6 +2,7 @@ import { ReplicaStatusStore } from "../extensions/sources.js";
2
2
  import { KernelConfigService } from "../infra/config/kernel-config.service.js";
3
3
  import { KernelDb } from "../infra/database/kernel-db.js";
4
4
  import { TransactionHost } from "../infra/database/transaction-host.js";
5
+ import type { HintPublisher } from "../invalidation/audiences.js";
5
6
  import type { KernelLogger } from "../log.js";
6
7
  import type { PushDeliverData } from "./jobs.js";
7
8
  import { PushProviderHost } from "./provider-host.js";
@@ -62,9 +63,10 @@ export declare class PushDelivery {
62
63
  private readonly replica;
63
64
  private readonly log;
64
65
  private readonly timeoutMs;
66
+ private readonly hints;
65
67
  constructor(kdb: KernelDb, txHost: TransactionHost, host: Pick<PushProviderHost, "provider" | "covers">, tokens: Pick<PushTokenStore, "open">, config: Pick<KernelConfigService, "get">,
66
68
  /** This process's replica id (its own `extension_replica_status` rows). */
67
- replica: Pick<ReplicaStatusStore, "replicaId">, log: KernelLogger, timeoutMs?: () => number);
69
+ replica: Pick<ReplicaStatusStore, "replicaId">, log: KernelLogger, timeoutMs: (() => number) | undefined, hints: HintPublisher);
68
70
  /** Delivers one job (see the class). */
69
71
  deliver(data: PushDeliverData): Promise<PushDeliveryOutcome>;
70
72
  /**