@agent-deck/backend 1.8.1 → 1.9.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (182) hide show
  1. package/dist/.tsbuildinfo +1 -1
  2. package/dist/cli-runtime.d.ts.map +1 -1
  3. package/dist/cli-runtime.js +5 -5
  4. package/dist/cli-runtime.js.map +1 -1
  5. package/dist/config/mcp-endpoint.d.ts +6 -0
  6. package/dist/config/mcp-endpoint.d.ts.map +1 -0
  7. package/dist/config/mcp-endpoint.js +19 -0
  8. package/dist/config/mcp-endpoint.js.map +1 -0
  9. package/dist/export-import/import-bundle.d.ts +12 -1
  10. package/dist/export-import/import-bundle.d.ts.map +1 -1
  11. package/dist/export-import/import-bundle.js +11 -3
  12. package/dist/export-import/import-bundle.js.map +1 -1
  13. package/dist/lib/agent-deck-context.d.ts +1 -1
  14. package/dist/lib/agent-deck-context.d.ts.map +1 -1
  15. package/dist/lib/agent-deck-context.js +4 -17
  16. package/dist/lib/agent-deck-context.js.map +1 -1
  17. package/dist/lib/backend-api-error.d.ts.map +1 -1
  18. package/dist/lib/backend-api-error.js +0 -1
  19. package/dist/lib/backend-api-error.js.map +1 -1
  20. package/dist/lib/bound-deck-scope.d.ts.map +1 -1
  21. package/dist/lib/bound-deck-scope.js +0 -4
  22. package/dist/lib/bound-deck-scope.js.map +1 -1
  23. package/dist/lib/http-auth.d.ts +0 -14
  24. package/dist/lib/http-auth.d.ts.map +1 -1
  25. package/dist/lib/http-auth.js +0 -25
  26. package/dist/lib/http-auth.js.map +1 -1
  27. package/dist/lib/invalid-deck-id-path-segment.d.ts +6 -0
  28. package/dist/lib/invalid-deck-id-path-segment.d.ts.map +1 -0
  29. package/dist/lib/invalid-deck-id-path-segment.js +11 -0
  30. package/dist/lib/invalid-deck-id-path-segment.js.map +1 -0
  31. package/dist/lib/route-policy.js +2 -2
  32. package/dist/lib/route-policy.js.map +1 -1
  33. package/dist/mcp-server.d.ts +11 -13
  34. package/dist/mcp-server.d.ts.map +1 -1
  35. package/dist/mcp-server.js +124 -161
  36. package/dist/mcp-server.js.map +1 -1
  37. package/dist/mcp-session-binding.d.ts +7 -15
  38. package/dist/mcp-session-binding.d.ts.map +1 -1
  39. package/dist/mcp-session-binding.js +14 -30
  40. package/dist/mcp-session-binding.js.map +1 -1
  41. package/dist/mcp-tools/policy.d.ts +0 -3
  42. package/dist/mcp-tools/policy.d.ts.map +1 -1
  43. package/dist/mcp-tools/policy.js +6 -43
  44. package/dist/mcp-tools/policy.js.map +1 -1
  45. package/dist/mcp-tools/register.d.ts +1 -5
  46. package/dist/mcp-tools/register.d.ts.map +1 -1
  47. package/dist/mcp-tools/register.js +100 -104
  48. package/dist/mcp-tools/register.js.map +1 -1
  49. package/dist/mcp-tools/test-harness.d.ts +22 -5
  50. package/dist/mcp-tools/test-harness.d.ts.map +1 -1
  51. package/dist/mcp-tools/test-harness.js +64 -23
  52. package/dist/mcp-tools/test-harness.js.map +1 -1
  53. package/dist/models/database.d.ts +2 -0
  54. package/dist/models/database.d.ts.map +1 -1
  55. package/dist/models/database.js +16 -0
  56. package/dist/models/database.js.map +1 -1
  57. package/dist/playbooks/playbook-manager.d.ts.map +1 -1
  58. package/dist/playbooks/playbook-manager.js +9 -4
  59. package/dist/playbooks/playbook-manager.js.map +1 -1
  60. package/dist/playbooks/stub-sync.d.ts +9 -0
  61. package/dist/playbooks/stub-sync.d.ts.map +1 -1
  62. package/dist/playbooks/stub-sync.js +51 -12
  63. package/dist/playbooks/stub-sync.js.map +1 -1
  64. package/dist/routes/decks.d.ts.map +1 -1
  65. package/dist/routes/decks.js +8 -52
  66. package/dist/routes/decks.js.map +1 -1
  67. package/dist/routes/export-import.d.ts.map +1 -1
  68. package/dist/routes/export-import.js +3 -5
  69. package/dist/routes/export-import.js.map +1 -1
  70. package/dist/routes/launch.d.ts +8 -0
  71. package/dist/routes/launch.d.ts.map +1 -0
  72. package/dist/routes/launch.js +35 -0
  73. package/dist/routes/launch.js.map +1 -0
  74. package/dist/routes/scope.d.ts.map +1 -1
  75. package/dist/routes/scope.js +1 -39
  76. package/dist/routes/scope.js.map +1 -1
  77. package/dist/routes/services.d.ts.map +1 -1
  78. package/dist/routes/services.js +1 -7
  79. package/dist/routes/services.js.map +1 -1
  80. package/dist/routes/trusted-session.d.ts.map +1 -1
  81. package/dist/routes/trusted-session.js +50 -152
  82. package/dist/routes/trusted-session.js.map +1 -1
  83. package/dist/scope/live-display-registry.d.ts +0 -2
  84. package/dist/scope/live-display-registry.d.ts.map +1 -1
  85. package/dist/scope/live-display-registry.js +0 -1
  86. package/dist/scope/live-display-registry.js.map +1 -1
  87. package/dist/server/index.d.ts +0 -2
  88. package/dist/server/index.d.ts.map +1 -1
  89. package/dist/server/index.js +2 -5
  90. package/dist/server/index.js.map +1 -1
  91. package/dist/services/service-manager.d.ts +5 -1
  92. package/dist/services/service-manager.d.ts.map +1 -1
  93. package/dist/services/service-manager.js +27 -3
  94. package/dist/services/service-manager.js.map +1 -1
  95. package/dist/store/deck-file.d.ts +55 -0
  96. package/dist/store/deck-file.d.ts.map +1 -0
  97. package/dist/store/deck-file.js +163 -0
  98. package/dist/store/deck-file.js.map +1 -0
  99. package/dist/store/index.d.ts +1 -0
  100. package/dist/store/index.d.ts.map +1 -1
  101. package/dist/store/index.js +1 -0
  102. package/dist/store/index.js.map +1 -1
  103. package/dist/store/migrate.d.ts.map +1 -1
  104. package/dist/store/migrate.js +2 -12
  105. package/dist/store/migrate.js.map +1 -1
  106. package/dist/test/auth-fixtures.d.ts +1 -1
  107. package/dist/test/auth-fixtures.d.ts.map +1 -1
  108. package/dist/test/auth-fixtures.js +2 -11
  109. package/dist/test/auth-fixtures.js.map +1 -1
  110. package/dist/trusted-session/auth.d.ts +1 -7
  111. package/dist/trusted-session/auth.d.ts.map +1 -1
  112. package/dist/trusted-session/auth.js +7 -54
  113. package/dist/trusted-session/auth.js.map +1 -1
  114. package/dist/trusted-session/policy-hook.d.ts.map +1 -1
  115. package/dist/trusted-session/policy-hook.js +1 -51
  116. package/dist/trusted-session/policy-hook.js.map +1 -1
  117. package/dist/trusted-session/route-policy-registry.d.ts.map +1 -1
  118. package/dist/trusted-session/route-policy-registry.js +5 -56
  119. package/dist/trusted-session/route-policy-registry.js.map +1 -1
  120. package/dist/trusted-session/store.d.ts +12 -45
  121. package/dist/trusted-session/store.d.ts.map +1 -1
  122. package/dist/trusted-session/store.js +66 -208
  123. package/dist/trusted-session/store.js.map +1 -1
  124. package/dist/vault/credential-manager.d.ts +6 -2
  125. package/dist/vault/credential-manager.d.ts.map +1 -1
  126. package/dist/vault/credential-manager.js +21 -14
  127. package/dist/vault/credential-manager.js.map +1 -1
  128. package/package.json +2 -2
  129. package/static-ui/assets/{index-DhP_UPyM.js → index-Bb9ckehB.js} +1 -1
  130. package/static-ui/index.html +1 -1
  131. package/dist/execution-authority/bearer.d.ts +0 -15
  132. package/dist/execution-authority/bearer.d.ts.map +0 -1
  133. package/dist/execution-authority/bearer.js +0 -35
  134. package/dist/execution-authority/bearer.js.map +0 -1
  135. package/dist/execution-authority/index.d.ts +0 -6
  136. package/dist/execution-authority/index.d.ts.map +0 -1
  137. package/dist/execution-authority/index.js +0 -8
  138. package/dist/execution-authority/index.js.map +0 -1
  139. package/dist/execution-authority/ledger.d.ts +0 -85
  140. package/dist/execution-authority/ledger.d.ts.map +0 -1
  141. package/dist/execution-authority/ledger.js +0 -507
  142. package/dist/execution-authority/ledger.js.map +0 -1
  143. package/dist/execution-authority/store.d.ts +0 -55
  144. package/dist/execution-authority/store.d.ts.map +0 -1
  145. package/dist/execution-authority/store.js +0 -256
  146. package/dist/execution-authority/store.js.map +0 -1
  147. package/dist/execution-authority/types.d.ts +0 -119
  148. package/dist/execution-authority/types.d.ts.map +0 -1
  149. package/dist/execution-authority/types.js +0 -9
  150. package/dist/execution-authority/types.js.map +0 -1
  151. package/dist/lib/execution-authority-http.d.ts +0 -23
  152. package/dist/lib/execution-authority-http.d.ts.map +0 -1
  153. package/dist/lib/execution-authority-http.js +0 -101
  154. package/dist/lib/execution-authority-http.js.map +0 -1
  155. package/dist/mcp-stdio.d.ts +0 -2
  156. package/dist/mcp-stdio.d.ts.map +0 -1
  157. package/dist/mcp-stdio.js.map +0 -1
  158. package/dist/playbooks/playbook-parser.d.ts +0 -8
  159. package/dist/playbooks/playbook-parser.d.ts.map +0 -1
  160. package/dist/playbooks/playbook-parser.js +0 -76
  161. package/dist/playbooks/playbook-parser.js.map +0 -1
  162. package/dist/playbooks/playbook-service.d.ts +0 -9
  163. package/dist/playbooks/playbook-service.d.ts.map +0 -1
  164. package/dist/playbooks/playbook-service.js +0 -107
  165. package/dist/playbooks/playbook-service.js.map +0 -1
  166. package/dist/routes/execution-authority.d.ts +0 -8
  167. package/dist/routes/execution-authority.d.ts.map +0 -1
  168. package/dist/routes/execution-authority.js +0 -506
  169. package/dist/routes/execution-authority.js.map +0 -1
  170. package/dist/scope/bindings-sidecar.d.ts +0 -9
  171. package/dist/scope/bindings-sidecar.d.ts.map +0 -1
  172. package/dist/scope/bindings-sidecar.js +0 -57
  173. package/dist/scope/bindings-sidecar.js.map +0 -1
  174. package/dist/scope/repo-deck.d.ts +0 -10
  175. package/dist/scope/repo-deck.d.ts.map +0 -1
  176. package/dist/scope/repo-deck.js +0 -63
  177. package/dist/scope/repo-deck.js.map +0 -1
  178. package/dist/test-local-mcp-e2e.d.ts +0 -3
  179. package/dist/test-local-mcp-e2e.d.ts.map +0 -1
  180. package/dist/test-local-mcp-e2e.js +0 -104
  181. package/dist/test-local-mcp-e2e.js.map +0 -1
  182. package/static-ui/favicon.png +0 -0
