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

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 (122) hide show
  1. package/dist/agents/agents.module.js +3 -0
  2. package/dist/agents/agents.service.js +1 -1
  3. package/dist/agents/org-templates.d.ts +3 -1
  4. package/dist/agents/org-templates.js +7 -3
  5. package/dist/agents/pending-connector-requests.d.ts +10 -4
  6. package/dist/agents/pending-connector-requests.js +29 -7
  7. package/dist/automations/events/acceptance.d.ts +6 -1
  8. package/dist/automations/events/acceptance.js +30 -11
  9. package/dist/catalog/catalog-import.module.js +3 -0
  10. package/dist/catalog/catalog-scope.service.d.ts +3 -1
  11. package/dist/catalog/catalog-scope.service.js +11 -7
  12. package/dist/catalog/catalog.module.js +3 -0
  13. package/dist/catalog/catalog.service.d.ts +3 -1
  14. package/dist/catalog/catalog.service.js +8 -4
  15. package/dist/catalog/component-promotion.d.ts +3 -1
  16. package/dist/catalog/component-promotion.js +7 -3
  17. package/dist/catalog/component-scope.service.d.ts +3 -1
  18. package/dist/catalog/component-scope.service.js +7 -3
  19. package/dist/catalog/enable-requests.d.ts +10 -8
  20. package/dist/catalog/enable-requests.js +40 -21
  21. package/dist/catalog/owned-items.d.ts +3 -1
  22. package/dist/catalog/owned-items.js +13 -9
  23. package/dist/catalog/platform-components.d.ts +6 -1
  24. package/dist/catalog/platform-components.js +9 -3
  25. package/dist/catalog/plugin-connectors.d.ts +8 -4
  26. package/dist/catalog/plugin-connectors.js +12 -6
  27. package/dist/catalog/plugin-import.d.ts +3 -1
  28. package/dist/catalog/plugin-import.js +14 -5
  29. package/dist/catalog/plugin-install.d.ts +3 -1
  30. package/dist/catalog/plugin-install.js +8 -4
  31. package/dist/catalog/plugin-upgrade.d.ts +3 -1
  32. package/dist/catalog/plugin-upgrade.js +8 -4
  33. package/dist/catalog/request-hints.d.ts +19 -0
  34. package/dist/catalog/request-hints.js +34 -0
  35. package/dist/catalog/request-rules.d.ts +9 -5
  36. package/dist/catalog/request-rules.js +16 -9
  37. package/dist/catalog/requests.service.d.ts +3 -1
  38. package/dist/catalog/requests.service.js +28 -9
  39. package/dist/catalog/scope-orgs.d.ts +2 -1
  40. package/dist/catalog/scope-orgs.js +2 -2
  41. package/dist/catalog/scope-sync.d.ts +3 -1
  42. package/dist/catalog/scope-sync.js +12 -2
  43. package/dist/catalog/scope-writer.d.ts +6 -3
  44. package/dist/catalog/scope-writer.js +28 -10
  45. package/dist/catalog/unshare.d.ts +3 -2
  46. package/dist/catalog/unshare.js +4 -4
  47. package/dist/config/schema.d.ts +3 -0
  48. package/dist/config/schema.js +30 -0
  49. package/dist/db/migrator.js +36 -0
  50. package/dist/extensions/admin-ops.d.ts +6 -1
  51. package/dist/extensions/admin-ops.js +17 -4
  52. package/dist/extensions/deployment-config.d.ts +6 -1
  53. package/dist/extensions/deployment-config.js +13 -2
  54. package/dist/extensions/extensions.module.js +3 -0
  55. package/dist/extensions/org-config.d.ts +3 -1
  56. package/dist/extensions/org-config.js +13 -4
  57. package/dist/extensions/org-overrides.d.ts +6 -1
  58. package/dist/extensions/org-overrides.js +13 -2
  59. package/dist/inbox/inbox-items.service.d.ts +6 -1
  60. package/dist/inbox/inbox-items.service.js +29 -10
  61. package/dist/inbox/inbox.module.js +3 -0
  62. package/dist/inbox/inbox.service.d.ts +3 -1
  63. package/dist/inbox/inbox.service.js +9 -2
  64. package/dist/inbox/org-notices.d.ts +4 -3
  65. package/dist/inbox/org-notices.js +9 -6
  66. package/dist/inbox/platform-inbox.service.d.ts +3 -1
  67. package/dist/inbox/platform-inbox.service.js +11 -3
  68. package/dist/inbox/platform-notices.d.ts +3 -2
  69. package/dist/inbox/platform-notices.js +10 -4
  70. package/dist/infra/config/kernel-config.service.js +4 -1
  71. package/dist/invalidation/audiences.d.ts +32 -0
  72. package/dist/invalidation/audiences.js +43 -0
  73. package/dist/invalidation/hints.d.ts +6 -0
  74. package/dist/invalidation/hints.js +7 -1
  75. package/dist/invalidation/invalidation-hints.d.ts +12 -1
  76. package/dist/invalidation/invalidation-hints.js +46 -5
  77. package/dist/invalidation/invalidation-hints.module.d.ts +2 -0
  78. package/dist/invalidation/invalidation-hints.module.js +4 -1
  79. package/dist/invalidation/me-stream.d.ts +1 -11
  80. package/dist/invalidation/me-stream.js +12 -41
  81. package/dist/invalidation/org-intent-bridge.d.ts +18 -0
  82. package/dist/invalidation/org-intent-bridge.js +46 -0
  83. package/dist/models/enablement.d.ts +3 -1
  84. package/dist/models/enablement.js +25 -5
  85. package/dist/orgs/offboarding.d.ts +3 -1
  86. package/dist/orgs/offboarding.js +7 -3
  87. package/dist/orgs/orgs.module.js +3 -0
  88. package/dist/orgs/orgs.service.d.ts +3 -1
  89. package/dist/orgs/orgs.service.js +7 -3
  90. package/dist/push/delivery.d.ts +3 -1
  91. package/dist/push/delivery.js +7 -3
  92. package/dist/push/push-processor.js +8 -1
  93. package/dist/runtime/stream-limit.d.ts +13 -0
  94. package/dist/runtime/stream-limit.js +40 -0
  95. package/dist/runtime/stream.controller.d.ts +2 -0
  96. package/dist/runtime/stream.controller.js +2 -0
  97. package/dist/runtime/stream.d.ts +1 -0
  98. package/dist/runtime/stream.js +15 -6
  99. package/dist/sandbox/permission-authority.module.js +6 -1
  100. package/dist/sandbox/permission-transitions.d.ts +3 -1
  101. package/dist/sandbox/permission-transitions.js +17 -2
  102. package/dist/skills/agent-skills.service.d.ts +6 -1
  103. package/dist/skills/agent-skills.service.js +12 -3
  104. package/dist/skills/changes.service.d.ts +6 -1
  105. package/dist/skills/changes.service.js +11 -3
  106. package/dist/skills/conversation-catalog.d.ts +3 -0
  107. package/dist/skills/conversation-catalog.js +2 -0
  108. package/dist/skills/skills.module.js +3 -0
  109. package/dist/skills/skills.service.d.ts +3 -1
  110. package/dist/skills/skills.service.js +8 -4
  111. package/dist/tools/approvals.service.d.ts +12 -1
  112. package/dist/tools/approvals.service.js +36 -9
  113. package/dist/tools/connectors.service.d.ts +3 -1
  114. package/dist/tools/connectors.service.js +29 -7
  115. package/dist/tools/tools.module.js +3 -0
  116. package/dist/ui/admin-ui.controller.d.ts +3 -1
  117. package/dist/ui/admin-ui.controller.js +3 -1
  118. package/dist/ui/ui-stream.d.ts +2 -0
  119. package/dist/ui/ui-stream.js +20 -6
  120. package/dist/ui/views.controller.d.ts +4 -2
  121. package/dist/ui/views.controller.js +4 -2
  122. package/package.json +1 -1
