yaml-flow 8.9.2 → 8.11.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 (79) hide show
  1. package/browser/asset-integrity.json +5 -5
  2. package/browser/live-cards.js +15 -15
  3. package/browser/live-cards.schema.json +35 -53
  4. package/browser/server-runtime-controlface.js +4 -4
  5. package/examples/board/cards/card-concentration.json +64 -16
  6. package/examples/board/cards/card-my-identity.json +1 -4
  7. package/examples/board/cards/card-portfolio-intelligence.json +1 -5
  8. package/examples/board/cards/card-rebalance-sim.json +1 -4
  9. package/examples/board/cards/cardT-market-prices.json +1 -4
  10. package/examples/board/cards/cardT-portfolio-value.json +35 -10
  11. package/examples/board/cards/cardT-portfolio.json +1 -4
  12. package/lib/board-live-cards-mcp.cjs +1 -1
  13. package/lib/board-live-cards-mcp.d.cts +0 -2
  14. package/lib/board-live-cards-mcp.d.ts +0 -2
  15. package/lib/board-live-cards-mcp.js +1 -1
  16. package/lib/board-live-cards-node.cjs +2 -2
  17. package/lib/board-live-cards-node.js +1 -1
  18. package/lib/board-live-cards-public.cjs +1 -1
  19. package/lib/board-live-cards-public.js +1 -1
  20. package/lib/board-live-cards-server-runtime.cjs +1 -1
  21. package/lib/board-live-cards-server-runtime.js +1 -1
  22. package/lib/board-livegraph-runtime/index.cjs +1 -1
  23. package/lib/board-livegraph-runtime/index.js +1 -1
  24. package/lib/board-state-reducer.cjs +1 -1
  25. package/lib/board-state-reducer.d.cts +1 -0
  26. package/lib/board-state-reducer.d.ts +1 -0
  27. package/lib/board-state-reducer.js +1 -1
  28. package/lib/card-compute/index.cjs +1 -1
  29. package/lib/card-compute/index.js +1 -1
  30. package/lib/card-validation.cjs +1 -1
  31. package/lib/card-validation.js +1 -1
  32. package/lib/chunk-2LGCYN35.js +2 -0
  33. package/lib/chunk-4LHFO56U.js +3 -0
  34. package/lib/{chunk-BVQISI6G.js → chunk-5U5NMYGT.js} +3 -3
  35. package/lib/chunk-6M3RIGUH.js +2 -0
  36. package/lib/chunk-ATOQP3BD.js +2 -0
  37. package/lib/chunk-CPJXGK2T.cjs +2 -0
  38. package/lib/{chunk-OEL5P7XE.js → chunk-CZ6ZFWFT.js} +2 -2
  39. package/lib/{chunk-7W4QQX7S.cjs → chunk-FFHG3CFU.cjs} +2 -2
  40. package/lib/chunk-GHUW6P4G.cjs +2 -0
  41. package/lib/{chunk-ZA4FS27N.js → chunk-H5FKNSCO.js} +3 -3
  42. package/lib/{chunk-GLKWEPX6.js → chunk-MEL5LKF7.js} +2 -2
  43. package/lib/{chunk-KSKPS6OO.cjs → chunk-NMOUBZXX.cjs} +2 -2
  44. package/lib/{chunk-GTHQJXYW.cjs → chunk-O65MSWUE.cjs} +2 -2
  45. package/lib/chunk-QBEQL4TL.cjs +2 -0
  46. package/lib/chunk-QEHKMLHA.cjs +3 -0
  47. package/lib/chunk-U6JMXOER.cjs +3 -0
  48. package/lib/{chunk-YXKWIPQM.cjs → chunk-VNLMJEIX.cjs} +3 -3
  49. package/lib/{chunk-N5RUH4NG.cjs → chunk-X5CZE2L7.cjs} +3 -3
  50. package/lib/chunk-YT76JNKE.js +3 -0
  51. package/lib/{chunk-7E5NKZIO.js → chunk-ZCU5O2LR.js} +2 -2
  52. package/lib/cloud-storage.cjs +1 -1
  53. package/lib/cloud-storage.js +1 -1
  54. package/lib/continuous-event-graph/index.cjs +1 -1
  55. package/lib/continuous-event-graph/index.js +1 -1
  56. package/lib/firestore-storage/index.cjs +1 -1
  57. package/lib/firestore-storage/index.js +1 -1
  58. package/lib/index.cjs +2 -2
  59. package/lib/index.js +1 -1
  60. package/lib/localstorage-storage/index.cjs +1 -1
  61. package/lib/localstorage-storage/index.js +1 -1
  62. package/lib/server-runtime/index.cjs +1 -1
  63. package/lib/server-runtime/index.js +1 -1
  64. package/lib/server-runtime-controlface/index.cjs +1 -1
  65. package/lib/server-runtime-controlface/index.js +1 -1
  66. package/lib/server-runtime-core/index.cjs +1 -1
  67. package/lib/server-runtime-core/index.js +1 -1
  68. package/package.json +1 -1
  69. package/schema/live-cards.schema.json +35 -53
  70. package/lib/chunk-4VZL3GWU.js +0 -3
  71. package/lib/chunk-CBRVINMT.js +0 -2
  72. package/lib/chunk-E46UCDYN.js +0 -2
  73. package/lib/chunk-IRGTOCEU.cjs +0 -2
  74. package/lib/chunk-JHXRGPL7.cjs +0 -3
  75. package/lib/chunk-M53MX233.js +0 -3
  76. package/lib/chunk-NLC4FN7V.cjs +0 -2
  77. package/lib/chunk-RWAEV253.js +0 -2
  78. package/lib/chunk-UG55PF75.cjs +0 -2
  79. package/lib/chunk-WYKCHXBZ.cjs +0 -3
