@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,526 @@
|
|
|
1
|
+
import { describe, expect, it } from 'bun:test'
|
|
2
|
+
|
|
3
|
+
import {
|
|
4
|
+
assessAnvilTrust,
|
|
5
|
+
ANVIL_TRUST_FALLBACK_LEVEL,
|
|
6
|
+
ANVIL_TRUST_LEVELS,
|
|
7
|
+
ANVIL_TRUST_EARNED,
|
|
8
|
+
ANVIL_TRUST_LIMITS,
|
|
9
|
+
ANVIL_TRUST_THRESHOLDS,
|
|
10
|
+
anvilTrustLimits,
|
|
11
|
+
isAtLeastTrustLevel,
|
|
12
|
+
toAnvilStandingInfo,
|
|
13
|
+
type AnvilTrustSignals,
|
|
14
|
+
} from '../constants/anvil-trust'
|
|
15
|
+
|
|
16
|
+
const NOW = new Date('2026-08-11T00:00:00Z')
|
|
17
|
+
const DAY_MS = 24 * 60 * 60 * 1000
|
|
18
|
+
|
|
19
|
+
function daysAgo(days: number): Date {
|
|
20
|
+
return new Date(NOW.getTime() - days * DAY_MS)
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
/** An account we know nothing about: every optional signal unknown. This is
|
|
24
|
+
* what most pre-provenance accounts actually look like. */
|
|
25
|
+
const UNKNOWN: AnvilTrustSignals = {
|
|
26
|
+
accountCreatedAt: null,
|
|
27
|
+
githubAccountCreatedAt: null,
|
|
28
|
+
githubOldestRepoCreatedAt: null,
|
|
29
|
+
githubPublicRepos: null,
|
|
30
|
+
githubFollowers: null,
|
|
31
|
+
githubTwoFactorEnabled: null,
|
|
32
|
+
activeDays: 0,
|
|
33
|
+
approvedBounties: 0,
|
|
34
|
+
qualifiedReferrals: 0,
|
|
35
|
+
hasPaid: false,
|
|
36
|
+
signupPrivacySignals: null,
|
|
37
|
+
signupIpSource: null,
|
|
38
|
+
signupPrefixAccountCount: null,
|
|
39
|
+
mailboxAccountCount: null,
|
|
40
|
+
hasUnreversedBanEvent: false,
|
|
41
|
+
privacyFlaggedAt: null,
|
|
42
|
+
privacyCorroboratedAt: null,
|
|
43
|
+
thirdPartyClientAt: null,
|
|
44
|
+
currentRiskScore: null,
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
function signals(overrides: Partial<AnvilTrustSignals>) {
|
|
48
|
+
return { ...UNKNOWN, ...overrides }
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
describe('level ordering', () => {
|
|
52
|
+
it('orders least- to most-established', () => {
|
|
53
|
+
expect(ANVIL_TRUST_LEVELS).toEqual([
|
|
54
|
+
'new',
|
|
55
|
+
'verified',
|
|
56
|
+
'established',
|
|
57
|
+
'core',
|
|
58
|
+
])
|
|
59
|
+
})
|
|
60
|
+
|
|
61
|
+
it('compares by position, not alphabetically', () => {
|
|
62
|
+
expect(isAtLeastTrustLevel('core', 'new')).toBe(true)
|
|
63
|
+
expect(isAtLeastTrustLevel('new', 'verified')).toBe(false)
|
|
64
|
+
expect(isAtLeastTrustLevel('established', 'established')).toBe(true)
|
|
65
|
+
})
|
|
66
|
+
})
|
|
67
|
+
|
|
68
|
+
describe('limit matrix', () => {
|
|
69
|
+
it('reproduces the pre-existing flat limits at established/full', () => {
|
|
70
|
+
// This is the safety property of the whole rollout: the population that
|
|
71
|
+
// already looked like ordinary heavy users must keep exactly what it had.
|
|
72
|
+
const full = anvilTrustLimits('full', 'established')
|
|
73
|
+
expect(full.messagesPerDay).toBe(5_000)
|
|
74
|
+
expect(full.messagesPer5Hours).toBe(3_000)
|
|
75
|
+
expect(full.dailySpendUsd).toBe(50)
|
|
76
|
+
expect(full.premiumSessionsPerDay).toBe(6)
|
|
77
|
+
|
|
78
|
+
const limited = anvilTrustLimits('limited', 'established')
|
|
79
|
+
expect(limited.messagesPerDay).toBe(3_000)
|
|
80
|
+
expect(limited.messagesPer5Hours).toBe(2_000)
|
|
81
|
+
})
|
|
82
|
+
|
|
83
|
+
it('is monotonic in level on every axis, in both regions', () => {
|
|
84
|
+
for (const tier of ['full', 'limited'] as const) {
|
|
85
|
+
for (let i = 1; i < ANVIL_TRUST_LEVELS.length; i++) {
|
|
86
|
+
const lower = ANVIL_TRUST_LIMITS[tier][ANVIL_TRUST_LEVELS[i - 1]]
|
|
87
|
+
const higher = ANVIL_TRUST_LIMITS[tier][ANVIL_TRUST_LEVELS[i]]
|
|
88
|
+
for (const key of Object.keys(lower) as (keyof typeof lower)[]) {
|
|
89
|
+
expect(higher[key]).toBeGreaterThanOrEqual(lower[key])
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
})
|
|
94
|
+
|
|
95
|
+
it('does not scale session-shape controls, only cost controls', () => {
|
|
96
|
+
// Browser sessions and Desktop tabs were deliberately removed: an open
|
|
97
|
+
// session costs nothing until it generates, and the generating is already
|
|
98
|
+
// bounded. If either reappears here, something re-added a limit that takes
|
|
99
|
+
// visible capability from new users and saves nothing.
|
|
100
|
+
expect(Object.keys(ANVIL_TRUST_LIMITS.full.new).sort()).toEqual([
|
|
101
|
+
'dailySpendUsd',
|
|
102
|
+
'messagesPer5Hours',
|
|
103
|
+
'messagesPerDay',
|
|
104
|
+
'premiumSessionsPerDay',
|
|
105
|
+
'userMessagesPerDay',
|
|
106
|
+
])
|
|
107
|
+
})
|
|
108
|
+
|
|
109
|
+
it('never lets the limited tier reach a premium session', () => {
|
|
110
|
+
// The model gate already refuses it; a non-zero number here would be a
|
|
111
|
+
// promise the rest of the system cannot keep.
|
|
112
|
+
for (const level of ANVIL_TRUST_LEVELS) {
|
|
113
|
+
expect(ANVIL_TRUST_LIMITS.limited[level].premiumSessionsPerDay).toBe(0)
|
|
114
|
+
}
|
|
115
|
+
})
|
|
116
|
+
|
|
117
|
+
it('lets a limited-region core member beat a full-region verified user', () => {
|
|
118
|
+
// The promise the region split has to make to a real developer abroad.
|
|
119
|
+
const limitedCore = anvilTrustLimits('limited', 'core')
|
|
120
|
+
const fullVerified = anvilTrustLimits('full', 'verified')
|
|
121
|
+
expect(limitedCore.messagesPerDay).toBeGreaterThan(
|
|
122
|
+
fullVerified.messagesPerDay,
|
|
123
|
+
)
|
|
124
|
+
expect(limitedCore.userMessagesPerDay).toBeGreaterThan(
|
|
125
|
+
fullVerified.userMessagesPerDay,
|
|
126
|
+
)
|
|
127
|
+
expect(limitedCore.dailySpendUsd).toBeGreaterThan(
|
|
128
|
+
fullVerified.dailySpendUsd,
|
|
129
|
+
)
|
|
130
|
+
})
|
|
131
|
+
|
|
132
|
+
it('keeps every new-account daily budget above the measured p90', () => {
|
|
133
|
+
// Sizing anchor from free-mode-rate-limiter.ts: full-tier per-user-per-day
|
|
134
|
+
// p90 is 837. A brand-new account doing genuinely heavy work must fit.
|
|
135
|
+
expect(
|
|
136
|
+
anvilTrustLimits('full', 'new').messagesPerDay,
|
|
137
|
+
).toBeGreaterThanOrEqual(837)
|
|
138
|
+
})
|
|
139
|
+
})
|
|
140
|
+
|
|
141
|
+
describe('scoring', () => {
|
|
142
|
+
it('leaves an unknown account at the floor', () => {
|
|
143
|
+
const result = assessAnvilTrust(UNKNOWN, NOW)
|
|
144
|
+
expect(result.level).toBe('new')
|
|
145
|
+
expect(result.score).toBe(0)
|
|
146
|
+
expect(result.cappedBy).toBeNull()
|
|
147
|
+
})
|
|
148
|
+
|
|
149
|
+
it('treats null signals as unknown, never as suspicious', () => {
|
|
150
|
+
// A pre-provenance account (null everything) must score the same as one
|
|
151
|
+
// explicitly checked and found to share nothing.
|
|
152
|
+
const unknownProvenance = assessAnvilTrust(
|
|
153
|
+
signals({ githubAccountCreatedAt: daysAgo(400) }),
|
|
154
|
+
NOW,
|
|
155
|
+
)
|
|
156
|
+
const cleanProvenance = assessAnvilTrust(
|
|
157
|
+
signals({
|
|
158
|
+
githubAccountCreatedAt: daysAgo(400),
|
|
159
|
+
signupPrefixAccountCount: 1,
|
|
160
|
+
mailboxAccountCount: 1,
|
|
161
|
+
}),
|
|
162
|
+
NOW,
|
|
163
|
+
)
|
|
164
|
+
expect(unknownProvenance.level).toBe(cleanProvenance.level)
|
|
165
|
+
expect(unknownProvenance.cappedBy).toBeNull()
|
|
166
|
+
})
|
|
167
|
+
|
|
168
|
+
it('reaches established on GitHub age plus ordinary account history', () => {
|
|
169
|
+
const result = assessAnvilTrust(
|
|
170
|
+
signals({
|
|
171
|
+
accountCreatedAt: daysAgo(120),
|
|
172
|
+
githubAccountCreatedAt: daysAgo(3 * 365 + 10),
|
|
173
|
+
githubOldestRepoCreatedAt: daysAgo(400),
|
|
174
|
+
githubPublicRepos: 12,
|
|
175
|
+
activeDays: 40,
|
|
176
|
+
}),
|
|
177
|
+
NOW,
|
|
178
|
+
)
|
|
179
|
+
// 10 linked + 20 age + 10 repo + 5 repos + 15 acct age + 10 active
|
|
180
|
+
expect(result.score).toBe(70)
|
|
181
|
+
expect(result.level).toBe('established')
|
|
182
|
+
})
|
|
183
|
+
|
|
184
|
+
it('lets a brand-new limited-region account climb with earned signals alone', () => {
|
|
185
|
+
// The route that does not require owning an aged GitHub account: this is
|
|
186
|
+
// what the Earn page has to be able to promise.
|
|
187
|
+
const result = assessAnvilTrust(
|
|
188
|
+
signals({
|
|
189
|
+
accountCreatedAt: daysAgo(10),
|
|
190
|
+
approvedBounties: 4,
|
|
191
|
+
qualifiedReferrals: 5,
|
|
192
|
+
}),
|
|
193
|
+
NOW,
|
|
194
|
+
)
|
|
195
|
+
// 5 acct age + 20 bounties + 15 referrals
|
|
196
|
+
expect(result.score).toBe(40)
|
|
197
|
+
expect(result.level).toBe('verified')
|
|
198
|
+
})
|
|
199
|
+
|
|
200
|
+
it('caps bounty and referral contributions', () => {
|
|
201
|
+
const capped = assessAnvilTrust(
|
|
202
|
+
signals({ approvedBounties: 50, qualifiedReferrals: 50 }),
|
|
203
|
+
NOW,
|
|
204
|
+
)
|
|
205
|
+
expect(capped.score).toBe(
|
|
206
|
+
ANVIL_TRUST_EARNED.BOUNTY_POINTS * ANVIL_TRUST_EARNED.BOUNTY_CAP +
|
|
207
|
+
ANVIL_TRUST_EARNED.REFERRAL_POINTS *
|
|
208
|
+
ANVIL_TRUST_EARNED.REFERRAL_CAP,
|
|
209
|
+
)
|
|
210
|
+
})
|
|
211
|
+
|
|
212
|
+
it('lets contribution alone reach core, with no GitHub and no payment', () => {
|
|
213
|
+
// THE property the earned caps exist for. Before they were raised this
|
|
214
|
+
// route peaked at 70 against a threshold of 75, so `core` was reachable
|
|
215
|
+
// only by owning an aged GitHub account or by paying — which is backwards
|
|
216
|
+
// for a program meant to give developers in unsupported regions a way to
|
|
217
|
+
// raise their own limits.
|
|
218
|
+
const earned = assessAnvilTrust(
|
|
219
|
+
signals({
|
|
220
|
+
accountCreatedAt: daysAgo(120),
|
|
221
|
+
activeDays: 40,
|
|
222
|
+
approvedBounties: ANVIL_TRUST_EARNED.BOUNTY_CAP,
|
|
223
|
+
qualifiedReferrals: ANVIL_TRUST_EARNED.REFERRAL_CAP,
|
|
224
|
+
signupPrivacySignals: [],
|
|
225
|
+
signupIpSource: 'cloudflare',
|
|
226
|
+
}),
|
|
227
|
+
NOW,
|
|
228
|
+
)
|
|
229
|
+
expect(earned.factors.map((f) => f.id)).not.toContain('github_linked')
|
|
230
|
+
expect(earned.score).toBeGreaterThanOrEqual(ANVIL_TRUST_THRESHOLDS.core)
|
|
231
|
+
expect(earned.level).toBe('core')
|
|
232
|
+
})
|
|
233
|
+
|
|
234
|
+
it('keeps paying past the point someone has proved they are real', () => {
|
|
235
|
+
// A flat incentive is not an incentive. The tenth referral and the sixth
|
|
236
|
+
// bounty must still be worth something, or the program stops pulling
|
|
237
|
+
// exactly where it should pull hardest.
|
|
238
|
+
const few = assessAnvilTrust(
|
|
239
|
+
signals({ approvedBounties: 4, qualifiedReferrals: 5 }),
|
|
240
|
+
NOW,
|
|
241
|
+
)
|
|
242
|
+
const many = assessAnvilTrust(
|
|
243
|
+
signals({ approvedBounties: 6, qualifiedReferrals: 10 }),
|
|
244
|
+
NOW,
|
|
245
|
+
)
|
|
246
|
+
expect(many.score).toBeGreaterThan(few.score)
|
|
247
|
+
})
|
|
248
|
+
|
|
249
|
+
it('never returns a score outside 0..100', () => {
|
|
250
|
+
const maxed = assessAnvilTrust(
|
|
251
|
+
signals({
|
|
252
|
+
accountCreatedAt: daysAgo(1000),
|
|
253
|
+
githubAccountCreatedAt: daysAgo(4000),
|
|
254
|
+
githubOldestRepoCreatedAt: daysAgo(3000),
|
|
255
|
+
githubPublicRepos: 100,
|
|
256
|
+
githubFollowers: 500,
|
|
257
|
+
githubTwoFactorEnabled: true,
|
|
258
|
+
activeDays: 300,
|
|
259
|
+
approvedBounties: 20,
|
|
260
|
+
qualifiedReferrals: 20,
|
|
261
|
+
hasPaid: true,
|
|
262
|
+
signupPrivacySignals: [],
|
|
263
|
+
signupIpSource: 'cloudflare',
|
|
264
|
+
}),
|
|
265
|
+
NOW,
|
|
266
|
+
)
|
|
267
|
+
expect(maxed.score).toBe(100)
|
|
268
|
+
expect(maxed.level).toBe('core')
|
|
269
|
+
})
|
|
270
|
+
|
|
271
|
+
it('ignores a future-dated timestamp rather than crediting it', () => {
|
|
272
|
+
const skewed = assessAnvilTrust(
|
|
273
|
+
signals({
|
|
274
|
+
githubAccountCreatedAt: new Date(NOW.getTime() + 10 * DAY_MS),
|
|
275
|
+
}),
|
|
276
|
+
NOW,
|
|
277
|
+
)
|
|
278
|
+
// Linked (10) but no age credit.
|
|
279
|
+
expect(skewed.score).toBe(10)
|
|
280
|
+
})
|
|
281
|
+
})
|
|
282
|
+
|
|
283
|
+
describe('caps', () => {
|
|
284
|
+
const HIGH_SCORE: Partial<AnvilTrustSignals> = {
|
|
285
|
+
accountCreatedAt: daysAgo(400),
|
|
286
|
+
githubAccountCreatedAt: daysAgo(2000),
|
|
287
|
+
githubOldestRepoCreatedAt: daysAgo(1000),
|
|
288
|
+
githubPublicRepos: 20,
|
|
289
|
+
githubFollowers: 50,
|
|
290
|
+
githubTwoFactorEnabled: true,
|
|
291
|
+
activeDays: 100,
|
|
292
|
+
approvedBounties: 4,
|
|
293
|
+
}
|
|
294
|
+
|
|
295
|
+
it('caps a live anonymous network at verified however high the score', () => {
|
|
296
|
+
const result = assessAnvilTrust(
|
|
297
|
+
signals({ ...HIGH_SCORE, currentRiskScore: 90 }),
|
|
298
|
+
NOW,
|
|
299
|
+
)
|
|
300
|
+
expect(result.uncappedLevel).toBe('core')
|
|
301
|
+
expect(result.level).toBe('verified')
|
|
302
|
+
expect(result.cappedBy).toBe('anonymous_network')
|
|
303
|
+
})
|
|
304
|
+
|
|
305
|
+
it('does not cap on a low current risk score', () => {
|
|
306
|
+
const result = assessAnvilTrust(
|
|
307
|
+
signals({ ...HIGH_SCORE, currentRiskScore: 10 }),
|
|
308
|
+
NOW,
|
|
309
|
+
)
|
|
310
|
+
expect(result.level).toBe('core')
|
|
311
|
+
expect(result.cappedBy).toBeNull()
|
|
312
|
+
})
|
|
313
|
+
|
|
314
|
+
it('caps a VPN signup at established, not lower', () => {
|
|
315
|
+
const result = assessAnvilTrust(
|
|
316
|
+
signals({ ...HIGH_SCORE, signupPrivacySignals: ['vpn'] }),
|
|
317
|
+
NOW,
|
|
318
|
+
)
|
|
319
|
+
expect(result.level).toBe('established')
|
|
320
|
+
expect(result.cappedBy).toBe('signup_privacy_egress')
|
|
321
|
+
})
|
|
322
|
+
|
|
323
|
+
it('credits a clean signup rather than capping it', () => {
|
|
324
|
+
const result = assessAnvilTrust(
|
|
325
|
+
signals({ ...HIGH_SCORE, signupPrivacySignals: [] }),
|
|
326
|
+
NOW,
|
|
327
|
+
)
|
|
328
|
+
expect(result.cappedBy).toBeNull()
|
|
329
|
+
expect(result.factors.some((f) => f.id === 'clean_signup')).toBe(true)
|
|
330
|
+
})
|
|
331
|
+
|
|
332
|
+
it('applies the lowest cap when several bind', () => {
|
|
333
|
+
const result = assessAnvilTrust(
|
|
334
|
+
signals({
|
|
335
|
+
...HIGH_SCORE,
|
|
336
|
+
signupPrivacySignals: ['vpn'],
|
|
337
|
+
mailboxAccountCount: 5,
|
|
338
|
+
}),
|
|
339
|
+
NOW,
|
|
340
|
+
)
|
|
341
|
+
expect(result.level).toBe('verified')
|
|
342
|
+
expect(result.cappedBy).toBe('shared_mailbox')
|
|
343
|
+
})
|
|
344
|
+
|
|
345
|
+
it('leads the next steps with the cap, since points cannot clear it', () => {
|
|
346
|
+
const result = assessAnvilTrust(
|
|
347
|
+
signals({ ...HIGH_SCORE, currentRiskScore: 90 }),
|
|
348
|
+
NOW,
|
|
349
|
+
)
|
|
350
|
+
expect(result.nextSteps[0]?.id).toBe('cap_anonymous_network')
|
|
351
|
+
expect(result.nextSteps[0]?.label).toMatch(/VPN/i)
|
|
352
|
+
})
|
|
353
|
+
|
|
354
|
+
it('caps an account with unreversed enforcement history', () => {
|
|
355
|
+
const result = assessAnvilTrust(
|
|
356
|
+
signals({ ...HIGH_SCORE, hasUnreversedBanEvent: true }),
|
|
357
|
+
NOW,
|
|
358
|
+
)
|
|
359
|
+
expect(result.level).toBe('verified')
|
|
360
|
+
expect(result.cappedBy).toBe('past_enforcement')
|
|
361
|
+
})
|
|
362
|
+
})
|
|
363
|
+
|
|
364
|
+
describe('next steps', () => {
|
|
365
|
+
it('leads with connecting GitHub for an account that has none', () => {
|
|
366
|
+
const result = assessAnvilTrust(UNKNOWN, NOW)
|
|
367
|
+
expect(result.nextSteps[0]?.id).toBe('connect_github')
|
|
368
|
+
expect(result.nextSteps[0]?.points).toBe(30)
|
|
369
|
+
})
|
|
370
|
+
|
|
371
|
+
it('stops offering steps the user has already exhausted', () => {
|
|
372
|
+
const result = assessAnvilTrust(
|
|
373
|
+
signals({
|
|
374
|
+
approvedBounties: ANVIL_TRUST_EARNED.BOUNTY_CAP,
|
|
375
|
+
qualifiedReferrals: ANVIL_TRUST_EARNED.REFERRAL_CAP,
|
|
376
|
+
}),
|
|
377
|
+
NOW,
|
|
378
|
+
)
|
|
379
|
+
expect(result.nextSteps.map((s) => s.id)).not.toContain('bounties')
|
|
380
|
+
expect(result.nextSteps.map((s) => s.id)).not.toContain('referrals')
|
|
381
|
+
})
|
|
382
|
+
|
|
383
|
+
it('offers the remaining value, not the full value, of a partial step', () => {
|
|
384
|
+
const result = assessAnvilTrust(signals({ approvedBounties: 2 }), NOW)
|
|
385
|
+
const remaining =
|
|
386
|
+
(ANVIL_TRUST_EARNED.BOUNTY_CAP - 2) *
|
|
387
|
+
ANVIL_TRUST_EARNED.BOUNTY_POINTS
|
|
388
|
+
expect(result.nextSteps.find((s) => s.id === 'bounties')?.points).toBe(
|
|
389
|
+
remaining,
|
|
390
|
+
)
|
|
391
|
+
})
|
|
392
|
+
})
|
|
393
|
+
|
|
394
|
+
describe('wire shape', () => {
|
|
395
|
+
it('never puts a raw limit on the wire', () => {
|
|
396
|
+
// A published limit is a published target: the abuse pattern here is
|
|
397
|
+
// sustained pacing just under the caps, so the caps stay server-side. This
|
|
398
|
+
// asserts the payload rather than the component, because the payload is
|
|
399
|
+
// what a future surface would reach for.
|
|
400
|
+
const info = toAnvilStandingInfo(
|
|
401
|
+
assessAnvilTrust(signals({ approvedBounties: 4 }), NOW),
|
|
402
|
+
'limited',
|
|
403
|
+
)
|
|
404
|
+
expect(info).not.toHaveProperty('limits')
|
|
405
|
+
|
|
406
|
+
// Scoped to the distinctive values. Small ones (a $3 spend cap, 6 premium
|
|
407
|
+
// sessions) collide with legitimate point values in the copy — "worth 3
|
|
408
|
+
// points" is not a leaked limit, and asserting on them would fail for the
|
|
409
|
+
// wrong reason.
|
|
410
|
+
const serialized = JSON.stringify(info)
|
|
411
|
+
const distinctive = Object.values(
|
|
412
|
+
anvilTrustLimits('limited', info.level),
|
|
413
|
+
).filter((value) => value >= 100)
|
|
414
|
+
expect(distinctive.length).toBeGreaterThan(0)
|
|
415
|
+
for (const value of distinctive) {
|
|
416
|
+
expect(serialized).not.toContain(String(value))
|
|
417
|
+
}
|
|
418
|
+
expect(info.accessTier).toBe('limited')
|
|
419
|
+
})
|
|
420
|
+
|
|
421
|
+
it('describes each axis in words', () => {
|
|
422
|
+
const info = toAnvilStandingInfo(
|
|
423
|
+
assessAnvilTrust(signals({ approvedBounties: 4 }), NOW),
|
|
424
|
+
'limited',
|
|
425
|
+
)
|
|
426
|
+
expect(info.highlights.map((h) => h.label)).toEqual([
|
|
427
|
+
'Prompts a day',
|
|
428
|
+
'Work per prompt',
|
|
429
|
+
'Premium models',
|
|
430
|
+
])
|
|
431
|
+
for (const highlight of info.highlights) {
|
|
432
|
+
expect(highlight.value).not.toMatch(/\d/)
|
|
433
|
+
}
|
|
434
|
+
})
|
|
435
|
+
|
|
436
|
+
it('frames premium as a region fact where no level can unlock it', () => {
|
|
437
|
+
// Every limited-row level has 0 premium sessions, so calling it a
|
|
438
|
+
// shortfall would send the user chasing points that cannot buy it.
|
|
439
|
+
const limited = toAnvilStandingInfo(
|
|
440
|
+
assessAnvilTrust(signals({ approvedBounties: 4 }), NOW),
|
|
441
|
+
'limited',
|
|
442
|
+
)
|
|
443
|
+
expect(
|
|
444
|
+
limited.highlights.find((h) => h.label === 'Premium models')?.value,
|
|
445
|
+
).toMatch(/region/i)
|
|
446
|
+
|
|
447
|
+
const full = toAnvilStandingInfo(
|
|
448
|
+
assessAnvilTrust(signals({ approvedBounties: 4 }), NOW),
|
|
449
|
+
'full',
|
|
450
|
+
)
|
|
451
|
+
expect(
|
|
452
|
+
full.highlights.find((h) => h.label === 'Premium models')?.value,
|
|
453
|
+
).not.toMatch(/region/i)
|
|
454
|
+
})
|
|
455
|
+
|
|
456
|
+
it('reports the next threshold, and nothing beyond core', () => {
|
|
457
|
+
const verified = toAnvilStandingInfo(
|
|
458
|
+
assessAnvilTrust(
|
|
459
|
+
signals({ approvedBounties: 4, activeDays: 10 }),
|
|
460
|
+
NOW,
|
|
461
|
+
),
|
|
462
|
+
'full',
|
|
463
|
+
)
|
|
464
|
+
expect(verified.level).toBe('verified')
|
|
465
|
+
expect(verified.nextLevel).toBe('established')
|
|
466
|
+
expect(verified.nextLevelAt).toBe(ANVIL_TRUST_THRESHOLDS.established)
|
|
467
|
+
|
|
468
|
+
const core = toAnvilStandingInfo(
|
|
469
|
+
assessAnvilTrust(
|
|
470
|
+
signals({
|
|
471
|
+
accountCreatedAt: daysAgo(400),
|
|
472
|
+
githubAccountCreatedAt: daysAgo(2000),
|
|
473
|
+
githubOldestRepoCreatedAt: daysAgo(1000),
|
|
474
|
+
githubPublicRepos: 20,
|
|
475
|
+
githubFollowers: 50,
|
|
476
|
+
githubTwoFactorEnabled: true,
|
|
477
|
+
activeDays: 100,
|
|
478
|
+
approvedBounties: 4,
|
|
479
|
+
}),
|
|
480
|
+
NOW,
|
|
481
|
+
),
|
|
482
|
+
'full',
|
|
483
|
+
)
|
|
484
|
+
expect(core.level).toBe('core')
|
|
485
|
+
expect(core.nextLevel).toBeNull()
|
|
486
|
+
expect(core.nextLevelAt).toBeNull()
|
|
487
|
+
})
|
|
488
|
+
|
|
489
|
+
it('explains a cap in the copy the client renders', () => {
|
|
490
|
+
const info = toAnvilStandingInfo(
|
|
491
|
+
assessAnvilTrust(
|
|
492
|
+
signals({
|
|
493
|
+
accountCreatedAt: daysAgo(400),
|
|
494
|
+
githubAccountCreatedAt: daysAgo(2000),
|
|
495
|
+
activeDays: 100,
|
|
496
|
+
currentRiskScore: 99,
|
|
497
|
+
}),
|
|
498
|
+
NOW,
|
|
499
|
+
),
|
|
500
|
+
'full',
|
|
501
|
+
)
|
|
502
|
+
expect(info.cappedBy).toBe('anonymous_network')
|
|
503
|
+
expect(info.cappedReason).toMatch(/VPN/i)
|
|
504
|
+
})
|
|
505
|
+
|
|
506
|
+
it('reports no cap when the cap sits at or above the earned level', () => {
|
|
507
|
+
// An account scoring 'new' is not "capped at verified" — nothing bound.
|
|
508
|
+
const info = toAnvilStandingInfo(
|
|
509
|
+
assessAnvilTrust(signals({ currentRiskScore: 99 }), NOW),
|
|
510
|
+
'full',
|
|
511
|
+
)
|
|
512
|
+
expect(info.level).toBe('new')
|
|
513
|
+
expect(info.cappedBy).toBeNull()
|
|
514
|
+
})
|
|
515
|
+
})
|
|
516
|
+
|
|
517
|
+
describe('failure behaviour', () => {
|
|
518
|
+
it('falls back to the level that reproduces the old flat limits', () => {
|
|
519
|
+
// A broken resolver must cost us the enforcement, never the users: if this
|
|
520
|
+
// were 'new', one degraded query would throttle the whole product.
|
|
521
|
+
expect(ANVIL_TRUST_FALLBACK_LEVEL).toBe('established')
|
|
522
|
+
expect(anvilTrustLimits('full', ANVIL_TRUST_FALLBACK_LEVEL)).toEqual(
|
|
523
|
+
anvilTrustLimits('full', 'established'),
|
|
524
|
+
)
|
|
525
|
+
})
|
|
526
|
+
})
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
import { describe, expect, test } from 'bun:test'
|
|
2
|
+
|
|
3
|
+
import {
|
|
4
|
+
DEFAULT_DIRECT_DEEPSEEK_MODEL,
|
|
5
|
+
remapModelForDirectDeepSeek,
|
|
6
|
+
} from '../constants/deepseek-direct'
|
|
7
|
+
|
|
8
|
+
describe('remapModelForDirectDeepSeek', () => {
|
|
9
|
+
test('keeps the model name for DeepSeek lane ids', () => {
|
|
10
|
+
expect(remapModelForDirectDeepSeek('deepseek/deepseek-v4-pro')).toBe(
|
|
11
|
+
'deepseek-v4-pro',
|
|
12
|
+
)
|
|
13
|
+
expect(remapModelForDirectDeepSeek('deepseek/deepseek-v4-flash')).toBe(
|
|
14
|
+
'deepseek-v4-flash',
|
|
15
|
+
)
|
|
16
|
+
})
|
|
17
|
+
|
|
18
|
+
test('normalizes -max context tiers to their base model', () => {
|
|
19
|
+
expect(remapModelForDirectDeepSeek('deepseek/deepseek-v4-pro-max')).toBe(
|
|
20
|
+
'deepseek-v4-pro',
|
|
21
|
+
)
|
|
22
|
+
expect(remapModelForDirectDeepSeek('deepseek/deepseek-v4-flash-max')).toBe(
|
|
23
|
+
'deepseek-v4-flash',
|
|
24
|
+
)
|
|
25
|
+
})
|
|
26
|
+
|
|
27
|
+
test('maps the legacy fireworks lane to flash', () => {
|
|
28
|
+
expect(remapModelForDirectDeepSeek('fireworks/deepseek-v4-flash')).toBe(
|
|
29
|
+
'deepseek-v4-flash',
|
|
30
|
+
)
|
|
31
|
+
})
|
|
32
|
+
|
|
33
|
+
test('falls back to the default model for other providers', () => {
|
|
34
|
+
// The default base agent requests anthropic/claude-opus-5, which DeepSeek
|
|
35
|
+
// rejects outright ("The supported API model names are deepseek-v4-pro or
|
|
36
|
+
// deepseek-v4-flash"). Every non-DeepSeek provider must fall back.
|
|
37
|
+
for (const model of [
|
|
38
|
+
'anthropic/claude-opus-5',
|
|
39
|
+
'openai/gpt-5.4',
|
|
40
|
+
'google/gemini-3.5-flash-lite',
|
|
41
|
+
'minimax/minimax-m3',
|
|
42
|
+
'z-ai/glm-5.2',
|
|
43
|
+
]) {
|
|
44
|
+
expect(remapModelForDirectDeepSeek(model)).toBe(
|
|
45
|
+
DEFAULT_DIRECT_DEEPSEEK_MODEL,
|
|
46
|
+
)
|
|
47
|
+
}
|
|
48
|
+
})
|
|
49
|
+
|
|
50
|
+
test('honors the DEEPSEEK_MODEL override', () => {
|
|
51
|
+
const previous = process.env.DEEPSEEK_MODEL
|
|
52
|
+
process.env.DEEPSEEK_MODEL = 'deepseek-chat'
|
|
53
|
+
try {
|
|
54
|
+
expect(remapModelForDirectDeepSeek('anthropic/claude-opus-5')).toBe(
|
|
55
|
+
'deepseek-chat',
|
|
56
|
+
)
|
|
57
|
+
expect(remapModelForDirectDeepSeek('deepseek/deepseek-v4-pro')).toBe(
|
|
58
|
+
'deepseek-chat',
|
|
59
|
+
)
|
|
60
|
+
} finally {
|
|
61
|
+
if (previous === undefined) {
|
|
62
|
+
delete process.env.DEEPSEEK_MODEL
|
|
63
|
+
} else {
|
|
64
|
+
process.env.DEEPSEEK_MODEL = previous
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
})
|
|
68
|
+
})
|