@capybara-hq/kernel 0.1.0-rc.84 → 0.1.0-rc.86
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.
- package/dist/admin/admin.module.js +5 -0
- package/dist/admin/health.service.d.ts +2 -2
- package/dist/admin/health.service.js +10 -2
- package/dist/catalog/admin-catalog.controller.d.ts +2 -1
- package/dist/catalog/admin-catalog.controller.js +2 -1
- package/dist/catalog/catalog-content.d.ts +5 -15
- package/dist/catalog/catalog-content.js +5 -56
- package/dist/catalog/catalog-scope.service.d.ts +3 -3
- package/dist/catalog/catalog-scope.service.js +4 -3
- package/dist/catalog/catalog.module.d.ts +3 -1
- package/dist/catalog/catalog.module.js +14 -1
- package/dist/catalog/component-scope.service.d.ts +6 -1
- package/dist/catalog/component-scope.service.js +16 -2
- package/dist/catalog/job-ids.d.ts +29 -0
- package/dist/catalog/job-ids.js +29 -0
- package/dist/catalog/jobs.d.ts +12 -3
- package/dist/catalog/jobs.js +28 -7
- package/dist/catalog/marketplaces.service.d.ts +1 -1
- package/dist/catalog/org-catalog.controller.d.ts +2 -30
- package/dist/catalog/org-catalog.controller.js +3 -29
- package/dist/catalog/org-catalog.schemas.d.ts +9 -46
- package/dist/catalog/org-catalog.schemas.js +9 -23
- package/dist/catalog/org-catalog.service.js +14 -23
- package/dist/catalog/plugin-import.d.ts +21 -0
- package/dist/catalog/plugin-import.js +33 -3
- package/dist/catalog/plugin-install.d.ts +69 -76
- package/dist/catalog/plugin-install.js +156 -234
- package/dist/catalog/plugin-upgrade.d.ts +71 -11
- package/dist/catalog/plugin-upgrade.js +222 -43
- package/dist/catalog/scope-sync.d.ts +22 -20
- package/dist/catalog/scope-sync.js +57 -42
- package/dist/catalog/template-connector-ensure.d.ts +100 -0
- package/dist/catalog/template-connector-ensure.js +285 -0
- package/dist/catalog/template-connector-jobs.d.ts +28 -0
- package/dist/catalog/template-connector-jobs.js +54 -0
- package/dist/catalog/template-connector-reconcile.d.ts +44 -0
- package/dist/catalog/template-connector-reconcile.js +114 -0
- package/dist/catalog/template-connectors.processor.d.ts +32 -0
- package/dist/catalog/template-connectors.processor.js +101 -0
- package/dist/channels/cards.d.ts +7 -3
- package/dist/channels/cards.js +9 -4
- package/dist/channels/phrases.d.ts +10 -0
- package/dist/channels/phrases.js +10 -0
- package/dist/config/docs.js +1 -1
- package/dist/config/schema.d.ts +3 -0
- package/dist/config/schema.js +18 -12
- package/dist/ctx/create-ctx.d.ts +10 -1
- package/dist/ctx/create-ctx.js +42 -2
- package/dist/db/kernel-schema.d.ts +2 -1
- package/dist/device-access/device-access.module.d.ts +7 -0
- package/dist/device-access/device-access.module.js +41 -0
- package/dist/device-access/device-access.service.d.ts +142 -0
- package/dist/device-access/device-access.service.js +464 -0
- package/dist/device-access/token.d.ts +6 -0
- package/dist/device-access/token.js +6 -0
- package/dist/device-access/viewer-routes.d.ts +45 -0
- package/dist/device-access/viewer-routes.js +81 -0
- package/dist/device-access/viewer.d.ts +244 -0
- package/dist/device-access/viewer.js +844 -0
- package/dist/dial-in/access.d.ts +19 -0
- package/dist/dial-in/access.js +23 -0
- package/dist/dial-in/gateway.d.ts +48 -6
- package/dist/dial-in/gateway.js +145 -10
- package/dist/dial-in/keys.d.ts +7 -0
- package/dist/dial-in/keys.js +7 -0
- package/dist/dial-in/routes.d.ts +11 -3
- package/dist/dial-in/routes.js +15 -4
- package/dist/dial-in/streams.d.ts +58 -0
- package/dist/dial-in/streams.js +283 -0
- package/dist/errors.d.ts +2 -0
- package/dist/errors.js +2 -0
- package/dist/extensions/host.d.ts +13 -1
- package/dist/extensions/host.js +20 -1
- package/dist/extensions/org-config.d.ts +6 -1
- package/dist/extensions/org-config.js +15 -2
- package/dist/extensions/permission-set.d.ts +15 -1
- package/dist/extensions/permission-set.js +13 -1
- package/dist/extensions/permission-view.d.ts +6 -4
- package/dist/extensions/permission-view.js +6 -1
- package/dist/git/gateway.js +3 -1
- package/dist/http/error.filter.js +2 -0
- package/dist/http/gateway-routes.d.ts +8 -4
- package/dist/http/gateway-routes.js +4 -3
- package/dist/infra/lock/lock.service.d.ts +5 -1
- package/dist/infra/lock/lock.service.js +10 -4
- package/dist/infra/outbox/registry.d.ts +28 -0
- package/dist/infra/outbox/registry.js +33 -0
- package/dist/infra/queue/queue-names.d.ts +1 -1
- package/dist/infra/queue/queue-names.js +2 -0
- package/dist/infra/throttler/named-throttlers.d.ts +3 -0
- package/dist/infra/throttler/named-throttlers.js +16 -0
- package/dist/kernel.module.js +3 -0
- package/dist/lifecycle/kernel-lifecycle.d.ts +8 -1
- package/dist/lifecycle/kernel-lifecycle.js +37 -11
- package/dist/orgs/org-owner.d.ts +7 -0
- package/dist/orgs/org-owner.js +16 -0
- package/dist/platform/operation.d.ts +3 -4
- package/dist/platform/ops/connectors.ops.js +8 -1
- package/dist/platform/ops/org-plugins.ops.d.ts +0 -9
- package/dist/platform/ops/org-plugins.ops.js +18 -235
- package/dist/platform/ops/plugins.ops.d.ts +0 -1
- package/dist/platform/ops/plugins.ops.js +3 -31
- package/dist/roles/gateway-role.d.ts +13 -6
- package/dist/roles/gateway-role.js +27 -9
- package/dist/roles/gateway.module.d.ts +2 -1
- package/dist/roles/gateway.module.js +13 -3
- package/dist/roles/worker-role.d.ts +9 -4
- package/dist/roles/worker-role.js +18 -5
- package/dist/roles/worker.module.d.ts +1 -1
- package/dist/roles/worker.module.js +8 -1
- package/dist/sandbox/device-services.d.ts +62 -0
- package/dist/sandbox/device-services.js +183 -0
- package/dist/sandbox/leases.d.ts +18 -1
- package/dist/sandbox/leases.js +75 -1
- package/dist/sandbox/network-grants.js +5 -2
- package/dist/sandbox/sandbox.module.d.ts +2 -1
- package/dist/sandbox/sandbox.module.js +5 -2
- package/dist/sandbox/sandbox.service.d.ts +44 -1
- package/dist/sandbox/sandbox.service.js +142 -5
- package/dist/setup/setup-guides.service.d.ts +9 -1
- package/dist/setup/setup-guides.service.js +38 -8
- package/dist/tools/admin-connectors.d.ts +3 -2
- package/dist/tools/admin-connectors.js +5 -4
- package/dist/tools/approvals.service.d.ts +45 -20
- package/dist/tools/approvals.service.js +19 -9
- package/dist/tools/call-scope.d.ts +60 -0
- package/dist/tools/call-scope.js +23 -0
- package/dist/tools/connector-setup.d.ts +28 -0
- package/dist/tools/connector-setup.js +33 -0
- package/dist/tools/connector-tools-jobs.d.ts +35 -0
- package/dist/tools/connector-tools-jobs.js +40 -0
- package/dist/tools/connector-tools.processor.d.ts +32 -0
- package/dist/tools/connector-tools.processor.js +97 -0
- package/dist/tools/connectors.controller.d.ts +1 -0
- package/dist/tools/connectors.schemas.d.ts +1 -0
- package/dist/tools/connectors.schemas.js +5 -0
- package/dist/tools/connectors.service.d.ts +138 -14
- package/dist/tools/connectors.service.js +410 -50
- package/dist/tools/credentials.d.ts +35 -0
- package/dist/tools/credentials.js +89 -1
- package/dist/tools/drift.d.ts +5 -0
- package/dist/tools/drift.js +21 -2
- package/dist/tools/editable-endpoint.d.ts +23 -0
- package/dist/tools/editable-endpoint.js +92 -0
- package/dist/tools/network-asks.d.ts +13 -0
- package/dist/tools/network-asks.js +26 -2
- package/dist/tools/oauth/flow.d.ts +1 -1
- package/dist/tools/oauth/flow.js +3 -2
- package/dist/tools/pipeline.d.ts +30 -1
- package/dist/tools/pipeline.js +299 -59
- package/dist/tools/questions.service.d.ts +24 -3
- package/dist/tools/questions.service.js +3 -1
- package/dist/tools/registry.d.ts +14 -2
- package/dist/tools/registry.js +27 -6
- package/dist/tools/tools.module.js +4 -0
- package/package.json +3 -3
- package/src/migrations/0183_connectors_created_by_nullable.sql +5 -0
|
@@ -11,20 +11,6 @@ import { CatalogGuideQuery, CatalogMarketplaceRequestBody, CatalogRequestBody, C
|
|
|
11
11
|
import { OrgCatalogService } from "./org-catalog.service.js";
|
|
12
12
|
import { PluginInstaller, type PluginInstallView, type UninstallPreview, type UninstallReport } from "./plugin-install.js";
|
|
13
13
|
import { CatalogRequestsService, type CatalogRequestView } from "./requests.service.js";
|
|
14
|
-
declare const ConnectorsBody: z.ZodObject<{
|
|
15
|
-
inputs: z.ZodObject<{
|
|
16
|
-
connectors: z.ZodRecord<z.ZodString, z.ZodObject<{
|
|
17
|
-
name: z.ZodOptional<z.ZodString>;
|
|
18
|
-
slug: z.ZodOptional<z.ZodString>;
|
|
19
|
-
endpoint: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
|
|
20
|
-
credential: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
|
|
21
|
-
client: z.ZodOptional<z.ZodObject<{
|
|
22
|
-
clientId: z.ZodString;
|
|
23
|
-
clientSecret: z.ZodOptional<z.ZodString>;
|
|
24
|
-
}, z.core.$strict>>;
|
|
25
|
-
}, z.core.$strict>>;
|
|
26
|
-
}, z.core.$strict>;
|
|
27
|
-
}, z.core.$strict>;
|
|
28
14
|
declare const TemplateConnectorBody: z.ZodObject<{
|
|
29
15
|
name: z.ZodOptional<z.ZodString>;
|
|
30
16
|
config: z.ZodObject<{
|
|
@@ -134,24 +120,10 @@ export declare class OrgCatalogController {
|
|
|
134
120
|
confirm: string;
|
|
135
121
|
}>;
|
|
136
122
|
install(principal: Principal, org: OrgContext, itemId: string, body: z.infer<typeof OrgPluginInstallBody>, reply: FastifyReply): Promise<Omit<OrgInstallResult, "status">>;
|
|
137
|
-
/**
|
|
138
|
-
* Creates the connectors an installed plugin is missing (ruling P2-10: a connector template on
|
|
139
|
-
* in the org without a connector there, e.g. added by a platform update; the plugin shows
|
|
140
|
-
* `needs_config`): `{ inputs: { connectors: { <templateId>: input } } }` with the same input
|
|
141
|
-
* checks as an install; recorded on the install -> 201 `{ connectors: [{ templateId,
|
|
142
|
-
* connectorId }] }`. Not installed -> 404 `plugin.install_not_found`; a template not missing ->
|
|
143
|
-
* 400 `validation_failed`.
|
|
144
|
-
*/
|
|
145
|
-
configureConnectors(principal: Principal, org: OrgContext, itemId: string, body: z.infer<typeof ConnectorsBody>): Promise<{
|
|
146
|
-
connectors: {
|
|
147
|
-
templateId: string;
|
|
148
|
-
connectorId: string;
|
|
149
|
-
}[];
|
|
150
|
-
}>;
|
|
151
123
|
/**
|
|
152
124
|
* One more connector from a platform connector template on in the org (rulings P4-7, P4-T6-8):
|
|
153
|
-
* `{ name?, config: { slug?, endpoint?, credential?, client? } }`
|
|
154
|
-
* -> 201 `{ connector, issues }` (as `POST connectors`). A template not usable in the org -> 404
|
|
125
|
+
* `{ name?, config: { slug?, endpoint?, credential?, client? } }` (the org credential or OAuth
|
|
126
|
+
* client the template needs is required) -> 201 `{ connector, issues }` (as `POST connectors`). A template not usable in the org -> 404
|
|
155
127
|
* `component.not_found`; off there -> 409 `component.off`; input errors -> 400 at `config.*`.
|
|
156
128
|
*/
|
|
157
129
|
templateConnector(principal: Principal, org: OrgContext, templateId: string, body: z.infer<typeof TemplateConnectorBody>): Promise<{
|
|
@@ -16,11 +16,10 @@ import { createZodDto } from "../infra/validation/create-zod-dto.js";
|
|
|
16
16
|
import { ZBody, ZQuery } from "../infra/validation/zod-params.js";
|
|
17
17
|
import { CurrentOrg, OrgAction } from "../orgs/org.guard.js";
|
|
18
18
|
import { roleAtLeast } from "../orgs/roles.js";
|
|
19
|
-
import { CatalogGuideQuery, CatalogMarketplaceRequestBody, CatalogRequestBody, CatalogRequestsListQuery, NetworkRequestBody,
|
|
19
|
+
import { CatalogGuideQuery, CatalogMarketplaceRequestBody, CatalogRequestBody, CatalogRequestsListQuery, NetworkRequestBody, OrgPluginInstallBody, OrgPluginSwitchBody, OrgTemplateConnectorSchema, } from "./org-catalog.schemas.js";
|
|
20
20
|
import { OrgCatalogService } from "./org-catalog.service.js";
|
|
21
21
|
import { PluginInstaller, } from "./plugin-install.js";
|
|
22
22
|
import { CatalogRequestsService } from "./requests.service.js";
|
|
23
|
-
const ConnectorsBody = OrgPluginConnectorsSchema;
|
|
24
23
|
const TemplateConnectorBody = OrgTemplateConnectorSchema;
|
|
25
24
|
/**
|
|
26
25
|
* 条目图标的响应头:图标可能是 SVG(可含脚本),只许网页以 `<img>` 显示;直接打开时 CSP sandbox 禁止脚本与一切外部
|
|
@@ -45,8 +44,6 @@ class CatalogDecideBody extends createZodDto(DecideBody, "CatalogDecideBody") {
|
|
|
45
44
|
}
|
|
46
45
|
class OrgPluginInstallBodyDto extends createZodDto(OrgPluginInstallBody, "OrgPluginInstallBody") {
|
|
47
46
|
}
|
|
48
|
-
class OrgPluginConnectorsBody extends createZodDto(ConnectorsBody, "OrgPluginConnectorsBody") {
|
|
49
|
-
}
|
|
50
47
|
class OrgPluginSwitchBodyDto extends createZodDto(OrgPluginSwitchBody, "OrgPluginSwitchBody") {
|
|
51
48
|
}
|
|
52
49
|
class OrgTemplateConnectorBody extends createZodDto(TemplateConnectorBody, "OrgTemplateConnectorBody") {
|
|
@@ -180,25 +177,10 @@ let OrgCatalogController = class OrgCatalogController {
|
|
|
180
177
|
const { status: _status, ...rest } = r;
|
|
181
178
|
return rest;
|
|
182
179
|
}
|
|
183
|
-
/**
|
|
184
|
-
* Creates the connectors an installed plugin is missing (ruling P2-10: a connector template on
|
|
185
|
-
* in the org without a connector there, e.g. added by a platform update; the plugin shows
|
|
186
|
-
* `needs_config`): `{ inputs: { connectors: { <templateId>: input } } }` with the same input
|
|
187
|
-
* checks as an install; recorded on the install -> 201 `{ connectors: [{ templateId,
|
|
188
|
-
* connectorId }] }`. Not installed -> 404 `plugin.install_not_found`; a template not missing ->
|
|
189
|
-
* 400 `validation_failed`.
|
|
190
|
-
*/
|
|
191
|
-
async configureConnectors(principal, org, itemId, body) {
|
|
192
|
-
const p = requireUser(principal);
|
|
193
|
-
const tokenId = patTokenId(p);
|
|
194
|
-
return {
|
|
195
|
-
connectors: await this.pluginInstaller.configureConnectors(org.orgId, p.account.id, itemId, body.inputs, tokenId !== undefined ? { actorTokenId: tokenId } : {}),
|
|
196
|
-
};
|
|
197
|
-
}
|
|
198
180
|
/**
|
|
199
181
|
* One more connector from a platform connector template on in the org (rulings P4-7, P4-T6-8):
|
|
200
|
-
* `{ name?, config: { slug?, endpoint?, credential?, client? } }`
|
|
201
|
-
* -> 201 `{ connector, issues }` (as `POST connectors`). A template not usable in the org -> 404
|
|
182
|
+
* `{ name?, config: { slug?, endpoint?, credential?, client? } }` (the org credential or OAuth
|
|
183
|
+
* client the template needs is required) -> 201 `{ connector, issues }` (as `POST connectors`). A template not usable in the org -> 404
|
|
202
184
|
* `component.not_found`; off there -> 409 `component.off`; input errors -> 400 at `config.*`.
|
|
203
185
|
*/
|
|
204
186
|
async templateConnector(principal, org, templateId, body) {
|
|
@@ -308,14 +290,6 @@ __decorate([
|
|
|
308
290
|
__param(3, ZBody(OrgPluginInstallBodyDto)),
|
|
309
291
|
__param(4, Res({ passthrough: true }))
|
|
310
292
|
], OrgCatalogController.prototype, "install", null);
|
|
311
|
-
__decorate([
|
|
312
|
-
Post("catalog/:itemId/connectors"),
|
|
313
|
-
OrgAction("connectors.manage"),
|
|
314
|
-
__param(0, CurrentPrincipal()),
|
|
315
|
-
__param(1, CurrentOrg()),
|
|
316
|
-
__param(2, Param("itemId")),
|
|
317
|
-
__param(3, ZBody(OrgPluginConnectorsBody))
|
|
318
|
-
], OrgCatalogController.prototype, "configureConnectors", null);
|
|
319
293
|
__decorate([
|
|
320
294
|
Post("connector-templates/:templateId/connectors"),
|
|
321
295
|
OrgAction("connectors.manage"),
|
|
@@ -28,8 +28,8 @@ export declare const CatalogMarketplaceRequestBody: z.ZodObject<{
|
|
|
28
28
|
note: z.ZodOptional<z.ZodString>;
|
|
29
29
|
}, z.core.$strict>;
|
|
30
30
|
/**
|
|
31
|
-
* One connector template's input
|
|
32
|
-
* client. The credential and the client secret are secrets (`secret()` meta, ruling R2): a Platform
|
|
31
|
+
* One connector template's input for one more connector from it (C30): name, slug, endpoint,
|
|
32
|
+
* credential or OAuth client. The credential and the client secret are secrets (`secret()` meta, ruling R2): a Platform
|
|
33
33
|
* operation never takes them as params; the person enters them in a secure input request.
|
|
34
34
|
*/
|
|
35
35
|
export declare const CatalogConnectorInput: z.ZodObject<{
|
|
@@ -43,43 +43,16 @@ export declare const CatalogConnectorInput: z.ZodObject<{
|
|
|
43
43
|
}, z.core.$strict>>;
|
|
44
44
|
}, z.core.$strict>;
|
|
45
45
|
/**
|
|
46
|
-
* The org install body:
|
|
47
|
-
*
|
|
48
|
-
*
|
|
49
|
-
*
|
|
50
|
-
*
|
|
46
|
+
* The org install body: the connector templates the org chose to switch on (`templatesOn`: exactly
|
|
47
|
+
* these are on after the install and make connectors, the plugin's other templates are switched off
|
|
48
|
+
* in the org and stay available on the connectors page; absent: the templates on in the org now).
|
|
49
|
+
* No connector input (plugin pages spec §5.2.2): a template that needs an org credential or OAuth
|
|
50
|
+
* client becomes a `needs_config` connector. No version: an org installs the platform version
|
|
51
|
+
* (one per deployment, ruling P2-17).
|
|
51
52
|
*/
|
|
52
53
|
export declare const OrgPluginInstallBody: z.ZodObject<{
|
|
53
|
-
connectors: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodObject<{
|
|
54
|
-
name: z.ZodOptional<z.ZodString>;
|
|
55
|
-
slug: z.ZodOptional<z.ZodString>;
|
|
56
|
-
endpoint: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
|
|
57
|
-
credential: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
|
|
58
|
-
client: z.ZodOptional<z.ZodObject<{
|
|
59
|
-
clientId: z.ZodString;
|
|
60
|
-
clientSecret: z.ZodOptional<z.ZodString>;
|
|
61
|
-
}, z.core.$strict>>;
|
|
62
|
-
}, z.core.$strict>>>;
|
|
63
54
|
templatesOn: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
64
55
|
}, z.core.$strict>;
|
|
65
|
-
/**
|
|
66
|
-
* `POST …/catalog/:itemId/connectors` (ruling P2-10): the input of missing connectors, by template
|
|
67
|
-
* id, as at install.
|
|
68
|
-
*/
|
|
69
|
-
export declare const OrgPluginConnectorsSchema: z.ZodObject<{
|
|
70
|
-
inputs: z.ZodObject<{
|
|
71
|
-
connectors: z.ZodRecord<z.ZodString, z.ZodObject<{
|
|
72
|
-
name: z.ZodOptional<z.ZodString>;
|
|
73
|
-
slug: z.ZodOptional<z.ZodString>;
|
|
74
|
-
endpoint: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
|
|
75
|
-
credential: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
|
|
76
|
-
client: z.ZodOptional<z.ZodObject<{
|
|
77
|
-
clientId: z.ZodString;
|
|
78
|
-
clientSecret: z.ZodOptional<z.ZodString>;
|
|
79
|
-
}, z.core.$strict>>;
|
|
80
|
-
}, z.core.$strict>>;
|
|
81
|
-
}, z.core.$strict>;
|
|
82
|
-
}, z.core.$strict>;
|
|
83
56
|
/**
|
|
84
57
|
* `POST …/connector-templates/:templateId/connectors` (ruling P4-T6-8): one more connector from a
|
|
85
58
|
* platform connector template, its name and an install's connector input (`config`).
|
|
@@ -100,20 +73,10 @@ export declare const OrgTemplateConnectorSchema: z.ZodObject<{
|
|
|
100
73
|
export declare const ConnectorTemplatePathParams: z.ZodObject<{
|
|
101
74
|
templateId: z.ZodString;
|
|
102
75
|
}, z.core.$strip>;
|
|
103
|
-
/** The switch body: on (with the install
|
|
76
|
+
/** The switch body: on (with the install choice), or off (with the preview's hash to confirm). */
|
|
104
77
|
export declare const OrgPluginSwitchBody: z.ZodObject<{
|
|
105
78
|
enabled: z.ZodBoolean;
|
|
106
79
|
inputs: z.ZodOptional<z.ZodObject<{
|
|
107
|
-
connectors: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodObject<{
|
|
108
|
-
name: z.ZodOptional<z.ZodString>;
|
|
109
|
-
slug: z.ZodOptional<z.ZodString>;
|
|
110
|
-
endpoint: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
|
|
111
|
-
credential: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
|
|
112
|
-
client: z.ZodOptional<z.ZodObject<{
|
|
113
|
-
clientId: z.ZodString;
|
|
114
|
-
clientSecret: z.ZodOptional<z.ZodString>;
|
|
115
|
-
}, z.core.$strict>>;
|
|
116
|
-
}, z.core.$strict>>>;
|
|
117
80
|
templatesOn: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
118
81
|
}, z.core.$strict>>;
|
|
119
82
|
confirm: z.ZodOptional<z.ZodString>;
|
|
@@ -50,8 +50,8 @@ export const CatalogMarketplaceRequestBody = z
|
|
|
50
50
|
})
|
|
51
51
|
.strict();
|
|
52
52
|
/**
|
|
53
|
-
* One connector template's input
|
|
54
|
-
* client. The credential and the client secret are secrets (`secret()` meta, ruling R2): a Platform
|
|
53
|
+
* One connector template's input for one more connector from it (C30): name, slug, endpoint,
|
|
54
|
+
* credential or OAuth client. The credential and the client secret are secrets (`secret()` meta, ruling R2): a Platform
|
|
55
55
|
* operation never takes them as params; the person enters them in a secure input request.
|
|
56
56
|
*/
|
|
57
57
|
export const CatalogConnectorInput = z
|
|
@@ -70,27 +70,18 @@ export const CatalogConnectorInput = z
|
|
|
70
70
|
})
|
|
71
71
|
.strict();
|
|
72
72
|
/**
|
|
73
|
-
* The org install body:
|
|
74
|
-
*
|
|
75
|
-
*
|
|
76
|
-
*
|
|
77
|
-
*
|
|
73
|
+
* The org install body: the connector templates the org chose to switch on (`templatesOn`: exactly
|
|
74
|
+
* these are on after the install and make connectors, the plugin's other templates are switched off
|
|
75
|
+
* in the org and stay available on the connectors page; absent: the templates on in the org now).
|
|
76
|
+
* No connector input (plugin pages spec §5.2.2): a template that needs an org credential or OAuth
|
|
77
|
+
* client becomes a `needs_config` connector. No version: an org installs the platform version
|
|
78
|
+
* (one per deployment, ruling P2-17).
|
|
78
79
|
*/
|
|
79
80
|
export const OrgPluginInstallBody = z
|
|
80
81
|
.object({
|
|
81
|
-
connectors: z.record(z.string(), CatalogConnectorInput).optional(),
|
|
82
82
|
templatesOn: z.array(z.string().min(1).max(100)).max(50).optional(),
|
|
83
83
|
})
|
|
84
84
|
.strict();
|
|
85
|
-
/**
|
|
86
|
-
* `POST …/catalog/:itemId/connectors` (ruling P2-10): the input of missing connectors, by template
|
|
87
|
-
* id, as at install.
|
|
88
|
-
*/
|
|
89
|
-
export const OrgPluginConnectorsSchema = z
|
|
90
|
-
.object({
|
|
91
|
-
inputs: z.object({ connectors: z.record(z.string(), CatalogConnectorInput) }).strict(),
|
|
92
|
-
})
|
|
93
|
-
.strict();
|
|
94
85
|
/**
|
|
95
86
|
* `POST …/connector-templates/:templateId/connectors` (ruling P4-T6-8): one more connector from a
|
|
96
87
|
* platform connector template, its name and an install's connector input (`config`).
|
|
@@ -103,7 +94,7 @@ export const OrgTemplateConnectorSchema = z
|
|
|
103
94
|
.strict();
|
|
104
95
|
/** `:templateId` of the template connector route (`@Param`). */
|
|
105
96
|
export const ConnectorTemplatePathParams = z.object({ templateId: z.string().min(1) });
|
|
106
|
-
/** The switch body: on (with the install
|
|
97
|
+
/** The switch body: on (with the install choice), or off (with the preview's hash to confirm). */
|
|
107
98
|
export const OrgPluginSwitchBody = z
|
|
108
99
|
.object({
|
|
109
100
|
enabled: z.boolean(),
|
|
@@ -163,11 +154,6 @@ export const ORG_CATALOG_ROUTES = [
|
|
|
163
154
|
params: CatalogItemPathParams,
|
|
164
155
|
body: OrgPluginInstallBody,
|
|
165
156
|
},
|
|
166
|
-
{
|
|
167
|
-
route: "POST /api/v1/orgs/:orgId/catalog/:itemId/connectors",
|
|
168
|
-
params: CatalogItemPathParams,
|
|
169
|
-
body: OrgPluginConnectorsSchema,
|
|
170
|
-
},
|
|
171
157
|
{
|
|
172
158
|
route: "POST /api/v1/orgs/:orgId/connector-templates/:templateId/connectors",
|
|
173
159
|
params: ConnectorTemplatePathParams,
|
|
@@ -24,7 +24,7 @@ import { packagePath } from "../packages/tgz.js";
|
|
|
24
24
|
import { StorageService } from "../storage/storage.service.js";
|
|
25
25
|
import { catalogHasIcon, findConnectorIn, orgTemplateView, readCatalogIcon, readCatalogTemplates, templatePluginProblem, } from "./catalog-content.js";
|
|
26
26
|
import { itemView, ownerOnlyFacts, versionUsable } from "./catalog-items.js";
|
|
27
|
-
import { connectorTemplatesOn
|
|
27
|
+
import { connectorTemplatesOn } from "./component-state.js";
|
|
28
28
|
import { LIVE_INSTALL_STATUSES } from "./install-status.js";
|
|
29
29
|
import { itemPendingError, ownerOf, ownersOf } from "./ownership.js";
|
|
30
30
|
import { PluginInstaller, uninstallPreviewHash, upsertOrgSwitch, } from "./plugin-install.js";
|
|
@@ -187,6 +187,11 @@ let OrgCatalogService = class OrgCatalogService {
|
|
|
187
187
|
let reason;
|
|
188
188
|
const extName = extensionOf(i);
|
|
189
189
|
const why = extName === undefined ? undefined : unloaded.get(extName);
|
|
190
|
+
// The plugin's own `needs_config` (plugin pages spec §5.2.3): its extension, loaded here, has
|
|
191
|
+
// no valid effective config for the org; connector setup shows on the connector cards
|
|
192
|
+
const configInvalid = async () => extName !== undefined &&
|
|
193
|
+
loaded.has(extName) &&
|
|
194
|
+
!(await this.effective.get(orgId, extName)).ok;
|
|
190
195
|
if (i.awaiting_confirmation)
|
|
191
196
|
state = "awaiting_confirmation";
|
|
192
197
|
else if (i.disabled) {
|
|
@@ -202,26 +207,17 @@ let OrgCatalogService = class OrgCatalogService {
|
|
|
202
207
|
reason = why.reason;
|
|
203
208
|
}
|
|
204
209
|
else if (a) {
|
|
205
|
-
|
|
206
|
-
const missing = await this.pluginInstaller.missingConnectors(orgId, i.id);
|
|
207
|
-
state = (missing?.templates.length ?? 0) > 0 ? "needs_config" : "on";
|
|
210
|
+
state = (await configInvalid()) ? "needs_config" : "on";
|
|
208
211
|
}
|
|
209
212
|
else if (i.builtin)
|
|
210
213
|
state = "on";
|
|
211
214
|
else if (!wanted)
|
|
212
215
|
state = "off";
|
|
213
216
|
else {
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
//
|
|
217
|
-
|
|
218
|
-
const needsInputs = (await connectorTemplatesOn(this.db, orgId, i.id, templateIds)).size > 0 ||
|
|
219
|
-
(m?.extension !== undefined &&
|
|
220
|
-
ext !== undefined &&
|
|
221
|
-
!(await this.effective.get(orgId, m.name)).ok);
|
|
222
|
-
// Wanted but not installed and needing nothing: the sync has not installed it (yet, or its
|
|
223
|
-
// install failed); `off`, so an org admin can switch it on (the worker start retries it)
|
|
224
|
-
state = needsInputs ? "needs_config" : "off";
|
|
217
|
+
// Wanted but not installed: the sync has not installed it (yet, or its install failed);
|
|
218
|
+
// `off`, so an org admin can switch it on (the worker start retries it), unless its
|
|
219
|
+
// extension's effective config is not valid here
|
|
220
|
+
state = (await configInvalid()) ? "needs_config" : "off";
|
|
225
221
|
}
|
|
226
222
|
out.push({
|
|
227
223
|
...view,
|
|
@@ -278,7 +274,7 @@ let OrgCatalogService = class OrgCatalogService {
|
|
|
278
274
|
throw itemNotFound();
|
|
279
275
|
const m = v.manifest;
|
|
280
276
|
const templates = await readCatalogTemplates(this.storage, v);
|
|
281
|
-
// Which templates are on in this org now: the install
|
|
277
|
+
// Which templates are on in this org now: the install makes connectors of those, a
|
|
282
278
|
// default-off one an admin switched on included
|
|
283
279
|
const on = await connectorTemplatesOn(this.db, orgId, itemId, templates.map((t) => t.id));
|
|
284
280
|
// Where each template's page finds its setup guide (spec 2026-11-09-setup-guides-v2 §9.3)
|
|
@@ -286,8 +282,7 @@ let OrgCatalogService = class OrgCatalogService {
|
|
|
286
282
|
const g = templateGuideOf(m, templateId);
|
|
287
283
|
return g ? { itemId, guideId: g.id } : null;
|
|
288
284
|
};
|
|
289
|
-
// A template whose connector an earlier switch-off kept: the install reuses it
|
|
290
|
-
// does not ask for its input
|
|
285
|
+
// A template whose connector an earlier switch-off kept: the install reuses it
|
|
291
286
|
const connected = await this.pluginInstaller.connectedTemplates(orgId, itemId);
|
|
292
287
|
// Providers the install would switch on first (a refusal is the install's to report)
|
|
293
288
|
const implied = await this.pluginInstaller
|
|
@@ -297,11 +292,8 @@ let OrgCatalogService = class OrgCatalogService {
|
|
|
297
292
|
return [];
|
|
298
293
|
throw e;
|
|
299
294
|
});
|
|
300
|
-
const missing = item.installed !== null && item.state === "needs_config"
|
|
301
|
-
? ((await this.pluginInstaller.missingConnectors(orgId, itemId))?.templates ?? [])
|
|
302
|
-
: [];
|
|
303
295
|
// Each template's icon on the org's routes (its own, else the plugin's)
|
|
304
|
-
const icons = await this.icons.ofItemTemplates(itemId,
|
|
296
|
+
const icons = await this.icons.ofItemTemplates(itemId, templates.map((t) => t.id), { kind: "org", orgId, isAdmin: await this.isOrgAdmin(orgId, accountId) });
|
|
305
297
|
const iconOf = (templateId) => icons.get(templateId) ?? null;
|
|
306
298
|
return {
|
|
307
299
|
item,
|
|
@@ -319,7 +311,6 @@ let OrgCatalogService = class OrgCatalogService {
|
|
|
319
311
|
],
|
|
320
312
|
skills: (m.skills ?? []).map((s) => packagePath(s.path)),
|
|
321
313
|
agents: (m.agents ?? []).map((a) => packagePath(a.path)),
|
|
322
|
-
missingTemplates: missing.map((t) => orgTemplateView(t.id, t.file, { guide: guideOf(t.id), on: true, icon: iconOf(t.id) })),
|
|
323
314
|
};
|
|
324
315
|
}
|
|
325
316
|
/**
|
|
@@ -138,6 +138,12 @@ export interface PluginReviewTemplate {
|
|
|
138
138
|
editableEndpoint: string[];
|
|
139
139
|
/** The connector is loaded on this replica and the endpoint was checked against its schema. */
|
|
140
140
|
endpointChecked: boolean;
|
|
141
|
+
/**
|
|
142
|
+
* The template's own icon from the package as a `data:` URL (svg or png, at most
|
|
143
|
+
* 64 KiB), null without one. Nothing serves a staged package's files, so
|
|
144
|
+
* the review carries it; display only, not part of {@link pluginReviewHash}.
|
|
145
|
+
*/
|
|
146
|
+
icon: string | null;
|
|
141
147
|
}
|
|
142
148
|
/** One agent template in a review (sub-agents spec §16.2: its tool narrowing and model tier). */
|
|
143
149
|
export interface PluginReviewAgentTemplate {
|
|
@@ -155,7 +161,22 @@ export interface PluginReviewAgentTemplate {
|
|
|
155
161
|
effort?: AgentTemplate["effort"];
|
|
156
162
|
maxSteps?: number;
|
|
157
163
|
skills?: string[];
|
|
164
|
+
/**
|
|
165
|
+
* The connectors the agent needs, from its definition: a connector template id (`<id>` or
|
|
166
|
+
* `<plugin>:<id>`), or a described need with its label, endpoint and protocol; [] without any.
|
|
167
|
+
*/
|
|
168
|
+
connectors: PluginReviewAgentConnector[];
|
|
158
169
|
}
|
|
170
|
+
/** One connector an agent template needs, as its review shows it. */
|
|
171
|
+
export type PluginReviewAgentConnector = {
|
|
172
|
+
template: string;
|
|
173
|
+
} | {
|
|
174
|
+
needs: {
|
|
175
|
+
label: string;
|
|
176
|
+
endpoint: string;
|
|
177
|
+
protocol: "mcp" | "openapi";
|
|
178
|
+
};
|
|
179
|
+
};
|
|
159
180
|
/** One theme in a review (themes spec §6): what the super admin sees before confirming. */
|
|
160
181
|
export interface PluginReviewTheme {
|
|
161
182
|
/** The theme id (the file's base name). */
|
|
@@ -38,7 +38,7 @@ import { Transactional } from "../infra/database/transactional.decorator.js";
|
|
|
38
38
|
import { OutboxService } from "../infra/outbox/outbox.service.js";
|
|
39
39
|
import { KERNEL_LOGGER } from "../infra/tokens.js";
|
|
40
40
|
import { OrgLock } from "../orgs/org-lock.js";
|
|
41
|
-
import { packPackageTgz } from "../packages/tgz.js";
|
|
41
|
+
import { packagePath, packPackageTgz } from "../packages/tgz.js";
|
|
42
42
|
import { checkSkillFiles, SkillArchiveError } from "../skills/package.js";
|
|
43
43
|
import { StorageService } from "../storage/storage.service.js";
|
|
44
44
|
import { canonicalJson } from "../tools/canonical-json.js";
|
|
@@ -1546,12 +1546,29 @@ let PluginImport = class PluginImport {
|
|
|
1546
1546
|
auth: t.auth,
|
|
1547
1547
|
editableEndpoint: t.editableEndpoint ?? [],
|
|
1548
1548
|
endpointChecked: loaded !== undefined,
|
|
1549
|
+
icon: reviewIcon(c.file.icon, pkg.files),
|
|
1549
1550
|
};
|
|
1550
1551
|
});
|
|
1551
1552
|
const agentTemplates = pkg.agentTemplates.map((a) => {
|
|
1552
1553
|
keepObject(a.path);
|
|
1553
|
-
const { name, description, instructions, model, ...rest } = a.template;
|
|
1554
|
-
return {
|
|
1554
|
+
const { name, description, instructions, model, connectors, ...rest } = a.template;
|
|
1555
|
+
return {
|
|
1556
|
+
name,
|
|
1557
|
+
path: a.path,
|
|
1558
|
+
description,
|
|
1559
|
+
instructions,
|
|
1560
|
+
model: model ?? "inherit",
|
|
1561
|
+
...rest,
|
|
1562
|
+
connectors: (connectors ?? []).map((c) => "template" in c
|
|
1563
|
+
? { template: c.template }
|
|
1564
|
+
: {
|
|
1565
|
+
needs: {
|
|
1566
|
+
label: c.needs.label,
|
|
1567
|
+
endpoint: c.needs.endpoint,
|
|
1568
|
+
protocol: c.needs.protocol,
|
|
1569
|
+
},
|
|
1570
|
+
}),
|
|
1571
|
+
};
|
|
1555
1572
|
});
|
|
1556
1573
|
// Themes: the file as written, the assets as sanitized by the reader (never the uploaded
|
|
1557
1574
|
// originals: a shared path, e.g. the plugin icon, is stored sanitized too)
|
|
@@ -1840,6 +1857,19 @@ export function pluginReviewHash(r, files) {
|
|
|
1840
1857
|
]);
|
|
1841
1858
|
return createHash("sha256").update(canonical).digest("hex").slice(0, 32);
|
|
1842
1859
|
}
|
|
1860
|
+
/**
|
|
1861
|
+
* A connector template's icon (package path `icon`) as a `data:` URL for its review, null without
|
|
1862
|
+
* one. The package reader checked it is an svg or png within the size limit.
|
|
1863
|
+
*/
|
|
1864
|
+
function reviewIcon(icon, files) {
|
|
1865
|
+
if (icon === undefined)
|
|
1866
|
+
return null;
|
|
1867
|
+
const data = files.get(packagePath(icon));
|
|
1868
|
+
if (data === undefined)
|
|
1869
|
+
return null;
|
|
1870
|
+
const type = /\.png$/i.test(icon) ? "image/png" : "image/svg+xml";
|
|
1871
|
+
return `data:${type};base64,${Buffer.from(data).toString("base64")}`;
|
|
1872
|
+
}
|
|
1843
1873
|
/** The client code of a read extension package for its review (sizes from the package's files). */
|
|
1844
1874
|
function reviewClient(pkg) {
|
|
1845
1875
|
const c = pkg.section.client;
|