agenttwin 0.3.21 → 0.3.23

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (411) 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/{1250-7571b1a697f6bb4a.js → 1250-a3c859fd20517500.js} +1 -1
  8. package/dist/dashboard/assets/next/static/chunks/{2743-a0efd6f4aeb11cc5.js → 2743-72610a5d5a3f8462.js} +1 -1
  9. package/dist/dashboard/assets/next/static/chunks/5663-403316746afad10e.js +1 -0
  10. package/dist/dashboard/assets/next/static/chunks/app/dashboard/{page-9c11295678539a5f.js → page-0e0392368e0a891e.js} +1 -1
  11. package/dist/dashboard/assets/next/static/chunks/app/docs/[[...slug]]/page-4981ea4966b19e3e.js +1 -0
  12. package/dist/dashboard/assets/next/static/chunks/app/onboarding/page-dd4ac0f5f36e6bfa.js +1 -0
  13. package/dist/dashboard/assets/next/static/chunks/app/v2/dashboard/{page-34574448d210c775.js → page-de0fe6d84be21e6a.js} +1 -1
  14. package/dist/dashboard/assets/next/static/chunks/app/v2/onboarding/page-360cbffc57981f6b.js +1 -0
  15. package/dist/dashboard/assets/next/static/chunks/app/v2/page-fc4df4912ce3af44.js +1 -0
  16. package/dist/dashboard/assets/next/static/chunks/{webpack-40324749d289e4a5.js → webpack-9e40ef55e5f2fb53.js} +1 -1
  17. package/dist/dashboard/assets/next/static/css/{42045de5f39b50ca.css → 37d81e1d2804cc5f.css} +1 -1
  18. package/dist/dashboard/assets/next/static/css/69ec1bae997c3bb0.css +1 -0
  19. package/dist/dashboard/assets/next/static/css/ad85402a1595e56e.css +1 -0
  20. package/dist/dashboard/assets/next/static/css/{4bbe78c2fe206b92.css → da981fb878a02b8c.css} +1 -1
  21. package/dist/dashboard/assets/next/static/media/bay-morning.82669113.webp +0 -0
  22. package/dist/dashboard/assets/next/static/media/golden-gate-afternoon.0aa49492.webp +0 -0
  23. package/dist/dashboard/assets/next/static/media/golden-gate-portrait.89fc667a.webp +0 -0
  24. package/dist/dashboard/assets/next/static/media/moonlit-coast.09739ef4.webp +0 -0
  25. package/dist/dashboard/index.html +2 -2
  26. package/dist/engine.js +6386 -4974
  27. package/dist/gateway.js +2194 -604
  28. package/dist/twins/catalog.json +6020 -0
  29. package/dist/twins/engine/v2/THIRD-PARTY.txt +25 -0
  30. package/dist/twins/engine/v2/chunks/2CHBP57N.mjs +8 -0
  31. package/dist/twins/engine/v2/chunks/4CPL6MPF.mjs +30 -0
  32. package/dist/twins/engine/v2/chunks/OYLYKZGD.mjs +2 -0
  33. package/dist/twins/engine/v2/chunks/SQSP35HM.mjs +38 -0
  34. package/dist/twins/engine/v2/chunks/YSJQQVUM.mjs +2 -0
  35. package/dist/twins/engine/v2/react-dom_client.mjs +272 -0
  36. package/dist/twins/engine/v2/react-dom_server.mjs +263 -0
  37. package/dist/twins/engine/v2/react.mjs +2 -0
  38. package/dist/twins/engine/v2/react_jsx-runtime.mjs +31 -0
  39. package/dist/twins/engine/v2/volter_world-core.mjs +195 -0
  40. package/dist/twins/engine/v2/volter_world-core_app-route.mjs +2 -0
  41. package/dist/twins/engine/v2/volter_world-core_network-policy.mjs +2 -0
  42. package/dist/twins/engine/v3/THIRD-PARTY.txt +65 -0
  43. package/dist/twins/engine/v3/chunks/2CHBP57N.mjs +8 -0
  44. package/dist/twins/engine/v3/chunks/2YSSPA5O.mjs +65 -0
  45. package/dist/twins/engine/v3/chunks/5PWRY4UK.mjs +154 -0
  46. package/dist/twins/engine/v3/chunks/7XRKSFFJ.mjs +2 -0
  47. package/dist/twins/engine/v3/chunks/AWOWH2H5.mjs +2 -0
  48. package/dist/twins/engine/v3/chunks/C46M5U3Q.mjs +2 -0
  49. package/dist/twins/engine/v3/chunks/MFH2VZPP.mjs +2 -0
  50. package/dist/twins/engine/v3/chunks/MWCO5UV3.mjs +2 -0
  51. package/dist/twins/engine/v3/chunks/N5BL5RDF.mjs +313 -0
  52. package/dist/twins/engine/v3/chunks/O7HGPMXG.mjs +2 -0
  53. package/dist/twins/engine/v3/chunks/OYLYKZGD.mjs +2 -0
  54. package/dist/twins/engine/v3/chunks/PLB7HTON.mjs +8 -0
  55. package/dist/twins/engine/v3/chunks/TY4LDBVH.mjs +7 -0
  56. package/dist/twins/engine/v3/chunks/VDIRUSCM.mjs +2 -0
  57. package/dist/twins/engine/v3/chunks/WGUCFQK6.mjs +2 -0
  58. package/dist/twins/engine/v3/chunks/WPATONSC.mjs +2 -0
  59. package/dist/twins/engine/v3/react_jsx-runtime.mjs +2 -0
  60. package/dist/twins/engine/v3/volter_world-core.mjs +2 -0
  61. package/dist/twins/engine/v3/volter_world-ui.mjs +559 -0
  62. package/dist/twins/packs/ahrefs/LICENSE +202 -0
  63. package/dist/twins/packs/ahrefs/NOTICE +7 -0
  64. package/dist/twins/packs/ahrefs/index.mjs +2 -0
  65. package/dist/twins/packs/ai-gateway/LICENSE +202 -0
  66. package/dist/twins/packs/ai-gateway/NOTICE +7 -0
  67. package/dist/twins/packs/ai-gateway/index.mjs +14 -0
  68. package/dist/twins/packs/airtable/LICENSE +202 -0
  69. package/dist/twins/packs/airtable/NOTICE +7 -0
  70. package/dist/twins/packs/airtable/index.mjs +2 -0
  71. package/dist/twins/packs/algolia/LICENSE +202 -0
  72. package/dist/twins/packs/algolia/NOTICE +7 -0
  73. package/dist/twins/packs/algolia/index.mjs +2 -0
  74. package/dist/twins/packs/ambientcg/LICENSE +202 -0
  75. package/dist/twins/packs/ambientcg/NOTICE +7 -0
  76. package/dist/twins/packs/ambientcg/index.mjs +2 -0
  77. package/dist/twins/packs/anthropic/LICENSE +202 -0
  78. package/dist/twins/packs/anthropic/NOTICE +7 -0
  79. package/dist/twins/packs/anthropic/index.mjs +18 -0
  80. package/dist/twins/packs/assemblyai/LICENSE +202 -0
  81. package/dist/twins/packs/assemblyai/NOTICE +7 -0
  82. package/dist/twins/packs/assemblyai/index.mjs +11 -0
  83. package/dist/twins/packs/aws/LICENSE +202 -0
  84. package/dist/twins/packs/aws/NOTICE +7 -0
  85. package/dist/twins/packs/aws/index.mjs +2 -0
  86. package/dist/twins/packs/azure/LICENSE +202 -0
  87. package/dist/twins/packs/azure/NOTICE +7 -0
  88. package/dist/twins/packs/azure/index.mjs +38 -0
  89. package/dist/twins/packs/azureformrecognizer/LICENSE +202 -0
  90. package/dist/twins/packs/azureformrecognizer/NOTICE +7 -0
  91. package/dist/twins/packs/azureformrecognizer/index.mjs +3 -0
  92. package/dist/twins/packs/bitly/LICENSE +202 -0
  93. package/dist/twins/packs/bitly/NOTICE +7 -0
  94. package/dist/twins/packs/bitly/index.mjs +2 -0
  95. package/dist/twins/packs/bluesky/LICENSE +202 -0
  96. package/dist/twins/packs/bluesky/NOTICE +7 -0
  97. package/dist/twins/packs/bluesky/index.mjs +30 -0
  98. package/dist/twins/packs/calcom/LICENSE +202 -0
  99. package/dist/twins/packs/calcom/NOTICE +7 -0
  100. package/dist/twins/packs/calcom/index.mjs +2 -0
  101. package/dist/twins/packs/clerk/LICENSE +202 -0
  102. package/dist/twins/packs/clerk/NOTICE +7 -0
  103. package/dist/twins/packs/clerk/index.mjs +5 -0
  104. package/dist/twins/packs/cloudflare/LICENSE +202 -0
  105. package/dist/twins/packs/cloudflare/NOTICE +7 -0
  106. package/dist/twins/packs/cloudflare/index.mjs +79 -0
  107. package/dist/twins/packs/cohere/LICENSE +202 -0
  108. package/dist/twins/packs/cohere/NOTICE +7 -0
  109. package/dist/twins/packs/cohere/index.mjs +2 -0
  110. package/dist/twins/packs/datadog/LICENSE +202 -0
  111. package/dist/twins/packs/datadog/NOTICE +7 -0
  112. package/dist/twins/packs/datadog/index.mjs +3 -0
  113. package/dist/twins/packs/deepinfra/LICENSE +202 -0
  114. package/dist/twins/packs/deepinfra/NOTICE +7 -0
  115. package/dist/twins/packs/deepinfra/index.mjs +13 -0
  116. package/dist/twins/packs/deepseek/LICENSE +202 -0
  117. package/dist/twins/packs/deepseek/NOTICE +7 -0
  118. package/dist/twins/packs/deepseek/index.mjs +12 -0
  119. package/dist/twins/packs/discord/LICENSE +202 -0
  120. package/dist/twins/packs/discord/NOTICE +7 -0
  121. package/dist/twins/packs/discord/index.mjs +2 -0
  122. package/dist/twins/packs/duckduckgo/LICENSE +202 -0
  123. package/dist/twins/packs/duckduckgo/NOTICE +7 -0
  124. package/dist/twins/packs/duckduckgo/index.mjs +532 -0
  125. package/dist/twins/packs/dynadot/LICENSE +202 -0
  126. package/dist/twins/packs/dynadot/NOTICE +7 -0
  127. package/dist/twins/packs/dynadot/index.mjs +2 -0
  128. package/dist/twins/packs/e2b/LICENSE +202 -0
  129. package/dist/twins/packs/e2b/NOTICE +7 -0
  130. package/dist/twins/packs/e2b/index.mjs +2 -0
  131. package/dist/twins/packs/elevenlabs/LICENSE +202 -0
  132. package/dist/twins/packs/elevenlabs/NOTICE +7 -0
  133. package/dist/twins/packs/elevenlabs/index.mjs +4 -0
  134. package/dist/twins/packs/expo/LICENSE +202 -0
  135. package/dist/twins/packs/expo/NOTICE +7 -0
  136. package/dist/twins/packs/expo/index.mjs +2 -0
  137. package/dist/twins/packs/fal/LICENSE +202 -0
  138. package/dist/twins/packs/fal/NOTICE +7 -0
  139. package/dist/twins/packs/fal/index.mjs +2 -0
  140. package/dist/twins/packs/figma/LICENSE +202 -0
  141. package/dist/twins/packs/figma/NOTICE +7 -0
  142. package/dist/twins/packs/figma/index.mjs +2 -0
  143. package/dist/twins/packs/firecrawl/LICENSE +202 -0
  144. package/dist/twins/packs/firecrawl/NOTICE +7 -0
  145. package/dist/twins/packs/firecrawl/index.mjs +9 -0
  146. package/dist/twins/packs/fireworks/LICENSE +202 -0
  147. package/dist/twins/packs/fireworks/NOTICE +7 -0
  148. package/dist/twins/packs/fireworks/index.mjs +13 -0
  149. package/dist/twins/packs/fly/LICENSE +202 -0
  150. package/dist/twins/packs/fly/NOTICE +7 -0
  151. package/dist/twins/packs/fly/index.mjs +2 -0
  152. package/dist/twins/packs/gcs/LICENSE +202 -0
  153. package/dist/twins/packs/gcs/NOTICE +7 -0
  154. package/dist/twins/packs/gcs/index.mjs +8 -0
  155. package/dist/twins/packs/gemini/LICENSE +202 -0
  156. package/dist/twins/packs/gemini/NOTICE +7 -0
  157. package/dist/twins/packs/gemini/index.mjs +7 -0
  158. package/dist/twins/packs/github/LICENSE +202 -0
  159. package/dist/twins/packs/github/NOTICE +7 -0
  160. package/dist/twins/packs/github/index.mjs +75153 -0
  161. package/dist/twins/packs/googleads/LICENSE +202 -0
  162. package/dist/twins/packs/googleads/NOTICE +7 -0
  163. package/dist/twins/packs/googleads/index.mjs +3 -0
  164. package/dist/twins/packs/googlemaps/LICENSE +202 -0
  165. package/dist/twins/packs/googlemaps/NOTICE +7 -0
  166. package/dist/twins/packs/googlemaps/index.mjs +2 -0
  167. package/dist/twins/packs/googleoauth/LICENSE +202 -0
  168. package/dist/twins/packs/googleoauth/NOTICE +7 -0
  169. package/dist/twins/packs/googleoauth/index.mjs +2 -0
  170. package/dist/twins/packs/hackernews/LICENSE +202 -0
  171. package/dist/twins/packs/hackernews/NOTICE +7 -0
  172. package/dist/twins/packs/hackernews/index.mjs +35 -0
  173. package/dist/twins/packs/huggingface/LICENSE +202 -0
  174. package/dist/twins/packs/huggingface/NOTICE +7 -0
  175. package/dist/twins/packs/huggingface/index.mjs +9 -0
  176. package/dist/twins/packs/inngest/LICENSE +202 -0
  177. package/dist/twins/packs/inngest/NOTICE +7 -0
  178. package/dist/twins/packs/inngest/index.mjs +2 -0
  179. package/dist/twins/packs/instagram/LICENSE +202 -0
  180. package/dist/twins/packs/instagram/NOTICE +7 -0
  181. package/dist/twins/packs/instagram/index.mjs +2 -0
  182. package/dist/twins/packs/jira/LICENSE +202 -0
  183. package/dist/twins/packs/jira/NOTICE +7 -0
  184. package/dist/twins/packs/jira/index.mjs +2 -0
  185. package/dist/twins/packs/langfuse/LICENSE +202 -0
  186. package/dist/twins/packs/langfuse/NOTICE +7 -0
  187. package/dist/twins/packs/langfuse/index.mjs +2 -0
  188. package/dist/twins/packs/linear/LICENSE +202 -0
  189. package/dist/twins/packs/linear/NOTICE +7 -0
  190. package/dist/twins/packs/linear/index.mjs +52866 -0
  191. package/dist/twins/packs/linkedin/LICENSE +202 -0
  192. package/dist/twins/packs/linkedin/NOTICE +7 -0
  193. package/dist/twins/packs/linkedin/index.mjs +78 -0
  194. package/dist/twins/packs/livekit/LICENSE +202 -0
  195. package/dist/twins/packs/livekit/NOTICE +7 -0
  196. package/dist/twins/packs/livekit/index.mjs +2 -0
  197. package/dist/twins/packs/mailgun/LICENSE +202 -0
  198. package/dist/twins/packs/mailgun/NOTICE +7 -0
  199. package/dist/twins/packs/mailgun/index.mjs +13 -0
  200. package/dist/twins/packs/mapbox/LICENSE +202 -0
  201. package/dist/twins/packs/mapbox/NOTICE +7 -0
  202. package/dist/twins/packs/mapbox/index.mjs +2 -0
  203. package/dist/twins/packs/merge/LICENSE +202 -0
  204. package/dist/twins/packs/merge/NOTICE +7 -0
  205. package/dist/twins/packs/merge/index.mjs +4 -0
  206. package/dist/twins/packs/mistral/LICENSE +202 -0
  207. package/dist/twins/packs/mistral/NOTICE +7 -0
  208. package/dist/twins/packs/mistral/index.mjs +6 -0
  209. package/dist/twins/packs/mixpanel/LICENSE +202 -0
  210. package/dist/twins/packs/mixpanel/NOTICE +8 -0
  211. package/dist/twins/packs/mixpanel/index.mjs +2 -0
  212. package/dist/twins/packs/mongodb/LICENSE +202 -0
  213. package/dist/twins/packs/mongodb/NOTICE +7 -0
  214. package/dist/twins/packs/mongodb/index.mjs +8 -0
  215. package/dist/twins/packs/moonshot/LICENSE +202 -0
  216. package/dist/twins/packs/moonshot/NOTICE +7 -0
  217. package/dist/twins/packs/moonshot/index.mjs +18 -0
  218. package/dist/twins/packs/notion/LICENSE +202 -0
  219. package/dist/twins/packs/notion/NOTICE +7 -0
  220. package/dist/twins/packs/notion/index.mjs +2 -0
  221. package/dist/twins/packs/npm-registry/LICENSE +202 -0
  222. package/dist/twins/packs/npm-registry/NOTICE +7 -0
  223. package/dist/twins/packs/npm-registry/index.mjs +2 -0
  224. package/dist/twins/packs/oa-treasury/LICENSE +202 -0
  225. package/dist/twins/packs/oa-treasury/NOTICE +8 -0
  226. package/dist/twins/packs/oa-treasury/index.mjs +16 -0
  227. package/dist/twins/packs/openai/LICENSE +202 -0
  228. package/dist/twins/packs/openai/NOTICE +7 -0
  229. package/dist/twins/packs/openai/index.mjs +3473 -0
  230. package/dist/twins/packs/openrouter/LICENSE +202 -0
  231. package/dist/twins/packs/openrouter/NOTICE +7 -0
  232. package/dist/twins/packs/openrouter/index.mjs +2 -0
  233. package/dist/twins/packs/openweather/LICENSE +202 -0
  234. package/dist/twins/packs/openweather/NOTICE +7 -0
  235. package/dist/twins/packs/openweather/index.mjs +2 -0
  236. package/dist/twins/packs/paypal/LICENSE +202 -0
  237. package/dist/twins/packs/paypal/NOTICE +7 -0
  238. package/dist/twins/packs/paypal/index.mjs +51 -0
  239. package/dist/twins/packs/pinecone/LICENSE +202 -0
  240. package/dist/twins/packs/pinecone/NOTICE +7 -0
  241. package/dist/twins/packs/pinecone/index.mjs +2 -0
  242. package/dist/twins/packs/plain/LICENSE +202 -0
  243. package/dist/twins/packs/plain/NOTICE +8 -0
  244. package/dist/twins/packs/plain/index.mjs +18426 -0
  245. package/dist/twins/packs/planetscale/LICENSE +202 -0
  246. package/dist/twins/packs/planetscale/NOTICE +7 -0
  247. package/dist/twins/packs/planetscale/index.mjs +18 -0
  248. package/dist/twins/packs/polar/LICENSE +202 -0
  249. package/dist/twins/packs/polar/NOTICE +7 -0
  250. package/dist/twins/packs/polar/index.mjs +2 -0
  251. package/dist/twins/packs/polyhaven/LICENSE +202 -0
  252. package/dist/twins/packs/polyhaven/NOTICE +7 -0
  253. package/dist/twins/packs/polyhaven/index.mjs +3 -0
  254. package/dist/twins/packs/postmark/LICENSE +202 -0
  255. package/dist/twins/packs/postmark/NOTICE +7 -0
  256. package/dist/twins/packs/postmark/index.mjs +12 -0
  257. package/dist/twins/packs/reddit/LICENSE +202 -0
  258. package/dist/twins/packs/reddit/NOTICE +7 -0
  259. package/dist/twins/packs/reddit/index.mjs +324 -0
  260. package/dist/twins/packs/redis/LICENSE +202 -0
  261. package/dist/twins/packs/redis/NOTICE +7 -0
  262. package/dist/twins/packs/redis/index.mjs +2 -0
  263. package/dist/twins/packs/replicate/LICENSE +202 -0
  264. package/dist/twins/packs/replicate/NOTICE +7 -0
  265. package/dist/twins/packs/replicate/index.mjs +2 -0
  266. package/dist/twins/packs/resend/LICENSE +202 -0
  267. package/dist/twins/packs/resend/NOTICE +7 -0
  268. package/dist/twins/packs/resend/index.mjs +139 -0
  269. package/dist/twins/packs/runhuman/LICENSE +202 -0
  270. package/dist/twins/packs/runhuman/NOTICE +7 -0
  271. package/dist/twins/packs/runhuman/index.mjs +3 -0
  272. package/dist/twins/packs/scrapecreators/LICENSE +202 -0
  273. package/dist/twins/packs/scrapecreators/NOTICE +7 -0
  274. package/dist/twins/packs/scrapecreators/index.mjs +2 -0
  275. package/dist/twins/packs/segment/LICENSE +202 -0
  276. package/dist/twins/packs/segment/NOTICE +8 -0
  277. package/dist/twins/packs/segment/index.mjs +2 -0
  278. package/dist/twins/packs/sendblue/LICENSE +202 -0
  279. package/dist/twins/packs/sendblue/NOTICE +7 -0
  280. package/dist/twins/packs/sendblue/index.mjs +2 -0
  281. package/dist/twins/packs/sendgrid/LICENSE +202 -0
  282. package/dist/twins/packs/sendgrid/NOTICE +8 -0
  283. package/dist/twins/packs/sendgrid/index.mjs +4 -0
  284. package/dist/twins/packs/sentry/LICENSE +202 -0
  285. package/dist/twins/packs/sentry/NOTICE +7 -0
  286. package/dist/twins/packs/sentry/index.mjs +5 -0
  287. package/dist/twins/packs/sigstore/LICENSE +202 -0
  288. package/dist/twins/packs/sigstore/NOTICE +7 -0
  289. package/dist/twins/packs/sigstore/index.mjs +12 -0
  290. package/dist/twins/packs/slack/LICENSE +202 -0
  291. package/dist/twins/packs/slack/NOTICE +7 -0
  292. package/dist/twins/packs/slack/index.mjs +66 -0
  293. package/dist/twins/packs/smtp/LICENSE +202 -0
  294. package/dist/twins/packs/smtp/NOTICE +7 -0
  295. package/dist/twins/packs/smtp/index.mjs +3 -0
  296. package/dist/twins/packs/snowflake/LICENSE +202 -0
  297. package/dist/twins/packs/snowflake/NOTICE +8 -0
  298. package/dist/twins/packs/snowflake/index.mjs +30 -0
  299. package/dist/twins/packs/stigg/LICENSE +202 -0
  300. package/dist/twins/packs/stigg/NOTICE +8 -0
  301. package/dist/twins/packs/stigg/index.mjs +22194 -0
  302. package/dist/twins/packs/stream/LICENSE +202 -0
  303. package/dist/twins/packs/stream/NOTICE +7 -0
  304. package/dist/twins/packs/stream/index.mjs +2 -0
  305. package/dist/twins/packs/stripe/LICENSE +202 -0
  306. package/dist/twins/packs/stripe/NOTICE +7 -0
  307. package/dist/twins/packs/stripe/index.mjs +211 -0
  308. package/dist/twins/packs/supabase/LICENSE +202 -0
  309. package/dist/twins/packs/supabase/NOTICE +7 -0
  310. package/dist/twins/packs/supabase/index.mjs +2 -0
  311. package/dist/twins/packs/supermemory/LICENSE +202 -0
  312. package/dist/twins/packs/supermemory/NOTICE +7 -0
  313. package/dist/twins/packs/supermemory/index.mjs +2 -0
  314. package/dist/twins/packs/svix/LICENSE +202 -0
  315. package/dist/twins/packs/svix/NOTICE +7 -0
  316. package/dist/twins/packs/svix/index.mjs +2 -0
  317. package/dist/twins/packs/tavily/LICENSE +202 -0
  318. package/dist/twins/packs/tavily/NOTICE +7 -0
  319. package/dist/twins/packs/tavily/index.mjs +2 -0
  320. package/dist/twins/packs/telegram/LICENSE +202 -0
  321. package/dist/twins/packs/telegram/NOTICE +7 -0
  322. package/dist/twins/packs/telegram/index.mjs +11 -0
  323. package/dist/twins/packs/temporal/LICENSE +202 -0
  324. package/dist/twins/packs/temporal/NOTICE +7 -0
  325. package/dist/twins/packs/temporal/index.mjs +44 -0
  326. package/dist/twins/packs/tiktok/LICENSE +202 -0
  327. package/dist/twins/packs/tiktok/NOTICE +7 -0
  328. package/dist/twins/packs/tiktok/index.mjs +2 -0
  329. package/dist/twins/packs/tinybird/LICENSE +202 -0
  330. package/dist/twins/packs/tinybird/NOTICE +7 -0
  331. package/dist/twins/packs/tinybird/index.mjs +50 -0
  332. package/dist/twins/packs/togetherai/LICENSE +202 -0
  333. package/dist/twins/packs/togetherai/NOTICE +7 -0
  334. package/dist/twins/packs/togetherai/index.mjs +11 -0
  335. package/dist/twins/packs/tremendous/LICENSE +202 -0
  336. package/dist/twins/packs/tremendous/NOTICE +7 -0
  337. package/dist/twins/packs/tremendous/index.mjs +2 -0
  338. package/dist/twins/packs/tripo/LICENSE +202 -0
  339. package/dist/twins/packs/tripo/NOTICE +7 -0
  340. package/dist/twins/packs/tripo/index.mjs +9 -0
  341. package/dist/twins/packs/tunnel/LICENSE +202 -0
  342. package/dist/twins/packs/tunnel/NOTICE +7 -0
  343. package/dist/twins/packs/tunnel/index.mjs +2 -0
  344. package/dist/twins/packs/twelvelabs/LICENSE +202 -0
  345. package/dist/twins/packs/twelvelabs/NOTICE +7 -0
  346. package/dist/twins/packs/twelvelabs/index.mjs +5 -0
  347. package/dist/twins/packs/twilio/LICENSE +202 -0
  348. package/dist/twins/packs/twilio/NOTICE +7 -0
  349. package/dist/twins/packs/twilio/index.mjs +2 -0
  350. package/dist/twins/packs/twitch/LICENSE +202 -0
  351. package/dist/twins/packs/twitch/NOTICE +7 -0
  352. package/dist/twins/packs/twitch/index.mjs +68 -0
  353. package/dist/twins/packs/upstash/LICENSE +202 -0
  354. package/dist/twins/packs/upstash/NOTICE +7 -0
  355. package/dist/twins/packs/upstash/index.mjs +14 -0
  356. package/dist/twins/packs/upstashvector/LICENSE +202 -0
  357. package/dist/twins/packs/upstashvector/NOTICE +7 -0
  358. package/dist/twins/packs/upstashvector/index.mjs +3 -0
  359. package/dist/twins/packs/vercel/LICENSE +202 -0
  360. package/dist/twins/packs/vercel/NOTICE +7 -0
  361. package/dist/twins/packs/vercel/index.mjs +10 -0
  362. package/dist/twins/packs/veriff/LICENSE +202 -0
  363. package/dist/twins/packs/veriff/NOTICE +7 -0
  364. package/dist/twins/packs/veriff/index.mjs +2 -0
  365. package/dist/twins/packs/vgauth/LICENSE +202 -0
  366. package/dist/twins/packs/vgauth/NOTICE +7 -0
  367. package/dist/twins/packs/vgauth/index.mjs +2 -0
  368. package/dist/twins/packs/vital/LICENSE +202 -0
  369. package/dist/twins/packs/vital/NOTICE +7 -0
  370. package/dist/twins/packs/vital/index.mjs +2 -0
  371. package/dist/twins/packs/volteridentity/LICENSE +202 -0
  372. package/dist/twins/packs/volteridentity/NOTICE +7 -0
  373. package/dist/twins/packs/volteridentity/index.mjs +2 -0
  374. package/dist/twins/packs/webrisk/LICENSE +202 -0
  375. package/dist/twins/packs/webrisk/NOTICE +7 -0
  376. package/dist/twins/packs/webrisk/index.mjs +2 -0
  377. package/dist/twins/packs/worldlabs/LICENSE +202 -0
  378. package/dist/twins/packs/worldlabs/NOTICE +7 -0
  379. package/dist/twins/packs/worldlabs/index.mjs +2 -0
  380. package/dist/twins/packs/x/LICENSE +202 -0
  381. package/dist/twins/packs/x/NOTICE +7 -0
  382. package/dist/twins/packs/x/index.mjs +63 -0
  383. package/dist/twins/packs/xai/LICENSE +202 -0
  384. package/dist/twins/packs/xai/NOTICE +7 -0
  385. package/dist/twins/packs/xai/index.mjs +4 -0
  386. package/dist/twins/packs/xidentity/LICENSE +202 -0
  387. package/dist/twins/packs/xidentity/NOTICE +8 -0
  388. package/dist/twins/packs/xidentity/index.mjs +209 -0
  389. package/dist/twins/packs/youtube/LICENSE +202 -0
  390. package/dist/twins/packs/youtube/NOTICE +7 -0
  391. package/dist/twins/packs/youtube/index.mjs +5 -0
  392. package/dist/worker.js +442 -18
  393. package/dist/world-host.js +928 -91
  394. package/package.json +6 -5
  395. package/dist/dashboard/assets/dashboard/bay-morning.png +0 -0
  396. package/dist/dashboard/assets/dashboard/golden-gate-afternoon.png +0 -0
  397. package/dist/dashboard/assets/dashboard/golden-gate-portrait.png +0 -0
  398. package/dist/dashboard/assets/dashboard/moonlit-coast.png +0 -0
  399. package/dist/dashboard/assets/next/static/chunks/2868-424d32cfc8ae81c9.js +0 -1
  400. package/dist/dashboard/assets/next/static/chunks/app/docs/[[...slug]]/page-f9fca2c08f779fa0.js +0 -1
  401. package/dist/dashboard/assets/next/static/chunks/app/onboarding/page-bc480c9258e5cc4d.js +0 -1
  402. package/dist/dashboard/assets/next/static/chunks/app/v2/onboarding/page-f04c0b236abaead3.js +0 -1
  403. package/dist/dashboard/assets/next/static/chunks/app/v2/page-07c8054d57c9089b.js +0 -1
  404. package/dist/dashboard/assets/next/static/css/4af3c8ca0da0f48b.css +0 -1
  405. package/dist/dashboard/assets/next/static/css/6b8edde77e493a51.css +0 -1
  406. package/dist/dashboard/assets/next/static/media/bay-morning.1a9f358c.png +0 -0
  407. package/dist/dashboard/assets/next/static/media/golden-gate-afternoon.3e7cea58.png +0 -0
  408. package/dist/dashboard/assets/next/static/media/golden-gate-portrait.7941528f.png +0 -0
  409. package/dist/dashboard/assets/next/static/media/moonlit-coast.bbe901a1.png +0 -0
  410. /package/dist/dashboard/assets/next/static/{5ub3D2yzS8DE7w2qZd1nv → GTd0IQ6HYyhE_2HqcgFno}/_buildManifest.js +0 -0
  411. /package/dist/dashboard/assets/next/static/{5ub3D2yzS8DE7w2qZd1nv → GTd0IQ6HYyhE_2HqcgFno}/_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-moonshot
