@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
@@ -18,6 +18,8 @@ import { KernelDb } from "../infra/database/kernel-db.js";
18
18
  import { TransactionHost } from "../infra/database/transaction-host.js";
19
19
  import { Transactional } from "../infra/database/transactional.decorator.js";
20
20
  import { KERNEL_LOGGER } from "../infra/tokens.js";
21
+ import { publishOrgAdminsInbox } from "../invalidation/audiences.js";
22
+ import { InvalidationHints } from "../invalidation/invalidation-hints.js";
21
23
  import { OrgLock } from "../orgs/org-lock.js";
22
24
  import { StorageService } from "../storage/storage.service.js";
23
25
  import { assertShareableName, isOrgAdmin, shareSkillIn } from "./agent-skills.service.js";
@@ -56,10 +58,13 @@ let SkillChangesService = class SkillChangesService {
56
58
  txHost;
57
59
  orgLock;
58
60
  skills;
61
+ hints;
59
62
  catalogDeps;
60
63
  constructor(db, storage, eventLog, log, txHost, orgLock,
61
64
  /** An approved version is an org skill version. */
62
- skills) {
65
+ skills,
66
+ /** A decision publishes `inbox` to the org's admins after the commit. */
67
+ hints) {
63
68
  this.db = db;
64
69
  this.storage = storage;
65
70
  this.eventLog = eventLog;
@@ -67,7 +72,8 @@ let SkillChangesService = class SkillChangesService {
67
72
  this.txHost = txHost;
68
73
  this.orgLock = orgLock;
69
74
  this.skills = skills;
70
- this.catalogDeps = { db, log, eventLog };
75
+ this.hints = hints;
76
+ this.catalogDeps = { db, log, eventLog, hints };
71
77
  }
72
78
  /**
73
79
  * An org admin decides a request (see the class comment): not an org admin -> 403 `forbidden`;
@@ -273,6 +279,7 @@ let SkillChangesService = class SkillChangesService {
273
279
  .where("org_id", "=", orgId)
274
280
  .returningAll()
275
281
  .executeTakeFirstOrThrow();
282
+ publishOrgAdminsInbox(this.hints, [orgId]);
276
283
  await audit(this.db.db, {
277
284
  actorAccountId: accountId,
278
285
  ...(actorTokenId !== undefined && { actorTokenId }),
@@ -485,7 +492,8 @@ SkillChangesService = __decorate([
485
492
  __param(3, Inject(KERNEL_LOGGER)),
486
493
  __param(4, Inject(TransactionHost)),
487
494
  __param(5, Inject(OrgLock)),
488
- __param(6, Inject(SkillsService))
495
+ __param(6, Inject(SkillsService)),
496
+ __param(7, Inject(InvalidationHints))
489
497
  ], SkillChangesService);
490
498
  export { SkillChangesService };
491
499
  /**
@@ -2,6 +2,7 @@ import { type Selectable } from "kysely";
2
2
  import type { EventLog } from "../conversations/event-log.js";
3
3
  import type { SkillChangeRequestsTable } from "../db/kernel-schema.js";
4
4
  import type { KernelDb } from "../infra/database/kernel-db.js";
5
+ import { type HintPublisher } from "../invalidation/audiences.js";
5
6
  import type { KernelLogger } from "../log.js";
6
7
  import { type SkillsSnapshot } from "../runtime/context/skills.js";
7
8
  /** What appending a conversation's skills catalog snapshot needs. */
@@ -9,6 +10,8 @@ export interface ConversationCatalogDeps {
9
10
  db: KernelDb;
10
11
  log: KernelLogger;
11
12
  eventLog: EventLog;
13
+ /** A cancelled change request publishes `inbox` to its org's admins after the commit. */
14
+ hints: HintPublisher;
12
15
  }
13
16
  /** Cancelled requests: draft prefixes to delete and (conversation, seq) to publish after the commit. */
14
17
  export interface CancelledDrafts {
@@ -1,5 +1,6 @@
1
1
  import { sql } from "kysely";
2
2
  import { audit } from "../identity/audit.js";
3
+ import { publishOrgAdminsInbox } from "../invalidation/audiences.js";
3
4
  import { sameSnapshot } from "../runtime/context/skills.js";
4
5
  import { invocationOf, lockLatestCatalog } from "./catalog.js";
5
6
  const byName = (a, b) => a.name < b.name ? -1 : a.name > b.name ? 1 : 0;
@@ -116,6 +117,7 @@ export async function cancelRequestIn(deps, req, out, how) {
116
117
  .where("id", "=", req.id)
117
118
  .where("org_id", "=", req.org_id)
118
119
  .execute();
120
+ publishOrgAdminsInbox(deps.hints, [req.org_id]);
119
121
  await audit(deps.db.db, {
120
122
  actorAccountId: how.actorAccountId,
121
123
  ...(how.actorTokenId !== undefined && { actorTokenId: how.actorTokenId }),
@@ -10,6 +10,7 @@ import { CatalogImportModule } from "../catalog/catalog-import.module.js";
10
10
  import { AttachmentsModule } from "../conversations/attachments.module.js";
11
11
  import { EventLogModule } from "../conversations/event-log.js";
12
12
  import { DevicesModule } from "../devices/devices.module.js";
13
+ import { InvalidationHintsModule } from "../invalidation/invalidation-hints.module.js";
13
14
  import { OrgLockModule } from "../orgs/org-lock.js";
14
15
  import { SandboxModule } from "../sandbox/sandbox.module.js";
15
16
  import { StorageModule } from "../storage/storage.module.js";
@@ -28,6 +29,8 @@ let SkillsModule = class SkillsModule {
28
29
  SkillsModule = __decorate([
29
30
  Module({
30
31
  imports: [
32
+ // invalidation hints its writers publish after their commit
33
+ InvalidationHintsModule,
31
34
  StorageModule,
32
35
  OrgLockModule,
33
36
  EventLogModule,
@@ -7,6 +7,7 @@ import type { KernelSchemaDb, SkillManifest, SourceFormat } from "../db/kernel-s
7
7
  import { ApiError } from "../errors.js";
8
8
  import { KernelDb } from "../infra/database/kernel-db.js";
9
9
  import { TransactionHost } from "../infra/database/transaction-host.js";
10
+ import type { HintPublisher } from "../invalidation/audiences.js";
10
11
  import type { KernelLogger } from "../log.js";
11
12
  import { OrgLock } from "../orgs/org-lock.js";
12
13
  import { StorageService } from "../storage/storage.service.js";
@@ -157,9 +158,10 @@ export declare class SkillsService {
157
158
  private readonly platform;
158
159
  private readonly eventLog;
159
160
  private readonly log;
161
+ private readonly hints;
160
162
  constructor(db: KernelDb, storage: StorageService, attachments: AttachmentsService, txHost: TransactionHost, orgLock: OrgLock,
161
163
  /** The owner's new versions of a skill it promoted go to the platform row (ruling P3-4). */
162
- platform: PlatformComponents, eventLog: EventLog, log: KernelLogger);
164
+ platform: PlatformComponents, eventLog: EventLog, log: KernelLogger, hints: HintPublisher);
163
165
  private readonly catalogDeps;
164
166
  /**
165
167
  * Writes a package's files where its version will live: for a new version of a skill the org
@@ -27,6 +27,7 @@ import { KernelDb } from "../infra/database/kernel-db.js";
27
27
  import { TransactionHost } from "../infra/database/transaction-host.js";
28
28
  import { Transactional } from "../infra/database/transactional.decorator.js";
29
29
  import { KERNEL_LOGGER } from "../infra/tokens.js";
30
+ import { InvalidationHints } from "../invalidation/invalidation-hints.js";
30
31
  import { OrgLock } from "../orgs/org-lock.js";
31
32
  import { StorageService } from "../storage/storage.service.js";
32
33
  import { invocationOf } from "./catalog.js";
@@ -335,9 +336,10 @@ let SkillsService = class SkillsService {
335
336
  platform;
336
337
  eventLog;
337
338
  log;
339
+ hints;
338
340
  constructor(db, storage, attachments, txHost, orgLock,
339
341
  /** The owner's new versions of a skill it promoted go to the platform row (ruling P3-4). */
340
- platform, eventLog, log) {
342
+ platform, eventLog, log, hints) {
341
343
  this.db = db;
342
344
  this.storage = storage;
343
345
  this.attachments = attachments;
@@ -346,7 +348,8 @@ let SkillsService = class SkillsService {
346
348
  this.platform = platform;
347
349
  this.eventLog = eventLog;
348
350
  this.log = log;
349
- this.catalogDeps = { db, log, eventLog };
351
+ this.hints = hints;
352
+ this.catalogDeps = { db, log, eventLog, hints };
350
353
  }
351
354
  catalogDeps;
352
355
  /**
@@ -560,7 +563,7 @@ let SkillsService = class SkillsService {
560
563
  ...opts.auditDetail,
561
564
  },
562
565
  });
563
- await notifySharedUpdate(this.db.db, { kind: "skill", id: promoted }, { name: pkg.name, from: String(version - 1), to: String(version) });
566
+ await notifySharedUpdate(this.db.db, this.hints, { kind: "skill", id: promoted }, { name: pkg.name, from: String(version - 1), to: String(version) });
564
567
  return {
565
568
  skill: await this.promotedSummary(existing.id, promoted),
566
569
  version,
@@ -1100,7 +1103,8 @@ SkillsService = __decorate([
1100
1103
  __param(4, Inject(OrgLock)),
1101
1104
  __param(5, Inject(PlatformComponents)),
1102
1105
  __param(6, Inject(EventLog)),
1103
- __param(7, Inject(KERNEL_LOGGER))
1106
+ __param(7, Inject(KERNEL_LOGGER)),
1107
+ __param(8, Inject(InvalidationHints))
1104
1108
  ], SkillsService);
1105
1109
  export { SkillsService };
1106
1110
  /**
@@ -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 type { ToolPolicy } from "./registry.js";
3
4
  /** One connector in the super admin's cross-org list (no endpoint, auth or credential). */
4
5
  export interface AdminConnectorRow {
@@ -47,9 +48,10 @@ export interface AdminConnectorQuery {
47
48
  status?: "active" | "disabled" | undefined;
48
49
  /** A case-insensitive substring of the connector name. */
49
50
  q?: string | undefined;
50
- /** The last id of the previous page. */
51
- after?: string | undefined;
52
- limit: number;
51
+ /** The page, 1-based. */
52
+ page: number;
53
+ /** Rows per page: 20, 50 or 100. */
54
+ size: number;
53
55
  }
54
56
  /**
55
57
  * Cross-org reads of connectors for the super admin (spec
@@ -61,11 +63,11 @@ export declare class AdminConnectors {
61
63
  constructor(kdb: KernelDb);
62
64
  private get db();
63
65
  private base;
64
- /** Live connectors of every live org by id, filtered; `next` is the last id when more follow. */
65
- list(q: AdminConnectorQuery): Promise<{
66
- connectors: AdminConnectorRow[];
67
- next: string | null;
68
- }>;
66
+ /**
67
+ * One page of every live org's live connectors, filtered, newest first (`created_at`, then id),
68
+ * by page number without a snapshot (table pagination spec §2.3: connectors are edited in place).
69
+ */
70
+ list(q: AdminConnectorQuery): Promise<Page<AdminConnectorRow>>;
69
71
  /** One live connector of a live org; else `connector.not_found`. */
70
72
  get(connectorId: string): Promise<AdminConnectorDetail>;
71
73
  }
@@ -12,6 +12,7 @@ import { sql } from "kysely";
12
12
  import { ApiError } from "../errors.js";
13
13
  import { avatarColumns, personAvatarUrl } from "../identity/account-avatar.js";
14
14
  import { KernelDb } from "../infra/database/kernel-db.js";
15
+ import { assertReadablePage, cappedCount, PAGED_TOTAL_CAP, pageOf, pageOffset, } from "../infra/paging/paged-read.js";
15
16
  import { endpointView } from "./endpoint.js";
16
17
  const notFound = () => new ApiError("connector.not_found", "Connector not found");
17
18
  /**
@@ -57,8 +58,12 @@ let AdminConnectors = class AdminConnectors {
57
58
  .where("c.deleted_at", "is", null)
58
59
  .where("o.deleted_at", "is", null));
59
60
  }
60
- /** Live connectors of every live org by id, filtered; `next` is the last id when more follow. */
61
+ /**
62
+ * One page of every live org's live connectors, filtered, newest first (`created_at`, then id),
63
+ * by page number without a snapshot (table pagination spec §2.3: connectors are edited in place).
64
+ */
61
65
  async list(q) {
66
+ assertReadablePage(q.page, q.size);
62
67
  let query = this.base();
63
68
  if (q.orgId !== undefined)
64
69
  query = query.where("c.org_id", "=", q.orgId);
@@ -68,17 +73,14 @@ let AdminConnectors = class AdminConnectors {
68
73
  const like = `%${q.q.replace(/[\\%_]/g, (ch) => `\\${ch}`)}%`;
69
74
  query = query.where(sql `c.name ILIKE ${like} ESCAPE '\\'`);
70
75
  }
71
- if (q.after !== undefined)
72
- query = query.where("c.id", ">", q.after);
76
+ const counted = await cappedCount(this.db, query, PAGED_TOTAL_CAP);
73
77
  const rows = await query
74
- .orderBy("c.id")
75
- .limit(q.limit + 1)
78
+ .orderBy("c.created_at", "desc")
79
+ .orderBy("c.id", "desc")
80
+ .offset(pageOffset(q.page, q.size))
81
+ .limit(q.size)
76
82
  .execute();
77
- const page = rows.slice(0, q.limit).map(toRow);
78
- return {
79
- connectors: page,
80
- next: rows.length > q.limit ? (page[page.length - 1]?.id ?? null) : null,
81
- };
83
+ return pageOf(rows.map(toRow), q, counted);
82
84
  }
83
85
  /** One live connector of a live org; else `connector.not_found`. */
84
86
  async get(connectorId) {
@@ -12,6 +12,7 @@ import { KernelDb } from "../infra/database/kernel-db.js";
12
12
  import { TransactionHost } from "../infra/database/transaction-host.js";
13
13
  import { KernelEvents } from "../infra/events/kernel-events.js";
14
14
  import { LockService } from "../infra/lock/lock.service.js";
15
+ import { type HintPublisher } from "../invalidation/audiences.js";
15
16
  import { OrgLock } from "../orgs/org-lock.js";
16
17
  import { type OrgRole } from "../orgs/roles.js";
17
18
  import type { FileCardDetail } from "../platform/file-ref.js";
@@ -539,6 +540,8 @@ export declare class ApprovalsService {
539
540
  private readonly sealed;
540
541
  /** A network ask's "add to this device's list" writes the device's own network list. */
541
542
  private readonly devices;
543
+ /** Every insert and status change publishes `inbox` to whoever the approval asks. */
544
+ private readonly hints;
542
545
  private readonly permissionLocks?;
543
546
  private readonly permissionGrants?;
544
547
  /** A loopback port ask's approval writes the root conversation's grant (absent: refused). */
@@ -560,7 +563,9 @@ export declare class ApprovalsService {
560
563
  /** A person's entered values are sealed in the decision's transaction (§4.3). */
561
564
  sealed: Pick<SealedInputs, "sealIn">,
562
565
  /** A network ask's "add to this device's list" writes the device's own network list. */
563
- devices: Pick<DevicesService, "lockNetworkAddSubject" | "addNetworkHostsIn">, permissionLocks?: PermissionAuthorityLock | undefined, permissionGrants?: PermissionCallGrants | undefined,
566
+ devices: Pick<DevicesService, "lockNetworkAddSubject" | "addNetworkHostsIn">,
567
+ /** Every insert and status change publishes `inbox` to whoever the approval asks. */
568
+ hints: HintPublisher, permissionLocks?: PermissionAuthorityLock | undefined, permissionGrants?: PermissionCallGrants | undefined,
564
569
  /** A loopback port ask's approval writes the root conversation's grant (absent: refused). */
565
570
  loopback?: Pick<LoopbackGrants, "grantIn" | "refusalNow" | "liveLockedIn"> | undefined, site?: DeviceSiteGrants | undefined, orgLock?: OrgLock | undefined, extensions?: Pick<ExtensionRegistry, "current"> | undefined);
566
571
  /**
@@ -831,6 +836,12 @@ export declare class ApprovalsService {
831
836
  private lockConversations;
832
837
  /** `conversationId` and its sub-agents' conversations at any depth (at most 16 levels). */
833
838
  private subtreeOf;
839
+ /**
840
+ * Publishes `inbox` after the commit to whoever the approval asks (account invalidation stream
841
+ * spec §4): its `requested_for` person, else the role topic of its `approver_role`. Called for
842
+ * every insert and every status change (decision, expiry, cancel, skip, supersede).
843
+ */
844
+ private hintApproval;
834
845
  /**
835
846
  * 系统写的 `approval_decided`(超时 / 取消,处理人为 null;跳过,处理人为消息作者),在当前事务内;返回事件 seq。
836
847
  */
@@ -37,6 +37,8 @@ import { Transactional } from "../infra/database/transactional.decorator.js";
37
37
  import { KernelEvents } from "../infra/events/kernel-events.js";
38
38
  import { LockService } from "../infra/lock/lock.service.js";
39
39
  import { WithLock } from "../infra/lock/with-lock.decorator.js";
40
+ import { approvalTopics } from "../invalidation/audiences.js";
41
+ import { InvalidationHints } from "../invalidation/invalidation-hints.js";
40
42
  import { OrgLock } from "../orgs/org-lock.js";
41
43
  import { ORG_ROLES, roleAtLeast } from "../orgs/roles.js";
42
44
  import { checkPersonValue } from "../platform/person-fields.js";
@@ -252,6 +254,7 @@ let ApprovalsService = class ApprovalsService {
252
254
  leakCheck;
253
255
  sealed;
254
256
  devices;
257
+ hints;
255
258
  permissionLocks;
256
259
  permissionGrants;
257
260
  loopback;
@@ -272,7 +275,9 @@ let ApprovalsService = class ApprovalsService {
272
275
  /** A person's entered values are sealed in the decision's transaction (§4.3). */
273
276
  sealed,
274
277
  /** A network ask's "add to this device's list" writes the device's own network list. */
275
- devices, permissionLocks, permissionGrants,
278
+ devices,
279
+ /** Every insert and status change publishes `inbox` to whoever the approval asks. */
280
+ hints, permissionLocks, permissionGrants,
276
281
  /** A loopback port ask's approval writes the root conversation's grant (absent: refused). */
277
282
  loopback, site, orgLock, extensions) {
278
283
  this.db = db;
@@ -288,6 +293,7 @@ let ApprovalsService = class ApprovalsService {
288
293
  this.leakCheck = leakCheck;
289
294
  this.sealed = sealed;
290
295
  this.devices = devices;
296
+ this.hints = hints;
291
297
  this.permissionLocks = permissionLocks;
292
298
  this.permissionGrants = permissionGrants;
293
299
  this.loopback = loopback;
@@ -321,7 +327,7 @@ let ApprovalsService = class ApprovalsService {
321
327
  .forUpdate()
322
328
  .execute();
323
329
  if (input.supersedesOrgAsk !== undefined) {
324
- await t
330
+ const superseded = await t
325
331
  .updateTable("approvals")
326
332
  .set({ status: "superseded", superseded_reason: "The organization’s tool policy changed" })
327
333
  .where("org_id", "=", input.orgId)
@@ -330,7 +336,10 @@ let ApprovalsService = class ApprovalsService {
330
336
  .where("kind", "=", "tool")
331
337
  .where("id", "=", input.supersedesOrgAsk)
332
338
  .where("status", "in", ["pending", "approved"])
339
+ .returningAll()
333
340
  .execute();
341
+ for (const r of superseded)
342
+ this.hintApproval(toRecord(r));
334
343
  }
335
344
  await t
336
345
  .insertInto("approvals")
@@ -365,6 +374,7 @@ let ApprovalsService = class ApprovalsService {
365
374
  .where("attempt", "=", input.attempt ?? 1)
366
375
  .executeTakeFirstOrThrow();
367
376
  const rec = toRecord(row);
377
+ this.hintApproval(rec);
368
378
  const written = await this.eventLog.appendIn(rec.conversationId, [
369
379
  {
370
380
  type: "approval_requested",
@@ -457,6 +467,7 @@ let ApprovalsService = class ApprovalsService {
457
467
  return { record: toRecord(row), toSeq: null };
458
468
  }
459
469
  const rec = toRecord(inserted);
470
+ this.hintApproval(rec);
460
471
  const written = await this.eventLog.appendIn(rec.conversationId, [
461
472
  {
462
473
  type: "approval_requested",
@@ -591,6 +602,7 @@ let ApprovalsService = class ApprovalsService {
591
602
  .returningAll()
592
603
  .executeTakeFirstOrThrow();
593
604
  const rec = toRecord(row);
605
+ this.hintApproval(rec);
594
606
  const written = await this.eventLog.appendIn(rec.conversationId, [
595
607
  {
596
608
  type: "approval_requested",
@@ -712,6 +724,7 @@ let ApprovalsService = class ApprovalsService {
712
724
  .returningAll()
713
725
  .executeTakeFirstOrThrow();
714
726
  const rec = toRecord(row);
727
+ this.hintApproval(rec);
715
728
  const written = await this.eventLog.appendIn(rec.conversationId, [
716
729
  {
717
730
  type: "approval_requested",
@@ -840,6 +853,7 @@ let ApprovalsService = class ApprovalsService {
840
853
  .returningAll()
841
854
  .executeTakeFirstOrThrow();
842
855
  const rec = toRecord(row);
856
+ this.hintApproval(rec);
843
857
  const written = await this.eventLog.appendIn(rec.conversationId, [
844
858
  {
845
859
  type: "approval_requested",
@@ -1627,6 +1641,7 @@ let ApprovalsService = class ApprovalsService {
1627
1641
  .where("org_id", "=", orgId)
1628
1642
  .returningAll()
1629
1643
  .executeTakeFirstOrThrow();
1644
+ this.hintApproval(before);
1630
1645
  if (approved && before.command?.permissionCandidate) {
1631
1646
  if (!this.permissionGrants)
1632
1647
  throw new Error("Permission grants are unavailable");
@@ -2334,10 +2349,21 @@ let ApprovalsService = class ApprovalsService {
2334
2349
  }
2335
2350
  return all;
2336
2351
  }
2352
+ /**
2353
+ * Publishes `inbox` after the commit to whoever the approval asks (account invalidation stream
2354
+ * spec §4): its `requested_for` person, else the role topic of its `approver_role`. Called for
2355
+ * every insert and every status change (decision, expiry, cancel, skip, supersede).
2356
+ */
2357
+ hintApproval(a) {
2358
+ const topics = approvalTopics(a);
2359
+ if (topics.length > 0)
2360
+ this.hints.publishAfterCommit(topics, { kind: "inbox" });
2361
+ }
2337
2362
  /**
2338
2363
  * 系统写的 `approval_decided`(超时 / 取消,处理人为 null;跳过,处理人为消息作者),在当前事务内;返回事件 seq。
2339
2364
  */
2340
2365
  async decidedEvent(a, decision, byAccountId = null) {
2366
+ this.hintApproval(a);
2341
2367
  const written = await this.eventLog.appendIn(a.conversationId, [
2342
2368
  {
2343
2369
  type: "approval_decided",
@@ -2578,17 +2604,18 @@ ApprovalsService = __decorate([
2578
2604
  __param(10, Inject(ConversationLeakCheck)),
2579
2605
  __param(11, Inject(SealedInputs)),
2580
2606
  __param(12, Inject(DevicesService)),
2581
- __param(13, Optional()),
2582
- __param(13, Inject(PermissionAuthorityLock)),
2607
+ __param(13, Inject(InvalidationHints)),
2583
2608
  __param(14, Optional()),
2584
- __param(14, Inject(PermissionCallGrants)),
2609
+ __param(14, Inject(PermissionAuthorityLock)),
2585
2610
  __param(15, Optional()),
2586
- __param(15, Inject(LoopbackGrants)),
2611
+ __param(15, Inject(PermissionCallGrants)),
2587
2612
  __param(16, Optional()),
2588
- __param(16, Inject(DeviceSiteGrants)),
2613
+ __param(16, Inject(LoopbackGrants)),
2589
2614
  __param(17, Optional()),
2590
- __param(17, Inject(OrgLock)),
2615
+ __param(17, Inject(DeviceSiteGrants)),
2591
2616
  __param(18, Optional()),
2592
- __param(18, Inject(ExtensionRegistry))
2617
+ __param(18, Inject(OrgLock)),
2618
+ __param(19, Optional()),
2619
+ __param(19, Inject(ExtensionRegistry))
2593
2620
  ], ApprovalsService);
2594
2621
  export { ApprovalsService };
@@ -31,7 +31,7 @@ import type { BuiltinTool } from "../registry.js";
31
31
  * the IM chat named by `chat`. The zone is the run's (`run_context`, else the org's, else UTC).
32
32
  */
33
33
  /** The task service as the tools use it (bound at start; null when not loaded here). */
34
- export type AutomationService = Pick<AutomationsService, "create" | "update" | "list" | "remove" | "addGrants" | "removeGrant" | "chatTargets">;
34
+ export type AutomationService = Pick<AutomationsService, "create" | "update" | "listOwn" | "remove" | "addGrants" | "removeGrant" | "chatTargets">;
35
35
  /**
36
36
  * Where the automation tools find the task service: a registration port. `AutomationsModule` imports
37
37
  * `ToolsModule` (its grants resolve the agent's tools through `ToolRegistry`, which lists these
@@ -989,7 +989,7 @@ export function automationTools(deps) {
989
989
  async run(_raw, ctx) {
990
990
  const svc = await service();
991
991
  await liveRole(ctx);
992
- const tasks = await call(() => svc.list(ctx.orgId, { accountId: ctx.accountId }), {});
992
+ const tasks = await call(() => svc.listOwn(ctx.orgId, { accountId: ctx.accountId }), {});
993
993
  if (tasks.length === 0) {
994
994
  return {
995
995
  content: [{ type: "text", text: "The user has no automations in this organization." }],
@@ -7,6 +7,7 @@ import { KernelDb } from "../infra/database/kernel-db.js";
7
7
  import { TransactionHost } from "../infra/database/transaction-host.js";
8
8
  import { LockService } from "../infra/lock/lock.service.js";
9
9
  import { OutboxService } from "../infra/outbox/outbox.service.js";
10
+ import { type HintPublisher } from "../invalidation/audiences.js";
10
11
  import { OrgLock } from "../orgs/org-lock.js";
11
12
  import type { OrgRole } from "../orgs/roles.js";
12
13
  import { type ConnectorSetup } from "./connector-setup.js";
@@ -268,6 +269,7 @@ export declare class ConnectorsService {
268
269
  readonly txHost: TransactionHost;
269
270
  /** Setup guides of connector templates (spec 2026-11-09-setup-guides-v2-design.md §11). */
270
271
  private readonly guides;
272
+ private readonly hints;
271
273
  constructor(kdb: KernelDb, registry: ToolRegistry, credentials: Credentials, config: Pick<KernelConfigService, "get">, drift: ToolDrift,
272
274
  /** The org row lock (orgs/org-lock.ts): joins the caller's transaction. */
273
275
  orgLock: Pick<OrgLock, "lock" | "tryLock" | "lockAndAuthorize">,
@@ -276,7 +278,7 @@ export declare class ConnectorsService {
276
278
  /** The cross-replica lock of a deferred connector's lazy client registration (R16). */
277
279
  locks: Pick<LockService, "run">, txHost: TransactionHost,
278
280
  /** Setup guides of connector templates (spec 2026-11-09-setup-guides-v2-design.md §11). */
279
- guides: Pick<PluginGuides, "templateAck" | "connectorStates">);
281
+ guides: Pick<PluginGuides, "templateAck" | "connectorStates">, hints: HintPublisher);
280
282
  /** The kernel-schema handle of the current context (its transaction, else the pool). */
281
283
  private get db();
282
284
  /**
@@ -28,6 +28,8 @@ import { TransactionHost } from "../infra/database/transaction-host.js";
28
28
  import { Transactional } from "../infra/database/transactional.decorator.js";
29
29
  import { LockService } from "../infra/lock/lock.service.js";
30
30
  import { OutboxService } from "../infra/outbox/outbox.service.js";
31
+ import { publishCapabilities } from "../invalidation/audiences.js";
32
+ import { InvalidationHints } from "../invalidation/invalidation-hints.js";
31
33
  import { OrgLock } from "../orgs/org-lock.js";
32
34
  import { firstOrgOwner } from "../orgs/org-owner.js";
33
35
  import { UUID_RE } from "../ui/registry.js";
@@ -125,6 +127,7 @@ let ConnectorsService = class ConnectorsService {
125
127
  locks;
126
128
  txHost;
127
129
  guides;
130
+ hints;
128
131
  constructor(kdb, registry, credentials, config, drift,
129
132
  /** The org row lock (orgs/org-lock.ts): joins the caller's transaction. */
130
133
  orgLock,
@@ -133,7 +136,7 @@ let ConnectorsService = class ConnectorsService {
133
136
  /** The cross-replica lock of a deferred connector's lazy client registration (R16). */
134
137
  locks, txHost,
135
138
  /** Setup guides of connector templates (spec 2026-11-09-setup-guides-v2-design.md §11). */
136
- guides) {
139
+ guides, hints) {
137
140
  this.kdb = kdb;
138
141
  this.registry = registry;
139
142
  this.credentials = credentials;
@@ -144,6 +147,7 @@ let ConnectorsService = class ConnectorsService {
144
147
  this.locks = locks;
145
148
  this.txHost = txHost;
146
149
  this.guides = guides;
150
+ this.hints = hints;
147
151
  }
148
152
  /** The kernel-schema handle of the current context (its transaction, else the pool). */
149
153
  get db() {
@@ -584,6 +588,8 @@ let ConnectorsService = class ConnectorsService {
584
588
  }),
585
589
  },
586
590
  });
591
+ // a new connector in the org: its members' pickers refetch
592
+ publishCapabilities(this.hints, [orgId]);
587
593
  return issues;
588
594
  }
589
595
  /**
@@ -702,6 +708,8 @@ let ConnectorsService = class ConnectorsService {
702
708
  policyChanges[tool.name] = { from: previous, to: next };
703
709
  }
704
710
  }
711
+ // its auth, endpoint or credentials may move its derived setup (needs_config / ready)
712
+ publishCapabilities(this.hints, [orgId]);
705
713
  if (input.resetCredentials) {
706
714
  await this.credentials.clearConnector(orgId, connectorId);
707
715
  if (p.secret && p.owner) {
@@ -1240,9 +1248,12 @@ let ConnectorsService = class ConnectorsService {
1240
1248
  .where("org_id", "=", orgId)
1241
1249
  .execute();
1242
1250
  }
1251
+ if (patch.status !== undefined && patch.status !== app.status) {
1252
+ publishCapabilities(this.hints, [orgId]);
1253
+ }
1243
1254
  // switched back on: the org's pending enable requests for the connector are settled
1244
1255
  if (patch.status === "active" && app.status === "disabled") {
1245
- await settleEnableRequests(t, orgId, { kind: "connector", id: connectorId }, actorAccountId, {
1256
+ await settleEnableRequests(t, this.hints, orgId, { kind: "connector", id: connectorId }, actorAccountId, {
1246
1257
  ...(actorTokenId !== undefined && { actorTokenId }),
1247
1258
  });
1248
1259
  }
@@ -1413,8 +1424,9 @@ let ConnectorsService = class ConnectorsService {
1413
1424
  .where("org_id", "=", orgId)
1414
1425
  .where("deleted_at", "is", null)
1415
1426
  .execute();
1427
+ publishCapabilities(this.hints, [orgId]);
1416
1428
  // its plugin is its owning switch now: a pending request for the connector is stale
1417
- await cancelEnableRequestsOfConnector(this.db, orgId, connectorId, null, "target_changed");
1429
+ await cancelEnableRequestsOfConnector(this.db, this.hints, orgId, connectorId, null, "target_changed");
1418
1430
  }
1419
1431
  /** Owe a listing before changing the row's status and legacy last-update timestamp. */
1420
1432
  async oweStaleEndpointList(orgId, app) {
@@ -1464,7 +1476,8 @@ let ConnectorsService = class ConnectorsService {
1464
1476
  .where("id", "=", connectorId)
1465
1477
  .where("org_id", "=", orgId)
1466
1478
  .execute();
1467
- await settleEnableRequests(this.db, orgId, { kind: "connector", id: connectorId }, null);
1479
+ publishCapabilities(this.hints, [orgId]);
1480
+ await settleEnableRequests(this.db, this.hints, orgId, { kind: "connector", id: connectorId }, null);
1468
1481
  return true;
1469
1482
  }
1470
1483
  /**
@@ -1489,8 +1502,10 @@ let ConnectorsService = class ConnectorsService {
1489
1502
  .where("id", "=", connectorId)
1490
1503
  .where("org_id", "=", orgId)
1491
1504
  .execute();
1505
+ if (status !== app.status)
1506
+ publishCapabilities(this.hints, [orgId]);
1492
1507
  if (status === "active" && app.status === "disabled") {
1493
- await settleEnableRequests(t, orgId, { kind: "connector", id: connectorId }, actor.accountId, { ...(actor.tokenId !== undefined && { actorTokenId: actor.tokenId }) });
1508
+ await settleEnableRequests(t, this.hints, orgId, { kind: "connector", id: connectorId }, actor.accountId, { ...(actor.tokenId !== undefined && { actorTokenId: actor.tokenId }) });
1494
1509
  }
1495
1510
  await audit(t, {
1496
1511
  actorAccountId: actor.accountId,
@@ -1536,7 +1551,8 @@ let ConnectorsService = class ConnectorsService {
1536
1551
  .where("id", "=", connectorId)
1537
1552
  .where("org_id", "=", orgId)
1538
1553
  .execute();
1539
- await cancelEnableRequestsOfConnector(t, orgId, connectorId, actorAccountId, "connector_removed");
1554
+ publishCapabilities(this.hints, [orgId]);
1555
+ await cancelEnableRequestsOfConnector(t, this.hints, orgId, connectorId, actorAccountId, "connector_removed");
1540
1556
  await this.credentials.clearConnector(orgId, connectorId);
1541
1557
  // 授权绑定连接器 id(软删除不触发外键级联):一并删掉,不留给任何后来的连接器
1542
1558
  await t
@@ -1788,6 +1804,9 @@ let ConnectorsService = class ConnectorsService {
1788
1804
  this.credentials.validate(auth, owner, value);
1789
1805
  const before = await this.setupOf(orgId, app);
1790
1806
  await this.credentials.setStatic(orgId, connectorId, auth, owner, value);
1807
+ // an org credential may move the derived setup (needs_config -> ready) every member sees
1808
+ if (ownership === "org")
1809
+ publishCapabilities(this.hints, [orgId]);
1791
1810
  if (ownership === "org" && before === "needs_config") {
1792
1811
  // the org credential it lacked: now ready, its tools follow (§5.2.1)
1793
1812
  await this.oweToolList(orgId, connectorId, "configured");
@@ -1859,6 +1878,8 @@ let ConnectorsService = class ConnectorsService {
1859
1878
  await this.credentials.setOAuthClient(orgId, connectorId, client);
1860
1879
  if (tokens)
1861
1880
  await this.credentials.setOAuthTokens(orgId, connectorId, { kind: "org" }, tokens);
1881
+ // the org's client may move the derived setup (needs_config -> ready) every member sees
1882
+ publishCapabilities(this.hints, [orgId]);
1862
1883
  // the client it lacked: now ready; a client credentials connector lists its tools with the
1863
1884
  // org token (an authorization-code one waits for a member's first connection, A16)
1864
1885
  if (before === "needs_config" && auth.ownership === "org") {
@@ -2027,6 +2048,7 @@ ConnectorsService = __decorate([
2027
2048
  __param(6, Inject(OutboxService)),
2028
2049
  __param(7, Inject(LockService)),
2029
2050
  __param(8, Inject(TransactionHost)),
2030
- __param(9, Inject(PluginGuides))
2051
+ __param(9, Inject(PluginGuides)),
2052
+ __param(10, Inject(InvalidationHints))
2031
2053
  ], ConnectorsService);
2032
2054
  export { ConnectorsService };
@@ -19,6 +19,7 @@ import { ExtensionsModule } from "../extensions/extensions.module.js";
19
19
  import { FileDeliveriesModule } from "../files/deliveries.module.js";
20
20
  import { LibraryReadModule } from "../files/library-read.module.js";
21
21
  import { QueueModule } from "../infra/queue/queue.module.js";
22
+ import { InvalidationHintsModule } from "../invalidation/invalidation-hints.module.js";
22
23
  import { ModelsModule } from "../models/models.module.js";
23
24
  import { OrgLockModule } from "../orgs/org-lock.js";
24
25
  import { FileRefs } from "../platform/file-ref.js";
@@ -74,6 +75,8 @@ let ToolsModule = class ToolsModule {
74
75
  ToolsModule = __decorate([
75
76
  Module({
76
77
  imports: [
78
+ // invalidation hints its writers publish after their commit
79
+ InvalidationHintsModule,
77
80
  PermissionCallGrantsModule,
78
81
  PermissionAuthorityModule,
79
82
  OperationAuthorityModule,