@squadrules/mcp 5.2.0 → 5.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (92) hide show
  1. package/README.md +66 -318
  2. package/dist/.tsbuildinfo +1 -1
  3. package/dist/cli/commands/serve.js +2 -2
  4. package/dist/cli/commands/serve.js.map +1 -1
  5. package/dist/cli/index.js +6 -0
  6. package/dist/cli/index.js.map +1 -1
  7. package/dist/config/embedding-fastembed.d.ts +4 -3
  8. package/dist/config/embedding-fastembed.d.ts.map +1 -1
  9. package/dist/config/embedding-fastembed.js +6 -5
  10. package/dist/config/embedding-fastembed.js.map +1 -1
  11. package/dist/embed-docs/mem/adapter-migration.md +1 -1
  12. package/dist/embed-docs/mem/bulk-insert-adapters-via-cli.md +1 -1
  13. package/dist/embed-docs/mem/challenge-type-guide.md +1 -1
  14. package/dist/embed-docs/mem/create-new-protocol.md +1 -1
  15. package/dist/embed-docs/mem/phase-critic-guide.md +1 -1
  16. package/dist/embed-docs/mem/phase-critic.md +1 -1
  17. package/dist/embed-docs/mem/protocol-linking-guide.md +1 -1
  18. package/dist/embed-docs/mem/refine-search.md +1 -1
  19. package/dist/embed-docs/mem/skill-format-guide.md +1 -1
  20. package/dist/index.d.ts.map +1 -1
  21. package/dist/index.js +12 -15
  22. package/dist/index.js.map +1 -1
  23. package/dist/resources/docs-resources.js +1 -1
  24. package/dist/resources/docs-resources.js.map +1 -1
  25. package/dist/resources/embedded-mcp-resources.js +9 -9
  26. package/dist/resources/mem-dir-utils.js +3 -3
  27. package/dist/resources/mem-dir-utils.js.map +1 -1
  28. package/dist/resources/mem-resources-boot.d.ts +1 -1
  29. package/dist/resources/mem-resources-boot.js +13 -13
  30. package/dist/resources/mem-resources-boot.js.map +1 -1
  31. package/dist/resources/mem-uuid-mapper.js +1 -1
  32. package/dist/resources/mem-uuid-mapper.js.map +1 -1
  33. package/dist/resources/prompt-resources.d.ts +3 -1
  34. package/dist/resources/prompt-resources.d.ts.map +1 -1
  35. package/dist/resources/prompt-resources.js +16 -2
  36. package/dist/resources/prompt-resources.js.map +1 -1
  37. package/dist/services/embedding/audit.js +1 -1
  38. package/dist/services/embedding/audit.js.map +1 -1
  39. package/dist/services/embedding/provider-audit.js +1 -1
  40. package/dist/services/embedding/provider-audit.js.map +1 -1
  41. package/dist/services/key-value-store-factory.d.ts.map +1 -1
  42. package/dist/services/key-value-store-factory.js +3 -0
  43. package/dist/services/key-value-store-factory.js.map +1 -1
  44. package/dist/services/oidc-state-store.js +2 -2
  45. package/dist/services/oidc-state-store.js.map +1 -1
  46. package/dist/services/redis-cache.js +1 -1
  47. package/dist/services/redis-cache.js.map +1 -1
  48. package/dist/services/stats/model-stats.js +2 -2
  49. package/dist/services/stats/model-stats.js.map +1 -1
  50. package/dist/services/vector-store/lancedb/LanceVectorRecordStore.js +1 -1
  51. package/dist/services/vector-store/lancedb/LanceVectorRecordStore.js.map +1 -1
  52. package/dist/services/vector-store/lancedb/lance-records-writes.js +1 -1
  53. package/dist/services/vector-store/lancedb/lance-records-writes.js.map +1 -1
  54. package/dist/stdio/stdio-server.d.ts.map +1 -1
  55. package/dist/stdio/stdio-server.js +1 -3
  56. package/dist/stdio/stdio-server.js.map +1 -1
  57. package/dist/ui/assets/{AccountPage-Ci29Zidn.js → AccountPage-DhaO-G9K.js} +1 -1
  58. package/dist/ui/assets/{ChallengeCard-gY-n7rwI.js → ChallengeCard-DVXo4j0b.js} +1 -1
  59. package/dist/ui/assets/{ErrorAlert-BQMph5Nh.js → ErrorAlert-BoPXaBKG.js} +1 -1
  60. package/dist/ui/assets/{HomePage-B06u5RCw.js → HomePage-B--ESwM9.js} +1 -1
  61. package/dist/ui/assets/{NotFoundPage-Dz-PKC4R.js → NotFoundPage-bTE_mpMC.js} +1 -1
  62. package/dist/ui/assets/{ProtocolDetailPage-DCw5D34S.js → ProtocolDetailPage-DFe_JOr3.js} +1 -1
  63. package/dist/ui/assets/{ProtocolEditPage-mChBe3JY.js → ProtocolEditPage-HAcAGXw7.js} +2 -2
  64. package/dist/ui/assets/{RichTextEditor-Bj6JxHM5.js → RichTextEditor-DWLV579w.js} +1 -1
  65. package/dist/ui/assets/{RunGuidedPage-Bd1bUTBH.js → RunGuidedPage-Bewi7Wsx.js} +1 -1
  66. package/dist/ui/assets/{RunsPage-4kDF_Ylg.js → RunsPage-BSgcu2TO.js} +1 -1
  67. package/dist/ui/assets/{SkillBundlePage-D1OPKJzA.js → SkillBundlePage-CiMQN0nf.js} +1 -1
  68. package/dist/ui/assets/{SpaceSelect-DDhPkDXU.js → SpaceSelect-D3al0TgQ.js} +1 -1
  69. package/dist/ui/assets/{SquadrulesPage-D84vIaBc.js → SquadrulesPage-C37VEZnc.js} +1 -1
  70. package/dist/ui/assets/{StepFlowGraph-DsL5lsIq.js → StepFlowGraph-BXsWPPO0.js} +1 -1
  71. package/dist/ui/assets/{SurfaceCard-CRidnDLP.js → SurfaceCard-BzJidvvn.js} +1 -1
  72. package/dist/ui/assets/{export-skill-zip-C1bRyhE2.js → export-skill-zip-D8iQY1Dl.js} +1 -1
  73. package/dist/ui/assets/{index-BD4O80zW.js → index-BtwABqCT.js} +3 -3
  74. package/dist/ui/assets/react-BvB9BS1T.js +9 -0
  75. package/dist/ui/assets/tiptap-CCr8bvo1.js +204 -0
  76. package/dist/ui/assets/{useRunSession-BX2U9D53.js → useRunSession-CB5wPJ8O.js} +1 -1
  77. package/dist/ui/assets/vendor-xESPQGR9.js +31 -0
  78. package/dist/ui/index.html +4 -4
  79. package/dist/utils/concurrency-limit.d.ts.map +1 -1
  80. package/dist/utils/concurrency-limit.js +3 -8
  81. package/dist/utils/concurrency-limit.js.map +1 -1
  82. package/dist/utils/log-core.d.ts.map +1 -1
  83. package/dist/utils/log-core.js +3 -1
  84. package/dist/utils/log-core.js.map +1 -1
  85. package/dist/utils/squadrules-user-dirs.d.ts +6 -8
  86. package/dist/utils/squadrules-user-dirs.d.ts.map +1 -1
  87. package/dist/utils/squadrules-user-dirs.js +10 -9
  88. package/dist/utils/squadrules-user-dirs.js.map +1 -1
  89. package/package.json +52 -50
  90. package/dist/ui/assets/react-CR5VJ85Q.js +0 -9
  91. package/dist/ui/assets/tiptap-74Cp-fci.js +0 -204
  92. package/dist/ui/assets/vendor-DGTQ2S8W.js +0 -31