@@ -1,2 +0,0 @@
1
- import {a}from'./chunk-E46UCDYN.js';function P(s,d){if(s?.status==="success")return Object.prototype.hasOwnProperty.call(s,"data")?s.data:void 0;throw s?.status==="fail"||s?.status==="error"?new Error(s.error||`${d} failed`):new Error(`${d} returned an unexpected response`)}function G(s,d){if(s?.status==="success"&&Object.prototype.hasOwnProperty.call(s,"data"))return s.data;throw s?.status==="success"?new Error(`${d} returned success without data`):s?.status==="fail"||s?.status==="error"?new Error(s.error||`${d} failed`):new Error(`${d} returned an unexpected response`)}function n(s){return s&&typeof s=="object"&&!Array.isArray(s)?s:{}}function y(s){return Array.isArray(s)?s:[]}function N(s,d){if(typeof d!="string"||d.length===0)return;let c=s,p=d;p.startsWith("fetched_sources.")&&(c=n(s).fetched_sources,p=p.slice(16));for(let g of p.split(".")){if(c==null||typeof c!="object")return;c=c[g];}return c}function z(s,d){let c=n(s.view),p=y(c.elements);return {layout:c.layout,features:c.features,elements:p.map((g,h)=>{let R=n(g),b=n(R.data),k=typeof R.visible=="string"?!!N(d,R.visible):true,x=typeof b.bind=="string"?b.bind:void 0,S=typeof b.maxRows=="number"?b.maxRows:void 0,B=x?N(d,x):void 0,q={id:typeof R.id=="string"&&R.id?R.id:`element-${h}`,kind:R.kind,label:R.label,visible:k};return B!==void 0&&(q.resolved=Array.isArray(B)&&typeof S=="number"?B.slice(0,S):B),q})}}function Q(s,d){let c=typeof s.id=="string"&&s.id?s.id:"card",p=y(s.provides),g=p.length>0?p:[{bindTo:c,ref:"card_data"}],h={};for(let R of g){let b=n(R),k=typeof b.bindTo=="string"?b.bindTo:"",x=typeof b.ref=="string"?b.ref:"";if(!k||!x)continue;let S=N(d,x);S!==void 0&&(h[k]=S);}return h}function be(s){if(typeof s!="string"||!s.trim())return null;let d=/^(file uploaded|AI generated|AI geneterated):\s*.*?#(\d+)\s*$/i.exec(s.trim());if(!d)return null;let c=Number.parseInt(d[2],10);return !Number.isInteger(c)||c<0?null:c}function ke(s){return {"card-content":s}}function j(s){let d={...s};return delete d.__private,d}function he(s,d){return Object.prototype.hasOwnProperty.call(s,d)}function Re(s){return typeof structuredClone=="function"?structuredClone(s):JSON.parse(JSON.stringify(s))}function ve(s,d){let c=Re(s);if(!d||Object.keys(d).length===0)return c;function p(g,h,R){let b=String(h||"").split(".").filter(Boolean);if(!b.length)return;let k=g;for(let x=0;x<b.length-1;x+=1){let S=b[x];(!k[S]||typeof k[S]!="object")&&(k[S]={}),k=k[S];}k[b[b.length-1]]=R;}if(d.fieldValues!==void 0&&d.fieldValues!==null){let g=null,h=n(c.view),R=y(h.elements);for(let b of R){let k=n(n(b).data);if(typeof k.writeTo=="string"&&k.writeTo){g=k.writeTo;break}}return g?p(c,g,d.fieldValues):typeof d.fieldValues=="object"&&!Array.isArray(d.fieldValues)&&(c.card_data={...n(c.card_data),...d.fieldValues}),c}if(Array.isArray(d._stagedFiles)&&d._stagedFiles.length>0)return c;for(let[g,h]of Object.entries(d))g!=="_stagedFiles"&&(h!==null&&typeof h=="object"&&!Array.isArray(h)&&c[g]!==null&&typeof c[g]=="object"&&!Array.isArray(c[g])?c[g]={...c[g],...h}:c[g]=h);return c}function D(s){return n(s.__private).visible_controlplane_only===true}async function T(s,d){let c=await A(s.get({params:{id:d}}),"cardStore.get"),p=Array.isArray(c?.cards)?c.cards:[];if(p.length===0)throw new Error(`Card "${d}" not found`);return p[0]}function Ae(s){let{board:d,nonCore:c,cardStore:p,chatStore:g,processAccumulated:h,sourceFetchDone:R,sourceFetchFailed:b,uploadCardFile:k,buildFileDownloadUrl:x,readFetchedSourceJsonByRef:S}=s;function B(e,r){if(typeof e=="function")return e;throw new Error(`${r} is not configured for this MCP facade`)}async function q(){let e=await A(p.get({}),"cardStore.get");return Array.isArray(e.cards)?e.cards.map(r=>n(r)).filter(r=>!D(r)):[]}function X(e){if(Array.isArray(e.bytes))return new Uint8Array(e.bytes.map(r=>Math.max(0,Math.min(255,Number(r)||0))));if(typeof e.text=="string")return new TextEncoder().encode(e.text);if(typeof e.base64=="string"){let r=String(e.base64).replace(/-/g,"+").replace(/_/g,"/"),t=r+"=".repeat((4-r.length%4)%4),a=atob(t);return Uint8Array.from(a,o=>o.charCodeAt(0))}throw new Error("file entry requires bytes, text, or base64")}async function Y(){let e=n(await A(c.describeTaskExecutorCapabilities({}),"describeTaskExecutorCapabilities"));return {version:e.version,commonSourceFields:n(e.commonSourceDefFields),sourceKinds:n(e.sourceKinds)}}async function Z(){let e=n(await A(d.status({}),"status")),r=n(e.summary),t=y(e.cards),a=await A(p.get({}),"cardStore.get"),o=new Set((Array.isArray(a.cards)?a.cards.map(n):[]).filter(D).map(u=>typeof u.id=="string"?u.id:"").filter(Boolean)),i=t.filter(u=>!o.has(String(n(u).name??"")));return {meta:n(e.meta),summary:{card_count:typeof r.card_count=="number"?r.card_count:0,completed:typeof r.completed=="number"?r.completed:0,eligible:typeof r.eligible=="number"?r.eligible:0,pending:typeof r.pending=="number"?r.pending:0,blocked:typeof r.blocked=="number"?r.blocked:0,in_progress:typeof r.in_progress=="number"?r.in_progress:0,failed:typeof r.failed=="number"?r.failed:0,unresolved:typeof r.unresolved=="number"?r.unresolved:0},cards:i.map(u=>{let l=n(u);return {"card-id":typeof l.name=="string"?l.name:null,status:l.status??null,error:l.error??null,requires:y(l.requires),requires_satisfied:y(l.requires_satisfied),requires_missing:y(l.requires_missing),provides_declared:y(l.provides_declared),provides_runtime:y(l.provides_runtime)}})}}async function ee(e){let r=String(e.cardId||"").trim();if(!r)throw new Error("inspectCardDefinitionAndRuntime requires cardId");let t=n(await A(d.status({}),"status")),o=y(t.cards).map(n).find(f=>f.name===r);if(!o)throw new Error(`card "${r}" not found in board status`);let i=n(await T(p,r)),u=j(i),l=y(o.requires_satisfied).filter(f=>typeof f=="string"&&!!f),I=y(o.provides_runtime).filter(f=>typeof f=="string"&&!!f),v=Object.fromEntries(await Promise.all(l.map(async f=>[f,await A(d.getOutputsDataObject({params:{key:f}}),`getOutputsDataObject(${f})`)]))),_=Object.fromEntries(await Promise.all(I.map(async f=>[f,await A(d.getOutputsDataObject({params:{key:f}}),`getOutputsDataObject(${f})`)]))),m=n(await A(d.getOutputsComputedValues({params:{key:r}}),"getOutputsComputedValues")),C=await A(d.getOutputsFetchedSources({params:{key:r}}),"getOutputsFetchedSources"),M=y(i.source_defs).map(n),w={};for(let f of M)typeof f.bindTo=="string"&&typeof f.outputFile=="string"&&(w[f.outputFile]=f.bindTo);let U={};for(let[f,F]of Object.entries(C)){let O=w[f]??f;if(!S||typeof F!="string"){U[O]=null;continue}try{U[O]=S({cardId:r,ref:F});}catch{U[O]=null;}}let L={card_data:n(i.card_data),requires:v,fetched_sources:U,computed_values:m};return {cardId:r,card_status_in_board:o,card_definition_and_static_data:u,refs_for_fetched_source_files:C,runtime_data:{requires:v,provides:_,computed_values:m,rendered_view:z(i,L)}}}async function re(e){let r=String(e.cardId||"").trim();if(!r)throw new Error("inspectChatMessagesOnCards requires cardId");let t=typeof e.turnId=="string"?e.turnId:"",a=e.allTurns===true,o=typeof e.tailTurnsBeforeId=="string"?e.tailTurnsBeforeId:"",i=a?void 0:e.lastUserTurns??(t?void 0:1),u=e.tail,l={...i===void 0?{}:{tailTurns:i},...t?{turnId:t}:{},...a?{allTurns:true}:{},...o?{tailTurnsBeforeId:o}:{}},I=Object.keys(l).length>0?{params:{cardId:r},body:l}:{params:{cardId:r}},v=P(await g.readAll(I),"chatStore.readAll"),_=n(await T(p,r)),m=y(n(_.card_data).files).map((w,U)=>({idx:U,stored_name:n(w).stored_name})).filter(w=>typeof w.stored_name=="string"&&w.stored_name.length>0),M=(Array.isArray(v.records)?v.records:[]).map(w=>{let L=n(w.payload),f={...w},F=typeof w?.role=="string"?w.role:typeof L.role=="string"?String(L.role):"",O=typeof w?.text=="string"?w.text:typeof L.text=="string"?String(L.text):"";if(F==="system"){let V=be(O);if(V!==null&&m.some(E=>E.idx===V)){let E=`Retrieve using inspect-file-contents --card-id ${r} --file-idx ${V}`;f.retrieval_hint=E,Object.keys(L).length>0&&typeof w.role!="string"&&(f.payload={...L,retrieval_hint:E});}}return f});return {cardId:r,messages:typeof u=="number"&&u>=0?M.slice(-u):M}}async function te(e){let r=String(e.cardId||"").trim(),t=Number(e.fileIdx);if(!r)throw new Error("inspectFileContents requires cardId");if(!Number.isInteger(t)||t<0)throw new Error("inspectFileContents requires fileIdx to be a non-negative integer");let a=n(await T(p,r)),o=y(n(a.card_data).files).map(n);if(t>=o.length)throw new Error(`attachment index ${t} is out of range for card "${r}"`);let i=o[t],u=typeof i.stored_name=="string"?i.stored_name:null;return {cardId:r,fileIdx:t,downloadUrl:x({cardId:r,fileIdx:t,storedName:u}),...typeof i.name=="string"?{name:i.name}:{},...typeof i.stored_name=="string"?{stored_name:i.stored_name}:{},...typeof i.mime_type=="string"?{mime_type:i.mime_type}:{},...typeof i.size=="number"?{size:i.size}:{},...typeof i.uploaded_at=="string"?{uploaded_at:i.uploaded_at}:{}}}async function $(e){return await c.validateCardPreflight({body:ke(e.candidateCardContent)})}function ne(e){if(!e.mockRequires||typeof e.mockRequires!="object"||Array.isArray(e.mockRequires))throw new Error("preflightMaterializeCandidateCard requires mockRequires");if(!e.mockFetchedSources||typeof e.mockFetchedSources!="object"||Array.isArray(e.mockFetchedSources))throw new Error("preflightMaterializeCandidateCard requires mockFetchedSources");let r=c.evalCardCompute({body:{"card-content":e.candidateCardContent,"mock-requires":e.mockRequires,"mock-fetched-sources":e.mockFetchedSources}});if(r.status!=="success")return r;let t=n(G(r,"evalCardCompute")),a=n(e.candidateCardContent),o={card_data:n(a.card_data),requires:n(e.mockRequires),fetched_sources:n(e.mockFetchedSources),computed_values:n(t.computed_values)};return {status:"success",data:{cardId:typeof t.cardId=="string"?t.cardId:typeof a.id=="string"?a.id:"(unknown)",ok:t.ok===true,computed_values:n(t.computed_values),errors:y(t.errors).map(i=>{let u=n(i);return {bindTo:typeof u.bindTo=="string"?u.bindTo:"",error:typeof u.error=="string"?u.error:""}}),provides_outputs:Q(a,o),rendered_view:z(a,o)}}}async function ae(e){return await c.probeSourcePreflight({params:{sourceIdx:e.sourceIdx},body:{"card-content":e.candidateCardContent,"mock-projections":e.mockProjections}})}async function oe(e){return await c.runSourcePreflight({params:{sourceIdx:e.sourceIdx},body:{"card-content":e.candidateCardContent,"mock-projections":e.mockProjections}})}async function se(e){let r=String(e.cardId||"").trim();if(!r)throw new Error("preflightRunSingleSourceInLiveCard requires cardId");if(!e.mockRequires||typeof e.mockRequires!="object"||Array.isArray(e.mockRequires))throw new Error("preflightRunSingleSourceInLiveCard requires mockRequires");let t=n(await T(p,r)),a$1=y(t.source_defs).filter(i=>!!i&&typeof i=="object"&&!Array.isArray(i)),o={};if(e.sourceIdx>=0&&e.sourceIdx<a$1.length){let i=a$1[e.sourceIdx],u=a.enrichSourcesSync([i],{card_data:n(t.card_data),requires:e.mockRequires});Array.isArray(u)&&u.length>0&&(o=n(u[0]._projections));}return await c.runSourcePreflight({params:{sourceIdx:e.sourceIdx},body:{"card-content":t,"mock-requires":e.mockRequires,"mock-projections":o}})}async function ie(e){let r=n(await A(c.simulateCardCycle({body:{"card-content":e.candidateCardContent,"mock-requires":e.mockRequires}}),"simulateCardCycle")),t=n(e.candidateCardContent),a=n(r.validation),o=y(r.source_probes),i=y(r.projection_errors),u=n(r.fetched_sources),l=y(r.compute_errors),I=n(r.computed_values),v={card_data:n(t.card_data),requires:e.mockRequires,fetched_sources:u,computed_values:I},_=[];for(let m of y(a.issues))typeof m=="string"&&m&&_.push(m);for(let m of o){let C=n(m),M=typeof C.bindTo=="string"?C.bindTo:"source",w=typeof C.error=="string"?C.error:"";w&&_.push(`${M}: ${w}`);}for(let m of i){let C=n(m),M=typeof C.bindTo=="string"?C.bindTo:"source",w=typeof C.key=="string"?C.key:"projection",U=typeof C.error=="string"?C.error:"projection failed";_.push(`${M}.${w}: ${U}`);}for(let m of l){let C=n(m),M=typeof C.bindTo=="string"?C.bindTo:"compute",w=typeof C.error=="string"?C.error:"compute failed";_.push(`${M}: ${w}`);}return {status:"success",data:{cardId:typeof r.cardId=="string"?r.cardId:"(unknown)",ok:r.ok===true,issues:_,provides_outputs:Q(t,v),rendered_view:z(t,v)}}}async function K(e){let r=String(e.cardId||"").trim();if(!r)throw new Error("manageReadCard requires cardId");let t=await A(p.get({params:{id:r}}),"cardStore.get");return (Array.isArray(t.cards)?t.cards.map(n):[]).map(o=>j(o))}async function W(e){let r=await Promise.all(y(e.files).map(async t=>{let a=n(t),o=String(a.file_name??a.fileName??a.name??"").trim(),i=String(a.content_type??a.contentType??"application/octet-stream");if(!o)throw new Error("file entry requires file_name");return await k({cardId:e.cardId,fileName:o,contentType:i,bytes:X(a),suppressChatRecordWrite:true})}));for(let[t,a]of r.entries()){let o=n(a.file),i=typeof a.file_idx=="number"&&Number.isInteger(a.file_idx)&&a.file_idx>=0?a.file_idx:t,u=e.role==="assistant"?`AI generated: ${String(o.name||"")} as ${String(o.stored_name||"")} #${i}`:`file uploaded: ${String(o.name||"")} as ${String(o.stored_name||"")} #${i}`;P(await g.append({params:{cardId:e.cardId},body:{role:"system",text:u,files:[],turn:e.turn}}),"chatStore.append(system attachment message)");}return r.map(t=>t.file)}async function de(e){let r=String(e.cardId||"").trim(),t=String(e.role||"user").trim()||"user",a=typeof e.turn=="string"?e.turn:"";if(!r)throw new Error("manageAddChatAttachment requires cardId");let o=await W({cardId:r,role:t,turn:a,files:e.files});return {status:"success",data:{cardId:r,turn:a,files:o}}}async function ce(e){let r=String(e.cardId||"").trim(),t=String(e.role||"").trim(),a=typeof e.text=="string"?e.text:"",o=typeof e.turn=="string"?e.turn:"";if(!r)throw new Error("manageAddChatEntryAndAnyAttachments requires cardId");if(!t)throw new Error("manageAddChatEntryAndAnyAttachments requires role");if(t==="assistant"&&o){let l=P(await g.readAll({params:{cardId:r},body:{turnId:o}}),"chatStore.readAll(existing turn messages)"),I=Array.isArray(l.records)?l.records.find(v=>v.role==="assistant"&&String(v.turn||"")===o):void 0;if(I)return {status:"success",data:{cardId:r,id:String(I.id),role:t,turn:o,files:Array.isArray(I.files)?I.files:[]}}}let i=await W({cardId:r,role:t,turn:o,files:e.files}),u=P(await g.append({params:{cardId:r},body:{role:t,text:a,files:i,turn:o}}),"chatStore.append");return {status:"success",data:{cardId:r,id:String(u.id),role:t,turn:o,files:i}}}async function ue(e,r={}){let t=String(e.cardId||"").trim(),a=n(e.patch);if(!t)throw new Error("managePatchCard requires cardId");let o=await K({cardId:t}),i=n(o[0]),u=ve(i,a);return J({cardId:t,candidateCardContent:u},r)}async function J(e,r={}){let t=String(e.cardId||"").trim(),a=n(e.candidateCardContent),o=j(a);if(!t)throw new Error("manageUpsertCard requires cardId");if(typeof o.id!="string"||!o.id.trim())throw new Error("candidateCardContent.id must be a non-empty string");if(o.id!==t)throw new Error(`candidateCardContent.id must match cardId (${t})`);let i=null;try{i=await $({candidateCardContent:o});}catch(m){let C=m instanceof Error?m.message:String(m);if(!/non-core adapter is not configured/i.test(C))throw m;i=null;}if(i!==null){let m=n(i),C=n(m.data);if(m.status!=="success"||C.isValid!==true)return {status:"fail",step:"validate",validation:i}}let u=null;try{u=await T(p,t);}catch{u=null;}let l=u?n(u):null;if(l&&D(l)&&!r.allowControlplaneOnlyCards)throw Object.assign(new Error(`Card "${t}" not found`),{statusCode:404});let I={...o,...l&&he(l,"__private")?{__private:l.__private}:{}},v=await p.set({body:I});P(v,"cardStore.set");let _;try{_=await d.upsertCard({params:{cardId:t,restart:!0}}),P(_,"upsertCard");}catch(m){try{u&&await p.set({body:u});}catch{}throw m}return {status:"success",data:{validation:i,card_saved:null,board_result:_}}}async function le(e,r={}){let t=String(e.cardId||"").trim();if(!t)throw new Error("manageRemoveCard requires cardId");if(!r.allowControlplaneOnlyCards){let i=await A(p.get({params:{id:t}}),"cardStore.get");if((Array.isArray(i.cards)?i.cards.map(n):[]).some(D))throw Object.assign(new Error(`Card "${t}" not found`),{statusCode:404})}let a=await d.removeCard({params:{id:t}});P(a,"removeCard");let o=await p.del({params:{id:t}});return P(o,"cardStore.del"),{status:"success",data:{board_result:a,store_result:o}}}async function pe(e){let r=String(e.cardId||"").trim();if(!r)throw new Error("adminReadCard requires cardId");let t=await A(p.get({params:{id:r}}),"cardStore.get");return Array.isArray(t.cards)?t.cards.map(a=>n(a)):[]}async function me(e){let r=String(e.cardId||"").trim(),t=n(e.candidateCardContent),a=j(t);if(!r)throw new Error("adminUpsertCard requires cardId");if(typeof a.id!="string"||!a.id.trim())throw new Error("candidateCardContent.id must be a non-empty string");if(a.id!==r)throw new Error(`candidateCardContent.id must match cardId (${r})`);let o=await $({candidateCardContent:a}),i=n(o),u=n(i.data);if(i.status!=="success"||u.isValid!==true)return {status:"fail",step:"validate",validation:o};let l=null;try{l=await T(p,r);}catch{l=null;}let I=l?n(n(l).__private):{},v={...a,__private:{...I,visible_controlplane_only:true}},_=await p.set({body:v});P(_,"cardStore.set");let m;try{m=await d.upsertCard({params:{cardId:r,restart:!0}}),P(m,"upsertCard");}catch(C){try{l&&await p.set({body:l});}catch{}throw C}return {status:"success",data:{validation:o,card_saved:null,board_result:m}}}async function fe(e){let r=String(e.cardId||"").trim();if(!r)throw new Error("getChatProcessing requires cardId");let t=G(await g.isProcessing({params:{cardId:r}}),"chatStore.isProcessing");return {cardId:r,active:!!t.active}}async function ge(e){let r=String(e.cardId||"").trim();if(!r)throw new Error("setChatProcessing requires cardId");if(typeof e.active!="boolean")throw new Error("setChatProcessing requires boolean active");return P(await g.setProcessing({params:{cardId:r},body:{active:e.active}}),"chatStore.setProcessing"),{cardId:r,active:e.active}}async function Ce(){let e=await B(h,"webhook.process-accumulated")();return e?.status==="fail"||e?.status==="error"?e:{status:"success",data:{runtime_result:Object.prototype.hasOwnProperty.call(e??{},"data")?e.data??null:null}}}async function we(e){let r=String(e.token||"").trim(),t=String(e.ref||"").trim();if(!r)throw new Error("webhookSourceFetchDone requires token");if(!t)throw new Error("webhookSourceFetchDone requires ref");let a=await B(R,"webhook.source-fetch-done")({token:r,ref:t});return a?.status==="fail"||a?.status==="error"?a:{status:"success",data:{token:r,ref:t,runtime_result:Object.prototype.hasOwnProperty.call(a??{},"data")?a.data??null:null}}}async function ye(e){let r=String(e.token||"").trim(),t=String(e.reason||"").trim();if(!r)throw new Error("webhookSourceFetchFailed requires token");if(!t)throw new Error("webhookSourceFetchFailed requires reason");let a=await B(b,"webhook.source-fetch-failed")({token:r,reason:t});return a?.status==="fail"||a?.status==="error"?a:{status:"success",data:{token:r,reason:t,runtime_result:Object.prototype.hasOwnProperty.call(a??{},"data")?a.data??null:null}}}return {listRuntimeCards:q,discoverSourceKinds:Y,inspectBoardRuntimeStatus:Z,inspectCardDefinitionAndRuntime:ee,inspectChatMessagesOnCards:re,inspectFileContents:te,preflightValidateCandidateCardDefinition:$,preflightMaterializeCandidateCard:ne,preflightProbeSingleSourceInCandidateCard:ae,preflightRunSingleSourceInCandidateCard:oe,preflightRunSingleSourceInLiveCard:se,preflightRunOneCycleWithCandidateCard:ie,manageReadCard:K,manageAddChatAttachment:de,manageAddChatEntryAndAnyAttachments:ce,managePatchCard:ue,manageUpsertCard:J,manageRemoveCard:le,adminReadCard:pe,adminUpsertCard:me,getChatProcessing:fe,setChatProcessing:ge,webhookProcessAccumulated:Ce,webhookSourceFetchDone:we,webhookSourceFetchFailed:ye}}async function A(s,d){return P(await s,d)}export{Ae as a};//# sourceMappingURL=chunk-RWAEV253.js.map
2
- //# sourceMappingURL=chunk-RWAEV253.js.map
@@ -1,2 +0,0 @@
1
- 'use strict';var module$1=require('module');var _documentCurrentScript=typeof document!=='undefined'?document.currentScript:null;var y=module$1.createRequire((typeof document === 'undefined' ? require('u' + 'rl').pathToFileURL(__filename).href : (_documentCurrentScript && _documentCurrentScript.tagName.toUpperCase() === 'SCRIPT' && _documentCurrentScript.src || new URL('chunk-UG55PF75.cjs', document.baseURI).href))),u=y("./jsonata-sync.cjs"),p=u;function c(t,r){if(!r||!t)return;let s=r.split("."),e=t;for(let n=0;n<s.length;n++){if(e==null)return;e=e[s[n]];}return e}function f(t,r,s){let e=r.split("."),n=t;for(let o=0;o<e.length-1;o++)(n[e[o]]==null||typeof n[e[o]]!="object")&&(n[e[o]]={}),n=n[e[o]];n[e[e.length-1]]=s;}async function m(t,r){if(!t?.compute?.length)return t;t.card_data||(t.card_data={}),t.computed_values={},t._sourcesData=r?.sourcesData??{};let s=t.requires??{},e={card_data:t.card_data,requires:s,expects_data:s,fetched_sources:t._sourcesData,data:t.computed_values,computed_values:t.computed_values};for(let n of t.compute)try{let o=await u(n.expr).evaluate(e);f(t.computed_values,n.bindTo,o),e.computed_values=t.computed_values;}catch{}return t}function g(t,r){if(!t?.compute?.length)return {ok:true,node:t};t.card_data||(t.card_data={}),t.computed_values={},t._sourcesData=r?.sourcesData??{};let s=t.requires??{},e={card_data:t.card_data,requires:s,expects_data:s,fetched_sources:t._sourcesData,data:t.computed_values,computed_values:t.computed_values},n=[];for(let o of t.compute)try{let a=p(o.expr).evaluate(e);f(t.computed_values,o.bindTo,a),e.computed_values=t.computed_values;}catch(a){let i=a instanceof Error?a.message:String(a);n.push({bindTo:o.bindTo,error:i});}return n.length>0?{ok:true,node:t,errors:n}:{ok:true,node:t}}async function b(t,r,s){let e={...s??{},card_data:r.card_data??{},requires:r.requires??{},fetched_sources:r._sourcesData??{},computed_values:r.computed_values??{}};return u(t).evaluate(e)}function _(t,r){return r.startsWith("fetched_sources.")?c(t._sourcesData??{},r.slice(16)):c(t,r)}var d=new Set(["metric","table","editable-table","chart","form","filter","list","notes","todo","alert","narrative","badge","text","markdown","ref","custom","actions"]),v=new Set(["id","meta","requires","provides","view","card_data","compute","source_defs"]);function h(t){let r=[];if(!t||typeof t!="object"||Array.isArray(t))return {ok:false,errors:["Node must be a non-null object"]};let s=t;(typeof s.id!="string"||!s.id)&&r.push("id: required, must be a non-empty string");for(let e of Object.keys(s))v.has(e)||r.push(`Unknown top-level key: "${e}"`);if((s.card_data==null||typeof s.card_data!="object"||Array.isArray(s.card_data))&&r.push("card_data: required, must be an object"),s.meta!=null)if(typeof s.meta!="object"||Array.isArray(s.meta))r.push("meta: must be an object");else {let e=s.meta;e.title!=null&&typeof e.title!="string"&&r.push("meta.title: must be a string"),e.tags!=null&&!Array.isArray(e.tags)&&r.push("meta.tags: must be an array");}if(s.requires!=null&&!Array.isArray(s.requires)&&r.push("requires: must be an array of strings"),s.provides!=null&&(Array.isArray(s.provides)?s.provides.forEach((e,n)=>{if(!e||typeof e!="object"||Array.isArray(e))r.push(`provides[${n}]: must be an object with bindTo and ref`);else {let o=e;(typeof o.bindTo!="string"||!o.bindTo)&&r.push(`provides[${n}]: missing required "bindTo" string`),(typeof o.ref!="string"||!o.ref)&&r.push(`provides[${n}]: missing required "ref" string`);}}):r.push("provides: must be an array of { bindTo, ref } bindings")),s.compute!=null&&(Array.isArray(s.compute)?s.compute.forEach((e,n)=>{if(!e||typeof e!="object"||Array.isArray(e))r.push(`compute[${n}]: must be a compute step object`);else {let o=e;(typeof o.bindTo!="string"||!o.bindTo)&&r.push(`compute[${n}]: missing required "bindTo" property`),(typeof o.expr!="string"||!o.expr)&&r.push(`compute[${n}]: missing required "expr" string (JSONata expression)`);}}):r.push("compute: must be an array of compute steps")),s.source_defs!=null)if(!Array.isArray(s.source_defs))r.push("source_defs: must be an array");else {let e=new Set,n=new Set;s.source_defs.forEach((o,a)=>{if(!o||typeof o!="object"||Array.isArray(o))r.push(`source_defs[${a}]: must be an object`);else {let i=o;typeof i.bindTo!="string"||!i.bindTo?r.push(`source_defs[${a}]: missing required "bindTo" property`):(e.has(i.bindTo)&&r.push(`source_defs[${a}]: bindTo "${i.bindTo}" is not unique across source_defs`),e.add(i.bindTo)),typeof i.outputFile!="string"||!i.outputFile?r.push(`source_defs[${a}]: missing required "outputFile" property`):(n.has(i.outputFile)&&r.push(`source_defs[${a}]: outputFile "${i.outputFile}" is not unique across source_defs`),n.add(i.outputFile));}});}if(s.view!=null)if(typeof s.view!="object"||Array.isArray(s.view))r.push("view: must be an object");else {let e=s.view;!Array.isArray(e.elements)||e.elements.length===0?r.push("view.elements: required, must be a non-empty array"):e.elements.forEach((n,o)=>{if(!n||typeof n!="object"){r.push(`view.elements[${o}]: must be an object`);return}!n.kind||typeof n.kind!="string"?r.push(`view.elements[${o}].kind: required, must be a string`):d.has(n.kind)||r.push(`view.elements[${o}].kind: unknown kind "${n.kind}". Valid: ${[...d].join(", ")}`),n.data!=null&&(typeof n.data!="object"||Array.isArray(n.data))&&r.push(`view.elements[${o}].data: must be an object`);}),e.layout!=null&&(typeof e.layout!="object"||Array.isArray(e.layout))&&r.push("view.layout: must be an object"),e.features!=null&&(typeof e.features!="object"||Array.isArray(e.features))&&r.push("view.features: must be an object");}return {ok:r.length===0,errors:r}}async function k(t,r){if(!t||t.length===0)return [];let s={card_data:r.card_data??{},requires:r.requires??{}};return Promise.all(t.map(async e=>{let n={};if(e.projections&&typeof e.projections=="object"&&!Array.isArray(e.projections)){for(let[o,a]of Object.entries(e.projections))if(typeof a=="string"&&a.trim().length>0)try{n[o]=await u(a).evaluate(s);}catch{n[o]=void 0;}}return {...e,_projections:n}}))}function w(t,r){if(!t||t.length===0)return [];let s={card_data:r.card_data??{},requires:r.requires??{}};return t.map(e=>{let n={};if(e.projections&&typeof e.projections=="object"&&!Array.isArray(e.projections)){for(let[o,a]of Object.entries(e.projections))if(typeof a=="string"&&a.trim().length>0)try{n[o]=p(a).evaluate(s);}catch{n[o]=void 0;}}return {...e,_projections:n}})}var j={run:m,runSync:g,eval:b,resolve:_,validate:h,enrichSources:k,enrichSourcesSync:w},$=j;exports.a=j;exports.b=$;//# sourceMappingURL=chunk-UG55PF75.cjs.map
2
- //# sourceMappingURL=chunk-UG55PF75.cjs.map
@@ -1,3 +0,0 @@
1
- 'use strict';var chunkLFVMX23W_cjs=require('./chunk-LFVMX23W.cjs'),chunkNM6O35RY_cjs=require('./chunk-NM6O35RY.cjs'),chunkNBJTYAYN_cjs=require('./chunk-NBJTYAYN.cjs'),chunkKSKPS6OO_cjs=require('./chunk-KSKPS6OO.cjs'),chunkBQUQTOPB_cjs=require('./chunk-BQUQTOPB.cjs'),chunkGPCMBPLK_cjs=require('./chunk-GPCMBPLK.cjs'),chunk7FGPOGRV_cjs=require('./chunk-7FGPOGRV.cjs'),chunkLPXVVMQT_cjs=require('./chunk-LPXVVMQT.cjs'),chunk272IYUKT_cjs=require('./chunk-272IYUKT.cjs'),chunkN5RUH4NG_cjs=require('./chunk-N5RUH4NG.cjs'),chunkWRMOGPRG_cjs=require('./chunk-WRMOGPRG.cjs'),chunkYXKWIPQM_cjs=require('./chunk-YXKWIPQM.cjs'),chunk5XLFPPTY_cjs=require('./chunk-5XLFPPTY.cjs'),chunkSDJ3747Q_cjs=require('./chunk-SDJ3747Q.cjs'),chunkOF4FPYNI_cjs=require('./chunk-OF4FPYNI.cjs'),chunk2RIHC5TZ_cjs=require('./chunk-2RIHC5TZ.cjs');function ce(R){let{apiBasePath:h,json:w,readJsonBody:L,initBoardAndSetup:F,bootstrapBoard:v,buildPublishedRuntimePayload:W,createMcpControlplaneToolRegistry:j,retriggerCard:M,applyCardAction:I,resolveChatHandlerTarget:E,sendCardFileDownloadResponse:$}=R;async function J(H,B,V){let l=H.method||"GET",A=V,u=A.pathname;try{if(l==="POST"&&u===`${h}/mcp-actions`){await v();let m=Date.now(),b=new Date(m).toISOString(),S=await L(H),f=typeof S.tool=="string"?S.tool.trim():"",T=S.args&&typeof S.args=="object"&&!Array.isArray(S.args)?S.args:{};if(!f)return w(B,400,{error:"tool is required"}),!0;let P=chunkLPXVVMQT_cjs.a(T,"card_id");if(!P)return w(B,400,{error:"MCP action requires card_id"}),!0;if(f==="retrigger-card"||f==="retrigger"){await M(P);let O=Date.now();return w(B,200,{status:"success",data:{ok:!0,cardId:P,actionType:f,requestReceivedAt:b,requestReceivedAtMs:m,responseSentAt:new Date(O).toISOString(),responseSentAtMs:O,responseStatus:200}}),!0}let g=chunkLPXVVMQT_cjs.c(T,"payload");if(f==="chat-send"&&!await E(P)){let O=Date.now();return w(B,409,{error:`chat handler is not configured for card: ${P}`,requestReceivedAt:b,requestReceivedAtMs:m,responseSentAt:new Date(O).toISOString(),responseSentAtMs:O,responseStatus:409}),!0}if(f==="chat-send"){let O=typeof g["turn-id"]=="string"?g["turn-id"]:typeof g.turnId=="string"?g.turnId:typeof g.turn=="string"?g.turn:"";if(!O||!String(O).trim()){let at=Date.now();return w(B,400,{error:`chat-send requires a non-empty 'turn-id' (or 'turnId'/'turn') in payload for card: ${P}`,requestReceivedAt:b,requestReceivedAtMs:m,responseSentAt:new Date(at).toISOString(),responseSentAtMs:at,responseStatus:400}),!0}}await I(P,f,g);let _=Date.now();return w(B,200,{status:"success",data:{ok:!0,cardId:P,actionType:f,requestReceivedAt:b,requestReceivedAtMs:m,responseSentAt:new Date(_).toISOString(),responseSentAtMs:_,responseStatus:200}}),!0}if(l==="POST"&&u===`${h}/mcp-controlplane`){await v();let m=await L(H),b=typeof m.tool=="string"?m.tool.trim():"",S=m.args&&typeof m.args=="object"&&!Array.isArray(m.args)?m.args:{};if(!b)return w(B,400,{error:"tool is required"}),!0;try{let f=await chunk272IYUKT_cjs.a(b,S,j());if(f&&typeof f=="object"&&!Array.isArray(f)){let T=f;if(T.status==="fail")return w(B,400,{error:chunk272IYUKT_cjs.b(f,"Request failed")}),!0;if(T.status==="error")return w(B,500,{error:chunk272IYUKT_cjs.b(f,"Internal error")}),!0}w(B,200,f);}catch(f){let T=typeof f?.statusCode=="number"?Number(f.statusCode):500,P=f instanceof Error?f.message:String(f);w(B,T,{error:P});}return !0}let k=u.match(new RegExp(`^${chunkBQUQTOPB_cjs.c(h)}/cards/([^/]+)/retrigger$`));if(l==="POST"&&k){await v();let m=decodeURIComponent(k[1]);return await M(m),w(B,200,{ok:!0}),!0}let x=u.match(new RegExp(`^${chunkBQUQTOPB_cjs.c(h)}/cards/([^/]+)/actions$`));if(l==="POST"&&x){await v();let m=decodeURIComponent(x[1]),b=Date.now(),S=new Date(b).toISOString(),f=await L(H),T=f?.actionType;if(T==="chat-send"&&!await E(m)){let g=Date.now();return w(B,409,{error:`chat handler is not configured for card: ${m}`,requestReceivedAt:S,requestReceivedAtMs:b,responseSentAt:new Date(g).toISOString(),responseSentAtMs:g,responseStatus:409}),!0}if(T==="chat-send"){let g=f?.payload??{},_=typeof g["turn-id"]=="string"?g["turn-id"]:typeof g.turnId=="string"?g.turnId:typeof g.turn=="string"?g.turn:"";if(!_||!String(_).trim()){let O=Date.now();return w(B,400,{error:`chat-send requires a non-empty 'turn-id' (or 'turnId'/'turn') in payload for card: ${m}`,requestReceivedAt:S,requestReceivedAtMs:b,responseSentAt:new Date(O).toISOString(),responseSentAtMs:O,responseStatus:400}),!0}}await I(m,T,f?.payload);let P=Date.now();return w(B,200,{ok:!0,requestReceivedAt:S,requestReceivedAtMs:b,responseSentAt:new Date(P).toISOString(),responseSentAtMs:P,responseStatus:200}),!0}let N=u.match(new RegExp(`^${chunkBQUQTOPB_cjs.c(h)}/cards/([^/]+)/files/(\\d+)$`));if(l==="GET"&&N){let m=decodeURIComponent(N[1]),b=parseInt(N[2],10),S=A.searchParams.get("sn");return await $(B,m,b,S),!0}return !1}catch(k){let x=k?.statusCode||500;return w(B,x,{error:String(k?.message||k)}),true}}return {handleRuntimeApi:J}}var ze=3e4;function Ke(R){let h=R.socket?.remoteAddress??"";return h==="127.0.0.1"||h==="::1"||h==="::ffff:127.0.0.1"}function ue(R){let{apiBasePath:h,emitNotifications:w,readJsonBody:L,json:F}=R,v=`${h}/notify-q`;async function W(j,M,I){if(I.pathname!==v)return false;if((j.method??"").toUpperCase()!=="POST")return F(M,405,{status:"error",error:"Method not allowed"}),true;if(!Ke(j))return F(M,403,{status:"error",error:"Forbidden"}),true;let E;try{E=await L(j);}catch{return F(M,400,{status:"error",error:"Invalid JSON body"}),true}if(!E||typeof E!="object"||!Array.isArray(E.notifications))return F(M,400,{status:"error",error:"body.notifications must be an array"}),true;let $=E.notifications,{accepted:J,rejected:H}=chunkKSKPS6OO_cjs.b($,Date.now(),ze);return J.length>0&&w(J),F(M,200,{status:"success",data:{accepted:J.length,rejected:H}}),true}return {handleNotifyRoute:W}}var le={"Access-Control-Allow-Origin":"*","Access-Control-Allow-Headers":"content-type,x-file-name","Access-Control-Allow-Methods":"GET,POST,PATCH,OPTIONS"},de="chat-handler-flow-queue",ot="__probe__echo__probe__";function jr(R){let h=String(R.apiBasePath||"/api/board").replace(/\/$/,""),w={...le,...R.corsHeaders||{}},L=R.queueLaneTuning??{},F=R.boardId||"",v=R.logger||{info:console.log,warn:console.warn,error:console.error},W=R.invocationAdapter,j=R.chatFlowRunner||null,M=R.notificationTransport||null,I=R.serverUrl||null,E=R.executionExtra||{},$=R.onSseClientConnected,J=R.onSseClientDisconnected,H=R.onChannelSubscribed,B=R.onChannelUnsubscribed,V=chunkLFVMX23W_cjs.a({buildChatOneShotBatch:async(t,e)=>await tt.buildSseOneShotBatch({params:{cardId:t},body:{receiving:e}}),onSseClientDisconnected:J}),l=chunkLFVMX23W_cjs.a({buildChatOneShotBatch:async()=>({status:"success",data:{kind:"notification-batch",category:"batch",notifications:[]}})});function A(t){function e(a){return {...a,queueStorageForRef(d,C){return chunkSDJ3747Q_cjs.a(a.queueStorageForRef(d,C),{lane:C,emitNotification:i})}}}function r(a){return {...a,queueStorageForRef(d,C){return chunkN5RUH4NG_cjs.h(a.queueStorageForRef(d,C),{lane:C,emitNotification:i})}}}function n(a){return {async get(d){return a.get(d)},async set(d){return a.set(d)},async del(d){return a.del(d)},async patch(d){return a.patch(d)},async appendFiles(d){return a.appendFiles(d)}}}function o(a){return {async get(d){return await a.get(d)},async set(d){return await a.set(d)},async del(d){return await a.del(d)},async patch(d){return await a.patch(d)},async appendFiles(d){return await a.appendFiles(d)}}}let s=null;function i(a){if(a.kind==="notification-batch"){O(a.notifications,s??void 0);return}O([a],s??void 0);}let c=chunkBQUQTOPB_cjs.a(t.boardAdapter)?r(t.boardAdapter):e(t.boardAdapter),D=t.nonCoreAdapter??(!chunkBQUQTOPB_cjs.a(c)&&b(c)?c:null),y=chunkBQUQTOPB_cjs.a(c)?chunkN5RUH4NG_cjs.i(t.baseRef,c,{boardRuntimeStoreRef:t.boardRuntimeStoreRef,scratchStoreRef:t.scratchStoreRef,taskExecutorRef:t.taskExecutorRef,chatHandlerFlow:t.chatHandlerFlow,emitNotification:i}):chunkYXKWIPQM_cjs.y(t.baseRef,c,{boardRuntimeStoreRef:t.boardRuntimeStoreRef,scratchStoreRef:t.scratchStoreRef,taskExecutorRef:t.taskExecutorRef,chatHandlerFlow:t.chatHandlerFlow,emitNotification:i}),q=t.nonCore??(D?chunkYXKWIPQM_cjs.z(t.baseRef,D,{boardRuntimeStoreRef:t.boardRuntimeStoreRef,taskExecutorRef:t.taskExecutorRef}):null),Ue=c.chatStorageForRef(t.chatStoreRef),lt,We=chunkBQUQTOPB_cjs.a(c)?(()=>{let a=chunkN5RUH4NG_cjs.d(chunkN5RUH4NG_cjs.c(chunkN5RUH4NG_cjs.b(c.kvStorageForRef(t.cardStoreRef)),c.hashFn),v.warn),d=chunkN5RUH4NG_cjs.g(a,{emitNotification:i}),C=o(d);return lt={get(p){return C.get(p)},set(p){return C.set(p)}},C})():(()=>{let a=c.kvStorageForRef(t.cardStoreRef),C=chunk5XLFPPTY_cjs.a(chunkYXKWIPQM_cjs.l({readIndex:()=>a.read("_index"),writeIndex:p=>a.write("_index",p),readCard:p=>a.read(p),writeCard:(p,pt)=>(a.write(p,pt),p),removeCard:p=>{a.delete(p);},cardExists:p=>a.read(p)!==null,defaultCardKey:p=>p},v.warn),{emitNotification:i});return lt=C,n(C)})(),ft;if(chunkBQUQTOPB_cjs.a(c)){let a=c.blobStorageForRef(t.artifactsStoreRef);ft={async putBytes(d,C){if(a.writeBytes){await a.writeBytes(d,C);return}let p=JSON.stringify({__kind:"bytes-array",data:[...C]});await a.write(d,p);},async getBytes(d){if(a.readBytes){let p=await a.readBytes(d);if(p!==null)return p}let C=await a.read(d);if(C===null)return null;try{let p=JSON.parse(C);if(p&&p.__kind==="bytes-array"&&Array.isArray(p.data))return new Uint8Array(p.data)}catch{}return new TextEncoder().encode(C)},async listKeys(d){return await a.listKeys(d)}};}else {let a=c.blobStorageForRef(t.artifactsStoreRef),d=chunkNBJTYAYN_cjs.a(a);ft={putBytes(C,p,pt){d.putBytes(C,p,pt);},getBytes(C){return d.getBytes(C)},listKeys(C){return d.list(C).map(p=>p.key)}};}let Je={async init(a){return y.init(a)},async status(a){return y.status(a)},async getConfig(a){return y.getConfig(a)},async getAllOutputsDataObjects(a){return y.getAllOutputsDataObjects(a)},async getAllOutputsComputedValues(a){return y.getAllOutputsComputedValues(a)},async getOutputsFetchedSources(a){return y.getOutputsFetchedSources(a)},async buildSseOneShotPayload(a){return y.buildSseOneShotPayload(a)},async upsertCard(a){return y.upsertCard(a)},async removeCard(a){return y.removeCard(a)},async sourceDataFetched(a){return y.sourceDataFetched(a)},async sourceDataFetchFailure(a){return y.sourceDataFetchFailure(a)}};return s={label:t.label,board:y,nonCore:q,publicCardStore:lt,boardOps:Je,cardStoreOps:We,get filesArtifacts(){return ft},get chatStorage(){return Ue},boardAdapter:c,boardRuntimeStoreRef:t.boardRuntimeStoreRef,cardStoreRef:t.cardStoreRef,outputsStoreRef:t.outputsStoreRef,artifactsStoreRef:t.artifactsStoreRef,fetchedSourcesStoreRef:t.fetchedSourcesStoreRef,queueStoreRef:t.queueStoreRef,chatStoreRef:t.chatStoreRef,scratchStoreRef:t.scratchStoreRef,notifyRef:t.notifyRef,taskExecutorRef:t.taskExecutorRef,chatHandlerRef:t.chatHandlerRef,chatHandlerFlow:t.chatHandlerFlow,inferenceAdapterRef:t.inferenceAdapterRef,notification:chunkKSKPS6OO_cjs.c(),notificationTeardown:null,initialized:false,cardsBootstrapped:false},s}let u=R.boards.map(A),k=new Map;function x(t){return k.get(t)??0}function N(t){return t.queueStoreRef}function m(t,e){if(chunkBQUQTOPB_cjs.a(t.boardAdapter)){let n=t.boardAdapter.queueStorageForRef(N(t),e);return chunkWRMOGPRG_cjs.a(n)}let r=t.boardAdapter.queueStorageForRef(N(t),e);return chunkGPCMBPLK_cjs.a(r)}function b(t){let e=t;return typeof e.invokeExecutor=="function"&&typeof e.validateSchema=="function"}function S(t){let e=u[x(t)];return {files:e?e.filesArtifacts:null}}function f(){return chunkNBJTYAYN_cjs.c()}function T(t){return String(t||"").replace(/[^a-zA-Z0-9_-]/g,"_")||"unknown-card"}function P(t){return "cardId"in t&&typeof t.cardId=="string"?z(t.cardId)??void 0:u[0]??void 0}function g(t){for(let e of t){let r=P(e);if(r)return r}return u[0]??void 0}function _(t,e={}){if(!t||t.length===0)return;let r=chunk2RIHC5TZ_cjs.e(t),n={kind:"notification-batch",category:"batch",notifications:r},o=e.ctx??g(r);if(e.appendState!==false&&o&&chunkKSKPS6OO_cjs.e(o.notification,n),e.broadcastSse!==false){let s=r.filter(c=>c.kind==="message_enqueued"),i=r.filter(c=>c.kind!=="message_enqueued");i.length>0&&V.broadcastNotificationBatch(i),s.length>0&&l.broadcastNotificationBatch(s);}if(!(e.mirrorExternal===false||!o?.boardAdapter.publishBoardChangeNotifications))try{let s=r.filter(i=>i.category==="board-output"||i.category==="card-store");s.length>0&&o.boardAdapter.publishBoardChangeNotifications(s);}catch{}}function O(t,e){_(t,{ctx:e,appendState:true,broadcastSse:true,mirrorExternal:true});}async function at(t){if(!t||t.notificationTeardown||!M||!t.notifyRef)return;let e=await M.subscribe(t.notifyRef,r=>{let n=chunkKSKPS6OO_cjs.a(r);_(n,{ctx:t,appendState:true,broadcastSse:true,mirrorExternal:false});});t.notificationTeardown=e;}async function fe(t){if(!t||t.initialized)return;let e={boardRuntimeStoreRef:t.boardRuntimeStoreRef,cardStoreRef:t.cardStoreRef,outputsStoreRef:t.outputsStoreRef,fetchedSourcesStoreRef:t.fetchedSourcesStoreRef,artifactsStoreRef:t.artifactsStoreRef,queueStoreRef:t.queueStoreRef,chatStoreRef:t.chatStoreRef,scratchStoreRef:t.scratchStoreRef},r={};t.taskExecutorRef&&(r["task-executor-ref"]=t.taskExecutorRef),t.chatHandlerFlow!==void 0&&(r["chat-handler-flow"]=t.chatHandlerFlow);let n=await t.boardOps.init({params:e,body:r});if(n.status!=="success")throw Object.assign(new Error(n.error||`init failed for ${t.label}`),{statusCode:500});if(await at(t),!t.chatHandlerFlow&&t.chatHandlerRef&&W.describe)try{let o=await W.describe(t.chatHandlerRef);o&&o.kind!=="chat-handler"?v.warn(`[init] chat-handler describe returned kind="${o.kind}", expected "chat-handler" for ${t.label}`):o&&v.info(`[init] chat-handler validated: ${o.name} (protocol ${o.protocolVersion}) for ${t.label}`);}catch(o){v.warn(`[init] chat-handler describe failed for ${t.label}: ${o?.message||String(o)}`);}t.initialized=true;}async function ut(t){let e=[],r=await t.boardOps.status({});r.status==="success"&&r.data!=null&&chunkKSKPS6OO_cjs.d(r.data)&&e.push({kind:"status",status:r.data});let n=await t.boardOps.getAllOutputsDataObjects({});if(n.status==="success"&&n.data!=null)for(let[s,i]of Object.entries(n.data))s&&e.push({kind:"data_object",key:s,payload:i});let o=await t.boardOps.getAllOutputsComputedValues({});if(o.status==="success"&&o.data!=null)for(let[s,i]of Object.entries(o.data))s&&i&&typeof i=="object"&&!Array.isArray(i)&&e.push({kind:"computed_values",cardId:s,values:i});e.length>0&&_(e,{ctx:t,appendState:true,broadcastSse:true,mirrorExternal:false});}async function Rt(t,e){if(!t||t.cardsBootstrapped)return;let r=await t.cardStoreOps.get({}),n=r.status==="success"&&Array.isArray(r.data?.cards)?r.data.cards:[];for(let o of n)typeof o.id=="string"&&(k.set(o.id,e),await t.boardOps.upsertCard({params:{cardId:o.id}}));t.cardsBootstrapped=true;}async function G(){for(let t of u)await fe(t);}async function st(){await G();for(let t=0;t<u.length;t++)await ut(u[t]),await Rt(u[t],t),await ut(u[t]);}async function yt(t=false){t||await G();for(let e of u){let r=await e.board.processAccumulatedEvents({});if(r.status!=="success")return r}return {status:"success"}}function z(t){return u[x(t)]??null}async function X(t){let e=z(t);if(!e)return null;let r=await e.cardStoreOps.get({params:{id:t}});if(r.status!=="success")return null;let n=Array.isArray(r.data?.cards)?r.data.cards:[];return n.length>0?n[0]:null}async function pe(){let t=async r=>{if(!r)return [];let n=await r.cardStoreOps.get({});return n.status!=="success"||!Array.isArray(n.data?.cards)?[]:n.data.cards},e=[];for(let r of u)e.push(...await t(r));return e}function ht(){return u[0]??null}function me(t){return z(t)??ht()}function U(t){let e=me(t);if(!e)throw Object.assign(new Error(`Board context is unavailable for chat operations: ${t}`),{statusCode:404});return e.chatStorage}async function ge(t){return await U(t).isProcessing(t)}async function Y(t,e){let r=await tt.setProcessing({params:{cardId:t},body:{active:e}});if(r.status!=="success")throw Object.assign(new Error(r.error||`Failed to set chat processing for card: ${t}`),{statusCode:500})}let tt=chunkOF4FPYNI_cjs.a({append(t,e,r,n,o){return U(t).append(t,e,r,n,o)},readAll(t){return U(t).readAll(t)},readAfter(t,e){return U(t).readAfter(t,e)},clear(t){return U(t).clear(t)},setProcessing(t,e){return U(t).setProcessing(t,e)},isProcessing(t){return U(t).isProcessing(t)},getConfig(t){return U(t).getConfig(t)},setConfig(t,e){return U(t).setConfig(t,e)}},{emitNotification(t){if(t.kind==="notification-batch"){O(t.notifications);return}O([t]);}}),wt=chunkKSKPS6OO_cjs.p({boardContexts:u,cardOwnerIndex:k,cardContextForCard:t=>z(t),readStatusSnapshot:()=>be(),readDataObjectsByToken:()=>Ce(),readCardRuntimeArtifacts:()=>Se(),readCardFromStore:t=>X(t),readCardDefinitions:()=>pe(),processAccumulatedLaneInternal:t=>yt(t),reportSourceFetched:(t,e)=>kt(t,{ref:e}),reportSourceFetchFailure:(t,e)=>Pt(t,{reason:e}),uploadCardFile:(t,e,r,n,o)=>Ct(t,e,r,n,o),chatStorePublic:tt,serverUrl:I,apiBasePath:h}),Re=wt.mcpCardStoreFacade,it=wt.createMcpFacade,ye=chunkKSKPS6OO_cjs.j({boardId:F,bootstrapBoard:()=>st(),sseHub:V,onChannelSubscribed:H,onChannelUnsubscribed:B,getMcpFacade:()=>it(),getMcpCardStoreFacade:()=>Re()});function he(t){return chunkKSKPS6OO_cjs.m(t)}function we(){return chunkKSKPS6OO_cjs.n(it())}function bt(){return chunkKSKPS6OO_cjs.o({boardId:F,uploadCardFile:Ct,getMcpFacade:()=>it(),controlplane:ye})}let ct=chunkKSKPS6OO_cjs.k({boardId:F,boardContexts:u,readChatRecords:t=>Fe(t),getChatProcessing:t=>ge(t)}),be=ct.readStatusSnapshot,Se=ct.readCardRuntimeArtifacts,Ce=ct.readDataObjectsByToken,dt=ct.buildPublishedRuntimePayload;async function St(t,e,r){let n=r?.syncBoard!==false,o=r?.restartOnlyIfChanged===true,s=z(t);if(!s)throw Object.assign(new Error(`Card not found: ${t}`),{statusCode:404});let i=await X(t);if(!i)throw Object.assign(new Error(`Card not found: ${t}`),{statusCode:404});let c=o?JSON.stringify(i):null,D=e(i)||i;if(o&&JSON.stringify(D)===c)return;let y=await s.cardStoreOps.set({body:D});if(y.status!=="success")throw Object.assign(new Error(y.error||`Failed to persist card: ${t}`),{statusCode:500});if(n){let q=await s.boardOps.upsertCard({params:{cardId:t,restart:true}});if(q.status!=="success")throw Object.assign(new Error(q.error||`Failed to upsert card: ${t}`),{statusCode:500})}}async function Ae(t,e){await St(t,e,{syncBoard:true});}async function Be(t,e){await St(t,e,{syncBoard:false});}async function ke(t){let e=z(t);if(!e)throw Object.assign(new Error(`Card not found: ${t}`),{statusCode:404});if(!await X(t))throw Object.assign(new Error(`Card not found: ${t}`),{statusCode:404});let n=await e.boardOps.upsertCard({params:{cardId:t,restart:true}});if(n.status!=="success")throw Object.assign(new Error(n.error||`Failed to retrigger card: ${t}`),{statusCode:500})}async function Pe(t){let e=await tt.clear({params:{cardId:t}});if(e.status!=="success")throw Object.assign(new Error(e.error||`Failed to clear chat records for card: ${t}`),{statusCode:500});try{await Y(t,!1);}catch{}}async function Oe(t,e,r,n,o=""){let s=typeof r=="string"?r.trim():"",i=await tt.append({params:{cardId:t},body:{role:e||"system",text:s,files:n,turn:o}});if(i.status!=="success")throw Object.assign(new Error(i.error||`Failed to append chat record for card: ${t}`),{statusCode:500});return String(i.data?.id||"")}async function Fe(t){return await U(t).readAll(t)}let Ct=chunkKSKPS6OO_cjs.l({safeCardId:t=>T(t),artifactsStores:t=>S(t),cardFileMetadataStore:()=>f(),readCardFromStore:t=>X(t),updateCardLocalOnly:(t,e)=>Be(t,e),writeChatRecord:(t,e,r,n,o)=>Oe(t,e,r,n,o)}).uploadCardFile;async function At(t){let e=z(t);if(!e)return null;let r=await e.boardOps.getConfig({params:{key:"chat-handler-flow"}}),o=(r.status==="success"?r.data?.value:null)??e.chatHandlerFlow??null,s=e.chatHandlerRef;return o==null&&(!s||typeof s!="object")?null:{ctx:e,handlerFlow:o,handlerRef:s}}function ve(t){let e=typeof t=="string"?t.trim():"";if(e.length<ot.length*2||!e.startsWith(ot)||!e.endsWith(ot))return null;let r=e.slice(ot.length,e.length-ot.length).trim(),n=/^([A-Za-z0-9_-]+)__(.*)$/s.exec(r);return n?{assistant:n[1].trim().toLowerCase(),text:n[2].trim()}:{assistant:"echo",text:r}}async function xe(t,e,r=false,n="",o=""){try{let s=await At(t);if(!s){try{await Y(t,!1);}catch{}return}let{ctx:i,handlerFlow:c,handlerRef:D}=s;if(!r)try{await Y(t,!0);}catch{}let y={boardId:F,cardId:String(t),lastChatEntryId:e,...n?{turnId:n}:{},...typeof o=="string"&&o.trim()?{probe:o.trim()}:{},...E,...I?{serverUrl:I}:{}},q=c!=null?{meta:"chat-handler-flow",howToRun:"built-in",whatToRun:{kind:"built-in",value:de}}:D;chunkBQUQTOPB_cjs.a(i.boardAdapter)?await m(i,"chat-agent").enqueueRequest({boardId:F,ref:q,args:c!=null?{...y,__chatHandlerFlow:c}:y}):m(i,"chat-agent").enqueueRequest({boardId:F,ref:q,args:c!=null?{...y,__chatHandlerFlow:c}:y}),await Promise.resolve(i.boardAdapter.requestProcessAccumulated?.());}catch(s){try{await Y(t,!1);}catch{}v.warn(`[chat-handler] queue failed for card "${t}": ${s instanceof Error?s.message:String(s)}`);}}async function Te(t,e,r){if(e.howToRun==="built-in"&&chunkBQUQTOPB_cjs.b(e)===de){let n=j,o=r.__chatHandlerFlow,s={...r};return delete s.__chatHandlerFlow,n?n.run(o,s,{boardId:F,cardId:String(s.cardId||""),label:t.label,logger:v,serverUrl:I,executionExtra:E}):{dispatched:false,error:"chat-handler-flow configured but no chatFlowRunner was provided"}}return W.invoke(e,r)}async function Ne(t,e=false){e||await G();let r=typeof t.args?.cardId=="string"?t.args.cardId:"",n=r?z(r):ht();if(!n)throw new Error(r?`Board context is unavailable for chat-agent request: ${r}`:"Board context is unavailable for chat-agent request");let o=await Te(n,t.ref,t.args);if(!o.dispatched){if(r)try{await Y(r,!1);}catch{}throw new Error(o.error||`chat-agent dispatch failed for card "${r||"unknown"}"`)}}async function Ee(t,e,r){if(e==="chat-send"){let o=r&&typeof r["turn-id"]=="string"?r["turn-id"]:r&&typeof r.turnId=="string"?r.turnId:r&&typeof r.turn=="string"?r.turn:"";if(r&&"files"in r&&r.files!==void 0&&r.files!==null)throw Object.assign(new Error('chat-send does not accept a "files" parameter; upload attachments via manage.add-chat-attachment first'),{statusCode:400});let s=bt(),i=ve(r?.text),c=i?i.text:r?.text,D=await chunk272IYUKT_cjs.a("manage.add-chat-entry-and-any-attachments",{board_id:F,card_id:t,role:"user",text:c,turn_id:o,files:[]},s);if(D?.status!=="success")throw new Error(chunk272IYUKT_cjs.b(D,`chat-send append failed for card ${t}`));let y=D?.data?.id;if(typeof y!="string"||!y)throw new Error(`chat-send did not return an append id for card ${t}`);let q=await chunk272IYUKT_cjs.a("setstate.chat-processing-started",{board_id:F,card_id:t},s);if(q?.status!=="success")throw new Error(chunk272IYUKT_cjs.b(q,`chat-send processing update failed for card ${t}`));xe(t,y,true,o,i?.assistant||"");return}await Ae(t,o=>{let s=new Date().toISOString(),i=o.card_data&&typeof o.card_data=="object"?o.card_data:{};if(o.card_data=i,e==="file-upload"){let c=f().normalizeIncoming(r?.files,s);return c.length>0&&f().merge(i,c),o}if(e==="action"){let c=r&&typeof r.buttonId=="string"?r.buttonId:"";if(!c)return o;i.lastAction={buttonId:c,at:s},i.lastActionText=`${c} @ ${s}`;}return o});}function et(t,e,r){let n=JSON.stringify(r),o=typeof Buffer<"u"?Buffer.byteLength(n):new TextEncoder().encode(n).length;t.writeHead(e,{...w,"Content-Type":"application/json; charset=utf-8","Content-Length":o}),t.end(n);}async function Bt(t,e,r){let n=await X(t);if(!n)throw Object.assign(new Error("Card not found"),{statusCode:404});let o=f().resolve(n.card_data,e,r);if(!o.ok&&o.reason==="stale_reference")throw Object.assign(new Error("File reference is stale. Refresh and try again."),{statusCode:409});if(!o.ok)throw Object.assign(new Error("File not found"),{statusCode:404});let s=o.file,i=T(t),c=S(t),D=String(s.stored_name||""),y=`${i}/${D}`,q=c.files?await c.files.getBytes(y):null;if(!q)throw Object.assign(new Error("File not found"),{statusCode:404});return {fileRecord:s,bytes:q}}async function je(t,e,r,n){let{fileRecord:o,bytes:s}=await Bt(e,r,n),i=String(o.name||o.stored_name||"download.bin"),c=String(o.mime_type||"application/octet-stream");t.writeHead(200,{"Content-Type":c,"Content-Disposition":`attachment; filename="${i}"`,"Content-Length":s.length}),t.end(s);}function Me(t){let e=String(t||"").toLowerCase();return e.startsWith("text/")||e.includes("json")||e.includes("xml")||e.includes("javascript")||e.includes("typescript")||e.includes("yaml")||e.includes("csv")}function _e(t,e,r){let n=t.split(/\r?\n/);return (e==="head"?n.slice(0,r):n.slice(-r)).join(`
2
- `)}async function rt(t){let e=[];for await(let n of t)e.push(n);let r=typeof Buffer<"u"?Buffer.concat(e).toString("utf-8").trim():new TextDecoder().decode(chunkBQUQTOPB_cjs.d(e)).trim();return r?JSON.parse(r):{}}async function kt(t,e){let r=typeof e.ref=="string"?e.ref.trim():"";if(!r)return {status:"fail",error:"board-worker success callback requires body.ref"};let n=u[0];return n?n.boardOps.sourceDataFetched({params:{token:t,ref:r}}):{status:"fail",error:"no board context"}}async function Pt(t,e){let r=typeof e.reason=="string"&&e.reason.trim()?e.reason:"unknown",n=u[0];return n?n.boardOps.sourceDataFetchFailure({params:{token:t,reason:r}}):{status:"fail",error:"no board context"}}let De=chunkLFVMX23W_cjs.b({sseHub:V,queueSseHub:l,corsHeaders:w,json:et,buildPublishedRuntimePayload:()=>dt(),onSseClientConnected:$,onChannelSubscribed:H,onChannelUnsubscribed:B,apiBasePath:h,readJsonBody:t=>rt(t),initBoardAndSetup:()=>G(),bootstrapBoard:()=>st(),boardContexts:u,publishPersistedStateSnapshot:t=>ut(t),upsertCardsFromSource:(t,e)=>Rt(t,e)}).handleWatchersRoutes,qe=chunk7FGPOGRV_cjs.a({apiBasePath:h,json:et,readJsonBody:t=>rt(t),bootstrapBoard:()=>st(),createMcpFacade:()=>it(),createMcpToolRegistry:t=>he(t),resolveCardFileDownloadPayload:(t,e,r)=>Bt(t,e,r),isLikelyTextMimeType:t=>Me(t),sliceTextByLines:(t,e,r)=>_e(t,e,r)}).handleAgentfaceApi,Ie=chunkNM6O35RY_cjs.a({apiBasePath:h,json:et,readJsonBody:t=>rt(t),initBoardAndSetup:()=>G(),createMcpWebhookToolRegistry:()=>we()}).handleWebhooksApi,$e=ce({apiBasePath:h,json:et,readJsonBody:t=>rt(t),initBoardAndSetup:()=>G(),bootstrapBoard:()=>st(),buildPublishedRuntimePayload:()=>dt(),createMcpControlplaneToolRegistry:()=>bt(),retriggerCard:t=>ke(t),applyCardAction:(t,e,r)=>Ee(t,e,r),resolveChatHandlerTarget:t=>At(t),sendCardFileDownloadResponse:(t,e,r,n)=>je(t,e,r,n)}).handleRuntimeApi,He=ue({apiBasePath:h,emitNotifications:t=>O(t),readJsonBody:t=>rt(t),json:(t,e,r)=>et(t,e,r)}).handleNotifyRoute;async function Le(t,e,r){return !!(await qe(t,e,r)||await Ie(t,e,r)||await De(t,e,r)||await He(t,e,r)||await $e(t,e,r))}return {get apiBasePath(){return h},get corsHeaders(){return w},get queueLaneTuning(){return L},handleRuntimeApi:Le,emitNotification(t){if(t.kind==="notification-batch"){O(t.notifications);return}O([t]);},buildPublishedRuntimePayload:dt,__drainProcessAccumulatedLane:yt,handleChatAgentRequest:Ne,clearChatRecords:Pe,reportSourceFetched(t,e){return kt(t,{ref:e})},reportSourceFetchFailure(t,e){return Pt(t,{reason:e})},get cardStore(){return u[0]?.publicCardStore??{get(){return Promise.resolve({status:"fail",error:"no board context"})},set(){return Promise.resolve({status:"fail",error:"no board context"})}}}}}function Mr(R){let h=String(R.apiBasePath||"/api/boards").replace(/\/$/,""),w={...le,...R.corsHeaders||{}},L=R.serverMetaStore,F=R.boardRuntimeFactory,v=new Map,W="boards-config.json";function j(){let l=L.getText(W);if(!l)return {boards:[{id:"default",label:"Default Board"}]};try{return JSON.parse(l)}catch{return {boards:[{id:"default",label:"Default Board"}]}}}function M(l){L.putText(W,JSON.stringify(l,null,2));}function I(l){let A=String(l||"").replace(/[^a-zA-Z0-9_-]/g,"_").replace(/^_+|_+$/g,"");return A.length>0&&A.length<=64?A:null}function E(l){if(v.has(l))return v.get(l);let u=j().boards.find(x=>x.id===l)||{},k=F(l,u);return v.set(l,k),k}function $(l,A,u){let k=JSON.stringify(u),x=typeof Buffer<"u"?Buffer.byteLength(k):new TextEncoder().encode(k).length;l.writeHead(A,{...w,"Content-Type":"application/json; charset=utf-8","Content-Length":x}),l.end(k);}async function J(l,A,u){let k=l.method||"GET",x=u.pathname;if(k==="GET"&&x===h)return $(A,200,{ok:true,boards:j().boards}),true;if(k==="POST"&&x===h){let N=[];for await(let g of l)N.push(g);let m=typeof Buffer<"u"?Buffer.concat(N).toString("utf-8").trim():new TextDecoder().decode(chunkBQUQTOPB_cjs.d(N)).trim(),b={};try{b=m?JSON.parse(m):{};}catch{b={};}let S=I(b.id);if(!S)return $(A,400,{error:"board id must be 1-64 alphanumeric/dash/underscore characters"}),true;let f=j();if(f.boards.some(g=>g.id===S))return $(A,409,{error:`Board "${S}" is already registered`}),true;let T=typeof b.label=="string"&&b.label.trim()?b.label.trim():S,P={id:S,label:T};for(let[g,_]of Object.entries(b))g==="id"||g==="label"||_!=null&&(P[g]=_);return f.boards.push(P),M(f),$(A,200,{ok:true,board:P}),true}return false}async function H(l,A,u){let x=u.pathname.match(new RegExp(`^${chunkBQUQTOPB_cjs.c(h)}/([^/]+)(/|$)`));if(!x)return false;let N=I(decodeURIComponent(x[1]));return N?j().boards.some(S=>S.id===N)?!!await E(N).handleRuntimeApi(l,A,u):($(A,404,{error:`Board "${N}" not registered. POST ${h} with {id} to register it first.`}),true):($(A,400,{error:"Invalid board id"}),true)}async function B(l,A,u){return !!(await J(l,A,u)||await H(l,A,u))}function V(l){if(!j().boards.some(u=>u.id===l))throw Object.assign(new Error(`Board "${l}" not registered`),{statusCode:404});return {service:E(l)}}return {get apiBasePath(){return h},get corsHeaders(){return w},handleApi:B,requireBoardService:V}}exports.a=jr;exports.b=Mr;//# sourceMappingURL=chunk-WYKCHXBZ.cjs.map
3
- //# sourceMappingURL=chunk-WYKCHXBZ.cjs.map