@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
|
@@ -13,26 +13,13 @@ import { ApiError } from "../errors.js";
|
|
|
13
13
|
import { CurrentPrincipal, patTokenId, requireUser, SuperAdmin, } from "../identity/principal.js";
|
|
14
14
|
import { createZodDto } from "../infra/validation/create-zod-dto.js";
|
|
15
15
|
import { ZBody, ZQuery } from "../infra/validation/zod-params.js";
|
|
16
|
-
import {
|
|
16
|
+
import { CatalogItemsQuery, CatalogUpdateBody, CatalogUpdatePreviewBody, CatalogDisabledBody as DisabledBody, CatalogGitImportBody as GitBody, CatalogHash as Hash, CatalogNpmImportBody as NpmBody, CatalogScopeOrgs as Orgs, CatalogScope as Scope, CatalogScopeBody as ScopeBody, CatalogScopePreviewBody as ScopePreviewBody, CatalogShownBody as ShownBody, } from "./admin-catalog.schemas.js";
|
|
17
|
+
import { CatalogService, } from "./catalog.service.js";
|
|
17
18
|
import { CatalogScopeService } from "./catalog-scope.service.js";
|
|
18
19
|
import { sendCatalogIcon } from "./org-catalog.controller.js";
|
|
19
20
|
import { OrgCatalogService } from "./org-catalog.service.js";
|
|
20
21
|
import { PluginImport } from "./plugin-import.js";
|
|
21
22
|
import { PlatformPluginUpdater, } from "./plugin-upgrade.js";
|
|
22
|
-
const NpmBody = z.object({
|
|
23
|
-
package: z.string().min(1).max(214),
|
|
24
|
-
version: z.string().min(1).max(256).optional(),
|
|
25
|
-
});
|
|
26
|
-
const GitBody = z
|
|
27
|
-
.object({
|
|
28
|
-
url: z.string().min(1).max(2000),
|
|
29
|
-
ref: z.string().min(1).max(256).optional(),
|
|
30
|
-
path: z.string().min(1).max(512).optional(),
|
|
31
|
-
})
|
|
32
|
-
.strict();
|
|
33
|
-
const Scope = z.enum(["all", "optional", "named"]);
|
|
34
|
-
const Orgs = z.array(z.string().min(1).max(128)).max(1000);
|
|
35
|
-
const Hash = z.string().min(1).max(128);
|
|
36
23
|
const ConfirmBody = z
|
|
37
24
|
.object({
|
|
38
25
|
reviewHash: Hash,
|
|
@@ -43,33 +30,9 @@ const ConfirmBody = z
|
|
|
43
30
|
pinnedSuggestions: z.array(z.string().min(1).max(64)).max(50).optional(),
|
|
44
31
|
})
|
|
45
32
|
.strict();
|
|
46
|
-
/** `{ scope, orgs? }` (a scope change) or `{ disabled: true }` (a disable), not both. */
|
|
47
|
-
const ScopePreviewBody = z
|
|
48
|
-
.object({ scope: Scope.optional(), orgs: Orgs.optional(), disabled: z.literal(true).optional() })
|
|
49
|
-
.strict()
|
|
50
|
-
.refine((b) => (b.disabled === true) !== (b.scope !== undefined), {
|
|
51
|
-
message: "send either scope (with orgs for named) or disabled: true",
|
|
52
|
-
})
|
|
53
|
-
.refine((b) => b.disabled === undefined || b.orgs === undefined, {
|
|
54
|
-
message: "orgs: only allowed with scope named",
|
|
55
|
-
path: ["orgs"],
|
|
56
|
-
});
|
|
57
|
-
const ScopeBody = z.object({ scope: Scope, orgs: Orgs.optional(), scopeHash: Hash }).strict();
|
|
58
|
-
const DisabledBody = z.object({ disabled: z.boolean(), scopeHash: Hash.optional() }).strict();
|
|
59
|
-
const ShownBody = z.object({ shownToOthers: z.boolean() }).strict();
|
|
60
|
-
const ListQuery = z.object({
|
|
61
|
-
includeDeleted: z.enum(["true", "false"]).optional(),
|
|
62
|
-
limit: z.coerce.number().int().min(1).max(CATALOG_LIST_MAX_LIMIT).optional(),
|
|
63
|
-
offset: z.coerce.number().int().min(0).max(1_000_000).optional(),
|
|
64
|
-
/** `true`: only the items waiting for a permission confirmation (not paged). */
|
|
65
|
-
pending: z.enum(["true", "false"]).optional(),
|
|
66
|
-
});
|
|
67
33
|
const ConfirmPermissionsBody = z.object({ permissionsHash: Hash }).strict();
|
|
68
34
|
/** The reason shown to the owner org in its `upload_rejected` notice (optional). */
|
|
69
35
|
const RejectBody = z.object({ reason: z.string().trim().min(1).max(1000).optional() }).strict();
|
|
70
|
-
const Version = z.string().min(1).max(256);
|
|
71
|
-
const UpdatePreviewBody = z.object({ version: Version }).strict();
|
|
72
|
-
const UpdateBody = z.object({ version: Version, diffHash: Hash }).strict();
|
|
73
36
|
const actorOpts = (actor) => {
|
|
74
37
|
const tokenId = patTokenId(actor);
|
|
75
38
|
return tokenId !== undefined ? { actorTokenId: tokenId } : {};
|
|
@@ -78,7 +41,7 @@ class CatalogImportConfirmBody extends createZodDto(ConfirmBody, "CatalogImportC
|
|
|
78
41
|
}
|
|
79
42
|
class CatalogGitImportBody extends createZodDto(GitBody, "CatalogGitImportBody") {
|
|
80
43
|
}
|
|
81
|
-
class
|
|
44
|
+
class CatalogItemsQueryDto extends createZodDto(CatalogItemsQuery, "CatalogItemsQuery") {
|
|
82
45
|
}
|
|
83
46
|
class CatalogNpmImportBody extends createZodDto(NpmBody, "CatalogNpmImportBody") {
|
|
84
47
|
}
|
|
@@ -94,9 +57,9 @@ class CatalogRejectBody extends createZodDto(RejectBody, "CatalogRejectBody") {
|
|
|
94
57
|
}
|
|
95
58
|
class CatalogDisabledBody extends createZodDto(DisabledBody, "CatalogDisabledBody") {
|
|
96
59
|
}
|
|
97
|
-
class
|
|
60
|
+
class CatalogUpdatePreviewBodyDto extends createZodDto(CatalogUpdatePreviewBody, "CatalogUpdatePreviewBody") {
|
|
98
61
|
}
|
|
99
|
-
class
|
|
62
|
+
class CatalogUpdateBodyDto extends createZodDto(CatalogUpdateBody, "CatalogUpdateBody") {
|
|
100
63
|
}
|
|
101
64
|
/**
|
|
102
65
|
* The platform catalog (`/api/v1/admin/catalog/*`, super admins): plugin import (upload / npm
|
|
@@ -351,7 +314,7 @@ __decorate([
|
|
|
351
314
|
], AdminCatalogController.prototype, "confirm", null);
|
|
352
315
|
__decorate([
|
|
353
316
|
Get("items"),
|
|
354
|
-
__param(0, ZQuery(
|
|
317
|
+
__param(0, ZQuery(CatalogItemsQueryDto))
|
|
355
318
|
], AdminCatalogController.prototype, "list", null);
|
|
356
319
|
__decorate([
|
|
357
320
|
Get("items/:id"),
|
|
@@ -404,13 +367,13 @@ __decorate([
|
|
|
404
367
|
Post("items/:id/update/preview"),
|
|
405
368
|
HttpCode(200),
|
|
406
369
|
__param(0, Param("id")),
|
|
407
|
-
__param(1, ZBody(
|
|
370
|
+
__param(1, ZBody(CatalogUpdatePreviewBodyDto))
|
|
408
371
|
], AdminCatalogController.prototype, "previewUpdate", null);
|
|
409
372
|
__decorate([
|
|
410
373
|
Put("items/:id/update"),
|
|
411
374
|
__param(0, CurrentPrincipal()),
|
|
412
375
|
__param(1, Param("id")),
|
|
413
|
-
__param(2, ZBody(
|
|
376
|
+
__param(2, ZBody(CatalogUpdateBodyDto))
|
|
414
377
|
], AdminCatalogController.prototype, "update", null);
|
|
415
378
|
__decorate([
|
|
416
379
|
Delete("items/:id"),
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
import type { RouteSchemas } from "../platform/route-schemas.js";
|
|
3
|
+
export declare const CatalogHash: z.ZodString;
|
|
4
|
+
export declare const CatalogItemsQuery: z.ZodObject<{
|
|
5
|
+
includeDeleted: z.ZodOptional<z.ZodEnum<{
|
|
6
|
+
false: "false";
|
|
7
|
+
true: "true";
|
|
8
|
+
}>>;
|
|
9
|
+
limit: z.ZodOptional<z.ZodCoercedNumber<unknown>>;
|
|
10
|
+
offset: z.ZodOptional<z.ZodCoercedNumber<unknown>>;
|
|
11
|
+
pending: z.ZodOptional<z.ZodEnum<{
|
|
12
|
+
false: "false";
|
|
13
|
+
true: "true";
|
|
14
|
+
}>>;
|
|
15
|
+
}, z.core.$strip>;
|
|
16
|
+
export declare const CatalogUpdatePreviewBody: z.ZodObject<{
|
|
17
|
+
version: z.ZodString;
|
|
18
|
+
}, z.core.$strict>;
|
|
19
|
+
export declare const CatalogUpdateBody: z.ZodObject<{
|
|
20
|
+
version: z.ZodString;
|
|
21
|
+
diffHash: z.ZodString;
|
|
22
|
+
}, z.core.$strict>;
|
|
23
|
+
/** `:id` as the routes take it (`@Param`). */
|
|
24
|
+
export declare const CatalogIdPathParams: z.ZodObject<{
|
|
25
|
+
id: z.ZodString;
|
|
26
|
+
}, z.core.$strip>;
|
|
27
|
+
/** `:stagingId` of a staged import as the route takes it (`@Param`). */
|
|
28
|
+
export declare const CatalogStagingPathParams: z.ZodObject<{
|
|
29
|
+
stagingId: z.ZodString;
|
|
30
|
+
}, z.core.$strip>;
|
|
31
|
+
export declare const CatalogNpmImportBody: z.ZodObject<{
|
|
32
|
+
package: z.ZodString;
|
|
33
|
+
version: z.ZodOptional<z.ZodString>;
|
|
34
|
+
}, z.core.$strip>;
|
|
35
|
+
export declare const CatalogGitImportBody: z.ZodObject<{
|
|
36
|
+
url: z.ZodString;
|
|
37
|
+
ref: z.ZodOptional<z.ZodString>;
|
|
38
|
+
path: z.ZodOptional<z.ZodString>;
|
|
39
|
+
}, z.core.$strict>;
|
|
40
|
+
export declare const CatalogScope: z.ZodEnum<{
|
|
41
|
+
all: "all";
|
|
42
|
+
named: "named";
|
|
43
|
+
optional: "optional";
|
|
44
|
+
}>;
|
|
45
|
+
export declare const CatalogScopeOrgs: z.ZodArray<z.ZodString>;
|
|
46
|
+
/** `{ scope, orgs? }` (a scope change) or `{ disabled: true }` (a disable), not both. */
|
|
47
|
+
export declare const CatalogScopePreviewBody: z.ZodObject<{
|
|
48
|
+
scope: z.ZodOptional<z.ZodEnum<{
|
|
49
|
+
all: "all";
|
|
50
|
+
named: "named";
|
|
51
|
+
optional: "optional";
|
|
52
|
+
}>>;
|
|
53
|
+
orgs: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
54
|
+
disabled: z.ZodOptional<z.ZodLiteral<true>>;
|
|
55
|
+
}, z.core.$strict>;
|
|
56
|
+
export declare const CatalogScopeBody: z.ZodObject<{
|
|
57
|
+
scope: z.ZodEnum<{
|
|
58
|
+
all: "all";
|
|
59
|
+
named: "named";
|
|
60
|
+
optional: "optional";
|
|
61
|
+
}>;
|
|
62
|
+
orgs: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
63
|
+
scopeHash: z.ZodString;
|
|
64
|
+
}, z.core.$strict>;
|
|
65
|
+
export declare const CatalogDisabledBody: z.ZodObject<{
|
|
66
|
+
disabled: z.ZodBoolean;
|
|
67
|
+
scopeHash: z.ZodOptional<z.ZodString>;
|
|
68
|
+
}, z.core.$strict>;
|
|
69
|
+
export declare const CatalogShownBody: z.ZodObject<{
|
|
70
|
+
shownToOthers: z.ZodBoolean;
|
|
71
|
+
}, z.core.$strict>;
|
|
72
|
+
export declare const ADMIN_CATALOG_ROUTES: readonly RouteSchemas[];
|
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
import { CATALOG_LIST_MAX_LIMIT } from "./catalog.service.js";
|
|
3
|
+
export const CatalogHash = z.string().min(1).max(128);
|
|
4
|
+
export const CatalogItemsQuery = z.object({
|
|
5
|
+
includeDeleted: z.enum(["true", "false"]).optional(),
|
|
6
|
+
limit: z.coerce.number().int().min(1).max(CATALOG_LIST_MAX_LIMIT).optional(),
|
|
7
|
+
offset: z.coerce.number().int().min(0).max(1_000_000).optional(),
|
|
8
|
+
/** `true`: only the items waiting for a permission confirmation (not paged). */
|
|
9
|
+
pending: z.enum(["true", "false"]).optional(),
|
|
10
|
+
});
|
|
11
|
+
const CatalogVersion = z.string().min(1).max(256);
|
|
12
|
+
export const CatalogUpdatePreviewBody = z.object({ version: CatalogVersion }).strict();
|
|
13
|
+
export const CatalogUpdateBody = z
|
|
14
|
+
.object({ version: CatalogVersion, diffHash: CatalogHash })
|
|
15
|
+
.strict();
|
|
16
|
+
/** `:id` as the routes take it (`@Param`). */
|
|
17
|
+
export const CatalogIdPathParams = z.object({ id: z.string().min(1) });
|
|
18
|
+
/** `:stagingId` of a staged import as the route takes it (`@Param`). */
|
|
19
|
+
export const CatalogStagingPathParams = z.object({ stagingId: z.string().min(1) });
|
|
20
|
+
export const CatalogNpmImportBody = z.object({
|
|
21
|
+
package: z.string().min(1).max(214),
|
|
22
|
+
version: z.string().min(1).max(256).optional(),
|
|
23
|
+
});
|
|
24
|
+
export const CatalogGitImportBody = z
|
|
25
|
+
.object({
|
|
26
|
+
url: z.string().min(1).max(2000),
|
|
27
|
+
ref: z.string().min(1).max(256).optional(),
|
|
28
|
+
path: z.string().min(1).max(512).optional(),
|
|
29
|
+
})
|
|
30
|
+
.strict();
|
|
31
|
+
export const CatalogScope = z.enum(["all", "optional", "named"]);
|
|
32
|
+
export const CatalogScopeOrgs = z.array(z.string().min(1).max(128)).max(1000);
|
|
33
|
+
/** `{ scope, orgs? }` (a scope change) or `{ disabled: true }` (a disable), not both. */
|
|
34
|
+
export const CatalogScopePreviewBody = z
|
|
35
|
+
.object({
|
|
36
|
+
scope: CatalogScope.optional(),
|
|
37
|
+
orgs: CatalogScopeOrgs.optional(),
|
|
38
|
+
disabled: z.literal(true).optional(),
|
|
39
|
+
})
|
|
40
|
+
.strict()
|
|
41
|
+
.refine((b) => (b.disabled === true) !== (b.scope !== undefined), {
|
|
42
|
+
message: "send either scope (with orgs for named) or disabled: true",
|
|
43
|
+
})
|
|
44
|
+
.refine((b) => b.disabled === undefined || b.orgs === undefined, {
|
|
45
|
+
message: "orgs: only allowed with scope named",
|
|
46
|
+
path: ["orgs"],
|
|
47
|
+
});
|
|
48
|
+
export const CatalogScopeBody = z
|
|
49
|
+
.object({ scope: CatalogScope, orgs: CatalogScopeOrgs.optional(), scopeHash: CatalogHash })
|
|
50
|
+
.strict();
|
|
51
|
+
export const CatalogDisabledBody = z
|
|
52
|
+
.object({ disabled: z.boolean(), scopeHash: CatalogHash.optional() })
|
|
53
|
+
.strict();
|
|
54
|
+
export const CatalogShownBody = z.object({ shownToOthers: z.boolean() }).strict();
|
|
55
|
+
export const ADMIN_CATALOG_ROUTES = [
|
|
56
|
+
{ route: "GET /api/v1/admin/catalog/items", query: CatalogItemsQuery },
|
|
57
|
+
{ route: "GET /api/v1/admin/catalog/items/:id", params: CatalogIdPathParams },
|
|
58
|
+
{
|
|
59
|
+
route: "POST /api/v1/admin/catalog/items/:id/update/preview",
|
|
60
|
+
params: CatalogIdPathParams,
|
|
61
|
+
body: CatalogUpdatePreviewBody,
|
|
62
|
+
},
|
|
63
|
+
{
|
|
64
|
+
route: "PUT /api/v1/admin/catalog/items/:id/update",
|
|
65
|
+
params: CatalogIdPathParams,
|
|
66
|
+
body: CatalogUpdateBody,
|
|
67
|
+
},
|
|
68
|
+
{ route: "POST /api/v1/admin/catalog/import/npm", body: CatalogNpmImportBody },
|
|
69
|
+
{ route: "POST /api/v1/admin/catalog/import/git", body: CatalogGitImportBody },
|
|
70
|
+
{ route: "GET /api/v1/admin/catalog/imports/:stagingId", params: CatalogStagingPathParams },
|
|
71
|
+
{
|
|
72
|
+
route: "POST /api/v1/admin/catalog/items/:id/scope/preview",
|
|
73
|
+
params: CatalogIdPathParams,
|
|
74
|
+
body: CatalogScopePreviewBody,
|
|
75
|
+
},
|
|
76
|
+
{
|
|
77
|
+
route: "PUT /api/v1/admin/catalog/items/:id/scope",
|
|
78
|
+
params: CatalogIdPathParams,
|
|
79
|
+
body: CatalogScopeBody,
|
|
80
|
+
},
|
|
81
|
+
{
|
|
82
|
+
route: "PUT /api/v1/admin/catalog/items/:id/disabled",
|
|
83
|
+
params: CatalogIdPathParams,
|
|
84
|
+
body: CatalogDisabledBody,
|
|
85
|
+
},
|
|
86
|
+
{
|
|
87
|
+
route: "PUT /api/v1/admin/catalog/items/:id/shown",
|
|
88
|
+
params: CatalogIdPathParams,
|
|
89
|
+
body: CatalogShownBody,
|
|
90
|
+
},
|
|
91
|
+
{ route: "DELETE /api/v1/admin/catalog/items/:id", params: CatalogIdPathParams },
|
|
92
|
+
];
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { type AgentTemplate, type Connector, type ConnectorTemplateFile, type ConnectorTemplateSpec, type LocalizedName, type PluginManifest } from "@capybara-hq/plugin-sdk";
|
|
2
2
|
import type { KernelSchemaDb } from "../db/kernel-schema.js";
|
|
3
3
|
import type { ExtensionRegistry } from "../extensions/registry.js";
|
|
4
|
+
import type { ExtensionUnavailableReason } from "../extensions/unavailable.js";
|
|
4
5
|
import type { OrgLock } from "../orgs/org-lock.js";
|
|
5
6
|
import { type OrgAction } from "../orgs/roles.js";
|
|
6
7
|
import { checkSkillFiles, type SkillPackageFile } from "../skills/package.js";
|
|
@@ -10,6 +11,8 @@ import type { CatalogItemView } from "./catalog.service.js";
|
|
|
10
11
|
import type { ConnectorInstallInput, PluginInstallInput, PluginInstallView } from "./plugin-install.js";
|
|
11
12
|
import type { OrgPluginState, PluginScope } from "./scope.js";
|
|
12
13
|
/** A catalog item from an organization's view (`GET /orgs/:orgId/catalog`). */
|
|
14
|
+
/** Why an org's plugin is `unavailable` ({@link OrgCatalogItem.reason}). */
|
|
15
|
+
export type PluginUnavailableReason = "plugin_disabled" | ExtensionUnavailableReason;
|
|
13
16
|
export interface OrgCatalogItem extends Omit<CatalogItemView, "installs" | "marketplaceId" | "latestMarketplaceVersion" | "newerInMarketplace" | "scopeOrgs" | "enabledOrgs" | "offCount" | "pending" | "shownToOthers" | "awaitingConfirmation" | "pendingVersion"> {
|
|
14
17
|
/** The owner org only (absent for other orgs): its upload waits for the super admin (P3-9). */
|
|
15
18
|
awaitingConfirmation?: boolean;
|
|
@@ -21,10 +24,17 @@ export interface OrgCatalogItem extends Omit<CatalogItemView, "installs" | "mark
|
|
|
21
24
|
/**
|
|
22
25
|
* The effective state in this org: `on`, `off`, `needs_config` (installed with an on connector
|
|
23
26
|
* template that has no connector here, ruling P2-10; or wanted but not installed, and the
|
|
24
|
-
* install needs inputs), `unavailable` (disabled by the super admin
|
|
25
|
-
*
|
|
27
|
+
* install needs inputs), `unavailable` (disabled by the super admin, members don't see it; or
|
|
28
|
+
* not installed here and its extension cannot run on the deployment, see `reason`) or
|
|
29
|
+
* `not_offered` (a `named` item shown to orgs outside its list: requestable, not usable).
|
|
26
30
|
*/
|
|
27
31
|
state: OrgPluginState;
|
|
32
|
+
/**
|
|
33
|
+
* Only when `unavailable`: why (Platform tool spec §14.2 problem 1). `plugin_disabled`: the super
|
|
34
|
+
* admin disabled the item; otherwise its extension's {@link ExtensionUnavailableReason}, the same
|
|
35
|
+
* one the org's 扩展 page shows.
|
|
36
|
+
*/
|
|
37
|
+
reason?: PluginUnavailableReason;
|
|
28
38
|
/** The org admin may switch it (never for `all` and builtin items). */
|
|
29
39
|
switchable: boolean;
|
|
30
40
|
/** The plugin's extension (or a template's connector extension) is not on the deployment. */
|
|
@@ -596,6 +596,7 @@ let CatalogScopeService = class CatalogScopeService {
|
|
|
596
596
|
ownerOrgId: item.owner_org_id,
|
|
597
597
|
removed: item.awaiting_confirmation,
|
|
598
598
|
...(how.kind === "reject" && { reason: how.reason }),
|
|
599
|
+
...opts.auditDetail,
|
|
599
600
|
},
|
|
600
601
|
});
|
|
601
602
|
}
|
|
@@ -661,7 +662,7 @@ let CatalogScopeService = class CatalogScopeService {
|
|
|
661
662
|
...(opts.actorTokenId !== undefined && { actorTokenId: opts.actorTokenId }),
|
|
662
663
|
action: "catalog.shown_changed",
|
|
663
664
|
target: itemId,
|
|
664
|
-
detail: { name: item.name, from: item.shown_to_others, to: shown },
|
|
665
|
+
detail: { name: item.name, from: item.shown_to_others, to: shown, ...opts.auditDetail },
|
|
665
666
|
});
|
|
666
667
|
}
|
|
667
668
|
async writeScope(actor, itemId, target, hash, opts) {
|
|
@@ -710,6 +711,7 @@ let CatalogScopeService = class CatalogScopeService {
|
|
|
710
711
|
name: item.name,
|
|
711
712
|
from: { scope: item.scope, orgs: from },
|
|
712
713
|
to: { scope: t.scope, orgs: t.orgs },
|
|
714
|
+
...opts.auditDetail,
|
|
713
715
|
},
|
|
714
716
|
});
|
|
715
717
|
afterCommit(() => this.enqueue(itemId));
|
|
@@ -740,7 +742,11 @@ let CatalogScopeService = class CatalogScopeService {
|
|
|
740
742
|
...(opts.actorTokenId !== undefined && { actorTokenId: opts.actorTokenId }),
|
|
741
743
|
action: "catalog.scope_changed",
|
|
742
744
|
target: itemId,
|
|
743
|
-
detail: {
|
|
745
|
+
detail: {
|
|
746
|
+
name: item.name,
|
|
747
|
+
disabled: { from: item.disabled, to: disabled },
|
|
748
|
+
...opts.auditDetail,
|
|
749
|
+
},
|
|
744
750
|
});
|
|
745
751
|
afterCommit(() => this.enqueue(itemId));
|
|
746
752
|
}
|
|
@@ -186,6 +186,8 @@ export interface CatalogItemDetail {
|
|
|
186
186
|
/** Audits carry the PAT when a personal token made the call. */
|
|
187
187
|
export interface ActorOpts {
|
|
188
188
|
actorTokenId?: string;
|
|
189
|
+
/** Merged into the audit detail (a write made through the Platform tool: `via`, …). */
|
|
190
|
+
auditDetail?: Record<string, unknown>;
|
|
189
191
|
}
|
|
190
192
|
/**
|
|
191
193
|
* The marketplace's permission summary differs from the keys computed from the package (a warning,
|
|
@@ -164,6 +164,7 @@ let CatalogService = class CatalogService {
|
|
|
164
164
|
}
|
|
165
165
|
const prepareOpts = {
|
|
166
166
|
...(opts.actorTokenId !== undefined && { actorTokenId: opts.actorTokenId }),
|
|
167
|
+
...(opts.auditDetail !== undefined && { auditDetail: opts.auditDetail }),
|
|
167
168
|
expect: {
|
|
168
169
|
marketplace: {
|
|
169
170
|
name: entry.name,
|
|
@@ -300,6 +301,7 @@ let CatalogService = class CatalogService {
|
|
|
300
301
|
: where.detail.path.split("/").pop();
|
|
301
302
|
const r = await this.pluginImport.prepareGit(actor, read.files, { kind: "git", ref: where.ref, detail: where.detail }, {
|
|
302
303
|
...(opts.actorTokenId !== undefined && { actorTokenId: opts.actorTokenId }),
|
|
304
|
+
...(opts.auditDetail !== undefined && { auditDetail: opts.auditDetail }),
|
|
303
305
|
fallback: {
|
|
304
306
|
name: pluginNameFrom(segment),
|
|
305
307
|
version: gitFallbackVersion(read.commit),
|
|
@@ -520,6 +522,7 @@ let CatalogService = class CatalogService {
|
|
|
520
522
|
name: row.name,
|
|
521
523
|
...(row.owner_org_id !== null && { ownerOrgId: row.owner_org_id }),
|
|
522
524
|
...(opts.reason !== undefined && { reason: opts.reason }),
|
|
525
|
+
...opts.auditDetail,
|
|
523
526
|
},
|
|
524
527
|
});
|
|
525
528
|
return { name: row.name };
|
|
@@ -1,70 +1,9 @@
|
|
|
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
|
+
import { ComponentParams, ComponentDisabledSchema as DisabledBody, ComponentIdSchema as IdParams, ComponentListQuery as ListQuery, OrgComponentListQuery, ComponentScopePreviewSchema as PreviewBody, ComponentScopeSchema as ScopeBody, ComponentShownSchema as ShownBody, ComponentSwitchBody as SwitchBody, ComponentTemplateVersionSchema as TemplateVersionBody } from "./component-scope.schemas.js";
|
|
4
5
|
import { type ComponentScopePreview, ComponentScopeService, type ComponentVersionView, type ComponentView, type OrgComponentView, type OrgOfferedComponentView } from "./component-scope.service.js";
|
|
5
6
|
import { PlatformComponents, type UploadedComponentVersion } from "./platform-components.js";
|
|
6
|
-
declare const ComponentParams: z.ZodObject<{
|
|
7
|
-
kind: z.ZodEnum<{
|
|
8
|
-
agent_template: "agent_template";
|
|
9
|
-
connector_template: "connector_template";
|
|
10
|
-
skill: "skill";
|
|
11
|
-
}>;
|
|
12
|
-
id: z.ZodString;
|
|
13
|
-
}, z.core.$strip>;
|
|
14
|
-
declare const ListQuery: z.ZodObject<{
|
|
15
|
-
kind: z.ZodEnum<{
|
|
16
|
-
agent_template: "agent_template";
|
|
17
|
-
connector_template: "connector_template";
|
|
18
|
-
skill: "skill";
|
|
19
|
-
}>;
|
|
20
|
-
}, z.core.$strict>;
|
|
21
|
-
declare const OrgListQuery: z.ZodObject<{
|
|
22
|
-
kind: z.ZodOptional<z.ZodEnum<{
|
|
23
|
-
agent_template: "agent_template";
|
|
24
|
-
connector_template: "connector_template";
|
|
25
|
-
skill: "skill";
|
|
26
|
-
}>>;
|
|
27
|
-
itemId: z.ZodOptional<z.ZodString>;
|
|
28
|
-
}, z.core.$strict>;
|
|
29
|
-
/** `{ scope, orgs? }`, `{ disabled: true }` or `{ follow: true }`: exactly one. */
|
|
30
|
-
declare const PreviewBody: z.ZodObject<{
|
|
31
|
-
scope: z.ZodOptional<z.ZodEnum<{
|
|
32
|
-
all: "all";
|
|
33
|
-
named: "named";
|
|
34
|
-
optional: "optional";
|
|
35
|
-
}>>;
|
|
36
|
-
orgs: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
37
|
-
disabled: z.ZodOptional<z.ZodLiteral<true>>;
|
|
38
|
-
follow: z.ZodOptional<z.ZodLiteral<true>>;
|
|
39
|
-
}, z.core.$strict>;
|
|
40
|
-
/** `{ scope, orgs?, scopeHash }` or `{ follow: true, scopeHash }`. */
|
|
41
|
-
declare const ScopeBody: z.ZodObject<{
|
|
42
|
-
scope: z.ZodOptional<z.ZodEnum<{
|
|
43
|
-
all: "all";
|
|
44
|
-
named: "named";
|
|
45
|
-
optional: "optional";
|
|
46
|
-
}>>;
|
|
47
|
-
orgs: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
48
|
-
follow: z.ZodOptional<z.ZodLiteral<true>>;
|
|
49
|
-
scopeHash: z.ZodString;
|
|
50
|
-
}, z.core.$strict>;
|
|
51
|
-
declare const DisabledBody: z.ZodObject<{
|
|
52
|
-
disabled: z.ZodBoolean;
|
|
53
|
-
scopeHash: z.ZodOptional<z.ZodString>;
|
|
54
|
-
}, z.core.$strict>;
|
|
55
|
-
declare const ShownBody: z.ZodObject<{
|
|
56
|
-
shownToOthers: z.ZodBoolean;
|
|
57
|
-
}, z.core.$strict>;
|
|
58
|
-
declare const SwitchBody: z.ZodObject<{
|
|
59
|
-
enabled: z.ZodBoolean;
|
|
60
|
-
confirm: z.ZodOptional<z.ZodString>;
|
|
61
|
-
}, z.core.$strict>;
|
|
62
|
-
declare const IdParams: z.ZodObject<{
|
|
63
|
-
id: z.ZodString;
|
|
64
|
-
}, z.core.$strip>;
|
|
65
|
-
declare const TemplateVersionBody: z.ZodObject<{
|
|
66
|
-
content: z.ZodString;
|
|
67
|
-
}, z.core.$strict>;
|
|
68
7
|
/**
|
|
69
8
|
* Platform components (`/api/v1/admin/components/*`, super admins; plugin scope phase 2, Task 6):
|
|
70
9
|
* the global list of skills, agent templates and connector templates, and each one's own scope,
|
|
@@ -132,7 +71,7 @@ export declare class OrgComponentsController {
|
|
|
132
71
|
* with its state in the org (`on`, `locked` for `all`, the org's `switch`) and whether an org
|
|
133
72
|
* admin may switch it. Members read it (the workspace pages are read-only for them).
|
|
134
73
|
*/
|
|
135
|
-
list(org: OrgContext, q: z.infer<typeof
|
|
74
|
+
list(org: OrgContext, q: z.infer<typeof OrgComponentListQuery>): Promise<{
|
|
136
75
|
components: OrgOfferedComponentView[];
|
|
137
76
|
}>;
|
|
138
77
|
setSwitch(principal: Principal, org: OrgContext, p: z.infer<typeof ComponentParams>, body: z.infer<typeof SwitchBody>): Promise<{
|
|
@@ -149,4 +88,3 @@ export declare class OrgComponentsController {
|
|
|
149
88
|
confirm: string;
|
|
150
89
|
}>;
|
|
151
90
|
}
|
|
152
|
-
export {};
|
|
@@ -8,67 +8,14 @@ var __param = (this && this.__param) || function (paramIndex, decorator) {
|
|
|
8
8
|
return function (target, key) { decorator(target, key, paramIndex); }
|
|
9
9
|
};
|
|
10
10
|
import { Controller, 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, SuperAdmin, } from "../identity/principal.js";
|
|
14
13
|
import { createZodDto } from "../infra/validation/create-zod-dto.js";
|
|
15
14
|
import { ZBody, ZParam, ZQuery } from "../infra/validation/zod-params.js";
|
|
16
15
|
import { CurrentOrg, OrgAction } from "../orgs/org.guard.js";
|
|
16
|
+
import { ComponentParams, ComponentDisabledSchema as DisabledBody, ComponentIdSchema as IdParams, ComponentListQuery as ListQuery, OrgComponentListQuery, ComponentScopePreviewSchema as PreviewBody, ComponentScopeSchema as ScopeBody, ComponentShownSchema as ShownBody, ComponentSwitchBody as SwitchBody, ComponentTemplateVersionSchema as TemplateVersionBody, } from "./component-scope.schemas.js";
|
|
17
17
|
import { ComponentScopeService, } from "./component-scope.service.js";
|
|
18
|
-
import { COMPONENT_KINDS } from "./component-state.js";
|
|
19
18
|
import { PlatformComponents } from "./platform-components.js";
|
|
20
|
-
const Kind = z.enum(COMPONENT_KINDS);
|
|
21
|
-
const Scope = z.enum(["all", "optional", "named"]);
|
|
22
|
-
const Orgs = z.array(z.string().min(1).max(128)).max(1000);
|
|
23
|
-
const Hash = z.string().min(1).max(128);
|
|
24
|
-
const ComponentParams = z.object({ kind: Kind, id: z.string().min(1).max(128) });
|
|
25
|
-
const ListQuery = z.object({ kind: Kind }).strict();
|
|
26
|
-
const OrgListQuery = z
|
|
27
|
-
.object({ kind: Kind.optional(), itemId: z.string().uuid().optional() })
|
|
28
|
-
.strict();
|
|
29
|
-
/** `{ scope, orgs? }`, `{ disabled: true }` or `{ follow: true }`: exactly one. */
|
|
30
|
-
const PreviewBody = z
|
|
31
|
-
.object({
|
|
32
|
-
scope: Scope.optional(),
|
|
33
|
-
orgs: Orgs.optional(),
|
|
34
|
-
disabled: z.literal(true).optional(),
|
|
35
|
-
follow: z.literal(true).optional(),
|
|
36
|
-
})
|
|
37
|
-
.strict()
|
|
38
|
-
.refine((b) => [b.scope !== undefined, b.disabled === true, b.follow === true].filter(Boolean).length === 1, { message: "send exactly one of scope (with orgs for named), disabled: true or follow: true" })
|
|
39
|
-
.refine((b) => b.scope !== undefined || b.orgs === undefined, {
|
|
40
|
-
message: "orgs: only allowed with scope named",
|
|
41
|
-
path: ["orgs"],
|
|
42
|
-
});
|
|
43
|
-
/** `{ scope, orgs?, scopeHash }` or `{ follow: true, scopeHash }`. */
|
|
44
|
-
const ScopeBody = z
|
|
45
|
-
.object({
|
|
46
|
-
scope: Scope.optional(),
|
|
47
|
-
orgs: Orgs.optional(),
|
|
48
|
-
follow: z.literal(true).optional(),
|
|
49
|
-
scopeHash: Hash,
|
|
50
|
-
})
|
|
51
|
-
.strict()
|
|
52
|
-
.refine((b) => (b.scope !== undefined) !== (b.follow === true), {
|
|
53
|
-
message: "send either scope (with orgs for named) or follow: true",
|
|
54
|
-
})
|
|
55
|
-
.refine((b) => b.scope !== undefined || b.orgs === undefined, {
|
|
56
|
-
message: "orgs: only allowed with scope named",
|
|
57
|
-
path: ["orgs"],
|
|
58
|
-
});
|
|
59
|
-
const DisabledBody = z.object({ disabled: z.boolean(), scopeHash: Hash.optional() }).strict();
|
|
60
|
-
const ShownBody = z.object({ shownToOthers: z.boolean() }).strict();
|
|
61
|
-
const SwitchBody = z
|
|
62
|
-
.object({
|
|
63
|
-
enabled: z.boolean(),
|
|
64
|
-
confirm: z
|
|
65
|
-
.string()
|
|
66
|
-
.regex(/^[0-9a-f]{64}$/)
|
|
67
|
-
.optional(),
|
|
68
|
-
})
|
|
69
|
-
.strict();
|
|
70
|
-
const IdParams = z.object({ id: z.string().min(1).max(128) });
|
|
71
|
-
const TemplateVersionBody = z.object({ content: z.string().min(1).max(400_000) }).strict();
|
|
72
19
|
class ComponentIdParams extends createZodDto(IdParams, "ComponentIdParams") {
|
|
73
20
|
}
|
|
74
21
|
class TemplateVersionDto extends createZodDto(TemplateVersionBody, "TemplateVersionBody") {
|
|
@@ -77,7 +24,7 @@ class ComponentParamsDto extends createZodDto(ComponentParams, "ComponentParams"
|
|
|
77
24
|
}
|
|
78
25
|
class ComponentListQuery extends createZodDto(ListQuery, "ComponentListQuery") {
|
|
79
26
|
}
|
|
80
|
-
class
|
|
27
|
+
class OrgComponentListQueryDto extends createZodDto(OrgComponentListQuery, "OrgComponentListQuery") {
|
|
81
28
|
}
|
|
82
29
|
class ComponentScopePreviewBody extends createZodDto(PreviewBody, "ComponentScopePreviewBody") {
|
|
83
30
|
}
|
|
@@ -270,7 +217,7 @@ __decorate([
|
|
|
270
217
|
Get(),
|
|
271
218
|
OrgAction("catalog.read"),
|
|
272
219
|
__param(0, CurrentOrg()),
|
|
273
|
-
__param(1, ZQuery(
|
|
220
|
+
__param(1, ZQuery(OrgComponentListQueryDto))
|
|
274
221
|
], OrgComponentsController.prototype, "list", null);
|
|
275
222
|
__decorate([
|
|
276
223
|
Put(":kind/:id/switch"),
|
|
@@ -0,0 +1,114 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
import type { RouteSchemas } from "../platform/route-schemas.js";
|
|
3
|
+
export declare const ComponentKindSchema: z.ZodEnum<{
|
|
4
|
+
agent_template: "agent_template";
|
|
5
|
+
connector_template: "connector_template";
|
|
6
|
+
skill: "skill";
|
|
7
|
+
}>;
|
|
8
|
+
export declare const OrgComponentListQuery: z.ZodObject<{
|
|
9
|
+
kind: z.ZodOptional<z.ZodEnum<{
|
|
10
|
+
agent_template: "agent_template";
|
|
11
|
+
connector_template: "connector_template";
|
|
12
|
+
skill: "skill";
|
|
13
|
+
}>>;
|
|
14
|
+
itemId: z.ZodOptional<z.ZodString>;
|
|
15
|
+
}, z.core.$strict>;
|
|
16
|
+
/** `?kind=` of the admin component list. */
|
|
17
|
+
export declare const ComponentListQuery: z.ZodObject<{
|
|
18
|
+
kind: z.ZodEnum<{
|
|
19
|
+
agent_template: "agent_template";
|
|
20
|
+
connector_template: "connector_template";
|
|
21
|
+
skill: "skill";
|
|
22
|
+
}>;
|
|
23
|
+
}, z.core.$strict>;
|
|
24
|
+
export declare const ComponentParams: z.ZodObject<{
|
|
25
|
+
kind: z.ZodEnum<{
|
|
26
|
+
agent_template: "agent_template";
|
|
27
|
+
connector_template: "connector_template";
|
|
28
|
+
skill: "skill";
|
|
29
|
+
}>;
|
|
30
|
+
id: z.ZodString;
|
|
31
|
+
}, z.core.$strip>;
|
|
32
|
+
/** `{ enabled, confirm? }` of the org's switch of a platform component. */
|
|
33
|
+
export declare const ComponentSwitchBody: z.ZodObject<{
|
|
34
|
+
enabled: z.ZodBoolean;
|
|
35
|
+
confirm: z.ZodOptional<z.ZodString>;
|
|
36
|
+
}, z.core.$strict>;
|
|
37
|
+
declare const exactlyOnePreviewTarget: (b: {
|
|
38
|
+
scope?: unknown;
|
|
39
|
+
disabled?: true | undefined;
|
|
40
|
+
follow?: true | undefined;
|
|
41
|
+
}) => boolean;
|
|
42
|
+
declare const orgsNeedScope: (b: {
|
|
43
|
+
scope?: unknown;
|
|
44
|
+
orgs?: unknown;
|
|
45
|
+
}) => boolean;
|
|
46
|
+
declare const scopeXorFollow: (b: {
|
|
47
|
+
scope?: unknown;
|
|
48
|
+
follow?: true | undefined;
|
|
49
|
+
}) => boolean;
|
|
50
|
+
/** The fields of the scope preview body, before its refinements (zod 4 cannot `extend` a refined object). */
|
|
51
|
+
export declare const ComponentScopePreviewFields: z.ZodObject<{
|
|
52
|
+
scope: z.ZodOptional<z.ZodEnum<{
|
|
53
|
+
all: "all";
|
|
54
|
+
named: "named";
|
|
55
|
+
optional: "optional";
|
|
56
|
+
}>>;
|
|
57
|
+
orgs: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
58
|
+
disabled: z.ZodOptional<z.ZodLiteral<true>>;
|
|
59
|
+
follow: z.ZodOptional<z.ZodLiteral<true>>;
|
|
60
|
+
}, z.core.$strict>;
|
|
61
|
+
/** `{ scope, orgs? }`, `{ disabled: true }` or `{ follow: true }`: exactly one. */
|
|
62
|
+
export declare const ComponentScopePreviewSchema: z.ZodObject<{
|
|
63
|
+
scope: z.ZodOptional<z.ZodEnum<{
|
|
64
|
+
all: "all";
|
|
65
|
+
named: "named";
|
|
66
|
+
optional: "optional";
|
|
67
|
+
}>>;
|
|
68
|
+
orgs: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
69
|
+
disabled: z.ZodOptional<z.ZodLiteral<true>>;
|
|
70
|
+
follow: z.ZodOptional<z.ZodLiteral<true>>;
|
|
71
|
+
}, z.core.$strict>;
|
|
72
|
+
/** The fields of the scope body, before its refinements. */
|
|
73
|
+
export declare const ComponentScopeFields: z.ZodObject<{
|
|
74
|
+
scope: z.ZodOptional<z.ZodEnum<{
|
|
75
|
+
all: "all";
|
|
76
|
+
named: "named";
|
|
77
|
+
optional: "optional";
|
|
78
|
+
}>>;
|
|
79
|
+
orgs: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
80
|
+
follow: z.ZodOptional<z.ZodLiteral<true>>;
|
|
81
|
+
scopeHash: z.ZodString;
|
|
82
|
+
}, z.core.$strict>;
|
|
83
|
+
/** `{ scope, orgs?, scopeHash }` or `{ follow: true, scopeHash }`. */
|
|
84
|
+
export declare const ComponentScopeSchema: z.ZodObject<{
|
|
85
|
+
scope: z.ZodOptional<z.ZodEnum<{
|
|
86
|
+
all: "all";
|
|
87
|
+
named: "named";
|
|
88
|
+
optional: "optional";
|
|
89
|
+
}>>;
|
|
90
|
+
orgs: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
91
|
+
follow: z.ZodOptional<z.ZodLiteral<true>>;
|
|
92
|
+
scopeHash: z.ZodString;
|
|
93
|
+
}, z.core.$strict>;
|
|
94
|
+
export declare const ComponentDisabledSchema: z.ZodObject<{
|
|
95
|
+
disabled: z.ZodBoolean;
|
|
96
|
+
scopeHash: z.ZodOptional<z.ZodString>;
|
|
97
|
+
}, z.core.$strict>;
|
|
98
|
+
export declare const ComponentShownSchema: z.ZodObject<{
|
|
99
|
+
shownToOthers: z.ZodBoolean;
|
|
100
|
+
}, z.core.$strict>;
|
|
101
|
+
export declare const ComponentIdSchema: z.ZodObject<{
|
|
102
|
+
id: z.ZodString;
|
|
103
|
+
}, z.core.$strip>;
|
|
104
|
+
export declare const ComponentTemplateVersionSchema: z.ZodObject<{
|
|
105
|
+
content: z.ZodString;
|
|
106
|
+
}, z.core.$strict>;
|
|
107
|
+
/** The refinements of the two scope bodies, for operations that rebuild them from the fields. */
|
|
108
|
+
export declare const componentScopeRules: {
|
|
109
|
+
exactlyOnePreviewTarget: typeof exactlyOnePreviewTarget;
|
|
110
|
+
orgsNeedScope: typeof orgsNeedScope;
|
|
111
|
+
scopeXorFollow: typeof scopeXorFollow;
|
|
112
|
+
};
|
|
113
|
+
export declare const COMPONENT_SCOPE_ROUTES: readonly RouteSchemas[];
|
|
114
|
+
export {};
|