@mndrk/agx 2.4.3 → 2.4.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (162) hide show
  1. package/cloud-runtime/standalone/apps/local/.next/BUILD_ID +1 -1
  2. package/cloud-runtime/standalone/apps/local/.next/build-manifest.json +2 -2
  3. package/cloud-runtime/standalone/apps/local/.next/prerender-manifest.json +3 -3
  4. package/cloud-runtime/standalone/apps/local/.next/server/app/_global-error.html +2 -2
  5. package/cloud-runtime/standalone/apps/local/.next/server/app/_global-error.rsc +1 -1
  6. package/cloud-runtime/standalone/apps/local/.next/server/app/_global-error.segments/__PAGE__.segment.rsc +1 -1
  7. package/cloud-runtime/standalone/apps/local/.next/server/app/_global-error.segments/_full.segment.rsc +1 -1
  8. package/cloud-runtime/standalone/apps/local/.next/server/app/_global-error.segments/_head.segment.rsc +1 -1
  9. package/cloud-runtime/standalone/apps/local/.next/server/app/_global-error.segments/_index.segment.rsc +1 -1
  10. package/cloud-runtime/standalone/apps/local/.next/server/app/_global-error.segments/_tree.segment.rsc +1 -1
  11. package/cloud-runtime/standalone/apps/local/.next/server/app/_not-found/page_client-reference-manifest.js +1 -1
  12. package/cloud-runtime/standalone/apps/local/.next/server/app/_not-found.html +2 -2
  13. package/cloud-runtime/standalone/apps/local/.next/server/app/_not-found.rsc +2 -2
  14. package/cloud-runtime/standalone/apps/local/.next/server/app/_not-found.segments/_full.segment.rsc +2 -2
  15. package/cloud-runtime/standalone/apps/local/.next/server/app/_not-found.segments/_head.segment.rsc +1 -1
  16. package/cloud-runtime/standalone/apps/local/.next/server/app/_not-found.segments/_index.segment.rsc +2 -2
  17. package/cloud-runtime/standalone/apps/local/.next/server/app/_not-found.segments/_not-found/__PAGE__.segment.rsc +1 -1
  18. package/cloud-runtime/standalone/apps/local/.next/server/app/_not-found.segments/_not-found.segment.rsc +1 -1
  19. package/cloud-runtime/standalone/apps/local/.next/server/app/_not-found.segments/_tree.segment.rsc +2 -2
  20. package/cloud-runtime/standalone/apps/local/.next/server/app/agents/[id]/page_client-reference-manifest.js +1 -1
  21. package/cloud-runtime/standalone/apps/local/.next/server/app/agents/page_client-reference-manifest.js +1 -1
  22. package/cloud-runtime/standalone/apps/local/.next/server/app/agents.html +2 -2
  23. package/cloud-runtime/standalone/apps/local/.next/server/app/agents.rsc +2 -2
  24. package/cloud-runtime/standalone/apps/local/.next/server/app/agents.segments/_full.segment.rsc +2 -2
  25. package/cloud-runtime/standalone/apps/local/.next/server/app/agents.segments/_head.segment.rsc +1 -1
  26. package/cloud-runtime/standalone/apps/local/.next/server/app/agents.segments/_index.segment.rsc +2 -2
  27. package/cloud-runtime/standalone/apps/local/.next/server/app/agents.segments/_tree.segment.rsc +2 -2
  28. package/cloud-runtime/standalone/apps/local/.next/server/app/agents.segments/agents/__PAGE__.segment.rsc +1 -1
  29. package/cloud-runtime/standalone/apps/local/.next/server/app/agents.segments/agents.segment.rsc +1 -1
  30. package/cloud-runtime/standalone/apps/local/.next/server/app/api/tasks/[id]/nodes/[nodeId]/comments/route.js +1 -1
  31. package/cloud-runtime/standalone/apps/local/.next/server/app/api/tasks/[id]/nodes/[nodeId]/comments/route.js.nft.json +1 -1
  32. package/cloud-runtime/standalone/apps/local/.next/server/app/api/trackers/[tracker]/auth/route.js +3 -3
  33. package/cloud-runtime/standalone/apps/local/.next/server/app/api/trackers/[tracker]/auth/route.js.nft.json +1 -1
  34. package/cloud-runtime/standalone/apps/local/.next/server/app/api/trackers/[tracker]/callback/route.js +3 -3
  35. package/cloud-runtime/standalone/apps/local/.next/server/app/api/trackers/[tracker]/callback/route.js.nft.json +1 -1
  36. package/cloud-runtime/standalone/apps/local/.next/server/app/api/trackers/[tracker]/groups/route.js +3 -3
  37. package/cloud-runtime/standalone/apps/local/.next/server/app/api/trackers/[tracker]/groups/route.js.nft.json +1 -1
  38. package/cloud-runtime/standalone/apps/local/.next/server/app/api/trackers/[tracker]/items/[id]/activity/route.js +3 -3
  39. package/cloud-runtime/standalone/apps/local/.next/server/app/api/trackers/[tracker]/items/[id]/activity/route.js.nft.json +1 -1
  40. package/cloud-runtime/standalone/apps/local/.next/server/app/api/trackers/[tracker]/items/[id]/recap/route.js +3 -3
  41. package/cloud-runtime/standalone/apps/local/.next/server/app/api/trackers/[tracker]/items/[id]/recap/route.js.nft.json +1 -1
  42. package/cloud-runtime/standalone/apps/local/.next/server/app/api/trackers/[tracker]/items/[id]/route.js +4 -4
  43. package/cloud-runtime/standalone/apps/local/.next/server/app/api/trackers/[tracker]/items/[id]/route.js.nft.json +1 -1
  44. package/cloud-runtime/standalone/apps/local/.next/server/app/api/trackers/[tracker]/items/route.js +3 -3
  45. package/cloud-runtime/standalone/apps/local/.next/server/app/api/trackers/[tracker]/items/route.js.nft.json +1 -1
  46. package/cloud-runtime/standalone/apps/local/.next/server/app/api/trackers/[tracker]/mcp-setup/route.js +3 -3
  47. package/cloud-runtime/standalone/apps/local/.next/server/app/api/trackers/[tracker]/mcp-setup/route.js.nft.json +1 -1
  48. package/cloud-runtime/standalone/apps/local/.next/server/app/api/trackers/[tracker]/options/route.js +3 -3
  49. package/cloud-runtime/standalone/apps/local/.next/server/app/api/trackers/[tracker]/options/route.js.nft.json +1 -1
  50. package/cloud-runtime/standalone/apps/local/.next/server/app/api/trackers/[tracker]/runs/[id]/route.js +1 -1
  51. package/cloud-runtime/standalone/apps/local/.next/server/app/api/trackers/[tracker]/runs/[id]/route.js.nft.json +1 -1
  52. package/cloud-runtime/standalone/apps/local/.next/server/app/api/trackers/[tracker]/runs/route.js +3 -3
  53. package/cloud-runtime/standalone/apps/local/.next/server/app/api/trackers/[tracker]/runs/route.js.nft.json +1 -1
  54. package/cloud-runtime/standalone/apps/local/.next/server/app/api/trackers/[tracker]/runs/scripted/route.js +1 -1
  55. package/cloud-runtime/standalone/apps/local/.next/server/app/api/trackers/[tracker]/runs/scripted/route.js.nft.json +1 -1
  56. package/cloud-runtime/standalone/apps/local/.next/server/app/api/trackers/[tracker]/status/route.js +4 -4
  57. package/cloud-runtime/standalone/apps/local/.next/server/app/api/trackers/[tracker]/status/route.js.nft.json +1 -1
  58. package/cloud-runtime/standalone/apps/local/.next/server/app/api/trackers/[tracker]/token/route.js +3 -3
  59. package/cloud-runtime/standalone/apps/local/.next/server/app/api/trackers/[tracker]/token/route.js.nft.json +1 -1
  60. package/cloud-runtime/standalone/apps/local/.next/server/app/api/trackers/[tracker]/token-receive/route.js +3 -3
  61. package/cloud-runtime/standalone/apps/local/.next/server/app/api/trackers/[tracker]/token-receive/route.js.nft.json +1 -1
  62. package/cloud-runtime/standalone/apps/local/.next/server/app/api/trackers/[tracker]/worker/route.js +6 -6
  63. package/cloud-runtime/standalone/apps/local/.next/server/app/api/trackers/[tracker]/worker/route.js.nft.json +1 -1
  64. package/cloud-runtime/standalone/apps/local/.next/server/app/api/trackers/connections/route.js +7 -2
  65. package/cloud-runtime/standalone/apps/local/.next/server/app/api/trackers/connections/route.js.nft.json +1 -1
  66. package/cloud-runtime/standalone/apps/local/.next/server/app/index.html +2 -2
  67. package/cloud-runtime/standalone/apps/local/.next/server/app/index.rsc +2 -2
  68. package/cloud-runtime/standalone/apps/local/.next/server/app/index.segments/__PAGE__.segment.rsc +1 -1
  69. package/cloud-runtime/standalone/apps/local/.next/server/app/index.segments/_full.segment.rsc +2 -2
  70. package/cloud-runtime/standalone/apps/local/.next/server/app/index.segments/_head.segment.rsc +1 -1
  71. package/cloud-runtime/standalone/apps/local/.next/server/app/index.segments/_index.segment.rsc +2 -2
  72. package/cloud-runtime/standalone/apps/local/.next/server/app/index.segments/_tree.segment.rsc +2 -2
  73. package/cloud-runtime/standalone/apps/local/.next/server/app/page_client-reference-manifest.js +1 -1
  74. package/cloud-runtime/standalone/apps/local/.next/server/app/projects/[slug]/automations/page_client-reference-manifest.js +1 -1
  75. package/cloud-runtime/standalone/apps/local/.next/server/app/projects/[slug]/env-vars/page_client-reference-manifest.js +1 -1
  76. package/cloud-runtime/standalone/apps/local/.next/server/app/projects/[slug]/folders/page_client-reference-manifest.js +1 -1
  77. package/cloud-runtime/standalone/apps/local/.next/server/app/projects/[slug]/graph/[taskId]/page_client-reference-manifest.js +1 -1
  78. package/cloud-runtime/standalone/apps/local/.next/server/app/projects/[slug]/objectives/[objectiveId]/page_client-reference-manifest.js +1 -1
  79. package/cloud-runtime/standalone/apps/local/.next/server/app/projects/[slug]/objectives/page_client-reference-manifest.js +1 -1
  80. package/cloud-runtime/standalone/apps/local/.next/server/app/projects/[slug]/page_client-reference-manifest.js +1 -1
  81. package/cloud-runtime/standalone/apps/local/.next/server/app/projects/[slug]/teams/[teamId]/agents/[agentId]/page_client-reference-manifest.js +1 -1
  82. package/cloud-runtime/standalone/apps/local/.next/server/app/projects/[slug]/teams/[teamId]/page_client-reference-manifest.js +1 -1
  83. package/cloud-runtime/standalone/apps/local/.next/server/app/projects/[slug]/teams/adopt/page_client-reference-manifest.js +1 -1
  84. package/cloud-runtime/standalone/apps/local/.next/server/app/projects/[slug]/teams/new/page_client-reference-manifest.js +1 -1
  85. package/cloud-runtime/standalone/apps/local/.next/server/app/projects/[slug]/teams/page_client-reference-manifest.js +1 -1
  86. package/cloud-runtime/standalone/apps/local/.next/server/app/projects/[slug]/teams/replace/page_client-reference-manifest.js +1 -1
  87. package/cloud-runtime/standalone/apps/local/.next/server/app/projects/[slug]/terminal/page_client-reference-manifest.js +1 -1
  88. package/cloud-runtime/standalone/apps/local/.next/server/app/projects/[slug]/thread/[threadId]/page_client-reference-manifest.js +1 -1
  89. package/cloud-runtime/standalone/apps/local/.next/server/app/projects/[slug]/tracking/[tracker]/page_client-reference-manifest.js +1 -1
  90. package/cloud-runtime/standalone/apps/local/.next/server/app/projects/[slug]/tracking/connect/page_client-reference-manifest.js +1 -1
  91. package/cloud-runtime/standalone/apps/local/.next/server/app/projects/[slug]/tracking/page_client-reference-manifest.js +1 -1
  92. package/cloud-runtime/standalone/apps/local/.next/server/app/projects/page_client-reference-manifest.js +1 -1
  93. package/cloud-runtime/standalone/apps/local/.next/server/app/projects.html +2 -2
  94. package/cloud-runtime/standalone/apps/local/.next/server/app/projects.rsc +2 -2
  95. package/cloud-runtime/standalone/apps/local/.next/server/app/projects.segments/_full.segment.rsc +2 -2
  96. package/cloud-runtime/standalone/apps/local/.next/server/app/projects.segments/_head.segment.rsc +1 -1
  97. package/cloud-runtime/standalone/apps/local/.next/server/app/projects.segments/_index.segment.rsc +2 -2
  98. package/cloud-runtime/standalone/apps/local/.next/server/app/projects.segments/_tree.segment.rsc +2 -2
  99. package/cloud-runtime/standalone/apps/local/.next/server/app/projects.segments/projects/__PAGE__.segment.rsc +1 -1
  100. package/cloud-runtime/standalone/apps/local/.next/server/app/projects.segments/projects.segment.rsc +1 -1
  101. package/cloud-runtime/standalone/apps/local/.next/server/app/setup/page_client-reference-manifest.js +1 -1
  102. package/cloud-runtime/standalone/apps/local/.next/server/app/setup.html +2 -2
  103. package/cloud-runtime/standalone/apps/local/.next/server/app/setup.rsc +2 -2
  104. package/cloud-runtime/standalone/apps/local/.next/server/app/setup.segments/_full.segment.rsc +2 -2
  105. package/cloud-runtime/standalone/apps/local/.next/server/app/setup.segments/_head.segment.rsc +1 -1
  106. package/cloud-runtime/standalone/apps/local/.next/server/app/setup.segments/_index.segment.rsc +2 -2
  107. package/cloud-runtime/standalone/apps/local/.next/server/app/setup.segments/_tree.segment.rsc +2 -2
  108. package/cloud-runtime/standalone/apps/local/.next/server/app/setup.segments/setup/__PAGE__.segment.rsc +1 -1
  109. package/cloud-runtime/standalone/apps/local/.next/server/app/setup.segments/setup.segment.rsc +1 -1
  110. package/cloud-runtime/standalone/apps/local/.next/server/app/status/page_client-reference-manifest.js +1 -1
  111. package/cloud-runtime/standalone/apps/local/.next/server/app/status.html +2 -2
  112. package/cloud-runtime/standalone/apps/local/.next/server/app/status.rsc +2 -2
  113. package/cloud-runtime/standalone/apps/local/.next/server/app/status.segments/_full.segment.rsc +2 -2
  114. package/cloud-runtime/standalone/apps/local/.next/server/app/status.segments/_head.segment.rsc +1 -1
  115. package/cloud-runtime/standalone/apps/local/.next/server/app/status.segments/_index.segment.rsc +2 -2
  116. package/cloud-runtime/standalone/apps/local/.next/server/app/status.segments/_tree.segment.rsc +2 -2
  117. package/cloud-runtime/standalone/apps/local/.next/server/app/status.segments/status/__PAGE__.segment.rsc +1 -1
  118. package/cloud-runtime/standalone/apps/local/.next/server/app/status.segments/status.segment.rsc +1 -1
  119. package/cloud-runtime/standalone/apps/local/.next/server/chunks/[root-of-the-server]__0fbbaf2d._.js +1 -1
  120. package/cloud-runtime/standalone/apps/local/.next/server/chunks/[root-of-the-server]__10a90219._.js +3 -3
  121. package/cloud-runtime/standalone/apps/local/.next/server/chunks/{[root-of-the-server]__2ab23e45._.js → [root-of-the-server]__2eb13697._.js} +2 -2
  122. package/cloud-runtime/standalone/apps/local/.next/server/chunks/[root-of-the-server]__3a038592._.js +3 -3
  123. package/cloud-runtime/standalone/apps/local/.next/server/chunks/[root-of-the-server]__498d8b2d._.js +3 -0
  124. package/cloud-runtime/standalone/apps/local/.next/server/chunks/[root-of-the-server]__68b692c4._.js +9 -9
  125. package/cloud-runtime/standalone/apps/local/.next/server/chunks/[root-of-the-server]__7fcbb0c2._.js +2 -2
  126. package/cloud-runtime/standalone/apps/local/.next/server/chunks/[root-of-the-server]__ba72d342._.js +5 -5
  127. package/cloud-runtime/standalone/apps/local/.next/server/chunks/apps_local_1a4cb196._.js +1 -1
  128. package/cloud-runtime/standalone/apps/local/.next/server/chunks/apps_local_5e5f36c4._.js +1 -1
  129. package/cloud-runtime/standalone/apps/local/.next/server/chunks/apps_local_9f0fd451._.js +3 -0
  130. package/cloud-runtime/standalone/apps/local/.next/server/chunks/apps_local_e1f4d9ad._.js +1 -1
  131. package/cloud-runtime/standalone/apps/local/.next/server/chunks/apps_local_f8b3abae._.js +1 -1
  132. package/cloud-runtime/standalone/apps/local/.next/server/chunks/apps_local_lib_orchestrator_chat-processor_ts_46384f36._.js +12 -12
  133. package/cloud-runtime/standalone/apps/local/.next/server/chunks/ssr/[root-of-the-server]__b8484b0e._.js +1 -1
  134. package/cloud-runtime/standalone/apps/local/.next/server/chunks/ssr/apps_local_5eebb5cb._.js +1 -1
  135. package/cloud-runtime/standalone/apps/local/.next/server/chunks/ssr/apps_local_components_projects_ProjectObjectivesWorkspace_tsx_751ab3d3._.js +7 -7
  136. package/cloud-runtime/standalone/apps/local/.next/server/middleware-manifest.json +5 -5
  137. package/cloud-runtime/standalone/apps/local/.next/server/pages/404.html +2 -2
  138. package/cloud-runtime/standalone/apps/local/.next/server/pages/500.html +2 -2
  139. package/cloud-runtime/standalone/apps/local/.next/server/server-reference-manifest.js +1 -1
  140. package/cloud-runtime/standalone/apps/local/.next/server/server-reference-manifest.json +1 -1
  141. package/cloud-runtime/standalone/apps/local/.next/static/chunks/7148feb61274d431.css +1 -0
  142. package/cloud-runtime/standalone/apps/local/.next/static/chunks/8b91e7692a899f00.js +20 -0
  143. package/cloud-runtime/standalone/apps/local/.next/static/chunks/{6c278ae4535b6d5c.js → 9e2208153f276f8c.js} +1 -1
  144. package/cloud-runtime/standalone/apps/local/.next/static/chunks/d590384ce3045a12.js +5 -0
  145. package/cloud-runtime/standalone/apps/local/app/api/trackers/connections/route.ts +46 -2
  146. package/cloud-runtime/standalone/apps/local/app/projects/[slug]/tracking/connect/page.tsx +41 -11
  147. package/cloud-runtime/standalone/apps/local/components/projects/ProjectObjectivesWorkspace.tsx +204 -49
  148. package/cloud-runtime/standalone/apps/local/hooks/useTrackerConnections.ts +29 -1
  149. package/cloud-runtime/standalone/apps/local/lib/agent-process-registry.ts +8 -2
  150. package/cloud-runtime/standalone/apps/local/lib/tracker/connections.ts +46 -15
  151. package/cloud-runtime/standalone/apps/local/src/prompt-scheduler/objective-worker.ts +7 -0
  152. package/cloud-runtime/standalone/apps/local/src/prompt-scheduler/task-worker.ts +7 -0
  153. package/cloud-runtime/standalone/apps/local/worker/index.js +7 -2
  154. package/package.json +1 -1
  155. package/cloud-runtime/standalone/apps/local/.next/server/chunks/[root-of-the-server]__847236fb._.js +0 -3
  156. package/cloud-runtime/standalone/apps/local/.next/server/chunks/apps_local_80b34b78._.js +0 -3
  157. package/cloud-runtime/standalone/apps/local/.next/static/chunks/cecf3e8c47c785f5.js +0 -5
  158. package/cloud-runtime/standalone/apps/local/.next/static/chunks/e72724fd8225ec39.js +0 -20
  159. package/cloud-runtime/standalone/apps/local/.next/static/chunks/f6d31036588ddfe4.css +0 -1
  160. /package/cloud-runtime/standalone/apps/local/.next/static/{4MnUE2NHztybGBWFbcBo5 → 3-6VaSnGGXdV-2eV44RDK}/_buildManifest.js +0 -0
  161. /package/cloud-runtime/standalone/apps/local/.next/static/{4MnUE2NHztybGBWFbcBo5 → 3-6VaSnGGXdV-2eV44RDK}/_clientMiddlewareManifest.json +0 -0
  162. /package/cloud-runtime/standalone/apps/local/.next/static/{4MnUE2NHztybGBWFbcBo5 → 3-6VaSnGGXdV-2eV44RDK}/_ssgManifest.js +0 -0
