@capybara-hq/kernel 0.1.0-rc.5 → 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 +21 -74
- package/dist/admin/admin.controller.js +50 -50
- 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 +16 -6
- package/dist/agents/agents.service.js +75 -19
- 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 +23 -6
- package/dist/agents/models.controller.d.ts +33 -5
- package/dist/agents/models.controller.js +50 -6
- 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/readiness.controller.d.ts +5 -5
- package/dist/agents/readiness.controller.js +6 -6
- 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/config/schema.d.ts +4 -0
- package/dist/config/schema.js +24 -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 +13 -4
- package/dist/conversations/conversations.service.js +32 -26
- 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/ctx/create-ctx.d.ts +15 -1
- package/dist/ctx/create-ctx.js +23 -2
- package/dist/db/kernel-schema.d.ts +44 -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 +6 -0
- package/dist/errors.js +6 -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 +17 -2
- package/dist/evals/runs.controller.d.ts +2 -57
- package/dist/evals/runs.controller.js +1 -42
- package/dist/evals/runs.service.d.ts +8 -7
- package/dist/evals/runs.service.js +45 -30
- 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/evals/step-replay.d.ts +2 -1
- package/dist/evals/step-replay.js +3 -2
- package/dist/extensions/admin-ops.d.ts +5 -3
- package/dist/extensions/admin-ops.js +17 -12
- package/dist/extensions/config-hash.d.ts +10 -0
- package/dist/extensions/config-hash.js +38 -0
- package/dist/extensions/deployment-config.d.ts +16 -1
- package/dist/extensions/deployment-config.js +83 -0
- package/dist/extensions/extensions.module.js +9 -12
- package/dist/extensions/host.d.ts +39 -12
- package/dist/extensions/host.js +129 -51
- 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/state.module.d.ts +9 -0
- package/dist/extensions/state.module.js +38 -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 +4 -0
- package/dist/http/plugin-dispatch.d.ts +4 -1
- package/dist/http/plugin-dispatch.js +14 -2
- 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/infra/config/kernel-config.service.js +3 -0
- package/dist/infra/events/kernel-events.d.ts +8 -0
- package/dist/lifecycle/kernel-lifecycle.js +4 -0
- package/dist/models/embeddings.d.ts +82 -0
- package/dist/models/embeddings.js +326 -0
- package/dist/models/enablement.controller.d.ts +40 -0
- package/dist/models/enablement.controller.js +74 -0
- package/dist/models/enablement.d.ts +101 -0
- package/dist/models/enablement.js +264 -0
- package/dist/models/models.module.d.ts +5 -1
- package/dist/models/models.module.js +16 -4
- 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 +30 -6
- package/dist/models/purposes.js +68 -17
- 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 -831
- 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/hook-calls.d.ts +8 -1
- package/dist/runtime/hook-calls.js +40 -9
- package/dist/runtime/model-call.d.ts +8 -3
- package/dist/runtime/model-call.js +30 -6
- package/dist/runtime/providers.d.ts +146 -32
- package/dist/runtime/providers.js +328 -67
- 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 +6 -1
- package/dist/runtime/run-worker.js +35 -10
- package/dist/runtime/runtime.module.js +2 -0
- package/dist/runtime/subagents/definition.d.ts +15 -15
- package/dist/runtime/subagents/definition.js +49 -118
- package/dist/runtime/usage-report-jobs.d.ts +88 -0
- package/dist/runtime/usage-report-jobs.js +158 -0
- package/dist/runtime/usage-report.d.ts +33 -38
- package/dist/runtime/usage-report.js +152 -84
- 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 +9 -1
- package/dist/tools/registry.d.ts +48 -51
- package/dist/tools/registry.js +222 -233
- package/package.json +3 -3
- package/src/migrations/0089_model_kinds_usage.sql +38 -0
- 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
|
@@ -10,6 +10,7 @@ var __param = (this && this.__param) || function (paramIndex, decorator) {
|
|
|
10
10
|
import { Inject, Injectable } from "@nestjs/common";
|
|
11
11
|
import { ApiError } from "../errors.js";
|
|
12
12
|
import { ExtensionRegistry } from "../extensions/registry.js";
|
|
13
|
+
import { ExtensionAvailability } from "../extensions/unavailable.js";
|
|
13
14
|
import { KernelDb } from "../infra/database/kernel-db.js";
|
|
14
15
|
import { TransactionHost } from "../infra/database/transaction-host.js";
|
|
15
16
|
import { Transactional } from "../infra/database/transactional.decorator.js";
|
|
@@ -47,9 +48,12 @@ let OrgCatalogService = class OrgCatalogService {
|
|
|
47
48
|
pluginInstaller;
|
|
48
49
|
log;
|
|
49
50
|
txHost;
|
|
51
|
+
availability;
|
|
50
52
|
constructor(kdb,
|
|
51
53
|
/** The org row lock (orgs/org-lock.ts): joins the caller's transaction. */
|
|
52
|
-
orgLock, storage, registry, pluginInstaller, log, txHost
|
|
54
|
+
orgLock, storage, registry, pluginInstaller, log, txHost,
|
|
55
|
+
/** Why a plugin's extension cannot run (the `unavailable` state's reason). */
|
|
56
|
+
availability) {
|
|
53
57
|
this.kdb = kdb;
|
|
54
58
|
this.orgLock = orgLock;
|
|
55
59
|
this.storage = storage;
|
|
@@ -57,6 +61,7 @@ let OrgCatalogService = class OrgCatalogService {
|
|
|
57
61
|
this.pluginInstaller = pluginInstaller;
|
|
58
62
|
this.log = log;
|
|
59
63
|
this.txHost = txHost;
|
|
64
|
+
this.availability = availability;
|
|
60
65
|
}
|
|
61
66
|
/** The kernel-schema handle of the current context (the transaction, else the pool). */
|
|
62
67
|
get db() {
|
|
@@ -158,6 +163,16 @@ let OrgCatalogService = class OrgCatalogService {
|
|
|
158
163
|
const configured = new Set(configs.map((c) => c.plugin));
|
|
159
164
|
const owners = await ownersOf(this.db, items.flatMap((i) => (i.owner_org_id === null ? [] : [i.owner_org_id])));
|
|
160
165
|
const loaded = new Map(this.registry.manifests().map((x) => [x.name, x]));
|
|
166
|
+
// the extensions of the latest versions that are not loaded: why (the `unavailable` reason)
|
|
167
|
+
const extensionOf = (i) => {
|
|
168
|
+
const v = versions.find((x) => x.item_id === i.id && x.version === i.latest_version);
|
|
169
|
+
const m = v?.manifest;
|
|
170
|
+
return m?.extension ? m.name : undefined;
|
|
171
|
+
};
|
|
172
|
+
const unloaded = await this.availability.unavailable(items.flatMap((i) => {
|
|
173
|
+
const n = extensionOf(i);
|
|
174
|
+
return n === undefined ? [] : [n];
|
|
175
|
+
}));
|
|
161
176
|
const out = [];
|
|
162
177
|
for (const i of items) {
|
|
163
178
|
// Another org sees only an org-owned plugin's applied version, never one its owner
|
|
@@ -172,12 +187,23 @@ let OrgCatalogService = class OrgCatalogService {
|
|
|
172
187
|
const scope = i.builtin ? "all" : i.scope;
|
|
173
188
|
const wanted = wantedOn(i, inList.has(i.id), sw.get(i.id) ?? null);
|
|
174
189
|
let state;
|
|
190
|
+
let reason;
|
|
191
|
+
const extName = extensionOf(i);
|
|
192
|
+
const why = extName === undefined ? undefined : unloaded.get(extName);
|
|
175
193
|
if (i.awaiting_confirmation)
|
|
176
194
|
state = "awaiting_confirmation";
|
|
177
|
-
else if (i.disabled)
|
|
195
|
+
else if (i.disabled) {
|
|
178
196
|
state = "unavailable";
|
|
197
|
+
reason = "plugin_disabled";
|
|
198
|
+
}
|
|
179
199
|
else if (requestable(i, inList.has(i.id)))
|
|
180
200
|
state = "not_offered";
|
|
201
|
+
// not installed here and its extension cannot run: switching it on would fail (spec §14.2
|
|
202
|
+
// problem 1); an installed one keeps its state (an org admin can still switch it off)
|
|
203
|
+
else if (!a && why !== undefined) {
|
|
204
|
+
state = "unavailable";
|
|
205
|
+
reason = why.reason;
|
|
206
|
+
}
|
|
181
207
|
else if (a) {
|
|
182
208
|
// An on connector template without a connector here (ruling P2-10)
|
|
183
209
|
const missing = await this.pluginInstaller.missingConnectors(orgId, i.id);
|
|
@@ -208,6 +234,7 @@ let OrgCatalogService = class OrgCatalogService {
|
|
|
208
234
|
scope,
|
|
209
235
|
builtin: i.builtin,
|
|
210
236
|
state,
|
|
237
|
+
...(reason !== undefined && { reason }),
|
|
211
238
|
switchable: state !== "not_offered" && state !== "awaiting_confirmation" && switchable(i),
|
|
212
239
|
notDeployed: latest !== undefined && undeployed.has(i.id),
|
|
213
240
|
installed: a
|
|
@@ -467,7 +494,9 @@ let OrgCatalogService = class OrgCatalogService {
|
|
|
467
494
|
* install writes the switch row false in the uninstall's transaction (an `all` item then stays
|
|
468
495
|
* off in the org); removing a failed or stale one writes none.
|
|
469
496
|
*/
|
|
470
|
-
async uninstall(orgId, actor, installId, actorTokenId
|
|
497
|
+
async uninstall(orgId, actor, installId, actorTokenId,
|
|
498
|
+
/** Merged into the audit detail (a write made through the Platform tool). */
|
|
499
|
+
auditDetail) {
|
|
471
500
|
if (!UUID_RE.test(installId))
|
|
472
501
|
throw new ApiError("plugin.install_not_found", "Plugin install not found");
|
|
473
502
|
const row = await this.db
|
|
@@ -482,7 +511,10 @@ let OrgCatalogService = class OrgCatalogService {
|
|
|
482
511
|
if (row !== undefined && live && !switchable(row)) {
|
|
483
512
|
throw new ApiError("plugin.scope_locked", "This plugin is built in: it is on for every organization and cannot be uninstalled here");
|
|
484
513
|
}
|
|
485
|
-
return this.pluginInstaller.uninstall(orgId, actor, installId,
|
|
514
|
+
return this.pluginInstaller.uninstall(orgId, actor, installId, {
|
|
515
|
+
...(actorTokenId !== undefined && { actorTokenId }),
|
|
516
|
+
...(auditDetail !== undefined && { auditDetail }),
|
|
517
|
+
},
|
|
486
518
|
// only a live install was on: removing a failed or stale one writes no switch row, so an
|
|
487
519
|
// item its scope wants stays wanted and the sync installs it again
|
|
488
520
|
row !== undefined && live ? {} : undefined);
|
|
@@ -546,6 +578,7 @@ OrgCatalogService = __decorate([
|
|
|
546
578
|
__param(3, Inject(ExtensionRegistry)),
|
|
547
579
|
__param(4, Inject(PluginInstaller)),
|
|
548
580
|
__param(5, Inject(KERNEL_LOGGER)),
|
|
549
|
-
__param(6, Inject(TransactionHost))
|
|
581
|
+
__param(6, Inject(TransactionHost)),
|
|
582
|
+
__param(7, Inject(ExtensionAvailability))
|
|
550
583
|
], OrgCatalogService);
|
|
551
584
|
export { OrgCatalogService };
|
|
@@ -6,6 +6,7 @@ import { OrgOverrides, type OrgOverrideView } from "../extensions/org-overrides.
|
|
|
6
6
|
import { type Principal } from "../identity/principal.js";
|
|
7
7
|
import { type OrgContext } from "../orgs/org.guard.js";
|
|
8
8
|
import { type OrgToolSwitch, OrgToolSwitches, type OrgToolSwitchResult } from "../tools/org-tool-switches.js";
|
|
9
|
+
import { OrgExtensionParams as ExtensionParams, OrgExtensionToolParams as ToolParams, OrgToolSwitchPut as ToolSwitchPut } from "./org-extension.schemas.js";
|
|
9
10
|
import { OrgExtensionSwitch } from "./org-extension-switch.js";
|
|
10
11
|
import type { UninstallPreview } from "./plugin-install.js";
|
|
11
12
|
declare const PutBody: z.ZodObject<{
|
|
@@ -26,18 +27,6 @@ declare const OverridesPut: z.ZodObject<{
|
|
|
26
27
|
declare const OverridesTake: z.ZodObject<{
|
|
27
28
|
paths: z.ZodArray<z.ZodString>;
|
|
28
29
|
}, z.core.$strict>;
|
|
29
|
-
declare const ToolSwitchPut: z.ZodObject<{
|
|
30
|
-
enabled: z.ZodBoolean;
|
|
31
|
-
confirm: z.ZodOptional<z.ZodString>;
|
|
32
|
-
}, z.core.$strict>;
|
|
33
|
-
/** Route parameters of the overrides and tool switch routes (decision R20). */
|
|
34
|
-
declare const ExtensionParams: z.ZodObject<{
|
|
35
|
-
extension: z.ZodString;
|
|
36
|
-
}, z.core.$strip>;
|
|
37
|
-
declare const ToolParams: z.ZodObject<{
|
|
38
|
-
extension: z.ZodString;
|
|
39
|
-
tool: z.ZodString;
|
|
40
|
-
}, z.core.$strip>;
|
|
41
30
|
/**
|
|
42
31
|
* One extension of the org list: the org view plus the plugin's display name and the extension
|
|
43
32
|
* points it provides (`channel@1`, `web-search@1`, … the names only, also for members).
|
|
@@ -18,6 +18,7 @@ import { ZBody, ZParam } from "../infra/validation/zod-params.js";
|
|
|
18
18
|
import { CurrentOrg, OrgAction } from "../orgs/org.guard.js";
|
|
19
19
|
import { roleAtLeast } from "../orgs/roles.js";
|
|
20
20
|
import { OrgToolSwitches, } from "../tools/org-tool-switches.js";
|
|
21
|
+
import { OrgExtensionParams as ExtensionParams, OrgExtensionToolParams as ToolParams, OrgToolSwitchPut as ToolSwitchPut, } from "./org-extension.schemas.js";
|
|
21
22
|
import { OrgExtensionSwitch } from "./org-extension-switch.js";
|
|
22
23
|
const PutBody = z
|
|
23
24
|
.object({
|
|
@@ -57,18 +58,8 @@ const OverridesPut = z
|
|
|
57
58
|
const OverridesTake = z
|
|
58
59
|
.object({ paths: z.array(z.string().min(1).max(256)).min(1).max(200) })
|
|
59
60
|
.strict();
|
|
60
|
-
const ToolSwitchPut = z
|
|
61
|
-
.object({
|
|
62
|
-
enabled: z.boolean(),
|
|
63
|
-
/** The hash of the switch-off preview, to confirm turning the tool off. */
|
|
64
|
-
confirm: z.string().min(1).max(128).optional(),
|
|
65
|
-
})
|
|
66
|
-
.strict();
|
|
67
61
|
class OrgToolSwitchPutBody extends createZodDto(ToolSwitchPut, "OrgToolSwitchPutBody") {
|
|
68
62
|
}
|
|
69
|
-
/** Route parameters of the overrides and tool switch routes (decision R20). */
|
|
70
|
-
const ExtensionParams = z.object({ extension: z.string().min(1).max(64) });
|
|
71
|
-
const ToolParams = ExtensionParams.extend({ tool: z.string().min(1).max(64) });
|
|
72
63
|
class OrgExtensionParamsDto extends createZodDto(ExtensionParams, "OrgExtensionParams") {
|
|
73
64
|
}
|
|
74
65
|
class OrgExtensionToolParamsDto extends createZodDto(ToolParams, "OrgExtensionToolParams") {
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
import type { RouteSchemas } from "../platform/route-schemas.js";
|
|
3
|
+
/** Route parameters of the overrides and tool switch routes (decision R20). */
|
|
4
|
+
export declare const OrgExtensionParams: z.ZodObject<{
|
|
5
|
+
extension: z.ZodString;
|
|
6
|
+
}, z.core.$strip>;
|
|
7
|
+
export declare const OrgExtensionToolParams: z.ZodObject<{
|
|
8
|
+
extension: z.ZodString;
|
|
9
|
+
tool: z.ZodString;
|
|
10
|
+
}, z.core.$strip>;
|
|
11
|
+
export declare const OrgToolSwitchPut: z.ZodObject<{
|
|
12
|
+
enabled: z.ZodBoolean;
|
|
13
|
+
confirm: z.ZodOptional<z.ZodString>;
|
|
14
|
+
}, z.core.$strict>;
|
|
15
|
+
export declare const ORG_EXTENSION_ROUTES: readonly RouteSchemas[];
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
/** Route parameters of the overrides and tool switch routes (decision R20). */
|
|
3
|
+
export const OrgExtensionParams = z.object({ extension: z.string().min(1).max(64) });
|
|
4
|
+
export const OrgExtensionToolParams = OrgExtensionParams.extend({
|
|
5
|
+
tool: z.string().min(1).max(64),
|
|
6
|
+
});
|
|
7
|
+
export const OrgToolSwitchPut = z
|
|
8
|
+
.object({
|
|
9
|
+
enabled: z.boolean(),
|
|
10
|
+
/** The hash of the switch-off preview, to confirm turning the tool off. */
|
|
11
|
+
confirm: z.string().min(1).max(128).optional(),
|
|
12
|
+
})
|
|
13
|
+
.strict();
|
|
14
|
+
export const ORG_EXTENSION_ROUTES = [
|
|
15
|
+
{ route: "GET /api/v1/orgs/:orgId/extensions" },
|
|
16
|
+
{ route: "GET /api/v1/orgs/:orgId/extensions/:extension/tools", params: OrgExtensionParams },
|
|
17
|
+
{
|
|
18
|
+
route: "PUT /api/v1/orgs/:orgId/extensions/:extension/tools/:tool",
|
|
19
|
+
params: OrgExtensionToolParams,
|
|
20
|
+
body: OrgToolSwitchPut,
|
|
21
|
+
},
|
|
22
|
+
];
|
|
@@ -1,27 +1,11 @@
|
|
|
1
|
-
import { z } from "zod";
|
|
1
|
+
import type { z } from "zod";
|
|
2
2
|
import { type Principal } from "../identity/principal.js";
|
|
3
3
|
import { type OrgContext } from "../orgs/org.guard.js";
|
|
4
4
|
import type { CatalogItemView } from "./catalog.service.js";
|
|
5
5
|
import { CatalogScopeService } from "./catalog-scope.service.js";
|
|
6
6
|
import { OrgPluginUploads, type OrgUploadOutcome, type OrgUploadReview } from "./org-plugin-uploads.js";
|
|
7
|
+
import { OrgUploadConfirmBody as ConfirmBody, OrgOwnedDeleteBody as DeleteBody, OrgOwnedPluginParams as OwnedParams, OrgOwnedShareableBody as ShareableBody, OrgUploadStagingParams as StagingParams } from "./org-plugin-uploads.schemas.js";
|
|
7
8
|
import { type OwnedDeletePreview, OwnedItems } from "./owned-items.js";
|
|
8
|
-
declare const StagingParams: z.ZodObject<{
|
|
9
|
-
stagingId: z.ZodString;
|
|
10
|
-
}, z.core.$strip>;
|
|
11
|
-
declare const OwnedParams: z.ZodObject<{
|
|
12
|
-
id: z.ZodString;
|
|
13
|
-
}, z.core.$strip>;
|
|
14
|
-
declare const ConfirmBody: z.ZodObject<{
|
|
15
|
-
reviewHash: z.ZodString;
|
|
16
|
-
shareable: z.ZodOptional<z.ZodBoolean>;
|
|
17
|
-
pinnedSuggestions: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
18
|
-
}, z.core.$strict>;
|
|
19
|
-
declare const ShareableBody: z.ZodObject<{
|
|
20
|
-
shareable: z.ZodBoolean;
|
|
21
|
-
}, z.core.$strict>;
|
|
22
|
-
declare const DeleteBody: z.ZodObject<{
|
|
23
|
-
previewHash: z.ZodString;
|
|
24
|
-
}, z.core.$strict>;
|
|
25
9
|
/**
|
|
26
10
|
* An org admin's plugin uploads (`/api/v1/orgs/:orgId/catalog/uploads/*`, spec §14, rulings P3-7,
|
|
27
11
|
* P3-8): a `.tgz` without an extension, prepared (one review) and confirmed like the super admin's
|
|
@@ -95,4 +79,3 @@ export declare class OrgOwnedPluginsController {
|
|
|
95
79
|
*/
|
|
96
80
|
withdraw(principal: Principal, org: OrgContext, params: z.infer<typeof OwnedParams>): Promise<void>;
|
|
97
81
|
}
|
|
98
|
-
export {};
|
|
@@ -8,7 +8,6 @@ var __param = (this && this.__param) || function (paramIndex, decorator) {
|
|
|
8
8
|
return function (target, key) { decorator(target, key, paramIndex); }
|
|
9
9
|
};
|
|
10
10
|
import { Controller, Delete, Get, HttpCode, Inject, Post, Put, Req } from "@nestjs/common";
|
|
11
|
-
import { z } from "zod";
|
|
12
11
|
import { ApiError } from "../errors.js";
|
|
13
12
|
import { CurrentPrincipal, patTokenId, requireUser, } from "../identity/principal.js";
|
|
14
13
|
import { createZodDto } from "../infra/validation/create-zod-dto.js";
|
|
@@ -16,29 +15,17 @@ import { ZBody, ZParam } from "../infra/validation/zod-params.js";
|
|
|
16
15
|
import { CurrentOrg, OrgAction } from "../orgs/org.guard.js";
|
|
17
16
|
import { CatalogScopeService } from "./catalog-scope.service.js";
|
|
18
17
|
import { OrgPluginUploads, } from "./org-plugin-uploads.js";
|
|
18
|
+
import { OrgUploadConfirmBody as ConfirmBody, OrgOwnedDeleteBody as DeleteBody, OrgOwnedPluginParams as OwnedParams, OrgOwnedShareableBody as ShareableBody, OrgUploadStagingParams as StagingParams, } from "./org-plugin-uploads.schemas.js";
|
|
19
19
|
import { OwnedItems } from "./owned-items.js";
|
|
20
|
-
|
|
21
|
-
const OwnedParams = z.object({ id: z.string().min(1).max(100) });
|
|
22
|
-
const ConfirmBody = z
|
|
23
|
-
.object({
|
|
24
|
-
reviewHash: z.string().min(1).max(128),
|
|
25
|
-
/** The org shares the new item with other orgs (default false, P3-16). */
|
|
26
|
-
shareable: z.boolean().optional(),
|
|
27
|
-
/** Skill names suggested as pinned (spec §9.1); omitted keeps the plugin's flags. */
|
|
28
|
-
pinnedSuggestions: z.array(z.string().min(1).max(64)).max(50).optional(),
|
|
29
|
-
})
|
|
30
|
-
.strict();
|
|
31
|
-
class OrgUploadStagingParams extends createZodDto(StagingParams, "OrgUploadStagingParams") {
|
|
20
|
+
class OrgUploadStagingParamsDto extends createZodDto(StagingParams, "OrgUploadStagingParams") {
|
|
32
21
|
}
|
|
33
|
-
class
|
|
22
|
+
class OrgUploadConfirmBodyDto extends createZodDto(ConfirmBody, "OrgUploadConfirmBody") {
|
|
34
23
|
}
|
|
35
|
-
class
|
|
24
|
+
class OrgOwnedPluginParamsDto extends createZodDto(OwnedParams, "OrgOwnedPluginParams") {
|
|
36
25
|
}
|
|
37
|
-
|
|
38
|
-
const DeleteBody = z.object({ previewHash: z.string().min(1).max(128) }).strict();
|
|
39
|
-
class OrgOwnedShareableBody extends createZodDto(ShareableBody, "OrgOwnedShareableBody") {
|
|
26
|
+
class OrgOwnedShareableBodyDto extends createZodDto(ShareableBody, "OrgOwnedShareableBody") {
|
|
40
27
|
}
|
|
41
|
-
class
|
|
28
|
+
class OrgOwnedDeleteBodyDto extends createZodDto(DeleteBody, "OrgOwnedDeleteBody") {
|
|
42
29
|
}
|
|
43
30
|
const actorOpts = (actor) => {
|
|
44
31
|
const tokenId = patTokenId(actor);
|
|
@@ -107,7 +94,7 @@ __decorate([
|
|
|
107
94
|
Get(":stagingId"),
|
|
108
95
|
OrgAction("catalog.upload"),
|
|
109
96
|
__param(0, CurrentOrg()),
|
|
110
|
-
__param(1, ZParam(
|
|
97
|
+
__param(1, ZParam(OrgUploadStagingParamsDto))
|
|
111
98
|
], OrgPluginUploadsController.prototype, "staged", null);
|
|
112
99
|
__decorate([
|
|
113
100
|
Post(":stagingId/confirm"),
|
|
@@ -115,8 +102,8 @@ __decorate([
|
|
|
115
102
|
OrgAction("catalog.upload"),
|
|
116
103
|
__param(0, CurrentPrincipal()),
|
|
117
104
|
__param(1, CurrentOrg()),
|
|
118
|
-
__param(2, ZParam(
|
|
119
|
-
__param(3, ZBody(
|
|
105
|
+
__param(2, ZParam(OrgUploadStagingParamsDto)),
|
|
106
|
+
__param(3, ZBody(OrgUploadConfirmBodyDto))
|
|
120
107
|
], OrgPluginUploadsController.prototype, "confirm", null);
|
|
121
108
|
OrgPluginUploadsController = __decorate([
|
|
122
109
|
Controller("api/v1/orgs/:orgId/catalog/uploads"),
|
|
@@ -178,15 +165,15 @@ __decorate([
|
|
|
178
165
|
OrgAction("catalog.upload"),
|
|
179
166
|
__param(0, CurrentPrincipal()),
|
|
180
167
|
__param(1, CurrentOrg()),
|
|
181
|
-
__param(2, ZParam(
|
|
182
|
-
__param(3, ZBody(
|
|
168
|
+
__param(2, ZParam(OrgOwnedPluginParamsDto)),
|
|
169
|
+
__param(3, ZBody(OrgOwnedShareableBodyDto))
|
|
183
170
|
], OrgOwnedPluginsController.prototype, "setShareable", null);
|
|
184
171
|
__decorate([
|
|
185
172
|
Post(":id/delete/preview"),
|
|
186
173
|
HttpCode(200),
|
|
187
174
|
OrgAction("catalog.upload"),
|
|
188
175
|
__param(0, CurrentOrg()),
|
|
189
|
-
__param(1, ZParam(
|
|
176
|
+
__param(1, ZParam(OrgOwnedPluginParamsDto))
|
|
190
177
|
], OrgOwnedPluginsController.prototype, "previewDelete", null);
|
|
191
178
|
__decorate([
|
|
192
179
|
Post(":id/delete"),
|
|
@@ -194,8 +181,8 @@ __decorate([
|
|
|
194
181
|
OrgAction("catalog.upload"),
|
|
195
182
|
__param(0, CurrentPrincipal()),
|
|
196
183
|
__param(1, CurrentOrg()),
|
|
197
|
-
__param(2, ZParam(
|
|
198
|
-
__param(3, ZBody(
|
|
184
|
+
__param(2, ZParam(OrgOwnedPluginParamsDto)),
|
|
185
|
+
__param(3, ZBody(OrgOwnedDeleteBodyDto))
|
|
199
186
|
], OrgOwnedPluginsController.prototype, "delete", null);
|
|
200
187
|
__decorate([
|
|
201
188
|
Delete(":id/pending"),
|
|
@@ -203,7 +190,7 @@ __decorate([
|
|
|
203
190
|
OrgAction("catalog.upload"),
|
|
204
191
|
__param(0, CurrentPrincipal()),
|
|
205
192
|
__param(1, CurrentOrg()),
|
|
206
|
-
__param(2, ZParam(
|
|
193
|
+
__param(2, ZParam(OrgOwnedPluginParamsDto))
|
|
207
194
|
], OrgOwnedPluginsController.prototype, "withdraw", null);
|
|
208
195
|
OrgOwnedPluginsController = __decorate([
|
|
209
196
|
Controller("api/v1/orgs/:orgId/owned-plugins"),
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
import type { RouteSchemas } from "../platform/route-schemas.js";
|
|
3
|
+
export declare const OrgUploadStagingParams: z.ZodObject<{
|
|
4
|
+
stagingId: z.ZodString;
|
|
5
|
+
}, z.core.$strip>;
|
|
6
|
+
export declare const OrgOwnedPluginParams: z.ZodObject<{
|
|
7
|
+
id: z.ZodString;
|
|
8
|
+
}, z.core.$strip>;
|
|
9
|
+
export declare const OrgUploadConfirmBody: z.ZodObject<{
|
|
10
|
+
reviewHash: z.ZodString;
|
|
11
|
+
shareable: z.ZodOptional<z.ZodBoolean>;
|
|
12
|
+
pinnedSuggestions: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
13
|
+
}, z.core.$strict>;
|
|
14
|
+
export declare const OrgOwnedShareableBody: z.ZodObject<{
|
|
15
|
+
shareable: z.ZodBoolean;
|
|
16
|
+
}, z.core.$strict>;
|
|
17
|
+
export declare const OrgOwnedDeleteBody: z.ZodObject<{
|
|
18
|
+
previewHash: z.ZodString;
|
|
19
|
+
}, z.core.$strict>;
|
|
20
|
+
export declare const ORG_PLUGIN_UPLOAD_ROUTES: readonly RouteSchemas[];
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
export const OrgUploadStagingParams = z.object({ stagingId: z.string().min(1).max(100) });
|
|
3
|
+
export const OrgOwnedPluginParams = z.object({ id: z.string().min(1).max(100) });
|
|
4
|
+
export const OrgUploadConfirmBody = z
|
|
5
|
+
.object({
|
|
6
|
+
reviewHash: z.string().min(1).max(128),
|
|
7
|
+
/** The org shares the new item with other orgs (default false, P3-16). */
|
|
8
|
+
shareable: z.boolean().optional(),
|
|
9
|
+
/** Skill names suggested as pinned (spec §9.1); omitted keeps the plugin's flags. */
|
|
10
|
+
pinnedSuggestions: z.array(z.string().min(1).max(64)).max(50).optional(),
|
|
11
|
+
})
|
|
12
|
+
.strict();
|
|
13
|
+
export const OrgOwnedShareableBody = z.object({ shareable: z.boolean() }).strict();
|
|
14
|
+
export const OrgOwnedDeleteBody = z.object({ previewHash: z.string().min(1).max(128) }).strict();
|
|
15
|
+
export const ORG_PLUGIN_UPLOAD_ROUTES = [
|
|
16
|
+
{ route: "GET /api/v1/orgs/:orgId/catalog/uploads/:stagingId", params: OrgUploadStagingParams },
|
|
17
|
+
{
|
|
18
|
+
route: "PUT /api/v1/orgs/:orgId/owned-plugins/:id/shareable",
|
|
19
|
+
params: OrgOwnedPluginParams,
|
|
20
|
+
body: OrgOwnedShareableBody,
|
|
21
|
+
},
|
|
22
|
+
{
|
|
23
|
+
route: "POST /api/v1/orgs/:orgId/owned-plugins/:id/delete/preview",
|
|
24
|
+
params: OrgOwnedPluginParams,
|
|
25
|
+
},
|
|
26
|
+
{
|
|
27
|
+
route: "POST /api/v1/orgs/:orgId/owned-plugins/:id/delete",
|
|
28
|
+
params: OrgOwnedPluginParams,
|
|
29
|
+
body: OrgOwnedDeleteBody,
|
|
30
|
+
},
|
|
31
|
+
{ route: "DELETE /api/v1/orgs/:orgId/owned-plugins/:id/pending", params: OrgOwnedPluginParams },
|
|
32
|
+
];
|
|
@@ -65,7 +65,9 @@ export declare class OwnedItems {
|
|
|
65
65
|
* 409 `catalog.not_owned`); one it promoted writes its platform row too (pre-flight F16). Audits
|
|
66
66
|
* `catalog.shareable_changed`.
|
|
67
67
|
*/
|
|
68
|
-
setShareable(orgId: string, actor: string, ref: OwnedRef, shareable: boolean, opts?: ActorOpts
|
|
68
|
+
setShareable(orgId: string, actor: string, ref: OwnedRef, shareable: boolean, opts?: ActorOpts & {
|
|
69
|
+
auditDetail?: Record<string, unknown>;
|
|
70
|
+
}): Promise<void>;
|
|
69
71
|
/** {@link setShareable} of an org skill or agent template (named by the org row's id). */
|
|
70
72
|
private setComponentShareable;
|
|
71
73
|
/** The other live orgs the item is on in (P3-18, {@link orgsUsing}), by name. */
|
|
@@ -86,7 +88,9 @@ export declare class OwnedItems {
|
|
|
86
88
|
* `owner_deleted` (another org using it keeps it, now the platform's), then the org row is
|
|
87
89
|
* soft-deleted as before (audit `skill.deleted`). Not an org-scope skill of the org -> 404.
|
|
88
90
|
*/
|
|
89
|
-
deleteSkill(orgId: string, actor: string, skillId: string, opts?: ActorOpts
|
|
91
|
+
deleteSkill(orgId: string, actor: string, skillId: string, opts?: ActorOpts & {
|
|
92
|
+
auditDetail?: Record<string, unknown>;
|
|
93
|
+
}): Promise<"transferred" | "removed">;
|
|
90
94
|
/**
|
|
91
95
|
* What deleting the org's own agent template `id` does (ruling P4-12, as
|
|
92
96
|
* {@link previewSkillDelete}): one it promoted that another org uses is `transferred` (`orgs`:
|
|
@@ -121,7 +121,7 @@ let OwnedItems = class OwnedItems {
|
|
|
121
121
|
orgId,
|
|
122
122
|
action: "catalog.shareable_changed",
|
|
123
123
|
target: item.id,
|
|
124
|
-
detail: { name: item.name, shareable },
|
|
124
|
+
detail: { name: item.name, shareable, ...opts.auditDetail },
|
|
125
125
|
});
|
|
126
126
|
}
|
|
127
127
|
/** {@link setShareable} of an org skill or agent template (named by the org row's id). */
|
|
@@ -165,6 +165,7 @@ let OwnedItems = class OwnedItems {
|
|
|
165
165
|
name: row.name,
|
|
166
166
|
shareable,
|
|
167
167
|
...(row.link !== null && { platformId: row.link }),
|
|
168
|
+
...opts.auditDetail,
|
|
168
169
|
},
|
|
169
170
|
});
|
|
170
171
|
}
|
|
@@ -221,7 +222,7 @@ let OwnedItems = class OwnedItems {
|
|
|
221
222
|
const outcome = row.link === null
|
|
222
223
|
? "removed"
|
|
223
224
|
: await this.transferOrRemove({ kind: "skill", id: row.link }, "owner_deleted", actor, opts);
|
|
224
|
-
await this.skills.deleteOrgSkillIn(orgId, row.id, actor, opts.actorTokenId);
|
|
225
|
+
await this.skills.deleteOrgSkillIn(orgId, row.id, actor, opts.actorTokenId, opts.auditDetail);
|
|
225
226
|
return outcome;
|
|
226
227
|
}
|
|
227
228
|
/**
|
|
@@ -266,7 +267,12 @@ let OwnedItems = class OwnedItems {
|
|
|
266
267
|
orgId,
|
|
267
268
|
action: "agent_template.deleted",
|
|
268
269
|
target: row.id,
|
|
269
|
-
detail: {
|
|
270
|
+
detail: {
|
|
271
|
+
name: row.name,
|
|
272
|
+
outcome,
|
|
273
|
+
...(row.link !== null && { platformId: row.link }),
|
|
274
|
+
...opts.auditDetail,
|
|
275
|
+
},
|
|
270
276
|
});
|
|
271
277
|
return outcome;
|
|
272
278
|
}
|
|
@@ -510,7 +516,13 @@ let OwnedItems = class OwnedItems {
|
|
|
510
516
|
orgId: owner,
|
|
511
517
|
action: "catalog.ownership_transferred",
|
|
512
518
|
target: item.id,
|
|
513
|
-
detail: {
|
|
519
|
+
detail: {
|
|
520
|
+
name: item.name,
|
|
521
|
+
fromOrgId: owner,
|
|
522
|
+
reason,
|
|
523
|
+
usedBy: others.map((o) => o.id),
|
|
524
|
+
...opts.auditDetail,
|
|
525
|
+
},
|
|
514
526
|
});
|
|
515
527
|
afterCommit(() => this.scope.enqueueSync(item.id));
|
|
516
528
|
return "transferred";
|
|
@@ -122,6 +122,8 @@ export interface OwnerVersion {
|
|
|
122
122
|
export interface UploadActor {
|
|
123
123
|
accountId: string;
|
|
124
124
|
actorTokenId?: string;
|
|
125
|
+
/** Added to the audit detail (the Platform tool's `via`). */
|
|
126
|
+
auditDetail?: Record<string, unknown>;
|
|
125
127
|
}
|
|
126
128
|
/**
|
|
127
129
|
* Writes the platform rows of a catalog version's components. Called by the import confirm that
|
|
@@ -346,6 +346,7 @@ let PlatformComponents = class PlatformComponents {
|
|
|
346
346
|
plugin: live.plugin_name,
|
|
347
347
|
from: live.current_version,
|
|
348
348
|
to,
|
|
349
|
+
...actor.auditDetail,
|
|
349
350
|
},
|
|
350
351
|
});
|
|
351
352
|
}
|
|
@@ -400,6 +401,7 @@ let PlatformComponents = class PlatformComponents {
|
|
|
400
401
|
plugin: live.plugin_name,
|
|
401
402
|
from: live.current_version,
|
|
402
403
|
to,
|
|
404
|
+
...actor.auditDetail,
|
|
403
405
|
},
|
|
404
406
|
});
|
|
405
407
|
}
|
|
@@ -896,7 +896,7 @@ let PluginInstaller = class PluginInstaller {
|
|
|
896
896
|
return null;
|
|
897
897
|
const name = manifest.name;
|
|
898
898
|
if (!this.registry.manifests().some((m) => m.name === name)) {
|
|
899
|
-
throw new ApiError("catalog.not_deployed", `The extension of plugin ${name} is not
|
|
899
|
+
throw new ApiError("catalog.not_deployed", `The extension of plugin ${name} is not running on the platform (not installed, waiting for its deployment config or permission approval, disabled, or failed to load); the org cannot switch it on until it runs`);
|
|
900
900
|
}
|
|
901
901
|
const enabled = await isExtensionEnabled(this.db, orgId, name);
|
|
902
902
|
if (!enabled && (await disabledPluginItems(this.db, [name])).length > 0) {
|
|
@@ -143,7 +143,8 @@ export declare class CatalogRequestsService {
|
|
|
143
143
|
* A request for a catalog item (`POST /orgs/:orgId/catalog/:itemId/requests`): `enable`
|
|
144
144
|
* (`catalog.request`, members and up) or `access` (`catalog.decide`, org admins), checked first.
|
|
145
145
|
* The item as the org sees it: absent (missing, deleted, hidden, disabled for a member) ->
|
|
146
|
-
* `catalog.item_not_found`; disabled -> `catalog.item_disabled` for an org admin;
|
|
146
|
+
* `catalog.item_not_found`; disabled -> `catalog.item_disabled` for an org admin; its extension
|
|
147
|
+
* unable to run on the platform -> `catalog.request_invalid`; `access` needs
|
|
147
148
|
* `not_offered`, `enable` needs `off` (else `catalog.request_invalid`); a pending request of the
|
|
148
149
|
* kind -> `catalog.request_pending`. Audits `catalog.requested`.
|
|
149
150
|
*/
|
|
@@ -95,7 +95,8 @@ let CatalogRequestsService = class CatalogRequestsService {
|
|
|
95
95
|
* A request for a catalog item (`POST /orgs/:orgId/catalog/:itemId/requests`): `enable`
|
|
96
96
|
* (`catalog.request`, members and up) or `access` (`catalog.decide`, org admins), checked first.
|
|
97
97
|
* The item as the org sees it: absent (missing, deleted, hidden, disabled for a member) ->
|
|
98
|
-
* `catalog.item_not_found`; disabled -> `catalog.item_disabled` for an org admin;
|
|
98
|
+
* `catalog.item_not_found`; disabled -> `catalog.item_disabled` for an org admin; its extension
|
|
99
|
+
* unable to run on the platform -> `catalog.request_invalid`; `access` needs
|
|
99
100
|
* `not_offered`, `enable` needs `off` (else `catalog.request_invalid`); a pending request of the
|
|
100
101
|
* kind -> `catalog.request_pending`. Audits `catalog.requested`.
|
|
101
102
|
*/
|
|
@@ -107,8 +108,11 @@ let CatalogRequestsService = class CatalogRequestsService {
|
|
|
107
108
|
const [item] = await this.orgCatalog.list(orgId, actor, itemId);
|
|
108
109
|
if (!item)
|
|
109
110
|
throw itemNotFound();
|
|
110
|
-
if (item.state === "unavailable")
|
|
111
|
+
if (item.state === "unavailable" && item.reason === "plugin_disabled")
|
|
111
112
|
throw itemDisabled();
|
|
113
|
+
if (item.state === "unavailable") {
|
|
114
|
+
throw new ApiError("catalog.request_invalid", `This plugin's extension cannot run on the platform now (${item.reason ?? "unavailable"}); only the super admin can fix that`);
|
|
115
|
+
}
|
|
112
116
|
const want = input.kind === "access" ? "not_offered" : "off";
|
|
113
117
|
if (item.state !== want) {
|
|
114
118
|
throw new ApiError("catalog.request_invalid", input.kind === "access"
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
import type { RouteSchemas } from "../platform/route-schemas.js";
|
|
3
|
+
export declare const ChannelCreateSchema: z.ZodObject<{
|
|
4
|
+
plugin: z.ZodString;
|
|
5
|
+
name: z.ZodString;
|
|
6
|
+
agentId: z.ZodString;
|
|
7
|
+
config: z.ZodRecord<z.ZodString, z.ZodUnknown>;
|
|
8
|
+
unboundPolicy: z.ZodOptional<z.ZodEnum<{
|
|
9
|
+
anonymous: "anonymous";
|
|
10
|
+
bind: "bind";
|
|
11
|
+
}>>;
|
|
12
|
+
}, z.core.$strict>;
|
|
13
|
+
export declare const ChannelPatchSchema: z.ZodObject<{
|
|
14
|
+
name: z.ZodOptional<z.ZodString>;
|
|
15
|
+
agentId: z.ZodOptional<z.ZodString>;
|
|
16
|
+
unboundPolicy: z.ZodOptional<z.ZodEnum<{
|
|
17
|
+
anonymous: "anonymous";
|
|
18
|
+
bind: "bind";
|
|
19
|
+
}>>;
|
|
20
|
+
status: z.ZodOptional<z.ZodEnum<{
|
|
21
|
+
active: "active";
|
|
22
|
+
disabled: "disabled";
|
|
23
|
+
}>>;
|
|
24
|
+
inboundMode: z.ZodOptional<z.ZodEnum<{
|
|
25
|
+
long_connection: "long_connection";
|
|
26
|
+
webhook: "webhook";
|
|
27
|
+
}>>;
|
|
28
|
+
config: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
|
|
29
|
+
}, z.core.$strict>;
|
|
30
|
+
export declare const ChannelPathParams: z.ZodObject<{
|
|
31
|
+
connectionId: z.ZodString;
|
|
32
|
+
}, z.core.$strip>;
|
|
33
|
+
export declare const CHANNEL_ROUTES: readonly RouteSchemas[];
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
const Config = z.record(z.string().max(200), z.unknown());
|
|
3
|
+
const Policy = z.enum(["bind", "anonymous"]);
|
|
4
|
+
export const ChannelCreateSchema = z
|
|
5
|
+
.object({
|
|
6
|
+
plugin: z.string().min(1).max(214),
|
|
7
|
+
name: z.string().trim().min(1).max(100),
|
|
8
|
+
agentId: z.string().min(1).max(100),
|
|
9
|
+
config: Config,
|
|
10
|
+
unboundPolicy: Policy.optional(),
|
|
11
|
+
})
|
|
12
|
+
.strict();
|
|
13
|
+
export const ChannelPatchSchema = z
|
|
14
|
+
.object({
|
|
15
|
+
name: z.string().trim().min(1).max(100).optional(),
|
|
16
|
+
agentId: z.string().min(1).max(100).optional(),
|
|
17
|
+
unboundPolicy: Policy.optional(),
|
|
18
|
+
status: z.enum(["active", "disabled"]).optional(),
|
|
19
|
+
// webhook needs plugin support and channels.webhookBaseUrl (409 channel.webhook_unavailable)
|
|
20
|
+
inboundMode: z.enum(["long_connection", "webhook"]).optional(),
|
|
21
|
+
config: Config.optional(),
|
|
22
|
+
})
|
|
23
|
+
.strict();
|
|
24
|
+
export const ChannelPathParams = z.object({ connectionId: z.string().min(1).max(100) });
|
|
25
|
+
export const CHANNEL_ROUTES = [
|
|
26
|
+
{ route: "GET /api/v1/orgs/:orgId/channels" },
|
|
27
|
+
{ route: "GET /api/v1/orgs/:orgId/channels/:connectionId", params: ChannelPathParams },
|
|
28
|
+
{
|
|
29
|
+
route: "PATCH /api/v1/orgs/:orgId/channels/:connectionId",
|
|
30
|
+
params: ChannelPathParams,
|
|
31
|
+
body: ChannelPatchSchema,
|
|
32
|
+
},
|
|
33
|
+
{ route: "DELETE /api/v1/orgs/:orgId/channels/:connectionId", params: ChannelPathParams },
|
|
34
|
+
];
|