@capybara-hq/kernel 0.1.0-rc.6 → 0.1.0-rc.8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/bootstrap.json +27 -3
- package/dist/admin/admin.controller.d.ts +8 -72
- package/dist/admin/admin.controller.js +21 -46
- package/dist/admin/admin.schemas.d.ts +57 -0
- package/dist/admin/admin.schemas.js +50 -0
- package/dist/admin/extensions.controller.d.ts +10 -0
- package/dist/admin/extensions.controller.js +18 -0
- package/dist/admin/extensions.schemas.d.ts +7 -0
- package/dist/admin/extensions.schemas.js +10 -0
- package/dist/admin/limit-defaults.d.ts +20 -0
- package/dist/admin/limit-defaults.js +10 -0
- package/dist/agents/agent-profile.service.d.ts +7 -5
- package/dist/agents/agent-profile.service.js +14 -9
- package/dist/agents/agents.controller.d.ts +7 -287
- package/dist/agents/agents.controller.js +7 -67
- package/dist/agents/agents.schemas.d.ts +389 -0
- package/dist/agents/agents.schemas.js +126 -0
- package/dist/agents/agents.service.d.ts +13 -5
- package/dist/agents/agents.service.js +67 -13
- package/dist/agents/definition.d.ts +47 -19
- package/dist/agents/definition.js +119 -38
- package/dist/agents/from-template.d.ts +2 -2
- package/dist/agents/from-template.js +76 -45
- package/dist/agents/from-template.service.d.ts +12 -0
- package/dist/agents/from-template.service.js +20 -3
- package/dist/agents/models.controller.d.ts +1 -2
- package/dist/agents/models.controller.js +1 -1
- package/dist/agents/org-templates.d.ts +13 -3
- package/dist/agents/org-templates.js +69 -28
- package/dist/agents/pending-connector-requests.d.ts +2 -0
- package/dist/agents/pending-connector-requests.js +1 -1
- package/dist/agents/pending-connectors.controller.d.ts +1 -1
- package/dist/agents/pending-connectors.controller.js +2 -2
- package/dist/agents/pending-connectors.service.d.ts +2 -2
- package/dist/agents/pending-connectors.service.js +19 -19
- package/dist/agents/profile.d.ts +18 -0
- package/dist/agents/profile.js +5 -1
- package/dist/agents/templates.controller.d.ts +8 -17
- package/dist/agents/templates.controller.js +13 -31
- package/dist/agents/templates.schemas.d.ts +20 -0
- package/dist/agents/templates.schemas.js +45 -0
- package/dist/background/background.controller.js +3 -2
- package/dist/background/background.schemas.d.ts +10 -0
- package/dist/background/background.schemas.js +16 -0
- package/dist/background/tasks.service.d.ts +1 -1
- package/dist/background/tasks.service.js +7 -2
- package/dist/catalog/admin-catalog.controller.d.ts +4 -57
- package/dist/catalog/admin-catalog.controller.js +8 -45
- package/dist/catalog/admin-catalog.schemas.d.ts +72 -0
- package/dist/catalog/admin-catalog.schemas.js +92 -0
- package/dist/catalog/catalog-content.d.ts +12 -2
- package/dist/catalog/catalog-scope.service.js +8 -2
- package/dist/catalog/catalog.service.d.ts +2 -0
- package/dist/catalog/catalog.service.js +3 -0
- package/dist/catalog/component-scope.controller.d.ts +3 -65
- package/dist/catalog/component-scope.controller.js +3 -56
- package/dist/catalog/component-scope.schemas.d.ts +114 -0
- package/dist/catalog/component-scope.schemas.js +97 -0
- package/dist/catalog/component-scope.service.d.ts +28 -4
- package/dist/catalog/component-scope.service.js +55 -3
- package/dist/catalog/component-state.d.ts +9 -2
- package/dist/catalog/component-state.js +22 -13
- package/dist/catalog/marketplaces.controller.d.ts +5 -35
- package/dist/catalog/marketplaces.controller.js +6 -34
- package/dist/catalog/marketplaces.schemas.d.ts +48 -0
- package/dist/catalog/marketplaces.schemas.js +53 -0
- package/dist/catalog/marketplaces.service.d.ts +15 -1
- package/dist/catalog/marketplaces.service.js +22 -1
- package/dist/catalog/org-catalog.controller.d.ts +6 -62
- package/dist/catalog/org-catalog.controller.js +12 -66
- package/dist/catalog/org-catalog.schemas.d.ts +79 -0
- package/dist/catalog/org-catalog.schemas.js +82 -0
- package/dist/catalog/org-catalog.service.d.ts +9 -2
- package/dist/catalog/org-catalog.service.js +38 -5
- package/dist/catalog/org-extension.controller.d.ts +1 -12
- package/dist/catalog/org-extension.controller.js +1 -10
- package/dist/catalog/org-extension.schemas.d.ts +15 -0
- package/dist/catalog/org-extension.schemas.js +22 -0
- package/dist/catalog/org-plugin-uploads.controller.d.ts +2 -19
- package/dist/catalog/org-plugin-uploads.controller.js +15 -28
- package/dist/catalog/org-plugin-uploads.schemas.d.ts +20 -0
- package/dist/catalog/org-plugin-uploads.schemas.js +32 -0
- package/dist/catalog/owned-items.d.ts +6 -2
- package/dist/catalog/owned-items.js +16 -4
- package/dist/catalog/platform-components.d.ts +2 -0
- package/dist/catalog/platform-components.js +2 -0
- package/dist/catalog/plugin-import.js +1 -0
- package/dist/catalog/plugin-install.js +1 -1
- package/dist/catalog/requests.service.d.ts +2 -1
- package/dist/catalog/requests.service.js +6 -2
- package/dist/channels/channels.schemas.d.ts +33 -0
- package/dist/channels/channels.schemas.js +34 -0
- package/dist/channels/connections.controller.d.ts +2 -29
- package/dist/channels/connections.controller.js +1 -23
- package/dist/channels/connections.service.d.ts +8 -2
- package/dist/channels/connections.service.js +23 -5
- package/dist/channels/inbound.js +4 -0
- package/dist/conversations/conversations.controller.d.ts +16 -37
- package/dist/conversations/conversations.controller.js +16 -56
- package/dist/conversations/conversations.schemas.d.ts +52 -0
- package/dist/conversations/conversations.schemas.js +79 -0
- package/dist/conversations/conversations.service.d.ts +9 -1
- package/dist/conversations/conversations.service.js +23 -18
- package/dist/conversations/events.d.ts +80 -6
- package/dist/conversations/events.js +60 -5
- package/dist/conversations/message-context.d.ts +28 -0
- package/dist/conversations/message-context.js +56 -0
- package/dist/conversations/queue.d.ts +2 -1
- package/dist/conversations/queue.js +11 -2
- package/dist/db/kernel-schema.d.ts +20 -0
- package/dist/environments/environments.schemas.d.ts +3 -0
- package/dist/environments/environments.schemas.js +14 -0
- package/dist/environments/environments.service.d.ts +16 -4
- package/dist/environments/environments.service.js +58 -13
- package/dist/errors.d.ts +3 -0
- package/dist/errors.js +3 -0
- package/dist/evals/evals.schemas.d.ts +110 -0
- package/dist/evals/evals.schemas.js +107 -0
- package/dist/evals/reconstruct.js +18 -11
- package/dist/evals/recorded-tools.d.ts +2 -1
- package/dist/evals/recorded-tools.js +11 -3
- package/dist/evals/run-replay.d.ts +8 -1
- package/dist/evals/run-replay.js +13 -0
- package/dist/evals/runs.controller.d.ts +2 -57
- package/dist/evals/runs.controller.js +1 -42
- package/dist/evals/runs.service.d.ts +6 -6
- package/dist/evals/runs.service.js +32 -18
- package/dist/evals/sets.controller.d.ts +2 -28
- package/dist/evals/sets.controller.js +1 -31
- package/dist/evals/sets.service.d.ts +7 -7
- package/dist/evals/sets.service.js +23 -17
- package/dist/evals/snapshot.d.ts +3 -2
- package/dist/evals/snapshot.js +17 -4
- package/dist/extensions/admin-ops.d.ts +5 -3
- package/dist/extensions/admin-ops.js +17 -12
- package/dist/extensions/deployment-config.d.ts +16 -1
- package/dist/extensions/deployment-config.js +83 -0
- package/dist/extensions/extensions.module.js +3 -0
- package/dist/extensions/host.d.ts +33 -2
- package/dist/extensions/host.js +107 -1
- package/dist/extensions/installs.d.ts +5 -0
- package/dist/extensions/installs.js +12 -0
- package/dist/extensions/org-config.d.ts +17 -2
- package/dist/extensions/org-config.js +23 -4
- package/dist/extensions/point-defaults.controller.d.ts +2 -8
- package/dist/extensions/point-defaults.controller.js +1 -3
- package/dist/extensions/point-defaults.d.ts +3 -1
- package/dist/extensions/point-defaults.js +4 -2
- package/dist/extensions/point-defaults.schemas.d.ts +9 -0
- package/dist/extensions/point-defaults.schemas.js +14 -0
- package/dist/extensions/unavailable.d.ts +49 -0
- package/dist/extensions/unavailable.js +113 -0
- package/dist/files/previewers.controller.js +2 -3
- package/dist/files/previewers.d.ts +1 -1
- package/dist/files/previewers.js +4 -4
- package/dist/files/previewers.schemas.d.ts +10 -0
- package/dist/files/previewers.schemas.js +9 -0
- package/dist/http/api.module.js +2 -0
- package/dist/identity/accounts.d.ts +43 -4
- package/dist/identity/accounts.js +74 -6
- package/dist/identity/auth.guard.js +10 -1
- package/dist/identity/cookies.d.ts +6 -0
- package/dist/identity/cookies.js +14 -0
- package/dist/identity/identity.module.js +3 -0
- package/dist/identity/initial-passwords.controller.d.ts +22 -0
- package/dist/identity/initial-passwords.controller.js +49 -0
- package/dist/identity/initial-passwords.d.ts +61 -0
- package/dist/identity/initial-passwords.job.d.ts +16 -0
- package/dist/identity/initial-passwords.job.js +46 -0
- package/dist/identity/initial-passwords.js +159 -0
- package/dist/identity/me.controller.d.ts +12 -0
- package/dist/identity/me.controller.js +31 -1
- package/dist/identity/me.schemas.d.ts +14 -0
- package/dist/identity/me.schemas.js +17 -0
- package/dist/identity/principal.d.ts +8 -0
- package/dist/identity/principal.js +8 -0
- package/dist/identity/settings.d.ts +3 -1
- package/dist/identity/settings.js +6 -4
- package/dist/inbox/inbox.schemas.d.ts +8 -0
- package/dist/inbox/inbox.schemas.js +11 -0
- package/dist/inbox/platform-inbox.controller.d.ts +1 -1
- package/dist/inbox/platform-inbox.controller.js +2 -2
- package/dist/index.d.ts +4 -0
- package/dist/index.js +6 -0
- package/dist/lifecycle/kernel-lifecycle.js +4 -0
- package/dist/models/enablement.d.ts +2 -0
- package/dist/models/enablement.js +1 -0
- package/dist/models/org-models.schemas.d.ts +8 -0
- package/dist/models/org-models.schemas.js +22 -0
- package/dist/models/prices.d.ts +3 -1
- package/dist/models/prices.js +7 -5
- package/dist/models/purposes.d.ts +12 -2
- package/dist/models/purposes.js +22 -8
- package/dist/orgs/orgs.controller.d.ts +2 -5
- package/dist/orgs/orgs.controller.js +3 -6
- package/dist/orgs/orgs.schemas.d.ts +8 -0
- package/dist/orgs/orgs.schemas.js +16 -0
- package/dist/orgs/orgs.service.d.ts +3 -1
- package/dist/orgs/orgs.service.js +6 -4
- package/dist/orgs/settings.service.d.ts +9 -1
- package/dist/orgs/settings.service.js +20 -5
- package/dist/overrides.d.ts +4 -0
- package/dist/overrides.js +2 -0
- package/dist/platform/errors.d.ts +21 -4
- package/dist/platform/errors.js +45 -6
- package/dist/platform/exclusions.d.ts +2 -3
- package/dist/platform/exclusions.js +58 -849
- package/dist/platform/method.js +1 -1
- package/dist/platform/operation.d.ts +82 -5
- package/dist/platform/operation.js +63 -8
- 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 +11 -6
- package/dist/platform/ops/platform.ops.js +73 -27
- 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 +63 -0
- package/dist/roles/worker.module.js +2 -0
- package/dist/runtime/context/build.d.ts +2 -0
- package/dist/runtime/context/build.js +28 -2
- package/dist/runtime/context/compaction.js +10 -1
- package/dist/runtime/context/run-context.d.ts +65 -0
- package/dist/runtime/context/run-context.js +215 -0
- package/dist/runtime/model-call.js +2 -1
- package/dist/runtime/providers.js +8 -1
- package/dist/runtime/run-context.service.d.ts +65 -0
- package/dist/runtime/run-context.service.js +220 -0
- package/dist/runtime/run-worker.d.ts +5 -0
- package/dist/runtime/run-worker.js +31 -6
- package/dist/runtime/runtime.module.js +2 -0
- package/dist/runtime/subagents/definition.d.ts +15 -15
- package/dist/runtime/subagents/definition.js +46 -115
- package/dist/skills/changes.controller.js +2 -1
- package/dist/skills/changes.service.d.ts +1 -1
- package/dist/skills/changes.service.js +4 -4
- package/dist/skills/invocable.controller.d.ts +1 -1
- package/dist/skills/invocable.controller.js +2 -2
- package/dist/skills/invoke.d.ts +2 -2
- package/dist/skills/invoke.js +8 -1
- package/dist/skills/skills.controller.d.ts +4 -13
- package/dist/skills/skills.controller.js +8 -24
- package/dist/skills/skills.schemas.d.ts +48 -0
- package/dist/skills/skills.schemas.js +61 -0
- package/dist/skills/skills.service.d.ts +11 -1
- package/dist/skills/skills.service.js +37 -14
- package/dist/time-zone.d.ts +5 -0
- package/dist/time-zone.js +19 -0
- package/dist/tools/approvals.controller.js +2 -3
- package/dist/tools/approvals.schemas.d.ts +21 -0
- package/dist/tools/approvals.schemas.js +15 -0
- package/dist/tools/builtin-names.d.ts +10 -8
- package/dist/tools/builtin-names.js +16 -11
- package/dist/tools/builtins/builtin-tools.d.ts +3 -1
- package/dist/tools/builtins/builtin-tools.js +15 -3
- package/dist/tools/builtins/current-time.d.ts +26 -0
- package/dist/tools/builtins/current-time.js +99 -0
- package/dist/tools/builtins/platform.d.ts +19 -2
- package/dist/tools/builtins/platform.js +105 -16
- package/dist/tools/connectors.controller.d.ts +1 -2
- package/dist/tools/connectors.controller.js +1 -4
- package/dist/tools/connectors.schemas.d.ts +12 -0
- package/dist/tools/connectors.schemas.js +19 -0
- package/dist/tools/connectors.service.d.ts +5 -2
- package/dist/tools/connectors.service.js +7 -5
- package/dist/tools/org-tool-switches.d.ts +16 -2
- package/dist/tools/org-tool-switches.js +26 -9
- package/dist/tools/pipeline.js +3 -1
- package/dist/tools/registry.d.ts +48 -51
- package/dist/tools/registry.js +222 -233
- package/package.json +3 -3
- package/src/migrations/0090_initial_passwords.sql +27 -0
- package/src/migrations/0091_account_time_zone.sql +4 -0
- package/src/migrations/0092_tools_default_on.sql +27 -0
- package/dist/platform/redact-orgs.d.ts +0 -7
- package/dist/platform/redact-orgs.js +0 -52
|
@@ -3,13 +3,15 @@ import { ComponentScopeService } from "../../catalog/component-scope.service.js"
|
|
|
3
3
|
import { ConnectorsService } from "../../tools/connectors.service.js";
|
|
4
4
|
import { PlatformOperations } from "../registry.js";
|
|
5
5
|
/**
|
|
6
|
-
* Connector operations of the `Platform` tool (spec §7):
|
|
7
|
-
*
|
|
6
|
+
* Connector operations of the `Platform` tool (spec §7): reads, deleting a connector and
|
|
7
|
+
* refreshing its tool list (org admins). Creating a connector, editing its endpoint or entering a
|
|
8
|
+
* credential stays on the web (a person types credentials, spec §6.4).
|
|
8
9
|
*/
|
|
9
10
|
export declare class ConnectorsOperations implements OnModuleInit {
|
|
10
11
|
private readonly registry;
|
|
11
12
|
private readonly connectors;
|
|
12
13
|
private readonly components;
|
|
13
14
|
constructor(registry: PlatformOperations, connectors: ConnectorsService, components: ComponentScopeService);
|
|
15
|
+
private connectorName;
|
|
14
16
|
onModuleInit(): void;
|
|
15
17
|
}
|
|
@@ -10,12 +10,14 @@ var __param = (this && this.__param) || function (paramIndex, decorator) {
|
|
|
10
10
|
import { Inject, Injectable } from "@nestjs/common";
|
|
11
11
|
import { z } from "zod";
|
|
12
12
|
import { ComponentScopeService } from "../../catalog/component-scope.service.js";
|
|
13
|
+
import { ConnectorPathParams } from "../../tools/connectors.schemas.js";
|
|
13
14
|
import { ConnectorsService, } from "../../tools/connectors.service.js";
|
|
14
15
|
import { publicEndpoint } from "../../tools/endpoint.js";
|
|
15
16
|
import { defineOperation } from "../operation.js";
|
|
16
17
|
import { PlatformOperations } from "../registry.js";
|
|
17
|
-
import {
|
|
18
|
+
import { precheckBy, viaAgent } from "./errors.js";
|
|
18
19
|
import { Cursor, pageOf, startOf } from "./paging.js";
|
|
20
|
+
import { named, orElse } from "./summary.js";
|
|
19
21
|
const PAGE = 50;
|
|
20
22
|
/**
|
|
21
23
|
* A connector without anything secret: the auth method and who holds the credential (the org or
|
|
@@ -51,8 +53,9 @@ const detail = (c) => ({
|
|
|
51
53
|
})),
|
|
52
54
|
});
|
|
53
55
|
/**
|
|
54
|
-
* Connector operations of the `Platform` tool (spec §7):
|
|
55
|
-
*
|
|
56
|
+
* Connector operations of the `Platform` tool (spec §7): reads, deleting a connector and
|
|
57
|
+
* refreshing its tool list (org admins). Creating a connector, editing its endpoint or entering a
|
|
58
|
+
* credential stays on the web (a person types credentials, spec §6.4).
|
|
56
59
|
*/
|
|
57
60
|
let ConnectorsOperations = class ConnectorsOperations {
|
|
58
61
|
registry;
|
|
@@ -63,6 +66,9 @@ let ConnectorsOperations = class ConnectorsOperations {
|
|
|
63
66
|
this.connectors = connectors;
|
|
64
67
|
this.components = components;
|
|
65
68
|
}
|
|
69
|
+
connectorName(ctx, connectorId) {
|
|
70
|
+
return orElse(async () => named((await this.connectors.get(ctx.orgId, connectorId, ctx.actorAccountId)).name), connectorId);
|
|
71
|
+
}
|
|
66
72
|
onModuleInit() {
|
|
67
73
|
this.registry.register([
|
|
68
74
|
defineOperation({
|
|
@@ -72,13 +78,14 @@ let ConnectorsOperations = class ConnectorsOperations {
|
|
|
72
78
|
example: {},
|
|
73
79
|
authz: { orgAction: "connectors.use" },
|
|
74
80
|
mirrors: ["GET /api/v1/orgs/:orgId/connectors"],
|
|
81
|
+
extras: ["cursor"],
|
|
75
82
|
confirm: "read",
|
|
76
83
|
run: async (input, ctx) => pageOf((await this.connectors.list(ctx.orgId)).map(summary), startOf(input.cursor), PAGE),
|
|
77
84
|
}),
|
|
78
85
|
defineOperation({
|
|
79
86
|
id: "connectors.get",
|
|
80
87
|
description: "Read one connector: its tools with their state and default policy, and whether your credential for it is connected. Credentials are never returned; a person enters them on the connector's web page.",
|
|
81
|
-
input: z.object({ connectorId:
|
|
88
|
+
input: z.object({ connectorId: ConnectorPathParams.shape.connectorId.max(100) }).strict(),
|
|
82
89
|
example: { connectorId: "5d2e8f1a-0b3c-4d5e-8f9a-1b2c3d4e5f60" },
|
|
83
90
|
authz: { orgAction: "connectors.use" },
|
|
84
91
|
mirrors: ["GET /api/v1/orgs/:orgId/connectors/:connectorId"],
|
|
@@ -86,9 +93,9 @@ let ConnectorsOperations = class ConnectorsOperations {
|
|
|
86
93
|
errors: [
|
|
87
94
|
{ code: "connector.not_found", next: "Check the connector id with connectors.list." },
|
|
88
95
|
],
|
|
89
|
-
run: async (input, ctx) =>
|
|
96
|
+
run: async (input, ctx) => ({
|
|
90
97
|
connector: detail(await this.connectors.get(ctx.orgId, input.connectorId, ctx.actorAccountId)),
|
|
91
|
-
})
|
|
98
|
+
}),
|
|
92
99
|
}),
|
|
93
100
|
defineOperation({
|
|
94
101
|
id: "connectors.templates",
|
|
@@ -97,6 +104,9 @@ let ConnectorsOperations = class ConnectorsOperations {
|
|
|
97
104
|
example: {},
|
|
98
105
|
authz: { orgAction: "catalog.read" },
|
|
99
106
|
mirrors: ["GET /api/v1/orgs/:orgId/components"],
|
|
107
|
+
// connector templates only, every plugin's
|
|
108
|
+
omits: ["kind", "itemId"],
|
|
109
|
+
extras: ["cursor"],
|
|
100
110
|
confirm: "read",
|
|
101
111
|
run: async (input, ctx) => {
|
|
102
112
|
const all = await this.components.orgList(ctx.orgId, { kind: "connector_template" });
|
|
@@ -114,6 +124,58 @@ let ConnectorsOperations = class ConnectorsOperations {
|
|
|
114
124
|
return pageOf(templates, startOf(input.cursor), PAGE);
|
|
115
125
|
},
|
|
116
126
|
}),
|
|
127
|
+
defineOperation({
|
|
128
|
+
id: "connectors.delete",
|
|
129
|
+
description: "Delete a connector of the org (org admins): its credentials are deleted too and agents that use it lose its tools. Creating a connector again needs its credentials entered on the web.",
|
|
130
|
+
input: z.object({ connectorId: ConnectorPathParams.shape.connectorId.max(100) }).strict(),
|
|
131
|
+
example: { connectorId: "5d2e8f1a-0b3c-4d5e-8f9a-1b2c3d4e5f60" },
|
|
132
|
+
authz: { orgAction: "connectors.manage" },
|
|
133
|
+
mirrors: ["DELETE /api/v1/orgs/:orgId/connectors/:connectorId"],
|
|
134
|
+
confirm: "org",
|
|
135
|
+
errors: [
|
|
136
|
+
{ code: "connector.not_found", next: "Check the connector id with connectors.list." },
|
|
137
|
+
],
|
|
138
|
+
precheck: (i, ctx) => precheckBy(() => this.connectors.get(ctx.orgId, i.connectorId, ctx.actorAccountId)),
|
|
139
|
+
summary: async (i, ctx) => {
|
|
140
|
+
const n = await this.connectorName(ctx, i.connectorId);
|
|
141
|
+
return {
|
|
142
|
+
zh: `删除连接器「${n}」及其全部凭据;使用它的智能体将失去其工具`,
|
|
143
|
+
en: `Delete connector "${n}" and all its credentials; agents that use it lose its tools`,
|
|
144
|
+
};
|
|
145
|
+
},
|
|
146
|
+
run: async (input, ctx) => {
|
|
147
|
+
await this.connectors.remove(ctx.orgId, input.connectorId, ctx.actorAccountId, undefined, viaAgent("connectors.delete", ctx));
|
|
148
|
+
return { id: input.connectorId, deleted: true };
|
|
149
|
+
},
|
|
150
|
+
}),
|
|
151
|
+
defineOperation({
|
|
152
|
+
id: "connectors.refresh",
|
|
153
|
+
description: "Fetch the connector's tool list again (org admins) and compare it with the stored one: new or changed tools wait for review on the connector's web page, vanished tools are switched off. Returns the connector and which tools were added, changed or removed. It calls the connector's server with the org's credential, or yours for a personal one.",
|
|
154
|
+
input: z.object({ connectorId: ConnectorPathParams.shape.connectorId.max(100) }).strict(),
|
|
155
|
+
example: { connectorId: "5d2e8f1a-0b3c-4d5e-8f9a-1b2c3d4e5f60" },
|
|
156
|
+
authz: { orgAction: "connectors.manage" },
|
|
157
|
+
mirrors: ["POST /api/v1/orgs/:orgId/connectors/:connectorId/refresh"],
|
|
158
|
+
confirm: "org",
|
|
159
|
+
errors: [
|
|
160
|
+
{ code: "connector.not_found", next: "Check the connector id with connectors.list." },
|
|
161
|
+
{
|
|
162
|
+
code: "credential.missing",
|
|
163
|
+
next: "Your credential for this connector is missing: open the connector's page on the web and connect it, then refresh again.",
|
|
164
|
+
},
|
|
165
|
+
],
|
|
166
|
+
precheck: (i, ctx) => precheckBy(() => this.connectors.get(ctx.orgId, i.connectorId, ctx.actorAccountId)),
|
|
167
|
+
summary: async (i, ctx) => {
|
|
168
|
+
const n = await this.connectorName(ctx, i.connectorId);
|
|
169
|
+
return {
|
|
170
|
+
zh: `刷新连接器「${n}」的工具列表(会访问该连接器的服务)`,
|
|
171
|
+
en: `Refresh the tool list of connector "${n}" (calls the connector's server)`,
|
|
172
|
+
};
|
|
173
|
+
},
|
|
174
|
+
run: async (input, ctx) => {
|
|
175
|
+
const r = await this.connectors.refresh(ctx.orgId, input.connectorId, ctx.actorAccountId, undefined, { auditDetail: viaAgent("connectors.refresh", ctx) });
|
|
176
|
+
return { connector: detail(r.connector), issues: r.issues, changes: r.changes };
|
|
177
|
+
},
|
|
178
|
+
}),
|
|
117
179
|
]);
|
|
118
180
|
}
|
|
119
181
|
};
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { type OnModuleInit } from "@nestjs/common";
|
|
2
|
+
import { ConversationsService } from "../../conversations/conversations.service.js";
|
|
3
|
+
import { ConversationEnvironmentStatus } from "../../conversations/environment-status.js";
|
|
4
|
+
import { ConversationFiles } from "../../conversations/files.js";
|
|
5
|
+
import { KernelDb } from "../../infra/database/kernel-db.js";
|
|
6
|
+
import { PlatformOperations } from "../registry.js";
|
|
7
|
+
/**
|
|
8
|
+
* Conversation operations of the `Platform` tool (spec §14, conversations): the person's own
|
|
9
|
+
* conversations only, as the web sidebar shows them. Starting a conversation or sending a message
|
|
10
|
+
* stays with the person (runs are started by them), and so do the live stream and the other
|
|
11
|
+
* display reads (see `exclusions.ts`).
|
|
12
|
+
*/
|
|
13
|
+
export declare class ConversationsOperations implements OnModuleInit {
|
|
14
|
+
private readonly registry;
|
|
15
|
+
private readonly conversations;
|
|
16
|
+
private readonly files;
|
|
17
|
+
private readonly environment;
|
|
18
|
+
private readonly kdb;
|
|
19
|
+
constructor(registry: PlatformOperations, conversations: ConversationsService, files: ConversationFiles, environment: ConversationEnvironmentStatus, kdb: KernelDb);
|
|
20
|
+
/**
|
|
21
|
+
* Whether `id` is the conversation this run belongs to: its ROOT (the Platform tool also runs in
|
|
22
|
+
* sub-agents, whose own id is not the person's conversation). Stopping or deleting it would end
|
|
23
|
+
* the very run that asked.
|
|
24
|
+
*/
|
|
25
|
+
private isRunsRoot;
|
|
26
|
+
private titleOf;
|
|
27
|
+
private precheckWritable;
|
|
28
|
+
private setArchived;
|
|
29
|
+
onModuleInit(): void;
|
|
30
|
+
}
|
|
@@ -0,0 +1,470 @@
|
|
|
1
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
2
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
3
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
4
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
5
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
6
|
+
};
|
|
7
|
+
var __param = (this && this.__param) || function (paramIndex, decorator) {
|
|
8
|
+
return function (target, key) { decorator(target, key, paramIndex); }
|
|
9
|
+
};
|
|
10
|
+
import { Inject, Injectable } from "@nestjs/common";
|
|
11
|
+
import { z } from "zod";
|
|
12
|
+
import { EventsQuery, FilesQuery, IdParams, ListQuery, PatchBody, SubagentsQuery, } from "../../conversations/conversations.schemas.js";
|
|
13
|
+
import { ConversationsService, } from "../../conversations/conversations.service.js";
|
|
14
|
+
import { ConversationEnvironmentStatus } from "../../conversations/environment-status.js";
|
|
15
|
+
import { ConversationFiles } from "../../conversations/files.js";
|
|
16
|
+
import { KernelDb } from "../../infra/database/kernel-db.js";
|
|
17
|
+
import { rootConversationOf } from "../../runtime/subagents/child.js";
|
|
18
|
+
import { defineOperation } from "../operation.js";
|
|
19
|
+
import { PlatformOperations } from "../registry.js";
|
|
20
|
+
import { precheckBy } from "./errors.js";
|
|
21
|
+
import { named, orElse } from "./summary.js";
|
|
22
|
+
const PAGE = 50;
|
|
23
|
+
const ConversationId = IdParams.shape.id;
|
|
24
|
+
const Id = z.object({ conversationId: ConversationId }).strict();
|
|
25
|
+
const EVENTS_PAGE_MAX = 100;
|
|
26
|
+
/** A list row: the compact form (`state` is what the run is doing, else archived or idle). */
|
|
27
|
+
const row = (c) => ({
|
|
28
|
+
id: c.id,
|
|
29
|
+
name: c.title ?? "Untitled",
|
|
30
|
+
state: c.activity ?? (c.archivedAt === null ? "idle" : "archived"),
|
|
31
|
+
agentId: c.agentId,
|
|
32
|
+
updatedAt: c.updatedAt,
|
|
33
|
+
});
|
|
34
|
+
/**
|
|
35
|
+
* Conversation operations of the `Platform` tool (spec §14, conversations): the person's own
|
|
36
|
+
* conversations only, as the web sidebar shows them. Starting a conversation or sending a message
|
|
37
|
+
* stays with the person (runs are started by them), and so do the live stream and the other
|
|
38
|
+
* display reads (see `exclusions.ts`).
|
|
39
|
+
*/
|
|
40
|
+
let ConversationsOperations = class ConversationsOperations {
|
|
41
|
+
registry;
|
|
42
|
+
conversations;
|
|
43
|
+
files;
|
|
44
|
+
environment;
|
|
45
|
+
kdb;
|
|
46
|
+
constructor(registry, conversations, files, environment, kdb) {
|
|
47
|
+
this.registry = registry;
|
|
48
|
+
this.conversations = conversations;
|
|
49
|
+
this.files = files;
|
|
50
|
+
this.environment = environment;
|
|
51
|
+
this.kdb = kdb;
|
|
52
|
+
}
|
|
53
|
+
/**
|
|
54
|
+
* Whether `id` is the conversation this run belongs to: its ROOT (the Platform tool also runs in
|
|
55
|
+
* sub-agents, whose own id is not the person's conversation). Stopping or deleting it would end
|
|
56
|
+
* the very run that asked.
|
|
57
|
+
*/
|
|
58
|
+
async isRunsRoot(id, ctx) {
|
|
59
|
+
const root = await rootConversationOf(this.kdb.db, ctx.conversationId);
|
|
60
|
+
return id === root || id === ctx.conversationId;
|
|
61
|
+
}
|
|
62
|
+
titleOf(ctx, id) {
|
|
63
|
+
return orElse(async () => named((await this.conversations.get(ctx.orgId, id, ctx.actorAccountId)).title ?? id), id);
|
|
64
|
+
}
|
|
65
|
+
precheckWritable(id, ctx) {
|
|
66
|
+
return precheckBy(() => this.conversations.writable(ctx.orgId, id, ctx.actorAccountId));
|
|
67
|
+
}
|
|
68
|
+
async setArchived(id, archived, ctx) {
|
|
69
|
+
return {
|
|
70
|
+
conversation: await this.conversations.setArchived(ctx.orgId, id, ctx.actorAccountId, archived),
|
|
71
|
+
};
|
|
72
|
+
}
|
|
73
|
+
onModuleInit() {
|
|
74
|
+
this.registry.register([
|
|
75
|
+
defineOperation({
|
|
76
|
+
id: "conversations.list",
|
|
77
|
+
description: "List your own conversations, most recently updated first: id, name, state (running, waiting, idle or archived), agent id and update time. Pages by 50: pass the returned next as params.after. Filter by title text q, by agentId, by state (running or waiting), or pass archived 1 for the archived ones.",
|
|
78
|
+
input: ListQuery.pick({
|
|
79
|
+
q: true,
|
|
80
|
+
state: true,
|
|
81
|
+
archived: true,
|
|
82
|
+
agentId: true,
|
|
83
|
+
after: true,
|
|
84
|
+
}).strict(),
|
|
85
|
+
example: { q: "report" },
|
|
86
|
+
authz: { orgAction: "agents.use" },
|
|
87
|
+
mirrors: ["GET /api/v1/orgs/:orgId/conversations"],
|
|
88
|
+
// the page size is fixed at 50
|
|
89
|
+
omits: ["limit"],
|
|
90
|
+
confirm: "read",
|
|
91
|
+
run: async (input, ctx) => {
|
|
92
|
+
const rows = await this.conversations.listMine(ctx.orgId, ctx.actorAccountId, {
|
|
93
|
+
limit: PAGE + 1,
|
|
94
|
+
...(input.after !== undefined && { after: input.after }),
|
|
95
|
+
...(input.agentId !== undefined && { agentId: input.agentId }),
|
|
96
|
+
...(input.q !== undefined && { q: input.q }),
|
|
97
|
+
...(input.state !== undefined && { state: input.state }),
|
|
98
|
+
...(input.archived !== undefined && { archived: true }),
|
|
99
|
+
});
|
|
100
|
+
const items = rows.slice(0, PAGE);
|
|
101
|
+
return {
|
|
102
|
+
conversations: items.map(row),
|
|
103
|
+
next: rows.length > PAGE ? (items.at(-1)?.id ?? null) : null,
|
|
104
|
+
};
|
|
105
|
+
},
|
|
106
|
+
}),
|
|
107
|
+
defineOperation({
|
|
108
|
+
id: "conversations.get",
|
|
109
|
+
description: "Read one of your conversations: title, agent, model selection, archived time, last event seq and what it is doing now. Takes the id from conversations.list.",
|
|
110
|
+
input: Id,
|
|
111
|
+
example: { conversationId: "3f2b8a40-6c1d-4e0b-9a77-5d1e2c8b9f10" },
|
|
112
|
+
authz: { orgAction: "agents.use" },
|
|
113
|
+
mirrors: ["GET /api/v1/orgs/:orgId/conversations/:id"],
|
|
114
|
+
renames: { conversationId: "id" },
|
|
115
|
+
errors: [
|
|
116
|
+
{
|
|
117
|
+
code: "conversation.not_found",
|
|
118
|
+
next: "Check the id with conversations.list: only your own conversations can be read or changed.",
|
|
119
|
+
},
|
|
120
|
+
],
|
|
121
|
+
confirm: "read",
|
|
122
|
+
run: async (input, ctx) => ({
|
|
123
|
+
conversation: await this.conversations.get(ctx.orgId, input.conversationId, ctx.actorAccountId),
|
|
124
|
+
}),
|
|
125
|
+
}),
|
|
126
|
+
defineOperation({
|
|
127
|
+
id: "conversations.events",
|
|
128
|
+
description: 'Read the event log of one of your conversations (messages, tool calls, results) in order, at most 100 events per call. Pass after (a seq; the last seq of the previous page) to read forward from the start, or before (a seq, or "end" for the log\'s last turns) to read the turns before it; the two cannot be combined. Takes the id from conversations.list.',
|
|
129
|
+
input: z
|
|
130
|
+
.object({
|
|
131
|
+
conversationId: ConversationId,
|
|
132
|
+
after: EventsQuery.shape.after,
|
|
133
|
+
before: EventsQuery.shape.before,
|
|
134
|
+
limit: z.number().int().min(1).max(EVENTS_PAGE_MAX).default(EVENTS_PAGE_MAX),
|
|
135
|
+
})
|
|
136
|
+
.strict()
|
|
137
|
+
.refine((q) => q.after === undefined || q.before === undefined, {
|
|
138
|
+
message: "after and before are exclusive",
|
|
139
|
+
path: ["before"],
|
|
140
|
+
}),
|
|
141
|
+
example: {
|
|
142
|
+
conversationId: "3f2b8a40-6c1d-4e0b-9a77-5d1e2c8b9f10",
|
|
143
|
+
before: "end",
|
|
144
|
+
limit: 100,
|
|
145
|
+
},
|
|
146
|
+
authz: { orgAction: "agents.use" },
|
|
147
|
+
mirrors: ["GET /api/v1/orgs/:orgId/conversations/:id/events"],
|
|
148
|
+
renames: { conversationId: "id" },
|
|
149
|
+
errors: [
|
|
150
|
+
{
|
|
151
|
+
code: "conversation.not_found",
|
|
152
|
+
next: "Check the id with conversations.list: only your own conversations can be read or changed.",
|
|
153
|
+
},
|
|
154
|
+
],
|
|
155
|
+
confirm: "read",
|
|
156
|
+
run: async (input, ctx) => {
|
|
157
|
+
if (input.before !== undefined) {
|
|
158
|
+
return this.conversations.listEventsBefore(ctx.orgId, input.conversationId, ctx.actorAccountId, input.before === "end" ? null : input.before, input.limit);
|
|
159
|
+
}
|
|
160
|
+
return {
|
|
161
|
+
events: await this.conversations.listEvents(ctx.orgId, input.conversationId, ctx.actorAccountId, input.after ?? 0, input.limit),
|
|
162
|
+
};
|
|
163
|
+
},
|
|
164
|
+
}),
|
|
165
|
+
defineOperation({
|
|
166
|
+
id: "conversations.rename",
|
|
167
|
+
description: "Rename one of your conversations. The new title is kept and never replaced by a generated one. Takes the id from conversations.list. The person may remember this permission.",
|
|
168
|
+
input: z
|
|
169
|
+
.object({ conversationId: ConversationId, title: PatchBody.shape.title.unwrap() })
|
|
170
|
+
.strict(),
|
|
171
|
+
example: { conversationId: "3f2b8a40-6c1d-4e0b-9a77-5d1e2c8b9f10", title: "Q3 report" },
|
|
172
|
+
authz: { orgAction: "agents.use" },
|
|
173
|
+
mirrors: ["PATCH /api/v1/orgs/:orgId/conversations/:id"],
|
|
174
|
+
// archiving is its own operation
|
|
175
|
+
omits: ["archived"],
|
|
176
|
+
renames: { conversationId: "id" },
|
|
177
|
+
errors: [
|
|
178
|
+
{
|
|
179
|
+
code: "conversation.not_found",
|
|
180
|
+
next: "Check the id with conversations.list: only your own conversations can be read or changed.",
|
|
181
|
+
},
|
|
182
|
+
{
|
|
183
|
+
code: "conversation.read_only",
|
|
184
|
+
next: "That is a sub-agent's conversation and cannot be changed; use the conversation it belongs to.",
|
|
185
|
+
},
|
|
186
|
+
],
|
|
187
|
+
confirm: "personal",
|
|
188
|
+
precheck: (i, ctx) => precheckBy(() => this.conversations.writable(ctx.orgId, i.conversationId, ctx.actorAccountId)),
|
|
189
|
+
summary: async (i, ctx) => {
|
|
190
|
+
const old = await this.titleOf(ctx, i.conversationId);
|
|
191
|
+
return {
|
|
192
|
+
zh: `将对话「${old}」重命名为「${named(i.title)}」`,
|
|
193
|
+
en: `Rename conversation "${old}" to "${named(i.title)}"`,
|
|
194
|
+
};
|
|
195
|
+
},
|
|
196
|
+
run: async (input, ctx) => ({
|
|
197
|
+
conversation: await this.conversations.rename(ctx.orgId, input.conversationId, ctx.actorAccountId, input.title),
|
|
198
|
+
}),
|
|
199
|
+
}),
|
|
200
|
+
defineOperation({
|
|
201
|
+
id: "conversations.archive",
|
|
202
|
+
description: "Archive one of your conversations: it leaves the default list and stays readable; conversations.unarchive brings it back. The person may remember this permission.",
|
|
203
|
+
input: Id,
|
|
204
|
+
example: { conversationId: "3f2b8a40-6c1d-4e0b-9a77-5d1e2c8b9f10" },
|
|
205
|
+
authz: { orgAction: "agents.use" },
|
|
206
|
+
mirrors: ["PATCH /api/v1/orgs/:orgId/conversations/:id"],
|
|
207
|
+
// the title is conversations.rename; `archived` is fixed by the operation
|
|
208
|
+
omits: ["title", "archived"],
|
|
209
|
+
renames: { conversationId: "id" },
|
|
210
|
+
errors: [
|
|
211
|
+
{
|
|
212
|
+
code: "conversation.not_found",
|
|
213
|
+
next: "Check the id with conversations.list: only your own conversations can be read or changed.",
|
|
214
|
+
},
|
|
215
|
+
{
|
|
216
|
+
code: "conversation.read_only",
|
|
217
|
+
next: "That is a sub-agent's conversation and cannot be changed; use the conversation it belongs to.",
|
|
218
|
+
},
|
|
219
|
+
],
|
|
220
|
+
confirm: "personal",
|
|
221
|
+
precheck: (i, ctx) => this.precheckWritable(i.conversationId, ctx),
|
|
222
|
+
summary: async (i, ctx) => {
|
|
223
|
+
const t = await this.titleOf(ctx, i.conversationId);
|
|
224
|
+
return { zh: `归档对话「${t}」`, en: `Archive conversation "${t}"` };
|
|
225
|
+
},
|
|
226
|
+
run: (input, ctx) => this.setArchived(input.conversationId, true, ctx),
|
|
227
|
+
}),
|
|
228
|
+
defineOperation({
|
|
229
|
+
id: "conversations.unarchive",
|
|
230
|
+
description: "Unarchive one of your conversations so it is in the default list again. The person may remember this permission.",
|
|
231
|
+
input: Id,
|
|
232
|
+
example: { conversationId: "3f2b8a40-6c1d-4e0b-9a77-5d1e2c8b9f10" },
|
|
233
|
+
authz: { orgAction: "agents.use" },
|
|
234
|
+
mirrors: ["PATCH /api/v1/orgs/:orgId/conversations/:id"],
|
|
235
|
+
omits: ["title", "archived"],
|
|
236
|
+
renames: { conversationId: "id" },
|
|
237
|
+
errors: [
|
|
238
|
+
{
|
|
239
|
+
code: "conversation.not_found",
|
|
240
|
+
next: "Check the id with conversations.list: only your own conversations can be read or changed.",
|
|
241
|
+
},
|
|
242
|
+
{
|
|
243
|
+
code: "conversation.read_only",
|
|
244
|
+
next: "That is a sub-agent's conversation and cannot be changed; use the conversation it belongs to.",
|
|
245
|
+
},
|
|
246
|
+
],
|
|
247
|
+
confirm: "personal",
|
|
248
|
+
precheck: (i, ctx) => this.precheckWritable(i.conversationId, ctx),
|
|
249
|
+
summary: async (i, ctx) => {
|
|
250
|
+
const t = await this.titleOf(ctx, i.conversationId);
|
|
251
|
+
return { zh: `取消归档对话「${t}」`, en: `Unarchive conversation "${t}"` };
|
|
252
|
+
},
|
|
253
|
+
run: (input, ctx) => this.setArchived(input.conversationId, false, ctx),
|
|
254
|
+
}),
|
|
255
|
+
defineOperation({
|
|
256
|
+
id: "conversations.usage",
|
|
257
|
+
description: "Read the token usage of one of your conversations, its sub-agents included: input, output, cache read and cache write tokens. Takes the id from conversations.list.",
|
|
258
|
+
input: Id,
|
|
259
|
+
example: { conversationId: "3f2b8a40-6c1d-4e0b-9a77-5d1e2c8b9f10" },
|
|
260
|
+
authz: { orgAction: "agents.use" },
|
|
261
|
+
mirrors: ["GET /api/v1/orgs/:orgId/conversations/:id/usage"],
|
|
262
|
+
renames: { conversationId: "id" },
|
|
263
|
+
errors: [
|
|
264
|
+
{
|
|
265
|
+
code: "conversation.not_found",
|
|
266
|
+
next: "Check the id with conversations.list: only your own conversations can be read or changed.",
|
|
267
|
+
},
|
|
268
|
+
],
|
|
269
|
+
confirm: "read",
|
|
270
|
+
run: async (input, ctx) => ({
|
|
271
|
+
usage: await this.conversations.usage(ctx.orgId, input.conversationId, ctx.actorAccountId),
|
|
272
|
+
}),
|
|
273
|
+
}),
|
|
274
|
+
defineOperation({
|
|
275
|
+
id: "conversations.subagents",
|
|
276
|
+
description: "List the sub-agents one of your conversations dispatched, newest first: id, type, description, status, tool calls, times, usage and any pending approval or question ids. Pages by 50: pass the returned next as params.after.",
|
|
277
|
+
input: SubagentsQuery.pick({ after: true })
|
|
278
|
+
.extend({ conversationId: ConversationId })
|
|
279
|
+
.strict(),
|
|
280
|
+
example: { conversationId: "3f2b8a40-6c1d-4e0b-9a77-5d1e2c8b9f10" },
|
|
281
|
+
authz: { orgAction: "agents.use" },
|
|
282
|
+
mirrors: ["GET /api/v1/orgs/:orgId/conversations/:id/subagents"],
|
|
283
|
+
// the page size is fixed at 50
|
|
284
|
+
omits: ["limit"],
|
|
285
|
+
renames: { conversationId: "id" },
|
|
286
|
+
errors: [
|
|
287
|
+
{
|
|
288
|
+
code: "conversation.not_found",
|
|
289
|
+
next: "Check the id with conversations.list: only your own conversations can be read or changed.",
|
|
290
|
+
},
|
|
291
|
+
],
|
|
292
|
+
confirm: "read",
|
|
293
|
+
run: async (input, ctx) => this.conversations.listSubagents(ctx.orgId, input.conversationId, ctx.actorAccountId, {
|
|
294
|
+
limit: PAGE,
|
|
295
|
+
...(input.after !== undefined && { after: input.after }),
|
|
296
|
+
}),
|
|
297
|
+
}),
|
|
298
|
+
defineOperation({
|
|
299
|
+
id: "conversations.agent-tree",
|
|
300
|
+
description: "Read the agent tree of one of your conversations: the conversation and every sub-agent below it with status, model, time, tokens and tool calls. Only a conversation you started, not a sub-agent's, has a tree.",
|
|
301
|
+
input: Id,
|
|
302
|
+
example: { conversationId: "3f2b8a40-6c1d-4e0b-9a77-5d1e2c8b9f10" },
|
|
303
|
+
authz: { orgAction: "agents.use" },
|
|
304
|
+
mirrors: ["GET /api/v1/orgs/:orgId/conversations/:id/agent-tree"],
|
|
305
|
+
renames: { conversationId: "id" },
|
|
306
|
+
errors: [
|
|
307
|
+
{
|
|
308
|
+
code: "conversation.not_found",
|
|
309
|
+
next: "Check the id with conversations.list: only your own conversations, not their sub-agents, have a tree.",
|
|
310
|
+
},
|
|
311
|
+
],
|
|
312
|
+
confirm: "read",
|
|
313
|
+
run: async (input, ctx) => this.conversations.agentTree(ctx.orgId, input.conversationId, ctx.actorAccountId),
|
|
314
|
+
}),
|
|
315
|
+
defineOperation({
|
|
316
|
+
id: "conversations.files",
|
|
317
|
+
description: "List the files one of your conversations produced, newest first: id, name, state (available or removed), type, size and version. File contents are downloaded on the web. Pages by 50: pass the returned next as params.after.",
|
|
318
|
+
input: FilesQuery.pick({ after: true }).extend({ conversationId: ConversationId }).strict(),
|
|
319
|
+
example: { conversationId: "3f2b8a40-6c1d-4e0b-9a77-5d1e2c8b9f10" },
|
|
320
|
+
authz: { orgAction: "agents.use" },
|
|
321
|
+
mirrors: ["GET /api/v1/orgs/:orgId/conversations/:id/files"],
|
|
322
|
+
// the page size is fixed at 50
|
|
323
|
+
omits: ["limit"],
|
|
324
|
+
renames: { conversationId: "id" },
|
|
325
|
+
errors: [
|
|
326
|
+
{
|
|
327
|
+
code: "conversation.not_found",
|
|
328
|
+
next: "Check the id with conversations.list: only your own conversations can be read or changed.",
|
|
329
|
+
},
|
|
330
|
+
],
|
|
331
|
+
confirm: "read",
|
|
332
|
+
run: async (input, ctx) => {
|
|
333
|
+
const out = await this.files.list(ctx.orgId, input.conversationId, ctx.actorAccountId, {
|
|
334
|
+
limit: PAGE,
|
|
335
|
+
...(input.after !== undefined && { after: input.after }),
|
|
336
|
+
});
|
|
337
|
+
return {
|
|
338
|
+
files: out.files.map((f) => ({
|
|
339
|
+
id: f.id,
|
|
340
|
+
name: f.name,
|
|
341
|
+
state: f.status,
|
|
342
|
+
contentType: f.contentType,
|
|
343
|
+
size: f.size,
|
|
344
|
+
version: f.version,
|
|
345
|
+
})),
|
|
346
|
+
next: out.next,
|
|
347
|
+
};
|
|
348
|
+
},
|
|
349
|
+
}),
|
|
350
|
+
defineOperation({
|
|
351
|
+
id: "conversations.environment",
|
|
352
|
+
description: "Read the environment one of your conversations works in and whether its instance is running or suspended; environment is null while the conversation has none. Takes the id from conversations.list.",
|
|
353
|
+
input: Id,
|
|
354
|
+
example: { conversationId: "3f2b8a40-6c1d-4e0b-9a77-5d1e2c8b9f10" },
|
|
355
|
+
authz: { orgAction: "agents.use" },
|
|
356
|
+
mirrors: ["GET /api/v1/orgs/:orgId/conversations/:id/environment"],
|
|
357
|
+
renames: { conversationId: "id" },
|
|
358
|
+
errors: [
|
|
359
|
+
{
|
|
360
|
+
code: "conversation.not_found",
|
|
361
|
+
next: "Check the id with conversations.list: only your own conversations can be read or changed.",
|
|
362
|
+
},
|
|
363
|
+
],
|
|
364
|
+
confirm: "read",
|
|
365
|
+
run: async (input, ctx) => ({
|
|
366
|
+
environment: await this.environment.get(ctx.orgId, input.conversationId, ctx.actorAccountId),
|
|
367
|
+
}),
|
|
368
|
+
}),
|
|
369
|
+
defineOperation({
|
|
370
|
+
id: "conversations.abort",
|
|
371
|
+
description: "Stop the run that is active in one of your other conversations (its sub-agents keep working; stopping a sub-agent's conversation stops it and those below it). Nothing happens if no run is active. The person confirms every stop; it is never remembered. The conversation you are working in cannot be stopped.",
|
|
372
|
+
input: Id,
|
|
373
|
+
example: { conversationId: "3f2b8a40-6c1d-4e0b-9a77-5d1e2c8b9f10" },
|
|
374
|
+
authz: { orgAction: "agents.use" },
|
|
375
|
+
mirrors: ["POST /api/v1/orgs/:orgId/conversations/:id/abort"],
|
|
376
|
+
renames: { conversationId: "id" },
|
|
377
|
+
errors: [
|
|
378
|
+
{
|
|
379
|
+
code: "conversation.not_found",
|
|
380
|
+
next: "Check the id with conversations.list: only your own conversations can be read or changed.",
|
|
381
|
+
},
|
|
382
|
+
{
|
|
383
|
+
code: "run.not_active",
|
|
384
|
+
next: "No run is active in that conversation: nothing to stop; check conversations.list for its state.",
|
|
385
|
+
},
|
|
386
|
+
{
|
|
387
|
+
code: "conversation.abort_current",
|
|
388
|
+
next: "This is the conversation you are running in: ask the person to stop it on the web, or stop a different one.",
|
|
389
|
+
},
|
|
390
|
+
],
|
|
391
|
+
confirm: "personal",
|
|
392
|
+
rememberable: false,
|
|
393
|
+
precheck: async (i, ctx) => {
|
|
394
|
+
if (await this.isRunsRoot(i.conversationId, ctx)) {
|
|
395
|
+
return {
|
|
396
|
+
ok: false,
|
|
397
|
+
code: "conversation.abort_current",
|
|
398
|
+
message: "The conversation you are running in cannot be stopped from here.",
|
|
399
|
+
};
|
|
400
|
+
}
|
|
401
|
+
return precheckBy(() => this.conversations.get(ctx.orgId, i.conversationId, ctx.actorAccountId));
|
|
402
|
+
},
|
|
403
|
+
summary: async (i, ctx) => {
|
|
404
|
+
const t = await this.titleOf(ctx, i.conversationId);
|
|
405
|
+
return {
|
|
406
|
+
zh: `停止对话「${t}」中正在进行的运行`,
|
|
407
|
+
en: `Stop the active run in conversation "${t}"`,
|
|
408
|
+
};
|
|
409
|
+
},
|
|
410
|
+
run: async (input, ctx) => ({
|
|
411
|
+
stopped: true,
|
|
412
|
+
runId: await this.conversations.abort(ctx.orgId, input.conversationId, ctx.actorAccountId),
|
|
413
|
+
}),
|
|
414
|
+
}),
|
|
415
|
+
defineOperation({
|
|
416
|
+
id: "conversations.delete",
|
|
417
|
+
description: "Delete one of your conversations: a running run in it is stopped and the conversation disappears from every list. This cannot be undone from the tool. The person confirms every delete; it is never remembered. The conversation you are working in cannot be deleted.",
|
|
418
|
+
input: Id,
|
|
419
|
+
example: { conversationId: "3f2b8a40-6c1d-4e0b-9a77-5d1e2c8b9f10" },
|
|
420
|
+
authz: { orgAction: "agents.use" },
|
|
421
|
+
mirrors: ["DELETE /api/v1/orgs/:orgId/conversations/:id"],
|
|
422
|
+
renames: { conversationId: "id" },
|
|
423
|
+
errors: [
|
|
424
|
+
{
|
|
425
|
+
code: "conversation.not_found",
|
|
426
|
+
next: "Check the id with conversations.list: only your own conversations can be read or changed.",
|
|
427
|
+
},
|
|
428
|
+
{
|
|
429
|
+
code: "conversation.read_only",
|
|
430
|
+
next: "That is a sub-agent's conversation and cannot be changed; use the conversation it belongs to.",
|
|
431
|
+
},
|
|
432
|
+
{
|
|
433
|
+
code: "conversation.delete_current",
|
|
434
|
+
next: "This is the conversation you are running in: ask the person to delete it from the web sidebar, or delete a different one.",
|
|
435
|
+
},
|
|
436
|
+
],
|
|
437
|
+
confirm: "personal",
|
|
438
|
+
// destructive: `personal` in rights, but each delete is asked and never remembered
|
|
439
|
+
rememberable: false,
|
|
440
|
+
precheck: async (i, ctx) => {
|
|
441
|
+
if (await this.isRunsRoot(i.conversationId, ctx)) {
|
|
442
|
+
return {
|
|
443
|
+
ok: false,
|
|
444
|
+
code: "conversation.delete_current",
|
|
445
|
+
message: "The conversation you are running in cannot be deleted from here.",
|
|
446
|
+
};
|
|
447
|
+
}
|
|
448
|
+
return precheckBy(() => this.conversations.writable(ctx.orgId, i.conversationId, ctx.actorAccountId));
|
|
449
|
+
},
|
|
450
|
+
summary: async (i, ctx) => {
|
|
451
|
+
const t = await this.titleOf(ctx, i.conversationId);
|
|
452
|
+
return { zh: `删除对话「${t}」`, en: `Delete conversation "${t}"` };
|
|
453
|
+
},
|
|
454
|
+
run: async (input, ctx) => {
|
|
455
|
+
await this.conversations.remove(ctx.orgId, input.conversationId, ctx.actorAccountId);
|
|
456
|
+
return { deleted: true, conversationId: input.conversationId };
|
|
457
|
+
},
|
|
458
|
+
}),
|
|
459
|
+
]);
|
|
460
|
+
}
|
|
461
|
+
};
|
|
462
|
+
ConversationsOperations = __decorate([
|
|
463
|
+
Injectable(),
|
|
464
|
+
__param(0, Inject(PlatformOperations)),
|
|
465
|
+
__param(1, Inject(ConversationsService)),
|
|
466
|
+
__param(2, Inject(ConversationFiles)),
|
|
467
|
+
__param(3, Inject(ConversationEnvironmentStatus)),
|
|
468
|
+
__param(4, Inject(KernelDb))
|
|
469
|
+
], ConversationsOperations);
|
|
470
|
+
export { ConversationsOperations };
|