@capybara-hq/kernel 0.1.0-rc.60 → 0.1.0-rc.61

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 (98) hide show
  1. package/dist/admin/admin.module.js +3 -0
  2. package/dist/admin/extensions.controller.d.ts +32 -1
  3. package/dist/admin/extensions.controller.js +72 -3
  4. package/dist/admin/health.service.d.ts +2 -2
  5. package/dist/admin/health.service.js +6 -2
  6. package/dist/catalog/marketplaces.service.d.ts +1 -1
  7. package/dist/config/schema.d.ts +6 -0
  8. package/dist/config/schema.js +12 -0
  9. package/dist/conversations/event-log.d.ts +12 -3
  10. package/dist/conversations/event-log.js +17 -5
  11. package/dist/ctx/secrets.d.ts +10 -5
  12. package/dist/ctx/secrets.js +16 -5
  13. package/dist/db/kernel-schema.d.ts +34 -2
  14. package/dist/errors.d.ts +7 -0
  15. package/dist/errors.js +7 -0
  16. package/dist/extensions/config-hash.d.ts +2 -0
  17. package/dist/extensions/config-hash.js +1 -1
  18. package/dist/extensions/guide-places.d.ts +5 -1
  19. package/dist/extensions/guide-places.js +9 -2
  20. package/dist/extensions/permission-view.d.ts +6 -4
  21. package/dist/extensions/permission-view.js +6 -3
  22. package/dist/extensions/plugin-guides.d.ts +20 -0
  23. package/dist/extensions/plugin-guides.js +49 -1
  24. package/dist/extensions/registry.js +1 -0
  25. package/dist/http/api.module.js +7 -0
  26. package/dist/http/meta.controller.d.ts +7 -1
  27. package/dist/http/meta.controller.js +14 -3
  28. package/dist/identity/accounts.js +5 -0
  29. package/dist/identity/sessions.d.ts +7 -0
  30. package/dist/identity/sessions.js +26 -4
  31. package/dist/inbox/platform-inbox.service.d.ts +21 -11
  32. package/dist/inbox/platform-inbox.service.js +27 -12
  33. package/dist/inbox/platform-notices.d.ts +15 -1
  34. package/dist/inbox/platform-notices.js +20 -0
  35. package/dist/infra/config/kernel-config.service.js +2 -0
  36. package/dist/infra/outbox/registry.d.ts +36 -0
  37. package/dist/infra/outbox/registry.js +30 -0
  38. package/dist/infra/queue/queue-names.d.ts +1 -1
  39. package/dist/infra/queue/queue-names.js +1 -0
  40. package/dist/orgs/offboarding.js +3 -0
  41. package/dist/overrides.d.ts +4 -0
  42. package/dist/overrides.js +2 -0
  43. package/dist/platform/exclusions.js +15 -0
  44. package/dist/platform/ops/extensions-admin.ops.d.ts +5 -1
  45. package/dist/platform/ops/extensions-admin.ops.js +97 -2
  46. package/dist/platform/ops/inbox.ops.d.ts +1 -1
  47. package/dist/platform/ops/inbox.ops.js +17 -7
  48. package/dist/platform/ops/platform.ops.d.ts +4 -2
  49. package/dist/platform/ops/platform.ops.js +55 -3
  50. package/dist/platform/platform-ops.module.js +2 -0
  51. package/dist/platform/route-schemas.js +3 -0
  52. package/dist/push/delivery.d.ts +88 -0
  53. package/dist/push/delivery.js +269 -0
  54. package/dist/push/fanout.d.ts +29 -0
  55. package/dist/push/fanout.js +95 -0
  56. package/dist/push/jobs.d.ts +43 -0
  57. package/dist/push/jobs.js +19 -0
  58. package/dist/push/preferences.service.d.ts +18 -0
  59. package/dist/push/preferences.service.js +82 -0
  60. package/dist/push/provider-host.d.ts +34 -0
  61. package/dist/push/provider-host.js +94 -0
  62. package/dist/push/push-owed.d.ts +33 -0
  63. package/dist/push/push-owed.js +93 -0
  64. package/dist/push/push-processor.d.ts +40 -0
  65. package/dist/push/push-processor.js +114 -0
  66. package/dist/push/push.controller.d.ts +28 -0
  67. package/dist/push/push.controller.js +92 -0
  68. package/dist/push/push.module.d.ts +6 -0
  69. package/dist/push/push.module.js +29 -0
  70. package/dist/push/push.schemas.d.ts +88 -0
  71. package/dist/push/push.schemas.js +53 -0
  72. package/dist/push/recipients.d.ts +29 -0
  73. package/dist/push/recipients.js +263 -0
  74. package/dist/push/registration-cleanup.d.ts +9 -0
  75. package/dist/push/registration-cleanup.js +16 -0
  76. package/dist/push/registrations.service.d.ts +55 -0
  77. package/dist/push/registrations.service.js +254 -0
  78. package/dist/push/stale.job.d.ts +25 -0
  79. package/dist/push/stale.job.js +76 -0
  80. package/dist/push/texts.d.ts +31 -0
  81. package/dist/push/texts.js +46 -0
  82. package/dist/push/token-store.d.ts +31 -0
  83. package/dist/push/token-store.js +52 -0
  84. package/dist/push/triggers.d.ts +19 -0
  85. package/dist/push/triggers.js +30 -0
  86. package/dist/roles/worker-role.d.ts +7 -4
  87. package/dist/roles/worker-role.js +12 -5
  88. package/dist/roles/worker.module.d.ts +1 -1
  89. package/dist/roles/worker.module.js +4 -1
  90. package/dist/schedules/run-tracker.d.ts +10 -2
  91. package/dist/schedules/run-tracker.js +18 -4
  92. package/dist/setup/setup-checks.schemas.d.ts +29 -0
  93. package/dist/setup/setup-checks.schemas.js +32 -0
  94. package/dist/setup/setup-checks.service.d.ts +36 -3
  95. package/dist/setup/setup-checks.service.js +137 -29
  96. package/package.json +4 -4
  97. package/src/migrations/0172_push.sql +40 -0
  98. package/src/migrations/0173_push_auth_notice.sql +10 -0
