@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
|
@@ -3,10 +3,11 @@ import { KernelDb } from "../infra/database/kernel-db.js";
|
|
|
3
3
|
import { TransactionHost } from "../infra/database/transaction-host.js";
|
|
4
4
|
import { AgentLookup } from "./agent-lookup.js";
|
|
5
5
|
import { AgentsService } from "./agents.service.js";
|
|
6
|
-
import type { AgentProfile,
|
|
6
|
+
import type { AgentProfile, ProfilePatch } from "./profile.js";
|
|
7
7
|
/**
|
|
8
|
-
* Writes an agent's profile (avatar,
|
|
9
|
-
*
|
|
8
|
+
* Writes an agent's profile (avatar, quick actions): display data stored beside the agent, never
|
|
9
|
+
* model-visible, so a change creates no agent version. The description is part of the definition
|
|
10
|
+
* (run context spec §3.5). The permission is the one of
|
|
10
11
|
* `AgentsService.update` (owner or org admin, checked under the org row lock).
|
|
11
12
|
*/
|
|
12
13
|
export declare class AgentProfileService {
|
|
@@ -19,11 +20,12 @@ export declare class AgentProfileService {
|
|
|
19
20
|
/**
|
|
20
21
|
* Applies `patch` (only the given fields) when `expectedUpdatedAt` is still the profile's
|
|
21
22
|
* `updatedAt`, else 409 `agent.profile_conflict` (never a silent overwrite). Audit
|
|
22
|
-
* `agent.profile_updated` `{ fields, channel }`: `api` for a personal access
|
|
23
|
+
* `agent.profile_updated` `{ fields, channel, ...auditDetail }`: `api` for a personal access
|
|
24
|
+
* token, `agent` for a write through the `Platform` tool (`auditDetail` given), else `web`.
|
|
23
25
|
* An `upload` avatar must be the actor's own upload that no other agent uses (else 404
|
|
24
26
|
* `attachment.not_found`): it is finalized first (outside the transaction, it reads the object
|
|
25
27
|
* store; 503 `storage.unavailable` without one) and bound to the agent inside it.
|
|
26
28
|
*/
|
|
27
|
-
update(orgId: string, agentId: string, actorAccountId: string, patch:
|
|
29
|
+
update(orgId: string, agentId: string, actorAccountId: string, patch: ProfilePatch, expectedUpdatedAt: string, actorTokenId?: string, auditDetail?: Record<string, unknown>): Promise<AgentProfile>;
|
|
28
30
|
private updateIn;
|
|
29
31
|
}
|
|
@@ -18,8 +18,9 @@ import { Transactional } from "../infra/database/transactional.decorator.js";
|
|
|
18
18
|
import { AgentLookup } from "./agent-lookup.js";
|
|
19
19
|
import { AgentsService } from "./agents.service.js";
|
|
20
20
|
/**
|
|
21
|
-
* Writes an agent's profile (avatar,
|
|
22
|
-
*
|
|
21
|
+
* Writes an agent's profile (avatar, quick actions): display data stored beside the agent, never
|
|
22
|
+
* model-visible, so a change creates no agent version. The description is part of the definition
|
|
23
|
+
* (run context spec §3.5). The permission is the one of
|
|
23
24
|
* `AgentsService.update` (owner or org admin, checked under the org row lock).
|
|
24
25
|
*/
|
|
25
26
|
let AgentProfileService = class AgentProfileService {
|
|
@@ -38,18 +39,19 @@ let AgentProfileService = class AgentProfileService {
|
|
|
38
39
|
/**
|
|
39
40
|
* Applies `patch` (only the given fields) when `expectedUpdatedAt` is still the profile's
|
|
40
41
|
* `updatedAt`, else 409 `agent.profile_conflict` (never a silent overwrite). Audit
|
|
41
|
-
* `agent.profile_updated` `{ fields, channel }`: `api` for a personal access
|
|
42
|
+
* `agent.profile_updated` `{ fields, channel, ...auditDetail }`: `api` for a personal access
|
|
43
|
+
* token, `agent` for a write through the `Platform` tool (`auditDetail` given), else `web`.
|
|
42
44
|
* An `upload` avatar must be the actor's own upload that no other agent uses (else 404
|
|
43
45
|
* `attachment.not_found`): it is finalized first (outside the transaction, it reads the object
|
|
44
46
|
* store; 503 `storage.unavailable` without one) and bound to the agent inside it.
|
|
45
47
|
*/
|
|
46
|
-
async update(orgId, agentId, actorAccountId, patch, expectedUpdatedAt, actorTokenId) {
|
|
48
|
+
async update(orgId, agentId, actorAccountId, patch, expectedUpdatedAt, actorTokenId, auditDetail) {
|
|
47
49
|
if (patch.avatar?.kind === "upload") {
|
|
48
50
|
await this.attachments.prepareAgentAvatar(orgId, actorAccountId, patch.avatar.uploadId, agentId);
|
|
49
51
|
}
|
|
50
|
-
return this.updateIn(orgId, agentId, actorAccountId, patch, expectedUpdatedAt, actorTokenId);
|
|
52
|
+
return this.updateIn(orgId, agentId, actorAccountId, patch, expectedUpdatedAt, actorTokenId, auditDetail);
|
|
51
53
|
}
|
|
52
|
-
async updateIn(orgId, agentId, actorAccountId, patch, expectedUpdatedAt, actorTokenId) {
|
|
54
|
+
async updateIn(orgId, agentId, actorAccountId, patch, expectedUpdatedAt, actorTokenId, auditDetail) {
|
|
53
55
|
const t = this.db.db;
|
|
54
56
|
await this.agents.lockForWrite(orgId, agentId, actorAccountId);
|
|
55
57
|
const current = await t
|
|
@@ -63,7 +65,7 @@ let AgentProfileService = class AgentProfileService {
|
|
|
63
65
|
if (patch.avatar?.kind === "upload") {
|
|
64
66
|
await this.attachments.consumeAgentAvatar(orgId, actorAccountId, patch.avatar.uploadId, agentId);
|
|
65
67
|
}
|
|
66
|
-
const fields = ["avatar", "
|
|
68
|
+
const fields = ["avatar", "quickActions"].filter((f) => patch[f] !== undefined);
|
|
67
69
|
// nothing to write: no timestamp bump, no audit row
|
|
68
70
|
if (fields.length === 0)
|
|
69
71
|
return (await this.lookup.view(agentId)).profile;
|
|
@@ -73,7 +75,6 @@ let AgentProfileService = class AgentProfileService {
|
|
|
73
75
|
...(patch.avatar !== undefined && {
|
|
74
76
|
profile_avatar: patch.avatar === null ? sql `null` : JSON.stringify(patch.avatar),
|
|
75
77
|
}),
|
|
76
|
-
...(patch.description !== undefined && { profile_description: patch.description }),
|
|
77
78
|
...(patch.quickActions !== undefined && {
|
|
78
79
|
profile_quick_actions: JSON.stringify(patch.quickActions),
|
|
79
80
|
}),
|
|
@@ -98,7 +99,11 @@ let AgentProfileService = class AgentProfileService {
|
|
|
98
99
|
orgId,
|
|
99
100
|
action: "agent.profile_updated",
|
|
100
101
|
target: agentId,
|
|
101
|
-
detail: {
|
|
102
|
+
detail: {
|
|
103
|
+
fields,
|
|
104
|
+
channel: actorTokenId !== undefined ? "api" : auditDetail !== undefined ? "agent" : "web",
|
|
105
|
+
...auditDetail,
|
|
106
|
+
},
|
|
102
107
|
});
|
|
103
108
|
return (await this.lookup.view(agentId)).profile;
|
|
104
109
|
}
|
|
@@ -4,150 +4,13 @@ import { AttachmentsService, type CreatedAttachment } from "../conversations/att
|
|
|
4
4
|
import { type Principal } from "../identity/principal.js";
|
|
5
5
|
import { type OrgContext } from "../orgs/org.guard.js";
|
|
6
6
|
import { AgentProfileService } from "./agent-profile.service.js";
|
|
7
|
+
import { AgentCreateBody, AgentFromTemplateBody, AgentFromTemplatePreviewBody, AgentProfileBody, AgentUpdateBody } from "./agents.schemas.js";
|
|
7
8
|
import { AgentsService, type AgentVersionSummary, type AgentView, type AgentWarning } from "./agents.service.js";
|
|
8
9
|
import { AgentsFromTemplate, type TemplatePreview } from "./from-template.service.js";
|
|
9
|
-
import {
|
|
10
|
+
import type { AgentProfile } from "./profile.js";
|
|
10
11
|
declare const OwnerBody: z.ZodObject<{
|
|
11
12
|
accountId: z.ZodString;
|
|
12
13
|
}, z.core.$strict>;
|
|
13
|
-
declare const CreateBody: z.ZodObject<{
|
|
14
|
-
definition: z.ZodObject<{
|
|
15
|
-
name: z.ZodString;
|
|
16
|
-
avatarUrl: z.ZodDefault<z.ZodNullable<z.ZodURL>>;
|
|
17
|
-
instructionFiles: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
18
|
-
name: z.ZodString;
|
|
19
|
-
content: z.ZodString;
|
|
20
|
-
}, z.core.$strict>>>;
|
|
21
|
-
model: z.ZodObject<{
|
|
22
|
-
provider: z.ZodString;
|
|
23
|
-
model: z.ZodString;
|
|
24
|
-
}, z.core.$strip>;
|
|
25
|
-
fallback: z.ZodDefault<z.ZodNullable<z.ZodObject<{
|
|
26
|
-
provider: z.ZodString;
|
|
27
|
-
model: z.ZodString;
|
|
28
|
-
}, z.core.$strip>>>;
|
|
29
|
-
modelParams: z.ZodDefault<z.ZodRecord<z.ZodString, z.ZodUnion<readonly [z.ZodString, z.ZodNumber, z.ZodBoolean]>>>;
|
|
30
|
-
fallbackParams: z.ZodDefault<z.ZodRecord<z.ZodString, z.ZodUnion<readonly [z.ZodString, z.ZodNumber, z.ZodBoolean]>>>;
|
|
31
|
-
toolPolicies: z.ZodDefault<z.ZodRecord<z.ZodString, z.ZodEnum<{
|
|
32
|
-
ask: "ask";
|
|
33
|
-
deny: "deny";
|
|
34
|
-
}>>>;
|
|
35
|
-
skills: z.ZodOptional<z.ZodObject<{
|
|
36
|
-
orgSkills: z.ZodDefault<z.ZodArray<z.ZodString>>;
|
|
37
|
-
writePolicy: z.ZodOptional<z.ZodEnum<{
|
|
38
|
-
allow: "allow";
|
|
39
|
-
ask: "ask";
|
|
40
|
-
}>>;
|
|
41
|
-
pinned: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
42
|
-
}, z.core.$strict>>;
|
|
43
|
-
subagents: z.ZodOptional<z.ZodObject<{
|
|
44
|
-
general: z.ZodOptional<z.ZodBoolean>;
|
|
45
|
-
templates: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
46
|
-
inline: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
47
|
-
name: z.ZodString;
|
|
48
|
-
description: z.ZodString;
|
|
49
|
-
instructions: z.ZodString;
|
|
50
|
-
tools: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
51
|
-
disallowedTools: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
52
|
-
toolPolicies: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodEnum<{
|
|
53
|
-
ask: "ask";
|
|
54
|
-
deny: "deny";
|
|
55
|
-
}>>>;
|
|
56
|
-
model: z.ZodOptional<z.ZodEnum<{
|
|
57
|
-
capable: "capable";
|
|
58
|
-
fast: "fast";
|
|
59
|
-
inherit: "inherit";
|
|
60
|
-
standard: "standard";
|
|
61
|
-
}>>;
|
|
62
|
-
effort: z.ZodOptional<z.ZodEnum<{
|
|
63
|
-
high: "high";
|
|
64
|
-
low: "low";
|
|
65
|
-
max: "max";
|
|
66
|
-
medium: "medium";
|
|
67
|
-
xhigh: "xhigh";
|
|
68
|
-
}>>;
|
|
69
|
-
maxSteps: z.ZodOptional<z.ZodNumber>;
|
|
70
|
-
skills: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
71
|
-
}, z.core.$strict>>>;
|
|
72
|
-
agents: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
73
|
-
agentId: z.ZodString;
|
|
74
|
-
as: z.ZodString;
|
|
75
|
-
description: z.ZodString;
|
|
76
|
-
}, z.core.$strict>>>;
|
|
77
|
-
dispatchable: z.ZodOptional<z.ZodBoolean>;
|
|
78
|
-
}, z.core.$strict>>;
|
|
79
|
-
instructions: z.ZodOptional<z.ZodString>;
|
|
80
|
-
tools: z.ZodDefault<z.ZodArray<z.ZodPreprocess<z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
81
|
-
kind: z.ZodLiteral<"builtin">;
|
|
82
|
-
name: z.ZodString;
|
|
83
|
-
}, z.core.$strict>, z.ZodObject<{
|
|
84
|
-
kind: z.ZodLiteral<"plugin">;
|
|
85
|
-
plugin: z.ZodString;
|
|
86
|
-
name: z.ZodString;
|
|
87
|
-
}, z.core.$strict>, z.ZodObject<{
|
|
88
|
-
kind: z.ZodLiteral<"connector">;
|
|
89
|
-
connectorId: z.ZodString;
|
|
90
|
-
tools: z.ZodUnion<readonly [z.ZodLiteral<"all">, z.ZodArray<z.ZodString>]>;
|
|
91
|
-
}, z.core.$strict>], "kind">, unknown>>>;
|
|
92
|
-
}, z.core.$strip>;
|
|
93
|
-
visibility: z.ZodEnum<{
|
|
94
|
-
members: "members";
|
|
95
|
-
org: "org";
|
|
96
|
-
private: "private";
|
|
97
|
-
}>;
|
|
98
|
-
memberIds: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
99
|
-
profile: z.ZodOptional<z.ZodObject<{
|
|
100
|
-
avatar: z.ZodOptional<z.ZodNullable<z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
101
|
-
kind: z.ZodLiteral<"preset">;
|
|
102
|
-
id: z.ZodEnum<{
|
|
103
|
-
"black-bear": "black-bear";
|
|
104
|
-
capybara: "capybara";
|
|
105
|
-
elephant: "elephant";
|
|
106
|
-
fox: "fox";
|
|
107
|
-
owl: "owl";
|
|
108
|
-
panda: "panda";
|
|
109
|
-
penguin: "penguin";
|
|
110
|
-
rabbit: "rabbit";
|
|
111
|
-
turtle: "turtle";
|
|
112
|
-
whale: "whale";
|
|
113
|
-
}>;
|
|
114
|
-
}, z.core.$strict>, z.ZodObject<{
|
|
115
|
-
kind: z.ZodLiteral<"upload">;
|
|
116
|
-
uploadId: z.ZodString;
|
|
117
|
-
}, z.core.$strict>], "kind">>>;
|
|
118
|
-
description: z.ZodOptional<z.ZodString>;
|
|
119
|
-
quickActions: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
120
|
-
title: z.ZodString;
|
|
121
|
-
body: z.ZodString;
|
|
122
|
-
}, z.core.$strict>>>;
|
|
123
|
-
}, z.core.$strict>>;
|
|
124
|
-
}, z.core.$strict>;
|
|
125
|
-
declare const ProfileBody: z.ZodObject<{
|
|
126
|
-
avatar: z.ZodOptional<z.ZodNullable<z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
127
|
-
kind: z.ZodLiteral<"preset">;
|
|
128
|
-
id: z.ZodEnum<{
|
|
129
|
-
"black-bear": "black-bear";
|
|
130
|
-
capybara: "capybara";
|
|
131
|
-
elephant: "elephant";
|
|
132
|
-
fox: "fox";
|
|
133
|
-
owl: "owl";
|
|
134
|
-
panda: "panda";
|
|
135
|
-
penguin: "penguin";
|
|
136
|
-
rabbit: "rabbit";
|
|
137
|
-
turtle: "turtle";
|
|
138
|
-
whale: "whale";
|
|
139
|
-
}>;
|
|
140
|
-
}, z.core.$strict>, z.ZodObject<{
|
|
141
|
-
kind: z.ZodLiteral<"upload">;
|
|
142
|
-
uploadId: z.ZodString;
|
|
143
|
-
}, z.core.$strict>], "kind">>>;
|
|
144
|
-
description: z.ZodOptional<z.ZodString>;
|
|
145
|
-
quickActions: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
146
|
-
title: z.ZodString;
|
|
147
|
-
body: z.ZodString;
|
|
148
|
-
}, z.core.$strict>>>;
|
|
149
|
-
expectedUpdatedAt: z.ZodString;
|
|
150
|
-
}, z.core.$strict>;
|
|
151
14
|
declare const AvatarUploadBody: z.ZodObject<{
|
|
152
15
|
name: z.ZodString;
|
|
153
16
|
contentType: z.ZodEnum<{
|
|
@@ -157,149 +20,6 @@ declare const AvatarUploadBody: z.ZodObject<{
|
|
|
157
20
|
}>;
|
|
158
21
|
size: z.ZodNumber;
|
|
159
22
|
}, z.core.$strict>;
|
|
160
|
-
declare const UpdateBody: z.ZodObject<{
|
|
161
|
-
definition: z.ZodOptional<z.ZodObject<{
|
|
162
|
-
name: z.ZodString;
|
|
163
|
-
avatarUrl: z.ZodDefault<z.ZodNullable<z.ZodURL>>;
|
|
164
|
-
instructionFiles: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
165
|
-
name: z.ZodString;
|
|
166
|
-
content: z.ZodString;
|
|
167
|
-
}, z.core.$strict>>>;
|
|
168
|
-
model: z.ZodObject<{
|
|
169
|
-
provider: z.ZodString;
|
|
170
|
-
model: z.ZodString;
|
|
171
|
-
}, z.core.$strip>;
|
|
172
|
-
fallback: z.ZodDefault<z.ZodNullable<z.ZodObject<{
|
|
173
|
-
provider: z.ZodString;
|
|
174
|
-
model: z.ZodString;
|
|
175
|
-
}, z.core.$strip>>>;
|
|
176
|
-
modelParams: z.ZodDefault<z.ZodRecord<z.ZodString, z.ZodUnion<readonly [z.ZodString, z.ZodNumber, z.ZodBoolean]>>>;
|
|
177
|
-
fallbackParams: z.ZodDefault<z.ZodRecord<z.ZodString, z.ZodUnion<readonly [z.ZodString, z.ZodNumber, z.ZodBoolean]>>>;
|
|
178
|
-
tools: z.ZodDefault<z.ZodArray<z.ZodPreprocess<z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
179
|
-
kind: z.ZodLiteral<"builtin">;
|
|
180
|
-
name: z.ZodString;
|
|
181
|
-
}, z.core.$strict>, z.ZodObject<{
|
|
182
|
-
kind: z.ZodLiteral<"plugin">;
|
|
183
|
-
plugin: z.ZodString;
|
|
184
|
-
name: z.ZodString;
|
|
185
|
-
}, z.core.$strict>, z.ZodObject<{
|
|
186
|
-
kind: z.ZodLiteral<"connector">;
|
|
187
|
-
connectorId: z.ZodString;
|
|
188
|
-
tools: z.ZodUnion<readonly [z.ZodLiteral<"all">, z.ZodArray<z.ZodString>]>;
|
|
189
|
-
}, z.core.$strict>], "kind">, unknown>>>;
|
|
190
|
-
toolPolicies: z.ZodDefault<z.ZodRecord<z.ZodString, z.ZodEnum<{
|
|
191
|
-
ask: "ask";
|
|
192
|
-
deny: "deny";
|
|
193
|
-
}>>>;
|
|
194
|
-
skills: z.ZodOptional<z.ZodObject<{
|
|
195
|
-
orgSkills: z.ZodDefault<z.ZodArray<z.ZodString>>;
|
|
196
|
-
writePolicy: z.ZodOptional<z.ZodEnum<{
|
|
197
|
-
allow: "allow";
|
|
198
|
-
ask: "ask";
|
|
199
|
-
}>>;
|
|
200
|
-
pinned: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
201
|
-
}, z.core.$strict>>;
|
|
202
|
-
subagents: z.ZodOptional<z.ZodObject<{
|
|
203
|
-
general: z.ZodOptional<z.ZodBoolean>;
|
|
204
|
-
templates: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
205
|
-
inline: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
206
|
-
name: z.ZodString;
|
|
207
|
-
description: z.ZodString;
|
|
208
|
-
instructions: z.ZodString;
|
|
209
|
-
tools: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
210
|
-
disallowedTools: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
211
|
-
toolPolicies: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodEnum<{
|
|
212
|
-
ask: "ask";
|
|
213
|
-
deny: "deny";
|
|
214
|
-
}>>>;
|
|
215
|
-
model: z.ZodOptional<z.ZodEnum<{
|
|
216
|
-
capable: "capable";
|
|
217
|
-
fast: "fast";
|
|
218
|
-
inherit: "inherit";
|
|
219
|
-
standard: "standard";
|
|
220
|
-
}>>;
|
|
221
|
-
effort: z.ZodOptional<z.ZodEnum<{
|
|
222
|
-
high: "high";
|
|
223
|
-
low: "low";
|
|
224
|
-
max: "max";
|
|
225
|
-
medium: "medium";
|
|
226
|
-
xhigh: "xhigh";
|
|
227
|
-
}>>;
|
|
228
|
-
maxSteps: z.ZodOptional<z.ZodNumber>;
|
|
229
|
-
skills: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
230
|
-
}, z.core.$strict>>>;
|
|
231
|
-
agents: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
232
|
-
agentId: z.ZodString;
|
|
233
|
-
as: z.ZodString;
|
|
234
|
-
description: z.ZodString;
|
|
235
|
-
}, z.core.$strict>>>;
|
|
236
|
-
dispatchable: z.ZodOptional<z.ZodBoolean>;
|
|
237
|
-
}, z.core.$strict>>;
|
|
238
|
-
pendingConnectors: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
239
|
-
key: z.ZodString;
|
|
240
|
-
label: z.ZodString;
|
|
241
|
-
source: z.ZodUnion<readonly [z.ZodObject<{
|
|
242
|
-
template: z.ZodString;
|
|
243
|
-
}, z.core.$strict>, z.ZodObject<{
|
|
244
|
-
needs: z.ZodObject<{
|
|
245
|
-
protocol: z.ZodEnum<{
|
|
246
|
-
mcp: "mcp";
|
|
247
|
-
openapi: "openapi";
|
|
248
|
-
}>;
|
|
249
|
-
endpoint: z.ZodString;
|
|
250
|
-
tools: z.ZodArray<z.ZodString>;
|
|
251
|
-
label: z.ZodString;
|
|
252
|
-
}, z.core.$strict>;
|
|
253
|
-
}, z.core.$strict>]>;
|
|
254
|
-
tools: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
255
|
-
policies: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodEnum<{
|
|
256
|
-
ask: "ask";
|
|
257
|
-
deny: "deny";
|
|
258
|
-
}>>>;
|
|
259
|
-
}, z.core.$strict>>>;
|
|
260
|
-
instructions: z.ZodOptional<z.ZodString>;
|
|
261
|
-
}, z.core.$strip>>;
|
|
262
|
-
visibility: z.ZodOptional<z.ZodEnum<{
|
|
263
|
-
members: "members";
|
|
264
|
-
org: "org";
|
|
265
|
-
private: "private";
|
|
266
|
-
}>>;
|
|
267
|
-
memberIds: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
268
|
-
expectedVersion: z.ZodOptional<z.ZodNumber>;
|
|
269
|
-
}, z.core.$strict>;
|
|
270
|
-
declare const FromTemplatePreviewBody: z.ZodObject<{
|
|
271
|
-
templateId: z.ZodString;
|
|
272
|
-
}, z.core.$strict>;
|
|
273
|
-
declare const FromTemplateBody: z.ZodObject<{
|
|
274
|
-
templateId: z.ZodString;
|
|
275
|
-
name: z.ZodString;
|
|
276
|
-
visibility: z.ZodOptional<z.ZodEnum<{
|
|
277
|
-
members: "members";
|
|
278
|
-
org: "org";
|
|
279
|
-
private: "private";
|
|
280
|
-
}>>;
|
|
281
|
-
members: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
282
|
-
model: z.ZodOptional<z.ZodObject<{
|
|
283
|
-
provider: z.ZodString;
|
|
284
|
-
model: z.ZodString;
|
|
285
|
-
}, z.core.$strict>>;
|
|
286
|
-
avatar: z.ZodOptional<z.ZodObject<{
|
|
287
|
-
kind: z.ZodLiteral<"preset">;
|
|
288
|
-
id: z.ZodEnum<{
|
|
289
|
-
"black-bear": "black-bear";
|
|
290
|
-
capybara: "capybara";
|
|
291
|
-
elephant: "elephant";
|
|
292
|
-
fox: "fox";
|
|
293
|
-
owl: "owl";
|
|
294
|
-
panda: "panda";
|
|
295
|
-
penguin: "penguin";
|
|
296
|
-
rabbit: "rabbit";
|
|
297
|
-
turtle: "turtle";
|
|
298
|
-
whale: "whale";
|
|
299
|
-
}>;
|
|
300
|
-
}, z.core.$strict>>;
|
|
301
|
-
previewHash: z.ZodString;
|
|
302
|
-
}, z.core.$strict>;
|
|
303
23
|
/**
|
|
304
24
|
* Agent 定义(`/api/v1/orgs/:orgId/agents`)。读用 `agents.use`(访客与服务令牌可用),
|
|
305
25
|
* 写用 `agents.create`(member 以上、HUMAN_ONLY),修改 / 删除的负责人或管理员判定在服务的组织行锁内完成。
|
|
@@ -318,17 +38,17 @@ export declare class AgentsController {
|
|
|
318
38
|
* template fields with no place in the agent, and the `previewHash` the create must send. A
|
|
319
39
|
* template not usable in the org → 404 `component.not_found`.
|
|
320
40
|
*/
|
|
321
|
-
previewFromTemplate(org: OrgContext, body: z.infer<typeof
|
|
41
|
+
previewFromTemplate(org: OrgContext, body: z.infer<typeof AgentFromTemplatePreviewBody>): Promise<TemplatePreview>;
|
|
322
42
|
/**
|
|
323
43
|
* Creates an agent from a template (ruling P4-3): private by default; another visibility without
|
|
324
44
|
* `agents.manage` → 403 `agent.visibility_forbidden`; a plan that no longer matches the preview →
|
|
325
45
|
* 409 `agent.template_preview_stale`. The agent records its provenance (P4-8) and carries the
|
|
326
46
|
* template's missing connectors as `pendingConnectors` (P4-6).
|
|
327
47
|
*/
|
|
328
|
-
createFromTemplate(principal: Principal, org: OrgContext, body: z.infer<typeof
|
|
48
|
+
createFromTemplate(principal: Principal, org: OrgContext, body: z.infer<typeof AgentFromTemplateBody>): Promise<{
|
|
329
49
|
agent: AgentView;
|
|
330
50
|
}>;
|
|
331
|
-
create(principal: Principal, org: OrgContext, body: z.infer<typeof
|
|
51
|
+
create(principal: Principal, org: OrgContext, body: z.infer<typeof AgentCreateBody>): Promise<{
|
|
332
52
|
agent: AgentView;
|
|
333
53
|
warnings: AgentWarning[];
|
|
334
54
|
}>;
|
|
@@ -338,12 +58,12 @@ export declare class AgentsController {
|
|
|
338
58
|
get(principal: Principal, org: OrgContext, agentId: string): Promise<{
|
|
339
59
|
agent: AgentView;
|
|
340
60
|
}>;
|
|
341
|
-
update(principal: Principal, org: OrgContext, agentId: string, body: z.infer<typeof
|
|
61
|
+
update(principal: Principal, org: OrgContext, agentId: string, body: z.infer<typeof AgentUpdateBody>): Promise<{
|
|
342
62
|
agent: AgentView;
|
|
343
63
|
warnings: AgentWarning[];
|
|
344
64
|
}>;
|
|
345
65
|
/** Display data only: no agent version. Same permission as `PATCH :agentId`. */
|
|
346
|
-
updateProfile(principal: Principal, org: OrgContext, agentId: string, body: z.infer<typeof
|
|
66
|
+
updateProfile(principal: Principal, org: OrgContext, agentId: string, body: z.infer<typeof AgentProfileBody>): Promise<{
|
|
347
67
|
profile: AgentProfile;
|
|
348
68
|
}>;
|
|
349
69
|
/**
|
|
@@ -17,37 +17,10 @@ import { createZodDto } from "../infra/validation/create-zod-dto.js";
|
|
|
17
17
|
import { ZBody } from "../infra/validation/zod-params.js";
|
|
18
18
|
import { CurrentOrg, OrgAction } from "../orgs/org.guard.js";
|
|
19
19
|
import { AgentProfileService } from "./agent-profile.service.js";
|
|
20
|
-
import {
|
|
21
|
-
import {
|
|
20
|
+
import { AgentCreateBody, AgentFromTemplateBody, AgentFromTemplatePreviewBody, AgentProfileBody, AgentUpdateBody, } from "./agents.schemas.js";
|
|
21
|
+
import { AgentsService, } from "./agents.service.js";
|
|
22
22
|
import { AgentsFromTemplate } from "./from-template.service.js";
|
|
23
|
-
import { PRESET_IDS, ProfileInputSchema } from "./profile.js";
|
|
24
|
-
const MemberIds = z.array(z.string().min(1).max(100)).max(1000);
|
|
25
23
|
const OwnerBody = z.object({ accountId: z.string().min(1).max(100) }).strict();
|
|
26
|
-
/** 创建时未给 `tools` → 默认工具(Ruling P7);修改请求不注入默认值,版本里总是存显式的 tools。 */
|
|
27
|
-
/**
|
|
28
|
-
* `instructions` has no default in a request: with `instructionFiles` the kernel derives it, and a
|
|
29
|
-
* new agent given neither gets the `AGENTS.md` starter (`deriveInstructions`).
|
|
30
|
-
*/
|
|
31
|
-
const RequestInstructions = z.string().max(100_000).optional();
|
|
32
|
-
/** Pending connectors come only from a template (ruling P4-6): a create request's are dropped. */
|
|
33
|
-
const CreateDefinition = AgentDefinitionSchema.omit({ pendingConnectors: true }).extend({
|
|
34
|
-
instructions: RequestInstructions,
|
|
35
|
-
tools: z.array(AgentToolRef).default(() => structuredClone(DEFAULT_AGENT_TOOLS)),
|
|
36
|
-
});
|
|
37
|
-
const UpdateDefinition = AgentDefinitionSchema.extend({ instructions: RequestInstructions });
|
|
38
|
-
const CreateBody = z
|
|
39
|
-
.object({
|
|
40
|
-
definition: CreateDefinition,
|
|
41
|
-
visibility: z.enum(AGENT_VISIBILITIES),
|
|
42
|
-
memberIds: MemberIds.optional(),
|
|
43
|
-
/** Without an avatar the agent gets a random preset. */
|
|
44
|
-
profile: ProfileInputSchema.optional(),
|
|
45
|
-
})
|
|
46
|
-
.strict();
|
|
47
|
-
const ProfileBody = ProfileInputSchema.extend({
|
|
48
|
-
/** The `profile.updatedAt` the client read; a different one → 409 `agent.profile_conflict`. */
|
|
49
|
-
expectedUpdatedAt: z.string().min(1).max(40),
|
|
50
|
-
}).strict();
|
|
51
24
|
const AvatarUploadBody = z
|
|
52
25
|
.object({
|
|
53
26
|
name: z
|
|
@@ -59,54 +32,21 @@ const AvatarUploadBody = z
|
|
|
59
32
|
size: z.number().int().min(1).max(AGENT_AVATAR_MAX_BYTES),
|
|
60
33
|
})
|
|
61
34
|
.strict();
|
|
62
|
-
const UpdateBody = z
|
|
63
|
-
.object({
|
|
64
|
-
definition: UpdateDefinition.optional(),
|
|
65
|
-
visibility: z.enum(AGENT_VISIBILITIES).optional(),
|
|
66
|
-
memberIds: MemberIds.optional(),
|
|
67
|
-
/**
|
|
68
|
-
* 乐观并发:编辑页打开时读到的 `currentVersion`。给出且与当前版本不同(别人已保存过)→ 409
|
|
69
|
-
* `agent.version_conflict`,不覆盖别人的改动。不给时不检查(旧客户端)。
|
|
70
|
-
*/
|
|
71
|
-
expectedVersion: z.number().int().positive().optional(),
|
|
72
|
-
})
|
|
73
|
-
.strict();
|
|
74
|
-
const TemplateId = z.string().min(1).max(100);
|
|
75
|
-
const FromTemplatePreviewBody = z.object({ templateId: TemplateId }).strict();
|
|
76
|
-
const FromTemplateBody = z
|
|
77
|
-
.object({
|
|
78
|
-
templateId: TemplateId,
|
|
79
|
-
name: z.string().min(1).max(80),
|
|
80
|
-
/** Default `private`; anything else needs `agents.manage` (ruling P4-3). */
|
|
81
|
-
visibility: z.enum(AGENT_VISIBILITIES).optional(),
|
|
82
|
-
/** The accounts of a `members` agent. */
|
|
83
|
-
members: MemberIds.optional(),
|
|
84
|
-
/** The person's choice; absent = the template's model resolution (P4-4). */
|
|
85
|
-
model: ModelRef.strict().optional(),
|
|
86
|
-
/** A preset avatar; absent = a random one. */
|
|
87
|
-
avatar: z
|
|
88
|
-
.object({ kind: z.literal("preset"), id: z.enum(PRESET_IDS) })
|
|
89
|
-
.strict()
|
|
90
|
-
.optional(),
|
|
91
|
-
/** The preview's `previewHash`; another one → 409 `agent.template_preview_stale`. */
|
|
92
|
-
previewHash: z.string().regex(/^[0-9a-f]{64}\.[0-9a-f]{16}$/),
|
|
93
|
-
})
|
|
94
|
-
.strict();
|
|
95
35
|
/** 服务令牌没有账号:以 null 作为 viewer,只看到 visibility='org' 的 agent。 */
|
|
96
36
|
const viewerOf = (p) => (p.kind === "user" ? p.account.id : null);
|
|
97
|
-
class AgentCreateBodyDto extends createZodDto(
|
|
37
|
+
class AgentCreateBodyDto extends createZodDto(AgentCreateBody, "AgentCreateBody") {
|
|
98
38
|
}
|
|
99
|
-
class AgentUpdateBodyDto extends createZodDto(
|
|
39
|
+
class AgentUpdateBodyDto extends createZodDto(AgentUpdateBody, "AgentUpdateBody") {
|
|
100
40
|
}
|
|
101
|
-
class AgentProfileBodyDto extends createZodDto(
|
|
41
|
+
class AgentProfileBodyDto extends createZodDto(AgentProfileBody, "AgentProfileBody") {
|
|
102
42
|
}
|
|
103
43
|
class AgentAvatarUploadBodyDto extends createZodDto(AvatarUploadBody, "AgentAvatarUploadBody") {
|
|
104
44
|
}
|
|
105
45
|
class AgentOwnerBodyDto extends createZodDto(OwnerBody, "AgentOwnerBody") {
|
|
106
46
|
}
|
|
107
|
-
class AgentFromTemplatePreviewBodyDto extends createZodDto(
|
|
47
|
+
class AgentFromTemplatePreviewBodyDto extends createZodDto(AgentFromTemplatePreviewBody, "AgentFromTemplatePreviewBody") {
|
|
108
48
|
}
|
|
109
|
-
class AgentFromTemplateBodyDto extends createZodDto(
|
|
49
|
+
class AgentFromTemplateBodyDto extends createZodDto(AgentFromTemplateBody, "AgentFromTemplateBody") {
|
|
110
50
|
}
|
|
111
51
|
/**
|
|
112
52
|
* Agent 定义(`/api/v1/orgs/:orgId/agents`)。读用 `agents.use`(访客与服务令牌可用),
|