@capybara-hq/kernel 0.1.0-rc.131 → 0.1.0-rc.133

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 (155) hide show
  1. package/bootstrap.json +5 -5
  2. package/dist/admin/admin.module.js +3 -0
  3. package/dist/admin/admin.schemas.d.ts +4 -0
  4. package/dist/admin/health.service.d.ts +2 -2
  5. package/dist/admin/health.service.js +6 -2
  6. package/dist/admin/setup.service.js +6 -1
  7. package/dist/agents/agents.controller.js +3 -2
  8. package/dist/agents/agents.service.d.ts +2 -0
  9. package/dist/agents/agents.service.js +7 -0
  10. package/dist/catalog/catalog.service.d.ts +2 -0
  11. package/dist/catalog/catalog.service.js +28 -5
  12. package/dist/catalog/marketplace-fetch.d.ts +2 -0
  13. package/dist/catalog/marketplace-fetch.js +15 -0
  14. package/dist/catalog/marketplaces.service.d.ts +4 -4
  15. package/dist/catalog/marketplaces.service.js +3 -2
  16. package/dist/catalog/owned-items.d.ts +2 -0
  17. package/dist/catalog/owned-items.js +30 -31
  18. package/dist/catalog/ownership.js +40 -38
  19. package/dist/catalog/plugin-import.d.ts +6 -5
  20. package/dist/catalog/plugin-import.js +69 -16
  21. package/dist/catalog/plugin-upgrade.d.ts +8 -0
  22. package/dist/catalog/plugin-upgrade.js +95 -7
  23. package/dist/catalog/publisher-policy.d.ts +9 -0
  24. package/dist/catalog/publisher-policy.js +12 -0
  25. package/dist/catalog/unshare.js +66 -58
  26. package/dist/client/client-access.service.js +5 -3
  27. package/dist/config/schema.d.ts +1 -0
  28. package/dist/config/schema.js +9 -1
  29. package/dist/conversations/conversations.controller.js +4 -14
  30. package/dist/conversations/conversations.service.d.ts +14 -0
  31. package/dist/conversations/conversations.service.js +20 -2
  32. package/dist/ctx/create-ctx.d.ts +14 -4
  33. package/dist/ctx/create-ctx.js +131 -59
  34. package/dist/ctx/queue.js +7 -4
  35. package/dist/db/extension-db.d.ts +30 -0
  36. package/dist/db/extension-db.js +91 -0
  37. package/dist/db/extension-rls-predicate.d.ts +1 -0
  38. package/dist/db/extension-rls-predicate.js +8 -0
  39. package/dist/db/extension-schema-transfer.d.ts +6 -0
  40. package/dist/db/extension-schema-transfer.js +141 -0
  41. package/dist/db/kernel-schema.d.ts +50 -4
  42. package/dist/db/migrator.d.ts +6 -0
  43. package/dist/db/migrator.js +35 -7
  44. package/dist/db/pool.d.ts +6 -2
  45. package/dist/db/pool.js +37 -2
  46. package/dist/db/sql-statements.d.ts +3 -0
  47. package/dist/db/sql-statements.js +15 -5
  48. package/dist/device-access/device-access.module.js +12 -2
  49. package/dist/device-access/device-access.service.d.ts +30 -2
  50. package/dist/device-access/device-access.service.js +38 -4
  51. package/dist/device-access/host-gate.d.ts +45 -0
  52. package/dist/device-access/host-gate.js +92 -0
  53. package/dist/device-access/host-service-stop-sweep.d.ts +33 -0
  54. package/dist/device-access/host-service-stop-sweep.js +112 -0
  55. package/dist/device-access/host-service-stop.d.ts +78 -0
  56. package/dist/device-access/host-service-stop.js +144 -0
  57. package/dist/device-access/host-services.d.ts +211 -0
  58. package/dist/device-access/host-services.js +803 -0
  59. package/dist/device-access/person-handles.d.ts +10 -0
  60. package/dist/device-access/person-handles.js +25 -0
  61. package/dist/device-access/service-events.d.ts +199 -0
  62. package/dist/device-access/service-events.js +704 -0
  63. package/dist/device-access/token.d.ts +5 -0
  64. package/dist/device-access/token.js +5 -0
  65. package/dist/devices/devices.service.js +3 -0
  66. package/dist/dial-in/access.d.ts +5 -5
  67. package/dist/dial-in/access.js +19 -12
  68. package/dist/dial-in/gateway.js +6 -2
  69. package/dist/dial-in/machines.d.ts +9 -2
  70. package/dist/dial-in/machines.js +27 -4
  71. package/dist/erasure/device-cleanup.js +12 -0
  72. package/dist/erasure/org-catalog.js +2 -2
  73. package/dist/erasure/org-rules.js +9 -0
  74. package/dist/errors.d.ts +2 -0
  75. package/dist/errors.js +2 -0
  76. package/dist/extensions/admin-ops.d.ts +3 -1
  77. package/dist/extensions/admin-ops.js +19 -9
  78. package/dist/extensions/deployed-snapshots.d.ts +4 -1
  79. package/dist/extensions/deployed-snapshots.js +7 -2
  80. package/dist/extensions/extensions.module.js +3 -0
  81. package/dist/extensions/host.d.ts +11 -3
  82. package/dist/extensions/host.js +40 -8
  83. package/dist/extensions/instance.d.ts +6 -0
  84. package/dist/extensions/instance.js +7 -1
  85. package/dist/extensions/ledger.d.ts +1 -1
  86. package/dist/extensions/lifecycle-hooks.js +3 -3
  87. package/dist/extensions/migrate-lock.d.ts +4 -1
  88. package/dist/extensions/migrate-lock.js +19 -2
  89. package/dist/extensions/org-config.js +6 -1
  90. package/dist/extensions/permission-set.d.ts +7 -0
  91. package/dist/extensions/permission-set.js +10 -0
  92. package/dist/extensions/permission-view.d.ts +1 -1
  93. package/dist/extensions/permission-view.js +10 -1
  94. package/dist/git/tickets.js +32 -27
  95. package/dist/http/app.js +5 -3
  96. package/dist/identity/accounts.d.ts +6 -1
  97. package/dist/identity/accounts.js +11 -2
  98. package/dist/identity/api-tokens.js +7 -6
  99. package/dist/identity/settings.d.ts +9 -1
  100. package/dist/identity/settings.js +16 -1
  101. package/dist/inbox/org-notices.js +3 -2
  102. package/dist/index.d.ts +1 -0
  103. package/dist/index.js +1 -0
  104. package/dist/infra/database/scoped-dialect.d.ts +3 -2
  105. package/dist/infra/database/scoped-dialect.js +260 -72
  106. package/dist/infra/database/startup-activation-transaction.d.ts +2 -0
  107. package/dist/infra/database/startup-activation-transaction.js +3 -2
  108. package/dist/infra/outbox/registry.d.ts +28 -14
  109. package/dist/infra/outbox/registry.js +30 -15
  110. package/dist/infra/queue/queue-names.d.ts +1 -1
  111. package/dist/infra/queue/queue-names.js +1 -0
  112. package/dist/infra/queue/run-job.d.ts +4 -1
  113. package/dist/infra/queue/run-job.js +10 -2
  114. package/dist/kernel.js +4 -0
  115. package/dist/kernel.module.js +3 -0
  116. package/dist/lifecycle/kernel-lifecycle.d.ts +3 -1
  117. package/dist/lifecycle/kernel-lifecycle.js +26 -21
  118. package/dist/orgs/offboarding.js +18 -9
  119. package/dist/orgs/settings.service.js +3 -0
  120. package/dist/packages/npm-publish-keys.json +27 -0
  121. package/dist/packages/official-publisher.d.ts +19 -0
  122. package/dist/packages/official-publisher.js +152 -0
  123. package/dist/packages/provenance.d.ts +7 -0
  124. package/dist/packages/provenance.js +22 -19
  125. package/dist/packages/sigstore-trusted-root.json +126 -0
  126. package/dist/platform/ops/admin.ops.js +2 -1
  127. package/dist/platform/ops/orgs.ops.js +1 -0
  128. package/dist/roles/worker-role.d.ts +6 -3
  129. package/dist/roles/worker-role.js +12 -4
  130. package/dist/roles/worker.module.js +7 -6
  131. package/dist/runtime/maintenance.d.ts +5 -4
  132. package/dist/runtime/maintenance.js +16 -13
  133. package/dist/sandbox/device-reports.d.ts +4 -4
  134. package/dist/sandbox/device-reports.js +40 -30
  135. package/dist/sandbox/device-services.d.ts +2 -1
  136. package/dist/sandbox/device-services.js +5 -1
  137. package/dist/sandbox/permission-ceiling-writes.d.ts +8 -0
  138. package/dist/sandbox/permission-ceiling-writes.js +21 -0
  139. package/dist/sandbox/permission-config-publication.js +5 -1
  140. package/dist/themes/theme-state.js +24 -13
  141. package/dist/tools/call-scope.d.ts +6 -0
  142. package/dist/tools/call-scope.js +22 -0
  143. package/dist/tools/registry.js +20 -2
  144. package/dist/ui/views.js +36 -8
  145. package/package.json +9 -4
  146. package/src/migrations/0219_event_org_constraint_check.sql +29 -0
  147. package/src/migrations/0220_require_event_org.sql +18 -0
  148. package/src/migrations/0221_drop_connector_declaration_policy.sql +2 -0
  149. package/src/migrations/0222_device_host_services.sql +27 -0
  150. package/src/migrations/0223_device_service_events.sql +54 -0
  151. package/src/migrations/0224_cache_conversation_rls_settings.sql +33 -0
  152. package/dist/conversations/event-org-backfill.d.ts +0 -111
  153. package/dist/conversations/event-org-backfill.js +0 -264
  154. package/dist/conversations/event-org-backfill.module.d.ts +0 -3
  155. package/dist/conversations/event-org-backfill.module.js +0 -18
