@capybara-hq/kernel 0.1.0-rc.132 → 0.1.0-rc.134

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 (173) 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/automations/events/trigger-events.service.d.ts +13 -1
  11. package/dist/automations/events/trigger-events.service.js +27 -14
  12. package/dist/catalog/catalog.service.d.ts +2 -0
  13. package/dist/catalog/catalog.service.js +28 -5
  14. package/dist/catalog/marketplace-fetch.d.ts +2 -0
  15. package/dist/catalog/marketplace-fetch.js +15 -0
  16. package/dist/catalog/marketplaces.service.d.ts +4 -4
  17. package/dist/catalog/marketplaces.service.js +3 -2
  18. package/dist/catalog/owned-items.d.ts +2 -0
  19. package/dist/catalog/owned-items.js +30 -31
  20. package/dist/catalog/ownership.js +40 -38
  21. package/dist/catalog/plugin-import.d.ts +3 -4
  22. package/dist/catalog/plugin-import.js +50 -1
  23. package/dist/catalog/plugin-upgrade.d.ts +8 -0
  24. package/dist/catalog/plugin-upgrade.js +95 -7
  25. package/dist/catalog/publisher-policy.d.ts +9 -0
  26. package/dist/catalog/publisher-policy.js +12 -0
  27. package/dist/catalog/unshare.js +66 -58
  28. package/dist/client/client-access.service.js +5 -3
  29. package/dist/config/schema.d.ts +1 -0
  30. package/dist/config/schema.js +8 -1
  31. package/dist/conversations/conversations.controller.js +4 -14
  32. package/dist/conversations/conversations.service.d.ts +14 -0
  33. package/dist/conversations/conversations.service.js +20 -2
  34. package/dist/ctx/create-ctx.d.ts +15 -2
  35. package/dist/ctx/create-ctx.js +195 -79
  36. package/dist/ctx/durable-cancellation.d.ts +3 -0
  37. package/dist/ctx/durable-cancellation.js +8 -0
  38. package/dist/ctx/durable-effects.service.d.ts +81 -0
  39. package/dist/ctx/durable-effects.service.js +316 -0
  40. package/dist/ctx/durable-envelope.d.ts +24 -0
  41. package/dist/ctx/durable-envelope.js +80 -0
  42. package/dist/ctx/durable-failure.d.ts +7 -0
  43. package/dist/ctx/durable-failure.js +32 -0
  44. package/dist/ctx/durable-job.d.ts +9 -0
  45. package/dist/ctx/durable-job.js +2 -0
  46. package/dist/ctx/durable-keys.d.ts +27 -0
  47. package/dist/ctx/durable-keys.js +138 -0
  48. package/dist/ctx/durable-relay.d.ts +29 -0
  49. package/dist/ctx/durable-relay.js +250 -0
  50. package/dist/ctx/queue.d.ts +2 -0
  51. package/dist/ctx/queue.js +25 -15
  52. package/dist/db/extension-db.js +2 -0
  53. package/dist/db/extension-handoff-schema.d.ts +6 -0
  54. package/dist/db/extension-handoff-schema.js +72 -0
  55. package/dist/db/extension-rls-predicate.d.ts +1 -0
  56. package/dist/db/extension-rls-predicate.js +8 -0
  57. package/dist/db/extension-schema-transfer.d.ts +1 -1
  58. package/dist/db/extension-schema-transfer.js +18 -6
  59. package/dist/db/kernel-schema.d.ts +64 -0
  60. package/dist/db/migrator.js +6 -13
  61. package/dist/db/pool.d.ts +2 -2
  62. package/dist/db/pool.js +2 -2
  63. package/dist/db/sql-statements.d.ts +3 -0
  64. package/dist/db/sql-statements.js +15 -5
  65. package/dist/device-access/device-access.module.js +12 -2
  66. package/dist/device-access/device-access.service.d.ts +30 -2
  67. package/dist/device-access/device-access.service.js +38 -4
  68. package/dist/device-access/host-gate.d.ts +45 -0
  69. package/dist/device-access/host-gate.js +92 -0
  70. package/dist/device-access/host-service-stop-sweep.d.ts +33 -0
  71. package/dist/device-access/host-service-stop-sweep.js +112 -0
  72. package/dist/device-access/host-service-stop.d.ts +78 -0
  73. package/dist/device-access/host-service-stop.js +144 -0
  74. package/dist/device-access/host-services.d.ts +211 -0
  75. package/dist/device-access/host-services.js +803 -0
  76. package/dist/device-access/person-handles.d.ts +10 -0
  77. package/dist/device-access/person-handles.js +25 -0
  78. package/dist/device-access/service-events.d.ts +199 -0
  79. package/dist/device-access/service-events.js +704 -0
  80. package/dist/device-access/token.d.ts +5 -0
  81. package/dist/device-access/token.js +5 -0
  82. package/dist/devices/devices.service.js +3 -0
  83. package/dist/dial-in/access.d.ts +5 -5
  84. package/dist/dial-in/access.js +19 -12
  85. package/dist/dial-in/gateway.js +6 -2
  86. package/dist/dial-in/machines.d.ts +9 -2
  87. package/dist/dial-in/machines.js +27 -4
  88. package/dist/erasure/device-cleanup.js +12 -0
  89. package/dist/erasure/org-catalog.js +2 -2
  90. package/dist/erasure/org-rules.js +10 -0
  91. package/dist/errors.d.ts +2 -0
  92. package/dist/errors.js +2 -0
  93. package/dist/extensions/admin-ops.js +8 -2
  94. package/dist/extensions/deployed-snapshots.d.ts +4 -1
  95. package/dist/extensions/deployed-snapshots.js +7 -2
  96. package/dist/extensions/extensions.module.js +10 -0
  97. package/dist/extensions/host.d.ts +12 -2
  98. package/dist/extensions/host.js +44 -22
  99. package/dist/extensions/instance.d.ts +5 -0
  100. package/dist/extensions/instance.js +10 -0
  101. package/dist/extensions/ledger.d.ts +1 -1
  102. package/dist/extensions/lifecycle-hooks.js +3 -3
  103. package/dist/extensions/org-config.js +6 -1
  104. package/dist/extensions/permission-set.d.ts +7 -0
  105. package/dist/extensions/permission-set.js +10 -0
  106. package/dist/extensions/permission-view.d.ts +1 -1
  107. package/dist/extensions/permission-view.js +10 -1
  108. package/dist/extensions/sources.d.ts +1 -0
  109. package/dist/extensions/sources.js +9 -0
  110. package/dist/git/tickets.js +32 -27
  111. package/dist/http/app.js +5 -3
  112. package/dist/identity/accounts.d.ts +6 -1
  113. package/dist/identity/accounts.js +11 -2
  114. package/dist/identity/api-tokens.js +7 -6
  115. package/dist/identity/settings.d.ts +9 -1
  116. package/dist/identity/settings.js +16 -1
  117. package/dist/inbox/inbox-items.service.d.ts +5 -0
  118. package/dist/inbox/inbox-items.service.js +57 -33
  119. package/dist/inbox/org-notices.js +3 -2
  120. package/dist/index.d.ts +1 -0
  121. package/dist/index.js +1 -0
  122. package/dist/infra/database/extension-effect-key-lock.d.ts +10 -0
  123. package/dist/infra/database/extension-effect-key-lock.js +69 -0
  124. package/dist/infra/database/extension-handoff.d.ts +27 -0
  125. package/dist/infra/database/extension-handoff.js +113 -0
  126. package/dist/infra/database/scoped-dialect.d.ts +3 -2
  127. package/dist/infra/database/scoped-dialect.js +260 -72
  128. package/dist/infra/database/startup-activation-transaction.d.ts +2 -0
  129. package/dist/infra/database/startup-activation-transaction.js +3 -2
  130. package/dist/infra/outbox/outbox.dispatcher.d.ts +6 -1
  131. package/dist/infra/outbox/outbox.dispatcher.js +64 -4
  132. package/dist/infra/outbox/outbox.module.js +2 -0
  133. package/dist/infra/outbox/registry.d.ts +40 -0
  134. package/dist/infra/outbox/registry.js +42 -0
  135. package/dist/infra/queue/queue-names.d.ts +1 -1
  136. package/dist/infra/queue/queue-names.js +1 -0
  137. package/dist/infra/queue/run-job.d.ts +4 -1
  138. package/dist/infra/queue/run-job.js +10 -2
  139. package/dist/kernel.js +1 -0
  140. package/dist/kernel.module.js +3 -0
  141. package/dist/orgs/offboarding.js +18 -9
  142. package/dist/orgs/orgs.service.js +16 -0
  143. package/dist/orgs/settings.service.js +3 -0
  144. package/dist/packages/npm-publish-keys.json +27 -0
  145. package/dist/packages/official-publisher.d.ts +19 -0
  146. package/dist/packages/official-publisher.js +152 -0
  147. package/dist/packages/provenance.d.ts +7 -0
  148. package/dist/packages/provenance.js +22 -19
  149. package/dist/packages/sigstore-trusted-root.json +126 -0
  150. package/dist/platform/ops/admin.ops.js +2 -1
  151. package/dist/platform/ops/orgs.ops.js +1 -0
  152. package/dist/roles/worker-role.d.ts +6 -3
  153. package/dist/roles/worker-role.js +12 -4
  154. package/dist/roles/worker.module.js +9 -0
  155. package/dist/runtime/maintenance.d.ts +5 -2
  156. package/dist/runtime/maintenance.js +18 -4
  157. package/dist/sandbox/device-reports.d.ts +4 -4
  158. package/dist/sandbox/device-reports.js +40 -30
  159. package/dist/sandbox/device-services.d.ts +2 -1
  160. package/dist/sandbox/device-services.js +5 -1
  161. package/dist/sandbox/permission-ceiling-writes.d.ts +8 -0
  162. package/dist/sandbox/permission-ceiling-writes.js +21 -0
  163. package/dist/sandbox/permission-config-publication.js +5 -1
  164. package/dist/themes/theme-state.js +24 -13
  165. package/dist/tools/call-scope.d.ts +6 -0
  166. package/dist/tools/call-scope.js +22 -0
  167. package/dist/tools/registry.js +20 -2
  168. package/dist/ui/views.js +36 -8
  169. package/package.json +9 -4
  170. package/src/migrations/0222_device_host_services.sql +27 -0
  171. package/src/migrations/0223_device_service_events.sql +54 -0
  172. package/src/migrations/0224_cache_conversation_rls_settings.sql +33 -0
  173. package/src/migrations/0225_extension_effect_receipts.sql +25 -0
