@capybara-hq/kernel 0.0.0-stage → 0.1.0-rc.1
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/LICENSE +202 -0
- package/NOTICE +2 -0
- package/README.md +20 -2
- package/bootstrap.json +26 -0
- package/dist/admin/admin.controller.d.ts +139 -0
- package/dist/admin/admin.controller.js +238 -0
- package/dist/admin/extensions.controller.d.ts +100 -0
- package/dist/admin/extensions.controller.js +226 -0
- package/dist/admin/setup.controller.d.ts +36 -0
- package/dist/admin/setup.controller.js +106 -0
- package/dist/admin/setup.service.d.ts +47 -0
- package/dist/admin/setup.service.js +90 -0
- package/dist/agents/agents.controller.d.ts +205 -0
- package/dist/agents/agents.controller.js +144 -0
- package/dist/agents/agents.service.d.ts +177 -0
- package/dist/agents/agents.service.js +677 -0
- package/dist/agents/definition.d.ts +198 -0
- package/dist/agents/definition.js +152 -0
- package/dist/agents/models.controller.d.ts +13 -0
- package/dist/agents/models.controller.js +31 -0
- package/dist/agents/templates.controller.d.ts +15 -0
- package/dist/agents/templates.controller.js +37 -0
- package/dist/agents/templates.d.ts +83 -0
- package/dist/agents/templates.js +173 -0
- package/dist/catalog/admin-catalog.controller.d.ts +143 -0
- package/dist/catalog/admin-catalog.controller.js +245 -0
- package/dist/catalog/catalog.service.d.ts +430 -0
- package/dist/catalog/catalog.service.js +882 -0
- package/dist/catalog/claude/agents.d.ts +27 -0
- package/dist/catalog/claude/agents.js +270 -0
- package/dist/catalog/claude/commands.d.ts +50 -0
- package/dist/catalog/claude/commands.js +179 -0
- package/dist/catalog/claude/manifest.d.ts +69 -0
- package/dist/catalog/claude/manifest.js +134 -0
- package/dist/catalog/claude/marketplace.d.ts +35 -0
- package/dist/catalog/claude/marketplace.js +194 -0
- package/dist/catalog/claude/mcp.d.ts +33 -0
- package/dist/catalog/claude/mcp.js +226 -0
- package/dist/catalog/claude/report.d.ts +86 -0
- package/dist/catalog/claude/report.js +121 -0
- package/dist/catalog/claude/translate.d.ts +56 -0
- package/dist/catalog/claude/translate.js +857 -0
- package/dist/catalog/cli.d.ts +46 -0
- package/dist/catalog/cli.js +211 -0
- package/dist/catalog/git-source.d.ts +127 -0
- package/dist/catalog/git-source.js +520 -0
- package/dist/catalog/marketplace-fetch.d.ts +99 -0
- package/dist/catalog/marketplace-fetch.js +203 -0
- package/dist/catalog/marketplaces.controller.d.ts +97 -0
- package/dist/catalog/marketplaces.controller.js +197 -0
- package/dist/catalog/marketplaces.service.d.ts +340 -0
- package/dist/catalog/marketplaces.service.js +1217 -0
- package/dist/catalog/org-catalog.controller.d.ts +128 -0
- package/dist/catalog/org-catalog.controller.js +277 -0
- package/dist/catalog/org-catalog.service.d.ts +246 -0
- package/dist/catalog/org-catalog.service.js +625 -0
- package/dist/catalog/plugin-import.d.ts +436 -0
- package/dist/catalog/plugin-import.js +1069 -0
- package/dist/catalog/plugin-install.d.ts +447 -0
- package/dist/catalog/plugin-install.js +1333 -0
- package/dist/catalog/plugin-package.d.ts +143 -0
- package/dist/catalog/plugin-package.js +382 -0
- package/dist/catalog/plugin-upgrade.d.ts +222 -0
- package/dist/catalog/plugin-upgrade.js +1219 -0
- package/dist/catalog/requests.service.d.ts +162 -0
- package/dist/catalog/requests.service.js +504 -0
- package/dist/catalog/schema-path.d.ts +7 -0
- package/dist/catalog/schema-path.js +63 -0
- package/dist/catalog/upgrade-targets.d.ts +59 -0
- package/dist/catalog/upgrade-targets.js +90 -0
- package/dist/catalog/versions.d.ts +31 -0
- package/dist/catalog/versions.js +44 -0
- package/dist/channels/actions.d.ts +37 -0
- package/dist/channels/actions.js +121 -0
- package/dist/channels/cards.d.ts +44 -0
- package/dist/channels/cards.js +156 -0
- package/dist/channels/connections.controller.d.ts +59 -0
- package/dist/channels/connections.controller.js +115 -0
- package/dist/channels/connections.service.d.ts +187 -0
- package/dist/channels/connections.service.js +534 -0
- package/dist/channels/features.d.ts +12 -0
- package/dist/channels/features.js +22 -0
- package/dist/channels/inbound.d.ts +120 -0
- package/dist/channels/inbound.js +332 -0
- package/dist/channels/outbound.d.ts +140 -0
- package/dist/channels/outbound.js +1126 -0
- package/dist/channels/phrases.d.ts +100 -0
- package/dist/channels/phrases.js +81 -0
- package/dist/channels/supervisor.d.ts +182 -0
- package/dist/channels/supervisor.js +625 -0
- package/dist/channels/threads.d.ts +29 -0
- package/dist/channels/threads.js +104 -0
- package/dist/channels/webhook-url.d.ts +16 -0
- package/dist/channels/webhook-url.js +34 -0
- package/dist/channels/webhook.controller.d.ts +19 -0
- package/dist/channels/webhook.controller.js +72 -0
- package/dist/channels/webhook.d.ts +73 -0
- package/dist/channels/webhook.js +274 -0
- package/dist/config/docs.d.ts +9 -0
- package/dist/config/docs.js +85 -0
- package/dist/config/env.d.ts +6 -0
- package/dist/config/env.js +73 -0
- package/dist/config/fields.d.ts +42 -0
- package/dist/config/fields.js +214 -0
- package/dist/config/file-source.d.ts +3 -0
- package/dist/config/file-source.js +31 -0
- package/dist/config/load.d.ts +20 -0
- package/dist/config/load.js +98 -0
- package/dist/config/nacos-source.d.ts +31 -0
- package/dist/config/nacos-source.js +229 -0
- package/dist/config/schema.d.ts +237 -0
- package/dist/config/schema.js +1192 -0
- package/dist/config/sources.d.ts +18 -0
- package/dist/config/sources.js +59 -0
- package/dist/config/types.d.ts +9 -0
- package/dist/config/types.js +7 -0
- package/dist/conversations/artifacts.d.ts +52 -0
- package/dist/conversations/artifacts.js +137 -0
- package/dist/conversations/attachments.controller.d.ts +28 -0
- package/dist/conversations/attachments.controller.js +96 -0
- package/dist/conversations/attachments.service.d.ts +180 -0
- package/dist/conversations/attachments.service.js +578 -0
- package/dist/conversations/conversations.controller.d.ts +288 -0
- package/dist/conversations/conversations.controller.js +607 -0
- package/dist/conversations/conversations.service.d.ts +321 -0
- package/dist/conversations/conversations.service.js +754 -0
- package/dist/conversations/event-log.d.ts +122 -0
- package/dist/conversations/event-log.js +259 -0
- package/dist/conversations/events.d.ts +856 -0
- package/dist/conversations/events.js +639 -0
- package/dist/conversations/files.d.ts +92 -0
- package/dist/conversations/files.js +213 -0
- package/dist/conversations/outputs-read.d.ts +34 -0
- package/dist/conversations/outputs-read.js +37 -0
- package/dist/conversations/queue.d.ts +169 -0
- package/dist/conversations/queue.js +527 -0
- package/dist/conversations/sandbox-status.d.ts +21 -0
- package/dist/conversations/sandbox-status.js +24 -0
- package/dist/conversations/selection.d.ts +46 -0
- package/dist/conversations/selection.js +75 -0
- package/dist/conversations/titles.d.ts +93 -0
- package/dist/conversations/titles.js +423 -0
- package/dist/ctx/bus.d.ts +16 -0
- package/dist/ctx/bus.js +101 -0
- package/dist/ctx/create-ctx.d.ts +109 -0
- package/dist/ctx/create-ctx.js +592 -0
- package/dist/ctx/kv.d.ts +4 -0
- package/dist/ctx/kv.js +31 -0
- package/dist/ctx/lock.d.ts +4 -0
- package/dist/ctx/lock.js +39 -0
- package/dist/ctx/namespace.d.ts +6 -0
- package/dist/ctx/namespace.js +12 -0
- package/dist/ctx/queue.d.ts +25 -0
- package/dist/ctx/queue.js +151 -0
- package/dist/ctx/secrets.d.ts +45 -0
- package/dist/ctx/secrets.js +175 -0
- package/dist/db/kernel-schema.d.ts +1122 -0
- package/dist/db/kernel-schema.js +5 -0
- package/dist/db/migrator.d.ts +28 -0
- package/dist/db/migrator.js +140 -0
- package/dist/db/pool.d.ts +21 -0
- package/dist/db/pool.js +28 -0
- package/dist/db/sql-statements.d.ts +34 -0
- package/dist/db/sql-statements.js +168 -0
- package/dist/errors.d.ts +211 -0
- package/dist/errors.js +213 -0
- package/dist/evals/budget.d.ts +61 -0
- package/dist/evals/budget.js +181 -0
- package/dist/evals/diff.d.ts +55 -0
- package/dist/evals/diff.js +133 -0
- package/dist/evals/judge.d.ts +53 -0
- package/dist/evals/judge.js +149 -0
- package/dist/evals/plan.d.ts +47 -0
- package/dist/evals/plan.js +77 -0
- package/dist/evals/reconstruct.d.ts +137 -0
- package/dist/evals/reconstruct.js +322 -0
- package/dist/evals/recorded-tools.d.ts +54 -0
- package/dist/evals/recorded-tools.js +167 -0
- package/dist/evals/run-replay.d.ts +86 -0
- package/dist/evals/run-replay.js +502 -0
- package/dist/evals/runs.controller.d.ts +100 -0
- package/dist/evals/runs.controller.js +199 -0
- package/dist/evals/runs.service.d.ts +275 -0
- package/dist/evals/runs.service.js +836 -0
- package/dist/evals/sets.controller.d.ts +61 -0
- package/dist/evals/sets.controller.js +183 -0
- package/dist/evals/sets.service.d.ts +128 -0
- package/dist/evals/sets.service.js +558 -0
- package/dist/evals/snapshot.d.ts +76 -0
- package/dist/evals/snapshot.js +207 -0
- package/dist/evals/step-replay.d.ts +113 -0
- package/dist/evals/step-replay.js +181 -0
- package/dist/evals/trajectory.controller.d.ts +41 -0
- package/dist/evals/trajectory.controller.js +88 -0
- package/dist/evals/trajectory.d.ts +144 -0
- package/dist/evals/trajectory.js +338 -0
- package/dist/evals/trajectory.service.d.ts +108 -0
- package/dist/evals/trajectory.service.js +323 -0
- package/dist/evals/worker.d.ts +101 -0
- package/dist/evals/worker.js +790 -0
- package/dist/extensions/admin-ops.d.ts +105 -0
- package/dist/extensions/admin-ops.js +353 -0
- package/dist/extensions/admin-view.d.ts +79 -0
- package/dist/extensions/admin-view.js +327 -0
- package/dist/extensions/approvals.d.ts +119 -0
- package/dist/extensions/approvals.js +205 -0
- package/dist/extensions/blobs.d.ts +45 -0
- package/dist/extensions/blobs.js +160 -0
- package/dist/extensions/bootstrap.d.ts +176 -0
- package/dist/extensions/bootstrap.js +535 -0
- package/dist/extensions/cli.d.ts +61 -0
- package/dist/extensions/cli.js +165 -0
- package/dist/extensions/config-json-schema.d.ts +9 -0
- package/dist/extensions/config-json-schema.js +73 -0
- package/dist/extensions/deployment-config.d.ts +138 -0
- package/dist/extensions/deployment-config.js +394 -0
- package/dist/extensions/enabled.d.ts +31 -0
- package/dist/extensions/enabled.js +55 -0
- package/dist/extensions/hooks.d.ts +161 -0
- package/dist/extensions/hooks.js +425 -0
- package/dist/extensions/host.d.ts +577 -0
- package/dist/extensions/host.js +2071 -0
- package/dist/extensions/inflight.d.ts +69 -0
- package/dist/extensions/inflight.js +277 -0
- package/dist/extensions/installs.d.ts +166 -0
- package/dist/extensions/installs.js +253 -0
- package/dist/extensions/instance.d.ts +167 -0
- package/dist/extensions/instance.js +329 -0
- package/dist/extensions/ledger.d.ts +30 -0
- package/dist/extensions/ledger.js +50 -0
- package/dist/extensions/lifecycle.d.ts +80 -0
- package/dist/extensions/lifecycle.js +152 -0
- package/dist/extensions/migrate-lock.d.ts +51 -0
- package/dist/extensions/migrate-lock.js +100 -0
- package/dist/extensions/org-config.controller.d.ts +24 -0
- package/dist/extensions/org-config.controller.js +59 -0
- package/dist/extensions/org-config.d.ts +169 -0
- package/dist/extensions/org-config.js +520 -0
- package/dist/extensions/package.d.ts +115 -0
- package/dist/extensions/package.js +246 -0
- package/dist/extensions/permission-set.d.ts +117 -0
- package/dist/extensions/permission-set.js +184 -0
- package/dist/extensions/permission-view.d.ts +194 -0
- package/dist/extensions/permission-view.js +284 -0
- package/dist/extensions/registry.d.ts +24 -0
- package/dist/extensions/registry.js +56 -0
- package/dist/extensions/resolve.d.ts +12 -0
- package/dist/extensions/resolve.js +71 -0
- package/dist/extensions/sources.d.ts +69 -0
- package/dist/extensions/sources.js +120 -0
- package/dist/extensions/sync.d.ts +40 -0
- package/dist/extensions/sync.js +242 -0
- package/dist/files/previewers.controller.d.ts +46 -0
- package/dist/files/previewers.controller.js +105 -0
- package/dist/files/previewers.d.ts +100 -0
- package/dist/files/previewers.js +250 -0
- package/dist/http/api.module.d.ts +114 -0
- package/dist/http/api.module.js +448 -0
- package/dist/http/app.d.ts +77 -0
- package/dist/http/app.js +220 -0
- package/dist/http/error.filter.d.ts +21 -0
- package/dist/http/error.filter.js +85 -0
- package/dist/http/gateway.module.d.ts +15 -0
- package/dist/http/gateway.module.js +13 -0
- package/dist/http/health.controller.d.ts +26 -0
- package/dist/http/health.controller.js +79 -0
- package/dist/http/nest-logger.d.ts +20 -0
- package/dist/http/nest-logger.js +28 -0
- package/dist/http/plugin-dispatch.d.ts +68 -0
- package/dist/http/plugin-dispatch.js +200 -0
- package/dist/http/tokens.d.ts +131 -0
- package/dist/http/tokens.js +131 -0
- package/dist/http/zod.pipe.d.ts +8 -0
- package/dist/http/zod.pipe.js +14 -0
- package/dist/identity/accounts.d.ts +93 -0
- package/dist/identity/accounts.js +367 -0
- package/dist/identity/api-tokens.d.ts +73 -0
- package/dist/identity/api-tokens.js +197 -0
- package/dist/identity/audit.d.ts +23 -0
- package/dist/identity/audit.js +41 -0
- package/dist/identity/auth.controller.d.ts +40 -0
- package/dist/identity/auth.controller.js +130 -0
- package/dist/identity/auth.guard.d.ts +41 -0
- package/dist/identity/auth.guard.js +162 -0
- package/dist/identity/binding.d.ts +47 -0
- package/dist/identity/binding.js +84 -0
- package/dist/identity/cookies.d.ts +16 -0
- package/dist/identity/cookies.js +32 -0
- package/dist/identity/credential-check.d.ts +17 -0
- package/dist/identity/credential-check.js +24 -0
- package/dist/identity/enterprise-admin.d.ts +14 -0
- package/dist/identity/enterprise-admin.js +27 -0
- package/dist/identity/external.d.ts +106 -0
- package/dist/identity/external.js +337 -0
- package/dist/identity/hash.d.ts +2 -0
- package/dist/identity/hash.js +3 -0
- package/dist/identity/login.d.ts +6 -0
- package/dist/identity/login.js +20 -0
- package/dist/identity/me.controller.d.ts +61 -0
- package/dist/identity/me.controller.js +159 -0
- package/dist/identity/passwords.d.ts +6 -0
- package/dist/identity/passwords.js +37 -0
- package/dist/identity/principal.d.ts +56 -0
- package/dist/identity/principal.js +38 -0
- package/dist/identity/rate-limit.d.ts +55 -0
- package/dist/identity/rate-limit.js +121 -0
- package/dist/identity/sessions.d.ts +84 -0
- package/dist/identity/sessions.js +306 -0
- package/dist/identity/settings.d.ts +121 -0
- package/dist/identity/settings.js +248 -0
- package/dist/identity/sso.controller.d.ts +59 -0
- package/dist/identity/sso.controller.js +192 -0
- package/dist/identity/sso.d.ts +83 -0
- package/dist/identity/sso.js +202 -0
- package/dist/inbox/inbox.service.d.ts +43 -0
- package/dist/inbox/inbox.service.js +57 -0
- package/dist/index.d.ts +69 -0
- package/dist/index.js +67 -0
- package/dist/kernel.d.ts +259 -0
- package/dist/kernel.js +1326 -0
- package/dist/log-config.d.ts +9 -0
- package/dist/log-config.js +27 -0
- package/dist/log-context.d.ts +32 -0
- package/dist/log-context.js +40 -0
- package/dist/log-loki.d.ts +34 -0
- package/dist/log-loki.js +145 -0
- package/dist/log.d.ts +79 -0
- package/dist/log.js +303 -0
- package/dist/models/prices.d.ts +53 -0
- package/dist/models/prices.js +121 -0
- package/dist/models/purposes.controller.d.ts +19 -0
- package/dist/models/purposes.controller.js +56 -0
- package/dist/models/purposes.d.ts +140 -0
- package/dist/models/purposes.js +267 -0
- package/dist/net/proxy.d.ts +44 -0
- package/dist/net/proxy.js +162 -0
- package/dist/net/public-address.d.ts +60 -0
- package/dist/net/public-address.js +272 -0
- package/dist/net/safe-fetch.d.ts +38 -0
- package/dist/net/safe-fetch.js +140 -0
- package/dist/orgs/directory-sync.controller.d.ts +14 -0
- package/dist/orgs/directory-sync.controller.js +40 -0
- package/dist/orgs/directory-sync.d.ts +166 -0
- package/dist/orgs/directory-sync.js +558 -0
- package/dist/orgs/invitations.controller.d.ts +58 -0
- package/dist/orgs/invitations.controller.js +137 -0
- package/dist/orgs/invitations.service.d.ts +80 -0
- package/dist/orgs/invitations.service.js +217 -0
- package/dist/orgs/members.service.d.ts +63 -0
- package/dist/orgs/members.service.js +234 -0
- package/dist/orgs/offboarding.d.ts +141 -0
- package/dist/orgs/offboarding.js +398 -0
- package/dist/orgs/org-lock.d.ts +32 -0
- package/dist/orgs/org-lock.js +46 -0
- package/dist/orgs/org.guard.d.ts +35 -0
- package/dist/orgs/org.guard.js +95 -0
- package/dist/orgs/orgs.controller.d.ts +78 -0
- package/dist/orgs/orgs.controller.js +192 -0
- package/dist/orgs/orgs.service.d.ts +61 -0
- package/dist/orgs/orgs.service.js +209 -0
- package/dist/orgs/roles.d.ts +13 -0
- package/dist/orgs/roles.js +58 -0
- package/dist/orgs/settings.controller.d.ts +20 -0
- package/dist/orgs/settings.controller.js +53 -0
- package/dist/orgs/settings.service.d.ts +120 -0
- package/dist/orgs/settings.service.js +178 -0
- package/dist/packages/npm.d.ts +50 -0
- package/dist/packages/npm.js +218 -0
- package/dist/packages/provenance.d.ts +47 -0
- package/dist/packages/provenance.js +147 -0
- package/dist/packages/tgz.d.ts +76 -0
- package/dist/packages/tgz.js +225 -0
- package/dist/runtime/abort.d.ts +32 -0
- package/dist/runtime/abort.js +71 -0
- package/dist/runtime/checkpointer.d.ts +32 -0
- package/dist/runtime/checkpointer.js +243 -0
- package/dist/runtime/context/build.d.ts +254 -0
- package/dist/runtime/context/build.js +693 -0
- package/dist/runtime/context/claude-tools.d.ts +11 -0
- package/dist/runtime/context/claude-tools.js +24 -0
- package/dist/runtime/context/compaction.d.ts +26 -0
- package/dist/runtime/context/compaction.js +195 -0
- package/dist/runtime/context/pairing.d.ts +11 -0
- package/dist/runtime/context/pairing.js +82 -0
- package/dist/runtime/context/reminders.d.ts +5 -0
- package/dist/runtime/context/reminders.js +11 -0
- package/dist/runtime/context/skills.d.ts +105 -0
- package/dist/runtime/context/skills.js +283 -0
- package/dist/runtime/context/tokens.d.ts +19 -0
- package/dist/runtime/context/tokens.js +104 -0
- package/dist/runtime/conversation-lock.d.ts +40 -0
- package/dist/runtime/conversation-lock.js +97 -0
- package/dist/runtime/hook-calls.d.ts +84 -0
- package/dist/runtime/hook-calls.js +136 -0
- package/dist/runtime/langgraph-loop.d.ts +52 -0
- package/dist/runtime/langgraph-loop.js +247 -0
- package/dist/runtime/loop.d.ts +93 -0
- package/dist/runtime/loop.js +7 -0
- package/dist/runtime/maintenance.d.ts +80 -0
- package/dist/runtime/maintenance.js +148 -0
- package/dist/runtime/media-cache.d.ts +21 -0
- package/dist/runtime/media-cache.js +51 -0
- package/dist/runtime/model-call.d.ts +176 -0
- package/dist/runtime/model-call.js +1049 -0
- package/dist/runtime/providers.d.ts +86 -0
- package/dist/runtime/providers.js +224 -0
- package/dist/runtime/quota.d.ts +29 -0
- package/dist/runtime/quota.js +70 -0
- package/dist/runtime/run-finish.d.ts +45 -0
- package/dist/runtime/run-finish.js +69 -0
- package/dist/runtime/run-queue.d.ts +121 -0
- package/dist/runtime/run-queue.js +493 -0
- package/dist/runtime/run-worker.d.ts +138 -0
- package/dist/runtime/run-worker.js +806 -0
- package/dist/runtime/stream.controller.d.ts +34 -0
- package/dist/runtime/stream.controller.js +122 -0
- package/dist/runtime/stream.d.ts +63 -0
- package/dist/runtime/stream.js +262 -0
- package/dist/runtime/subagents/child.d.ts +80 -0
- package/dist/runtime/subagents/child.js +225 -0
- package/dist/runtime/subagents/definition.d.ts +103 -0
- package/dist/runtime/subagents/definition.js +392 -0
- package/dist/runtime/subagents/dispatch.d.ts +69 -0
- package/dist/runtime/subagents/dispatch.js +502 -0
- package/dist/runtime/subagents/limits.d.ts +23 -0
- package/dist/runtime/subagents/limits.js +34 -0
- package/dist/runtime/subagents/org-agents.d.ts +50 -0
- package/dist/runtime/subagents/org-agents.js +70 -0
- package/dist/runtime/subagents/preamble.d.ts +7 -0
- package/dist/runtime/subagents/preamble.js +11 -0
- package/dist/runtime/subagents/progress.d.ts +26 -0
- package/dist/runtime/subagents/progress.js +36 -0
- package/dist/runtime/subagents/roster.d.ts +55 -0
- package/dist/runtime/subagents/roster.js +111 -0
- package/dist/runtime/subagents/skill-fork.d.ts +123 -0
- package/dist/runtime/subagents/skill-fork.js +259 -0
- package/dist/runtime/usage-report.d.ts +163 -0
- package/dist/runtime/usage-report.js +551 -0
- package/dist/runtime/waits.d.ts +233 -0
- package/dist/runtime/waits.js +883 -0
- package/dist/sandbox/leases.d.ts +169 -0
- package/dist/sandbox/leases.js +515 -0
- package/dist/sandbox/lifecycle.d.ts +21 -0
- package/dist/sandbox/lifecycle.js +68 -0
- package/dist/sandbox/sandbox.service.d.ts +249 -0
- package/dist/sandbox/sandbox.service.js +908 -0
- package/dist/skills/catalog.d.ts +149 -0
- package/dist/skills/catalog.js +405 -0
- package/dist/skills/changes.controller.d.ts +56 -0
- package/dist/skills/changes.controller.js +136 -0
- package/dist/skills/changes.service.d.ts +175 -0
- package/dist/skills/changes.service.js +805 -0
- package/dist/skills/invocable.controller.d.ts +23 -0
- package/dist/skills/invocable.controller.js +50 -0
- package/dist/skills/invocation-keys.d.ts +23 -0
- package/dist/skills/invocation-keys.js +44 -0
- package/dist/skills/invoke.d.ts +135 -0
- package/dist/skills/invoke.js +286 -0
- package/dist/skills/package.d.ts +87 -0
- package/dist/skills/package.js +227 -0
- package/dist/skills/skills.controller.d.ts +40 -0
- package/dist/skills/skills.controller.js +110 -0
- package/dist/skills/skills.service.d.ts +192 -0
- package/dist/skills/skills.service.js +567 -0
- package/dist/storage/prefix.d.ts +36 -0
- package/dist/storage/prefix.js +104 -0
- package/dist/storage/purge.d.ts +27 -0
- package/dist/storage/purge.js +75 -0
- package/dist/storage/storage.service.d.ts +44 -0
- package/dist/storage/storage.service.js +145 -0
- package/dist/text.d.ts +13 -0
- package/dist/text.js +13 -0
- package/dist/tools/approvals.controller.d.ts +53 -0
- package/dist/tools/approvals.controller.js +128 -0
- package/dist/tools/approvals.service.d.ts +172 -0
- package/dist/tools/approvals.service.js +568 -0
- package/dist/tools/breaker.d.ts +28 -0
- package/dist/tools/breaker.js +72 -0
- package/dist/tools/builtins/agent.d.ts +81 -0
- package/dist/tools/builtins/agent.js +223 -0
- package/dist/tools/builtins/ask-user.d.ts +28 -0
- package/dist/tools/builtins/ask-user.js +139 -0
- package/dist/tools/builtins/read-tool-output.d.ts +18 -0
- package/dist/tools/builtins/read-tool-output.js +108 -0
- package/dist/tools/builtins/sandbox/bash.d.ts +16 -0
- package/dist/tools/builtins/sandbox/bash.js +137 -0
- package/dist/tools/builtins/sandbox/common.d.ts +116 -0
- package/dist/tools/builtins/sandbox/common.js +306 -0
- package/dist/tools/builtins/sandbox/deliver.d.ts +5 -0
- package/dist/tools/builtins/sandbox/deliver.js +180 -0
- package/dist/tools/builtins/sandbox/edit.d.ts +4 -0
- package/dist/tools/builtins/sandbox/edit.js +98 -0
- package/dist/tools/builtins/sandbox/glob-match.d.ts +25 -0
- package/dist/tools/builtins/sandbox/glob-match.js +240 -0
- package/dist/tools/builtins/sandbox/glob.d.ts +4 -0
- package/dist/tools/builtins/sandbox/glob.js +104 -0
- package/dist/tools/builtins/sandbox/grep.d.ts +9 -0
- package/dist/tools/builtins/sandbox/grep.js +133 -0
- package/dist/tools/builtins/sandbox/index.d.ts +12 -0
- package/dist/tools/builtins/sandbox/index.js +27 -0
- package/dist/tools/builtins/sandbox/names.d.ts +7 -0
- package/dist/tools/builtins/sandbox/names.js +20 -0
- package/dist/tools/builtins/sandbox/read.d.ts +8 -0
- package/dist/tools/builtins/sandbox/read.js +121 -0
- package/dist/tools/builtins/sandbox/write.d.ts +4 -0
- package/dist/tools/builtins/sandbox/write.js +88 -0
- package/dist/tools/builtins/skill-load.d.ts +53 -0
- package/dist/tools/builtins/skill-load.js +446 -0
- package/dist/tools/builtins/skill-write.d.ts +59 -0
- package/dist/tools/builtins/skill-write.js +244 -0
- package/dist/tools/builtins/tool-search.d.ts +31 -0
- package/dist/tools/builtins/tool-search.js +171 -0
- package/dist/tools/connector-content.controller.d.ts +34 -0
- package/dist/tools/connector-content.controller.js +78 -0
- package/dist/tools/connector-content.d.ts +104 -0
- package/dist/tools/connector-content.js +267 -0
- package/dist/tools/connectors.controller.d.ts +210 -0
- package/dist/tools/connectors.controller.js +234 -0
- package/dist/tools/connectors.service.d.ts +303 -0
- package/dist/tools/connectors.service.js +1102 -0
- package/dist/tools/credentials.d.ts +139 -0
- package/dist/tools/credentials.js +351 -0
- package/dist/tools/drift.d.ts +141 -0
- package/dist/tools/drift.js +539 -0
- package/dist/tools/elicitation.d.ts +81 -0
- package/dist/tools/elicitation.js +266 -0
- package/dist/tools/endpoint.d.ts +18 -0
- package/dist/tools/endpoint.js +115 -0
- package/dist/tools/info.d.ts +67 -0
- package/dist/tools/info.js +113 -0
- package/dist/tools/naming.d.ts +27 -0
- package/dist/tools/naming.js +47 -0
- package/dist/tools/oauth/discovery.d.ts +65 -0
- package/dist/tools/oauth/discovery.js +307 -0
- package/dist/tools/oauth/flow.d.ts +63 -0
- package/dist/tools/oauth/flow.js +237 -0
- package/dist/tools/oauth/oauth.controller.d.ts +31 -0
- package/dist/tools/oauth/oauth.controller.js +95 -0
- package/dist/tools/oauth/tokens.d.ts +111 -0
- package/dist/tools/oauth/tokens.js +258 -0
- package/dist/tools/outputs.d.ts +61 -0
- package/dist/tools/outputs.js +156 -0
- package/dist/tools/pipeline.d.ts +322 -0
- package/dist/tools/pipeline.js +1236 -0
- package/dist/tools/policy.d.ts +60 -0
- package/dist/tools/policy.js +236 -0
- package/dist/tools/questions.controller.d.ts +24 -0
- package/dist/tools/questions.controller.js +58 -0
- package/dist/tools/questions.service.d.ts +103 -0
- package/dist/tools/questions.service.js +295 -0
- package/dist/tools/redact.d.ts +20 -0
- package/dist/tools/redact.js +60 -0
- package/dist/tools/registry.d.ts +246 -0
- package/dist/tools/registry.js +481 -0
- package/dist/tools/resources.d.ts +16 -0
- package/dist/tools/resources.js +76 -0
- package/dist/tools/specs.d.ts +14 -0
- package/dist/tools/specs.js +31 -0
- package/dist/tools/validate.d.ts +20 -0
- package/dist/tools/validate.js +183 -0
- package/dist/tools/view.d.ts +43 -0
- package/dist/tools/view.js +225 -0
- package/dist/ui/embed-token.d.ts +31 -0
- package/dist/ui/embed-token.js +132 -0
- package/dist/ui/registry.d.ts +58 -0
- package/dist/ui/registry.js +90 -0
- package/dist/ui/ui-stream.d.ts +37 -0
- package/dist/ui/ui-stream.js +162 -0
- package/dist/ui/views.controller.d.ts +81 -0
- package/dist/ui/views.controller.js +261 -0
- package/dist/ui/views.d.ts +155 -0
- package/dist/ui/views.js +306 -0
- package/dist/version.d.ts +5 -0
- package/dist/version.js +6 -0
- package/package.json +69 -3
- package/src/migrations/0001_init.sql +8 -0
- package/src/migrations/0002_secrets.sql +8 -0
- package/src/migrations/0003_identity.sql +117 -0
- package/src/migrations/0004_plugin_org_config_nullable.sql +3 -0
- package/src/migrations/0005_agents.sql +27 -0
- package/src/migrations/0006_conversations.sql +37 -0
- package/src/migrations/0007_checkpoints.sql +26 -0
- package/src/migrations/0008_runs_trigger_seq.sql +3 -0
- package/src/migrations/0009_runs_active_unique.sql +4 -0
- package/src/migrations/0010_tools.sql +125 -0
- package/src/migrations/0011_approvals_spec.sql +10 -0
- package/src/migrations/0012_run_waits.sql +24 -0
- package/src/migrations/0013_app_tools_source.sql +4 -0
- package/src/migrations/0014_tool_specs.sql +8 -0
- package/src/migrations/0015_tool_drift.sql +20 -0
- package/src/migrations/0016_plugin_permissions.sql +11 -0
- package/src/migrations/0017_identity_sources.sql +6 -0
- package/src/migrations/0018_channels.sql +74 -0
- package/src/migrations/0019_identity_trust.sql +17 -0
- package/src/migrations/0020_channel_card_lookup.sql +10 -0
- package/src/migrations/0021_org_storage_purge.sql +9 -0
- package/src/migrations/0022_attachments.sql +29 -0
- package/src/migrations/0023_sandboxes.sql +37 -0
- package/src/migrations/0024_skills.sql +46 -0
- package/src/migrations/0025_skills_catalog_idx.sql +6 -0
- package/src/migrations/0026_skill_changes.sql +34 -0
- package/src/migrations/0027_model_prices.sql +18 -0
- package/src/migrations/0028_evals.sql +105 -0
- package/src/migrations/0029_model_purposes.sql +18 -0
- package/src/migrations/0030_plugin_installs.sql +73 -0
- package/src/migrations/0031_plugin_snapshot_source.sql +6 -0
- package/src/migrations/0032_plugin_deployment_configs.sql +10 -0
- package/src/migrations/0033_rename_apps_to_connectors.sql +25 -0
- package/src/migrations/0034_directory.sql +49 -0
- package/src/migrations/0035_catalogs.sql +40 -0
- package/src/migrations/0036_app_import_staging.sql +17 -0
- package/src/migrations/0037_directory_installs.sql +92 -0
- package/src/migrations/0038_channel_inbound_mode.sql +6 -0
- package/src/migrations/0039_channel_card_pending.sql +8 -0
- package/src/migrations/0040_usage_report_sweep.sql +10 -0
- package/src/migrations/0041_rename_plugins_to_extensions.sql +38 -0
- package/src/migrations/0042_rename_directory_to_catalog.sql +80 -0
- package/src/migrations/0043_rename_app_installs_to_plugin_installs.sql +20 -0
- package/src/migrations/0044_catalog_one_kind.sql +90 -0
- package/src/migrations/0045_plugin_dependencies.sql +9 -0
- package/src/migrations/0046_git_sources.sql +25 -0
- package/src/migrations/0047_marketplace_entry_heads.sql +7 -0
- package/src/migrations/0048_marketplace_entry_trees.sql +8 -0
- package/src/migrations/0049_plugin_upgrades.sql +37 -0
- package/src/migrations/0050_bootstrap.sql +53 -0
- package/src/migrations/0051_claude_compat.sql +26 -0
- package/src/migrations/0052_conversations_account_agent_idx.sql +5 -0
- package/src/migrations/0053_subagents.sql +73 -0
- package/src/migrations/0054_subagent_wait_expiry.sql +7 -0
- package/src/migrations/0055_subagent_parent_indexes.sql +10 -0
- package/src/migrations/0056_approval_reason.sql +3 -0
- package/src/migrations/0057_conversation_titles.sql +11 -0
- package/src/migrations/0058_conversation_selection.sql +4 -0
- package/src/migrations/0059_conversation_queue.sql +22 -0
- package/src/migrations/0060_file_previewers.sql +10 -0
- package/src/migrations/0061_queue_selection.sql +5 -0
- package/src/migrations/0062_queued_skill.sql +8 -0
|
@@ -0,0 +1,133 @@
|
|
|
1
|
+
import { ToolError } from "@capybara-hq/plugin-sdk";
|
|
2
|
+
import { checkPath, clip, display, inSandbox, SYNC_MARKER, sandboxBaseTimeoutMs, searchTimeoutMs, shellQuote, unavailableWhenNoSandbox, withNotices, } from "./common.js";
|
|
3
|
+
/** 最多返回的匹配行数。 */
|
|
4
|
+
const MAX_MATCHES = 500;
|
|
5
|
+
/** 每个匹配行最多显示的字符数。 */
|
|
6
|
+
const MAX_LINE_CHARS = 500;
|
|
7
|
+
/** grep 输出的上限(字节)。 */
|
|
8
|
+
const MAX_GREP_BYTES = 4 * 1024 * 1024;
|
|
9
|
+
const SPEC = {
|
|
10
|
+
name: "sandbox_grep",
|
|
11
|
+
// Display only (the tool row; not in the fingerprint, never sent to the model).
|
|
12
|
+
keyArgs: ["pattern", "path"],
|
|
13
|
+
description: "Search file contents in this conversation's sandbox with a regular expression (POSIX " +
|
|
14
|
+
"extended, as grep -E). Use it to find where something is defined or mentioned. Searches path " +
|
|
15
|
+
"(a file, or a directory recursively; default /workspace), skipping binary files; glob limits " +
|
|
16
|
+
'the files searched by name, e.g. "*.py". Returns matching lines as <path>:<line>:<text>, up ' +
|
|
17
|
+
"to 500. To find files by name, use sandbox_glob.",
|
|
18
|
+
inputSchema: {
|
|
19
|
+
type: "object",
|
|
20
|
+
properties: {
|
|
21
|
+
pattern: {
|
|
22
|
+
type: "string",
|
|
23
|
+
minLength: 1,
|
|
24
|
+
description: 'Regular expression (POSIX extended), e.g. "def [a-z_]+\\(" or "TODO".',
|
|
25
|
+
},
|
|
26
|
+
path: {
|
|
27
|
+
type: "string",
|
|
28
|
+
minLength: 1,
|
|
29
|
+
description: "Absolute file or directory to search. Default /workspace.",
|
|
30
|
+
},
|
|
31
|
+
glob: {
|
|
32
|
+
type: "string",
|
|
33
|
+
minLength: 1,
|
|
34
|
+
description: 'Only search files whose name matches this glob, e.g. "*.md".',
|
|
35
|
+
},
|
|
36
|
+
ignoreCase: { type: "boolean", description: "Case-insensitive match. Default false." },
|
|
37
|
+
},
|
|
38
|
+
required: ["pattern"],
|
|
39
|
+
additionalProperties: false,
|
|
40
|
+
},
|
|
41
|
+
annotations: { readOnlyHint: true },
|
|
42
|
+
};
|
|
43
|
+
const notFound = (path) => `${clip(path, 200)} does not exist; check the path with sandbox_glob.`;
|
|
44
|
+
const failed = (stderr) => `grep failed: ${clip(stderr, 300)}. Check the pattern (POSIX extended regular expression) and retry.`;
|
|
45
|
+
const GREP_TIMEOUT = "The search did not finish in time; pass a narrower path or a glob and retry.";
|
|
46
|
+
/**
|
|
47
|
+
* 解析 `grep -nH --null` 的输出:每条为 `<文件名>\0<行号>:<行>\n`(文件名可能含换行,行本身不含)。
|
|
48
|
+
* 返回 `<绝对路径>:<行号>:<行>`;文件名里的换行显示为 `\n`。最后一条不完整(输出被截断)时丢掉。
|
|
49
|
+
*/
|
|
50
|
+
export function parseGrepNull(stdout, base) {
|
|
51
|
+
const out = [];
|
|
52
|
+
let pos = 0;
|
|
53
|
+
for (;;) {
|
|
54
|
+
const nul = stdout.indexOf("\0", pos);
|
|
55
|
+
if (nul === -1)
|
|
56
|
+
break;
|
|
57
|
+
const nl = stdout.indexOf("\n", nul);
|
|
58
|
+
if (nl === -1)
|
|
59
|
+
break;
|
|
60
|
+
const raw = stdout.slice(pos, nul);
|
|
61
|
+
const name = (raw.startsWith("./") ? raw.slice(2) : raw).replace(/\n/g, "\\n");
|
|
62
|
+
out.push(`${base}/${name}:${stdout.slice(nul + 1, nl)}`);
|
|
63
|
+
pos = nl + 1;
|
|
64
|
+
}
|
|
65
|
+
return out;
|
|
66
|
+
}
|
|
67
|
+
/** 内置工具 `sandbox_grep`:按正则搜文件内容(只读)。 */
|
|
68
|
+
export function sandboxGrepTool(deps) {
|
|
69
|
+
return {
|
|
70
|
+
spec: SPEC,
|
|
71
|
+
defaultPolicy: "allow",
|
|
72
|
+
unavailable: unavailableWhenNoSandbox(deps),
|
|
73
|
+
timeoutMs: () => sandboxBaseTimeoutMs(deps.config()),
|
|
74
|
+
async run(input, ctx) {
|
|
75
|
+
const startedAt = Date.now();
|
|
76
|
+
const { pattern, glob, ignoreCase = false } = input;
|
|
77
|
+
const path = checkPath(input.path ?? "/workspace");
|
|
78
|
+
const { value, notices } = await inSandbox(deps, ctx, async ({ h, p, signal }) => {
|
|
79
|
+
const st = await p.stat(h, path, signal);
|
|
80
|
+
if (st === null)
|
|
81
|
+
throw new ToolError(notFound(path));
|
|
82
|
+
// 在目标所在目录里搜相对路径,输出再拼回绝对路径(命令里不出现沙箱绝对路径)
|
|
83
|
+
const slash = path.lastIndexOf("/");
|
|
84
|
+
const cwd = st.isDir ? path : path.slice(0, slash) || "/";
|
|
85
|
+
const target = st.isDir ? "." : path.slice(slash + 1);
|
|
86
|
+
const command = [
|
|
87
|
+
// --null:文件名后跟 NUL 而不是 `:`,文件名里有换行或冒号也能解析
|
|
88
|
+
"grep -rnHIE --null",
|
|
89
|
+
...(ignoreCase ? ["-i"] : []),
|
|
90
|
+
...(glob !== undefined ? [`--include=${shellQuote(glob)}`] : []),
|
|
91
|
+
"-e",
|
|
92
|
+
shellQuote(pattern),
|
|
93
|
+
"--",
|
|
94
|
+
shellQuote(target),
|
|
95
|
+
].join(" ");
|
|
96
|
+
const r = await p.exec(h, {
|
|
97
|
+
command,
|
|
98
|
+
cwd,
|
|
99
|
+
timeoutMs: searchTimeoutMs(deps.config(), startedAt, Date.now(), ctx.runDeadline),
|
|
100
|
+
maxOutputBytes: MAX_GREP_BYTES,
|
|
101
|
+
signal,
|
|
102
|
+
});
|
|
103
|
+
if (r.timedOut || r.exitCode === null)
|
|
104
|
+
throw new ToolError(GREP_TIMEOUT);
|
|
105
|
+
if (r.exitCode === 1)
|
|
106
|
+
return { lines: [], warning: null };
|
|
107
|
+
const all = parseGrepNull(r.stdout, cwd === "/" ? "" : cwd);
|
|
108
|
+
const lines = all.filter((l) => !l.startsWith(`${SYNC_MARKER}:`));
|
|
109
|
+
// 退出码 2 = 有错误(如个别文件不可读);有输出时照常返回(可能为空:只匹配到隐藏的标记文件)并附上说明
|
|
110
|
+
if (r.exitCode !== 0 && all.length === 0)
|
|
111
|
+
throw new ToolError(failed(r.stderr));
|
|
112
|
+
const warning = r.exitCode !== 0 ? clip(r.stderr, 300) : null;
|
|
113
|
+
return { lines, warning };
|
|
114
|
+
});
|
|
115
|
+
const { lines, warning } = value;
|
|
116
|
+
const shown = lines
|
|
117
|
+
.slice(0, MAX_MATCHES)
|
|
118
|
+
.map((l) => (l.length > MAX_LINE_CHARS ? `${l.slice(0, MAX_LINE_CHARS)}…` : l));
|
|
119
|
+
const note = warning !== null ? `\n[grep also reported errors: ${warning}]` : "";
|
|
120
|
+
const text = (lines.length === 0
|
|
121
|
+
? `No matches for ${pattern} in ${path}.`
|
|
122
|
+
: shown.join("\n") +
|
|
123
|
+
(lines.length > MAX_MATCHES
|
|
124
|
+
? `\n[Showing the first ${MAX_MATCHES} of ${lines.length} matching lines; use a narrower pattern, path or glob.]`
|
|
125
|
+
: "")) + note;
|
|
126
|
+
const n = lines.length;
|
|
127
|
+
return {
|
|
128
|
+
content: [{ type: "text", text: withNotices(notices, text) }],
|
|
129
|
+
display: display(`搜索 ${clip(pattern, 120)}(${n} 处)`, `Searched for ${clip(pattern, 120)} (${n} match${n === 1 ? "" : "es"})`),
|
|
130
|
+
};
|
|
131
|
+
},
|
|
132
|
+
};
|
|
133
|
+
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type { BuiltinTool } from "../../registry.js";
|
|
2
|
+
import type { SandboxToolDeps } from "./common.js";
|
|
3
|
+
export { BASH_SPILL_CHARS, formatExec } from "./bash.js";
|
|
4
|
+
export { assignAttachmentNames, RUN_DEADLINE_MARGIN_MS, runTimeLeftMs, SANDBOX_RECREATED_NOTICE, SANDBOX_SETUP_MARGIN_MS, SANDBOX_STARTED_NOTICE, SANDBOX_UNAVAILABLE_REASON, type SandboxToolDeps, sandboxBaseTimeoutMs, searchTimeoutMs, shellQuote, } from "./common.js";
|
|
5
|
+
export { compileGlob, GlobPatternError, MAX_GLOB_STARS } from "./glob-match.js";
|
|
6
|
+
export { SANDBOX_ASK_TOOL_NAMES, SANDBOX_TOOL_NAMES } from "./names.js";
|
|
7
|
+
/**
|
|
8
|
+
* 沙箱内置工具(M5 T8):bash / read / write / edit / glob / grep / deliver,都在本对话的沙箱上执行
|
|
9
|
+
* (`SandboxService.withSandbox`),执行前同步附件到 `/workspace/attachments`。没有沙箱提供方时报不可用。
|
|
10
|
+
* 默认 allow;组织设置 `sandboxToolPolicy` 为 ask 时除 read / glob / grep 外需要审批(见 policy.ts)。
|
|
11
|
+
*/
|
|
12
|
+
export declare function sandboxTools(deps: SandboxToolDeps): BuiltinTool[];
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { sandboxBashTool } from "./bash.js";
|
|
2
|
+
import { sandboxDeliverTool } from "./deliver.js";
|
|
3
|
+
import { sandboxEditTool } from "./edit.js";
|
|
4
|
+
import { sandboxGlobTool } from "./glob.js";
|
|
5
|
+
import { sandboxGrepTool } from "./grep.js";
|
|
6
|
+
import { sandboxReadTool } from "./read.js";
|
|
7
|
+
import { sandboxWriteTool } from "./write.js";
|
|
8
|
+
export { BASH_SPILL_CHARS, formatExec } from "./bash.js";
|
|
9
|
+
export { assignAttachmentNames, RUN_DEADLINE_MARGIN_MS, runTimeLeftMs, SANDBOX_RECREATED_NOTICE, SANDBOX_SETUP_MARGIN_MS, SANDBOX_STARTED_NOTICE, SANDBOX_UNAVAILABLE_REASON, sandboxBaseTimeoutMs, searchTimeoutMs, shellQuote, } from "./common.js";
|
|
10
|
+
export { compileGlob, GlobPatternError, MAX_GLOB_STARS } from "./glob-match.js";
|
|
11
|
+
export { SANDBOX_ASK_TOOL_NAMES, SANDBOX_TOOL_NAMES } from "./names.js";
|
|
12
|
+
/**
|
|
13
|
+
* 沙箱内置工具(M5 T8):bash / read / write / edit / glob / grep / deliver,都在本对话的沙箱上执行
|
|
14
|
+
* (`SandboxService.withSandbox`),执行前同步附件到 `/workspace/attachments`。没有沙箱提供方时报不可用。
|
|
15
|
+
* 默认 allow;组织设置 `sandboxToolPolicy` 为 ask 时除 read / glob / grep 外需要审批(见 policy.ts)。
|
|
16
|
+
*/
|
|
17
|
+
export function sandboxTools(deps) {
|
|
18
|
+
return [
|
|
19
|
+
sandboxBashTool(deps),
|
|
20
|
+
sandboxReadTool(deps),
|
|
21
|
+
sandboxWriteTool(deps),
|
|
22
|
+
sandboxEditTool(deps),
|
|
23
|
+
sandboxGlobTool(deps),
|
|
24
|
+
sandboxGrepTool(deps),
|
|
25
|
+
sandboxDeliverTool(deps),
|
|
26
|
+
];
|
|
27
|
+
}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 沙箱内置工具的名字(M5 T8,Ruling M12:工具 key 只能含字母数字、`_`、`-`,所以是 `sandbox_<动作>`)。
|
|
3
|
+
* 单独成文件:注册表与策略判定只需要名字,不引入工具实现。
|
|
4
|
+
*/
|
|
5
|
+
export declare const SANDBOX_TOOL_NAMES: readonly ["sandbox_bash", "sandbox_read", "sandbox_write", "sandbox_edit", "sandbox_glob", "sandbox_grep", "sandbox_deliver"];
|
|
6
|
+
/** 组织设置 `sandboxToolPolicy` 为 `ask` 时需要审批的沙箱工具(只读的 read / glob / grep 除外)。 */
|
|
7
|
+
export declare const SANDBOX_ASK_TOOL_NAMES: ReadonlySet<string>;
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 沙箱内置工具的名字(M5 T8,Ruling M12:工具 key 只能含字母数字、`_`、`-`,所以是 `sandbox_<动作>`)。
|
|
3
|
+
* 单独成文件:注册表与策略判定只需要名字,不引入工具实现。
|
|
4
|
+
*/
|
|
5
|
+
export const SANDBOX_TOOL_NAMES = [
|
|
6
|
+
"sandbox_bash",
|
|
7
|
+
"sandbox_read",
|
|
8
|
+
"sandbox_write",
|
|
9
|
+
"sandbox_edit",
|
|
10
|
+
"sandbox_glob",
|
|
11
|
+
"sandbox_grep",
|
|
12
|
+
"sandbox_deliver",
|
|
13
|
+
];
|
|
14
|
+
/** 组织设置 `sandboxToolPolicy` 为 `ask` 时需要审批的沙箱工具(只读的 read / glob / grep 除外)。 */
|
|
15
|
+
export const SANDBOX_ASK_TOOL_NAMES = new Set([
|
|
16
|
+
"sandbox_bash",
|
|
17
|
+
"sandbox_write",
|
|
18
|
+
"sandbox_edit",
|
|
19
|
+
"sandbox_deliver",
|
|
20
|
+
]);
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { BuiltinTool } from "../../registry.js";
|
|
2
|
+
import { type SandboxToolDeps } from "./common.js";
|
|
3
|
+
/** 最多读出的字节数(更大的文件只读开头,并说明用 sandbox_bash 读其余部分)。 */
|
|
4
|
+
export declare const READ_MAX_BYTES: number;
|
|
5
|
+
/** 按行编号显示 `[offset, offset + limit)`(1 起),结尾注明还有多少行。 */
|
|
6
|
+
export declare function numberLines(text: string, offset: number, limit: number): string;
|
|
7
|
+
/** 内置工具 `sandbox_read`:读沙箱里的文本文件(只读,组织策略为 ask 时也不审批)。 */
|
|
8
|
+
export declare function sandboxReadTool(deps: SandboxToolDeps): BuiltinTool;
|
|
@@ -0,0 +1,121 @@
|
|
|
1
|
+
import { ToolError } from "@capybara-hq/plugin-sdk";
|
|
2
|
+
import { viewPath } from "../../view.js";
|
|
3
|
+
import { checkPath, clip, display, inSandbox, looksBinary, sandboxBaseTimeoutMs, unavailableWhenNoSandbox, withNotices, } from "./common.js";
|
|
4
|
+
/** 不给 `limit` 时一次读的行数。 */
|
|
5
|
+
const DEFAULT_LIMIT = 2000;
|
|
6
|
+
/** 单行最多显示的字符数(更长的截断并注明)。 */
|
|
7
|
+
const MAX_LINE_CHARS = 2000;
|
|
8
|
+
/** 最多读出的字节数(更大的文件只读开头,并说明用 sandbox_bash 读其余部分)。 */
|
|
9
|
+
export const READ_MAX_BYTES = 10 * 1024 * 1024;
|
|
10
|
+
const SPEC = {
|
|
11
|
+
name: "sandbox_read",
|
|
12
|
+
// Display only (the tool row; not in the fingerprint, never sent to the model).
|
|
13
|
+
keyArgs: ["path"],
|
|
14
|
+
description: "Read a text file from this conversation's sandbox, with line numbers. Use it to look at " +
|
|
15
|
+
"source code, data files, logs and files the user attached (under /workspace/attachments). " +
|
|
16
|
+
"Paths are absolute, under /workspace, /skills or /tmp. Lines are numbered from 1; pass " +
|
|
17
|
+
"offset and limit to read part of a long file. Binary files are not shown; use sandbox_bash " +
|
|
18
|
+
"to inspect them. Do not use it to list directories; use sandbox_glob instead.",
|
|
19
|
+
inputSchema: {
|
|
20
|
+
type: "object",
|
|
21
|
+
properties: {
|
|
22
|
+
path: {
|
|
23
|
+
type: "string",
|
|
24
|
+
minLength: 1,
|
|
25
|
+
description: 'Absolute path of the file, e.g. "/workspace/src/main.py".',
|
|
26
|
+
},
|
|
27
|
+
offset: {
|
|
28
|
+
type: "integer",
|
|
29
|
+
minimum: 1,
|
|
30
|
+
description: "First line to read (1-based). Default 1.",
|
|
31
|
+
},
|
|
32
|
+
limit: {
|
|
33
|
+
type: "integer",
|
|
34
|
+
minimum: 1,
|
|
35
|
+
description: `Maximum number of lines to read. Default ${DEFAULT_LIMIT}.`,
|
|
36
|
+
},
|
|
37
|
+
},
|
|
38
|
+
required: ["path"],
|
|
39
|
+
additionalProperties: false,
|
|
40
|
+
},
|
|
41
|
+
annotations: { readOnlyHint: true },
|
|
42
|
+
};
|
|
43
|
+
const notFound = (path) => `File not found: ${clip(path, 200)}. Check the path with sandbox_glob.`;
|
|
44
|
+
const isDirectory = (path) => `${clip(path, 200)} is a directory; use sandbox_glob to list its files.`;
|
|
45
|
+
const pastEnd = (offset, total) => `offset ${offset} is past the end of the file (${total} lines); pass an offset of at most ${total}.`;
|
|
46
|
+
/** The file's lines (a final newline does not start another line). */
|
|
47
|
+
function fileLines(text) {
|
|
48
|
+
const lines = text.split("\n");
|
|
49
|
+
if (lines.length > 1 && lines.at(-1) === "")
|
|
50
|
+
lines.pop();
|
|
51
|
+
return lines;
|
|
52
|
+
}
|
|
53
|
+
/** 按行编号显示 `[offset, offset + limit)`(1 起),结尾注明还有多少行。 */
|
|
54
|
+
export function numberLines(text, offset, limit) {
|
|
55
|
+
const lines = fileLines(text);
|
|
56
|
+
const total = lines.length;
|
|
57
|
+
if (offset > total)
|
|
58
|
+
throw new ToolError(pastEnd(offset, total));
|
|
59
|
+
const end = Math.min(total, offset - 1 + limit);
|
|
60
|
+
const out = [];
|
|
61
|
+
for (let i = offset - 1; i < end; i++) {
|
|
62
|
+
const line = lines[i];
|
|
63
|
+
const shown = line.length > MAX_LINE_CHARS
|
|
64
|
+
? `${line.slice(0, MAX_LINE_CHARS)}… [line cut at ${MAX_LINE_CHARS} characters]`
|
|
65
|
+
: line;
|
|
66
|
+
out.push(`${String(i + 1).padStart(6)}\t${shown}`);
|
|
67
|
+
}
|
|
68
|
+
if (end < total) {
|
|
69
|
+
out.push(`[Lines ${offset}–${end} of ${total}; continue with offset=${end + 1}]`);
|
|
70
|
+
}
|
|
71
|
+
return out.join("\n");
|
|
72
|
+
}
|
|
73
|
+
/** 内置工具 `sandbox_read`:读沙箱里的文本文件(只读,组织策略为 ask 时也不审批)。 */
|
|
74
|
+
export function sandboxReadTool(deps) {
|
|
75
|
+
return {
|
|
76
|
+
spec: SPEC,
|
|
77
|
+
defaultPolicy: "allow",
|
|
78
|
+
unavailable: unavailableWhenNoSandbox(deps),
|
|
79
|
+
timeoutMs: () => sandboxBaseTimeoutMs(deps.config()),
|
|
80
|
+
async run(input, ctx) {
|
|
81
|
+
const { offset = 1, limit = DEFAULT_LIMIT } = input;
|
|
82
|
+
const path = checkPath(input.path);
|
|
83
|
+
const { value, notices } = await inSandbox(deps, ctx, async ({ h, p, signal }) => {
|
|
84
|
+
const st = await p.stat(h, path, signal);
|
|
85
|
+
if (st === null)
|
|
86
|
+
throw new ToolError(notFound(path));
|
|
87
|
+
if (st.isDir)
|
|
88
|
+
throw new ToolError(isDirectory(path));
|
|
89
|
+
const got = await p.readFile(h, path, { maxBytes: READ_MAX_BYTES, signal });
|
|
90
|
+
if (got === null)
|
|
91
|
+
throw new ToolError(notFound(path));
|
|
92
|
+
return { ...got, size: st.size };
|
|
93
|
+
});
|
|
94
|
+
let text;
|
|
95
|
+
// display only: the line range shown on the row
|
|
96
|
+
let range = {};
|
|
97
|
+
if (looksBinary(value.data)) {
|
|
98
|
+
text = `Binary file (${value.size} bytes); use sandbox_bash to inspect it (for example file or xxd).`;
|
|
99
|
+
}
|
|
100
|
+
else if (value.data.byteLength === 0) {
|
|
101
|
+
text = "(empty file)";
|
|
102
|
+
}
|
|
103
|
+
else {
|
|
104
|
+
const decoded = new TextDecoder().decode(value.data);
|
|
105
|
+
text = numberLines(decoded, offset, limit);
|
|
106
|
+
range = {
|
|
107
|
+
fromLine: offset,
|
|
108
|
+
toLine: Math.min(fileLines(decoded).length, offset - 1 + limit),
|
|
109
|
+
};
|
|
110
|
+
if (value.truncated) {
|
|
111
|
+
text += `\n[Only the first ${READ_MAX_BYTES} bytes of this ${value.size}-byte file were read; use sandbox_bash (e.g. sed -n or tail) for the rest.]`;
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
return {
|
|
115
|
+
content: [{ type: "text", text: withNotices(notices, text) }],
|
|
116
|
+
display: display(`读取 ${clip(path, 180)}`, `Read ${clip(path, 180)}`),
|
|
117
|
+
view: { kind: "read", path: viewPath(path), ...range },
|
|
118
|
+
};
|
|
119
|
+
},
|
|
120
|
+
};
|
|
121
|
+
}
|
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
import { isSandboxGoneError, ToolError } from "@capybara-hq/plugin-sdk";
|
|
2
|
+
import { lineDiff, TOOL_VIEW_DIFF_MAX_BYTES, viewPath } from "../../view.js";
|
|
3
|
+
import { checkWritable, clip, display, inSandbox, looksBinary, sandboxBaseTimeoutMs, unavailableWhenNoSandbox, withNotices, withPathLease, } from "./common.js";
|
|
4
|
+
const SPEC = {
|
|
5
|
+
name: "sandbox_write",
|
|
6
|
+
// Display only (the tool row; not in the fingerprint, never sent to the model).
|
|
7
|
+
keyArgs: ["path"],
|
|
8
|
+
description: "Write a text file in this conversation's sandbox, creating parent directories as needed. " +
|
|
9
|
+
"Each call replaces the whole file (it is created if missing). Use it to create scripts, " +
|
|
10
|
+
"source files and data files. The path is absolute, under /workspace or /tmp (/skills is " +
|
|
11
|
+
"read-only). To change part of an existing file, use sandbox_edit instead; to give a file to " +
|
|
12
|
+
"the user, use sandbox_deliver.",
|
|
13
|
+
inputSchema: {
|
|
14
|
+
type: "object",
|
|
15
|
+
properties: {
|
|
16
|
+
path: {
|
|
17
|
+
type: "string",
|
|
18
|
+
minLength: 1,
|
|
19
|
+
description: 'Absolute path of the file, e.g. "/workspace/report.md".',
|
|
20
|
+
},
|
|
21
|
+
content: { type: "string", description: "The complete new content of the file." },
|
|
22
|
+
},
|
|
23
|
+
required: ["path", "content"],
|
|
24
|
+
additionalProperties: false,
|
|
25
|
+
},
|
|
26
|
+
};
|
|
27
|
+
/**
|
|
28
|
+
* The most of an existing file read to diff against (display only): the size above which a diff
|
|
29
|
+
* has no hunks anyway. A larger or binary file (a NUL anywhere) is overwritten as usual and the
|
|
30
|
+
* result carries no view.
|
|
31
|
+
*/
|
|
32
|
+
const PREVIOUS_MAX_BYTES = TOOL_VIEW_DIFF_MAX_BYTES;
|
|
33
|
+
const isDirectory = (path) => `${clip(path, 200)} is a directory; pass the path of a file inside it.`;
|
|
34
|
+
/** 内置工具 `sandbox_write`:整文件写入。 */
|
|
35
|
+
export function sandboxWriteTool(deps) {
|
|
36
|
+
return {
|
|
37
|
+
spec: SPEC,
|
|
38
|
+
defaultPolicy: "allow",
|
|
39
|
+
unavailable: unavailableWhenNoSandbox(deps),
|
|
40
|
+
timeoutMs: () => sandboxBaseTimeoutMs(deps.config()),
|
|
41
|
+
async run(input, ctx) {
|
|
42
|
+
const path = checkWritable(input.path);
|
|
43
|
+
const data = new TextEncoder().encode(input.content);
|
|
44
|
+
const { value, notices } = await inSandbox(deps, ctx, ({ h, p, signal }) =>
|
|
45
|
+
// stat, read the previous content, write: one holder at a time per file
|
|
46
|
+
withPathLease(deps, ctx, path, signal, async (signal) => {
|
|
47
|
+
const st = await p.stat(h, path, signal);
|
|
48
|
+
if (st?.isDir)
|
|
49
|
+
throw new ToolError(isDirectory(path));
|
|
50
|
+
// the previous content, for the diff on the row (display only: a failure here never
|
|
51
|
+
// fails the write, the result just carries no view)
|
|
52
|
+
let previous = "";
|
|
53
|
+
if (st !== null) {
|
|
54
|
+
try {
|
|
55
|
+
const got = st.size <= PREVIOUS_MAX_BYTES
|
|
56
|
+
? await p.readFile(h, path, { maxBytes: PREVIOUS_MAX_BYTES, signal })
|
|
57
|
+
: null;
|
|
58
|
+
previous =
|
|
59
|
+
got === null || got.truncated || looksBinary(got.data) || got.data.includes(0)
|
|
60
|
+
? null
|
|
61
|
+
: new TextDecoder().decode(got.data);
|
|
62
|
+
}
|
|
63
|
+
catch (e) {
|
|
64
|
+
if (signal.aborted || isSandboxGoneError(e))
|
|
65
|
+
throw e;
|
|
66
|
+
previous = null;
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
await p.writeFile(h, path, data, signal);
|
|
70
|
+
return { existed: st !== null, previous };
|
|
71
|
+
}));
|
|
72
|
+
const { existed, previous } = value;
|
|
73
|
+
const text = `${existed ? "Overwrote" : "Created"} ${path} (${data.byteLength} bytes).`;
|
|
74
|
+
return {
|
|
75
|
+
content: [{ type: "text", text: withNotices(notices, text) }],
|
|
76
|
+
display: display(`写入 ${clip(path, 180)}`, `Wrote ${clip(path, 180)}`),
|
|
77
|
+
...(previous !== null && {
|
|
78
|
+
view: {
|
|
79
|
+
kind: "edit",
|
|
80
|
+
path: viewPath(path),
|
|
81
|
+
created: !existed,
|
|
82
|
+
...lineDiff(previous, input.content),
|
|
83
|
+
},
|
|
84
|
+
}),
|
|
85
|
+
};
|
|
86
|
+
},
|
|
87
|
+
};
|
|
88
|
+
}
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
import { type ObjectStore } from "@capybara-hq/plugin-sdk";
|
|
2
|
+
import type { EventLog } from "../../conversations/event-log.js";
|
|
3
|
+
import type { KernelDb, SkillManifest } from "../../db/kernel-schema.js";
|
|
4
|
+
import { type CatalogSkill } from "../../runtime/context/skills.js";
|
|
5
|
+
import type { BuiltinCallContext, BuiltinTool } from "../registry.js";
|
|
6
|
+
import { type SandboxToolDeps } from "./sandbox/common.js";
|
|
7
|
+
/**
|
|
8
|
+
* 内置工具 `skill_load`(M5 T14,Ruling M17):按日志里最新一份技能目录快照把名字解析为 id 与版本,返回该版本
|
|
9
|
+
* SKILL.md 的正文与文件清单(结果里写明版本)。技能带其他文件时把整个技能复制进本对话沙箱的 `/skills/<name>/`
|
|
10
|
+
* (提供方以 root 写,命令用户只读);没有沙箱提供方时只给正文,并说明脚本不可用。
|
|
11
|
+
*
|
|
12
|
+
* - 存储里读出的每个文件都按清单的 sha256 核对,不符即拒绝(不把被替换的内容给模型或放进沙箱)。
|
|
13
|
+
* - 复制记录在内核控制的标记文件(每个技能一个,{@link skillMarkerPath}:`/skills/.capybara/<name>.json`,
|
|
14
|
+
* 命令用户改不了):`{ id, version, prefix, files, stale }`。新建 / 重建的沙箱、版本或来源前缀变化、同名换了技能时
|
|
15
|
+
* 重新复制,否则跳过。
|
|
16
|
+
* - agent 没有任何沙箱工具时不创建沙箱、不复制(模型也跑不了脚本),只给正文并说明。
|
|
17
|
+
* - 可执行位:提供方写的文件一律不可执行(0644)。不扩展 `sandbox@1` 的 `writeFile`,而是在结果里告诉模型用解释器
|
|
18
|
+
* 运行(`sh` / `python3` / `node`):契约与两个提供方不变,技能包里的 shebang 脚本照样能跑,代价只是不能 `./x`。
|
|
19
|
+
* - 旧版本多出的文件:`sandbox@1` 没有删除原语,命令用户也删不了 `/skills` 下的文件,所以新版本原地覆盖,
|
|
20
|
+
* 旧版本独有的文件留在原处、记进标记的 `stale`,每次加载都在结果里列出「不属于当前版本、忽略它们」。
|
|
21
|
+
*/
|
|
22
|
+
/**
|
|
23
|
+
* 已复制进沙箱的技能的标记目录(内核控制:`/skills` 只有提供方以 root 能写;技能名不以 `.` 开头,不会撞名)。
|
|
24
|
+
*/
|
|
25
|
+
export declare const SKILLS_MARKER_DIR = "/skills/.capybara";
|
|
26
|
+
/** 一个技能的标记文件。 */
|
|
27
|
+
export declare const skillMarkerPath: (name: string) => string;
|
|
28
|
+
/** 依赖:沙箱工具的依赖,加上读技能行用的库与读快照用的日志。 */
|
|
29
|
+
export interface SkillLoadDeps extends SandboxToolDeps {
|
|
30
|
+
db: KernelDb;
|
|
31
|
+
eventLog: Pick<EventLog, "append" | "latestOfType">;
|
|
32
|
+
}
|
|
33
|
+
/** A stored skill file is missing or does not match its manifest entry (size, sha256). */
|
|
34
|
+
export declare class SkillIntegrityError extends Error {
|
|
35
|
+
}
|
|
36
|
+
/**
|
|
37
|
+
* Reads one skill file and checks it against its manifest entry (size and sha256). A missing or
|
|
38
|
+
* mismatching object throws {@link SkillIntegrityError}; a storage error is rethrown as is
|
|
39
|
+
* (`storage.unavailable` from the store). Shared with a person's skill invocation (phase D).
|
|
40
|
+
*/
|
|
41
|
+
export declare function readSkillFile(store: ObjectStore, key: string, file: SkillManifest["files"][number], signal?: AbortSignal): Promise<Uint8Array>;
|
|
42
|
+
/**
|
|
43
|
+
* 目录条目对应的内容,按条目的 `source`(对象前缀,T15)精确解析:先找该技能前缀相同的已生成版本(技能未删除;
|
|
44
|
+
* 批准时草稿前缀原样成为版本前缀,版本号变了也能找到),再找本对话发起、仍待批准、前缀相同的技能改动(试用草稿:
|
|
45
|
+
* 没有 `skill_versions` 行,新技能连 `skills` 行都没有)。绝不按版本号解析——被拒绝的草稿与之后别人批准的同号版本
|
|
46
|
+
* 内容不同。都没有 → undefined(已移除)。
|
|
47
|
+
*/
|
|
48
|
+
export declare function findSkillVersion(db: KernelDb, ctx: Pick<BuiltinCallContext, "orgId" | "conversationId">, entry: Pick<CatalogSkill, "id" | "source">): Promise<{
|
|
49
|
+
manifest: SkillManifest;
|
|
50
|
+
object_prefix: string;
|
|
51
|
+
} | undefined>;
|
|
52
|
+
/** 内置工具 `skill_load`(见文件头)。 */
|
|
53
|
+
export declare function skillLoadTool(deps: SkillLoadDeps): BuiltinTool;
|