@@ -377,6 +377,42 @@ export declare const OUTBOX_JOBS: {
377
377
  readonly removeOnFail: 1000;
378
378
  };
379
379
  };
380
+ readonly "push-fanout": {
381
+ readonly queue: "cap-push-deliver";
382
+ readonly idempotent: "Owes delivery jobs under deterministic ids; a repeat owes nothing new";
383
+ readonly processedIn: "packages/kernel/src/push/push-processor.ts";
384
+ readonly opts: {
385
+ readonly attempts: 5;
386
+ readonly backoff: {
387
+ readonly type: "exponential";
388
+ readonly delay: 5000;
389
+ };
390
+ readonly removeOnComplete: {
391
+ readonly age: 86400;
392
+ };
393
+ readonly removeOnFail: {
394
+ readonly age: 86400;
395
+ };
396
+ };
397
+ };
398
+ readonly "push-deliver": {
399
+ readonly queue: "cap-push-deliver";
400
+ readonly idempotent: "Completed jobs are kept a day under the deterministic id, so a repeated add is swallowed; a missing registration ends the job";
401
+ readonly processedIn: "packages/kernel/src/push/push-processor.ts";
402
+ readonly opts: {
403
+ readonly attempts: 5;
404
+ readonly backoff: {
405
+ readonly type: "exponential";
406
+ readonly delay: 10000;
407
+ };
408
+ readonly removeOnComplete: {
409
+ readonly age: 86400;
410
+ };
411
+ readonly removeOnFail: {
412
+ readonly age: 86400;
413
+ };
414
+ };
415
+ };
380
416
  readonly lifecycle: {
381
417
  readonly queue: "cap-kernel-lifecycle";
382
418
  readonly idempotent: "lifecycle handlers must be idempotent (the SDK contract): they delete what the plugin holds for the removed member, agent or org, and deleting it again is a no-op";
@@ -343,6 +343,36 @@ export const OUTBOX_JOBS = {
343
343
  removeOnFail: 1000,
344
344
  },
345
345
  },
346
+ // `push/jobs.ts` PUSH_FANOUT_JOB: one per trigger event, owed in the event's transaction by
347
+ // `PushOwed` under `pushFanoutJobId` (`push-fanout-<eventId>`, mobile app spec §9.4)
348
+ "push-fanout": {
349
+ queue: "cap-push-deliver",
350
+ idempotent: "Owes delivery jobs under deterministic ids; a repeat owes nothing new",
351
+ processedIn: "packages/kernel/src/push/push-processor.ts",
352
+ // 5 attempts, 5 s doubling (PG briefly unavailable); finished and failed jobs kept a day, so
353
+ // an add of the same id within it is swallowed
354
+ opts: {
355
+ attempts: 5,
356
+ backoff: { type: "exponential", delay: 5_000 },
357
+ removeOnComplete: { age: 86_400 },
358
+ removeOnFail: { age: 86_400 },
359
+ },
360
+ },
361
+ // `push/jobs.ts` PUSH_DELIVER_JOB: one per event and registration, owed by the push fanout
362
+ // under `pushDeliverJobId` (`push-<eventId>-<registrationId>`, mobile app spec §9.4)
363
+ "push-deliver": {
364
+ queue: "cap-push-deliver",
365
+ idempotent: "Completed jobs are kept a day under the deterministic id, so a repeated add is swallowed; a missing registration ends the job",
366
+ processedIn: "packages/kernel/src/push/push-processor.ts",
367
+ // 5 attempts, 10 s doubling (transient and rate_limited answers, timeouts); finished and
368
+ // failed jobs kept a day, so an add of the same id within it is swallowed
369
+ opts: {
370
+ attempts: 5,
371
+ backoff: { type: "exponential", delay: 10_000 },
372
+ removeOnComplete: { age: 86_400 },
373
+ removeOnFail: { age: 86_400 },
374
+ },
375
+ },
346
376
  // `extensions/lifecycle-hooks.ts` LIFECYCLE_JOB: owed by the transaction that removes a member,
347
377
  // deletes an agent or deletes an org, once per subscribing plugin, under `lifecycleJobId`
348
378
  // (memory plugin spec §6.3)
