@alumbwe/anvil 1.0.20 → 1.0.21
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/package.json +6 -2
- package/src/agents/bundled-agents.generated.ts +4 -4
- package/src/chat.tsx +1703 -1698
- package/src/cli-args.ts +134 -134
- package/src/components/status-bar.tsx +331 -313
- package/src/hooks/helpers/send-message.ts +663 -654
- package/src/hooks/use-send-message.ts +806 -773
- package/src/index.tsx +473 -473
- package/src/state/chat-store.ts +553 -544
- package/src/utils/create-run-config.ts +121 -121
- package/src/utils/format-compact-number.ts +37 -0
- package/vendor/@anvil/common/package.json +27 -0
- package/vendor/@anvil/common/src/__tests__/agent-validation.test.ts +846 -0
- package/vendor/@anvil/common/src/__tests__/anvil-model-availability.test.ts +101 -0
- package/vendor/@anvil/common/src/__tests__/anvil-models.test.ts +1408 -0
- package/vendor/@anvil/common/src/__tests__/anvil-public-data-use-copy.test.ts +258 -0
- package/vendor/@anvil/common/src/__tests__/anvil-referral-tiers.test.ts +48 -0
- package/vendor/@anvil/common/src/__tests__/anvil-spend-ceilings.test.ts +282 -0
- package/vendor/@anvil/common/src/__tests__/anvil-trust.test.ts +526 -0
- package/vendor/@anvil/common/src/__tests__/deepseek-direct.test.ts +68 -0
- package/vendor/@anvil/common/src/__tests__/disposable-email.test.ts +132 -0
- package/vendor/@anvil/common/src/__tests__/dynamic-agent-template-schema.test.ts +422 -0
- package/vendor/@anvil/common/src/__tests__/env-ci.test.ts +167 -0
- package/vendor/@anvil/common/src/__tests__/env-process.test.ts +145 -0
- package/vendor/@anvil/common/src/__tests__/foreign-client-shipped-agents.test.ts +234 -0
- package/vendor/@anvil/common/src/__tests__/foreign-client-signals.test.ts +379 -0
- package/vendor/@anvil/common/src/__tests__/free-agents.test.ts +807 -0
- package/vendor/@anvil/common/src/__tests__/gravity-capi.test.ts +154 -0
- package/vendor/@anvil/common/src/__tests__/handlesteps-parsing.test.ts +246 -0
- package/vendor/@anvil/common/src/__tests__/kimi-k3-god-only.test.ts +77 -0
- package/vendor/@anvil/common/src/__tests__/model-config.test.ts +89 -0
- package/vendor/@anvil/common/src/__tests__/project-file-tree.test.ts +298 -0
- package/vendor/@anvil/common/src/__tests__/provisioned-model-tiers.test.ts +116 -0
- package/vendor/@anvil/common/src/__tests__/reasoning-effort.test.ts +167 -0
- package/vendor/@anvil/common/src/__tests__/reddit-capi.test.ts +132 -0
- package/vendor/@anvil/common/src/__tests__/response-ad-positions.test.ts +72 -0
- package/vendor/@anvil/common/src/__tests__/user-state.test.ts +30 -0
- package/vendor/@anvil/common/src/actions.ts +215 -0
- package/vendor/@anvil/common/src/analytics-core.ts +69 -0
- package/vendor/@anvil/common/src/analytics.ts +93 -0
- package/vendor/@anvil/common/src/api-keys/constants.ts +26 -0
- package/vendor/@anvil/common/src/browser-actions.ts +413 -0
- package/vendor/@anvil/common/src/constants/__tests__/anvil-onboarding-gate.test.ts +63 -0
- package/vendor/@anvil/common/src/constants/__tests__/anvil-onboarding.test.ts +246 -0
- package/vendor/@anvil/common/src/constants/__tests__/cf-worker-signals.test.ts +106 -0
- package/vendor/@anvil/common/src/constants/agents.ts +99 -0
- package/vendor/@anvil/common/src/constants/analytics-events.ts +435 -0
- package/vendor/@anvil/common/src/constants/anthropic.ts +73 -0
- package/vendor/@anvil/common/src/constants/anvil-data-use.ts +81 -0
- package/vendor/@anvil/common/src/constants/anvil-errors.ts +7 -0
- package/vendor/@anvil/common/src/constants/anvil-gemini-thinker.ts +21 -0
- package/vendor/@anvil/common/src/constants/anvil-model-ids.ts +11 -0
- package/vendor/@anvil/common/src/constants/anvil-models.ts +2130 -0
- package/vendor/@anvil/common/src/constants/anvil-onboarding-gate.ts +55 -0
- package/vendor/@anvil/common/src/constants/anvil-onboarding.ts +307 -0
- package/vendor/@anvil/common/src/constants/anvil-referral-tiers.ts +87 -0
- package/vendor/@anvil/common/src/constants/anvil-signup-block.ts +68 -0
- package/vendor/@anvil/common/src/constants/anvil-spend-ceilings.ts +450 -0
- package/vendor/@anvil/common/src/constants/anvil-trust.ts +976 -0
- package/vendor/@anvil/common/src/constants/auth.ts +18 -0
- package/vendor/@anvil/common/src/constants/byok.ts +2 -0
- package/vendor/@anvil/common/src/constants/cf-worker-signals.ts +132 -0
- package/vendor/@anvil/common/src/constants/composio.ts +34 -0
- package/vendor/@anvil/common/src/constants/deepseek-direct.ts +55 -0
- package/vendor/@anvil/common/src/constants/feedback.ts +13 -0
- package/vendor/@anvil/common/src/constants/foreign-client-signals.ts +272 -0
- package/vendor/@anvil/common/src/constants/free-agents.ts +777 -0
- package/vendor/@anvil/common/src/constants/gemini.ts +15 -0
- package/vendor/@anvil/common/src/constants/grant-priorities.ts +13 -0
- package/vendor/@anvil/common/src/constants/hosts.ts +6 -0
- package/vendor/@anvil/common/src/constants/images.ts +51 -0
- package/vendor/@anvil/common/src/constants/index.ts +7 -0
- package/vendor/@anvil/common/src/constants/knowledge.ts +35 -0
- package/vendor/@anvil/common/src/constants/limits.ts +23 -0
- package/vendor/@anvil/common/src/constants/model-config.ts +277 -0
- package/vendor/@anvil/common/src/constants/openrouter-attribution.ts +8 -0
- package/vendor/@anvil/common/src/constants/paths.ts +69 -0
- package/vendor/@anvil/common/src/constants/provider-routes.ts +317 -0
- package/vendor/@anvil/common/src/constants/reasoning-effort.ts +79 -0
- package/vendor/@anvil/common/src/constants/skills.ts +60 -0
- package/vendor/@anvil/common/src/constants/subscription-plans.ts +49 -0
- package/vendor/@anvil/common/src/constants/ui.ts +25 -0
- package/vendor/@anvil/common/src/env-ci.ts +36 -0
- package/vendor/@anvil/common/src/env-process.ts +95 -0
- package/vendor/@anvil/common/src/env-schema.ts +95 -0
- package/vendor/@anvil/common/src/env.ts +24 -0
- package/vendor/@anvil/common/src/gravity-capi.ts +207 -0
- package/vendor/@anvil/common/src/mcp/client.ts +233 -0
- package/vendor/@anvil/common/src/old-constants.ts +10 -0
- package/vendor/@anvil/common/src/project-file-tree.ts +355 -0
- package/vendor/@anvil/common/src/reddit-capi.ts +254 -0
- package/vendor/@anvil/common/src/schemas/feedback.ts +52 -0
- package/vendor/@anvil/common/src/schemas/logs.ts +66 -0
- package/vendor/@anvil/common/src/templates/agent-validation.ts +392 -0
- package/vendor/@anvil/common/src/templates/initial-agents-dir/LICENSE +202 -0
- package/vendor/@anvil/common/src/templates/initial-agents-dir/README.md +294 -0
- package/vendor/@anvil/common/src/templates/initial-agents-dir/examples/01-basic-diff-reviewer.ts +17 -0
- package/vendor/@anvil/common/src/templates/initial-agents-dir/examples/02-intermediate-git-committer.ts +78 -0
- package/vendor/@anvil/common/src/templates/initial-agents-dir/examples/03-advanced-file-explorer.ts +73 -0
- package/vendor/@anvil/common/src/templates/initial-agents-dir/my-custom-agent.ts +40 -0
- package/vendor/@anvil/common/src/templates/initial-agents-dir/package.json +6 -0
- package/vendor/@anvil/common/src/templates/initial-agents-dir/skills/README.md +65 -0
- package/vendor/@anvil/common/src/templates/initial-agents-dir/skills/example-skill/SKILL.md +29 -0
- package/vendor/@anvil/common/src/templates/initial-agents-dir/types/agent-definition.ts +497 -0
- package/vendor/@anvil/common/src/templates/initial-agents-dir/types/tools.ts +444 -0
- package/vendor/@anvil/common/src/templates/initial-agents-dir/types/util-types.ts +178 -0
- package/vendor/@anvil/common/src/testing/TESTING_PATTERNS.md +351 -0
- package/vendor/@anvil/common/src/testing/anvil-offer-invariants.ts +169 -0
- package/vendor/@anvil/common/src/testing/errors.ts +33 -0
- package/vendor/@anvil/common/src/testing/fixtures/agent-runtime.ts +334 -0
- package/vendor/@anvil/common/src/testing/impl/agent-runtime.ts +6 -0
- package/vendor/@anvil/common/src/testing/index.ts +84 -0
- package/vendor/@anvil/common/src/testing/mock-modules.ts +53 -0
- package/vendor/@anvil/common/src/testing/mock-types.ts +123 -0
- package/vendor/@anvil/common/src/testing/mocks/analytics.ts +261 -0
- package/vendor/@anvil/common/src/testing/mocks/child-process.ts +93 -0
- package/vendor/@anvil/common/src/testing/mocks/crypto.ts +218 -0
- package/vendor/@anvil/common/src/testing/mocks/database.ts +337 -0
- package/vendor/@anvil/common/src/testing/mocks/fetch.ts +219 -0
- package/vendor/@anvil/common/src/testing/mocks/filesystem.ts +166 -0
- package/vendor/@anvil/common/src/testing/mocks/index.ts +101 -0
- package/vendor/@anvil/common/src/testing/mocks/logger.ts +135 -0
- package/vendor/@anvil/common/src/testing/mocks/stream.ts +313 -0
- package/vendor/@anvil/common/src/testing/mocks/timers.ts +132 -0
- package/vendor/@anvil/common/src/testing/mocks/tree-sitter.ts +127 -0
- package/vendor/@anvil/common/src/testing/setup.ts +282 -0
- package/vendor/@anvil/common/src/testing-env-ci.ts +15 -0
- package/vendor/@anvil/common/src/testing-env-process.ts +78 -0
- package/vendor/@anvil/common/src/tools/__tests__/compile-tool-definitions.test.ts +34 -0
- package/vendor/@anvil/common/src/tools/compile-tool-definitions.ts +157 -0
- package/vendor/@anvil/common/src/tools/constants.ts +117 -0
- package/vendor/@anvil/common/src/tools/list.ts +190 -0
- package/vendor/@anvil/common/src/tools/params/__tests__/coerce-to-array.test.ts +213 -0
- package/vendor/@anvil/common/src/tools/params/__tests__/read-docs.test.ts +47 -0
- package/vendor/@anvil/common/src/tools/params/__tests__/render-ui.test.ts +65 -0
- package/vendor/@anvil/common/src/tools/params/tool/__tests__/run-terminal-command-timeout.test.ts +49 -0
- package/vendor/@anvil/common/src/tools/params/tool/add-message.ts +39 -0
- package/vendor/@anvil/common/src/tools/params/tool/add-subgoal.ts +57 -0
- package/vendor/@anvil/common/src/tools/params/tool/apply-patch.ts +110 -0
- package/vendor/@anvil/common/src/tools/params/tool/ask-user.ts +181 -0
- package/vendor/@anvil/common/src/tools/params/tool/browser-logs.ts +85 -0
- package/vendor/@anvil/common/src/tools/params/tool/cloud-plan-ready.ts +94 -0
- package/vendor/@anvil/common/src/tools/params/tool/code-search.ts +159 -0
- package/vendor/@anvil/common/src/tools/params/tool/composio.ts +131 -0
- package/vendor/@anvil/common/src/tools/params/tool/create-plan.ts +80 -0
- package/vendor/@anvil/common/src/tools/params/tool/end-turn.ts +57 -0
- package/vendor/@anvil/common/src/tools/params/tool/find-files.ts +60 -0
- package/vendor/@anvil/common/src/tools/params/tool/glob.ts +80 -0
- package/vendor/@anvil/common/src/tools/params/tool/gravity-index.ts +93 -0
- package/vendor/@anvil/common/src/tools/params/tool/list-directory.ts +58 -0
- package/vendor/@anvil/common/src/tools/params/tool/lookup-agent-info.ts +37 -0
- package/vendor/@anvil/common/src/tools/params/tool/propose-str-replace.ts +103 -0
- package/vendor/@anvil/common/src/tools/params/tool/propose-write-file.ts +71 -0
- package/vendor/@anvil/common/src/tools/params/tool/read-docs.ts +90 -0
- package/vendor/@anvil/common/src/tools/params/tool/read-files.ts +109 -0
- package/vendor/@anvil/common/src/tools/params/tool/read-subtree.ts +79 -0
- package/vendor/@anvil/common/src/tools/params/tool/read-url.ts +81 -0
- package/vendor/@anvil/common/src/tools/params/tool/render-ui.ts +168 -0
- package/vendor/@anvil/common/src/tools/params/tool/run-file-change-hooks.ts +57 -0
- package/vendor/@anvil/common/src/tools/params/tool/run-terminal-command.ts +211 -0
- package/vendor/@anvil/common/src/tools/params/tool/screenshot.ts +97 -0
- package/vendor/@anvil/common/src/tools/params/tool/set-messages.ts +44 -0
- package/vendor/@anvil/common/src/tools/params/tool/set-output.ts +61 -0
- package/vendor/@anvil/common/src/tools/params/tool/skill.ts +59 -0
- package/vendor/@anvil/common/src/tools/params/tool/spawn-agent-inline.ts +56 -0
- package/vendor/@anvil/common/src/tools/params/tool/spawn-agents.ts +154 -0
- package/vendor/@anvil/common/src/tools/params/tool/str-replace.ts +107 -0
- package/vendor/@anvil/common/src/tools/params/tool/suggest-followups.ts +97 -0
- package/vendor/@anvil/common/src/tools/params/tool/task-completed.ts +61 -0
- package/vendor/@anvil/common/src/tools/params/tool/think-deeply.ts +56 -0
- package/vendor/@anvil/common/src/tools/params/tool/update-subgoal.ts +89 -0
- package/vendor/@anvil/common/src/tools/params/tool/vision-analyze.ts +82 -0
- package/vendor/@anvil/common/src/tools/params/tool/web-search.ts +73 -0
- package/vendor/@anvil/common/src/tools/params/tool/write-file.ts +71 -0
- package/vendor/@anvil/common/src/tools/params/tool/write-todos.ts +67 -0
- package/vendor/@anvil/common/src/tools/params/utils.ts +150 -0
- package/vendor/@anvil/common/src/tools/utils.ts +24 -0
- package/vendor/@anvil/common/src/types/__tests__/dynamic-agent-template.test.ts +20 -0
- package/vendor/@anvil/common/src/types/agent-template.ts +215 -0
- package/vendor/@anvil/common/src/types/anvil-session.ts +535 -0
- package/vendor/@anvil/common/src/types/anvil-streak.ts +6 -0
- package/vendor/@anvil/common/src/types/anvil-usage.ts +64 -0
- package/vendor/@anvil/common/src/types/api/agents/publish.ts +61 -0
- package/vendor/@anvil/common/src/types/bun-test.d.ts +5 -0
- package/vendor/@anvil/common/src/types/contracts/agent-runtime.ts +75 -0
- package/vendor/@anvil/common/src/types/contracts/analytics.ts +9 -0
- package/vendor/@anvil/common/src/types/contracts/bigquery.ts +55 -0
- package/vendor/@anvil/common/src/types/contracts/billing.ts +46 -0
- package/vendor/@anvil/common/src/types/contracts/client.ts +53 -0
- package/vendor/@anvil/common/src/types/contracts/database.ts +112 -0
- package/vendor/@anvil/common/src/types/contracts/env.ts +203 -0
- package/vendor/@anvil/common/src/types/contracts/llm.ts +191 -0
- package/vendor/@anvil/common/src/types/contracts/logger.ts +14 -0
- package/vendor/@anvil/common/src/types/contracts/logs.ts +34 -0
- package/vendor/@anvil/common/src/types/contracts/trace.ts +21 -0
- package/vendor/@anvil/common/src/types/dynamic-agent-template.ts +328 -0
- package/vendor/@anvil/common/src/types/filesystem.ts +10 -0
- package/vendor/@anvil/common/src/types/function-params.ts +33 -0
- package/vendor/@anvil/common/src/types/grant.ts +20 -0
- package/vendor/@anvil/common/src/types/gravity-index.ts +170 -0
- package/vendor/@anvil/common/src/types/json.ts +29 -0
- package/vendor/@anvil/common/src/types/mcp.ts +24 -0
- package/vendor/@anvil/common/src/types/messages/anvil-message.ts +58 -0
- package/vendor/@anvil/common/src/types/messages/content-part.ts +59 -0
- package/vendor/@anvil/common/src/types/messages/data-content.ts +14 -0
- package/vendor/@anvil/common/src/types/messages/provider-metadata.ts +13 -0
- package/vendor/@anvil/common/src/types/organization.ts +118 -0
- package/vendor/@anvil/common/src/types/print-mode.ts +121 -0
- package/vendor/@anvil/common/src/types/publisher.ts +67 -0
- package/vendor/@anvil/common/src/types/session-state.ts +149 -0
- package/vendor/@anvil/common/src/types/skill.ts +86 -0
- package/vendor/@anvil/common/src/types/source.ts +11 -0
- package/vendor/@anvil/common/src/types/spawn.ts +13 -0
- package/vendor/@anvil/common/src/types/subscription.ts +67 -0
- package/vendor/@anvil/common/src/types/usage.ts +16 -0
- package/vendor/@anvil/common/src/types/util.ts +3 -0
- package/vendor/@anvil/common/src/util/__tests__/ad-user-agent.test.ts +26 -0
- package/vendor/@anvil/common/src/util/__tests__/analytics-dispatcher.test.ts +122 -0
- package/vendor/@anvil/common/src/util/__tests__/analytics-log.test.ts +102 -0
- package/vendor/@anvil/common/src/util/__tests__/analytics-sampling.test.ts +143 -0
- package/vendor/@anvil/common/src/util/__tests__/anvil-streak.test.ts +202 -0
- package/vendor/@anvil/common/src/util/__tests__/anvil-usage-summary.test.ts +193 -0
- package/vendor/@anvil/common/src/util/__tests__/axiom-only-log.test.ts +140 -0
- package/vendor/@anvil/common/src/util/__tests__/client-user-agent.test.ts +148 -0
- package/vendor/@anvil/common/src/util/__tests__/engagement-tracker.test.ts +115 -0
- package/vendor/@anvil/common/src/util/__tests__/env-file-path.test.ts +57 -0
- package/vendor/@anvil/common/src/util/__tests__/error-abort.test.ts +774 -0
- package/vendor/@anvil/common/src/util/__tests__/error-api-details.test.ts +206 -0
- package/vendor/@anvil/common/src/util/__tests__/file-read-limits.test.ts +173 -0
- package/vendor/@anvil/common/src/util/__tests__/format-code-search.test.ts +60 -0
- package/vendor/@anvil/common/src/util/__tests__/log-mirror.test.ts +31 -0
- package/vendor/@anvil/common/src/util/__tests__/messages.test.ts +1252 -0
- package/vendor/@anvil/common/src/util/__tests__/partial-json-delta.test.ts +505 -0
- package/vendor/@anvil/common/src/util/__tests__/path.test.ts +22 -0
- package/vendor/@anvil/common/src/util/__tests__/project-ignore.test.ts +90 -0
- package/vendor/@anvil/common/src/util/__tests__/promise.test.ts +325 -0
- package/vendor/@anvil/common/src/util/__tests__/rate-limit.test.ts +28 -0
- package/vendor/@anvil/common/src/util/__tests__/reddit-anvil-retention.test.ts +130 -0
- package/vendor/@anvil/common/src/util/__tests__/saxy.test.ts +1008 -0
- package/vendor/@anvil/common/src/util/__tests__/split-data.test.ts +289 -0
- package/vendor/@anvil/common/src/util/__tests__/string.test.ts +239 -0
- package/vendor/@anvil/common/src/util/__tests__/thread-title.test.ts +70 -0
- package/vendor/@anvil/common/src/util/__tests__/tool-result-media-order.test.ts +108 -0
- package/vendor/@anvil/common/src/util/__tests__/ttft-histogram.test.ts +180 -0
- package/vendor/@anvil/common/src/util/__tests__/with-timeout.test.ts +24 -0
- package/vendor/@anvil/common/src/util/__tests__/zoned-time.test.ts +88 -0
- package/vendor/@anvil/common/src/util/ad-user-agent.ts +25 -0
- package/vendor/@anvil/common/src/util/agent-file-utils.ts +110 -0
- package/vendor/@anvil/common/src/util/agent-id-parsing.ts +136 -0
- package/vendor/@anvil/common/src/util/agent-name-normalization.ts +38 -0
- package/vendor/@anvil/common/src/util/agent-name-resolver.ts +86 -0
- package/vendor/@anvil/common/src/util/analytics-dispatcher.ts +82 -0
- package/vendor/@anvil/common/src/util/analytics-log.ts +78 -0
- package/vendor/@anvil/common/src/util/analytics-sampling.ts +255 -0
- package/vendor/@anvil/common/src/util/anvil-model-availability.ts +102 -0
- package/vendor/@anvil/common/src/util/anvil-privacy.ts +82 -0
- package/vendor/@anvil/common/src/util/anvil-streak-line.ts +103 -0
- package/vendor/@anvil/common/src/util/anvil-streak.ts +156 -0
- package/vendor/@anvil/common/src/util/anvil-usage-summary.ts +125 -0
- package/vendor/@anvil/common/src/util/array.ts +31 -0
- package/vendor/@anvil/common/src/util/axiom-only-log.ts +124 -0
- package/vendor/@anvil/common/src/util/cache-debug.ts +171 -0
- package/vendor/@anvil/common/src/util/client-user-agent.ts +114 -0
- package/vendor/@anvil/common/src/util/credentials.ts +26 -0
- package/vendor/@anvil/common/src/util/currency.ts +25 -0
- package/vendor/@anvil/common/src/util/dates.ts +81 -0
- package/vendor/@anvil/common/src/util/disposable-email.ts +277 -0
- package/vendor/@anvil/common/src/util/engagement-tracker.ts +129 -0
- package/vendor/@anvil/common/src/util/env-file-path.ts +40 -0
- package/vendor/@anvil/common/src/util/error.ts +562 -0
- package/vendor/@anvil/common/src/util/file-read-limits.ts +236 -0
- package/vendor/@anvil/common/src/util/file.ts +339 -0
- package/vendor/@anvil/common/src/util/format-code-search.ts +115 -0
- package/vendor/@anvil/common/src/util/lazy-response-ads.ts +92 -0
- package/vendor/@anvil/common/src/util/log-data.ts +57 -0
- package/vendor/@anvil/common/src/util/log-ingest.ts +58 -0
- package/vendor/@anvil/common/src/util/log-mirror.ts +34 -0
- package/vendor/@anvil/common/src/util/lru-cache.ts +67 -0
- package/vendor/@anvil/common/src/util/messages.ts +685 -0
- package/vendor/@anvil/common/src/util/min-heap.ts +87 -0
- package/vendor/@anvil/common/src/util/model-utils.ts +4 -0
- package/vendor/@anvil/common/src/util/object.ts +128 -0
- package/vendor/@anvil/common/src/util/partial-json-delta.ts +89 -0
- package/vendor/@anvil/common/src/util/path.ts +15 -0
- package/vendor/@anvil/common/src/util/project-ignore.ts +119 -0
- package/vendor/@anvil/common/src/util/promise.ts +73 -0
- package/vendor/@anvil/common/src/util/random.ts +15 -0
- package/vendor/@anvil/common/src/util/rate-limit.ts +56 -0
- package/vendor/@anvil/common/src/util/reddit-anvil-retention.ts +60 -0
- package/vendor/@anvil/common/src/util/reddit-capi-events.ts +36 -0
- package/vendor/@anvil/common/src/util/response-ad-positions.ts +54 -0
- package/vendor/@anvil/common/src/util/saxy.ts +741 -0
- package/vendor/@anvil/common/src/util/skills.test.ts +44 -0
- package/vendor/@anvil/common/src/util/skills.ts +36 -0
- package/vendor/@anvil/common/src/util/split-data.ts +259 -0
- package/vendor/@anvil/common/src/util/stop-sequence.ts +61 -0
- package/vendor/@anvil/common/src/util/string.ts +426 -0
- package/vendor/@anvil/common/src/util/system-info.ts +53 -0
- package/vendor/@anvil/common/src/util/thread-title.ts +46 -0
- package/vendor/@anvil/common/src/util/ttft-histogram.ts +73 -0
- package/vendor/@anvil/common/src/util/xml-parser.ts +27 -0
- package/vendor/@anvil/common/src/util/xml.ts +17 -0
- package/vendor/@anvil/common/src/util/zod-schema.ts +25 -0
- package/vendor/@anvil/common/src/util/zoned-time.ts +136 -0
- package/vendor/@anvil/common/src/utils/ask-user-bridge.ts +44 -0
- package/vendor/@anvil/sdk/dist/index.cjs +52297 -0
- package/vendor/@anvil/sdk/dist/index.cjs.map +440 -0
- package/vendor/@anvil/sdk/dist/index.d.ts +4277 -0
- package/vendor/@anvil/sdk/dist/index.mjs +52290 -0
- package/vendor/@anvil/sdk/dist/index.mjs.map +440 -0
- package/vendor/@anvil/sdk/dist/vendor/ai.cjs +30886 -0
- package/vendor/@anvil/sdk/dist/vendor/ripgrep/arm64-darwin/rg +0 -0
- package/vendor/@anvil/sdk/dist/vendor/ripgrep/arm64-linux/rg +0 -0
- package/vendor/@anvil/sdk/dist/vendor/ripgrep/x64-darwin/rg +0 -0
- package/vendor/@anvil/sdk/dist/vendor/ripgrep/x64-linux/rg +0 -0
- package/vendor/@anvil/sdk/dist/vendor/ripgrep/x64-win32/rg.exe +0 -0
- package/vendor/@anvil/sdk/dist/wasm/tree-sitter-c-sharp.wasm +0 -0
- package/vendor/@anvil/sdk/dist/wasm/tree-sitter-cpp.wasm +0 -0
- package/vendor/@anvil/sdk/dist/wasm/tree-sitter-go.wasm +0 -0
- package/vendor/@anvil/sdk/dist/wasm/tree-sitter-java.wasm +0 -0
- package/vendor/@anvil/sdk/dist/wasm/tree-sitter-javascript.wasm +0 -0
- package/vendor/@anvil/sdk/dist/wasm/tree-sitter-python.wasm +0 -0
- package/vendor/@anvil/sdk/dist/wasm/tree-sitter-ruby.wasm +0 -0
- package/vendor/@anvil/sdk/dist/wasm/tree-sitter-rust.wasm +0 -0
- package/vendor/@anvil/sdk/dist/wasm/tree-sitter-tsx.wasm +0 -0
- package/vendor/@anvil/sdk/dist/wasm/tree-sitter-typescript.wasm +0 -0
- package/vendor/@anvil/sdk/dist/wasm/tree-sitter.wasm +0 -0
- package/vendor/@anvil/sdk/package.json +21 -0
|
@@ -0,0 +1,154 @@
|
|
|
1
|
+
import { describe, expect, test } from 'bun:test'
|
|
2
|
+
|
|
3
|
+
import {
|
|
4
|
+
buildGravityFirstMessagePayload,
|
|
5
|
+
gravityFirstMessageEventId,
|
|
6
|
+
isAnvilGravitySurface,
|
|
7
|
+
sanitizeGravityCapiData,
|
|
8
|
+
sendGravityFirstMessageConversion,
|
|
9
|
+
} from '../gravity-capi'
|
|
10
|
+
|
|
11
|
+
describe('Gravity first-message CAPI', () => {
|
|
12
|
+
test('sanitizes browser attribution in one shared boundary', () => {
|
|
13
|
+
expect(
|
|
14
|
+
sanitizeGravityCapiData(
|
|
15
|
+
{
|
|
16
|
+
user_data: {
|
|
17
|
+
click_id: 'click-1',
|
|
18
|
+
visitor_id: 123,
|
|
19
|
+
session_id: 'session-1',
|
|
20
|
+
},
|
|
21
|
+
event_source_url: 'https://stale.example',
|
|
22
|
+
client_context: { timezone: 'America/Los_Angeles' },
|
|
23
|
+
},
|
|
24
|
+
'https://anvil.com/chat',
|
|
25
|
+
),
|
|
26
|
+
).toEqual({
|
|
27
|
+
user_data: {
|
|
28
|
+
click_id: 'click-1',
|
|
29
|
+
visitor_id: undefined,
|
|
30
|
+
session_id: 'session-1',
|
|
31
|
+
client_user_agent: undefined,
|
|
32
|
+
},
|
|
33
|
+
event_source_url: 'https://anvil.com/chat',
|
|
34
|
+
client_context: { timezone: 'America/Los_Angeles' },
|
|
35
|
+
})
|
|
36
|
+
expect(isAnvilGravitySurface('desktop')).toBe(true)
|
|
37
|
+
expect(isAnvilGravitySurface('preexisting')).toBe(false)
|
|
38
|
+
})
|
|
39
|
+
|
|
40
|
+
test('drops oversized client context before forwarding it to Gravity', () => {
|
|
41
|
+
expect(
|
|
42
|
+
sanitizeGravityCapiData({
|
|
43
|
+
user_data: { click_id: 'click-123' },
|
|
44
|
+
client_context: { padding: 'x'.repeat(32_768) },
|
|
45
|
+
}),
|
|
46
|
+
).toEqual({
|
|
47
|
+
user_data: {
|
|
48
|
+
click_id: 'click-123',
|
|
49
|
+
visitor_id: undefined,
|
|
50
|
+
session_id: undefined,
|
|
51
|
+
client_user_agent: undefined,
|
|
52
|
+
},
|
|
53
|
+
event_source_url: undefined,
|
|
54
|
+
client_context: undefined,
|
|
55
|
+
})
|
|
56
|
+
})
|
|
57
|
+
|
|
58
|
+
test('builds a stable, attributed payload with authoritative identity', () => {
|
|
59
|
+
expect(
|
|
60
|
+
buildGravityFirstMessagePayload({
|
|
61
|
+
userId: 'user-123',
|
|
62
|
+
email: 'person@example.com',
|
|
63
|
+
surface: 'cloud',
|
|
64
|
+
eventTime: 123,
|
|
65
|
+
gravity: {
|
|
66
|
+
event_source_url: 'https://anvil.com/cloud/project/example',
|
|
67
|
+
user_data: {
|
|
68
|
+
click_id: 'click-1',
|
|
69
|
+
visitor_id: 'visitor-1',
|
|
70
|
+
session_id: 'session-1',
|
|
71
|
+
client_user_agent: 'pixel-agent',
|
|
72
|
+
},
|
|
73
|
+
client_context: { timezone: 'America/Los_Angeles' },
|
|
74
|
+
},
|
|
75
|
+
}),
|
|
76
|
+
).toEqual({
|
|
77
|
+
data: [
|
|
78
|
+
{
|
|
79
|
+
event_name: 'FirstMessage',
|
|
80
|
+
event_time: 123,
|
|
81
|
+
event_id: 'anvil-first-message-user-123',
|
|
82
|
+
action_source: 'website',
|
|
83
|
+
event_source_url: 'https://anvil.com/cloud/project/example',
|
|
84
|
+
user_data: {
|
|
85
|
+
click_id: 'click-1',
|
|
86
|
+
visitor_id: 'visitor-1',
|
|
87
|
+
session_id: 'session-1',
|
|
88
|
+
client_user_agent: 'pixel-agent',
|
|
89
|
+
em: ['person@example.com'],
|
|
90
|
+
external_id: ['user-123'],
|
|
91
|
+
},
|
|
92
|
+
client_context: { timezone: 'America/Los_Angeles' },
|
|
93
|
+
custom_data: {
|
|
94
|
+
content_name: 'Anvil first message',
|
|
95
|
+
content_category: 'cloud',
|
|
96
|
+
},
|
|
97
|
+
},
|
|
98
|
+
],
|
|
99
|
+
})
|
|
100
|
+
})
|
|
101
|
+
|
|
102
|
+
test('uses the same event id across surfaces for Gravity deduplication', () => {
|
|
103
|
+
expect(gravityFirstMessageEventId('user-123')).toBe(
|
|
104
|
+
'anvil-first-message-user-123',
|
|
105
|
+
)
|
|
106
|
+
})
|
|
107
|
+
|
|
108
|
+
test('accepts a duplicate response as delivered', async () => {
|
|
109
|
+
let requestBody: unknown
|
|
110
|
+
const result = await sendGravityFirstMessageConversion({
|
|
111
|
+
apiKey: 'secret',
|
|
112
|
+
userId: 'user-123',
|
|
113
|
+
surface: 'desktop',
|
|
114
|
+
fetchImpl: (async (_input, init) => {
|
|
115
|
+
requestBody = JSON.parse(String(init?.body))
|
|
116
|
+
return new Response(
|
|
117
|
+
JSON.stringify({
|
|
118
|
+
results: [
|
|
119
|
+
{
|
|
120
|
+
event_id: 'anvil-first-message-user-123',
|
|
121
|
+
status: 'duplicate',
|
|
122
|
+
},
|
|
123
|
+
],
|
|
124
|
+
}),
|
|
125
|
+
{ status: 200 },
|
|
126
|
+
)
|
|
127
|
+
}) as typeof fetch,
|
|
128
|
+
})
|
|
129
|
+
|
|
130
|
+
expect(result.status).toBe('duplicate')
|
|
131
|
+
expect(requestBody).toMatchObject({
|
|
132
|
+
data: [
|
|
133
|
+
{
|
|
134
|
+
event_name: 'FirstMessage',
|
|
135
|
+
custom_data: { content_category: 'desktop' },
|
|
136
|
+
},
|
|
137
|
+
],
|
|
138
|
+
})
|
|
139
|
+
})
|
|
140
|
+
|
|
141
|
+
test('throws on an event-level error so the claim remains retryable', async () => {
|
|
142
|
+
await expect(
|
|
143
|
+
sendGravityFirstMessageConversion({
|
|
144
|
+
apiKey: 'secret',
|
|
145
|
+
userId: 'user-123',
|
|
146
|
+
surface: 'cli',
|
|
147
|
+
fetchImpl: (async () =>
|
|
148
|
+
new Response(JSON.stringify({ results: [{ status: 'error' }] }), {
|
|
149
|
+
status: 200,
|
|
150
|
+
})) as unknown as typeof fetch,
|
|
151
|
+
}),
|
|
152
|
+
).rejects.toThrow('status error')
|
|
153
|
+
})
|
|
154
|
+
})
|
|
@@ -0,0 +1,246 @@
|
|
|
1
|
+
import { afterEach, beforeEach, describe, expect, test } from 'bun:test'
|
|
2
|
+
|
|
3
|
+
import { validateAgents } from '../templates/agent-validation'
|
|
4
|
+
import { DynamicAgentDefinitionSchema } from '../types/dynamic-agent-template'
|
|
5
|
+
|
|
6
|
+
import type { DynamicAgentTemplate } from '../types/dynamic-agent-template'
|
|
7
|
+
import type { AgentState } from '../types/session-state'
|
|
8
|
+
import type { ProjectFileContext } from '../util/file'
|
|
9
|
+
import type { Logger } from '@anvil/common/types/contracts/logger'
|
|
10
|
+
|
|
11
|
+
describe('handleSteps Parsing Tests', () => {
|
|
12
|
+
let mockFileContext: ProjectFileContext
|
|
13
|
+
let mockAgentTemplate: DynamicAgentTemplate
|
|
14
|
+
const logger: Logger = {
|
|
15
|
+
debug: () => {},
|
|
16
|
+
error: () => {},
|
|
17
|
+
info: () => {},
|
|
18
|
+
warn: () => {},
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
beforeEach(() => {
|
|
22
|
+
// Setup common mock data
|
|
23
|
+
mockFileContext = {
|
|
24
|
+
projectRoot: '/test',
|
|
25
|
+
cwd: '/test',
|
|
26
|
+
fileTree: [],
|
|
27
|
+
fileTokenScores: {},
|
|
28
|
+
knowledgeFiles: {},
|
|
29
|
+
agentTemplates: {},
|
|
30
|
+
customToolDefinitions: {},
|
|
31
|
+
gitChanges: {
|
|
32
|
+
status: '',
|
|
33
|
+
diff: '',
|
|
34
|
+
diffCached: '',
|
|
35
|
+
lastCommitMessages: '',
|
|
36
|
+
},
|
|
37
|
+
changesSinceLastChat: {},
|
|
38
|
+
shellConfigFiles: {},
|
|
39
|
+
systemInfo: {
|
|
40
|
+
platform: 'test',
|
|
41
|
+
shell: 'test',
|
|
42
|
+
nodeVersion: 'test',
|
|
43
|
+
arch: 'test',
|
|
44
|
+
homedir: '/test',
|
|
45
|
+
cpus: 1,
|
|
46
|
+
chromeAvailable: false,
|
|
47
|
+
},
|
|
48
|
+
tokenCallers: {},
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
mockAgentTemplate = {
|
|
52
|
+
id: 'test-agent',
|
|
53
|
+
version: '1.0.0',
|
|
54
|
+
displayName: 'Test Agent',
|
|
55
|
+
spawnerPrompt: 'Testing',
|
|
56
|
+
model: 'claude-3-5-sonnet-20241022',
|
|
57
|
+
outputMode: 'structured_output' as const,
|
|
58
|
+
mcpServers: {},
|
|
59
|
+
toolNames: ['set_output'],
|
|
60
|
+
spawnableAgents: [],
|
|
61
|
+
includeMessageHistory: true,
|
|
62
|
+
inheritParentSystemPrompt: false,
|
|
63
|
+
systemPrompt: 'Test system prompt',
|
|
64
|
+
instructionsPrompt: 'Test user prompt',
|
|
65
|
+
stepPrompt: 'Test agent step prompt',
|
|
66
|
+
}
|
|
67
|
+
})
|
|
68
|
+
|
|
69
|
+
afterEach(() => {
|
|
70
|
+
// No cleanup needed for stateless functions
|
|
71
|
+
})
|
|
72
|
+
|
|
73
|
+
test('should validate agent config with handleSteps function', () => {
|
|
74
|
+
const agentConfig = {
|
|
75
|
+
id: 'test-agent',
|
|
76
|
+
version: '1.0.0',
|
|
77
|
+
displayName: 'Test Agent',
|
|
78
|
+
spawnerPrompt: 'Testing handleSteps',
|
|
79
|
+
model: 'claude-3-5-sonnet-20241022',
|
|
80
|
+
outputMode: 'structured_output' as const,
|
|
81
|
+
toolNames: ['set_output'],
|
|
82
|
+
systemPrompt: 'You are a test agent',
|
|
83
|
+
instructionsPrompt: 'Process: {prompt}',
|
|
84
|
+
stepPrompt: 'Continue processing',
|
|
85
|
+
handleSteps: function* ({
|
|
86
|
+
agentState,
|
|
87
|
+
prompt,
|
|
88
|
+
params,
|
|
89
|
+
}: {
|
|
90
|
+
agentState: AgentState
|
|
91
|
+
prompt?: string
|
|
92
|
+
params?: any
|
|
93
|
+
}) {
|
|
94
|
+
yield {
|
|
95
|
+
toolName: 'set_output',
|
|
96
|
+
args: { message: 'Test completed' },
|
|
97
|
+
}
|
|
98
|
+
},
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
const result = DynamicAgentDefinitionSchema.safeParse(agentConfig)
|
|
102
|
+
expect(result.success).toBe(true)
|
|
103
|
+
|
|
104
|
+
if (result.success) {
|
|
105
|
+
expect(typeof result.data.handleSteps).toBe('function')
|
|
106
|
+
}
|
|
107
|
+
})
|
|
108
|
+
|
|
109
|
+
test('should convert handleSteps function to string', async () => {
|
|
110
|
+
const handleStepsFunction = function* ({
|
|
111
|
+
agentState,
|
|
112
|
+
prompt,
|
|
113
|
+
params,
|
|
114
|
+
}: {
|
|
115
|
+
agentState: AgentState
|
|
116
|
+
prompt?: string
|
|
117
|
+
params?: any
|
|
118
|
+
}) {
|
|
119
|
+
yield {
|
|
120
|
+
toolName: 'set_output',
|
|
121
|
+
args: { message: 'Hello from generator' },
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
const agentTemplates = {
|
|
126
|
+
'test-agent.ts': {
|
|
127
|
+
...mockAgentTemplate,
|
|
128
|
+
handleSteps: handleStepsFunction.toString(),
|
|
129
|
+
},
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
const fileContext: ProjectFileContext = {
|
|
133
|
+
...mockFileContext,
|
|
134
|
+
agentTemplates,
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
const result = validateAgents({
|
|
138
|
+
agentTemplates: fileContext.agentTemplates || {},
|
|
139
|
+
logger,
|
|
140
|
+
})
|
|
141
|
+
|
|
142
|
+
expect(result.validationErrors).toHaveLength(0)
|
|
143
|
+
expect(result.templates['test-agent']).toBeDefined()
|
|
144
|
+
expect(typeof result.templates['test-agent'].handleSteps).toBe('string')
|
|
145
|
+
})
|
|
146
|
+
|
|
147
|
+
// Note: The validation that required set_output tool for structured_output mode was
|
|
148
|
+
// intentionally disabled to allow handleSteps to use set_output while the LLM does not
|
|
149
|
+
// have access to the set_output tool.
|
|
150
|
+
test('should allow structured_output mode without set_output tool in toolNames', () => {
|
|
151
|
+
const {
|
|
152
|
+
DynamicAgentTemplateSchema,
|
|
153
|
+
} = require('../types/dynamic-agent-template')
|
|
154
|
+
|
|
155
|
+
const agentConfig = {
|
|
156
|
+
id: 'test-agent',
|
|
157
|
+
version: '1.0.0',
|
|
158
|
+
displayName: 'Test Agent',
|
|
159
|
+
spawnerPrompt: 'Testing handleSteps',
|
|
160
|
+
model: 'claude-3-5-sonnet-20241022',
|
|
161
|
+
outputMode: 'structured_output' as const,
|
|
162
|
+
toolNames: ['end_turn'], // Missing set_output - now allowed
|
|
163
|
+
spawnableAgents: [],
|
|
164
|
+
systemPrompt: 'Test',
|
|
165
|
+
instructionsPrompt: 'Test',
|
|
166
|
+
stepPrompt: 'Test',
|
|
167
|
+
|
|
168
|
+
handleSteps:
|
|
169
|
+
'function* () { yield { toolName: "set_output", args: {} } }',
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
const result = DynamicAgentTemplateSchema.safeParse(agentConfig)
|
|
173
|
+
expect(result.success).toBe(true)
|
|
174
|
+
})
|
|
175
|
+
|
|
176
|
+
test('should validate that handleSteps is a generator function', async () => {
|
|
177
|
+
const agentTemplates = {
|
|
178
|
+
'test-agent.ts': {
|
|
179
|
+
...mockAgentTemplate,
|
|
180
|
+
handleSteps: 'function () { return "not a generator" }', // Missing *
|
|
181
|
+
},
|
|
182
|
+
}
|
|
183
|
+
|
|
184
|
+
const fileContext: ProjectFileContext = {
|
|
185
|
+
...mockFileContext,
|
|
186
|
+
agentTemplates,
|
|
187
|
+
}
|
|
188
|
+
|
|
189
|
+
const result = validateAgents({
|
|
190
|
+
agentTemplates: fileContext.agentTemplates || {},
|
|
191
|
+
logger,
|
|
192
|
+
})
|
|
193
|
+
|
|
194
|
+
expect(result.validationErrors.length).toBeGreaterThan(0)
|
|
195
|
+
expect(result.validationErrors[0].message).toContain('generator function')
|
|
196
|
+
expect(result.validationErrors[0].message).toContain('function*')
|
|
197
|
+
})
|
|
198
|
+
|
|
199
|
+
test('should verify loaded template handleSteps matches original function toString', async () => {
|
|
200
|
+
// Create a generator function
|
|
201
|
+
const originalFunction = function* ({
|
|
202
|
+
agentState,
|
|
203
|
+
prompt,
|
|
204
|
+
params,
|
|
205
|
+
}: {
|
|
206
|
+
agentState: AgentState
|
|
207
|
+
prompt?: string
|
|
208
|
+
params?: any
|
|
209
|
+
}) {
|
|
210
|
+
yield {
|
|
211
|
+
toolName: 'set_output',
|
|
212
|
+
args: { message: 'Test output', data: params },
|
|
213
|
+
}
|
|
214
|
+
}
|
|
215
|
+
|
|
216
|
+
// Get the string representation
|
|
217
|
+
const expectedStringified = originalFunction.toString()
|
|
218
|
+
|
|
219
|
+
// Create agent templates with the function
|
|
220
|
+
const agentTemplates = {
|
|
221
|
+
'test-agent.ts': {
|
|
222
|
+
...mockAgentTemplate,
|
|
223
|
+
handleSteps: expectedStringified,
|
|
224
|
+
},
|
|
225
|
+
}
|
|
226
|
+
|
|
227
|
+
const fileContext: ProjectFileContext = {
|
|
228
|
+
...mockFileContext,
|
|
229
|
+
agentTemplates,
|
|
230
|
+
}
|
|
231
|
+
|
|
232
|
+
// Load agents through the service
|
|
233
|
+
const result = validateAgents({
|
|
234
|
+
agentTemplates: fileContext.agentTemplates || {},
|
|
235
|
+
logger,
|
|
236
|
+
})
|
|
237
|
+
|
|
238
|
+
// Verify no validation errors
|
|
239
|
+
expect(result.validationErrors).toHaveLength(0)
|
|
240
|
+
expect(result.templates['test-agent']).toBeDefined()
|
|
241
|
+
|
|
242
|
+
// Verify the loaded template's handleSteps field matches the original toString
|
|
243
|
+
expect(result.templates['test-agent'].handleSteps).toBe(expectedStringified)
|
|
244
|
+
expect(typeof result.templates['test-agent'].handleSteps).toBe('string')
|
|
245
|
+
})
|
|
246
|
+
})
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Kimi K3 (Eco) is god-only on Anvil Web — a testing row, not a product one.
|
|
3
|
+
* Cost backs that up: CrofAI lists it at $1.00/$4.00 per M against DeepSeek V4
|
|
4
|
+
* Flash's $0.12/$0.21 on the same provider, ~8x input and ~19x output.
|
|
5
|
+
*/
|
|
6
|
+
import { describe, expect, it } from 'bun:test'
|
|
7
|
+
|
|
8
|
+
import {
|
|
9
|
+
ANVIL_KIMI_K3_ECO_MODEL_ID,
|
|
10
|
+
ANVIL_MODELS,
|
|
11
|
+
ANVIL_WEB_ALL_MODELS,
|
|
12
|
+
ANVIL_WEB_GOD_ONLY_MODELS,
|
|
13
|
+
ANVIL_WEB_MODELS,
|
|
14
|
+
ANVIL_WEB_PREMIUM_MODEL_IDS,
|
|
15
|
+
ANVIL_WEB_STANDARD_MODEL_IDS,
|
|
16
|
+
isAnvilWebGodOnlyModelId,
|
|
17
|
+
isAnvilWebModelId,
|
|
18
|
+
SUPPORTED_ANVIL_MODELS,
|
|
19
|
+
} from '../constants/anvil-models'
|
|
20
|
+
|
|
21
|
+
const KIMI_ID = ANVIL_KIMI_K3_ECO_MODEL_ID
|
|
22
|
+
|
|
23
|
+
describe('Kimi K3 is god-only on Anvil Web', () => {
|
|
24
|
+
it('is offered to god users and nobody else', () => {
|
|
25
|
+
expect(isAnvilWebGodOnlyModelId(KIMI_ID)).toBe(true)
|
|
26
|
+
expect(isAnvilWebModelId(KIMI_ID, { includeGodOnly: true })).toBe(true)
|
|
27
|
+
expect(isAnvilWebModelId(KIMI_ID, { includeGodOnly: false })).toBe(false)
|
|
28
|
+
expect(ANVIL_WEB_GOD_ONLY_MODELS.map((m) => m.id)).toContain(KIMI_ID)
|
|
29
|
+
// The god-only list is additive to the visible one, so it must NOT also
|
|
30
|
+
// appear there or every user would see it.
|
|
31
|
+
expect(ANVIL_WEB_MODELS.map((m) => m.id)).not.toContain(KIMI_ID)
|
|
32
|
+
})
|
|
33
|
+
|
|
34
|
+
it('stays off every non-web surface', () => {
|
|
35
|
+
// Web only, as asked. ANVIL_MODELS is the CLI/Desktop catalog and
|
|
36
|
+
// SUPPORTED_ANVIL_MODELS the waiting-room set.
|
|
37
|
+
expect(ANVIL_MODELS.map((m) => m.id)).not.toContain(KIMI_ID)
|
|
38
|
+
expect(SUPPORTED_ANVIL_MODELS.map((m) => m.id)).not.toContain(KIMI_ID)
|
|
39
|
+
expect(ANVIL_WEB_ALL_MODELS.map((m) => m.id)).toContain(KIMI_ID)
|
|
40
|
+
})
|
|
41
|
+
|
|
42
|
+
it('is metered by the premium pool, never the standard one', () => {
|
|
43
|
+
// ANVIL_WEB_STANDARD_MODEL_IDS is derived by filtering `!premium`, so a
|
|
44
|
+
// premium row missing from the premium list would be metered by NO pool.
|
|
45
|
+
expect(ANVIL_WEB_PREMIUM_MODEL_IDS).toContain(KIMI_ID)
|
|
46
|
+
expect(ANVIL_WEB_STANDARD_MODEL_IDS).not.toContain(KIMI_ID)
|
|
47
|
+
const model = ANVIL_WEB_GOD_ONLY_MODELS.find((m) => m.id === KIMI_ID)
|
|
48
|
+
expect(model?.premium).toBe(true)
|
|
49
|
+
})
|
|
50
|
+
|
|
51
|
+
it('displays as "Kimi K3" while the wire id keeps the -eco build', () => {
|
|
52
|
+
// DELIBERATE, by explicit request, and the reason this assertion exists: it
|
|
53
|
+
// breaks the convention DeepSeek V4 Flash 07/31 sets (name the exact build),
|
|
54
|
+
// so without a test someone would "fix" the label to 'Kimi K3 Eco'.
|
|
55
|
+
//
|
|
56
|
+
// The wire id must keep `-eco` regardless. CrofAI serves a full `kimi-k3` at
|
|
57
|
+
// twice the price ($2.00/$8.00), and routing, billing and CROF_MODEL_MAP all
|
|
58
|
+
// key off this id — collapsing it to a bare `kimi-k3` would silently point
|
|
59
|
+
// this row at the dearer model.
|
|
60
|
+
const model = ANVIL_WEB_GOD_ONLY_MODELS.find((m) => m.id === KIMI_ID)
|
|
61
|
+
expect(model?.displayName).toBe('Kimi K3')
|
|
62
|
+
expect(model?.displayName).not.toContain('Eco')
|
|
63
|
+
expect(KIMI_ID).toBe('crof/kimi-k3-eco')
|
|
64
|
+
})
|
|
65
|
+
|
|
66
|
+
it('is marked experimental, since it exists to be tested', () => {
|
|
67
|
+
const model = ANVIL_WEB_GOD_ONLY_MODELS.find((m) => m.id === KIMI_ID)
|
|
68
|
+
expect(model?.experimental).toBe(true)
|
|
69
|
+
})
|
|
70
|
+
|
|
71
|
+
it('keeps its id distinct from every other catalog row', () => {
|
|
72
|
+
// A second id for an already-offered model is how the retired `crof/glm-5.2`
|
|
73
|
+
// became a quota-bypass route. This must be the only id that reaches K3 Eco.
|
|
74
|
+
const all = ANVIL_WEB_ALL_MODELS.map((m) => m.id)
|
|
75
|
+
expect(new Set(all).size).toBe(all.length)
|
|
76
|
+
})
|
|
77
|
+
})
|
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
import { describe, expect, test } from 'bun:test'
|
|
2
|
+
|
|
3
|
+
import {
|
|
4
|
+
contextPrunerBudgetForModel,
|
|
5
|
+
isExplicitlyDefinedModel,
|
|
6
|
+
models,
|
|
7
|
+
supportsAssistantPrefill,
|
|
8
|
+
} from '../constants/model-config'
|
|
9
|
+
|
|
10
|
+
describe('isExplicitlyDefinedModel', () => {
|
|
11
|
+
test('distinguishes configured models from unknown model IDs', () => {
|
|
12
|
+
expect(isExplicitlyDefinedModel(models.openrouter_gpt5)).toBe(true)
|
|
13
|
+
expect(isExplicitlyDefinedModel('custom/unknown-model')).toBe(false)
|
|
14
|
+
})
|
|
15
|
+
})
|
|
16
|
+
|
|
17
|
+
describe('supportsAssistantPrefill', () => {
|
|
18
|
+
test('rejects prefill for Claude 4.6+', () => {
|
|
19
|
+
expect(supportsAssistantPrefill('anthropic/claude-opus-4.6')).toBe(false)
|
|
20
|
+
expect(supportsAssistantPrefill('anthropic/claude-opus-4.7')).toBe(false)
|
|
21
|
+
expect(supportsAssistantPrefill('anthropic/claude-sonnet-4.6')).toBe(false)
|
|
22
|
+
expect(supportsAssistantPrefill('anthropic/claude-fable-5')).toBe(false)
|
|
23
|
+
})
|
|
24
|
+
|
|
25
|
+
test('allows prefill for Claude before 4.6', () => {
|
|
26
|
+
expect(supportsAssistantPrefill('anthropic/claude-sonnet-4.5')).toBe(true)
|
|
27
|
+
expect(supportsAssistantPrefill('anthropic/claude-opus-4')).toBe(true)
|
|
28
|
+
expect(supportsAssistantPrefill('anthropic/claude-3-5-sonnet')).toBe(true)
|
|
29
|
+
expect(
|
|
30
|
+
supportsAssistantPrefill('anthropic/claude-haiku-4-5-20251001'),
|
|
31
|
+
).toBe(true)
|
|
32
|
+
})
|
|
33
|
+
|
|
34
|
+
test('allows prefill for non-Claude models', () => {
|
|
35
|
+
expect(supportsAssistantPrefill('openai/gpt-5.1')).toBe(true)
|
|
36
|
+
expect(supportsAssistantPrefill('deepseek/deepseek-v4-pro')).toBe(true)
|
|
37
|
+
expect(supportsAssistantPrefill('moonshotai/kimi-k2.6')).toBe(true)
|
|
38
|
+
})
|
|
39
|
+
})
|
|
40
|
+
|
|
41
|
+
describe('contextPrunerBudgetForModel', () => {
|
|
42
|
+
test('defaults to 400k, which every ~1M-window model we serve can hold', () => {
|
|
43
|
+
for (const model of [
|
|
44
|
+
'anthropic/claude-opus-5',
|
|
45
|
+
'anthropic/claude-sonnet-5',
|
|
46
|
+
'openai/gpt-5.4',
|
|
47
|
+
'openai/gpt-5.6-luna',
|
|
48
|
+
'deepseek/deepseek-v4-flash',
|
|
49
|
+
'deepseek/deepseek-v4-pro',
|
|
50
|
+
'mimo/mimo-v2.5',
|
|
51
|
+
'z-ai/glm-5.2',
|
|
52
|
+
// MiniMax M3's real enforced limit is 524_288 (Fireworks rejects with
|
|
53
|
+
// "model maximum context length: 524287"), not the 1M OpenRouter lists.
|
|
54
|
+
// 400k is still comfortably under it.
|
|
55
|
+
'minimax/minimax-m3',
|
|
56
|
+
'some/model-we-have-never-shipped',
|
|
57
|
+
]) {
|
|
58
|
+
expect(contextPrunerBudgetForModel(model)).toBe(400_000)
|
|
59
|
+
}
|
|
60
|
+
})
|
|
61
|
+
|
|
62
|
+
test('drops to 250k for the 262,144-token models', () => {
|
|
63
|
+
// Kimi K2.7 Code is the only remaining exception: the HY3 and Ling 3.0
|
|
64
|
+
// Flash entries that shared its window went with those models on
|
|
65
|
+
// 2026-08-07, so they now take the 400k default like anything unlisted.
|
|
66
|
+
expect(contextPrunerBudgetForModel('moonshotai/kimi-k2.7-code')).toBe(
|
|
67
|
+
250_000,
|
|
68
|
+
)
|
|
69
|
+
for (const removed of [
|
|
70
|
+
'tencent/hy3',
|
|
71
|
+
'tencent/hy3:free',
|
|
72
|
+
'tencent/hy3-preview',
|
|
73
|
+
'inclusionai/ling-3.0-flash:free',
|
|
74
|
+
]) {
|
|
75
|
+
expect(contextPrunerBudgetForModel(removed)).toBe(400_000)
|
|
76
|
+
}
|
|
77
|
+
})
|
|
78
|
+
|
|
79
|
+
test('every exception stays under its real window', () => {
|
|
80
|
+
// The budget is compared against a GPT-4o-based estimate applied to other
|
|
81
|
+
// tokenizers, so it must sit under the provider's limit with room to spare.
|
|
82
|
+
expect(
|
|
83
|
+
contextPrunerBudgetForModel('moonshotai/kimi-k2.7-code'),
|
|
84
|
+
).toBeLessThan(262_144)
|
|
85
|
+
// Kimi K3 Eco is deliberately NOT an exception — CrofAI serves it at a 1M
|
|
86
|
+
// context, so the 400k default is correct for it.
|
|
87
|
+
expect(contextPrunerBudgetForModel('crof/kimi-k3-eco')).toBe(400_000)
|
|
88
|
+
})
|
|
89
|
+
})
|