@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
|
@@ -8,9 +8,9 @@ import { connectorTemplateState } from "../catalog/component-state.js";
|
|
|
8
8
|
import { invocationOf, PINNED_SKILLS_LIMITS } from "../skills/catalog.js";
|
|
9
9
|
import { usableSkillVersions } from "../skills/usable.js";
|
|
10
10
|
import { CONTROL_OR_HIDDEN_RE } from "../text.js";
|
|
11
|
-
import { AGENT_TOOL, BASH_COMPANION_TOOLS, BUILTIN, BUILTIN_TOOL_NAMES,
|
|
11
|
+
import { AGENT_BUILTIN_NAMES, AGENT_TOOL, BASH_COMPANION_TOOLS, BUILTIN, BUILTIN_TOOL_NAMES, } from "../tools/builtin-names.js";
|
|
12
12
|
import { canonicalJson } from "../tools/canonical-json.js";
|
|
13
|
-
import { AgentDefinitionSchema, SUBAGENT_NAME_RE, SUBAGENT_ROSTER_MAX, } from "./definition.js";
|
|
13
|
+
import { AgentDefinitionSchema, builtinDisabled, canonicalDisabledTools, connectorToolDisabled, extensionToolDisabled, SUBAGENT_NAME_RE, SUBAGENT_ROSTER_MAX, } from "./definition.js";
|
|
14
14
|
import { INSTRUCTION_FILE_LIMITS, INSTRUCTION_FILE_NAME_RE, joinInstructionFiles, } from "./instruction-files.js";
|
|
15
15
|
import { sanitizeEndpoint } from "./org-templates.js";
|
|
16
16
|
import { PROFILE_LIMITS, ProfileInputSchema } from "./profile.js";
|
|
@@ -259,34 +259,38 @@ export async function planFromTemplate(db, orgId, row, opts) {
|
|
|
259
259
|
});
|
|
260
260
|
if (t.maxSteps !== undefined)
|
|
261
261
|
dropped.push("maxSteps");
|
|
262
|
-
// tools:
|
|
262
|
+
// tools (tools default-on spec §3): the new agent has every tool the org offers; the template
|
|
263
|
+
// turns off its `disallowedTools` and, with a `tools` allowlist, the builtins it does not list
|
|
264
|
+
// (extension and connector tools follow the org); its keys are listed for the preview (P4-5)
|
|
263
265
|
const disallowed = new Set(t.disallowedTools ?? []);
|
|
264
|
-
const
|
|
266
|
+
const disabled = [];
|
|
265
267
|
const builtinNames = new Set(BUILTIN_TOOL_NAMES);
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
item("tool", ref.name, "carried", "default");
|
|
271
|
-
}
|
|
268
|
+
const agentBuiltins = new Set(AGENT_BUILTIN_NAMES);
|
|
269
|
+
const offBuiltin = (name) => {
|
|
270
|
+
if (agentBuiltins.has(name) && !builtinDisabled(disabled, name)) {
|
|
271
|
+
disabled.push({ kind: "builtin", name });
|
|
272
272
|
}
|
|
273
|
-
}
|
|
274
|
-
|
|
273
|
+
};
|
|
274
|
+
const offExtensionTool = (plugin, name) => disabled.push({ kind: "plugin", plugin, tools: [name] });
|
|
275
|
+
// a template that describes sub-agents keeps `Agent` (ruling P4-T3-5) unless it disallows it
|
|
276
|
+
const sub0 = t.subagents;
|
|
277
|
+
const describesSubagents = sub0 !== undefined &&
|
|
278
|
+
((sub0.types ?? []).length > 0 || (sub0.inline ?? []).length > 0 || sub0.general === true);
|
|
279
|
+
if (t.tools !== undefined) {
|
|
280
|
+
const listed = new Set();
|
|
275
281
|
for (const key of t.tools) {
|
|
276
282
|
if (disallowed.has(key))
|
|
277
283
|
continue;
|
|
278
284
|
const parsed = parseToolKey(key);
|
|
279
285
|
if (parsed?.kind === "builtin" && builtinNames.has(parsed.name)) {
|
|
280
|
-
|
|
286
|
+
listed.add(parsed.name);
|
|
281
287
|
item("tool", key, "carried");
|
|
282
288
|
}
|
|
283
289
|
else if (parsed?.kind === "extension") {
|
|
284
290
|
const ok = opts.enabledPlugins.has(parsed.plugin) &&
|
|
285
291
|
opts.pluginTools.some((x) => x.plugin === parsed.plugin && x.name === parsed.tool);
|
|
286
|
-
if (ok)
|
|
287
|
-
tools.push({ kind: "plugin", plugin: parsed.plugin, name: parsed.tool });
|
|
292
|
+
if (ok)
|
|
288
293
|
item("tool", key, "carried");
|
|
289
|
-
}
|
|
290
294
|
else
|
|
291
295
|
item("tool", key, "unavailable", "plugin_unavailable");
|
|
292
296
|
}
|
|
@@ -296,6 +300,20 @@ export async function planFromTemplate(db, orgId, row, opts) {
|
|
|
296
300
|
else
|
|
297
301
|
item("tool", key, "unavailable", "unknown_tool");
|
|
298
302
|
}
|
|
303
|
+
if (describesSubagents)
|
|
304
|
+
listed.add(AGENT_TOOL);
|
|
305
|
+
// `TaskOutput` / `TaskStop` follow `Bash`
|
|
306
|
+
for (const name of AGENT_BUILTIN_NAMES)
|
|
307
|
+
if (!listed.has(name))
|
|
308
|
+
offBuiltin(name);
|
|
309
|
+
}
|
|
310
|
+
for (const key of disallowed) {
|
|
311
|
+
const parsed = parseToolKey(key);
|
|
312
|
+
if (parsed?.kind === "builtin")
|
|
313
|
+
offBuiltin(parsed.name);
|
|
314
|
+
else if (parsed?.kind === "extension")
|
|
315
|
+
offExtensionTool(parsed.plugin, parsed.tool);
|
|
316
|
+
// a connector key is matched against the bound connectors below
|
|
299
317
|
}
|
|
300
318
|
// skills: by name against the org's usable skills (P4-5); every name gets its item
|
|
301
319
|
const usable = await usableSkillVersions(db, orgId);
|
|
@@ -410,11 +428,14 @@ export async function planFromTemplate(db, orgId, row, opts) {
|
|
|
410
428
|
// `disallowedTools` naming its tools narrows it (P4-5)
|
|
411
429
|
const allowed = names.filter((n) => !disallowed.has(connectorToolKey(first.slug, n)));
|
|
412
430
|
if (allowed.length === 0) {
|
|
431
|
+
// the connector is the org's, so it is on by default: its disallowed tools are turned off
|
|
432
|
+
const off = first.tools.filter((n) => disallowed.has(connectorToolKey(first.slug, n)));
|
|
433
|
+
if (off.length > 0 && !slugs.has(first.id)) {
|
|
434
|
+
disabled.push({ kind: "connector", connectorId: first.id, tools: off });
|
|
435
|
+
}
|
|
413
436
|
item("connector", first.name, "unavailable", "disallowed");
|
|
414
437
|
continue;
|
|
415
438
|
}
|
|
416
|
-
const narrowed = allowed.length !== names.length;
|
|
417
|
-
const refTools = entry.tools === undefined && !narrowed ? "all" : allowed;
|
|
418
439
|
for (const [name, p] of Object.entries(entry.policies ?? {})) {
|
|
419
440
|
if (!allowed.includes(name)) {
|
|
420
441
|
dropped.push(`connectors.${key}.policies.${name}`);
|
|
@@ -425,14 +446,20 @@ export async function planFromTemplate(db, orgId, row, opts) {
|
|
|
425
446
|
if (prev === undefined || RANK[p] > RANK[prev])
|
|
426
447
|
connectorPolicies[k] = p;
|
|
427
448
|
}
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
449
|
+
// the bound connector's tools the entry leaves out (or the template disallows) are turned off;
|
|
450
|
+
// a second entry on the same connector turns on what it names (the union of the entries)
|
|
451
|
+
const prevOn = slugs.has(first.id)
|
|
452
|
+
? first.tools.filter((n) => !connectorToolDisabled(disabled, first.id, n))
|
|
453
|
+
: [];
|
|
454
|
+
const on = new Set([...prevOn, ...allowed]);
|
|
455
|
+
const off = first.tools.filter((n) => !on.has(n));
|
|
456
|
+
for (let i = disabled.length - 1; i >= 0; i--) {
|
|
457
|
+
const r = disabled[i];
|
|
458
|
+
if (r?.kind === "connector" && r.connectorId === first.id)
|
|
459
|
+
disabled.splice(i, 1);
|
|
435
460
|
}
|
|
461
|
+
if (off.length > 0)
|
|
462
|
+
disabled.push({ kind: "connector", connectorId: first.id, tools: off });
|
|
436
463
|
slugs.set(first.id, first);
|
|
437
464
|
item("connector", first.name, "carried", made.length > 1 ? "several" : undefined);
|
|
438
465
|
}
|
|
@@ -528,32 +555,36 @@ export async function planFromTemplate(db, orgId, row, opts) {
|
|
|
528
555
|
if (inline.length > 0)
|
|
529
556
|
out.inline = inline;
|
|
530
557
|
subagents = out;
|
|
531
|
-
// a roster needs the `Agent` tool
|
|
532
|
-
//
|
|
558
|
+
// a roster needs the `Agent` tool (ruling P4-T3-5): it is on unless the template disallows
|
|
559
|
+
// it; a template whose allowlist leaves it out still gets it (kept on above)
|
|
533
560
|
const describes = templateIds.length > 0 || inline.length > 0 || sub.general === true;
|
|
534
561
|
if (describes &&
|
|
535
|
-
|
|
536
|
-
!tools.
|
|
537
|
-
|
|
562
|
+
t.tools !== undefined &&
|
|
563
|
+
!t.tools.includes(AGENT_TOOL) &&
|
|
564
|
+
!builtinDisabled(disabled, AGENT_TOOL)) {
|
|
538
565
|
item("tool", AGENT_TOOL, "carried", "subagents");
|
|
539
566
|
}
|
|
540
567
|
}
|
|
541
|
-
// the tool keys the agent has, for policies and inline
|
|
568
|
+
// the tool keys the agent has (of those the template can name), for policies and inline
|
|
569
|
+
// allowlists: its builtins, the enabled extensions' tools and the bound connectors' tools, each
|
|
570
|
+
// unless turned off
|
|
542
571
|
const keys = new Set();
|
|
543
|
-
for (const
|
|
544
|
-
if (
|
|
545
|
-
|
|
546
|
-
|
|
547
|
-
|
|
548
|
-
|
|
572
|
+
for (const name of AGENT_BUILTIN_NAMES) {
|
|
573
|
+
if (builtinDisabled(disabled, name))
|
|
574
|
+
continue;
|
|
575
|
+
keys.add(name);
|
|
576
|
+
if (name === BUILTIN.Bash)
|
|
577
|
+
for (const c of BASH_COMPANION_TOOLS)
|
|
578
|
+
keys.add(c);
|
|
579
|
+
}
|
|
580
|
+
for (const x of opts.pluginTools) {
|
|
581
|
+
if (opts.enabledPlugins.has(x.plugin) && !extensionToolDisabled(disabled, x.plugin, x.name)) {
|
|
582
|
+
keys.add(extensionToolKey(x.plugin, x.name));
|
|
549
583
|
}
|
|
550
|
-
|
|
551
|
-
|
|
552
|
-
|
|
553
|
-
|
|
554
|
-
if (!c)
|
|
555
|
-
continue;
|
|
556
|
-
for (const n of r.tools === "all" ? c.tools : r.tools)
|
|
584
|
+
}
|
|
585
|
+
for (const c of slugs.values()) {
|
|
586
|
+
for (const n of c.tools) {
|
|
587
|
+
if (!connectorToolDisabled(disabled, c.id, n))
|
|
557
588
|
keys.add(connectorToolKey(c.slug, n));
|
|
558
589
|
}
|
|
559
590
|
}
|
|
@@ -584,7 +615,7 @@ export async function planFromTemplate(db, orgId, row, opts) {
|
|
|
584
615
|
...(instructions === undefined ? { instructionFiles: files } : { instructions }),
|
|
585
616
|
fallback: null,
|
|
586
617
|
fallbackParams: {},
|
|
587
|
-
|
|
618
|
+
disabledTools: canonicalDisabledTools(disabled),
|
|
588
619
|
toolPolicies,
|
|
589
620
|
...((orgSkills.length > 0 || pinned.length > 0) && {
|
|
590
621
|
skills: { orgSkills, ...(pinned.length > 0 && { pinned }) },
|
|
@@ -54,6 +54,18 @@ export declare class AgentsFromTemplate {
|
|
|
54
54
|
private template;
|
|
55
55
|
private plan;
|
|
56
56
|
preview(orgId: string, templateId: string): Promise<TemplatePreview>;
|
|
57
|
+
/**
|
|
58
|
+
* The template and the plan of a create, read only: 404 `component.not_found` for a template
|
|
59
|
+
* not usable here, 409 `agent.template_preview_stale` for a hash that no longer matches, and
|
|
60
|
+
* `agent.model_unavailable` when no model resolves.
|
|
61
|
+
*/
|
|
62
|
+
private checked;
|
|
63
|
+
/**
|
|
64
|
+
* The read-only checks of {@link create}, for the `Platform` tool's precheck (before the card):
|
|
65
|
+
* throws the `ApiError` the create would for an unknown template, a stale preview hash or no
|
|
66
|
+
* model.
|
|
67
|
+
*/
|
|
68
|
+
check(orgId: string, req: Pick<CreateFromTemplateRequest, "templateId" | "previewHash" | "model">): Promise<void>;
|
|
57
69
|
create(orgId: string, actorAccountId: string, req: CreateFromTemplateRequest, actorTokenId?: string, auditDetail?: Record<string, unknown>): Promise<{
|
|
58
70
|
agent: AgentView;
|
|
59
71
|
}>;
|
|
@@ -99,7 +99,12 @@ let AgentsFromTemplate = class AgentsFromTemplate {
|
|
|
99
99
|
previewHash: plan.hash,
|
|
100
100
|
};
|
|
101
101
|
}
|
|
102
|
-
|
|
102
|
+
/**
|
|
103
|
+
* The template and the plan of a create, read only: 404 `component.not_found` for a template
|
|
104
|
+
* not usable here, 409 `agent.template_preview_stale` for a hash that no longer matches, and
|
|
105
|
+
* `agent.model_unavailable` when no model resolves.
|
|
106
|
+
*/
|
|
107
|
+
async checked(orgId, req) {
|
|
103
108
|
const row = await this.template(orgId, req.templateId);
|
|
104
109
|
const plan = await this.plan(orgId, row, req.model);
|
|
105
110
|
// the base part always; the automatic model's part only when the person chose none, so a
|
|
@@ -111,12 +116,24 @@ let AgentsFromTemplate = class AgentsFromTemplate {
|
|
|
111
116
|
if (plan.model === null) {
|
|
112
117
|
throw new ApiError("agent.model_unavailable", "No model is available for the new agent");
|
|
113
118
|
}
|
|
119
|
+
return { row, plan, model: plan.model };
|
|
120
|
+
}
|
|
121
|
+
/**
|
|
122
|
+
* The read-only checks of {@link create}, for the `Platform` tool's precheck (before the card):
|
|
123
|
+
* throws the `ApiError` the create would for an unknown template, a stale preview hash or no
|
|
124
|
+
* model.
|
|
125
|
+
*/
|
|
126
|
+
async check(orgId, req) {
|
|
127
|
+
await this.checked(orgId, req);
|
|
128
|
+
}
|
|
129
|
+
async create(orgId, actorAccountId, req, actorTokenId, auditDetail) {
|
|
130
|
+
const { row, plan, model } = await this.checked(orgId, req);
|
|
114
131
|
const { agent, role } = await this.agents.createFromTemplate(orgId, actorAccountId, {
|
|
115
132
|
definition: {
|
|
116
133
|
...plan.definition,
|
|
117
134
|
name: req.name,
|
|
118
|
-
model:
|
|
119
|
-
modelParams:
|
|
135
|
+
model: model.ref,
|
|
136
|
+
modelParams: model.params,
|
|
120
137
|
},
|
|
121
138
|
visibility: req.visibility ?? "private",
|
|
122
139
|
...(req.members !== undefined && { memberIds: req.members }),
|
|
@@ -4,7 +4,7 @@ import { ExtensionDisplayNames } from "../extensions/display-name.js";
|
|
|
4
4
|
import { type Principal } from "../identity/principal.js";
|
|
5
5
|
import { type OrgContext } from "../orgs/org.guard.js";
|
|
6
6
|
import { type KernelModelInfo, ProviderRegistry, type ProviderStatus } from "../runtime/providers.js";
|
|
7
|
-
declare const ModelsQuery: z.ZodObject<{
|
|
7
|
+
export declare const ModelsQuery: z.ZodObject<{
|
|
8
8
|
kind: z.ZodOptional<z.ZodEnum<{
|
|
9
9
|
chat: "chat";
|
|
10
10
|
embedding: "embedding";
|
|
@@ -45,4 +45,3 @@ export declare class ModelsController {
|
|
|
45
45
|
})[];
|
|
46
46
|
}>;
|
|
47
47
|
}
|
|
48
|
-
export {};
|
|
@@ -15,7 +15,7 @@ import { createZodDto } from "../infra/validation/create-zod-dto.js";
|
|
|
15
15
|
import { ZQuery } from "../infra/validation/zod-params.js";
|
|
16
16
|
import { CurrentOrg, OrgAction } from "../orgs/org.guard.js";
|
|
17
17
|
import { ProviderRegistry, } from "../runtime/providers.js";
|
|
18
|
-
const ModelsQuery = z.object({
|
|
18
|
+
export const ModelsQuery = z.object({
|
|
19
19
|
kind: z
|
|
20
20
|
.enum([
|
|
21
21
|
"chat",
|
|
@@ -4,6 +4,7 @@ import type { KernelSchemaDb } from "../db/kernel-schema.js";
|
|
|
4
4
|
import { KernelDb } from "../infra/database/kernel-db.js";
|
|
5
5
|
import { TransactionHost } from "../infra/database/transaction-host.js";
|
|
6
6
|
import { OrgLock } from "../orgs/org-lock.js";
|
|
7
|
+
import { ToolRegistry } from "../tools/registry.js";
|
|
7
8
|
import { AgentLookup, type AgentView } from "./agent-lookup.js";
|
|
8
9
|
import { type AgentTemplateView } from "./templates.js";
|
|
9
10
|
/** A template with its definition, as `GET orgs/:orgId/agent-templates/:id` answers. */
|
|
@@ -96,7 +97,12 @@ export declare function canonicalEndpoints(template: AgentTemplate): AgentTempla
|
|
|
96
97
|
export declare function templateFromAgent(db: KernelSchemaDb, orgId: string, agent: AgentView, meta: {
|
|
97
98
|
name: string;
|
|
98
99
|
description: string;
|
|
99
|
-
}
|
|
100
|
+
},
|
|
101
|
+
/** The extension tools loaded on this replica (a wholly turned-off extension's tools). */
|
|
102
|
+
extensionTools?: readonly {
|
|
103
|
+
plugin: string;
|
|
104
|
+
name: string;
|
|
105
|
+
}[]): Promise<{
|
|
100
106
|
template: AgentTemplate;
|
|
101
107
|
omitted: SaveAsOmission[];
|
|
102
108
|
}>;
|
|
@@ -110,7 +116,11 @@ export declare class OrgAgentTemplates {
|
|
|
110
116
|
private readonly orgLock;
|
|
111
117
|
private readonly agents;
|
|
112
118
|
readonly txHost: TransactionHost;
|
|
113
|
-
|
|
119
|
+
/** The extension tools loaded here (a wholly turned-off extension saved as its tool keys). */
|
|
120
|
+
private readonly tools;
|
|
121
|
+
constructor(kdb: KernelDb, orgLock: Pick<OrgLock, "lockAndAuthorize">, agents: Pick<AgentLookup, "view">, txHost: TransactionHost,
|
|
122
|
+
/** The extension tools loaded here (a wholly turned-off extension saved as its tool keys). */
|
|
123
|
+
tools: Pick<ToolRegistry, "extensionToolSpecs">);
|
|
114
124
|
private get db();
|
|
115
125
|
/**
|
|
116
126
|
* 另存为模板 (ruling P4-9): the org's live agent `agentId` (any one: an org admin may edit every
|
|
@@ -154,7 +164,7 @@ export declare class OrgAgentTemplates {
|
|
|
154
164
|
update(orgId: string, actor: string, id: string, body: {
|
|
155
165
|
definition: Record<string, unknown>;
|
|
156
166
|
expectedVersion: number;
|
|
157
|
-
}, actorTokenId?: string): Promise<AgentTemplateDetail>;
|
|
167
|
+
}, actorTokenId?: string, auditDetail?: Record<string, unknown>): Promise<AgentTemplateDetail>;
|
|
158
168
|
/**
|
|
159
169
|
* The org's own template `id` ({@link readOwnTemplate}, the predicate `OwnedItems` shares), or
|
|
160
170
|
* undefined: another org's, a plugin's, or a copy of a platform template it does not own.
|
|
@@ -24,6 +24,7 @@ import { Transactional } from "../infra/database/transactional.decorator.js";
|
|
|
24
24
|
import { OrgLock } from "../orgs/org-lock.js";
|
|
25
25
|
import { skillVersionsById } from "../skills/usable.js";
|
|
26
26
|
import { canonicalJson } from "../tools/canonical-json.js";
|
|
27
|
+
import { ToolRegistry } from "../tools/registry.js";
|
|
27
28
|
import { AgentLookup } from "./agent-lookup.js";
|
|
28
29
|
import { loadTemplates, putTemplateVersionIn, readOwnTemplate, templateTypeOf, templateViewOf, usableTemplates, } from "./templates.js";
|
|
29
30
|
/**
|
|
@@ -129,7 +130,9 @@ export function canonicalEndpoints(template) {
|
|
|
129
130
|
* The template an agent is saved as (rulings P4-10, P4-11), with what was left out. Pure reads of
|
|
130
131
|
* the org's state through `db`.
|
|
131
132
|
*/
|
|
132
|
-
export async function templateFromAgent(db, orgId, agent, meta
|
|
133
|
+
export async function templateFromAgent(db, orgId, agent, meta,
|
|
134
|
+
/** The extension tools loaded on this replica (a wholly turned-off extension's tools). */
|
|
135
|
+
extensionTools = []) {
|
|
133
136
|
const def = agent.definition;
|
|
134
137
|
const omitted = [];
|
|
135
138
|
const L = AGENT_TEMPLATE_LIMITS;
|
|
@@ -151,34 +154,57 @@ export async function templateFromAgent(db, orgId, agent, meta) {
|
|
|
151
154
|
reason: "fallback",
|
|
152
155
|
});
|
|
153
156
|
}
|
|
154
|
-
// Tools:
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
const key = r.kind === "builtin" ? r.name : extensionToolKey(r.plugin, r.name);
|
|
164
|
-
if (!TOOL_KEY_RE.test(key) || tools.includes(key))
|
|
165
|
-
continue;
|
|
166
|
-
if (tools.length >= L.tools) {
|
|
157
|
+
// Tools (tools default-on spec §3): the template turns off what the agent turns off
|
|
158
|
+
// (`disallowedTools`, builtin and extension tool keys; a wholly turned-off extension as all its
|
|
159
|
+
// loaded tools); every connector on for the agent becomes a `connectors` entry
|
|
160
|
+
const disabled = def.disabledTools ?? [];
|
|
161
|
+
const disallowedTools = [];
|
|
162
|
+
const disallow = (key) => {
|
|
163
|
+
if (!TOOL_KEY_RE.test(key) || disallowedTools.includes(key))
|
|
164
|
+
return;
|
|
165
|
+
if (disallowedTools.length >= L.tools) {
|
|
167
166
|
omitted.push({ kind: "tool", name: key, reason: "limit" });
|
|
168
|
-
|
|
167
|
+
return;
|
|
168
|
+
}
|
|
169
|
+
disallowedTools.push(key);
|
|
170
|
+
};
|
|
171
|
+
for (const r of disabled) {
|
|
172
|
+
if (r.kind === "builtin")
|
|
173
|
+
disallow(r.name);
|
|
174
|
+
else if (r.kind === "plugin") {
|
|
175
|
+
const names = r.tools === "all"
|
|
176
|
+
? extensionTools.filter((x) => x.plugin === r.plugin).map((x) => x.name)
|
|
177
|
+
: r.tools;
|
|
178
|
+
for (const n of names)
|
|
179
|
+
disallow(extensionToolKey(r.plugin, n));
|
|
169
180
|
}
|
|
170
|
-
|
|
181
|
+
}
|
|
182
|
+
const liveConnectors = await db
|
|
183
|
+
.selectFrom("connectors")
|
|
184
|
+
.select(["id"])
|
|
185
|
+
.where("org_id", "=", orgId)
|
|
186
|
+
.where("status", "=", "active")
|
|
187
|
+
.where("deleted_at", "is", null)
|
|
188
|
+
.orderBy("created_at")
|
|
189
|
+
.orderBy("id")
|
|
190
|
+
.execute();
|
|
191
|
+
const connectorRefs = [];
|
|
192
|
+
for (const c of liveConnectors) {
|
|
193
|
+
const entry = disabled.find((r) => r.kind === "connector" && r.connectorId === c.id);
|
|
194
|
+
if (entry?.tools === "all")
|
|
195
|
+
continue;
|
|
196
|
+
connectorRefs.push({ connectorId: c.id, off: entry === undefined ? [] : entry.tools });
|
|
171
197
|
}
|
|
172
198
|
// builtin / plugin keys stay keys; a connector tool's policy goes to its connector entry by
|
|
173
199
|
// tool name (`policies`), since the key embeds this org's connector slug
|
|
174
200
|
const toolPolicies = {};
|
|
175
201
|
const connectorPolicies = new Map();
|
|
176
202
|
for (const [k, v] of Object.entries(def.toolPolicies ?? {})) {
|
|
177
|
-
|
|
203
|
+
const parsed = parseToolKey(k);
|
|
204
|
+
if (parsed !== null && parsed.kind !== "connector" && TOOL_KEY_RE.test(k)) {
|
|
178
205
|
toolPolicies[k] = v;
|
|
179
206
|
continue;
|
|
180
207
|
}
|
|
181
|
-
const parsed = parseToolKey(k);
|
|
182
208
|
if (parsed?.kind === "connector") {
|
|
183
209
|
const list = connectorPolicies.get(parsed.slug) ?? [];
|
|
184
210
|
list.push({ key: k, tool: parsed.tool, policy: v });
|
|
@@ -286,10 +312,20 @@ export async function templateFromAgent(db, orgId, agent, meta) {
|
|
|
286
312
|
omitted.push({ kind: "connector", name: id, id, reason: "unavailable" });
|
|
287
313
|
continue;
|
|
288
314
|
}
|
|
289
|
-
const
|
|
290
|
-
|
|
315
|
+
const off = connectorRefs.find((r) => r.connectorId === id)?.off ?? [];
|
|
316
|
+
// some tools off: the entry names the connector's enabled tools that stay on
|
|
317
|
+
const named = off.length === 0
|
|
291
318
|
? null
|
|
292
|
-
:
|
|
319
|
+
: (await db
|
|
320
|
+
.selectFrom("connector_tools")
|
|
321
|
+
.select("name")
|
|
322
|
+
.where("connector_id", "=", id)
|
|
323
|
+
.where("status", "=", "enabled")
|
|
324
|
+
.orderBy("name")
|
|
325
|
+
.execute())
|
|
326
|
+
.map((x) => x.name)
|
|
327
|
+
.filter((n) => !off.includes(n))
|
|
328
|
+
.slice(0, L.connectorTools);
|
|
293
329
|
if (c.template_id !== null) {
|
|
294
330
|
// only the platform connector template is recorded, not this connector: creating an agent
|
|
295
331
|
// from the template rebinds the entry to the org's oldest connector made from that
|
|
@@ -463,7 +499,7 @@ export async function templateFromAgent(db, orgId, agent, meta) {
|
|
|
463
499
|
name: meta.name,
|
|
464
500
|
description: meta.description,
|
|
465
501
|
instructions: def.instructions ?? "",
|
|
466
|
-
|
|
502
|
+
...(disallowedTools.length > 0 && { disallowedTools }),
|
|
467
503
|
...(Object.keys(toolPolicies).length > 0 && { toolPolicies }),
|
|
468
504
|
model: "standard",
|
|
469
505
|
modelRef: `${def.model.provider}/${def.model.model}`,
|
|
@@ -493,11 +529,15 @@ let OrgAgentTemplates = class OrgAgentTemplates {
|
|
|
493
529
|
orgLock;
|
|
494
530
|
agents;
|
|
495
531
|
txHost;
|
|
496
|
-
|
|
532
|
+
tools;
|
|
533
|
+
constructor(kdb, orgLock, agents, txHost,
|
|
534
|
+
/** The extension tools loaded here (a wholly turned-off extension saved as its tool keys). */
|
|
535
|
+
tools) {
|
|
497
536
|
this.kdb = kdb;
|
|
498
537
|
this.orgLock = orgLock;
|
|
499
538
|
this.agents = agents;
|
|
500
539
|
this.txHost = txHost;
|
|
540
|
+
this.tools = tools;
|
|
501
541
|
}
|
|
502
542
|
get db() {
|
|
503
543
|
return this.kdb.db;
|
|
@@ -524,7 +564,7 @@ let OrgAgentTemplates = class OrgAgentTemplates {
|
|
|
524
564
|
throw agentNotFound();
|
|
525
565
|
const agent = await this.agents.view(agentId);
|
|
526
566
|
await this.assertNameFree(orgId, meta.name);
|
|
527
|
-
const { template, omitted } = await templateFromAgent(t, orgId, agent, meta);
|
|
567
|
+
const { template, omitted } = await templateFromAgent(t, orgId, agent, meta, this.tools.extensionToolSpecs().map((x) => ({ plugin: x.plugin, name: x.spec.name })));
|
|
528
568
|
const put = await putTemplateVersionIn(t, { orgId, plugin: null, catalogItemId: null, catalogVersion: null, sourceFormat: "capybara" }, template);
|
|
529
569
|
await audit(t, {
|
|
530
570
|
actorAccountId: actor,
|
|
@@ -641,7 +681,7 @@ let OrgAgentTemplates = class OrgAgentTemplates {
|
|
|
641
681
|
* definition writes nothing. Not the org's own -> 409 `catalog.not_owned`; missing -> 404.
|
|
642
682
|
* Agents created earlier are never touched. Audits `agent_template.updated`.
|
|
643
683
|
*/
|
|
644
|
-
async update(orgId, actor, id, body, actorTokenId) {
|
|
684
|
+
async update(orgId, actor, id, body, actorTokenId, auditDetail) {
|
|
645
685
|
const t = this.db;
|
|
646
686
|
await this.orgLock.lockAndAuthorize(orgId, actor, "agents.manage");
|
|
647
687
|
const row = await this.ownRow(orgId, id, true);
|
|
@@ -671,7 +711,7 @@ let OrgAgentTemplates = class OrgAgentTemplates {
|
|
|
671
711
|
orgId,
|
|
672
712
|
action: "agent_template.updated",
|
|
673
713
|
target: id,
|
|
674
|
-
detail: { name: row.name, from: row.current_version, to: put.version },
|
|
714
|
+
detail: { name: row.name, from: row.current_version, to: put.version, ...auditDetail },
|
|
675
715
|
});
|
|
676
716
|
}
|
|
677
717
|
return this.detail(orgId, id);
|
|
@@ -716,7 +756,7 @@ let OrgAgentTemplates = class OrgAgentTemplates {
|
|
|
716
756
|
orgId,
|
|
717
757
|
action: "agent_template.updated",
|
|
718
758
|
target: id,
|
|
719
|
-
detail: { name: row.name, platformId: row.link, from: p.current_version, to },
|
|
759
|
+
detail: { name: row.name, platformId: row.link, from: p.current_version, to, ...auditDetail },
|
|
720
760
|
});
|
|
721
761
|
return this.detail(orgId, id);
|
|
722
762
|
}
|
|
@@ -822,6 +862,7 @@ OrgAgentTemplates = __decorate([
|
|
|
822
862
|
__param(0, Inject(KernelDb)),
|
|
823
863
|
__param(1, Inject(OrgLock)),
|
|
824
864
|
__param(2, Inject(AgentLookup)),
|
|
825
|
-
__param(3, Inject(TransactionHost))
|
|
865
|
+
__param(3, Inject(TransactionHost)),
|
|
866
|
+
__param(4, Inject(ToolRegistry))
|
|
826
867
|
], OrgAgentTemplates);
|
|
827
868
|
export { OrgAgentTemplates };
|
|
@@ -50,6 +50,8 @@ export declare class PendingConnectorRequests {
|
|
|
50
50
|
requestedBy: string;
|
|
51
51
|
actor: string;
|
|
52
52
|
actorTokenId?: string | undefined;
|
|
53
|
+
/** Merged into the audit detail (a write made through the Platform tool). */
|
|
54
|
+
auditDetail?: Record<string, unknown>;
|
|
53
55
|
}): Promise<{
|
|
54
56
|
id: string;
|
|
55
57
|
created: boolean;
|
|
@@ -122,7 +122,7 @@ let PendingConnectorRequests = class PendingConnectorRequests {
|
|
|
122
122
|
orgId: a.orgId,
|
|
123
123
|
action: "catalog.requested",
|
|
124
124
|
target: id,
|
|
125
|
-
detail: { kind: "connector_setup", agentId: a.agentId, keys },
|
|
125
|
+
detail: { kind: "connector_setup", agentId: a.agentId, keys, ...a.auditDetail },
|
|
126
126
|
});
|
|
127
127
|
return { id, created: true };
|
|
128
128
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { FastifyReply } from "fastify";
|
|
2
|
-
import { z } from "zod";
|
|
2
|
+
import type { z } from "zod";
|
|
3
3
|
import { CatalogRequestsService, type CatalogRequestView } from "../catalog/requests.service.js";
|
|
4
4
|
import { type Principal } from "../identity/principal.js";
|
|
5
5
|
import { type OrgContext } from "../orgs/org.guard.js";
|
|
@@ -8,15 +8,15 @@ var __param = (this && this.__param) || function (paramIndex, decorator) {
|
|
|
8
8
|
return function (target, key) { decorator(target, key, paramIndex); }
|
|
9
9
|
};
|
|
10
10
|
import { Controller, Get, HttpCode, Inject, Param, Post, Res } from "@nestjs/common";
|
|
11
|
-
import { z } from "zod";
|
|
12
11
|
import { CatalogRequestsService } from "../catalog/requests.service.js";
|
|
13
12
|
import { CurrentPrincipal, patTokenId, requireUser, } from "../identity/principal.js";
|
|
14
13
|
import { createZodDto } from "../infra/validation/create-zod-dto.js";
|
|
15
14
|
import { ZBody } from "../infra/validation/zod-params.js";
|
|
16
15
|
import { CurrentOrg, OrgAction } from "../orgs/org.guard.js";
|
|
16
|
+
import { PendingConnectorBindBody as BindBodySchema } from "./agents.schemas.js";
|
|
17
17
|
import { AgentsService } from "./agents.service.js";
|
|
18
18
|
import { PendingConnectorsService } from "./pending-connectors.service.js";
|
|
19
|
-
const BindBody =
|
|
19
|
+
const BindBody = BindBodySchema;
|
|
20
20
|
class PendingConnectorBindBody extends createZodDto(BindBody, "PendingConnectorBindBody") {
|
|
21
21
|
}
|
|
22
22
|
/**
|
|
@@ -41,14 +41,14 @@ export declare class PendingConnectorsService {
|
|
|
41
41
|
* authorized) or none of the entry's tools -> 400 `agent.pending_connector_mismatch`.
|
|
42
42
|
* Audits `agent.pending_connector_bound`.
|
|
43
43
|
*/
|
|
44
|
-
bind(orgId: string, agentId: string, key: string, connectorId: string, actor: string, actorTokenId?: string): Promise<BindResult>;
|
|
44
|
+
bind(orgId: string, agentId: string, key: string, connectorId: string, actor: string, actorTokenId?: string, auditDetail?: Record<string, unknown>): Promise<BindResult>;
|
|
45
45
|
/**
|
|
46
46
|
* (Re-)opens the agent's connector setup request (ruling P4-T6-7; the owner or an org admin+):
|
|
47
47
|
* the pending one when it has one (`created` false), else a new one for the current pending
|
|
48
48
|
* keys, requested by the agent's owner (P4-T6-4). No pending connectors -> 409
|
|
49
49
|
* `agent.no_pending_connectors`.
|
|
50
50
|
*/
|
|
51
|
-
reopen(orgId: string, agentId: string, actor: string, actorTokenId?: string): Promise<{
|
|
51
|
+
reopen(orgId: string, agentId: string, actor: string, actorTokenId?: string, auditDetail?: Record<string, unknown>): Promise<{
|
|
52
52
|
id: string;
|
|
53
53
|
created: boolean;
|
|
54
54
|
}>;
|