@@ -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
@@ -10,21 +10,25 @@ var __param = (this && this.__param) || function (paramIndex, decorator) {
10
10
  import { randomUUID } from "node:crypto";
11
11
  import { Inject, Injectable } from "@nestjs/common";
12
12
  import { sql } from "kysely";
13
+ import { publishRequestHints } from "../catalog/request-hints.js";
13
14
  import { audit } from "../identity/audit.js";
14
15
  import { KernelDb } from "../infra/database/kernel-db.js";
15
16
  import { TransactionHost } from "../infra/database/transaction-host.js";
16
17
  import { Transactional } from "../infra/database/transactional.decorator.js";
18
+ import { InvalidationHints } from "../invalidation/invalidation-hints.js";
17
19
  /**
18
20
  * Moves the agents' setup requests that still concern their owner (pending, or decided and not
19
21
  * dismissed) to the new owner `owner` (an owner change: `AgentsService.reassignOwner`, member
20
- * offboarding). Runs through `db` (the caller's transaction).
22
+ * offboarding). Runs through `db` (the caller's transaction); the moved rows publish `requests`
23
+ * after the commit to the new owner and the org's admins, and to `previousOwner` when the caller
24
+ * holds it (an owner change; offboarding's previous owner leaves the org, so it passes none).
21
25
  */
22
- export async function retargetSetupRequests(db, agentIds, owner) {
26
+ export async function retargetSetupRequests(db, hints, agentIds, owner, previousOwner) {
23
27
  if (agentIds.length === 0)
24
28
  return;
25
29
  // org-filter: the agent ids were resolved in the caller's org (owner change, offboarding) and a
26
30
  // setup request lives in its agent's org
27
- await db
31
+ const moved = await db
28
32
  .updateTable("catalog_requests")
29
33
  .set({ requested_by: owner })
30
34
  .where("kind", "=", "connector_setup")
@@ -33,7 +37,11 @@ export async function retargetSetupRequests(db, agentIds, owner) {
33
37
  eb("status", "=", "pending"),
34
38
  eb.and([eb("status", "in", ["approved", "rejected"]), eb("dismissed_at", "is", null)]),
35
39
  ]))
40
+ .returning(["org_id", "requested_by", "kind"])
36
41
  .execute();
42
+ publishRequestHints(hints, moved, previousOwner !== undefined && moved.length > 0 && previousOwner !== owner
43
+ ? [previousOwner]
44
+ : []);
37
45
  }