@@ -4,5 +4,5 @@
4
4
  * (admin/health.service.ts) lists the same names from the feature constants;
5
5
  * test/infra/queue-names.test.ts keeps the two equal.
6
6
  */
7
- export declare const KERNEL_QUEUES: readonly ["cap-kernel-runs", "cap-kernel-subagent-runs", "cap-kernel-channels", "cap-kernel-maintenance", "cap-kernel-plugin-scope", "cap-kernel-titles", "cap-kernel-suggestions", "cap-kernel-usage-report", "cap-kernel-evals", "cap-kernel-lifecycle"];
7
+ export declare const KERNEL_QUEUES: readonly ["cap-kernel-runs", "cap-kernel-subagent-runs", "cap-kernel-channels", "cap-kernel-maintenance", "cap-kernel-plugin-scope", "cap-kernel-titles", "cap-kernel-suggestions", "cap-kernel-usage-report", "cap-kernel-evals", "cap-kernel-lifecycle", "cap-push-deliver"];
8
8
  export type KernelQueueName = (typeof KERNEL_QUEUES)[number];
@@ -15,4 +15,5 @@ export const KERNEL_QUEUES = [
15
15
  "cap-kernel-usage-report",
16
16
  "cap-kernel-evals",
17
17
  "cap-kernel-lifecycle",
18
+ "cap-push-deliver",
18
19
  ];
@@ -24,6 +24,7 @@ import { TransactionHost } from "../infra/database/transaction-host.js";
24
24
  import { Transactional } from "../infra/database/transactional.decorator.js";
25
25
  import { OutboxService } from "../infra/outbox/outbox.service.js";
26
26
  import { KERNEL_LOGGER } from "../infra/tokens.js";
27
+ import { deletePushRegistrationsForSessions } from "../push/registration-cleanup.js";
27
28
  import { MAINTENANCE_QUEUE_NAME } from "../runtime/maintenance-queue.js";
28
29
  import { RunControl } from "../runtime/run-control.js";
29
30
  import { oweDeviceDestroy } from "../sandbox/jobs.js";
@@ -208,6 +209,8 @@ let Offboarding = class Offboarding {
208
209
  .returning("id")
209
210
  .execute()
210
211
  : [];
212
+ // a registration follows its session (push plan decision 3)
213
+ await deletePushRegistrationsForSessions(this.db.db, sessions.map((r) => r.id));
211
214
  // in this transaction (the approvals and questions services join it: `mandatory`)
212
215
  const credentials = await this.credentials.clearAccount(orgId, accountId);
213
216
  // only in the conversations locked above (one asked meanwhile elsewhere waits for its run's stop)
@@ -19,6 +19,7 @@ import { OUTBOX_FAST_PATH_SETTLED } from "./infra/outbox/outbox.module.js";
19
19
  import { PRESENCE_INTERVAL_MS } from "./infra/presence/replica-presence.js";
20
20
  import type { KernelQueueName } from "./infra/queue/queue-names.js";
21
21
  import { DEVICE_POLICY_AFTER_CALL } from "./local-devices/device-policy.service.js";
22
+ import { PUSH_SEND_TIMEOUT_MS } from "./push/delivery.js";
22
23
  import { PROJECT_KNOWLEDGE_TIMEOUT } from "./runtime/project/knowledge.service.js";
23
24
  import { LIST_MODELS_TIMEOUT } from "./runtime/providers.js";
24
25
  import { RUN_CONTEXT_CLOCK } from "./runtime/run-context.service.js";
@@ -61,6 +62,8 @@ import { EMBED_TOKEN_CLOCK } from "./ui/embed-token.js";
61
62
  * recorded (throwing stands for a crash between the call and the resolve transaction);
62
63
  * - `PROJECT_KNOWLEDGE_TIMEOUT`: the run-start read of a bound project's time limit, read at every
63
64
  * read (a test shortens it for one run);
65
+ * - `PUSH_SEND_TIMEOUT_MS`: one push send's time limit, read at every send (a test shortens it
66
+ * for a hanging provider);
64
67
  * - `PROMPT_SUGGESTION_TIMEOUT`: the prompt suggestion call's time limit, read at every call (a test
65
68
  * shortens it for one call);
66
69
  * - `PLUGIN_PUBLIC_WRITE_LIMIT`: a lower limit for unsafe methods on `public` extension routes;
