@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
|
@@ -32,6 +32,7 @@ import { ConversationLock } from "./conversation-lock.js";
|
|
|
32
32
|
import { RunError } from "./model-call.js";
|
|
33
33
|
import { ProviderListError, ProviderRegistry } from "./providers.js";
|
|
34
34
|
import { ORG_QUOTA_LEASE_MS, orgRunLimit, RUN_QUOTA } from "./quota.js";
|
|
35
|
+
import { RunContextService } from "./run-context.service.js";
|
|
35
36
|
import { RunDrafts, streamSink } from "./run-drafts.js";
|
|
36
37
|
import { RunFinish, TERMINAL_STATUSES } from "./run-finish.js";
|
|
37
38
|
import { RunQueue } from "./run-queue.js";
|
|
@@ -84,6 +85,7 @@ let RunWorker = class RunWorker {
|
|
|
84
85
|
titles;
|
|
85
86
|
models;
|
|
86
87
|
skillsCatalog;
|
|
88
|
+
runContext;
|
|
87
89
|
pipeline;
|
|
88
90
|
finisher;
|
|
89
91
|
txHost;
|
|
@@ -111,6 +113,8 @@ let RunWorker = class RunWorker {
|
|
|
111
113
|
models,
|
|
112
114
|
/** Run start's skills catalog snapshot (reads the pinned skills' bodies, phase B). */
|
|
113
115
|
skillsCatalog,
|
|
116
|
+
/** Run start's run context (run context spec §5): who the agent is, the day, the person. */
|
|
117
|
+
runContext,
|
|
114
118
|
/**
|
|
115
119
|
* In the terminal transaction of every run: writes its open `Agent` call results
|
|
116
120
|
* (`stopOpenAgentCalls`; a no-op without dispatches); `fire` runs their observe hooks after the
|
|
@@ -135,6 +139,7 @@ let RunWorker = class RunWorker {
|
|
|
135
139
|
this.titles = titles;
|
|
136
140
|
this.models = models;
|
|
137
141
|
this.skillsCatalog = skillsCatalog;
|
|
142
|
+
this.runContext = runContext;
|
|
138
143
|
this.pipeline = pipeline;
|
|
139
144
|
this.finisher = finisher;
|
|
140
145
|
this.txHost = txHost;
|
|
@@ -511,6 +516,8 @@ let RunWorker = class RunWorker {
|
|
|
511
516
|
let saved;
|
|
512
517
|
let maxSteps = runtime.maxSteps;
|
|
513
518
|
let parent;
|
|
519
|
+
/** A sub-agent's name in its run context: the roster name, or the forked skill's. */
|
|
520
|
+
let childName;
|
|
514
521
|
if (conv.kind === "subagent") {
|
|
515
522
|
// a sub-agent runs its effective definition frozen at dispatch, never agent_versions
|
|
516
523
|
// (spec §6.3), and works for the parent call that dispatched this run
|
|
@@ -525,6 +532,7 @@ let RunWorker = class RunWorker {
|
|
|
525
532
|
? trigger.payload.dispatch?.narrowed
|
|
526
533
|
: undefined);
|
|
527
534
|
maxSteps = Math.min(started.payload.maxSteps, runtime.maxSteps);
|
|
535
|
+
childName = started.payload.template.invokedSkill?.name ?? started.payload.agentType;
|
|
528
536
|
const row = await dispatchOfChildRun(this.db, runId);
|
|
529
537
|
const otherAgent = started.payload.template.source === "agent";
|
|
530
538
|
const parentConversationId = row?.parentConversationId ?? started.payload.parent.conversationId;
|
|
@@ -620,6 +628,22 @@ let RunWorker = class RunWorker {
|
|
|
620
628
|
});
|
|
621
629
|
return "finished";
|
|
622
630
|
}
|
|
631
|
+
// run context (spec §5): after the catalog, before the run is running, so before any
|
|
632
|
+
// compaction and model call; a retried run start finds its event or no change
|
|
633
|
+
await this.runContext.record({
|
|
634
|
+
orgId: conv.org_id,
|
|
635
|
+
conversationId,
|
|
636
|
+
runId,
|
|
637
|
+
triggerSeq: Number(run.trigger_seq),
|
|
638
|
+
agent,
|
|
639
|
+
...(parent !== undefined && {
|
|
640
|
+
subagent: {
|
|
641
|
+
parentConversationId: parent.conversationId,
|
|
642
|
+
parentRunId: parent.runId,
|
|
643
|
+
name: childName ?? agent.name,
|
|
644
|
+
},
|
|
645
|
+
}),
|
|
646
|
+
});
|
|
623
647
|
const updated = await this.db
|
|
624
648
|
.updateTable("runs")
|
|
625
649
|
.set({ status: "running", started_at: sql `COALESCE(started_at, now())` })
|
|
@@ -946,11 +970,12 @@ RunWorker = __decorate([
|
|
|
946
970
|
__param(15, Inject(TitleQueue)),
|
|
947
971
|
__param(16, Inject(ProviderRegistry)),
|
|
948
972
|
__param(17, Inject(SkillsCatalogService)),
|
|
949
|
-
__param(18, Inject(
|
|
950
|
-
__param(19, Inject(
|
|
951
|
-
__param(20, Inject(
|
|
952
|
-
__param(21, Inject(
|
|
953
|
-
__param(22,
|
|
954
|
-
__param(
|
|
973
|
+
__param(18, Inject(RunContextService)),
|
|
974
|
+
__param(19, Inject(ToolPipeline)),
|
|
975
|
+
__param(20, Inject(RunFinish)),
|
|
976
|
+
__param(21, Inject(TransactionHost)),
|
|
977
|
+
__param(22, Inject(RunDrafts)),
|
|
978
|
+
__param(23, Optional()),
|
|
979
|
+
__param(23, Inject(RUN_HOOKS))
|
|
955
980
|
], RunWorker);
|
|
956
981
|
export { RunWorker };
|
|
@@ -24,6 +24,7 @@ import { ConversationLock } from "./conversation-lock.js";
|
|
|
24
24
|
import { MAINTENANCE_QUEUE_NAME } from "./maintenance-queue.js";
|
|
25
25
|
import { ProvidersModule } from "./providers.js";
|
|
26
26
|
import { EVAL_QUOTA, EVAL_QUOTA_PREFIX, OrgQuota, RUN_QUOTA, RUN_QUOTA_PREFIX } from "./quota.js";
|
|
27
|
+
import { RunContextService } from "./run-context.service.js";
|
|
27
28
|
import { RunControl } from "./run-control.js";
|
|
28
29
|
import { RunDrafts } from "./run-drafts.js";
|
|
29
30
|
import { RunFinish } from "./run-finish.js";
|
|
@@ -79,6 +80,7 @@ RuntimeModule = __decorate([
|
|
|
79
80
|
RunDrafts,
|
|
80
81
|
AgentLoops,
|
|
81
82
|
RunSteps,
|
|
83
|
+
RunContextService,
|
|
82
84
|
RunWorker,
|
|
83
85
|
// a finished background task wakes an idle conversation (background Bash spec §3)
|
|
84
86
|
BackgroundWake,
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { type AgentTemplateTier } from "@capybara-hq/plugin-sdk";
|
|
2
|
-
import type
|
|
2
|
+
import { type AgentDefinition, type DisabledToolRef, type ModelRef } from "../../agents/definition.js";
|
|
3
3
|
import type { EventPayload } from "../../conversations/events.js";
|
|
4
4
|
import type { KernelSchemaDb } from "../../db/kernel-schema.js";
|
|
5
5
|
import type { KernelConfigService } from "../../infra/config/kernel-config.service.js";
|
|
@@ -77,31 +77,31 @@ export declare function effectiveDefinition(d: EffectiveDefinitionDeps, a: Child
|
|
|
77
77
|
tierFallback: boolean;
|
|
78
78
|
}>;
|
|
79
79
|
/**
|
|
80
|
-
* What a follow-up (`resume`) may still use (final review I1, spec §5.3): the frozen
|
|
81
|
-
*
|
|
82
|
-
*
|
|
80
|
+
* What a follow-up (`resume`) may still use (final review I1, spec §5.3): the frozen definition's
|
|
81
|
+
* turned-off tools together with the current version's (it can lose tools, never gain them), and
|
|
82
|
+
* the frozen org skills intersected with the current ones. Recorded on the follow-up's task message
|
|
83
|
+
* (`user_message.dispatch.narrowed`), so the run and its replay read it from the log.
|
|
83
84
|
*/
|
|
84
85
|
export interface FollowUpNarrowing {
|
|
85
|
-
tools
|
|
86
|
+
/** Absent in logs from before tools were on by default (no tool narrowing then). */
|
|
87
|
+
disabledTools?: DisabledToolRef[] | undefined;
|
|
86
88
|
skills?: {
|
|
87
89
|
orgSkills: string[];
|
|
88
90
|
pinned?: string[] | undefined;
|
|
89
91
|
} | undefined;
|
|
90
92
|
}
|
|
91
|
-
/**
|
|
92
|
-
* The refs of `frozen` that `current` still has: a builtin or plugin tool by name, a connector by
|
|
93
|
-
* id; a connector's `all` meets the other side's names (`all` on both stays `all`), and a
|
|
94
|
-
* connector left with no names is dropped. Pure: a connector `current` lists is not looked up.
|
|
95
|
-
*/
|
|
96
|
-
export declare function intersectTools(frozen: readonly AgentToolRef[], current: readonly AgentToolRef[]): AgentToolRef[];
|
|
97
93
|
/**
|
|
98
94
|
* The narrowing of a follow-up (final review I1): `frozen` (the child's `subagent_started`
|
|
99
95
|
* definition) against `current`, the definition a fresh dispatch would read now: the dispatching
|
|
100
96
|
* parent run's version for `general` / inline / plugin children, the dispatched org agent's
|
|
101
97
|
* current version for an org agent child (whose tools are its own at dispatch too, §5.5). Its
|
|
102
|
-
* `orgSkills` keep only those `current` still
|
|
103
|
-
* skills goes with it (the agent's own skills
|
|
98
|
+
* `disabledTools` are both lists together; its `orgSkills` keep only those `current` still
|
|
99
|
+
* selects; a pinned id that was one of the frozen org skills goes with it (the agent's own skills
|
|
100
|
+
* stay).
|
|
101
|
+
*/
|
|
102
|
+
export declare function narrowFollowUp(frozen: Pick<AgentDefinition, "disabledTools" | "skills">, current: Pick<AgentDefinition, "disabledTools" | "skills">): FollowUpNarrowing;
|
|
103
|
+
/**
|
|
104
|
+
* The definition a child run uses: the frozen one with its trigger's follow-up narrowing. A
|
|
105
|
+
* narrowing logged before tools were on by default (no `disabledTools`) narrows only skills.
|
|
104
106
|
*/
|
|
105
|
-
export declare function narrowFollowUp(frozen: Pick<AgentDefinition, "tools" | "skills">, current: Pick<AgentDefinition, "tools" | "skills">): FollowUpNarrowing;
|
|
106
|
-
/** The definition a child run uses: the frozen one with its trigger's follow-up narrowing. */
|
|
107
107
|
export declare function childRunDefinition(frozen: AgentDefinition, narrowed: FollowUpNarrowing | undefined): AgentDefinition;
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { SKILL_ENTRY_FILE, sanitizeParams, } from "@capybara-hq/plugin-sdk";
|
|
2
|
+
import { canonicalDisabledTools, } from "../../agents/definition.js";
|
|
2
3
|
import { loadTemplates } from "../../agents/templates.js";
|
|
3
4
|
import { ApiError } from "../../errors.js";
|
|
4
5
|
import { PINNED_SKILLS_LIMITS } from "../../skills/catalog.js";
|
|
@@ -38,78 +39,28 @@ export function stricterPolicies(base, over) {
|
|
|
38
39
|
}
|
|
39
40
|
return out;
|
|
40
41
|
}
|
|
41
|
-
async function loadConnectors(db, orgId, refs) {
|
|
42
|
-
const ids = [...new Set(refs.flatMap((r) => (r.kind === "connector" ? [r.connectorId] : [])))];
|
|
43
|
-
const out = new Map();
|
|
44
|
-
if (ids.length === 0)
|
|
45
|
-
return out;
|
|
46
|
-
const rows = await db
|
|
47
|
-
.selectFrom("connectors")
|
|
48
|
-
.select(["id", "slug"])
|
|
49
|
-
.where("org_id", "=", orgId)
|
|
50
|
-
.where("deleted_at", "is", null)
|
|
51
|
-
.where("id", "in", ids)
|
|
52
|
-
.execute();
|
|
53
|
-
const tools = rows.length === 0
|
|
54
|
-
? []
|
|
55
|
-
: await db
|
|
56
|
-
.selectFrom("connector_tools")
|
|
57
|
-
.select(["connector_id", "name"])
|
|
58
|
-
.where("connector_id", "in", rows.map((r) => r.id))
|
|
59
|
-
.orderBy("name")
|
|
60
|
-
.execute();
|
|
61
|
-
for (const r of rows) {
|
|
62
|
-
out.set(r.id, {
|
|
63
|
-
slug: r.slug,
|
|
64
|
-
tools: tools.filter((t) => t.connector_id === r.id).map((t) => t.name),
|
|
65
|
-
});
|
|
66
|
-
}
|
|
67
|
-
return out;
|
|
68
|
-
}
|
|
69
42
|
/**
|
|
70
|
-
*
|
|
71
|
-
*
|
|
72
|
-
*
|
|
73
|
-
*
|
|
74
|
-
* is dropped. A connector that no longer exists keeps its ref only without an allowlist.
|
|
43
|
+
* A child's key filter (tools default-on spec §4): `deny` = the parent's own filter's (a nested
|
|
44
|
+
* child), {@link CHILD_REMOVED_TOOLS}, `Agent` when the child is at the depth limit, and the
|
|
45
|
+
* template's `disallowedTools`; `allow` = the template's `tools` allowlist met with the parent's
|
|
46
|
+
* (absent on both = everything the parent has). Keys are deduplicated in first-seen order.
|
|
75
47
|
*/
|
|
76
|
-
function
|
|
77
|
-
const
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
const c = connectors.get(ref.connectorId);
|
|
93
|
-
if (!c) {
|
|
94
|
-
if (allow === null)
|
|
95
|
-
out.push(ref);
|
|
96
|
-
continue;
|
|
97
|
-
}
|
|
98
|
-
const ownsKey = (k) => {
|
|
99
|
-
const parsed = parseToolKey(k);
|
|
100
|
-
return parsed?.kind === "connector" && parsed.slug === c.slug;
|
|
101
|
-
};
|
|
102
|
-
if (ref.tools === "all" && allow === null && ![...deny].some(ownsKey)) {
|
|
103
|
-
out.push(ref);
|
|
104
|
-
continue;
|
|
105
|
-
}
|
|
106
|
-
const names = ref.tools === "all" ? c.tools : ref.tools;
|
|
107
|
-
const kept = names.filter((name) => keep(connectorToolKey(c.slug, name)));
|
|
108
|
-
if (kept.length > 0)
|
|
109
|
-
out.push({ ...ref, tools: kept });
|
|
110
|
-
}
|
|
111
|
-
}
|
|
112
|
-
return out;
|
|
48
|
+
function childFilter(removeAgent, template, parent) {
|
|
49
|
+
const deny = [
|
|
50
|
+
...new Set([
|
|
51
|
+
...(parent?.deny ?? []),
|
|
52
|
+
...CHILD_REMOVED_TOOLS,
|
|
53
|
+
...(removeAgent ? [AGENT_TOOL] : []),
|
|
54
|
+
...(template?.disallowedTools ?? []),
|
|
55
|
+
]),
|
|
56
|
+
];
|
|
57
|
+
const own = template?.tools === undefined ? undefined : [...new Set(template.tools)];
|
|
58
|
+
const allow = own === undefined
|
|
59
|
+
? parent?.allow
|
|
60
|
+
: parent?.allow === undefined
|
|
61
|
+
? own
|
|
62
|
+
: own.filter((k) => parent.allow?.includes(k));
|
|
63
|
+
return { ...(allow !== undefined && { allow: [...allow] }), deny };
|
|
113
64
|
}
|
|
114
65
|
/**
|
|
115
66
|
* The template's skills the parent selects (its `orgSkills` or the parent agent's own skills),
|
|
@@ -236,10 +187,12 @@ function orgAgentDefinition(d, a) {
|
|
|
236
187
|
// block stays: it is the roster the child dispatches from (agent map spec §4.1); pending
|
|
237
188
|
// connectors are authoring data too (ruling P4-6)
|
|
238
189
|
const { skills, instructionFiles: _files, pendingConnectors: _pending, ...rest } = own;
|
|
190
|
+
const { subagentTools: _filter, ...ownRest } = rest;
|
|
239
191
|
const definition = {
|
|
240
|
-
...
|
|
192
|
+
...ownRest,
|
|
241
193
|
// its own tools, not intersected with the parent's; only the child-removed ones go
|
|
242
|
-
|
|
194
|
+
disabledTools: own.disabledTools ?? [],
|
|
195
|
+
subagentTools: childFilter(atMaxDepth(a), null),
|
|
243
196
|
// its policies, then the parent's on top, stricter wins (keys outside its tools are inert)
|
|
244
197
|
toolPolicies: stricterPolicies(own.toolPolicies ?? {}, a.parent.toolPolicies ?? {}),
|
|
245
198
|
...(skills !== undefined && {
|
|
@@ -298,8 +251,6 @@ export async function effectiveDefinition(d, a) {
|
|
|
298
251
|
...(row.platformTemplateId !== undefined && { platformTemplateId: row.platformTemplateId }),
|
|
299
252
|
};
|
|
300
253
|
}
|
|
301
|
-
const connectors = await loadConnectors(d.db, a.orgId, parent.tools);
|
|
302
|
-
const tools = narrowTools(parent.tools, connectors, template?.tools !== undefined ? new Set(template.tools) : null, new Set(template?.disallowedTools ?? []), atMaxDepth(a));
|
|
303
254
|
const toolPolicies = stricterPolicies(parent.toolPolicies ?? {}, template?.toolPolicies ?? {});
|
|
304
255
|
const { pinned, warnings } = await pinnedFor(d.db, a, template?.skills ?? [], entry.source === "plugin" ? { plugin: entry.plugin } : null, template?.selectedSkills ?? []);
|
|
305
256
|
const tier = a.tier ?? template?.model ?? "inherit";
|
|
@@ -322,7 +273,8 @@ export async function effectiveDefinition(d, a) {
|
|
|
322
273
|
fallback: m.fallback,
|
|
323
274
|
modelParams,
|
|
324
275
|
fallbackParams: m.fallbackParams,
|
|
325
|
-
|
|
276
|
+
disabledTools: parent.disabledTools ?? [],
|
|
277
|
+
subagentTools: childFilter(atMaxDepth(a), template, parent.subagentTools),
|
|
326
278
|
toolPolicies,
|
|
327
279
|
...((parentSkills !== undefined || pinned.length > 0) && {
|
|
328
280
|
skills: {
|
|
@@ -341,57 +293,32 @@ export async function effectiveDefinition(d, a) {
|
|
|
341
293
|
tierFallback: m.tierFallback,
|
|
342
294
|
};
|
|
343
295
|
}
|
|
344
|
-
/**
|
|
345
|
-
* The refs of `frozen` that `current` still has: a builtin or plugin tool by name, a connector by
|
|
346
|
-
* id; a connector's `all` meets the other side's names (`all` on both stays `all`), and a
|
|
347
|
-
* connector left with no names is dropped. Pure: a connector `current` lists is not looked up.
|
|
348
|
-
*/
|
|
349
|
-
export function intersectTools(frozen, current) {
|
|
350
|
-
const out = [];
|
|
351
|
-
for (const ref of frozen) {
|
|
352
|
-
if (ref.kind === "builtin") {
|
|
353
|
-
if (current.some((c) => c.kind === "builtin" && c.name === ref.name))
|
|
354
|
-
out.push(ref);
|
|
355
|
-
}
|
|
356
|
-
else if (ref.kind === "plugin") {
|
|
357
|
-
if (current.some((c) => c.kind === "plugin" && c.plugin === ref.plugin && c.name === ref.name)) {
|
|
358
|
-
out.push(ref);
|
|
359
|
-
}
|
|
360
|
-
}
|
|
361
|
-
else {
|
|
362
|
-
const c = current.find((x) => x.kind === "connector" && x.connectorId === ref.connectorId);
|
|
363
|
-
if (!c)
|
|
364
|
-
continue;
|
|
365
|
-
if (c.tools === "all") {
|
|
366
|
-
out.push(ref);
|
|
367
|
-
continue;
|
|
368
|
-
}
|
|
369
|
-
const names = ref.tools === "all" ? c.tools : ref.tools.filter((n) => c.tools.includes(n));
|
|
370
|
-
if (names.length > 0)
|
|
371
|
-
out.push({ ...ref, tools: names });
|
|
372
|
-
}
|
|
373
|
-
}
|
|
374
|
-
return out;
|
|
375
|
-
}
|
|
376
296
|
/**
|
|
377
297
|
* The narrowing of a follow-up (final review I1): `frozen` (the child's `subagent_started`
|
|
378
298
|
* definition) against `current`, the definition a fresh dispatch would read now: the dispatching
|
|
379
299
|
* parent run's version for `general` / inline / plugin children, the dispatched org agent's
|
|
380
300
|
* current version for an org agent child (whose tools are its own at dispatch too, §5.5). Its
|
|
381
|
-
* `orgSkills` keep only those `current` still
|
|
382
|
-
* skills goes with it (the agent's own skills
|
|
301
|
+
* `disabledTools` are both lists together; its `orgSkills` keep only those `current` still
|
|
302
|
+
* selects; a pinned id that was one of the frozen org skills goes with it (the agent's own skills
|
|
303
|
+
* stay).
|
|
383
304
|
*/
|
|
384
305
|
export function narrowFollowUp(frozen, current) {
|
|
385
|
-
const
|
|
306
|
+
const disabledTools = canonicalDisabledTools([
|
|
307
|
+
...(frozen.disabledTools ?? []),
|
|
308
|
+
...(current.disabledTools ?? []),
|
|
309
|
+
]);
|
|
386
310
|
if (frozen.skills === undefined)
|
|
387
|
-
return {
|
|
311
|
+
return { disabledTools };
|
|
388
312
|
const frozenOrg = new Set(frozen.skills.orgSkills);
|
|
389
313
|
const now = new Set(current.skills?.orgSkills ?? []);
|
|
390
314
|
const orgSkills = frozen.skills.orgSkills.filter((id) => now.has(id));
|
|
391
315
|
const pinned = frozen.skills.pinned?.filter((id) => !frozenOrg.has(id) || now.has(id));
|
|
392
|
-
return {
|
|
316
|
+
return { disabledTools, skills: { orgSkills, ...(pinned !== undefined && { pinned }) } };
|
|
393
317
|
}
|
|
394
|
-
/**
|
|
318
|
+
/**
|
|
319
|
+
* The definition a child run uses: the frozen one with its trigger's follow-up narrowing. A
|
|
320
|
+
* narrowing logged before tools were on by default (no `disabledTools`) narrows only skills.
|
|
321
|
+
*/
|
|
395
322
|
export function childRunDefinition(frozen, narrowed) {
|
|
396
323
|
if (narrowed === undefined)
|
|
397
324
|
return frozen;
|
|
@@ -403,5 +330,9 @@ export function childRunDefinition(frozen, narrowed) {
|
|
|
403
330
|
orgSkills: narrowed.skills.orgSkills,
|
|
404
331
|
...(narrowed.skills.pinned !== undefined && { pinned: narrowed.skills.pinned }),
|
|
405
332
|
};
|
|
406
|
-
return {
|
|
333
|
+
return {
|
|
334
|
+
...rest,
|
|
335
|
+
...(Array.isArray(narrowed.disabledTools) && { disabledTools: narrowed.disabledTools }),
|
|
336
|
+
...(kept !== undefined && { skills: kept }),
|
|
337
|
+
};
|
|
407
338
|
}
|
|
@@ -11,6 +11,7 @@ import { Controller, Delete, Get, HttpCode, Inject, Param, Post } from "@nestjs/
|
|
|
11
11
|
import { z } from "zod";
|
|
12
12
|
import { AgentsService } from "../agents/agents.service.js";
|
|
13
13
|
import { CurrentPrincipal, patTokenId, requireUser, } from "../identity/principal.js";
|
|
14
|
+
import { InboxNoticeParams } from "../inbox/inbox.schemas.js";
|
|
14
15
|
import { InboxService } from "../inbox/inbox.service.js";
|
|
15
16
|
import { createZodDto } from "../infra/validation/create-zod-dto.js";
|
|
16
17
|
import { ZBody, ZParam } from "../infra/validation/zod-params.js";
|
|
@@ -25,7 +26,7 @@ const DecideBody = z
|
|
|
25
26
|
.strict();
|
|
26
27
|
class SkillChangeDecideBody extends createZodDto(DecideBody, "SkillChangeDecideBody") {
|
|
27
28
|
}
|
|
28
|
-
const NoticeParamsSchema =
|
|
29
|
+
const NoticeParamsSchema = InboxNoticeParams;
|
|
29
30
|
class NoticeParams extends createZodDto(NoticeParamsSchema, "InboxNoticeParams") {
|
|
30
31
|
}
|
|
31
32
|
/**
|
|
@@ -130,7 +130,7 @@ export declare class SkillChangesService {
|
|
|
130
130
|
* agent → `skill.not_found`。同名的待处理改动一并取消(发起对话追加回退快照,提交后删草稿)。审计 `skill.deleted`。
|
|
131
131
|
* 各对话下一次运行开始时目录里去掉它;之后同名可再写为新技能。
|
|
132
132
|
*/
|
|
133
|
-
deleteAgentSkill(orgId: string, agentId: string, skillId: string, accountId: string, actorTokenId?: string): Promise<void>;
|
|
133
|
+
deleteAgentSkill(orgId: string, agentId: string, skillId: string, accountId: string, actorTokenId?: string, auditDetail?: Record<string, unknown>): Promise<void>;
|
|
134
134
|
/** The transaction of {@link write}. */
|
|
135
135
|
private writeIn;
|
|
136
136
|
/** The transaction of {@link decide}. */
|
|
@@ -146,8 +146,8 @@ let SkillChangesService = class SkillChangesService {
|
|
|
146
146
|
* agent → `skill.not_found`。同名的待处理改动一并取消(发起对话追加回退快照,提交后删草稿)。审计 `skill.deleted`。
|
|
147
147
|
* 各对话下一次运行开始时目录里去掉它;之后同名可再写为新技能。
|
|
148
148
|
*/
|
|
149
|
-
async deleteAgentSkill(orgId, agentId, skillId, accountId, actorTokenId) {
|
|
150
|
-
const cancelled = await this.deleteAgentSkillIn(orgId, agentId, skillId, accountId, actorTokenId);
|
|
149
|
+
async deleteAgentSkill(orgId, agentId, skillId, accountId, actorTokenId, auditDetail) {
|
|
150
|
+
const cancelled = await this.deleteAgentSkillIn(orgId, agentId, skillId, accountId, actorTokenId, auditDetail);
|
|
151
151
|
await this.finishCancel(orgId, cancelled);
|
|
152
152
|
}
|
|
153
153
|
/** The transaction of {@link write}. */
|
|
@@ -401,7 +401,7 @@ let SkillChangesService = class SkillChangesService {
|
|
|
401
401
|
return { updated, revertSeq };
|
|
402
402
|
}
|
|
403
403
|
/** The transaction of {@link deleteAgentSkill}. */
|
|
404
|
-
async deleteAgentSkillIn(orgId, agentId, skillId, accountId, actorTokenId) {
|
|
404
|
+
async deleteAgentSkillIn(orgId, agentId, skillId, accountId, actorTokenId, auditDetail) {
|
|
405
405
|
await this.keyShareOrg(orgId);
|
|
406
406
|
const agent = await this.db
|
|
407
407
|
.selectFrom("agents")
|
|
@@ -471,7 +471,7 @@ let SkillChangesService = class SkillChangesService {
|
|
|
471
471
|
orgId,
|
|
472
472
|
action: "skill.deleted",
|
|
473
473
|
target: skillId,
|
|
474
|
-
detail: { name: r.name, agentId },
|
|
474
|
+
detail: { name: r.name, agentId, ...auditDetail },
|
|
475
475
|
});
|
|
476
476
|
return out;
|
|
477
477
|
}
|
|
@@ -8,13 +8,13 @@ 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, Header, Inject, Param } from "@nestjs/common";
|
|
11
|
-
import { z } from "zod";
|
|
12
11
|
import { CurrentPrincipal, requireUser } from "../identity/principal.js";
|
|
13
12
|
import { createZodDto } from "../infra/validation/create-zod-dto.js";
|
|
14
13
|
import { ZQuery } from "../infra/validation/zod-params.js";
|
|
15
14
|
import { CurrentOrg, OrgAction } from "../orgs/org.guard.js";
|
|
16
15
|
import { SkillInvoker } from "./invoke.js";
|
|
17
|
-
|
|
16
|
+
import { InvocableSkillsQuerySchema } from "./skills.schemas.js";
|
|
17
|
+
const ListQuery = InvocableSkillsQuerySchema;
|
|
18
18
|
class InvocableSkillsQuery extends createZodDto(ListQuery, "InvocableSkillsQuery") {
|
|
19
19
|
}
|
|
20
20
|
/**
|
package/dist/skills/invoke.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { AgentLookup } from "../agents/agent-lookup.js";
|
|
2
|
-
import type
|
|
2
|
+
import { type AgentDefinition } from "../agents/definition.js";
|
|
3
3
|
import type { EventPayload } from "../conversations/events.js";
|
|
4
4
|
import type { KernelSchemaDb } from "../db/kernel-schema.js";
|
|
5
5
|
import { ApiError } from "../errors.js";
|
|
@@ -128,7 +128,7 @@ export declare class SkillInvoker {
|
|
|
128
128
|
conversationId: string;
|
|
129
129
|
skill: InvocationRecord;
|
|
130
130
|
}): Promise<{
|
|
131
|
-
task: (child: Pick<AgentDefinition, "
|
|
131
|
+
task: (child: Pick<AgentDefinition, "disabledTools" | "subagentTools">) => string;
|
|
132
132
|
warning?: string;
|
|
133
133
|
}>;
|
|
134
134
|
/** Reads and parses the version's SKILL.md (checked against the manifest), returns the body. */
|
package/dist/skills/invoke.js
CHANGED
|
@@ -10,6 +10,7 @@ var __param = (this && this.__param) || function (paramIndex, decorator) {
|
|
|
10
10
|
import { escapeSkillInvocationTags, hasShellInjection, parseSkillMd, renderSkillBody, renderSkillInvocation, SKILL_ENTRY_FILE, SKILL_INVOCATION_LIMITS, skillDigest, } from "@capybara-hq/plugin-sdk";
|
|
11
11
|
import { Inject, Injectable } from "@nestjs/common";
|
|
12
12
|
import { AgentLookup } from "../agents/agent-lookup.js";
|
|
13
|
+
import { builtinDisabled } from "../agents/definition.js";
|
|
13
14
|
import { ApiError } from "../errors.js";
|
|
14
15
|
import { KernelDb } from "../infra/database/kernel-db.js";
|
|
15
16
|
import { KERNEL_LOGGER } from "../infra/tokens.js";
|
|
@@ -289,7 +290,13 @@ SkillInvoker = __decorate([
|
|
|
289
290
|
__param(3, Inject(KERNEL_LOGGER))
|
|
290
291
|
], SkillInvoker);
|
|
291
292
|
export { SkillInvoker };
|
|
292
|
-
|
|
293
|
+
/**
|
|
294
|
+
* Does the definition leave builtin `name` on (tools default-on spec §4): not turned off and not
|
|
295
|
+
* removed by a sub-agent's key filter. Whether it can run now (a sandbox) is not checked.
|
|
296
|
+
*/
|
|
297
|
+
const hasBuiltin = (agent, name) => !builtinDisabled(agent.disabledTools, name) &&
|
|
298
|
+
!(agent.subagentTools?.deny ?? []).includes(name) &&
|
|
299
|
+
(agent.subagentTools?.allow === undefined || agent.subagentTools.allow.includes(name));
|
|
293
300
|
/** The skill's own body over the rendered limit: a 400 on `skill` naming the skill. */
|
|
294
301
|
function tooLarge(name, render) {
|
|
295
302
|
try {
|
|
@@ -3,21 +3,12 @@ import { OwnedItems, type OwnedSkillDeletePreview } from "../catalog/owned-items
|
|
|
3
3
|
import { type CreatedAttachment } from "../conversations/attachments.service.js";
|
|
4
4
|
import { type Principal } from "../identity/principal.js";
|
|
5
5
|
import { type OrgContext } from "../orgs/org.guard.js";
|
|
6
|
+
import { SkillCreateBody, SkillIdParams } from "./skills.schemas.js";
|
|
6
7
|
import { type SkillDetail, type SkillSummary, SkillsService, type UploadedSkill } from "./skills.service.js";
|
|
7
8
|
declare const UploadBody: z.ZodObject<{
|
|
8
9
|
name: z.ZodString;
|
|
9
10
|
size: z.ZodNumber;
|
|
10
11
|
}, z.core.$strict>;
|
|
11
|
-
declare const CreateBody: z.ZodObject<{
|
|
12
|
-
uploadId: z.ZodOptional<z.ZodString>;
|
|
13
|
-
name: z.ZodOptional<z.ZodString & z.ZodType<string, string, z.core.$ZodTypeInternals<string, string>>>;
|
|
14
|
-
description: z.ZodOptional<z.ZodString>;
|
|
15
|
-
body: z.ZodOptional<z.ZodString>;
|
|
16
|
-
shareable: z.ZodOptional<z.ZodBoolean>;
|
|
17
|
-
}, z.core.$strict>;
|
|
18
|
-
declare const IdParams: z.ZodObject<{
|
|
19
|
-
id: z.ZodString;
|
|
20
|
-
}, z.core.$strip>;
|
|
21
12
|
declare const ShareableBody: z.ZodObject<{
|
|
22
13
|
shareable: z.ZodBoolean;
|
|
23
14
|
}, z.core.$strict>;
|
|
@@ -46,7 +37,7 @@ export declare class SkillsController {
|
|
|
46
37
|
/** The org's own items: 可共享 and the delete of a promoted skill (rulings P3-3, P3-19). */
|
|
47
38
|
owned: OwnedItems);
|
|
48
39
|
createUpload(principal: Principal, org: OrgContext, body: z.infer<typeof UploadBody>): Promise<CreatedAttachment>;
|
|
49
|
-
create(principal: Principal, org: OrgContext, body: z.infer<typeof
|
|
40
|
+
create(principal: Principal, org: OrgContext, body: z.infer<typeof SkillCreateBody>): Promise<UploadedSkill>;
|
|
50
41
|
list(principal: Principal, org: OrgContext): Promise<{
|
|
51
42
|
skills: SkillSummary[];
|
|
52
43
|
}>;
|
|
@@ -56,7 +47,7 @@ export declare class SkillsController {
|
|
|
56
47
|
* skill of the org's own (P3-6: an agent's skill or a copy of another owner's platform skill ->
|
|
57
48
|
* 409 `catalog.not_owned`); one it promoted writes its platform row too (ruling P3-2).
|
|
58
49
|
*/
|
|
59
|
-
setShareable(principal: Principal, org: OrgContext, params: z.infer<typeof
|
|
50
|
+
setShareable(principal: Principal, org: OrgContext, params: z.infer<typeof SkillIdParams>, body: z.infer<typeof ShareableBody>): Promise<{
|
|
60
51
|
id: string;
|
|
61
52
|
shareable: boolean;
|
|
62
53
|
}>;
|
|
@@ -65,7 +56,7 @@ export declare class SkillsController {
|
|
|
65
56
|
* `transferred` when it was shared and another org uses it (`orgs`), else `removed`; `agents`
|
|
66
57
|
* the org's agents that lose it.
|
|
67
58
|
*/
|
|
68
|
-
deletePreview(principal: Principal, org: OrgContext, params: z.infer<typeof
|
|
59
|
+
deletePreview(principal: Principal, org: OrgContext, params: z.infer<typeof SkillIdParams>): Promise<OwnedSkillDeletePreview>;
|
|
69
60
|
/**
|
|
70
61
|
* Soft-deletes the skill; one the org shared that another org uses is transferred to the
|
|
71
62
|
* platform first (P3-19, platform notice `ownership_transferred`). 204.
|
|
@@ -7,7 +7,7 @@ var __decorate = (this && this.__decorate) || function (decorators, target, key,
|
|
|
7
7
|
var __param = (this && this.__param) || function (paramIndex, decorator) {
|
|
8
8
|
return function (target, key) { decorator(target, key, paramIndex); }
|
|
9
9
|
};
|
|
10
|
-
import { hasControlChars,
|
|
10
|
+
import { hasControlChars, MEDIA_NAME_MAX_CHARS } from "@capybara-hq/plugin-sdk";
|
|
11
11
|
import { Controller, Delete, Get, HttpCode, Inject, Param, Post, Put } from "@nestjs/common";
|
|
12
12
|
import { z } from "zod";
|
|
13
13
|
import { OwnedItems } from "../catalog/owned-items.js";
|
|
@@ -16,7 +16,7 @@ import { CurrentPrincipal, patTokenId, requireUser, } from "../identity/principa
|
|
|
16
16
|
import { createZodDto } from "../infra/validation/create-zod-dto.js";
|
|
17
17
|
import { ZBody, ZParam } from "../infra/validation/zod-params.js";
|
|
18
18
|
import { CurrentOrg, OrgAction } from "../orgs/org.guard.js";
|
|
19
|
-
import {
|
|
19
|
+
import { SkillCreateBody, SkillIdParams, SkillShareableSchema } from "./skills.schemas.js";
|
|
20
20
|
import { SkillsService, } from "./skills.service.js";
|
|
21
21
|
const UploadBody = z
|
|
22
22
|
.object({
|
|
@@ -28,28 +28,12 @@ const UploadBody = z
|
|
|
28
28
|
size: z.number().int().min(1).max(SKILL_PACKAGE_UPLOAD_MAX_BYTES),
|
|
29
29
|
})
|
|
30
30
|
.strict();
|
|
31
|
-
const CreateBody = z
|
|
32
|
-
.object({
|
|
33
|
-
uploadId: z.string().min(1).max(100).optional(),
|
|
34
|
-
name: z
|
|
35
|
-
.string()
|
|
36
|
-
.refine(isSkillName, "name must be 1-64 lowercase letters, digits and single hyphens")
|
|
37
|
-
.optional(),
|
|
38
|
-
description: z.string().min(1).max(SKILL_LIMITS.descriptionMaxChars).optional(),
|
|
39
|
-
body: z.string().max(SKILL_WRITE_MAX_BYTES).optional(),
|
|
40
|
-
shareable: z.boolean().optional(),
|
|
41
|
-
})
|
|
42
|
-
.strict()
|
|
43
|
-
.refine((v) => v.uploadId !== undefined
|
|
44
|
-
? v.name === undefined && v.description === undefined && v.body === undefined
|
|
45
|
-
: v.name !== undefined && v.description !== undefined && v.body !== undefined, "send either { uploadId } or { name, description, body }");
|
|
46
31
|
class SkillUploadBody extends createZodDto(UploadBody, "SkillUploadBody") {
|
|
47
32
|
}
|
|
48
|
-
class
|
|
33
|
+
class SkillCreateBodyDto extends createZodDto(SkillCreateBody, "SkillCreateBody") {
|
|
49
34
|
}
|
|
50
|
-
const
|
|
51
|
-
|
|
52
|
-
class SkillIdParams extends createZodDto(IdParams, "SkillIdParams") {
|
|
35
|
+
const ShareableBody = SkillShareableSchema;
|
|
36
|
+
class SkillIdParamsDto extends createZodDto(SkillIdParams, "SkillIdParams") {
|
|
53
37
|
}
|
|
54
38
|
class SkillShareableBody extends createZodDto(ShareableBody, "SkillShareableBody") {
|
|
55
39
|
}
|
|
@@ -147,7 +131,7 @@ __decorate([
|
|
|
147
131
|
OrgAction("skills.manage"),
|
|
148
132
|
__param(0, CurrentPrincipal()),
|
|
149
133
|
__param(1, CurrentOrg()),
|
|
150
|
-
__param(2, ZBody(
|
|
134
|
+
__param(2, ZBody(SkillCreateBodyDto))
|
|
151
135
|
], SkillsController.prototype, "create", null);
|
|
152
136
|
__decorate([
|
|
153
137
|
Get(),
|
|
@@ -167,7 +151,7 @@ __decorate([
|
|
|
167
151
|
OrgAction("skills.manage"),
|
|
168
152
|
__param(0, CurrentPrincipal()),
|
|
169
153
|
__param(1, CurrentOrg()),
|
|
170
|
-
__param(2, ZParam(
|
|
154
|
+
__param(2, ZParam(SkillIdParamsDto)),
|
|
171
155
|
__param(3, ZBody(SkillShareableBody))
|
|
172
156
|
], SkillsController.prototype, "setShareable", null);
|
|
173
157
|
__decorate([
|
|
@@ -175,7 +159,7 @@ __decorate([
|
|
|
175
159
|
OrgAction("skills.manage"),
|
|
176
160
|
__param(0, CurrentPrincipal()),
|
|
177
161
|
__param(1, CurrentOrg()),
|
|
178
|
-
__param(2, ZParam(
|
|
162
|
+
__param(2, ZParam(SkillIdParamsDto))
|
|
179
163
|
], SkillsController.prototype, "deletePreview", null);
|
|
180
164
|
__decorate([
|
|
181
165
|
Delete(":id"),
|