38
46
  /**
39
47
  * The org inbox requests for an agent's pending connectors (ruling P4-7: one `connector_setup`
@@ -49,9 +57,11 @@ export async function retargetSetupRequests(db, agentIds, owner) {
49
57
  let PendingConnectorRequests = class PendingConnectorRequests {
50
58
  kdb;
51
59
  txHost;
52
- constructor(kdb, txHost) {
60
+ hints;
61
+ constructor(kdb, txHost, hints) {
53
62
  this.kdb = kdb;
54
63
  this.txHost = txHost;
64
+ this.hints = hints;
55
65
  }
56
66
  /**
57
67
  * The request for a new agent, requested by its owner (ruling P4-T6-4). `args.keys` are what the
@@ -118,6 +128,9 @@ let PendingConnectorRequests = class PendingConnectorRequests {
118
128
  .returning("id")
119
129
  .executeTakeFirst();
120
130
  if (inserted !== undefined) {
131
+ publishRequestHints(this.hints, [
132
+ { org_id: a.orgId, requested_by: a.requestedBy, kind: "connector_setup" },
133
+ ]);
121
134
  await audit(t, {
122
135
  actorAccountId: a.actor,
123
136
  ...(a.actorTokenId !== undefined && { actorTokenId: a.actorTokenId }),
@@ -145,8 +158,10 @@ let PendingConnectorRequests = class PendingConnectorRequests {
145
158
  * The agent's new owner receives its setup request's decision (fix round 1, item 4): the pending
146
159
  * request and the decided ones not dismissed move to `owner`. In the caller's transaction.
147
160
  */