@@ -100,6 +103,7 @@ interface KernelSeams {
100
103
  [SCOPE_ORG_CHUNK_SIZE]: number;
101
104
  [PROJECT_KNOWLEDGE_TIMEOUT]: () => number;
102
105
  [PROMPT_SUGGESTION_TIMEOUT]: () => number;
106
+ [PUSH_SEND_TIMEOUT_MS]: () => number;
103
107
  [PLUGIN_PUBLIC_WRITE_LIMIT]: number;
104
108
  [DEVICE_POLICY_AFTER_CALL]: (opId: string) => void;
105
109
  [EXTENSION_NET_SEAMS]: ExtensionNetSeams;
package/dist/overrides.js CHANGED
@@ -16,6 +16,7 @@ import { OUTBOX_DISPATCH_FAILS } from "./infra/outbox/outbox.dispatcher.js";
16
16
  import { OUTBOX_FAST_PATH_SETTLED } from "./infra/outbox/outbox.module.js";
17
17
  import { PRESENCE_INTERVAL_MS } from "./infra/presence/replica-presence.js";
18
18
  import { DEVICE_POLICY_AFTER_CALL } from "./local-devices/device-policy.service.js";
19
+ import { PUSH_SEND_TIMEOUT_MS } from "./push/delivery.js";
19
20
  import { PROJECT_KNOWLEDGE_TIMEOUT } from "./runtime/project/knowledge.service.js";
20
21
  import { LIST_MODELS_TIMEOUT } from "./runtime/providers.js";
21
22
  import { RUN_CONTEXT_CLOCK } from "./runtime/run-context.service.js";
@@ -55,6 +56,7 @@ const SEAM_TOKENS = [
55
56
  SCOPE_ORG_CHUNK_SIZE,
56
57
  PROJECT_KNOWLEDGE_TIMEOUT,
57
58
  PROMPT_SUGGESTION_TIMEOUT,
59
+ PUSH_SEND_TIMEOUT_MS,
58
60
  PLUGIN_PUBLIC_WRITE_LIMIT,
59
61
  DEVICE_POLICY_AFTER_CALL,
60
62
  EXTENSION_NET_SEAMS,
@@ -447,6 +447,21 @@ export const PLATFORM_EXCLUSIONS = [
447
447
  category: "human-only",
448
448
  reason: "Revokes a personal access token",
449
449
  },
450
+ {
451
+ route: "POST /api/v1/me/push-registrations",
452
+ category: "human-only",
453
+ reason: "Registers the person's own app install for push; a device action of the person's app",
454
+ },
455
+ {
456
+ route: "DELETE /api/v1/me/push-registrations/:id",
457
+ category: "human-only",
458
+ reason: "Removes one of the person's app installs from push (sign-out, profile removal, settings)",
459
+ },
460
+ {
461
+ route: "GET /api/v1/me/push-registrations",
462
+ category: "human-only",
463
+ reason: "Lists the person's own app installs that receive push, for the settings page",
464
+ },
450
465
  {
451
466
  route: "GET /api/v1/auth/sources",
452
467
  category: "internal",
@@ -4,8 +4,10 @@ import { ExtensionAdminOps } from "../../extensions/admin-ops.js";
4
4
  import { ExtensionAdmin } from "../../extensions/admin-view.js";
5
5
  import { type DeploymentConfigView, ExtensionDeploymentConfigService } from "../../extensions/deployment-config.js";
6
6
  import { ExtensionInstalls } from "../../extensions/installs.js";
7
+ import { PluginGuides } from "../../extensions/plugin-guides.js";
7
8
  import { KernelConfigService } from "../../infra/config/kernel-config.service.js";
8
9
  import { KernelDb } from "../../infra/database/kernel-db.js";
10
+ import { SetupChecksService } from "../../setup/setup-checks.service.js";
9
11
  import { type PersonFieldTarget } from "../person-fields.js";
10
12
  import { PlatformOperations } from "../registry.js";
11
13
  /**
@@ -33,7 +35,9 @@ export declare class ExtensionsAdminOperations implements OnModuleInit {
33
35
  private readonly catalog;
34
36
  private readonly deploymentConfigs;
35
37
  private readonly installs;
36
- constructor(registry: PlatformOperations, admin: ExtensionAdmin, ops: ExtensionAdminOps, config: KernelConfigService, kdb: KernelDb, catalog: CatalogService, deploymentConfigs: ExtensionDeploymentConfigService, installs: ExtensionInstalls);
38
+ private readonly guides;
39
+ private readonly checks;
40
+ constructor(registry: PlatformOperations, admin: ExtensionAdmin, ops: ExtensionAdminOps, config: KernelConfigService, kdb: KernelDb, catalog: CatalogService, deploymentConfigs: ExtensionDeploymentConfigService, installs: ExtensionInstalls, guides: Pick<PluginGuides, "deploymentGuides">, checks: Pick<SetupChecksService, "deploymentStates" | "deploymentRun">);
37
41
  /** The view of `name` for a precheck, or the refusal (unknown, startup-declared). */
38
42
  private viewFor;
39
43
  onModuleInit(): void;
@@ -16,10 +16,13 @@ import { ExtensionAdminOps } from "../../extensions/admin-ops.js";
16
16
  import { ExtensionAdmin } from "../../extensions/admin-view.js";
17
17
  import { ExtensionDeploymentConfigService, } from "../../extensions/deployment-config.js";
18
18
  import { ExtensionInstalls } from "../../extensions/installs.js";
19
+ import { PluginGuides } from "../../extensions/plugin-guides.js";
19
20
  import { SINGLE_PROVIDER_ENABLED, SINGLE_PROVIDER_REQUIRED, singleProviderMessage, } from "../../extensions/single-provider.js";
20
21
  import { unavailableReason } from "../../extensions/unavailable.js";
21
22
  import { KernelConfigService } from "../../infra/config/kernel-config.service.js";
22
23
  import { KernelDb } from "../../infra/database/kernel-db.js";
24
+ import { DeploymentCheckPathParams, DeploymentCheckRunBody, DeploymentGuidePathParams, DeploymentGuidesPathParams, DeploymentGuidesQuery, } from "../../setup/setup-checks.schemas.js";
25
+ import { SetupChecksService } from "../../setup/setup-checks.service.js";
23
26
  import { FileRefSchema } from "../file-ref.js";
24
27
  import { defineOperation } from "../operation.js";
25
28
  import { pathsTouched, personFieldParams, secretFieldsOf, } from "../person-fields.js";
@@ -143,7 +146,9 @@ let ExtensionsAdminOperations = class ExtensionsAdminOperations {
143
146
  catalog;
144
147
  deploymentConfigs;
145
148
  installs;
146
- constructor(registry, admin, ops, config, kdb, catalog, deploymentConfigs, installs) {
149
+ guides;
150
+ checks;
151
+ constructor(registry, admin, ops, config, kdb, catalog, deploymentConfigs, installs, guides, checks) {
147
152
  this.registry = registry;
148
153
  this.admin = admin;
149
154
  this.ops = ops;
@@ -152,6 +157,8 @@ let ExtensionsAdminOperations = class ExtensionsAdminOperations {
152
157
  this.catalog = catalog;
153
158
  this.deploymentConfigs = deploymentConfigs;
154
159
  this.installs = installs;
160
+ this.guides = guides;
161
+ this.checks = checks;
155
162
  }
156
163
  /** The view of `name` for a precheck, or the refusal (unknown, startup-declared). */
157
164
  async viewFor(name, orgId) {
@@ -606,6 +613,92 @@ let ExtensionsAdminOperations = class ExtensionsAdminOperations {
606
613
  return { config: view };
607
614
  },
608
615
  }),
616
+ defineOperation({
617
+ id: "extensions.platform-guides",
618
+ description: "Read an extension's platform setup guides (super admin): the guides it ships for its deployment config (for example a push provider's credentials), rendered with the steps and the checks as check rows (run them with extensions.platform-check). Secrets are never in a guide: the person types each one into the deployment config form in the admin console (Extensions → the extension), or on the confirmation card of extensions.platform-set-config. Empty when the extension ships none.",
619
+ input: DeploymentGuidesPathParams.extend(DeploymentGuidesQuery.shape).strict(),
620
+ example: { name: "push-apns" },
621
+ authz: { superAdmin: true },
622
+ mirrors: ["GET /api/v1/admin/extensions/:name/guides"],
623
+ confirm: "read",
624
+ errors: [
625
+ {
626
+ code: "extension.not_found",
627
+ next: "Check the extension name with extensions.platform-list.",
628
+ },
629
+ ],
630
+ run: async (input, ctx) => {
631
+ await assertExtensionNotOtherOrgs(this.kdb.db, input.name, ctx.orgId);
632
+ return { guides: await this.guides.deploymentGuides(input.name, input) };
633
+ },
634
+ handoff: (input) => ({
635
+ kind: "handoff",
636
+ title: {
637
+ zh: "在扩展页面填写部署配置",
638
+ en: "Fill in the deployment config on the extension page",
639
+ },
640
+ target: { type: "link", url: `/admin/extensions/${encodeURIComponent(input.name)}` },
641
+ }),
642
+ }),
643
+ defineOperation({
644
+ id: "extensions.platform-check-status",
645
+ description: "Read the cached state of every check of an extension's platform setup guide, by check id: ok, failing, unknown, running or not_run, with the reason and fix to show the person. Runs nothing; run a check with extensions.platform-check.",
646
+ input: DeploymentGuidePathParams.strict(),
647
+ example: { name: "push-apns", guideId: "apns-key" },
648
+ authz: { superAdmin: true },
649
+ mirrors: ["GET /api/v1/admin/extensions/:name/guides/:guideId/checks"],
650
+ confirm: "read",
651
+ errors: [
652
+ {
653
+ code: "extension.not_found",
654
+ next: "Check the extension name with extensions.platform-list.",
655
+ },
656
+ {
657
+ code: "catalog.guide_not_found",
658
+ next: "The extension has no platform setup guide with that id; list them with extensions.platform-guides.",
659
+ },
660
+ ],
661
+ run: async (input, ctx) => {
662
+ await assertExtensionNotOtherOrgs(this.kdb.db, input.name, ctx.orgId);
663
+ return {
664
+ results: await this.checks.deploymentStates(ctx.actorAccountId, input.name, input.guideId),
665
+ };
666
+ },
667
+ }),
668
+ defineOperation({
669
+ id: "extensions.platform-check",
670
+ description: "Run one check of an extension's platform setup guide against its deployment config and return its state: ok, failing (with a reason and a fix to explain), unknown, or running (try again in a moment). A fresh cached result is returned as is; force reruns it, at most once per 10 seconds per check. A check only reads; run it after the person says they saved the config. The result is shown to you: the kernel redacts exact matches of whole secret values of 8 characters or more, so a well-behaved check never echoes any part of a secret, and you never repeat a value that looks like one.",
671
+ input: DeploymentCheckPathParams.extend(DeploymentCheckRunBody.shape).strict(),
672
+ example: { name: "push-apns", guideId: "apns-key", checkId: "key-works" },
673
+ authz: { superAdmin: true },
674
+ mirrors: ["POST /api/v1/admin/extensions/:name/guides/:guideId/checks/:checkId/run"],
675
+ confirm: "read",
676
+ errors: [
677
+ {
678
+ code: "extension.not_found",
679
+ next: "Check the extension name with extensions.platform-list.",
680
+ },
681
+ {
682
+ code: "catalog.guide_not_found",
683
+ next: "The extension has no platform setup guide with that id; list them with extensions.platform-guides.",
684
+ },
685
+ {
686
+ code: "catalog.check_not_found",
687
+ next: "That check is not in the guide; read the check ids with extensions.platform-check-status.",
688
+ },
689
+ {
690
+ code: "rate_limited",
691
+ next: "This person ran 30 checks in the last minute; wait a minute before running another, and read the cached states with extensions.platform-check-status meanwhile.",
692
+ },
693
+ ],
694
+ run: async (input, ctx) => {
695
+ await assertExtensionNotOtherOrgs(this.kdb.db, input.name, ctx.orgId);
696
+ const { name, guideId, checkId, ...body } = input;
697
+ return {
698
+ result: await this.checks.deploymentRun(ctx.actorAccountId, name, guideId, checkId, body),
699
+ };
700
+ },
701
+ }),
609
702
  ]);
610
703
  }
611
704
  };
@@ -618,6 +711,8 @@ ExtensionsAdminOperations = __decorate([
618
711
  __param(4, Inject(KernelDb)),
619
712
  __param(5, Inject(CatalogService)),
620
713
  __param(6, Inject(ExtensionDeploymentConfigService)),
621
- __param(7, Inject(ExtensionInstalls))
714
+ __param(7, Inject(ExtensionInstalls)),
715
+ __param(8, Inject(PluginGuides)),
716
+ __param(9, Inject(SetupChecksService))
622
717
  ], ExtensionsAdminOperations);
623
718
  export { ExtensionsAdminOperations };
@@ -17,7 +17,7 @@ export declare class InboxOperations implements OnModuleInit {
17
17
  constructor(registry: PlatformOperations, inbox: InboxService, platformInbox: PlatformInboxService, kdb: KernelDb);
18
18
  /** The org's open notice `id` when the actor is an org admin (else null: not found). */
19
19
  private orgNotice;
20
- /** A platform notice by id (dismissed or not), or null. */
20
+ /** A platform notice's subject name by id (dismissed or not), or null. */
21
21
  private platformNotice;
22
22
  /** Org ids that own each of `itemIds` (platform items: absent). */
23
23
  private owners;
@@ -199,6 +199,14 @@ function platformRow(i) {
199
199
  summary: platformNoticeSummary(i.notice.detail),
200
200
  next: "Dismiss it with inbox.platform-dismiss-notice once read.",
201
201
  };
202
+ case "push_auth_failed":
203
+ return {
204
+ ...base,
205
+ name: i.notice.detail.plugin,
206
+ state: "open",
207
+ summary: `The push provider ${i.notice.detail.plugin} had its credentials refused on a delivery; pushes through it fail until its deployment config is fixed.`,
208
+ next: "Fix the extension's deployment config in the admin console, then dismiss it with inbox.platform-dismiss-notice.",
209
+ };
202
210
  }
203
211
  }