@@ -16,6 +16,7 @@ import { STALE_RECONCILE_PERIODS } from "../extensions/lifecycle-topics.js";
16
16
  import { CLIENT_EXTENSIONS_SETTING, parseClientExtensions, readClientExtensions, } from "../identity/settings.js";
17
17
  import { KernelConfigService } from "../infra/config/kernel-config.service.js";
18
18
  import { KernelDb } from "../infra/database/kernel-db.js";
19
+ import { asPlatform } from "../infra/database/org-scope.js";
19
20
  import { KERNEL_LOGGER } from "../infra/tokens.js";
20
21
  import { StorageService } from "../storage/storage.service.js";
21
22
  import { canUseSlot } from "../ui/registry.js";
@@ -182,7 +183,7 @@ let ClientAccess = class ClientAccess {
182
183
  */
183
184
  async fetchable(accountId, superAdmin, plugin, build) {
184
185
  const db = this.db.db;
185
- const row = await this.served(db)
186
+ const query = this.served(db)
186
187
  .where("i.name", "=", plugin)
187
188
  .where("b.package_sha256", "=", build)
188
189
  .select((eb) => [
@@ -210,8 +211,9 @@ let ClientAccess = class ClientAccess {
210
211
  .where("c.enabled", "=", true)),
211
212
  ])))
