reflex-agent 0.2.4 → 0.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.next/BUILD_ID +1 -1
- package/.next/app-build-manifest.json +103 -90
- package/.next/app-path-routes-manifest.json +8 -8
- package/.next/build-manifest.json +5 -5
- package/.next/prerender-manifest.json +4 -54
- package/.next/react-loadable-manifest.json +1 -1
- package/.next/server/app/_not-found/page.js +1 -1
- package/.next/server/app/_not-found/page.js.nft.json +1 -1
- package/.next/server/app/_not-found/page_client-reference-manifest.js +1 -1
- package/.next/server/app/agents/[agentId]/page.js +3 -3
- package/.next/server/app/agents/[agentId]/page.js.nft.json +1 -1
- package/.next/server/app/agents/[agentId]/page_client-reference-manifest.js +1 -1
- package/.next/server/app/api/agents/[agentId]/respond/route.js +2 -2
- package/.next/server/app/api/agents/[agentId]/respond/route.js.nft.json +1 -1
- package/.next/server/app/api/agents/[agentId]/respond/route_client-reference-manifest.js +1 -1
- package/.next/server/app/api/images/[rootId]/[file]/route_client-reference-manifest.js +1 -1
- package/.next/server/app/api/oauth/callback/route.js +3 -3
- package/.next/server/app/api/oauth/callback/route_client-reference-manifest.js +1 -1
- package/.next/server/app/api/oauth/start/route_client-reference-manifest.js +1 -1
- package/.next/server/app/api/roots/[id]/attachments/route.js +0 -0
- package/.next/server/app/api/roots/[id]/attachments/route_client-reference-manifest.js +1 -1
- package/.next/server/app/api/roots/[id]/chat/[topicId]/send/route.js +2 -2
- package/.next/server/app/api/roots/[id]/chat/[topicId]/send/route.js.nft.json +1 -1
- package/.next/server/app/api/roots/[id]/chat/[topicId]/send/route_client-reference-manifest.js +1 -1
- package/.next/server/app/api/roots/[id]/chat/[topicId]/stop/route.js +2 -2
- package/.next/server/app/api/roots/[id]/chat/[topicId]/stop/route.js.nft.json +1 -1
- package/.next/server/app/api/roots/[id]/chat/[topicId]/stop/route_client-reference-manifest.js +1 -1
- package/.next/server/app/api/roots/[id]/chat/[topicId]/stream/route.js +2 -2
- package/.next/server/app/api/roots/[id]/chat/[topicId]/stream/route.js.nft.json +1 -1
- package/.next/server/app/api/roots/[id]/chat/[topicId]/stream/route_client-reference-manifest.js +1 -1
- package/.next/server/app/api/roots/[id]/dashboard/route.js +1 -1
- package/.next/server/app/api/roots/[id]/dashboard/route.js.nft.json +1 -1
- package/.next/server/app/api/roots/[id]/dashboard/route_client-reference-manifest.js +1 -1
- package/.next/server/app/api/roots/[id]/suggestions/route.js +1 -1
- package/.next/server/app/api/roots/[id]/suggestions/route.js.nft.json +1 -1
- package/.next/server/app/api/roots/[id]/suggestions/route_client-reference-manifest.js +1 -1
- package/.next/server/app/api/utilities/[scope]/[id]/bundle.js/route_client-reference-manifest.js +1 -1
- package/.next/server/app/api/utilities/[scope]/[id]/host/route.js +2 -2
- package/.next/server/app/api/utilities/[scope]/[id]/host/route.js.nft.json +1 -1
- package/.next/server/app/api/utilities/[scope]/[id]/host/route_client-reference-manifest.js +1 -1
- package/.next/server/app/api/utilities/[scope]/[id]/host-api.mjs/route_client-reference-manifest.js +1 -1
- package/.next/server/app/api/utilities/[scope]/[id]/host-ui.mjs/route_client-reference-manifest.js +1 -1
- package/.next/server/app/api/utilities/[scope]/[id]/iframe/route_client-reference-manifest.js +1 -1
- package/.next/server/app/api/utilities/[scope]/[id]/style.css/route_client-reference-manifest.js +1 -1
- package/.next/server/app/audit/page.js +2 -2
- package/.next/server/app/audit/page.js.nft.json +1 -1
- package/.next/server/app/audit/page_client-reference-manifest.js +1 -1
- package/.next/server/app/onboarding/page.js +3 -3
- package/.next/server/app/onboarding/page.js.nft.json +1 -1
- package/.next/server/app/onboarding/page_client-reference-manifest.js +1 -1
- package/.next/server/app/page.js +2 -2
- package/.next/server/app/page.js.nft.json +1 -1
- package/.next/server/app/page_client-reference-manifest.js +1 -1
- package/.next/server/app/roots/[id]/chat/[topicId]/page.js +2 -6
- package/.next/server/app/roots/[id]/chat/[topicId]/page.js.nft.json +1 -1
- package/.next/server/app/roots/[id]/chat/[topicId]/page_client-reference-manifest.js +1 -1
- package/.next/server/app/roots/[id]/kb/[...slug]/page.js +2 -6
- package/.next/server/app/roots/[id]/kb/[...slug]/page.js.nft.json +1 -1
- package/.next/server/app/roots/[id]/kb/[...slug]/page_client-reference-manifest.js +1 -1
- package/.next/server/app/roots/[id]/page.js +3 -3
- package/.next/server/app/roots/[id]/page.js.nft.json +1 -1
- package/.next/server/app/roots/[id]/page_client-reference-manifest.js +1 -1
- package/.next/server/app/roots/[id]/workflows/[wfId]/page.js +2 -2
- package/.next/server/app/roots/[id]/workflows/[wfId]/page.js.nft.json +1 -1
- package/.next/server/app/roots/[id]/workflows/[wfId]/page_client-reference-manifest.js +1 -1
- package/.next/server/app/roots/[id]/workflows/page.js +2 -2
- package/.next/server/app/roots/[id]/workflows/page.js.nft.json +1 -1
- package/.next/server/app/roots/[id]/workflows/page_client-reference-manifest.js +1 -1
- package/.next/server/app/roots/new/page.js +5 -3
- package/.next/server/app/roots/new/page.js.nft.json +1 -1
- package/.next/server/app/roots/new/page_client-reference-manifest.js +1 -1
- package/.next/server/app/settings/page.js +5 -5
- package/.next/server/app/settings/page.js.nft.json +1 -1
- package/.next/server/app/settings/page_client-reference-manifest.js +1 -1
- package/.next/server/app/share/[id]/file/page.js +2 -2
- package/.next/server/app/share/[id]/file/page.js.nft.json +1 -1
- package/.next/server/app/share/[id]/file/page_client-reference-manifest.js +1 -1
- package/.next/server/app/share/[id]/page.js +2 -2
- package/.next/server/app/share/[id]/page.js.nft.json +1 -1
- package/.next/server/app/share/[id]/page_client-reference-manifest.js +1 -1
- package/.next/server/app/utilities/[scope]/[id]/page.js +2 -2
- package/.next/server/app/utilities/[scope]/[id]/page.js.nft.json +1 -1
- package/.next/server/app/utilities/[scope]/[id]/page_client-reference-manifest.js +1 -1
- package/.next/server/app/utilities/page.js +2 -17
- package/.next/server/app/utilities/page.js.nft.json +1 -1
- package/.next/server/app/utilities/page_client-reference-manifest.js +1 -1
- package/.next/server/app-paths-manifest.json +8 -8
- package/.next/server/chunks/1.js +3 -0
- package/.next/server/chunks/1223.js +1 -1
- package/.next/server/chunks/133.js +1 -490
- package/.next/server/chunks/1888.js +1 -1
- package/.next/server/chunks/{9739.js → 1988.js} +13 -9
- package/.next/server/chunks/2192.js +1 -0
- package/.next/server/chunks/2433.js +1 -1
- package/.next/server/chunks/2503.js +1 -1
- package/.next/server/chunks/285.js +471 -0
- package/.next/server/chunks/2995.js +1 -0
- package/.next/server/chunks/3240.js +1 -1
- package/.next/server/chunks/3332.js +1 -1
- package/.next/server/chunks/{3953.js → 3512.js} +2 -2
- package/.next/server/chunks/3657.js +1 -1
- package/.next/server/chunks/4066.js +1 -1
- package/.next/server/chunks/4438.js +1 -0
- package/.next/server/chunks/4553.js +1 -1
- package/.next/server/chunks/4812.js +179 -0
- package/.next/server/chunks/4925.js +1 -1
- package/.next/server/chunks/5319.js +1 -1
- package/.next/server/chunks/569.js +1 -1
- package/.next/server/chunks/6730.js +1 -1
- package/.next/server/chunks/6734.js +1 -0
- package/.next/server/chunks/6909.js +142 -161
- package/.next/server/chunks/7215.js +1 -0
- package/.next/server/chunks/8262.js +1 -1
- package/.next/server/chunks/9098.js +1 -1
- package/.next/server/chunks/94.js +1 -1
- package/.next/server/chunks/9835.js +1 -1
- package/.next/server/chunks/9944.js +1 -0
- package/.next/server/middleware-build-manifest.js +1 -1
- package/.next/server/middleware-manifest.json +5 -5
- package/.next/server/middleware-react-loadable-manifest.js +1 -1
- package/.next/server/pages/500.html +1 -1
- package/.next/server/pages-manifest.json +1 -2
- package/.next/server/server-reference-manifest.js +1 -1
- package/.next/server/server-reference-manifest.json +1 -1
- package/.next/static/chunks/1082-326e649fb24d4945.js +1 -0
- package/.next/static/chunks/3736-f4e42d6d38be50b0.js +1 -0
- package/.next/static/chunks/4108.ca0bdf3cbf3c56cc.js +1 -0
- package/.next/static/chunks/6445-99824866a51b582a.js +1 -0
- package/.next/static/chunks/7482-7ef26030a10ce14f.js +1 -0
- package/.next/static/chunks/8944-c4f2406ecd61094f.js +1 -0
- package/.next/static/chunks/9411-af5f758c57741929.js +3 -0
- package/.next/static/chunks/9415-eb6b5d4c2de3a7c0.js +1 -0
- package/.next/static/chunks/app/agents/[agentId]/page-5d6f4cb16b42d02b.js +1 -0
- package/.next/static/chunks/app/layout-85eb1fd21dab0895.js +1 -0
- package/.next/static/chunks/app/onboarding/page-2013bd8124b9162e.js +1 -0
- package/.next/static/chunks/app/page-558a224e13ffb52c.js +1 -0
- package/.next/static/chunks/app/roots/[id]/chat/[topicId]/page-b42f03fd58669d12.js +1 -0
- package/.next/static/chunks/app/roots/[id]/kb/[...slug]/page-7d17b4e6a5231f56.js +1 -0
- package/.next/static/chunks/app/roots/[id]/page-4aab5266f432e37e.js +1 -0
- package/.next/static/chunks/app/roots/[id]/workflows/[wfId]/page-1ee3320bf5744efc.js +1 -0
- package/.next/static/chunks/app/roots/new/page-df8d2c1f0c64c37a.js +1 -0
- package/.next/static/chunks/app/settings/page-fdba798d9e243ad3.js +1 -0
- package/.next/static/chunks/app/share/[id]/page-818a451d05e08d26.js +1 -0
- package/.next/static/chunks/app/utilities/[scope]/[id]/page-2cee09cc2ab9b5e8.js +1 -0
- package/.next/static/chunks/app/utilities/page-44a51522b347f13e.js +1 -0
- package/.next/static/chunks/{webpack-5fca180586957874.js → webpack-2b0eab4ccdf44f63.js} +1 -1
- package/.next/static/css/4b367c1d0fa99b78.css +1 -0
- package/.next/trace +47 -46
- package/dist/lib/reflex/agents/prompts.js +46 -46
- package/dist/lib/reflex/agents/prompts.js.map +1 -1
- package/dist/lib/reflex/prompts/defaults.js +102 -102
- package/next.config.ts +4 -1
- package/package.json +2 -1
- package/packages/utilities/learn-anything/README.md +29 -29
- package/packages/utilities/learn-anything/actions/_json.ts +11 -11
- package/packages/utilities/learn-anything/actions/_store.ts +2 -2
- package/packages/utilities/learn-anything/actions/buildModule.ts +60 -59
- package/packages/utilities/learn-anything/actions/explainSelection.ts +14 -13
- package/packages/utilities/learn-anything/actions/generateOutline.ts +15 -15
- package/packages/utilities/learn-anything/actions/generateQuiz.ts +8 -8
- package/packages/utilities/learn-anything/actions/generateTrainer.ts +15 -15
- package/packages/utilities/learn-anything/actions/refreshCourseCard.ts +4 -4
- package/packages/utilities/learn-anything/actions/tutorAsk.ts +15 -15
- package/packages/utilities/learn-anything/article-view.tsx +4 -4
- package/packages/utilities/learn-anything/manifest.json +5 -5
- package/packages/utilities/learn-anything/ui.tsx +57 -57
- package/.next/server/app/_not-found.html +0 -1
- package/.next/server/app/_not-found.meta +0 -8
- package/.next/server/app/_not-found.rsc +0 -18
- package/.next/server/app/index.html +0 -1
- package/.next/server/app/index.meta +0 -9
- package/.next/server/app/index.rsc +0 -19
- package/.next/server/chunks/1410.js +0 -1
- package/.next/server/chunks/1986.js +0 -1
- package/.next/server/chunks/2448.js +0 -3
- package/.next/server/chunks/5754.js +0 -3
- package/.next/server/chunks/7097.js +0 -1
- package/.next/server/chunks/7782.js +0 -1
- package/.next/server/chunks/7987.js +0 -1
- package/.next/server/chunks/810.js +0 -1
- package/.next/server/chunks/8843.js +0 -1
- package/.next/server/chunks/9328.js +0 -179
- package/.next/server/pages/404.html +0 -1
- package/.next/static/chunks/2488-c9590facb4b9f184.js +0 -1
- package/.next/static/chunks/2684-257d38989ef53935.js +0 -1
- package/.next/static/chunks/4108.fb9f99a9c899ef54.js +0 -1
- package/.next/static/chunks/6231-d83c1544bbea8424.js +0 -1
- package/.next/static/chunks/9045-731ff0865352dd95.js +0 -1
- package/.next/static/chunks/9496-75ccd3fadb294fba.js +0 -1
- package/.next/static/chunks/992-4e7b7f722c629e21.js +0 -1
- package/.next/static/chunks/app/agents/[agentId]/page-0b5c2838354d0eba.js +0 -1
- package/.next/static/chunks/app/layout-9a59ed07c18cb786.js +0 -1
- package/.next/static/chunks/app/onboarding/page-79f07a813ea2abfe.js +0 -1
- package/.next/static/chunks/app/page-27f4b98b02ac4f79.js +0 -1
- package/.next/static/chunks/app/roots/[id]/chat/[topicId]/page-8db2d0b75cd333c8.js +0 -1
- package/.next/static/chunks/app/roots/[id]/kb/[...slug]/page-873b131eec3a2f30.js +0 -1
- package/.next/static/chunks/app/roots/[id]/page-270d0d49eb668784.js +0 -1
- package/.next/static/chunks/app/roots/[id]/workflows/[wfId]/page-7c1f10dbe0bcb9ad.js +0 -1
- package/.next/static/chunks/app/roots/new/page-ac1a9f6379710ca2.js +0 -1
- package/.next/static/chunks/app/settings/page-81cb1393e817dfc3.js +0 -1
- package/.next/static/chunks/app/share/[id]/page-2d123f0a99e1606f.js +0 -1
- package/.next/static/chunks/app/utilities/[scope]/[id]/page-0bbb8d17af80c1da.js +0 -1
- package/.next/static/chunks/app/utilities/page-e6ce673b9357bf1f.js +0 -1
- package/.next/static/css/87e01f779d555d04.css +0 -1
- /package/.next/static/{og_wC7UPkGtJDiapaTgBr → fhVNqfmJl5Mdfhyhg6orp}/_buildManifest.js +0 -0
- /package/.next/static/{og_wC7UPkGtJDiapaTgBr → fhVNqfmJl5Mdfhyhg6orp}/_ssgManifest.js +0 -0
|
@@ -0,0 +1,471 @@
|
|
|
1
|
+
exports.id=285,exports.ids=[285],exports.modules={580:(a,b,c)=>{"use strict";c.d(b,{S:()=>t,addMcpServer:()=>r,getMcpServer:()=>q,listMcpServers:()=>p,updateMcpServer:()=>s});var d=c(73024),e=c(76760),f=c.n(e),g=c(56149),h=c(97453),i=c(73652);let j=f().join((0,i._)(),"mcp"),k=f().join(j,"servers.json"),l=g.Ik({id:g.Yj().min(1).max(64).regex(/^[a-zA-Z][a-zA-Z0-9_-]*$/,"id must start with a letter; letters, digits, '_' and '-' allowed"),label:g.Yj().min(1).max(120),description:g.Yj().max(2e3).default(""),config:h.McpConfigSchema,addedAt:g.Yj(),lastVerifiedAt:g.Yj().optional()}),m=g.Ik({version:g.eu(1),servers:g.YO(l)});async function n(){try{let a=await d.promises.readFile(k,"utf8"),b=m.safeParse(JSON.parse(a));if(!b.success)return{version:1,servers:[]};return b.data}catch{return{version:1,servers:[]}}}async function o(a){await d.promises.mkdir(j,{recursive:!0}),await d.promises.writeFile(k,JSON.stringify(a,null,2)+"\n",{encoding:"utf8",mode:384});try{await d.promises.chmod(k,384)}catch{}}async function p(){return[...(await n()).servers].sort((a,b)=>a.id.localeCompare(b.id))}async function q(a){return(await n()).servers.find(b=>b.id===a)??null}async function r(a){let b=l.parse({id:a.id,label:a.label,description:a.description??"",config:a.config,addedAt:new Date().toISOString()}),c=await n();if(c.servers.some(a=>a.id===b.id))throw Error(`MCP server "${b.id}" already exists`);return c.servers.push(b),await o(c),b}async function s(a,b){let c=await n(),d=c.servers.findIndex(b=>b.id===a);if(d<0)throw Error(`MCP server "${a}" not found`);let e=l.parse({...c.servers[d],...b});return c.servers[d]=e,await o(c),e}async function t(a){let b=await n(),c=b.servers.filter(b=>b.id!==a);c.length!==b.servers.length&&(b.servers=c,await o(b))}},875:(a,b,c)=>{"use strict";c.d(b,{$4:()=>f,FB:()=>g,GX:()=>l,YE:()=>k,dA:()=>h,vl:()=>j,wr:()=>e,wt:()=>i});var d=c(96921);function e(a){let b=(0,d.dr)(a);return b&&("plan"===b.def.id||"goal"===b.def.id)?{kind:b.def.id,text:b.payload}:null}function f(a){return`## /plan — Plan-first mode
|
|
2
|
+
|
|
3
|
+
Reply in ${a}. **Before doing anything**, lay out a clear, numbered step-by-step plan. Each step should be concrete and verifiable.
|
|
4
|
+
|
|
5
|
+
Once the plan is ready, emit a question marker requesting approval:
|
|
6
|
+
|
|
7
|
+
<<reflex:question>>{"prompt":"Approve this plan?","choices":["approve","revise"]}<</reflex:question>>
|
|
8
|
+
|
|
9
|
+
Then STOP and wait for the user's reply.
|
|
10
|
+
|
|
11
|
+
On the next turn:
|
|
12
|
+
- If the user approved → execute the plan, narrating progress and tools used.
|
|
13
|
+
- If the user asked to revise/change → update the plan and emit another approval question.
|
|
14
|
+
Iterate until the user explicitly approves. Do not begin execution until then.`}function g(a,b){return`## /goal — Persistent goal mode (do not stop until validated)
|
|
15
|
+
|
|
16
|
+
Active goal: ${a}
|
|
17
|
+
|
|
18
|
+
Reply in ${b}. Reflex will keep re-invoking you turn after turn until the goal is achieved AND validated. Don't write filler — every turn must move the task forward.
|
|
19
|
+
|
|
20
|
+
Workflow each turn:
|
|
21
|
+
1. Take the next concrete action toward the goal (use tools when needed: Read, Glob, Grep, WebSearch, WebFetch, etc.).
|
|
22
|
+
2. Show your work briefly so the user can audit progress.
|
|
23
|
+
3. When you believe the goal is complete, **validate it** (verify with a tool: read the file, fetch the URL, run a search). Don't claim completion without evidence.
|
|
24
|
+
4. After successful validation, emit a KB record:
|
|
25
|
+
|
|
26
|
+
<<reflex:kb>>{"kind":"goal-completion","title":"<short>","body":"<what was done + validation evidence>","meta":{"goal":${JSON.stringify(a)}}}<</reflex:kb>>
|
|
27
|
+
|
|
28
|
+
And END your message with the literal phrase on its own line:
|
|
29
|
+
|
|
30
|
+
GOAL ACHIEVED
|
|
31
|
+
|
|
32
|
+
If you genuinely need user input mid-flight (clarification, permission for a risky action, missing data), pause via <<reflex:question>> or <<reflex:permission>>. Those markers stop auto-continuation; everything else keeps the loop going.`}function h(a,b){return["## /research — Deep research mode (this turn)","",`Reply in ${b}.`,a?`Topic: ${a}`:"","","Approach:"," 1. Delegate the main search to a sub-agent with role `researcher` via `<<reflex:dispatch>>` (one marker — it will sweep web + KB on its own).",' 2. If possible — multiple researchers in parallel with different angles (e.g. "history", "current state", "criticism").'," 3. Wait for results, **compose a synthesis**: similarities, disagreements, blind spots. Cite sources with links.",' 4. At the end, propose saving key facts to the KB via the `<<reflex:kb>>` marker (kind="research-note") — but wait for confirmation.'," 5. If the topic is deep — propose a `news-list` or `link-list` widget via `<<reflex:widget-create>>`.","","Don't answer from model memory — drive everything through WebSearch/WebFetch."].filter(Boolean).join("\n")}function i(a,b){return["## /widget — Create a dashboard widget","",`Reply in ${b}.`,a?`User request: ${a}`:"","","Rules:"," 1. Pick the appropriate `kind` (see the widgets block in the system prompt). If the request is ambiguous — ask via `<<reflex:question>>`."," 2. Pick a stable kebab-case `id` that can later be reused for widget-update."," 3. If you need fresh data (news, prices, statuses) — gather it via WebSearch/WebFetch before emitting."," 4. Emit **one** `<<reflex:widget-create>>` marker in this turn, then briefly tell the user what appeared on the dashboard.",' 5. If the widget makes sense to auto-refresh — set `refresh: "hourly"|"daily"|"weekly"` and describe `memory` for dedup/history.'].filter(Boolean).join("\n")}function j(a,b){return["## /workflow — Build a workflow (n8n-style linear recipe)","",`Reply in ${b}.`,a?`User request: ${a}`:"","","Rules:"," 1. If the task is ambiguous (what's included, where to write, how often) — ask 1-3 clarifying questions via `<<reflex:question>>` in a SINGLE block. Don't guess."," 2. Steps are SHORT (3-5). Supported kinds: `text-template`, `http-request`, `web-fetch`, `ask-agent`, `kb-write`. If the task is broader — split it into multiple workflows."," 3. Each step's `id` is stable kebab-case (templates use it: `{{steps.<id>.output}}`)."," 4. Trigger defaults to `manual`. Set `hourly/daily/weekly` only if the user explicitly asked for a schedule."," 5. Emit **one** `<<reflex:workflow-create>>` marker in this turn. Don't duplicate the JSON in text — the preview card renders in chat automatically."," 6. After the marker — a short plan in words: what the workflow does step by step, how to run it, what appears as the result."].filter(Boolean).join("\n")}function k(a,b){return["## /mcp — Connect an MCP server","",`Reply in ${b}.`,a?`Request: ${a}`:"The user wants to connect an MCP server but didn't specify which one.","","Act as an MCP wizard:",' 1. If the request is concrete (e.g. "github mcp", "notion") — pick a config right away and propose it via `<<reflex:mcp-add>>`. Don\'t forget secrets slots with a description of where to get the token.'," 2. If the request is abstract — ask via `<<reflex:question>>` what to connect (Notion / Slack / GitHub / Linear / other)."," 3. If it's about an existing server — ask the user to use its tools; don't propose the add card again."].filter(Boolean).join("\n")}let l=15},1405:(a,b,c)=>{"use strict";c.d(b,{SYSTEM_WIDGET_IDS:()=>e,VQ:()=>d,hU:()=>f});let d={hourly:36e5,daily:864e5,weekly:6048e5},e=["sys:active-goals","sys:pending","sys:recent-kb","sys:ai-suggestions"],f=["markdown","news-list","link-list","kpi","checklist","quote","kb-pinned","progress","image","stat-table","map","utility-card"]},3724:(a,b,c)=>{"use strict";c.a(a,async(a,d)=>{try{c.d(b,{runHeadlessAgent:()=>l});var e=c(93554),f=c(51021),g=c(20243),h=c(5492),i=c(36017),j=c(53905),k=a([e,f]);async function l(a){let b=await (0,j.Zn)(a.rootId);if(!b)throw Error(`runHeadlessAgent: root not found: ${a.rootId}`);let c=await (0,i.M)(),d=c.assignments.chat,k=await (0,h.OY)({root:b.path,firstMessage:a.label??"[headless agent run]",harness:a.harness??d.harness,model:a.model??d.model,language:a.language??c.language}),l=!1;try{let c=await (0,f.W)({rootId:a.rootId,topicId:k.meta.id,message:a.prompt,attachments:a.attachments??[],...a.harness?{harness:a.harness}:{},...a.model?{model:a.model}:{}});if("error"in c)throw Error(c.error);let d=Date.now()+(a.timeoutMs??3e5);for(await m(400);Date.now()<d&&e.z.isActive(k.meta.id);)await m(400);e.z.isActive(k.meta.id)&&(l=!0),await m(400);let h=await (0,g.readEvents)(b.path,k.meta.id),i=h.filter(a=>"assistant-delta"===a.type).map(a=>a.text).join("").trim();if(!i){let b=h.filter(a=>"error"===a.type).map(a=>a.message).filter(Boolean);if(b.length>0)throw Error(`Agent finished with errors: ${b.slice(0,3).join(" \xb7 ")}`);let c=h.filter(a=>"system"===a.type).map(a=>a.text).filter(Boolean);if(c.length>0)return{text:c.join("\n"),topicId:k.meta.id,timedOut:l};if(l)throw Error(`Agent did not respond within ${Math.round((a.timeoutMs??3e5)/1e3)}s (timeout)`);throw Error("Agent finished without producing any text — perhaps no chat engine is configured in Settings.")}return{text:i,topicId:k.meta.id,timedOut:l}}finally{try{await e.z.stopTopic(k.meta.id)}catch{}try{await (0,h.do)(b.path,k.meta.id)}catch{}}}function m(a){return new Promise(b=>setTimeout(b,a))}[e,f]=k.then?(await k)():k,d()}catch(a){d(a)}})},3890:(a,b,c)=>{"use strict";c.d(b,{u:()=>j,z:()=>k});var d=c(73745);c(66493);var e=c(76760),f=c.n(e),g=c(53905),h=c(19319),i=c(5492);async function j(a){try{let b=await (0,g.Zn)(a);if(!b)return{ok:!1,error:"Root not found"};let c=await (0,h.dj)(b.path);return{ok:!0,sections:function(a){let b=[],c=new Map;for(let e of a){let a=e.rel.split("/");if(1===a.length){var d;b.push({rel:(d=e).rel,label:d.meta.title??d.rel,isDir:!1,fileRel:d.rel});continue}let f=a[0],g=c.get(f)??[];g.push(e),c.set(f,g)}let e=[];for(let a of(b.sort(l),e.push(...b),[...c.keys()].sort())){let b=(c.get(a)??[]).map(a=>{let b=a.rel.split("/").slice(1).join("/");return{rel:a.rel,label:a.meta.title??f().basename(b),isDir:!1,fileRel:a.rel}}).sort((a,b)=>"INDEX.md"===f().basename(a.rel)?-1:"INDEX.md"===f().basename(b.rel)?1:a.label.localeCompare(b.label)),d=b.find(a=>"INDEX.md"===f().basename(a.rel)),g=d?.label??a;e.push({rel:`${a}/`,label:g,isDir:!0,children:b})}return e}(c)}}catch(a){return{ok:!1,error:a instanceof Error?a.message:String(a)}}}async function k(a){try{let b=await (0,g.Zn)(a);if(!b)return{ok:!1,error:"Root not found"};let c=await (0,i.hk)(b.path);return{ok:!0,topics:c.map(a=>({id:a.meta.id,title:a.meta.title,updatedAt:a.meta.updatedAt}))}}catch(a){return{ok:!1,error:a instanceof Error?a.message:String(a)}}}function l(a,b){let c=f().basename(a.rel),d=f().basename(b.rel);return"INDEX.md"===c?-1:"INDEX.md"===d?1:a.label.localeCompare(b.label)}(0,c(63781).D)([j,k]),(0,d.A)(j,"40fb9a51fc988de06001469d31584e206fe09c114a",null),(0,d.A)(k,"403e94ff983431251fa0fbb2f25b8da8f6fcf79b7c",null)},4868:(a,b,c)=>{"use strict";c.d(b,{AppSidebar:()=>J});var d=c(64173),e=c(17240),f=c(1056),g=c.n(f),h=c(87671),i=c(44052),j=c(71813),k=c(69552),l=c(61636),m=c(15666),n=c(58405),o=c(58507),p=c(98463),q=c(68669),r=c(62261),s=c(53186),t=c(51348),u=c(97338),v=c(43173),w=c(88724),x=c(27456),y=c(68394),z=c(20583),A=c(3265);let B=(0,A.createServerReference)("40fb9a51fc988de06001469d31584e206fe09c114a",A.callServer,void 0,A.findSourceMapURL,"loadKbSectionsAction"),C=(0,A.createServerReference)("403e94ff983431251fa0fbb2f25b8da8f6fcf79b7c",A.callServer,void 0,A.findSourceMapURL,"loadTopicsAction"),D=(0,A.createServerReference)("0005921da7741e17d472ed0986d2f5be5a6f350a19",A.callServer,void 0,A.findSourceMapURL,"listRootsAction"),E=(0,A.createServerReference)("403e063aecb7113e309df608c40aaed12362c7ba48",A.callServer,void 0,A.findSourceMapURL,"listAgentsAction");var F=c(97162),G=c(29370),H=c(65266),I=c(10082);function J({initialRoots:a}){let b=(0,h.usePathname)(),c=(0,j.c)("app"),[f,i]=(0,e.useState)(a),n=(0,e.useCallback)(async()=>{let a=await D();a.ok&&i(a.entries)},[]);return((0,w.S9)(w.Zi.rootsChanged,n),b?.startsWith("/share/")||"/share"===b)?null:(0,d.jsxs)("aside",{className:"w-72 shrink-0 border-r bg-muted/30 flex flex-col",children:[(0,d.jsxs)("div",{className:"px-4 py-4 flex items-center gap-2 border-b",children:[(0,d.jsx)("span",{className:"reflex-gradient inline-flex h-7 w-7 items-center justify-center rounded-lg text-white shadow-sm",children:(0,d.jsx)(k.A,{className:"h-4 w-4"})}),(0,d.jsxs)("div",{className:"leading-tight",children:[(0,d.jsx)(g(),{href:"/",className:"text-sm font-semibold tracking-tight hover:underline",children:"Reflex"}),(0,d.jsx)("div",{className:"text-[10px] uppercase tracking-wider text-muted-foreground",children:"knowledge base"})]})]}),(0,d.jsx)(x.F,{className:"flex-1",children:(0,d.jsxs)("nav",{className:"px-2 pt-3 pb-6",children:[(0,d.jsx)("div",{className:"px-2 mb-1 text-[10px] uppercase tracking-wider text-muted-foreground",children:c("sidebar.spaces")}),0===f.length?(0,d.jsx)("div",{className:"px-2 py-3 text-xs text-muted-foreground",children:c("sidebar.empty")}):(0,d.jsx)("ul",{className:"space-y-0.5",children:f.map(a=>(0,d.jsx)(K,{root:a,active:b?.startsWith(`/roots/${a.id}`)??!1},a.id))}),(0,d.jsx)("div",{className:"mt-2 px-2",children:(0,d.jsx)(z.$,{asChild:!0,variant:"ghost",size:"sm",className:"h-7 w-full justify-start text-xs",children:(0,d.jsxs)(g(),{href:"/roots/new",children:[(0,d.jsx)(l.A,{className:"mr-1 h-3.5 w-3.5"})," ",c("sidebar.addSpace")]})})})]})}),(0,d.jsx)(y.Separator,{}),(0,d.jsxs)("div",{className:"px-2 py-2 space-y-0.5",children:[(0,d.jsx)(z.$,{asChild:!0,variant:"/utilities"===b||b?.startsWith("/utilities/")?"secondary":"ghost",size:"sm",className:"w-full justify-start",children:(0,d.jsxs)(g(),{href:"/utilities",children:[(0,d.jsx)(F.A,{className:"mr-2 h-4 w-4"})," ",c("sidebar.utilities")]})}),(0,d.jsx)(z.$,{asChild:!0,variant:"/audit"===b?"secondary":"ghost",size:"sm",className:"w-full justify-start",children:(0,d.jsxs)(g(),{href:"/audit",children:[(0,d.jsx)(G.A,{className:"mr-2 h-4 w-4"})," ",c("sidebar.audit")]})}),(0,d.jsx)(z.$,{asChild:!0,variant:"/settings"===b?"secondary":"ghost",size:"sm",className:"w-full justify-start",children:(0,d.jsxs)(g(),{href:"/settings",children:[(0,d.jsx)(m.A,{className:"mr-2 h-4 w-4"})," Settings"]})})]})]})}function K({root:a,active:b}){let c=(0,j.c)("app"),[f,i]=(0,e.useState)(b),[k,l]=(0,e.useState)(!1),[m,t]=(0,e.useState)(!1),[u,v]=(0,e.useState)(!1),[x,y]=(0,e.useState)(null),[z,A]=(0,e.useState)(null),[D,F]=(0,e.useState)(null),[G,I]=(0,e.useState)(!1),[J,K]=(0,e.useState)(!1),[M,N]=(0,e.useState)(!1),Q=(0,h.usePathname)(),R=(0,e.useCallback)(async()=>{I(!0);let b=await B(a.id);I(!1),b.ok?y(b.sections):y([])},[a.id]),S=(0,e.useCallback)(async()=>{K(!0);let b=await C(a.id);K(!1),b.ok?A(b.topics):A([])},[a.id]),U=(0,e.useCallback)(async()=>{N(!0);let b=await E({rootId:a.id});N(!1),b.ok?F(b.agents):F([])},[a.id]);(0,w.S9)(w.Zi.kbChanged(a.id),()=>{k?R():y(null)}),(0,w.S9)(w.Zi.topicsChanged(a.id),()=>{m?S():A(null),u?U():F(null)});let V=async()=>{let a=!k;l(a),a&&null===x&&!G&&await R()},W=async()=>{let a=!m;t(a),a&&null===z&&!J&&await S()},X=async()=>{let a=!u;v(a),a&&null===D&&!M&&await U()},Y=function(a){let b=a.split("/").filter(Boolean);return b[b.length-1]??a}(a.path);return(0,d.jsxs)("li",{children:[(0,d.jsxs)("div",{className:"flex items-center group",children:[(0,d.jsx)("button",{type:"button",onClick:()=>i(a=>!a),className:"h-6 w-6 flex items-center justify-center text-muted-foreground hover:text-foreground shrink-0","aria-label":c(f?"sidebar.collapse":"sidebar.expand"),children:f?(0,d.jsx)(n.A,{className:"h-3.5 w-3.5"}):(0,d.jsx)(o.A,{className:"h-3.5 w-3.5"})}),(0,d.jsxs)(g(),{href:`/roots/${a.id}`,className:`flex-1 min-w-0 flex items-center gap-2 px-2 py-1 rounded-md text-sm hover:bg-accent ${b?"bg-accent":""}`,children:[(0,d.jsx)(p.A,{className:"h-3.5 w-3.5 text-muted-foreground shrink-0"}),(0,d.jsx)("span",{className:"truncate",children:Y})]})]}),f&&(0,d.jsxs)("ul",{className:"ml-5 mt-0.5 space-y-0.5 border-l pl-1",children:[(0,d.jsxs)("li",{children:[(0,d.jsxs)("button",{type:"button",onClick:V,className:"w-full flex items-center gap-1 px-2 py-1 rounded-md text-xs text-muted-foreground hover:bg-accent hover:text-foreground",children:[k?(0,d.jsx)(n.A,{className:"h-3 w-3 shrink-0"}):(0,d.jsx)(o.A,{className:"h-3 w-3 shrink-0"}),(0,d.jsx)(q.A,{className:"h-3 w-3 shrink-0"}),(0,d.jsx)("span",{className:"truncate",children:c("sidebar.kb")}),G&&(0,d.jsx)(r.A,{className:"ml-auto h-3 w-3 animate-spin shrink-0"})]}),k&&null!==x&&(0,d.jsx)(P,{rootId:a.id,sections:x,pathname:Q})]}),(0,d.jsxs)("li",{children:[(0,d.jsxs)("button",{type:"button",onClick:W,className:"w-full flex items-center gap-1 px-2 py-1 rounded-md text-xs text-muted-foreground hover:bg-accent hover:text-foreground",children:[m?(0,d.jsx)(n.A,{className:"h-3 w-3 shrink-0"}):(0,d.jsx)(o.A,{className:"h-3 w-3 shrink-0"}),(0,d.jsx)(s.A,{className:"h-3 w-3 shrink-0"}),(0,d.jsx)("span",{className:"truncate",children:c("sidebar.topics")}),J&&(0,d.jsx)(r.A,{className:"ml-auto h-3 w-3 animate-spin shrink-0"}),null!==z&&(0,d.jsx)("span",{className:"ml-auto text-[10px] text-muted-foreground",children:z.length})]}),m&&null!==z&&(0,d.jsx)(T,{rootId:a.id,topics:z,pathname:Q})]}),(0,d.jsxs)("li",{children:[(0,d.jsxs)("button",{type:"button",onClick:X,className:"w-full flex items-center gap-1 px-2 py-1 rounded-md text-xs text-muted-foreground hover:bg-accent hover:text-foreground",children:[u?(0,d.jsx)(n.A,{className:"h-3 w-3 shrink-0"}):(0,d.jsx)(o.A,{className:"h-3 w-3 shrink-0"}),(0,d.jsx)(H.A,{className:"h-3 w-3 shrink-0"}),(0,d.jsx)("span",{className:"truncate",children:c("sidebar.agents")}),M&&(0,d.jsx)(r.A,{className:"ml-auto h-3 w-3 animate-spin shrink-0"}),null!==D&&!M&&(0,d.jsxs)("span",{className:"ml-auto text-[10px] text-muted-foreground",children:[D.filter(a=>O(a.status)).length,"/",D.length]})]}),u&&null!==D&&(0,d.jsx)(L,{agents:D,pathname:Q})]})]})]})}function L({agents:a,pathname:b}){if(0===a.length)return(0,d.jsx)(M,{});let c=new Map;for(let b of a){let a=b.parentId,d=c.get(a)??[];d.push(b),c.set(a,d)}let e=c.get(void 0)??[];return(0,d.jsx)("ul",{className:"ml-4 mt-0.5 space-y-0.5 border-l pl-1",children:e.map(a=>(0,d.jsx)(N,{agent:a,byParent:c,pathname:b,depth:0},a.id))})}function M(){let a=(0,j.c)("app");return(0,d.jsx)("div",{className:"ml-4 px-3 py-1 text-[11px] italic text-muted-foreground",children:a("sidebar.noAgents")})}function N({agent:a,byParent:b,pathname:c,depth:e}){let f=b.get(a.id)??[],h=`/agents/${a.id}`,i=c===h;return(0,d.jsxs)("li",{children:[(0,d.jsxs)(g(),{href:h,className:`flex items-center gap-1 px-2 py-1 text-[12px] rounded hover:bg-accent ${i?"bg-accent":""}`,style:{paddingLeft:8*e+4},children:[O(a.status)?(0,d.jsx)(I.A,{className:"h-3 w-3 text-emerald-600 shrink-0 animate-pulse"}):(0,d.jsx)(H.A,{className:"h-3 w-3 text-muted-foreground shrink-0"}),(0,d.jsx)("span",{className:"truncate flex-1",children:a.label}),(0,d.jsx)("span",{className:"font-mono text-[10px] text-muted-foreground shrink-0",title:`${a.harness} \xb7 ${a.model}`,children:"claude-code"===a.harness?"claude":"ollama"===a.harness?"ollama":"codex"})]}),f.length>0&&(0,d.jsx)("ul",{className:"space-y-0.5",children:f.map(a=>(0,d.jsx)(N,{agent:a,byParent:b,pathname:c,depth:e+1},a.id))})]})}function O(a){return"starting"===a||"running"===a}function P({rootId:a,sections:b,pathname:c}){return 0===b.length?(0,d.jsx)(Q,{}):(0,d.jsx)("ul",{className:"ml-4 mt-0.5 space-y-0.5 border-l pl-1",children:b.map(b=>b.isDir?(0,d.jsx)(R,{rootId:a,section:b,pathname:c},b.rel):(0,d.jsx)("li",{children:(0,d.jsx)(S,{rootId:a,section:b,pathname:c})},b.rel))})}function Q(){let a=(0,j.c)("app");return(0,d.jsx)("div",{className:"px-3 py-1 text-[11px] italic text-muted-foreground",children:a("sidebar.kbEmpty")})}function R({rootId:a,section:b,pathname:c}){let[f,g]=(0,e.useState)(!1);return(0,d.jsxs)("li",{children:[(0,d.jsxs)("div",{className:"flex items-center",children:[(0,d.jsx)("button",{type:"button",onClick:()=>g(a=>!a),className:"h-5 w-5 flex items-center justify-center text-muted-foreground hover:text-foreground shrink-0",children:f?(0,d.jsx)(n.A,{className:"h-3 w-3"}):(0,d.jsx)(o.A,{className:"h-3 w-3"})}),(0,d.jsx)(t.A,{className:"h-3 w-3 text-muted-foreground shrink-0 mr-1"}),(0,d.jsx)("span",{className:"text-[12px] flex-1 truncate",children:b.label})]}),f&&b.children&&(0,d.jsx)("ul",{className:"ml-4 space-y-0.5 border-l pl-1",children:b.children.map(b=>(0,d.jsx)("li",{children:(0,d.jsx)(S,{rootId:a,section:b,pathname:c})},b.rel))})]})}function S({rootId:a,section:b,pathname:c}){if(!b.fileRel)return null;let e=b.fileRel.split("/").map(encodeURIComponent).join("/"),f=`/roots/${a}/kb/${e}`,h=c===f;return(0,d.jsxs)(g(),{href:f,className:`flex items-center gap-1 px-2 py-1 text-[12px] rounded hover:bg-accent ${h?"bg-accent":""}`,children:[(0,d.jsx)(q.A,{className:"h-3 w-3 text-muted-foreground shrink-0"}),(0,d.jsx)("span",{className:"truncate",children:b.label})]})}function T({rootId:a,topics:b,pathname:c}){return 0===b.length?(0,d.jsx)(U,{}):(0,d.jsx)("ul",{className:"ml-4 mt-0.5 space-y-0.5 border-l pl-1",children:b.map(b=>(0,d.jsx)(V,{rootId:a,topic:b,pathname:c},b.id))})}function U(){let a=(0,j.c)("app");return(0,d.jsx)("div",{className:"ml-4 px-3 py-1 text-[11px] italic text-muted-foreground",children:a("sidebar.noTopics")})}function V({rootId:a,topic:b,pathname:c}){let f=(0,j.c)("app"),k=`/roots/${a}/chat/${b.id}`,l=c===k,[m,n]=(0,e.useTransition)(),o=(0,h.useRouter)();return(0,d.jsx)("li",{className:"group/topic",children:(0,d.jsxs)(g(),{href:k,className:`flex items-center gap-1 px-2 py-1 text-[12px] rounded hover:bg-accent ${l?"bg-accent":""}`,children:[(0,d.jsx)(s.A,{className:"h-3 w-3 text-muted-foreground shrink-0"}),(0,d.jsx)("span",{className:"truncate flex-1 min-w-0",children:b.title}),(0,d.jsx)("button",{type:"button",onClick:c=>{c.preventDefault(),c.stopPropagation(),confirm(f("sidebar.deleteTopicConfirm",{title:b.title}))&&n(async()=>{let c=await (0,v.L)(a,b.id);if(!c.ok)return void i.oR.error(c.error??f("sidebar.deleteFailed"));i.oR.success(f("sidebar.topicDeleted")),(0,w.$d)(w.Zi.topicsChanged(a)),l&&o.push(`/roots/${a}`)})},disabled:m,"aria-label":f("sidebar.deleteTopic"),title:f("sidebar.deleteTopic"),className:"opacity-0 group-hover/topic:opacity-100 transition-opacity p-0.5 rounded hover:bg-destructive/15 text-muted-foreground hover:text-destructive shrink-0",children:m?(0,d.jsx)(r.A,{className:"h-3 w-3 animate-spin"}):(0,d.jsx)(u.A,{className:"h-3 w-3"})})]})})}},5053:(a,b,c)=>{Promise.resolve().then(c.t.bind(c,53869,23)),Promise.resolve().then(c.t.bind(c,85684,23)),Promise.resolve().then(c.t.bind(c,89338,23)),Promise.resolve().then(c.t.bind(c,65597,23)),Promise.resolve().then(c.t.bind(c,41833,23)),Promise.resolve().then(c.t.bind(c,63921,23)),Promise.resolve().then(c.t.bind(c,25211,23)),Promise.resolve().then(c.t.bind(c,19908,23)),Promise.resolve().then(c.bind(c,49289))},5492:(a,b,c)=>{"use strict";c.d(b,{OY:()=>u,PF:()=>r,_9:()=>t,dL:()=>v,do:()=>w,eF:()=>p,hk:()=>o,o0:()=>s});var d=c(73024),e=c(76760),f=c.n(e),g=c(77598),h=c.n(g),i=c(87841),j=c.n(i),k=c(54287);function l(a){return f().join((0,k.FF)(a),"topics")}function m(a,b){return f().join(l(a),`${n(b)}.md`)}function n(a){return a.replace(/[^A-Za-z0-9_-]/g,"")}async function o(a){let b,c=l(a);try{b=await d.promises.readdir(c,{withFileTypes:!0})}catch{return[]}let e=[];for(let a of b){if(!a.isFile()||!a.name.toLowerCase().endsWith(".md"))continue;let b=f().join(c,a.name);try{let a=await d.promises.readFile(b,"utf8"),c=j()(a),f=c.data;if(!f.id||!f.createdAt)continue;let g=c.content.replace(/^##\s+(user|assistant)\s*$/gim,"").trim().slice(0,160);e.push({meta:{id:f.id,title:f.title??"Untitled",createdAt:f.createdAt,updatedAt:f.updatedAt??f.createdAt,harness:f.harness,model:f.model,language:f.language,...f.goal?{goal:f.goal}:{},...f.goalStatus?{goalStatus:f.goalStatus}:{},..."number"==typeof f.goalIterations?{goalIterations:f.goalIterations}:{}},preview:g,abs:b})}catch{}}return e.sort((a,b)=>Date.parse(b.meta.updatedAt)-Date.parse(a.meta.updatedAt)),e}async function p(a,b){let c,e=m(a,b);try{c=await d.promises.readFile(e,"utf8")}catch{return null}let f=j()(c),g=f.data;return g.id?{meta:{id:g.id,title:g.title??"Untitled",createdAt:g.createdAt??new Date().toISOString(),updatedAt:g.updatedAt??g.createdAt??new Date().toISOString(),harness:g.harness,model:g.model,language:g.language,...g.goal?{goal:g.goal}:{},...g.goalStatus?{goalStatus:g.goalStatus}:{},..."number"==typeof g.goalIterations?{goalIterations:g.goalIterations}:{}},messages:function(a){let b=[],c=a.split(/\r?\n/),d=null;for(let a of c){let c=/^##\s+(user|assistant)\s*$/i.exec(a);if(c){d&&b.push({...d,body:d.body.trimEnd()}),d={role:c[1].toLowerCase(),body:""};continue}d&&(d.body+=a+"\n")}return d&&b.push({...d,body:d.body.trimEnd()}),b}(f.content),abs:e}:null}async function q(a,b,c){let e=m(a,b),f=await d.promises.readFile(e,"utf8"),g=j()(f),h={...g.data,...c,updatedAt:new Date().toISOString()};for(let a of Object.keys(h))void 0===h[a]&&delete h[a];await d.promises.writeFile(e,j().stringify(g.content,h),"utf8")}async function r(a,b,c){await q(a,b,{goal:c,goalStatus:"active",goalIterations:0})}async function s(a,b){let c=m(a,b),e=await d.promises.readFile(c,"utf8"),f=j()(e).data,g=("number"==typeof f.goalIterations?f.goalIterations:0)+1;return await q(a,b,{goalIterations:g}),g}async function t(a,b,c="abandoned"){await q(a,b,{goalStatus:c})}async function u(a){let b=function(){let a=new Date().toISOString().slice(0,10),b=h().randomBytes(4).toString("hex");return`${a}-${b}`}(),c=new Date().toISOString(),e={id:b,title:function(a){let b=a.trim().split(/\r?\n/)[0]??"Untitled";return b.length>80?b.slice(0,77)+"…":b}(a.firstMessage),createdAt:c,updatedAt:c,...a.harness?{harness:a.harness}:{},...a.model?{model:a.model}:{},...a.language?{language:a.language}:{},...a.helperFor?{helperFor:a.helperFor}:{}};return await d.promises.mkdir(l(a.root),{recursive:!0}),await d.promises.writeFile(m(a.root,b),y(e,""),"utf8"),{meta:e,messages:[],abs:m(a.root,b)}}async function v(a,b,c){let e=await p(a,b);if(!e)throw Error(`Topic not found: ${b}`);e.meta.title=c,e.meta.updatedAt=new Date().toISOString();let f=e.messages.map(a=>`## ${a.role}
|
|
33
|
+
${a.body}`).join("\n\n")+"\n";await d.promises.writeFile(m(a,b),y(e.meta,f),"utf8")}async function w(a,b){let c=n(b);if(!c)throw Error(`Invalid topic id: ${b}`);let d=m(a,c),e=f().join(l(a),`${c}.events.jsonl`);return{removedMd:await x(d),removedEvents:await x(e)}}async function x(a){try{return await d.promises.unlink(a),!0}catch(a){if("object"==typeof a&&null!==a&&"code"in a&&"ENOENT"===a.code)return!1;throw a}}function y(a,b){return j().stringify(b,a)}},6240:(a,b,c)=>{Promise.resolve().then(c.bind(c,30849)),Promise.resolve().then(c.bind(c,95422)),Promise.resolve().then(c.bind(c,11935))},8118:(a,b,c)=>{"use strict";c.d(b,{Od:()=>m,gd:()=>s,getUtility:()=>r,jc:()=>u,listUtilities:()=>n});var d=c(73024),e=c(76760),f=c.n(e),g=c(53905),h=c(73652),i=c(54287),j=c(20050);let k=f().join((0,h._)(),"utilities");function l(a){return f().join((0,i.FF)(a),"utilities")}function m(a,b,c){if("global"===a)return f().join(k,b);if(!c)throw Error("project-scoped utility requires rootPath");return f().join(l(c),b)}async function n(a={}){let b=[];if(a.scope&&"global"!==a.scope||b.push(...await o("global",k)),!a.scope||"project"===a.scope)for(let c of a.rootId?await (0,g.Zn)(a.rootId).then(a=>a?[a]:[]).catch(()=>[]):await (0,g.qV)().catch(()=>[])){let a=l(c.path);b.push(...(await o("project",a,c.id)).map(a=>({...a,rootId:c.id})))}return b}async function o(a,b,c){let e;try{e=await d.promises.readdir(b,{withFileTypes:!0})}catch{return[]}let g=[];for(let d of e){if(!d.isDirectory())continue;let e=f().join(b,d.name),h=await p(e);h&&g.push({scope:a,...c?{rootId:c}:{},dir:e,manifest:h,bundleAvailable:await q(f().join(e,"bundle.js"))})}return g}async function p(a){try{let b=await d.promises.readFile(f().join(a,"manifest.json"),"utf8"),c=j.pL.safeParse(JSON.parse(b));return c.success?c.data:null}catch{return null}}async function q(a){try{return await d.promises.access(a),!0}catch{return!1}}async function r(a,b,c){let d,e;if("global"===a)d=k;else{if(!c)return null;let a=await (0,g.Zn)(c).catch(()=>null);if(!a)return null;d=l(a.path),e=a.id}let h=f().join(d,b),i=await p(h);return i?{scope:a,...e?{rootId:e}:{},dir:h,manifest:i,bundleAvailable:await q(f().join(h,"bundle.js"))}:null}async function s(a){let b;if(a.manifest.id!==a.manifest.id.toLowerCase())throw Error("manifest.id must be lowercase kebab-case");if("project"===a.scope){if(!a.rootId)throw Error("project-scoped install requires rootId");let c=await (0,g.Zn)(a.rootId);if(!c)throw Error(`unknown rootId: ${a.rootId}`);b=c.path}let c=m(a.scope,a.manifest.id,b);for(let[e,g]of(await d.promises.mkdir(c,{recursive:!0}),await d.promises.mkdir(f().join(c,"data"),{recursive:!0}),Object.entries(a.files))){if("manifest.json"===e)continue;let c=function(a,b,c,d){let e=m(a,b,d),g=f().resolve(e,c),h=f().relative(e,g);if(h.startsWith("..")||f().isAbsolute(h))throw Error(`refused path outside utility dir: ${c}`);return g}(a.scope,a.manifest.id,e,b);await d.promises.mkdir(f().dirname(c),{recursive:!0}),await d.promises.writeFile(c,g,"utf8")}let e={...a.manifest,source:a.source};if(await d.promises.writeFile(f().join(c,"manifest.json"),JSON.stringify(e,null,2)+"\n","utf8"),"project"===a.scope&&a.rootId&&b&&e.card)try{await t(b,a.scope,e)}catch(a){console.error("[utility install] card seed failed:",a)}return{scope:a.scope,...a.rootId?{rootId:a.rootId}:{},dir:c,manifest:e,bundleAvailable:!1}}async function t(a,b,d){if(!d.card)return;let{buildRecord:e,readLayout:f,reconcileLayout:g,writeLayout:h,writeWidget:i,listWidgets:j}=await Promise.resolve().then(c.bind(c,69509)),{SYSTEM_WIDGET_IDS:k}=await Promise.resolve().then(c.bind(c,1405)),l=`utility:${d.id}`,m=e({id:l,title:d.card.title??d.name,...d.card.description?{description:d.card.description}:{},payload:{kind:"utility-card",data:{utilityId:d.id,utilityScope:b,inner:{kind:d.card.kind,data:d.card.data,...d.card.title?{title:d.card.title}:{},...d.card.description?{description:d.card.description}:{}}}}});await i(a,m);let n=await f(a);n.order.includes(l)||n.hidden.includes(l)||(n.hidden=[...n.hidden,l]);let o=g(n,(await j(a)).map(a=>a.id),k);await h(a,o)}async function u(a,b,c){let e;if("project"===a){if(!c)throw Error("project-scoped remove requires rootId");let a=await (0,g.Zn)(c);if(!a)return;e=a.path}let f=m(a,b,e);await d.promises.rm(f,{recursive:!0,force:!0})}},13415:(a,b,c)=>{"use strict";c.a(a,async(a,d)=>{try{c.d(b,{L4:()=>r,OQ:()=>s,T$:()=>t,g3:()=>o,h$:()=>q,nC:()=>u,nY:()=>p});var e=c(73745);c(66493);var f=c(65326),g=c(53905),h=c(5492),i=c(36017),j=c(99353),k=c(51021),l=c(93554),m=c(63781),n=a([j,k,l]);async function o(a,b,c=[],d){try{let e=await (0,g.Zn)(a);if(!e)return{ok:!1,error:"Root not found"};if(!b.trim()&&0===c.length)return{ok:!1,error:"Empty prompt"};let j=await (0,i.M)(),l=j.assignments.chat,m=b.trim()||c[0]?.name||"Untitled",n=await (0,h.OY)({root:e.path,firstMessage:m,harness:l.harness,model:l.model,language:j.language}),o=await (0,k.W)({rootId:a,topicId:n.meta.id,message:b.trim(),attachments:c,...d?{focusFile:d}:{}});if("error"in o)return{ok:!1,error:o.error};return(0,f.revalidatePath)(`/roots/${a}`),{ok:!0,topicId:n.meta.id}}catch(a){return{ok:!1,error:a instanceof Error?a.message:String(a)}}}async function p(a){try{let b=await (0,g.Zn)(a);if(!b)return{ok:!1,error:"Root not found"};let c=(await (0,h.hk)(b.path)).filter(a=>!a.meta.helperFor);return{ok:!0,topics:c}}catch(a){return{ok:!1,error:a instanceof Error?a.message:String(a)}}}async function q(a,b,c){try{let d,e=await (0,g.Zn)(a);if(!e)return{ok:!1,error:"Root not found"};let k=await (0,i.M)(),l=k.assignments.quick,m=k.language,n=["Write a short, descriptive title for the following user question.",`Language: ${m}.`,"Constraints:\n - 3 to 7 words\n - no quotes, no trailing punctuation",` - no leading prefixes like "Title:" — just the title text`,"\nUser question:",c].join("\n"),o=(d=(d=(d=(d=(await (0,j.T)(l,n,{timeoutMs:25e3})).trim()).replace(/^```[a-z]*\s*([\s\S]*?)\s*```$/i,"$1")).replace(/^['"«»“”‘’`]+|['"«»“”‘’`]+$/g,"")).replace(/^\s*title\s*:\s*/i,""),(d=(d=d.split(/\r?\n/)[0]?.trim()??"").replace(/[.!?…]+$/u,"").trim()).length>80&&(d=d.slice(0,77).trimEnd()+"…"),d);if(!o)return{ok:!1,error:"Empty title from model"};return await (0,h.dL)(e.path,b,o),(0,f.revalidatePath)(`/roots/${a}`),(0,f.revalidatePath)(`/roots/${a}/chat/${b}`),{ok:!0,title:o}}catch(a){return{ok:!1,error:a instanceof Error?a.message:String(a)}}}async function r(a,b){try{let c=await (0,g.Zn)(a);if(!c)return{ok:!1,error:"Root not found"};return await l.z.stopTopic(b),await (0,h.do)(c.path,b),(0,f.revalidatePath)(`/roots/${a}`),{ok:!0}}catch(a){return{ok:!1,error:a instanceof Error?a.message:String(a)}}}async function s(a,b){try{let c=await (0,g.Zn)(a);if(!c)return{ok:!1,error:"Root not found"};return await (0,h._9)(c.path,b,"abandoned"),(0,f.revalidatePath)(`/roots/${a}/chat/${b}`),{ok:!0}}catch(a){return{ok:!1,error:a instanceof Error?a.message:String(a)}}}async function t(a,b){try{let d=await (0,g.Zn)(a);if(!d)return{ok:!1,error:"Root not found"};let{readEvents:e}=await Promise.resolve().then(c.bind(c,20243)),f=await e(d.path,b),h=[],i=null,j=()=>{i&&i.text.trim()&&h.push({role:"assistant",text:(function(a){let b=a;for(let a of["permission","question","kb","utility","dispatch","mcp-add","youtube-summary","widget-create","widget-update","workflow-create","image-gen"])b=b.replace(RegExp(`<{1,2}reflex:${a}>{1,2}[\\s\\S]*?<{1,2}\\/reflex:${a}>{1,2}`,"g"),"");return b})(i.text).trim(),ts:i.ts}),i=null};for(let a of f)"user-message"===a.type?(j(),"string"==typeof a.text&&a.text.trim()&&!a.text.startsWith("[Helper \xb7")&&h.push({role:"user",text:a.text,ts:a.ts})):"assistant-delta"===a.type?(i||(i={text:"",ts:a.ts}),i.text+=a.text):("turn-end"===a.type||"agent-end"===a.type)&&j();return j(),{ok:!0,messages:h}}catch(a){return{ok:!1,error:a instanceof Error?a.message:String(a)}}}async function u(a){try{let b=await (0,g.Zn)(a.rootId);if(!b)return{ok:!1,error:"Root not found"};let c=(await (0,h.hk)(b.path)).find(b=>b.meta.helperFor===a.utilityId);if(c)return{ok:!0,topicId:c.meta.id,created:!1};let d=await (0,i.M)(),e=d.assignments.chat,f=await (0,h.OY)({root:b.path,firstMessage:`[Helper \xb7 ${a.utilityName}]`,harness:e.harness,model:e.model,language:d.language,helperFor:a.utilityId});return{ok:!0,topicId:f.meta.id,created:!0}}catch(a){return{ok:!1,error:a instanceof Error?a.message:String(a)}}}[j,k,l]=n.then?(await n)():n,(0,m.D)([o,p,q,r,s,t,u]),(0,e.A)(o,"78a981760a75d8854ed82bf304ee5f360f02dc821e",null),(0,e.A)(p,"402cbf99c1fdf13210ea998c2af08f3adac7def6e9",null),(0,e.A)(q,"705c9b38be5e6407b9daf47274b59aa3259557510f",null),(0,e.A)(r,"607c26b40d69de467a6ec39b6800629c4e799ba4f4",null),(0,e.A)(s,"60b36387ec7b85e9989ded5e614bd25800977fa466",null),(0,e.A)(t,"60918e20214ae50680d72925bbdd8d83bb4b34f9f8",null),(0,e.A)(u,"40d6562417a30bc8cc42766d13e723b96019d2033e",null),d()}catch(a){d(a)}})},15754:(a,b,c)=>{"use strict";c.a(a,async(a,d)=>{try{c.d(b,{$z:()=>l,MU:()=>m,Tc:()=>k});var e=c(73745);c(66493);var f=c(53905),g=c(20243),h=c(93554),i=c(63781),j=a([h]);async function k(a,b){try{let c=await (0,f.Zn)(a);if(!c)return{ok:!1,error:"Root not found"};let d=await (0,g.readEvents)(c.path,b);return{ok:!0,events:d,active:h.z.isActive(b)}}catch(a){return{ok:!1,error:a instanceof Error?a.message:String(a)}}}async function l(a){try{return{ok:!0,agents:h.z.list(a)}}catch(a){return{ok:!1,error:a instanceof Error?a.message:String(a)}}}async function m(a){try{let b=h.z.get(a);if(!b)return{ok:!1,error:"Agent not found"};return{ok:!0,agent:b}}catch(a){return{ok:!1,error:a instanceof Error?a.message:String(a)}}}h=(j.then?(await j)():j)[0],(0,i.D)([k,l,m]),(0,e.A)(k,"603e96fd25840980577a2e951a8d9cf475e93cddb4",null),(0,e.A)(l,"403e063aecb7113e309df608c40aaed12362c7ba48",null),(0,e.A)(m,"40a717854d3a91ffa395ba4148dd30b4684c210dfd",null),d()}catch(a){d(a)}})},17640:(a,b,c)=>{"use strict";c.d(b,{M:()=>o,D:()=>p});var d=c(73024),e=c(76760),f=c.n(e),g=c(14126);let h=g.Ik({"claude-code":g.Ik({enabled:g.zM().default(!0)}),codex:g.Ik({enabled:g.zM().default(!0)}),ollama:g.Ik({enabled:g.zM().default(!0),baseUrl:g.Yj().url().default("http://localhost:11434")})}),i=g.Ik({harness:g.k5(["claude-code","codex","ollama"]),model:g.Yj().min(1),allowedTools:g.YO(g.Yj()).default([])}),j=g.Ik({enabled:g.zM().default(!0),maxDimension:g.ai().int().min(256).max(8192).default(2e3),quality:g.ai().int().min(40).max(100).default(85),format:g.k5(["auto","jpeg","webp","original"]).default("auto")}),k=g.Ik({version:g.eu(1).default(1),language:g.Yj().min(1).default("en"),onboardedAt:g.Yj().optional(),userName:g.Yj().default(""),timezone:g.Yj().default(""),uiMode:g.k5(["simple","advanced"]).default("simple"),imageProcessing:j.default({enabled:!0,maxDimension:2e3,quality:85,format:"auto"}),harnesses:h.default({"claude-code":{enabled:!0},codex:{enabled:!0},ollama:{enabled:!0,baseUrl:"http://localhost:11434"}}),assignments:g.Ik({analyze:i,chat:i,rag:i,embed:i,quick:i}).default({analyze:{harness:"claude-code",model:"claude-opus-4-7",allowedTools:["Read","Write","Edit","LS","Glob","Grep","WebSearch","WebFetch"]},chat:{harness:"claude-code",model:"claude-sonnet-4-6",allowedTools:["Read","LS","Glob","Grep","WebSearch","WebFetch"]},rag:{harness:"ollama",model:"llama3.1:8b",allowedTools:[]},embed:{harness:"ollama",model:"nomic-embed-text",allowedTools:[]},quick:{harness:"claude-code",model:"claude-haiku-4-5",allowedTools:[]}}),mapServices:g.Ik({enabled:g.YO(g.Yj()).default(["google","yandex","apple","osm"])}).default({enabled:["google","yandex","apple","osm"]}),ngrok:g.Ik({authtoken:g.Yj().default(""),apiKey:g.Yj().default(""),domain:g.Yj().default(""),port:g.ai().int().min(1).max(65535).default(3210)}).default({authtoken:"",apiKey:"",domain:"",port:3210})}),l=k.parse({}),m=(0,c(29163)._)(),n=f().join(m,"settings.json");async function o(){try{let a=await d.promises.readFile(n,"utf8"),b=k.safeParse(JSON.parse(a));if(!b.success)return l;return b.data}catch(b){var a;if("object"==typeof(a=b)&&null!==a&&"code"in a&&"ENOENT"===a.code)return l;throw b}}async function p(a){let b=k.parse(a);await d.promises.mkdir(m,{recursive:!0}),await d.promises.writeFile(n,JSON.stringify(b,null,2)+"\n","utf8")}},18809:(a,b,c)=>{"use strict";c.d(b,{Aq:()=>i,pO:()=>h});let d=["Read","Glob","Grep","WebFetch","WebSearch"],e=[...d,"Write","Edit","MultiEdit"];function f(a,b,c){return[`## Specialist role: ${a}`,"",`Reply in ${b}. You are a focused specialist, not a general assistant. Do exactly the task in the brief — no more.`,"\n## Brief from the orchestrator",c.trim(),""].join("\n")}function g(a){return["\n## Rules",a,"\n- Don't ask clarifying questions to the user — you don't have a chat surface. If the brief is ambiguous, do your best with stated assumptions and note them in your output.\n- Don't emit `<<reflex:kb>>`, `<<reflex:utility>>`, `<<reflex:permission>>`, `<<reflex:question>>`, `<<reflex:dispatch>>` markers — those are for the orchestrator only. Just write your answer as plain text/markdown.\n- End with a tight summary the orchestrator can quote verbatim if the user asks for the result."].join("\n")}let h={researcher:{id:"researcher",label:"Researcher",description:"Deep KB reading / project search / web research. Read-only — never writes files. Use when you need to find or gather facts.",allowedTools:d,systemPrompt:({language:a,root:b,reflexScope:c,brief:d})=>[f("researcher",a,d),`Project root: \`${b}\``,`Knowledge base scope: \`${c}\``,g("- You are READ-ONLY: never Write/Edit/MultiEdit. Use Read/Glob/Grep to scan the KB and WebFetch/WebSearch for external lookups.\n- Cite sources by rel-path inside the KB (or URL for web).\n- If the brief asks for something that requires a write, explicitly say `cannot complete — write required` instead of doing it.")].join("\n")},coder:{id:"coder",label:"Coder",description:"Writes/edits source code, configs, schemas. Can create a utility. Use when file changes are required.",allowedTools:e,systemPrompt:({language:a,root:b,reflexScope:c,brief:d})=>[f("coder",a,d),`Project root: \`${b}\``,`Reflex scope (write here for KB files): \`${c}\``,g("- You may Write/Edit/MultiEdit files. Stay inside the project root.\n- Don't run shell or invoke other agents. If the brief implies installing a utility, write the utility files but do NOT emit `<<reflex:utility>>` — that's the orchestrator's job.\n- Report what you changed: list each touched file with a one-line summary.")].join("\n")},summarizer:{id:"summarizer",label:"Summarizer",description:"Compresses a large text / long transcript / file list into a short summary. No tools — only the text in the brief.",allowedTools:[],systemPrompt:({language:a,brief:b})=>[f("summarizer",a,b),g("- You have NO tools — work only from the text in the brief.\n- Compress aggressively: bullet points, ~10x reduction is the target unless the brief says otherwise.\n- Preserve names, numbers, dates, file paths verbatim. Drop filler.")].join("\n")},"kb-writer":{id:"kb-writer",label:"KB Writer",description:"Structured knowledge-base entry (kind/title/body/frontmatter). Use when the orchestrator decides to save something.",allowedTools:d,systemPrompt:({language:a,root:b,reflexScope:c,brief:d})=>[f("kb-writer",a,d),`KB root: \`${c}\``,`Project: \`${b}\``,g('- You DO NOT write the file yourself. Output a JSON object the orchestrator will pass to <<reflex:kb>>:\n ```json\n {"kind":"<entity-type>","title":"…","body":"…markdown…","meta":{…optional frontmatter fields…}}\n ```\n- Pick a sensible `kind` (fact / task / meeting / product / decision / source / …).\n- `body` is full markdown. Frontmatter `meta` should hold structured fields the user might filter/group on.')].join("\n")},"utility-builder":{id:"utility-builder",label:"Utility Builder",description:"Design a utility: manifest + ui.tsx + (optional) server actions. Use when the user explicitly asks to create a utility.",allowedTools:d,systemPrompt:({language:a,root:b,brief:c})=>[f("utility-builder",a,c),`Project: \`${b}\``,g("- Output the utility files inline in markdown code fences with file paths as headers:\n ### manifest.json\n ```json\n { … }\n ```\n ### ui.tsx\n ```tsx\n … React functional component, default-export …\n ```\n- Follow Reflex utility contract: imports only from `react`, `react-dom/client`, `react/jsx-runtime`, `@host/api`, `@host/ui`. Declare needed permissions and secrets in manifest.\n- Don't emit `<<reflex:utility>>` yourself — the orchestrator wraps your output and emits the marker.")].join("\n")}};function i(a){return a in h}},19319:(a,b,c)=>{"use strict";c.d(b,{IK:()=>l,dj:()=>k});var d=c(73024),e=c(76760),f=c.n(e),g=c(87841),h=c.n(g),i=c(54287);async function j(a){let b=(0,i.FF)(a);return m(b,b)}async function k(a){let b=await j(a);return await Promise.all(b.map(async a=>({...a,meta:await n(a.abs)})))}async function l(a,b){let c=(0,i.FF)(a),e=f().resolve(c,b),g=f().relative(c,e);if(g.startsWith("..")||f().isAbsolute(g))throw Error(`Refused to read outside ${i.fW}: ${b}`);return d.promises.readFile(e,"utf8")}async function m(a,b){let c;try{c=await d.promises.readdir(b,{withFileTypes:!0})}catch{return[]}let e=[],g=[];for(let d of c){let c=f().join(b,d.name);if(d.isDirectory()){if(b===a&&"topics"===d.name)continue;e.push(m(a,c));continue}d.isFile()&&d.name.toLowerCase().endsWith(".md")&&g.push({rel:f().relative(a,c).split(f().sep).join("/"),abs:c,size:0,modifiedAt:""})}let h=await Promise.all(g.map(async a=>{try{let b=await d.promises.stat(a.abs);return{...a,size:b.size,modifiedAt:b.mtime.toISOString()}}catch{return a}}));for(let a of(await Promise.all(e)))h.push(...a);return h.sort((a,b)=>a.rel.localeCompare(b.rel)),h}async function n(a){try{let b=await d.promises.readFile(a,"utf8"),c=h()(b).data;return{...void 0!==o(c.title)?{title:o(c.title)}:{},...void 0!==p(c.version)?{version:p(c.version)}:{},...void 0!==o(c.date)?{date:o(c.date)}:{},...void 0!==o(c.kind)?{kind:o(c.kind)}:{},data:c}}catch{return{data:{}}}}function o(a){return"string"==typeof a?a:a instanceof Date?a.toISOString().slice(0,10):void 0}function p(a){if("string"==typeof a||"number"==typeof a)return a}},20050:(a,b,c)=>{"use strict";c.d(b,{pL:()=>j});var d=c(56149);let e=d.Yj().min(1).max(80).regex(/^[a-z][a-z0-9]*(-[a-z0-9]+)*$/,"id must be kebab-case (e.g. furniture-gen)"),f=d.Ik({llm:d.Ik({tasks:d.YO(d.k5(["chat","quick","rag","embed"])).default([])}).optional(),kb:d.Ik({read:d.zM().optional(),write:d.zM().optional(),kinds:d.YO(d.Yj()).optional()}).optional(),fs:d.Ik({sandbox:d.eu(!0)}).optional(),web:d.Ik({fetch:d.Ik({domains:d.YO(d.Yj()).default([])}).optional(),search:d.zM().optional()}).optional(),audit:d.Ik({write:d.eu(!0).optional()}).optional(),workers:d.Ik({enabled:d.eu(!0),maxConcurrent:d.ai().int().min(1).max(8).default(1).optional()}).optional(),agent:d.Ik({invoke:d.eu(!0)}).optional(),workflow:d.Ik({read:d.zM().optional(),run:d.zM().optional()}).optional(),images:d.Ik({generate:d.zM().optional(),search:d.zM().optional(),attach:d.zM().optional()}).optional()}).default({}),g=d.Ik({key:d.Yj().min(1).max(64).regex(/^[A-Z][A-Z0-9_]*$/,"secret key must be UPPER_SNAKE_CASE (e.g. OPENAI_API_KEY)"),label:d.Yj().min(1).max(120),description:d.Yj().max(2e3).default(""),required:d.zM().default(!1)}),h=d.Ik({name:d.Yj().min(1).max(64).regex(/^[a-zA-Z_][a-zA-Z0-9_]*$/,"action name must be a JS identifier"),entry:d.Yj().min(1).regex(/^[A-Za-z0-9_\-./]+\.ts$/,"entry must be a relative .ts path"),timeoutMs:d.ai().int().min(1e3).max(6e5).default(3e4)}),i=d.Ik({type:d.k5(["agent","github","archive","mcp","builtin"]),origin:d.Yj().optional(),fetchedAt:d.Yj(),installedBy:d.Yj().optional()}),j=d.Ik({id:e,name:d.Yj().min(1).max(120),description:d.Yj().max(2e3).default(""),version:d.Yj().regex(/^\d+\.\d+\.\d+(?:[-+][\w.]+)?$/,"version must be semver"),author:d.Yj().max(120).optional(),homepage:d.Yj().url().optional(),icon:d.Yj().max(64e3).regex(/^(?:lucide:[A-Za-z0-9_-]+|data:image\/(?:png|svg\+xml|jpeg);base64,[A-Za-z0-9+/=]+)$/,"icon must be 'lucide:Name' or a base64 data URL").optional(),category:d.Yj().max(64).optional(),ui:d.Yj().min(1).max(120).default("ui.tsx"),serverActions:d.YO(h).default([]),secrets:d.YO(g).default([]),mcpServers:d.YO(d.Yj().min(1).max(64)).default([]),permissions:f,source:i.optional(),card:d.Ik({kind:d.k5(["markdown","news-list","link-list","kpi","checklist","quote","kb-pinned","progress","image","stat-table","map"]),title:d.Yj().min(1).max(120).optional(),description:d.Yj().max(280).optional(),data:d.g1(d.Yj(),d.L5()).default({})}).optional()}),k=d.g1(d.Yj(),d.Yj()).superRefine((a,b)=>{for(let c of(!("manifest.json"in a||a["manifest.json"]),Object.keys(a)))(c.startsWith("/")||c.includes(".."))&&b.addIssue({code:"custom",message:`Unsafe file path: ${c}`})});d.Ik({scope:d.k5(["global","project"]),rootId:d.Yj().optional(),manifest:j,files:k,source:i})},20243:(a,b,c)=>{"use strict";c.d(b,{Zn:()=>i,readEvents:()=>j,v:()=>k});var d=c(73024),e=c(76760),f=c.n(e),g=c(54287);function h(a,b){return f().join((0,g.FF)(a),"topics",`${b}.events.jsonl`)}async function i(a,b,c){let e=h(a,b);await d.promises.mkdir(f().dirname(e),{recursive:!0}),await d.promises.appendFile(e,JSON.stringify(c)+"\n","utf8")}async function j(a,b){let c,e=h(a,b);try{c=await d.promises.readFile(e,"utf8")}catch(a){var f;if("object"==typeof(f=a)&&null!==f&&"code"in f&&"ENOENT"===f.code)return[];throw a}let g=[];for(let a of c.split(/\r?\n/))if(a.trim())try{g.push(JSON.parse(a))}catch{}return g}async function k(a,b){let c=await j(a,b);return 0===c.length?0:c[c.length-1].seq+1}},20583:(a,b,c)=>{"use strict";c.d(b,{$:()=>i});var d=c(64173);c(17240);var e=c(20483),f=c(91520),g=c(91344);let h=(0,e.F)("inline-flex shrink-0 items-center justify-center gap-2 rounded-md text-sm font-medium whitespace-nowrap transition-all outline-none focus-visible:border-ring focus-visible:ring-[3px] focus-visible:ring-ring/50 disabled:pointer-events-none disabled:opacity-50 aria-invalid:border-destructive aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4",{variants:{variant:{default:"bg-primary text-primary-foreground hover:bg-primary/90",destructive:"bg-destructive text-white hover:bg-destructive/90 focus-visible:ring-destructive/20 dark:bg-destructive/60 dark:focus-visible:ring-destructive/40",outline:"border bg-background shadow-xs hover:bg-accent hover:text-accent-foreground dark:border-input dark:bg-input/30 dark:hover:bg-input/50",secondary:"bg-secondary text-secondary-foreground hover:bg-secondary/80",ghost:"hover:bg-accent hover:text-accent-foreground dark:hover:bg-accent/50",link:"text-primary underline-offset-4 hover:underline"},size:{default:"h-9 px-4 py-2 has-[>svg]:px-3",xs:"h-6 gap-1 rounded-md px-2 text-xs has-[>svg]:px-1.5 [&_svg:not([class*='size-'])]:size-3",sm:"h-8 gap-1.5 rounded-md px-3 has-[>svg]:px-2.5",lg:"h-10 rounded-md px-6 has-[>svg]:px-4",icon:"size-9","icon-xs":"size-6 rounded-md [&_svg:not([class*='size-'])]:size-3","icon-sm":"size-8","icon-lg":"size-10"}},defaultVariants:{variant:"default",size:"default"}});function i({className:a,variant:b="default",size:c="default",asChild:e=!1,...i}){let j=e?f.bL:"button";return(0,d.jsx)(j,{"data-slot":"button","data-variant":b,"data-size":c,className:(0,g.cn)(h({variant:b,size:c,className:a})),...i})}},20938:(a,b,c)=>{"use strict";c.d(b,{GC:()=>l,az:()=>m});var d=c(73024),e=c(76760),f=c.n(e),g=c(73652);let h=f().join((0,g._)(),"pending-mcp-adds.json");async function i(){try{let a=await d.promises.readFile(h,"utf8"),b=JSON.parse(a);if(1!==b.version||!Array.isArray(b.entries))return{version:1,entries:[]};return b}catch{return{version:1,entries:[]}}}async function j(a){await d.promises.mkdir(f().dirname(h),{recursive:!0}),await d.promises.writeFile(h,JSON.stringify(a,null,2)+"\n",{encoding:"utf8",mode:384});try{await d.promises.chmod(h,384)}catch{}}function k(a){let b=Date.now()-2592e6;return{version:1,entries:a.entries.filter(a=>{let c=Date.parse(a.createdAt);return Number.isFinite(c)&&c>b})}}async function l(a){let b=k(await i());b.entries=b.entries.filter(b=>b.requestId!==a.requestId),b.entries.push({...a,createdAt:new Date().toISOString()}),await j(b)}async function m(a){let b=k(await i()),c=b.entries.findIndex(b=>b.requestId===a);if(c<0)return null;let d=b.entries[c];return b.entries.splice(c,1),await j(b),d}},27456:(a,b,c)=>{"use strict";c.d(b,{F:()=>g});var d=c(64173);c(17240);var e=c(6912),f=c(91344);function g({className:a,children:b,...c}){return(0,d.jsxs)(e.Root,{"data-slot":"scroll-area",className:(0,f.cn)("relative",a),...c,children:[(0,d.jsx)(e.Viewport,{"data-slot":"scroll-area-viewport",className:"size-full rounded-[inherit] transition-[color,box-shadow] outline-none focus-visible:ring-[3px] focus-visible:ring-ring/50 focus-visible:outline-1",children:b}),(0,d.jsx)(h,{}),(0,d.jsx)(e.Corner,{})]})}function h({className:a,orientation:b="vertical",...c}){return(0,d.jsx)(e.ScrollAreaScrollbar,{"data-slot":"scroll-area-scrollbar",orientation:b,className:(0,f.cn)("flex touch-none p-px transition-colors select-none","vertical"===b&&"h-full w-2.5 border-l border-l-transparent","horizontal"===b&&"h-2.5 flex-col border-t border-t-transparent",a),...c,children:(0,d.jsx)(e.ScrollAreaThumb,{"data-slot":"scroll-area-thumb",className:"relative flex-1 rounded-full bg-border"})})}},28548:(a,b,c)=>{"use strict";c.d(b,{AI:()=>m,PM:()=>l,Qs:()=>o,Y7:()=>k,iP:()=>n});var d=c(73024),e=c(76760),f=c.n(e),g=c(73652),h=c(61495);let i=f().join((0,g._)(),"prompts");function j(a){return f().join(i,`${a}.md`)}function k(a){return j(a)}async function l(a){let b=j(a);try{return await d.promises.readFile(b,"utf8")}catch(a){var c;if(!("object"==typeof(c=a)&&null!==c&&"code"in c&&"ENOENT"===c.code))throw a}return await d.promises.mkdir(i,{recursive:!0}),await d.promises.writeFile(b,h.EE[a],"utf8"),h.EE[a]}async function m(a,b){await d.promises.mkdir(i,{recursive:!0}),await d.promises.writeFile(j(a),b,"utf8")}async function n(a){return await m(a,h.EE[a]),h.EE[a]}function o(a){if(!h._W.includes(a))throw Error(`Unknown template: ${a}`);return a}},30516:(a,b,c)=>{"use strict";c.d(b,{P:()=>l});var d=c(56149);let e=d.Ik({template:d.Yj().default("")}),f=d.Ik({url:d.Yj().url("url must be a valid URL"),method:d.k5(["GET","POST","PUT","PATCH","DELETE"]).default("GET"),headers:d.KC([d.g1(d.Yj(),d.Yj()),d.Yj(),d.Vx()]).optional(),body:d.KC([d.Yj(),d.g1(d.Yj(),d.L5()),d.Vx()]).optional()}),g=d.Ik({url:d.Yj().url("url must be a valid URL")}),h=d.Ik({prompt:d.Yj().min(1,"prompt is required")}),i=d.Ik({kind:d.Yj().min(1).default("note"),title:d.Yj().default(""),body:d.Yj().default("")}),j=d.Ik({utilityId:d.Yj().min(1,"utilityId is required"),utilityScope:d.k5(["global","project"]).default("global"),actionName:d.Yj().min(1,"actionName is required"),args:d.L5().optional()}),k={"text-template":e,"http-request":f,"web-fetch":g,"ask-agent":h,"kb-write":i,"utility-call":j,"image-generate":d.Ik({prompt:d.Yj().min(1,"prompt is required"),provider:d.k5(["gemini","codex"]).optional(),size:d.Yj().optional(),aspectRatio:d.Yj().optional()}),"image-search":d.Ik({query:d.Yj().min(1,"query is required"),provider:d.k5(["unsplash","pexels","brave"]).optional(),count:d.KC([d.Yj(),d.ai()]).optional()})};function l(a,b){let c=k[a];return c?c.parse(b):b}},30849:(a,b,c)=>{"use strict";c.d(b,{AppSidebar:()=>d});let d=(0,c(54491).registerClientReference)(function(){throw Error("Attempted to call AppSidebar() from the server but AppSidebar is on the client. It's not possible to invoke a client function from the server, it can only be rendered as a Component or passed to props of a Client Component.")},"/home/runner/work/reflex-agent/reflex-agent/app/_components/app-sidebar.tsx","AppSidebar")},35616:(a,b,c)=>{Promise.resolve().then(c.bind(c,4868)),Promise.resolve().then(c.bind(c,99668)),Promise.resolve().then(c.bind(c,54225))},36017:(a,b,c)=>{"use strict";c.d(b,{D:()=>k,M:()=>j});var d=c(73024),e=c(76760),f=c.n(e),g=c(78555);let h=(0,c(73652)._)(),i=f().join(h,"settings.json");async function j(){try{let a=await d.promises.readFile(i,"utf8"),b=g.ht.safeParse(JSON.parse(a));if(!b.success)return g.a$;return b.data}catch(b){var a;if("object"==typeof(a=b)&&null!==a&&"code"in a&&"ENOENT"===a.code)return g.a$;throw b}}async function k(a){let b=g.ht.parse(a);await d.promises.mkdir(h,{recursive:!0}),await d.promises.writeFile(i,JSON.stringify(b,null,2)+"\n","utf8")}},36724:(a,b,c)=>{"use strict";c.a(a,async(a,d)=>{try{c.d(b,{L:()=>j});var e=c(56942),f=c(3724),g=a([f]);f=(g.then?(await g)():g)[0];let j={"text-template":async a=>"string"==typeof a.template?a.template:"","http-request":async a=>{let b=h(a.url,"url"),c=i(a.method,"GET").toUpperCase(),d=function(a,b){if("string"!=typeof a||!a.trim())return b;try{return JSON.parse(a)}catch{return b}}(a.headers,{}),e=i(a.body,""),f={method:c,headers:d};"GET"!==c&&"HEAD"!==c&&e&&(f.body=e);let g=await fetch(b,f),j=await g.text(),k=g.headers.get("content-type")??"",l=j;if(k.includes("application/json"))try{l=JSON.parse(j)}catch{}if(!g.ok)throw Error(`HTTP ${g.status} ${g.statusText}: ${j.slice(0,200)}`);return l},"web-fetch":async a=>{let b=h(a.url,"url"),c=await fetch(b,{headers:{"User-Agent":"Reflex-Workflow/1.0"}});if(!c.ok)throw Error(`HTTP ${c.status} ${c.statusText}`);return await c.text()},"ask-agent":async(a,b)=>{let c=h(a.prompt,"prompt"),{text:d}=await (0,f.runHeadlessAgent)({rootId:b.rootId,prompt:c,label:`[workflow ${b.workflow.id}] ${b.workflow.label}`});return d},"kb-write":async(a,b)=>{let c=i(a.kind,"note"),d=i(a.title,`Workflow ${b.workflow.label}`),f=i(a.body,""),g=await (0,e.j)({rootPath:b.rootPath,directive:{kind:c,title:d,body:f}});return{kind:g.kind,title:g.title,relPath:g.relPath,absPath:g.absPath}},"image-generate":async(a,b)=>{let d=h(a.prompt,"prompt"),e="codex"===a.provider||"gemini"===a.provider?a.provider:void 0,{generateImage:f}=await Promise.resolve().then(c.bind(c,84579)),g=await f({rootId:b.rootId,prompt:d,...e?{provider:e}:{},..."string"==typeof a.size&&a.size?{size:a.size}:{},..."string"==typeof a.aspectRatio&&a.aspectRatio?{aspectRatio:a.aspectRatio}:{}});return{url:g.urlPath,sha:g.sha,size:g.size,mime:g.mime,provider:g.provider}},"image-search":async a=>{let b,d=h(a.query,"query"),e="pexels"===a.provider||"unsplash"===a.provider||"brave"===a.provider?a.provider:void 0;if("number"==typeof a.count)b=a.count;else if("string"==typeof a.count&&a.count.trim()){let c=parseInt(a.count,10);Number.isFinite(c)&&c>0&&(b=c)}let{searchImages:f}=await Promise.resolve().then(c.bind(c,84579));return{results:await f({query:d,...e?{provider:e}:{},...void 0!==b?{count:b}:{}})}},"utility-call":async(a,b)=>{let d=h(a.utilityId,"utilityId"),e=h(a.actionName,"actionName"),f="project"===a.utilityScope?"project":"global",g=a.args??{};if("string"==typeof g)try{g=g.trim()?JSON.parse(g):{}}catch(a){throw Error(`utility-call: args is not valid JSON: ${a instanceof Error?a.message:String(a)}`)}let{getUtility:i}=await Promise.resolve().then(c.bind(c,8118)),j=await i(f,d,"project"===f?b.rootId:void 0);if(!j)throw Error(`utility-call: ${f}/${d} not installed`);let k=j.manifest.serverActions.find(a=>a.name===e);if(!k)throw Error(`utility-call: ${d} has no serverAction "${e}"`);let{runServerAction:l}=await Promise.all([c.e(9861),c.e(4031)]).then(c.bind(c,49556));return l({utility:j,action:k,args:g,parentCorrelationId:`workflow:${b.workflow.id}`})}};function h(a,b){if("string"!=typeof a||!a.trim())throw Error(`Param "${b}" is required (string)`);return a}function i(a,b){return"string"==typeof a?a:b}d()}catch(a){d(a)}})},43173:(a,b,c)=>{"use strict";c.d(b,{L:()=>e});var d=c(3265);let e=(0,d.createServerReference)("607c26b40d69de467a6ec39b6800629c4e799ba4f4",d.callServer,void 0,d.findSourceMapURL,"deleteTopicAction")},44427:()=>{},49410:(a,b,c)=>{"use strict";c.d(b,{b:()=>l,k:()=>n});var d=c(73024),e=c(76760),f=c.n(e),g=c(87841),h=c.n(g),i=c(73652);let j=f().join((0,i._)(),"skills"),k=[{id:"deep-research",title:"Deep research",description:"Deep research with citations - web + KB, synthesis via researcher sub-agents.",author:"builtin",instructions:'## Skill: deep-research\n\nRun the investigation like a professional analyst:\n 1. First draft a short search plan: 3-5 key questions around the topic.\n 2. For each key question, dispatch a researcher sub-agent with a concrete brief and the expected output shape.\n 3. Once results come back, synthesize: what is confirmed, what conflicts, where the gaps are.\n 4. Cite sources with URL and date (when available). Never invent links.\n 5. At the end propose: (a) saving the key facts into KB (`<<reflex:kb>>` kind="research-note"), (b) assembling a news-list/link-list widget.\n 6. If data is thin - say so openly and suggest next steps.'},{id:"widget-builder",title:"Widget builder",description:"Widget-creation helper - suggests the kind and data format.",author:"builtin",instructions:"## Skill: widget-builder\n\nYou help design and assemble a widget:\n 1. Clarify via `<<reflex:question>>` the widget's purpose and audience (for me alone / for the team / a report).\n 2. Pick the optimal `kind` - justify the choice out loud (one line).\n 3. If the widget needs data, gather it via WebFetch/WebSearch/Read before emitting.\n 4. Emit exactly one `<<reflex:widget-create>>` marker, with a thoughtful `id` and `refresh` cadence.\n 5. Tell the user how to edit the widget (pencil icon -> this same topic)."},{id:"kb-curator",title:"KB curator",description:"Turns raw content into clean KB notes with the right kind and meta.",author:"builtin",instructions:"## Skill: kb-curator\n\nYou are the knowledge-base curator. Every input - note, fact, or link - becomes a tidy KB entry:\n 1. Determine the `kind` (fact | task | meeting | product | person | place | event | ...). If ambiguous - ask.\n 2. Title: 4-9 words, no quotes, no trailing period.\n 3. `meta`: put structured fields here (ISO dates, links, tags). Do NOT duplicate them in the body.\n 4. `body`: anything that didn't fit in meta - context, nuance, quotes with sources.\n 5. Emit a `<<reflex:kb>>` marker; do not write via Write - the manager places it in the correct folder.\n 6. If the entry adds to an existing topic - mention sibling files via @-mentions in chat (for context, not for the agent)."}];async function l(){let a=await m(),b=new Set(a.map(a=>a.id)),c=k.filter(a=>!b.has(a.id)).map(({instructions:a,...b})=>b);return[...a.map(({instructions:a,...b})=>b),...c]}async function m(){let a;try{a=await d.promises.readdir(j,{withFileTypes:!0})}catch{return[]}let b=[];for(let c of a)if(c.isFile()&&c.name.toLowerCase().endsWith(".md"))try{let a=await d.promises.readFile(f().join(j,c.name),"utf8"),e=h()(a),g=e.data,i="string"==typeof g.id?g.id:null;if(!i)continue;b.push({id:i,title:"string"==typeof g.title?g.title:i,description:"string"==typeof g.description?g.description:"",author:"user",instructions:e.content.trim()})}catch{}return b}async function n(a){let b=(await m()).find(b=>b.id===a);return b||(k.find(b=>b.id===a)??null)}},50995:(a,b,c)=>{"use strict";c.d(b,{i:()=>f});var d=c(73745);c(66493);var e=c(53905);async function f(){try{let a=await (0,e.qV)();return{ok:!0,entries:a}}catch(a){return{ok:!1,error:a instanceof Error?a.message:String(a)}}}(0,c(63781).D)([f]),(0,d.A)(f,"0005921da7741e17d472ed0986d2f5be5a6f350a19",null)},51021:(a,b,c)=>{"use strict";c.a(a,async(a,d)=>{try{c.d(b,{W:()=>r});var e=c(76760),f=c.n(e),g=c(54287),h=c(78744),i=c(36017),j=c(53905),k=c(93554),l=c(20243),m=c(875),n=c(96921),o=c(5492),p=c(49410),q=a([k]);k=(q.then?(await q)():q)[0];let t="рус";async function r(a){let b=await (0,j.Zn)(a.rootId);if(!b)return{error:"Root not found",status:404};if(k.z.isActive(a.topicId))return{error:"Topic already has a running agent",status:409};let c=await (0,i.M)(),d=c.assignments.chat,e=a.harness??d.harness,l=a.model??d.model,q=c.language,r=(0,g.FF)(b.path),v=(0,m.wr)(a.message),w=(0,n.dr)(a.message),x=a.message;v?"goal"===v.kind&&v.text?(await (0,o.PF)(b.path,a.topicId,v.text),x=v.text):"plan"===v.kind&&(x=v.text||a.message):w&&"agent-mode"===w.def.kind&&(x=w.payload||a.message);let y=null;if(w?.def.id==="skill"){let[a,...b]=w.payload.split(/\s+/);if(a){let c=await (0,p.k)(a);c&&(y=c.instructions,x=b.join(" ").trim()||x)}}let z=await (0,o.eF)(b.path,a.topicId),A=z?.meta.goal&&"active"===z.meta.goalStatus?z.meta.goal:void 0,B=await (0,h.M)({root:b.path,scope:b.path,reflexScope:r,language:q}),C=function(a){let b=[],c=new Set;for(let d of a.matchAll(/https?:\/\/[^\s)>'"]+/g)){let a=d[0];try{let d=new URL(a);if(!u.has(d.hostname.toLowerCase())||c.has(a))continue;c.add(a),b.push(a)}catch{}}return b}(x),D=[B,A?(0,m.FB)(A,q):"",v?.kind==="plan"?(0,m.$4)(q):"",w?.def.id==="research"?(0,m.dA)(w.payload,q):"",w?.def.id==="widget"?(0,m.wt)(w.payload,q):"",w?.def.id==="mcp"?(0,m.YE)(w.payload,q):"",w?.def.id==="workflow"?(0,m.vl)(w.payload,q):"",y??"",a.focusFile?function(a,b,c){let d=f().join(b,a);return/russ/i.test(c)||RegExp(t,"i").test(c)?`## Open document — primary context
|
|
34
|
+
|
|
35
|
+
The user is currently reading this KB file: \`${a}\`
|
|
36
|
+
Absolute path: \`${d}\`
|
|
37
|
+
|
|
38
|
+
Rules for this turn (respond in Russian):
|
|
39
|
+
1. **Read this file in full via the Read tool first** — it is the primary source of context.
|
|
40
|
+
2. Base your answer primarily on its contents.
|
|
41
|
+
3. Only fall back to neighbouring files (same directory, sibling INDEX.md, parent dir) if the open file lacks the needed info.
|
|
42
|
+
4. Don't guess: if neither the open file nor its neighbours contain the answer, say so explicitly and suggest where to look.
|
|
43
|
+
5. When linking in your reply, use paths relative to the KB root (matching the open file).`:`## Open document — primary context
|
|
44
|
+
|
|
45
|
+
The user is currently reading this KB file: \`${a}\`
|
|
46
|
+
Absolute path: \`${d}\`
|
|
47
|
+
|
|
48
|
+
Rules for this turn:
|
|
49
|
+
1. **Read this file first via the Read tool** — it is the primary source of context.
|
|
50
|
+
2. Base your answer primarily on its contents.
|
|
51
|
+
3. Only fall back to neighbouring files (same directory, sibling INDEX.md, parent dir) if the open file lacks the needed info.
|
|
52
|
+
4. Don't guess: if neither the open file nor its neighbours contain the answer, say so explicitly and suggest where to look.
|
|
53
|
+
5. When citing, use rel-paths from the KB root (same convention as the open file).`}(a.focusFile,r,q):"",C.length>0?function(a,b){let c=/russ/i.test(b)||RegExp(t,"i").test(b),d=a.map(a=>`- ${a}`).join("\n");return c?["## YouTube video in the message\n\nThe user's message contains YouTube URL(s):",d,'\n**Decide whether you actually need the video\'s content to answer.**\n\n- If the user wants to know **what the video is about** / **what\'s said in it** / a description / summary / quotes / facts — ask Reflex to run a Gemini summary:\n\n```\n<<reflex:youtube-summary>>{"url":"<URL>"}<</reflex:youtube-summary>>\n```\n\n One marker per video, all in the same turn. After emitting markers **STOP** — do not try to answer in this same turn. Reflex will wait for Gemini and re-invoke you with the summary in context.\n\n- If the request **doesn\'t need** the video\'s content (for example "which player is better", "fix this link", "add another video to this") — answer directly, no directive.\n\n- **Do not use WebFetch** for YouTube URLs — it returns neither captions nor video. Only the directive above.\n\n- If the Gemini summary fails (Reflex will return an error message), apologise and suggest saving a key in Settings -> Gemini. Respond in Russian.'].join("\n"):["## YouTube video in the message\n\nThe user's message contains YouTube URL(s):",d,'\n**Decide whether you actually need the video\'s content to answer.**\n\n- If the user wants to know **what the video is about** / **what\'s said in it** / a description / summary / quotes / facts — ask Reflex to run Gemini-summary:\n\n```\n<<reflex:youtube-summary>>{"url":"<URL>"}<</reflex:youtube-summary>>\n```\n\n One marker per video, all in the same turn. After emitting markers **STOP** — don\'t try to answer in this same turn. Reflex will wait for Gemini and re-invoke you with the summary in context.\n\n- If the request **doesn\'t need** the video\'s content ("which player is best", "fix this URL", "add another video") — answer directly, no directive.\n\n- **Don\'t use WebFetch** for YouTube URLs — it gets neither captions nor video. Only the directive above.\n\n- If the Gemini summary fails (Reflex will return an error message), apologise and suggest saving a key in Settings → Gemini.'].join("\n")}(C,q):""].filter(Boolean).join("\n\n"),E=await k.z.ensureAgent({topicId:a.topicId,rootId:a.rootId,rootPath:b.path,reflexScope:r,role:"orchestrator",task:"chat",harness:e,model:l,language:q,label:"Orchestrator"}),F=function(a,b){let c=a.trim();if(!b||0===b.length)return c;let d=b.map(a=>`📎 ${a.name} (${a.absPath})`).join("\n");return c?`${c}
|
|
54
|
+
|
|
55
|
+
${d}`:d}(a.message,a.attachments);return await k.z.emit({type:"user-message",text:F,agentId:E.id,ts:new Date().toISOString(),seq:0}),(async()=>{try{let c=await s(b.path,a.topicId),e=function(a,b){let c=["### user",a.trim()||"(no text)"];if(b&&b.length>0)for(let a of(c.push(""),c.push("Attached files (use the Read tool to open them):"),b))c.push(` - ${a.absPath} (${a.mime}, ${a.size} bytes) — original: ${a.name}`);return c.join("\n")}(x,a.attachments),f=c?`Prior conversation:
|
|
56
|
+
|
|
57
|
+
${c}
|
|
58
|
+
|
|
59
|
+
${e}
|
|
60
|
+
|
|
61
|
+
### assistant
|
|
62
|
+
(Reply now.)`:`${e}
|
|
63
|
+
|
|
64
|
+
### assistant
|
|
65
|
+
(Reply now.)`;await k.z.invoke({agentId:E.id,systemPrompt:D,prompt:f,allowedTools:d.allowedTools})}catch(a){await k.z.emit({type:"error",message:a instanceof Error?a.message:String(a),agentId:E.id,ts:new Date().toISOString(),seq:0})}})(),{agentId:E.id}}let u=new Set(["youtube.com","www.youtube.com","m.youtube.com","youtu.be","youtube-nocookie.com","www.youtube-nocookie.com"]);async function s(a,b){let c=await (0,l.readEvents)(a,b),d=[],e=null,f=()=>{e&&(d.push(`### ${e.role}
|
|
66
|
+
${e.text.trim()}`),e=null)};for(let a of c)"user-message"===a.type?(f(),e={role:"user",text:a.text},f()):"assistant-delta"===a.type?(e&&"assistant"===e.role||(f(),e={role:"assistant",text:""}),e.text+=a.text):("turn-end"===a.type||"agent-end"===a.type)&&f();return f(),d.join("\n\n")}d()}catch(a){d(a)}})},52219:(a,b,c)=>{"use strict";c.d(b,{H:()=>e});var d=c(59377);async function e(a){let b=(0,d.Tf)().startThread({model:a.args.model,workingDirectory:a.args.rootPath,sandboxMode:"read-only",additionalDirectories:[a.args.reflexScope],approvalPolicy:"never",skipGitRepoCheck:!0}),c=a.args.systemPrompt.trim().length>0?`${a.args.systemPrompt}
|
|
67
|
+
|
|
68
|
+
${a.args.prompt}`:a.args.prompt,e=await b.runStreamed(c),f=new Map;try{for await(let b of e.events)if("item.started"!==b.type){if("item.updated"===b.type||"item.completed"===b.type){let c=b.item;if("agent_message"===c.type){let b=f.get(c.id)??"",d=c.text.slice(b.length);d.length>0&&(f.set(c.id,c.text),await a.manager.emit({type:"assistant-delta",text:d,agentId:a.meta.id,ts:new Date().toISOString(),seq:0}));continue}if("command_execution"===c.type&&"item.completed"===b.type){await a.manager.emit({type:"tool-use",toolUseId:c.id,name:"Bash",input:{command:c.command},agentId:a.meta.id,ts:new Date().toISOString(),seq:0}),await a.manager.emit({type:"tool-result",toolUseId:c.id,content:c.aggregated_output??"",...0!==c.exit_code?{isError:!0}:{},agentId:a.meta.id,ts:new Date().toISOString(),seq:0});continue}if("file_change"===c.type&&"item.completed"===b.type){await a.manager.emit({type:"tool-use",toolUseId:c.id,name:"FileChange",input:{changes:c.changes},agentId:a.meta.id,ts:new Date().toISOString(),seq:0}),await a.manager.emit({type:"tool-result",toolUseId:c.id,content:`${c.status}: ${c.changes.map(a=>`${a.kind} ${a.path}`).join(", ")}`,..."failed"===c.status?{isError:!0}:{},agentId:a.meta.id,ts:new Date().toISOString(),seq:0});continue}if("mcp_tool_call"===c.type&&"item.completed"===b.type){await a.manager.emit({type:"tool-use",toolUseId:c.id,name:`mcp:${c.server}:${c.tool}`,input:c.arguments,agentId:a.meta.id,ts:new Date().toISOString(),seq:0});let b=c.error?c.error.message:JSON.stringify(c.result?.content??[]).slice(0,4e3);await a.manager.emit({type:"tool-result",toolUseId:c.id,content:b,...c.error?{isError:!0}:{},agentId:a.meta.id,ts:new Date().toISOString(),seq:0});continue}if("web_search"===c.type&&"item.completed"===b.type){await a.manager.emit({type:"tool-use",toolUseId:c.id,name:"WebSearch",input:{query:c.query},agentId:a.meta.id,ts:new Date().toISOString(),seq:0});continue}"error"===c.type&&"item.completed"===b.type&&await a.manager.emit({type:"error",message:c.message,agentId:a.meta.id,ts:new Date().toISOString(),seq:0});continue}if("turn.failed"===b.type)throw await a.manager.emit({type:"error",message:`codex turn failed: ${b.error.message}`,agentId:a.meta.id,ts:new Date().toISOString(),seq:0}),Error(b.error.message);if("error"===b.type)throw await a.manager.emit({type:"error",message:b.message,agentId:a.meta.id,ts:new Date().toISOString(),seq:0}),Error(b.message)}}finally{await (0,d.Nb)(b.id)}}},53905:(a,b,c)=>{"use strict";c.d(b,{L7:()=>r,Qu:()=>s,Zn:()=>p,_S:()=>q,mM:()=>l,qV:()=>o});var d=c(73024),e=c(76760),f=c.n(e),g=c(77598),h=c.n(g);let i=(0,c(73652)._)(),j=f().join(i,"registry.json"),k={version:1,entries:[]};function l(a){return h().createHash("sha1").update(f().resolve(a)).digest("hex").slice(0,16)}async function m(){try{let a=await d.promises.readFile(j,"utf8"),b=JSON.parse(a);if("object"==typeof b&&null!==b&&"entries"in b&&Array.isArray(b.entries))return b;return k}catch(a){if("object"==typeof a&&null!==a&&"code"in a&&"ENOENT"===a.code)return k;throw a}}async function n(a){await d.promises.mkdir(i,{recursive:!0}),await d.promises.writeFile(j,JSON.stringify(a,null,2)+"\n","utf8")}async function o(){return[...(await m()).entries].sort((a,b)=>Date.parse(b.addedAt)-Date.parse(a.addedAt))}async function p(a){return(await m()).entries.find(b=>b.id===a)??null}async function q(a){let b=f().resolve(a),c=l(b),d=await m(),e=d.entries.find(a=>a.id===c);if(e)return e;let g={id:c,path:b,addedAt:new Date().toISOString()};return await n({...d,entries:[...d.entries,g]}),g}async function r(a){let b=await m();await n({...b,entries:b.entries.filter(b=>b.id!==a)})}async function s(a){let b=await m(),c=b.entries.findIndex(b=>b.id===a);if(c<0)return;let d=[...b.entries],e=d[c];d[c]={...e,lastInitAt:new Date().toISOString()},await n({...b,entries:d})}},54287:(a,b,c)=>{"use strict";c.d(b,{FF:()=>k,KZ:()=>g,Lj:()=>h,VU:()=>i,a:()=>j,eQ:()=>l,fW:()=>f,x9:()=>m});var d=c(76760),e=c.n(d);let f=".reflex",g=".reflexignore",h=new Set([".reflex",".git","node_modules",".DS_Store"]),i=18e5,j=1e3;function k(a){return e().join(a,f)}function l(a){return e().join(k(a),"config.json")}function m(a,b){return e().join(k(a),b)}},55143:(a,b,c)=>{"use strict";c.a(a,async(a,d)=>{try{c.d(b,{n:()=>n,runWorkflow:()=>m});var e=c(77598),f=c.n(e),g=c(53905),h=c(73928),i=c(30516),j=c(59895),k=c(36724),l=a([k]);async function m(a,b,c){let d=await (0,g.Zn)(a);if(!d)return{ok:!1,error:"Root not found"};let e=await (0,h.readWorkflow)(d.path,b);if(!e)return{ok:!1,error:"Workflow not found"};let l={id:function(){let a=new Date().toISOString().replace(/[:.]/g,"-").slice(0,19),b=f().randomBytes(3).toString("hex");return`${a}-${b}`}(),workflowId:e.id,workflowLabel:e.label,status:"running",startedAt:new Date().toISOString(),steps:e.steps.map(a=>({stepId:a.id,status:"pending"})),...void 0!==c?{initialInput:c}:{}};await (0,h.bp)(d.path,l);let m={},n=c,o={rootId:a,rootPath:d.path,workflow:{id:e.id,label:e.label}};for(let a=0;a<e.steps.length;a++){let b=e.steps[a],f=l.steps[a];f.status="running",f.startedAt=new Date().toISOString(),await (0,h.bp)(d.path,l);try{let a=k.L[b.kind];if(!a)throw Error(`Unknown node kind: ${b.kind}`);let d=(0,j.V)(b.params,{prev:n,steps:m,input:c,workflow:{id:e.id,label:e.label}}),g=(0,i.P)(b.kind,d);f.renderedParams=g;let h=await a(g,o);f.output=h,f.status="completed",f.finishedAt=new Date().toISOString(),m[b.id]={output:h},n=h}catch(a){return f.status="failed",f.error=a instanceof Error?a.message:String(a),f.finishedAt=new Date().toISOString(),l.status="failed",l.finishedAt=new Date().toISOString(),await (0,h.bp)(d.path,l),(0,h.lq)(d.path,e.id),{ok:!0,run:l}}await (0,h.bp)(d.path,l)}return l.status="completed",l.finishedAt=new Date().toISOString(),await (0,h.bp)(d.path,l),(0,h.lq)(d.path,e.id),{ok:!0,run:l}}function n(a){if(!a.id||"string"!=typeof a.id)return"id is required";if(!a.label||"string"!=typeof a.label)return"label is required";if(!Array.isArray(a.steps)||0===a.steps.length)return"steps[] cannot be empty";let b=new Set;for(let c of a.steps){if(!c.id)return"every step must have an id";if(b.has(c.id))return`Duplicate step id: ${c.id}`;if(b.add(c.id),!k.L[c.kind])return`Unknown step kind: ${c.kind}`}return null}k=(l.then?(await l)():l)[0],d()}catch(a){d(a)}})},56942:(a,b,c)=>{"use strict";c.d(b,{j:()=>j});var d=c(73024),e=c(76760),f=c.n(e),g=c(87841),h=c.n(g),i=c(54287);async function j(a){var b;let{rootPath:c,directive:e,provenance:g}=a,j=k(e.kind)||"note",m=new Date().toISOString().slice(0,10),n=((b=e.date)&&/^\d{4}-\d{2}-\d{2}$/.test(b)?b:null)??m,o=k(e.slug&&e.slug.trim()?e.slug:e.title)||"entry",p=`${n}-${o}`,q=f().join((0,i.FF)(c),j);await d.promises.mkdir(q,{recursive:!0});let r=await l(q,p,".md"),s={title:e.title,kind:j,date:n,version:1,...e.meta&&"object"==typeof e.meta?e.meta:{}};g&&(s.createdBy=`${g.kind}:${g.id}${g.version?"@"+g.version:""}`);let t=(e.body??"").replace(/\r\n/g,"\n").trimEnd(),u=h().stringify(t?t+"\n":"",s);await d.promises.writeFile(r,u,"utf8");let v=f().relative((0,i.FF)(c),r).split(f().sep).join("/");return{kind:j,title:e.title,relPath:v,absPath:r}}function k(a){return a.normalize("NFKD").toLowerCase().replace(/[^\p{L}\p{N}]+/gu,"-").replace(/^-+|-+$/g,"").slice(0,60)}async function l(a,b,c){let d=f().join(a,b+c),e=1;for(;await m(d);){if(e>99){d=f().join(a,`${b}-${Date.now().toString(36)}${c}`);break}d=f().join(a,`${b}-${++e}${c}`)}return d}async function m(a){try{return await d.promises.access(a),!0}catch{return!1}}},59377:(a,b,c)=>{"use strict";c.d(b,{He:()=>o,Nb:()=>s,Tf:()=>l,dt:()=>n,listCodexModels:()=>q});var d=c(93628),e=c(73024),f=c(48161),g=c.n(f),h=c(76760),i=c.n(h),j=c(31421);let k=null;function l(){return k||(k=new d.U),k}let m=null;async function n(){return m||(m=(async()=>{let a=process.env.CODEX_HOME||i().join(g().homedir(),".codex"),b=i().join(a,"skills",".system","imagegen"),c=i().join(b,"SKILL.md");try{await e.promises.access(c);return}catch{}let d=i().join(process.cwd(),"lib","server","codex","skills","imagegen","SKILL.md");try{await e.promises.mkdir(b,{recursive:!0}),await e.promises.copyFile(d,c)}catch(a){console.warn("Failed to install Reflex imagegen skill into $CODEX_HOME:",a instanceof Error?a.message:a)}})())}function o(){let a=process.env.CODEX_HOME||i().join(g().homedir(),".codex");return i().join(a,"generated_images")}let p=null;async function q(a={}){if(!a.force&&p&&Date.now()-p.at<6e4)return p.models;let b=await r();return p={at:Date.now(),models:b},b}async function r(){return new Promise((a,b)=>{let c=(0,j.spawn)("codex",["app-server"],{stdio:["pipe","pipe","pipe"]}),d="",e=!1,f=()=>{try{c.kill("SIGTERM")}catch{}},g=setTimeout(()=>{e||(e=!0,f(),b(Error("codex app-server model/list timed out")))},1e4);c.on("error",a=>{e||(e=!0,clearTimeout(g),b(a))}),c.stdout.on("data",b=>{let c=(d+=b.toString("utf8")).indexOf("\n");for(;c>=0;){let b=d.slice(0,c).trim();if(d=d.slice(c+1),b.length>0)try{let c=JSON.parse(b);if(2===c.id&&c.result&&Array.isArray(c.result.data)){let b=[];for(let a of c.result.data)"string"==typeof a?.id&&b.push({id:a.id,displayName:"string"==typeof a.displayName?a.displayName:a.id,description:"string"==typeof a.description?a.description:"",hidden:!0===a.hidden,isDefault:!0===a.isDefault});if(!e){e=!0,clearTimeout(g),f(),a(b);return}}}catch{}c=d.indexOf("\n")}}),c.stderr.on("data",()=>{}),c.stdin.write(JSON.stringify({jsonrpc:"2.0",id:1,method:"initialize",params:{clientInfo:{name:"reflex",title:"Reflex",version:"0.0.0"},capabilities:{}}})+"\n"),c.stdin.write(JSON.stringify({jsonrpc:"2.0",method:"initialized",params:{}})+"\n"),c.stdin.write(JSON.stringify({jsonrpc:"2.0",id:2,method:"model/list",params:{}})+"\n"),c.stdin.end()})}async function s(a){if(!a)return;let b=process.env.CODEX_HOME||i().join(g().homedir(),".codex"),c=i().join(b,"sessions"),d=new Date;for(let b of[-1,0,1]){let f,g=new Date(d);g.setDate(g.getDate()+b);let h=i().join(c,String(g.getFullYear()),String(g.getMonth()+1).padStart(2,"0"),String(g.getDate()).padStart(2,"0"));try{f=await e.promises.readdir(h)}catch{continue}for(let b of f)b.includes(a)&&await e.promises.unlink(i().join(h,b)).catch(()=>{})}}},59788:(a,b,c)=>{"use strict";c.d(b,{R:()=>f});var d=c(84579),e=c(53905);async function f(a){let b=function(a){let b=a.trim();if(b.startsWith("{")&&b.endsWith("}"))try{let a=JSON.parse(b),c={prompt:"string"==typeof a.prompt&&a.prompt.trim().length>0?a.prompt:b};return("gemini"===a.provider||"codex"===a.provider)&&(c.provider=a.provider),"string"==typeof a.size&&(c.size=a.size),"string"==typeof a.aspectRatio&&(c.aspectRatio=a.aspectRatio),"string"==typeof a.alt&&(c.alt=a.alt),c}catch{}return{prompt:b}}(a.args.prompt),c=(0,e.mM)(a.args.rootPath);try{var f;let e=await (0,d.generateImage)({rootId:c,prompt:b.prompt,...b.provider?{provider:b.provider}:{},...b.size?{size:b.size}:{},...b.aspectRatio?{aspectRatio:b.aspectRatio}:{},...b.alt?{alt:b.alt}:{}}),g=b.alt||b.prompt,h=`![${g.replace(/[\[\]\n]/g," ").slice(0,200)}](${e.urlPath})
|
|
69
|
+
|
|
70
|
+
_generated: ${e.provider} \xb7 ${(f=e.size)<1024?`${f} B`:f<1048576?`${(f/1024).toFixed(1)} KB`:`${(f/1048576).toFixed(2)} MB`}_
|
|
71
|
+
`;await a.manager.emit({type:"assistant-delta",text:h,agentId:a.meta.id,ts:new Date().toISOString(),seq:0})}catch(c){let b=c instanceof Error?c.message:String(c);throw await a.manager.emit({type:"assistant-delta",text:`Failed to generate image: ${b}
|
|
72
|
+
`,agentId:a.meta.id,ts:new Date().toISOString(),seq:0}),c}}},59895:(a,b,c)=>{"use strict";c.d(b,{V:()=>e});let d=/\{\{\s*([^{}\s][^{}]*?)\s*\}\}/g;function e(a,b){return function a(b,c){if("string"==typeof b)return b.replace(d,(a,b)=>(function(a){if(null==a)return"";if("string"==typeof a)return a;if("number"==typeof a||"boolean"==typeof a)return String(a);try{return JSON.stringify(a)}catch{return String(a)}})(function(a,b){if("prev"===a)return b.prev;if(a.startsWith("workflow.")){let c=a.slice(9);return b.workflow[c]}if(a.startsWith("input."))return f(b.input,a.slice(6));if(a.startsWith("input"))return b.input;if(a.startsWith("steps.")){let[c,...d]=a.slice(6).split(".");if(!c)return;let e=b.steps[c];if(!e)return;if(0===d.length||1===d.length&&"output"===d[0])return e.output;if("output"===d[0])return f(e.output,d.slice(1).join("."))}}(b.trim(),c)));if(Array.isArray(b))return b.map(b=>a(b,c));if(b&&"object"==typeof b){let d={};for(let[e,f]of Object.entries(b))d[e]=a(f,c);return d}return b}(a,b)}function f(a,b){if(!b)return a;let c=b.split("."),d=a;for(let a of c){if(null==d||"object"!=typeof d)return;d=d[a]}return d}},61495:(a,b,c)=>{"use strict";c.d(b,{Bb:()=>e,EE:()=>g,Rg:()=>f,_W:()=>d});let d=["analyze","chat"],e={analyze:"Analyze (KB build)",chat:"Chat (KB Q&A)"},f={analyze:["language","root","scope","relScope","reflexScope","files","fileCount","overflow"],chat:["language","root","scope","reflexScope"]},g={analyze:`You are populating a local knowledge base (KB) for the directory:
|
|
73
|
+
{{scope}}
|
|
74
|
+
|
|
75
|
+
Project root: {{root}}
|
|
76
|
+
Scope (relative to root): {{relScope}}
|
|
77
|
+
Write all KB output as Markdown files under: {{reflexScope}}
|
|
78
|
+
|
|
79
|
+
**Write all Markdown content in {{language}}.** Keep code identifiers, file paths, and quoted source verbatim — translate prose only.
|
|
80
|
+
|
|
81
|
+
## Required structure
|
|
82
|
+
|
|
83
|
+
The KB is hierarchical. **Every directory under {{reflexScope}} MUST contain an INDEX.md.** Group related topics into subdirectories — do not dump every MD at the root.
|
|
84
|
+
|
|
85
|
+
Layout to produce (example for a typical project):
|
|
86
|
+
|
|
87
|
+
{{reflexScope}}/
|
|
88
|
+
├── INDEX.md # root overview, required
|
|
89
|
+
├── architecture/
|
|
90
|
+
│ ├── INDEX.md # required at every level
|
|
91
|
+
│ ├── data-model.md
|
|
92
|
+
│ └── routing.md
|
|
93
|
+
├── operations/
|
|
94
|
+
│ ├── INDEX.md
|
|
95
|
+
│ ├── build-and-test.md
|
|
96
|
+
│ └── deploy.md
|
|
97
|
+
└── modules/
|
|
98
|
+
├── INDEX.md
|
|
99
|
+
├── api/
|
|
100
|
+
│ ├── INDEX.md
|
|
101
|
+
│ └── endpoints.md
|
|
102
|
+
└── ui/
|
|
103
|
+
├── INDEX.md
|
|
104
|
+
└── components.md
|
|
105
|
+
|
|
106
|
+
Filenames are kebab-case. Directories are kebab-case too.
|
|
107
|
+
|
|
108
|
+
## Required frontmatter
|
|
109
|
+
|
|
110
|
+
Every Markdown file (INDEX.md included) MUST start with YAML frontmatter:
|
|
111
|
+
|
|
112
|
+
---
|
|
113
|
+
title: <human-readable title in {{language}}>
|
|
114
|
+
version: 1
|
|
115
|
+
date: <today's date in YYYY-MM-DD>
|
|
116
|
+
---
|
|
117
|
+
|
|
118
|
+
# <body>
|
|
119
|
+
|
|
120
|
+
Increment \`version\` only when re-writing a file later; keep \`date\` aligned with the day you last touched the content. \`title\` is what the UI sidebar shows — make it readable, not a filename.
|
|
121
|
+
|
|
122
|
+
## Content rules
|
|
123
|
+
|
|
124
|
+
- Each INDEX.md is a one-page overview of its directory: purpose, key files, how it relates to its parent. Link to direct-child files/INDEX.md as relative paths.
|
|
125
|
+
- Topic MD files focus on a single subject. Cross-link with relative paths.
|
|
126
|
+
- Prefer factual, source-grounded notes over speculation.
|
|
127
|
+
- Do not modify anything outside {{reflexScope}}.
|
|
128
|
+
- Do not write into \`{{reflexScope}}/topics/\` — that folder is reserved for chat transcripts.
|
|
129
|
+
- If the scope is essentially empty or boilerplate, write only a brief root INDEX.md and stop.
|
|
130
|
+
|
|
131
|
+
## Files visible in this scope (already filtered by .reflexignore)
|
|
132
|
+
|
|
133
|
+
{{files}}{{overflow}}
|
|
134
|
+
`,chat:`You are a knowledge-base assistant for the directory: {{scope}}
|
|
135
|
+
Project root: {{root}}
|
|
136
|
+
The authoritative KB for this scope lives at: {{reflexScope}}
|
|
137
|
+
|
|
138
|
+
Reply in {{language}}. Keep code identifiers, file paths, and quoted source verbatim.
|
|
139
|
+
|
|
140
|
+
When the user asks a question:
|
|
141
|
+
1. Prefer reading the relevant MD file(s) inside {{reflexScope}} first.
|
|
142
|
+
2. If the KB is missing the answer, you may read source files under {{scope}}, but never modify them.
|
|
143
|
+
3. Cite MD files by relative path so the user can open them.
|
|
144
|
+
4. Do not regenerate or rewrite the KB unless the user explicitly asks.
|
|
145
|
+
|
|
146
|
+
## Interaction protocol (works for any provider)
|
|
147
|
+
|
|
148
|
+
If you need a permission decision before doing something, output a marker
|
|
149
|
+
block and STOP. Reflex will surface buttons to the user and send their
|
|
150
|
+
decision as your next user message.
|
|
151
|
+
|
|
152
|
+
<<reflex:permission>>{"tool":"Write","input":{"file_path":"…"},"description":"Why you need it"}<</reflex:permission>>
|
|
153
|
+
|
|
154
|
+
If you need a clarifying answer from the user, emit a question marker. **DO NOT use the native \`AskUserQuestion\` tool — it is not allowed in Reflex.** Use only the marker below — it supports everything (header, multiSelect, label+description) and more.
|
|
155
|
+
|
|
156
|
+
Simple variant with ready-made answers:
|
|
157
|
+
|
|
158
|
+
<<reflex:question>>{"prompt":"Which language for the summary?","choices":["english","russian"]}<</reflex:question>>
|
|
159
|
+
|
|
160
|
+
Detailed variant with label+description (like AskUserQuestion):
|
|
161
|
+
|
|
162
|
+
<<reflex:question>>{
|
|
163
|
+
"id":"section",
|
|
164
|
+
"header":"Section",
|
|
165
|
+
"prompt":"Which section should we start with?",
|
|
166
|
+
"multiSelect":false,
|
|
167
|
+
"options":[
|
|
168
|
+
{"label":"History","description":"F1 timeline since 1950"},
|
|
169
|
+
{"label":"Season 2025","description":"Calendar and tables for the current season"}
|
|
170
|
+
]
|
|
171
|
+
}<</reflex:question>>
|
|
172
|
+
|
|
173
|
+
Multiple questions in one marker (batch — Reflex will show them as sequential cards):
|
|
174
|
+
|
|
175
|
+
<<reflex:question>>{
|
|
176
|
+
"questions":[
|
|
177
|
+
{"id":"section","header":"Section","prompt":"Which section should we start with?","options":[…]},
|
|
178
|
+
{"id":"depth","header":"Depth","prompt":"How detailed should the articles be?","options":[…]}
|
|
179
|
+
]
|
|
180
|
+
}<</reflex:question>>
|
|
181
|
+
|
|
182
|
+
Fields:
|
|
183
|
+
- \`prompt\` — required. The question itself, ~4-12 words.
|
|
184
|
+
- \`header\` — short tag label (≤12 chars): "Section", "Language", "Size". Optional.
|
|
185
|
+
- \`multiSelect\` — \`true\` if multiple options can be selected. Reflex returns the answer as a JSON array of strings.
|
|
186
|
+
- \`options\` — list of \`{label, description?}\`. Description — 1 line of context under the label.
|
|
187
|
+
- \`choices\` — legacy flat array of strings. For simple cases. Don't combine with \`options\`.
|
|
188
|
+
- \`id\` — stable id if you need to correlate the answer. Reflex generates one if omitted.
|
|
189
|
+
|
|
190
|
+
After emitting the marker(s) — STOP. Reflex will show the card, wait for the answer, and continue your turn.
|
|
191
|
+
|
|
192
|
+
## Routing: you are an orchestrator, not the worker
|
|
193
|
+
|
|
194
|
+
For anything non-trivial (deep KB reading, multi-file research, code writes,
|
|
195
|
+
utility creation, summarization of large texts) — DELEGATE to a specialist
|
|
196
|
+
sub-agent instead of doing it yourself. Sub-agents run with a focused system
|
|
197
|
+
prompt and a constrained toolset, so they're faster and stay in their lane.
|
|
198
|
+
|
|
199
|
+
Available roles:
|
|
200
|
+
- **researcher** — read-only KB / web research (Read, Glob, Grep, WebFetch, WebSearch). Use for "find / gather / quote".
|
|
201
|
+
- **coder** — writes/edits files (Write, Edit, MultiEdit + read tools). Use for "do / fix / create a file".
|
|
202
|
+
- **summarizer** — no tools; compresses long text passed in the brief. Use for "compress / extract the main points" from a large chunk.
|
|
203
|
+
- **kb-writer** — designs a structured KB entry (returns JSON for <<reflex:kb>>). Use when something is worth saving but the shape is non-trivial.
|
|
204
|
+
- **utility-builder** — designs a Reflex utility (manifest + ui.tsx). Use when the user asks to build a new utility.
|
|
205
|
+
|
|
206
|
+
To dispatch, emit one or more dispatch markers in a single turn and STOP:
|
|
207
|
+
|
|
208
|
+
<<reflex:dispatch>>{"id":"r1","role":"researcher","brief":"Read {{reflexScope}}/INDEX.md and collect a list of all topics."}<</reflex:dispatch>>
|
|
209
|
+
<<reflex:dispatch>>{"id":"c1","role":"coder","brief":"Add a \`tags\` field to schema/note.md and update the examples."}<</reflex:dispatch>>
|
|
210
|
+
|
|
211
|
+
Rules:
|
|
212
|
+
- The \`brief\` must be self-contained. Sub-agents do NOT see the chat
|
|
213
|
+
transcript — include all the context they need (rel-paths, expected
|
|
214
|
+
output shape, constraints).
|
|
215
|
+
- Multiple dispatches in one turn run **concurrently**. Don't dispatch
|
|
216
|
+
sequentially dependent tasks in the same turn — wait for the first
|
|
217
|
+
result before sending the second.
|
|
218
|
+
- After dispatches Reflex re-invokes you with each sub-agent's output
|
|
219
|
+
quoted. Compose the final user-facing reply from those results — quote
|
|
220
|
+
or paraphrase, don't just dump them.
|
|
221
|
+
- Do simple things yourself (one short answer, citing one file, a quick
|
|
222
|
+
KB lookup). Don't dispatch trivia.
|
|
223
|
+
- Don't re-dispatch the same brief if a sub-agent returned an empty or
|
|
224
|
+
unhelpful result — either solve it yourself or ask the user.
|
|
225
|
+
|
|
226
|
+
## Knowledge-base writes — ONLY via the \`<<reflex:kb>>\` marker
|
|
227
|
+
|
|
228
|
+
**CRITICAL.** To write to the knowledge base (any file under \`{{reflexScope}}/\`) you must use **only** the \`<<reflex:kb>>\` marker. **DO NOT use the Write/Edit tool for KB files** — they are not permitted there, you'll hit a permission gate and stall the user. Reflex creates the file under \`{{reflexScope}}/<kind>/<date>-<slug>.md\` with the correct structure and frontmatter; no Write needed.
|
|
229
|
+
|
|
230
|
+
<<reflex:kb>>{"kind":"fact","title":"Short title","body":"# H1\\n\\nDetailed description in Markdown","meta":{"tags":["finance"]}}<</reflex:kb>>
|
|
231
|
+
|
|
232
|
+
Fields:
|
|
233
|
+
- kind — \`fact\` | \`task\` | \`meeting\` | \`product\` | any kebab-case noun
|
|
234
|
+
- title — 3-10 words, human-readable, in {{language}}
|
|
235
|
+
- body — Markdown content (use \\n for newlines inside JSON)
|
|
236
|
+
- meta (opt.) — structured fields surfaced as YAML frontmatter
|
|
237
|
+
- slug (opt.) — file slug if you want to fix the name
|
|
238
|
+
- date (opt.) — YYYY-MM-DD (for meetings/events; defaults to today)
|
|
239
|
+
|
|
240
|
+
Conventional \`meta\` shapes:
|
|
241
|
+
- task → {"status":"todo|doing|done","priority":"low|med|high","due":"YYYY-MM-DD","assignee":"…"}
|
|
242
|
+
- meeting → {"attendees":["…"],"decisions":["…"],"action_items":["…"]}
|
|
243
|
+
- product → {"sku":"…","price":"…","currency":"USD","vendor":"…","url":"…"}
|
|
244
|
+
- fact → {"tags":["…"],"source":"…"}
|
|
245
|
+
|
|
246
|
+
Rules:
|
|
247
|
+
- Emit a marker for **each** entry, even if there are 50+. Multiple markers in a single response are allowed and encouraged for batch operations — this is your only path to writing to the KB.
|
|
248
|
+
- Write/Edit are allowed for **code and files outside \`.reflex/\`** (project sources). For anything that should land in the knowledge base — only \`<<reflex:kb>>\`.
|
|
249
|
+
- Don't duplicate the marker contents in the regular response text — the marker is canonical.
|
|
250
|
+
- The UI shows each saved entry as a card linking to the new file.
|
|
251
|
+
- If the user explicitly asks "do a Write" to a file under \`.reflex/\` — that's a special case; request permission via \`<<reflex:permission>>\` with a description of why the regular \`<<reflex:kb>>\` path doesn't fit.
|
|
252
|
+
|
|
253
|
+
## /reflex:utility — utility generation
|
|
254
|
+
|
|
255
|
+
Reflex supports mini-applications ("utilities") that you can create right from chat. A utility lives in a separate directory (\`~/.reflex/utilities/<id>/\` for global or \`<root>/.reflex/utilities/<id>/\` for project-scoped), loads in an isolated iframe, and **has no direct access to network, LLMs, or FS** — only via Reflex's Host API with permission checks.
|
|
256
|
+
|
|
257
|
+
To create a utility, emit a marker:
|
|
258
|
+
|
|
259
|
+
<<reflex:utility>>{"scope":"global","manifest":{...},"files":{...}}<</reflex:utility>>
|
|
260
|
+
|
|
261
|
+
### Hard rules
|
|
262
|
+
|
|
263
|
+
1. **UI** — a single React functional-component default-export, TypeScript. Put it in files["ui.tsx"].
|
|
264
|
+
2. **Imports ONLY**:
|
|
265
|
+
- \`"react"\`, \`"react-dom"\`, \`"react-dom/client"\` — resolved by the bundler.
|
|
266
|
+
- \`"@host/api"\` — gives the \`{ reflex }\` object (see below).
|
|
267
|
+
- \`"@host/ui"\` — gives primitives: Button, Input, Textarea, Label, Card, CardContent, CardHeader, CardTitle, Badge, ScrollArea.
|
|
268
|
+
- No other packages / node_modules / node:* modules. esbuild rejects any other import.
|
|
269
|
+
3. **No fetch/XHR/WebSocket/localStorage** inside the utility. Only \`reflex.web.fetch({url})\` with an explicitly whitelisted domain in the manifest.
|
|
270
|
+
4. **State** is persisted via \`reflex.fs.write({path, content})\` (in \`<utility>/data/\`) or \`reflex.kb.add({...})\`.
|
|
271
|
+
5. **Manifest** must list every required permission — the user sees this list at install time and can refuse.
|
|
272
|
+
|
|
273
|
+
### Manifest (JSON)
|
|
274
|
+
|
|
275
|
+
\`\`\`json
|
|
276
|
+
{
|
|
277
|
+
"id": "kebab-case-id",
|
|
278
|
+
"name": "Human-readable name",
|
|
279
|
+
"description": "What the utility does",
|
|
280
|
+
"version": "1.0.0",
|
|
281
|
+
"ui": "ui.tsx",
|
|
282
|
+
"permissions": {
|
|
283
|
+
"llm": {"tasks": ["chat", "quick"]},
|
|
284
|
+
"kb": {"read": true, "write": true, "kinds": ["3d-model"]},
|
|
285
|
+
"fs": {"sandbox": true},
|
|
286
|
+
"web": {"fetch": {"domains": ["api.example.com"]}, "search": false},
|
|
287
|
+
"audit": {"write": true},
|
|
288
|
+
"workers": {"enabled": true}
|
|
289
|
+
},
|
|
290
|
+
"serverActions": [
|
|
291
|
+
{"name": "summarize", "entry": "actions/summarize.ts", "timeoutMs": 30000}
|
|
292
|
+
],
|
|
293
|
+
"secrets": [
|
|
294
|
+
{"key": "OPENAI_API_KEY", "label": "OpenAI API key", "description": "Needed for calls to api.openai.com from this utility.", "required": true}
|
|
295
|
+
],
|
|
296
|
+
"mcpServers": ["github", "google-calendar"]
|
|
297
|
+
}
|
|
298
|
+
\`\`\`
|
|
299
|
+
|
|
300
|
+
### Host API (what's available on the \`reflex\` object)
|
|
301
|
+
|
|
302
|
+
- \`reflex.llm.complete({task, prompt, model?})\` → \`{text}\` — non-streaming LLM call. task ∈ {"chat","quick","rag","embed"}.
|
|
303
|
+
- \`reflex.kb.add({kind, title, body, meta?, rootId?})\` → \`{relPath, absPath}\`.
|
|
304
|
+
- \`reflex.kb.list({kind?, query?, rootId?})\` → array of summaries.
|
|
305
|
+
- \`reflex.kb.read({relPath, rootId?})\` → \`{content}\`.
|
|
306
|
+
- \`reflex.fs.read({path})\` / \`fs.write({path, content})\` / \`fs.list({path})\` — sandboxed to \`<utility>/data/\`.
|
|
307
|
+
- \`reflex.web.fetch({url, method?, headers?, body?})\` → \`{status, headers, body}\`. URL must be in \`permissions.web.fetch.domains\`.
|
|
308
|
+
- \`reflex.web.search({query})\` → \`{results: [{title, url, snippet}]}\`.
|
|
309
|
+
- \`reflex.audit.log({type, payload})\` — custom audit log entry.
|
|
310
|
+
- \`reflex.actions.invoke({name, args})\` — run your own server action in a Node Worker (if declared in the manifest).
|
|
311
|
+
- \`reflex.secrets.get({key})\` → \`{value}\` — reads a secret filled in by the user. \`key\` must be from \`manifest.secrets\`, otherwise error. If the value isn't set — also error (the utility should show the user what needs to be filled in).
|
|
312
|
+
- \`reflex.secrets.list()\` → \`{secrets: [{key, label, description, required, set}]}\` — the utility UI can show the user which secrets are needed and which are already filled in.
|
|
313
|
+
- \`reflex.mcp.listServers()\` → \`{servers: [{id, label, description, registered}]}\` — which MCP servers are available (from \`manifest.mcpServers\`) and which of them are actually registered in the system.
|
|
314
|
+
- \`reflex.mcp.listTools({server?})\` → \`{server, tools: [{name, description?, inputSchema?}]}\` — list of tools for a specific MCP server. If exactly one is declared in \`mcpServers\` — \`server\` can be omitted.
|
|
315
|
+
- \`reflex.mcp.call({server?, tool, args})\` → \`{server, isError?, content}\` — invoke an MCP tool. Use when you need to actually do something via a third-party service (GitHub, Calendar, Slack…). The server must be in \`manifest.mcpServers\` AND registered by the user in Settings → MCP.
|
|
316
|
+
|
|
317
|
+
### Secrets
|
|
318
|
+
|
|
319
|
+
If the utility needs confidential data (API keys, tokens, passwords) — **declare them in the manifest, don't bake them into code**:
|
|
320
|
+
|
|
321
|
+
\`\`\`json
|
|
322
|
+
"secrets": [
|
|
323
|
+
{"key": "OPENAI_API_KEY", "label": "OpenAI API key", "description": "What this is and why", "required": true}
|
|
324
|
+
]
|
|
325
|
+
\`\`\`
|
|
326
|
+
|
|
327
|
+
Rules:
|
|
328
|
+
- \`key\` — UPPER_SNAKE_CASE (like env vars).
|
|
329
|
+
- The description (\`label\` + \`description\`) is **shown to the user** in the utility's right-hand panel, where they fill in the value themselves. Explain clearly: what it is, where to get it, what it affects.
|
|
330
|
+
- **You as the agent DO NOT SEE the secret values** — they're stored in \`~/.reflex/secrets/\` outside your sandbox. Don't try to read them via Read/Glob, don't ask the user to type them into chat, don't put placeholders in utility files.
|
|
331
|
+
- Inside the utility use it like this: \`const {value: apiKey} = await reflex.secrets.get({key: "OPENAI_API_KEY"});\`. If \`required: true\` and not filled in — the utility should show a clear message (via \`reflex.secrets.list()\` and a UI card "Fill in secrets", not crash in the console).
|
|
332
|
+
|
|
333
|
+
### Registering an MCP server from chat
|
|
334
|
+
|
|
335
|
+
If the answer requires an MCP server that isn't yet in the registry — **don't ask** the user to go to Settings manually. Emit a \`<<reflex:mcp-add>>\` marker with a proposal: what the server is, how to launch it, which secrets to ask for. Reflex shows the user a card with your config and password fields for the secrets. Once they approve — the server is saved to the registry, and you get a message "MCP server X registered. You can now call …", after which call \`mcp__<id>__<tool>\` immediately.
|
|
336
|
+
|
|
337
|
+
<<reflex:mcp-add>>{"id":"mcp1","server":"google-calendar","label":"Google Calendar","description":"Read/create events in Google Calendar.","config":{"transport":"stdio","command":"npx","args":["-y","@modelcontextprotocol/server-google-calendar"],"env":{}},"secrets":[{"envKey":"GOOGLE_OAUTH_TOKEN","label":"Access token","description":"Get one via https://developers.google.com/oauthplayground (scope https://www.googleapis.com/auth/calendar). Copy the access_token.","required":true}]}<</reflex:mcp-add>>
|
|
338
|
+
|
|
339
|
+
Rules:
|
|
340
|
+
- \`server\` — kebab-case id under which it will live in the registry (and from which the tool prefix \`mcp__<id>__\` is derived). Not to be confused with \`id\` (correlation id for you).
|
|
341
|
+
- \`config\` — McpConfig: stdio (command/args/env), http/sse (url/headers). DO NOT BAKE secrets directly into env/headers — leave them empty/as placeholders; declare what the user must enter via \`secrets[]\`.
|
|
342
|
+
- For stdio, secrets go into \`env\`; for http/sse — into \`headers\` (key name = \`envKey\`).
|
|
343
|
+
- In the secret's \`description\` you **must** tell the user where to get the token.
|
|
344
|
+
- Don't try to read the secret values yourself after registration — they're only for the server, you don't see them.
|
|
345
|
+
- If the user declined — DO NOT try the same configuration again. Ask what was wrong via \`<<reflex:question>>\` or pick an alternative.
|
|
346
|
+
|
|
347
|
+
#### Full OAuth (auto-refresh)
|
|
348
|
+
|
|
349
|
+
Reflex supports a built-in OAuth flow with a local callback, persisted refresh tokens, and auto-renewal. Supported providers: \`google\`, \`github\`, \`notion\`, \`slack\`, \`linear\`. If the server authenticates via one of them — **use an oauth-slot instead of the regular secret input**: in the slot, set \`"oauth":"<provider>"\`, and the UI shows the user an "Authorize via <provider>" button instead of a password input. After authorization, the placeholder \`$oauth:<provider>\` is written into env — Reflex substitutes a fresh access_token on every call.
|
|
350
|
+
|
|
351
|
+
<<reflex:mcp-add>>{"id":"mcp1","server":"google-calendar","label":"Google Calendar","config":{"transport":"stdio","command":"npx","args":["-y","@modelcontextprotocol/server-google-calendar"],"env":{}},"secrets":[{"envKey":"GOOGLE_OAUTH_TOKEN","label":"Access token","oauth":"google","required":true,"description":"Reflex will open a Google OAuth window and save the refresh token. You need to configure client_id once beforehand in Settings → OAuth providers → Google."}]}<</reflex:mcp-add>>
|
|
352
|
+
|
|
353
|
+
When to do this: for any wrapper server over a service from the list above (Google Calendar/Gmail/Drive, GitHub, Notion, Slack, Linear). If the provider isn't in the list — fall back to a manual pat/bearer via the regular \`secrets[]\` without \`oauth\`.
|
|
354
|
+
|
|
355
|
+
### MCP servers (external services)
|
|
356
|
+
|
|
357
|
+
Reflex stores a **global MCP server registry** (Settings → MCP) — Google Calendar, GitHub, Slack, any compatible server. A utility gets access to them by declaring their ids in the manifest:
|
|
358
|
+
|
|
359
|
+
\`\`\`json
|
|
360
|
+
"mcpServers": ["github", "google-calendar"]
|
|
361
|
+
\`\`\`
|
|
362
|
+
|
|
363
|
+
Rules:
|
|
364
|
+
- Server IDs are kebab-case and must match what's in the registry. If a server isn't in the registry — \`reflex.mcp.listServers()\` returns it with \`registered: false\`, and the utility should suggest the user add it (as text — don't try to register it yourself).
|
|
365
|
+
- DO NOT use \`reflex.llm.complete\` to "execute a tool call" — the LLM returns only text. To actually invoke a tool, call \`reflex.mcp.call({server, tool, args})\` directly.
|
|
366
|
+
- The server config (command/args/url/env) is stored centrally — don't duplicate it in the utility and don't ask the user for it; they already set it once in Settings.
|
|
367
|
+
- If \`mcpServers\` is empty or a declared server isn't registered — the utility should render a clear "Register server X in Settings → MCP" message rather than crash.
|
|
368
|
+
|
|
369
|
+
The chat agent (orchestrator) **also** has native MCP via \`--mcp-config\`, which Reflex automatically forwards to the claude-code CLI. Tools there are available as \`mcp__<server-id>__<tool-name>\` (e.g. \`mcp__github__list_repos\`). In chat, use them **directly** via ToolUse — don't route through the utility paths.
|
|
370
|
+
|
|
371
|
+
### Server actions (heavy server-side logic)
|
|
372
|
+
|
|
373
|
+
If a utility needs to do something in Node, declare \`serverActions\` in the manifest. Each action is a .ts file in \`files["actions/<name>.ts"]\` with a default export:
|
|
374
|
+
|
|
375
|
+
\`\`\`ts
|
|
376
|
+
import { reflex } from "@host/api";
|
|
377
|
+
export default async function run(args, host) {
|
|
378
|
+
// host === reflex; use for llm/fs/kb/web calls
|
|
379
|
+
const data = await host.fs.read({path: args.path});
|
|
380
|
+
return {summary: data.content.slice(0, 200)};
|
|
381
|
+
}
|
|
382
|
+
\`\`\`
|
|
383
|
+
|
|
384
|
+
The action runs in a Worker thread with the same permissions as the UI. The Worker is terminated after a single invocation. Hard limits: 256MB heap, timeout per \`timeoutMs\`.
|
|
385
|
+
|
|
386
|
+
### Files
|
|
387
|
+
|
|
388
|
+
- \`ui.tsx\` — entry React component (required).
|
|
389
|
+
- \`README.md\` — description (recommended).
|
|
390
|
+
- \`actions/<name>.ts\` — server actions (if declared).
|
|
391
|
+
|
|
392
|
+
Tailwind classes are available via the standard sheet (cdn.jsdelivr.net/npm/tailwindcss).
|
|
393
|
+
|
|
394
|
+
### When to use
|
|
395
|
+
|
|
396
|
+
Emit \`<<reflex:utility>>\` only if the user explicitly asks to create a utility / mini-app / form / generator. For one-off tasks — a regular reply. If unsure — ask via \`<<reflex:question>>\`.
|
|
397
|
+
|
|
398
|
+
After the marker, the system shows a "Utility installed" card with a link; don't duplicate the name in prose.
|
|
399
|
+
|
|
400
|
+
## General rules
|
|
401
|
+
|
|
402
|
+
- Emit at most one permission/question marker per pause, then stop
|
|
403
|
+
generating until the user responds.
|
|
404
|
+
- Markers must be valid JSON on a single block (whitespace inside is fine).
|
|
405
|
+
- You may proceed normally without any marker; only use them when blocked
|
|
406
|
+
or when there's knowledge worth persisting.
|
|
407
|
+
`}},63848:(a,b,c)=>{"use strict";c.d(b,{F8:()=>m,Qr:()=>k,pV:()=>l});var d=c(73024),e=c(76760),f=c.n(e),g=c(87841),h=c.n(g),i=c(54287);let j=new Set(["topics","attachments","data","audit"]);async function k(a){let b=(0,i.FF)(a),c=new Map;return await n(b,b,c),{files:c}}async function l(a,b){let c=(0,i.FF)(a),d=new Map;await n(c,c,d);let e=[];for(let[a,g]of d){let d=b.files.get(a);if(void 0!==d&&d>=g)continue;let h=f().relative(c,a).split(f().sep).join("/");e.push({abs:a,rel:h,...await o(a)})}return e}async function m(a,b){let c=(0,i.FF)(a),e=new Set;for(let a of b){if("index.md"===f().basename(a.abs).toLowerCase())continue;let b=f().dirname(a.abs),g=f().join(b,"INDEX.md"),h=await p(g),i=f().basename(a.abs),j=a.title??i.replace(/\.md$/,""),k=a.kind?` _(${a.kind})_`:"",l=`- [${j}](./${i})${k}`,m=h?await d.promises.readFile(g,"utf8"):"";if(!function(a,b){let c=b.replace(/[.*+?^${}()|[\]\\]/g,"\\$&");return RegExp(`]\\(\\.?/?${c}\\)`).test(a)}(m,i)){if(h)/\n## Files\b/i.test(m)?m.endsWith("\n")||(m+="\n"):m=m.trimEnd()+"\n\n## Files\n\n";else{let a=f().relative(c,b)||".";m=`# ${a}
|
|
408
|
+
|
|
409
|
+
Auto-generated index. Edit freely — Reflex only appends new entries below.
|
|
410
|
+
|
|
411
|
+
## Files
|
|
412
|
+
|
|
413
|
+
`}m+=l+"\n",await d.promises.writeFile(g,m,"utf8"),e.add(g)}}return[...e]}async function n(a,b,c){let e;try{e=await d.promises.readdir(b,{withFileTypes:!0})}catch{return}for(let g of e){if(g.isDirectory()){if(b===a&&j.has(g.name)||"utilities"===g.name)continue;await n(a,f().join(b,g.name),c);continue}if(!g.name.toLowerCase().endsWith(".md"))continue;let e=f().join(b,g.name);try{let a=await d.promises.stat(e);c.set(e,a.mtimeMs)}catch{}}}async function o(a){try{let b=await d.promises.readFile(a,"utf8");if(!b.startsWith("---"))return{};let c=h()(b).data,e={};return"string"==typeof c.title&&(e.title=c.title),"string"==typeof c.kind&&(e.kind=c.kind),e}catch{return{}}}async function p(a){try{return await d.promises.access(a),!0}catch{return!1}}},64421:(a,b,c)=>{"use strict";function d(a){return p(a,"<<reflex:permission>>","<</reflex:permission>>")}function e(a){let b=p(a,"<<reflex:question>>","<</reflex:question>>"),c=[];for(let a of b)if(a&&"object"==typeof a){if("questions"in a&&Array.isArray(a.questions)){for(let b of a.questions)b&&"object"==typeof b&&"string"==typeof b.prompt&&c.push(b);continue}"string"==typeof a.prompt&&c.push(a)}return c}function f(a){return p(a,"<<reflex:kb>>","<</reflex:kb>>").filter(a=>"string"==typeof a?.kind&&"string"==typeof a?.title)}function g(a){return p(a,"<<reflex:mcp-add>>","<</reflex:mcp-add>>").filter(a=>null!==a&&"object"==typeof a&&"string"==typeof a.server&&"string"==typeof a.label&&"object"==typeof a.config&&null!==a.config)}function h(a){return p(a,"<<reflex:dispatch>>","<</reflex:dispatch>>").filter(a=>null!==a&&"object"==typeof a&&"string"==typeof a.role&&"string"==typeof a.brief&&a.brief.trim().length>0)}function i(a){return p(a,"<<reflex:youtube-summary>>","<</reflex:youtube-summary>>").filter(a=>null!==a&&"object"==typeof a&&"string"==typeof a.url)}function j(a){return p(a,"<<reflex:workflow-create>>","<</reflex:workflow-create>>").filter(a=>!!a&&"object"==typeof a&&"string"==typeof a.id&&"string"==typeof a.label&&Array.isArray(a.steps)&&a.steps.length>0)}function k(a){return p(a,"<<reflex:widget-create>>","<</reflex:widget-create>>").filter(m)}function l(a){return p(a,"<<reflex:widget-update>>","<</reflex:widget-update>>").filter(m)}function m(a){return!!a&&"object"==typeof a&&"string"==typeof a.id&&a.id.length>0&&"string"==typeof a.title&&"string"==typeof a.kind&&!!a.data&&"object"==typeof a.data}function n(a){return p(a,"<<reflex:image-gen>>","<</reflex:image-gen>>").filter(a=>!!a&&"object"==typeof a&&"string"==typeof a.prompt&&a.prompt.trim().length>0)}function o(a){return p(a,"<<reflex:utility>>","<</reflex:utility>>").filter(a=>null!==a&&"object"==typeof a&&("global"===a.scope||"project"===a.scope)&&"object"==typeof a.files&&null!==a.files)}function p(a,b,c){let d=b.replace(/^<+/,"").replace(/>+$/,""),e=c.replace(/^<+/,"").replace(/>+$/,""),f=RegExp(`<{1,2}${q(d)}>{1,2}`,"g"),g=RegExp(`<{1,2}${q(e)}>{1,2}`,"g"),h=[],i=0;for(;i<a.length;){f.lastIndex=i;let b=f.exec(a);if(!b)break;let c=b.index+b[0].length;g.lastIndex=c;let d=g.exec(a);if(!d)break;let e=a.slice(c,d.index).trim();i=d.index+d[0].length;try{h.push(JSON.parse(e))}catch{}}return h}function q(a){return a.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}c.d(b,{Bc:()=>f,Dq:()=>k,Eb:()=>h,Oo:()=>o,QN:()=>j,Up:()=>l,XZ:()=>i,dJ:()=>e,eD:()=>g,gQ:()=>d,qk:()=>n})},68394:(a,b,c)=>{"use strict";c.d(b,{Separator:()=>g});var d=c(64173);c(17240);var e=c(42572),f=c(91344);function g({className:a,orientation:b="horizontal",decorative:c=!0,...g}){return(0,d.jsx)(e.b,{"data-slot":"separator",decorative:c,orientation:b,className:(0,f.cn)("shrink-0 bg-border data-[orientation=horizontal]:h-px data-[orientation=horizontal]:w-full data-[orientation=vertical]:h-full data-[orientation=vertical]:w-px",a),...g})}},69509:(a,b,c)=>{"use strict";c.d(b,{buildRecord:()=>x,iq:()=>p,listWidgets:()=>m,readLayout:()=>t,readWidget:()=>n,reconcileLayout:()=>v,uv:()=>q,writeLayout:()=>u,writeWidget:()=>o});var d=c(73024),e=c(76760),f=c.n(e),g=c(54287),h=c(1405);function i(a){return f().join((0,g.FF)(a),"widgets")}function j(a,b){return f().join(i(a),`${l(b)}.json`)}function k(a){return f().join((0,g.FF)(a),"dashboard-layout.json")}function l(a){return a.replace(/[^A-Za-z0-9_-]/g,"-").slice(0,80)}async function m(a){let b,c=i(a);try{b=await d.promises.readdir(c,{withFileTypes:!0})}catch{return[]}let e=[];for(let a of b)if(a.isFile()&&a.name.toLowerCase().endsWith(".json"))try{let b=await d.promises.readFile(f().join(c,a.name),"utf8"),g=JSON.parse(b);w(g)&&e.push(g)}catch{}return e}async function n(a,b){try{let c=await d.promises.readFile(j(a,b),"utf8"),e=JSON.parse(c);return w(e)?e:null}catch{return null}}async function o(a,b){if(!w(b))throw Error(`Invalid widget record (id=${b.id}, kind=${b.kind})`);await d.promises.mkdir(i(a),{recursive:!0}),await d.promises.writeFile(j(a,b.id),JSON.stringify(b,null,2)+"\n","utf8")}async function p(a,b){try{let c=(0,g.FF)(a),e=f().resolve(c,b),h=f().relative(c,e);if(h.startsWith("..")||f().isAbsolute(h))return null;return await d.promises.readFile(e,"utf8")}catch{return null}}async function q(a,b){try{return await d.promises.unlink(j(a,b)),!0}catch{return!1}}let r={order:["sys:active-goals","sys:pending","sys:recent-kb","sys:ai-suggestions"],hidden:[],sizes:{}},s=new Set(["sm","md","wide"]);async function t(a){try{let b=await d.promises.readFile(k(a),"utf8"),c=JSON.parse(b);if(!Array.isArray(c.order)||!Array.isArray(c.hidden))return r;let e={};if(c.sizes&&"object"==typeof c.sizes)for(let[a,b]of Object.entries(c.sizes))"string"==typeof b&&s.has(b)&&(e[a]=b);return{order:c.order.filter(a=>"string"==typeof a),hidden:c.hidden.filter(a=>"string"==typeof a),sizes:e}}catch{return r}}async function u(a,b){await d.promises.mkdir((0,g.FF)(a),{recursive:!0}),await d.promises.writeFile(k(a),JSON.stringify(b,null,2)+"\n","utf8")}function v(a,b,c){let d=new Set([...b,...c]),e=a.order.filter(a=>d.has(a)),f=a.hidden.filter(a=>d.has(a)),g=new Set([...e,...f]);for(let a of[...c,...b])g.has(a)||e.push(a);let h={};if(a.sizes)for(let[b,c]of Object.entries(a.sizes))d.has(b)&&(h[b]=c);return{order:e,hidden:f,sizes:h}}function w(a){return!!a&&"object"==typeof a&&"string"==typeof a.id&&!!a.id&&"string"==typeof a.title&&"string"==typeof a.kind&&!!h.hU.includes(a.kind)&&!!a.data&&"object"==typeof a.data&&"string"==typeof a.createdAt&&"string"==typeof a.updatedAt&&!0}function x(a){let b=new Date().toISOString(),c=l(a.id);if(!c)throw Error("Widget id is empty after sanitization");if(!h.hU.includes(a.payload.kind))throw Error(`Unknown widget kind: ${a.payload.kind}`);let d=a.refresh??a.existing?.refresh,e=a.memory??a.existing?.memory,f=a.memoryFile??a.existing?.memoryFile,g=a.lastRefreshAt??a.existing?.lastRefreshAt;return{id:c,title:a.title||c,...a.description?{description:a.description}:{},...a.sourceTopicId?{sourceTopicId:a.sourceTopicId}:{},kind:a.payload.kind,data:a.payload.data,createdAt:a.existing?.createdAt??b,updatedAt:b,...a.size?{size:a.size}:a.existing?.size?{size:a.existing.size}:{},...d?{refresh:d}:{},...void 0!==e?{memory:e}:{},...f?{memoryFile:f}:{},...g?{lastRefreshAt:g}:{}}}},70333:(a,b,c)=>{"use strict";c.d(b,{$L:()=>j,CG:()=>k,Lh:()=>o,ND:()=>n,Pc:()=>m,hasApiKey:()=>p});var d=c(73024),e=c(76760),f=c.n(e),g=c(73652);let h=f().join((0,g._)(),"api-keys");function i(a){return f().join(h,`${a}.json`)}async function j(a){try{let b=await d.promises.readFile(i(a),"utf8"),c=JSON.parse(b);if("string"!=typeof c.apiKey||0===c.apiKey.length)return null;return{apiKey:c.apiKey,..."string"==typeof c.model?{model:c.model}:{},..."string"==typeof c.videoModel?{videoModel:c.videoModel}:{},updatedAt:"string"==typeof c.updatedAt?c.updatedAt:new Date().toISOString()}}catch{return null}}async function k(a){let b=await j(a);return b?.apiKey??null}async function l(a,b){let c=i(a);await d.promises.mkdir(f().dirname(c),{recursive:!0}),await d.promises.writeFile(c,JSON.stringify(b,null,2)+"\n",{encoding:"utf8",mode:384});try{await d.promises.chmod(c,384)}catch{}}async function m(a,b){let c=await j(a);await l(a,{...c??{},apiKey:b.trim(),updatedAt:new Date().toISOString()})}async function n(a,b){let c=await j(a);if(!c)throw Error(`API key for "${a}" is not saved`);let d={apiKey:c.apiKey,updatedAt:new Date().toISOString()},e=void 0===b.model?c.model:b.model??void 0,f=void 0===b.videoModel?c.videoModel:b.videoModel??void 0;e&&(d.model=e),f&&(d.videoModel=f),await l(a,d)}async function o(a){try{await d.promises.unlink(i(a))}catch{}}async function p(a){return await k(a)!==null}},71222:(a,b,c)=>{"use strict";c.a(a,async(a,d)=>{try{c.d(b,{Z:()=>j});var e=c(7206),f=c(77598),g=c.n(f),h=c(71700),i=a([e]);e=(i.then?(await i)():i)[0];let l=["Read","LS","Glob","Grep","WebSearch","WebFetch"];async function j(a){let b=await (0,h._)(a.meta.id),c=a.args.allowedTools&&a.args.allowedTools.length>0?a.args.allowedTools:l,d=b?[...c,...b.serverIds.map(a=>`mcp__${a}__*`)]:c,f=["-p",a.args.prompt,"--append-system-prompt",a.args.systemPrompt,"--permission-mode","default","--allowedTools",d.join(","),"--add-dir",a.args.reflexScope,"--output-format","stream-json","--verbose","--model",a.args.model,...b?["--mcp-config",b.path]:[]],i=(0,e.execa)("claude",f,{cwd:a.args.rootPath,buffer:!1,stdin:"ignore"}),j=new Map;try{for await(let b of k(i.stdout)){let c=function(a){try{return JSON.parse(a)}catch{return null}}(b);if(c)for(let b of function(a,b,c){let d=new Date().toISOString();if("system"===a.type)return[{type:"system",text:a.subtype??"system",subtype:a.subtype,agentId:b,ts:d,seq:0}];if("assistant"===a.type){let e=[];for(let f of a.message?.content??[])"text"===f.type?e.push({type:"assistant-delta",text:f.text,agentId:b,ts:d,seq:0}):"tool_use"===f.type&&(c.set(f.id,f.name),e.push({type:"tool-use",toolUseId:f.id,name:f.name,input:f.input??{},agentId:b,ts:d,seq:0}));return e}if("user"===a.type){let h=[];for(let i of a.message?.content??[])if("tool_result"===i.type){var e,f;let a=(e=i.content)?"string"==typeof e?e:e.map(a=>"text"===a.type&&a.text?a.text:"").join(""):"";if(h.push({type:"tool-result",toolUseId:i.tool_use_id,content:a,...i.is_error?{isError:!0}:{},agentId:b,ts:d,seq:0}),i.is_error){let e=c.get(i.tool_use_id)??function(a){let b=/requested permissions to use\s+([A-Za-z_]\w*)/i.exec(a);if(b?.[1])return b[1];if(/requested permissions to write\b/i.test(a))return"Write";if(/requested permissions to edit\b/i.test(a))return"Edit";if(/requested permissions to run\b/i.test(a))return"Bash";if(/requested permissions to read\b/i.test(a))return"Read";let c=/permission .* tool[:\s]+([A-Za-z_]\w*)/i.exec(a);return c?.[1]??null}(a);if(e){let c=function(a){let b=/requested permissions to (?:write to|edit|read)\s+(\S+?)(?:,|\s+but\b|\s*$)/i.exec(a)??/requested permissions to run\s+(.+?)(?:,\s+but\b|\s*$)/i.exec(a);return b?.[1]?.trim()??null}(a);h.push({type:"permission-request",requestId:g().randomUUID().replace(/-/g,"").slice(0,12),tool:e,action:"tool-policy",...c?{input:{target:c}}:{},description:c?`The agent wants to ${f=e,"Write"===f?"write to":"Edit"===f||"MultiEdit"===f?"edit":"Read"===f?"read":"Bash"===f?"run a command":"NotebookEdit"===f?"edit a notebook":"WebFetch"===f?"fetch a URL":"WebSearch"===f?"search the web":"use"} \`${c}\` via "${e}". Allow?`:`The agent tried to call the "${e}" tool, but it is not in the allowed list for this task. Allow?`,agentId:b,ts:d,seq:0})}}}return h}return a.type,[]}(c,a.meta.id,j))await a.manager.emit(b)}await i}finally{b&&await b.cleanup()}}async function*k(a){if(!a)return;let b="";for await(let c of a){let a;for(b+="string"==typeof c?c:c.toString("utf8");(a=b.indexOf("\n"))>=0;){let c=b.slice(0,a);b=b.slice(a+1),c.trim()&&(yield c)}}b.trim()&&(yield b)}d()}catch(a){d(a)}})},71700:(a,b,c)=>{"use strict";c.d(b,{_:()=>k});var d=c(73024),e=c(48161),f=c.n(e),g=c(76760),h=c.n(g),i=c(580),j=c(97453);async function k(a){let b=await (0,i.listMcpServers)();if(0===b.length)return null;let c={};for(let a of b)if("stdio"===a.config.transport){let b=await (0,j.Jc)(a.config.env);c[a.id]={command:a.config.command,args:a.config.args,env:b}}else if("http"===a.config.transport){let b=await (0,j.Jc)(a.config.headers);c[a.id]={type:"http",url:a.config.url,...Object.keys(b).length>0?{headers:b}:{}}}else{let b=await (0,j.Jc)(a.config.headers);c[a.id]={type:"sse",url:a.config.url,...Object.keys(b).length>0?{headers:b}:{}}}let e=await d.promises.mkdtemp(h().join(f().tmpdir(),`reflex-mcp-${a}-`)),g=h().join(e,"mcp.json");return await d.promises.writeFile(g,JSON.stringify({mcpServers:c},null,2),"utf8"),{path:g,serverIds:b.map(a=>a.id),cleanup:async()=>{try{await d.promises.rm(e,{recursive:!0,force:!0})}catch{}}}}},73652:(a,b,c)=>{"use strict";c.d(b,{_:()=>h});var d=c(48161),e=c.n(d),f=c(76760),g=c.n(f);function h(){let a=process.env.REFLEX_HOME;return a&&a.length>0?a:g().join(e().homedir(),".reflex")}},73928:(a,b,c)=>{"use strict";c.d(b,{L6:()=>o,bp:()=>p,listWorkflows:()=>l,lq:()=>r,ni:()=>k,r$:()=>n,readWorkflow:()=>m,v:()=>q});var d=c(73024),e=c(76760),f=c.n(e),g=c(54287);function h(a){return f().join((0,g.FF)(a),"workflows")}function i(a,b){return f().join(h(a),`${k(b)}.json`)}function j(a,b){return f().join(h(a),"runs",k(b))}function k(a){return a.replace(/[^A-Za-z0-9_-]/g,"-").slice(0,80)}async function l(a){let b,c=h(a);try{b=await d.promises.readdir(c,{withFileTypes:!0})}catch{return[]}let e=[];for(let a of b)if(a.isFile()&&a.name.toLowerCase().endsWith(".json"))try{let b=await d.promises.readFile(f().join(c,a.name),"utf8"),g=JSON.parse(b);s(g)&&e.push(g)}catch{}return e.sort((a,b)=>a.updatedAt<b.updatedAt?1:-1),e}async function m(a,b){try{let c=await d.promises.readFile(i(a,b),"utf8"),e=JSON.parse(c);return s(e)?e:null}catch{return null}}async function n(a,b){if(!s(b))throw Error(`Invalid workflow (id=${b.id})`);await d.promises.mkdir(h(a),{recursive:!0}),await d.promises.writeFile(i(a,b.id),JSON.stringify(b,null,2)+"\n","utf8")}async function o(a,b){try{await d.promises.unlink(i(a,b));try{await d.promises.rm(j(a,b),{recursive:!0,force:!0})}catch{}return!0}catch{return!1}}async function p(a,b){var c,e;await d.promises.mkdir(j(a,b.workflowId),{recursive:!0}),await d.promises.writeFile((c=b.workflowId,e=b.id,f().join(j(a,c),`${k(e)}.json`)),JSON.stringify(b,null,2)+"\n","utf8")}async function q(a,b,c=20){let e,g=j(a,b);try{e=await d.promises.readdir(g,{withFileTypes:!0})}catch{return[]}let h=(await Promise.all(e.filter(a=>a.isFile()&&a.name.toLowerCase().endsWith(".json")).map(async a=>{let b=f().join(g,a.name);try{let a=await d.promises.stat(b);return{abs:b,mtime:a.mtimeMs}}catch{return null}}))).filter(a=>null!==a).sort((a,b)=>b.mtime-a.mtime).slice(0,c),i=[];for(let a of h)try{let b=await d.promises.readFile(a.abs,"utf8");i.push(JSON.parse(b))}catch{}return i}async function r(a,b){let c,e=j(a,b);try{c=await d.promises.readdir(e,{withFileTypes:!0})}catch{return}for(let a of(await Promise.all(c.filter(a=>a.isFile()&&a.name.toLowerCase().endsWith(".json")).map(async a=>{let b=f().join(e,a.name);try{let a=await d.promises.stat(b);return{abs:b,mtime:a.mtimeMs}}catch{return null}}))).filter(a=>null!==a).sort((a,b)=>b.mtime-a.mtime).slice(50))await d.promises.unlink(a.abs).catch(()=>void 0)}function s(a){return!!a&&"object"==typeof a&&"string"==typeof a.id&&!!a.id&&"string"==typeof a.label&&!!Array.isArray(a.steps)&&"string"==typeof a.createdAt&&"string"==typeof a.updatedAt}},78555:(a,b,c)=>{"use strict";c.d(b,{a$:()=>i,ht:()=>h});var d=c(56149);let e=d.Ik({"claude-code":d.Ik({enabled:d.zM().default(!0)}),codex:d.Ik({enabled:d.zM().default(!0)}),ollama:d.Ik({enabled:d.zM().default(!0),baseUrl:d.Yj().url().default("http://localhost:11434")})}),f=d.Ik({harness:d.k5(["claude-code","codex","ollama"]),model:d.Yj().min(1),allowedTools:d.YO(d.Yj()).default([])}),g=d.Ik({enabled:d.zM().default(!0),maxDimension:d.ai().int().min(256).max(8192).default(2e3),quality:d.ai().int().min(40).max(100).default(85),format:d.k5(["auto","jpeg","webp","original"]).default("auto")}),h=d.Ik({version:d.eu(1).default(1),language:d.Yj().min(1).default("en"),onboardedAt:d.Yj().optional(),userName:d.Yj().default(""),timezone:d.Yj().default(""),uiMode:d.k5(["simple","advanced"]).default("simple"),imageProcessing:g.default({enabled:!0,maxDimension:2e3,quality:85,format:"auto"}),harnesses:e.default({"claude-code":{enabled:!0},codex:{enabled:!0},ollama:{enabled:!0,baseUrl:"http://localhost:11434"}}),assignments:d.Ik({analyze:f,chat:f,rag:f,embed:f,quick:f}).default({analyze:{harness:"claude-code",model:"claude-opus-4-7",allowedTools:["Read","Write","Edit","LS","Glob","Grep","WebSearch","WebFetch"]},chat:{harness:"claude-code",model:"claude-sonnet-4-6",allowedTools:["Read","LS","Glob","Grep","WebSearch","WebFetch"]},rag:{harness:"ollama",model:"llama3.1:8b",allowedTools:[]},embed:{harness:"ollama",model:"nomic-embed-text",allowedTools:[]},quick:{harness:"claude-code",model:"claude-haiku-4-5",allowedTools:[]}}),mapServices:d.Ik({enabled:d.YO(d.Yj()).default(["google","yandex","apple","osm"])}).default({enabled:["google","yandex","apple","osm"]}),ngrok:d.Ik({authtoken:d.Yj().default(""),apiKey:d.Yj().default(""),domain:d.Yj().default(""),port:d.ai().int().min(1).max(65535).default(3210)}).default({authtoken:"",apiKey:"",domain:"",port:3210})}),i=h.parse({})},78744:(a,b,c)=>{"use strict";c.d(b,{p:()=>i,M:()=>j});var d=c(76760),e=c.n(d),f=c(28548);function g(a,b){return a.replace(/\{\{\s*([a-zA-Z_][a-zA-Z0-9_]*)\s*\}\}/g,(a,c)=>{let d=b[c];return void 0===d?a:String(d)})}let h="english";async function i(a){let b=await (0,f.PM)("analyze"),c=e().relative(a.root,a.scope)||".",d=a.files.slice(0,400),i=a.files.length>400?`
|
|
414
|
+
…and ${a.files.length-400} more files (truncated).`:"";return g(b,{language:a.language??h,root:a.root,scope:a.scope,relScope:c,reflexScope:a.reflexScope,files:d.map(a=>` - ${a}`).join("\n"),fileCount:a.files.length,overflow:i})}async function j(a){return[g(await (0,f.PM)("chat"),{language:a.language??h,root:a.root,scope:a.scope,reflexScope:a.reflexScope}),'## Routing: you are an orchestrator, not the worker\n\nFor anything non-trivial (deep KB reading, multi-file research, code writes, utility creation, summarization of large texts) — DELEGATE to a specialist sub-agent instead of doing it yourself. Sub-agents run with a focused system prompt and a constrained toolset.\n\nAvailable roles:\n - **researcher** — read-only KB / web research. Use for "find / gather / quote".\n - **coder** — writes/edits files (Write/Edit + read tools). Use for "do / fix / create a file".\n - **summarizer** — no tools; compresses long text from the brief. Use for "compress / extract the main points" from a large chunk.\n - **kb-writer** — designs a structured KB entry (returns JSON for <<reflex:kb>>). Use when something is worth saving but the shape is non-trivial.\n - **utility-builder** — designs a Reflex utility (manifest + ui.tsx). Use when the user asks to build a new utility.\n\nTo dispatch, emit one or more markers in a single turn and STOP:\n\n <<reflex:dispatch>>{"id":"r1","role":"researcher","brief":"Read INDEX.md and collect a list of topics."}<</reflex:dispatch>>\n\nRules:\n - `brief` must be self-contained — sub-agents do NOT see the chat transcript. Include all rel-paths, expected output shape, constraints.\n - Multiple dispatches in one turn run **concurrently**. Sequentially-dependent tasks → do them across multiple turns.\n - After dispatches Reflex re-invokes you with each sub-agent\'s output quoted. Compose the final user-facing reply from those results.\n - Do simple things yourself (one short answer, citing one file). Don\'t dispatch trivia.\n - Don\'t re-dispatch the same brief if a sub-agent returned empty — either solve it yourself or ask the user.\n\nOptional harness routing:\n - Add `"harness":"codex"` to the dispatch payload to run THAT sub-agent on Codex instead of inheriting yours. Useful when:\n – task is heavy code synthesis / refactor / type-fixing — Codex shines there.\n – task is short text classification / extraction — `"harness":"ollama"` is cheap and fast.\n - Without `harness`, the sub-agent inherits the orchestrator\'s runtime — usually fine. Override only when you have a concrete reason.\n - Example: `<<reflex:dispatch>>{"role":"coder","harness":"codex","brief":"Rewrite X in TypeScript strict mode"}<</reflex:dispatch>>`','## Widgets: putting results on the project dashboard\n\nWhen the user wants you to produce something durable — a news digest, a checklist, a KPI snapshot, a curated link list — DON\'T just answer in chat and forget. Materialize it as a **widget** on the project dashboard so the user sees it on every visit.\n\nEmit a marker on its own block:\n\n```\n<<reflex:widget-create>>{\n "id": "<kebab-case-id>",\n "title": "<short user-visible title>",\n "description": "<one-line subtitle, optional>",\n "kind": "<one of: markdown, news-list, link-list, kpi, checklist, quote, kb-pinned, progress, image, stat-table, map>",\n "data": { ...kind-specific payload... },\n "size": { "mode": "md" }\n}<</reflex:widget-create>>\n```\n\nUse `widget-update` (same shape, same id) when refreshing an existing widget — e.g. user asked for a weekly news digest, you regenerate the items.\n\n### Auto-refresh and memory\n\n- `refresh`: `"manual"` (default) | `"hourly"` | `"daily"` | `"weekly"`. When set to anything other than manual, Reflex\'s scheduler will periodically re-invoke you on the source topic with a synthetic `[Reflex] Refresh widget <id>` user-message — you respond by emitting a fresh `<<reflex:widget-update>>` with the same id.\n- `memory`: agent-managed inline state (markdown, <2KB). Use for **short** state that should persist across refreshes — e.g. "already-shown URLs to dedupe", "last 4 KPI snapshots", "running tally". On every refresh prompt you\'ll see the current `memory` value; emit an updated one inside the widget-update payload.\n- `memoryFile`: rel-path (inside `.reflex/`) for **long** memory — a journal-style markdown file you append to via the regular `<<reflex:kb>>` directive. Use for OKR-history-style widgets where the journal itself is worth keeping in the KB tree. Pick a path like `widgets/<widget-id>.memory.md`.\n- Pick ONE of `memory` or `memoryFile` per widget. Inline for compact structured deduping; file for narrative history.\n- When refreshing, prefer **incremental** updates: dedupe against memory, add new items at the top, drop very old ones — the user wants signal, not a snapshot reset.\n\n### Kinds and `data` shapes\n\n- `markdown` — `{body: string}`. Long-form notes, summaries, instructions.\n- `news-list` — `{items: [{title, url?, summary?, source?, date?}]}`. Headlines + 1-2 line summaries.\n- `link-list` — `{items: [{title, url, hint?}]}`. Curated resources, bookmarks.\n- `kpi` — `{items: [{label, value, hint?, delta?: "up"|"down"|"flat"}]}`. Big-number tiles.\n- `checklist` — `{items: [{text, done?: boolean}]}`. Action items / todo.\n- `quote` — `{text, attribution?}`. One memorable quote.\n- `kb-pinned` — `{items: [{rel, title?, snippet?}]}`. Pinned KB rel-paths.\n- `progress` — `{items: [{label, current, target, unit?}]}`. Goal-tracking bars.\n- `image` — `{url, alt?, caption?}`. Single image card.\n- `stat-table` — `{columns?: [string], rows: [[string, ...]]}`. Compact comparison table.\n- `map` — `{points: [{lat, lng, title, description?}], center?, zoom?, route?: {stops: number[], color?, mode?}}`. Map with points + an optional route (polyline + multi-waypoint deep-links: google/yandex/2gis/apple/osm/waze/organic). `route.stops` — array of indices in `points` in traversal order (minimum 2). Each point gets a popup with branded service buttons. By default the map auto-fits to the points. IMPORTANT: `lat`/`lng` are numbers in decimal degrees (lat=55.7558, lng=37.6173 — Moscow). NOT strings. If you have an address — find coordinates via WebSearch/WebFetch (geocoding); don\'t invent them. The user can search for places (Nominatim) and build a route right in the widget — the "Route" button switches to point-pick-by-click mode.\n\n### Interactivity\n\nDashboard widgets are interactive — the user can, right in the UI:\n - **checklist**: tick checkboxes (toggle done), delete items, add new ones.\n - **link-list**: delete links.\n - **news-list**: mark a news item as read (`read:true`), remove the card.\n - **kb-pinned**: unpin files.\n - **progress**: \xb1 buttons on `current`.\n\nThese changes are written straight to disk, bypassing you. On the next `widget-update` you\'ll see the current state. Strategy:\n - If the user deleted a checklist item — don\'t add it back (that\'s a signal).\n - If the user marked a news item as read — record its URL in `memory` for dedup.\n - If the user reset progress — apparently it\'s a new cycle; respect it.\n\n### Rules\n\n- Pick the SIMPLEST kind that fits — don\'t squeeze a news digest into `markdown` if `news-list` exists.\n- `id` is stable: same id across `widget-create` and `widget-update`. Pick a slug from the topic content (e.g. `tech-news-weekly`, `okrs-q2`).\n- `size.mode`: `"sm"` (3 per row, icons/KPI) | `"md"` (default, 2 per row) | `"wide"` (full row, for long tables/markdown). Match it to the content, but the user can override via the UI — your choice is only a hint.\n- After emitting the marker, briefly tell the user in plain text WHAT widget you assembled. IMPORTANT: a new widget does NOT appear on the dashboard automatically — it sits in the library as a draft. The user sees it right in the chat (preview) and can pin it with the "Pin to dashboard" button or via the library. Don\'t claim the widget is already on the dashboard.\n- Reflex automatically shows a live preview of the widget inside this chat turn — no need to re-render in markdown.',`## Workflows — built-in "n8n for non-techies"
|
|
415
|
+
|
|
416
|
+
When the user wants to automate something recurring (morning digest, page monitor, "fetch → process → save" routine), emit a \`<<reflex:workflow-create>>\` marker — Reflex will save the workflow to disk and show a preview with a link to the editor.
|
|
417
|
+
|
|
418
|
+
\`\`\`
|
|
419
|
+
<<reflex:workflow-create>>{
|
|
420
|
+
"id": "<kebab-case-id>",
|
|
421
|
+
"label": "<short title>",
|
|
422
|
+
"description": "<one line>",
|
|
423
|
+
"trigger": "manual" | "hourly" | "daily" | "weekly",
|
|
424
|
+
"steps": [
|
|
425
|
+
{"id": "fetch", "kind": "web-fetch", "label": "Fetch HN", "params": {"url": "https://news.ycombinator.com/rss"}},
|
|
426
|
+
{"id": "digest", "kind": "ask-agent", "label": "Compress into digest", "params": {"prompt": "Summarize the top 5 headlines from the RSS:\\n{{prev}}"}},
|
|
427
|
+
{"id": "save", "kind": "kb-write", "label": "Write to KB", "params": {"kind": "digest", "title": "HN digest", "body": "{{prev}}"}}
|
|
428
|
+
]
|
|
429
|
+
}<</reflex:workflow-create>>
|
|
430
|
+
\`\`\`
|
|
431
|
+
|
|
432
|
+
### Available step \`kind\`s
|
|
433
|
+
|
|
434
|
+
- \`text-template\` — \`{template: string}\`. Substitutions: \`{{prev}}\`, \`{{steps.<id>.output}}\`, \`{{input.<field>}}\`, \`{{workflow.label}}\`.
|
|
435
|
+
- \`http-request\` — \`{url, method?, headers?: string-JSON, body?}\`. Output: text or JSON (by content-type).
|
|
436
|
+
- \`web-fetch\` — \`{url}\`. Simple GET; output is the response text.
|
|
437
|
+
- \`ask-agent\` — \`{prompt}\`. Runs a headless orchestrator and returns the response text. Use for summarization, paraphrasing, classification.
|
|
438
|
+
- \`kb-write\` — \`{kind, title, body}\`. Saves to the knowledge base as a regular KB file.
|
|
439
|
+
|
|
440
|
+
### Rules
|
|
441
|
+
|
|
442
|
+
- Each step passes its output to the next via \`{{prev}}\` or \`{{steps.<id>.output}}\`. This is the only link between steps.
|
|
443
|
+
- A step's \`id\` must be stable and kebab-case — templates reference it.
|
|
444
|
+
- Steps run strictly sequentially. If a step fails — the rest won't run, and the run is marked failed.
|
|
445
|
+
- Keep workflows SHORT (3-5 steps). If the task is larger — split it into several workflows or let the agent handle the complex part via \`ask-agent\`.
|
|
446
|
+
- Trigger defaults to \`manual\`. \`hourly\`/\`daily\`/\`weekly\` currently work only via manual launch; the scheduler is in progress.
|
|
447
|
+
- After emitting the marker — a short message to the user: what you assembled, how to run it, where to edit it.`,'## Generating images inline\n\nWhen the user asks to draw, generate, or illustrate something ("draw a cat", "make an illustration", "generate a preview"), DON\'T describe what you\'d draw — emit an image-gen marker and Reflex will render the actual image inside your reply.\n\n```\n<<reflex:image-gen>>{\n "prompt": "detailed prompt describing the picture",\n "provider": "gemini",\n "aspectRatio": "16:9",\n "caption": "short caption (optional)",\n "attachToKb": false\n}<</reflex:image-gen>>\n```\n\n- `provider`: `"gemini"` (Nano Banana, default, cheap and fast) or `"codex"` (via `$imagegen` in Codex CLI).\n- `aspectRatio`: `"1:1"`, `"16:9"`, `"9:16"`, `"4:3"`, etc. Optional.\n- `attachToKb: true` — also save the image to the KB as `kind: "image"` for future reuse.\n- You can emit multiple markers in one reply — that produces N images in a row.\n- Write a detailed prompt: style (photorealism / watercolor / 3D / illustration), composition, lighting, mood. The more specific — the better the result.\n- DO NOT describe in words "here is a picture of a cat" — just emit the marker; Reflex inserts the image into your reply itself.'].join("\n\n")}},79459:(a,b,c)=>{"use strict";c.r(b),c.d(b,{default:()=>m,dynamic:()=>k,metadata:()=>l});var d=c(63003),e=c(29373),f=c(87557),g=c(50359);c(44427);var h=c(95422),i=c(30849),j=c(24576);let k="force-dynamic",l={title:"Reflex",description:"Local-first knowledge base built by an agent."};async function m({children:a}){let b=await (0,j.qV)(),c=await (0,f.A)(),k=await (0,g.A)();return(0,d.jsx)("html",{lang:c,suppressHydrationWarning:!0,children:(0,d.jsx)("body",{children:(0,d.jsxs)(e.A,{locale:c,messages:k,children:[(0,d.jsxs)("div",{className:"h-screen flex",children:[(0,d.jsx)(i.AppSidebar,{initialRoots:b}),(0,d.jsx)("main",{className:"flex-1 min-w-0 flex flex-col",children:a})]}),(0,d.jsx)(h.Toaster,{richColors:!0,closeButton:!0})]})})})}},84579:(a,b,c)=>{"use strict";c.d(b,{attachRemote:()=>k,generateImage:()=>h,searchImages:()=>i});var d=c(91388),e=c(70333);async function f(a){let b=await (0,e.CG)("gemini");if(!b)throw Error("Gemini API key is not configured. Open Settings → Gemini.");let c=[{text:a.prompt}];for(let b of a.referenceImageUrls??[]){let a=await g(b);a&&c.push({inlineData:a})}let f={contents:[{role:"user",parts:c}]};a.aspectRatio&&(f.generationConfig={imageConfig:{aspectRatio:a.aspectRatio}});let h=await fetch(`https://generativelanguage.googleapis.com/v1beta/models/gemini-2.5-flash-image-preview:generateContent?key=${encodeURIComponent(b)}`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(f)});if(!h.ok){let a=await h.text().catch(()=>"");throw Error(`Gemini image API ${h.status}: ${a.slice(0,400)}`)}let i=await h.json(),j=function(a){for(let b of a.candidates??[])for(let a of b.content?.parts??[]){let b=a.inlineData;if(b?.data&&b.mimeType?.startsWith("image/"))return{data:b.data,mime:b.mimeType}}return null}(i);if(!j){let a=i?.candidates?.[0]?.finishReason??"no image returned",b=i?.candidates?.[0]?.content?.parts?.map(a=>a.text).filter(Boolean).join(" ")?.slice(0,300);throw Error(`Gemini returned a non-image response (${a})${b?": "+b:""}`)}let k=Buffer.from(j.data,"base64");return(0,d.YN)(a.rootId,k,j.mime)}async function g(a){try{let b=await fetch(a,{redirect:"follow"});if(!b.ok)return null;let c=b.headers.get("content-type")?.split(";")[0]?.trim()??"";if(!c.startsWith("image/"))return null;let d=await b.arrayBuffer();return{data:Buffer.from(d).toString("base64"),mimeType:c}}catch{return null}}async function h(a){let b,d=a.provider??"gemini";if("gemini"===d)b=await f({rootId:a.rootId,prompt:a.prompt,...a.aspectRatio?{aspectRatio:a.aspectRatio}:{},...a.referenceImageUrls?{referenceImageUrls:a.referenceImageUrls}:{}});else if("codex"===d){let d=await c.e(1961).then(c.bind(c,61961));b=await d.generateWithCodex({rootId:a.rootId,prompt:a.prompt,...a.size?{size:a.size}:{}})}else throw Error(`unknown image provider: ${d}`);return{urlPath:b.urlPath,sha:b.sha,mime:b.mime,size:b.size,provider:d}}async function i(a){let b=Math.max(1,Math.min(24,a.count??12)),d=a.provider??await j();if("unsplash"===d)return(await c.e(7508).then(c.bind(c,57508))).searchUnsplash({query:a.query,count:b});if("pexels"===d)return(await c.e(5087).then(c.bind(c,95087))).searchPexels({query:a.query,count:b});if("brave"===d)return(await c.e(8262).then(c.bind(c,48262))).searchBrave({query:a.query,count:b});throw Error(`unknown image search provider: ${d}`)}async function j(){let{hasApiKey:a}=await Promise.resolve().then(c.bind(c,70333)),{resolveBraveKey:b}=await c.e(8262).then(c.bind(c,48262));return await b()?"brave":await a("unsplash")?"unsplash":await a("pexels")?"pexels":"brave"}async function k(a){return(0,d.fH)(a.rootId,a.sourceUrl)}},88724:(a,b,c)=>{"use strict";c.d(b,{$d:()=>e,S9:()=>f,Zi:()=>d}),c(17240);let d={rootsChanged:"reflex:roots-changed",topicsChanged:a=>`reflex:topics-changed:${a}`,kbChanged:a=>`reflex:kb-changed:${a}`};function e(a,b){}function f(a,b){}},91344:(a,b,c)=>{"use strict";c.d(b,{cn:()=>f});var d=c(53221),e=c(25813);function f(...a){return(0,e.QP)((0,d.$)(a))}},91388:(a,b,c)=>{"use strict";c.d(b,{YN:()=>p,fH:()=>q,tf:()=>m});var d=c(73024),e=c(76760),f=c.n(e),g=c(77598),h=c.n(g),i=c(53905);let j=f().join(".reflex","assets","images"),k={"image/png":"png","image/jpeg":"jpg","image/jpg":"jpg","image/webp":"webp","image/gif":"gif","image/svg+xml":"svg","image/avif":"avif"},l={png:"image/png",jpg:"image/jpeg",jpeg:"image/jpeg",webp:"image/webp",gif:"image/gif",svg:"image/svg+xml",avif:"image/avif"};function m(a){return l[a.toLowerCase()]??"application/octet-stream"}async function n(a){let b=await (0,i.Zn)(a);if(!b)throw Error(`unknown root: ${a}`);return b.path}async function o(a){let b=f().join(await n(a),j);return await d.promises.mkdir(b,{recursive:!0}),b}async function p(a,b,c){let e=Buffer.isBuffer(b)?b:Buffer.from(b),g=h().createHash("sha256").update(e).digest("hex"),i=k[c.toLowerCase()]??"bin",l=await o(a),m=f().join(l,`${g}.${i}`);try{await d.promises.access(m)}catch{await d.promises.writeFile(m,e)}return{sha:g,ext:i,mime:c,absPath:m,relPath:f().posix.join(j.split(f().sep).join("/"),`${g}.${i}`),urlPath:`/api/images/${encodeURIComponent(a)}/${g}.${i}`,size:e.byteLength}}async function q(a,b){let c=await fetch(b,{redirect:"follow",signal:AbortSignal.timeout(3e4)});if(!c.ok)throw Error(`fetch ${b} -> ${c.status} ${c.statusText}`);let d=c.headers.get("content-type")?.split(";")[0]?.trim()??"";if(!d.startsWith("image/"))throw Error(`not an image: content-type=${d||"(none)"}`);let e=Number(c.headers.get("content-length")??"0");if(e>0x1400000)throw Error(`image too large: ${e} bytes (cap 20971520)`);let f=await c.arrayBuffer();if(f.byteLength>0x1400000)throw Error(`image too large after download: ${f.byteLength} bytes (cap 20971520)`);return p(a,Buffer.from(f),d)}},92185:(a,b,c)=>{"use strict";c.d(b,{Ay:()=>i});var d=c(73024),e=c(76760),f=c.n(e),g=c(47e3),h=c(17640);let i=(0,g.A)(async()=>{let a=function(a){if(!a)return"en";let b=a.toLowerCase();return"ru"===b||"russian"===b||b.startsWith("ru-")?"ru":"en"}((await (0,h.M)()).language),b=await j(a);return{locale:a,messages:b}});async function j(a){let b=f().resolve(process.cwd(),"messages",a),c=[];try{c=(await d.promises.readdir(b)).filter(a=>a.endsWith(".json"))}catch{return{}}let e={};for(let a of c){let c=a.replace(/\.json$/,"");try{let g=await d.promises.readFile(f().join(b,a),"utf8");e[c]=JSON.parse(g)}catch{}}return e}},93437:(a,b,c)=>{Promise.resolve().then(c.t.bind(c,47319,23)),Promise.resolve().then(c.t.bind(c,97654,23)),Promise.resolve().then(c.t.bind(c,10432,23)),Promise.resolve().then(c.t.bind(c,73671,23)),Promise.resolve().then(c.t.bind(c,78767,23)),Promise.resolve().then(c.t.bind(c,75751,23)),Promise.resolve().then(c.t.bind(c,48609,23)),Promise.resolve().then(c.t.bind(c,59118,23)),Promise.resolve().then(c.t.bind(c,84583,23))},93554:(a,b,c)=>{"use strict";c.a(a,async(a,d)=>{try{c.d(b,{z:()=>G});var e=c(78474),f=c(77598),g=c(20243),h=c(71222),i=c(52219),j=c(98360),k=c(59788),l=c(64421),m=c(84579),n=c(69509),o=c(73928),p=c(55143),q=c(56942),r=c(63848),s=c(20938),t=c(20050),u=c(8118),v=c(36017),w=c(5492),x=c(875),y=c(18809),z=a([h,p]);[h,p]=z.then?(await z)():z;class E{async ensureAgent(a){let b=this.byTopicRole.get(a.topicId)?.get(a.role);if(b){let a=this.agents.get(b);if(a)return{...a.meta}}return this.createAgent(a)}async createAgent(a){let b=C(),c={id:b,topicId:a.topicId,rootId:a.rootId,role:a.role,task:a.task,harness:a.harness,model:a.model,label:a.label,status:"idle",startedAt:A(),...a.parentId?{parentId:a.parentId}:{}};this.agents.set(b,{meta:c,rootPath:a.rootPath,reflexScope:a.reflexScope});let d=this.byTopicRole.get(a.topicId);return d||(d=new Map,this.byTopicRole.set(a.topicId,d)),d.set(a.role,b),await this.emit({type:"agent-start",meta:c,agentId:b,ts:c.startedAt,seq:0}),c}async invoke(a){let b=this.agents.get(a.agentId);if(!b)throw Error(`Agent not found: ${a.agentId}`);if("running"===b.meta.status)throw Error(`Agent ${a.agentId} is already running`);b.meta.status="running",this.lastInvoke.set(a.agentId,{systemPrompt:a.systemPrompt,rootPath:b.rootPath}),this.turnText.set(a.agentId,"");let c=C();a.userMessage&&await this.emit({type:"user-message",text:a.userMessage,agentId:a.agentId,ts:A(),seq:0}),await this.emit({type:"turn-start",turnId:c,agentId:a.agentId,ts:A(),seq:0});let d=null;try{d=await (0,r.Qr)(b.rootPath)}catch{}try{let e={meta:{id:b.meta.id},args:{rootPath:b.rootPath,reflexScope:b.reflexScope,systemPrompt:a.systemPrompt,prompt:a.prompt,model:b.meta.model,allowedTools:a.allowedTools??[]},manager:this};if("claude-code"===b.meta.harness)await (0,h.Z)(e);else if("codex"===b.meta.harness)await (0,i.H)(e);else if("ollama"===b.meta.harness)await (0,j.E)(e);else if("image-gen"===b.meta.harness)await (0,k.R)({meta:e.meta,args:{rootPath:e.args.rootPath,prompt:e.args.prompt},manager:e.manager});else throw Error(`Unsupported harness: ${String(b.meta.harness)}`);await this.applyImageGenDirectives(a.agentId);let f=await this.evaluateGoalContinuation(a.agentId);b.meta.status="idle",await this.emit({type:"turn-end",turnId:c,status:"completed",agentId:a.agentId,ts:A(),seq:0});let{writtenViaKb:g,dispatches:l,youtubeSummaries:m}=await this.detectInteractionDirectives(a.agentId);d&&await this.reindexAfterTurn(a.agentId,d,g),l.length>0&&"orchestrator"===b.meta.role?this.dispatchSubAgents(a.agentId,l).catch(b=>{this.emit({type:"error",message:"sub-agent dispatch failed: "+(b instanceof Error?b.message:String(b)),agentId:a.agentId,ts:A(),seq:0})}):m.length>0&&"orchestrator"===b.meta.role?this.runYoutubeSummaries(a.agentId,m).catch(b=>{this.emit({type:"error",message:"youtube-summary failed: "+(b instanceof Error?b.message:String(b)),agentId:a.agentId,ts:A(),seq:0})}):f&&setTimeout(()=>{this.continueTurn(a.agentId,`[Reflex /goal] Continue execution. Active goal: ${f.goal}. Iteration ${f.iteration}/${x.GX}. If the task is done AND verified, finish with the marker \`GOAL ACHIEVED\` and a kb-entry kind:"goal-completion".`)},50)}catch(e){let d=e instanceof Error?e.message:String(e);b.meta.status="idle",b.meta.error=d,await this.emit({type:"error",message:d,agentId:a.agentId,ts:A(),seq:0}),await this.emit({type:"turn-end",turnId:c,status:"failed",error:d,agentId:a.agentId,ts:A(),seq:0})}finally{this.turnText.delete(a.agentId)}}async respondPermission(a,b){let c,d=this.agents.get(a);if(!d)throw Error("Agent not found");let e="running"===d.meta.status;try{let a=(await (0,g.readEvents)(d.rootPath,d.meta.topicId)).find(a=>"permission-request"===a.type&&a.requestId===b.requestId);c=a?.action}catch{}await this.emit({type:"permission-response",requestId:b.requestId,decision:b.decision,...b.scope?{scope:b.scope}:{},agentId:a,ts:A(),seq:0});let f="";if("tool-policy"===c&&"allow"===b.decision&&b.tool)try{let a=await (0,v.M)(),c=d.meta.task,e=a.assignments[c];e&&!e.allowedTools.includes(b.tool)&&(e.allowedTools=[...e.allowedTools,b.tool],await (0,v.D)(a),f=` Tool ${b.tool} added to settings.assignments.${c}.allowedTools.`)}catch(b){await this.emit({type:"error",message:"Failed to save allowed tool: "+(b instanceof Error?b.message:String(b)),agentId:a,ts:A(),seq:0})}let h=`[Reflex] Permission for ${b.tool??"action"} (${b.requestId}): ${b.decision}${b.scope?` (${b.scope})`:""}.${f} Continue.`;e||await this.continueTurn(a,h)}async respondQuestion(a,b){let c=this.agents.get(a);if(!c)throw Error("Agent not found");let d="running"===c.meta.status;await this.emit({type:"answer",questionId:b.questionId,answer:b.answer,agentId:a,ts:A(),seq:0});let e=`[Reflex] Answer for question ${b.questionId}: ${b.answer}. Continue.`;d||await this.continueTurn(a,e)}async respondMcpAdd(a,b){let d,e=this.agents.get(a),f=!!(e&&"running"===e.meta.status),h=null,i=e?.meta.topicId??null,j=e?.rootPath??null,k=this.pendingMcpAdds.get(b.requestId);if(k&&k.agentId===a)h=k.directive,this.pendingMcpAdds.delete(b.requestId);else{let a=await (0,s.az)(b.requestId);a&&(h=a.directive,i=i??a.topicId,j=j??a.rootPath)}if(!h)throw Error(`Unknown mcp-add request: ${b.requestId}`);let l=async a=>{if(e)return void await this.emit(a);if(i&&j){let b=await (0,g.v)(j,i);await (0,g.Zn)(j,i,{...a,seq:b})}};if("reject"===b.decision){await l({type:"mcp-add-response",requestId:b.requestId,decision:"reject",agentId:a,ts:A(),seq:0}),d=`[Reflex] User rejected adding MCP server "${h.server}". Don't re-propose the same server — either pick a different approach or ask the user what they prefer.`,e&&!f&&await this.continueTurn(a,d);return}try{let e=await B(h.config,h.secrets??[],b.secretValues??{}),{McpConfigSchema:f}=await Promise.resolve().then(c.bind(c,97453)),g=f.parse(e),{addMcpServer:i,updateMcpServer:j,getMcpServer:k}=await Promise.resolve().then(c.bind(c,580));await k(h.server)?await j(h.server,{label:h.label,...void 0!==h.description?{description:h.description}:{},config:g}):await i({id:h.server,label:h.label,...void 0!==h.description?{description:h.description}:{},config:g}),await l({type:"mcp-add-response",requestId:b.requestId,decision:"approve",server:h.server,agentId:a,ts:A(),seq:0}),d=`[Reflex] MCP server "${h.server}" registered. You can now call its tools via \`mcp__${h.server}__<tool>\` (chat) or \`reflex.mcp.call({server:"${h.server}",tool,args})\` (from a utility that declared it in manifest.mcpServers). Continue.`}catch(e){let c=e instanceof Error?e.message:String(e);await l({type:"error",message:"mcp-add failed: "+c,agentId:a,ts:A(),seq:0}),await l({type:"mcp-add-response",requestId:b.requestId,decision:"reject",agentId:a,ts:A(),seq:0}),d=`[Reflex] Failed to register MCP server "${h.server}": ${c}. Don't retry the exact same config; either fix the issue or ask the user.`}e&&!f&&await this.continueTurn(a,d)}async continueTurn(a,b){let c=this.agents.get(a);if(!c)return;let d=this.lastInvoke.get(a);if(!d)return void await this.emit({type:"error",message:"Cannot continue turn: no cached system prompt. Send another message manually.",agentId:a,ts:A(),seq:0});let e=[];try{let a=await (0,v.M)();e=a.assignments[c.meta.task]?.allowedTools??[]}catch{}let f=await D(d.rootPath,c.meta.topicId),g=`Prior conversation:
|
|
448
|
+
|
|
449
|
+
${f}
|
|
450
|
+
|
|
451
|
+
### user
|
|
452
|
+
${b}
|
|
453
|
+
|
|
454
|
+
### assistant
|
|
455
|
+
(Reply now.)`;this.invoke({agentId:a,systemPrompt:d.systemPrompt,prompt:g,userMessage:b,allowedTools:e}).catch(()=>{})}async evaluateGoalContinuation(a){let b,c=this.agents.get(a);if(!c||"orchestrator"!==c.meta.role)return null;try{b=await (0,w.eF)(c.rootPath,c.meta.topicId)}catch{return null}if(!b)return null;let d=b.meta;if(!d.goal||"active"!==d.goalStatus)return null;let e=this.turnText.get(a)??"";if(/(^|\n)\s*GOAL ACHIEVED\s*(\n|$)/i.test(e)||/<<reflex:kb>>[\s\S]*?"kind"\s*:\s*"goal-completion"[\s\S]*?<<\/reflex:kb>>/i.test(e)){try{await (0,w._9)(c.rootPath,c.meta.topicId,"completed")}catch{}return null}if(/<<reflex:(?:question|permission)>>[\s\S]*?<<\/reflex:(?:question|permission)>>/i.test(e))return null;try{let b=await (0,w.o0)(c.rootPath,c.meta.topicId);if(b>x.GX)return await (0,w._9)(c.rootPath,c.meta.topicId,"abandoned"),await this.emit({type:"error",message:`Goal iteration cap reached (${x.GX}). Goal marked as abandoned — clear or restart via /goal to keep trying.`,agentId:a,ts:A(),seq:0}),null;return{goal:d.goal,iteration:b}}catch{return null}}async reindexAfterTurn(a,b,c=new Set){let d=this.agents.get(a);if(d)try{let e=(await (0,r.pV)(d.rootPath,b)).filter(a=>!c.has(a.abs));if(0===e.length)return;for(let b of(await (0,r.F8)(d.rootPath,e),e))await this.emit({type:"kb-write",kind:b.kind??"note",title:b.title??b.rel,relPath:b.rel,absPath:b.abs,agentId:a,ts:A(),seq:0})}catch(b){await this.emit({type:"error",message:"kb auto-index failed: "+(b instanceof Error?b.message:String(b)),agentId:a,ts:A(),seq:0})}}async dispatchSubAgents(a,b){let c=this.agents.get(a);if(!c)return;let d=await (0,v.M)(),e=c.meta.harness,f=c.meta.model,g=d.language,h=(await Promise.all(b.map(async b=>{var d;let h=b.role,i=y.pO[h],j=C(),k=b.harness&&(d=b.harness,F.has(d))?b.harness:e,l="string"==typeof b.model&&b.model.length>0?b.model:f,m={id:j,topicId:c.meta.topicId,rootId:c.meta.rootId,role:"subagent",task:c.meta.task,harness:k,model:l,label:i.label,status:"idle",startedAt:A(),parentId:a};this.agents.set(j,{meta:m,rootPath:c.rootPath,reflexScope:c.reflexScope}),await this.emit({type:"agent-start",meta:m,agentId:j,ts:A(),seq:0});let n=i.systemPrompt({language:g,root:c.rootPath,reflexScope:c.reflexScope,brief:b.brief}),o=b.brief,p=`${o}
|
|
456
|
+
|
|
457
|
+
### assistant
|
|
458
|
+
(Reply now.)`;try{await this.invoke({agentId:j,systemPrompt:n,prompt:p,userMessage:o,allowedTools:i.allowedTools})}catch(c){let a=c instanceof Error?c.message:String(c);return await this.emit({type:"error",message:`sub-agent (${h}) failed: ${a}`,agentId:j,ts:A(),seq:0}),await this.destroy(j,"failed"),{role:h,id:b.id??j,brief:b.brief,output:"",error:a}}let q=(this.turnText.get(j)??"").trim();return await this.destroy(j,"completed"),{role:h,id:b.id??j,brief:b.brief,output:q}}))).map(a=>{let b=`### sub-agent: ${a.role}${a.id?` [${a.id}]`:""}`,c=`**Brief:** ${a.brief.replace(/\n+/g," ").trim()}`,d=a.error?`_failed_ — ${a.error}`:a.output.length>0?a.output:"_(no output)_";return[b,c,"",d].join("\n")}),i=["[Reflex] Sub-agent results follow. Use them to compose the user-facing reply. Do NOT re-dispatch the same brief; if a result is empty or insufficient, either solve it yourself or ask the user.","",...h].join("\n\n");await this.continueTurn(a,i)}async detectInteractionDirectives(a){let b=new Set,d=this.turnText.get(a)??"";if(!d)return{writtenViaKb:b,dispatches:[],youtubeSummaries:[]};let e=this.agents.get(a);for(let b of(0,l.gQ)(d))await this.emit({type:"permission-request",requestId:b.id??C(),...b.tool?{tool:b.tool}:{},...b.action?{action:b.action}:{},...void 0!==b.input?{input:b.input}:{},...b.description?{description:b.description}:{},agentId:a,ts:A(),seq:0});for(let b of(0,l.dJ)(d))await this.emit({type:"question",questionId:b.id??C(),prompt:b.prompt,...b.header?{header:b.header}:{},...b.multiSelect?{multiSelect:!0}:{},...b.choices?{choices:b.choices}:{},...b.options?{options:b.options}:{},agentId:a,ts:A(),seq:0});for(let b of(0,l.eD)(d)){let c=b.id??C();this.pendingMcpAdds.set(c,{agentId:a,directive:b}),e&&await (0,s.GC)({requestId:c,agentId:a,topicId:e.meta.topicId,rootPath:e.rootPath,directive:b}),await this.emit({type:"mcp-add-request",requestId:c,server:b.server,label:b.label,...b.description?{description:b.description}:{},config:function(a,b){if(!a||"object"!=typeof a)return a;let c=a.transport,d="stdio"===c?"env":"http"===c||"sse"===c?"headers":null;if(!d)return a;let e=new Set(b.map(a=>a.envKey));if(0===e.size)return a;let f=a[d];if(!f||"object"!=typeof f)return a;let g={};for(let[a,b]of Object.entries(f))g[a]=e.has(a)?"***":String(b);return{...a,[d]:g}}(b.config,b.secrets??[]),...b.secrets&&b.secrets.length>0?{secrets:b.secrets}:{},agentId:a,ts:A(),seq:0})}if(e){for(let c of(0,l.Bc)(d))try{let d=await (0,q.j)({rootPath:e.rootPath,directive:c});b.add(d.absPath),await this.emit({type:"kb-write",kind:d.kind,title:d.title,relPath:d.relPath,absPath:d.absPath,agentId:a,ts:A(),seq:0})}catch(b){await this.emit({type:"error",message:"kb-write failed: "+(b instanceof Error?b.message:String(b)),agentId:a,ts:A(),seq:0})}for(let b of(0,l.Oo)(d))try{let d=b.manifest&&"object"==typeof b.manifest?b.manifest:{},f=d.source&&"object"==typeof d.source?d.source:{},{source:g,...h}=d,i=t.pL.parse(h),j=["agent","github","archive","mcp"],k="string"==typeof f.type&&j.includes(f.type)?f.type:"agent",l=await (0,u.gd)({scope:b.scope,..."project"===b.scope?{rootId:e.meta.rootId}:{},manifest:i,files:b.files,source:{type:k,origin:"string"==typeof f.origin?f.origin:`agent:${e.meta.rootId}:${e.meta.topicId}:${e.meta.id}`,fetchedAt:new Date().toISOString(),installedBy:"agent"}}),m=await c.e(9861).then(c.bind(c,99861));await m.buildUtility(l),await this.emit({type:"utility-installed",utilityId:l.manifest.id,scope:l.scope,name:l.manifest.name,version:l.manifest.version,agentId:a,ts:A(),seq:0})}catch(b){await this.emit({type:"utility-error",message:"utility install failed: "+(b instanceof Error?b.message:String(b)),agentId:a,ts:A(),seq:0})}}let f=(0,l.Eb)(d).filter(a=>(0,y.Aq)(a.role)),g=(0,l.XZ)(d),h=(0,l.Dq)(d),i=(0,l.Up)(d);e&&(h.length>0||i.length>0)&&await this.applyWidgetDirectives(e.rootPath,e.meta.topicId,a,h,i);let j=(0,l.QN)(d);return e&&j.length>0&&await this.applyWorkflowDirectives(e.rootPath,e.meta.topicId,a,j),{writtenViaKb:b,dispatches:f,youtubeSummaries:g}}async applyImageGenDirectives(a){let b=this.agents.get(a);if(!b)return;let c=this.turnText.get(a)??"";if(!c||!c.includes("reflex:image-gen"))return;let d=(0,l.qk)(c);if(0!==d.length)for(let c of d)try{let d=await (0,m.generateImage)({rootId:b.meta.rootId,prompt:c.prompt,...c.provider?{provider:c.provider}:{},...c.size?{size:c.size}:{},...c.aspectRatio?{aspectRatio:c.aspectRatio}:{},...c.referenceImageUrls?{referenceImageUrls:c.referenceImageUrls}:{}}),e=(c.caption||c.prompt).replace(/[\[\]\n]/g," ").slice(0,200);if(await this.emit({type:"assistant-delta",text:`
|
|
459
|
+
|
|
460
|
+

|
|
461
|
+
`,agentId:a,ts:A(),seq:0}),c.attachToKb)try{let f=await (0,q.j)({rootPath:b.rootPath,directive:{kind:"image",title:c.caption||c.prompt.slice(0,80),body:``,meta:{provider:d.provider,prompt:c.prompt,sha:d.sha,...c.aspectRatio?{aspectRatio:c.aspectRatio}:{}}}});await this.emit({type:"kb-write",kind:f.kind,title:f.title,relPath:f.relPath,absPath:f.absPath,agentId:a,ts:A(),seq:0})}catch(b){await this.emit({type:"error",message:"image-gen kb attach failed: "+(b instanceof Error?b.message:String(b)),agentId:a,ts:A(),seq:0})}}catch(b){await this.emit({type:"assistant-delta",text:`
|
|
462
|
+
|
|
463
|
+
_Failed to generate image: ${b instanceof Error?b.message:String(b)}_
|
|
464
|
+
`,agentId:a,ts:A(),seq:0})}}async applyWorkflowDirectives(a,b,c,d){for(let e of d)try{let d=(0,o.ni)(e.id);if(!d)throw Error("Workflow id is empty");let f=new Date().toISOString(),g=e.steps.map((a,b)=>({id:(0,o.ni)(a.id??`step-${b+1}`),kind:a.kind,label:a.label,params:a.params??{}})),h={id:d,label:e.label,...e.description?{description:e.description}:{},trigger:e.trigger??"manual",steps:g,createdAt:f,updatedAt:f,sourceTopicId:b},i=(0,p.n)(h);if(i)throw Error(i);await (0,o.r$)(a,h),await this.emit({type:"workflow-event",workflowId:h.id,label:h.label,...h.description?{description:h.description}:{},trigger:h.trigger,stepCount:h.steps.length,sourceTopicId:b,agentId:c,ts:f,seq:0})}catch(a){await this.emit({type:"workflow-error",workflowId:e.id,message:"workflow-create failed: "+(a instanceof Error?a.message:String(a)),agentId:c,ts:A(),seq:0})}}async applyWidgetDirectives(a,b,c,d,e){let f=await (0,n.readLayout)(a),g=[...f.order],h=[...f.hidden];for(let f of[...d,...e]){let d=e.includes(f);try{let e={kind:f.kind,data:f.data},i=d?await (0,n.readWidget)(a,f.id):null,j=(0,n.buildRecord)({id:f.id,title:f.title,...f.description?{description:f.description}:{},sourceTopicId:b,payload:e,existing:i,...f.size?{size:f.size}:{},...f.refresh?{refresh:f.refresh}:{},...void 0!==f.memory?{memory:f.memory}:{},...f.memoryFile?{memoryFile:f.memoryFile}:{}});await (0,n.writeWidget)(a,j),i||h.includes(j.id)||g.includes(j.id)||h.push(j.id),await this.emit({type:"widget-event",op:d&&i?"update":"create",widgetId:j.id,title:j.title,...j.description?{description:j.description}:{},kind:j.kind,data:j.data,sourceTopicId:b,agentId:c,ts:A(),seq:0})}catch(a){await this.emit({type:"widget-error",widgetId:f.id,message:(d?"widget-update":"widget-create")+" failed: "+(a instanceof Error?a.message:String(a)),agentId:c,ts:A(),seq:0})}}await (0,n.writeLayout)(a,{order:g,hidden:h})}async runYoutubeSummaries(a,b){if(!this.agents.get(a))return;await this.emit({type:"system",text:`Starting Gemini YouTube summary (${b.length}):
|
|
465
|
+
${b.map(a=>`• ${a.url}`).join("\n")}`,subtype:"reflex.preflight",agentId:a,ts:A(),seq:0});let{summarizeYoutubeAction:d}=await c.e(9098).then(c.bind(c,39098)),e=await Promise.all(b.map(async a=>{let b=await d({url:a.url,...a.prompt?{prompt:a.prompt}:{}});return b.ok?{url:a.url,text:b.text,model:b.model}:{url:a.url,error:b.error}})),f=e.map(a=>"text"in a?[`### youtube-summary ${a.url}`,`_(Gemini ${a.model} — use as primary source; do not WebFetch the same URL.)_`,"",a.text].join("\n"):`### youtube-summary ${a.url}
|
|
466
|
+
_(Gemini failed: ${a.error}. Notify the user and suggest saving the key in Settings -> Gemini, or answer without the summary.)_`);await this.emit({type:"system",text:e.every(a=>"text"in a)?"Summaries received, passing to the agent.":"Some summaries failed — details are in the context.",subtype:"reflex.preflight",agentId:a,ts:A(),seq:0});let g=`[Reflex] Gemini YouTube summaries you requested:
|
|
467
|
+
|
|
468
|
+
${f.join("\n\n")}
|
|
469
|
+
|
|
470
|
+
Now answer the user based on this context. Do not repeat the summaries verbatim — compose a human-readable response.`;await this.continueTurn(a,g)}async destroy(a,b="completed"){let c=this.agents.get(a);if(!c)return;c.meta.status=b,c.meta.endedAt=A(),await this.emit({type:"agent-end",status:b,agentId:a,ts:c.meta.endedAt,seq:0}),this.agents.delete(a),this.turnText.delete(a),this.lastInvoke.delete(a);let d=this.byTopicRole.get(c.meta.topicId);if(d){for(let[b,c]of d)c===a&&d.delete(b);0===d.size&&this.byTopicRole.delete(c.meta.topicId)}}async emit(a){let b=this.agents.get(a.agentId);if(!b)return;let c=await (0,g.v)(b.rootPath,b.meta.topicId),d={...a,seq:c};if(await (0,g.Zn)(b.rootPath,b.meta.topicId,d),"assistant-delta"===a.type){let b=this.turnText.get(a.agentId)??"";this.turnText.set(a.agentId,b+a.text)}this.emitter.emit(`topic:${b.meta.topicId}`,d),this.emitter.emit(`agent:${a.agentId}`,d)}subscribeTopic(a,b){let c=`topic:${a}`;return this.emitter.on(c,b),()=>this.emitter.off(c,b)}subscribeAgent(a,b){let c=`agent:${a}`;return this.emitter.on(c,b),()=>this.emitter.off(c,b)}list(a){let b=[];for(let c of this.agents.values())(!a?.topicId||c.meta.topicId===a.topicId)&&(a?.rootId&&c.meta.rootId!==a.rootId||b.push({...c.meta}));return b.sort((a,b)=>Date.parse(b.startedAt)-Date.parse(a.startedAt)),b}get(a){let b=this.agents.get(a);return b?{...b.meta}:null}isActive(a){let b=this.byTopicRole.get(a);if(!b)return!1;for(let a of b.values()){let b=this.agents.get(a);if(b?.meta.status==="running")return!0}return!1}listRunningTopicsForRoot(a){let b=new Set;for(let c of this.agents.values())c.meta.rootId===a&&"running"===c.meta.status&&b.add(c.meta.topicId);return[...b]}async stopTopic(a){let b=[];for(let[c,d]of this.agents)d.meta.topicId===a&&b.push(c);let c=0;for(let a of b){let b=this.agents.get(a);b&&"running"===b.meta.status&&(await this.destroy(a,"cancelled"),c+=1)}return{stopped:c}}constructor(){this.agents=new Map,this.byTopicRole=new Map,this.emitter=new e.EventEmitter,this.turnText=new Map,this.lastInvoke=new Map,this.pendingMcpAdds=new Map}}function A(){return new Date().toISOString()}let F=new Set(["claude-code","codex","ollama","image-gen"]);async function B(a,b,d){if(!a||"object"!=typeof a)return a;let e={...a},f=e.transport,g="stdio"===f?"env":"http"===f||"sse"===f?"headers":null;if(!g)return e;let h=e[g]??{},i={};for(let[a,b]of Object.entries(h))i[a]=String(b);for(let a of b){if(a.oauth){let{getOAuthTokens:b}=await c.e(1223).then(c.bind(c,1223)),{isOAuthProviderId:d}=await c.e(94).then(c.bind(c,10094));if(!d(a.oauth))throw Error(`unknown OAuth provider: ${a.oauth}`);if(!await b(a.oauth))throw Error(`provider "${a.oauth}" not authorized — open Settings → OAuth and Authorize first`);i[a.envKey]=`$oauth:${a.oauth}`;continue}let b=d[a.envKey];if(void 0!==b&&""!==b)i[a.envKey]=b;else if(a.required)throw Error(`secret "${a.envKey}" is required`);else delete i[a.envKey]}return e[g]=i,e}function C(){return(0,f.randomUUID)().replace(/-/g,"").slice(0,12)}async function D(a,b){let c=await (0,g.readEvents)(a,b),d=[],e=null,f=()=>{e&&(d.push(`### ${e.role}
|
|
471
|
+
${e.text.trim()}`),e=null)};for(let a of c)"user-message"===a.type?(f(),e={role:"user",text:a.text},f()):"assistant-delta"===a.type?(e&&"assistant"===e.role||(f(),e={role:"assistant",text:""}),e.text+=a.text):("turn-end"===a.type||"agent-end"===a.type)&&f();return f(),d.join("\n\n")}let G=globalThis.__reflexAgentManager??new E;globalThis.__reflexAgentManager=G,c.e(569).then(c.bind(c,10569)).then(a=>a.startWidgetScheduler()).catch(a=>{console.error("[widget-scheduler] failed to start:",a)}),d()}catch(a){d(a)}})},95422:(a,b,c)=>{"use strict";c.d(b,{Toaster:()=>d});let d=(0,c(54491).registerClientReference)(function(){throw Error("Attempted to call Toaster() from the server but Toaster is on the client. It's not possible to invoke a client function from the server, it can only be rendered as a Component or passed to props of a Client Component.")},"/home/runner/work/reflex-agent/reflex-agent/components/ui/sonner.tsx","Toaster")},96921:(a,b,c)=>{"use strict";c.d(b,{Lo:()=>d,dr:()=>e});let d=[{id:"plan",trigger:"plan",label:"/plan",description:"Show the plan first — Reflex lays out the steps and waits for approval.",kind:"agent-mode",usage:"/plan <task>",icon:"ListChecks"},{id:"goal",trigger:"goal",label:"/goal",description:"Set a goal — Reflex will work toward it on its own, without reminders.",kind:"agent-mode",usage:"/goal <what to achieve>",icon:"Target"},{id:"research",trigger:"research",label:"/research",description:"Deep research on a topic — web search + summary with sources.",kind:"agent-mode",usage:"/research <topic>",icon:"Telescope"},{id:"widget",trigger:"widget",label:"/widget",description:"Create a card on the space dashboard.",kind:"agent-mode",usage:"/widget <what to show>",icon:"LayoutGrid"},{id:"workflow",trigger:"workflow",label:"/workflow",description:"Build a recipe — linear step-based automation for the task.",kind:"agent-mode",usage:"/workflow <what to automate>",icon:"Workflow"},{id:"remember",trigger:"remember",label:"/remember",description:"Save a note — straight into memory, no AI involved.",kind:"direct",usage:"/remember <what to remember>",icon:"BookmarkPlus"},{id:"mcp",trigger:"mcp",label:"/mcp",description:"Connect an external service (setup wizard opens in chat).",kind:"agent-mode",usage:"/mcp <what you need>",icon:"PackagePlus"},{id:"skill",trigger:"skill",label:"/skill",description:"Attach a role — a ready-made instruction set for this conversation.",kind:"agent-mode",usage:"/skill <role-id> [prompt]",icon:"Sparkles"},{id:"delete-topic",trigger:"delete-topic",label:"/delete-topic",description:"Delete this conversation (with confirmation).",kind:"direct",usage:"/delete-topic",requiresConfirm:!0,allowEmpty:!0,icon:"Trash2"},{id:"clear-project",trigger:"clear-project",label:"/clear-project",description:"DANGER: clear the space — all conversations, cards, memory. Double confirmation.",kind:"direct",usage:"/clear-project",requiresConfirm:!0,allowEmpty:!0,icon:"AlertOctagon"},{id:"util",trigger:"util",label:"/util",description:"Open a mini-app (by partial name or from the list).",kind:"direct",usage:"/util <partial name or id>",allowEmpty:!0,icon:"Boxes"},{id:"help",trigger:"help",label:"/help",description:"List available commands.",kind:"direct",usage:"/help",allowEmpty:!0,icon:"HelpCircle"}];function e(a){var b;let c=a.trim();if(!c.startsWith("/"))return null;let e=/^\/([a-z][a-z0-9-]*)(?:\s+([\s\S]*))?$/.exec(c);if(!e)return null;let f=(b=e[1],d.find(a=>a.trigger===b)??null);return f?{def:f,payload:(e[2]??"").trim()}:null}},97453:(a,b,c)=>{"use strict";c.d(b,{Jc:()=>p,McpConfigSchema:()=>l,callTool:()=>r,connectAndListTools:()=>q});var d=c(1680),e=c(81475),f=c(73444),g=c(43451),h=c(56149);let i=h.Ik({transport:h.eu("stdio"),command:h.Yj().min(1),args:h.YO(h.Yj()).default([]),env:h.g1(h.Yj(),h.Yj()).default({}),cwd:h.Yj().optional()}),j=h.Ik({transport:h.eu("http"),url:h.Yj().url(),headers:h.g1(h.Yj(),h.Yj()).default({})}),k=h.Ik({transport:h.eu("sse"),url:h.Yj().url(),headers:h.g1(h.Yj(),h.Yj()).default({})}),l=h.gM("transport",[i,j,k]),m={name:"reflex-utility-bridge",version:"0.1.0"};async function n(a){let b=new d.K(m);if("stdio"===a.transport){let c=await p(a.env),d=new e.oQ({command:a.command,args:a.args,env:{...process.env,...c},cwd:a.cwd});return await b.connect(d),{client:b,close:()=>b.close()}}if("http"===a.transport){let c=await p(a.headers),d=new f.j(new URL(a.url),{requestInit:{headers:c}});return await b.connect(d),{client:b,close:()=>b.close()}}let c=await p(a.headers),h=new g.A(new URL(a.url),{requestInit:{headers:c}});return await b.connect(h),{client:b,close:()=>b.close()}}let o=/\$oauth:([a-z][a-z0-9-]*)/g;async function p(a){let b={};for(let[d,e]of Object.entries(a)){if("string"!=typeof e||!e.includes("$oauth:")){b[d]=e;continue}let a=new Set;e.replace(o,(b,c)=>(a.add(c),""));let f=e,{getAccessToken:g}=await c.e(1888).then(c.bind(c,61888)),{isOAuthProviderId:h}=await c.e(94).then(c.bind(c,10094));for(let b of a){if(!h(b))throw Error(`unknown OAuth provider in placeholder: ${b}`);let a=await g(b);f=f.replace(RegExp(`\\$oauth:${b}\\b`,"g"),a)}b[d]=f}return b}async function q(a){let{client:b,close:c}=await n(a);try{let a=b.getServerVersion(),{tools:c}=await b.listTools();return{name:a?.name,version:a?.version,tools:c.map(a=>({name:a.name,description:a.description,inputSchema:a.inputSchema}))}}finally{await c().catch(()=>{})}}async function r(a,b,c){let{client:d,close:e}=await n(a);try{let a=await d.callTool({name:b,arguments:c});return{isError:"boolean"==typeof a.isError?a.isError:void 0,content:a.content}}finally{await e().catch(()=>{})}}},98360:(a,b,c)=>{"use strict";c.d(b,{E:()=>e});var d=c(36017);async function e(a){let b=(await (0,d.M)()).harnesses.ollama.baseUrl.replace(/\/$/,""),c=await fetch(`${b}/api/generate`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({model:a.args.model,system:a.args.systemPrompt,prompt:a.args.prompt,stream:!0})});if(!c.ok||!c.body)throw Error(`Ollama /api/generate HTTP ${c.status}`);let e=c.body.getReader(),f=new TextDecoder,g="";for(;;){let b,{done:c,value:d}=await e.read();if(c)break;for(g+=f.decode(d,{stream:!0});(b=g.indexOf("\n"))>=0;){let c=g.slice(0,b).trim();if(g=g.slice(b+1),c)try{let b=JSON.parse(c);if(b.error)throw Error(b.error);b.response&&await a.manager.emit({type:"assistant-delta",text:b.response,agentId:a.meta.id,ts:new Date().toISOString(),seq:0})}catch{}}}}},99353:(a,b,c)=>{"use strict";c.a(a,async(a,d)=>{try{c.d(b,{T:()=>h});var e=c(7206),f=c(36017),g=a([e]);async function h(a,b,c){let d=c?.timeoutMs??3e4;if("claude-code"===a.harness)return(await (0,e.execa)("claude",["-p",b,"--permission-mode","default","--allowedTools","","--model",a.model],{timeout:d,stdio:["ignore","pipe","pipe"]})).stdout.trim();if("codex"===a.harness)return(await (0,e.execa)("codex",["exec","--sandbox","read-only","--model",a.model,b],{timeout:d,stdio:["ignore","pipe","pipe"]})).stdout.trim();if("ollama"===a.harness){let c=(await (0,f.M)()).harnesses.ollama.baseUrl.replace(/\/$/,""),e=await fetch(`${c}/api/generate`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({model:a.model,prompt:b,stream:!1}),signal:AbortSignal.timeout(d)});if(!e.ok)throw Error(`Ollama /api/generate HTTP ${e.status}`);return((await e.json()).response??"").trim()}throw Error(`Unsupported quick harness: ${a.harness}`)}e=(g.then?(await g)():g)[0],d()}catch(a){d(a)}})},99668:(a,b,c)=>{"use strict";c.d(b,{Toaster:()=>l});var d=c(64173),e=c(9338),f=c(48855),g=c(74868),h=c(35089),i=c(62261),j=c(22571),k=c(44052);let l=({...a})=>{let{theme:b="system"}=(0,j.D)();return(0,d.jsx)(k.l$,{theme:b,className:"toaster group",icons:{success:(0,d.jsx)(e.A,{className:"size-4"}),info:(0,d.jsx)(f.A,{className:"size-4"}),warning:(0,d.jsx)(g.A,{className:"size-4"}),error:(0,d.jsx)(h.A,{className:"size-4"}),loading:(0,d.jsx)(i.A,{className:"size-4 animate-spin"})},style:{"--normal-bg":"var(--popover)","--normal-text":"var(--popover-foreground)","--normal-border":"var(--border)","--border-radius":"var(--radius)"},...a})}}};
|