@@ -1,5 +1,5 @@
1
- import{r as e}from"./rolldown-runtime-hePW80VL.js";import{a as t,m as n,p as r,t as i,y as a}from"./vendor-DGTQ2S8W.js";import{i as o,t as s}from"./react-CR5VJ85Q.js";import{t as c}from"./api-BgTb-tmJ.js";import{r as l,t as u}from"./SpaceSelect-DDhPkDXU.js";import{t as d}from"./SurfaceCard-CRidnDLP.js";import{a as f,i as p,n as m,o as h,r as g,s as _,t as v}from"./export-skill-zip-C1bRyhE2.js";import{t as y}from"./ChallengeCard-gY-n7rwI.js";import{t as b}from"./RichTextEditor-Bj6JxHM5.js";var x=e(o(),1),S=i().min(1,`Protocol content is required`).refine(e=>e.includes(`# `),`Protocol must have an H1 title`).refine(e=>/(^|\n)##\s+Activation Patterns\b/i.test(e),`Include an "Activation Patterns" section (H2)`).refine(e=>/(^|\n)##\s+Reward Signal\b/i.test(e),`Include a "Reward Signal" section (H2)`),C={label:`Step`,bodyMarkdown:`What the user or agent does in this step.`,type:`comment`,comment:{min_length:10}},w=[`shell`,`mcp`,`user_input`,`comment`],T=/^squadrules:\/\/adapter\/[a-z0-9](?:[a-z0-9-]*[a-z0-9])?$/i,E=s();function D({t:e,fileInputRef:n,onUpload:r,isNew:i,decodedUri:a}){return(0,E.jsx)(d,{className:`mb-8`,title:e(`protocolEdit.importCardTitle`),subtitle:e(`protocolEdit.uploadHint`),children:(0,E.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[(0,E.jsx)(`input`,{ref:n,type:`file`,accept:`.md,text/markdown`,onChange:r,className:`sr-only`,id:`protocol-upload`,"aria-label":e(`protocolEdit.upload`)}),(0,E.jsx)(`button`,{type:`button`,onClick:()=>n.current?.click(),className:`min-h-[44px] min-w-[44px] inline-flex items-center justify-center 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:e(`protocolEdit.upload`)}),!i&&a&&(0,E.jsx)(t,{to:`/protocols/${encodeURIComponent(a)}/skill`,className:`min-h-[44px] min-w-[44px] inline-flex items-center justify-center 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)] 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(`protocol.editAsSkill`)})]})})}function O({t:e,preview:n,skillFolderSlug:r,isNew:i,decodedUri:a}){let[o,s]=(0,x.useState)(!1),[c,l]=(0,x.useState)(null);return(0,E.jsxs)(`div`,{className:`space-y-4`,"aria-label":e(`protocolEdit.previewLabel`),children:[(0,E.jsxs)(d,{title:e(`protocolEdit.previewRenderedTitle`),subtitle:e(`protocolEdit.previewRenderedSubtitle`),children:[(0,E.jsx)(`div`,{className:`text-lg font-semibold text-[var(--color-text-heading)]`,children:n.title}),(0,E.jsx)(`div`,{className:`mt-3 space-y-3`,children:n.steps.length===0?(0,E.jsx)(`div`,{className:`text-sm text-[var(--color-text-muted)]`,children:e(`protocolEdit.previewNoSteps`)}):n.steps.slice(0,20).map((t,n)=>(0,E.jsxs)(`div`,{className:`rounded-[var(--radius-sm)] border border-[var(--color-border)] bg-[var(--color-surface)] p-3`,children:[(0,E.jsx)(`div`,{className:`font-medium text-[var(--color-text-heading)]`,children:e(`protocolEdit.previewStepLine`,{n:n+1,label:t.label})}),(0,E.jsx)(`div`,{className:`mt-1 text-sm text-[var(--color-text-muted)]`,children:y[t.type]??t.type})]},`${t.label}:${n}`))}),(0,E.jsxs)(`div`,{className:`mt-4 border-t border-[var(--color-border)] pt-4 text-sm text-[var(--color-text-muted)]`,children:[(0,E.jsxs)(`div`,{children:[(0,E.jsxs)(`strong`,{className:`text-[var(--color-text-heading)]`,children:[e(`protocol.triggers`),`:`]}),` `,n.triggers?e(`protocolEdit.present`):e(`protocolEdit.missing`)]}),(0,E.jsxs)(`div`,{className:`mt-1`,children:[(0,E.jsxs)(`strong`,{className:`text-[var(--color-text-heading)]`,children:[e(`protocol.completion`),`:`]}),` `,n.completion?e(`protocolEdit.present`):e(`protocolEdit.missing`)]})]})]}),!i&&a?(0,E.jsxs)(d,{title:e(`protocolEdit.skillShortcutTitle`),subtitle:e(`protocolEdit.skillShortcutSubtitle`),children:[(0,E.jsxs)(`div`,{className:`rounded-[var(--radius-md)] border border-[var(--color-border)] bg-[var(--color-surface)] p-3`,children:[(0,E.jsxs)(`div`,{className:`font-medium text-[var(--color-text-heading)]`,children:[r,`-skill/`]}),(0,E.jsxs)(`div`,{className:`mt-2 font-mono text-sm text-[var(--color-text-muted)]`,children:[`Skill.md`,(0,E.jsx)(`br`,{}),`references/`,(0,E.jsx)(`br`,{}),`\xA0\xA0SQUADRULES.md`]})]}),(0,E.jsxs)(`div`,{className:`mt-3 flex flex-wrap gap-2`,children:[(0,E.jsx)(t,{to:`/protocols/${encodeURIComponent(a)}/skill`,className:`min-h-[44px] min-w-[44px] inline-flex items-center justify-center 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)] 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(`protocol.editAsSkill`)}),(0,E.jsx)(`button`,{type:`button`,disabled:o,onClick:()=>{(async()=>{if(a){l(null),s(!0);try{let{blob:e,skill_bundle_manifest:t}=await v(a),n=m(t,r);g(e,n)}catch(e){l(e instanceof Error?e.message:String(e))}finally{s(!1)}}})()},className:`min-h-[44px] min-w-[44px] inline-flex items-center justify-center rounded-[var(--radius-md)] bg-[var(--color-primary)] px-4 py-2 text-sm 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:opacity-60`,children:e(`protocol.downloadAsSkill`)}),c?(0,E.jsx)(`p`,{className:`mt-2 m-0 text-xs text-[var(--color-error)]`,role:`alert`,children:c}):null]})]}):null]})}function k({t:e,isNew:t,spaces:n,spacesLoading:r,targetSpace:i,setTargetSpace:a,forkSourceUri:o,setForkSourceUri:s,moveSpace:c,setMoveSpace:l}){return(0,E.jsx)(`section`,{className:`mb-8 space-y-5 rounded-[var(--radius-md)] border border-[var(--color-border)] bg-[var(--color-surface-elevated)] p-5`,children:t?(0,E.jsxs)(E.Fragment,{children:[(0,E.jsxs)(`div`,{children:[(0,E.jsx)(`label`,{htmlFor:`protocol-target-space`,className:`mb-2 block font-medium text-[var(--color-text-heading)]`,children:e(`protocolEdit.targetSpaceLabel`)}),(0,E.jsx)(u,{id:`protocol-target-space`,spaces:n,value:i,onChange:a,disabled:r}),(0,E.jsx)(`p`,{className:`mt-2 text-sm text-[var(--color-text-muted)]`,children:e(`protocolEdit.targetSpaceHint`)})]}),(0,E.jsxs)(`div`,{children:[(0,E.jsx)(`label`,{htmlFor:`protocol-fork-source`,className:`mb-2 block font-medium text-[var(--color-text-heading)]`,children:e(`protocolEdit.forkSourceLabel`)}),(0,E.jsx)(`input`,{id:`protocol-fork-source`,type:`text`,value:o,onChange:e=>s(e.target.value),placeholder:e(`protocolEdit.forkSourcePlaceholder`),autoComplete:`off`,className:`min-h-[44px] w-full max-w-2xl rounded-[var(--radius-md)] border border-[var(--color-border)] bg-[var(--color-surface)] px-4 py-3 text-sm text-[var(--color-text)] focus-visible:outline focus-visible:outline-2 focus-visible:outline-[var(--color-focus-ring)] focus-visible:outline-offset-2`}),(0,E.jsx)(`p`,{className:`mt-2 text-sm text-[var(--color-text-muted)]`,children:e(`protocolEdit.forkSourceHint`)})]})]}):(0,E.jsxs)(`div`,{children:[(0,E.jsx)(`label`,{htmlFor:`protocol-move-space`,className:`mb-2 block font-medium text-[var(--color-text-heading)]`,children:e(`protocolEdit.moveSpaceLabel`)}),(0,E.jsx)(u,{id:`protocol-move-space`,spaces:n,value:c,onChange:l,disabled:r}),(0,E.jsx)(`p`,{className:`mt-2 text-sm text-[var(--color-text-muted)]`,children:e(`protocolEdit.moveSpaceHint`)})]})})}var A=`min-h-[44px] w-full rounded-[var(--radius-md)] border border-[var(--color-border)] bg-[var(--color-surface)] px-4 py-3 text-sm text-[var(--color-text)] focus-visible:outline focus-visible:outline-2 focus-visible:outline-[var(--color-focus-ring)] focus-visible:outline-offset-2`,j=`min-h-[44px] w-full rounded-[var(--radius-md)] border border-[var(--color-border)] bg-[var(--color-surface-elevated)] px-4 py-3 text-sm text-[var(--color-text)] focus-visible:outline focus-visible:outline-2 focus-visible:outline-[var(--color-focus-ring)] focus-visible:outline-offset-2`;function M({t:e,step:t,index:n,stepsLength:r,uploadKey:i,challengeTypeLabel:a,setStep:o,removeStep:s}){return(0,E.jsxs)(`div`,{className:`rounded-[var(--radius-md)] border border-[var(--color-border)] bg-[var(--color-surface-elevated)] p-5 space-y-5`,children:[(0,E.jsxs)(`div`,{className:`mb-4 flex flex-wrap items-center justify-between gap-2`,children:[(0,E.jsxs)(`div`,{children:[(0,E.jsx)(`div`,{className:`text-sm font-medium text-[var(--color-text-heading)]`,children:e(`protocolEdit.stepHeading`,{n:n+1})}),(0,E.jsx)(`div`,{className:`text-sm text-[var(--color-text-muted)]`,children:e(`protocolEdit.stepEditorHint`)})]}),(0,E.jsx)(`button`,{type:`button`,onClick:()=>s(n),disabled:r<=1,className:`min-h-[44px] min-w-[44px] inline-flex items-center justify-center 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 disabled:opacity-50`,children:e(`protocolEdit.removeStep`)})]}),(0,E.jsxs)(`div`,{children:[(0,E.jsx)(`label`,{className:`mb-2 block font-medium text-[var(--color-text-heading)]`,children:e(`protocolEdit.stepLabel`)}),(0,E.jsx)(`input`,{type:`text`,value:t.label,onChange:e=>o(n,{label:e.target.value}),className:A})]}),(0,E.jsxs)(`div`,{children:[(0,E.jsx)(`div`,{className:`mb-2 font-medium text-[var(--color-text-heading)]`,children:e(`protocolEdit.challengeType`)}),(0,E.jsx)(`div`,{className:`flex flex-wrap gap-2`,children:w.map(e=>(0,E.jsx)(`button`,{type:`button`,"aria-pressed":t.type===e,onClick:()=>o(n,{type:e,shell:e===`shell`?{cmd:t.shell?.cmd??``,timeout_seconds:t.shell?.timeout_seconds??30,interpreter:t.shell?.interpreter,workdir:t.shell?.workdir,flags:t.shell?.flags??[],args:t.shell?.args??[]}:void 0,mcp:e===`mcp`?{tool_name:t.mcp?.tool_name??``}:void 0,user_input:e===`user_input`?{prompt:t.user_input?.prompt??``}:void 0,comment:e===`comment`?{min_length:t.comment?.min_length??10}:void 0}),className:`min-h-[44px] rounded-[var(--radius-md)] px-4 text-sm font-medium ${t.type===e?`bg-[var(--color-primary)] text-white`:`border border-[var(--color-border)] bg-[var(--color-surface)] text-[var(--color-text)]`}`,children:a[e]},e))})]}),(0,E.jsx)(`div`,{children:(0,E.jsx)(b,{label:e(`protocolEdit.stepContent`),value:t.bodyMarkdown,onChange:e=>o(n,{bodyMarkdown:e}),contentKey:i})}),(0,E.jsxs)(`div`,{className:`rounded-[var(--radius-md)] border border-[var(--color-border)] bg-[var(--color-surface)] p-4`,children:[(0,E.jsx)(`div`,{className:`mb-3 text-sm font-medium text-[var(--color-text-heading)]`,children:`Challenge fields`}),(0,E.jsxs)(`div`,{className:`grid grid-cols-1 gap-3 sm:grid-cols-2`,children:[t.type===`shell`&&(0,E.jsxs)(E.Fragment,{children:[(0,E.jsxs)(`div`,{children:[(0,E.jsx)(`label`,{className:`mb-2 block text-sm font-medium text-[var(--color-text-heading)]`,children:e(`protocolEdit.shellCmd`)}),(0,E.jsx)(`input`,{type:`text`,value:t.shell?.cmd??``,onChange:e=>o(n,{shell:{cmd:e.target.value,timeout_seconds:t.shell?.timeout_seconds??30,interpreter:t.shell?.interpreter,workdir:t.shell?.workdir,flags:t.shell?.flags??[],args:t.shell?.args??[]}}),className:j})]}),(0,E.jsxs)(`div`,{children:[(0,E.jsx)(`label`,{className:`mb-2 block text-sm font-medium text-[var(--color-text-heading)]`,children:e(`protocolEdit.shellTimeout`)}),(0,E.jsx)(`input`,{type:`number`,min:1,value:t.shell?.timeout_seconds??30,onChange:e=>o(n,{shell:{cmd:t.shell?.cmd??``,timeout_seconds:Math.max(1,Number(e.target.value)||30),interpreter:t.shell?.interpreter,workdir:t.shell?.workdir,flags:t.shell?.flags??[],args:t.shell?.args??[]}}),className:j})]}),(0,E.jsxs)(`div`,{children:[(0,E.jsx)(`label`,{className:`mb-2 block text-sm font-medium text-[var(--color-text-heading)]`,children:e(`protocolEdit.shellInterpreter`)}),(0,E.jsx)(`input`,{type:`text`,value:t.shell?.interpreter??``,onChange:e=>o(n,{shell:{cmd:t.shell?.cmd??``,timeout_seconds:t.shell?.timeout_seconds??30,interpreter:e.target.value||void 0,workdir:t.shell?.workdir,flags:t.shell?.flags??[],args:t.shell?.args??[]}}),className:j})]}),(0,E.jsxs)(`div`,{children:[(0,E.jsx)(`label`,{className:`mb-2 block text-sm font-medium text-[var(--color-text-heading)]`,children:e(`protocolEdit.shellWorkdir`)}),(0,E.jsx)(`input`,{type:`text`,value:t.shell?.workdir??``,onChange:e=>o(n,{shell:{cmd:t.shell?.cmd??``,timeout_seconds:t.shell?.timeout_seconds??30,interpreter:t.shell?.interpreter,workdir:e.target.value||void 0,flags:t.shell?.flags??[],args:t.shell?.args??[]}}),className:j})]}),(0,E.jsxs)(`div`,{className:`sm:col-span-2`,children:[(0,E.jsx)(`label`,{className:`mb-2 block text-sm font-medium text-[var(--color-text-heading)]`,children:e(`protocolEdit.shellFlags`)}),(0,E.jsx)(`textarea`,{rows:3,value:(t.shell?.flags??[]).join(`
1
+ import{r as e}from"./rolldown-runtime-hePW80VL.js";import{a as t,m as n,p as r,t 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{r as l,t as u}from"./SpaceSelect-D3al0TgQ.js";import{t as d}from"./SurfaceCard-BzJidvvn.js";import{a as f,i as p,n as m,o as h,r as g,s as _,t as v}from"./export-skill-zip-D8iQY1Dl.js";import{t as y}from"./ChallengeCard-DVXo4j0b.js";import{t as b}from"./RichTextEditor-DWLV579w.js";var x=e(o(),1),S=i().min(1,`Protocol content is required`).refine(e=>e.includes(`# `),`Protocol must have an H1 title`).refine(e=>/(^|\n)##\s+Activation Patterns\b/i.test(e),`Include an "Activation Patterns" section (H2)`).refine(e=>/(^|\n)##\s+Reward Signal\b/i.test(e),`Include a "Reward Signal" section (H2)`),C={label:`Step`,bodyMarkdown:`What the user or agent does in this step.`,type:`comment`,comment:{min_length:10}},w=[`shell`,`mcp`,`user_input`,`comment`],T=/^squadrules:\/\/adapter\/[a-z0-9](?:[a-z0-9-]*[a-z0-9])?$/i,E=s();function D({t:e,fileInputRef:n,onUpload:r,isNew:i,decodedUri:a}){return(0,E.jsx)(d,{className:`mb-8`,title:e(`protocolEdit.importCardTitle`),subtitle:e(`protocolEdit.uploadHint`),children:(0,E.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[(0,E.jsx)(`input`,{ref:n,type:`file`,accept:`.md,text/markdown`,onChange:r,className:`sr-only`,id:`protocol-upload`,"aria-label":e(`protocolEdit.upload`)}),(0,E.jsx)(`button`,{type:`button`,onClick:()=>n.current?.click(),className:`min-h-[44px] min-w-[44px] inline-flex items-center justify-center 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:e(`protocolEdit.upload`)}),!i&&a&&(0,E.jsx)(t,{to:`/protocols/${encodeURIComponent(a)}/skill`,className:`min-h-[44px] min-w-[44px] inline-flex items-center justify-center 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)] 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(`protocol.editAsSkill`)})]})})}function O({t:e,preview:n,skillFolderSlug:r,isNew:i,decodedUri:a}){let[o,s]=(0,x.useState)(!1),[c,l]=(0,x.useState)(null);return(0,E.jsxs)(`div`,{className:`space-y-4`,"aria-label":e(`protocolEdit.previewLabel`),children:[(0,E.jsxs)(d,{title:e(`protocolEdit.previewRenderedTitle`),subtitle:e(`protocolEdit.previewRenderedSubtitle`),children:[(0,E.jsx)(`div`,{className:`text-lg font-semibold text-[var(--color-text-heading)]`,children:n.title}),(0,E.jsx)(`div`,{className:`mt-3 space-y-3`,children:n.steps.length===0?(0,E.jsx)(`div`,{className:`text-sm text-[var(--color-text-muted)]`,children:e(`protocolEdit.previewNoSteps`)}):n.steps.slice(0,20).map((t,n)=>(0,E.jsxs)(`div`,{className:`rounded-[var(--radius-sm)] border border-[var(--color-border)] bg-[var(--color-surface)] p-3`,children:[(0,E.jsx)(`div`,{className:`font-medium text-[var(--color-text-heading)]`,children:e(`protocolEdit.previewStepLine`,{n:n+1,label:t.label})}),(0,E.jsx)(`div`,{className:`mt-1 text-sm text-[var(--color-text-muted)]`,children:y[t.type]??t.type})]},`${t.label}:${n}`))}),(0,E.jsxs)(`div`,{className:`mt-4 border-t border-[var(--color-border)] pt-4 text-sm text-[var(--color-text-muted)]`,children:[(0,E.jsxs)(`div`,{children:[(0,E.jsxs)(`strong`,{className:`text-[var(--color-text-heading)]`,children:[e(`protocol.triggers`),`:`]}),` `,n.triggers?e(`protocolEdit.present`):e(`protocolEdit.missing`)]}),(0,E.jsxs)(`div`,{className:`mt-1`,children:[(0,E.jsxs)(`strong`,{className:`text-[var(--color-text-heading)]`,children:[e(`protocol.completion`),`:`]}),` `,n.completion?e(`protocolEdit.present`):e(`protocolEdit.missing`)]})]})]}),!i&&a?(0,E.jsxs)(d,{title:e(`protocolEdit.skillShortcutTitle`),subtitle:e(`protocolEdit.skillShortcutSubtitle`),children:[(0,E.jsxs)(`div`,{className:`rounded-[var(--radius-md)] border border-[var(--color-border)] bg-[var(--color-surface)] p-3`,children:[(0,E.jsxs)(`div`,{className:`font-medium text-[var(--color-text-heading)]`,children:[r,`-skill/`]}),(0,E.jsxs)(`div`,{className:`mt-2 font-mono text-sm text-[var(--color-text-muted)]`,children:[`Skill.md`,(0,E.jsx)(`br`,{}),`references/`,(0,E.jsx)(`br`,{}),`\xA0\xA0SQUADRULES.md`]})]}),(0,E.jsxs)(`div`,{className:`mt-3 flex flex-wrap gap-2`,children:[(0,E.jsx)(t,{to:`/protocols/${encodeURIComponent(a)}/skill`,className:`min-h-[44px] min-w-[44px] inline-flex items-center justify-center 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)] 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(`protocol.editAsSkill`)}),(0,E.jsx)(`button`,{type:`button`,disabled:o,onClick:()=>{(async()=>{if(a){l(null),s(!0);try{let{blob:e,skill_bundle_manifest:t}=await v(a),n=m(t,r);g(e,n)}catch(e){l(e instanceof Error?e.message:String(e))}finally{s(!1)}}})()},className:`min-h-[44px] min-w-[44px] inline-flex items-center justify-center rounded-[var(--radius-md)] bg-[var(--color-primary)] px-4 py-2 text-sm 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:opacity-60`,children:e(`protocol.downloadAsSkill`)}),c?(0,E.jsx)(`p`,{className:`mt-2 m-0 text-xs text-[var(--color-error)]`,role:`alert`,children:c}):null]})]}):null]})}function k({t:e,isNew:t,spaces:n,spacesLoading:r,targetSpace:i,setTargetSpace:a,forkSourceUri:o,setForkSourceUri:s,moveSpace:c,setMoveSpace:l}){return(0,E.jsx)(`section`,{className:`mb-8 space-y-5 rounded-[var(--radius-md)] border border-[var(--color-border)] bg-[var(--color-surface-elevated)] p-5`,children:t?(0,E.jsxs)(E.Fragment,{children:[(0,E.jsxs)(`div`,{children:[(0,E.jsx)(`label`,{htmlFor:`protocol-target-space`,className:`mb-2 block font-medium text-[var(--color-text-heading)]`,children:e(`protocolEdit.targetSpaceLabel`)}),(0,E.jsx)(u,{id:`protocol-target-space`,spaces:n,value:i,onChange:a,disabled:r}),(0,E.jsx)(`p`,{className:`mt-2 text-sm text-[var(--color-text-muted)]`,children:e(`protocolEdit.targetSpaceHint`)})]}),(0,E.jsxs)(`div`,{children:[(0,E.jsx)(`label`,{htmlFor:`protocol-fork-source`,className:`mb-2 block font-medium text-[var(--color-text-heading)]`,children:e(`protocolEdit.forkSourceLabel`)}),(0,E.jsx)(`input`,{id:`protocol-fork-source`,type:`text`,value:o,onChange:e=>s(e.target.value),placeholder:e(`protocolEdit.forkSourcePlaceholder`),autoComplete:`off`,className:`min-h-[44px] w-full max-w-2xl rounded-[var(--radius-md)] border border-[var(--color-border)] bg-[var(--color-surface)] px-4 py-3 text-sm text-[var(--color-text)] focus-visible:outline focus-visible:outline-2 focus-visible:outline-[var(--color-focus-ring)] focus-visible:outline-offset-2`}),(0,E.jsx)(`p`,{className:`mt-2 text-sm text-[var(--color-text-muted)]`,children:e(`protocolEdit.forkSourceHint`)})]})]}):(0,E.jsxs)(`div`,{children:[(0,E.jsx)(`label`,{htmlFor:`protocol-move-space`,className:`mb-2 block font-medium text-[var(--color-text-heading)]`,children:e(`protocolEdit.moveSpaceLabel`)}),(0,E.jsx)(u,{id:`protocol-move-space`,spaces:n,value:c,onChange:l,disabled:r}),(0,E.jsx)(`p`,{className:`mt-2 text-sm text-[var(--color-text-muted)]`,children:e(`protocolEdit.moveSpaceHint`)})]})})}var A=`min-h-[44px] w-full rounded-[var(--radius-md)] border border-[var(--color-border)] bg-[var(--color-surface)] px-4 py-3 text-sm text-[var(--color-text)] focus-visible:outline focus-visible:outline-2 focus-visible:outline-[var(--color-focus-ring)] focus-visible:outline-offset-2`,j=`min-h-[44px] w-full rounded-[var(--radius-md)] border border-[var(--color-border)] bg-[var(--color-surface-elevated)] px-4 py-3 text-sm text-[var(--color-text)] focus-visible:outline focus-visible:outline-2 focus-visible:outline-[var(--color-focus-ring)] focus-visible:outline-offset-2`;function M({t:e,step:t,index:n,stepsLength:r,uploadKey:i,challengeTypeLabel:a,setStep:o,removeStep:s}){return(0,E.jsxs)(`div`,{className:`rounded-[var(--radius-md)] border border-[var(--color-border)] bg-[var(--color-surface-elevated)] p-5 space-y-5`,children:[(0,E.jsxs)(`div`,{className:`mb-4 flex flex-wrap items-center justify-between gap-2`,children:[(0,E.jsxs)(`div`,{children:[(0,E.jsx)(`div`,{className:`text-sm font-medium text-[var(--color-text-heading)]`,children:e(`protocolEdit.stepHeading`,{n:n+1})}),(0,E.jsx)(`div`,{className:`text-sm text-[var(--color-text-muted)]`,children:e(`protocolEdit.stepEditorHint`)})]}),(0,E.jsx)(`button`,{type:`button`,onClick:()=>s(n),disabled:r<=1,className:`min-h-[44px] min-w-[44px] inline-flex items-center justify-center 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 disabled:opacity-50`,children:e(`protocolEdit.removeStep`)})]}),(0,E.jsxs)(`div`,{children:[(0,E.jsx)(`label`,{className:`mb-2 block font-medium text-[var(--color-text-heading)]`,children:e(`protocolEdit.stepLabel`)}),(0,E.jsx)(`input`,{type:`text`,value:t.label,onChange:e=>o(n,{label:e.target.value}),className:A})]}),(0,E.jsxs)(`div`,{children:[(0,E.jsx)(`div`,{className:`mb-2 font-medium text-[var(--color-text-heading)]`,children:e(`protocolEdit.challengeType`)}),(0,E.jsx)(`div`,{className:`flex flex-wrap gap-2`,children:w.map(e=>(0,E.jsx)(`button`,{type:`button`,"aria-pressed":t.type===e,onClick:()=>o(n,{type:e,shell:e===`shell`?{cmd:t.shell?.cmd??``,timeout_seconds:t.shell?.timeout_seconds??30,interpreter:t.shell?.interpreter,workdir:t.shell?.workdir,flags:t.shell?.flags??[],args:t.shell?.args??[]}:void 0,mcp:e===`mcp`?{tool_name:t.mcp?.tool_name??``}:void 0,user_input:e===`user_input`?{prompt:t.user_input?.prompt??``}:void 0,comment:e===`comment`?{min_length:t.comment?.min_length??10}:void 0}),className:`min-h-[44px] rounded-[var(--radius-md)] px-4 text-sm font-medium ${t.type===e?`bg-[var(--color-primary)] text-white`:`border border-[var(--color-border)] bg-[var(--color-surface)] text-[var(--color-text)]`}`,children:a[e]},e))})]}),(0,E.jsx)(`div`,{children:(0,E.jsx)(b,{label:e(`protocolEdit.stepContent`),value:t.bodyMarkdown,onChange:e=>o(n,{bodyMarkdown:e}),contentKey:i})}),(0,E.jsxs)(`div`,{className:`rounded-[var(--radius-md)] border border-[var(--color-border)] bg-[var(--color-surface)] p-4`,children:[(0,E.jsx)(`div`,{className:`mb-3 text-sm font-medium text-[var(--color-text-heading)]`,children:`Challenge fields`}),(0,E.jsxs)(`div`,{className:`grid grid-cols-1 gap-3 sm:grid-cols-2`,children:[t.type===`shell`&&(0,E.jsxs)(E.Fragment,{children:[(0,E.jsxs)(`div`,{children:[(0,E.jsx)(`label`,{className:`mb-2 block text-sm font-medium text-[var(--color-text-heading)]`,children:e(`protocolEdit.shellCmd`)}),(0,E.jsx)(`input`,{type:`text`,value:t.shell?.cmd??``,onChange:e=>o(n,{shell:{cmd:e.target.value,timeout_seconds:t.shell?.timeout_seconds??30,interpreter:t.shell?.interpreter,workdir:t.shell?.workdir,flags:t.shell?.flags??[],args:t.shell?.args??[]}}),className:j})]}),(0,E.jsxs)(`div`,{children:[(0,E.jsx)(`label`,{className:`mb-2 block text-sm font-medium text-[var(--color-text-heading)]`,children:e(`protocolEdit.shellTimeout`)}),(0,E.jsx)(`input`,{type:`number`,min:1,value:t.shell?.timeout_seconds??30,onChange:e=>o(n,{shell:{cmd:t.shell?.cmd??``,timeout_seconds:Math.max(1,Number(e.target.value)||30),interpreter:t.shell?.interpreter,workdir:t.shell?.workdir,flags:t.shell?.flags??[],args:t.shell?.args??[]}}),className:j})]}),(0,E.jsxs)(`div`,{children:[(0,E.jsx)(`label`,{className:`mb-2 block text-sm font-medium text-[var(--color-text-heading)]`,children:e(`protocolEdit.shellInterpreter`)}),(0,E.jsx)(`input`,{type:`text`,value:t.shell?.interpreter??``,onChange:e=>o(n,{shell:{cmd:t.shell?.cmd??``,timeout_seconds:t.shell?.timeout_seconds??30,interpreter:e.target.value||void 0,workdir:t.shell?.workdir,flags:t.shell?.flags??[],args:t.shell?.args??[]}}),className:j})]}),(0,E.jsxs)(`div`,{children:[(0,E.jsx)(`label`,{className:`mb-2 block text-sm font-medium text-[var(--color-text-heading)]`,children:e(`protocolEdit.shellWorkdir`)}),(0,E.jsx)(`input`,{type:`text`,value:t.shell?.workdir??``,onChange:e=>o(n,{shell:{cmd:t.shell?.cmd??``,timeout_seconds:t.shell?.timeout_seconds??30,interpreter:t.shell?.interpreter,workdir:e.target.value||void 0,flags:t.shell?.flags??[],args:t.shell?.args??[]}}),className:j})]}),(0,E.jsxs)(`div`,{className:`sm:col-span-2`,children:[(0,E.jsx)(`label`,{className:`mb-2 block text-sm font-medium text-[var(--color-text-heading)]`,children:e(`protocolEdit.shellFlags`)}),(0,E.jsx)(`textarea`,{rows:3,value:(t.shell?.flags??[]).join(`
2
2
  `),onChange:e=>o(n,{shell:{cmd:t.shell?.cmd??``,timeout_seconds:t.shell?.timeout_seconds??30,interpreter:t.shell?.interpreter,workdir:t.shell?.workdir,flags:e.target.value.split(`
3
3
  `).map(e=>e.trim()).filter(Boolean),args:t.shell?.args??[]}}),className:`w-full rounded-[var(--radius-md)] border border-[var(--color-border)] bg-[var(--color-surface-elevated)] px-4 py-3 text-sm text-[var(--color-text)] focus-visible:outline focus-visible:outline-2 focus-visible:outline-[var(--color-focus-ring)] focus-visible:outline-offset-2`})]}),(0,E.jsxs)(`div`,{className:`sm:col-span-2`,children:[(0,E.jsx)(`label`,{className:`mb-2 block text-sm font-medium text-[var(--color-text-heading)]`,children:e(`protocolEdit.shellArgs`)}),(0,E.jsx)(`textarea`,{rows:3,value:(t.shell?.args??[]).join(`
4
4
  `),onChange:e=>o(n,{shell:{cmd:t.shell?.cmd??``,timeout_seconds:t.shell?.timeout_seconds??30,interpreter:t.shell?.interpreter,workdir:t.shell?.workdir,flags:t.shell?.flags??[],args:e.target.value.split(`
5
- `).map(e=>e.trim()).filter(Boolean)}}),className:`w-full rounded-[var(--radius-md)] border border-[var(--color-border)] bg-[var(--color-surface-elevated)] px-4 py-3 text-sm text-[var(--color-text)] focus-visible:outline focus-visible:outline-2 focus-visible:outline-[var(--color-focus-ring)] focus-visible:outline-offset-2`})]})]}),t.type===`mcp`&&(0,E.jsxs)(`div`,{children:[(0,E.jsx)(`label`,{className:`mb-2 block text-sm font-medium text-[var(--color-text-heading)]`,children:e(`protocolEdit.mcpToolName`)}),(0,E.jsx)(`input`,{type:`text`,value:t.mcp?.tool_name??``,onChange:e=>o(n,{mcp:{tool_name:e.target.value}}),className:j})]}),t.type===`user_input`&&(0,E.jsxs)(`div`,{children:[(0,E.jsx)(`label`,{className:`mb-2 block text-sm font-medium text-[var(--color-text-heading)]`,children:e(`protocolEdit.userInputPrompt`)}),(0,E.jsx)(`input`,{type:`text`,value:t.user_input?.prompt??``,onChange:e=>o(n,{user_input:{prompt:e.target.value}}),className:j})]}),t.type===`comment`&&(0,E.jsxs)(`div`,{children:[(0,E.jsx)(`label`,{className:`mb-2 block text-sm font-medium text-[var(--color-text-heading)]`,children:e(`protocolEdit.commentMinLength`)}),(0,E.jsx)(`input`,{type:`number`,min:1,value:t.comment?.min_length??10,onChange:e=>o(n,{comment:{min_length:Math.max(1,parseInt(e.target.value,10)||10)}}),className:j})]})]})]})]})}function N(){let{t:e}=a(),{uri:i}=n(),o=r(),s=i?decodeURIComponent(i):void 0,u=!s,{data:d,isLoading:m}=_(s,!u),[g,v]=(0,x.useState)({protocolLabel:``,triggersMarkdown:``,steps:[{...C}],completionMarkdown:``}),[y,w]=(0,x.useState)(()=>String(Date.now())),[A,j]=(0,x.useState)(!1),[N,P]=(0,x.useState)(null),[F,I]=(0,x.useState)(null),L=(0,x.useRef)(null),R=(0,x.useRef)(``),[z,B]=(0,x.useState)(``),[V,H]=(0,x.useState)(``),[U,W]=(0,x.useState)(``),{data:G,isLoading:K}=l(!0,{});(0,x.useEffect)(()=>{u&&(B(``),W(``))},[u]),(0,x.useEffect)(()=>{if(!u)return;let e=G?.spaces?.find(e=>e.type===`personal`);B(t=>t===``&&e?e.space_id:t)},[u,G?.spaces]),(0,x.useEffect)(()=>{if(u||!d)return;let e=typeof d.space_id==`string`?d.space_id.trim():``;R.current=e,H(e)},[u,d]),(0,x.useEffect)(()=>{if(d?.content)try{v(h(d.content)),w(String(Date.now()))}catch{v({protocolLabel:d.label||`Protocol`,triggersMarkdown:``,steps:[{...C}],completionMarkdown:``})}},[d]);let q=e=>{let t=e.target.files?.[0];if(!t)return;let n=new FileReader;n.onload=()=>{let e=typeof n.result==`string`?n.result:``;try{v(h(e)),w(String(Date.now())),I(null),P(null)}catch{P(`Could not parse the uploaded file. Use valid protocol markdown.`)}},n.readAsText(t,`UTF-8`),e.target.value=``},J=(e,t)=>{v(n=>({...n,[e]:t}))},Y=(e,t)=>{v(n=>({...n,steps:n.steps.map((n,r)=>r===e?typeof t==`function`?t(n):{...n,...t}:n)}))},X=()=>{v(e=>({...e,steps:[...e.steps,{...C,label:`Step ${e.steps.length+1}`}]}))},Z=e=>{v(t=>({...t,steps:t.steps.filter((t,n)=>n!==e)}))},Q=async t=>{t.preventDefault(),P(null),I(null);let n=p(g),r=S.safeParse(n);if(!r.success){I(r.error.issues[0]?.message??`Invalid`);return}let i=U.trim();if(i&&!T.test(i)){I(e(`protocolEdit.forkUriInvalid`));return}j(!0);try{if(u){let e=z.trim()||`personal`,t=await c(`/api/train`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({content:n,llm_model_id:`squadrules-ui`,force_update:!1,space:e,...i?{source_adapter_uri:i}:{}})});if(!t.ok){let e=await t.json().catch(()=>({}));throw Error(e.message??t.statusText)}let r=await t.json(),a=r.items?.[0]?.adapter_uri,s=r.items?.[0]?.uri;o(a?`/protocols/${encodeURIComponent(a)}`:s?`/protocols/${encodeURIComponent(s)}`:`/`)}else{let e=R.current.trim(),t=V.trim(),r={uris:[s],content:[n]};t&&t!==e&&(r.space=t);let i=await c(`/api/tune`,{method:`POST`,body:JSON.stringify(r)});if(!i.ok){let e=await i.json().catch(()=>({}));throw Error(e.message??i.statusText)}o(`/protocols/${encodeURIComponent(s)}`)}}catch(e){P(e instanceof Error?e.message:String(e))}finally{j(!1)}},$=(()=>{try{return f(p(g))}catch{return{title:g.protocolLabel||`Protocol`,steps:[],triggers:``,completion:``}}})();if(!u&&m&&!d)return(0,E.jsx)(`p`,{className:`text-[var(--color-text-muted)]`,children:e(`protocol.loading`)});let ee={shell:e(`protocolEdit.challengeShell`),mcp:e(`protocolEdit.challengeMcp`),user_input:e(`protocolEdit.challengeUserInput`),comment:e(`protocolEdit.challengeComment`)},te=(g.protocolLabel.trim()||$.title||`skill`).replace(/[^a-zA-Z0-9]+/g,`-`).replace(/^-|-$/g,``).toLowerCase()||`skill`;return(0,E.jsxs)(`div`,{children:[(0,E.jsx)(`h1`,{className:`mb-1 text-2xl font-semibold text-[var(--color-text-heading)]`,children:e(u?`protocolEdit.newTitle`:`protocolEdit.editTitle`)}),(0,E.jsx)(`p`,{className:`mb-6 text-sm text-[var(--color-text-muted)]`,children:e(`protocolEdit.hint`)}),(0,E.jsx)(k,{t:e,isNew:u,spaces:G?.spaces,spacesLoading:K,targetSpace:z,setTargetSpace:B,forkSourceUri:U,setForkSourceUri:W,moveSpace:V,setMoveSpace:H}),(0,E.jsx)(D,{t:e,fileInputRef:L,onUpload:q,isNew:u,decodedUri:s}),(0,E.jsx)(`form`,{onSubmit:Q,"aria-label":e(`protocolEdit.formLabel`),children:(0,E.jsxs)(`div`,{className:`mb-6 grid gap-6 xl:grid-cols-[1.45fr_1fr]`,children:[(0,E.jsxs)(`div`,{className:`space-y-6`,children:[(0,E.jsxs)(`div`,{children:[(0,E.jsx)(`label`,{htmlFor:`protocol-label`,className:`mb-2 block font-medium text-[var(--color-text-heading)]`,children:e(`protocolEdit.protocolLabel`)}),(0,E.jsx)(`input`,{id:`protocol-label`,type:`text`,value:g.protocolLabel,onChange:e=>J(`protocolLabel`,e.target.value),className:`min-h-[44px] w-full rounded-[var(--radius-md)] border border-[var(--color-border)] bg-[var(--color-surface)] px-4 py-3 text-sm text-[var(--color-text)] focus-visible:outline focus-visible:outline-2 focus-visible:outline-[var(--color-focus-ring)] focus-visible:outline-offset-2`})]}),(0,E.jsx)(b,{label:e(`protocolEdit.triggersLabel`),hint:e(`protocolEdit.triggersEditorHint`),value:g.triggersMarkdown,onChange:e=>J(`triggersMarkdown`,e),contentKey:y}),g.steps.map((t,n)=>(0,E.jsx)(M,{t:e,step:t,index:n,stepsLength:g.steps.length,uploadKey:y,challengeTypeLabel:ee,setStep:Y,removeStep:Z},n)),(0,E.jsx)(`button`,{type:`button`,onClick:X,className:`min-h-[44px] min-w-[44px] inline-flex items-center justify-center 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:e(`protocolEdit.addStep`)}),(0,E.jsx)(b,{label:e(`protocolEdit.completionLabel`),value:g.completionMarkdown,onChange:e=>J(`completionMarkdown`,e),contentKey:y}),F&&(0,E.jsx)(`p`,{className:`text-sm text-[var(--color-error)]`,role:`alert`,children:F}),N&&(0,E.jsx)(`div`,{className:`rounded-[var(--radius-md)] bg-[var(--color-error-bg)] p-4 text-[var(--color-error)]`,role:`alert`,children:N}),(0,E.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[(0,E.jsx)(`button`,{type:`submit`,disabled:A,className:`min-h-[44px] min-w-[44px] inline-flex items-center justify-center rounded-[var(--radius-md)] 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:opacity-60`,children:e(A?`protocolEdit.saving`:`protocolEdit.save`)}),(0,E.jsx)(t,{to:u?`/`:`/protocols/${encodeURIComponent(s)}`,className:`min-h-[44px] min-w-[44px] inline-flex items-center justify-center rounded-[var(--radius-md)] border border-[var(--color-border)] bg-[var(--color-surface)] px-4 py-2 font-medium 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(`protocolEdit.cancel`)})]})]}),(0,E.jsx)(O,{t:e,preview:$,skillFolderSlug:te,isNew:u,decodedUri:s})]})})]})}export{N as ProtocolEditPage};
5
+ `).map(e=>e.trim()).filter(Boolean)}}),className:`w-full rounded-[var(--radius-md)] border border-[var(--color-border)] bg-[var(--color-surface-elevated)] px-4 py-3 text-sm text-[var(--color-text)] focus-visible:outline focus-visible:outline-2 focus-visible:outline-[var(--color-focus-ring)] focus-visible:outline-offset-2`})]})]}),t.type===`mcp`&&(0,E.jsxs)(`div`,{children:[(0,E.jsx)(`label`,{className:`mb-2 block text-sm font-medium text-[var(--color-text-heading)]`,children:e(`protocolEdit.mcpToolName`)}),(0,E.jsx)(`input`,{type:`text`,value:t.mcp?.tool_name??``,onChange:e=>o(n,{mcp:{tool_name:e.target.value}}),className:j})]}),t.type===`user_input`&&(0,E.jsxs)(`div`,{children:[(0,E.jsx)(`label`,{className:`mb-2 block text-sm font-medium text-[var(--color-text-heading)]`,children:e(`protocolEdit.userInputPrompt`)}),(0,E.jsx)(`input`,{type:`text`,value:t.user_input?.prompt??``,onChange:e=>o(n,{user_input:{prompt:e.target.value}}),className:j})]}),t.type===`comment`&&(0,E.jsxs)(`div`,{children:[(0,E.jsx)(`label`,{className:`mb-2 block text-sm font-medium text-[var(--color-text-heading)]`,children:e(`protocolEdit.commentMinLength`)}),(0,E.jsx)(`input`,{type:`number`,min:1,value:t.comment?.min_length??10,onChange:e=>o(n,{comment:{min_length:Math.max(1,parseInt(e.target.value,10)||10)}}),className:j})]})]})]})]})}function N(){let{t:e}=a(),{uri:i}=n(),o=r(),s=i?decodeURIComponent(i):void 0,u=!s,{data:d,isLoading:m}=_(s,!u),[g,v]=(0,x.useState)({protocolLabel:``,triggersMarkdown:``,steps:[{...C}],completionMarkdown:``}),[y,w]=(0,x.useState)(()=>String(Date.now())),[A,j]=(0,x.useState)(!1),[N,P]=(0,x.useState)(null),[F,I]=(0,x.useState)(null),L=(0,x.useRef)(null),R=(0,x.useRef)(``),[z,B]=(0,x.useState)(``),[V,H]=(0,x.useState)(``),[U,W]=(0,x.useState)(``),{data:G,isLoading:K}=l(!0,{});(0,x.useEffect)(()=>{u&&(B(``),W(``))},[u]),(0,x.useEffect)(()=>{if(!u)return;let e=G?.spaces?.find(e=>e.type===`personal`);B(t=>t===``&&e?e.space_id:t)},[u,G?.spaces]),(0,x.useEffect)(()=>{if(u||!d)return;let e=typeof d.space_id==`string`?d.space_id.trim():``;R.current=e,H(e)},[u,d]),(0,x.useEffect)(()=>{if(d?.content)try{v(h(d.content)),w(String(Date.now()))}catch{v({protocolLabel:d.label||`Protocol`,triggersMarkdown:``,steps:[{...C}],completionMarkdown:``})}},[d]);let q=e=>{let t=e.target.files?.[0];if(!t)return;let n=new FileReader;n.onload=()=>{let e=typeof n.result==`string`?n.result:``;try{v(h(e)),w(String(Date.now())),I(null),P(null)}catch{P(`Could not parse the uploaded file. Use valid protocol markdown.`)}},n.readAsText(t,`UTF-8`),e.target.value=``},J=(e,t)=>{v(n=>({...n,[e]:t}))},Y=(e,t)=>{v(n=>({...n,steps:n.steps.map((n,r)=>r===e?typeof t==`function`?t(n):{...n,...t}:n)}))},X=()=>{v(e=>({...e,steps:[...e.steps,{...C,label:`Step ${e.steps.length+1}`}]}))},Z=e=>{v(t=>({...t,steps:t.steps.filter((t,n)=>n!==e)}))},Q=async t=>{t.preventDefault(),P(null),I(null);let n=p(g),r=S.safeParse(n);if(!r.success){I(r.error.issues[0]?.message??`Invalid`);return}let i=U.trim();if(i&&!T.test(i))I(e(`protocolEdit.forkUriInvalid`));else{j(!0);try{if(u){let e=z.trim()||`personal`,t=await c(`/api/train`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({content:n,llm_model_id:`squadrules-ui`,force_update:!1,space:e,...i?{source_adapter_uri:i}:{}})});if(!t.ok){let e=await t.json().catch(()=>({}));throw Error(e.message??t.statusText)}let r=await t.json(),a=r.items?.[0]?.adapter_uri,s=r.items?.[0]?.uri;o(a?`/protocols/${encodeURIComponent(a)}`:s?`/protocols/${encodeURIComponent(s)}`:`/`)}else{let e=R.current.trim(),t=V.trim(),r={uris:[s],content:[n]};t&&t!==e&&(r.space=t);let i=await c(`/api/tune`,{method:`POST`,body:JSON.stringify(r)});if(!i.ok){let e=await i.json().catch(()=>({}));throw Error(e.message??i.statusText)}o(`/protocols/${encodeURIComponent(s)}`)}}catch(e){P(e instanceof Error?e.message:String(e))}finally{j(!1)}}},$=(()=>{try{return f(p(g))}catch{return{title:g.protocolLabel||`Protocol`,steps:[],triggers:``,completion:``}}})();if(!u&&m&&!d)return(0,E.jsx)(`p`,{className:`text-[var(--color-text-muted)]`,children:e(`protocol.loading`)});let ee={shell:e(`protocolEdit.challengeShell`),mcp:e(`protocolEdit.challengeMcp`),user_input:e(`protocolEdit.challengeUserInput`),comment:e(`protocolEdit.challengeComment`)},te=(g.protocolLabel.trim()||$.title||`skill`).replace(/[^a-zA-Z0-9]+/g,`-`).replace(/^-|-$/g,``).toLowerCase()||`skill`;return(0,E.jsxs)(`div`,{children:[(0,E.jsx)(`h1`,{className:`mb-1 text-2xl font-semibold text-[var(--color-text-heading)]`,children:e(u?`protocolEdit.newTitle`:`protocolEdit.editTitle`)}),(0,E.jsx)(`p`,{className:`mb-6 text-sm text-[var(--color-text-muted)]`,children:e(`protocolEdit.hint`)}),(0,E.jsx)(k,{t:e,isNew:u,spaces:G?.spaces,spacesLoading:K,targetSpace:z,setTargetSpace:B,forkSourceUri:U,setForkSourceUri:W,moveSpace:V,setMoveSpace:H}),(0,E.jsx)(D,{t:e,fileInputRef:L,onUpload:q,isNew:u,decodedUri:s}),(0,E.jsx)(`form`,{onSubmit:Q,"aria-label":e(`protocolEdit.formLabel`),children:(0,E.jsxs)(`div`,{className:`mb-6 grid gap-6 xl:grid-cols-[1.45fr_1fr]`,children:[(0,E.jsxs)(`div`,{className:`space-y-6`,children:[(0,E.jsxs)(`div`,{children:[(0,E.jsx)(`label`,{htmlFor:`protocol-label`,className:`mb-2 block font-medium text-[var(--color-text-heading)]`,children:e(`protocolEdit.protocolLabel`)}),(0,E.jsx)(`input`,{id:`protocol-label`,type:`text`,value:g.protocolLabel,onChange:e=>J(`protocolLabel`,e.target.value),className:`min-h-[44px] w-full rounded-[var(--radius-md)] border border-[var(--color-border)] bg-[var(--color-surface)] px-4 py-3 text-sm text-[var(--color-text)] focus-visible:outline focus-visible:outline-2 focus-visible:outline-[var(--color-focus-ring)] focus-visible:outline-offset-2`})]}),(0,E.jsx)(b,{label:e(`protocolEdit.triggersLabel`),hint:e(`protocolEdit.triggersEditorHint`),value:g.triggersMarkdown,onChange:e=>J(`triggersMarkdown`,e),contentKey:y}),g.steps.map((t,n)=>(0,E.jsx)(M,{t:e,step:t,index:n,stepsLength:g.steps.length,uploadKey:y,challengeTypeLabel:ee,setStep:Y,removeStep:Z},n)),(0,E.jsx)(`button`,{type:`button`,onClick:X,className:`min-h-[44px] min-w-[44px] inline-flex items-center justify-center 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:e(`protocolEdit.addStep`)}),(0,E.jsx)(b,{label:e(`protocolEdit.completionLabel`),value:g.completionMarkdown,onChange:e=>J(`completionMarkdown`,e),contentKey:y}),F&&(0,E.jsx)(`p`,{className:`text-sm text-[var(--color-error)]`,role:`alert`,children:F}),N&&(0,E.jsx)(`div`,{className:`rounded-[var(--radius-md)] bg-[var(--color-error-bg)] p-4 text-[var(--color-error)]`,role:`alert`,children:N}),(0,E.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[(0,E.jsx)(`button`,{type:`submit`,disabled:A,className:`min-h-[44px] min-w-[44px] inline-flex items-center justify-center rounded-[var(--radius-md)] 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:opacity-60`,children:e(A?`protocolEdit.saving`:`protocolEdit.save`)}),(0,E.jsx)(t,{to:u?`/`:`/protocols/${encodeURIComponent(s)}`,className:`min-h-[44px] min-w-[44px] inline-flex items-center justify-center rounded-[var(--radius-md)] border border-[var(--color-border)] bg-[var(--color-surface)] px-4 py-2 font-medium 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(`protocolEdit.cancel`)})]})]}),(0,E.jsx)(O,{t:e,preview:$,skillFolderSlug:te,isNew:u,decodedUri:s})]})})]})}export{N as ProtocolEditPage};
@@ -1 +1 @@
1
- import{r as e}from"./rolldown-runtime-hePW80VL.js";import{i as t,t as n}from"./react-CR5VJ85Q.js";import{a as r,c as i,i as a,l as o,n as s,o as c,r as l,s as u,t as d}from"./tiptap-74Cp-fci.js";var f=e(t(),1);function p(){return[c.configure({link:!1,heading:{levels:[2,3,4]}}),u.configure({openOnClick:!1,autolink:!1}),s.configure({resizable:!1}),r,l,a,d.configure({markedOptions:{gfm:!0,breaks:!1}})]}var m=n(),h=`min-h-[11rem] px-4 py-3 text-sm leading-6 text-[var(--color-text)] focus:outline-none prose prose-sm max-w-none [&_table]:my-3 [&_table]:w-full [&_table]:border-collapse [&_th]:border [&_th]:border-[var(--color-border)] [&_th]:bg-[var(--color-surface-elevated)] [&_th]:px-2 [&_th]:py-1.5 [&_td]:border [&_td]:border-[var(--color-border)] [&_td]:px-2 [&_td]:py-1.5`;function g({children:e,className:t=`h-4 w-4`}){return(0,m.jsx)(`svg`,{"aria-hidden":`true`,viewBox:`0 0 16 16`,fill:`none`,stroke:`currentColor`,strokeWidth:`1.5`,strokeLinecap:`round`,strokeLinejoin:`round`,className:t,children:e})}function _(){return(0,m.jsxs)(g,{children:[(0,m.jsx)(`circle`,{cx:`3`,cy:`4`,r:`1`,fill:`currentColor`,stroke:`none`}),(0,m.jsx)(`circle`,{cx:`3`,cy:`8`,r:`1`,fill:`currentColor`,stroke:`none`}),(0,m.jsx)(`circle`,{cx:`3`,cy:`12`,r:`1`,fill:`currentColor`,stroke:`none`}),(0,m.jsx)(`path`,{d:`M6 4h7`}),(0,m.jsx)(`path`,{d:`M6 8h7`}),(0,m.jsx)(`path`,{d:`M6 12h7`})]})}function v(){return(0,m.jsxs)(g,{children:[(0,m.jsx)(`path`,{d:`M6 10L4.5 11.5a2.5 2.5 0 1 1-3.5-3.5L2.5 6.5`}),(0,m.jsx)(`path`,{d:`M10 6l1.5-1.5a2.5 2.5 0 1 1 3.5 3.5L13.5 9.5`}),(0,m.jsx)(`path`,{d:`M5.5 10.5l5-5`})]})}function y(){return(0,m.jsxs)(g,{children:[(0,m.jsx)(`path`,{d:`M5.5 5.5A2.5 2.5 0 0 0 3 8v2.5h3V8H4.5`}),(0,m.jsx)(`path`,{d:`M11.5 5.5A2.5 2.5 0 0 0 9 8v2.5h3V8h-1.5`})]})}function b(){return(0,m.jsxs)(g,{children:[(0,m.jsx)(`path`,{d:`M6 5.5l2 5-2 5`}),(0,m.jsx)(`path`,{d:`M10 5.5l2 5-2 5`})]})}function x(){return(0,m.jsxs)(g,{children:[(0,m.jsx)(`path`,{d:`M6 4L2.5 8L6 12`}),(0,m.jsx)(`path`,{d:`M10 4l3.5 4L10 12`}),(0,m.jsx)(`path`,{d:`M8.75 3.5L7.25 12.5`})]})}function S(){return(0,m.jsxs)(g,{children:[(0,m.jsx)(`path`,{d:`M2 3h12v2H2V3z`}),(0,m.jsx)(`path`,{d:`M2 7h12v1H2V7z`}),(0,m.jsx)(`path`,{d:`M2 11h12v1H2v-1z`}),(0,m.jsx)(`path`,{d:`M2 15h12v1H2v-1z`}),(0,m.jsx)(`path`,{d:`M2 4v11`}),(0,m.jsx)(`path`,{d:`M6 4v11`}),(0,m.jsx)(`path`,{d:`M10 4v11`}),(0,m.jsx)(`path`,{d:`M14 4v11`})]})}function C({label:e,ariaLabel:t,active:n,onClick:r}){return(0,m.jsx)(`button`,{type:`button`,"aria-label":t,title:t,onClick:r,className:`inline-flex min-h-[36px] min-w-[36px] items-center justify-center rounded-[var(--radius-sm)] border px-3 text-xs font-medium transition-colors ${n?`border-[var(--color-primary)] bg-[var(--color-primary)] text-white`:`border-[var(--color-border)] bg-[var(--color-surface)] text-[var(--color-text-muted)] hover:bg-[var(--color-surface)] hover:text-[var(--color-text)]`}`,children:e})}function w({editor:e}){return e?(0,m.jsxs)(`div`,{className:`flex flex-wrap gap-2 border-b border-[var(--color-border)] bg-[var(--color-surface-elevated)] px-3 py-2`,children:[(0,m.jsx)(C,{label:(0,m.jsx)(`span`,{className:`text-base leading-none`,children:`¶`}),ariaLabel:`Paragraph`,active:e.isActive(`paragraph`),onClick:()=>e.chain().focus().setParagraph().run()}),(0,m.jsx)(C,{label:(0,m.jsx)(`strong`,{className:`text-sm font-semibold`,children:`B`}),ariaLabel:`Bold`,active:e.isActive(`bold`),onClick:()=>e.chain().focus().toggleBold().run()}),(0,m.jsx)(C,{label:(0,m.jsx)(`em`,{className:`text-sm`,children:`I`}),ariaLabel:`Italic`,active:e.isActive(`italic`),onClick:()=>e.chain().focus().toggleItalic().run()}),(0,m.jsx)(C,{label:(0,m.jsx)(_,{}),ariaLabel:`Bullet list`,active:e.isActive(`bulletList`),onClick:()=>e.chain().focus().toggleBulletList().run()}),(0,m.jsx)(C,{label:(0,m.jsx)(`span`,{className:`text-sm font-semibold`,children:`1.`}),ariaLabel:`Numbered list`,active:e.isActive(`orderedList`),onClick:()=>e.chain().focus().toggleOrderedList().run()}),(0,m.jsx)(C,{label:(0,m.jsx)(v,{}),ariaLabel:`Link`,active:e.isActive(`link`),onClick:()=>{let t=e.getAttributes(`link`).href,n=window.prompt(`Enter URL`,t??`https://`);if(n==null)return;let r=n.trim();if(!r){e.chain().focus().unsetLink().run();return}e.chain().focus().extendMarkRange(`link`).setLink({href:r}).run()}}),(0,m.jsx)(C,{label:(0,m.jsx)(y,{}),ariaLabel:`Quote`,active:e.isActive(`blockquote`),onClick:()=>e.chain().focus().toggleBlockquote().run()}),(0,m.jsx)(C,{label:(0,m.jsx)(b,{}),ariaLabel:`Inline code`,active:e.isActive(`code`),onClick:()=>e.chain().focus().toggleCode().run()}),(0,m.jsx)(C,{label:(0,m.jsx)(x,{}),ariaLabel:`Code block`,active:e.isActive(`codeBlock`),onClick:()=>e.chain().focus().toggleCodeBlock().run()}),(0,m.jsx)(C,{label:(0,m.jsx)(S,{}),ariaLabel:`Insert table`,active:e.isActive(`table`),onClick:()=>e.chain().focus().insertTable({rows:3,cols:3,withHeaderRow:!0}).run()})]}):null}function T({value:e,onChange:t,label:n,hint:r,id:a,contentKey:s}){let c=(0,f.useRef)(s),l=(0,f.useRef)(null),u=(0,f.useRef)(e),d=(0,f.useRef)(t);u.current=e,d.current=t;let g=o({immediatelyRender:!1,extensions:p(),content:e,contentType:`markdown`,editorProps:{attributes:{class:h}},onUpdate:({editor:e})=>{let t=e.getMarkdown?.()??``;l.current=t,t!==u.current&&d.current(t)}});return(0,f.useEffect)(()=>{if(g){if(s!==c.current){c.current=s,l.current=e,g.commands.setContent(e,{emitUpdate:!1,contentType:`markdown`});return}e!==l.current&&(l.current=e,g.commands.setContent(e,{emitUpdate:!1,contentType:`markdown`}))}},[s,e,g]),(0,m.jsxs)(`div`,{children:[n&&(0,m.jsx)(`label`,{htmlFor:a,className:`mb-2 block font-medium text-[var(--color-text-heading)]`,children:n}),(0,m.jsxs)(`div`,{className:`overflow-hidden rounded-[var(--radius-md)] border border-[var(--color-border)] bg-[var(--color-surface)]`,children:[(0,m.jsx)(w,{editor:g}),(0,m.jsx)(i,{editor:g})]}),r&&(0,m.jsx)(`p`,{className:`mt-2 text-sm text-[var(--color-text-muted)]`,children:r})]})}export{T as t};
1
+ import{r as e}from"./rolldown-runtime-hePW80VL.js";import{i as t,t as n}from"./react-BvB9BS1T.js";import{a as r,c as i,i as a,l as o,n as s,o as c,r as l,s as u,t as d}from"./tiptap-CCr8bvo1.js";var f=e(t(),1);function p(){return[c.configure({link:!1,heading:{levels:[2,3,4]}}),u.configure({openOnClick:!1,autolink:!1}),s.configure({resizable:!1}),r,l,a,d.configure({markedOptions:{gfm:!0,breaks:!1}})]}var m=n(),h=`min-h-[11rem] px-4 py-3 text-sm leading-6 text-[var(--color-text)] focus:outline-none prose prose-sm max-w-none [&_table]:my-3 [&_table]:w-full [&_table]:border-collapse [&_th]:border [&_th]:border-[var(--color-border)] [&_th]:bg-[var(--color-surface-elevated)] [&_th]:px-2 [&_th]:py-1.5 [&_td]:border [&_td]:border-[var(--color-border)] [&_td]:px-2 [&_td]:py-1.5`;function g({children:e,className:t=`h-4 w-4`}){return(0,m.jsx)(`svg`,{"aria-hidden":`true`,viewBox:`0 0 16 16`,fill:`none`,stroke:`currentColor`,strokeWidth:`1.5`,strokeLinecap:`round`,strokeLinejoin:`round`,className:t,children:e})}function _(){return(0,m.jsxs)(g,{children:[(0,m.jsx)(`circle`,{cx:`3`,cy:`4`,r:`1`,fill:`currentColor`,stroke:`none`}),(0,m.jsx)(`circle`,{cx:`3`,cy:`8`,r:`1`,fill:`currentColor`,stroke:`none`}),(0,m.jsx)(`circle`,{cx:`3`,cy:`12`,r:`1`,fill:`currentColor`,stroke:`none`}),(0,m.jsx)(`path`,{d:`M6 4h7`}),(0,m.jsx)(`path`,{d:`M6 8h7`}),(0,m.jsx)(`path`,{d:`M6 12h7`})]})}function v(){return(0,m.jsxs)(g,{children:[(0,m.jsx)(`path`,{d:`M6 10L4.5 11.5a2.5 2.5 0 1 1-3.5-3.5L2.5 6.5`}),(0,m.jsx)(`path`,{d:`M10 6l1.5-1.5a2.5 2.5 0 1 1 3.5 3.5L13.5 9.5`}),(0,m.jsx)(`path`,{d:`M5.5 10.5l5-5`})]})}function y(){return(0,m.jsxs)(g,{children:[(0,m.jsx)(`path`,{d:`M5.5 5.5A2.5 2.5 0 0 0 3 8v2.5h3V8H4.5`}),(0,m.jsx)(`path`,{d:`M11.5 5.5A2.5 2.5 0 0 0 9 8v2.5h3V8h-1.5`})]})}function b(){return(0,m.jsxs)(g,{children:[(0,m.jsx)(`path`,{d:`M6 5.5l2 5-2 5`}),(0,m.jsx)(`path`,{d:`M10 5.5l2 5-2 5`})]})}function x(){return(0,m.jsxs)(g,{children:[(0,m.jsx)(`path`,{d:`M6 4L2.5 8L6 12`}),(0,m.jsx)(`path`,{d:`M10 4l3.5 4L10 12`}),(0,m.jsx)(`path`,{d:`M8.75 3.5L7.25 12.5`})]})}function S(){return(0,m.jsxs)(g,{children:[(0,m.jsx)(`path`,{d:`M2 3h12v2H2V3z`}),(0,m.jsx)(`path`,{d:`M2 7h12v1H2V7z`}),(0,m.jsx)(`path`,{d:`M2 11h12v1H2v-1z`}),(0,m.jsx)(`path`,{d:`M2 15h12v1H2v-1z`}),(0,m.jsx)(`path`,{d:`M2 4v11`}),(0,m.jsx)(`path`,{d:`M6 4v11`}),(0,m.jsx)(`path`,{d:`M10 4v11`}),(0,m.jsx)(`path`,{d:`M14 4v11`})]})}function C({label:e,ariaLabel:t,active:n,onClick:r}){return(0,m.jsx)(`button`,{type:`button`,"aria-label":t,title:t,onClick:r,className:`inline-flex min-h-[36px] min-w-[36px] items-center justify-center rounded-[var(--radius-sm)] border px-3 text-xs font-medium transition-colors ${n?`border-[var(--color-primary)] bg-[var(--color-primary)] text-white`:`border-[var(--color-border)] bg-[var(--color-surface)] text-[var(--color-text-muted)] hover:bg-[var(--color-surface)] hover:text-[var(--color-text)]`}`,children:e})}function w({editor:e}){return e?(0,m.jsxs)(`div`,{className:`flex flex-wrap gap-2 border-b border-[var(--color-border)] bg-[var(--color-surface-elevated)] px-3 py-2`,children:[(0,m.jsx)(C,{label:(0,m.jsx)(`span`,{className:`text-base leading-none`,children:`¶`}),ariaLabel:`Paragraph`,active:e.isActive(`paragraph`),onClick:()=>e.chain().focus().setParagraph().run()}),(0,m.jsx)(C,{label:(0,m.jsx)(`strong`,{className:`text-sm font-semibold`,children:`B`}),ariaLabel:`Bold`,active:e.isActive(`bold`),onClick:()=>e.chain().focus().toggleBold().run()}),(0,m.jsx)(C,{label:(0,m.jsx)(`em`,{className:`text-sm`,children:`I`}),ariaLabel:`Italic`,active:e.isActive(`italic`),onClick:()=>e.chain().focus().toggleItalic().run()}),(0,m.jsx)(C,{label:(0,m.jsx)(_,{}),ariaLabel:`Bullet list`,active:e.isActive(`bulletList`),onClick:()=>e.chain().focus().toggleBulletList().run()}),(0,m.jsx)(C,{label:(0,m.jsx)(`span`,{className:`text-sm font-semibold`,children:`1.`}),ariaLabel:`Numbered list`,active:e.isActive(`orderedList`),onClick:()=>e.chain().focus().toggleOrderedList().run()}),(0,m.jsx)(C,{label:(0,m.jsx)(v,{}),ariaLabel:`Link`,active:e.isActive(`link`),onClick:()=>{let t=e.getAttributes(`link`).href,n=window.prompt(`Enter URL`,t??`https://`);if(n==null)return;let r=n.trim();r?e.chain().focus().extendMarkRange(`link`).setLink({href:r}).run():e.chain().focus().unsetLink().run()}}),(0,m.jsx)(C,{label:(0,m.jsx)(y,{}),ariaLabel:`Quote`,active:e.isActive(`blockquote`),onClick:()=>e.chain().focus().toggleBlockquote().run()}),(0,m.jsx)(C,{label:(0,m.jsx)(b,{}),ariaLabel:`Inline code`,active:e.isActive(`code`),onClick:()=>e.chain().focus().toggleCode().run()}),(0,m.jsx)(C,{label:(0,m.jsx)(x,{}),ariaLabel:`Code block`,active:e.isActive(`codeBlock`),onClick:()=>e.chain().focus().toggleCodeBlock().run()}),(0,m.jsx)(C,{label:(0,m.jsx)(S,{}),ariaLabel:`Insert table`,active:e.isActive(`table`),onClick:()=>e.chain().focus().insertTable({rows:3,cols:3,withHeaderRow:!0}).run()})]}):null}function T({value:e,onChange:t,label:n,hint:r,id:a,contentKey:s}){let c=(0,f.useRef)(s),l=(0,f.useRef)(null),u=(0,f.useRef)(e),d=(0,f.useRef)(t);u.current=e,d.current=t;let g=o({immediatelyRender:!1,extensions:p(),content:e,contentType:`markdown`,editorProps:{attributes:{class:h}},onUpdate:({editor:e})=>{let t=e.getMarkdown?.()??``;l.current=t,t!==u.current&&d.current(t)}});return(0,f.useEffect)(()=>{g&&(s===c.current?e!==l.current&&(l.current=e,g.commands.setContent(e,{emitUpdate:!1,contentType:`markdown`})):(c.current=s,l.current=e,g.commands.setContent(e,{emitUpdate:!1,contentType:`markdown`})))},[s,e,g]),(0,m.jsxs)(`div`,{children:[n&&(0,m.jsx)(`label`,{htmlFor:a,className:`mb-2 block font-medium text-[var(--color-text-heading)]`,children:n}),(0,m.jsxs)(`div`,{className:`overflow-hidden rounded-[var(--radius-md)] border border-[var(--color-border)] bg-[var(--color-surface)]`,children:[(0,m.jsx)(w,{editor:g}),(0,m.jsx)(i,{editor:g})]}),r&&(0,m.jsx)(`p`,{className:`mt-2 text-sm text-[var(--color-text-muted)]`,children:r})]})}export{T as t};
@@ -1 +1 @@
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-DGTQ2S8W.js";import{i as o,t as s}from"./react-CR5VJ85Q.js";import{t as c}from"./api-BgTb-tmJ.js";import{t as l}from"./SurfaceCard-CRidnDLP.js";import{t as u}from"./ErrorAlert-BQMph5Nh.js";import{n as d}from"./ChallengeCard-gY-n7rwI.js";import{n as f,t as p}from"./StepFlowGraph-DsL5lsIq.js";import{n as m,t as h}from"./useRunSession-BX2U9D53.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};
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};
@@ -1 +1 @@
1
- import{a as e,y as t}from"./vendor-DGTQ2S8W.js";import{t as n}from"./react-CR5VJ85Q.js";import{n as r}from"./useRunSession-BX2U9D53.js";var i=n();function a(){let{t:n}=t(),{sessions:a,remove:o}=r();return(0,i.jsxs)(`div`,{children:[(0,i.jsx)(`h1`,{className:`text-[var(--color-text-heading)] text-2xl font-semibold mb-1`,children:n(`runs.title`)}),(0,i.jsx)(`p`,{className:`text-sm text-[var(--color-text-muted)] mb-6`,children:n(`runs.subtitle`)}),a.length===0?(0,i.jsx)(`div`,{className:`rounded-[var(--radius-md)] border border-[var(--color-border)] bg-[var(--color-surface-elevated)] p-6`,children:(0,i.jsx)(`p`,{className:`text-[var(--color-text-muted)]`,children:n(`runs.empty`)})}):(0,i.jsx)(`ul`,{className:`list-none p-0 m-0 space-y-3`,"aria-label":n(`runs.listLabel`),children:a.map(t=>(0,i.jsxs)(`li`,{className:`flex flex-col gap-3 rounded-[var(--radius-md)] border border-[var(--color-border)] bg-[var(--color-surface-elevated)] p-4 sm:flex-row sm:items-start sm:justify-between`,children:[(0,i.jsxs)(`div`,{className:`min-w-0`,children:[(0,i.jsx)(`div`,{className:`font-medium text-[var(--color-text-heading)] truncate`,children:t.adapter_uri}),(0,i.jsxs)(`div`,{className:`text-sm text-[var(--color-text-muted)] mt-1`,children:[n(`runs.status`),`: `,t.status,` · `,n(`runs.updated`),`: `,new Date(t.updated_at).toLocaleString(),` · `,n(`runs.stepsDone`,{count:t.history.length})]}),t.last_message&&(0,i.jsx)(`div`,{className:`text-sm text-[var(--color-text-muted)] mt-1`,children:t.last_message})]}),(0,i.jsxs)(`div`,{className:`flex flex-wrap gap-2 flex-shrink-0`,children:[(0,i.jsx)(e,{to:`/protocols/${encodeURIComponent(t.adapter_uri)}/run?session=${encodeURIComponent(t.id)}`,className:`min-h-[44px] min-w-[44px] inline-flex items-center justify-center px-4 py-2 rounded-[var(--radius-md)] font-medium bg-[var(--color-primary)] text-white no-underline 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:n(`runs.resume`)}),(0,i.jsx)(`button`,{type:`button`,onClick:()=>o(t.id),className:`min-h-[44px] min-w-[44px] px-4 py-2 rounded-[var(--radius-md)] font-medium border border-[var(--color-border)] text-[var(--color-text)] bg-transparent 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:n(`runs.remove`)})]})]},t.id))})]})}export{a as RunsPage};
1
+ import{a as e,y as t}from"./vendor-xESPQGR9.js";import{t as n}from"./react-BvB9BS1T.js";import{n as r}from"./useRunSession-CB5wPJ8O.js";var i=n();function a(){let{t:n}=t(),{sessions:a,remove:o}=r();return(0,i.jsxs)(`div`,{children:[(0,i.jsx)(`h1`,{className:`text-[var(--color-text-heading)] text-2xl font-semibold mb-1`,children:n(`runs.title`)}),(0,i.jsx)(`p`,{className:`text-sm text-[var(--color-text-muted)] mb-6`,children:n(`runs.subtitle`)}),a.length===0?(0,i.jsx)(`div`,{className:`rounded-[var(--radius-md)] border border-[var(--color-border)] bg-[var(--color-surface-elevated)] p-6`,children:(0,i.jsx)(`p`,{className:`text-[var(--color-text-muted)]`,children:n(`runs.empty`)})}):(0,i.jsx)(`ul`,{className:`list-none p-0 m-0 space-y-3`,"aria-label":n(`runs.listLabel`),children:a.map(t=>(0,i.jsxs)(`li`,{className:`flex flex-col gap-3 rounded-[var(--radius-md)] border border-[var(--color-border)] bg-[var(--color-surface-elevated)] p-4 sm:flex-row sm:items-start sm:justify-between`,children:[(0,i.jsxs)(`div`,{className:`min-w-0`,children:[(0,i.jsx)(`div`,{className:`font-medium text-[var(--color-text-heading)] truncate`,children:t.adapter_uri}),(0,i.jsxs)(`div`,{className:`text-sm text-[var(--color-text-muted)] mt-1`,children:[n(`runs.status`),`: `,t.status,` · `,n(`runs.updated`),`: `,new Date(t.updated_at).toLocaleString(),` · `,n(`runs.stepsDone`,{count:t.history.length})]}),t.last_message&&(0,i.jsx)(`div`,{className:`text-sm text-[var(--color-text-muted)] mt-1`,children:t.last_message})]}),(0,i.jsxs)(`div`,{className:`flex flex-wrap gap-2 flex-shrink-0`,children:[(0,i.jsx)(e,{to:`/protocols/${encodeURIComponent(t.adapter_uri)}/run?session=${encodeURIComponent(t.id)}`,className:`min-h-[44px] min-w-[44px] inline-flex items-center justify-center px-4 py-2 rounded-[var(--radius-md)] font-medium bg-[var(--color-primary)] text-white no-underline 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:n(`runs.resume`)}),(0,i.jsx)(`button`,{type:`button`,onClick:()=>o(t.id),className:`min-h-[44px] min-w-[44px] px-4 py-2 rounded-[var(--radius-md)] font-medium border border-[var(--color-border)] text-[var(--color-text)] bg-transparent 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:n(`runs.remove`)})]})]},t.id))})]})}export{a as RunsPage};
@@ -1 +1 @@
1
- import{r as e}from"./rolldown-runtime-hePW80VL.js";import{a as t,m as n,y as r}from"./vendor-DGTQ2S8W.js";import{i,t as a}from"./react-CR5VJ85Q.js";import{t as o}from"./SurfaceCard-CRidnDLP.js";import{a as s,n as c,r as l,s as u,t as d}from"./export-skill-zip-C1bRyhE2.js";import{t as f}from"./RichTextEditor-Bj6JxHM5.js";var p=e(i(),1),m=a();function h(e){return`min-h-[44px] rounded-full px-4 text-sm font-medium ${e?`bg-[var(--color-primary)] text-white`:`border border-[var(--color-border)] bg-[var(--color-surface)] text-[var(--color-text)]`}`}function g(){let{t:e}=r(),{uri:i}=n(),{data:a,isLoading:g,isError:_,error:v}=u(i?decodeURIComponent(i):void 0,!0),[y,b]=(0,p.useState)(``),[x,S]=(0,p.useState)(``),[C,w]=(0,p.useState)(``),[T,E]=(0,p.useState)(!0),[D,O]=(0,p.useState)(!1),[k,A]=(0,p.useState)(null);if(g&&!a)return(0,m.jsx)(`p`,{className:`text-[var(--color-text-muted)]`,children:e(`protocol.loading`)});if(_||!a)return(0,m.jsxs)(`div`,{role:`alert`,className:`rounded-[var(--radius-md)] bg-[var(--color-error-bg)] p-4 text-[var(--color-error)]`,children:[v instanceof Error?v.message:e(`protocol.notFound`),(0,m.jsx)(t,{to:`/`,className:`mt-2 block text-[var(--color-primary)] underline hover:no-underline focus-visible:outline focus-visible:outline-2 focus-visible:outline-[var(--color-focus-ring)] focus-visible:outline-offset-2`,children:e(`notFound.goHome`)})]});let{title:j}=s(a.content),M=(y.trim()||j).replace(/[^a-zA-Z0-9]+/g,`-`).replace(/^-|-$/g,``)||`skill`,N=`${M}-skill`,P=async()=>{A(null),O(!0);try{let{blob:e,skill_bundle_manifest:t}=await d(a.uri),n=c(t,M);l(e,n)}catch(e){A(e instanceof Error?e.message:String(e))}finally{O(!1)}};return(0,m.jsxs)(`div`,{children:[(0,m.jsx)(`h1`,{className:`mb-1 text-2xl font-semibold text-[var(--color-text-heading)]`,children:e(`skill.title`)}),(0,m.jsx)(`p`,{className:`mb-6 text-sm text-[var(--color-text-muted)]`,children:e(`skill.subtitle`)}),(0,m.jsxs)(`div`,{className:`grid gap-4 xl:grid-cols-[1.3fr_1fr]`,children:[(0,m.jsxs)(`div`,{className:`space-y-4`,children:[(0,m.jsxs)(`div`,{children:[(0,m.jsx)(`label`,{htmlFor:`skill-name`,className:`mb-2 block font-medium text-[var(--color-text-heading)]`,children:e(`skill.skillName`)}),(0,m.jsx)(`input`,{id:`skill-name`,type:`text`,value:y,onChange:e=>b(e.target.value),placeholder:j,className:`min-h-[44px] w-full rounded-[var(--radius-md)] border border-[var(--color-border)] bg-[var(--color-surface)] px-4 py-3 text-sm text-[var(--color-text)] focus-visible:outline focus-visible:outline-2 focus-visible:outline-[var(--color-focus-ring)] focus-visible:outline-offset-2`})]}),(0,m.jsx)(f,{label:e(`skill.description`),hint:e(`skill.descriptionHint`),value:x,onChange:S,contentKey:`skill-desc`}),(0,m.jsx)(f,{label:e(`skill.whenToUse`),value:C,onChange:w,contentKey:`skill-when`}),(0,m.jsx)(o,{title:e(`skill.bundleContentsTitle`),subtitle:e(`skill.bundleContentsSubtitle`),children:(0,m.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[(0,m.jsx)(`button`,{type:`button`,"aria-pressed":T,onClick:()=>E(e=>!e),className:h(T),children:e(`skill.includeReferences`)}),(0,m.jsx)(`button`,{type:`button`,disabled:!0,className:`${h(!1)} cursor-not-allowed opacity-50`,title:e(`skill.comingSoon`),children:e(`skill.chipReadme`)}),(0,m.jsx)(`button`,{type:`button`,disabled:!0,className:`${h(!1)} cursor-not-allowed opacity-50`,title:e(`skill.comingSoon`),children:e(`skill.chipPrompts`)})]})}),(0,m.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[(0,m.jsx)(`button`,{type:`button`,onClick:()=>void P(),disabled:D,className:`min-h-[44px] min-w-[44px] inline-flex items-center justify-center rounded-[var(--radius-md)] 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:opacity-60`,children:e(`skill.downloadAsSkill`)}),k?(0,m.jsx)(`p`,{className:`m-0 text-sm text-[var(--color-error)]`,role:`alert`,children:k}):null,(0,m.jsx)(t,{to:`/protocols/${encodeURIComponent(a.uri)}`,className:`min-h-[44px] min-w-[44px] inline-flex items-center justify-center rounded-[var(--radius-md)] border border-[var(--color-border)] bg-[var(--color-surface)] px-4 py-2 font-medium 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(`skill.backToProtocol`)})]})]}),(0,m.jsxs)(`div`,{className:`space-y-4`,children:[(0,m.jsx)(o,{title:e(`skill.bundlePreviewTitle`),subtitle:e(`skill.bundlePreviewSubtitle`),children:(0,m.jsxs)(`div`,{className:`rounded-[var(--radius-md)] border border-[var(--color-border)] bg-[var(--color-surface)] p-4 font-mono text-sm text-[var(--color-text)]`,children:[N,`.zip`,(0,m.jsx)(`br`,{}),`└── `,N,`/`,(0,m.jsx)(`br`,{}),`\xA0\xA0\xA0\xA0├── Skill.md`,(0,m.jsx)(`br`,{}),T?(0,m.jsxs)(m.Fragment,{children:[`\xA0\xA0\xA0\xA0└── references/`,(0,m.jsx)(`br`,{}),`\xA0\xA0\xA0\xA0\xA0\xA0\xA0\xA0└── SQUADRULES.md`]}):(0,m.jsx)(m.Fragment,{children:`\xA0\xA0\xA0\xA0└── (no references/)`})]})}),(0,m.jsx)(o,{title:e(`skill.whyExportTitle`),subtitle:e(`skill.whyExportSubtitle`),children:(0,m.jsx)(`p`,{className:`m-0 text-sm text-[var(--color-text-muted)]`,children:e(`skill.whyExportBody`)})})]})]})]})}export{g as SkillBundlePage};
1
+ import{r as e}from"./rolldown-runtime-hePW80VL.js";import{a as t,m as n,y as r}from"./vendor-xESPQGR9.js";import{i,t as a}from"./react-BvB9BS1T.js";import{t as o}from"./SurfaceCard-BzJidvvn.js";import{a as s,n as c,r as l,s as u,t as d}from"./export-skill-zip-D8iQY1Dl.js";import{t as f}from"./RichTextEditor-DWLV579w.js";var p=e(i(),1),m=a();function h(e){return`min-h-[44px] rounded-full px-4 text-sm font-medium ${e?`bg-[var(--color-primary)] text-white`:`border border-[var(--color-border)] bg-[var(--color-surface)] text-[var(--color-text)]`}`}function g(){let{t:e}=r(),{uri:i}=n(),{data:a,isLoading:g,isError:_,error:v}=u(i?decodeURIComponent(i):void 0,!0),[y,b]=(0,p.useState)(``),[x,S]=(0,p.useState)(``),[C,w]=(0,p.useState)(``),[T,E]=(0,p.useState)(!0),[D,O]=(0,p.useState)(!1),[k,A]=(0,p.useState)(null);if(g&&!a)return(0,m.jsx)(`p`,{className:`text-[var(--color-text-muted)]`,children:e(`protocol.loading`)});if(_||!a)return(0,m.jsxs)(`div`,{role:`alert`,className:`rounded-[var(--radius-md)] bg-[var(--color-error-bg)] p-4 text-[var(--color-error)]`,children:[v instanceof Error?v.message:e(`protocol.notFound`),(0,m.jsx)(t,{to:`/`,className:`mt-2 block text-[var(--color-primary)] underline hover:no-underline focus-visible:outline focus-visible:outline-2 focus-visible:outline-[var(--color-focus-ring)] focus-visible:outline-offset-2`,children:e(`notFound.goHome`)})]});let{title:j}=s(a.content),M=(y.trim()||j).replace(/[^a-zA-Z0-9]+/g,`-`).replace(/^-|-$/g,``)||`skill`,N=`${M}-skill`,P=async()=>{A(null),O(!0);try{let{blob:e,skill_bundle_manifest:t}=await d(a.uri),n=c(t,M);l(e,n)}catch(e){A(e instanceof Error?e.message:String(e))}finally{O(!1)}};return(0,m.jsxs)(`div`,{children:[(0,m.jsx)(`h1`,{className:`mb-1 text-2xl font-semibold text-[var(--color-text-heading)]`,children:e(`skill.title`)}),(0,m.jsx)(`p`,{className:`mb-6 text-sm text-[var(--color-text-muted)]`,children:e(`skill.subtitle`)}),(0,m.jsxs)(`div`,{className:`grid gap-4 xl:grid-cols-[1.3fr_1fr]`,children:[(0,m.jsxs)(`div`,{className:`space-y-4`,children:[(0,m.jsxs)(`div`,{children:[(0,m.jsx)(`label`,{htmlFor:`skill-name`,className:`mb-2 block font-medium text-[var(--color-text-heading)]`,children:e(`skill.skillName`)}),(0,m.jsx)(`input`,{id:`skill-name`,type:`text`,value:y,onChange:e=>b(e.target.value),placeholder:j,className:`min-h-[44px] w-full rounded-[var(--radius-md)] border border-[var(--color-border)] bg-[var(--color-surface)] px-4 py-3 text-sm text-[var(--color-text)] focus-visible:outline focus-visible:outline-2 focus-visible:outline-[var(--color-focus-ring)] focus-visible:outline-offset-2`})]}),(0,m.jsx)(f,{label:e(`skill.description`),hint:e(`skill.descriptionHint`),value:x,onChange:S,contentKey:`skill-desc`}),(0,m.jsx)(f,{label:e(`skill.whenToUse`),value:C,onChange:w,contentKey:`skill-when`}),(0,m.jsx)(o,{title:e(`skill.bundleContentsTitle`),subtitle:e(`skill.bundleContentsSubtitle`),children:(0,m.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[(0,m.jsx)(`button`,{type:`button`,"aria-pressed":T,onClick:()=>E(e=>!e),className:h(T),children:e(`skill.includeReferences`)}),(0,m.jsx)(`button`,{type:`button`,disabled:!0,className:`${h(!1)} cursor-not-allowed opacity-50`,title:e(`skill.comingSoon`),children:e(`skill.chipReadme`)}),(0,m.jsx)(`button`,{type:`button`,disabled:!0,className:`${h(!1)} cursor-not-allowed opacity-50`,title:e(`skill.comingSoon`),children:e(`skill.chipPrompts`)})]})}),(0,m.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[(0,m.jsx)(`button`,{type:`button`,onClick:()=>void P(),disabled:D,className:`min-h-[44px] min-w-[44px] inline-flex items-center justify-center rounded-[var(--radius-md)] 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:opacity-60`,children:e(`skill.downloadAsSkill`)}),k?(0,m.jsx)(`p`,{className:`m-0 text-sm text-[var(--color-error)]`,role:`alert`,children:k}):null,(0,m.jsx)(t,{to:`/protocols/${encodeURIComponent(a.uri)}`,className:`min-h-[44px] min-w-[44px] inline-flex items-center justify-center rounded-[var(--radius-md)] border border-[var(--color-border)] bg-[var(--color-surface)] px-4 py-2 font-medium 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(`skill.backToProtocol`)})]})]}),(0,m.jsxs)(`div`,{className:`space-y-4`,children:[(0,m.jsx)(o,{title:e(`skill.bundlePreviewTitle`),subtitle:e(`skill.bundlePreviewSubtitle`),children:(0,m.jsxs)(`div`,{className:`rounded-[var(--radius-md)] border border-[var(--color-border)] bg-[var(--color-surface)] p-4 font-mono text-sm text-[var(--color-text)]`,children:[N,`.zip`,(0,m.jsx)(`br`,{}),`└── `,N,`/`,(0,m.jsx)(`br`,{}),`\xA0\xA0\xA0\xA0├── Skill.md`,(0,m.jsx)(`br`,{}),T?(0,m.jsxs)(m.Fragment,{children:[`\xA0\xA0\xA0\xA0└── references/`,(0,m.jsx)(`br`,{}),`\xA0\xA0\xA0\xA0\xA0\xA0\xA0\xA0└── SQUADRULES.md`]}):(0,m.jsx)(m.Fragment,{children:`\xA0\xA0\xA0\xA0└── (no references/)`})]})}),(0,m.jsx)(o,{title:e(`skill.whyExportTitle`),subtitle:e(`skill.whyExportSubtitle`),children:(0,m.jsx)(`p`,{className:`m-0 text-sm text-[var(--color-text-muted)]`,children:e(`skill.whyExportBody`)})})]})]})]})}export{g as SkillBundlePage};
@@ -1 +1 @@
1
- import{g as e,y as t}from"./vendor-DGTQ2S8W.js";import{t as n}from"./react-CR5VJ85Q.js";import{t as r}from"./api-BgTb-tmJ.js";async function i(e={}){let t=await r(`/api/spaces`,{method:`POST`,body:JSON.stringify({include_adapter_titles:e.includeAdapterTitles??!1})});if(!t.ok){let e=(await t.json().catch(()=>({}))).message??t.statusText;throw Error(e)}return{spaces:(await t.json()).spaces??[]}}function a(t=!0,n={}){let r=n.includeAdapterTitles??!1;return e({queryKey:[`spaces`,{includeAdapterTitles:r}],queryFn:()=>i(n),enabled:t})}var o=n(),s={personal:`bg-[var(--badge-personal-bg)] text-[var(--badge-personal-fg)]`,group:`bg-[var(--badge-group-bg)] text-[var(--badge-group-fg)]`,app:`bg-[var(--badge-app-bg)] text-[var(--badge-app-fg)]`,other:`bg-[var(--badge-other-bg)] text-[var(--badge-other-fg)]`};function c({id:e,spaces:n,value:r,onChange:i,includeAllOption:a=!1,disabled:s=!1,"aria-describedby":c}){let{t:l}=t(),u=n??[];return(0,o.jsxs)(`select`,{id:e,value:r,disabled:s||u.length===0&&!a,onChange:e=>i(e.target.value),"aria-describedby":c,className:`min-h-[44px] w-full max-w-md rounded-[var(--radius-md)] border border-[var(--color-border)] bg-[var(--color-surface)] px-3 py-2 text-[var(--color-text)] focus-visible:outline focus-visible:outline-2 focus-visible:outline-[var(--color-focus-ring)] focus-visible:outline-offset-2`,children:[a?(0,o.jsx)(`option`,{value:``,children:l(`spaces.filterAll`)}):null,u.map(e=>(0,o.jsx)(`option`,{value:e.space_id,children:e.name},e.space_id))]})}function l({type:e}){let{t:n}=t(),r=n(`spaces.type.${e}`);return(0,o.jsx)(`span`,{className:`inline-block rounded px-2 py-0.5 text-xs font-medium uppercase tracking-wide ${s[e]}`,children:r})}export{l as n,a as r,c as t};
1
+ import{g as e,y as t}from"./vendor-xESPQGR9.js";import{t as n}from"./react-BvB9BS1T.js";import{t as r}from"./api-BgTb-tmJ.js";async function i(e={}){let t=await r(`/api/spaces`,{method:`POST`,body:JSON.stringify({include_adapter_titles:e.includeAdapterTitles??!1})});if(!t.ok){let e=(await t.json().catch(()=>({}))).message??t.statusText;throw Error(e)}return{spaces:(await t.json()).spaces??[]}}function a(t=!0,n={}){let r=n.includeAdapterTitles??!1;return e({queryKey:[`spaces`,{includeAdapterTitles:r}],queryFn:()=>i(n),enabled:t})}var o=n(),s={personal:`bg-[var(--badge-personal-bg)] text-[var(--badge-personal-fg)]`,group:`bg-[var(--badge-group-bg)] text-[var(--badge-group-fg)]`,app:`bg-[var(--badge-app-bg)] text-[var(--badge-app-fg)]`,other:`bg-[var(--badge-other-bg)] text-[var(--badge-other-fg)]`};function c({id:e,spaces:n,value:r,onChange:i,includeAllOption:a=!1,disabled:s=!1,"aria-describedby":c}){let{t:l}=t(),u=n??[];return(0,o.jsxs)(`select`,{id:e,value:r,disabled:s||u.length===0&&!a,onChange:e=>i(e.target.value),"aria-describedby":c,className:`min-h-[44px] w-full max-w-md rounded-[var(--radius-md)] border border-[var(--color-border)] bg-[var(--color-surface)] px-3 py-2 text-[var(--color-text)] focus-visible:outline focus-visible:outline-2 focus-visible:outline-[var(--color-focus-ring)] focus-visible:outline-offset-2`,children:[a?(0,o.jsx)(`option`,{value:``,children:l(`spaces.filterAll`)}):null,u.map(e=>(0,o.jsx)(`option`,{value:e.space_id,children:e.name},e.space_id))]})}function l({type:e}){let{t:n}=t(),r=n(`spaces.type.${e}`);return(0,o.jsx)(`span`,{className:`inline-block rounded px-2 py-0.5 text-xs font-medium uppercase tracking-wide ${s[e]}`,children:r})}export{l as n,a as r,c as t};
@@ -1 +1 @@
1
- import{r as e}from"./rolldown-runtime-hePW80VL.js";import{a as t,g as n,s as r,y as i}from"./vendor-DGTQ2S8W.js";import{i as a,t as o}from"./react-CR5VJ85Q.js";import{t as s}from"./api-BgTb-tmJ.js";import{n as c,r as l,t as u}from"./SpaceSelect-DDhPkDXU.js";import{t as d}from"./ErrorAlert-BQMph5Nh.js";var f=e(a(),1);async function p(e,t){let n={query:e.trim()},r=t?.space?.trim();r&&(n.space=r),t?.max_choices!=null&&(n.max_choices=t.max_choices);let i=await s(`/api/activate`,{method:`POST`,body:JSON.stringify(n)});if(!i.ok){let e=await i.json().catch(()=>({}));throw Error(e.message??i.statusText)}return await i.json()}function m(e,t,n){let r=e.trim();return{queryKey:[`activate`,r,(n?.space?.trim()??``)||null,n?.max_choices??null],queryFn:()=>p(r,n),enabled:t&&r.length>0}}function h(e,t,r){return n(m(e,t,r))}var g=o();function _(){return(0,g.jsx)(`ul`,{className:`list-none p-0 m-0 space-y-2`,role:`list`,"aria-hidden":`true`,children:[1,2,3].map(e=>(0,g.jsxs)(`li`,{className:`rounded-[var(--radius-md)] border border-[var(--color-border)] bg-[var(--color-surface-elevated)] p-4 flex justify-between items-start gap-4`,children:[(0,g.jsxs)(`div`,{className:`flex-1 min-w-0 space-y-2`,children:[(0,g.jsx)(`div`,{className:`h-5 w-3/4 rounded bg-[var(--color-border)] animate-pulse`}),(0,g.jsx)(`div`,{className:`h-4 w-1/2 rounded bg-[var(--color-border)] animate-pulse`}),(0,g.jsx)(`div`,{className:`h-5 w-16 rounded bg-[var(--color-border)] animate-pulse`})]}),(0,g.jsx)(`div`,{className:`h-10 w-20 rounded-[var(--radius-md)] bg-[var(--color-border)] animate-pulse flex-shrink-0`})]},e))})}function v(e){return typeof e!=`number`||Number.isNaN(e)?0:Math.round(Math.max(0,Math.min(e,1))*100)}var y=`ABCDEFGHIJKLMNOPQRSTUVWXYZ`.split(``);function b(e){let t=[];for(let n of e??[])for(let e of n.adapters??[])t.push({adapter_id:e.adapter_id,title:e.title,layer_count:e.layer_count,slug:e.slug,uri:e.uri,space_name:n.name,space_type:n.type});let n=new Map,r=[];for(let e of t){let t=(e.adapter_id??``).trim();if(!t){r.push(e);continue}let i=n.get(t);i?(e.layer_count??0)>(i.layer_count??0)&&n.set(t,e):n.set(t,e)}let i=[...n.values(),...r],a={};for(let e of y)a[e]=0;for(let e of i){let t=(e.title??``).trim().charAt(0).toUpperCase();y.includes(t)&&(a[t]=(a[t]??0)+1)}return{browseAdapters:i,countsByLetter:a}}function x(e){let{t:n,spacesLoading:r,browseAdapters:i,countsByLetter:a}=e,[o,s]=(0,f.useState)(null),l=(0,f.useMemo)(()=>o?i.filter(e=>(e.title??``).trim().charAt(0).toUpperCase()===o).sort((e,t)=>(e.title??``).localeCompare(t.title??``,void 0,{sensitivity:`base`})):[],[i,o]),u=i.length>0;return(0,g.jsxs)(`section`,{"aria-labelledby":`browse-by-label-heading`,children:[(0,g.jsx)(`h2`,{id:`browse-by-label-heading`,className:`text-lg font-semibold text-[var(--color-text-heading)] mb-3`,children:n(`squadrules.browseByLabel`)}),(0,g.jsx)(`p`,{className:`text-sm text-[var(--color-text-muted)] mb-4`,children:n(`squadrules.browseByLetterHint`)}),!r&&!u?(0,g.jsx)(`p`,{className:`text-sm text-[var(--color-text-muted)]`,children:n(`squadrules.browseEmpty`)}):null,!r&&u?(0,g.jsx)(`div`,{className:`flex flex-wrap gap-2 mb-4`,role:`group`,"aria-label":n(`squadrules.browseByLabel`),children:y.map(e=>{let t=a[e]??0;return(0,g.jsxs)(`button`,{type:`button`,onClick:()=>s(t=>t===e?null:e),"aria-expanded":o===e,"aria-controls":`browse-letter-panel-${e}`,"aria-pressed":o===e,"aria-label":n(`squadrules.letterCount`,{letter:e,count:t}),className:`min-h-[var(--layout-touch-target)] min-w-[var(--layout-touch-target)] inline-flex items-center justify-center rounded-[var(--radius-md)] border px-3 py-2 text-sm font-medium transition-colors focus-visible:outline focus-visible:outline-2 focus-visible:outline-[var(--color-focus-ring)] focus-visible:outline-offset-2 ${o===e?`border-[var(--color-primary)] bg-[var(--color-surface-elevated)] text-[var(--color-primary)]`:`border-[var(--color-border)] bg-[var(--color-surface)] text-[var(--color-text)] hover:bg-[var(--color-surface-elevated)]`}`,children:[e,`: `,t]},e)})}):null,o&&!r&&u?(0,g.jsxs)(`div`,{id:`browse-letter-panel-${o}`,role:`region`,"aria-labelledby":`browse-letter-panel-heading`,"aria-live":`polite`,className:`rounded-[var(--radius-md)] border border-[var(--color-border)] bg-[var(--color-surface-elevated)] p-5`,children:[(0,g.jsx)(`h3`,{id:`browse-letter-panel-heading`,className:`text-base font-semibold text-[var(--color-text-heading)] mb-3`,children:n(`squadrules.labelsStartingWith`,{letter:o})}),l.length===0?(0,g.jsx)(`p`,{className:`text-sm text-[var(--color-text-muted)]`,children:n(`squadrules.noLabelsForLetter`)}):(0,g.jsx)(`ul`,{className:`m-0 list-none space-y-2 p-0`,role:`list`,"aria-label":n(`squadrules.labelsStartingWith`,{letter:o}),children:l.map(e=>(0,g.jsxs)(`li`,{className:`flex flex-col gap-3 rounded-[var(--radius-sm)] border border-[var(--color-border)] bg-[var(--color-surface)] p-3 sm:flex-row sm:items-center sm:justify-between`,children:[(0,g.jsxs)(`div`,{className:`min-w-0 flex flex-col gap-1`,children:[(0,g.jsx)(`span`,{className:`font-medium text-[var(--color-text-heading)]`,children:e.title}),(0,g.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,g.jsx)(c,{type:e.space_type}),(0,g.jsx)(`span`,{className:`text-xs text-[var(--color-text-muted)]`,children:e.space_name})]})]}),(0,g.jsx)(`div`,{className:`flex-shrink-0`,children:(0,g.jsx)(t,{to:`/protocols/${encodeURIComponent(e.uri)}`,"aria-label":n(`squadrules.viewProtocol`,{title:e.title}),className:`min-h-[var(--layout-touch-target)] min-w-[var(--layout-touch-target)] inline-flex items-center justify-center px-4 py-2 rounded-[var(--radius-md)] font-medium bg-[var(--color-primary)] text-white no-underline 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:n(`squadrules.view`)})})]},e.adapter_id))})]}):null]})}function S(e){let{t:n,choices:r,topScore:i,roleBadgeClass:a}=e;return(0,g.jsxs)(g.Fragment,{children:[r.length>0&&(0,g.jsx)(`p`,{id:`squadrules-results-summary`,className:`text-sm text-[var(--color-text-muted)] mb-4`,"aria-live":`polite`,role:`status`,children:n(`squadrules.foundMatches`,{count:r.length,top:i==null?0:Math.round(i)})}),(0,g.jsx)(`ul`,{className:`list-none p-0 m-0 space-y-2`,role:`list`,"aria-label":n(`squadrules.resultsLabel`),children:r.map(e=>(0,g.jsxs)(`li`,{className:`rounded-[var(--radius-md)] border border-[var(--color-border)] bg-[var(--color-surface-elevated)] p-5 flex justify-between items-start gap-4`,children:[(0,g.jsxs)(`div`,{className:`flex-1 min-w-0`,children:[(0,g.jsx)(`span`,{className:`font-medium text-[var(--color-text-heading)] block`,children:e.label}),(0,g.jsxs)(`div`,{className:`text-sm text-[var(--color-text-muted)] mt-1`,children:[e.adapter_name??(e.role===`refine`?n(`squadrules.refineMeta`):e.role===`create`?n(`squadrules.createMeta`):``),e.role===`match`&&e.space_name!=null&&e.space_name.length>0&&(0,g.jsxs)(g.Fragment,{children:[` `,`· `,n(`squadrules.spaceLabel`),`: `,e.space_name]}),e.activation_score!=null&&` · ${n(`squadrules.score`)}: ${v(e.activation_score)}%`,e.adapter_version&&` · ${n(`squadrules.version`)}: ${e.adapter_version}`]}),(0,g.jsx)(`span`,{className:`inline-block mt-1 text-xs uppercase tracking-wide px-2 py-0.5 rounded ${a[e.role]??`bg-[var(--color-surface)] text-[var(--color-text-muted)]`}`,"aria-label":`Role: ${e.role}`,children:e.role}),e.tags?.length>0&&(0,g.jsx)(`div`,{className:`flex flex-wrap gap-1 mt-2`,"aria-label":n(`squadrules.tagsLabel`),children:e.tags.slice(0,8).map(e=>(0,g.jsx)(`span`,{className:`inline-block text-xs px-2 py-0.5 rounded bg-[var(--color-surface)] border border-[var(--color-border)] text-[var(--color-text-muted)]`,children:e},e))})]}),(0,g.jsxs)(`div`,{className:`flex-shrink-0`,children:[e.role===`match`&&(0,g.jsx)(t,{to:`/protocols/${encodeURIComponent(e.uri)}`,"aria-label":n(`squadrules.viewProtocol`,{title:e.label}),className:`min-h-[44px] min-w-[44px] inline-flex items-center justify-center px-4 py-2 rounded-[var(--radius-md)] font-medium bg-[var(--color-primary)] text-white no-underline 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:n(`squadrules.view`)}),e.role===`refine`&&(0,g.jsx)(t,{to:`/protocols/${encodeURIComponent(e.uri)}`,className:`min-h-[44px] min-w-[44px] inline-flex items-center justify-center px-4 py-2 rounded-[var(--radius-md)] font-medium bg-[var(--color-primary)] text-white no-underline 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:n(`squadrules.refineSearch`)}),e.role===`create`&&(0,g.jsx)(t,{to:`/protocols/new`,className:`min-h-[44px] min-w-[44px] inline-flex items-center justify-center px-4 py-2 rounded-[var(--radius-md)] font-medium bg-[var(--color-primary)] text-white no-underline 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:n(`squadrules.createNew`)})]})]},e.uri))})]})}var C={match:`bg-[var(--badge-match-bg)] text-[var(--badge-match-fg)]`,refine:`bg-[var(--badge-refine-bg)] text-[var(--badge-refine-fg)]`,create:`bg-[var(--badge-create-bg)] text-[var(--badge-create-fg)]`};function w(){let{t:e}=i(),[n,a]=r(),o=n.get(`q`)??``,s=n.get(`space`)??``,[c,p]=(0,f.useState)(o),[m,y]=(0,f.useState)(o),[w,T]=(0,f.useState)(s),[E,D]=(0,f.useState)(s),O=E.trim(),{data:k,isLoading:A,isError:j,error:M,refetch:N}=h(m,!!m,{...O?{space:O}:{}}),P=!m,{data:F,isLoading:I,isError:L,error:R,refetch:z}=l(!0,{includeAdapterTitles:P});(0,f.useEffect)(()=>{let e=n.get(`q`)??``,t=n.get(`space`)??``;p(e),y(e),T(t),D(t)},[n]);let B=e=>{e.preventDefault(),y(c),D(w);let t={};c.trim()&&(t.q=c.trim()),w.trim()&&(t.space=w.trim()),a(t,{replace:!0})},V=k?.choices??[],H={match:0,refine:1,create:2},U=V.slice().sort((e,t)=>{let n=(H[e.role]??99)-(H[t.role]??99);if(n!==0)return n;let r=e.activation_score??-1;return(t.activation_score??-1)-r}),W=U.length>0?Math.max(...U.map(e=>v(e.activation_score))):null,{browseAdapters:G,countsByLetter:K}=(0,f.useMemo)(()=>b(F?.spaces),[F?.spaces]);return(0,g.jsxs)(`div`,{children:[(0,g.jsx)(`h1`,{className:`text-[var(--color-text-heading)] text-2xl font-semibold mb-1`,children:e(`squadrules.title`)}),(0,g.jsx)(`p`,{className:`text-sm text-[var(--color-text-muted)] mb-6`,children:e(`squadrules.searchHint`)}),(0,g.jsxs)(`section`,{className:`mb-8`,"aria-labelledby":`browse-search-label`,children:[(0,g.jsx)(`h2`,{id:`browse-search-label`,className:`sr-only`,children:e(`squadrules.searchLabel`)}),(0,g.jsxs)(`form`,{onSubmit:B,"aria-label":e(`squadrules.searchLabel`),children:[(0,g.jsx)(`label`,{htmlFor:`squadrules-search-query`,className:`block font-medium text-[var(--color-text-heading)] mb-2`,children:e(`squadrules.searchLabel`)}),(0,g.jsxs)(`div`,{className:`grid gap-3 md:grid-cols-[1fr_auto] md:items-end mb-4`,children:[(0,g.jsxs)(`div`,{children:[(0,g.jsx)(`input`,{id:`squadrules-search-query`,type:`search`,value:c,onChange:e=>p(e.target.value),placeholder:e(`squadrules.searchPlaceholder`),"aria-describedby":`squadrules-search-hint`,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`}),(0,g.jsx)(`p`,{id:`squadrules-search-hint`,className:`text-sm text-[var(--color-text-muted)] mt-2`,children:e(`squadrules.searchHintShort`)})]}),(0,g.jsx)(`div`,{className:`flex md:pb-0 pb-0`,children:(0,g.jsx)(`button`,{type:`submit`,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 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:e(`squadrules.search`)})})]}),(0,g.jsxs)(`div`,{className:`max-w-md mb-6`,children:[(0,g.jsx)(`label`,{htmlFor:`squadrules-activate-space`,className:`block text-sm font-medium text-[var(--color-text-heading)] mb-2`,children:e(`squadrules.scopeSpaceLabel`)}),(0,g.jsx)(u,{id:`squadrules-activate-space`,spaces:F?.spaces,value:w,onChange:T,includeAllOption:!0,disabled:I,"aria-describedby":`squadrules-search-hint`})]})]})]}),j&&(0,g.jsx)(d,{message:M instanceof Error?M.message:String(M),onRetry:()=>N(),showGoBack:!0}),P&&L&&(0,g.jsx)(d,{message:R instanceof Error?R.message:String(R),onRetry:()=>z(),showGoBack:!0}),A&&m&&(0,g.jsxs)(`div`,{className:`mb-4`,"aria-live":`polite`,"aria-busy":`true`,children:[(0,g.jsx)(`p`,{className:`sr-only`,children:e(`squadrules.loading`)}),(0,g.jsx)(_,{})]}),P&&I&&(0,g.jsxs)(`div`,{className:`mb-4`,"aria-live":`polite`,"aria-busy":`true`,children:[(0,g.jsx)(`p`,{className:`sr-only`,children:e(`squadrules.loading`)}),(0,g.jsx)(_,{})]}),!A&&!j&&!(P&&L)&&(0,g.jsx)(g.Fragment,{children:m?U.length===0?(0,g.jsxs)(`div`,{className:`rounded-[var(--radius-md)] border border-[var(--color-border)] bg-[var(--color-surface-elevated)] p-6`,role:`status`,"aria-live":`polite`,children:[(0,g.jsx)(`p`,{className:`text-[var(--color-text-muted)] mb-4`,children:e(`squadrules.empty`)}),(0,g.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[(0,g.jsx)(t,{to:`/squadrules`,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(`squadrules.refineSearch`)}),(0,g.jsx)(t,{to:`/protocols/new`,className:`min-h-[44px] min-w-[44px] inline-flex items-center justify-center px-4 py-2 rounded-[var(--radius-md)] font-medium bg-[var(--color-primary)] text-white border-0 no-underline 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:e(`squadrules.createNew`)})]})]}):m?(0,g.jsx)(S,{t:e,choices:U,topScore:W,roleBadgeClass:C}):null:(0,g.jsx)(x,{t:e,spacesLoading:I,browseAdapters:G,countsByLetter:K})})]})}export{w as SquadrulesPage};
1
+ import{r as e}from"./rolldown-runtime-hePW80VL.js";import{a as t,g as n,s as r,y as i}from"./vendor-xESPQGR9.js";import{i as a,t as o}from"./react-BvB9BS1T.js";import{t as s}from"./api-BgTb-tmJ.js";import{n as c,r as l,t as u}from"./SpaceSelect-D3al0TgQ.js";import{t as d}from"./ErrorAlert-BoPXaBKG.js";var f=e(a(),1);async function p(e,t){let n={query:e.trim()},r=t?.space?.trim();r&&(n.space=r),t?.max_choices!=null&&(n.max_choices=t.max_choices);let i=await s(`/api/activate`,{method:`POST`,body:JSON.stringify(n)});if(!i.ok){let e=await i.json().catch(()=>({}));throw Error(e.message??i.statusText)}return await i.json()}function m(e,t,n){let r=e.trim();return{queryKey:[`activate`,r,(n?.space?.trim()??``)||null,n?.max_choices??null],queryFn:()=>p(r,n),enabled:t&&r.length>0}}function h(e,t,r){return n(m(e,t,r))}var g=o();function _(){return(0,g.jsx)(`ul`,{className:`list-none p-0 m-0 space-y-2`,role:`list`,"aria-hidden":`true`,children:[1,2,3].map(e=>(0,g.jsxs)(`li`,{className:`rounded-[var(--radius-md)] border border-[var(--color-border)] bg-[var(--color-surface-elevated)] p-4 flex justify-between items-start gap-4`,children:[(0,g.jsxs)(`div`,{className:`flex-1 min-w-0 space-y-2`,children:[(0,g.jsx)(`div`,{className:`h-5 w-3/4 rounded bg-[var(--color-border)] animate-pulse`}),(0,g.jsx)(`div`,{className:`h-4 w-1/2 rounded bg-[var(--color-border)] animate-pulse`}),(0,g.jsx)(`div`,{className:`h-5 w-16 rounded bg-[var(--color-border)] animate-pulse`})]}),(0,g.jsx)(`div`,{className:`h-10 w-20 rounded-[var(--radius-md)] bg-[var(--color-border)] animate-pulse flex-shrink-0`})]},e))})}function v(e){return typeof e!=`number`||Number.isNaN(e)?0:Math.round(Math.max(0,Math.min(e,1))*100)}var y=`ABCDEFGHIJKLMNOPQRSTUVWXYZ`.split(``);function b(e){let t=[];for(let n of e??[])for(let e of n.adapters??[])t.push({adapter_id:e.adapter_id,title:e.title,layer_count:e.layer_count,slug:e.slug,uri:e.uri,space_name:n.name,space_type:n.type});let n=new Map,r=[];for(let e of t){let t=(e.adapter_id??``).trim();if(!t){r.push(e);continue}let i=n.get(t);i?(e.layer_count??0)>(i.layer_count??0)&&n.set(t,e):n.set(t,e)}let i=[...n.values(),...r],a={};for(let e of y)a[e]=0;for(let e of i){let t=(e.title??``).trim().charAt(0).toUpperCase();y.includes(t)&&(a[t]=(a[t]??0)+1)}return{browseAdapters:i,countsByLetter:a}}function x(e){let{t:n,spacesLoading:r,browseAdapters:i,countsByLetter:a}=e,[o,s]=(0,f.useState)(null),l=(0,f.useMemo)(()=>o?i.filter(e=>(e.title??``).trim().charAt(0).toUpperCase()===o).sort((e,t)=>(e.title??``).localeCompare(t.title??``,void 0,{sensitivity:`base`})):[],[i,o]),u=i.length>0;return(0,g.jsxs)(`section`,{"aria-labelledby":`browse-by-label-heading`,children:[(0,g.jsx)(`h2`,{id:`browse-by-label-heading`,className:`text-lg font-semibold text-[var(--color-text-heading)] mb-3`,children:n(`squadrules.browseByLabel`)}),(0,g.jsx)(`p`,{className:`text-sm text-[var(--color-text-muted)] mb-4`,children:n(`squadrules.browseByLetterHint`)}),!r&&!u?(0,g.jsx)(`p`,{className:`text-sm text-[var(--color-text-muted)]`,children:n(`squadrules.browseEmpty`)}):null,!r&&u?(0,g.jsx)(`div`,{className:`flex flex-wrap gap-2 mb-4`,role:`group`,"aria-label":n(`squadrules.browseByLabel`),children:y.map(e=>{let t=a[e]??0;return(0,g.jsxs)(`button`,{type:`button`,onClick:()=>s(t=>t===e?null:e),"aria-expanded":o===e,"aria-controls":`browse-letter-panel-${e}`,"aria-pressed":o===e,"aria-label":n(`squadrules.letterCount`,{letter:e,count:t}),className:`min-h-[var(--layout-touch-target)] min-w-[var(--layout-touch-target)] inline-flex items-center justify-center rounded-[var(--radius-md)] border px-3 py-2 text-sm font-medium transition-colors focus-visible:outline focus-visible:outline-2 focus-visible:outline-[var(--color-focus-ring)] focus-visible:outline-offset-2 ${o===e?`border-[var(--color-primary)] bg-[var(--color-surface-elevated)] text-[var(--color-primary)]`:`border-[var(--color-border)] bg-[var(--color-surface)] text-[var(--color-text)] hover:bg-[var(--color-surface-elevated)]`}`,children:[e,`: `,t]},e)})}):null,o&&!r&&u?(0,g.jsxs)(`div`,{id:`browse-letter-panel-${o}`,role:`region`,"aria-labelledby":`browse-letter-panel-heading`,"aria-live":`polite`,className:`rounded-[var(--radius-md)] border border-[var(--color-border)] bg-[var(--color-surface-elevated)] p-5`,children:[(0,g.jsx)(`h3`,{id:`browse-letter-panel-heading`,className:`text-base font-semibold text-[var(--color-text-heading)] mb-3`,children:n(`squadrules.labelsStartingWith`,{letter:o})}),l.length===0?(0,g.jsx)(`p`,{className:`text-sm text-[var(--color-text-muted)]`,children:n(`squadrules.noLabelsForLetter`)}):(0,g.jsx)(`ul`,{className:`m-0 list-none space-y-2 p-0`,role:`list`,"aria-label":n(`squadrules.labelsStartingWith`,{letter:o}),children:l.map(e=>(0,g.jsxs)(`li`,{className:`flex flex-col gap-3 rounded-[var(--radius-sm)] border border-[var(--color-border)] bg-[var(--color-surface)] p-3 sm:flex-row sm:items-center sm:justify-between`,children:[(0,g.jsxs)(`div`,{className:`min-w-0 flex flex-col gap-1`,children:[(0,g.jsx)(`span`,{className:`font-medium text-[var(--color-text-heading)]`,children:e.title}),(0,g.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,g.jsx)(c,{type:e.space_type}),(0,g.jsx)(`span`,{className:`text-xs text-[var(--color-text-muted)]`,children:e.space_name})]})]}),(0,g.jsx)(`div`,{className:`flex-shrink-0`,children:(0,g.jsx)(t,{to:`/protocols/${encodeURIComponent(e.uri)}`,"aria-label":n(`squadrules.viewProtocol`,{title:e.title}),className:`min-h-[var(--layout-touch-target)] min-w-[var(--layout-touch-target)] inline-flex items-center justify-center px-4 py-2 rounded-[var(--radius-md)] font-medium bg-[var(--color-primary)] text-white no-underline 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:n(`squadrules.view`)})})]},e.adapter_id))})]}):null]})}function S(e){let{t:n,choices:r,topScore:i,roleBadgeClass:a}=e;return(0,g.jsxs)(g.Fragment,{children:[r.length>0&&(0,g.jsx)(`p`,{id:`squadrules-results-summary`,className:`text-sm text-[var(--color-text-muted)] mb-4`,"aria-live":`polite`,role:`status`,children:n(`squadrules.foundMatches`,{count:r.length,top:i==null?0:Math.round(i)})}),(0,g.jsx)(`ul`,{className:`list-none p-0 m-0 space-y-2`,role:`list`,"aria-label":n(`squadrules.resultsLabel`),children:r.map(e=>(0,g.jsxs)(`li`,{className:`rounded-[var(--radius-md)] border border-[var(--color-border)] bg-[var(--color-surface-elevated)] p-5 flex justify-between items-start gap-4`,children:[(0,g.jsxs)(`div`,{className:`flex-1 min-w-0`,children:[(0,g.jsx)(`span`,{className:`font-medium text-[var(--color-text-heading)] block`,children:e.label}),(0,g.jsxs)(`div`,{className:`text-sm text-[var(--color-text-muted)] mt-1`,children:[e.adapter_name??(e.role===`refine`?n(`squadrules.refineMeta`):e.role===`create`?n(`squadrules.createMeta`):``),e.role===`match`&&e.space_name!=null&&e.space_name.length>0&&(0,g.jsxs)(g.Fragment,{children:[` `,`· `,n(`squadrules.spaceLabel`),`: `,e.space_name]}),e.activation_score!=null&&` · ${n(`squadrules.score`)}: ${v(e.activation_score)}%`,e.adapter_version&&` · ${n(`squadrules.version`)}: ${e.adapter_version}`]}),(0,g.jsx)(`span`,{className:`inline-block mt-1 text-xs uppercase tracking-wide px-2 py-0.5 rounded ${a[e.role]??`bg-[var(--color-surface)] text-[var(--color-text-muted)]`}`,"aria-label":`Role: ${e.role}`,children:e.role}),e.tags?.length>0&&(0,g.jsx)(`div`,{className:`flex flex-wrap gap-1 mt-2`,"aria-label":n(`squadrules.tagsLabel`),children:e.tags.slice(0,8).map(e=>(0,g.jsx)(`span`,{className:`inline-block text-xs px-2 py-0.5 rounded bg-[var(--color-surface)] border border-[var(--color-border)] text-[var(--color-text-muted)]`,children:e},e))})]}),(0,g.jsxs)(`div`,{className:`flex-shrink-0`,children:[e.role===`match`&&(0,g.jsx)(t,{to:`/protocols/${encodeURIComponent(e.uri)}`,"aria-label":n(`squadrules.viewProtocol`,{title:e.label}),className:`min-h-[44px] min-w-[44px] inline-flex items-center justify-center px-4 py-2 rounded-[var(--radius-md)] font-medium bg-[var(--color-primary)] text-white no-underline 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:n(`squadrules.view`)}),e.role===`refine`&&(0,g.jsx)(t,{to:`/protocols/${encodeURIComponent(e.uri)}`,className:`min-h-[44px] min-w-[44px] inline-flex items-center justify-center px-4 py-2 rounded-[var(--radius-md)] font-medium bg-[var(--color-primary)] text-white no-underline 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:n(`squadrules.refineSearch`)}),e.role===`create`&&(0,g.jsx)(t,{to:`/protocols/new`,className:`min-h-[44px] min-w-[44px] inline-flex items-center justify-center px-4 py-2 rounded-[var(--radius-md)] font-medium bg-[var(--color-primary)] text-white no-underline 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:n(`squadrules.createNew`)})]})]},e.uri))})]})}var C={match:`bg-[var(--badge-match-bg)] text-[var(--badge-match-fg)]`,refine:`bg-[var(--badge-refine-bg)] text-[var(--badge-refine-fg)]`,create:`bg-[var(--badge-create-bg)] text-[var(--badge-create-fg)]`};function w(){let{t:e}=i(),[n,a]=r(),o=n.get(`q`)??``,s=n.get(`space`)??``,[c,p]=(0,f.useState)(o),[m,y]=(0,f.useState)(o),[w,T]=(0,f.useState)(s),[E,D]=(0,f.useState)(s),O=E.trim(),{data:k,isLoading:A,isError:j,error:M,refetch:N}=h(m,!!m,{...O?{space:O}:{}}),P=!m,{data:F,isLoading:I,isError:L,error:R,refetch:z}=l(!0,{includeAdapterTitles:P});(0,f.useEffect)(()=>{let e=n.get(`q`)??``,t=n.get(`space`)??``;p(e),y(e),T(t),D(t)},[n]);let B=e=>{e.preventDefault(),y(c),D(w);let t={};c.trim()&&(t.q=c.trim()),w.trim()&&(t.space=w.trim()),a(t,{replace:!0})},V=k?.choices??[],H={match:0,refine:1,create:2},U=V.slice().sort((e,t)=>{let n=(H[e.role]??99)-(H[t.role]??99);if(n!==0)return n;let r=e.activation_score??-1;return(t.activation_score??-1)-r}),W=U.length>0?Math.max(...U.map(e=>v(e.activation_score))):null,{browseAdapters:G,countsByLetter:K}=(0,f.useMemo)(()=>b(F?.spaces),[F?.spaces]);return(0,g.jsxs)(`div`,{children:[(0,g.jsx)(`h1`,{className:`text-[var(--color-text-heading)] text-2xl font-semibold mb-1`,children:e(`squadrules.title`)}),(0,g.jsx)(`p`,{className:`text-sm text-[var(--color-text-muted)] mb-6`,children:e(`squadrules.searchHint`)}),(0,g.jsxs)(`section`,{className:`mb-8`,"aria-labelledby":`browse-search-label`,children:[(0,g.jsx)(`h2`,{id:`browse-search-label`,className:`sr-only`,children:e(`squadrules.searchLabel`)}),(0,g.jsxs)(`form`,{onSubmit:B,"aria-label":e(`squadrules.searchLabel`),children:[(0,g.jsx)(`label`,{htmlFor:`squadrules-search-query`,className:`block font-medium text-[var(--color-text-heading)] mb-2`,children:e(`squadrules.searchLabel`)}),(0,g.jsxs)(`div`,{className:`grid gap-3 md:grid-cols-[1fr_auto] md:items-end mb-4`,children:[(0,g.jsxs)(`div`,{children:[(0,g.jsx)(`input`,{id:`squadrules-search-query`,type:`search`,value:c,onChange:e=>p(e.target.value),placeholder:e(`squadrules.searchPlaceholder`),"aria-describedby":`squadrules-search-hint`,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`}),(0,g.jsx)(`p`,{id:`squadrules-search-hint`,className:`text-sm text-[var(--color-text-muted)] mt-2`,children:e(`squadrules.searchHintShort`)})]}),(0,g.jsx)(`div`,{className:`flex md:pb-0 pb-0`,children:(0,g.jsx)(`button`,{type:`submit`,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 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:e(`squadrules.search`)})})]}),(0,g.jsxs)(`div`,{className:`max-w-md mb-6`,children:[(0,g.jsx)(`label`,{htmlFor:`squadrules-activate-space`,className:`block text-sm font-medium text-[var(--color-text-heading)] mb-2`,children:e(`squadrules.scopeSpaceLabel`)}),(0,g.jsx)(u,{id:`squadrules-activate-space`,spaces:F?.spaces,value:w,onChange:T,includeAllOption:!0,disabled:I,"aria-describedby":`squadrules-search-hint`})]})]})]}),j&&(0,g.jsx)(d,{message:M instanceof Error?M.message:String(M),onRetry:()=>N(),showGoBack:!0}),P&&L&&(0,g.jsx)(d,{message:R instanceof Error?R.message:String(R),onRetry:()=>z(),showGoBack:!0}),A&&m&&(0,g.jsxs)(`div`,{className:`mb-4`,"aria-live":`polite`,"aria-busy":`true`,children:[(0,g.jsx)(`p`,{className:`sr-only`,children:e(`squadrules.loading`)}),(0,g.jsx)(_,{})]}),P&&I&&(0,g.jsxs)(`div`,{className:`mb-4`,"aria-live":`polite`,"aria-busy":`true`,children:[(0,g.jsx)(`p`,{className:`sr-only`,children:e(`squadrules.loading`)}),(0,g.jsx)(_,{})]}),!A&&!j&&!(P&&L)&&(0,g.jsx)(g.Fragment,{children:m?U.length===0?(0,g.jsxs)(`div`,{className:`rounded-[var(--radius-md)] border border-[var(--color-border)] bg-[var(--color-surface-elevated)] p-6`,role:`status`,"aria-live":`polite`,children:[(0,g.jsx)(`p`,{className:`text-[var(--color-text-muted)] mb-4`,children:e(`squadrules.empty`)}),(0,g.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[(0,g.jsx)(t,{to:`/squadrules`,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(`squadrules.refineSearch`)}),(0,g.jsx)(t,{to:`/protocols/new`,className:`min-h-[44px] min-w-[44px] inline-flex items-center justify-center px-4 py-2 rounded-[var(--radius-md)] font-medium bg-[var(--color-primary)] text-white border-0 no-underline 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:e(`squadrules.createNew`)})]})]}):m?(0,g.jsx)(S,{t:e,choices:U,topScore:W,roleBadgeClass:C}):null:(0,g.jsx)(x,{t:e,spacesLoading:I,browseAdapters:G,countsByLetter:K})})]})}export{w as SquadrulesPage};
@@ -1 +1 @@
1
- import{n as e,r as t}from"./vendor-DGTQ2S8W.js";import{t as n}from"./react-CR5VJ85Q.js";var r=n(),i=`text-sm leading-6 text-[var(--color-text)] [&_p]:mt-0 [&_p:first-child]:mt-0 [&_p+p]:mt-3 [&_ul]:my-3 [&_ul]:pl-6 [&_ol]:my-3 [&_ol]:pl-6 [&_li]:my-0.5 [&_strong]:font-semibold [&_strong]:text-[var(--color-text-heading)] [&_code]:rounded [&_code]:bg-[var(--color-surface-elevated)] [&_code]:px-1.5 [&_code]:py-0.5 [&_code]:text-xs [&_code]:font-mono [&_pre]:my-3 [&_pre]:overflow-x-auto [&_pre]:rounded-[var(--radius-md)] [&_pre]:bg-[var(--color-surface-elevated)] [&_pre]:p-3 [&_pre]:text-sm [&_pre]:font-mono [&_pre]:whitespace-pre-wrap [&_pre_code]:bg-transparent [&_pre_code]:p-0 [&_pre_code]:text-inherit [&_a]:text-[var(--color-primary)] [&_a]:underline [&_a:hover]:no-underline [&_a:focus-visible]:outline [&_a:focus-visible]:outline-2 [&_a:focus-visible]:outline-[var(--color-focus-ring)] [&_a:focus-visible]:outline-offset-2 [&_blockquote]:border-l-4 [&_blockquote]:border-[var(--color-border)] [&_blockquote]:pl-4 [&_blockquote]:italic [&_blockquote]:text-[var(--color-text-muted)] [&_h1]:text-xl [&_h1]:font-semibold [&_h1]:text-[var(--color-text-heading)] [&_h1]:mt-4 [&_h1]:mb-2 [&_h2]:text-lg [&_h2]:font-semibold [&_h2]:text-[var(--color-text-heading)] [&_h2]:mt-4 [&_h2]:mb-2 [&_h3]:text-base [&_h3]:font-medium [&_h3]:text-[var(--color-text-heading)] [&_h3]:mt-3 [&_h3]:mb-1 [&_table]:my-4 [&_table]:w-full [&_table]:border-collapse [&_table]:text-left [&_th]:border [&_th]:border-[var(--color-border)] [&_th]:bg-[var(--color-surface-elevated)] [&_th]:px-3 [&_th]:py-2 [&_th]:font-semibold [&_th]:text-[var(--color-text-heading)] [&_td]:border [&_td]:border-[var(--color-border)] [&_td]:px-3 [&_td]:py-2 [&_tr]:border-b [&_tr]:border-[var(--color-border)] [&_tr:last-child]:border-b-0`;function a({content:n,className:a=``}){return n.trim()?(0,r.jsx)(`div`,{className:`${i} ${a}`.trim(),children:(0,r.jsx)(t,{remarkPlugins:[e],children:n})}):null}function o({steps:e,currentIndex:t}){let n=[`Start`,...e.map(e=>e.label),`Attest`];return(0,r.jsx)(`div`,{className:`flex flex-wrap items-center gap-1 py-3 px-4 rounded-[var(--radius-md)] border border-[var(--color-border)] bg-[var(--color-surface-elevated)]`,role:`img`,"aria-label":`Step flow: ${n.join(`, `)}`,children:n.map((n,i)=>{let a=i>0&&i<=e.length?i-1:void 0;return(0,r.jsxs)(`div`,{className:`flex items-center gap-1`,children:[i>0&&(0,r.jsx)(`span`,{className:`px-0.5 text-[var(--color-text-muted)]`,"aria-hidden":!0,children:`→`}),(0,r.jsx)(`span`,{className:`inline-flex min-h-[32px] items-center justify-center rounded-[var(--radius-sm)] px-3 text-sm font-medium ${a!==void 0&&a===t?`bg-[var(--color-primary)] text-white ring-2 ring-[var(--color-primary)] ring-offset-2 ring-offset-[var(--color-surface)]`:`border border-[var(--color-border)] bg-[var(--color-surface)] text-[var(--color-text)]`}`,children:n})]},i)})})}export{a as n,o as t};
1
+ import{n as e,r as t}from"./vendor-xESPQGR9.js";import{t as n}from"./react-BvB9BS1T.js";var r=n(),i=`text-sm leading-6 text-[var(--color-text)] [&_p]:mt-0 [&_p:first-child]:mt-0 [&_p+p]:mt-3 [&_ul]:my-3 [&_ul]:pl-6 [&_ol]:my-3 [&_ol]:pl-6 [&_li]:my-0.5 [&_strong]:font-semibold [&_strong]:text-[var(--color-text-heading)] [&_code]:rounded [&_code]:bg-[var(--color-surface-elevated)] [&_code]:px-1.5 [&_code]:py-0.5 [&_code]:text-xs [&_code]:font-mono [&_pre]:my-3 [&_pre]:overflow-x-auto [&_pre]:rounded-[var(--radius-md)] [&_pre]:bg-[var(--color-surface-elevated)] [&_pre]:p-3 [&_pre]:text-sm [&_pre]:font-mono [&_pre]:whitespace-pre-wrap [&_pre_code]:bg-transparent [&_pre_code]:p-0 [&_pre_code]:text-inherit [&_a]:text-[var(--color-primary)] [&_a]:underline [&_a:hover]:no-underline [&_a:focus-visible]:outline [&_a:focus-visible]:outline-2 [&_a:focus-visible]:outline-[var(--color-focus-ring)] [&_a:focus-visible]:outline-offset-2 [&_blockquote]:border-l-4 [&_blockquote]:border-[var(--color-border)] [&_blockquote]:pl-4 [&_blockquote]:italic [&_blockquote]:text-[var(--color-text-muted)] [&_h1]:text-xl [&_h1]:font-semibold [&_h1]:text-[var(--color-text-heading)] [&_h1]:mt-4 [&_h1]:mb-2 [&_h2]:text-lg [&_h2]:font-semibold [&_h2]:text-[var(--color-text-heading)] [&_h2]:mt-4 [&_h2]:mb-2 [&_h3]:text-base [&_h3]:font-medium [&_h3]:text-[var(--color-text-heading)] [&_h3]:mt-3 [&_h3]:mb-1 [&_table]:my-4 [&_table]:w-full [&_table]:border-collapse [&_table]:text-left [&_th]:border [&_th]:border-[var(--color-border)] [&_th]:bg-[var(--color-surface-elevated)] [&_th]:px-3 [&_th]:py-2 [&_th]:font-semibold [&_th]:text-[var(--color-text-heading)] [&_td]:border [&_td]:border-[var(--color-border)] [&_td]:px-3 [&_td]:py-2 [&_tr]:border-b [&_tr]:border-[var(--color-border)] [&_tr:last-child]:border-b-0`;function a({content:n,className:a=``}){return n.trim()?(0,r.jsx)(`div`,{className:`${i} ${a}`.trim(),children:(0,r.jsx)(t,{remarkPlugins:[e],children:n})}):null}function o({steps:e,currentIndex:t}){let n=[`Start`,...e.map(e=>e.label),`Attest`];return(0,r.jsx)(`div`,{className:`flex flex-wrap items-center gap-1 py-3 px-4 rounded-[var(--radius-md)] border border-[var(--color-border)] bg-[var(--color-surface-elevated)]`,role:`img`,"aria-label":`Step flow: ${n.join(`, `)}`,children:n.map((n,i)=>{let a=i>0&&i<=e.length?i-1:void 0;return(0,r.jsxs)(`div`,{className:`flex items-center gap-1`,children:[i>0&&(0,r.jsx)(`span`,{className:`px-0.5 text-[var(--color-text-muted)]`,"aria-hidden":!0,children:`→`}),(0,r.jsx)(`span`,{className:`inline-flex min-h-[32px] items-center justify-center rounded-[var(--radius-sm)] px-3 text-sm font-medium ${a!==void 0&&a===t?`bg-[var(--color-primary)] text-white ring-2 ring-[var(--color-primary)] ring-offset-2 ring-offset-[var(--color-surface)]`:`border border-[var(--color-border)] bg-[var(--color-surface)] text-[var(--color-text)]`}`,children:n})]},i)})})}export{a as n,o as t};
@@ -1 +1 @@
1
- import{t as e}from"./react-CR5VJ85Q.js";var t=e();function n({title:e,subtitle:n,children:r,className:i}){return(0,t.jsxs)(`section`,{className:`rounded-[var(--radius-md)] border border-[var(--color-border)] bg-[var(--color-surface-elevated)] p-4 ${i??``}`,children:[(0,t.jsxs)(`div`,{className:`mb-3`,children:[(0,t.jsx)(`h2`,{className:`text-base font-semibold text-[var(--color-text-heading)]`,children:e}),n?(0,t.jsx)(`p`,{className:`mt-1 text-sm text-[var(--color-text-muted)]`,children:n}):null]}),r]})}export{n as t};
1
+ import{t as e}from"./react-BvB9BS1T.js";var t=e();function n({title:e,subtitle:n,children:r,className:i}){return(0,t.jsxs)(`section`,{className:`rounded-[var(--radius-md)] border border-[var(--color-border)] bg-[var(--color-surface-elevated)] p-4 ${i??``}`,children:[(0,t.jsxs)(`div`,{className:`mb-3`,children:[(0,t.jsx)(`h2`,{className:`text-base font-semibold text-[var(--color-text-heading)]`,children:e}),n?(0,t.jsx)(`p`,{className:`mt-1 text-sm text-[var(--color-text-muted)]`,children:n}):null]}),r]})}export{n as t};
@@ -1,4 +1,4 @@
1
- import{g as e}from"./vendor-DGTQ2S8W.js";import{t}from"./api-BgTb-tmJ.js";async function n(e){let n=await t(`/api/export`,{method:`POST`,body:JSON.stringify({uri:e,format:`markdown`})});if(!n.ok){let e=(await n.json().catch(()=>({}))).message??n.statusText,t=Error(e);throw t.statusCode=n.status,t}let r=await n.json();return{content:r.content,uri:r.uri,label:r.adapter_name??`Adapter`,adapter_name:r.adapter_name??null,...r.adapter_version?{protocol_version:r.adapter_version}:{},...r.space_id!==void 0&&{space_id:r.space_id},...r.space_name!==void 0&&{space_name:r.space_name},...r.space_type!==void 0&&{space_type:r.space_type}}}function r(t,r){return e({queryKey:[`protocol`,t],queryFn:()=>n(t),enabled:!!(t&&r)})}function i(e){let t=e.split(`
1
+ import{g as e}from"./vendor-xESPQGR9.js";import{t}from"./api-BgTb-tmJ.js";async function n(e){let n=await t(`/api/export`,{method:`POST`,body:JSON.stringify({uri:e,format:`markdown`})});if(!n.ok){let e=(await n.json().catch(()=>({}))).message??n.statusText,t=Error(e);throw t.statusCode=n.status,t}let r=await n.json();return{content:r.content,uri:r.uri,label:r.adapter_name??`Adapter`,adapter_name:r.adapter_name??null,...r.adapter_version?{protocol_version:r.adapter_version}:{},...r.space_id!==void 0&&{space_id:r.space_id},...r.space_name!==void 0&&{space_name:r.space_name},...r.space_type!==void 0&&{space_type:r.space_type}}}function r(t,r){return e({queryKey:[`protocol`,t],queryFn:()=>n(t),enabled:!!(t&&r)})}function i(e){let t=e.split(`
2
2
  `),n=`Protocol`,r=[],i=``,a=``,o=t.find(e=>e.startsWith(`# `));o&&(n=o.replace(/^#\s+/,``).trim());let s=e.split(/\n##\s+/);for(let e=1;e<s.length;e++){let t=s[e],n=t.split(`
3
3
  `)[0]??``,o=n.trim(),c=t.slice(n.length).replace(/^\n+/,``).trim();if(o.toLowerCase().includes(`activation pattern`)||o.toLowerCase().includes(`natural language trigger`))i=c.replace(/\n```json[\s\S]*?```/g,``).trim();else if(o.toLowerCase().includes(`reward signal`)||o.toLowerCase().includes(`completion rule`))a=c.replace(/\n```json[\s\S]*?```/g,``).trim();else{let e=c.match(/```json\s*([\s\S]*?)```/),t=`comment`,n=`Comment`,i;if(e)try{let r=JSON.parse(e[1].trim()),a=r?.contract??r?.challenge??r;if(a?.type&&(t=String(a.type)),t===`shell`){let e=a?.shell?.cmd??a?.cmd,t=a?.shell?.interpreter;n=e?t?`Shell (${t}): ${String(e).slice(0,60)}${String(e).length>60?`…`:``}`:`Shell: ${String(e).slice(0,80)}${String(e).length>80?`…`:``}`:`Shell`,e&&(i={cmd:String(e)})}else if(t===`mcp`){let e=a?.mcp?.tool_name;n=e?`MCP: ${String(e)}`:`MCP`,e&&(i={tool_name:String(e)})}else if(t===`user_input`){let e=a?.user_input?.prompt;n=e?`User input: ${String(e)}`:`User input`,e&&(i={prompt:String(e)})}else if(t===`tensor`){let e=a?.tensor?.output?.name,t=a?.tensor?.output?.type;n=e?`Tensor: ${String(e)}${t?` (${String(t)})`:``}`:`Tensor`}else if(t===`comment`){let e=a?.comment?.min_length;n=e?`Comment: min ${Number(e)} chars`:`Comment`,e!=null&&!Number.isNaN(Number(e))&&(i={min_length:Number(e)})}else n=String(t)}catch{}n||=String(t),r.push({label:o,type:t,summary:n,body:c,challengePayload:i})}}return{title:n,steps:r,triggers:i,completion:a}}function a(e){let{title:t,steps:n,triggers:r,completion:a}=i(e);return{protocolLabel:t,triggersMarkdown:r,steps:n.map(e=>{let t=e.body.replace(/\n```json\s*[\s\S]*?```\s*$/g,``).trim(),n=`comment`,r={label:e.label,bodyMarkdown:t,type:n},i=e.body.match(/```json\s*([\s\S]*?)```/);if(i)try{let e=JSON.parse(i[1].trim()),t=e?.contract??e?.challenge??e;if(t?.type&&[`shell`,`mcp`,`user_input`,`comment`].includes(String(t.type))&&(n=t.type,r.type=n),n===`shell`){let e=t?.shell;r.shell={cmd:String(e?.cmd??t?.cmd??``).trim(),timeout_seconds:Number(e?.timeout_seconds??30),interpreter:typeof e?.interpreter==`string`?e.interpreter:void 0,workdir:typeof e?.workdir==`string`?e.workdir:void 0,flags:Array.isArray(e?.flags)?e.flags.map(String):[],args:Array.isArray(e?.args)?e.args.map(String):[]}}else n===`mcp`?r.mcp={tool_name:String(t?.mcp?.tool_name??``).trim()}:n===`user_input`?r.user_input={prompt:String(t?.user_input?.prompt??``).trim()}:n===`comment`&&(r.comment={min_length:Number(t?.comment?.min_length??10)})}catch{}return r}),completionMarkdown:a}}function o(e){let t=[];t.push(`# ${e.protocolLabel.trim()||`Protocol`}`),t.push(``),t.push(`## Activation Patterns`),t.push(``),t.push(e.triggersMarkdown.trim()||`Describe when this protocol should run.`),t.push(``);for(let n of e.steps){t.push(`## ${n.label.trim()||`Step`}`),t.push(``),t.push(n.bodyMarkdown.trim()||`Step content.`);let e={type:n.type};if(n.type===`shell`){let t={cmd:n.shell?.cmd??``,timeout_seconds:n.shell?.timeout_seconds??30},r=n.shell?.interpreter?.trim();r&&(t.interpreter=r);let i=n.shell?.workdir?.trim();i&&(t.workdir=i),n.shell?.flags?.length&&(t.flags=n.shell.flags),n.shell?.args?.length&&(t.args=n.shell.args),e.shell=t}else n.type===`mcp`?e.mcp={tool_name:n.mcp?.tool_name??``}:n.type===`user_input`?e.user_input={prompt:n.user_input?.prompt??``}:n.type===`comment`&&(e.comment={min_length:n.comment?.min_length??10});t.push(``),t.push("```json"),t.push(JSON.stringify({contract:e},null,2)),t.push("```"),t.push(``)}return t.push(`## Reward Signal`),t.push(``),t.push(e.completionMarkdown.trim()||`Describe how this adapter should be rewarded when it completes.`),t.join(`
4
4
  `)}async function s(e){let n=await t(`/api/export`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({uri:e,format:`skill_zip`})});if(!n.ok){let e=(await n.json().catch(()=>({}))).message??n.statusText;throw Error(e)}let r=await n.json();if(r.format===`skill_zip`&&r.download_ref?.url){let e=await fetch(r.download_ref.url,{credentials:`same-origin`});if(!e.ok)throw Error(`Download failed: ${e.statusText}`);return{blob:await e.blob(),skill_bundle_manifest:r.skill_bundle_manifest}}if(r.format!==`skill_zip`||r.content_encoding!==`base64`)throw Error(`Expected a skill_zip export with download_ref or base64-encoded content.`);return{blob:c(r.content,r.content_type||`application/zip`),skill_bundle_manifest:r.skill_bundle_manifest}}function c(e,t){let n=atob(e),r=new Uint8Array(n.length);for(let e=0;e<n.length;e++)r[e]=n.charCodeAt(e);return new Blob([r],{type:t})}function l(e,t){let n=URL.createObjectURL(e),r=document.createElement(`a`);r.href=n,r.download=t,r.click(),URL.revokeObjectURL(n)}function u(e,t){try{if(e){let t=JSON.parse(e).skills?.[0]?.slug;if(t&&t.length>0)return`${t}-squadrules-skill.zip`}}catch{}return`${t.replace(/[^a-zA-Z0-9]+/g,`-`).replace(/^-|-$/g,``)||`squadrules-skill`}-squadrules-skill.zip`}export{i as a,o as i,u as n,a as o,l as r,r as s,s as t};
@@ -1,8 +1,8 @@
1
- const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/HomePage-B06u5RCw.js","assets/vendor-DGTQ2S8W.js","assets/rolldown-runtime-hePW80VL.js","assets/react-CR5VJ85Q.js","assets/tiptap-74Cp-fci.js","assets/SpaceSelect-DDhPkDXU.js","assets/api-BgTb-tmJ.js","assets/SurfaceCard-CRidnDLP.js","assets/SquadrulesPage-D84vIaBc.js","assets/ErrorAlert-BQMph5Nh.js","assets/RunsPage-4kDF_Ylg.js","assets/useRunSession-BX2U9D53.js","assets/ProtocolEditPage-mChBe3JY.js","assets/export-skill-zip-C1bRyhE2.js","assets/ChallengeCard-gY-n7rwI.js","assets/RichTextEditor-Bj6JxHM5.js","assets/RunGuidedPage-Bd1bUTBH.js","assets/StepFlowGraph-DsL5lsIq.js","assets/SkillBundlePage-D1OPKJzA.js","assets/ProtocolDetailPage-DCw5D34S.js","assets/AccountPage-Ci29Zidn.js","assets/NotFoundPage-Dz-PKC4R.js"])))=>i.map(i=>d[i]);
2
- import{r as e}from"./rolldown-runtime-hePW80VL.js";import{_ as t,b as n,c as r,d as i,f as a,i as o,l as s,o as c,u as l,v as u,x as d,y as f}from"./vendor-DGTQ2S8W.js";import{i as p,n as m,t as h}from"./react-CR5VJ85Q.js";(function(){let e=document.createElement(`link`).relList;if(e&&e.supports&&e.supports(`modulepreload`))return;for(let e of document.querySelectorAll(`link[rel="modulepreload"]`))n(e);new MutationObserver(e=>{for(let t of e)if(t.type===`childList`)for(let e of t.addedNodes)e.tagName===`LINK`&&e.rel===`modulepreload`&&n(e)}).observe(document,{childList:!0,subtree:!0});function t(e){let t={};return e.integrity&&(t.integrity=e.integrity),e.referrerPolicy&&(t.referrerPolicy=e.referrerPolicy),t.credentials=e.crossOrigin===`use-credentials`?`include`:e.crossOrigin===`anonymous`?`omit`:`same-origin`,t}function n(e){if(e.ep)return;e.ep=!0;let n=t(e);fetch(e.href,n)}})(),d.use(n).init({lng:`en`,fallbackLng:`en`,ns:[`translation`],defaultNS:`translation`,resources:{en:{translation:{"nav.home":`Home`,"nav.squadrules":`Browse`,"nav.create":`Create`,"nav.runs":`Test Run`,"nav.account":`Account`,"layout.squadrulesVersion":`SQUADRULES v{{version}}`,skipToMain:`Skip to main content`,"home.title":`Home`,"home.tagline":`Start from a clear task: browse protocols, create a new workflow, or continue protocol testing.`,"home.findCardTitle":`Find the right protocol`,"home.findCardSubtitle":`Home stays lightweight. Search and deeper discovery live in Browse.`,"home.goToBrowse":`Go to Browse`,"home.cardBrowseTitle":`Browse protocols`,"home.cardBrowseSubtitle":`Search or browse by label.`,"home.cardBrowseCta":`Open Browse`,"home.cardCreateTitle":`Create protocol`,"home.cardCreateSubtitle":`Use the rendered editor to draft a new workflow.`,"home.cardCreateCta":`Create new`,"home.cardRunsTitle":`Test Run`,"home.cardRunsSubtitle":`Resume a saved test run from this device.`,"home.cardRunsCta":`Open Test Run`,"home.spacesHeading":`Spaces`,"home.searchLabel":`Search protocols`,"home.searchPlaceholder":`e.g. deploy and test`,"home.searchHint":`Enter a query to find the best matching protocol. Results open in Browse.`,"home.statsLabel":`Space and protocol counts`,"home.stats.personalProtocols":`—`,"home.stats.personalProtocolsLabel":`Personal protocols`,"home.stats.squadrulesApp":`—`,"home.stats.squadrulesAppLabel":`Squadrules app`,"home.stats.spaces":`—`,"home.stats.spacesLabel":`Spaces`,"home.stats.protocolCount":`{{count}} protocol`,"home.stats.protocolCount_plural":`{{count}} protocols`,"home.ctaPre":`Search and manage protocols in`,"home.ctaSuffix":`.`,"squadrules.title":`Browse`,"squadrules.searchLabel":`Activation query`,"squadrules.searchPlaceholder":`e.g. deploy and test`,"squadrules.searchHint":`Search or browse by label. The default view lists protocols by their label.`,"squadrules.searchHintShort":`Run an activation query to rank the best matches, or browse the list below.`,"squadrules.browseByLabel":`Browse by label`,"squadrules.browseByLetterHint":`Click a letter to list protocols whose title starts with that letter (A–Z).`,"squadrules.letterCount":`Letter {{letter}}, {{count}} protocols`,"squadrules.labelsStartingWith":`Labels starting with {{letter}}`,"squadrules.noLabelsForLetter":`No protocols starting with this letter.`,"squadrules.browseFlatListHint":`Protocols listed by label. This is the default view when you open Browse.`,"squadrules.browseEmpty":`No protocols found in your spaces yet.`,"squadrules.enterQueryHint":`Enter an activation query above to find the best matching protocol. Results appear below.`,"spaces.filterAll":`All spaces`,"spaces.type.personal":`Personal`,"spaces.type.group":`Group`,"spaces.type.app":`App`,"spaces.type.other":`Other`,"squadrules.scopeSpaceLabel":`Limit search to a space`,"squadrules.spaceLabel":`Space`,"squadrules.search":`Activate`,"squadrules.loading":`Activating…`,"squadrules.empty":`No matching protocols found`,"squadrules.foundMatches":`Found {{count}} activation choices (top confidence: {{top}}%). View one, refine the query, or create a new protocol.`,"squadrules.resultsLabel":`Activation results`,"squadrules.score":`Score`,"squadrules.version":`Version`,"squadrules.tagsLabel":`Tags`,"squadrules.refineMeta":`Refine query`,"squadrules.createMeta":`Start from scratch`,"squadrules.view":`View`,"squadrules.viewProtocol":`View {{title}}`,"squadrules.refineSearch":`Refine query`,"squadrules.createNew":`Create new`,"protocol.loading":`Loading protocol…`,"protocol.notFound":`Protocol not found`,"protocol.uri":`URI`,"protocol.spaceLabel":`Space`,"protocol.readOnly":`Read-only`,"protocol.copyUri":`Copy URI`,"protocol.download":`Download`,"protocol.downloadAsMarkdown":`Download as Markdown`,"protocol.downloadAsSkill":`Download as Skill`,"protocol.editAsSkill":`Edit as Skill`,"protocol.expand":`Expand`,"protocol.collapse":`Collapse`,"protocol.edit":`Edit`,"protocol.duplicate":`Duplicate`,"protocol.runGuided":`Test Run`,"protocol.steps":`Steps`,"protocol.stepFlow":`Step flow`,"protocol.exportCardTitle":`Export`,"protocol.exportCardSubtitle":`Clear language replaces internal dump terminology.`,"protocol.exportFooter":`Skill export prepares a portable bundle for external AI tools.`,"protocol.triggers":`Activation patterns`,"protocol.completion":`Reward signal`,"protocol.howToUse":`How to use this protocol`,"protocol.howToUseInProduct":`The public UI helps people read, edit, export, and manually test protocol steps. Live AI execution still happens through MCP or CLI tooling.`,"protocol.howToUseCopy":`Use Test Run from the button above to step through this protocol in the browser. For agents or CLI, use Cursor (MCP) or the command line. See`,"protocol.docsLink":`documentation`,"runs.title":`Test Run`,"runs.subtitle":`Continue a test run you started earlier on this device.`,"runs.empty":`No runs yet.`,"runs.listLabel":`Test Run list`,"runs.status":`Status`,"runs.updated":`Updated`,"runs.stepsDone":`{{count}} steps completed`,"runs.resume":`Resume`,"runs.remove":`Remove`,"run.title":`Test Run`,"run.guidedIntro":`Step through the saved run in the browser and submit the same data the current run flow expects.`,"run.progressHeading":`Progress`,"run.currentStepHeading":`Current step`,"run.challengeHeading":`Challenge`,"run.stepProgress":`Step {{current}} of {{total}}`,"run.sessionBadge":`Active manual test session`,"run.flowStepN":`{{n}}`,"run.copyShellCommand":`Copy command`,"run.adapterUri":`Adapter URI`,"run.backToProtocol":`Back to adapter`,"run.start":`Start run`,"run.starting":`Starting…`,"run.safety.title":`Safe by default`,"run.safety.copy":`This guided run never executes shell commands in your browser. For shell challenges, run the command yourself and paste the real results.`,"run.serverMessage":`Server message`,"run.currentLayer":`Current layer`,"run.layerUri":`Layer URI`,"run.noLayerContent":`(No layer content)`,"run.contract":`Contract`,"run.contractType":`Type`,"run.advanced":`Advanced`,"run.nonce":`Nonce`,"run.proofHash":`Challenge proof_hash`,"run.previousProofHash":`Previous proof_hash`,"run.copy":`Copy`,"run.copied":`Copied`,"run.solution":`Solution`,"run.solutionFormLabel":`Submit solution`,"run.submitStep":`Submit step`,"run.shell.command":`Command`,"run.shell.invocation":`Invocation`,"run.shell.exitCode":`Exit code`,"run.shell.stdout":`Stdout`,"run.shell.stderr":`Stderr`,"run.mcp.toolName":`Tool`,"run.mcp.toolMissing":`(Missing tool name)`,"run.mcp.success":`Success`,"run.mcp.arguments":`Arguments (JSON)`,"run.mcp.result":`Result (JSON)`,"run.userInput.prompt":`Prompt`,"run.userInput.promptMissing":`(Missing prompt)`,"run.userInput.confirmation":`User confirmation`,"run.comment.minLength":`Minimum {{count}} characters`,"run.comment.count":`{{count}} typed`,"run.comment.text":`Comment`,"run.reward.title":`Reward completion`,"run.reward.subtitle":`Finalize the run outcome for reward and export quality.`,"run.reward.outcomeLabel":`Outcome`,"run.reward.success":`Success`,"run.reward.failure":`Failure`,"run.reward.feedback":`Feedback`,"run.reward.submit":`Submit reward`,"run.reward.submitting":`Submitting…`,"run.reward.defaultFeedback":`Completed guided run.`,"run.stepperProgress":`{{completed}} step(s) completed`,"run.history":`History`,"run.historyLabel":`Run history`,"run.completed":`Run completed`,"run.missingUri":`Missing adapter URI.`,"protocolEdit.newTitle":`New protocol`,"protocolEdit.editTitle":`Edit protocol`,"protocolEdit.hint":`Write as a human. The editor renders text on input and output while keeping the saved format compatible with generic Markdown.`,"protocolEdit.stepHeading":`Step {{n}}`,"protocolEdit.stepEditorHint":`Human-friendly editor with Markdown-safe formatting.`,"protocolEdit.triggersEditorHint":`Shown to humans as rendered text and serialized as Markdown-compatible content.`,"protocolEdit.previewRenderedTitle":`Rendered preview`,"protocolEdit.previewRenderedSubtitle":`Reading flow is fully rendered. Editing keeps a Markdown-safe rich text surface and this card previews section structure.`,"protocolEdit.previewStepLine":`Step {{n}}: {{label}}`,"protocolEdit.skillShortcutTitle":`Skill bundle shortcut`,"protocolEdit.skillShortcutSubtitle":`Authors can turn a protocol into a reusable skill bundle without learning repo-internal file names.`,"protocolEdit.formLabel":`Protocol form`,"protocolEdit.protocolLabel":`Protocol label`,"protocolEdit.triggersLabel":`Activation patterns`,"protocolEdit.triggersHint":`Describe when this protocol should run (e.g. deploy and test).`,"protocolEdit.stepLabel":`Step label`,"protocolEdit.stepContent":`Step content`,"protocolEdit.challengeType":`Challenge type`,"protocolEdit.addStep":`Add step`,"protocolEdit.removeStep":`Remove step`,"protocolEdit.completionLabel":`Reward signal`,"protocolEdit.challengeShell":`Shell command`,"protocolEdit.challengeMcp":`MCP tool call`,"protocolEdit.challengeUserInput":`User input`,"protocolEdit.challengeComment":`Comment`,"protocolEdit.shellCmd":`Command`,"protocolEdit.shellTimeout":`Timeout (seconds)`,"protocolEdit.shellInterpreter":`Interpreter (optional)`,"protocolEdit.shellFlags":`Flags (one per line, optional)`,"protocolEdit.shellArgs":`Args (one per line, optional)`,"protocolEdit.shellWorkdir":`Workdir (optional)`,"protocolEdit.mcpToolName":`Tool name`,"protocolEdit.userInputPrompt":`Prompt`,"protocolEdit.commentMinLength":`Minimum length (characters)`,"protocolEdit.importCardTitle":`Import existing content`,"protocolEdit.uploadHint":"Uploading a `.md` file fills this editor form. It does not publish or overwrite anything until you save.","protocolEdit.contentLabel":`Protocol content (markdown)`,"protocolEdit.previewLabel":`Protocol preview`,"protocolEdit.previewTitle":`Live preview`,"protocolEdit.previewSteps":`Steps`,"protocolEdit.previewNoSteps":`No steps yet.`,"protocolEdit.previewSections":`Key sections`,"protocolEdit.present":`present`,"protocolEdit.missing":`missing`,"protocolEdit.insertTemplate":`Insert template`,"protocolEdit.upload":`Upload .md file`,"skill.title":`Edit as Skill`,"skill.subtitle":`Prepare a skill bundle for external AI tools before downloading the zip. Protocol content stays connected to the original workflow.`,"skill.bundleContentsTitle":`Bundle contents`,"skill.bundleContentsSubtitle":`Optional protocol references can be included in a dedicated folder.`,"skill.chipReadme":`Include README snippet`,"skill.chipPrompts":`Include example prompts`,"skill.comingSoon":`Coming soon`,"skill.bundlePreviewTitle":`Bundle preview`,"skill.bundlePreviewSubtitle":`Zip root contains the skill folder so users can upload it directly.`,"skill.whyExportTitle":`Why this export exists`,"skill.whyExportSubtitle":`The bundle is for human-friendly reuse, not an internal raw dump.`,"skill.whyExportBody":`Authors can package a protocol as a portable skill with polished naming and usage guidance, then download the final zip in one step.`,"skill.skillName":`Skill name`,"skill.description":`Skill description`,"skill.descriptionHint":`Describe what the skill does and when an AI assistant should use it.`,"skill.whenToUse":`When to use it`,"skill.includeReferences":`Include references folder`,"skill.downloadAsSkill":`Download as Skill`,"skill.backToProtocol":`Back to protocol`,"protocolEdit.placeholder":`# Protocol title
1
+ const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/HomePage-B--ESwM9.js","assets/vendor-xESPQGR9.js","assets/rolldown-runtime-hePW80VL.js","assets/react-BvB9BS1T.js","assets/tiptap-CCr8bvo1.js","assets/SpaceSelect-D3al0TgQ.js","assets/api-BgTb-tmJ.js","assets/SurfaceCard-BzJidvvn.js","assets/SquadrulesPage-C37VEZnc.js","assets/ErrorAlert-BoPXaBKG.js","assets/RunsPage-BSgcu2TO.js","assets/useRunSession-CB5wPJ8O.js","assets/ProtocolEditPage-HAcAGXw7.js","assets/export-skill-zip-D8iQY1Dl.js","assets/ChallengeCard-DVXo4j0b.js","assets/RichTextEditor-DWLV579w.js","assets/RunGuidedPage-Bewi7Wsx.js","assets/StepFlowGraph-BXsWPPO0.js","assets/SkillBundlePage-CiMQN0nf.js","assets/ProtocolDetailPage-DFe_JOr3.js","assets/AccountPage-DhaO-G9K.js","assets/NotFoundPage-bTE_mpMC.js"])))=>i.map(i=>d[i]);
2
+ import{r as e}from"./rolldown-runtime-hePW80VL.js";import{_ as t,b as n,c as r,d as i,f as a,i as o,l as s,o as c,u as l,v as u,x as d,y as f}from"./vendor-xESPQGR9.js";import{i as p,n as m,t as h}from"./react-BvB9BS1T.js";(function(){let e=document.createElement(`link`).relList;if(e&&e.supports&&e.supports(`modulepreload`))return;for(let e of document.querySelectorAll(`link[rel="modulepreload"]`))n(e);new MutationObserver(e=>{for(let t of e)if(t.type===`childList`)for(let e of t.addedNodes)e.tagName===`LINK`&&e.rel===`modulepreload`&&n(e)}).observe(document,{childList:!0,subtree:!0});function t(e){let t={};return e.integrity&&(t.integrity=e.integrity),e.referrerPolicy&&(t.referrerPolicy=e.referrerPolicy),t.credentials=e.crossOrigin===`use-credentials`?`include`:e.crossOrigin===`anonymous`?`omit`:`same-origin`,t}function n(e){if(e.ep)return;e.ep=!0;let n=t(e);fetch(e.href,n)}})(),d.use(n).init({lng:`en`,fallbackLng:`en`,ns:[`translation`],defaultNS:`translation`,resources:{en:{translation:{"nav.home":`Home`,"nav.squadrules":`Browse`,"nav.create":`Create`,"nav.runs":`Test Run`,"nav.account":`Account`,"layout.squadrulesVersion":`SQUADRULES v{{version}}`,skipToMain:`Skip to main content`,"home.title":`Home`,"home.tagline":`Start from a clear task: browse protocols, create a new workflow, or continue protocol testing.`,"home.findCardTitle":`Find the right protocol`,"home.findCardSubtitle":`Home stays lightweight. Search and deeper discovery live in Browse.`,"home.goToBrowse":`Go to Browse`,"home.cardBrowseTitle":`Browse protocols`,"home.cardBrowseSubtitle":`Search or browse by label.`,"home.cardBrowseCta":`Open Browse`,"home.cardCreateTitle":`Create protocol`,"home.cardCreateSubtitle":`Use the rendered editor to draft a new workflow.`,"home.cardCreateCta":`Create new`,"home.cardRunsTitle":`Test Run`,"home.cardRunsSubtitle":`Resume a saved test run from this device.`,"home.cardRunsCta":`Open Test Run`,"home.spacesHeading":`Spaces`,"home.searchLabel":`Search protocols`,"home.searchPlaceholder":`e.g. deploy and test`,"home.searchHint":`Enter a query to find the best matching protocol. Results open in Browse.`,"home.statsLabel":`Space and protocol counts`,"home.stats.personalProtocols":`—`,"home.stats.personalProtocolsLabel":`Personal protocols`,"home.stats.squadrulesApp":`—`,"home.stats.squadrulesAppLabel":`Squadrules app`,"home.stats.spaces":`—`,"home.stats.spacesLabel":`Spaces`,"home.stats.protocolCount":`{{count}} protocol`,"home.stats.protocolCount_plural":`{{count}} protocols`,"home.ctaPre":`Search and manage protocols in`,"home.ctaSuffix":`.`,"squadrules.title":`Browse`,"squadrules.searchLabel":`Activation query`,"squadrules.searchPlaceholder":`e.g. deploy and test`,"squadrules.searchHint":`Search or browse by label. The default view lists protocols by their label.`,"squadrules.searchHintShort":`Run an activation query to rank the best matches, or browse the list below.`,"squadrules.browseByLabel":`Browse by label`,"squadrules.browseByLetterHint":`Click a letter to list protocols whose title starts with that letter (A–Z).`,"squadrules.letterCount":`Letter {{letter}}, {{count}} protocols`,"squadrules.labelsStartingWith":`Labels starting with {{letter}}`,"squadrules.noLabelsForLetter":`No protocols starting with this letter.`,"squadrules.browseFlatListHint":`Protocols listed by label. This is the default view when you open Browse.`,"squadrules.browseEmpty":`No protocols found in your spaces yet.`,"squadrules.enterQueryHint":`Enter an activation query above to find the best matching protocol. Results appear below.`,"spaces.filterAll":`All spaces`,"spaces.type.personal":`Personal`,"spaces.type.group":`Group`,"spaces.type.app":`App`,"spaces.type.other":`Other`,"squadrules.scopeSpaceLabel":`Limit search to a space`,"squadrules.spaceLabel":`Space`,"squadrules.search":`Activate`,"squadrules.loading":`Activating…`,"squadrules.empty":`No matching protocols found`,"squadrules.foundMatches":`Found {{count}} activation choices (top confidence: {{top}}%). View one, refine the query, or create a new protocol.`,"squadrules.resultsLabel":`Activation results`,"squadrules.score":`Score`,"squadrules.version":`Version`,"squadrules.tagsLabel":`Tags`,"squadrules.refineMeta":`Refine query`,"squadrules.createMeta":`Start from scratch`,"squadrules.view":`View`,"squadrules.viewProtocol":`View {{title}}`,"squadrules.refineSearch":`Refine query`,"squadrules.createNew":`Create new`,"protocol.loading":`Loading protocol…`,"protocol.notFound":`Protocol not found`,"protocol.uri":`URI`,"protocol.spaceLabel":`Space`,"protocol.readOnly":`Read-only`,"protocol.copyUri":`Copy URI`,"protocol.download":`Download`,"protocol.downloadAsMarkdown":`Download as Markdown`,"protocol.downloadAsSkill":`Download as Skill`,"protocol.editAsSkill":`Edit as Skill`,"protocol.expand":`Expand`,"protocol.collapse":`Collapse`,"protocol.edit":`Edit`,"protocol.duplicate":`Duplicate`,"protocol.runGuided":`Test Run`,"protocol.steps":`Steps`,"protocol.stepFlow":`Step flow`,"protocol.exportCardTitle":`Export`,"protocol.exportCardSubtitle":`Clear language replaces internal dump terminology.`,"protocol.exportFooter":`Skill export prepares a portable bundle for external AI tools.`,"protocol.triggers":`Activation patterns`,"protocol.completion":`Reward signal`,"protocol.howToUse":`How to use this protocol`,"protocol.howToUseInProduct":`The public UI helps people read, edit, export, and manually test protocol steps. Live AI execution still happens through MCP or CLI tooling.`,"protocol.howToUseCopy":`Use Test Run from the button above to step through this protocol in the browser. For agents or CLI, use Cursor (MCP) or the command line. See`,"protocol.docsLink":`documentation`,"runs.title":`Test Run`,"runs.subtitle":`Continue a test run you started earlier on this device.`,"runs.empty":`No runs yet.`,"runs.listLabel":`Test Run list`,"runs.status":`Status`,"runs.updated":`Updated`,"runs.stepsDone":`{{count}} steps completed`,"runs.resume":`Resume`,"runs.remove":`Remove`,"run.title":`Test Run`,"run.guidedIntro":`Step through the saved run in the browser and submit the same data the current run flow expects.`,"run.progressHeading":`Progress`,"run.currentStepHeading":`Current step`,"run.challengeHeading":`Challenge`,"run.stepProgress":`Step {{current}} of {{total}}`,"run.sessionBadge":`Active manual test session`,"run.flowStepN":`{{n}}`,"run.copyShellCommand":`Copy command`,"run.adapterUri":`Adapter URI`,"run.backToProtocol":`Back to adapter`,"run.start":`Start run`,"run.starting":`Starting…`,"run.safety.title":`Safe by default`,"run.safety.copy":`This guided run never executes shell commands in your browser. For shell challenges, run the command yourself and paste the real results.`,"run.serverMessage":`Server message`,"run.currentLayer":`Current layer`,"run.layerUri":`Layer URI`,"run.noLayerContent":`(No layer content)`,"run.contract":`Contract`,"run.contractType":`Type`,"run.advanced":`Advanced`,"run.nonce":`Nonce`,"run.proofHash":`Challenge proof_hash`,"run.previousProofHash":`Previous proof_hash`,"run.copy":`Copy`,"run.copied":`Copied`,"run.solution":`Solution`,"run.solutionFormLabel":`Submit solution`,"run.submitStep":`Submit step`,"run.shell.command":`Command`,"run.shell.invocation":`Invocation`,"run.shell.exitCode":`Exit code`,"run.shell.stdout":`Stdout`,"run.shell.stderr":`Stderr`,"run.mcp.toolName":`Tool`,"run.mcp.toolMissing":`(Missing tool name)`,"run.mcp.success":`Success`,"run.mcp.arguments":`Arguments (JSON)`,"run.mcp.result":`Result (JSON)`,"run.userInput.prompt":`Prompt`,"run.userInput.promptMissing":`(Missing prompt)`,"run.userInput.confirmation":`User confirmation`,"run.comment.minLength":`Minimum {{count}} characters`,"run.comment.count":`{{count}} typed`,"run.comment.text":`Comment`,"run.reward.title":`Reward completion`,"run.reward.subtitle":`Finalize the run outcome for reward and export quality.`,"run.reward.outcomeLabel":`Outcome`,"run.reward.success":`Success`,"run.reward.failure":`Failure`,"run.reward.feedback":`Feedback`,"run.reward.submit":`Submit reward`,"run.reward.submitting":`Submitting…`,"run.reward.defaultFeedback":`Completed guided run.`,"run.stepperProgress":`{{completed}} step(s) completed`,"run.history":`History`,"run.historyLabel":`Run history`,"run.completed":`Run completed`,"run.missingUri":`Missing adapter URI.`,"protocolEdit.newTitle":`New protocol`,"protocolEdit.editTitle":`Edit protocol`,"protocolEdit.hint":`Write as a human. The editor renders text on input and output while keeping the saved format compatible with generic Markdown.`,"protocolEdit.stepHeading":`Step {{n}}`,"protocolEdit.stepEditorHint":`Human-friendly editor with Markdown-safe formatting.`,"protocolEdit.triggersEditorHint":`Shown to humans as rendered text and serialized as Markdown-compatible content.`,"protocolEdit.previewRenderedTitle":`Rendered preview`,"protocolEdit.previewRenderedSubtitle":`Reading flow is fully rendered. Editing keeps a Markdown-safe rich text surface and this card previews section structure.`,"protocolEdit.previewStepLine":`Step {{n}}: {{label}}`,"protocolEdit.skillShortcutTitle":`Skill bundle shortcut`,"protocolEdit.skillShortcutSubtitle":`Authors can turn a protocol into a reusable skill bundle without learning repo-internal file names.`,"protocolEdit.formLabel":`Protocol form`,"protocolEdit.protocolLabel":`Protocol label`,"protocolEdit.triggersLabel":`Activation patterns`,"protocolEdit.triggersHint":`Describe when this protocol should run (e.g. deploy and test).`,"protocolEdit.stepLabel":`Step label`,"protocolEdit.stepContent":`Step content`,"protocolEdit.challengeType":`Challenge type`,"protocolEdit.addStep":`Add step`,"protocolEdit.removeStep":`Remove step`,"protocolEdit.completionLabel":`Reward signal`,"protocolEdit.challengeShell":`Shell command`,"protocolEdit.challengeMcp":`MCP tool call`,"protocolEdit.challengeUserInput":`User input`,"protocolEdit.challengeComment":`Comment`,"protocolEdit.shellCmd":`Command`,"protocolEdit.shellTimeout":`Timeout (seconds)`,"protocolEdit.shellInterpreter":`Interpreter (optional)`,"protocolEdit.shellFlags":`Flags (one per line, optional)`,"protocolEdit.shellArgs":`Args (one per line, optional)`,"protocolEdit.shellWorkdir":`Workdir (optional)`,"protocolEdit.mcpToolName":`Tool name`,"protocolEdit.userInputPrompt":`Prompt`,"protocolEdit.commentMinLength":`Minimum length (characters)`,"protocolEdit.importCardTitle":`Import existing content`,"protocolEdit.uploadHint":"Uploading a `.md` file fills this editor form. It does not publish or overwrite anything until you save.","protocolEdit.contentLabel":`Protocol content (markdown)`,"protocolEdit.previewLabel":`Protocol preview`,"protocolEdit.previewTitle":`Live preview`,"protocolEdit.previewSteps":`Steps`,"protocolEdit.previewNoSteps":`No steps yet.`,"protocolEdit.previewSections":`Key sections`,"protocolEdit.present":`present`,"protocolEdit.missing":`missing`,"protocolEdit.insertTemplate":`Insert template`,"protocolEdit.upload":`Upload .md file`,"skill.title":`Edit as Skill`,"skill.subtitle":`Prepare a skill bundle for external AI tools before downloading the zip. Protocol content stays connected to the original workflow.`,"skill.bundleContentsTitle":`Bundle contents`,"skill.bundleContentsSubtitle":`Optional protocol references can be included in a dedicated folder.`,"skill.chipReadme":`Include README snippet`,"skill.chipPrompts":`Include example prompts`,"skill.comingSoon":`Coming soon`,"skill.bundlePreviewTitle":`Bundle preview`,"skill.bundlePreviewSubtitle":`Zip root contains the skill folder so users can upload it directly.`,"skill.whyExportTitle":`Why this export exists`,"skill.whyExportSubtitle":`The bundle is for human-friendly reuse, not an internal raw dump.`,"skill.whyExportBody":`Authors can package a protocol as a portable skill with polished naming and usage guidance, then download the final zip in one step.`,"skill.skillName":`Skill name`,"skill.description":`Skill description`,"skill.descriptionHint":`Describe what the skill does and when an AI assistant should use it.`,"skill.whenToUse":`When to use it`,"skill.includeReferences":`Include references folder`,"skill.downloadAsSkill":`Download as Skill`,"skill.backToProtocol":`Back to protocol`,"protocolEdit.placeholder":`# Protocol title
3
3
 
4
4
  ## Activation Patterns
5
5
  ...
6
6
 
7
7
  ## Step 1
8
- ...`,"protocolEdit.contentHint":`Include: Activation Patterns (first H2), steps (H2 + optional challenge block), Reward Signal (last H2).`,"protocolEdit.targetSpaceLabel":`Save to space`,"protocolEdit.targetSpaceHint":`New protocols are stored in the space you pick (default: Personal).`,"protocolEdit.forkSourceLabel":`Fork from adapter (optional)`,"protocolEdit.forkSourcePlaceholder":`squadrules://adapter/{slug}`,"protocolEdit.forkSourceHint":`Leave empty for a brand-new protocol, or paste an adapter URI to copy its markdown into the target space as a new adapter.`,"protocolEdit.forkUriInvalid":`Fork source must be a squadrules://adapter/{slug} URI.`,"protocolEdit.moveSpaceLabel":`Space for this protocol`,"protocolEdit.moveSpaceHint":`Change the space and save to move every layer to the selected space (same as tune with a space parameter).`,"protocolEdit.save":`Save`,"protocolEdit.saving":`Saving…`,"protocolEdit.cancel":`Cancel`,"account.title":`Account`,"account.intro":`You are signed in. Sign out below or use the options to manage your profile.`,"account.loading":`Loading…`,"account.notSignedIn":`You are not signed in.`,"account.signIn":`Sign in`,"account.name":`Name`,"account.username":`Username`,"account.email":`Email`,"account.emailVerified":`verified`,"account.accountType":`Account type`,"account.realm":`Realm`,"account.identityProvider":`Login provider`,"account.groups":`Groups`,"account.themeTitle":`Theme`,"account.themeDescription":`Choose how SQUADRULES UI appearance should be rendered.`,"account.themePreferenceLabel":`Theme preference`,"account.themeOptionLight":`Light`,"account.themeOptionDark":`Dark`,"account.themeOptionSystem":`Match system`,"account.logOut":`Log out`,"notFound.title":`Page not found`,"notFound.message":`The page you requested could not be found.`,"notFound.goHome":`Go to Home`,"error.title":`Something went wrong`,"error.retry":`Retry`,"error.goBack":`Go to Home`,"error.support":`Support`}}},interpolation:{escapeValue:!1}});var g=e(p(),1),_=m(),v=`/ui/assets/squadrules-mcp-Qc5pokoj.svg`,y=h(),b=e=>e.startsWith(`/protocols`)||e.startsWith(`/runs`);function x(){let{t:e}=f(),t=a().pathname,n=({isActive:e})=>`min-h-[var(--layout-touch-target)] flex items-center px-4 py-3 text-[var(--color-text)] no-underline border-l-[3px] border-transparent outline-offset-2 focus-visible:outline focus-visible:outline-2 focus-visible:outline-[var(--color-focus-ring)] hover:bg-[var(--color-surface)] hover:text-[var(--color-text-heading)] ${e?`font-semibold text-[var(--color-primary)] border-l-[var(--color-primary)] bg-[var(--color-surface)]`:``}`,r=b(t)?`min(100%, var(--layout-main-max), var(--layout-main-wide))`:`min(100%, var(--layout-main-max), var(--layout-main-narrow))`;return(0,y.jsxs)(y.Fragment,{children:[(0,y.jsx)(`a`,{href:`#main`,className:`skip-link`,children:e(`skipToMain`)}),(0,y.jsxs)(`div`,{className:`flex min-h-screen`,children:[(0,y.jsxs)(`aside`,{className:`flex min-h-screen w-[var(--layout-sidebar-width)] flex-shrink-0 flex-col border-r border-[var(--color-border)] bg-[var(--color-surface-elevated)] py-4`,"aria-label":`Main navigation`,children:[(0,y.jsx)(`div`,{className:`px-4 pb-4`,children:(0,y.jsxs)(c,{to:`/`,end:!0,className:`flex min-h-[var(--layout-touch-target)] min-w-[var(--layout-touch-target)] items-center gap-3 rounded-md outline-offset-2 focus-visible:outline focus-visible:outline-2 focus-visible:outline-[var(--color-focus-ring)]`,children:[(0,y.jsx)(`img`,{src:v,alt:``,className:`h-10 w-10 flex-shrink-0 rounded-lg object-contain`,width:`40`,height:`40`}),(0,y.jsxs)(`span`,{className:`flex flex-col leading-tight`,children:[(0,y.jsx)(`span`,{className:`font-bold text-[var(--color-text-heading)] text-lg`,children:`Squadrules`}),(0,y.jsx)(`span`,{className:`font-bold text-[var(--color-text-muted)] text-xs uppercase tracking-wide`,children:`MCP`})]})]})}),(0,y.jsxs)(`nav`,{className:`flex min-h-0 flex-1 flex-col gap-0.5`,children:[(0,y.jsx)(c,{to:`/`,end:!0,"aria-current":t===`/`?`page`:void 0,className:n,children:e(`nav.home`)}),(0,y.jsx)(c,{to:`/squadrules`,"aria-current":t===`/squadrules`?`page`:void 0,className:n,children:e(`nav.squadrules`)}),(0,y.jsx)(c,{to:`/protocols/new`,"aria-current":t===`/protocols/new`?`page`:void 0,className:n,children:e(`nav.create`)}),(0,y.jsx)(c,{to:`/runs`,"aria-current":t===`/runs`?`page`:void 0,className:n,children:e(`nav.runs`)}),(0,y.jsx)(c,{to:`/account`,"aria-current":t===`/account`?`page`:void 0,className:n,children:e(`nav.account`)})]}),(0,y.jsx)(`div`,{className:`mt-auto border-t border-[var(--color-border)] px-4 pt-3`,children:(0,y.jsx)(`p`,{className:`m-0 text-xs text-[var(--color-text-muted)]`,children:e(`layout.squadrulesVersion`,{version:`5.2.0`})})})]}),(0,y.jsx)(`main`,{id:`main`,className:`flex-1 mx-auto w-full py-[var(--layout-main-padding-y)] px-[var(--layout-main-padding-x)]`,style:{maxWidth:r},tabIndex:-1,children:(0,y.jsx)(s,{})})]})]})}var S=(0,g.lazy)(()=>r(()=>import(`./HomePage-B06u5RCw.js`).then(e=>({default:e.HomePage})),__vite__mapDeps([0,1,2,3,4,5,6,7]))),C=(0,g.lazy)(()=>r(()=>import(`./SquadrulesPage-D84vIaBc.js`).then(e=>({default:e.SquadrulesPage})),__vite__mapDeps([8,2,1,3,4,6,5,9]))),w=(0,g.lazy)(()=>r(()=>import(`./RunsPage-4kDF_Ylg.js`).then(e=>({default:e.RunsPage})),__vite__mapDeps([10,1,2,3,4,11]))),T=(0,g.lazy)(()=>r(()=>import(`./ProtocolEditPage-mChBe3JY.js`).then(e=>({default:e.ProtocolEditPage})),__vite__mapDeps([12,2,1,3,4,6,5,7,13,14,15]))),E=(0,g.lazy)(()=>r(()=>import(`./RunGuidedPage-Bd1bUTBH.js`).then(e=>({default:e.RunGuidedPage})),__vite__mapDeps([16,2,1,3,4,6,7,9,14,17,11]))),D=(0,g.lazy)(()=>r(()=>import(`./SkillBundlePage-D1OPKJzA.js`).then(e=>({default:e.SkillBundlePage})),__vite__mapDeps([18,2,1,3,4,7,13,6,15]))),O=(0,g.lazy)(()=>r(()=>import(`./ProtocolDetailPage-DCw5D34S.js`).then(e=>({default:e.ProtocolDetailPage})),__vite__mapDeps([19,2,1,3,4,7,13,6,14,17]))),k=(0,g.lazy)(()=>r(()=>import(`./AccountPage-Ci29Zidn.js`).then(e=>({default:e.AccountPage})),__vite__mapDeps([20,1,2,3,4,6]))),A=(0,g.lazy)(()=>r(()=>import(`./NotFoundPage-Dz-PKC4R.js`).then(e=>({default:e.NotFoundPage})),__vite__mapDeps([21,1,2,3,4,9])));function j(){return(0,y.jsx)(`div`,{className:`flex min-h-[12rem] items-center justify-center text-[var(--color-text-muted)]`,"aria-busy":`true`,children:`Loading…`})}function M(){return(0,y.jsx)(i,{children:(0,y.jsxs)(l,{path:`/`,element:(0,y.jsx)(x,{}),children:[(0,y.jsx)(l,{index:!0,element:(0,y.jsx)(g.Suspense,{fallback:(0,y.jsx)(j,{}),children:(0,y.jsx)(S,{})})}),(0,y.jsx)(l,{path:`squadrules`,element:(0,y.jsx)(g.Suspense,{fallback:(0,y.jsx)(j,{}),children:(0,y.jsx)(C,{})})}),(0,y.jsx)(l,{path:`runs`,element:(0,y.jsx)(g.Suspense,{fallback:(0,y.jsx)(j,{}),children:(0,y.jsx)(w,{})})}),(0,y.jsx)(l,{path:`protocols/new`,element:(0,y.jsx)(g.Suspense,{fallback:(0,y.jsx)(j,{}),children:(0,y.jsx)(T,{})})}),(0,y.jsx)(l,{path:`protocols/:uri/edit`,element:(0,y.jsx)(g.Suspense,{fallback:(0,y.jsx)(j,{}),children:(0,y.jsx)(T,{})})}),(0,y.jsx)(l,{path:`protocols/:uri/run`,element:(0,y.jsx)(g.Suspense,{fallback:(0,y.jsx)(j,{}),children:(0,y.jsx)(E,{})})}),(0,y.jsx)(l,{path:`protocols/:uri/skill`,element:(0,y.jsx)(g.Suspense,{fallback:(0,y.jsx)(j,{}),children:(0,y.jsx)(D,{})})}),(0,y.jsx)(l,{path:`protocols/:uri`,element:(0,y.jsx)(g.Suspense,{fallback:(0,y.jsx)(j,{}),children:(0,y.jsx)(O,{})})}),(0,y.jsx)(l,{path:`account`,element:(0,y.jsx)(g.Suspense,{fallback:(0,y.jsx)(j,{}),children:(0,y.jsx)(k,{})})}),(0,y.jsx)(l,{path:`*`,element:(0,y.jsx)(g.Suspense,{fallback:(0,y.jsx)(j,{}),children:(0,y.jsx)(A,{})})})]})})}function N(){return(0,y.jsx)(o,{basename:`/ui`,children:(0,y.jsx)(M,{})})}var P=[`light`,`dark`],F=`squadrules:ui:theme-preference`,I=`(prefers-color-scheme: dark)`,L=`system`;function R(e){return e===null?!1:e===`system`||P.includes(e)}function z(e,t){return e===`system`?t?`dark`:`light`:e}function B(){if(typeof window>`u`)return L;try{let e=window.localStorage.getItem(F);return R(e)?e:L}catch{return L}}function V(){return typeof window>`u`||typeof window.matchMedia!=`function`?!1:window.matchMedia(I).matches}function H(e){if(typeof document>`u`)return;let t=document.documentElement;t.setAttribute(`data-theme`,e),t.style.colorScheme=e===`light`?`light`:`dark`}function U(){let[e,t]=(0,g.useState)(()=>B()),[n,r]=(0,g.useState)(()=>V()),i=(0,g.useMemo)(()=>z(e,n),[e,n]);return(0,g.useEffect)(()=>{H(i)},[i]),(0,g.useEffect)(()=>{if(typeof window>`u`||e!==`system`||typeof window.matchMedia!=`function`)return;let t=window.matchMedia(I);r(t.matches);let n=e=>{r(e.matches)};return typeof t.addEventListener==`function`?(t.addEventListener(`change`,n),()=>t.removeEventListener(`change`,n)):(t.addListener(n),()=>t.removeListener(n))},[e]),(0,g.useEffect)(()=>{if(typeof window>`u`)return;let e=e=>{e.key===`squadrules:ui:theme-preference`&&t(R(e.newValue)?e.newValue:L)};return window.addEventListener(`storage`,e),()=>window.removeEventListener(`storage`,e)},[]),{preference:e,effectiveTheme:i,setPreference:(0,g.useCallback)(e=>{if(t(e),typeof window<`u`)try{window.localStorage.setItem(F,e)}catch{}},[])}}var W=(0,g.createContext)(null);function G({children:e}){let t=U();return(0,y.jsx)(W.Provider,{value:t,children:e})}function K(){let e=(0,g.useContext)(W);if(!e)throw Error(`useThemePreferenceContext must be used within ThemeProvider`);return e}var q=new t;(0,_.createRoot)(document.getElementById(`root`)).render((0,y.jsx)(g.StrictMode,{children:(0,y.jsx)(u,{client:q,children:(0,y.jsx)(G,{children:(0,y.jsx)(N,{})})})}));export{R as n,K as r,P as t};
8
+ ...`,"protocolEdit.contentHint":`Include: Activation Patterns (first H2), steps (H2 + optional challenge block), Reward Signal (last H2).`,"protocolEdit.targetSpaceLabel":`Save to space`,"protocolEdit.targetSpaceHint":`New protocols are stored in the space you pick (default: Personal).`,"protocolEdit.forkSourceLabel":`Fork from adapter (optional)`,"protocolEdit.forkSourcePlaceholder":`squadrules://adapter/{slug}`,"protocolEdit.forkSourceHint":`Leave empty for a brand-new protocol, or paste an adapter URI to copy its markdown into the target space as a new adapter.`,"protocolEdit.forkUriInvalid":`Fork source must be a squadrules://adapter/{slug} URI.`,"protocolEdit.moveSpaceLabel":`Space for this protocol`,"protocolEdit.moveSpaceHint":`Change the space and save to move every layer to the selected space (same as tune with a space parameter).`,"protocolEdit.save":`Save`,"protocolEdit.saving":`Saving…`,"protocolEdit.cancel":`Cancel`,"account.title":`Account`,"account.intro":`You are signed in. Sign out below or use the options to manage your profile.`,"account.loading":`Loading…`,"account.notSignedIn":`You are not signed in.`,"account.signIn":`Sign in`,"account.name":`Name`,"account.username":`Username`,"account.email":`Email`,"account.emailVerified":`verified`,"account.accountType":`Account type`,"account.realm":`Realm`,"account.identityProvider":`Login provider`,"account.groups":`Groups`,"account.themeTitle":`Theme`,"account.themeDescription":`Choose how SQUADRULES UI appearance should be rendered.`,"account.themePreferenceLabel":`Theme preference`,"account.themeOptionLight":`Light`,"account.themeOptionDark":`Dark`,"account.themeOptionSystem":`Match system`,"account.logOut":`Log out`,"notFound.title":`Page not found`,"notFound.message":`The page you requested could not be found.`,"notFound.goHome":`Go to Home`,"error.title":`Something went wrong`,"error.retry":`Retry`,"error.goBack":`Go to Home`,"error.support":`Support`}}},interpolation:{escapeValue:!1}});var g=e(p(),1),_=m(),v=`/ui/assets/squadrules-mcp-Qc5pokoj.svg`,y=h(),b=e=>e.startsWith(`/protocols`)||e.startsWith(`/runs`);function x(){let{t:e}=f(),t=a().pathname,n=({isActive:e})=>`min-h-[var(--layout-touch-target)] flex items-center px-4 py-3 text-[var(--color-text)] no-underline border-l-[3px] border-transparent outline-offset-2 focus-visible:outline focus-visible:outline-2 focus-visible:outline-[var(--color-focus-ring)] hover:bg-[var(--color-surface)] hover:text-[var(--color-text-heading)] ${e?`font-semibold text-[var(--color-primary)] border-l-[var(--color-primary)] bg-[var(--color-surface)]`:``}`,r=b(t)?`min(100%, var(--layout-main-max), var(--layout-main-wide))`:`min(100%, var(--layout-main-max), var(--layout-main-narrow))`;return(0,y.jsxs)(y.Fragment,{children:[(0,y.jsx)(`a`,{href:`#main`,className:`skip-link`,children:e(`skipToMain`)}),(0,y.jsxs)(`div`,{className:`flex min-h-screen`,children:[(0,y.jsxs)(`aside`,{className:`flex min-h-screen w-[var(--layout-sidebar-width)] flex-shrink-0 flex-col border-r border-[var(--color-border)] bg-[var(--color-surface-elevated)] py-4`,"aria-label":`Main navigation`,children:[(0,y.jsx)(`div`,{className:`px-4 pb-4`,children:(0,y.jsxs)(c,{to:`/`,end:!0,className:`flex min-h-[var(--layout-touch-target)] min-w-[var(--layout-touch-target)] items-center gap-3 rounded-md outline-offset-2 focus-visible:outline focus-visible:outline-2 focus-visible:outline-[var(--color-focus-ring)]`,children:[(0,y.jsx)(`img`,{src:v,alt:``,className:`h-10 w-10 flex-shrink-0 rounded-lg object-contain`,width:`40`,height:`40`}),(0,y.jsxs)(`span`,{className:`flex flex-col leading-tight`,children:[(0,y.jsx)(`span`,{className:`font-bold text-[var(--color-text-heading)] text-lg`,children:`Squadrules`}),(0,y.jsx)(`span`,{className:`font-bold text-[var(--color-text-muted)] text-xs uppercase tracking-wide`,children:`MCP`})]})]})}),(0,y.jsxs)(`nav`,{className:`flex min-h-0 flex-1 flex-col gap-0.5`,children:[(0,y.jsx)(c,{to:`/`,end:!0,"aria-current":t===`/`?`page`:void 0,className:n,children:e(`nav.home`)}),(0,y.jsx)(c,{to:`/squadrules`,"aria-current":t===`/squadrules`?`page`:void 0,className:n,children:e(`nav.squadrules`)}),(0,y.jsx)(c,{to:`/protocols/new`,"aria-current":t===`/protocols/new`?`page`:void 0,className:n,children:e(`nav.create`)}),(0,y.jsx)(c,{to:`/runs`,"aria-current":t===`/runs`?`page`:void 0,className:n,children:e(`nav.runs`)}),(0,y.jsx)(c,{to:`/account`,"aria-current":t===`/account`?`page`:void 0,className:n,children:e(`nav.account`)})]}),(0,y.jsx)(`div`,{className:`mt-auto border-t border-[var(--color-border)] px-4 pt-3`,children:(0,y.jsx)(`p`,{className:`m-0 text-xs text-[var(--color-text-muted)]`,children:e(`layout.squadrulesVersion`,{version:`5.3.0`})})})]}),(0,y.jsx)(`main`,{id:`main`,className:`flex-1 mx-auto w-full py-[var(--layout-main-padding-y)] px-[var(--layout-main-padding-x)]`,style:{maxWidth:r},tabIndex:-1,children:(0,y.jsx)(s,{})})]})]})}var S=(0,g.lazy)(()=>r(()=>import(`./HomePage-B--ESwM9.js`).then(e=>({default:e.HomePage})),__vite__mapDeps([0,1,2,3,4,5,6,7]))),C=(0,g.lazy)(()=>r(()=>import(`./SquadrulesPage-C37VEZnc.js`).then(e=>({default:e.SquadrulesPage})),__vite__mapDeps([8,2,1,3,4,6,5,9]))),w=(0,g.lazy)(()=>r(()=>import(`./RunsPage-BSgcu2TO.js`).then(e=>({default:e.RunsPage})),__vite__mapDeps([10,1,2,3,4,11]))),T=(0,g.lazy)(()=>r(()=>import(`./ProtocolEditPage-HAcAGXw7.js`).then(e=>({default:e.ProtocolEditPage})),__vite__mapDeps([12,2,1,3,4,6,5,7,13,14,15]))),E=(0,g.lazy)(()=>r(()=>import(`./RunGuidedPage-Bewi7Wsx.js`).then(e=>({default:e.RunGuidedPage})),__vite__mapDeps([16,2,1,3,4,6,7,9,14,17,11]))),D=(0,g.lazy)(()=>r(()=>import(`./SkillBundlePage-CiMQN0nf.js`).then(e=>({default:e.SkillBundlePage})),__vite__mapDeps([18,2,1,3,4,7,13,6,15]))),O=(0,g.lazy)(()=>r(()=>import(`./ProtocolDetailPage-DFe_JOr3.js`).then(e=>({default:e.ProtocolDetailPage})),__vite__mapDeps([19,2,1,3,4,7,13,6,14,17]))),k=(0,g.lazy)(()=>r(()=>import(`./AccountPage-DhaO-G9K.js`).then(e=>({default:e.AccountPage})),__vite__mapDeps([20,1,2,3,4,6]))),A=(0,g.lazy)(()=>r(()=>import(`./NotFoundPage-bTE_mpMC.js`).then(e=>({default:e.NotFoundPage})),__vite__mapDeps([21,1,2,3,4,9])));function j(){return(0,y.jsx)(`div`,{className:`flex min-h-[12rem] items-center justify-center text-[var(--color-text-muted)]`,"aria-busy":`true`,children:`Loading…`})}function M(){return(0,y.jsx)(i,{children:(0,y.jsxs)(l,{path:`/`,element:(0,y.jsx)(x,{}),children:[(0,y.jsx)(l,{index:!0,element:(0,y.jsx)(g.Suspense,{fallback:(0,y.jsx)(j,{}),children:(0,y.jsx)(S,{})})}),(0,y.jsx)(l,{path:`squadrules`,element:(0,y.jsx)(g.Suspense,{fallback:(0,y.jsx)(j,{}),children:(0,y.jsx)(C,{})})}),(0,y.jsx)(l,{path:`runs`,element:(0,y.jsx)(g.Suspense,{fallback:(0,y.jsx)(j,{}),children:(0,y.jsx)(w,{})})}),(0,y.jsx)(l,{path:`protocols/new`,element:(0,y.jsx)(g.Suspense,{fallback:(0,y.jsx)(j,{}),children:(0,y.jsx)(T,{})})}),(0,y.jsx)(l,{path:`protocols/:uri/edit`,element:(0,y.jsx)(g.Suspense,{fallback:(0,y.jsx)(j,{}),children:(0,y.jsx)(T,{})})}),(0,y.jsx)(l,{path:`protocols/:uri/run`,element:(0,y.jsx)(g.Suspense,{fallback:(0,y.jsx)(j,{}),children:(0,y.jsx)(E,{})})}),(0,y.jsx)(l,{path:`protocols/:uri/skill`,element:(0,y.jsx)(g.Suspense,{fallback:(0,y.jsx)(j,{}),children:(0,y.jsx)(D,{})})}),(0,y.jsx)(l,{path:`protocols/:uri`,element:(0,y.jsx)(g.Suspense,{fallback:(0,y.jsx)(j,{}),children:(0,y.jsx)(O,{})})}),(0,y.jsx)(l,{path:`account`,element:(0,y.jsx)(g.Suspense,{fallback:(0,y.jsx)(j,{}),children:(0,y.jsx)(k,{})})}),(0,y.jsx)(l,{path:`*`,element:(0,y.jsx)(g.Suspense,{fallback:(0,y.jsx)(j,{}),children:(0,y.jsx)(A,{})})})]})})}function N(){return(0,y.jsx)(o,{basename:`/ui`,children:(0,y.jsx)(M,{})})}var P=[`light`,`dark`],F=`squadrules:ui:theme-preference`,I=`(prefers-color-scheme: dark)`,L=`system`;function R(e){return e===null?!1:e===`system`||P.includes(e)}function z(e,t){return e===`system`?t?`dark`:`light`:e}function B(){if(typeof window>`u`)return L;try{let e=window.localStorage.getItem(F);return R(e)?e:L}catch{return L}}function V(){return typeof window>`u`||typeof window.matchMedia!=`function`?!1:window.matchMedia(I).matches}function H(e){if(typeof document>`u`)return;let t=document.documentElement;t.setAttribute(`data-theme`,e),t.style.colorScheme=e===`light`?`light`:`dark`}function U(){let[e,t]=(0,g.useState)(()=>B()),[n,r]=(0,g.useState)(()=>V()),i=(0,g.useMemo)(()=>z(e,n),[e,n]);return(0,g.useEffect)(()=>{H(i)},[i]),(0,g.useEffect)(()=>{if(typeof window>`u`||e!==`system`||typeof window.matchMedia!=`function`)return;let t=window.matchMedia(I);r(t.matches);let n=e=>{r(e.matches)};return typeof t.addEventListener==`function`?(t.addEventListener(`change`,n),()=>t.removeEventListener(`change`,n)):(t.addListener(n),()=>t.removeListener(n))},[e]),(0,g.useEffect)(()=>{if(typeof window>`u`)return;let e=e=>{e.key===`squadrules:ui:theme-preference`&&t(R(e.newValue)?e.newValue:L)};return window.addEventListener(`storage`,e),()=>window.removeEventListener(`storage`,e)},[]),{preference:e,effectiveTheme:i,setPreference:(0,g.useCallback)(e=>{if(t(e),typeof window<`u`)try{window.localStorage.setItem(F,e)}catch{}},[])}}var W=(0,g.createContext)(null);function G({children:e}){let t=U();return(0,y.jsx)(W.Provider,{value:t,children:e})}function K(){let e=(0,g.useContext)(W);if(!e)throw Error(`useThemePreferenceContext must be used within ThemeProvider`);return e}var q=new t;(0,_.createRoot)(document.getElementById(`root`)).render((0,y.jsx)(g.StrictMode,{children:(0,y.jsx)(u,{client:q,children:(0,y.jsx)(G,{children:(0,y.jsx)(N,{})})})}));export{R as n,K as r,P as t};