reflex-agent 0.2.4 → 0.3.1

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 (206) hide show
  1. package/.next/BUILD_ID +1 -1
  2. package/.next/app-build-manifest.json +111 -98
  3. package/.next/app-path-routes-manifest.json +9 -9
  4. package/.next/build-manifest.json +5 -5
  5. package/.next/prerender-manifest.json +4 -54
  6. package/.next/react-loadable-manifest.json +1 -1
  7. package/.next/server/app/_not-found/page.js +1 -1
  8. package/.next/server/app/_not-found/page.js.nft.json +1 -1
  9. package/.next/server/app/_not-found/page_client-reference-manifest.js +1 -1
  10. package/.next/server/app/agents/[agentId]/page.js +3 -3
  11. package/.next/server/app/agents/[agentId]/page.js.nft.json +1 -1
  12. package/.next/server/app/agents/[agentId]/page_client-reference-manifest.js +1 -1
  13. package/.next/server/app/api/agents/[agentId]/respond/route.js +2 -2
  14. package/.next/server/app/api/agents/[agentId]/respond/route.js.nft.json +1 -1
  15. package/.next/server/app/api/agents/[agentId]/respond/route_client-reference-manifest.js +1 -1
  16. package/.next/server/app/api/images/[rootId]/[file]/route_client-reference-manifest.js +1 -1
  17. package/.next/server/app/api/oauth/callback/route.js +3 -3
  18. package/.next/server/app/api/oauth/callback/route_client-reference-manifest.js +1 -1
  19. package/.next/server/app/api/oauth/start/route_client-reference-manifest.js +1 -1
  20. package/.next/server/app/api/roots/[id]/attachments/route.js +0 -0
  21. package/.next/server/app/api/roots/[id]/attachments/route_client-reference-manifest.js +1 -1
  22. package/.next/server/app/api/roots/[id]/chat/[topicId]/send/route.js +2 -2
  23. package/.next/server/app/api/roots/[id]/chat/[topicId]/send/route.js.nft.json +1 -1
  24. package/.next/server/app/api/roots/[id]/chat/[topicId]/send/route_client-reference-manifest.js +1 -1
  25. package/.next/server/app/api/roots/[id]/chat/[topicId]/stop/route.js +2 -2
  26. package/.next/server/app/api/roots/[id]/chat/[topicId]/stop/route.js.nft.json +1 -1
  27. package/.next/server/app/api/roots/[id]/chat/[topicId]/stop/route_client-reference-manifest.js +1 -1
  28. package/.next/server/app/api/roots/[id]/chat/[topicId]/stream/route.js +2 -2
  29. package/.next/server/app/api/roots/[id]/chat/[topicId]/stream/route.js.nft.json +1 -1
  30. package/.next/server/app/api/roots/[id]/chat/[topicId]/stream/route_client-reference-manifest.js +1 -1
  31. package/.next/server/app/api/roots/[id]/dashboard/route.js +1 -1
  32. package/.next/server/app/api/roots/[id]/dashboard/route.js.nft.json +1 -1
  33. package/.next/server/app/api/roots/[id]/dashboard/route_client-reference-manifest.js +1 -1
  34. package/.next/server/app/api/roots/[id]/suggestions/route.js +1 -1
  35. package/.next/server/app/api/roots/[id]/suggestions/route.js.nft.json +1 -1
  36. package/.next/server/app/api/roots/[id]/suggestions/route_client-reference-manifest.js +1 -1
  37. package/.next/server/app/api/utilities/[scope]/[id]/bundle.js/route_client-reference-manifest.js +1 -1
  38. package/.next/server/app/api/utilities/[scope]/[id]/host/route.js +2 -2
  39. package/.next/server/app/api/utilities/[scope]/[id]/host/route.js.nft.json +1 -1
  40. package/.next/server/app/api/utilities/[scope]/[id]/host/route_client-reference-manifest.js +1 -1
  41. package/.next/server/app/api/utilities/[scope]/[id]/host-api.mjs/route_client-reference-manifest.js +1 -1
  42. package/.next/server/app/api/utilities/[scope]/[id]/host-ui.mjs/route_client-reference-manifest.js +1 -1
  43. package/.next/server/app/api/utilities/[scope]/[id]/iframe/route_client-reference-manifest.js +1 -1
  44. package/.next/server/app/api/utilities/[scope]/[id]/style.css/route_client-reference-manifest.js +1 -1
  45. package/.next/server/app/audit/page.js +2 -2
  46. package/.next/server/app/audit/page.js.nft.json +1 -1
  47. package/.next/server/app/audit/page_client-reference-manifest.js +1 -1
  48. package/.next/server/app/onboarding/page.js +4 -4
  49. package/.next/server/app/onboarding/page.js.nft.json +1 -1
  50. package/.next/server/app/onboarding/page_client-reference-manifest.js +1 -1
  51. package/.next/server/app/page.js +2 -2
  52. package/.next/server/app/page.js.nft.json +1 -1
  53. package/.next/server/app/page_client-reference-manifest.js +1 -1
  54. package/.next/server/app/roots/[id]/chat/[topicId]/page.js +2 -6
  55. package/.next/server/app/roots/[id]/chat/[topicId]/page.js.nft.json +1 -1
  56. package/.next/server/app/roots/[id]/chat/[topicId]/page_client-reference-manifest.js +1 -1
  57. package/.next/server/app/roots/[id]/kb/[...slug]/page.js +2 -6
  58. package/.next/server/app/roots/[id]/kb/[...slug]/page.js.nft.json +1 -1
  59. package/.next/server/app/roots/[id]/kb/[...slug]/page_client-reference-manifest.js +1 -1
  60. package/.next/server/app/roots/[id]/page.js +3 -3
  61. package/.next/server/app/roots/[id]/page.js.nft.json +1 -1
  62. package/.next/server/app/roots/[id]/page_client-reference-manifest.js +1 -1
  63. package/.next/server/app/roots/[id]/workflows/[wfId]/page.js +2 -2
  64. package/.next/server/app/roots/[id]/workflows/[wfId]/page.js.nft.json +1 -1
  65. package/.next/server/app/roots/[id]/workflows/[wfId]/page_client-reference-manifest.js +1 -1
  66. package/.next/server/app/roots/[id]/workflows/page.js +2 -2
  67. package/.next/server/app/roots/[id]/workflows/page.js.nft.json +1 -1
  68. package/.next/server/app/roots/[id]/workflows/page_client-reference-manifest.js +1 -1
  69. package/.next/server/app/roots/new/page.js +4 -2
  70. package/.next/server/app/roots/new/page.js.nft.json +1 -1
  71. package/.next/server/app/roots/new/page_client-reference-manifest.js +1 -1
  72. package/.next/server/app/settings/page.js +6 -6
  73. package/.next/server/app/settings/page.js.nft.json +1 -1
  74. package/.next/server/app/settings/page_client-reference-manifest.js +1 -1
  75. package/.next/server/app/share/[id]/file/page.js +2 -2
  76. package/.next/server/app/share/[id]/file/page.js.nft.json +1 -1
  77. package/.next/server/app/share/[id]/file/page_client-reference-manifest.js +1 -1
  78. package/.next/server/app/share/[id]/page.js +2 -2
  79. package/.next/server/app/share/[id]/page.js.nft.json +1 -1
  80. package/.next/server/app/share/[id]/page_client-reference-manifest.js +1 -1
  81. package/.next/server/app/utilities/[scope]/[id]/page.js +2 -2
  82. package/.next/server/app/utilities/[scope]/[id]/page.js.nft.json +1 -1
  83. package/.next/server/app/utilities/[scope]/[id]/page_client-reference-manifest.js +1 -1
  84. package/.next/server/app/utilities/page.js +2 -17
  85. package/.next/server/app/utilities/page.js.nft.json +1 -1
  86. package/.next/server/app/utilities/page_client-reference-manifest.js +1 -1
  87. package/.next/server/app-paths-manifest.json +9 -9
  88. package/.next/server/chunks/1223.js +1 -1
  89. package/.next/server/chunks/133.js +1 -490
  90. package/.next/server/chunks/1888.js +1 -1
  91. package/.next/server/chunks/{9739.js → 1988.js} +13 -9
  92. package/.next/server/chunks/2433.js +1 -1
  93. package/.next/server/chunks/2503.js +1 -1
  94. package/.next/server/chunks/285.js +471 -0
  95. package/.next/server/chunks/2959.js +1 -0
  96. package/.next/server/chunks/2995.js +1 -0
  97. package/.next/server/chunks/3240.js +1 -1
  98. package/.next/server/chunks/3332.js +1 -1
  99. package/.next/server/chunks/3657.js +1 -1
  100. package/.next/server/chunks/4066.js +1 -1
  101. package/.next/server/chunks/4438.js +1 -0
  102. package/.next/server/chunks/4514.js +3 -0
  103. package/.next/server/chunks/4553.js +1 -1
  104. package/.next/server/chunks/4812.js +179 -0
  105. package/.next/server/chunks/4925.js +1 -1
  106. package/.next/server/chunks/{3953.js → 5068.js} +2 -2
  107. package/.next/server/chunks/5319.js +1 -1
  108. package/.next/server/chunks/569.js +1 -1
  109. package/.next/server/chunks/6730.js +1 -1
  110. package/.next/server/chunks/6909.js +142 -161
  111. package/.next/server/chunks/8262.js +1 -1
  112. package/.next/server/chunks/9098.js +1 -1
  113. package/.next/server/chunks/94.js +1 -1
  114. package/.next/server/chunks/9427.js +1 -0
  115. package/.next/server/chunks/9538.js +1 -0
  116. package/.next/server/chunks/963.js +1 -0
  117. package/.next/server/chunks/9835.js +1 -1
  118. package/.next/server/middleware-build-manifest.js +1 -1
  119. package/.next/server/middleware-manifest.json +5 -5
  120. package/.next/server/middleware-react-loadable-manifest.js +1 -1
  121. package/.next/server/pages/500.html +1 -1
  122. package/.next/server/pages-manifest.json +1 -2
  123. package/.next/server/server-reference-manifest.js +1 -1
  124. package/.next/server/server-reference-manifest.json +1 -1
  125. package/.next/static/chunks/2865-134f546f21ca4330.js +1 -0
  126. package/.next/static/chunks/4108.5abdb7812a13eafd.js +1 -0
  127. package/.next/static/chunks/5254-4196f25e56270de5.js +1 -0
  128. package/.next/static/chunks/5521-cbc665104c7e59d3.js +1 -0
  129. package/.next/static/chunks/6445-99824866a51b582a.js +1 -0
  130. package/.next/static/chunks/8855-9b941d2b78f398ce.js +1 -0
  131. package/.next/static/chunks/8871-2948840b33c0863d.js +1 -0
  132. package/.next/static/chunks/9411-af5f758c57741929.js +3 -0
  133. package/.next/static/chunks/app/agents/[agentId]/page-5d6f4cb16b42d02b.js +1 -0
  134. package/.next/static/chunks/app/layout-d4cf24375db6d793.js +1 -0
  135. package/.next/static/chunks/app/onboarding/page-7303664b62ccc24a.js +1 -0
  136. package/.next/static/chunks/app/page-97d312db91d569f7.js +1 -0
  137. package/.next/static/chunks/app/roots/[id]/chat/[topicId]/page-123f60a544619a3c.js +1 -0
  138. package/.next/static/chunks/app/roots/[id]/kb/[...slug]/page-e253597edb1b2440.js +1 -0
  139. package/.next/static/chunks/app/roots/[id]/page-91a8de6a1c79f8a3.js +1 -0
  140. package/.next/static/chunks/app/roots/[id]/workflows/[wfId]/page-4300a52e163883df.js +1 -0
  141. package/.next/static/chunks/app/roots/new/page-6b104aad46a38173.js +1 -0
  142. package/.next/static/chunks/app/settings/page-afe1b80f7f45c5eb.js +1 -0
  143. package/.next/static/chunks/app/share/[id]/page-a5fb565bd892d4df.js +1 -0
  144. package/.next/static/chunks/app/utilities/[scope]/[id]/page-eb713a2b5209942c.js +1 -0
  145. package/.next/static/chunks/app/utilities/page-b7f30c151c42a27c.js +1 -0
  146. package/.next/static/chunks/{webpack-5fca180586957874.js → webpack-bddc3babcbc30dd7.js} +1 -1
  147. package/.next/static/css/60e9b6cdf1283e83.css +1 -0
  148. package/.next/trace +47 -46
  149. package/dist/lib/reflex/agents/prompts.js +46 -46
  150. package/dist/lib/reflex/agents/prompts.js.map +1 -1
  151. package/dist/lib/reflex/prompts/defaults.js +102 -102
  152. package/next.config.ts +4 -1
  153. package/package.json +2 -2
  154. package/.next/server/app/_not-found.html +0 -1
  155. package/.next/server/app/_not-found.meta +0 -8
  156. package/.next/server/app/_not-found.rsc +0 -18
  157. package/.next/server/app/index.html +0 -1
  158. package/.next/server/app/index.meta +0 -9
  159. package/.next/server/app/index.rsc +0 -19
  160. package/.next/server/chunks/1410.js +0 -1
  161. package/.next/server/chunks/1986.js +0 -1
  162. package/.next/server/chunks/2448.js +0 -3
  163. package/.next/server/chunks/5754.js +0 -3
  164. package/.next/server/chunks/7097.js +0 -1
  165. package/.next/server/chunks/7782.js +0 -1
  166. package/.next/server/chunks/7987.js +0 -1
  167. package/.next/server/chunks/810.js +0 -1
  168. package/.next/server/chunks/8843.js +0 -1
  169. package/.next/server/chunks/9328.js +0 -179
  170. package/.next/server/pages/404.html +0 -1
  171. package/.next/static/chunks/2488-c9590facb4b9f184.js +0 -1
  172. package/.next/static/chunks/2684-257d38989ef53935.js +0 -1
  173. package/.next/static/chunks/4108.fb9f99a9c899ef54.js +0 -1
  174. package/.next/static/chunks/6231-d83c1544bbea8424.js +0 -1
  175. package/.next/static/chunks/9045-731ff0865352dd95.js +0 -1
  176. package/.next/static/chunks/9496-75ccd3fadb294fba.js +0 -1
  177. package/.next/static/chunks/992-4e7b7f722c629e21.js +0 -1
  178. package/.next/static/chunks/app/agents/[agentId]/page-0b5c2838354d0eba.js +0 -1
  179. package/.next/static/chunks/app/layout-9a59ed07c18cb786.js +0 -1
  180. package/.next/static/chunks/app/onboarding/page-79f07a813ea2abfe.js +0 -1
  181. package/.next/static/chunks/app/page-27f4b98b02ac4f79.js +0 -1
  182. package/.next/static/chunks/app/roots/[id]/chat/[topicId]/page-8db2d0b75cd333c8.js +0 -1
  183. package/.next/static/chunks/app/roots/[id]/kb/[...slug]/page-873b131eec3a2f30.js +0 -1
  184. package/.next/static/chunks/app/roots/[id]/page-270d0d49eb668784.js +0 -1
  185. package/.next/static/chunks/app/roots/[id]/workflows/[wfId]/page-7c1f10dbe0bcb9ad.js +0 -1
  186. package/.next/static/chunks/app/roots/new/page-ac1a9f6379710ca2.js +0 -1
  187. package/.next/static/chunks/app/settings/page-81cb1393e817dfc3.js +0 -1
  188. package/.next/static/chunks/app/share/[id]/page-2d123f0a99e1606f.js +0 -1
  189. package/.next/static/chunks/app/utilities/[scope]/[id]/page-0bbb8d17af80c1da.js +0 -1
  190. package/.next/static/chunks/app/utilities/page-e6ce673b9357bf1f.js +0 -1
  191. package/.next/static/css/87e01f779d555d04.css +0 -1
  192. package/packages/utilities/learn-anything/README.md +0 -41
  193. package/packages/utilities/learn-anything/actions/_json.ts +0 -191
  194. package/packages/utilities/learn-anything/actions/_store.ts +0 -248
  195. package/packages/utilities/learn-anything/actions/buildModule.ts +0 -487
  196. package/packages/utilities/learn-anything/actions/explainSelection.ts +0 -64
  197. package/packages/utilities/learn-anything/actions/generateOutline.ts +0 -170
  198. package/packages/utilities/learn-anything/actions/generateQuiz.ts +0 -72
  199. package/packages/utilities/learn-anything/actions/generateTrainer.ts +0 -106
  200. package/packages/utilities/learn-anything/actions/refreshCourseCard.ts +0 -76
  201. package/packages/utilities/learn-anything/actions/tutorAsk.ts +0 -93
  202. package/packages/utilities/learn-anything/article-view.tsx +0 -464
  203. package/packages/utilities/learn-anything/manifest.json +0 -42
  204. package/packages/utilities/learn-anything/ui.tsx +0 -1589
  205. /package/.next/static/{og_wC7UPkGtJDiapaTgBr → IGuuMcet1qtGZQCP2MEn4}/_buildManifest.js +0 -0
  206. /package/.next/static/{og_wC7UPkGtJDiapaTgBr → IGuuMcet1qtGZQCP2MEn4}/_ssgManifest.js +0 -0
