@capybara-hq/kernel 0.1.0-rc.148 → 0.1.0-rc.149

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 (46) hide show
  1. package/bootstrap.json +29 -29
  2. package/dist/admin/extensions.controller.d.ts +26 -2
  3. package/dist/admin/extensions.controller.js +52 -3
  4. package/dist/admin/extensions.schemas.d.ts +4 -0
  5. package/dist/admin/extensions.schemas.js +6 -0
  6. package/dist/catalog/cli.d.ts +3 -2
  7. package/dist/catalog/cli.js +19 -3
  8. package/dist/catalog/marketplaces.service.d.ts +1 -1
  9. package/dist/channels/channels.module.js +3 -0
  10. package/dist/channels/connection-summary.d.ts +32 -0
  11. package/dist/channels/connection-summary.js +67 -0
  12. package/dist/db/kernel-schema.d.ts +27 -0
  13. package/dist/erasure/org-catalog.js +4 -2
  14. package/dist/erasure/org-rules.js +1 -0
  15. package/dist/extensions/admin-ops.js +1 -0
  16. package/dist/extensions/admin-view.d.ts +5 -0
  17. package/dist/extensions/admin-view.js +19 -2
  18. package/dist/extensions/config-json-schema.d.ts +10 -6
  19. package/dist/extensions/config-json-schema.js +12 -8
  20. package/dist/extensions/deployment-config-store.d.ts +2 -0
  21. package/dist/extensions/deployment-config.d.ts +1 -1
  22. package/dist/extensions/deployment-config.js +5 -2
  23. package/dist/extensions/enabled.d.ts +1 -0
  24. package/dist/extensions/grant-epoch.d.ts +11 -2
  25. package/dist/extensions/grant-epoch.js +26 -3
  26. package/dist/extensions/host.d.ts +3 -0
  27. package/dist/extensions/host.js +5 -2
  28. package/dist/extensions/org-overrides.js +1 -1
  29. package/dist/extensions/permission-view.d.ts +5 -0
  30. package/dist/net/private-endpoint-preflight.js +1 -1
  31. package/dist/orgs/directory-sync-state.d.ts +125 -0
  32. package/dist/orgs/directory-sync-state.js +259 -0
  33. package/dist/orgs/directory-sync.controller.d.ts +16 -3
  34. package/dist/orgs/directory-sync.controller.js +29 -5
  35. package/dist/orgs/directory-sync.d.ts +18 -7
  36. package/dist/orgs/directory-sync.js +238 -106
  37. package/dist/orgs/directory-sync.schemas.d.ts +26 -0
  38. package/dist/orgs/directory-sync.schemas.js +50 -0
  39. package/dist/orgs/orgs.module.js +3 -0
  40. package/dist/platform/ops/extensions-admin.ops.d.ts +5 -1
  41. package/dist/platform/ops/extensions-admin.ops.js +43 -3
  42. package/dist/platform/ops/extensions.ops.d.ts +3 -1
  43. package/dist/platform/ops/extensions.ops.js +19 -2
  44. package/dist/platform/route-schemas.js +3 -0
  45. package/package.json +2 -2
  46. package/src/migrations/0240_directory_sync_state.sql +34 -0
@@ -9,8 +9,9 @@ var __param = (this && this.__param) || function (paramIndex, decorator) {
9
9
  };
10
10
  import { Inject, Injectable } from "@nestjs/common";
11
11
  import { z } from "zod";
12
- import { AdminExtensionConfigBody, AdminExtensionNamePathParams, AdminExtensionOrgCountsQuery, EXTENSION_ORG_COUNT_PAGE_SIZE, } from "../../admin/extensions.schemas.js";
12
+ import { AdminExtensionChannelSummaryParams, AdminExtensionConfigBody, AdminExtensionNamePathParams, AdminExtensionOrgCountsQuery, EXTENSION_ORG_COUNT_PAGE_SIZE, } from "../../admin/extensions.schemas.js";
13
13
  import { CatalogService } from "../../catalog/catalog.service.js";