@@ -232,4 +232,4 @@ ${F.data.oauth.issuer?`Issuer: ${F.data.oauth.issuer}`:``}`;A({title:`OAuth Setu
232
232
  `));let n=[],r=e.split(/(\n|\r\n)/);r[r.length-1]||r.pop();for(let e=0;e<r.length;e++){let i=r[e];e%2&&!t.newlineIsToken?n[n.length-1]+=i:n.push(i)}return n}function $V(e){return e==`.`||e==`!`||e==`?`}new class extends PV{tokenize(e){let t=[],n=0;for(let r=0;r<e.length;r++){if(r==e.length-1){t.push(e.slice(n));break}if($V(e[r])&&e[r+1].match(/\s/)){for(t.push(e.slice(n,r+1)),r=n=r+1;e[r+1]?.match(/\s/);)r++;t.push(e.slice(n,r+1)),n=r+1}}return t}},new class extends PV{tokenize(e){return e.split(/([{}:;,]|\s+)/)}},new class extends PV{constructor(){super(...arguments),this.tokenize=QV}get useLongestToken(){return!0}castInput(e,t){let{undefinedReplacement:n,stringifyReplacer:r=(e,t)=>t===void 0?n:t}=t;return typeof e==`string`?e:JSON.stringify(eH(e,null,null,r),null,` `)}equals(e,t,n){return super.equals(e.replace(/,([\r\n])/g,`$1`),t.replace(/,([\r\n])/g,`$1`),n)}};function eH(e,t,n,r,i){t||=[],n||=[],r&&(e=r(i===void 0?``:i,e));let a=0;for(;a<t.length;a+=1)if(t[a]===e)return n[a];let o;if(Object.prototype.toString.call(e)===`[object Array]`){for(t.push(e),o=Array(e.length),n.push(o),a=0;a<e.length;a+=1)o[a]=eH(e[a],t,n,r,String(a));return t.pop(),n.pop(),o}if(e&&e.toJSON&&(e=e.toJSON()),typeof e==`object`&&e){t.push(e),o={},n.push(o);let i=[],s;for(s in e)Object.prototype.hasOwnProperty.call(e,s)&&i.push(s);for(i.sort(),a=0;a<i.length;a+=1)s=i[a],o[s]=eH(e[s],t,n,r,s);t.pop(),n.pop()}else o=e;return o}new class extends PV{tokenize(e){return e.slice()}join(e){return e}removeEmpty(e){return e}};var tH=3,nH=10;function rH(e){return e===``?[]:e.replace(/\n$/,``).split(`
233
233
  `)}function iH(e,t){let n=ZV(e,t),r=[],i=1,a=1;for(let e of n){let t=rH(e.value);if(!e.added&&!e.removed&&t.length>=nH){let e=t.slice(0,tH),n=t.slice(-3),o=t.length-6;for(let t of e)r.push({kind:`unchanged`,text:t,oldLine:i++,newLine:a++});o>0&&(r.push({kind:`ellipsis`,text:`${o} unchanged lines`}),i+=o,a+=o);for(let e of n)r.push({kind:`unchanged`,text:e,oldLine:i++,newLine:a++});continue}for(let n of t)e.added?r.push({kind:`added`,text:n,newLine:a++}):e.removed?r.push({kind:`removed`,text:n,oldLine:i++}):r.push({kind:`unchanged`,text:n,oldLine:i++,newLine:a++})}return r}function aH(e){return e.some(e=>e.kind===`added`||e.kind===`removed`)}var oH=`max-w-full overflow-x-auto rounded-md border border-gray-800 bg-gray-950 font-mono text-xs leading-5`;function sH(e){switch(e){case`added`:return`bg-emerald-950/70 text-emerald-100`;case`removed`:return`bg-rose-950/70 text-rose-100`;case`ellipsis`:return`bg-gray-900 text-gray-500 italic`;default:return`bg-gray-950 text-gray-300`}}function cH(e){switch(e){case`added`:return`+`;case`removed`:return`-`;case`ellipsis`:return`…`;default:return` `}}function lH({rows:e,emptyLabel:t}){return e.length===0?(0,V.jsx)(`p`,{className:`text-sm text-gray-500`,children:t}):(0,V.jsx)(`div`,{className:oH,children:e.map((e,t)=>(0,V.jsxs)(`div`,{className:`grid min-w-0 grid-cols-[3rem_3rem_minmax(0,1fr)] gap-0 ${sH(e.kind)}`,children:[(0,V.jsx)(`span`,{className:`select-none border-r border-gray-800/80 px-2 py-0.5 text-right text-gray-600`,children:e.oldLine??``}),(0,V.jsx)(`span`,{className:`select-none border-r border-gray-800/80 px-2 py-0.5 text-right text-gray-600`,children:e.newLine??``}),(0,V.jsxs)(`div`,{className:`flex min-w-0 gap-2 px-2 py-0.5`,children:[(0,V.jsx)(`span`,{className:`w-3 shrink-0 select-none text-gray-500`,children:cH(e.kind)}),(0,V.jsx)(`span`,{className:`min-w-0 whitespace-pre-wrap break-words`,children:e.text||` `})]})]},`${e.kind}-${t}-${e.oldLine??``}-${e.newLine??``}`))})}function uH({before:e,after:t}){let n=e.filter(e=>!t.includes(e)),r=t.filter(t=>!e.includes(t));return n.length===0&&r.length===0?null:(0,V.jsxs)(`div`,{className:`space-y-2`,children:[(0,V.jsx)(`h4`,{className:`text-sm font-medium text-gray-400`,children:`Triggers`}),(0,V.jsxs)(`div`,{className:`${oH} p-0`,children:[n.map(e=>(0,V.jsxs)(`div`,{className:`grid min-w-0 grid-cols-[3rem_3rem_minmax(0,1fr)] bg-rose-950/70 text-rose-100`,children:[(0,V.jsx)(`span`,{className:`border-r border-gray-800/80 px-2 py-0.5`}),(0,V.jsx)(`span`,{className:`border-r border-gray-800/80 px-2 py-0.5`}),(0,V.jsxs)(`div`,{className:`flex gap-2 px-2 py-0.5`,children:[(0,V.jsx)(`span`,{className:`w-3 shrink-0 text-gray-500`,children:`-`}),(0,V.jsx)(`span`,{children:e})]})]},`removed-${e}`)),r.map(e=>(0,V.jsxs)(`div`,{className:`grid min-w-0 grid-cols-[3rem_3rem_minmax(0,1fr)] bg-emerald-950/70 text-emerald-100`,children:[(0,V.jsx)(`span`,{className:`border-r border-gray-800/80 px-2 py-0.5`}),(0,V.jsx)(`span`,{className:`border-r border-gray-800/80 px-2 py-0.5`}),(0,V.jsxs)(`div`,{className:`flex gap-2 px-2 py-0.5`,children:[(0,V.jsx)(`span`,{className:`w-3 shrink-0 text-gray-500`,children:`+`}),(0,V.jsx)(`span`,{children:e})]})]},`added-${e}`))]})]})}function dH({preview:e}){let t=NV(e),n=iH(e.before.body,e.after.body),r=e.before.body.trim()!==e.after.body.trim()&&e.after.body.length>0&&!e.after.body.includes(e.before.body.slice(0,40))&&aH(n),i=e.before.title!==e.after.title,a=e.before.triggers.join(`
234
234
  `)!==e.after.triggers.join(`
