@debian777/kairos-mcp 4.0.0 → 4.0.1

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 (80) hide show
  1. package/dist/.tsbuildinfo +1 -1
  2. package/dist/constants/builtin-search-meta.d.ts +4 -0
  3. package/dist/constants/builtin-search-meta.d.ts.map +1 -1
  4. package/dist/constants/builtin-search-meta.js +20 -0
  5. package/dist/constants/builtin-search-meta.js.map +1 -1
  6. package/dist/embed-docs/mem/00000000-0000-0000-0000-000000002001.md +11 -6
  7. package/dist/embed-docs/mem/00000000-0000-0000-0000-000000002002.md +1 -1
  8. package/dist/embed-docs/mem/00000000-0000-0000-0000-000000002003.md +2 -2
  9. package/dist/embed-docs/mem/00000000-0000-0000-0000-000000002004.md +5 -5
  10. package/dist/embed-docs/mem/00000000-0000-0000-0000-000000002005.md +2 -2
  11. package/dist/mcp-apps/forward-widget-inline-script.js +1 -1
  12. package/dist/resources/embedded-mcp-resources.js +8 -8
  13. package/dist/resources/embedded-mcp-resources.js.map +1 -1
  14. package/dist/services/memory/activation-pattern-payload.d.ts.map +1 -1
  15. package/dist/services/memory/activation-pattern-payload.js +3 -0
  16. package/dist/services/memory/activation-pattern-payload.js.map +1 -1
  17. package/dist/services/memory/adapter-builder.d.ts.map +1 -1
  18. package/dist/services/memory/adapter-builder.js +16 -1
  19. package/dist/services/memory/adapter-builder.js.map +1 -1
  20. package/dist/services/memory/qdrant-point-to-memory.d.ts.map +1 -1
  21. package/dist/services/memory/qdrant-point-to-memory.js +3 -0
  22. package/dist/services/memory/qdrant-point-to-memory.js.map +1 -1
  23. package/dist/services/memory/store-adapter-default-handler.d.ts.map +1 -1
  24. package/dist/services/memory/store-adapter-default-handler.js +2 -1
  25. package/dist/services/memory/store-adapter-default-handler.js.map +1 -1
  26. package/dist/services/memory/store-adapter-header-handler.d.ts.map +1 -1
  27. package/dist/services/memory/store-adapter-header-handler.js +2 -1
  28. package/dist/services/memory/store-adapter-header-handler.js.map +1 -1
  29. package/dist/services/qdrant/memory-retrieval.d.ts.map +1 -1
  30. package/dist/services/qdrant/memory-retrieval.js +3 -0
  31. package/dist/services/qdrant/memory-retrieval.js.map +1 -1
  32. package/dist/tools/activate.d.ts.map +1 -1
  33. package/dist/tools/activate.js +3 -4
  34. package/dist/tools/activate.js.map +1 -1
  35. package/dist/tools/dump.d.ts.map +1 -1
  36. package/dist/tools/dump.js +19 -0
  37. package/dist/tools/dump.js.map +1 -1
  38. package/dist/tools/forward_schema.d.ts +40 -4
  39. package/dist/tools/forward_schema.d.ts.map +1 -1
  40. package/dist/tools/forward_schema.js +66 -4
  41. package/dist/tools/forward_schema.js.map +1 -1
  42. package/dist/tools/mcp-tool-input-teaching.d.ts.map +1 -1
  43. package/dist/tools/mcp-tool-input-teaching.js +11 -3
  44. package/dist/tools/mcp-tool-input-teaching.js.map +1 -1
  45. package/dist/tools/search.d.ts.map +1 -1
  46. package/dist/tools/search.js +2 -2
  47. package/dist/tools/search.js.map +1 -1
  48. package/dist/tools/search_output.d.ts.map +1 -1
  49. package/dist/tools/search_output.js +13 -9
  50. package/dist/tools/search_output.js.map +1 -1
  51. package/dist/tools/tune-execute.d.ts +4 -0
  52. package/dist/tools/tune-execute.d.ts.map +1 -0
  53. package/dist/tools/tune-execute.js +260 -0
  54. package/dist/tools/tune-execute.js.map +1 -0
  55. package/dist/tools/tune.d.ts +1 -3
  56. package/dist/tools/tune.d.ts.map +1 -1
  57. package/dist/tools/tune.js +8 -125
  58. package/dist/tools/tune.js.map +1 -1
  59. package/dist/types/memory.d.ts +1 -0
  60. package/dist/types/memory.d.ts.map +1 -1
  61. package/dist/ui/assets/{AccountPage-0lWmC1Yi.js → AccountPage-Bin0OWw2.js} +1 -1
  62. package/dist/ui/assets/{ErrorAlert-CEK6Hts_.js → ErrorAlert-xId7zQnR.js} +1 -1
  63. package/dist/ui/assets/{HomePage-DHaSrH_k.js → HomePage-U88uxI09.js} +1 -1
  64. package/dist/ui/assets/{KairosPage-D3vTZLht.js → KairosPage-B8Bgfpqu.js} +1 -1
  65. package/dist/ui/assets/{NotFoundPage-DTGI5qLn.js → NotFoundPage-CSfAllV_.js} +1 -1
  66. package/dist/ui/assets/{ProtocolDetailPage-CbEkCdWc.js → ProtocolDetailPage-DkzLwH8_.js} +1 -1
  67. package/dist/ui/assets/{ProtocolEditPage-DBf4NQGA.js → ProtocolEditPage-DP9Sk1Fh.js} +1 -1
  68. package/dist/ui/assets/{RichTextEditor-MeDG49aR.js → RichTextEditor-CpNxz2Fi.js} +1 -1
  69. package/dist/ui/assets/{RunGuidedPage-QZ-FTCqP.js → RunGuidedPage-BVCMdEbN.js} +1 -1
  70. package/dist/ui/assets/{RunsPage-D8QLy4VF.js → RunsPage-1wzJYbQQ.js} +1 -1
  71. package/dist/ui/assets/{SkillBundlePage-CiQ_FPd0.js → SkillBundlePage-Bqzg9lj8.js} +1 -1
  72. package/dist/ui/assets/{SpaceSelect-D8dsuZ8v.js → SpaceSelect-C_bHSva4.js} +1 -1
  73. package/dist/ui/assets/{StepFlowGraph-DjRbEg_P.js → StepFlowGraph-BEV34aU4.js} +1 -1
  74. package/dist/ui/assets/{index-B0SMMGlX.js → index-BhOTXMY1.js} +3 -3
  75. package/dist/ui/assets/{tiptap-DcbFCWb9.js → tiptap-VSnrfrI4.js} +2 -2
  76. package/dist/ui/assets/{useProtocol-CN2rdtdQ.js → useProtocol-DMe_p3jp.js} +1 -1
  77. package/dist/ui/assets/vendor-DLefRYp3.js +33 -0
  78. package/dist/ui/index.html +3 -3
  79. package/package.json +3 -3
  80. package/dist/ui/assets/vendor-CwKUmZK2.js +0 -33