14
+ import { ChannelConnectionSummaries } from "../../channels/connection-summary.js";
14
15
  import { ApiError } from "../../errors.js";
15
16
  import { ExtensionAdminOps } from "../../extensions/admin-ops.js";
16
17
  import { ExtensionAdmin } from "../../extensions/admin-view.js";
@@ -22,6 +23,8 @@ import { unavailableReason } from "../../extensions/unavailable.js";
22
23
  import { LoginSourcesService } from "../../identity/login-sources.js";
23
24
  import { KernelConfigService } from "../../infra/config/kernel-config.service.js";
24
25
  import { KernelDb } from "../../infra/database/kernel-db.js";
26
+ import { AdminDirectoryOrgsParams, AdminDirectoryOrgsQuery, } from "../../orgs/directory-sync.schemas.js";
27
+ import { DirectorySyncStates } from "../../orgs/directory-sync-state.js";
25
28
  import { DeploymentCheckPathParams, DeploymentCheckRunBody, DeploymentGuidePathParams, DeploymentGuidesPathParams, DeploymentGuidesQuery, } from "../../setup/setup-checks.schemas.js";
26
29
  import { SetupChecksService } from "../../setup/setup-checks.service.js";
27
30
  import { FileRefSchema } from "../file-ref.js";
@@ -188,7 +191,9 @@ let ExtensionsAdminOperations = class ExtensionsAdminOperations {
188
191
  guides;
189
192
  checks;
190
193
  loginSources;
191
- constructor(registry, admin, ops, config, kdb, catalog, deploymentConfigs, installs, guides, checks, loginSources) {
194
+ directoryStates;
195
+ channelSummaries;
196
+ constructor(registry, admin, ops, config, kdb, catalog, deploymentConfigs, installs, guides, checks, loginSources, directoryStates, channelSummaries) {
192
197
  this.registry = registry;
193
198
  this.admin = admin;
194
199
  this.ops = ops;
@@ -200,6 +205,8 @@ let ExtensionsAdminOperations = class ExtensionsAdminOperations {
200
205
  this.guides = guides;
201
206
  this.checks = checks;
202
207
  this.loginSources = loginSources;
208
+ this.directoryStates = directoryStates;
209
+ this.channelSummaries = channelSummaries;
203
210
  }
204
211
  /** The view of `name` for a precheck, or the refusal (unknown, startup-declared). */
205
212
  async viewFor(name, orgId) {
@@ -682,6 +689,37 @@ let ExtensionsAdminOperations = class ExtensionsAdminOperations {
682
689
  return { config: view };
683
690
  },
684
691
  }),
692
+ defineOperation({
693
+ id: "extensions.platform-channel-summary",
694
+ description: "Summarize the channel connections of an extension that provides channel@1 across the platform (super admin): how many live connections there are, in how many orgs, and the failing ones (org, connection id and name, last error; at most 20, most recently updated first). Never a connection's config. Each org creates its connections itself (channels.create in that org).",
695
+ input: AdminExtensionChannelSummaryParams.strict(),
696
+ example: { name: "slack" },
697
+ authz: { superAdmin: true },
698
+ mirrors: ["GET /api/v1/admin/extensions/:name/channel-connections/summary"],
699
+ confirm: "read",
700
+ run: async (input, ctx) => {
701
+ await assertExtensionNotOtherOrgs(this.kdb.db, input.name, ctx.orgId);
702
+ await this.admin.assertKnown(input.name);
703
+ return this.channelSummaries.forPlugin(input.name);
704
+ },
705
+ }),
706
+ defineOperation({
707
+ id: "extensions.platform-directory-status",
708
+ description: "List the orgs where an extension that provides directory@1 is enabled, with their directory sync (super admin), by org name: whether the org follows the platform's config (config.kind platform) or keeps its own copy (own, since when), how many members the directory added (people), when the last run finished, its outcome (synced, partial, removal_blocked, failed, null before any run) and the kernel's reason code with the extension's message (secrets masked). attention: \"1\" keeps the orgs whose last run failed, was partial or was removal_blocked. Read only: a sync adds and removes an org's members, so only that org's admins start one; the super admin cannot. Pass the returned next as params.cursor.",
709
+ input: AdminDirectoryOrgsParams.extend(AdminDirectoryOrgsQuery.shape).strict(),
710
+ example: { name: "slack", attention: "1" },
711
+ authz: { superAdmin: true },
712
+ mirrors: ["GET /api/v1/admin/extensions/:name/directory/orgs"],
713
+ confirm: "read",
714
+ run: async (input, ctx) => {
715
+ await assertExtensionNotOtherOrgs(this.kdb.db, input.name, ctx.orgId);
716
+ await this.admin.assertKnown(input.name);
717
+ return this.directoryStates.listForPlugin(input.name, {
718
+ cursor: input.cursor,
719
+ attention: input.attention === "1",
720
+ });
721
+ },
722
+ }),
685
723
  defineOperation({
686
724
  id: "extensions.platform-guides",
687
725
  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 (Plugins → the plugin's Extension tab, or the deployment extension's page), or in the secure input request of extensions.platform-set-config. Empty when the extension ships none.",
@@ -786,6 +824,8 @@ ExtensionsAdminOperations = __decorate([
786
824
  __param(7, Inject(ExtensionInstalls)),
787
825
  __param(8, Inject(PluginGuides)),
788
826
  __param(9, Inject(SetupChecksService)),
789
- __param(10, Inject(LoginSourcesService))
827
+ __param(10, Inject(LoginSourcesService)),
828
+ __param(11, Inject(DirectorySyncStates)),
829
+ __param(12, Inject(ChannelConnectionSummaries))
790
830
  ], ExtensionsAdminOperations);
791
831
  export { ExtensionsAdminOperations };
@@ -4,6 +4,7 @@ import { OrgExtensionConfigs } from "../../extensions/org-config.js";
4
4
  import { OrgOverrides, type OrgOverrideView } from "../../extensions/org-overrides.js";
5
5
  import { ExtensionPointDefaults } from "../../extensions/point-defaults.js";
6
6
  import { KernelDb } from "../../infra/database/kernel-db.js";
7
+ import { DirectorySyncStates } from "../../orgs/directory-sync-state.js";
7
8
  import { type PersonFieldTarget } from "../person-fields.js";
8
9
  import { PlatformOperations } from "../registry.js";
9
10
  /**
@@ -26,7 +27,8 @@ export declare class ExtensionsOperations implements OnModuleInit {
26
27
  private readonly kdb;
27
28
  private readonly pointDefaults;
28
29
  private readonly overrides;
29
- constructor(registry: PlatformOperations, configs: OrgExtensionConfigs, displayNames: ExtensionDisplayNames, kdb: KernelDb, pointDefaults: ExtensionPointDefaults, overrides: OrgOverrides);
30
+ private readonly directoryStates;
31
+ constructor(registry: PlatformOperations, configs: OrgExtensionConfigs, displayNames: ExtensionDisplayNames, kdb: KernelDb, pointDefaults: ExtensionPointDefaults, overrides: OrgOverrides, directoryStates: Pick<DirectorySyncStates, "get">);
30
32
  /**
31
33
  * Why `extensions.set-enabled` refuses the switch before writing, or null: switching on needs the
32
34
  * extension's plugin installed in the org; a required or builtin one cannot go off. The write
@@ -18,6 +18,8 @@ import { OrgOverrides } from "../../extensions/org-overrides.js";
18
18
  import { ExtensionPointDefaults } from "../../extensions/point-defaults.js";
19
19
  import { ExtensionPointDefaultBody, ExtensionPointParams, } from "../../extensions/point-defaults.schemas.js";
20
20
  import { KernelDb } from "../../infra/database/kernel-db.js";
21
+ import { OrgDirectoryParams } from "../../orgs/directory-sync.schemas.js";
22
+ import { DirectorySyncStates } from "../../orgs/directory-sync-state.js";
21
23
  import { can } from "../../orgs/roles.js";
22
24
  import { resolveNext } from "../errors.js";
23
25
  import { defineOperation } from "../operation.js";
@@ -89,13 +91,15 @@ let ExtensionsOperations = class ExtensionsOperations {
89
91
  kdb;
90
92
  pointDefaults;
91
93
  overrides;
92
- constructor(registry, configs, displayNames, kdb, pointDefaults, overrides) {
94
+ directoryStates;
95
+ constructor(registry, configs, displayNames, kdb, pointDefaults, overrides, directoryStates) {
93
96
  this.registry = registry;
94
97
  this.configs = configs;
95
98
  this.displayNames = displayNames;
96
99
  this.kdb = kdb;
97
100
  this.pointDefaults = pointDefaults;
98
101
  this.overrides = overrides;
102
+ this.directoryStates = directoryStates;
99
103
  }
100
104
  /**
101
105
  * Why `extensions.set-enabled` refuses the switch before writing, or null: switching on needs the
@@ -283,6 +287,18 @@ let ExtensionsOperations = class ExtensionsOperations {
283
287
  };
284
288
  },
285
289
  }),
290
+ defineOperation({
291
+ id: "extensions.directory-status",
292
+ description: "Read this org's directory sync of one extension that provides directory@1 (org admins): whether a run holds the sync now (running, runningSince), the last run (when it started and finished, its trigger: schedule, changed or manual, its outcome: synced, partial, removal_blocked or failed, its counts), the kernel's reason code (list_failed, page_limit, cursor_loop, timeout, member_failures, changed_during_sync, no_longer_eligible, lock_lost: the run lost its lock and stopped) with the extension's message (secrets masked), the last successful run, the failed runs in a row and how many members the directory added (people), as { state }; state is null before the first recorded run, also while the directory is not configured. Read only: a sync adds and removes members, so only an org admin starts one by hand.",
293
+ input: OrgDirectoryParams.strict(),
294
+ example: { extension: "slack" },
295
+ authz: { orgAction: "org.members.manage" },
296
+ mirrors: ["GET /api/v1/orgs/:orgId/extensions/:extension/directory"],
297
+ confirm: "read",
298
+ run: async (input, ctx) => ({
299
+ state: await this.directoryStates.get(ctx.orgId, input.extension),
300
+ }),
301
+ }),
286
302
  defineOperation({
287
303
  id: "extensions.save-org-config",
288
304
  description: "Save fields of the org's own copy of an extension's platform deployment config (org admins): only overridable fields (extensions.org-config lists them under deploymentCopy). values maps field dot paths to values (null clears; a field left out keeps). Secret fields are never in values: list them in askPerson and the person types them in a secure input request (on the web); list stored secrets to empty in clearSecrets. The first save makes the copy from the platform's non-secret values and must be valid on its own (its required secrets are asked).",
@@ -524,6 +540,7 @@ ExtensionsOperations = __decorate([
524
540
  __param(2, Inject(ExtensionDisplayNames)),
525
541
  __param(3, Inject(KernelDb)),
526
542
  __param(4, Inject(ExtensionPointDefaults)),
527
- __param(5, Inject(OrgOverrides))
543
+ __param(5, Inject(OrgOverrides)),
544
+ __param(6, Inject(DirectorySyncStates))
528
545
  ], ExtensionsOperations);
529
546
  export { ExtensionsOperations };
@@ -28,6 +28,7 @@ import { FILE_PREVIEWER_ROUTES } from "../files/previewers.schemas.js";
28
28
  import { ME_ROUTES } from "../identity/me.schemas.js";
29
29
  import { INBOX_ROUTES } from "../inbox/inbox.schemas.js";
30
30
  import { ORG_MODEL_ROUTES } from "../models/org-models.schemas.js";
31
+ import { DIRECTORY_SYNC_ROUTES } from "../orgs/directory-sync.schemas.js";
31
32
  import { ORG_ROUTES, ORG_SETTINGS_ROUTES } from "../orgs/orgs.schemas.js";
32
33
  import { PUSH_ROUTES } from "../push/push.schemas.js";
33
34
  import { SETUP_CHECK_ROUTES } from "../setup/setup-checks.schemas.js";
@@ -109,4 +110,6 @@ export const ROUTE_SCHEMAS = [
109
110
  ...SHARE_ROUTES,
110
111
  // the person's file library (file library spec §6)
111
112
  ...FILE_ROUTES,
113
+ // directory sync state (multi-capability extension pages spec §3)
114
+ ...DIRECTORY_SYNC_ROUTES,
112
115
  ];
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@capybara-hq/kernel",
3
- "version": "0.1.0-rc.148",
3
+ "version": "0.1.0-rc.149",
4
4
  "description": "Capybara kernel: config, database, plugin host and HTTP API of the Capybara agent platform",
5
5
  "license": "Apache-2.0",
6
6
  "repository": {
@@ -70,7 +70,7 @@
70
70
  "yaml": "^2.9.1",
71
71
  "yauzl": "3.4.0",
72
72
  "zod": "^4.6.7",
73
- "@capybara-hq/plugin-sdk": "^0.1.0-rc.104"
73
+ "@capybara-hq/plugin-sdk": "^0.1.0-rc.105"
74
74
  },
75
75
  "devDependencies": {
76
76
  "@langchain/langgraph-checkpoint-validation": "^1.2.0",
@@ -0,0 +1,34 @@
1
+ -- Directory sync state (multi-capability extension pages spec 2026-12-04 §3): one row per
2
+ -- (org, directory extension), written by DirectorySync. `running_since` is set when a run takes
3
+ -- its lock and cleared when the run ends; a reader treats it as stale once the lock is gone.
4
+ -- The outcome columns are written in the transaction of the run's `org.directory.synced` audit
5
+ -- row. `last_error` is the extension's message, truncated and with the org's secret config values
6
+ -- masked, never a config value. Silent skips (directory not configured, org needing config) write
7
+ -- nothing. orgs.id is text, so org_id is text.
8
+ CREATE TABLE IF NOT EXISTS directory_sync_state (
9
+ org_id text NOT NULL REFERENCES orgs(id) ON DELETE CASCADE,
10
+ plugin text NOT NULL,
11
+ running_since timestamptz,
12
+ last_started_at timestamptz,
13
+ last_finished_at timestamptz,
14
+ last_trigger text CHECK (last_trigger IN ('schedule', 'changed', 'manual')),
15
+ last_outcome text CHECK (last_outcome IN ('synced', 'partial', 'removal_blocked', 'failed')),
16
+ -- { added, removed, failed, total, skippedLastOwner }
17
+ last_counts jsonb CHECK (last_counts IS NULL OR jsonb_typeof(last_counts) = 'object'),
18
+ last_error_code text CHECK (last_error_code IN (
19
+ 'list_failed', 'page_limit', 'cursor_loop', 'timeout', 'member_failures',
20
+ 'changed_during_sync', 'no_longer_eligible', 'lock_lost'
21
+ )),
22
+ last_error text CHECK (last_error IS NULL OR char_length(last_error) <= 500),
23
+ last_success_at timestamptz,
24
+ consecutive_failures integer NOT NULL DEFAULT 0 CHECK (consecutive_failures >= 0),
25
+ PRIMARY KEY (org_id, plugin)
26
+ );
27
+
28
+ -- The platform's per-extension list of orgs.
29
+ CREATE INDEX IF NOT EXISTS directory_sync_state_plugin_idx ON directory_sync_state (plugin, org_id);
30
+
31
+ DROP POLICY IF EXISTS org_scope ON directory_sync_state;
32
+ CREATE POLICY org_scope ON directory_sync_state
33
+ USING (rls_admits(org_id)) WITH CHECK (rls_admits(org_id));
34
+ ALTER TABLE directory_sync_state ENABLE ROW LEVEL SECURITY, FORCE ROW LEVEL SECURITY;