@capybara-hq/kernel 0.1.0-rc.6 → 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 +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 +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/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 +68 -849
- 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/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
package/dist/tools/registry.js
CHANGED
|
@@ -10,6 +10,7 @@ var __param = (this && this.__param) || function (paramIndex, decorator) {
|
|
|
10
10
|
import { createHash } from "node:crypto";
|
|
11
11
|
import { connectorToolKey, extensionToolKey } from "@capybara-hq/plugin-sdk";
|
|
12
12
|
import { Inject, Injectable } from "@nestjs/common";
|
|
13
|
+
import { builtinDisabled, connectorToolDisabled, extensionToolDisabled, } from "../agents/definition.js";
|
|
13
14
|
import { EffectiveConfigs, NEEDS_CONFIG_REASON } from "../extensions/effective-config.js";
|
|
14
15
|
import { ExtensionHost } from "../extensions/host.js";
|
|
15
16
|
import { ExtensionRegistry } from "../extensions/registry.js";
|
|
@@ -19,7 +20,7 @@ import { readOrgSettings } from "../orgs/settings.service.js";
|
|
|
19
20
|
import { estimateTokens } from "../runtime/context/tokens.js";
|
|
20
21
|
import { SUBAGENT_LIMIT_DEFAULTS, subagentLimits } from "../runtime/subagents/limits.js";
|
|
21
22
|
import { resolveRoster } from "../runtime/subagents/roster.js";
|
|
22
|
-
import { AGENT_TOOL, BASH_COMPANION_TOOLS, BUILTIN,
|
|
23
|
+
import { AGENT_BUILTIN_NAMES, AGENT_TOOL, BASH_COMPANION_TOOLS, BUILTIN, SEND_MESSAGE, SKILL_LOAD, SUBAGENT_HANDBACK, TOOL_SEARCH, } from "./builtin-names.js";
|
|
23
24
|
import { agentToolSpec } from "./builtins/agent.js";
|
|
24
25
|
import { BuiltinTools } from "./builtins/builtin-tools.js";
|
|
25
26
|
import { canonicalJson } from "./canonical-json.js";
|
|
@@ -85,23 +86,21 @@ const builtinTool = (b, spec) => ({
|
|
|
85
86
|
...(b.callPolicy !== undefined && { callPolicy: b.callPolicy }),
|
|
86
87
|
});
|
|
87
88
|
/**
|
|
88
|
-
* Tool registry: resolves
|
|
89
|
-
*
|
|
90
|
-
* replicas.
|
|
89
|
+
* Tool registry: resolves what an agent has for this run (tools default-on spec §4): everything
|
|
90
|
+
* the org offers minus the definition's `disabledTools`. Not cached (reads PG and the host live
|
|
91
|
+
* every time), so changes take effect right away across replicas.
|
|
91
92
|
*
|
|
92
|
-
*
|
|
93
|
-
* -
|
|
94
|
-
*
|
|
95
|
-
*
|
|
96
|
-
* org
|
|
97
|
-
*
|
|
98
|
-
*
|
|
99
|
-
* - connector tools:
|
|
100
|
-
*
|
|
101
|
-
*
|
|
102
|
-
*
|
|
103
|
-
* Only the first of a key is kept; the same source referenced twice is deduplicated silently,
|
|
104
|
-
* different sources with the same key report a duplicate.
|
|
93
|
+
* What is offered:
|
|
94
|
+
* - builtins: every {@link AGENT_BUILTIN_NAMES} entry registered here that can run (`unavailable`
|
|
95
|
+
* says why not), `TaskOutput` / `TaskStop` with `Bash`, `Agent` while its roster is not empty;
|
|
96
|
+
* - extension tools: every tool registered by an extension loaded on this replica and enabled in
|
|
97
|
+
* the org (`extension_org_configs.enabled`; required bootstrap plugins are enabled in every org,
|
|
98
|
+
* `enabled.ts`), whose effective config for the org is valid (layering spec A §6) and that the
|
|
99
|
+
* org did not switch off (§7: the org's switch wins);
|
|
100
|
+
* - connector tools: every enabled tool of every live, active connector of the org whose
|
|
101
|
+
* connector extension is installed, with a valid key.
|
|
102
|
+
* What cannot be offered goes to `hidden` with the reason; nothing is reported to the model as
|
|
103
|
+
* unavailable except two sources with one key (the first wins).
|
|
105
104
|
*/
|
|
106
105
|
let ToolRegistry = class ToolRegistry {
|
|
107
106
|
db;
|
|
@@ -213,92 +212,93 @@ let ToolRegistry = class ToolRegistry {
|
|
|
213
212
|
return (await this.connectorKindsFor(orgId)).some((k) => k.kind === kind);
|
|
214
213
|
}
|
|
215
214
|
/**
|
|
216
|
-
*
|
|
217
|
-
*
|
|
218
|
-
*
|
|
219
|
-
* -
|
|
220
|
-
*
|
|
221
|
-
*
|
|
215
|
+
* Checks a definition's `disabledTools` on save (existence only): a builtin an agent can turn off
|
|
216
|
+
* ({@link AGENT_BUILTIN_NAMES}), an extension loaded here and the tools it registered, a live
|
|
217
|
+
* connector of the org and tools of its snapshot. An entry equal to one of `kept` (the current
|
|
218
|
+
* version's) is not re-checked: a connector deleted or an extension uninstalled later never
|
|
219
|
+
* blocks other edits. Returns `keys`: every tool key the agent could have, on or turned off (all
|
|
220
|
+
* its builtins, every loaded extension's tools, every tool of the org's live connectors in any
|
|
221
|
+
* status), the keys `toolPolicies` may use.
|
|
222
222
|
*/
|
|
223
|
-
async
|
|
223
|
+
async checkDisabled(orgId, disabled, kept = []) {
|
|
224
224
|
const issues = [];
|
|
225
|
-
const
|
|
225
|
+
const keys = new Set();
|
|
226
|
+
for (const name of AGENT_BUILTIN_NAMES)
|
|
227
|
+
keys.add(name);
|
|
228
|
+
for (const name of BASH_COMPANION_TOOLS)
|
|
229
|
+
keys.add(name);
|
|
226
230
|
const pluginTools = this.host.tools();
|
|
227
|
-
const
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
const
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
refs.forEach((ref, i) => {
|
|
240
|
-
const path = `tools.${i}`;
|
|
231
|
+
for (const t of pluginTools)
|
|
232
|
+
keys.add(extensionToolKey(t.plugin, t.spec.name));
|
|
233
|
+
const apps = await this.loadOrgConnectors(orgId, { includeDeleted: false });
|
|
234
|
+
for (const app of apps)
|
|
235
|
+
for (const t of app.tools)
|
|
236
|
+
keys.add(connectorToolKey(app.slug, t.name));
|
|
237
|
+
const builtins = new Set(AGENT_BUILTIN_NAMES);
|
|
238
|
+
const keptJson = new Set(kept.map((r) => canonicalJson(r)));
|
|
239
|
+
disabled.forEach((ref, i) => {
|
|
240
|
+
const path = `disabledTools.${i}`;
|
|
241
|
+
if (keptJson.has(canonicalJson(ref)))
|
|
242
|
+
return;
|
|
241
243
|
if (ref.kind === "builtin") {
|
|
242
|
-
if (!
|
|
244
|
+
if (!builtins.has(ref.name)) {
|
|
243
245
|
const renamed = legacyKeySaveText(ref.name);
|
|
244
246
|
issues.push({
|
|
245
247
|
path,
|
|
246
|
-
message: renamed
|
|
247
|
-
? `Built-in tool
|
|
248
|
-
: `
|
|
248
|
+
message: renamed !== null
|
|
249
|
+
? `Built-in tool ${renamed}`
|
|
250
|
+
: `"${ref.name}" is not a built-in tool an agent can turn off`,
|
|
249
251
|
});
|
|
250
|
-
return;
|
|
251
|
-
}
|
|
252
|
-
claim(path, ref.name, `builtin:${ref.name}`);
|
|
253
|
-
// offered with Bash (see resolve), so their policies validate too
|
|
254
|
-
if (ref.name === BUILTIN.Bash) {
|
|
255
|
-
for (const c of BASH_COMPANION_TOOLS)
|
|
256
|
-
claim(path, c, `builtin:${c}`);
|
|
257
252
|
}
|
|
258
253
|
}
|
|
259
254
|
else if (ref.kind === "plugin") {
|
|
260
|
-
const
|
|
261
|
-
if (
|
|
262
|
-
issues.push({ path, message: `
|
|
255
|
+
const own = pluginTools.filter((x) => x.plugin === ref.plugin);
|
|
256
|
+
if (own.length === 0) {
|
|
257
|
+
issues.push({ path, message: `Extension "${ref.plugin}" has no tools` });
|
|
263
258
|
return;
|
|
264
259
|
}
|
|
265
|
-
|
|
266
|
-
if (issue) {
|
|
267
|
-
issues.push({ path, message: issue });
|
|
260
|
+
if (ref.tools === "all")
|
|
268
261
|
return;
|
|
262
|
+
for (const name of ref.tools) {
|
|
263
|
+
if (!own.some((x) => x.spec.name === name)) {
|
|
264
|
+
issues.push({
|
|
265
|
+
path,
|
|
266
|
+
message: `Extension tool "${extensionToolKey(ref.plugin, name)}" does not exist`,
|
|
267
|
+
});
|
|
268
|
+
}
|
|
269
269
|
}
|
|
270
|
-
claim(path, key, `plugin:${ref.plugin}:${ref.name}`);
|
|
271
270
|
}
|
|
272
271
|
else {
|
|
273
|
-
const app = apps.
|
|
274
|
-
if (!app
|
|
272
|
+
const app = apps.find((a) => a.id === ref.connectorId);
|
|
273
|
+
if (!app) {
|
|
275
274
|
issues.push({ path, message: `Connector "${ref.connectorId}" does not exist` });
|
|
276
275
|
return;
|
|
277
276
|
}
|
|
278
|
-
|
|
279
|
-
|
|
277
|
+
if (ref.tools === "all")
|
|
278
|
+
return;
|
|
279
|
+
for (const name of ref.tools) {
|
|
280
280
|
if (!app.tools.some((t) => t.name === name)) {
|
|
281
281
|
issues.push({
|
|
282
282
|
path,
|
|
283
283
|
message: `Tool "${name}" does not exist in connector ${app.slug}`,
|
|
284
284
|
});
|
|
285
|
-
continue;
|
|
286
285
|
}
|
|
287
|
-
claim(path, connectorToolKey(app.slug, name), `connector:${app.id}:${name}`);
|
|
288
286
|
}
|
|
289
287
|
}
|
|
290
288
|
});
|
|
291
|
-
return { keys
|
|
289
|
+
return { keys, issues };
|
|
292
290
|
}
|
|
293
291
|
/**
|
|
294
|
-
*
|
|
295
|
-
*
|
|
296
|
-
*
|
|
297
|
-
* `skillLoad
|
|
298
|
-
*
|
|
292
|
+
* Resolves what the agent has (see the class comment), then decides on `ToolSearch`: the org
|
|
293
|
+
* setting `toolSearch === "on"` and more than `tools.searchThresholdTools` tools or more than
|
|
294
|
+
* `tools.searchThresholdTokens` estimated definition tokens; when on, the builtin `ToolSearch` is
|
|
295
|
+
* appended. `skillLoad`: the log has a skills catalog snapshot (`skills_catalog`, Ruling M17) →
|
|
296
|
+
* the builtin `Skill` is added (always fully loaded).
|
|
299
297
|
*/
|
|
300
298
|
async forAgent(orgId, def) {
|
|
301
|
-
const
|
|
299
|
+
const resolved = await this.resolve(orgId, def);
|
|
300
|
+
const { unavailable, hidden } = resolved;
|
|
301
|
+
const tools = filterSubagentTools(resolved.tools, def.subagentTools);
|
|
302
302
|
// `SendMessage` to an agent that has `Agent` (to reach its sub-agents) or a parent;
|
|
303
303
|
// `SubagentHandback` to a sub-agent only; a fork invocation's child reports by its reply
|
|
304
304
|
const toParent = def.child === true && def.forkChild !== true;
|
|
@@ -347,6 +347,7 @@ let ToolRegistry = class ToolRegistry {
|
|
|
347
347
|
return (await readOrgSettings(this.db.db, orgId)).toolSearch === "on";
|
|
348
348
|
}
|
|
349
349
|
async resolve(orgId, def) {
|
|
350
|
+
const disabled = def.disabledTools ?? [];
|
|
350
351
|
const tools = [];
|
|
351
352
|
const unavailable = [];
|
|
352
353
|
const hidden = [];
|
|
@@ -365,155 +366,135 @@ let ToolRegistry = class ToolRegistry {
|
|
|
365
366
|
});
|
|
366
367
|
}
|
|
367
368
|
};
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
let ok = configured.get(plugin);
|
|
380
|
-
if (!ok) {
|
|
381
|
-
ok = this.effective.get(orgId, plugin).then((e) => e.ok);
|
|
382
|
-
configured.set(plugin, ok);
|
|
369
|
+
// builtins
|
|
370
|
+
for (const name of AGENT_BUILTIN_NAMES) {
|
|
371
|
+
if (builtinDisabled(disabled, name))
|
|
372
|
+
continue;
|
|
373
|
+
const b = this.builtins.find((x) => x.spec.name === name);
|
|
374
|
+
if (!b)
|
|
375
|
+
continue;
|
|
376
|
+
const why = (await b.unavailable?.({ orgId })) ?? null;
|
|
377
|
+
if (why !== null) {
|
|
378
|
+
hidden.push({ ref: name, reason: why });
|
|
379
|
+
continue;
|
|
383
380
|
}
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
if (
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
if (SUBAGENT_MESSAGE_TOOLS.has(ref.name))
|
|
381
|
+
// `Agent`: the description lists this definition's roster (sub-agents spec §4.3); with an
|
|
382
|
+
// empty roster there is nothing to dispatch, so the tool is not offered at all
|
|
383
|
+
let spec = b.spec;
|
|
384
|
+
if (name === AGENT_TOOL) {
|
|
385
|
+
const roster = await resolveRoster(this.db.db, orgId, { subagents: def.subagents });
|
|
386
|
+
if (roster.length === 0)
|
|
391
387
|
continue;
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
unavailable
|
|
400
|
-
|
|
401
|
-
}
|
|
402
|
-
// `Agent`: the description lists this definition's roster (sub-agents spec §4.3); with an
|
|
403
|
-
// empty roster there is nothing to dispatch, so the tool is not offered at all
|
|
404
|
-
let spec = b.spec;
|
|
405
|
-
if (b.spec.name === AGENT_TOOL) {
|
|
406
|
-
const roster = await resolveRoster(this.db.db, orgId, { subagents: def.subagents });
|
|
407
|
-
if (roster.length === 0)
|
|
408
|
-
continue;
|
|
409
|
-
spec = agentToolSpec(roster, await this.maxConcurrentSubagents(orgId));
|
|
410
|
-
}
|
|
411
|
-
add(builtinTool(b, spec));
|
|
412
|
-
// `TaskOutput` and `TaskStop` come with an available `Bash` (background Bash spec §2)
|
|
413
|
-
if (b.spec.name === BUILTIN.Bash) {
|
|
414
|
-
for (const name of BASH_COMPANION_TOOLS) {
|
|
415
|
-
const c = this.builtins.find((x) => x.spec.name === name);
|
|
416
|
-
if (c && ((await c.unavailable?.({ orgId })) ?? null) === null)
|
|
417
|
-
add(builtinTool(c, c.spec));
|
|
388
|
+
spec = agentToolSpec(roster, await this.maxConcurrentSubagents(orgId));
|
|
389
|
+
}
|
|
390
|
+
add(builtinTool(b, spec));
|
|
391
|
+
// `TaskOutput` and `TaskStop` come with an available `Bash` (background Bash spec §2)
|
|
392
|
+
if (name === BUILTIN.Bash) {
|
|
393
|
+
for (const companion of BASH_COMPANION_TOOLS) {
|
|
394
|
+
const c = this.builtins.find((x) => x.spec.name === companion);
|
|
395
|
+
if (c && ((await c.unavailable?.({ orgId })) ?? null) === null) {
|
|
396
|
+
add(builtinTool(c, c.spec));
|
|
418
397
|
}
|
|
419
398
|
}
|
|
420
399
|
}
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
400
|
+
}
|
|
401
|
+
// extension tools: the extensions enabled in the org
|
|
402
|
+
const pluginTools = this.host.tools();
|
|
403
|
+
if (pluginTools.length > 0) {
|
|
404
|
+
const [enabledPlugins, offKeys] = await Promise.all([
|
|
405
|
+
this.enabledPlugins(orgId),
|
|
406
|
+
this.switches.offKeys(orgId),
|
|
407
|
+
]);
|
|
408
|
+
// one effective config read per extension and resolution, however many tools it has
|
|
409
|
+
const configured = new Map();
|
|
410
|
+
const configuredIn = (plugin) => {
|
|
411
|
+
let ok = configured.get(plugin);
|
|
412
|
+
if (!ok) {
|
|
413
|
+
ok = this.effective.get(orgId, plugin).then((e) => e.ok);
|
|
414
|
+
configured.set(plugin, ok);
|
|
427
415
|
}
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
});
|
|
416
|
+
return ok;
|
|
417
|
+
};
|
|
418
|
+
for (const t of pluginTools) {
|
|
419
|
+
if (!enabledPlugins.has(t.plugin))
|
|
433
420
|
continue;
|
|
434
|
-
|
|
421
|
+
if (extensionToolDisabled(disabled, t.plugin, t.spec.name))
|
|
422
|
+
continue;
|
|
423
|
+
const key = extensionToolKey(t.plugin, t.spec.name);
|
|
435
424
|
// the pipeline refuses such calls too (a resumed step), this keeps them from the model
|
|
436
425
|
if (offKeys.has(key)) {
|
|
437
|
-
|
|
426
|
+
hidden.push({ ref: key, reason: toolTurnedOffReason(key) });
|
|
438
427
|
continue;
|
|
439
428
|
}
|
|
440
|
-
if (!(await configuredIn(
|
|
441
|
-
|
|
429
|
+
if (!(await configuredIn(t.plugin))) {
|
|
430
|
+
hidden.push({ ref: key, reason: `Plugin ${t.plugin} ${NEEDS_CONFIG_REASON}` });
|
|
442
431
|
continue;
|
|
443
432
|
}
|
|
444
433
|
const issue = toolKeyIssue(key);
|
|
445
434
|
if (issue) {
|
|
446
|
-
|
|
435
|
+
hidden.push({ ref: key, reason: issue });
|
|
447
436
|
continue;
|
|
448
437
|
}
|
|
449
438
|
add({
|
|
450
439
|
key,
|
|
451
|
-
source: { kind: "plugin", plugin:
|
|
440
|
+
source: { kind: "plugin", plugin: t.plugin, name: t.spec.name },
|
|
452
441
|
spec: t.spec,
|
|
453
442
|
specHash: specHash(t.spec),
|
|
454
443
|
defaultPolicy: t.spec.defaultPolicy ?? policyFromAnnotations(t.spec.annotations),
|
|
455
444
|
});
|
|
456
445
|
}
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
446
|
+
}
|
|
447
|
+
// connector tools: the org's live connectors
|
|
448
|
+
for (const app of await this.loadOrgConnectors(orgId, { includeDeleted: false })) {
|
|
449
|
+
if (disabled.some((r) => r.kind === "connector" && r.connectorId === app.id && r.tools === "all")) {
|
|
450
|
+
continue;
|
|
451
|
+
}
|
|
452
|
+
const all = connectorToolKey(app.slug, "*");
|
|
453
|
+
if (app.status !== "active") {
|
|
454
|
+
hidden.push({ ref: all, reason: `App ${app.slug} is disabled` });
|
|
455
|
+
continue;
|
|
456
|
+
}
|
|
457
|
+
if (!this.findConnector(app.connector)) {
|
|
458
|
+
hidden.push({
|
|
459
|
+
ref: all,
|
|
460
|
+
reason: `Connector ${app.connector} for app ${app.slug} is not installed`,
|
|
461
|
+
});
|
|
462
|
+
continue;
|
|
463
|
+
}
|
|
464
|
+
for (const t of app.tools) {
|
|
465
|
+
if (connectorToolDisabled(disabled, app.id, t.name))
|
|
461
466
|
continue;
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
if (
|
|
465
|
-
|
|
467
|
+
const key = connectorToolKey(app.slug, t.name);
|
|
468
|
+
// 远端已不再提供(漂移检测置停用并标记,见 drift.ts)
|
|
469
|
+
if (t.gone) {
|
|
470
|
+
hidden.push({ ref: key, reason: `Tool no longer exists in app ${app.slug}` });
|
|
466
471
|
continue;
|
|
467
472
|
}
|
|
468
|
-
if (
|
|
469
|
-
|
|
473
|
+
if (t.status === "disabled") {
|
|
474
|
+
hidden.push({ ref: key, reason: "Tool is disabled" });
|
|
470
475
|
continue;
|
|
471
476
|
}
|
|
472
|
-
if (
|
|
473
|
-
|
|
474
|
-
ref: all,
|
|
475
|
-
reason: `Connector ${app.connector} for app ${app.slug} is not installed`,
|
|
476
|
-
});
|
|
477
|
+
if (t.status === "pending_review") {
|
|
478
|
+
hidden.push({ ref: key, reason: "Tool is pending review" });
|
|
477
479
|
continue;
|
|
478
480
|
}
|
|
479
|
-
const
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
const notEnabled = ref.tools === "all" ? hidden : unavailable;
|
|
484
|
-
for (const t of wanted) {
|
|
485
|
-
const key = connectorToolKey(app.slug, t.name);
|
|
486
|
-
// 远端已不再提供(漂移检测置停用并标记,见 drift.ts):与「没有这一行」同一个事实
|
|
487
|
-
if ("missing" in t || t.gone) {
|
|
488
|
-
notEnabled.push({ ref: key, reason: `Tool no longer exists in app ${app.slug}` });
|
|
489
|
-
continue;
|
|
490
|
-
}
|
|
491
|
-
if (t.status === "disabled") {
|
|
492
|
-
notEnabled.push({ ref: key, reason: "Tool is disabled" });
|
|
493
|
-
continue;
|
|
494
|
-
}
|
|
495
|
-
if (t.status === "pending_review") {
|
|
496
|
-
notEnabled.push({ ref: key, reason: "Tool is pending review" });
|
|
497
|
-
continue;
|
|
498
|
-
}
|
|
499
|
-
const issue = toolKeyIssue(key);
|
|
500
|
-
if (issue) {
|
|
501
|
-
unavailable.push({ ref: key, reason: issue });
|
|
502
|
-
continue;
|
|
503
|
-
}
|
|
504
|
-
add({
|
|
505
|
-
key,
|
|
506
|
-
source: {
|
|
507
|
-
kind: "connector",
|
|
508
|
-
connectorId: app.id,
|
|
509
|
-
name: t.name,
|
|
510
|
-
...(t.source === "resources" && { resources: true }),
|
|
511
|
-
},
|
|
512
|
-
spec: t.spec,
|
|
513
|
-
specHash: t.specHash,
|
|
514
|
-
defaultPolicy: t.defaultPolicy,
|
|
515
|
-
});
|
|
481
|
+
const issue = toolKeyIssue(key);
|
|
482
|
+
if (issue) {
|
|
483
|
+
hidden.push({ ref: key, reason: issue });
|
|
484
|
+
continue;
|
|
516
485
|
}
|
|
486
|
+
add({
|
|
487
|
+
key,
|
|
488
|
+
source: {
|
|
489
|
+
kind: "connector",
|
|
490
|
+
connectorId: app.id,
|
|
491
|
+
name: t.name,
|
|
492
|
+
...(t.source === "resources" && { resources: true }),
|
|
493
|
+
},
|
|
494
|
+
spec: t.spec,
|
|
495
|
+
specHash: t.specHash,
|
|
496
|
+
defaultPolicy: t.defaultPolicy,
|
|
497
|
+
});
|
|
517
498
|
}
|
|
518
499
|
}
|
|
519
500
|
return { tools, unavailable, hidden };
|
|
@@ -537,56 +518,50 @@ let ToolRegistry = class ToolRegistry {
|
|
|
537
518
|
async enabledPlugins(orgId) {
|
|
538
519
|
return this.host.enabledPlugins(orgId);
|
|
539
520
|
}
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
if (ids.length === 0)
|
|
543
|
-
return out;
|
|
544
|
-
// 软删除的连接器也读出来,只为给出「已删除」这个更准确的原因(slug 可能已被新连接器复用,按 id 区分)
|
|
521
|
+
/** The org's connectors (live ones, sorted by slug) with their tool snapshots (by name). */
|
|
522
|
+
async loadOrgConnectors(orgId, _opts) {
|
|
545
523
|
const apps = await this.db
|
|
546
524
|
.selectFrom("connectors")
|
|
547
|
-
.select(["id", "slug", "connector", "status"
|
|
525
|
+
.select(["id", "slug", "connector", "status"])
|
|
548
526
|
.where("org_id", "=", orgId)
|
|
549
|
-
.where("
|
|
527
|
+
.where("deleted_at", "is", null)
|
|
528
|
+
.orderBy("slug")
|
|
529
|
+
.orderBy("id")
|
|
550
530
|
.execute();
|
|
551
|
-
|
|
552
|
-
|
|
553
|
-
|
|
554
|
-
|
|
555
|
-
|
|
556
|
-
|
|
557
|
-
|
|
558
|
-
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
|
|
562
|
-
|
|
563
|
-
|
|
564
|
-
|
|
565
|
-
|
|
566
|
-
|
|
567
|
-
|
|
568
|
-
|
|
569
|
-
|
|
570
|
-
|
|
571
|
-
|
|
572
|
-
|
|
573
|
-
|
|
574
|
-
|
|
575
|
-
|
|
576
|
-
|
|
577
|
-
|
|
578
|
-
|
|
579
|
-
|
|
580
|
-
|
|
581
|
-
|
|
582
|
-
|
|
583
|
-
|
|
584
|
-
|
|
585
|
-
gone: t.missing_since !== null,
|
|
586
|
-
})),
|
|
587
|
-
});
|
|
588
|
-
}
|
|
589
|
-
return out;
|
|
531
|
+
if (apps.length === 0)
|
|
532
|
+
return [];
|
|
533
|
+
const toolRows = await this.db
|
|
534
|
+
.selectFrom("connector_tools")
|
|
535
|
+
.select([
|
|
536
|
+
"connector_id",
|
|
537
|
+
"name",
|
|
538
|
+
"spec",
|
|
539
|
+
"spec_hash",
|
|
540
|
+
"status",
|
|
541
|
+
"default_policy",
|
|
542
|
+
"source",
|
|
543
|
+
"missing_since",
|
|
544
|
+
])
|
|
545
|
+
.where("connector_id", "in", apps.map((a) => a.id))
|
|
546
|
+
.orderBy("name")
|
|
547
|
+
.execute();
|
|
548
|
+
return apps.map((a) => ({
|
|
549
|
+
id: a.id,
|
|
550
|
+
slug: a.slug,
|
|
551
|
+
connector: a.connector,
|
|
552
|
+
status: a.status,
|
|
553
|
+
tools: toolRows
|
|
554
|
+
.filter((t) => t.connector_id === a.id)
|
|
555
|
+
.map((t) => ({
|
|
556
|
+
name: t.name,
|
|
557
|
+
spec: t.spec,
|
|
558
|
+
specHash: t.spec_hash,
|
|
559
|
+
status: t.status,
|
|
560
|
+
defaultPolicy: t.default_policy,
|
|
561
|
+
source: t.source,
|
|
562
|
+
gone: t.missing_since !== null,
|
|
563
|
+
})),
|
|
564
|
+
}));
|
|
590
565
|
}
|
|
591
566
|
};
|
|
592
567
|
ToolRegistry = __decorate([
|
|
@@ -600,3 +575,17 @@ ToolRegistry = __decorate([
|
|
|
600
575
|
__param(6, Inject(KernelConfigService))
|
|
601
576
|
], ToolRegistry);
|
|
602
577
|
export { ToolRegistry };
|
|
578
|
+
/**
|
|
579
|
+
* `tools` narrowed by a sub-agent's key filter (tools default-on spec §4): `deny` keys removed,
|
|
580
|
+
* and with `allow` only its keys kept. `TaskOutput` / `TaskStop` follow `Bash`, as they come with
|
|
581
|
+
* it. Without a filter the list is returned as it is.
|
|
582
|
+
*/
|
|
583
|
+
export function filterSubagentTools(tools, filter) {
|
|
584
|
+
if (filter === undefined)
|
|
585
|
+
return tools;
|
|
586
|
+
const companions = new Set(BASH_COMPANION_TOOLS);
|
|
587
|
+
const deny = new Set(filter.deny ?? []);
|
|
588
|
+
const allow = filter.allow === undefined ? null : new Set(filter.allow);
|
|
589
|
+
const keep = (key) => !deny.has(key) && (allow === null || allow.has(key));
|
|
590
|
+
return tools.filter((t) => (companions.has(t.key) ? keep(BUILTIN.Bash) : keep(t.key)));
|
|
591
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@capybara-hq/kernel",
|
|
3
|
-
"version": "0.1.0-rc.
|
|
3
|
+
"version": "0.1.0-rc.7",
|
|
4
4
|
"description": "Capybara kernel: config, database, plugin host and HTTP API of the Capybara agent platform",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"repository": {
|
|
@@ -64,14 +64,14 @@
|
|
|
64
64
|
"yaml": "^2.9.1",
|
|
65
65
|
"yauzl": "3.4.0",
|
|
66
66
|
"zod": "^4.6.7",
|
|
67
|
-
"@capybara-hq/plugin-sdk": "^0.1.0-rc.
|
|
67
|
+
"@capybara-hq/plugin-sdk": "^0.1.0-rc.5"
|
|
68
68
|
},
|
|
69
69
|
"devDependencies": {
|
|
70
70
|
"@langchain/langgraph-checkpoint-validation": "^1.2.0",
|
|
71
71
|
"@types/pg": "^8.23.1",
|
|
72
72
|
"@types/semver": "^7.8.0",
|
|
73
73
|
"@types/yauzl": "3.4.0",
|
|
74
|
-
"@capybara-hq/testing": "0.1.0-rc.
|
|
74
|
+
"@capybara-hq/testing": "0.1.0-rc.8"
|
|
75
75
|
},
|
|
76
76
|
"scripts": {
|
|
77
77
|
"build": "tsc -b"
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
-- Platform tool phase 2 (spec 2026-11-07-platform-tool-design.md §14.5 item 2): the super admin's
|
|
2
|
+
-- agent creates an account with a kernel-generated one-time password. Expand-only.
|
|
3
|
+
--
|
|
4
|
+
-- must_change_password: the account must set its own password before anything else (the auth
|
|
5
|
+
-- guard refuses every route but the password change, /me and logout until it does).
|
|
6
|
+
ALTER TABLE capybara.accounts ADD COLUMN IF NOT EXISTS must_change_password boolean NOT NULL DEFAULT false;
|
|
7
|
+
|
|
8
|
+
-- The generated password, sealed with the master keyring (AES-256-GCM, AAD = account id), waiting
|
|
9
|
+
-- for the person who approved the creation to read it once on the web. Keyed by the account; the
|
|
10
|
+
-- tool call it came from (conversation_id, run_id, call_id: a call id is unique only within its run)
|
|
11
|
+
-- and its recipient decide who may read it. Read once (deleted as it is read), dropped when the
|
|
12
|
+
-- account changes its password, and dropped after expires_at by the hourly cleanup job.
|
|
13
|
+
CREATE TABLE IF NOT EXISTS capybara.account_initial_passwords (
|
|
14
|
+
account_id text PRIMARY KEY REFERENCES capybara.accounts(id) ON DELETE CASCADE,
|
|
15
|
+
recipient_account_id text NOT NULL REFERENCES capybara.accounts(id) ON DELETE CASCADE,
|
|
16
|
+
conversation_id text NOT NULL REFERENCES capybara.conversations(id) ON DELETE CASCADE,
|
|
17
|
+
run_id text NOT NULL,
|
|
18
|
+
call_id text NOT NULL,
|
|
19
|
+
master_key_id text NOT NULL,
|
|
20
|
+
ciphertext bytea NOT NULL,
|
|
21
|
+
expires_at timestamptz NOT NULL,
|
|
22
|
+
created_at timestamptz NOT NULL DEFAULT now()
|
|
23
|
+
);
|
|
24
|
+
CREATE INDEX IF NOT EXISTS account_initial_passwords_call_idx
|
|
25
|
+
ON capybara.account_initial_passwords (conversation_id, run_id, call_id);
|
|
26
|
+
CREATE INDEX IF NOT EXISTS account_initial_passwords_expires_idx
|
|
27
|
+
ON capybara.account_initial_passwords (expires_at);
|