212
213
  .as("member"),
213
- ])
214
- .executeTakeFirst();
214
+ ]);
215
+ // org-filter: deployment-wide bundle access uses the authenticated account's memberships.
216
+ const row = await asPlatform("Check bundle access across the account's organizations", () => query.executeTakeFirst());
215
217
  if (row === undefined)
216
218
  return null;
217
219
  const kill = parseClientExtensions(row.kill ?? undefined, this.log);
@@ -69,6 +69,7 @@ export declare const KernelConfigSchema: z.ZodObject<{
69
69
  url: z.ZodString;
70
70
  migrationUrl: z.ZodOptional<z.ZodString>;
71
71
  extensionsUrl: z.ZodOptional<z.ZodString>;
72
+ extensionEffectRelayLogin: z.ZodOptional<z.ZodString>;
72
73
  extensionPoolMax: z.ZodDefault<z.ZodNumber>;
73
74
  poolMax: z.ZodDefault<z.ZodNumber>;
74
75
  connectTimeoutMs: z.ZodDefault<z.ZodNumber>;
@@ -344,6 +344,13 @@ export const KernelConfigSchema = z.strictObject({
344
344
  secret: true,
345
345
  description: "PostgreSQL connection URL for the shared extension login",
346
346
  })),
347
+ extensionEffectRelayLogin: z
348
+ .string()
349
+ .min(1)
350
+ .optional()
351
+ .meta(meta({
352
+ description: "PostgreSQL runtime login granted access to extension handoffs by the one-shot schema transfer, default capybara_runtime",
353
+ })),
347
354
  extensionPoolMax: z
