@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
package/bootstrap.json CHANGED
@@ -3,103 +3,103 @@
3
3
  "schemaVersion": 1,
4
4
  "marketplace": {
5
5
  "url": "https://github.com/capybara-hq/plugins.git",
6
- "commit": "ecc903f26ba0d949cc17a7f44dade2ca0316973f"
6
+ "commit": "77336d5fbababec22504916b18f15b385a6fccbb"
7
7
  },
8
8
  "plugins": [
9
9
  {
10
10
  "name": "openai-compatible",
11
11
  "source": "npm",
12
12
  "npm": "@capybara-hq/plugin-openai-compatible",
13
- "version": "0.1.0-rc.18",
14
- "integrity": "sha512-u2/gp9oYXINijXSqiLdeKYoHQzTHiZM7bxt8lynrjNGxYtPzV4rwmPk3See1yOTpmJMeKqNPqavudisocZYOBA==",
13
+ "version": "0.1.0-rc.19",
14
+ "integrity": "sha512-jehBq0muKH4YVdqlMYWSILW1uV5XfEI0cXHMfMV5PRLg6EtE0IQhvUNStmk8jXQS1eBnCgRYsqS2DmHf5/E25A==",
15
15
  "required": false
16
16
  },
17
17
  {
18
18
  "name": "object-store-s3",
19
19
  "source": "npm",
20
20
  "npm": "@capybara-hq/plugin-object-store-s3",
21
- "version": "0.1.0-rc.14",
22
- "integrity": "sha512-SRqBeqzAIuli9kEsdFprO4wQW17mCLxXooheNei0q4UyzPZggtpRORrRCZcgixTsFuzQFP0hPonZcgx3wm0oqQ==",
21
+ "version": "0.1.0-rc.15",
22
+ "integrity": "sha512-eEdpPtW1pk1RebqG8SVZ55uG+307cTDRqlzLDQ8kKkw4JQQztEiFZNIJ6OFQrCHG4iWNg9zEdZyTnFO0tH5xsQ==",
23
23
  "required": true
24
24
  },
25
25
  {
26
26
  "name": "anthropic",
27
27
  "source": "npm",
28
28
  "npm": "@capybara-hq/plugin-anthropic",
29
- "version": "0.1.0-rc.14",
30
- "integrity": "sha512-Ygtv1sWffIBX2Vd6q7T71DHkwhAMDPwKEr4TUjp7cZxyUtG2oZvrlRIVxcfRVaF/OSpGrUrf47v8DLWNOwCaxQ==",
29
+ "version": "0.1.0-rc.15",
30
+ "integrity": "sha512-phITTMaDGAu6TkbYTpaq/gxeN2C0Dg6qsTSHGiG44/voHm+C5luSv4RGtfqheC/ny1AyZtHzI0LhnomeULGorw==",
31
31
  "required": false
32
32
  },
33
33
  {
34
34
  "name": "openai",
35
35
  "source": "npm",
36
36
  "npm": "@capybara-hq/plugin-openai",
37
- "version": "0.1.0-rc.17",
38
- "integrity": "sha512-e5AXAERCCXP4EGLmUwtVH8KmTbTi7W+baaSz3RHY3sMmJEtGQaHcyg9BjjRCDi1/Ic6G8OURhs+SUcgHs/m13Q==",
37
+ "version": "0.1.0-rc.18",
38
+ "integrity": "sha512-JzKAJhhJN6eBJ8ht7wn/D3tBjZ6zoHzReBb5r6/Gh+uDVqZeAkKGmFvY5MdMRwVcpanL9MQOha6qhra//EwmIg==",
39
39
  "required": false
40
40
  },
41
41
  {
42
42
  "name": "deepseek",
43
43
  "source": "npm",
44
44
  "npm": "@capybara-hq/plugin-deepseek",
45
- "version": "0.1.0-rc.16",
46
- "integrity": "sha512-WDNjY/MyKp1A2Lf2TfuAucD/GdtP2FNGZRe3yQmBDXn8SMqJ7Plr876P6gL1j667rhbgGGz8w/uUBXcr+smiLg==",
45
+ "version": "0.1.0-rc.17",
46
+ "integrity": "sha512-BAGMUNCg40kfEa5+bl0Bh8aZMQ6KY+0RqZEVCvzSXHo635vuK4byYPXFbWicQc04JZPs4fAyQKlj6ZJKRNwerQ==",
47
47
  "required": false
48
48
  },
49
49
  {
50
50
  "name": "bailian",
51
51
  "source": "npm",
52
52
  "npm": "@capybara-hq/plugin-bailian",
53
- "version": "0.1.0-rc.17",
54
- "integrity": "sha512-76rHTjx6ri9+eWpsLDQhAK8V06+FfUdFWrSc1Br/vCF4NQ3HQlvmqwzalJxUiPtTz4UnyBmHf7UC/0N2lnmahw==",
53
+ "version": "0.1.0-rc.18",
54
+ "integrity": "sha512-ymmEJ5P71DGaJEmGnU02xwGr22FetnMzA9gfLIub1krLO+K5vVEjdiTjVHVklRZ9No+EEOo4OuCkNlnHeQ7AxQ==",
55
55
  "required": false
56
56
  },
57
57
  {
58
58
  "name": "ark",
59
59
  "source": "npm",
60
60
  "npm": "@capybara-hq/plugin-ark",
61
- "version": "0.1.0-rc.17",
62
- "integrity": "sha512-VL6Tphbffn/6jSZaOq2m9W6Z5qglqs7qYCxrNrDRW4JeLFaQtHz6ykIqxJUvGfRQkkSsDX6VO8Gwnpj7B/kKIg==",
61
+ "version": "0.1.0-rc.18",
62
+ "integrity": "sha512-rEPWrGUYXkhSCU7JQqae2JZ6Ry/eit0qofsDeL1em+qXeZ9ZyWskAyHH0hjSzu8UdEPcAsS8S9RTpT6H3AAI3g==",
63
63
  "required": false
64
64
  },
65
65
  {
66
66
  "name": "connector-mcp",
67
67
  "source": "npm",
68
68
  "npm": "@capybara-hq/plugin-connector-mcp",
69
- "version": "0.1.0-rc.15",
70
- "integrity": "sha512-BuSf3Igah93ZXWe30dx7nueuwWCPHZtgDtvtZ5EZ877+s4FfnPAufdaPqygzT2aAtD0P1mhy62+cDx67TzPNOg==",
69
+ "version": "0.1.0-rc.16",
70
+ "integrity": "sha512-FQz6IZ8EjvuQVo+/deQVRFqB0UdnUQsv7zXzQK5tGxfjmlpYtgoAVjVMoSnP34ABUg8JboAapvoxGjd7T1eVkA==",
71
71
  "required": false
72
72
  },
73
73
  {
74
74
  "name": "connector-openapi",
75
75
  "source": "npm",
76
76
  "npm": "@capybara-hq/plugin-connector-openapi",
77
- "version": "0.1.0-rc.15",
78
- "integrity": "sha512-PiuBDlCHtIIqlapdw5LRRhxIwgPqrsZEZuxvXg9rsBoN1Qygkh0OX2SNv2nx6wJQZ8eXnLXFFysWNaIPslFNUg==",
77
+ "version": "0.1.0-rc.16",
78
+ "integrity": "sha512-hhW/GmnXjZR9wtPwQP0ytzHIug/wIHVzMMlAkY+7N/qG2tVxyeTrjuS4Uc4mCVEsRmQI/3pTdfDkav26a1QRsA==",
79
79
  "required": false
80
80
  },
81
81
  {
82
82
  "name": "jina",
83
83
  "source": "npm",
84
84
  "npm": "@capybara-hq/plugin-jina",
85
- "version": "0.1.0-rc.12",
86
- "integrity": "sha512-LYE+UdX/m2YunIVxzbqj8qpHyOOjDBlaF96WbLPBuDcfNwwtHSHFCwzrjHzJhcZPKn9VF9JCdLrYWRQS4nehqQ==",
85
+ "version": "0.1.0-rc.13",
86
+ "integrity": "sha512-Bz33lbFvlVFuV+Ei31/tLDaRgs5JD5lpo0XCK7SOxywrXFUzLc+UiP6JToyHtPeFt79lA6qdAjMegWNRbwgGMQ==",
87
87
  "required": false
88
88
  },
89
89
  {
90
90
  "name": "device-docker",
91
91
  "source": "npm",
92
92
  "npm": "@capybara-hq/plugin-device-docker",
93
- "version": "0.1.0-rc.37",
94
- "integrity": "sha512-eQbKWWB391h02S8ViOl9SIzHTRjEYGun7LTP/IkMWrkytwr8YR6jFEqUUTB+oYW0a4nBxjWm42gh2UJ0H+6WHw==",
93
+ "version": "0.1.0-rc.38",
94
+ "integrity": "sha512-BU6HQNC2zsckdp35efcUK13uUBShGVAEazyG74adT9BMFyU2JeLvG6z/N2dmSNH/KouCEX/UBYtX8brgSjDsWA==",
95
95
  "required": false
96
96
  },
97
97
  {
98
98
  "name": "device-local",
99
99
  "source": "npm",
100
100
  "npm": "@capybara-hq/plugin-device-local",
101
- "version": "0.1.0-rc.21",
102
- "integrity": "sha512-LPwym68E61ZUdgDziwXIpfPO9pXz9tD5aUdMZdoZF6sqea6uDrijz7djo1oCZ+yrGAZhzLBXDqEHJCT8kdRkqw==",
101
+ "version": "0.1.0-rc.25",
102
+ "integrity": "sha512-ovAHzMqufnkq+S7eTfdybGvPtK5uq96DM2sYrWI8Ew2P6EA3vSRxaZYLFr00TiEp5ImYW7cjjTOWJoupzHIH8w==",
103
103
  "required": false,
104
104
  "scope": "all"
105
105
  },
@@ -107,8 +107,8 @@
107
107
  "name": "todo",
108
108
  "source": "npm",
109
109
  "npm": "@capybara-hq/plugin-todo",
110
- "version": "0.1.0-rc.18",
111
- "integrity": "sha512-KpIBNLiQAOM8/rRpdVwbUKMVpPwT2MZ1ygjWqTqShtD2xSKEyTJ9yo1buSADPrWTeQfqDx/YRu5+sQ/QYm5cOA==",
110
+ "version": "0.1.0-rc.21",
111
+ "integrity": "sha512-pPPTHJ6cheUNS8kS11jK9lfkpZgmrmp+LuEgWvX+O3rrEcU175pf3YozQEUb6Jmx1axw8jiRUrNV9SHFa8/odg==",
112
112
  "required": false
113
113
  },
