@capybara-hq/kernel 0.1.0-rc.6 → 0.1.0-rc.8
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 +12 -0
- package/dist/identity/me.controller.js +31 -1
- package/dist/identity/me.schemas.d.ts +14 -0
- package/dist/identity/me.schemas.js +17 -0
- 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 +58 -849
- package/dist/platform/method.js +1 -1
- package/dist/platform/operation.d.ts +82 -5
- package/dist/platform/operation.js +63 -8
- 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 +11 -6
- package/dist/platform/ops/platform.ops.js +73 -27
- 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 +63 -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
|
@@ -9,6 +9,8 @@ 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 { CatalogService } from "../../catalog/catalog.service.js";
|
|
13
|
+
import { MarketplaceAddBody, MarketplaceEntriesQuery, MarketplaceEntryPathParams, MarketplaceIdPathParams, MarketplaceImportBody, MarketplacePatchBody, } from "../../catalog/marketplaces.schemas.js";
|
|
12
14
|
import { MarketplacesService, } from "../../catalog/marketplaces.service.js";
|
|
13
15
|
import { itemsSeenBy } from "../../catalog/scope-state.js";
|
|
14
16
|
import { ApiError } from "../../errors.js";
|
|
@@ -16,9 +18,14 @@ import { readOrgMarketplaceBrowse } from "../../identity/settings.js";
|
|
|
16
18
|
import { KernelDb } from "../../infra/database/kernel-db.js";
|
|
17
19
|
import { defineOperation } from "../operation.js";
|
|
18
20
|
import { PlatformOperations } from "../registry.js";
|
|
19
|
-
import {
|
|
21
|
+
import { CONFIRM_ON_WEB, reviewBrief, reviewUrl } from "./catalog-admin.ops.js";
|
|
22
|
+
import { viaAgent } from "./errors.js";
|
|
20
23
|
import { Cursor, pageOf, startOf } from "./paging.js";
|
|
21
24
|
const PAGE = 50;
|
|
25
|
+
/** A marketplace source id (`:id` of the admin routes), named as the entries name it. */
|
|
26
|
+
const MarketplaceId = MarketplaceIdPathParams.shape.id.max(100);
|
|
27
|
+
/** The manual refresh's overall deadline (the route's). */
|
|
28
|
+
const REFRESH_DEADLINE_MS = 300_000;
|
|
22
29
|
/** A marketplace source as the list shows it: no token, etag or skip list. */
|
|
23
30
|
const source = (m) => ({
|
|
24
31
|
id: m.id,
|
|
@@ -60,10 +67,31 @@ let MarketplacesOperations = class MarketplacesOperations {
|
|
|
60
67
|
registry;
|
|
61
68
|
marketplaces;
|
|
62
69
|
kdb;
|
|
63
|
-
|
|
70
|
+
catalog;
|
|
71
|
+
constructor(registry, marketplaces, kdb, catalog) {
|
|
64
72
|
this.registry = registry;
|
|
65
73
|
this.marketplaces = marketplaces;
|
|
66
74
|
this.kdb = kdb;
|
|
75
|
+
this.catalog = catalog;
|
|
76
|
+
}
|
|
77
|
+
/** The source `id`, or null when there is none. */
|
|
78
|
+
async sourceOf(id) {
|
|
79
|
+
return (await this.marketplaces.list()).find((m) => m.id === id) ?? null;
|
|
80
|
+
}
|
|
81
|
+
/** The precheck refusal of an unknown source, or of anything but `enabled` on the official one. */
|
|
82
|
+
async editable(id, onlyEnabled) {
|
|
83
|
+
const m = await this.sourceOf(id);
|
|
84
|
+
if (m === null) {
|
|
85
|
+
return { ok: false, code: "marketplace.not_found", message: "Marketplace not found" };
|
|
86
|
+
}
|
|
87
|
+
if (m.builtin && !onlyEnabled) {
|
|
88
|
+
return {
|
|
89
|
+
ok: false,
|
|
90
|
+
code: "marketplace.builtin",
|
|
91
|
+
message: "The official marketplace can only be enabled or disabled",
|
|
92
|
+
};
|
|
93
|
+
}
|
|
94
|
+
return { ok: true, source: m };
|
|
67
95
|
}
|
|
68
96
|
onModuleInit() {
|
|
69
97
|
this.registry.register([
|
|
@@ -74,6 +102,7 @@ let MarketplacesOperations = class MarketplacesOperations {
|
|
|
74
102
|
example: {},
|
|
75
103
|
authz: { superAdmin: true },
|
|
76
104
|
mirrors: ["GET /api/v1/admin/marketplaces"],
|
|
105
|
+
extras: ["cursor"],
|
|
77
106
|
confirm: "read",
|
|
78
107
|
run: async (input) => pageOf((await this.marketplaces.list()).map(source), startOf(input.cursor), PAGE),
|
|
79
108
|
}),
|
|
@@ -82,22 +111,29 @@ let MarketplacesOperations = class MarketplacesOperations {
|
|
|
82
111
|
description: "Browse the plugins the enabled marketplaces offer (org admins, when the platform lets orgs browse): name, version, summary, whether it can be imported and whether it is in the catalog already. Filter by marketplaceId or a search text q. Pages by 50: pass the returned next as params.cursor. To get one imported, use requests.create-import.",
|
|
83
112
|
input: z
|
|
84
113
|
.object({
|
|
85
|
-
marketplaceId:
|
|
86
|
-
q:
|
|
114
|
+
marketplaceId: MarketplaceEntriesQuery.shape.sourceId,
|
|
115
|
+
q: MarketplaceEntriesQuery.shape.q.unwrap().min(1).optional(),
|
|
87
116
|
cursor: Cursor.optional(),
|
|
88
117
|
})
|
|
89
118
|
.strict(),
|
|
90
119
|
example: { q: "github" },
|
|
91
120
|
authz: { orgAction: "catalog.decide" },
|
|
92
121
|
mirrors: ["GET /api/v1/orgs/:orgId/marketplaces/entries"],
|
|
122
|
+
// `marketplaceId` is the route's `sourceId`, named as the entries and requests name it
|
|
123
|
+
renames: { marketplaceId: "sourceId" },
|
|
124
|
+
extras: ["cursor"],
|
|
93
125
|
confirm: "read",
|
|
94
126
|
errors: [
|
|
95
127
|
{
|
|
96
128
|
code: "not_found",
|
|
97
|
-
next:
|
|
129
|
+
next: {
|
|
130
|
+
superAdmin: "Org marketplace browsing is off (deployment setting orgMarketplaceBrowse); browse and import the marketplaces in the admin console under Plugins instead.",
|
|
131
|
+
orgAdmin: "The platform does not let orgs browse the marketplaces; ask the super admin.",
|
|
132
|
+
member: "The platform does not let orgs browse the marketplaces; ask an org admin.",
|
|
133
|
+
},
|
|
98
134
|
},
|
|
99
135
|
],
|
|
100
|
-
run: async (input, ctx) =>
|
|
136
|
+
run: async (input, ctx) => {
|
|
101
137
|
if (!(await readOrgMarketplaceBrowse(this.kdb.db))) {
|
|
102
138
|
throw new ApiError("not_found", "Marketplace browsing is off for organizations");
|
|
103
139
|
}
|
|
@@ -111,39 +147,311 @@ let MarketplacesOperations = class MarketplacesOperations {
|
|
|
111
147
|
? e
|
|
112
148
|
: { ...e, adopted: null, newerAvailable: false, contentChanged: false });
|
|
113
149
|
return pageOf(items.map(entry), startOf(input.cursor), PAGE);
|
|
114
|
-
}
|
|
150
|
+
},
|
|
115
151
|
}),
|
|
116
152
|
defineOperation({
|
|
117
153
|
id: "marketplaces.add",
|
|
118
154
|
description: "Add a custom marketplace source to the platform (super admin): a name and an https URL of a marketplace.json, or a git repository (…/*.git or owner/repo) with an optional ref. Sources that need a token or mirrors are added on the web.",
|
|
119
|
-
input:
|
|
120
|
-
.object({
|
|
121
|
-
name: z.string().min(1).max(100),
|
|
122
|
-
url: z.string().min(1).max(2000),
|
|
123
|
-
ref: z.string().min(1).max(200).optional(),
|
|
124
|
-
})
|
|
125
|
-
.strict(),
|
|
155
|
+
input: MarketplaceAddBody.pick({ name: true, url: true, ref: true }).strict(),
|
|
126
156
|
example: { name: "Team plugins", url: "https://plugins.example.com/marketplace.json" },
|
|
127
157
|
authz: { superAdmin: true },
|
|
128
158
|
mirrors: ["POST /api/v1/admin/marketplaces"],
|
|
159
|
+
// the form is inferred from the URL; mirrors and a token are added on the web
|
|
160
|
+
omits: ["form", "mirrors", "token"],
|
|
129
161
|
confirm: "platform",
|
|
130
162
|
errors: [
|
|
131
163
|
{
|
|
132
164
|
code: "validation_failed",
|
|
133
165
|
next: "Fix the name or URL as the message says (https, no user info), then call again.",
|
|
134
166
|
},
|
|
167
|
+
{
|
|
168
|
+
code: "marketplace.already_added",
|
|
169
|
+
next: "Use the existing source (marketplaces.list) instead of adding it again.",
|
|
170
|
+
},
|
|
135
171
|
],
|
|
172
|
+
precheck: async (i) => {
|
|
173
|
+
let same;
|
|
174
|
+
try {
|
|
175
|
+
same = await this.marketplaces.checkAdd({
|
|
176
|
+
name: i.name,
|
|
177
|
+
url: i.url,
|
|
178
|
+
...(i.ref !== undefined && { ref: i.ref }),
|
|
179
|
+
});
|
|
180
|
+
}
|
|
181
|
+
catch (e) {
|
|
182
|
+
if (e instanceof ApiError)
|
|
183
|
+
return { ok: false, code: e.code, message: e.message };
|
|
184
|
+
throw e;
|
|
185
|
+
}
|
|
186
|
+
return same === null
|
|
187
|
+
? { ok: true }
|
|
188
|
+
: {
|
|
189
|
+
ok: false,
|
|
190
|
+
code: "marketplace.already_added",
|
|
191
|
+
message: `The marketplace source "${same.name}" (id ${same.id}) already has this URL`,
|
|
192
|
+
};
|
|
193
|
+
},
|
|
136
194
|
summary: (i) => ({
|
|
137
195
|
zh: `添加市场源「${i.name}」${i.url}`,
|
|
138
196
|
en: `Add marketplace source "${i.name}" ${i.url}`,
|
|
139
197
|
}),
|
|
140
|
-
run: async (input, ctx) =>
|
|
198
|
+
run: async (input, ctx) => ({
|
|
141
199
|
marketplace: source(await this.marketplaces.add(ctx.actorAccountId, {
|
|
142
200
|
name: input.name,
|
|
143
201
|
url: input.url,
|
|
144
202
|
...(input.ref !== undefined && { ref: input.ref }),
|
|
145
203
|
}, { auditDetail: viaAgent("marketplaces.add", ctx) })),
|
|
146
|
-
})
|
|
204
|
+
}),
|
|
205
|
+
}),
|
|
206
|
+
defineOperation({
|
|
207
|
+
id: "marketplaces.platform-entries",
|
|
208
|
+
description: "Browse every plugin the enabled marketplaces offer (super admin): name, version, summary, whether it can be imported (and why not) and whether it is in the catalog already. Filter by marketplaceId or a search text q. Pages by 50: pass the returned next as params.cursor. To import one, use marketplaces.import.",
|
|
209
|
+
input: z
|
|
210
|
+
.object({
|
|
211
|
+
marketplaceId: MarketplaceEntriesQuery.shape.sourceId,
|
|
212
|
+
q: MarketplaceEntriesQuery.shape.q.unwrap().min(1).optional(),
|
|
213
|
+
cursor: Cursor.optional(),
|
|
214
|
+
})
|
|
215
|
+
.strict(),
|
|
216
|
+
example: { q: "github" },
|
|
217
|
+
authz: { superAdmin: true },
|
|
218
|
+
mirrors: ["GET /api/v1/admin/marketplaces/entries"],
|
|
219
|
+
renames: { marketplaceId: "sourceId" },
|
|
220
|
+
extras: ["cursor"],
|
|
221
|
+
confirm: "read",
|
|
222
|
+
run: async (input) => {
|
|
223
|
+
const r = await this.marketplaces.entries({
|
|
224
|
+
...(input.marketplaceId !== undefined && { marketplaceId: input.marketplaceId }),
|
|
225
|
+
...(input.q !== undefined && { q: input.q }),
|
|
226
|
+
});
|
|
227
|
+
return {
|
|
228
|
+
...pageOf(r.items.map(entry), startOf(input.cursor), PAGE),
|
|
229
|
+
truncated: r.truncated,
|
|
230
|
+
};
|
|
231
|
+
},
|
|
232
|
+
}),
|
|
233
|
+
defineOperation({
|
|
234
|
+
id: "marketplaces.update",
|
|
235
|
+
description: "Edit a marketplace source (super admin): name, url, form, ref (null: follow the remote HEAD), mirrors, enabled. The official one takes only enabled. A token is set on the web.",
|
|
236
|
+
input: z
|
|
237
|
+
.object({
|
|
238
|
+
marketplaceId: MarketplaceId,
|
|
239
|
+
...MarketplacePatchBody.omit({ token: true }).shape,
|
|
240
|
+
})
|
|
241
|
+
.strict(),
|
|
242
|
+
example: { marketplaceId: "3f1c2a9e-5b7d-4e21-9c0a-1d2e3f4a5b6c", enabled: false },
|
|
243
|
+
authz: { superAdmin: true },
|
|
244
|
+
mirrors: ["PATCH /api/v1/admin/marketplaces/:id"],
|
|
245
|
+
renames: { marketplaceId: "id" },
|
|
246
|
+
// the token is a secret: set on the web only
|
|
247
|
+
omits: ["token"],
|
|
248
|
+
confirm: "platform",
|
|
249
|
+
errors: [
|
|
250
|
+
{ code: "marketplace.not_found", next: "Check the source id with marketplaces.list." },
|
|
251
|
+
{
|
|
252
|
+
code: "marketplace.builtin",
|
|
253
|
+
next: "The official marketplace can only be enabled or disabled; it cannot be edited or removed.",
|
|
254
|
+
},
|
|
255
|
+
{
|
|
256
|
+
code: "validation_failed",
|
|
257
|
+
next: "Fix the field the message names (https, no user info), then call again.",
|
|
258
|
+
},
|
|
259
|
+
],
|
|
260
|
+
precheck: async (i) => {
|
|
261
|
+
const { marketplaceId: _id, enabled: _enabled, ...rest } = i;
|
|
262
|
+
const r = await this.editable(i.marketplaceId, Object.keys(rest).length === 0);
|
|
263
|
+
return r.ok ? { ok: true } : r;
|
|
264
|
+
},
|
|
265
|
+
summary: async (i) => {
|
|
266
|
+
const { marketplaceId, ...patch } = i;
|
|
267
|
+
const m = await this.sourceOf(marketplaceId);
|
|
268
|
+
const name = m?.name ?? marketplaceId;
|
|
269
|
+
const fields = Object.entries(patch)
|
|
270
|
+
.map(([k, v]) => `${k}=${Array.isArray(v) ? `[${v.length}]` : String(v)}`)
|
|
271
|
+
.join(", ");
|
|
272
|
+
return {
|
|
273
|
+
zh: `修改市场源「${name}」:${fields}`,
|
|
274
|
+
en: `Edit marketplace source "${name}": ${fields}`,
|
|
275
|
+
};
|
|
276
|
+
},
|
|
277
|
+
run: async (input, ctx) => {
|
|
278
|
+
const { marketplaceId, ...patch } = input;
|
|
279
|
+
return {
|
|
280
|
+
marketplace: source(await this.marketplaces.update(ctx.actorAccountId, marketplaceId, Object.fromEntries(Object.entries(patch).filter(([, v]) => v !== undefined)), { auditDetail: viaAgent("marketplaces.update", ctx) })),
|
|
281
|
+
};
|
|
282
|
+
},
|
|
283
|
+
}),
|
|
284
|
+
defineOperation({
|
|
285
|
+
id: "marketplaces.remove",
|
|
286
|
+
description: "Remove a custom marketplace source (super admin): its entries and token go; plugins imported from it stay in the catalog. The official one cannot be removed (disable it with marketplaces.update).",
|
|
287
|
+
input: z.object({ marketplaceId: MarketplaceId }).strict(),
|
|
288
|
+
example: { marketplaceId: "3f1c2a9e-5b7d-4e21-9c0a-1d2e3f4a5b6c" },
|
|
289
|
+
authz: { superAdmin: true },
|
|
290
|
+
mirrors: ["DELETE /api/v1/admin/marketplaces/:id"],
|
|
291
|
+
renames: { marketplaceId: "id" },
|
|
292
|
+
confirm: "platform",
|
|
293
|
+
errors: [
|
|
294
|
+
{ code: "marketplace.not_found", next: "Check the source id with marketplaces.list." },
|
|
295
|
+
{
|
|
296
|
+
code: "marketplace.builtin",
|
|
297
|
+
next: "The official marketplace can only be enabled or disabled; it cannot be edited or removed.",
|
|
298
|
+
},
|
|
299
|
+
],
|
|
300
|
+
precheck: async (i) => {
|
|
301
|
+
const r = await this.editable(i.marketplaceId, false);
|
|
302
|
+
return r.ok ? { ok: true } : r;
|
|
303
|
+
},
|
|
304
|
+
summary: async (i) => {
|
|
305
|
+
const m = await this.sourceOf(i.marketplaceId);
|
|
306
|
+
const name = m?.name ?? i.marketplaceId;
|
|
307
|
+
return {
|
|
308
|
+
zh: `删除市场源「${name}」(${m?.entryCount ?? 0} 个条目;已导入的插件保留)`,
|
|
309
|
+
en: `Remove marketplace source "${name}" (${m?.entryCount ?? 0} entries; imported plugins stay)`,
|
|
310
|
+
};
|
|
311
|
+
},
|
|
312
|
+
run: async (input, ctx) => {
|
|
313
|
+
await this.marketplaces.remove(ctx.actorAccountId, input.marketplaceId, {
|
|
314
|
+
auditDetail: viaAgent("marketplaces.remove", ctx),
|
|
315
|
+
});
|
|
316
|
+
return { removed: input.marketplaceId };
|
|
317
|
+
},
|
|
318
|
+
}),
|
|
319
|
+
defineOperation({
|
|
320
|
+
id: "marketplaces.refresh",
|
|
321
|
+
description: "Refresh a marketplace source now (super admin): fetch its index again (a git source with an unchanged commit is skipped). On failure the old entries are kept and the error says why.",
|
|
322
|
+
input: z.object({ marketplaceId: MarketplaceId }).strict(),
|
|
323
|
+
example: { marketplaceId: "3f1c2a9e-5b7d-4e21-9c0a-1d2e3f4a5b6c" },
|
|
324
|
+
authz: { superAdmin: true },
|
|
325
|
+
mirrors: ["POST /api/v1/admin/marketplaces/:id/refresh"],
|
|
326
|
+
renames: { marketplaceId: "id" },
|
|
327
|
+
confirm: "platform",
|
|
328
|
+
errors: [
|
|
329
|
+
{ code: "marketplace.not_found", next: "Check the source id with marketplaces.list." },
|
|
330
|
+
{
|
|
331
|
+
code: "marketplace.fetch_failed",
|
|
332
|
+
next: "The source could not be fetched; check its URL with marketplaces.list, or try again later.",
|
|
333
|
+
},
|
|
334
|
+
{
|
|
335
|
+
code: "marketplace.invalid",
|
|
336
|
+
next: "The source returned an invalid marketplace index; tell the person who maintains it.",
|
|
337
|
+
},
|
|
338
|
+
],
|
|
339
|
+
precheck: async (i) => {
|
|
340
|
+
const r = await this.editable(i.marketplaceId, true);
|
|
341
|
+
return r.ok ? { ok: true } : r;
|
|
342
|
+
},
|
|
343
|
+
summary: async (i) => {
|
|
344
|
+
const name = (await this.sourceOf(i.marketplaceId))?.name ?? i.marketplaceId;
|
|
345
|
+
return { zh: `刷新市场源「${name}」`, en: `Refresh marketplace source "${name}"` };
|
|
346
|
+
},
|
|
347
|
+
run: async (input, ctx) => ({
|
|
348
|
+
marketplace: source(await this.marketplaces.refresh(input.marketplaceId, AbortSignal.any([ctx.signal, AbortSignal.timeout(REFRESH_DEADLINE_MS)]), ctx.actorAccountId, { throwOnError: true, auditDetail: viaAgent("marketplaces.refresh", ctx) })),
|
|
349
|
+
}),
|
|
350
|
+
}),
|
|
351
|
+
defineOperation({
|
|
352
|
+
id: "marketplaces.import",
|
|
353
|
+
description: "Prepare importing one marketplace entry into the catalog (super admin; version defaults to the newest compatible one, verified against the marketplace's integrity). Stages it for 24 hours and returns what it brings and a reviewUrl; nothing is imported until the person confirms it there.",
|
|
354
|
+
input: z
|
|
355
|
+
.object({
|
|
356
|
+
marketplaceId: MarketplaceId,
|
|
357
|
+
name: MarketplaceEntryPathParams.shape.name.max(214),
|
|
358
|
+
...MarketplaceImportBody.shape,
|
|
359
|
+
})
|
|
360
|
+
.strict(),
|
|
361
|
+
example: { marketplaceId: "3f1c2a9e-5b7d-4e21-9c0a-1d2e3f4a5b6c", name: "github" },
|
|
362
|
+
authz: { superAdmin: true },
|
|
363
|
+
mirrors: ["POST /api/v1/admin/marketplaces/:id/entries/:name/import"],
|
|
364
|
+
renames: { marketplaceId: "id" },
|
|
365
|
+
confirm: "platform",
|
|
366
|
+
errors: [
|
|
367
|
+
{
|
|
368
|
+
code: "marketplace.entry_not_found",
|
|
369
|
+
next: "Check the entry name and version with marketplaces.platform-entries.",
|
|
370
|
+
},
|
|
371
|
+
{
|
|
372
|
+
code: "marketplace.host_not_allowed",
|
|
373
|
+
next: "The entry downloads from a host outside the deployment's marketplaces.allowedHosts; that list is deployment config, changed by whoever runs the deployment.",
|
|
374
|
+
},
|
|
375
|
+
{
|
|
376
|
+
code: "marketplace.incompatible",
|
|
377
|
+
next: "The entry needs a newer kernel than this platform runs; pick an older version with marketplaces.platform-entries.",
|
|
378
|
+
},
|
|
379
|
+
{
|
|
380
|
+
code: "catalog.version_exists",
|
|
381
|
+
next: "This version is in the catalog already: update the plugin to it with plugins.update-preview.",
|
|
382
|
+
},
|
|
383
|
+
{
|
|
384
|
+
code: "marketplace.path_unsupported",
|
|
385
|
+
next: "The entry is a path inside a marketplace fetched over http, which cannot be read; the marketplace must be added as a git source (marketplaces.add with its repository URL).",
|
|
386
|
+
},
|
|
387
|
+
{
|
|
388
|
+
code: "marketplace.entry_deprecated",
|
|
389
|
+
next: "The marketplace deprecates this version; import another version (marketplaces.platform-entries lists them).",
|
|
390
|
+
},
|
|
391
|
+
],
|
|
392
|
+
precheck: async (i) => {
|
|
393
|
+
const r = await this.marketplaces.entries({ marketplaceId: i.marketplaceId });
|
|
394
|
+
const found = r.items.filter((e) => e.name === i.name && (i.version === undefined || e.version === i.version));
|
|
395
|
+
if (found.length === 0) {
|
|
396
|
+
return r.truncated
|
|
397
|
+
? { ok: true }
|
|
398
|
+
: {
|
|
399
|
+
ok: false,
|
|
400
|
+
code: "marketplace.entry_not_found",
|
|
401
|
+
message: `The marketplace has no entry ${i.name}${i.version !== undefined ? `@${i.version}` : ""}`,
|
|
402
|
+
};
|
|
403
|
+
}
|
|
404
|
+
// as the import picks: a compatible, not deprecated, importable version
|
|
405
|
+
if (found.some((e) => e.compatible && e.deprecated === null && e.importable)) {
|
|
406
|
+
return { ok: true };
|
|
407
|
+
}
|
|
408
|
+
const what = `${i.name}${i.version !== undefined ? `@${i.version}` : ""}`;
|
|
409
|
+
if (!found.some((e) => e.compatible)) {
|
|
410
|
+
return {
|
|
411
|
+
ok: false,
|
|
412
|
+
code: "marketplace.incompatible",
|
|
413
|
+
message: `${what} needs a newer kernel than this platform runs`,
|
|
414
|
+
};
|
|
415
|
+
}
|
|
416
|
+
const live = found.filter((e) => e.compatible && e.deprecated === null);
|
|
417
|
+
if (live.length === 0) {
|
|
418
|
+
const reason = found.find((e) => e.deprecated !== null)?.deprecated?.reason ?? null;
|
|
419
|
+
return {
|
|
420
|
+
ok: false,
|
|
421
|
+
code: "marketplace.entry_deprecated",
|
|
422
|
+
message: `${what} is deprecated by its marketplace${reason !== null ? `: ${reason}` : ""}`,
|
|
423
|
+
};
|
|
424
|
+
}
|
|
425
|
+
return {
|
|
426
|
+
ok: false,
|
|
427
|
+
code: live[0]?.reason === "host_not_allowed"
|
|
428
|
+
? "marketplace.host_not_allowed"
|
|
429
|
+
: "marketplace.path_unsupported",
|
|
430
|
+
message: `Entry ${what} cannot be imported (${live[0]?.reason ?? "not importable"})`,
|
|
431
|
+
};
|
|
432
|
+
},
|
|
433
|
+
summary: async (i) => {
|
|
434
|
+
const name = (await this.sourceOf(i.marketplaceId))?.name ?? i.marketplaceId;
|
|
435
|
+
const v = i.version !== undefined ? `@${i.version}` : "";
|
|
436
|
+
return {
|
|
437
|
+
zh: `从市场源「${name}」准备导入插件 ${i.name}${v}(确认在网页上进行)`,
|
|
438
|
+
en: `Prepare importing plugin ${i.name}${v} from marketplace source "${name}" (confirmed on the web)`,
|
|
439
|
+
};
|
|
440
|
+
},
|
|
441
|
+
run: async (input, ctx) => {
|
|
442
|
+
const r = await this.catalog.importFromMarketplace(ctx.actorAccountId, {
|
|
443
|
+
marketplaceId: input.marketplaceId,
|
|
444
|
+
name: input.name,
|
|
445
|
+
...(input.version !== undefined && { version: input.version }),
|
|
446
|
+
}, { auditDetail: viaAgent("marketplaces.import", ctx) });
|
|
447
|
+
return {
|
|
448
|
+
stagingId: r.stagingId,
|
|
449
|
+
review: reviewBrief(r.review),
|
|
450
|
+
permissionsMismatch: r.permissionsMismatch,
|
|
451
|
+
reviewUrl: reviewUrl(r.stagingId),
|
|
452
|
+
next: CONFIRM_ON_WEB,
|
|
453
|
+
};
|
|
454
|
+
},
|
|
147
455
|
}),
|
|
148
456
|
]);
|
|
149
457
|
}
|
|
@@ -152,6 +460,7 @@ MarketplacesOperations = __decorate([
|
|
|
152
460
|
Injectable(),
|
|
153
461
|
__param(0, Inject(PlatformOperations)),
|
|
154
462
|
__param(1, Inject(MarketplacesService)),
|
|
155
|
-
__param(2, Inject(KernelDb))
|
|
463
|
+
__param(2, Inject(KernelDb)),
|
|
464
|
+
__param(3, Inject(CatalogService))
|
|
156
465
|
], MarketplacesOperations);
|
|
157
466
|
export { MarketplacesOperations };
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { type OnModuleInit } from "@nestjs/common";
|
|
2
|
+
import { ExtensionDisplayNames } from "../../extensions/display-name.js";
|
|
3
|
+
import { ExtensionRegistry } from "../../extensions/registry.js";
|
|
4
|
+
import { ModelEnablement } from "../../models/enablement.js";
|
|
5
|
+
import { ModelPurposesService } from "../../models/purposes.js";
|
|
6
|
+
import { ProviderRegistry } from "../../runtime/providers.js";
|
|
7
|
+
import { PlatformOperations } from "../registry.js";
|
|
8
|
+
/**
|
|
9
|
+
* The org's model operations of the `Platform` tool (spec §14.2): the model per purpose (the
|
|
10
|
+
* platform default, the org's override, the effective one) and setting or clearing the override,
|
|
11
|
+
* and the org's switched-off models of one provider. Org admins (`org.models.manage`). The
|
|
12
|
+
* platform's defaults and model list are the admin console's (platform-admin operations).
|
|
13
|
+
*/
|
|
14
|
+
export declare class ModelsOperations implements OnModuleInit {
|
|
15
|
+
private readonly registry;
|
|
16
|
+
private readonly purposes;
|
|
17
|
+
private readonly enablement;
|
|
18
|
+
private readonly displayNames;
|
|
19
|
+
private readonly extensions;
|
|
20
|
+
private readonly providers;
|
|
21
|
+
constructor(registry: PlatformOperations, purposes: ModelPurposesService, enablement: ModelEnablement, displayNames: ExtensionDisplayNames, extensions: ExtensionRegistry, providers: ProviderRegistry);
|
|
22
|
+
/** The precheck refusal of a provider that is not a running model-provider extension. */
|
|
23
|
+
private providerPrecheck;
|
|
24
|
+
onModuleInit(): void;
|
|
25
|
+
}
|