agenttwin 0.3.21 → 0.3.22

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (408) hide show
  1. package/dist/api.js +2113 -609
  2. package/dist/dashboard/assets/dashboard/agent-home.css +7 -7
  3. package/dist/dashboard/assets/dashboard/bay-morning.webp +0 -0
  4. package/dist/dashboard/assets/dashboard/golden-gate-afternoon.webp +0 -0
  5. package/dist/dashboard/assets/dashboard/golden-gate-portrait.webp +0 -0
  6. package/dist/dashboard/assets/dashboard/moonlit-coast.webp +0 -0
  7. package/dist/dashboard/assets/next/static/chunks/5663-403316746afad10e.js +1 -0
  8. package/dist/dashboard/assets/next/static/chunks/app/dashboard/{page-9c11295678539a5f.js → page-0e0392368e0a891e.js} +1 -1
  9. package/dist/dashboard/assets/next/static/chunks/app/docs/[[...slug]]/page-4981ea4966b19e3e.js +1 -0
  10. package/dist/dashboard/assets/next/static/chunks/app/onboarding/page-dd4ac0f5f36e6bfa.js +1 -0
  11. package/dist/dashboard/assets/next/static/chunks/app/v2/dashboard/{page-34574448d210c775.js → page-de0fe6d84be21e6a.js} +1 -1
  12. package/dist/dashboard/assets/next/static/chunks/app/v2/onboarding/page-360cbffc57981f6b.js +1 -0
  13. package/dist/dashboard/assets/next/static/chunks/app/v2/{page-07c8054d57c9089b.js → page-3e86fffabfa87d88.js} +1 -1
  14. package/dist/dashboard/assets/next/static/chunks/{webpack-40324749d289e4a5.js → webpack-be6e526fd530c797.js} +1 -1
  15. package/dist/dashboard/assets/next/static/css/{42045de5f39b50ca.css → 37d81e1d2804cc5f.css} +1 -1
  16. package/dist/dashboard/assets/next/static/css/69ec1bae997c3bb0.css +1 -0
  17. package/dist/dashboard/assets/next/static/css/ad85402a1595e56e.css +1 -0
  18. package/dist/dashboard/assets/next/static/css/{4bbe78c2fe206b92.css → da981fb878a02b8c.css} +1 -1
  19. package/dist/dashboard/assets/next/static/media/bay-morning.82669113.webp +0 -0
  20. package/dist/dashboard/assets/next/static/media/golden-gate-afternoon.0aa49492.webp +0 -0
  21. package/dist/dashboard/assets/next/static/media/golden-gate-portrait.89fc667a.webp +0 -0
  22. package/dist/dashboard/assets/next/static/media/moonlit-coast.09739ef4.webp +0 -0
  23. package/dist/dashboard/index.html +2 -2
  24. package/dist/engine.js +6385 -4973
  25. package/dist/gateway.js +2194 -604
  26. package/dist/twins/catalog.json +6020 -0
  27. package/dist/twins/engine/v2/THIRD-PARTY.txt +25 -0
  28. package/dist/twins/engine/v2/chunks/2CHBP57N.mjs +8 -0
  29. package/dist/twins/engine/v2/chunks/4CPL6MPF.mjs +30 -0
  30. package/dist/twins/engine/v2/chunks/OYLYKZGD.mjs +2 -0
  31. package/dist/twins/engine/v2/chunks/SQSP35HM.mjs +38 -0
  32. package/dist/twins/engine/v2/chunks/YSJQQVUM.mjs +2 -0
  33. package/dist/twins/engine/v2/react-dom_client.mjs +272 -0
  34. package/dist/twins/engine/v2/react-dom_server.mjs +263 -0
  35. package/dist/twins/engine/v2/react.mjs +2 -0
  36. package/dist/twins/engine/v2/react_jsx-runtime.mjs +31 -0
  37. package/dist/twins/engine/v2/volter_world-core.mjs +195 -0
  38. package/dist/twins/engine/v2/volter_world-core_app-route.mjs +2 -0
  39. package/dist/twins/engine/v2/volter_world-core_network-policy.mjs +2 -0
  40. package/dist/twins/engine/v3/THIRD-PARTY.txt +65 -0
  41. package/dist/twins/engine/v3/chunks/2CHBP57N.mjs +8 -0
  42. package/dist/twins/engine/v3/chunks/2YSSPA5O.mjs +65 -0
  43. package/dist/twins/engine/v3/chunks/5PWRY4UK.mjs +154 -0
  44. package/dist/twins/engine/v3/chunks/7XRKSFFJ.mjs +2 -0
  45. package/dist/twins/engine/v3/chunks/AWOWH2H5.mjs +2 -0
  46. package/dist/twins/engine/v3/chunks/C46M5U3Q.mjs +2 -0
  47. package/dist/twins/engine/v3/chunks/MFH2VZPP.mjs +2 -0
  48. package/dist/twins/engine/v3/chunks/MWCO5UV3.mjs +2 -0
  49. package/dist/twins/engine/v3/chunks/N5BL5RDF.mjs +313 -0
  50. package/dist/twins/engine/v3/chunks/O7HGPMXG.mjs +2 -0
  51. package/dist/twins/engine/v3/chunks/OYLYKZGD.mjs +2 -0
  52. package/dist/twins/engine/v3/chunks/PLB7HTON.mjs +8 -0
  53. package/dist/twins/engine/v3/chunks/TY4LDBVH.mjs +7 -0
  54. package/dist/twins/engine/v3/chunks/VDIRUSCM.mjs +2 -0
  55. package/dist/twins/engine/v3/chunks/WGUCFQK6.mjs +2 -0
  56. package/dist/twins/engine/v3/chunks/WPATONSC.mjs +2 -0
  57. package/dist/twins/engine/v3/react_jsx-runtime.mjs +2 -0
  58. package/dist/twins/engine/v3/volter_world-core.mjs +2 -0
  59. package/dist/twins/engine/v3/volter_world-ui.mjs +559 -0
  60. package/dist/twins/packs/ahrefs/LICENSE +202 -0
  61. package/dist/twins/packs/ahrefs/NOTICE +7 -0
  62. package/dist/twins/packs/ahrefs/index.mjs +2 -0
  63. package/dist/twins/packs/ai-gateway/LICENSE +202 -0
  64. package/dist/twins/packs/ai-gateway/NOTICE +7 -0
  65. package/dist/twins/packs/ai-gateway/index.mjs +14 -0
  66. package/dist/twins/packs/airtable/LICENSE +202 -0
  67. package/dist/twins/packs/airtable/NOTICE +7 -0
  68. package/dist/twins/packs/airtable/index.mjs +2 -0
  69. package/dist/twins/packs/algolia/LICENSE +202 -0
  70. package/dist/twins/packs/algolia/NOTICE +7 -0
  71. package/dist/twins/packs/algolia/index.mjs +2 -0
  72. package/dist/twins/packs/ambientcg/LICENSE +202 -0
  73. package/dist/twins/packs/ambientcg/NOTICE +7 -0
  74. package/dist/twins/packs/ambientcg/index.mjs +2 -0
  75. package/dist/twins/packs/anthropic/LICENSE +202 -0
  76. package/dist/twins/packs/anthropic/NOTICE +7 -0
  77. package/dist/twins/packs/anthropic/index.mjs +18 -0
  78. package/dist/twins/packs/assemblyai/LICENSE +202 -0
  79. package/dist/twins/packs/assemblyai/NOTICE +7 -0
  80. package/dist/twins/packs/assemblyai/index.mjs +11 -0
  81. package/dist/twins/packs/aws/LICENSE +202 -0
  82. package/dist/twins/packs/aws/NOTICE +7 -0
  83. package/dist/twins/packs/aws/index.mjs +2 -0
  84. package/dist/twins/packs/azure/LICENSE +202 -0
  85. package/dist/twins/packs/azure/NOTICE +7 -0
  86. package/dist/twins/packs/azure/index.mjs +38 -0
  87. package/dist/twins/packs/azureformrecognizer/LICENSE +202 -0
  88. package/dist/twins/packs/azureformrecognizer/NOTICE +7 -0
  89. package/dist/twins/packs/azureformrecognizer/index.mjs +3 -0
  90. package/dist/twins/packs/bitly/LICENSE +202 -0
  91. package/dist/twins/packs/bitly/NOTICE +7 -0
  92. package/dist/twins/packs/bitly/index.mjs +2 -0
  93. package/dist/twins/packs/bluesky/LICENSE +202 -0
  94. package/dist/twins/packs/bluesky/NOTICE +7 -0
  95. package/dist/twins/packs/bluesky/index.mjs +30 -0
  96. package/dist/twins/packs/calcom/LICENSE +202 -0
  97. package/dist/twins/packs/calcom/NOTICE +7 -0
  98. package/dist/twins/packs/calcom/index.mjs +2 -0
  99. package/dist/twins/packs/clerk/LICENSE +202 -0
  100. package/dist/twins/packs/clerk/NOTICE +7 -0
  101. package/dist/twins/packs/clerk/index.mjs +5 -0
  102. package/dist/twins/packs/cloudflare/LICENSE +202 -0
  103. package/dist/twins/packs/cloudflare/NOTICE +7 -0
  104. package/dist/twins/packs/cloudflare/index.mjs +79 -0
  105. package/dist/twins/packs/cohere/LICENSE +202 -0
  106. package/dist/twins/packs/cohere/NOTICE +7 -0
  107. package/dist/twins/packs/cohere/index.mjs +2 -0
  108. package/dist/twins/packs/datadog/LICENSE +202 -0
  109. package/dist/twins/packs/datadog/NOTICE +7 -0
  110. package/dist/twins/packs/datadog/index.mjs +3 -0
  111. package/dist/twins/packs/deepinfra/LICENSE +202 -0
  112. package/dist/twins/packs/deepinfra/NOTICE +7 -0
  113. package/dist/twins/packs/deepinfra/index.mjs +13 -0
  114. package/dist/twins/packs/deepseek/LICENSE +202 -0
  115. package/dist/twins/packs/deepseek/NOTICE +7 -0
  116. package/dist/twins/packs/deepseek/index.mjs +12 -0
  117. package/dist/twins/packs/discord/LICENSE +202 -0
  118. package/dist/twins/packs/discord/NOTICE +7 -0
  119. package/dist/twins/packs/discord/index.mjs +2 -0
  120. package/dist/twins/packs/duckduckgo/LICENSE +202 -0
  121. package/dist/twins/packs/duckduckgo/NOTICE +7 -0
  122. package/dist/twins/packs/duckduckgo/index.mjs +532 -0
  123. package/dist/twins/packs/dynadot/LICENSE +202 -0
  124. package/dist/twins/packs/dynadot/NOTICE +7 -0
  125. package/dist/twins/packs/dynadot/index.mjs +2 -0
  126. package/dist/twins/packs/e2b/LICENSE +202 -0
  127. package/dist/twins/packs/e2b/NOTICE +7 -0
  128. package/dist/twins/packs/e2b/index.mjs +2 -0
  129. package/dist/twins/packs/elevenlabs/LICENSE +202 -0
  130. package/dist/twins/packs/elevenlabs/NOTICE +7 -0
  131. package/dist/twins/packs/elevenlabs/index.mjs +4 -0
  132. package/dist/twins/packs/expo/LICENSE +202 -0
  133. package/dist/twins/packs/expo/NOTICE +7 -0
  134. package/dist/twins/packs/expo/index.mjs +2 -0
  135. package/dist/twins/packs/fal/LICENSE +202 -0
  136. package/dist/twins/packs/fal/NOTICE +7 -0
  137. package/dist/twins/packs/fal/index.mjs +2 -0
  138. package/dist/twins/packs/figma/LICENSE +202 -0
  139. package/dist/twins/packs/figma/NOTICE +7 -0
  140. package/dist/twins/packs/figma/index.mjs +2 -0
  141. package/dist/twins/packs/firecrawl/LICENSE +202 -0
  142. package/dist/twins/packs/firecrawl/NOTICE +7 -0
  143. package/dist/twins/packs/firecrawl/index.mjs +9 -0
  144. package/dist/twins/packs/fireworks/LICENSE +202 -0
  145. package/dist/twins/packs/fireworks/NOTICE +7 -0
  146. package/dist/twins/packs/fireworks/index.mjs +13 -0
  147. package/dist/twins/packs/fly/LICENSE +202 -0
  148. package/dist/twins/packs/fly/NOTICE +7 -0
  149. package/dist/twins/packs/fly/index.mjs +2 -0
  150. package/dist/twins/packs/gcs/LICENSE +202 -0
  151. package/dist/twins/packs/gcs/NOTICE +7 -0
  152. package/dist/twins/packs/gcs/index.mjs +8 -0
  153. package/dist/twins/packs/gemini/LICENSE +202 -0
  154. package/dist/twins/packs/gemini/NOTICE +7 -0
  155. package/dist/twins/packs/gemini/index.mjs +7 -0
  156. package/dist/twins/packs/github/LICENSE +202 -0
  157. package/dist/twins/packs/github/NOTICE +7 -0
  158. package/dist/twins/packs/github/index.mjs +75153 -0
  159. package/dist/twins/packs/googleads/LICENSE +202 -0
  160. package/dist/twins/packs/googleads/NOTICE +7 -0
  161. package/dist/twins/packs/googleads/index.mjs +3 -0
  162. package/dist/twins/packs/googlemaps/LICENSE +202 -0
  163. package/dist/twins/packs/googlemaps/NOTICE +7 -0
  164. package/dist/twins/packs/googlemaps/index.mjs +2 -0
  165. package/dist/twins/packs/googleoauth/LICENSE +202 -0
  166. package/dist/twins/packs/googleoauth/NOTICE +7 -0
  167. package/dist/twins/packs/googleoauth/index.mjs +2 -0
  168. package/dist/twins/packs/hackernews/LICENSE +202 -0
  169. package/dist/twins/packs/hackernews/NOTICE +7 -0
  170. package/dist/twins/packs/hackernews/index.mjs +35 -0
  171. package/dist/twins/packs/huggingface/LICENSE +202 -0
  172. package/dist/twins/packs/huggingface/NOTICE +7 -0
  173. package/dist/twins/packs/huggingface/index.mjs +9 -0
  174. package/dist/twins/packs/inngest/LICENSE +202 -0
  175. package/dist/twins/packs/inngest/NOTICE +7 -0
  176. package/dist/twins/packs/inngest/index.mjs +2 -0
  177. package/dist/twins/packs/instagram/LICENSE +202 -0
  178. package/dist/twins/packs/instagram/NOTICE +7 -0
  179. package/dist/twins/packs/instagram/index.mjs +2 -0
  180. package/dist/twins/packs/jira/LICENSE +202 -0
  181. package/dist/twins/packs/jira/NOTICE +7 -0
  182. package/dist/twins/packs/jira/index.mjs +2 -0
  183. package/dist/twins/packs/langfuse/LICENSE +202 -0
  184. package/dist/twins/packs/langfuse/NOTICE +7 -0
  185. package/dist/twins/packs/langfuse/index.mjs +2 -0
  186. package/dist/twins/packs/linear/LICENSE +202 -0
  187. package/dist/twins/packs/linear/NOTICE +7 -0
  188. package/dist/twins/packs/linear/index.mjs +52866 -0
  189. package/dist/twins/packs/linkedin/LICENSE +202 -0
  190. package/dist/twins/packs/linkedin/NOTICE +7 -0
  191. package/dist/twins/packs/linkedin/index.mjs +78 -0
  192. package/dist/twins/packs/livekit/LICENSE +202 -0
  193. package/dist/twins/packs/livekit/NOTICE +7 -0
  194. package/dist/twins/packs/livekit/index.mjs +2 -0
  195. package/dist/twins/packs/mailgun/LICENSE +202 -0
  196. package/dist/twins/packs/mailgun/NOTICE +7 -0
  197. package/dist/twins/packs/mailgun/index.mjs +13 -0
  198. package/dist/twins/packs/mapbox/LICENSE +202 -0
  199. package/dist/twins/packs/mapbox/NOTICE +7 -0
  200. package/dist/twins/packs/mapbox/index.mjs +2 -0
  201. package/dist/twins/packs/merge/LICENSE +202 -0
  202. package/dist/twins/packs/merge/NOTICE +7 -0
  203. package/dist/twins/packs/merge/index.mjs +4 -0
  204. package/dist/twins/packs/mistral/LICENSE +202 -0
  205. package/dist/twins/packs/mistral/NOTICE +7 -0
  206. package/dist/twins/packs/mistral/index.mjs +6 -0
  207. package/dist/twins/packs/mixpanel/LICENSE +202 -0
  208. package/dist/twins/packs/mixpanel/NOTICE +8 -0
  209. package/dist/twins/packs/mixpanel/index.mjs +2 -0
  210. package/dist/twins/packs/mongodb/LICENSE +202 -0
  211. package/dist/twins/packs/mongodb/NOTICE +7 -0
  212. package/dist/twins/packs/mongodb/index.mjs +8 -0
  213. package/dist/twins/packs/moonshot/LICENSE +202 -0
  214. package/dist/twins/packs/moonshot/NOTICE +7 -0
  215. package/dist/twins/packs/moonshot/index.mjs +18 -0
  216. package/dist/twins/packs/notion/LICENSE +202 -0
  217. package/dist/twins/packs/notion/NOTICE +7 -0
  218. package/dist/twins/packs/notion/index.mjs +2 -0
  219. package/dist/twins/packs/npm-registry/LICENSE +202 -0
  220. package/dist/twins/packs/npm-registry/NOTICE +7 -0
  221. package/dist/twins/packs/npm-registry/index.mjs +2 -0
  222. package/dist/twins/packs/oa-treasury/LICENSE +202 -0
  223. package/dist/twins/packs/oa-treasury/NOTICE +8 -0
  224. package/dist/twins/packs/oa-treasury/index.mjs +16 -0
  225. package/dist/twins/packs/openai/LICENSE +202 -0
  226. package/dist/twins/packs/openai/NOTICE +7 -0
  227. package/dist/twins/packs/openai/index.mjs +3473 -0
  228. package/dist/twins/packs/openrouter/LICENSE +202 -0
  229. package/dist/twins/packs/openrouter/NOTICE +7 -0
  230. package/dist/twins/packs/openrouter/index.mjs +2 -0
  231. package/dist/twins/packs/openweather/LICENSE +202 -0
  232. package/dist/twins/packs/openweather/NOTICE +7 -0
  233. package/dist/twins/packs/openweather/index.mjs +2 -0
  234. package/dist/twins/packs/paypal/LICENSE +202 -0
  235. package/dist/twins/packs/paypal/NOTICE +7 -0
  236. package/dist/twins/packs/paypal/index.mjs +51 -0
  237. package/dist/twins/packs/pinecone/LICENSE +202 -0
  238. package/dist/twins/packs/pinecone/NOTICE +7 -0
  239. package/dist/twins/packs/pinecone/index.mjs +2 -0
  240. package/dist/twins/packs/plain/LICENSE +202 -0
  241. package/dist/twins/packs/plain/NOTICE +8 -0
  242. package/dist/twins/packs/plain/index.mjs +18426 -0
  243. package/dist/twins/packs/planetscale/LICENSE +202 -0
  244. package/dist/twins/packs/planetscale/NOTICE +7 -0
  245. package/dist/twins/packs/planetscale/index.mjs +18 -0
  246. package/dist/twins/packs/polar/LICENSE +202 -0
  247. package/dist/twins/packs/polar/NOTICE +7 -0
  248. package/dist/twins/packs/polar/index.mjs +2 -0
  249. package/dist/twins/packs/polyhaven/LICENSE +202 -0
  250. package/dist/twins/packs/polyhaven/NOTICE +7 -0
  251. package/dist/twins/packs/polyhaven/index.mjs +3 -0
  252. package/dist/twins/packs/postmark/LICENSE +202 -0
  253. package/dist/twins/packs/postmark/NOTICE +7 -0
  254. package/dist/twins/packs/postmark/index.mjs +12 -0
  255. package/dist/twins/packs/reddit/LICENSE +202 -0
  256. package/dist/twins/packs/reddit/NOTICE +7 -0
  257. package/dist/twins/packs/reddit/index.mjs +324 -0
  258. package/dist/twins/packs/redis/LICENSE +202 -0
  259. package/dist/twins/packs/redis/NOTICE +7 -0
  260. package/dist/twins/packs/redis/index.mjs +2 -0
  261. package/dist/twins/packs/replicate/LICENSE +202 -0
  262. package/dist/twins/packs/replicate/NOTICE +7 -0
  263. package/dist/twins/packs/replicate/index.mjs +2 -0
  264. package/dist/twins/packs/resend/LICENSE +202 -0
  265. package/dist/twins/packs/resend/NOTICE +7 -0
  266. package/dist/twins/packs/resend/index.mjs +139 -0
  267. package/dist/twins/packs/runhuman/LICENSE +202 -0
  268. package/dist/twins/packs/runhuman/NOTICE +7 -0
  269. package/dist/twins/packs/runhuman/index.mjs +3 -0
  270. package/dist/twins/packs/scrapecreators/LICENSE +202 -0
  271. package/dist/twins/packs/scrapecreators/NOTICE +7 -0
  272. package/dist/twins/packs/scrapecreators/index.mjs +2 -0
  273. package/dist/twins/packs/segment/LICENSE +202 -0
  274. package/dist/twins/packs/segment/NOTICE +8 -0
  275. package/dist/twins/packs/segment/index.mjs +2 -0
  276. package/dist/twins/packs/sendblue/LICENSE +202 -0
  277. package/dist/twins/packs/sendblue/NOTICE +7 -0
  278. package/dist/twins/packs/sendblue/index.mjs +2 -0
  279. package/dist/twins/packs/sendgrid/LICENSE +202 -0
  280. package/dist/twins/packs/sendgrid/NOTICE +8 -0
  281. package/dist/twins/packs/sendgrid/index.mjs +4 -0
  282. package/dist/twins/packs/sentry/LICENSE +202 -0
  283. package/dist/twins/packs/sentry/NOTICE +7 -0
  284. package/dist/twins/packs/sentry/index.mjs +5 -0
  285. package/dist/twins/packs/sigstore/LICENSE +202 -0
  286. package/dist/twins/packs/sigstore/NOTICE +7 -0
  287. package/dist/twins/packs/sigstore/index.mjs +12 -0
  288. package/dist/twins/packs/slack/LICENSE +202 -0
  289. package/dist/twins/packs/slack/NOTICE +7 -0
  290. package/dist/twins/packs/slack/index.mjs +66 -0
  291. package/dist/twins/packs/smtp/LICENSE +202 -0
  292. package/dist/twins/packs/smtp/NOTICE +7 -0
  293. package/dist/twins/packs/smtp/index.mjs +3 -0
  294. package/dist/twins/packs/snowflake/LICENSE +202 -0
  295. package/dist/twins/packs/snowflake/NOTICE +8 -0
  296. package/dist/twins/packs/snowflake/index.mjs +30 -0
  297. package/dist/twins/packs/stigg/LICENSE +202 -0
  298. package/dist/twins/packs/stigg/NOTICE +8 -0
  299. package/dist/twins/packs/stigg/index.mjs +22194 -0
  300. package/dist/twins/packs/stream/LICENSE +202 -0
  301. package/dist/twins/packs/stream/NOTICE +7 -0
  302. package/dist/twins/packs/stream/index.mjs +2 -0
  303. package/dist/twins/packs/stripe/LICENSE +202 -0
  304. package/dist/twins/packs/stripe/NOTICE +7 -0
  305. package/dist/twins/packs/stripe/index.mjs +211 -0
  306. package/dist/twins/packs/supabase/LICENSE +202 -0
  307. package/dist/twins/packs/supabase/NOTICE +7 -0
  308. package/dist/twins/packs/supabase/index.mjs +2 -0
  309. package/dist/twins/packs/supermemory/LICENSE +202 -0
  310. package/dist/twins/packs/supermemory/NOTICE +7 -0
  311. package/dist/twins/packs/supermemory/index.mjs +2 -0
  312. package/dist/twins/packs/svix/LICENSE +202 -0
  313. package/dist/twins/packs/svix/NOTICE +7 -0
  314. package/dist/twins/packs/svix/index.mjs +2 -0
  315. package/dist/twins/packs/tavily/LICENSE +202 -0
  316. package/dist/twins/packs/tavily/NOTICE +7 -0
  317. package/dist/twins/packs/tavily/index.mjs +2 -0
  318. package/dist/twins/packs/telegram/LICENSE +202 -0
  319. package/dist/twins/packs/telegram/NOTICE +7 -0
  320. package/dist/twins/packs/telegram/index.mjs +11 -0
  321. package/dist/twins/packs/temporal/LICENSE +202 -0
  322. package/dist/twins/packs/temporal/NOTICE +7 -0
  323. package/dist/twins/packs/temporal/index.mjs +44 -0
  324. package/dist/twins/packs/tiktok/LICENSE +202 -0
  325. package/dist/twins/packs/tiktok/NOTICE +7 -0
  326. package/dist/twins/packs/tiktok/index.mjs +2 -0
  327. package/dist/twins/packs/tinybird/LICENSE +202 -0
  328. package/dist/twins/packs/tinybird/NOTICE +7 -0
  329. package/dist/twins/packs/tinybird/index.mjs +50 -0
  330. package/dist/twins/packs/togetherai/LICENSE +202 -0
  331. package/dist/twins/packs/togetherai/NOTICE +7 -0
  332. package/dist/twins/packs/togetherai/index.mjs +11 -0
  333. package/dist/twins/packs/tremendous/LICENSE +202 -0
  334. package/dist/twins/packs/tremendous/NOTICE +7 -0
  335. package/dist/twins/packs/tremendous/index.mjs +2 -0
  336. package/dist/twins/packs/tripo/LICENSE +202 -0
  337. package/dist/twins/packs/tripo/NOTICE +7 -0
  338. package/dist/twins/packs/tripo/index.mjs +9 -0
  339. package/dist/twins/packs/tunnel/LICENSE +202 -0
  340. package/dist/twins/packs/tunnel/NOTICE +7 -0
  341. package/dist/twins/packs/tunnel/index.mjs +2 -0
  342. package/dist/twins/packs/twelvelabs/LICENSE +202 -0
  343. package/dist/twins/packs/twelvelabs/NOTICE +7 -0
  344. package/dist/twins/packs/twelvelabs/index.mjs +5 -0
  345. package/dist/twins/packs/twilio/LICENSE +202 -0
  346. package/dist/twins/packs/twilio/NOTICE +7 -0
  347. package/dist/twins/packs/twilio/index.mjs +2 -0
  348. package/dist/twins/packs/twitch/LICENSE +202 -0
  349. package/dist/twins/packs/twitch/NOTICE +7 -0
  350. package/dist/twins/packs/twitch/index.mjs +68 -0
  351. package/dist/twins/packs/upstash/LICENSE +202 -0
  352. package/dist/twins/packs/upstash/NOTICE +7 -0
  353. package/dist/twins/packs/upstash/index.mjs +14 -0
  354. package/dist/twins/packs/upstashvector/LICENSE +202 -0
  355. package/dist/twins/packs/upstashvector/NOTICE +7 -0
  356. package/dist/twins/packs/upstashvector/index.mjs +3 -0
  357. package/dist/twins/packs/vercel/LICENSE +202 -0
  358. package/dist/twins/packs/vercel/NOTICE +7 -0
  359. package/dist/twins/packs/vercel/index.mjs +10 -0
  360. package/dist/twins/packs/veriff/LICENSE +202 -0
  361. package/dist/twins/packs/veriff/NOTICE +7 -0
  362. package/dist/twins/packs/veriff/index.mjs +2 -0
  363. package/dist/twins/packs/vgauth/LICENSE +202 -0
  364. package/dist/twins/packs/vgauth/NOTICE +7 -0
  365. package/dist/twins/packs/vgauth/index.mjs +2 -0
  366. package/dist/twins/packs/vital/LICENSE +202 -0
  367. package/dist/twins/packs/vital/NOTICE +7 -0
  368. package/dist/twins/packs/vital/index.mjs +2 -0
  369. package/dist/twins/packs/volteridentity/LICENSE +202 -0
  370. package/dist/twins/packs/volteridentity/NOTICE +7 -0
  371. package/dist/twins/packs/volteridentity/index.mjs +2 -0
  372. package/dist/twins/packs/webrisk/LICENSE +202 -0
  373. package/dist/twins/packs/webrisk/NOTICE +7 -0
  374. package/dist/twins/packs/webrisk/index.mjs +2 -0
  375. package/dist/twins/packs/worldlabs/LICENSE +202 -0
  376. package/dist/twins/packs/worldlabs/NOTICE +7 -0
  377. package/dist/twins/packs/worldlabs/index.mjs +2 -0
  378. package/dist/twins/packs/x/LICENSE +202 -0
  379. package/dist/twins/packs/x/NOTICE +7 -0
  380. package/dist/twins/packs/x/index.mjs +63 -0
  381. package/dist/twins/packs/xai/LICENSE +202 -0
  382. package/dist/twins/packs/xai/NOTICE +7 -0
  383. package/dist/twins/packs/xai/index.mjs +4 -0
  384. package/dist/twins/packs/xidentity/LICENSE +202 -0
  385. package/dist/twins/packs/xidentity/NOTICE +8 -0
  386. package/dist/twins/packs/xidentity/index.mjs +209 -0
  387. package/dist/twins/packs/youtube/LICENSE +202 -0
  388. package/dist/twins/packs/youtube/NOTICE +7 -0
  389. package/dist/twins/packs/youtube/index.mjs +5 -0
  390. package/dist/worker.js +442 -18
  391. package/dist/world-host.js +928 -91
  392. package/package.json +5 -4
  393. package/dist/dashboard/assets/dashboard/bay-morning.png +0 -0
  394. package/dist/dashboard/assets/dashboard/golden-gate-afternoon.png +0 -0
  395. package/dist/dashboard/assets/dashboard/golden-gate-portrait.png +0 -0
  396. package/dist/dashboard/assets/dashboard/moonlit-coast.png +0 -0
  397. package/dist/dashboard/assets/next/static/chunks/2868-424d32cfc8ae81c9.js +0 -1
  398. package/dist/dashboard/assets/next/static/chunks/app/docs/[[...slug]]/page-f9fca2c08f779fa0.js +0 -1
  399. package/dist/dashboard/assets/next/static/chunks/app/onboarding/page-bc480c9258e5cc4d.js +0 -1
  400. package/dist/dashboard/assets/next/static/chunks/app/v2/onboarding/page-f04c0b236abaead3.js +0 -1
  401. package/dist/dashboard/assets/next/static/css/4af3c8ca0da0f48b.css +0 -1
  402. package/dist/dashboard/assets/next/static/css/6b8edde77e493a51.css +0 -1
  403. package/dist/dashboard/assets/next/static/media/bay-morning.1a9f358c.png +0 -0
  404. package/dist/dashboard/assets/next/static/media/golden-gate-afternoon.3e7cea58.png +0 -0
  405. package/dist/dashboard/assets/next/static/media/golden-gate-portrait.7941528f.png +0 -0
  406. package/dist/dashboard/assets/next/static/media/moonlit-coast.bbe901a1.png +0 -0
  407. /package/dist/dashboard/assets/next/static/{5ub3D2yzS8DE7w2qZd1nv → 8f121VqXS9LLPMmYd1SRn}/_buildManifest.js +0 -0
  408. /package/dist/dashboard/assets/next/static/{5ub3D2yzS8DE7w2qZd1nv → 8f121VqXS9LLPMmYd1SRn}/_ssgManifest.js +0 -0