114
114
  {
@@ -124,8 +124,8 @@
124
124
  "name": "file-preview",
125
125
  "source": "npm",
126
126
  "npm": "@capybara-hq/plugin-file-preview",
127
- "version": "0.1.0-rc.7",
128
- "integrity": "sha512-0xIyrYnFtw04gVyqw+HxgKoDvsAVqoy+u2C3Wn6+adhCs+58q8miqMB1AGFxV6b9DSUuQT6nqzhWsBH5lLLgkA==",
127
+ "version": "0.1.0-rc.8",
128
+ "integrity": "sha512-QJTD3UkG1lTXetupixxhEbi7enSNI3anGosMGZLYTgZOC++rUeTfbfbydgDAExNsvGHjY/ux+lecvGolJ3CaMg==",
129
129
  "required": false,
130
130
  "builtin": true
131
131
  }
@@ -1,4 +1,5 @@
1
1
  import { z } from "zod";
2
+ import { ChannelConnectionSummaries, type ChannelConnectionSummary } from "../channels/connection-summary.js";
2
3
  import { ExtensionAdminOps } from "../extensions/admin-ops.js";
3
4
  import { ExtensionAdmin } from "../extensions/admin-view.js";
4
5
  import { type DeploymentConfigView, ExtensionDeploymentConfigService } from "../extensions/deployment-config.js";