@@ -86,6 +86,6 @@ module.exports=[11061,e=>{"use strict";var t=e.i(522734),r=e.i(446786),s=e.i(814
86
86
  SELECT id FROM chat_runs WHERE thread_id = lr.thread_id ORDER BY updated_at DESC LIMIT 1
87
87
  )
88
88
  WHERE cr.status IN ('queued', 'running')`;return(r?t.prepare(s).all(e.trim()):t.prepare(s).all()).map(e=>({issueId:e.issue_id,agentId:e.agent_id,agentName:e.agent_name}))})}e.s(["getIssueActiveAgents",()=>p,"listLinearRuns",()=>d])},720395,e=>{"use strict";var t=e.i(84516),r=e.i(29764),s=e.i(11061),i=e.i(124985);e.i(243174);var a=e.i(248821),n=e.i(901977);let o="project_objective_health_history",c={"on track":"on_track","at risk":"at_risk","off track":"off_track",done:"done"};function u(e){return!!e&&"object"==typeof e&&!Array.isArray(e)}function l(e){return"number"==typeof e&&Number.isFinite(e)?Math.max(0,Math.min(100,Math.round(e))):0}function d(e){return"string"==typeof e&&e.trim()?e.trim():void 0}function p(...e){let t=e.flatMap(e=>e??[]),r=[];for(let e of[...t].sort((e,t)=>Date.parse(e.recordedAt)-Date.parse(t.recordedAt))){let t=r[r.length-1]??null;t&&t.progress===e.progress&&t.status===e.status&&(!t.source||!e.source||t.source===e.source)&&5e3>=Math.abs(Date.parse(e.recordedAt)-Date.parse(t.recordedAt))||r.push(e)}return r}var T=e.i(460275),_=e.i(765443);let E={on_track:"On track",at_risk:"At risk",off_track:"Off track",done:"Done"};async function m(e){let t=Date.now(),r="";try{return await (0,T.runCliResponse)({provider:e.provider,model:e.model,prompt:e.prompt,identity:e.identity,self:e.self,skills:e.skills,systemContext:e.systemContext,passthroughArgs:e.cliArgs?e.cliArgs.split(/\s+/).filter(Boolean):void 0,onDelta:e=>{r+=e},onSpawn:e.onSpawn}),{output:r,error:"",durationMs:Date.now()-t,status:"success"}}catch(e){return{output:r,error:e instanceof Error?e.message:String(e),durationMs:Date.now()-t,status:"failed"}}}function g(e){try{let t=JSON.parse(e);return t&&"object"==typeof t&&!Array.isArray(t)?t:null}catch{return null}}function h(e){let t=e.trim();if(!t)return null;let r=g(t);if(r)return r;let s=t.indexOf("{"),i=t.lastIndexOf("}");return -1===s||i<=s?null:g(t.slice(s,i+1))}function N(e){return"number"==typeof e&&Number.isFinite(e)?(0,_.normalizeProjectHealthProgress)(e):null}function j(e){return"string"==typeof e&&e.trim()?(0,_.normalizeProjectHealthStatus)(e):null}function I(e,t,r){return`${e}: ${t}% ${E[r]}`}function f(e){return[`- id: ${e.id}`,` identifier: ${e.identifier}`,` title: ${e.title}`,` status: ${e.status}`,` assignee: ${e.assignee??"Unassigned"}`,e.url?` url: ${e.url}`:null].filter(e=>!!e).join("\n")}async function b(e){let{job:n,objectiveContext:o}=e,{project:c,workspace:u,objective:l}=o,d=c.slug??c.id,[{issues:p},T,_,E]=await Promise.all([(0,r.listObjectiveTrackerIssues)({projectId:c.id,objectiveKey:l.key,projectSlug:d,refresh:!0}),(0,s.getIssueActiveAgents)(c.id),Promise.resolve((0,i.getActivityRepository)(d,l.key).list({limit:20})),Promise.resolve((0,a.getNoteRepository)(d,l.key).readAll())]),m=new Set(p.map(e=>e.id)),g=T.filter(e=>m.has(e.issueId)),h=(0,r.filterObjectiveTrackerIssuesForAction)(p,g.map(e=>e.issueId)),N=(0,t.getPromptJobStore)().listJobs({objectiveId:l.id}).filter(e=>e.id!==n.id),j=u.objectives.filter(e=>e.id!==l.id),I=[];I.push("GOAL",l.title,l.summary?.trim()||"No summary provided."),I.push("","CURRENT STATE",`Progress: ${l.progress}% | Status: ${l.status}`),E.length>0&&I.push("","NOTES",...E.map(e=>`### ${e.title}
89
- ${e.body}`));let b=_.activities??[];return b.length>0&&I.push("","RECENT ACTIVITY",...b.map(e=>{let t=e.createdAt.replace("T"," ").replace(/\.\d+Z$/,"").slice(0,16);return`- [${t}] ${e.body.split("\n")[0]}`})),p.length>0?I.push("","LINEAR TICKETS",p.map(e=>f(e)).join("\n\n")):I.push("","LINEAR TICKETS","- None."),g.length>0&&I.push("","ACTIVE SESSIONS",...g.map(e=>`- ${e.issueId}: running with ${e.agentName}`)),N.length>0&&I.push("","SCHEDULED TASKS",...N.map(e=>`- ${e.name} | state: ${e.state} | last outcome: ${e.lastOutcome??"none"}`)),j.length>0&&I.push("","PROJECT CONTEXT",...j.map(e=>`- ${e.title} (${e.key}) | ${e.progress}% | ${e.status}`)),I.push("","GUIDANCE",n.prompt.trim()||"No additional guidance provided."),I.push("","ELIGIBLE TICKETS",h.length>0?h.map(e=>f(e)).join("\n\n"):"- None."),I.push("","---","What single action most advances this objective right now?"),{prompt:I.join("\n"),issues:p,eligibleIssues:h,activeIssueAgents:g}}async function L(t){let r=Date.now();try{if(!t.job.projectId||!t.job.objectiveId)throw Error("Objective worker jobs require projectId and objectiveId.");let s=await (0,n.loadProjectObjectiveContext)(t.job.projectId,t.job.objectiveId);if(!s)throw Error("Objective context could not be resolved for this scheduled task.");let i=await b({job:t.job,objectiveContext:s}),a=await m({...t.controllerContext,prompt:i.prompt,systemContext:'You are deciding what action an objective worker should take next.\nReturn ONLY raw JSON with no markdown fences or commentary.\nValid responses:\n{"action":"work_ticket","ticketId":"ticket-id","reason":"...","objectiveProgress":42,"objectiveStatus":"at_risk","projectProgress":35,"projectStatus":"at_risk"}\n{"action":"run_prompt","prompt":"detailed instructions","reason":"...","objectiveProgress":42,"objectiveStatus":"at_risk"}\n{"action":"stop","reason":"...","objectiveProgress":42,"objectiveStatus":"at_risk"}\nRules:\n- "work_ticket": ticketId must exactly match one of the ELIGIBLE TICKETS ids.\n- "run_prompt": for work not captured by existing tickets. When no tickets are actionable and the objective is not done, use this to plan: review notes, refine the last plan, or outline next steps. The prompt should instruct the agent to append to an existing note when one is relevant rather than creating a new note.\n- "stop": only when the objective is done or genuinely no action (including planning) adds value.\nPercentages must be integers 0-100.\nStatuses: on_track, at_risk, off_track, done.',cliArgs:t.cliArgs,onSpawn:t.onSpawn});if("success"!==a.status)return{...a,output:a.output||"Objective controller failed before selecting an action."};let T=h(a.output),E="string"==typeof T?.action?T.action.trim().toLowerCase():"string"==typeof T?.decision?T.decision.trim().toLowerCase():"",g="string"==typeof T?.reason?T.reason.trim():"",f=N(T?.objectiveProgress),L=j(T?.objectiveStatus),O=N(T?.projectProgress),A=j(T?.projectStatus),v="string"==typeof T?.projectNote?T.projectNote.trim():"",S="string"==typeof T?.objectiveNote?T.objectiveNote.trim():"",y=new Date().toISOString(),R=null!==f&&L?I("Objective health",f,L):null,k=null!==O&&A?I("Project health",O,A):null,w=null!==f&&null!==L?{objectiveId:s.objective.id,objectiveKey:s.objective.key,progress:f,status:L,recordedAt:y,source:`scheduled-task:${t.job.id}`,note:S||void 0}:null,D=null!==f&&null!==L&&(f!==s.objective.progress||L!==s.objective.status),X=D?(0,_.upsertProjectObjective)(s.workspace,{...s.objective,progress:f,status:L,updatedAt:y}):s.workspace,C=null!==O&&null!==A?{progress:O,status:A,updatedAt:y,source:`scheduled-task:${t.job.id}`,objectiveId:s.objective.id,objectiveKey:s.objective.key,note:v||void 0}:null,U=e=>{let t=e;return C&&(t=(0,_.writeProjectHealthSnapshot)(t,C)),w&&(t=function(e,t){let r=t.objectiveId.trim();if(!r)return e;let s=function(e,t){if(!u(e)||!t.trim())return[];let r=e[o];if(!u(r))return[];let s=r[t.trim()];return Array.isArray(s)?p(s.map(e=>(function(e){if(!u(e))return null;let t=function(e){if("string"!=typeof e)return null;let t=e.trim().toLowerCase();return"on_track"===t||"at_risk"===t||"off_track"===t||"done"===t?t:c[t]??null}(e.status),r=function(e){if("string"!=typeof e)return null;let t=Date.parse(e);return Number.isNaN(t)?null:new Date(t).toISOString()}(e.recordedAt);return t&&r?{progress:l(e.progress),status:t,recordedAt:r,source:d(e.source),note:d(e.note),objectiveId:d(e.objectiveId)??null,objectiveKey:d(e.objectiveKey)??null}:null})(e)).filter(e=>!!e)):[]}(e,r),i=p(s,[t]).slice(-200),a=u(e[o])?e[o]:{};return{...e,[o]:{...a,[r]:i.map(e=>({progress:l(e.progress),status:e.status,recordedAt:e.recordedAt,...e.source?{source:e.source}:{},...e.note?{note:e.note}:{},...e.objectiveId?{objectiveId:e.objectiveId}:{},...e.objectiveKey?{objectiveKey:e.objectiveKey}:{}}))}}}(t,w)),t};D?await (0,n.persistProjectObjectiveWorkspace)({projectId:s.project.id,currentMetadata:s.project.metadata,workspace:X,transformMetadata:U}):(w||C)&&await (0,n.persistProjectObjectiveMetadata)({projectId:s.project.id,currentMetadata:s.project.metadata,transformMetadata:U});let{dispatchObjectiveAction:M}=await e.A(688671),x=await M({action:"work"===E?"work_ticket":E,parsed:T,reason:g,job:t.job,controllerContext:t.controllerContext,sessionAgent:t.sessionAgent,objectiveContext:s,eligibleIssues:i.eligibleIssues,issues:i.issues,healthSummaries:{objectiveHealthSummary:R,projectHealthSummary:k,objectiveNote:S,projectNote:v},cliArgs:t.cliArgs,onSpawn:t.onSpawn,startMs:r}),{logActionReceipt:P}=await e.A(688671);return await P(x,{jobId:t.job.id,projectId:t.job.projectId,objectiveId:t.job.objectiveId}),{output:x.result,error:"failed"===x.status?x.result:"",durationMs:Date.now()-r,status:x.status}}catch(e){return{output:"",error:e instanceof Error?e.message:String(e),durationMs:Date.now()-r,status:"failed"}}}e.s(["buildObjectiveObservation",()=>b,"executeObjectiveWorker",()=>L,"extractFirstJsonObject",()=>h],720395)},688671,e=>{e.v(e=>Promise.resolve().then(()=>e(917435)))}];
89
+ ${e.body}`));let b=_.activities??[];return b.length>0&&I.push("","RECENT ACTIVITY",...b.map(e=>{let t=e.createdAt.replace("T"," ").replace(/\.\d+Z$/,"").slice(0,16);return`- [${t}] ${e.body.split("\n")[0]}`})),p.length>0?I.push("","LINEAR TICKETS",p.map(e=>f(e)).join("\n\n")):I.push("","LINEAR TICKETS","- None."),g.length>0&&I.push("","ACTIVE SESSIONS",...g.map(e=>`- ${e.issueId}: running with ${e.agentName}`)),N.length>0&&I.push("","SCHEDULED TASKS",...N.map(e=>`- ${e.name} | state: ${e.state} | last outcome: ${e.lastOutcome??"none"}`)),j.length>0&&I.push("","PROJECT CONTEXT",...j.map(e=>`- ${e.title} (${e.key}) | ${e.progress}% | ${e.status}`)),I.push("","GUIDANCE",n.prompt.trim()||"No additional guidance provided."),I.push("","ELIGIBLE TICKETS",h.length>0?h.map(e=>f(e)).join("\n\n"):"- None."),I.push("","---","What single action most advances this objective right now?"),{prompt:I.join("\n"),issues:p,eligibleIssues:h,activeIssueAgents:g}}async function L(t){let r=Date.now();try{if(!t.job.projectId||!t.job.objectiveId)throw Error("Objective worker jobs require projectId and objectiveId.");let s=await (0,n.loadProjectObjectiveContext)(t.job.projectId,t.job.objectiveId);if(!s)throw Error("Objective context could not be resolved for this scheduled task.");let i=await b({job:t.job,objectiveContext:s}),a=await m({...t.controllerContext,prompt:i.prompt,systemContext:'You are deciding what action an objective worker should take next.\nReturn ONLY raw JSON with no markdown fences or commentary.\nValid responses:\n{"action":"work_ticket","ticketId":"ticket-id","reason":"...","objectiveProgress":42,"objectiveStatus":"at_risk","projectProgress":35,"projectStatus":"at_risk"}\n{"action":"run_prompt","prompt":"detailed instructions","reason":"...","objectiveProgress":42,"objectiveStatus":"at_risk"}\n{"action":"stop","reason":"...","objectiveProgress":42,"objectiveStatus":"at_risk"}\nRules:\n- "work_ticket": ticketId must exactly match one of the ELIGIBLE TICKETS ids.\n- "run_prompt": for work not captured by existing tickets. When no tickets are actionable and the objective is not done, use this to plan: review notes, refine the last plan, or outline next steps. The prompt should instruct the agent to append to an existing note when one is relevant rather than creating a new note.\n- "stop": only when the objective is done or genuinely no action (including planning) adds value.\nPercentages must be integers 0-100.\nStatuses: on_track, at_risk, off_track, done.',cliArgs:t.cliArgs,onSpawn:t.onSpawn});if("success"!==a.status)return{...a,output:a.output||"Objective controller failed before selecting an action."};let T=h(a.output),E="string"==typeof T?.action?T.action.trim().toLowerCase():"string"==typeof T?.decision?T.decision.trim().toLowerCase():"",g="work"===E?"work_ticket":E;if(!g){let e=a.output??"";console.warn(`[objective-worker] empty action from controller (job=${t.job.id}, outputLen=${e.length}, parsed=${T?"object":"null"}):`,e.slice(0,500))}let f="string"==typeof T?.reason?T.reason.trim():"",L=N(T?.objectiveProgress),O=j(T?.objectiveStatus),v=N(T?.projectProgress),A=j(T?.projectStatus),S="string"==typeof T?.projectNote?T.projectNote.trim():"",y="string"==typeof T?.objectiveNote?T.objectiveNote.trim():"",R=new Date().toISOString(),k=null!==L&&O?I("Objective health",L,O):null,w=null!==v&&A?I("Project health",v,A):null,D=null!==L&&null!==O?{objectiveId:s.objective.id,objectiveKey:s.objective.key,progress:L,status:O,recordedAt:R,source:`scheduled-task:${t.job.id}`,note:y||void 0}:null,X=null!==L&&null!==O&&(L!==s.objective.progress||O!==s.objective.status),C=X?(0,_.upsertProjectObjective)(s.workspace,{...s.objective,progress:L,status:O,updatedAt:R}):s.workspace,U=null!==v&&null!==A?{progress:v,status:A,updatedAt:R,source:`scheduled-task:${t.job.id}`,objectiveId:s.objective.id,objectiveKey:s.objective.key,note:S||void 0}:null,M=e=>{let t=e;return U&&(t=(0,_.writeProjectHealthSnapshot)(t,U)),D&&(t=function(e,t){let r=t.objectiveId.trim();if(!r)return e;let s=function(e,t){if(!u(e)||!t.trim())return[];let r=e[o];if(!u(r))return[];let s=r[t.trim()];return Array.isArray(s)?p(s.map(e=>(function(e){if(!u(e))return null;let t=function(e){if("string"!=typeof e)return null;let t=e.trim().toLowerCase();return"on_track"===t||"at_risk"===t||"off_track"===t||"done"===t?t:c[t]??null}(e.status),r=function(e){if("string"!=typeof e)return null;let t=Date.parse(e);return Number.isNaN(t)?null:new Date(t).toISOString()}(e.recordedAt);return t&&r?{progress:l(e.progress),status:t,recordedAt:r,source:d(e.source),note:d(e.note),objectiveId:d(e.objectiveId)??null,objectiveKey:d(e.objectiveKey)??null}:null})(e)).filter(e=>!!e)):[]}(e,r),i=p(s,[t]).slice(-200),a=u(e[o])?e[o]:{};return{...e,[o]:{...a,[r]:i.map(e=>({progress:l(e.progress),status:e.status,recordedAt:e.recordedAt,...e.source?{source:e.source}:{},...e.note?{note:e.note}:{},...e.objectiveId?{objectiveId:e.objectiveId}:{},...e.objectiveKey?{objectiveKey:e.objectiveKey}:{}}))}}}(t,D)),t};X?await (0,n.persistProjectObjectiveWorkspace)({projectId:s.project.id,currentMetadata:s.project.metadata,workspace:C,transformMetadata:M}):(D||U)&&await (0,n.persistProjectObjectiveMetadata)({projectId:s.project.id,currentMetadata:s.project.metadata,transformMetadata:M});let{dispatchObjectiveAction:$}=await e.A(688671),x=await $({action:g,parsed:T,reason:f,job:t.job,controllerContext:t.controllerContext,sessionAgent:t.sessionAgent,objectiveContext:s,eligibleIssues:i.eligibleIssues,issues:i.issues,healthSummaries:{objectiveHealthSummary:k,projectHealthSummary:w,objectiveNote:y,projectNote:S},cliArgs:t.cliArgs,onSpawn:t.onSpawn,startMs:r}),{logActionReceipt:P}=await e.A(688671);return await P(x,{jobId:t.job.id,projectId:t.job.projectId,objectiveId:t.job.objectiveId}),{output:x.result,error:"failed"===x.status?x.result:"",durationMs:Date.now()-r,status:x.status}}catch(e){return{output:"",error:e instanceof Error?e.message:String(e),durationMs:Date.now()-r,status:"failed"}}}e.s(["buildObjectiveObservation",()=>b,"executeObjectiveWorker",()=>L,"extractFirstJsonObject",()=>h],720395)},688671,e=>{e.v(e=>Promise.resolve().then(()=>e(917435)))}];
90
90
 
91
91
  //# sourceMappingURL=apps_local_f8b3abae._.js.map
