@squadrules/mcp 5.10.1 → 5.12.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 (132) hide show
  1. package/README.md +15 -0
  2. package/dist/.tsbuildinfo +1 -1
  3. package/dist/embed-docs/mem/README.md +34 -37
  4. package/dist/embed-docs/mem/adapter-migration.md +31 -40
  5. package/dist/embed-docs/mem/author-adapter.md +91 -229
  6. package/dist/embed-docs/mem/bulk-insert-adapters-via-cli.md +28 -44
  7. package/dist/embed-docs/mem/challenge-type-guide.md +89 -205
  8. package/dist/embed-docs/mem/critic-loop-guide.md +10 -8
  9. package/dist/embed-docs/mem/critic-loop.md +20 -41
  10. package/dist/embed-docs/mem/protocol-linking-guide.md +36 -81
  11. package/dist/embed-docs/mem/refine-search.md +10 -33
  12. package/dist/resources/embedded-mcp-resources.d.ts +0 -4
  13. package/dist/resources/embedded-mcp-resources.d.ts.map +1 -1
  14. package/dist/resources/embedded-mcp-resources.js +10 -14
  15. package/dist/resources/embedded-mcp-resources.js.map +1 -1
  16. package/dist/resources/mem-resources-boot.d.ts.map +1 -1
  17. package/dist/resources/mem-resources-boot.js +6 -1
  18. package/dist/resources/mem-resources-boot.js.map +1 -1
  19. package/dist/runtime/boot-local-runtime.d.ts.map +1 -1
  20. package/dist/runtime/boot-local-runtime.js +9 -0
  21. package/dist/runtime/boot-local-runtime.js.map +1 -1
  22. package/dist/services/forward-runtime-store.d.ts +1 -5
  23. package/dist/services/forward-runtime-store.d.ts.map +1 -1
  24. package/dist/services/forward-runtime-store.js +1 -35
  25. package/dist/services/forward-runtime-store.js.map +1 -1
  26. package/dist/services/memory/validate-protocol-structure.d.ts.map +1 -1
  27. package/dist/services/memory/validate-protocol-structure.js +73 -4
  28. package/dist/services/memory/validate-protocol-structure.js.map +1 -1
  29. package/dist/services/qdrant/memory-retrieval.d.ts.map +1 -1
  30. package/dist/services/qdrant/memory-retrieval.js +1 -2
  31. package/dist/services/qdrant/memory-retrieval.js.map +1 -1
  32. package/dist/services/vector-store/lancedb/lance-records-engine.d.ts +7 -0
  33. package/dist/services/vector-store/lancedb/lance-records-engine.d.ts.map +1 -1
  34. package/dist/services/vector-store/lancedb/lance-records-engine.js +30 -1
  35. package/dist/services/vector-store/lancedb/lance-records-engine.js.map +1 -1
  36. package/dist/services/vector-store/lancedb/lance-records-mutations.d.ts.map +1 -1
  37. package/dist/services/vector-store/lancedb/lance-records-mutations.js +4 -1
  38. package/dist/services/vector-store/lancedb/lance-records-mutations.js.map +1 -1
  39. package/dist/services/vector-store/lancedb/lance-records-reads.d.ts.map +1 -1
  40. package/dist/services/vector-store/lancedb/lance-records-reads.js +1 -2
  41. package/dist/services/vector-store/lancedb/lance-records-reads.js.map +1 -1
  42. package/dist/services/vector-store/lancedb/lance-records-search.d.ts.map +1 -1
  43. package/dist/services/vector-store/lancedb/lance-records-search.js +8 -4
  44. package/dist/services/vector-store/lancedb/lance-records-search.js.map +1 -1
  45. package/dist/services/vector-store/lancedb/lance-records-write-artifact.d.ts.map +1 -1
  46. package/dist/services/vector-store/lancedb/lance-records-write-artifact.js +3 -1
  47. package/dist/services/vector-store/lancedb/lance-records-write-artifact.js.map +1 -1
  48. package/dist/services/vector-store/lancedb/lance-records-writes.d.ts.map +1 -1
  49. package/dist/services/vector-store/lancedb/lance-records-writes.js +6 -4
  50. package/dist/services/vector-store/lancedb/lance-records-writes.js.map +1 -1
  51. package/dist/services/vector-store/lancedb/lance-store-metadata.d.ts +21 -0
  52. package/dist/services/vector-store/lancedb/lance-store-metadata.d.ts.map +1 -0
  53. package/dist/services/vector-store/lancedb/lance-store-metadata.js +69 -0
  54. package/dist/services/vector-store/lancedb/lance-store-metadata.js.map +1 -0
  55. package/dist/stdio/stdio-banner.d.ts.map +1 -1
  56. package/dist/stdio/stdio-banner.js +1 -3
  57. package/dist/stdio/stdio-banner.js.map +1 -1
  58. package/dist/tools/export.d.ts.map +1 -1
  59. package/dist/tools/export.js +39 -0
  60. package/dist/tools/export.js.map +1 -1
  61. package/dist/tools/export_schema.d.ts +12 -0
  62. package/dist/tools/export_schema.d.ts.map +1 -1
  63. package/dist/tools/export_schema.js +11 -2
  64. package/dist/tools/export_schema.js.map +1 -1
  65. package/dist/tools/forward-trace.d.ts +1 -4
  66. package/dist/tools/forward-trace.d.ts.map +1 -1
  67. package/dist/tools/forward-trace.js +1 -111
  68. package/dist/tools/forward-trace.js.map +1 -1
  69. package/dist/tools/forward-view.d.ts +0 -1
  70. package/dist/tools/forward-view.d.ts.map +1 -1
  71. package/dist/tools/forward-view.js +4 -44
  72. package/dist/tools/forward-view.js.map +1 -1
  73. package/dist/tools/forward.d.ts.map +1 -1
  74. package/dist/tools/forward.js +1 -4
  75. package/dist/tools/forward.js.map +1 -1
  76. package/dist/tools/forward_schema.d.ts +0 -46
  77. package/dist/tools/forward_schema.d.ts.map +1 -1
  78. package/dist/tools/forward_schema.js +7 -32
  79. package/dist/tools/forward_schema.js.map +1 -1
  80. package/dist/tools/next-pow-challenge-shape.d.ts.map +1 -1
  81. package/dist/tools/next-pow-challenge-shape.js +0 -7
  82. package/dist/tools/next-pow-challenge-shape.js.map +1 -1
  83. package/dist/tools/next-pow-helpers.d.ts.map +1 -1
  84. package/dist/tools/next-pow-helpers.js +0 -3
  85. package/dist/tools/next-pow-helpers.js.map +1 -1
  86. package/dist/tools/next_schema.d.ts +4 -4
  87. package/dist/tools/next_schema.js +2 -2
  88. package/dist/tools/next_schema.js.map +1 -1
  89. package/dist/tools/search_output.d.ts.map +1 -1
  90. package/dist/tools/search_output.js +0 -5
  91. package/dist/tools/search_output.js.map +1 -1
  92. package/dist/tools/shell-challenge-invocation.d.ts +8 -2
  93. package/dist/tools/shell-challenge-invocation.d.ts.map +1 -1
  94. package/dist/tools/shell-challenge-invocation.js +18 -7
  95. package/dist/tools/shell-challenge-invocation.js.map +1 -1
  96. package/dist/tools/squadrules-challenge-display.d.ts.map +1 -1
  97. package/dist/tools/squadrules-challenge-display.js +7 -9
  98. package/dist/tools/squadrules-challenge-display.js.map +1 -1
  99. package/dist/tools/tool-registry.d.ts +23 -22
  100. package/dist/tools/tool-registry.d.ts.map +1 -1
  101. package/dist/tools/train.d.ts.map +1 -1
  102. package/dist/tools/train.js +31 -0
  103. package/dist/tools/train.js.map +1 -1
  104. package/dist/tools/train_schema.d.ts +11 -0
  105. package/dist/tools/train_schema.d.ts.map +1 -1
  106. package/dist/tools/train_schema.js +13 -4
  107. package/dist/tools/train_schema.js.map +1 -1
  108. package/dist/types/memory.d.ts +4 -18
  109. package/dist/types/memory.d.ts.map +1 -1
  110. package/dist/ui/assets/{AccountPage-BpPby8tL.js → AccountPage-rmFJddfQ.js} +1 -1
  111. package/dist/ui/assets/{ProtocolDetailPage-DFe_JOr3.js → ProtocolDetailPage-kPGgNobg.js} +1 -1
  112. package/dist/ui/assets/{ProtocolEditPage-HAcAGXw7.js → ProtocolEditPage-IvFbUiUS.js} +2 -2
  113. package/dist/ui/assets/RunGuidedPage-Db_CQ-9q.js +1 -0
  114. package/dist/ui/assets/{SkillBundlePage-CiMQN0nf.js → SkillBundlePage-DV9CXjfI.js} +1 -1
  115. package/dist/ui/assets/{export-skill-zip-D8iQY1Dl.js → export-skill-zip-seCWjJSV.js} +1 -1
  116. package/dist/ui/assets/{index-cB_UoTxa.css → index-BGjXjHf7.css} +1 -1
  117. package/dist/ui/assets/{index-DLLKkKKa.js → index-D_BmxEln.js} +3 -3
  118. package/dist/ui/index.html +2 -2
  119. package/dist/utils/adapter-alias.d.ts +1 -11
  120. package/dist/utils/adapter-alias.d.ts.map +1 -1
  121. package/dist/utils/adapter-alias.js +2 -20
  122. package/dist/utils/adapter-alias.js.map +1 -1
  123. package/dist/utils/directory-access.d.ts +26 -0
  124. package/dist/utils/directory-access.d.ts.map +1 -0
  125. package/dist/utils/directory-access.js +153 -0
  126. package/dist/utils/directory-access.js.map +1 -0
  127. package/package.json +1 -3
  128. package/dist/embed-docs/mem/create-new-protocol.md +0 -44
  129. package/dist/embed-docs/mem/phase-critic-guide.md +0 -42
  130. package/dist/embed-docs/mem/phase-critic.md +0 -46
  131. package/dist/embed-docs/mem/skill-format-guide.md +0 -280
  132. package/dist/ui/assets/RunGuidedPage-Bewi7Wsx.js +0 -1