@@ -1 +1 @@
1
- import{r as e}from"./rolldown-runtime-Dw2cE7zH.js";import{a as t,f as n,h as r,p as i,y as a}from"./vendor-CwKUmZK2.js";import{i as o,t as s}from"./react-BdWJx0XL.js";import{t as c}from"./api-D88c6lbH.js";import{t as l}from"./SurfaceCard-BBbNWQYu.js";import{t as u}from"./ErrorAlert-CEK6Hts_.js";import{n as d}from"./ChallengeCard-Coecs--0.js";import{n as f,t as p}from"./StepFlowGraph-DjRbEg_P.js";import{n as m,t as h}from"./useRunSession-BL4aKCjV.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:!1,[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;return{type:`mcp`,...t?{payload:{tool_name:t}}:{}}}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:0)||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 r({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 r({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 r({mutationFn:e=>D(e)})}function k(e){if(e)return e.match(/kairos:\/\/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:r}=n(),[o]=i(),s=r?decodeURIComponent(r):void 0,{session:c}=h(o.get(`session`)),{upsert:d}=m(),f=w(),p=E(),v=O(),[y,b]=(0,g.useState)(null),[x,C]=(0,g.useState)(`success`),[T,D]=(0,g.useState)(``),[j,M]=(0,g.useState)(null);(0,g.useEffect)(()=>{c&&!y&&(b(c),C(`success`),D(``))},[c,y]);let N=e=>{b(e),d(e)},P=async()=>{if(s)try{let e=await f.mutateAsync(s),t=A(),n=`${s}:${t}`,r=e.next_action?.includes(`reward`)?`ready_to_reward`:`running`,i=k(e.next_action);N({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{b(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`)}),!y&&(0,_.jsx)(`button`,{type:`button`,onClick:P,disabled:f.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:f.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`)})}),f.isError&&(0,_.jsx)(u,{message:f.error instanceof Error?f.error.message:String(f.error),onRetry:()=>P(),showGoBack:!0}),y?.status===`error`&&y.last_message&&(0,_.jsx)(`div`,{className:`mb-6`,children:(0,_.jsx)(u,{message:y.last_message,onRetry:()=>P(),showGoBack:!0})}),y&&y.status!==`error`&&(0,_.jsx)(S,{run:y,rewardOutcome:x,setRewardOutcome:C,rewardFeedback:T,setRewardFeedback:D,copyStatus:j,onCopy:async t=>{M(null);try{await navigator.clipboard.writeText(t),M(e(`run.copied`)),setTimeout(()=>M(null),1500)}catch(e){M(e instanceof Error?e.message:String(e))}},onSubmitStep:async e=>{if(!y?.current_layer)return;let t=y.contract.nonce,n=y.previous_proof_hash??y.contract.proof_hash,r={...e,...t?{nonce:t}:{},...n?{proof_hash:n}:{}};try{let e=await p.mutateAsync({uri:y.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)??y.reward_uri;N({...y,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??y.previous_proof_hash,reward_uri:n?i:void 0,history:[...y.history,{layer:y.current_layer,contract:y.contract,solution:r,submitted_at:t,proof_hash:e.proof_hash,server_message:e.message}]})}catch(e){N({...y,updated_at:A(),status:`error`,last_message:e instanceof Error?e.message:String(e)})}},onReward:async()=>{if(!y)return;let t=y.reward_uri??y.current_layer?.uri;if(t)try{let n=await v.mutateAsync({uri:t,outcome:x,feedback:T.trim()||e(`run.reward.defaultFeedback`)});N({...y,updated_at:A(),status:`completed`,last_message:n.results[0]?.feedback??y.last_message})}catch(e){N({...y,updated_at:A(),status:`error`,last_message:e instanceof Error?e.message:String(e)})}},isForwardStepPending:p.isPending,isForwardStartPending:f.isPending,isRewardPending:v.isPending})]}):(0,_.jsx)(u,{message:e(`run.missingUri`),showGoBack:!0})}export{j as RunGuidedPage};
1
+ import{r as e}from"./rolldown-runtime-Dw2cE7zH.js";import{a as t,f as n,h as r,p as i,y as a}from"./vendor-DLefRYp3.js";import{i as o,t as s}from"./react-BdWJx0XL.js";import{t as c}from"./api-D88c6lbH.js";import{t as l}from"./SurfaceCard-BBbNWQYu.js";import{t as u}from"./ErrorAlert-xId7zQnR.js";import{n as d}from"./ChallengeCard-Coecs--0.js";import{n as f,t as p}from"./StepFlowGraph-BEV34aU4.js";import{n as m,t as h}from"./useRunSession-BL4aKCjV.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:!1,[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;return{type:`mcp`,...t?{payload:{tool_name:t}}:{}}}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:0)||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 r({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 r({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 r({mutationFn:e=>D(e)})}function k(e){if(e)return e.match(/kairos:\/\/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:r}=n(),[o]=i(),s=r?decodeURIComponent(r):void 0,{session:c}=h(o.get(`session`)),{upsert:d}=m(),f=w(),p=E(),v=O(),[y,b]=(0,g.useState)(null),[x,C]=(0,g.useState)(`success`),[T,D]=(0,g.useState)(``),[j,M]=(0,g.useState)(null);(0,g.useEffect)(()=>{c&&!y&&(b(c),C(`success`),D(``))},[c,y]);let N=e=>{b(e),d(e)},P=async()=>{if(s)try{let e=await f.mutateAsync(s),t=A(),n=`${s}:${t}`,r=e.next_action?.includes(`reward`)?`ready_to_reward`:`running`,i=k(e.next_action);N({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{b(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`)}),!y&&(0,_.jsx)(`button`,{type:`button`,onClick:P,disabled:f.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:f.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`)})}),f.isError&&(0,_.jsx)(u,{message:f.error instanceof Error?f.error.message:String(f.error),onRetry:()=>P(),showGoBack:!0}),y?.status===`error`&&y.last_message&&(0,_.jsx)(`div`,{className:`mb-6`,children:(0,_.jsx)(u,{message:y.last_message,onRetry:()=>P(),showGoBack:!0})}),y&&y.status!==`error`&&(0,_.jsx)(S,{run:y,rewardOutcome:x,setRewardOutcome:C,rewardFeedback:T,setRewardFeedback:D,copyStatus:j,onCopy:async t=>{M(null);try{await navigator.clipboard.writeText(t),M(e(`run.copied`)),setTimeout(()=>M(null),1500)}catch(e){M(e instanceof Error?e.message:String(e))}},onSubmitStep:async e=>{if(!y?.current_layer)return;let t=y.contract.nonce,n=y.previous_proof_hash??y.contract.proof_hash,r={...e,...t?{nonce:t}:{},...n?{proof_hash:n}:{}};try{let e=await p.mutateAsync({uri:y.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)??y.reward_uri;N({...y,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??y.previous_proof_hash,reward_uri:n?i:void 0,history:[...y.history,{layer:y.current_layer,contract:y.contract,solution:r,submitted_at:t,proof_hash:e.proof_hash,server_message:e.message}]})}catch(e){N({...y,updated_at:A(),status:`error`,last_message:e instanceof Error?e.message:String(e)})}},onReward:async()=>{if(!y)return;let t=y.reward_uri??y.current_layer?.uri;if(t)try{let n=await v.mutateAsync({uri:t,outcome:x,feedback:T.trim()||e(`run.reward.defaultFeedback`)});N({...y,updated_at:A(),status:`completed`,last_message:n.results[0]?.feedback??y.last_message})}catch(e){N({...y,updated_at:A(),status:`error`,last_message:e instanceof Error?e.message:String(e)})}},isForwardStepPending:p.isPending,isForwardStartPending:f.isPending,isRewardPending:v.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-CwKUmZK2.js";import{t as n}from"./react-BdWJx0XL.js";import{n as r}from"./useRunSession-BL4aKCjV.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-DLefRYp3.js";import{t as n}from"./react-BdWJx0XL.js";import{n as r}from"./useRunSession-BL4aKCjV.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,4 +1,4 @@
1
- import{r as e}from"./rolldown-runtime-Dw2cE7zH.js";import{a as t,f as n,y as r}from"./vendor-CwKUmZK2.js";import{i,t as a}from"./react-BdWJx0XL.js";import{t as o}from"./SurfaceCard-BBbNWQYu.js";import{i as s,n as c}from"./useProtocol-CN2rdtdQ.js";import{t as l}from"./RichTextEditor-MeDG49aR.js";var u=e(i(),1),d=a();function f(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 p(){let{t:e}=r(),{uri:i}=n(),{data:a,isLoading:p,isError:m,error:h}=s(i?decodeURIComponent(i):void 0,!0),[g,_]=(0,u.useState)(``),[v,y]=(0,u.useState)(``),[b,x]=(0,u.useState)(``),[S,C]=(0,u.useState)(!0);if(p&&!a)return(0,d.jsx)(`p`,{className:`text-[var(--color-text-muted)]`,children:e(`protocol.loading`)});if(m||!a)return(0,d.jsxs)(`div`,{role:`alert`,className:`rounded-[var(--radius-md)] bg-[var(--color-error-bg)] p-4 text-[var(--color-error)]`,children:[h instanceof Error?h.message:e(`protocol.notFound`),(0,d.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:w}=c(a.markdown_doc),T=g.trim()||w,E=T.replace(/[^a-zA-Z0-9]+/g,`-`).replace(/^-|-$/g,``)||`skill`,D=`${E}-skill`,O=()=>{let e=S?`
1
+ import{r as e}from"./rolldown-runtime-Dw2cE7zH.js";import{a as t,f as n,y as r}from"./vendor-DLefRYp3.js";import{i,t as a}from"./react-BdWJx0XL.js";import{t as o}from"./SurfaceCard-BBbNWQYu.js";import{i as s,n as c}from"./useProtocol-DMe_p3jp.js";import{t as l}from"./RichTextEditor-CpNxz2Fi.js";var u=e(i(),1),d=a();function f(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 p(){let{t:e}=r(),{uri:i}=n(),{data:a,isLoading:p,isError:m,error:h}=s(i?decodeURIComponent(i):void 0,!0),[g,_]=(0,u.useState)(``),[v,y]=(0,u.useState)(``),[b,x]=(0,u.useState)(``),[S,C]=(0,u.useState)(!0);if(p&&!a)return(0,d.jsx)(`p`,{className:`text-[var(--color-text-muted)]`,children:e(`protocol.loading`)});if(m||!a)return(0,d.jsxs)(`div`,{role:`alert`,className:`rounded-[var(--radius-md)] bg-[var(--color-error-bg)] p-4 text-[var(--color-error)]`,children:[h instanceof Error?h.message:e(`protocol.notFound`),(0,d.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:w}=c(a.markdown_doc),T=g.trim()||w,E=T.replace(/[^a-zA-Z0-9]+/g,`-`).replace(/^-|-$/g,``)||`skill`,D=`${E}-skill`,O=()=>{let e=S?`
2
2
 
3
3
  ## References
4
4
 
@@ -1 +1 @@
1
- import{g as e,y as t}from"./vendor-CwKUmZK2.js";import{t as n}from"./react-BdWJx0XL.js";import{t as r}from"./api-D88c6lbH.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={}){return e({queryKey:[`spaces`,{includeAdapterTitles:n.includeAdapterTitles??!1}],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-DLefRYp3.js";import{t as n}from"./react-BdWJx0XL.js";import{t as r}from"./api-D88c6lbH.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={}){return e({queryKey:[`spaces`,{includeAdapterTitles:n.includeAdapterTitles??!1}],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{n as e,r as t}from"./vendor-CwKUmZK2.js";import{t as n}from"./react-BdWJx0XL.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,o=a!==void 0&&a===t;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 ${o?`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-DLefRYp3.js";import{t as n}from"./react-BdWJx0XL.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,o=a!==void 0&&a===t;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 ${o?`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,8 +1,8 @@
1
- const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/HomePage-DHaSrH_k.js","assets/vendor-CwKUmZK2.js","assets/rolldown-runtime-Dw2cE7zH.js","assets/tiptap-DcbFCWb9.js","assets/react-BdWJx0XL.js","assets/SpaceSelect-D8dsuZ8v.js","assets/api-D88c6lbH.js","assets/SurfaceCard-BBbNWQYu.js","assets/KairosPage-D3vTZLht.js","assets/ErrorAlert-CEK6Hts_.js","assets/RunsPage-D8QLy4VF.js","assets/useRunSession-BL4aKCjV.js","assets/ProtocolEditPage-DBf4NQGA.js","assets/ChallengeCard-Coecs--0.js","assets/RichTextEditor-MeDG49aR.js","assets/useProtocol-CN2rdtdQ.js","assets/RunGuidedPage-QZ-FTCqP.js","assets/StepFlowGraph-DjRbEg_P.js","assets/SkillBundlePage-CiQ_FPd0.js","assets/ProtocolDetailPage-CbEkCdWc.js","assets/AccountPage-0lWmC1Yi.js","assets/NotFoundPage-DTGI5qLn.js"])))=>i.map(i=>d[i]);
2
- import{r as e}from"./rolldown-runtime-Dw2cE7zH.js";import{_ as t,b as n,c as r,i,l as a,m as o,o as s,s as c,u as l,v as u,x as d,y as f}from"./vendor-CwKUmZK2.js";import{i as p,n as m,t as h}from"./react-BdWJx0XL.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),e.crossOrigin===`use-credentials`?t.credentials=`include`:e.crossOrigin===`anonymous`?t.credentials=`omit`:t.credentials=`same-origin`,t}function n(e){if(e.ep)return;e.ep=!0;let n=t(e);fetch(e.href,n)}})();var g=`Skip to main content`,_={"nav.home":`Home`,"nav.kairos":`Browse`,"nav.create":`Create`,"nav.runs":`Test Run`,"nav.account":`Account`,"layout.kairosVersion":`KAIROS v{{version}}`,skipToMain:g,"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.kairosApp":`—`,"home.stats.kairosAppLabel":`Kairos 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":`.`,"kairos.title":`Browse`,"kairos.searchLabel":`Activation query`,"kairos.searchPlaceholder":`e.g. deploy and test`,"kairos.searchHint":`Search or browse by label. The default view lists protocols by their label.`,"kairos.searchHintShort":`Run an activation query to rank the best matches, or browse the list below.`,"kairos.browseByLabel":`Browse by label`,"kairos.browseByLetterHint":`Click a letter to list protocols whose title starts with that letter (A–Z).`,"kairos.letterCount":`Letter {{letter}}, {{count}} protocols`,"kairos.labelsStartingWith":`Labels starting with {{letter}}`,"kairos.noLabelsForLetter":`No protocols starting with this letter.`,"kairos.browseFlatListHint":`Protocols listed by label. This is the default view when you open Browse.`,"kairos.browseEmpty":`No protocols found in your spaces yet.`,"kairos.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`,"kairos.scopeSpaceLabel":`Limit search to a space`,"kairos.spaceLabel":`Space`,"kairos.search":`Activate`,"kairos.loading":`Activating…`,"kairos.empty":`No matching protocols found`,"kairos.foundMatches":`Found {{count}} activation choices (top confidence: {{top}}%). View one, refine the query, or create a new protocol.`,"kairos.resultsLabel":`Activation results`,"kairos.score":`Score`,"kairos.version":`Version`,"kairos.tagsLabel":`Tags`,"kairos.refineMeta":`Refine query`,"kairos.createMeta":`Start from scratch`,"kairos.view":`View`,"kairos.viewProtocol":`View {{title}}`,"kairos.refineSearch":`Refine query`,"kairos.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":`Natural language triggers`,"protocol.completion":`Completion rule`,"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":`Natural language triggers`,"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":`Completion rule`,"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-U88uxI09.js","assets/vendor-DLefRYp3.js","assets/rolldown-runtime-Dw2cE7zH.js","assets/tiptap-VSnrfrI4.js","assets/react-BdWJx0XL.js","assets/SpaceSelect-C_bHSva4.js","assets/api-D88c6lbH.js","assets/SurfaceCard-BBbNWQYu.js","assets/KairosPage-B8Bgfpqu.js","assets/ErrorAlert-xId7zQnR.js","assets/RunsPage-1wzJYbQQ.js","assets/useRunSession-BL4aKCjV.js","assets/ProtocolEditPage-DP9Sk1Fh.js","assets/ChallengeCard-Coecs--0.js","assets/RichTextEditor-CpNxz2Fi.js","assets/useProtocol-DMe_p3jp.js","assets/RunGuidedPage-BVCMdEbN.js","assets/StepFlowGraph-BEV34aU4.js","assets/SkillBundlePage-Bqzg9lj8.js","assets/ProtocolDetailPage-DkzLwH8_.js","assets/AccountPage-Bin0OWw2.js","assets/NotFoundPage-CSfAllV_.js"])))=>i.map(i=>d[i]);
2
+ import{r as e}from"./rolldown-runtime-Dw2cE7zH.js";import{_ as t,b as n,c as r,i,l as a,m as o,o as s,s as c,u as l,v as u,x as d,y as f}from"./vendor-DLefRYp3.js";import{i as p,n as m,t as h}from"./react-BdWJx0XL.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),e.crossOrigin===`use-credentials`?t.credentials=`include`:e.crossOrigin===`anonymous`?t.credentials=`omit`:t.credentials=`same-origin`,t}function n(e){if(e.ep)return;e.ep=!0;let n=t(e);fetch(e.href,n)}})();var g=`Skip to main content`,_={"nav.home":`Home`,"nav.kairos":`Browse`,"nav.create":`Create`,"nav.runs":`Test Run`,"nav.account":`Account`,"layout.kairosVersion":`KAIROS v{{version}}`,skipToMain:g,"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.kairosApp":`—`,"home.stats.kairosAppLabel":`Kairos 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":`.`,"kairos.title":`Browse`,"kairos.searchLabel":`Activation query`,"kairos.searchPlaceholder":`e.g. deploy and test`,"kairos.searchHint":`Search or browse by label. The default view lists protocols by their label.`,"kairos.searchHintShort":`Run an activation query to rank the best matches, or browse the list below.`,"kairos.browseByLabel":`Browse by label`,"kairos.browseByLetterHint":`Click a letter to list protocols whose title starts with that letter (A–Z).`,"kairos.letterCount":`Letter {{letter}}, {{count}} protocols`,"kairos.labelsStartingWith":`Labels starting with {{letter}}`,"kairos.noLabelsForLetter":`No protocols starting with this letter.`,"kairos.browseFlatListHint":`Protocols listed by label. This is the default view when you open Browse.`,"kairos.browseEmpty":`No protocols found in your spaces yet.`,"kairos.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`,"kairos.scopeSpaceLabel":`Limit search to a space`,"kairos.spaceLabel":`Space`,"kairos.search":`Activate`,"kairos.loading":`Activating…`,"kairos.empty":`No matching protocols found`,"kairos.foundMatches":`Found {{count}} activation choices (top confidence: {{top}}%). View one, refine the query, or create a new protocol.`,"kairos.resultsLabel":`Activation results`,"kairos.score":`Score`,"kairos.version":`Version`,"kairos.tagsLabel":`Tags`,"kairos.refineMeta":`Refine query`,"kairos.createMeta":`Start from scratch`,"kairos.view":`View`,"kairos.viewProtocol":`View {{title}}`,"kairos.refineSearch":`Refine query`,"kairos.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":`Natural language triggers`,"protocol.completion":`Completion rule`,"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":`Natural language triggers`,"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":`Completion rule`,"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
  ## Natural language triggers
5
5
  ...
6
6
 
7
7
  ## Step 1
8
- ...`,"protocolEdit.contentHint":`Include: Natural language triggers (first H2), steps (H2 + optional challenge block), Completion rule (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":`kairos://adapter/{uuid}`,"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 kairos://adapter/{uuid} 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 KAIROS 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`};d.use(n).init({lng:`en`,fallbackLng:`en`,ns:[`translation`],defaultNS:`translation`,resources:{en:{translation:_}},interpolation:{escapeValue:!1}});var v=e(p(),1),y=m(),b=`/ui/assets/kaiiros-mcp-BmYVdCL6.svg`,x=h(),S=e=>e.startsWith(`/protocols`)||e.startsWith(`/runs`);function C(){let{t:e}=f(),t=l().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=S(t)?`min(100%, var(--layout-main-max), var(--layout-main-wide))`:`min(100%, var(--layout-main-max), var(--layout-main-narrow))`;return(0,x.jsxs)(x.Fragment,{children:[(0,x.jsx)(`a`,{href:`#main`,className:`skip-link`,children:e(`skipToMain`)}),(0,x.jsxs)(`div`,{className:`flex min-h-screen`,children:[(0,x.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,x.jsx)(`div`,{className:`px-4 pb-4`,children:(0,x.jsxs)(s,{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,x.jsx)(`img`,{src:b,alt:``,className:`h-10 w-10 flex-shrink-0 rounded-lg object-contain`,width:`40`,height:`40`}),(0,x.jsxs)(`span`,{className:`flex flex-col leading-tight`,children:[(0,x.jsx)(`span`,{className:`font-bold text-[var(--color-text-heading)] text-lg`,children:`Kairos`}),(0,x.jsx)(`span`,{className:`font-bold text-[var(--color-text-muted)] text-xs uppercase tracking-wide`,children:`MCP`})]})]})}),(0,x.jsxs)(`nav`,{className:`flex min-h-0 flex-1 flex-col gap-0.5`,children:[(0,x.jsx)(s,{to:`/`,end:!0,"aria-current":t===`/`?`page`:void 0,className:n,children:e(`nav.home`)}),(0,x.jsx)(s,{to:`/kairos`,"aria-current":t===`/kairos`?`page`:void 0,className:n,children:e(`nav.kairos`)}),(0,x.jsx)(s,{to:`/protocols/new`,"aria-current":t===`/protocols/new`?`page`:void 0,className:n,children:e(`nav.create`)}),(0,x.jsx)(s,{to:`/runs`,"aria-current":t===`/runs`?`page`:void 0,className:n,children:e(`nav.runs`)}),(0,x.jsx)(s,{to:`/account`,"aria-current":t===`/account`?`page`:void 0,className:n,children:e(`nav.account`)})]}),(0,x.jsx)(`div`,{className:`mt-auto border-t border-[var(--color-border)] px-4 pt-3`,children:(0,x.jsx)(`p`,{className:`m-0 text-xs text-[var(--color-text-muted)]`,children:e(`layout.kairosVersion`,{version:`4.0.0`})})})]}),(0,x.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,x.jsx)(c,{})})]})]})}var w=(0,v.lazy)(()=>o(()=>import(`./HomePage-DHaSrH_k.js`).then(e=>({default:e.HomePage})),__vite__mapDeps([0,1,2,3,4,5,6,7]))),T=(0,v.lazy)(()=>o(()=>import(`./KairosPage-D3vTZLht.js`).then(e=>({default:e.KairosPage})),__vite__mapDeps([8,2,1,3,4,9,5,6]))),E=(0,v.lazy)(()=>o(()=>import(`./RunsPage-D8QLy4VF.js`).then(e=>({default:e.RunsPage})),__vite__mapDeps([10,1,2,3,4,11]))),D=(0,v.lazy)(()=>o(()=>import(`./ProtocolEditPage-DBf4NQGA.js`).then(e=>({default:e.ProtocolEditPage})),__vite__mapDeps([12,2,1,3,4,13,14,5,6,7,15]))),O=(0,v.lazy)(()=>o(()=>import(`./RunGuidedPage-QZ-FTCqP.js`).then(e=>({default:e.RunGuidedPage})),__vite__mapDeps([16,2,1,3,4,13,9,17,7,11,6]))),k=(0,v.lazy)(()=>o(()=>import(`./SkillBundlePage-CiQ_FPd0.js`).then(e=>({default:e.SkillBundlePage})),__vite__mapDeps([18,2,1,3,4,14,7,15,6]))),A=(0,v.lazy)(()=>o(()=>import(`./ProtocolDetailPage-CbEkCdWc.js`).then(e=>({default:e.ProtocolDetailPage})),__vite__mapDeps([19,2,1,3,4,13,17,7,15,6]))),j=(0,v.lazy)(()=>o(()=>import(`./AccountPage-0lWmC1Yi.js`).then(e=>({default:e.AccountPage})),__vite__mapDeps([20,1,2,3,4,6]))),M=(0,v.lazy)(()=>o(()=>import(`./NotFoundPage-DTGI5qLn.js`).then(e=>({default:e.NotFoundPage})),__vite__mapDeps([21,1,2,3,4,9])));function N(){return(0,x.jsx)(`div`,{className:`flex min-h-[12rem] items-center justify-center text-[var(--color-text-muted)]`,"aria-busy":`true`,children:`Loading…`})}function P(){return(0,x.jsx)(a,{children:(0,x.jsxs)(r,{path:`/`,element:(0,x.jsx)(C,{}),children:[(0,x.jsx)(r,{index:!0,element:(0,x.jsx)(v.Suspense,{fallback:(0,x.jsx)(N,{}),children:(0,x.jsx)(w,{})})}),(0,x.jsx)(r,{path:`kairos`,element:(0,x.jsx)(v.Suspense,{fallback:(0,x.jsx)(N,{}),children:(0,x.jsx)(T,{})})}),(0,x.jsx)(r,{path:`runs`,element:(0,x.jsx)(v.Suspense,{fallback:(0,x.jsx)(N,{}),children:(0,x.jsx)(E,{})})}),(0,x.jsx)(r,{path:`protocols/new`,element:(0,x.jsx)(v.Suspense,{fallback:(0,x.jsx)(N,{}),children:(0,x.jsx)(D,{})})}),(0,x.jsx)(r,{path:`protocols/:uri/edit`,element:(0,x.jsx)(v.Suspense,{fallback:(0,x.jsx)(N,{}),children:(0,x.jsx)(D,{})})}),(0,x.jsx)(r,{path:`protocols/:uri/run`,element:(0,x.jsx)(v.Suspense,{fallback:(0,x.jsx)(N,{}),children:(0,x.jsx)(O,{})})}),(0,x.jsx)(r,{path:`protocols/:uri/skill`,element:(0,x.jsx)(v.Suspense,{fallback:(0,x.jsx)(N,{}),children:(0,x.jsx)(k,{})})}),(0,x.jsx)(r,{path:`protocols/:uri`,element:(0,x.jsx)(v.Suspense,{fallback:(0,x.jsx)(N,{}),children:(0,x.jsx)(A,{})})}),(0,x.jsx)(r,{path:`account`,element:(0,x.jsx)(v.Suspense,{fallback:(0,x.jsx)(N,{}),children:(0,x.jsx)(j,{})})}),(0,x.jsx)(r,{path:`*`,element:(0,x.jsx)(v.Suspense,{fallback:(0,x.jsx)(N,{}),children:(0,x.jsx)(M,{})})})]})})}function F(){return(0,x.jsx)(i,{basename:`/ui`,children:(0,x.jsx)(P,{})})}var I=[`light`,`dark`],L=`kairos:ui:theme-preference`,R=`(prefers-color-scheme: dark)`,z=`system`;function B(e){return e===null?!1:e===`system`?!0:I.includes(e)}function V(e,t){return e===`system`?t?`dark`:`light`:e}function H(){if(typeof window>`u`)return z;try{let e=window.localStorage.getItem(L);return B(e)?e:z}catch{return z}}function U(){return typeof window>`u`||typeof window.matchMedia!=`function`?!1:window.matchMedia(R).matches}function W(e){if(typeof document>`u`)return;let t=document.documentElement;t.setAttribute(`data-theme`,e),t.style.colorScheme=e===`light`?`light`:`dark`}function G(){let[e,t]=(0,v.useState)(()=>H()),[n,r]=(0,v.useState)(()=>U()),i=(0,v.useMemo)(()=>V(e,n),[e,n]);return(0,v.useEffect)(()=>{W(i)},[i]),(0,v.useEffect)(()=>{if(typeof window>`u`||e!==`system`||typeof window.matchMedia!=`function`)return;let t=window.matchMedia(R);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,v.useEffect)(()=>{if(typeof window>`u`)return;let e=e=>{e.key===`kairos:ui:theme-preference`&&t(B(e.newValue)?e.newValue:z)};return window.addEventListener(`storage`,e),()=>window.removeEventListener(`storage`,e)},[]),{preference:e,effectiveTheme:i,setPreference:(0,v.useCallback)(e=>{if(t(e),!(typeof window>`u`))try{window.localStorage.setItem(L,e)}catch{}},[])}}var K=(0,v.createContext)(null);function q({children:e}){let t=G();return(0,x.jsx)(K.Provider,{value:t,children:e})}function J(){let e=(0,v.useContext)(K);if(!e)throw Error(`useThemePreferenceContext must be used within ThemeProvider`);return e}var Y=new u;(0,y.createRoot)(document.getElementById(`root`)).render((0,x.jsx)(v.StrictMode,{children:(0,x.jsx)(t,{client:Y,children:(0,x.jsx)(q,{children:(0,x.jsx)(F,{})})})}));export{B as n,J as r,I as t};
8
+ ...`,"protocolEdit.contentHint":`Include: Natural language triggers (first H2), steps (H2 + optional challenge block), Completion rule (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":`kairos://adapter/{uuid}`,"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 kairos://adapter/{uuid} 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 KAIROS 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`};d.use(n).init({lng:`en`,fallbackLng:`en`,ns:[`translation`],defaultNS:`translation`,resources:{en:{translation:_}},interpolation:{escapeValue:!1}});var v=e(p(),1),y=m(),b=`/ui/assets/kaiiros-mcp-BmYVdCL6.svg`,x=h(),S=e=>e.startsWith(`/protocols`)||e.startsWith(`/runs`);function C(){let{t:e}=f(),t=l().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=S(t)?`min(100%, var(--layout-main-max), var(--layout-main-wide))`:`min(100%, var(--layout-main-max), var(--layout-main-narrow))`;return(0,x.jsxs)(x.Fragment,{children:[(0,x.jsx)(`a`,{href:`#main`,className:`skip-link`,children:e(`skipToMain`)}),(0,x.jsxs)(`div`,{className:`flex min-h-screen`,children:[(0,x.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,x.jsx)(`div`,{className:`px-4 pb-4`,children:(0,x.jsxs)(s,{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,x.jsx)(`img`,{src:b,alt:``,className:`h-10 w-10 flex-shrink-0 rounded-lg object-contain`,width:`40`,height:`40`}),(0,x.jsxs)(`span`,{className:`flex flex-col leading-tight`,children:[(0,x.jsx)(`span`,{className:`font-bold text-[var(--color-text-heading)] text-lg`,children:`Kairos`}),(0,x.jsx)(`span`,{className:`font-bold text-[var(--color-text-muted)] text-xs uppercase tracking-wide`,children:`MCP`})]})]})}),(0,x.jsxs)(`nav`,{className:`flex min-h-0 flex-1 flex-col gap-0.5`,children:[(0,x.jsx)(s,{to:`/`,end:!0,"aria-current":t===`/`?`page`:void 0,className:n,children:e(`nav.home`)}),(0,x.jsx)(s,{to:`/kairos`,"aria-current":t===`/kairos`?`page`:void 0,className:n,children:e(`nav.kairos`)}),(0,x.jsx)(s,{to:`/protocols/new`,"aria-current":t===`/protocols/new`?`page`:void 0,className:n,children:e(`nav.create`)}),(0,x.jsx)(s,{to:`/runs`,"aria-current":t===`/runs`?`page`:void 0,className:n,children:e(`nav.runs`)}),(0,x.jsx)(s,{to:`/account`,"aria-current":t===`/account`?`page`:void 0,className:n,children:e(`nav.account`)})]}),(0,x.jsx)(`div`,{className:`mt-auto border-t border-[var(--color-border)] px-4 pt-3`,children:(0,x.jsx)(`p`,{className:`m-0 text-xs text-[var(--color-text-muted)]`,children:e(`layout.kairosVersion`,{version:`4.0.1`})})})]}),(0,x.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,x.jsx)(c,{})})]})]})}var w=(0,v.lazy)(()=>o(()=>import(`./HomePage-U88uxI09.js`).then(e=>({default:e.HomePage})),__vite__mapDeps([0,1,2,3,4,5,6,7]))),T=(0,v.lazy)(()=>o(()=>import(`./KairosPage-B8Bgfpqu.js`).then(e=>({default:e.KairosPage})),__vite__mapDeps([8,2,1,3,4,9,5,6]))),E=(0,v.lazy)(()=>o(()=>import(`./RunsPage-1wzJYbQQ.js`).then(e=>({default:e.RunsPage})),__vite__mapDeps([10,1,2,3,4,11]))),D=(0,v.lazy)(()=>o(()=>import(`./ProtocolEditPage-DP9Sk1Fh.js`).then(e=>({default:e.ProtocolEditPage})),__vite__mapDeps([12,2,1,3,4,13,14,5,6,7,15]))),O=(0,v.lazy)(()=>o(()=>import(`./RunGuidedPage-BVCMdEbN.js`).then(e=>({default:e.RunGuidedPage})),__vite__mapDeps([16,2,1,3,4,13,9,17,7,11,6]))),k=(0,v.lazy)(()=>o(()=>import(`./SkillBundlePage-Bqzg9lj8.js`).then(e=>({default:e.SkillBundlePage})),__vite__mapDeps([18,2,1,3,4,14,7,15,6]))),A=(0,v.lazy)(()=>o(()=>import(`./ProtocolDetailPage-DkzLwH8_.js`).then(e=>({default:e.ProtocolDetailPage})),__vite__mapDeps([19,2,1,3,4,13,17,7,15,6]))),j=(0,v.lazy)(()=>o(()=>import(`./AccountPage-Bin0OWw2.js`).then(e=>({default:e.AccountPage})),__vite__mapDeps([20,1,2,3,4,6]))),M=(0,v.lazy)(()=>o(()=>import(`./NotFoundPage-CSfAllV_.js`).then(e=>({default:e.NotFoundPage})),__vite__mapDeps([21,1,2,3,4,9])));function N(){return(0,x.jsx)(`div`,{className:`flex min-h-[12rem] items-center justify-center text-[var(--color-text-muted)]`,"aria-busy":`true`,children:`Loading…`})}function P(){return(0,x.jsx)(a,{children:(0,x.jsxs)(r,{path:`/`,element:(0,x.jsx)(C,{}),children:[(0,x.jsx)(r,{index:!0,element:(0,x.jsx)(v.Suspense,{fallback:(0,x.jsx)(N,{}),children:(0,x.jsx)(w,{})})}),(0,x.jsx)(r,{path:`kairos`,element:(0,x.jsx)(v.Suspense,{fallback:(0,x.jsx)(N,{}),children:(0,x.jsx)(T,{})})}),(0,x.jsx)(r,{path:`runs`,element:(0,x.jsx)(v.Suspense,{fallback:(0,x.jsx)(N,{}),children:(0,x.jsx)(E,{})})}),(0,x.jsx)(r,{path:`protocols/new`,element:(0,x.jsx)(v.Suspense,{fallback:(0,x.jsx)(N,{}),children:(0,x.jsx)(D,{})})}),(0,x.jsx)(r,{path:`protocols/:uri/edit`,element:(0,x.jsx)(v.Suspense,{fallback:(0,x.jsx)(N,{}),children:(0,x.jsx)(D,{})})}),(0,x.jsx)(r,{path:`protocols/:uri/run`,element:(0,x.jsx)(v.Suspense,{fallback:(0,x.jsx)(N,{}),children:(0,x.jsx)(O,{})})}),(0,x.jsx)(r,{path:`protocols/:uri/skill`,element:(0,x.jsx)(v.Suspense,{fallback:(0,x.jsx)(N,{}),children:(0,x.jsx)(k,{})})}),(0,x.jsx)(r,{path:`protocols/:uri`,element:(0,x.jsx)(v.Suspense,{fallback:(0,x.jsx)(N,{}),children:(0,x.jsx)(A,{})})}),(0,x.jsx)(r,{path:`account`,element:(0,x.jsx)(v.Suspense,{fallback:(0,x.jsx)(N,{}),children:(0,x.jsx)(j,{})})}),(0,x.jsx)(r,{path:`*`,element:(0,x.jsx)(v.Suspense,{fallback:(0,x.jsx)(N,{}),children:(0,x.jsx)(M,{})})})]})})}function F(){return(0,x.jsx)(i,{basename:`/ui`,children:(0,x.jsx)(P,{})})}var I=[`light`,`dark`],L=`kairos:ui:theme-preference`,R=`(prefers-color-scheme: dark)`,z=`system`;function B(e){return e===null?!1:e===`system`?!0:I.includes(e)}function V(e,t){return e===`system`?t?`dark`:`light`:e}function H(){if(typeof window>`u`)return z;try{let e=window.localStorage.getItem(L);return B(e)?e:z}catch{return z}}function U(){return typeof window>`u`||typeof window.matchMedia!=`function`?!1:window.matchMedia(R).matches}function W(e){if(typeof document>`u`)return;let t=document.documentElement;t.setAttribute(`data-theme`,e),t.style.colorScheme=e===`light`?`light`:`dark`}function G(){let[e,t]=(0,v.useState)(()=>H()),[n,r]=(0,v.useState)(()=>U()),i=(0,v.useMemo)(()=>V(e,n),[e,n]);return(0,v.useEffect)(()=>{W(i)},[i]),(0,v.useEffect)(()=>{if(typeof window>`u`||e!==`system`||typeof window.matchMedia!=`function`)return;let t=window.matchMedia(R);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,v.useEffect)(()=>{if(typeof window>`u`)return;let e=e=>{e.key===`kairos:ui:theme-preference`&&t(B(e.newValue)?e.newValue:z)};return window.addEventListener(`storage`,e),()=>window.removeEventListener(`storage`,e)},[]),{preference:e,effectiveTheme:i,setPreference:(0,v.useCallback)(e=>{if(t(e),!(typeof window>`u`))try{window.localStorage.setItem(L,e)}catch{}},[])}}var K=(0,v.createContext)(null);function q({children:e}){let t=G();return(0,x.jsx)(K.Provider,{value:t,children:e})}function J(){let e=(0,v.useContext)(K);if(!e)throw Error(`useThemePreferenceContext must be used within ThemeProvider`);return e}var Y=new u;(0,y.createRoot)(document.getElementById(`root`)).render((0,x.jsx)(v.StrictMode,{children:(0,x.jsx)(t,{client:Y,children:(0,x.jsx)(q,{children:(0,x.jsx)(F,{})})})}));export{B as n,J as r,I as t};
@@ -203,9 +203,9 @@ ${e}</tr>
203
203
  `}strong({tokens:e}){return`<strong>${this.parser.parseInline(e)}</strong>`}em({tokens:e}){return`<em>${this.parser.parseInline(e)}</em>`}codespan({text:e}){return`<code>${Pb(e,!0)}</code>`}br(e){return`<br>`}del({tokens:e}){return`<del>${this.parser.parseInline(e)}</del>`}link({href:e,title:t,tokens:n}){let r=this.parser.parseInline(n),i=Fb(e);if(i===null)return r;e=i;let a=`<a href="`+e+`"`;return t&&(a+=` title="`+Pb(t)+`"`),a+=`>`+r+`</a>`,a}image({href:e,title:t,text:n,tokens:r}){r&&(n=this.parser.parseInline(r,this.parser.textRenderer));let i=Fb(e);if(i===null)return Pb(n);e=i;let a=`<img src="${e}" alt="${Pb(n)}"`;return t&&(a+=` title="${Pb(t)}"`),a+=`>`,a}text(e){return`tokens`in e&&e.tokens?this.parser.parseInline(e.tokens):`escaped`in e&&e.escaped?e.text:Pb(e.text)}},Gb=class{strong({text:e}){return e}em({text:e}){return e}codespan({text:e}){return e}del({text:e}){return e}html({text:e}){return e}text({text:e}){return e}link({text:e}){return``+e}image({text:e}){return``+e}br(){return``}checkbox({raw:e}){return e}},Kb=class e{options;renderer;textRenderer;constructor(e){this.options=e||by,this.options.renderer=this.options.renderer||new Wb,this.renderer=this.options.renderer,this.renderer.options=this.options,this.renderer.parser=this,this.textRenderer=new Gb}static parse(t,n){return new e(n).parse(t)}static parseInline(t,n){return new e(n).parseInline(t)}parse(e){let t=``;for(let n=0;n<e.length;n++){let r=e[n];if(this.options.extensions?.renderers?.[r.type]){let e=r,n=this.options.extensions.renderers[e.type].call({parser:this},e);if(n!==!1||![`space`,`hr`,`heading`,`code`,`table`,`blockquote`,`list`,`html`,`def`,`paragraph`,`text`].includes(e.type)){t+=n||``;continue}}let i=r;switch(i.type){case`space`:t+=this.renderer.space(i);break;case`hr`:t+=this.renderer.hr(i);break;case`heading`:t+=this.renderer.heading(i);break;case`code`:t+=this.renderer.code(i);break;case`table`:t+=this.renderer.table(i);break;case`blockquote`:t+=this.renderer.blockquote(i);break;case`list`:t+=this.renderer.list(i);break;case`checkbox`:t+=this.renderer.checkbox(i);break;case`html`:t+=this.renderer.html(i);break;case`def`:t+=this.renderer.def(i);break;case`paragraph`:t+=this.renderer.paragraph(i);break;case`text`:t+=this.renderer.text(i);break;default:{let e=`Token with "`+i.type+`" type was not found.`;if(this.options.silent)return console.error(e),``;throw Error(e)}}}return t}parseInline(e,t=this.renderer){let n=``;for(let r=0;r<e.length;r++){let i=e[r];if(this.options.extensions?.renderers?.[i.type]){let e=this.options.extensions.renderers[i.type].call({parser:this},i);if(e!==!1||![`escape`,`html`,`link`,`image`,`strong`,`em`,`codespan`,`br`,`del`,`text`].includes(i.type)){n+=e||``;continue}}let a=i;switch(a.type){case`escape`:n+=t.text(a);break;case`html`:n+=t.html(a);break;case`link`:n+=t.link(a);break;case`image`:n+=t.image(a);break;case`checkbox`:n+=t.checkbox(a);break;case`strong`:n+=t.strong(a);break;case`em`:n+=t.em(a);break;case`codespan`:n+=t.codespan(a);break;case`br`:n+=t.br(a);break;case`del`:n+=t.del(a);break;case`text`:n+=t.text(a);break;default:{let e=`Token with "`+a.type+`" type was not found.`;if(this.options.silent)return console.error(e),``;throw Error(e)}}}return n}},qb=class{options;block;constructor(e){this.options=e||by}static passThroughHooks=new Set([`preprocess`,`postprocess`,`processAllTokens`,`emStrongMask`]);static passThroughHooksRespectAsync=new Set([`preprocess`,`postprocess`,`processAllTokens`]);preprocess(e){return e}postprocess(e){return e}processAllTokens(e){return e}emStrongMask(e){return e}provideLexer(){return this.block?Ub.lex:Ub.lexInline}provideParser(){return this.block?Kb.parse:Kb.parseInline}},Jb=new class{defaults=yy();options=this.setOptions;parse=this.parseMarkdown(!0);parseInline=this.parseMarkdown(!1);Parser=Kb;Renderer=Wb;TextRenderer=Gb;Lexer=Ub;Tokenizer=Hb;Hooks=qb;constructor(...e){this.use(...e)}walkTokens(e,t){let n=[];for(let r of e)switch(n=n.concat(t.call(this,r)),r.type){case`table`:{let e=r;for(let r of e.header)n=n.concat(this.walkTokens(r.tokens,t));for(let r of e.rows)for(let e of r)n=n.concat(this.walkTokens(e.tokens,t));break}case`list`:{let e=r;n=n.concat(this.walkTokens(e.items,t));break}default:{let e=r;this.defaults.extensions?.childTokens?.[e.type]?this.defaults.extensions.childTokens[e.type].forEach(r=>{let i=e[r].flat(1/0);n=n.concat(this.walkTokens(i,t))}):e.tokens&&(n=n.concat(this.walkTokens(e.tokens,t)))}}return n}use(...e){let t=this.defaults.extensions||{renderers:{},childTokens:{}};return e.forEach(e=>{let n={...e};if(n.async=this.defaults.async||n.async||!1,e.extensions&&(e.extensions.forEach(e=>{if(!e.name)throw Error(`extension name required`);if(`renderer`in e){let n=t.renderers[e.name];n?t.renderers[e.name]=function(...t){let r=e.renderer.apply(this,t);return r===!1&&(r=n.apply(this,t)),r}:t.renderers[e.name]=e.renderer}if(`tokenizer`in e){if(!e.level||e.level!==`block`&&e.level!==`inline`)throw Error(`extension level must be 'block' or 'inline'`);let n=t[e.level];n?n.unshift(e.tokenizer):t[e.level]=[e.tokenizer],e.start&&(e.level===`block`?t.startBlock?t.startBlock.push(e.start):t.startBlock=[e.start]:e.level===`inline`&&(t.startInline?t.startInline.push(e.start):t.startInline=[e.start]))}`childTokens`in e&&e.childTokens&&(t.childTokens[e.name]=e.childTokens)}),n.extensions=t),e.renderer){let t=this.defaults.renderer||new Wb(this.defaults);for(let n in e.renderer){if(!(n in t))throw Error(`renderer '${n}' does not exist`);if([`options`,`parser`].includes(n))continue;let r=n,i=e.renderer[r],a=t[r];t[r]=(...e)=>{let n=i.apply(t,e);return n===!1&&(n=a.apply(t,e)),n||``}}n.renderer=t}if(e.tokenizer){let t=this.defaults.tokenizer||new Hb(this.defaults);for(let n in e.tokenizer){if(!(n in t))throw Error(`tokenizer '${n}' does not exist`);if([`options`,`rules`,`lexer`].includes(n))continue;let r=n,i=e.tokenizer[r],a=t[r];t[r]=(...e)=>{let n=i.apply(t,e);return n===!1&&(n=a.apply(t,e)),n}}n.tokenizer=t}if(e.hooks){let t=this.defaults.hooks||new qb;for(let n in e.hooks){if(!(n in t))throw Error(`hook '${n}' does not exist`);if([`options`,`block`].includes(n))continue;let r=n,i=e.hooks[r],a=t[r];qb.passThroughHooks.has(n)?t[r]=e=>{if(this.defaults.async&&qb.passThroughHooksRespectAsync.has(n))return(async()=>{let n=await i.call(t,e);return a.call(t,n)})();let r=i.call(t,e);return a.call(t,r)}:t[r]=(...e)=>{if(this.defaults.async)return(async()=>{let n=await i.apply(t,e);return n===!1&&(n=await a.apply(t,e)),n})();let n=i.apply(t,e);return n===!1&&(n=a.apply(t,e)),n}}n.hooks=t}if(e.walkTokens){let t=this.defaults.walkTokens,r=e.walkTokens;n.walkTokens=function(e){let n=[];return n.push(r.call(this,e)),t&&(n=n.concat(t.call(this,e))),n}}this.defaults={...this.defaults,...n}}),this}setOptions(e){return this.defaults={...this.defaults,...e},this}lexer(e,t){return Ub.lex(e,t??this.defaults)}parser(e,t){return Kb.parse(e,t??this.defaults)}parseMarkdown(e){return(t,n)=>{let r={...n},i={...this.defaults,...r},a=this.onError(!!i.silent,!!i.async);if(this.defaults.async===!0&&r.async===!1)return a(Error(`marked(): The async option was set to true by an extension. Remove async: false from the parse options object to return a Promise.`));if(typeof t>`u`||t===null)return a(Error(`marked(): input parameter is undefined or null`));if(typeof t!=`string`)return a(Error(`marked(): input parameter is of type `+Object.prototype.toString.call(t)+`, string expected`));if(i.hooks&&(i.hooks.options=i,i.hooks.block=e),i.async)return(async()=>{let n=i.hooks?await i.hooks.preprocess(t):t,r=await(i.hooks?await i.hooks.provideLexer():e?Ub.lex:Ub.lexInline)(n,i),a=i.hooks?await i.hooks.processAllTokens(r):r;i.walkTokens&&await Promise.all(this.walkTokens(a,i.walkTokens));let o=await(i.hooks?await i.hooks.provideParser():e?Kb.parse:Kb.parseInline)(a,i);return i.hooks?await i.hooks.postprocess(o):o})().catch(a);try{i.hooks&&(t=i.hooks.preprocess(t));let n=(i.hooks?i.hooks.provideLexer():e?Ub.lex:Ub.lexInline)(t,i);i.hooks&&(n=i.hooks.processAllTokens(n)),i.walkTokens&&this.walkTokens(n,i.walkTokens);let r=(i.hooks?i.hooks.provideParser():e?Kb.parse:Kb.parseInline)(n,i);return i.hooks&&(r=i.hooks.postprocess(r)),r}catch(e){return a(e)}}}onError(e,t){return n=>{if(n.message+=`
204
204
  Please report this to https://github.com/markedjs/marked.`,e){let e=`<p>An error occurred:</p><pre>`+Pb(n.message+``,!0)+`</pre>`;return t?Promise.resolve(e):e}if(t)return Promise.reject(n);throw n}}};function $(e,t){return Jb.parse(e,t)}$.options=$.setOptions=function(e){return Jb.setOptions(e),$.defaults=Jb.defaults,xy($.defaults),$},$.getDefaults=yy,$.defaults=by,$.use=function(...e){return Jb.use(...e),$.defaults=Jb.defaults,xy($.defaults),$},$.walkTokens=function(e,t){return Jb.walkTokens(e,t)},$.parseInline=Jb.parseInline,$.Parser=Kb,$.parser=Kb.parse,$.Renderer=Wb,$.TextRenderer=Gb,$.Lexer=Ub,$.lexer=Ub.lex,$.Tokenizer=Hb,$.Hooks=qb,$.parse=$,$.options,$.setOptions,$.use,$.walkTokens,$.parseInline,Kb.parse,Ub.lex;function Yb(e,t){let n=t.split(`
205
205
  `).flatMap(e=>[e,``]).map(t=>`${e}${t}`).join(`
206
- `);return n.slice(0,n.length-1)}function Xb(e,t){let n=[];return Array.from(e.keys()).forEach(e=>{(!t||!t.marks||!t.marks.map(e=>e.type).includes(e))&&n.push(e)}),n}function Zb(e,t){let n=[];return Array.from(t.entries()).forEach(([t,r])=>{e.has(t)||n.push({type:t,mark:r})}),n}function Qb(e,t,n,r){let i=!n,a=n&&n.type===`text`&&(!n.marks||n.marks.length===0),o=n&&n.type===`text`&&n.marks&&!r(t,new Map(n.marks.map(e=>[e.type,e]))),s=[];if(i||a||o)if(n&&n.type===`text`&&n.marks){let t=new Map(n.marks.map(e=>[e.type,e]));Array.from(e.keys()).reverse().forEach(e=>{t.has(e)||s.push(e)})}else (i||a)&&s.push(...Array.from(e.keys()).reverse());return s}function $b(e,t){let n=``;return Array.from(e.keys()).reverse().forEach(r=>{let i=t(r,e.get(r));i&&(n=i+n)}),e.clear(),n}function ex(e,t,n){let r=``;return Array.from(e.entries()).forEach(([e,i])=>{let a=n(e,i);a&&(r+=a),t.set(e,i)}),r}function tx(e){let t=(e.raw||e.text||``).match(/^(\s*)[-+*]\s+\[([ xX])\]\s+/);return t?{isTask:!0,checked:t[2].toLowerCase()===`x`,indentLevel:t[1].length}:{isTask:!1,indentLevel:0}}function nx(e,t){return typeof e==`string`?t:`json`}var rx=class{constructor(e){this.baseExtensions=[],this.extensions=[],this.lastParseResult=null,this.markedInstance=e?.marked??$,this.lexer=new this.markedInstance.Lexer,this.indentStyle=e?.indentation?.style??`space`,this.indentSize=e?.indentation?.size??2,this.baseExtensions=e?.extensions||[],e?.markedOptions&&typeof this.markedInstance.setOptions==`function`&&this.markedInstance.setOptions(e.markedOptions),this.registry=new Map,this.nodeTypeRegistry=new Map,e?.extensions&&(this.baseExtensions=e.extensions,jl(e.extensions).forEach(e=>this.registerExtension(e,!1))),this.lexer=new this.markedInstance.Lexer}get instance(){return this.markedInstance}get indentCharacter(){return this.indentStyle===`space`?` `:` `}get indentString(){return this.indentCharacter.repeat(this.indentSize)}hasMarked(){return!!this.markedInstance}registerExtension(e,t=!0){this.extensions.push(e);let n=e.name,r=L(e,`markdownTokenName`)||n,i=L(e,`parseMarkdown`),a=L(e,`renderMarkdown`),o=L(e,`markdownTokenizer`),s=L(e,`markdownOptions`)??null,c={tokenName:r,nodeName:n,parseMarkdown:i,renderMarkdown:a,isIndenting:s?.indentsContent??!1,htmlReopen:s?.htmlReopen,tokenizer:o};if(r&&i){let e=this.registry.get(r)||[];e.push(c),this.registry.set(r,e)}if(a){let e=this.nodeTypeRegistry.get(n)||[];e.push(c),this.nodeTypeRegistry.set(n,e)}o&&this.hasMarked()&&(this.registerTokenizer(o),t&&(this.lexer=new this.markedInstance.Lexer))}registerTokenizer(e){if(!this.hasMarked())return;let{name:t,start:n,level:r=`inline`,tokenize:i}=e,a={inlineTokens:e=>this.lexer.inlineTokens(e),blockTokens:e=>this.lexer.blockTokens(e)},o;o=n?typeof n==`function`?n:e=>e.indexOf(n):e=>{let t=i(e,[],a);return t&&t.raw?e.indexOf(t.raw):-1};let s={name:t,level:r,start:o,tokenizer:(e,n)=>{let r=i(e,n,a);if(r&&r.type)return{...r,type:r.type||t,raw:r.raw||``,tokens:r.tokens||[]}},childTokens:[]};this.markedInstance.use({extensions:[s]})}getHandlersForToken(e){try{return this.registry.get(e)||[]}catch{return[]}}getHandlerForToken(e){let t=this.getHandlersForToken(e);if(t.length>0)return t[0];let n=this.getHandlersForNodeType(e);return n.length>0?n[0]:void 0}getHandlersForNodeType(e){try{return this.nodeTypeRegistry.get(e)||[]}catch{return[]}}serialize(e){if(!e)return``;let t=this.renderNodes(e,e);return this.isEmptyOutput(t)?``:t}isEmptyOutput(e){return!e||e.trim()===``?!0:e.replace(/&nbsp;/g,``).replace(/\u00A0/g,``).trim()===``}parse(e){if(!this.hasMarked())throw Error(`No marked instance available for parsing`);let t=this.markedInstance.lexer(e);return{type:`doc`,content:this.parseTokens(t,!0)}}parseTokens(e,t=!1){let n=e.reduce((e,t,n)=>(t.type!==`space`&&e.push(n),e),[]),r=-1,i=0;return e.flatMap((e,a)=>{for(;i<n.length&&n[i]<a;)r=n[i],i+=1;if(t&&e.type===`space`){let t=n[i]??-1;return this.createImplicitEmptyParagraphsFromSpace(e,r,t)}let o=this.parseToken(e,t);return o===null?[]:Array.isArray(o)?o:[o]})}createImplicitEmptyParagraphsFromSpace(e,t,n){let r=this.countParagraphSeparators(e.raw||``);if(r===0)return[];let i=Math.max(r-(t===-1||n===-1?0:1),0);return Array.from({length:i},()=>({type:`paragraph`,content:[]}))}countParagraphSeparators(e){return(e.replace(/\r\n/g,`
206
+ `);return n.slice(0,n.length-1)}function Xb(e,t){let n=[];return Array.from(e.keys()).forEach(e=>{(!t||!t.marks||!t.marks.map(e=>e.type).includes(e))&&n.push(e)}),n}function Zb(e,t){let n=[];return Array.from(t.entries()).forEach(([t,r])=>{e.has(t)||n.push({type:t,mark:r})}),n}function Qb(e,t,n,r){let i=!n,a=n&&n.type===`text`&&(!n.marks||n.marks.length===0),o=n&&n.type===`text`&&n.marks&&!r(t,new Map(n.marks.map(e=>[e.type,e]))),s=[];if(i||a||o)if(n&&n.type===`text`&&n.marks){let t=new Map(n.marks.map(e=>[e.type,e]));Array.from(e.keys()).reverse().forEach(e=>{t.has(e)||s.push(e)})}else (i||a)&&s.push(...Array.from(e.keys()).reverse());return s}function $b(e,t){let n=``;return Array.from(e.keys()).reverse().forEach(r=>{let i=t(r,e.get(r));i&&(n=i+n)}),e.clear(),n}function ex(e,t,n){let r=``;return Array.from(e.entries()).forEach(([e,i])=>{let a=n(e,i);a&&(r+=a),t.set(e,i)}),r}function tx(e){let t=(e.raw||e.text||``).match(/^(\s*)[-+*]\s+\[([ xX])\]\s+/);return t?{isTask:!0,checked:t[2].toLowerCase()===`x`,indentLevel:t[1].length}:{isTask:!1,indentLevel:0}}function nx(e,t){return typeof e==`string`?t:`json`}var rx=class{constructor(e){this.activeParseLexer=null,this.baseExtensions=[],this.extensions=[],this.lastParseResult=null,this.markedInstance=e?.marked??$,this.indentStyle=e?.indentation?.style??`space`,this.indentSize=e?.indentation?.size??2,this.baseExtensions=e?.extensions||[],e?.markedOptions&&typeof this.markedInstance.setOptions==`function`&&this.markedInstance.setOptions(e.markedOptions),this.registry=new Map,this.nodeTypeRegistry=new Map,e?.extensions&&(this.baseExtensions=e.extensions,jl(e.extensions).forEach(e=>this.registerExtension(e)))}get instance(){return this.markedInstance}get indentCharacter(){return this.indentStyle===`space`?` `:` `}get indentString(){return this.indentCharacter.repeat(this.indentSize)}hasMarked(){return!!this.markedInstance}registerExtension(e){this.extensions.push(e);let t=e.name,n=L(e,`markdownTokenName`)||t,r=L(e,`parseMarkdown`),i=L(e,`renderMarkdown`),a=L(e,`markdownTokenizer`),o=L(e,`markdownOptions`)??null,s={tokenName:n,nodeName:t,parseMarkdown:r,renderMarkdown:i,isIndenting:o?.indentsContent??!1,htmlReopen:o?.htmlReopen,tokenizer:a};if(n&&r){let e=this.registry.get(n)||[];e.push(s),this.registry.set(n,e)}if(i){let e=this.nodeTypeRegistry.get(t)||[];e.push(s),this.nodeTypeRegistry.set(t,e)}a&&this.hasMarked()&&this.registerTokenizer(a)}createLexer(){return new this.markedInstance.Lexer}createTokenizerHelpers(e){return{inlineTokens:t=>e.inlineTokens(t),blockTokens:t=>e.blockTokens(t)}}tokenizeInline(e){return(this.activeParseLexer??this.createLexer()).inlineTokens(e)}registerTokenizer(e){if(!this.hasMarked())return;let{name:t,start:n,level:r=`inline`,tokenize:i}=e,a=this.createTokenizerHelpers.bind(this),o=this.createLexer.bind(this),s;s=n?typeof n==`function`?n:e=>e.indexOf(n):e=>{let t=i(e,[],this.createTokenizerHelpers(this.createLexer()));return t&&t.raw?e.indexOf(t.raw):-1};let c={name:t,level:r,start:s,tokenizer(e,n){let r=i(e,n,this.lexer?a(this.lexer):a(o()));if(r&&r.type)return{...r,type:r.type||t,raw:r.raw||``,tokens:r.tokens||[]}},childTokens:[]};this.markedInstance.use({extensions:[c]})}getHandlersForToken(e){try{return this.registry.get(e)||[]}catch{return[]}}getHandlerForToken(e){let t=this.getHandlersForToken(e);if(t.length>0)return t[0];let n=this.getHandlersForNodeType(e);return n.length>0?n[0]:void 0}getHandlersForNodeType(e){try{return this.nodeTypeRegistry.get(e)||[]}catch{return[]}}serialize(e){if(!e)return``;let t=this.renderNodes(e,e);return this.isEmptyOutput(t)?``:t}isEmptyOutput(e){return!e||e.trim()===``?!0:e.replace(/&nbsp;/g,``).replace(/\u00A0/g,``).trim()===``}parse(e){if(!this.hasMarked())throw Error(`No marked instance available for parsing`);let t=this.activeParseLexer,n=this.createLexer();this.activeParseLexer=n;try{let t=n.lex(e);return{type:`doc`,content:this.parseTokens(t,!0)}}finally{this.activeParseLexer=t}}parseTokens(e,t=!1){let n=e.reduce((e,t,n)=>(t.type!==`space`&&e.push(n),e),[]),r=-1,i=0;return e.flatMap((e,a)=>{for(;i<n.length&&n[i]<a;)r=n[i],i+=1;if(t&&e.type===`space`){let t=n[i]??-1;return this.createImplicitEmptyParagraphsFromSpace(e,r,t)}let o=this.parseToken(e,t);return o===null?[]:Array.isArray(o)?o:[o]})}createImplicitEmptyParagraphsFromSpace(e,t,n){let r=this.countParagraphSeparators(e.raw||``);if(r===0)return[];let i=Math.max(r-(t===-1||n===-1?0:1),0);return Array.from({length:i},()=>({type:`paragraph`,content:[]}))}countParagraphSeparators(e){return(e.replace(/\r\n/g,`
207
207
  `).match(/\n\n/g)||[]).length}parseToken(e,t=!1){if(!e.type)return null;if(e.type===`list`)return this.parseListToken(e);let n=this.getHandlersForToken(e.type),r=this.createParseHelpers();if(n.find(t=>{if(!t.parseMarkdown)return!1;let n=t.parseMarkdown(e,r),i=this.normalizeParseResult(n);return i&&(!Array.isArray(i)||i.length>0)?(this.lastParseResult=i,!0):!1})&&this.lastParseResult){let e=this.lastParseResult;return this.lastParseResult=null,e}return this.parseFallbackToken(e,t)}parseListToken(e){if(!e.items||e.items.length===0)return this.parseTokenWithHandlers(e);let t=e.items.some(e=>tx(e).isTask),n=e.items.some(e=>!tx(e).isTask);if(!t||!n||this.getHandlersForToken(`taskList`).length===0)return this.parseTokenWithHandlers(e);let r=[],i=[],a=null;for(let t=0;t<e.items.length;t+=1){let n=e.items[t],{isTask:o,checked:s,indentLevel:c}=tx(n),l=n;if(o){let e=(n.raw||n.text||``).split(`
208
208
  `),t=e[0].match(/^\s*[-+*]\s+\[([ xX])\]\s+(.*)$/),r=t?t[2]:``,i=[];if(e.length>1&&e.slice(1).join(`
209
209
  `).trim()){let t=e.slice(1),n=t.filter(e=>e.trim());if(n.length>0){let e=Math.min(...n.map(e=>e.length-e.trimStart().length)),r=t.map(t=>t.trim()?t.slice(e):``).join(`
210
210
  `).trim();r&&(i=this.markedInstance.lexer(`${r}
211
- `))}}l={type:`taskItem`,raw:``,mainContent:r,indentLevel:c,checked:s??!1,text:r,tokens:this.lexer.inlineTokens(r),nestedTokens:i}}let u=o?`taskList`:`list`;a===u?i.push(l):(i.length>0&&r.push({type:a,items:i}),i=[l],a=u)}i.length>0&&r.push({type:a,items:i});let o=[];for(let t=0;t<r.length;t+=1){let n=r[t],i={...e,type:n.type,items:n.items},a=this.parseToken(i);a&&(Array.isArray(a)?o.push(...a):o.push(a))}return o.length>0?o:null}parseTokenWithHandlers(e){if(!e.type)return null;let t=this.getHandlersForToken(e.type),n=this.createParseHelpers();if(t.find(t=>{if(!t.parseMarkdown)return!1;let r=t.parseMarkdown(e,n),i=this.normalizeParseResult(r);return i&&(!Array.isArray(i)||i.length>0)?(this.lastParseResult=i,!0):!1})&&this.lastParseResult){let e=this.lastParseResult;return this.lastParseResult=null,e}return this.parseFallbackToken(e)}createParseHelpers(){return{parseInline:e=>this.parseInlineTokens(e),parseChildren:e=>this.parseTokens(e),parseBlockChildren:e=>this.parseTokens(e,!0),createTextNode:(e,t)=>({type:`text`,text:e,marks:t||void 0}),createNode:(e,t,n)=>{let r={type:e,attrs:t||void 0,content:n||void 0};return(!t||Object.keys(t).length===0)&&delete r.attrs,r},applyMark:(e,t,n)=>({mark:e,content:t,attrs:n&&Object.keys(n).length>0?n:void 0})}}escapeRegex(e){return e.replace(/[.*+?^${}()|[\]\\]/g,`\\$&`)}parseInlineTokens(e){let t=[];for(let n=0;n<e.length;n+=1){let r=e[n];if(r.type===`text`)t.push({type:`text`,text:r.text||``});else if(r.type===`html`){let i=(r.raw??r.text??``).toString(),a=/^<\/[\s]*[\w-]+/i.test(i),o=i.match(/^<[\s]*([\w-]+)(\s|>|\/|$)/i);if(!a&&o&&!/\/>$/.test(i)){let r=o[1],a=this.escapeRegex(r),s=RegExp(`^<\\/\\s*${a}\\b`,`i`),c=-1,l=[i];for(let t=n+1;t<e.length;t+=1){let n=e[t],r=(n.raw??n.text??``).toString();if(l.push(r),n.type===`html`&&s.test(r)){c=t;break}}if(c!==-1){let e=l.join(``),r={type:`html`,raw:e,text:e,block:!1},i=this.parseHTMLToken(r);if(i){let e=this.normalizeParseResult(i);Array.isArray(e)?t.push(...e):e&&t.push(e)}n=c;continue}}let s=this.parseHTMLToken(r);if(s){let e=this.normalizeParseResult(s);Array.isArray(e)?t.push(...e):e&&t.push(e)}}else if(r.type){let e=this.getHandlerForToken(r.type);if(e&&e.parseMarkdown){let n=this.createParseHelpers(),i=e.parseMarkdown(r,n);if(this.isMarkResult(i)){let e=this.applyMarkToContent(i.mark,i.content,i.attrs);t.push(...e)}else{let e=this.normalizeParseResult(i);Array.isArray(e)?t.push(...e):e&&t.push(e)}}else r.tokens&&t.push(...this.parseInlineTokens(r.tokens))}}return t}applyMarkToContent(e,t,n){return t.map(t=>{if(t.type===`text`){let r=t.marks||[],i=n?{type:e,attrs:n}:{type:e};return{...t,marks:[...r,i]}}return{...t,content:t.content?this.applyMarkToContent(e,t.content,n):void 0}})}isMarkResult(e){return e&&typeof e==`object`&&`mark`in e}normalizeParseResult(e){return e?this.isMarkResult(e)?e.content:e:null}parseFallbackToken(e,t=!1){switch(e.type){case`paragraph`:return{type:`paragraph`,content:e.tokens?this.parseInlineTokens(e.tokens):[]};case`heading`:return{type:`heading`,attrs:{level:e.depth||1},content:e.tokens?this.parseInlineTokens(e.tokens):[]};case`text`:return{type:`text`,text:e.text||``};case`html`:return this.parseHTMLToken(e);case`space`:return null;default:return e.tokens?this.parseTokens(e.tokens,t):null}}parseHTMLToken(e){let t=e.text||e.raw||``;if(!t.trim())return null;if(typeof window>`u`)return e.block?{type:`paragraph`,content:[{type:`text`,text:t}]}:{type:`text`,text:t};try{let n=Yl(t,this.baseExtensions);return n.type===`doc`&&n.content?e.block?n.content:n.content.length===1&&n.content[0].type===`paragraph`&&n.content[0].content?n.content[0].content:n.content:n}catch(e){throw Error(`Failed to parse HTML in markdown: ${e}`)}}renderNodeToMarkdown(e,t,n=0,r=0,i={}){if(e.type===`text`)return e.text||``;if(!e.type)return``;let a=this.getHandlerForToken(e.type);if(!a)return``;let o=Array.isArray(t?.content)&&n>0?t.content[n-1]:void 0,s={renderChildren:(t,i)=>{let o=a.isIndenting?r+1:r;return!Array.isArray(t)&&t.content?this.renderNodes(t.content,e,i||``,n,o):this.renderNodes(t,e,i||``,n,o)},renderChild:(t,n)=>{let i=a.isIndenting?r+1:r;return this.renderNodeToMarkdown(t,e,n,i)},indent:e=>this.indentString+e,wrapInBlock:Yb},c={index:n,level:r,parentType:t?.type,previousNode:o,meta:{parentAttrs:t?.attrs,...i}};return a.renderMarkdown?.call(a,e,s,c)||``}renderNodes(e,t,n=``,r=0,i=0){return Array.isArray(e)?this.renderNodesWithMarkBoundaries(e,t,n,i):e.type?this.renderNodeToMarkdown(e,t,r,i):``}renderNodesWithMarkBoundaries(e,t,n=``,r=0){let i=[],a=new Map,o=new Set,s=new Map;return e.forEach((n,c)=>{let l=c<e.length-1?e[c+1]:null;if(n.type)if(n.type===`text`){let e=n.text||``,t=new Map((n.marks||[]).map(e=>[e.type,e])),r=Zb(a,t),c=Xb(t,l),u=c.filter(e=>a.has(e)),d=u.length>0&&r.length>0,f=``;if(c.length>0&&!d){let t=e.match(/(\s+)$/);t&&(f=t[1],e=e.slice(0,-f.length))}d||c.forEach(n=>{if(!a.has(n))return;let r=t.get(n),i=this.getMarkClosing(n,r,s.get(n));i&&(e+=i),a.has(n)&&(a.delete(n),s.delete(n))});let p=``;if(r.length>0){let t=e.match(/^(\s+)/);t&&(p=t[1],e=e.slice(p.length))}r.forEach(({type:t,mark:n})=>{let r=o.has(t)?`html`:`markdown`,i=this.getMarkOpening(t,n,r);i&&(e=i+e),s.set(t,r),o.delete(t)}),d||r.slice().reverse().forEach(({type:e,mark:t})=>{a.set(e,t)}),e=p+e;let m;if(d){let e=new Set((l?.marks||[]).map(e=>e.type));r.forEach(({type:t})=>{e.has(t)&&this.getHtmlReopenTags(t)&&o.add(t)}),m=[...r.map(e=>e.type),...u]}else m=Qb(a,t,l,this.markSetsEqual.bind(this));let h=``;if(m.length>0){let t=e.match(/(\s+)$/);t&&(h=t[1],e=e.slice(0,-h.length))}m.forEach(n=>{let r=a.get(n)??t.get(n),i=this.getMarkClosing(n,r,s.get(n));i&&(e+=i),a.delete(n),s.delete(n)}),e+=h,e+=f,i.push(e)}else{let e=new Map(a),o=new Map(s),l=$b(a,(e,t)=>this.getMarkClosing(e,t,s.get(e)));s.clear();let u=this.renderNodeToMarkdown(n,t,c,r),d=n.type===`hardBreak`?``:ex(e,a,(e,t)=>{let n=o.get(e)??`markdown`;return s.set(e,n),this.getMarkOpening(e,t,n)});i.push(l+u+d)}}),i.join(n)}getMarkOpening(e,t,n=`markdown`){if(n===`html`)return this.getHtmlReopenTags(e)?.open||``;let r=this.getHandlersForNodeType(e),i=r.length>0?r[0]:void 0;if(!i||!i.renderMarkdown)return``;let a=`__TIPTAP_MARKDOWN_PLACEHOLDER__`,o={type:e,attrs:t.attrs||{},content:[{type:`text`,text:a}]};try{let e=i.renderMarkdown(o,{renderChildren:()=>a,renderChild:()=>a,indent:e=>e,wrapInBlock:(e,t)=>e+t},{index:0,level:0,parentType:`text`,meta:{}}),t=e.indexOf(a);return t>=0?e.substring(0,t):``}catch(t){throw Error(`Failed to get mark opening for ${e}: ${t}`)}}getMarkClosing(e,t,n=`markdown`){if(n===`html`)return this.getHtmlReopenTags(e)?.close||``;let r=this.getHandlersForNodeType(e),i=r.length>0?r[0]:void 0;if(!i||!i.renderMarkdown)return``;let a=`__TIPTAP_MARKDOWN_PLACEHOLDER__`,o={type:e,attrs:t.attrs||{},content:[{type:`text`,text:a}]};try{let e=i.renderMarkdown(o,{renderChildren:()=>a,renderChild:()=>a,indent:e=>e,wrapInBlock:(e,t)=>e+t},{index:0,level:0,parentType:`text`,meta:{}}),t=e.indexOf(a),n=t+33;return t>=0?e.substring(n):``}catch(t){throw Error(`Failed to get mark closing for ${e}: ${t}`)}}getHtmlReopenTags(e){let t=this.getHandlersForNodeType(e);return(t.length>0?t[0]:void 0)?.htmlReopen}markSetsEqual(e,t){return e.size===t.size?Array.from(e.keys()).every(e=>t.has(e)):!1}},ix=B.create({name:`markdown`,addOptions(){return{indentation:{style:`space`,size:2},marked:void 0,markedOptions:{}}},addCommands(){return{setContent:(e,t)=>{if(!t?.contentType||nx(e,t?.contentType)!==`markdown`||!this.editor.markdown)return hc.setContent(e,t);let n=this.editor.markdown.parse(e);return hc.setContent(n,t)},insertContent:(e,t)=>{if(!t?.contentType||nx(e,t?.contentType)!==`markdown`||!this.editor.markdown)return hc.insertContent(e,t);let n=this.editor.markdown.parse(e);return hc.insertContent(n,t)},insertContentAt:(e,t,n)=>{if(!n?.contentType||nx(t,n?.contentType)!==`markdown`||!this.editor.markdown)return hc.insertContentAt(e,t,n);let r=this.editor.markdown.parse(t);return hc.insertContentAt(e,r,n)}}},addStorage(){return{manager:new rx({indentation:this.options.indentation,marked:this.options.marked,markedOptions:this.options.markedOptions,extensions:[]})}},onBeforeCreate(){if(this.editor.markdown){console.error("[tiptap][markdown]: There is already a `markdown` property on the editor instance. This might lead to unexpected behavior.");return}if(this.storage.manager=new rx({indentation:this.options.indentation,marked:this.options.marked,markedOptions:this.options.markedOptions,extensions:this.editor.extensionManager.baseExtensions}),this.editor.markdown=this.storage.manager,this.editor.getMarkdown=()=>this.storage.manager.serialize(this.editor.getJSON()),!this.editor.options.contentType||nx(this.editor.options.content,this.editor.options.contentType)!==`markdown`)return;if(!this.editor.markdown)throw Error('[tiptap][markdown]: The `contentType` option is set to "markdown", but the Markdown extension is not added to the editor. Please add the Markdown extension to use this feature.');if(this.editor.options.content===void 0||typeof this.editor.options.content!=`string`)throw Error('[tiptap][markdown]: The `contentType` option is set to "markdown", but the initial content is not a string. Please provide the initial content as a markdown string.');let e=this.editor.markdown.parse(this.editor.options.content);this.editor.options.content=e}});export{ay as a,Jf as c,iy as i,np as l,vy as n,b_ as o,ry as r,Kh as s,ix as t,o as u};
211
+ `))}}l={type:`taskItem`,raw:``,mainContent:r,indentLevel:c,checked:s??!1,text:r,tokens:this.tokenizeInline(r),nestedTokens:i}}let u=o?`taskList`:`list`;a===u?i.push(l):(i.length>0&&r.push({type:a,items:i}),i=[l],a=u)}i.length>0&&r.push({type:a,items:i});let o=[];for(let t=0;t<r.length;t+=1){let n=r[t],i={...e,type:n.type,items:n.items},a=this.parseToken(i);a&&(Array.isArray(a)?o.push(...a):o.push(a))}return o.length>0?o:null}parseTokenWithHandlers(e){if(!e.type)return null;let t=this.getHandlersForToken(e.type),n=this.createParseHelpers();if(t.find(t=>{if(!t.parseMarkdown)return!1;let r=t.parseMarkdown(e,n),i=this.normalizeParseResult(r);return i&&(!Array.isArray(i)||i.length>0)?(this.lastParseResult=i,!0):!1})&&this.lastParseResult){let e=this.lastParseResult;return this.lastParseResult=null,e}return this.parseFallbackToken(e)}createParseHelpers(){return{parseInline:e=>this.parseInlineTokens(e),parseChildren:e=>this.parseTokens(e),parseBlockChildren:e=>this.parseTokens(e,!0),createTextNode:(e,t)=>({type:`text`,text:e,marks:t||void 0}),createNode:(e,t,n)=>{let r={type:e,attrs:t||void 0,content:n||void 0};return(!t||Object.keys(t).length===0)&&delete r.attrs,r},applyMark:(e,t,n)=>({mark:e,content:t,attrs:n&&Object.keys(n).length>0?n:void 0})}}escapeRegex(e){return e.replace(/[.*+?^${}()|[\]\\]/g,`\\$&`)}parseInlineTokens(e){let t=[];for(let n=0;n<e.length;n+=1){let r=e[n];if(r.type===`text`)t.push({type:`text`,text:r.text||``});else if(r.type===`html`){let i=(r.raw??r.text??``).toString(),a=/^<\/[\s]*[\w-]+/i.test(i),o=i.match(/^<[\s]*([\w-]+)(\s|>|\/|$)/i);if(!a&&o&&!/\/>$/.test(i)){let r=o[1],a=this.escapeRegex(r),s=RegExp(`^<\\/\\s*${a}\\b`,`i`),c=-1,l=[i];for(let t=n+1;t<e.length;t+=1){let n=e[t],r=(n.raw??n.text??``).toString();if(l.push(r),n.type===`html`&&s.test(r)){c=t;break}}if(c!==-1){let e=l.join(``),r={type:`html`,raw:e,text:e,block:!1},i=this.parseHTMLToken(r);if(i){let e=this.normalizeParseResult(i);Array.isArray(e)?t.push(...e):e&&t.push(e)}n=c;continue}}let s=this.parseHTMLToken(r);if(s){let e=this.normalizeParseResult(s);Array.isArray(e)?t.push(...e):e&&t.push(e)}}else if(r.type){let e=this.getHandlerForToken(r.type);if(e&&e.parseMarkdown){let n=this.createParseHelpers(),i=e.parseMarkdown(r,n);if(this.isMarkResult(i)){let e=this.applyMarkToContent(i.mark,i.content,i.attrs);t.push(...e)}else{let e=this.normalizeParseResult(i);Array.isArray(e)?t.push(...e):e&&t.push(e)}}else r.tokens&&t.push(...this.parseInlineTokens(r.tokens))}}return t}applyMarkToContent(e,t,n){return t.map(t=>{if(t.type===`text`){let r=t.marks||[],i=n?{type:e,attrs:n}:{type:e};return{...t,marks:[...r,i]}}return{...t,content:t.content?this.applyMarkToContent(e,t.content,n):void 0}})}isMarkResult(e){return e&&typeof e==`object`&&`mark`in e}normalizeParseResult(e){return e?this.isMarkResult(e)?e.content:e:null}parseFallbackToken(e,t=!1){switch(e.type){case`paragraph`:return{type:`paragraph`,content:e.tokens?this.parseInlineTokens(e.tokens):[]};case`heading`:return{type:`heading`,attrs:{level:e.depth||1},content:e.tokens?this.parseInlineTokens(e.tokens):[]};case`text`:return{type:`text`,text:e.text||``};case`html`:return this.parseHTMLToken(e);case`space`:return null;default:return e.tokens?this.parseTokens(e.tokens,t):null}}parseHTMLToken(e){let t=e.text||e.raw||``;if(!t.trim())return null;if(typeof window>`u`)return e.block?{type:`paragraph`,content:[{type:`text`,text:t}]}:{type:`text`,text:t};try{let n=Yl(t,this.baseExtensions);return n.type===`doc`&&n.content?e.block?n.content:n.content.length===1&&n.content[0].type===`paragraph`&&n.content[0].content?n.content[0].content:n.content:n}catch(e){throw Error(`Failed to parse HTML in markdown: ${e}`)}}renderNodeToMarkdown(e,t,n=0,r=0,i={}){if(e.type===`text`)return e.text||``;if(!e.type)return``;let a=this.getHandlerForToken(e.type);if(!a)return``;let o=Array.isArray(t?.content)&&n>0?t.content[n-1]:void 0,s={renderChildren:(t,i)=>{let o=a.isIndenting?r+1:r;return!Array.isArray(t)&&t.content?this.renderNodes(t.content,e,i||``,n,o):this.renderNodes(t,e,i||``,n,o)},renderChild:(t,n)=>{let i=a.isIndenting?r+1:r;return this.renderNodeToMarkdown(t,e,n,i)},indent:e=>this.indentString+e,wrapInBlock:Yb},c={index:n,level:r,parentType:t?.type,previousNode:o,meta:{parentAttrs:t?.attrs,...i}};return a.renderMarkdown?.call(a,e,s,c)||``}renderNodes(e,t,n=``,r=0,i=0){return Array.isArray(e)?this.renderNodesWithMarkBoundaries(e,t,n,i):e.type?this.renderNodeToMarkdown(e,t,r,i):``}renderNodesWithMarkBoundaries(e,t,n=``,r=0){let i=[],a=new Map,o=new Set,s=new Map;return e.forEach((n,c)=>{let l=c<e.length-1?e[c+1]:null;if(n.type)if(n.type===`text`){let e=n.text||``,t=new Map((n.marks||[]).map(e=>[e.type,e])),r=Zb(a,t),c=Xb(t,l),u=c.filter(e=>a.has(e)),d=u.length>0&&r.length>0,f=``;if(c.length>0&&!d){let t=e.match(/(\s+)$/);t&&(f=t[1],e=e.slice(0,-f.length))}d||c.forEach(n=>{if(!a.has(n))return;let r=t.get(n),i=this.getMarkClosing(n,r,s.get(n));i&&(e+=i),a.has(n)&&(a.delete(n),s.delete(n))});let p=``;if(r.length>0){let t=e.match(/^(\s+)/);t&&(p=t[1],e=e.slice(p.length))}r.forEach(({type:t,mark:n})=>{let r=o.has(t)?`html`:`markdown`,i=this.getMarkOpening(t,n,r);i&&(e=i+e),s.set(t,r),o.delete(t)}),d||r.slice().reverse().forEach(({type:e,mark:t})=>{a.set(e,t)}),e=p+e;let m;if(d){let e=new Set((l?.marks||[]).map(e=>e.type));r.forEach(({type:t})=>{e.has(t)&&this.getHtmlReopenTags(t)&&o.add(t)}),m=[...r.map(e=>e.type),...u]}else m=Qb(a,t,l,this.markSetsEqual.bind(this));let h=``;if(m.length>0){let t=e.match(/(\s+)$/);t&&(h=t[1],e=e.slice(0,-h.length))}m.forEach(n=>{let r=a.get(n)??t.get(n),i=this.getMarkClosing(n,r,s.get(n));i&&(e+=i),a.delete(n),s.delete(n)}),e+=h,e+=f,i.push(e)}else{let e=new Map(a),o=new Map(s),l=$b(a,(e,t)=>this.getMarkClosing(e,t,s.get(e)));s.clear();let u=this.renderNodeToMarkdown(n,t,c,r),d=n.type===`hardBreak`?``:ex(e,a,(e,t)=>{let n=o.get(e)??`markdown`;return s.set(e,n),this.getMarkOpening(e,t,n)});i.push(l+u+d)}}),i.join(n)}getMarkOpening(e,t,n=`markdown`){if(n===`html`)return this.getHtmlReopenTags(e)?.open||``;let r=this.getHandlersForNodeType(e),i=r.length>0?r[0]:void 0;if(!i||!i.renderMarkdown)return``;let a=`__TIPTAP_MARKDOWN_PLACEHOLDER__`,o={type:e,attrs:t.attrs||{},content:[{type:`text`,text:a}]};try{let e=i.renderMarkdown(o,{renderChildren:()=>a,renderChild:()=>a,indent:e=>e,wrapInBlock:(e,t)=>e+t},{index:0,level:0,parentType:`text`,meta:{}}),t=e.indexOf(a);return t>=0?e.substring(0,t):``}catch(t){throw Error(`Failed to get mark opening for ${e}: ${t}`)}}getMarkClosing(e,t,n=`markdown`){if(n===`html`)return this.getHtmlReopenTags(e)?.close||``;let r=this.getHandlersForNodeType(e),i=r.length>0?r[0]:void 0;if(!i||!i.renderMarkdown)return``;let a=`__TIPTAP_MARKDOWN_PLACEHOLDER__`,o={type:e,attrs:t.attrs||{},content:[{type:`text`,text:a}]};try{let e=i.renderMarkdown(o,{renderChildren:()=>a,renderChild:()=>a,indent:e=>e,wrapInBlock:(e,t)=>e+t},{index:0,level:0,parentType:`text`,meta:{}}),t=e.indexOf(a),n=t+33;return t>=0?e.substring(n):``}catch(t){throw Error(`Failed to get mark closing for ${e}: ${t}`)}}getHtmlReopenTags(e){let t=this.getHandlersForNodeType(e);return(t.length>0?t[0]:void 0)?.htmlReopen}markSetsEqual(e,t){return e.size===t.size?Array.from(e.keys()).every(e=>t.has(e)):!1}},ix=B.create({name:`markdown`,addOptions(){return{indentation:{style:`space`,size:2},marked:void 0,markedOptions:{}}},addCommands(){return{setContent:(e,t)=>{if(!t?.contentType||nx(e,t?.contentType)!==`markdown`||!this.editor.markdown)return hc.setContent(e,t);let n=this.editor.markdown.parse(e);return hc.setContent(n,t)},insertContent:(e,t)=>{if(!t?.contentType||nx(e,t?.contentType)!==`markdown`||!this.editor.markdown)return hc.insertContent(e,t);let n=this.editor.markdown.parse(e);return hc.insertContent(n,t)},insertContentAt:(e,t,n)=>{if(!n?.contentType||nx(t,n?.contentType)!==`markdown`||!this.editor.markdown)return hc.insertContentAt(e,t,n);let r=this.editor.markdown.parse(t);return hc.insertContentAt(e,r,n)}}},addStorage(){return{manager:new rx({indentation:this.options.indentation,marked:this.options.marked,markedOptions:this.options.markedOptions,extensions:[]})}},onBeforeCreate(){if(this.editor.markdown){console.error("[tiptap][markdown]: There is already a `markdown` property on the editor instance. This might lead to unexpected behavior.");return}if(this.storage.manager=new rx({indentation:this.options.indentation,marked:this.options.marked,markedOptions:this.options.markedOptions,extensions:this.editor.extensionManager.baseExtensions}),this.editor.markdown=this.storage.manager,this.editor.getMarkdown=()=>this.storage.manager.serialize(this.editor.getJSON()),!this.editor.options.contentType||nx(this.editor.options.content,this.editor.options.contentType)!==`markdown`)return;if(!this.editor.markdown)throw Error('[tiptap][markdown]: The `contentType` option is set to "markdown", but the Markdown extension is not added to the editor. Please add the Markdown extension to use this feature.');if(this.editor.options.content===void 0||typeof this.editor.options.content!=`string`)throw Error('[tiptap][markdown]: The `contentType` option is set to "markdown", but the initial content is not a string. Please provide the initial content as a markdown string.');let e=this.editor.markdown.parse(this.editor.options.content);this.editor.options.content=e}});export{ay as a,Jf as c,iy as i,np as l,vy as n,b_ as o,ry as r,Kh as s,ix as t,o as u};
@@ -1,4 +1,4 @@
1
- import{g as e}from"./vendor-CwKUmZK2.js";import{t}from"./api-D88c6lbH.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{markdown_doc: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-DLefRYp3.js";import{t}from"./api-D88c6lbH.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{markdown_doc: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
  `)}export{r as i,i as n,a as r,o as t};