@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
@@ -2,6 +2,7 @@ import type { z } from "zod";
2
2
  import { type AdminAgentDetail, type AdminAgentRow, AdminAgents } from "../agents/admin-agents.js";
3
3
  import { AgentsService } from "../agents/agents.service.js";
4
4
  import { type Principal } from "../identity/principal.js";
5
+ import type { Page } from "../infra/paging/paged-read.js";
5
6
  import { AdminAgentListQuery, AgentIdParams, OwnerBody } from "./admin-items.schemas.js";
6
7
  /**
7
8
  * Every org's agents for the super admin (admin agents and connectors spec §4.1): read any agent,
@@ -12,11 +13,8 @@ export declare class AdminAgentsController {
12
13
  private readonly admin;
13
14
  private readonly agents;
14
15
  constructor(admin: AdminAgents, agents: AgentsService);
15
- /** Live agents of live orgs by id; `next` is the `after` of the next page, null at the end. */
16
- list(q: z.infer<typeof AdminAgentListQuery>): Promise<{
17
- agents: AdminAgentRow[];
18
- next: string | null;
19
- }>;
16
+ /** Live agents of live orgs, newest first, by page number (table pagination spec §2.3). */
17
+ list(q: z.infer<typeof AdminAgentListQuery>): Promise<Page<AdminAgentRow>>;
20
18
  get({ agentId }: z.infer<typeof AgentIdParams>): Promise<{
21
19
  agent: AdminAgentDetail;
22
20
  }>;
@@ -33,7 +33,7 @@ let AdminAgentsController = class AdminAgentsController {
33
33
  this.admin = admin;
34
34
  this.agents = agents;
35
35
  }
36
- /** Live agents of live orgs by id; `next` is the `after` of the next page, null at the end. */
36
+ /** Live agents of live orgs, newest first, by page number (table pagination spec §2.3). */
37
37
  list(q) {
38
38
  return this.admin.list(q);
39
39
  }
@@ -1,5 +1,6 @@
1
1
  import type { z } from "zod";
2
2
  import { type Principal } from "../identity/principal.js";
3
+ import type { Page } from "../infra/paging/paged-read.js";
3
4
  import { type AdminConnectorDetail, type AdminConnectorRow, AdminConnectors } from "../tools/admin-connectors.js";
4
5
  import { ConnectorsService } from "../tools/connectors.service.js";
5
6
  import { AdminConnectorListQuery, ConnectorIdParams, ConnectorStatusBody } from "./admin-items.schemas.js";