@@ -1,4 +1,4 @@
1
- module.exports=[329893,e=>{"use strict";var t=e.i(924868),a=e.i(374371),n=e.i(801243),i=e.i(814747),r=e.i(446786),s=e.i(522734);let{DatabaseSync:o}=process.getBuiltinModule("node:sqlite"),d=process.env.AGX_GROUP_CHAT_DIR?.trim()||i.default.join(r.default.homedir(),".agx","group-chat"),l=i.default.join(d,"history.sqlite");function c(e){return{id:e.id,workspaceId:e.workspace_id,threadId:e.thread_id,agentId:e.agent_id,pid:e.pid,state:e.state,sinceMessageId:e.since_message_id,responseMessageId:e.response_message_id||"",startedAt:e.started_at,lastActivity:e.last_activity,projectSlug:e.project_slug||""}}function p(e){let t=function(){(0,s.mkdirSync)(d,{recursive:!0});let e=new o(l);(0,n.pragmaSet)(e,"journal_mode = WAL"),e.exec(`
1
+ module.exports=[329893,e=>{"use strict";var t=e.i(924868),a=e.i(374371),n=e.i(801243),i=e.i(814747),r=e.i(446786),s=e.i(522734);let{DatabaseSync:o}=process.getBuiltinModule("node:sqlite"),l=process.env.AGX_GROUP_CHAT_DIR?.trim()||i.default.join(r.default.homedir(),".agx","group-chat"),d=i.default.join(l,"history.sqlite");function c(e){return{id:e.id,workspaceId:e.workspace_id,threadId:e.thread_id,agentId:e.agent_id,pid:e.pid,state:e.state,sinceMessageId:e.since_message_id,responseMessageId:e.response_message_id||"",startedAt:e.started_at,lastActivity:e.last_activity,projectSlug:e.project_slug||""}}function p(e){let t=function(){(0,s.mkdirSync)(l,{recursive:!0});let e=new o(d);(0,n.pragmaSet)(e,"journal_mode = WAL"),e.exec(`
2
2
  CREATE TABLE IF NOT EXISTS agent_processes (
3
3
  id INTEGER PRIMARY KEY AUTOINCREMENT,
4
4
  workspace_id TEXT NOT NULL,
@@ -12,7 +12,7 @@ module.exports=[329893,e=>{"use strict";var t=e.i(924868),a=e.i(374371),n=e.i(80
12
12
  project_slug TEXT NOT NULL DEFAULT '',
13
13
  UNIQUE (workspace_id, agent_id)
14
14
  )
15
- `),e.exec("CREATE INDEX IF NOT EXISTS idx_agent_processes_state ON agent_processes (state)"),e.exec("CREATE INDEX IF NOT EXISTS idx_agent_processes_thread ON agent_processes (thread_id)"),e.exec("CREATE INDEX IF NOT EXISTS idx_agent_processes_workspace ON agent_processes (workspace_id)");try{e.exec("ALTER TABLE agent_processes ADD COLUMN project_slug TEXT NOT NULL DEFAULT ''")}catch{}try{e.exec("ALTER TABLE agent_processes ADD COLUMN response_message_id TEXT NOT NULL DEFAULT ''")}catch{}return e.exec(`
15
+ `),e.exec("CREATE INDEX IF NOT EXISTS idx_agent_processes_state ON agent_processes (state)"),e.exec("CREATE INDEX IF NOT EXISTS idx_agent_processes_thread ON agent_processes (thread_id)"),e.exec("CREATE INDEX IF NOT EXISTS idx_agent_processes_workspace ON agent_processes (workspace_id)");try{e.exec("ALTER TABLE agent_processes ADD COLUMN project_slug TEXT NOT NULL DEFAULT ''")}catch{}try{e.exec("ALTER TABLE agent_processes ADD COLUMN response_message_id TEXT NOT NULL DEFAULT ''")}catch{}e.exec(`
16
16
  CREATE TABLE IF NOT EXISTS messages (
17
17
  thread_id TEXT NOT NULL,
18
18
  id TEXT NOT NULL,
@@ -22,7 +22,7 @@ module.exports=[329893,e=>{"use strict";var t=e.i(924868),a=e.i(374371),n=e.i(80
22
22
  timestamp INTEGER NOT NULL,
23
23
  PRIMARY KEY (thread_id, id)
24
24
  )
25
- `),e.prepare("SELECT name FROM sqlite_master WHERE type='table' AND name='linear_runs'").get()&&e.exec("ALTER TABLE linear_runs RENAME TO tracker_runs"),e.exec(`
25
+ `);let t=e.prepare("SELECT name FROM sqlite_master WHERE type='table' AND name='linear_runs'").get(),a=e.prepare("SELECT name FROM sqlite_master WHERE type='table' AND name='tracker_runs'").get();return t&&!a?e.exec("ALTER TABLE linear_runs RENAME TO tracker_runs"):t&&a&&e.exec("DROP TABLE linear_runs"),e.exec(`
26
26
  CREATE TABLE IF NOT EXISTS tracker_runs (
27
27
  id TEXT PRIMARY KEY,
28
28
  project_id TEXT,
@@ -56,8 +56,8 @@ module.exports=[329893,e=>{"use strict";var t=e.i(924868),a=e.i(374371),n=e.i(80
56
56
  created_at INTEGER NOT NULL
57
57
  );
58
58
  CREATE INDEX IF NOT EXISTS idx_attachments_message ON attachments(message_id);
59
- `),!a.prepare("PRAGMA table_info(attachments)").all().some(e=>"disk_name"===e.name)){a.exec("ALTER TABLE attachments ADD COLUMN disk_name TEXT NOT NULL DEFAULT ''");let e=a.prepare("SELECT id, filename FROM attachments WHERE disk_name = ''").all(),t=a.prepare("UPDATE attachments SET disk_name = ? WHERE id = ?");for(let a of e){let e=a.filename.includes(".")?"."+a.filename.split(".").pop().toLowerCase():"";t.run(a.id+e,a.id)}}let t=a.prepare("SELECT filename, disk_name, mime_type, size FROM attachments WHERE id = ?").get(e);if(!t)return null;let n=t.disk_name||e;return{filename:t.filename,mimeType:t.mime_type,size:t.size,diskPath:i.default.join(E,n)}}finally{a.close()}}var L=e.i(633211),v=e.i(855532),N=e.i(329905),b=e.i(224316),$=e.i(888652);let S=(0,i.join)((0,r.homedir)(),".agx","agents");var R=e.i(476805),A=e.i(121239),k=e.i(254799);let O=new Map,D=new Map;function U(e){return null!==e}let x="I evolve through experience and collaboration.";function C(e,t){let a=e.replace(/\s+/g," ").trim();if(!a)return`I am ${t}. ${x}`;let n=a.replace(/^you are\b[^.!?\n]*[.!?]?\s*/i,`I am ${t}. `);return(/^i am\b/i.test(n)?n:`I am ${t}. ${n}`).slice(0,500).trim()}function j(e,t){(0,b.ensureAgent)(e.id,{voice:e.voice?.trim()||`${e.name} style`,seed:function(e,t,a){let n=String(a||"").trim();if(n)return C(n,t);let i=String(e||"").trim();return i?C(i,t):`I am ${t}. ${x}`}(t,e.name,e.seed)})}async function M(e){j(e);let t=(0,b.readIdentity)(e.id);if(!t)return;let n=(0,v.readSelf)(e.id),r=(0,v.readReflectionState)(e.id),o=(0,N.readJournalSince)(e.id,r?.lastProcessedJournalId).filter(e=>"post"===e.type);if(0===o.length)return;let d=(0,b.getTeamSelves)(e.id),l=(n?.version??0)+1,c=(0,R.listKnowledgeEntries)({scope:"agent",subjectId:e.id,limit:50}),p=(0,v.buildStructuredReflectionPrompt)(t,n,o,d,c),u="";await (0,a.runCliResponse)({provider:e.provider,model:e.model,systemContext:"You are performing a self-modeling exercise. Output ONLY raw JSON matching the requested schema. No markdown fences, no commentary.",prompt:p,signal:void 0,onDelta:e=>{u+=e}});let g=u.trim().replace(/^```(?:json)?\s*/i,"").replace(/\s*```\s*$/,"").trim(),m=null;try{m=JSON.parse(g)}catch{m=null}let f=m?.self_model?.trim()||"";if(!f)return;let h=Array.isArray(m?.memories)?m.memories.slice(0,3).map(t=>({scope:"agent",subjectId:e.id,sourceType:"reflection",sourceId:o[o.length-1]?.id||`reflection:${e.id}:${l}`,kind:t.kind,title:String(t.title??"").trim(),body:String(t.body??"").trim(),confidence:t.confidence,durability:t.durability,tags:t.tags,evidence:Array.isArray(t.evidence)?t.evidence.map(e=>{let t=String(e?.note??"").trim(),a="string"==typeof e?.id?e.id.trim():"";return t?a?{id:a,note:t}:{note:t}:null}).filter(U):[],metadata:{reflection_window_start:o[0]?.id??null,reflection_window_end:o[o.length-1]?.id??null,self_version:l}})).filter(e=>e.title&&e.body):[],y=(0,R.storeKnowledgeEntries)(h);if((0,v.writeSelf)(e.id,f,l),(0,v.writeReflectionState)(e.id,{lastProcessedJournalId:o[o.length-1]?.id??r?.lastProcessedJournalId??null,updatedAt:new Date().toISOString()}),y>0){let t=(0,L.getSQLiteDb)().prepare(`INSERT OR IGNORE INTO agent_memory (id, agent_id, task_id, memory_type, content, content_hash, created_at)
60
- VALUES (?, ?, ?, ?, ?, ?, ?)`),a=`reflection:${e.id}:${o[o.length-1]?.id??l}`,n=Date.now();for(let i of h){let r="decision"===i.kind?"decision":"gotcha"===i.kind||"constraint"===i.kind?"gotcha":"outcome"===i.kind?"outcome":"pattern",s=(0,k.createHash)("sha256").update(i.body.trim()).digest("hex");t.run((0,k.randomUUID)(),e.id,a,r,i.body.trim(),s,n)}}(0,N.appendJournal)(e.id,{t:new Date().toISOString(),type:"reflection",observation:"Reflected after 10 messages",judgement:"Updated self-model from incremental journal evidence and deduped agent memories",delta:`self-model updated to v${l}${y>0?`; stored ${y} agent memories`:""}`,threads:[],selfVersion:l,body:f});let T=(0,b.listAgents)().filter(t=>t!==e.id).flatMap(e=>(0,N.readJournal)(e,3).map(t=>({agentId:e,entry:t})));if(T.length>0){let t=T.map(e=>`${e.entry.id}: ${e.entry.observation.slice(0,200)}`).join("\n"),n="";try{await (0,a.runCliResponse)({provider:e.provider,model:e.model,prompt:`You are ${e.id}. Review these recent entries from other agents and react to any that resonate with you.
59
+ `),!a.prepare("PRAGMA table_info(attachments)").all().some(e=>"disk_name"===e.name)){a.exec("ALTER TABLE attachments ADD COLUMN disk_name TEXT NOT NULL DEFAULT ''");let e=a.prepare("SELECT id, filename FROM attachments WHERE disk_name = ''").all(),t=a.prepare("UPDATE attachments SET disk_name = ? WHERE id = ?");for(let a of e){let e=a.filename.includes(".")?"."+a.filename.split(".").pop().toLowerCase():"";t.run(a.id+e,a.id)}}let t=a.prepare("SELECT filename, disk_name, mime_type, size FROM attachments WHERE id = ?").get(e);if(!t)return null;let n=t.disk_name||e;return{filename:t.filename,mimeType:t.mime_type,size:t.size,diskPath:i.default.join(E,n)}}finally{a.close()}}var L=e.i(633211),v=e.i(855532),N=e.i(329905),b=e.i(224316),R=e.i(888652);let $=(0,i.join)((0,r.homedir)(),".agx","agents");var S=e.i(476805),A=e.i(121239),k=e.i(254799);let O=new Map,D=new Map;function U(e){return null!==e}let x="I evolve through experience and collaboration.";function C(e,t){let a=e.replace(/\s+/g," ").trim();if(!a)return`I am ${t}. ${x}`;let n=a.replace(/^you are\b[^.!?\n]*[.!?]?\s*/i,`I am ${t}. `);return(/^i am\b/i.test(n)?n:`I am ${t}. ${n}`).slice(0,500).trim()}function j(e,t){(0,b.ensureAgent)(e.id,{voice:e.voice?.trim()||`${e.name} style`,seed:function(e,t,a){let n=String(a||"").trim();if(n)return C(n,t);let i=String(e||"").trim();return i?C(i,t):`I am ${t}. ${x}`}(t,e.name,e.seed)})}async function M(e){j(e);let t=(0,b.readIdentity)(e.id);if(!t)return;let n=(0,v.readSelf)(e.id),r=(0,v.readReflectionState)(e.id),o=(0,N.readJournalSince)(e.id,r?.lastProcessedJournalId).filter(e=>"post"===e.type);if(0===o.length)return;let l=(0,b.getTeamSelves)(e.id),d=(n?.version??0)+1,c=(0,S.listKnowledgeEntries)({scope:"agent",subjectId:e.id,limit:50}),p=(0,v.buildStructuredReflectionPrompt)(t,n,o,l,c),u="";await (0,a.runCliResponse)({provider:e.provider,model:e.model,systemContext:"You are performing a self-modeling exercise. Output ONLY raw JSON matching the requested schema. No markdown fences, no commentary.",prompt:p,signal:void 0,onDelta:e=>{u+=e}});let g=u.trim().replace(/^```(?:json)?\s*/i,"").replace(/\s*```\s*$/,"").trim(),m=null;try{m=JSON.parse(g)}catch{m=null}let f=m?.self_model?.trim()||"";if(!f)return;let h=Array.isArray(m?.memories)?m.memories.slice(0,3).map(t=>({scope:"agent",subjectId:e.id,sourceType:"reflection",sourceId:o[o.length-1]?.id||`reflection:${e.id}:${d}`,kind:t.kind,title:String(t.title??"").trim(),body:String(t.body??"").trim(),confidence:t.confidence,durability:t.durability,tags:t.tags,evidence:Array.isArray(t.evidence)?t.evidence.map(e=>{let t=String(e?.note??"").trim(),a="string"==typeof e?.id?e.id.trim():"";return t?a?{id:a,note:t}:{note:t}:null}).filter(U):[],metadata:{reflection_window_start:o[0]?.id??null,reflection_window_end:o[o.length-1]?.id??null,self_version:d}})).filter(e=>e.title&&e.body):[],y=(0,S.storeKnowledgeEntries)(h);if((0,v.writeSelf)(e.id,f,d),(0,v.writeReflectionState)(e.id,{lastProcessedJournalId:o[o.length-1]?.id??r?.lastProcessedJournalId??null,updatedAt:new Date().toISOString()}),y>0){let t=(0,L.getSQLiteDb)().prepare(`INSERT OR IGNORE INTO agent_memory (id, agent_id, task_id, memory_type, content, content_hash, created_at)
60
+ VALUES (?, ?, ?, ?, ?, ?, ?)`),a=`reflection:${e.id}:${o[o.length-1]?.id??d}`,n=Date.now();for(let i of h){let r="decision"===i.kind?"decision":"gotcha"===i.kind||"constraint"===i.kind?"gotcha":"outcome"===i.kind?"outcome":"pattern",s=(0,k.createHash)("sha256").update(i.body.trim()).digest("hex");t.run((0,k.randomUUID)(),e.id,a,r,i.body.trim(),s,n)}}(0,N.appendJournal)(e.id,{t:new Date().toISOString(),type:"reflection",observation:"Reflected after 10 messages",judgement:"Updated self-model from incremental journal evidence and deduped agent memories",delta:`self-model updated to v${d}${y>0?`; stored ${y} agent memories`:""}`,threads:[],selfVersion:d,body:f});let T=(0,b.listAgents)().filter(t=>t!==e.id).flatMap(e=>(0,N.readJournal)(e,3).map(t=>({agentId:e,entry:t})));if(T.length>0){let t=T.map(e=>`${e.entry.id}: ${e.entry.observation.slice(0,200)}`).join("\n"),n="";try{await (0,a.runCliResponse)({provider:e.provider,model:e.model,prompt:`You are ${e.id}. Review these recent entries from other agents and react to any that resonate with you.
61
61
 
62
62
  Entries:
63
63
  ${t}
@@ -67,13 +67,13 @@ REACT <entryId> <type>
67
67
 
68
68
  Valid types: agree, disagree, learned-from, builds-on, curious
69
69
 
70
- Only react to entries that genuinely resonate. It's fine to react to zero entries. Output nothing else.`,signal:void 0,onDelta:e=>{n+=e}})}catch{}for(let t of n.split("\n")){let a=t.trim().match(/^REACT\s+(\S+)\s+(agree|disagree|learned-from|builds-on|curious)$/);if(a)try{!function(e,t,a){let n;if(!function(e){let[t]=e.split(":");return!!t&&(0,N.readJournal)(t).some(t=>t.id===e)}(t))throw Error(`Target entry ${t} not found`);n=(0,i.join)(S,e),(0,s.existsSync)(n)||(0,s.mkdirSync)(n,{recursive:!0});let r={agent:e,t:new Date().toISOString(),targetEntry:t,type:a};(0,s.appendFileSync)((0,i.join)(S,e,"reactions.jsonl"),JSON.stringify(r)+"\n","utf-8"),(0,$.logActivity)(e,"mesh-reaction",{meta:{target:t,type:a}})}(e.id,a[1],a[2])}catch{}}}}async function P(e){try{return await (0,t.readFile)(e,"utf-8")}catch(a){let t=a instanceof Error?a.message:String(a);return`[Error reading ${e}: ${t}]`}}async function X(e){let t=e.trim();if(!t)return{label:"unknown",content:"[Empty file reference]"};let a=function(e){let t=e.trim();if(!t)return null;let a=t.match(/^attachment:([a-zA-Z0-9-]+)$/);if(a)return a[1];let n=t.match(/\/api\/attachments\/([a-zA-Z0-9-]+)/);return n?n[1]:t.match(/^[0-9a-f]{8}-[0-9a-f]{4}-[1-5][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/i)?t:null}(t);if(a){let e=await _(a);if(e){let t=await P(e.diskPath);return{label:e.filename,content:t}}}return{label:t,content:await P(t)}}function F(e,t){let a=new Set(e.toLowerCase().replace(/[^\w\s]/g,"").split(/\s+/).filter(Boolean)),n=new Set(t.toLowerCase().replace(/[^\w\s]/g,"").split(/\s+/).filter(Boolean));if(0===a.size||0===n.size)return 0;let i=0;for(let e of a)n.has(e)&&i++;return i/(a.size+n.size-i)}async function B(e,t,n,i,r,s,o,d,l,c,g,T,I,w){var E;let _,b,S,R,k,U,x,C="";T({type:"participant-start",participantId:t.id}),T({type:"participant-thinking",participantId:t.id});let P=(_=[String(t.identity??t.identity??"").trim(),t.voice?.trim()?`Voice: ${t.voice.trim()}`:"",t.seed?.trim()?`Core orientation: ${t.seed.trim()}`:""].filter(Boolean)).length>0?_.join("\n\n"):void 0;j(t,P);let F=(0,v.readSelf)(t.id);F?.content&&(k=`[Self-Model]
70
+ Only react to entries that genuinely resonate. It's fine to react to zero entries. Output nothing else.`,signal:void 0,onDelta:e=>{n+=e}})}catch{}for(let t of n.split("\n")){let a=t.trim().match(/^REACT\s+(\S+)\s+(agree|disagree|learned-from|builds-on|curious)$/);if(a)try{!function(e,t,a){let n;if(!function(e){let[t]=e.split(":");return!!t&&(0,N.readJournal)(t).some(t=>t.id===e)}(t))throw Error(`Target entry ${t} not found`);n=(0,i.join)($,e),(0,s.existsSync)(n)||(0,s.mkdirSync)(n,{recursive:!0});let r={agent:e,t:new Date().toISOString(),targetEntry:t,type:a};(0,s.appendFileSync)((0,i.join)($,e,"reactions.jsonl"),JSON.stringify(r)+"\n","utf-8"),(0,R.logActivity)(e,"mesh-reaction",{meta:{target:t,type:a}})}(e.id,a[1],a[2])}catch{}}}}async function P(e){try{return await (0,t.readFile)(e,"utf-8")}catch(a){let t=a instanceof Error?a.message:String(a);return`[Error reading ${e}: ${t}]`}}async function X(e){let t=e.trim();if(!t)return{label:"unknown",content:"[Empty file reference]"};let a=function(e){let t=e.trim();if(!t)return null;let a=t.match(/^attachment:([a-zA-Z0-9-]+)$/);if(a)return a[1];let n=t.match(/\/api\/attachments\/([a-zA-Z0-9-]+)/);return n?n[1]:t.match(/^[0-9a-f]{8}-[0-9a-f]{4}-[1-5][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/i)?t:null}(t);if(a){let e=await _(a);if(e){let t=await P(e.diskPath);return{label:e.filename,content:t}}}return{label:t,content:await P(t)}}function F(e,t){let a=new Set(e.toLowerCase().replace(/[^\w\s]/g,"").split(/\s+/).filter(Boolean)),n=new Set(t.toLowerCase().replace(/[^\w\s]/g,"").split(/\s+/).filter(Boolean));if(0===a.size||0===n.size)return 0;let i=0;for(let e of a)n.has(e)&&i++;return i/(a.size+n.size-i)}async function B(e,t,n,i,r,s,o,l,d,c,g,T,I,w){var E;let _,b,$,S,k,U,x,C="";T({type:"participant-start",participantId:t.id}),T({type:"participant-thinking",participantId:t.id});let P=(_=[String(t.identity??t.identity??"").trim(),t.voice?.trim()?`Voice: ${t.voice.trim()}`:"",t.seed?.trim()?`Core orientation: ${t.seed.trim()}`:""].filter(Boolean)).length>0?_.join("\n\n"):void 0;j(t,P);let F=(0,v.readSelf)(t.id);F?.content&&(k=`[Self-Model]
71
71
  ${F.content}`);let B=c?.provenanceByAgentId?.[t.id],z=B?.memory??[];if(z.length>0){let e=z.map(e=>`- (${e.source}) ${e.content}`);k=[k,`[Knowledge: Agent Derived]
72
72
  ${e.join("\n")}`].filter(Boolean).join("\n\n")}let G=function(e,t,a){let n=t?.provenanceByAgentId?.[e.id]?.skills;if(n&&n.length>0)return n;let i=[],r=new Set;for(let t of e.skills??[]){let e=t.file.split("/").pop()||t.file;r.has(e)||(r.add(e),i.push({file:t.file,condition:t.condition,source:"agent"}))}for(let t of(0,A.resolveBoundSkillFiles)(e.skillBindings??[],a,e.provider)){let e=t.file.split("/").pop()||t.file;r.has(e)||(r.add(e),i.push({file:t.file,condition:t.condition,source:"agent"}))}for(let e of t?.skills??[]){let t=e.file.split("/").pop()||e.file;r.has(t)||(r.add(t),i.push({file:e.file,condition:e.condition,source:"project"}))}return i}(t,c,r);if(G.length>0){let e=await Promise.all(G.map(async e=>{let t=e.file,a=e.condition,n=await X(t),i=a?`--- ${n.label} [${e.source}] ---
73
73
  Use when: ${a}`:`--- ${n.label} [${e.source}] ---`;return`${i}
74
74
  ${n.content}`}));U=`[Knowledge References]
75
- ${e.join("\n\n")}`}let W=[function(e,t,a,n,i,r,s,o){let d=a.filter(t=>t.id!==e.id).map(e=>e.name).join(", "),l=t.map(e=>e.name).join(", "),c=t.find(t=>t.id!==e.id)?.name||"Name",p=`<role>
76
- You are "${e.name}" in a group chat. All agents: ${l}.`;d&&(p+=` Currently active in this exchange: ${d}.`),p+=`
75
+ ${e.join("\n\n")}`}let W=[function(e,t,a,n,i,r,s,o){let l=a.filter(t=>t.id!==e.id).map(e=>e.name).join(", "),d=t.map(e=>e.name).join(", "),c=t.find(t=>t.id!==e.id)?.name||"Name",p=`<role>
76
+ You are "${e.name}" in a group chat. All agents: ${d}.`;l&&(p+=` Currently active in this exchange: ${l}.`),p+=`
77
77
  Respond as ${e.name} only. Keep responses conversational and concise.
78
78
  IMPORTANT: Always respond to the user's actual question. Do not reference unrelated technical context, previous threads, or system internals unless directly asked.
79
79
  </role>
@@ -137,11 +137,11 @@ Project knowledge notes:`,t))p+=`
137
137
  - ${e.content}${e.source?` (source: ${e.source})`:""}`;let a=o?.repoKnowledge;if(a&&a.length>0)for(let e of(p+=`
138
138
  Repo knowledge:`,a)){let t=e.path?`${e.repoName} (${e.path})`:e.repoName;p+=`
139
139
  - ${t}: ${e.content}`}p+=`
140
- </project-context>`}return p}(t,n,i,s,o,d,l,c),B?`<execution-provenance>
140
+ </project-context>`}return p}(t,n,i,s,o,l,d,c),B?`<execution-provenance>
141
141
  Resolved skills: ${B.skills.map(e=>`${e.file} (${e.source})`).join(", ")||"none"}
142
142
  Resolved memory entries: ${B.memory.map(e=>`${e.source}${e.id?`:${e.id}`:""}`).join(", ")||"none"}
143
143
  </execution-provenance>`:null].filter(Boolean).join("\n\n");T({type:"log",participantId:t.id,stream:"stdout",line:`[DIAGNOSTIC] Model payload for ${t.id}:
144
- ${JSON.stringify({provider:t.provider,model:t.model,promptLength:r.length,identity:P?P.slice(0,200)+"...":void 0,self:k?k.slice(0,200)+"...":void 0,skills:U?U.slice(0,200)+"...":void 0,provenance:B,systemContext:W.slice(0,500)+"..."},null,2)}`});let H=l||"",Y=`${t.id}-${Date.now()}-${Math.random().toString(36).slice(2,8)}`,J=(E={workspaceId:e,threadId:I||"",agentId:t.id,pid:0,state:"spawning",sinceMessageId:H,responseMessageId:Y,startedAt:Date.now(),lastActivity:Date.now(),projectSlug:c?.activeProject?.slug||""},p(e=>{let t=e.prepare(`INSERT INTO agent_processes (workspace_id, thread_id, agent_id, pid, state, since_message_id, response_message_id, started_at, last_activity, project_slug)
144
+ ${JSON.stringify({provider:t.provider,model:t.model,promptLength:r.length,identity:P?P.slice(0,200)+"...":void 0,self:k?k.slice(0,200)+"...":void 0,skills:U?U.slice(0,200)+"...":void 0,provenance:B,systemContext:W.slice(0,500)+"..."},null,2)}`});let H=d||"",Y=`${t.id}-${Date.now()}-${Math.random().toString(36).slice(2,8)}`,J=(E={workspaceId:e,threadId:I||"",agentId:t.id,pid:0,state:"spawning",sinceMessageId:H,responseMessageId:Y,startedAt:Date.now(),lastActivity:Date.now(),projectSlug:c?.activeProject?.slug||""},p(e=>{let t=e.prepare(`INSERT INTO agent_processes (workspace_id, thread_id, agent_id, pid, state, since_message_id, response_message_id, started_at, last_activity, project_slug)
145
145
  VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?)
146
146
  ON CONFLICT(workspace_id, agent_id)
147
147
  DO UPDATE SET
@@ -152,9 +152,9 @@ ${JSON.stringify({provider:t.provider,model:t.model,promptLength:r.length,identi
152
152
  response_message_id = excluded.response_message_id,
153
153
  started_at = excluded.started_at,
154
154
  last_activity = excluded.last_activity,
155
- project_slug = excluded.project_slug`).run(E.workspaceId,E.threadId,E.agentId,E.pid,E.state,E.sinceMessageId,E.responseMessageId||"",E.startedAt,E.lastActivity,E.projectSlug||"");if(1===t.changes&&t.lastInsertRowid)return Number(t.lastInsertRowid);let a=e.prepare("SELECT id FROM agent_processes WHERE workspace_id = ? AND agent_id = ?").get(E.workspaceId,E.agentId);return a?.id??0}));w?.(J);let K=null;try{await (0,a.runCliResponse)({provider:t.provider,model:t.model,prompt:r,identity:P,self:k,skills:U,systemContext:W,signal:g,onSpawn:a=>{K=a,u(e,t.id,{pid:a,state:"running",lastActivity:Date.now()})},onLog:(e,a)=>{T({type:"log",participantId:t.id,stream:e,line:a})},onDelta:a=>{C+=a,u(e,t.id,{lastActivity:Date.now()}),T({type:"text-delta",participantId:t.id,delta:a})},onThought:e=>{T({type:"participant-thought",participantId:t.id,content:e})}}),u(e,t.id,{state:"done",lastActivity:Date.now()})}catch(i){let a=i instanceof Error?i.message:String(i),n=g?.aborted;u(e,t.id,{state:n?"killed":"error",lastActivity:Date.now()}),(0,$.logActivity)(t.id,"error",{thread:I||e,error:a}),T({type:"participant-error",participantId:t.id,error:a})}finally{}let q=(b=[],S=[],R=C.replace(h,(e,t)=>{let a=function(e){let t=new Map;for(y.lastIndex=0;;){let a=y.exec(e);if(!a)break;let n=a[1].toLowerCase(),i=a[2],r=a[3],s=a[4],o=(i??r??s??"").replace(/\\(["'\\])/g,"$1").trim();t.set(n,o)}return t}(String(t)),n=(a.get("target")||"").trim(),i=(a.get("type")||"").trim().toLowerCase(),r=(a.get("reason")||"").trim(),s=(a.get("blockercode")||a.get("blocker_code")||"").trim();return n?f.has(i)?"clarify"!==i&&"blocked"!==i||r?b.push({raw:e,target:n,type:i,reason:r||void 0,blockerCode:"blocked"===i&&s||void 0}):S.push({raw:e,error:`"${i}" requires reason`}):S.push({raw:e,error:`Invalid type: ${i||"(empty)"}`}):S.push({raw:e,error:"Missing target"}),""}).replace(/[ \t]+\n/g,"\n").replace(/\n{3,}/g,"\n\n").trim(),{signals:b,invalid:S,cleanedText:R});for(let e of q.invalid)T({type:"log",participantId:t.id,stream:"stderr",line:`[reaction] ignored ${e.raw}: ${e.error}`});for(let a of q.signals)try{let n=await (0,m.setReaction)({threadId:e,messageId:a.target,participantId:t.id,type:a.type,reason:a.reason,blockerCode:a.blockerCode,hostPid:K,responseMessageId:Y});T({type:"message-reactions",messageId:a.target,reactions:n.reactions})}catch(n){let e=n instanceof Error?n.message:String(n);T({type:"log",participantId:t.id,stream:"stderr",line:`[reaction] failed ${a.raw}: ${e}`})}let V=q.cleanedText.trim();if("[SKIP]"===V)return(0,$.logActivity)(t.id,"skip",{thread:I||e}),T({type:"participant-end",participantId:t.id}),{skipped:!0,response:"",mentions:new Set,parallel:!1,parallelIds:new Set,agentProcessId:J};let Z=function(e,t){let a=e;for(let e of(a=a.replace(/@@all/gi,"@all"),t))a=(a=a.replace(RegExp(`@@${e.name}`,"gi"),`@${e.name}`)).replace(RegExp(`@@${e.id}`,"gi"),`@${e.id}`);return a}(V,n);if(Z)try{await (0,m.saveMessages)(e,[{id:Y,role:"assistant",participantId:t.id,content:Z,timestamp:Date.now(),rootMessageId:I||null,parentMessageId:I||null,depth:+!!I}]),x=Y}catch(a){let e=a instanceof Error?a.message:String(a);T({type:"log",participantId:t.id,stream:"stderr",line:`[history] failed to save assistant message: ${e}`})}if(Z&&Z.length>20)try{let a,n,i,r,s,o,d,l,c,p,u,g,m,f;j(t,P);let h=(s=(r=Z.trim()).slice(0,120).replace(/\n/g," "),o=/\?/.test(r),d=r.match(/@\w+/g)||[],l=/\b(should|need to|must|plan|steps?|implement|fix|verify|ship|next|start)\b/i.test(r),c=/\b(maybe|might|could|unsure|not sure|unclear)\b/i.test(r),p=/\b(i will|i'll|i can|i'm going to|starting|checking|verified|fixed|done|shipped)\b/i.test(r),u=/```/.test(r)||/\bfunction\b|\bconst\b|\binterface\b/i.test(r),g=/\|.*\|.*\|/.test(r)||/^#{1,3}\s/m.test(r),m=/\b(finding|issue|bug|problem|missing|broken|wrong)\b/i.test(r),a=u&&g?`Observed a structured technical response with code or implementation detail — "${s}..."`:u?`Observed code-centric output — "${s}..."`:g?`Observed structured analysis or specification language — "${s}..."`:m?`Observed review or issue-spotting behavior — "${s}..."`:p?`Observed a concrete commitment to action — "${s}..."`:l?`Observed direction-setting or next-step guidance — "${s}..."`:o?`Observed clarifying or exploratory questioning — "${s}..."`:c?`Observed explicit uncertainty or caveating — "${s}..."`:d.length>0?`Observed coordination with ${d.join(", ")} — "${s}..."`:`Observed a general perspective contribution — "${s}..."`,f=[],(u||g)&&f.push("technical depth"),(l||p)&&f.push("execution bias"),o&&f.push("inquiry instinct"),m&&f.push("critical eye"),d.length>0&&f.push("team coordination"),c&&f.push("intellectual honesty"),n=f.length>0?`Candidate specialization signals: ${f.join(" + ")}. Treat as suggestive evidence, not settled identity.`:"Low-signal contribution for specialization; keep as weak evidence only.",l||p?i="Follow through on the action I just committed to.":m?i="Verify the issues I flagged get addressed.":o&&(i="Wait for the answer before moving forward."),{judgement:a,delta:n,intent:i});(0,N.appendJournal)(t.id,{t:new Date().toISOString(),type:"post",thread:I||e,observation:"Responded to thread",judgement:h.judgement,delta:h.delta,intent:h.intent})}catch{}if(Z){let e;j(t,P);let a=(O.get(t.id)||0)+1;O.set(t.id,a),a%10==0&&(e=(D.get(t.id)??Promise.resolve()).catch(()=>{}).then(()=>M(t)),D.set(t.id,e),e.finally(()=>{D.get(t.id)===e&&D.delete(t.id)})).catch(()=>{})}let{ids:Q,parallel:ee}=Z?function(e,t){let a=new Set,n=new Set,i=e.toLowerCase(),r=i.includes("@@all");if(i.includes("@all")||r){for(let e of t)a.add(e.id),r&&n.add(e.id);return{ids:a,parallel:n}}try{let e=(0,L.getSQLiteDb)();for(let t of e.prepare("SELECT id, name, slug FROM projects").all()){let r=t.name.toLowerCase(),s=t.slug.toLowerCase(),o=i.includes(`@@${r}`)||i.includes(`@@${s}`),d=i.includes(`@${r}`)||i.includes(`@${s}`);if(o||d)for(let i of e.prepare("SELECT agent_id FROM project_agents WHERE project_id = ? ORDER BY routing_order ASC").all(t.id))a.add(i.agent_id),o&&n.add(i.agent_id)}}catch{}for(let e of t){let t=e.id.toLowerCase(),r=e.name.toLowerCase(),s=i.includes(`@@${t}`),o=i.includes(`@@${r}`),d=i.includes(`@${t}`),l=i.includes(`@${r}`);(s||o||d||l)&&(a.add(e.id),(s||o)&&n.add(e.id))}return{ids:a,parallel:n}}(Z,n):{ids:new Set,parallel:new Set};if(Q.delete(t.id),ee.delete(t.id),Z){let a=q.signals.map(e=>e.type);(0,$.logActivity)(t.id,"message",{thread:I||e,messageId:x,response:Z,prompt:r,mentions:Q.size>0?[...Q]:void 0,reactions:a.length>0?a:void 0})}return(T({type:"participant-end",participantId:t.id,messageId:x,content:Z||void 0}),Z)?{skipped:!1,response:Z,mentions:Q,parallel:ee.size>0,parallelIds:ee,messageId:x,agentProcessId:J}:{skipped:!0,response:"",mentions:new Set,parallel:!1,parallelIds:new Set,agentProcessId:J}}var z=e.i(133439);async function G(e){return(0,m.getChatRun)(e)}async function W(e){return(0,m.updateChatRun)(e)}async function H(e){let t=await (0,m.listChatRunSteps)(e.chatRunId);return(0,m.appendChatRunStep)({id:crypto.randomUUID(),chatRunId:e.chatRunId,stepIndex:t.length+1,kind:e.kind,status:e.status,participantId:e.participantId,inputPayload:e.inputPayload,outputPayload:e.outputPayload})}async function Y(e){return(0,m.updateChatRunStep)({id:e.stepId,status:e.status,outputPayload:e.outputPayload,completedAt:Date.now()})}class J{streams=new Map;publish(e,t){let a=this.streams.get(e);if(a||(a={events:[],subscribers:new Set,done:!1},this.streams.set(e,a)),!a.done)for(let e of(a.events.push(t),a.subscribers))try{e(t)}catch{}}subscribe(e,t){let a=this.streams.get(e);for(let n of(a||(a={events:[],subscribers:new Set,done:!1},this.streams.set(e,a)),a.events))try{t(n)}catch{}return a.done||a.subscribers.add(t),()=>{a.subscribers.delete(t)}}complete(e){let t=this.streams.get(e);if(t){for(let e of(t.done=!0,t.subscribers))try{e({type:"done"})}catch{}t.subscribers.clear(),setTimeout(()=>{this.streams.delete(e)},3e5)}}isComplete(e){return this.streams.get(e)?.done??!1}}let K=Symbol.for("agx:ChatEventBus");var q=e.i(47973);async function V(e){var t;(0,q.writeDebugLog)("chat-processor.start.received",{jobId:e.id,chatRunId:e.data.chatRunId,signal:e.data.signal});let a=await G(e.data.chatRunId);if(!a){(0,q.writeDebugLog)("chat-processor.start.missing",{chatRunId:e.data.chatRunId,jobId:e.id}),console.warn(`[chat-processor] Chat run ${e.data.chatRunId} not found, skipping`);return}if("completed"===a.status||"failed"===a.status||"cancelled"===a.status)return void(0,q.writeDebugLog)("chat-processor.start.skip_terminal",{chatRunId:a.id,status:a.status});if(!((t=a.payload)&&"object"==typeof t&&"string"==typeof t.threadId&&"string"==typeof t.prompt&&Array.isArray(t.participantIds))){(0,q.writeDebugLog)("chat-processor.start.invalid_payload",{chatRunId:a.id}),await W({id:a.id,status:"failed",lastError:"Chat run payload is missing or invalid",completedAt:Date.now()});return}let n=await H({chatRunId:a.id,kind:"model_turn",status:"running",inputPayload:{participantIds:a.payload.participantIds,rootMessageId:a.payload.rootMessageId,maxRounds:a.payload.maxRounds}});await W({id:a.id,status:"running",currentStep:n.stepIndex,stepsUsed:n.stepIndex,lastError:null});let i=(globalThis[K]||(globalThis[K]=new J),globalThis[K]);try{(0,q.writeDebugLog)("chat-processor.start.running",{chatRunId:a.id,threadId:a.threadId,rootMessageId:a.rootMessageId,participantIds:a.payload.participantIds});let e=await (0,z.loadDbParticipants)(),t=new Set(a.payload.participantIds),r=a.payload.participantIds.map(t=>e.find(e=>e.id===t)).filter(e=>!!e);if(0===r.length)throw(0,q.writeDebugLog)("chat-processor.start.no_participants_resolved",{chatRunId:a.id,participantIds:a.payload.participantIds}),Error("No participants resolved for chat run");let s=new Set(a.payload.mentionedIds.filter(e=>t.has(e))),o=new Set(a.payload.initialParallelIds.filter(e=>t.has(e))),d=(function({threadId:e,allParticipants:t,mentioned:a,initialParallelIds:n,prompt:i,projectContext:r,signal:s,maxRounds:o,recentHistory:d,currentUserMessageId:l,rootMessageId:c}){let p=new TextEncoder;return new ReadableStream({async start(u){let g=[],f=new Map,h=e=>{try{u.enqueue(p.encode(`data: ${JSON.stringify(e)}
155
+ project_slug = excluded.project_slug`).run(E.workspaceId,E.threadId,E.agentId,E.pid,E.state,E.sinceMessageId,E.responseMessageId||"",E.startedAt,E.lastActivity,E.projectSlug||"");if(1===t.changes&&t.lastInsertRowid)return Number(t.lastInsertRowid);let a=e.prepare("SELECT id FROM agent_processes WHERE workspace_id = ? AND agent_id = ?").get(E.workspaceId,E.agentId);return a?.id??0}));w?.(J);let K=null;try{await (0,a.runCliResponse)({provider:t.provider,model:t.model,prompt:r,identity:P,self:k,skills:U,systemContext:W,signal:g,onSpawn:a=>{K=a,u(e,t.id,{pid:a,state:"running",lastActivity:Date.now()})},onLog:(e,a)=>{T({type:"log",participantId:t.id,stream:e,line:a})},onDelta:a=>{C+=a,u(e,t.id,{lastActivity:Date.now()}),T({type:"text-delta",participantId:t.id,delta:a})},onThought:e=>{T({type:"participant-thought",participantId:t.id,content:e})}}),u(e,t.id,{state:"done",lastActivity:Date.now()})}catch(i){let a=i instanceof Error?i.message:String(i),n=g?.aborted;u(e,t.id,{state:n?"killed":"error",lastActivity:Date.now()}),(0,R.logActivity)(t.id,"error",{thread:I||e,error:a}),T({type:"participant-error",participantId:t.id,error:a})}finally{}let q=(b=[],$=[],S=C.replace(h,(e,t)=>{let a=function(e){let t=new Map;for(y.lastIndex=0;;){let a=y.exec(e);if(!a)break;let n=a[1].toLowerCase(),i=a[2],r=a[3],s=a[4],o=(i??r??s??"").replace(/\\(["'\\])/g,"$1").trim();t.set(n,o)}return t}(String(t)),n=(a.get("target")||"").trim(),i=(a.get("type")||"").trim().toLowerCase(),r=(a.get("reason")||"").trim(),s=(a.get("blockercode")||a.get("blocker_code")||"").trim();return n?f.has(i)?"clarify"!==i&&"blocked"!==i||r?b.push({raw:e,target:n,type:i,reason:r||void 0,blockerCode:"blocked"===i&&s||void 0}):$.push({raw:e,error:`"${i}" requires reason`}):$.push({raw:e,error:`Invalid type: ${i||"(empty)"}`}):$.push({raw:e,error:"Missing target"}),""}).replace(/[ \t]+\n/g,"\n").replace(/\n{3,}/g,"\n\n").trim(),{signals:b,invalid:$,cleanedText:S});for(let e of q.invalid)T({type:"log",participantId:t.id,stream:"stderr",line:`[reaction] ignored ${e.raw}: ${e.error}`});for(let a of q.signals)try{let n=await (0,m.setReaction)({threadId:e,messageId:a.target,participantId:t.id,type:a.type,reason:a.reason,blockerCode:a.blockerCode,hostPid:K,responseMessageId:Y});T({type:"message-reactions",messageId:a.target,reactions:n.reactions})}catch(n){let e=n instanceof Error?n.message:String(n);T({type:"log",participantId:t.id,stream:"stderr",line:`[reaction] failed ${a.raw}: ${e}`})}let V=q.cleanedText.trim();if("[SKIP]"===V)return(0,R.logActivity)(t.id,"skip",{thread:I||e}),T({type:"participant-end",participantId:t.id}),{skipped:!0,response:"",mentions:new Set,parallel:!1,parallelIds:new Set,agentProcessId:J};let Z=function(e,t){let a=e;for(let e of(a=a.replace(/@@all/gi,"@all"),t))a=(a=a.replace(RegExp(`@@${e.name}`,"gi"),`@${e.name}`)).replace(RegExp(`@@${e.id}`,"gi"),`@${e.id}`);return a}(V,n);if(Z)try{await (0,m.saveMessages)(e,[{id:Y,role:"assistant",participantId:t.id,content:Z,timestamp:Date.now(),rootMessageId:I||null,parentMessageId:I||null,depth:+!!I}]),x=Y}catch(a){let e=a instanceof Error?a.message:String(a);T({type:"log",participantId:t.id,stream:"stderr",line:`[history] failed to save assistant message: ${e}`})}if(Z&&Z.length>20)try{let a,n,i,r,s,o,l,d,c,p,u,g,m,f;j(t,P);let h=(s=(r=Z.trim()).slice(0,120).replace(/\n/g," "),o=/\?/.test(r),l=r.match(/@\w+/g)||[],d=/\b(should|need to|must|plan|steps?|implement|fix|verify|ship|next|start)\b/i.test(r),c=/\b(maybe|might|could|unsure|not sure|unclear)\b/i.test(r),p=/\b(i will|i'll|i can|i'm going to|starting|checking|verified|fixed|done|shipped)\b/i.test(r),u=/```/.test(r)||/\bfunction\b|\bconst\b|\binterface\b/i.test(r),g=/\|.*\|.*\|/.test(r)||/^#{1,3}\s/m.test(r),m=/\b(finding|issue|bug|problem|missing|broken|wrong)\b/i.test(r),a=u&&g?`Observed a structured technical response with code or implementation detail — "${s}..."`:u?`Observed code-centric output — "${s}..."`:g?`Observed structured analysis or specification language — "${s}..."`:m?`Observed review or issue-spotting behavior — "${s}..."`:p?`Observed a concrete commitment to action — "${s}..."`:d?`Observed direction-setting or next-step guidance — "${s}..."`:o?`Observed clarifying or exploratory questioning — "${s}..."`:c?`Observed explicit uncertainty or caveating — "${s}..."`:l.length>0?`Observed coordination with ${l.join(", ")} — "${s}..."`:`Observed a general perspective contribution — "${s}..."`,f=[],(u||g)&&f.push("technical depth"),(d||p)&&f.push("execution bias"),o&&f.push("inquiry instinct"),m&&f.push("critical eye"),l.length>0&&f.push("team coordination"),c&&f.push("intellectual honesty"),n=f.length>0?`Candidate specialization signals: ${f.join(" + ")}. Treat as suggestive evidence, not settled identity.`:"Low-signal contribution for specialization; keep as weak evidence only.",d||p?i="Follow through on the action I just committed to.":m?i="Verify the issues I flagged get addressed.":o&&(i="Wait for the answer before moving forward."),{judgement:a,delta:n,intent:i});(0,N.appendJournal)(t.id,{t:new Date().toISOString(),type:"post",thread:I||e,observation:"Responded to thread",judgement:h.judgement,delta:h.delta,intent:h.intent})}catch{}if(Z){let e;j(t,P);let a=(O.get(t.id)||0)+1;O.set(t.id,a),a%10==0&&(e=(D.get(t.id)??Promise.resolve()).catch(()=>{}).then(()=>M(t)),D.set(t.id,e),e.finally(()=>{D.get(t.id)===e&&D.delete(t.id)})).catch(()=>{})}let{ids:Q,parallel:ee}=Z?function(e,t){let a=new Set,n=new Set,i=e.toLowerCase(),r=i.includes("@@all");if(i.includes("@all")||r){for(let e of t)a.add(e.id),r&&n.add(e.id);return{ids:a,parallel:n}}try{let e=(0,L.getSQLiteDb)();for(let t of e.prepare("SELECT id, name, slug FROM projects").all()){let r=t.name.toLowerCase(),s=t.slug.toLowerCase(),o=i.includes(`@@${r}`)||i.includes(`@@${s}`),l=i.includes(`@${r}`)||i.includes(`@${s}`);if(o||l)for(let i of e.prepare("SELECT agent_id FROM project_agents WHERE project_id = ? ORDER BY routing_order ASC").all(t.id))a.add(i.agent_id),o&&n.add(i.agent_id)}}catch{}for(let e of t){let t=e.id.toLowerCase(),r=e.name.toLowerCase(),s=i.includes(`@@${t}`),o=i.includes(`@@${r}`),l=i.includes(`@${t}`),d=i.includes(`@${r}`);(s||o||l||d)&&(a.add(e.id),(s||o)&&n.add(e.id))}return{ids:a,parallel:n}}(Z,n):{ids:new Set,parallel:new Set};if(Q.delete(t.id),ee.delete(t.id),Z){let a=q.signals.map(e=>e.type);(0,R.logActivity)(t.id,"message",{thread:I||e,messageId:x,response:Z,prompt:r,mentions:Q.size>0?[...Q]:void 0,reactions:a.length>0?a:void 0})}return(T({type:"participant-end",participantId:t.id,messageId:x,content:Z||void 0}),Z)?{skipped:!1,response:Z,mentions:Q,parallel:ee.size>0,parallelIds:ee,messageId:x,agentProcessId:J}:{skipped:!0,response:"",mentions:new Set,parallel:!1,parallelIds:new Set,agentProcessId:J}}var z=e.i(133439);async function G(e){return(0,m.getChatRun)(e)}async function W(e){return(0,m.updateChatRun)(e)}async function H(e){let t=await (0,m.listChatRunSteps)(e.chatRunId);return(0,m.appendChatRunStep)({id:crypto.randomUUID(),chatRunId:e.chatRunId,stepIndex:t.length+1,kind:e.kind,status:e.status,participantId:e.participantId,inputPayload:e.inputPayload,outputPayload:e.outputPayload})}async function Y(e){return(0,m.updateChatRunStep)({id:e.stepId,status:e.status,outputPayload:e.outputPayload,completedAt:Date.now()})}class J{streams=new Map;publish(e,t){let a=this.streams.get(e);if(a||(a={events:[],subscribers:new Set,done:!1},this.streams.set(e,a)),!a.done)for(let e of(a.events.push(t),a.subscribers))try{e(t)}catch{}}subscribe(e,t){let a=this.streams.get(e);for(let n of(a||(a={events:[],subscribers:new Set,done:!1},this.streams.set(e,a)),a.events))try{t(n)}catch{}return a.done||a.subscribers.add(t),()=>{a.subscribers.delete(t)}}complete(e){let t=this.streams.get(e);if(t){for(let e of(t.done=!0,t.subscribers))try{e({type:"done"})}catch{}t.subscribers.clear(),setTimeout(()=>{this.streams.delete(e)},3e5)}}isComplete(e){return this.streams.get(e)?.done??!1}}let K=Symbol.for("agx:ChatEventBus");var q=e.i(47973);async function V(e){var t;(0,q.writeDebugLog)("chat-processor.start.received",{jobId:e.id,chatRunId:e.data.chatRunId,signal:e.data.signal});let a=await G(e.data.chatRunId);if(!a){(0,q.writeDebugLog)("chat-processor.start.missing",{chatRunId:e.data.chatRunId,jobId:e.id}),console.warn(`[chat-processor] Chat run ${e.data.chatRunId} not found, skipping`);return}if("completed"===a.status||"failed"===a.status||"cancelled"===a.status)return void(0,q.writeDebugLog)("chat-processor.start.skip_terminal",{chatRunId:a.id,status:a.status});if(!((t=a.payload)&&"object"==typeof t&&"string"==typeof t.threadId&&"string"==typeof t.prompt&&Array.isArray(t.participantIds))){(0,q.writeDebugLog)("chat-processor.start.invalid_payload",{chatRunId:a.id}),await W({id:a.id,status:"failed",lastError:"Chat run payload is missing or invalid",completedAt:Date.now()});return}let n=await H({chatRunId:a.id,kind:"model_turn",status:"running",inputPayload:{participantIds:a.payload.participantIds,rootMessageId:a.payload.rootMessageId,maxRounds:a.payload.maxRounds}});await W({id:a.id,status:"running",currentStep:n.stepIndex,stepsUsed:n.stepIndex,lastError:null});let i=(globalThis[K]||(globalThis[K]=new J),globalThis[K]);try{(0,q.writeDebugLog)("chat-processor.start.running",{chatRunId:a.id,threadId:a.threadId,rootMessageId:a.rootMessageId,participantIds:a.payload.participantIds});let e=await (0,z.loadDbParticipants)(),t=new Set(a.payload.participantIds),r=a.payload.participantIds.map(t=>e.find(e=>e.id===t)).filter(e=>!!e);if(0===r.length)throw(0,q.writeDebugLog)("chat-processor.start.no_participants_resolved",{chatRunId:a.id,participantIds:a.payload.participantIds}),Error("No participants resolved for chat run");let s=new Set(a.payload.mentionedIds.filter(e=>t.has(e))),o=new Set(a.payload.initialParallelIds.filter(e=>t.has(e))),l=(function({threadId:e,allParticipants:t,mentioned:a,initialParallelIds:n,prompt:i,projectContext:r,signal:s,maxRounds:o,recentHistory:l,currentUserMessageId:d,rootMessageId:c}){let p=new TextEncoder;return new ReadableStream({async start(u){let g=[],f=new Map,h=e=>{try{u.enqueue(p.encode(`data: ${JSON.stringify(e)}
156
156
 
157
- `))}catch{}if("log"===e.type){let t=f.get(e.participantId);t&&g.push({agentProcessId:t,stream:e.stream,line:e.line,timestamp:Date.now()})}},y=async()=>{if(0===g.length)return;let e=new Map;for(let t of g){let a=e.get(t.agentProcessId);a||(a=[],e.set(t.agentProcessId,a)),a.push({stream:t.stream,line:t.line,timestamp:t.timestamp})}await Promise.all(Array.from(e.entries()).map(([e,t])=>(0,m.saveLogs)(e,t).catch(e=>console.error("[stream-multiplexer] saveLogs failed:",e))))},T=[],I=[],w=d?d.map(e=>({name:e.name,content:e.content})):[],E=t[0],_=new Set;if(a.size>0)for(let e of a)_.add(e);else _.add(E.id);let L=o??10,v=new Set(_);for(let a=0;a<L&&!s?.aborted;a++){let o=!0,p=t.filter(e=>_.has(e.id)),u=new Set,g=new Set;if(0===a&&n&&n.size>0){let a=p.filter(e=>n.has(e.id)&&v.has(e.id));if(a.length>0){for(let e of a)g.add(e.id);let n=a.map(async a=>{let n=await B(e,a,t,p,i,T,d||[],I,l||null,r,s,h,c,e=>f.set(a.id,e));return{agent:a,result:n}});for(let e of(await Promise.allSettled(n))){if("fulfilled"!==e.status)continue;let{agent:t,result:a}=e.value;if(!a.skipped)for(let e of(a.response&&a.messageId&&I.push({id:a.messageId,name:t.name,content:a.response}),a.response&&([...w,...T].filter(e=>e.name===t.name).some(e=>F(e.content,a.response)>.5)||(T.push({name:t.name,content:a.response}),o=!1)),a.mentions))_.add(e),p.findIndex(t=>t.id===e)>=0&&!g.has(e)&&v.has(e)||u.add(e)}}}for(let a=0;a<p.length;a++){let n=p[a];if(s?.aborted)break;if(!v.has(n.id)||g.has(n.id))continue;let m=await B(e,n,t,p,i,T,d||[],I,l||null,r,s,h,c,e=>f.set(n.id,e));if(m.skipped||(m.response&&m.messageId&&I.push({id:m.messageId,name:n.name,content:m.response}),m.response&&[...w,...T].filter(e=>e.name===n.name).some(e=>F(e.content,m.response)>.5)))continue;for(let e of(o=!1,m.response&&T.push({name:n.name,content:m.response}),m.mentions))p.findIndex(t=>t.id===e)>a&&v.has(e)||u.add(e);let y=new Set;for(let e of m.mentions)_.has(e)||(_.add(e),y.add(e));let E=new Set([...m.parallelIds].filter(e=>y.has(e)));if(E.size>0){let a=t.filter(e=>E.has(e.id)),n=t.filter(e=>_.has(e.id)),o=a.map(async a=>{let o=await B(e,a,t,n,i,T,d||[],I,l||null,r,s,h,c,e=>f.set(a.id,e));return{agent:a,result:o}});for(let e of(await Promise.allSettled(o))){if("fulfilled"!==e.status)continue;let{agent:t,result:a}=e.value;if(!a.skipped){if(a.response&&a.messageId&&I.push({id:a.messageId,name:t.name,content:a.response}),a.response){if([...w,...T].filter(e=>e.name===t.name).some(e=>F(e.content,a.response)>.5))continue;T.push({name:t.name,content:a.response})}for(let e of a.mentions)_.add(e),u.add(e)}}}}if(o)break;v=u}await y(),h({type:"done"}),u.close()}})})({threadId:a.payload.threadId,allParticipants:r,mentioned:s,initialParallelIds:o,prompt:a.payload.prompt,projectContext:a.payload.projectContext,maxRounds:a.payload.maxRounds,recentHistory:a.payload.recentHistory,currentUserMessageId:a.payload.currentUserMessageId,rootMessageId:a.payload.rootMessageId}).getReader();(0,q.writeDebugLog)("chat-processor.stream.open",{chatRunId:a.id,participantCount:r.length});let l="";for(;;){let{done:e,value:t}=await d.read();if(e)break;if(t){let e=(l+=new TextDecoder().decode(t)).split("\n");for(let t of(l=e.pop()||"",e)){let e=t.trim();if(e.startsWith("data: "))try{let t=JSON.parse(e.slice(6));"log"!==t.type&&i.publish(a.id,t)}catch{}}}}if(l.trim().startsWith("data: "))try{let e=JSON.parse(l.trim().slice(6));"log"!==e.type&&i.publish(a.id,e)}catch{}i.complete(a.id),(0,q.writeDebugLog)("chat-processor.stream.complete",{chatRunId:a.id}),await Y({stepId:n.id,status:"completed",outputPayload:{completed:!0,participantCount:r.length}}),await W({id:a.id,status:"completed",completedAt:Date.now(),result:{participantIds:r.map(e=>e.id),rootMessageId:a.payload.rootMessageId}}),(0,q.writeDebugLog)("chat-processor.complete",{chatRunId:a.id,rootMessageId:a.payload.rootMessageId})}catch(t){let e=t instanceof Error?t.message:String(t);i.complete(a.id),(0,q.writeDebugLog)("chat-processor.error",{chatRunId:a.id,error:t,message:e}),await Y({stepId:n.id,status:"failed",outputPayload:{error:e}}),await W({id:a.id,status:"failed",lastError:e,completedAt:Date.now(),result:{error:e}})}}async function Z(e){(0,q.writeDebugLog)("chat-processor.cancel.received",{jobId:e.id,chatRunId:e.data.chatRunId});let t=await G(e.data.chatRunId);if(t){var a,n,i,r;if(t.rootMessageId)g((n=a=t.rootMessageId,p(e=>e.prepare("SELECT * FROM agent_processes WHERE thread_id = ?").all(n).map(c))).filter(e=>"running"===e.state||"spawning"===e.state))>0&&p(e=>e.prepare(`UPDATE agent_processes SET state = 'killed', last_activity = ?
157
+ `))}catch{}if("log"===e.type){let t=f.get(e.participantId);t&&g.push({agentProcessId:t,stream:e.stream,line:e.line,timestamp:Date.now()})}},y=async()=>{if(0===g.length)return;let e=new Map;for(let t of g){let a=e.get(t.agentProcessId);a||(a=[],e.set(t.agentProcessId,a)),a.push({stream:t.stream,line:t.line,timestamp:t.timestamp})}await Promise.all(Array.from(e.entries()).map(([e,t])=>(0,m.saveLogs)(e,t).catch(e=>console.error("[stream-multiplexer] saveLogs failed:",e))))},T=[],I=[],w=l?l.map(e=>({name:e.name,content:e.content})):[],E=t[0],_=new Set;if(a.size>0)for(let e of a)_.add(e);else _.add(E.id);let L=o??10,v=new Set(_);for(let a=0;a<L&&!s?.aborted;a++){let o=!0,p=t.filter(e=>_.has(e.id)),u=new Set,g=new Set;if(0===a&&n&&n.size>0){let a=p.filter(e=>n.has(e.id)&&v.has(e.id));if(a.length>0){for(let e of a)g.add(e.id);let n=a.map(async a=>{let n=await B(e,a,t,p,i,T,l||[],I,d||null,r,s,h,c,e=>f.set(a.id,e));return{agent:a,result:n}});for(let e of(await Promise.allSettled(n))){if("fulfilled"!==e.status)continue;let{agent:t,result:a}=e.value;if(!a.skipped)for(let e of(a.response&&a.messageId&&I.push({id:a.messageId,name:t.name,content:a.response}),a.response&&([...w,...T].filter(e=>e.name===t.name).some(e=>F(e.content,a.response)>.5)||(T.push({name:t.name,content:a.response}),o=!1)),a.mentions))_.add(e),p.findIndex(t=>t.id===e)>=0&&!g.has(e)&&v.has(e)||u.add(e)}}}for(let a=0;a<p.length;a++){let n=p[a];if(s?.aborted)break;if(!v.has(n.id)||g.has(n.id))continue;let m=await B(e,n,t,p,i,T,l||[],I,d||null,r,s,h,c,e=>f.set(n.id,e));if(m.skipped||(m.response&&m.messageId&&I.push({id:m.messageId,name:n.name,content:m.response}),m.response&&[...w,...T].filter(e=>e.name===n.name).some(e=>F(e.content,m.response)>.5)))continue;for(let e of(o=!1,m.response&&T.push({name:n.name,content:m.response}),m.mentions))p.findIndex(t=>t.id===e)>a&&v.has(e)||u.add(e);let y=new Set;for(let e of m.mentions)_.has(e)||(_.add(e),y.add(e));let E=new Set([...m.parallelIds].filter(e=>y.has(e)));if(E.size>0){let a=t.filter(e=>E.has(e.id)),n=t.filter(e=>_.has(e.id)),o=a.map(async a=>{let o=await B(e,a,t,n,i,T,l||[],I,d||null,r,s,h,c,e=>f.set(a.id,e));return{agent:a,result:o}});for(let e of(await Promise.allSettled(o))){if("fulfilled"!==e.status)continue;let{agent:t,result:a}=e.value;if(!a.skipped){if(a.response&&a.messageId&&I.push({id:a.messageId,name:t.name,content:a.response}),a.response){if([...w,...T].filter(e=>e.name===t.name).some(e=>F(e.content,a.response)>.5))continue;T.push({name:t.name,content:a.response})}for(let e of a.mentions)_.add(e),u.add(e)}}}}if(o)break;v=u}await y(),h({type:"done"}),u.close()}})})({threadId:a.payload.threadId,allParticipants:r,mentioned:s,initialParallelIds:o,prompt:a.payload.prompt,projectContext:a.payload.projectContext,maxRounds:a.payload.maxRounds,recentHistory:a.payload.recentHistory,currentUserMessageId:a.payload.currentUserMessageId,rootMessageId:a.payload.rootMessageId}).getReader();(0,q.writeDebugLog)("chat-processor.stream.open",{chatRunId:a.id,participantCount:r.length});let d="";for(;;){let{done:e,value:t}=await l.read();if(e)break;if(t){let e=(d+=new TextDecoder().decode(t)).split("\n");for(let t of(d=e.pop()||"",e)){let e=t.trim();if(e.startsWith("data: "))try{let t=JSON.parse(e.slice(6));"log"!==t.type&&i.publish(a.id,t)}catch{}}}}if(d.trim().startsWith("data: "))try{let e=JSON.parse(d.trim().slice(6));"log"!==e.type&&i.publish(a.id,e)}catch{}i.complete(a.id),(0,q.writeDebugLog)("chat-processor.stream.complete",{chatRunId:a.id}),await Y({stepId:n.id,status:"completed",outputPayload:{completed:!0,participantCount:r.length}}),await W({id:a.id,status:"completed",completedAt:Date.now(),result:{participantIds:r.map(e=>e.id),rootMessageId:a.payload.rootMessageId}}),(0,q.writeDebugLog)("chat-processor.complete",{chatRunId:a.id,rootMessageId:a.payload.rootMessageId})}catch(t){let e=t instanceof Error?t.message:String(t);i.complete(a.id),(0,q.writeDebugLog)("chat-processor.error",{chatRunId:a.id,error:t,message:e}),await Y({stepId:n.id,status:"failed",outputPayload:{error:e}}),await W({id:a.id,status:"failed",lastError:e,completedAt:Date.now(),result:{error:e}})}}async function Z(e){(0,q.writeDebugLog)("chat-processor.cancel.received",{jobId:e.id,chatRunId:e.data.chatRunId});let t=await G(e.data.chatRunId);if(t){var a,n,i,r;if(t.rootMessageId)g((n=a=t.rootMessageId,p(e=>e.prepare("SELECT * FROM agent_processes WHERE thread_id = ?").all(n).map(c))).filter(e=>"running"===e.state||"spawning"===e.state))>0&&p(e=>e.prepare(`UPDATE agent_processes SET state = 'killed', last_activity = ?
158
158
  WHERE thread_id = ? AND state IN ('running', 'spawning')`).run(Date.now(),a));else g((r=i=t.threadId,p(e=>e.prepare("SELECT * FROM agent_processes WHERE workspace_id = ?").all(r).map(c))).filter(e=>"running"===e.state||"spawning"===e.state))>0&&p(e=>e.prepare(`UPDATE agent_processes SET state = 'killed', last_activity = ?
159
159
  WHERE workspace_id = ? AND state IN ('running', 'spawning')`).run(Date.now(),i));await W({id:t.id,status:"cancelled",lastError:e.data.payload?.reason||"Cancelled",completedAt:Date.now(),result:{cancelled:!0}}),(0,q.writeDebugLog)("chat-processor.cancel.complete",{chatRunId:t.id,threadId:t.threadId})}}async function Q(e){switch(e.data.signal){case"start":await V(e);break;case"cancel":await Z(e);break;default:console.warn(`[chat-processor] Unknown signal: ${e.data.signal}`)}}async function ee(e){for(let t of e)await Q(t)}e.s(["chatProcessor",()=>ee],329893)}];
160
160
 
@@ -2,6 +2,6 @@ module.exports=[556704,(a,b,c)=>{b.exports=a.x("next/dist/server/app-render/work
2
2
  w-full text-left px-3.5 py-2.5 flex items-center gap-3 transition-colors
3
3
  ${a.disabled?"opacity-35 cursor-not-allowed":""}
4
4
  ${c?"bg-[var(--primary)]/10":"hover:bg-[var(--muted)]/40"}
5
- `,children:[(0,b.jsx)("div",{className:`w-5 h-5 rounded-md flex items-center justify-center flex-shrink-0 border ${c?"bg-[var(--primary)] border-[var(--primary)]":"border-[var(--border)]"}`,children:c&&(0,b.jsx)(f.Check,{className:"w-3 h-3 text-white"})}),(0,b.jsxs)("div",{className:"min-w-0 flex-1",children:[(0,b.jsxs)("div",{className:"flex items-center gap-2",children:[(0,b.jsx)("span",{className:"text-sm font-medium",children:a.label}),a.meta&&(0,b.jsx)("span",{className:"text-[10px] px-1.5 py-0.5 rounded-full bg-[var(--muted)]/50 text-[var(--muted-foreground)]",children:a.meta})]}),a.description&&(0,b.jsx)("p",{className:"text-xs text-[var(--muted-foreground)] mt-0.5 line-clamp-1",children:a.description})]})]},a.id)})]})]})]})}a.s(["default",()=>h])},66456,a=>{"use strict";let b=(0,a.i(831709).default)("zap",[["path",{d:"M4 14a1 1 0 0 1-.78-1.63l9.9-10.2a.5.5 0 0 1 .86.46l-1.92 6.02A1 1 0 0 0 13 10h7a1 1 0 0 1 .78 1.63l-9.9 10.2a.5.5 0 0 1-.86-.46l1.92-6.02A1 1 0 0 0 11 14z",key:"1xq2db"}]]);a.s(["Zap",()=>b],66456)},144462,962684,a=>{"use strict";let b=(0,a.i(831709).default)("square-terminal",[["path",{d:"m7 11 2-2-2-2",key:"1lz0vl"}],["path",{d:"M11 13h4",key:"1p7l4v"}],["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",ry:"2",key:"1m3agn"}]]);a.s(["default",()=>b],962684),a.s(["TerminalSquare",()=>b],144462)},227444,a=>{"use strict";var b=a.i(786220);function c(a){let[c,d]=(0,b.useState)([]),[e,f]=(0,b.useState)(!0),g=(0,b.useCallback)(async()=>{if(!a){d([]),f(!1);return}try{let b=await fetch(`/api/trackers/connections?projectId=${encodeURIComponent(a)}`),c=await b.json();d(Array.isArray(c.connections)?c.connections:[])}catch{d([])}finally{f(!1)}},[a]);(0,b.useEffect)(()=>{g()},[g]);let h=(0,b.useCallback)(async(b,c)=>{if(!a)return{ok:!1,error:"Missing projectId"};try{let d=await fetch("/api/trackers/connections",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({type:b,projectId:a,metadata:c})});if(!d.ok){let a=await d.json().catch(()=>({}));return{ok:!1,error:a.error||"Failed to add connection"}}return await g(),{ok:!0}}catch{return{ok:!1,error:"Failed to add connection"}}},[a,g]),i=(0,b.useCallback)(async b=>{if(!a)return{ok:!1,error:"Missing projectId"};try{let c=await fetch(`/api/trackers/${b}/status?projectId=${encodeURIComponent(a)}`,{method:"DELETE"});if(!c.ok){let a=await c.json().catch(()=>({}));return{ok:!1,error:a.error||"Failed to remove connection"}}return await g(),{ok:!0}}catch{return{ok:!1,error:"Failed to remove connection"}}},[a,g]);return{connections:c,loading:e,refresh:g,addConnection:h,removeConnection:i}}a.s(["useTrackerConnections",()=>c])},349692,372871,a=>{"use strict";let b=(0,a.i(831709).default)("loader-circle",[["path",{d:"M21 12a9 9 0 1 1-6.219-8.56",key:"13zald"}]]);a.s(["default",()=>b],372871),a.s(["Loader2",()=>b],349692)},157633,a=>{"use strict";let b=(0,a.i(831709).default)("folder",[["path",{d:"M20 20a2 2 0 0 0 2-2V8a2 2 0 0 0-2-2h-7.9a2 2 0 0 1-1.69-.9L9.6 3.9A2 2 0 0 0 7.93 3H4a2 2 0 0 0-2 2v13a2 2 0 0 0 2 2Z",key:"1kt360"}]]);a.s(["Folder",()=>b],157633)},427411,a=>{"use strict";let b={bounds:null,sidebar:{workspaceWidth:260,logPanelHeight:200,workspaceVisible:!0,logPanelVisible:!1,linearTicketPanelWidth:576,objectiveChatPanelWidth:440,objectiveListPanelWidth:320},scroll:{lastThreadId:null,lastWorkspaceId:null}};function c(){return({...b}).sidebar}function d(a){let c={...b};c.sidebar={...c.sidebar,...a}}function e(){return c().workspaceWidth}function f(a){d({workspaceWidth:a})}function g(){return c().linearTicketPanelWidth}function h(a){d({linearTicketPanelWidth:a})}function i(){return c().objectiveChatPanelWidth}function j(a){d({objectiveChatPanelWidth:a})}function k(){return c().objectiveListPanelWidth}function l(a){d({objectiveListPanelWidth:a})}a.s(["loadLinearTicketPanelWidth",()=>g,"loadObjectiveChatPanelWidth",()=>i,"loadObjectiveListPanelWidth",()=>k,"loadWorkspaceWidth",()=>e,"persistLinearTicketPanelWidth",()=>h,"persistObjectiveChatPanelWidth",()=>j,"persistObjectiveListPanelWidth",()=>l,"persistWorkspaceWidth",()=>f])},552605,a=>{"use strict";let b=(0,a.i(831709).default)("file-text",[["path",{d:"M6 22a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.704.706l3.588 3.588A2.4 2.4 0 0 1 20 8v12a2 2 0 0 1-2 2z",key:"1oefj6"}],["path",{d:"M14 2v5a1 1 0 0 0 1 1h5",key:"wfsgrz"}],["path",{d:"M10 9H8",key:"b1mrlr"}],["path",{d:"M16 13H8",key:"t4e002"}],["path",{d:"M16 17H8",key:"z1uh3a"}]]);a.s(["FileText",()=>b],552605)},422662,(a,b,c)=>{"use strict";Object.defineProperty(c,"__esModule",{value:!0});var d={getDeploymentId:function(){return f},getDeploymentIdQueryOrEmptyString:function(){return g}};for(var e in d)Object.defineProperty(c,e,{enumerable:!0,get:d[e]});function f(){return!1}function g(){return""}},737313,a=>{"use strict";let b=(0,a.i(831709).default)("message-square",[["path",{d:"M22 17a2 2 0 0 1-2 2H6.828a2 2 0 0 0-1.414.586l-2.202 2.202A.71.71 0 0 1 2 21.286V5a2 2 0 0 1 2-2h16a2 2 0 0 1 2 2z",key:"18887p"}]]);a.s(["MessageSquare",()=>b],737313)},392045,70014,a=>{"use strict";var b=a.i(308316);function c({className:a}){return(0,b.jsx)("svg",{className:a,viewBox:"0 0 24 24",fill:"currentColor",xmlns:"http://www.w3.org/2000/svg",children:(0,b.jsx)("path",{d:"M2.886 4.18A11.982 11.982 0 0 1 11.99 0C18.624 0 24 5.376 24 12.009c0 3.64-1.62 6.903-4.18 9.105L2.887 4.18ZM1.817 5.626l16.556 16.556c-.524.33-1.075.62-1.65.866L.951 7.277c.247-.575.537-1.126.866-1.65ZM.322 9.163l14.515 14.515c-.71.172-1.443.282-2.195.322L0 11.358a12 12 0 0 1 .322-2.195Zm-.17 4.862 9.823 9.824a12.02 12.02 0 0 1-9.824-9.824Z"})})}a.s(["LinearIcon",()=>c],70014);let d={linear:c,jira:function({className:a}){return(0,b.jsxs)("svg",{className:a,viewBox:"12 12 104 104",fill:"currentColor",xmlns:"http://www.w3.org/2000/svg",children:[(0,b.jsx)("path",{d:"M108.023 16H61.805c0 11.52 9.324 20.848 20.847 20.848h8.5v8.226c0 11.52 9.328 20.848 20.848 20.848V19.977A3.98 3.98 0 00108.023 16zm0 0"}),(0,b.jsx)("path",{d:"M85.121 39.04H38.902c0 11.519 9.325 20.847 20.844 20.847h8.504v8.226c0 11.52 9.328 20.848 20.848 20.848V43.016a3.983 3.983 0 00-3.977-3.977zm0 0"}),(0,b.jsx)("path",{d:"M62.219 62.078H16c0 11.524 9.324 20.848 20.848 20.848h8.5v8.23c0 11.52 9.328 20.844 20.847 20.844V66.059a3.984 3.984 0 00-3.976-3.98zm0 0"})]})}};function e({trackerType:a,className:c}){let e=d[a];return e?(0,b.jsx)(e,{className:c}):(0,b.jsx)(f,{className:c})}function f({className:a}){return(0,b.jsxs)("svg",{className:a,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round",children:[(0,b.jsx)("path",{d:"M9 5H7a2 2 0 0 0-2 2v12a2 2 0 0 0 2 2h10a2 2 0 0 0 2-2V7a2 2 0 0 0-2-2h-2"}),(0,b.jsx)("rect",{x:"9",y:"3",width:"6",height:"4",rx:"2"}),(0,b.jsx)("path",{d:"M9 12h6"}),(0,b.jsx)("path",{d:"M9 16h6"})]})}a.s(["TrackerIcon",()=>e],392045)},971382,a=>{"use strict";let b=(0,a.i(831709).default)("bot",[["path",{d:"M12 8V4H8",key:"hb8ula"}],["rect",{width:"16",height:"12",x:"4",y:"8",rx:"2",key:"enze0r"}],["path",{d:"M2 14h2",key:"vft8re"}],["path",{d:"M20 14h2",key:"4cs60a"}],["path",{d:"M15 13v2",key:"1xurst"}],["path",{d:"M9 13v2",key:"rq6x2g"}]]);a.s(["Bot",()=>b],971382)}];
5
+ `,children:[(0,b.jsx)("div",{className:`w-5 h-5 rounded-md flex items-center justify-center flex-shrink-0 border ${c?"bg-[var(--primary)] border-[var(--primary)]":"border-[var(--border)]"}`,children:c&&(0,b.jsx)(f.Check,{className:"w-3 h-3 text-white"})}),(0,b.jsxs)("div",{className:"min-w-0 flex-1",children:[(0,b.jsxs)("div",{className:"flex items-center gap-2",children:[(0,b.jsx)("span",{className:"text-sm font-medium",children:a.label}),a.meta&&(0,b.jsx)("span",{className:"text-[10px] px-1.5 py-0.5 rounded-full bg-[var(--muted)]/50 text-[var(--muted-foreground)]",children:a.meta})]}),a.description&&(0,b.jsx)("p",{className:"text-xs text-[var(--muted-foreground)] mt-0.5 line-clamp-1",children:a.description})]})]},a.id)})]})]})]})}a.s(["default",()=>h])},66456,a=>{"use strict";let b=(0,a.i(831709).default)("zap",[["path",{d:"M4 14a1 1 0 0 1-.78-1.63l9.9-10.2a.5.5 0 0 1 .86.46l-1.92 6.02A1 1 0 0 0 13 10h7a1 1 0 0 1 .78 1.63l-9.9 10.2a.5.5 0 0 1-.86-.46l1.92-6.02A1 1 0 0 0 11 14z",key:"1xq2db"}]]);a.s(["Zap",()=>b],66456)},144462,962684,a=>{"use strict";let b=(0,a.i(831709).default)("square-terminal",[["path",{d:"m7 11 2-2-2-2",key:"1lz0vl"}],["path",{d:"M11 13h4",key:"1p7l4v"}],["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",ry:"2",key:"1m3agn"}]]);a.s(["default",()=>b],962684),a.s(["TerminalSquare",()=>b],144462)},227444,a=>{"use strict";var b=a.i(786220);function c(a){let[c,d]=(0,b.useState)([]),[e,f]=(0,b.useState)(null),[g,h]=(0,b.useState)(!0),i=(0,b.useCallback)(async()=>{if(!a){d([]),f(null),h(!1);return}try{let b=await fetch(`/api/trackers/connections?projectId=${encodeURIComponent(a)}`),c=await b.json();d(Array.isArray(c.connections)?c.connections:[]),f("string"==typeof c.defaultTracker?c.defaultTracker:null)}catch{d([]),f(null)}finally{h(!1)}},[a]);(0,b.useEffect)(()=>{i()},[i]);let j=(0,b.useCallback)(async(b,c)=>{if(!a)return{ok:!1,error:"Missing projectId"};try{let d=await fetch("/api/trackers/connections",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({type:b,projectId:a,metadata:c})});if(!d.ok){let a=await d.json().catch(()=>({}));return{ok:!1,error:a.error||"Failed to add connection"}}return await i(),{ok:!0}}catch{return{ok:!1,error:"Failed to add connection"}}},[a,i]),k=(0,b.useCallback)(async b=>{if(!a)return{ok:!1,error:"Missing projectId"};try{let c=await fetch(`/api/trackers/${b}/status?projectId=${encodeURIComponent(a)}`,{method:"DELETE"});if(!c.ok){let a=await c.json().catch(()=>({}));return{ok:!1,error:a.error||"Failed to remove connection"}}return await i(),{ok:!0}}catch{return{ok:!1,error:"Failed to remove connection"}}},[a,i]),l=(0,b.useCallback)(async b=>{if(!a)return{ok:!1,error:"Missing projectId"};try{let c=await fetch("/api/trackers/connections",{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify({projectId:a,defaultTracker:b})});if(!c.ok){let a=await c.json().catch(()=>({}));return{ok:!1,error:a.error||"Failed to set default tracker"}}return await i(),{ok:!0}}catch{return{ok:!1,error:"Failed to set default tracker"}}},[a,i]);return{connections:c,defaultTracker:e,loading:g,refresh:i,addConnection:j,removeConnection:k,setDefaultTracker:l}}a.s(["useTrackerConnections",()=>c])},349692,372871,a=>{"use strict";let b=(0,a.i(831709).default)("loader-circle",[["path",{d:"M21 12a9 9 0 1 1-6.219-8.56",key:"13zald"}]]);a.s(["default",()=>b],372871),a.s(["Loader2",()=>b],349692)},157633,a=>{"use strict";let b=(0,a.i(831709).default)("folder",[["path",{d:"M20 20a2 2 0 0 0 2-2V8a2 2 0 0 0-2-2h-7.9a2 2 0 0 1-1.69-.9L9.6 3.9A2 2 0 0 0 7.93 3H4a2 2 0 0 0-2 2v13a2 2 0 0 0 2 2Z",key:"1kt360"}]]);a.s(["Folder",()=>b],157633)},427411,a=>{"use strict";let b={bounds:null,sidebar:{workspaceWidth:260,logPanelHeight:200,workspaceVisible:!0,logPanelVisible:!1,linearTicketPanelWidth:576,objectiveChatPanelWidth:440,objectiveListPanelWidth:320},scroll:{lastThreadId:null,lastWorkspaceId:null}};function c(){return({...b}).sidebar}function d(a){let c={...b};c.sidebar={...c.sidebar,...a}}function e(){return c().workspaceWidth}function f(a){d({workspaceWidth:a})}function g(){return c().linearTicketPanelWidth}function h(a){d({linearTicketPanelWidth:a})}function i(){return c().objectiveChatPanelWidth}function j(a){d({objectiveChatPanelWidth:a})}function k(){return c().objectiveListPanelWidth}function l(a){d({objectiveListPanelWidth:a})}a.s(["loadLinearTicketPanelWidth",()=>g,"loadObjectiveChatPanelWidth",()=>i,"loadObjectiveListPanelWidth",()=>k,"loadWorkspaceWidth",()=>e,"persistLinearTicketPanelWidth",()=>h,"persistObjectiveChatPanelWidth",()=>j,"persistObjectiveListPanelWidth",()=>l,"persistWorkspaceWidth",()=>f])},552605,a=>{"use strict";let b=(0,a.i(831709).default)("file-text",[["path",{d:"M6 22a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.704.706l3.588 3.588A2.4 2.4 0 0 1 20 8v12a2 2 0 0 1-2 2z",key:"1oefj6"}],["path",{d:"M14 2v5a1 1 0 0 0 1 1h5",key:"wfsgrz"}],["path",{d:"M10 9H8",key:"b1mrlr"}],["path",{d:"M16 13H8",key:"t4e002"}],["path",{d:"M16 17H8",key:"z1uh3a"}]]);a.s(["FileText",()=>b],552605)},422662,(a,b,c)=>{"use strict";Object.defineProperty(c,"__esModule",{value:!0});var d={getDeploymentId:function(){return f},getDeploymentIdQueryOrEmptyString:function(){return g}};for(var e in d)Object.defineProperty(c,e,{enumerable:!0,get:d[e]});function f(){return!1}function g(){return""}},737313,a=>{"use strict";let b=(0,a.i(831709).default)("message-square",[["path",{d:"M22 17a2 2 0 0 1-2 2H6.828a2 2 0 0 0-1.414.586l-2.202 2.202A.71.71 0 0 1 2 21.286V5a2 2 0 0 1 2-2h16a2 2 0 0 1 2 2z",key:"18887p"}]]);a.s(["MessageSquare",()=>b],737313)},392045,70014,a=>{"use strict";var b=a.i(308316);function c({className:a}){return(0,b.jsx)("svg",{className:a,viewBox:"0 0 24 24",fill:"currentColor",xmlns:"http://www.w3.org/2000/svg",children:(0,b.jsx)("path",{d:"M2.886 4.18A11.982 11.982 0 0 1 11.99 0C18.624 0 24 5.376 24 12.009c0 3.64-1.62 6.903-4.18 9.105L2.887 4.18ZM1.817 5.626l16.556 16.556c-.524.33-1.075.62-1.65.866L.951 7.277c.247-.575.537-1.126.866-1.65ZM.322 9.163l14.515 14.515c-.71.172-1.443.282-2.195.322L0 11.358a12 12 0 0 1 .322-2.195Zm-.17 4.862 9.823 9.824a12.02 12.02 0 0 1-9.824-9.824Z"})})}a.s(["LinearIcon",()=>c],70014);let d={linear:c,jira:function({className:a}){return(0,b.jsxs)("svg",{className:a,viewBox:"12 12 104 104",fill:"currentColor",xmlns:"http://www.w3.org/2000/svg",children:[(0,b.jsx)("path",{d:"M108.023 16H61.805c0 11.52 9.324 20.848 20.847 20.848h8.5v8.226c0 11.52 9.328 20.848 20.848 20.848V19.977A3.98 3.98 0 00108.023 16zm0 0"}),(0,b.jsx)("path",{d:"M85.121 39.04H38.902c0 11.519 9.325 20.847 20.844 20.847h8.504v8.226c0 11.52 9.328 20.848 20.848 20.848V43.016a3.983 3.983 0 00-3.977-3.977zm0 0"}),(0,b.jsx)("path",{d:"M62.219 62.078H16c0 11.524 9.324 20.848 20.848 20.848h8.5v8.23c0 11.52 9.328 20.844 20.847 20.844V66.059a3.984 3.984 0 00-3.976-3.98zm0 0"})]})}};function e({trackerType:a,className:c}){let e=d[a];return e?(0,b.jsx)(e,{className:c}):(0,b.jsx)(f,{className:c})}function f({className:a}){return(0,b.jsxs)("svg",{className:a,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round",children:[(0,b.jsx)("path",{d:"M9 5H7a2 2 0 0 0-2 2v12a2 2 0 0 0 2 2h10a2 2 0 0 0 2-2V7a2 2 0 0 0-2-2h-2"}),(0,b.jsx)("rect",{x:"9",y:"3",width:"6",height:"4",rx:"2"}),(0,b.jsx)("path",{d:"M9 12h6"}),(0,b.jsx)("path",{d:"M9 16h6"})]})}a.s(["TrackerIcon",()=>e],392045)},971382,a=>{"use strict";let b=(0,a.i(831709).default)("bot",[["path",{d:"M12 8V4H8",key:"hb8ula"}],["rect",{width:"16",height:"12",x:"4",y:"8",rx:"2",key:"enze0r"}],["path",{d:"M2 14h2",key:"vft8re"}],["path",{d:"M20 14h2",key:"4cs60a"}],["path",{d:"M15 13v2",key:"1xurst"}],["path",{d:"M9 13v2",key:"rq6x2g"}]]);a.s(["Bot",()=>b],971382)}];
6
6
 
7
7
  //# sourceMappingURL=%5Broot-of-the-server%5D__b8484b0e._.js.map
@@ -1,3 +1,3 @@
1
- module.exports=[356239,a=>{"use strict";let b=(0,a.i(831709).default)("terminal",[["path",{d:"M12 19h8",key:"baeox8"}],["path",{d:"m4 17 6-6-6-6",key:"1yngyt"}]]);a.s(["Terminal",()=>b],356239)},693896,a=>{"use strict";let b=(0,a.i(831709).default)("circle-alert",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["line",{x1:"12",x2:"12",y1:"8",y2:"12",key:"1pkeuh"}],["line",{x1:"12",x2:"12.01",y1:"16",y2:"16",key:"4dfq90"}]]);a.s(["AlertCircle",()=>b],693896)},44668,a=>{"use strict";let b=(0,a.i(831709).default)("circle-check",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"m9 12 2 2 4-4",key:"dzmm74"}]]);a.s(["CheckCircle2",()=>b],44668)},947218,a=>{"use strict";var b=a.i(786220);let c=new Map;function d(a){let b=c.get(a);return b?Date.now()-b.ts>3e5?(c.delete(a),null):b:null}function e(a){c.delete(a)}function f(a,f){let[g,h]=(0,b.useState)(!1),[i,j]=(0,b.useState)(!0),[k,l]=(0,b.useState)(null),[m,n]=(0,b.useState)({claude:!1,codex:!1,gemini:!1}),[o,p]=(0,b.useState)({}),q=(0,b.useRef)(null),r=`/api/trackers/${encodeURIComponent(a)}`,s=`${a}:${f}`,t=(0,b.useCallback)(async()=>{try{let a=await fetch(`${r}/mcp-setup`),b=await a.json();p(b.configured??{})}catch{}},[r]),u=(0,b.useCallback)(async()=>{if(!f)return h(!1),!1;let a=d(s);if(a)return h(a.connected),l(a.user),n(a.clis),p(a.mcpConfigured),j(!1),a.connected;try{var b;let a=`?projectId=${encodeURIComponent(f)}`,[d,e]=await Promise.all([fetch(`${r}/status${a}`),fetch(`${r}/mcp-setup`)]),g=await d.json(),i=await e.json(),j=g.clis??{claude:!1,codex:!1,gemini:!1},k=i.configured??{},m=g.user??null;return h(g.connected),l(m),n(j),p(k),b={connected:g.connected,user:m,clis:j,mcpConfigured:k},c.set(s,{...b,ts:Date.now()}),g.connected}catch{return h(!1),!1}finally{j(!1)}},[f,r,s]);(0,b.useEffect)(()=>{let a=d(s);a?(h(a.connected),l(a.user),n(a.clis),p(a.mcpConfigured),j(!1)):(j(!0),h(!1),l(null))},[a,f,s]),(0,b.useEffect)(()=>(u(),()=>{q.current&&clearInterval(q.current)}),[u]);let v=(0,b.useCallback)(()=>{f&&(e(s),window.open(`${r}/auth?projectId=${encodeURIComponent(f)}`,"_blank","noopener"),q.current&&clearInterval(q.current),q.current=setInterval(async()=>{e(s),await u()&&q.current&&(clearInterval(q.current),q.current=null)},2e3))},[f,r,s,u]),w=(0,b.useCallback)(async a=>{if(!f)return{ok:!1,error:"Missing projectId"};try{let b=await fetch(`${r}/token`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({projectId:f,accessToken:a})});if(!b.ok){let a=await b.json().catch(()=>({}));return{ok:!1,error:a.error||"Failed to save token"}}return e(s),await u(),{ok:!0}}catch{return{ok:!1,error:"Failed to connect"}}},[f,r,s,u]);return{connected:g,loading:i,user:k,clis:m,mcpConfigured:o,connect:v,connectWithKey:w,disconnect:(0,b.useCallback)(async()=>{f&&(e(s),await fetch(`${r}/status?projectId=${encodeURIComponent(f)}`,{method:"DELETE"}),h(!1),l(null))},[f,r,s]),configureMcp:(0,b.useCallback)(async a=>{try{let b=await fetch(`${r}/mcp-setup`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({cli:a})});if(!b.ok){let a=await b.json().catch(()=>({}));return{ok:!1,error:a.error||"Failed to configure MCP"}}return await t(),{ok:!0}}catch{return{ok:!1,error:"Failed to configure MCP"}}},[r,t]),refresh:u}}a.s(["useTrackerConnection",()=>f])},500650,a=>{"use strict";let b=(0,a.i(831709).default)("log-out",[["path",{d:"m16 17 5-5-5-5",key:"1bji2h"}],["path",{d:"M21 12H9",key:"dn1m92"}],["path",{d:"M9 21H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h4",key:"1uf3rs"}]]);a.s(["LogOut",()=>b],500650)},663504,235992,a=>{"use strict";var b=a.i(831709);let c=(0,b.default)("key",[["path",{d:"m15.5 7.5 2.3 2.3a1 1 0 0 0 1.4 0l2.1-2.1a1 1 0 0 0 0-1.4L19 4",key:"g0fldk"}],["path",{d:"m21 2-9.6 9.6",key:"1j0ho8"}],["circle",{cx:"7.5",cy:"15.5",r:"5.5",key:"yqb3hr"}]]);a.s(["Key",()=>c],663504);let d=(0,b.default)("globe",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M12 2a14.5 14.5 0 0 0 0 20 14.5 14.5 0 0 0 0-20",key:"13o1zl"}],["path",{d:"M2 12h20",key:"9i4pu4"}]]);a.s(["Globe",()=>d],235992)},778784,a=>{"use strict";var b=a.i(308316),c=a.i(786220),d=a.i(44668),e=a.i(663504),f=a.i(235992),g=a.i(349692),h=a.i(693896),i=a.i(356239),j=a.i(500650),k=a.i(392045);let l={claude:{name:"Claude Code",configPath:"~/.claude/settings.json"},codex:{name:"Codex CLI",configPath:"~/.codex/config.toml"},gemini:{name:"Gemini CLI",configPath:"~/.gemini/settings.json"}};function m({trackerType:a,projectId:m,connected:n,onConnect:o,onConnectWithKey:p,onDisconnect:q,loading:r=!1,clis:s,mcpConfigured:t,onConfigureMcp:u}){let[v,w]=c.default.useState(""),[x,y]=c.default.useState(null),[z,A]=c.default.useState(!1),[B,C]=c.default.useState(!1),[D,E]=c.default.useState(null),[F,G]=c.default.useState({}),H=async a=>{if(!u)return;E(a),G(b=>({...b,[a]:""}));let b=await u(a);b.ok||G(c=>({...c,[a]:b.error??"Failed to install MCP"})),E(null)},I=s?["claude","codex","gemini"].filter(a=>s[a]):["claude"];if(r)return(0,b.jsx)("div",{className:"flex items-center justify-center p-12",children:(0,b.jsx)(g.Loader2,{className:"animate-spin h-8 w-8 text-muted-foreground"})});if(n)return(0,b.jsxs)("div",{className:"p-8 flex flex-col items-center gap-6",children:[(0,b.jsxs)("div",{className:"w-full max-w-md p-8 border border-green-500/20 bg-green-500/5 rounded-2xl flex flex-col items-center gap-4 text-center",children:[(0,b.jsx)("div",{className:"h-16 w-16 rounded-full bg-green-500/10 flex items-center justify-center text-green-600 shadow-inner",children:(0,b.jsx)(d.CheckCircle2,{className:"h-8 w-8"})}),(0,b.jsxs)("div",{className:"space-y-2",children:[(0,b.jsxs)("h3",{className:"text-xl font-bold text-foreground capitalize",children:[a," Connected"]}),(0,b.jsxs)("p",{className:"text-sm text-muted-foreground leading-relaxed",children:["Your ",a," workspace is successfully connected. The agent can now sync issues and manage your backlog."]})]}),(0,b.jsxs)("div",{className:"mt-2 px-4 py-1.5 rounded-full bg-background border text-xs font-medium text-muted-foreground flex items-center gap-2",children:[(0,b.jsx)("div",{className:"h-1.5 w-1.5 rounded-full bg-green-500 animate-pulse"}),"Active Connection"]}),q&&(0,b.jsxs)("button",{onClick:q,className:"flex items-center gap-1.5 text-xs text-muted-foreground hover:text-destructive transition-colors mt-1",children:[(0,b.jsx)(j.LogOut,{className:"h-3.5 w-3.5"}),"Disconnect"]})]}),I.length>0&&(0,b.jsx)("div",{className:"w-full max-w-md",children:(0,b.jsxs)("div",{className:"border rounded-xl p-5 flex flex-col gap-4",children:[(0,b.jsxs)("div",{className:"flex items-center gap-2",children:[(0,b.jsx)(i.Terminal,{className:"h-4 w-4 text-muted-foreground"}),(0,b.jsx)("span",{className:"text-sm font-medium",children:"MCP Server"})]}),(0,b.jsxs)("p",{className:"text-xs text-muted-foreground leading-relaxed -mt-2",children:["Install the ",a," MCP server so agents can access ",a," directly."]}),I.map(a=>{let c=l[a],e=t?.[a]??!1,f=D===a,i=F[a];return(0,b.jsxs)("div",{className:"flex flex-col gap-1.5",children:[(0,b.jsxs)("div",{className:"flex items-center justify-between gap-3",children:[(0,b.jsx)("span",{className:"text-xs font-medium text-foreground",children:c.name}),e?(0,b.jsxs)("span",{className:"text-xs font-medium text-green-600 flex items-center gap-1",children:[(0,b.jsx)(d.CheckCircle2,{className:"h-3.5 w-3.5"}),"Installed"]}):(0,b.jsx)("button",{onClick:()=>H(a),disabled:f||!u,className:"flex items-center gap-1.5 px-3 py-1 bg-secondary text-secondary-foreground rounded-md text-xs font-semibold hover:bg-secondary/90 disabled:opacity-50 transition-all active:scale-[0.98]",children:f?(0,b.jsxs)(b.Fragment,{children:[(0,b.jsx)(g.Loader2,{className:"h-3 w-3 animate-spin"}),"Installing…"]}):(0,b.jsx)(b.Fragment,{children:"Install"})})]}),e&&(0,b.jsxs)("p",{className:"text-[10px] text-muted-foreground",children:["Configured in ",(0,b.jsx)("code",{className:"font-mono",children:c.configPath})]}),i&&(0,b.jsxs)("div",{className:"flex items-center gap-1.5 text-xs text-destructive bg-destructive/10 p-2 rounded-md",children:[(0,b.jsx)(h.AlertCircle,{className:"h-3.5 w-3.5 shrink-0"}),i]})]},a)})]})})]});let J=async()=>{if(v.trim()){C(!0),y(null);try{let a=await p(v.trim());a.ok?(w(""),A(!1)):y(a.error??"Failed to connect")}catch(a){y("An unexpected error occurred")}finally{C(!1)}}};return(0,b.jsxs)("div",{className:"flex flex-col items-center gap-6 p-8",children:[(0,b.jsxs)("div",{className:"relative",children:[(0,b.jsx)(k.TrackerIcon,{trackerType:a,className:"h-16 w-16"}),(0,b.jsx)("div",{className:"absolute -bottom-1 -right-1 h-6 w-6 rounded-full bg-background border flex items-center justify-center shadow-sm",children:(0,b.jsx)(f.Globe,{className:"h-3 w-3 text-muted-foreground"})})]}),(0,b.jsxs)("div",{className:"text-center space-y-2",children:[(0,b.jsxs)("h3",{className:"text-lg font-semibold capitalize",children:["Connect to ",a]}),(0,b.jsxs)("p",{className:"text-sm text-muted-foreground text-center max-w-sm leading-relaxed",children:["Link your ",a," account to import issues, track progress, and automate your workflow."]})]}),(0,b.jsxs)("div",{className:"flex flex-col gap-3 w-full max-w-xs pt-2",children:[(0,b.jsxs)("button",{onClick:o,className:"flex items-center justify-center gap-2 w-full px-4 py-2.5 bg-primary text-primary-foreground rounded-lg text-sm font-semibold hover:bg-primary/90 transition-all active:scale-[0.98] shadow-sm",children:[(0,b.jsx)(f.Globe,{className:"h-4 w-4"}),"Connect with OAuth"]}),(0,b.jsxs)("button",{onClick:()=>{A(!z),y(null)},className:"flex items-center justify-center gap-2 w-full px-4 py-2 text-sm text-muted-foreground hover:text-foreground transition-colors font-medium",children:[(0,b.jsx)(e.Key,{className:"h-3.5 w-3.5"}),z?"Use OAuth instead":"Connect with API key"]}),(0,b.jsx)("div",{className:`grid transition-all duration-300 ease-in-out ${z?"grid-rows-[1fr] opacity-100":"grid-rows-[0fr] opacity-0 pointer-events-none"}`,children:(0,b.jsx)("div",{className:"overflow-hidden",children:(0,b.jsxs)("div",{className:"flex flex-col gap-3 pt-2",children:[(0,b.jsxs)("div",{className:"relative",children:[(0,b.jsx)("input",{type:"password",value:v,onChange:a=>{w(a.target.value),x&&y(null)},placeholder:"Paste your API key here",className:`w-full px-3 py-2 border rounded-lg text-sm bg-background transition-colors focus:outline-none focus:ring-2 focus:ring-primary/20 ${x?"border-destructive":"focus:border-primary"}`,onKeyDown:a=>"Enter"===a.key&&J()}),(0,b.jsx)(e.Key,{className:"absolute right-3 top-2.5 h-4 w-4 text-muted-foreground/50"})]}),x&&(0,b.jsxs)("div",{className:"flex items-center gap-2 text-xs text-destructive bg-destructive/10 p-2 rounded-md",children:[(0,b.jsx)(h.AlertCircle,{className:"h-3.5 w-3.5 shrink-0"}),(0,b.jsx)("p",{children:x})]}),(0,b.jsx)("button",{onClick:J,disabled:B||!v.trim(),className:"flex items-center justify-center gap-2 w-full px-4 py-2 bg-secondary text-secondary-foreground rounded-lg text-sm font-semibold hover:bg-secondary/90 disabled:opacity-50 transition-all active:scale-[0.98]",children:B?(0,b.jsxs)(b.Fragment,{children:[(0,b.jsx)(g.Loader2,{className:"h-4 w-4 animate-spin"}),"Connecting..."]}):"Verify & Connect"}),(0,b.jsxs)("p",{className:"text-[10px] text-muted-foreground text-center px-2",children:["Your API key is stored securely and only used for ",a," integration."]})]})})})]})]})}a.s(["default",()=>m])},742557,a=>{"use strict";var b=a.i(308316),c=a.i(786220),d=a.i(285320),e=a.i(44668),f=a.i(500650),g=a.i(778784),h=a.i(392045),i=a.i(830284),j=a.i(947218),k=a.i(227444);let l=[{type:"linear",label:"Linear"},{type:"jira",label:"Jira Cloud"}];function m(){return(0,b.jsxs)("div",{className:"flex flex-col items-center justify-center min-h-[calc(100vh-3.5rem)] gap-8 p-8 -mt-7 animate-pulse",children:[(0,b.jsxs)("div",{className:"space-y-3 text-center flex flex-col items-center",children:[(0,b.jsx)("div",{className:"h-7 w-56 rounded-lg bg-muted"}),(0,b.jsx)("div",{className:"h-4 w-80 rounded bg-muted"})]}),(0,b.jsx)("div",{className:"grid grid-cols-1 sm:grid-cols-2 gap-4 w-full max-w-lg",children:[0,1].map(a=>(0,b.jsxs)("div",{className:"flex flex-col items-center gap-4 p-8 rounded-xl border border-border",children:[(0,b.jsx)("div",{className:"h-16 w-16 rounded-xl bg-muted"}),(0,b.jsxs)("div",{className:"flex flex-col items-center gap-2",children:[(0,b.jsx)("div",{className:"h-4 w-20 rounded bg-muted"}),(0,b.jsx)("div",{className:"h-3 w-24 rounded bg-muted"})]})]},a))})]})}function n(){return(0,b.jsxs)("div",{className:"flex flex-col items-center gap-6 p-8 animate-pulse",children:[(0,b.jsx)("div",{className:"h-16 w-16 rounded-xl bg-muted"}),(0,b.jsxs)("div",{className:"flex flex-col items-center gap-2 w-full max-w-sm",children:[(0,b.jsx)("div",{className:"h-5 w-40 rounded bg-muted"}),(0,b.jsx)("div",{className:"h-3 w-72 rounded bg-muted"}),(0,b.jsx)("div",{className:"h-3 w-56 rounded bg-muted"})]}),(0,b.jsxs)("div",{className:"flex flex-col gap-3 w-full max-w-xs pt-2",children:[(0,b.jsx)("div",{className:"h-10 w-full rounded-lg bg-muted"}),(0,b.jsx)("div",{className:"h-8 w-full rounded-lg bg-muted/60"})]})]})}function o({params:a}){let{slug:o}=(0,c.use)(a),{projects:p}=(0,i.useProjects)(),q=p.find(a=>a.slug===o),r=q?.id??"",{connections:s,loading:t,removeConnection:u}=(0,k.useTrackerConnections)(r),v=new Set(s.filter(a=>a.connected).map(a=>a.type)),[w,x]=(0,c.useState)(null),{connected:y,loading:z,connect:A,connectWithKey:B,disconnect:C,clis:D,mcpConfigured:E,configureMcp:F}=(0,j.useTrackerConnection)(w??"linear",r);return(0,b.jsx)("div",{className:"flex flex-col h-full bg-background",children:(0,b.jsx)("main",{className:"flex-1 overflow-auto",children:w?(0,b.jsx)("div",{className:"flex flex-col items-center px-6 py-12",children:(0,b.jsxs)("div",{className:"w-full max-w-2xl",children:[(0,b.jsxs)("button",{onClick:()=>x(null),className:"group flex items-center gap-2 text-sm text-muted-foreground hover:text-foreground mb-8 transition-colors",children:[(0,b.jsx)(d.ArrowLeft,{className:"h-3 w-3 transition-transform group-hover:-translate-x-0.5"}),"Back to tracker picker"]}),(0,b.jsxs)("div",{className:"bg-card border rounded-xl shadow-sm overflow-hidden",children:[(0,b.jsx)("div",{className:"px-6 pt-8 pb-1 text-center",children:(0,b.jsxs)("h2",{className:"text-2xl font-semibold tracking-tight",children:["Connect ",l.find(a=>a.type===w)?.label??w]})}),z?(0,b.jsx)(n,{}):(0,b.jsx)(g.default,{projectId:r,trackerType:w,connected:y,loading:!1,onConnect:A,onConnectWithKey:B,onDisconnect:()=>{C(),x(null)},clis:D,mcpConfigured:E,onConfigureMcp:F})]})]})}):t?(0,b.jsx)(m,{}):(0,b.jsxs)("div",{className:"flex flex-col items-center justify-center min-h-[calc(100vh-3.5rem)] gap-8 p-8 -mt-7",children:[(0,b.jsxs)("div",{className:"space-y-2 text-center",children:[(0,b.jsx)("h2",{className:"text-2xl font-bold tracking-tight",children:"Connect Issue Tracker"}),(0,b.jsx)("p",{className:"text-muted-foreground max-w-md mx-auto",children:"Choose an issue tracker to connect to this project to enable issue tracking and agent workflows."})]}),(0,b.jsx)("div",{className:"grid grid-cols-1 sm:grid-cols-2 gap-4 w-full max-w-lg",children:l.map(a=>{let c=v.has(a.type);return(0,b.jsxs)("div",{className:"relative flex flex-col items-center gap-4 p-8 rounded-xl border transition-all duration-200 group "+(c?"border-green-500/20 bg-green-500/5":"border-border hover:border-primary/50 hover:bg-accent/50 hover:shadow-md cursor-pointer active:scale-[0.98]"),onClick:()=>!c&&x(a.type),children:[(0,b.jsxs)("div",{className:"relative",children:[(0,b.jsx)(h.TrackerIcon,{trackerType:a.type,className:"h-16 w-16 transition-transform group-hover:scale-105"}),c&&(0,b.jsx)("div",{className:"absolute -top-1 -right-1 h-6 w-6 rounded-full bg-green-500 border-2 border-background flex items-center justify-center text-white shadow-sm",children:(0,b.jsx)(e.CheckCircle2,{className:"h-4 w-4"})})]}),(0,b.jsxs)("div",{className:"flex flex-col items-center gap-1",children:[(0,b.jsx)("span",{className:"text-base font-semibold",children:a.label}),c?(0,b.jsx)("span",{className:"text-xs font-medium text-green-600",children:"Connected"}):(0,b.jsx)("span",{className:"text-xs text-muted-foreground",children:"Click to connect"})]}),c&&(0,b.jsxs)("button",{onClick:b=>{b.stopPropagation(),u(a.type)},className:"flex items-center gap-1.5 text-xs text-muted-foreground hover:text-destructive transition-colors",children:[(0,b.jsx)(f.LogOut,{className:"h-3.5 w-3.5"}),"Disconnect"]})]},a.type)})})]})})})}a.s(["default",()=>o])}];
1
+ module.exports=[356239,a=>{"use strict";let b=(0,a.i(831709).default)("terminal",[["path",{d:"M12 19h8",key:"baeox8"}],["path",{d:"m4 17 6-6-6-6",key:"1yngyt"}]]);a.s(["Terminal",()=>b],356239)},693896,a=>{"use strict";let b=(0,a.i(831709).default)("circle-alert",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["line",{x1:"12",x2:"12",y1:"8",y2:"12",key:"1pkeuh"}],["line",{x1:"12",x2:"12.01",y1:"16",y2:"16",key:"4dfq90"}]]);a.s(["AlertCircle",()=>b],693896)},44668,a=>{"use strict";let b=(0,a.i(831709).default)("circle-check",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"m9 12 2 2 4-4",key:"dzmm74"}]]);a.s(["CheckCircle2",()=>b],44668)},947218,a=>{"use strict";var b=a.i(786220);let c=new Map;function d(a){let b=c.get(a);return b?Date.now()-b.ts>3e5?(c.delete(a),null):b:null}function e(a){c.delete(a)}function f(a,f){let[g,h]=(0,b.useState)(!1),[i,j]=(0,b.useState)(!0),[k,l]=(0,b.useState)(null),[m,n]=(0,b.useState)({claude:!1,codex:!1,gemini:!1}),[o,p]=(0,b.useState)({}),q=(0,b.useRef)(null),r=`/api/trackers/${encodeURIComponent(a)}`,s=`${a}:${f}`,t=(0,b.useCallback)(async()=>{try{let a=await fetch(`${r}/mcp-setup`),b=await a.json();p(b.configured??{})}catch{}},[r]),u=(0,b.useCallback)(async()=>{if(!f)return h(!1),!1;let a=d(s);if(a)return h(a.connected),l(a.user),n(a.clis),p(a.mcpConfigured),j(!1),a.connected;try{var b;let a=`?projectId=${encodeURIComponent(f)}`,[d,e]=await Promise.all([fetch(`${r}/status${a}`),fetch(`${r}/mcp-setup`)]),g=await d.json(),i=await e.json(),j=g.clis??{claude:!1,codex:!1,gemini:!1},k=i.configured??{},m=g.user??null;return h(g.connected),l(m),n(j),p(k),b={connected:g.connected,user:m,clis:j,mcpConfigured:k},c.set(s,{...b,ts:Date.now()}),g.connected}catch{return h(!1),!1}finally{j(!1)}},[f,r,s]);(0,b.useEffect)(()=>{let a=d(s);a?(h(a.connected),l(a.user),n(a.clis),p(a.mcpConfigured),j(!1)):(j(!0),h(!1),l(null))},[a,f,s]),(0,b.useEffect)(()=>(u(),()=>{q.current&&clearInterval(q.current)}),[u]);let v=(0,b.useCallback)(()=>{f&&(e(s),window.open(`${r}/auth?projectId=${encodeURIComponent(f)}`,"_blank","noopener"),q.current&&clearInterval(q.current),q.current=setInterval(async()=>{e(s),await u()&&q.current&&(clearInterval(q.current),q.current=null)},2e3))},[f,r,s,u]),w=(0,b.useCallback)(async a=>{if(!f)return{ok:!1,error:"Missing projectId"};try{let b=await fetch(`${r}/token`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({projectId:f,accessToken:a})});if(!b.ok){let a=await b.json().catch(()=>({}));return{ok:!1,error:a.error||"Failed to save token"}}return e(s),await u(),{ok:!0}}catch{return{ok:!1,error:"Failed to connect"}}},[f,r,s,u]);return{connected:g,loading:i,user:k,clis:m,mcpConfigured:o,connect:v,connectWithKey:w,disconnect:(0,b.useCallback)(async()=>{f&&(e(s),await fetch(`${r}/status?projectId=${encodeURIComponent(f)}`,{method:"DELETE"}),h(!1),l(null))},[f,r,s]),configureMcp:(0,b.useCallback)(async a=>{try{let b=await fetch(`${r}/mcp-setup`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({cli:a})});if(!b.ok){let a=await b.json().catch(()=>({}));return{ok:!1,error:a.error||"Failed to configure MCP"}}return await t(),{ok:!0}}catch{return{ok:!1,error:"Failed to configure MCP"}}},[r,t]),refresh:u}}a.s(["useTrackerConnection",()=>f])},500650,a=>{"use strict";let b=(0,a.i(831709).default)("log-out",[["path",{d:"m16 17 5-5-5-5",key:"1bji2h"}],["path",{d:"M21 12H9",key:"dn1m92"}],["path",{d:"M9 21H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h4",key:"1uf3rs"}]]);a.s(["LogOut",()=>b],500650)},663504,235992,a=>{"use strict";var b=a.i(831709);let c=(0,b.default)("key",[["path",{d:"m15.5 7.5 2.3 2.3a1 1 0 0 0 1.4 0l2.1-2.1a1 1 0 0 0 0-1.4L19 4",key:"g0fldk"}],["path",{d:"m21 2-9.6 9.6",key:"1j0ho8"}],["circle",{cx:"7.5",cy:"15.5",r:"5.5",key:"yqb3hr"}]]);a.s(["Key",()=>c],663504);let d=(0,b.default)("globe",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M12 2a14.5 14.5 0 0 0 0 20 14.5 14.5 0 0 0 0-20",key:"13o1zl"}],["path",{d:"M2 12h20",key:"9i4pu4"}]]);a.s(["Globe",()=>d],235992)},778784,a=>{"use strict";var b=a.i(308316),c=a.i(786220),d=a.i(44668),e=a.i(663504),f=a.i(235992),g=a.i(349692),h=a.i(693896),i=a.i(356239),j=a.i(500650),k=a.i(392045);let l={claude:{name:"Claude Code",configPath:"~/.claude/settings.json"},codex:{name:"Codex CLI",configPath:"~/.codex/config.toml"},gemini:{name:"Gemini CLI",configPath:"~/.gemini/settings.json"}};function m({trackerType:a,projectId:m,connected:n,onConnect:o,onConnectWithKey:p,onDisconnect:q,loading:r=!1,clis:s,mcpConfigured:t,onConfigureMcp:u}){let[v,w]=c.default.useState(""),[x,y]=c.default.useState(null),[z,A]=c.default.useState(!1),[B,C]=c.default.useState(!1),[D,E]=c.default.useState(null),[F,G]=c.default.useState({}),H=async a=>{if(!u)return;E(a),G(b=>({...b,[a]:""}));let b=await u(a);b.ok||G(c=>({...c,[a]:b.error??"Failed to install MCP"})),E(null)},I=s?["claude","codex","gemini"].filter(a=>s[a]):["claude"];if(r)return(0,b.jsx)("div",{className:"flex items-center justify-center p-12",children:(0,b.jsx)(g.Loader2,{className:"animate-spin h-8 w-8 text-muted-foreground"})});if(n)return(0,b.jsxs)("div",{className:"p-8 flex flex-col items-center gap-6",children:[(0,b.jsxs)("div",{className:"w-full max-w-md p-8 border border-green-500/20 bg-green-500/5 rounded-2xl flex flex-col items-center gap-4 text-center",children:[(0,b.jsx)("div",{className:"h-16 w-16 rounded-full bg-green-500/10 flex items-center justify-center text-green-600 shadow-inner",children:(0,b.jsx)(d.CheckCircle2,{className:"h-8 w-8"})}),(0,b.jsxs)("div",{className:"space-y-2",children:[(0,b.jsxs)("h3",{className:"text-xl font-bold text-foreground capitalize",children:[a," Connected"]}),(0,b.jsxs)("p",{className:"text-sm text-muted-foreground leading-relaxed",children:["Your ",a," workspace is successfully connected. The agent can now sync issues and manage your backlog."]})]}),(0,b.jsxs)("div",{className:"mt-2 px-4 py-1.5 rounded-full bg-background border text-xs font-medium text-muted-foreground flex items-center gap-2",children:[(0,b.jsx)("div",{className:"h-1.5 w-1.5 rounded-full bg-green-500 animate-pulse"}),"Active Connection"]}),q&&(0,b.jsxs)("button",{onClick:q,className:"flex items-center gap-1.5 text-xs text-muted-foreground hover:text-destructive transition-colors mt-1",children:[(0,b.jsx)(j.LogOut,{className:"h-3.5 w-3.5"}),"Disconnect"]})]}),I.length>0&&(0,b.jsx)("div",{className:"w-full max-w-md",children:(0,b.jsxs)("div",{className:"border rounded-xl p-5 flex flex-col gap-4",children:[(0,b.jsxs)("div",{className:"flex items-center gap-2",children:[(0,b.jsx)(i.Terminal,{className:"h-4 w-4 text-muted-foreground"}),(0,b.jsx)("span",{className:"text-sm font-medium",children:"MCP Server"})]}),(0,b.jsxs)("p",{className:"text-xs text-muted-foreground leading-relaxed -mt-2",children:["Install the ",a," MCP server so agents can access ",a," directly."]}),I.map(a=>{let c=l[a],e=t?.[a]??!1,f=D===a,i=F[a];return(0,b.jsxs)("div",{className:"flex flex-col gap-1.5",children:[(0,b.jsxs)("div",{className:"flex items-center justify-between gap-3",children:[(0,b.jsx)("span",{className:"text-xs font-medium text-foreground",children:c.name}),e?(0,b.jsxs)("span",{className:"text-xs font-medium text-green-600 flex items-center gap-1",children:[(0,b.jsx)(d.CheckCircle2,{className:"h-3.5 w-3.5"}),"Installed"]}):(0,b.jsx)("button",{onClick:()=>H(a),disabled:f||!u,className:"flex items-center gap-1.5 px-3 py-1 bg-secondary text-secondary-foreground rounded-md text-xs font-semibold hover:bg-secondary/90 disabled:opacity-50 transition-all active:scale-[0.98]",children:f?(0,b.jsxs)(b.Fragment,{children:[(0,b.jsx)(g.Loader2,{className:"h-3 w-3 animate-spin"}),"Installing…"]}):(0,b.jsx)(b.Fragment,{children:"Install"})})]}),e&&(0,b.jsxs)("p",{className:"text-[10px] text-muted-foreground",children:["Configured in ",(0,b.jsx)("code",{className:"font-mono",children:c.configPath})]}),i&&(0,b.jsxs)("div",{className:"flex items-center gap-1.5 text-xs text-destructive bg-destructive/10 p-2 rounded-md",children:[(0,b.jsx)(h.AlertCircle,{className:"h-3.5 w-3.5 shrink-0"}),i]})]},a)})]})})]});let J=async()=>{if(v.trim()){C(!0),y(null);try{let a=await p(v.trim());a.ok?(w(""),A(!1)):y(a.error??"Failed to connect")}catch(a){y("An unexpected error occurred")}finally{C(!1)}}};return(0,b.jsxs)("div",{className:"flex flex-col items-center gap-6 p-8",children:[(0,b.jsxs)("div",{className:"relative",children:[(0,b.jsx)(k.TrackerIcon,{trackerType:a,className:"h-16 w-16"}),(0,b.jsx)("div",{className:"absolute -bottom-1 -right-1 h-6 w-6 rounded-full bg-background border flex items-center justify-center shadow-sm",children:(0,b.jsx)(f.Globe,{className:"h-3 w-3 text-muted-foreground"})})]}),(0,b.jsxs)("div",{className:"text-center space-y-2",children:[(0,b.jsxs)("h3",{className:"text-lg font-semibold capitalize",children:["Connect to ",a]}),(0,b.jsxs)("p",{className:"text-sm text-muted-foreground text-center max-w-sm leading-relaxed",children:["Link your ",a," account to import issues, track progress, and automate your workflow."]})]}),(0,b.jsxs)("div",{className:"flex flex-col gap-3 w-full max-w-xs pt-2",children:[(0,b.jsxs)("button",{onClick:o,className:"flex items-center justify-center gap-2 w-full px-4 py-2.5 bg-primary text-primary-foreground rounded-lg text-sm font-semibold hover:bg-primary/90 transition-all active:scale-[0.98] shadow-sm",children:[(0,b.jsx)(f.Globe,{className:"h-4 w-4"}),"Connect with OAuth"]}),(0,b.jsxs)("button",{onClick:()=>{A(!z),y(null)},className:"flex items-center justify-center gap-2 w-full px-4 py-2 text-sm text-muted-foreground hover:text-foreground transition-colors font-medium",children:[(0,b.jsx)(e.Key,{className:"h-3.5 w-3.5"}),z?"Use OAuth instead":"Connect with API key"]}),(0,b.jsx)("div",{className:`grid transition-all duration-300 ease-in-out ${z?"grid-rows-[1fr] opacity-100":"grid-rows-[0fr] opacity-0 pointer-events-none"}`,children:(0,b.jsx)("div",{className:"overflow-hidden",children:(0,b.jsxs)("div",{className:"flex flex-col gap-3 pt-2",children:[(0,b.jsxs)("div",{className:"relative",children:[(0,b.jsx)("input",{type:"password",value:v,onChange:a=>{w(a.target.value),x&&y(null)},placeholder:"Paste your API key here",className:`w-full px-3 py-2 border rounded-lg text-sm bg-background transition-colors focus:outline-none focus:ring-2 focus:ring-primary/20 ${x?"border-destructive":"focus:border-primary"}`,onKeyDown:a=>"Enter"===a.key&&J()}),(0,b.jsx)(e.Key,{className:"absolute right-3 top-2.5 h-4 w-4 text-muted-foreground/50"})]}),x&&(0,b.jsxs)("div",{className:"flex items-center gap-2 text-xs text-destructive bg-destructive/10 p-2 rounded-md",children:[(0,b.jsx)(h.AlertCircle,{className:"h-3.5 w-3.5 shrink-0"}),(0,b.jsx)("p",{children:x})]}),(0,b.jsx)("button",{onClick:J,disabled:B||!v.trim(),className:"flex items-center justify-center gap-2 w-full px-4 py-2 bg-secondary text-secondary-foreground rounded-lg text-sm font-semibold hover:bg-secondary/90 disabled:opacity-50 transition-all active:scale-[0.98]",children:B?(0,b.jsxs)(b.Fragment,{children:[(0,b.jsx)(g.Loader2,{className:"h-4 w-4 animate-spin"}),"Connecting..."]}):"Verify & Connect"}),(0,b.jsxs)("p",{className:"text-[10px] text-muted-foreground text-center px-2",children:["Your API key is stored securely and only used for ",a," integration."]})]})})})]})]})}a.s(["default",()=>m])},742557,a=>{"use strict";var b=a.i(308316),c=a.i(786220),d=a.i(285320),e=a.i(44668),f=a.i(500650);let g=(0,a.i(831709).default)("star",[["path",{d:"M11.525 2.295a.53.53 0 0 1 .95 0l2.31 4.679a2.123 2.123 0 0 0 1.595 1.16l5.166.756a.53.53 0 0 1 .294.904l-3.736 3.638a2.123 2.123 0 0 0-.611 1.878l.882 5.14a.53.53 0 0 1-.771.56l-4.618-2.428a2.122 2.122 0 0 0-1.973 0L6.396 21.01a.53.53 0 0 1-.77-.56l.881-5.139a2.122 2.122 0 0 0-.611-1.879L2.16 9.795a.53.53 0 0 1 .294-.906l5.165-.755a2.122 2.122 0 0 0 1.597-1.16z",key:"r04s7s"}]]);var h=a.i(778784),i=a.i(392045),j=a.i(830284),k=a.i(947218),l=a.i(227444);let m=[{type:"linear",label:"Linear"},{type:"jira",label:"Jira Cloud"}];function n(){return(0,b.jsxs)("div",{className:"flex flex-col items-center justify-center min-h-[calc(100vh-3.5rem)] gap-8 p-8 -mt-7 animate-pulse",children:[(0,b.jsxs)("div",{className:"space-y-3 text-center flex flex-col items-center",children:[(0,b.jsx)("div",{className:"h-7 w-56 rounded-lg bg-muted"}),(0,b.jsx)("div",{className:"h-4 w-80 rounded bg-muted"})]}),(0,b.jsx)("div",{className:"grid grid-cols-1 sm:grid-cols-2 gap-4 w-full max-w-lg",children:[0,1].map(a=>(0,b.jsxs)("div",{className:"flex flex-col items-center gap-4 p-8 rounded-xl border border-border",children:[(0,b.jsx)("div",{className:"h-16 w-16 rounded-xl bg-muted"}),(0,b.jsxs)("div",{className:"flex flex-col items-center gap-2",children:[(0,b.jsx)("div",{className:"h-4 w-20 rounded bg-muted"}),(0,b.jsx)("div",{className:"h-3 w-24 rounded bg-muted"})]})]},a))})]})}function o(){return(0,b.jsxs)("div",{className:"flex flex-col items-center gap-6 p-8 animate-pulse",children:[(0,b.jsx)("div",{className:"h-16 w-16 rounded-xl bg-muted"}),(0,b.jsxs)("div",{className:"flex flex-col items-center gap-2 w-full max-w-sm",children:[(0,b.jsx)("div",{className:"h-5 w-40 rounded bg-muted"}),(0,b.jsx)("div",{className:"h-3 w-72 rounded bg-muted"}),(0,b.jsx)("div",{className:"h-3 w-56 rounded bg-muted"})]}),(0,b.jsxs)("div",{className:"flex flex-col gap-3 w-full max-w-xs pt-2",children:[(0,b.jsx)("div",{className:"h-10 w-full rounded-lg bg-muted"}),(0,b.jsx)("div",{className:"h-8 w-full rounded-lg bg-muted/60"})]})]})}function p({params:a}){let{slug:p}=(0,c.use)(a),{projects:q}=(0,j.useProjects)(),r=q.find(a=>a.slug===p),s=r?.id??"",{connections:t,defaultTracker:u,loading:v,removeConnection:w,setDefaultTracker:x}=(0,l.useTrackerConnections)(s),y=new Set(t.filter(a=>a.connected).map(a=>a.type)),z=y.size,[A,B]=(0,c.useState)(null),{connected:C,loading:D,connect:E,connectWithKey:F,disconnect:G,clis:H,mcpConfigured:I,configureMcp:J}=(0,k.useTrackerConnection)(A??"linear",s);return(0,b.jsx)("div",{className:"flex flex-col h-full bg-background",children:(0,b.jsx)("main",{className:"flex-1 overflow-auto",children:A?(0,b.jsx)("div",{className:"flex flex-col items-center px-6 py-12",children:(0,b.jsxs)("div",{className:"w-full max-w-2xl",children:[(0,b.jsxs)("button",{onClick:()=>B(null),className:"group flex items-center gap-2 text-sm text-muted-foreground hover:text-foreground mb-8 transition-colors",children:[(0,b.jsx)(d.ArrowLeft,{className:"h-3 w-3 transition-transform group-hover:-translate-x-0.5"}),"Back to tracker picker"]}),(0,b.jsxs)("div",{className:"bg-card border rounded-xl shadow-sm overflow-hidden",children:[(0,b.jsx)("div",{className:"px-6 pt-8 pb-1 text-center",children:(0,b.jsxs)("h2",{className:"text-2xl font-semibold tracking-tight",children:["Connect ",m.find(a=>a.type===A)?.label??A]})}),D?(0,b.jsx)(o,{}):(0,b.jsx)(h.default,{projectId:s,trackerType:A,connected:C,loading:!1,onConnect:E,onConnectWithKey:F,onDisconnect:()=>{G(),B(null)},clis:H,mcpConfigured:I,onConfigureMcp:J})]})]})}):v?(0,b.jsx)(n,{}):(0,b.jsxs)("div",{className:"flex flex-col items-center justify-center min-h-[calc(100vh-3.5rem)] gap-8 p-8 -mt-7",children:[(0,b.jsxs)("div",{className:"space-y-2 text-center",children:[(0,b.jsx)("h2",{className:"text-2xl font-bold tracking-tight",children:"Connect Issue Tracker"}),(0,b.jsx)("p",{className:"text-muted-foreground max-w-md mx-auto",children:"Choose an issue tracker to connect to this project to enable issue tracking and agent workflows."})]}),(0,b.jsx)("div",{className:"grid grid-cols-1 sm:grid-cols-2 gap-4 w-full max-w-lg",children:m.map(a=>{let c=y.has(a.type),d=u===a.type,h=c&&z>1&&!d;return(0,b.jsxs)("div",{className:"relative flex flex-col items-center gap-4 p-8 rounded-xl border transition-all duration-200 group "+(c?d?"border-yellow-500/40 bg-yellow-500/5":"border-green-500/20 bg-green-500/5":"border-border hover:border-primary/50 hover:bg-accent/50 hover:shadow-md cursor-pointer active:scale-[0.98]"),onClick:()=>!c&&B(a.type),children:[(0,b.jsxs)("div",{className:"relative",children:[(0,b.jsx)(i.TrackerIcon,{trackerType:a.type,className:"h-16 w-16 transition-transform group-hover:scale-105"}),c&&(0,b.jsx)("div",{className:"absolute -top-1 -right-1 h-6 w-6 rounded-full bg-green-500 border-2 border-background flex items-center justify-center text-white shadow-sm",children:(0,b.jsx)(e.CheckCircle2,{className:"h-4 w-4"})})]}),(0,b.jsxs)("div",{className:"flex flex-col items-center gap-1",children:[(0,b.jsx)("span",{className:"text-base font-semibold",children:a.label}),c?(0,b.jsxs)("span",{className:"inline-flex items-center gap-1 text-xs font-medium text-green-600",children:["Connected",d&&(0,b.jsxs)("span",{className:"inline-flex items-center gap-0.5 rounded-full bg-yellow-500/10 px-1.5 py-0.5 text-[10px] font-semibold uppercase tracking-wide text-yellow-700",children:[(0,b.jsx)(g,{className:"h-3 w-3 fill-yellow-500 text-yellow-500"}),"Default"]})]}):(0,b.jsx)("span",{className:"text-xs text-muted-foreground",children:"Click to connect"})]}),c&&(0,b.jsxs)("div",{className:"flex flex-col items-center gap-1.5",children:[h&&(0,b.jsxs)("button",{onClick:b=>{b.stopPropagation(),x(a.type)},className:"flex items-center gap-1.5 text-xs text-muted-foreground hover:text-foreground transition-colors",children:[(0,b.jsx)(g,{className:"h-3.5 w-3.5"}),"Set as default"]}),(0,b.jsxs)("button",{onClick:b=>{b.stopPropagation(),w(a.type)},className:"flex items-center gap-1.5 text-xs text-muted-foreground hover:text-destructive transition-colors",children:[(0,b.jsx)(f.LogOut,{className:"h-3.5 w-3.5"}),"Disconnect"]})]})]},a.type)})})]})})})}a.s(["default",()=>p],742557)}];
2
2
 
3
3
  //# sourceMappingURL=apps_local_5eebb5cb._.js.map