@@ -8,10 +9,12 @@ import type { AdminExtensionView, ExtensionOrgCounts } from "../extensions/permi
8
9
  import { PluginGuides, type RenderedSetupGuide } from "../extensions/plugin-guides.js";
9
10
  import { type Principal } from "../identity/principal.js";
10
11
  import { KernelConfigService } from "../infra/config/kernel-config.service.js";
12
+ import { AdminDirectoryOrgsParams, AdminDirectoryOrgsQuery } from "../orgs/directory-sync.schemas.js";
13
+ import { type DirectorySyncOrgRow, DirectorySyncStates } from "../orgs/directory-sync-state.js";
11
14
  import type { SetupCheckState } from "../setup/setup-check-registry.js";
12
15
  import { DeploymentCheckPathParams, DeploymentCheckRunBody, DeploymentGuidePathParams, DeploymentGuidesPathParams, DeploymentGuidesQuery } from "../setup/setup-checks.schemas.js";
13
16
  import { SetupChecksService } from "../setup/setup-checks.service.js";
14
- import { AdminExtensionConfigBody, AdminExtensionOrgCountsQuery } from "./extensions.schemas.js";
17
+ import { AdminExtensionChannelSummaryParams, AdminExtensionConfigBody, AdminExtensionOrgCountsQuery } from "./extensions.schemas.js";
15
18
  declare const InstallSchema: z.ZodObject<{
16
19
  sha256: z.ZodString;
17
20
  }, z.core.$strip>;