235
- `);return(0,V.jsxs)(`div`,{className:`min-w-0 space-y-4`,children:[!t&&(0,V.jsxs)(`div`,{className:`rounded-md border border-amber-500/50 bg-amber-500/10 p-3 text-sm text-amber-100`,children:[`No change detected — ops did not alter the playbook body or triggers. Reject this proposal and re-propose with a matching list anchor or `,(0,V.jsx)(`code`,{children:`rewrite_body`}),`.`]}),r&&(0,V.jsx)(`div`,{className:`rounded-md border border-amber-500/50 bg-amber-500/10 p-3 text-sm text-amber-100`,children:`Full-body rewrite proposed — review carefully.`}),i&&(0,V.jsxs)(`div`,{className:`space-y-2`,children:[(0,V.jsx)(`h4`,{className:`text-sm font-medium text-gray-400`,children:`Title`}),(0,V.jsxs)(`div`,{className:`${oH} p-0`,children:[e.before.title&&(0,V.jsxs)(`div`,{className:`grid min-w-0 grid-cols-[3rem_3rem_minmax(0,1fr)] bg-rose-950/70 text-rose-100`,children:[(0,V.jsx)(`span`,{className:`border-r border-gray-800/80 px-2 py-0.5`}),(0,V.jsx)(`span`,{className:`border-r border-gray-800/80 px-2 py-0.5`}),(0,V.jsxs)(`div`,{className:`flex gap-2 px-2 py-0.5`,children:[(0,V.jsx)(`span`,{className:`w-3 shrink-0 text-gray-500`,children:`-`}),(0,V.jsx)(`span`,{children:e.before.title})]})]}),e.after.title&&(0,V.jsxs)(`div`,{className:`grid min-w-0 grid-cols-[3rem_3rem_minmax(0,1fr)] bg-emerald-950/70 text-emerald-100`,children:[(0,V.jsx)(`span`,{className:`border-r border-gray-800/80 px-2 py-0.5`}),(0,V.jsx)(`span`,{className:`border-r border-gray-800/80 px-2 py-0.5`}),(0,V.jsxs)(`div`,{className:`flex gap-2 px-2 py-0.5`,children:[(0,V.jsx)(`span`,{className:`w-3 shrink-0 text-gray-500`,children:`+`}),(0,V.jsx)(`span`,{children:e.after.title})]})]})]})]}),(0,V.jsxs)(`div`,{className:`space-y-2`,children:[(0,V.jsx)(`h4`,{className:`text-sm font-medium text-gray-400`,children:`Body`}),(0,V.jsx)(lH,{rows:n,emptyLabel:`No body changes.`})]}),a&&(0,V.jsx)(uH,{before:e.before.triggers,after:e.after.triggers})]})}function fH(e){if(!e)return[];try{return JSON.parse(e)}catch{return[]}}function pH({conflicts:e,title:t=`Trigger overlap warnings`}){return e.length===0?null:(0,V.jsxs)(`div`,{className:`rounded-md border border-amber-500/40 bg-amber-500/10 p-4 text-sm text-amber-50`,children:[(0,V.jsx)(`p`,{className:`text-xs font-medium uppercase tracking-wide text-amber-200/90`,children:t}),(0,V.jsx)(`p`,{className:`mt-2 text-amber-100/90`,children:`These triggers overlap with other playbooks on the deck. Accept is still allowed — disambiguate triggers or propose a merge if the wrong playbook keeps firing.`}),(0,V.jsx)(`ul`,{className:`mt-3 space-y-2`,children:e.map(e=>(0,V.jsxs)(`li`,{className:`rounded border border-amber-500/20 bg-gray-950/60 p-3`,children:[(0,V.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,V.jsx)(jh,{variant:`outline`,className:`border-amber-400/40 text-amber-100`,children:e.level}),(0,V.jsx)(`span`,{className:`font-medium text-amber-50`,children:e.otherPlaybookTitle}),(0,V.jsx)(`span`,{className:`font-mono text-xs text-amber-200/70`,children:e.otherPlaybookId})]}),(0,V.jsxs)(`p`,{className:`mt-2 text-amber-100/90`,children:[(0,V.jsx)(`span`,{className:`text-amber-200/80`,children:`Candidate:`}),` `,e.trigger]}),(0,V.jsxs)(`p`,{className:`text-amber-100/80`,children:[(0,V.jsx)(`span`,{className:`text-amber-200/80`,children:`Other:`}),` `,e.otherTrigger]})]},`${e.trigger}-${e.otherPlaybookId}-${e.level}`))})]})}var mH=8,hH=[{value:`proposed`,label:`Waiting`},{value:`accepted`,label:`Accepted`},{value:`rejected`,label:`Rejected`},{value:`superseded`,label:`Superseded`},{value:`stale`,label:`Stale`},{value:`all`,label:`All`}];function gH(e){if(!e.evidenceJson)return null;try{return JSON.parse(e.evidenceJson)}catch{return null}}function _H(e){switch(e){case`proposed`:return`border-blue-500/40 text-blue-200`;case`accepted`:return`border-emerald-500/40 text-emerald-200`;case`rejected`:return`border-rose-500/40 text-rose-200`;case`superseded`:return`border-violet-500/40 text-violet-200`;case`stale`:return`border-amber-500/40 text-amber-200`}}function vH(){let[e,t]=(0,b.useState)(null),[n,r]=(0,b.useState)(`proposed`),[i,a]=(0,b.useState)(0),{toast:o}=on(),s=Et();function c(e){t(e)}function l(e){r(e),a(0),t(null)}let{data:u=[]}=Vt({queryKey:[`/api/playbook-patches`,`proposed`],queryFn:()=>hh(`proposed`)}),d=n===`all`?void 0:n,{data:f=[],isLoading:p}=Vt({queryKey:[`/api/playbook-patches`,n],queryFn:()=>hh(d)}),m=Math.max(1,Math.ceil(f.length/mH)),h=Math.min(i,m-1),g=(0,b.useMemo)(()=>{let e=h*mH;return f.slice(e,e+mH)},[f,h]);(0,b.useEffect)(()=>{i!==h&&a(h)},[i,h]);let{data:_,isLoading:v,isError:y,error:x}=Vt({queryKey:[`/api/playbook-patches`,e,`preview`],queryFn:()=>gh(e),enabled:!!e}),S=_?NV(_):!1,C=f.find(t=>t.id===e)??null,w=C?.status===`proposed`,T=Ht({mutationFn:e=>_h(e),onSuccess:()=>{o({title:`Patch accepted`}),t(null),s.invalidateQueries({queryKey:[`/api/playbook-patches`]}),s.invalidateQueries({queryKey:[`/api/playbooks`]}),s.invalidateQueries({queryKey:[`/api/feedback-signals`]})},onError:e=>{o({title:`Accept failed`,description:e.message,variant:`destructive`})}}),E=Ht({mutationFn:e=>vh(e),onSuccess:()=>{o({title:`Patch rejected`}),t(null),s.invalidateQueries({queryKey:[`/api/playbook-patches`]}),s.invalidateQueries({queryKey:[`/api/feedback-signals`]})},onError:e=>{o({title:`Reject failed`,description:e.message,variant:`destructive`})}}),D=n===`proposed`?`No proposals waiting for review.`:n===`all`?`No playbook patches yet.`:`No ${n} patches.`;return(0,V.jsxs)(`div`,{className:`flex h-dvh flex-col overflow-hidden bg-gray-950 text-gray-100`,children:[(0,V.jsx)(`header`,{className:`shrink-0 border-b border-gray-800 px-4 py-4 sm:px-6`,children:(0,V.jsxs)(`div`,{className:`mx-auto flex max-w-7xl flex-wrap items-center gap-3`,children:[(0,V.jsx)(ye,{href:`/`,children:(0,V.jsxs)(G,{variant:`ghost`,size:`sm`,className:`text-gray-300`,children:[(0,V.jsx)(li,{className:`mr-1 h-4 w-4`}),`Deck`]})}),(0,V.jsx)(`h1`,{className:`text-lg font-semibold`,children:`Playbook review queue`}),(0,V.jsxs)(jh,{variant:`secondary`,children:[u.length,` waiting`]}),(0,V.jsx)(ye,{href:`/feedback-signals`,className:`ml-auto text-sm hover:underline`,style:{color:`#92E4DD`},children:`Feedback data →`})]})}),(0,V.jsxs)(`main`,{className:`mx-auto grid w-full max-w-7xl min-h-0 flex-1 gap-6 overflow-hidden px-4 py-6 sm:px-6 lg:grid-cols-[minmax(18rem,20rem)_minmax(0,1fr)] lg:items-stretch`,children:[(0,V.jsxs)(`section`,{className:`flex min-h-0 min-w-0 flex-col`,children:[(0,V.jsx)(`h2`,{className:`mb-3 shrink-0 text-sm font-medium text-gray-400`,children:`Proposals`}),(0,V.jsx)(`div`,{className:`mb-3 flex shrink-0 flex-wrap gap-1`,children:hH.map(({value:e,label:t})=>{let r=n===e;return(0,V.jsx)(G,{size:`sm`,variant:r?`gold`:`outline`,className:r?void 0:`border-gray-600 bg-transparent text-gray-300 hover:bg-gray-800 hover:text-gray-100`,"aria-pressed":r,onClick:()=>l(e),children:t},e)})}),(0,V.jsxs)(`div`,{className:`min-h-0 flex-1 overflow-y-auto`,children:[p&&(0,V.jsx)(`p`,{className:`text-sm text-gray-500`,children:`Loading…`}),!p&&f.length===0&&(0,V.jsx)(`p`,{className:`text-sm text-gray-500`,children:D}),(0,V.jsx)(`ul`,{className:`space-y-2`,children:g.map(t=>(0,V.jsx)(`li`,{children:(0,V.jsxs)(`button`,{type:`button`,onClick:()=>c(t.id),className:`w-full rounded-lg border p-3 text-left transition ${e===t.id?`border-blue-500 bg-gray-900`:`border-gray-800 bg-gray-900/50 hover:border-gray-700`}`,children:[(0,V.jsxs)(`div`,{className:`flex items-start justify-between gap-2`,children:[(0,V.jsxs)(`div`,{className:`min-w-0`,children:[(0,V.jsx)(`span`,{className:`block font-medium leading-snug`,children:t.kind===`create`?`New: ${t.displayTitle}`:t.displayTitle}),t.playbookId&&t.kind!==`create`&&(0,V.jsx)(`span`,{className:`mt-0.5 block truncate font-mono text-xs text-gray-600`,children:t.playbookId}),mh(t.deckNames)&&(0,V.jsxs)(`span`,{className:`mt-1 block text-xs text-gray-500`,children:[`Decks: `,mh(t.deckNames)]})]}),(0,V.jsxs)(`div`,{className:`flex shrink-0 flex-col items-end gap-1`,children:[(0,V.jsx)(jh,{variant:`outline`,className:`shrink-0`,children:t.kind}),n!==`proposed`&&(0,V.jsx)(jh,{variant:`outline`,className:`shrink-0 ${_H(t.status)}`,children:t.status})]})]}),(0,V.jsx)(`p`,{className:`mt-1 line-clamp-2 text-sm text-gray-400`,children:t.rationale}),(0,V.jsxs)(`p`,{className:`mt-1 text-xs text-gray-600`,children:[t.source,` · `,new Date(t.createdAt).toLocaleString()]})]})},t.id))})]}),f.length>mH&&(0,V.jsxs)(`div`,{className:`mt-3 flex shrink-0 items-center justify-between gap-2 border-t border-gray-800 pt-3`,children:[(0,V.jsxs)(G,{type:`button`,size:`sm`,variant:`outline`,className:`border-gray-600 bg-transparent text-gray-300 hover:bg-gray-800`,disabled:h<=0,onClick:()=>a(e=>Math.max(0,e-1)),children:[(0,V.jsx)(gi,{className:`mr-1 h-4 w-4`}),`Newer`]}),(0,V.jsxs)(`span`,{className:`text-xs text-gray-500`,children:[h+1,` / `,m,(0,V.jsxs)(`span`,{className:`ml-1 text-gray-600`,children:[`(`,f.length,`)`]})]}),(0,V.jsxs)(G,{type:`button`,size:`sm`,variant:`outline`,className:`border-gray-600 bg-transparent text-gray-300 hover:bg-gray-800`,disabled:h>=m-1,onClick:()=>a(e=>Math.min(m-1,e+1)),children:[`Older`,(0,V.jsx)(_i,{className:`ml-1 h-4 w-4`})]})]})]}),(0,V.jsxs)(`section`,{className:`flex min-h-0 min-w-0 flex-col overflow-hidden`,children:[(0,V.jsx)(`h2`,{className:`mb-3 shrink-0 text-sm font-medium text-gray-400`,children:`Detail`}),!C&&(0,V.jsx)(`p`,{className:`text-sm text-gray-500`,children:`Select a proposal to preview the diff.`}),C&&(0,V.jsxs)(`div`,{className:`flex min-h-0 flex-1 flex-col overflow-hidden rounded-lg border border-gray-800 bg-gray-900/50`,children:[(0,V.jsx)(`div`,{className:`min-h-0 flex-1 overflow-y-auto overscroll-contain p-4 sm:p-5`,children:(0,V.jsxs)(`div`,{className:`min-w-0 space-y-4`,children:[(0,V.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,V.jsx)(jh,{variant:`outline`,className:_H(C.status),children:C.status}),C.resolvedAt&&(0,V.jsxs)(`span`,{className:`text-xs text-gray-500`,children:[`Resolved `,new Date(C.resolvedAt).toLocaleString()]})]}),(0,V.jsx)(`p`,{className:`text-sm leading-relaxed text-gray-300`,children:C.rationale}),C.status===`rejected`&&C.rejectionReason&&(0,V.jsxs)(`div`,{className:`rounded-md border border-rose-500/40 bg-rose-500/10 p-3 text-sm text-rose-100`,children:[(0,V.jsx)(`p`,{className:`text-xs font-medium uppercase tracking-wide text-rose-300/80`,children:`Rejection reason`}),(0,V.jsx)(`p`,{className:`mt-1`,children:C.rejectionReason})]}),C.status===`superseded`&&C.supersededBy&&(0,V.jsxs)(`div`,{className:`rounded-md border border-violet-500/40 bg-violet-500/10 p-3 text-sm text-violet-100`,children:[(0,V.jsx)(`p`,{className:`text-xs font-medium uppercase tracking-wide text-violet-300/80`,children:`Superseded by`}),(0,V.jsx)(`button`,{type:`button`,className:`mt-1 font-mono text-sm underline-offset-2 hover:underline`,onClick:()=>{let e=C.supersededBy;r(`all`),a(0),c(e)},children:C.supersededBy})]}),(()=>{let e=gH(C);return e?(0,V.jsxs)(`div`,{className:`rounded-md border border-gray-700 bg-gray-950 p-4 text-sm`,children:[(0,V.jsx)(`p`,{className:`text-xs font-medium uppercase tracking-wide text-gray-500`,children:`Your correction`}),(0,V.jsxs)(`p`,{className:`mt-2 italic text-gray-200`,children:[`“`,e.user_feedback_excerpt,`”`]}),e.failure_summary&&(0,V.jsx)(`p`,{className:`mt-2 text-gray-400`,children:e.failure_summary})]}):null})(),(()=>{let e=fH(C.conflictsJson),t=_?.trigger_conflicts??[],n=t.length>0?t:e;return(0,V.jsx)(pH,{conflicts:n})})(),v&&(0,V.jsx)(`p`,{className:`text-sm text-gray-500`,children:`Loading preview…`}),y&&(0,V.jsxs)(`div`,{className:`rounded-md border border-rose-500/50 bg-rose-500/10 p-3 text-sm text-rose-100`,children:[`Preview failed —`,` `,x?.message??`could not apply ops to the current playbook.`,w?` Reject and re-propose with exact list anchors or rewrite_body.`:` Historical preview may be incomplete if the playbook changed.`]}),_&&(0,V.jsx)(dH,{preview:_}),C.status===`stale`&&(0,V.jsx)(`p`,{className:`text-sm text-amber-400`,children:`Stale — playbook changed since proposal. Re-propose from a fresh session.`})]})}),w?(0,V.jsxs)(`div`,{className:`relative z-10 shrink-0 space-y-3 border-t border-gray-800 bg-gray-950 p-4 shadow-[0_-16px_32px_rgba(0,0,0,0.55)] sm:p-5`,children:[(0,V.jsx)(`h3`,{className:`text-sm font-medium text-gray-400`,children:`Your decision`}),(0,V.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[(0,V.jsx)(G,{variant:`gold`,onClick:()=>T.mutate(C.id),disabled:T.isPending||y||!S,children:`Accept`}),(0,V.jsx)(G,{variant:`destructive`,onClick:()=>E.mutate(C.id),disabled:E.isPending,children:`Reject`})]})]}):(0,V.jsxs)(`div`,{className:`shrink-0 border-t border-gray-800 bg-gray-950 px-4 py-3 text-sm text-gray-500 sm:px-5`,children:[`Read-only — already `,C.status,`. Switch to Waiting to review open proposals.`]})]})]})]})]})}var yH=`border-[#C4B643] data-[state=checked]:bg-[#C4B643] data-[state=checked]:text-[#0A0A07] data-[state=indeterminate]:bg-[#C4B643] data-[state=indeterminate]:text-[#0A0A07]`;function bH(){let{toast:e}=on(),t=Et(),[n,r]=(0,b.useState)(`open`),[i,a]=(0,b.useState)(``),[o,s]=(0,b.useState)(!1),[c,l]=(0,b.useState)(new Set),{data:u}=Vt({queryKey:[`/api/playbooks/vault`]}),d=u?.data??[],f=(0,b.useMemo)(()=>{let e=new Map;for(let t of d)e.set(t.id,t.title);return e},[d]),p={status:n===`all`?void 0:n,playbookId:i||void 0,excludeInProposal:n===`open`?!o:void 0},{data:m=[],isLoading:h}=Vt({queryKey:[`/api/feedback-signals`,p],queryFn:()=>Sh(p)}),g=Ht({mutationFn:e=>Ch(e),onSuccess:n=>{e({title:`Discarded ${n.discarded} signal(s)`}),l(new Set),t.invalidateQueries({queryKey:[`/api/feedback-signals`]})},onError:t=>{e({title:`Discard failed`,description:t.message,variant:`destructive`})}}),_=e=>{l(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n})},v=async()=>{let t=c.size>0?m.filter(e=>c.has(e.id)):m;if(t.length!==0){if(t.some(e=>!e.id)){e({title:`Copy blocked`,description:`Every signal must include an id for tracking.`,variant:`destructive`});return}try{await navigator.clipboard.writeText(Dh(t)),e({title:`Copied curation prompt`,description:`${t.length} signal id(s) included — paste into your IDE agent.`})}catch(t){e({title:`Copy failed`,description:t instanceof Error?t.message:`Clipboard unavailable`,variant:`destructive`})}}},y=[...c].filter(e=>m.find(t=>t.id===e)?.status===`open`),x=m.length>0&&m.every(e=>c.has(e.id)),S=m.some(e=>c.has(e.id));return(0,V.jsxs)(`div`,{className:`flex min-h-dvh flex-col bg-gray-950 text-gray-100`,children:[(0,V.jsx)(`header`,{className:`shrink-0 border-b border-gray-800 px-4 py-4 sm:px-6`,children:(0,V.jsxs)(`div`,{className:`mx-auto flex max-w-7xl flex-wrap items-center gap-3`,children:[(0,V.jsx)(ye,{href:`/`,children:(0,V.jsxs)(G,{variant:`ghost`,size:`sm`,className:`text-gray-300`,children:[(0,V.jsx)(li,{className:`mr-1 h-4 w-4`}),`Home`]})}),(0,V.jsx)(`h1`,{className:`text-lg font-semibold`,children:`Feedback`}),(0,V.jsx)(jh,{variant:`outline`,children:m.length}),(0,V.jsx)(ye,{href:`/playbook-patches`,className:`ml-auto text-sm hover:underline`,style:{color:`#92E4DD`},children:`Playbook proposals →`})]})}),(0,V.jsxs)(`main`,{className:`mx-auto w-full max-w-7xl flex-1 space-y-4 px-4 py-6 sm:px-6`,children:[(0,V.jsx)(`p`,{className:`text-sm text-gray-400`,children:`Durable correction data for playbook enhancement. Filter by playbook, copy rows (with ids) for an IDE agent to propose, then accept the proposal to mark feedback solved.`}),(0,V.jsxs)(`div`,{className:`flex flex-wrap items-end gap-3 rounded-lg border border-gray-800 bg-gray-900/40 p-3`,children:[(0,V.jsxs)(`label`,{className:`text-xs text-gray-500`,children:[`Playbook`,(0,V.jsxs)(`select`,{className:`mt-1 block min-w-[12rem] rounded border border-gray-700 bg-gray-950 px-2 py-1.5 text-sm text-gray-100`,value:i,onChange:e=>{a(e.target.value),l(new Set)},children:[(0,V.jsx)(`option`,{value:``,children:`All`}),d.map(e=>(0,V.jsx)(`option`,{value:e.id,children:e.title},e.id))]})]}),(0,V.jsx)(`div`,{className:`flex flex-wrap gap-1`,children:[[`open`,`Open`],[`actioned`,`Actioned`],[`discarded`,`Discarded`],[`all`,`All`]].map(([e,t])=>{let i=n===e;return(0,V.jsx)(G,{size:`sm`,variant:i?`gold`:`outline`,className:i?void 0:`border-gray-600 bg-transparent text-gray-300 hover:bg-gray-800 hover:text-gray-100`,"aria-pressed":i,onClick:()=>{r(e),l(new Set)},children:t},e)})}),n===`open`&&(0,V.jsxs)(`label`,{className:`flex items-center gap-2 text-xs text-gray-400`,children:[(0,V.jsx)(`input`,{type:`checkbox`,checked:o,onChange:e=>s(e.target.checked)}),`Include already in an open proposal`]}),(0,V.jsxs)(`div`,{className:`ml-auto flex flex-wrap gap-2`,children:[(0,V.jsxs)(G,{size:`sm`,variant:`outline`,disabled:m.length===0,onClick:()=>void v(),children:[(0,V.jsx)(Ci,{className:`mr-1 h-3.5 w-3.5`}),`Copy for agent`,c.size>0?` (${c.size})`:``]}),(0,V.jsxs)(G,{size:`sm`,variant:`destructive`,disabled:y.length===0||g.isPending,onClick:()=>g.mutate(y),children:[(0,V.jsx)(Vi,{className:`mr-1 h-3.5 w-3.5`}),`Discard selected`]})]})]}),h&&(0,V.jsx)(`p`,{className:`text-sm text-gray-500`,children:`Loading…`}),!h&&m.length===0&&(0,V.jsx)(`p`,{className:`text-sm text-gray-500`,children:`No signals match these filters.`}),!h&&m.length>0&&(0,V.jsx)(`div`,{className:`overflow-x-auto rounded-lg border border-gray-800`,children:(0,V.jsxs)(`table`,{className:`w-full min-w-[48rem] text-left text-sm`,children:[(0,V.jsx)(`thead`,{className:`border-b border-gray-800 bg-gray-900/80 text-xs uppercase text-gray-500`,children:(0,V.jsxs)(`tr`,{children:[(0,V.jsx)(`th`,{className:`w-10 px-3 py-2`,children:(0,V.jsx)(Dg,{checked:x?!0:S?`indeterminate`:!1,onCheckedChange:()=>{if(x){l(new Set);return}l(new Set(m.map(e=>e.id)))},"aria-label":`Select all visible signals`,disabled:m.length===0,className:yH})}),(0,V.jsx)(`th`,{className:`px-3 py-2`,children:`Excerpt`}),(0,V.jsx)(`th`,{className:`px-3 py-2`,children:`Failure`}),(0,V.jsx)(`th`,{className:`px-3 py-2`,children:`Playbook`}),(0,V.jsx)(`th`,{className:`px-3 py-2`,children:`Source`}),(0,V.jsx)(`th`,{className:`px-3 py-2`,children:`When`})]})}),(0,V.jsx)(`tbody`,{children:m.map(e=>{let t=wh(e);return(0,V.jsxs)(`tr`,{className:`border-b border-gray-800/80 align-top`,children:[(0,V.jsx)(`td`,{className:`px-3 py-2`,children:(0,V.jsx)(Dg,{checked:c.has(e.id),onCheckedChange:()=>_(e.id),"aria-label":`Select ${e.id}`,className:yH})}),(0,V.jsxs)(`td`,{className:`px-3 py-2`,children:[(0,V.jsx)(`p`,{className:`font-mono text-[11px] text-gray-600`,children:e.id}),(0,V.jsxs)(`p`,{className:`text-gray-200`,children:[`“`,e.userFeedbackExcerpt,`”`]}),t&&(0,V.jsx)(jh,{variant:`outline`,className:`mt-1 text-[10px]`,children:`In proposal`})]}),(0,V.jsx)(`td`,{className:`px-3 py-2 text-gray-400`,children:e.failureSummary}),(0,V.jsx)(`td`,{className:`px-3 py-2 text-gray-300`,children:e.candidatePlaybookId?f.get(e.candidatePlaybookId)??e.candidatePlaybookId:`—`}),(0,V.jsx)(`td`,{className:`px-3 py-2 text-gray-500`,children:e.source}),(0,V.jsx)(`td`,{className:`px-3 py-2 whitespace-nowrap text-gray-500`,children:new Date(e.createdAt).toLocaleString()})]},e.id)})})]})})]})]})}function xH(){let e=new URLSearchParams(window.location.search),t=e.get(`challenge`)??``,n=e.get(`session`)??``,[r,i]=(0,b.useState)(`idle`),[a,o]=(0,b.useState)(``);(0,b.useEffect)(()=>{(!t||!n)&&(i(`error`),o(`Missing challenge or session in URL.`))},[t,n]);async function s(){if(t&&n){i(`loading`);try{await H(`POST`,`/api/trusted-session/admin/approve`,{challengeId:t,runtimeSessionId:n}),i(`success`),o(`Admin elevation approved for this MCP session. Return to the agent.`)}catch(e){i(`error`),o(e instanceof Error?e.message:`Approval failed`)}}}return(0,V.jsx)(`div`,{className:`min-h-screen flex items-center justify-center p-6 bg-muted/30`,children:(0,V.jsxs)(IO,{className:`w-full max-w-md`,children:[(0,V.jsxs)(LO,{children:[(0,V.jsx)(RO,{children:`Approve agent-admin elevation`}),(0,V.jsx)(zO,{children:`Grants ephemeral deck-admin mode to one MCP session (30-minute lease). This does not change the persistent workspace grant.`})]}),(0,V.jsxs)(BO,{className:`space-y-4`,children:[t&&n?(0,V.jsxs)(`dl`,{className:`text-sm space-y-1 text-muted-foreground`,children:[(0,V.jsxs)(`div`,{children:[(0,V.jsx)(`dt`,{className:`inline font-medium text-foreground`,children:`Session `}),(0,V.jsx)(`dd`,{className:`inline font-mono text-xs`,children:n})]}),(0,V.jsxs)(`div`,{children:[(0,V.jsx)(`dt`,{className:`inline font-medium text-foreground`,children:`Challenge `}),(0,V.jsx)(`dd`,{className:`inline font-mono text-xs`,children:t})]})]}):null,r===`success`?(0,V.jsx)(`p`,{className:`text-sm text-green-700 dark:text-green-400`,children:a}):r===`error`?(0,V.jsx)(`p`,{className:`text-sm text-destructive`,children:a}):null,r!==`success`&&t&&n?(0,V.jsx)(G,{onClick:()=>void s(),disabled:r===`loading`,className:`w-full`,children:r===`loading`?`Approving…`:`Approve elevation`}):null]})]})})}function SH(){return(0,V.jsxs)(xe,{children:[(0,V.jsx)(ve,{path:`/`,component:FO}),(0,V.jsx)(ve,{path:`/oauth/callback`,component:UO}),(0,V.jsx)(ve,{path:`/playbook-patches`,component:vH}),(0,V.jsx)(ve,{path:`/feedback-signals`,component:bH}),(0,V.jsx)(ve,{path:`/admin/approve`,component:xH}),(0,V.jsx)(ve,{path:`/mcp-test`,component:MV}),(0,V.jsx)(ve,{component:HO})]})}function CH(){let[e,t]=(0,b.useState)(!1);return(0,b.useEffect)(()=>{let e=!1;return qt().finally(()=>{e||t(!0)}),()=>{e=!0}},[]),e?(0,V.jsx)(Dt,{client:Kt,children:(0,V.jsxs)(wl,{children:[(0,V.jsx)(Za,{}),(0,V.jsx)(SH,{})]})}):(0,V.jsx)(`div`,{className:`flex min-h-screen items-center justify-center bg-[#0B1220] text-sm text-gray-300`,children:`Loading AgentDeck...`})}(0,x.createRoot)(document.getElementById(`root`)).render((0,V.jsx)(b.StrictMode,{children:(0,V.jsx)(CH,{})}));
235
+ `);return(0,V.jsxs)(`div`,{className:`min-w-0 space-y-4`,children:[!t&&(0,V.jsxs)(`div`,{className:`rounded-md border border-amber-500/50 bg-amber-500/10 p-3 text-sm text-amber-100`,children:[`No change detected — ops did not alter the playbook body or triggers. Reject this proposal and re-propose with a matching list anchor or `,(0,V.jsx)(`code`,{children:`rewrite_body`}),`.`]}),r&&(0,V.jsx)(`div`,{className:`rounded-md border border-amber-500/50 bg-amber-500/10 p-3 text-sm text-amber-100`,children:`Full-body rewrite proposed — review carefully.`}),i&&(0,V.jsxs)(`div`,{className:`space-y-2`,children:[(0,V.jsx)(`h4`,{className:`text-sm font-medium text-gray-400`,children:`Title`}),(0,V.jsxs)(`div`,{className:`${oH} p-0`,children:[e.before.title&&(0,V.jsxs)(`div`,{className:`grid min-w-0 grid-cols-[3rem_3rem_minmax(0,1fr)] bg-rose-950/70 text-rose-100`,children:[(0,V.jsx)(`span`,{className:`border-r border-gray-800/80 px-2 py-0.5`}),(0,V.jsx)(`span`,{className:`border-r border-gray-800/80 px-2 py-0.5`}),(0,V.jsxs)(`div`,{className:`flex gap-2 px-2 py-0.5`,children:[(0,V.jsx)(`span`,{className:`w-3 shrink-0 text-gray-500`,children:`-`}),(0,V.jsx)(`span`,{children:e.before.title})]})]}),e.after.title&&(0,V.jsxs)(`div`,{className:`grid min-w-0 grid-cols-[3rem_3rem_minmax(0,1fr)] bg-emerald-950/70 text-emerald-100`,children:[(0,V.jsx)(`span`,{className:`border-r border-gray-800/80 px-2 py-0.5`}),(0,V.jsx)(`span`,{className:`border-r border-gray-800/80 px-2 py-0.5`}),(0,V.jsxs)(`div`,{className:`flex gap-2 px-2 py-0.5`,children:[(0,V.jsx)(`span`,{className:`w-3 shrink-0 text-gray-500`,children:`+`}),(0,V.jsx)(`span`,{children:e.after.title})]})]})]})]}),(0,V.jsxs)(`div`,{className:`space-y-2`,children:[(0,V.jsx)(`h4`,{className:`text-sm font-medium text-gray-400`,children:`Body`}),(0,V.jsx)(lH,{rows:n,emptyLabel:`No body changes.`})]}),a&&(0,V.jsx)(uH,{before:e.before.triggers,after:e.after.triggers})]})}function fH(e){if(!e)return[];try{return JSON.parse(e)}catch{return[]}}function pH({conflicts:e,title:t=`Trigger overlap warnings`}){return e.length===0?null:(0,V.jsxs)(`div`,{className:`rounded-md border border-amber-500/40 bg-amber-500/10 p-4 text-sm text-amber-50`,children:[(0,V.jsx)(`p`,{className:`text-xs font-medium uppercase tracking-wide text-amber-200/90`,children:t}),(0,V.jsx)(`p`,{className:`mt-2 text-amber-100/90`,children:`These triggers overlap with other playbooks on the deck. Accept is still allowed — disambiguate triggers or propose a merge if the wrong playbook keeps firing.`}),(0,V.jsx)(`ul`,{className:`mt-3 space-y-2`,children:e.map(e=>(0,V.jsxs)(`li`,{className:`rounded border border-amber-500/20 bg-gray-950/60 p-3`,children:[(0,V.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,V.jsx)(jh,{variant:`outline`,className:`border-amber-400/40 text-amber-100`,children:e.level}),(0,V.jsx)(`span`,{className:`font-medium text-amber-50`,children:e.otherPlaybookTitle}),(0,V.jsx)(`span`,{className:`font-mono text-xs text-amber-200/70`,children:e.otherPlaybookId})]}),(0,V.jsxs)(`p`,{className:`mt-2 text-amber-100/90`,children:[(0,V.jsx)(`span`,{className:`text-amber-200/80`,children:`Candidate:`}),` `,e.trigger]}),(0,V.jsxs)(`p`,{className:`text-amber-100/80`,children:[(0,V.jsx)(`span`,{className:`text-amber-200/80`,children:`Other:`}),` `,e.otherTrigger]})]},`${e.trigger}-${e.otherPlaybookId}-${e.level}`))})]})}var mH=8,hH=[{value:`proposed`,label:`Waiting`},{value:`accepted`,label:`Accepted`},{value:`rejected`,label:`Rejected`},{value:`superseded`,label:`Superseded`},{value:`stale`,label:`Stale`},{value:`all`,label:`All`}];function gH(e){if(!e.evidenceJson)return null;try{return JSON.parse(e.evidenceJson)}catch{return null}}function _H(e){switch(e){case`proposed`:return`border-blue-500/40 text-blue-200`;case`accepted`:return`border-emerald-500/40 text-emerald-200`;case`rejected`:return`border-rose-500/40 text-rose-200`;case`superseded`:return`border-violet-500/40 text-violet-200`;case`stale`:return`border-amber-500/40 text-amber-200`}}function vH(){let[e,t]=(0,b.useState)(null),[n,r]=(0,b.useState)(`proposed`),[i,a]=(0,b.useState)(0),{toast:o}=on(),s=Et();function c(e){t(e)}function l(e){r(e),a(0),t(null)}let{data:u=[]}=Vt({queryKey:[`/api/playbook-patches`,`proposed`],queryFn:()=>hh(`proposed`)}),d=n===`all`?void 0:n,{data:f=[],isLoading:p}=Vt({queryKey:[`/api/playbook-patches`,n],queryFn:()=>hh(d)}),m=Math.max(1,Math.ceil(f.length/mH)),h=Math.min(i,m-1),g=(0,b.useMemo)(()=>{let e=h*mH;return f.slice(e,e+mH)},[f,h]);(0,b.useEffect)(()=>{i!==h&&a(h)},[i,h]);let{data:_,isLoading:v,isError:y,error:x}=Vt({queryKey:[`/api/playbook-patches`,e,`preview`],queryFn:()=>gh(e),enabled:!!e}),S=_?NV(_):!1,C=f.find(t=>t.id===e)??null,w=C?.status===`proposed`,T=Ht({mutationFn:e=>_h(e),onSuccess:()=>{o({title:`Patch accepted`}),t(null),s.invalidateQueries({queryKey:[`/api/playbook-patches`]}),s.invalidateQueries({queryKey:[`/api/playbooks`]}),s.invalidateQueries({queryKey:[`/api/feedback-signals`]})},onError:e=>{o({title:`Accept failed`,description:e.message,variant:`destructive`})}}),E=Ht({mutationFn:e=>vh(e),onSuccess:()=>{o({title:`Patch rejected`}),t(null),s.invalidateQueries({queryKey:[`/api/playbook-patches`]}),s.invalidateQueries({queryKey:[`/api/feedback-signals`]})},onError:e=>{o({title:`Reject failed`,description:e.message,variant:`destructive`})}}),D=n===`proposed`?`No proposals waiting for review.`:n===`all`?`No playbook patches yet.`:`No ${n} patches.`;return(0,V.jsxs)(`div`,{className:`flex h-dvh flex-col overflow-hidden bg-gray-950 text-gray-100`,children:[(0,V.jsx)(`header`,{className:`shrink-0 border-b border-gray-800 px-4 py-4 sm:px-6`,children:(0,V.jsxs)(`div`,{className:`mx-auto flex max-w-7xl flex-wrap items-center gap-3`,children:[(0,V.jsx)(ye,{href:`/`,children:(0,V.jsxs)(G,{variant:`ghost`,size:`sm`,className:`text-gray-300`,children:[(0,V.jsx)(li,{className:`mr-1 h-4 w-4`}),`Deck`]})}),(0,V.jsx)(`h1`,{className:`text-lg font-semibold`,children:`Playbook review queue`}),(0,V.jsxs)(jh,{variant:`secondary`,children:[u.length,` waiting`]}),(0,V.jsx)(ye,{href:`/feedback-signals`,className:`ml-auto text-sm hover:underline`,style:{color:`#92E4DD`},children:`Feedback data →`})]})}),(0,V.jsxs)(`main`,{className:`mx-auto grid w-full max-w-7xl min-h-0 flex-1 gap-6 overflow-hidden px-4 py-6 sm:px-6 lg:grid-cols-[minmax(18rem,20rem)_minmax(0,1fr)] lg:items-stretch`,children:[(0,V.jsxs)(`section`,{className:`flex min-h-0 min-w-0 flex-col`,children:[(0,V.jsx)(`h2`,{className:`mb-3 shrink-0 text-sm font-medium text-gray-400`,children:`Proposals`}),(0,V.jsx)(`div`,{className:`mb-3 flex shrink-0 flex-wrap gap-1`,children:hH.map(({value:e,label:t})=>{let r=n===e;return(0,V.jsx)(G,{size:`sm`,variant:r?`gold`:`outline`,className:r?void 0:`border-gray-600 bg-transparent text-gray-300 hover:bg-gray-800 hover:text-gray-100`,"aria-pressed":r,onClick:()=>l(e),children:t},e)})}),(0,V.jsxs)(`div`,{className:`min-h-0 flex-1 overflow-y-auto`,children:[p&&(0,V.jsx)(`p`,{className:`text-sm text-gray-500`,children:`Loading…`}),!p&&f.length===0&&(0,V.jsx)(`p`,{className:`text-sm text-gray-500`,children:D}),(0,V.jsx)(`ul`,{className:`space-y-2`,children:g.map(t=>(0,V.jsx)(`li`,{children:(0,V.jsxs)(`button`,{type:`button`,onClick:()=>c(t.id),className:`w-full rounded-lg border p-3 text-left transition ${e===t.id?`border-blue-500 bg-gray-900`:`border-gray-800 bg-gray-900/50 hover:border-gray-700`}`,children:[(0,V.jsxs)(`div`,{className:`flex items-start justify-between gap-2`,children:[(0,V.jsxs)(`div`,{className:`min-w-0`,children:[(0,V.jsx)(`span`,{className:`block font-medium leading-snug`,children:t.kind===`create`?`New: ${t.displayTitle}`:t.displayTitle}),t.playbookId&&t.kind!==`create`&&(0,V.jsx)(`span`,{className:`mt-0.5 block truncate font-mono text-xs text-gray-600`,children:t.playbookId}),mh(t.deckNames)&&(0,V.jsxs)(`span`,{className:`mt-1 block text-xs text-gray-500`,children:[`Decks: `,mh(t.deckNames)]})]}),(0,V.jsxs)(`div`,{className:`flex shrink-0 flex-col items-end gap-1`,children:[(0,V.jsx)(jh,{variant:`outline`,className:`shrink-0`,children:t.kind}),n!==`proposed`&&(0,V.jsx)(jh,{variant:`outline`,className:`shrink-0 ${_H(t.status)}`,children:t.status})]})]}),(0,V.jsx)(`p`,{className:`mt-1 line-clamp-2 text-sm text-gray-400`,children:t.rationale}),(0,V.jsxs)(`p`,{className:`mt-1 text-xs text-gray-600`,children:[t.source,` · `,new Date(t.createdAt).toLocaleString()]})]})},t.id))})]}),f.length>mH&&(0,V.jsxs)(`div`,{className:`mt-3 flex shrink-0 items-center justify-between gap-2 border-t border-gray-800 pt-3`,children:[(0,V.jsxs)(G,{type:`button`,size:`sm`,variant:`outline`,className:`border-gray-600 bg-transparent text-gray-300 hover:bg-gray-800`,disabled:h<=0,onClick:()=>a(e=>Math.max(0,e-1)),children:[(0,V.jsx)(gi,{className:`mr-1 h-4 w-4`}),`Newer`]}),(0,V.jsxs)(`span`,{className:`text-xs text-gray-500`,children:[h+1,` / `,m,(0,V.jsxs)(`span`,{className:`ml-1 text-gray-600`,children:[`(`,f.length,`)`]})]}),(0,V.jsxs)(G,{type:`button`,size:`sm`,variant:`outline`,className:`border-gray-600 bg-transparent text-gray-300 hover:bg-gray-800`,disabled:h>=m-1,onClick:()=>a(e=>Math.min(m-1,e+1)),children:[`Older`,(0,V.jsx)(_i,{className:`ml-1 h-4 w-4`})]})]})]}),(0,V.jsxs)(`section`,{className:`flex min-h-0 min-w-0 flex-col overflow-hidden`,children:[(0,V.jsx)(`h2`,{className:`mb-3 shrink-0 text-sm font-medium text-gray-400`,children:`Detail`}),!C&&(0,V.jsx)(`p`,{className:`text-sm text-gray-500`,children:`Select a proposal to preview the diff.`}),C&&(0,V.jsxs)(`div`,{className:`flex min-h-0 flex-1 flex-col overflow-hidden rounded-lg border border-gray-800 bg-gray-900/50`,children:[(0,V.jsx)(`div`,{className:`min-h-0 flex-1 overflow-y-auto overscroll-contain p-4 sm:p-5`,children:(0,V.jsxs)(`div`,{className:`min-w-0 space-y-4`,children:[(0,V.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,V.jsx)(jh,{variant:`outline`,className:_H(C.status),children:C.status}),C.resolvedAt&&(0,V.jsxs)(`span`,{className:`text-xs text-gray-500`,children:[`Resolved `,new Date(C.resolvedAt).toLocaleString()]})]}),(0,V.jsx)(`p`,{className:`text-sm leading-relaxed text-gray-300`,children:C.rationale}),C.status===`rejected`&&C.rejectionReason&&(0,V.jsxs)(`div`,{className:`rounded-md border border-rose-500/40 bg-rose-500/10 p-3 text-sm text-rose-100`,children:[(0,V.jsx)(`p`,{className:`text-xs font-medium uppercase tracking-wide text-rose-300/80`,children:`Rejection reason`}),(0,V.jsx)(`p`,{className:`mt-1`,children:C.rejectionReason})]}),C.status===`superseded`&&C.supersededBy&&(0,V.jsxs)(`div`,{className:`rounded-md border border-violet-500/40 bg-violet-500/10 p-3 text-sm text-violet-100`,children:[(0,V.jsx)(`p`,{className:`text-xs font-medium uppercase tracking-wide text-violet-300/80`,children:`Superseded by`}),(0,V.jsx)(`button`,{type:`button`,className:`mt-1 font-mono text-sm underline-offset-2 hover:underline`,onClick:()=>{let e=C.supersededBy;r(`all`),a(0),c(e)},children:C.supersededBy})]}),(()=>{let e=gH(C);return e?(0,V.jsxs)(`div`,{className:`rounded-md border border-gray-700 bg-gray-950 p-4 text-sm`,children:[(0,V.jsx)(`p`,{className:`text-xs font-medium uppercase tracking-wide text-gray-500`,children:`Your correction`}),(0,V.jsxs)(`p`,{className:`mt-2 italic text-gray-200`,children:[`“`,e.user_feedback_excerpt,`”`]}),e.failure_summary&&(0,V.jsx)(`p`,{className:`mt-2 text-gray-400`,children:e.failure_summary})]}):null})(),(()=>{let e=fH(C.conflictsJson),t=_?.trigger_conflicts??[],n=t.length>0?t:e;return(0,V.jsx)(pH,{conflicts:n})})(),v&&(0,V.jsx)(`p`,{className:`text-sm text-gray-500`,children:`Loading preview…`}),y&&(0,V.jsxs)(`div`,{className:`rounded-md border border-rose-500/50 bg-rose-500/10 p-3 text-sm text-rose-100`,children:[`Preview failed —`,` `,x?.message??`could not apply ops to the current playbook.`,w?` Reject and re-propose with exact list anchors or rewrite_body.`:` Historical preview may be incomplete if the playbook changed.`]}),_&&(0,V.jsx)(dH,{preview:_}),C.status===`stale`&&(0,V.jsx)(`p`,{className:`text-sm text-amber-400`,children:`Stale — playbook changed since proposal. Re-propose from a fresh session.`})]})}),w?(0,V.jsxs)(`div`,{className:`relative z-10 shrink-0 space-y-3 border-t border-gray-800 bg-gray-950 p-4 shadow-[0_-16px_32px_rgba(0,0,0,0.55)] sm:p-5`,children:[(0,V.jsx)(`h3`,{className:`text-sm font-medium text-gray-400`,children:`Your decision`}),(0,V.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[(0,V.jsx)(G,{variant:`gold`,onClick:()=>T.mutate(C.id),disabled:T.isPending||y||!S,children:`Accept`}),(0,V.jsx)(G,{variant:`destructive`,onClick:()=>E.mutate(C.id),disabled:E.isPending,children:`Reject`})]})]}):(0,V.jsxs)(`div`,{className:`shrink-0 border-t border-gray-800 bg-gray-950 px-4 py-3 text-sm text-gray-500 sm:px-5`,children:[`Read-only — already `,C.status,`. Switch to Waiting to review open proposals.`]})]})]})]})]})}var yH=`border-[#C4B643] data-[state=checked]:bg-[#C4B643] data-[state=checked]:text-[#0A0A07] data-[state=indeterminate]:bg-[#C4B643] data-[state=indeterminate]:text-[#0A0A07]`;function bH(){let{toast:e}=on(),t=Et(),[n,r]=(0,b.useState)(`open`),[i,a]=(0,b.useState)(``),[o,s]=(0,b.useState)(!1),[c,l]=(0,b.useState)(new Set),{data:u}=Vt({queryKey:[`/api/playbooks/vault`]}),d=u?.data??[],f=(0,b.useMemo)(()=>{let e=new Map;for(let t of d)e.set(t.id,t.title);return e},[d]),p={status:n===`all`?void 0:n,playbookId:i||void 0,excludeInProposal:n===`open`?!o:void 0},{data:m=[],isLoading:h}=Vt({queryKey:[`/api/feedback-signals`,p],queryFn:()=>Sh(p)}),g=Ht({mutationFn:e=>Ch(e),onSuccess:n=>{e({title:`Discarded ${n.discarded} signal(s)`}),l(new Set),t.invalidateQueries({queryKey:[`/api/feedback-signals`]})},onError:t=>{e({title:`Discard failed`,description:t.message,variant:`destructive`})}}),_=e=>{l(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n})},v=async()=>{let t=c.size>0?m.filter(e=>c.has(e.id)):m;if(t.length!==0){if(t.some(e=>!e.id)){e({title:`Copy blocked`,description:`Every signal must include an id for tracking.`,variant:`destructive`});return}try{await navigator.clipboard.writeText(Dh(t)),e({title:`Copied curation prompt`,description:`${t.length} signal id(s) included — paste into your IDE agent.`})}catch(t){e({title:`Copy failed`,description:t instanceof Error?t.message:`Clipboard unavailable`,variant:`destructive`})}}},y=[...c].filter(e=>m.find(t=>t.id===e)?.status===`open`),x=m.length>0&&m.every(e=>c.has(e.id)),S=m.some(e=>c.has(e.id));return(0,V.jsxs)(`div`,{className:`flex min-h-dvh flex-col bg-gray-950 text-gray-100`,children:[(0,V.jsx)(`header`,{className:`shrink-0 border-b border-gray-800 px-4 py-4 sm:px-6`,children:(0,V.jsxs)(`div`,{className:`mx-auto flex max-w-7xl flex-wrap items-center gap-3`,children:[(0,V.jsx)(ye,{href:`/`,children:(0,V.jsxs)(G,{variant:`ghost`,size:`sm`,className:`text-gray-300`,children:[(0,V.jsx)(li,{className:`mr-1 h-4 w-4`}),`Home`]})}),(0,V.jsx)(`h1`,{className:`text-lg font-semibold`,children:`Feedback`}),(0,V.jsx)(jh,{variant:`outline`,children:m.length}),(0,V.jsx)(ye,{href:`/playbook-patches`,className:`ml-auto text-sm hover:underline`,style:{color:`#92E4DD`},children:`Playbook proposals →`})]})}),(0,V.jsxs)(`main`,{className:`mx-auto w-full max-w-7xl flex-1 space-y-4 px-4 py-6 sm:px-6`,children:[(0,V.jsx)(`p`,{className:`text-sm text-gray-400`,children:`Durable correction data for playbook enhancement. Filter by playbook, copy rows (with ids) for an IDE agent to propose, then accept the proposal to mark feedback solved.`}),(0,V.jsxs)(`div`,{className:`flex flex-wrap items-end gap-3 rounded-lg border border-gray-800 bg-gray-900/40 p-3`,children:[(0,V.jsxs)(`label`,{className:`text-xs text-gray-500`,children:[`Playbook`,(0,V.jsxs)(`select`,{className:`mt-1 block min-w-[12rem] rounded border border-gray-700 bg-gray-950 px-2 py-1.5 text-sm text-gray-100`,value:i,onChange:e=>{a(e.target.value),l(new Set)},children:[(0,V.jsx)(`option`,{value:``,children:`All`}),d.map(e=>(0,V.jsx)(`option`,{value:e.id,children:e.title},e.id))]})]}),(0,V.jsx)(`div`,{className:`flex flex-wrap gap-1`,children:[[`open`,`Open`],[`actioned`,`Actioned`],[`discarded`,`Discarded`],[`all`,`All`]].map(([e,t])=>{let i=n===e;return(0,V.jsx)(G,{size:`sm`,variant:i?`gold`:`outline`,className:i?void 0:`border-gray-600 bg-transparent text-gray-300 hover:bg-gray-800 hover:text-gray-100`,"aria-pressed":i,onClick:()=>{r(e),l(new Set)},children:t},e)})}),n===`open`&&(0,V.jsxs)(`label`,{className:`flex items-center gap-2 text-xs text-gray-400`,children:[(0,V.jsx)(`input`,{type:`checkbox`,checked:o,onChange:e=>s(e.target.checked)}),`Include already in an open proposal`]}),(0,V.jsxs)(`div`,{className:`ml-auto flex flex-wrap gap-2`,children:[(0,V.jsxs)(G,{size:`sm`,variant:`outline`,disabled:m.length===0,onClick:()=>void v(),children:[(0,V.jsx)(Ci,{className:`mr-1 h-3.5 w-3.5`}),`Copy for agent`,c.size>0?` (${c.size})`:``]}),(0,V.jsxs)(G,{size:`sm`,variant:`destructive`,disabled:y.length===0||g.isPending,onClick:()=>g.mutate(y),children:[(0,V.jsx)(Vi,{className:`mr-1 h-3.5 w-3.5`}),`Discard selected`]})]})]}),h&&(0,V.jsx)(`p`,{className:`text-sm text-gray-500`,children:`Loading…`}),!h&&m.length===0&&(0,V.jsx)(`p`,{className:`text-sm text-gray-500`,children:`No signals match these filters.`}),!h&&m.length>0&&(0,V.jsx)(`div`,{className:`overflow-x-auto rounded-lg border border-gray-800`,children:(0,V.jsxs)(`table`,{className:`w-full min-w-[48rem] text-left text-sm`,children:[(0,V.jsx)(`thead`,{className:`border-b border-gray-800 bg-gray-900/80 text-xs uppercase text-gray-500`,children:(0,V.jsxs)(`tr`,{children:[(0,V.jsx)(`th`,{className:`w-10 px-3 py-2`,children:(0,V.jsx)(Dg,{checked:x?!0:S?`indeterminate`:!1,onCheckedChange:()=>{if(x){l(new Set);return}l(new Set(m.map(e=>e.id)))},"aria-label":`Select all visible signals`,disabled:m.length===0,className:yH})}),(0,V.jsx)(`th`,{className:`px-3 py-2`,children:`Excerpt`}),(0,V.jsx)(`th`,{className:`px-3 py-2`,children:`Failure`}),(0,V.jsx)(`th`,{className:`px-3 py-2`,children:`Playbook`}),(0,V.jsx)(`th`,{className:`px-3 py-2`,children:`Source`}),(0,V.jsx)(`th`,{className:`px-3 py-2`,children:`When`})]})}),(0,V.jsx)(`tbody`,{children:m.map(e=>{let t=wh(e);return(0,V.jsxs)(`tr`,{className:`border-b border-gray-800/80 align-top`,children:[(0,V.jsx)(`td`,{className:`px-3 py-2`,children:(0,V.jsx)(Dg,{checked:c.has(e.id),onCheckedChange:()=>_(e.id),"aria-label":`Select ${e.id}`,className:yH})}),(0,V.jsxs)(`td`,{className:`px-3 py-2`,children:[(0,V.jsx)(`p`,{className:`font-mono text-[11px] text-gray-600`,children:e.id}),(0,V.jsxs)(`p`,{className:`text-gray-200`,children:[`“`,e.userFeedbackExcerpt,`”`]}),t&&(0,V.jsx)(jh,{variant:`outline`,className:`mt-1 text-[10px]`,children:`In proposal`})]}),(0,V.jsx)(`td`,{className:`px-3 py-2 text-gray-400`,children:e.failureSummary}),(0,V.jsx)(`td`,{className:`px-3 py-2 text-gray-300`,children:e.candidatePlaybookId?f.get(e.candidatePlaybookId)??e.candidatePlaybookId:`—`}),(0,V.jsx)(`td`,{className:`px-3 py-2 text-gray-500`,children:e.source}),(0,V.jsx)(`td`,{className:`px-3 py-2 whitespace-nowrap text-gray-500`,children:new Date(e.createdAt).toLocaleString()})]},e.id)})})]})})]})]})}function xH(){let e=new URLSearchParams(window.location.search),t=e.get(`challenge`)??``,n=e.get(`session`)??``,[r,i]=(0,b.useState)(`idle`),[a,o]=(0,b.useState)(``);(0,b.useEffect)(()=>{(!t||!n)&&(i(`error`),o(`Missing challenge or session in URL.`))},[t,n]);async function s(){if(t&&n){i(`loading`);try{await H(`POST`,`/api/trusted-session/admin/approve`,{challengeId:t,runtimeSessionId:n}),i(`success`),o(`Admin elevation approved for this MCP session. Return to the agent.`)}catch(e){i(`error`),o(e instanceof Error?e.message:`Approval failed`)}}}return(0,V.jsx)(`div`,{className:`min-h-screen flex items-center justify-center p-6 bg-muted/30`,children:(0,V.jsxs)(IO,{className:`w-full max-w-md`,children:[(0,V.jsxs)(LO,{children:[(0,V.jsx)(RO,{children:`Approve agent-admin elevation`}),(0,V.jsx)(zO,{children:`Grants ephemeral deck-admin mode to one MCP session (30-minute lease). This does not change the folder's deck assignment.`})]}),(0,V.jsxs)(BO,{className:`space-y-4`,children:[t&&n?(0,V.jsxs)(`dl`,{className:`text-sm space-y-1 text-muted-foreground`,children:[(0,V.jsxs)(`div`,{children:[(0,V.jsx)(`dt`,{className:`inline font-medium text-foreground`,children:`Session `}),(0,V.jsx)(`dd`,{className:`inline font-mono text-xs`,children:n})]}),(0,V.jsxs)(`div`,{children:[(0,V.jsx)(`dt`,{className:`inline font-medium text-foreground`,children:`Challenge `}),(0,V.jsx)(`dd`,{className:`inline font-mono text-xs`,children:t})]})]}):null,r===`success`?(0,V.jsx)(`p`,{className:`text-sm text-green-700 dark:text-green-400`,children:a}):r===`error`?(0,V.jsx)(`p`,{className:`text-sm text-destructive`,children:a}):null,r!==`success`&&t&&n?(0,V.jsx)(G,{onClick:()=>void s(),disabled:r===`loading`,className:`w-full`,children:r===`loading`?`Approving…`:`Approve elevation`}):null]})]})})}function SH(){return(0,V.jsxs)(xe,{children:[(0,V.jsx)(ve,{path:`/`,component:FO}),(0,V.jsx)(ve,{path:`/oauth/callback`,component:UO}),(0,V.jsx)(ve,{path:`/playbook-patches`,component:vH}),(0,V.jsx)(ve,{path:`/feedback-signals`,component:bH}),(0,V.jsx)(ve,{path:`/admin/approve`,component:xH}),(0,V.jsx)(ve,{path:`/mcp-test`,component:MV}),(0,V.jsx)(ve,{component:HO})]})}function CH(){let[e,t]=(0,b.useState)(!1);return(0,b.useEffect)(()=>{let e=!1;return qt().finally(()=>{e||t(!0)}),()=>{e=!0}},[]),e?(0,V.jsx)(Dt,{client:Kt,children:(0,V.jsxs)(wl,{children:[(0,V.jsx)(Za,{}),(0,V.jsx)(SH,{})]})}):(0,V.jsx)(`div`,{className:`flex min-h-screen items-center justify-center bg-[#0B1220] text-sm text-gray-300`,children:`Loading AgentDeck...`})}(0,x.createRoot)(document.getElementById(`root`)).render((0,V.jsx)(b.StrictMode,{children:(0,V.jsx)(CH,{})}));
@@ -8,7 +8,7 @@
8
8
  <link rel="preconnect" href="https://fonts.googleapis.com">
