@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
|
@@ -122,7 +122,7 @@ let PendingConnectorRequests = class PendingConnectorRequests {
|
|
|
122
122
|
orgId: a.orgId,
|
|
123
123
|
action: "catalog.requested",
|
|
124
124
|
target: id,
|
|
125
|
-
detail: { kind: "connector_setup", agentId: a.agentId, keys },
|
|
125
|
+
detail: { kind: "connector_setup", agentId: a.agentId, keys, ...a.auditDetail },
|
|
126
126
|
});
|
|
127
127
|
return { id, created: true };
|
|
128
128
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { FastifyReply } from "fastify";
|
|
2
|
-
import { z } from "zod";
|
|
2
|
+
import type { z } from "zod";
|
|
3
3
|
import { CatalogRequestsService, type CatalogRequestView } from "../catalog/requests.service.js";
|
|
4
4
|
import { type Principal } from "../identity/principal.js";
|
|
5
5
|
import { type OrgContext } from "../orgs/org.guard.js";
|
|
@@ -8,15 +8,15 @@ var __param = (this && this.__param) || function (paramIndex, decorator) {
|
|
|
8
8
|
return function (target, key) { decorator(target, key, paramIndex); }
|
|
9
9
|
};
|
|
10
10
|
import { Controller, Get, HttpCode, Inject, Param, Post, Res } from "@nestjs/common";
|
|
11
|
-
import { z } from "zod";
|
|
12
11
|
import { CatalogRequestsService } from "../catalog/requests.service.js";
|
|
13
12
|
import { CurrentPrincipal, patTokenId, requireUser, } from "../identity/principal.js";
|
|
14
13
|
import { createZodDto } from "../infra/validation/create-zod-dto.js";
|
|
15
14
|
import { ZBody } from "../infra/validation/zod-params.js";
|
|
16
15
|
import { CurrentOrg, OrgAction } from "../orgs/org.guard.js";
|
|
16
|
+
import { PendingConnectorBindBody as BindBodySchema } from "./agents.schemas.js";
|
|
17
17
|
import { AgentsService } from "./agents.service.js";
|
|
18
18
|
import { PendingConnectorsService } from "./pending-connectors.service.js";
|
|
19
|
-
const BindBody =
|
|
19
|
+
const BindBody = BindBodySchema;
|
|
20
20
|
class PendingConnectorBindBody extends createZodDto(BindBody, "PendingConnectorBindBody") {
|
|
21
21
|
}
|
|
22
22
|
/**
|
|
@@ -41,14 +41,14 @@ export declare class PendingConnectorsService {
|
|
|
41
41
|
* authorized) or none of the entry's tools -> 400 `agent.pending_connector_mismatch`.
|
|
42
42
|
* Audits `agent.pending_connector_bound`.
|
|
43
43
|
*/
|
|
44
|
-
bind(orgId: string, agentId: string, key: string, connectorId: string, actor: string, actorTokenId?: string): Promise<BindResult>;
|
|
44
|
+
bind(orgId: string, agentId: string, key: string, connectorId: string, actor: string, actorTokenId?: string, auditDetail?: Record<string, unknown>): Promise<BindResult>;
|
|
45
45
|
/**
|
|
46
46
|
* (Re-)opens the agent's connector setup request (ruling P4-T6-7; the owner or an org admin+):
|
|
47
47
|
* the pending one when it has one (`created` false), else a new one for the current pending
|
|
48
48
|
* keys, requested by the agent's owner (P4-T6-4). No pending connectors -> 409
|
|
49
49
|
* `agent.no_pending_connectors`.
|
|
50
50
|
*/
|
|
51
|
-
reopen(orgId: string, agentId: string, actor: string, actorTokenId?: string): Promise<{
|
|
51
|
+
reopen(orgId: string, agentId: string, actor: string, actorTokenId?: string, auditDetail?: Record<string, unknown>): Promise<{
|
|
52
52
|
id: string;
|
|
53
53
|
created: boolean;
|
|
54
54
|
}>;
|
|
@@ -18,7 +18,7 @@ import { Transactional } from "../infra/database/transactional.decorator.js";
|
|
|
18
18
|
import { roleAtLeast } from "../orgs/roles.js";
|
|
19
19
|
import { AgentLookup, isAgentVisibleTo } from "./agent-lookup.js";
|
|
20
20
|
import { AgentsService } from "./agents.service.js";
|
|
21
|
-
import { normalizeStoredDefinition, } from "./definition.js";
|
|
21
|
+
import { canonicalDisabledTools, normalizeStoredDefinition, } from "./definition.js";
|
|
22
22
|
import { PendingConnectorRequests } from "./pending-connector-requests.js";
|
|
23
23
|
const UUID_RE = /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i;
|
|
24
24
|
const RANK = { ask: 1, deny: 2 };
|
|
@@ -71,7 +71,7 @@ let PendingConnectorsService = class PendingConnectorsService {
|
|
|
71
71
|
* authorized) or none of the entry's tools -> 400 `agent.pending_connector_mismatch`.
|
|
72
72
|
* Audits `agent.pending_connector_bound`.
|
|
73
73
|
*/
|
|
74
|
-
async bind(orgId, agentId, key, connectorId, actor, actorTokenId) {
|
|
74
|
+
async bind(orgId, agentId, key, connectorId, actor, actorTokenId, auditDetail) {
|
|
75
75
|
const t = this.kdb.db;
|
|
76
76
|
const before = await this.agents.lockForWrite(orgId, agentId, actor);
|
|
77
77
|
const def = await this.currentDefinition(agentId, before.current_version);
|
|
@@ -137,25 +137,18 @@ let PendingConnectorsService = class PendingConnectorsService {
|
|
|
137
137
|
if (prev === undefined || RANK[p] > RANK[prev])
|
|
138
138
|
toolPolicies[k] = p;
|
|
139
139
|
}
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
return {
|
|
148
|
-
...r,
|
|
149
|
-
tools: names === "all" ? "all" : [...new Set([...r.tools, ...names])],
|
|
150
|
-
};
|
|
151
|
-
});
|
|
152
|
-
if (!merged)
|
|
153
|
-
tools.push({ kind: "connector", connectorId: c.id, tools: names });
|
|
140
|
+
// tools are on by default (tools default-on spec §3): binding an entry that names some tools
|
|
141
|
+
// turns the connector's other tools off for this agent; one taking them all leaves it all on
|
|
142
|
+
const off = names === "all" ? [] : offered.filter((n) => !names.includes(n));
|
|
143
|
+
const disabledTools = [
|
|
144
|
+
...(def.disabledTools ?? []).filter((r) => r.kind !== "connector" || r.connectorId !== c.id),
|
|
145
|
+
...(off.length > 0 ? [{ kind: "connector", connectorId: c.id, tools: off }] : []),
|
|
146
|
+
];
|
|
154
147
|
const left = pending.filter((x) => x.key !== key);
|
|
155
148
|
const { pendingConnectors: _old, ...rest } = def;
|
|
156
149
|
const next = {
|
|
157
150
|
...rest,
|
|
158
|
-
|
|
151
|
+
disabledTools: canonicalDisabledTools(disabledTools),
|
|
159
152
|
toolPolicies,
|
|
160
153
|
...(left.length > 0 && { pendingConnectors: left }),
|
|
161
154
|
};
|
|
@@ -180,7 +173,13 @@ let PendingConnectorsService = class PendingConnectorsService {
|
|
|
180
173
|
orgId,
|
|
181
174
|
action: "agent.pending_connector_bound",
|
|
182
175
|
target: agentId,
|
|
183
|
-
detail: {
|
|
176
|
+
detail: {
|
|
177
|
+
key,
|
|
178
|
+
connectorId: c.id,
|
|
179
|
+
fromVersion: before.current_version,
|
|
180
|
+
toVersion,
|
|
181
|
+
...auditDetail,
|
|
182
|
+
},
|
|
184
183
|
});
|
|
185
184
|
await this.requests.settleIn({
|
|
186
185
|
orgId,
|
|
@@ -198,7 +197,7 @@ let PendingConnectorsService = class PendingConnectorsService {
|
|
|
198
197
|
* keys, requested by the agent's owner (P4-T6-4). No pending connectors -> 409
|
|
199
198
|
* `agent.no_pending_connectors`.
|
|
200
199
|
*/
|
|
201
|
-
async reopen(orgId, agentId, actor, actorTokenId) {
|
|
200
|
+
async reopen(orgId, agentId, actor, actorTokenId, auditDetail) {
|
|
202
201
|
const before = await this.agents.lockForWrite(orgId, agentId, actor);
|
|
203
202
|
const def = await this.currentDefinition(agentId, before.current_version);
|
|
204
203
|
const keys = (def.pendingConnectors ?? []).map((c) => c.key);
|
|
@@ -216,6 +215,7 @@ let PendingConnectorsService = class PendingConnectorsService {
|
|
|
216
215
|
requestedBy: owner.owner_account_id,
|
|
217
216
|
actor,
|
|
218
217
|
actorTokenId,
|
|
218
|
+
...(auditDetail !== undefined && { auditDetail }),
|
|
219
219
|
});
|
|
220
220
|
// the agent row is locked above, so the keys read there are still pending
|
|
221
221
|
if (r === null)
|
package/dist/agents/profile.d.ts
CHANGED
|
@@ -44,6 +44,22 @@ export declare const QuickActionsSchema: z.ZodArray<z.ZodObject<{
|
|
|
44
44
|
body: z.ZodString;
|
|
45
45
|
}, z.core.$strict>>;
|
|
46
46
|
/** What a client may write (`external` is migrated data only). */
|
|
47
|
+
/** A preset avatar: the only kind the `Platform` tool sets (an upload is the web's). */
|
|
48
|
+
export declare const PresetAvatarSchema: z.ZodObject<{
|
|
49
|
+
kind: z.ZodLiteral<"preset">;
|
|
50
|
+
id: z.ZodEnum<{
|
|
51
|
+
"black-bear": "black-bear";
|
|
52
|
+
capybara: "capybara";
|
|
53
|
+
elephant: "elephant";
|
|
54
|
+
fox: "fox";
|
|
55
|
+
owl: "owl";
|
|
56
|
+
panda: "panda";
|
|
57
|
+
penguin: "penguin";
|
|
58
|
+
rabbit: "rabbit";
|
|
59
|
+
turtle: "turtle";
|
|
60
|
+
whale: "whale";
|
|
61
|
+
}>;
|
|
62
|
+
}, z.core.$strict>;
|
|
47
63
|
export declare const AvatarInputSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
48
64
|
kind: z.ZodLiteral<"preset">;
|
|
49
65
|
id: z.ZodEnum<{
|
|
@@ -88,6 +104,8 @@ export declare const ProfileInputSchema: z.ZodObject<{
|
|
|
88
104
|
}, z.core.$strict>>>;
|
|
89
105
|
}, z.core.$strict>;
|
|
90
106
|
export type ProfileInput = z.infer<typeof ProfileInputSchema>;
|
|
107
|
+
/** What `PATCH …/profile` writes: the description is saved with the definition (run context §3.5). */
|
|
108
|
+
export type ProfilePatch = Omit<ProfileInput, "description">;
|
|
91
109
|
export interface AgentProfile {
|
|
92
110
|
avatar: AgentAvatar;
|
|
93
111
|
description: string;
|
package/dist/agents/profile.js
CHANGED
|
@@ -38,8 +38,12 @@ export const QuickActionSchema = z
|
|
|
38
38
|
export const DescriptionSchema = z.string().max(PROFILE_LIMITS.description);
|
|
39
39
|
export const QuickActionsSchema = z.array(QuickActionSchema).max(PROFILE_LIMITS.quickActions);
|
|
40
40
|
/** What a client may write (`external` is migrated data only). */
|
|
41
|
+
/** A preset avatar: the only kind the `Platform` tool sets (an upload is the web's). */
|
|
42
|
+
export const PresetAvatarSchema = z
|
|
43
|
+
.object({ kind: z.literal("preset"), id: z.enum(PRESET_IDS) })
|
|
44
|
+
.strict();
|
|
41
45
|
export const AvatarInputSchema = z.discriminatedUnion("kind", [
|
|
42
|
-
|
|
46
|
+
PresetAvatarSchema,
|
|
43
47
|
z.object({ kind: z.literal("upload"), uploadId: z.string().min(1).max(200) }).strict(),
|
|
44
48
|
]);
|
|
45
49
|
export const ProfileInputSchema = z
|
|
@@ -9,11 +9,11 @@ import { AgentsService } from "./agents.service.js";
|
|
|
9
9
|
* a vendor call; `agents` is the number of agents the caller can see (the agent list's
|
|
10
10
|
* visibility). Humans and service tokens (`org.read`).
|
|
11
11
|
*
|
|
12
|
-
* `modelProvider`
|
|
13
|
-
* (
|
|
14
|
-
*
|
|
15
|
-
*
|
|
16
|
-
*
|
|
12
|
+
* `modelProvider` counts the deployment's providers whose effective config is valid in this org
|
|
13
|
+
* (spec B §5.5: a provider the platform installed without a key needs each org's own). It is read
|
|
14
|
+
* from this replica's provider registry, which follows the per-replica extension reconcile: right
|
|
15
|
+
* after a provider is enabled, a replica that has not reconciled yet may still answer `none` for
|
|
16
|
+
* a moment.
|
|
17
17
|
*/
|
|
18
18
|
export declare class ReadinessController {
|
|
19
19
|
private readonly registry;
|
|
@@ -21,11 +21,11 @@ const viewerOf = (p) => (p.kind === "user" ? p.account.id : null);
|
|
|
21
21
|
* a vendor call; `agents` is the number of agents the caller can see (the agent list's
|
|
22
22
|
* visibility). Humans and service tokens (`org.read`).
|
|
23
23
|
*
|
|
24
|
-
* `modelProvider`
|
|
25
|
-
* (
|
|
26
|
-
*
|
|
27
|
-
*
|
|
28
|
-
*
|
|
24
|
+
* `modelProvider` counts the deployment's providers whose effective config is valid in this org
|
|
25
|
+
* (spec B §5.5: a provider the platform installed without a key needs each org's own). It is read
|
|
26
|
+
* from this replica's provider registry, which follows the per-replica extension reconcile: right
|
|
27
|
+
* after a provider is enabled, a replica that has not reconciled yet may still answer `none` for
|
|
28
|
+
* a moment.
|
|
29
29
|
*/
|
|
30
30
|
let ReadinessController = class ReadinessController {
|
|
31
31
|
registry;
|
|
@@ -37,7 +37,7 @@ let ReadinessController = class ReadinessController {
|
|
|
37
37
|
async get(principal, org) {
|
|
38
38
|
const visible = await this.agents.listVisible(org.orgId, viewerOf(principal));
|
|
39
39
|
return {
|
|
40
|
-
modelProvider: this.registry.hasProvider() ? "ready" : "none",
|
|
40
|
+
modelProvider: (await this.registry.hasProvider(org.orgId)) ? "ready" : "none",
|
|
41
41
|
agents: visible.length,
|
|
42
42
|
};
|
|
43
43
|
}
|
|
@@ -1,22 +1,13 @@
|
|
|
1
|
-
import { z } from "zod";
|
|
1
|
+
import type { z } from "zod";
|
|
2
2
|
import { OwnedItems, type OwnedSkillDeletePreview } from "../catalog/owned-items.js";
|
|
3
3
|
import { type Principal } from "../identity/principal.js";
|
|
4
4
|
import { type OrgContext } from "../orgs/org.guard.js";
|
|
5
5
|
import { type AgentTemplateDetail, OrgAgentTemplates, type SaveAsOmission } from "./org-templates.js";
|
|
6
6
|
import { AgentTemplatesService, type AgentTemplateView } from "./templates.js";
|
|
7
|
-
|
|
8
|
-
id: z.ZodString;
|
|
9
|
-
}, z.core.$strip>;
|
|
10
|
-
declare const AgentIdParams: z.ZodObject<{
|
|
11
|
-
agentId: z.ZodString;
|
|
12
|
-
}, z.core.$strip>;
|
|
7
|
+
import { AgentTemplateIdParams, SaveAsAgentIdParams, SaveAsTemplateBody } from "./templates.schemas.js";
|
|
13
8
|
declare const ShareableBody: z.ZodObject<{
|
|
14
9
|
shareable: z.ZodBoolean;
|
|
15
10
|
}, z.core.$strict>;
|
|
16
|
-
declare const SaveAsBody: z.ZodObject<{
|
|
17
|
-
name: z.ZodString;
|
|
18
|
-
description: z.ZodString;
|
|
19
|
-
}, z.core.$strict>;
|
|
20
11
|
declare const UpdateBody: z.ZodObject<{
|
|
21
12
|
definition: z.ZodRecord<z.ZodString, z.ZodUnknown>;
|
|
22
13
|
expectedVersion: z.ZodNumber;
|
|
@@ -42,7 +33,7 @@ export declare class AgentTemplatesController {
|
|
|
42
33
|
* the org) with its definition, owner and the org's flags (`owned`, `shareable`, `promoted`).
|
|
43
34
|
* Not usable here -> 404 `component.not_found`.
|
|
44
35
|
*/
|
|
45
|
-
get(principal: Principal, org: OrgContext, params: z.infer<typeof
|
|
36
|
+
get(principal: Principal, org: OrgContext, params: z.infer<typeof AgentTemplateIdParams>): Promise<{
|
|
46
37
|
template: AgentTemplateDetail;
|
|
47
38
|
}>;
|
|
48
39
|
/**
|
|
@@ -50,7 +41,7 @@ export declare class AgentTemplatesController {
|
|
|
50
41
|
* 200 `{ template }`; a stale version -> 409 `agent_template.version_conflict`; a template the
|
|
51
42
|
* org does not own -> 409 `catalog.not_owned`.
|
|
52
43
|
*/
|
|
53
|
-
update(principal: Principal, org: OrgContext, params: z.infer<typeof
|
|
44
|
+
update(principal: Principal, org: OrgContext, params: z.infer<typeof AgentTemplateIdParams>, body: z.infer<typeof UpdateBody>): Promise<{
|
|
54
45
|
template: AgentTemplateDetail;
|
|
55
46
|
}>;
|
|
56
47
|
/**
|
|
@@ -58,12 +49,12 @@ export declare class AgentTemplatesController {
|
|
|
58
49
|
* was shared and another org uses it (`orgs`), else `removed`; `agents` the org's agents whose
|
|
59
50
|
* roster loses it.
|
|
60
51
|
*/
|
|
61
|
-
deletePreview(principal: Principal, org: OrgContext, params: z.infer<typeof
|
|
52
|
+
deletePreview(principal: Principal, org: OrgContext, params: z.infer<typeof AgentTemplateIdParams>): Promise<OwnedSkillDeletePreview>;
|
|
62
53
|
/**
|
|
63
54
|
* Deletes the org's own template (the P3 owner rules, ruling P4-12): one it shared that another
|
|
64
55
|
* org uses becomes the platform's (platform notice `ownership_transferred`). 200 `{ outcome }`.
|
|
65
56
|
*/
|
|
66
|
-
remove(principal: Principal, org: OrgContext, params: z.infer<typeof
|
|
57
|
+
remove(principal: Principal, org: OrgContext, params: z.infer<typeof AgentTemplateIdParams>): Promise<{
|
|
67
58
|
outcome: "transferred" | "removed";
|
|
68
59
|
}>;
|
|
69
60
|
/**
|
|
@@ -71,7 +62,7 @@ export declare class AgentTemplatesController {
|
|
|
71
62
|
* template, ruling P4-13): a plugin's template or a copy of another owner's platform template
|
|
72
63
|
* -> 409 `catalog.not_owned`; one the org promoted writes its platform row too (ruling P3-2).
|
|
73
64
|
*/
|
|
74
|
-
setShareable(principal: Principal, org: OrgContext, params: z.infer<typeof
|
|
65
|
+
setShareable(principal: Principal, org: OrgContext, params: z.infer<typeof AgentTemplateIdParams>, body: z.infer<typeof ShareableBody>): Promise<{
|
|
75
66
|
id: string;
|
|
76
67
|
shareable: boolean;
|
|
77
68
|
}>;
|
|
@@ -88,7 +79,7 @@ export declare class AgentTemplatesController {
|
|
|
88
79
|
export declare class AgentSaveAsTemplateController {
|
|
89
80
|
private readonly orgTemplates;
|
|
90
81
|
constructor(orgTemplates: OrgAgentTemplates);
|
|
91
|
-
saveAs(principal: Principal, org: OrgContext, params: z.infer<typeof
|
|
82
|
+
saveAs(principal: Principal, org: OrgContext, params: z.infer<typeof SaveAsAgentIdParams>, body: z.infer<typeof SaveAsTemplateBody>): Promise<{
|
|
92
83
|
template: AgentTemplateDetail;
|
|
93
84
|
omitted: SaveAsOmission[];
|
|
94
85
|
}>;
|
|
@@ -7,9 +7,7 @@ var __decorate = (this && this.__decorate) || function (decorators, target, key,
|
|
|
7
7
|
var __param = (this && this.__param) || function (paramIndex, decorator) {
|
|
8
8
|
return function (target, key) { decorator(target, key, paramIndex); }
|
|
9
9
|
};
|
|
10
|
-
import { AGENT_TEMPLATE_NAME_RE } from "@capybara-hq/plugin-sdk";
|
|
11
10
|
import { Controller, Delete, Get, Inject, Post, Put } from "@nestjs/common";
|
|
12
|
-
import { z } from "zod";
|
|
13
11
|
import { OwnedItems } from "../catalog/owned-items.js";
|
|
14
12
|
import { CurrentPrincipal, patTokenId, requireUser, } from "../identity/principal.js";
|
|
15
13
|
import { createZodDto } from "../infra/validation/create-zod-dto.js";
|
|
@@ -17,32 +15,16 @@ import { ZBody, ZParam } from "../infra/validation/zod-params.js";
|
|
|
17
15
|
import { CurrentOrg, OrgAction } from "../orgs/org.guard.js";
|
|
18
16
|
import { OrgAgentTemplates, } from "./org-templates.js";
|
|
19
17
|
import { AgentTemplatesService } from "./templates.js";
|
|
20
|
-
|
|
21
|
-
const
|
|
22
|
-
const
|
|
23
|
-
|
|
24
|
-
.object({
|
|
25
|
-
/** The bare template name (the template name rule); unique in the org's usable set. */
|
|
26
|
-
name: z.string().regex(AGENT_TEMPLATE_NAME_RE),
|
|
27
|
-
/** When to use it (trimmed, as a template file's). */
|
|
28
|
-
description: z.string().trim().min(1).max(4096),
|
|
29
|
-
})
|
|
30
|
-
.strict();
|
|
31
|
-
const UpdateBody = z
|
|
32
|
-
.object({
|
|
33
|
-
/** The whole definition (the `AgentTemplate` shape), validated like a template file. */
|
|
34
|
-
definition: z.record(z.string(), z.unknown()),
|
|
35
|
-
/** The `version` the editor read; another one -> 409 `agent_template.version_conflict`. */
|
|
36
|
-
expectedVersion: z.number().int().min(1),
|
|
37
|
-
})
|
|
38
|
-
.strict();
|
|
39
|
-
class AgentTemplateIdParams extends createZodDto(IdParams, "AgentTemplateIdParams") {
|
|
18
|
+
import { AgentTemplateIdParams, SaveAsAgentIdParams, SaveAsTemplateBody, AgentTemplateShareableBody as ShareableBodySchema, AgentTemplateUpdateBody as UpdateBodySchema, } from "./templates.schemas.js";
|
|
19
|
+
const ShareableBody = ShareableBodySchema;
|
|
20
|
+
const UpdateBody = UpdateBodySchema;
|
|
21
|
+
class AgentTemplateIdParamsDto extends createZodDto(AgentTemplateIdParams, "AgentTemplateIdParams") {
|
|
40
22
|
}
|
|
41
|
-
class
|
|
23
|
+
class SaveAsAgentIdParamsDto extends createZodDto(SaveAsAgentIdParams, "SaveAsAgentIdParams") {
|
|
42
24
|
}
|
|
43
25
|
class AgentTemplateShareableBody extends createZodDto(ShareableBody, "AgentTemplateShareableBody") {
|
|
44
26
|
}
|
|
45
|
-
class
|
|
27
|
+
class SaveAsTemplateBodyDto extends createZodDto(SaveAsTemplateBody, "SaveAsTemplateBody") {
|
|
46
28
|
}
|
|
47
29
|
class AgentTemplateUpdateBody extends createZodDto(UpdateBody, "AgentTemplateUpdateBody") {
|
|
48
30
|
}
|
|
@@ -128,14 +110,14 @@ __decorate([
|
|
|
128
110
|
OrgAction("agents.create"),
|
|
129
111
|
__param(0, CurrentPrincipal()),
|
|
130
112
|
__param(1, CurrentOrg()),
|
|
131
|
-
__param(2, ZParam(
|
|
113
|
+
__param(2, ZParam(AgentTemplateIdParamsDto))
|
|
132
114
|
], AgentTemplatesController.prototype, "get", null);
|
|
133
115
|
__decorate([
|
|
134
116
|
Put(":id"),
|
|
135
117
|
OrgAction("agents.manage"),
|
|
136
118
|
__param(0, CurrentPrincipal()),
|
|
137
119
|
__param(1, CurrentOrg()),
|
|
138
|
-
__param(2, ZParam(
|
|
120
|
+
__param(2, ZParam(AgentTemplateIdParamsDto)),
|
|
139
121
|
__param(3, ZBody(AgentTemplateUpdateBody))
|
|
140
122
|
], AgentTemplatesController.prototype, "update", null);
|
|
141
123
|
__decorate([
|
|
@@ -143,21 +125,21 @@ __decorate([
|
|
|
143
125
|
OrgAction("agents.manage"),
|
|
144
126
|
__param(0, CurrentPrincipal()),
|
|
145
127
|
__param(1, CurrentOrg()),
|
|
146
|
-
__param(2, ZParam(
|
|
128
|
+
__param(2, ZParam(AgentTemplateIdParamsDto))
|
|
147
129
|
], AgentTemplatesController.prototype, "deletePreview", null);
|
|
148
130
|
__decorate([
|
|
149
131
|
Delete(":id"),
|
|
150
132
|
OrgAction("agents.manage"),
|
|
151
133
|
__param(0, CurrentPrincipal()),
|
|
152
134
|
__param(1, CurrentOrg()),
|
|
153
|
-
__param(2, ZParam(
|
|
135
|
+
__param(2, ZParam(AgentTemplateIdParamsDto))
|
|
154
136
|
], AgentTemplatesController.prototype, "remove", null);
|
|
155
137
|
__decorate([
|
|
156
138
|
Put(":id/shareable"),
|
|
157
139
|
OrgAction("agents.manage"),
|
|
158
140
|
__param(0, CurrentPrincipal()),
|
|
159
141
|
__param(1, CurrentOrg()),
|
|
160
|
-
__param(2, ZParam(
|
|
142
|
+
__param(2, ZParam(AgentTemplateIdParamsDto)),
|
|
161
143
|
__param(3, ZBody(AgentTemplateShareableBody))
|
|
162
144
|
], AgentTemplatesController.prototype, "setShareable", null);
|
|
163
145
|
AgentTemplatesController = __decorate([
|
|
@@ -191,8 +173,8 @@ __decorate([
|
|
|
191
173
|
OrgAction("agents.manage"),
|
|
192
174
|
__param(0, CurrentPrincipal()),
|
|
193
175
|
__param(1, CurrentOrg()),
|
|
194
|
-
__param(2, ZParam(
|
|
195
|
-
__param(3, ZBody(
|
|
176
|
+
__param(2, ZParam(SaveAsAgentIdParamsDto)),
|
|
177
|
+
__param(3, ZBody(SaveAsTemplateBodyDto))
|
|
196
178
|
], AgentSaveAsTemplateController.prototype, "saveAs", null);
|
|
197
179
|
AgentSaveAsTemplateController = __decorate([
|
|
198
180
|
Controller("api/v1/orgs/:orgId/agents"),
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
import type { RouteSchemas } from "../platform/route-schemas.js";
|
|
3
|
+
export declare const AgentTemplateIdParams: z.ZodObject<{
|
|
4
|
+
id: z.ZodString;
|
|
5
|
+
}, z.core.$strip>;
|
|
6
|
+
export declare const SaveAsAgentIdParams: z.ZodObject<{
|
|
7
|
+
agentId: z.ZodString;
|
|
8
|
+
}, z.core.$strip>;
|
|
9
|
+
export declare const SaveAsTemplateBody: z.ZodObject<{
|
|
10
|
+
name: z.ZodString;
|
|
11
|
+
description: z.ZodString;
|
|
12
|
+
}, z.core.$strict>;
|
|
13
|
+
export declare const AgentTemplateShareableBody: z.ZodObject<{
|
|
14
|
+
shareable: z.ZodBoolean;
|
|
15
|
+
}, z.core.$strict>;
|
|
16
|
+
export declare const AgentTemplateUpdateBody: z.ZodObject<{
|
|
17
|
+
definition: z.ZodRecord<z.ZodString, z.ZodUnknown>;
|
|
18
|
+
expectedVersion: z.ZodNumber;
|
|
19
|
+
}, z.core.$strict>;
|
|
20
|
+
export declare const AGENT_TEMPLATE_ROUTES: readonly RouteSchemas[];
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import { AGENT_TEMPLATE_NAME_RE } from "@capybara-hq/plugin-sdk";
|
|
2
|
+
import { z } from "zod";
|
|
3
|
+
export const AgentTemplateIdParams = z.object({ id: z.string().min(1).max(100) });
|
|
4
|
+
export const SaveAsAgentIdParams = z.object({ agentId: z.string().min(1).max(100) });
|
|
5
|
+
export const SaveAsTemplateBody = z
|
|
6
|
+
.object({
|
|
7
|
+
/** The bare template name (the template name rule); unique in the org's usable set. */
|
|
8
|
+
name: z.string().regex(AGENT_TEMPLATE_NAME_RE),
|
|
9
|
+
/** When to use it (trimmed, as a template file's). */
|
|
10
|
+
description: z.string().trim().min(1).max(4096),
|
|
11
|
+
})
|
|
12
|
+
.strict();
|
|
13
|
+
export const AgentTemplateShareableBody = z.object({ shareable: z.boolean() }).strict();
|
|
14
|
+
export const AgentTemplateUpdateBody = z
|
|
15
|
+
.object({
|
|
16
|
+
/** The whole definition (the `AgentTemplate` shape), validated like a template file. */
|
|
17
|
+
definition: z.record(z.string(), z.unknown()),
|
|
18
|
+
/** The `version` the editor read; another one -> 409 `agent_template.version_conflict`. */
|
|
19
|
+
expectedVersion: z.number().int().min(1),
|
|
20
|
+
})
|
|
21
|
+
.strict();
|
|
22
|
+
export const AGENT_TEMPLATE_ROUTES = [
|
|
23
|
+
{ route: "GET /api/v1/orgs/:orgId/agent-templates" },
|
|
24
|
+
{ route: "GET /api/v1/orgs/:orgId/agent-templates/:id", params: AgentTemplateIdParams },
|
|
25
|
+
{
|
|
26
|
+
route: "POST /api/v1/orgs/:orgId/agents/:agentId/save-as-template",
|
|
27
|
+
params: SaveAsAgentIdParams,
|
|
28
|
+
body: SaveAsTemplateBody,
|
|
29
|
+
},
|
|
30
|
+
{
|
|
31
|
+
route: "PUT /api/v1/orgs/:orgId/agent-templates/:id",
|
|
32
|
+
params: AgentTemplateIdParams,
|
|
33
|
+
body: AgentTemplateUpdateBody,
|
|
34
|
+
},
|
|
35
|
+
{
|
|
36
|
+
route: "GET /api/v1/orgs/:orgId/agent-templates/:id/delete-preview",
|
|
37
|
+
params: AgentTemplateIdParams,
|
|
38
|
+
},
|
|
39
|
+
{ route: "DELETE /api/v1/orgs/:orgId/agent-templates/:id", params: AgentTemplateIdParams },
|
|
40
|
+
{
|
|
41
|
+
route: "PUT /api/v1/orgs/:orgId/agent-templates/:id/shareable",
|
|
42
|
+
params: AgentTemplateIdParams,
|
|
43
|
+
body: AgentTemplateShareableBody,
|
|
44
|
+
},
|
|
45
|
+
];
|
|
@@ -13,9 +13,10 @@ import { CurrentPrincipal, patTokenId, requireUser, } from "../identity/principa
|
|
|
13
13
|
import { createZodDto } from "../infra/validation/create-zod-dto.js";
|
|
14
14
|
import { ZParam, ZQuery } from "../infra/validation/zod-params.js";
|
|
15
15
|
import { CurrentOrg, OrgAction } from "../orgs/org.guard.js";
|
|
16
|
+
import { BackgroundConversationParams, BackgroundTaskParams } from "./background.schemas.js";
|
|
16
17
|
import { BackgroundTasks, OUTPUT_TAIL_MAX_BYTES, } from "./tasks.service.js";
|
|
17
|
-
const ConversationParams =
|
|
18
|
-
const TaskParams =
|
|
18
|
+
const ConversationParams = BackgroundConversationParams;
|
|
19
|
+
const TaskParams = BackgroundTaskParams;
|
|
19
20
|
const OutputQuery = z.object({
|
|
20
21
|
tail: z.coerce.number().int().min(1).max(OUTPUT_TAIL_MAX_BYTES).default(OUTPUT_TAIL_MAX_BYTES),
|
|
21
22
|
});
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
import type { RouteSchemas } from "../platform/route-schemas.js";
|
|
3
|
+
export declare const BackgroundConversationParams: z.ZodObject<{
|
|
4
|
+
id: z.ZodString;
|
|
5
|
+
}, z.core.$strip>;
|
|
6
|
+
export declare const BackgroundTaskParams: z.ZodObject<{
|
|
7
|
+
id: z.ZodString;
|
|
8
|
+
taskId: z.ZodString;
|
|
9
|
+
}, z.core.$strip>;
|
|
10
|
+
export declare const BACKGROUND_ROUTES: readonly RouteSchemas[];
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
export const BackgroundConversationParams = z.object({ id: z.string().min(1).max(100) });
|
|
3
|
+
export const BackgroundTaskParams = z.object({
|
|
4
|
+
id: z.string().min(1).max(100),
|
|
5
|
+
taskId: z.string().min(1).max(100),
|
|
6
|
+
});
|
|
7
|
+
export const BACKGROUND_ROUTES = [
|
|
8
|
+
{
|
|
9
|
+
route: "GET /api/v1/orgs/:orgId/conversations/:id/background-tasks",
|
|
10
|
+
params: BackgroundConversationParams,
|
|
11
|
+
},
|
|
12
|
+
{
|
|
13
|
+
route: "POST /api/v1/orgs/:orgId/conversations/:id/background-tasks/:taskId/stop",
|
|
14
|
+
params: BackgroundTaskParams,
|
|
15
|
+
},
|
|
16
|
+
];
|
|
@@ -61,7 +61,7 @@ export declare class BackgroundTasks {
|
|
|
61
61
|
* stop already claimed the task (or the task is a reservation still launching, which its launch
|
|
62
62
|
* then kills); a stop that fails throws. Writes the `background_task.stopped` audit event.
|
|
63
63
|
*/
|
|
64
|
-
stop(orgId: string, conversationId: string, accountId: string, taskId: string, actorTokenId?: string): Promise<BackgroundTaskView>;
|
|
64
|
+
stop(orgId: string, conversationId: string, accountId: string, taskId: string, actorTokenId?: string, auditDetail?: Record<string, unknown>): Promise<BackgroundTaskView>;
|
|
65
65
|
/**
|
|
66
66
|
* Whether the task's environment may still be used by its conversation's owner (the access
|
|
67
67
|
* re-check every sandbox tool call makes); when it may not, the live read is skipped.
|
|
@@ -100,7 +100,7 @@ let BackgroundTasks = class BackgroundTasks {
|
|
|
100
100
|
* stop already claimed the task (or the task is a reservation still launching, which its launch
|
|
101
101
|
* then kills); a stop that fails throws. Writes the `background_task.stopped` audit event.
|
|
102
102
|
*/
|
|
103
|
-
async stop(orgId, conversationId, accountId, taskId, actorTokenId) {
|
|
103
|
+
async stop(orgId, conversationId, accountId, taskId, actorTokenId, auditDetail) {
|
|
104
104
|
const task = await this.owned(orgId, conversationId, accountId, taskId);
|
|
105
105
|
const after = await this.stopper.stop(task, "person");
|
|
106
106
|
await audit(this.db.db, {
|
|
@@ -109,7 +109,12 @@ let BackgroundTasks = class BackgroundTasks {
|
|
|
109
109
|
orgId,
|
|
110
110
|
action: "background_task.stopped",
|
|
111
111
|
target: task.id,
|
|
112
|
-
detail: {
|
|
112
|
+
detail: {
|
|
113
|
+
taskId: task.id,
|
|
114
|
+
conversationId: task.conversationId,
|
|
115
|
+
status: after.status,
|
|
116
|
+
...auditDetail,
|
|
117
|
+
},
|
|
113
118
|
});
|
|
114
119
|
return this.view(after, conversationId);
|
|
115
120
|
}
|