@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
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
import { COMPONENT_KINDS } from "./component-state.js";
|
|
3
|
+
export const ComponentKindSchema = z.enum(COMPONENT_KINDS);
|
|
4
|
+
export const OrgComponentListQuery = z
|
|
5
|
+
.object({ kind: ComponentKindSchema.optional(), itemId: z.string().uuid().optional() })
|
|
6
|
+
.strict();
|
|
7
|
+
/** `?kind=` of the admin component list. */
|
|
8
|
+
export const ComponentListQuery = z.object({ kind: ComponentKindSchema }).strict();
|
|
9
|
+
export const ComponentParams = z.object({
|
|
10
|
+
kind: ComponentKindSchema,
|
|
11
|
+
id: z.string().min(1).max(128),
|
|
12
|
+
});
|
|
13
|
+
/** `{ enabled, confirm? }` of the org's switch of a platform component. */
|
|
14
|
+
export const ComponentSwitchBody = z
|
|
15
|
+
.object({
|
|
16
|
+
enabled: z.boolean(),
|
|
17
|
+
confirm: z
|
|
18
|
+
.string()
|
|
19
|
+
.regex(/^[0-9a-f]{64}$/)
|
|
20
|
+
.optional(),
|
|
21
|
+
})
|
|
22
|
+
.strict();
|
|
23
|
+
const Scope = z.enum(["all", "optional", "named"]);
|
|
24
|
+
const Orgs = z.array(z.string().min(1).max(128)).max(1000);
|
|
25
|
+
const Hash = z.string().min(1).max(128);
|
|
26
|
+
const exactlyOnePreviewTarget = (b) => [b.scope !== undefined, b.disabled === true, b.follow === true].filter(Boolean).length === 1;
|
|
27
|
+
const orgsNeedScope = (b) => b.scope !== undefined || b.orgs === undefined;
|
|
28
|
+
const scopeXorFollow = (b) => (b.scope !== undefined) !== (b.follow === true);
|
|
29
|
+
/** The fields of the scope preview body, before its refinements (zod 4 cannot `extend` a refined object). */
|
|
30
|
+
export const ComponentScopePreviewFields = 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
|
+
/** `{ scope, orgs? }`, `{ disabled: true }` or `{ follow: true }`: exactly one. */
|
|
39
|
+
export const ComponentScopePreviewSchema = ComponentScopePreviewFields.refine(exactlyOnePreviewTarget, { message: "send exactly one of scope (with orgs for named), disabled: true or follow: true" }).refine(orgsNeedScope, { message: "orgs: only allowed with scope named", path: ["orgs"] });
|
|
40
|
+
/** The fields of the scope body, before its refinements. */
|
|
41
|
+
export const ComponentScopeFields = z
|
|
42
|
+
.object({
|
|
43
|
+
scope: Scope.optional(),
|
|
44
|
+
orgs: Orgs.optional(),
|
|
45
|
+
follow: z.literal(true).optional(),
|
|
46
|
+
scopeHash: Hash,
|
|
47
|
+
})
|
|
48
|
+
.strict();
|
|
49
|
+
/** `{ scope, orgs?, scopeHash }` or `{ follow: true, scopeHash }`. */
|
|
50
|
+
export const ComponentScopeSchema = ComponentScopeFields.refine(scopeXorFollow, {
|
|
51
|
+
message: "send either scope (with orgs for named) or follow: true",
|
|
52
|
+
}).refine(orgsNeedScope, { message: "orgs: only allowed with scope named", path: ["orgs"] });
|
|
53
|
+
export const ComponentDisabledSchema = z
|
|
54
|
+
.object({ disabled: z.boolean(), scopeHash: Hash.optional() })
|
|
55
|
+
.strict();
|
|
56
|
+
export const ComponentShownSchema = z.object({ shownToOthers: z.boolean() }).strict();
|
|
57
|
+
export const ComponentIdSchema = z.object({ id: z.string().min(1).max(128) });
|
|
58
|
+
export const ComponentTemplateVersionSchema = z
|
|
59
|
+
.object({ content: z.string().min(1).max(400_000) })
|
|
60
|
+
.strict();
|
|
61
|
+
/** The refinements of the two scope bodies, for operations that rebuild them from the fields. */
|
|
62
|
+
export const componentScopeRules = { exactlyOnePreviewTarget, orgsNeedScope, scopeXorFollow };
|
|
63
|
+
export const COMPONENT_SCOPE_ROUTES = [
|
|
64
|
+
{ route: "GET /api/v1/orgs/:orgId/components", query: OrgComponentListQuery },
|
|
65
|
+
{ route: "GET /api/v1/admin/components", query: ComponentListQuery },
|
|
66
|
+
{ route: "GET /api/v1/admin/components/:kind/:id/versions", params: ComponentParams },
|
|
67
|
+
{
|
|
68
|
+
route: "POST /api/v1/admin/components/:kind/:id/scope/preview",
|
|
69
|
+
params: ComponentParams,
|
|
70
|
+
body: ComponentScopePreviewSchema,
|
|
71
|
+
},
|
|
72
|
+
{
|
|
73
|
+
route: "PUT /api/v1/admin/components/:kind/:id/scope",
|
|
74
|
+
params: ComponentParams,
|
|
75
|
+
body: ComponentScopeSchema,
|
|
76
|
+
},
|
|
77
|
+
{
|
|
78
|
+
route: "PUT /api/v1/admin/components/:kind/:id/disabled",
|
|
79
|
+
params: ComponentParams,
|
|
80
|
+
body: ComponentDisabledSchema,
|
|
81
|
+
},
|
|
82
|
+
{
|
|
83
|
+
route: "PUT /api/v1/admin/components/:kind/:id/shown",
|
|
84
|
+
params: ComponentParams,
|
|
85
|
+
body: ComponentShownSchema,
|
|
86
|
+
},
|
|
87
|
+
{
|
|
88
|
+
route: "POST /api/v1/admin/components/agent_template/:id/versions",
|
|
89
|
+
params: ComponentIdSchema,
|
|
90
|
+
body: ComponentTemplateVersionSchema,
|
|
91
|
+
},
|
|
92
|
+
{
|
|
93
|
+
route: "PUT /api/v1/orgs/:orgId/components/:kind/:id/switch",
|
|
94
|
+
params: ComponentParams,
|
|
95
|
+
body: ComponentSwitchBody,
|
|
96
|
+
},
|
|
97
|
+
];
|
|
@@ -160,6 +160,10 @@ export type ComponentSwitchResult = {
|
|
|
160
160
|
};
|
|
161
161
|
confirm: string;
|
|
162
162
|
};
|
|
163
|
+
/** Actor facts of a write: the token, and detail the caller adds to the audit row. */
|
|
164
|
+
type AuditOpts = ActorOpts & {
|
|
165
|
+
auditDetail?: Record<string, unknown>;
|
|
166
|
+
};
|
|
163
167
|
/**
|
|
164
168
|
* 409 `plugin.skill_conflict` listing the orgs whose own skills use a component's name (rule 10);
|
|
165
169
|
* for an agent template 409 `agent_template.name_taken` listing the orgs that already use its
|
|
@@ -238,7 +242,7 @@ export declare class ComponentScopeService {
|
|
|
238
242
|
follow: true;
|
|
239
243
|
}) & {
|
|
240
244
|
scopeHash: string;
|
|
241
|
-
}, opts?:
|
|
245
|
+
}, opts?: AuditOpts): Promise<ComponentView>;
|
|
242
246
|
/**
|
|
243
247
|
* Disables the component on the whole deployment (after its preview, `scopeHash` required) or
|
|
244
248
|
* enables it again (no hash; refused while an org it would be offered to has a skill of its name).
|
|
@@ -246,9 +250,9 @@ export declare class ComponentScopeService {
|
|
|
246
250
|
setDisabled(actor: string, kind: ComponentKind, id: string, body: {
|
|
247
251
|
disabled: boolean;
|
|
248
252
|
scopeHash?: string;
|
|
249
|
-
}, opts?:
|
|
253
|
+
}, opts?: AuditOpts): Promise<ComponentView>;
|
|
250
254
|
/** Shows or hides the component to orgs outside its `named` list (never makes it usable). */
|
|
251
|
-
setShown(actor: string, kind: ComponentKind, id: string, shown: boolean, opts?:
|
|
255
|
+
setShown(actor: string, kind: ComponentKind, id: string, shown: boolean, opts?: AuditOpts): Promise<ComponentView>;
|
|
252
256
|
/**
|
|
253
257
|
* The org admin's switch of one component (`PUT orgs/:orgId/components/:kind/:id/switch`): only
|
|
254
258
|
* this component (rule 5). A component not offered to the org -> 404. On: refused while the
|
|
@@ -260,7 +264,26 @@ export declare class ComponentScopeService {
|
|
|
260
264
|
setSwitch(orgId: string, actor: string, kind: ComponentKind, id: string, body: {
|
|
261
265
|
enabled: boolean;
|
|
262
266
|
confirm?: string;
|
|
263
|
-
}, actorTokenId?: string): Promise<ComponentSwitchResult>;
|
|
267
|
+
}, actorTokenId?: string, auditDetail?: Record<string, unknown>): Promise<ComponentSwitchResult>;
|
|
268
|
+
/**
|
|
269
|
+
* What {@link setSwitch} would do to the org's switch, read-only (the Platform tool's preview):
|
|
270
|
+
* the component as the org sees it, whether it is `stopped` on the deployment, and for one that
|
|
271
|
+
* is on and can be switched off the preview of the agents that lose it with the `confirm` hash
|
|
272
|
+
* the switch-off needs (both null otherwise). Unknown or not offered -> 404 `component.not_found`.
|
|
273
|
+
*/
|
|
274
|
+
switchPreview(orgId: string, kind: ComponentKind, id: string): Promise<{
|
|
275
|
+
component: OrgComponentView;
|
|
276
|
+
stopped: boolean;
|
|
277
|
+
preview: {
|
|
278
|
+
agents: {
|
|
279
|
+
id: string;
|
|
280
|
+
name: string;
|
|
281
|
+
refs: string[];
|
|
282
|
+
}[];
|
|
283
|
+
connectorsKept: number;
|
|
284
|
+
} | null;
|
|
285
|
+
confirm: string | null;
|
|
286
|
+
}>;
|
|
264
287
|
/**
|
|
265
288
|
* `x.hashId`: the id the preview was asked for (an org row's id before its promotion);
|
|
266
289
|
* `x.promote`: the org row to promote first, in this transaction. Returns the id written.
|
|
@@ -301,3 +324,4 @@ export declare class ComponentScopeService {
|
|
|
301
324
|
*/
|
|
302
325
|
private compute;
|
|
303
326
|
}
|
|
327
|
+
export {};
|
|
@@ -432,7 +432,7 @@ let ComponentScopeService = class ComponentScopeService {
|
|
|
432
432
|
* is on, without `confirm` the preview (agents that use it) and its hash are returned, with the
|
|
433
433
|
* current hash the switch is written (a changed preview -> `plugin.switch_stale`).
|
|
434
434
|
*/
|
|
435
|
-
async setSwitch(orgId, actor, kind, id, body, actorTokenId) {
|
|
435
|
+
async setSwitch(orgId, actor, kind, id, body, actorTokenId, auditDetail) {
|
|
436
436
|
await this.orgLock.lockAndAuthorize(orgId, actor, ACTION[kind]);
|
|
437
437
|
// The rows an unshare narrows (ruling P3-25) are locked before the scope is read, in its order
|
|
438
438
|
// (plugin, then component): a switch-on never commits against a scope narrowed meanwhile
|
|
@@ -509,7 +509,14 @@ let ComponentScopeService = class ComponentScopeService {
|
|
|
509
509
|
orgId,
|
|
510
510
|
action: "component.org_switched",
|
|
511
511
|
target: c.id,
|
|
512
|
-
detail: {
|
|
512
|
+
detail: {
|
|
513
|
+
kind,
|
|
514
|
+
name: c.name,
|
|
515
|
+
plugin: c.plugin,
|
|
516
|
+
from: sw,
|
|
517
|
+
to: body.enabled,
|
|
518
|
+
...auditDetail,
|
|
519
|
+
},
|
|
513
520
|
});
|
|
514
521
|
}
|
|
515
522
|
return {
|
|
@@ -525,6 +532,42 @@ let ComponentScopeService = class ComponentScopeService {
|
|
|
525
532
|
},
|
|
526
533
|
};
|
|
527
534
|
}
|
|
535
|
+
/**
|
|
536
|
+
* What {@link setSwitch} would do to the org's switch, read-only (the Platform tool's preview):
|
|
537
|
+
* the component as the org sees it, whether it is `stopped` on the deployment, and for one that
|
|
538
|
+
* is on and can be switched off the preview of the agents that lose it with the `confirm` hash
|
|
539
|
+
* the switch-off needs (both null otherwise). Unknown or not offered -> 404 `component.not_found`.
|
|
540
|
+
*/
|
|
541
|
+
async switchPreview(orgId, kind, id) {
|
|
542
|
+
const [c] = await loadComponents(this.db, kind, { ids: [id] });
|
|
543
|
+
if (!c)
|
|
544
|
+
throw notFound();
|
|
545
|
+
const st = await loadScopeState(this.db, kind, [c]);
|
|
546
|
+
const p = pluginFactsOf(st, c.itemId, orgId);
|
|
547
|
+
const listed = listedIn(st, c.id, orgId);
|
|
548
|
+
const sw = switchOf(st, c.id, orgId);
|
|
549
|
+
const on = componentOn(c, p, listed, sw);
|
|
550
|
+
const stopped = c.disabled || (p?.live === true && p.disabled);
|
|
551
|
+
const offered = componentOffered({ ...c, disabled: false }, p && { ...p, disabled: false }, listed);
|
|
552
|
+
if (!on && !offered)
|
|
553
|
+
throw notFound();
|
|
554
|
+
const locked = componentLocked(c, p);
|
|
555
|
+
let preview = null;
|
|
556
|
+
let confirm = null;
|
|
557
|
+
if (on && !locked) {
|
|
558
|
+
preview = {
|
|
559
|
+
agents: await agentsUsing(this.db, orgId, kind, [c.id]),
|
|
560
|
+
connectorsKept: kind === "connector_template" ? await connectorsMadeFrom(this.db, orgId, c.id) : 0,
|
|
561
|
+
};
|
|
562
|
+
confirm = switchHash(orgId, c, preview);
|
|
563
|
+
}
|
|
564
|
+
return {
|
|
565
|
+
component: { kind, id: c.id, name: c.name, plugin: c.plugin, switch: sw, on, locked },
|
|
566
|
+
stopped,
|
|
567
|
+
preview,
|
|
568
|
+
confirm,
|
|
569
|
+
};
|
|
570
|
+
}
|
|
528
571
|
/**
|
|
529
572
|
* `x.hashId`: the id the preview was asked for (an org row's id before its promotion);
|
|
530
573
|
* `x.promote`: the org row to promote first, in this transaction. Returns the id written.
|
|
@@ -590,6 +633,7 @@ let ComponentScopeService = class ComponentScopeService {
|
|
|
590
633
|
plugin: c.plugin,
|
|
591
634
|
from: { scopeMode: c.scopeMode, scope: c.scope, orgs: from },
|
|
592
635
|
to: { scopeMode: t.scopeMode, scope: t.scope, orgs: t.orgs },
|
|
636
|
+
...opts.auditDetail,
|
|
593
637
|
},
|
|
594
638
|
});
|
|
595
639
|
return id;
|
|
@@ -623,6 +667,7 @@ let ComponentScopeService = class ComponentScopeService {
|
|
|
623
667
|
name: c.name,
|
|
624
668
|
plugin: c.plugin,
|
|
625
669
|
disabled: { from: c.disabled, to: disabled },
|
|
670
|
+
...opts.auditDetail,
|
|
626
671
|
},
|
|
627
672
|
});
|
|
628
673
|
}
|
|
@@ -649,7 +694,14 @@ let ComponentScopeService = class ComponentScopeService {
|
|
|
649
694
|
...(opts.actorTokenId !== undefined && { actorTokenId: opts.actorTokenId }),
|
|
650
695
|
action: "component.shown_changed",
|
|
651
696
|
target: id,
|
|
652
|
-
detail: {
|
|
697
|
+
detail: {
|
|
698
|
+
kind,
|
|
699
|
+
name: c.name,
|
|
700
|
+
plugin: c.plugin,
|
|
701
|
+
from: c.shownToOthers,
|
|
702
|
+
to: shown,
|
|
703
|
+
...opts.auditDetail,
|
|
704
|
+
},
|
|
653
705
|
});
|
|
654
706
|
return id;
|
|
655
707
|
}
|
|
@@ -101,14 +101,21 @@ export declare const switchOf: (st: ScopeState, id: string, orgId: string) => bo
|
|
|
101
101
|
export declare const listedIn: (st: ScopeState, id: string, orgId: string) => boolean;
|
|
102
102
|
/** The connectors, skills and agent templates an agent definition references. */
|
|
103
103
|
export interface DefinitionRefs {
|
|
104
|
+
/**
|
|
105
|
+
* The connectors the agent uses: tools are on by default (tools default-on spec §6), so every
|
|
106
|
+
* one of `orgConnectors` it does not turn off as a whole.
|
|
107
|
+
*/
|
|
104
108
|
connectors: Set<string>;
|
|
105
109
|
/** `skills.orgSkills`, `skills.pinned` and the inline sub-agent templates' `skills`. */
|
|
106
110
|
skills: Set<string>;
|
|
107
111
|
/** `subagents.templates`. */
|
|
108
112
|
templates: Set<string>;
|
|
109
113
|
}
|
|
110
|
-
/**
|
|
111
|
-
|
|
114
|
+
/**
|
|
115
|
+
* The ids an agent definition references (see {@link DefinitionRefs}); `orgConnectors` are the
|
|
116
|
+
* ids of the org's live connectors.
|
|
117
|
+
*/
|
|
118
|
+
export declare function definitionRefs(definition: unknown, orgConnectors?: readonly string[]): DefinitionRefs;
|
|
112
119
|
/** The org's live agents with their current definitions' references, sorted by id. */
|
|
113
120
|
export declare function agentDefinitionRefs(db: KernelSchemaDb, orgId: string): Promise<({
|
|
114
121
|
id: string;
|
|
@@ -1,9 +1,3 @@
|
|
|
1
|
-
// Component scope (plugin scope phase 2, Task 6; spec §5 rules 2, 5, 8, 10, 11, §13.5): when a platform
|
|
2
|
-
// component (skill, agent template, connector template) is on in an org, offered to it, or locked on,
|
|
3
|
-
// and which agents of an org use one. Pure predicates plus the reads they need; the usable sets
|
|
4
|
-
// (skills/usable.ts, agents/templates.ts), the component scope service and the plugin scope preview
|
|
5
|
-
// all decide with the same predicates.
|
|
6
|
-
import { normalizeToolRef } from "../agents/definition.js";
|
|
7
1
|
import { visibleTo, wantedOn } from "./scope.js";
|
|
8
2
|
export const COMPONENT_KINDS = [
|
|
9
3
|
"skill",
|
|
@@ -244,17 +238,25 @@ export function pluginFactsOf(st, itemId, orgId) {
|
|
|
244
238
|
export const switchOf = (st, id, orgId) => st.switches.get(id)?.get(orgId) ?? null;
|
|
245
239
|
/** Whether the org is on a component's own `named` list in a {@link ScopeState}. */
|
|
246
240
|
export const listedIn = (st, id, orgId) => st.listed.get(id)?.has(orgId) ?? false;
|
|
247
|
-
/**
|
|
248
|
-
|
|
241
|
+
/**
|
|
242
|
+
* The ids an agent definition references (see {@link DefinitionRefs}); `orgConnectors` are the
|
|
243
|
+
* ids of the org's live connectors.
|
|
244
|
+
*/
|
|
245
|
+
export function definitionRefs(definition, orgConnectors = []) {
|
|
249
246
|
const def = definition;
|
|
250
247
|
const connectors = new Set();
|
|
251
248
|
const skills = new Set();
|
|
252
249
|
const templates = new Set();
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
250
|
+
const off = new Set();
|
|
251
|
+
for (const ref of Array.isArray(def?.disabledTools) ? def.disabledTools : []) {
|
|
252
|
+
const n = ref;
|
|
253
|
+
if (n?.kind === "connector" && typeof n.connectorId === "string" && n.tools === "all") {
|
|
254
|
+
off.add(n.connectorId);
|
|
255
|
+
}
|
|
257
256
|
}
|
|
257
|
+
for (const id of orgConnectors)
|
|
258
|
+
if (!off.has(id))
|
|
259
|
+
connectors.add(id);
|
|
258
260
|
const strings = (xs, into) => {
|
|
259
261
|
if (Array.isArray(xs))
|
|
260
262
|
for (const x of xs)
|
|
@@ -280,12 +282,19 @@ export async function agentDefinitionRefs(db, orgId) {
|
|
|
280
282
|
.where("a.deleted_at", "is", null)
|
|
281
283
|
.orderBy("a.id")
|
|
282
284
|
.execute();
|
|
285
|
+
const connectors = (await db
|
|
286
|
+
.selectFrom("connectors")
|
|
287
|
+
.select("id")
|
|
288
|
+
.where("org_id", "=", orgId)
|
|
289
|
+
.where("deleted_at", "is", null)
|
|
290
|
+
.orderBy("id")
|
|
291
|
+
.execute()).map((c) => c.id);
|
|
283
292
|
return rows.map((r) => {
|
|
284
293
|
const name = r.definition?.name;
|
|
285
294
|
return {
|
|
286
295
|
id: r.id,
|
|
287
296
|
name: typeof name === "string" ? name : r.id,
|
|
288
|
-
...definitionRefs(r.definition),
|
|
297
|
+
...definitionRefs(r.definition, connectors),
|
|
289
298
|
};
|
|
290
299
|
});
|
|
291
300
|
}
|
|
@@ -1,40 +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 { KernelConfigService } from "../infra/config/kernel-config.service.js";
|
|
4
4
|
import { KernelDb } from "../infra/database/kernel-db.js";
|
|
5
5
|
import { type OrgContext } from "../orgs/org.guard.js";
|
|
6
6
|
import { CatalogService, type MarketplaceImportResult } from "./catalog.service.js";
|
|
7
|
+
import { MarketplaceImportBody as ImportBody, MarketplaceAddBody, MarketplaceEntriesQuery, MarketplacePatchBody as PatchBody } from "./marketplaces.schemas.js";
|
|
7
8
|
import { type MarketplaceEntryView, MarketplacesService, type MarketplaceView } from "./marketplaces.service.js";
|
|
8
|
-
declare const AddBody: z.ZodObject<{
|
|
9
|
-
name: z.ZodString;
|
|
10
|
-
url: z.ZodString;
|
|
11
|
-
form: z.ZodOptional<z.ZodEnum<{
|
|
12
|
-
git: "git";
|
|
13
|
-
http: "http";
|
|
14
|
-
}>>;
|
|
15
|
-
ref: z.ZodOptional<z.ZodString>;
|
|
16
|
-
mirrors: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
17
|
-
token: z.ZodOptional<z.ZodString>;
|
|
18
|
-
}, z.core.$strip>;
|
|
19
|
-
declare const PatchBody: z.ZodObject<{
|
|
20
|
-
name: z.ZodOptional<z.ZodString>;
|
|
21
|
-
url: z.ZodOptional<z.ZodString>;
|
|
22
|
-
form: z.ZodOptional<z.ZodEnum<{
|
|
23
|
-
git: "git";
|
|
24
|
-
http: "http";
|
|
25
|
-
}>>;
|
|
26
|
-
ref: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
27
|
-
mirrors: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
28
|
-
enabled: z.ZodOptional<z.ZodBoolean>;
|
|
29
|
-
token: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
30
|
-
}, z.core.$strict>;
|
|
31
|
-
declare const EntriesQuery: z.ZodObject<{
|
|
32
|
-
sourceId: z.ZodOptional<z.ZodString>;
|
|
33
|
-
q: z.ZodOptional<z.ZodString>;
|
|
34
|
-
}, z.core.$strip>;
|
|
35
|
-
declare const ImportBody: z.ZodObject<{
|
|
36
|
-
version: z.ZodOptional<z.ZodString>;
|
|
37
|
-
}, z.core.$strip>;
|
|
38
9
|
/**
|
|
39
10
|
* Marketplaces (`/api/v1/admin/marketplaces/*`, super admins): create, update, delete and
|
|
40
11
|
* refresh the official and custom marketplaces, browse entries, import from a marketplace.
|
|
@@ -55,7 +26,7 @@ export declare class MarketplacesController {
|
|
|
55
26
|
* to the URL's origin). A git URL (`…/*.git`, `owner/repo`, or any URL with `form: "git"`) is a
|
|
56
27
|
* git marketplace with an optional `ref`; anything else is a marketplace.json URL.
|
|
57
28
|
*/
|
|
58
|
-
add(principal: Principal, body: z.infer<typeof
|
|
29
|
+
add(principal: Principal, body: z.infer<typeof MarketplaceAddBody>): Promise<MarketplaceView>;
|
|
59
30
|
/**
|
|
60
31
|
* Browses entries (enabled marketplaces only, `sourceId` filters by marketplace; at most
|
|
61
32
|
* `MARKETPLACE_ENTRIES_MAX`, `truncated` true means there are more). An entry that cannot be
|
|
@@ -63,7 +34,7 @@ export declare class MarketplacesController {
|
|
|
63
34
|
* outside `marketplaces.allowedHosts`) or `path_needs_git_marketplace` (a path entry of an http
|
|
64
35
|
* marketplace).
|
|
65
36
|
*/
|
|
66
|
-
entries(q: z.infer<typeof
|
|
37
|
+
entries(q: z.infer<typeof MarketplaceEntriesQuery>): Promise<{
|
|
67
38
|
items: MarketplaceEntryView[];
|
|
68
39
|
truncated: boolean;
|
|
69
40
|
}>;
|
|
@@ -106,9 +77,8 @@ export declare class OrgMarketplacesController {
|
|
|
106
77
|
private readonly marketplaces;
|
|
107
78
|
private readonly kdb;
|
|
108
79
|
constructor(marketplaces: MarketplacesService, kdb: KernelDb);
|
|
109
|
-
entries(org: OrgContext, q: z.infer<typeof
|
|
80
|
+
entries(org: OrgContext, q: z.infer<typeof MarketplaceEntriesQuery>): Promise<{
|
|
110
81
|
items: MarketplaceEntryView[];
|
|
111
82
|
truncated: boolean;
|
|
112
83
|
}>;
|
|
113
84
|
}
|
|
114
|
-
export {};
|
|
@@ -8,8 +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, Param, Patch, Post } from "@nestjs/common";
|
|
11
|
-
import { z } from "zod";
|
|
12
|
-
import { MARKETPLACE_MAX_MIRRORS } from "../config/schema.js";
|
|
13
11
|
import { ApiError } from "../errors.js";
|
|
14
12
|
import { CurrentPrincipal, patTokenId, requireUser, SuperAdmin, } from "../identity/principal.js";
|
|
15
13
|
import { readOrgMarketplaceBrowse } from "../identity/settings.js";
|
|
@@ -19,44 +17,18 @@ import { createZodDto } from "../infra/validation/create-zod-dto.js";
|
|
|
19
17
|
import { ZBody, ZQuery } from "../infra/validation/zod-params.js";
|
|
20
18
|
import { CurrentOrg, OrgAction } from "../orgs/org.guard.js";
|
|
21
19
|
import { CatalogService } from "./catalog.service.js";
|
|
20
|
+
import { MarketplaceImportBody as ImportBody, MarketplaceAddBody, MarketplaceEntriesQuery, MarketplacePatchBody as PatchBody, } from "./marketplaces.schemas.js";
|
|
22
21
|
import { MarketplacesService, } from "./marketplaces.service.js";
|
|
23
22
|
import { itemsSeenBy } from "./scope-state.js";
|
|
24
|
-
const Url = z.string().min(1).max(2000);
|
|
25
|
-
const Form = z.enum(["http", "git"]);
|
|
26
|
-
const Ref = z.string().min(1).max(256);
|
|
27
|
-
const AddBody = z.object({
|
|
28
|
-
name: z.string().min(1).max(100),
|
|
29
|
-
url: Url,
|
|
30
|
-
form: Form.optional(),
|
|
31
|
-
ref: Ref.optional(),
|
|
32
|
-
mirrors: z.array(Url).max(MARKETPLACE_MAX_MIRRORS).optional(),
|
|
33
|
-
token: z.string().min(1).max(4096).optional(),
|
|
34
|
-
});
|
|
35
|
-
const PatchBody = z
|
|
36
|
-
.object({
|
|
37
|
-
name: z.string().min(1).max(100).optional(),
|
|
38
|
-
url: Url.optional(),
|
|
39
|
-
form: Form.optional(),
|
|
40
|
-
ref: Ref.nullable().optional(),
|
|
41
|
-
mirrors: z.array(Url).max(MARKETPLACE_MAX_MIRRORS).optional(),
|
|
42
|
-
enabled: z.boolean().optional(),
|
|
43
|
-
token: z.string().min(1).max(4096).nullable().optional(),
|
|
44
|
-
})
|
|
45
|
-
.strict();
|
|
46
|
-
const EntriesQuery = z.object({
|
|
47
|
-
sourceId: z.string().min(1).max(100).optional(),
|
|
48
|
-
q: z.string().max(200).optional(),
|
|
49
|
-
});
|
|
50
|
-
const ImportBody = z.object({ version: z.string().min(1).max(256).optional() });
|
|
51
23
|
/** 手动刷新的总时限(每个地址另有 30 秒超时)。 */
|
|
52
24
|
const REFRESH_DEADLINE_MS = 300_000;
|
|
53
25
|
const actorOpts = (actor) => {
|
|
54
26
|
const tokenId = patTokenId(actor);
|
|
55
27
|
return tokenId !== undefined ? { actorTokenId: tokenId } : {};
|
|
56
28
|
};
|
|
57
|
-
class
|
|
29
|
+
class MarketplaceAddBodyDto extends createZodDto(MarketplaceAddBody, "MarketplaceAddBody") {
|
|
58
30
|
}
|
|
59
|
-
class
|
|
31
|
+
class MarketplaceEntriesQueryDto extends createZodDto(MarketplaceEntriesQuery, "MarketplaceEntriesQuery") {
|
|
60
32
|
}
|
|
61
33
|
class MarketplaceImportBody extends createZodDto(ImportBody, "MarketplaceImportBody") {
|
|
62
34
|
}
|
|
@@ -171,11 +143,11 @@ __decorate([
|
|
|
171
143
|
Post(),
|
|
172
144
|
HttpCode(201),
|
|
173
145
|
__param(0, CurrentPrincipal()),
|
|
174
|
-
__param(1, ZBody(
|
|
146
|
+
__param(1, ZBody(MarketplaceAddBodyDto))
|
|
175
147
|
], MarketplacesController.prototype, "add", null);
|
|
176
148
|
__decorate([
|
|
177
149
|
Get("entries"),
|
|
178
|
-
__param(0, ZQuery(
|
|
150
|
+
__param(0, ZQuery(MarketplaceEntriesQueryDto))
|
|
179
151
|
], MarketplacesController.prototype, "entries", null);
|
|
180
152
|
__decorate([
|
|
181
153
|
Patch(":id"),
|
|
@@ -247,7 +219,7 @@ __decorate([
|
|
|
247
219
|
Get("entries"),
|
|
248
220
|
OrgAction("catalog.decide"),
|
|
249
221
|
__param(0, CurrentOrg()),
|
|
250
|
-
__param(1, ZQuery(
|
|
222
|
+
__param(1, ZQuery(MarketplaceEntriesQueryDto))
|
|
251
223
|
], OrgMarketplacesController.prototype, "entries", null);
|
|
252
224
|
OrgMarketplacesController = __decorate([
|
|
253
225
|
Controller("api/v1/orgs/:orgId/marketplaces"),
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
import type { RouteSchemas } from "../platform/route-schemas.js";
|
|
3
|
+
export declare const MarketplaceUrl: z.ZodString;
|
|
4
|
+
export declare const MarketplaceForm: z.ZodEnum<{
|
|
5
|
+
git: "git";
|
|
6
|
+
http: "http";
|
|
7
|
+
}>;
|
|
8
|
+
export declare const MarketplaceRef: z.ZodString;
|
|
9
|
+
export declare const MarketplaceAddBody: z.ZodObject<{
|
|
10
|
+
name: z.ZodString;
|
|
11
|
+
url: z.ZodString;
|
|
12
|
+
form: z.ZodOptional<z.ZodEnum<{
|
|
13
|
+
git: "git";
|
|
14
|
+
http: "http";
|
|
15
|
+
}>>;
|
|
16
|
+
ref: z.ZodOptional<z.ZodString>;
|
|
17
|
+
mirrors: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
18
|
+
token: z.ZodOptional<z.ZodString>;
|
|
19
|
+
}, z.core.$strip>;
|
|
20
|
+
export declare const MarketplaceEntriesQuery: z.ZodObject<{
|
|
21
|
+
sourceId: z.ZodOptional<z.ZodString>;
|
|
22
|
+
q: z.ZodOptional<z.ZodString>;
|
|
23
|
+
}, z.core.$strip>;
|
|
24
|
+
export declare const MarketplacePatchBody: z.ZodObject<{
|
|
25
|
+
name: z.ZodOptional<z.ZodString>;
|
|
26
|
+
url: z.ZodOptional<z.ZodString>;
|
|
27
|
+
form: z.ZodOptional<z.ZodEnum<{
|
|
28
|
+
git: "git";
|
|
29
|
+
http: "http";
|
|
30
|
+
}>>;
|
|
31
|
+
ref: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
32
|
+
mirrors: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
33
|
+
enabled: z.ZodOptional<z.ZodBoolean>;
|
|
34
|
+
token: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
35
|
+
}, z.core.$strict>;
|
|
36
|
+
export declare const MarketplaceImportBody: z.ZodObject<{
|
|
37
|
+
version: z.ZodOptional<z.ZodString>;
|
|
38
|
+
}, z.core.$strip>;
|
|
39
|
+
/** `:id` of a marketplace as the routes take it (`@Param`). */
|
|
40
|
+
export declare const MarketplaceIdPathParams: z.ZodObject<{
|
|
41
|
+
id: z.ZodString;
|
|
42
|
+
}, z.core.$strip>;
|
|
43
|
+
/** `:id` and the entry `:name` of the import route (`@Param`). */
|
|
44
|
+
export declare const MarketplaceEntryPathParams: z.ZodObject<{
|
|
45
|
+
id: z.ZodString;
|
|
46
|
+
name: z.ZodString;
|
|
47
|
+
}, z.core.$strip>;
|
|
48
|
+
export declare const MARKETPLACE_ROUTES: readonly RouteSchemas[];
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
import { MARKETPLACE_MAX_MIRRORS } from "../config/schema.js";
|
|
3
|
+
export const MarketplaceUrl = z.string().min(1).max(2000);
|
|
4
|
+
export const MarketplaceForm = z.enum(["http", "git"]);
|
|
5
|
+
export const MarketplaceRef = z.string().min(1).max(256);
|
|
6
|
+
export const MarketplaceAddBody = z.object({
|
|
7
|
+
name: z.string().min(1).max(100),
|
|
8
|
+
url: MarketplaceUrl,
|
|
9
|
+
form: MarketplaceForm.optional(),
|
|
10
|
+
ref: MarketplaceRef.optional(),
|
|
11
|
+
mirrors: z.array(MarketplaceUrl).max(MARKETPLACE_MAX_MIRRORS).optional(),
|
|
12
|
+
token: z.string().min(1).max(4096).optional(),
|
|
13
|
+
});
|
|
14
|
+
export const MarketplaceEntriesQuery = z.object({
|
|
15
|
+
sourceId: z.string().min(1).max(100).optional(),
|
|
16
|
+
q: z.string().max(200).optional(),
|
|
17
|
+
});
|
|
18
|
+
export const MarketplacePatchBody = z
|
|
19
|
+
.object({
|
|
20
|
+
name: z.string().min(1).max(100).optional(),
|
|
21
|
+
url: MarketplaceUrl.optional(),
|
|
22
|
+
form: MarketplaceForm.optional(),
|
|
23
|
+
ref: MarketplaceRef.nullable().optional(),
|
|
24
|
+
mirrors: z.array(MarketplaceUrl).max(MARKETPLACE_MAX_MIRRORS).optional(),
|
|
25
|
+
enabled: z.boolean().optional(),
|
|
26
|
+
token: z.string().min(1).max(4096).nullable().optional(),
|
|
27
|
+
})
|
|
28
|
+
.strict();
|
|
29
|
+
export const MarketplaceImportBody = z.object({ version: z.string().min(1).max(256).optional() });
|
|
30
|
+
/** `:id` of a marketplace as the routes take it (`@Param`). */
|
|
31
|
+
export const MarketplaceIdPathParams = z.object({ id: z.string().min(1) });
|
|
32
|
+
/** `:id` and the entry `:name` of the import route (`@Param`). */
|
|
33
|
+
export const MarketplaceEntryPathParams = MarketplaceIdPathParams.extend({
|
|
34
|
+
name: z.string().min(1),
|
|
35
|
+
});
|
|
36
|
+
export const MARKETPLACE_ROUTES = [
|
|
37
|
+
{ route: "GET /api/v1/admin/marketplaces" },
|
|
38
|
+
{ route: "POST /api/v1/admin/marketplaces", body: MarketplaceAddBody },
|
|
39
|
+
{ route: "GET /api/v1/orgs/:orgId/marketplaces/entries", query: MarketplaceEntriesQuery },
|
|
40
|
+
{ route: "GET /api/v1/admin/marketplaces/entries", query: MarketplaceEntriesQuery },
|
|
41
|
+
{
|
|
42
|
+
route: "PATCH /api/v1/admin/marketplaces/:id",
|
|
43
|
+
params: MarketplaceIdPathParams,
|
|
44
|
+
body: MarketplacePatchBody,
|
|
45
|
+
},
|
|
46
|
+
{ route: "DELETE /api/v1/admin/marketplaces/:id", params: MarketplaceIdPathParams },
|
|
47
|
+
{ route: "POST /api/v1/admin/marketplaces/:id/refresh", params: MarketplaceIdPathParams },
|
|
48
|
+
{
|
|
49
|
+
route: "POST /api/v1/admin/marketplaces/:id/entries/:name/import",
|
|
50
|
+
params: MarketplaceEntryPathParams,
|
|
51
|
+
body: MarketplaceImportBody,
|
|
52
|
+
},
|
|
53
|
+
];
|
|
@@ -181,7 +181,7 @@ export declare function headsToResolve(entries: readonly MarketplaceEntry[], imp
|
|
|
181
181
|
/** The host versions (an entry's `minKernel` is judged against them). */
|
|
182
182
|
export declare const HOST_VERSIONS: {
|
|
183
183
|
readonly kernel: string;
|
|
184
|
-
readonly sdk: "0.1.0-rc.
|
|
184
|
+
readonly sdk: "0.1.0-rc.5";
|
|
185
185
|
};
|
|
186
186
|
/** Whether this deployment satisfies the entry's `minKernel`. */
|
|
187
187
|
export declare const entryCompatible: (e: Pick<MarketplaceEntry, "minKernel">) => boolean;
|
|
@@ -297,6 +297,20 @@ export declare class MarketplacesService {
|
|
|
297
297
|
mirrors?: string[];
|
|
298
298
|
token?: string;
|
|
299
299
|
}, opts?: ActorOpts): Promise<MarketplaceView>;
|
|
300
|
+
/**
|
|
301
|
+
* The read-only checks of {@link add}, for the `Platform` tool's precheck (before the card): the
|
|
302
|
+
* name, URL and git fields as `add` checks them (throws `validation_failed`), then the source
|
|
303
|
+
* that has the same URL and ref already, if any (adding a duplicate is allowed; the tool points
|
|
304
|
+
* the agent at the existing source instead).
|
|
305
|
+
*/
|
|
306
|
+
checkAdd(input: {
|
|
307
|
+
name: string;
|
|
308
|
+
url: string;
|
|
309
|
+
ref?: string;
|
|
310
|
+
}): Promise<{
|
|
311
|
+
id: string;
|
|
312
|
+
name: string;
|
|
313
|
+
} | null>;
|
|
300
314
|
private writeAdd;
|
|
301
315
|
/**
|
|
302
316
|
* Updates a custom marketplace (audit `marketplace.updated`, listing the changed fields, the
|