348
355
  .number()
349
356
  .int()
@@ -376,7 +383,7 @@ export const KernelConfigSchema = z.strictObject({
376
383
  .enum(["off", "scoped", "enforce"])
377
384
  .default("off")
378
385
  .meta(meta({
379
- description: "Row level security (RLS spec, issue #115): off sends nothing; scoped sets the caller's org scope on every PostgreSQL connection (one extra round trip per pool query and per transaction) while the policies admit every row; enforce makes the policies filter every org-scoped table by that scope once row level security is enabled on the tables (RLS spec phase 5; until then the kernel warns at start and nothing is filtered). Needs a session-capable connection (no PgBouncer transaction pooling) unless off; PostgreSQL applies no policy to a superuser or BYPASSRLS role",
386
+ description: "PostgreSQL row-level security mode where off leaves scope unset, scoped sets transaction-local scope while policies admit all rows, and enforce filters by transaction-local scope on tables with RLS enabled when the runtime login is subject to the policies. Both scoped modes require session-capable connections, with ordinary standalone queries sharing a round trip with their scope setup.",
380
387
  })),
381
388
  })
382
389
  .prefault({}),
@@ -351,13 +351,7 @@ let ConversationsController = class ConversationsController {
351
351
  }
352
352
  async get(principal, org, id) {
353
353
  const p = requireUser(principal);
354
- const conversation = await this.conversations.get(org.orgId, id, p.account.id);
355
- return {
356
- conversation: {
357
- ...conversation,
358
- owner: await this.conversations.person(conversation.accountId),
359
- },
360
- };
354
+ return { conversation: await this.conversations.getWithOwner(org.orgId, id, p.account.id) };
361
355
  }
362
356
  /**
363
357
  * Events in ascending seq. `after`: those after it (at most `limit`; the client passes the last
@@ -366,13 +360,9 @@ let ConversationsController = class ConversationsController {
366
360
  */