@@ -18,10 +18,12 @@ import { TRIGGER_EVENTS_BACKEND } from "../automations/events/token.js";
18
18
  import { changedPaths, configFields, getPath, secretValues, unreachableSecrets, } from "../config/fields.js";
19
19
  import { pluginSchemaName, queryEnabledPlugins, } from "../ctx/create-ctx.js";
20
20
  import { EXTENSION_NET_SEAMS } from "../ctx/net.js";
21
+ import { ConfiguredExtensionDbIdentity, extensionDbIdentity, extensionDbPool, } from "../db/extension-db.js";
22
+ import { transferKnownExtensionSchemas } from "../db/extension-schema-transfer.js";
21
23
  import { kernelDb } from "../db/kernel-schema.js";
22
24
  import { migrate } from "../db/migrator.js";
23
25
  import { createDb } from "../db/pool.js";
24
- import { DEVICE_ACCESS_BACKEND } from "../device-access/token.js";
26
+ import { DEVICE_ACCESS_BACKEND, SERVICE_EVENTS_BACKEND } from "../device-access/token.js";
25
27
  import { DialInAccess } from "../dial-in/access.js";
26
28
  import { INBOX_ITEMS_BACKEND } from "../inbox/token.js";
27
29
  import { waitWithin } from "../infra/close-within.js";
