@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,243 @@
|
|
|
1
|
+
import { BaseCheckpointSaver, compareWritesSortKeys, copyCheckpoint, getCheckpointId, maxChannelVersion, TASKS, WRITES_IDX_MAP, writesSortKey, } from "@langchain/langgraph-checkpoint";
|
|
2
|
+
import { sql } from "kysely";
|
|
3
|
+
const CHECKPOINT_COLUMNS = [
|
|
4
|
+
"thread_id",
|
|
5
|
+
"checkpoint_ns",
|
|
6
|
+
"checkpoint_id",
|
|
7
|
+
"parent_checkpoint_id",
|
|
8
|
+
"checkpoint_type",
|
|
9
|
+
"checkpoint",
|
|
10
|
+
"metadata_type",
|
|
11
|
+
"metadata",
|
|
12
|
+
];
|
|
13
|
+
/** checkpoint_id(uuid6)按字节序比较,不受数据库排序规则影响。 */
|
|
14
|
+
const idC = sql `checkpoint_id collate "C"`;
|
|
15
|
+
/**
|
|
16
|
+
* LangGraph checkpoint saver,存在内核 schema 的 `lg_checkpoints` / `lg_checkpoint_writes` 里(0007_checkpoints.sql)。
|
|
17
|
+
*
|
|
18
|
+
* - 每个 checkpoint 存整份(含全部 channel_values),不按 channel 增量存,所以 {@link pruneToLatest}
|
|
19
|
+
* 之后最新一份仍能独立还原。不要配合实验性的 `DeltaChannel` 使用:它依赖父链上的 writes 还原状态。
|
|
20
|
+
* - thread_id 约定为 runId。
|
|
21
|
+
* - 所有状态都在 PG 里,不持有进程内状态,任意副本都能续跑。
|
|
22
|
+
*/
|
|
23
|
+
export class KyselyCheckpointSaver extends BaseCheckpointSaver {
|
|
24
|
+
db;
|
|
25
|
+
constructor(db) {
|
|
26
|
+
super();
|
|
27
|
+
this.db = db;
|
|
28
|
+
}
|
|
29
|
+
async getTuple(config) {
|
|
30
|
+
const threadId = config.configurable?.thread_id;
|
|
31
|
+
if (threadId === undefined)
|
|
32
|
+
return undefined;
|
|
33
|
+
const ns = config.configurable?.checkpoint_ns ?? "";
|
|
34
|
+
const checkpointId = getCheckpointId(config);
|
|
35
|
+
let q = this.db
|
|
36
|
+
.selectFrom("lg_checkpoints")
|
|
37
|
+
.select(CHECKPOINT_COLUMNS)
|
|
38
|
+
.where("thread_id", "=", threadId)
|
|
39
|
+
.where("checkpoint_ns", "=", ns);
|
|
40
|
+
q = checkpointId
|
|
41
|
+
? q.where("checkpoint_id", "=", checkpointId)
|
|
42
|
+
: q.orderBy(sql `${idC} desc`).limit(1);
|
|
43
|
+
const row = await q.executeTakeFirst();
|
|
44
|
+
return row ? this.toTuple(row) : undefined;
|
|
45
|
+
}
|
|
46
|
+
async *list(config, options) {
|
|
47
|
+
const { before, filter } = options ?? {};
|
|
48
|
+
let { limit } = options ?? {};
|
|
49
|
+
const threadId = config.configurable?.thread_id;
|
|
50
|
+
const ns = config.configurable?.checkpoint_ns;
|
|
51
|
+
const checkpointId = config.configurable?.checkpoint_id;
|
|
52
|
+
const beforeId = before?.configurable?.checkpoint_id;
|
|
53
|
+
const filterEntries = Object.entries(filter ?? {});
|
|
54
|
+
let q = this.db.selectFrom("lg_checkpoints").select(CHECKPOINT_COLUMNS);
|
|
55
|
+
if (threadId !== undefined)
|
|
56
|
+
q = q.where("thread_id", "=", threadId);
|
|
57
|
+
if (ns !== undefined)
|
|
58
|
+
q = q.where("checkpoint_ns", "=", ns);
|
|
59
|
+
if (checkpointId)
|
|
60
|
+
q = q.where("checkpoint_id", "=", checkpointId);
|
|
61
|
+
if (beforeId)
|
|
62
|
+
q = q.where(idC, "<", beforeId);
|
|
63
|
+
q = q.orderBy(sql `${idC} desc`).orderBy("thread_id").orderBy("checkpoint_ns");
|
|
64
|
+
// metadata 是序列化字节,过滤只能在读出后做;没有过滤条件时 limit 下推到 SQL。
|
|
65
|
+
if (limit !== undefined && filterEntries.length === 0)
|
|
66
|
+
q = q.limit(Math.max(limit, 0));
|
|
67
|
+
const rows = await q.execute();
|
|
68
|
+
for (const row of rows) {
|
|
69
|
+
if (limit !== undefined && limit <= 0)
|
|
70
|
+
return;
|
|
71
|
+
const metadata = (await this.serde.loadsTyped(row.metadata_type, row.metadata));
|
|
72
|
+
if (!filterEntries.every(([k, v]) => metadata[k] === v))
|
|
73
|
+
continue;
|
|
74
|
+
if (limit !== undefined)
|
|
75
|
+
limit -= 1;
|
|
76
|
+
yield this.toTuple(row, metadata);
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
async put(config, checkpoint, metadata, _newVersions) {
|
|
80
|
+
const threadId = config.configurable?.thread_id;
|
|
81
|
+
if (threadId === undefined) {
|
|
82
|
+
throw new Error('Failed to put checkpoint: config.configurable is missing the required "thread_id" field.');
|
|
83
|
+
}
|
|
84
|
+
const ns = config.configurable?.checkpoint_ns ?? "";
|
|
85
|
+
const parentId = config.configurable?.checkpoint_id ?? null;
|
|
86
|
+
const [[checkpointType, checkpointBytes], [metadataType, metadataBytes]] = await Promise.all([
|
|
87
|
+
this.serde.dumpsTyped(copyCheckpoint(checkpoint)),
|
|
88
|
+
this.serde.dumpsTyped(metadata),
|
|
89
|
+
]);
|
|
90
|
+
const values = {
|
|
91
|
+
parent_checkpoint_id: parentId,
|
|
92
|
+
checkpoint_type: checkpointType,
|
|
93
|
+
checkpoint: Buffer.from(checkpointBytes),
|
|
94
|
+
metadata_type: metadataType,
|
|
95
|
+
metadata: Buffer.from(metadataBytes),
|
|
96
|
+
};
|
|
97
|
+
await this.db
|
|
98
|
+
.insertInto("lg_checkpoints")
|
|
99
|
+
.values({ thread_id: threadId, checkpoint_ns: ns, checkpoint_id: checkpoint.id, ...values })
|
|
100
|
+
.onConflict((oc) => oc.columns(["thread_id", "checkpoint_ns", "checkpoint_id"]).doUpdateSet(values))
|
|
101
|
+
.execute();
|
|
102
|
+
return {
|
|
103
|
+
configurable: { thread_id: threadId, checkpoint_ns: ns, checkpoint_id: checkpoint.id },
|
|
104
|
+
};
|
|
105
|
+
}
|
|
106
|
+
async putWrites(config, writes, taskId, taskPath) {
|
|
107
|
+
const threadId = config.configurable?.thread_id;
|
|
108
|
+
const checkpointId = config.configurable?.checkpoint_id;
|
|
109
|
+
if (threadId === undefined) {
|
|
110
|
+
throw new Error('Failed to put writes: config.configurable is missing the required "thread_id" field.');
|
|
111
|
+
}
|
|
112
|
+
if (checkpointId === undefined) {
|
|
113
|
+
throw new Error('Failed to put writes: config.configurable is missing the required "checkpoint_id" field.');
|
|
114
|
+
}
|
|
115
|
+
const ns = config.configurable?.checkpoint_ns ?? "";
|
|
116
|
+
const rows = await Promise.all(writes.map(async ([channel, value], i) => {
|
|
117
|
+
const [valueType, bytes] = await this.serde.dumpsTyped(value);
|
|
118
|
+
return {
|
|
119
|
+
thread_id: threadId,
|
|
120
|
+
checkpoint_ns: ns,
|
|
121
|
+
checkpoint_id: checkpointId,
|
|
122
|
+
task_id: taskId,
|
|
123
|
+
idx: WRITES_IDX_MAP[channel] ?? i,
|
|
124
|
+
channel,
|
|
125
|
+
value_type: valueType,
|
|
126
|
+
value: Buffer.from(bytes),
|
|
127
|
+
task_path: taskPath ?? "",
|
|
128
|
+
};
|
|
129
|
+
}));
|
|
130
|
+
// 特殊 channel(错误、中断等,idx < 0)以最后一次为准;普通 write 已存在则保留先写入的。
|
|
131
|
+
const special = rows.filter((r) => r.idx < 0);
|
|
132
|
+
const regular = rows.filter((r) => r.idx >= 0);
|
|
133
|
+
const key = ["thread_id", "checkpoint_ns", "checkpoint_id", "task_id", "idx"];
|
|
134
|
+
await this.db.transaction().execute(async (trx) => {
|
|
135
|
+
if (regular.length > 0) {
|
|
136
|
+
await trx
|
|
137
|
+
.insertInto("lg_checkpoint_writes")
|
|
138
|
+
.values(regular)
|
|
139
|
+
.onConflict((oc) => oc.columns(key).doNothing())
|
|
140
|
+
.execute();
|
|
141
|
+
}
|
|
142
|
+
if (special.length > 0) {
|
|
143
|
+
await trx
|
|
144
|
+
.insertInto("lg_checkpoint_writes")
|
|
145
|
+
.values(special)
|
|
146
|
+
.onConflict((oc) => oc.columns(key).doUpdateSet((eb) => ({
|
|
147
|
+
channel: eb.ref("excluded.channel"),
|
|
148
|
+
value_type: eb.ref("excluded.value_type"),
|
|
149
|
+
value: eb.ref("excluded.value"),
|
|
150
|
+
task_path: eb.ref("excluded.task_path"),
|
|
151
|
+
})))
|
|
152
|
+
.execute();
|
|
153
|
+
}
|
|
154
|
+
});
|
|
155
|
+
}
|
|
156
|
+
async deleteThread(threadId) {
|
|
157
|
+
await this.db.transaction().execute(async (trx) => {
|
|
158
|
+
await trx.deleteFrom("lg_checkpoint_writes").where("thread_id", "=", threadId).execute();
|
|
159
|
+
await trx.deleteFrom("lg_checkpoints").where("thread_id", "=", threadId).execute();
|
|
160
|
+
});
|
|
161
|
+
}
|
|
162
|
+
/**
|
|
163
|
+
* 一轮运行结束后调用:根命名空间(`checkpoint_ns = ''`)下只保留最新一个 checkpoint 及其 writes,
|
|
164
|
+
* 更早的 checkpoint 与它们的 writes 删除。只删 checkpoint_id **小于**最新的(按字节序):
|
|
165
|
+
* 读出最新与删除之间并发写入的更新 checkpoint 不会被误删(R20)。返回删除的 checkpoint 条数。其他命名空间(子图)不动。
|
|
166
|
+
* 保留下来的 checkpoint 的 parent_checkpoint_id 原样保留(父 checkpoint 已不存在)。
|
|
167
|
+
*/
|
|
168
|
+
async pruneToLatest(threadId) {
|
|
169
|
+
return this.db.transaction().execute(async (trx) => {
|
|
170
|
+
const latest = await trx
|
|
171
|
+
.selectFrom("lg_checkpoints")
|
|
172
|
+
.select("checkpoint_id")
|
|
173
|
+
.where("thread_id", "=", threadId)
|
|
174
|
+
.where("checkpoint_ns", "=", "")
|
|
175
|
+
.orderBy(sql `${idC} desc`)
|
|
176
|
+
.limit(1)
|
|
177
|
+
.executeTakeFirst();
|
|
178
|
+
if (!latest)
|
|
179
|
+
return 0;
|
|
180
|
+
await trx
|
|
181
|
+
.deleteFrom("lg_checkpoint_writes")
|
|
182
|
+
.where("thread_id", "=", threadId)
|
|
183
|
+
.where("checkpoint_ns", "=", "")
|
|
184
|
+
.where(idC, "<", latest.checkpoint_id)
|
|
185
|
+
.execute();
|
|
186
|
+
const res = await trx
|
|
187
|
+
.deleteFrom("lg_checkpoints")
|
|
188
|
+
.where("thread_id", "=", threadId)
|
|
189
|
+
.where("checkpoint_ns", "=", "")
|
|
190
|
+
.where(idC, "<", latest.checkpoint_id)
|
|
191
|
+
.executeTakeFirst();
|
|
192
|
+
return Number(res.numDeletedRows);
|
|
193
|
+
});
|
|
194
|
+
}
|
|
195
|
+
async toTuple(row, metadata) {
|
|
196
|
+
const { thread_id, checkpoint_ns, checkpoint_id, parent_checkpoint_id } = row;
|
|
197
|
+
const checkpoint = (await this.serde.loadsTyped(row.checkpoint_type, row.checkpoint));
|
|
198
|
+
if (checkpoint.v < 4 && parent_checkpoint_id !== null) {
|
|
199
|
+
await this.migratePendingSends(checkpoint, thread_id, checkpoint_ns, parent_checkpoint_id);
|
|
200
|
+
}
|
|
201
|
+
const tuple = {
|
|
202
|
+
config: { configurable: { thread_id, checkpoint_ns, checkpoint_id } },
|
|
203
|
+
checkpoint,
|
|
204
|
+
metadata: metadata ??
|
|
205
|
+
(await this.serde.loadsTyped(row.metadata_type, row.metadata)),
|
|
206
|
+
pendingWrites: (await this.loadWrites(thread_id, checkpoint_ns, checkpoint_id)).map((w) => [w.taskId, w.channel, w.value]),
|
|
207
|
+
};
|
|
208
|
+
if (parent_checkpoint_id !== null) {
|
|
209
|
+
tuple.parentConfig = {
|
|
210
|
+
configurable: { thread_id, checkpoint_ns, checkpoint_id: parent_checkpoint_id },
|
|
211
|
+
};
|
|
212
|
+
}
|
|
213
|
+
return tuple;
|
|
214
|
+
}
|
|
215
|
+
/** 某个 checkpoint 的 writes,按 `writesSortKey`(task_path, task_id, idx)排序。 */
|
|
216
|
+
async loadWrites(threadId, ns, checkpointId) {
|
|
217
|
+
const rows = await this.db
|
|
218
|
+
.selectFrom("lg_checkpoint_writes")
|
|
219
|
+
.select(["task_id", "idx", "channel", "value_type", "value", "task_path"])
|
|
220
|
+
.where("thread_id", "=", threadId)
|
|
221
|
+
.where("checkpoint_ns", "=", ns)
|
|
222
|
+
.where("checkpoint_id", "=", checkpointId)
|
|
223
|
+
.execute();
|
|
224
|
+
rows.sort((a, b) => compareWritesSortKeys(writesSortKey(a.task_path, a.task_id, a.idx), writesSortKey(b.task_path, b.task_id, b.idx)));
|
|
225
|
+
return Promise.all(rows.map(async (r) => ({
|
|
226
|
+
taskId: r.task_id,
|
|
227
|
+
channel: r.channel,
|
|
228
|
+
value: await this.serde.loadsTyped(r.value_type, r.value),
|
|
229
|
+
})));
|
|
230
|
+
}
|
|
231
|
+
/** v < 4 的旧 checkpoint:把父 checkpoint 上的 TASKS writes 迁成本 checkpoint 的 TASKS channel(同 MemorySaver)。 */
|
|
232
|
+
async migratePendingSends(checkpoint, threadId, ns, parentId) {
|
|
233
|
+
const sends = (await this.loadWrites(threadId, ns, parentId))
|
|
234
|
+
.filter((w) => w.channel === TASKS)
|
|
235
|
+
.map((w) => w.value);
|
|
236
|
+
checkpoint.channel_values ??= {};
|
|
237
|
+
checkpoint.channel_values[TASKS] = sends;
|
|
238
|
+
checkpoint.channel_versions ??= {};
|
|
239
|
+
const versions = Object.values(checkpoint.channel_versions);
|
|
240
|
+
checkpoint.channel_versions[TASKS] =
|
|
241
|
+
versions.length > 0 ? maxChannelVersion(...versions) : this.getNextVersion(undefined);
|
|
242
|
+
}
|
|
243
|
+
}
|
|
@@ -0,0 +1,254 @@
|
|
|
1
|
+
import { type ContentBlock, type ModelInfo, type ModelRequest, type ParamValue } from "@capybara-hq/plugin-sdk";
|
|
2
|
+
import type { AgentDefinition } from "../../agents/definition.js";
|
|
3
|
+
import type { ConversationEvent, EventPayload } from "../../conversations/events.js";
|
|
4
|
+
import type { ResolvedTool } from "../../tools/registry.js";
|
|
5
|
+
/**
|
|
6
|
+
* 平台行为规范(模型可见,英文)。短而通用(spec 6 原则 5);不放时间戳、会话 ID 等会变化的内容,
|
|
7
|
+
* 保证同一 agent 版本在所有会话中 system 前缀一致、可命中提示词缓存。改动它会让所有缓存失效。
|
|
8
|
+
*/
|
|
9
|
+
export declare const BEHAVIOR_RULES: string;
|
|
10
|
+
/** 一次模型请求的来源(与 `model_call` 事件的 `request` 字段相同):凭它可从日志还原请求。 */
|
|
11
|
+
export interface ModelCallMeta {
|
|
12
|
+
/** 参与构建的事件 seq 下界(含):有摘要时为 `coversUpToSeq + 1`。 */
|
|
13
|
+
fromSeq: number;
|
|
14
|
+
/** 参与构建的事件 seq 上界(含)。 */
|
|
15
|
+
toSeq: number;
|
|
16
|
+
/** 使用的 `compaction_summary` 事件 seq;没有摘要为 null。 */
|
|
17
|
+
summarySeq: number | null;
|
|
18
|
+
/** system 文本的 sha256(hex)。 */
|
|
19
|
+
systemHash: string;
|
|
20
|
+
/** 被放进请求的 `reminder` 事件 seq。 */
|
|
21
|
+
reminderSeqs: number[];
|
|
22
|
+
/** 构建时的 `absorbedUpToSeq`(见 {@link BuildModelRequestInput});未提供则没有该字段。 */
|
|
23
|
+
absorbedUpToSeq?: number;
|
|
24
|
+
/** 请求的模型参数(即 `ModelRequest.params`)。 */
|
|
25
|
+
params: Record<string, ParamValue>;
|
|
26
|
+
/**
|
|
27
|
+
* 请求带的工具(按发送顺序)及定义指纹;定义本身按指纹存在 `capybara.tool_specs`。
|
|
28
|
+
* 未启用 tool_search 时按 key 排序;启用时见 {@link BuildModelRequestInput.toolSearch}。
|
|
29
|
+
*/
|
|
30
|
+
tools: {
|
|
31
|
+
key: string;
|
|
32
|
+
specHash: string;
|
|
33
|
+
}[];
|
|
34
|
+
/** 启用 tool_search 时 system 第二块目录里的工具(按 key 排序)及定义指纹;未启用没有该字段。 */
|
|
35
|
+
catalog?: {
|
|
36
|
+
key: string;
|
|
37
|
+
specHash: string;
|
|
38
|
+
}[];
|
|
39
|
+
/** 请求的 `toolChoice`(收尾调用为 `"none"`);未设置则没有该字段。 */
|
|
40
|
+
toolChoice?: "auto" | "none";
|
|
41
|
+
/**
|
|
42
|
+
* 请求里每个附件的处理结果(按首次出现,同一附件一条);发了字节的带 finalize 时的 etag。没有媒体则没有该字段。
|
|
43
|
+
*/
|
|
44
|
+
media?: MediaOutcomeEntry[];
|
|
45
|
+
/** 请求里有媒体、且给了有限的预算时:所用的媒体字节预算(还原时重现同样的省略)。 */
|
|
46
|
+
mediaBudgetBytes?: number;
|
|
47
|
+
}
|
|
48
|
+
/** 构建请求用到的工具信息(`ResolvedTool` 的子集)。 */
|
|
49
|
+
export type RequestTool = Pick<ResolvedTool, "key" | "spec" | "specHash">;
|
|
50
|
+
export interface BuildModelRequestInput {
|
|
51
|
+
events: ConversationEvent[];
|
|
52
|
+
agent: AgentDefinition;
|
|
53
|
+
agentVersion: number;
|
|
54
|
+
model: ModelInfo;
|
|
55
|
+
step: number;
|
|
56
|
+
/**
|
|
57
|
+
* loop 已吸收到的 user_message seq(R31)。提供时:
|
|
58
|
+
* - seq 大于它的 user_message 不进请求(运行中途到达、尚未被吸收的插话,由后续步骤吸收或触发下一轮);
|
|
59
|
+
* - 每条 user_message 放在**吸收它的那次模型调用**的位置:日志里第一个 `request.absorbedUpToSeq`
|
|
60
|
+
* 不小于它的 `model_call` 之前(没有该字段的旧 model_call 视为吸收了它之前的全部消息),
|
|
61
|
+
* 本次请求吸收的放在末尾。于是模型看到的历史只追加(插话不会插到已发送的回复之前),
|
|
62
|
+
* 且请求可由日志 + `model_call` 精确还原。
|
|
63
|
+
* 不提供时按 seq 原样回放全部 user_message。
|
|
64
|
+
*/
|
|
65
|
+
absorbedUpToSeq?: number;
|
|
66
|
+
/**
|
|
67
|
+
* 本次请求的模型参数,原样放进 `ModelRequest.params`(不读 agent 定义里的参数):
|
|
68
|
+
* 由 `runModelStep` 按所用模型的声明 sanitize 后传入,并记在 `model_call.request.params`;
|
|
69
|
+
* 还原时传入记录下的值。默认空。
|
|
70
|
+
*/
|
|
71
|
+
params?: Record<string, ParamValue>;
|
|
72
|
+
/**
|
|
73
|
+
* 本步可用的工具(由 `ToolRegistry.forAgent` 在步骤开始时解析)。映射为 `ToolDefinition`
|
|
74
|
+
* (`name` 为模型可见的 key),按 key 排序以保证缓存前缀稳定;key 与指纹记在 `meta.tools`。默认空。
|
|
75
|
+
*/
|
|
76
|
+
tools?: RequestTool[];
|
|
77
|
+
/**
|
|
78
|
+
* 启用 tool_search(spec 5.5,由 `ToolRegistry.forAgent` 判定)。启用且有工具时:
|
|
79
|
+
* - `tools` 只放内置工具(含 `tool_search`,按 key 排序)与**已加载**工具的完整定义;
|
|
80
|
+
* 已加载 = 日志中全部 `tool_result.loadedTools` 的并集(含摘要之前的;不在本步可用工具中的忽略),
|
|
81
|
+
* 按首次加载顺序追加在内置工具之后——新加载只在末尾追加,已发送的工具顺序不变;
|
|
82
|
+
* - 其余工具(不论是否已加载)以目录形式放进 system 第二个块(按 key 排序,打缓存断点),
|
|
83
|
+
* 目录只随可用工具集合变化,不随加载变化,保持 system 前缀稳定。
|
|
84
|
+
* 默认不启用(全部工具按 key 排序直接放完整定义)。
|
|
85
|
+
*/
|
|
86
|
+
toolSearch?: boolean;
|
|
87
|
+
/** 本次请求的 `ModelRequest.toolChoice`;只在有工具时生效(没有工具时请求与 meta 都不带)。 */
|
|
88
|
+
toolChoice?: "auto" | "none";
|
|
89
|
+
/**
|
|
90
|
+
* 日志里媒体引用(`source.kind === "ref"`)对应的附件行(声明大小、PDF 页数):附件 id → 信息;
|
|
91
|
+
* 缺省表示没有行(已删除)→「不再可用」占位。预算({@link planMedia})只按这里的声明大小计算,结果确定。
|
|
92
|
+
*/
|
|
93
|
+
mediaInfo?: ReadonlyMap<string, MediaInfo>;
|
|
94
|
+
/**
|
|
95
|
+
* 引用的字节:附件 id → 字节;null 或缺省表示取不到(对象已不在、内容被替换)。调用方按 {@link planMedia}
|
|
96
|
+
* 的 `fetch` 取好再传入(本函数保持纯函数)。解析规则见 {@link resolveMedia}。
|
|
97
|
+
*/
|
|
98
|
+
media?: ReadonlyMap<string, MediaBytes | null>;
|
|
99
|
+
/** 单次请求里媒体原始字节的预算(见 {@link planMedia});默认不限。 */
|
|
100
|
+
mediaBudgetBytes?: number;
|
|
101
|
+
}
|
|
102
|
+
/** 一个附件的字节。 */
|
|
103
|
+
export interface MediaBytes {
|
|
104
|
+
mediaType: string;
|
|
105
|
+
data: Uint8Array;
|
|
106
|
+
}
|
|
107
|
+
/** 一个附件行的声明信息(finalize 时核对过)。 */
|
|
108
|
+
export interface MediaInfo {
|
|
109
|
+
/** 字节数。 */
|
|
110
|
+
size: number;
|
|
111
|
+
/** PDF 的页数(finalize 时数出);不是 PDF 或数不到为 null。 */
|
|
112
|
+
pages: number | null;
|
|
113
|
+
/** finalize 时记下的对象 etag(记进 `model_call` 的媒体结果,便于核对还原);提供方不给为 null / 缺省。 */
|
|
114
|
+
etag?: string | null;
|
|
115
|
+
}
|
|
116
|
+
/** `text/*` 附件(内联文本与 base64 文档两种方式都一样)的最大字符数(UTF-16 码元,超出截断并注明)。 */
|
|
117
|
+
export declare const TEXT_INLINE_MAX_CHARS = 50000;
|
|
118
|
+
/**
|
|
119
|
+
* `text/*` 附件最多取的字节数:UTF-8 里一个 UTF-16 码元最多 3 字节,取这么多一定够凑满
|
|
120
|
+
* {@link TEXT_INLINE_MAX_CHARS}。更后面的字节不取(按范围读),预算也只按封顶后的大小计。
|
|
121
|
+
*/
|
|
122
|
+
export declare const TEXT_FETCH_MAX_BYTES: number;
|
|
123
|
+
/** 单次请求最多的图片数(常见供应商的上限):只保留最新的,更早的换成占位。 */
|
|
124
|
+
export declare const MAX_IMAGES_PER_REQUEST = 20;
|
|
125
|
+
/** PDF 的最大页数(常见供应商的上限):页数(finalize 时数出)超过它的换成占位。 */
|
|
126
|
+
export declare const MAX_PDF_PAGES = 100;
|
|
127
|
+
/** 一张图片的估算 token 数(固定值,与尺寸无关)。 */
|
|
128
|
+
export declare const IMAGE_TOKENS = 1600;
|
|
129
|
+
/** PDF 每页的估算 token 数。 */
|
|
130
|
+
export declare const PDF_PAGE_TOKENS = 1000;
|
|
131
|
+
/** 数不到页数时,PDF 按每多少字节一页估算。 */
|
|
132
|
+
export declare const PDF_BYTES_PER_PAGE_ESTIMATE: number;
|
|
133
|
+
/** PDF 的估算 token 数:有页数按页数,没有按 `ceil(字节数 / 100 KB)`(最多 {@link MAX_PDF_PAGES} 页)。 */
|
|
134
|
+
export declare function pdfTokens(size: number, pages: number | null): number;
|
|
135
|
+
/** 日志里(按 zod 推导的形状)的内容块。 */
|
|
136
|
+
type LogBlock = EventPayload<"user_message">["content"][number];
|
|
137
|
+
/**
|
|
138
|
+
* 日志里 `media_excluded` 排除的附件(全部事件的并集,不看摘要边界):此后的请求一律换成「被供应商拒绝」占位。
|
|
139
|
+
*/
|
|
140
|
+
export declare function excludedMedia(events: readonly ConversationEvent[]): Set<string>;
|
|
141
|
+
/**
|
|
142
|
+
* 该模型需要的附件 id(去重、按出现顺序),调用方据此查行信息({@link MediaInfo})。
|
|
143
|
+
* 模型不支持的图片 / PDF、被 `media_excluded` 排除的不在其中——只发占位,行与字节都不取。
|
|
144
|
+
*/
|
|
145
|
+
export declare function mediaRefs(events: readonly ConversationEvent[], model: ModelInfo): string[];
|
|
146
|
+
/** {@link planMedia} 的结果。 */
|
|
147
|
+
export interface MediaPlan {
|
|
148
|
+
/** 要取字节的附件 id(从新到旧)。 */
|
|
149
|
+
fetch: string[];
|
|
150
|
+
/** 只取开头若干字节的附件(`text/*` 超过 {@link TEXT_FETCH_MAX_BYTES}):id → 字节数。 */
|
|
151
|
+
caps: Map<string, number>;
|
|
152
|
+
/** 为控制请求大小而省略(预算)。 */
|
|
153
|
+
dropped: Set<string>;
|
|
154
|
+
/** 图片超过 {@link MAX_IMAGES_PER_REQUEST} 而省略。 */
|
|
155
|
+
tooManyImages: Set<string>;
|
|
156
|
+
/** PDF 页数超过 {@link MAX_PDF_PAGES}。 */
|
|
157
|
+
tooManyPages: Set<string>;
|
|
158
|
+
/** 日志里 `media_excluded` 排除的。 */
|
|
159
|
+
excluded: Set<string>;
|
|
160
|
+
}
|
|
161
|
+
/**
|
|
162
|
+
* 单次请求的媒体计划(Ruling M6 / M8),只取决于日志、模型能力与行信息,是确定的:
|
|
163
|
+
* - 被 `media_excluded` 排除的:不取、不计;
|
|
164
|
+
* - PDF 页数超过 {@link MAX_PDF_PAGES}:不取、不计;
|
|
165
|
+
* - 从最新的媒体往前:图片最多保留 {@link MAX_IMAGES_PER_REQUEST} 张,更早的图片省略(不影响其他媒体);
|
|
166
|
+
* - 预算:按行里的**声明大小**(`text/*` 按封顶后的大小 `min(size, TEXT_FETCH_MAX_BYTES)`)累计,
|
|
167
|
+
* 第一次超出 `budgetBytes` 起,该附件及更早的全部省略;
|
|
168
|
+
* - 同一附件只算一次(按最后一次出现的位置算新旧);没有行的不计(它们是「不再可用」)。
|
|
169
|
+
*
|
|
170
|
+
* 已知取舍(接受):新的媒体把较早的媒体挤成占位时,请求里**较早位置**的内容随之改变,这一处之后的提示词缓存
|
|
171
|
+
* 失效(不是严格的只追加)。配置保证 `maxBytes ≤ requestMediaBytes`,所以最新的附件总能放进请求。
|
|
172
|
+
*/
|
|
173
|
+
export declare function planMedia(events: readonly ConversationEvent[], model: ModelInfo, info: ReadonlyMap<string, MediaInfo>, budgetBytes?: number): MediaPlan;
|
|
174
|
+
/** 文字占位里的附件名:按 JSON 字符串转义(带引号),名字里的引号、括号不会打乱占位。 */
|
|
175
|
+
export declare const quoted: (name: string) => string;
|
|
176
|
+
/** 附件不可用时的占位(模型可见,英文)。 */
|
|
177
|
+
export declare const mediaUnavailableText: (name: string) => string;
|
|
178
|
+
/** 为控制单次请求大小而省略的附件(模型可见,英文)。 */
|
|
179
|
+
export declare const mediaOmittedText: (name: string) => string;
|
|
180
|
+
/** 单次请求图片太多而省略的附件(模型可见,英文)。 */
|
|
181
|
+
export declare const mediaTooManyImagesText: (name: string) => string;
|
|
182
|
+
/** PDF 页数超过上限(模型可见,英文)。 */
|
|
183
|
+
export declare const mediaTooManyPagesText: (name: string) => string;
|
|
184
|
+
/** 被供应商拒绝、此后不再发送的附件(模型可见,英文)。 */
|
|
185
|
+
export declare const mediaRejectedText: (name: string) => string;
|
|
186
|
+
/** {@link resolveMedia} 的输入:行信息、字节与本次请求的媒体计划。 */
|
|
187
|
+
export interface MediaContext {
|
|
188
|
+
info: ReadonlyMap<string, MediaInfo> | undefined;
|
|
189
|
+
bytes: ReadonlyMap<string, MediaBytes | null> | undefined;
|
|
190
|
+
plan: MediaPlan;
|
|
191
|
+
}
|
|
192
|
+
/** `model_call.request.media` 的一项(形状取自事件 schema)。 */
|
|
193
|
+
export type MediaOutcomeEntry = NonNullable<EventPayload<"model_call">["request"]["media"]>[number];
|
|
194
|
+
/** 一个附件在本次请求里的处理结果。 */
|
|
195
|
+
export type MediaOutcome = MediaOutcomeEntry["outcome"];
|
|
196
|
+
/**
|
|
197
|
+
* 把日志里的媒体引用换成发给模型的内容(不改日志,结果只取决于日志、模型能力、行信息与字节):
|
|
198
|
+
* - 模型不支持(图片看 `vision`,文档看 `documents`):图片 / PDF 换成英文占位,**绝不带字节**;
|
|
199
|
+
* - 被 `media_excluded` 排除 →「被供应商拒绝」占位;没有行 →「不再可用」;PDF 页数过多 →「页数太多」;
|
|
200
|
+
* 图片太多或超出预算 →「省略」;取不到字节 →「不再可用」;字节超过 `MEDIA_LIMITS` →「太大」;
|
|
201
|
+
* - `text/*`:两种方式都封顶为 {@link TEXT_INLINE_MAX_CHARS} 个字符并注明截断——不支持 documents 时内联为文本,
|
|
202
|
+
* 支持时作为 base64 文档(截断时文档内容是截断后的文本加注明);
|
|
203
|
+
* - 其余 → `base64` 块。
|
|
204
|
+
* 插件永远收不到 `ref`。返回块、发出的媒体块的估算 token 数(图片 {@link IMAGE_TOKENS},PDF 见 {@link pdfTokens},
|
|
205
|
+
* 文本文档按发出的字节数 ÷ 3)与每个块的处理结果。
|
|
206
|
+
*/
|
|
207
|
+
export declare function resolveMedia(content: readonly LogBlock[], model: ModelInfo, ctx: MediaContext): {
|
|
208
|
+
blocks: ContentBlock[];
|
|
209
|
+
tokens: number;
|
|
210
|
+
outcomes: {
|
|
211
|
+
attachmentId: string;
|
|
212
|
+
outcome: MediaOutcome;
|
|
213
|
+
}[];
|
|
214
|
+
};
|
|
215
|
+
type SummaryEvent = ConversationEvent & {
|
|
216
|
+
type: "compaction_summary";
|
|
217
|
+
payload: EventPayload<"compaction_summary">;
|
|
218
|
+
};
|
|
219
|
+
/** 最近一条 `compaction_summary` 事件(按 seq);没有则 null。 */
|
|
220
|
+
export declare function latestSummary(events: ConversationEvent[]): SummaryEvent | null;
|
|
221
|
+
/** 摘要作为首条 user 消息时的文本。 */
|
|
222
|
+
export declare function summaryText(summary: string): string;
|
|
223
|
+
/**
|
|
224
|
+
* 由会话事件日志 + agent 定义构建模型请求(纯函数,不做 I/O)。
|
|
225
|
+
* - system:`BEHAVIOR_RULES + "\n\n" + agent.instructions` 一个块,打缓存断点(a sub-agent's log:
|
|
226
|
+
* `BEHAVIOR_RULES`, its preamble and its instructions, all from its `subagent_started`);日志里第一份 `skills_catalog`
|
|
227
|
+
* 快照在任何 `model_call` 之前时,技能目录接在这个块末尾(Ruling M17,见 ./skills.ts);启用 tool_search 时
|
|
228
|
+
* 第二个块是工具目录(见 {@link BuildModelRequestInput.toolSearch});
|
|
229
|
+
* - 之后的 `skills_catalog` 在所在位置渲染为 system 变更提醒;被压缩摘要覆盖的,若摘要时生效的目录与 system 里的
|
|
230
|
+
* 不同,紧随摘要补一条完整的当前目录;
|
|
231
|
+
* - messages:最近一条摘要(若有)作为首条 user 消息,其后按 seq 回放 `coversUpToSeq` 之后的
|
|
232
|
+
* `user_message` / `assistant_message`(content 原样,含 opaque;aborted 的也回放;媒体引用按
|
|
233
|
+
* {@link resolveMedia} 换成 base64 或文字占位)/ `reminder`
|
|
234
|
+
* (`role: "system"`,放在它所在的位置);`tool_result` 事件还原为紧随其 assistant 消息之后的一条 user 消息
|
|
235
|
+
* (同一步的多个结果合并,按该 assistant 消息里 tool_call 的顺序;找不到对应调用的结果不进请求)。
|
|
236
|
+
* 其他事件不进请求。提供 `absorbedUpToSeq` 时,
|
|
237
|
+
* 尚未被吸收的 user_message 不进请求,运行中途到达的插话放在吸收它的调用处(见 BuildModelRequestInput)。
|
|
238
|
+
* 只追加:新事件只会在 messages 末尾追加;唯一的前缀变化来自新的压缩摘要。
|
|
239
|
+
* `step` 与 `agentVersion` 不进请求内容(保证缓存前缀稳定),由调用方写入 `model_call` 事件。
|
|
240
|
+
*/
|
|
241
|
+
export declare function buildModelRequest(input: BuildModelRequestInput): {
|
|
242
|
+
request: ModelRequest;
|
|
243
|
+
meta: ModelCallMeta;
|
|
244
|
+
/** 请求里媒体块(base64 的图片 / 文档)的估算 token 数,传给 `estimateTokens`。 */
|
|
245
|
+
mediaTokens: number;
|
|
246
|
+
};
|
|
247
|
+
/**
|
|
248
|
+
* 日志里 `tool_search` 加载过的工具 key(全部 `tool_result.loadedTools` 的并集,按首次出现顺序)。
|
|
249
|
+
* 不看压缩摘要的边界:加载过的工具在摘要之后仍保持加载(模型可能凭摘要继续使用它们,且已发送的工具列表只追加)。
|
|
250
|
+
*/
|
|
251
|
+
export declare function loadedToolKeys(events: readonly ConversationEvent[]): string[];
|
|
252
|
+
/** system 各块文本的 sha256(hex);按 JSON 数组哈希,避免块边界歧义。 */
|
|
253
|
+
export declare function hashSystem(system: ModelRequest["system"]): string;
|
|
254
|
+
export {};
|