@@ -1 +1 @@
1
- "use strict";exports.id=5319,exports.ids=[5319,6435],exports.modules={16435:(a,b,c)=>{c.d(b,{U:()=>w});var d=c(29021),e=c(21820),f=c(33873),g=c(79646),h=c(4984),i=c(8086);async function j(a){var b;if(void 0===a)return{cleanup:async()=>{}};if(!("object"==typeof(b=a)&&null!==b&&!Array.isArray(b)))throw Error("outputSchema must be a plain JSON object");let c=await d.promises.mkdtemp(f.join(e.tmpdir(),"codex-output-schema-")),g=f.join(c,"schema.json"),h=async()=>{try{await d.promises.rm(c,{recursive:!0,force:!0})}catch{}};try{return await d.promises.writeFile(g,JSON.stringify(a),"utf8"),{schemaPath:g,cleanup:h}}catch(a){throw await h(),a}}var k=class{_exec;_options;_id;_threadOptions;get id(){return this._id}constructor(a,b,c,d=null){this._exec=a,this._options=b,this._id=d,this._threadOptions=c}async runStreamed(a,b={}){return{events:this.runStreamedInternal(a,b)}}async *runStreamedInternal(a,b={}){let{schemaPath:c,cleanup:d}=await j(b.outputSchema),e=this._threadOptions,{prompt:f,images:g}=function(a){if("string"==typeof a)return{prompt:a,images:[]};let b=[],c=[];for(let d of a)"text"===d.type?b.push(d.text):"local_image"===d.type&&c.push(d.path);return{prompt:b.join("\n\n"),images:c}}(a),h=this._exec.run({input:f,baseUrl:this._options.baseUrl,apiKey:this._options.apiKey,threadId:this._id,images:g,model:e?.model,sandboxMode:e?.sandboxMode,workingDirectory:e?.workingDirectory,skipGitRepoCheck:e?.skipGitRepoCheck,outputSchemaFile:c,modelReasoningEffort:e?.modelReasoningEffort,signal:b.signal,networkAccessEnabled:e?.networkAccessEnabled,webSearchMode:e?.webSearchMode,webSearchEnabled:e?.webSearchEnabled,approvalPolicy:e?.approvalPolicy,additionalDirectories:e?.additionalDirectories});try{for await(let a of h){let b;try{b=JSON.parse(a)}catch(b){throw Error(`Failed to parse item: ${a}`,{cause:b})}"thread.started"===b.type&&(this._id=b.thread_id),yield b}}finally{await d()}}async run(a,b={}){let c=this.runStreamedInternal(a,b),d=[],e="",f=null,g=null;for await(let a of c)if("item.completed"===a.type)"agent_message"===a.item.type&&(e=a.item.text),d.push(a.item);else if("turn.completed"===a.type)f=a.usage;else if("turn.failed"===a.type){g=a.error;break}if(g)throw Error(g.message);return{items:d,finalResponse:e,usage:f}}},l="CODEX_INTERNAL_ORIGINATOR_OVERRIDE",m="@openai/codex",n={"x86_64-unknown-linux-musl":"@openai/codex-linux-x64","aarch64-unknown-linux-musl":"@openai/codex-linux-arm64","x86_64-apple-darwin":"@openai/codex-darwin-x64","aarch64-apple-darwin":"@openai/codex-darwin-arm64","x86_64-pc-windows-msvc":"@openai/codex-win32-x64","aarch64-pc-windows-msvc":"@openai/codex-win32-arm64"},o=(0,i.createRequire)("file:///home/runner/work/reflex-agent/reflex-agent/node_modules/.pnpm/@openai+codex-sdk@0.133.0/node_modules/@openai/codex-sdk/dist/index.js"),p=class{executablePath;pathDirs;envOverride;configOverrides;constructor(a=null,b,c){if(a)this.executablePath=a,this.pathDirs=[];else{let a=function(){let a,{platform:b,arch:c}=process,d=null;switch(b){case"linux":case"android":switch(c){case"x64":d="x86_64-unknown-linux-musl";break;case"arm64":d="aarch64-unknown-linux-musl"}break;case"darwin":switch(c){case"x64":d="x86_64-apple-darwin";break;case"arm64":d="aarch64-apple-darwin"}break;case"win32":switch(c){case"x64":d="x86_64-pc-windows-msvc";break;case"arm64":d="aarch64-pc-windows-msvc"}}if(!d)throw Error(`Unsupported platform: ${b} (${c})`);let e=n[d];if(!e)throw Error(`Unsupported target triple: ${d}`);try{let b=o.resolve(`${m}/package.json`),c=(0,i.createRequire)(b).resolve(`${e}/package.json`);a=f.join(f.dirname(c),"vendor")}catch{throw Error(`Unable to locate Codex CLI binaries. Ensure ${m} is installed with optional dependencies.`)}let g=function(a,b,c){let d=f.join(a,b),e=f.join(d,"bin",c);if(u(e)&&u(f.join(d,"codex-package.json")))return{executablePath:e,pathDirs:t(f.join(d,"codex-path"))};let g=f.join(d,"codex",c);return u(g)?{executablePath:g,pathDirs:t(f.join(d,"path"))}:null}(a,d,"win32"===process.platform?"codex.exe":"codex");if(!g)throw Error(`Unable to locate Codex CLI binaries for ${d}. Ensure ${m} is installed with optional dependencies.`);return g}();this.executablePath=a.executablePath,this.pathDirs=a.pathDirs}this.envOverride=b,this.configOverrides=c}async *run(a){let b=["exec","--experimental-json"];if(this.configOverrides)for(let a of function(a){let b=[];return function a(b,c,d){if(!s(b))if(c)return void d.push(`${c}=${q(b,c)}`);else throw Error("Codex config overrides must be a plain object");let e=Object.entries(b);if(c||0!==e.length){if(c&&0===e.length)return void d.push(`${c}={}`);for(let[b,f]of e){if(!b)throw Error("Codex config override keys must be non-empty strings");if(void 0===f)continue;let e=c?`${c}.${b}`:b;s(f)?a(f,e,d):d.push(`${e}=${q(f,e)}`)}}}(a,"",b),b}(this.configOverrides))b.push("--config",a);if(a.baseUrl&&b.push("--config",`openai_base_url=${q(a.baseUrl,"openai_base_url")}`),a.model&&b.push("--model",a.model),a.sandboxMode&&b.push("--sandbox",a.sandboxMode),a.workingDirectory&&b.push("--cd",a.workingDirectory),a.additionalDirectories?.length)for(let c of a.additionalDirectories)b.push("--add-dir",c);if(a.skipGitRepoCheck&&b.push("--skip-git-repo-check"),a.outputSchemaFile&&b.push("--output-schema",a.outputSchemaFile),a.modelReasoningEffort&&b.push("--config",`model_reasoning_effort="${a.modelReasoningEffort}"`),void 0!==a.networkAccessEnabled&&b.push("--config",`sandbox_workspace_write.network_access=${a.networkAccessEnabled}`),a.webSearchMode?b.push("--config",`web_search="${a.webSearchMode}"`):!0===a.webSearchEnabled?b.push("--config",'web_search="live"'):!1===a.webSearchEnabled&&b.push("--config",'web_search="disabled"'),a.approvalPolicy&&b.push("--config",`approval_policy="${a.approvalPolicy}"`),a.threadId&&b.push("resume",a.threadId),a.images?.length)for(let c of a.images)b.push("--image",c);let c={};if(this.envOverride)Object.assign(c,this.envOverride);else for(let[a,b]of Object.entries(process.env))void 0!==b&&(c[a]=b);c[l]||(c[l]="codex_sdk_ts"),a.apiKey&&(c.CODEX_API_KEY=a.apiKey),this.pathDirs.length>0&&function(a,b,c=process.platform){let d=function(a,b){if("win32"!==b)return"PATH";let c=Object.keys(a).filter(a=>"path"===a.toLowerCase());return c.includes("Path")?"Path":c.at(-1)??"PATH"}(a,c);if("win32"===c)for(let b of Object.keys(a))"path"===b.toLowerCase()&&b!==d&&delete a[b];let e=(a[d]??"").split(f.delimiter).filter(a=>a.length>0&&!b.includes(a));a[d]=[...b,...e].join(f.delimiter)}(c,this.pathDirs);let d=(0,g.spawn)(this.executablePath,b,{env:c,signal:a.signal}),e=null;if(d.once("error",a=>e=a),!d.stdin)throw d.kill(),Error("Child process has no stdin");if(d.stdin.write(a.input),d.stdin.end(),!d.stdout)throw d.kill(),Error("Child process has no stdout");let i=[];d.stderr&&d.stderr.on("data",a=>{i.push(a)});let j=new Promise(a=>{d.once("exit",(b,c)=>{a({code:b,signal:c})})}),k=h.createInterface({input:d.stdout,crlfDelay:1/0});try{for await(let a of k)yield a;if(e)throw e;let{code:a,signal:b}=await j;if(0!==a||b){let c=Buffer.concat(i),d=b?`signal ${b}`:`code ${a??1}`;throw Error(`Codex Exec exited with ${d}: ${c.toString("utf8")}`)}}finally{k.close(),d.removeAllListeners();try{d.killed||d.kill()}catch{}}}};function q(a,b){if("string"==typeof a)return JSON.stringify(a);if("number"==typeof a){if(!Number.isFinite(a))throw Error(`Codex config override at ${b} must be a finite number`);return`${a}`}if("boolean"==typeof a)return a?"true":"false";if(Array.isArray(a)){let c=a.map((a,c)=>q(a,`${b}[${c}]`));return`[${c.join(", ")}]`}if(s(a)){let d=[];for(let[e,f]of Object.entries(a)){var c;if(!e)throw Error("Codex config override keys must be non-empty strings");void 0!==f&&d.push(`${r.test(c=e)?c:JSON.stringify(c)} = ${q(f,`${b}.${e}`)}`)}return`{${d.join(", ")}}`}else if(null===a)throw Error(`Codex config override at ${b} cannot be null`);else{let c=typeof a;throw Error(`Unsupported Codex config override value at ${b}: ${c}`)}}var r=/^[A-Za-z0-9_-]+$/;function s(a){return"object"==typeof a&&null!==a&&!Array.isArray(a)}function t(...a){return a.filter(v)}function u(a){try{return(0,d.statSync)(a).isFile()}catch{return!1}}function v(a){try{return(0,d.statSync)(a).isDirectory()}catch{return!1}}var w=class{exec;options;constructor(a={}){let{codexPathOverride:b,env:c,config:d}=a;this.exec=new p(b,c,d),this.options=a}startThread(a={}){return new k(this.exec,this.options,a)}resumeThread(a,b={}){return new k(this.exec,this.options,b,a)}}},73117:(a,b,c)=>{c.a(a,async(a,d)=>{try{c.d(b,{pickBestImage:()=>m});var e=c(73024),f=c(76760),g=c.n(f),h=c(77598),i=c.n(h),j=c(64163),k=c(24576),l=a([j]);async function m(a){if(0===a.candidates.length)return{pickIndex:-1,reason:"no candidates",via:"fallback"};if(1===a.candidates.length)return{pickIndex:0,reason:"only one candidate",via:"fallback"};try{return await n(a)}catch(d){let b=d instanceof Error?d.message:String(d),c=o(a);return{...c,reason:`agent judge failed (${b}); ${c.reason}`}}}async function n(a){let b=await (0,k.Zn)(a.rootId);if(!b)throw Error(`unknown rootId: ${a.rootId}`);let c=g().join(b.path,".reflex",".tmp",`judge-${i().randomBytes(6).toString("hex")}`);await e.promises.mkdir(c,{recursive:!0});let d=(await Promise.all(a.candidates.map(async(a,b)=>{try{let d=await fetch(a.thumb,{signal:AbortSignal.timeout(1e4)});if(!d.ok)return null;let f=d.headers.get("content-type")?.split(";")[0]?.trim()||"image/jpeg";if(!f.startsWith("image/"))return null;let h=await d.arrayBuffer();if(h.byteLength>5242880)return null;let i=function(a){switch(a.toLowerCase()){case"image/png":return"png";case"image/jpeg":case"image/jpg":return"jpg";case"image/webp":return"webp";case"image/gif":return"gif";case"image/avif":return"avif";case"image/svg+xml":return"svg";default:return"img"}}(f),j=g().join(c,`cand-${b}.${i}`);return await e.promises.writeFile(j,Buffer.from(h)),{index:b,path:j,mime:f,size:h.byteLength}}catch{return null}}))).filter(a=>null!==a);if(0===d.length)return await p(c),o(a);let f=[`Курс/тема: ${a.context}`,`Поисковый запрос: "${a.query}"`,`Что должно быть на картинке: ${a.alt}`,"",`На диске лежат ${d.length} кандидатов поисковой выдачи. ОТКРОЙ КАЖДОГО через Read tool — он вернёт картинку как vision-контент, ты её увидишь:`,""];for(let b=0;b<d.length;b++){let c=a.candidates[d[b].index],e="(unknown)";try{e=new URL(c.url).hostname}catch{}f.push(` [${b}] ${d[b].path} (источник: ${e}, автор: ${c.attribution.name})`)}f.push("","Прочитай каждую (Read tool, по одной), посмотри что РЕАЛЬНО на картинке, выбери одну ЛУЧШЕ ВСЕГО подходящую как учебная иллюстрация.","","Критерии (в порядке важности):"," 1. На картинке РЕАЛЬНО изображено то, что просит запрос. Например, если запрос \xabгипсовый шар\xbb, а на картинке рука — отклоняй."," 2. Качество годится для учебника: не клипарт, не мем, не logo, не размытое."," 3. Контекст соответствует теме курса."," 4. Если ВСЕ кандидаты не подходят — верни pick: -1, тогда система сгенерирует AI-иллюстрацию вместо подобранной.","",`В САМОМ КОНЦЕ ответа выведи ОДНУ строку с JSON: {"pick": число от 0 до ${d.length-1} ИЛИ -1, "reason": "коротко по-русски"}`,"До этой строки можешь думать вслух / описывать что видишь — мне важна только последняя JSON-строка.");let h=d.map(a=>({name:g().basename(a.path),absPath:a.path,size:a.size,mime:a.mime})),l=-1,m="";try{let b=await (0,j.runHeadlessAgent)({rootId:a.rootId,prompt:f.join("\n"),label:`[images.pickBest] ${a.query}`,timeoutMs:3e5,attachments:h}),c=function(a,b){let c=a.trim().split(/\r?\n/);for(let a=c.length-1;a>=0;a--){let d=c[a].trim();if(d.startsWith("{"))try{let a=JSON.parse(d),c="number"==typeof a.pick&&Number.isInteger(a.pick)?a.pick:NaN;if(Number.isFinite(c)&&(-1===c||c>=0&&c<b))return{pickIndex:c,reason:"string"==typeof a.reason?a.reason:""}}catch{}}let d=/\{[^{}]*"pick"[^{}]*\}/.exec(a);if(d)try{let a=JSON.parse(d[0]),c="number"==typeof a.pick&&Number.isInteger(a.pick)?a.pick:NaN;if(Number.isFinite(c))return{pickIndex:-1===c||c>=0&&c<b?c:0,reason:"string"==typeof a.reason?a.reason:""}}catch{}return{pickIndex:0,reason:"could not parse pick from agent reply"}}(b.text,d.length);l=c.pickIndex,m=c.reason}finally{await p(c)}return -1===l?{pickIndex:-1,reason:m||"agent rejected all",via:"agent"}:l<0||l>=d.length?{pickIndex:d[0].index,reason:`agent returned invalid pick (${l}); falling back to first usable`,via:"agent"}:{pickIndex:d[l].index,reason:m,via:"agent"}}function o(a){let b=/(wikipedia|wikimedia|britannica|mdn|github|stanford|mit\.edu|nature\.com|nasa\.gov|noaa\.gov|smithsonian)/i;for(let c=0;c<a.candidates.length;c++){let d=a.candidates[c];try{let a=new URL(d.url).hostname;if(b.test(a))return{pickIndex:c,reason:`trusted domain ${a}`,via:"heuristic"}}catch{}}return{pickIndex:0,reason:"no trusted domain; first result",via:"heuristic"}}async function p(a){try{await e.promises.rm(a,{recursive:!0,force:!0})}catch{}}j=(l.then?(await l)():l)[0],d()}catch(a){d(a)}})}};
1
+ "use strict";exports.id=5319,exports.ids=[5319,6435],exports.modules={16435:(a,b,c)=>{c.d(b,{U:()=>w});var d=c(29021),e=c(21820),f=c(33873),g=c(79646),h=c(4984),i=c(8086);async function j(a){var b;if(void 0===a)return{cleanup:async()=>{}};if(!("object"==typeof(b=a)&&null!==b&&!Array.isArray(b)))throw Error("outputSchema must be a plain JSON object");let c=await d.promises.mkdtemp(f.join(e.tmpdir(),"codex-output-schema-")),g=f.join(c,"schema.json"),h=async()=>{try{await d.promises.rm(c,{recursive:!0,force:!0})}catch{}};try{return await d.promises.writeFile(g,JSON.stringify(a),"utf8"),{schemaPath:g,cleanup:h}}catch(a){throw await h(),a}}var k=class{_exec;_options;_id;_threadOptions;get id(){return this._id}constructor(a,b,c,d=null){this._exec=a,this._options=b,this._id=d,this._threadOptions=c}async runStreamed(a,b={}){return{events:this.runStreamedInternal(a,b)}}async *runStreamedInternal(a,b={}){let{schemaPath:c,cleanup:d}=await j(b.outputSchema),e=this._threadOptions,{prompt:f,images:g}=function(a){if("string"==typeof a)return{prompt:a,images:[]};let b=[],c=[];for(let d of a)"text"===d.type?b.push(d.text):"local_image"===d.type&&c.push(d.path);return{prompt:b.join("\n\n"),images:c}}(a),h=this._exec.run({input:f,baseUrl:this._options.baseUrl,apiKey:this._options.apiKey,threadId:this._id,images:g,model:e?.model,sandboxMode:e?.sandboxMode,workingDirectory:e?.workingDirectory,skipGitRepoCheck:e?.skipGitRepoCheck,outputSchemaFile:c,modelReasoningEffort:e?.modelReasoningEffort,signal:b.signal,networkAccessEnabled:e?.networkAccessEnabled,webSearchMode:e?.webSearchMode,webSearchEnabled:e?.webSearchEnabled,approvalPolicy:e?.approvalPolicy,additionalDirectories:e?.additionalDirectories});try{for await(let a of h){let b;try{b=JSON.parse(a)}catch(b){throw Error(`Failed to parse item: ${a}`,{cause:b})}"thread.started"===b.type&&(this._id=b.thread_id),yield b}}finally{await d()}}async run(a,b={}){let c=this.runStreamedInternal(a,b),d=[],e="",f=null,g=null;for await(let a of c)if("item.completed"===a.type)"agent_message"===a.item.type&&(e=a.item.text),d.push(a.item);else if("turn.completed"===a.type)f=a.usage;else if("turn.failed"===a.type){g=a.error;break}if(g)throw Error(g.message);return{items:d,finalResponse:e,usage:f}}},l="CODEX_INTERNAL_ORIGINATOR_OVERRIDE",m="@openai/codex",n={"x86_64-unknown-linux-musl":"@openai/codex-linux-x64","aarch64-unknown-linux-musl":"@openai/codex-linux-arm64","x86_64-apple-darwin":"@openai/codex-darwin-x64","aarch64-apple-darwin":"@openai/codex-darwin-arm64","x86_64-pc-windows-msvc":"@openai/codex-win32-x64","aarch64-pc-windows-msvc":"@openai/codex-win32-arm64"},o=(0,i.createRequire)("file:///home/runner/work/reflex-agent/reflex-agent/node_modules/.pnpm/@openai+codex-sdk@0.133.0/node_modules/@openai/codex-sdk/dist/index.js"),p=class{executablePath;pathDirs;envOverride;configOverrides;constructor(a=null,b,c){if(a)this.executablePath=a,this.pathDirs=[];else{let a=function(){let a,{platform:b,arch:c}=process,d=null;switch(b){case"linux":case"android":switch(c){case"x64":d="x86_64-unknown-linux-musl";break;case"arm64":d="aarch64-unknown-linux-musl"}break;case"darwin":switch(c){case"x64":d="x86_64-apple-darwin";break;case"arm64":d="aarch64-apple-darwin"}break;case"win32":switch(c){case"x64":d="x86_64-pc-windows-msvc";break;case"arm64":d="aarch64-pc-windows-msvc"}}if(!d)throw Error(`Unsupported platform: ${b} (${c})`);let e=n[d];if(!e)throw Error(`Unsupported target triple: ${d}`);try{let b=o.resolve(`${m}/package.json`),c=(0,i.createRequire)(b).resolve(`${e}/package.json`);a=f.join(f.dirname(c),"vendor")}catch{throw Error(`Unable to locate Codex CLI binaries. Ensure ${m} is installed with optional dependencies.`)}let g=function(a,b,c){let d=f.join(a,b),e=f.join(d,"bin",c);if(u(e)&&u(f.join(d,"codex-package.json")))return{executablePath:e,pathDirs:t(f.join(d,"codex-path"))};let g=f.join(d,"codex",c);return u(g)?{executablePath:g,pathDirs:t(f.join(d,"path"))}:null}(a,d,"win32"===process.platform?"codex.exe":"codex");if(!g)throw Error(`Unable to locate Codex CLI binaries for ${d}. Ensure ${m} is installed with optional dependencies.`);return g}();this.executablePath=a.executablePath,this.pathDirs=a.pathDirs}this.envOverride=b,this.configOverrides=c}async *run(a){let b=["exec","--experimental-json"];if(this.configOverrides)for(let a of function(a){let b=[];return function a(b,c,d){if(!s(b))if(c)return void d.push(`${c}=${q(b,c)}`);else throw Error("Codex config overrides must be a plain object");let e=Object.entries(b);if(c||0!==e.length){if(c&&0===e.length)return void d.push(`${c}={}`);for(let[b,f]of e){if(!b)throw Error("Codex config override keys must be non-empty strings");if(void 0===f)continue;let e=c?`${c}.${b}`:b;s(f)?a(f,e,d):d.push(`${e}=${q(f,e)}`)}}}(a,"",b),b}(this.configOverrides))b.push("--config",a);if(a.baseUrl&&b.push("--config",`openai_base_url=${q(a.baseUrl,"openai_base_url")}`),a.model&&b.push("--model",a.model),a.sandboxMode&&b.push("--sandbox",a.sandboxMode),a.workingDirectory&&b.push("--cd",a.workingDirectory),a.additionalDirectories?.length)for(let c of a.additionalDirectories)b.push("--add-dir",c);if(a.skipGitRepoCheck&&b.push("--skip-git-repo-check"),a.outputSchemaFile&&b.push("--output-schema",a.outputSchemaFile),a.modelReasoningEffort&&b.push("--config",`model_reasoning_effort="${a.modelReasoningEffort}"`),void 0!==a.networkAccessEnabled&&b.push("--config",`sandbox_workspace_write.network_access=${a.networkAccessEnabled}`),a.webSearchMode?b.push("--config",`web_search="${a.webSearchMode}"`):!0===a.webSearchEnabled?b.push("--config",'web_search="live"'):!1===a.webSearchEnabled&&b.push("--config",'web_search="disabled"'),a.approvalPolicy&&b.push("--config",`approval_policy="${a.approvalPolicy}"`),a.threadId&&b.push("resume",a.threadId),a.images?.length)for(let c of a.images)b.push("--image",c);let c={};if(this.envOverride)Object.assign(c,this.envOverride);else for(let[a,b]of Object.entries(process.env))void 0!==b&&(c[a]=b);c[l]||(c[l]="codex_sdk_ts"),a.apiKey&&(c.CODEX_API_KEY=a.apiKey),this.pathDirs.length>0&&function(a,b,c=process.platform){let d=function(a,b){if("win32"!==b)return"PATH";let c=Object.keys(a).filter(a=>"path"===a.toLowerCase());return c.includes("Path")?"Path":c.at(-1)??"PATH"}(a,c);if("win32"===c)for(let b of Object.keys(a))"path"===b.toLowerCase()&&b!==d&&delete a[b];let e=(a[d]??"").split(f.delimiter).filter(a=>a.length>0&&!b.includes(a));a[d]=[...b,...e].join(f.delimiter)}(c,this.pathDirs);let d=(0,g.spawn)(this.executablePath,b,{env:c,signal:a.signal}),e=null;if(d.once("error",a=>e=a),!d.stdin)throw d.kill(),Error("Child process has no stdin");if(d.stdin.write(a.input),d.stdin.end(),!d.stdout)throw d.kill(),Error("Child process has no stdout");let i=[];d.stderr&&d.stderr.on("data",a=>{i.push(a)});let j=new Promise(a=>{d.once("exit",(b,c)=>{a({code:b,signal:c})})}),k=h.createInterface({input:d.stdout,crlfDelay:1/0});try{for await(let a of k)yield a;if(e)throw e;let{code:a,signal:b}=await j;if(0!==a||b){let c=Buffer.concat(i),d=b?`signal ${b}`:`code ${a??1}`;throw Error(`Codex Exec exited with ${d}: ${c.toString("utf8")}`)}}finally{k.close(),d.removeAllListeners();try{d.killed||d.kill()}catch{}}}};function q(a,b){if("string"==typeof a)return JSON.stringify(a);if("number"==typeof a){if(!Number.isFinite(a))throw Error(`Codex config override at ${b} must be a finite number`);return`${a}`}if("boolean"==typeof a)return a?"true":"false";if(Array.isArray(a)){let c=a.map((a,c)=>q(a,`${b}[${c}]`));return`[${c.join(", ")}]`}if(s(a)){let d=[];for(let[e,f]of Object.entries(a)){var c;if(!e)throw Error("Codex config override keys must be non-empty strings");void 0!==f&&d.push(`${r.test(c=e)?c:JSON.stringify(c)} = ${q(f,`${b}.${e}`)}`)}return`{${d.join(", ")}}`}else if(null===a)throw Error(`Codex config override at ${b} cannot be null`);else{let c=typeof a;throw Error(`Unsupported Codex config override value at ${b}: ${c}`)}}var r=/^[A-Za-z0-9_-]+$/;function s(a){return"object"==typeof a&&null!==a&&!Array.isArray(a)}function t(...a){return a.filter(v)}function u(a){try{return(0,d.statSync)(a).isFile()}catch{return!1}}function v(a){try{return(0,d.statSync)(a).isDirectory()}catch{return!1}}var w=class{exec;options;constructor(a={}){let{codexPathOverride:b,env:c,config:d}=a;this.exec=new p(b,c,d),this.options=a}startThread(a={}){return new k(this.exec,this.options,a)}resumeThread(a,b={}){return new k(this.exec,this.options,b,a)}}},73117:(a,b,c)=>{c.a(a,async(a,d)=>{try{c.d(b,{pickBestImage:()=>m});var e=c(73024),f=c(76760),g=c.n(f),h=c(77598),i=c.n(h),j=c(64163),k=c(24576),l=a([j]);async function m(a){if(0===a.candidates.length)return{pickIndex:-1,reason:"no candidates",via:"fallback"};if(1===a.candidates.length)return{pickIndex:0,reason:"only one candidate",via:"fallback"};try{return await n(a)}catch(d){let b=d instanceof Error?d.message:String(d),c=o(a);return{...c,reason:`agent judge failed (${b}); ${c.reason}`}}}async function n(a){let b=await (0,k.Zn)(a.rootId);if(!b)throw Error(`unknown rootId: ${a.rootId}`);let c=g().join(b.path,".reflex",".tmp",`judge-${i().randomBytes(6).toString("hex")}`);await e.promises.mkdir(c,{recursive:!0});let d=(await Promise.all(a.candidates.map(async(a,b)=>{try{let d=await fetch(a.thumb,{signal:AbortSignal.timeout(1e4)});if(!d.ok)return null;let f=d.headers.get("content-type")?.split(";")[0]?.trim()||"image/jpeg";if(!f.startsWith("image/"))return null;let h=await d.arrayBuffer();if(h.byteLength>5242880)return null;let i=function(a){switch(a.toLowerCase()){case"image/png":return"png";case"image/jpeg":case"image/jpg":return"jpg";case"image/webp":return"webp";case"image/gif":return"gif";case"image/avif":return"avif";case"image/svg+xml":return"svg";default:return"img"}}(f),j=g().join(c,`cand-${b}.${i}`);return await e.promises.writeFile(j,Buffer.from(h)),{index:b,path:j,mime:f,size:h.byteLength}}catch{return null}}))).filter(a=>null!==a);if(0===d.length)return await p(c),o(a);let f=[`Course/topic: ${a.context}`,`Search query: "${a.query}"`,`What the image should depict: ${a.alt}`,"",`On disk you have ${d.length} search-result candidates. OPEN EACH ONE through the Read tool — it returns the image as vision content so you can see it:`,""];for(let b=0;b<d.length;b++){let c=a.candidates[d[b].index],e="(unknown)";try{e=new URL(c.url).hostname}catch{}f.push(` [${b}] ${d[b].path} (source: ${e}, author: ${c.attribution.name})`)}f.push("","Read each one (Read tool, one at a time), look at what is REALLY in the image, and pick the ONE that BEST works as an educational illustration.","","Criteria (in order of importance):",' 1. The image ACTUALLY depicts what the query asks for. For example, if the query is "plaster sphere" and the image shows a hand — reject it.'," 2. Quality is textbook-grade: not clipart, not a meme, not a logo, not blurry."," 3. The context matches the course topic."," 4. If ALL candidates are unsuitable — return pick: -1, and the system will generate an AI illustration instead.","",`At the VERY END of your response, output ONE line of JSON: {"pick": number from 0 to ${d.length-1} OR -1, "reason": "short rationale"}`,"Before that line you may think out loud / describe what you see — only the final JSON line matters.");let h=d.map(a=>({name:g().basename(a.path),absPath:a.path,size:a.size,mime:a.mime})),l=-1,m="";try{let b=await (0,j.runHeadlessAgent)({rootId:a.rootId,prompt:f.join("\n"),label:`[images.pickBest] ${a.query}`,timeoutMs:3e5,attachments:h}),c=function(a,b){let c=a.trim().split(/\r?\n/);for(let a=c.length-1;a>=0;a--){let d=c[a].trim();if(d.startsWith("{"))try{let a=JSON.parse(d),c="number"==typeof a.pick&&Number.isInteger(a.pick)?a.pick:NaN;if(Number.isFinite(c)&&(-1===c||c>=0&&c<b))return{pickIndex:c,reason:"string"==typeof a.reason?a.reason:""}}catch{}}let d=/\{[^{}]*"pick"[^{}]*\}/.exec(a);if(d)try{let a=JSON.parse(d[0]),c="number"==typeof a.pick&&Number.isInteger(a.pick)?a.pick:NaN;if(Number.isFinite(c))return{pickIndex:-1===c||c>=0&&c<b?c:0,reason:"string"==typeof a.reason?a.reason:""}}catch{}return{pickIndex:0,reason:"could not parse pick from agent reply"}}(b.text,d.length);l=c.pickIndex,m=c.reason}finally{await p(c)}return -1===l?{pickIndex:-1,reason:m||"agent rejected all",via:"agent"}:l<0||l>=d.length?{pickIndex:d[0].index,reason:`agent returned invalid pick (${l}); falling back to first usable`,via:"agent"}:{pickIndex:d[l].index,reason:m,via:"agent"}}function o(a){let b=/(wikipedia|wikimedia|britannica|mdn|github|stanford|mit\.edu|nature\.com|nasa\.gov|noaa\.gov|smithsonian)/i;for(let c=0;c<a.candidates.length;c++){let d=a.candidates[c];try{let a=new URL(d.url).hostname;if(b.test(a))return{pickIndex:c,reason:`trusted domain ${a}`,via:"heuristic"}}catch{}}return{pickIndex:0,reason:"no trusted domain; first result",via:"heuristic"}}async function p(a){try{await e.promises.rm(a,{recursive:!0,force:!0})}catch{}}j=(l.then?(await l)():l)[0],d()}catch(a){d(a)}})}};
@@ -1 +1 @@
1
- "use strict";exports.id=569,exports.ids=[569,4553],exports.modules={10569:(a,b,c)=>{c.a(a,async(a,d)=>{try{c.r(b),c.d(b,{isDue:()=>q,startWidgetScheduler:()=>m,stopWidgetScheduler:()=>n});var e=c(53905),f=c(93554),g=c(51021),h=c(69509),i=c(1405),j=c(94553),k=a([f,g]);[f,g]=k.then?(await k)():k;let s="__reflexWidgetScheduler";function l(){return globalThis[s]||(globalThis[s]={intervalId:null,ticking:!1,startedAt:new Date().toISOString()}),globalThis[s]}function m(){let a=l();a.intervalId||(setTimeout(()=>{o().catch(a=>{console.error("[widget-scheduler] initial tick failed:",a)})},3e4),a.intervalId=setInterval(()=>{o().catch(a=>{console.error("[widget-scheduler] tick failed:",a)})},3e5))}function n(){let a=l();a.intervalId&&(clearInterval(a.intervalId),a.intervalId=null)}async function o(){let a=l();if(!a.ticking){a.ticking=!0;try{for(let a of(await (0,e.qV)()))try{await p(a.id,a.path)}catch(b){console.error(`[widget-scheduler] root ${a.id} failed:`,b instanceof Error?b.message:b)}}finally{a.ticking=!1}}}async function p(a,b){for(let c of(await (0,h.listWidgets)(b)))q(c)&&c.sourceTopicId&&(f.z.isActive(c.sourceTopicId)||await r(a,b,c))}function q(a){if(!a.refresh||"manual"===a.refresh)return!1;let b=i.VQ[a.refresh];if(!b)return!1;let c=a.lastRefreshAt??a.updatedAt,d=Date.now()-Date.parse(c);return Number.isFinite(d)&&d>=b}async function r(a,b,c){let d={...c,lastRefreshAt:new Date().toISOString()};await (0,h.writeWidget)(b,d);let e=await (0,j.buildRefreshPromptForWidget)(b,d),f=await (0,g.W)({rootId:a,topicId:c.sourceTopicId,message:e,attachments:[]});"error"in f&&console.error(`[widget-scheduler] couldn't start refresh for ${c.id}: ${f.error}`)}d()}catch(a){d(a)}})},94553:(a,b,c)=>{c.d(b,{buildRefreshPromptForWidget:()=>e});var d=c(69509);async function e(a,b){let c=b.memoryFile?await (0,d.iq)(a,b.memoryFile):null,e=[];return e.push(`[Reflex auto-refresh] Виджет \xab${b.title}\xbb (id: \`${b.id}\`, kind: \`${b.kind}\`) пришло время обновить.`),e.push(""),e.push("Текущие данные виджета:"),e.push("```json"),e.push(JSON.stringify(b.data,null,2)),e.push("```"),e.push(""),b.memory&&b.memory.trim()&&(e.push("Текущая inline-memory:"),e.push("```"),e.push(b.memory),e.push("```"),e.push("")),b.memoryFile&&(e.push(`Memory-файл: \`${b.memoryFile}\``),c&&c.trim()?(e.push("```markdown"),e.push(c.slice(0,4e3)),e.push("```")):e.push("_(файл пуст или не существуетсоздашь при первом апдейте)_"),e.push("")),e.push("Что сделать:"),e.push(`- Эмитни \`<<reflex:widget-update>>\` с id="${b.id}" и свежими данными.`),e.push("- Если есть `memory` обнови её содержимое (дедуп ссылок, история значений и т.п.). Не сбрасывай в ноль."),b.memoryFile&&e.push(`- Если есть смысл допиши в memoryFile (\`${b.memoryFile}\`) через \`<<reflex:kb>>\` (kind="widget-memory", title="<заголовок>"). Не дублируй там содержимое самого виджета.`),e.push("- В чат отвечай коротко (одна строка) — это автоматический рефреш, развёрнутый комментарий не нужен."),e.push(`- Cadence: \`${b.refresh??"manual"}\`. Не меняй её без явной просьбы.`),e.join("\n")}}};
1
+ "use strict";exports.id=569,exports.ids=[569,4553],exports.modules={10569:(a,b,c)=>{c.a(a,async(a,d)=>{try{c.r(b),c.d(b,{isDue:()=>q,startWidgetScheduler:()=>m,stopWidgetScheduler:()=>n});var e=c(53905),f=c(93554),g=c(51021),h=c(69509),i=c(1405),j=c(94553),k=a([f,g]);[f,g]=k.then?(await k)():k;let s="__reflexWidgetScheduler";function l(){return globalThis[s]||(globalThis[s]={intervalId:null,ticking:!1,startedAt:new Date().toISOString()}),globalThis[s]}function m(){let a=l();a.intervalId||(setTimeout(()=>{o().catch(a=>{console.error("[widget-scheduler] initial tick failed:",a)})},3e4),a.intervalId=setInterval(()=>{o().catch(a=>{console.error("[widget-scheduler] tick failed:",a)})},3e5))}function n(){let a=l();a.intervalId&&(clearInterval(a.intervalId),a.intervalId=null)}async function o(){let a=l();if(!a.ticking){a.ticking=!0;try{for(let a of(await (0,e.qV)()))try{await p(a.id,a.path)}catch(b){console.error(`[widget-scheduler] root ${a.id} failed:`,b instanceof Error?b.message:b)}}finally{a.ticking=!1}}}async function p(a,b){for(let c of(await (0,h.listWidgets)(b)))q(c)&&c.sourceTopicId&&(f.z.isActive(c.sourceTopicId)||await r(a,b,c))}function q(a){if(!a.refresh||"manual"===a.refresh)return!1;let b=i.VQ[a.refresh];if(!b)return!1;let c=a.lastRefreshAt??a.updatedAt,d=Date.now()-Date.parse(c);return Number.isFinite(d)&&d>=b}async function r(a,b,c){let d={...c,lastRefreshAt:new Date().toISOString()};await (0,h.writeWidget)(b,d);let e=await (0,j.buildRefreshPromptForWidget)(b,d),f=await (0,g.W)({rootId:a,topicId:c.sourceTopicId,message:e,attachments:[]});"error"in f&&console.error(`[widget-scheduler] couldn't start refresh for ${c.id}: ${f.error}`)}d()}catch(a){d(a)}})},94553:(a,b,c)=>{c.d(b,{buildRefreshPromptForWidget:()=>e});var d=c(69509);async function e(a,b){let c=b.memoryFile?await (0,d.iq)(a,b.memoryFile):null,e=[];return e.push(`[Reflex auto-refresh] Widget "${b.title}" (id: \`${b.id}\`, kind: \`${b.kind}\`) is due for an update.`),e.push(""),e.push("Current widget data:"),e.push("```json"),e.push(JSON.stringify(b.data,null,2)),e.push("```"),e.push(""),b.memory&&b.memory.trim()&&(e.push("Current inline memory:"),e.push("```"),e.push(b.memory),e.push("```"),e.push("")),b.memoryFile&&(e.push(`Memory file: \`${b.memoryFile}\``),c&&c.trim()?(e.push("```markdown"),e.push(c.slice(0,4e3)),e.push("```")):e.push("_(file is empty or does not exist create it on the first update)_"),e.push("")),e.push("What to do:"),e.push(`- Emit \`<<reflex:widget-update>>\` with id="${b.id}" and fresh data.`),e.push("- If `memory` exists, update its contents (dedup links, value history, etc.). Do not reset it to empty."),b.memoryFile&&e.push(`- If it makes sense, append to memoryFile (\`${b.memoryFile}\`) via \`<<reflex:kb>>\` (kind="widget-memory", title="<title>"). Do not duplicate the widget's own data there.`),e.push("- Keep the chat reply short (one line) — this is an automatic refresh, no extended commentary needed."),e.push(`- Cadence: \`${b.refresh??"manual"}\`. Do not change it without an explicit request.`),e.join("\n")}}};
@@ -1 +1 @@
1
- "use strict";exports.id=6730,exports.ids=[3657,6730],exports.modules={63657:(a,b,c)=>{c.d(b,{Cs:()=>n,getOAuthProvider:()=>s,isOAuthProviderId:()=>t});var d=c(73024),e=c(48161),f=c.n(e),g=c(76760),h=c.n(g),i=c(14126);let j=i.Ik({title:i.Yj().min(1).max(200),body:i.Yj().max(2e3).optional(),field:i.Yj().max(200).optional(),copy:i.Yj().max(2e3).optional(),choice:i.Yj().max(200).optional()}),k=i.Ik({id:i.Yj().min(1).max(64).regex(/^[a-z][a-z0-9-]*$/,"provider id must be kebab-case (e.g. google, dropbox)"),label:i.Yj().min(1).max(120),authorizeUrl:i.Yj().url(),tokenUrl:i.Yj().url(),defaultScopes:i.YO(i.Yj()).default([]),supportsPKCE:i.zM().default(!0),refreshTokenSupported:i.zM().default(!0),extraAuthorizeParams:i.g1(i.Yj(),i.Yj()).default({}),needsClientSecret:i.zM().default(!0),setupHint:i.Yj().default(""),consoleUrl:i.Yj().url(),setupSteps:i.YO(j).default([])}),l={google:{id:"google",label:"Google",authorizeUrl:"https://accounts.google.com/o/oauth2/v2/auth",tokenUrl:"https://oauth2.googleapis.com/token",defaultScopes:["openid","email","https://www.googleapis.com/auth/calendar"],supportsPKCE:!0,refreshTokenSupported:!0,extraAuthorizeParams:{access_type:"offline",prompt:"consent"},needsClientSecret:!0,setupHint:"Если ещё не делалсначала включи нужный API (Calendar/Gmail/Drive) во вкладке APIs & Services → Library.",consoleUrl:"https://console.cloud.google.com/apis/credentials",setupSteps:[{title:"Открой Google Cloud Console → APIs & Services → Credentials."},{title:"Нажми \xab+ CREATE CREDENTIALS\xbb\xabOAuth client ID\xbb."},{title:"Application type",choice:"Web application",body:"Не \xabDesktop\xbb — Reflex использует фиксированный localhost-redirect."},{title:"Name — любое, например \xabReflex\xbb."},{title:"Authorized redirect URIs → ADD URI",field:"Authorized redirect URIs",copy:"http://localhost:3210/api/oauth/callback",body:"Точно как есть, без слэша в конце, http (не https)."},{title:"Жми CREATE → откроется попап с Client ID и Client Secret."},{title:"Скопируй сюда оба значения. (Если потерялоткрой клиент в Credentials, \xabDownload JSON\xbb или \xabReset secret\xbb.)"},{title:"Перед первым Authorize убедись, что нужный API включён: APIs & Services → Library → Google Calendar API → Enable (для других сервисов — аналогично)."}]},github:{id:"github",label:"GitHub",authorizeUrl:"https://github.com/login/oauth/authorize",tokenUrl:"https://github.com/login/oauth/access_token",defaultScopes:["repo","read:user"],supportsPKCE:!1,refreshTokenSupported:!1,extraAuthorizeParams:{},needsClientSecret:!0,setupHint:"Личные OAuth Apps живут в Settings → Developer settings.",consoleUrl:"https://github.com/settings/developers",setupSteps:[{title:"Открой github.com/settings/developers → OAuth Apps."},{title:"Нажми \xabNew OAuth App\xbb."},{title:"Application name — что угодно, например \xabReflex\xbb."},{title:"Homepage URL",field:"Homepage URL",copy:"http://localhost:3210"},{title:"Authorization callback URL",field:"Authorization callback URL",copy:"http://localhost:3210/api/oauth/callback"},{title:"Жми \xabRegister application\xbb."},{title:"Скопируй \xabClient ID\xbb отсюдав Reflex."},{title:"Нажми \xabGenerate a new client secret\xbb, скопируй значение сразу (показывается один раз) → в Reflex."}]},notion:{id:"notion",label:"Notion",authorizeUrl:"https://api.notion.com/v1/oauth/authorize",tokenUrl:"https://api.notion.com/v1/oauth/token",defaultScopes:[],supportsPKCE:!1,refreshTokenSupported:!1,extraAuthorizeParams:{owner:"user"},needsClientSecret:!0,setupHint:"Reflex использует Public integration (с OAuth flow), не Internal.",consoleUrl:"https://www.notion.so/profile/integrations",setupSteps:[{title:"Открой notion.so/profile/integrations → \xab+ New integration\xbb."},{title:"Name — \xabReflex\xbb."},{title:"Associated workspace — твой workspace."},{title:"Type",choice:"Public",body:"Internal не подходитдля OAuth flow нужна публичная integration."},{title:"Submit → integration создана. Перейди на её страницу."},{title:"В разделе \xabOAuth Domain & URIs\xbb → Redirect URIs → Add URI",field:"Redirect URIs",copy:"http://localhost:3210/api/oauth/callback"},{title:"Save."},{title:"В \xabSecrets\xbb скопируй OAuth client ID и OAuth client secret сюда."}]},slack:{id:"slack",label:"Slack",authorizeUrl:"https://slack.com/oauth/v2/authorize",tokenUrl:"https://slack.com/api/oauth.v2.access",defaultScopes:["chat:write","channels:read"],supportsPKCE:!1,refreshTokenSupported:!0,extraAuthorizeParams:{},needsClientSecret:!0,setupHint:"Scopes по умолчанию (chat:write, channels:read) можно расширить в OAuth & Permissions.",consoleUrl:"https://api.slack.com/apps",setupSteps:[{title:"Открой api.slack.com/apps → \xabCreate New App\xbb\xabFrom scratch\xbb."},{title:"App Name — \xabReflex\xbb, выбери свой workspace → Create App."},{title: левой панели открой \xabOAuth & Permissions\xbb → Redirect URLs → \xabAdd New Redirect URL\xbb",field:"Redirect URLs",copy:"http://localhost:3210/api/oauth/callback"},{title:"Save URLs."},{title:"Под Scopes → User Token Scopes добавь нужные (chat:write, channels:read и т.д. из defaults Reflex)."},{title:"Вверху страницы Install App → разреши доступполучишь Client ID и Client Secret в \xabBasic Information\xbb."}]},linear:{id:"linear",label:"Linear",authorizeUrl:"https://linear.app/oauth/authorize",tokenUrl:"https://api.linear.app/oauth/token",defaultScopes:["read","write"],supportsPKCE:!1,refreshTokenSupported:!0,extraAuthorizeParams:{},needsClientSecret:!0,setupHint:"Личная OAuth-aplication привязывается к твоему workspace.",consoleUrl:"https://linear.app/settings/api/applications/new",setupSteps:[{title:"Открой linear.app/settings/api/applications/new (Settings → API → OAuth applications → Create new)."},{title:"Name — \xabReflex\xbb, описание любое."},{title:"Developer URL",field:"Developer URL",copy:"http://localhost:3210"},{title:"Callback URLs",field:"Callback URLs",copy:"http://localhost:3210/api/oauth/callback"},{title:"Scopes — отметь read + write (или те, что нужны: issues:create и т.п.)."},{title:"Submit → копируй Client ID + Client Secret сюда."}]}},m=Object.keys(l),n="http://localhost:3210/api/oauth/callback",o=h().join(f().homedir(),".reflex","oauth","providers.json"),p=i.Ik({version:i.eu(1),providers:i.YO(k)});async function q(){try{let a=await d.promises.readFile(o,"utf8"),b=p.safeParse(JSON.parse(a));if(!b.success)return{version:1,providers:[]};return b.data}catch{return{version:1,providers:[]}}}async function r(){let a=await q(),b=new Set(a.providers.map(a=>a.id)),c=[];for(let a of m)b.has(a)||c.push({def:l[a],origin:"builtin"});for(let b of a.providers)c.push({def:b,origin:"user"});return c}async function s(a){let b=await r();return b.find(b=>b.def.id===a)?.def??null}async function t(a){return await s(a)!==null}},96730:(a,b,c)=>{c.d(b,{Dt:()=>o,getOAuthTokens:()=>p,tY:()=>n});var d=c(73024),e=c(76760),f=c.n(e);c(63657);var g=c(29163);let h=f().join((0,g._)(),"oauth"),i=f().join(h,"clients"),j=f().join(h,"tokens");function k(a){return f().join(j,`${a}.json`)}async function l(a,b){await d.promises.mkdir(f().dirname(a),{recursive:!0}),await d.promises.writeFile(a,JSON.stringify(b,null,2)+"\n",{encoding:"utf8",mode:384});try{await d.promises.chmod(a,384)}catch{}}async function m(a){try{let b=await d.promises.readFile(a,"utf8");return JSON.parse(b)}catch{return null}}async function n(a){return m(f().join(i,`${a}.json`))}async function o(a,b){await l(k(a),{...b,updatedAt:new Date().toISOString()})}async function p(a){return m(k(a))}}};
1
+ "use strict";exports.id=6730,exports.ids=[3657,6730],exports.modules={63657:(a,b,c)=>{c.d(b,{Cs:()=>n,getOAuthProvider:()=>s,isOAuthProviderId:()=>t});var d=c(73024),e=c(48161),f=c.n(e),g=c(76760),h=c.n(g),i=c(14126);let j=i.Ik({title:i.Yj().min(1).max(200),body:i.Yj().max(2e3).optional(),field:i.Yj().max(200).optional(),copy:i.Yj().max(2e3).optional(),choice:i.Yj().max(200).optional()}),k=i.Ik({id:i.Yj().min(1).max(64).regex(/^[a-z][a-z0-9-]*$/,"provider id must be kebab-case (e.g. google, dropbox)"),label:i.Yj().min(1).max(120),authorizeUrl:i.Yj().url(),tokenUrl:i.Yj().url(),defaultScopes:i.YO(i.Yj()).default([]),supportsPKCE:i.zM().default(!0),refreshTokenSupported:i.zM().default(!0),extraAuthorizeParams:i.g1(i.Yj(),i.Yj()).default({}),needsClientSecret:i.zM().default(!0),setupHint:i.Yj().default(""),consoleUrl:i.Yj().url(),setupSteps:i.YO(j).default([])}),l={google:{id:"google",label:"Google",authorizeUrl:"https://accounts.google.com/o/oauth2/v2/auth",tokenUrl:"https://oauth2.googleapis.com/token",defaultScopes:["openid","email","https://www.googleapis.com/auth/calendar"],supportsPKCE:!0,refreshTokenSupported:!0,extraAuthorizeParams:{access_type:"offline",prompt:"consent"},needsClientSecret:!0,setupHint:"If you haven't alreadyfirst enable the required API (Calendar/Gmail/Drive) under APIs & Services → Library.",consoleUrl:"https://console.cloud.google.com/apis/credentials",setupSteps:[{title:"Open Google Cloud Console → APIs & Services → Credentials."},{title:'Click "+ CREATE CREDENTIALS""OAuth client ID".'},{title:"Application type",choice:"Web application",body:'Not "Desktop" — Reflex uses a fixed localhost redirect.'},{title:'Name — anything, e.g. "Reflex".'},{title:"Authorized redirect URIs → ADD URI",field:"Authorized redirect URIs",copy:"http://localhost:3210/api/oauth/callback",body:"Exactly as shown, no trailing slash, http (not https)."},{title:"Hit CREATE → a popup will show the Client ID and Client Secret."},{title:'Copy both values here. (If lostopen the client in Credentials, use "Download JSON" or "Reset secret".)'},{title:"Before the first Authorize, make sure the required API is enabled: APIs & Services → Library → Google Calendar API → Enable (similarly for other services)."}]},github:{id:"github",label:"GitHub",authorizeUrl:"https://github.com/login/oauth/authorize",tokenUrl:"https://github.com/login/oauth/access_token",defaultScopes:["repo","read:user"],supportsPKCE:!1,refreshTokenSupported:!1,extraAuthorizeParams:{},needsClientSecret:!0,setupHint:"Personal OAuth Apps live in Settings → Developer settings.",consoleUrl:"https://github.com/settings/developers",setupSteps:[{title:"Open github.com/settings/developers → OAuth Apps."},{title:'Click "New OAuth App".'},{title:'Application name — anything, e.g. "Reflex".'},{title:"Homepage URL",field:"Homepage URL",copy:"http://localhost:3210"},{title:"Authorization callback URL",field:"Authorization callback URL",copy:"http://localhost:3210/api/oauth/callback"},{title:'Click "Register application".'},{title:'Copy "Client ID" from here into Reflex.'},{title:'Click "Generate a new client secret", copy the value immediately (shown only once) → into Reflex.'}]},notion:{id:"notion",label:"Notion",authorizeUrl:"https://api.notion.com/v1/oauth/authorize",tokenUrl:"https://api.notion.com/v1/oauth/token",defaultScopes:[],supportsPKCE:!1,refreshTokenSupported:!1,extraAuthorizeParams:{owner:"user"},needsClientSecret:!0,setupHint:"Reflex uses a Public integration (with OAuth flow), not Internal.",consoleUrl:"https://www.notion.so/profile/integrations",setupSteps:[{title:'Open notion.so/profile/integrations → "+ New integration".'},{title:'Name — "Reflex".'},{title:"Associated workspace — your workspace."},{title:"Type",choice:"Public",body:"Internal doesn't fitthe OAuth flow needs a public integration."},{title:"Submit → integration is created. Go to its page."},{title:'Under "OAuth Domain & URIs" → Redirect URIs → Add URI',field:"Redirect URIs",copy:"http://localhost:3210/api/oauth/callback"},{title:"Save."},{title:'Under "Secrets", copy the OAuth client ID and OAuth client secret here.'}]},slack:{id:"slack",label:"Slack",authorizeUrl:"https://slack.com/oauth/v2/authorize",tokenUrl:"https://slack.com/api/oauth.v2.access",defaultScopes:["chat:write","channels:read"],supportsPKCE:!1,refreshTokenSupported:!0,extraAuthorizeParams:{},needsClientSecret:!0,setupHint:"Default scopes (chat:write, channels:read) can be extended in OAuth & Permissions.",consoleUrl:"https://api.slack.com/apps",setupSteps:[{title:'Open api.slack.com/apps → "Create New App""From scratch".'},{title:'App Name — "Reflex", pick your workspace → Create App.'},{title:'In the left panel open "OAuth & Permissions" → Redirect URLs → "Add New Redirect URL"',field:"Redirect URLs",copy:"http://localhost:3210/api/oauth/callback"},{title:"Save URLs."},{title:"Under Scopes → User Token Scopes add the required ones (chat:write, channels:read, etc.from Reflex defaults)."},{title:'At the top of the page click Install App → grant accessyou\'ll get Client ID and Client Secret under "Basic Information".'}]},linear:{id:"linear",label:"Linear",authorizeUrl:"https://linear.app/oauth/authorize",tokenUrl:"https://api.linear.app/oauth/token",defaultScopes:["read","write"],supportsPKCE:!1,refreshTokenSupported:!0,extraAuthorizeParams:{},needsClientSecret:!0,setupHint:"A personal OAuth application is tied to your workspace.",consoleUrl:"https://linear.app/settings/api/applications/new",setupSteps:[{title:"Open linear.app/settings/api/applications/new (Settings → API → OAuth applications → Create new)."},{title:'Name — "Reflex", description anything.'},{title:"Developer URL",field:"Developer URL",copy:"http://localhost:3210"},{title:"Callback URLs",field:"Callback URLs",copy:"http://localhost:3210/api/oauth/callback"},{title:"Scopes — check read + write (or whichever you need: issues:create, etc.)."},{title:"Submit → copy Client ID + Client Secret here."}]}},m=Object.keys(l),n="http://localhost:3210/api/oauth/callback",o=h().join(f().homedir(),".reflex","oauth","providers.json"),p=i.Ik({version:i.eu(1),providers:i.YO(k)});async function q(){try{let a=await d.promises.readFile(o,"utf8"),b=p.safeParse(JSON.parse(a));if(!b.success)return{version:1,providers:[]};return b.data}catch{return{version:1,providers:[]}}}async function r(){let a=await q(),b=new Set(a.providers.map(a=>a.id)),c=[];for(let a of m)b.has(a)||c.push({def:l[a],origin:"builtin"});for(let b of a.providers)c.push({def:b,origin:"user"});return c}async function s(a){let b=await r();return b.find(b=>b.def.id===a)?.def??null}async function t(a){return await s(a)!==null}},96730:(a,b,c)=>{c.d(b,{Dt:()=>o,getOAuthTokens:()=>p,tY:()=>n});var d=c(73024),e=c(76760),f=c.n(e);c(63657);var g=c(29163);let h=f().join((0,g._)(),"oauth"),i=f().join(h,"clients"),j=f().join(h,"tokens");function k(a){return f().join(j,`${a}.json`)}async function l(a,b){await d.promises.mkdir(f().dirname(a),{recursive:!0}),await d.promises.writeFile(a,JSON.stringify(b,null,2)+"\n",{encoding:"utf8",mode:384});try{await d.promises.chmod(a,384)}catch{}}async function m(a){try{let b=await d.promises.readFile(a,"utf8");return JSON.parse(b)}catch{return null}}async function n(a){return m(f().join(i,`${a}.json`))}async function o(a,b){await l(k(a),{...b,updatedAt:new Date().toISOString()})}async function p(a){return m(k(a))}}};