agenttwin 0.3.21 → 0.3.23
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/{1250-7571b1a697f6bb4a.js → 1250-a3c859fd20517500.js} +1 -1
- package/dist/dashboard/assets/next/static/chunks/{2743-a0efd6f4aeb11cc5.js → 2743-72610a5d5a3f8462.js} +1 -1
- 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-fc4df4912ce3af44.js +1 -0
- package/dist/dashboard/assets/next/static/chunks/{webpack-40324749d289e4a5.js → webpack-9e40ef55e5f2fb53.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 +6386 -4974
- 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 +6 -5
- 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/chunks/app/v2/page-07c8054d57c9089b.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 → GTd0IQ6HYyhE_2HqcgFno}/_buildManifest.js +0 -0
- /package/dist/dashboard/assets/next/static/{5ub3D2yzS8DE7w2qZd1nv → GTd0IQ6HYyhE_2HqcgFno}/_ssgManifest.js +0 -0
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import{createRequire as __atReq}from'node:module';const require=__atReq(import.meta.url);
|
|
2
|
+
import{applyTwinWrite as ee,applyTwinWriteAtomic as So,ownFields as Ao,projectResources as Ro,resolveSubjectId as _o,subjectAliases as Er,worldNow as To}from"../../engine/v2/volter_world-core.mjs";var Zt={"content-type":"application/json; charset=utf-8"};function C(e,t,r){return{status:e,body:r===void 0?{error:t}:{error:t,message:r},headers:{...Zt}}}var y=(e,t="InvalidRequest")=>C(400,t,e),ve=()=>C(401,"AuthMissing","Authentication Required"),j=(e="Authentication Required",t="AuthenticationRequired")=>C(401,t,e),Ze=()=>C(400,"ExpiredToken","Token has expired"),ce=(e="Token could not be verified")=>C(400,"InvalidToken",e),pe=()=>C(501,"MethodNotImplemented","Method Not Implemented"),Se=()=>C(404,"NotFound","Not Found"),E=e=>C(501,"MethodNotImplemented",`[twin gap] ${e} is real Bluesky surface this twin does not model`),Ae=()=>C(405,"MethodNotAllowed","This twin is read-only");function A(e,t={}){return{status:200,body:e,headers:{...Zt,...t}}}import{blobDigest as ho}from"../../engine/v2/volter_world-core.mjs";var Xe="abcdefghijklmnopqrstuvwxyz234567";function Qe(e){let t="",r=0,o=0;for(let n of e)for(o=o<<8|n,r+=8;r>=5;)t+=Xe[o>>>r-5&31],r-=5;return r>0&&(t+=Xe[o<<5-r&31]),t}function Xt(e){let t=[],r=0,o=0;for(let n of e){let i=Xe.indexOf(n);if(i===-1)return null;o=o<<5|i,r+=5,r>=8&&(t.push(o>>>r-8&255),r-=8)}return new Uint8Array(t)}var Qt=e=>new Uint8Array(e.match(/../g).map(t=>parseInt(t,16)));function qt(e,t){let r=new Uint8Array(4+t.length);return r.set([1,e,18,32]),r.set(t,4),r}var er=85,tr=113;function _e(e){return`b${Qe(qt(er,Qt(e)))}`}function qe(e){if(typeof e!="string"||!e.startsWith("b"))return!1;let t=Xt(e.slice(1));return!!t&&t.length===36&&t[0]===1&&(t[1]===er||t[1]===tr)&&t[2]===18&&t[3]===32}function X(e,t){let r=BigInt(t),o=e<<5;return r<24n?[o|Number(r)]:r<0x100n?[o|24,Number(r)]:r<0x10000n?[o|25,Number(r>>8n)&255,Number(r)&255]:r<0x100000000n?[o|26,...[24n,16n,8n,0n].map(n=>Number(r>>n&0xffn))]:[o|27,...[56n,48n,40n,32n,24n,16n,8n,0n].map(n=>Number(r>>n&0xffn))]}var le=e=>new TextEncoder().encode(e);function Re(e,t){if(e===null){t.push(246);return}if(e===!0){t.push(245);return}if(e===!1){t.push(244);return}if(typeof e=="number"){if(!Number.isSafeInteger(e))throw new Error("atproto data carries no floats");e>=0?t.push(...X(0,e)):t.push(...X(1,-1-e));return}if(typeof e=="string"){let r=le(e);t.push(...X(3,r.length),...r);return}if(Array.isArray(e)){t.push(...X(4,e.length));for(let r of e)Re(r,t);return}if(typeof e=="object"){let r=e,o=Object.keys(r);if(o.length===1&&o[0]==="$link"&&typeof r.$link=="string"){let i=Xt(r.$link.slice(1));if(!r.$link.startsWith("b")||!i)throw new Error(`not a CID: ${r.$link}`);let s=[0,...i];t.push(216,42,...X(2,s.length),...s);return}if(o.length===1&&o[0]==="$bytes"&&typeof r.$bytes=="string"){let i=Uint8Array.from(atob(r.$bytes.replace(/-/g,"+").replace(/_/g,"/")),s=>s.charCodeAt(0));t.push(...X(2,i.length),...i);return}let n=o.filter(i=>r[i]!==void 0);n.sort((i,s)=>{let a=le(i),d=le(s);if(a.length!==d.length)return a.length-d.length;for(let p=0;p<a.length;p+=1)if(a[p]!==d[p])return a[p]-d[p];return 0}),t.push(...X(5,n.length));for(let i of n)Re(i,t),Re(r[i],t);return}throw new Error(`atproto data cannot carry ${typeof e}`)}function mo(e){let t=[];return Re(e,t),new Uint8Array(t)}function W(e){return`b${Qe(qt(tr,Qt(ho(mo(e)))))}`}var rr="234567abcdefghijklmnopqrstuvwxyz";function et(e,t=0){let r=e<<10n|BigInt(t&1023),o="";for(let n=0;n<13;n+=1)o=rr[Number(r&31n)]+o,r>>=5n;return o}function tt(e){if(!/^[234567abcdefghij][234567abcdefghijklmnopqrstuvwxyz]{12}$/.test(e))return null;let t=0n;for(let r of e)t=t<<5n|BigInt(rr.indexOf(r));return t}var or=e=>typeof e=="string"&&tt(e)!==null,Q=e=>le(e).length;function V(e){let t=Intl.Segmenter;if(!t)return[...e].length;let r=0;for(let o of new t(void 0,{granularity:"grapheme"}).segment(e))r+=1;return r}function q(e){let t=typeof e=="string"?le(e):e,r="";for(let o of t)r+=String.fromCharCode(o);return btoa(r).replace(/\+/g,"-").replace(/\//g,"_").replace(/=+$/,"")}function oe(e){if(!/^[A-Za-z0-9_-]*$/.test(e))return null;try{let t=atob(e.replace(/-/g,"+").replace(/_/g,"/")+"=".repeat((4-e.length%4)%4));return Uint8Array.from(t,r=>r.charCodeAt(0))}catch{return null}}function nr(){return`did:plc:${Qe(crypto.getRandomValues(new Uint8Array(15))).slice(0,24)}`}var ir=/^did:(plc:[a-z2-7]{24}|web:[a-zA-Z0-9.%-]+)$/,rt=/^([a-zA-Z0-9]([a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?\.)+[a-zA-Z]([a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?$/;import{join as G}from"node:path";import{blobDigest as yo,getActiveBlobStore as ne,readBranchMeta as bo,readResourceBlob as st,readResourceBlobRange as go,resourceBlobSize as wo,worldPaths as nt}from"../../engine/v2/volter_world-core.mjs";var H="bluesky",at=/^[0-9a-f]{64}$/,Te=e=>nt(H,e).resources,Ie=e=>G("blobs","sha256",e.slice(0,2),e),Ee=e=>e.replace(/[^A-Za-z0-9._-]/g,"_");async function dt(e,t){let r=yo(e),o=G(Te(t),Ie(r));return await ne().exists(o)||await ne().put(o,e),{sha256:r,size:e.length,cid:_e(r)}}async function sr(e,t){return typeof e!="string"||!at.test(e)?null:wo(H,Ie(e),t)}async function ct(e,t,r,o){return typeof e!="string"||!at.test(e)?null:go(H,Ie(e),t,r,o)}async function ar(e,t){return typeof e!="string"||!at.test(e)?null:st(H,Ie(e),t)}async function pt(e,t){try{let r=await st(H,e,t);return r===null?null:JSON.parse(new TextDecoder().decode(r))}catch{return null}}async function it(e,t,r){await ne().put(G(Te(r),e),new TextEncoder().encode(JSON.stringify(t)))}var dr=(e,t)=>G("uploads",Ee(e),`${Ee(t)}.json`);async function lt(e,t,r){await it(dr(e,t.cid),t,r)}async function cr(e,t,r){return pt(dr(e,t),r)}var pr=e=>G("video-jobs",`${Ee(e)}.json`),lr=(e,t)=>G("video-jobs-by-content",Ee(e),`${t}.json`);async function ur(e,t){await it(pr(e.jobId),e,t),await it(lr(e.did,e.sha256),{jobId:e.jobId},t)}async function ut(e,t){return/^[A-Za-z0-9_-]{8,64}$/.test(e)?pt(pr(e),t):null}async function fr(e,t,r){let o=await pt(lr(e,t),r);return o?ut(o.jobId,r):null}async function hr(e){let t=new Map,r=new Set,o=nt(H,e).root;for(;!r.has(o);){r.add(o);let n=`${G(nt(H,o).resources,"video-jobs")}/`;for(let s of await ne().list(n)){if(!s.endsWith(".json")||s.slice(n.length).includes("/"))continue;let a=await ne().get(s);if(a)try{let d=JSON.parse(new TextDecoder().decode(a));t.has(d.jobId)||t.set(d.jobId,d)}catch{}}let i=bo(H,o)?.parent;if(!i)break;o=i.at}return[...t.values()]}var ot=new Map;async function mr(e,t,r){let o=`${Te(r)}|${e}`,n=ot.get(o);if(n)return n;let i=(async()=>{let s=await st(H,e,r);if(s&&s.length>0)return s;let a=await t();return await ne().put(G(Te(r),e),a),a})();ot.set(o,i);try{return await i}catch(s){throw ot.delete(o),s}}async function yr(e){return mr("session-jwt-secret",async()=>crypto.getRandomValues(new Uint8Array(32)),e)}async function Pe(e){let t=await mr("repo-signing-key.jwk",async()=>{let s=await crypto.subtle.generateKey({name:"ECDSA",namedCurve:"P-256"},!0,["sign","verify"]),a=await crypto.subtle.exportKey("jwk",s.privateKey);return new TextEncoder().encode(JSON.stringify(a))},e),r=JSON.parse(new TextDecoder().decode(t)),o={kty:r.kty,crv:r.crv,x:r.x,y:r.y},n=await crypto.subtle.importKey("jwk",r,{name:"ECDSA",namedCurve:"P-256"},!1,["sign"]),i=await crypto.subtle.importKey("jwk",o,{name:"ECDSA",namedCurve:"P-256"},!1,["verify"]);return{privateKey:n,publicKey:i,publicJwk:o}}var xo=7200,ko=90*86400,Ce=new TextEncoder;async function gr(e){return crypto.subtle.importKey("raw",new Uint8Array(await yr(e)),{name:"HMAC",hash:"SHA-256"},!1,["sign","verify"])}var wr=e=>[...crypto.getRandomValues(new Uint8Array(e))].map(t=>t.toString(16).padStart(2,"0")).join("");async function br(e,t,r){let o=`${q(JSON.stringify(e))}.${q(JSON.stringify(t))}`,n=new Uint8Array(await crypto.subtle.sign("HMAC",await gr(r),Ce.encode(o)));return`${o}.${q(n)}`}async function ft(e,t,r,o,n){let i=Math.floor(o/1e3),s=await br({typ:"at+jwt",alg:"HS256"},{scope:t,sub:e,aud:r,iat:i,exp:i+xo},n),a=await br({typ:"refresh+jwt",alg:"HS256"},{scope:"com.atproto.refresh",sub:e,aud:r,jti:wr(16),iat:i,exp:i+ko,...t==="com.atproto.appPass"?{appPass:!0}:{}},n);return{accessJwt:s,refreshJwt:a}}function xr(e){let t=e.split(".");if(t.length!==3)return null;let r=oe(t[0]),o=oe(t[1]),n=oe(t[2]);if(!r||!o||!n)return null;try{let i=JSON.parse(new TextDecoder().decode(r)),s=JSON.parse(new TextDecoder().decode(o));return typeof i!="object"||i===null||typeof s!="object"||s===null?null:{header:i,claims:s,input:`${t[0]}.${t[1]}`,sig:n}}catch{return null}}async function ht(e,t,r,o){let n=xr(e);return!n||n.header.alg!=="HS256"?{ok:!1,reason:"malformed"}:await crypto.subtle.verify("HMAC",await gr(o),new Uint8Array(n.sig),Ce.encode(n.input))?n.header.typ!==t?{ok:!1,reason:"signature"}:typeof n.claims.exp!="number"||n.claims.exp*1e3<=r?{ok:!1,reason:"expired"}:{ok:!0,header:n.header,claims:n.claims}:{ok:!1,reason:"signature"}}async function kr(e,t,r,o,n,i){let{privateKey:s}=await Pe(i),a={iat:Math.floor(n/1e3),iss:e,aud:t,exp:r,...o?{lxm:o}:{},jti:wr(16)},d=`${q(JSON.stringify({typ:"JWT",alg:"ES256"}))}.${q(JSON.stringify(a))}`,p=new Uint8Array(await crypto.subtle.sign({name:"ECDSA",hash:"SHA-256"},s,Ce.encode(d)));return`${d}.${q(p)}`}async function $r(e,t){let r=xr(e);if(!r)return null;if(r.header.alg!=="ES256")return{header:r.header,claims:r.claims,signed:!1};let{publicKey:o}=await Pe(t),n=await crypto.subtle.verify({name:"ECDSA",hash:"SHA-256"},o,new Uint8Array(r.sig),Ce.encode(r.input));return{header:r.header,claims:r.claims,signed:n}}var $o="123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz";function vo(e){let t=0n;for(let o of e)t=t<<8n|BigInt(o);let r="";for(;t>0n;)r=$o[Number(t%58n)]+r,t/=58n;for(let o of e){if(o!==0)break;r=`1${r}`}return r}async function vr(e){let{publicJwk:t}=await Pe(e),r=oe(String(t.x)),o=oe(String(t.y)),n=new Uint8Array(35);return n.set([128,36]),n[2]=(o[o.length-1]&1)===1?3:2,n.set(r,3),`z${vo(n)}`}function Sr(e){let t=e,r=i=>t[i]<<8|t[i+1],o=i=>t[i]|t[i+1]<<8,n=i=>(t[i]<<24>>>0)+(t[i+1]<<16)+(t[i+2]<<8)+t[i+3];if(t.length>=24&&t[0]===137&&t[1]===80&&t[2]===78&&t[3]===71)return{mediaType:"image/png",width:n(16),height:n(20)};if(t.length>=10&&t[0]===71&&t[1]===73&&t[2]===70&&t[3]===56)return{mediaType:"image/gif",width:o(6),height:o(8)};if(t.length>=4&&t[0]===255&&t[1]===216&&t[2]===255){let i=2;for(;i+9<t.length;){if(t[i]!==255){i+=1;continue}let s=t[i+1];if(s===216||s===1||s>=208&&s<=215){i+=2;continue}let a=r(i+2);if(s>=192&&s<=207&&s!==196&&s!==200&&s!==204)return{mediaType:"image/jpeg",height:r(i+5),width:r(i+7)};i+=2+a}}}function mt(e){let t=e,r=new DataView(t.buffer,t.byteOffset,t.byteLength),o=c=>String.fromCharCode(t[c+4],t[c+5],t[c+6],t[c+7]),n=(c,l)=>{let h=[],f=c;for(;f+8<=l;){let u=r.getUint32(f),m=8;if(u===1){if(f+16>l)break;u=Number(r.getBigUint64(f+8)),m=16}else u===0&&(u=l-f);if(u<m||f+u>l)break;h.push([o(f),f+m,f+u]),f+=u}return h},i=n(0,t.length);if(i[0]?.[0]!=="ftyp")return;let s=i.find(([c])=>c==="moov");if(!s)return;let a,d=0,p=0;for(let[c,l,h]of n(s[1],s[2])){if(c==="mvhd"&&h-l>=32){let f=t[l],u=f===1?r.getUint32(l+20):r.getUint32(l+12),m=f===1?Number(r.getBigUint64(l+24)):r.getUint32(l+16);u>0&&(a=Math.round(m*1e3/u))}if(c==="trak"){let f=n(l,h).find(([w])=>w==="tkhd");if(!f)continue;let u=t[f[1]],m=f[1]+(u===1?88:76);if(m+8>f[2])continue;let $=r.getUint32(m)>>>16,b=r.getUint32(m+4)>>>16;$>0&&b>0&&d===0&&(d=$,p=b)}}if(!(a===void 0||d===0))return{width:d,height:p,durationMs:a}}function Ar(e,t){let r=e>0?e:1280,o=t>0?t:720,n=Math.round(Math.min(r,o)*.09),i=r/2,s=o/2;return`<svg xmlns="http://www.w3.org/2000/svg" width="${r}" height="${o}" viewBox="0 0 ${r} ${o}"><rect width="${r}" height="${o}" fill="#000"/><circle cx="${i}" cy="${s}" r="${n}" fill="rgba(0,0,0,0.6)" stroke="#fff" stroke-width="${Math.max(2,n*.06)}"/><path d="M${i-n*.3} ${s-n*.45}L${i+n*.5} ${s}L${i-n*.3} ${s+n*.45}Z" fill="#fff"/></svg>`}var M="bluesky",Eo="https://cdn.bsky.app",Io="https://video.bsky.app",Po="https://bsky.social",Ir="did:web:video.bsky.app",z="app.bsky.feed.post",K="app.bsky.graph.follow",B="app.bsky.actor.profile",Co=52428800,Bo=2e6,Pr=3e8,jo=1e6,Rr=10*6e4,Oo=25,No=10*1024**3,Be=1e3,yt=["JOB_STATE_ENCODING","JOB_STATE_SCANNING","JOB_STATE_UPLOADING"];function _r(e){if(e===void 0||e.trim()==="")return{object:{}};try{let t=JSON.parse(e);return t===null||typeof t!="object"||Array.isArray(t)?{malformed:!0}:{object:t}}catch{return{malformed:!0}}}function wt(e,t){if(e){for(let[r,o]of Object.entries(e))if(r.toLowerCase()===t)return o}}var ie=e=>Ro(M,e),O=(e,t)=>e.filter(r=>r.type===t),k=e=>Ao(e),T=e=>Date.parse(e.occurredAt??To()),N=e=>new Date(T(e)).toISOString(),D=e=>typeof e=="object"&&e!==null&&"status"in e&&"body"in e&&!("did"in e),I=e=>k(e)._deleted===!0||k(e).deleted===!0,he=e=>e.publicBase?.replace(/\/+$/,""),Do=e=>he(e)?`${he(e)}/cdn.bsky.app`:Eo,Uo=e=>he(e)?`${he(e)}/video.bsky.app`:Io,xt=e=>he(e)??Po,Cr=e=>`did:web:${new URL(xt(e)).host.replace(":","%3A")}`,Ne=/^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}(\.\d+)?(Z|[+-]\d{2}:\d{2})$/,kt=/^at:\/\/(did:[a-z]+:[A-Za-z0-9._:%-]+)\/([a-zA-Z0-9.-]+)\/([A-Za-z0-9._:~-]{1,512})$/;function ye(e){return O(e,"account").filter(t=>!I(t)).map(t=>({...k(t),did:String(t.id)}))}function P(e,t){if(typeof t!="string"||t==="")return;let r=t.startsWith("@")?t.slice(1):t;return ye(e).find(o=>o.did===r||o.handle.toLowerCase()===r.toLowerCase())}var ue=async e=>[...new Uint8Array(await crypto.subtle.digest("SHA-256",new TextEncoder().encode(e)))].map(t=>t.toString(16).padStart(2,"0")).join("");async function $t(e,t){return{"@context":["https://www.w3.org/ns/did/v1","https://w3id.org/security/multikey/v1","https://w3id.org/security/suites/secp256k1-2019/v1"],id:t.did,alsoKnownAs:[`at://${t.handle}`],verificationMethod:[{id:`${t.did}#atproto`,type:"Multikey",controller:t.did,publicKeyMultibase:await vr(e.root)}],service:[{id:"#atproto_pds",type:"AtprotoPersonalDataServer",serviceEndpoint:xt(e)}]}}function De(e){let t=wt(e.headers,"authorization");if(t===void 0||t==="")return;let r=t.split(" ");if(r.length!==2)return ce("Malformed authorization header");let o=r[0].toUpperCase();return o==="BEARER"?r[1]:o==="DPOP"?E("OAuth (DPoP-bound access tokens)"):o==="BASIC"?E("Admin (Basic) authentication"):ce(`Unsupported authorization type: ${r[0]}`)}async function Br(e,t){let r=De(e);if(r===void 0)return ve();if(typeof r!="string")return r;let o=await ue(r),n=O(t,"_token").find(a=>String(a.id)===o&&!I(a));if(n){let a=String(k(n).did);return P(t,a)?{did:a,scope:"com.atproto.access"}:j("Account not found","AccountNotFound")}let i=await ht(r,"at+jwt",T(e),e.root);if(!i.ok)return i.reason==="expired"?Ze():ce(i.reason==="malformed"?"Malformed token":"Token could not be verified");let s=String(i.claims.sub);return P(t,s)?{did:s,scope:String(i.claims.scope)}:C(403,"AccountNotFound","Account not found")}async function Mo(e,t){return De(e)===void 0?null:Br(e,t)}async function Lo(e,t,r){let{identifier:o,password:n}=r;if(typeof o!="string")return y('Input must have the property "identifier"');if(typeof n!="string")return y('Input must have the property "password"');if(r.authFactorToken!==void 0)return E("Email two-factor sign-in (authFactorToken)");let i=o.trim(),s=P(t,i)??ye(t).find(c=>c.email!==void 0&&c.email.toLowerCase()===i.toLowerCase());if(!s)return j("Invalid identifier or password");let a=await ue(n),d;if(O(t,"_account_password").some(c=>String(c.id)===s.did&&k(c).passwordSha256===a)?d="com.atproto.access":O(t,"_app_password").some(c=>!I(c)&&k(c).did===s.did&&k(c).passwordSha256===a)&&(d="com.atproto.appPass"),!d)return j("Invalid identifier or password");let p=await ft(s.did,d,Cr(e),T(e),e.root);return A({...p,handle:s.handle,did:s.did,didDoc:await $t(e,s),...s.email!==void 0?{email:s.email}:{},emailConfirmed:s.emailConfirmed,emailAuthFactor:!1,active:!0})}async function zo(e,t){let r=De(e);if(r===void 0)return ve();if(typeof r!="string")return r;let o=await ht(r,"refresh+jwt",T(e),e.root);if(!o.ok)return o.reason==="expired"?Ze():ce(o.reason==="malformed"?"Malformed token":"Token could not be verified");let n=P(t,o.claims.sub);if(!n)return C(403,"AccountNotFound","Account not found");let i=await ft(n.did,o.claims.appPass===!0?"com.atproto.appPass":"com.atproto.access",Cr(e),T(e),e.root);return A({...i,handle:n.handle,did:n.did,didDoc:await $t(e,n),active:!0})}async function Fo(e,t,r){let o=P(t,r.did);return A({handle:o.handle,did:o.did,didDoc:await $t(e,o),...o.email!==void 0?{email:o.email}:{},emailConfirmed:o.emailConfirmed,emailAuthFactor:!1,active:!0})}async function Jo(e,t,r){let o=r.searchParams.get("aud");if(o===null)return y('Params must have the property "aud"');if(!/^did:[a-z]+:[A-Za-z0-9._:%-]+(#[A-Za-z0-9_-]+)?$/.test(o))return y("aud must be a valid atproto DID or did#serviceId reference");let n=r.searchParams.get("lxm");if(n!==null&&!/^[a-zA-Z]([a-zA-Z0-9-]*\.)+[a-zA-Z][a-zA-Z0-9]*$/.test(n))return y("lxm must be a valid nsid");let i=T(e),s=r.searchParams.get("exp"),a=Math.floor(i/1e3)+60;if(s!==null){if(!/^\d+$/.test(s))return y("exp must be an integer");a=Number(s);let d=a*1e3-i;if(d<0)return y("expiration is in past","BadExpiration");if(d>36e5)return y("cannot request a token with an expiration more than an hour in the future","BadExpiration");if(n===null&&d>6e4)return y("cannot request a method-less token with an expiration more than a minute in the future","BadExpiration")}return A({token:await kr(t.did,o,a,n,i,e.root)})}var L=(e,t,r)=>`at://${e}/${t}/${r}`,Ue=e=>typeof e=="object"&&e!==null&&e.$type==="blob"&&typeof e.ref?.$link=="string"&&typeof e.mimeType=="string"&&typeof e.size=="number",x=(e,t,r)=>y(`Invalid ${e} record: ${t} ${r}`);async function je(e,t,r,o,n,i,s){if(!Ue(n))return x(r,o,"should be a blob ref");if(!i(n.mimeType))return x(r,o,`mimeType (${n.mimeType}) not accepted`);if(n.size>s)return x(r,o,`size (${n.size}) cannot be greater than ${s}`);let a=n.ref.$link,d=qe(a)?await cr(t,a,e.root):null;return!d||d.available_ms>T(e)?y(`Could not find blob: ${a}`,"BlobNotFound"):d.mimeType!==n.mimeType||d.size!==n.size?y(`Referenced Mimetype does not match stored blob. Expected: ${d.mimeType}, Got: ${n.mimeType}`,"InvalidMimeType"):{...d,field:o}}var me=e=>typeof e=="object"&&e!==null&&typeof e.uri=="string"&&kt.test(e.uri)&&qe(e.cid);function Tr(e){return e===void 0?!0:typeof e=="object"&&e!==null&&Number.isInteger(e.width)&&e.width>=1&&Number.isInteger(e.height)&&e.height>=1}async function Ho(e,t,r){let o=z;if(typeof r.text!="string")return x(o,"Record/text","must be a string");if(V(r.text)>300)return x(o,"Record/text","must not be longer than 300 graphemes");if(Q(r.text)>3e3)return x(o,"Record/text","must not be longer than 3000 characters");if(typeof r.createdAt!="string"||!Ne.test(r.createdAt)||Number.isNaN(Date.parse(r.createdAt)))return x(o,"Record/createdAt","must be an valid atproto datetime (both RFC-3339 and ISO-8601)");if(r.facets!==void 0){if(!Array.isArray(r.facets))return x(o,"Record/facets","must be an array");for(let[s,a]of r.facets.entries()){let d=a?.index;if(!d||!Number.isInteger(d.byteStart)||!Number.isInteger(d.byteEnd)||d.byteStart<0||d.byteEnd<0)return x(o,`Record/facets/${s}/index`,"must have integer byteStart and byteEnd >= 0");if(!Array.isArray(a.features))return x(o,`Record/facets/${s}/features`,"must be an array");for(let[p,c]of a.features.entries()){let l=`Record/facets/${s}/features/${p}`;if(c?.$type==="app.bsky.richtext.facet#link"&&(typeof c.uri!="string"||!/^[a-z][a-z0-9+.-]*:\S+$/i.test(c.uri)))return x(o,`${l}/uri`,"must be a uri");if(c?.$type==="app.bsky.richtext.facet#mention"&&(typeof c.did!="string"||!/^did:[a-z]+:\S+$/.test(c.did)))return x(o,`${l}/did`,"must be a did");if(c?.$type==="app.bsky.richtext.facet#tag"&&(typeof c.tag!="string"||Q(c.tag)>640||V(c.tag)>64))return x(o,`${l}/tag`,"must be a string of at most 64 graphemes")}}}if(r.langs!==void 0&&(!Array.isArray(r.langs)||r.langs.length>3||r.langs.some(s=>typeof s!="string")))return x(o,"Record/langs","must be an array of at most 3 language tags");if(r.tags!==void 0&&(!Array.isArray(r.tags)||r.tags.length>8||r.tags.some(s=>typeof s!="string"||V(s)>64)))return x(o,"Record/tags","must be an array of at most 8 tags");if(r.labels!==void 0)return E("Self-labels on a post (labels)");if(r.reply!==void 0){if(!me(r.reply?.root))return x(o,"Record/reply/root","must be a strong ref (uri, cid)");if(!me(r.reply?.parent))return x(o,"Record/reply/parent","must be a strong ref (uri, cid)")}let n=[],i=r.embed;if(i!==void 0){if(typeof i!="object"||i===null)return x(o,"Record/embed","must be an object");if(i.$type==="app.bsky.embed.images"){if(!Array.isArray(i.images)||i.images.length<1)return x(o,"Record/embed/images","must be an array of 1 to 4 images");if(i.images.length>4)return x(o,"Record/embed/images","must not have more than 4 elements");for(let[s,a]of i.images.entries()){if(typeof a?.alt!="string")return x(o,`Record/embed/images/${s}/alt`,"must be a string");if(!Tr(a.aspectRatio))return x(o,`Record/embed/images/${s}/aspectRatio`,"must have integer width and height >= 1");let d=await je(e,t,o,`Record/embed/images/${s}/image`,a.image,p=>p.startsWith("image/"),Bo);if(D(d))return d;n.push(d)}}else if(i.$type==="app.bsky.embed.video"){if(i.captions!==void 0)return E("Video captions (app.bsky.embed.video captions)");if(i.alt!==void 0&&(typeof i.alt!="string"||V(i.alt)>1e3))return x(o,"Record/embed/alt","must be a string of at most 1000 graphemes");if(!Tr(i.aspectRatio))return x(o,"Record/embed/aspectRatio","must have integer width and height >= 1");if(i.presentation!==void 0&&typeof i.presentation!="string")return x(o,"Record/embed/presentation","must be a string");let s=await je(e,t,o,"Record/embed/video",i.video,a=>a==="video/mp4",Pr);if(D(s))return s;n.push(s)}else if(i.$type==="app.bsky.embed.external"){let s=i.external;if(typeof s!="object"||s===null||typeof s.uri!="string"||typeof s.title!="string"||typeof s.description!="string")return x(o,"Record/embed/external","must have uri, title and description");if(s.thumb!==void 0){let a=await je(e,t,o,"Record/embed/external/thumb",s.thumb,d=>d.startsWith("image/"),1e6);if(D(a))return a;n.push(a)}}else{if(i.$type==="app.bsky.embed.record"||i.$type==="app.bsky.embed.recordWithMedia")return E(`Quote posts (${i.$type})`);if(typeof i.$type!="string")return x(o,"Record/embed",'must be an object which includes the "$type" property')}}return n}async function Wo(e,t,r){let o=B;if(r.displayName!==void 0&&(typeof r.displayName!="string"||V(r.displayName)>64||Q(r.displayName)>640))return x(o,"Record/displayName","must not be longer than 64 graphemes");if(r.description!==void 0&&(typeof r.description!="string"||V(r.description)>256||Q(r.description)>2560))return x(o,"Record/description","must not be longer than 256 graphemes");if(r.createdAt!==void 0&&(typeof r.createdAt!="string"||!Ne.test(r.createdAt)))return x(o,"Record/createdAt","must be an valid atproto datetime (both RFC-3339 and ISO-8601)");if(r.pinnedPost!==void 0&&!me(r.pinnedPost))return x(o,"Record/pinnedPost","must be a strong ref (uri, cid)");if(r.pronouns!==void 0&&(typeof r.pronouns!="string"||V(r.pronouns)>20||Q(r.pronouns)>200))return x(o,"Record/pronouns","must not be longer than 20 graphemes");if(r.website!==void 0&&(typeof r.website!="string"||!/^[a-z][a-z0-9+.-]*:\S+$/i.test(r.website)))return x(o,"Record/website","must be a uri");if(r.joinedViaStarterPack!==void 0&&!me(r.joinedViaStarterPack))return x(o,"Record/joinedViaStarterPack","must be a strong ref (uri, cid)");if(r.labels!==void 0){let i=r.labels;if(typeof i!="object"||i===null||i.$type!=="com.atproto.label.defs#selfLabels"||!Array.isArray(i.values)||i.values.length>10||i.values.some(s=>typeof s?.val!="string"||Q(s.val)>128))return x(o,"Record/labels","must be com.atproto.label.defs#selfLabels (at most 10 values)")}let n=[];for(let i of["avatar","banner"]){if(r[i]===void 0)continue;let s=await je(e,t,o,`Record/${i}`,r[i],a=>a==="image/png"||a==="image/jpeg",jo);if(D(s))return s;n.push(s)}return n}function Vo(e){if(typeof e.subject!="string"||!/^did:[a-z]+:\S+$/.test(e.subject))return x(K,"Record/subject","must be a did");if(typeof e.createdAt!="string"||!Ne.test(e.createdAt))return x(K,"Record/createdAt","must be an valid atproto datetime (both RFC-3339 and ISO-8601)")}var jr=e=>e.map(t=>({field:t.field,cid:t.cid,sha256:t.sha256,mimeType:t.mimeType,size:t.size,...t.width!==void 0?{width:t.width,height:t.height}:{},...t.duration_ms!==void 0?{duration_ms:t.duration_ms}:{}}));function Or(e,t,r){let o=0n,n=e.filter(i=>i.type==="post"||i.type==="follow").map(i=>String(i.id));for(let i of Er(M,r).keys()){let s=i.indexOf(":");n.push(i.slice(s+1))}for(let i of n){let s=kt.exec(i);if(!s||s[1]!==t)continue;let a=tt(s[3]);a!==null&&a>o&&(o=a)}return o}function Nr(e,t){try{return W(e)}catch(r){return x(t,"Record",`cannot be encoded: ${r instanceof Error?r.message:String(r)}`)}}var Dr=(1n<<63n)-1n;function Go(e,t,r,o,n,i){let s=new Set(e.filter(f=>f.type==="post"||f.type==="follow").map(f=>String(f.id)));for(let f of Er(M,i).keys())s.add(f.slice(f.indexOf(":")+1));let a="abcdefghijklmnopqrstuvwxyz234567",d=BigInt((a.indexOf(n.at(-2))<<5|a.indexOf(n.at(-1)))&1023),p=o<<10n|d,c=Or(e,t,i),l=p>c?p:c+1n;l>Dr&&(l=p);let h=f=>et(f>>10n,Number(f&1023n));for(;s.has(L(t,r,h(l)))||s.has(L(t,r===z?K:z,h(l)));)l+=1n;return h(l)}function vt(e,t,r){let o=BigInt(T(r))*1000n<<10n,n=Or(e,t,r.root),i=o>n?o:n+1n<=Dr?n+1n:o;return et(i>>10n,Number(i&1023n))}function St(e,t,r){if(typeof r!="string")return y('Input must have the property "repo"');let o=P(e,r);return o?o.did!==t.did?j():{did:o.did}:y(`Could not find repo for DID: ${r}`,"RepoNotFound")}async function Ko(e,t,r,o){let n=St(t,r,o.repo);if(D(n))return n;let i=o.collection;if(typeof i!="string")return y('Input must have the property "collection"');if(o.swapCommit!==void 0&&o.swapCommit!==null)return E("swapCommit on a record write");if(o.validate===!1)return E("Writing a record unvalidated (validate: false)");let s=o.record;if(typeof s!="object"||s===null||Array.isArray(s))return y('Input must have the property "record"');if(s.$type!==void 0&&s.$type!==i)return y(`Invalid $type: expected ${i}, got ${s.$type}`);if(i===B)return Ur(e,t,r,n.did,o.rkey??"self",s,"create");if(i!==z&&i!==K)return E(`Records of ${i}`);if(o.rkey!==void 0&&!or(o.rkey))return y(`Invalid record key for ${i}: must be a valid TID`);let a=[];if(i===z){let u=await Ho(e,n.did,s);if(D(u))return u;a=u}else{let u=Vo(s);if(u)return u}let d={...s,$type:i},p=Nr(d,i);if(typeof p!="string")return p;let c=i===z?"post":"follow",l=BigInt(T(e))*1000n,{value:h}=await So(M,u=>{let m;if(o.rkey!==void 0){m=o.rkey;let b=L(n.did,i,m);if(u.some(w=>w.type===c&&String(w.id)===b&&!I(w)))return{kind:"skip",value:null}}else m=Go(u,n.did,i,l,p,e.root);let $=L(n.did,i,m);return{kind:"write",value:{uri:$,rkey:m},write:{operation:`bluesky.${c}.create`,subjectType:c,subjectId:$,fields:{did:n.did,collection:i,rkey:m,cid:p,record:d,indexedAt:N(e),...c==="follow"?{subject:d.subject}:{},...a.length>0?{_blobs:jr(a)}:{},_deleted:!1},occurredAt:N(e),actor:{kind:"agent",id:r.did}}}},e.root);if(h===null)return y(`Record already exists: ${L(n.did,i,String(o.rkey))}`);if(c==="follow")for(let u of O(t,"follow").filter(m=>!I(m)&&k(m).did===n.did&&k(m).subject===d.subject&&String(m.id)!==h.uri))await ee(M,{operation:"bluesky.follow.delete",subjectType:"follow",subjectId:String(u.id),fields:{...k(u),_deleted:!0},occurredAt:N(e),actor:{kind:"agent",id:r.did}},e.root);let f=vt(ie(e.root),n.did,e);return A({uri:h.uri,cid:p,commit:{cid:W({did:n.did,version:3,rev:f,data:{$link:p}}),rev:f},validationStatus:"valid"})}async function Ur(e,t,r,o,n,i,s,a){if(n!=="self")return y(`Invalid record key for ${B}: must be "self"`);let d=O(t,"profile").find(f=>String(f.id)===o&&!I(f));if(s==="create"&&d)return y(`Record already exists: ${L(o,B,"self")}`);if(a!==void 0){let f=d?String(k(d).cid):null;if(a!==f)return y(`Record was at ${f??"null"}`,"InvalidSwap")}let p=await Wo(e,o,i);if(D(p))return p;let c={...i,$type:B},l=Nr(c,B);if(typeof l!="string")return l;await ee(M,{operation:"bluesky.profile.put",subjectType:"profile",subjectId:o,fields:{did:o,collection:B,rkey:"self",cid:l,record:c,indexedAt:N(e),...p.length>0?{_blobs:jr(p)}:{_blobs:[]},_deleted:!1},occurredAt:N(e),actor:{kind:"agent",id:r.did}},e.root);let h=vt(t,o,e);return A({uri:L(o,B,"self"),cid:l,commit:{cid:W({did:o,version:3,rev:h,data:{$link:l}}),rev:h},validationStatus:"valid"})}async function Yo(e,t,r,o){let n=St(t,r,o.repo);if(D(n))return n;if(o.swapCommit!==void 0&&o.swapCommit!==null)return E("swapCommit on a record write");if(o.validate===!1)return E("Writing a record unvalidated (validate: false)");let i=o.record;return typeof i!="object"||i===null||Array.isArray(i)?y('Input must have the property "record"'):o.collection!==B?E(`Updating a record of ${String(o.collection)} (putRecord)`):i.$type!==void 0&&i.$type!==B?y(`Invalid $type: expected ${B}, got ${i.$type}`):Ur(e,t,r,n.did,o.rkey,i,"put",o.swapRecord)}function At(e,t,r,o){let n=_o(M,t,r,o);return O(e,t).find(i=>String(i.id)===n)}async function Zo(e,t,r,o){let n=St(t,r,o.repo);if(D(n))return n;let{collection:i,rkey:s}=o;if(typeof i!="string")return y('Input must have the property "collection"');if(typeof s!="string")return y('Input must have the property "rkey"');if(o.swapRecord!==void 0&&o.swapRecord!==null||o.swapCommit!==void 0&&o.swapCommit!==null)return E("swapRecord / swapCommit on a delete");if(i!==z&&i!==K&&i!==B)return E(`Deleting a record of ${i}`);let a=i===z?"post":i===K?"follow":"profile",d=a==="profile"?s==="self"?O(t,"profile").find(c=>String(c.id)===n.did):void 0:At(t,a,L(n.did,i,s),e.root);if(!d||I(d))return A({});await ee(M,{operation:`bluesky.${a}.delete`,subjectType:a,subjectId:String(d.id),fields:{...k(d),_deleted:!0},occurredAt:N(e),actor:{kind:"agent",id:r.did}},e.root);let p=vt(t,n.did,e);return A({commit:{cid:W({did:n.did,version:3,rev:p,data:null}),rev:p}})}function Xo(e,t,r,o,n){if(r===B)return o==="self"?O(e,"profile").find(a=>String(a.id)===t&&!I(a)):void 0;let i=r===z?"post":r===K?"follow":void 0;if(!i)return;let s=At(e,i,L(t,r,o),n);return s&&!I(s)?s:void 0}function Qo(e,t,r){let o=t.searchParams.get("repo"),n=t.searchParams.get("collection"),i=t.searchParams.get("rkey");if(o===null)return y('Params must have the property "repo"');if(n===null)return y('Params must have the property "collection"');if(i===null)return y('Params must have the property "rkey"');let s=P(e,o);if(!s)return y(`Could not find repo for DID: ${o}`,"RepoNotFound");let a=L(s.did,n,i),d=Xo(e,s.did,n,i,r);if(!d)return y(`Could not locate record: ${a}`,"RecordNotFound");let p=k(d),c=t.searchParams.get("cid");return c!==null&&c!==p.cid?y(`Could not locate record: ${a}`,"RecordNotFound"):A({uri:n===B?a:String(d.id),cid:p.cid,value:p.record})}function qo(e,t){let r=t.searchParams.get("repo"),o=t.searchParams.get("collection");if(r===null)return y('Params must have the property "repo"');if(o===null)return y('Params must have the property "collection"');let n=t.searchParams.get("limit"),i=n===null?50:Number(n);if(!Number.isInteger(i)||i<1||i>100)return y("limit must be an integer between 1 and 100");let s=P(e,r);if(!s)return y(`Could not find repo for DID: ${r}`,"RepoNotFound");let a=t.searchParams.get("reverse")==="true",d=t.searchParams.get("cursor"),p;o===B?p=O(e,"profile").filter(u=>String(u.id)===s.did&&!I(u)):o===z||o===K?p=O(e,o===z?"post":"follow").filter(u=>k(u).did===s.did&&!I(u)):p=[];let c=p.map(u=>({r:u,rkey:String(k(u).rkey)})).sort((u,m)=>u.rkey<m.rkey?1:u.rkey>m.rkey?-1:0);a&&c.reverse();let l=d===null?c:c.filter(u=>a?u.rkey>d:u.rkey<d),h=l.slice(0,i),f=h.map(({r:u})=>({uri:L(s.did,o,String(k(u).rkey)),cid:k(u).cid,value:k(u).record}));return A({...l.length>i?{cursor:h.at(-1).rkey}:{},records:f})}async function en(e,t){let r=e.bytes??new Uint8Array;if(r.length>Co)return C(413,"PayloadTooLarge","request entity too large");let o=(wt(e.headers,"content-type")??"").split(";")[0].trim().toLowerCase(),n=Sr(r),i=n?void 0:mt(r),s=n?.mediaType??(i?"video/mp4":o!==""&&o!=="*/*"?o:"application/octet-stream"),a=await dt(r,e.root);return await lt(t.did,{cid:a.cid,sha256:a.sha256,mimeType:s,size:r.length,available_ms:T(e),...n?{width:n.width,height:n.height}:i?{width:i.width,height:i.height,duration_ms:i.durationMs}:{}},e.root),A({blob:{$type:"blob",ref:{$link:a.cid},mimeType:s,size:r.length}})}function Mr(e,t){return ye(ie(t)).some(r=>r.did===e)}function be(e,t,r){for(let o of ie(r)){if(!["post","profile"].includes(o.type)||I(o))continue;let n=k(o);if(n.did!==e||!Array.isArray(n._blobs))continue;let i=n._blobs.find(s=>s.cid===t);if(i)return i}}var Lr=(e,t)=>{let r=O(e,"profile").find(o=>String(o.id)===t&&!I(o));return r?k(r).record:void 0},fe=(e,t,r,o)=>`${Do(e)}/img/${t}/plain/${r}/${o}@jpeg`;function zr(e,t,r){let o=Lr(t,r.did);return{did:r.did,handle:r.handle,...typeof o?.displayName=="string"?{displayName:o.displayName}:{},...Ue(o?.avatar)?{avatar:fe(e,"avatar",r.did,o.avatar.ref.$link)}:{},associated:{activitySubscription:{allowSubscriptions:"followers"}},labels:[],createdAt:r.createdAt}}var Me=e=>O(e,"post").filter(t=>!I(t)),tn=e=>O(e,"follow").filter(t=>!I(t));function rn(e,t,r){let o=Lr(t,r.did),n=tn(t);return{...zr(e,t,r),...typeof o?.description=="string"?{description:o.description}:{},...Ue(o?.banner)?{banner:fe(e,"banner",r.did,o.banner.ref.$link)}:{},followersCount:new Set(n.filter(i=>k(i).subject===r.did).map(i=>k(i).did)).size,followsCount:n.filter(i=>k(i).did===r.did).length,postsCount:Me(t).filter(i=>k(i).did===r.did).length,indexedAt:r.createdAt,...me(o?.pinnedPost)?{pinnedPost:o.pinnedPost}:{},viewer:{muted:!1,blockedBy:!1}}}function on(e,t,r,o){let n=r.embed;if(n){if(n.$type==="app.bsky.embed.images")return{$type:"app.bsky.embed.images#view",images:n.images.map(i=>({thumb:fe(e,"feed_thumbnail",t,i.image.ref.$link),fullsize:fe(e,"feed_fullsize",t,i.image.ref.$link),alt:i.alt,...i.aspectRatio?{aspectRatio:i.aspectRatio}:{}}))};if(n.$type==="app.bsky.embed.video"){let i=n.video.ref.$link,s=o.find(d=>d.cid===i),a=`${Uo(e)}/watch/${encodeURIComponent(t)}/${i}`;return{$type:"app.bsky.embed.video#view",cid:i,playlist:`${a}/playlist.m3u8`,thumbnail:`${a}/thumbnail.jpg`,...typeof n.alt=="string"?{alt:n.alt}:{},...n.aspectRatio?{aspectRatio:n.aspectRatio}:s?.width?{aspectRatio:{width:s.width,height:s.height}}:{},...typeof n.presentation=="string"?{presentation:n.presentation}:{}}}if(n.$type==="app.bsky.embed.external"){let i=n.external;return{$type:"app.bsky.embed.external#view",external:{uri:i.uri,title:i.title,description:i.description,...Ue(i.thumb)?{thumb:fe(e,"feed_thumbnail",t,i.thumb.ref.$link)}:{}}}}}}function se(e,t,r){let o=k(r),n=P(t,o.did),i=String(r.id),s=on(e,o.did,o.record,Array.isArray(o._blobs)?o._blobs:[]);return{uri:i,cid:o.cid,author:n?zr(e,t,n):{did:o.did,handle:"handle.invalid",labels:[]},record:o.record,...s?{embed:s}:{},bookmarkCount:0,replyCount:Me(t).filter(a=>k(a).record?.reply?.parent?.uri===i).length,repostCount:0,likeCount:0,quoteCount:0,indexedAt:o.indexedAt,viewer:{bookmarked:!1,threadMuted:!1,embeddingDisabled:!1},labels:[]}}var bt=e=>{let t=k(e),r=String(t.record?.createdAt??"");return r!==""&&r<t.indexedAt?r:String(t.indexedAt)};function gt(e,t,r){let o=At(e,"post",t,r);return o&&!I(o)?o:void 0}function nn(e,t,r){let o=r.searchParams.get("actor");if(o===null)return y('Params must have the property "actor"');let n=r.searchParams.get("limit"),i=n===null?50:Number(n);if(!Number.isInteger(i)||i<1||i>100)return y("limit must be an integer between 1 and 100");let s=r.searchParams.get("filter")??"posts_with_replies",a=["posts_with_replies","posts_no_replies","posts_with_media","posts_and_author_threads","posts_with_video"];if(!a.includes(s))return y(`filter must be one of ${a.join(", ")}`);let d=P(t,o);if(!d)return y("Profile not found");let p=["app.bsky.embed.images","app.bsky.embed.video"],c=Me(t).filter(b=>k(b).did===d.did);s==="posts_no_replies"&&(c=c.filter(b=>!k(b).record?.reply)),s==="posts_and_author_threads"&&(c=c.filter(b=>{let w=k(b).record?.reply;return!w||String(w.root?.uri??"").startsWith(`at://${d.did}/`)})),s==="posts_with_media"&&(c=c.filter(b=>!k(b).record?.reply&&p.includes(k(b).record?.embed?.$type))),s==="posts_with_video"&&(c=c.filter(b=>!k(b).record?.reply&&k(b).record?.embed?.$type==="app.bsky.embed.video"));let l=b=>`${bt(b)}::${k(b).cid}`,h=c.map(b=>({p:b,key:l(b)})).sort((b,w)=>b.key<w.key?1:b.key>w.key?-1:0),f=r.searchParams.get("cursor"),u=f===null?h:h.filter(b=>b.key<f),m=u.slice(0,i),$=m.map(({p:b})=>{let w=k(b).record?.reply;if(!w)return{post:se(e,t,b)};let F=_=>{let Z=gt(t,_,e.root);return Z?{$type:"app.bsky.feed.defs#postView",...se(e,t,Z)}:{$type:"app.bsky.feed.defs#notFoundPost",uri:_,notFound:!0}};return{post:se(e,t,b),reply:{root:F(w.root.uri),parent:F(w.parent.uri)}}});return A({...u.length>i?{cursor:m.at(-1).key}:{},feed:$})}function sn(e,t,r){let o=r.searchParams.get("uri");if(o===null)return y('Params must have the property "uri"');let n=Number(r.searchParams.get("depth")??6),i=Number(r.searchParams.get("parentHeight")??80);if(!Number.isInteger(n)||n<0||n>1e3)return y("depth must be an integer between 0 and 1000");if(!Number.isInteger(i)||i<0||i>1e3)return y("parentHeight must be an integer between 0 and 1000");let s=kt.exec(o)??/^at:\/\/([^/]+)\/([^/]+)\/([^/]+)$/.exec(o),a=s?P(t,s[1]):void 0,d=a&&s?gt(t,L(a.did,s[2],s[3]),e.root):void 0;if(!d)return y(`Post not found: ${o}`,"NotFound");let p=(h,f)=>{if(f<=0)return[];let u=String(h.id);return Me(t).filter(m=>k(m).record?.reply?.parent?.uri===u).sort((m,$)=>bt(m)<bt($)?-1:1).map(m=>({$type:"app.bsky.feed.defs#threadViewPost",post:se(e,t,m),replies:p(m,f-1)}))},c=(h,f)=>{let u=k(h).record?.reply?.parent?.uri;if(!u||f<=0)return;let m=gt(t,u,e.root);if(!m)return{$type:"app.bsky.feed.defs#notFoundPost",uri:u,notFound:!0};let $=c(m,f-1);return{$type:"app.bsky.feed.defs#threadViewPost",post:se(e,t,m),...$?{parent:$}:{}}},l=c(d,i);return A({thread:{$type:"app.bsky.feed.defs#threadViewPost",post:se(e,t,d),...l?{parent:l}:{},replies:p(d,n)}})}function Oe(e,t){let r={jobId:e.jobId,did:e.did};if(e.failure)return{...r,state:"JOB_STATE_FAILED",error:e.failure.error,failureCode:e.failure.code,message:e.failure.error};let o=Math.max(0,t-e.created_ms),n=Math.floor(o/Be);return n<yt.length?{...r,state:yt[n],progress:Math.floor(o%Be/Be*100)}:{...r,state:"JOB_STATE_COMPLETED",progress:100,blob:{$type:"blob",ref:{$link:_e(e.sha256)},mimeType:"video/mp4",size:e.size}}}async function Fr(e,t,r,o){let n=De(e);if(n===void 0)return ve();if(typeof n!="string")return n;let i=await $r(n,e.root);if(!i)return j("poorly formatted jwt","BadJwt");let s=i.header.typ;if(s==="at+jwt"||s==="refresh+jwt"||s==="dpop+jwt")return j(`Invalid jwt type "${String(s)}"`,"BadJwtType");if(typeof i.claims.exp!="number"||i.claims.exp*1e3<=T(e))return j("jwt expired","JwtExpired");if(!o(String(i.claims.aud)))return j("jwt audience does not match service did","BadJwtAudience");if(i.claims.lxm!==r)return j(i.claims.lxm!==void 0?`bad jwt lexicon method ("lxm"). must match: ${r}`:`missing jwt lexicon method ("lxm"). must match: ${r}`,"BadJwtLexiconMethod");let a=String(i.claims.iss);return/^did:[a-z]+:\S+$/.test(a)?P(t,a)?i.signed?{did:a}:j("jwt signature does not match jwt issuer","BadJwtSignature"):j("could not resolve iss did"):j("jwt iss is not a valid did","BadJwtIss")}function an(e){let{host:t,hostname:r}=new URL(xt(e));return o=>o===`did:web:${r}`||o===`did:web:${t}`||o===`did:web:${t.replace(":","%3A")}`}async function dn(e,t,r){let o=await Fr(e,t,"com.atproto.repo.uploadBlob",an(e));if(D(o))return o;let n=r.searchParams.get("did");if(n===null)return y('Params must have the property "did"');if(n!==o.did)return j("jwt issuer does not match the did the upload names","BadJwtIss");let i=(wt(e.headers,"content-type")??"").split(";")[0].trim().toLowerCase();if(i!=="video/mp4")return C(415,"UnsupportedMediaType",`Wrong request encoding (Content-Type): ${i||"(none)"}; the video service takes video/mp4`);let s=e.bytes??new Uint8Array;if(s.length===0)return y("Request body is empty");if(s.length>Pr)return C(413,"PayloadTooLarge","request entity too large");let a=await dt(s,e.root),d=await fr(n,a.sha256,e.root);if(d)return{status:409,body:{error:"already_exists",message:"Video already processed",...Oe(d,T(e))},headers:{"content-type":"application/json; charset=utf-8"}};let p=mt(s),c=p?p.durationMs>Rr?{code:"validation_failure",error:`Video is ${Math.round(p.durationMs/1e3)}s long; videos can be up to ${Rr/6e4} minutes.`}:void 0:{code:"validation_failure",error:"The file is not an MP4 with a video track."},h={jobId:[...crypto.getRandomValues(new Uint8Array(12))].map(f=>f.toString(36).padStart(2,"0")).join("").slice(0,20),did:n,...r.searchParams.get("name")?{name:r.searchParams.get("name")}:{},sha256:a.sha256,size:s.length,created_ms:T(e),...p?{width:p.width,height:p.height,duration_ms:p.durationMs}:{},...c?{failure:c}:{}};return await ur(h,e.root),c||await lt(n,{cid:a.cid,sha256:a.sha256,mimeType:"video/mp4",size:s.length,available_ms:h.created_ms+yt.length*Be,width:p.width,height:p.height,duration_ms:p.durationMs},e.root),A({...Oe(h,T(e)),state:c?"JOB_STATE_FAILED":"JOB_STATE_CREATED"})}async function cn(e,t){let r=t.searchParams.get("jobId");if(r===null)return y('Params must have the property "jobId"');let o=await ut(r,e.root);return o?A({jobStatus:Oe(o,T(e))}):y(`Job not found: ${r}`,"NotFound")}async function pn(e,t){let r=await Fr(e,t,"app.bsky.video.getUploadLimits",d=>d===Ir);if(D(r))return r;if(!P(t,r.did).emailConfirmed)return A({canUpload:!1,message:"You must verify your email before you can upload a video."});let n=T(e)-864e5,i=(await hr(e.root)).filter(d=>d.did===r.did&&d.created_ms>n&&d.created_ms<=T(e)),s=Math.max(0,Oo-i.length),a=Math.max(0,No-i.reduce((d,p)=>d+p.size,0));return A({canUpload:s>0&&a>0,remainingDailyVideos:s,remainingDailyBytes:a})}async function ln(e,t,r,o){if(e.method!=="POST")return Se();if(r==="/_twin/accounts"){let n=o.handle;if(typeof n!="string"||!rt.test(n))return y("handle must be a valid handle (e.g. volter.bsky.social)","InvalidHandle");let i=o.did===void 0?nr():o.did;if(typeof i!="string"||!ir.test(i))return y("did must be a did:plc or did:web","InvalidDid");if(ye(t).some(a=>a.did!==i&&a.handle.toLowerCase()===n.toLowerCase()))return y(`Handle already taken: ${n}`,"HandleNotAvailable");if(o.email!==void 0&&(typeof o.email!="string"||!/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(o.email)))return y("email must be an email address","InvalidEmail");if(o.password!==void 0&&(typeof o.password!="string"||o.password.length<8))return y("password must be at least 8 characters","InvalidPassword");if(o.emailConfirmed!==void 0&&typeof o.emailConfirmed!="boolean")return y("emailConfirmed must be a boolean");if(o.createdAt!==void 0&&(typeof o.createdAt!="string"||!Ne.test(o.createdAt)))return y("createdAt must be a datetime");let s={handle:n,...o.email!==void 0?{email:o.email}:{},emailConfirmed:o.emailConfirmed??!0,createdAt:o.createdAt??N(e),_deleted:!1};return await ee(M,{operation:"bluesky.twin.seed_account",subjectType:"account",subjectId:i,fields:s,occurredAt:N(e)},e.root),o.password!==void 0&&await ee(M,{operation:"bluesky.twin.seed_account_password",subjectType:"_account_password",subjectId:i,fields:{passwordSha256:await ue(o.password)},occurredAt:N(e)},e.root),A({did:i,handle:n,...o.email!==void 0?{email:o.email}:{},emailConfirmed:s.emailConfirmed,createdAt:s.createdAt})}if(r==="/_twin/appPasswords"){let n=P(t,o.account);return n?typeof o.name!="string"||o.name.trim()===""||o.name.length>32?y("name must be 1 to 32 characters"):typeof o.password!="string"||!/^[a-z2-7]{4}-[a-z2-7]{4}-[a-z2-7]{4}-[a-z2-7]{4}$/.test(o.password)?y("password must be an app password (xxxx-xxxx-xxxx-xxxx of a-z and 2-7)"):(await ee(M,{operation:"bluesky.twin.seed_app_password",subjectType:"_app_password",subjectId:`${n.did}|${o.name}`,fields:{did:n.did,name:o.name,passwordSha256:await ue(o.password),createdAt:N(e),privileged:!1,_deleted:!1},occurredAt:N(e)},e.root),A({name:o.name,createdAt:N(e),privileged:!1})):y(`account must be a seeded handle or DID (got ${String(o.account)})`)}if(r==="/_twin/tokens"){let n=P(t,o.account);return n?typeof o.token!="string"||!/^[A-Za-z0-9._~-]{8,512}$/.test(o.token)?y("token must be 8-512 characters of A-Z a-z 0-9 . _ ~ -"):(await ee(M,{operation:"bluesky.twin.seed_token",subjectType:"_token",subjectId:await ue(o.token),fields:{did:n.did},occurredAt:N(e)},e.root),A({did:n.did})):y(`account must be a seeded handle or DID (got ${String(o.account)})`)}return Se()}var Jr=["com.atproto.identity.resolveHandle","com.atproto.server.getSession","com.atproto.server.getServiceAuth","com.atproto.repo.getRecord","com.atproto.repo.listRecords","app.bsky.actor.getProfile","app.bsky.feed.getAuthorFeed","app.bsky.feed.getPostThread"],Hr=["com.atproto.server.createSession","com.atproto.server.refreshSession","com.atproto.repo.createRecord","com.atproto.repo.putRecord","com.atproto.repo.deleteRecord","com.atproto.repo.uploadBlob"];async function ae(e){let t=new URL(e.path,"http://twin.local"),r=t.pathname.replace(/\/+$/,"")||"/",o=e.method.toUpperCase(),n=/^\/video\.bsky\.app\/xrpc\/(app\.bsky\.video\.[A-Za-z]+)$/.exec(r);if(n){let h=ie(e.root),f=n[1];return f==="app.bsky.video.uploadVideo"&&o==="POST"?e.readOnly?Ae():dn(e,h,t):f==="app.bsky.video.getJobStatus"&&o==="GET"?cn(e,t):f==="app.bsky.video.getUploadLimits"&&o==="GET"?pn(e,h):pe()}if(r.startsWith("/_twin/")){if(e.readOnly)return Ae();let h=_r(e.body);return"malformed"in h?y("Request body must be a JSON object"):ln(e,ie(e.root),r,h.object)}let i=/^\/xrpc\/([a-zA-Z0-9.-]+)$/.exec(r);if(!i)return Se();let s=i[1],a=ie(e.root),d=Jr.includes(s),p=Hr.includes(s);if(d&&o!=="GET"&&o!=="HEAD"||p&&o!=="POST")return y(`Incorrect HTTP method (${o}) expected ${d?"GET":"POST"}`,"InvalidRequest");if(!d&&!p)return s.startsWith("app.bsky.video.")?pe():s.startsWith("com.atproto.")||s.startsWith("app.bsky.")||s.startsWith("chat.bsky.")||s.startsWith("tools.ozone.")?E(`XRPC ${s}`):pe();if(p&&e.readOnly)return Ae();let c={};if(p&&s!=="com.atproto.repo.uploadBlob"){let h=_r(e.body);if("malformed"in h)return y("Request body must be a JSON object");c=h.object}switch(s){case"com.atproto.server.createSession":return Lo(e,a,c);case"com.atproto.server.refreshSession":return zo(e,a);case"com.atproto.repo.getRecord":return Qo(a,t,e.root);case"com.atproto.repo.listRecords":return qo(a,t);case"com.atproto.identity.resolveHandle":{let h=t.searchParams.get("handle");if(h===null)return y('Params must have the property "handle"');let f=rt.test(h)?ye(a).find(u=>u.handle.toLowerCase()===h.toLowerCase()):void 0;return f?A({did:f.did}):y("Unable to resolve handle")}case"app.bsky.actor.getProfile":case"app.bsky.feed.getAuthorFeed":case"app.bsky.feed.getPostThread":{let h=await Mo(e,a);if(h!==null&&D(h))return h;if(s==="app.bsky.feed.getAuthorFeed")return nn(e,a,t);if(s==="app.bsky.feed.getPostThread")return sn(e,a,t);let f=t.searchParams.get("actor");if(f===null)return y('Params must have the property "actor"');let u=P(a,f);return u?A(rn(e,a,u)):y("Profile not found")}default:break}let l=await Br(e,a);if(D(l))return l;switch(s){case"com.atproto.server.getSession":return Fo(e,a,l);case"com.atproto.server.getServiceAuth":return Jo(e,l,t);case"com.atproto.repo.createRecord":return Ko(e,a,l,c);case"com.atproto.repo.putRecord":return Yo(e,a,l,c);case"com.atproto.repo.deleteRecord":return Zo(e,a,l,c);case"com.atproto.repo.uploadBlob":return en(e,l);default:return pe()}}import{filePathOf as ii,bundleClient as si,fileResponse as ai,ownFields as di,serveHttp as ci,twinResources as pi}from"../../engine/v2/volter_world-core.mjs";var Wr=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"];function Rt(e,t){let r=typeof e=="string"?Date.parse(e):typeof e=="number"?e:NaN;if(!Number.isFinite(r))return"";let o=Math.max(0,Math.floor((t-r)/1e3));if(o<60)return`${o}s`;if(o<3600)return`${Math.floor(o/60)}m`;if(o<86400)return`${Math.floor(o/3600)}h`;if(o<30*86400)return`${Math.floor(o/86400)}d`;let n=new Date(r),i=new Date(t);return`${Wr[n.getUTCMonth()]} ${n.getUTCDate()}${n.getUTCFullYear()===i.getUTCFullYear()?"":`, ${n.getUTCFullYear()}`}`}function _t(e){let t=typeof e=="string"?Date.parse(e):NaN;if(!Number.isFinite(t))return"";let r=new Date(t),o=r.getUTCHours(),n=String(r.getUTCMinutes()).padStart(2,"0");return`${Wr[r.getUTCMonth()]} ${r.getUTCDate()}, ${r.getUTCFullYear()} at ${(o+11)%12+1}:${n} ${o<12?"AM":"PM"}`}function Le(e){let t=typeof e=="number"&&Number.isFinite(e)?e:0;if(t<1e3)return String(t);let[r,o]=t<1e6?[1e3,"K"]:[1e6,"M"],n=t/r;return`${(n<10?(Math.floor(n*10)/10).toString():String(Math.floor(n))).replace(/\.0$/,"")}${o}`}function Tt(e,t){let r=typeof e=="string"?e:"",o=new TextEncoder().encode(r),n=new TextDecoder,i=(Array.isArray(t)?t:[]).filter(d=>Number.isInteger(d?.index?.byteStart)&&Number.isInteger(d?.index?.byteEnd)&&d.index.byteStart<d.index.byteEnd&&d.index.byteEnd<=o.length).sort((d,p)=>d.index.byteStart-p.index.byteStart),s=[],a=0;for(let d of i){if(d.index.byteStart<a)continue;d.index.byteStart>a&&s.push({kind:"text",text:n.decode(o.subarray(a,d.index.byteStart))});let p=n.decode(o.subarray(d.index.byteStart,d.index.byteEnd)),c=Array.isArray(d.features)?d.features[0]:void 0;c?.$type==="app.bsky.richtext.facet#link"?s.push({kind:"link",text:p,href:String(c.uri)}):c?.$type==="app.bsky.richtext.facet#mention"?s.push({kind:"mention",text:p,href:Vr(String(c.did))}):c?.$type==="app.bsky.richtext.facet#tag"?s.push({kind:"tag",text:p}):s.push({kind:"text",text:p}),a=d.index.byteEnd}return a<o.length&&s.push({kind:"text",text:n.decode(o.subarray(a))}),s}function Vr(e){return`#/profile/${encodeURIComponent(e)}`}var Pt="^/profile/[^/]+/?$|^/profile/[^/]+/post/[A-Za-z0-9._:~-]{1,512}/?$",un=/^\/bsky\.app\/profile\/([^/]+)(?:\/post\/([A-Za-z0-9._:~-]{1,512}))?\/?$/,fn="https://bsky.social",g=e=>String(e??"").replace(/[&<>"']/g,t=>({"&":"&","<":"<",">":">",'"':""","'":"'"})[t]);async function It(e,t,r){let o=await ae({method:"GET",path:`/xrpc/${e}?${new URLSearchParams(t)}`,...r!==void 0?{root:r}:{}});return{status:o.status,body:o.body??{}}}async function Ct(e,t,r){if(e.method!=="GET"&&e.method!=="HEAD")return null;let o=un.exec(t);if(!o)return null;let n;try{n=decodeURIComponent(o[1])}catch{return null}let i=o[2]?await hn(n,o[2],r):await mn(n,r);return new Response(e.method==="HEAD"?null:i.html,{status:i.status,headers:{"content-type":"text/html; charset=utf-8"}})}async function hn(e,t,r){let o=await It("app.bsky.feed.getPostThread",{uri:`at://${e}/app.bsky.feed.post/${t}`,depth:"1",parentHeight:"0"},r.root),n=o.status===200?o.body.thread?.post:void 0;if(!n)return Gr("Post not found","The post may have been deleted.");let i=n.author,s=jt("Post")+`<article class="thread-anchor" data-post-uri="${g(n.uri)}"><div class="anchor-author"><a href="/profile/${g(i.handle)}">${Ot(i,42)}</a><div class="anchor-names"><a class="name" href="/profile/${g(i.handle)}">${g(i.displayName||i.handle)}</a><div class="handle">@${g(i.handle)}</div></div></div>`+Yr(n.record?.text,n.record?.facets,!0)+Zr(n)+`<div class="anchor-time"><time datetime="${g(n.record?.createdAt??n.indexedAt)}">${g(_t(n.record?.createdAt??n.indexedAt))}</time></div>`+Xr(n,!0)+"</article>";return{status:200,html:Nt(`${String(i.displayName||i.handle)}: "${String(n.record?.text??"")}" \u2014 Bluesky`,s)}}async function mn(e,t){let r=await It("app.bsky.actor.getProfile",{actor:e},t.root);if(r.status!==200)return Gr("Profile not found","This account may not exist.");let o=r.body,n=await It("app.bsky.feed.getAuthorFeed",{actor:String(o.did),filter:"posts_and_author_threads",limit:"50"},t.root),i=n.status===200&&Array.isArray(n.body.feed)?n.body.feed:[],s=d=>Le(d),a=jt(String(o.displayName||o.handle),`${s(o.postsCount)} ${o.postsCount===1?"post":"posts"}`)+`<div class="profile-header" data-did="${g(o.did)}"><div class="banner"${o.banner?` style="background-image:url("${g(o.banner)}")"`:""}></div><div class="profile-top"><div class="profile-avatar">${Ot(o,90)}</div></div><div class="profile-names"><h1 class="display-name">${g(o.displayName||o.handle)}</h1><div class="profile-handle">@${g(o.handle)}</div></div><div class="profile-counts"><span><b>${s(o.followersCount)}</b> ${o.followersCount===1?"follower":"followers"}</span><span><b>${s(o.followsCount)}</b> following</span><span><b>${s(o.postsCount)}</b> ${o.postsCount===1?"post":"posts"}</span></div>`+(o.description?`<div class="profile-bio">${g(o.description)}</div>`:"")+`<nav class="tabs"><span class="tab active">Posts</span><span class="tab">Replies</span><span class="tab">Media</span><span class="tab">Videos</span></nav></div><div class="feed">${i.length===0?'<div class="empty">No posts yet.</div>':i.map(d=>bn(d,t.nowMs)).join("")}</div>`;return{status:200,html:Nt(`${String(o.displayName||o.handle)} (@${String(o.handle)}) \u2014 Bluesky`,a)}}function Gr(e,t){return{status:200,html:Nt(`${e} \u2014 Bluesky`,jt("")+`<div class="notice"><div class="notice-title">${g(e)}</div><div class="muted">${g(t)}</div></div>`)}}var Bt=(e,t=18)=>`<svg viewBox="0 0 24 24" width="${t}" height="${t}" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="${e}"/></svg>`,yn='<svg viewBox="0 0 64 57" width="34" height="30" aria-label="Bluesky"><path fill="#1185fe" d="M13.873 3.805C21.21 9.332 29.103 20.537 32 26.55v15.882c0-.338-.13.044-.41.867-1.512 4.456-7.418 21.847-20.923 7.944-7.111-7.32-3.819-14.64 9.125-16.85-7.405 1.264-15.73-.825-18.014-9.015C1.12 23.022 0 8.51 0 6.55 0-3.268 8.579-.182 13.873 3.805ZM50.127 3.805C42.79 9.332 34.897 20.537 32 26.55v15.882c0-.338.13.044.41.867 1.512 4.456 7.418 21.847 20.923 7.944 7.111-7.32 3.819-14.64-9.125-16.85 7.405 1.264 15.73-.825 18.014-9.015C62.88 23.022 64 8.51 64 6.55c0-9.818-8.578-6.732-13.873-2.745Z"/></svg>';function jt(e,t=""){return`<header class="center-header"><button type="button" class="back" onclick="history.back()" aria-label="Back">${Bt("M19 12H5M12 19l-7-7 7-7",22)}</button><div><div class="header-title">${g(e)}</div>${t?`<div class="header-sub">${g(t)}</div>`:""}</div></header>`}function Ot(e,t){return e.avatar?`<img class="avatar" src="${g(e.avatar)}" alt="${g(e.displayName??e.handle)}" width="${t}" height="${t}">`:`<span class="avatar avatar-default" style="width:${t}px;height:${t}px">${Bt("M20 21a8 8 0 0 0-16 0M12 13a5 5 0 1 0 0-10 5 5 0 0 0 0 10z",Math.round(t*.55))}</span>`}function Kr(e){if(typeof e=="string")try{let t=new URL(e);return t.protocol==="http:"||t.protocol==="https:"?t.href:void 0}catch{return}}function Yr(e,t,r){let o=Tt(e,t).map(n=>{if(n.kind==="text"||n.href===void 0)return n.kind==="text"?g(n.text):`<span class="facet facet-${n.kind}">${g(n.text)}</span>`;let i=n.kind==="link"?Kr(n.href):n.href.startsWith("#/")?n.href.slice(1):void 0;return i===void 0?`<span class="facet facet-${n.kind}">${g(n.text)}</span>`:`<a class="facet facet-${n.kind}" href="${g(i)}"${n.kind==="link"?' target="_blank" rel="noreferrer"':""}>${g(n.text)}</a>`});return`<div class="${r?"post-text big":"post-text"}">${o.join("")}</div>`}function Zr(e){let t=e.embed;if(!t)return"";if(t.$type==="app.bsky.embed.video#view"){let r=String(e.author?.did??""),o=t.aspectRatio?`${t.aspectRatio.width} / ${t.aspectRatio.height}`:"16 / 9",n=`${fn}/xrpc/com.atproto.sync.getBlob?did=${encodeURIComponent(r)}&cid=${encodeURIComponent(String(t.cid))}`;return`<div class="embed video-embed" style="aspect-ratio:${o}"><video class="video" controls playsinline preload="metadata" poster="${g(t.thumbnail)}" src="${g(n)}" aria-label="${g(t.alt??"Video")}" data-cid="${g(t.cid)}"></video></div>`}if(t.$type==="app.bsky.embed.images#view"){let r=t.images??[];return`<div class="embed images images-${r.length}">${r.map(o=>`<img src="${g(o.thumb)}" alt="${g(o.alt??"")}"${r.length===1&&o.aspectRatio?` style="aspect-ratio:${o.aspectRatio.width} / ${o.aspectRatio.height}"`:""}>`).join("")}</div>`}if(t.$type==="app.bsky.embed.external#view"){let r=t.external??{},o="";try{o=new URL(String(r.uri)).host.replace(/^www\./,"")}catch{}let n=`${r.thumb?`<img src="${g(r.thumb)}" alt="">`:""}<div class="external-meta"><div class="external-title">${g(r.title)}</div><div class="external-desc">${g(r.description)}</div><div class="external-host">${g(o)}</div></div>`,i=Kr(r.uri);return i?`<a class="embed external" href="${g(i)}" target="_blank" rel="noreferrer">${n}</a>`:`<div class="embed external">${n}</div>`}return""}function Xr(e,t){let r=n=>typeof n=="number"&&n>0?Le(n):"",o=(n,i="")=>`<span class="action">${Bt(n,t?22:18)}<span>${i}</span></span>`;return`<div class="${t?"actions big":"actions"}">`+o("M21 11.5a8.4 8.4 0 0 1-8.5 8.5 8.4 8.4 0 0 1-3.8-.9L3 21l1.9-5.7A8.4 8.4 0 0 1 4 11.5 8.5 8.5 0 0 1 12.5 3 8.4 8.4 0 0 1 21 11.5z",r(e.replyCount))+o("M17 2l4 4-4 4M3 11v-1a4 4 0 0 1 4-4h14M7 22l-4-4 4-4M21 13v1a4 4 0 0 1-4 4H3",r(e.repostCount))+o("M19 14c1.5-1.5 3-3.2 3-5.5A5.5 5.5 0 0 0 16.5 3c-1.8 0-3 .5-4.5 2-1.5-1.5-2.7-2-4.5-2A5.5 5.5 0 0 0 2 8.5c0 2.3 1.5 4 3 5.5l7 7z",r(e.likeCount))+o("M12 3v13M7 8l5-5 5 5M5 13v6a2 2 0 0 0 2 2h10a2 2 0 0 0 2-2v-6")+"</div>"}function bn(e,t){let r=e.post,o=r.author,n=`/profile/${g(o.handle)}/post/${g(String(r.uri).split("/").pop())}`,i=e.reply?.parent;return`<article class="feed-item" data-post-uri="${g(r.uri)}"><a class="feed-item-link" href="${n}" aria-label="Open thread"></a><a href="/profile/${g(o.handle)}" class="feed-avatar">${Ot(o,42)}</a><div class="feed-body"><div class="post-meta"><a class="name" href="/profile/${g(o.handle)}">${g(o.displayName||o.handle)}</a><span class="handle">@${g(o.handle)}</span><span class="dot">\xB7</span><a class="age" href="${n}" title="${g(_t(r.indexedAt))}">${g(Rt(r.record?.createdAt??r.indexedAt,t))}</a></div>`+(i&&i.author?`<div class="reply-to">Reply to ${g(i.author.displayName||i.author.handle)}</div>`:"")+Yr(r.record?.text,r.record?.facets,!1)+Zr(r)+Xr(r,!1)+"</div></article>"}function Nt(e,t){return`<!doctype html>
|
|
3
|
+
<html lang="en"><head><meta charset="utf-8"><meta name="viewport" content="width=device-width,initial-scale=1"><title>${g(e)}</title><style>${gn}</style></head>
|
|
4
|
+
<body><div class="shell"><aside class="left-nav"><a class="nav-logo" href="/">${yn}</a></aside><main class="center">${t}</main><aside class="right-col"></aside></div></body></html>`}var gn=`
|
|
5
|
+
*{box-sizing:border-box}
|
|
6
|
+
html,body{margin:0;background:#fff;color:#0b0f14;font-family:InterVariable,Inter,-apple-system,BlinkMacSystemFont,"Segoe UI",Roboto,Helvetica,Arial,sans-serif;font-size:15px;-webkit-font-smoothing:antialiased}
|
|
7
|
+
a{color:inherit;text-decoration:none}
|
|
8
|
+
.shell{display:grid;grid-template-columns:1fr minmax(0,600px) 1fr;min-height:100vh}
|
|
9
|
+
.left-nav{justify-self:end;padding:16px 20px 16px 0}.nav-logo{padding:6px 12px 10px;display:inline-flex}
|
|
10
|
+
.center{border-left:1px solid #d4dbe2;border-right:1px solid #d4dbe2;min-height:100vh;min-width:0}
|
|
11
|
+
.center-header{position:sticky;top:0;z-index:2;background:rgba(255,255,255,.96);display:flex;align-items:center;gap:14px;height:54px;padding:0 16px;border-bottom:1px solid #d4dbe2}
|
|
12
|
+
.header-title{font-weight:700;font-size:19px}.header-sub{color:#6f869f;font-size:13px}.back{display:inline-flex;border:0;background:none;color:inherit;cursor:pointer;padding:0}
|
|
13
|
+
.avatar{border-radius:50%;object-fit:cover;display:inline-flex;background:#fff;flex:none}.avatar-default{align-items:center;justify-content:center;color:#fff;background:#1185fe}
|
|
14
|
+
.banner{height:150px;background:#1185fe center/cover no-repeat}
|
|
15
|
+
.profile-header{border-bottom:1px solid #d4dbe2}.profile-top{position:relative;height:52px}.profile-avatar{position:absolute;left:12px;top:-46px;border:2px solid #fff;border-radius:50%;display:inline-flex;background:#fff}
|
|
16
|
+
.profile-names{padding:4px 16px 0}.display-name{font-size:28px;font-weight:700;margin:0;line-height:1.2}.profile-handle{color:#6f869f;margin-top:2px}
|
|
17
|
+
.profile-counts{display:flex;gap:12px;padding:10px 16px 0;color:#6f869f}.profile-counts b{color:#0b0f14;font-weight:600}
|
|
18
|
+
.profile-bio{padding:10px 16px 0;white-space:pre-wrap;line-height:20px}
|
|
19
|
+
.tabs{display:flex;gap:20px;padding:12px 16px 0;color:#6f869f;font-weight:600}.tab{padding-bottom:10px}.tab.active{color:#0b0f14;box-shadow:inset 0 -3px 0 #1185fe}
|
|
20
|
+
.feed-item{position:relative;display:flex;gap:10px;padding:12px 16px 6px;border-bottom:1px solid #d4dbe2}.feed-item-link{position:absolute;inset:0;z-index:0}
|
|
21
|
+
.feed-avatar,.feed-body a,.feed-body video,.feed-body .embed{position:relative;z-index:1}.feed-body{flex:1;min-width:0}
|
|
22
|
+
.post-meta{display:flex;gap:4px;align-items:baseline;white-space:nowrap;overflow:hidden}.name{font-weight:600}.handle,.dot,.age,.reply-to,.muted{color:#6f869f}
|
|
23
|
+
.post-text{white-space:pre-wrap;overflow-wrap:anywhere;line-height:20px;margin-top:2px}.post-text.big{font-size:18px;line-height:25px;margin-top:10px}.facet{color:#1185fe}
|
|
24
|
+
.embed{display:block;margin-top:8px;border-radius:8px;overflow:hidden}.video-embed{background:#000;border:1px solid #d4dbe2;max-height:512px}.video{width:100%;height:100%;display:block;object-fit:contain;background:#000}
|
|
25
|
+
.images img{width:100%;display:block;object-fit:cover;border-radius:8px;border:1px solid #d4dbe2}.images-2,.images-3,.images-4{display:grid;grid-template-columns:1fr 1fr;gap:4px}
|
|
26
|
+
.external{border:1px solid #d4dbe2}.external img{width:100%;aspect-ratio:1.91/1;object-fit:cover;display:block}.external-meta{padding:10px 12px}.external-title{font-weight:600}.external-desc{color:#42576c;font-size:14px;margin-top:2px}.external-host{color:#6f869f;font-size:13px;margin-top:8px;border-top:1px solid #d4dbe2;padding-top:6px}
|
|
27
|
+
.actions{display:flex;justify-content:space-between;max-width:460px;color:#6f869f;padding:8px 0 4px;position:relative;z-index:1}.actions.big{max-width:none;padding:10px 4px;border-top:1px solid #d4dbe2;margin-top:12px}.action{display:inline-flex;gap:4px;align-items:center}
|
|
28
|
+
.thread-anchor{padding:12px 16px 4px;border-bottom:1px solid #d4dbe2}.anchor-author{display:flex;gap:10px;align-items:center}.anchor-names .handle{display:block}.anchor-time{color:#6f869f;padding:12px 0 0}
|
|
29
|
+
.empty{padding:32px 16px;color:#6f869f;text-align:center}.notice{padding:48px 32px;text-align:center}.notice-title{font-size:22px;font-weight:700;margin-bottom:8px}
|
|
30
|
+
`;import{createTwinFetchFromHandler as wn,runWithCorrelationId as xn,serveHttp as ki,statefulTwinManifest as kn,twinPublicBase as Qr,worldNow as Dt}from"../../engine/v2/volter_world-core.mjs";var ze=8*1024*1024,$n=new Set(["video.bsky.app","cdn.bsky.app","bsky.app"]),vn=new Set(["/xrpc/com.atproto.repo.uploadBlob","/video.bsky.app/xrpc/app.bsky.video.uploadVideo"]),Sn=/^\/cdn\.bsky\.app\/img\/(avatar|avatar_thumbnail|banner|feed_thumbnail|feed_fullsize)\/plain\/(did:[a-z]+:[A-Za-z0-9._:%-]+)\/(b[a-z2-7]{58})@(jpeg|png|webp)$/,An=/^\/video\.bsky\.app\/watch\/([^/]+)\/(b[a-z2-7]{58})\/(thumbnail\.jpg|playlist\.m3u8)$/,ge=(e,t,r)=>Response.json({error:t,message:r},{status:e});function Rn(e,t,r,o){if(r-t+1<=ze)return ct(e,t,r,o).then(i=>i===null?null:new Blob([new Uint8Array(i)]));let n=t;return new ReadableStream({async pull(i){if(n>r){i.close();return}let s=await ct(e,n,Math.min(r,n+ze-1),o);if(s===null||s.length===0){i.error(new Error("the stored bytes went away mid-read"));return}n+=s.length,i.enqueue(new Uint8Array(s))}})}async function qr(e,t,r,o,n){let i=await sr(t,n);if(i===null)return null;let s={"content-type":r,"accept-ranges":"bytes",...o},a=0,d=i-1,p=/^bytes=(\d*)-(\d*)$/.exec((e.headers.get("range")??"").trim());if(p&&(p[1]!==""||p[2]!=="")&&(p[1]===""?a=Math.max(0,i-Number(p[2])):(a=Number(p[1]),d=p[2]===""?Math.min(i-1,a+ze-1):Math.min(Number(p[2]),i-1)),a>=i||a>d))return new Response(null,{status:416,headers:{...s,"content-range":`bytes */${i}`}});let c=a!==0||d!==i-1,l={...s,"content-length":String(d-a+1),...c?{"content-range":`bytes ${a}-${d}/${i}`}:{}};if(e.method==="HEAD")return new Response(null,{status:c?206:200,headers:l});let h=await Rn(t,a,d,n);return h===null?null:new Response(h,{status:c?206:200,headers:l})}function _n(e,t){let o=(e.headers.get("x-volter-twin-original-host")??e.headers.get("host")??"").replace(/:\d+$/,"").toLowerCase();return $n.has(o)&&!t.pathname.startsWith(`/${o}/`)?`/${o}${t.pathname}`:t.pathname}function Et(e={}){let t=wn(ae,{...e,extras:n=>({publicBase:Qr(n)}),manifest:kn({vendor:"bluesky",twinOf:"Bluesky (the account PDS over XRPC, the App View reads, the video service)",stores:"accounts, app passwords, posts, follows, profiles, uploaded blobs and video jobs"})}),r=async n=>{let i=await n,s=new Headers(i.headers);return s.set("date",new Date(Dt()).toUTCString()),new Response(i.body,{status:i.status,statusText:i.statusText,headers:s})};return async n=>r(o(n));async function o(n){let i=new URL(n.url),s=_n(n,i),a=n.method==="GET"||n.method==="HEAD",d=a&&s.startsWith("/bsky.app/")?await Ct(n,s,{...e.root!==void 0?{root:e.root}:{},nowMs:Date.parse(Dt())}):null;if(d)return d;if(a&&s==="/xrpc/com.atproto.sync.getBlob"){let l=i.searchParams.get("did"),h=i.searchParams.get("cid");if(l===null)return ge(400,"InvalidRequest",'Params must have the property "did"');if(h===null)return ge(400,"InvalidRequest",'Params must have the property "cid"');if(!Mr(l,e.root))return ge(400,"RepoNotFound",`Could not find repo for DID: ${l}`);let f=be(l,h,e.root);return(f?await qr(n,String(f.sha256),String(f.mimeType),{"x-content-type-options":"nosniff","content-disposition":`attachment; filename="${h}"`,"content-security-policy":"default-src 'none'; sandbox"},e.root):null)??ge(400,"InvalidRequest","Blob not found")}let p=a?Sn.exec(s):null;if(p){let l=be(decodeURIComponent(p[2]),p[3],e.root);return(l&&String(l.mimeType).startsWith("image/")?await qr(n,String(l.sha256),String(l.mimeType),{"cache-control":"public, max-age=604800"},e.root):null)??new Response("Not Found",{status:404})}let c=a?An.exec(s):null;if(c){let l=be(decodeURIComponent(c[1]),c[2],e.root);return!l||l.mimeType!=="video/mp4"?new Response("Not Found",{status:404}):c[3]==="playlist.m3u8"?ge(501,"MethodNotImplemented","[twin gap] the HLS playlist is real Bluesky surface this twin does not model (bluesky.video.hls_playlist); the file is served by com.atproto.sync.getBlob"):new Response(n.method==="HEAD"?null:Ar(Number(l.width??0),Number(l.height??0)),{headers:{"content-type":"image/svg+xml","cache-control":"public, max-age=604800"}})}if(n.method==="POST"&&vn.has(s)){let l=new Uint8Array(await n.arrayBuffer()),h={};n.headers.forEach(($,b)=>{h[b]=$});let f=()=>ae({method:n.method,path:s+(i.search||""),headers:h,bytes:l,readOnly:e.readOnly??!1,occurredAt:Dt(),publicBase:Qr(n),...e.root!==void 0?{root:e.root}:{}}),u=n.headers.get("x-twins-request-id")??void 0,m=await(u?xn(u,f):f());return new Response(JSON.stringify(m.body),{status:m.status,headers:{"content-type":"application/json; charset=utf-8",...m.headers}})}if(s!==i.pathname){let l=new URL(i);return l.pathname=s,t(new Request(l,n))}return t(n)}}import{assertBudgetGuardIntact as Pn,observeResource as Cn,ownFields as we,projectResources as We,RefusedWriteError as Ft}from"../../engine/v2/volter_world-core.mjs";import{declareRateBudget as Tn,rateBudgetPath as Si,rateBudgetWeight as En,RateBudget as In}from"../../engine/v2/volter_world-core.mjs";import{RateBudgetError as Lt}from"../../engine/v2/volter_world-core.mjs";var Ut="bluesky",eo=60*6e4,to=600,ro=30,oo=3600,te={create:3,update:2,delete:1,upload:2,read:1,other:2},Fe={windowMs:eo,ceiling:to,burstCeiling:ro,defaultWeight:te.other,maxRetryAfterSeconds:oo,rules:[{match:"^POST /xrpc/com\\.atproto\\.repo\\.createRecord$",weight:te.create},{match:"^POST /xrpc/com\\.atproto\\.repo\\.putRecord$",weight:te.update},{match:"^POST /xrpc/com\\.atproto\\.repo\\.deleteRecord$",weight:te.delete},{match:"^POST /xrpc/com\\.atproto\\.repo\\.uploadBlob$",weight:te.upload},{match:"^GET /xrpc/",weight:te.read}],reason:"Bluesky publishes 3000 API requests per 5 minutes per IP, createSession 30 per 5 minutes and 300 per day per account, and 5,000 repo-write points per hour / 35,000 per day (CREATE 3, UPDATE 2, DELETE 1), answering over-limit requests with 429 (docs.bsky.app rate-limits page, fetched 2026-09-27). The per-IP request figure is shared box-wide and far above one account's publishing, so it is not transcribed: this declaration stays at the kernel fallback's shape (600 weighted units per rolling hour, a 30-unit burst a minute) and prices writes by Bluesky's own points \u2014 create 3, update 2, delete 1 \u2014 an upload 2, a read 1, anything unnamed 2. The kernel's session exchange and the presigned video-service calls are not charged (bluesky-budget.ts says why)."};Tn(Ut,Fe);function Mt(e,t){let r=t.indexOf("?"),o={};if(r!==-1)for(let[i,s]of new URLSearchParams(t.slice(r+1)))o[i]=s;let n=r===-1?t:t.slice(0,r);return En(Ut,`${String(e).toUpperCase()} ${n}`,o)}var Y=class extends In{constructor(t={}){super({...t,vendor:Ut})}};var xe="bluesky",no="https://video.bsky.app",io=12e4,so=40;function ao(e){return Math.min(5e3,1e3*2**Math.max(0,e))}function Wt(e,t=new Y){let r=Pn(t,Y,"budgetedBlueskyExecute");return async o=>{if(o.presigned)return e(o);let n=Mt(o.method,o.path),i=r.checkBudget(n),s=await e(o);try{r.recordCall(n,Object.fromEntries(Object.entries(s.headers??{}).map(([a,d])=>[a.toLowerCase(),d])),{status:s.status,reservation:i})}catch(a){if(!(a instanceof Lt))throw a}return s}}async function U(e,t,r,o=[200]){let n=await e({...r,headers:{accept:"application/json",...r.headers??{}}});if(!o.includes(n.status))throw new Error(`bluesky refused ${t}: HTTP ${n.status} ${n.body.slice(0,300)}`);let i={};if(n.body.trim()!=="")try{i=JSON.parse(n.body)}catch{throw new Error(`bluesky answered ${t} with a body that is not JSON: ${n.body.slice(0,200)}`)}return{status:n.status,body:n.body,json:i,headers:n.headers??{}}}var co=e=>new Promise(t=>setTimeout(t,e));async function Vt(e){let t=await U(e,"getSession",{method:"GET",path:"/xrpc/com.atproto.server.getSession"}),{did:r,handle:o,didDoc:n}=t.json;if(typeof r!="string"||typeof o!="string")throw new Error(`bluesky answered getSession without a did and handle: ${t.body.slice(0,200)}`);let i=Array.isArray(n?.service)?n.service.find(d=>d.id==="#atproto_pds"||d.id===`${r}#atproto_pds`):void 0,s=typeof i?.serviceEndpoint=="string"?i.serviceEndpoint:void 0;if(!s)throw new Error(`bluesky answered getSession with no #atproto_pds endpoint in its DID document: ${t.body.slice(0,200)}`);let a=Date.parse(Object.entries(t.headers).find(([d])=>d.toLowerCase()==="date")?.[1]??"");return{did:r,handle:o,pds:s.replace(/\/+$/,""),vendorNowMs:Number.isFinite(a)?a:Date.now(),...typeof t.json.email=="string"?{email:t.json.email}:{},...typeof t.json.emailConfirmed=="boolean"?{emailConfirmed:t.json.emailConfirmed}:{}}}function po(e){let t=new URL(e);return t.protocol==="http:"&&["127.0.0.1","localhost","[::1]"].includes(t.hostname)?`${e}/video.bsky.app`:no}var Ve=class extends Error{jobId;retryable=!0;constructor(t,r,o){super(`video still processing at the vendor (job ${t}) after ${Math.round(r/1e3)}s and ${o} getJobStatus reads \u2014 the entry stays pending; the next deploy performs it again`),this.jobId=t,this.name="BlueskyVideoStillProcessingError"}};async function lo(e,t,r,o,n=co){let i=`did:web:${new URL(t.pds).host}`,s=Math.floor(t.vendorNowMs/1e3)+1800,a=await U(e,"getServiceAuth",{method:"GET",path:`/xrpc/com.atproto.server.getServiceAuth?aud=${encodeURIComponent(i)}&lxm=com.atproto.repo.uploadBlob&exp=${s}`}),d=a.json.token;if(typeof d!="string"||d==="")throw new Error(`bluesky answered getServiceAuth with no token: ${a.body.slice(0,120)}`);let p=po(t.pds),c=await U(e,"the video upload (uploadVideo)",{method:"POST",presigned:!0,path:`${p}/xrpc/app.bsky.video.uploadVideo?did=${encodeURIComponent(t.did)}&name=${encodeURIComponent(o)}`,headers:{authorization:`Bearer ${d}`,"content-type":"video/mp4"},body:r},[200,409]);if(c.status===409&&c.json.error!=="already_exists")throw new Error(`bluesky refused the video upload: HTTP 409 ${c.body.slice(0,200)}`);let l=c.json.jobStatus??c.json,h=l.jobId;if(typeof h!="string"||h==="")throw new Error(`bluesky answered the video upload with no jobId: ${c.body.slice(0,200)}`);let f=0;for(let u=0;;u+=1){if(l.state==="JOB_STATE_COMPLETED"){let b=l.blob;if(!b||typeof b.ref?.$link!="string")throw new Error(`bluesky completed video job ${h} with no blob`);return{$type:"blob",ref:{$link:b.ref.$link},mimeType:String(b.mimeType??"video/mp4"),size:Number(b.size)}}if(l.state==="JOB_STATE_FAILED")throw new Error(`bluesky failed to process video job ${h}: ${String(l.error??l.message??l.failureCode??"no reason given")}`);let m=ao(u);if(u>=so||f+m>io)throw new Ve(h,f,u);await n(m),f+=m,l=(await U(e,"the video job status (getJobStatus)",{method:"GET",presigned:!0,path:`${p}/xrpc/app.bsky.video.getJobStatus?jobId=${encodeURIComponent(h)}`})).json.jobStatus??{}}}async function Bn(e,t,r){let o=await U(e,"uploadBlob",{method:"POST",path:"/xrpc/com.atproto.repo.uploadBlob",headers:{"content-type":r},body:t}),n=o.json.blob;if(!n||typeof n.ref?.$link!="string")throw new Error(`bluesky answered uploadBlob with no blob ref: ${o.body.slice(0,200)}`);return n}function Jt(e,t){if(Array.isArray(e))return e.map(o=>Jt(o,t));if(typeof e!="object"||e===null)return e;let r=e;return r.$type==="blob"&&typeof r.ref?.$link=="string"&&t.has(r.ref.$link)?t.get(r.ref.$link):Object.fromEntries(Object.entries(r).map(([o,n])=>[o,Jt(n,t)]))}var ke=/^at:\/\/([^/]+)\/([^/]+)\/([^/]+)$/;async function jn(e,t,r,o,n,i){let s=new Map;for(let a of r){if(s.has(String(a.cid)))continue;let d=await ar(a.sha256,n);if(!d)throw new Error(`bluesky cannot perform ${o}: the bytes of blob ${String(a.cid)} are not on this twin's blob seam`);let p=a.mimeType==="video/mp4"&&String(a.field??"").endsWith("/embed/video")?await lo(e,t,d,`${String(a.cid).slice(-12)}.mp4`,i):await Bn(e,d,String(a.mimeType));s.set(String(a.cid),p)}return s}function uo(e,t){let r=We(xe,e).filter(n=>n.type==="account"&&we(n)._deleted!==!0).map(n=>({did:String(n.id),handle:String(we(n).handle??"").toLowerCase()})),o=r.find(n=>n.did===t.did)??r.find(n=>n.handle===t.handle.toLowerCase());if(o)return{local:o.did,vendor:t.did,others:new Set(r.map(n=>n.did).filter(n=>n!==o.did&&n!==t.did)),worldOnly:new Map}}async function Ht(e,t,r){if(!t.others.has(r))return!1;let o=t.worldOnly.get(r);if(o!==void 0)return o;let n=await e({method:"GET",path:`/xrpc/app.bsky.actor.getProfile?actor=${encodeURIComponent(r)}`,headers:{accept:"application/json"}});if(n.status!==200&&n.status!==400)throw new Error(`bluesky refused getProfile for ${r}: HTTP ${n.status} ${n.body.slice(0,200)}`);let i=!1;if(n.status===400){let s={};try{s=JSON.parse(n.body)}catch{}if(s.error==="AccountDeactivated"||s.error==="AccountTakedown")return t.worldOnly.set(r,!1),!1;if(s.message!=="Profile not found")throw new Error(`bluesky answered getProfile for ${r} with a refusal that does not say whether it exists: ${n.body.slice(0,200)}`);i=!0}return t.worldOnly.set(r,i),i}function $e(e,t,r){return t===r?e:typeof e=="string"?e===t?r:e.startsWith(`at://${t}/`)?`at://${r}/${e.slice(`at://${t}/`.length)}`:/^https?:\/\/\S+$/i.test(e)?e.replace(new RegExp(`${t.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}(?=[/?#]|$)`,"g"),r):e:Array.isArray(e)?e.map(o=>$e(o,t,r)):typeof e!="object"||e===null?e:Object.fromEntries(Object.entries(e).map(([o,n])=>[o,$e(n,t,r)]))}var On=e=>ke.exec(e)?.[1];async function zt(e,t,r,o,n,i){let s=On(o.uri);if(s&&await Ht(e,r,s)){if(i==="pin")return null;throw new Ft("bluesky.reply_target",`the post replies ${i==="root"?"in a thread rooted at":"to"} ${o.uri}, by an account only this World holds \u2014 a reply to it cannot be published`,n)}let a=String($e(t.resolve("post",o.uri),r.local,r.vendor)),d=ke.exec(a);if(!d)throw new Error(`bluesky cannot resolve the reply reference ${o.uri}`);let p=await U(e,`getRecord ${a}`,{method:"GET",path:`/xrpc/com.atproto.repo.getRecord?repo=${encodeURIComponent(d[1])}&collection=${encodeURIComponent(d[2])}&rkey=${encodeURIComponent(d[3])}`},[200,400]);if(p.status===400){if(p.json.error!=="RecordNotFound")throw new Error(`bluesky refused getRecord ${a}: ${p.body.slice(0,200)}`);if(i!=="reply")return null;throw new Ft("bluesky.reply_target",`the post replies to ${o.uri}, which is not at Bluesky (deleted, or never published) \u2014 the reply is not published`,n)}if(typeof p.json.cid!="string")throw new Error(`bluesky answered getRecord ${a} with no cid`);return{uri:a,cid:p.json.cid}}async function Gt(e,t,r){return fo(new Y(r.credential!==void 0?{token:r.credential}:r.root!==void 0?{root:r.root}:{}),e,t,r)}async function fo(e,t,r,o,n=co){let i=r.operation??"",s=r.subject?.id??"",a=v=>({externalId:o.resolve(r.subject?.type??"account",s),data:{performed:!1,reason:v}});if(i.startsWith("bluesky.twin."))return a(`${i} is the twin's own record \u2014 nothing at Bluesky to write`);if(!["bluesky.post.create","bluesky.post.delete","bluesky.follow.create","bluesky.follow.delete","bluesky.profile.put","bluesky.profile.delete"].includes(i))throw new Error(`bluesky cannot perform ${i||"this entry"} on ${s}: no Bluesky request expresses it`);let p=Wt(t,e),c=await Vt(p),l={...r.fields??{}},h=uo(o.root,c);if(!h)throw new Error(`bluesky cannot perform ${s}: this World holds no account for the root's @${c.handle} (${c.did}) \u2014 seed it (/_twin/accounts) under that DID or handle`);let f=String(l.did??(r.subject?.type==="profile"?s:""));if(f!==h.local&&f!==h.vendor){let v=We(xe,o.root).find(R=>R.type==="account"&&String(R.id)===f),S=v?we(v).email:void 0;if(c.email!==void 0&&typeof S=="string"&&S.toLowerCase()===c.email.toLowerCase())throw new Error(`bluesky cannot perform ${s}: it is by ${f}, which holds the root's email (${c.email}) but not its DID or handle @${c.handle} \u2014 re-seed ${f} with handle ${c.handle} (/_twin/accounts {"did": "${f}", "handle": "${c.handle}"}), first moving the handle off any other account that holds it`);return a(`${i} is by ${f||"an unknown author"}, not the root's account @${c.handle} \u2014 another account's record is the World's own and crosses nothing`)}let u=v=>$e(v,h.local,h.vendor);if(i.endsWith(".delete")){if(i==="bluesky.profile.delete")return await U(p,"deleteRecord (profile)",{method:"POST",path:"/xrpc/com.atproto.repo.deleteRecord",headers:{"content-type":"application/json"},body:JSON.stringify({repo:c.did,collection:"app.bsky.actor.profile",rkey:"self"})}),{externalId:`at://${c.did}/app.bsky.actor.profile/self`,data:{deleted:!0}};let v=i==="bluesky.post.delete"?"post":"follow",S=u(o.resolve(v,s)),R=ke.exec(S);if(!R||R[1]!==c.did)throw new Error(`bluesky cannot delete ${s}: it resolves to ${S}, outside the root's repo`);let J=await p({method:"GET",path:`/xrpc/com.atproto.repo.getRecord?repo=${encodeURIComponent(c.did)}&collection=${encodeURIComponent(R[2])}&rkey=${encodeURIComponent(R[3])}`,headers:{accept:"application/json"}});if(J.status===400&&/RecordNotFound/.test(J.body))return{externalId:S,data:{deleted:!0,absent:!0}};if(J.status!==200)throw new Error(`bluesky refused getRecord before the delete: HTTP ${J.status} ${J.body.slice(0,200)}`);let Ke=JSON.parse(J.body).value??{},Ye=u(l.record??{});if(!(Ke.createdAt===Ye.createdAt&&(v==="post"?Ke.text===Ye.text:Ke.subject===Ye.subject)))throw new Ft("bluesky.delete_target",`${S} holds a different record than the one this World deleted \u2014 it is not deleted`,r.id);return await U(p,`deleteRecord ${S}`,{method:"POST",path:"/xrpc/com.atproto.repo.deleteRecord",headers:{"content-type":"application/json"},body:JSON.stringify({repo:c.did,collection:R[2],rkey:R[3]})}),{externalId:S,data:{deleted:!0}}}let m=i==="bluesky.post.create"?"app.bsky.feed.post":i==="bluesky.follow.create"?"app.bsky.graph.follow":"app.bsky.actor.profile",$=i==="bluesky.profile.put"?void 0:typeof l.rkey=="string"?l.rkey:void 0,b=v=>m==="app.bsky.feed.post"?{url:`https://bsky.app/profile/${c.handle}/post/${v}`}:{},w=u(l.record??{});if($){let v=await p({method:"GET",path:`/xrpc/com.atproto.repo.getRecord?repo=${encodeURIComponent(c.did)}&collection=${m}&rkey=${encodeURIComponent($)}`,headers:{accept:"application/json"}});if(v.status===200){let S=JSON.parse(v.body);if(!(S.value?.createdAt===w.createdAt&&(m==="app.bsky.feed.post"?S.value?.text===w.text:S.value?.subject===w.subject)))throw new Error(`bluesky cannot perform ${s}: ${String(S.uri)} already holds a different record`);return{externalId:String(S.uri),...b($),data:{cid:S.cid,adopted:!0}}}if(!(v.status===400&&/RecordNotFound/.test(v.body)))throw new Error(`bluesky refused getRecord before the create: HTTP ${v.status} ${v.body.slice(0,200)}`)}if(i!=="bluesky.profile.put"){let v=We(xe,o.root).find(R=>R.type===r.subject?.type&&String(R.id)===s),S=v?we(v):void 0;if(S&&(S._deleted===!0||S.deleted===!0))return a(`${s} was deleted in the World before it was deployed \u2014 it never goes public`)}if(m==="app.bsky.graph.follow"&&await Ht(p,h,String(w.subject)))return a(`${s} follows ${String(w.subject)}, an account only this World holds`);let F=[];if(Array.isArray(w.facets)){let v=[];for(let S of w.facets){let R=Array.isArray(S.features)?S.features.find(J=>J?.$type==="app.bsky.richtext.facet#mention"):void 0;if(R&&await Ht(p,h,String(R.did))){F.push(String(R.did));continue}v.push(S)}w={...w,facets:v}}if(w.reply){let v=await zt(p,o,h,l.record.reply.parent,r.id,"reply"),S=await zt(p,o,h,l.record.reply.root,r.id,"root")??{uri:String(u(o.resolve("post",l.record.reply.root.uri))),cid:String(l.record.reply.root.cid)};w={...w,reply:{root:S,parent:v}}}let _=[];if(i==="bluesky.profile.put"&&w.pinnedPost?.uri){let v=await zt(p,o,h,l.record.pinnedPost,r.id,"pin");if(v)w={...w,pinnedPost:v};else{_.push(String(l.record.pinnedPost.uri));let{pinnedPost:S,...R}=w;w=R}}let Z=Array.isArray(l._blobs)?l._blobs:[],re=await jn(p,c,Z,s,o.root,n);if(w=Jt(w,re),i==="bluesky.profile.put"){let v=await U(p,"putRecord (profile)",{method:"POST",path:"/xrpc/com.atproto.repo.putRecord",headers:{"content-type":"application/json"},body:JSON.stringify({repo:c.did,collection:"app.bsky.actor.profile",rkey:"self",record:w})}),S=_.length>0?(()=>{let{pinnedPost:R,...J}=l.record??{};return J})():void 0;return{externalId:String(v.json.uri??`at://${c.did}/app.bsky.actor.profile/self`),url:`https://bsky.app/profile/${c.handle}`,data:{cid:v.json.cid,..._.length>0?{unpinned:_,record:S}:{}}}}let de=await U(p,`createRecord (${m})`,{method:"POST",path:"/xrpc/com.atproto.repo.createRecord",headers:{"content-type":"application/json"},body:JSON.stringify({repo:c.did,collection:m,...$?{rkey:$}:{},record:w})}),Ge=de.json.uri,Yt=typeof Ge=="string"?ke.exec(Ge):null;if(!Yt)throw new Error(`bluesky answered createRecord with no at:// uri: ${de.body.slice(0,200)}`);return{externalId:Ge,...b(Yt[3]),data:{cid:de.json.cid,...F.length>0?{droppedMentions:F}:{}}}}var Je=50,He=0;function Nn(){let e=Date.now();return He=e>He?e:He+1,new Date(He).toISOString()}async function Kt(e,t={}){let r=Wt(e,t.budget??new Y(t.credential!==void 0?{token:t.credential}:t.root!==void 0?{root:t.root}:{})),o=t.occurredAt??Nn(),n=(u,m,$)=>Cn(xe,{type:u,id:m,fields:$},{...t.root!==void 0?{root:t.root}:{},at:o}),i=await Vt(r),s=await U(r,"getProfile",{method:"GET",path:`/xrpc/app.bsky.actor.getProfile?actor=${encodeURIComponent(i.did)}`}),a=uo(t.root,i);if(!a){let u=We(xe,t.root).filter(m=>m.type==="account").map(m=>`${String(m.id)} (@${String(we(m).handle??"")})`);if(u.length>0)throw new Error(`bluesky refresh refused: the root's account is @${i.handle} (${i.did}), and this World holds none of that DID or handle \u2014 only ${u.join(", ")}. Re-seed the World's OWN account (the one its posts are by) under its existing DID with the root's current handle: /_twin/accounts {"did": "<that DID>", "handle": "${i.handle}"} \u2014 a new account would leave its posts by another author`)}let d=a?.local??i.did,p=u=>$e(u,i.did,d);n("account",d,{handle:i.handle,...i.email!==void 0?{email:i.email}:{},emailConfirmed:i.emailConfirmed??!1,createdAt:String(s.json.createdAt??s.json.indexedAt??o),_deleted:!1});let c=await r({method:"GET",path:`/xrpc/com.atproto.repo.getRecord?repo=${encodeURIComponent(i.did)}&collection=app.bsky.actor.profile&rkey=self`,headers:{accept:"application/json"}});if(c.status===200){let u=JSON.parse(c.body),m=p(u.value);n("profile",d,{did:d,collection:"app.bsky.actor.profile",rkey:"self",cid:JSON.stringify(m)===JSON.stringify(u.value)?u.cid:W(m),record:m,indexedAt:o,_blobs:[],_deleted:!1})}else if(!(c.status===400&&/RecordNotFound/.test(c.body)))throw new Error(`bluesky refused getRecord (profile): HTTP ${c.status} ${c.body.slice(0,200)}`);let l=new Map,h;for(let u=0;;u+=1){if(u>=Je)throw new Error(`bluesky author feed of ${i.did} exceeded ${Je} pages; refusing to page further`);let m=await U(r,"getAuthorFeed",{method:"GET",path:`/xrpc/app.bsky.feed.getAuthorFeed?actor=${encodeURIComponent(i.did)}&filter=posts_with_replies&limit=100${h?`&cursor=${encodeURIComponent(h)}`:""}`}),$=m.json.feed;if(!Array.isArray($))throw new Error(`bluesky answered getAuthorFeed with no feed: ${m.body.slice(0,200)}`);for(let b of $)typeof b.post?.uri=="string"&&typeof b.post?.indexedAt=="string"&&l.set(b.post.uri,b.post.indexedAt);if(h=typeof m.json.cursor=="string"?m.json.cursor:void 0,!h||$.length===0)break}let f={post:0,follow:0};for(let[u,m]of[["app.bsky.feed.post","post"],["app.bsky.graph.follow","follow"]]){let $;for(let b=0;;b+=1){if(b>=Je)throw new Error(`bluesky ${u} of ${i.did} exceeded ${Je} pages; refusing to page further`);let w=await U(r,`listRecords ${u}`,{method:"GET",path:`/xrpc/com.atproto.repo.listRecords?repo=${encodeURIComponent(i.did)}&collection=${u}&limit=100${$?`&cursor=${encodeURIComponent($)}`:""}`}),F=w.json.records;if(!Array.isArray(F))throw new Error(`bluesky answered listRecords with no records: ${w.body.slice(0,200)}`);for(let _ of F){let Z=typeof _.uri=="string"?ke.exec(_.uri):null;if(!Z||typeof _.cid!="string"||typeof _.value!="object")throw new Error(`bluesky answered a record with no uri, cid or value: ${JSON.stringify(_).slice(0,200)}`);let re=p(_.value),de=JSON.stringify(re)===JSON.stringify(_.value)?_.cid:W(re);n(m,p(String(_.uri)),{did:d,collection:u,rkey:Z[3],cid:de,record:re,indexedAt:l.get(_.uri)??String(_.value.createdAt??o),...m==="follow"?{subject:re.subject}:{},_deleted:!1}),f[m]+=1}if($=typeof w.json.cursor=="string"?w.json.cursor:void 0,!$||F.length===0)break}}return{observed:1+f.post+f.follow+(c.status===200?1:0),posts:f.post,follows:f.follow}}import{registerPack as Dn}from"../../engine/v2/volter_world-core.mjs";var Un={vendor:"bluesky",rateBudget:Fe,transport:"rest",protocol:"2",archetype:"crud",bin:"world-bluesky",resources:["account","post","follow","profile"],specSource:'The AT Protocol lexicons (github.com/bluesky-social/atproto, lexicons/, main, read 2026-09-27) for com.atproto.server.{createSession,refreshSession,getSession,getServiceAuth}, com.atproto.repo.{createRecord,putRecord,deleteRecord,getRecord,listRecords,uploadBlob}, com.atproto.sync.getBlob, app.bsky.actor.{getProfile,profile}, app.bsky.feed.{getAuthorFeed,getPostThread,post,defs}, app.bsky.embed.{images,video,external}, app.bsky.richtext.facet and app.bsky.video.{uploadVideo,getJobStatus,getUploadLimits,defs}; the PDS sources (packages/pds/src) for auth and error wording; docs.bsky.app "Uploading video" and "Rate Limits".',description:"Bluesky twin \u2014 an account's PDS over XRPC (app-password sessions, service-auth tokens, post/follow/profile records with byte-indexed facets and image, video or link-card embeds, blob upload and ranged getBlob), the App View's profile, author feed and thread, and the video service's upload/job/limits flow, with a bsky.app mirror; everything else refuses by name.",refresh:{every:"1h",webhook:!1,onDemand:{atMost:"60s"}},stateSystem:{perform:Gt,refresh:Kt},auth:{in:"exchange",request:{method:"POST",path:"/xrpc/com.atproto.server.createSession",format:"json",body:{identifier:{credential:"keyId"},password:{credential:"secret"}}},token:"accessJwt",retryOn:[400,401],retryCode:"ExpiredToken"},roundTrip:[{method:"POST",path:"/_twin/accounts",body:{handle:"round-trip.bsky.social",did:"did:plc:roundtripaaaaaaaaaaaaaaa"}},{method:"POST",path:"/_twin/tokens",body:{account:"did:plc:roundtripaaaaaaaaaaaaaaa",token:"round-trip-token"}},{method:"POST",path:"/xrpc/com.atproto.repo.createRecord",headers:{authorization:"Bearer round-trip-token"},body:{repo:"did:plc:roundtripaaaaaaaaaaaaaaa",collection:"app.bsky.feed.post",record:{$type:"app.bsky.feed.post",text:"round trip",createdAt:"2026-09-27T12:00:00.000Z"}}}],parityOrigin:"http://twin",shapeParity:"held",adoption:{sdks:["@atproto/api"],pypi:[],envStems:["BLUESKY","BSKY"]},hosts:[{host:"bsky.social",pathPattern:"^/xrpc/(com\\.atproto|app\\.bsky)\\."},{hostPattern:"^[a-z0-9-]+\\.[a-z0-9-]+\\.host\\.bsky\\.network$",pathPattern:"^/xrpc/(com\\.atproto|app\\.bsky)\\."},{host:"api.bsky.app",pathPattern:"^/xrpc/app\\.bsky\\.(actor|feed)\\."},{host:"public.api.bsky.app",pathPattern:"^/xrpc/app\\.bsky\\.(actor|feed)\\."},{host:"video.bsky.app",pathPattern:"^/(xrpc/app\\.bsky\\.video\\.|watch/)"},{host:"cdn.bsky.app",pathPattern:"^/img/"},{host:"bsky.app",pathPattern:Pt}],endpointEnvNone:"@atproto/api reads no base-URL environment variable (an AtpAgent takes its `service` URL in code, and the video service's is the social-app's constant), so a World reaches it through the hosts above; inventing a BLUESKY_BASE_URL the app never reads would report coverage the app does not have.",browserRouting:{apiPathPrefix:"/xrpc/",loaderHost:"https://bsky.social"}};Dn(Un);export{Et 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-calcom
|
|
2
|
+
|
|
3
|
+
Contains @volter/twin-calcom 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,2 @@
|
|
|
1
|
+
import{createRequire as __atReq}from'node:module';const require=__atReq(import.meta.url);
|
|
2
|
+
import{applyTwinWrite as ae,projectResources as se,resolveSubjectId as le}from"../../engine/v2/volter_world-core.mjs";var L="calcom";function d(e,n=200){return{status:n,body:{status:"success",data:e}}}function u(e,n=400,t){return{status:n,body:{status:"error",error:{code:t??ue(n),message:e}}}}function ue(e){return e===404?"NotFoundException":e===401?"UnauthorizedException":e===409?"ConflictException":"BadRequestException"}function k(e,n){let t={booking:9e3,event_type:7100,schedule:8e3,team:6e3,membership:4e3,webhook:3e3},s=I(e,n).length;return(t[e]??1e3)+s+1}function I(e,n){return se(L,n).filter(t=>t.type===e).filter(t=>t.deleted!==!0)}function p(e,n,t){let s=le(L,e,n,t);return I(e,t).find(m=>m.id===s)}var w={id:5e3,username:"twin-calcom-admin",email:"admin@calcom.twin",name:"Cal.com Twin Admin",avatarUrl:null,bio:null,timeFormat:12,defaultScheduleId:8e3,weekStart:"Monday",timeZone:"America/Los_Angeles",organizationId:6e3,organization:{id:6e3,isPlatform:!0}};function F(e){let n=p("profile","profile_me",e);if(!n)return w;let{type:t,updatedAt:s,id:m,...g}=n;return{...w,...g}}var _={id:7001,title:"30 Min Meeting",slug:"consultation",lengthInMinutes:30,requiresConfirmation:!1};function de(e){if(!e)return{};try{return JSON.parse(e)}catch{return{}}}async function f(e,n,t,s,m){await ae(L,{operation:`set.${e}`,subjectType:e,subjectId:n,fields:t,...m?{occurredAt:m}:{},actor:{kind:"agent"}},s)}function q(e,n="id"){let{type:t,updatedAt:s,id:m,...g}=e;return g}function j(e,n){let t=n.get("take"),s=n.get("skip");if(t===null&&s===null)return d(e);let m=Math.max(0,Number.isFinite(Number(s))?Number(s):0),g=t===null?e.length:Math.max(0,Number(t)||0);return{status:200,body:{status:"success",data:e.slice(m,m+g),pagination:{totalCount:e.length,take:g,skip:m,hasMore:m+g<e.length}}}}var ce="2026-07-01T00:00:00.000Z";function me(e){let n=e.get("start")??e.get("startTime"),t=new Date(n&&!Number.isNaN(Date.parse(n))?n:ce);t.setUTCHours(16,0,0,0);let s=new Date(t.getTime()+3600*1e3);return{[t.toISOString().slice(0,10)]:[{start:t.toISOString()},{start:s.toISOString()}]}}function fe(e){return q(e)}async function G(e){let{method:n,root:t,occurredAt:s}=e,m=e.readOnly??!1,g=n!=="GET"&&n!=="HEAD",v;try{v=new URL(e.path,"http://twin.local")}catch{return u("invalid path",400)}let r=v.pathname.replace(/^\/v2(\/|$)/,"/").replace(/^\/+|\/+$/g,"").split("/").filter(Boolean),E=v.searchParams,i=de(e.body);if(m&&g)return u("this twin was started read-only; omit readOnly to accept writes",405,"ReadOnlyException");if(r[0]==="me"&&r.length===1){if(n==="GET")return d(F(t));if(n==="PATCH"){let a=["name","email","timeZone","weekStart","timeFormat","bio","avatarUrl","locale","username"],o={};for(let l of a)i[l]!==void 0&&(o[l]=i[l]);return Object.keys(o).length===0?u("at least one updatable profile field is required",400):(await f("profile","profile_me",o,t,s),d(F(t)))}}if(n==="GET"&&r[0]==="slots"&&r.length===1)return d(me(E));if(r[0]==="slots"&&r[1]==="reservations"){if(n==="POST"&&r.length===2){let a=i.eventTypeId,o=i.slotStart??i.start;if(a===void 0)return u("eventTypeId is required",400);if(o===void 0)return u("slotStart is required",400);let l=`slot_${U("slot",t)}`;return await f("slot",l,{reservationUid:l,eventTypeId:a,slotStart:o,slotDuration:i.slotDuration??30},t,s),d({reservationUid:l,eventTypeId:a,slotStart:o,slotEnd:P(String(o),Number(i.slotDuration??30))},201)}if(r.length===3){let a=`slot_${W(r[2],"slot_")}`,o=p("slot",a,t)??p("slot",r[2],t);if(n==="GET")return o?d(q(o)):u(`No reservation found for uid ${r[2]}`,404);if(n==="DELETE")return o?(await f("slot",o.id,{deleted:!0},t,s),d({reservationUid:r[2]})):u(`No reservation found for uid ${r[2]}`,404)}}if(r[0]==="bookings"){if(n==="POST"&&r.length===1){let a=i.start;if(a===void 0||typeof a!="string"||Number.isNaN(Date.parse(a)))return u("start is required and must be an ISO 8601 datetime",400);let o=i.attendee??{};if(!o.name||!o.email)return u("attendee.name and attendee.email are required",400);let l=i.eventTypeId??_.id,c=l===_.id?_:p("event_type",`evt_${l}`,t);if(!c)return u(`No event type found for id ${l}`,404);let h=i.lengthInMinutes??c.lengthInMinutes??30,T=k("booking",t),b=`booking_${U("booking",t)}`,y=P(a,h),oe=c?.requiresConfirmation===!0?"pending":"accepted",re={bid:T,uid:b,title:i.title??c?.title??"Consultation between Cal.com Twin Admin and "+o.name,status:oe,start:a,end:y,duration:h,eventTypeId:l,eventType:{id:l,slug:c?.slug??"consultation"},attendees:[{name:o.name,email:o.email,timeZone:o.timeZone??"America/Los_Angeles",language:o.language??"en",absent:!1}],hosts:[{id:w.id,name:w.name,timeZone:w.timeZone,mandatory:!0}],guests:i.guests??[],location:i.location??null,meetingUrl:i.meetingUrl??null,metadata:i.metadata??{}};await f("booking",b,re,t,s);let ie=await C(b,t);return d(ie,201)}if(n==="GET"&&r.length===1){let o=I("booking",t).filter(b=>b.uid),l=E.get("status");l&&(o=o.filter(b=>b.status===l));let c=E.get("attendeeEmail");c&&(o=o.filter(b=>Array.isArray(b.attendees)&&b.attendees.some(y=>y.email===c)));let h=E.get("eventTypeId");h&&(o=o.filter(b=>String(b.eventTypeId)===h));let T=await Promise.all(o.map(b=>C(b.id,t)));return j(T,E)}if(n==="GET"&&r.length===2){let a=M(r[1]);return p("booking",a,t)?d(await C(a,t)):u(`No booking found for uid ${r[1]}`,404)}if(n==="GET"&&r.length===3){let a=M(r[1]),o=r[2],l=p("booking",a,t);return l?o==="references"?d(l.references??[]):o==="recordings"?d(l.recordings??[]):u(`Cannot GET /v2/bookings/${r[1]}/${o}`,404):u(`No booking found for uid ${r[1]}`,404)}if(n==="POST"&&r.length===3){let a=M(r[1]),o=r[2],l=p("booking",a,t);if(!l)return u(`No booking found for uid ${r[1]}`,404);let c=l.status;if(o==="mark-absent"){if(c==="cancelled")return u("Cannot mark a cancelled booking absent",400);let h=i.noShowHost===!0,T=new Set((Array.isArray(i.attendees)?i.attendees:[]).filter(y=>y.absent===!0).map(y=>String(y.email))),b=l.attendees.map(y=>T.has(String(y.email))?{...y,absent:!0}:y);return await f("booking",a,{attendees:b,noShowHost:h},t,s),d({...await C(a,t),noShowHost:h})}if(o==="cancel")return c==="cancelled"?u(`Booking ${r[1]} is already cancelled`,400,"ConflictException"):(await f("booking",a,{status:"cancelled",cancellationReason:i.cancellationReason??null},t,s),d({...await C(a,t),status:"cancelled"}));if(o==="reschedule"){if(c==="cancelled")return u("Cannot reschedule a cancelled booking",400);let h=i.start;if(h===void 0||typeof h!="string"||Number.isNaN(Date.parse(h)))return u("start is required to reschedule",400);let T=`booking_${U("booking",t)}`,b=l.duration,y={...l,uid:T,bid:k("booking",t),start:h,end:P(h,b),status:"accepted",reschedulingReason:i.reschedulingReason??null,fromReschedule:a};return await f("booking",T,y,t,s),await f("booking",a,{status:"cancelled",rescheduled:!0},t,s),d(await C(T,t),201)}return o==="confirm"?c!=="pending"?u(`Only a pending booking can be confirmed (current status: ${c})`,400):(await f("booking",a,{status:"accepted"},t,s),d(await C(a,t))):o==="decline"?c!=="pending"?u(`Only a pending booking can be declined (current status: ${c})`,400):(await f("booking",a,{status:"rejected",rejectionReason:i.reason??null},t,s),d(await C(a,t))):u(`Unknown booking action: ${o}`,404)}}if(r[0]==="event-types"){if(n==="POST"&&r.length===1){if(!i.title||!i.slug||i.lengthInMinutes===void 0)return u("title, slug and lengthInMinutes are required",400);let a=k("event_type",t),o=`evt_${a}`,l={evtId:a,title:i.title,slug:i.slug,lengthInMinutes:i.lengthInMinutes,description:i.description??null,ownerId:w.id,hidden:i.hidden??!1,scheduleId:i.scheduleId??null,requiresConfirmation:i.requiresConfirmation??!1,bookingUrl:`https://cal.com/${w.username}/${i.slug}`,locations:i.locations??[],bookingFields:i.bookingFields??[],seatsPerTimeSlot:i.seatsPerTimeSlot??null,seatsShowAttendees:i.seatsShowAttendees??!1,seatsShowAvailabilityCount:i.seatsShowAvailabilityCount??!0,beforeEventBuffer:i.beforeEventBuffer??0,afterEventBuffer:i.afterEventBuffer??0,minimumBookingNotice:i.minimumBookingNotice??0};return await f("event_type",o,l,t,s),d(S(p("event_type",o,t)),201)}if(n==="GET"&&r.length===1){let a=I("event_type",t).filter(c=>c.teamId===void 0||c.teamId===null).map(S),o=E.get("username"),l=E.get("eventSlug");return l!==null&&o===null?u("username is required when eventSlug is provided",400):(o!==null&&(o===w.username?a=[pe(),...a]:a=[],l!==null&&(a=a.filter(c=>c.slug===l))),j(a,E))}if(r.length===2){let a=r[1].startsWith("evt_")?r[1]:`evt_${r[1]}`,o=p("event_type",a,t);if(n==="GET")return o?d(S(o)):u(`No event type found for id ${r[1]}`,404);if(n==="PATCH")return o?(await f("event_type",a,i,t,s),d(S(p("event_type",a,t)))):u(`No event type found for id ${r[1]}`,404);if(n==="DELETE")return o?(await f("event_type",a,{deleted:!0},t,s),d({id:o.evtId,lengthInMinutes:o.lengthInMinutes,title:o.title,slug:o.slug})):u(`No event type found for id ${r[1]}`,404)}}if(r[0]==="schedules"){if(n==="POST"&&r.length===1){if(!i.name||!i.timeZone||i.isDefault===void 0)return u("name, timeZone and isDefault are required",400);let a=k("schedule",t),o=`sched_${a}`,l={schedId:a,ownerId:w.id,name:i.name,timeZone:i.timeZone,availability:i.availability??[{days:["Monday","Tuesday","Wednesday","Thursday","Friday"],startTime:"09:00",endTime:"17:00"}],isDefault:i.isDefault,overrides:i.overrides??[]};return await f("schedule",o,l,t,s),d(N(p("schedule",o,t)),201)}if(n==="GET"&&r.length===1)return d(I("schedule",t).map(N));if(r.length===2){let a=r[1].startsWith("sched_")?r[1]:`sched_${r[1]}`,o=p("schedule",a,t);if(n==="GET")return o?d(N(o)):u(`No schedule found for id ${r[1]}`,404);if(n==="PATCH")return o?(await f("schedule",a,i,t,s),d(N(p("schedule",a,t)))):u(`No schedule found for id ${r[1]}`,404);if(n==="DELETE")return o?(await f("schedule",a,{deleted:!0},t,s),d({id:o.schedId})):u(`No schedule found for id ${r[1]}`,404)}}if(r[0]==="teams"){if(n==="POST"&&r.length===1){if(!i.name)return u("name is required",400);let a=k("team",t),o=`team_${a}`;return await f("team",o,{teamId:a,name:i.name,slug:i.slug??he(String(i.name)),isOrganization:i.isOrganization??!1},t,s),d($(p("team",o,t)),201)}if(n==="GET"&&r.length===1)return d(I("team",t).map($));if(r.length===2){let a=r[1].startsWith("team_")?r[1]:`team_${r[1]}`,o=p("team",a,t);if(n==="GET")return o?d($(o)):u(`No team found for id ${r[1]}`,404);if(n==="PATCH"){if(!o)return u(`No team found for id ${r[1]}`,404);let l={};for(let c of["name","slug","bio","hideBranding","isPrivate"])i[c]!==void 0&&(l[c]=i[c]);return Object.keys(l).length===0?u("at least one updatable team field is required",400):(await f("team",a,l,t,s),d($(p("team",a,t))))}if(n==="DELETE")return o?(await f("team",a,{deleted:!0},t,s),d($(o))):u(`No team found for id ${r[1]}`,404)}if(r[2]==="event-types"){let a=r[1].startsWith("team_")?r[1]:`team_${r[1]}`,o=p("team",a,t);if(!o)return u(`No team found for id ${r[1]}`,404);let l=o.teamId;if(n==="POST"&&r.length===3){if(!i.title||!i.slug||i.lengthInMinutes===void 0)return u("title, slug and lengthInMinutes are required",400);let c=k("event_type",t),h=`evt_${c}`,T={evtId:c,title:i.title,slug:i.slug,lengthInMinutes:i.lengthInMinutes,description:i.description??null,ownerId:w.id,hidden:i.hidden??!1,scheduleId:i.scheduleId??null,requiresConfirmation:i.requiresConfirmation??!1,bookingUrl:`https://cal.com/team/${o.slug}/${i.slug}`,teamId:l,schedulingType:i.schedulingType??"collective",locations:i.locations??[],bookingFields:i.bookingFields??[]};return await f("event_type",h,T,t,s),d(S(p("event_type",h,t)),201)}if(n==="GET"&&r.length===3)return d(I("event_type",t).filter(c=>c.teamId===l).map(S))}if(r[2]==="memberships"){let a=r[1].startsWith("team_")?r[1]:`team_${r[1]}`;if(!p("team",a,t))return u(`No team found for id ${r[1]}`,404);if(n==="POST"&&r.length===3){if(i.userId===void 0)return u("userId is required",400);let o=k("membership",t),l=`mem_${o}`;return await f("membership",l,{memId:o,teamId:a,userId:i.userId,role:i.role??"MEMBER",accepted:i.accepted??!0},t,s),d(R(p("membership",l,t)),201)}if(n==="GET"&&r.length===3)return d(I("membership",t).filter(o=>o.teamId===a).map(R));if(r.length===4){let o=r[3].startsWith("mem_")?r[3]:`mem_${r[3]}`,l=p("membership",o,t);if(!l||l.teamId!==a)return u(`No membership found for id ${r[3]}`,404);if(n==="GET")return d(R(l));if(n==="PATCH"){let c={};for(let h of["role","accepted","disableImpersonation"])i[h]!==void 0&&(c[h]=i[h]);return Object.keys(c).length===0?u("at least one updatable membership field is required",400):(await f("membership",o,c,t,s),d(R(p("membership",o,t))))}if(n==="DELETE")return await f("membership",o,{deleted:!0},t,s),d(R(l))}}}if(r[0]==="webhooks"){if(n==="POST"&&r.length===1){if(!i.subscriberUrl||!Array.isArray(i.triggers)||i.triggers.length===0)return u("subscriberUrl and a non-empty triggers[] are required",400);let o=`wh_${k("webhook",t)}`;return await f("webhook",o,{whId:o,subscriberUrl:i.subscriberUrl,triggers:i.triggers,active:i.active??!0,payloadTemplate:i.payloadTemplate??null},t,s),d(O(p("webhook",o,t)),201)}if(n==="GET"&&r.length===1)return d(I("webhook",t).map(O));if(r.length===2){let a=r[1].startsWith("wh_")?r[1]:`wh_${r[1]}`,o=p("webhook",a,t);if(n==="GET")return o?d(O(o)):u(`No webhook found for id ${r[1]}`,404);if(n==="PATCH")return o?(await f("webhook",a,i,t,s),d(O(p("webhook",a,t)))):u(`No webhook found for id ${r[1]}`,404);if(n==="DELETE")return o?(await f("webhook",a,{deleted:!0},t,s),d({id:a})):u(`No webhook found for id ${r[1]}`,404)}}return u(`Cannot ${n} ${v.pathname}`,404)}async function C(e,n){let t=p("booking",e,n),s=fe(t);return{id:t.bid,uid:t.uid,title:s.title,status:s.status,start:s.start,end:s.end,duration:s.duration,eventTypeId:s.eventTypeId,eventType:s.eventType,attendees:s.attendees,hosts:s.hosts,guests:s.guests??[],location:s.location??null,meetingUrl:s.meetingUrl??null,metadata:s.metadata??{},...s.noShowHost!==void 0?{noShowHost:s.noShowHost}:{},...s.cancellationReason!==void 0&&s.cancellationReason!==null?{cancellationReason:s.cancellationReason}:{},...s.reschedulingReason!==void 0&&s.reschedulingReason!==null?{reschedulingReason:s.reschedulingReason}:{}}}function S(e){return{id:e.evtId,lengthInMinutes:e.lengthInMinutes,title:e.title,slug:e.slug,description:e.description??null,ownerId:e.ownerId,hidden:e.hidden??!1,scheduleId:e.scheduleId??null,requiresConfirmation:e.requiresConfirmation??!1,bookingUrl:e.bookingUrl,locations:e.locations??[],bookingFields:e.bookingFields??[],seatsPerTimeSlot:e.seatsPerTimeSlot??null,seatsShowAttendees:e.seatsShowAttendees??!1,seatsShowAvailabilityCount:e.seatsShowAvailabilityCount??!0,beforeEventBuffer:e.beforeEventBuffer??0,afterEventBuffer:e.afterEventBuffer??0,minimumBookingNotice:e.minimumBookingNotice??0,...e.teamId!==void 0&&e.teamId!==null?{teamId:e.teamId,schedulingType:e.schedulingType??"collective"}:{}}}function pe(){return S({evtId:_.id,..._,ownerId:w.id,bookingUrl:`https://cal.com/${w.username}/${_.slug}`})}function N(e){return{id:e.schedId,ownerId:e.ownerId,name:e.name,timeZone:e.timeZone,availability:e.availability??[],isDefault:e.isDefault??!1,overrides:e.overrides??[]}}function $(e){return{id:e.teamId,name:e.name,slug:e.slug,isOrganization:e.isOrganization??!1}}function R(e){return{id:e.memId,userId:e.userId,role:e.role,accepted:e.accepted??!0,teamId:ge(e.teamId),disableImpersonation:e.disableImpersonation??!1}}function O(e){return{id:e.whId,subscriberUrl:e.subscriberUrl,triggers:e.triggers,active:e.active??!0,payloadTemplate:e.payloadTemplate??null}}function P(e,n){return new Date(new Date(e).getTime()+n*60*1e3).toISOString()}function he(e){return e.toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/^-+|-+$/g,"")}function W(e,n){return e.startsWith(n)?e.slice(n.length):e}function ge(e){return Number(W(e,"team_"))}function M(e){return e.startsWith("booking_")?e:`booking_${e}`}function U(e,n){return(I(e,n).length+1).toString(16).padStart(6,"0")}import{serveHttp as Be}from"../../engine/v2/volter_world-core.mjs";import{createTwinFetchFromHandler as be,statefulTwinManifest as ye}from"../../engine/v2/volter_world-core.mjs";function D(e={}){return be(G,{...e,manifest:ye({vendor:"calcom",twinOf:"the Cal.com v2 API",stores:"event types, bookings, schedules and availability"}),extras:n=>{let t=n.headers.get("cal-api-version");return t?{apiVersion:t}:{}}})}import{assertBudgetGuardIntact as He,observeResources as Ee}from"../../engine/v2/volter_world-core.mjs";import{declareRateBudget as we,rateBudgetPath as Ge,rateBudgetWeight as De,RateBudget as Fe}from"../../engine/v2/volter_world-core.mjs";import{RateBudgetError as z}from"../../engine/v2/volter_world-core.mjs";var ve="calcom",H=6e4,Z=60,V=300,x={book:3,slots:2,other:1},B={windowMs:H,ceiling:Z,defaultWeight:x.other,maxRetryAfterSeconds:V,rules:[{match:"^POST /bookings$",weight:x.book},{match:"^GET /slots",weight:x.slots}],reason:"Cal.com documents 120 requests/minute per API key (cal.com/docs/api-reference/v2/introduction, read 2026-07-26; the same 120/min is the unauthenticated default, and it is raisable on request). That page documents no response headers; the X-RateLimit-* names the guard reads are the conventional spelling, read if present and never assumed. 60 weighted units / 60s is 60 calls a minute \u2014 HALF the documented 120, so the 60s average stays under the vendor's own. It is deliberately more permissive than the kernel's undeclared fallback (30 calls/min) BECAUSE 120/min is documented; without that number it would not be. POST /bookings costs 3 (it sends e-mail, writes real connected calendars and fires webhooks \u2014 a human blast radius, not just a throttle) and GET /slots costs 2 (availability computed across every connected calendar, and the endpoint a naive UI polls in a loop) \u2014 judgement calls, not published costs. The window bounds the 60s AVERAGE and does not pace; the 429 / `X-RateLimit-Remaining: 0` cooldown is the backstop for a sub-second burst."};we(ve,B);var Y="calcom",ke=new Set(["slot"]);function J(e){return{type:"booking",id:String(e.uid),fields:{uid:e.uid,bid:e.id,title:e.title,status:e.status,start:e.start,end:e.end,duration:e.duration,eventTypeId:e.eventTypeId,eventType:e.eventType,attendees:e.attendees??[],hosts:e.hosts??[],guests:e.guests??[],location:e.location??null,meetingUrl:e.meetingUrl??null,metadata:e.metadata??{}}}}function X(e){return{type:"event_type",id:`evt_${e.id}`,fields:{evtId:e.id,title:e.title,slug:e.slug,lengthInMinutes:e.lengthInMinutes,description:e.description??null,ownerId:e.ownerId,hidden:e.hidden??!1,scheduleId:e.scheduleId??null,requiresConfirmation:e.requiresConfirmation??!1,bookingUrl:e.bookingUrl,locations:e.locations??[],bookingFields:e.bookingFields??[],seatsPerTimeSlot:e.seatsPerTimeSlot??null,seatsShowAttendees:e.seatsShowAttendees??!1,seatsShowAvailabilityCount:e.seatsShowAvailabilityCount??!0,beforeEventBuffer:e.beforeEventBuffer??0,afterEventBuffer:e.afterEventBuffer??0,minimumBookingNotice:e.minimumBookingNotice??0}}}var Ce="2026-07-01T00:00:00.000Z";async function Se(e){let n=await e("GET","/bookings");return(Array.isArray(n.data)?n.data:n.data?.bookings??[]).map(J)}async function _e(e){let n=await e("GET","/event-types");return(Array.isArray(n.data)?n.data:n.data?.eventTypes??[]).map(X)}async function K(e,n={}){let t=n.occurredAt??Ce,s=await Se(e),m=await _e(e),g=[...s,...m],v=Ee(Y,g.map(A=>({type:A.type,id:A.id,fields:A.fields})),{...n.root!==void 0?{root:n.root}:{},at:t,batch:`obs:${Y}:${t}`});return{observed:v.observed,deltasAppended:v.appended}}function Q(e){if(ke.has(e.subject.type))return null;let n=e.fields??{};return e.subject.type==="booking"?n.status==="cancelled"?{method:"POST",path:`/bookings/${String(n.uid??e.subject.id)}/cancel`,body:{}}:{method:"POST",path:"/bookings",body:n}:e.subject.type==="event_type"?{method:"POST",path:"/event-types",body:n}:e.subject.type==="schedule"?{method:"POST",path:"/schedules",body:n}:e.subject.type==="webhook"?{method:"POST",path:"/webhooks",body:n}:null}function ee(e){return async(n,t,s)=>{let m=await e({method:n,path:t,headers:{accept:"application/json",...s?{"content-type":"application/json"}:{}},...s===void 0?{}:{body:JSON.stringify(s)}}),g={};if(m.body)try{g=JSON.parse(m.body)}catch{g={status:"error",error:{message:m.body}}}return g}}async function te(e,n={}){return K(ee(e),{...n.root!==void 0?{root:n.root}:{},...n.occurredAt!==void 0?{occurredAt:n.occurredAt}:{}})}async function ne(e,n,t){return Ae(ee(e),n,t)}async function Ae(e,n,t){let s=Q(n);if(!s)return{externalId:n.subject.id,data:{performed:!1,reason:`${n.subject.type} is the twin's own record \u2014 nothing at Cal.com to write`}};let m=await e(s.method,s.path,s.body);if(m.status!=="success"||m.error!==void 0)throw new Error(`calcom perform ${n.operation??n.subject.type} refused: ${JSON.stringify(m.error??m).slice(0,200)}`);let g=m.data??{},v=g.uid??g.id;return{externalId:v===void 0?n.subject.id:String(v)}}import{bundleClient as Ye,fileResponse as Je,filePathOf as Xe}from"../../engine/v2/volter_world-core.mjs";import{serveHttp as Qe}from"../../engine/v2/volter_world-core.mjs";import{registerPack as $e}from"../../engine/v2/volter_world-core.mjs";var Re={vendor:"calcom",protocol:"2",refresh:{every:"5m",webhook:!0,onDemand:{atMost:"30s"}},stateSystem:{perform:ne,refresh:te},roundTrip:{method:"POST",path:"/v2/event-types",body:{title:"Round trip",slug:"round-trip",lengthInMinutes:30},headers:{authorization:"Bearer round-trip","cal-api-version":"2024-06-14"}},referenceTrip:{method:"POST",path:"/v2/bookings",body:{start:"2026-09-09T11:00:00.000Z",eventTypeId:"{{evtId}}",attendee:{name:"Round Trip",email:"round@trip.test",timeZone:"UTC"}},headers:{authorization:"Bearer round-trip","cal-api-version":"2024-08-13"}},references:[{type:"booking",to:"event_type",key:e=>e.eventTypeId===void 0||e.eventTypeId===null?void 0:`evt_${String(e.eventTypeId)}`,adopt:(e,n)=>({eventTypeId:n.replace(/^evt_/,"")})}],parityOrigin:"http://twin",shapeParity:"held",rateBudget:B,transport:"rest",archetype:"crud",bin:"world-calcom",resources:["booking","event_type","schedule","team","membership","webhook","slot"],specSource:"cal.com/docs/api-reference/v2 (hand-authored from the published v2 reference)",description:"Cal.com v2 REST twin \u2014 { status, data } envelope, stateful bookings/event-types/schedules/teams/webhooks, dashboard mirror.",adoption:{pypi:[],envStems:["CALCOM","CAL"]},hosts:[{host:"api.cal.com"}],browserRouting:{apiPathPrefix:"/v2/",loaderHost:"https://api.cal.com"}};$e(Re);export{D as createTwinFetch};
|