@@ -1 +0,0 @@
1
- import{r as e}from"./rolldown-runtime-hePW80VL.js";import{a as t,h as n,m as r,s as i,y as a}from"./vendor-xESPQGR9.js";import{i as o,t as s}from"./react-BvB9BS1T.js";import{t as c}from"./api-BgTb-tmJ.js";import{t as l}from"./SurfaceCard-BzJidvvn.js";import{t as u}from"./ErrorAlert-BoPXaBKG.js";import{n as d}from"./ChallengeCard-DVXo4j0b.js";import{n as f,t as p}from"./StepFlowGraph-BXsWPPO0.js";import{n as m,t as h}from"./useRunSession-CB5wPJ8O.js";var g=e(o(),1),_=s();function v(e){let t=e.trim();return t?JSON.parse(t):null}function y({contract:e,disabled:t,onSubmit:n}){let{t:r}=a(),i=e.type,[o,s]=(0,g.useState)(0),[c,l]=(0,g.useState)(``),[u,d]=(0,g.useState)(``),[f,p]=(0,g.useState)(``),m=e.mcp?.tool_name??``,[h,y]=(0,g.useState)(!0),[b,x]=(0,g.useState)(``),[S,C]=(0,g.useState)(``),w=e.user_input?.prompt??``,[T,E]=(0,g.useState)(``),D=e.comment?.min_length??10,[O,k]=(0,g.useState)(``),[A,j]=(0,g.useState)(null);(0,g.useEffect)(()=>{j(null),s(0),l(``),d(``),p(``),y(!0),x(``),C(``),E(``),k(``)},[i,m,w,D]);let M=(0,g.useMemo)(()=>i===`tensor`?f.trim().length>0:i===`shell`?Number.isFinite(o):i===`mcp`?m.trim().length>0:i===`user_input`?T.trim().length>0:i===`comment`&&O.trim().length>=D,[i,o,m,T,O,D]);return(0,_.jsxs)(`form`,{onSubmit:t=>{if(t.preventDefault(),j(null),M)try{if(i===`tensor`){let t=v(f);n({type:i,tensor:{name:e.tensor?.output.name??`tensor`,value:t}});return}if(i===`shell`){n({type:i,shell:{exit_code:o,...c.trim()?{stdout:c}:{},...u.trim()?{stderr:u}:{}}});return}if(i===`mcp`){let e=v(b),t=v(S);n({type:i,mcp:{tool_name:m,...e===null?{}:{arguments:e},result:t,success:h}});return}if(i===`user_input`){n({type:i,user_input:{confirmation:T.trim(),timestamp:new Date().toISOString()}});return}if(i===`comment`){n({type:i,comment:{text:O.trim()}});return}}catch(e){j(e instanceof Error?e.message:String(e))}},"aria-label":r(`run.solutionFormLabel`),children:[A&&(0,_.jsx)(`div`,{className:`mb-4 p-4 rounded-[var(--radius-md)] bg-[var(--color-error-bg)] text-[var(--color-error)]`,role:`alert`,children:A}),i===`shell`&&(0,_.jsxs)(`div`,{className:`space-y-4`,children:[(0,_.jsxs)(`div`,{children:[(0,_.jsx)(`label`,{htmlFor:`run-shell-exit-code`,className:`block font-medium text-[var(--color-text-heading)] mb-2`,children:r(`run.shell.exitCode`)}),(0,_.jsx)(`input`,{id:`run-shell-exit-code`,type:`number`,inputMode:`numeric`,value:o,onChange:e=>s(Number(e.target.value)),className:`w-full min-h-[44px] px-4 py-2 border border-[var(--color-border)] rounded-[var(--radius-md)] text-[var(--color-text)] bg-[var(--color-surface)] focus-visible:outline focus-visible:outline-2 focus-visible:outline-[var(--color-focus-ring)] focus-visible:outline-offset-2`,disabled:t,required:!0})]}),(0,_.jsxs)(`div`,{children:[(0,_.jsx)(`label`,{htmlFor:`run-shell-stdout`,className:`block font-medium text-[var(--color-text-heading)] mb-2`,children:r(`run.shell.stdout`)}),(0,_.jsx)(`textarea`,{id:`run-shell-stdout`,value:c,onChange:e=>l(e.target.value),className:`w-full min-h-[8rem] px-4 py-3 border border-[var(--color-border)] rounded-[var(--radius-md)] text-[var(--color-text)] bg-[var(--color-surface)] font-mono text-sm resize-y`,disabled:t})]}),(0,_.jsxs)(`div`,{children:[(0,_.jsx)(`label`,{htmlFor:`run-shell-stderr`,className:`block font-medium text-[var(--color-text-heading)] mb-2`,children:r(`run.shell.stderr`)}),(0,_.jsx)(`textarea`,{id:`run-shell-stderr`,value:u,onChange:e=>d(e.target.value),className:`w-full min-h-[6rem] px-4 py-3 border border-[var(--color-border)] rounded-[var(--radius-md)] text-[var(--color-text)] bg-[var(--color-surface)] font-mono text-sm resize-y`,disabled:t})]})]}),i===`tensor`&&(0,_.jsxs)(`div`,{className:`space-y-4`,children:[(0,_.jsxs)(`div`,{className:`rounded-[var(--radius-md)] border border-[var(--color-border)] bg-[var(--color-surface)] p-4`,children:[(0,_.jsx)(`div`,{className:`text-sm text-[var(--color-text-muted)]`,children:`Output tensor`}),(0,_.jsxs)(`div`,{className:`font-medium text-[var(--color-text-heading)]`,children:[e.tensor?.output.name??`tensor`,` (`,e.tensor?.output.type??`unknown`,`)`]}),e.tensor?.required_inputs?.length?(0,_.jsxs)(`div`,{className:`text-sm text-[var(--color-text-muted)] mt-2`,children:[`Required inputs: `,e.tensor.required_inputs.join(`, `)]}):null]}),(0,_.jsxs)(`div`,{children:[(0,_.jsx)(`label`,{htmlFor:`run-tensor-value`,className:`block font-medium text-[var(--color-text-heading)] mb-2`,children:`Tensor value (JSON)`}),(0,_.jsx)(`textarea`,{id:`run-tensor-value`,value:f,onChange:e=>p(e.target.value),placeholder:`"example string" or ["item1", "item2"]`,className:`w-full min-h-[10rem] px-4 py-3 border border-[var(--color-border)] rounded-[var(--radius-md)] text-[var(--color-text)] bg-[var(--color-surface)] font-mono text-sm resize-y`,disabled:t,required:!0})]})]}),i===`mcp`&&(0,_.jsxs)(`div`,{className:`space-y-4`,children:[(0,_.jsxs)(`div`,{className:`rounded-[var(--radius-md)] border border-[var(--color-border)] bg-[var(--color-surface)] p-4`,children:[(0,_.jsx)(`div`,{className:`text-sm text-[var(--color-text-muted)]`,children:r(`run.mcp.toolName`)}),(0,_.jsx)(`div`,{className:`font-medium text-[var(--color-text-heading)] break-all`,children:m||r(`run.mcp.toolMissing`)})]}),(0,_.jsxs)(`label`,{className:`inline-flex items-center gap-2 min-h-[44px]`,children:[(0,_.jsx)(`input`,{type:`checkbox`,checked:h,onChange:e=>y(e.target.checked),disabled:t,className:`h-4 w-4`}),(0,_.jsx)(`span`,{className:`text-sm text-[var(--color-text)]`,children:r(`run.mcp.success`)})]}),(0,_.jsxs)(`div`,{children:[(0,_.jsx)(`label`,{htmlFor:`run-mcp-args`,className:`block font-medium text-[var(--color-text-heading)] mb-2`,children:r(`run.mcp.arguments`)}),(0,_.jsx)(`textarea`,{id:`run-mcp-args`,value:b,onChange:e=>x(e.target.value),placeholder:`{ "example": true }`,className:`w-full min-h-[6rem] px-4 py-3 border border-[var(--color-border)] rounded-[var(--radius-md)] text-[var(--color-text)] bg-[var(--color-surface)] font-mono text-sm resize-y`,disabled:t})]}),(0,_.jsxs)(`div`,{children:[(0,_.jsx)(`label`,{htmlFor:`run-mcp-result`,className:`block font-medium text-[var(--color-text-heading)] mb-2`,children:r(`run.mcp.result`)}),(0,_.jsx)(`textarea`,{id:`run-mcp-result`,value:S,onChange:e=>C(e.target.value),placeholder:`{ "ok": true }`,className:`w-full min-h-[10rem] px-4 py-3 border border-[var(--color-border)] rounded-[var(--radius-md)] text-[var(--color-text)] bg-[var(--color-surface)] font-mono text-sm resize-y`,disabled:t,required:!0})]})]}),i===`user_input`&&(0,_.jsxs)(`div`,{className:`space-y-4`,children:[(0,_.jsxs)(`div`,{className:`rounded-[var(--radius-md)] border border-[var(--color-border)] bg-[var(--color-surface)] p-4`,children:[(0,_.jsx)(`div`,{className:`text-sm text-[var(--color-text-muted)]`,children:r(`run.userInput.prompt`)}),(0,_.jsx)(`div`,{className:`font-medium text-[var(--color-text-heading)]`,children:w||r(`run.userInput.promptMissing`)})]}),(0,_.jsxs)(`div`,{children:[(0,_.jsx)(`label`,{htmlFor:`run-user-confirmation`,className:`block font-medium text-[var(--color-text-heading)] mb-2`,children:r(`run.userInput.confirmation`)}),(0,_.jsx)(`textarea`,{id:`run-user-confirmation`,value:T,onChange:e=>E(e.target.value),className:`w-full min-h-[6rem] px-4 py-3 border border-[var(--color-border)] rounded-[var(--radius-md)] text-[var(--color-text)] bg-[var(--color-surface)] resize-y`,disabled:t,required:!0})]})]}),i===`comment`&&(0,_.jsxs)(`div`,{className:`space-y-2`,children:[(0,_.jsxs)(`div`,{className:`text-sm text-[var(--color-text-muted)]`,children:[r(`run.comment.minLength`,{count:D}),` · `,r(`run.comment.count`,{count:O.length})]}),(0,_.jsxs)(`div`,{children:[(0,_.jsx)(`label`,{htmlFor:`run-comment-text`,className:`block font-medium text-[var(--color-text-heading)] mb-2`,children:r(`run.comment.text`)}),(0,_.jsx)(`textarea`,{id:`run-comment-text`,value:O,onChange:e=>k(e.target.value),className:`w-full min-h-[10rem] px-4 py-3 border border-[var(--color-border)] rounded-[var(--radius-md)] text-[var(--color-text)] bg-[var(--color-surface)] resize-y`,disabled:t,required:!0,"aria-invalid":O.trim().length>0&&O.trim().length<D})]})]}),(0,_.jsx)(`button`,{type:`submit`,disabled:t||!M,className:`mt-4 min-h-[44px] min-w-[44px] px-4 py-2 rounded-[var(--radius-md)] font-medium bg-[var(--color-primary)] text-white border-0 cursor-pointer disabled:opacity-60 disabled:cursor-not-allowed hover:bg-[var(--color-primary-hover)] focus-visible:outline focus-visible:outline-2 focus-visible:outline-[var(--color-focus-ring)] focus-visible:outline-offset-2`,children:r(`run.submitStep`)})]})}function b(e){let t=e.type;if(t===`shell`){let t=e.shell?.cmd;return{type:`shell`,...t?{payload:{cmd:t}}:{}}}if(t===`mcp`){let t=e.mcp?.tool_name,n=e.mcp?.arguments,r=n!==void 0&&typeof n==`object`&&!!n&&!Array.isArray(n);return{type:`mcp`,...t||r?{payload:{...t?{tool_name:t}:{},...r?{arguments:n}:{}}}:{}}}if(t===`user_input`){let t=e.user_input?.prompt;return{type:`user_input`,...t?{payload:{prompt:t}}:{}}}if(t===`comment`){let t=e.comment?.min_length;return{type:`comment`,...t==null?{}:{payload:{min_length:t}}}}return{type:t}}function x(e,t){let n=e.history.length,r=e.status===`running`,i=!!e.current_layer,a=e.status===`ready_to_reward`||e.status===`completed`||e.status===`error`,o=a?Math.max(n,1):Math.max(n+(r&&i?1:0),+!!r)||1;return{flowSteps:Array.from({length:o},(e,n)=>({label:t(n+1)})),currentFlowIndex:r&&i?n:void 0,displayCurrent:r&&i?n+1:a?o:Math.max(n,1),displayTotal:o}}function S({run:e,rewardOutcome:t,setRewardOutcome:n,rewardFeedback:r,setRewardFeedback:i,copyStatus:o,onCopy:s,onSubmitStep:c,onReward:l,isForwardStepPending:u,isForwardStartPending:m,isRewardPending:h}){let{t:g}=a(),{flowSteps:v,currentFlowIndex:S,displayCurrent:C,displayTotal:w}=x(e,e=>g(`run.flowStepN`,{n:e})),T=b(e.contract);return(0,_.jsxs)(_.Fragment,{children:[(0,_.jsxs)(`section`,{className:`mb-6`,"aria-labelledby":`run-flow-heading`,children:[(0,_.jsx)(`h2`,{id:`run-flow-heading`,className:`mb-2 text-lg font-semibold text-[var(--color-text-heading)]`,children:g(`run.progressHeading`)}),(0,_.jsx)(p,{steps:v,currentIndex:S})]}),(0,_.jsxs)(`div`,{className:`mb-4 flex flex-wrap items-center gap-2 text-sm text-[var(--color-text-muted)]`,role:`status`,children:[(0,_.jsx)(`span`,{className:`font-medium text-[var(--color-text-heading)]`,children:g(`run.stepProgress`,{current:C,total:w})}),(0,_.jsx)(`span`,{"aria-hidden":!0,children:`·`}),(0,_.jsx)(`span`,{children:g(`run.sessionBadge`)})]}),e.last_message&&(0,_.jsxs)(`div`,{className:`mb-4 rounded-[var(--radius-md)] border border-[var(--color-border)] bg-[var(--color-surface)] p-4`,role:`status`,"aria-live":`polite`,children:[(0,_.jsx)(`div`,{className:`text-sm text-[var(--color-text-muted)]`,children:g(`run.serverMessage`)}),(0,_.jsx)(`div`,{className:`text-[var(--color-text)]`,children:e.last_message})]}),(0,_.jsxs)(`section`,{"aria-labelledby":`run-current-step`,className:`mb-6`,children:[(0,_.jsx)(`h2`,{id:`run-current-step`,className:`mb-2 text-lg font-semibold text-[var(--color-text-heading)]`,children:g(`run.currentStepHeading`)}),(0,_.jsx)(`div`,{className:`rounded-[var(--radius-md)] border border-[var(--color-border)] bg-[var(--color-surface-elevated)] p-4`,children:e.current_layer?(0,_.jsxs)(_.Fragment,{children:[(0,_.jsxs)(`div`,{className:`mb-2 text-sm text-[var(--color-text-muted)]`,children:[g(`run.layerUri`),`: `,(0,_.jsx)(`span`,{className:`font-mono break-all`,children:e.current_layer.uri})]}),e.current_layer.content?(0,_.jsx)(`div`,{className:`prose prose-sm max-w-none text-[var(--color-text)]`,children:(0,_.jsx)(f,{content:e.current_layer.content})}):(0,_.jsx)(`p`,{className:`m-0 text-sm text-[var(--color-text-muted)]`,children:g(`run.noLayerContent`)})]}):(0,_.jsx)(`p`,{className:`m-0 text-sm text-[var(--color-text-muted)]`,children:g(`run.noLayerContent`)})})]}),(0,_.jsxs)(`section`,{"aria-labelledby":`run-challenge`,className:`mb-6`,children:[(0,_.jsx)(`h2`,{id:`run-challenge`,className:`mb-2 text-lg font-semibold text-[var(--color-text-heading)]`,children:g(`run.challengeHeading`)}),(0,_.jsx)(d,{type:T.type,payload:T.payload}),e.contract.type===`shell`&&e.contract.shell?.cmd&&(0,_.jsxs)(`div`,{className:`mt-2`,children:[(0,_.jsx)(`button`,{type:`button`,onClick:()=>s(e.contract.shell.cmd),className:`min-h-[44px] min-w-[44px] rounded-[var(--radius-md)] border border-[var(--color-border)] bg-[var(--color-surface)] px-4 py-2 text-sm font-medium text-[var(--color-text)] hover:bg-[var(--color-surface-elevated)] focus-visible:outline focus-visible:outline-2 focus-visible:outline-[var(--color-focus-ring)] focus-visible:outline-offset-2`,children:g(`run.copyShellCommand`)}),o?(0,_.jsx)(`div`,{className:`mt-2 text-xs text-[var(--color-text-muted)]`,children:o}):null]}),(0,_.jsxs)(`details`,{className:`mt-4 text-sm`,children:[(0,_.jsx)(`summary`,{className:`cursor-pointer text-[var(--color-primary)]`,children:g(`run.advanced`)}),(0,_.jsxs)(`div`,{className:`mt-2 space-y-2 text-[var(--color-text-muted)]`,children:[(0,_.jsxs)(`div`,{children:[(0,_.jsx)(`span`,{className:`text-[var(--color-text-muted)]`,children:g(`run.contractType`)}),`:`,` `,(0,_.jsx)(`span`,{className:`font-medium text-[var(--color-text-heading)]`,children:e.contract.type})]}),e.contract.description&&(0,_.jsx)(`p`,{className:`m-0 text-sm`,children:e.contract.description}),e.contract.nonce&&(0,_.jsxs)(`div`,{children:[g(`run.nonce`),`: `,(0,_.jsx)(`span`,{className:`font-mono break-all`,children:e.contract.nonce})]}),e.contract.proof_hash&&(0,_.jsxs)(`div`,{children:[g(`run.proofHash`),`: `,(0,_.jsx)(`span`,{className:`font-mono break-all`,children:e.contract.proof_hash})]}),e.previous_proof_hash&&(0,_.jsxs)(`div`,{children:[g(`run.previousProofHash`),`: `,(0,_.jsx)(`span`,{className:`font-mono break-all`,children:e.previous_proof_hash})]})]})]}),e.contract.type===`tensor`&&(0,_.jsxs)(`div`,{className:`mt-4 rounded-[var(--radius-md)] border border-[var(--color-border)] bg-[var(--color-surface)] p-4`,children:[(0,_.jsx)(`div`,{className:`text-sm text-[var(--color-text-muted)]`,children:`Tensor output`}),(0,_.jsxs)(`div`,{className:`font-medium text-[var(--color-text-heading)]`,children:[e.contract.tensor?.output.name??`tensor`,` (`,e.contract.tensor?.output.type??`unknown`,`)`]}),e.contract.tensor?.required_inputs?.length?(0,_.jsxs)(`div`,{className:`mt-2 text-sm text-[var(--color-text-muted)]`,children:[`Required inputs: `,e.contract.tensor.required_inputs.join(`, `)]}):null]})]}),e.status!==`completed`&&e.status!==`ready_to_reward`&&(0,_.jsxs)(`section`,{"aria-labelledby":`run-solution`,className:`mb-6`,children:[(0,_.jsx)(`h2`,{id:`run-solution`,className:`mb-2 text-lg font-semibold text-[var(--color-text-heading)]`,children:g(`run.solution`)}),(0,_.jsx)(`div`,{className:`rounded-[var(--radius-md)] border border-[var(--color-border)] bg-[var(--color-surface-elevated)] p-4`,children:(0,_.jsx)(y,{contract:e.contract,disabled:u||m,onSubmit:c})})]}),e.status===`ready_to_reward`&&(0,_.jsxs)(`section`,{"aria-labelledby":`run-reward`,className:`mb-6`,children:[(0,_.jsx)(`h2`,{id:`run-reward`,className:`mb-2 text-lg font-semibold text-[var(--color-text-heading)]`,children:g(`run.reward.title`)}),(0,_.jsxs)(`div`,{className:`rounded-[var(--radius-md)] border border-[var(--color-border)] bg-[var(--color-surface-elevated)] p-4`,children:[(0,_.jsx)(`div`,{className:`mb-4 text-sm text-[var(--color-text-muted)]`,children:g(`run.reward.subtitle`)}),(0,_.jsxs)(`div`,{className:`mb-4 flex flex-wrap gap-4`,role:`radiogroup`,"aria-label":g(`run.reward.outcomeLabel`),children:[(0,_.jsxs)(`label`,{className:`inline-flex min-h-[44px] items-center gap-2`,children:[(0,_.jsx)(`input`,{type:`radio`,name:`reward-outcome`,value:`success`,checked:t===`success`,onChange:()=>n(`success`)}),(0,_.jsx)(`span`,{className:`text-sm text-[var(--color-text)]`,children:g(`run.reward.success`)})]}),(0,_.jsxs)(`label`,{className:`inline-flex min-h-[44px] items-center gap-2`,children:[(0,_.jsx)(`input`,{type:`radio`,name:`reward-outcome`,value:`failure`,checked:t===`failure`,onChange:()=>n(`failure`)}),(0,_.jsx)(`span`,{className:`text-sm text-[var(--color-text)]`,children:g(`run.reward.failure`)})]})]}),(0,_.jsxs)(`div`,{className:`mb-4`,children:[(0,_.jsx)(`label`,{htmlFor:`run-reward-feedback`,className:`mb-2 block font-medium text-[var(--color-text-heading)]`,children:g(`run.reward.feedback`)}),(0,_.jsx)(`textarea`,{id:`run-reward-feedback`,value:r,onChange:e=>i(e.target.value),className:`min-h-[8rem] w-full resize-y rounded-[var(--radius-md)] border border-[var(--color-border)] bg-[var(--color-surface)] px-4 py-3 text-[var(--color-text)] focus-visible:outline focus-visible:outline-2 focus-visible:outline-[var(--color-focus-ring)] focus-visible:outline-offset-2`})]}),(0,_.jsx)(`button`,{type:`button`,onClick:l,disabled:h,className:`min-h-[44px] min-w-[44px] cursor-pointer rounded-[var(--radius-md)] border-0 bg-[var(--color-primary)] px-4 py-2 font-medium text-white hover:bg-[var(--color-primary-hover)] focus-visible:outline focus-visible:outline-2 focus-visible:outline-[var(--color-focus-ring)] focus-visible:outline-offset-2 disabled:cursor-not-allowed disabled:opacity-60`,children:g(h?`run.reward.submitting`:`run.reward.submit`)})]})]}),e.history.length>0&&(0,_.jsxs)(`section`,{"aria-labelledby":`run-history`,className:`mb-6`,children:[(0,_.jsx)(`h2`,{id:`run-history`,className:`mb-2 text-lg font-semibold text-[var(--color-text-heading)]`,children:g(`run.history`)}),(0,_.jsx)(`ul`,{className:`m-0 list-none space-y-2 p-0`,"aria-label":g(`run.historyLabel`),children:e.history.slice().reverse().map((e,t)=>(0,_.jsxs)(`li`,{className:`rounded-[var(--radius-md)] border border-[var(--color-border)] bg-[var(--color-surface-elevated)] p-4`,children:[(0,_.jsxs)(`div`,{className:`text-sm text-[var(--color-text-muted)]`,children:[new Date(e.submitted_at).toLocaleString(),` · `,e.contract.type,` ·`,` `,(0,_.jsx)(`span`,{className:`font-mono break-all`,children:e.layer.uri})]}),e.server_message&&(0,_.jsx)(`div`,{className:`mt-1 text-sm text-[var(--color-text)]`,children:e.server_message})]},`${e.layer.uri}:${t}`))})]}),e.status===`completed`&&(0,_.jsxs)(`div`,{className:`rounded-[var(--radius-md)] border border-[var(--color-border)] bg-[var(--status-success-bg)] p-4 text-[var(--status-success-fg)]`,children:[(0,_.jsx)(`strong`,{className:`block`,children:g(`run.completed`)}),e.last_message&&(0,_.jsx)(`div`,{className:`mt-1 text-sm`,children:e.last_message})]})]})}async function C(e){let t=await c(`/api/forward`,{method:`POST`,body:JSON.stringify({uri:e})});if(!t.ok){let e=await t.json().catch(()=>({}));throw Error(e.message??t.statusText)}return await t.json()}function w(){return n({mutationFn:e=>C(e)})}async function T(e){let t=await c(`/api/forward`,{method:`POST`,body:JSON.stringify(e)});if(!t.ok){let e=await t.json().catch(()=>({}));throw Error(e.message??t.statusText)}return await t.json()}function E(){return n({mutationFn:e=>T(e)})}async function D(e){let t=await c(`/api/reward`,{method:`POST`,body:JSON.stringify(e)});if(!t.ok){let e=await t.json().catch(()=>({}));throw Error(e.message??t.statusText)}return await t.json()}function O(){return n({mutationFn:e=>D(e)})}function k(e){if(e)return e.match(/squadrules:\/\/layer\/[0-9a-fA-F-]{36}(?:\?execution_id=[0-9a-fA-F-]{36})?/)?.[0]}function A(){return new Date().toISOString()}function j(){let{t:e}=a(),{uri:n}=r(),[o]=i(),s=n?decodeURIComponent(n):void 0,c=o.get(`session`),{session:d}=h(c),{upsert:f}=m(),p=w(),v=E(),y=O(),[b,x]=(0,g.useState)(null),[C,T]=(0,g.useState)(`success`),[D,j]=(0,g.useState)(``),[M,N]=(0,g.useState)(null);(0,g.useEffect)(()=>{d&&!b&&(x(d),T(`success`),j(``))},[d,b]);let P=e=>{x(e),f(e)},F=async()=>{if(s)try{let e=await p.mutateAsync(s),t=A(),n=`${s}:${t}`,r=e.next_action?.includes(`reward`)?`ready_to_reward`:`running`,i=k(e.next_action);P({id:n,adapter_uri:s,started_at:t,updated_at:t,status:r,current_layer:e.current_layer??null,contract:e.contract,next_action:e.next_action,last_message:e.message,previous_proof_hash:e.proof_hash,reward_uri:r===`ready_to_reward`?i:void 0,history:[]})}catch{x(null)}};return s?(0,_.jsxs)(`div`,{children:[(0,_.jsx)(`h1`,{className:`text-[var(--color-text-heading)] text-2xl font-semibold mb-1`,children:e(`run.title`)}),(0,_.jsx)(`p`,{className:`mb-4 text-sm text-[var(--color-text-muted)]`,children:e(`run.guidedIntro`)}),(0,_.jsxs)(`p`,{className:`mb-4 text-sm text-[var(--color-text-muted)]`,children:[e(`run.adapterUri`),`: `,(0,_.jsx)(`span`,{className:`font-mono break-all`,children:s})]}),(0,_.jsxs)(`div`,{className:`flex flex-wrap gap-2 mb-6`,children:[(0,_.jsx)(t,{to:`/protocols/${encodeURIComponent(s)}`,className:`min-h-[44px] min-w-[44px] inline-flex items-center justify-center px-4 py-2 rounded-[var(--radius-md)] font-medium border border-[var(--color-border)] text-[var(--color-text)] no-underline hover:bg-[var(--color-surface-elevated)] focus-visible:outline focus-visible:outline-2 focus-visible:outline-[var(--color-focus-ring)] focus-visible:outline-offset-2`,children:e(`run.backToProtocol`)}),!b&&(0,_.jsx)(`button`,{type:`button`,onClick:F,disabled:p.isPending,className:`min-h-[44px] min-w-[44px] px-4 py-2 rounded-[var(--radius-md)] font-medium bg-[var(--color-primary)] text-white border-0 cursor-pointer disabled:opacity-60 disabled:cursor-not-allowed hover:bg-[var(--color-primary-hover)] focus-visible:outline focus-visible:outline-2 focus-visible:outline-[var(--color-focus-ring)] focus-visible:outline-offset-2`,children:p.isPending?e(`run.starting`):e(`run.start`)})]}),(0,_.jsx)(l,{className:`mb-6`,title:e(`run.safety.title`),children:(0,_.jsx)(`p`,{className:`m-0 text-sm text-[var(--color-text-muted)]`,children:e(`run.safety.copy`)})}),p.isError&&(0,_.jsx)(u,{message:p.error instanceof Error?p.error.message:String(p.error),onRetry:()=>F(),showGoBack:!0}),b?.status===`error`&&b.last_message&&(0,_.jsx)(`div`,{className:`mb-6`,children:(0,_.jsx)(u,{message:b.last_message,onRetry:()=>F(),showGoBack:!0})}),b&&b.status!==`error`&&(0,_.jsx)(S,{run:b,rewardOutcome:C,setRewardOutcome:T,rewardFeedback:D,setRewardFeedback:j,copyStatus:M,onCopy:async t=>{N(null);try{await navigator.clipboard.writeText(t),N(e(`run.copied`)),setTimeout(()=>N(null),1500)}catch(e){N(e instanceof Error?e.message:String(e))}},onSubmitStep:async e=>{if(!b?.current_layer)return;let t=b.contract.nonce,n=b.previous_proof_hash??b.contract.proof_hash,r={...e,...t?{nonce:t}:{},...n?{proof_hash:n}:{}};try{let e=await v.mutateAsync({uri:b.current_layer.uri,solution:r}),t=A(),n=e.next_action?.includes(`reward`)||(e.message?.toLowerCase().includes(`call reward`)??!1),i=k(e.next_action)??b.reward_uri;P({...b,updated_at:t,status:n?`ready_to_reward`:`running`,current_layer:e.current_layer??null,contract:e.contract,next_action:e.next_action,last_message:e.message,previous_proof_hash:e.proof_hash??b.previous_proof_hash,reward_uri:n?i:void 0,history:[...b.history,{layer:b.current_layer,contract:b.contract,solution:r,submitted_at:t,proof_hash:e.proof_hash,server_message:e.message}]})}catch(e){P({...b,updated_at:A(),status:`error`,last_message:e instanceof Error?e.message:String(e)})}},onReward:async()=>{if(!b)return;let t=b.reward_uri??b.current_layer?.uri;if(t)try{let n=await y.mutateAsync({uri:t,outcome:C,feedback:D.trim()||e(`run.reward.defaultFeedback`)});P({...b,updated_at:A(),status:`completed`,last_message:n.results[0]?.feedback??b.last_message})}catch(e){P({...b,updated_at:A(),status:`error`,last_message:e instanceof Error?e.message:String(e)})}},isForwardStepPending:v.isPending,isForwardStartPending:p.isPending,isRewardPending:y.isPending})]}):(0,_.jsx)(u,{message:e(`run.missingUri`),showGoBack:!0})}export{j as RunGuidedPage};