@capybara-hq/kernel 0.1.0-rc.6 → 0.1.0-rc.7
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/bootstrap.json +27 -3
- package/dist/admin/admin.controller.d.ts +8 -72
- package/dist/admin/admin.controller.js +21 -46
- package/dist/admin/admin.schemas.d.ts +57 -0
- package/dist/admin/admin.schemas.js +50 -0
- package/dist/admin/extensions.controller.d.ts +10 -0
- package/dist/admin/extensions.controller.js +18 -0
- package/dist/admin/extensions.schemas.d.ts +7 -0
- package/dist/admin/extensions.schemas.js +10 -0
- package/dist/admin/limit-defaults.d.ts +20 -0
- package/dist/admin/limit-defaults.js +10 -0
- package/dist/agents/agent-profile.service.d.ts +7 -5
- package/dist/agents/agent-profile.service.js +14 -9
- package/dist/agents/agents.controller.d.ts +7 -287
- package/dist/agents/agents.controller.js +7 -67
- package/dist/agents/agents.schemas.d.ts +389 -0
- package/dist/agents/agents.schemas.js +126 -0
- package/dist/agents/agents.service.d.ts +13 -5
- package/dist/agents/agents.service.js +67 -13
- package/dist/agents/definition.d.ts +47 -19
- package/dist/agents/definition.js +119 -38
- package/dist/agents/from-template.d.ts +2 -2
- package/dist/agents/from-template.js +76 -45
- package/dist/agents/from-template.service.d.ts +12 -0
- package/dist/agents/from-template.service.js +20 -3
- package/dist/agents/models.controller.d.ts +1 -2
- package/dist/agents/models.controller.js +1 -1
- package/dist/agents/org-templates.d.ts +13 -3
- package/dist/agents/org-templates.js +69 -28
- package/dist/agents/pending-connector-requests.d.ts +2 -0
- package/dist/agents/pending-connector-requests.js +1 -1
- package/dist/agents/pending-connectors.controller.d.ts +1 -1
- package/dist/agents/pending-connectors.controller.js +2 -2
- package/dist/agents/pending-connectors.service.d.ts +2 -2
- package/dist/agents/pending-connectors.service.js +19 -19
- package/dist/agents/profile.d.ts +18 -0
- package/dist/agents/profile.js +5 -1
- package/dist/agents/templates.controller.d.ts +8 -17
- package/dist/agents/templates.controller.js +13 -31
- package/dist/agents/templates.schemas.d.ts +20 -0
- package/dist/agents/templates.schemas.js +45 -0
- package/dist/background/background.controller.js +3 -2
- package/dist/background/background.schemas.d.ts +10 -0
- package/dist/background/background.schemas.js +16 -0
- package/dist/background/tasks.service.d.ts +1 -1
- package/dist/background/tasks.service.js +7 -2
- package/dist/catalog/admin-catalog.controller.d.ts +4 -57
- package/dist/catalog/admin-catalog.controller.js +8 -45
- package/dist/catalog/admin-catalog.schemas.d.ts +72 -0
- package/dist/catalog/admin-catalog.schemas.js +92 -0
- package/dist/catalog/catalog-content.d.ts +12 -2
- package/dist/catalog/catalog-scope.service.js +8 -2
- package/dist/catalog/catalog.service.d.ts +2 -0
- package/dist/catalog/catalog.service.js +3 -0
- package/dist/catalog/component-scope.controller.d.ts +3 -65
- package/dist/catalog/component-scope.controller.js +3 -56
- package/dist/catalog/component-scope.schemas.d.ts +114 -0
- package/dist/catalog/component-scope.schemas.js +97 -0
- package/dist/catalog/component-scope.service.d.ts +28 -4
- package/dist/catalog/component-scope.service.js +55 -3
- package/dist/catalog/component-state.d.ts +9 -2
- package/dist/catalog/component-state.js +22 -13
- package/dist/catalog/marketplaces.controller.d.ts +5 -35
- package/dist/catalog/marketplaces.controller.js +6 -34
- package/dist/catalog/marketplaces.schemas.d.ts +48 -0
- package/dist/catalog/marketplaces.schemas.js +53 -0
- package/dist/catalog/marketplaces.service.d.ts +15 -1
- package/dist/catalog/marketplaces.service.js +22 -1
- package/dist/catalog/org-catalog.controller.d.ts +6 -62
- package/dist/catalog/org-catalog.controller.js +12 -66
- package/dist/catalog/org-catalog.schemas.d.ts +79 -0
- package/dist/catalog/org-catalog.schemas.js +82 -0
- package/dist/catalog/org-catalog.service.d.ts +9 -2
- package/dist/catalog/org-catalog.service.js +38 -5
- package/dist/catalog/org-extension.controller.d.ts +1 -12
- package/dist/catalog/org-extension.controller.js +1 -10
- package/dist/catalog/org-extension.schemas.d.ts +15 -0
- package/dist/catalog/org-extension.schemas.js +22 -0
- package/dist/catalog/org-plugin-uploads.controller.d.ts +2 -19
- package/dist/catalog/org-plugin-uploads.controller.js +15 -28
- package/dist/catalog/org-plugin-uploads.schemas.d.ts +20 -0
- package/dist/catalog/org-plugin-uploads.schemas.js +32 -0
- package/dist/catalog/owned-items.d.ts +6 -2
- package/dist/catalog/owned-items.js +16 -4
- package/dist/catalog/platform-components.d.ts +2 -0
- package/dist/catalog/platform-components.js +2 -0
- package/dist/catalog/plugin-import.js +1 -0
- package/dist/catalog/plugin-install.js +1 -1
- package/dist/catalog/requests.service.d.ts +2 -1
- package/dist/catalog/requests.service.js +6 -2
- package/dist/channels/channels.schemas.d.ts +33 -0
- package/dist/channels/channels.schemas.js +34 -0
- package/dist/channels/connections.controller.d.ts +2 -29
- package/dist/channels/connections.controller.js +1 -23
- package/dist/channels/connections.service.d.ts +8 -2
- package/dist/channels/connections.service.js +23 -5
- package/dist/channels/inbound.js +4 -0
- package/dist/conversations/conversations.controller.d.ts +16 -37
- package/dist/conversations/conversations.controller.js +16 -56
- package/dist/conversations/conversations.schemas.d.ts +52 -0
- package/dist/conversations/conversations.schemas.js +79 -0
- package/dist/conversations/conversations.service.d.ts +9 -1
- package/dist/conversations/conversations.service.js +23 -18
- package/dist/conversations/events.d.ts +80 -6
- package/dist/conversations/events.js +60 -5
- package/dist/conversations/message-context.d.ts +28 -0
- package/dist/conversations/message-context.js +56 -0
- package/dist/conversations/queue.d.ts +2 -1
- package/dist/conversations/queue.js +11 -2
- package/dist/db/kernel-schema.d.ts +20 -0
- package/dist/environments/environments.schemas.d.ts +3 -0
- package/dist/environments/environments.schemas.js +14 -0
- package/dist/environments/environments.service.d.ts +16 -4
- package/dist/environments/environments.service.js +58 -13
- package/dist/errors.d.ts +3 -0
- package/dist/errors.js +3 -0
- package/dist/evals/evals.schemas.d.ts +110 -0
- package/dist/evals/evals.schemas.js +107 -0
- package/dist/evals/reconstruct.js +18 -11
- package/dist/evals/recorded-tools.d.ts +2 -1
- package/dist/evals/recorded-tools.js +11 -3
- package/dist/evals/run-replay.d.ts +8 -1
- package/dist/evals/run-replay.js +13 -0
- package/dist/evals/runs.controller.d.ts +2 -57
- package/dist/evals/runs.controller.js +1 -42
- package/dist/evals/runs.service.d.ts +6 -6
- package/dist/evals/runs.service.js +32 -18
- package/dist/evals/sets.controller.d.ts +2 -28
- package/dist/evals/sets.controller.js +1 -31
- package/dist/evals/sets.service.d.ts +7 -7
- package/dist/evals/sets.service.js +23 -17
- package/dist/evals/snapshot.d.ts +3 -2
- package/dist/evals/snapshot.js +17 -4
- package/dist/extensions/admin-ops.d.ts +5 -3
- package/dist/extensions/admin-ops.js +17 -12
- package/dist/extensions/deployment-config.d.ts +16 -1
- package/dist/extensions/deployment-config.js +83 -0
- package/dist/extensions/extensions.module.js +3 -0
- package/dist/extensions/host.d.ts +33 -2
- package/dist/extensions/host.js +107 -1
- package/dist/extensions/installs.d.ts +5 -0
- package/dist/extensions/installs.js +12 -0
- package/dist/extensions/org-config.d.ts +17 -2
- package/dist/extensions/org-config.js +23 -4
- package/dist/extensions/point-defaults.controller.d.ts +2 -8
- package/dist/extensions/point-defaults.controller.js +1 -3
- package/dist/extensions/point-defaults.d.ts +3 -1
- package/dist/extensions/point-defaults.js +4 -2
- package/dist/extensions/point-defaults.schemas.d.ts +9 -0
- package/dist/extensions/point-defaults.schemas.js +14 -0
- package/dist/extensions/unavailable.d.ts +49 -0
- package/dist/extensions/unavailable.js +113 -0
- package/dist/files/previewers.controller.js +2 -3
- package/dist/files/previewers.d.ts +1 -1
- package/dist/files/previewers.js +4 -4
- package/dist/files/previewers.schemas.d.ts +10 -0
- package/dist/files/previewers.schemas.js +9 -0
- package/dist/http/api.module.js +2 -0
- package/dist/identity/accounts.d.ts +43 -4
- package/dist/identity/accounts.js +74 -6
- package/dist/identity/auth.guard.js +10 -1
- package/dist/identity/cookies.d.ts +6 -0
- package/dist/identity/cookies.js +14 -0
- package/dist/identity/identity.module.js +3 -0
- package/dist/identity/initial-passwords.controller.d.ts +22 -0
- package/dist/identity/initial-passwords.controller.js +49 -0
- package/dist/identity/initial-passwords.d.ts +61 -0
- package/dist/identity/initial-passwords.job.d.ts +16 -0
- package/dist/identity/initial-passwords.job.js +46 -0
- package/dist/identity/initial-passwords.js +159 -0
- package/dist/identity/me.controller.d.ts +14 -0
- package/dist/identity/me.controller.js +39 -1
- package/dist/identity/principal.d.ts +8 -0
- package/dist/identity/principal.js +8 -0
- package/dist/identity/settings.d.ts +3 -1
- package/dist/identity/settings.js +6 -4
- package/dist/inbox/inbox.schemas.d.ts +8 -0
- package/dist/inbox/inbox.schemas.js +11 -0
- package/dist/inbox/platform-inbox.controller.d.ts +1 -1
- package/dist/inbox/platform-inbox.controller.js +2 -2
- package/dist/index.d.ts +4 -0
- package/dist/index.js +6 -0
- package/dist/lifecycle/kernel-lifecycle.js +4 -0
- package/dist/models/enablement.d.ts +2 -0
- package/dist/models/enablement.js +1 -0
- package/dist/models/org-models.schemas.d.ts +8 -0
- package/dist/models/org-models.schemas.js +22 -0
- package/dist/models/prices.d.ts +3 -1
- package/dist/models/prices.js +7 -5
- package/dist/models/purposes.d.ts +12 -2
- package/dist/models/purposes.js +22 -8
- package/dist/orgs/orgs.controller.d.ts +2 -5
- package/dist/orgs/orgs.controller.js +3 -6
- package/dist/orgs/orgs.schemas.d.ts +8 -0
- package/dist/orgs/orgs.schemas.js +16 -0
- package/dist/orgs/orgs.service.d.ts +3 -1
- package/dist/orgs/orgs.service.js +6 -4
- package/dist/orgs/settings.service.d.ts +9 -1
- package/dist/orgs/settings.service.js +20 -5
- package/dist/overrides.d.ts +4 -0
- package/dist/overrides.js +2 -0
- package/dist/platform/errors.d.ts +21 -4
- package/dist/platform/errors.js +45 -6
- package/dist/platform/exclusions.d.ts +2 -3
- package/dist/platform/exclusions.js +68 -849
- package/dist/platform/method.js +1 -1
- package/dist/platform/operation.d.ts +82 -5
- package/dist/platform/operation.js +62 -7
- package/dist/platform/ops/accounts.ops.d.ts +32 -0
- package/dist/platform/ops/accounts.ops.js +291 -0
- package/dist/platform/ops/admin.ops.d.ts +36 -0
- package/dist/platform/ops/admin.ops.js +389 -0
- package/dist/platform/ops/agent-skills.ops.d.ts +24 -0
- package/dist/platform/ops/agent-skills.ops.js +226 -0
- package/dist/platform/ops/agent-templates.ops.d.ts +4 -1
- package/dist/platform/ops/agent-templates.ops.js +194 -14
- package/dist/platform/ops/agents.ops.d.ts +19 -1
- package/dist/platform/ops/agents.ops.js +481 -58
- package/dist/platform/ops/approvals.ops.d.ts +30 -0
- package/dist/platform/ops/approvals.ops.js +116 -0
- package/dist/platform/ops/background.ops.d.ts +14 -0
- package/dist/platform/ops/background.ops.js +134 -0
- package/dist/platform/ops/catalog-admin.ops.d.ts +74 -0
- package/dist/platform/ops/catalog-admin.ops.js +587 -0
- package/dist/platform/ops/channels.ops.d.ts +16 -0
- package/dist/platform/ops/channels.ops.js +195 -0
- package/dist/platform/ops/components.ops.d.ts +46 -0
- package/dist/platform/ops/components.ops.js +853 -0
- package/dist/platform/ops/connectors.ops.d.ts +4 -2
- package/dist/platform/ops/connectors.ops.js +68 -6
- package/dist/platform/ops/conversations.ops.d.ts +30 -0
- package/dist/platform/ops/conversations.ops.js +470 -0
- package/dist/platform/ops/environments.ops.d.ts +26 -0
- package/dist/platform/ops/environments.ops.js +289 -0
- package/dist/platform/ops/errors.d.ts +10 -5
- package/dist/platform/ops/errors.js +19 -11
- package/dist/platform/ops/evals.ops.d.ts +28 -0
- package/dist/platform/ops/evals.ops.js +783 -0
- package/dist/platform/ops/extensions-admin.ops.d.ts +25 -0
- package/dist/platform/ops/extensions-admin.ops.js +344 -0
- package/dist/platform/ops/extensions.ops.d.ts +7 -1
- package/dist/platform/ops/extensions.ops.js +248 -17
- package/dist/platform/ops/inbox.ops.d.ts +25 -0
- package/dist/platform/ops/inbox.ops.js +378 -0
- package/dist/platform/ops/marketplaces.ops.d.ts +7 -1
- package/dist/platform/ops/marketplaces.ops.js +326 -17
- package/dist/platform/ops/models.ops.d.ts +25 -0
- package/dist/platform/ops/models.ops.js +232 -0
- package/dist/platform/ops/org-plugins.ops.d.ts +29 -0
- package/dist/platform/ops/org-plugins.ops.js +329 -0
- package/dist/platform/ops/org-settings.ops.d.ts +16 -0
- package/dist/platform/ops/org-settings.ops.js +102 -0
- package/dist/platform/ops/orgs.ops.d.ts +28 -0
- package/dist/platform/ops/orgs.ops.js +295 -0
- package/dist/platform/ops/other-orgs.d.ts +20 -0
- package/dist/platform/ops/other-orgs.js +72 -0
- package/dist/platform/ops/platform.ops.d.ts +4 -4
- package/dist/platform/ops/platform.ops.js +23 -24
- package/dist/platform/ops/plugins.ops.d.ts +10 -8
- package/dist/platform/ops/plugins.ops.js +176 -77
- package/dist/platform/ops/previewers.ops.d.ts +14 -0
- package/dist/platform/ops/previewers.ops.js +109 -0
- package/dist/platform/ops/requests.ops.js +57 -19
- package/dist/platform/ops/skills.ops.d.ts +5 -1
- package/dist/platform/ops/skills.ops.js +129 -11
- package/dist/platform/ops/unavailable.d.ts +23 -0
- package/dist/platform/ops/unavailable.js +111 -0
- package/dist/platform/parity.d.ts +33 -0
- package/dist/platform/parity.js +272 -0
- package/dist/platform/platform-ops.module.d.ts +32 -0
- package/dist/platform/platform-ops.module.js +78 -11
- package/dist/platform/route-schemas.d.ts +18 -0
- package/dist/platform/route-schemas.js +60 -0
- package/dist/roles/worker.module.js +2 -0
- package/dist/runtime/context/build.d.ts +2 -0
- package/dist/runtime/context/build.js +28 -2
- package/dist/runtime/context/compaction.js +10 -1
- package/dist/runtime/context/run-context.d.ts +65 -0
- package/dist/runtime/context/run-context.js +215 -0
- package/dist/runtime/model-call.js +2 -1
- package/dist/runtime/providers.js +8 -1
- package/dist/runtime/run-context.service.d.ts +65 -0
- package/dist/runtime/run-context.service.js +220 -0
- package/dist/runtime/run-worker.d.ts +5 -0
- package/dist/runtime/run-worker.js +31 -6
- package/dist/runtime/runtime.module.js +2 -0
- package/dist/runtime/subagents/definition.d.ts +15 -15
- package/dist/runtime/subagents/definition.js +46 -115
- package/dist/skills/changes.controller.js +2 -1
- package/dist/skills/changes.service.d.ts +1 -1
- package/dist/skills/changes.service.js +4 -4
- package/dist/skills/invocable.controller.d.ts +1 -1
- package/dist/skills/invocable.controller.js +2 -2
- package/dist/skills/invoke.d.ts +2 -2
- package/dist/skills/invoke.js +8 -1
- package/dist/skills/skills.controller.d.ts +4 -13
- package/dist/skills/skills.controller.js +8 -24
- package/dist/skills/skills.schemas.d.ts +48 -0
- package/dist/skills/skills.schemas.js +61 -0
- package/dist/skills/skills.service.d.ts +11 -1
- package/dist/skills/skills.service.js +37 -14
- package/dist/time-zone.d.ts +5 -0
- package/dist/time-zone.js +19 -0
- package/dist/tools/approvals.controller.js +2 -3
- package/dist/tools/approvals.schemas.d.ts +21 -0
- package/dist/tools/approvals.schemas.js +15 -0
- package/dist/tools/builtin-names.d.ts +10 -8
- package/dist/tools/builtin-names.js +16 -11
- package/dist/tools/builtins/builtin-tools.d.ts +3 -1
- package/dist/tools/builtins/builtin-tools.js +15 -3
- package/dist/tools/builtins/current-time.d.ts +26 -0
- package/dist/tools/builtins/current-time.js +99 -0
- package/dist/tools/builtins/platform.d.ts +19 -2
- package/dist/tools/builtins/platform.js +105 -16
- package/dist/tools/connectors.controller.d.ts +1 -2
- package/dist/tools/connectors.controller.js +1 -4
- package/dist/tools/connectors.schemas.d.ts +12 -0
- package/dist/tools/connectors.schemas.js +19 -0
- package/dist/tools/connectors.service.d.ts +5 -2
- package/dist/tools/connectors.service.js +7 -5
- package/dist/tools/org-tool-switches.d.ts +16 -2
- package/dist/tools/org-tool-switches.js +26 -9
- package/dist/tools/pipeline.js +3 -1
- package/dist/tools/registry.d.ts +48 -51
- package/dist/tools/registry.js +222 -233
- package/package.json +3 -3
- package/src/migrations/0090_initial_passwords.sql +27 -0
- package/src/migrations/0091_account_time_zone.sql +4 -0
- package/src/migrations/0092_tools_default_on.sql +27 -0
- package/dist/platform/redact-orgs.d.ts +0 -7
- package/dist/platform/redact-orgs.js +0 -52
|
@@ -0,0 +1,109 @@
|
|
|
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 { z } from "zod";
|
|
12
|
+
import { PreviewerRegistry } from "../../files/previewers.js";
|
|
13
|
+
import { FilePreviewersOrderBody } from "../../files/previewers.schemas.js";
|
|
14
|
+
import { defineOperation } from "../operation.js";
|
|
15
|
+
import { PlatformOperations } from "../registry.js";
|
|
16
|
+
import { viaAgent } from "./errors.js";
|
|
17
|
+
import { named } from "./summary.js";
|
|
18
|
+
const Item = FilePreviewersOrderBody.shape.items.element;
|
|
19
|
+
const row = (p) => ({
|
|
20
|
+
id: `${p.plugin}/${p.id}`,
|
|
21
|
+
name: p.title.en,
|
|
22
|
+
state: p.disabled ? "disabled" : "enabled",
|
|
23
|
+
plugin: p.plugin,
|
|
24
|
+
kind: p.kind,
|
|
25
|
+
position: p.position,
|
|
26
|
+
});
|
|
27
|
+
/**
|
|
28
|
+
* File previewer operations (the `extensions` domain): the org's order of the previewers its
|
|
29
|
+
* extensions provide and which are off (org admins, `org.extensions.manage`). Rendering a preview
|
|
30
|
+
* is the web's (`transport`).
|
|
31
|
+
*/
|
|
32
|
+
let PreviewersOperations = class PreviewersOperations {
|
|
33
|
+
registry;
|
|
34
|
+
previewers;
|
|
35
|
+
constructor(registry, previewers) {
|
|
36
|
+
this.registry = registry;
|
|
37
|
+
this.previewers = previewers;
|
|
38
|
+
}
|
|
39
|
+
onModuleInit() {
|
|
40
|
+
this.registry.register([
|
|
41
|
+
defineOperation({
|
|
42
|
+
id: "extensions.previewers",
|
|
43
|
+
description: "List the file previewers of the org's enabled extensions in the org's order (org admins): which extension provides each, its kind and whether the org switched it off. The first previewer that takes a file opens it.",
|
|
44
|
+
input: z.object({}).strict(),
|
|
45
|
+
example: {},
|
|
46
|
+
authz: { orgAction: "org.extensions.manage" },
|
|
47
|
+
mirrors: ["GET /api/v1/orgs/:orgId/file-previewers"],
|
|
48
|
+
confirm: "read",
|
|
49
|
+
run: async (_input, ctx) => {
|
|
50
|
+
const items = await this.previewers.list(ctx.orgId);
|
|
51
|
+
return { items: items.map(row), total: items.length };
|
|
52
|
+
},
|
|
53
|
+
}),
|
|
54
|
+
defineOperation({
|
|
55
|
+
id: "extensions.set-previewers",
|
|
56
|
+
description: "Set the org's order of file previewers and which are off (org admins): items lists { plugin, id, disabled } first to last, and previewers not listed follow in their usual order. Read the current list with extensions.previewers first; an item that is not a previewer of an enabled extension, or is listed twice, is refused.",
|
|
57
|
+
input: z
|
|
58
|
+
.object({
|
|
59
|
+
items: z.array(Item.strict()).max(500),
|
|
60
|
+
})
|
|
61
|
+
.strict(),
|
|
62
|
+
example: { items: [{ plugin: "viewer-markdown", id: "markdown", disabled: false }] },
|
|
63
|
+
authz: { orgAction: "org.extensions.manage" },
|
|
64
|
+
mirrors: ["PUT /api/v1/orgs/:orgId/file-previewers"],
|
|
65
|
+
confirm: "org",
|
|
66
|
+
errors: [
|
|
67
|
+
{
|
|
68
|
+
code: "validation_failed",
|
|
69
|
+
next: "An item is not a previewer of an extension enabled in this org, or is listed twice; take plugin and id from extensions.previewers.",
|
|
70
|
+
},
|
|
71
|
+
],
|
|
72
|
+
precheck: async (i, ctx) => {
|
|
73
|
+
const known = new Set((await this.previewers.list(ctx.orgId)).map((p) => `${p.plugin}/${p.id}`));
|
|
74
|
+
const seen = new Set();
|
|
75
|
+
for (const x of i.items) {
|
|
76
|
+
const k = `${x.plugin}/${x.id}`;
|
|
77
|
+
if (!known.has(k) || seen.has(k)) {
|
|
78
|
+
return {
|
|
79
|
+
ok: false,
|
|
80
|
+
code: "validation_failed",
|
|
81
|
+
message: `${k} is not a previewer of an extension enabled in this organization, or is listed twice`,
|
|
82
|
+
};
|
|
83
|
+
}
|
|
84
|
+
seen.add(k);
|
|
85
|
+
}
|
|
86
|
+
return { ok: true };
|
|
87
|
+
},
|
|
88
|
+
summary: (i) => {
|
|
89
|
+
const off = i.items.filter((x) => x.disabled).map((x) => `${x.plugin}/${x.id}`);
|
|
90
|
+
const first = i.items.slice(0, 3).map((x) => named(`${x.plugin}/${x.id}`));
|
|
91
|
+
return {
|
|
92
|
+
zh: `设置文件预览器的顺序:${i.items.length} 项在前(${first.join("、") || "无"}${i.items.length > 3 ? "…" : ""}),其中 ${off.length} 项关闭`,
|
|
93
|
+
en: `Set the order of file previewers: ${i.items.length} first (${first.join(", ") || "none"}${i.items.length > 3 ? ", …" : ""}), ${off.length} of them switched off`,
|
|
94
|
+
};
|
|
95
|
+
},
|
|
96
|
+
run: async (input, ctx) => {
|
|
97
|
+
const items = await this.previewers.put(ctx.orgId, input.items, { accountId: ctx.actorAccountId }, viaAgent("extensions.set-previewers", ctx));
|
|
98
|
+
return { items: items.map(row), total: items.length };
|
|
99
|
+
},
|
|
100
|
+
}),
|
|
101
|
+
]);
|
|
102
|
+
}
|
|
103
|
+
};
|
|
104
|
+
PreviewersOperations = __decorate([
|
|
105
|
+
Injectable(),
|
|
106
|
+
__param(0, Inject(PlatformOperations)),
|
|
107
|
+
__param(1, Inject(PreviewerRegistry))
|
|
108
|
+
], PreviewersOperations);
|
|
109
|
+
export { PreviewersOperations };
|
|
@@ -9,12 +9,12 @@ var __param = (this && this.__param) || function (paramIndex, decorator) {
|
|
|
9
9
|
};
|
|
10
10
|
import { Inject, Injectable } from "@nestjs/common";
|
|
11
11
|
import { z } from "zod";
|
|
12
|
+
import { CatalogItemPathParams, CatalogMarketplaceRequestBody, CatalogRequestBody, CatalogRequestsListQuery, } from "../../catalog/org-catalog.schemas.js";
|
|
12
13
|
import { CatalogRequestsService } from "../../catalog/requests.service.js";
|
|
13
14
|
import { defineOperation } from "../operation.js";
|
|
14
15
|
import { PlatformOperations } from "../registry.js";
|
|
15
|
-
import {
|
|
16
|
+
import { viaAgent } from "./errors.js";
|
|
16
17
|
import { Cursor, pageOf, startOf } from "./paging.js";
|
|
17
|
-
const Note = z.string().max(1000);
|
|
18
18
|
/** A request as the requester reads it (no org name: it is this org's). */
|
|
19
19
|
const view = (r) => ({
|
|
20
20
|
id: r.id,
|
|
@@ -28,6 +28,25 @@ const view = (r) => ({
|
|
|
28
28
|
decidedAt: r.decidedAt,
|
|
29
29
|
createdAt: r.createdAt,
|
|
30
30
|
});
|
|
31
|
+
/** A platform request as the super admin's list shows it: a compact row (the inbox's summary). */
|
|
32
|
+
const platformRow = (r) => ({
|
|
33
|
+
id: r.id,
|
|
34
|
+
name: r.item?.name ?? r.entry?.name ?? r.kind,
|
|
35
|
+
state: r.status,
|
|
36
|
+
kind: r.kind,
|
|
37
|
+
org: r.orgName,
|
|
38
|
+
createdAt: r.createdAt,
|
|
39
|
+
});
|
|
40
|
+
/** A member's pending request as the org admins' list shows it: a compact row (the inbox's). */
|
|
41
|
+
const pendingRow = (r) => ({
|
|
42
|
+
id: r.id,
|
|
43
|
+
name: r.item?.name ?? r.entry?.name ?? r.agent?.name ?? r.kind,
|
|
44
|
+
state: r.status,
|
|
45
|
+
kind: r.kind,
|
|
46
|
+
requestedBy: r.requestedByName,
|
|
47
|
+
note: r.note,
|
|
48
|
+
next: "Decide it on the web, in the inbox; agents never decide requests.",
|
|
49
|
+
});
|
|
31
50
|
/**
|
|
32
51
|
* Request operations of the `Platform` tool (spec §7): a member asks the org admins to switch a
|
|
33
52
|
* plugin on, an org admin asks the super admin for access to a plugin or for an import from a
|
|
@@ -59,11 +78,8 @@ let RequestsOperations = class RequestsOperations {
|
|
|
59
78
|
id: "requests.create",
|
|
60
79
|
description: 'Ask for a plugin: kind "enable" asks the org admins to switch on a plugin that is off in this org (members and up); kind "access" asks the super admin to offer this org a plugin it sees as not_offered (org admins). Take the plugin id and state from plugins.list. An optional note says why.',
|
|
61
80
|
input: z
|
|
62
|
-
.object({
|
|
63
|
-
|
|
64
|
-
kind: z.enum(["enable", "access"]),
|
|
65
|
-
note: Note.optional(),
|
|
66
|
-
})
|
|
81
|
+
.object({ itemId: CatalogItemPathParams.shape.itemId.max(100) })
|
|
82
|
+
.extend(CatalogRequestBody.shape)
|
|
67
83
|
.strict(),
|
|
68
84
|
example: {
|
|
69
85
|
itemId: "3f1c2a9e-5b7d-4e21-9c0a-1d2e3f4a5b6c",
|
|
@@ -96,21 +112,14 @@ let RequestsOperations = class RequestsOperations {
|
|
|
96
112
|
zh: `向超级管理员申请插件 ${i.itemId} 的使用权`,
|
|
97
113
|
en: `Request access to plugin ${i.itemId} from the super admin`,
|
|
98
114
|
},
|
|
99
|
-
run: async (input, ctx) =>
|
|
115
|
+
run: async (input, ctx) => ({
|
|
100
116
|
request: view(await this.requests.requestItem(ctx.orgId, ctx.actorAccountId, input.itemId, { kind: input.kind, ...(input.note !== undefined && { note: input.note }) }, { auditDetail: viaAgent("requests.create", ctx) })),
|
|
101
|
-
})
|
|
117
|
+
}),
|
|
102
118
|
}),
|
|
103
119
|
defineOperation({
|
|
104
120
|
id: "requests.create-import",
|
|
105
121
|
description: "Ask the super admin to import a plugin from a marketplace into the platform catalog (org admins, when the platform lets orgs browse): the marketplaceId, name and version from marketplaces.entries, and an optional note.",
|
|
106
|
-
input:
|
|
107
|
-
.object({
|
|
108
|
-
marketplaceId: z.string().min(1).max(100),
|
|
109
|
-
name: z.string().min(1).max(214),
|
|
110
|
-
version: z.string().min(1).max(100),
|
|
111
|
-
note: Note.optional(),
|
|
112
|
-
})
|
|
113
|
-
.strict(),
|
|
122
|
+
input: CatalogMarketplaceRequestBody,
|
|
114
123
|
example: { marketplaceId: "official", name: "github", version: "1.4.0" },
|
|
115
124
|
authz: { orgAction: "catalog.decide" },
|
|
116
125
|
mirrors: ["POST /api/v1/orgs/:orgId/marketplace-requests"],
|
|
@@ -133,14 +142,43 @@ let RequestsOperations = class RequestsOperations {
|
|
|
133
142
|
zh: `申请从市场导入插件 ${i.name} ${i.version}`,
|
|
134
143
|
en: `Request the import of plugin ${i.name} ${i.version} from a marketplace`,
|
|
135
144
|
}),
|
|
136
|
-
run: async (input, ctx) =>
|
|
145
|
+
run: async (input, ctx) => ({
|
|
137
146
|
request: view(await this.requests.requestImport(ctx.orgId, ctx.actorAccountId, {
|
|
138
147
|
marketplaceId: input.marketplaceId,
|
|
139
148
|
name: input.name,
|
|
140
149
|
version: input.version,
|
|
141
150
|
...(input.note !== undefined && { note: input.note }),
|
|
142
151
|
}, { auditDetail: viaAgent("requests.create-import", ctx) })),
|
|
143
|
-
})
|
|
152
|
+
}),
|
|
153
|
+
}),
|
|
154
|
+
defineOperation({
|
|
155
|
+
id: "requests.pending",
|
|
156
|
+
description: "List the requests members sent this org's admins that wait for a decision (org admins), as the inbox shows them, newest first: kind enable (switch a plugin on) or connector_setup (set up an agent's connectors), what it is about (the plugin or the agent), who asked and their note. Deciding them is done on the web. Pages by 50: pass the returned next as params.cursor.",
|
|
157
|
+
input: z.object({ cursor: Cursor.optional() }).strict(),
|
|
158
|
+
example: {},
|
|
159
|
+
authz: { orgAction: "catalog.decide" },
|
|
160
|
+
mirrors: [],
|
|
161
|
+
confirm: "read",
|
|
162
|
+
run: async (input, ctx) => {
|
|
163
|
+
const all = await this.requests.listForOrgAdmin(ctx.orgId, ctx.actorAccountId);
|
|
164
|
+
return pageOf(all.map(pendingRow), startOf(input.cursor), 50);
|
|
165
|
+
},
|
|
166
|
+
}),
|
|
167
|
+
defineOperation({
|
|
168
|
+
id: "requests.platform-list",
|
|
169
|
+
description: "List the requests orgs sent the super admin (super admin): access to a plugin and imports from a marketplace, one compact row each (what, status, kind, the requesting org, when), newest first; pending by default, or filter by status. Deciding them is done on the web. Pages by 50: pass the returned next as params.cursor.",
|
|
170
|
+
input: z
|
|
171
|
+
.object({ status: CatalogRequestsListQuery.shape.status, cursor: Cursor.optional() })
|
|
172
|
+
.strict(),
|
|
173
|
+
example: {},
|
|
174
|
+
authz: { superAdmin: true },
|
|
175
|
+
mirrors: ["GET /api/v1/admin/catalog/requests"],
|
|
176
|
+
extras: ["cursor"],
|
|
177
|
+
confirm: "read",
|
|
178
|
+
run: async (input) => {
|
|
179
|
+
const all = await this.requests.listDeployment(input.status !== undefined ? { status: input.status } : {});
|
|
180
|
+
return pageOf(all.map(platformRow), startOf(input.cursor), 50);
|
|
181
|
+
},
|
|
144
182
|
}),
|
|
145
183
|
]);
|
|
146
184
|
}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { type OnModuleInit } from "@nestjs/common";
|
|
2
|
+
import { OwnedItems } from "../../catalog/owned-items.js";
|
|
2
3
|
import { SkillsService } from "../../skills/skills.service.js";
|
|
3
4
|
import { PlatformOperations } from "../registry.js";
|
|
4
5
|
/**
|
|
@@ -8,6 +9,9 @@ import { PlatformOperations } from "../registry.js";
|
|
|
8
9
|
export declare class SkillsOperations implements OnModuleInit {
|
|
9
10
|
private readonly registry;
|
|
10
11
|
private readonly skills;
|
|
11
|
-
|
|
12
|
+
private readonly owned;
|
|
13
|
+
constructor(registry: PlatformOperations, skills: SkillsService, owned: OwnedItems);
|
|
14
|
+
/** The skill's name for a card summary; its id when it cannot be read. */
|
|
15
|
+
private skillName;
|
|
12
16
|
onModuleInit(): void;
|
|
13
17
|
}
|
|
@@ -9,12 +9,17 @@ var __param = (this && this.__param) || function (paramIndex, decorator) {
|
|
|
9
9
|
};
|
|
10
10
|
import { Inject, Injectable } from "@nestjs/common";
|
|
11
11
|
import { z } from "zod";
|
|
12
|
+
import { OwnedItems } from "../../catalog/owned-items.js";
|
|
13
|
+
import { SkillCreateFields, SkillIdParams, SkillPathParams, SkillShareableSchema, } from "../../skills/skills.schemas.js";
|
|
12
14
|
import { SkillsService } from "../../skills/skills.service.js";
|
|
13
15
|
import { defineOperation } from "../operation.js";
|
|
14
16
|
import { PlatformOperations } from "../registry.js";
|
|
15
|
-
import {
|
|
17
|
+
import { precheckBy, viaAgent } from "./errors.js";
|
|
18
|
+
import { named, orElse } from "./summary.js";
|
|
16
19
|
const NoInput = z.object({}).strict();
|
|
17
|
-
const SkillId = z.object({ skillId:
|
|
20
|
+
const SkillId = z.object({ skillId: SkillPathParams.shape.id.max(100) }).strict();
|
|
21
|
+
const Create = SkillCreateFields.shape;
|
|
22
|
+
const OwnedSkillId = z.object({ skillId: SkillIdParams.shape.id }).strict();
|
|
18
23
|
/**
|
|
19
24
|
* Skill library operations of the `Platform` tool (spec §7). The skill body can be long; `get`
|
|
20
25
|
* returns it whole because reading it is the point of the call.
|
|
@@ -22,9 +27,15 @@ const SkillId = z.object({ skillId: z.string().min(1).max(100) }).strict();
|
|
|
22
27
|
let SkillsOperations = class SkillsOperations {
|
|
23
28
|
registry;
|
|
24
29
|
skills;
|
|
25
|
-
|
|
30
|
+
owned;
|
|
31
|
+
constructor(registry, skills, owned) {
|
|
26
32
|
this.registry = registry;
|
|
27
33
|
this.skills = skills;
|
|
34
|
+
this.owned = owned;
|
|
35
|
+
}
|
|
36
|
+
/** The skill's name for a card summary; its id when it cannot be read. */
|
|
37
|
+
skillName(orgId, skillId) {
|
|
38
|
+
return orElse(async () => named((await this.skills.get(orgId, skillId)).name), skillId);
|
|
28
39
|
}
|
|
29
40
|
onModuleInit() {
|
|
30
41
|
this.registry.register([
|
|
@@ -45,18 +56,20 @@ let SkillsOperations = class SkillsOperations {
|
|
|
45
56
|
example: { skillId: "0b9f2c4e-1d3a-4c55-9e0a-7a2f6d1c8b11" },
|
|
46
57
|
authz: { orgAction: "skills.read" },
|
|
47
58
|
mirrors: ["GET /api/v1/orgs/:orgId/skills/:id"],
|
|
59
|
+
renames: { skillId: "id" },
|
|
48
60
|
confirm: "read",
|
|
49
|
-
run: async (input, ctx) =>
|
|
61
|
+
run: async (input, ctx) => this.skills.get(ctx.orgId, input.skillId),
|
|
50
62
|
}),
|
|
51
63
|
defineOperation({
|
|
52
64
|
id: "skills.create",
|
|
53
65
|
description: "Create an org skill from text: a name, a one-line description of when to use it, and the SKILL.md body. A skill of that name must not exist yet. Uploads of packages are done on the web.",
|
|
66
|
+
// the route's text form, its bounds tightened for the model (a SKILL.md up to 100k chars)
|
|
54
67
|
input: z
|
|
55
68
|
.object({
|
|
56
|
-
name:
|
|
57
|
-
description:
|
|
58
|
-
body:
|
|
59
|
-
shareable:
|
|
69
|
+
name: Create.name.unwrap().max(64),
|
|
70
|
+
description: Create.description.unwrap(),
|
|
71
|
+
body: Create.body.unwrap().min(1).max(100_000),
|
|
72
|
+
shareable: Create.shareable,
|
|
60
73
|
})
|
|
61
74
|
.strict(),
|
|
62
75
|
example: {
|
|
@@ -66,26 +79,130 @@ let SkillsOperations = class SkillsOperations {
|
|
|
66
79
|
},
|
|
67
80
|
authz: { orgAction: "skills.manage" },
|
|
68
81
|
mirrors: ["POST /api/v1/orgs/:orgId/skills"],
|
|
82
|
+
// packages are uploaded on the web
|
|
83
|
+
omits: ["uploadId"],
|
|
69
84
|
confirm: "org",
|
|
70
85
|
errors: [
|
|
71
86
|
{
|
|
72
87
|
code: "skill.name_exists",
|
|
73
88
|
next: "A skill of that name exists: pick another name, or read the existing one with skills.get.",
|
|
74
89
|
},
|
|
90
|
+
{
|
|
91
|
+
code: "validation_failed",
|
|
92
|
+
next: "Fix the SKILL.md as the message says (name, description, body), then call again.",
|
|
93
|
+
},
|
|
94
|
+
{
|
|
95
|
+
code: "catalog.custom_disabled",
|
|
96
|
+
next: {
|
|
97
|
+
superAdmin: "The platform does not allow custom skills: allow them in the admin console under Settings, then call again.",
|
|
98
|
+
orgAdmin: "The platform does not allow custom skills; ask the super admin, or use a platform skill from skills.list.",
|
|
99
|
+
member: "The platform does not allow custom skills; use a platform skill from skills.list, or ask an org admin.",
|
|
100
|
+
},
|
|
101
|
+
},
|
|
75
102
|
],
|
|
103
|
+
precheck: (i, ctx) => precheckBy(() => this.skills.checkCreateFromText(ctx.orgId, i)),
|
|
76
104
|
summary: (i) => i.shareable === true
|
|
77
105
|
? {
|
|
78
106
|
zh: `新建组织技能「${i.name}」(可共享给其他组织)`,
|
|
79
107
|
en: `Create org skill "${i.name}" (shared with other orgs)`,
|
|
80
108
|
}
|
|
81
109
|
: { zh: `新建组织技能「${i.name}」`, en: `Create org skill "${i.name}"` },
|
|
82
|
-
run: async (input, ctx) =>
|
|
110
|
+
run: async (input, ctx) => this.skills.createFromText(ctx.orgId, ctx.actorAccountId, {
|
|
83
111
|
name: input.name,
|
|
84
112
|
description: input.description,
|
|
85
113
|
body: input.body,
|
|
86
114
|
...(input.shareable !== undefined && { shareable: input.shareable }),
|
|
87
115
|
auditDetail: viaAgent("skills.create", ctx),
|
|
88
|
-
})
|
|
116
|
+
}),
|
|
117
|
+
}),
|
|
118
|
+
defineOperation({
|
|
119
|
+
id: "skills.set-shareable",
|
|
120
|
+
description: "Set whether an org skill may be shared with other orgs. Only the org's own skills can be changed; a skill that came from a platform plugin cannot.",
|
|
121
|
+
input: OwnedSkillId.extend({ shareable: SkillShareableSchema.shape.shareable }).strict(),
|
|
122
|
+
example: { skillId: "0b9f2c4e-1d3a-4c55-9e0a-7a2f6d1c8b11", shareable: true },
|
|
123
|
+
authz: { orgAction: "skills.manage" },
|
|
124
|
+
mirrors: ["PUT /api/v1/orgs/:orgId/skills/:id/shareable"],
|
|
125
|
+
renames: { skillId: "id" },
|
|
126
|
+
confirm: "org",
|
|
127
|
+
errors: [
|
|
128
|
+
{
|
|
129
|
+
code: "skill.not_found",
|
|
130
|
+
next: "Check the skill id with skills.list; only the org's own skills can be changed or deleted here.",
|
|
131
|
+
},
|
|
132
|
+
{
|
|
133
|
+
code: "catalog.not_owned",
|
|
134
|
+
next: "Only a skill the org created can be shared; a platform skill or a copy of another owner's is not the org's to share.",
|
|
135
|
+
},
|
|
136
|
+
],
|
|
137
|
+
precheck: (i, ctx) => precheckBy(() => this.owned.previewSkillDelete(ctx.orgId, i.skillId)),
|
|
138
|
+
summary: async (i, ctx) => {
|
|
139
|
+
const n = await this.skillName(ctx.orgId, i.skillId);
|
|
140
|
+
return i.shareable
|
|
141
|
+
? {
|
|
142
|
+
zh: `允许把组织技能「${n}」共享给其他组织`,
|
|
143
|
+
en: `Allow org skill "${n}" to be shared with other orgs`,
|
|
144
|
+
}
|
|
145
|
+
: {
|
|
146
|
+
zh: `不再把组织技能「${n}」共享给其他组织`,
|
|
147
|
+
en: `Stop sharing org skill "${n}" with other orgs`,
|
|
148
|
+
};
|
|
149
|
+
},
|
|
150
|
+
run: async (input, ctx) => {
|
|
151
|
+
await this.owned.setShareable(ctx.orgId, ctx.actorAccountId, { kind: "skill", id: input.skillId }, input.shareable, { auditDetail: viaAgent("skills.set-shareable", ctx) });
|
|
152
|
+
return { id: input.skillId, shareable: input.shareable };
|
|
153
|
+
},
|
|
154
|
+
}),
|
|
155
|
+
defineOperation({
|
|
156
|
+
id: "skills.delete-preview",
|
|
157
|
+
description: "Preview deleting an org skill (org admins): whether it is removed or handed to the platform because another org uses it, and which of the org's agents lose it. Show it to the person before skills.delete.",
|
|
158
|
+
input: OwnedSkillId,
|
|
159
|
+
example: { skillId: "0b9f2c4e-1d3a-4c55-9e0a-7a2f6d1c8b11" },
|
|
160
|
+
authz: { orgAction: "skills.manage" },
|
|
161
|
+
mirrors: ["GET /api/v1/orgs/:orgId/skills/:id/delete-preview"],
|
|
162
|
+
renames: { skillId: "id" },
|
|
163
|
+
confirm: "read",
|
|
164
|
+
errors: [
|
|
165
|
+
{
|
|
166
|
+
code: "skill.not_found",
|
|
167
|
+
next: "Check the skill id with skills.list; only the org's own skills can be changed or deleted here.",
|
|
168
|
+
},
|
|
169
|
+
],
|
|
170
|
+
run: async (input, ctx) => ({
|
|
171
|
+
preview: await this.owned.previewSkillDelete(ctx.orgId, input.skillId),
|
|
172
|
+
}),
|
|
173
|
+
}),
|
|
174
|
+
defineOperation({
|
|
175
|
+
id: "skills.delete",
|
|
176
|
+
description: "Delete an org skill. Agents of the org that use it lose it; a skill another org uses is handed to the platform instead of removed. Read skills.delete-preview first and show it to the person.",
|
|
177
|
+
input: OwnedSkillId,
|
|
178
|
+
example: { skillId: "0b9f2c4e-1d3a-4c55-9e0a-7a2f6d1c8b11" },
|
|
179
|
+
authz: { orgAction: "skills.manage" },
|
|
180
|
+
mirrors: ["DELETE /api/v1/orgs/:orgId/skills/:id"],
|
|
181
|
+
renames: { skillId: "id" },
|
|
182
|
+
confirm: "org",
|
|
183
|
+
errors: [
|
|
184
|
+
{
|
|
185
|
+
code: "skill.not_found",
|
|
186
|
+
next: "Check the skill id with skills.list; only the org's own skills can be changed or deleted here.",
|
|
187
|
+
},
|
|
188
|
+
],
|
|
189
|
+
precheck: (i, ctx) => precheckBy(() => this.owned.previewSkillDelete(ctx.orgId, i.skillId)),
|
|
190
|
+
summary: async (i, ctx) => {
|
|
191
|
+
const n = await this.skillName(ctx.orgId, i.skillId);
|
|
192
|
+
const p = await orElse(() => this.owned.previewSkillDelete(ctx.orgId, i.skillId), null);
|
|
193
|
+
const agents = p?.agents.length ?? 0;
|
|
194
|
+
const handed = p?.outcome === "transferred";
|
|
195
|
+
return {
|
|
196
|
+
zh: `删除组织技能「${n}」:${agents} 个智能体将失去它${handed ? ";其他组织在用,将转为平台技能" : ""}`,
|
|
197
|
+
en: `Delete org skill "${n}": ${agents} agents lose it${handed ? "; another org uses it, so it becomes a platform skill" : ""}`,
|
|
198
|
+
};
|
|
199
|
+
},
|
|
200
|
+
run: async (input, ctx) => ({
|
|
201
|
+
id: input.skillId,
|
|
202
|
+
outcome: await this.owned.deleteSkill(ctx.orgId, ctx.actorAccountId, input.skillId, {
|
|
203
|
+
auditDetail: viaAgent("skills.delete", ctx),
|
|
204
|
+
}),
|
|
205
|
+
}),
|
|
89
206
|
}),
|
|
90
207
|
]);
|
|
91
208
|
}
|
|
@@ -93,6 +210,7 @@ let SkillsOperations = class SkillsOperations {
|
|
|
93
210
|
SkillsOperations = __decorate([
|
|
94
211
|
Injectable(),
|
|
95
212
|
__param(0, Inject(PlatformOperations)),
|
|
96
|
-
__param(1, Inject(SkillsService))
|
|
213
|
+
__param(1, Inject(SkillsService)),
|
|
214
|
+
__param(2, Inject(OwnedItems))
|
|
97
215
|
], SkillsOperations);
|
|
98
216
|
export { SkillsOperations };
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import type { PluginUnavailableReason } from "../../catalog/catalog-content.js";
|
|
2
|
+
import type { KernelSchemaDb } from "../../db/kernel-schema.js";
|
|
3
|
+
import { type ErrorRole } from "../errors.js";
|
|
4
|
+
import type { OperationContext, OperationErrorNext } from "../operation.js";
|
|
5
|
+
/** The next step for an unavailable plugin or extension, keyed by role. */
|
|
6
|
+
export declare function unavailableNext(reason: PluginUnavailableReason, name: string): OperationErrorNext;
|
|
7
|
+
/** Why it cannot be used: "The extension of plugin "X" is not running on the platform: … (reason)." */
|
|
8
|
+
export declare function unavailableMessage(reason: PluginUnavailableReason, name: string): string;
|
|
9
|
+
/** The fields an unavailable list row or detail adds: the reason and the role's next step. */
|
|
10
|
+
export declare function unavailableFields(reason: PluginUnavailableReason | undefined, name: string, role: ErrorRole): {
|
|
11
|
+
reason?: PluginUnavailableReason;
|
|
12
|
+
next?: string;
|
|
13
|
+
};
|
|
14
|
+
/**
|
|
15
|
+
* The actor's role for next steps: the one the tool derived from this call's actor facts
|
|
16
|
+
* (`ctx.errorRole`), else read now with {@link errorRoleFor} (a context no tool call is behind).
|
|
17
|
+
*/
|
|
18
|
+
export declare function roleFor(db: KernelSchemaDb, ctx: OperationContext): Promise<ErrorRole>;
|
|
19
|
+
/**
|
|
20
|
+
* The actor's role for next steps, read now (the super admin first, then an org admin): the
|
|
21
|
+
* fallback of {@link roleFor}, the same rule as `errorRoleOf` over `PlatformActor` facts.
|
|
22
|
+
*/
|
|
23
|
+
export declare function errorRoleFor(db: KernelSchemaDb, orgId: string, accountId: string): Promise<ErrorRole>;
|
|
@@ -0,0 +1,111 @@
|
|
|
1
|
+
import { errorRoleOf, resolveNext } from "../errors.js";
|
|
2
|
+
/**
|
|
3
|
+
* What an unavailable plugin or extension tells the model (Platform tool spec §14.2 problems 1
|
|
4
|
+
* and 3): what is missing, and the next step for the actor's role. Only the super admin gets the
|
|
5
|
+
* admin console path; nothing names a config field or carries a value.
|
|
6
|
+
*/
|
|
7
|
+
/** What is missing, per reason (model-visible English, completes "…is not running on the platform: "). */
|
|
8
|
+
const MISSING = {
|
|
9
|
+
plugin_disabled: "the super admin stopped the plugin on the platform",
|
|
10
|
+
not_deployed: "its extension is not installed on the platform",
|
|
11
|
+
needs_deployment_config: "it is installed, but its deployment config is missing or invalid",
|
|
12
|
+
pending_approval: "it is installed, but its permissions wait for the super admin's approval",
|
|
13
|
+
pending_migration: "the platform is still preparing it (database migration)",
|
|
14
|
+
loading: "the platform is still loading it",
|
|
15
|
+
dependency: "it requires an extension point that no running extension provides",
|
|
16
|
+
failed: "it failed to load on the platform",
|
|
17
|
+
deployment_disabled: "the super admin disabled it on the platform",
|
|
18
|
+
};
|
|
19
|
+
/** No request operation reaches the super admin for these (requests.create: enable / access only). */
|
|
20
|
+
const TELL_SUPER_ADMIN = "There is no request operation for this (requests.create covers enabling and access only), so tell the super admin directly.";
|
|
21
|
+
/** The member's step: inside the org, never the admin console. */
|
|
22
|
+
const memberNext = (name) => `Ask an org admin: the super admin must set up ${name} on the platform before anyone in the org can use it.`;
|
|
23
|
+
/** The next step for an unavailable plugin or extension, keyed by role. */
|
|
24
|
+
export function unavailableNext(reason, name) {
|
|
25
|
+
const adminPath = `Open the admin console → Extensions → ${name}`;
|
|
26
|
+
switch (reason) {
|
|
27
|
+
case "loading":
|
|
28
|
+
case "pending_migration":
|
|
29
|
+
return `The platform is still bringing ${name} up; wait a minute and check again with plugins.get or extensions.list.`;
|
|
30
|
+
case "plugin_disabled":
|
|
31
|
+
return {
|
|
32
|
+
superAdmin: "The plugin is stopped on the platform: turn it back on in the admin console under Plugins, then call again.",
|
|
33
|
+
orgAdmin: "The super admin stopped this plugin on the platform; ask them.",
|
|
34
|
+
member: "The super admin stopped this plugin on the platform; nothing can switch it on here.",
|
|
35
|
+
};
|
|
36
|
+
case "needs_deployment_config":
|
|
37
|
+
return {
|
|
38
|
+
superAdmin: `${adminPath} → fill in the deployment config; once it loads, switch the plugin on again.`,
|
|
39
|
+
orgAdmin: `Only the super admin can fill in the deployment config of ${name}. ${TELL_SUPER_ADMIN}`,
|
|
40
|
+
member: memberNext(name),
|
|
41
|
+
};
|
|
42
|
+
case "pending_approval":
|
|
43
|
+
return {
|
|
44
|
+
superAdmin: `${adminPath} → review and approve its permissions; once it loads, switch the plugin on again.`,
|
|
45
|
+
orgAdmin: `Only the super admin can approve the permissions of ${name}. ${TELL_SUPER_ADMIN}`,
|
|
46
|
+
member: memberNext(name),
|
|
47
|
+
};
|
|
48
|
+
case "dependency":
|
|
49
|
+
return {
|
|
50
|
+
superAdmin: `${adminPath} to see the extension point it requires, then install or enable an extension that provides it.`,
|
|
51
|
+
orgAdmin: `Only the super admin can provide what ${name} requires. ${TELL_SUPER_ADMIN}`,
|
|
52
|
+
member: memberNext(name),
|
|
53
|
+
};
|
|
54
|
+
case "failed":
|
|
55
|
+
return {
|
|
56
|
+
superAdmin: `${adminPath} to see why it failed to load; fix its deployment config or reinstall it.`,
|
|
57
|
+
orgAdmin: `Only the super admin can fix ${name}, which failed to load. ${TELL_SUPER_ADMIN}`,
|
|
58
|
+
member: memberNext(name),
|
|
59
|
+
};
|
|
60
|
+
case "deployment_disabled":
|
|
61
|
+
return {
|
|
62
|
+
superAdmin: `${adminPath} → enable it; once it loads, switch the plugin on again.`,
|
|
63
|
+
orgAdmin: `Only the super admin can enable ${name} on the platform. ${TELL_SUPER_ADMIN}`,
|
|
64
|
+
member: memberNext(name),
|
|
65
|
+
};
|
|
66
|
+
case "not_deployed":
|
|
67
|
+
return {
|
|
68
|
+
superAdmin: `Install the extension of ${name}: admin console → Extensions (or update the plugin in the admin console under Plugins), then switch it on again.`,
|
|
69
|
+
orgAdmin: `Only the super admin can install the extension of ${name}. ${TELL_SUPER_ADMIN}`,
|
|
70
|
+
member: memberNext(name),
|
|
71
|
+
};
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
/** Why it cannot be used: "The extension of plugin "X" is not running on the platform: … (reason)." */
|
|
75
|
+
export function unavailableMessage(reason, name) {
|
|
76
|
+
if (reason === "plugin_disabled")
|
|
77
|
+
return `Plugin "${name}" is unavailable: ${MISSING[reason]}.`;
|
|
78
|
+
return `The extension of "${name}" is not running on the platform: ${MISSING[reason]} (${reason}).`;
|
|
79
|
+
}
|
|
80
|
+
/** The fields an unavailable list row or detail adds: the reason and the role's next step. */
|
|
81
|
+
export function unavailableFields(reason, name, role) {
|
|
82
|
+
if (reason === undefined)
|
|
83
|
+
return {};
|
|
84
|
+
const next = resolveNext(unavailableNext(reason, name), role);
|
|
85
|
+
return { reason, ...(next !== undefined && { next }) };
|
|
86
|
+
}
|
|
87
|
+
/**
|
|
88
|
+
* The actor's role for next steps: the one the tool derived from this call's actor facts
|
|
89
|
+
* (`ctx.errorRole`), else read now with {@link errorRoleFor} (a context no tool call is behind).
|
|
90
|
+
*/
|
|
91
|
+
export function roleFor(db, ctx) {
|
|
92
|
+
return ctx.errorRole !== undefined
|
|
93
|
+
? Promise.resolve(ctx.errorRole)
|
|
94
|
+
: errorRoleFor(db, ctx.orgId, ctx.actorAccountId);
|
|
95
|
+
}
|
|
96
|
+
/**
|
|
97
|
+
* The actor's role for next steps, read now (the super admin first, then an org admin): the
|
|
98
|
+
* fallback of {@link roleFor}, the same rule as `errorRoleOf` over `PlatformActor` facts.
|
|
99
|
+
*/
|
|
100
|
+
export async function errorRoleFor(db, orgId, accountId) {
|
|
101
|
+
const row = await db
|
|
102
|
+
.selectFrom("accounts")
|
|
103
|
+
.leftJoin("memberships", (j) => j.onRef("memberships.account_id", "=", "accounts.id").on("memberships.org_id", "=", orgId))
|
|
104
|
+
.select(["accounts.is_super_admin", "accounts.status", "memberships.role"])
|
|
105
|
+
.where("accounts.id", "=", accountId)
|
|
106
|
+
.executeTakeFirst();
|
|
107
|
+
return errorRoleOf({
|
|
108
|
+
role: row?.role ?? null,
|
|
109
|
+
isSuperAdmin: row?.is_super_admin === true && row.status === "active",
|
|
110
|
+
});
|
|
111
|
+
}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import type { PlatformOperation } from "./operation.js";
|
|
2
|
+
import type { RouteSchemas } from "./route-schemas.js";
|
|
3
|
+
/** One difference between an operation's input and its mirrored route (spec §14.5 item 3). */
|
|
4
|
+
export interface ParityFinding {
|
|
5
|
+
op: string;
|
|
6
|
+
route: string;
|
|
7
|
+
/** The operation field (or declaration entry) it is about; absent when about the whole route. */
|
|
8
|
+
field?: string;
|
|
9
|
+
message: string;
|
|
10
|
+
}
|
|
11
|
+
/** What {@link inputParity} reads of an operation. */
|
|
12
|
+
export type ParityOperation = Pick<PlatformOperation, "id" | "input" | "mirrors"> & Partial<Pick<PlatformOperation, "omits" | "extras" | "renames" | "loosens">>;
|
|
13
|
+
/**
|
|
14
|
+
* Compares an operation's input with one mirrored route's body + query + path params (spec
|
|
15
|
+
* §14.5 item 3), on their input JSON Schemas:
|
|
16
|
+
* - each input field is compared with the route field of the same name, or the route path its
|
|
17
|
+
* `renames` entry names (`skillId` → `id`, `name` → `definition.name`): the same type (an
|
|
18
|
+
* operation `integer` fits a route `number`), enum values a subset, bounds no looser
|
|
19
|
+
* (`maxLength` / `maximum` / `maxItems` at most the route's, the lower bounds at least), the
|
|
20
|
+
* same `pattern` and `format`, and required where the route requires it; nested objects,
|
|
21
|
+
* arrays and records recursively (a nested optional route field the operation leaves out is
|
|
22
|
+
* allowed, a required one is not);
|
|
23
|
+
* - a `loosens` entry names an input field allowed to accept more than the route (with the
|
|
24
|
+
* reason); it is still compared by type, and an entry that loosens nothing is stale;
|
|
25
|
+
* - a top-level route field the input neither has nor renames into is listed in `omits`, an input
|
|
26
|
+
* field with no route counterpart in `extras`; stale entries of either are findings.
|
|
27
|
+
*/
|
|
28
|
+
export declare function inputParity(op: ParityOperation, route: RouteSchemas): ParityFinding[];
|
|
29
|
+
/**
|
|
30
|
+
* {@link inputParity} of every operation against each route it mirrors; a mirrored route whose
|
|
31
|
+
* schemas are not registered is a finding too (a removed route is `check:platform-ops`'s orphan).
|
|
32
|
+
*/
|
|
33
|
+
export declare function checkInputParity(ops: readonly ParityOperation[], routes: readonly RouteSchemas[]): ParityFinding[];
|