@alumbwe/anvil 1.0.20 → 1.0.21
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +6 -2
- package/src/agents/bundled-agents.generated.ts +4 -4
- package/src/chat.tsx +1703 -1698
- package/src/cli-args.ts +134 -134
- package/src/components/status-bar.tsx +331 -313
- package/src/hooks/helpers/send-message.ts +663 -654
- package/src/hooks/use-send-message.ts +806 -773
- package/src/index.tsx +473 -473
- package/src/state/chat-store.ts +553 -544
- package/src/utils/create-run-config.ts +121 -121
- package/src/utils/format-compact-number.ts +37 -0
- package/vendor/@anvil/common/package.json +27 -0
- package/vendor/@anvil/common/src/__tests__/agent-validation.test.ts +846 -0
- package/vendor/@anvil/common/src/__tests__/anvil-model-availability.test.ts +101 -0
- package/vendor/@anvil/common/src/__tests__/anvil-models.test.ts +1408 -0
- package/vendor/@anvil/common/src/__tests__/anvil-public-data-use-copy.test.ts +258 -0
- package/vendor/@anvil/common/src/__tests__/anvil-referral-tiers.test.ts +48 -0
- package/vendor/@anvil/common/src/__tests__/anvil-spend-ceilings.test.ts +282 -0
- package/vendor/@anvil/common/src/__tests__/anvil-trust.test.ts +526 -0
- package/vendor/@anvil/common/src/__tests__/deepseek-direct.test.ts +68 -0
- package/vendor/@anvil/common/src/__tests__/disposable-email.test.ts +132 -0
- package/vendor/@anvil/common/src/__tests__/dynamic-agent-template-schema.test.ts +422 -0
- package/vendor/@anvil/common/src/__tests__/env-ci.test.ts +167 -0
- package/vendor/@anvil/common/src/__tests__/env-process.test.ts +145 -0
- package/vendor/@anvil/common/src/__tests__/foreign-client-shipped-agents.test.ts +234 -0
- package/vendor/@anvil/common/src/__tests__/foreign-client-signals.test.ts +379 -0
- package/vendor/@anvil/common/src/__tests__/free-agents.test.ts +807 -0
- package/vendor/@anvil/common/src/__tests__/gravity-capi.test.ts +154 -0
- package/vendor/@anvil/common/src/__tests__/handlesteps-parsing.test.ts +246 -0
- package/vendor/@anvil/common/src/__tests__/kimi-k3-god-only.test.ts +77 -0
- package/vendor/@anvil/common/src/__tests__/model-config.test.ts +89 -0
- package/vendor/@anvil/common/src/__tests__/project-file-tree.test.ts +298 -0
- package/vendor/@anvil/common/src/__tests__/provisioned-model-tiers.test.ts +116 -0
- package/vendor/@anvil/common/src/__tests__/reasoning-effort.test.ts +167 -0
- package/vendor/@anvil/common/src/__tests__/reddit-capi.test.ts +132 -0
- package/vendor/@anvil/common/src/__tests__/response-ad-positions.test.ts +72 -0
- package/vendor/@anvil/common/src/__tests__/user-state.test.ts +30 -0
- package/vendor/@anvil/common/src/actions.ts +215 -0
- package/vendor/@anvil/common/src/analytics-core.ts +69 -0
- package/vendor/@anvil/common/src/analytics.ts +93 -0
- package/vendor/@anvil/common/src/api-keys/constants.ts +26 -0
- package/vendor/@anvil/common/src/browser-actions.ts +413 -0
- package/vendor/@anvil/common/src/constants/__tests__/anvil-onboarding-gate.test.ts +63 -0
- package/vendor/@anvil/common/src/constants/__tests__/anvil-onboarding.test.ts +246 -0
- package/vendor/@anvil/common/src/constants/__tests__/cf-worker-signals.test.ts +106 -0
- package/vendor/@anvil/common/src/constants/agents.ts +99 -0
- package/vendor/@anvil/common/src/constants/analytics-events.ts +435 -0
- package/vendor/@anvil/common/src/constants/anthropic.ts +73 -0
- package/vendor/@anvil/common/src/constants/anvil-data-use.ts +81 -0
- package/vendor/@anvil/common/src/constants/anvil-errors.ts +7 -0
- package/vendor/@anvil/common/src/constants/anvil-gemini-thinker.ts +21 -0
- package/vendor/@anvil/common/src/constants/anvil-model-ids.ts +11 -0
- package/vendor/@anvil/common/src/constants/anvil-models.ts +2130 -0
- package/vendor/@anvil/common/src/constants/anvil-onboarding-gate.ts +55 -0
- package/vendor/@anvil/common/src/constants/anvil-onboarding.ts +307 -0
- package/vendor/@anvil/common/src/constants/anvil-referral-tiers.ts +87 -0
- package/vendor/@anvil/common/src/constants/anvil-signup-block.ts +68 -0
- package/vendor/@anvil/common/src/constants/anvil-spend-ceilings.ts +450 -0
- package/vendor/@anvil/common/src/constants/anvil-trust.ts +976 -0
- package/vendor/@anvil/common/src/constants/auth.ts +18 -0
- package/vendor/@anvil/common/src/constants/byok.ts +2 -0
- package/vendor/@anvil/common/src/constants/cf-worker-signals.ts +132 -0
- package/vendor/@anvil/common/src/constants/composio.ts +34 -0
- package/vendor/@anvil/common/src/constants/deepseek-direct.ts +55 -0
- package/vendor/@anvil/common/src/constants/feedback.ts +13 -0
- package/vendor/@anvil/common/src/constants/foreign-client-signals.ts +272 -0
- package/vendor/@anvil/common/src/constants/free-agents.ts +777 -0
- package/vendor/@anvil/common/src/constants/gemini.ts +15 -0
- package/vendor/@anvil/common/src/constants/grant-priorities.ts +13 -0
- package/vendor/@anvil/common/src/constants/hosts.ts +6 -0
- package/vendor/@anvil/common/src/constants/images.ts +51 -0
- package/vendor/@anvil/common/src/constants/index.ts +7 -0
- package/vendor/@anvil/common/src/constants/knowledge.ts +35 -0
- package/vendor/@anvil/common/src/constants/limits.ts +23 -0
- package/vendor/@anvil/common/src/constants/model-config.ts +277 -0
- package/vendor/@anvil/common/src/constants/openrouter-attribution.ts +8 -0
- package/vendor/@anvil/common/src/constants/paths.ts +69 -0
- package/vendor/@anvil/common/src/constants/provider-routes.ts +317 -0
- package/vendor/@anvil/common/src/constants/reasoning-effort.ts +79 -0
- package/vendor/@anvil/common/src/constants/skills.ts +60 -0
- package/vendor/@anvil/common/src/constants/subscription-plans.ts +49 -0
- package/vendor/@anvil/common/src/constants/ui.ts +25 -0
- package/vendor/@anvil/common/src/env-ci.ts +36 -0
- package/vendor/@anvil/common/src/env-process.ts +95 -0
- package/vendor/@anvil/common/src/env-schema.ts +95 -0
- package/vendor/@anvil/common/src/env.ts +24 -0
- package/vendor/@anvil/common/src/gravity-capi.ts +207 -0
- package/vendor/@anvil/common/src/mcp/client.ts +233 -0
- package/vendor/@anvil/common/src/old-constants.ts +10 -0
- package/vendor/@anvil/common/src/project-file-tree.ts +355 -0
- package/vendor/@anvil/common/src/reddit-capi.ts +254 -0
- package/vendor/@anvil/common/src/schemas/feedback.ts +52 -0
- package/vendor/@anvil/common/src/schemas/logs.ts +66 -0
- package/vendor/@anvil/common/src/templates/agent-validation.ts +392 -0
- package/vendor/@anvil/common/src/templates/initial-agents-dir/LICENSE +202 -0
- package/vendor/@anvil/common/src/templates/initial-agents-dir/README.md +294 -0
- package/vendor/@anvil/common/src/templates/initial-agents-dir/examples/01-basic-diff-reviewer.ts +17 -0
- package/vendor/@anvil/common/src/templates/initial-agents-dir/examples/02-intermediate-git-committer.ts +78 -0
- package/vendor/@anvil/common/src/templates/initial-agents-dir/examples/03-advanced-file-explorer.ts +73 -0
- package/vendor/@anvil/common/src/templates/initial-agents-dir/my-custom-agent.ts +40 -0
- package/vendor/@anvil/common/src/templates/initial-agents-dir/package.json +6 -0
- package/vendor/@anvil/common/src/templates/initial-agents-dir/skills/README.md +65 -0
- package/vendor/@anvil/common/src/templates/initial-agents-dir/skills/example-skill/SKILL.md +29 -0
- package/vendor/@anvil/common/src/templates/initial-agents-dir/types/agent-definition.ts +497 -0
- package/vendor/@anvil/common/src/templates/initial-agents-dir/types/tools.ts +444 -0
- package/vendor/@anvil/common/src/templates/initial-agents-dir/types/util-types.ts +178 -0
- package/vendor/@anvil/common/src/testing/TESTING_PATTERNS.md +351 -0
- package/vendor/@anvil/common/src/testing/anvil-offer-invariants.ts +169 -0
- package/vendor/@anvil/common/src/testing/errors.ts +33 -0
- package/vendor/@anvil/common/src/testing/fixtures/agent-runtime.ts +334 -0
- package/vendor/@anvil/common/src/testing/impl/agent-runtime.ts +6 -0
- package/vendor/@anvil/common/src/testing/index.ts +84 -0
- package/vendor/@anvil/common/src/testing/mock-modules.ts +53 -0
- package/vendor/@anvil/common/src/testing/mock-types.ts +123 -0
- package/vendor/@anvil/common/src/testing/mocks/analytics.ts +261 -0
- package/vendor/@anvil/common/src/testing/mocks/child-process.ts +93 -0
- package/vendor/@anvil/common/src/testing/mocks/crypto.ts +218 -0
- package/vendor/@anvil/common/src/testing/mocks/database.ts +337 -0
- package/vendor/@anvil/common/src/testing/mocks/fetch.ts +219 -0
- package/vendor/@anvil/common/src/testing/mocks/filesystem.ts +166 -0
- package/vendor/@anvil/common/src/testing/mocks/index.ts +101 -0
- package/vendor/@anvil/common/src/testing/mocks/logger.ts +135 -0
- package/vendor/@anvil/common/src/testing/mocks/stream.ts +313 -0
- package/vendor/@anvil/common/src/testing/mocks/timers.ts +132 -0
- package/vendor/@anvil/common/src/testing/mocks/tree-sitter.ts +127 -0
- package/vendor/@anvil/common/src/testing/setup.ts +282 -0
- package/vendor/@anvil/common/src/testing-env-ci.ts +15 -0
- package/vendor/@anvil/common/src/testing-env-process.ts +78 -0
- package/vendor/@anvil/common/src/tools/__tests__/compile-tool-definitions.test.ts +34 -0
- package/vendor/@anvil/common/src/tools/compile-tool-definitions.ts +157 -0
- package/vendor/@anvil/common/src/tools/constants.ts +117 -0
- package/vendor/@anvil/common/src/tools/list.ts +190 -0
- package/vendor/@anvil/common/src/tools/params/__tests__/coerce-to-array.test.ts +213 -0
- package/vendor/@anvil/common/src/tools/params/__tests__/read-docs.test.ts +47 -0
- package/vendor/@anvil/common/src/tools/params/__tests__/render-ui.test.ts +65 -0
- package/vendor/@anvil/common/src/tools/params/tool/__tests__/run-terminal-command-timeout.test.ts +49 -0
- package/vendor/@anvil/common/src/tools/params/tool/add-message.ts +39 -0
- package/vendor/@anvil/common/src/tools/params/tool/add-subgoal.ts +57 -0
- package/vendor/@anvil/common/src/tools/params/tool/apply-patch.ts +110 -0
- package/vendor/@anvil/common/src/tools/params/tool/ask-user.ts +181 -0
- package/vendor/@anvil/common/src/tools/params/tool/browser-logs.ts +85 -0
- package/vendor/@anvil/common/src/tools/params/tool/cloud-plan-ready.ts +94 -0
- package/vendor/@anvil/common/src/tools/params/tool/code-search.ts +159 -0
- package/vendor/@anvil/common/src/tools/params/tool/composio.ts +131 -0
- package/vendor/@anvil/common/src/tools/params/tool/create-plan.ts +80 -0
- package/vendor/@anvil/common/src/tools/params/tool/end-turn.ts +57 -0
- package/vendor/@anvil/common/src/tools/params/tool/find-files.ts +60 -0
- package/vendor/@anvil/common/src/tools/params/tool/glob.ts +80 -0
- package/vendor/@anvil/common/src/tools/params/tool/gravity-index.ts +93 -0
- package/vendor/@anvil/common/src/tools/params/tool/list-directory.ts +58 -0
- package/vendor/@anvil/common/src/tools/params/tool/lookup-agent-info.ts +37 -0
- package/vendor/@anvil/common/src/tools/params/tool/propose-str-replace.ts +103 -0
- package/vendor/@anvil/common/src/tools/params/tool/propose-write-file.ts +71 -0
- package/vendor/@anvil/common/src/tools/params/tool/read-docs.ts +90 -0
- package/vendor/@anvil/common/src/tools/params/tool/read-files.ts +109 -0
- package/vendor/@anvil/common/src/tools/params/tool/read-subtree.ts +79 -0
- package/vendor/@anvil/common/src/tools/params/tool/read-url.ts +81 -0
- package/vendor/@anvil/common/src/tools/params/tool/render-ui.ts +168 -0
- package/vendor/@anvil/common/src/tools/params/tool/run-file-change-hooks.ts +57 -0
- package/vendor/@anvil/common/src/tools/params/tool/run-terminal-command.ts +211 -0
- package/vendor/@anvil/common/src/tools/params/tool/screenshot.ts +97 -0
- package/vendor/@anvil/common/src/tools/params/tool/set-messages.ts +44 -0
- package/vendor/@anvil/common/src/tools/params/tool/set-output.ts +61 -0
- package/vendor/@anvil/common/src/tools/params/tool/skill.ts +59 -0
- package/vendor/@anvil/common/src/tools/params/tool/spawn-agent-inline.ts +56 -0
- package/vendor/@anvil/common/src/tools/params/tool/spawn-agents.ts +154 -0
- package/vendor/@anvil/common/src/tools/params/tool/str-replace.ts +107 -0
- package/vendor/@anvil/common/src/tools/params/tool/suggest-followups.ts +97 -0
- package/vendor/@anvil/common/src/tools/params/tool/task-completed.ts +61 -0
- package/vendor/@anvil/common/src/tools/params/tool/think-deeply.ts +56 -0
- package/vendor/@anvil/common/src/tools/params/tool/update-subgoal.ts +89 -0
- package/vendor/@anvil/common/src/tools/params/tool/vision-analyze.ts +82 -0
- package/vendor/@anvil/common/src/tools/params/tool/web-search.ts +73 -0
- package/vendor/@anvil/common/src/tools/params/tool/write-file.ts +71 -0
- package/vendor/@anvil/common/src/tools/params/tool/write-todos.ts +67 -0
- package/vendor/@anvil/common/src/tools/params/utils.ts +150 -0
- package/vendor/@anvil/common/src/tools/utils.ts +24 -0
- package/vendor/@anvil/common/src/types/__tests__/dynamic-agent-template.test.ts +20 -0
- package/vendor/@anvil/common/src/types/agent-template.ts +215 -0
- package/vendor/@anvil/common/src/types/anvil-session.ts +535 -0
- package/vendor/@anvil/common/src/types/anvil-streak.ts +6 -0
- package/vendor/@anvil/common/src/types/anvil-usage.ts +64 -0
- package/vendor/@anvil/common/src/types/api/agents/publish.ts +61 -0
- package/vendor/@anvil/common/src/types/bun-test.d.ts +5 -0
- package/vendor/@anvil/common/src/types/contracts/agent-runtime.ts +75 -0
- package/vendor/@anvil/common/src/types/contracts/analytics.ts +9 -0
- package/vendor/@anvil/common/src/types/contracts/bigquery.ts +55 -0
- package/vendor/@anvil/common/src/types/contracts/billing.ts +46 -0
- package/vendor/@anvil/common/src/types/contracts/client.ts +53 -0
- package/vendor/@anvil/common/src/types/contracts/database.ts +112 -0
- package/vendor/@anvil/common/src/types/contracts/env.ts +203 -0
- package/vendor/@anvil/common/src/types/contracts/llm.ts +191 -0
- package/vendor/@anvil/common/src/types/contracts/logger.ts +14 -0
- package/vendor/@anvil/common/src/types/contracts/logs.ts +34 -0
- package/vendor/@anvil/common/src/types/contracts/trace.ts +21 -0
- package/vendor/@anvil/common/src/types/dynamic-agent-template.ts +328 -0
- package/vendor/@anvil/common/src/types/filesystem.ts +10 -0
- package/vendor/@anvil/common/src/types/function-params.ts +33 -0
- package/vendor/@anvil/common/src/types/grant.ts +20 -0
- package/vendor/@anvil/common/src/types/gravity-index.ts +170 -0
- package/vendor/@anvil/common/src/types/json.ts +29 -0
- package/vendor/@anvil/common/src/types/mcp.ts +24 -0
- package/vendor/@anvil/common/src/types/messages/anvil-message.ts +58 -0
- package/vendor/@anvil/common/src/types/messages/content-part.ts +59 -0
- package/vendor/@anvil/common/src/types/messages/data-content.ts +14 -0
- package/vendor/@anvil/common/src/types/messages/provider-metadata.ts +13 -0
- package/vendor/@anvil/common/src/types/organization.ts +118 -0
- package/vendor/@anvil/common/src/types/print-mode.ts +121 -0
- package/vendor/@anvil/common/src/types/publisher.ts +67 -0
- package/vendor/@anvil/common/src/types/session-state.ts +149 -0
- package/vendor/@anvil/common/src/types/skill.ts +86 -0
- package/vendor/@anvil/common/src/types/source.ts +11 -0
- package/vendor/@anvil/common/src/types/spawn.ts +13 -0
- package/vendor/@anvil/common/src/types/subscription.ts +67 -0
- package/vendor/@anvil/common/src/types/usage.ts +16 -0
- package/vendor/@anvil/common/src/types/util.ts +3 -0
- package/vendor/@anvil/common/src/util/__tests__/ad-user-agent.test.ts +26 -0
- package/vendor/@anvil/common/src/util/__tests__/analytics-dispatcher.test.ts +122 -0
- package/vendor/@anvil/common/src/util/__tests__/analytics-log.test.ts +102 -0
- package/vendor/@anvil/common/src/util/__tests__/analytics-sampling.test.ts +143 -0
- package/vendor/@anvil/common/src/util/__tests__/anvil-streak.test.ts +202 -0
- package/vendor/@anvil/common/src/util/__tests__/anvil-usage-summary.test.ts +193 -0
- package/vendor/@anvil/common/src/util/__tests__/axiom-only-log.test.ts +140 -0
- package/vendor/@anvil/common/src/util/__tests__/client-user-agent.test.ts +148 -0
- package/vendor/@anvil/common/src/util/__tests__/engagement-tracker.test.ts +115 -0
- package/vendor/@anvil/common/src/util/__tests__/env-file-path.test.ts +57 -0
- package/vendor/@anvil/common/src/util/__tests__/error-abort.test.ts +774 -0
- package/vendor/@anvil/common/src/util/__tests__/error-api-details.test.ts +206 -0
- package/vendor/@anvil/common/src/util/__tests__/file-read-limits.test.ts +173 -0
- package/vendor/@anvil/common/src/util/__tests__/format-code-search.test.ts +60 -0
- package/vendor/@anvil/common/src/util/__tests__/log-mirror.test.ts +31 -0
- package/vendor/@anvil/common/src/util/__tests__/messages.test.ts +1252 -0
- package/vendor/@anvil/common/src/util/__tests__/partial-json-delta.test.ts +505 -0
- package/vendor/@anvil/common/src/util/__tests__/path.test.ts +22 -0
- package/vendor/@anvil/common/src/util/__tests__/project-ignore.test.ts +90 -0
- package/vendor/@anvil/common/src/util/__tests__/promise.test.ts +325 -0
- package/vendor/@anvil/common/src/util/__tests__/rate-limit.test.ts +28 -0
- package/vendor/@anvil/common/src/util/__tests__/reddit-anvil-retention.test.ts +130 -0
- package/vendor/@anvil/common/src/util/__tests__/saxy.test.ts +1008 -0
- package/vendor/@anvil/common/src/util/__tests__/split-data.test.ts +289 -0
- package/vendor/@anvil/common/src/util/__tests__/string.test.ts +239 -0
- package/vendor/@anvil/common/src/util/__tests__/thread-title.test.ts +70 -0
- package/vendor/@anvil/common/src/util/__tests__/tool-result-media-order.test.ts +108 -0
- package/vendor/@anvil/common/src/util/__tests__/ttft-histogram.test.ts +180 -0
- package/vendor/@anvil/common/src/util/__tests__/with-timeout.test.ts +24 -0
- package/vendor/@anvil/common/src/util/__tests__/zoned-time.test.ts +88 -0
- package/vendor/@anvil/common/src/util/ad-user-agent.ts +25 -0
- package/vendor/@anvil/common/src/util/agent-file-utils.ts +110 -0
- package/vendor/@anvil/common/src/util/agent-id-parsing.ts +136 -0
- package/vendor/@anvil/common/src/util/agent-name-normalization.ts +38 -0
- package/vendor/@anvil/common/src/util/agent-name-resolver.ts +86 -0
- package/vendor/@anvil/common/src/util/analytics-dispatcher.ts +82 -0
- package/vendor/@anvil/common/src/util/analytics-log.ts +78 -0
- package/vendor/@anvil/common/src/util/analytics-sampling.ts +255 -0
- package/vendor/@anvil/common/src/util/anvil-model-availability.ts +102 -0
- package/vendor/@anvil/common/src/util/anvil-privacy.ts +82 -0
- package/vendor/@anvil/common/src/util/anvil-streak-line.ts +103 -0
- package/vendor/@anvil/common/src/util/anvil-streak.ts +156 -0
- package/vendor/@anvil/common/src/util/anvil-usage-summary.ts +125 -0
- package/vendor/@anvil/common/src/util/array.ts +31 -0
- package/vendor/@anvil/common/src/util/axiom-only-log.ts +124 -0
- package/vendor/@anvil/common/src/util/cache-debug.ts +171 -0
- package/vendor/@anvil/common/src/util/client-user-agent.ts +114 -0
- package/vendor/@anvil/common/src/util/credentials.ts +26 -0
- package/vendor/@anvil/common/src/util/currency.ts +25 -0
- package/vendor/@anvil/common/src/util/dates.ts +81 -0
- package/vendor/@anvil/common/src/util/disposable-email.ts +277 -0
- package/vendor/@anvil/common/src/util/engagement-tracker.ts +129 -0
- package/vendor/@anvil/common/src/util/env-file-path.ts +40 -0
- package/vendor/@anvil/common/src/util/error.ts +562 -0
- package/vendor/@anvil/common/src/util/file-read-limits.ts +236 -0
- package/vendor/@anvil/common/src/util/file.ts +339 -0
- package/vendor/@anvil/common/src/util/format-code-search.ts +115 -0
- package/vendor/@anvil/common/src/util/lazy-response-ads.ts +92 -0
- package/vendor/@anvil/common/src/util/log-data.ts +57 -0
- package/vendor/@anvil/common/src/util/log-ingest.ts +58 -0
- package/vendor/@anvil/common/src/util/log-mirror.ts +34 -0
- package/vendor/@anvil/common/src/util/lru-cache.ts +67 -0
- package/vendor/@anvil/common/src/util/messages.ts +685 -0
- package/vendor/@anvil/common/src/util/min-heap.ts +87 -0
- package/vendor/@anvil/common/src/util/model-utils.ts +4 -0
- package/vendor/@anvil/common/src/util/object.ts +128 -0
- package/vendor/@anvil/common/src/util/partial-json-delta.ts +89 -0
- package/vendor/@anvil/common/src/util/path.ts +15 -0
- package/vendor/@anvil/common/src/util/project-ignore.ts +119 -0
- package/vendor/@anvil/common/src/util/promise.ts +73 -0
- package/vendor/@anvil/common/src/util/random.ts +15 -0
- package/vendor/@anvil/common/src/util/rate-limit.ts +56 -0
- package/vendor/@anvil/common/src/util/reddit-anvil-retention.ts +60 -0
- package/vendor/@anvil/common/src/util/reddit-capi-events.ts +36 -0
- package/vendor/@anvil/common/src/util/response-ad-positions.ts +54 -0
- package/vendor/@anvil/common/src/util/saxy.ts +741 -0
- package/vendor/@anvil/common/src/util/skills.test.ts +44 -0
- package/vendor/@anvil/common/src/util/skills.ts +36 -0
- package/vendor/@anvil/common/src/util/split-data.ts +259 -0
- package/vendor/@anvil/common/src/util/stop-sequence.ts +61 -0
- package/vendor/@anvil/common/src/util/string.ts +426 -0
- package/vendor/@anvil/common/src/util/system-info.ts +53 -0
- package/vendor/@anvil/common/src/util/thread-title.ts +46 -0
- package/vendor/@anvil/common/src/util/ttft-histogram.ts +73 -0
- package/vendor/@anvil/common/src/util/xml-parser.ts +27 -0
- package/vendor/@anvil/common/src/util/xml.ts +17 -0
- package/vendor/@anvil/common/src/util/zod-schema.ts +25 -0
- package/vendor/@anvil/common/src/util/zoned-time.ts +136 -0
- package/vendor/@anvil/common/src/utils/ask-user-bridge.ts +44 -0
- package/vendor/@anvil/sdk/dist/index.cjs +52297 -0
- package/vendor/@anvil/sdk/dist/index.cjs.map +440 -0
- package/vendor/@anvil/sdk/dist/index.d.ts +4277 -0
- package/vendor/@anvil/sdk/dist/index.mjs +52290 -0
- package/vendor/@anvil/sdk/dist/index.mjs.map +440 -0
- package/vendor/@anvil/sdk/dist/vendor/ai.cjs +30886 -0
- package/vendor/@anvil/sdk/dist/vendor/ripgrep/arm64-darwin/rg +0 -0
- package/vendor/@anvil/sdk/dist/vendor/ripgrep/arm64-linux/rg +0 -0
- package/vendor/@anvil/sdk/dist/vendor/ripgrep/x64-darwin/rg +0 -0
- package/vendor/@anvil/sdk/dist/vendor/ripgrep/x64-linux/rg +0 -0
- package/vendor/@anvil/sdk/dist/vendor/ripgrep/x64-win32/rg.exe +0 -0
- package/vendor/@anvil/sdk/dist/wasm/tree-sitter-c-sharp.wasm +0 -0
- package/vendor/@anvil/sdk/dist/wasm/tree-sitter-cpp.wasm +0 -0
- package/vendor/@anvil/sdk/dist/wasm/tree-sitter-go.wasm +0 -0
- package/vendor/@anvil/sdk/dist/wasm/tree-sitter-java.wasm +0 -0
- package/vendor/@anvil/sdk/dist/wasm/tree-sitter-javascript.wasm +0 -0
- package/vendor/@anvil/sdk/dist/wasm/tree-sitter-python.wasm +0 -0
- package/vendor/@anvil/sdk/dist/wasm/tree-sitter-ruby.wasm +0 -0
- package/vendor/@anvil/sdk/dist/wasm/tree-sitter-rust.wasm +0 -0
- package/vendor/@anvil/sdk/dist/wasm/tree-sitter-tsx.wasm +0 -0
- package/vendor/@anvil/sdk/dist/wasm/tree-sitter-typescript.wasm +0 -0
- package/vendor/@anvil/sdk/dist/wasm/tree-sitter.wasm +0 -0
- package/vendor/@anvil/sdk/package.json +21 -0
|
@@ -0,0 +1,170 @@
|
|
|
1
|
+
import z from 'zod/v4'
|
|
2
|
+
|
|
3
|
+
import { jsonObjectSchema } from './json'
|
|
4
|
+
|
|
5
|
+
// Shared field constraints reused by both the per-action schemas
|
|
6
|
+
// (gravityIndexApiInputSchema) and the flat tool-facing schema below, so the
|
|
7
|
+
// bounds and error messages stay in sync. Descriptions are applied per use
|
|
8
|
+
// site because they differ between the two contexts (single-action vs. the
|
|
9
|
+
// `For action "X":` prefixes the flat LLM schema needs).
|
|
10
|
+
const queryField = z
|
|
11
|
+
.string()
|
|
12
|
+
.min(1, 'Query cannot be empty')
|
|
13
|
+
.max(1000, 'Query cannot exceed 1000 characters')
|
|
14
|
+
const slugField = z.string().min(1, 'Slug cannot be empty')
|
|
15
|
+
const integratedSlugField = z.string().min(1, 'integrated_slug cannot be empty')
|
|
16
|
+
|
|
17
|
+
const searchInputSchema = z.object({
|
|
18
|
+
action: z.literal('search').describe('Search for the best service.'),
|
|
19
|
+
query: queryField.describe(
|
|
20
|
+
`What the user needs, including stack, constraints, and required capabilities when known. Example: "serverless database with branching for a Next.js app".`,
|
|
21
|
+
),
|
|
22
|
+
search_id: z
|
|
23
|
+
.string()
|
|
24
|
+
.optional()
|
|
25
|
+
.describe('Continue a previous Gravity Index search as a follow-up.'),
|
|
26
|
+
context: jsonObjectSchema
|
|
27
|
+
.optional()
|
|
28
|
+
.describe(
|
|
29
|
+
'Optional structured JSON context about the project, stack, or constraints.',
|
|
30
|
+
),
|
|
31
|
+
})
|
|
32
|
+
|
|
33
|
+
const browseInputSchema = z.object({
|
|
34
|
+
action: z
|
|
35
|
+
.literal('browse')
|
|
36
|
+
.describe('Browse catalog services by category and/or keyword.'),
|
|
37
|
+
category: z
|
|
38
|
+
.string()
|
|
39
|
+
.optional()
|
|
40
|
+
.describe(
|
|
41
|
+
'Optional category filter, e.g. Database, Auth, Payments, Hosting, Email, Cache, Monitoring, Analytics, AI, Storage, CMS, Search, Realtime, Background Jobs, Infrastructure, CRM, Support, Productivity, Commerce, Video, Webhooks, SMS.',
|
|
42
|
+
),
|
|
43
|
+
q: z
|
|
44
|
+
.string()
|
|
45
|
+
.optional()
|
|
46
|
+
.describe('Optional keyword filter, e.g. sendgrid or postgres.'),
|
|
47
|
+
})
|
|
48
|
+
|
|
49
|
+
const listCategoriesInputSchema = z.object({
|
|
50
|
+
action: z
|
|
51
|
+
.literal('list_categories')
|
|
52
|
+
.describe('List every category with service counts.'),
|
|
53
|
+
})
|
|
54
|
+
|
|
55
|
+
const getServiceInputSchema = z.object({
|
|
56
|
+
action: z
|
|
57
|
+
.literal('get_service')
|
|
58
|
+
.describe('Fetch full detail for a single service by slug.'),
|
|
59
|
+
slug: slugField.describe('Service slug, e.g. supabase, stripe, sendgrid.'),
|
|
60
|
+
})
|
|
61
|
+
|
|
62
|
+
const reportIntegrationInputSchema = z.object({
|
|
63
|
+
action: z
|
|
64
|
+
.literal('report_integration')
|
|
65
|
+
.describe('Report that an integration from a prior search was done.'),
|
|
66
|
+
search_id: z
|
|
67
|
+
.string()
|
|
68
|
+
.min(1, 'search_id cannot be empty')
|
|
69
|
+
.describe('search_id from the earlier search result.'),
|
|
70
|
+
integrated_slug: integratedSlugField.describe(
|
|
71
|
+
'Slug of the service that was actually integrated.',
|
|
72
|
+
),
|
|
73
|
+
})
|
|
74
|
+
|
|
75
|
+
const runtimeAttributionFields = {
|
|
76
|
+
external_session_id: z
|
|
77
|
+
.string()
|
|
78
|
+
.optional()
|
|
79
|
+
.describe(
|
|
80
|
+
'Stable Anvil session ID for Gravity API key attribution. Anvil usually fills this automatically.',
|
|
81
|
+
),
|
|
82
|
+
// Raw, stable per-end-user identifier for Gravity attribution + payout
|
|
83
|
+
// matching. Surfaces that run under a shared service account (e.g. Anvil
|
|
84
|
+
// Web) set this to the real end user so conversions don't all collapse onto
|
|
85
|
+
// the service account. The server hashes it before sending it to Gravity.
|
|
86
|
+
// Anvil usually fills this automatically.
|
|
87
|
+
external_user_id: z
|
|
88
|
+
.string()
|
|
89
|
+
.optional()
|
|
90
|
+
.describe(
|
|
91
|
+
'Stable per-end-user identifier for Gravity attribution. Anvil usually fills this automatically.',
|
|
92
|
+
),
|
|
93
|
+
metadata: jsonObjectSchema
|
|
94
|
+
.optional()
|
|
95
|
+
.describe(
|
|
96
|
+
'Non-sensitive API key metadata for Gravity attribution and debugging. Anvil usually fills this automatically.',
|
|
97
|
+
),
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
// Tool-facing schema presented to the LLM provider. Native function-calling
|
|
101
|
+
// providers require the top-level `parameters` to be a JSON Schema of
|
|
102
|
+
// `type: "object"`, so this MUST be a flat `z.object` rather than a top-level
|
|
103
|
+
// discriminated union (which serializes to `oneOf`/`anyOf` with no top-level
|
|
104
|
+
// type). Per-action requiredness is enforced server-side by
|
|
105
|
+
// `gravityIndexApiInputSchema` below.
|
|
106
|
+
export const gravityIndexInputSchema = z
|
|
107
|
+
.object({
|
|
108
|
+
action: z
|
|
109
|
+
.enum([
|
|
110
|
+
'search',
|
|
111
|
+
'browse',
|
|
112
|
+
'list_categories',
|
|
113
|
+
'get_service',
|
|
114
|
+
'report_integration',
|
|
115
|
+
])
|
|
116
|
+
.describe(
|
|
117
|
+
'Which Gravity Index operation to perform. search: recommend a provider; browse: list catalog services; list_categories: list categories with counts; get_service: full detail for a known slug; report_integration: report a completed integration.',
|
|
118
|
+
),
|
|
119
|
+
query: queryField
|
|
120
|
+
.optional()
|
|
121
|
+
.describe(
|
|
122
|
+
`For action "search": what the user needs, including stack, constraints, and required capabilities when known. Example: "serverless database with branching for a Next.js app".`,
|
|
123
|
+
),
|
|
124
|
+
search_id: z
|
|
125
|
+
.string()
|
|
126
|
+
.optional()
|
|
127
|
+
.describe(
|
|
128
|
+
'For action "search": continue a previous Gravity Index search as a follow-up. For action "report_integration": the search_id from the earlier search result (required).',
|
|
129
|
+
),
|
|
130
|
+
context: jsonObjectSchema
|
|
131
|
+
.optional()
|
|
132
|
+
.describe(
|
|
133
|
+
'For action "search": optional structured JSON context about the project, stack, or constraints.',
|
|
134
|
+
),
|
|
135
|
+
category: z
|
|
136
|
+
.string()
|
|
137
|
+
.optional()
|
|
138
|
+
.describe(
|
|
139
|
+
'For action "browse": optional category filter, e.g. Database, Auth, Payments, Hosting, Email, Cache, Monitoring, Analytics, AI, Storage, CMS, Search, Realtime, Background Jobs, Infrastructure, CRM, Support, Productivity, Commerce, Video, Webhooks, SMS.',
|
|
140
|
+
),
|
|
141
|
+
q: z
|
|
142
|
+
.string()
|
|
143
|
+
.optional()
|
|
144
|
+
.describe(
|
|
145
|
+
'For action "browse": optional keyword filter, e.g. sendgrid or postgres.',
|
|
146
|
+
),
|
|
147
|
+
slug: slugField
|
|
148
|
+
.optional()
|
|
149
|
+
.describe(
|
|
150
|
+
'For action "get_service": service slug, e.g. supabase, stripe, sendgrid (required).',
|
|
151
|
+
),
|
|
152
|
+
integrated_slug: integratedSlugField
|
|
153
|
+
.optional()
|
|
154
|
+
.describe(
|
|
155
|
+
'For action "report_integration": slug of the service that was actually integrated (required).',
|
|
156
|
+
),
|
|
157
|
+
})
|
|
158
|
+
.describe(`Use the Gravity Index tool discovery and install API.`)
|
|
159
|
+
|
|
160
|
+
export const gravityIndexApiInputSchema = z
|
|
161
|
+
.discriminatedUnion('action', [
|
|
162
|
+
searchInputSchema.extend(runtimeAttributionFields),
|
|
163
|
+
browseInputSchema,
|
|
164
|
+
listCategoriesInputSchema,
|
|
165
|
+
getServiceInputSchema,
|
|
166
|
+
reportIntegrationInputSchema.extend(runtimeAttributionFields),
|
|
167
|
+
])
|
|
168
|
+
.describe(`Use the Gravity Index tool discovery and install API.`)
|
|
169
|
+
|
|
170
|
+
export type GravityIndexInput = z.infer<typeof gravityIndexApiInputSchema>
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import z from 'zod/v4'
|
|
2
|
+
|
|
3
|
+
export type JSONValue =
|
|
4
|
+
| null
|
|
5
|
+
| string
|
|
6
|
+
| number
|
|
7
|
+
| boolean
|
|
8
|
+
| JSONObject
|
|
9
|
+
| JSONArray
|
|
10
|
+
export const jsonValueSchema: z.ZodType<JSONValue> = z.lazy(() =>
|
|
11
|
+
z.union([
|
|
12
|
+
z.null(),
|
|
13
|
+
z.string(),
|
|
14
|
+
z.number(),
|
|
15
|
+
z.boolean(),
|
|
16
|
+
jsonObjectSchema,
|
|
17
|
+
jsonArraySchema,
|
|
18
|
+
]),
|
|
19
|
+
)
|
|
20
|
+
|
|
21
|
+
export const jsonObjectSchema: z.ZodType<JSONObject> = z.lazy(() =>
|
|
22
|
+
z.record(z.string(), jsonValueSchema.optional()),
|
|
23
|
+
)
|
|
24
|
+
export type JSONObject = { [key in string]: JSONValue | undefined }
|
|
25
|
+
|
|
26
|
+
export const jsonArraySchema: z.ZodType<JSONArray> = z.lazy(() =>
|
|
27
|
+
z.array(jsonValueSchema),
|
|
28
|
+
)
|
|
29
|
+
export type JSONArray = JSONValue[]
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { z } from 'zod/v4'
|
|
2
|
+
|
|
3
|
+
export const mcpConfigStdioSchema = z.strictObject({
|
|
4
|
+
type: z.literal('stdio').default('stdio'),
|
|
5
|
+
command: z.string(),
|
|
6
|
+
args: z
|
|
7
|
+
.string()
|
|
8
|
+
.array()
|
|
9
|
+
.default(() => []),
|
|
10
|
+
env: z.record(z.string(), z.string()).default(() => ({})),
|
|
11
|
+
})
|
|
12
|
+
|
|
13
|
+
export const mcpConfigRemoteSchema = z.strictObject({
|
|
14
|
+
type: z.enum(['http', 'sse']).default('http'),
|
|
15
|
+
url: z.string(),
|
|
16
|
+
params: z.record(z.string(), z.string()).default(() => ({})),
|
|
17
|
+
headers: z.record(z.string(), z.string()).default(() => ({})),
|
|
18
|
+
})
|
|
19
|
+
|
|
20
|
+
export const mcpConfigSchema = z.union([
|
|
21
|
+
mcpConfigRemoteSchema,
|
|
22
|
+
mcpConfigStdioSchema,
|
|
23
|
+
])
|
|
24
|
+
export type MCPConfig = z.infer<typeof mcpConfigSchema>
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
import type {
|
|
2
|
+
FilePart,
|
|
3
|
+
ImagePart,
|
|
4
|
+
ReasoningPart,
|
|
5
|
+
TextPart,
|
|
6
|
+
ToolCallPart,
|
|
7
|
+
ToolResultOutput,
|
|
8
|
+
} from './content-part'
|
|
9
|
+
import type { ProviderMetadata } from './provider-metadata'
|
|
10
|
+
|
|
11
|
+
export type AuxiliaryMessageData = {
|
|
12
|
+
providerOptions?: ProviderMetadata
|
|
13
|
+
tags?: string[]
|
|
14
|
+
|
|
15
|
+
/**
|
|
16
|
+
* Unix timestamp (ms) when the message was added to history.
|
|
17
|
+
* Used to detect prompt cache expiry (>5 min gap = cache miss).
|
|
18
|
+
* This field is stripped before sending to the LLM.
|
|
19
|
+
*/
|
|
20
|
+
sentAt?: number
|
|
21
|
+
|
|
22
|
+
// James: All the below is overly prescriptive for the framework.
|
|
23
|
+
// Instead, let's tag what the message is, and let the user decide time to live, keep during truncation, etc.
|
|
24
|
+
/** @deprecated Use tags instead. */
|
|
25
|
+
timeToLive?: 'agentStep' | 'userPrompt'
|
|
26
|
+
/** @deprecated Use tags instead. */
|
|
27
|
+
keepDuringTruncation?: boolean
|
|
28
|
+
/** @deprecated Use tags instead. */
|
|
29
|
+
keepLastTags?: string[]
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
export type SystemMessage = {
|
|
33
|
+
role: 'system'
|
|
34
|
+
content: TextPart[]
|
|
35
|
+
} & AuxiliaryMessageData
|
|
36
|
+
|
|
37
|
+
export type UserMessage = {
|
|
38
|
+
role: 'user'
|
|
39
|
+
content: (TextPart | ImagePart | FilePart)[]
|
|
40
|
+
} & AuxiliaryMessageData
|
|
41
|
+
|
|
42
|
+
export type AssistantMessage = {
|
|
43
|
+
role: 'assistant'
|
|
44
|
+
content: (TextPart | ReasoningPart | ToolCallPart)[]
|
|
45
|
+
} & AuxiliaryMessageData
|
|
46
|
+
|
|
47
|
+
export type ToolMessage = {
|
|
48
|
+
role: 'tool'
|
|
49
|
+
toolCallId: string
|
|
50
|
+
toolName: string
|
|
51
|
+
content: ToolResultOutput[]
|
|
52
|
+
} & AuxiliaryMessageData
|
|
53
|
+
|
|
54
|
+
export type Message =
|
|
55
|
+
| SystemMessage
|
|
56
|
+
| UserMessage
|
|
57
|
+
| AssistantMessage
|
|
58
|
+
| ToolMessage
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
import z from 'zod/v4'
|
|
2
|
+
|
|
3
|
+
import { providerMetadataSchema } from './provider-metadata'
|
|
4
|
+
import { jsonValueSchema } from '../json'
|
|
5
|
+
import { dataContentSchema } from './data-content'
|
|
6
|
+
|
|
7
|
+
export const textPartSchema = z.object({
|
|
8
|
+
type: z.literal('text'),
|
|
9
|
+
text: z.string(),
|
|
10
|
+
providerOptions: providerMetadataSchema.optional(),
|
|
11
|
+
})
|
|
12
|
+
export type TextPart = z.infer<typeof textPartSchema>
|
|
13
|
+
|
|
14
|
+
export const imagePartSchema = z.object({
|
|
15
|
+
type: z.literal('image'),
|
|
16
|
+
image: z.union([dataContentSchema, z.instanceof(URL)]),
|
|
17
|
+
mediaType: z.string().optional(),
|
|
18
|
+
providerOptions: providerMetadataSchema.optional(),
|
|
19
|
+
})
|
|
20
|
+
export type ImagePart = z.infer<typeof imagePartSchema>
|
|
21
|
+
|
|
22
|
+
export const filePartSchema = z.object({
|
|
23
|
+
type: z.literal('file'),
|
|
24
|
+
data: z.union([dataContentSchema, z.instanceof(URL)]),
|
|
25
|
+
filename: z.string().optional(),
|
|
26
|
+
mediaType: z.string(),
|
|
27
|
+
providerOptions: providerMetadataSchema.optional(),
|
|
28
|
+
})
|
|
29
|
+
export type FilePart = z.infer<typeof filePartSchema>
|
|
30
|
+
|
|
31
|
+
export const reasoningPartSchema = z.object({
|
|
32
|
+
type: z.literal('reasoning'),
|
|
33
|
+
text: z.string(),
|
|
34
|
+
providerOptions: providerMetadataSchema.optional(),
|
|
35
|
+
})
|
|
36
|
+
export type ReasoningPart = z.infer<typeof reasoningPartSchema>
|
|
37
|
+
|
|
38
|
+
export const toolCallPartSchema = z.object({
|
|
39
|
+
type: z.literal('tool-call'),
|
|
40
|
+
toolCallId: z.string(),
|
|
41
|
+
toolName: z.string(),
|
|
42
|
+
input: z.record(z.string(), z.unknown()),
|
|
43
|
+
providerOptions: providerMetadataSchema.optional(),
|
|
44
|
+
providerExecuted: z.boolean().optional(),
|
|
45
|
+
})
|
|
46
|
+
export type ToolCallPart = z.infer<typeof toolCallPartSchema>
|
|
47
|
+
|
|
48
|
+
export const toolResultOutputSchema = z.discriminatedUnion('type', [
|
|
49
|
+
z.object({
|
|
50
|
+
type: z.literal('json'),
|
|
51
|
+
value: jsonValueSchema,
|
|
52
|
+
}),
|
|
53
|
+
z.object({
|
|
54
|
+
type: z.literal('media'),
|
|
55
|
+
data: z.string(),
|
|
56
|
+
mediaType: z.string(),
|
|
57
|
+
}),
|
|
58
|
+
])
|
|
59
|
+
export type ToolResultOutput = z.infer<typeof toolResultOutputSchema>
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import z from 'zod/v4'
|
|
2
|
+
|
|
3
|
+
export const dataContentSchema = z.union([
|
|
4
|
+
z.string(),
|
|
5
|
+
z.instanceof(Uint8Array),
|
|
6
|
+
z.instanceof(ArrayBuffer),
|
|
7
|
+
z.custom<Buffer>(
|
|
8
|
+
// Buffer might not be available in some environments such as CloudFlare:
|
|
9
|
+
(value: unknown): value is Buffer =>
|
|
10
|
+
globalThis.Buffer?.isBuffer(value) ?? false,
|
|
11
|
+
{ message: 'Must be a Buffer' },
|
|
12
|
+
),
|
|
13
|
+
])
|
|
14
|
+
export type DataContent = z.infer<typeof dataContentSchema>
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import z from 'zod/v4'
|
|
2
|
+
|
|
3
|
+
import { jsonValueSchema, type JSONValue } from '../json'
|
|
4
|
+
|
|
5
|
+
export type ProviderMetadata = Record<
|
|
6
|
+
string,
|
|
7
|
+
Record<string, JSONValue | undefined>
|
|
8
|
+
>
|
|
9
|
+
|
|
10
|
+
export const providerMetadataSchema: z.ZodType<ProviderMetadata> = z.record(
|
|
11
|
+
z.string(),
|
|
12
|
+
z.record(z.string(), jsonValueSchema.optional()),
|
|
13
|
+
)
|
|
@@ -0,0 +1,118 @@
|
|
|
1
|
+
export type OrganizationRole = 'owner' | 'admin' | 'member'
|
|
2
|
+
|
|
3
|
+
export interface OrganizationMember {
|
|
4
|
+
organization_id: string
|
|
5
|
+
user_id: string
|
|
6
|
+
role: OrganizationRole
|
|
7
|
+
joined_at: Date
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
export interface Organization {
|
|
11
|
+
id: string
|
|
12
|
+
name: string
|
|
13
|
+
slug: string
|
|
14
|
+
description?: string
|
|
15
|
+
owner_id: string
|
|
16
|
+
stripe_customer_id?: string
|
|
17
|
+
created_at: Date
|
|
18
|
+
updated_at: Date
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
export interface OrganizationRepository {
|
|
22
|
+
id: string
|
|
23
|
+
organization_id: string
|
|
24
|
+
repository_url: string
|
|
25
|
+
repository_name: string
|
|
26
|
+
approved_by: string
|
|
27
|
+
approved_at: Date
|
|
28
|
+
is_active: boolean
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
export interface OrganizationUsage {
|
|
32
|
+
id: string
|
|
33
|
+
organization_id: string
|
|
34
|
+
user_id: string
|
|
35
|
+
repository_url: string
|
|
36
|
+
credits_used: number
|
|
37
|
+
message_id?: string
|
|
38
|
+
created_at: Date
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
export interface CreateOrganizationRequest {
|
|
42
|
+
name: string
|
|
43
|
+
slug?: string
|
|
44
|
+
description?: string
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
export interface ListOrganizationsResponse {
|
|
48
|
+
organizations: Array<{
|
|
49
|
+
id: string
|
|
50
|
+
name: string
|
|
51
|
+
slug: string
|
|
52
|
+
role: OrganizationRole
|
|
53
|
+
memberCount: number
|
|
54
|
+
repositoryCount: number
|
|
55
|
+
}>
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
export interface OrganizationDetailsResponse {
|
|
59
|
+
id: string
|
|
60
|
+
name: string
|
|
61
|
+
slug: string
|
|
62
|
+
description?: string
|
|
63
|
+
userRole: 'owner' | 'admin' | 'member'
|
|
64
|
+
memberCount: number
|
|
65
|
+
repositoryCount: number
|
|
66
|
+
creditBalance: number
|
|
67
|
+
hasStripeSubscription?: boolean
|
|
68
|
+
stripeSubscriptionId?: string
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
export interface InviteMemberRequest {
|
|
72
|
+
email: string
|
|
73
|
+
role: 'admin' | 'member'
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
export interface UpdateMemberRoleRequest {
|
|
77
|
+
role: 'admin' | 'member'
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
export interface AddRepositoryRequest {
|
|
81
|
+
repository_url: string
|
|
82
|
+
repository_name: string
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
export interface OrganizationUsageResponse {
|
|
86
|
+
currentBalance: number
|
|
87
|
+
usageThisCycle: number
|
|
88
|
+
cycleStartDate: string
|
|
89
|
+
cycleEndDate: string
|
|
90
|
+
topUsers: Array<{
|
|
91
|
+
user_id: string
|
|
92
|
+
user_name: string
|
|
93
|
+
user_email: string
|
|
94
|
+
credits_used: number
|
|
95
|
+
}>
|
|
96
|
+
recentUsage: Array<{
|
|
97
|
+
date: string
|
|
98
|
+
credits_used: number
|
|
99
|
+
repository_url: string
|
|
100
|
+
user_name: string
|
|
101
|
+
}>
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
export interface CreditDelegationResult {
|
|
105
|
+
useOrganization: boolean
|
|
106
|
+
organizationId?: string
|
|
107
|
+
requiresOverride: boolean
|
|
108
|
+
organizationBalance?: number
|
|
109
|
+
userBalance?: number
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
export interface CreditConsumptionWithDelegationResult {
|
|
113
|
+
success: boolean
|
|
114
|
+
consumed: number
|
|
115
|
+
fromOrganization: boolean
|
|
116
|
+
organizationId?: string
|
|
117
|
+
error?: string
|
|
118
|
+
}
|
|
@@ -0,0 +1,121 @@
|
|
|
1
|
+
import z from 'zod/v4'
|
|
2
|
+
|
|
3
|
+
import { toolResultOutputSchema } from './messages/content-part'
|
|
4
|
+
|
|
5
|
+
export const printModeStartSchema = z.object({
|
|
6
|
+
type: z.literal('start'),
|
|
7
|
+
agentId: z.string().optional(),
|
|
8
|
+
messageHistoryLength: z.number(),
|
|
9
|
+
})
|
|
10
|
+
export type PrintModeStart = z.infer<typeof printModeStartSchema>
|
|
11
|
+
|
|
12
|
+
export const printModeErrorSchema = z.object({
|
|
13
|
+
type: z.literal('error'),
|
|
14
|
+
message: z.string(),
|
|
15
|
+
/** Auto-recovered stream endings ('stream-interrupted': connection cut
|
|
16
|
+
* mid-response; 'output-limit': reasoning ended with no usable answer).
|
|
17
|
+
* The agent loop is automatically taking another step; UIs show a
|
|
18
|
+
* transient retrying indicator rather than a failure. */
|
|
19
|
+
source: z.enum(['stream-interrupted', 'output-limit']).optional(),
|
|
20
|
+
})
|
|
21
|
+
export type PrintModeError = z.infer<typeof printModeErrorSchema>
|
|
22
|
+
|
|
23
|
+
export const printModeDownloadStatusSchema = z.object({
|
|
24
|
+
type: z.literal('download'),
|
|
25
|
+
version: z.string(),
|
|
26
|
+
status: z.enum(['complete', 'failed']),
|
|
27
|
+
})
|
|
28
|
+
export type PrintModeDownloadStatus = z.infer<
|
|
29
|
+
typeof printModeDownloadStatusSchema
|
|
30
|
+
>
|
|
31
|
+
|
|
32
|
+
export const printModeToolCallSchema = z.object({
|
|
33
|
+
type: z.literal('tool_call'),
|
|
34
|
+
toolCallId: z.string(),
|
|
35
|
+
toolName: z.string(),
|
|
36
|
+
input: z.record(z.string(), z.any()),
|
|
37
|
+
agentId: z.string().optional(),
|
|
38
|
+
parentAgentId: z.string().optional(),
|
|
39
|
+
includeToolCall: z.boolean().optional(),
|
|
40
|
+
})
|
|
41
|
+
export type PrintModeToolCall = z.infer<typeof printModeToolCallSchema>
|
|
42
|
+
|
|
43
|
+
export const printModeToolResultSchema = z.object({
|
|
44
|
+
type: z.literal('tool_result'),
|
|
45
|
+
toolCallId: z.string(),
|
|
46
|
+
toolName: z.string(),
|
|
47
|
+
output: toolResultOutputSchema.array(),
|
|
48
|
+
parentAgentId: z.string().optional(),
|
|
49
|
+
})
|
|
50
|
+
export type PrintModeToolResult = z.infer<typeof printModeToolResultSchema>
|
|
51
|
+
|
|
52
|
+
export const printModeTextSchema = z.object({
|
|
53
|
+
type: z.literal('text'),
|
|
54
|
+
text: z.string(),
|
|
55
|
+
agentId: z.string().optional(),
|
|
56
|
+
})
|
|
57
|
+
export type PrintModeText = z.infer<typeof printModeTextSchema>
|
|
58
|
+
|
|
59
|
+
export const printModeFinishSchema = z.object({
|
|
60
|
+
type: z.literal('finish'),
|
|
61
|
+
agentId: z.string().optional(),
|
|
62
|
+
totalCost: z.number(),
|
|
63
|
+
})
|
|
64
|
+
export type PrintModeFinish = z.infer<typeof printModeFinishSchema>
|
|
65
|
+
|
|
66
|
+
export const printModeSubagentStartSchema = z.object({
|
|
67
|
+
type: z.literal('subagent_start'),
|
|
68
|
+
agentId: z.string(),
|
|
69
|
+
agentType: z.string(),
|
|
70
|
+
displayName: z.string(),
|
|
71
|
+
onlyChild: z.boolean(),
|
|
72
|
+
parentAgentId: z.string().optional(),
|
|
73
|
+
params: z.record(z.string(), z.any()).optional(),
|
|
74
|
+
prompt: z.string().optional(),
|
|
75
|
+
})
|
|
76
|
+
export type PrintModeSubagentStart = z.infer<
|
|
77
|
+
typeof printModeSubagentStartSchema
|
|
78
|
+
>
|
|
79
|
+
|
|
80
|
+
export const printModeSubagentFinishSchema = z.object({
|
|
81
|
+
type: z.literal('subagent_finish'),
|
|
82
|
+
agentId: z.string(),
|
|
83
|
+
agentType: z.string(),
|
|
84
|
+
displayName: z.string(),
|
|
85
|
+
onlyChild: z.boolean(),
|
|
86
|
+
parentAgentId: z.string().optional(),
|
|
87
|
+
params: z.record(z.string(), z.any()).optional(),
|
|
88
|
+
prompt: z.string().optional(),
|
|
89
|
+
})
|
|
90
|
+
export type PrintModeSubagentFinish = z.infer<
|
|
91
|
+
typeof printModeSubagentFinishSchema
|
|
92
|
+
>
|
|
93
|
+
|
|
94
|
+
export const printModeReasoningDeltaSchema = z.object({
|
|
95
|
+
type: z.literal('reasoning_delta'),
|
|
96
|
+
text: z.string(),
|
|
97
|
+
ancestorRunIds: z.string().array(),
|
|
98
|
+
runId: z.string(),
|
|
99
|
+
/** The reasoning agent's stable id (matches subagent_start/subagent_chunk
|
|
100
|
+
* agentId), so consumers can attribute reasoning to the right agent. */
|
|
101
|
+
agentId: z.string(),
|
|
102
|
+
})
|
|
103
|
+
export type PrintModeReasoningDelta = z.infer<
|
|
104
|
+
typeof printModeReasoningDeltaSchema
|
|
105
|
+
>
|
|
106
|
+
|
|
107
|
+
export const printModeEventSchema = z.discriminatedUnion('type', [
|
|
108
|
+
printModeDownloadStatusSchema,
|
|
109
|
+
printModeErrorSchema,
|
|
110
|
+
printModeFinishSchema,
|
|
111
|
+
printModeStartSchema,
|
|
112
|
+
printModeSubagentFinishSchema,
|
|
113
|
+
printModeSubagentStartSchema,
|
|
114
|
+
printModeTextSchema,
|
|
115
|
+
printModeToolCallSchema,
|
|
116
|
+
printModeToolResultSchema,
|
|
117
|
+
|
|
118
|
+
printModeReasoningDeltaSchema,
|
|
119
|
+
])
|
|
120
|
+
|
|
121
|
+
export type PrintModeEvent = z.infer<typeof printModeEventSchema>
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
import { z } from 'zod/v4'
|
|
2
|
+
|
|
3
|
+
// Publisher ID validation schema - same restrictions as agent ID
|
|
4
|
+
export const PublisherIdSchema = z
|
|
5
|
+
.string()
|
|
6
|
+
.regex(
|
|
7
|
+
/^[a-z0-9-]+$/,
|
|
8
|
+
'Publisher ID must contain only lowercase letters, numbers, and hyphens',
|
|
9
|
+
)
|
|
10
|
+
|
|
11
|
+
// Publisher creation/update schema
|
|
12
|
+
export const PublisherSchema = z.object({
|
|
13
|
+
id: PublisherIdSchema,
|
|
14
|
+
name: z.string().min(1, 'Publisher name is required'),
|
|
15
|
+
email: z.string().email().optional(),
|
|
16
|
+
bio: z.string().optional(),
|
|
17
|
+
avatar_url: z.string().url().optional(),
|
|
18
|
+
})
|
|
19
|
+
|
|
20
|
+
export type PublisherInput = z.infer<typeof PublisherSchema>
|
|
21
|
+
|
|
22
|
+
export interface Publisher {
|
|
23
|
+
id: string
|
|
24
|
+
user_id: string | null
|
|
25
|
+
org_id: string | null
|
|
26
|
+
created_by: string
|
|
27
|
+
name: string
|
|
28
|
+
email: string | null
|
|
29
|
+
verified: boolean
|
|
30
|
+
bio: string | null
|
|
31
|
+
avatar_url: string | null
|
|
32
|
+
created_at: Date
|
|
33
|
+
updated_at: Date
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
export interface CreatePublisherRequest {
|
|
37
|
+
id: string
|
|
38
|
+
name: string
|
|
39
|
+
email?: string
|
|
40
|
+
bio?: string
|
|
41
|
+
avatar_url?: string
|
|
42
|
+
org_id?: string // Optional: if creating for an organization
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
export interface UpdatePublisherRequest {
|
|
46
|
+
name?: string
|
|
47
|
+
email?: string
|
|
48
|
+
bio?: string
|
|
49
|
+
avatar_url?: string
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
export interface PublisherProfileResponse {
|
|
53
|
+
id: string
|
|
54
|
+
user_id: string | null
|
|
55
|
+
org_id: string | null
|
|
56
|
+
created_by: string
|
|
57
|
+
name: string
|
|
58
|
+
email: string | null
|
|
59
|
+
verified: boolean
|
|
60
|
+
bio: string | null
|
|
61
|
+
avatar_url: string | null
|
|
62
|
+
created_at: Date
|
|
63
|
+
updated_at: Date
|
|
64
|
+
agentCount?: number
|
|
65
|
+
ownershipType: 'user' | 'organization'
|
|
66
|
+
organizationName?: string // If owned by org
|
|
67
|
+
}
|