148
- async retargetIn(agentIds, owner) {
149
- await retargetSetupRequests(this.kdb.db, agentIds, owner);
161
+ async retargetIn(agentIds, owner,
162
+ /** The owner the requests move from (it gets a `requests` hint). */
163
+ previousOwner) {
164
+ await retargetSetupRequests(this.kdb.db, this.hints, agentIds, owner, previousOwner);
150
165
  }
151
166
  /**
152
167
  * Settles the agent's pending request after a definition write, in the caller's transaction
@@ -178,6 +193,9 @@ let PendingConnectorRequests = class PendingConnectorRequests {
178
193
  .where("id", "=", row.id)
179
194
  .where("org_id", "=", a.orgId)
180
195
  .execute();
196
+ publishRequestHints(this.hints, [
197
+ { org_id: a.orgId, requested_by: row.requested_by, kind: "connector_setup" },
198
+ ]);
181
199
  }
182
200
  return;
183
201
  }
@@ -194,6 +212,9 @@ let PendingConnectorRequests = class PendingConnectorRequests {
194
212
  .where("id", "=", row.id)
195
213
  .where("org_id", "=", a.orgId)
196
214
  .execute();
215
+ publishRequestHints(this.hints, [
216
+ { org_id: a.orgId, requested_by: row.requested_by, kind: "connector_setup" },
217
+ ]);
197
218
  await audit(t, {
198
219
  actorAccountId: a.actor,
199
220
  ...(a.actorTokenId !== undefined && { actorTokenId: a.actorTokenId }),
@@ -216,6 +237,7 @@ __decorate([
216
237
  PendingConnectorRequests = __decorate([
217
238
  Injectable(),
218
239
  __param(0, Inject(KernelDb)),
219
- __param(1, Inject(TransactionHost))
240
+ __param(1, Inject(TransactionHost)),
241
+ __param(2, Inject(InvalidationHints))
220
242
  ], PendingConnectorRequests);
221
243
  export { PendingConnectorRequests };
@@ -8,6 +8,7 @@ import { KernelConfigService } from "../../infra/config/kernel-config.service.js
8
8
  import { KernelDb } from "../../infra/database/kernel-db.js";
9
9
  import { TransactionHost } from "../../infra/database/transaction-host.js";
10
10
  import { OutboxService } from "../../infra/outbox/outbox.service.js";
11
+ import { type HintPublisher } from "../../invalidation/audiences.js";
11
12
  import type { KernelLogger } from "../../log.js";
12
13
  import { type EffectiveAutomationSettings } from "../effective-settings.js";
13
14
  import { type EventCause, type EventRow } from "./deliver.js";
@@ -99,6 +100,8 @@ export interface RouteContext {
99
100
  * Every read and write filters by the org; the person acts only on their own rules and offers.
100
101
  */
101
102
  export declare class AcceptanceService {
103
+ /** Offers publish `inbox` to their person after the commit. */
104
+ private readonly hints;
102
105
  private readonly kdb;
103
106
  readonly txHost: TransactionHost;
104
107
  private readonly config;
@@ -108,7 +111,9 @@ export declare class AcceptanceService {
108
111
  private readonly inbox;
109
112
  private readonly agents;
110
113
  private readonly displayNames;
111
- constructor(kdb: KernelDb, txHost: TransactionHost, config: Pick<KernelConfigService, "get">, points: Pick<ExtensionPointDefaults, "providersFor">, outbox: Pick<OutboxService, "add">, log: Pick<KernelLogger, "info" | "warn">, inbox: Pick<InboxItemsService, "post" | "close">, agents: Pick<AgentLookup, "get">, displayNames: Pick<ExtensionDisplayNames, "many">);
114
+ constructor(
115
+ /** Offers publish `inbox` to their person after the commit. */
116
+ hints: HintPublisher, kdb: KernelDb, txHost: TransactionHost, config: Pick<KernelConfigService, "get">, points: Pick<ExtensionPointDefaults, "providersFor">, outbox: Pick<OutboxService, "add">, log: Pick<KernelLogger, "info" | "warn">, inbox: Pick<InboxItemsService, "post" | "close">, agents: Pick<AgentLookup, "get">, displayNames: Pick<ExtensionDisplayNames, "many">);
112
117
  /**
113
118
  * Routes the pending directed event `ev` (the dispatcher's guards for depth, the source and its
114
119
  * declarations already passed), see the class. The event ends `dispatched` (fired, offered, off
@@ -25,6 +25,9 @@ import { TransactionHost } from "../../infra/database/transaction-host.js";
25
25
  import { Transactional } from "../../infra/database/transactional.decorator.js";
26
26
  import { OutboxService } from "../../infra/outbox/outbox.service.js";
27
27
  import { KERNEL_LOGGER } from "../../infra/tokens.js";
28
+ import { publishAccountInbox } from "../../invalidation/audiences.js";
29
+ import { InvalidationHints } from "../../invalidation/invalidation-hints.js";
30
+ import { InvalidationHintsModule } from "../../invalidation/invalidation-hints.module.js";
28
31
  import { roleAtLeast } from "../../orgs/roles.js";
29
32
  import { pluginDisplayNames } from "../../tools/display-names.js";
30
33
  import { readAutomationSettings } from "../effective-settings.js";
@@ -88,6 +91,7 @@ const webLink = (url) => {
88
91
  * Every read and write filters by the org; the person acts only on their own rules and offers.
89
92
  */
90
93
  let AcceptanceService = class AcceptanceService {
94
+ hints;
91
95
  kdb;
92
96
  txHost;
93
97
  config;
@@ -97,7 +101,10 @@ let AcceptanceService = class AcceptanceService {
97
101
  inbox;
98
102
  agents;
99
103
  displayNames;
100
- constructor(kdb, txHost, config, points, outbox, log, inbox, agents, displayNames) {
104
+ constructor(
105
+ /** Offers publish `inbox` to their person after the commit. */
106
+ hints, kdb, txHost, config, points, outbox, log, inbox, agents, displayNames) {
107
+ this.hints = hints;
101
108
  this.kdb = kdb;
102
109
  this.txHost = txHost;
103
110
  this.config = config;
@@ -357,6 +364,8 @@ let AcceptanceService = class AcceptanceService {
357
364
  .executeTakeFirst();
358
365
  if (row === undefined)
359
366
  return;
367
+ // the offer lists in its person's inbox
368
+ publishAccountInbox(this.hints, [audience.accountId]);
360
369
  const [names, agentName] = await Promise.all([
361
370
  pluginDisplayNames(db, [ev.plugin]),
362
371
  this.agentName(orgId, audience.agentId),
@@ -616,6 +625,7 @@ let AcceptanceService = class AcceptanceService {
616
625
  .where("org_id", "=", orgId)
617
626
  .where("id", "=", offerId)
618
627
  .execute();
628
+ publishAccountInbox(this.hints, [accountId]);
619
629
  if (offer.inbox_item_id !== null)
620
630
  await this.inbox.close(orgId, offer.inbox_item_id);
621
631
  await audit(db, {
@@ -647,6 +657,7 @@ let AcceptanceService = class AcceptanceService {
647
657
  .where("org_id", "=", orgId)
648
658
  .where("id", "=", offerId)
649
659
  .execute();
660
+ publishAccountInbox(this.hints, [accountId]);
650
661
  if (offer.inbox_item_id !== null)
651
662
  await this.inbox.close(orgId, offer.inbox_item_id);
652
663
  await audit(db, {
@@ -729,6 +740,7 @@ let AcceptanceService = class AcceptanceService {
729
740
  .executeTakeFirst();
730
741
  if (row === undefined)
731
742
  return false;
743
+ publishAccountInbox(this.hints, [row.account_id]);
732
744
  if (row.inbox_item_id !== null)
733
745
  await this.inbox.close(orgId, row.inbox_item_id);
734
746
  const ev = await db
@@ -812,15 +824,16 @@ __decorate([
812
824
  ], AcceptanceService.prototype, "expireOffer", null);
813
825
  AcceptanceService = __decorate([
814
826
  Injectable(),
815
- __param(0, Inject(KernelDb)),
816
- __param(1, Inject(TransactionHost)),
817
- __param(2, Inject(KernelConfigService)),
818
- __param(3, Inject(ExtensionPointDefaults)),
819
- __param(4, Inject(OutboxService)),
820
- __param(5, Inject(KERNEL_LOGGER)),
821
- __param(6, Inject(InboxItemsService)),
822
- __param(7, Inject(AgentLookup)),
823
- __param(8, Inject(ExtensionDisplayNames))
827
+ __param(0, Inject(InvalidationHints)),
828
+ __param(1, Inject(KernelDb)),
829
+ __param(2, Inject(TransactionHost)),
830
+ __param(3, Inject(KernelConfigService)),
831
+ __param(4, Inject(ExtensionPointDefaults)),
832
+ __param(5, Inject(OutboxService)),
833
+ __param(6, Inject(KERNEL_LOGGER)),
834
+ __param(7, Inject(InboxItemsService)),
835
+ __param(8, Inject(AgentLookup)),
836
+ __param(9, Inject(ExtensionDisplayNames))
824
837
  ], AcceptanceService);
825
838
  export { AcceptanceService };
826
839
  /**
@@ -831,7 +844,13 @@ let AcceptanceModule = class AcceptanceModule {
831
844
  };
832
845
  AcceptanceModule = __decorate([
833
846
  Module({
834
- imports: [ExtensionsModule, AgentLookupModule, InboxItemsModule],
847
+ imports: [
848
+ // invalidation hints its writers publish after their commit
849
+ InvalidationHintsModule,
850
+ ExtensionsModule,
851
+ AgentLookupModule,
852
+ InboxItemsModule,
853
+ ],
835
854
  providers: [AcceptanceService],
836
855
  exports: [AcceptanceService],
837
856
  })
@@ -8,6 +8,7 @@ import { Module } from "@nestjs/common";
8
8
  import { ClientModule } from "../client/client.module.js";
9
9
  import { ExtensionsModule } from "../extensions/extensions.module.js";
10
10
  import { SuperAdminLockModule } from "../identity/super-admin.js";
11
+ import { InvalidationHintsModule } from "../invalidation/invalidation-hints.module.js";
11
12
  import { OrgLockModule } from "../orgs/org-lock.js";
12
13
  import { StorageModule } from "../storage/storage.module.js";
13
14
  import { CatalogService } from "./catalog.service.js";
@@ -28,6 +29,8 @@ let CatalogImportModule = class CatalogImportModule {
28
29
  CatalogImportModule = __decorate([
29
30
  Module({
30
31
  imports: [
32
+ // invalidation hints its writers publish after their commit
33
+ InvalidationHintsModule,
31
34
  ExtensionsModule,
32
35
  SuperAdminLockModule,
33
36
  // an org upload re-checks the owner org's admin (`PluginImport`, ruling P3-7)
@@ -4,6 +4,7 @@ import { ExtensionAdmin } from "../extensions/admin-view.js";
4
4
  import { SuperAdminLock } from "../identity/super-admin.js";
5
5
  import { KernelDb } from "../infra/database/kernel-db.js";
6
6
  import { TransactionHost } from "../infra/database/transaction-host.js";
7
+ import type { HintPublisher } from "../invalidation/audiences.js";
7
8
  import { type ThemePreview } from "../themes/theme-usage.js";
8
9
  import { type ActorOpts, type CatalogItemView, CatalogService } from "./catalog.service.js";
9
10
  import { type ComponentKind } from "./component-state.js";
@@ -98,7 +99,8 @@ export declare class CatalogScopeService {
98
99
  private readonly ops;
99
100
  private readonly sync;
100
101
  readonly txHost: TransactionHost;
101
- constructor(kdb: KernelDb, adminLock: SuperAdminLock, scopeWriter: ScopeWriter, catalog: CatalogService, pluginImport: PluginImport, installer: PluginInstaller, extensions: ExtensionAdmin, ops: ExtensionAdminOps, sync: PluginScopeSync, txHost: TransactionHost);
102
+ private readonly hints;
103
+ constructor(kdb: KernelDb, adminLock: SuperAdminLock, scopeWriter: ScopeWriter, catalog: CatalogService, pluginImport: PluginImport, installer: PluginInstaller, extensions: ExtensionAdmin, ops: ExtensionAdminOps, sync: PluginScopeSync, txHost: TransactionHost, hints: HintPublisher);
102
104
  private get db();
103
105
  /**
104
106
  * Confirms a staged import ({@link PluginImport.confirm}: installs and enables the extension,
@@ -19,6 +19,7 @@ import { notifyItemShared } from "../inbox/org-notices.js";
19
19
  import { KernelDb } from "../infra/database/kernel-db.js";
20
20
  import { TransactionHost } from "../infra/database/transaction-host.js";
21
21
  import { Transactional } from "../infra/database/transactional.decorator.js";
22
+ import { InvalidationHints } from "../invalidation/invalidation-hints.js";
22
23
  import { assertNotPlatformDefault, themesPreview, } from "../themes/theme-usage.js";
23
24
  import { CatalogService } from "./catalog.service.js";
24
25
  import { assertOrgsExist } from "./catalog-items.js";
@@ -94,7 +95,8 @@ let CatalogScopeService = class CatalogScopeService {
94
95
  ops;
95
96
  sync;
96
97
  txHost;
97
- constructor(kdb, adminLock, scopeWriter, catalog, pluginImport, installer, extensions, ops, sync, txHost) {
98
+ hints;
99
+ constructor(kdb, adminLock, scopeWriter, catalog, pluginImport, installer, extensions, ops, sync, txHost, hints) {
98
100
  this.kdb = kdb;
99
101
  this.adminLock = adminLock;
100
102
  this.scopeWriter = scopeWriter;
@@ -105,6 +107,7 @@ let CatalogScopeService = class CatalogScopeService {
105
107
  this.ops = ops;
106
108
  this.sync = sync;
107
109
  this.txHost = txHost;
110
+ this.hints = hints;
108
111
  }
109
112
  get db() {
110
113
  return this.kdb.db;
@@ -273,7 +276,7 @@ let CatalogScopeService = class CatalogScopeService {
273
276
  });
274
277
  const shared = newlySharedWith({ scope: item.scope, orgs: from }, t);
275
278
  if (shared === "all_orgs" || shared.length > 0) {
276
- await notifyItemShared(this.db, item.owner_org_id, { kind: "plugin", id: itemId }, item.name, shared);
279
+ await notifyItemShared(this.db, this.hints, item.owner_org_id, { kind: "plugin", id: itemId }, item.name, shared);
277
280
  }
278
281
  await audit(this.db, {
279
282
  actorAccountId: actor,
@@ -362,14 +365,14 @@ let CatalogScopeService = class CatalogScopeService {
362
365
  }
363
366
  if (shareable)
364
367
  return;
365
- const narrowed = await narrowItemOnUnshare(this.db, actor, item);
368
+ const narrowed = await narrowItemOnUnshare(this.db, this.hints, actor, item);
366
369
  for (const kind of COMPONENT_KINDS) {
367
370
  for (const c of await loadComponents(this.db, kind, { itemId, forUpdate: true })) {
368
- await narrowComponentOnUnshare(this.db, actor, c);
371
+ await narrowComponentOnUnshare(this.db, this.hints, actor, c);
369
372
  }
370
373
  }
371
374
  // other orgs' pending enable requests for it (the share gate hides it from them now)
372
- await reconcileEnableRequestsOf(this.db, { kind: "plugin", id: itemId }, actor);
375
+ await reconcileEnableRequestsOf(this.db, this.hints, { kind: "plugin", id: itemId }, actor);
373
376
  if (narrowed)
374
377
  await this.enqueue(itemId);
375
378
  this.scopeWriter.refreshIsolatedOrgIntent();
@@ -382,7 +385,7 @@ let CatalogScopeService = class CatalogScopeService {
382
385
  */
383
386
  async addOrg(actor, itemId, orgId, opts = {}) {
384
387
  const item = await this.item(itemId, true);
385
- const changed = await addScopeOrg(this.db, actor, item, orgId, opts);
388
+ const changed = await addScopeOrg(this.db, this.hints, actor, item, orgId, opts);
386
389
  if (changed)
387
390
  await this.enqueue(itemId);
388
391
  return changed;
@@ -688,6 +691,7 @@ CatalogScopeService = __decorate([
688
691
  __param(6, Inject(ExtensionAdmin)),
689
692
  __param(7, Inject(ExtensionAdminOps)),
690
693
  __param(8, Inject(PluginScopeSync)),
691
- __param(9, Inject(TransactionHost))
694
+ __param(9, Inject(TransactionHost)),
695
+ __param(10, Inject(InvalidationHints))
692
696
  ], CatalogScopeService);
693
697
  export { CatalogScopeService };
@@ -9,6 +9,7 @@ import { ExtensionsModule } from "../extensions/extensions.module.js";
9
9
  import { ExtensionRegistryModule } from "../extensions/registry.js";
10
10
  import { SuperAdminLockModule } from "../identity/super-admin.js";
11
11
  import { QueueModule } from "../infra/queue/queue.module.js";
12
+ import { InvalidationHintsModule } from "../invalidation/invalidation-hints.module.js";
12
13
  import { ModelEnablementModule } from "../models/enablement.js";
13
14
  import { OrgLockModule } from "../orgs/org-lock.js";
14
15
  import { OrgSettingsModule } from "../orgs/settings.service.js";
@@ -50,6 +51,8 @@ let CatalogModule = class CatalogModule {
50
51
  CatalogModule = __decorate([
51
52
  Module({
52
53
  imports: [
54
+ // invalidation hints its writers publish after their commit
55
+ InvalidationHintsModule,
53
56
  CatalogImportModule,
54
57
  ExtensionsModule,
55
58
  SuperAdminLockModule,
@@ -10,6 +10,7 @@ import { TransactionHost } from "../infra/database/transaction-host.js";
10
10
  import { XactLock } from "../infra/database/xact-lock.js";
11
11
  import { KernelEvents } from "../infra/events/kernel-events.js";
12
12
  import { OutboxService } from "../infra/outbox/outbox.service.js";
13
+ import type { HintPublisher } from "../invalidation/audiences.js";
13
14
  import { OrgLock } from "../orgs/org-lock.js";
14
15
  import type { OfficialPublisherProof } from "../packages/official-publisher.js";
15
16
  import type { TranslationReport } from "./claude/report.js";
@@ -263,6 +264,7 @@ export declare class CatalogService {
263
264
  private readonly xactLock;
264
265
  private readonly outbox;
265
266
  private readonly events;
267
+ private readonly hints;
266
268
  constructor(kdb: KernelDb,
267
269
  /** The super admin lock (identity/super-admin.ts): joins the caller's transaction. */
268
270
  adminLock: SuperAdminLock, config: KernelConfigService, installs: ExtensionInstalls,
@@ -275,7 +277,7 @@ export declare class CatalogService {
275
277
  /** Serializes a claim release with an install of that name still committing (F10). */
276
278
  installLock: PluginInstallLock,
277
279
  /** The orgs whose connectors a delete switches off, locked before the item (ruling P3-50). */
278
- orgLock: OrgLock, txHost: TransactionHost, xactLock: XactLock, outbox: OutboxService, events: KernelEvents);
280
+ orgLock: OrgLock, txHost: TransactionHost, xactLock: XactLock, outbox: OutboxService, events: KernelEvents, hints: HintPublisher);
279
281
  /** The kernel-schema handle of the current context (the transaction, else the pool). */
280
282
  private get db();
281
283
  /** Downloads a marketplace archive source, verified against its integrity. */
@@ -26,6 +26,7 @@ import { Transactional } from "../infra/database/transactional.decorator.js";
26
26
  import { XactLock } from "../infra/database/xact-lock.js";
27
27
  import { KernelEvents } from "../infra/events/kernel-events.js";
28
28
  import { OutboxService } from "../infra/outbox/outbox.service.js";
29
+ import { InvalidationHints } from "../invalidation/invalidation-hints.js";
29
30
  import { OrgLock } from "../orgs/org-lock.js";
30
31
  import { sameRepository } from "../packages/provenance.js";
31
32
  import { assertNotPlatformDefault } from "../themes/theme-usage.js";
@@ -114,6 +115,7 @@ let CatalogService = class CatalogService {
114
115
  xactLock;
115
116
  outbox;
116
117
  events;
118
+ hints;
117
119
  constructor(kdb,
118
120
  /** The super admin lock (identity/super-admin.ts): joins the caller's transaction. */
119
121
  adminLock, config, installs,
@@ -126,7 +128,7 @@ let CatalogService = class CatalogService {
126
128
  /** Serializes a claim release with an install of that name still committing (F10). */
127
129
  installLock,
128
130
  /** The orgs whose connectors a delete switches off, locked before the item (ruling P3-50). */
129
- orgLock, txHost, xactLock, outbox, events) {
131
+ orgLock, txHost, xactLock, outbox, events, hints) {
130
132
  this.kdb = kdb;
131
133
  this.adminLock = adminLock;
132
134
  this.config = config;
@@ -140,6 +142,7 @@ let CatalogService = class CatalogService {
140
142
  this.xactLock = xactLock;
141
143
  this.outbox = outbox;
142
144
  this.events = events;
145
+ this.hints = hints;
143
146
  }
144
147
  /** The kernel-schema handle of the current context (the transaction, else the pool). */
145
148
  get db() {
@@ -665,9 +668,9 @@ let CatalogService = class CatalogService {
665
668
  // new item, whose install switches them back on (`relinkDeletedItemConnectors`). The super
666
669
  // admin's delete locked their orgs first; an owner's delete or an org deletion removes an
667
670
  // item no other org uses (P3-19), so its connectors are the owner org's, already locked
668
- await switchOffItemConnectors(t, itemId);
671
+ await switchOffItemConnectors(t, this.hints, itemId);
669
672
  // Pending requests for a deleted item are pointless: cancel them in the same transaction
670
- await cancelPendingRequests(t, { itemId }, actor, "item_removed", opts);
673
+ await cancelPendingRequests(t, this.hints, { itemId }, actor, "item_removed", opts);
671
674
  await audit(t, {
672
675
  actorAccountId: actor,
673
676
  ...(opts.actorTokenId !== undefined && { actorTokenId: opts.actorTokenId }),
@@ -711,6 +714,7 @@ CatalogService = __decorate([
711
714
  __param(9, Inject(TransactionHost)),
712
715
  __param(10, Inject(XactLock)),
713
716
  __param(11, Inject(OutboxService)),
714
- __param(12, Inject(KernelEvents))
717
+ __param(12, Inject(KernelEvents)),
718
+ __param(13, Inject(InvalidationHints))
715
719
  ], CatalogService);
716
720
  export { CatalogService };
@@ -2,6 +2,7 @@ import type { KernelSchemaDb } from "../db/kernel-schema.js";
2
2
  import { ApiError } from "../errors.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 { StorageService } from "../storage/storage.service.js";
6
7
  /** The kinds an org owns as rows of its own (connector templates have none). */
7
8
  export type PromotableKind = "skill" | "agent_template";
@@ -60,9 +61,10 @@ export declare class ComponentPromotion {
60
61
  /** Where files are read and written (the kernel's object storage). */
61
62
  private readonly files;
62
63
  readonly txHost: TransactionHost;
64
+ private readonly hints;
63
65
  constructor(kdb: KernelDb,
64
66
  /** Where files are read and written (the kernel's object storage). */
65
- files: StorageService, txHost: TransactionHost);
67
+ files: StorageService, txHost: TransactionHost, hints: HintPublisher);
66
68
  private get db();
67
69
  /**
68
70
  * The live org row `id` of `kind` (an org-scope skill, an agent template) of a live org, when it
@@ -24,6 +24,7 @@ import { audit } from "../identity/audit.js";
24
24
  import { KernelDb } from "../infra/database/kernel-db.js";
25
25
  import { TransactionHost } from "../infra/database/transaction-host.js";
26
26
  import { Transactional } from "../infra/database/transactional.decorator.js";
27
+ import { InvalidationHints } from "../invalidation/invalidation-hints.js";
27
28
  import { StorageService } from "../storage/storage.service.js";
28
29
  import { putCatalogFiles } from "./catalog-items.js";
29
30
  import { platformSkillPrefix, uniqueVersionPrefix } from "./platform-components.js";
@@ -53,12 +54,14 @@ let ComponentPromotion = class ComponentPromotion {
53
54
  kdb;
54
55
  files;
55
56
  txHost;
57
+ hints;
56
58
  constructor(kdb,
57
59
  /** Where files are read and written (the kernel's object storage). */
58
- files, txHost) {
60
+ files, txHost, hints) {
59
61
  this.kdb = kdb;
60
62
  this.files = files;
61
63
  this.txHost = txHost;
64
+ this.hints = hints;
62
65
  }
63
66
  get db() {
64
67
  return this.kdb.db;
@@ -250,7 +253,7 @@ let ComponentPromotion = class ComponentPromotion {
250
253
  .where("org_id", "=", row.orgId)
251
254
  .execute();
252
255
  }
253
- await writeScope(this.db, {
256
+ await writeScope(this.db, this.hints, {
254
257
  kind: p.kind,
255
258
  id: p.platformId,
256
259
  scopeMode: "own",
@@ -299,7 +302,8 @@ ComponentPromotion = __decorate([
299
302
  Injectable(),
300
303
  __param(0, Inject(KernelDb)),
301
304
  __param(1, Inject(StorageService)),
302
- __param(2, Inject(TransactionHost))
305
+ __param(2, Inject(TransactionHost)),
306
+ __param(3, Inject(InvalidationHints))
303
307
  ], ComponentPromotion);
304
308
  export { ComponentPromotion };
305
309
  /** {@link ComponentPromotion.orgRow} through `db` (readers outside the provider). */