2
+
3
+ Contains @volter/twin-moonshot 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,18 @@
1
+ import{createRequire as __atReq}from'node:module';const require=__atReq(import.meta.url);
2
+ import{applyTwinWrite as ee,projectResources as kt,resolveSubjectId as Re,worldNow as Ot}from"../../engine/v2/volter_world-core.mjs";var U=[{id:"kimi-k3",object:"model",created:176e7,owned_by:"moonshot",supports:{chat:!0,responses:!0,messages:!0,batch:!1,vision:!0},context_length:1048576,max_completion_tokens:1048576},{id:"kimi-k2.7-code",object:"model",created:1760000001,owned_by:"moonshot",supports:{chat:!0,responses:!1,messages:!1,batch:!0,vision:!1},context_length:262144,max_completion_tokens:262144},{id:"kimi-k2.7-code-highspeed",object:"model",created:1760000002,owned_by:"moonshot",supports:{chat:!0,responses:!1,messages:!1,batch:!0,vision:!1},context_length:262144,max_completion_tokens:262144},{id:"kimi-k2.6",object:"model",created:1760000003,owned_by:"moonshot",supports:{chat:!0,responses:!1,messages:!1,batch:!0,vision:!0},context_length:262144,max_completion_tokens:262144}];function F(e){return U.find(t=>t.id===e)}var bt=new Set(U.filter(e=>e.supports.batch).map(e=>e.id)),$=["low","high","max"],z=["enabled","disabled"],re=["enabled"];function y(e){return e?Math.max(1,Math.ceil(e.length/4)):0}function O(e){return typeof e=="string"?e:e==null||!Array.isArray(e)?"":e.map(t=>t&&typeof t=="object"&&t.type==="text"?String(t.text??""):JSON.stringify(t)).join(`
3
+ `)}function C(e){let t=0;for(let n of e){t+=y(O(n.content)),n.name&&(t+=y(n.name));for(let o of n.tool_calls??[])t+=y(JSON.stringify(o))}return t}function j(e){for(let t=e.length-1;t>=0;t--)if(e[t].role==="user")return O(e[t].content);return e.length?O(e[e.length-1].content):""}function W(e,t){let n=j(e).trim(),o=n.length>200?`${n.slice(0,200)}\u2026`:n;return`[twin-stub:${t}] This is a deterministic stub from the Moonshot twin (no model weights are run). Echoing your last message: ${o||"(empty)"}`}function D(e,t){return`[twin-stub:${t}] deterministic stub reasoning (no model weights are run) for: ${j(e).trim().slice(0,120)||"(empty)"}`}function V(e,t){return`sig_twin_${P(`${t}:${j(e)}`).toString(36)}`}var xt=256;function J(e){return e>xt?Math.floor(e*.25):0}function se(e,t,n){let o=n!==void 0?J(e):0;return{prompt_tokens:e,completion_tokens:t,total_tokens:e+t,cached_tokens:o}}function we(e){let t=e;return t?.function&&typeof t.function.name=="string"?t.function.name:typeof t?.name=="string"?t.name:"unknown_function"}function ve(e){let t=e;if(Array.isArray(t?.enum)&&t.enum.length)return t.enum[0];switch(t?.type){case"number":case"integer":return 0;case"boolean":return!1;case"array":return[];case"object":return{};default:return""}}function ke(e){let t=e,n=t?.function?.parameters??t?.parameters??t?.input_schema,o=n&&typeof n=="object"?n.properties:void 0;if(!o||typeof o!="object")return"{}";let i={};for(let[r,c]of Object.entries(o))i[r]=ve(c);return JSON.stringify(i)}function K(e,t,n){if(!Array.isArray(e)||e.length===0)return null;let o=n?e.find(i=>we(i)===n)??e[0]:e[0];return{id:`call_twin_${t}`,type:"function",function:{name:we(o),arguments:ke(o)}}}function Z(e,t,n){let o=n,i=o?.schema?.properties??o?.properties;if(i&&typeof i=="object"){let r={};for(let[c,s]of Object.entries(i))r[c]=ve(s);return JSON.stringify(r)}return JSON.stringify({_twin_stub:!0,model:t,echo:j(e).slice(0,200)})}function P(e){let t=2166136261;for(let n=0;n<e.length;n++)t^=e.charCodeAt(n),t=Math.imul(t,16777619);return t>>>0}function A(...e){return P(e.map(t=>JSON.stringify(t)??String(t)).join("|")).toString(36)}function ie(e,t,n,o=!1){let i=[];for(let r=0;r<t;r++){let c={authority:"twin",date:"2026-01-01",icon:"",mime:"text/html",site_name:"twin-stub",snippet:`[twin-stub] deterministic search result ${r+1}/${t} for: ${e}`,title:`[twin-stub] result ${r+1} for: ${e}`,url:`https://twin-stub.invalid/search?q=${encodeURIComponent(e)}&i=${r}`};n?i.push({...c,chunks:[{text:`[twin-stub] chunk for: ${e}`,score:.5}]}):i.push({...c,text:o?`[twin-stub] content for: ${e} (result ${r+1}) \u2014 the twin performs no real network I/O (D4).`:""})}return i}function ae(e){return{url:e,markdown:`[twin-stub] deterministic fetch of ${e} \u2014 the twin performs no real network I/O (D4).`,title:`[twin-stub] ${e}`}}import{getActiveWorldStore as Tt,parseScenarioDocument as St,ScenarioError as wt,ScenarioEngine as vt}from"../../engine/v2/volter_world-core.mjs";var Oe=new Set(["text","reasoning","toolCalls","finishReason","error"]),Ae=new Set(["stop","length","tool_calls"]),Ee=new Set(["rate_limit_reached_error","server_unavailable","server_error"]),$e=new Set(["enabled","disabled"]),L=e=>typeof e=="string"&&e.length>0;function je(e){let t=new Set,n=e[e.length-1];if(!n||n.role!=="tool"||typeof n.tool_call_id!="string")return t;for(let o of e){let i=o;if(!(i.role!=="assistant"||!Array.isArray(i.tool_calls)))for(let r of i.tool_calls)r?.id===n.tool_call_id&&typeof r?.function?.name=="string"&&t.add(r.function.name)}return t}function Me(e){return Array.isArray(e)?e.map(t=>typeof t?.function?.name=="string"?t.function.name:typeof t?.name=="string"?t.name:null).filter(t=>t!==null):[]}var ce={vendor:"moonshot",renderFault:e=>({body:e.status===429?{error:{message:e.message??"Request rate limit reached: 3 requests per minute (Tier 0). Please retry after 20 seconds.",type:"rate_limit_reached_error"}}:e.status>=500?{error:{message:e.message??"The server is overloaded or not ready to handle the request. Please try again later.",type:e.status===503?"server_unavailable":"server_error"}}:{error:{message:e.message??"The request was refused by a scripted fault.",type:"invalid_request_error"}}}),features:e=>({model:e.model,lastUserText:j(e.messages).slice(0,300),tools:Me(e.tools),lastMessageIsToolResult:e.messages[e.messages.length-1]?.role==="tool",toolResultFor:[...je(e.messages)],thinkingType:e.thinking?.type??"enabled"}),matchers:{modelEquals:(e,t)=>L(t)&&e.model===t,userTextIncludes:(e,t)=>L(t)&&j(e.messages).toLowerCase().includes(t.toLowerCase()),anyTextIncludes:(e,t)=>L(t)&&e.messages.map(n=>O(n.content)).join(`
4
+ `).toLowerCase().includes(t.toLowerCase()),lastMessageIsToolResult:(e,t)=>typeof t=="boolean"&&e.messages[e.messages.length-1]?.role==="tool"===t,toolResultFor:(e,t)=>L(t)&&je(e.messages).has(t),hasTool:(e,t)=>L(t)&&Me(e.tools).includes(t),thinkingTypeEquals:(e,t)=>L(t)&&(e.thinking?.type??"enabled")===t},text:e=>e.messages.map(t=>O(t.content)).join(`
5
+ `),validateOn:e=>{for(let t of["modelEquals","userTextIncludes","anyTextIncludes","toolResultFor","hasTool"])if(e[t]!==void 0&&(typeof e[t]!="string"||!e[t]))return`on.${t} is a non-empty string`;return e.lastMessageIsToolResult!==void 0&&typeof e.lastMessageIsToolResult!="boolean"?"on.lastMessageIsToolResult is a boolean":e.thinkingTypeEquals!==void 0&&(typeof e.thinkingTypeEquals!="string"||!$e.has(e.thinkingTypeEquals))?`on.thinkingTypeEquals is one of ${[...$e].join(", ")}`:null},validateRespond:e=>{if(typeof e!="object"||e===null||Array.isArray(e))return"respond is an object { text?, reasoning?, toolCalls?, finishReason?, error? }";let t=e;for(let n of Object.keys(t))if(!Oe.has(n))return`respond: unknown key "${n}" (valid: ${[...Oe].join(", ")})`;if(t.error!==void 0){let n=t.error;if(!n||typeof n!="object"||Array.isArray(n))return"respond.error is an object { type, message? }";if(typeof n.type!="string"||!Ee.has(n.type))return`respond.error.type is one of ${[...Ee].join(", ")}`;if(n.message!==void 0&&typeof n.message!="string")return"respond.error.message is a string";for(let o of["text","reasoning","toolCalls","finishReason"])if(t[o]!==void 0)return`respond.error cannot be combined with respond.${o}`;return null}if(t.text!==void 0&&typeof t.text!="string")return"respond.text is a string";if(t.reasoning!==void 0&&typeof t.reasoning!="string")return"respond.reasoning is a string";if(t.finishReason!==void 0&&(typeof t.finishReason!="string"||!Ae.has(t.finishReason)))return`respond.finishReason is one of ${[...Ae].join(", ")}`;if(t.toolCalls!==void 0)for(let n of Array.isArray(t.toolCalls)?t.toolCalls:[t.toolCalls]){let o=n;if(!o||typeof o!="object"||Array.isArray(o))return"respond.toolCalls entries are objects";if(typeof o.name!="string"||!o.name)return"respond.toolCalls[].name is a non-empty string";if(!o.arguments||typeof o.arguments!="object"||Array.isArray(o.arguments))return"respond.toolCalls[].arguments is an object";if(o.id!==void 0&&typeof o.id!="string")return"respond.toolCalls[].id is a string"}return t.text===void 0&&t.toolCalls===void 0?"respond needs text or toolCalls (or an error)":null}};function ue(e){let t;try{let n=Tt().read(e);if(n===null)throw new Error(`ENOENT: no such file or directory, open '${e}'`);t=JSON.parse(n)}catch(n){throw new wt(`moonshot scenario: cannot read/parse ${e}: ${n instanceof Error?n.message:String(n)}`)}return St(t,ce)}function le(e){return new vt(ce,e)}function q(e){let t=[];return(e.toolCalls?Array.isArray(e.toolCalls)?e.toolCalls:[e.toolCalls]:[]).forEach((o,i)=>{let r=`${i}:${o.name}:${JSON.stringify(o.arguments)}`;t.push({id:o.id??`call_scripted_${P(r).toString(36)}`,type:"function",function:{name:o.name,arguments:JSON.stringify(o.arguments)}})}),{text:e.text??(t.length?null:""),reasoning:e.reasoning??null,toolCalls:t,finishReason:e.finishReason??(t.length?"tool_calls":"stop")}}var B="moonshot",R="/v1",N="/anthropic/v1";function v(e,t,n){return{error:{message:t,...e!==void 0?{type:e}:{},...n!==void 0?{code:n}:{}}}}function f(e,t){return{status:400,body:v("invalid_request_error",e,t)}}function M(e){return{status:404,body:v("resource_not_found_error",e)}}function Ne(e,t){return{status:401,body:v(t,e)}}function At(e){let t=He(e.path),n=e.headers?.authorization,o=typeof n=="string"&&n.toLowerCase().startsWith("bearer ")?n.slice(7).trim():"",i=typeof e.headers?.["x-api-key"]=="string"?e.headers["x-api-key"].trim():"",r=(e.apiKey??"").trim()||(t?i||o:o||i);return r?r==="sk_invalid"||r==="invalid"?t?_(401,"authentication_error","invalid x-api-key."):Ne("The API key is invalid. Please check your API key.","incorrect_api_key_error"):null:t?_(401,"authentication_error","missing API key. Provide an x-api-key header (or Authorization: Bearer \u2026)."):Ne("The API key is missing or malformed. Please check your API key.","invalid_authentication_error")}function He(e){let t=e.split("?")[0]??"";return t===N||t.startsWith(`${N}/`)}function Ge(){return{status:429,body:v("rate_limit_reached_error","Request rate limit reached: 3 requests per minute (Tier 0). Please retry after 20 seconds."),headers:{"retry-after":"20","x-ratelimit-limit":"3","x-ratelimit-remaining":"0","x-ratelimit-reset":"20s"}}}function de(){return{status:503,body:v("server_unavailable","The server is overloaded or not ready to handle the request. Please try again later.")}}function Ie(e,t){let n=e.headers?.[t];return n==="1"||n==="true"}function G(e){return Math.floor((e?Date.parse(e):0)/1e3)}function Y(e,t){return kt(B,t).filter(n=>n.type===e)}function Ue(e,t,n){let o=0;for(let i of Y(e,n)){let r=new RegExp(`^${t}_twin_(\\d+)$`).exec(String(i.id));r&&(o=Math.max(o,Number(r[1])))}return`${t}_twin_${o+1}`}function Et(e){return Y("model",e).filter(t=>!t._deleted).map(t=>({id:t.id,object:"model",created:t.created,owned_by:t.owned_by}))}function $t(e){let t=Et(e),n=new Map;for(let o of U)n.set(o.id,{id:o.id,object:"model",created:o.created,owned_by:o.owned_by});for(let o of t)n.set(String(o.id),o);return[...n.values()]}function k(e,t,n){return Y(e,n).find(o=>o.id===t)}function We(e){let t={};for(let[n,o]of Object.entries(e))n==="type"||n==="updatedAt"||n.startsWith("_")||(t[n]=o);return t}function jt(e){if(!e||!e.trim())return{};try{let t=JSON.parse(e);return t&&typeof t=="object"?t:{}}catch{return{}}}var te=/^[a-zA-Z_][a-zA-Z0-9-_]{0,127}$/,Ce=5,Pe=32;function Mt(e,t){if(t==null)return{};if(typeof t!="object"||Array.isArray(t))return{error:f("'thinking' must be an object")};let n=t,o=n.type;if(typeof o!="string")return{error:f("'thinking.type' is required")};if(e==="kimi-k2.6"){if(!z.includes(o))return{error:f(`'thinking.type' must be one of ${z.map(r=>`'${r}'`).join(", ")} for kimi-k2.6`)}}else if(e==="kimi-k2.7-code"||e==="kimi-k2.7-code-highspeed"){if(!re.includes(o))return{error:f(`'thinking.type' must be 'enabled' for ${e} \u2014 'disabled' is not supported and returns an error`)}}else return{error:f(`'thinking' is not a parameter of ${e}`)};let i;if(n.keep!==void 0){if(n.keep!==null&&n.keep!=="all")return{error:f("'thinking.keep' must be 'all' or null")};i=n.keep}return{value:{type:o,...i!==void 0?{keep:i}:{}}}}function Rt(e){if(e.model===void 0||e.model==="")return{error:f("'model' is a required property")};if(typeof e.model!="string")return{error:f("'model' must be a string")};let t=F(e.model);if(!t)return{error:f(`The model '${e.model}' does not exist or you do not have access to it.`)};if(!Array.isArray(e.messages))return{error:f("'messages' is a required property")};if(e.messages.length===0)return{error:f("[] is too short - 'messages'")};let n=e.messages;for(let d of n){if(!d||typeof d!="object"||typeof d.role!="string")return{error:f("each message must have a valid 'role'")};if(!["system","user","assistant","tool"].includes(d.role))return{error:f(`'${d.role}' is not one of ['system', 'user', 'assistant', 'tool']`)}}for(let d of n){let b=Array.isArray(d.tools);if(!(d.role==="system"&&b&&d.content===void 0)&&b&&d.content===void 0)return{error:f("a dynamic tool message must use the 'system' role")}}if(!t.supports.vision)for(let d of n){let b=d.content;if(Array.isArray(b)&&b.some(x=>x?.type==="image_url"))return{error:f(`The model '${e.model}' does not support image input`)}}let o=e.logprobs===!0,i;if(e.top_logprobs!==void 0&&e.top_logprobs!==null){let d=Number(e.top_logprobs);if(!Number.isInteger(d)||d<0||d>20)return{error:f("'top_logprobs' must be an integer between 0 and 20")};if(!o)return{error:f("'logprobs' must be set to true when 'top_logprobs' is used")};i=d}let r=e.max_completion_tokens??e.max_tokens,c;if(r!==void 0){if(c=Number(r),!Number.isInteger(c)||c<1)return{error:f("'max_completion_tokens' must be an integer >= 1")};let d=C(n);if(d+c>t.context_length)return{error:f(`'max_completion_tokens' plus input tokens (${d+c}) exceeds the model context window (${t.context_length})`)}}let s;if(e.stop!==void 0&&e.stop!==null){if(typeof e.stop=="string")s=[e.stop];else if(Array.isArray(e.stop))s=e.stop;else return{error:f("'stop' must be a string or an array of strings")};if(s.length>Ce)return{error:f(`'stop' must not exceed ${Ce} strings`)};for(let d of s){if(typeof d!="string")return{error:f("'stop' must be a string or an array of strings")};if(Buffer.byteLength(d,"utf8")>Pe)return{error:f(`'stop' entries must not exceed ${Pe} bytes`)}}}let a,u=e.tool_choice;if(u!=null){if(typeof u=="string"){if(!["auto","none","required"].includes(u))return{error:f("'tool_choice' must be one of 'none', 'auto', 'required' or a named function")};a=u}else if(typeof u=="object"){let d=u.function?.name;if(typeof d!="string"||!d)return{error:f("'tool_choice.function.name' is required for a named tool choice")};a={name:d}}}let p={kind:"text"},h=e.response_format;if(h&&typeof h=="object"){if(h.type==="json_object")p={kind:"json_object"};else if(h.type==="json_schema"){let d=h.json_schema;if(!d||typeof d!="object")return{error:f("'response_format.json_schema' is required when 'response_format.type' is 'json_schema'")};if(typeof d.name!="string"||!d.name)return{error:f("'response_format.json_schema.name' is required")};if(!d.schema||typeof d.schema!="object")return{error:f("'response_format.json_schema.schema' is required")};p={kind:"json_schema",schema:d.schema}}else if(h.type!==void 0&&h.type!=="text")return{error:f("'response_format.type' must be one of 'text', 'json_object', 'json_schema'")}}if(e.tools!==void 0){if(!Array.isArray(e.tools))return{error:f("'tools' must be an array")};for(let d of e.tools){let b=d?.function?.name;if(typeof b!="string"||!te.test(b))return{error:f(`'tools[].function.name' must match ${te.source}`)}}}let l;if(e.reasoning_effort!==void 0&&e.reasoning_effort!==null){if(e.model!=="kimi-k3")return{error:f(`'reasoning_effort' is not a parameter of ${e.model}`)};if(typeof e.reasoning_effort!="string"||!$.includes(e.reasoning_effort))return{error:f(`'reasoning_effort' must be one of ${$.map(d=>`'${d}'`).join(", ")}`)};l=e.reasoning_effort}let m=Mt(e.model,e.thinking);if(m.error)return{error:m.error};let g=e.stream_options;return g!==void 0&&(typeof g!="object"||g===null)?{error:f("'stream_options' must be an object")}:{args:{model:e.model,messages:n,...e.tools!==void 0?{tools:e.tools}:{},n:1,...c!==void 0?{maxTokens:c}:{},...s!==void 0?{stop:s}:{},stream:e.stream===!0,...g?.include_usage===!0?{streamOptions:{includeUsage:!0}}:{},...a!==void 0?{toolChoice:a}:{},responseFormat:p,logprobs:o,...i!==void 0?{topLogprobs:i}:{},...l!==void 0?{reasoningEffort:l}:{},...m.value!==void 0?{thinking:m.value}:{},...typeof e.prompt_cache_key=="string"?{promptCacheKey:e.prompt_cache_key}:{}}}}function Nt(e,t){let n=Array.isArray(e.tools)&&e.tools.length>0,o=e.toolChoice==="none",i=typeof e.toolChoice=="object"?e.toolChoice.name:void 0;if(n&&!o){let p=e.tools,h=[];if(i){let l=K(e.tools,t+1,i);l&&h.push(l)}else for(let l=0;l<p.length;l++){let m=K([p[l]],t*100+l+1);m&&h.push(m)}if(h.length)return{choice:{index:t,message:{role:"assistant",content:null,tool_calls:h},finish_reason:"tool_calls"},completionTokens:y(JSON.stringify(h))}}let r=e.responseFormat.kind==="json_object"?Z(e.messages,e.model):e.responseFormat.kind==="json_schema"?Z(e.messages,e.model,e.responseFormat.schema):W(e.messages,e.model),c="stop",s=-1;for(let p of e.stop??[]){if(!p)continue;let h=r.indexOf(p);h>=0&&(s<0||h<s)&&(s=h)}s>=0&&(r=r.slice(0,s)),e.maxTokens!==void 0&&y(r)>e.maxTokens&&(r=r.slice(0,e.maxTokens*4),c="length");let a={role:"assistant",content:r};if((e.model==="kimi-k3"||e.model==="kimi-k2.7-code"||e.model==="kimi-k2.7-code-highspeed"||e.model==="kimi-k2.6"&&e.thinking?.type!=="disabled")&&(a.reasoning_content=D(e.messages,e.model),e.maxTokens!==void 0)){let p=y(String(a.content??""));if(p>=e.maxTokens)delete a.reasoning_content;else{let h=e.maxTokens-p,l=a.reasoning_content;y(l)>h&&(a.reasoning_content=l.slice(0,h*4))}}return{choice:{index:t,message:a,finish_reason:c},completionTokens:y(String(a.content??""))+y(a.reasoning_content??"")}}function he(e,t,n){let o=C(e.messages),i=null,r="";if(n)if(n.kind==="handler"){let p=n.respond;if(p.error)return Je(p.error);i=q(p)}else r=`
6
+ [twin-scenario miss \u2014 no handler matched. Author one in the world dir's handlers/moonshot.json (GET /twin explains; GET /twin/scenario lists handlers + misses). Features seen: ${JSON.stringify(n.miss.features)}]`;let c=[],s=0;for(let p=0;p<e.n;p++){if(i){let m=i.toolCalls.length?{role:"assistant",content:i.text,tool_calls:i.toolCalls}:{role:"assistant",content:i.text??""};i.reasoning!==null&&(m.reasoning_content=i.reasoning),c.push({index:p,message:m,finish_reason:i.finishReason}),s+=y(JSON.stringify(i.toolCalls.length?i.toolCalls:i.text??""));continue}let{choice:h,completionTokens:l}=Nt(e,p);r&&typeof h.message.content=="string"&&(h.message.content+=r),c.push(h),s+=l}let a=se(o,s,e.promptCacheKey);return{id:`chatcmpl-twin-${A(e.messages,e.model)}`,object:"chat.completion",created:G(t),model:e.model,choices:c,usage:a}}function Je(e){if(e.type==="rate_limit_reached_error"){let t=Ge();return e.message?{...t,body:v("rate_limit_reached_error",e.message)}:t}return e.type==="server_unavailable"?e.message?{...de(),body:v("server_unavailable",e.message)}:de():{status:500,body:v("server_error",e.message??"Internal Server Error")}}var H=e=>typeof e.status=="number"&&"body"in e;function fe(e){if(!e)return[];let t=[];for(let n=0;n<e.length;n+=20)t.push(e.slice(n,n+20));return t}function Ke(e,t,n,o){let i=he(e,n,o);if(H(i))return i;let r=i,c={id:r.id,object:"chat.completion.chunk",created:r.created,model:r.model};for(let s of r.choices){let a=s.index;if(t({data:{...c,choices:[{index:a,delta:{role:"assistant",content:""},finish_reason:null,usage:null}]}}),s.message.reasoning_content&&t({data:{...c,choices:[{index:a,delta:{reasoning_content:s.message.reasoning_content},finish_reason:null,usage:null}]}}),s.message.tool_calls&&s.message.tool_calls.length)s.message.tool_calls.forEach((u,p)=>{t({data:{...c,choices:[{index:a,delta:{tool_calls:[{index:p,id:u.id,type:"function",function:{name:u.function.name,arguments:""}}]},finish_reason:null,usage:null}]}}),t({data:{...c,choices:[{index:a,delta:{tool_calls:[{index:p,function:{arguments:u.function.arguments}}]},finish_reason:null,usage:null}]}})});else for(let u of fe(s.message.content??""))t({data:{...c,choices:[{index:a,delta:{content:u},finish_reason:null,usage:null}]}});t({data:{...c,choices:[{index:a,delta:{},finish_reason:s.finish_reason,usage:null}]}})}return t({data:{...c,choices:[],finish_reason:null,usage:r.usage}}),t({done:!0}),r}function It(e){if(e.model===void 0||typeof e.model!="string"||!e.model)return f("'model' is a required property");if(!F(e.model))return f(`The model '${e.model}' does not exist or you do not have access to it.`);if(!Array.isArray(e.messages))return{status:400,body:v("invalid_request_error","'messages' is a required property")};let t=e.messages;for(let n of t){if(!n||typeof n!="object"||typeof n.role!="string")return f("each message must have a valid 'role'");if(n.content===void 0||n.content===null||typeof n.content=="string"&&n.content==="")return f("'messages[].content' must not be empty")}return{status:200,body:{data:{total_tokens:C(t)}}}}function Ct(e,t){for(let r of["nonce","timestamp","model","signature"])if(e[r]===void 0||e[r]===null||e[r]==="")return f(`'${r}' is a required property`);if(typeof e.nonce!="string"||typeof e.model!="string"||typeof e.signature!="string")return f("'nonce', 'model' and 'signature' must be strings");let n=Number(e.timestamp);if(!Number.isFinite(n)||n<1)return f("'timestamp' must be a positive integer");let o=String(e.signature);if(!o.startsWith("reqsigv1_"))return{status:200,body:{valid:!1}};let i=me(String(e.nonce),n,String(e.model));return{status:200,body:{valid:o===i}}}function me(e,t,n){return`reqsigv1_twin_${P(`${e}|${t}|${n}`).toString(36)}`}var Pt=/^\d{4}(-\d{2})?(-\d{2})?$/;function Bt(e){if(e===void 0)return null;if(typeof e!="object"||e===null)return f("'time_window' must be an object");let t=e;for(let n of["start","end"])if(t[n]!==void 0&&(typeof t[n]!="string"||!Pt.test(t[n])))return f(`'time_window.${n}' must be in YYYY, YYYY-MM or YYYY-MM-DD format`);return null}function Be(e,t){if(typeof e.text_query!="string"||!e.text_query)return f("'text_query' is a required property and must not be empty");if(e.limit!==void 0){let r=Number(e.limit);if(!Number.isInteger(r)||r<1||r>20)return f("'limit' must be an integer between 1 and 20")}if(e.timeout_seconds!==void 0){let r=Number(e.timeout_seconds);if(!Number.isInteger(r)||r<1||r>60)return f("'timeout_seconds' must be an integer between 1 and 60")}if(t){if(e.sites!==void 0){if(!Array.isArray(e.sites)||e.sites.length>5)return f("'sites' must be an array of at most 5 strings");for(let c of e.sites)if(typeof c!="string"||!c||/\s|\(|\)/.test(c))return f("'sites' entries must be non-empty and contain no whitespace or parentheses")}let r=Bt(e.time_window);if(r)return r}else if(e.include_content!==void 0&&typeof e.include_content!="boolean")return f("'include_content' must be a boolean");let n=e.limit===void 0?5:Number(e.limit),o=t?!1:e.include_content===!0;return{status:200,body:{search_results:ie(String(e.text_query),n,t,o)}}}function Ft(e){return typeof e.url!="string"||!e.url?f("'url' is a required property"):/^https?:\/\//.test(e.url)?{status:200,body:ae(e.url)}:f("'url' must be an http or https URL")}var Fe=new Set(["file-extract","image","video","batch"]);async function Dt(e,t){let n=String(e.purpose??"");if(!n)return f("'purpose' is a required property");if(!Fe.has(n))return f(`'purpose' must be one of ${[...Fe].map(u=>`'${u}'`).join(", ")} (got '${n}')`);if(e._multipart_missing_file===!0)return f("the multipart form carries no 'file' part");let o=String(e.filename??e.file??"upload"),i=typeof e.content=="string"?e.content:"",r=e.binary_content===!0;if(r&&!/^[A-Za-z0-9+/]*={0,2}$/.test(i)||r&&i.length%4!==0)return f("'binary_content' content must be base64-encoded");let c=typeof e.bytes=="number"?e.bytes:r?Buffer.from(i,"base64").length:Buffer.byteLength(i,"utf8"),s=Ue("file","file",t.root);await ee(B,{operation:"file.create",subjectType:"file",subjectId:s,fields:{object:"file",bytes:c,created_at:G(t.occurredAt),filename:o,purpose:n,status:"ready",_content:i,...r?{_content_encoding:"base64"}:{}},...t.occurredAt?{occurredAt:t.occurredAt}:{},actor:{kind:"agent"}},t.root);let a=k("file",s,t.root);return{status:200,body:pe(a??{})}}function pe(e){let t=We(e);return{id:e.id,object:"file",bytes:t.bytes,created_at:t.created_at,filename:t.filename,purpose:t.purpose,status:t.status??"ready"}}var De=new Set(["/v1/chat/completions"]),Lt=/^(\d+)(h|d)$/;function Ht(e){let t=Lt.exec(e);if(!t)return null;let n=Number(t[1]);return t[2]==="d"?n*24:n}async function Gt(e,t){let n=e.input_file_id;if(typeof n!="string"||!n)return f("'input_file_id' is a required property");let o=e.endpoint;if(typeof o!="string"||!De.has(o))return f(`'endpoint' must be one of ${[...De].map(u=>`'${u}'`).join(", ")}`);let i=e.completion_window;if(typeof i!="string")return f("'completion_window' is a required property");let r=Ht(i);if(r===null||r<12||r>168)return f("'completion_window' must be a duration from '12h' to '7d'");if(e.metadata!==void 0){let u=e.metadata;if(!u||typeof u!="object"||Array.isArray(u))return f("'metadata' must be an object");let p=Object.entries(u);if(p.length>16)return f("'metadata' must not exceed 16 key-value pairs");for(let[h,l]of p){if(h.length>64)return f("'metadata' keys must not exceed 64 characters");if(typeof l!="string"||l.length>512)return f("'metadata' values must be strings of at most 512 characters")}}let c=k("file",n,t.root);if(!c||c._deleted)return M(`No such File object: ${n}`);if(c.purpose!=="batch")return f(`File ${n} must have purpose 'batch' (has '${String(c.purpose)}')`);let s=G(t.occurredAt),a=Ue("batch","batch",t.root);return await ee(B,{operation:"batch.create",subjectType:"batch",subjectId:a,fields:{object:"batch",endpoint:o,input_file_id:n,completion_window:i,status:"validating",output_file_id:null,error_file_id:null,created_at:s,in_progress_at:null,expires_at:s+r*3600,finalizing_at:null,completed_at:null,failed_at:null,cancelling_at:null,cancelled_at:null,request_counts:{total:0,completed:0,failed:0},metadata:e.metadata??null},...t.occurredAt?{occurredAt:t.occurredAt}:{},actor:{kind:"agent"}},t.root),{status:200,body:Q(k("batch",a,t.root)??{})}}function Q(e){return{id:e.id,...We(e)}}function Ut(e){let t=k("balance","me",e);return{status:200,body:{code:0,data:t&&!t._deleted?{available_balance:Number(t.available_balance),voucher_balance:Number(t.voucher_balance),cash_balance:Number(t.cash_balance)}:{available_balance:49.58894,voucher_balance:46.58893,cash_balance:3.00001},scode:"0x0",status:!0}}}function Le(e){let t=e;return typeof t?.name=="string"?t.name:""}function Wt(e){if(e.model===void 0||e.model==="")return{error:_(400,"invalid_request_error","'model' is a required property")};if(!F(String(e.model))?.supports.messages)return{error:_(400,"invalid_request_error",`The endpoint currently supports 'kimi-k3' only (got '${String(e.model)}')`)};if(!Array.isArray(e.messages))return{error:_(400,"invalid_request_error","'messages' is a required property")};if(e.messages.length===0)return{error:_(400,"invalid_request_error","'messages' must not be empty")};let t=[];for(let u of e.messages){if(!u||typeof u!="object")return{error:_(400,"invalid_request_error","each message must be an object")};if(u.role!=="user"&&u.role!=="assistant")return{error:_(400,"invalid_request_error",`'${String(u.role)}' is not one of ['user', 'assistant'] \u2014 use the top-level 'system' field for the system prompt`)};t.push({role:u.role,content:u.content})}if(e.max_tokens===void 0||e.max_tokens===null)return{error:_(400,"invalid_request_error","'max_tokens' is a required property")};let n=Number(e.max_tokens);if(!Number.isInteger(n)||n<1)return{error:_(400,"invalid_request_error","'max_tokens' must be an integer >= 1")};let o;if(e.system!==void 0)if(typeof e.system=="string")o=e.system;else if(Array.isArray(e.system))o=e.system.map(u=>String(u?.text??"")).join(`
7
+ `);else return{error:_(400,"invalid_request_error","'system' must be a string or an array of text blocks")};let i;if(e.stop_sequences!==void 0){if(!Array.isArray(e.stop_sequences))return{error:_(400,"invalid_request_error","'stop_sequences' must be an array of strings")};if(e.stop_sequences.length>5)return{error:_(400,"invalid_request_error","'stop_sequences' must not exceed 5 entries")};for(let u of e.stop_sequences){if(typeof u!="string")return{error:_(400,"invalid_request_error","'stop_sequences' entries must be strings")};if(Buffer.byteLength(u,"utf8")>32)return{error:_(400,"invalid_request_error","'stop_sequences' entries must not exceed 32 bytes")}}i=e.stop_sequences}let r;if(e.tools!==void 0){if(!Array.isArray(e.tools))return{error:_(400,"invalid_request_error","'tools' must be an array")};for(let u of e.tools){if(!u||typeof u!="object"||Array.isArray(u))return{error:_(400,"invalid_request_error","each tool must be an object")};let p=Le(u);if(!p||!te.test(p))return{error:_(400,"invalid_request_error",`'tools[].name' must match ${te.source}`)};let h=u.input_schema;if(h!==void 0&&(!h||typeof h!="object"||Array.isArray(h)))return{error:_(400,"invalid_request_error","'tools[].input_schema' must be an object")}}r=e.tools}let c;if(e.tool_choice!==void 0){let u=e.tool_choice?.type;if(typeof u!="string"||!["auto","any","tool","none"].includes(u))return{error:_(400,"invalid_request_error","'tool_choice.type' must be one of 'auto', 'any', 'tool', 'none'")};if(!r)return{error:_(400,"invalid_request_error","'tool_choice' requires 'tools' to be set")};if(u==="tool"){let p=e.tool_choice.name;if(typeof p!="string"||!r.some(h=>Le(h)===p))return{error:_(400,"invalid_request_error",`'tool_choice' names tool '${typeof p=="string"?p:String(p)}', which is not in tools`)};c={type:"tool",name:p}}else c={type:u}}let s,a=e.output_config;if(a&&typeof a=="object"&&a.effort!==void 0){if(typeof a.effort!="string"||!$.includes(a.effort))return{error:_(400,"invalid_request_error",`'output_config.effort' must be one of ${$.map(u=>`'${u}'`).join(", ")}`)};s=a.effort}return{args:{model:String(e.model),messages:t,maxTokens:n,...o!==void 0?{system:o}:{},...i!==void 0?{stopSequences:i}:{},stream:e.stream===!0,...r!==void 0?{tools:r}:{},...c!==void 0?{toolChoice:c}:{},...s!==void 0?{outputEffort:s}:{}}}}function _(e,t,n){return{status:e,body:{type:"error",error:{type:t,message:n}}}}function Jt(e,t){let n=t?.error,o=n?.message??`The request was refused by a scripted fault (${e}).`;return{type:"error",error:{type:n?.type==="rate_limit_reached_error"?"rate_limit_error":n?.type==="server_unavailable"||n?.type==="server_error"?"api_error":"invalid_request_error",message:o}}}function _e(e,t,n){let o=null,i="";if(n)if(n.kind==="handler"){let l=n.respond;if(l.error)return Kt(l.error);o=q(l)}else i=`
8
+ [twin-scenario miss \u2014 no handler matched. Author one in handlers/moonshot.json.]`;let r=C(e.messages.map(l=>({role:l.role,content:l.content}))),c,s,a;if(o){c=[],o.reasoning!==null&&c.push({type:"thinking",thinking:o.reasoning,signature:V(e.messages,e.model)}),o.text&&c.push({type:"text",text:o.text+(i&&o.text?i:"")});for(let l of o.toolCalls)c.push({type:"tool_use",id:l.id,name:l.function.name,input:JSON.parse(l.function.arguments)});s=o.finishReason==="tool_calls"?"tool_use":o.finishReason==="length"?"max_tokens":"end_turn"}else{let l=Array.isArray(e.tools)&&e.tools.length>0,m=e.toolChoice?.type??"auto",g=m==="none",d=m==="tool"?e.toolChoice?.name:void 0,b=e.messages[e.messages.length-1],x=b?.role==="user"&&Array.isArray(b.content)&&b.content.some(S=>S?.type==="tool_result"),w=l&&!g&&(m==="any"||m==="tool"||!x)?[K(e.tools,1,d)].filter(S=>S!==null):[];c=[{type:"thinking",thinking:D(e.messages.map(S=>({role:S.role,content:S.content})),e.model),signature:V(e.messages,e.model)}],w.length?w.forEach((S,X)=>{c.push({type:"tool_use",id:`toolu_twin_${X+1}`,name:S.function.name,input:JSON.parse(S.function.arguments)})}):c.push({type:"text",text:W(e.messages.map(S=>({role:S.role,content:S.content})),e.model)+(i||"")}),s=w.length?"tool_use":"end_turn"}let u=l=>l.type==="thinking"?y(l.thinking):l.type==="text"?y(l.text):y(JSON.stringify(l.input)),p=()=>c.reduce((l,m)=>l+u(m),0);if(e.maxTokens!==void 0&&p()>e.maxTokens){let l=0,m=!1;for(let g=0;g<c.length;g++){let d=c[g],b=u(d);if(l+b<=e.maxTokens){l+=b;continue}let x=e.maxTokens-l;if(m=!0,(d.type==="text"||d.type==="thinking")&&(x>=1||g===0)){let T=Math.max(1,x);d.type==="text"?d.text=d.text.slice(0,T*4):d.thinking=d.thinking.slice(0,T*4),l+=u(d),c.length=g+1;break}c.length=g,c.length===0&&c.push({type:"text",text:""});break}a=l,m&&(s="max_tokens")}else a=p();let h=null;if(e.stopSequences?.length){let l=c.find(m=>m.type==="text");if(l&&l.type==="text"){for(let m of e.stopSequences){let g=l.text.indexOf(m);if(g>=0){l.text=l.text.slice(0,g),h=m,s="stop_sequence";break}}a=p()}}return{id:`msg_twin_${A(e.messages,e.model)}`,type:"message",role:"assistant",model:e.model,content:c,stop_reason:s,stop_sequence:h,usage:{input_tokens:r,output_tokens:a,cache_read_input_tokens:J(r),cache_creation_input_tokens:0}}}function Kt(e){return e.type==="rate_limit_reached_error"?_(429,"rate_limit_reached_error",e.message??"Request rate limit reached"):e.type==="server_unavailable"?_(503,"server_unavailable",e.message??"The server is overloaded"):_(500,"server_error",e.message??"Internal Server Error")}function qe(e,t,n,o){let i=_e(e,n,o);if(H(i))return i;let r=i;return t({event:"message_start",data:{type:"message_start",message:{id:r.id,type:"message",role:"assistant",model:r.model,content:[],stop_reason:null,stop_sequence:null,usage:{input_tokens:r.usage.input_tokens,output_tokens:0,cache_read_input_tokens:0,cache_creation_input_tokens:0}}}}),t({event:"ping",data:{type:"ping"}}),r.content.forEach((c,s)=>{if(c.type==="thinking"){t({event:"content_block_start",data:{type:"content_block_start",index:s,content_block:{type:"thinking",thinking:""}}});for(let a of fe(c.thinking))t({event:"content_block_delta",data:{type:"content_block_delta",index:s,delta:{type:"thinking_delta",thinking:a}}});t({event:"content_block_delta",data:{type:"content_block_delta",index:s,delta:{type:"signature_delta",signature:c.signature??""}}}),t({event:"content_block_stop",data:{type:"content_block_stop",index:s}})}else if(c.type==="text"){t({event:"content_block_start",data:{type:"content_block_start",index:s,content_block:{type:"text",text:""}}});for(let a of fe(c.text))t({event:"content_block_delta",data:{type:"content_block_delta",index:s,delta:{type:"text_delta",text:a}}});t({event:"content_block_stop",data:{type:"content_block_stop",index:s}})}else{t({event:"content_block_start",data:{type:"content_block_start",index:s,content_block:{type:"tool_use",id:c.id,name:c.name,input:{}}}});let a=JSON.stringify(c.input);t({event:"content_block_delta",data:{type:"content_block_delta",index:s,delta:{type:"input_json_delta",partial_json:a}}}),t({event:"content_block_stop",data:{type:"content_block_stop",index:s}})}}),t({event:"message_delta",data:{type:"message_delta",delta:{stop_reason:r.stop_reason,stop_sequence:r.stop_sequence},usage:{output_tokens:r.usage.output_tokens}}}),t({event:"message_stop",data:{type:"message_stop"}}),t({done:!0}),r}function qt(e){if(e.model===void 0||e.model==="")return{error:f("'model' is a required property")};if(!F(String(e.model))?.supports.responses)return{error:f(`This endpoint currently supports 'kimi-k3' only (got '${String(e.model)}')`)};if(e.input===void 0||e.input===null)return{error:f("'input' is a required property")};if(typeof e.input!="string"&&!Array.isArray(e.input))return{error:f("'input' must be a string or an array of items")};let n,o=e.reasoning;if(o&&typeof o=="object"&&o.effort!==void 0){if(typeof o.effort!="string"||!$.includes(o.effort))return{error:f(`'reasoning.effort' must be one of ${$.map(r=>`'${r}'`).join(", ")}`)};n=o.effort}let i;return e.max_output_tokens!==void 0&&(i=Number(e.max_output_tokens),!Number.isInteger(i)||i<1)?{error:f("'max_output_tokens' must be an integer >= 1")}:{args:{model:String(e.model),input:e.input,...typeof e.instructions=="string"?{instructions:e.instructions}:{},...i!==void 0?{maxOutputTokens:i}:{},...n!==void 0?{reasoningEffort:n}:{},stream:e.stream===!0}}}function Ye(e){return typeof e=="string"?e:e.map(t=>{if(t.type==="message"||t.type===void 0){let n=t.content;return O(n)}return JSON.stringify(t)}).join(`
9
+ `)}function ge(e,t,n){let o=null,i="";if(n)if(n.kind==="handler"){let l=n.respond;if(l.error)return Je(l.error);o=q(l)}else i=`
10
+ [twin-scenario miss \u2014 no handler matched. Author one in handlers/moonshot.json.]`;let r=Ye(e.input),c=[{role:"user",content:r}],s=C(c),a=[],u=0;if(o)if(o.reasoning!==null&&(a.push({type:"reasoning",id:`rs_twin_${A(e.input,"reasoning")}`,summary:[{type:"summary_text",text:o.reasoning}],status:"completed"}),u+=y(o.reasoning)),o.toolCalls.length)for(let l of o.toolCalls)a.push({type:"function_call",id:`fc_twin_${A(l)}`,call_id:l.id,name:l.function.name,arguments:l.function.arguments,status:"completed"}),u+=y(l.function.arguments);else{let l=(o.text??"")+(i||"");a.push({type:"message",id:`msg_twin_${A(e.input,"message")}`,role:"assistant",status:"completed",content:[{type:"output_text",text:l,annotations:[]}]}),u+=y(l)}else{a.push({type:"reasoning",id:`rs_twin_${A(r,"reasoning")}`,summary:[{type:"summary_text",text:D(c,e.model)}],status:"completed"});let l=W(c,e.model)+(i||"");a.push({type:"message",id:`msg_twin_${A(r,"message")}`,role:"assistant",status:"completed",content:[{type:"output_text",text:l,annotations:[]}]}),u=y(D(c,e.model))+y(l)}let p="completed",h=null;if(e.maxOutputTokens!==void 0&&u>e.maxOutputTokens){let l=0,m=!1;for(let g=0;g<a.length;g++){let d=a[g],b=y(d.type==="message"?d.content.map(w=>w.text??"").join(""):d.type==="reasoning"?d.summary.map(w=>w.text??"").join(""):d.type==="function_call"?d.arguments:d.type==="custom_tool_call"?d.input:"");if(l+b<=e.maxOutputTokens){l+=b;continue}let x=e.maxOutputTokens-l,T=Math.max(1,x)*4;(d.type==="message"||d.type==="reasoning")&&x>=1&&(d.type==="message"?d.content[0].text=(d.content[0].text??"").slice(0,T):d.summary[0].text=(d.summary[0].text??"").slice(0,T),l+=y(d.type==="message"?d.content[0].text??"":d.summary[0].text??"")),a.length=g+1,m=!0;break}u=l,m&&(p="incomplete",h={reason:"max_output_tokens"})}return{id:`resp_twin_${A(r,e.model)}`,object:"response",created_at:G(t),completed_at:p==="completed"||p==="incomplete"?G(t):null,status:p,model:e.model,output:a,usage:{input_tokens:s,input_tokens_details:{cached_tokens:J(s),cache_write_tokens:0},output_tokens:u,output_tokens_details:{reasoning_tokens:a.filter(l=>l.type==="reasoning").reduce((l,m)=>l+y(m.summary.map(g=>g.text??"").join("")),0)},total_tokens:s+u},incomplete_details:h,error:null,store:!1}}function Xe(e,t,n,o){let i=ge(e,n,o);if(H(i))return i;let r=i,c=0,s=(a,u)=>t({event:a,data:{type:a,sequence_number:c++,...u}});s("response.created",{response:{...r,status:"in_progress",output:[],usage:null}}),s("response.in_progress",{response:{...r,status:"in_progress",output:[],usage:null}});for(let a of r.output)s("response.output_item.added",{output_index:r.output.indexOf(a),output_item:a}),s("response.output_item.done",{output_index:r.output.indexOf(a),output_item:a});return s(r.status==="completed"?"response.completed":"response.incomplete",{response:r}),t({done:!0}),r}async function ne(e){let t=e.method.toUpperCase(),n=He(e.path);if(e.headers!==void 0||e.apiKey!==void 0){let r=At(e);if(r)return r}if(Ie(e,"x-twin-force-rate-limit")){let r=Ge();return n?{..._(429,"rate_limit_error",r.body.error.message),headers:r.headers}:r}if(Ie(e,"x-twin-force-server-unavailable")){let r=de();return n?_(503,"overloaded_error",r.body.error.message):r}let o=await Yt(e,t),i=e.headers?.["x-msh-request-nonce"];if(i&&e.sseSink&&e.method.toUpperCase()==="POST"&&e.path===`${R}/chat/completions`){let r=(()=>{try{return typeof JSON.parse(e.body??"").model=="string"?JSON.parse(e.body??"").model:null}catch{return null}})();if(r){let c=Date.parse(e.occurredAt??Ot());return{...o,headers:{...o.headers??{},"msh-request-timestamp":String(c),"msh-request-signature":me(i,c,r)}}}}return o}async function Yt(e,t){let n=(e.path.split("?")[0]??"/").replace(/\/+$/,"")||"/",o=jt(e.body),i=a=>decodeURIComponent(a),r=n===R||n.startsWith(`${R}/`),c=n===N||n.startsWith(`${N}/`);if(!r&&!c)return M(`Unknown request URL: ${t} ${n}.`);if(e.readOnly&&t!=="GET"){let a="twin is read-only; omit readOnly to accept writes";return c?_(405,"invalid_request_error",a):{status:405,body:v("invalid_request_error",a)}}if(c){if(n!==`${N}/messages`)return _(404,"not_found_error",`Unknown request URL: ${t} ${n}.`);if(t!=="POST")return _(405,"invalid_request_error",`${t} is not supported on /anthropic/v1/messages`);let a=Wt(o);if("error"in a)return a.error;let u=a.args,p;if(e.scenarioEngine){let l=await e.scenarioEngine.serve({model:u.model,messages:u.messages.map(m=>({role:m.role,content:m.content})),tools:u.tools,thinking:void 0});if(l.kind==="fault")return{status:l.result.status,body:Jt(l.result.status,l.result.body),headers:l.result.headers};p=l}let h=u.stream&&e.messagesSseSink?qe(u,e.messagesSseSink,e.occurredAt,p):_e(u,e.occurredAt,p);return H(h)?h:{status:200,body:h}}let s=n.slice(R.length).replace(/^\/+/,"").split("/").filter(Boolean);if(s[0]==="files"&&s[1]&&(s[1]=Re(B,"file",i(s[1]),e.root)),s[0]==="batches"&&s[1]&&(s[1]=Re(B,"batch",i(s[1]),e.root)),s[0]==="models"&&s.length===1&&t==="GET")return{status:200,body:{object:"list",data:$t(e.root)}};if(s[0]==="chat"&&s[1]==="completions"&&s.length===2&&t==="POST"){let a=Rt(o);if("error"in a)return a.error;let u=a.args,p;if(e.scenarioEngine){let l=await e.scenarioEngine.serve({model:u.model,messages:u.messages,tools:u.tools,thinking:u.thinking});if(l.kind==="fault")return{status:l.result.status,body:l.result.body,headers:l.result.headers};p=l}let h=u.stream&&e.sseSink?Ke(u,e.sseSink,e.occurredAt,p):he(u,e.occurredAt,p);return H(h)?h:{status:200,body:h}}if(s[0]==="responses"&&s.length===1&&t==="POST"){let a=qt(o);if("error"in a)return a.error;let u=a.args,p;if(e.scenarioEngine){let l=await e.scenarioEngine.serve({model:u.model,messages:[{role:"user",content:Ye(u.input)}],tools:void 0,thinking:void 0});if(l.kind==="fault")return{status:l.result.status,body:l.result.body,headers:l.result.headers};p=l}let h=u.stream&&e.messagesSseSink?Xe(u,e.messagesSseSink,e.occurredAt,p):ge(u,e.occurredAt,p);return H(h)?h:{status:200,body:h}}if(s[0]==="tokenizers"&&s[1]==="estimate-token-count"&&s.length===2&&t==="POST")return It(o);if(s[0]==="signatures"&&s[1]==="verify"&&s.length===2&&t==="POST")return Ct(o,e);if(s[0]==="tools"&&s[1]==="search"&&s.length===2&&t==="POST")return Be(o,!1);if(s[0]==="tools"&&s[1]==="search_pro"&&s.length===2&&t==="POST")return Be(o,!0);if(s[0]==="tools"&&s[1]==="fetch"&&s.length===2&&t==="POST")return Ft(o);if(s[0]==="users"&&s[1]==="me"&&s[2]==="balance"&&s.length===3&&t==="GET")return Ut(e.root);if(s[0]==="files"&&s.length===1&&t==="POST")return Dt(o,e);if(s[0]==="files"&&s.length===1&&t==="GET")return{status:200,body:{object:"list",data:Y("file",e.root).filter(u=>!u._deleted).map(pe)}};if(s[0]==="files"&&s.length===2&&t==="GET"){let a=k("file",i(s[1]),e.root);return a&&!a._deleted?{status:200,body:pe(a)}:M(`No such File object: ${i(s[1])}`)}if(s[0]==="files"&&s.length===3&&s[2]==="content"&&t==="GET"){let a=k("file",i(s[1]),e.root);return!a||a._deleted?M(`No such File object: ${i(s[1])}`):a._content===void 0&&Number(a.bytes)>0?{status:501,body:v("server_error",`the twin holds no content for pulled file ${i(s[1])} (the vendor's list endpoint does not return file content; re-create the file locally to read it back)`)}:a._content_encoding==="base64"?{status:200,body:Buffer.from(String(a._content??""),"base64").toString("latin1"),headers:{"content-type":"application/octet-stream","x-twin-content-binary":"1"}}:{status:200,body:String(a._content??""),headers:{"content-type":"application/octet-stream"}}}if(s[0]==="files"&&s.length===2&&t==="DELETE"){let a=i(s[1]),u=k("file",a,e.root);return!u||u._deleted?M(`No such File object: ${a}`):(await ee(B,{operation:"file.delete",subjectType:"file",subjectId:a,fields:{_deleted:!0,object:"file"},...e.occurredAt?{occurredAt:e.occurredAt}:{},actor:{kind:"agent"}},e.root),{status:200,body:{id:a,object:"file",deleted:!0}})}if(s[0]==="batches"&&s.length===1&&t==="POST")return Gt(o,e);if(s[0]==="batches"&&s.length===1&&t==="GET")return{status:200,body:{object:"list",data:Y("batch",e.root).map(Q),has_more:!1}};if(s[0]==="batches"&&s.length===2&&t==="GET"){let a=k("batch",i(s[1]),e.root);return a?{status:200,body:Q(a)}:M(`No such Batch object: ${i(s[1])}`)}if(s[0]==="batches"&&s.length===3&&s[2]==="cancel"&&t==="POST"){let a=i(s[1]),u=k("batch",a,e.root);return u?u.status==="cancelling"||u.status==="cancelled"?f(`Cannot cancel a batch with status '${String(u.status)}'.`):(await ee(B,{operation:"batch.cancel",subjectType:"batch",subjectId:a,fields:{status:"cancelling",cancelling_at:G(e.occurredAt)},...e.occurredAt?{occurredAt:e.occurredAt}:{},actor:{kind:"agent"}},e.root),{status:200,body:Q(k("batch",a,e.root)??{})}):M(`No such Batch object: ${a}`)}return M(`Unknown request URL: ${t} ${n}.`)}import{serveHttp as kn,twinManifest as Xt,worldNow as ze}from"../../engine/v2/volter_world-core.mjs";function zt(e){if(!e)return!1;try{return JSON.parse(e)?.stream===!0}catch{return!1}}function Vt(e){return e.done?`data: [DONE]
11
+
12
+ `:`data: ${JSON.stringify(e.data)}
13
+
14
+ `}function Zt(e){return e.done?`
15
+ `:`event: ${e.event??"message"}
16
+ data: ${JSON.stringify(e.data)}
17
+
18
+ `}var Qt=new Set([`${R}/chat/completions`]),Ve=new Set([`${N}/messages`,`${R}/responses`]);async function en(e){try{let t=await e.formData(),n={};for(let[i,r]of t.entries())if(typeof r=="string")if(i.endsWith("[]")){let c=i.slice(0,-2),s=n[c];n[c]=Array.isArray(s)?[...s,r]:[r]}else n[i]=r;let o=t.get("file");if(o instanceof File||(n._multipart_missing_file=!0),o instanceof File){let i=new Uint8Array(await o.arrayBuffer());n.file=o.name||"upload",n.filename=o.name||"upload",n.content=Buffer.from(i).toString("base64"),n.binary_content=!0,n.media_type=o.type||"",n.bytes=i.length}return JSON.stringify(n)}catch{return"{}"}}function Ze(e){let t=e.readOnly??!1,n=e.scenarioPath??process.env.TWIN_MOONSHOT_SCENARIO,o=n?le(ue(n)):void 0;return async function(r){let c=new URL(r.url);if(r.method==="GET"&&c.pathname.replace(/\/+$/,"")==="/twin")return Response.json(Xt({vendor:"moonshot",twinOf:"Moonshot (Kimi) Platform API \u2014 OpenAI-compatible under /v1, Anthropic-compatible under /anthropic/v1; Moonshot ships no SDK of its own, its documented clients are the standard openai/anthropic SDKs with a swapped base URL",stateSentence:"Seed files through the ordinary API (POST /v1/files, multipart) with any key; files, batches and the account balance are stateful, everything else is deterministic.",behaviorSentence:"The three inference endpoints are scripted by MSW-shaped handlers in the world dir (handlers/moonshot.json): {on:{userTextIncludes|anyTextIncludes|modelEquals|hasTool|toolResultFor|lastMessageIsToolResult|thinkingTypeEquals}, respond:{text|reasoning|toolCalls, finishReason?} | {error:{type:rate_limit_reached_error|server_unavailable|server_error}}, once?, phase?}. Unmatched requests answer a labeled stub naming this door.",exampleHandler:{on:{userTextIncludes:"summarize",hasTool:"search_docs"},respond:{text:"Scripted summary."},once:!0},engine:o}));if(r.method==="GET"&&c.pathname.replace(/\/+$/,"")==="/twin/scenario")return Response.json(o?o.status():{vendor:"moonshot",handlers:[],misses:0,recentMisses:[]});let s=c.pathname+(c.search||""),a=c.pathname.replace(/\/{2,}/g,"/").replace(/\/+$/,""),u=r.headers.get("content-type")??"",p={};for(let x of["authorization","x-api-key","anthropic-version","x-msh-request-nonce","x-twin-force-rate-limit","x-twin-force-server-unavailable"]){let T=r.headers.get(x);T!==null&&(p[x]=T)}let h="";if(r.method!=="GET"&&(h=u.includes("multipart/form-data")?await en(r):await r.text()),!t&&r.method.toUpperCase()==="POST"&&(Qt.has(a)||Ve.has(a))&&zt(h)){let x=Ve.has(a),T=[],w=E=>T.push(E),S=E=>T.push(E),{status:X,body:_t,headers:Se}=await ne({...o?{scenarioEngine:o}:{},method:r.method,path:s,body:h,readOnly:t,occurredAt:ze(),headers:p,...e.root!==void 0?{root:e.root}:{},sseSink:x?void 0:w,messagesSseSink:x?S:void 0}),gt={"content-type":"text/event-stream; charset=utf-8","cache-control":"no-cache",connection:"keep-alive",...Se??{}};if(X!==200)return new Response(JSON.stringify(_t),{status:X,headers:{"content-type":"application/json",...Se??{}}});let yt=T.map(E=>"event"in E&&E.event!==void 0?Zt(E):Vt(E)).join("");return new Response(yt,{status:200,headers:gt})}let{status:m,body:g,headers:d}=await ne({...o?{scenarioEngine:o}:{},method:r.method,path:s,body:h,readOnly:t,occurredAt:ze(),headers:p,...e.root!==void 0?{root:e.root}:{}});if(r.method==="GET"&&/\/v1\/files\/[^/]+\/content$/.test(a)&&m===200){let T=d?.["x-twin-content-binary"]==="1"?Buffer.from(String(g),"latin1"):Buffer.from(String(g),"utf8"),w={...d};return delete w["x-twin-content-binary"],new Response(T,{status:m,headers:{"content-type":"application/octet-stream",...w}})}return new Response(JSON.stringify(g),{status:m,headers:{"content-type":"application/json",...d??{}}})}}import{assertBudgetGuardIntact as Pn,confirmAction as Bn,deployableEntries as Fn,observeResources as sn,resolveSubjectId as Dn}from"../../engine/v2/volter_world-core.mjs";import{declareRateBudget as tn,rateBudgetPath as jn,rateBudgetWeight as Mn,RateBudget as Rn}from"../../engine/v2/volter_world-core.mjs";import{RateBudgetError as nt}from"../../engine/v2/volter_world-core.mjs";var nn="moonshot",Qe=6e4,et=60,tt=300,I={inference:6,webSearch:6,other:2},oe={windowMs:Qe,ceiling:et,defaultWeight:I.other,maxRetryAfterSeconds:tt,rules:[{match:"^POST /v1/chat/completions$",weight:I.inference},{match:"^POST /v1/responses$",weight:I.inference},{match:"^POST /anthropic/v1/messages$",weight:I.inference},{match:"^POST /v1/tools/search$",weight:I.webSearch},{match:"^POST /v1/tools/search_pro$",weight:I.webSearch},{match:"^POST /v1/tools/fetch$",weight:I.webSearch}],reason:"Moonshot publishes a per-tier limit table (platform.kimi.ai/docs/pricing/limits, read 2026-09-16): Tier 0 (deposit \u2265 $1) is concurrency 1, RPM 3, TPM 500,000, TPD 1,500,000, Web Search QPS 1; Tier 5 (\u2265 $3000) is 100/300/5M/Unlimited/50. A 429 carries X-RateLimit-Limit / X-RateLimit-Remaining / X-RateLimit-Reset. Because the LOWEST published RPM (3) is far under the kernel fallback of 30 calls/min, the ceiling is pinned AT the fallback (60 units / 60s, defaultWeight 2) and the declaration spends it downward: the three model-facing inference endpoints (POST /v1/chat/completions, POST /v1/responses, POST /anthropic/v1/messages) cost 6 each \u2014 at most 10 land in a window \u2014 because those calls are token-metered (TPM) at the vendor and one call spends far more of a real account's allowance than a list poll. The web-search tool endpoints get their own 6-weight rule because Moonshot meters them on a SEPARATE QPS pool (1 at Tier 0), so a search sweep must not be priceable as a cheap read. The per-tier judgment call is the strict direction: the budget protects Tier 0 by construction and only ever under-spends a higher tier. The window bounds the 60s AVERAGE and does not pace; a `retry-after` read off a real 429 is the persisted cooldown backstop."};tn(nn,oe);var ot="moonshot";function an(e){return Array.isArray(e.data)?e.data:[]}function ye(e,t){if(e.error)throw new Error(`moonshot ${t} failed: ${e.error.message??e.error.type??"unknown error"}`)}function rt(e){return{type:"model",id:String(e.id),fields:{object:"model",created:e.created??null,owned_by:e.owned_by??null}}}function st(e){return{type:"file",id:String(e.id),fields:{object:"file",bytes:e.bytes??0,created_at:e.created_at??null,filename:e.filename??null,purpose:e.purpose??null,status:e.status??null}}}function it(e){let t=e.request_counts&&typeof e.request_counts=="object"?e.request_counts:{};return{type:"batch",id:String(e.id),fields:{object:"batch",endpoint:e.endpoint??null,input_file_id:e.input_file_id??null,completion_window:e.completion_window??null,status:e.status??null,output_file_id:e.output_file_id??null,created_at:e.created_at??null,completed_at:e.completed_at??null,request_counts:t}}}function at(e){let t=e.data&&typeof e.data=="object"?e.data:{};return{type:"balance",id:"me",fields:{available_balance:t.available_balance??null,voucher_balance:t.voucher_balance??null,cash_balance:t.cash_balance??null}}}var cn=[{path:"/v1/models",map:rt},{path:"/v1/files",map:st},{path:"/v1/batches",map:it}];async function ct(e){let t=[];for(let o of cn){let i=await e("GET",o.path);ye(i,`pull ${o.path}`);for(let r of an(i))t.push(o.map(r))}let n=await e("GET","/v1/users/me/balance");return ye(n,"pull /v1/users/me/balance"),t.push(at(n)),t}async function ut(e,t){let n=await ct(e),o=sn(ot,n.map(i=>({type:i.type,id:i.id,fields:i.fields})),{...t.root!==void 0?{root:t.root}:{},at:t.occurredAt,batch:`obs:${ot}:${t.occurredAt}`});return{observed:o.observed,deltasAppended:o.appended}}var lt=new Set(["create","cancel","delete"]);function un(e){let t=e.includes(".")?e.slice(e.indexOf(".")+1):e;if(!lt.has(t))throw new Error(`moonshot push: unsupported operation '${e}' \u2014 refusing to silently drop a local write`);let n=ft[e];if(n)throw new Error(`moonshot push: cannot push '${e}' \u2014 ${n}`)}function dt(e){let t=e.includes(".")?e.slice(e.indexOf(".")+1):e;return lt.has(t)?ft[e]??null:`unsupported operation '${e}'`}var ln={file:"/v1/files",batch:"/v1/batches"},ft={"file.create":"real Moonshot's POST /v1/files is multipart/form-data with the file body; this JSON executor cannot express it, and the twin stores no real bytes to send"},pt=/_twin_\d+$/;function ht(e,t){let n=e.operation??`${e.subject.type}.update`,o=n.includes(".")?n.slice(n.indexOf(".")+1):n,i=ln[e.subject.type];if(!i)throw new Error(`moonshot push: no REST collection for subject type '${e.subject.type}'`);if(o==="create")return{method:"POST",path:i};let r=t??e.subject.id;if(pt.test(r))throw new Error(`moonshot push: refusing to address the real account by the twin's own id '${r}' \u2014 no vendor id was ever recorded for this subject`);return o==="cancel"?{method:"POST",path:`${i}/${r}/cancel`}:o==="delete"?{method:"DELETE",path:`${i}/${r}`}:{method:"POST",path:i}}async function mt(e,t,n={}){un(t.operation??`${t.subject.type}.update`);let{method:o,path:i}=ht(t,n.externalId),c=((t.operation??"").includes(".")?t.operation.slice(t.operation.indexOf(".")+1):"")==="create"?dn(t):void 0,s=await e(o,i,c);ye(s,`push ${t.subject.type}`);let a=s.id;return{externalId:typeof a=="string"&&a?a:t.subject.id}}function dn(e){let t=e.fields??{};return e.subject.type==="batch"?{input_file_id:t.input_file_id,endpoint:t.endpoint,completion_window:t.completion_window,...t.metadata?{metadata:t.metadata}:{}}:{}}function be(e){return async(t,n,o)=>{let i=await e({method:t,path:n,headers:{accept:"application/json",authorization:"Bearer twin",...t==="POST"?{"content-type":"application/json"}:{}},...o===void 0?{}:{body:JSON.stringify(o)}});if(i.body==="")return{};try{return JSON.parse(i.body)}catch{return{error:{type:"server_error",message:i.body.slice(0,200)}}}}}async function xe(e,t={}){return ut(be(e),{...t.root!==void 0?{root:t.root}:{},occurredAt:t.occurredAt??new Date().toISOString()})}async function Te(e,t,n){let o=t.operation??`${t.subject.type}.update`,i=dt(o);if(i)return{externalId:t.subject.id,data:{performed:!1,reason:i}};let r=n.resolve(t.subject.type,t.subject.id),c=o.includes(".")?o.slice(o.indexOf(".")+1):o;if(c!=="create"&&pt.test(r))throw new Error(`moonshot push: refusing to address the real account by the twin's own id '${r}' \u2014 no vendor id was ever recorded for this subject`);let{externalId:s}=await mt(be(e),{operation:o,subject:t.subject,fields:t.fields??{}},...c!=="create"?[{externalId:r}]:[]);return{externalId:s}}import{registerPack as fn}from"../../engine/v2/volter_world-core.mjs";var pn={vendor:"moonshot",protocol:"2",refresh:{every:"5m",onDemand:{atMost:"30s"}},stateSystem:{perform:Te,refresh:xe},roundTrip:{method:"POST",path:"/v1/files",body:{purpose:"batch",filename:"round-trip.jsonl",content:"x"},headers:{authorization:"Bearer sk-round-trip"}},rateBudget:oe,transport:"rest",archetype:"generative",bin:"world-moonshot",resourcesUnreachable:{model:"the vendor catalog",balance:"the account ledger the vendor keeps; read-only"},resources:["file","batch","balance","model"],specSource:"Moonshot Platform API \u2014 enumerated from Moonshot's own OpenAPI 3.1.0 document (https://platform.kimi.ai/docs/openapi.json, read 2026-09-16; 19 operations) + platform.kimi.ai/docs/{overview,api-reference,errors,models,pricing/limits,guides/context-caching} (read 2026-09-16). Envelope-faithful across the OpenAI-compatible /v1 and Anthropic-compatible /anthropic/v1 surfaces; model output is a labeled deterministic stub.",description:"Moonshot (Kimi) API twin \u2014 faithful protocol envelope across three inference protocols (OpenAI chat completions, Responses, Anthropic-compatible Messages) with streaming grammars, tool calls and cache-split usage; models catalog; stateful files/batches/balance; deterministic token counting, signature verify and web-search tool stubs; Moonshot's own documented rejections.",browserRouting:{apiPathPrefix:"/v1/",loaderHost:"https://api.moonshot.ai"},adoption:{pypi:[],sdks:[],envStems:["MOONSHOT"]},hosts:[{host:"api.moonshot.ai"}],endpointEnvNone:"Moonshot ships no SDK of its own; its documented clients (the standard openai/anthropic SDKs) take their base URL as a constructor option and read no MOONSHOT_BASE_URL env, so an app-read var would cover only env-configured callers while disabling the api.moonshot.ai interception that covers all traffic."};fn(pn);export{Ze 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-notion
2
+
3
+ Contains @volter/twin-notion 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.