204
212
  /**
@@ -242,18 +250,20 @@ let InboxOperations = class InboxOperations {
242
250
  const base = { id: row.id, createdAt: row.created_at.toISOString() };
243
251
  return { ...base, kind: row.kind, detail: row.detail };
244
252
  }
245
- /** A platform notice by id (dismissed or not), or null. */
253
+ /** A platform notice's subject name by id (dismissed or not), or null. */
246
254
  async platformNotice(id) {
247
255
  if (!UUID_RE.test(id))
248
256
  return null;
249
257
  const row = await this.kdb.db
250
258
  .selectFrom("platform_notices")
251
- .select(["id", "detail"])
259
+ .select(["id", "kind", "detail"])
252
260
  .where("id", "=", id)
253
261
  .executeTakeFirst();
254
- return row === undefined
255
- ? null
256
- : row.detail;
262
+ if (row === undefined)
263
+ return null;
264
+ return row.kind === "push_auth_failed"
265
+ ? { name: row.detail.plugin }
266
+ : { name: row.detail.name };
257
267
  }
258
268
  /** Org ids that own each of `itemIds` (platform items: absent). */
259
269
  async owners(itemIds) {
@@ -368,7 +378,7 @@ let InboxOperations = class InboxOperations {
368
378
  }),
369
379
  defineOperation({
370
380
  id: "inbox.platform-dismiss-notice",
371
- description: "Dismiss a platform notice (super admin) for every super admin: the id of an ownership_transferred row from inbox.platform-list. Other platform inbox items go away when they are dealt with in the admin console.",
381
+ description: "Dismiss a platform notice (super admin) for every super admin: the id of an ownership_transferred or push_auth_failed row from inbox.platform-list. Other platform inbox items go away when they are dealt with in the admin console.",
372
382
  input: NoticeInput,
373
383
  example: NOTICE_EXAMPLE,
374
384
  authz: { superAdmin: true },
@@ -377,7 +387,7 @@ let InboxOperations = class InboxOperations {
377
387
  errors: [
378
388
  {
379
389
  code: "inbox.notice_not_found",
380
- next: "No platform notice has that id; list them with inbox.platform-list (ownership_transferred rows).",
390
+ next: "No platform notice has that id; list them with inbox.platform-list (ownership_transferred and push_auth_failed rows).",
381
391
  },
382
392
  ],
383
393
  precheck: async (input) => (await this.platformNotice(input.id)) === null ? NOT_FOUND : { ok: true },
@@ -4,13 +4,14 @@ import { AccountsService } from "../../identity/accounts.js";
4
4
  import { KernelConfigService } from "../../infra/config/kernel-config.service.js";
5
5
  import { KernelDb } from "../../infra/database/kernel-db.js";
6
6
  import { OrgSettingsService } from "../../orgs/settings.service.js";
7
+ import { PushPreferencesService } from "../../push/preferences.service.js";
7
8
  import { ThemesService } from "../../themes/themes.service.js";
8
9
  import { ToolRegistry } from "../../tools/registry.js";
9
10
  import { PlatformActor } from "../actor.js";
10
11
  import { PlatformOperations } from "../registry.js";
11
12
  /**
12
13
  * The `platform` domain: orientation and what this agent is (spec §7, synthetic), and the
13
- * person's own preferences (`/me/preferences`).
14
+ * person's own preferences (`/me/preferences`, `/me/push-preferences`).
14
15
  */
15
16
  export declare class PlatformOperationsProvider implements OnModuleInit {
16
17
  private readonly registry;
@@ -22,7 +23,8 @@ export declare class PlatformOperationsProvider implements OnModuleInit {
22
23
  private readonly themes;
23
24
  private readonly db;
24
25
  private readonly config;
25
- constructor(registry: PlatformOperations, actor: PlatformActor, agents: AgentsService, settings: OrgSettingsService, tools: ToolRegistry, accounts: AccountsService, themes: ThemesService, db: KernelDb, config: KernelConfigService);
26
+ private readonly push;
27
+ constructor(registry: PlatformOperations, actor: PlatformActor, agents: AgentsService, settings: OrgSettingsService, tools: ToolRegistry, accounts: AccountsService, themes: ThemesService, db: KernelDb, config: KernelConfigService, push: PushPreferencesService);
26
28
  /**
27
29
  * The skills in the agent's catalog now, by the names a run's catalog lists them, each with its
28
30
  * plugin (skills default-on spec §11): the resolver's result for this conversation, as the next
@@ -17,6 +17,8 @@ import { KernelConfigService } from "../../infra/config/kernel-config.service.js
17
17
  import { KernelDb } from "../../infra/database/kernel-db.js";
18
18
  import { can } from "../../orgs/roles.js";
19
19
  import { OrgSettingsService } from "../../orgs/settings.service.js";
20
+ import { PushPreferencesService } from "../../push/preferences.service.js";
21
+ import { PUSH_CATEGORIES, PushPreferencesPatchSchema, } from "../../push/push.schemas.js";
20
22
  import { effectiveDevicePolicy, readDeploymentDevicePolicy } from "../../sandbox/modes.js";
21
23
  import { resolveEffectiveSkills } from "../../skills/catalog.js";
22
24
  import { ThemesService } from "../../themes/themes.service.js";
@@ -42,9 +44,16 @@ const FAMILIES = [
42
44
  "Plugin and connector tools, named plugin__<plugin>__<tool> and mcp__<connector>__<tool>.",
43
45
  ];
44
46
  const EMPTY = z.object({}).strict();
47
+ /** The push categories as the notification settings name them (UI copy, zh and en). */
48
+ const PUSH_CATEGORY_NAMES = {
49
+ waiting: { zh: "等你处理", en: "Waiting for you" },
50
+ replies: { zh: "智能体回复", en: "Agent replies" },
51
+ tasks: { zh: "任务状态", en: "Task status" },
52
+ schedules: { zh: "定时任务", en: "Scheduled tasks" },
53
+ };
45
54
  /**
46
55
  * The `platform` domain: orientation and what this agent is (spec §7, synthetic), and the
47
- * person's own preferences (`/me/preferences`).
56
+ * person's own preferences (`/me/preferences`, `/me/push-preferences`).
48
57
  */
49
58
  let PlatformOperationsProvider = class PlatformOperationsProvider {
50
59
  registry;
@@ -56,7 +65,8 @@ let PlatformOperationsProvider = class PlatformOperationsProvider {
56
65
  themes;
57
66
  db;
58
67
  config;
59
- constructor(registry, actor, agents, settings, tools, accounts, themes, db, config) {
68
+ push;
69
+ constructor(registry, actor, agents, settings, tools, accounts, themes, db, config, push) {
60
70
  this.registry = registry;
61
71
  this.actor = actor;
62
72
  this.agents = agents;
@@ -66,6 +76,7 @@ let PlatformOperationsProvider = class PlatformOperationsProvider {
66
76
  this.themes = themes;
67
77
  this.db = db;
68
78
  this.config = config;
79
+ this.push = push;
69
80
  }
70
81
  /**
71
82
  * The skills in the agent's catalog now, by the names a run's catalog lists them, each with its
@@ -243,6 +254,46 @@ let PlatformOperationsProvider = class PlatformOperationsProvider {
243
254
  theme: input.theme,
244
255
  }),
245
256
  }),
257
+ defineOperation({
258
+ id: "platform.push-preferences",
259
+ description: "Read your own push notification switches for your mobile app: waiting (approvals, questions and connect requests waiting for you), replies (an agent's run in your conversation finished or failed), tasks (background tasks and sub-agents finished) and schedules (your scheduled task ran or failed). Each is true unless you switched it off; they apply in every org.",
260
+ input: EMPTY,
261
+ example: {},
262
+ // any signed-in person may call the route; every run's actor is a member of this org
263
+ authz: { orgAction: "agents.use" },
264
+ mirrors: ["GET /api/v1/me/push-preferences"],
265
+ confirm: "read",
266
+ run: async (_input, ctx) => this.push.get(ctx.actorAccountId),
267
+ }),
268
+ defineOperation({
269
+ id: "platform.set-push-preferences",
270
+ description: "Switch your own push notification categories on or off; give only the ones to change (waiting, replies, tasks, schedules: true or false), the others keep their values. They apply to every device of yours that receives push, in every org.",
271
+ input: PushPreferencesPatchSchema,
272
+ example: { replies: false },
273
+ authz: { orgAction: "agents.use" },
274
+ mirrors: ["PUT /api/v1/me/push-preferences"],
275
+ confirm: "personal",
276
+ errors: [
277
+ {
278
+ code: "validation_failed",
279
+ next: "Give at least one of waiting, replies, tasks, schedules, each true or false.",
280
+ },
281
+ ],
282
+ summary: async (input) => {
283
+ const zh = [];
284
+ const en = [];
285
+ for (const category of PUSH_CATEGORIES) {
286
+ const on = input[category];
287
+ if (on === undefined)
288
+ continue;
289
+ const name = PUSH_CATEGORY_NAMES[category];
290
+ zh.push(`${on ? "开启" : "关闭"}「${name.zh}」通知`);
291
+ en.push(`Turn ${on ? "on" : "off"} "${name.en}" notifications`);
292
+ }
293
+ return { zh: zh.join(";"), en: en.join("; ") };
294
+ },
295
+ run: async (input, ctx) => this.push.set(ctx.actorAccountId, input),
296
+ }),
246
297
  ]);
247
298
  }
248
299
  };
@@ -256,6 +307,7 @@ PlatformOperationsProvider = __decorate([
256
307
  __param(5, Inject(AccountsService)),
257
308
  __param(6, Inject(ThemesService)),
258
309
  __param(7, Inject(KernelDb)),
259
- __param(8, Inject(KernelConfigService))
310
+ __param(8, Inject(KernelConfigService)),
311
+ __param(9, Inject(PushPreferencesService))
260
312
  ], PlatformOperationsProvider);
261
313
  export { PlatformOperationsProvider };
@@ -20,6 +20,7 @@ import { IdentityModule } from "../identity/identity.module.js";
20
20
  import { InboxModule } from "../inbox/inbox.module.js";
21
21
  import { ModelsModule } from "../models/models.module.js";
22
22
  import { OrgsModule } from "../orgs/orgs.module.js";
23
+ import { PushModule } from "../push/push.module.js";
23
24
  import { ProvidersModule } from "../runtime/providers.js";
24
25
  import { SchedulesModule } from "../schedules/schedules.module.js";
25
26
  import { SetupModule } from "../setup/setup.module.js";
@@ -151,6 +152,7 @@ PlatformOpsModule = __decorate([
151
152
  SetupModule,
152
153
  SchedulesModule,
153
154
  SharesModule,
155
+ PushModule,
154
156
  ],
155
157
  providers: [...PLATFORM_OPERATION_PROVIDERS],
156
158
  })
@@ -25,6 +25,7 @@ import { ME_ROUTES } from "../identity/me.schemas.js";
25
25
  import { INBOX_ROUTES } from "../inbox/inbox.schemas.js";
26
26
  import { ORG_MODEL_ROUTES } from "../models/org-models.schemas.js";
27
27
  import { ORG_ROUTES, ORG_SETTINGS_ROUTES } from "../orgs/orgs.schemas.js";
28
+ import { PUSH_ROUTES } from "../push/push.schemas.js";
28
29
  import { SCHEDULE_ROUTES } from "../schedules/schedules.schemas.js";
29
30
  import { SETUP_CHECK_ROUTES } from "../setup/setup-checks.schemas.js";
30
31
  import { SETUP_GUIDE_ROUTES } from "../setup/setup-guides.schemas.js";
@@ -75,6 +76,8 @@ export const ROUTE_SCHEMAS = [
75
76
  ...DEVICE_ROUTES,
76
77
  // personal preferences (run context spec §3.4)
77
78
  ...ME_ROUTES,
79
+ // push preferences (mobile app spec §9.4)
80
+ ...PUSH_ROUTES,
78
81
  // themes (themes spec §9)
79
82
  ...THEME_ROUTES,
80
83
  // the platform icon (mobile layout spec §10.2.1)