367
361
  async events(principal, org, id, q) {
368
362
  const p = requireUser(principal);
369
- if (q.before !== undefined) {
370
- const before = q.before === "end" ? null : q.before;
371
- const page = await this.conversations.listEventsBefore(org.orgId, id, p.account.id, before, q.limit);
372
- return { ...page, people: await this.conversations.eventPeople(page.events) };
373
- }
374
- const events = await this.conversations.listEvents(org.orgId, id, p.account.id, q.after ?? 0, q.limit);
375
- return { events, people: await this.conversations.eventPeople(events) };
363
+ return this.conversations.listEventsWithPeople(org.orgId, id, p.account.id, q.before !== undefined
364
+ ? { before: q.before === "end" ? null : q.before, limit: q.limit }
365
+ : { after: q.after ?? 0, limit: q.limit });
376
366
  }
377
367
  /**
378
368
  * The conversation's sub-agents, newest first (sub-agents spec §14.3): `{ subagents, next }`,
@@ -542,6 +542,9 @@ export declare class ConversationsService {
542
542
  private treeExpired;
543
543
  /** 读会话:非所有者、或 agent 已对所有者不可用 → `conversation.not_found`。 */
544
544
  get(orgId: string, conversationId: string, viewerAccountId: string): Promise<ConversationView>;
