@alumbwe/anvil 1.0.20 → 1.0.22
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 +74 -70
- 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,15 @@
|
|
|
1
|
+
/** Previous lightweight Gemini model. No agent still defaults to it, but
|
|
2
|
+
* FREE_MODE_AGENT_MODELS keeps accepting it — released clients ship pinned
|
|
3
|
+
* agent definitions and go on requesting it until their users upgrade. */
|
|
4
|
+
export const GEMINI_3_1_FLASH_LITE_MODEL_ID = 'google/gemini-3.1-flash-lite'
|
|
5
|
+
|
|
6
|
+
/** Current model for the lightweight Gemini helper subagents: basher,
|
|
7
|
+
* browser-use, file-lister(-max), file-picker-max, and the researchers.
|
|
8
|
+
* Pricier than 3.1 flash-lite ($0.30/$2.50 per M tokens vs $0.25/$1.50), and
|
|
9
|
+
* those agents run millions of calls a month, so moving an agent onto it is a
|
|
10
|
+
* real cost decision — not a free upgrade. */
|
|
11
|
+
export const GEMINI_3_5_FLASH_LITE_MODEL_ID = 'google/gemini-3.5-flash-lite'
|
|
12
|
+
|
|
13
|
+
/** Retired model ID emitted by Anvil clients released before July 2026. */
|
|
14
|
+
export const LEGACY_GEMINI_3_1_FLASH_LITE_PREVIEW_MODEL_ID =
|
|
15
|
+
'google/gemini-3.1-flash-lite-preview'
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import type { GrantType } from '@anvil/common/types/grant'
|
|
2
|
+
|
|
3
|
+
// Lower = consumed first
|
|
4
|
+
export const GRANT_PRIORITIES: Record<GrantType, number> = {
|
|
5
|
+
subscription: 10,
|
|
6
|
+
free: 20,
|
|
7
|
+
referral_legacy: 30, // Legacy recurring referrals (renews monthly, consumed first)
|
|
8
|
+
ad: 40,
|
|
9
|
+
referral: 50, // One-time referrals (never expires, preserved longer)
|
|
10
|
+
admin: 60,
|
|
11
|
+
organization: 70,
|
|
12
|
+
purchase: 80,
|
|
13
|
+
} as const
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Prod origin of the anvil.com web app (marketing site + browser sign-in).
|
|
3
|
+
* The CLI and Anvil Desktop both send users here for the device-code login
|
|
4
|
+
* flow; sharing the literal keeps their prod defaults from drifting.
|
|
5
|
+
*/
|
|
6
|
+
export const ANVIL_WEB_URL_PROD = 'https://anvil.com'
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Image-related constants shared across the codebase
|
|
3
|
+
*/
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* Extension to MIME type mapping for supported image formats
|
|
7
|
+
*/
|
|
8
|
+
export const IMAGE_EXTENSION_TO_MIME: Record<string, string> = {
|
|
9
|
+
'.jpg': 'image/jpeg',
|
|
10
|
+
'.jpeg': 'image/jpeg',
|
|
11
|
+
'.png': 'image/png',
|
|
12
|
+
'.webp': 'image/webp',
|
|
13
|
+
'.gif': 'image/gif',
|
|
14
|
+
'.bmp': 'image/bmp',
|
|
15
|
+
'.tiff': 'image/tiff',
|
|
16
|
+
'.tif': 'image/tiff',
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
/**
|
|
20
|
+
* Supported image extensions (derived from IMAGE_EXTENSION_TO_MIME)
|
|
21
|
+
*/
|
|
22
|
+
export const SUPPORTED_IMAGE_EXTENSIONS = new Set(Object.keys(IMAGE_EXTENSION_TO_MIME))
|
|
23
|
+
|
|
24
|
+
/**
|
|
25
|
+
* Check if a file extension is a supported image format
|
|
26
|
+
*/
|
|
27
|
+
export function isSupportedImageExtension(ext: string): boolean {
|
|
28
|
+
return SUPPORTED_IMAGE_EXTENSIONS.has(ext.toLowerCase())
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
/**
|
|
32
|
+
* Get MIME type for an image extension
|
|
33
|
+
*/
|
|
34
|
+
export function getImageMimeType(ext: string): string | null {
|
|
35
|
+
return IMAGE_EXTENSION_TO_MIME[ext.toLowerCase()] ?? null
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
/**
|
|
39
|
+
* Image extensions as a regex alternation pattern (without dots)
|
|
40
|
+
* e.g., "jpg|jpeg|png|webp|gif|bmp|tiff|tif"
|
|
41
|
+
*/
|
|
42
|
+
export const IMAGE_EXTENSIONS_PATTERN = Object.keys(IMAGE_EXTENSION_TO_MIME)
|
|
43
|
+
.map((ext) => ext.slice(1)) // Remove leading dot
|
|
44
|
+
.join('|')
|
|
45
|
+
|
|
46
|
+
// Size limits for image uploads
|
|
47
|
+
// Research shows Claude/GPT-4V support up to 20MB, but we use practical limits
|
|
48
|
+
// for good performance and token efficiency
|
|
49
|
+
export const MAX_IMAGE_FILE_SIZE = 10 * 1024 * 1024 // 10MB - allow larger files since we can compress
|
|
50
|
+
export const MAX_IMAGE_BASE64_SIZE = 1 * 1024 * 1024 // 1MB max for base64 after compression
|
|
51
|
+
export const MAX_TOTAL_IMAGE_SIZE = 5 * 1024 * 1024 // 5MB total for multiple images
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
// Re-export all constants from domain-specific files for backwards compatibility
|
|
2
|
+
// This allows existing imports from '@anvil/common/old-constants' to continue working
|
|
3
|
+
|
|
4
|
+
export * from './model-config'
|
|
5
|
+
export * from './limits'
|
|
6
|
+
export * from './ui'
|
|
7
|
+
export * from './paths'
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import path from 'path'
|
|
2
|
+
|
|
3
|
+
export const KNOWLEDGE_FILE_NAMES = [
|
|
4
|
+
'AGENTS.md',
|
|
5
|
+
'CLAUDE.md',
|
|
6
|
+
] as const
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* Pre-computed lowercase knowledge file names for efficient matching.
|
|
10
|
+
*/
|
|
11
|
+
export const KNOWLEDGE_FILE_NAMES_LOWERCASE = KNOWLEDGE_FILE_NAMES.map((name) =>
|
|
12
|
+
name.toLowerCase(),
|
|
13
|
+
)
|
|
14
|
+
|
|
15
|
+
/**
|
|
16
|
+
* Checks if a file path is a knowledge file.
|
|
17
|
+
* Matches:
|
|
18
|
+
* - Exact file names: AGENTS.md, CLAUDE.md (case-insensitive)
|
|
19
|
+
* - Pattern: *.knowledge.md (e.g., authentication.knowledge.md)
|
|
20
|
+
*/
|
|
21
|
+
export function isKnowledgeFile(filePath: string): boolean {
|
|
22
|
+
const fileName = path.basename(filePath).toLowerCase()
|
|
23
|
+
|
|
24
|
+
// Check for exact matches with standard knowledge file names
|
|
25
|
+
if (KNOWLEDGE_FILE_NAMES_LOWERCASE.includes(fileName)) {
|
|
26
|
+
return true
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
// Check for *.knowledge.md pattern (e.g., authentication.knowledge.md)
|
|
30
|
+
if (fileName.endsWith('.knowledge.md')) {
|
|
31
|
+
return true
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
return false
|
|
35
|
+
}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
export const PROFIT_MARGIN = 0.055
|
|
2
|
+
|
|
3
|
+
export const REQUEST_CREDIT_SHOW_THRESHOLD = 1
|
|
4
|
+
export const MAX_DATE = new Date(86399999999999)
|
|
5
|
+
export const BILLING_PERIOD_DAYS = 30
|
|
6
|
+
export const SESSION_MAX_AGE_SECONDS = 30 * 24 * 60 * 60 // 30 days
|
|
7
|
+
export const SESSION_TIME_WINDOW_MS = 30 * 60 * 1000 // 30 minutes - used for matching sessions created around fingerprint creation
|
|
8
|
+
// Signup credits are disabled. Re-enabling requires restoring the Anvil
|
|
9
|
+
// GitHub-link hook and pricing copy in addition to changing this amount.
|
|
10
|
+
export const SIGNUP_FREE_CREDITS_GRANT = 0
|
|
11
|
+
// If re-enabled, signup credits require a GitHub account at least this old.
|
|
12
|
+
export const SIGNUP_CREDIT_MIN_GITHUB_ACCOUNT_AGE_MONTHS = 4
|
|
13
|
+
|
|
14
|
+
// New accounts do not receive monthly free credits; grandfathered monthly grants
|
|
15
|
+
// are based on previous expiring free grants instead of this default.
|
|
16
|
+
export const DEFAULT_FREE_CREDITS_GRANT = 0
|
|
17
|
+
|
|
18
|
+
// Credit pricing configuration
|
|
19
|
+
export const CREDIT_PRICING = {
|
|
20
|
+
CENTS_PER_CREDIT: 1, // 1 credit = 1 cent = $0.01
|
|
21
|
+
MIN_PURCHASE_CREDITS: 100, // $1.00 minimum
|
|
22
|
+
DISPLAY_RATE: '$0.01 per credit',
|
|
23
|
+
} as const
|
|
@@ -0,0 +1,277 @@
|
|
|
1
|
+
// Allowed model prefixes for validation
|
|
2
|
+
export const ALLOWED_MODEL_PREFIXES = [
|
|
3
|
+
'anthropic',
|
|
4
|
+
'openai',
|
|
5
|
+
'google',
|
|
6
|
+
'x-ai',
|
|
7
|
+
'deepseek',
|
|
8
|
+
'minimax',
|
|
9
|
+
'mimo',
|
|
10
|
+
'tencent',
|
|
11
|
+
] as const
|
|
12
|
+
|
|
13
|
+
export const costModes = [
|
|
14
|
+
'free',
|
|
15
|
+
'lite',
|
|
16
|
+
'normal',
|
|
17
|
+
'max',
|
|
18
|
+
'experimental',
|
|
19
|
+
'ask',
|
|
20
|
+
] as const
|
|
21
|
+
export type CostMode = (typeof costModes)[number]
|
|
22
|
+
|
|
23
|
+
export const openaiModels = {
|
|
24
|
+
gpt4_1: 'gpt-4.1-2025-04-14',
|
|
25
|
+
gpt4o: 'gpt-4o-2024-11-20',
|
|
26
|
+
gpt4omini: 'gpt-4o-mini-2024-07-18',
|
|
27
|
+
o3mini: 'o3-mini-2025-01-31',
|
|
28
|
+
o3: 'o3-2025-04-16',
|
|
29
|
+
o3pro: 'o3-pro-2025-06-10',
|
|
30
|
+
o4mini: 'o4-mini-2025-04-16',
|
|
31
|
+
generatePatch:
|
|
32
|
+
'ft:gpt-4o-2024-08-06:manifold-markets:generate-patch-batch2:AKYtDIhk',
|
|
33
|
+
} as const
|
|
34
|
+
export type OpenAIModel = (typeof openaiModels)[keyof typeof openaiModels]
|
|
35
|
+
|
|
36
|
+
export const openrouterModels = {
|
|
37
|
+
openrouter_claude_sonnet_4_5: 'anthropic/claude-sonnet-4.5',
|
|
38
|
+
openrouter_claude_sonnet_4: 'anthropic/claude-4-sonnet-20250522',
|
|
39
|
+
openrouter_claude_opus_4: 'anthropic/claude-opus-4.1',
|
|
40
|
+
openrouter_claude_3_5_haiku: 'anthropic/claude-3.5-haiku-20241022',
|
|
41
|
+
openrouter_claude_3_5_sonnet: 'anthropic/claude-3.5-sonnet-20240620',
|
|
42
|
+
openrouter_gpt4o: 'openai/gpt-4o-2024-11-20',
|
|
43
|
+
openrouter_gpt5: 'openai/gpt-5.1',
|
|
44
|
+
openrouter_gpt5_chat: 'openai/gpt-5.1-chat',
|
|
45
|
+
openrouter_gpt4o_mini: 'openai/gpt-4o-mini-2024-07-18',
|
|
46
|
+
openrouter_gpt4_1_nano: 'openai/gpt-4.1-nano',
|
|
47
|
+
openrouter_o3_mini: 'openai/o3-mini-2025-01-31',
|
|
48
|
+
openrouter_gemini2_5_pro_preview: 'google/gemini-2.5-pro',
|
|
49
|
+
openrouter_gemini2_5_flash: 'google/gemini-2.5-flash',
|
|
50
|
+
openrouter_gemini2_5_flash_thinking:
|
|
51
|
+
'google/gemini-2.5-flash-preview:thinking',
|
|
52
|
+
openrouter_grok_4: 'x-ai/grok-4-07-09',
|
|
53
|
+
} as const
|
|
54
|
+
export type openrouterModel =
|
|
55
|
+
(typeof openrouterModels)[keyof typeof openrouterModels]
|
|
56
|
+
|
|
57
|
+
export const openCodeZenModels = {
|
|
58
|
+
opencode_kimi_k2_6: 'opencode/kimi-k2.6',
|
|
59
|
+
} as const
|
|
60
|
+
export type OpenCodeZenModel =
|
|
61
|
+
(typeof openCodeZenModels)[keyof typeof openCodeZenModels]
|
|
62
|
+
|
|
63
|
+
export const deepseekModels = {
|
|
64
|
+
deepseekChat: 'deepseek-chat',
|
|
65
|
+
deepseekReasoner: 'deepseek-reasoner',
|
|
66
|
+
deepseekV4ProDirect: 'deepseek-v4-pro',
|
|
67
|
+
deepseekV4Pro: 'deepseek/deepseek-v4-pro',
|
|
68
|
+
deepseekV4FlashDirect: 'deepseek-v4-flash',
|
|
69
|
+
deepseekV4Flash: 'deepseek/deepseek-v4-flash',
|
|
70
|
+
} as const
|
|
71
|
+
export type DeepseekModel = (typeof deepseekModels)[keyof typeof deepseekModels]
|
|
72
|
+
|
|
73
|
+
export const mimoModels = {
|
|
74
|
+
mimoV25Direct: 'mimo-v2.5',
|
|
75
|
+
mimoV25: 'mimo/mimo-v2.5',
|
|
76
|
+
mimoV25ProDirect: 'mimo-v2.5-pro',
|
|
77
|
+
mimoV25Pro: 'mimo/mimo-v2.5-pro',
|
|
78
|
+
} as const
|
|
79
|
+
export type MimoModel = (typeof mimoModels)[keyof typeof mimoModels]
|
|
80
|
+
|
|
81
|
+
export const minimaxModels = {
|
|
82
|
+
minimaxM3: 'minimax/minimax-m3',
|
|
83
|
+
} as const
|
|
84
|
+
export type MiniMaxModel = (typeof minimaxModels)[keyof typeof minimaxModels]
|
|
85
|
+
|
|
86
|
+
export const moonshotModels = {
|
|
87
|
+
kimiK26: 'moonshotai/kimi-k2.6',
|
|
88
|
+
kimiK27Code: 'moonshotai/kimi-k2.7-code',
|
|
89
|
+
} as const
|
|
90
|
+
export type MoonshotModel = (typeof moonshotModels)[keyof typeof moonshotModels]
|
|
91
|
+
|
|
92
|
+
// Vertex uses "endpoint IDs" for finetuned models, which are just integers
|
|
93
|
+
export const finetunedVertexModels = {
|
|
94
|
+
ft_filepicker_003: '196166068534771712',
|
|
95
|
+
ft_filepicker_005: '8493203957034778624',
|
|
96
|
+
ft_filepicker_007: '2589952415784501248',
|
|
97
|
+
ft_filepicker_topk_001: '3676445825887633408',
|
|
98
|
+
ft_filepicker_008: '2672143108984012800',
|
|
99
|
+
ft_filepicker_topk_002: '1694861989844615168',
|
|
100
|
+
ft_filepicker_010: '3808739064941641728',
|
|
101
|
+
ft_filepicker_010_epoch_2: '6231675664466968576',
|
|
102
|
+
ft_filepicker_topk_003: '1502192368286171136',
|
|
103
|
+
} as const
|
|
104
|
+
export const finetunedVertexModelNames: Record<string, string> = {
|
|
105
|
+
[finetunedVertexModels.ft_filepicker_003]: 'ft_filepicker_003',
|
|
106
|
+
[finetunedVertexModels.ft_filepicker_005]: 'ft_filepicker_005',
|
|
107
|
+
[finetunedVertexModels.ft_filepicker_007]: 'ft_filepicker_007',
|
|
108
|
+
[finetunedVertexModels.ft_filepicker_topk_001]: 'ft_filepicker_topk_001',
|
|
109
|
+
[finetunedVertexModels.ft_filepicker_008]: 'ft_filepicker_008',
|
|
110
|
+
[finetunedVertexModels.ft_filepicker_topk_002]: 'ft_filepicker_topk_002',
|
|
111
|
+
[finetunedVertexModels.ft_filepicker_010]: 'ft_filepicker_010',
|
|
112
|
+
[finetunedVertexModels.ft_filepicker_010_epoch_2]:
|
|
113
|
+
'ft_filepicker_010_epoch_2',
|
|
114
|
+
[finetunedVertexModels.ft_filepicker_topk_003]: 'ft_filepicker_topk_003',
|
|
115
|
+
}
|
|
116
|
+
export type FinetunedVertexModel =
|
|
117
|
+
(typeof finetunedVertexModels)[keyof typeof finetunedVertexModels]
|
|
118
|
+
|
|
119
|
+
export const models = {
|
|
120
|
+
...openaiModels,
|
|
121
|
+
...deepseekModels,
|
|
122
|
+
...mimoModels,
|
|
123
|
+
...minimaxModels,
|
|
124
|
+
...openrouterModels,
|
|
125
|
+
...finetunedVertexModels,
|
|
126
|
+
} as const
|
|
127
|
+
|
|
128
|
+
export const shortModelNames = {
|
|
129
|
+
'gemini-2.5-pro': models.openrouter_gemini2_5_pro_preview,
|
|
130
|
+
'flash-2.5': models.openrouter_gemini2_5_flash,
|
|
131
|
+
'opus-4': models.openrouter_claude_opus_4,
|
|
132
|
+
'sonnet-4.5': models.openrouter_claude_sonnet_4_5,
|
|
133
|
+
'sonnet-4': models.openrouter_claude_sonnet_4,
|
|
134
|
+
'sonnet-3.7': models.openrouter_claude_sonnet_4,
|
|
135
|
+
'sonnet-3.6': models.openrouter_claude_3_5_sonnet,
|
|
136
|
+
'sonnet-3.5': models.openrouter_claude_3_5_sonnet,
|
|
137
|
+
'gpt-4.1': models.gpt4_1,
|
|
138
|
+
'o3-mini': models.o3mini,
|
|
139
|
+
o3: models.o3,
|
|
140
|
+
'o4-mini': models.o4mini,
|
|
141
|
+
'o3-pro': models.o3pro,
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
export const providerModelNames = {
|
|
145
|
+
...Object.fromEntries(
|
|
146
|
+
Object.entries(openaiModels).map(([name, model]) => [
|
|
147
|
+
model,
|
|
148
|
+
'openai' as const,
|
|
149
|
+
]),
|
|
150
|
+
),
|
|
151
|
+
...Object.fromEntries(
|
|
152
|
+
Object.entries(openrouterModels).map(([name, model]) => [
|
|
153
|
+
model,
|
|
154
|
+
'openrouter' as const,
|
|
155
|
+
]),
|
|
156
|
+
),
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
export type Model = (typeof models)[keyof typeof models] | (string & {})
|
|
160
|
+
|
|
161
|
+
const explicitlyDefinedModels = new Set<string>(Object.values(models))
|
|
162
|
+
|
|
163
|
+
/** Whether `model` is one of the statically configured model IDs. */
|
|
164
|
+
export function isExplicitlyDefinedModel(model: Model): boolean {
|
|
165
|
+
return explicitlyDefinedModels.has(model)
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
const nonCacheableModels = [
|
|
169
|
+
models.openrouter_grok_4,
|
|
170
|
+
] satisfies string[] as string[]
|
|
171
|
+
export function supportsCacheControl(model: Model): boolean {
|
|
172
|
+
if (model.startsWith('openai/')) {
|
|
173
|
+
return true
|
|
174
|
+
}
|
|
175
|
+
if (model.startsWith('anthropic/')) {
|
|
176
|
+
return true
|
|
177
|
+
}
|
|
178
|
+
if (!isExplicitlyDefinedModel(model)) {
|
|
179
|
+
// Default to no cache control for unknown models
|
|
180
|
+
return false
|
|
181
|
+
}
|
|
182
|
+
return !nonCacheableModels.includes(model)
|
|
183
|
+
}
|
|
184
|
+
|
|
185
|
+
/**
|
|
186
|
+
* Claude 4.6+ (including Fable) rejects requests whose final message is an
|
|
187
|
+
* assistant message ("This model does not support assistant message prefill"),
|
|
188
|
+
* e.g. when routed through Amazon Bedrock. Older Claude models and other
|
|
189
|
+
* providers accept a trailing assistant message as a prefill to continue from.
|
|
190
|
+
*/
|
|
191
|
+
export function supportsAssistantPrefill(model: Model): boolean {
|
|
192
|
+
const match = model.match(/claude-(?:[a-z]+-)?(\d+(?:[.-]\d+)?)/)
|
|
193
|
+
if (!match) {
|
|
194
|
+
return true
|
|
195
|
+
}
|
|
196
|
+
const version = parseFloat(match[1].replace('-', '.'))
|
|
197
|
+
return version < 4.6
|
|
198
|
+
}
|
|
199
|
+
|
|
200
|
+
/**
|
|
201
|
+
* Token budget a model's conversation may reach before context-pruner
|
|
202
|
+
* summarizes it, compared against `agentState.contextTokenCount`.
|
|
203
|
+
*
|
|
204
|
+
* 400k by default: every model we serve has roughly a 1M window, which leaves
|
|
205
|
+
* ample headroom — including for the estimator being a GPT-4o count applied to
|
|
206
|
+
* models with their own tokenizers, so it can run under the provider's real
|
|
207
|
+
* number.
|
|
208
|
+
*
|
|
209
|
+
* The one exception is the 262,144-token Kimi K2.7 Code below, confirmed by a
|
|
210
|
+
* provider rejection quoted in anvil-models.ts. It gets 250k, the value it
|
|
211
|
+
* has been running on in prod. That margin is thin for exactly the estimator
|
|
212
|
+
* reason above, so it is the number to revisit if this model starts hitting
|
|
213
|
+
* context rejections. (The HY3 and Ling 3.0 Flash entries that used to sit
|
|
214
|
+
* alongside it went with those models on 2026-08-07. Kimi K3 Eco is NOT an
|
|
215
|
+
* exception: CrofAI serves it at a 1M context.)
|
|
216
|
+
*
|
|
217
|
+
* MiniMax M3 is deliberately NOT an exception: its real enforced limit is
|
|
218
|
+
* 524,288, not the 1,048,576 OpenRouter advertises (Fireworks rejects with
|
|
219
|
+
* "model maximum context length: 524287"), but 400k is still under it.
|
|
220
|
+
*
|
|
221
|
+
* The return type is the two budgets rather than `number` on purpose — base2
|
|
222
|
+
* pre-serializes one handleSteps variant per budget, so a third value has to be
|
|
223
|
+
* a compile error there rather than silently falling through to 400k.
|
|
224
|
+
*/
|
|
225
|
+
const SMALL_CONTEXT_MODELS: ReadonlySet<string> = new Set([
|
|
226
|
+
moonshotModels.kimiK27Code,
|
|
227
|
+
])
|
|
228
|
+
|
|
229
|
+
export function contextPrunerBudgetForModel(model: Model): 250_000 | 400_000 {
|
|
230
|
+
return SMALL_CONTEXT_MODELS.has(model) ? 250_000 : 400_000
|
|
231
|
+
}
|
|
232
|
+
|
|
233
|
+
export function getModelFromShortName(
|
|
234
|
+
modelName: string | undefined,
|
|
235
|
+
): Model | undefined {
|
|
236
|
+
if (!modelName) return undefined
|
|
237
|
+
if (modelName && !(modelName in shortModelNames)) {
|
|
238
|
+
throw new Error(
|
|
239
|
+
`Unknown model: ${modelName}. Please use a valid model. Valid models are: ${Object.keys(
|
|
240
|
+
shortModelNames,
|
|
241
|
+
).join(', ')}`,
|
|
242
|
+
)
|
|
243
|
+
}
|
|
244
|
+
|
|
245
|
+
return shortModelNames[modelName as keyof typeof shortModelNames]
|
|
246
|
+
}
|
|
247
|
+
|
|
248
|
+
export const providerDomains = {
|
|
249
|
+
google: 'google.com',
|
|
250
|
+
anthropic: 'anthropic.com',
|
|
251
|
+
openai: 'chatgpt.com',
|
|
252
|
+
deepseek: 'deepseek.com',
|
|
253
|
+
minimax: 'minimax.io',
|
|
254
|
+
mimo: 'xiaomi.com',
|
|
255
|
+
tencent: 'tencent.com',
|
|
256
|
+
xai: 'x.ai',
|
|
257
|
+
} as const
|
|
258
|
+
|
|
259
|
+
export function getLogoForModel(modelName: string): string | undefined {
|
|
260
|
+
let domain: string | undefined
|
|
261
|
+
|
|
262
|
+
if (Object.values(openaiModels).includes(modelName as OpenAIModel))
|
|
263
|
+
domain = providerDomains.openai
|
|
264
|
+
else if (Object.values(deepseekModels).includes(modelName as DeepseekModel))
|
|
265
|
+
domain = providerDomains.deepseek
|
|
266
|
+
else if (Object.values(minimaxModels).includes(modelName as MiniMaxModel))
|
|
267
|
+
domain = providerDomains.minimax
|
|
268
|
+
else if (Object.values(mimoModels).includes(modelName as MimoModel))
|
|
269
|
+
domain = providerDomains.mimo
|
|
270
|
+
else if (modelName.startsWith('tencent/')) domain = providerDomains.tencent
|
|
271
|
+
else if (modelName.includes('claude')) domain = providerDomains.anthropic
|
|
272
|
+
else if (modelName.includes('grok')) domain = providerDomains.xai
|
|
273
|
+
|
|
274
|
+
return domain
|
|
275
|
+
? `https://www.google.com/s2/favicons?domain=${domain}&sz=256`
|
|
276
|
+
: undefined
|
|
277
|
+
}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
// HTTP-Referer is required for OpenRouter to create the app attribution page.
|
|
2
|
+
// Categories are capped at two per request (ten per app); unknown values are
|
|
3
|
+
// silently ignored, so keep additions deliberate and spelling exact.
|
|
4
|
+
export const OPENROUTER_DEFAULT_HEADERS = {
|
|
5
|
+
'HTTP-Referer': 'https://anvil.com',
|
|
6
|
+
'X-OpenRouter-Title': 'Anvil',
|
|
7
|
+
'X-OpenRouter-Categories': 'cli-agent,cloud-agent',
|
|
8
|
+
} as const
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
export const STOP_MARKER = '[' + 'END]'
|
|
2
|
+
export const FIND_FILES_MARKER = '[' + 'FIND_FILES_PLEASE]'
|
|
3
|
+
|
|
4
|
+
// Directory where agent template override files are stored
|
|
5
|
+
export const AGENT_TEMPLATES_DIR = '.agents/'
|
|
6
|
+
export const AGENT_DEFINITION_FILE = 'agent-definition.d.ts'
|
|
7
|
+
|
|
8
|
+
export const API_KEY_ENV_VAR = 'ANVIL_API_KEY'
|
|
9
|
+
|
|
10
|
+
export const INVALID_AUTH_TOKEN_MESSAGE =
|
|
11
|
+
'Invalid auth token. You may have been logged out from the web portal. Please log in again.'
|
|
12
|
+
|
|
13
|
+
export const DEFAULT_IGNORED_PATHS = [
|
|
14
|
+
'.git',
|
|
15
|
+
'.env',
|
|
16
|
+
'.env.*',
|
|
17
|
+
'*.min.*',
|
|
18
|
+
'node_modules',
|
|
19
|
+
'venv',
|
|
20
|
+
'virtualenv',
|
|
21
|
+
'.venv',
|
|
22
|
+
'.virtualenv',
|
|
23
|
+
'__pycache__',
|
|
24
|
+
'*.egg-info/',
|
|
25
|
+
'*.pyc',
|
|
26
|
+
'.DS_Store',
|
|
27
|
+
'.pytest_cache',
|
|
28
|
+
'.mypy_cache',
|
|
29
|
+
'.ruff_cache',
|
|
30
|
+
'.next',
|
|
31
|
+
'package-lock.json',
|
|
32
|
+
'bun.lockb',
|
|
33
|
+
]
|
|
34
|
+
|
|
35
|
+
// Special message content tags indicating specific server states
|
|
36
|
+
export const ASKED_CONFIG = 'asked_config'
|
|
37
|
+
export const SHOULD_ASK_CONFIG = 'should_ask_config'
|
|
38
|
+
export const ONE_TIME_TAGS = [] as const
|
|
39
|
+
export const ONE_TIME_LABELS = [
|
|
40
|
+
...ONE_TIME_TAGS,
|
|
41
|
+
ASKED_CONFIG,
|
|
42
|
+
SHOULD_ASK_CONFIG,
|
|
43
|
+
] as const
|
|
44
|
+
|
|
45
|
+
export const FILE_READ_STATUS = {
|
|
46
|
+
DOES_NOT_EXIST: '[FILE_DOES_NOT_EXIST]',
|
|
47
|
+
IGNORED: '[BLOCKED]',
|
|
48
|
+
TEMPLATE: '[TEMPLATE]',
|
|
49
|
+
OUTSIDE_PROJECT: '[FILE_OUTSIDE_PROJECT]',
|
|
50
|
+
TOO_LARGE: '[FILE_TOO_LARGE]',
|
|
51
|
+
ERROR: '[FILE_READ_ERROR]',
|
|
52
|
+
} as const
|
|
53
|
+
|
|
54
|
+
export const HIDDEN_FILE_READ_STATUS = [
|
|
55
|
+
FILE_READ_STATUS.DOES_NOT_EXIST,
|
|
56
|
+
FILE_READ_STATUS.IGNORED,
|
|
57
|
+
FILE_READ_STATUS.OUTSIDE_PROJECT,
|
|
58
|
+
FILE_READ_STATUS.TOO_LARGE,
|
|
59
|
+
FILE_READ_STATUS.ERROR,
|
|
60
|
+
]
|
|
61
|
+
|
|
62
|
+
export function toOptionalFile(file: string | null) {
|
|
63
|
+
if (file === null) return null
|
|
64
|
+
return HIDDEN_FILE_READ_STATUS.some((status) => file.startsWith(status))
|
|
65
|
+
? null
|
|
66
|
+
: file
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
export const TEST_USER_ID = 'test-user-id'
|