@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
|
@@ -1,35 +1,9 @@
|
|
|
1
|
-
import { z } from "zod";
|
|
1
|
+
import type { z } from "zod";
|
|
2
2
|
import type { JsonSchema } from "../extensions/config-json-schema.js";
|
|
3
3
|
import { type Principal } from "../identity/principal.js";
|
|
4
4
|
import { type OrgContext } from "../orgs/org.guard.js";
|
|
5
|
+
import { ChannelCreateSchema as CreateBody, ChannelPatchSchema as PatchBody } from "./channels.schemas.js";
|
|
5
6
|
import { ChannelConnections, type ChannelConnectionView } from "./connections.service.js";
|
|
6
|
-
declare const CreateBody: z.ZodObject<{
|
|
7
|
-
plugin: z.ZodString;
|
|
8
|
-
name: z.ZodString;
|
|
9
|
-
agentId: z.ZodString;
|
|
10
|
-
config: z.ZodRecord<z.ZodString, z.ZodUnknown>;
|
|
11
|
-
unboundPolicy: z.ZodOptional<z.ZodEnum<{
|
|
12
|
-
anonymous: "anonymous";
|
|
13
|
-
bind: "bind";
|
|
14
|
-
}>>;
|
|
15
|
-
}, z.core.$strict>;
|
|
16
|
-
declare const PatchBody: z.ZodObject<{
|
|
17
|
-
name: z.ZodOptional<z.ZodString>;
|
|
18
|
-
agentId: z.ZodOptional<z.ZodString>;
|
|
19
|
-
unboundPolicy: z.ZodOptional<z.ZodEnum<{
|
|
20
|
-
anonymous: "anonymous";
|
|
21
|
-
bind: "bind";
|
|
22
|
-
}>>;
|
|
23
|
-
status: z.ZodOptional<z.ZodEnum<{
|
|
24
|
-
active: "active";
|
|
25
|
-
disabled: "disabled";
|
|
26
|
-
}>>;
|
|
27
|
-
inboundMode: z.ZodOptional<z.ZodEnum<{
|
|
28
|
-
long_connection: "long_connection";
|
|
29
|
-
webhook: "webhook";
|
|
30
|
-
}>>;
|
|
31
|
-
config: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
|
|
32
|
-
}, z.core.$strict>;
|
|
33
7
|
/**
|
|
34
8
|
* 组织的渠道连接(`/api/v1/orgs/:orgId/channels`),全部需要 `channels.manage`(admin,仅限人)。
|
|
35
9
|
* 响应只回显非密钥配置与密钥是否已设置。
|
|
@@ -56,4 +30,3 @@ export declare class ChannelConnectionsController {
|
|
|
56
30
|
}>;
|
|
57
31
|
remove(principal: Principal, org: OrgContext, id: string): Promise<void>;
|
|
58
32
|
}
|
|
59
|
-
export {};
|
|
@@ -8,34 +8,12 @@ var __param = (this && this.__param) || function (paramIndex, decorator) {
|
|
|
8
8
|
return function (target, key) { decorator(target, key, paramIndex); }
|
|
9
9
|
};
|
|
10
10
|
import { Controller, Delete, Get, HttpCode, Inject, Param, Patch, Post } from "@nestjs/common";
|
|
11
|
-
import { z } from "zod";
|
|
12
11
|
import { CurrentPrincipal, patTokenId, requireUser, } from "../identity/principal.js";
|
|
13
12
|
import { createZodDto } from "../infra/validation/create-zod-dto.js";
|
|
14
13
|
import { ZBody } from "../infra/validation/zod-params.js";
|
|
15
14
|
import { CurrentOrg, OrgAction } from "../orgs/org.guard.js";
|
|
15
|
+
import { ChannelCreateSchema as CreateBody, ChannelPatchSchema as PatchBody, } from "./channels.schemas.js";
|
|
16
16
|
import { ChannelConnections } from "./connections.service.js";
|
|
17
|
-
const Config = z.record(z.string().max(200), z.unknown());
|
|
18
|
-
const Policy = z.enum(["bind", "anonymous"]);
|
|
19
|
-
const CreateBody = z
|
|
20
|
-
.object({
|
|
21
|
-
plugin: z.string().min(1).max(214),
|
|
22
|
-
name: z.string().trim().min(1).max(100),
|
|
23
|
-
agentId: z.string().min(1).max(100),
|
|
24
|
-
config: Config,
|
|
25
|
-
unboundPolicy: Policy.optional(),
|
|
26
|
-
})
|
|
27
|
-
.strict();
|
|
28
|
-
const PatchBody = z
|
|
29
|
-
.object({
|
|
30
|
-
name: z.string().trim().min(1).max(100).optional(),
|
|
31
|
-
agentId: z.string().min(1).max(100).optional(),
|
|
32
|
-
unboundPolicy: Policy.optional(),
|
|
33
|
-
status: z.enum(["active", "disabled"]).optional(),
|
|
34
|
-
// webhook needs plugin support and channels.webhookBaseUrl (409 channel.webhook_unavailable)
|
|
35
|
-
inboundMode: z.enum(["long_connection", "webhook"]).optional(),
|
|
36
|
-
config: Config.optional(),
|
|
37
|
-
})
|
|
38
|
-
.strict();
|
|
39
17
|
class ChannelCreateBody extends createZodDto(CreateBody, "ChannelCreateBody") {
|
|
40
18
|
}
|
|
41
19
|
class ChannelPatchBody extends createZodDto(PatchBody, "ChannelPatchBody") {
|
|
@@ -159,18 +159,24 @@ export declare class ChannelConnections implements OnApplicationShutdown {
|
|
|
159
159
|
create(orgId: string, input: CreateChannelInput, actorAccountId: string, actorTokenId?: string): Promise<ChannelConnectionView>;
|
|
160
160
|
/** The rows of {@link create}, in their own transaction (the caller publishes after the commit). */
|
|
161
161
|
private insertIn;
|
|
162
|
+
/** The read-only refusals of {@link update} that need no write (the Platform tool's precheck). */
|
|
163
|
+
checkUpdate(orgId: string, id: string, patch: UpdateChannelInput): Promise<void>;
|
|
162
164
|
/**
|
|
163
165
|
* 修改名称、agent、未绑定策略、启停,或轮换凭据(新配置同样先 `verify`,失败什么都不改)。
|
|
164
166
|
* 插件在该组织停用时仍可轮换凭据,此时不 verify,返回 `verifySkipped: true`。
|
|
165
167
|
*/
|
|
166
|
-
update(orgId: string, id: string, patch: UpdateChannelInput, actorAccountId: string, actorTokenId?: string
|
|
168
|
+
update(orgId: string, id: string, patch: UpdateChannelInput, actorAccountId: string, actorTokenId?: string,
|
|
169
|
+
/** Merged into the audit detail (the Platform tool's `via: "agent"`). */
|
|
170
|
+
auditDetail?: Record<string, unknown>): Promise<{
|
|
167
171
|
channel: ChannelConnectionView;
|
|
168
172
|
verifySkipped: boolean;
|
|
169
173
|
}>;
|
|
170
174
|
/** The rows of {@link update}, in their own transaction (the caller publishes after the commit). */
|
|
171
175
|
private updateIn;
|
|
172
176
|
/** 删除(软删除,同一事务删掉密钥);持有长连接的副本收到广播后断开。 */
|
|
173
|
-
remove(orgId: string, id: string, actorAccountId: string, actorTokenId?: string
|
|
177
|
+
remove(orgId: string, id: string, actorAccountId: string, actorTokenId?: string,
|
|
178
|
+
/** Merged into the audit detail (the Platform tool's `via: "agent"`). */
|
|
179
|
+
auditDetail?: Record<string, unknown>): Promise<void>;
|
|
174
180
|
/** The rows of {@link remove}, in their own transaction (the caller publishes after the commit). */
|
|
175
181
|
private removeIn;
|
|
176
182
|
/** 提交后广播;失败只记日志(持有方每轮续租时也会复核连接状态)。 */
|
|
@@ -376,11 +376,24 @@ let ChannelConnections = class ChannelConnections {
|
|
|
376
376
|
});
|
|
377
377
|
return inserted;
|
|
378
378
|
}
|
|
379
|
+
/** The read-only refusals of {@link update} that need no write (the Platform tool's precheck). */
|
|
380
|
+
async checkUpdate(orgId, id, patch) {
|
|
381
|
+
const current = await this.live(orgId).where("id", "=", id).executeTakeFirst();
|
|
382
|
+
if (!current)
|
|
383
|
+
throw notFound();
|
|
384
|
+
if (patch.agentId !== undefined)
|
|
385
|
+
await this.assertAgent(orgId, patch.agentId);
|
|
386
|
+
if (patch.inboundMode === "webhook" && patch.inboundMode !== current.inbound_mode) {
|
|
387
|
+
this.assertWebhookAvailable(current.plugin);
|
|
388
|
+
}
|
|
389
|
+
}
|
|
379
390
|
/**
|
|
380
391
|
* 修改名称、agent、未绑定策略、启停,或轮换凭据(新配置同样先 `verify`,失败什么都不改)。
|
|
381
392
|
* 插件在该组织停用时仍可轮换凭据,此时不 verify,返回 `verifySkipped: true`。
|
|
382
393
|
*/
|
|
383
|
-
async update(orgId, id, patch, actorAccountId, actorTokenId
|
|
394
|
+
async update(orgId, id, patch, actorAccountId, actorTokenId,
|
|
395
|
+
/** Merged into the audit detail (the Platform tool's `via: "agent"`). */
|
|
396
|
+
auditDetail) {
|
|
384
397
|
const current = await this.live(orgId).where("id", "=", id).executeTakeFirst();
|
|
385
398
|
if (!current)
|
|
386
399
|
throw notFound();
|
|
@@ -421,6 +434,7 @@ let ChannelConnections = class ChannelConnections {
|
|
|
421
434
|
verified,
|
|
422
435
|
actorAccountId,
|
|
423
436
|
actorTokenId,
|
|
437
|
+
auditDetail,
|
|
424
438
|
});
|
|
425
439
|
if (rotated)
|
|
426
440
|
this.reportSecrets(rotated.schema, rotated.full);
|
|
@@ -443,7 +457,7 @@ let ChannelConnections = class ChannelConnections {
|
|
|
443
457
|
}
|
|
444
458
|
/** The rows of {@link update}, in their own transaction (the caller publishes after the commit). */
|
|
445
459
|
async updateIn(a) {
|
|
446
|
-
const { orgId, id, patch, rotated, verified, actorAccountId, actorTokenId } = a;
|
|
460
|
+
const { orgId, id, patch, rotated, verified, actorAccountId, actorTokenId, auditDetail } = a;
|
|
447
461
|
await this.orgLock.lockAndAuthorize(orgId, actorAccountId, "channels.manage");
|
|
448
462
|
if (patch.agentId !== undefined)
|
|
449
463
|
await this.assertAgent(orgId, patch.agentId);
|
|
@@ -488,17 +502,20 @@ let ChannelConnections = class ChannelConnections {
|
|
|
488
502
|
...Object.keys(patch).filter((k) => k !== "config" && patch[k] !== undefined),
|
|
489
503
|
...(rotated ? ["config"] : []),
|
|
490
504
|
],
|
|
505
|
+
...auditDetail,
|
|
491
506
|
},
|
|
492
507
|
});
|
|
493
508
|
return updated;
|
|
494
509
|
}
|
|
495
510
|
/** 删除(软删除,同一事务删掉密钥);持有长连接的副本收到广播后断开。 */
|
|
496
|
-
async remove(orgId, id, actorAccountId, actorTokenId
|
|
497
|
-
|
|
511
|
+
async remove(orgId, id, actorAccountId, actorTokenId,
|
|
512
|
+
/** Merged into the audit detail (the Platform tool's `via: "agent"`). */
|
|
513
|
+
auditDetail) {
|
|
514
|
+
await this.removeIn(orgId, id, actorAccountId, actorTokenId, auditDetail);
|
|
498
515
|
await this.changed(id, true);
|
|
499
516
|
}
|
|
500
517
|
/** The rows of {@link remove}, in their own transaction (the caller publishes after the commit). */
|
|
501
|
-
async removeIn(orgId, id, actorAccountId, actorTokenId) {
|
|
518
|
+
async removeIn(orgId, id, actorAccountId, actorTokenId, auditDetail) {
|
|
502
519
|
await this.orgLock.lockAndAuthorize(orgId, actorAccountId, "channels.manage");
|
|
503
520
|
const r = await this.db
|
|
504
521
|
.updateTable("channel_connections")
|
|
@@ -516,6 +533,7 @@ let ChannelConnections = class ChannelConnections {
|
|
|
516
533
|
orgId,
|
|
517
534
|
action: "channel.deleted",
|
|
518
535
|
target: id,
|
|
536
|
+
...(auditDetail !== undefined && { detail: auditDetail }),
|
|
519
537
|
});
|
|
520
538
|
}
|
|
521
539
|
/** 提交后广播;失败只记日志(持有方每轮续租时也会复核连接状态)。 */
|
package/dist/channels/inbound.js
CHANGED
|
@@ -243,6 +243,10 @@ let ChannelInbound = class ChannelInbound {
|
|
|
243
243
|
const posted = await this.post(row.orgId, conversationId, accountId, {
|
|
244
244
|
text: e.text,
|
|
245
245
|
clientMessageId: `${connectionId}:${e.messageId}`,
|
|
246
|
+
// run context spec §7: an anonymous guest is named by their IM profile name; a bound
|
|
247
|
+
// person by their account's name (the kernel reads it)
|
|
248
|
+
...(threadAccount === null &&
|
|
249
|
+
e.sender.displayName !== undefined && { senderName: e.sender.displayName }),
|
|
246
250
|
});
|
|
247
251
|
seq = posted.event.seq;
|
|
248
252
|
// best-effort (batch 5 review m4): a failed note must not fail the job before the thread
|
package/dist/config/schema.d.ts
CHANGED
|
@@ -232,6 +232,10 @@ export declare const KernelConfigSchema: z.ZodObject<{
|
|
|
232
232
|
judgeMaxOutputTokens: z.ZodDefault<z.ZodNumber>;
|
|
233
233
|
maxConsecutiveErrors: z.ZodDefault<z.ZodNumber>;
|
|
234
234
|
}, z.core.$strip>>;
|
|
235
|
+
models: z.ZodPrefault<z.ZodObject<{
|
|
236
|
+
listTimeoutMs: z.ZodDefault<z.ZodNumber>;
|
|
237
|
+
embedTimeoutMs: z.ZodDefault<z.ZodNumber>;
|
|
238
|
+
}, z.core.$strip>>;
|
|
235
239
|
hooks: z.ZodPrefault<z.ZodObject<{
|
|
236
240
|
timeoutMs: z.ZodDefault<z.ZodNumber>;
|
|
237
241
|
usageReportConcurrency: z.ZodDefault<z.ZodNumber>;
|
package/dist/config/schema.js
CHANGED
|
@@ -1252,6 +1252,30 @@ export const KernelConfigSchema = z.object({
|
|
|
1252
1252
|
path: ["defaultTokenCap"],
|
|
1253
1253
|
})
|
|
1254
1254
|
.prefault({}),
|
|
1255
|
+
models: z
|
|
1256
|
+
.object({
|
|
1257
|
+
listTimeoutMs: z
|
|
1258
|
+
.number()
|
|
1259
|
+
.int()
|
|
1260
|
+
.positive()
|
|
1261
|
+
.max(300_000)
|
|
1262
|
+
.default(10_000)
|
|
1263
|
+
.meta(meta({
|
|
1264
|
+
hot: true,
|
|
1265
|
+
description: "Time limit in milliseconds for one model provider's model list (listModels, which may page through a large platform catalog); a provider that exceeds it is treated as failing to list",
|
|
1266
|
+
})),
|
|
1267
|
+
embedTimeoutMs: z
|
|
1268
|
+
.number()
|
|
1269
|
+
.int()
|
|
1270
|
+
.positive()
|
|
1271
|
+
.max(600_000)
|
|
1272
|
+
.default(60_000)
|
|
1273
|
+
.meta(meta({
|
|
1274
|
+
hot: true,
|
|
1275
|
+
description: "Time limit in milliseconds for one embed call to a model provider (one batch of an extension's ctx.models.embed); the call is aborted and fails with a timeout model error",
|
|
1276
|
+
})),
|
|
1277
|
+
})
|
|
1278
|
+
.prefault({}),
|
|
1255
1279
|
hooks: z
|
|
1256
1280
|
.object({
|
|
1257
1281
|
timeoutMs: z
|
|
@@ -6,6 +6,7 @@ import { type OrgContext } from "../orgs/org.guard.js";
|
|
|
6
6
|
import { ConversationToolInfo, type ToolInfo } from "../tools/info.js";
|
|
7
7
|
import type { AgentTreeNode } from "./agent-tree.js";
|
|
8
8
|
import { type ArtifactPreview, ConversationArtifacts } from "./artifacts.js";
|
|
9
|
+
import { EventsQuery, FilesQuery, IdParams, ListQuery, PatchBody, SubagentsQuery } from "./conversations.schemas.js";
|
|
9
10
|
import { type ConversationGroup, ConversationsService, type ConversationView, type SubagentView, type UsageTotals } from "./conversations.service.js";
|
|
10
11
|
import { ConversationEnvironmentStatus } from "./environment-status.js";
|
|
11
12
|
import type { ConversationEvent } from "./events.js";
|
|
@@ -13,19 +14,6 @@ import { ConversationFiles, type FileOutput } from "./files.js";
|
|
|
13
14
|
import { ConversationOutputs, type OutputPage } from "./outputs-read.js";
|
|
14
15
|
import type { QueueItem, QueuePauseReason } from "./queue.js";
|
|
15
16
|
import { ConversationQueue } from "./queue.service.js";
|
|
16
|
-
declare const ListQuery: z.ZodObject<{
|
|
17
|
-
q: z.ZodOptional<z.ZodString>;
|
|
18
|
-
state: z.ZodOptional<z.ZodEnum<{
|
|
19
|
-
running: "running";
|
|
20
|
-
waiting: "waiting";
|
|
21
|
-
}>>;
|
|
22
|
-
archived: z.ZodOptional<z.ZodEnum<{
|
|
23
|
-
1: "1";
|
|
24
|
-
}>>;
|
|
25
|
-
after: z.ZodOptional<z.ZodString>;
|
|
26
|
-
limit: z.ZodDefault<z.ZodCoercedNumber<unknown>>;
|
|
27
|
-
agentId: z.ZodOptional<z.ZodString>;
|
|
28
|
-
}, z.core.$strip>;
|
|
29
17
|
declare const GroupsQuery: z.ZodObject<{
|
|
30
18
|
q: z.ZodOptional<z.ZodString>;
|
|
31
19
|
state: z.ZodOptional<z.ZodEnum<{
|
|
@@ -39,15 +27,6 @@ declare const GroupsQuery: z.ZodObject<{
|
|
|
39
27
|
limit: z.ZodDefault<z.ZodCoercedNumber<unknown>>;
|
|
40
28
|
after: z.ZodOptional<z.ZodString>;
|
|
41
29
|
}, z.core.$strip>;
|
|
42
|
-
declare const SubagentsQuery: z.ZodObject<{
|
|
43
|
-
after: z.ZodOptional<z.ZodString>;
|
|
44
|
-
limit: z.ZodDefault<z.ZodCoercedNumber<unknown>>;
|
|
45
|
-
}, z.core.$strip>;
|
|
46
|
-
declare const EventsQuery: z.ZodObject<{
|
|
47
|
-
after: z.ZodOptional<z.ZodCoercedNumber<unknown>>;
|
|
48
|
-
before: z.ZodOptional<z.ZodUnion<readonly [z.ZodLiteral<"end">, z.ZodCoercedNumber<unknown>]>>;
|
|
49
|
-
limit: z.ZodDefault<z.ZodCoercedNumber<unknown>>;
|
|
50
|
-
}, z.core.$strip>;
|
|
51
30
|
/** `?keys=a,b`: 1–100 comma-separated tool keys of 1–200 characters each. */
|
|
52
31
|
declare const ToolsQuery: z.ZodObject<{
|
|
53
32
|
keys: z.ZodPipe<z.ZodPipe<z.ZodString, z.ZodTransform<string[], string>>, z.ZodArray<z.ZodString>>;
|
|
@@ -56,10 +35,6 @@ declare const OutputQuery: z.ZodObject<{
|
|
|
56
35
|
offset: z.ZodDefault<z.ZodCoercedNumber<unknown>>;
|
|
57
36
|
limit: z.ZodDefault<z.ZodCoercedNumber<unknown>>;
|
|
58
37
|
}, z.core.$strip>;
|
|
59
|
-
declare const FilesQuery: z.ZodObject<{
|
|
60
|
-
after: z.ZodOptional<z.ZodString>;
|
|
61
|
-
limit: z.ZodDefault<z.ZodCoercedNumber<unknown>>;
|
|
62
|
-
}, z.core.$strip>;
|
|
63
38
|
declare const FileContentQuery: z.ZodObject<{
|
|
64
39
|
limit: z.ZodDefault<z.ZodCoercedNumber<unknown>>;
|
|
65
40
|
}, z.core.$strip>;
|
|
@@ -93,6 +68,11 @@ declare const MessageBody: z.ZodObject<{
|
|
|
93
68
|
skill: z.ZodOptional<z.ZodObject<{
|
|
94
69
|
name: z.ZodString;
|
|
95
70
|
}, z.core.$strict>>;
|
|
71
|
+
timeZone: z.ZodOptional<z.ZodString>;
|
|
72
|
+
locale: z.ZodOptional<z.ZodEnum<{
|
|
73
|
+
en: "en";
|
|
74
|
+
zh: "zh";
|
|
75
|
+
}>>;
|
|
96
76
|
}, z.core.$strict>;
|
|
97
77
|
/**
|
|
98
78
|
* `POST /conversations`: `message` creates the conversation with its first message (create on
|
|
@@ -125,6 +105,11 @@ declare const CreateBody: z.ZodObject<{
|
|
|
125
105
|
skill: z.ZodOptional<z.ZodObject<{
|
|
126
106
|
name: z.ZodString;
|
|
127
107
|
}, z.core.$strict>>;
|
|
108
|
+
timeZone: z.ZodOptional<z.ZodString>;
|
|
109
|
+
locale: z.ZodOptional<z.ZodEnum<{
|
|
110
|
+
en: "en";
|
|
111
|
+
zh: "zh";
|
|
112
|
+
}>>;
|
|
128
113
|
clientMessageId: z.ZodString;
|
|
129
114
|
}, z.core.$strict>>;
|
|
130
115
|
}, z.core.$strict>;
|
|
@@ -152,23 +137,17 @@ declare const QueueBody: z.ZodObject<{
|
|
|
152
137
|
skill: z.ZodOptional<z.ZodObject<{
|
|
153
138
|
name: z.ZodString;
|
|
154
139
|
}, z.core.$strict>>;
|
|
140
|
+
timeZone: z.ZodOptional<z.ZodString>;
|
|
141
|
+
locale: z.ZodOptional<z.ZodEnum<{
|
|
142
|
+
en: "en";
|
|
143
|
+
zh: "zh";
|
|
144
|
+
}>>;
|
|
155
145
|
clientMessageId: z.ZodString;
|
|
156
146
|
}, z.core.$strict>;
|
|
157
147
|
/** `PATCH …/queue/:itemId`: only the text changes (the text rule is checked against the item). */
|
|
158
148
|
declare const QueueEditBody: z.ZodObject<{
|
|
159
149
|
text: z.ZodString;
|
|
160
150
|
}, z.core.$strict>;
|
|
161
|
-
/**
|
|
162
|
-
* A rename: 1–120 characters counted in code points after trimming, with no control or format
|
|
163
|
-
* (bidi, zero-width) characters, the same rule generated and tool titles follow.
|
|
164
|
-
*/
|
|
165
|
-
declare const PatchBody: z.ZodObject<{
|
|
166
|
-
title: z.ZodOptional<z.ZodString>;
|
|
167
|
-
archived: z.ZodOptional<z.ZodBoolean>;
|
|
168
|
-
}, z.core.$strict>;
|
|
169
|
-
declare const IdParams: z.ZodObject<{
|
|
170
|
-
id: z.ZodString;
|
|
171
|
-
}, z.core.$strip>;
|
|
172
151
|
/**
|
|
173
152
|
* 会话(`/api/v1/orgs/:orgId/conversations`):`agents.use`(访客以上),只接受人类用户;
|
|
174
153
|
* 服务令牌 → 403 `forbidden`。只有会话所有者可见,其他人一律 `conversation.not_found`。
|
|
@@ -14,28 +14,15 @@ import { CurrentPrincipal, requireUser } from "../identity/principal.js";
|
|
|
14
14
|
import { createZodDto } from "../infra/validation/create-zod-dto.js";
|
|
15
15
|
import { ZBody, ZParam, ZQuery } from "../infra/validation/zod-params.js";
|
|
16
16
|
import { CurrentOrg, OrgAction } from "../orgs/org.guard.js";
|
|
17
|
-
import { CONTROL_OR_HIDDEN_RE } from "../text.js";
|
|
18
17
|
import { MAX_ATTACHMENTS } from "../tools/connector-content.js";
|
|
19
18
|
import { ConversationToolInfo, TOOL_INFO_KEY_MAX, TOOL_INFO_MAX_KEYS, } from "../tools/info.js";
|
|
20
19
|
import { ARTIFACT_DOWNLOAD_CACHE_SECONDS, ConversationArtifacts, } from "./artifacts.js";
|
|
21
|
-
import {
|
|
20
|
+
import { EventsQuery, FilesQuery, IdParams, ListQuery, PatchBody, SubagentsQuery, searchFields, } from "./conversations.schemas.js";
|
|
21
|
+
import { ConversationsService, } from "./conversations.service.js";
|
|
22
22
|
import { ConversationEnvironmentStatus } from "./environment-status.js";
|
|
23
|
-
import { ConversationFiles, FILE_CONTENT_MAX_BYTES
|
|
23
|
+
import { ConversationFiles, FILE_CONTENT_MAX_BYTES } from "./files.js";
|
|
24
24
|
import { ConversationOutputs, OUTPUT_PAGE_MAX_CHARS } from "./outputs-read.js";
|
|
25
25
|
import { ConversationQueue } from "./queue.service.js";
|
|
26
|
-
/** Shared by the list and groups queries: title search, run activity and the archived list. */
|
|
27
|
-
const searchFields = {
|
|
28
|
-
q: z.string().min(1).max(100).optional(),
|
|
29
|
-
state: z.enum(["running", "waiting"]).optional(),
|
|
30
|
-
archived: z.enum(["1"]).optional(),
|
|
31
|
-
};
|
|
32
|
-
const ListQuery = z.object({
|
|
33
|
-
after: z.string().min(1).max(100).optional(),
|
|
34
|
-
limit: z.coerce.number().int().min(1).max(200).default(50),
|
|
35
|
-
/** Only this agent's conversations (the sidebar's per-group "More"). */
|
|
36
|
-
agentId: z.string().min(1).max(100).optional(),
|
|
37
|
-
...searchFields,
|
|
38
|
-
});
|
|
39
26
|
const GroupsQuery = z.object({
|
|
40
27
|
perGroup: z.coerce.number().int().min(1).max(20).default(5),
|
|
41
28
|
limit: z.coerce.number().int().min(1).max(50).default(20),
|
|
@@ -43,22 +30,6 @@ const GroupsQuery = z.object({
|
|
|
43
30
|
after: z.string().min(1).max(100).optional(),
|
|
44
31
|
...searchFields,
|
|
45
32
|
});
|
|
46
|
-
const SubagentsQuery = z.object({
|
|
47
|
-
/** The previous page's last sub-agent id (`next`). */
|
|
48
|
-
after: z.string().min(1).max(100).optional(),
|
|
49
|
-
limit: z.coerce.number().int().min(1).max(100).default(50),
|
|
50
|
-
});
|
|
51
|
-
const EventsQuery = z
|
|
52
|
-
.object({
|
|
53
|
-
after: z.coerce.number().int().min(0).optional(),
|
|
54
|
-
/** The page before this seq, or the log's last page (`end`); exclusive with `after`. */
|
|
55
|
-
before: z.union([z.literal("end"), z.coerce.number().int().min(1)]).optional(),
|
|
56
|
-
limit: z.coerce.number().int().min(1).max(500).default(500),
|
|
57
|
-
})
|
|
58
|
-
.refine((q) => q.after === undefined || q.before === undefined, {
|
|
59
|
-
message: "after and before are exclusive",
|
|
60
|
-
path: ["before"],
|
|
61
|
-
});
|
|
62
33
|
/** `?keys=a,b`: 1–100 comma-separated tool keys of 1–200 characters each. */
|
|
63
34
|
const ToolsQuery = z.object({
|
|
64
35
|
keys: z
|
|
@@ -71,10 +42,6 @@ const OutputQuery = z.object({
|
|
|
71
42
|
offset: z.coerce.number().int().min(0).default(0),
|
|
72
43
|
limit: z.coerce.number().int().min(1).max(OUTPUT_PAGE_MAX_CHARS).default(OUTPUT_PAGE_MAX_CHARS),
|
|
73
44
|
});
|
|
74
|
-
const FilesQuery = z.object({
|
|
75
|
-
after: z.string().min(1).max(100).optional(),
|
|
76
|
-
limit: z.coerce.number().int().min(1).max(FILES_PAGE_MAX).default(50),
|
|
77
|
-
});
|
|
78
45
|
const FileContentQuery = z.object({
|
|
79
46
|
limit: z.coerce.number().int().min(1).max(FILE_CONTENT_MAX_BYTES).default(FILE_CONTENT_MAX_BYTES),
|
|
80
47
|
});
|
|
@@ -114,6 +81,13 @@ const MessageFields = z.object({
|
|
|
114
81
|
})
|
|
115
82
|
.strict()
|
|
116
83
|
.optional(),
|
|
84
|
+
/**
|
|
85
|
+
* The browser's IANA time zone (run context spec §3.4). An unknown name is ignored, never a
|
|
86
|
+
* 400; the sender's account setting overrides it.
|
|
87
|
+
*/
|
|
88
|
+
timeZone: z.string().min(1).max(64).optional(),
|
|
89
|
+
/** The sender's UI language (run context spec §3.4). */
|
|
90
|
+
locale: z.enum(["zh", "en"]).optional(),
|
|
117
91
|
});
|
|
118
92
|
// The body of `@` resource i is `content[i + 1]`, so `content[0]` must be the user's text: with
|
|
119
93
|
// `@` resources the text must not be empty. A skill invocation's `content[0]` is the rendered
|
|
@@ -155,26 +129,6 @@ const QueueBody = MessageFields.omit({ retryOf: true })
|
|
|
155
129
|
.refine(...textRule);
|
|
156
130
|
/** `PATCH …/queue/:itemId`: only the text changes (the text rule is checked against the item). */
|
|
157
131
|
const QueueEditBody = z.object({ text: z.string().max(100_000) }).strict();
|
|
158
|
-
/**
|
|
159
|
-
* A rename: 1–120 characters counted in code points after trimming, with no control or format
|
|
160
|
-
* (bidi, zero-width) characters, the same rule generated and tool titles follow.
|
|
161
|
-
*/
|
|
162
|
-
const PatchBody = z
|
|
163
|
-
.object({
|
|
164
|
-
title: z
|
|
165
|
-
.string()
|
|
166
|
-
.max(CONVERSATION_TITLE_MAX_CHARS * 2 + 100)
|
|
167
|
-
.trim()
|
|
168
|
-
.refine((t) => t.length > 0, "title must not be empty")
|
|
169
|
-
.refine((t) => Array.from(t).length <= CONVERSATION_TITLE_MAX_CHARS, `title must be at most ${CONVERSATION_TITLE_MAX_CHARS} characters`)
|
|
170
|
-
.refine((t) => !CONTROL_OR_HIDDEN_RE.test(t), "title must not contain control or format characters")
|
|
171
|
-
.optional(),
|
|
172
|
-
/** true archives (hidden from the default lists), false unarchives. */
|
|
173
|
-
archived: z.boolean().optional(),
|
|
174
|
-
})
|
|
175
|
-
.strict()
|
|
176
|
-
.refine((b) => b.title !== undefined || b.archived !== undefined, "title or archived is required");
|
|
177
|
-
const IdParams = z.object({ id: z.string().min(1).max(100) });
|
|
178
132
|
class ConversationCreateBodyDto extends createZodDto(CreateBody, "ConversationCreateBody") {
|
|
179
133
|
}
|
|
180
134
|
class ConversationPatchBodyDto extends createZodDto(PatchBody, "ConversationPatchBody") {
|
|
@@ -248,6 +202,8 @@ let ConversationsController = class ConversationsController {
|
|
|
248
202
|
...(m.model !== undefined && { model: m.model }),
|
|
249
203
|
...(m.effort !== undefined && { effort: m.effort }),
|
|
250
204
|
...(m.skill !== undefined && { skill: m.skill }),
|
|
205
|
+
...(m.timeZone !== undefined && { timeZone: m.timeZone }),
|
|
206
|
+
...(m.locale !== undefined && { locale: m.locale }),
|
|
251
207
|
}, pick);
|
|
252
208
|
reply.status(out.created ? 201 : 200);
|
|
253
209
|
return { conversation: out.conversation, event: out.event, events: out.events };
|
|
@@ -443,6 +399,8 @@ let ConversationsController = class ConversationsController {
|
|
|
443
399
|
...(body.effort !== undefined && { effort: body.effort }),
|
|
444
400
|
...(body.retryOf !== undefined && { retryOf: body.retryOf }),
|
|
445
401
|
...(body.skill !== undefined && { skill: body.skill }),
|
|
402
|
+
...(body.timeZone !== undefined && { timeZone: body.timeZone }),
|
|
403
|
+
...(body.locale !== undefined && { locale: body.locale }),
|
|
446
404
|
}),
|
|
447
405
|
};
|
|
448
406
|
}
|
|
@@ -470,6 +428,8 @@ let ConversationsController = class ConversationsController {
|
|
|
470
428
|
...(body.model !== undefined && { model: body.model }),
|
|
471
429
|
...(body.effort !== undefined && { effort: body.effort }),
|
|
472
430
|
...(body.skill !== undefined && { skill: body.skill }),
|
|
431
|
+
...(body.timeZone !== undefined && { timeZone: body.timeZone }),
|
|
432
|
+
...(body.locale !== undefined && { locale: body.locale }),
|
|
473
433
|
}),
|
|
474
434
|
};
|
|
475
435
|
}
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
import type { RouteSchemas } from "../platform/route-schemas.js";
|
|
3
|
+
/** Shared by the list and groups queries: title search, run activity and the archived list. */
|
|
4
|
+
export declare const searchFields: {
|
|
5
|
+
q: z.ZodOptional<z.ZodString>;
|
|
6
|
+
state: z.ZodOptional<z.ZodEnum<{
|
|
7
|
+
running: "running";
|
|
8
|
+
waiting: "waiting";
|
|
9
|
+
}>>;
|
|
10
|
+
archived: z.ZodOptional<z.ZodEnum<{
|
|
11
|
+
1: "1";
|
|
12
|
+
}>>;
|
|
13
|
+
};
|
|
14
|
+
export declare const ListQuery: z.ZodObject<{
|
|
15
|
+
q: z.ZodOptional<z.ZodString>;
|
|
16
|
+
state: z.ZodOptional<z.ZodEnum<{
|
|
17
|
+
running: "running";
|
|
18
|
+
waiting: "waiting";
|
|
19
|
+
}>>;
|
|
20
|
+
archived: z.ZodOptional<z.ZodEnum<{
|
|
21
|
+
1: "1";
|
|
22
|
+
}>>;
|
|
23
|
+
after: z.ZodOptional<z.ZodString>;
|
|
24
|
+
limit: z.ZodDefault<z.ZodCoercedNumber<unknown>>;
|
|
25
|
+
agentId: z.ZodOptional<z.ZodString>;
|
|
26
|
+
}, z.core.$strip>;
|
|
27
|
+
export declare const EventsQuery: z.ZodObject<{
|
|
28
|
+
after: z.ZodOptional<z.ZodCoercedNumber<unknown>>;
|
|
29
|
+
before: z.ZodOptional<z.ZodUnion<readonly [z.ZodLiteral<"end">, z.ZodCoercedNumber<unknown>]>>;
|
|
30
|
+
limit: z.ZodDefault<z.ZodCoercedNumber<unknown>>;
|
|
31
|
+
}, z.core.$strip>;
|
|
32
|
+
/**
|
|
33
|
+
* A rename: 1–120 characters counted in code points after trimming, with no control or format
|
|
34
|
+
* (bidi, zero-width) characters, the same rule generated and tool titles follow.
|
|
35
|
+
*/
|
|
36
|
+
export declare const PatchBody: z.ZodObject<{
|
|
37
|
+
title: z.ZodOptional<z.ZodString>;
|
|
38
|
+
archived: z.ZodOptional<z.ZodBoolean>;
|
|
39
|
+
}, z.core.$strict>;
|
|
40
|
+
export declare const IdParams: z.ZodObject<{
|
|
41
|
+
id: z.ZodString;
|
|
42
|
+
}, z.core.$strip>;
|
|
43
|
+
export declare const SubagentsQuery: z.ZodObject<{
|
|
44
|
+
after: z.ZodOptional<z.ZodString>;
|
|
45
|
+
limit: z.ZodDefault<z.ZodCoercedNumber<unknown>>;
|
|
46
|
+
}, z.core.$strip>;
|
|
47
|
+
export declare const FilesQuery: z.ZodObject<{
|
|
48
|
+
after: z.ZodOptional<z.ZodString>;
|
|
49
|
+
limit: z.ZodDefault<z.ZodCoercedNumber<unknown>>;
|
|
50
|
+
}, z.core.$strip>;
|
|
51
|
+
/** The conversation routes a Platform operation mirrors (spec §14, conversations). */
|
|
52
|
+
export declare const CONVERSATION_ROUTES: readonly RouteSchemas[];
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
import { CONTROL_OR_HIDDEN_RE } from "../text.js";
|
|
3
|
+
import { CONVERSATION_TITLE_MAX_CHARS } from "./conversations.service.js";
|
|
4
|
+
import { FILES_PAGE_MAX } from "./files.js";
|
|
5
|
+
/** Shared by the list and groups queries: title search, run activity and the archived list. */
|
|
6
|
+
export const searchFields = {
|
|
7
|
+
q: z.string().min(1).max(100).optional(),
|
|
8
|
+
state: z.enum(["running", "waiting"]).optional(),
|
|
9
|
+
archived: z.enum(["1"]).optional(),
|
|
10
|
+
};
|
|
11
|
+
export const ListQuery = z.object({
|
|
12
|
+
after: z.string().min(1).max(100).optional(),
|
|
13
|
+
limit: z.coerce.number().int().min(1).max(200).default(50),
|
|
14
|
+
/** Only this agent's conversations (the sidebar's per-group "More"). */
|
|
15
|
+
agentId: z.string().min(1).max(100).optional(),
|
|
16
|
+
...searchFields,
|
|
17
|
+
});
|
|
18
|
+
export const EventsQuery = z
|
|
19
|
+
.object({
|
|
20
|
+
after: z.coerce.number().int().min(0).optional(),
|
|
21
|
+
/** The page before this seq, or the log's last page (`end`); exclusive with `after`. */
|
|
22
|
+
before: z.union([z.literal("end"), z.coerce.number().int().min(1)]).optional(),
|
|
23
|
+
limit: z.coerce.number().int().min(1).max(500).default(500),
|
|
24
|
+
})
|
|
25
|
+
.refine((q) => q.after === undefined || q.before === undefined, {
|
|
26
|
+
message: "after and before are exclusive",
|
|
27
|
+
path: ["before"],
|
|
28
|
+
});
|
|
29
|
+
/**
|
|
30
|
+
* A rename: 1–120 characters counted in code points after trimming, with no control or format
|
|
31
|
+
* (bidi, zero-width) characters, the same rule generated and tool titles follow.
|
|
32
|
+
*/
|
|
33
|
+
export const PatchBody = z
|
|
34
|
+
.object({
|
|
35
|
+
title: z
|
|
36
|
+
.string()
|
|
37
|
+
.max(CONVERSATION_TITLE_MAX_CHARS * 2 + 100)
|
|
38
|
+
.trim()
|
|
39
|
+
.refine((t) => t.length > 0, "title must not be empty")
|
|
40
|
+
.refine((t) => Array.from(t).length <= CONVERSATION_TITLE_MAX_CHARS, `title must be at most ${CONVERSATION_TITLE_MAX_CHARS} characters`)
|
|
41
|
+
.refine((t) => !CONTROL_OR_HIDDEN_RE.test(t), "title must not contain control or format characters")
|
|
42
|
+
.optional(),
|
|
43
|
+
/** true archives (hidden from the default lists), false unarchives. */
|
|
44
|
+
archived: z.boolean().optional(),
|
|
45
|
+
})
|
|
46
|
+
.strict()
|
|
47
|
+
.refine((b) => b.title !== undefined || b.archived !== undefined, "title or archived is required");
|
|
48
|
+
export const IdParams = z.object({ id: z.string().min(1).max(100) });
|
|
49
|
+
export const SubagentsQuery = z.object({
|
|
50
|
+
/** The previous page's last sub-agent id (`next`). */
|
|
51
|
+
after: z.string().min(1).max(100).optional(),
|
|
52
|
+
limit: z.coerce.number().int().min(1).max(100).default(50),
|
|
53
|
+
});
|
|
54
|
+
export const FilesQuery = z.object({
|
|
55
|
+
after: z.string().min(1).max(100).optional(),
|
|
56
|
+
limit: z.coerce.number().int().min(1).max(FILES_PAGE_MAX).default(50),
|
|
57
|
+
});
|
|
58
|
+
/** The conversation routes a Platform operation mirrors (spec §14, conversations). */
|
|
59
|
+
export const CONVERSATION_ROUTES = [
|
|
60
|
+
{ route: "GET /api/v1/orgs/:orgId/conversations", query: ListQuery },
|
|
61
|
+
{ route: "GET /api/v1/orgs/:orgId/conversations/:id", params: IdParams },
|
|
62
|
+
{
|
|
63
|
+
route: "GET /api/v1/orgs/:orgId/conversations/:id/events",
|
|
64
|
+
params: IdParams,
|
|
65
|
+
query: EventsQuery,
|
|
66
|
+
},
|
|
67
|
+
{ route: "PATCH /api/v1/orgs/:orgId/conversations/:id", params: IdParams, body: PatchBody },
|
|
68
|
+
{ route: "DELETE /api/v1/orgs/:orgId/conversations/:id", params: IdParams },
|
|
69
|
+
{
|
|
70
|
+
route: "GET /api/v1/orgs/:orgId/conversations/:id/subagents",
|
|
71
|
+
params: IdParams,
|
|
72
|
+
query: SubagentsQuery,
|
|
73
|
+
},
|
|
74
|
+
{ route: "GET /api/v1/orgs/:orgId/conversations/:id/agent-tree", params: IdParams },
|
|
75
|
+
{ route: "GET /api/v1/orgs/:orgId/conversations/:id/usage", params: IdParams },
|
|
76
|
+
{ route: "GET /api/v1/orgs/:orgId/conversations/:id/files", params: IdParams, query: FilesQuery },
|
|
77
|
+
{ route: "GET /api/v1/orgs/:orgId/conversations/:id/environment", params: IdParams },
|
|
78
|
+
{ route: "POST /api/v1/orgs/:orgId/conversations/:id/abort", params: IdParams },
|
|
79
|
+
];
|
|
@@ -161,6 +161,11 @@ export interface UserMessageInput {
|
|
|
161
161
|
skill?: {
|
|
162
162
|
name: string;
|
|
163
163
|
};
|
|
164
|
+
/** The browser's IANA time zone and UI language (run context spec §3.4); IM sends none. */
|
|
165
|
+
timeZone?: string;
|
|
166
|
+
locale?: "zh" | "en";
|
|
167
|
+
/** An anonymous IM guest's IM profile name (run context spec §7); other senders: none. */
|
|
168
|
+
senderName?: string;
|
|
164
169
|
}
|
|
165
170
|
/**
|
|
166
171
|
* 会话:只有所有者可见;每次访问都实时复核 agent 对所有者仍可用(spec 3.6 R5),
|
|
@@ -366,15 +371,19 @@ export declare class ConversationsService {
|
|
|
366
371
|
* `text` 为空时(只发附件,HTTP 层保证此时有 `files` 且没有 `@` 资源)不写文本块。
|
|
367
372
|
*/
|
|
368
373
|
postUserMessage(orgId: string, conversationId: string, accountId: string, input: UserMessageInput): Promise<ConversationEvent>;
|
|
369
|
-
/**
|
|
374
|
+
/**
|
|
375
|
+
* Writes a message in one transaction: binds its files, reads its sender context and appends it
|
|
376
|
+
* (after its `model_switched` when it switches).
|
|
377
|
+
*/
|
|
370
378
|
private postIn;
|
|
371
379
|
/**
|
|
372
380
|
* The selection a message switches to, or null when it changes nothing. A model equal to the
|
|
373
381
|
* agent's means "back to the agent's model" (null); a model change without `effort` resets the
|
|
374
382
|
* effort. The target model must resolve (`agent.model_unavailable`) and declare the effort
|
|
375
|
-
* (`validation_failed`). Resolving is the agent editor's check
|
|
376
|
-
*
|
|
377
|
-
* worker's `fallBackIfUnavailable`
|
|
383
|
+
* (`validation_failed`). Resolving is the agent editor's check, for the org (its effective
|
|
384
|
+
* provider config, spec B §5.5) and its disabled lists: a model the platform or the org disabled,
|
|
385
|
+
* or a non-chat model, is refused (spec B §5.3), as the run worker's `fallBackIfUnavailable` falls
|
|
386
|
+
* back from it.
|
|
378
387
|
*/
|
|
379
388
|
private planSwitch;
|
|
380
389
|
/**
|