545
+ getWithOwner(orgId: string, conversationId: string, viewerAccountId: string): Promise<ConversationView & {
546
+ owner: PersonRef | null;
547
+ }>;
545
548
  /**
546
549
  * {@link get} for a change made by a person (a message, rename, queue, model switch): a
547
550
  * sub-agent's conversation is read-only (sub-agents spec §6.1) → `conversation.read_only`.
@@ -648,6 +651,17 @@ export declare class ConversationsService {
648
651
  events: ConversationEvent[];
649
652
  turnsBefore: number;
650
653
  }>;
654
+ listEventsWithPeople(orgId: string, conversationId: string, viewerAccountId: string, page: {
655
+ before: number | null;
656
+ limit: number;
657
+ } | {
658
+ after: number;
659
+ limit: number;
660
+ }): Promise<{
661
+ events: ConversationEvent[];
662
+ turnsBefore?: number;
663
+ people: Record<string, PersonRef>;
664
+ }>;
651
665
  /**
652
666
  * Appends a user message; a repeated send with the same `clientMessageId` returns the same
653
667
  * event. After the write it calls `ensureRun`: with no run in progress it enqueues one; during
@@ -778,6 +778,10 @@ let ConversationsService = class ConversationsService {
778
778
  const { kind: _kind, ...row } = await this.readable(orgId, conversationId, viewerAccountId);
779
779
  return toView(row);
780
780
  }
781
+ async getWithOwner(orgId, conversationId, viewerAccountId) {
782
+ const conversation = await this.get(orgId, conversationId, viewerAccountId);
783
+ return { ...conversation, owner: await this.person(conversation.accountId) };
784
+ }
781
785
  /**
782
786
  * {@link get} for a change made by a person (a message, rename, queue, model switch): a
783
787
  * sub-agent's conversation is read-only (sub-agents spec §6.1) → `conversation.read_only`.
@@ -837,8 +841,8 @@ let ConversationsService = class ConversationsService {
837
841
  .$if(opts.total === true, (qb) => qb.select(sql `count(*) OVER ()`.as("total_count")))
838
842
  .where("org_id", "=", orgId)
839
843
  .where("account_id", "=", accountId)
840
- // 评测回放的隐藏对话(kind = 'eval')不在「我的对话」里
841
- .where("kind", "=", "chat")
844
+ // Keep the fixed kind literal so generic plans can use the partial chat index.
845
+ .where("kind", "=", sql.lit("chat"))
842
846
  .where("deleted_at", "is", null)
843
847
  .where("archived_at", opts.archived === true ? "is not" : "is", null)
844
848
  .where((eb) => eb.exists(eb
@@ -1151,6 +1155,14 @@ let ConversationsService = class ConversationsService {
1151
1155
  await this.get(orgId, conversationId, viewerAccountId);
1152
1156
  return this.eventLog.readTurnPageBefore(conversationId, beforeSeq, limit, EVENTS_TURN_EXTEND);
1153
1157
  }
1158
+ async listEventsWithPeople(orgId, conversationId, viewerAccountId, page) {
1159
+ const result = "before" in page
1160
+ ? await this.listEventsBefore(orgId, conversationId, viewerAccountId, page.before, page.limit)
1161
+ : {
1162
+ events: await this.listEvents(orgId, conversationId, viewerAccountId, page.after, page.limit),
1163
+ };
1164
+ return { ...result, people: await this.eventPeople(result.events) };
1165
+ }
1154
1166
  /**
1155
1167
  * Appends a user message; a repeated send with the same `clientMessageId` returns the same
1156
1168
  * event. After the write it calls `ensureRun`: with no run in progress it enqueues one; during
@@ -1976,6 +1988,12 @@ __decorate([
1976
1988
  __decorate([
1977
1989
  Transactional()
1978
1990
  ], ConversationsService.prototype, "markDeleted", null);
1991
+ __decorate([
1992
+ Transactional({ accessMode: "read only" })
1993
+ ], ConversationsService.prototype, "getWithOwner", null);
1994
+ __decorate([
1995
+ Transactional({ accessMode: "read only" })
1996
+ ], ConversationsService.prototype, "listEventsWithPeople", null);
1979
1997
  __decorate([
1980
1998
  Transactional({ propagation: "requires_new" })
1981
1999
  ], ConversationsService.prototype, "postIn", null);
@@ -4,6 +4,7 @@ import { Kysely } from "kysely";
4
4
  import type { TriggerEventsService } from "../automations/events/trigger-events.service.js";
5
5
  import { pluginSchemaName } from "../db/extension-db.js";
6
6
  import type { DeviceAccessService } from "../device-access/device-access.service.js";
7
+ import type { ServiceEventHandler, ServiceEventsBackend } from "../device-access/service-events.js";
7
8
  import type { DialInAccess } from "../dial-in/access.js";
8
9
  import { type RegisteredHook } from "../extensions/hooks.js";
9
10
  import { RegistrationLedger } from "../extensions/ledger.js";
@@ -19,6 +20,7 @@ import type { ShareLiveness } from "../shares/liveness.js";
19
20
  import type { EmbedTokens } from "../ui/embed-token.js";
20
21
  import { type UiActionHandler, type UiQueryHandler, type UiRender } from "../ui/registry.js";
21
22
  import { type BusSubscriber } from "./bus.js";
23
+ import { type ExtensionEffects } from "./durable-effects.service.js";
22
24
  import { type ExtensionNetServices } from "./net.js";
23
25
  import { type Keyring } from "./secrets.js";
24
26
  export { pluginSchemaName };
@@ -68,7 +70,7 @@ export interface KernelDeps {
68
70
  * served by the calling extension. Absent (a ctx built alone in a test): `ctx.dialIn` calls
69
71
  * reject.
70
72
  */
71
- dialIn?: Pick<DialInAccess, "serves" | "request" | "online" | "capacity" | "stop" | "openStream">;
73
+ dialIn?: Pick<DialInAccess, "servedOrg" | "request" | "online" | "capacity" | "stop" | "openStream">;
72
74
  /**
73
75
  * What `ctx.devices` is built from (`DeviceReports`): `changed` reads a device's report again
74
76
  * from the calling provider and refuses (`not-served`) a device bound to another one. Absent
@@ -81,6 +83,12 @@ export interface KernelDeps {
81
83
  * a test, the CLI): `ctx.deviceAccess` calls are refused.
82
84
  */
83
85
  deviceAccess?: () => DeviceAccessBackend | undefined;