9
9
  <link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
10
10
  <link href="https://fonts.googleapis.com/css2?family=Architects+Daughter&family=DM+Sans:ital,opsz,wght@0,9..40,100..1000;1,9..40,100..1000&family=Fira+Code:wght@300..700&family=Geist+Mono:wght@100..900&family=Geist:wght@100..900&family=IBM+Plex+Mono:ital,wght@0,100;0,200;0,300;0,400;0,500;0,600;0,700;1,100;1,200;1,300;1,400;1,500;1,600;1,700&family=IBM+Plex+Sans:ital,wght@0,100..700;1,100..700&family=Inter:ital,opsz,wght@0,14..32,100..900;1,14..32,100..900&family=JetBrains+Mono:ital,wght@0,100..800;1,100..800&family=Libre+Baskerville:ital,wght@0,400;0,700;1,400&family=Lora:ital,wght@0,400..700;1,400..700&family=Merriweather:ital,opsz,wght@0,18..144,300..900;1,18..144,300..900&family=Montserrat:ital,wght@0,100..900;1,100..900&family=Open+Sans:ital,wght@0,300..800;1,300..800&family=Outfit:wght@100..900&family=Oxanium:wght@200..800&family=Playfair+Display:ital,wght@0,400..900;1,400..900&family=Plus+Jakarta+Sans:ital,wght@0,200..800;1,200..800&family=Poppins:ital,wght@0,100;0,200;0,300;0,400;0,500;0,600;0,700;0,800;0,900;1,100;1,200;1,300;1,400;1,500;1,600;1,700;1,800;1,900&family=Roboto+Mono:ital,wght@0,100..700;1,100..700&family=Roboto:ital,wght@0,100..900;1,100..900&family=Source+Code+Pro:ital,wght@0,200..900;1,200..900&family=Source+Serif+4:ital,opsz,wght@0,8..60,200..900;1,8..60,200..900&family=Space+Grotesk:wght@300..700&family=Space+Mono:ital,wght@0,400;0,700;1,400;1,700&display=swap" rel="stylesheet">
