@capybara-hq/kernel 0.1.0-rc.5 → 0.1.0-rc.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/bootstrap.json +27 -3
- package/dist/admin/admin.controller.d.ts +21 -74
- package/dist/admin/admin.controller.js +50 -50
- package/dist/admin/admin.schemas.d.ts +57 -0
- package/dist/admin/admin.schemas.js +50 -0
- package/dist/admin/extensions.controller.d.ts +10 -0
- package/dist/admin/extensions.controller.js +18 -0
- package/dist/admin/extensions.schemas.d.ts +7 -0
- package/dist/admin/extensions.schemas.js +10 -0
- package/dist/admin/limit-defaults.d.ts +20 -0
- package/dist/admin/limit-defaults.js +10 -0
- package/dist/agents/agent-profile.service.d.ts +7 -5
- package/dist/agents/agent-profile.service.js +14 -9
- package/dist/agents/agents.controller.d.ts +7 -287
- package/dist/agents/agents.controller.js +7 -67
- package/dist/agents/agents.schemas.d.ts +389 -0
- package/dist/agents/agents.schemas.js +126 -0
- package/dist/agents/agents.service.d.ts +16 -6
- package/dist/agents/agents.service.js +75 -19
- package/dist/agents/definition.d.ts +47 -19
- package/dist/agents/definition.js +119 -38
- package/dist/agents/from-template.d.ts +2 -2
- package/dist/agents/from-template.js +76 -45
- package/dist/agents/from-template.service.d.ts +12 -0
- package/dist/agents/from-template.service.js +23 -6
- package/dist/agents/models.controller.d.ts +33 -5
- package/dist/agents/models.controller.js +50 -6
- package/dist/agents/org-templates.d.ts +13 -3
- package/dist/agents/org-templates.js +69 -28
- package/dist/agents/pending-connector-requests.d.ts +2 -0
- package/dist/agents/pending-connector-requests.js +1 -1
- package/dist/agents/pending-connectors.controller.d.ts +1 -1
- package/dist/agents/pending-connectors.controller.js +2 -2
- package/dist/agents/pending-connectors.service.d.ts +2 -2
- package/dist/agents/pending-connectors.service.js +19 -19
- package/dist/agents/profile.d.ts +18 -0
- package/dist/agents/profile.js +5 -1
- package/dist/agents/readiness.controller.d.ts +5 -5
- package/dist/agents/readiness.controller.js +6 -6
- package/dist/agents/templates.controller.d.ts +8 -17
- package/dist/agents/templates.controller.js +13 -31
- package/dist/agents/templates.schemas.d.ts +20 -0
- package/dist/agents/templates.schemas.js +45 -0
- package/dist/background/background.controller.js +3 -2
- package/dist/background/background.schemas.d.ts +10 -0
- package/dist/background/background.schemas.js +16 -0
- package/dist/background/tasks.service.d.ts +1 -1
- package/dist/background/tasks.service.js +7 -2
- package/dist/catalog/admin-catalog.controller.d.ts +4 -57
- package/dist/catalog/admin-catalog.controller.js +8 -45
- package/dist/catalog/admin-catalog.schemas.d.ts +72 -0
- package/dist/catalog/admin-catalog.schemas.js +92 -0
- package/dist/catalog/catalog-content.d.ts +12 -2
- package/dist/catalog/catalog-scope.service.js +8 -2
- package/dist/catalog/catalog.service.d.ts +2 -0
- package/dist/catalog/catalog.service.js +3 -0
- package/dist/catalog/component-scope.controller.d.ts +3 -65
- package/dist/catalog/component-scope.controller.js +3 -56
- package/dist/catalog/component-scope.schemas.d.ts +114 -0
- package/dist/catalog/component-scope.schemas.js +97 -0
- package/dist/catalog/component-scope.service.d.ts +28 -4
- package/dist/catalog/component-scope.service.js +55 -3
- package/dist/catalog/component-state.d.ts +9 -2
- package/dist/catalog/component-state.js +22 -13
- package/dist/catalog/marketplaces.controller.d.ts +5 -35
- package/dist/catalog/marketplaces.controller.js +6 -34
- package/dist/catalog/marketplaces.schemas.d.ts +48 -0
- package/dist/catalog/marketplaces.schemas.js +53 -0
- package/dist/catalog/marketplaces.service.d.ts +15 -1
- package/dist/catalog/marketplaces.service.js +22 -1
- package/dist/catalog/org-catalog.controller.d.ts +6 -62
- package/dist/catalog/org-catalog.controller.js +12 -66
- package/dist/catalog/org-catalog.schemas.d.ts +79 -0
- package/dist/catalog/org-catalog.schemas.js +82 -0
- package/dist/catalog/org-catalog.service.d.ts +9 -2
- package/dist/catalog/org-catalog.service.js +38 -5
- package/dist/catalog/org-extension.controller.d.ts +1 -12
- package/dist/catalog/org-extension.controller.js +1 -10
- package/dist/catalog/org-extension.schemas.d.ts +15 -0
- package/dist/catalog/org-extension.schemas.js +22 -0
- package/dist/catalog/org-plugin-uploads.controller.d.ts +2 -19
- package/dist/catalog/org-plugin-uploads.controller.js +15 -28
- package/dist/catalog/org-plugin-uploads.schemas.d.ts +20 -0
- package/dist/catalog/org-plugin-uploads.schemas.js +32 -0
- package/dist/catalog/owned-items.d.ts +6 -2
- package/dist/catalog/owned-items.js +16 -4
- package/dist/catalog/platform-components.d.ts +2 -0
- package/dist/catalog/platform-components.js +2 -0
- package/dist/catalog/plugin-import.js +1 -0
- package/dist/catalog/plugin-install.js +1 -1
- package/dist/catalog/requests.service.d.ts +2 -1
- package/dist/catalog/requests.service.js +6 -2
- package/dist/channels/channels.schemas.d.ts +33 -0
- package/dist/channels/channels.schemas.js +34 -0
- package/dist/channels/connections.controller.d.ts +2 -29
- package/dist/channels/connections.controller.js +1 -23
- package/dist/channels/connections.service.d.ts +8 -2
- package/dist/channels/connections.service.js +23 -5
- package/dist/channels/inbound.js +4 -0
- package/dist/config/schema.d.ts +4 -0
- package/dist/config/schema.js +24 -0
- package/dist/conversations/conversations.controller.d.ts +16 -37
- package/dist/conversations/conversations.controller.js +16 -56
- package/dist/conversations/conversations.schemas.d.ts +52 -0
- package/dist/conversations/conversations.schemas.js +79 -0
- package/dist/conversations/conversations.service.d.ts +13 -4
- package/dist/conversations/conversations.service.js +32 -26
- package/dist/conversations/events.d.ts +80 -6
- package/dist/conversations/events.js +60 -5
- package/dist/conversations/message-context.d.ts +28 -0
- package/dist/conversations/message-context.js +56 -0
- package/dist/conversations/queue.d.ts +2 -1
- package/dist/conversations/queue.js +11 -2
- package/dist/ctx/create-ctx.d.ts +15 -1
- package/dist/ctx/create-ctx.js +23 -2
- package/dist/db/kernel-schema.d.ts +44 -0
- package/dist/environments/environments.schemas.d.ts +3 -0
- package/dist/environments/environments.schemas.js +14 -0
- package/dist/environments/environments.service.d.ts +16 -4
- package/dist/environments/environments.service.js +58 -13
- package/dist/errors.d.ts +6 -0
- package/dist/errors.js +6 -0
- package/dist/evals/evals.schemas.d.ts +110 -0
- package/dist/evals/evals.schemas.js +107 -0
- package/dist/evals/reconstruct.js +18 -11
- package/dist/evals/recorded-tools.d.ts +2 -1
- package/dist/evals/recorded-tools.js +11 -3
- package/dist/evals/run-replay.d.ts +8 -1
- package/dist/evals/run-replay.js +17 -2
- package/dist/evals/runs.controller.d.ts +2 -57
- package/dist/evals/runs.controller.js +1 -42
- package/dist/evals/runs.service.d.ts +8 -7
- package/dist/evals/runs.service.js +45 -30
- package/dist/evals/sets.controller.d.ts +2 -28
- package/dist/evals/sets.controller.js +1 -31
- package/dist/evals/sets.service.d.ts +7 -7
- package/dist/evals/sets.service.js +23 -17
- package/dist/evals/snapshot.d.ts +3 -2
- package/dist/evals/snapshot.js +17 -4
- package/dist/evals/step-replay.d.ts +2 -1
- package/dist/evals/step-replay.js +3 -2
- package/dist/extensions/admin-ops.d.ts +5 -3
- package/dist/extensions/admin-ops.js +17 -12
- package/dist/extensions/config-hash.d.ts +10 -0
- package/dist/extensions/config-hash.js +38 -0
- package/dist/extensions/deployment-config.d.ts +16 -1
- package/dist/extensions/deployment-config.js +83 -0
- package/dist/extensions/extensions.module.js +9 -12
- package/dist/extensions/host.d.ts +39 -12
- package/dist/extensions/host.js +129 -51
- package/dist/extensions/installs.d.ts +5 -0
- package/dist/extensions/installs.js +12 -0
- package/dist/extensions/org-config.d.ts +17 -2
- package/dist/extensions/org-config.js +23 -4
- package/dist/extensions/point-defaults.controller.d.ts +2 -8
- package/dist/extensions/point-defaults.controller.js +1 -3
- package/dist/extensions/point-defaults.d.ts +3 -1
- package/dist/extensions/point-defaults.js +4 -2
- package/dist/extensions/point-defaults.schemas.d.ts +9 -0
- package/dist/extensions/point-defaults.schemas.js +14 -0
- package/dist/extensions/state.module.d.ts +9 -0
- package/dist/extensions/state.module.js +38 -0
- package/dist/extensions/unavailable.d.ts +49 -0
- package/dist/extensions/unavailable.js +113 -0
- package/dist/files/previewers.controller.js +2 -3
- package/dist/files/previewers.d.ts +1 -1
- package/dist/files/previewers.js +4 -4
- package/dist/files/previewers.schemas.d.ts +10 -0
- package/dist/files/previewers.schemas.js +9 -0
- package/dist/http/api.module.js +4 -0
- package/dist/http/plugin-dispatch.d.ts +4 -1
- package/dist/http/plugin-dispatch.js +14 -2
- package/dist/identity/accounts.d.ts +43 -4
- package/dist/identity/accounts.js +74 -6
- package/dist/identity/auth.guard.js +10 -1
- package/dist/identity/cookies.d.ts +6 -0
- package/dist/identity/cookies.js +14 -0
- package/dist/identity/identity.module.js +3 -0
- package/dist/identity/initial-passwords.controller.d.ts +22 -0
- package/dist/identity/initial-passwords.controller.js +49 -0
- package/dist/identity/initial-passwords.d.ts +61 -0
- package/dist/identity/initial-passwords.job.d.ts +16 -0
- package/dist/identity/initial-passwords.job.js +46 -0
- package/dist/identity/initial-passwords.js +159 -0
- package/dist/identity/me.controller.d.ts +14 -0
- package/dist/identity/me.controller.js +39 -1
- package/dist/identity/principal.d.ts +8 -0
- package/dist/identity/principal.js +8 -0
- package/dist/identity/settings.d.ts +3 -1
- package/dist/identity/settings.js +6 -4
- package/dist/inbox/inbox.schemas.d.ts +8 -0
- package/dist/inbox/inbox.schemas.js +11 -0
- package/dist/inbox/platform-inbox.controller.d.ts +1 -1
- package/dist/inbox/platform-inbox.controller.js +2 -2
- package/dist/index.d.ts +4 -0
- package/dist/index.js +6 -0
- package/dist/infra/config/kernel-config.service.js +3 -0
- package/dist/infra/events/kernel-events.d.ts +8 -0
- package/dist/lifecycle/kernel-lifecycle.js +4 -0
- package/dist/models/embeddings.d.ts +82 -0
- package/dist/models/embeddings.js +326 -0
- package/dist/models/enablement.controller.d.ts +40 -0
- package/dist/models/enablement.controller.js +74 -0
- package/dist/models/enablement.d.ts +101 -0
- package/dist/models/enablement.js +264 -0
- package/dist/models/models.module.d.ts +5 -1
- package/dist/models/models.module.js +16 -4
- package/dist/models/org-models.schemas.d.ts +8 -0
- package/dist/models/org-models.schemas.js +22 -0
- package/dist/models/prices.d.ts +3 -1
- package/dist/models/prices.js +7 -5
- package/dist/models/purposes.d.ts +30 -6
- package/dist/models/purposes.js +68 -17
- package/dist/orgs/orgs.controller.d.ts +2 -5
- package/dist/orgs/orgs.controller.js +3 -6
- package/dist/orgs/orgs.schemas.d.ts +8 -0
- package/dist/orgs/orgs.schemas.js +16 -0
- package/dist/orgs/orgs.service.d.ts +3 -1
- package/dist/orgs/orgs.service.js +6 -4
- package/dist/orgs/settings.service.d.ts +9 -1
- package/dist/orgs/settings.service.js +20 -5
- package/dist/overrides.d.ts +4 -0
- package/dist/overrides.js +2 -0
- package/dist/platform/errors.d.ts +21 -4
- package/dist/platform/errors.js +45 -6
- package/dist/platform/exclusions.d.ts +2 -3
- package/dist/platform/exclusions.js +68 -831
- package/dist/platform/method.js +1 -1
- package/dist/platform/operation.d.ts +82 -5
- package/dist/platform/operation.js +62 -7
- package/dist/platform/ops/accounts.ops.d.ts +32 -0
- package/dist/platform/ops/accounts.ops.js +291 -0
- package/dist/platform/ops/admin.ops.d.ts +36 -0
- package/dist/platform/ops/admin.ops.js +389 -0
- package/dist/platform/ops/agent-skills.ops.d.ts +24 -0
- package/dist/platform/ops/agent-skills.ops.js +226 -0
- package/dist/platform/ops/agent-templates.ops.d.ts +4 -1
- package/dist/platform/ops/agent-templates.ops.js +194 -14
- package/dist/platform/ops/agents.ops.d.ts +19 -1
- package/dist/platform/ops/agents.ops.js +481 -58
- package/dist/platform/ops/approvals.ops.d.ts +30 -0
- package/dist/platform/ops/approvals.ops.js +116 -0
- package/dist/platform/ops/background.ops.d.ts +14 -0
- package/dist/platform/ops/background.ops.js +134 -0
- package/dist/platform/ops/catalog-admin.ops.d.ts +74 -0
- package/dist/platform/ops/catalog-admin.ops.js +587 -0
- package/dist/platform/ops/channels.ops.d.ts +16 -0
- package/dist/platform/ops/channels.ops.js +195 -0
- package/dist/platform/ops/components.ops.d.ts +46 -0
- package/dist/platform/ops/components.ops.js +853 -0
- package/dist/platform/ops/connectors.ops.d.ts +4 -2
- package/dist/platform/ops/connectors.ops.js +68 -6
- package/dist/platform/ops/conversations.ops.d.ts +30 -0
- package/dist/platform/ops/conversations.ops.js +470 -0
- package/dist/platform/ops/environments.ops.d.ts +26 -0
- package/dist/platform/ops/environments.ops.js +289 -0
- package/dist/platform/ops/errors.d.ts +10 -5
- package/dist/platform/ops/errors.js +19 -11
- package/dist/platform/ops/evals.ops.d.ts +28 -0
- package/dist/platform/ops/evals.ops.js +783 -0
- package/dist/platform/ops/extensions-admin.ops.d.ts +25 -0
- package/dist/platform/ops/extensions-admin.ops.js +344 -0
- package/dist/platform/ops/extensions.ops.d.ts +7 -1
- package/dist/platform/ops/extensions.ops.js +248 -17
- package/dist/platform/ops/inbox.ops.d.ts +25 -0
- package/dist/platform/ops/inbox.ops.js +378 -0
- package/dist/platform/ops/marketplaces.ops.d.ts +7 -1
- package/dist/platform/ops/marketplaces.ops.js +326 -17
- package/dist/platform/ops/models.ops.d.ts +25 -0
- package/dist/platform/ops/models.ops.js +232 -0
- package/dist/platform/ops/org-plugins.ops.d.ts +29 -0
- package/dist/platform/ops/org-plugins.ops.js +329 -0
- package/dist/platform/ops/org-settings.ops.d.ts +16 -0
- package/dist/platform/ops/org-settings.ops.js +102 -0
- package/dist/platform/ops/orgs.ops.d.ts +28 -0
- package/dist/platform/ops/orgs.ops.js +295 -0
- package/dist/platform/ops/other-orgs.d.ts +20 -0
- package/dist/platform/ops/other-orgs.js +72 -0
- package/dist/platform/ops/platform.ops.d.ts +4 -4
- package/dist/platform/ops/platform.ops.js +23 -24
- package/dist/platform/ops/plugins.ops.d.ts +10 -8
- package/dist/platform/ops/plugins.ops.js +176 -77
- package/dist/platform/ops/previewers.ops.d.ts +14 -0
- package/dist/platform/ops/previewers.ops.js +109 -0
- package/dist/platform/ops/requests.ops.js +57 -19
- package/dist/platform/ops/skills.ops.d.ts +5 -1
- package/dist/platform/ops/skills.ops.js +129 -11
- package/dist/platform/ops/unavailable.d.ts +23 -0
- package/dist/platform/ops/unavailable.js +111 -0
- package/dist/platform/parity.d.ts +33 -0
- package/dist/platform/parity.js +272 -0
- package/dist/platform/platform-ops.module.d.ts +32 -0
- package/dist/platform/platform-ops.module.js +78 -11
- package/dist/platform/route-schemas.d.ts +18 -0
- package/dist/platform/route-schemas.js +60 -0
- package/dist/roles/worker.module.js +2 -0
- package/dist/runtime/context/build.d.ts +2 -0
- package/dist/runtime/context/build.js +28 -2
- package/dist/runtime/context/compaction.js +10 -1
- package/dist/runtime/context/run-context.d.ts +65 -0
- package/dist/runtime/context/run-context.js +215 -0
- package/dist/runtime/hook-calls.d.ts +8 -1
- package/dist/runtime/hook-calls.js +40 -9
- package/dist/runtime/model-call.d.ts +8 -3
- package/dist/runtime/model-call.js +30 -6
- package/dist/runtime/providers.d.ts +146 -32
- package/dist/runtime/providers.js +328 -67
- package/dist/runtime/run-context.service.d.ts +65 -0
- package/dist/runtime/run-context.service.js +220 -0
- package/dist/runtime/run-worker.d.ts +6 -1
- package/dist/runtime/run-worker.js +35 -10
- package/dist/runtime/runtime.module.js +2 -0
- package/dist/runtime/subagents/definition.d.ts +15 -15
- package/dist/runtime/subagents/definition.js +49 -118
- package/dist/runtime/usage-report-jobs.d.ts +88 -0
- package/dist/runtime/usage-report-jobs.js +158 -0
- package/dist/runtime/usage-report.d.ts +33 -38
- package/dist/runtime/usage-report.js +152 -84
- package/dist/skills/changes.controller.js +2 -1
- package/dist/skills/changes.service.d.ts +1 -1
- package/dist/skills/changes.service.js +4 -4
- package/dist/skills/invocable.controller.d.ts +1 -1
- package/dist/skills/invocable.controller.js +2 -2
- package/dist/skills/invoke.d.ts +2 -2
- package/dist/skills/invoke.js +8 -1
- package/dist/skills/skills.controller.d.ts +4 -13
- package/dist/skills/skills.controller.js +8 -24
- package/dist/skills/skills.schemas.d.ts +48 -0
- package/dist/skills/skills.schemas.js +61 -0
- package/dist/skills/skills.service.d.ts +11 -1
- package/dist/skills/skills.service.js +37 -14
- package/dist/time-zone.d.ts +5 -0
- package/dist/time-zone.js +19 -0
- package/dist/tools/approvals.controller.js +2 -3
- package/dist/tools/approvals.schemas.d.ts +21 -0
- package/dist/tools/approvals.schemas.js +15 -0
- package/dist/tools/builtin-names.d.ts +10 -8
- package/dist/tools/builtin-names.js +16 -11
- package/dist/tools/builtins/builtin-tools.d.ts +3 -1
- package/dist/tools/builtins/builtin-tools.js +15 -3
- package/dist/tools/builtins/current-time.d.ts +26 -0
- package/dist/tools/builtins/current-time.js +99 -0
- package/dist/tools/builtins/platform.d.ts +19 -2
- package/dist/tools/builtins/platform.js +105 -16
- package/dist/tools/connectors.controller.d.ts +1 -2
- package/dist/tools/connectors.controller.js +1 -4
- package/dist/tools/connectors.schemas.d.ts +12 -0
- package/dist/tools/connectors.schemas.js +19 -0
- package/dist/tools/connectors.service.d.ts +5 -2
- package/dist/tools/connectors.service.js +7 -5
- package/dist/tools/org-tool-switches.d.ts +16 -2
- package/dist/tools/org-tool-switches.js +26 -9
- package/dist/tools/pipeline.js +9 -1
- package/dist/tools/registry.d.ts +48 -51
- package/dist/tools/registry.js +222 -233
- package/package.json +3 -3
- package/src/migrations/0089_model_kinds_usage.sql +38 -0
- package/src/migrations/0090_initial_passwords.sql +27 -0
- package/src/migrations/0091_account_time_zone.sql +4 -0
- package/src/migrations/0092_tools_default_on.sql +27 -0
- package/dist/platform/redact-orgs.d.ts +0 -7
- package/dist/platform/redact-orgs.js +0 -52
|
@@ -12,21 +12,29 @@ import { z } from "zod";
|
|
|
12
12
|
import { AgentsService } from "../../agents/agents.service.js";
|
|
13
13
|
import { OrgAgentTemplates } from "../../agents/org-templates.js";
|
|
14
14
|
import { AgentTemplatesService } from "../../agents/templates.js";
|
|
15
|
+
import { AgentTemplateIdParams, AgentTemplateShareableBody, AgentTemplateUpdateBody, SaveAsAgentIdParams, SaveAsTemplateBody, } from "../../agents/templates.schemas.js";
|
|
16
|
+
import { OwnedItems } from "../../catalog/owned-items.js";
|
|
15
17
|
import { defineOperation } from "../operation.js";
|
|
16
18
|
import { PlatformOperations } from "../registry.js";
|
|
17
|
-
import {
|
|
19
|
+
import { precheckBy, viaAgent } from "./errors.js";
|
|
18
20
|
import { named, orElse } from "./summary.js";
|
|
21
|
+
const TemplateId = AgentTemplateIdParams.shape.id;
|
|
19
22
|
/** Agent template operations of the `Platform` tool (spec §7). */
|
|
20
23
|
let AgentTemplatesOperations = class AgentTemplatesOperations {
|
|
21
24
|
registry;
|
|
22
25
|
templates;
|
|
23
26
|
orgTemplates;
|
|
24
27
|
agents;
|
|
25
|
-
|
|
28
|
+
owned;
|
|
29
|
+
constructor(registry, templates, orgTemplates, agents, owned) {
|
|
26
30
|
this.registry = registry;
|
|
27
31
|
this.templates = templates;
|
|
28
32
|
this.orgTemplates = orgTemplates;
|
|
29
33
|
this.agents = agents;
|
|
34
|
+
this.owned = owned;
|
|
35
|
+
}
|
|
36
|
+
templateName(ctx, id) {
|
|
37
|
+
return orElse(async () => named((await this.orgTemplates.detail(ctx.orgId, id)).name), id);
|
|
30
38
|
}
|
|
31
39
|
onModuleInit() {
|
|
32
40
|
this.registry.register([
|
|
@@ -43,25 +51,23 @@ let AgentTemplatesOperations = class AgentTemplatesOperations {
|
|
|
43
51
|
defineOperation({
|
|
44
52
|
id: "agent-templates.get",
|
|
45
53
|
description: "Read one agent template with its definition (model tier, tools, skills, connectors it needs). Takes the template id from agent-templates.list.",
|
|
46
|
-
input: z.object({ templateId:
|
|
54
|
+
input: z.object({ templateId: AgentTemplateIdParams.shape.id }).strict(),
|
|
47
55
|
example: { templateId: "5d0c7a52-3a0e-4f0a-bd0a-0f8c3d2a9e10" },
|
|
48
56
|
authz: { orgAction: "agents.create" },
|
|
49
57
|
mirrors: ["GET /api/v1/orgs/:orgId/agent-templates/:id"],
|
|
58
|
+
renames: { templateId: "id" },
|
|
50
59
|
confirm: "read",
|
|
51
|
-
run: async (input, ctx) =>
|
|
60
|
+
run: async (input, ctx) => ({
|
|
52
61
|
template: await this.orgTemplates.detail(ctx.orgId, input.templateId),
|
|
53
|
-
})
|
|
62
|
+
}),
|
|
54
63
|
}),
|
|
55
64
|
defineOperation({
|
|
56
65
|
id: "agent-templates.save",
|
|
57
66
|
description: "Save an agent of the org as an org agent template under a new name, so members can create their own copy from it. Credentials and per-person settings are not carried over; the result lists what was omitted.",
|
|
58
|
-
input:
|
|
59
|
-
.
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
description: z.string().min(1).max(1024),
|
|
63
|
-
})
|
|
64
|
-
.strict(),
|
|
67
|
+
input: SaveAsAgentIdParams.extend({
|
|
68
|
+
name: SaveAsTemplateBody.shape.name.min(1).max(80),
|
|
69
|
+
description: SaveAsTemplateBody.shape.description.max(1024),
|
|
70
|
+
}).strict(),
|
|
65
71
|
example: {
|
|
66
72
|
agentId: "7c1a5b0e-9a53-4c6b-8d64-2f5a1b0c3e77",
|
|
67
73
|
name: "support-triage",
|
|
@@ -77,7 +83,180 @@ let AgentTemplatesOperations = class AgentTemplatesOperations {
|
|
|
77
83
|
en: `Save agent "${source}" as org template "${named(i.name)}"`,
|
|
78
84
|
};
|
|
79
85
|
},
|
|
80
|
-
run: async (input, ctx) =>
|
|
86
|
+
run: async (input, ctx) => this.orgTemplates.saveAs(ctx.orgId, ctx.actorAccountId, input.agentId, { name: input.name, description: input.description }, undefined, viaAgent("agent-templates.save", ctx)),
|
|
87
|
+
}),
|
|
88
|
+
defineOperation({
|
|
89
|
+
id: "agent-templates.update",
|
|
90
|
+
description: "Save a new version of an org agent template (org admins): send the whole definition as agent-templates.get returned it, changed as wanted, and the version you read. The name cannot change. Agents already created from the template keep their definition. A version that is no longer current is refused: read the template again first.",
|
|
91
|
+
input: z
|
|
92
|
+
.object({
|
|
93
|
+
templateId: TemplateId,
|
|
94
|
+
version: AgentTemplateUpdateBody.shape.expectedVersion,
|
|
95
|
+
definition: z
|
|
96
|
+
.record(z.string().max(200), z.unknown())
|
|
97
|
+
.refine((v) => JSON.stringify(v).length <= 500_000, {
|
|
98
|
+
message: "The definition is too large",
|
|
99
|
+
}),
|
|
100
|
+
})
|
|
101
|
+
.strict(),
|
|
102
|
+
example: {
|
|
103
|
+
templateId: "5d0c7a52-3a0e-4f0a-bd0a-0f8c3d2a9e10",
|
|
104
|
+
version: 2,
|
|
105
|
+
definition: { name: "support-triage", description: "Triages support requests." },
|
|
106
|
+
},
|
|
107
|
+
authz: { orgAction: "agents.manage" },
|
|
108
|
+
mirrors: ["PUT /api/v1/orgs/:orgId/agent-templates/:id"],
|
|
109
|
+
renames: { templateId: "id", version: "expectedVersion" },
|
|
110
|
+
confirm: "org",
|
|
111
|
+
errors: [
|
|
112
|
+
{
|
|
113
|
+
code: "agent_template.version_conflict",
|
|
114
|
+
next: "The template changed since you read it: read it again with agent-templates.get, then send its current version.",
|
|
115
|
+
},
|
|
116
|
+
{
|
|
117
|
+
code: "catalog.not_owned",
|
|
118
|
+
next: "Only an agent template the org created can be changed here; a plugin's template or a copy of another owner's is not the org's to change.",
|
|
119
|
+
},
|
|
120
|
+
{
|
|
121
|
+
code: "component.not_found",
|
|
122
|
+
next: "Check the template id with agent-templates.list; this org cannot use that template.",
|
|
123
|
+
},
|
|
124
|
+
{
|
|
125
|
+
code: "validation_failed",
|
|
126
|
+
next: "The definition is not a valid agent template, or its name changed; fix it as the message says.",
|
|
127
|
+
},
|
|
128
|
+
],
|
|
129
|
+
precheck: async (i, ctx) => {
|
|
130
|
+
const found = await precheckBy(() => this.orgTemplates.detail(ctx.orgId, i.templateId));
|
|
131
|
+
if (!found.ok)
|
|
132
|
+
return found;
|
|
133
|
+
const t = await this.orgTemplates.detail(ctx.orgId, i.templateId);
|
|
134
|
+
return t.owned
|
|
135
|
+
? { ok: true }
|
|
136
|
+
: {
|
|
137
|
+
ok: false,
|
|
138
|
+
code: "catalog.not_owned",
|
|
139
|
+
message: "The org does not own this template",
|
|
140
|
+
};
|
|
141
|
+
},
|
|
142
|
+
summary: async (i, ctx) => {
|
|
143
|
+
const n = await this.templateName(ctx, i.templateId);
|
|
144
|
+
return {
|
|
145
|
+
zh: `保存组织智能体模板「${n}」的新版本(基于版本 ${i.version})`,
|
|
146
|
+
en: `Save a new version of org agent template "${n}" (from version ${i.version})`,
|
|
147
|
+
};
|
|
148
|
+
},
|
|
149
|
+
run: async (input, ctx) => ({
|
|
150
|
+
template: await this.orgTemplates.update(ctx.orgId, ctx.actorAccountId, input.templateId, { definition: input.definition, expectedVersion: input.version }, undefined, viaAgent("agent-templates.update", ctx)),
|
|
151
|
+
}),
|
|
152
|
+
}),
|
|
153
|
+
defineOperation({
|
|
154
|
+
id: "agent-templates.delete-preview",
|
|
155
|
+
description: "Preview deleting an org agent template (org admins): whether it is removed or handed to the platform because another org uses it, and which of the org's agents were created from it. Show it to the person before agent-templates.delete.",
|
|
156
|
+
input: z.object({ templateId: TemplateId }).strict(),
|
|
157
|
+
example: { templateId: "5d0c7a52-3a0e-4f0a-bd0a-0f8c3d2a9e10" },
|
|
158
|
+
authz: { orgAction: "agents.manage" },
|
|
159
|
+
mirrors: ["GET /api/v1/orgs/:orgId/agent-templates/:id/delete-preview"],
|
|
160
|
+
renames: { templateId: "id" },
|
|
161
|
+
confirm: "read",
|
|
162
|
+
errors: [
|
|
163
|
+
{
|
|
164
|
+
code: "catalog.not_owned",
|
|
165
|
+
next: "Only an agent template the org created can be changed here; a plugin's template or a copy of another owner's is not the org's to change.",
|
|
166
|
+
},
|
|
167
|
+
{
|
|
168
|
+
code: "component.not_found",
|
|
169
|
+
next: "Check the template id with agent-templates.list; this org cannot use that template.",
|
|
170
|
+
},
|
|
171
|
+
],
|
|
172
|
+
run: async (input, ctx) => ({
|
|
173
|
+
preview: await this.owned.previewAgentTemplateDelete(ctx.orgId, input.templateId),
|
|
174
|
+
}),
|
|
175
|
+
}),
|
|
176
|
+
defineOperation({
|
|
177
|
+
id: "agent-templates.delete",
|
|
178
|
+
description: "Delete an org agent template (org admins). A template another org uses is handed to the platform instead of removed; agents created from it keep working. Read agent-templates.delete-preview first and show it to the person.",
|
|
179
|
+
input: z.object({ templateId: TemplateId }).strict(),
|
|
180
|
+
example: { templateId: "5d0c7a52-3a0e-4f0a-bd0a-0f8c3d2a9e10" },
|
|
181
|
+
authz: { orgAction: "agents.manage" },
|
|
182
|
+
mirrors: ["DELETE /api/v1/orgs/:orgId/agent-templates/:id"],
|
|
183
|
+
renames: { templateId: "id" },
|
|
184
|
+
confirm: "org",
|
|
185
|
+
errors: [
|
|
186
|
+
{
|
|
187
|
+
code: "catalog.not_owned",
|
|
188
|
+
next: "Only an agent template the org created can be changed here; a plugin's template or a copy of another owner's is not the org's to change.",
|
|
189
|
+
},
|
|
190
|
+
{
|
|
191
|
+
code: "component.not_found",
|
|
192
|
+
next: "Check the template id with agent-templates.list; this org cannot use that template.",
|
|
193
|
+
},
|
|
194
|
+
],
|
|
195
|
+
precheck: (i, ctx) => precheckBy(() => this.owned.previewAgentTemplateDelete(ctx.orgId, i.templateId)),
|
|
196
|
+
summary: async (i, ctx) => {
|
|
197
|
+
const n = await this.templateName(ctx, i.templateId);
|
|
198
|
+
const p = await orElse(() => this.owned.previewAgentTemplateDelete(ctx.orgId, i.templateId), null);
|
|
199
|
+
const handed = p?.outcome === "transferred";
|
|
200
|
+
return {
|
|
201
|
+
zh: `删除组织智能体模板「${n}」${handed ? ";其他组织在用,将转为平台模板" : ""}`,
|
|
202
|
+
en: `Delete org agent template "${n}"${handed ? "; another org uses it, so it becomes a platform template" : ""}`,
|
|
203
|
+
};
|
|
204
|
+
},
|
|
205
|
+
run: async (input, ctx) => ({
|
|
206
|
+
id: input.templateId,
|
|
207
|
+
outcome: await this.owned.deleteAgentTemplate(ctx.orgId, ctx.actorAccountId, input.templateId, { auditDetail: viaAgent("agent-templates.delete", ctx) }),
|
|
208
|
+
}),
|
|
209
|
+
}),
|
|
210
|
+
defineOperation({
|
|
211
|
+
id: "agent-templates.set-shareable",
|
|
212
|
+
description: "Set whether an org agent template may be shared with other orgs (org admins). Only the org's own templates can be changed; a plugin's template cannot.",
|
|
213
|
+
input: z
|
|
214
|
+
.object({ templateId: TemplateId, shareable: AgentTemplateShareableBody.shape.shareable })
|
|
215
|
+
.strict(),
|
|
216
|
+
example: { templateId: "5d0c7a52-3a0e-4f0a-bd0a-0f8c3d2a9e10", shareable: true },
|
|
217
|
+
authz: { orgAction: "agents.manage" },
|
|
218
|
+
mirrors: ["PUT /api/v1/orgs/:orgId/agent-templates/:id/shareable"],
|
|
219
|
+
renames: { templateId: "id" },
|
|
220
|
+
confirm: "org",
|
|
221
|
+
errors: [
|
|
222
|
+
{
|
|
223
|
+
code: "catalog.not_owned",
|
|
224
|
+
next: "Only an agent template the org created can be changed here; a plugin's template or a copy of another owner's is not the org's to change.",
|
|
225
|
+
},
|
|
226
|
+
{
|
|
227
|
+
code: "component.not_found",
|
|
228
|
+
next: "Check the template id with agent-templates.list; this org cannot use that template.",
|
|
229
|
+
},
|
|
230
|
+
],
|
|
231
|
+
precheck: async (i, ctx) => {
|
|
232
|
+
const found = await precheckBy(() => this.orgTemplates.detail(ctx.orgId, i.templateId));
|
|
233
|
+
if (!found.ok)
|
|
234
|
+
return found;
|
|
235
|
+
const t = await this.orgTemplates.detail(ctx.orgId, i.templateId);
|
|
236
|
+
return t.owned
|
|
237
|
+
? { ok: true }
|
|
238
|
+
: {
|
|
239
|
+
ok: false,
|
|
240
|
+
code: "catalog.not_owned",
|
|
241
|
+
message: "The org does not own this template",
|
|
242
|
+
};
|
|
243
|
+
},
|
|
244
|
+
summary: async (i, ctx) => {
|
|
245
|
+
const n = await this.templateName(ctx, i.templateId);
|
|
246
|
+
return i.shareable
|
|
247
|
+
? {
|
|
248
|
+
zh: `允许把组织智能体模板「${n}」共享给其他组织`,
|
|
249
|
+
en: `Allow org agent template "${n}" to be shared with other orgs`,
|
|
250
|
+
}
|
|
251
|
+
: {
|
|
252
|
+
zh: `不再把组织智能体模板「${n}」共享给其他组织`,
|
|
253
|
+
en: `Stop sharing org agent template "${n}" with other orgs`,
|
|
254
|
+
};
|
|
255
|
+
},
|
|
256
|
+
run: async (input, ctx) => {
|
|
257
|
+
await this.owned.setShareable(ctx.orgId, ctx.actorAccountId, { kind: "agent_template", id: input.templateId }, input.shareable, { auditDetail: viaAgent("agent-templates.set-shareable", ctx) });
|
|
258
|
+
return { id: input.templateId, shareable: input.shareable };
|
|
259
|
+
},
|
|
81
260
|
}),
|
|
82
261
|
]);
|
|
83
262
|
}
|
|
@@ -87,6 +266,7 @@ AgentTemplatesOperations = __decorate([
|
|
|
87
266
|
__param(0, Inject(PlatformOperations)),
|
|
88
267
|
__param(1, Inject(AgentTemplatesService)),
|
|
89
268
|
__param(2, Inject(OrgAgentTemplates)),
|
|
90
|
-
__param(3, Inject(AgentsService))
|
|
269
|
+
__param(3, Inject(AgentsService)),
|
|
270
|
+
__param(4, Inject(OwnedItems))
|
|
91
271
|
], AgentTemplatesOperations);
|
|
92
272
|
export { AgentTemplatesOperations };
|
|
@@ -1,15 +1,33 @@
|
|
|
1
1
|
import { type OnModuleInit } from "@nestjs/common";
|
|
2
|
+
import { AgentProfileService } from "../../agents/agent-profile.service.js";
|
|
2
3
|
import { AgentsService } from "../../agents/agents.service.js";
|
|
3
4
|
import { AgentsFromTemplate } from "../../agents/from-template.service.js";
|
|
4
5
|
import { OrgAgentTemplates } from "../../agents/org-templates.js";
|
|
6
|
+
import { PendingConnectorsService } from "../../agents/pending-connectors.service.js";
|
|
7
|
+
import { CatalogRequestsService } from "../../catalog/requests.service.js";
|
|
8
|
+
import { KernelDb } from "../../infra/database/kernel-db.js";
|
|
9
|
+
import { ProviderRegistry } from "../../runtime/providers.js";
|
|
10
|
+
import { ConnectorsService } from "../../tools/connectors.service.js";
|
|
5
11
|
import { PlatformOperations } from "../registry.js";
|
|
6
12
|
/** Agent operations of the `Platform` tool (spec §7); visibility is the person's own agents. */
|
|
7
13
|
export declare class AgentsOperations implements OnModuleInit {
|
|
8
14
|
private readonly registry;
|
|
9
15
|
private readonly agents;
|
|
16
|
+
private readonly profiles;
|
|
10
17
|
private readonly fromTemplate;
|
|
11
18
|
private readonly orgTemplates;
|
|
12
|
-
|
|
19
|
+
private readonly pending;
|
|
20
|
+
private readonly requests;
|
|
21
|
+
private readonly connectors;
|
|
22
|
+
private readonly providers;
|
|
23
|
+
private readonly kdb;
|
|
24
|
+
constructor(registry: PlatformOperations, agents: AgentsService, profiles: AgentProfileService, fromTemplate: AgentsFromTemplate, orgTemplates: OrgAgentTemplates, pending: PendingConnectorsService, requests: CatalogRequestsService, connectors: ConnectorsService, providers: ProviderRegistry, kdb: KernelDb);
|
|
25
|
+
/**
|
|
26
|
+
* The edit rule the service enforces, read before the card: the agent is visible, and the actor
|
|
27
|
+
* owns it or is an org admin. Returns the agent too for the checks that follow.
|
|
28
|
+
*/
|
|
29
|
+
private editCheck;
|
|
30
|
+
private agentName;
|
|
13
31
|
/**
|
|
14
32
|
* `agents.update`'s class (spec §13): `personal` (may be remembered) only on a private agent the
|
|
15
33
|
* actor owns; any other agent the actor may edit is shared, so each change is confirmed.
|