@@ -39,7 +42,9 @@ export declare class AdminExtensionsController {
39
42
  private readonly orgOverrides;
40
43
  private readonly pluginGuides;
41
44
  private readonly setupChecks;
42
- constructor(installs: ExtensionInstalls, admin: ExtensionAdmin, ops: ExtensionAdminOps, deploymentConfigs: ExtensionDeploymentConfigService, kernelConfig: KernelConfigService, orgOverrides: OrgOverrides, pluginGuides: PluginGuides, setupChecks: SetupChecksService);
45
+ private readonly directoryStates;
46
+ private readonly channelSummaries;
47
+ constructor(installs: ExtensionInstalls, admin: ExtensionAdmin, ops: ExtensionAdminOps, deploymentConfigs: ExtensionDeploymentConfigService, kernelConfig: KernelConfigService, orgOverrides: OrgOverrides, pluginGuides: PluginGuides, setupChecks: SetupChecksService, directoryStates: DirectorySyncStates, channelSummaries: ChannelConnectionSummaries);
43
48
  /**
44
49
  * 部署上的全部插件(内置、配置声明、安装记录)及其状态、权限与快照;`drainSeconds` 为停用 / 升级时
45
50
  * 在途工具调用最多等待的秒数(`extensionHost.drainSeconds`,界面提示用)。
@@ -67,6 +72,25 @@ export declare class AdminExtensionsController {
67
72
  orgCopies({ name }: z.infer<typeof NameParams>): Promise<{
68
73
  overrides: OrgOverrideSummary[];
69
74
  }>;
75
+ /**
76
+ * The extension's channel connections across orgs (multi-capability extension pages spec §3):
77
+ * how many, in how many orgs, and the failing ones (org, name, last error; at most 20). Never a
78
+ * connection's config. Connections are created per org on its channels page. Unknown -> 404
79
+ * `extension.not_found`.
80
+ */
81
+ channelSummary({ name }: z.infer<typeof AdminExtensionChannelSummaryParams>): Promise<ChannelConnectionSummary>;
82
+ /**
83
+ * The orgs where the extension is enabled, with their directory sync state (multi-capability
84
+ * extension pages spec §3), by org name: whether each follows the platform's config or keeps its
85
+ * own copy, its directory members, the last run's outcome and reason. `attention=1` keeps the
86
+ * orgs whose last run failed, was partial or was removal-blocked. Paged by `cursor` (the
87
+ * previous page's `next`). Read only: the super admin cannot start an org's sync (decision 2).
88
+ * Unknown -> 404 `extension.not_found`.
89
+ */
90
+ directoryOrgs({ name }: z.infer<typeof AdminDirectoryOrgsParams>, q: z.infer<typeof AdminDirectoryOrgsQuery>): Promise<{
91
+ items: DirectorySyncOrgRow[];
92
+ next: string | null;
93
+ }>;
70
94
  /**
71
95
  * The extension's `extension-deployment` setup guides (setup place of the push notifications
72
96
  * plan, task C8), rendered for the platform in `locale`: the guides of that place in the latest
@@ -9,6 +9,7 @@ var __param = (this && this.__param) || function (paramIndex, decorator) {
9
9
  };
10
10
  import { Controller, Delete, Get, HttpCode, Inject, Param, Post, Put, Req } from "@nestjs/common";
11
11
  import { z } from "zod";
12
+ import { ChannelConnectionSummaries, } from "../channels/connection-summary.js";
12
13
  import { ApiError } from "../errors.js";
13
14
  import { ExtensionAdminOps } from "../extensions/admin-ops.js";
14
15
  import { ExtensionAdmin } from "../extensions/admin-view.js";
@@ -21,9 +22,11 @@ import { KernelConfigService } from "../infra/config/kernel-config.service.js";
21
22
  import { Throttled } from "../infra/throttler/throttler.guard.js";
22
23
  import { createZodDto } from "../infra/validation/create-zod-dto.js";
23
24
  import { ZBody, ZParam, ZQuery } from "../infra/validation/zod-params.js";
25
+ import { AdminDirectoryOrgsParams, AdminDirectoryOrgsQuery, } from "../orgs/directory-sync.schemas.js";
26
+ import { DirectorySyncStates } from "../orgs/directory-sync-state.js";
24
27
  import { DeploymentCheckPathParams, DeploymentCheckRunBody, DeploymentGuidePathParams, DeploymentGuidesPathParams, DeploymentGuidesQuery, } from "../setup/setup-checks.schemas.js";
25
28
  import { SetupChecksService } from "../setup/setup-checks.service.js";
26
- import { AdminExtensionConfigBody, AdminExtensionOrgCountsQuery } from "./extensions.schemas.js";
29
+ import { AdminExtensionChannelSummaryParams, AdminExtensionConfigBody, AdminExtensionOrgCountsQuery, } from "./extensions.schemas.js";
27
30
  const InstallSchema = z.object({
28
31
  /** 包存储里的包(上传 / npm 导入返回的 sha256)。 */
29
32
  sha256: z.string().regex(/^[0-9a-f]{64}$/),
@@ -44,6 +47,12 @@ class ExtensionNpmImportBody extends createZodDto(NpmSchema, "ExtensionNpmImport
44
47
  const NameParams = z.object({ name: z.string().min(1).max(64) });
45
48
  class AdminExtensionNameParamsDto extends createZodDto(NameParams, "AdminExtensionNameParams") {
46
49
  }
50
+ class AdminExtensionChannelSummaryParamsDto extends createZodDto(AdminExtensionChannelSummaryParams, "AdminExtensionChannelSummaryParams") {
51
+ }
52
+ class AdminDirectoryOrgsParamsDto extends createZodDto(AdminDirectoryOrgsParams, "AdminDirectoryOrgsParams") {
53
+ }
54
+ class AdminDirectoryOrgsQueryDto extends createZodDto(AdminDirectoryOrgsQuery, "AdminDirectoryOrgsQuery") {
55
+ }
47
56
  class DeploymentGuidesParamsDto extends createZodDto(DeploymentGuidesPathParams, "DeploymentGuidesPathParams") {
48
57
  }
49
58
  class DeploymentGuidesQueryDto extends createZodDto(DeploymentGuidesQuery, "DeploymentGuidesQuery") {
@@ -70,9 +79,11 @@ let AdminExtensionsController = class AdminExtensionsController {
70
79
  orgOverrides;
71
80
  pluginGuides;
72
81
  setupChecks;
82
+ directoryStates;
83
+ channelSummaries;
73
84
  constructor(installs, admin, ops, deploymentConfigs,
74
85
  // 字段名不能与路由方法同名(如 `config`):实例字段会遮住原型上的处理函数
75
- kernelConfig, orgOverrides, pluginGuides, setupChecks) {
86
+ kernelConfig, orgOverrides, pluginGuides, setupChecks, directoryStates, channelSummaries) {
76
87
  this.installs = installs;
77
88
  this.admin = admin;
78
89
  this.ops = ops;
@@ -81,6 +92,8 @@ let AdminExtensionsController = class AdminExtensionsController {
81
92
  this.orgOverrides = orgOverrides;
82
93
  this.pluginGuides = pluginGuides;
83
94
  this.setupChecks = setupChecks;
95
+ this.directoryStates = directoryStates;
96
+ this.channelSummaries = channelSummaries;
84
97
  }
85
98
  /**
86
99
  * 部署上的全部插件(内置、配置声明、安装记录)及其状态、权限与快照;`drainSeconds` 为停用 / 升级时
@@ -115,6 +128,31 @@ let AdminExtensionsController = class AdminExtensionsController {
115
128
  async orgCopies({ name }) {
116
129
  return { overrides: await this.orgOverrides.listForPlugin(name) };
117
130
  }
131
+ /**
132
+ * The extension's channel connections across orgs (multi-capability extension pages spec §3):
133
+ * how many, in how many orgs, and the failing ones (org, name, last error; at most 20). Never a
134
+ * connection's config. Connections are created per org on its channels page. Unknown -> 404
135
+ * `extension.not_found`.
136
+ */
137
+ async channelSummary({ name }) {
138
+ await this.admin.assertKnown(name);
139
+ return this.channelSummaries.forPlugin(name);
140
+ }
141
+ /**
142
+ * The orgs where the extension is enabled, with their directory sync state (multi-capability
143
+ * extension pages spec §3), by org name: whether each follows the platform's config or keeps its
144
+ * own copy, its directory members, the last run's outcome and reason. `attention=1` keeps the
145
+ * orgs whose last run failed, was partial or was removal-blocked. Paged by `cursor` (the
146
+ * previous page's `next`). Read only: the super admin cannot start an org's sync (decision 2).
147
+ * Unknown -> 404 `extension.not_found`.
148
+ */
149
+ async directoryOrgs({ name }, q) {
150
+ await this.admin.assertKnown(name);
151
+ return this.directoryStates.listForPlugin(name, {
152
+ cursor: q.cursor,
153
+ attention: q.attention === "1",
154
+ });
155
+ }
118
156
  /**
119
157
  * The extension's `extension-deployment` setup guides (setup place of the push notifications
120
158
  * plan, task C8), rendered for the platform in `locale`: the guides of that place in the latest
@@ -244,6 +282,15 @@ __decorate([
244
282
  Get(":name/org-overrides"),
245
283
  __param(0, ZParam(AdminExtensionNameParamsDto))
246
284
  ], AdminExtensionsController.prototype, "orgCopies", null);
285
+ __decorate([
286
+ Get(":name/channel-connections/summary"),
287
+ __param(0, ZParam(AdminExtensionChannelSummaryParamsDto))
288
+ ], AdminExtensionsController.prototype, "channelSummary", null);
289
+ __decorate([
290
+ Get(":name/directory/orgs"),
291
+ __param(0, ZParam(AdminDirectoryOrgsParamsDto)),
292
+ __param(1, ZQuery(AdminDirectoryOrgsQueryDto))
293
+ ], AdminExtensionsController.prototype, "directoryOrgs", null);
247
294
  __decorate([
248
295
  Get(":name/guides"),
249
296
  __param(0, ZParam(DeploymentGuidesParamsDto)),
@@ -320,6 +367,8 @@ AdminExtensionsController = __decorate([
320
367
  __param(4, Inject(KernelConfigService)),
321
368
  __param(5, Inject(OrgOverrides)),
322
369
  __param(6, Inject(PluginGuides)),
323
- __param(7, Inject(SetupChecksService))
370
+ __param(7, Inject(SetupChecksService)),
371
+ __param(8, Inject(DirectorySyncStates)),
372
+ __param(9, Inject(ChannelConnectionSummaries))
324
373
  ], AdminExtensionsController);
325
374
  export { AdminExtensionsController };
@@ -25,6 +25,10 @@ export declare const AdminExtensionConfigBody: z.ZodObject<{
25
25
  renameFrom: z.ZodOptional<z.ZodString>;
26
26
  }, z.core.$strict>>>;
27
27
  }, z.core.$strip>;
28
+ /** `:name` of `GET /admin/extensions/:name/channel-connections/summary`. */
29
+ export declare const AdminExtensionChannelSummaryParams: z.ZodObject<{
30
+ name: z.ZodString;
31
+ }, z.core.$strip>;
28
32
  export declare const EXTENSION_ORG_COUNT_PAGE_SIZE = 20;
29
33
  export declare const AdminExtensionOrgCountsQuery: z.ZodObject<{
30
34
  names: z.ZodString;
@@ -31,6 +31,8 @@ export const AdminExtensionConfigBody = z.object({
31
31
  /** Single keys of hinted secret records (extension config forms spec §4.3), applied in order. */
32
32
  secretEntries: z.array(AdminExtensionSecretEntry).max(200).optional(),
33
33
  });
34
+ /** `:name` of `GET /admin/extensions/:name/channel-connections/summary`. */
35
+ export const AdminExtensionChannelSummaryParams = z.object({ name: z.string().min(1).max(64) });
34
36
  export const EXTENSION_ORG_COUNT_PAGE_SIZE = 20;
35
37
  export const AdminExtensionOrgCountsQuery = z
36
38
  .object({
@@ -55,4 +57,8 @@ export const ADMIN_EXTENSION_ROUTES = [
55
57
  body: AdminExtensionConfigBody,
56
58
  },
57
59
  { route: "DELETE /api/v1/admin/extensions/:name/config", params: AdminExtensionNamePathParams },
60
+ {
61
+ route: "GET /api/v1/admin/extensions/:name/channel-connections/summary",
62
+ params: AdminExtensionChannelSummaryParams,
63
+ },
58
64
  ];
@@ -25,8 +25,9 @@ export type CliObjectStore = {
25
25
  };
26
26
  /**
27
27
  * Sets up the deployment's object-store extension inside the CLI process. The CLI hosts no
28
- * extensions, so this runs only the provider's `setup` with a context that offers `config` and
29
- * `provide` (any other ctx access fails). It uses a provider only when replicas would load it:
28
+ * extensions, so this runs only the provider's `setup` with a context that offers `config`,
29
+ * `provide` and `net` (the kernel's guarded client, for the platform only; any other ctx access
30
+ * fails). It uses a provider only when replicas would load it:
30
31
  * - a config-declared one: its permissions are approved and its deployment config is valid;
31
32
  * - else an install record desired enabled (e.g. the bootstrap plugin object-store-s3) whose
32
33
  * reviewed manifest provides `object-store@1` and whose name no config-declared extension takes:
@@ -3,6 +3,7 @@ import { tmpdir } from "node:os";
3
3
  import { join } from "node:path";
4
4
  import { extensionPointRefs, OBJECT_STORE_EXTENSION_POINT, } from "@capybara-hq/plugin-sdk";
5
5
  import { ClientBuilds } from "../client/client-builds.service.js";
6
+ import { createExtensionNet } from "../ctx/net.js";
6
7
  import { ApiError } from "../errors.js";
7
8
  import { planApprovals, snapshotCovers } from "../extensions/approvals.js";
8
9
  import { loadBootstrapManifest } from "../extensions/bootstrap-extra.js";
@@ -19,8 +20,9 @@ import { PluginImport } from "./plugin-import.js";
19
20
  import { PlatformPluginUpdater } from "./plugin-upgrade.js";
20
21
  /**
21
22
  * Sets up the deployment's object-store extension inside the CLI process. The CLI hosts no
22
- * extensions, so this runs only the provider's `setup` with a context that offers `config` and
23
- * `provide` (any other ctx access fails). It uses a provider only when replicas would load it:
23
+ * extensions, so this runs only the provider's `setup` with a context that offers `config`,
24
+ * `provide` and `net` (the kernel's guarded client, for the platform only; any other ctx access
25
+ * fails). It uses a provider only when replicas would load it:
24
26
  * - a config-declared one: its permissions are approved and its deployment config is valid;
25
27
  * - else an install record desired enabled (e.g. the bootstrap plugin object-store-s3) whose
26
28
  * reviewed manifest provides `object-store@1` and whose name no config-declared extension takes:
@@ -53,6 +55,20 @@ export async function loadCliObjectStore(cli, log, syncDir) {
53
55
  if (point === OBJECT_STORE_EXTENSION_POINT)
54
56
  store = impl;
55
57
  },
58
+ // The kernel's guarded client for the platform's own endpoint (object-store-s3 0.1.0-rc.15
59
+ // and later reach S3 through it): the same policy as a replica's ctx.net, a
60
+ // net.privateEndpoints alias granted to the plugin included. The CLI acts for no org.
61
+ net: createExtensionNet({
62
+ config: { get: () => cli.config },
63
+ allowances: {
64
+ policyFor: async () => {
65
+ throw new Error("the CLI makes no organization-bound ctx.net request");
66
+ },
67
+ },
68
+ log,
69
+ plugin: name,
70
+ signal: new AbortController().signal,
71
+ }),
56
72
  }, {
57
73
  get(target, prop, receiver) {
58
74
  if (prop in target)
@@ -66,7 +82,7 @@ export async function loadCliObjectStore(cli, log, syncDir) {
66
82
  }
67
83
  catch (err) {
68
84
  log.warn("the CLI cannot set up the object store extension", { plugin: name, err });
69
- reasons.push(`${name} needs more than ctx.config and ctx.provide`);
85
+ reasons.push(`${name} needs more than ctx.config, ctx.provide and ctx.net`);
70
86
  return undefined;
71
87
  }
72
88
  if (!store)
@@ -209,7 +209,7 @@ export declare function headsToResolve(entries: readonly MarketplaceEntry[], imp
209
209
  /** The host versions (an entry's `minKernel` is judged against them). */
210
210
  export declare const HOST_VERSIONS: {
211
211
  readonly kernel: string;
212
- readonly sdk: "0.1.0-rc.104";
212
+ readonly sdk: "0.1.0-rc.105";
213
213
  };
214
214
  /** Whether this deployment satisfies the entry's `minKernel`. */
215
215
  export declare const entryCompatible: (e: Pick<MarketplaceEntry, "minKernel">) => boolean;
@@ -25,6 +25,7 @@ import { OrgLockModule } from "../orgs/org-lock.js";
25
25
  import { OrgsModule } from "../orgs/orgs.module.js";
26
26
  import { RuntimeModule } from "../runtime/runtime.module.js";
27
27
  import { ToolsModule } from "../tools/tools.module.js";
28
+ import { ChannelConnectionSummaries } from "./connection-summary.js";
28
29
  import { ChannelConnections } from "./connections.service.js";
29
30
  import { ChannelInbound } from "./inbound.js";
30
31
  import { CHANNEL_QUEUE_NAME, ChannelJobs, DELIVER_JOB, INBOUND_JOB, RESUME_JOB, } from "./jobs.js";
@@ -63,6 +64,7 @@ ChannelsModule = __decorate([
63
64
  providers: [
64
65
  ChannelJobs,
65
66
  ChannelConnections,
67
+ ChannelConnectionSummaries,
66
68
  AnonymousGuestLock,
67
69
  AnonymousGuests,
68
70
  ChannelInbound,
@@ -71,6 +73,7 @@ ChannelsModule = __decorate([
71
73
  exports: [
72
74
  ChannelJobs,
73
75
  ChannelConnections,
76
+ ChannelConnectionSummaries,
74
77
  AnonymousGuests,
75
78
  ChannelInbound,
76
79
  ChannelOutbound,
@@ -0,0 +1,32 @@
1
+ import { KernelDb } from "../infra/database/kernel-db.js";
2
+ /** The most failing connections a summary lists. */
3
+ export declare const CHANNEL_SUMMARY_FAILING_MAX = 20;
4
+ /** The channel connections of one extension across the platform (super admin). */
5
+ export interface ChannelConnectionSummary {
6
+ /** Live connections (not deleted, in orgs not deleted). */
7
+ connections: number;
8
+ /** Orgs holding at least one of them. */
9
+ orgs: number;
10
+ /**
11
+ * Connections not switched off whose last connect or delivery failed (`last_error` set, cleared
12
+ * once the connection holds again), most recently updated first, at most 20. Nothing writes the
13
+ * legacy status `error`: a failing connection stays `active` while the supervisor retries.
14
+ */
15
+ failing: {
16
+ orgId: string;
17
+ orgName: string;
18
+ connectionId: string;
19
+ name: string;
20
+ lastError: string | null;
21
+ }[];
22
+ }
23
+ /**
24
+ * The deployment-wide channel connection summary of an extension (multi-capability extension pages
25
+ * spec §3): the platform Extension tab's channel section says how many connections exist, in how many
26
+ * orgs, and which fail. Read only; never a connection's config.
27
+ */
28
+ export declare class ChannelConnectionSummaries {
29
+ private readonly db;
30
+ constructor(db: KernelDb);
31
+ forPlugin(plugin: string): Promise<ChannelConnectionSummary>;
32
+ }
@@ -0,0 +1,67 @@
1
+ var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
2
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
3
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
4
+ else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
5
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
6
+ };
7
+ var __param = (this && this.__param) || function (paramIndex, decorator) {
8
+ return function (target, key) { decorator(target, key, paramIndex); }
9
+ };
10
+ import { Inject, Injectable } from "@nestjs/common";
11
+ import { KernelDb } from "../infra/database/kernel-db.js";
12
+ import { asPlatform } from "../infra/database/org-scope.js";
13
+ /** The most failing connections a summary lists. */
14
+ export const CHANNEL_SUMMARY_FAILING_MAX = 20;
15
+ /**
16
+ * The deployment-wide channel connection summary of an extension (multi-capability extension pages
17
+ * spec §3): the platform Extension tab's channel section says how many connections exist, in how many
18
+ * orgs, and which fail. Read only; never a connection's config.
19
+ */
20
+ let ChannelConnectionSummaries = class ChannelConnectionSummaries {
21
+ db;
22
+ constructor(db) {
23
+ this.db = db;
24
+ }
25
+ async forPlugin(plugin) {
26
+ // org-filter: deployment-wide channel connection counts of one extension (super admin summary)
27
+ return asPlatform("channel connections of an extension across orgs", async () => {
28
+ const db = this.db.db;
29
+ const live = db
30
+ .selectFrom("channel_connections as c")
31
+ .innerJoin("orgs as o", "o.id", "c.org_id")
32
+ .where("c.plugin", "=", plugin)
33
+ .where("c.deleted_at", "is", null)
34
+ .where("o.deleted_at", "is", null);
35
+ const counts = await live
36
+ .select((eb) => [
37
+ eb.fn.countAll().as("connections"),
38
+ eb.fn.count("c.org_id").distinct().as("orgs"),
39
+ ])
40
+ .executeTakeFirstOrThrow();
41
+ const failing = await live
42
+ .select([
43
+ "c.org_id as orgId",
44
+ "o.name as orgName",
45
+ "c.id as connectionId",
46
+ "c.name as name",
47
+ "c.last_error as lastError",
48
+ ])
49
+ .where("c.last_error", "is not", null)
50
+ .where("c.status", "<>", "disabled")
51
+ .orderBy("c.updated_at", "desc")
52
+ .orderBy("c.id")
53
+ .limit(CHANNEL_SUMMARY_FAILING_MAX)
54
+ .execute();
55
+ return {
56
+ connections: Number(counts.connections),
57
+ orgs: Number(counts.orgs),
58
+ failing,
59
+ };
60
+ });
61
+ }
62
+ };
63
+ ChannelConnectionSummaries = __decorate([
64
+ Injectable(),
65
+ __param(0, Inject(KernelDb))
66
+ ], ChannelConnectionSummaries);
67
+ export { ChannelConnectionSummaries };
@@ -979,6 +979,32 @@ export interface DirectoryExclusionsTable {
979
979
  created_at: Ts;
980
980
  created_by: string | null;
981
981
  }
982
+ /** The counts of the last directory sync run (`directory_sync_state.last_counts`). */
983
+ export interface DirectorySyncCountsJson {
984
+ added: number;
985
+ removed: number;
986
+ failed: number;
987
+ total: number;
988
+ skippedLastOwner: number;
989
+ }
990
+ /**
991
+ * 0240_directory_sync_state.sql: the directory sync state of one (org, directory extension),
992
+ * written by `DirectorySync` (`orgs/directory-sync-state.ts`).
993
+ */
994
+ export interface DirectorySyncStateTable {
995
+ org_id: string;
996
+ plugin: string;
997
+ running_since: TsNullable;
998
+ last_started_at: TsNullable;
999
+ last_finished_at: TsNullable;
1000
+ last_trigger: "schedule" | "changed" | "manual" | null;
1001
+ last_outcome: "synced" | "partial" | "removal_blocked" | "failed" | null;
1002
+ last_counts: ColumnType<DirectorySyncCountsJson | null, string | null | undefined, string | null>;
1003
+ last_error_code: "list_failed" | "page_limit" | "cursor_loop" | "timeout" | "member_failures" | "changed_during_sync" | "no_longer_eligible" | "lock_lost" | null;
1004
+ last_error: string | null;
1005
+ last_success_at: TsNullable;
1006
+ consecutive_failures: Generated<number>;
1007
+ }
982
1008
  /** 0022_attachments.sql:对话附件(字节在对象存储,见 conversations/attachments.service.ts)。 */
983
1009
  export interface AttachmentsTable {
984
1010
  id: string;
@@ -2226,6 +2252,7 @@ export interface KernelDatabase {
2226
2252
  channel_card_messages: ChannelCardMessagesTable;
2227
2253
  org_anonymous_accounts: OrgAnonymousAccountsTable;
2228
2254
  directory_exclusions: DirectoryExclusionsTable;
2255
+ directory_sync_state: DirectorySyncStateTable;
2229
2256
  attachments: AttachmentsTable;
2230
2257
  devices: DevicesTable;
2231
2258
  device_instances: DeviceInstancesTable;
@@ -1,5 +1,5 @@
1
1
  import { sql } from "kysely";
2
- // PostgreSQL 17 after 0239. Re-review the ownership map before updating this fingerprint.
2
+ // PostgreSQL 17 after 0240. Re-review the ownership map before updating this fingerprint.
3
3
  // 0234 adds extension_grant_epoch: deployment state with no org or account reference, so it
4
4
  // needs no erasure rule. 0235 adds extension_revision_grants (approver columns cleared by account
5
5
  // erasure, deployment scope) and extension_revision_grant_orgs (an org row rule; the org FK
@@ -9,6 +9,8 @@ import { sql } from "kysely";
9
9
  // (deployment state: flush batch ids with no org or account reference, no erasure rule).
10
10
  // 0239 adds extension_replica_isolation (deployment state: each replica's supervisor checks and
11
11
  // shadow placements by plugin and version, no org or account reference, no erasure rule).
12
+ // 0240 adds directory_sync_state: org-owned (an org row rule; the org FK cascades), no account
13
+ // column; its last_error is the extension's message, erased with the row.
12
14
  // The fingerprint includes relation/column identities and ordered PK, UNIQUE and inbound/outbound FK
13
15
  // columns and actions, including FKs from outside the kernel schema.
14
16
  export async function orgCatalogDrift(db) {
@@ -39,5 +41,5 @@ WITH catalog AS (
39
41
  )
40
42
  SELECT md5(string_agg(entry, chr(10) ORDER BY entry COLLATE "C")) AS fingerprint FROM catalog
41
43
  `.execute(db);
42
- return rows[0]?.fingerprint === "d3b21b83bd3b12ee253eb2800f0731c6" ? undefined : "schema-drift";
44
+ return rows[0]?.fingerprint === "fa6da86dab3501dd7d33eee311acc771" ? undefined : "schema-drift";
43
45
  }
@@ -28,6 +28,7 @@ export const rowRules = [
28
28
  rule("connector_tool_account_policies", "connector_id, account_id, tool_name"),
29
29
  rule("connector_tools", "connector_id, name", "connector_id IN (SELECT id FROM capybara.connectors WHERE org_id = (SELECT id FROM subject))"),
30
30
  rule("directory_exclusions", "org_id, account_id, plugin"),
31
+ rule("directory_sync_state", "org_id, plugin"),
31
32
  rule("eval_results", "id"),
32
33
  rule("extension_client_reports", "plugin, build, org_id, contribution, kind"),
33
34
  rule("extension_org_configs", "plugin, org_id"),
@@ -630,6 +630,7 @@ function fallbackView(name, known, err) {
630
630
  displayName: null,
631
631
  version: known.version,
632
632
  source: "install",
633
+ provides: [],
633
634
  sha256: known.sha256,
634
635
  status: "failed",
635
636
  desired: known.state === undefined
@@ -99,6 +99,11 @@ export declare class ExtensionAdmin {
99
99
  get(name: string, opts?: {
100
100
  allowUnreadable?: boolean;
101
101
  }): Promise<AdminExtensionView>;
102
+ /**
103
+ * Refuses a name this deployment does not know (`extension.not_found`) without reading its
104
+ * package: for reads keyed by the name that need nothing of the package.
105
+ */
106
+ assertKnown(name: string): Promise<void>;
102
107
  /**
103
108
  * The review digest of a stored package (the `reviewHash` its extension would show once
104
109
  * installed); null when the package cannot be read.