@capybara-hq/kernel 0.1.0-rc.12 → 0.1.0-rc.14
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.schemas.d.ts +13 -0
- package/dist/agents/agent-lookup.d.ts +5 -0
- package/dist/agents/agent-lookup.js +15 -0
- package/dist/background/background.module.js +2 -2
- package/dist/background/launch-lock.d.ts +1 -1
- package/dist/background/launch-lock.js +1 -1
- package/dist/background/poll.job.d.ts +2 -2
- package/dist/background/poll.job.js +10 -10
- package/dist/background/stop.d.ts +1 -1
- package/dist/background/stop.js +3 -3
- package/dist/background/store.d.ts +5 -5
- package/dist/background/store.js +5 -5
- package/dist/background/tasks.service.d.ts +6 -6
- package/dist/background/tasks.service.js +13 -13
- package/dist/catalog/admin-catalog.controller.d.ts +13 -2
- package/dist/catalog/admin-catalog.controller.js +24 -3
- package/dist/catalog/admin-catalog.schemas.d.ts +10 -0
- package/dist/catalog/admin-catalog.schemas.js +7 -0
- package/dist/catalog/catalog-content.d.ts +9 -1
- package/dist/catalog/catalog-content.js +2 -1
- package/dist/catalog/catalog-files.d.ts +3 -2
- package/dist/catalog/catalog-files.js +8 -5
- package/dist/catalog/component-scope.service.d.ts +14 -1
- package/dist/catalog/component-scope.service.js +12 -2
- package/dist/catalog/marketplaces.service.d.ts +1 -1
- package/dist/catalog/org-catalog.controller.d.ts +5 -4
- package/dist/catalog/org-catalog.controller.js +5 -4
- package/dist/catalog/org-catalog.schemas.d.ts +18 -2
- package/dist/catalog/org-catalog.schemas.js +16 -2
- package/dist/catalog/org-catalog.service.js +8 -2
- package/dist/catalog/plugin-import.js +1 -1
- package/dist/catalog/plugin-package.js +37 -9
- package/dist/catalog/plugin-upgrade.d.ts +15 -1
- package/dist/catalog/plugin-upgrade.js +18 -5
- package/dist/channels/channels.module.js +2 -2
- package/dist/channels/connections.controller.d.ts +1 -1
- package/dist/channels/connections.controller.js +1 -1
- package/dist/channels/connections.service.d.ts +22 -5
- package/dist/channels/connections.service.js +56 -10
- package/dist/channels/inbound.d.ts +8 -8
- package/dist/channels/inbound.js +31 -31
- package/dist/channels/phrases.d.ts +27 -27
- package/dist/channels/phrases.js +27 -27
- package/dist/channels/webhook.d.ts +21 -1
- package/dist/channels/webhook.js +39 -4
- package/dist/config/docs.js +1 -1
- package/dist/config/schema.d.ts +2 -2
- package/dist/config/schema.js +21 -21
- package/dist/conversations/conversations.controller.d.ts +11 -11
- package/dist/conversations/conversations.controller.js +15 -15
- package/dist/conversations/conversations.module.d.ts +1 -1
- package/dist/conversations/conversations.module.js +7 -7
- package/dist/conversations/conversations.schemas.js +1 -1
- package/dist/conversations/conversations.service.d.ts +14 -14
- package/dist/conversations/conversations.service.js +19 -19
- package/dist/conversations/{environment-status.d.ts → device-status.d.ts} +9 -9
- package/dist/conversations/{environment-status.js → device-status.js} +18 -18
- package/dist/conversations/event-log.d.ts +1 -1
- package/dist/conversations/event-log.js +1 -1
- package/dist/conversations/events.d.ts +1 -1
- package/dist/conversations/events.js +2 -2
- package/dist/ctx/create-ctx.d.ts +26 -3
- package/dist/ctx/create-ctx.js +134 -26
- package/dist/db/kernel-schema.d.ts +37 -25
- package/dist/{environments → devices}/access.d.ts +19 -19
- package/dist/{environments → devices}/access.js +28 -28
- package/dist/devices/conversation-devices.d.ts +75 -0
- package/dist/{environments/conversation-environments.js → devices/conversation-devices.js} +71 -72
- package/dist/devices/devices.controller.d.ts +36 -0
- package/dist/{environments/environments.controller.js → devices/devices.controller.js} +37 -37
- package/dist/devices/devices.module.d.ts +5 -13
- package/dist/devices/devices.module.js +16 -29
- package/dist/devices/devices.schemas.d.ts +3 -0
- package/dist/devices/devices.schemas.js +14 -0
- package/dist/{environments/environments.service.d.ts → devices/devices.service.d.ts} +70 -70
- package/dist/{environments/environments.service.js → devices/devices.service.js} +122 -122
- package/dist/devices/dto.d.ts +13 -54
- package/dist/devices/dto.js +7 -39
- package/dist/devices/label.d.ts +11 -0
- package/dist/{environments → devices}/label.js +7 -7
- package/dist/{environments → devices}/legacy-cleanup.job.d.ts +3 -3
- package/dist/{environments → devices}/legacy-cleanup.job.js +3 -3
- package/dist/errors.d.ts +29 -25
- package/dist/errors.js +29 -25
- package/dist/evals/recorded-tools.d.ts +2 -2
- package/dist/evals/recorded-tools.js +6 -6
- package/dist/extensions/admin-ops.js +1 -0
- package/dist/extensions/admin-view.js +2 -0
- package/dist/extensions/effective-config.d.ts +6 -0
- package/dist/extensions/effective-config.js +18 -7
- package/dist/extensions/guide-places.d.ts +66 -0
- package/dist/extensions/guide-places.js +152 -0
- package/dist/extensions/host.d.ts +13 -2
- package/dist/extensions/host.js +27 -6
- package/dist/extensions/instance.d.ts +17 -2
- package/dist/extensions/instance.js +21 -0
- package/dist/extensions/ledger.d.ts +1 -1
- package/dist/extensions/permission-set.d.ts +16 -2
- package/dist/extensions/permission-set.js +17 -3
- package/dist/extensions/permission-view.d.ts +10 -1
- package/dist/extensions/plugin-guides.d.ts +207 -54
- package/dist/extensions/plugin-guides.js +436 -165
- package/dist/files/previewers.d.ts +1 -1
- package/dist/files/previewers.js +1 -1
- package/dist/http/api.module.js +16 -6
- package/dist/http/gateway-routes.d.ts +1 -1
- package/dist/http/gateway-routes.js +1 -1
- package/dist/identity/settings.d.ts +32 -0
- package/dist/identity/settings.js +26 -2
- package/dist/infra/config/kernel-config.service.js +4 -4
- package/dist/infra/lock/lock.service.d.ts +8 -0
- package/dist/infra/lock/lock.service.js +27 -0
- package/dist/infra/throttler/named-throttlers.d.ts +4 -1
- package/dist/infra/throttler/named-throttlers.js +16 -1
- package/dist/infra/throttler/throttler.guard.js +1 -1
- package/dist/kernel.module.js +3 -3
- package/dist/{devices → local-devices}/device-auth.controller.d.ts +6 -6
- package/dist/{devices → local-devices}/device-auth.controller.js +5 -5
- package/dist/{devices → local-devices}/device-auth.d.ts +20 -20
- package/dist/{devices → local-devices}/device-auth.js +51 -53
- package/dist/local-devices/device-auth.module.d.ts +7 -0
- package/dist/{devices → local-devices}/device-auth.module.js +5 -5
- package/dist/{devices → local-devices}/device-routes.d.ts +3 -3
- package/dist/{devices → local-devices}/device-routes.js +2 -2
- package/dist/local-devices/dto.d.ts +66 -0
- package/dist/local-devices/dto.js +44 -0
- package/dist/{devices → local-devices}/keys.d.ts +11 -11
- package/dist/{devices → local-devices}/keys.js +11 -11
- package/dist/{devices/device-gateway.d.ts → local-devices/local-device-gateway.d.ts} +14 -14
- package/dist/{devices/device-gateway.js → local-devices/local-device-gateway.js} +44 -44
- package/dist/{devices/device-provider.d.ts → local-devices/local-device-provider.d.ts} +15 -15
- package/dist/{devices/device-provider.js → local-devices/local-device-provider.js} +23 -23
- package/dist/local-devices/local-devices.module.d.ts +16 -0
- package/dist/local-devices/local-devices.module.js +44 -0
- package/dist/{devices → local-devices}/machines.d.ts +26 -26
- package/dist/{devices → local-devices}/machines.js +71 -71
- package/dist/{devices → local-devices}/relay.d.ts +15 -15
- package/dist/{devices → local-devices}/relay.js +55 -55
- package/dist/{devices → local-devices}/targets.d.ts +8 -8
- package/dist/{devices → local-devices}/targets.js +14 -14
- package/dist/orgs/offboarding.d.ts +6 -6
- package/dist/orgs/offboarding.js +12 -12
- package/dist/orgs/settings.service.d.ts +28 -0
- package/dist/orgs/settings.service.js +20 -1
- package/dist/overrides.d.ts +3 -1
- package/dist/overrides.js +2 -0
- package/dist/platform/exclusions.js +48 -8
- package/dist/platform/operation.js +10 -2
- package/dist/platform/ops/admin.ops.js +8 -2
- package/dist/platform/ops/connectors.ops.js +2 -0
- package/dist/platform/ops/conversations.ops.d.ts +3 -3
- package/dist/platform/ops/conversations.ops.js +9 -9
- package/dist/platform/ops/devices.ops.d.ts +26 -0
- package/dist/platform/ops/devices.ops.js +311 -0
- package/dist/platform/ops/org-settings.ops.js +2 -2
- package/dist/platform/ops/orgs.ops.js +1 -0
- package/dist/platform/ops/setup.ops.d.ts +24 -0
- package/dist/platform/ops/setup.ops.js +212 -0
- package/dist/platform/ops/ui.ops.d.ts +8 -0
- package/dist/platform/ops/ui.ops.js +41 -0
- package/dist/platform/platform-ops.module.d.ts +4 -2
- package/dist/platform/platform-ops.module.js +13 -5
- package/dist/platform/route-schemas.js +11 -3
- package/dist/roles/gateway-role.d.ts +3 -3
- package/dist/roles/gateway-role.js +4 -4
- package/dist/roles/gateway.module.d.ts +1 -1
- package/dist/roles/gateway.module.js +5 -5
- package/dist/roles/worker.module.js +1 -1
- package/dist/runtime/context/build.d.ts +1 -1
- package/dist/runtime/context/build.js +6 -6
- package/dist/runtime/context/compaction.js +1 -1
- package/dist/runtime/context/{environment-paths.d.ts → device-paths.d.ts} +11 -11
- package/dist/runtime/context/{environment-paths.js → device-paths.js} +13 -13
- package/dist/runtime/maintenance.d.ts +1 -1
- package/dist/sandbox/jobs.d.ts +13 -13
- package/dist/sandbox/jobs.js +20 -20
- package/dist/sandbox/leases.d.ts +9 -9
- package/dist/sandbox/leases.js +14 -14
- package/dist/sandbox/providers.d.ts +8 -8
- package/dist/sandbox/providers.js +8 -8
- package/dist/sandbox/sandbox.module.d.ts +1 -1
- package/dist/sandbox/sandbox.module.js +1 -1
- package/dist/sandbox/sandbox.service.d.ts +76 -76
- package/dist/sandbox/sandbox.service.js +230 -230
- package/dist/setup/kernel-checks.d.ts +91 -0
- package/dist/setup/kernel-checks.js +295 -0
- package/dist/setup/oauth-token-probe.d.ts +47 -0
- package/dist/setup/oauth-token-probe.js +108 -0
- package/dist/setup/redact-check.d.ts +18 -0
- package/dist/setup/redact-check.js +46 -0
- package/dist/setup/setup-check-registry.d.ts +86 -0
- package/dist/setup/setup-check-registry.js +75 -0
- package/dist/setup/setup-checks.controller.d.ts +28 -0
- package/dist/setup/setup-checks.controller.js +78 -0
- package/dist/setup/setup-checks.schemas.d.ts +38 -0
- package/dist/setup/setup-checks.schemas.js +43 -0
- package/dist/setup/setup-checks.service.d.ts +144 -0
- package/dist/setup/setup-checks.service.js +683 -0
- package/dist/setup/setup-guides.controller.d.ts +18 -0
- package/dist/setup/setup-guides.controller.js +48 -0
- package/dist/setup/setup-guides.schemas.d.ts +10 -0
- package/dist/setup/setup-guides.schemas.js +6 -0
- package/dist/setup/setup-guides.service.d.ts +126 -0
- package/dist/setup/setup-guides.service.js +315 -0
- package/dist/setup/setup.module.d.ts +8 -0
- package/dist/setup/setup.module.js +31 -0
- package/dist/tools/builtins/builtin-tools.d.ts +2 -2
- package/dist/tools/builtins/builtin-tools.js +5 -5
- package/dist/tools/builtins/platform.js +1 -1
- package/dist/tools/builtins/sandbox/bash.js +6 -6
- package/dist/tools/builtins/sandbox/common.d.ts +25 -25
- package/dist/tools/builtins/sandbox/common.js +51 -51
- package/dist/tools/builtins/sandbox/edit.js +2 -2
- package/dist/tools/builtins/sandbox/index.d.ts +1 -1
- package/dist/tools/builtins/sandbox/index.js +1 -1
- package/dist/tools/builtins/sandbox/task-output.d.ts +6 -6
- package/dist/tools/builtins/sandbox/task-output.js +10 -10
- package/dist/tools/builtins/sandbox/task-stop.js +2 -2
- package/dist/tools/builtins/sandbox/write.js +2 -2
- package/dist/tools/builtins/skill-load.d.ts +1 -1
- package/dist/tools/builtins/skill-load.js +2 -2
- package/dist/tools/connectors.controller.d.ts +28 -11
- package/dist/tools/connectors.controller.js +49 -14
- package/dist/tools/connectors.schemas.d.ts +4 -0
- package/dist/tools/connectors.schemas.js +4 -0
- package/dist/tools/connectors.service.d.ts +30 -2
- package/dist/tools/connectors.service.js +98 -3
- package/dist/tools/credentials.d.ts +20 -0
- package/dist/tools/credentials.js +90 -1
- package/dist/tools/oauth/tokens.d.ts +20 -0
- package/dist/tools/oauth/tokens.js +49 -24
- package/dist/tools/pipeline.js +4 -3
- package/dist/tools/registry.d.ts +2 -2
- package/dist/tools/tools.module.js +3 -3
- package/dist/ui/admin-ui.controller.d.ts +56 -0
- package/dist/ui/admin-ui.controller.js +192 -0
- package/dist/ui/arrangement.d.ts +74 -0
- package/dist/ui/arrangement.js +98 -0
- package/dist/ui/embed-token.d.ts +2 -2
- package/dist/ui/embed-token.js +30 -5
- package/dist/ui/registry.d.ts +29 -14
- package/dist/ui/registry.js +31 -10
- package/dist/ui/slots.controller.d.ts +11 -0
- package/dist/ui/slots.controller.js +25 -0
- package/dist/ui/ui-stream.d.ts +20 -3
- package/dist/ui/ui-stream.js +25 -7
- package/dist/ui/ui.schemas.d.ts +66 -0
- package/dist/ui/ui.schemas.js +65 -0
- package/dist/ui/views.controller.d.ts +35 -49
- package/dist/ui/views.controller.js +48 -70
- package/dist/ui/views.d.ts +84 -18
- package/dist/ui/views.js +201 -38
- package/package.json +3 -3
- package/src/migrations/0105_devices_rename.sql +136 -0
- package/src/migrations/0106_setup_guides_v2.sql +10 -0
- package/dist/devices/device-auth.module.d.ts +0 -7
- package/dist/environments/conversation-environments.d.ts +0 -75
- package/dist/environments/dto.d.ts +0 -25
- package/dist/environments/dto.js +0 -12
- package/dist/environments/environments.controller.d.ts +0 -36
- package/dist/environments/environments.module.d.ts +0 -8
- package/dist/environments/environments.module.js +0 -31
- package/dist/environments/environments.schemas.d.ts +0 -3
- package/dist/environments/environments.schemas.js +0 -14
- package/dist/environments/label.d.ts +0 -11
- package/dist/platform/ops/environments.ops.d.ts +0 -26
- package/dist/platform/ops/environments.ops.js +0 -311
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import type { LocalizedName, ThemeScheme } from "@capybara-hq/plugin-sdk";
|
|
2
2
|
import { ApiError } from "../errors.js";
|
|
3
|
+
import { PluginGuides } from "../extensions/plugin-guides.js";
|
|
3
4
|
import { SuperAdminLock } from "../identity/super-admin.js";
|
|
4
5
|
import { KernelDb } from "../infra/database/kernel-db.js";
|
|
5
6
|
import { TransactionHost } from "../infra/database/transaction-host.js";
|
|
@@ -172,6 +173,14 @@ export interface OrgOfferedComponentView extends OrgComponentView {
|
|
|
172
173
|
* name as its owner (本组织 for the viewing org's own, the owner's name for another org's).
|
|
173
174
|
*/
|
|
174
175
|
owner: Owner;
|
|
176
|
+
/**
|
|
177
|
+
* Connector templates only: the template's setup guide in its plugin's latest version (`GET
|
|
178
|
+
* …/catalog/:itemId/guides/:guideId`), null without one (spec 2026-11-09-setup-guides-v2 §9.3).
|
|
179
|
+
*/
|
|
180
|
+
guide?: {
|
|
181
|
+
itemId: string;
|
|
182
|
+
guideId: string;
|
|
183
|
+
} | null;
|
|
175
184
|
}
|
|
176
185
|
/** The result of an org switch: the component, or (switching off without `confirm`) the preview. */
|
|
177
186
|
export type ComponentSwitchResult = {
|
|
@@ -231,11 +240,15 @@ export declare class ComponentScopeService {
|
|
|
231
240
|
/** Promote on share (ruling P3-3): an org row shown or associated becomes a platform row. */
|
|
232
241
|
private readonly promotion;
|
|
233
242
|
readonly txHost: TransactionHost;
|
|
243
|
+
/** The connector templates' setup guides (the org list's `guide`). */
|
|
244
|
+
private readonly guides;
|
|
234
245
|
constructor(kdb: KernelDb, adminLock: SuperAdminLock,
|
|
235
246
|
/** The org row lock (orgs/org-lock.ts): joins the caller's transaction. */
|
|
236
247
|
orgLock: OrgLock,
|
|
237
248
|
/** Promote on share (ruling P3-3): an org row shown or associated becomes a platform row. */
|
|
238
|
-
promotion: ComponentPromotion, txHost: TransactionHost
|
|
249
|
+
promotion: ComponentPromotion, txHost: TransactionHost,
|
|
250
|
+
/** The connector templates' setup guides (the org list's `guide`). */
|
|
251
|
+
guides: Pick<PluginGuides, "templateGuides">);
|
|
239
252
|
private get db();
|
|
240
253
|
/**
|
|
241
254
|
* What the admin routes act on (ruling P3-23): the platform component `id`, an org row the org
|
|
@@ -12,6 +12,7 @@ import { Inject, Injectable } from "@nestjs/common";
|
|
|
12
12
|
import { sql } from "kysely";
|
|
13
13
|
import { templateTypeClashes, templateTypeOf } from "../agents/templates.js";
|
|
14
14
|
import { ApiError } from "../errors.js";
|
|
15
|
+
import { PluginGuides } from "../extensions/plugin-guides.js";
|
|
15
16
|
import { audit } from "../identity/audit.js";
|
|
16
17
|
import { SuperAdminLock } from "../identity/super-admin.js";
|
|
17
18
|
import { notifyItemShared } from "../inbox/org-notices.js";
|
|
@@ -124,16 +125,20 @@ let ComponentScopeService = class ComponentScopeService {
|
|
|
124
125
|
orgLock;
|
|
125
126
|
promotion;
|
|
126
127
|
txHost;
|
|
128
|
+
guides;
|
|
127
129
|
constructor(kdb, adminLock,
|
|
128
130
|
/** The org row lock (orgs/org-lock.ts): joins the caller's transaction. */
|
|
129
131
|
orgLock,
|
|
130
132
|
/** Promote on share (ruling P3-3): an org row shown or associated becomes a platform row. */
|
|
131
|
-
promotion, txHost
|
|
133
|
+
promotion, txHost,
|
|
134
|
+
/** The connector templates' setup guides (the org list's `guide`). */
|
|
135
|
+
guides) {
|
|
132
136
|
this.kdb = kdb;
|
|
133
137
|
this.adminLock = adminLock;
|
|
134
138
|
this.orgLock = orgLock;
|
|
135
139
|
this.promotion = promotion;
|
|
136
140
|
this.txHost = txHost;
|
|
141
|
+
this.guides = guides;
|
|
137
142
|
}
|
|
138
143
|
get db() {
|
|
139
144
|
return this.kdb.db;
|
|
@@ -245,6 +250,9 @@ let ComponentScopeService = class ComponentScopeService {
|
|
|
245
250
|
const st = await loadScopeState(this.db, kind, comps);
|
|
246
251
|
const linked = await this.linkedCopies(orgId, kind);
|
|
247
252
|
const owners = await ownersOf(this.db, comps.flatMap((c) => (c.ownerOrgId === null ? [] : [c.ownerOrgId])));
|
|
253
|
+
const guides = kind === "connector_template"
|
|
254
|
+
? await this.guides.templateGuides(comps.flatMap((c) => c.itemId === null ? [] : [{ itemId: c.itemId, templateId: c.name }]))
|
|
255
|
+
: undefined;
|
|
248
256
|
const rows = [];
|
|
249
257
|
for (const c of comps) {
|
|
250
258
|
const p = pluginFactsOf(st, c.itemId, orgId);
|
|
@@ -273,6 +281,7 @@ let ComponentScopeService = class ComponentScopeService {
|
|
|
273
281
|
platformDefault: !locked && (c.scopeMode === "follow" ? p?.scope === "all" : c.scope === "all"),
|
|
274
282
|
linkedIds: linked.get(c.id) ?? [],
|
|
275
283
|
owner: ownerOf(c.ownerOrgId, owners),
|
|
284
|
+
...(guides !== undefined && { guide: guides.get(`${c.itemId}/${c.name}`) ?? null }),
|
|
276
285
|
});
|
|
277
286
|
}
|
|
278
287
|
rows.sort((a, b) => a.name < b.name ? -1 : a.name > b.name ? 1 : a.id < b.id ? -1 : a.id > b.id ? 1 : 0);
|
|
@@ -1067,7 +1076,8 @@ ComponentScopeService = __decorate([
|
|
|
1067
1076
|
__param(1, Inject(SuperAdminLock)),
|
|
1068
1077
|
__param(2, Inject(OrgLock)),
|
|
1069
1078
|
__param(3, Inject(ComponentPromotion)),
|
|
1070
|
-
__param(4, Inject(TransactionHost))
|
|
1079
|
+
__param(4, Inject(TransactionHost)),
|
|
1080
|
+
__param(5, Inject(PluginGuides))
|
|
1071
1081
|
], ComponentScopeService);
|
|
1072
1082
|
export { ComponentScopeService };
|
|
1073
1083
|
/** Whether `c` is the platform default theme `uiTheme` (locked on in every org, themes spec §7). */
|
|
@@ -188,7 +188,7 @@ export declare function headsToResolve(entries: readonly MarketplaceEntry[], imp
|
|
|
188
188
|
/** The host versions (an entry's `minKernel` is judged against them). */
|
|
189
189
|
export declare const HOST_VERSIONS: {
|
|
190
190
|
readonly kernel: string;
|
|
191
|
-
readonly sdk: "0.1.0-rc.
|
|
191
|
+
readonly sdk: "0.1.0-rc.10";
|
|
192
192
|
};
|
|
193
193
|
/** Whether this deployment satisfies the entry's `minKernel`. */
|
|
194
194
|
export declare const entryCompatible: (e: Pick<MarketplaceEntry, "minKernel">) => boolean;
|
|
@@ -98,10 +98,11 @@ export declare class OrgCatalogController {
|
|
|
98
98
|
*/
|
|
99
99
|
icon(org: OrgContext, itemId: string, reply: FastifyReply): Promise<void>;
|
|
100
100
|
/**
|
|
101
|
-
* A setup guide of the item, rendered for this org (spec 2026-11-
|
|
102
|
-
* §
|
|
103
|
-
*
|
|
104
|
-
*
|
|
101
|
+
* A setup guide of the item, rendered for this org (spec 2026-11-09-setup-guides-v2-design.md
|
|
102
|
+
* §7.2): the document's blocks with the place's variables filled in, its modes, audiences and
|
|
103
|
+
* checks, the unresolved variables with their reasons, the drift hash and the target. The item
|
|
104
|
+
* must be one the org's catalog shows; the place and audience's action (`channels.manage`,
|
|
105
|
+
* `connectors.manage`, `connectors.use`) is checked by the service.
|
|
105
106
|
*/
|
|
106
107
|
guide(org: OrgContext, itemId: string, guideId: string, q: z.infer<typeof CatalogGuideQuery>): Promise<{
|
|
107
108
|
guide: RenderedSetupGuide;
|
|
@@ -129,10 +129,11 @@ let OrgCatalogController = class OrgCatalogController {
|
|
|
129
129
|
await sendCatalogIcon(reply, icon);
|
|
130
130
|
}
|
|
131
131
|
/**
|
|
132
|
-
* A setup guide of the item, rendered for this org (spec 2026-11-
|
|
133
|
-
* §
|
|
134
|
-
*
|
|
135
|
-
*
|
|
132
|
+
* A setup guide of the item, rendered for this org (spec 2026-11-09-setup-guides-v2-design.md
|
|
133
|
+
* §7.2): the document's blocks with the place's variables filled in, its modes, audiences and
|
|
134
|
+
* checks, the unresolved variables with their reasons, the drift hash and the target. The item
|
|
135
|
+
* must be one the org's catalog shows; the place and audience's action (`channels.manage`,
|
|
136
|
+
* `connectors.manage`, `connectors.use`) is checked by the service.
|
|
136
137
|
*/
|
|
137
138
|
async guide(org, itemId, guideId, q) {
|
|
138
139
|
return { guide: await this.guides.render(org, itemId, guideId, q) };
|
|
@@ -63,6 +63,11 @@ export declare const OrgPluginSwitchBody: z.ZodObject<{
|
|
|
63
63
|
export declare const CatalogItemPathParams: z.ZodObject<{
|
|
64
64
|
itemId: z.ZodString;
|
|
65
65
|
}, z.core.$strip>;
|
|
66
|
+
/** `:itemId` / `:guideId` of the guide route (`@Param`). */
|
|
67
|
+
export declare const CatalogGuidePathParams: z.ZodObject<{
|
|
68
|
+
itemId: z.ZodString;
|
|
69
|
+
guideId: z.ZodString;
|
|
70
|
+
}, z.core.$strip>;
|
|
66
71
|
/** `:installId` as the uninstall route takes it (`@Param`). */
|
|
67
72
|
export declare const PluginInstallPathParams: z.ZodObject<{
|
|
68
73
|
installId: z.ZodString;
|
|
@@ -77,12 +82,23 @@ export declare const CatalogRequestsListQuery: z.ZodObject<{
|
|
|
77
82
|
}>>;
|
|
78
83
|
}, z.core.$strip>;
|
|
79
84
|
/**
|
|
80
|
-
* `GET catalog/:itemId/guides/:guideId
|
|
81
|
-
*
|
|
85
|
+
* `GET catalog/:itemId/guides/:guideId` (spec 2026-11-09-setup-guides-v2-design.md §7.2): the mode
|
|
86
|
+
* and audience to render (the place's, checked by the service), the document language, and the
|
|
87
|
+
* target: a channel connection or the name typed so far on 新建渠道 (`channel-connection`), a
|
|
88
|
+
* connector made from the template (`connector-template`).
|
|
82
89
|
*/
|
|
83
90
|
export declare const CatalogGuideQuery: z.ZodObject<{
|
|
84
91
|
mode: z.ZodOptional<z.ZodString>;
|
|
92
|
+
audience: z.ZodOptional<z.ZodEnum<{
|
|
93
|
+
admin: "admin";
|
|
94
|
+
member: "member";
|
|
95
|
+
}>>;
|
|
96
|
+
locale: z.ZodOptional<z.ZodEnum<{
|
|
97
|
+
en: "en";
|
|
98
|
+
zh: "zh";
|
|
99
|
+
}>>;
|
|
85
100
|
connectionId: z.ZodOptional<z.ZodString>;
|
|
86
101
|
name: z.ZodOptional<z.ZodString>;
|
|
102
|
+
connectorId: z.ZodOptional<z.ZodString>;
|
|
87
103
|
}, z.core.$strict>;
|
|
88
104
|
export declare const ORG_CATALOG_ROUTES: readonly RouteSchemas[];
|
|
@@ -53,6 +53,10 @@ export const OrgPluginSwitchBody = z
|
|
|
53
53
|
.strict();
|
|
54
54
|
/** `:itemId` as the routes take it (`@Param`). */
|
|
55
55
|
export const CatalogItemPathParams = z.object({ itemId: z.string().min(1) });
|
|
56
|
+
/** `:itemId` / `:guideId` of the guide route (`@Param`). */
|
|
57
|
+
export const CatalogGuidePathParams = CatalogItemPathParams.extend({
|
|
58
|
+
guideId: z.string().min(1).max(64),
|
|
59
|
+
});
|
|
56
60
|
/** `:installId` as the uninstall route takes it (`@Param`). */
|
|
57
61
|
export const PluginInstallPathParams = z.object({ installId: z.string().min(1) });
|
|
58
62
|
/** The super admin's request list filter. */
|
|
@@ -60,19 +64,29 @@ export const CatalogRequestsListQuery = z.object({
|
|
|
60
64
|
status: z.enum(["pending", "approved", "rejected", "cancelled"]).optional(),
|
|
61
65
|
});
|
|
62
66
|
/**
|
|
63
|
-
* `GET catalog/:itemId/guides/:guideId
|
|
64
|
-
*
|
|
67
|
+
* `GET catalog/:itemId/guides/:guideId` (spec 2026-11-09-setup-guides-v2-design.md §7.2): the mode
|
|
68
|
+
* and audience to render (the place's, checked by the service), the document language, and the
|
|
69
|
+
* target: a channel connection or the name typed so far on 新建渠道 (`channel-connection`), a
|
|
70
|
+
* connector made from the template (`connector-template`).
|
|
65
71
|
*/
|
|
66
72
|
export const CatalogGuideQuery = z
|
|
67
73
|
.object({
|
|
68
74
|
mode: z.string().min(1).max(64).optional(),
|
|
75
|
+
audience: z.enum(["admin", "member"]).optional(),
|
|
76
|
+
locale: z.enum(["en", "zh"]).optional(),
|
|
69
77
|
connectionId: z.string().min(1).max(100).optional(),
|
|
70
78
|
name: z.string().max(100).optional(),
|
|
79
|
+
connectorId: z.string().min(1).max(100).optional(),
|
|
71
80
|
})
|
|
72
81
|
.strict();
|
|
73
82
|
export const ORG_CATALOG_ROUTES = [
|
|
74
83
|
{ route: "GET /api/v1/orgs/:orgId/catalog" },
|
|
75
84
|
{ route: "GET /api/v1/orgs/:orgId/catalog/:itemId", params: CatalogItemPathParams },
|
|
85
|
+
{
|
|
86
|
+
route: "GET /api/v1/orgs/:orgId/catalog/:itemId/guides/:guideId",
|
|
87
|
+
params: CatalogGuidePathParams,
|
|
88
|
+
query: CatalogGuideQuery,
|
|
89
|
+
},
|
|
76
90
|
{
|
|
77
91
|
route: "POST /api/v1/orgs/:orgId/catalog/:itemId/requests",
|
|
78
92
|
params: CatalogItemPathParams,
|
|
@@ -9,6 +9,7 @@ var __param = (this && this.__param) || function (paramIndex, decorator) {
|
|
|
9
9
|
};
|
|
10
10
|
import { Inject, Injectable } from "@nestjs/common";
|
|
11
11
|
import { ApiError } from "../errors.js";
|
|
12
|
+
import { templateGuideOf } from "../extensions/plugin-guides.js";
|
|
12
13
|
import { ExtensionRegistry } from "../extensions/registry.js";
|
|
13
14
|
import { ExtensionAvailability } from "../extensions/unavailable.js";
|
|
14
15
|
import { KernelDb } from "../infra/database/kernel-db.js";
|
|
@@ -272,6 +273,11 @@ let OrgCatalogService = class OrgCatalogService {
|
|
|
272
273
|
throw itemNotFound();
|
|
273
274
|
const m = v.manifest;
|
|
274
275
|
const templates = await readCatalogTemplates(this.storage, v);
|
|
276
|
+
// where each template's page finds its setup guide (spec 2026-11-09-setup-guides-v2 §9.3)
|
|
277
|
+
const guideOf = (templateId) => {
|
|
278
|
+
const g = templateGuideOf(m, templateId);
|
|
279
|
+
return g ? { itemId, guideId: g.id } : null;
|
|
280
|
+
};
|
|
275
281
|
// Providers the install would switch on first (a refusal is the install's to report)
|
|
276
282
|
const implied = await this.pluginInstaller
|
|
277
283
|
.impliedProviders(orgId, m, templates, m.dependencies ?? [])
|
|
@@ -284,7 +290,7 @@ let OrgCatalogService = class OrgCatalogService {
|
|
|
284
290
|
item,
|
|
285
291
|
hasIcon: m.icon !== undefined,
|
|
286
292
|
extension: m.extension ? m.name : null,
|
|
287
|
-
templates: templates.map((t) => orgTemplateView(t.id, t.file)),
|
|
293
|
+
templates: templates.map((t) => orgTemplateView(t.id, t.file, guideOf(t.id))),
|
|
288
294
|
dependencies: [
|
|
289
295
|
...(m.dependencies ?? []).map((d) => ({ name: d.name, range: d.version })),
|
|
290
296
|
...implied.map((d) => ({ name: d.name, range: d.range, implied: true })),
|
|
@@ -292,7 +298,7 @@ let OrgCatalogService = class OrgCatalogService {
|
|
|
292
298
|
skills: (m.skills ?? []).map((s) => packagePath(s.path)),
|
|
293
299
|
agents: (m.agents ?? []).map((a) => packagePath(a.path)),
|
|
294
300
|
missingTemplates: item.installed !== null && item.state === "needs_config"
|
|
295
|
-
? ((await this.pluginInstaller.missingConnectors(orgId, itemId))?.templates ?? []).map((t) => orgTemplateView(t.id, t.file))
|
|
301
|
+
? ((await this.pluginInstaller.missingConnectors(orgId, itemId))?.templates ?? []).map((t) => orgTemplateView(t.id, t.file, guideOf(t.id)))
|
|
296
302
|
: [],
|
|
297
303
|
};
|
|
298
304
|
}
|
|
@@ -1377,7 +1377,7 @@ let PluginImport = class PluginImport {
|
|
|
1377
1377
|
if (stored.has(path))
|
|
1378
1378
|
objectPaths.add(path);
|
|
1379
1379
|
};
|
|
1380
|
-
// The plugin icon and the setup guide
|
|
1380
|
+
// The plugin icon and the setup guide documents (rendered by PluginGuides): display files
|
|
1381
1381
|
const displayPaths = displayFilePaths(m, pkg.connectorTemplates.flatMap((c) => (c.file.icon === undefined ? [] : [c.file.icon])));
|
|
1382
1382
|
for (const path of displayPaths)
|
|
1383
1383
|
keep(path);
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { createHash } from "node:crypto";
|
|
2
|
-
import { AGENT_TEMPLATE_LIMITS, CATALOG_ITEM_NAME_RE, CONNECTOR_TEMPLATE_LIMITS, hostSdkProblem, PLUGIN_MANIFEST_FILE, PLUGIN_MANIFEST_LIMITS, parseAgentTemplate, parseConnectorTemplateFile, parsePluginManifest, parseSkillMd, parseThemeFile, SKILL_ENTRY_FILE,
|
|
2
|
+
import { AGENT_TEMPLATE_LIMITS, CATALOG_ITEM_NAME_RE, CONNECTOR_TEMPLATE_LIMITS, hostSdkProblem, PLUGIN_MANIFEST_FILE, PLUGIN_MANIFEST_LIMITS, parseAgentTemplate, parseConnectorTemplateFile, parsePluginManifest, parseSkillMd, parseThemeFile, SKILL_ENTRY_FILE, setupGuideDocPath, setupGuideDocProblem, THEME_LIMITS, themeIdOf, validatePluginPackageJsonFor, validateSetupGuide, validateThemeAssets, } from "@capybara-hq/plugin-sdk";
|
|
3
3
|
import { ApiError } from "../errors.js";
|
|
4
4
|
import { HOST_ZOD_VERSION, LEGACY_FORMAT_MESSAGE, PackageTgzError, packagePath, parsePackageJsonFile, unpackPackageTgz, } from "../packages/tgz.js";
|
|
5
5
|
export { LEGACY_FORMAT_MESSAGE, packagePath };
|
|
@@ -362,18 +362,46 @@ export function readPluginFiles(files, opts) {
|
|
|
362
362
|
issues.push(`icon: ${problem}`);
|
|
363
363
|
}
|
|
364
364
|
const ext = manifest.extension;
|
|
365
|
-
// Setup guides
|
|
366
|
-
//
|
|
367
|
-
// the manifest parser checks when the
|
|
365
|
+
// Setup guides v2 (spec 2026-11-09-setup-guides-v2-design.md §4.5): the documents are text
|
|
366
|
+
// within the limits and pass the SDK validator (an unknown variable is accepted: it renders as
|
|
367
|
+
// written); a channel guide needs a channel extension, which the manifest parser checks when the
|
|
368
|
+
// extension section is there; a template guide names one of the plugin's connector templates
|
|
369
|
+
const templateIds = new Set(connectorTemplates.map((t) => t.id));
|
|
368
370
|
manifest.setupGuides?.forEach((g, i) => {
|
|
371
|
+
const at = `setupGuides.${i} (${g.id})`;
|
|
369
372
|
if (g.place === "channel-connection" && ext === undefined) {
|
|
370
|
-
issues.push(
|
|
373
|
+
issues.push(`${at}: a channel-connection guide needs the plugin's extension to provide channel@1`);
|
|
371
374
|
}
|
|
372
|
-
|
|
373
|
-
|
|
375
|
+
// a listed template is checked by the manifest parser; scanned ones only here
|
|
376
|
+
if (g.template !== undefined &&
|
|
377
|
+
manifest.connectorTemplates === undefined &&
|
|
378
|
+
!templateIds.has(g.template)) {
|
|
379
|
+
issues.push(`${at}: template ${g.template} is not one of the plugin's connector templates`);
|
|
380
|
+
}
|
|
381
|
+
const docs = {};
|
|
382
|
+
for (const locale of ["en", "zh"]) {
|
|
383
|
+
const path = setupGuideDocPath(g.id, locale);
|
|
384
|
+
const data = files.get(path);
|
|
385
|
+
if (locale === "zh" && data === undefined)
|
|
386
|
+
continue;
|
|
387
|
+
const problem = setupGuideDocProblem(path, data);
|
|
374
388
|
if (problem !== undefined)
|
|
375
|
-
issues.push(
|
|
376
|
-
|
|
389
|
+
issues.push(`${at}: ${problem}`);
|
|
390
|
+
else
|
|
391
|
+
docs[locale] = new TextDecoder().decode(data);
|
|
392
|
+
}
|
|
393
|
+
if (docs.en === undefined)
|
|
394
|
+
return;
|
|
395
|
+
for (const issue of validateSetupGuide({
|
|
396
|
+
place: g.place,
|
|
397
|
+
en: docs.en,
|
|
398
|
+
...(docs.zh !== undefined && { zh: docs.zh }),
|
|
399
|
+
id: g.id,
|
|
400
|
+
allowUnknownVariables: true,
|
|
401
|
+
})) {
|
|
402
|
+
if (issue.level === "error")
|
|
403
|
+
issues.push(`${at}: ${issue.message}`);
|
|
404
|
+
}
|
|
377
405
|
});
|
|
378
406
|
if (ext !== undefined) {
|
|
379
407
|
if (!files.has(packagePath(ext.entry))) {
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import type { PluginManifest } from "@capybara-hq/plugin-sdk";
|
|
2
2
|
import { ExtensionAdminOps } from "../extensions/admin-ops.js";
|
|
3
3
|
import { ExtensionBlobs } from "../extensions/blobs.js";
|
|
4
|
+
import { PluginGuides, type TemplateGuideChange } from "../extensions/plugin-guides.js";
|
|
4
5
|
import { ExtensionRegistry } from "../extensions/registry.js";
|
|
5
6
|
import type { SingleProviderNote } from "../extensions/single-provider.js";
|
|
6
7
|
import { SuperAdminLock } from "../identity/super-admin.js";
|
|
@@ -110,6 +111,13 @@ export interface PlatformUpdatePreview {
|
|
|
110
111
|
needsApproval: boolean;
|
|
111
112
|
} | null;
|
|
112
113
|
connectorOrgs: PlatformUpdateConnectorOrg[];
|
|
114
|
+
/**
|
|
115
|
+
* Connector templates whose setup guide the update changes (code blocks or checks of the admin
|
|
116
|
+
* text): "the setup guide of template X changed; org admins of N orgs will be asked to update
|
|
117
|
+
* their app" (spec 2026-11-09-setup-guides-v2-design.md §11). Counts only. Not covered by
|
|
118
|
+
* `diffHash` (nothing the confirm does depends on it).
|
|
119
|
+
*/
|
|
120
|
+
guideChanges: TemplateGuideChange[];
|
|
113
121
|
/**
|
|
114
122
|
* The themes the update removes that are on in some org (themes spec §6): the orgs whose default
|
|
115
123
|
* each is and how many people picked it. Absent when no such theme is removed.
|
|
@@ -211,14 +219,20 @@ export declare class PlatformPluginUpdater {
|
|
|
211
219
|
private readonly connectors;
|
|
212
220
|
private readonly sync;
|
|
213
221
|
private readonly log;
|
|
222
|
+
/** The connector template guides an update changes (the preview's `guideChanges`). */
|
|
223
|
+
private readonly guides;
|
|
214
224
|
constructor(kdb: KernelDb, txHost: TransactionHost, adminLock: SuperAdminLock, itemLock: CatalogItemLock, orgLock: OrgLock, locks: LockService, storage: StorageService, registry: ExtensionRegistry, ops: ExtensionAdminOps,
|
|
215
225
|
/** Reads the target's extension package (its permissions, for `needsApproval`). */
|
|
216
226
|
blobs: ExtensionBlobs, config: KernelConfigService, platform: PlatformComponents,
|
|
217
227
|
/** Template dependencies (the deployed connector kinds). */
|
|
218
|
-
installer: PluginInstaller, connectors: ConnectorsService, sync: PluginScopeSync, log: KernelLogger
|
|
228
|
+
installer: PluginInstaller, connectors: ConnectorsService, sync: PluginScopeSync, log: KernelLogger,
|
|
229
|
+
/** The connector template guides an update changes (the preview's `guideChanges`). */
|
|
230
|
+
guides: Pick<PluginGuides, "templateGuideChanges">);
|
|
219
231
|
private get db();
|
|
220
232
|
/** The update preview (see the class comment); writes nothing. */
|
|
221
233
|
preview(itemId: string, version: string): Promise<PlatformUpdatePreview>;
|
|
234
|
+
/** The preview of a diff with the template guides it changes. */
|
|
235
|
+
private withGuideChanges;
|
|
222
236
|
/**
|
|
223
237
|
* The update preview of a new version of an org's own plugin (ruling P3-12): the item must be
|
|
224
238
|
* owned by `orgId` (else 404, as for any item the org cannot see), the target carries no
|
|
@@ -20,6 +20,7 @@ import { ExtensionAdminOps } from "../extensions/admin-ops.js";
|
|
|
20
20
|
import { ExtensionBlobs } from "../extensions/blobs.js";
|
|
21
21
|
import { permissionSetOfPackage, readExtensionPackage } from "../extensions/package.js";
|
|
22
22
|
import { blockingKeys, diffPermissions } from "../extensions/permission-set.js";
|
|
23
|
+
import { PluginGuides } from "../extensions/plugin-guides.js";
|
|
23
24
|
import { ExtensionRegistry } from "../extensions/registry.js";
|
|
24
25
|
import { audit } from "../identity/audit.js";
|
|
25
26
|
import { SuperAdminLock } from "../identity/super-admin.js";
|
|
@@ -143,11 +144,14 @@ let PlatformPluginUpdater = class PlatformPluginUpdater {
|
|
|
143
144
|
connectors;
|
|
144
145
|
sync;
|
|
145
146
|
log;
|
|
147
|
+
guides;
|
|
146
148
|
constructor(kdb, txHost, adminLock, itemLock, orgLock, locks, storage, registry, ops,
|
|
147
149
|
/** Reads the target's extension package (its permissions, for `needsApproval`). */
|
|
148
150
|
blobs, config, platform,
|
|
149
151
|
/** Template dependencies (the deployed connector kinds). */
|
|
150
|
-
installer, connectors, sync, log
|
|
152
|
+
installer, connectors, sync, log,
|
|
153
|
+
/** The connector template guides an update changes (the preview's `guideChanges`). */
|
|
154
|
+
guides) {
|
|
151
155
|
this.kdb = kdb;
|
|
152
156
|
this.txHost = txHost;
|
|
153
157
|
this.adminLock = adminLock;
|
|
@@ -164,13 +168,21 @@ let PlatformPluginUpdater = class PlatformPluginUpdater {
|
|
|
164
168
|
this.connectors = connectors;
|
|
165
169
|
this.sync = sync;
|
|
166
170
|
this.log = log;
|
|
171
|
+
this.guides = guides;
|
|
167
172
|
}
|
|
168
173
|
get db() {
|
|
169
174
|
return this.kdb.db;
|
|
170
175
|
}
|
|
171
176
|
/** The update preview (see the class comment); writes nothing. */
|
|
172
177
|
async preview(itemId, version) {
|
|
173
|
-
return
|
|
178
|
+
return this.withGuideChanges(await this.diff(itemId, version));
|
|
179
|
+
}
|
|
180
|
+
/** The preview of a diff with the template guides it changes. */
|
|
181
|
+
async withGuideChanges(d) {
|
|
182
|
+
return {
|
|
183
|
+
...previewOf(d),
|
|
184
|
+
guideChanges: await this.guides.templateGuideChanges(d.itemId, d.from, d.to),
|
|
185
|
+
};
|
|
174
186
|
}
|
|
175
187
|
/**
|
|
176
188
|
* The update preview of a new version of an org's own plugin (ruling P3-12): the item must be
|
|
@@ -186,7 +198,7 @@ let PlatformPluginUpdater = class PlatformPluginUpdater {
|
|
|
186
198
|
if (staged !== undefined && staged.version !== version) {
|
|
187
199
|
throw new Error(`internal: previewForOwner got the staged target of version ${staged.version} for version ${version}`);
|
|
188
200
|
}
|
|
189
|
-
const preview =
|
|
201
|
+
const preview = await this.withGuideChanges(await this.diff(itemId, version, {
|
|
190
202
|
owner: { orgId },
|
|
191
203
|
...(staged !== undefined && { target: staged }),
|
|
192
204
|
}));
|
|
@@ -1502,10 +1514,11 @@ PlatformPluginUpdater = __decorate([
|
|
|
1502
1514
|
__param(12, Inject(PluginInstaller)),
|
|
1503
1515
|
__param(13, Inject(ConnectorsService)),
|
|
1504
1516
|
__param(14, Inject(PluginScopeSync)),
|
|
1505
|
-
__param(15, Inject(KERNEL_LOGGER))
|
|
1517
|
+
__param(15, Inject(KERNEL_LOGGER)),
|
|
1518
|
+
__param(16, Inject(PluginGuides))
|
|
1506
1519
|
], PlatformPluginUpdater);
|
|
1507
1520
|
export { PlatformPluginUpdater };
|
|
1508
|
-
/** The preview of a diff. */
|
|
1521
|
+
/** The preview of a diff (without `guideChanges`, which reads PG). */
|
|
1509
1522
|
function previewOf(d) {
|
|
1510
1523
|
return {
|
|
1511
1524
|
itemId: d.itemId,
|
|
@@ -12,7 +12,7 @@ import { OnWorkerEvent, WorkerHost } from "@nestjs/bullmq";
|
|
|
12
12
|
import { Inject, Injectable, Module } from "@nestjs/common";
|
|
13
13
|
import { ConversationsModule } from "../conversations/conversations.module.js";
|
|
14
14
|
import { EventLogModule } from "../conversations/event-log.js";
|
|
15
|
-
import {
|
|
15
|
+
import { DevicesModule } from "../devices/devices.module.js";
|
|
16
16
|
import { ExtensionsModule } from "../extensions/extensions.module.js";
|
|
17
17
|
import { IdentityModule } from "../identity/identity.module.js";
|
|
18
18
|
import { configuredProcessor, } from "../infra/queue/configured-processor.js";
|
|
@@ -39,7 +39,7 @@ let ChannelsModule = class ChannelsModule {
|
|
|
39
39
|
ChannelsModule = __decorate([
|
|
40
40
|
Module({
|
|
41
41
|
imports: [
|
|
42
|
-
|
|
42
|
+
DevicesModule,
|
|
43
43
|
EventLogModule,
|
|
44
44
|
ExtensionsModule,
|
|
45
45
|
IdentityModule,
|
|
@@ -13,7 +13,7 @@ import { ChannelConnections, type ChannelConnectionView } from "./connections.se
|
|
|
13
13
|
* the URL of its plugin's icon on the org's catalog route (null without one, or when the org may
|
|
14
14
|
* not see the plugin's catalog item; maintainer decision 2026-11-08), and its plugin's setup guide
|
|
15
15
|
* with the drift since the connection was set up (`setupGuide`, `guideDrift`; spec
|
|
16
|
-
* 2026-11-
|
|
16
|
+
* 2026-11-09-setup-guides-v2-design.md §11).
|
|
17
17
|
*/
|
|
18
18
|
export type ChannelConnectionPage = ChannelConnectionView & ConnectionGuideState & {
|
|
19
19
|
pluginDisplayName: LocalizedName | null;
|
|
@@ -93,7 +93,7 @@ let ChannelConnectionsController = class ChannelConnectionsController {
|
|
|
93
93
|
*/
|
|
94
94
|
async ackGuide(principal, org, id, body) {
|
|
95
95
|
const p = requireUser(principal);
|
|
96
|
-
const view = await this.channels.ackGuide(org.orgId, id, body.hash, p.account.id, patTokenId(p));
|
|
96
|
+
const view = await this.channels.ackGuide({ orgId: org.orgId, role: org.role }, id, body.hash, p.account.id, patTokenId(p));
|
|
97
97
|
return { channel: await this.withPlugin(org, view) };
|
|
98
98
|
}
|
|
99
99
|
async remove(principal, org, id) {
|
|
@@ -12,6 +12,7 @@ import { TransactionHost } from "../infra/database/transaction-host.js";
|
|
|
12
12
|
import { KernelEvents } from "../infra/events/kernel-events.js";
|
|
13
13
|
import { type KernelLogger } from "../log.js";
|
|
14
14
|
import { OrgLock } from "../orgs/org-lock.js";
|
|
15
|
+
import type { OrgRole } from "../orgs/roles.js";
|
|
15
16
|
import { ChannelJobs } from "./jobs.js";
|
|
16
17
|
import type { ChannelLocale } from "./phrases.js";
|
|
17
18
|
/** 连接配置里全部密钥字段存成一行:`{ 点路径: 值 }` 的 JSON。 */
|
|
@@ -112,7 +113,7 @@ export declare class ChannelConnections implements OnApplicationShutdown {
|
|
|
112
113
|
/** Secret values handled here (written or decrypted) are redacted from the logs (`addOrgSecrets`). */
|
|
113
114
|
private readonly log;
|
|
114
115
|
readonly txHost: TransactionHost;
|
|
115
|
-
/** The setup guide acks (spec 2026-11-
|
|
116
|
+
/** The setup guide acks (spec 2026-11-09-setup-guides-v2-design.md §11). */
|
|
116
117
|
private readonly guides;
|
|
117
118
|
private readonly unsubscribe;
|
|
118
119
|
/** `<plugin>@<version>` whose invalid connection hints were warned about (a log dedupe only). */
|
|
@@ -126,7 +127,7 @@ export declare class ChannelConnections implements OnApplicationShutdown {
|
|
|
126
127
|
config: Pick<KernelConfigService, "get">, events: Pick<KernelEvents, "on">,
|
|
127
128
|
/** Secret values handled here (written or decrypted) are redacted from the logs (`addOrgSecrets`). */
|
|
128
129
|
log: Pick<KernelLogger, "warn" | "addOrgSecrets">, txHost: TransactionHost,
|
|
129
|
-
/** The setup guide acks (spec 2026-11-
|
|
130
|
+
/** The setup guide acks (spec 2026-11-09-setup-guides-v2-design.md §11). */
|
|
130
131
|
guides: Pick<PluginGuides, "currentAck" | "ackDrifted">);
|
|
131
132
|
/** Unsubscribes after the stop phases: events emitted while they drain are still handled. */
|
|
132
133
|
onApplicationShutdown(): void;
|
|
@@ -186,11 +187,15 @@ export declare class ChannelConnections implements OnApplicationShutdown {
|
|
|
186
187
|
private updateIn;
|
|
187
188
|
/**
|
|
188
189
|
* 「我已更新应用」: records the plugin's current channel-connection guide for the connection's
|
|
189
|
-
* mode as the one it is set up with. `hash` is the
|
|
190
|
+
* mode as the one it is set up with. `hash` is the drift hash of the guide the person was
|
|
190
191
|
* shown; when the plugin has moved on since, 409 `channel.guide_changed` (show the new guide
|
|
191
|
-
* first). A plugin without a guide -> 404
|
|
192
|
+
* first). A plugin without a guide, or whose item the org's catalog does not show -> 404
|
|
193
|
+
* `catalog.guide_not_found`.
|
|
192
194
|
*/
|
|
193
|
-
ackGuide(
|
|
195
|
+
ackGuide(org: {
|
|
196
|
+
orgId: string;
|
|
197
|
+
role: OrgRole;
|
|
198
|
+
}, id: string, hash: string, actorAccountId: string, actorTokenId?: string): Promise<ChannelConnectionView>;
|
|
194
199
|
/** The row of {@link ackGuide}, in its own transaction. */
|
|
195
200
|
private ackIn;
|
|
196
201
|
/** 删除(软删除,同一事务删掉密钥);持有长连接的副本收到广播后断开。 */
|
|
@@ -211,6 +216,18 @@ export declare class ChannelConnections implements OnApplicationShutdown {
|
|
|
211
216
|
* 持有长连接的副本立即断开(扫描复核只是兜底)。只广播,失败只记日志。
|
|
212
217
|
*/
|
|
213
218
|
notifyOrgChanged(orgId: string, plugin?: string): Promise<void>;
|
|
219
|
+
/**
|
|
220
|
+
* For setup checks (setup guides v2 §10.4): the input revision of a live connection of the org
|
|
221
|
+
* on `plugin`: the `updated_at` of its row and of its secrets row (ISO), never a value. Missing,
|
|
222
|
+
* deleted, of another org or plugin -> `channel.not_found`.
|
|
223
|
+
*/
|
|
224
|
+
checkRevision(orgId: string, plugin: string, id: string): Promise<string>;
|
|
225
|
+
/**
|
|
226
|
+
* For setup checks (setup guides v2 §10.8): the stored secret values of a live connection of the
|
|
227
|
+
* org on `plugin` (every secret field, decrypted), what a check's result is redacted by. Missing,
|
|
228
|
+
* deleted, of another org or plugin -> `channel.not_found`. Never echo them.
|
|
229
|
+
*/
|
|
230
|
+
checkSecrets(orgId: string, plugin: string, id: string): Promise<string[]>;
|
|
214
231
|
/**
|
|
215
232
|
* The extension implementation and full config a connection needs to run (decrypted secrets
|
|
216
233
|
* included, validated against `connectionSchema`). Connection missing / deleted ->
|