agenttwin 0.3.21 → 0.3.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/dist/api.js +2113 -609
- package/dist/dashboard/assets/dashboard/agent-home.css +7 -7
- package/dist/dashboard/assets/dashboard/bay-morning.webp +0 -0
- package/dist/dashboard/assets/dashboard/golden-gate-afternoon.webp +0 -0
- package/dist/dashboard/assets/dashboard/golden-gate-portrait.webp +0 -0
- package/dist/dashboard/assets/dashboard/moonlit-coast.webp +0 -0
- package/dist/dashboard/assets/next/static/chunks/5663-403316746afad10e.js +1 -0
- package/dist/dashboard/assets/next/static/chunks/app/dashboard/{page-9c11295678539a5f.js → page-0e0392368e0a891e.js} +1 -1
- package/dist/dashboard/assets/next/static/chunks/app/docs/[[...slug]]/page-4981ea4966b19e3e.js +1 -0
- package/dist/dashboard/assets/next/static/chunks/app/onboarding/page-dd4ac0f5f36e6bfa.js +1 -0
- package/dist/dashboard/assets/next/static/chunks/app/v2/dashboard/{page-34574448d210c775.js → page-de0fe6d84be21e6a.js} +1 -1
- package/dist/dashboard/assets/next/static/chunks/app/v2/onboarding/page-360cbffc57981f6b.js +1 -0
- package/dist/dashboard/assets/next/static/chunks/app/v2/{page-07c8054d57c9089b.js → page-3e86fffabfa87d88.js} +1 -1
- package/dist/dashboard/assets/next/static/chunks/{webpack-40324749d289e4a5.js → webpack-be6e526fd530c797.js} +1 -1
- package/dist/dashboard/assets/next/static/css/{42045de5f39b50ca.css → 37d81e1d2804cc5f.css} +1 -1
- package/dist/dashboard/assets/next/static/css/69ec1bae997c3bb0.css +1 -0
- package/dist/dashboard/assets/next/static/css/ad85402a1595e56e.css +1 -0
- package/dist/dashboard/assets/next/static/css/{4bbe78c2fe206b92.css → da981fb878a02b8c.css} +1 -1
- package/dist/dashboard/assets/next/static/media/bay-morning.82669113.webp +0 -0
- package/dist/dashboard/assets/next/static/media/golden-gate-afternoon.0aa49492.webp +0 -0
- package/dist/dashboard/assets/next/static/media/golden-gate-portrait.89fc667a.webp +0 -0
- package/dist/dashboard/assets/next/static/media/moonlit-coast.09739ef4.webp +0 -0
- package/dist/dashboard/index.html +2 -2
- package/dist/engine.js +6385 -4973
- package/dist/gateway.js +2194 -604
- package/dist/twins/catalog.json +6020 -0
- package/dist/twins/engine/v2/THIRD-PARTY.txt +25 -0
- package/dist/twins/engine/v2/chunks/2CHBP57N.mjs +8 -0
- package/dist/twins/engine/v2/chunks/4CPL6MPF.mjs +30 -0
- package/dist/twins/engine/v2/chunks/OYLYKZGD.mjs +2 -0
- package/dist/twins/engine/v2/chunks/SQSP35HM.mjs +38 -0
- package/dist/twins/engine/v2/chunks/YSJQQVUM.mjs +2 -0
- package/dist/twins/engine/v2/react-dom_client.mjs +272 -0
- package/dist/twins/engine/v2/react-dom_server.mjs +263 -0
- package/dist/twins/engine/v2/react.mjs +2 -0
- package/dist/twins/engine/v2/react_jsx-runtime.mjs +31 -0
- package/dist/twins/engine/v2/volter_world-core.mjs +195 -0
- package/dist/twins/engine/v2/volter_world-core_app-route.mjs +2 -0
- package/dist/twins/engine/v2/volter_world-core_network-policy.mjs +2 -0
- package/dist/twins/engine/v3/THIRD-PARTY.txt +65 -0
- package/dist/twins/engine/v3/chunks/2CHBP57N.mjs +8 -0
- package/dist/twins/engine/v3/chunks/2YSSPA5O.mjs +65 -0
- package/dist/twins/engine/v3/chunks/5PWRY4UK.mjs +154 -0
- package/dist/twins/engine/v3/chunks/7XRKSFFJ.mjs +2 -0
- package/dist/twins/engine/v3/chunks/AWOWH2H5.mjs +2 -0
- package/dist/twins/engine/v3/chunks/C46M5U3Q.mjs +2 -0
- package/dist/twins/engine/v3/chunks/MFH2VZPP.mjs +2 -0
- package/dist/twins/engine/v3/chunks/MWCO5UV3.mjs +2 -0
- package/dist/twins/engine/v3/chunks/N5BL5RDF.mjs +313 -0
- package/dist/twins/engine/v3/chunks/O7HGPMXG.mjs +2 -0
- package/dist/twins/engine/v3/chunks/OYLYKZGD.mjs +2 -0
- package/dist/twins/engine/v3/chunks/PLB7HTON.mjs +8 -0
- package/dist/twins/engine/v3/chunks/TY4LDBVH.mjs +7 -0
- package/dist/twins/engine/v3/chunks/VDIRUSCM.mjs +2 -0
- package/dist/twins/engine/v3/chunks/WGUCFQK6.mjs +2 -0
- package/dist/twins/engine/v3/chunks/WPATONSC.mjs +2 -0
- package/dist/twins/engine/v3/react_jsx-runtime.mjs +2 -0
- package/dist/twins/engine/v3/volter_world-core.mjs +2 -0
- package/dist/twins/engine/v3/volter_world-ui.mjs +559 -0
- package/dist/twins/packs/ahrefs/LICENSE +202 -0
- package/dist/twins/packs/ahrefs/NOTICE +7 -0
- package/dist/twins/packs/ahrefs/index.mjs +2 -0
- package/dist/twins/packs/ai-gateway/LICENSE +202 -0
- package/dist/twins/packs/ai-gateway/NOTICE +7 -0
- package/dist/twins/packs/ai-gateway/index.mjs +14 -0
- package/dist/twins/packs/airtable/LICENSE +202 -0
- package/dist/twins/packs/airtable/NOTICE +7 -0
- package/dist/twins/packs/airtable/index.mjs +2 -0
- package/dist/twins/packs/algolia/LICENSE +202 -0
- package/dist/twins/packs/algolia/NOTICE +7 -0
- package/dist/twins/packs/algolia/index.mjs +2 -0
- package/dist/twins/packs/ambientcg/LICENSE +202 -0
- package/dist/twins/packs/ambientcg/NOTICE +7 -0
- package/dist/twins/packs/ambientcg/index.mjs +2 -0
- package/dist/twins/packs/anthropic/LICENSE +202 -0
- package/dist/twins/packs/anthropic/NOTICE +7 -0
- package/dist/twins/packs/anthropic/index.mjs +18 -0
- package/dist/twins/packs/assemblyai/LICENSE +202 -0
- package/dist/twins/packs/assemblyai/NOTICE +7 -0
- package/dist/twins/packs/assemblyai/index.mjs +11 -0
- package/dist/twins/packs/aws/LICENSE +202 -0
- package/dist/twins/packs/aws/NOTICE +7 -0
- package/dist/twins/packs/aws/index.mjs +2 -0
- package/dist/twins/packs/azure/LICENSE +202 -0
- package/dist/twins/packs/azure/NOTICE +7 -0
- package/dist/twins/packs/azure/index.mjs +38 -0
- package/dist/twins/packs/azureformrecognizer/LICENSE +202 -0
- package/dist/twins/packs/azureformrecognizer/NOTICE +7 -0
- package/dist/twins/packs/azureformrecognizer/index.mjs +3 -0
- package/dist/twins/packs/bitly/LICENSE +202 -0
- package/dist/twins/packs/bitly/NOTICE +7 -0
- package/dist/twins/packs/bitly/index.mjs +2 -0
- package/dist/twins/packs/bluesky/LICENSE +202 -0
- package/dist/twins/packs/bluesky/NOTICE +7 -0
- package/dist/twins/packs/bluesky/index.mjs +30 -0
- package/dist/twins/packs/calcom/LICENSE +202 -0
- package/dist/twins/packs/calcom/NOTICE +7 -0
- package/dist/twins/packs/calcom/index.mjs +2 -0
- package/dist/twins/packs/clerk/LICENSE +202 -0
- package/dist/twins/packs/clerk/NOTICE +7 -0
- package/dist/twins/packs/clerk/index.mjs +5 -0
- package/dist/twins/packs/cloudflare/LICENSE +202 -0
- package/dist/twins/packs/cloudflare/NOTICE +7 -0
- package/dist/twins/packs/cloudflare/index.mjs +79 -0
- package/dist/twins/packs/cohere/LICENSE +202 -0
- package/dist/twins/packs/cohere/NOTICE +7 -0
- package/dist/twins/packs/cohere/index.mjs +2 -0
- package/dist/twins/packs/datadog/LICENSE +202 -0
- package/dist/twins/packs/datadog/NOTICE +7 -0
- package/dist/twins/packs/datadog/index.mjs +3 -0
- package/dist/twins/packs/deepinfra/LICENSE +202 -0
- package/dist/twins/packs/deepinfra/NOTICE +7 -0
- package/dist/twins/packs/deepinfra/index.mjs +13 -0
- package/dist/twins/packs/deepseek/LICENSE +202 -0
- package/dist/twins/packs/deepseek/NOTICE +7 -0
- package/dist/twins/packs/deepseek/index.mjs +12 -0
- package/dist/twins/packs/discord/LICENSE +202 -0
- package/dist/twins/packs/discord/NOTICE +7 -0
- package/dist/twins/packs/discord/index.mjs +2 -0
- package/dist/twins/packs/duckduckgo/LICENSE +202 -0
- package/dist/twins/packs/duckduckgo/NOTICE +7 -0
- package/dist/twins/packs/duckduckgo/index.mjs +532 -0
- package/dist/twins/packs/dynadot/LICENSE +202 -0
- package/dist/twins/packs/dynadot/NOTICE +7 -0
- package/dist/twins/packs/dynadot/index.mjs +2 -0
- package/dist/twins/packs/e2b/LICENSE +202 -0
- package/dist/twins/packs/e2b/NOTICE +7 -0
- package/dist/twins/packs/e2b/index.mjs +2 -0
- package/dist/twins/packs/elevenlabs/LICENSE +202 -0
- package/dist/twins/packs/elevenlabs/NOTICE +7 -0
- package/dist/twins/packs/elevenlabs/index.mjs +4 -0
- package/dist/twins/packs/expo/LICENSE +202 -0
- package/dist/twins/packs/expo/NOTICE +7 -0
- package/dist/twins/packs/expo/index.mjs +2 -0
- package/dist/twins/packs/fal/LICENSE +202 -0
- package/dist/twins/packs/fal/NOTICE +7 -0
- package/dist/twins/packs/fal/index.mjs +2 -0
- package/dist/twins/packs/figma/LICENSE +202 -0
- package/dist/twins/packs/figma/NOTICE +7 -0
- package/dist/twins/packs/figma/index.mjs +2 -0
- package/dist/twins/packs/firecrawl/LICENSE +202 -0
- package/dist/twins/packs/firecrawl/NOTICE +7 -0
- package/dist/twins/packs/firecrawl/index.mjs +9 -0
- package/dist/twins/packs/fireworks/LICENSE +202 -0
- package/dist/twins/packs/fireworks/NOTICE +7 -0
- package/dist/twins/packs/fireworks/index.mjs +13 -0
- package/dist/twins/packs/fly/LICENSE +202 -0
- package/dist/twins/packs/fly/NOTICE +7 -0
- package/dist/twins/packs/fly/index.mjs +2 -0
- package/dist/twins/packs/gcs/LICENSE +202 -0
- package/dist/twins/packs/gcs/NOTICE +7 -0
- package/dist/twins/packs/gcs/index.mjs +8 -0
- package/dist/twins/packs/gemini/LICENSE +202 -0
- package/dist/twins/packs/gemini/NOTICE +7 -0
- package/dist/twins/packs/gemini/index.mjs +7 -0
- package/dist/twins/packs/github/LICENSE +202 -0
- package/dist/twins/packs/github/NOTICE +7 -0
- package/dist/twins/packs/github/index.mjs +75153 -0
- package/dist/twins/packs/googleads/LICENSE +202 -0
- package/dist/twins/packs/googleads/NOTICE +7 -0
- package/dist/twins/packs/googleads/index.mjs +3 -0
- package/dist/twins/packs/googlemaps/LICENSE +202 -0
- package/dist/twins/packs/googlemaps/NOTICE +7 -0
- package/dist/twins/packs/googlemaps/index.mjs +2 -0
- package/dist/twins/packs/googleoauth/LICENSE +202 -0
- package/dist/twins/packs/googleoauth/NOTICE +7 -0
- package/dist/twins/packs/googleoauth/index.mjs +2 -0
- package/dist/twins/packs/hackernews/LICENSE +202 -0
- package/dist/twins/packs/hackernews/NOTICE +7 -0
- package/dist/twins/packs/hackernews/index.mjs +35 -0
- package/dist/twins/packs/huggingface/LICENSE +202 -0
- package/dist/twins/packs/huggingface/NOTICE +7 -0
- package/dist/twins/packs/huggingface/index.mjs +9 -0
- package/dist/twins/packs/inngest/LICENSE +202 -0
- package/dist/twins/packs/inngest/NOTICE +7 -0
- package/dist/twins/packs/inngest/index.mjs +2 -0
- package/dist/twins/packs/instagram/LICENSE +202 -0
- package/dist/twins/packs/instagram/NOTICE +7 -0
- package/dist/twins/packs/instagram/index.mjs +2 -0
- package/dist/twins/packs/jira/LICENSE +202 -0
- package/dist/twins/packs/jira/NOTICE +7 -0
- package/dist/twins/packs/jira/index.mjs +2 -0
- package/dist/twins/packs/langfuse/LICENSE +202 -0
- package/dist/twins/packs/langfuse/NOTICE +7 -0
- package/dist/twins/packs/langfuse/index.mjs +2 -0
- package/dist/twins/packs/linear/LICENSE +202 -0
- package/dist/twins/packs/linear/NOTICE +7 -0
- package/dist/twins/packs/linear/index.mjs +52866 -0
- package/dist/twins/packs/linkedin/LICENSE +202 -0
- package/dist/twins/packs/linkedin/NOTICE +7 -0
- package/dist/twins/packs/linkedin/index.mjs +78 -0
- package/dist/twins/packs/livekit/LICENSE +202 -0
- package/dist/twins/packs/livekit/NOTICE +7 -0
- package/dist/twins/packs/livekit/index.mjs +2 -0
- package/dist/twins/packs/mailgun/LICENSE +202 -0
- package/dist/twins/packs/mailgun/NOTICE +7 -0
- package/dist/twins/packs/mailgun/index.mjs +13 -0
- package/dist/twins/packs/mapbox/LICENSE +202 -0
- package/dist/twins/packs/mapbox/NOTICE +7 -0
- package/dist/twins/packs/mapbox/index.mjs +2 -0
- package/dist/twins/packs/merge/LICENSE +202 -0
- package/dist/twins/packs/merge/NOTICE +7 -0
- package/dist/twins/packs/merge/index.mjs +4 -0
- package/dist/twins/packs/mistral/LICENSE +202 -0
- package/dist/twins/packs/mistral/NOTICE +7 -0
- package/dist/twins/packs/mistral/index.mjs +6 -0
- package/dist/twins/packs/mixpanel/LICENSE +202 -0
- package/dist/twins/packs/mixpanel/NOTICE +8 -0
- package/dist/twins/packs/mixpanel/index.mjs +2 -0
- package/dist/twins/packs/mongodb/LICENSE +202 -0
- package/dist/twins/packs/mongodb/NOTICE +7 -0
- package/dist/twins/packs/mongodb/index.mjs +8 -0
- package/dist/twins/packs/moonshot/LICENSE +202 -0
- package/dist/twins/packs/moonshot/NOTICE +7 -0
- package/dist/twins/packs/moonshot/index.mjs +18 -0
- package/dist/twins/packs/notion/LICENSE +202 -0
- package/dist/twins/packs/notion/NOTICE +7 -0
- package/dist/twins/packs/notion/index.mjs +2 -0
- package/dist/twins/packs/npm-registry/LICENSE +202 -0
- package/dist/twins/packs/npm-registry/NOTICE +7 -0
- package/dist/twins/packs/npm-registry/index.mjs +2 -0
- package/dist/twins/packs/oa-treasury/LICENSE +202 -0
- package/dist/twins/packs/oa-treasury/NOTICE +8 -0
- package/dist/twins/packs/oa-treasury/index.mjs +16 -0
- package/dist/twins/packs/openai/LICENSE +202 -0
- package/dist/twins/packs/openai/NOTICE +7 -0
- package/dist/twins/packs/openai/index.mjs +3473 -0
- package/dist/twins/packs/openrouter/LICENSE +202 -0
- package/dist/twins/packs/openrouter/NOTICE +7 -0
- package/dist/twins/packs/openrouter/index.mjs +2 -0
- package/dist/twins/packs/openweather/LICENSE +202 -0
- package/dist/twins/packs/openweather/NOTICE +7 -0
- package/dist/twins/packs/openweather/index.mjs +2 -0
- package/dist/twins/packs/paypal/LICENSE +202 -0
- package/dist/twins/packs/paypal/NOTICE +7 -0
- package/dist/twins/packs/paypal/index.mjs +51 -0
- package/dist/twins/packs/pinecone/LICENSE +202 -0
- package/dist/twins/packs/pinecone/NOTICE +7 -0
- package/dist/twins/packs/pinecone/index.mjs +2 -0
- package/dist/twins/packs/plain/LICENSE +202 -0
- package/dist/twins/packs/plain/NOTICE +8 -0
- package/dist/twins/packs/plain/index.mjs +18426 -0
- package/dist/twins/packs/planetscale/LICENSE +202 -0
- package/dist/twins/packs/planetscale/NOTICE +7 -0
- package/dist/twins/packs/planetscale/index.mjs +18 -0
- package/dist/twins/packs/polar/LICENSE +202 -0
- package/dist/twins/packs/polar/NOTICE +7 -0
- package/dist/twins/packs/polar/index.mjs +2 -0
- package/dist/twins/packs/polyhaven/LICENSE +202 -0
- package/dist/twins/packs/polyhaven/NOTICE +7 -0
- package/dist/twins/packs/polyhaven/index.mjs +3 -0
- package/dist/twins/packs/postmark/LICENSE +202 -0
- package/dist/twins/packs/postmark/NOTICE +7 -0
- package/dist/twins/packs/postmark/index.mjs +12 -0
- package/dist/twins/packs/reddit/LICENSE +202 -0
- package/dist/twins/packs/reddit/NOTICE +7 -0
- package/dist/twins/packs/reddit/index.mjs +324 -0
- package/dist/twins/packs/redis/LICENSE +202 -0
- package/dist/twins/packs/redis/NOTICE +7 -0
- package/dist/twins/packs/redis/index.mjs +2 -0
- package/dist/twins/packs/replicate/LICENSE +202 -0
- package/dist/twins/packs/replicate/NOTICE +7 -0
- package/dist/twins/packs/replicate/index.mjs +2 -0
- package/dist/twins/packs/resend/LICENSE +202 -0
- package/dist/twins/packs/resend/NOTICE +7 -0
- package/dist/twins/packs/resend/index.mjs +139 -0
- package/dist/twins/packs/runhuman/LICENSE +202 -0
- package/dist/twins/packs/runhuman/NOTICE +7 -0
- package/dist/twins/packs/runhuman/index.mjs +3 -0
- package/dist/twins/packs/scrapecreators/LICENSE +202 -0
- package/dist/twins/packs/scrapecreators/NOTICE +7 -0
- package/dist/twins/packs/scrapecreators/index.mjs +2 -0
- package/dist/twins/packs/segment/LICENSE +202 -0
- package/dist/twins/packs/segment/NOTICE +8 -0
- package/dist/twins/packs/segment/index.mjs +2 -0
- package/dist/twins/packs/sendblue/LICENSE +202 -0
- package/dist/twins/packs/sendblue/NOTICE +7 -0
- package/dist/twins/packs/sendblue/index.mjs +2 -0
- package/dist/twins/packs/sendgrid/LICENSE +202 -0
- package/dist/twins/packs/sendgrid/NOTICE +8 -0
- package/dist/twins/packs/sendgrid/index.mjs +4 -0
- package/dist/twins/packs/sentry/LICENSE +202 -0
- package/dist/twins/packs/sentry/NOTICE +7 -0
- package/dist/twins/packs/sentry/index.mjs +5 -0
- package/dist/twins/packs/sigstore/LICENSE +202 -0
- package/dist/twins/packs/sigstore/NOTICE +7 -0
- package/dist/twins/packs/sigstore/index.mjs +12 -0
- package/dist/twins/packs/slack/LICENSE +202 -0
- package/dist/twins/packs/slack/NOTICE +7 -0
- package/dist/twins/packs/slack/index.mjs +66 -0
- package/dist/twins/packs/smtp/LICENSE +202 -0
- package/dist/twins/packs/smtp/NOTICE +7 -0
- package/dist/twins/packs/smtp/index.mjs +3 -0
- package/dist/twins/packs/snowflake/LICENSE +202 -0
- package/dist/twins/packs/snowflake/NOTICE +8 -0
- package/dist/twins/packs/snowflake/index.mjs +30 -0
- package/dist/twins/packs/stigg/LICENSE +202 -0
- package/dist/twins/packs/stigg/NOTICE +8 -0
- package/dist/twins/packs/stigg/index.mjs +22194 -0
- package/dist/twins/packs/stream/LICENSE +202 -0
- package/dist/twins/packs/stream/NOTICE +7 -0
- package/dist/twins/packs/stream/index.mjs +2 -0
- package/dist/twins/packs/stripe/LICENSE +202 -0
- package/dist/twins/packs/stripe/NOTICE +7 -0
- package/dist/twins/packs/stripe/index.mjs +211 -0
- package/dist/twins/packs/supabase/LICENSE +202 -0
- package/dist/twins/packs/supabase/NOTICE +7 -0
- package/dist/twins/packs/supabase/index.mjs +2 -0
- package/dist/twins/packs/supermemory/LICENSE +202 -0
- package/dist/twins/packs/supermemory/NOTICE +7 -0
- package/dist/twins/packs/supermemory/index.mjs +2 -0
- package/dist/twins/packs/svix/LICENSE +202 -0
- package/dist/twins/packs/svix/NOTICE +7 -0
- package/dist/twins/packs/svix/index.mjs +2 -0
- package/dist/twins/packs/tavily/LICENSE +202 -0
- package/dist/twins/packs/tavily/NOTICE +7 -0
- package/dist/twins/packs/tavily/index.mjs +2 -0
- package/dist/twins/packs/telegram/LICENSE +202 -0
- package/dist/twins/packs/telegram/NOTICE +7 -0
- package/dist/twins/packs/telegram/index.mjs +11 -0
- package/dist/twins/packs/temporal/LICENSE +202 -0
- package/dist/twins/packs/temporal/NOTICE +7 -0
- package/dist/twins/packs/temporal/index.mjs +44 -0
- package/dist/twins/packs/tiktok/LICENSE +202 -0
- package/dist/twins/packs/tiktok/NOTICE +7 -0
- package/dist/twins/packs/tiktok/index.mjs +2 -0
- package/dist/twins/packs/tinybird/LICENSE +202 -0
- package/dist/twins/packs/tinybird/NOTICE +7 -0
- package/dist/twins/packs/tinybird/index.mjs +50 -0
- package/dist/twins/packs/togetherai/LICENSE +202 -0
- package/dist/twins/packs/togetherai/NOTICE +7 -0
- package/dist/twins/packs/togetherai/index.mjs +11 -0
- package/dist/twins/packs/tremendous/LICENSE +202 -0
- package/dist/twins/packs/tremendous/NOTICE +7 -0
- package/dist/twins/packs/tremendous/index.mjs +2 -0
- package/dist/twins/packs/tripo/LICENSE +202 -0
- package/dist/twins/packs/tripo/NOTICE +7 -0
- package/dist/twins/packs/tripo/index.mjs +9 -0
- package/dist/twins/packs/tunnel/LICENSE +202 -0
- package/dist/twins/packs/tunnel/NOTICE +7 -0
- package/dist/twins/packs/tunnel/index.mjs +2 -0
- package/dist/twins/packs/twelvelabs/LICENSE +202 -0
- package/dist/twins/packs/twelvelabs/NOTICE +7 -0
- package/dist/twins/packs/twelvelabs/index.mjs +5 -0
- package/dist/twins/packs/twilio/LICENSE +202 -0
- package/dist/twins/packs/twilio/NOTICE +7 -0
- package/dist/twins/packs/twilio/index.mjs +2 -0
- package/dist/twins/packs/twitch/LICENSE +202 -0
- package/dist/twins/packs/twitch/NOTICE +7 -0
- package/dist/twins/packs/twitch/index.mjs +68 -0
- package/dist/twins/packs/upstash/LICENSE +202 -0
- package/dist/twins/packs/upstash/NOTICE +7 -0
- package/dist/twins/packs/upstash/index.mjs +14 -0
- package/dist/twins/packs/upstashvector/LICENSE +202 -0
- package/dist/twins/packs/upstashvector/NOTICE +7 -0
- package/dist/twins/packs/upstashvector/index.mjs +3 -0
- package/dist/twins/packs/vercel/LICENSE +202 -0
- package/dist/twins/packs/vercel/NOTICE +7 -0
- package/dist/twins/packs/vercel/index.mjs +10 -0
- package/dist/twins/packs/veriff/LICENSE +202 -0
- package/dist/twins/packs/veriff/NOTICE +7 -0
- package/dist/twins/packs/veriff/index.mjs +2 -0
- package/dist/twins/packs/vgauth/LICENSE +202 -0
- package/dist/twins/packs/vgauth/NOTICE +7 -0
- package/dist/twins/packs/vgauth/index.mjs +2 -0
- package/dist/twins/packs/vital/LICENSE +202 -0
- package/dist/twins/packs/vital/NOTICE +7 -0
- package/dist/twins/packs/vital/index.mjs +2 -0
- package/dist/twins/packs/volteridentity/LICENSE +202 -0
- package/dist/twins/packs/volteridentity/NOTICE +7 -0
- package/dist/twins/packs/volteridentity/index.mjs +2 -0
- package/dist/twins/packs/webrisk/LICENSE +202 -0
- package/dist/twins/packs/webrisk/NOTICE +7 -0
- package/dist/twins/packs/webrisk/index.mjs +2 -0
- package/dist/twins/packs/worldlabs/LICENSE +202 -0
- package/dist/twins/packs/worldlabs/NOTICE +7 -0
- package/dist/twins/packs/worldlabs/index.mjs +2 -0
- package/dist/twins/packs/x/LICENSE +202 -0
- package/dist/twins/packs/x/NOTICE +7 -0
- package/dist/twins/packs/x/index.mjs +63 -0
- package/dist/twins/packs/xai/LICENSE +202 -0
- package/dist/twins/packs/xai/NOTICE +7 -0
- package/dist/twins/packs/xai/index.mjs +4 -0
- package/dist/twins/packs/xidentity/LICENSE +202 -0
- package/dist/twins/packs/xidentity/NOTICE +8 -0
- package/dist/twins/packs/xidentity/index.mjs +209 -0
- package/dist/twins/packs/youtube/LICENSE +202 -0
- package/dist/twins/packs/youtube/NOTICE +7 -0
- package/dist/twins/packs/youtube/index.mjs +5 -0
- package/dist/worker.js +442 -18
- package/dist/world-host.js +928 -91
- package/package.json +5 -4
- package/dist/dashboard/assets/dashboard/bay-morning.png +0 -0
- package/dist/dashboard/assets/dashboard/golden-gate-afternoon.png +0 -0
- package/dist/dashboard/assets/dashboard/golden-gate-portrait.png +0 -0
- package/dist/dashboard/assets/dashboard/moonlit-coast.png +0 -0
- package/dist/dashboard/assets/next/static/chunks/2868-424d32cfc8ae81c9.js +0 -1
- package/dist/dashboard/assets/next/static/chunks/app/docs/[[...slug]]/page-f9fca2c08f779fa0.js +0 -1
- package/dist/dashboard/assets/next/static/chunks/app/onboarding/page-bc480c9258e5cc4d.js +0 -1
- package/dist/dashboard/assets/next/static/chunks/app/v2/onboarding/page-f04c0b236abaead3.js +0 -1
- package/dist/dashboard/assets/next/static/css/4af3c8ca0da0f48b.css +0 -1
- package/dist/dashboard/assets/next/static/css/6b8edde77e493a51.css +0 -1
- package/dist/dashboard/assets/next/static/media/bay-morning.1a9f358c.png +0 -0
- package/dist/dashboard/assets/next/static/media/golden-gate-afternoon.3e7cea58.png +0 -0
- package/dist/dashboard/assets/next/static/media/golden-gate-portrait.7941528f.png +0 -0
- package/dist/dashboard/assets/next/static/media/moonlit-coast.bbe901a1.png +0 -0
- /package/dist/dashboard/assets/next/static/{5ub3D2yzS8DE7w2qZd1nv → 8f121VqXS9LLPMmYd1SRn}/_buildManifest.js +0 -0
- /package/dist/dashboard/assets/next/static/{5ub3D2yzS8DE7w2qZd1nv → 8f121VqXS9LLPMmYd1SRn}/_ssgManifest.js +0 -0
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import{createRequire as __atReq}from'node:module';const require=__atReq(import.meta.url);
|
|
2
|
+
var w=Object.defineProperty;var A=(e,r)=>{for(var t in r)w(e,t,{get:r[t],enumerable:!0})};import{packOf as M,registerPack as R}from"../../engine/v3/volter_world-core.mjs";var o={vendor:"firecrawl",service:"firecrawl",body:{json:"always"},ids:{template:"{uuid}"},time:"iso",error:{success:!1,code:"{code}",error:"{message}",documentation_url:"https://docs.firecrawl.dev/api-reference/introduction"},answerHeaders:{"x-content-type-options":"nosniff"},readOnly:{status:403,message:"This World is read-only."},notFound:{status:404,code:"NOT_FOUND",message:"{method} {path} is not a Firecrawl API endpoint."},gap:{status:404,code:"NOT_FOUND",message:"{method} {path} is not a Firecrawl API endpoint."},deleted:{},resources:{_api_key:{idPrefix:"key_",ids:"{prefix}{n}"},_web_page:{idPrefix:"page_",ids:"{uuid}"}},unmodeled:["listAgents","startAgent","getAgentStatus","cancelAgent","getAgentSnapshot","getAgentTrace","scrapeAndExtractFromUrls","getBatchScrapeStatus","cancelBatchScrape","getBatchScrapeErrors","crawlUrls","getCrawlStatus","cancelCrawl","getCrawlErrors","getActiveCrawls","crawlParamsPreview","extractData","getExtractStatus","submitEndpointFeedback","listBrowserSessions","createBrowserSession","deleteBrowserSession","executeBrowserCode","mapUrls","listMonitors","createMonitor","getMonitor","updateMonitor","deleteMonitor","listMonitorChecks","getMonitorCheck","runMonitor","parseFile","getScrapeStatus","interactWithScrapeBrowserSession","stopInteractiveScrapeBrowserSession","searchAndScrape","submitSearchFeedback","developerSearch","developerSearchPost","researchSearchPapers","researchGetPaper","researchRelatedPapers","askSupportAgent","searchSupportDocs","getActivity","getCreditUsage","getHistoricalCreditUsage","getQueueStatus","getThreatProtection","updateThreatProtection","getTokenUsage","getHistoricalTokenUsage"],doors:[{id:"appCredentials",method:"POST",path:"/_twin/app-credentials",note:"Dashboard-issued first application credential"},{id:"pages",method:"POST",path:"/_twin/pages",note:"Synthetic public page content; no Firecrawl operation creates web pages"}],auth:{header:"authorization",scheme:"Bearer",gateWhenAbsent:!0,invalidKeys:[],held:{storedAs:"_api_key",hashField:"sha256"},wires:[{paths:"^/",error:{success:!1,error:"{message}"}}],missing:{status:401,message:"Unauthorized"},invalid:{status:401,message:"Unauthorized: Invalid token"}},vendorBacked:{none:"Scrape computes page content; _api_key and _web_page are World setup bookkeeping, not stored Firecrawl resources."},discovery:{twinOf:"Firecrawl API v2",stores:"Credential hashes and synthetic public pages",behavior:"Scrape returns held page content as markdown/rawHtml; no live web or model runs."},descriptor:{protocol:"3",transport:"rest",archetype:"crud",bin:"world-firecrawl",resources:[],specSource:"Firecrawl API v2 (spec/openapi.json.gz; provenance in spec/SOURCE.md)",description:"Firecrawl v2 scrape for LibreChat web search; deterministic held-page content.",adoption:{sdks:["@mendable/firecrawl-js"],envStems:["FIRECRAWL"]},hosts:[{host:"api.firecrawl.dev"}],endpointEnvNone:"LibreChat defaults to api.firecrawl.dev/v2/scrape; the World claims that host",clientCasesNone:"LibreChat uses axios in @librechat/agents@4.0.1 FirecrawlScraper; it uses no official Firecrawl SDK.",credentialDoor:{path:"/_twin/app-credentials",body:{},fill:{FIRECRAWL_API_KEY:"api_key"}}}};var d={generatedBy:"scripts/derive-pack.ts",spec:"openapi.json.gz",format:"openapi",version:"v2",basePath:"/v2",resources:[{name:"AgentTraceEvent",schema:"AgentTraceEvent",fields:[{name:"agent",type:"AgentTraceAgent",nullable:!1,required:!0},{name:"artifact",type:"AgentTraceArtifact",nullable:!1},{name:"durationMs",type:"integer",nullable:!1},{name:"error",type:"any",nullable:!0},{name:"eventId",type:"string",nullable:!1,required:!0},{name:"message",type:"string",nullable:!1},{name:"occurredAt",type:"string",nullable:!1,required:!0},{name:"outcome",type:"string",nullable:!1,enum:["succeeded","failed","cancelled","refused","credit_limit_reached"]},{name:"parameters",type:"any",nullable:!1},{name:"phase",type:"string",nullable:!1,enum:["planning","working","finalizing"]},{name:"producerSequence",type:"integer",nullable:!1,required:!0},{name:"reason",type:"string",nullable:!1,enum:["user"]},{name:"result",type:"any",nullable:!1},{name:"runId",type:"string",nullable:!1,required:!0},{name:"schemaVersion",type:"integer",nullable:!1,required:!0,enum:["1"],discriminator:!0},{name:"sessionId",type:"string",nullable:!1},{name:"text",type:"string",nullable:!1},{name:"toolCallId",type:"string",nullable:!1},{name:"toolName",type:"string",nullable:!1},{name:"type",type:"string",nullable:!1,required:!0,enum:["run.started","run.cancel_requested","run.finished","agent.started","agent.finished","browser.session.started","browser.session.finished","progress.reported","reasoning.summary","tool_call.started","tool_call.finished","artifact.updated","error.occurred"],discriminator:!0}],stateCandidates:[{field:"outcome",values:["cancelled","credit_limit_reached","failed","refused","succeeded"]},{field:"phase",values:["finalizing","planning","working"]}],expandable:[]},{name:"DeveloperSearchResult",schema:"DeveloperSearchResult",fields:[{name:"id",type:"string",nullable:!1},{name:"passages",type:"array",nullable:!1},{name:"title",type:"string",nullable:!1},{name:"type",type:"string",nullable:!1,enum:["doc","issue","pull_request","readme"]},{name:"url",type:"string",nullable:!1}],stateCandidates:[{field:"type",values:["doc","issue","pull_request","readme"]}],expandable:[]},{name:"Monitor",schema:"Monitor",fields:[{name:"createdAt",type:"string",nullable:!1},{name:"currentCheckId",type:"string",nullable:!0},{name:"estimatedCreditsPerMonth",type:"integer",nullable:!0},{name:"goal",type:"string",nullable:!0},{name:"id",type:"string",nullable:!1},{name:"judgeEnabled",type:"boolean",nullable:!1},{name:"lastCheckSummary",type:"MonitorSummary",nullable:!1},{name:"lastRunAt",type:"string",nullable:!0},{name:"name",type:"string",nullable:!1},{name:"nextRunAt",type:"string",nullable:!0},{name:"notification",type:"MonitorNotification",nullable:!1},{name:"retentionDays",type:"integer",nullable:!1},{name:"schedule",type:"object",nullable:!1},{name:"status",type:"string",nullable:!1,enum:["active","paused","deleted"]},{name:"targets",type:"array",nullable:!1},{name:"updatedAt",type:"string",nullable:!1},{name:"webhook",type:"MonitorWebhook",nullable:!1}],stateCandidates:[{field:"status",values:["active","deleted","paused"]}],expandable:[]},{name:"MonitorCheck",schema:"MonitorCheck",fields:[{name:"actualCredits",type:"integer",nullable:!0},{name:"billingStatus",type:"string",nullable:!1},{name:"createdAt",type:"string",nullable:!1},{name:"error",type:"string",nullable:!0},{name:"estimatedCredits",type:"integer",nullable:!0},{name:"finishedAt",type:"string",nullable:!0},{name:"id",type:"string",nullable:!1},{name:"monitorId",type:"string",nullable:!1},{name:"notificationStatus",type:"object",nullable:!0},{name:"reservedCredits",type:"integer",nullable:!0},{name:"scheduledFor",type:"string",nullable:!0},{name:"startedAt",type:"string",nullable:!0},{name:"status",type:"string",nullable:!1,enum:["queued","running","completed","failed","partial","skipped_overlap","skipped_no_credits"]},{name:"summary",type:"MonitorSummary",nullable:!1},{name:"targetResults",type:"array",nullable:!0},{name:"trigger",type:"string",nullable:!1,enum:["scheduled","manual"]},{name:"updatedAt",type:"string",nullable:!1}],stateCandidates:[{field:"status",values:["completed","failed","partial","queued","running","skipped_no_credits","skipped_overlap"]},{field:"trigger",values:["manual","scheduled"]}],expandable:[]},{name:"ResearchPaperResult",schema:"ResearchPaperResult",fields:[{name:"abstract",type:"string",nullable:!1,required:!0},{name:"ids",type:"ResearchIdMap",nullable:!1},{name:"paperId",type:"string",nullable:!1,required:!0},{name:"primaryId",type:"string",nullable:!1,required:!0},{name:"score",type:"number",nullable:!1,required:!0},{name:"signals",type:"ResearchPaperSignals",nullable:!1},{name:"title",type:"string",nullable:!1,required:!0}],stateCandidates:[],expandable:[]}],operations:[{id:"listAgents",method:"get",path:"/agent",pathParams:[],query:[{name:"before",type:"integer",required:!1,minimum:0}],body:[],bodyEncoding:"none",successStatus:200,credentials:["bearerAuth"],class:"computed"},{id:"startAgent",method:"post",path:"/agent",pathParams:[],query:[],body:[{name:"auditMetadata",type:"AuditMetadata",required:!1},{name:"effort",type:"string",required:!1},{name:"maxCredits",type:"number",required:!1},{name:"model",type:"string",required:!1},{name:"prompt",type:"string",required:!0},{name:"schema",type:"object",required:!1},{name:"strictConstrainToURLs",type:"boolean",required:!1},{name:"threatProtection",type:"ThreatProtectionOverride",required:!1},{name:"urls",type:"array",required:!1},{name:"webhook",type:"object",required:!1}],bodyEncoding:"json",successStatus:200,credentials:["bearerAuth"],class:"non-resource"},{id:"getAgentStatus",method:"get",path:"/agent/{jobId}",pathParams:["jobId"],query:[],body:[],bodyEncoding:"none",successStatus:200,credentials:["bearerAuth"],class:"computed"},{id:"cancelAgent",method:"delete",path:"/agent/{jobId}",pathParams:["jobId"],query:[],body:[],bodyEncoding:"none",successStatus:200,credentials:["bearerAuth"],class:"delete"},{id:"getAgentSnapshot",method:"get",path:"/agent/{jobId}/snapshots/{snapshotId}",pathParams:["jobId","snapshotId"],query:[],body:[],bodyEncoding:"none",successStatus:200,credentials:["bearerAuth"],class:"computed"},{id:"getAgentTrace",method:"get",path:"/agent/{jobId}/trace",pathParams:["jobId"],query:[{name:"liveView",type:"string",required:!1}],body:[],bodyEncoding:"none",successStatus:200,credentials:["bearerAuth"],class:"computed"},{id:"scrapeAndExtractFromUrls",method:"post",path:"/batch/scrape",pathParams:[],query:[],body:[],bodyEncoding:"json",successStatus:200,credentials:["bearerAuth"],class:"non-resource"},{id:"getBatchScrapeStatus",method:"get",path:"/batch/scrape/{id}",pathParams:["id"],query:[],body:[],bodyEncoding:"none",successStatus:200,credentials:["bearerAuth"],class:"computed"},{id:"cancelBatchScrape",method:"delete",path:"/batch/scrape/{id}",pathParams:["id"],query:[],body:[],bodyEncoding:"none",successStatus:200,credentials:["bearerAuth"],class:"delete"},{id:"getBatchScrapeErrors",method:"get",path:"/batch/scrape/{id}/errors",pathParams:["id"],query:[],body:[],bodyEncoding:"none",successStatus:200,credentials:["bearerAuth"],class:"retrieve",resource:"CrawlErrorsResponseObj"},{id:"crawlUrls",method:"post",path:"/crawl",pathParams:[],query:[],body:[{name:"allowExternalLinks",type:"boolean",required:!1},{name:"allowSubdomains",type:"boolean",required:!1},{name:"crawlEntireDomain",type:"boolean",required:!1},{name:"delay",type:"number",required:!1},{name:"excludePaths",type:"array",required:!1},{name:"ignoreQueryParameters",type:"boolean",required:!1},{name:"ignoreRobotsTxt",type:"boolean",required:!1},{name:"includePaths",type:"array",required:!1},{name:"limit",type:"integer",required:!1},{name:"maxConcurrency",type:"integer",required:!1},{name:"maxDiscoveryDepth",type:"integer",required:!1},{name:"prompt",type:"string",required:!1},{name:"regexOnFullURL",type:"boolean",required:!1},{name:"robotsUserAgent",type:"string",required:!1},{name:"scrapeOptions",type:"ScrapeOptions",required:!1},{name:"sitemap",type:"string",required:!1},{name:"url",type:"string",required:!0},{name:"webhook",type:"object",required:!1},{name:"zeroDataRetention",type:"boolean",required:!1}],bodyEncoding:"json",successStatus:200,credentials:["bearerAuth"],class:"non-resource"},{id:"getCrawlStatus",method:"get",path:"/crawl/{id}",pathParams:["id"],query:[],body:[],bodyEncoding:"none",successStatus:200,credentials:["bearerAuth"],class:"computed"},{id:"cancelCrawl",method:"delete",path:"/crawl/{id}",pathParams:["id"],query:[],body:[],bodyEncoding:"none",successStatus:200,credentials:["bearerAuth"],class:"delete"},{id:"getCrawlErrors",method:"get",path:"/crawl/{id}/errors",pathParams:["id"],query:[],body:[],bodyEncoding:"none",successStatus:200,credentials:["bearerAuth"],class:"retrieve",resource:"CrawlErrorsResponseObj"},{id:"getActiveCrawls",method:"get",path:"/crawl/active",pathParams:[],query:[],body:[],bodyEncoding:"none",successStatus:200,credentials:["bearerAuth"],class:"computed"},{id:"crawlParamsPreview",method:"post",path:"/crawl/params-preview",pathParams:[],query:[],body:[{name:"prompt",type:"string",required:!0},{name:"url",type:"string",required:!0}],bodyEncoding:"json",successStatus:200,credentials:["bearerAuth"],class:"non-resource"},{id:"extractData",method:"post",path:"/extract",pathParams:[],query:[],body:[{name:"enableWebSearch",type:"boolean",required:!1},{name:"ignoreInvalidURLs",type:"boolean",required:!1},{name:"ignoreSitemap",type:"boolean",required:!1},{name:"includeSubdomains",type:"boolean",required:!1},{name:"prompt",type:"string",required:!1},{name:"schema",type:"object",required:!1},{name:"scrapeOptions",type:"ScrapeOptions",required:!1},{name:"showSources",type:"boolean",required:!1},{name:"threatProtection",type:"ThreatProtectionOverride",required:!1},{name:"urls",type:"array",required:!0}],bodyEncoding:"json",successStatus:200,credentials:["bearerAuth"],class:"non-resource"},{id:"getExtractStatus",method:"get",path:"/extract/{id}",pathParams:["id"],query:[],body:[],bodyEncoding:"none",successStatus:200,credentials:["bearerAuth"],class:"computed"},{id:"submitEndpointFeedback",method:"post",path:"/feedback",pathParams:[],query:[],body:[],bodyEncoding:"json",successStatus:200,credentials:["bearerAuth"],class:"non-resource"},{id:"listBrowserSessions",method:"get",path:"/interact",pathParams:[],query:[{name:"status",type:"string",required:!1}],body:[],bodyEncoding:"none",successStatus:200,credentials:["bearerAuth"],class:"computed"},{id:"createBrowserSession",method:"post",path:"/interact",pathParams:[],query:[],body:[{name:"activityTtl",type:"integer",required:!1,minimum:10,maximum:3600},{name:"profile",type:"object",required:!1},{name:"streamWebView",type:"boolean",required:!1},{name:"ttl",type:"integer",required:!1,minimum:30,maximum:3600}],bodyEncoding:"json",successStatus:200,credentials:["bearerAuth"],class:"non-resource"},{id:"deleteBrowserSession",method:"delete",path:"/interact/{sessionId}",pathParams:["sessionId"],query:[],body:[],bodyEncoding:"none",successStatus:200,credentials:["bearerAuth"],class:"delete"},{id:"executeBrowserCode",method:"post",path:"/interact/{sessionId}/execute",pathParams:["sessionId"],query:[],body:[{name:"code",type:"string",required:!0},{name:"language",type:"string",required:!1},{name:"timeout",type:"integer",required:!1,minimum:1,maximum:300}],bodyEncoding:"json",successStatus:200,credentials:["bearerAuth"],class:"non-resource"},{id:"mapUrls",method:"post",path:"/map",pathParams:[],query:[],body:[{name:"auditMetadata",type:"AuditMetadata",required:!1},{name:"ignoreCache",type:"boolean",required:!1},{name:"ignoreQueryParameters",type:"boolean",required:!1},{name:"includeSubdomains",type:"boolean",required:!1},{name:"limit",type:"integer",required:!1,maximum:1e5},{name:"location",type:"object",required:!1},{name:"search",type:"string",required:!1},{name:"sitemap",type:"string",required:!1},{name:"threatProtection",type:"ThreatProtectionOverride",required:!1},{name:"timeout",type:"integer",required:!1},{name:"url",type:"string",required:!0}],bodyEncoding:"json",successStatus:200,credentials:["bearerAuth"],class:"non-resource"},{id:"listMonitors",method:"get",path:"/monitor",pathParams:[],query:[{name:"limit",type:"integer",required:!1,minimum:1,maximum:100},{name:"offset",type:"integer",required:!1,minimum:0}],body:[],bodyEncoding:"none",successStatus:200,credentials:["bearerAuth"],answers:{resource:"Monitor",list:!0},class:"list",resource:"Monitor"},{id:"createMonitor",method:"post",path:"/monitor",pathParams:[],query:[],body:[{name:"goal",type:"string",required:!1},{name:"judgeEnabled",type:"boolean",required:!1},{name:"name",type:"string",required:!0},{name:"notification",type:"MonitorNotification",required:!1},{name:"retentionDays",type:"integer",required:!1,minimum:1,maximum:365},{name:"schedule",type:"MonitorSchedule",required:!0},{name:"targets",type:"array",required:!0},{name:"webhook",type:"MonitorWebhook",required:!1}],bodyEncoding:"json",successStatus:200,credentials:["bearerAuth"],answers:{resource:"Monitor",list:!1,key:"data"},class:"create",resource:"Monitor"},{id:"getMonitor",method:"get",path:"/monitor/{monitorId}",pathParams:["monitorId"],query:[],body:[],bodyEncoding:"none",successStatus:200,credentials:["bearerAuth"],answers:{resource:"Monitor",list:!1,key:"data"},class:"retrieve",resource:"Monitor"},{id:"updateMonitor",method:"patch",path:"/monitor/{monitorId}",pathParams:["monitorId"],query:[],body:[{name:"goal",type:"string",required:!1},{name:"judgeEnabled",type:"boolean",required:!1},{name:"name",type:"string",required:!1},{name:"notification",type:"MonitorNotification",required:!1},{name:"retentionDays",type:"integer",required:!1,minimum:1,maximum:365},{name:"schedule",type:"MonitorSchedule",required:!1},{name:"status",type:"string",required:!1},{name:"targets",type:"array",required:!1},{name:"webhook",type:"MonitorWebhook",required:!1}],bodyEncoding:"json",successStatus:200,credentials:["bearerAuth"],answers:{resource:"Monitor",list:!1,key:"data"},class:"update",resource:"Monitor"},{id:"deleteMonitor",method:"delete",path:"/monitor/{monitorId}",pathParams:["monitorId"],query:[],body:[],bodyEncoding:"none",successStatus:200,credentials:["bearerAuth"],class:"delete",resource:"Monitor"},{id:"listMonitorChecks",method:"get",path:"/monitor/{monitorId}/checks",pathParams:["monitorId"],query:[{name:"limit",type:"integer",required:!1,minimum:1,maximum:100},{name:"offset",type:"integer",required:!1,minimum:0},{name:"status",type:"string",required:!1}],body:[],bodyEncoding:"none",successStatus:200,credentials:["bearerAuth"],answers:{resource:"MonitorCheck",list:!0},class:"list",resource:"MonitorCheck"},{id:"getMonitorCheck",method:"get",path:"/monitor/{monitorId}/checks/{checkId}",pathParams:["monitorId","checkId"],query:[{name:"limit",type:"integer",required:!1,minimum:1,maximum:100},{name:"skip",type:"integer",required:!1,minimum:0},{name:"status",type:"string",required:!1}],body:[],bodyEncoding:"none",successStatus:200,credentials:["bearerAuth"],answers:{resource:"MonitorCheck",list:!1,key:"data"},class:"retrieve",resource:"MonitorCheck"},{id:"runMonitor",method:"post",path:"/monitor/{monitorId}/run",pathParams:["monitorId"],query:[],body:[],bodyEncoding:"none",successStatus:200,credentials:["bearerAuth"],answers:{resource:"MonitorCheck",list:!1,key:"data"},class:"action",resource:"Monitor"},{id:"parseFile",method:"post",path:"/parse",pathParams:[],query:[],body:[{name:"file",type:"string",required:!0},{name:"options",type:"ParseOptions",required:!1}],bodyEncoding:"multipart",successStatus:200,credentials:["bearerAuth"],class:"non-resource"},{id:"scrapeAndExtractFromUrl",method:"post",path:"/scrape",pathParams:[],query:[],body:[],bodyEncoding:"json",successStatus:200,credentials:["bearerAuth"],class:"non-resource"},{id:"getScrapeStatus",method:"get",path:"/scrape/{jobId}",pathParams:["jobId"],query:[],body:[],bodyEncoding:"none",successStatus:200,credentials:["bearerAuth"],class:"computed"},{id:"interactWithScrapeBrowserSession",method:"post",path:"/scrape/{jobId}/interact",pathParams:["jobId"],query:[],body:[{name:"code",type:"string",required:!0},{name:"language",type:"string",required:!1},{name:"origin",type:"string",required:!1},{name:"timeout",type:"integer",required:!1,minimum:1,maximum:300}],bodyEncoding:"json",successStatus:200,credentials:["bearerAuth"],class:"non-resource"},{id:"stopInteractiveScrapeBrowserSession",method:"delete",path:"/scrape/{jobId}/interact",pathParams:["jobId"],query:[],body:[],bodyEncoding:"none",successStatus:200,credentials:["bearerAuth"],class:"action"},{id:"searchAndScrape",method:"post",path:"/search",pathParams:[],query:[],body:[{name:"categories",type:"array",required:!1},{name:"country",type:"string",required:!1},{name:"domainTools",type:"boolean",required:!1},{name:"enterprise",type:"array",required:!1},{name:"excludeDomains",type:"array",required:!1},{name:"highlights",type:"boolean",required:!1},{name:"ignoreInvalidURLs",type:"boolean",required:!1},{name:"includeDomains",type:"array",required:!1},{name:"limit",type:"integer",required:!1,minimum:1,maximum:100},{name:"location",type:"string",required:!1},{name:"query",type:"string",required:!0},{name:"safe",type:"boolean",required:!1},{name:"scrapeOptions",type:"any",required:!1},{name:"sources",type:"array",required:!1},{name:"tbs",type:"string",required:!1},{name:"threatProtection",type:"ThreatProtectionOverride",required:!1},{name:"timeout",type:"integer",required:!1}],bodyEncoding:"json",successStatus:200,credentials:["bearerAuth"],class:"non-resource"},{id:"submitSearchFeedback",method:"post",path:"/search/{jobId}/feedback",pathParams:["jobId"],query:[],body:[{name:"integration",type:"string",required:!1},{name:"missingContent",type:"array",required:!1},{name:"origin",type:"string",required:!1},{name:"querySuggestions",type:"string",required:!1},{name:"rating",type:"string",required:!0},{name:"valuableSources",type:"array",required:!1}],bodyEncoding:"json",successStatus:200,credentials:["bearerAuth"],class:"non-resource"},{id:"developerSearch",method:"get",path:"/search/developer",pathParams:[],query:[{name:"archived",type:"boolean",required:!1},{name:"fork",type:"boolean",required:!1},{name:"k",type:"integer",required:!1,minimum:1,maximum:100},{name:"language",type:"string",required:!1},{name:"license",type:"string",required:!1},{name:"max_stars",type:"integer",required:!1,minimum:0},{name:"min_stars",type:"integer",required:!1,minimum:0},{name:"passages",type:"integer",required:!1,minimum:1,maximum:5},{name:"query",type:"string",required:!0},{name:"repos",type:"array",required:!1},{name:"skills",type:"string",required:!1},{name:"sources",type:"array",required:!1},{name:"topic",type:"string",required:!1},{name:"types",type:"array",required:!1}],body:[],bodyEncoding:"none",successStatus:200,credentials:["bearerAuth"],class:"retrieve",resource:"DeveloperSearchResponse"},{id:"developerSearchPost",method:"post",path:"/search/developer",pathParams:[],query:[],body:[{name:"archived",type:"boolean",required:!1},{name:"fork",type:"boolean",required:!1},{name:"k",type:"integer",required:!1,minimum:1,maximum:100},{name:"language",type:"string",required:!1},{name:"license",type:"string",required:!1},{name:"max_stars",type:"integer",required:!1,minimum:0},{name:"min_stars",type:"integer",required:!1,minimum:0},{name:"passages",type:"integer",required:!1,minimum:1,maximum:5},{name:"query",type:"string",required:!0},{name:"repos",type:"array",required:!1},{name:"skills",type:"string",required:!1},{name:"sources",type:"array",required:!1},{name:"topic",type:"string",required:!1},{name:"types",type:"array",required:!1}],bodyEncoding:"json",successStatus:200,credentials:["bearerAuth"],class:"non-resource"},{id:"researchSearchPapers",method:"get",path:"/search/research/papers",pathParams:[],query:[{name:"authors",type:"string",required:!1},{name:"categories",type:"string",required:!1},{name:"from",type:"string",required:!1},{name:"k",type:"integer",required:!1,minimum:1,maximum:500},{name:"query",type:"string",required:!0},{name:"to",type:"string",required:!1}],body:[],bodyEncoding:"none",successStatus:200,credentials:["bearerAuth"],answers:{resource:"ResearchPaperResult",list:!0,key:"results"},class:"list",resource:"ResearchPaperResult"},{id:"researchGetPaper",method:"get",path:"/search/research/papers/{id}",pathParams:["id"],query:[{name:"k",type:"integer",required:!1,minimum:1,maximum:50},{name:"query",type:"string",required:!1}],body:[],bodyEncoding:"none",successStatus:200,credentials:["bearerAuth"],class:"computed"},{id:"researchRelatedPapers",method:"get",path:"/search/research/papers/{id}/similar",pathParams:["id"],query:[{name:"anchor",type:"string",required:!1},{name:"intent",type:"string",required:!0},{name:"k",type:"integer",required:!1,minimum:1,maximum:500},{name:"mode",type:"string",required:!1},{name:"rerank",type:"boolean",required:!1}],body:[],bodyEncoding:"none",successStatus:200,credentials:["bearerAuth"],answers:{resource:"ResearchPaperResult",list:!0,key:"results"},class:"list",resource:"ResearchPaperResult"},{id:"askSupportAgent",method:"post",path:"/support/ask",pathParams:[],query:[],body:[{name:"question",type:"string",required:!0},{name:"rationale",type:"string",required:!1}],bodyEncoding:"json",successStatus:200,credentials:["bearerAuth"],class:"non-resource"},{id:"searchSupportDocs",method:"post",path:"/support/docs-search",pathParams:[],query:[],body:[{name:"question",type:"string",required:!0}],bodyEncoding:"json",successStatus:200,credentials:["bearerAuth"],class:"non-resource"},{id:"getActivity",method:"get",path:"/team/activity",pathParams:[],query:[{name:"cursor",type:"string",required:!1},{name:"endpoint",type:"string",required:!1},{name:"limit",type:"integer",required:!1,minimum:1,maximum:100}],body:[],bodyEncoding:"none",successStatus:200,credentials:["bearerAuth"],class:"computed"},{id:"getCreditUsage",method:"get",path:"/team/credit-usage",pathParams:[],query:[],body:[],bodyEncoding:"none",successStatus:200,credentials:["bearerAuth"],class:"computed"},{id:"getHistoricalCreditUsage",method:"get",path:"/team/credit-usage/historical",pathParams:[],query:[{name:"byApiKey",type:"boolean",required:!1}],body:[],bodyEncoding:"none",successStatus:200,credentials:["bearerAuth"],class:"computed"},{id:"getQueueStatus",method:"get",path:"/team/queue-status",pathParams:[],query:[],body:[],bodyEncoding:"none",successStatus:200,credentials:["bearerAuth"],class:"computed"},{id:"getThreatProtection",method:"get",path:"/team/threat-protection",pathParams:[],query:[],body:[],bodyEncoding:"none",successStatus:200,credentials:["bearerAuth"],class:"computed"},{id:"updateThreatProtection",method:"put",path:"/team/threat-protection",pathParams:[],query:[],body:[{name:"allowRequestOverrides",type:"boolean",required:!1},{name:"blacklist",type:"array",required:!1},{name:"blockedTlds",type:"array",required:!1},{name:"failurePolicy",type:"string",required:!1},{name:"mode",type:"string",required:!0},{name:"riskScoreThreshold",type:"integer",required:!1,minimum:0,maximum:100},{name:"whitelist",type:"array",required:!1}],bodyEncoding:"json",successStatus:200,credentials:["bearerAuth"],class:"update"},{id:"getTokenUsage",method:"get",path:"/team/token-usage",pathParams:[],query:[],body:[],bodyEncoding:"none",successStatus:200,credentials:["bearerAuth"],class:"computed"},{id:"getHistoricalTokenUsage",method:"get",path:"/team/token-usage/historical",pathParams:[],query:[{name:"byApiKey",type:"boolean",required:!1}],body:[],bodyEncoding:"none",successStatus:200,credentials:["bearerAuth"],class:"computed"}]};import{createPackFetch as C}from"../../engine/v3/volter_world-core.mjs";var c={};A(c,{appCredentials:()=>E,pages:()=>v});var l="_api_key",n="_web_page",p=(e,r)=>e.crypto.digest("sha256",r,"hex"),y=async(e,r)=>`fc-${e.crypto.digest("sha256",await e.secret(r),"hex").slice(0,32)}`;async function h(e,r){let t=e.mint(l),a=`firecrawl-api-key:${t}`,s=await y(e,a);return await e.record(l,{name:r,label:a,created:e.occurredAt,sha256:p(e,s)},t),s}async function g(e,r){let t=e.rowsRaw(l).find(s=>s.deleted!==!0&&s.name===r);if(!t)return;let a=await y(e,String(t.label));return p(e,a)===t.sha256?a:void 0}var u=(e,r,t)=>Response.json({success:!1,...t?{code:t}:{},error:r},{status:e});function b(e){return(/<body[^>]*>([\s\S]*)<\/body>/i.exec(e)?.[1]??e).replace(/<(script|style|noscript)[^>]*>[\s\S]*?<\/\1>/gi,"").replace(/<h([1-6])[^>]*>([\s\S]*?)<\/h\1>/gi,(t,a,s)=>`
|
|
3
|
+
${"#".repeat(Number(a))} ${s.trim()}
|
|
4
|
+
`).replace(/<a [^>]*href="([^"]*)"[^>]*>([\s\S]*?)<\/a>/gi,(t,a,s)=>`[${s.trim()}](${a})`).replace(/<li[^>]*>/gi,`
|
|
5
|
+
- `).replace(/<(p|div|br|tr)[^>]*>/gi,`
|
|
6
|
+
`).replace(/<[^>]+>/g,"").replace(/ /g," ").replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,'"').replace(/'/g,"'").replace(/[ \t]+\n/g,`
|
|
7
|
+
`).replace(/\n{3,}/g,`
|
|
8
|
+
|
|
9
|
+
`).trim()}var k=e=>e.body&&typeof e.body=="object"?e.body:{};async function E(e){return Response.json({api_key:await g(e,"world-app")??await h(e,"world-app")},{status:201})}async function v(e){let r=k(e);if(typeof r.url!="string"||!/^https?:\/\//.test(r.url))return Response.json({error:"url is an http(s) URL"},{status:400});if(typeof r.html!="string")return Response.json({error:"html is a string"},{status:400});let t=e.rowsRaw(n).find(s=>s.deleted!==!0&&s.url===r.url),a=String(t?.id??e.mint(n));return await e.record(n,{url:r.url,title:typeof r.title=="string"?r.title:"",html:r.html,put:e.occurredAt},a),Response.json({url:r.url,id:a},{status:201})}var j=new Set(["markdown","rawHtml"]);function x(e,r){let t=e.rowsRaw(n).find(s=>s.deleted!==!0&&s.url===r);if(!t)return;let a=String(t.html);return{html:a,markdown:b(a),title:String(t.title??/<title[^>]*>([\s\S]*?)<\/title>/i.exec(a)?.[1]?.trim()??"")}}async function f(e){let r=e.body&&typeof e.body=="object"?e.body:{};if(typeof r.url!="string"||!/^https?:\/\//.test(r.url))return u(400,"Bad Request: url must be a valid http(s) URL","BAD_REQUEST");let t=(Array.isArray(r.formats)?r.formats:["markdown"]).map(i=>typeof i=="string"?i:String(i.type??"")),a=x(e,r.url);if(!a)return u(500,`All scraping engines failed! The twin reaches no page outside the World: ${r.url}`,"SCRAPE_ALL_ENGINES_FAILED");let s=t.filter(i=>!j.has(i)),S={...t.includes("markdown")?{markdown:a.markdown}:{},...t.includes("rawHtml")?{rawHtml:a.html}:{},metadata:{title:a.title,language:"en",sourceURL:r.url,url:r.url,statusCode:200,contentType:"text/html",scrapeId:e.crypto.uuidFrom(`firecrawl-scrape:${e.occurredAt}:${r.url}`),proxyUsed:"basic",cacheState:"miss",creditsUsed:1},...s.length?{warning:`twin: ${s.join(", ")} not produced; no browser or model runs`}:{}};return Response.json({success:!0,data:S})}var q={scrapeAndExtractFromUrl:f};function m(e={}){return C({manifest:o,surface:d,handlers:q,doors:c},e)}import{serveHttp as z}from"../../engine/v3/volter_world-core.mjs";var Z=R(M(o,d));export{m as createTwinFetch};
|
|
@@ -0,0 +1,202 @@
|
|
|
1
|
+
|
|
2
|
+
Apache License
|
|
3
|
+
Version 2.0, January 2004
|
|
4
|
+
http://www.apache.org/licenses/
|
|
5
|
+
|
|
6
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
7
|
+
|
|
8
|
+
1. Definitions.
|
|
9
|
+
|
|
10
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
|
11
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
|
12
|
+
|
|
13
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
|
14
|
+
the copyright owner that is granting the License.
|
|
15
|
+
|
|
16
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
|
17
|
+
other entities that control, are controlled by, or are under common
|
|
18
|
+
control with that entity. For the purposes of this definition,
|
|
19
|
+
"control" means (i) the power, direct or indirect, to cause the
|
|
20
|
+
direction or management of such entity, whether by contract or
|
|
21
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
22
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
23
|
+
|
|
24
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
|
25
|
+
exercising permissions granted by this License.
|
|
26
|
+
|
|
27
|
+
"Source" form shall mean the preferred form for making modifications,
|
|
28
|
+
including but not limited to software source code, documentation
|
|
29
|
+
source, and configuration files.
|
|
30
|
+
|
|
31
|
+
"Object" form shall mean any form resulting from mechanical
|
|
32
|
+
transformation or translation of a Source form, including but
|
|
33
|
+
not limited to compiled object code, generated documentation,
|
|
34
|
+
and conversions to other media types.
|
|
35
|
+
|
|
36
|
+
"Work" shall mean the work of authorship, whether in Source or
|
|
37
|
+
Object form, made available under the License, as indicated by a
|
|
38
|
+
copyright notice that is included in or attached to the work
|
|
39
|
+
(an example is provided in the Appendix below).
|
|
40
|
+
|
|
41
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
|
42
|
+
form, that is based on (or derived from) the Work and for which the
|
|
43
|
+
editorial revisions, annotations, elaborations, or other modifications
|
|
44
|
+
represent, as a whole, an original work of authorship. For the purposes
|
|
45
|
+
of this License, Derivative Works shall not include works that remain
|
|
46
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
|
47
|
+
the Work and Derivative Works thereof.
|
|
48
|
+
|
|
49
|
+
"Contribution" shall mean any work of authorship, including
|
|
50
|
+
the original version of the Work and any modifications or additions
|
|
51
|
+
to that Work or Derivative Works thereof, that is intentionally
|
|
52
|
+
submitted to Licensor for inclusion in the Work by the copyright owner
|
|
53
|
+
or by an individual or Legal Entity authorized to submit on behalf of
|
|
54
|
+
the copyright owner. For the purposes of this definition, "submitted"
|
|
55
|
+
means any form of electronic, verbal, or written communication sent
|
|
56
|
+
to the Licensor or its representatives, including but not limited to
|
|
57
|
+
communication on electronic mailing lists, source code control systems,
|
|
58
|
+
and issue tracking systems that are managed by, or on behalf of, the
|
|
59
|
+
Licensor for the purpose of discussing and improving the Work, but
|
|
60
|
+
excluding communication that is conspicuously marked or otherwise
|
|
61
|
+
designated in writing by the copyright owner as "Not a Contribution."
|
|
62
|
+
|
|
63
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
64
|
+
on behalf of whom a Contribution has been received by Licensor and
|
|
65
|
+
subsequently incorporated within the Work.
|
|
66
|
+
|
|
67
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
68
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
69
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
70
|
+
copyright license to reproduce, prepare Derivative Works of,
|
|
71
|
+
publicly display, publicly perform, sublicense, and distribute the
|
|
72
|
+
Work and such Derivative Works in Source or Object form.
|
|
73
|
+
|
|
74
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
|
75
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
76
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
77
|
+
(except as stated in this section) patent license to make, have made,
|
|
78
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
79
|
+
where such license applies only to those patent claims licensable
|
|
80
|
+
by such Contributor that are necessarily infringed by their
|
|
81
|
+
Contribution(s) alone or by combination of their Contribution(s)
|
|
82
|
+
with the Work to which such Contribution(s) was submitted. If You
|
|
83
|
+
institute patent litigation against any entity (including a
|
|
84
|
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
|
85
|
+
or a Contribution incorporated within the Work constitutes direct
|
|
86
|
+
or contributory patent infringement, then any patent licenses
|
|
87
|
+
granted to You under this License for that Work shall terminate
|
|
88
|
+
as of the date such litigation is filed.
|
|
89
|
+
|
|
90
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
|
91
|
+
Work or Derivative Works thereof in any medium, with or without
|
|
92
|
+
modifications, and in Source or Object form, provided that You
|
|
93
|
+
meet the following conditions:
|
|
94
|
+
|
|
95
|
+
(a) You must give any other recipients of the Work or
|
|
96
|
+
Derivative Works a copy of this License; and
|
|
97
|
+
|
|
98
|
+
(b) You must cause any modified files to carry prominent notices
|
|
99
|
+
stating that You changed the files; and
|
|
100
|
+
|
|
101
|
+
(c) You must retain, in the Source form of any Derivative Works
|
|
102
|
+
that You distribute, all copyright, patent, trademark, and
|
|
103
|
+
attribution notices from the Source form of the Work,
|
|
104
|
+
excluding those notices that do not pertain to any part of
|
|
105
|
+
the Derivative Works; and
|
|
106
|
+
|
|
107
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
|
108
|
+
distribution, then any Derivative Works that You distribute must
|
|
109
|
+
include a readable copy of the attribution notices contained
|
|
110
|
+
within such NOTICE file, excluding those notices that do not
|
|
111
|
+
pertain to any part of the Derivative Works, in at least one
|
|
112
|
+
of the following places: within a NOTICE text file distributed
|
|
113
|
+
as part of the Derivative Works; within the Source form or
|
|
114
|
+
documentation, if provided along with the Derivative Works; or,
|
|
115
|
+
within a display generated by the Derivative Works, if and
|
|
116
|
+
wherever such third-party notices normally appear. The contents
|
|
117
|
+
of the NOTICE file are for informational purposes only and
|
|
118
|
+
do not modify the License. You may add Your own attribution
|
|
119
|
+
notices within Derivative Works that You distribute, alongside
|
|
120
|
+
or as an addendum to the NOTICE text from the Work, provided
|
|
121
|
+
that such additional attribution notices cannot be construed
|
|
122
|
+
as modifying the License.
|
|
123
|
+
|
|
124
|
+
You may add Your own copyright statement to Your modifications and
|
|
125
|
+
may provide additional or different license terms and conditions
|
|
126
|
+
for use, reproduction, or distribution of Your modifications, or
|
|
127
|
+
for any such Derivative Works as a whole, provided Your use,
|
|
128
|
+
reproduction, and distribution of the Work otherwise complies with
|
|
129
|
+
the conditions stated in this License.
|
|
130
|
+
|
|
131
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
132
|
+
any Contribution intentionally submitted for inclusion in the Work
|
|
133
|
+
by You to the Licensor shall be under the terms and conditions of
|
|
134
|
+
this License, without any additional terms or conditions.
|
|
135
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
|
136
|
+
the terms of any separate license agreement you may have executed
|
|
137
|
+
with Licensor regarding such Contributions.
|
|
138
|
+
|
|
139
|
+
6. Trademarks. This License does not grant permission to use the trade
|
|
140
|
+
names, trademarks, service marks, or product names of the Licensor,
|
|
141
|
+
except as required for reasonable and customary use in describing the
|
|
142
|
+
origin of the Work and reproducing the content of the NOTICE file.
|
|
143
|
+
|
|
144
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
145
|
+
agreed to in writing, Licensor provides the Work (and each
|
|
146
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
147
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
148
|
+
implied, including, without limitation, any warranties or conditions
|
|
149
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
150
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
151
|
+
appropriateness of using or redistributing the Work and assume any
|
|
152
|
+
risks associated with Your exercise of permissions under this License.
|
|
153
|
+
|
|
154
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
|
155
|
+
whether in tort (including negligence), contract, or otherwise,
|
|
156
|
+
unless required by applicable law (such as deliberate and grossly
|
|
157
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
|
158
|
+
liable to You for damages, including any direct, indirect, special,
|
|
159
|
+
incidental, or consequential damages of any character arising as a
|
|
160
|
+
result of this License or out of the use or inability to use the
|
|
161
|
+
Work (including but not limited to damages for loss of goodwill,
|
|
162
|
+
work stoppage, computer failure or malfunction, or any and all
|
|
163
|
+
other commercial damages or losses), even if such Contributor
|
|
164
|
+
has been advised of the possibility of such damages.
|
|
165
|
+
|
|
166
|
+
9. Accepting Warranty or Additional Liability. While redistributing
|
|
167
|
+
the Work or Derivative Works thereof, You may choose to offer,
|
|
168
|
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
|
169
|
+
or other liability obligations and/or rights consistent with this
|
|
170
|
+
License. However, in accepting such obligations, You may act only
|
|
171
|
+
on Your own behalf and on Your sole responsibility, not on behalf
|
|
172
|
+
of any other Contributor, and only if You agree to indemnify,
|
|
173
|
+
defend, and hold each Contributor harmless for any liability
|
|
174
|
+
incurred by, or claims asserted against, such Contributor by reason
|
|
175
|
+
of your accepting any such warranty or additional liability.
|
|
176
|
+
|
|
177
|
+
END OF TERMS AND CONDITIONS
|
|
178
|
+
|
|
179
|
+
APPENDIX: How to apply the Apache License to your work.
|
|
180
|
+
|
|
181
|
+
To apply the Apache License to your work, attach the following
|
|
182
|
+
boilerplate notice, with the fields enclosed by brackets "[]"
|
|
183
|
+
replaced with your own identifying information. (Don't include
|
|
184
|
+
the brackets!) The text should be enclosed in the appropriate
|
|
185
|
+
comment syntax for the file format. We also recommend that a
|
|
186
|
+
file or class name and description of purpose be included on the
|
|
187
|
+
same "printed page" as the copyright notice for easier
|
|
188
|
+
identification within third-party archives.
|
|
189
|
+
|
|
190
|
+
Copyright [yyyy] [name of copyright owner]
|
|
191
|
+
|
|
192
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
193
|
+
you may not use this file except in compliance with the License.
|
|
194
|
+
You may obtain a copy of the License at
|
|
195
|
+
|
|
196
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
197
|
+
|
|
198
|
+
Unless required by applicable law or agreed to in writing, software
|
|
199
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
200
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
201
|
+
See the License for the specific language governing permissions and
|
|
202
|
+
limitations under the License.
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
@agenttwin/twin-fireworks
|
|
2
|
+
|
|
3
|
+
Contains @volter/twin-fireworks 0.1.37 by Volter (https://github.com/volter-ai),
|
|
4
|
+
licensed under the Apache License, Version 2.0 (see LICENSE).
|
|
5
|
+
|
|
6
|
+
Modified by AgentTwin: bundled and minified into one file; only code reachable from the pack's
|
|
7
|
+
fetch factory is included; shared modules are imported from the AgentTwin twin engine.
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import{createRequire as __atReq}from'node:module';const require=__atReq(import.meta.url);
|
|
2
|
+
import{applyTwinWrite as N,projectResources as Se}from"../../engine/v2/volter_world-core.mjs";var Ze=[{id:"kimi-latest",kind:"chat"},{id:"kimi-fast-latest",kind:"chat"},{id:"glm-latest",kind:"chat"},{id:"glm-fast-latest",kind:"chat"},{id:"glm-5p2",kind:"chat"},{id:"glm-5p3-flash",kind:"chat"},{id:"kimi-k2-instruct",kind:"chat"},{id:"accounts/fireworks/models/kimi-k2-instruct",kind:"chat"},{id:"accounts/fireworks/models/kimi-k2-instruct-0905",kind:"chat"},{id:"accounts/fireworks/models/llama-v3p1-8b-instruct",kind:"chat"},{id:"fireworks/qwen3-embedding-8b",kind:"embeddings"},{id:"accounts/fireworks/models/qwen3-embedding-8b",kind:"embeddings"},{id:"nomic-ai/nomic-embed-text-v1.5",kind:"embeddings"},{id:"fireworks/qwen3-reranker-8b",kind:"rerank"},{id:"accounts/fireworks/models/qwen3-reranker-8b",kind:"rerank"}],ae=new Set(Ze.map(e=>e.id));function j(e){let t=2166136261;for(let n=0;n<e.length;n++)t^=e.charCodeAt(n),t=Math.imul(t,16777619);return t>>>0}function P(e){return typeof e=="string"?e:Array.isArray(e)?e.map(t=>typeof t=="string"?t:typeof t?.text=="string"?t.text:"").join(" "):""}function S(e){return Math.max(1,Math.ceil(e.length/4))}function ue(e){return e.reduce((t,n)=>t+S(P(n.content)),0)}function te(e){for(let t=e.length-1;t>=0;t--)if(e[t].role==="user")return P(e[t].content);return""}function B(e,t){let n=j(`${e}\0${t}`);return`[twin-stub:${e}] Deterministic response to: ${t.slice(0,120)||"(empty prompt)"} (hash ${n.toString(16)})`}function de(e,t){let n=j(`reasoning\0${e}\0${t}`);return`[twin-stub:${e}] reasoning trace (hash ${n.toString(16)})`}function ce(e,t){if(!Number.isInteger(t)||t<1||t>4096)throw new RangeError(`pseudoEmbedding: dimensions must be an integer in [1, 4096], got ${t}`);let n=new Array(t),o=j(e);for(let s=0;s<t;s++)o=Math.imul(o^s+1,16777619)>>>0,n[s]=o/4294967295*2-1;let r=Math.hypot(...n)||1;return n.map(s=>s/r)}function le(e,t){let n=new Set(e.toLowerCase().split(/\W+/).filter(Boolean)),o=new Set(t.toLowerCase().split(/\W+/).filter(Boolean)),r=0;for(let u of n)o.has(u)&&r++;let s=j(`${e}\0${t}`)%1e3/1e4;return Math.min(1,r/Math.max(1,n.size)+s)}import{getActiveWorldStore as Qe,parseScenarioDocument as qe,ScenarioError as et,ScenarioEngine as tt}from"../../engine/v2/volter_world-core.mjs";var fe=new Set(["text","reasoning","toolCalls","finishReason"]),pe=new Set(["stop","length","tool_calls"]),me=new Set(["auto","default","flex","priority"]),G=e=>typeof e=="string"&&e.length>0;function ye(e){let t=new Set,n=e[e.length-1];if(!n||n.role!=="tool"||typeof n.tool_call_id!="string")return t;for(let o of e){let r=o;if(!(r.role!=="assistant"||!Array.isArray(r.tool_calls)))for(let s of r.tool_calls)s?.id===n.tool_call_id&&typeof s?.function?.name=="string"&&t.add(s.function.name)}return t}function he(e){return Array.isArray(e)?e.map(t=>typeof t?.function?.name=="string"?t.function.name:typeof t?.name=="string"?t.name:null).filter(t=>t!==null):[]}var ge={vendor:"fireworks",renderFault:e=>({body:{error:{message:e.message??(e.status===429?"Rate limit exceeded. Please retry your request.":e.status>=500?"Internal Server Error":"The request was refused by a scripted fault."),code:e.status,type:e.status===429?"rate_limit_exceeded":e.status>=500?"internal_server_error":"invalid_request_error"}}}),features:e=>({model:e.model,lastUserText:te(e.messages).slice(0,300),tools:he(e.tools),lastMessageIsToolResult:e.messages[e.messages.length-1]?.role==="tool",toolResultFor:[...ye(e.messages)],serviceTier:e.serviceTier??"default"}),matchers:{modelEquals:(e,t)=>G(t)&&e.model===t,userTextIncludes:(e,t)=>G(t)&&te(e.messages).toLowerCase().includes(t.toLowerCase()),anyTextIncludes:(e,t)=>G(t)&&e.messages.map(n=>P(n.content)).join(`
|
|
3
|
+
`).toLowerCase().includes(t.toLowerCase()),lastMessageIsToolResult:(e,t)=>typeof t=="boolean"&&e.messages[e.messages.length-1]?.role==="tool"===t,toolResultFor:(e,t)=>G(t)&&ye(e.messages).has(t),hasTool:(e,t)=>G(t)&&he(e.tools).includes(t),serviceTierEquals:(e,t)=>G(t)&&(e.serviceTier??"default")===t},text:e=>e.messages.map(t=>P(t.content)).join(`
|
|
4
|
+
`),validateOn:e=>{for(let t of["modelEquals","userTextIncludes","anyTextIncludes","toolResultFor","hasTool"])if(e[t]!==void 0&&(typeof e[t]!="string"||!e[t]))return`on.${t} is a non-empty string`;return e.lastMessageIsToolResult!==void 0&&typeof e.lastMessageIsToolResult!="boolean"?"on.lastMessageIsToolResult is a boolean":e.serviceTierEquals!==void 0&&(typeof e.serviceTierEquals!="string"||!me.has(e.serviceTierEquals))?`on.serviceTierEquals is one of ${[...me].join(", ")}`:null},validateRespond:e=>{if(typeof e!="object"||e===null||Array.isArray(e))return"respond is an object { text?, reasoning?, toolCalls?, finishReason? }";let t=e;for(let n of Object.keys(t))if(!fe.has(n))return`respond: unknown key "${n}" (valid: ${[...fe].join(", ")})`;if(t.text!==void 0&&typeof t.text!="string")return"respond.text is a string";if(t.reasoning!==void 0&&typeof t.reasoning!="string")return"respond.reasoning is a string";if(t.finishReason!==void 0&&(typeof t.finishReason!="string"||!pe.has(t.finishReason)))return`respond.finishReason is one of ${[...pe].join(", ")}`;if(t.toolCalls!==void 0)for(let n of Array.isArray(t.toolCalls)?t.toolCalls:[t.toolCalls]){let o=n;if(!o||typeof o!="object"||Array.isArray(o))return"respond.toolCalls entries are objects";if(typeof o.name!="string"||!o.name)return"respond.toolCalls[].name is a non-empty string";if(!o.arguments||typeof o.arguments!="object"||Array.isArray(o.arguments))return"respond.toolCalls[].arguments is an object";if(o.id!==void 0&&typeof o.id!="string")return"respond.toolCalls[].id is a string"}return t.text===void 0&&t.toolCalls===void 0?"respond needs text or toolCalls":null}};function be(e){let t;try{let n=Qe().read(e);if(n===null)throw new Error(`ENOENT: no such file or directory, open '${e}'`);t=JSON.parse(n)}catch(n){throw new et(`fireworks scenario: cannot read/parse ${e}: ${n instanceof Error?n.message:String(n)}`)}return qe(t,ge)}function _e(e){return new tt(ge,e)}function Te(e){let t=[];return(e.toolCalls?Array.isArray(e.toolCalls)?e.toolCalls:[e.toolCalls]:[]).forEach((o,r)=>{let s=`${r}:${o.name}:${JSON.stringify(o.arguments)}`,u=2166136261;for(let a=0;a<s.length;a++)u^=s.charCodeAt(a),u=Math.imul(u,16777619);t.push({id:o.id??`call_scripted_${(u>>>0).toString(36)}`,type:"function",function:{name:o.name,arguments:JSON.stringify(o.arguments)}})}),{text:e.text??(t.length?null:""),reasoning:e.reasoning??null,toolCalls:t,finishReason:e.finishReason??(t.length?"tool_calls":"stop")}}var R="fireworks",C="/inference/v1",W="/v1/accounts";function Y(e,t={}){return{error:{message:e,...t}}}function L(e,t={}){return{status:400,body:Y(e,{code:400,...t})}}function z(e){return{status:404,body:Y(e,{code:404})}}function nt(e){return{status:401,body:Y(e,{code:401})}}function w(e,t,n){return{status:422,body:{detail:[{loc:e,msg:t,type:n}]}}}function T(e,t){return{status:e,body:{code:e===400?"INVALID_ARGUMENT":e===401?"UNAUTHENTICATED":e===403?"PERMISSION_DENIED":e===404?"NOT_FOUND":e===409?"ALREADY_EXISTS":"UNKNOWN",message:t}}}function ot(e){let t=e.headers?.authorization,n=typeof t=="string"&&t.toLowerCase().startsWith("bearer ")?t.slice(7).trim():"",o=(e.apiKey??"").trim()||n;return!o||o==="fw_invalid"||o==="invalid"?e.path.startsWith(`${C}/messages`)?H(401,"authentication_error","Unauthorized: missing or invalid API key"):e.path.startsWith(`${W}/`)?T(401,"Unauthorized: missing or invalid API key"):nt("Unauthorized: missing or invalid API key"):null}function X(e){return Math.floor((e?Date.parse(e):0)/1e3)}function v(e){return e._deleted===!0||e.deleted===!0}function V(e,t,n){return Se(R,n).filter(o=>o.type===e&&(t===void 0||o._account===t))}function Ae(e,t,n,o){let r=0;for(let s of V(e,n,o)){let u=n!==void 0&&typeof s.id=="string"&&s.id.startsWith(`${n}/`)?s.id.slice(n.length+1):String(s.id),a=new RegExp(`^${t}_twin_(\\d+)$`).exec(u);a&&(r=Math.max(r,Number(a[1])))}return`${t}_twin_${r+1}`}function x(e,t,n,o){let r=n===void 0?t:`${n}/${t}`;return V(e,n,o).find(s=>s.id===r)}function Re(e){let t={};for(let[n,o]of Object.entries(e))n==="type"||n==="updatedAt"||n==="deleted"||n.startsWith("_")||(t[n]=o);return t}function rt(e){if(!e||!e.trim())return{};try{let t=JSON.parse(e);return t&&typeof t=="object"?t:{}}catch{return{}}}function U(e){return j(e).toString(36)}function Z(e){let t=new Set(ae);for(let n of Se(R,e))n.type!=="model"||v(n)||typeof n.name=="string"&&t.add(n.name);return t}function Q(e){return z(`Model id not found: ${e}`)}var ke=["auto","default","flex","priority"],st=["error","truncate"],it=[{field:"temperature",kind:"number",min:0,max:2},{field:"top_p",kind:"number",min:0,max:1},{field:"n",kind:"number",min:1,max:128,integer:!0},{field:"top_k",kind:"number",min:0,max:100,integer:!0},{field:"frequency_penalty",kind:"number",min:-2,max:2},{field:"presence_penalty",kind:"number",min:-2,max:2}];function Ne(e){for(let t of it){let n=e[t.field];if(n!=null&&t.kind==="number"){if(typeof n!="number"||Number.isNaN(n))return w(["body",t.field],`Input should be a valid ${t.integer?"integer":"number"}`,t.integer?"int_parsing":"float_parsing");if(t.integer&&!Number.isInteger(n))return w(["body",t.field],"Input should be a valid integer","int_from_float");if(t.min!==void 0&&n<t.min)return w(["body",t.field],`Input should be greater than or equal to ${t.min}`,"greater_than_equal");if(t.max!==void 0&&n>t.max)return w(["body",t.field],`Input should be less than or equal to ${t.max}`,"less_than_equal")}}return e.stream!==void 0&&e.stream!==null&&typeof e.stream!="boolean"?w(["body","stream"],"Input should be a valid boolean","bool_type"):null}var Ee=["system","user","assistant","tool","function","developer"];function at(e){if(e.model===void 0)return{error:w(["body","model"],"Field required","missing")};if(typeof e.model!="string"||!e.model)return{error:w(["body","model"],"Input should be a valid string","string_type")};if(!Array.isArray(e.messages))return{error:w(["body","messages"],"Field required","missing")};if(e.messages.length===0)return{error:L("'messages' must not be empty")};let t=e.messages;for(let[l,b]of t.entries()){if(!b||typeof b!="object"||typeof b.role!="string")return{error:w(["body","messages"],"Input should be a valid dictionary","model_attributes_type")};if(!Ee.includes(b.role))return{error:w(["body","messages",l,"role"],`Input should be one of ${Ee.map(E=>`'${E}'`).join(", ")}`,"enum")}}let n=Ne(e);if(n)return{error:n};if(e.max_tokens!==void 0&&e.max_tokens!==null&&e.max_completion_tokens!==void 0&&e.max_completion_tokens!==null)return{error:L("'max_tokens' and 'max_completion_tokens' cannot both be specified \u2014 'max_completion_tokens' is an alias for 'max_tokens'")};let o=e.max_completion_tokens??e.max_tokens,r;if(o!=null){if(r=Number(o),typeof o!="number"||Number.isNaN(o))return{error:w(["body","max_tokens"],"Input should be a valid integer","int_parsing")};if(!Number.isInteger(r))return{error:w(["body","max_tokens"],"Input should be a valid integer","int_from_float")};if(r<1)return{error:w(["body","max_tokens"],"Input should be a valid integer greater than or equal to 1","greater_than_equal")}}let s;if(e.stop!==void 0&&e.stop!==null)if(typeof e.stop=="string")s=[e.stop];else if(Array.isArray(e.stop))s=e.stop;else return{error:w(["body","stop"],"Input should be a valid string or array of strings","string_type")};let u="default";if(e.service_tier!==void 0&&e.service_tier!==null){if(typeof e.service_tier!="string"||!ke.includes(e.service_tier))return{error:w(["body","service_tier"],`Input should be one of ${ke.map(l=>`'${l}'`).join(", ")}`,"enum")};u=e.service_tier==="priority"?"priority":"default"}let a="truncate";if(e.context_length_exceeded_behavior!==void 0&&e.context_length_exceeded_behavior!==null){if(typeof e.context_length_exceeded_behavior!="string"||!st.includes(e.context_length_exceeded_behavior))return{error:w(["body","context_length_exceeded_behavior"],"Input should be one of 'error', 'truncate'","enum")};a=e.context_length_exceeded_behavior}let i,d=e.response_format;if(d&&typeof d=="object"){if(d.type==="json_object")i={type:"json_object"};else if(d.type==="json_schema")i={type:"json_schema",schema:d.json_schema};else if(d.type!==void 0&&d.type!=="text")return{error:L("'response_format.type' must be one of 'text', 'json_object', 'json_schema'")}}let f=e.stream===!0,p=e.stream_options?.include_usage!==!1;return{args:{model:e.model,messages:t,promptText:t.map(l=>P(l.content)).join(`
|
|
5
|
+
`),...e.tools!==void 0?{tools:e.tools}:{},...r!==void 0?{maxTokens:r}:{},...s!==void 0?{stop:s}:{},stream:f,includeUsage:p,serviceTier:u,contextBehavior:a,...i!==void 0?{responseFormat:i}:{},...e.reasoning_effort!==void 0&&e.reasoning_effort!==null?{reasoningEffort:e.reasoning_effort}:{}}}}function $e(e,t,n){let o=ue(e.messages),r=null,s="";if(n&&(n.kind==="handler"?r=Te(n.respond):s=`
|
|
6
|
+
[twin-scenario miss \u2014 no handler matched. Author one in the world dir's handlers/fireworks.json (GET /twin explains; GET /twin/scenario lists handlers + misses). Features seen: ${JSON.stringify(n.miss.features)}]`),r){let E={role:"assistant",content:r.text??"",...r.toolCalls.length?{tool_calls:r.toolCalls}:{}};r.reasoning!==null&&(E.reasoning_content=r.reasoning);let A=S(JSON.stringify(r.toolCalls.length?r.toolCalls:r.text??""));return{id:`chatcmpl-twin-${U(JSON.stringify(e.messages)+e.model)}`,object:"chat.completion",created:X(t),model:e.model,choices:[{index:0,message:E,finish_reason:r.finishReason,logprobs:null}],usage:{prompt_tokens:o,total_tokens:o+A,completion_tokens:A}}}let u=e.responseFormat?.type==="json_object"||e.responseFormat?.type==="json_schema"?`${B(e.model,e.promptText)}
|
|
7
|
+
{"twin_stub":true}`:B(e.model,e.promptText);s&&(u+=s);let a="stop",i=-1;for(let E of e.stop??[]){if(!E)continue;let A=u.indexOf(E);A>=0&&(i<0||A<i)&&(i=A)}i>=0&&(u=u.slice(0,i),a="stop");let d=8192;if(o+(e.maxTokens??0)>d){if(e.contextBehavior==="error")return L(`This model's maximum context length is ${d} tokens. However, you requested ${(e.maxTokens??0)+o} tokens in the messages, which exceeds the model's context limit.`);e.maxTokens!==void 0&&(e.maxTokens=Math.max(1,d-o))}e.maxTokens!==void 0&&S(u)>e.maxTokens&&(u=u.slice(0,e.maxTokens*4),a="length");let f={role:"assistant",content:u};e.reasoningEffort!==void 0&&e.reasoningEffort!=="none"&&e.reasoningEffort!==!1&&(f.reasoning_content=de(e.model,e.promptText));let p=S(u)+S(f.reasoning_content??""),l={prompt_tokens:o,total_tokens:o+p,completion_tokens:p};return{id:`chatcmpl-twin-${U(JSON.stringify(e.messages)+e.model)}`,object:"chat.completion",created:X(t),model:e.model,choices:[{index:0,message:f,finish_reason:a,logprobs:null}],usage:l}}function ve(e){if(!e)return[];let t=[];for(let n=0;n<e.length;n+=20)t.push(e.slice(n,n+20));return t}function ut(e,t,n,o){let r=$e(e,n,o);if("status"in r)return r;let s=r,u={id:s.id,object:"chat.completion.chunk",created:s.created,model:s.model};t({data:{...u,choices:[{index:0,delta:{role:"assistant",content:""},finish_reason:null}],usage:null}}),s.choices[0].message.reasoning_content&&t({data:{...u,choices:[{index:0,delta:{reasoning_content:s.choices[0].message.reasoning_content},finish_reason:null}],usage:null}});for(let a of ve(s.choices[0].message.content??""))t({data:{...u,choices:[{index:0,delta:{content:a},finish_reason:null}],usage:null}});return t({data:{...u,choices:[{index:0,delta:{},finish_reason:s.choices[0].finish_reason}],...e.includeUsage?{usage:s.usage}:{usage:null}}}),t({done:!0}),s}function dt(e,t,n){let o={id:e.id,object:"text_completion",created:e.created,model:e.model};for(let r of e.choices)t({data:{...o,choices:[{index:r.index,text:r.text,finish_reason:null,logprobs:r.logprobs}],usage:null}});return t({data:{...o,choices:e.choices.map(r=>({index:r.index,text:"",finish_reason:r.finish_reason,logprobs:r.logprobs})),...n?{usage:e.usage}:{usage:null}}}),t({done:!0}),e}function ct(e,t,n,o){if(e.model===void 0)return{status:422,body:{detail:[{loc:["body","model"],msg:"Field required",type:"missing"}]}};if(e.prompt===void 0)return{status:422,body:{detail:[{loc:["body","prompt"],msg:"Field required",type:"missing"}]}};if(typeof e.model!="string"||!e.model)return{status:422,body:{detail:[{loc:["body","model"],msg:"Input should be a valid string",type:"string_type"}]}};if(!Z(o).has(e.model))return Q(e.model);let r=Ne(e);if(r)return r;let s=Array.isArray(e.prompt)?e.prompt.map(String):[String(e.prompt)],u=e.max_completion_tokens??e.max_tokens;if(e.max_tokens!==void 0&&e.max_tokens!==null&&e.max_completion_tokens!==void 0&&e.max_completion_tokens!==null)return L("'max_tokens' and 'max_completion_tokens' cannot both be specified \u2014 'max_completion_tokens' is an alias for 'max_tokens'");let a;if(u!=null){if(a=Number(u),typeof u!="number"||Number.isNaN(u))return{status:422,body:{detail:[{loc:["body","max_tokens"],msg:"Input should be a valid integer",type:"int_parsing"}]}};if(!Number.isInteger(a))return{status:422,body:{detail:[{loc:["body","max_tokens"],msg:"Input should be a valid integer",type:"int_from_float"}]}};if(a<1)return{status:422,body:{detail:[{loc:["body","max_tokens"],msg:"Input should be a valid integer greater than or equal to 1",type:"greater_than_equal"}]}}}let i=String(e.model),d=s.reduce((b,E)=>b+S(E),0),f=s.map((b,E)=>{let A=B(i,b),D="stop";return a!==void 0&&S(A)>a&&(A=A.slice(0,a*4),D="length"),{index:E,text:A,finish_reason:D,logprobs:null}}),g=f.reduce((b,E)=>b+S(E.text),0),p={id:`cmpl-twin-${U(JSON.stringify(s)+i)}`,object:"text_completion",created:X(t),model:i,choices:f,usage:{prompt_tokens:d,total_tokens:d+g,completion_tokens:g}},l=e.stream_options;return n?{status:200,body:dt(p,n,l?.include_usage!==!1)}:{status:200,body:p}}function oe(e){return{id:e.id,...Re(e)}}async function lt(e,t){if(e.model===void 0)return{status:422,body:{detail:[{loc:["body","model"],msg:"Field required",type:"missing"}]}};if(e.input===void 0)return{status:422,body:{detail:[{loc:["body","input"],msg:"Field required",type:"missing"}]}};if(typeof e.model!="string"||!e.model)return{status:422,body:{detail:[{loc:["body","model"],msg:"Input should be a valid string",type:"string_type"}]}};let n=e.store!==!1,o=typeof e.input=="string"?e.input:JSON.stringify(e.input),r=S(o),s=B(String(e.model),o),u=S(s),a={type:"message",id:`msg_twin_${U(s)}`,role:"assistant",status:"completed",content:[{type:"output_text",text:s}]},i={object:"response",created_at:X(t.occurredAt),status:"completed",model:e.model,output:[a],usage:{prompt_tokens:r,total_tokens:r+u,completion_tokens:u},...e.instructions!==void 0?{instructions:e.instructions}:{},...e.metadata!==void 0?{metadata:e.metadata}:{},...e.previous_response_id!==void 0?{previous_response_id:e.previous_response_id}:{},...e.temperature!==void 0?{temperature:e.temperature}:{},...e.max_output_tokens!==void 0?{max_output_tokens:e.max_output_tokens}:{},store:n};if(!n)return{status:200,body:{...i,id:null}};let d=`resp_twin_${U(o+String(e.model))}`;return await N(R,{operation:"response.create",subjectType:"response",subjectId:d,fields:i,...t.occurredAt?{occurredAt:t.occurredAt}:{},actor:{kind:"agent"}},t.root),{status:200,body:oe(x("response",d,void 0,t.root)??{...i,id:d})}}function ft(e){let t=new URL(e.path,"http://twin"),n=Number(t.searchParams.get("limit")??20),o=V("response",void 0,e.root).filter(s=>!v(s)).map(oe),r=o.slice(0,Number.isFinite(n)&&n>0?n:20);return{status:200,body:{object:"list",data:r,has_more:o.length>r.length,first_id:r[0]?.id??null,last_id:r[r.length-1]?.id??null}}}function pt(e,t){let n=x("response",e,void 0,t.root);return!n||v(n)?z(`No response found with id '${e}'.`):{status:200,body:oe(n)}}async function mt(e,t){let n=x("response",e,void 0,t.root);return!n||v(n)?z(`No response found with id '${e}'.`):(await N(R,{operation:"response.delete",subjectType:"response",subjectId:e,fields:{_deleted:!0},...t.occurredAt?{occurredAt:t.occurredAt}:{},actor:{kind:"agent"}},t.root),{status:200,body:{id:e,object:"response",deleted:!0}})}function H(e,t,n){return{status:e,body:{type:"error",error:{type:t,message:n},request_id:null}}}function yt(e){if(e.model===void 0)return{error:H(400,"invalid_request_error","model: Field required")};if(!Array.isArray(e.messages)||e.messages.length===0)return{error:H(400,"invalid_request_error","messages: Field required")};for(let t of e.messages)if(!t||typeof t!="object"||t.role!=="user"&&t.role!=="assistant")return{error:H(400,"invalid_request_error","messages: each message must have role 'user' or 'assistant'")};return{ok:!0}}function Oe(e,t){let n=yt(e);if("error"in n)return n.error;let r=e.messages.map(l=>P(l.content)).join(`
|
|
8
|
+
`),s=typeof e.system=="string"?e.system:Array.isArray(e.system)?e.system.map(l=>P(l.text)).join(`
|
|
9
|
+
`):"",u=S(r+s),a=typeof e.max_tokens=="number"?e.max_tokens:void 0,i=B(String(e.model),r.trim()||s),d="end_turn";a!==void 0&&S(i)>a&&(i=i.slice(0,a*4),d="max_tokens");let f=[{type:"text",text:i,citations:null}],g=S(i);return{status:200,body:{id:`msg_twin_${U(r+String(e.model))}`,type:"message",role:"assistant",content:f,model:String(e.model),stop_reason:d,stop_sequence:null,usage:{input_tokens:u,output_tokens:g}}}}function ht(e,t,n){let o=Oe(e,n);if(o.status!==200)return o;let r=o.body,s=r.content,u=r.usage??{input_tokens:0,output_tokens:0};t({data:{type:"message_start",message:{...r,content:[],stop_reason:null,usage:{input_tokens:u.input_tokens,output_tokens:0}}}}),t({data:{type:"content_block_start",index:0,content_block:{type:"text",text:""}}});for(let a of ve(s[0].type==="text"?s[0].text:""))t({data:{type:"content_block_delta",index:0,delta:{type:"text_delta",text:a}}});return t({data:{type:"content_block_stop",index:0}}),t({data:{type:"message_delta",delta:{stop_reason:r.stop_reason,stop_sequence:null},usage:{input_tokens:u.input_tokens,output_tokens:u.output_tokens}}}),t({data:{type:"message_stop"}}),t({done:!0}),o}var we=4096;function gt(e,t){if(e.model===void 0)return{status:422,body:{detail:[{loc:["body","model"],msg:"Field required",type:"missing"}]}};if(e.input===void 0)return{status:422,body:{detail:[{loc:["body","input"],msg:"Field required",type:"missing"}]}};if(typeof e.model!="string"||!Z(t).has(e.model))return Q(String(e.model));let n=Array.isArray(e.input)?e.input.map(i=>typeof i=="string"?i:JSON.stringify(i)):[String(e.input)];if(n.some(i=>i.length===0))return L("'input' must not be an empty string");let o=e.dimensions;if(o!=null){if(typeof o!="number"||Number.isNaN(o))return w(["body","dimensions"],"Input should be a valid integer","int_parsing");if(!Number.isInteger(o))return w(["body","dimensions"],"Input should be a valid integer","int_from_float");if(o<1)return w(["body","dimensions"],"Input should be greater than or equal to 1","greater_than_equal");if(o>we)return w(["body","dimensions"],`Input should be less than or equal to ${we}`,"less_than_equal")}let r=typeof o=="number"?o:768,s=e.encoding_format===void 0?"float":e.encoding_format;if(s!=="float"&&s!=="base64")return L("'encoding_format' must be one of 'float', 'base64'");let u=0;return{status:200,body:{object:"list",data:n.map((i,d)=>{u+=S(i);let f=ce(i,r);return{object:"embedding",index:d,embedding:s==="base64"?Buffer.from(new Float32Array(f).buffer).toString("base64"):f}}),model:e.model,usage:{prompt_tokens:u,total_tokens:u}}}}function bt(e,t){if(e.query===void 0)return{status:422,body:{detail:[{loc:["body","query"],msg:"Field required",type:"missing"}]}};if(!Array.isArray(e.documents)||e.documents.length===0)return{status:422,body:{detail:[{loc:["body","documents"],msg:"Field required",type:"missing"}]}};if(e.model!==void 0&&(typeof e.model!="string"||!Z(t).has(e.model)))return Q(String(e.model));let n=String(e.query),o=e.documents.map(String),r=e.return_documents!==!1,s=o.map((f,g)=>({index:g,score:le(n,f),doc:f}));s.sort((f,g)=>g.score-f.score);let u=e.top_n;if(u!=null){if(typeof u!="number"||Number.isNaN(u))return w(["body","top_n"],"Input should be a valid integer","int_parsing");if(!Number.isInteger(u))return w(["body","top_n"],"Input should be a valid integer","int_from_float");if(u<1)return w(["body","top_n"],"Input should be greater than or equal to 1","greater_than_equal")}let a=typeof u=="number"?u:o.length,i=s.slice(0,Math.max(0,a)).map(f=>({index:f.index,relevance_score:f.score,...r?{document:f.doc}:{}})),d=S(n)+o.reduce((f,g)=>f+S(g),0);return{status:200,body:{object:"list",model:e.model??null,data:i,usage:{prompt_tokens:d,total_tokens:d}}}}function O(e){let{id:t,...n}=e;return Re(n)}function _t(e,t){let n=Number(t.searchParams.get("pageSize")??0),o=t.searchParams.get("pageToken"),r=0;if(o){let i=Number(o);r=Number.isFinite(i)&&i>0?i:0}let s=Number.isFinite(n)&&n>0?n:e.length,u=e.slice(r,r+s),a=r+s<e.length?String(r+s):null;return{items:u,nextPageToken:a}}function M(){return{code:"OK",message:""}}async function Tt(e,t,n,o,r,s,u){let a=s.searchParams.get(`${e}Id`)??s.searchParams.get(`${e}_id`),i=o[e]&&typeof o[e]=="object"?o[e]:o,d=typeof i[`${e}Id`]=="string"?i[`${e}Id`]:typeof o[`${e}Id`]=="string"?o[`${e}Id`]:e==="secret"&&typeof o.name=="string"?o.name.split("/").pop():void 0,f=a||d||Ae(e,t,n,r.root);if(e==="dataset"||e==="model"){if(!a&&!d)return T(400,`${e}Id is required`);if(e==="dataset"&&!(o.dataset&&typeof o.dataset=="object"))return T(400,"dataset is required")}let g=`${n}/${f}`;if(x(e,f,n,r.root)&&!v(x(e,f,n,r.root)))return T(409,`Resource already exists: ${f}`);let p=u(o);return p._account=n,typeof p.name=="string"&&(p.name=p.name.replace("PLACEHOLDER",f)),await N(R,{operation:`${e}.create`,subjectType:e,subjectId:g,fields:p,...r.occurredAt?{occurredAt:r.occurredAt}:{},actor:{kind:"agent"}},r.root),{status:200,body:O(x(e,f,n,r.root)??{id:g,...p})}}async function kt(e,t,n,o){let r=x(e,t,n,o.root);return!r||v(r)?T(404,`Not found: ${e}/${t}`):(await N(R,{operation:`${e}.delete`,subjectType:e,subjectId:`${n}/${t}`,fields:{_deleted:!0},...o.occurredAt?{occurredAt:o.occurredAt}:{},actor:{kind:"agent"}},o.root),{status:200,body:{}})}var ne=["STATE_UNSPECIFIED","CREATING","READY","DELETING","FAILED","UPDATING","DELETED"],xe=["JOB_STATE_UNSPECIFIED","JOB_STATE_CREATING","JOB_STATE_RUNNING","JOB_STATE_COMPLETED","JOB_STATE_FAILED","JOB_STATE_CANCELLED","JOB_STATE_DELETING","JOB_STATE_WRITING_RESULTS","JOB_STATE_VALIDATING","JOB_STATE_DELETING_CLEANING_UP","JOB_STATE_PENDING","JOB_STATE_EXPIRED","JOB_STATE_RE_QUEUEING","JOB_STATE_CREATING_INPUT_DATASET","JOB_STATE_IDLE","JOB_STATE_CANCELLING","JOB_STATE_EARLY_STOPPED","JOB_STATE_PAUSED","JOB_STATE_DELETED","JOB_STATE_ARCHIVED"],Et=["STATE_UNSPECIFIED","CREATING","READY","UPDATING","DELETING"],Ie=["admin","user","contributor","inference-user","custom"];async function q(e){let t=e.method.toUpperCase();if(e.headers!==void 0||e.apiKey!==void 0){let n=ot(e);if(n)return n}return wt(e,t)}async function wt(e,t){let n=(e.path.split("?")[0]??"/").replace(/\/+$/,"")||"/",o=e.path.includes("?")?e.path.slice(e.path.indexOf("?")):"",r=rt(e.body),s=a=>decodeURIComponent(a);if(e.readOnly&&t!=="GET"){let a="twin is read-only; omit readOnly to accept writes";return n.startsWith(`${W}/`)?T(405,a):{status:405,body:Y(a,{code:405})}}let u=new URL(e.path,"http://twin");if(n===C||n.startsWith(`${C}/`)){let a=n.slice(C.length).replace(/^\/+/,"").split("/").filter(Boolean);if(a[0]==="messages"&&a.length===1&&t==="POST")return r.stream===!0?e.sseSink?ht(r,e.sseSink,e.occurredAt):H(400,"invalid_request_error","streaming requires an SSE-capable connection"):Oe(r,e.occurredAt);if(a[0]==="chat"&&a[1]==="completions"&&a.length===2&&t==="POST"){let i=at(r);if("error"in i)return i.error;let d=i.args;if(!Z(e.root).has(d.model))return Q(d.model);let f;if(e.scenarioEngine){let p=await e.scenarioEngine.serve({model:d.model,messages:d.messages,tools:d.tools,serviceTier:d.serviceTier});if(p.kind==="fault")return{status:p.result.status,body:p.result.body,headers:p.result.headers};f=p}let g=d.stream&&e.sseSink?ut(d,e.sseSink,e.occurredAt,f):$e(d,e.occurredAt,f);return"status"in g?g:{status:200,body:g}}return a[0]==="completions"&&a.length===1&&t==="POST"?ct(r,e.occurredAt,e.sseSink,e.root):a[0]==="responses"&&a.length===1&&t==="POST"?lt(r,e):a[0]==="responses"&&a.length===1&&t==="GET"?ft(e):a[0]==="responses"&&a.length===2&&t==="GET"?pt(s(a[1]),e):a[0]==="responses"&&a.length===2&&t==="DELETE"?mt(s(a[1]),e):a[0]==="embeddings"&&a.length===1&&t==="POST"?gt(r,e.root):a[0]==="rerank"&&a.length===1&&t==="POST"?bt(r,e.root):z(`Unknown request URL: ${t} ${n}.`)}if(n.startsWith(`${W}/`)){let a=n.slice(W.length).split("/").filter(Boolean).map(s),i=a[0];if(!i)return T(404,`Unknown request URL: ${t} ${n}.`);let d=a.slice(1);if(d.length===0&&t==="GET")return T(404,`Not found: accounts/${i}`);let f=d[0],g=f?.indexOf(":")??-1,p=g>=0?f.slice(g+1):void 0,l=g>=0?f.slice(0,g):f,b=d[1];if(p===void 0&&d.length>=2&&d[1].includes(":")){let m=d[1].indexOf(":");p=d[1].slice(m+1),b=d[1].slice(0,m)}let A=l?{deployments:{plural:"deployments",states:ne,stateKey:"state"},datasets:{plural:"datasets",states:["STATE_UNSPECIFIED","UPLOADING","READY"],stateKey:"state"},batchInferenceJobs:{plural:"batchInferenceJobs",states:xe,stateKey:"state"},supervisedFineTuningJobs:{plural:"supervisedFineTuningJobs",states:xe,stateKey:"state"},users:{plural:"users",states:Et,stateKey:"state"},models:{plural:"models",states:ne,stateKey:"state"},secrets:{plural:"secrets",states:ne,stateKey:"state"}}[l]:void 0;if(!A)return T(404,`Unknown request URL: ${t} ${n}.`);let D={deployments:["displayName","region","replicaCount","minReplicaCount","maxReplicaCount","precision"],users:["displayName","email","role","permissionPreset"],models:["displayName","contextLength","description"],secrets:["keyName"],datasets:["displayName","exampleCount","userUploaded","evaluationResult","transformed","splitted","evalProtocol","externalUrl","format","sourceJobName"]},$=l==="deployments"?"deployment":l==="datasets"?"dataset":l==="batchInferenceJobs"?"batchInferenceJob":l==="supervisedFineTuningJobs"?"supervisedFineTuningJob":l==="users"?"user":l==="models"?"model":"secret";if(d.length===1&&t==="GET"){let m=V($,i,e.root).filter(h=>!v(h)).map(O),{items:k,nextPageToken:_}=_t(m,u);return{status:200,body:{[A.plural]:k,nextPageToken:_,totalSize:m.length}}}if(d.length===1&&t==="POST"&&!p){let m=y=>{let c=l==="datasets"&&y.dataset&&typeof y.dataset=="object"?y.dataset:l==="models"&&y.model&&typeof y.model=="object"?y.model:y,I=new Date(e.occurredAt??"1970-01-01T00:00:00Z").toISOString().replace(/\.\d{3}Z$/,"Z");if(l==="deployments")return c.baseModel===void 0?{__error:"baseModel is required"}:{name:`accounts/${i}/deployments/PLACEHOLDER`,displayName:c.displayName??"",baseModel:c.baseModel,state:"CREATING",status:M(),createTime:I,updateTime:I,...c.region!==void 0?{region:c.region}:{},...c.replicaCount!==void 0?{replicaCount:c.replicaCount}:{},...c.minReplicaCount!==void 0?{minReplicaCount:c.minReplicaCount}:{},...c.maxReplicaCount!==void 0?{maxReplicaCount:c.maxReplicaCount}:{},...c.precision!==void 0?{precision:c.precision}:{}};if(l==="datasets")return{name:`accounts/${i}/datasets/PLACEHOLDER`,displayName:c.displayName??"",state:"UPLOADING",status:M(),createTime:I,updateTime:I,exampleCount:0,userUploaded:!0,...c.format!==void 0?{format:c.format}:{}};if(l==="batchInferenceJobs"){if(c.inputDatasetId!==void 0){let F=String(c.inputDatasetId).split("/").pop()??"",K=x("dataset",F,i,e.root);if(!K||v(K))return{__error:`inputDatasetId not found: ${String(c.inputDatasetId)}`}}return{name:`accounts/${i}/batchInferenceJobs/PLACEHOLDER`,displayName:c.displayName??"",state:"JOB_STATE_CREATING",status:M(),createTime:I,updateTime:I,...c.model!==void 0?{model:c.model}:{},...c.inputDatasetId!==void 0?{inputDatasetId:c.inputDatasetId}:{},...c.outputDatasetId!==void 0?{outputDatasetId:c.outputDatasetId}:{}}}if(l==="supervisedFineTuningJobs"){if(c.dataset===void 0)return{__error:"dataset is required"};let F=String(c.dataset).split("/").pop()??"",K=x("dataset",F,i,e.root);return!K||v(K)?{__error:`dataset not found: ${String(c.dataset)}`}:{name:`accounts/${i}/supervisedFineTuningJobs/PLACEHOLDER`,displayName:c.displayName??"",dataset:c.dataset,state:"JOB_STATE_CREATING",status:M(),createTime:I,updateTime:I,...c.baseModel!==void 0?{baseModel:c.baseModel}:{},...c.epochs!==void 0?{epochs:c.epochs}:{},...c.learningRate!==void 0?{learningRate:c.learningRate}:{}}}if(l==="users")return c.role===void 0?{__error:"role is required"}:Ie.includes(c.role)?{name:`accounts/${i}/users/PLACEHOLDER`,displayName:c.displayName??"",email:c.email??null,role:c.role,state:"CREATING",status:M(),createTime:I,updateTime:I,...c.permissionPreset!==void 0?{permissionPreset:c.permissionPreset}:{}}:{__error:`role must be one of ${Ie.join(", ")}`};if(l==="secrets"){if(c.name===void 0||c.keyName===void 0)return{__error:"name and keyName are required"};let F=String(c.name).split("/").pop();return{name:`accounts/${i}/secrets/${F}`,keyName:c.keyName,createTime:I,updateTime:I}}return l==="models"?{name:`accounts/${i}/models/PLACEHOLDER`,displayName:c.displayName??"",state:"CREATING",status:M(),createTime:I,updateTime:I,public:!1,...c.baseModelDetails!==void 0?{baseModelDetails:c.baseModelDetails}:{},...c.contextLength!==void 0?{contextLength:c.contextLength}:{},...c.description!==void 0?{description:c.description}:{}}:{}},k=m(r);if(k.__error!==void 0)return T(400,String(k.__error));let _=l==="deployments"?"deployment":l==="datasets"?"dataset":l==="batchInferenceJobs"?"batchInferenceJob":l==="supervisedFineTuningJobs"?"supervisedFineTuningJob":l==="users"?"user":l==="models"?"model":"secret",h=l==="batchInferenceJobs"?"bij":l==="supervisedFineTuningJobs"?"sft":_==="secret"?"secret":`${_}`;return Tt(_,h,i,r,e,u,y=>m(y))}if(d.length===2&&!p){let m=b,k=x($,m,i,e.root);if(t==="GET")return!k||v(k)?T(404,`Not found: ${l}/${m}`):{status:200,body:O(k)};if(t==="PATCH"){if(!D[l])return T(404,`Unknown request URL: ${t} ${n}.`);if(!k||v(k))return T(404,`Not found: ${l}/${m}`);let _={...r},h=Object.keys(_).filter(y=>!D[l]?.includes(y));return h.length?T(400,`Invalid JSON payload received. Unknown name "${h[0]}": Cannot find field.`):(await N(R,{operation:`${$}.update`,subjectType:$,subjectId:`${i}/${m}`,fields:_,...e.occurredAt?{occurredAt:e.occurredAt}:{},actor:{kind:"agent"}},e.root),{status:200,body:O(x($,m,i,e.root)??{})})}if(t==="DELETE")return kt($,m,i,e)}if(d.length===2&&p&&t==="POST"){let m=b,k=x($,m,i,e.root);if(!k||v(k)&&p!=="undelete")return T(404,`Not found: ${l}/${m}`);if(p==="cancel"&&(l==="batchInferenceJobs"||l==="supervisedFineTuningJobs"))return k.state==="JOB_STATE_CANCELLED"||k.state==="JOB_STATE_CANCELLING"?T(400,`Cannot cancel a job in state ${String(k.state)}`):(await N(R,{operation:`${$}.cancel`,subjectType:$,subjectId:`${i}/${m}`,fields:{state:"JOB_STATE_CANCELLING"},...e.occurredAt?{occurredAt:e.occurredAt}:{},actor:{kind:"agent"}},e.root),{status:200,body:{}});if(p==="resume"&&(l==="batchInferenceJobs"||l==="supervisedFineTuningJobs"))return await N(R,{operation:`${$}.resume`,subjectType:$,subjectId:`${i}/${m}`,fields:{state:"JOB_STATE_RUNNING"},...e.occurredAt?{occurredAt:e.occurredAt}:{},actor:{kind:"agent"}},e.root),{status:200,body:{}};if(p==="undelete"&&l==="deployments")return await N(R,{operation:"deployment.undelete",subjectType:"deployment",subjectId:`${i}/${m}`,fields:{_deleted:!1,state:"CREATING"},...e.occurredAt?{occurredAt:e.occurredAt}:{},actor:{kind:"agent"}},e.root),{status:200,body:O(x("deployment",m,i,e.root)??{})};if(p==="scale"&&l==="deployments"&&t==="POST"){let _=r.replicaCount;return typeof _!="number"?T(400,"replicaCount is required"):(await N(R,{operation:"deployment.scale",subjectType:"deployment",subjectId:`${i}/${m}`,fields:{replicaCount:_},...e.occurredAt?{occurredAt:e.occurredAt}:{},actor:{kind:"agent"}},e.root),{status:200,body:O(x("deployment",m,i,e.root)??{})})}return T(404,`Unknown operation: ${p} on ${l}`)}if(d.length===2&&p==="scale"&&l==="deployments"&&t==="PATCH"){let m=b,k=x("deployment",m,i,e.root);if(!k||v(k))return T(404,`Not found: deployments/${m}`);let _=r.replicaCount;return typeof _!="number"?T(400,"replicaCount is required"):(await N(R,{operation:"deployment.scale",subjectType:"deployment",subjectId:`${i}/${m}`,fields:{replicaCount:_},...e.occurredAt?{occurredAt:e.occurredAt}:{},actor:{kind:"agent"}},e.root),{status:200,body:{}})}if(l==="users"&&d.length>=3&&d[2].split(":")[0]==="apiKeys"){let m=d[1],k=x("user",m,i,e.root);if(!k||k._deleted)return T(404,`Not found: users/${m}`);let _=d.slice(3);if(_.length===0&&t==="GET"){let h=V("apiKey",i,e.root).filter(y=>!y._deleted&&y._user_id===m).map(O);for(let y of h)delete y.key;return{status:200,body:{apiKeys:h,nextPageToken:null,totalSize:h.length}}}if(_.length===0&&t==="POST"&&d[2]==="apiKeys:delete"){let h=typeof r.keyId=="string"?r.keyId:void 0;if(!h)return T(400,"keyId is required");let y=x("apiKey",h,i,e.root);return!y||y._deleted||y._user_id!==m?T(404,`Not found: apiKeys/${h}`):(await N(R,{operation:"apiKey.delete",subjectType:"apiKey",subjectId:`${i}/${h}`,fields:{_deleted:!0},...e.occurredAt?{occurredAt:e.occurredAt}:{},actor:{kind:"agent"}},e.root),{status:200,body:{}})}if(_.length===0&&t==="POST"&&d[2]==="apiKeys"){let h=r.apiKey&&typeof r.apiKey=="object"?r.apiKey:r,y=Ae("apiKey","key",i,e.root),c=new Date(e.occurredAt??"1970-01-01T00:00:00Z").toISOString().replace(/\.\d{3}Z$/,"Z"),I=`fw_${U(y+c)}${j(y).toString(36)}`;return await N(R,{operation:"apiKey.create",subjectType:"apiKey",subjectId:`${i}/${y}`,fields:{name:`accounts/${i}/users/${m}/apiKeys/${y}`,displayName:h.displayName??"default",key:I,prefix:I.slice(0,6),keyId:y,_user_id:m,_account:i,createTime:c,expireTime:typeof h.expireTime=="string"?h.expireTime:null},...e.occurredAt?{occurredAt:e.occurredAt}:{},actor:{kind:"agent"}},e.root),{status:200,body:O(x("apiKey",y,i,e.root)??{})}}if(_.length===1&&t==="GET"){let h=x("apiKey",_[0],i,e.root);if(!h||h._deleted||h._user_id!==m)return T(404,`Not found: apiKeys/${_[0]}`);let y=O(h);return delete y.key,{status:200,body:y}}if(_.length===1&&t==="PATCH"){let h=x("apiKey",_[0],i,e.root);if(!h||h._deleted||h._user_id!==m)return T(404,`Not found: apiKeys/${_[0]}`);let y={...r};for(let F of["key","keyId","prefix","secure","email","createTime","lastUsed","isFirepass"])delete y[F];let c=Object.keys(y).filter(F=>!["displayName","expireTime"].includes(F));if(c.length)return T(400,`Invalid JSON payload received. Unknown name "${c[0]}": Cannot find field.`);await N(R,{operation:"apiKey.update",subjectType:"apiKey",subjectId:`${i}/${_[0]}`,fields:y,...e.occurredAt?{occurredAt:e.occurredAt}:{},actor:{kind:"agent"}},e.root);let I=O(x("apiKey",_[0],i,e.root)??{});return delete I.key,{status:200,body:I}}if(_.length===1&&_[0].endsWith(":delete")&&t==="POST"){let h=typeof r.keyId=="string"?r.keyId:_[0].slice(0,-7),y=x("apiKey",h,i,e.root);return!y||y._deleted||y._user_id!==m?T(404,`Not found: apiKeys/${h}`):(await N(R,{operation:"apiKey.delete",subjectType:"apiKey",subjectId:`${i}/${h}`,fields:{_deleted:!0},...e.occurredAt?{occurredAt:e.occurredAt}:{},actor:{kind:"agent"}},e.root),{status:200,body:{}})}}return T(404,`Unknown request URL: ${t} ${n}.`)}return z(`Unknown request URL: ${t} ${n}.`)}import{serveHttp as un,twinManifest as xt,worldNow as Ce}from"../../engine/v2/volter_world-core.mjs";function It(e){if(!e)return!1;try{return JSON.parse(e)?.stream===!0}catch{return!1}}function St(e){return e.done?`data: [DONE]
|
|
10
|
+
|
|
11
|
+
`:`data: ${JSON.stringify(e.data)}
|
|
12
|
+
|
|
13
|
+
`}var At=new Set([`${C}/chat/completions`,`${C}/completions`,`${C}/messages`]);function Fe(e){let t=e.readOnly??!1,n=e.scenarioPath??process.env.TWIN_FIREWORKS_SCENARIO,o=n?_e(be(n)):void 0;return async function(s){let u=new URL(s.url);if(s.method==="GET"&&u.pathname.replace(/\/+$/,"")==="/twin")return Response.json(xt({vendor:"fireworks",twinOf:"Fireworks AI API (inference plane at /inference/v1, Gateway control plane at /v1/accounts/{account_id})",stateSentence:"Seed control-plane state through the ordinary Gateway API (POST /v1/accounts/{account_id}/deployments?deploymentId=\u2026) with any key.",behaviorSentence:"Chat completions are scripted by MSW-shaped handlers in the world dir (handlers/fireworks.json): {on:{userTextIncludes|anyTextIncludes|modelEquals|lastMessageIsToolResult|serviceTierEquals|nthCall}, respond:{text|reasoning, finishReason?} | fault:{kind:'status'|'slow'|'drop', ...}, once?, phase?}. Unmatched requests answer a labeled stub naming this door.",exampleHandler:{on:{userTextIncludes:"summarize"},respond:{text:"Scripted summary."},once:!0},engine:o}));if(s.method==="GET"&&u.pathname.replace(/\/+$/,"")==="/twin/scenario")return Response.json(o?o.status():{vendor:"fireworks",handlers:[],misses:0,recentMisses:[]});let a=u.pathname+(u.search||""),i=u.pathname.replace(/\/+$/,""),d={};for(let b of["authorization","anthropic-version"]){let E=s.headers.get(b);E!==null&&(d[b]=E)}let f="";if(s.method!=="GET"&&(f=await s.text()),!t&&s.method.toUpperCase()==="POST"&&At.has(i)&&It(f)){let b=[],{status:E,body:A,headers:D}=await q({...o?{scenarioEngine:o}:{},method:s.method,path:a,body:f,readOnly:t,occurredAt:Ce(),headers:d,...e.root!==void 0?{root:e.root}:{},sseSink:k=>b.push(k)});if(E>=400)return new Response(JSON.stringify(A),{status:E,headers:{"content-type":"application/json","x-request-id":"req_twin",...D??{}}});let $=i===`${C}/messages`,m=new ReadableStream({start(k){let _=new TextEncoder;for(let h of b)h.done&&$||k.enqueue(_.encode(St(h)));k.close()}});return new Response(m,{headers:{"content-type":"text/event-stream; charset=utf-8","cache-control":"no-cache","x-request-id":"req_twin"}})}let g,p,l;try{let b=await q({...o?{scenarioEngine:o}:{},method:s.method,path:a,body:f,readOnly:t,occurredAt:Ce(),headers:d,...e.root!==void 0?{root:e.root}:{}});g=b.status,p=b.body,l=b.headers}catch(b){return new Response(JSON.stringify({error:{message:`twin handler error: ${b instanceof Error?b.message:String(b)}`,code:500}}),{status:500,headers:{"content-type":"application/json","x-request-id":"req_twin"}})}return new Response(JSON.stringify(p),{status:g,headers:{"content-type":"application/json","x-request-id":"req_twin",...l??{}}})}}import{assertBudgetGuardIntact as _n,confirmAction as Tn,deployableEntries as kn,observeResources as Ct,projectResources as Je}from"../../engine/v2/volter_world-core.mjs";import{declareRateBudget as Rt,rateBudgetPath as pn,rateBudgetWeight as mn,RateBudget as yn}from"../../engine/v2/volter_world-core.mjs";import{RateBudgetError as Le}from"../../engine/v2/volter_world-core.mjs";var Nt="fireworks",Pe=6e4,De=60,je=300,re={inference:6,other:2},ee={windowMs:Pe,ceiling:De,defaultWeight:re.other,maxRetryAfterSeconds:je,rules:[{match:"^POST /inference/v1/(chat/completions|completions|responses|embeddings|rerank|messages)$",weight:re.inference}],reason:"Fireworks publishes NO scalar per-key request limit (docs.fireworks.ai/serverless/rate-limits, read 2026-09-16): it meters THREE token-per-minute metrics \u2014 Total Prompt TPM, Uncached Prompt TPM and Generated TPM \u2014 each per account AND per model, with ADAPTIVE ceilings that scale within a size tier based on recent usage, so the real numbers live only on the account's dashboard. Its documented rate-limit response headers (X-Ratelimit-Limit-Tokens-Prompt / -Cache-Adjusted-Prompt / -Generated) carry TOKEN CEILING values, not a remaining count or a retry-after, so no header is a signal the cooldown can arm on. Because no published figure justifies going higher, the ceiling is pinned at the kernel fallback in EVERY dimension \u2014 60 units / 60s at defaultWeight 2 = 30 calls/min \u2014 and the declaration buys resolution DOWNWARD, never headroom: the inference endpoints cost 6, so at most 10 land in a window. The window bounds the 60s AVERAGE and does not pace; the `retry-after`/429 cooldown is the only sub-second-burst backstop."};Rt(Nt,ee);var se="fireworks",Ft="1970-01-01T00:00:00.000Z",Be="my-account";function Pt(e,t){if(e===null||typeof e!="object")return[];let n=e[t];return Array.isArray(n)?n:[]}function J(e){let t=e.split("/");return t.length>=4?`${t[1]}/${t[t.length-1]}`:t[t.length-1]??e}function Dt(e){let t=typeof e.name=="string"?e.name:"";return{type:"deployment",id:J(t),fields:{name:t,_account:t.split("/")[1]??null,displayName:e.displayName??null,baseModel:e.baseModel??null,state:e.state??"STATE_UNSPECIFIED",region:e.region??null,replicaCount:e.replicaCount??null,minReplicaCount:e.minReplicaCount??null,maxReplicaCount:e.maxReplicaCount??null,precision:e.precision??null,createTime:e.createTime??null,updateTime:e.updateTime??null,status:e.status??null}}}function jt(e){let t=typeof e.name=="string"?e.name:"";return{type:"dataset",id:J(t),fields:{name:t,_account:t.split("/")[1]??null,displayName:e.displayName??null,state:e.state??"STATE_UNSPECIFIED",format:e.format??null,exampleCount:e.exampleCount??null,userUploaded:e.userUploaded??null,createTime:e.createTime??null,updateTime:e.updateTime??null,status:e.status??null}}}function Lt(e){let t=typeof e.name=="string"?e.name:"";return{type:"batchInferenceJob",id:J(t),fields:{name:t,_account:t.split("/")[1]??null,displayName:e.displayName??null,model:e.model??null,inputDatasetId:e.inputDatasetId??null,outputDatasetId:e.outputDatasetId??null,state:e.state??"JOB_STATE_UNSPECIFIED",createTime:e.createTime??null,updateTime:e.updateTime??null,status:e.status??null}}}function Ut(e){let t=typeof e.name=="string"?e.name:"";return{type:"supervisedFineTuningJob",id:J(t),fields:{name:t,_account:t.split("/")[1]??null,displayName:e.displayName??null,baseModel:e.baseModel??null,dataset:e.dataset??null,state:e.state??"JOB_STATE_UNSPECIFIED",createTime:e.createTime??null,updateTime:e.updateTime??null,status:e.status??null}}}function Jt(e){let t=typeof e.name=="string"?e.name:"";return{type:"user",id:J(t),fields:{name:t,_account:t.split("/")[1]??null,displayName:e.displayName??null,email:e.email??null,role:e.role??null,state:e.state??"STATE_UNSPECIFIED",createTime:e.createTime??null,updateTime:e.updateTime??null,status:e.status??null}}}function Bt(e){let t=typeof e.name=="string"?e.name:"";return{type:"model",id:J(t),fields:{name:t,_account:t.split("/")[1]??null,displayName:e.displayName??null,state:e.state??"STATE_UNSPECIFIED",public:e.public??null,contextLength:e.contextLength??null,createTime:e.createTime??null,updateTime:e.updateTime??null,status:e.status??null}}}function Gt(e){let t=typeof e.name=="string"?e.name:"";return{type:"secret",id:J(t),fields:{name:t,_account:t.split("/")[1]??null,keyName:e.keyName??null,state:e.state??"STATE_UNSPECIFIED",createTime:e.createTime??null,updateTime:e.updateTime??null,status:e.status??null}}}var Ge=[{plural:"deployments",type:"deployment",map:Dt},{plural:"datasets",type:"dataset",map:jt},{plural:"batchInferenceJobs",type:"batchInferenceJob",map:Lt},{plural:"supervisedFineTuningJobs",type:"supervisedFineTuningJob",map:Ut},{plural:"users",type:"user",map:Jt},{plural:"models",type:"model",map:Bt},{plural:"secrets",type:"secret",map:Gt}];async function Me(e,t){let n=[];for(let o of Ge){let r=null;for(let s=0;s<Ue;s++){let u=r?`?pageToken=${encodeURIComponent(r)}&pageSize=200`:"?pageSize=200",a=await e("GET",`/v1/accounts/${encodeURIComponent(t)}/${o.plural}${u}`);if(a.status<200||a.status>=300)throw new Error(`fireworks pull ${o.plural} failed: HTTP ${a.status} ${JSON.stringify(a.data).slice(0,200)}`);for(let i of Pt(a.data,o.plural))n.push(o.map(i));if(r=typeof a.data?.nextPageToken=="string"?a.data.nextPageToken:null,!r)break}if(r!==null)throw new Error(`fireworks pull ${o.plural} did not terminate after ${Ue} pages \u2014 refusing to loop forever on a vendor that keeps returning nextPageToken`)}return n}var Ue=50;function Mt(e,t){let n=t.occurredAt??Ft,o=e.map(s=>({type:s.type,id:s.id,fields:s.fields})),r=new Set(o.map(s=>`${s.type}:${s.id}`));for(let s of Je(se,t.root))Kt.has(s.type)&&s._account===t.accountId&&(r.has(`${s.type}:${s.id}`)||s.deleted!==!0&&o.push({type:s.type,id:s.id,fields:{deleted:!0}}));return Ct(se,o,{...t.root!==void 0?{root:t.root}:{},at:n,batch:`obs:fireworks:${n}`})}var Kt=new Set(Ge.map(e=>e.type));async function Ke(e,t={accountId:""}){let n=await Me(e,t.accountId),o=Mt(n,t);return{observed:o.observed,deltasAppended:o.appended}}function Wt(e,t){return e==="deployment"||e==="user"||e==="batchInferenceJob"||e==="supervisedFineTuningJob"?`?${e}Id=${encodeURIComponent(t)}`:""}var Ht={deployment:"deployments",dataset:"datasets",batchInferenceJob:"batchInferenceJobs",supervisedFineTuningJob:"supervisedFineTuningJobs",user:"users",model:"models",secret:"secrets"},We=/_twin_\d+$/;function ie(e){return e.includes("/")?e.slice(e.indexOf("/")+1):e}function He(e){return e.startsWith("response.")||e==="chat.completion"||e==="completion"?"inference is generative and stores nothing \u2014 replaying it at the vendor would spend real money for no stored state; the twin records it locally only":e.endsWith(".cancel")||e.endsWith(".resume")||e.endsWith(".undelete")||e.endsWith(".scale")?`the custom verb '${e.slice(e.indexOf(".")+1)}' has no push mapping in this pack \u2014 the twin models it for wire fidelity, the connector replays only create/delete`:null}function ze(e,t,n={}){let o=e.operation??`${e.subject.type}.update`,r=o.includes(".")?o.slice(o.indexOf(".")+1):o,s=Ht[e.subject.type];if(!s)throw new Error(`fireworks push: no REST collection for subject type '${e.subject.type}'`);let u=e.fields??{};if(r==="create"){let a=ie(e.subject.id),i=`/v1/accounts/${encodeURIComponent(t)}/${s}${Wt(e.subject.type,a)}`;return e.subject.type==="dataset"?{method:"POST",path:i,body:{dataset:u,datasetId:a}}:e.subject.type==="model"?{method:"POST",path:i,body:{model:u,modelId:a}}:{method:"POST",path:i,body:u}}if(r==="delete"){let a=ie(e.subject.id),i=We.test(a)?n.externalId??null:a;if(i===null)throw new Error(`fireworks push: refusing to address the real account by the twin's own id '${a}' \u2014 no vendor id was ever recorded for this subject`);return{method:"DELETE",path:`/v1/accounts/${encodeURIComponent(t)}/${s}/${encodeURIComponent(i)}`}}throw new Error(`fireworks push: unsupported operation '${o}' \u2014 refusing to silently drop a local write`)}function zt(e){return async(t,n,o)=>{let r=await e({method:t,path:n,headers:{accept:"application/json","content-type":"application/json",authorization:"Bearer fireworks_twin_bootstrap_token"},...o===void 0?{}:{body:JSON.stringify(o)}}),s={};try{s=JSON.parse(r.body||"{}")}catch{s={}}return{status:r.status,data:s}}}function Ve(e){return zt(e)}async function Xe(e,t={}){return Ke(Ve(e),{accountId:t.accountId??Be,...t.root!==void 0?{root:t.root}:{},...t.occurredAt!==void 0?{occurredAt:t.occurredAt}:{}})}async function Ye(e,t,n){let o=t.operation??`${t.subject.type}.update`,r=o.includes(".")?o.slice(o.indexOf(".")+1):o;if(r!=="create"&&r!=="delete")return{externalId:t.subject.id,data:{performed:!1,reason:`${o} is the twin's own record \u2014 ${He(o)??"the connector does not replay it"}`}};let s=t.subject.id.includes("/")?t.subject.id.slice(0,t.subject.id.indexOf("/")):Be,u=Je(se,n.root).find(E=>E.type===t.subject.type&&E.id===t.subject.id),a=typeof u?._external_id=="string"?u._external_id:void 0,i=ie(t.subject.id),d=r==="create"?i:We.test(i)?a??null:i;if(d===null)throw new Error(`fireworks perform ${o} refused: the subject '${t.subject.id}' was never pushed, so the vendor holds no row to ${r}`);let f=ze(t,s,...d!==t.subject.id?[{externalId:d}]:[]),g=await Ve(e)(f.method,f.path,f.body);if(g.status<200||g.status>=300)throw new Error(`fireworks perform ${o} refused: HTTP ${g.status} ${JSON.stringify(g.data).slice(0,200)}`);let p=g.data;return{externalId:(typeof p?.name=="string"?p.name:"").split("/").pop()||d,data:p??{}}}import{registerPack as Xt}from"../../engine/v2/volter_world-core.mjs";var Vt={vendor:"fireworks",rateBudget:ee,transport:"rest",protocol:"2",refresh:{every:"15m",onDemand:{atMost:"60s"}},stateSystem:{perform:Ye,refresh:Xe},roundTrip:[{method:"POST",path:"/inference/v1/chat/completions",body:{model:"accounts/fireworks/models/kimi-k2-instruct",messages:[{role:"user",content:"round trip"}]},headers:{authorization:"Bearer round-trip"}},{method:"POST",path:"/v1/accounts/round-trip/deployments",body:{baseModel:"accounts/fireworks/models/kimi-k2-instruct",displayName:"round trip"},headers:{authorization:"Bearer round-trip"}}],parityOrigin:"http://twin",archetype:"generative",bin:"world-fireworks",resources:["deployment","dataset","batchInferenceJob","supervisedFineTuningJob","user","apiKey","secret","model"],resourcesUnreachable:{account:"the vendor\u2019s own account row (one per credential, not creatable through the API)",quota:"vendor-assigned limits (read-only in the API; the twin derives them from the account)",serverlessModel:"the vendor catalog (serverless models are curated by Fireworks, not created by callers)"},specSource:"Fireworks first-party OpenAPI spec (https://docs.fireworks.ai/merged.openapi.yaml, downloaded 2026-09-16): the merged Gateway REST API 5.10.0 document covering the control plane (api.fireworks.ai/v1/accounts/{account_id}/\u2026) AND the inference plane namespaces (chat/completions, completions, Responses, Anthropic-compatible messages). The embeddings and rerank operations are documented on the vendor api-reference pages only (docs.fireworks.ai/api-reference \u2014 post /embeddings, post /rerank), not in the merged spec. The earlier cited URLs (api.fireworks.ai and app.fireworks.ai api/docs/openapi.json, the per-plane api-reference *-openapi.* files) are dead (404, checked 2026-09-16). Envelope-faithful; model output, embedding values and rerank scores are labeled deterministic stubs.",description:"Fireworks AI twin \u2014 the OpenAI-compatible inference plane (chat/completions + streaming, completions, Responses API CRUD, Anthropic-compatible /v1/messages, embeddings, rerank) with Fireworks\u2019 documented OpenAI differences (usage in the final stream chunk by default, context_length_exceeded_behavior, service_tier 'priority'-only), plus the stateful Gateway control plane (deployments, datasets, batch-inference and supervised-fine-tuning jobs, users/apiKeys, secrets, models) with google.rpc-style statuses; generative output is a labeled deterministic stub.",browserRouting:{apiPathPrefix:"/v",loaderHost:"https://api.fireworks.ai"},adoption:{pypi:["fireworks-ai"],sdks:["@ai-sdk/fireworks"],envStems:["FIREWORKS"]},hosts:[{host:"api.fireworks.ai"}],endpointEnvNone:"The injector intercepts api.fireworks.ai (see `hosts`), so a world wires this pack through FIREWORKS_TWIN_URL rather than an app-read base-URL var. The `fireworks` Python client would honour FIREWORKS_BASE_URL, but @ai-sdk/fireworks \u2014 the dominant client in this repo\u2019s demand census \u2014 takes its baseURL as a constructor option and reads no such env, so an app-read var would cover only half the traffic while disabling the interception that covers all of it."};Xt(Vt);export{Fe as createTwinFetch};
|