11
- <script type="module" crossorigin src="/assets/index-DhP_UPyM.js"></script>
11
+ <script type="module" crossorigin src="/assets/index-Bb9ckehB.js"></script>
12
12
  <link rel="stylesheet" crossorigin href="/assets/index-DRG5q9lJ.css">
13
13
  </head>
14
14
  <body>
@@ -1,15 +0,0 @@
1
- /**
2
- * Parse coordinator enrollment / execution-authority bearer tokens.
3
- * Forms: `enr_…:secret`, `authz_…:secret` (preferred), or raw secret with id header.
4
- */
5
- export type EnrollmentBearer = {
6
- enrollmentId: string;
7
- secret: string;
8
- };
9
- export type AuthorityBearer = {
10
- authorityId: string;
11
- secret: string;
12
- };
13
- export declare function parseEnrollmentBearer(token: string): EnrollmentBearer | null;
14
- export declare function parseAuthorityBearer(token: string): AuthorityBearer | null;
15
- //# sourceMappingURL=bearer.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"bearer.d.ts","sourceRoot":"","sources":["../../src/execution-authority/bearer.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,MAAM,MAAM,gBAAgB,GAAG;IAC7B,YAAY,EAAE,MAAM,CAAC;IACrB,MAAM,EAAE,MAAM,CAAC;CAChB,CAAC;AAEF,MAAM,MAAM,eAAe,GAAG;IAC5B,WAAW,EAAE,MAAM,CAAC;IACpB,MAAM,EAAE,MAAM,CAAC;CAChB,CAAC;AAEF,wBAAgB,qBAAqB,CAAC,KAAK,EAAE,MAAM,GAAG,gBAAgB,GAAG,IAAI,CAS5E;AAED,wBAAgB,oBAAoB,CAAC,KAAK,EAAE,MAAM,GAAG,eAAe,GAAG,IAAI,CAS1E"}
@@ -1,35 +0,0 @@
1
- "use strict";
2
- /**
3
- * Parse coordinator enrollment / execution-authority bearer tokens.
4
- * Forms: `enr_…:secret`, `authz_…:secret` (preferred), or raw secret with id header.
5
- */
6
- Object.defineProperty(exports, "__esModule", { value: true });
7
- exports.parseEnrollmentBearer = parseEnrollmentBearer;
8
- exports.parseAuthorityBearer = parseAuthorityBearer;
9
- function parseEnrollmentBearer(token) {
10
- const trimmed = token.trim();
11
- const colon = trimmed.indexOf(':');
12
- if (colon <= 0)
13
- return null;
14
- const enrollmentId = trimmed.slice(0, colon);
15
- if (!/^enr_[A-Za-z0-9]+$/.test(enrollmentId))
16
- return null;
17
- const secret = trimmed.slice(colon + 1);
18
- if (!secret)
19
- return null;
20
- return { enrollmentId, secret };
21
- }
22
- function parseAuthorityBearer(token) {
23
- const trimmed = token.trim();
24
- const colon = trimmed.indexOf(':');
25
- if (colon <= 0)
26
- return null;
27
- const authorityId = trimmed.slice(0, colon);
28
- if (!/^authz_[A-Za-z0-9]+$/.test(authorityId))
29
- return null;
30
- const secret = trimmed.slice(colon + 1);
31
- if (!secret)
32
- return null;
33
- return { authorityId, secret };
34
- }
35
- //# sourceMappingURL=bearer.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"bearer.js","sourceRoot":"","sources":["../../src/execution-authority/bearer.ts"],"names":[],"mappings":";AAAA;;;GAGG;;AAYH,sDASC;AAED,oDASC;AApBD,SAAgB,qBAAqB,CAAC,KAAa;IACjD,MAAM,OAAO,GAAG,KAAK,CAAC,IAAI,EAAE,CAAC;IAC7B,MAAM,KAAK,GAAG,OAAO,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC;IACnC,IAAI,KAAK,IAAI,CAAC;QAAE,OAAO,IAAI,CAAC;IAC5B,MAAM,YAAY,GAAG,OAAO,CAAC,KAAK,CAAC,CAAC,EAAE,KAAK,CAAC,CAAC;IAC7C,IAAI,CAAC,oBAAoB,CAAC,IAAI,CAAC,YAAY,CAAC;QAAE,OAAO,IAAI,CAAC;IAC1D,MAAM,MAAM,GAAG,OAAO,CAAC,KAAK,CAAC,KAAK,GAAG,CAAC,CAAC,CAAC;IACxC,IAAI,CAAC,MAAM;QAAE,OAAO,IAAI,CAAC;IACzB,OAAO,EAAE,YAAY,EAAE,MAAM,EAAE,CAAC;AAClC,CAAC;AAED,SAAgB,oBAAoB,CAAC,KAAa;IAChD,MAAM,OAAO,GAAG,KAAK,CAAC,IAAI,EAAE,CAAC;IAC7B,MAAM,KAAK,GAAG,OAAO,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC;IACnC,IAAI,KAAK,IAAI,CAAC;QAAE,OAAO,IAAI,CAAC;IAC5B,MAAM,WAAW,GAAG,OAAO,CAAC,KAAK,CAAC,CAAC,EAAE,KAAK,CAAC,CAAC;IAC5C,IAAI,CAAC,sBAAsB,CAAC,IAAI,CAAC,WAAW,CAAC;QAAE,OAAO,IAAI,CAAC;IAC3D,MAAM,MAAM,GAAG,OAAO,CAAC,KAAK,CAAC,KAAK,GAAG,CAAC,CAAC,CAAC;IACxC,IAAI,CAAC,MAAM;QAAE,OAAO,IAAI,CAAC;IACzB,OAAO,EAAE,WAAW,EAAE,MAAM,EAAE,CAAC;AACjC,CAAC"}
@@ -1,6 +0,0 @@
1
- export { ExecutionAuthorityLedger } from './ledger';
2
- export type { LedgerState } from './ledger';
3
- export { ExecutionAuthorityStore } from './store';
4
- export type { ExecutionAuthorityStoreOptions } from './store';
5
- export type * from './types';
6
- //# sourceMappingURL=index.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/execution-authority/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,wBAAwB,EAAE,MAAM,UAAU,CAAC;AACpD,YAAY,EAAE,WAAW,EAAE,MAAM,UAAU,CAAC;AAC5C,OAAO,EAAE,uBAAuB,EAAE,MAAM,SAAS,CAAC;AAClD,YAAY,EAAE,8BAA8B,EAAE,MAAM,SAAS,CAAC;AAC9D,mBAAmB,SAAS,CAAC"}
@@ -1,8 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.ExecutionAuthorityStore = exports.ExecutionAuthorityLedger = void 0;
4
- var ledger_1 = require("./ledger");
5
- Object.defineProperty(exports, "ExecutionAuthorityLedger", { enumerable: true, get: function () { return ledger_1.ExecutionAuthorityLedger; } });
6
- var store_1 = require("./store");
7
- Object.defineProperty(exports, "ExecutionAuthorityStore", { enumerable: true, get: function () { return store_1.ExecutionAuthorityStore; } });
8
- //# sourceMappingURL=index.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/execution-authority/index.ts"],"names":[],"mappings":";;;AAAA,mCAAoD;AAA3C,kHAAA,wBAAwB,OAAA;AAEjC,iCAAkD;AAAzC,gHAAA,uBAAuB,OAAA"}
@@ -1,85 +0,0 @@
1
- /**
2
- * In-memory execution-authority ledger (NOT-85 logic engine).
3
- * Durable SQLite wrapper: `ExecutionAuthorityStore` (NOT-86).
4
- */
5
- import type { AuditEvent, AuthorizedCallInput, ContractResult, CoordinatorEnrollment, EnrollCoordinatorResult, ExecutionAuthority, MintAuthorityInput, MintAuthorityResult } from './types';
6
- /** Serializable ledger state for durable hydrate/persist. */
7
- export type LedgerState = {
8
- enrollments: CoordinatorEnrollment[];
9
- enrollmentSecretHashes: Array<{
10
- enrollmentId: string;
11
- secretHash: string;
12
- }>;
13
- authorities: ExecutionAuthority[];
14
- secretHashes: Array<{
15
- authorityId: string;
16
- secretHash: string;
17
- }>;
18
- mintIndex: Array<{
19
- enrollmentId: string;
20
- idempotencyKey: string;
21
- authorityId: string;
22
- }>;
23
- audit: AuditEvent[];
24
- };
25
- export interface ExecutionAuthorityLedgerOptions {
26
- /** Injectable clock for expiry tests. */
27
- now?: () => Date;
28
- }
29
- /**
30
- * Deck-side authorization ledger (skeleton). Authoritative for enrollment and
31
- * execution authority; does not model Dealer run lifecycle.
32
- */
33
- export declare class ExecutionAuthorityLedger {
34
- private readonly enrollments;
35
- private readonly enrollmentSecretHashes;
36
- private readonly authorities;
37
- private readonly secretHashes;
38
- private readonly mintIndex;
39
- private readonly audit;
40
- private readonly now;
41
- constructor(options?: ExecutionAuthorityLedgerOptions);
42
- exportState(): LedgerState;
43
- replaceState(state: LedgerState): void;
44
- getEnrollment(enrollmentId: string): CoordinatorEnrollment | undefined;
45
- listEnrollments(): CoordinatorEnrollment[];
46
- verifyEnrollmentSecret(enrollmentId: string, secret: string): boolean;
47
- verifyAuthoritySecret(authorityId: string, secret: string): boolean;
48
- enrollCoordinator(input: {
49
- coordinatorId: string;
50
- allowedDeckIds: string[];
51
- }): ContractResult<EnrollCoordinatorResult>;
52
- revokeEnrollment(enrollmentId: string): ContractResult<{
53
- enrollmentId: string;
54
- }>;
55
- mintAuthority(input: MintAuthorityInput): ContractResult<MintAuthorityResult>;
56
- /**
57
- * Non-auditing lookup for ownership / existence checks.
58
- * Does not refresh expiry (avoids authority_expired side effects during probes).
59
- */
60
- peekAuthority(authorityId: string): ExecutionAuthority | undefined;
61
- inspectAuthority(authorityId: string): ContractResult<ExecutionAuthority>;
62
- revokeAuthority(authorityId: string): ContractResult<{
63
- authorityId: string;
64
- }>;
65
- /**
66
- * Simulate one authorized Deck tool call under execution authority.
67
- * Never waits for human approval — returns INTERACTION_REQUIRED immediately.
68
- */
69
- invokeAuthorizedCall(input: AuthorizedCallInput): ContractResult<{
70
- serviceId: string;
71
- toolName: string;
72
- result: string;
73
- }>;
74
- listAuditEvents(filter?: {
75
- runId?: string;
76
- attemptId?: string;
77
- authorityId?: string;
78
- enrollmentId?: string;
79
- requestId?: string;
80
- }): AuditEvent[];
81
- private toolAllowed;
82
- private refreshAuthorityStatus;
83
- private pushAudit;
84
- }
85
- //# sourceMappingURL=ledger.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"ledger.d.ts","sourceRoot":"","sources":["../../src/execution-authority/ledger.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAOH,OAAO,KAAK,EAGV,UAAU,EAEV,mBAAmB,EACnB,cAAc,EACd,qBAAqB,EACrB,uBAAuB,EACvB,kBAAkB,EAClB,kBAAkB,EAClB,mBAAmB,EACpB,MAAM,SAAS,CAAC;AAMjB,6DAA6D;AAC7D,MAAM,MAAM,WAAW,GAAG;IACxB,WAAW,EAAE,qBAAqB,EAAE,CAAC;IACrC,sBAAsB,EAAE,KAAK,CAAC;QAAE,YAAY,EAAE,MAAM,CAAC;QAAC,UAAU,EAAE,MAAM,CAAA;KAAE,CAAC,CAAC;IAC5E,WAAW,EAAE,kBAAkB,EAAE,CAAC;IAClC,YAAY,EAAE,KAAK,CAAC;QAAE,WAAW,EAAE,MAAM,CAAC;QAAC,UAAU,EAAE,MAAM,CAAA;KAAE,CAAC,CAAC;IACjE,SAAS,EAAE,KAAK,CAAC;QAAE,YAAY,EAAE,MAAM,CAAC;QAAC,cAAc,EAAE,MAAM,CAAC;QAAC,WAAW,EAAE,MAAM,CAAA;KAAE,CAAC,CAAC;IACxF,KAAK,EAAE,UAAU,EAAE,CAAC;CACrB,CAAC;AAgCF,MAAM,WAAW,+BAA+B;IAC9C,yCAAyC;IACzC,GAAG,CAAC,EAAE,MAAM,IAAI,CAAC;CAClB;AAED;;;GAGG;AACH,qBAAa,wBAAwB;IACnC,OAAO,CAAC,QAAQ,CAAC,WAAW,CAA4C;IACxE,OAAO,CAAC,QAAQ,CAAC,sBAAsB,CAA6B;IACpE,OAAO,CAAC,QAAQ,CAAC,WAAW,CAAyC;IACrE,OAAO,CAAC,QAAQ,CAAC,YAAY,CAA6B;IAC1D,OAAO,CAAC,QAAQ,CAAC,SAAS,CAA6B;IACvD,OAAO,CAAC,QAAQ,CAAC,KAAK,CAAoB;IAC1C,OAAO,CAAC,QAAQ,CAAC,GAAG,CAAa;gBAErB,OAAO,GAAE,+BAAoC;IAIzD,WAAW,IAAI,WAAW;IA0B1B,YAAY,CAAC,KAAK,EAAE,WAAW,GAAG,IAAI;IAkCtC,aAAa,CAAC,YAAY,EAAE,MAAM,GAAG,qBAAqB,GAAG,SAAS;IAMtE,eAAe,IAAI,qBAAqB,EAAE;IAO1C,sBAAsB,CAAC,YAAY,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,GAAG,OAAO;IAMrE,qBAAqB,CAAC,WAAW,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,GAAG,OAAO;IAMnE,iBAAiB,CAAC,KAAK,EAAE;QACvB,aAAa,EAAE,MAAM,CAAC;QACtB,cAAc,EAAE,MAAM,EAAE,CAAC;KAC1B,GAAG,cAAc,CAAC,uBAAuB,CAAC;IA2B3C,gBAAgB,CAAC,YAAY,EAAE,MAAM,GAAG,cAAc,CAAC;QAAE,YAAY,EAAE,MAAM,CAAA;KAAE,CAAC;IAiChF,aAAa,CAAC,KAAK,EAAE,kBAAkB,GAAG,cAAc,CAAC,mBAAmB,CAAC;IAuH7E;;;OAGG;IACH,aAAa,CAAC,WAAW,EAAE,MAAM,GAAG,kBAAkB,GAAG,SAAS;IAKlE,gBAAgB,CAAC,WAAW,EAAE,MAAM,GAAG,cAAc,CAAC,kBAAkB,CAAC;IAoBzE,eAAe,CAAC,WAAW,EAAE,MAAM,GAAG,cAAc,CAAC;QAAE,WAAW,EAAE,MAAM,CAAA;KAAE,CAAC;IAuB7E;;;OAGG;IACH,oBAAoB,CAClB,KAAK,EAAE,mBAAmB,GACzB,cAAc,CAAC;QAAE,SAAS,EAAE,MAAM,CAAC;QAAC,QAAQ,EAAE,MAAM,CAAC;QAAC,MAAM,EAAE,MAAM,CAAA;KAAE,CAAC;IA0G1E,eAAe,CAAC,MAAM,GAAE;QACtB,KAAK,CAAC,EAAE,MAAM,CAAC;QACf,SAAS,CAAC,EAAE,MAAM,CAAC;QACnB,WAAW,CAAC,EAAE,MAAM,CAAC;QACrB,YAAY,CAAC,EAAE,MAAM,CAAC;QACtB,SAAS,CAAC,EAAE,MAAM,CAAC;KACf,GAAG,UAAU,EAAE;IAYrB,OAAO,CAAC,WAAW;IAOnB,OAAO,CAAC,sBAAsB;IAgB9B,OAAO,CAAC,SAAS;CAalB"}