@capybara-hq/kernel 0.1.0-rc.6 → 0.1.0-rc.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/bootstrap.json +27 -3
- package/dist/admin/admin.controller.d.ts +8 -72
- package/dist/admin/admin.controller.js +21 -46
- package/dist/admin/admin.schemas.d.ts +57 -0
- package/dist/admin/admin.schemas.js +50 -0
- package/dist/admin/extensions.controller.d.ts +10 -0
- package/dist/admin/extensions.controller.js +18 -0
- package/dist/admin/extensions.schemas.d.ts +7 -0
- package/dist/admin/extensions.schemas.js +10 -0
- package/dist/admin/limit-defaults.d.ts +20 -0
- package/dist/admin/limit-defaults.js +10 -0
- package/dist/agents/agent-profile.service.d.ts +7 -5
- package/dist/agents/agent-profile.service.js +14 -9
- package/dist/agents/agents.controller.d.ts +7 -287
- package/dist/agents/agents.controller.js +7 -67
- package/dist/agents/agents.schemas.d.ts +389 -0
- package/dist/agents/agents.schemas.js +126 -0
- package/dist/agents/agents.service.d.ts +13 -5
- package/dist/agents/agents.service.js +67 -13
- package/dist/agents/definition.d.ts +47 -19
- package/dist/agents/definition.js +119 -38
- package/dist/agents/from-template.d.ts +2 -2
- package/dist/agents/from-template.js +76 -45
- package/dist/agents/from-template.service.d.ts +12 -0
- package/dist/agents/from-template.service.js +20 -3
- package/dist/agents/models.controller.d.ts +1 -2
- package/dist/agents/models.controller.js +1 -1
- package/dist/agents/org-templates.d.ts +13 -3
- package/dist/agents/org-templates.js +69 -28
- package/dist/agents/pending-connector-requests.d.ts +2 -0
- package/dist/agents/pending-connector-requests.js +1 -1
- package/dist/agents/pending-connectors.controller.d.ts +1 -1
- package/dist/agents/pending-connectors.controller.js +2 -2
- package/dist/agents/pending-connectors.service.d.ts +2 -2
- package/dist/agents/pending-connectors.service.js +19 -19
- package/dist/agents/profile.d.ts +18 -0
- package/dist/agents/profile.js +5 -1
- package/dist/agents/templates.controller.d.ts +8 -17
- package/dist/agents/templates.controller.js +13 -31
- package/dist/agents/templates.schemas.d.ts +20 -0
- package/dist/agents/templates.schemas.js +45 -0
- package/dist/background/background.controller.js +3 -2
- package/dist/background/background.schemas.d.ts +10 -0
- package/dist/background/background.schemas.js +16 -0
- package/dist/background/tasks.service.d.ts +1 -1
- package/dist/background/tasks.service.js +7 -2
- package/dist/catalog/admin-catalog.controller.d.ts +4 -57
- package/dist/catalog/admin-catalog.controller.js +8 -45
- package/dist/catalog/admin-catalog.schemas.d.ts +72 -0
- package/dist/catalog/admin-catalog.schemas.js +92 -0
- package/dist/catalog/catalog-content.d.ts +12 -2
- package/dist/catalog/catalog-scope.service.js +8 -2
- package/dist/catalog/catalog.service.d.ts +2 -0
- package/dist/catalog/catalog.service.js +3 -0
- package/dist/catalog/component-scope.controller.d.ts +3 -65
- package/dist/catalog/component-scope.controller.js +3 -56
- package/dist/catalog/component-scope.schemas.d.ts +114 -0
- package/dist/catalog/component-scope.schemas.js +97 -0
- package/dist/catalog/component-scope.service.d.ts +28 -4
- package/dist/catalog/component-scope.service.js +55 -3
- package/dist/catalog/component-state.d.ts +9 -2
- package/dist/catalog/component-state.js +22 -13
- package/dist/catalog/marketplaces.controller.d.ts +5 -35
- package/dist/catalog/marketplaces.controller.js +6 -34
- package/dist/catalog/marketplaces.schemas.d.ts +48 -0
- package/dist/catalog/marketplaces.schemas.js +53 -0
- package/dist/catalog/marketplaces.service.d.ts +15 -1
- package/dist/catalog/marketplaces.service.js +22 -1
- package/dist/catalog/org-catalog.controller.d.ts +6 -62
- package/dist/catalog/org-catalog.controller.js +12 -66
- package/dist/catalog/org-catalog.schemas.d.ts +79 -0
- package/dist/catalog/org-catalog.schemas.js +82 -0
- package/dist/catalog/org-catalog.service.d.ts +9 -2
- package/dist/catalog/org-catalog.service.js +38 -5
- package/dist/catalog/org-extension.controller.d.ts +1 -12
- package/dist/catalog/org-extension.controller.js +1 -10
- package/dist/catalog/org-extension.schemas.d.ts +15 -0
- package/dist/catalog/org-extension.schemas.js +22 -0
- package/dist/catalog/org-plugin-uploads.controller.d.ts +2 -19
- package/dist/catalog/org-plugin-uploads.controller.js +15 -28
- package/dist/catalog/org-plugin-uploads.schemas.d.ts +20 -0
- package/dist/catalog/org-plugin-uploads.schemas.js +32 -0
- package/dist/catalog/owned-items.d.ts +6 -2
- package/dist/catalog/owned-items.js +16 -4
- package/dist/catalog/platform-components.d.ts +2 -0
- package/dist/catalog/platform-components.js +2 -0
- package/dist/catalog/plugin-import.js +1 -0
- package/dist/catalog/plugin-install.js +1 -1
- package/dist/catalog/requests.service.d.ts +2 -1
- package/dist/catalog/requests.service.js +6 -2
- package/dist/channels/channels.schemas.d.ts +33 -0
- package/dist/channels/channels.schemas.js +34 -0
- package/dist/channels/connections.controller.d.ts +2 -29
- package/dist/channels/connections.controller.js +1 -23
- package/dist/channels/connections.service.d.ts +8 -2
- package/dist/channels/connections.service.js +23 -5
- package/dist/channels/inbound.js +4 -0
- package/dist/conversations/conversations.controller.d.ts +16 -37
- package/dist/conversations/conversations.controller.js +16 -56
- package/dist/conversations/conversations.schemas.d.ts +52 -0
- package/dist/conversations/conversations.schemas.js +79 -0
- package/dist/conversations/conversations.service.d.ts +9 -1
- package/dist/conversations/conversations.service.js +23 -18
- package/dist/conversations/events.d.ts +80 -6
- package/dist/conversations/events.js +60 -5
- package/dist/conversations/message-context.d.ts +28 -0
- package/dist/conversations/message-context.js +56 -0
- package/dist/conversations/queue.d.ts +2 -1
- package/dist/conversations/queue.js +11 -2
- package/dist/db/kernel-schema.d.ts +20 -0
- package/dist/environments/environments.schemas.d.ts +3 -0
- package/dist/environments/environments.schemas.js +14 -0
- package/dist/environments/environments.service.d.ts +16 -4
- package/dist/environments/environments.service.js +58 -13
- package/dist/errors.d.ts +3 -0
- package/dist/errors.js +3 -0
- package/dist/evals/evals.schemas.d.ts +110 -0
- package/dist/evals/evals.schemas.js +107 -0
- package/dist/evals/reconstruct.js +18 -11
- package/dist/evals/recorded-tools.d.ts +2 -1
- package/dist/evals/recorded-tools.js +11 -3
- package/dist/evals/run-replay.d.ts +8 -1
- package/dist/evals/run-replay.js +13 -0
- package/dist/evals/runs.controller.d.ts +2 -57
- package/dist/evals/runs.controller.js +1 -42
- package/dist/evals/runs.service.d.ts +6 -6
- package/dist/evals/runs.service.js +32 -18
- package/dist/evals/sets.controller.d.ts +2 -28
- package/dist/evals/sets.controller.js +1 -31
- package/dist/evals/sets.service.d.ts +7 -7
- package/dist/evals/sets.service.js +23 -17
- package/dist/evals/snapshot.d.ts +3 -2
- package/dist/evals/snapshot.js +17 -4
- package/dist/extensions/admin-ops.d.ts +5 -3
- package/dist/extensions/admin-ops.js +17 -12
- package/dist/extensions/deployment-config.d.ts +16 -1
- package/dist/extensions/deployment-config.js +83 -0
- package/dist/extensions/extensions.module.js +3 -0
- package/dist/extensions/host.d.ts +33 -2
- package/dist/extensions/host.js +107 -1
- package/dist/extensions/installs.d.ts +5 -0
- package/dist/extensions/installs.js +12 -0
- package/dist/extensions/org-config.d.ts +17 -2
- package/dist/extensions/org-config.js +23 -4
- package/dist/extensions/point-defaults.controller.d.ts +2 -8
- package/dist/extensions/point-defaults.controller.js +1 -3
- package/dist/extensions/point-defaults.d.ts +3 -1
- package/dist/extensions/point-defaults.js +4 -2
- package/dist/extensions/point-defaults.schemas.d.ts +9 -0
- package/dist/extensions/point-defaults.schemas.js +14 -0
- package/dist/extensions/unavailable.d.ts +49 -0
- package/dist/extensions/unavailable.js +113 -0
- package/dist/files/previewers.controller.js +2 -3
- package/dist/files/previewers.d.ts +1 -1
- package/dist/files/previewers.js +4 -4
- package/dist/files/previewers.schemas.d.ts +10 -0
- package/dist/files/previewers.schemas.js +9 -0
- package/dist/http/api.module.js +2 -0
- package/dist/identity/accounts.d.ts +43 -4
- package/dist/identity/accounts.js +74 -6
- package/dist/identity/auth.guard.js +10 -1
- package/dist/identity/cookies.d.ts +6 -0
- package/dist/identity/cookies.js +14 -0
- package/dist/identity/identity.module.js +3 -0
- package/dist/identity/initial-passwords.controller.d.ts +22 -0
- package/dist/identity/initial-passwords.controller.js +49 -0
- package/dist/identity/initial-passwords.d.ts +61 -0
- package/dist/identity/initial-passwords.job.d.ts +16 -0
- package/dist/identity/initial-passwords.job.js +46 -0
- package/dist/identity/initial-passwords.js +159 -0
- package/dist/identity/me.controller.d.ts +14 -0
- package/dist/identity/me.controller.js +39 -1
- package/dist/identity/principal.d.ts +8 -0
- package/dist/identity/principal.js +8 -0
- package/dist/identity/settings.d.ts +3 -1
- package/dist/identity/settings.js +6 -4
- package/dist/inbox/inbox.schemas.d.ts +8 -0
- package/dist/inbox/inbox.schemas.js +11 -0
- package/dist/inbox/platform-inbox.controller.d.ts +1 -1
- package/dist/inbox/platform-inbox.controller.js +2 -2
- package/dist/index.d.ts +4 -0
- package/dist/index.js +6 -0
- package/dist/lifecycle/kernel-lifecycle.js +4 -0
- package/dist/models/enablement.d.ts +2 -0
- package/dist/models/enablement.js +1 -0
- package/dist/models/org-models.schemas.d.ts +8 -0
- package/dist/models/org-models.schemas.js +22 -0
- package/dist/models/prices.d.ts +3 -1
- package/dist/models/prices.js +7 -5
- package/dist/models/purposes.d.ts +12 -2
- package/dist/models/purposes.js +22 -8
- package/dist/orgs/orgs.controller.d.ts +2 -5
- package/dist/orgs/orgs.controller.js +3 -6
- package/dist/orgs/orgs.schemas.d.ts +8 -0
- package/dist/orgs/orgs.schemas.js +16 -0
- package/dist/orgs/orgs.service.d.ts +3 -1
- package/dist/orgs/orgs.service.js +6 -4
- package/dist/orgs/settings.service.d.ts +9 -1
- package/dist/orgs/settings.service.js +20 -5
- package/dist/overrides.d.ts +4 -0
- package/dist/overrides.js +2 -0
- package/dist/platform/errors.d.ts +21 -4
- package/dist/platform/errors.js +45 -6
- package/dist/platform/exclusions.d.ts +2 -3
- package/dist/platform/exclusions.js +68 -849
- package/dist/platform/method.js +1 -1
- package/dist/platform/operation.d.ts +82 -5
- package/dist/platform/operation.js +62 -7
- package/dist/platform/ops/accounts.ops.d.ts +32 -0
- package/dist/platform/ops/accounts.ops.js +291 -0
- package/dist/platform/ops/admin.ops.d.ts +36 -0
- package/dist/platform/ops/admin.ops.js +389 -0
- package/dist/platform/ops/agent-skills.ops.d.ts +24 -0
- package/dist/platform/ops/agent-skills.ops.js +226 -0
- package/dist/platform/ops/agent-templates.ops.d.ts +4 -1
- package/dist/platform/ops/agent-templates.ops.js +194 -14
- package/dist/platform/ops/agents.ops.d.ts +19 -1
- package/dist/platform/ops/agents.ops.js +481 -58
- package/dist/platform/ops/approvals.ops.d.ts +30 -0
- package/dist/platform/ops/approvals.ops.js +116 -0
- package/dist/platform/ops/background.ops.d.ts +14 -0
- package/dist/platform/ops/background.ops.js +134 -0
- package/dist/platform/ops/catalog-admin.ops.d.ts +74 -0
- package/dist/platform/ops/catalog-admin.ops.js +587 -0
- package/dist/platform/ops/channels.ops.d.ts +16 -0
- package/dist/platform/ops/channels.ops.js +195 -0
- package/dist/platform/ops/components.ops.d.ts +46 -0
- package/dist/platform/ops/components.ops.js +853 -0
- package/dist/platform/ops/connectors.ops.d.ts +4 -2
- package/dist/platform/ops/connectors.ops.js +68 -6
- package/dist/platform/ops/conversations.ops.d.ts +30 -0
- package/dist/platform/ops/conversations.ops.js +470 -0
- package/dist/platform/ops/environments.ops.d.ts +26 -0
- package/dist/platform/ops/environments.ops.js +289 -0
- package/dist/platform/ops/errors.d.ts +10 -5
- package/dist/platform/ops/errors.js +19 -11
- package/dist/platform/ops/evals.ops.d.ts +28 -0
- package/dist/platform/ops/evals.ops.js +783 -0
- package/dist/platform/ops/extensions-admin.ops.d.ts +25 -0
- package/dist/platform/ops/extensions-admin.ops.js +344 -0
- package/dist/platform/ops/extensions.ops.d.ts +7 -1
- package/dist/platform/ops/extensions.ops.js +248 -17
- package/dist/platform/ops/inbox.ops.d.ts +25 -0
- package/dist/platform/ops/inbox.ops.js +378 -0
- package/dist/platform/ops/marketplaces.ops.d.ts +7 -1
- package/dist/platform/ops/marketplaces.ops.js +326 -17
- package/dist/platform/ops/models.ops.d.ts +25 -0
- package/dist/platform/ops/models.ops.js +232 -0
- package/dist/platform/ops/org-plugins.ops.d.ts +29 -0
- package/dist/platform/ops/org-plugins.ops.js +329 -0
- package/dist/platform/ops/org-settings.ops.d.ts +16 -0
- package/dist/platform/ops/org-settings.ops.js +102 -0
- package/dist/platform/ops/orgs.ops.d.ts +28 -0
- package/dist/platform/ops/orgs.ops.js +295 -0
- package/dist/platform/ops/other-orgs.d.ts +20 -0
- package/dist/platform/ops/other-orgs.js +72 -0
- package/dist/platform/ops/platform.ops.d.ts +4 -4
- package/dist/platform/ops/platform.ops.js +23 -24
- package/dist/platform/ops/plugins.ops.d.ts +10 -8
- package/dist/platform/ops/plugins.ops.js +176 -77
- package/dist/platform/ops/previewers.ops.d.ts +14 -0
- package/dist/platform/ops/previewers.ops.js +109 -0
- package/dist/platform/ops/requests.ops.js +57 -19
- package/dist/platform/ops/skills.ops.d.ts +5 -1
- package/dist/platform/ops/skills.ops.js +129 -11
- package/dist/platform/ops/unavailable.d.ts +23 -0
- package/dist/platform/ops/unavailable.js +111 -0
- package/dist/platform/parity.d.ts +33 -0
- package/dist/platform/parity.js +272 -0
- package/dist/platform/platform-ops.module.d.ts +32 -0
- package/dist/platform/platform-ops.module.js +78 -11
- package/dist/platform/route-schemas.d.ts +18 -0
- package/dist/platform/route-schemas.js +60 -0
- package/dist/roles/worker.module.js +2 -0
- package/dist/runtime/context/build.d.ts +2 -0
- package/dist/runtime/context/build.js +28 -2
- package/dist/runtime/context/compaction.js +10 -1
- package/dist/runtime/context/run-context.d.ts +65 -0
- package/dist/runtime/context/run-context.js +215 -0
- package/dist/runtime/model-call.js +2 -1
- package/dist/runtime/providers.js +8 -1
- package/dist/runtime/run-context.service.d.ts +65 -0
- package/dist/runtime/run-context.service.js +220 -0
- package/dist/runtime/run-worker.d.ts +5 -0
- package/dist/runtime/run-worker.js +31 -6
- package/dist/runtime/runtime.module.js +2 -0
- package/dist/runtime/subagents/definition.d.ts +15 -15
- package/dist/runtime/subagents/definition.js +46 -115
- package/dist/skills/changes.controller.js +2 -1
- package/dist/skills/changes.service.d.ts +1 -1
- package/dist/skills/changes.service.js +4 -4
- package/dist/skills/invocable.controller.d.ts +1 -1
- package/dist/skills/invocable.controller.js +2 -2
- package/dist/skills/invoke.d.ts +2 -2
- package/dist/skills/invoke.js +8 -1
- package/dist/skills/skills.controller.d.ts +4 -13
- package/dist/skills/skills.controller.js +8 -24
- package/dist/skills/skills.schemas.d.ts +48 -0
- package/dist/skills/skills.schemas.js +61 -0
- package/dist/skills/skills.service.d.ts +11 -1
- package/dist/skills/skills.service.js +37 -14
- package/dist/time-zone.d.ts +5 -0
- package/dist/time-zone.js +19 -0
- package/dist/tools/approvals.controller.js +2 -3
- package/dist/tools/approvals.schemas.d.ts +21 -0
- package/dist/tools/approvals.schemas.js +15 -0
- package/dist/tools/builtin-names.d.ts +10 -8
- package/dist/tools/builtin-names.js +16 -11
- package/dist/tools/builtins/builtin-tools.d.ts +3 -1
- package/dist/tools/builtins/builtin-tools.js +15 -3
- package/dist/tools/builtins/current-time.d.ts +26 -0
- package/dist/tools/builtins/current-time.js +99 -0
- package/dist/tools/builtins/platform.d.ts +19 -2
- package/dist/tools/builtins/platform.js +105 -16
- package/dist/tools/connectors.controller.d.ts +1 -2
- package/dist/tools/connectors.controller.js +1 -4
- package/dist/tools/connectors.schemas.d.ts +12 -0
- package/dist/tools/connectors.schemas.js +19 -0
- package/dist/tools/connectors.service.d.ts +5 -2
- package/dist/tools/connectors.service.js +7 -5
- package/dist/tools/org-tool-switches.d.ts +16 -2
- package/dist/tools/org-tool-switches.js +26 -9
- package/dist/tools/pipeline.js +3 -1
- package/dist/tools/registry.d.ts +48 -51
- package/dist/tools/registry.js +222 -233
- package/package.json +3 -3
- package/src/migrations/0090_initial_passwords.sql +27 -0
- package/src/migrations/0091_account_time_zone.sql +4 -0
- package/src/migrations/0092_tools_default_on.sql +27 -0
- package/dist/platform/redact-orgs.d.ts +0 -7
- package/dist/platform/redact-orgs.js +0 -52
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
import type { RouteSchemas } from "../platform/route-schemas.js";
|
|
3
|
+
/** Route parameters of the overrides and tool switch routes (decision R20). */
|
|
4
|
+
export declare const OrgExtensionParams: z.ZodObject<{
|
|
5
|
+
extension: z.ZodString;
|
|
6
|
+
}, z.core.$strip>;
|
|
7
|
+
export declare const OrgExtensionToolParams: z.ZodObject<{
|
|
8
|
+
extension: z.ZodString;
|
|
9
|
+
tool: z.ZodString;
|
|
10
|
+
}, z.core.$strip>;
|
|
11
|
+
export declare const OrgToolSwitchPut: z.ZodObject<{
|
|
12
|
+
enabled: z.ZodBoolean;
|
|
13
|
+
confirm: z.ZodOptional<z.ZodString>;
|
|
14
|
+
}, z.core.$strict>;
|
|
15
|
+
export declare const ORG_EXTENSION_ROUTES: readonly RouteSchemas[];
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
/** Route parameters of the overrides and tool switch routes (decision R20). */
|
|
3
|
+
export const OrgExtensionParams = z.object({ extension: z.string().min(1).max(64) });
|
|
4
|
+
export const OrgExtensionToolParams = OrgExtensionParams.extend({
|
|
5
|
+
tool: z.string().min(1).max(64),
|
|
6
|
+
});
|
|
7
|
+
export const OrgToolSwitchPut = z
|
|
8
|
+
.object({
|
|
9
|
+
enabled: z.boolean(),
|
|
10
|
+
/** The hash of the switch-off preview, to confirm turning the tool off. */
|
|
11
|
+
confirm: z.string().min(1).max(128).optional(),
|
|
12
|
+
})
|
|
13
|
+
.strict();
|
|
14
|
+
export const ORG_EXTENSION_ROUTES = [
|
|
15
|
+
{ route: "GET /api/v1/orgs/:orgId/extensions" },
|
|
16
|
+
{ route: "GET /api/v1/orgs/:orgId/extensions/:extension/tools", params: OrgExtensionParams },
|
|
17
|
+
{
|
|
18
|
+
route: "PUT /api/v1/orgs/:orgId/extensions/:extension/tools/:tool",
|
|
19
|
+
params: OrgExtensionToolParams,
|
|
20
|
+
body: OrgToolSwitchPut,
|
|
21
|
+
},
|
|
22
|
+
];
|
|
@@ -1,27 +1,11 @@
|
|
|
1
|
-
import { z } from "zod";
|
|
1
|
+
import type { z } from "zod";
|
|
2
2
|
import { type Principal } from "../identity/principal.js";
|
|
3
3
|
import { type OrgContext } from "../orgs/org.guard.js";
|
|
4
4
|
import type { CatalogItemView } from "./catalog.service.js";
|
|
5
5
|
import { CatalogScopeService } from "./catalog-scope.service.js";
|
|
6
6
|
import { OrgPluginUploads, type OrgUploadOutcome, type OrgUploadReview } from "./org-plugin-uploads.js";
|
|
7
|
+
import { OrgUploadConfirmBody as ConfirmBody, OrgOwnedDeleteBody as DeleteBody, OrgOwnedPluginParams as OwnedParams, OrgOwnedShareableBody as ShareableBody, OrgUploadStagingParams as StagingParams } from "./org-plugin-uploads.schemas.js";
|
|
7
8
|
import { type OwnedDeletePreview, OwnedItems } from "./owned-items.js";
|
|
8
|
-
declare const StagingParams: z.ZodObject<{
|
|
9
|
-
stagingId: z.ZodString;
|
|
10
|
-
}, z.core.$strip>;
|
|
11
|
-
declare const OwnedParams: z.ZodObject<{
|
|
12
|
-
id: z.ZodString;
|
|
13
|
-
}, z.core.$strip>;
|
|
14
|
-
declare const ConfirmBody: z.ZodObject<{
|
|
15
|
-
reviewHash: z.ZodString;
|
|
16
|
-
shareable: z.ZodOptional<z.ZodBoolean>;
|
|
17
|
-
pinnedSuggestions: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
18
|
-
}, z.core.$strict>;
|
|
19
|
-
declare const ShareableBody: z.ZodObject<{
|
|
20
|
-
shareable: z.ZodBoolean;
|
|
21
|
-
}, z.core.$strict>;
|
|
22
|
-
declare const DeleteBody: z.ZodObject<{
|
|
23
|
-
previewHash: z.ZodString;
|
|
24
|
-
}, z.core.$strict>;
|
|
25
9
|
/**
|
|
26
10
|
* An org admin's plugin uploads (`/api/v1/orgs/:orgId/catalog/uploads/*`, spec §14, rulings P3-7,
|
|
27
11
|
* P3-8): a `.tgz` without an extension, prepared (one review) and confirmed like the super admin's
|
|
@@ -95,4 +79,3 @@ export declare class OrgOwnedPluginsController {
|
|
|
95
79
|
*/
|
|
96
80
|
withdraw(principal: Principal, org: OrgContext, params: z.infer<typeof OwnedParams>): Promise<void>;
|
|
97
81
|
}
|
|
98
|
-
export {};
|
|
@@ -8,7 +8,6 @@ var __param = (this && this.__param) || function (paramIndex, decorator) {
|
|
|
8
8
|
return function (target, key) { decorator(target, key, paramIndex); }
|
|
9
9
|
};
|
|
10
10
|
import { Controller, Delete, Get, HttpCode, Inject, Post, Put, Req } from "@nestjs/common";
|
|
11
|
-
import { z } from "zod";
|
|
12
11
|
import { ApiError } from "../errors.js";
|
|
13
12
|
import { CurrentPrincipal, patTokenId, requireUser, } from "../identity/principal.js";
|
|
14
13
|
import { createZodDto } from "../infra/validation/create-zod-dto.js";
|
|
@@ -16,29 +15,17 @@ import { ZBody, ZParam } from "../infra/validation/zod-params.js";
|
|
|
16
15
|
import { CurrentOrg, OrgAction } from "../orgs/org.guard.js";
|
|
17
16
|
import { CatalogScopeService } from "./catalog-scope.service.js";
|
|
18
17
|
import { OrgPluginUploads, } from "./org-plugin-uploads.js";
|
|
18
|
+
import { OrgUploadConfirmBody as ConfirmBody, OrgOwnedDeleteBody as DeleteBody, OrgOwnedPluginParams as OwnedParams, OrgOwnedShareableBody as ShareableBody, OrgUploadStagingParams as StagingParams, } from "./org-plugin-uploads.schemas.js";
|
|
19
19
|
import { OwnedItems } from "./owned-items.js";
|
|
20
|
-
|
|
21
|
-
const OwnedParams = z.object({ id: z.string().min(1).max(100) });
|
|
22
|
-
const ConfirmBody = z
|
|
23
|
-
.object({
|
|
24
|
-
reviewHash: z.string().min(1).max(128),
|
|
25
|
-
/** The org shares the new item with other orgs (default false, P3-16). */
|
|
26
|
-
shareable: z.boolean().optional(),
|
|
27
|
-
/** Skill names suggested as pinned (spec §9.1); omitted keeps the plugin's flags. */
|
|
28
|
-
pinnedSuggestions: z.array(z.string().min(1).max(64)).max(50).optional(),
|
|
29
|
-
})
|
|
30
|
-
.strict();
|
|
31
|
-
class OrgUploadStagingParams extends createZodDto(StagingParams, "OrgUploadStagingParams") {
|
|
20
|
+
class OrgUploadStagingParamsDto extends createZodDto(StagingParams, "OrgUploadStagingParams") {
|
|
32
21
|
}
|
|
33
|
-
class
|
|
22
|
+
class OrgUploadConfirmBodyDto extends createZodDto(ConfirmBody, "OrgUploadConfirmBody") {
|
|
34
23
|
}
|
|
35
|
-
class
|
|
24
|
+
class OrgOwnedPluginParamsDto extends createZodDto(OwnedParams, "OrgOwnedPluginParams") {
|
|
36
25
|
}
|
|
37
|
-
|
|
38
|
-
const DeleteBody = z.object({ previewHash: z.string().min(1).max(128) }).strict();
|
|
39
|
-
class OrgOwnedShareableBody extends createZodDto(ShareableBody, "OrgOwnedShareableBody") {
|
|
26
|
+
class OrgOwnedShareableBodyDto extends createZodDto(ShareableBody, "OrgOwnedShareableBody") {
|
|
40
27
|
}
|
|
41
|
-
class
|
|
28
|
+
class OrgOwnedDeleteBodyDto extends createZodDto(DeleteBody, "OrgOwnedDeleteBody") {
|
|
42
29
|
}
|
|
43
30
|
const actorOpts = (actor) => {
|
|
44
31
|
const tokenId = patTokenId(actor);
|
|
@@ -107,7 +94,7 @@ __decorate([
|
|
|
107
94
|
Get(":stagingId"),
|
|
108
95
|
OrgAction("catalog.upload"),
|
|
109
96
|
__param(0, CurrentOrg()),
|
|
110
|
-
__param(1, ZParam(
|
|
97
|
+
__param(1, ZParam(OrgUploadStagingParamsDto))
|
|
111
98
|
], OrgPluginUploadsController.prototype, "staged", null);
|
|
112
99
|
__decorate([
|
|
113
100
|
Post(":stagingId/confirm"),
|
|
@@ -115,8 +102,8 @@ __decorate([
|
|
|
115
102
|
OrgAction("catalog.upload"),
|
|
116
103
|
__param(0, CurrentPrincipal()),
|
|
117
104
|
__param(1, CurrentOrg()),
|
|
118
|
-
__param(2, ZParam(
|
|
119
|
-
__param(3, ZBody(
|
|
105
|
+
__param(2, ZParam(OrgUploadStagingParamsDto)),
|
|
106
|
+
__param(3, ZBody(OrgUploadConfirmBodyDto))
|
|
120
107
|
], OrgPluginUploadsController.prototype, "confirm", null);
|
|
121
108
|
OrgPluginUploadsController = __decorate([
|
|
122
109
|
Controller("api/v1/orgs/:orgId/catalog/uploads"),
|
|
@@ -178,15 +165,15 @@ __decorate([
|
|
|
178
165
|
OrgAction("catalog.upload"),
|
|
179
166
|
__param(0, CurrentPrincipal()),
|
|
180
167
|
__param(1, CurrentOrg()),
|
|
181
|
-
__param(2, ZParam(
|
|
182
|
-
__param(3, ZBody(
|
|
168
|
+
__param(2, ZParam(OrgOwnedPluginParamsDto)),
|
|
169
|
+
__param(3, ZBody(OrgOwnedShareableBodyDto))
|
|
183
170
|
], OrgOwnedPluginsController.prototype, "setShareable", null);
|
|
184
171
|
__decorate([
|
|
185
172
|
Post(":id/delete/preview"),
|
|
186
173
|
HttpCode(200),
|
|
187
174
|
OrgAction("catalog.upload"),
|
|
188
175
|
__param(0, CurrentOrg()),
|
|
189
|
-
__param(1, ZParam(
|
|
176
|
+
__param(1, ZParam(OrgOwnedPluginParamsDto))
|
|
190
177
|
], OrgOwnedPluginsController.prototype, "previewDelete", null);
|
|
191
178
|
__decorate([
|
|
192
179
|
Post(":id/delete"),
|
|
@@ -194,8 +181,8 @@ __decorate([
|
|
|
194
181
|
OrgAction("catalog.upload"),
|
|
195
182
|
__param(0, CurrentPrincipal()),
|
|
196
183
|
__param(1, CurrentOrg()),
|
|
197
|
-
__param(2, ZParam(
|
|
198
|
-
__param(3, ZBody(
|
|
184
|
+
__param(2, ZParam(OrgOwnedPluginParamsDto)),
|
|
185
|
+
__param(3, ZBody(OrgOwnedDeleteBodyDto))
|
|
199
186
|
], OrgOwnedPluginsController.prototype, "delete", null);
|
|
200
187
|
__decorate([
|
|
201
188
|
Delete(":id/pending"),
|
|
@@ -203,7 +190,7 @@ __decorate([
|
|
|
203
190
|
OrgAction("catalog.upload"),
|
|
204
191
|
__param(0, CurrentPrincipal()),
|
|
205
192
|
__param(1, CurrentOrg()),
|
|
206
|
-
__param(2, ZParam(
|
|
193
|
+
__param(2, ZParam(OrgOwnedPluginParamsDto))
|
|
207
194
|
], OrgOwnedPluginsController.prototype, "withdraw", null);
|
|
208
195
|
OrgOwnedPluginsController = __decorate([
|
|
209
196
|
Controller("api/v1/orgs/:orgId/owned-plugins"),
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
import type { RouteSchemas } from "../platform/route-schemas.js";
|
|
3
|
+
export declare const OrgUploadStagingParams: z.ZodObject<{
|
|
4
|
+
stagingId: z.ZodString;
|
|
5
|
+
}, z.core.$strip>;
|
|
6
|
+
export declare const OrgOwnedPluginParams: z.ZodObject<{
|
|
7
|
+
id: z.ZodString;
|
|
8
|
+
}, z.core.$strip>;
|
|
9
|
+
export declare const OrgUploadConfirmBody: z.ZodObject<{
|
|
10
|
+
reviewHash: z.ZodString;
|
|
11
|
+
shareable: z.ZodOptional<z.ZodBoolean>;
|
|
12
|
+
pinnedSuggestions: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
13
|
+
}, z.core.$strict>;
|
|
14
|
+
export declare const OrgOwnedShareableBody: z.ZodObject<{
|
|
15
|
+
shareable: z.ZodBoolean;
|
|
16
|
+
}, z.core.$strict>;
|
|
17
|
+
export declare const OrgOwnedDeleteBody: z.ZodObject<{
|
|
18
|
+
previewHash: z.ZodString;
|
|
19
|
+
}, z.core.$strict>;
|
|
20
|
+
export declare const ORG_PLUGIN_UPLOAD_ROUTES: readonly RouteSchemas[];
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
export const OrgUploadStagingParams = z.object({ stagingId: z.string().min(1).max(100) });
|
|
3
|
+
export const OrgOwnedPluginParams = z.object({ id: z.string().min(1).max(100) });
|
|
4
|
+
export const OrgUploadConfirmBody = z
|
|
5
|
+
.object({
|
|
6
|
+
reviewHash: z.string().min(1).max(128),
|
|
7
|
+
/** The org shares the new item with other orgs (default false, P3-16). */
|
|
8
|
+
shareable: z.boolean().optional(),
|
|
9
|
+
/** Skill names suggested as pinned (spec §9.1); omitted keeps the plugin's flags. */
|
|
10
|
+
pinnedSuggestions: z.array(z.string().min(1).max(64)).max(50).optional(),
|
|
11
|
+
})
|
|
12
|
+
.strict();
|
|
13
|
+
export const OrgOwnedShareableBody = z.object({ shareable: z.boolean() }).strict();
|
|
14
|
+
export const OrgOwnedDeleteBody = z.object({ previewHash: z.string().min(1).max(128) }).strict();
|
|
15
|
+
export const ORG_PLUGIN_UPLOAD_ROUTES = [
|
|
16
|
+
{ route: "GET /api/v1/orgs/:orgId/catalog/uploads/:stagingId", params: OrgUploadStagingParams },
|
|
17
|
+
{
|
|
18
|
+
route: "PUT /api/v1/orgs/:orgId/owned-plugins/:id/shareable",
|
|
19
|
+
params: OrgOwnedPluginParams,
|
|
20
|
+
body: OrgOwnedShareableBody,
|
|
21
|
+
},
|
|
22
|
+
{
|
|
23
|
+
route: "POST /api/v1/orgs/:orgId/owned-plugins/:id/delete/preview",
|
|
24
|
+
params: OrgOwnedPluginParams,
|
|
25
|
+
},
|
|
26
|
+
{
|
|
27
|
+
route: "POST /api/v1/orgs/:orgId/owned-plugins/:id/delete",
|
|
28
|
+
params: OrgOwnedPluginParams,
|
|
29
|
+
body: OrgOwnedDeleteBody,
|
|
30
|
+
},
|
|
31
|
+
{ route: "DELETE /api/v1/orgs/:orgId/owned-plugins/:id/pending", params: OrgOwnedPluginParams },
|
|
32
|
+
];
|
|
@@ -65,7 +65,9 @@ export declare class OwnedItems {
|
|
|
65
65
|
* 409 `catalog.not_owned`); one it promoted writes its platform row too (pre-flight F16). Audits
|
|
66
66
|
* `catalog.shareable_changed`.
|
|
67
67
|
*/
|
|
68
|
-
setShareable(orgId: string, actor: string, ref: OwnedRef, shareable: boolean, opts?: ActorOpts
|
|
68
|
+
setShareable(orgId: string, actor: string, ref: OwnedRef, shareable: boolean, opts?: ActorOpts & {
|
|
69
|
+
auditDetail?: Record<string, unknown>;
|
|
70
|
+
}): Promise<void>;
|
|
69
71
|
/** {@link setShareable} of an org skill or agent template (named by the org row's id). */
|
|
70
72
|
private setComponentShareable;
|
|
71
73
|
/** The other live orgs the item is on in (P3-18, {@link orgsUsing}), by name. */
|
|
@@ -86,7 +88,9 @@ export declare class OwnedItems {
|
|
|
86
88
|
* `owner_deleted` (another org using it keeps it, now the platform's), then the org row is
|
|
87
89
|
* soft-deleted as before (audit `skill.deleted`). Not an org-scope skill of the org -> 404.
|
|
88
90
|
*/
|
|
89
|
-
deleteSkill(orgId: string, actor: string, skillId: string, opts?: ActorOpts
|
|
91
|
+
deleteSkill(orgId: string, actor: string, skillId: string, opts?: ActorOpts & {
|
|
92
|
+
auditDetail?: Record<string, unknown>;
|
|
93
|
+
}): Promise<"transferred" | "removed">;
|
|
90
94
|
/**
|
|
91
95
|
* What deleting the org's own agent template `id` does (ruling P4-12, as
|
|
92
96
|
* {@link previewSkillDelete}): one it promoted that another org uses is `transferred` (`orgs`:
|
|
@@ -121,7 +121,7 @@ let OwnedItems = class OwnedItems {
|
|
|
121
121
|
orgId,
|
|
122
122
|
action: "catalog.shareable_changed",
|
|
123
123
|
target: item.id,
|
|
124
|
-
detail: { name: item.name, shareable },
|
|
124
|
+
detail: { name: item.name, shareable, ...opts.auditDetail },
|
|
125
125
|
});
|
|
126
126
|
}
|
|
127
127
|
/** {@link setShareable} of an org skill or agent template (named by the org row's id). */
|
|
@@ -165,6 +165,7 @@ let OwnedItems = class OwnedItems {
|
|
|
165
165
|
name: row.name,
|
|
166
166
|
shareable,
|
|
167
167
|
...(row.link !== null && { platformId: row.link }),
|
|
168
|
+
...opts.auditDetail,
|
|
168
169
|
},
|
|
169
170
|
});
|
|
170
171
|
}
|
|
@@ -221,7 +222,7 @@ let OwnedItems = class OwnedItems {
|
|
|
221
222
|
const outcome = row.link === null
|
|
222
223
|
? "removed"
|
|
223
224
|
: await this.transferOrRemove({ kind: "skill", id: row.link }, "owner_deleted", actor, opts);
|
|
224
|
-
await this.skills.deleteOrgSkillIn(orgId, row.id, actor, opts.actorTokenId);
|
|
225
|
+
await this.skills.deleteOrgSkillIn(orgId, row.id, actor, opts.actorTokenId, opts.auditDetail);
|
|
225
226
|
return outcome;
|
|
226
227
|
}
|
|
227
228
|
/**
|
|
@@ -266,7 +267,12 @@ let OwnedItems = class OwnedItems {
|
|
|
266
267
|
orgId,
|
|
267
268
|
action: "agent_template.deleted",
|
|
268
269
|
target: row.id,
|
|
269
|
-
detail: {
|
|
270
|
+
detail: {
|
|
271
|
+
name: row.name,
|
|
272
|
+
outcome,
|
|
273
|
+
...(row.link !== null && { platformId: row.link }),
|
|
274
|
+
...opts.auditDetail,
|
|
275
|
+
},
|
|
270
276
|
});
|
|
271
277
|
return outcome;
|
|
272
278
|
}
|
|
@@ -510,7 +516,13 @@ let OwnedItems = class OwnedItems {
|
|
|
510
516
|
orgId: owner,
|
|
511
517
|
action: "catalog.ownership_transferred",
|
|
512
518
|
target: item.id,
|
|
513
|
-
detail: {
|
|
519
|
+
detail: {
|
|
520
|
+
name: item.name,
|
|
521
|
+
fromOrgId: owner,
|
|
522
|
+
reason,
|
|
523
|
+
usedBy: others.map((o) => o.id),
|
|
524
|
+
...opts.auditDetail,
|
|
525
|
+
},
|
|
514
526
|
});
|
|
515
527
|
afterCommit(() => this.scope.enqueueSync(item.id));
|
|
516
528
|
return "transferred";
|
|
@@ -122,6 +122,8 @@ export interface OwnerVersion {
|
|
|
122
122
|
export interface UploadActor {
|
|
123
123
|
accountId: string;
|
|
124
124
|
actorTokenId?: string;
|
|
125
|
+
/** Added to the audit detail (the Platform tool's `via`). */
|
|
126
|
+
auditDetail?: Record<string, unknown>;
|
|
125
127
|
}
|
|
126
128
|
/**
|
|
127
129
|
* Writes the platform rows of a catalog version's components. Called by the import confirm that
|
|
@@ -346,6 +346,7 @@ let PlatformComponents = class PlatformComponents {
|
|
|
346
346
|
plugin: live.plugin_name,
|
|
347
347
|
from: live.current_version,
|
|
348
348
|
to,
|
|
349
|
+
...actor.auditDetail,
|
|
349
350
|
},
|
|
350
351
|
});
|
|
351
352
|
}
|
|
@@ -400,6 +401,7 @@ let PlatformComponents = class PlatformComponents {
|
|
|
400
401
|
plugin: live.plugin_name,
|
|
401
402
|
from: live.current_version,
|
|
402
403
|
to,
|
|
404
|
+
...actor.auditDetail,
|
|
403
405
|
},
|
|
404
406
|
});
|
|
405
407
|
}
|
|
@@ -896,7 +896,7 @@ let PluginInstaller = class PluginInstaller {
|
|
|
896
896
|
return null;
|
|
897
897
|
const name = manifest.name;
|
|
898
898
|
if (!this.registry.manifests().some((m) => m.name === name)) {
|
|
899
|
-
throw new ApiError("catalog.not_deployed", `The extension of plugin ${name} is not
|
|
899
|
+
throw new ApiError("catalog.not_deployed", `The extension of plugin ${name} is not running on the platform (not installed, waiting for its deployment config or permission approval, disabled, or failed to load); the org cannot switch it on until it runs`);
|
|
900
900
|
}
|
|
901
901
|
const enabled = await isExtensionEnabled(this.db, orgId, name);
|
|
902
902
|
if (!enabled && (await disabledPluginItems(this.db, [name])).length > 0) {
|
|
@@ -143,7 +143,8 @@ export declare class CatalogRequestsService {
|
|
|
143
143
|
* A request for a catalog item (`POST /orgs/:orgId/catalog/:itemId/requests`): `enable`
|
|
144
144
|
* (`catalog.request`, members and up) or `access` (`catalog.decide`, org admins), checked first.
|
|
145
145
|
* The item as the org sees it: absent (missing, deleted, hidden, disabled for a member) ->
|
|
146
|
-
* `catalog.item_not_found`; disabled -> `catalog.item_disabled` for an org admin;
|
|
146
|
+
* `catalog.item_not_found`; disabled -> `catalog.item_disabled` for an org admin; its extension
|
|
147
|
+
* unable to run on the platform -> `catalog.request_invalid`; `access` needs
|
|
147
148
|
* `not_offered`, `enable` needs `off` (else `catalog.request_invalid`); a pending request of the
|
|
148
149
|
* kind -> `catalog.request_pending`. Audits `catalog.requested`.
|
|
149
150
|
*/
|
|
@@ -95,7 +95,8 @@ let CatalogRequestsService = class CatalogRequestsService {
|
|
|
95
95
|
* A request for a catalog item (`POST /orgs/:orgId/catalog/:itemId/requests`): `enable`
|
|
96
96
|
* (`catalog.request`, members and up) or `access` (`catalog.decide`, org admins), checked first.
|
|
97
97
|
* The item as the org sees it: absent (missing, deleted, hidden, disabled for a member) ->
|
|
98
|
-
* `catalog.item_not_found`; disabled -> `catalog.item_disabled` for an org admin;
|
|
98
|
+
* `catalog.item_not_found`; disabled -> `catalog.item_disabled` for an org admin; its extension
|
|
99
|
+
* unable to run on the platform -> `catalog.request_invalid`; `access` needs
|
|
99
100
|
* `not_offered`, `enable` needs `off` (else `catalog.request_invalid`); a pending request of the
|
|
100
101
|
* kind -> `catalog.request_pending`. Audits `catalog.requested`.
|
|
101
102
|
*/
|
|
@@ -107,8 +108,11 @@ let CatalogRequestsService = class CatalogRequestsService {
|
|
|
107
108
|
const [item] = await this.orgCatalog.list(orgId, actor, itemId);
|
|
108
109
|
if (!item)
|
|
109
110
|
throw itemNotFound();
|
|
110
|
-
if (item.state === "unavailable")
|
|
111
|
+
if (item.state === "unavailable" && item.reason === "plugin_disabled")
|
|
111
112
|
throw itemDisabled();
|
|
113
|
+
if (item.state === "unavailable") {
|
|
114
|
+
throw new ApiError("catalog.request_invalid", `This plugin's extension cannot run on the platform now (${item.reason ?? "unavailable"}); only the super admin can fix that`);
|
|
115
|
+
}
|
|
112
116
|
const want = input.kind === "access" ? "not_offered" : "off";
|
|
113
117
|
if (item.state !== want) {
|
|
114
118
|
throw new ApiError("catalog.request_invalid", input.kind === "access"
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
import type { RouteSchemas } from "../platform/route-schemas.js";
|
|
3
|
+
export declare const ChannelCreateSchema: z.ZodObject<{
|
|
4
|
+
plugin: z.ZodString;
|
|
5
|
+
name: z.ZodString;
|
|
6
|
+
agentId: z.ZodString;
|
|
7
|
+
config: z.ZodRecord<z.ZodString, z.ZodUnknown>;
|
|
8
|
+
unboundPolicy: z.ZodOptional<z.ZodEnum<{
|
|
9
|
+
anonymous: "anonymous";
|
|
10
|
+
bind: "bind";
|
|
11
|
+
}>>;
|
|
12
|
+
}, z.core.$strict>;
|
|
13
|
+
export declare const ChannelPatchSchema: z.ZodObject<{
|
|
14
|
+
name: z.ZodOptional<z.ZodString>;
|
|
15
|
+
agentId: z.ZodOptional<z.ZodString>;
|
|
16
|
+
unboundPolicy: z.ZodOptional<z.ZodEnum<{
|
|
17
|
+
anonymous: "anonymous";
|
|
18
|
+
bind: "bind";
|
|
19
|
+
}>>;
|
|
20
|
+
status: z.ZodOptional<z.ZodEnum<{
|
|
21
|
+
active: "active";
|
|
22
|
+
disabled: "disabled";
|
|
23
|
+
}>>;
|
|
24
|
+
inboundMode: z.ZodOptional<z.ZodEnum<{
|
|
25
|
+
long_connection: "long_connection";
|
|
26
|
+
webhook: "webhook";
|
|
27
|
+
}>>;
|
|
28
|
+
config: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
|
|
29
|
+
}, z.core.$strict>;
|
|
30
|
+
export declare const ChannelPathParams: z.ZodObject<{
|
|
31
|
+
connectionId: z.ZodString;
|
|
32
|
+
}, z.core.$strip>;
|
|
33
|
+
export declare const CHANNEL_ROUTES: readonly RouteSchemas[];
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
const Config = z.record(z.string().max(200), z.unknown());
|
|
3
|
+
const Policy = z.enum(["bind", "anonymous"]);
|
|
4
|
+
export const ChannelCreateSchema = z
|
|
5
|
+
.object({
|
|
6
|
+
plugin: z.string().min(1).max(214),
|
|
7
|
+
name: z.string().trim().min(1).max(100),
|
|
8
|
+
agentId: z.string().min(1).max(100),
|
|
9
|
+
config: Config,
|
|
10
|
+
unboundPolicy: Policy.optional(),
|
|
11
|
+
})
|
|
12
|
+
.strict();
|
|
13
|
+
export const ChannelPatchSchema = z
|
|
14
|
+
.object({
|
|
15
|
+
name: z.string().trim().min(1).max(100).optional(),
|
|
16
|
+
agentId: z.string().min(1).max(100).optional(),
|
|
17
|
+
unboundPolicy: Policy.optional(),
|
|
18
|
+
status: z.enum(["active", "disabled"]).optional(),
|
|
19
|
+
// webhook needs plugin support and channels.webhookBaseUrl (409 channel.webhook_unavailable)
|
|
20
|
+
inboundMode: z.enum(["long_connection", "webhook"]).optional(),
|
|
21
|
+
config: Config.optional(),
|
|
22
|
+
})
|
|
23
|
+
.strict();
|
|
24
|
+
export const ChannelPathParams = z.object({ connectionId: z.string().min(1).max(100) });
|
|
25
|
+
export const CHANNEL_ROUTES = [
|
|
26
|
+
{ route: "GET /api/v1/orgs/:orgId/channels" },
|
|
27
|
+
{ route: "GET /api/v1/orgs/:orgId/channels/:connectionId", params: ChannelPathParams },
|
|
28
|
+
{
|
|
29
|
+
route: "PATCH /api/v1/orgs/:orgId/channels/:connectionId",
|
|
30
|
+
params: ChannelPathParams,
|
|
31
|
+
body: ChannelPatchSchema,
|
|
32
|
+
},
|
|
33
|
+
{ route: "DELETE /api/v1/orgs/:orgId/channels/:connectionId", params: ChannelPathParams },
|
|
34
|
+
];
|
|
@@ -1,35 +1,9 @@
|
|
|
1
|
-
import { z } from "zod";
|
|
1
|
+
import type { z } from "zod";
|
|
2
2
|
import type { JsonSchema } from "../extensions/config-json-schema.js";
|
|
3
3
|
import { type Principal } from "../identity/principal.js";
|
|
4
4
|
import { type OrgContext } from "../orgs/org.guard.js";
|
|
5
|
+
import { ChannelCreateSchema as CreateBody, ChannelPatchSchema as PatchBody } from "./channels.schemas.js";
|
|
5
6
|
import { ChannelConnections, type ChannelConnectionView } from "./connections.service.js";
|
|
6
|
-
declare const CreateBody: z.ZodObject<{
|
|
7
|
-
plugin: z.ZodString;
|
|
8
|
-
name: z.ZodString;
|
|
9
|
-
agentId: z.ZodString;
|
|
10
|
-
config: z.ZodRecord<z.ZodString, z.ZodUnknown>;
|
|
11
|
-
unboundPolicy: z.ZodOptional<z.ZodEnum<{
|
|
12
|
-
anonymous: "anonymous";
|
|
13
|
-
bind: "bind";
|
|
14
|
-
}>>;
|
|
15
|
-
}, z.core.$strict>;
|
|
16
|
-
declare const PatchBody: z.ZodObject<{
|
|
17
|
-
name: z.ZodOptional<z.ZodString>;
|
|
18
|
-
agentId: z.ZodOptional<z.ZodString>;
|
|
19
|
-
unboundPolicy: z.ZodOptional<z.ZodEnum<{
|
|
20
|
-
anonymous: "anonymous";
|
|
21
|
-
bind: "bind";
|
|
22
|
-
}>>;
|
|
23
|
-
status: z.ZodOptional<z.ZodEnum<{
|
|
24
|
-
active: "active";
|
|
25
|
-
disabled: "disabled";
|
|
26
|
-
}>>;
|
|
27
|
-
inboundMode: z.ZodOptional<z.ZodEnum<{
|
|
28
|
-
long_connection: "long_connection";
|
|
29
|
-
webhook: "webhook";
|
|
30
|
-
}>>;
|
|
31
|
-
config: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
|
|
32
|
-
}, z.core.$strict>;
|
|
33
7
|
/**
|
|
34
8
|
* 组织的渠道连接(`/api/v1/orgs/:orgId/channels`),全部需要 `channels.manage`(admin,仅限人)。
|
|
35
9
|
* 响应只回显非密钥配置与密钥是否已设置。
|
|
@@ -56,4 +30,3 @@ export declare class ChannelConnectionsController {
|
|
|
56
30
|
}>;
|
|
57
31
|
remove(principal: Principal, org: OrgContext, id: string): Promise<void>;
|
|
58
32
|
}
|
|
59
|
-
export {};
|
|
@@ -8,34 +8,12 @@ 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
11
|
import { CurrentPrincipal, patTokenId, requireUser, } from "../identity/principal.js";
|
|
13
12
|
import { createZodDto } from "../infra/validation/create-zod-dto.js";
|
|
14
13
|
import { ZBody } from "../infra/validation/zod-params.js";
|
|
15
14
|
import { CurrentOrg, OrgAction } from "../orgs/org.guard.js";
|
|
15
|
+
import { ChannelCreateSchema as CreateBody, ChannelPatchSchema as PatchBody, } from "./channels.schemas.js";
|
|
16
16
|
import { ChannelConnections } from "./connections.service.js";
|
|
17
|
-
const Config = z.record(z.string().max(200), z.unknown());
|
|
18
|
-
const Policy = z.enum(["bind", "anonymous"]);
|
|
19
|
-
const CreateBody = z
|
|
20
|
-
.object({
|
|
21
|
-
plugin: z.string().min(1).max(214),
|
|
22
|
-
name: z.string().trim().min(1).max(100),
|
|
23
|
-
agentId: z.string().min(1).max(100),
|
|
24
|
-
config: Config,
|
|
25
|
-
unboundPolicy: Policy.optional(),
|
|
26
|
-
})
|
|
27
|
-
.strict();
|
|
28
|
-
const PatchBody = z
|
|
29
|
-
.object({
|
|
30
|
-
name: z.string().trim().min(1).max(100).optional(),
|
|
31
|
-
agentId: z.string().min(1).max(100).optional(),
|
|
32
|
-
unboundPolicy: Policy.optional(),
|
|
33
|
-
status: z.enum(["active", "disabled"]).optional(),
|
|
34
|
-
// webhook needs plugin support and channels.webhookBaseUrl (409 channel.webhook_unavailable)
|
|
35
|
-
inboundMode: z.enum(["long_connection", "webhook"]).optional(),
|
|
36
|
-
config: Config.optional(),
|
|
37
|
-
})
|
|
38
|
-
.strict();
|
|
39
17
|
class ChannelCreateBody extends createZodDto(CreateBody, "ChannelCreateBody") {
|
|
40
18
|
}
|
|
41
19
|
class ChannelPatchBody extends createZodDto(PatchBody, "ChannelPatchBody") {
|
|
@@ -159,18 +159,24 @@ export declare class ChannelConnections implements OnApplicationShutdown {
|
|
|
159
159
|
create(orgId: string, input: CreateChannelInput, actorAccountId: string, actorTokenId?: string): Promise<ChannelConnectionView>;
|
|
160
160
|
/** The rows of {@link create}, in their own transaction (the caller publishes after the commit). */
|
|
161
161
|
private insertIn;
|
|
162
|
+
/** The read-only refusals of {@link update} that need no write (the Platform tool's precheck). */
|
|
163
|
+
checkUpdate(orgId: string, id: string, patch: UpdateChannelInput): Promise<void>;
|
|
162
164
|
/**
|
|
163
165
|
* 修改名称、agent、未绑定策略、启停,或轮换凭据(新配置同样先 `verify`,失败什么都不改)。
|
|
164
166
|
* 插件在该组织停用时仍可轮换凭据,此时不 verify,返回 `verifySkipped: true`。
|
|
165
167
|
*/
|
|
166
|
-
update(orgId: string, id: string, patch: UpdateChannelInput, actorAccountId: string, actorTokenId?: string
|
|
168
|
+
update(orgId: string, id: string, patch: UpdateChannelInput, actorAccountId: string, actorTokenId?: string,
|
|
169
|
+
/** Merged into the audit detail (the Platform tool's `via: "agent"`). */
|
|
170
|
+
auditDetail?: Record<string, unknown>): Promise<{
|
|
167
171
|
channel: ChannelConnectionView;
|
|
168
172
|
verifySkipped: boolean;
|
|
169
173
|
}>;
|
|
170
174
|
/** The rows of {@link update}, in their own transaction (the caller publishes after the commit). */
|
|
171
175
|
private updateIn;
|
|
172
176
|
/** 删除(软删除,同一事务删掉密钥);持有长连接的副本收到广播后断开。 */
|
|
173
|
-
remove(orgId: string, id: string, actorAccountId: string, actorTokenId?: string
|
|
177
|
+
remove(orgId: string, id: string, actorAccountId: string, actorTokenId?: string,
|
|
178
|
+
/** Merged into the audit detail (the Platform tool's `via: "agent"`). */
|
|
179
|
+
auditDetail?: Record<string, unknown>): Promise<void>;
|
|
174
180
|
/** The rows of {@link remove}, in their own transaction (the caller publishes after the commit). */
|
|
175
181
|
private removeIn;
|
|
176
182
|
/** 提交后广播;失败只记日志(持有方每轮续租时也会复核连接状态)。 */
|
|
@@ -376,11 +376,24 @@ let ChannelConnections = class ChannelConnections {
|
|
|
376
376
|
});
|
|
377
377
|
return inserted;
|
|
378
378
|
}
|
|
379
|
+
/** The read-only refusals of {@link update} that need no write (the Platform tool's precheck). */
|
|
380
|
+
async checkUpdate(orgId, id, patch) {
|
|
381
|
+
const current = await this.live(orgId).where("id", "=", id).executeTakeFirst();
|
|
382
|
+
if (!current)
|
|
383
|
+
throw notFound();
|
|
384
|
+
if (patch.agentId !== undefined)
|
|
385
|
+
await this.assertAgent(orgId, patch.agentId);
|
|
386
|
+
if (patch.inboundMode === "webhook" && patch.inboundMode !== current.inbound_mode) {
|
|
387
|
+
this.assertWebhookAvailable(current.plugin);
|
|
388
|
+
}
|
|
389
|
+
}
|
|
379
390
|
/**
|
|
380
391
|
* 修改名称、agent、未绑定策略、启停,或轮换凭据(新配置同样先 `verify`,失败什么都不改)。
|
|
381
392
|
* 插件在该组织停用时仍可轮换凭据,此时不 verify,返回 `verifySkipped: true`。
|
|
382
393
|
*/
|
|
383
|
-
async update(orgId, id, patch, actorAccountId, actorTokenId
|
|
394
|
+
async update(orgId, id, patch, actorAccountId, actorTokenId,
|
|
395
|
+
/** Merged into the audit detail (the Platform tool's `via: "agent"`). */
|
|
396
|
+
auditDetail) {
|
|
384
397
|
const current = await this.live(orgId).where("id", "=", id).executeTakeFirst();
|
|
385
398
|
if (!current)
|
|
386
399
|
throw notFound();
|
|
@@ -421,6 +434,7 @@ let ChannelConnections = class ChannelConnections {
|
|
|
421
434
|
verified,
|
|
422
435
|
actorAccountId,
|
|
423
436
|
actorTokenId,
|
|
437
|
+
auditDetail,
|
|
424
438
|
});
|
|
425
439
|
if (rotated)
|
|
426
440
|
this.reportSecrets(rotated.schema, rotated.full);
|
|
@@ -443,7 +457,7 @@ let ChannelConnections = class ChannelConnections {
|
|
|
443
457
|
}
|
|
444
458
|
/** The rows of {@link update}, in their own transaction (the caller publishes after the commit). */
|
|
445
459
|
async updateIn(a) {
|
|
446
|
-
const { orgId, id, patch, rotated, verified, actorAccountId, actorTokenId } = a;
|
|
460
|
+
const { orgId, id, patch, rotated, verified, actorAccountId, actorTokenId, auditDetail } = a;
|
|
447
461
|
await this.orgLock.lockAndAuthorize(orgId, actorAccountId, "channels.manage");
|
|
448
462
|
if (patch.agentId !== undefined)
|
|
449
463
|
await this.assertAgent(orgId, patch.agentId);
|
|
@@ -488,17 +502,20 @@ let ChannelConnections = class ChannelConnections {
|
|
|
488
502
|
...Object.keys(patch).filter((k) => k !== "config" && patch[k] !== undefined),
|
|
489
503
|
...(rotated ? ["config"] : []),
|
|
490
504
|
],
|
|
505
|
+
...auditDetail,
|
|
491
506
|
},
|
|
492
507
|
});
|
|
493
508
|
return updated;
|
|
494
509
|
}
|
|
495
510
|
/** 删除(软删除,同一事务删掉密钥);持有长连接的副本收到广播后断开。 */
|
|
496
|
-
async remove(orgId, id, actorAccountId, actorTokenId
|
|
497
|
-
|
|
511
|
+
async remove(orgId, id, actorAccountId, actorTokenId,
|
|
512
|
+
/** Merged into the audit detail (the Platform tool's `via: "agent"`). */
|
|
513
|
+
auditDetail) {
|
|
514
|
+
await this.removeIn(orgId, id, actorAccountId, actorTokenId, auditDetail);
|
|
498
515
|
await this.changed(id, true);
|
|
499
516
|
}
|
|
500
517
|
/** The rows of {@link remove}, in their own transaction (the caller publishes after the commit). */
|
|
501
|
-
async removeIn(orgId, id, actorAccountId, actorTokenId) {
|
|
518
|
+
async removeIn(orgId, id, actorAccountId, actorTokenId, auditDetail) {
|
|
502
519
|
await this.orgLock.lockAndAuthorize(orgId, actorAccountId, "channels.manage");
|
|
503
520
|
const r = await this.db
|
|
504
521
|
.updateTable("channel_connections")
|
|
@@ -516,6 +533,7 @@ let ChannelConnections = class ChannelConnections {
|
|
|
516
533
|
orgId,
|
|
517
534
|
action: "channel.deleted",
|
|
518
535
|
target: id,
|
|
536
|
+
...(auditDetail !== undefined && { detail: auditDetail }),
|
|
519
537
|
});
|
|
520
538
|
}
|
|
521
539
|
/** 提交后广播;失败只记日志(持有方每轮续租时也会复核连接状态)。 */
|