@@ -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-inngest
2
+
3
+ Contains @volter/twin-inngest 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
+ var ht=Object.defineProperty;var _t=(t,e)=>()=>(t&&(e=t(t=0)),e);var Et=(t,e)=>{for(var n in e)ht(t,n,{get:e[n],enumerable:!0})};var it={};Et(it,{INNGEST_SIGNING_KEY_TYPE:()=>x,InngestSignatureError:()=>h,buildInngestSignatureHeader:()=>rt,inngestSigningKey:()=>nt,mintInngestSigningKey:()=>U,signInngestRequest:()=>R,storedInngestSigningKey:()=>B,verifyInngestSignature:()=>st});import{applyTwinWriteAtomic as Ot,projectResources as Dt,nodeBuiltin as $t,worldNow as Bt}from"../../engine/v2/volter_world-core.mjs";function $(){return $t("node:crypto")}function D(t){return t===null||typeof t!="object"?JSON.stringify(t):Array.isArray(t)?`[${t.map(D).join(",")}]`:`{${Object.keys(t).sort().map(n=>`${JSON.stringify(n)}:${D(t[n])}`).join(",")}}`}function et(t){let n=t.find(r=>r.type===x&&r.id===tt)?._key;return typeof n=="string"&&n.length>0?n:void 0}function B(t){return et(Dt(q,t))}function U(){return`signkey-prod-${$().randomBytes(32).toString("hex")}`}async function nt(t){let e=B(t);if(e)return e;let{value:n}=await Ot(q,r=>{let i=et(r);if(i)return{kind:"skip",value:i};let o=U();return{kind:"write",value:o,write:{operation:"signing_key.create",subjectType:x,subjectId:tt,fields:{_key:o},actor:{kind:"system"}}}},t);return n}function Ut(t){return t.replace(/^signkey-[\w]+-/,"")}function R(t,e,n){let r=`${D(t)}${e}`;return $().createHmac("sha256",Ut(n)).update(r).digest("hex")}function rt(t,e,n){let r=R(t,e,n);return`t=${e}&s=${r}`}function Ct(t){let e=new URLSearchParams(t),n=Number(e.get("t")),r=e.get("s")??"";if(!Number.isFinite(n)||!r)throw new h(`Invalid x-inngest-signature header: "${t}"`);return{t:n,s:r}}function st(t,e,n,r={}){let{t:i,s:o}=Ct(e),s=r.now??Math.floor(Date.parse(Bt())/1e3),a=r.toleranceSec??300;if(Math.abs(s-i)>a)throw new h(`Signature timestamp outside the ${a}s tolerance.`);let u=R(t,i,n),d=Buffer.from(u,"hex"),E=Buffer.from(o,"hex");if(!(d.length===E.length&&d.length>0&&$().timingSafeEqual(d,E)))throw new h("Signature verification failed.")}var h,q,x,tt,C=_t(()=>{h=class extends Error{constructor(e){super(e),this.name="InngestSignatureError"}},q="inngest",x="signing_key",tt="signing_key:executor"});import{worldNow as Pt}from"../../engine/v2/volter_world-core.mjs";import{applyTwinWrite as St,projectResources as vt,worldNow as Tt}from"../../engine/v2/volter_world-core.mjs";import{createHash as A}from"node:crypto";var K="inngest",wt=4;function Nt(t,e){return`${t}:${e}`}function p(t){return t??Tt()}function T(t){return t===null||typeof t!="object"?JSON.stringify(t):Array.isArray(t)?`[${t.map(T).join(",")}]`:`{${Object.keys(t).sort().map(n=>`${JSON.stringify(n)}:${T(t[n])}`).join(",")}}`}function bt(t,e,n){return`[twin-stub:inngest:${A("sha256").update(`${t}::${e}::${T(n)}`).digest("hex").slice(0,8)}]`}var W="0123456789ABCDEFGHJKMNPQRSTVWXYZ";function xt(t,e){let n="",r=Math.max(0,Math.floor(t));for(let s=0;s<10;s++)n=W[r%32]+n,r=Math.floor(r/32);let i="",o=A("sha256").update(e).digest("hex");for(let s=0;s<16;s++)i+=W[parseInt(o[s],16)%32];return n+i}function Rt(t){let e=A("sha256").update(t).digest("hex");return`${e.slice(0,8)}-${e.slice(8,12)}-4${e.slice(13,16)}-8${e.slice(17,20)}-${e.slice(20,32)}`}function l(t,e){let n=`${t}:`;return vt(K,e).filter(r=>r.type===t&&r.id.startsWith(n)&&r._deleted!==!0).map(r=>({...r,id:r.id.slice(n.length)}))}function y(t,e,n){return l(t,n).find(r=>r.id===e)}function It(t){let{type:e,updatedAt:n,...r}=t,i={};for(let[o,s]of Object.entries(r))o.startsWith("_")||(i[o]=s);return i}async function c(t,e,n,r,i,o){let{resource:s}=await St(K,{operation:r,subjectType:t,subjectId:Nt(t,e),fields:n,...o?{occurredAt:o}:{},actor:{kind:"agent"}},i);return It({...s,id:e})}async function H(t,e,n){let r=y("function",t.id,e),i={fn_id:t.id,triggers:t.triggers,step_plan:t.steps,config:t.config??{},cancel_on:t.cancelOn??[],url:t.url??null,registered_at:p(n)},o=a=>({triggers:a.triggers,step_plan:a.step_plan,config:a.config,cancel_on:a.cancel_on,url:a.url});if(r){let a=o(r),u=o(i);if(T(a)===T(u))return{row:r,modified:!1,skipped:!0}}return{row:await c("function",t.id,i,r?"function.reregister":"function.register",e,n),modified:!0,skipped:!1}}function b(t){return l("function",t)}function V(t,e){return b(e).filter(n=>n.triggers.some(r=>r.event===t))}function Y(t,e){return b(e).filter(n=>(n.cancel_on??[]).some(r=>r.event===t))}function Gt(t,e,n){return l("event",n).find(r=>r.name===t&&r.idempotency_id===e)}async function J(t,e,n){if(t.id){let o=Gt(t.name,t.id,e);if(o)return{id:o.id,deduped:!0}}let r=p(n),i=xt(Date.parse(r),`event:${t.name}:${r}:${l("event",e).length}`);return await c("event",i,{name:t.name,data:t.data??{},user:t.user??null,idempotency_id:t.id??null,ts:t.ts??Date.parse(p(n)),received_at:p(n),v:t.v??null},"event.send",e,n),{id:i,deduped:!1}}async function Q(t,e,n,r){let i=Rt(`run:${t}:${e}:${p(r)}:${l("run",n).length}`);return c("run",i,{function_id:t,event_id:e,status:"QUEUED",cursor:0,output:null,error:null,created_at:p(r),started_at:null,ended_at:null},"run.create",n,r)}function X(t,e){return l("run",e).filter(n=>n.event_id===t)}function kt(t,e){return l("run",e).filter(n=>n.function_id===t)}var z=new Set(["COMPLETED","FAILED","CANCELLED"]);async function Z(t,e,n){let r=[];for(let i of kt(t,e)){if(z.has(i.status))continue;let o=await c("run",i.id,{status:"CANCELLED",ended_at:p(n)},"run.cancel_via_event",e,n);r.push(o)}return r}function g(t,e){return`${t}::${e}`}function k(t,e,n){return y("step",g(t,e),n)}function At(t,e,n,r){let i={};for(let o=0;o<n;o++){let s=e[o],a=k(t,s.id,r);a&&a.state==="completed"&&(i[s.id]=a.output??null)}return i}async function O(t,e,n){let r=y("run",t,e);if(!r)return;let i=r.status;if(z.has(i))return{run:r};if(i==="QUEUED")return{run:await c("run",t,{status:"RUNNING",started_at:p(n)},"run.start",e,n)};let o=y("function",r.function_id,e);if(!o)return{run:r};let s=o.step_plan??[],a=r.cursor;if(a>=s.length){if(i!=="COMPLETED"){let f=s.length>0?k(t,s[s.length-1].id,e):void 0;return{run:await c("run",t,{status:"COMPLETED",output:f?.output??null,ended_at:p(n)},"run.complete",e,n)}}return{run:r}}let u=s[a],d=k(t,u.id,e);if(u.op==="Sleep"){if(d?.state==="completed")return{run:await c("run",t,{cursor:a+1},"run.advance",e,n),step:d};let f=await c("step",g(t,u.id),{run_id:t,step_id:u.id,op:"Sleep",output:null,attempts:1,state:"completed"},"step.sleep",e,n);return{run:await c("run",t,{cursor:a+1},"run.advance",e,n),step:f}}if(u.op==="WaitForEvent"){let f=u.eventName??"";if(!d){let S=await c("step",g(t,u.id),{run_id:t,step_id:u.id,op:"WaitForEvent",wait_event_name:f,waiting_since:p(n),output:null,attempts:1,state:"waiting"},"step.wait_created",e,n);return{run:r,step:S}}if(d.state==="waiting"){let S=d.waiting_since,N=l("event",e).find(v=>v.name===f&&v.received_at>=S);if(N){let v=await c("step",g(t,u.id),{state:"completed",output:{name:N.name,data:N.data}},"step.wait_resolved",e,n);return{run:await c("run",t,{cursor:a+1},"run.advance",e,n),step:v}}let G=d.attempts+1;if(u.timeoutAfterPolls!==void 0&&G>=u.timeoutAfterPolls){let v=await c("step",g(t,u.id),{state:"completed",output:null,attempts:G},"step.wait_timeout",e,n);return{run:await c("run",t,{cursor:a+1},"run.advance",e,n),step:v}}let mt=await c("step",g(t,u.id),{attempts:G},"step.wait_poll",e,n);return{run:r,step:mt}}return{run:r,step:d}}if(d?.state==="completed")return{run:await c("run",t,{cursor:a+1},"run.advance",e,n),step:d};let E=u.failTimes??0,w=o?.config?.retries??wt,m=(d?.attempts??0)+1;if(m>w){let f=await c("step",g(t,u.id),{run_id:t,step_id:u.id,op:u.op,state:"failed",attempts:m,error:"max attempts exceeded",output:null},"step.retry_exhausted",e,n);return{run:await c("run",t,{status:"FAILED",error:{step:u.id,message:"max attempts exceeded"},ended_at:p(n)},"run.fail",e,n),step:f}}if(m<=E){let f=await c("step",g(t,u.id),{run_id:t,step_id:u.id,op:u.op,state:"failed",attempts:m,error:`stub failure ${m}`,output:null},"step.retry",e,n);return{run:r,step:f}}let pt={priorOutputs:At(t,s,a,e),stepId:u.id},lt=u.output!==void 0?u.output:bt(t,u.id,pt),gt=await c("step",g(t,u.id),{run_id:t,step_id:u.id,op:u.op,state:"completed",attempts:m,error:null,output:lt},"step.run",e,n);return{run:await c("run",t,{cursor:a+1},"run.advance",e,n),step:gt}}function ot(t){let e=(t.path.split("?")[0]??"/").replace(/\/+$/,"")||"/";return e.startsWith("/e/")?"event":e==="/api/inngest"||e==="/fn/register"?"exec":e.startsWith("/api/v2/")?"api":"exec"}function I(t,e,n){return{status:t,body:{errors:[{code:e,message:n}]}}}function _(t,e){return{status:t,body:{error:e}}}function P(t){if(!(t===void 0||t===""))try{return JSON.parse(t)}catch{return{__parseError:!0}}}function F(t){return t??Pt()}var Ft={QUEUED:"QUEUED",RUNNING:"RUNNING",COMPLETED:"COMPLETED",FAILED:"FAILED",CANCELLED:"CANCELLED"};function L(t){return{id:t.id,function_id:t.function_id,event_id:t.event_id,status:Ft[t.status]??t.status,cursor:t.cursor,output:t.output??null,error:t.error??null,created_at:t.created_at,started_at:t.started_at??null,ended_at:t.ended_at??null}}function Lt(t){return{run_id:t.run_id,step_id:t.step_id,op:t.op,state:t.state,attempts:t.attempts,output:t.output??null,error:t.error??null}}function jt(t){return{id:t.fn_id,triggers:t.triggers,steps:t.step_plan,config:t.config,cancel_on:t.cancel_on,url:t.url??null}}function Mt(t){return t===void 0?{ok:!0,events:[]}:Array.isArray(t)?t.some(e=>typeof e!="object"||e===null)?{ok:!1}:{ok:!0,events:t}:typeof t=="object"&&t!==null?{ok:!0,events:[t]}:{ok:!1}}async function Wt(t,e){let n=P(t),r=Mt(n);if(!r.ok)return _(400,"Event payload must be an object or an array of objects.");if(r.events.length===0)return{status:200,body:{ids:[],status:200}};let i=[];for(let o of r.events){let s=o.name;if(typeof s!="string"||s.length===0)return _(400,'Event payload must include a "name" (string).');let{id:a,deduped:u}=await J({name:s,data:o.data,user:o.user,id:typeof o.id=="string"?o.id:void 0,ts:typeof o.ts=="number"?o.ts:void 0,v:typeof o.v=="string"?o.v:void 0},e.root,e.occurredAt);if(i.push(a),!u){for(let d of V(s,e.root))await Q(d.fn_id,a,e.root,e.occurredAt);for(let d of Y(s,e.root))await Z(d.fn_id,e.root,e.occurredAt)}}return{status:200,body:{ids:i,status:200}}}function Kt(t){let e=t.id,n=t.op;if(typeof e!="string"||n!=="StepRun"&&n!=="Sleep"&&n!=="WaitForEvent"&&n!=="InvokeFunction")return;let r={id:e,op:n};return typeof t.eventName=="string"&&(r.eventName=t.eventName),typeof t.timeoutAfterPolls=="number"&&(r.timeoutAfterPolls=t.timeoutAfterPolls),typeof t.failTimes=="number"&&(r.failTimes=t.failTimes),"output"in t&&(r.output=t.output),r}async function Ht(t,e){let n=P(t),r=n?.functions;if(!Array.isArray(r)||r.length===0)return _(400,'Register body must include a non-empty "functions" array.');let i=!1,o=!0;for(let s of r){if(typeof s.id!="string")return _(400,'Every function must have a string "id".');let a=Array.isArray(s.triggers)?s.triggers:[],u=Array.isArray(s.steps)?s.steps.map(Kt).filter(m=>m!==void 0):[],d={id:s.id,triggers:a,steps:u,config:s.config??{},cancelOn:Array.isArray(s.cancelOn)?s.cancelOn:[],url:typeof n?.url=="string"?n.url:void 0},{modified:E,skipped:w}=await H(d,e.root,e.occurredAt);E&&(i=!0),w||(o=!1)}return{status:200,body:{status:200,error:"Successfully registered",skipped:o,modified:i}}}function Vt(t){let e=b(t.root);return{status:200,body:{function_count:e.length,functions:e.map(jt),mode:"dev",sdk_language:"js",sdk_version:"4.12.0",authentication_succeeded:!1}}}async function Yt(t,e){let r=P(t)?.runId;if(typeof r!="string")return _(400,'Invoke body must include "runId" (twin-only exec-protocol simplification \u2014 see inngest-twin.ts header).');let i=await O(r,e.root,e.occurredAt);return i?{status:200,body:{run:L(i.run),...i.step?{step:Lt(i.step)}:{}}}:I(404,"run_not_found",`No run with id "${r}".`)}async function Jt(t,e){let n=y("run",t,e.root);if(!n)return I(404,"run_not_found",`No run with id "${t}".`);let i=(e.readOnly?void 0:await O(t,e.root,e.occurredAt))?.run??n;return{status:200,body:{data:L(i),metadata:{fetchedAt:F(e.occurredAt)}}}}function Qt(t,e){if(!y("event",t,e.root))return I(404,"event_not_found",`No event with id "${t}".`);let r=X(t,e.root).map(L);return{status:200,body:{data:r,metadata:{fetchedAt:F(e.occurredAt)},page:{cursor:"",hasMore:!1,limit:r.length}}}}async function Xt(t){if(!t.readOnly){let{inngestSigningKey:e}=await Promise.resolve().then(()=>(C(),it));await e(t.root)}return{status:200,body:{data:[{id:"signing-key",key:"signkey-prod-***"}],metadata:{fetchedAt:F(t.occurredAt)}}}}async function j(t){let e=t.method.toUpperCase(),[n]=t.path.split("?"),r=(n??"/").replace(/\/+$/,"")||"/",i=ot({host:t.host,headers:t.headers,path:r,method:e});if(t.readOnly&&e!=="GET"&&e!=="HEAD")return{status:405,body:{error:"read_only",hint:"this twin was started read-only; omit readOnly to accept writes"}};if(r==="/"||r==="")return{status:200,body:{service:"inngest",object:"twin"}};if(i==="event")return e==="POST"?Wt(t.body,t):_(404,"not found");if(i==="exec")return e==="PUT"&&r==="/api/inngest"||e==="POST"&&r==="/fn/register"?Ht(t.body,t):e==="GET"&&r==="/api/inngest"?Vt(t):e==="POST"&&r==="/api/inngest"?Yt(t.body,t):_(404,"not found");let s=r.replace(/^\/+/,"").split("/").filter(Boolean).slice(2);return e==="GET"&&s[0]==="runs"&&s.length===2?Jt(decodeURIComponent(s[1]),t):e==="GET"&&s[0]==="events"&&s.length===3&&s[2]==="runs"?Qt(decodeURIComponent(s[1]),t):e==="GET"&&s[0]==="keys"&&s[1]==="signing"?Xt(t):I(404,"not_found",`No route for ${e} ${r}`)}import{serveHttp as ge}from"../../engine/v2/volter_world-core.mjs";import{createTwinFetchFromHandler as zt,statefulTwinManifest as Zt,withRequestScopes as qt}from"../../engine/v2/volter_world-core.mjs";function ut(t={}){return qt(zt(j,{...t,manifest:Zt({vendor:"inngest",twinOf:"the Inngest durable-execution surface",stores:"events, registered functions and their kernel-persisted run state"}),stores:{events:()=>l("event",t.root),runs:()=>l("run",t.root)},extras:(e,n)=>({host:n.host})}),{refuse:()=>Response.json({error:"read_only",hint:"this twin was started read-only; omit readOnly to accept writes"},{status:405})})}import{syncPull as Ie}from"../../engine/v2/volter_world-core.mjs";import{declareRateBudget as te,rateBudgetPath as Se,rateBudgetWeight as ve,RateBudget as Te,RateBudgetError as we}from"../../engine/v2/volter_world-core.mjs";import{RateBudgetError as ne}from"../../engine/v2/volter_world-core.mjs";var ee="inngest",at=6e4,ct=60,dt=300,ft={other:2};var M={windowMs:at,ceiling:ct,defaultWeight:ft.other,maxRetryAfterSeconds:dt,rules:[],reason:`Inngest documents NO rate limit, no 429 and no Retry-After for the REST endpoints this connector calls (/v1/events, /v1/runs); its published usage limits are payload-shape limits (5000 events/request, 10 MiB batches) rather than rates. The only rate-limit statement in its whole API reference annotates a different endpoint ("fetch function run jobs \u2026 rate limited and cached for 5 seconds") and gives no number. With no documented figure to aim at, this ceiling is pinned to the kernel's conservative fallback (60 units / 60s at weight 2 = 30 calls/min) rather than invented \u2014 no more permissive than an undeclared vendor already gets. Weights are flat because both modeled endpoints are single fetch-by-id reads and no per-endpoint rate is published.`};te(ee,M);C();export{ut 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-instagram
2
+
3
+ Contains @volter/twin-instagram 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 Me,applyTwinWriteAtomic as Tn,blobDigest as Ue,ownFields as In,projectResources as Rn,resolveSubjectId as $n,subjectAliases as xn,worldNow as St}from"../../engine/v2/volter_world-core.mjs";import{blobDigest as sn}from"../../engine/v2/volter_world-core.mjs";var Ie={"content-type":"application/json; charset=UTF-8"},an="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_";function dn(e){let r=sn(new TextEncoder().encode(e)),n="";for(let t=0;t<11;t+=1)n+=an[parseInt(r.slice(t*2,t*2+2),16)%64];return n}function T(e,r,n,t={}){return{status:e,headers:{...Ie},body:{error:{message:n,type:t.type??"OAuthException",code:r,...t.subcode!==void 0?{error_subcode:t.subcode}:{},is_transient:t.transient??!1,...t.title?{error_user_title:t.title}:{},...t.userMsg?{error_user_msg:t.userMsg}:{},fbtrace_id:dn(`${e}|${r}|${t.subcode??""}|${n}`)}}}}var tt=()=>T(400,104,"An access token is required to request this resource."),nt=()=>T(400,190,"Invalid OAuth access token - Cannot parse access token"),K=e=>T(400,10,`(#10) Application does not have permission for this action: ${e}`),x=(e,r)=>T(400,100,`Unsupported ${e.toLowerCase()} request. Object with ID '${r}' does not exist, cannot be loaded due to missing permissions, or does not support this operation. Please read the Graph API documentation at https://developers.facebook.com/docs/graph-api`,{type:"GraphMethodException",subcode:33}),Z=e=>T(400,2500,`Unknown path components: ${e}`),y=(e,r)=>T(400,100,`(#100) ${e}`,r!==void 0?{subcode:r}:{}),de=e=>T(400,100,`(#100) The parameter ${e} is required`),A=e=>T(422,100,`[twin gap] ${e} is real Instagram Platform surface this twin does not model`),ue=()=>T(405,3,"(#3) This twin is read-only");function v(e,r=200){return{status:r,body:e,headers:{...Ie}}}var rt=()=>v({success:!0,message:"Upload successful."});function I(e,r,n,t=!1){return{status:e,headers:{...Ie},body:{debug_info:{retriable:t,type:r,message:JSON.stringify({success:!1,error:{message:n}})}}}}import{join as O}from"node:path";import{blobDigest as ot,getActiveBlobStore as P,readBranchMeta as un,readResourceBlob as it,readResourceBlobRange as Nr,resourceBlobSize as Lr,worldPaths as Re}from"../../engine/v2/volter_world-core.mjs";var V="instagram",Q=3e8,cn=3e3,ln=15*6e4,fn=1920,mn=.01,pn=10,hn=23,gn=60,_n=48e3,wn=25128e3,W=24*36e5,bn=5e3,yn=2207026,En=2207057;function $e(e,r,n){return n?"PUBLISHED":r>=e.created_ms+W?"EXPIRED":e.uploaded_ms===void 0||r<e.uploaded_ms+bn?"IN_PROGRESS":e.error_subcode!==void 0?"ERROR":"FINISHED"}var G=e=>Re(V,e).resources,le=e=>O("blobs","sha256",e.slice(0,2),e),st=e=>O("containers",`${fe(e)}.json`),Sn=(e,r)=>O("container-chunks",fe(e),`${String(r).padStart(12,"0")}.part`);function X(e){return/^\d{1,25}$/.test(e)}function fe(e){if(!X(e))throw new Error(`invalid Instagram container id for storage: ${JSON.stringify(e)}`);return e}async function xe(e,r){let n=ot(e),t=O(G(r),le(n));return await P().exists(t)||await P().put(t,e),{sha256:n,size:e.length}}async function at(e,r){return typeof e!="string"||!/^[0-9a-f]{64}$/.test(e)?null:it(V,le(e),r)}async function me(e,r){await P().put(O(G(r),st(e.id)),new TextEncoder().encode(JSON.stringify(e)))}async function J(e,r){if(X(e))try{let n=await it(V,st(e),r);if(n===null)return;let t=JSON.parse(new TextDecoder().decode(n));return typeof t.id=="string"&&t.media_type==="REELS"?t:void 0}catch{return}}async function ve(e){let r=new Set,n=new Set,t=Re(V,e).root;for(;!n.has(t);){n.add(t);let i=`${O(Re(V,t).resources,"containers")}/`;for(let a of await P().list(i))a.startsWith(i)&&!a.slice(i.length).includes("/")&&a.endsWith(".json")&&r.add(a.slice(i.length,-5));let s=un(V,t)?.parent;if(!s)break;t=s.at}let o=[];for(let i of r){let s=await J(i,e);s&&o.push(s)}return o}async function dt(e,r,n,t){await P().put(O(G(t),Sn(e,r)),n)}async function ut(e,r){let n=`${O(G(r),"container-chunks",fe(e))}/`,t=(await P().list(n)).filter(i=>i.endsWith(".part")).sort(),o=[];for(let i of t){let s=await P().get(i);s&&o.push(s)}return o}async function ct(e,r){let n=`${O(G(r),"container-chunks",fe(e))}/`;for(let t of await P().list(n))try{await P().remove(t)}catch{}}var ce=new Map;async function lt(e,r,n){let t=`${G(r)}|${e}`,i=(ce.get(t)??Promise.resolve()).then(n,n),s=i.then(()=>{},()=>{});ce.set(t,s);try{return await i}finally{ce.get(t)===s&&ce.delete(t)}}var Ae=(e,r)=>O(G(r),"perform-containers",`${ot(new TextEncoder().encode(e))}.json`);async function ft(e,r){let n=await P().get(Ae(e,r));if(n===null)return null;try{let t=JSON.parse(new TextDecoder().decode(n));return typeof t.container=="string"&&typeof t.sha256=="string"&&typeof t.created_ms=="number"&&typeof t.uploaded=="number"&&typeof t.target=="string"?t:null}catch{return null}}async function pe(e,r,n){await P().put(Ae(e,n),new TextEncoder().encode(JSON.stringify(r)))}async function mt(e,r){try{await P().remove(Ae(e,r))}catch{}}function pt(e){let r=e,n=new DataView(r.buffer,r.byteOffset,r.byteLength),t=h=>String.fromCharCode(r[h+4],r[h+5],r[h+6],r[h+7]),o=(h,S)=>{let _=[],g=h;for(;g+8<=S;){let l=n.getUint32(g),b=8;if(l===1){if(g+16>S)break;l=Number(n.getBigUint64(g+8)),b=16}else l===0&&(l=S-g);if(l<b||g+l>S)break;_.push([t(g),g+b,g+l]),g+=l}return _},i=(h,S)=>h?o(h[1],h[2]).find(([_])=>_===S):void 0,s=o(0,r.length);if(s[0]?.[0]!=="ftyp")return;let a=String.fromCharCode(r[s[0][1]],r[s[0][1]+1],r[s[0][1]+2],r[s[0][1]+3]),d=s.findIndex(([h])=>h==="moov"),u=s.findIndex(([h])=>h==="mdat");if(d<0)return;let c=s[d],m=i(c,"mvhd");if(!m||m[2]-m[1]<32)return;let p=r[m[1]],E=p===1?n.getUint32(m[1]+20):n.getUint32(m[1]+12),w=p===1?Number(n.getBigUint64(m[1]+24)):n.getUint32(m[1]+16);if(E===0)return;let f={container:a==="qt "?"mov":"mp4",moovFirst:u<0||d<u,durationMs:Math.round(w*1e3/E),width:0,height:0,videoCodec:""};for(let h of o(c[1],c[2]).filter(([S])=>S==="trak")){let S=i(h,"mdia"),_=i(S,"hdlr"),g=_&&_[2]-_[1]>=12?String.fromCharCode(r[_[1]+8],r[_[1]+9],r[_[1]+10],r[_[1]+11]):"",l=i(i(S,"minf"),"stbl"),b=i(l,"stsd"),R=b&&b[2]-b[1]>=16?b[1]+8:void 0,qe=R!==void 0?t(R):"";if(g==="vide"&&f.videoCodec===""){f.videoCodec=qe;let ie=i(h,"tkhd");if(ie){let se=r[ie[1]],z=ie[1]+(se===1?88:76);z+8<=ie[2]&&(f.width=n.getUint32(z)>>>16,f.height=n.getUint32(z+4)>>>16)}let H=i(S,"mdhd"),L=i(l,"stts");if(H&&L&&L[2]-L[1]>=8){let se=r[H[1]],z=se===1?n.getUint32(H[1]+20):n.getUint32(H[1]+12),et=se===1?Number(n.getBigUint64(H[1]+24)):n.getUint32(H[1]+16),on=n.getUint32(L[1]+4),Te=0;for(let ae=0;ae<on&&L[1]+8+ae*8+8<=L[2];ae+=1)Te+=n.getUint32(L[1]+8+ae*8);z>0&&et>0&&Te>0&&(f.fps=Math.round(Te*z*100/et)/100)}}else g==="soun"&&f.audioCodec===void 0&&(f.audioCodec=qe,R!==void 0&&R+36<=b[2]&&(f.audioChannels=n.getUint16(R+24),f.audioHz=n.getUint32(R+32)>>>16))}if(!(f.videoCodec===""||f.width===0||f.height===0))return f}function ht(e,r,n){let t=s=>({subcode:yn,reason:s});if(!e)return t("The file is not an MOV or MP4 (MPEG-4 Part 14) with a video track.");if(!e.moovFirst)return t("The moov atom is not at the front of the file.");if(!["avc1","avc3","hvc1","hev1"].includes(e.videoCodec))return t(`Video codec ${e.videoCodec} is not HEVC or H264.`);if(e.audioCodec!==void 0&&e.audioCodec!=="mp4a")return t(`Audio codec ${e.audioCodec} is not AAC.`);if(e.audioHz!==void 0&&e.audioHz>_n)return t(`Audio sample rate ${e.audioHz} Hz is over 48 kHz.`);if(e.audioChannels!==void 0&&(e.audioChannels<1||e.audioChannels>2))return t(`Audio has ${e.audioChannels} channels; 1 or 2 are accepted.`);if(e.fps!==void 0&&(e.fps<hn||e.fps>gn))return t(`Frame rate ${e.fps} FPS is outside 23-60 FPS.`);if(e.width>fn)return t(`${e.width} columns is over the 1920 maximum.`);let o=e.width/e.height;if(o<mn||o>pn)return t(`Aspect ratio ${o.toFixed(3)}:1 is outside 0.01:1 to 10:1.`);if(e.durationMs<cn||e.durationMs>ln)return t(`Duration ${e.durationMs} ms is outside 3 seconds to 15 minutes.`);if(r>Q)return t(`File size ${r} bytes is over 300MB.`);let i=r*8*1e3/e.durationMs;if(i>wn)return t(`Average bitrate ${Math.round(i/1e3)} kbps is over the 25 Mbps video and 128 kbps audio maximum.`);if(n!==void 0&&n>=e.durationMs)return{subcode:En,reason:`Thumbnail offset must be greater than or equal to 0 and less than video duration, i.e. ${e.durationMs}`}}function gt(e){let r=e,n=o=>r[o]<<8|r[o+1],t=o=>(r[o]<<24>>>0)+(r[o+1]<<16)+(r[o+2]<<8)+r[o+3];if(r.length>=24&&r[0]===137&&r[1]===80&&r[2]===78&&r[3]===71)return{mediaType:"image/png",width:t(16),height:t(20)};if(r.length>=4&&r[0]===255&&r[1]===216&&r[2]===255){let o=2;for(;o+9<r.length;){if(r[o]!==255){o+=1;continue}let i=r[o+1];if(i===216||i===1||i>=208&&i<=215){o+=2;continue}if(i>=192&&i<=207&&i!==196&&i!==200&&i!==204)return{mediaType:"image/jpeg",height:n(o+5),width:n(o+7)};o+=2+n(o+2)}}}function _t(e,r){let n=e>0?e:1080,t=r>0?r:1920,o=Math.round(Math.min(n,t)*.09),i=n/2,s=t/2;return`<svg xmlns="http://www.w3.org/2000/svg" width="${n}" height="${t}" viewBox="0 0 ${n} ${t}"><rect width="${n}" height="${t}" fill="#262626"/><path d="M${i-o*.35} ${s-o*.5}L${i+o*.55} ${s}L${i-o*.35} ${s+o*.5}Z" fill="#fff"/></svg>`}var D="instagram";var ke=[{major:19,released:"2024-01-23",expires:"2026-05-21"},{major:20,released:"2024-05-21",expires:"2026-09-24"},{major:21,released:"2024-10-02",expires:"2027-01-21"},{major:22,released:"2025-01-21",expires:"2027-05-20"},{major:23,released:"2025-05-29",expires:"2027-10-08"},{major:24,released:"2025-10-08",expires:"2028-02-18"},{major:25,released:"2026-02-18",expires:"2028-07-29"},{major:26,released:"2026-07-29",expires:null}];function Tt(e){return ke.filter(r=>r.expires===null||e<Date.parse(r.expires)).map(r=>r.major)}var vn="https://rupload.facebook.com",Ce="https://scontent.cdninstagram.com",An="https://graph.facebook.com",Ne=50,he=86400,wt=400,bt=2200,yt=30,Pe=20,Pn=900000000000000000n,Mn=800000000000000000n,On=new Set(["instagram_basic","instagram_content_publish","pages_read_engagement","pages_show_list","ads_management","ads_read","business_management","instagram_manage_comments","instagram_manage_contents","instagram_business_basic","instagram_business_content_publish","instagram_business_manage_comments"]),Le=["instagram_business_basic"],It=["instagram_business_basic","instagram_business_content_publish"],Un=[["instagram_basic","pages_read_engagement"],Le],kn=[["instagram_basic","pages_read_engagement"],["instagram_basic","pages_show_list"],Le],Cn=[["instagram_basic","pages_read_engagement"],Le],Ge=[["instagram_basic","instagram_content_publish","pages_read_engagement"],It],Nn=[["instagram_basic","instagram_content_publish"],It],Rt=[["instagram_basic","instagram_content_publish"]],Ln=[["instagram_basic","instagram_manage_contents"]],Gn=new Set(["id","username","name","biography","website","followers_count","follows_count","media_count","profile_picture_url","has_profile_pic"]),Dn=new Set(["alt_text","is_published","legacy_instagram_user_id","shopping_product_tag_eligibility","collaborative_media_search","business_discovery","ig_id"]),$t=new Set(["id","media_type","media_product_type","media_url","permalink","caption","timestamp","thumbnail_url","shortcode","username","owner","is_shared_to_feed","is_comment_enabled","comments_count","like_count","is_ai_generated"]),xt=new Set(["alt_text","boost_ads_list","boost_eligibility_info","copyright_check_information","legacy_instagram_media_id","media_audio_type","view_count","reposts_count","saved_count","shares_count","total_comments_count","total_like_count","total_views_count","children","collaborators","comments","insights"]),Bn=new Set(["id","status_code","status"]),Fn=new Set(["agencies","authorized_adaccounts","connected_threads_user","insights","instagram_backed_threads_user","live_media","mentions","mentioned_comment","mentioned_media","recently_searched_hashtags","stories","tags","upcoming_events","collaboration_invites","collaborative_media","available_catalogs","catalog_product_search","product_appeal"]),jn=["collaborators","user_tags","location_id","trial_params","product_tags","branded_content_sponsor_ids","is_paid_partnership"];function q(e,r){if(e){for(let[n,t]of Object.entries(e))if(n.toLowerCase()===r)return t}}function Hn(e,r){let n={};for(let[i,s]of e.searchParams)n[i]=s;let t=r.body;if(t===void 0||t.trim()==="")return n;let o=(q(r.headers,"content-type")??"").toLowerCase();if(o.includes("application/x-www-form-urlencoded")||!o.includes("json")&&!t.trim().startsWith("{")){for(let[i,s]of new URLSearchParams(t))n[i]=s;return n}try{let i=JSON.parse(t);return i===null||typeof i!="object"||Array.isArray(i)?"malformed":{...n,...i}}catch{return"malformed"}}function vt(e){return Rn(D,e)}var k=(e,r)=>e.filter(n=>n.type===r),$=e=>In(e),B=e=>Date.parse(e.occurredAt??St()),Y=e=>e.occurredAt??St();function At(e){return`${new Date(e).toISOString().slice(0,19)}+0000`}function zn(e){return Date.parse(String(e).replace(/([+-]\d\d)(\d\d)$/,"$1:$2"))}function De(e){return Ue(new TextEncoder().encode(e))}function Et(e){if(e!==void 0)return e===!0||e==="true"?!0:e===!1||e==="false"?!1:"invalid"}var ee=e=>typeof e=="object"&&e!==null&&"status"in e&&"body"in e;function Pt(e,r,n){let t=q(e.headers,"authorization"),o=t?n.exec(t.trim()):null;return o?o[1]:typeof r.access_token=="string"&&r.access_token!==""?r.access_token:void 0}function Mt(e,r){if(!r)return tt();let n=k(e,"_token").find(o=>String(o.id)===De(r));if(!n)return nt();let t=$(n);return{user:String(t.user),permissions:new Set(Array.isArray(t.permissions)?t.permissions.map(String):[])}}var Be=(e,r)=>r.some(n=>n.every(t=>e.permissions.has(t)));function C(e,r,n){return Be(e,r)?void 0:K(`${n} needs ${r.map(t=>t.join(" + ")).join(", or ")}`)}function te(e){if(typeof e!="string"||e.trim()==="")return;let r=[],n=0,t="";for(let o of e){if(o==="{")n+=1;else if(o==="}")n=Math.max(0,n-1);else if(o===","&&n===0){t.trim()&&r.push(t.trim()),t="";continue}n===0&&o!=="}"&&(t+=o)}return t.trim()&&r.push(t.trim()),r}function Fe(e,r,n,t,o){let i=n??["id"];for(let a of i){if(o.has(a))return A(`The ${a} field on ${e}`);if(!t.has(a))return y(`Tried accessing nonexisting field (${a}) on node type (${e})`)}let s={};for(let a of i)r[a]!==void 0&&(s[a]=r[a]);return s.id=r.id,s}function Vn(e,r,n){let t=new Set(k(e,"media").map(o=>String(o.id)));for(let o of xn(D,r).keys())o.startsWith("media:")&&t.add(o.slice(6));for(let o=0;;o+=1){let i=Ue(new TextEncoder().encode(`${n}|${t.size}|${o}`)),s=String(Pn+BigInt(`0x${i.slice(0,16)}`)%99000000000000000n);if(!t.has(s))return s}}async function Wn(e){let r=new Set((await ve(e)).map(n=>n.id));for(;;){let n=crypto.getRandomValues(new Uint32Array(2)),t=String(Mn+(BigInt(n[0])*4294967296n+BigInt(n[1]))%99000000000000000n);if(!r.has(t))return t}}function Oe(e){let r="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_",n=Ue(new TextEncoder().encode(`shortcode|${e}`)),t="";for(let o=0;o<11;o+=1)t+=r[parseInt(n.slice(o*2,o*2+2),16)%64];return t}var je=(e,r)=>(e.publicBase??r).replace(/\/+$/,"");function Ot(e,r){return`${(e.publicBase??Ce).replace(/\/+$/,"")}/o1/v/t16/f2/m86/${r}.mp4`}function Ut(e){return $(e)._deleted===!0||$(e).deleted===!0}function kt(e,r,n){return k(e,"media").filter(t=>{let o=$(t);return typeof o._container=="string"&&String(o.owner?.id)===r&&zn(o.timestamp)>=n}).length}function Ct(e,r){return k(e,"media").filter(n=>!Ut(n)&&(r===void 0||String($(n).owner?.id)===r))}function He(e,r){return k(e,"ig_user").find(n=>String(n.id)===r)}function Xn(e,r,n){let t=$(n),o=t._profile_picture,i=o?`${je(e,Ce)}/v/t51.2885-19/${o.sha256}.${o.media_type==="image/png"?"png":"jpg"}`:typeof t.profile_picture_url=="string"?t.profile_picture_url:void 0;return{id:String(n.id),username:t.username,...typeof t.name=="string"?{name:t.name}:{},...typeof t.biography=="string"?{biography:t.biography}:{},...typeof t.website=="string"?{website:t.website}:{},...typeof t.followers_count=="number"?{followers_count:t.followers_count}:{},...typeof t.follows_count=="number"?{follows_count:t.follows_count}:{},media_count:Ct(r,String(n.id)).length,...i?{profile_picture_url:i}:{},has_profile_pic:i!==void 0}}function ze(e,r,n){let t=$(n),o={};for(let[a,d]of Object.entries(t))a.startsWith("_")||(o[a]=d);let i=t._video;i&&(o.media_url=Ot(e,i.sha256),o.thumbnail_url=typeof t._cover_url=="string"?t._cover_url:`${(e.publicBase??Ce).replace(/\/+$/,"")}/v/t51.71878-15/${i.sha256}_poster.svg`);let s=He(r,String(t.owner?.id??""));return s&&(o.username=$(s).username),o.id=String(n.id),o}function Jn(e,r,n){let t=$n(D,"media",r,n),o=k(e,"media").find(i=>String(i.id)===t);return o&&!Ut(o)?o:void 0}function Nt(e,r){return k(e,"media").some(n=>String($(n)._container??"")===r)}function Yn(e,r,n,t,o){let i=C(n,Un,"Reading an IG User");if(i)return i;if(String(t.id)!==n.user)return x("GET",String(t.id));let s=Fe("IGUser",Xn(e,r,t),te(o.fields),Gn,Dn);return ee(s)?s:v(s)}function Kn(e,r,n,t,o,i,s){let a=C(t,kn,"Reading an IG User's media");if(a)return a;if(String(o.id)!==t.user)return x("GET",String(o.id));if(i.since!==void 0||i.until!==void 0)return A("Time-based pagination (since / until) on /{ig-user-id}/media");let d=te(i.fields);for(let g of d??[]){if(xt.has(g))return A(`The ${g} field on IGMedia`);if(!$t.has(g))return y(`Tried accessing nonexisting field (${g}) on node type (IGMedia)`)}let u=i.limit,c=u===void 0?25:Number(u);if(!Number.isInteger(c)||c<1)return y("The parameter limit must be a positive integer");let m=Math.min(c,100),p=Ct(n,String(o.id)).map((g,l)=>({m:g,i:l})).sort((g,l)=>String($(l.m).timestamp).localeCompare(String($(g.m).timestamp))||l.i-g.i).map(({m:g})=>g),E=g=>btoa(`cursor:${g}`).replace(/=+$/,""),w=g=>{if(typeof g=="string")try{let l=atob(g);return l.startsWith("cursor:")?l.slice(7):void 0}catch{return}},f=0;if(i.after!==void 0){let g=p.findIndex(l=>String(l.id)===w(i.after));if(g<0)return y("The after cursor is not valid");f=g+1}let h=p.slice(f,f+m),_={data:h.map(g=>{let l=ze(e,n,g),b={};for(let R of d??["id"])l[R]!==void 0&&(b[R]=l[R]);return b.id=l.id,b})};if(h.length>0){let g={cursors:{before:E(String(h[0].id)),after:E(String(h[h.length-1].id))}};if(f+m<p.length){let l=new URLSearchParams(r.searchParams);l.delete("access_token"),l.set("limit",String(m)),l.set("after",E(String(h[h.length-1].id))),g.next=`${je(e,An)}/${s}/${o.id}/media?${l.toString()}`}_.paging=g}return v(_)}async function Zn(e,r,n,t,o,i){let s=C(n,Ge,"Creating a media container");if(s)return s;if(String(t.id)!==n.user)return K(`Creating media on IG User ${String(t.id)}, which this token's user is not`);let a=o.media_type;if(a===void 0)return o.image_url!==void 0?A("Image posts (image_url containers)"):de("image_url");if(a==="CAROUSEL"||a==="STORIES"||a==="VIDEO")return A(`${a} containers`);if(a!=="REELS")return T(400,100,`The media type ${String(a)} is unknown.`,{subcode:2207023,title:"Unknown media type",userMsg:`The media type ${String(a)} is unknown.`});if(o.upload_type===void 0)return o.video_url!==void 0?A("A Reel from video_url (Meta fetching a hosted video)"):de("video_url");if(o.upload_type!=="resumable")return y(`upload_type must be the lowercase string resumable (got ${JSON.stringify(o.upload_type)})`);if(!Be(n,Rt))return K("upload_type=resumable is only for apps that have implemented Facebook Login for Business");if(o.video_url!==void 0)return y("video_url is not taken by a resumable upload session; upload the video to the returned uri");for(let _ of jn)if(o[_]!==void 0)return A(`\`${_}\` on a Reel`);if(o.alt_text!==void 0)return y("alt_text is for image posts only; Reels and stories are not supported");if(o.is_carousel_item!==void 0||o.children!==void 0||o.image_url!==void 0)return y("A Reel takes no image_url, children or is_carousel_item; Reels cannot appear in carousels");let d=o.caption;if(d!==void 0&&typeof d!="string")return y("caption must be a string");if(typeof d=="string"){if([...d].length>bt){let l=`The submitted image's caption was ${[...d].length} characters long. The maximum number of characters permitted for a caption is ${bt}. Please submit media with a shorter caption.`;return T(400,36004,l,{subcode:2207010,title:"Caption too long",userMsg:l})}let _=d.match(/(^|\s)#[\p{L}\p{N}_]+/gu)?.length??0;if(_>yt)return y(`A caption may carry at most ${yt} hashtags (it has ${_})`);if((d.match(/(^|\s)@[A-Za-z0-9._]+/g)?.length??0)>Pe)return T(400,100,`Cannot use more than ${Pe} tags per created media.`,{subcode:2207040,title:"Too many tags",userMsg:`Cannot use more than ${Pe} tags per created media.`})}let u=Et(o.share_to_feed);if(u==="invalid")return y("share_to_feed must be true or false");let c=Et(o.is_ai_generated);if(c==="invalid")return y("is_ai_generated must be true or false");let m=o.cover_url;if(m!==void 0&&(typeof m!="string"||!/^https?:\/\/\S+$/i.test(m)))return y("cover_url must be an http(s) URL");let p;if(o.thumb_offset!==void 0&&(p=Number(o.thumb_offset),!Number.isInteger(p)||p<0))return T(400,1,"Thumbnail offset must be greater than or equal to 0 and less than video duration",{subcode:2207057,title:"Invalid thumbnail offset"});let E=o.audio_name;if(E!==void 0&&(typeof E!="string"||E.trim()===""))return y("audio_name must be a non-empty string");let w=B(e);if((await ve(e.root)).filter(_=>_.owner===String(t.id)&&w-_.created_ms<W).length>=wt)return T(400,9,`An Instagram account can only create ${wt} containers within a rolling 24 hour period`);let h=await Wn(e.root),S={id:h,owner:String(t.id),media_type:"REELS",upload_type:"resumable",created_ms:w,received:0,share_to_feed:u??!0,...typeof d=="string"?{caption:d}:{},...typeof m=="string"?{cover_url:m}:{},...p!==void 0?{thumb_offset:p}:{},...typeof E=="string"?{audio_name:E}:{},...c!==void 0?{is_ai_generated:c}:{}};return await me(S,e.root),v({id:h,uri:`${je(e,vn)}/ig-api-upload/${i}/${h}`})}function Qn(e,r,n,t,o){let i=C(n,Ge,"Reading an IG Container");if(i)return i;if(t.owner!==n.user)return x("GET",t.id);let s=te(o.fields);if(s?.includes("copyright_check_status"))return A("copyright_check_status on an IG Container");let a=$e(t,B(e),Nt(r,t.id)),d={id:t.id,status_code:a,status:a==="ERROR"?String(t.error_subcode):a},u=Fe("ShadowIGMediaBuilder",d,s,Bn,new Set);return ee(u)?u:v(u)}async function qn(e,r,n,t,o){let i=C(n,Nn,"Publishing media");if(i)return i;if(String(t.id)!==n.user)return K(`Publishing on IG User ${String(t.id)}, which this token's user is not`);let s=o.creation_id;if(s===void 0||s==="")return de("creation_id");let a=String(s),d=()=>T(400,24,`The media builder with creation id = ${a} does not exist or has been expired.`,{subcode:2207008,title:"Media builder expired",userMsg:`The media builder with creation id = ${a} does not exist or has been expired.`}),u=X(a)?await J(a,e.root):void 0;if(!u||u.owner!==String(t.id))return d();let c=$e(u,B(e),Nt(r,u.id));if(c==="PUBLISHED")return d();if(c==="EXPIRED")return T(400,-2,"The media you are trying to access has expired. Please try to upload again.",{subcode:2207020,title:"Media expired"});if(c==="IN_PROGRESS")return T(400,9007,"The media is not ready for publishing, please wait for a moment",{subcode:2207027,title:"Media not ready",userMsg:"The media is not ready for publishing, please wait for a moment"});if(c==="ERROR")return T(400,-1,"Create media fail, please try to re-create media",{subcode:2207032,title:"Create media fail",userMsg:u.error_reason??"Create media fail, please try to re-create media"});let m=B(e);if(kt(r,String(t.id),m-he*1e3+1)>=Ne)return T(400,9,"You reached maximum number of posts that is allowed to be published by Content Publishing API.",{subcode:2207042,title:"Publishing limit reached",userMsg:"You reached maximum number of posts that is allowed to be published by Content Publishing API."});let{value:p}=await Tn(D,E=>{let w=Vn(E,e.root,`${Y(e)}|${t.id}|${u.sha256}|${u.caption??""}|${u.share_to_feed}`);return{kind:"write",value:w,write:{operation:"instagram.media.publish",subjectType:"media",subjectId:w,fields:{media_type:"VIDEO",media_product_type:"REELS",...u.caption!==void 0?{caption:u.caption}:{},timestamp:At(Y(e)),shortcode:Oe(w),permalink:`https://www.instagram.com/reel/${Oe(w)}/`,owner:{id:String(t.id)},is_shared_to_feed:u.share_to_feed,is_comment_enabled:!0,comments_count:0,like_count:0,...u.is_ai_generated!==void 0?{is_ai_generated:u.is_ai_generated}:{},_video:{sha256:u.sha256,size:u.size,width:u.video?.width,height:u.video?.height,duration_ms:u.video?.durationMs},_container:u.id,...u.cover_url!==void 0?{_cover_url:u.cover_url}:{},...u.thumb_offset!==void 0?{_thumb_offset:u.thumb_offset}:{},...u.audio_name!==void 0?{_audio_name:u.audio_name}:{},_deleted:!1},occurredAt:Y(e),actor:{kind:"agent",id:String(t.id)}}}},e.root);return v({id:p})}function er(e,r,n,t,o){let i=C(n,Ge,"Reading content_publishing_limit");if(i)return i;if(String(t.id)!==n.user)return x("GET",String(t.id));let s=B(e),a=s-he*1e3;if(o.since!==void 0){let c=Number(o.since);if(!Number.isInteger(c)||c*1e3<s-he*1e3||c*1e3>s)return y("since must be a Unix timestamp no older than 24 hours");a=c*1e3}let d=te(o.fields)??["quota_usage"];for(let c of d)if(c!=="quota_usage"&&c!=="config"&&c!=="rate_limit_settings")return y(`Tried accessing nonexisting field (${c}) on node type (ContentPublishingLimit)`);let u={};return d.includes("quota_usage")&&(u.quota_usage=kt(r,String(t.id),a)),(d.includes("config")||d.includes("rate_limit_settings"))&&(u.config={quota_total:Ne,quota_duration:he}),v({data:[u]})}function tr(e,r,n,t,o){let i=C(n,Cn,"Reading an IG Media");if(i)return i;if(String($(t).owner?.id)!==n.user)return x("GET",String(t.id));let s=Fe("IGMedia",ze(e,r,t),te(o.fields),$t,xt);return ee(s)?s:v(s)}async function nr(e,r,n){let t=C(r,Ln,"Deleting an IG Media");return t||(String($(n).owner?.id)!==r.user?x("DELETE",String(n.id)):(await Me(D,{operation:"instagram.media.delete",subjectType:"media",subjectId:String(n.id),fields:{...$(n),_deleted:!0},occurredAt:Y(e),actor:{kind:"agent",id:r.user}},e.root),v({success:!0,deleted_id:String(n.id)})))}async function rr(e,r,n){let t=vt(e.root),o=Object.fromEntries(r.searchParams),i=Pt(e,o,/^(?:OAuth|Bearer)\s+(\S+)$/i),s=()=>I(400,"ProcessingFailedError","unauthorized user request"),a=Mt(t,i);if(ee(a)||!Be(a,Rt))return s();if(e.method==="GET"){let d=await J(n,e.root);return!d||d.owner!==a.user?I(400,"ProcessingFailedError",`Invalid container id ${n}`):v({id:n,file_offset:d.received,...d.file_size!==void 0?{file_size:d.file_size}:{}})}return q(e.headers,"file_url")!==void 0?A("Uploading a Reel from a hosted file_url (Meta fetching it)"):lt(n,e.root,async()=>{let d=await J(n,e.root);if(!d||d.owner!==a.user)return I(400,"ProcessingFailedError",`Invalid container id ${n}`);let u=B(e);if(u>=d.created_ms+W)return I(400,"ProcessingFailedError",`Container ${n} has expired`);if(d.file_size!==void 0&&d.received===d.file_size)return I(400,"ProcessingFailedError",`Container ${n} has already received its whole file`);let c=Number(q(e.headers,"offset")??"0"),m=Number(q(e.headers,"file_size"));if(!Number.isInteger(m)||m<=0)return I(400,"ProcessingFailedError","The file_size header must be the size of the file in bytes");if(m>Q)return I(400,"ProcessingFailedError",`file_size ${m} is over the Reels maximum of 300MB`);if(d.file_size!==void 0&&d.file_size!==m)return I(400,"ProcessingFailedError",`file_size ${m} differs from the ${d.file_size} this upload began with`);if(!Number.isInteger(c)||c<0)return I(400,"ProcessingFailedError","The offset header must be the first byte being uploaded");if(c!==d.received)return I(400,"ProcessingFailedError",`offset ${c} does not continue the upload: resume at offset ${d.received}`);let p=e.bytes??new Uint8Array;if(p.length===0)return I(400,"ProcessingFailedError","The request carries no bytes");if(c+p.length>m)return I(400,"ProcessingFailedError",`${p.length} bytes at offset ${c} run past file_size ${m}`);await dt(d.id,c,p,e.root);let E=c+p.length;if(E<m)return await me({...d,file_size:m,received:E},e.root),v({offset:E,file_size:m});let w=await ut(d.id,e.root),f=new Uint8Array(w.reduce((l,b)=>l+b.length,0)),h=0;for(let l of w)f.set(l,h),h+=l.length;if(f.length!==m)return I(400,"ProcessingFailedError",`The stored chunks hold ${f.length} of ${m} bytes; upload again from offset 0`);let S=await xe(f,e.root);await ct(d.id,e.root);let _=pt(f),g=ht(_,f.length,d.cover_url===void 0?d.thumb_offset:void 0);return await me({...d,file_size:m,received:E,uploaded_ms:u,sha256:S.sha256,size:f.length,..._?{video:_}:{},...g?{error_subcode:g.subcode,error_reason:g.reason}:{}},e.root),rt()})}async function or(e,r,n,t){if(e.method!=="POST")return Z(n);if(n==="/_twin/users"){let o=String(t.id??"");if(!X(o))return y("id must be a numeric IG user id");if(typeof t.username!="string"||!/^[a-z0-9._]{1,30}$/.test(t.username))return y("username must be 1-30 of a-z 0-9 . _");if(k(r,"ig_user").some(a=>String(a.id)!==o&&$(a).username===t.username))return y(`username ${t.username} is already another account's`);for(let a of["name","biography","website"])if(t[a]!==void 0&&typeof t[a]!="string")return y(`${a} must be a string`);for(let a of["followers_count","follows_count"])if(t[a]!==void 0&&(!Number.isInteger(t[a])||t[a]<0))return y(`${a} must be a non-negative integer`);let i;if(t.profile_picture!==void 0){if(typeof t.profile_picture!="string")return y("profile_picture must be base64 JPEG or PNG bytes");let a=Uint8Array.from(atob(t.profile_picture),u=>u.charCodeAt(0)),d=gt(a);if(!d)return y("profile_picture must be base64 JPEG or PNG bytes");i={sha256:(await xe(a,e.root)).sha256,media_type:d.mediaType}}let s={username:t.username,...t.name!==void 0?{name:t.name}:{},...t.biography!==void 0?{biography:t.biography}:{},...t.website!==void 0?{website:t.website}:{},...t.followers_count!==void 0?{followers_count:t.followers_count}:{},...t.follows_count!==void 0?{follows_count:t.follows_count}:{},...i?{_profile_picture:i}:{}};return await Me(D,{operation:"instagram.twin.seed_user",subjectType:"ig_user",subjectId:o,fields:s,occurredAt:Y(e)},e.root),v({id:o,username:t.username})}if(n==="/_twin/tokens"){let o=t.token;if(typeof o!="string"||!/^[A-Za-z0-9._~-]{8,512}$/.test(o))return y("token must be 8-512 characters of A-Z a-z 0-9 . _ ~ -");let i=String(t.user??"");if(!He(r,i))return y(`user ${i} is not a seeded IG user id`);let s=Array.isArray(t.permissions)?t.permissions.map(String):String(t.permissions??"").split(/[\s,]+/).filter(a=>a!=="");for(let a of s)if(!On.has(a))return y(`permission ${a} is not one these pages name`);return await Me(D,{operation:"instagram.twin.seed_token",subjectType:"_token",subjectId:De(o),fields:{user:i,permissions:s},occurredAt:Y(e)},e.root),v({user:i,permissions:s})}return Z(n)}var ir=/^\/ig-api-upload\/(?:(v\d+\.\d+)\/)?(\d{1,25})$/,sr=/^\/(v(\d+)\.(\d+))(\/.*)?$/;async function ge(e){let r=new URL(e.path,"http://twin.local"),n=r.pathname.replace(/\/+$/,"")||"/",t=e.method.toUpperCase(),o=ir.exec(n);if(o&&o[1]!==void 0&&!ke.some(l=>o[1]===`v${l.major}.0`))return I(400,"ProcessingFailedError","Invalid upload path");if(o)return t!=="POST"&&t!=="GET"?I(405,"ProcessingFailedError",`${t} is not an upload`):t==="POST"&&e.readOnly?ue():rr(e,r,o[2]);if(n.startsWith("/ig-api-upload"))return I(400,"ProcessingFailedError","Invalid upload path");let i=Hn(r,e);if(i==="malformed")return y("The request body could not be parsed");let s=vt(e.root);if(n.startsWith("/_twin/"))return e.readOnly?ue():or(e,s,n,i);let a=Tt(B(e)),d=`v${a[a.length-1]??26}.0`,u=n,c=sr.exec(n);if(c){let l=Number(c[2]);if(c[3]!=="0"||l>(a[a.length-1]??26))return Z(n);d=l<(a[0]??l)?`v${a[0]}.0`:c[1],u=c[4]??"/"}let m=u.split("/").filter(Boolean);if(m.length===0||m.length>2)return Z(n);let p=Mt(s,Pt(e,i,/^(?:Bearer|OAuth)\s+(\S+)$/i));if(ee(p))return p;if(t!=="GET"&&t!=="HEAD"&&e.readOnly)return ue();let[w,f]=m,h=w==="me"?p.user:w;if(!X(h))return x(t,h);let S=He(s,h);if(S)return f===void 0?t==="GET"?Yn(e,s,p,S,i):x(t,h):f==="media"?t==="GET"?Kn(e,r,s,p,S,i,d):t==="POST"?Zn(e,s,p,S,i,d):x(t,h):f==="media_publish"?t==="POST"?qn(e,s,p,S,i):x(t,h):f==="content_publishing_limit"?t==="GET"?er(e,s,p,S,i):x(t,h):Fn.has(f)?A(`The ${f} edge on an IG User`):y(`Tried accessing nonexisting field (${f}) on node type (IGUser)`);let _=Jn(s,h,e.root);if(_)return f!==void 0?f==="children"||f==="comments"||f==="insights"||f==="collaborators"?A(`The ${f} edge on an IG Media`):y(`Tried accessing nonexisting field (${f}) on node type (IGMedia)`):t==="GET"?tr(e,s,p,_,i):t==="DELETE"?nr(e,p,_):t==="POST"?A("Updating an IG Media (comment_enabled)"):x(t,h);let g=f===void 0?await J(h,e.root):void 0;return g&&t==="GET"?Qn(e,s,p,g,i):x(t,h)}import{createTwinFetchFromHandler as ar,ownFields as jt,projectResources as Ht,readResourceBlobRange as Lt,resourceBlobSize as dr,runWithCorrelationId as ur,serveHttp as Wr,statefulTwinManifest as cr,twinPublicBase as Gt,worldNow as Dt}from"../../engine/v2/volter_world-core.mjs";var re="instagram",lr=/^\/ig-api-upload\//,fr=/^\/o1\/v\/t16\/f2\/m86\/([0-9a-f]{64})\.mp4$/,mr=/^\/v\/t51\.71878-15\/([0-9a-f]{64})_poster\.svg$/,pr=/^\/v\/t51\.2885-19\/([0-9a-f]{64})\.(jpg|png)$/,_e=8*1024*1024;async function hr(e,r,n,t){if(n-r+1<=_e){let i=await Lt(re,e,r,n,t);return i===null?null:new Blob([new Uint8Array(i)])}let o=r;return new ReadableStream({async pull(i){if(o>n){i.close();return}let s=await Lt(re,e,o,Math.min(n,o+_e-1),t);if(s===null||s.length===0){i.error(new Error("the stored bytes went away mid-read"));return}o+=s.length,i.enqueue(new Uint8Array(s))}})}async function Bt(e,r,n,t){let o=le(r),i=await dr(re,o,t);if(i===null)return ne();let s={"content-type":n,"accept-ranges":"bytes","cache-control":"public, max-age=604800, immutable"},a=0,d=i-1,u=/^bytes=(\d*)-(\d*)$/.exec((e.headers.get("range")??"").trim());if(u&&(u[1]!==""||u[2]!=="")&&(u[1]===""?a=Math.max(0,i-Number(u[2])):(a=Number(u[1]),d=u[2]===""?Math.min(i-1,a+_e-1):Math.min(Number(u[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,m={...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:m});let p=await hr(o,a,d,t);return p===null?ne():new Response(p,{status:c?206:200,headers:m})}var ne=()=>new Response("Not Found",{status:404,headers:{"content-type":"text/plain"}});function Ft(e,r){return Ht(re,r).map(n=>({r:n,f:jt(n)})).find(({r:n,f:t})=>n.type==="media"&&t._deleted!==!0&&t.deleted!==!0&&t._video?.sha256===e)?.f}function gr(e,r){return Ht(re,r).map(n=>({r:n,f:jt(n)})).find(({r:n,f:t})=>n.type==="ig_user"&&t._profile_picture?.sha256===e)?.f}function Ve(e={}){let r=ar(ge,{...e,extras:t=>({publicBase:Gt(t)}),manifest:cr({vendor:"instagram",twinOf:"the Instagram Platform content publishing API (Reels, resumable upload)",stores:"professional accounts, published Reels, and staged media containers"})}),n=async t=>{let o=new URL(t.url),i=t.method==="GET"||t.method==="HEAD",s=i?fr.exec(o.pathname):null;if(s)return Ft(s[1],e.root)?Bt(t,s[1],"video/mp4",e.root):ne();let a=i?mr.exec(o.pathname):null;if(a){let u=Ft(a[1],e.root);return u?new Response(t.method==="HEAD"?null:_t(Number(u._video.width??0),Number(u._video.height??0)),{headers:{"content-type":"image/svg+xml","cache-control":"public, max-age=604800"}}):ne()}let d=i?pr.exec(o.pathname):null;if(d){let u=gr(d[1],e.root);return u?Bt(t,d[1],String(u._profile_picture.media_type),e.root):ne()}if((t.method==="POST"||t.method==="GET")&&lr.test(o.pathname)){let u=t.method==="POST"?new Uint8Array(await t.arrayBuffer()):void 0,c={};t.headers.forEach((w,f)=>{c[f]=w});let m=()=>ge({method:t.method,path:o.pathname+(o.search||""),headers:c,...u?{bytes:u}:{},readOnly:e.readOnly??!1,occurredAt:Dt(),publicBase:Gt(t),...e.root!==void 0?{root:e.root}:{}}),p=t.headers.get("x-twins-request-id")??void 0,E=await(p?ur(p,m):m());return new Response(JSON.stringify(E.body),{status:E.status,headers:{"content-type":"application/json; charset=UTF-8",...E.headers}})}return r(t)};return async t=>{let o=await n(t),i=new Headers(o.headers);return i.set("date",new Date(Dt()).toUTCString()),new Response(o.body,{status:o.status,statusText:o.statusText,headers:i})}}import{assertBudgetGuardIntact as Er,observeResource as Sr,RefusedWriteError as be}from"../../engine/v2/volter_world-core.mjs";import{declareRateBudget as _r,rateBudgetPath as Yr,rateBudgetWeight as wr,RateBudget as br}from"../../engine/v2/volter_world-core.mjs";import{RateBudgetError as yr}from"../../engine/v2/volter_world-core.mjs";var We="instagram",zt=60*6e4,Vt=250,Wt=180,Xt=3600,F={publish:100,container:16,delete:8,upload:1,read:1,other:6},we={windowMs:zt,ceiling:Vt,burstCeiling:Wt,defaultWeight:F.other,maxRetryAfterSeconds:Xt,rules:[{match:"^POST (/v\\d+\\.\\d+)?/\\d+/media_publish$",weight:F.publish},{match:"^POST (/v\\d+\\.\\d+)?/\\d+/media$",weight:F.container},{match:"^DELETE (/v\\d+\\.\\d+)?/\\d+$",weight:F.delete},{match:"^POST (rupload\\.facebook\\.com)?/ig-api-upload/",weight:F.upload},{match:"^GET ",weight:F.read}],reason:`Meta limits an Instagram professional account to 50 API-published posts in a 24-hour moving period (IG User Media Publish and Content Publishing Limit references, "currently 50"; the Content Publishing guide says 100 \u2014 the stricter 50 is kept) and to 400 containers in a rolling 24 hours (IG User Media reference), developers.facebook.com/docs/instagram-platform, fetched 2026-09-27. The general call allowance is a Business Use Case formula with no scalar. The daily figures are spread over the kernel's one-hour window and rounded down: 250 units an hour, a publish 100 (2 an hour, 48 a day), a container 16 (15 an hour, 360 a day), a rupload POST (an 8 MiB chunk) 1, a delete 8, a read 1, anything else 6; a 180-unit burst per minute (30 calls at the default weight, the fallback's own) admits one whole perform of the largest Reel (155 units).`};_r(We,we);function Xe(e,r){let n=r;if(/^https?:\/\//i.test(n)){let s=new URL(n);n=`${s.hostname==="rupload.facebook.com"?s.hostname:""}${s.pathname}${s.search}`}let t=n.indexOf("?"),o={};if(t!==-1)for(let[s,a]of new URLSearchParams(n.slice(t+1)))o[s]=a;let i=(t===-1?n:n.slice(0,t)).replace(/(.)\/+$/,"$1");return wr(We,`${String(e).toUpperCase()} ${i}`,o)}var N=class extends br{constructor(r={}){super({...r,vendor:We})}};var Tr="instagram",Je="v26.0",Jt="rupload.facebook.com";function Ye(e,r=new N){let n=Er(r,N,"budgetedInstagramExecute");return async t=>{let o=Xe(t.method,t.path),i=n.checkBudget(o),s=await e(t);try{n.recordCall(o,Object.fromEntries(Object.entries(s.headers??{}).map(([a,d])=>[a.toLowerCase(),d])),{status:s.status,reservation:i})}catch(a){if(s.status<200||s.status>=300)throw a}return s}}var Ee=6e4,Se=12e4;async function M(e,r,n,t){let o=await e(n),i={};if(o.body.trim()!=="")try{i=JSON.parse(o.body)}catch{throw new Error(`instagram answered ${r} with a body that is not JSON: HTTP ${o.status} ${o.body.slice(0,200)}`)}if(!t.includes(o.status))throw new oe(r,o.status,o.body,i);return{status:o.status,headers:o.headers,body:o.body,json:i}}var oe=class extends Error{label;status;code;subcode;constructor(r,n,t,o){super(`instagram refused ${r}: HTTP ${n} ${t.slice(0,300)}`),this.label=r,this.status=n,this.name="InstagramCallError";let i=o.error;typeof i?.code=="number"&&(this.code=i.code),typeof i?.error_subcode=="number"&&(this.subcode=i.error_subcode)}},Zt=e=>new Promise(r=>setTimeout(r,e)),U=e=>`/${Je}${e}`,Yt={"content-type":"application/json"};function Ke(e,r){if(typeof e=="string"&&e!==""){let n;try{n=new URL(e)}catch{throw new Error(`instagram answered a container uri that is not a URL: ${e.slice(0,200)}`)}if(n.hostname===Jt){if(n.protocol!=="https:"||n.port!==""||n.username!==""||n.password!=="")throw new Error(`instagram answered an upload uri that is not plain https on its upload host: ${e.slice(0,200)}`);return n.href}let t=n.pathname.indexOf("/ig-api-upload/");if(t<0)throw new Error(`instagram answered a container uri with no /ig-api-upload/ path: ${e.slice(0,200)}`);return n.pathname.slice(t)}return`https://${Jt}/ig-api-upload/${Je}/${r}`}function Qt(e){return{media_type:"REELS",upload_type:"resumable",...typeof e.caption=="string"?{caption:e.caption}:{},share_to_feed:e.is_shared_to_feed!==!1,...typeof e._cover_url=="string"?{cover_url:e._cover_url}:{},...typeof e._thumb_offset=="number"&&typeof e._cover_url!="string"?{thumb_offset:e._thumb_offset}:{},...typeof e._audio_name=="string"?{audio_name:e._audio_name}:{},...typeof e.is_ai_generated=="boolean"?{is_ai_generated:e.is_ai_generated}:{}}}var qt=8*1024*1024;async function en(e,r,n,t=0,o=async()=>{}){for(let i=t;i<n.length;){let s=Math.min(n.length,i+qt),a=await M(e,`rupload at offset ${i}`,{method:"POST",path:r,headers:{offset:String(i),file_size:String(n.length),"content-type":"application/octet-stream"},body:n.subarray(i,s)},[200,201]);if(i=typeof a.json.offset=="number"&&Number.isInteger(a.json.offset)&&a.json.offset>i&&a.json.offset<=s?a.json.offset:s,i===n.length){if(a.json.success!==!0)throw new Error(`instagram's upload host did not confirm the upload: ${a.body.slice(0,300)}`);await o(i);return}await o(i)}}async function tn(e,r,n=Zt){for(let t=0;;t+=Ee){let i=(await M(e,"container status",{method:"GET",path:U(`/${r}?fields=status_code,status`)},[200])).json.status_code;if(i==="FINISHED"||i==="ERROR"||i==="EXPIRED"||i==="PUBLISHED")return i;if(i!=="IN_PROGRESS")throw new Error(`instagram answered container ${r} with an unknown status_code ${JSON.stringify(i)}`);if(t+Ee>Se)return"TIMEOUT";await n(Ee)}}async function Ze(e,r,n){return nn(new N(n.credential!==void 0?{token:n.credential}:n.root!==void 0?{root:n.root}:{}),e,r,n)}async function nn(e,r,n,t,o=Zt,i=Date.now){let s=Ye(r,e),a={...n.fields??{}},d=n.subject?.id??"";if((n.operation??"").startsWith("instagram.twin."))return{externalId:t.resolve(n.subject?.type??"ig_user",d),data:{performed:!1,reason:`${n.operation} is the twin's own record \u2014 nothing at Instagram to write`}};if(n.operation==="instagram.media.delete"){let l=t.resolve("media",d),b=await M(s,"media DELETE",{method:"DELETE",path:U(`/${encodeURIComponent(l)}`)},[200]);if(b.json.success!==!0)throw new Error(`instagram did not confirm deleting ${l}: ${b.body.slice(0,200)}`);return{externalId:l,data:{deleted:!0}}}if(n.operation!=="instagram.media.publish")throw new Error(`instagram cannot perform ${n.operation??"this entry"} on ${d}: no Instagram request expresses it`);let u=a._video,c=t.resolve("ig_user",String(a.owner?.id??""));if(!/^\d+$/.test(c))throw new be("instagram.media.owner",`media ${d} names no IG user`,n.id);let m=u?.sha256?await at(u.sha256,t.root):null;if(!m)throw new Error(`instagram cannot perform ${d}: the bytes of its Reel are not on this twin's blob seam`);if(m.length>Q)throw new be("instagram.reel_spec",`a ${m.length}-byte Reel is over the 300MB maximum`,n.id);let p=await ft(n.id,t.root);p&&(p.sha256!==u.sha256||i()-p.created_ms>=W||!Rr(p.target,p.container))&&(await j(n.id,t.root),p=null);let E=p!==null;if(!p){let l=await M(s,"media container CREATE",{method:"POST",path:U(`/${c}/media`),headers:Yt,body:JSON.stringify(Qt(a))},[200]),b=l.json.id;if(typeof b!="string"||!/^\d+$/.test(b))throw new Error(`instagram answered the container CREATE without a container id: ${l.body.slice(0,200)}`);let R=Date.parse($r(l.headers,"date")??"");p={container:b,sha256:u.sha256,created_ms:i(),vendor_opened_ms:Number.isFinite(R)?R:i(),uploaded:0,target:Ke(l.json.uri,b)},await pe(n.id,p,t.root)}let w=p;if(w.uploaded<m.length){let l=E;try{await en(s,w.target,m,w.uploaded,async b=>{w.uploaded=b,await pe(n.id,w,t.root)})}catch(b){if(!(l&&b instanceof oe&&b.status===400))throw b;let R=await M(s,"container status",{method:"GET",path:U(`/${w.container}?fields=status_code`)},[200]);if(R.json.status_code==="EXPIRED")throw await j(n.id,t.root),b;w.uploaded=m.length,R.json.status_code==="IN_PROGRESS"&&(w.unsure=!0),await pe(n.id,w,t.root)}}let f=w.container,h=await tn(s,f,o);if(h==="ERROR"){let l=await M(s,"container status",{method:"GET",path:U(`/${f}?fields=status_code,status`)},[200]).catch(()=>null),b=String(l?.json.status??"");throw await j(n.id,t.root),/2207026|2207057/.test(b)?new be("instagram.reel_spec",`Meta could not process the Reel (container ${f}, status ${b})`,n.id):new Error(`instagram could not process the Reel (container ${f}, status ${b||"ERROR"}); a retry uploads it to a new container`)}if(h==="EXPIRED")throw await j(n.id,t.root),new Error(`instagram container ${f} expired before it was published; a retry uploads the Reel again`);if(h==="PUBLISHED"){let l=await Ir(s,c,a,w.vendor_opened_ms??w.created_ms);if(await j(n.id,t.root),l)return{externalId:l.id,...l.permalink?{url:l.permalink}:{},data:{_vendor_container:f}};throw new be("instagram.publish_answer_lost",`container ${f} is PUBLISHED at Meta, but its media could not be identified (a caption-less Reel, or not exactly one Reel with this caption since the container opened); not publishing it twice`,n.id)}if(h==="TIMEOUT")throw w.unsure?(await j(n.id,t.root),new Error(`instagram container ${f} was still IN_PROGRESS after ${Se/1e3}s after a refused resume: it may hold only part of the file; a retry uploads to a new container`)):new Error(`instagram container ${f} was still IN_PROGRESS after ${Se/1e3}s; kept \u2014 a retry publishes it without uploading again`);let S=await M(s,"media_publish",{method:"POST",path:U(`/${c}/media_publish`),headers:Yt,body:JSON.stringify({creation_id:f})},[200]),_=S.json.id;if(typeof _!="string"||!/^\d+$/.test(_))throw new Error(`instagram answered media_publish without a media id: ${S.body.slice(0,200)}`);await j(n.id,t.root);let g;try{let l=await M(s,"media GET",{method:"GET",path:U(`/${_}?fields=permalink`)},[200]);typeof l.json.permalink=="string"&&(g=l.json.permalink)}catch{}return{externalId:_,...g?{url:g}:{},data:{_vendor_container:f}}}async function j(e,r){try{await mt(e,r)}catch{}}async function Ir(e,r,n,t){let o=typeof n.caption=="string"&&n.caption.trim()!==""?n.caption:void 0;if(o===void 0)return;let i=await M(e,"media list (a lost publish)",{method:"GET",path:U(`/${r}/media?fields=id,caption,timestamp,permalink,media_product_type&limit=25`)},[200]);if(!Array.isArray(i.json.data))throw new Error(`instagram answered the media list with no data: ${i.body.slice(0,200)}`);let s=d=>String(d??"").replace(/@/g,""),a=i.json.data.filter(d=>d.media_product_type==="REELS"&&s(d.caption)===s(o)&&Date.parse(String(d.timestamp).replace(/([+-]\d\d)(\d\d)$/,"$1:$2"))>=t-6e4);return a.length===1&&typeof a[0].id=="string"?{id:a[0].id,...typeof a[0].permalink=="string"?{permalink:a[0].permalink}:{}}:void 0}function Rr(e,r){if(!/^\d+$/.test(r))return!1;if(/^https:\/\//i.test(e))try{return Ke(e,r)===e&&new URL(e).pathname.endsWith(`/${r}`)}catch{return!1}return new RegExp(`^/ig-api-upload/(?:v\\d+\\.\\d+/)?${r}$`).test(e)}function $r(e,r){for(let[n,t]of Object.entries(e??{}))if(n.toLowerCase()===r)return t}var Kt=50,xr="id,username,name,biography,website,followers_count,follows_count,profile_picture_url",vr="id,media_type,media_product_type,media_url,permalink,caption,timestamp,thumbnail_url,shortcode,owner,is_shared_to_feed,is_comment_enabled,comments_count,like_count",ye=0;function Ar(){let e=Date.now();return ye=e>ye?e:ye+1,new Date(ye).toISOString()}async function Qe(e,r={}){let n=Ye(e,r.budget??new N(r.credential!==void 0?{token:r.credential}:r.root!==void 0?{root:r.root}:{})),t=r.occurredAt??Ar(),o=(c,m,p)=>Sr(Tr,{type:c,id:m,fields:p},{...r.root!==void 0?{root:r.root}:{},at:t}),i=await M(n,"IG User GET me",{method:"GET",path:U(`/me?fields=${xr}`)},[200]),s=i.json;if(typeof s.id!="string"||typeof s.username!="string")throw new Error(`instagram answered /me without its id and username: ${i.body.slice(0,200)}`);let a={username:s.username};for(let c of["name","biography","website","profile_picture_url"])typeof s[c]=="string"&&(a[c]=s[c]);for(let c of["followers_count","follows_count"])typeof s[c]=="number"&&(a[c]=s[c]);o("ig_user",s.id,a);let d=0,u;for(let c=0;;c+=1){if(c>=Kt)throw new Error(`instagram media of ${s.id} exceeded ${Kt} pages; refusing to page further`);let m=await M(n,`media list ${s.id}`,{method:"GET",path:U(`/${s.id}/media?fields=${vr}&limit=100${u?`&after=${encodeURIComponent(u)}`:""}`)},[200]),p=m.json.data;if(!Array.isArray(p))throw new Error(`instagram answered the media list with no data: ${m.body.slice(0,200)}`);for(let f of p){if(typeof f.id!="string"||!/^\d+$/.test(f.id))throw new Error(`instagram answered a media with no id: ${JSON.stringify(f).slice(0,200)}`);let{id:h,username:S,..._}=f;o("media",h,_),d+=1}let E=m.json.paging?.next,w=m.json.paging?.cursors?.after;if(typeof E!="string"||typeof w!="string"||p.length===0)break;u=w}return{observed:1+d,users:1,media:d}}import{filePathOf as ro,bundleClient as oo,fileResponse as io,ownFields as so,serveHttp as ao,twinResources as uo}from"../../engine/v2/volter_world-core.mjs";import{registerPack as Pr}from"../../engine/v2/volter_world-core.mjs";var rn="^(?:/v\\d+\\.\\d+)?/(?:me|\\d{1,25})(?:/(?:media|media_publish|content_publishing_limit))?/?$|^/_twin/",Mr={vendor:"instagram",rateBudget:we,transport:"rest",protocol:"2",archetype:"crud",bin:"world-instagram",resources:["ig_user","media"],specSource:"Instagram Platform docs (developers.facebook.com/docs/instagram-platform, Graph API v26.0), read 2026-09-27: Content Publishing (incl. Resumable Upload Session and Reels), the IG User, IG User Media, IG Container, IG User Media Publish, IG Media and IG User Content Publishing Limit references, Error Codes; and the Graph API guides for Versioning, Handle Errors and Resumable Upload. Meta publishes no machine-readable spec for this surface.",description:"Instagram twin \u2014 a professional account's Reels through the Graph API's content publishing flow (a resumable container, the rupload.facebook.com upload, the status_code lifecycle, media_publish), the account and media nodes, the publishing limit, and an instagram.com profile mirror with a Reels grid and a Reel viewer; everything else refuses by name.",refresh:{every:"1h",webhook:!1,onDemand:{atMost:"60s"}},stateSystem:{perform:Ze,refresh:Qe},roundTrip:[{method:"POST",path:"/_twin/users",body:{id:"17841400000000001",username:"round.trip",name:"Round Trip",followers_count:7}},{method:"POST",path:"/_twin/tokens",body:{token:"round-trip-token",user:"17841400000000001",permissions:["instagram_basic","instagram_content_publish","pages_read_engagement"]}},{method:"POST",path:"/v26.0/17841400000000001/media",headers:{authorization:"Bearer round-trip-token"},body:{media_type:"REELS",upload_type:"resumable",caption:"round trip"}}],parityOrigin:"http://twin",shapeParity:"held",adoption:{envStems:["INSTAGRAM"]},hosts:[{host:"graph.facebook.com",pathPattern:rn},{host:"graph.instagram.com",pathPattern:rn},{host:"rupload.facebook.com",pathPattern:"^/ig-api-upload/"},{host:"scontent.cdninstagram.com",pathPattern:"^/(?:o1/v/t16/f2/m86/|v/t51\\.(?:71878-15|2885-19)/)"}],endpointEnvNone:"Meta ships no Instagram Platform client that reads a base-URL environment variable: apps call https://graph.facebook.com/<version>/\u2026 and the rupload host by constant, so a World reaches them through the hosts above; inventing an INSTAGRAM_BASE_URL the app never reads would report coverage the app does not have."};Pr(Mr);export{Ve as createTwinFetch};