@@ -12,11 +13,8 @@ export declare class AdminConnectorsController {
12
13
  private readonly admin;
13
14
  private readonly connectors;
14
15
  constructor(admin: AdminConnectors, connectors: ConnectorsService);
15
- /** Live connectors of live orgs by id; `next` is the `after` of the next page, null at the end. */
16
- list(q: z.infer<typeof AdminConnectorListQuery>): Promise<{
17
- connectors: AdminConnectorRow[];
18
- next: string | null;
19
- }>;
16
+ /** Live connectors of live orgs, newest first, by page number (table pagination spec §2.3). */
17
+ list(q: z.infer<typeof AdminConnectorListQuery>): Promise<Page<AdminConnectorRow>>;
20
18
  get({ connectorId }: z.infer<typeof ConnectorIdParams>): Promise<{
21
19
  connector: AdminConnectorDetail;
22
20
  }>;
@@ -33,7 +33,7 @@ let AdminConnectorsController = class AdminConnectorsController {
33
33
  this.admin = admin;
34
34
  this.connectors = connectors;
35
35
  }
36
- /** Live connectors of live orgs by id; `next` is the `after` of the next page, null at the end. */
36
+ /** Live connectors of live orgs, newest first, by page number (table pagination spec §2.3). */
37
37
  list(q) {
38
38
  return this.admin.list(q);
39
39
  }
@@ -1,16 +1,16 @@
1
1
  import { z } from "zod";
2
2
  import type { RouteSchemas } from "../platform/route-schemas.js";
3
- /** `GET /api/v1/admin/agents`: org filter, name search, id paging. */
3
+ /** `GET /api/v1/admin/agents`: org filter, name search, page numbers (no snapshot: spec §2.3). */
4
4
  export declare const AdminAgentListQuery: z.ZodObject<{
5
- after: z.ZodOptional<z.ZodString>;
6
- limit: z.ZodDefault<z.ZodCoercedNumber<unknown>>;
5
+ page: z.ZodDefault<z.ZodCoercedNumber<unknown>>;
6
+ size: z.ZodDefault<z.ZodCoercedNumber<unknown>>;
7
7
  orgId: z.ZodOptional<z.ZodString>;
8
8
  q: z.ZodOptional<z.ZodString>;
9
9
  }, z.core.$strip>;
10
- /** `GET /api/v1/admin/connectors`: org and status filters, name search, id paging. */
10
+ /** `GET /api/v1/admin/connectors`: org and status filters, name search, page numbers. */
11
11
  export declare const AdminConnectorListQuery: z.ZodObject<{
12
- after: z.ZodOptional<z.ZodString>;
13
- limit: z.ZodDefault<z.ZodCoercedNumber<unknown>>;
12
+ page: z.ZodDefault<z.ZodCoercedNumber<unknown>>;
13
+ size: z.ZodDefault<z.ZodCoercedNumber<unknown>>;
14
14
  orgId: z.ZodOptional<z.ZodString>;
15
15
  status: z.ZodOptional<z.ZodEnum<{
16
16
  active: "active";
@@ -1,27 +1,23 @@
1
1
  import { z } from "zod";
2
+ import { PageQueryFields } from "../infra/paging/paged-read.js";
2
3
  /**
3
4
  * Schemas of the super admin's routes for every org's agents and connectors (admin agents and
4
5
  * connectors spec §4.1). Ids are `text` columns, so a malformed id cannot fail the query: it is
5
6
  * bounded here (400 `validation_failed` past 100 characters) and otherwise reads as not found.
6
7
  */
7
8
  const Id = z.string().min(1).max(100);
8
- const Paging = {
9
- /** The last id of the previous page (the `next` of the previous response). */
10
- after: Id.optional(),
11
- limit: z.coerce.number().int().min(1).max(200).default(50),
12
- };
13
- /** `GET /api/v1/admin/agents`: org filter, name search, id paging. */
9
+ /** `GET /api/v1/admin/agents`: org filter, name search, page numbers (no snapshot: spec §2.3). */
14
10
  export const AdminAgentListQuery = z.object({
15
11
  orgId: Id.optional(),
16
12
  q: z.string().max(200).optional(),
17
- ...Paging,
13
+ ...PageQueryFields,
18
14
  });
19
- /** `GET /api/v1/admin/connectors`: org and status filters, name search, id paging. */
15
+ /** `GET /api/v1/admin/connectors`: org and status filters, name search, page numbers. */
20
16
  export const AdminConnectorListQuery = z.object({
21
17
  orgId: Id.optional(),
22
18
  status: z.enum(["active", "disabled"]).optional(),
23
19
  q: z.string().max(200).optional(),
24
- ...Paging,
20
+ ...PageQueryFields,
25
21
  });
26
22
  export const AgentIdParams = z.object({ agentId: Id });
27
23
  export const ConnectorIdParams = z.object({ connectorId: Id });
@@ -9,15 +9,16 @@ import { SessionService } from "../identity/sessions.js";
9
9
  import { type DeploymentSettingsView, SettingsService } from "../identity/settings.js";
10
10
  import { KernelConfigService } from "../infra/config/kernel-config.service.js";
11
11
  import { KernelDb } from "../infra/database/kernel-db.js";
12
+ import type { Page } from "../infra/paging/paged-read.js";
12
13
  import { type ModelDisabledPatch, type ModelProviderParams } from "../models/enablement.controller.js";
13
14
  import { type ModelDisableResult, ModelEnablement } from "../models/enablement.js";
14
15
  import { type ModelPrice, type ModelPricePut, PricesService } from "../models/prices.js";
15
16
  import { ModelPurposesService, type PurposeListing, type PurposePut } from "../models/purposes.js";
16
17
  import { type Member, MembersService } from "../orgs/members.service.js";
17
- import { type Org, OrgsService } from "../orgs/orgs.service.js";
18
+ import { type Org, type OrgDirectoryEntry, OrgsService } from "../orgs/orgs.service.js";
18
19
  import { type PlatformProviderState, ProviderRegistry, type ProviderStatus } from "../runtime/providers.js";
19
20
  import { AccountErasures } from "./account-erasures.js";
20
- import { AccountErasureBody, AccountListQuery, AccountParams, AdminOrgParams, CreateAccountBody, DeploymentSettingsBody, ErasureDispositionBody, ErasureWorkParams, PurposeParams, UpdateAccountBody } from "./admin.schemas.js";
21
+ import { AccountErasureBody, AccountListQuery, AccountParams, AdminOrgListQuery, AdminOrgParams, CreateAccountBody, DeploymentSettingsBody, ErasureDispositionBody, ErasureWorkParams, PurposeParams, UpdateAccountBody } from "./admin.schemas.js";
21
22
  import { ErasureDispositions } from "./erasure-dispositions.js";
22
23
  import { type LimitDefaults } from "./limit-defaults.js";
23
24
  /**
@@ -45,12 +46,10 @@ export declare class AdminController {
45
46
  /** One account with its avatar URL and source. */
46
47
  private view;
47
48
  /**
48
- * 全部账号,按 id 升序分页:`next` 为下一页的游标(作为 `after` 传回),没有更多时为 null。
49
- * 多取一条判断是否还有下一页。
49
+ * Every account, newest first, by page number (table pagination spec §2.3, no snapshot), with
50
+ * whether account erasure is on.
50
51
  */
51
- listAccounts(q: z.infer<typeof AccountListQuery>): Promise<{
52
- accounts: AccountView[];
53
- next: string | null;
52
+ listAccounts(q: z.infer<typeof AccountListQuery>): Promise<Page<AccountView> & {
54
53
  erasureEnabled: boolean;
55
54
  }>;
56
55
  requestAccountErasure(principal: Principal, { accountId }: z.infer<typeof AccountParams>, _body: z.infer<typeof AccountErasureBody>): Promise<{
@@ -89,15 +88,22 @@ export declare class AdminController {
89
88
  account: AccountView;
90
89
  }>;
91
90
  /**
92
- * 全部组织的元数据与成员数(不含成员明细), with the deployment's defaults of the limits an org
91
+ * One page of the live orgs with their member counts (never the members), newest first, by
92
+ * page number (table pagination spec §2.3), with the deployment's defaults of the limits an org
93
93
  * can be given its own value of (the org limits dialog shows them for the values left empty).
94
94
  */
95
- listOrgs(): Promise<{
96
- orgs: (Org & {
97
- memberCount: number;
98
- })[];
95
+ listOrgs(q: z.infer<typeof AdminOrgListQuery>): Promise<Page<Org & {
96
+ memberCount: number;
97
+ }> & {
99
98
  limitDefaults: LimitDefaults;
100
99
  }>;
100
+ /**
101
+ * Every live org at once in the compact directory shape (id, slug, name), oldest first: the org
102
+ * filters, pickers and names of the console; the orgs table pages `GET orgs`.
103
+ */
104
+ orgDirectory(): Promise<{
105
+ orgs: OrgDirectoryEntry[];
106
+ }>;
101
107
  /**
102
108
  * The members of any live org (the agent owner transfer picks the new owner from them); the super
103
109
  * admin need not be a member. A missing or deleted org → `org.not_found`.
@@ -30,7 +30,7 @@ import { MembersService } from "../orgs/members.service.js";
30
30
  import { OrgsService } from "../orgs/orgs.service.js";
31
31
  import { ProviderRegistry, } from "../runtime/providers.js";
32
32
  import { AccountErasures } from "./account-erasures.js";
33
- import { AccountErasureBody, AccountListQuery, AccountParams, AdminOrgParams, CreateAccountBody, DeploymentSettingsBody, ErasureDispositionBody, ErasureWorkParams, PurposeParams, UpdateAccountBody, } from "./admin.schemas.js";
33
+ import { AccountErasureBody, AccountListQuery, AccountParams, AdminOrgListQuery, AdminOrgParams, CreateAccountBody, DeploymentSettingsBody, ErasureDispositionBody, ErasureWorkParams, PurposeParams, UpdateAccountBody, } from "./admin.schemas.js";
34
34
  import { ErasureDispositions } from "./erasure-dispositions.js";
35
35
  import { limitDefaults } from "./limit-defaults.js";
36
36
  class AccountErasureBodyDto extends createZodDto(AccountErasureBody, "AccountErasureBody") {
@@ -47,6 +47,8 @@ class UpdateAccountBodyDto extends createZodDto(UpdateAccountBody, "UpdateAccoun
47
47
  }
48
48
  class AccountParamsDto extends createZodDto(AccountParams, "AccountParams") {
49
49
  }
50
+ class AdminOrgListQueryDto extends createZodDto(AdminOrgListQuery, "AdminOrgListQuery") {
51
+ }
50
52
  class AdminOrgParamsDto extends createZodDto(AdminOrgParams, "AdminOrgParams") {
51
53
  }
52
54
  class PurposeParamsDto extends createZodDto(PurposeParams, "PurposeParams") {
@@ -99,20 +101,15 @@ let AdminController = class AdminController {
99
101
  return withAvatarUrl(this.db.db, account);
100
102
  }
101
103
  /**
102
- * 全部账号,按 id 升序分页:`next` 为下一页的游标(作为 `after` 传回),没有更多时为 null。
103
- * 多取一条判断是否还有下一页。
104
+ * Every account, newest first, by page number (table pagination spec §2.3, no snapshot), with
105
+ * whether account erasure is on.
104
106
  */
105
107
  async listAccounts(q) {
106
- const rows = await this.accounts.list({
107
- limit: q.limit + 1,
108
- ...(q.after !== undefined && { after: q.after }),
109
- });
110
- const page = rows.slice(0, q.limit);
111
- const next = rows.length > q.limit ? (page.at(-1)?.id ?? null) : null;
108
+ const page = await this.accounts.list(q);
112
109
  const retention = this.config.get().retention;
113
110
  return {
114
- accounts: await withAvatarUrls(this.db.db, page),
115
- next,
111
+ ...page,
112
+ items: await withAvatarUrls(this.db.db, page.items),
116
113
  erasureEnabled: retention.erasureEnabled && retention.destructiveEnabled,
117
114
  };
118
115
  }
@@ -162,11 +159,24 @@ let AdminController = class AdminController {
162
159
  return { account: await this.view(account) };
163
160
  }
164
161
  /**
165
- * 全部组织的元数据与成员数(不含成员明细), with the deployment's defaults of the limits an org
162
+ * One page of the live orgs with their member counts (never the members), newest first, by
163
+ * page number (table pagination spec §2.3), with the deployment's defaults of the limits an org
166
164
  * can be given its own value of (the org limits dialog shows them for the values left empty).
167
165
  */
168
- async listOrgs() {
169
- return { orgs: await this.orgs.listAll(), limitDefaults: limitDefaults(this.config) };
166
+ async listOrgs(q) {
167
+ const page = await this.orgs.page({
168
+ page: q.page,
169
+ size: q.size,
170
+ ...(q.q !== undefined && { q: q.q }),
171
+ });
172
+ return { ...page, limitDefaults: limitDefaults(this.config) };
173
+ }
174
+ /**
175
+ * Every live org at once in the compact directory shape (id, slug, name), oldest first: the org
176
+ * filters, pickers and names of the console; the orgs table pages `GET orgs`.
177
+ */
178
+ async orgDirectory() {
179
+ return { orgs: await this.orgs.directory() };
170
180
  }
171
181
  /**
172
182
  * The members of any live org (the agent owner transfer picks the new owner from them); the super
@@ -293,8 +303,12 @@ __decorate([
293
303
  __param(2, ZBody(UpdateAccountBodyDto))
294
304
  ], AdminController.prototype, "updateAccount", null);
295
305
  __decorate([
296
- Get("orgs")
306
+ Get("orgs"),
307
+ __param(0, ZQuery(AdminOrgListQueryDto))
297
308
  ], AdminController.prototype, "listOrgs", null);
309
+ __decorate([
310
+ Get("orgs/directory")
311
+ ], AdminController.prototype, "orgDirectory", null);
298
312
  __decorate([
299
313
  Get("orgs/:orgId/members"),
300
314
  __param(0, ZParam(AdminOrgParamsDto))
@@ -1,9 +1,9 @@
1
1
  import { z } from "zod";
2
2
  import type { RouteSchemas } from "../platform/route-schemas.js";
3
- /** `GET /api/v1/admin/accounts`: keyset paging by account id. */
3
+ /** `GET /api/v1/admin/accounts`: page numbers without a snapshot (table pagination spec §2.3). */
4
4
  export declare const AccountListQuery: z.ZodObject<{
5
- after: z.ZodOptional<z.ZodString>;
6
- limit: z.ZodDefault<z.ZodCoercedNumber<unknown>>;
5
+ page: z.ZodDefault<z.ZodCoercedNumber<unknown>>;
6
+ size: z.ZodDefault<z.ZodCoercedNumber<unknown>>;
7
7
  }, z.core.$strip>;
8
8
  export declare const CreateAccountBody: z.ZodObject<{
9
9
  login: z.ZodString;
@@ -179,6 +179,15 @@ export declare const DeploymentSettingsBody: z.ZodObject<{
179
179
  export declare const PurposeParams: z.ZodObject<{
180
180
  purpose: z.ZodString;
181
181
  }, z.core.$strip>;
182
+ /**
183
+ * `GET /api/v1/admin/orgs`: page numbers without a snapshot (spec §2.3) and a search (empty or
184
+ * blank: no search).
185
+ */
186
+ export declare const AdminOrgListQuery: z.ZodObject<{
187
+ page: z.ZodDefault<z.ZodCoercedNumber<unknown>>;
188
+ size: z.ZodDefault<z.ZodCoercedNumber<unknown>>;
189
+ q: z.ZodOptional<z.ZodString>;
190
+ }, z.core.$strip>;
182
191
  /** `:orgId` of an admin route: any org, the super admin need not be a member. */
183
192
  export declare const AdminOrgParams: z.ZodObject<{
184
193
  orgId: z.ZodString;
@@ -2,14 +2,12 @@ import { z } from "zod";
2
2
  import { externalDispositionBlockers } from "../erasure/external-evidence.js";
3
3
  import { MAX_PASSWORD_LENGTH } from "../identity/login.js";
4
4
  import { DEPLOYMENT_SETTINGS_PATCH } from "../identity/settings.js";
5
+ import { PageQueryFields } from "../infra/paging/paged-read.js";
5
6
  import { ModelDisabledPatch, ModelProviderParams } from "../models/enablement.controller.js";
6
7
  import { MODEL_PRICE_PUT } from "../models/prices.js";
7
8
  import { PURPOSE_PUT } from "../models/purposes.js";
8
- /** `GET /api/v1/admin/accounts`: keyset paging by account id. */
9
- export const AccountListQuery = z.object({
10
- after: z.string().min(1).optional(),
11
- limit: z.coerce.number().int().min(1).max(200).default(50),
12
- });
9
+ /** `GET /api/v1/admin/accounts`: page numbers without a snapshot (table pagination spec §2.3). */
10
+ export const AccountListQuery = z.object({ ...PageQueryFields });
13
11
  export const CreateAccountBody = z.object({
14
12
  login: z.string().min(1).max(64),
15
13
  password: z.string().min(1).max(MAX_PASSWORD_LENGTH),
@@ -34,6 +32,19 @@ export const UpdateAccountBody = z.object({
34
32
  /** At least one key; `runConcurrencyOverrides` merges by org, a null value drops that org's. */
35
33
  export const DeploymentSettingsBody = DEPLOYMENT_SETTINGS_PATCH.refine((b) => Object.keys(b).length > 0, { message: "at least one setting is required" });
36
34
  export const PurposeParams = z.object({ purpose: z.string().min(1).max(100) });
35
+ /**
36
+ * `GET /api/v1/admin/orgs`: page numbers without a snapshot (spec §2.3) and a search (empty or
37
+ * blank: no search).
38
+ */
39
+ export const AdminOrgListQuery = z.object({
40
+ q: z
41
+ .string()
42
+ .trim()
43
+ .max(200)
44
+ .optional()
45
+ .describe("Only orgs whose name or slug contains this (case-insensitive)."),
46
+ ...PageQueryFields,
47
+ });
37
48
  /** `:orgId` of an admin route: any org, the super admin need not be a member. */
38
49
  export const AdminOrgParams = z.object({ orgId: z.string().min(1).max(100) });
39
50
  export const ADMIN_ROUTES = [
@@ -56,7 +67,7 @@ export const ADMIN_ROUTES = [
56
67
  params: ErasureWorkParams,
57
68
  body: ErasureDispositionBody,
58
69
  },
59
- { route: "GET /api/v1/admin/orgs" },
70
+ { route: "GET /api/v1/admin/orgs", query: AdminOrgListQuery },
60
71
  // `:orgId` is the conversation's org for the operation, so never an operation field
61
72
  { route: "GET /api/v1/admin/orgs/:orgId/members" },
62
73
  { route: "GET /api/v1/admin/settings" },
@@ -1,4 +1,5 @@
1
1
  import { KernelDb } from "../infra/database/kernel-db.js";
2
+ import { type Page } from "../infra/paging/paged-read.js";
2
3
  import { AgentLookup, type AgentVisibility } from "./agent-lookup.js";
3
4
  import { type AgentDefinition } from "./definition.js";
4
5
  import type { AgentAvatarView } from "./profile.js";
@@ -69,9 +70,10 @@ export interface AdminAgentListQuery {
69
70
  orgId?: string | undefined;
70
71
  /** Case-insensitive substring of the name; LIKE wildcards match literally. */
71
72
  q?: string | undefined;
72
- /** The last id of the previous page. */
73
- after?: string | undefined;
74
- limit: number;
73
+ /** The page, 1-based. */
74
+ page: number;
75
+ /** Rows per page: 20, 50 or 100. */
76
+ size: number;
75
77
  }
76
78
  /**
77
79
  * Cross-org agent reads for the super admin (admin agents spec §3.2, §3.3): every org's live
@@ -82,11 +84,11 @@ export declare class AdminAgents {
82
84
  private readonly db;
83
85
  private readonly lookup;
84
86
  constructor(db: KernelDb, lookup: AgentLookup);
85
- /** Live agents of live orgs by id, `limit` per page; `next` is the last id when more follow. */
86
- list(q: AdminAgentListQuery): Promise<{
87
- agents: AdminAgentRow[];
88
- next: string | null;
89
- }>;
87
+ /**
88
+ * One page of every live org's live agents, filtered, newest first (`created_at`, then id), by
89
+ * page number without a snapshot (table pagination spec §2.3: agents are edited in place).
90
+ */
91
+ list(q: AdminAgentListQuery): Promise<Page<AdminAgentRow>>;
90
92
  /** One live agent of a live org; otherwise `agent.not_found`. */
91
93
  get(agentId: string): Promise<AdminAgentDetail>;
92
94
  /**
@@ -13,6 +13,7 @@ import { escapeLike } from "../conversations/conversations.service.js";
13
13
  import { ApiError } from "../errors.js";
14
14
  import { avatarColumns, personAvatarUrl } from "../identity/account-avatar.js";
15
15
  import { KernelDb } from "../infra/database/kernel-db.js";
16
+ import { assertReadablePage, cappedCount, PAGED_TOTAL_CAP, pageOf, pageOffset, } from "../infra/paging/paged-read.js";
16
17
  import { agentSkills, builtinSkillIds, builtinSkillPlugins, linkedCopyIds, skillIdsOf, usableSkillVersions, } from "../skills/usable.js";
17
18
  import { AgentLookup } from "./agent-lookup.js";
18
19
  import { avatarView } from "./avatar-view.js";
@@ -30,24 +31,27 @@ let AdminAgents = class AdminAgents {
30
31
  this.db = db;
31
32
  this.lookup = lookup;
32
33
  }
33
- /** Live agents of live orgs by id, `limit` per page; `next` is the last id when more follow. */
34
+ /**
35
+ * One page of every live org's live agents, filtered, newest first (`created_at`, then id), by
36
+ * page number without a snapshot (table pagination spec §2.3: agents are edited in place).
37
+ */
34
38
  async list(q) {
39
+ assertReadablePage(q.page, q.size);
35
40
  let query = this.rows();
36
41
  if (q.orgId !== undefined)
37
42
  query = query.where("agents.org_id", "=", q.orgId);
38
43
  if (q.q !== undefined && q.q !== "") {
39
44
  query = query.where(sql `agent_versions.definition->>'name' ILIKE ${`%${escapeLike(q.q)}%`} ESCAPE '\\'`);
40
45
  }
41
- if (q.after !== undefined)
42
- query = query.where("agents.id", ">", q.after);
46
+ const counted = await cappedCount(this.db.db, query, PAGED_TOTAL_CAP);
43
47
  const rows = await query
44
- .orderBy("agents.id")
45
- .limit(q.limit + 1)
48
+ .orderBy("agents.created_at", "desc")
49
+ .orderBy("agents.id", "desc")
50
+ .offset(pageOffset(q.page, q.size))
51
+ .limit(q.size)
46
52
  .execute();
47
- const kept = rows.slice(0, q.limit);
48
- const off = await this.skillsOff(kept);
49
- const page = kept.map((r) => toRow(r, off.get(r.id) ?? 0));
50
- return { agents: page, next: rows.length > q.limit ? (page.at(-1)?.id ?? null) : null };
53
+ const off = await this.skillsOff(rows);
54
+ return pageOf(rows.map((r) => toRow(r, off.get(r.id) ?? 0)), q, counted);
51
55
  }
52
56
  /** One live agent of a live org; otherwise `agent.not_found`. */
53
57
  async get(agentId) {
@@ -10,6 +10,7 @@ import { DeviceProviderSelectionModule } from "../devices/device-provider-select
10
10
  import { EvalBudgetModule } from "../evals/budget.js";
11
11
  import { ExtensionsModule } from "../extensions/extensions.module.js";
12
12
  import { LifecycleHooksModule } from "../extensions/lifecycle-hooks.js";
13
+ import { InvalidationHintsModule } from "../invalidation/invalidation-hints.module.js";
13
14
  import { ModelsModule } from "../models/models.module.js";
14
15
  import { OrgLockModule } from "../orgs/org-lock.js";
15
16
  import { ProvidersModule } from "../runtime/providers.js";
@@ -41,6 +42,8 @@ let AgentsModule = class AgentsModule {
41
42
  AgentsModule = __decorate([
42
43
  Module({
43
44
  imports: [
45
+ // invalidation hints its writers publish after their commit
46
+ InvalidationHintsModule,
44
47
  AgentLookupModule,
45
48
  DeviceProviderSelectionModule,
46
49
  // avatar uploads
@@ -845,7 +845,7 @@ let AgentsService = class AgentsService {
845
845
  .where("org_id", "=", orgId)
846
846
  .execute();
847
847
  // the new owner hears about the agent's connector setup request (P4-T6-4)
848
- await this.setupRequests.retargetIn([agentId], newOwnerId);
848
+ await this.setupRequests.retargetIn([agentId], newOwnerId, agent.owner_account_id);
849
849
  // the previous owner's asks to share the agent's skills lapse (the new owner did not ask);
850
850
  // a share request has no draft or trial, so nothing is left to clean up after the commit
851
851
  await this.skillChanges.cancelPendingForAgent(orgId, agentId, actor.accountId, "owner_changed", actor.tokenId, ["share"]);
@@ -3,6 +3,7 @@ import { type Owner } from "../catalog/ownership.js";
3
3
  import type { KernelSchemaDb } from "../db/kernel-schema.js";
4
4
  import { KernelDb } from "../infra/database/kernel-db.js";
5
5
  import { TransactionHost } from "../infra/database/transaction-host.js";
6
+ import type { HintPublisher } from "../invalidation/audiences.js";
6
7
  import { OrgLock } from "../orgs/org-lock.js";
7
8
  import { ToolRegistry } from "../tools/registry.js";
8
9
  import { AgentLookup, type AgentView } from "./agent-lookup.js";
@@ -118,9 +119,10 @@ export declare class OrgAgentTemplates {
118
119
  readonly txHost: TransactionHost;
119
120
  /** The extension tools loaded here (a wholly turned-off extension saved as its tool keys). */
120
121
  private readonly tools;
122
+ private readonly hints;
121
123
  constructor(kdb: KernelDb, orgLock: Pick<OrgLock, "lockAndAuthorize">, agents: Pick<AgentLookup, "view">, txHost: TransactionHost,
122
124
  /** The extension tools loaded here (a wholly turned-off extension saved as its tool keys). */
123
- tools: Pick<ToolRegistry, "extensionToolSpecs">);
125
+ tools: Pick<ToolRegistry, "extensionToolSpecs">, hints: HintPublisher);
124
126
  private get db();
125
127
  /**
126
128
  * 另存为模板 (ruling P4-9): the org's live agent `agentId` (any one: an org admin may edit every
@@ -21,6 +21,7 @@ import { notifySharedUpdate } from "../inbox/org-notices.js";
21
21
  import { KernelDb } from "../infra/database/kernel-db.js";
22
22
  import { TransactionHost } from "../infra/database/transaction-host.js";
23
23
  import { Transactional } from "../infra/database/transactional.decorator.js";
24
+ import { InvalidationHints } from "../invalidation/invalidation-hints.js";
24
25
  import { OrgLock } from "../orgs/org-lock.js";
25
26
  import { builtinSkillIds, builtinSkillPlugins, linkedCopyIds, skillIdsOf, skillVersionsById, usableSkillVersions, } from "../skills/usable.js";
26
27
  import { canonicalJson } from "../tools/canonical-json.js";
@@ -590,14 +591,16 @@ let OrgAgentTemplates = class OrgAgentTemplates {
590
591
  agents;
591
592
  txHost;
592
593
  tools;
594
+ hints;
593
595
  constructor(kdb, orgLock, agents, txHost,
594
596
  /** The extension tools loaded here (a wholly turned-off extension saved as its tool keys). */
595
- tools) {
597
+ tools, hints) {
596
598
  this.kdb = kdb;
597
599
  this.orgLock = orgLock;
598
600
  this.agents = agents;
599
601
  this.txHost = txHost;
600
602
  this.tools = tools;
603
+ this.hints = hints;
601
604
  }
602
605
  get db() {
603
606
  return this.kdb.db;
@@ -809,7 +812,7 @@ let OrgAgentTemplates = class OrgAgentTemplates {
809
812
  created_by: actor,
810
813
  })
811
814
  .execute();
812
- await notifySharedUpdate(t, { kind: "agent_template", id: row.link }, { name: row.name, from: String(p.current_version), to: String(to) });
815
+ await notifySharedUpdate(t, this.hints, { kind: "agent_template", id: row.link }, { name: row.name, from: String(p.current_version), to: String(to) });
813
816
  await audit(t, {
814
817
  actorAccountId: actor,
815
818
  ...(actorTokenId !== undefined && { actorTokenId }),
@@ -924,6 +927,7 @@ OrgAgentTemplates = __decorate([
924
927
  __param(1, Inject(OrgLock)),
925
928
  __param(2, Inject(AgentLookup)),
926
929
  __param(3, Inject(TransactionHost)),
927
- __param(4, Inject(ToolRegistry))
930
+ __param(4, Inject(ToolRegistry)),
931
+ __param(5, Inject(InvalidationHints))
928
932
  ], OrgAgentTemplates);
929
933
  export { OrgAgentTemplates };
@@ -1,12 +1,15 @@
1
1
  import type { KernelSchemaDb } from "../db/kernel-schema.js";
2
2
  import { KernelDb } from "../infra/database/kernel-db.js";
3
3
  import { TransactionHost } from "../infra/database/transaction-host.js";
4
+ import type { HintPublisher } from "../invalidation/audiences.js";
4
5
  /**
5
6
  * Moves the agents' setup requests that still concern their owner (pending, or decided and not
6
7
  * dismissed) to the new owner `owner` (an owner change: `AgentsService.reassignOwner`, member
7
- * offboarding). Runs through `db` (the caller's transaction).
8
+ * offboarding). Runs through `db` (the caller's transaction); the moved rows publish `requests`
9
+ * after the commit to the new owner and the org's admins, and to `previousOwner` when the caller
10
+ * holds it (an owner change; offboarding's previous owner leaves the org, so it passes none).
8
11
  */
9
- export declare function retargetSetupRequests(db: KernelSchemaDb, agentIds: readonly string[], owner: string): Promise<void>;
12
+ export declare function retargetSetupRequests(db: KernelSchemaDb, hints: HintPublisher, agentIds: readonly string[], owner: string, previousOwner?: string): Promise<void>;
10
13
  /** What {@link PendingConnectorRequests.openFor} receives: plain values, no transaction. */
11
14
  export interface PendingConnectorRequestArgs {
12
15
  orgId: string;
@@ -31,7 +34,8 @@ export type PendingRequestClose = "approved" | "cancelled";
31
34
  export declare class PendingConnectorRequests {
32
35
  private readonly kdb;
33
36
  readonly txHost: TransactionHost;
34
- constructor(kdb: KernelDb, txHost: TransactionHost);
37
+ private readonly hints;
38
+ constructor(kdb: KernelDb, txHost: TransactionHost, hints: HintPublisher);
35
39
  /**
36
40
  * The request for a new agent, requested by its owner (ruling P4-T6-4). `args.keys` are what the
37
41
  * create saw; {@link open} reads the agent's pending keys again under its row.
@@ -60,7 +64,9 @@ export declare class PendingConnectorRequests {
60
64
  * The agent's new owner receives its setup request's decision (fix round 1, item 4): the pending
61
65
  * request and the decided ones not dismissed move to `owner`. In the caller's transaction.
62
66
  */
63
- retargetIn(agentIds: readonly string[], owner: string): Promise<void>;
67
+ retargetIn(agentIds: readonly string[], owner: string,
68
+ /** The owner the requests move from (it gets a `requests` hint). */
69
+ previousOwner?: string): Promise<void>;
64
70
  /**
65
71
  * Settles the agent's pending request after a definition write, in the caller's transaction
66
72
  * (it holds the agent row lock): `keys` are the agent's pending connector keys now. The request