86
+ /**
87
+ * What `ctx.devices.serviceEvent` calls through (`ServiceEvents`), found at the time of use like
88
+ * `deviceAccess`. Absent, or resolving to undefined (a ctx built alone in a test, the CLI):
89
+ * `ctx.devices.serviceEvent` rejects.
90
+ */
91
+ serviceEvents?: () => ServiceEventsBackend | undefined;
84
92
  /**
85
93
  * What `ctx.triggers` calls through (`TriggerEventsService`), found at the time of use like
86
94
  * `deviceAccess`. Absent, or resolving to undefined (a ctx built alone in a test, the CLI):
@@ -93,6 +101,7 @@ export interface KernelDeps {
93
101
  * `ctx.inbox` calls reject.
94
102
  */
95
103
  inbox?: () => InboxBackend | undefined;
104
+ durableEffects?: () => Pick<ExtensionEffects, "commit" | "prepare"> | undefined;
96
105
  /**
97
106
  * What `ctx.agents`, `ctx.conversations` and `ctx.people` call through (`PluginReadsService`),
98
107
  * found at the time of use like `inbox`. Absent, or resolving to undefined: those calls reject.
@@ -105,7 +114,7 @@ export interface KernelDeps {
105
114
  };
106
115
  }
107
116
  /** What `ctx.deviceAccess` calls through (`DeviceAccessService`). */
108
- export type DeviceAccessBackend = Pick<DeviceAccessService, "ensureService" | "request" | "reportBlockedHosts" | "requestSiteAccess" | "siteGrants" | "revokeSiteGrant" | "streamTicket" | "addNetworkHosts" | "answerHandoff" | "grantLoopbackPort" | "revokeLoopbackPort" | "loopbackPorts">;
117
+ export type DeviceAccessBackend = Pick<DeviceAccessService, "ensureService" | "request" | "reportBlockedHosts" | "requestSiteAccess" | "siteGrants" | "revokeSiteGrant" | "streamTicket" | "addNetworkHosts" | "answerHandoff" | "grantLoopbackPort" | "revokeLoopbackPort" | "loopbackPorts" | "ensureHostService" | "hostRequest" | "stopHostService" | "personalDevices">;
109
118
  /** What `ctx.triggers` calls through (`TriggerEventsService`). */
110
119
  export type TriggersBackend = Pick<TriggerEventsService, "emit" | "causeOf">;
111
120
  /** What `ctx.inbox` calls through (`InboxItemsService`). */
@@ -192,6 +201,8 @@ export type UiResolution = ReturnType<typeof resolveUiSlots>;
192
201
  export type KernelExtensionContext = ExtensionContext & {
193
202
  /** 本实例的登记账(C17):每次登记记一笔,撤销时逐项撤销。 */
194
203
  ledger: RegistrationLedger;
204
+ hasEffectQueue(name: string): boolean;
205
+ dispatchEffectQueue(name: string, data: unknown, jobId: string, delayMs?: number): Promise<void>;
195
206
  /**
196
207
  * 撤销第一步:停止取新的队列任务;`deadline`(epoch 毫秒)之后撤销队列 worker 时不再等进行中的任务。
197
208
  */
@@ -216,6 +227,8 @@ export type KernelExtensionContext = ExtensionContext & {
216
227
  uiQueries: ReadonlyMap<string, UiQueryHandler>;
217
228
  /** Setup checks registered through `ctx.setup.check`, by id. */
218
229
  setupChecks: ReadonlyMap<string, RegisteredSetupCheck>;
230
+ /** Handlers registered through `ctx.deviceAccess.onServiceEvent`, by host service name. */
231
+ serviceEventHandlers: ReadonlyMap<string, ServiceEventHandler>;
219
232
  /**
220
233
  * setup 结束后调用:此后 `tools.register`、`ui.view`、`ui.action`、`hooks.on`、`setup.check` 抛错。
221
234
  */