@@ -181,12 +183,16 @@ function warnPending(log, p) {
181
183
  * 无迁移时返回 undefined。迁移器在会话上持有按 schema 的咨询锁:多副本同时启动时只有一个在执行,其余等它结束后
182
184
  * 发现都已应用。
183
185
  */
184
- async function migratePlugin(dbUrl, manifest, migrationsDir, connectTimeoutMs, signal) {
186
+ async function migratePlugin(connection, manifest, migrationsDir, connectTimeoutMs, signal) {
185
187
  if (!migrationsDir)
186
188
  return undefined;
187
189
  const schema = pluginSchemaName(manifest.name);
188
190
  try {
189
- const { applied } = await migrate(dbUrl, { schema, dir: migrationsDir }, { connectTimeoutMs, signal });
191
+ const { applied } = await migrate(connection.url, { schema, dir: migrationsDir }, {
192
+ connectTimeoutMs,
193
+ signal,
194
+ extensionLogin: connection.separate ? connection.login : undefined,
195
+ });
190
196
  return { schema, applied };
191
197
  }
192
198
  catch (e) {
@@ -237,6 +243,7 @@ let ExtensionHost = class ExtensionHost {
237
243
  config;
238
244
  log;
239
245
  effective;
246
+ dbIdentity;
240
247
  /**
241
248
  * Only resolves extensions and runs migrations in dependency order: no deployment config check, no
242
249
  * setup, no Redis (for `capybara migrate`). Like `load()` it checks secret markers first
@@ -254,6 +261,10 @@ let ExtensionHost = class ExtensionHost {
254
261
  const ordered = resolveExtensions(entries.map((e) => e.manifest), SDK_VERSION);
255
262
  for (const manifest of ordered)
256
263
  assertSecretsReachable(manifest);
264
+ const identity = opts.extensionIdentity ?? extensionDbIdentity({ url: opts.dbUrl });
265
+ if (opts.extensionIdentity) {
266
+ await transferKnownExtensionSchemas(opts.dbUrl, identity, dirs.keys(), opts.connectTimeoutMs);
267
+ }
257
268
  let toMigrate = ordered;
258
269
  if (!opts.autoApprove && ordered.length > 0) {
259
270
  const sets = await permissionSets(ordered, dirs);
@@ -273,7 +284,7 @@ let ExtensionHost = class ExtensionHost {
273
284
  }
274
285
  const out = [];
275
286
  for (const manifest of toMigrate) {
276
- const r = await migratePlugin(opts.dbUrl, manifest, migrationsDirOf(manifest, dirs.get(manifest.name)), opts.connectTimeoutMs);
287
+ const r = await migratePlugin(identity.resolve(manifest.name), manifest, migrationsDirOf(manifest, dirs.get(manifest.name)), opts.connectTimeoutMs);
277
288
  if (r)
278
289
  out.push({ plugin: manifest.name, ...r });
279
290
  }
@@ -439,11 +450,12 @@ let ExtensionHost = class ExtensionHost {
439
450
  * Absent (a hand-built host) or not found (the CLI): `ctx.deviceAccess` calls are refused.
440
451
  * `TriggerEventsService` (`ctx.triggers`, {@link TRIGGER_EVENTS_BACKEND}) and
441
452
  * `InboxItemsService` (`ctx.inbox`, {@link INBOX_ITEMS_BACKEND}) and `PluginReadsService`
442
- * (`ctx.agents`, `ctx.conversations`, `ctx.people`, {@link PLUGIN_READS_BACKEND}) likewise.
453
+ * (`ctx.agents`, `ctx.conversations`, `ctx.people`, {@link PLUGIN_READS_BACKEND}) and
454
+ * `ServiceEvents` (`ctx.devices.serviceEvent`, {@link SERVICE_EVENTS_BACKEND}) likewise.
443
455
  */
444
456
  modules,
445
457
  /** Tests only: `ctx.net`'s DNS and dispatcher seams (`EXTENSION_NET_SEAMS`). */
446
- netSeams) {
458
+ netSeams, dbIdentity = extensionDbIdentity(config.get().db)) {
447
459
  this.registry = registry;
448
460
  this.installs = installs;
449
461
  this.approvals = approvals;
@@ -451,6 +463,7 @@ let ExtensionHost = class ExtensionHost {
451
463
  this.config = config;
452
464
  this.log = log;
453
465
  this.effective = effective;
466
+ this.dbIdentity = dbIdentity;
454
467
  const c = config.get();
455
468
  this.hooks = new HookRegistry({
456
469
  instances: () => this.registry.all(),
@@ -486,6 +499,14 @@ let ExtensionHost = class ExtensionHost {
486
499
  return undefined;
487
500
  }
488
501
  },
502
+ serviceEvents: () => {
503
+ try {
504
+ return modules?.get(SERVICE_EVENTS_BACKEND, { strict: false });
505
+ }
506
+ catch {
507
+ return undefined;
508
+ }
509
+ },
489
510
  triggers: () => {
490
511
  try {
491
512
  return modules?.get(TRIGGER_EVENTS_BACKEND, { strict: false });
@@ -1410,7 +1431,7 @@ let ExtensionHost = class ExtensionHost {
1410
1431
  // 安装记录:一个副本持锁迁移(C16),别的副本正在迁移时待定、旧实例照常;配置声明:按 schema 锁直接迁移
1411
1432
  const migrating = a.migrate
1412
1433
  ? a.migrate()
1413
- : migratePlugin(this.deps.dbUrl, manifest, a.migrationsDir, this.deps.connectTimeoutMs, this.abort.signal);
1434
+ : migratePlugin(this.dbIdentity.resolve(name), manifest, a.migrationsDir, this.deps.connectTimeoutMs, this.abort.signal);
1414
1435
  this.migrating = migrating;
1415
1436
  try {
1416
1437
  if ((await migrating) === "busy") {
@@ -1783,6 +1804,11 @@ let ExtensionHost = class ExtensionHost {
1783
1804
  warnUpgrades(this.log, this.imports);
1784
1805
  }
1785
1806
  let ctx;
1807
+ const name = spec.manifest.name;
1808
+ const identity = this.dbIdentity.resolve(name);
1809
+ const extensionDb = identity.separate
1810
+ ? extensionDbPool(identity, name, this.config.get().db, (err) => this.log.warn("extension database pool error", { plugin: name, err }))
1811
+ : undefined;
1786
1812
  const p = setupInstance(this.loadDeps, spec.manifest, {
1787
1813
  entryUrl: spec.entryUrl,
1788
1814
  source: spec.source,
@@ -1790,12 +1816,17 @@ let ExtensionHost = class ExtensionHost {
1790
1816
  config: spec.config,
1791
1817
  configHash: spec.configHash,
1792
1818
  permissions: spec.permissions,
1819
+ ...(extensionDb && { extensionDb }),
1793
1820
  onCtx: (c) => {
1794
1821
  if (c)
1795
1822
  ctx = c;
1796
1823
  if (c || this.settingUp === ctx)
1797
1824
  this.settingUp = c;
1798
1825
  },
1826
+ }).catch(async (error) => {
1827
+ if (!ctx)
1828
+ await extensionDb?.destroy();
1829
+ throw error;
1799
1830
  });
1800
1831
  if (timeoutMs === undefined)
1801
1832
  return p.then((inst) => this.logUiResolution(inst));
@@ -2476,6 +2507,7 @@ ExtensionHost = __decorate([
2476
2507
  __param(20, Optional()),
2477
2508
  __param(20, Inject(ModuleRef)),
2478
2509
  __param(21, Optional()),
2479
- __param(21, Inject(EXTENSION_NET_SEAMS))
2510
+ __param(21, Inject(EXTENSION_NET_SEAMS)),
2511
+ __param(22, Inject(ConfiguredExtensionDbIdentity))
2480
2512
  ], ExtensionHost);
2481
2513
  export { ExtensionHost };
@@ -1,5 +1,7 @@
1
1
  import { type DroppedUiContribution, type ExtensionManifest, type ExtensionPointRef, type ResolvedUiContribution, type StaticExtensionManifest } from "@capybara-hq/plugin-sdk";
2
2
  import { type ExtensionPointAccess, type KernelDeps, type KernelExtensionContext, LiveConfig, type RegisteredSetupCheck, type RegisteredTool, type Route } from "../ctx/create-ctx.js";
3
+ import type { extensionDbPool } from "../db/extension-db.js";
4
+ import type { ServiceEventHandler } from "../device-access/service-events.js";
3
5
  import type { UiActionHandler, UiQueryHandler, UiRender } from "../ui/registry.js";
4
6
  import type { RegisteredHook } from "./hooks.js";
5
7
  import { InflightTracker } from "./inflight.js";
@@ -81,6 +83,8 @@ export declare class ExtensionInstance {
81
83
  get uiQueries(): ReadonlyMap<string, UiQueryHandler>;
82
84
  /** Setup checks registered through `ctx.setup.check` (empty after revocation). */
83
85
  get setupChecks(): ReadonlyMap<string, RegisteredSetupCheck>;
86
+ /** Handlers registered through `ctx.deviceAccess.onServiceEvent` (empty after revocation). */
87
+ get serviceEventHandlers(): ReadonlyMap<string, ServiceEventHandler>;
84
88
  /** The instance's `ctx.signal`: aborted when it is revoked or disposed. */
85
89
  get signal(): AbortSignal;
86
90
  /** 账上仍在的登记(撤销后为空)。 */
@@ -159,6 +163,7 @@ export declare function setupInstance(deps: LoadDeps, manifest: ExtensionManifes
159
163
  permissions: PermissionSet;
160
164
  /** 已建好 ctx、setup 进行中时回调(宿主据此在 close() 时立即关闭它)。 */
161
165
  onCtx?: (ctx: KernelExtensionContext | undefined) => void;
166
+ extensionDb?: ReturnType<typeof extensionDbPool>;
162
167
  }): Promise<ExtensionInstance>;
163
168
  /**
164
169
  * 加载一个插件实例:import → defineExtension → 有包内静态清单(`section`)时与 {@link staticManifestOf} 核对
@@ -179,4 +184,5 @@ export declare function loadInstance(deps: LoadDeps, input: {
179
184
  manifest: StaticExtensionManifest;
180
185
  };
181
186
  onCtx?: (ctx: KernelExtensionContext | undefined) => void;
187
+ extensionDb?: ReturnType<typeof extensionDbPool>;
182
188
  }): Promise<ExtensionInstance>;
@@ -2,6 +2,7 @@ import { dirname } from "node:path";
2
2
  import { fileURLToPath } from "node:url";
3
3
  import { defineExtension, ExtensionManifestError, staticManifestOf, } from "@capybara-hq/plugin-sdk";
4
4
  import { createExtensionContext, LiveConfig, } from "../ctx/create-ctx.js";
5
+ import { asPlatform } from "../infra/database/org-scope.js";
5
6
  import { InflightTracker } from "./inflight.js";
6
7
  const errMsg = (e) => (e instanceof Error ? e.message : String(e));
7
8
  /** 模块清单与审阅过的静态清单(包内 `capybara.manifest`)不一致。 */
@@ -135,6 +136,10 @@ export class ExtensionInstance {
135
136
  get setupChecks() {
136
137
  return this.ctx.setupChecks;
137
138
  }
139
+ /** Handlers registered through `ctx.deviceAccess.onServiceEvent` (empty after revocation). */
140
+ get serviceEventHandlers() {
141
+ return this.ctx.serviceEventHandlers;
142
+ }
138
143
  /** The instance's `ctx.signal`: aborted when it is revoked or disposed. */
139
144
  get signal() {
140
145
  return this.ctx.signal;
@@ -299,10 +304,11 @@ export async function setupInstance(deps, manifest, input) {
299
304
  const live = new LiveConfig(input.config);
300
305
  const ctx = createExtensionContext(deps.kernel, manifest, live, deps.extensionPointAccess, {
301
306
  sha256: input.sha256,
307
+ ...(input.extensionDb && { db: input.extensionDb }),
302
308
  });
303
309
  input.onCtx?.(ctx);
304
310
  try {
305
- await manifest.setup(ctx);
311
+ await asPlatform("initialize an extension on this replica", () => manifest.setup(ctx));
306
312
  ctx.sealTools();
307
313
  for (const cap of manifest.provides) {
308
314
  if (!ctx.provided.has(cap)) {
@@ -1,5 +1,5 @@
1
1
  /** 插件经 ctx 做的一项登记的种类(C17)。 */
2
- export type RegistrationKind = "tool" | "route" | "queue" | "bus" | "lease" | "ui.view" | "ui.action" | "ui.query" | "provide" | "hook" | "setup.check";
2
+ export type RegistrationKind = "tool" | "route" | "queue" | "bus" | "lease" | "ui.view" | "ui.action" | "ui.query" | "provide" | "hook" | "setup.check" | "service.event";
3
3
  /** 账上的一项:撤销时调用 `dispose()`。 */
4
4
  export interface Registration {
5
5
  kind: RegistrationKind;
@@ -11,6 +11,7 @@ import { OnWorkerEvent, Processor, WorkerHost } from "@nestjs/bullmq";
11
11
  import { Inject, Injectable, Module } from "@nestjs/common";
12
12
  import { sql } from "kysely";
13
13
  import { KernelDb } from "../infra/database/kernel-db.js";
14
+ import { withOrgScope } from "../infra/database/org-scope.js";
14
15
  import { TransactionHost } from "../infra/database/transaction-host.js";
15
16
  import { Transactional } from "../infra/database/transactional.decorator.js";
16
17
  import { OutboxService } from "../infra/outbox/outbox.service.js";
@@ -250,9 +251,8 @@ let LifecycleHooksProcessor = class LifecycleHooksProcessor extends WorkerHost {
250
251
  this.log = log;
251
252
  }
252
253
  process(job) {
253
- return runJob(LIFECYCLE_QUEUE, job, () => this.hooks.process(job.data, this.stopping.signal), {
254
- platform: "extension lifecycle hook (deployment-wide)",
255
- });
254
+ // The original job shape already carries the organization inside the durable payload.
255
+ return runJob(LIFECYCLE_QUEUE, job, () => withOrgScope(job.data.payload.orgId, () => this.hooks.process(job.data, this.stopping.signal)));
256
256
  }
257
257
  /** Starts consuming (worker role, after the extensions loaded). */
258
258
  start() {
@@ -1,3 +1,4 @@
1
+ import { type ExtensionDbConnection } from "../db/extension-db.js";
1
2
  import type { KernelSchemaDb } from "../db/kernel-schema.js";
2
3
  /** 插件迁移完成(kernel bus 主题,频道 `cap:kernel:plugins.migrated`,payload `{ plugin, sha256 }`)。 */
3
4
  export declare const PLUGINS_MIGRATED_TOPIC = "plugins.migrated";
@@ -8,6 +9,8 @@ export interface MigrateLockDeps {
8
9
  db: KernelSchemaDb;
9
10
  /** 迁移用独立连接(不走连接池)。 */
10
11
  dbUrl: string;
12
+ /** The schema migrations authenticate independently of the install record lock. */
13
+ extensionDb?: ExtensionDbConnection;
11
14
  connectTimeoutMs?: number | undefined;
12
15
  /** 发布 `plugins.migrated`(kernel bus)。 */
13
16
  bus: {
@@ -47,4 +50,4 @@ export declare function ensureMigrated(d: MigrateLockDeps, name: string, sha256:
47
50
  export declare function unrunMigrations(db: KernelSchemaDb, name: string, files: {
48
51
  file: string;
49
52
  sql: string;
50
- }[]): Promise<string[]>;
53
+ }[], identity?: ExtensionDbConnection, connectTimeoutMs?: number): Promise<string[]>;
@@ -2,6 +2,7 @@ import { createHash } from "node:crypto";
2
2
  import { sql } from "kysely";
3
3
  import pg from "pg";
4
4
  import { pluginSchemaName } from "../ctx/create-ctx.js";
5
+ import { extensionDbPool } from "../db/extension-db.js";
5
6
  import { migrate } from "../db/migrator.js";
6
7
  import { pgConnectOptions } from "../db/pool.js";
7
8
  /** 插件迁移完成(kernel bus 主题,频道 `cap:kernel:plugins.migrated`,payload `{ plugin, sha256 }`)。 */
@@ -42,9 +43,10 @@ export async function ensureMigrated(d, name, sha256, dir) {
42
43
  const timeout = d.timeoutMs === undefined ? undefined : AbortSignal.timeout(d.timeoutMs);
43
44
  const signals = [d.signal, timeout].filter((x) => x !== undefined);
44
45
  try {
45
- await migrate(d.dbUrl, { schema: pluginSchemaName(name), dir }, {
46
+ await migrate(d.extensionDb?.url ?? d.dbUrl, { schema: pluginSchemaName(name), dir }, {
46
47
  connectTimeoutMs: d.connectTimeoutMs,
47
48
  signal: signals.length > 0 ? AbortSignal.any(signals) : undefined,
49
+ extensionLogin: d.extensionDb?.separate ? d.extensionDb.login : undefined,
48
50
  ...(d.timeoutMs !== undefined && {
49
51
  statementTimeoutMs: d.timeoutMs,
50
52
  lockTimeoutMs: Math.min(d.timeoutMs, MIGRATION_LOCK_TIMEOUT_MS),
@@ -83,9 +85,24 @@ export async function ensureMigrated(d, name, sha256, dir) {
83
85
  * 按插件 schema 的 `_migrations` 表比对文件名与 checksum(与迁移器相同的 sha256);改过内容的也算未执行。
84
86
  * 插件从没迁移过时返回全部文件。
85
87
  */
86
- export async function unrunMigrations(db, name, files) {
88
+ export async function unrunMigrations(db, name, files, identity, connectTimeoutMs) {
87
89
  if (files.length === 0)
88
90
  return [];
91
+ if (!identity?.separate)
92
+ return readUnrunMigrations(db, name, files);
93
+ const pool = extensionDbPool(identity, name, {
94
+ rls: "off",
95
+ connectTimeoutMs,
96
+ extensionPoolMax: 1,
97
+ });
98
+ try {
99
+ return await readUnrunMigrations(pool, name, files);
100
+ }
101
+ finally {
102
+ await pool.destroy();
103
+ }
104
+ }
105
+ async function readUnrunMigrations(db, name, files) {
89
106
  const schema = pluginSchemaName(name);
90
107
  const exists = await sql `SELECT to_regclass(${`"${schema}"._migrations`})::text AS t`.execute(db);
91
108
  const done = new Map();
@@ -11,6 +11,7 @@ import { EXTENSION_POINTS, parseExtensionPoint, } from "@capybara-hq/plugin-sdk"
11
11
  import { Inject, Injectable } from "@nestjs/common";
12
12
  import { assertItemInstallable, assertPluginSourcesInstallable, disabledPluginItems, pluginItemDisabled, } from "../catalog/request-rules.js";
13
13
  import { oweTemplateConnectors } from "../catalog/template-connector-jobs.js";
14
+ import { oweHostServicesStop } from "../device-access/host-service-stop.js";
14
15
  import { revokeSiteGrantsOfExtension } from "../device-access/site-grants.js";
15
16
  import { ApiError } from "../errors.js";
16
17
  import { audit } from "../identity/audit.js";
@@ -293,8 +294,11 @@ let OrgExtensionConfigs = class OrgExtensionConfigs {
293
294
  updated_at: new Date(),
294
295
  }))
295
296
  .execute();
296
- if (!enabled)
297
+ if (!enabled) {
297
298
  await revokeSiteGrantsOfExtension(t, { orgId, extensionName: plugin });
299
+ // its host services on the org's machines stop (local agents spec, call 5)
300
+ await oweHostServicesStop(t, this.outbox, { orgId, extension: plugin });
301
+ }
298
302
  // Switched on: it may provide the connector kind of a template whose plugin is installed in
299
303
  // the org without its connector; a worker creates the connectors it never had, once the
300
304
  // extension is loaded there (ruling R27)
@@ -414,6 +418,7 @@ let OrgExtensionConfigs = class OrgExtensionConfigs {
414
418
  if (!r)
415
419
  return false;
416
420
  await revokeSiteGrantsOfExtension(t, { orgId, extensionName: plugin });
421
+ await oweHostServicesStop(t, this.outbox, { orgId, extension: plugin });
417
422
  await audit(t, {
418
423
  actorAccountId,
419
424
  orgId,
@@ -81,6 +81,8 @@ export interface PermissionSet {
81
81
  services: string[];
82
82
  loopbackPorts?: true;
83
83
  siteAccess?: true;
84
+ /** Services that may run on the owner's machine outside the sandbox: one blocking key each. */
85
+ hostServices?: string[];
84
86
  };
85
87
  /**
86
88
  * The event types the extension may emit (`permissions.triggers.emit`, collaboration spec
@@ -188,6 +190,11 @@ export declare const DEVICE_ACCESS_KEY_PREFIX = "permissions.deviceaccess:";
188
190
  * upgrade without approval again. Recorded only when declared.
189
191
  */
190
192
  export declare const DEVICE_LOOPBACK_PORTS_KEY = "permissions.deviceaccess.loopbackports";
193
+ /**
194
+ * Key prefix of a host service (`permissions.deviceAccess.hostServices`): the service runs on the
195
+ * owner's machine outside the sandbox; sensitive and blocking like any device service key.
196
+ */
197
+ export declare const DEVICE_HOST_KEY_PREFIX = "permissions.deviceaccess.host:";
191
198
  /** Blocking permission for profile decisions on non-loopback site actions. */
192
199
  export declare const DEVICE_SITE_ACCESS_KEY = "permissions.deviceaccess.siteaccess";
193
200
  /**
@@ -124,6 +124,9 @@ export function buildPermissionSet(input) {
124
124
  services: sortedUnique(p.deviceAccess.services),
125
125
  ...(p.deviceAccess.loopbackPorts === true && { loopbackPorts: true }),
126
126
  ...(p.deviceAccess.siteAccess === true && { siteAccess: true }),
127
+ ...(p.deviceAccess.hostServices && p.deviceAccess.hostServices.length > 0
128
+ ? { hostServices: sortedUnique(p.deviceAccess.hostServices) }
129
+ : {}),
127
130
  },
128
131
  }
129
132
  : {}),
@@ -200,6 +203,8 @@ export function permissionKeys(set) {
200
203
  keys.push(DEVICE_LOOPBACK_PORTS_KEY);
201
204
  if (p.deviceAccess?.siteAccess === true)
202
205
  keys.push(DEVICE_SITE_ACCESS_KEY);
206
+ for (const svc of p.deviceAccess?.hostServices ?? [])
207
+ keys.push(`${DEVICE_HOST_KEY_PREFIX}${svc}`);
203
208
  for (const t of p.triggers?.emit ?? [])
204
209
  keys.push(`${TRIGGERS_KEY_PREFIX}${t}`);
205
210
  if (p.inbox === true)
@@ -241,6 +246,11 @@ export const DEVICE_ACCESS_KEY_PREFIX = "permissions.deviceaccess:";
241
246
  * upgrade without approval again. Recorded only when declared.
242
247
  */
243
248
  export const DEVICE_LOOPBACK_PORTS_KEY = "permissions.deviceaccess.loopbackports";
249
+ /**
250
+ * Key prefix of a host service (`permissions.deviceAccess.hostServices`): the service runs on the
251
+ * owner's machine outside the sandbox; sensitive and blocking like any device service key.
252
+ */
253
+ export const DEVICE_HOST_KEY_PREFIX = "permissions.deviceaccess.host:";
244
254
  /** Blocking permission for profile decisions on non-loopback site actions. */
245
255
  export const DEVICE_SITE_ACCESS_KEY = "permissions.deviceaccess.siteaccess";
246
256
  /**
@@ -34,7 +34,7 @@ export interface PermissionGroup {
34
34
  * ({@link SENSITIVE_EXTENSION_POINTS}; the code is the extension point name without `@<major>`, with
35
35
  * `-` replaced by `_`).
36
36
  */
37
- export type SensitiveReason = "secrets" | "public_routes" | "embed_routes" | "tools" | "hooks" | "ui_embed" | "client_code" | "ui_component" | "channel" | "directory" | "identity_source" | "device_provider" | "object_store" | "context" | "push_provider" | "device_access" | "device_loopback_ports" | "device_site_access" | "migration_warnings";
37
+ export type SensitiveReason = "secrets" | "public_routes" | "embed_routes" | "tools" | "hooks" | "ui_embed" | "client_code" | "ui_component" | "channel" | "directory" | "identity_source" | "device_provider" | "object_store" | "context" | "push_provider" | "device_access" | "device_loopback_ports" | "device_site_access" | "device_host_service" | "migration_warnings";
38
38
  /** 权限清单里的一项(分组里的一项,或 `added` 里的一个权限键)。 */
39
39
  export interface PermissionItem {
40
40
  value: string;
@@ -1,7 +1,8 @@
1
1
  import { createHash } from "node:crypto";
2
2
  import { pluginSchemaName } from "../ctx/create-ctx.js";
3
+ import { EXTENSION_RLS_PREDICATE } from "../db/extension-rls-predicate.js";
3
4
  import { isDestructiveSql, splitSqlStatements } from "../db/sql-statements.js";
4
- import { AGENTS_KEY, CLIENT_KEY, CONVERSATIONS_KEY, DEVICE_ACCESS_KEY_PREFIX, DEVICE_LOOPBACK_PORTS_KEY, DEVICE_SITE_ACCESS_KEY, DIAL_IN_KEY_PREFIX, INBOX_KEY, PEOPLE_KEY, permissionKeys, TRIGGERS_KEY_PREFIX, UI_COMPONENT_KEY_PREFIX, WARNINGS_KEY_PREFIX, } from "./permission-set.js";
5
+ import { AGENTS_KEY, CLIENT_KEY, CONVERSATIONS_KEY, DEVICE_ACCESS_KEY_PREFIX, DEVICE_HOST_KEY_PREFIX, DEVICE_LOOPBACK_PORTS_KEY, DEVICE_SITE_ACCESS_KEY, DIAL_IN_KEY_PREFIX, INBOX_KEY, PEOPLE_KEY, permissionKeys, TRIGGERS_KEY_PREFIX, UI_COMPONENT_KEY_PREFIX, WARNINGS_KEY_PREFIX, } from "./permission-set.js";
5
6
  /**
6
7
  * Review digest: the first 16 hex digits of `sha256(permissionKeys(set).join("\n"))`; with migration
7
8
  * warnings their digest (kind, file, line and statement) is folded in, without warnings it equals the
@@ -43,6 +44,8 @@ const CLIENT_ITEM = "client code";
43
44
  /** The "deviceAccess" group's item of loopback port grants (`permissions.deviceAccess.loopbackPorts`). */
44
45
  const LOOPBACK_PORTS_ITEM = "local ports on the device (loopback)";
45
46
  const SITE_ACCESS_ITEM = "profile-approved actions on websites";
47
+ /** Item prefix of a host service (`permissions.deviceAccess.hostServices`): `host:<service>`. */
48
+ const HOST_ITEM_PREFIX = "host:";
46
49
  /** The one item of the "inbox" group (collaboration spec §4.9). */
47
50
  const INBOX_ITEM = "personal inbox items";
48
51
  /** The items of the read-only org fact groups. */
@@ -92,6 +95,8 @@ function itemReason(category, item) {
92
95
  return "device_loopback_ports";
93
96
  if (category === "deviceAccess" && item === SITE_ACCESS_ITEM)
94
97
  return "device_site_access";
98
+ if (category === "deviceAccess" && item.startsWith(HOST_ITEM_PREFIX))
99
+ return "device_host_service";
95
100
  return ALWAYS_SENSITIVE.has(category) ? CATEGORY_REASON[category] : undefined;
96
101
  }
97
102
  /** Routes of the `http` group: member and admin (the kernel authenticates a person). */
@@ -134,6 +139,7 @@ function keyItem(key) {
134
139
  ["ui.view:", "ui", "view:"],
135
140
  [DIAL_IN_KEY_PREFIX, "dialIn", ""],
136
141
  [DEVICE_ACCESS_KEY_PREFIX, "deviceAccess", ""],
142
+ [DEVICE_HOST_KEY_PREFIX, "deviceAccess", HOST_ITEM_PREFIX],
137
143
  [TRIGGERS_KEY_PREFIX, "triggers", ""],
138
144
  ];
139
145
  for (const [prefix, category, itemPrefix] of table) {
@@ -220,6 +226,7 @@ export function permissionGroups(set) {
220
226
  ...(p.deviceAccess?.services ?? []),
221
227
  ...(p.deviceAccess?.loopbackPorts === true ? [LOOPBACK_PORTS_ITEM] : []),
222
228
  ...(p.deviceAccess?.siteAccess === true ? [SITE_ACCESS_ITEM] : []),
229
+ ...(p.deviceAccess?.hostServices ?? []).map((s) => `${HOST_ITEM_PREFIX}${s}`),
223
230
  ],
224
231
  },
225
232
  // the event types it emits for the orgs' event automations (not sensitive)
@@ -287,6 +294,8 @@ export function deriveExtensionStatus(i) {
287
294
  export function migrationWarnings(files, plugin) {
288
295
  const own = pluginSchemaName(plugin);
289
296
  return files.flatMap((m) => splitSqlStatements(m.sql).flatMap((st) => {
297
+ if (m.sql.slice(st.startOffset, st.endOffset) === EXTENSION_RLS_PREDICATE)
298
+ return [];
290
299
  const base = { sensitive: true, file: m.file, line: st.line, statement: st.text };
291
300
  if (/^DO\b/i.test(st.text))
292
301
  return [{ kind: "dynamic_sql", ...base }];
@@ -12,6 +12,7 @@ import { Inject, Injectable } from "@nestjs/common";
12
12
  import { z } from "zod";
13
13
  import { KernelConfigService } from "../infra/config/kernel-config.service.js";
14
14
  import { KernelDb } from "../infra/database/kernel-db.js";
15
+ import { withOrgScope } from "../infra/database/org-scope.js";
15
16
  import { KERNEL_LOGGER, REDIS } from "../infra/tokens.js";
16
17
  import { readOrgSettings } from "../orgs/settings.service.js";
17
18
  const BindingSchema = z.object({
@@ -110,33 +111,37 @@ let GitTickets = class GitTickets {
110
111
  const binding = parseBinding(stored);
111
112
  if (binding === null)
112
113
  return refuse("invalid binding");
113
- const run = await this.db
114
- .selectFrom("runs")
115
- .innerJoin("conversations", "conversations.id", "runs.conversation_id")
116
- .innerJoin("orgs", "orgs.id", "conversations.org_id")
117
- .select(["runs.status", "conversations.org_id"])
118
- .where("runs.id", "=", binding.runId)
119
- .where("orgs.deleted_at", "is", null)
120
- .executeTakeFirst();
121
- if (run === undefined || run.org_id !== binding.orgId)
122
- return refuse("run not in org");
123
- if (!ACTIVE_RUN_STATUSES.includes(run.status)) {
124
- return refuse("run not active");
125
- }
126
- const member = await this.db
127
- .selectFrom("memberships")
128
- .innerJoin("accounts", "accounts.id", "memberships.account_id")
129
- .select("memberships.account_id")
130
- .where("memberships.org_id", "=", binding.orgId)
131
- .where("memberships.account_id", "=", binding.accountId)
132
- .where("accounts.status", "=", "active")
133
- .executeTakeFirst();
134
- if (member === undefined)
135
- return refuse("not an active member");
136
- const settings = await readOrgSettings(this.db.db, binding.orgId);
137
- if (settings.gitGateway?.enabled === false)
138
- return refuse("gateway off for the org");
139
- return binding;
114
+ // The binding is issued by the kernel. Re-check its run and membership under that org's scope.
115
+ return withOrgScope(binding.orgId, async () => {
116
+ const run = await this.db
117
+ .selectFrom("runs")
118
+ .innerJoin("conversations", "conversations.id", "runs.conversation_id")
119
+ .innerJoin("orgs", "orgs.id", "conversations.org_id")
120
+ .select("runs.status")
121
+ .where("runs.id", "=", binding.runId)
122
+ .where("conversations.org_id", "=", binding.orgId)
123
+ .where("orgs.deleted_at", "is", null)
124
+ .executeTakeFirst();
125
+ if (run === undefined)
126
+ return refuse("run not in org");
127
+ if (!ACTIVE_RUN_STATUSES.includes(run.status)) {
128
+ return refuse("run not active");
129
+ }
130
+ const member = await this.db
131
+ .selectFrom("memberships")
132
+ .innerJoin("accounts", "accounts.id", "memberships.account_id")
133
+ .select("memberships.account_id")
134
+ .where("memberships.org_id", "=", binding.orgId)
135
+ .where("memberships.account_id", "=", binding.accountId)
136
+ .where("accounts.status", "=", "active")
137
+ .executeTakeFirst();
138
+ if (member === undefined)
139
+ return refuse("not an active member");
140
+ const settings = await readOrgSettings(this.db.db, binding.orgId);
141
+ if (settings.gitGateway?.enabled === false)
142
+ return refuse("gateway off for the org");
143
+ return binding;
144
+ });
140
145
  }
141
146
  /**
142
147
  * Deletes every ticket of the run (run end, abort, offboarding) in one Lua script, so a ticket
package/dist/http/app.js CHANGED
@@ -7,7 +7,7 @@ import { ApiTokenService } from "../identity/api-tokens.js";
7
7
  import { authenticateOrgUploader, authorizeSuperAdmin, } from "../identity/auth.guard.js";
8
8
  import { SessionService } from "../identity/sessions.js";
9
9
  import { KernelDb } from "../infra/database/kernel-db.js";
10
- import { withRequestScopeSlot } from "../infra/database/org-scope.js";
10
+ import { withOrgScope, withRequestScopeSlot } from "../infra/database/org-scope.js";
11
11
  import { withLogContext } from "../log-context.js";
12
12
  import { authorizeOrgAction } from "../orgs/org.guard.js";
13
13
  import { redactPath } from "./error.filter.js";
@@ -158,8 +158,10 @@ export async function createHttpApp(opts, app) {
158
158
  // the org admin role before the body (ruling P3-29): no one else makes the kernel buffer
159
159
  // a package-sized body
160
160
  const principal = await authenticateOrgUploader(req, services());
161
- const orgId = req.params.orgId ?? "";
162
- await authorizeOrgAction(app.get(KernelDb, { strict: false }).db, principal, orgId, "catalog.upload");
161
+ const orgId = req.params.orgId;
162
+ if (!orgId)
163
+ throw new ApiError("org.not_found", "Organization not found");
164
+ await withOrgScope(orgId, () => authorizeOrgAction(app.get(KernelDb, { strict: false }).db, principal, orgId, "catalog.upload"));
163
165
  }
164
166
  catch (e) {
165
167
  return sendError(reply, e, req.method, req.url);
@@ -3,6 +3,7 @@ import { SetupLock } from "../admin/setup-lock.js";
3
3
  import type { AccountsTable } 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 { OutboxService } from "../infra/outbox/outbox.service.js";
6
7
  import { PermissionCeilingWrites } from "../sandbox/permission-ceiling-writes.js";
7
8
  import { type AccountAvatar, type AccountView } from "./account-avatar.js";
8
9
  import type { Preferences } from "./me.schemas.js";
@@ -73,7 +74,11 @@ export declare class AccountsService {
73
74
  private readonly adminLock;
74
75
  private readonly setupLock;
75
76
  private readonly ceilings;
76
- constructor(db: KernelDb, txHost: TransactionHost, adminLock: SuperAdminLock, setupLock: SetupLock, ceilings: PermissionCeilingWrites);
77
+ /** The owed stops of a disabled account's host services. */
78
+ private readonly outbox;
79
+ constructor(db: KernelDb, txHost: TransactionHost, adminLock: SuperAdminLock, setupLock: SetupLock, ceilings: PermissionCeilingWrites,
80
+ /** The owed stops of a disabled account's host services. */
81
+ outbox: Pick<OutboxService, "add">);
77
82
  /** Checks the password length and hashes it (scrypt, slow): for callers that hash before their transaction opens. */
78
83
  hashNewPassword(password: string): Promise<string>;
79
84
  /**
@@ -11,11 +11,13 @@ import { randomUUID } from "node:crypto";
11
11
  import { Inject, Injectable, Module } from "@nestjs/common";
12
12
  import { sql } from "kysely";
13
13
  import { SetupLock, SetupLockModule } from "../admin/setup-lock.js";
14
+ import { oweHostServicesStopOfAccount } from "../device-access/host-service-stop.js";
14
15
  import { ApiError } from "../errors.js";
15
16
  import { KernelDb } from "../infra/database/kernel-db.js";
16
17
  import { asPlatform } from "../infra/database/org-scope.js";
17
18
  import { TransactionHost, withOrderedLocks } from "../infra/database/transaction-host.js";
18
19
  import { Transactional } from "../infra/database/transactional.decorator.js";
20
+ import { OutboxService } from "../infra/outbox/outbox.service.js";
19
21
  import { deletePushRegistrationsForSessions } from "../push/registration-cleanup.js";
20
22
  import { PermissionCeilingWritesModule } from "../sandbox/permission-authority.module.js";
21
23
  import { PermissionCeilingWrites } from "../sandbox/permission-ceiling-writes.js";
@@ -86,12 +88,16 @@ let AccountsService = class AccountsService {
86
88
  adminLock;
87
89
  setupLock;
88
90
  ceilings;
89
- constructor(db, txHost, adminLock, setupLock, ceilings) {
91
+ outbox;
92
+ constructor(db, txHost, adminLock, setupLock, ceilings,
93
+ /** The owed stops of a disabled account's host services. */
94
+ outbox) {
90
95
  this.db = db;
91
96
  this.txHost = txHost;
92
97
  this.adminLock = adminLock;
93
98
  this.setupLock = setupLock;
94
99
  this.ceilings = ceilings;
100
+ this.outbox = outbox;
95
101
  }
96
102
  /** Checks the password length and hashes it (scrypt, slow): for callers that hash before their transaction opens. */
97
103
  async hashNewPassword(password) {
@@ -644,6 +650,8 @@ let AccountsService = class AccountsService {
644
650
  revokedSessionIds = sessions.map((r) => r.id);
645
651
  // a registration follows its session (push plan decision 3): a disabled account loses all
646
652
  await deletePushRegistrationsForSessions(this.db.db, revokedSessionIds);
653
+ // its host services stop on every machine of theirs (local agents spec, call 5)
654
+ await oweHostServicesStopOfAccount(this.db.db, this.outbox, id);
647
655
  }
648
656
  return { account: toAccount(row), revokedSessionIds };
649
657
  }
@@ -687,7 +695,8 @@ AccountsService = __decorate([
687
695
  __param(1, Inject(TransactionHost)),
688
696
  __param(2, Inject(SuperAdminLock)),
689
697
  __param(3, Inject(SetupLock)),
690
- __param(4, Inject(PermissionCeilingWrites))
698
+ __param(4, Inject(PermissionCeilingWrites)),
699
+ __param(5, Inject(OutboxService))
691
700
  ], AccountsService);
692
701
  export { AccountsService };
693
702
  /**