@kodax-ai/kodax 0.7.72 → 0.7.73

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 (86) hide show
  1. package/CHANGELOG.md +92 -0
  2. package/README.md +48 -14
  3. package/README_CN.md +33 -10
  4. package/dist/chunks/{agent-YKGU4USA.js → agent-T6PGT6AU.js} +1 -1
  5. package/dist/chunks/argument-completer-QGMWA2C3.js +2 -0
  6. package/dist/chunks/{chunk-SQODXBLX.js → chunk-64M5HOCA.js} +1 -1
  7. package/dist/chunks/{chunk-PKQOEDHJ.js → chunk-6JTWXGVU.js} +217 -223
  8. package/dist/chunks/{chunk-IR5KIK7E.js → chunk-6RI2RBTF.js} +1 -1
  9. package/dist/chunks/chunk-AGDDM5AW.js +329 -0
  10. package/dist/chunks/chunk-BUPJGG3C.js +5 -0
  11. package/dist/chunks/chunk-EAD4SF3Z.js +413 -0
  12. package/dist/chunks/chunk-F7AIEHSS.js +46 -0
  13. package/dist/chunks/{chunk-E27LHEIP.js → chunk-GAFFYJU3.js} +1 -1
  14. package/dist/chunks/chunk-HVCNAZ52.js +365 -0
  15. package/dist/chunks/{chunk-MVARIMQV.js → chunk-M7FXNPWV.js} +2 -2
  16. package/dist/chunks/{chunk-44QXPEEE.js → chunk-MBAPT2R5.js} +1 -1
  17. package/dist/chunks/{chunk-WIBLZK4G.js → chunk-MLEAQTCD.js} +2 -2
  18. package/dist/chunks/{chunk-JSDLBXME.js → chunk-OG6DRNKV.js} +63 -63
  19. package/dist/chunks/{chunk-2RI252RN.js → chunk-PFH53O4M.js} +1 -1
  20. package/dist/chunks/chunk-V4F6IYNK.js +73 -0
  21. package/dist/chunks/chunk-WQ6PWGK5.js +320 -0
  22. package/dist/chunks/chunk-XXQLPTAN.js +78 -0
  23. package/dist/chunks/compaction-config-IHJBP4GO.js +2 -0
  24. package/dist/chunks/{construction-bootstrap-ZJPXUPXQ.js → construction-bootstrap-EGRUHKLP.js} +1 -1
  25. package/dist/chunks/dist-5N3I2RTW.js +2 -0
  26. package/dist/chunks/{dist-GOUP4YVE.js → dist-EVEJAII2.js} +1 -1
  27. package/dist/chunks/host-MECITNE3.js +2 -0
  28. package/dist/chunks/run-manager-AY7RQOWM.js +2 -0
  29. package/dist/chunks/{utils-OTT5CG5J.js → utils-2GAE4XIM.js} +1 -1
  30. package/dist/index.d.ts +16 -16
  31. package/dist/index.js +5 -5
  32. package/dist/kodax_cli.js +1341 -1320
  33. package/dist/provider-capabilities.json +184 -5
  34. package/dist/runtime-worker.js +1227 -1216
  35. package/dist/sdk-a2a.d.ts +10 -10
  36. package/dist/sdk-a2a.js +1 -1
  37. package/dist/sdk-agent.d.ts +13 -13
  38. package/dist/sdk-agent.js +1 -1
  39. package/dist/sdk-coding.d.ts +96 -30
  40. package/dist/sdk-coding.js +1 -1
  41. package/dist/sdk-experimental-memory.d.ts +1 -1
  42. package/dist/sdk-experimental-memory.js +1 -1
  43. package/dist/sdk-llm.d.ts +8 -49
  44. package/dist/sdk-llm.js +1 -1
  45. package/dist/sdk-mcp.js +1 -1
  46. package/dist/sdk-media.d.ts +1 -1
  47. package/dist/sdk-media.js +1 -1
  48. package/dist/sdk-repl.d.ts +138 -16
  49. package/dist/sdk-repl.js +2 -2
  50. package/dist/sdk-runtime.d.ts +99 -17
  51. package/dist/sdk-runtime.js +1 -1
  52. package/dist/sdk-session.d.ts +6 -6
  53. package/dist/sdk-session.js +1 -1
  54. package/dist/sdk-skills.js +1 -1
  55. package/dist/semantic-worker.js +10 -10
  56. package/dist/types-chunks/{base.d-Cz_rwpOi.d.ts → base.d-ChvpaKjZ.d.ts} +1 -1
  57. package/dist/types-chunks/{bash-prefix-extractor.d-CHJO5y94.d.ts → bash-prefix-extractor.d-bApf5nGw.d.ts} +3 -3
  58. package/dist/types-chunks/{capability-learning.d-_lR0J4iR.d.ts → capability-learning.d-DPrYxRjF.d.ts} +1 -1
  59. package/dist/types-chunks/{capsule.d-DxtdE-GD.d.ts → capsule.d-CGWltwno.d.ts} +2 -2
  60. package/dist/types-chunks/{commands.d-DZxHzH5-.d.ts → commands.d-CEHGwRok.d.ts} +62 -6
  61. package/dist/types-chunks/{guardrail.d-DlpMnd-Y.d.ts → guardrail.d-CC4vAQl7.d.ts} +2 -1
  62. package/dist/types-chunks/{guardrail.d-auV61_h5.d.ts → guardrail.d-CXIPlWP3.d.ts} +10 -10
  63. package/dist/types-chunks/{public-api.d--IDNJsu1.d.ts → public-api.d-FBmX0kxo.d.ts} +4 -3
  64. package/dist/types-chunks/{run-manager.d-Bh50OdVl.d.ts → run-manager.d-DUNnJcpE.d.ts} +1 -1
  65. package/dist/types-chunks/{sdk-session-Cfw6NFu-.d.ts → sdk-session-XqacVOs8.d.ts} +3 -3
  66. package/dist/types-chunks/{resolver.d-ssgNSlrh.d.ts → side-query.d-DWTMsndP.d.ts} +68 -5
  67. package/dist/types-chunks/{types.d-DH1mvdcl.d.ts → types.d-BnPhGmar.d.ts} +3 -1
  68. package/dist/types-chunks/{types.d-Cqaw71Ax.d.ts → types.d-CSmF0t0n.d.ts} +6 -5
  69. package/dist/types-chunks/{types.d-EqQmHztg.d.ts → types.d-DKr6TCXL.d.ts} +16 -9
  70. package/dist/types-chunks/{types.d-CNZgY52F.d.ts → types.d-DgciGHoG.d.ts} +2 -2
  71. package/dist/types-chunks/{utils.d-gmn3c5U4.d.ts → utils.d-BPYX7-KN.d.ts} +94 -10
  72. package/docs/SDK_EMBEDDER_GUIDE.md +128 -21
  73. package/package.json +2 -2
  74. package/dist/chunks/argument-completer-QZETLNAB.js +0 -2
  75. package/dist/chunks/chunk-23X6REO4.js +0 -46
  76. package/dist/chunks/chunk-CLFP6UGU.js +0 -71
  77. package/dist/chunks/chunk-EDZ5KJFT.js +0 -5
  78. package/dist/chunks/chunk-GIK4SGAT.js +0 -364
  79. package/dist/chunks/chunk-GVWPHE23.js +0 -310
  80. package/dist/chunks/chunk-VDGCGOQH.js +0 -328
  81. package/dist/chunks/chunk-VVE3UM4F.js +0 -410
  82. package/dist/chunks/chunk-ZJIMT5I3.js +0 -78
  83. package/dist/chunks/compaction-config-TWCDFLX6.js +0 -2
  84. package/dist/chunks/dist-JT4ATXVM.js +0 -2
  85. package/dist/chunks/host-SVEDZUC5.js +0 -2
  86. package/dist/chunks/run-manager-RX42UNEM.js +0 -2
@@ -0,0 +1,5 @@
1
+ // @kodax-ai/kodax — bundled distribution. See docs/ADR.md ADR-022 + ADR-024.
2
+ import{g as R,h as _}from"./chunk-F7AIEHSS.js";import{a as r}from"./chunk-ONUPGMER.js";var u=class extends Error{static{r(this,"KodaXMediaError")}code;detail;cause;constructor(e,i,o={}){super(i),this.name="KodaXMediaError",this.code=e,this.detail=o.detail,this.cause=o.cause}},p=class extends u{static{r(this,"ImageResizeError")}constructor(e,i={}){super(i.code??"IMAGE_TOO_LARGE",e,i),this.name="ImageResizeError"}};import O from"node:path";var Z={".gif":"image/gif",".jpeg":"image/jpeg",".jpg":"image/jpeg",".png":"image/png",".webp":"image/webp"},ee={".3gp":"video/3gpp",".3gpp":"video/3gpp",".avi":"video/x-msvideo",".flv":"video/x-flv",".mov":"video/quicktime",".mp4":"video/mp4",".mpeg":"video/mpeg",".mpg":"video/mpeg",".webm":"video/webm",".wmv":"video/x-ms-wmv"};function N(t){return Z[O.extname(t).toLowerCase()]}r(N,"inferImageMediaType");function $(t){return ee[O.extname(t).toLowerCase()]}r($,"inferVideoMediaType");function te(t,e={}){let i=e.mediaType??N(t);return{kind:"image",path:t,...i?{mediaType:i}:{},...e.source?{source:e.source}:{},...e.description?{description:e.description}:{}}}r(te,"createImageArtifactFromPath");function ie(t,e={}){if(e.mediaType!==void 0&&e.mimeType!==void 0&&e.mediaType!==e.mimeType)throw new u("UNSUPPORTED_MEDIA_TYPE",`File artifact mediaType and mimeType disagree: ${e.mediaType} != ${e.mimeType}.`);return{kind:"file",path:t,...e.mediaType?{mediaType:e.mediaType}:{},...e.mimeType?{mimeType:e.mimeType}:{},...e.name?{name:e.name}:{},...e.source?{source:e.source}:{},...e.description?{description:e.description}:{}}}r(ie,"createFileArtifactFromPath");function re(t,e={}){let i=e.mediaType??$(t);if(!i)throw new u("UNSUPPORTED_MEDIA_TYPE",`Cannot infer video media type from path: ${t}.`);return{kind:"video",path:t,mediaType:i,...e.name?{name:e.name}:{},...e.source?{source:e.source}:{},...e.description?{description:e.description}:{}}}r(re,"createVideoArtifactFromPath");import{Jimp as ne}from"jimp";var F=2e3,C=Math.floor(3.75*1024*1024),oe=[80,60,40];async function A(t,e={}){let i=e.maxDimension??F,o=e.targetBytes??C;if(t.length===0)throw new p("Empty image buffer.",{code:"IMAGE_DECODE_FAILED"});let n;try{n=await ne.read(t)}catch(c){let I=c instanceof Error?c.message:String(c);throw new p(`Failed to decode image: ${I}`,{code:"IMAGE_DECODE_FAILED",cause:c})}let{width:a,height:d}=n.bitmap,s=Math.max(a,d);if(s>i){let c=i/s;n.resize({w:Math.max(1,Math.round(a*c)),h:Math.max(1,Math.round(d*c))})}let m=n.bitmap.width,l=n.bitmap.height;if(e.preferMediaType!=="image/jpeg"){let c=await n.getBuffer("image/png");if(c.length<=o)return{buffer:Buffer.from(c),mediaType:"image/png",width:m,height:l}}for(let c of oe){let I=await n.getBuffer("image/jpeg",{quality:c});if(I.length<=o)return{buffer:Buffer.from(I),mediaType:"image/jpeg",width:m,height:l}}if(e.preferMediaType==="image/jpeg"){let c=await n.getBuffer("image/png");if(c.length<=o)return{buffer:Buffer.from(c),mediaType:"image/png",width:m,height:l}}throw new p(`Image still exceeds budget (${o} bytes raw) after PNG and JPEG q40 compression. Try a smaller image or take a fresh screenshot of a smaller region.`,{code:"IMAGE_TOO_LARGE"})}r(A,"normalizePastedImage");import{spawn as L}from"node:child_process";import{mkdtemp as ae,readFile as se,rm as de}from"node:fs/promises";import{tmpdir as me}from"node:os";import U from"node:path";var q=5e3;async function X(){switch(process.platform){case"darwin":return ce();case"win32":return fe();case"linux":return pe();default:throw new u("UNSUPPORTED_PLATFORM",`Clipboard image fallback is not supported on platform "${process.platform}".`)}}r(X,"readClipboardImage");async function ue(t={}){let e=await X();return e?A(e,t):null}r(ue,"readAndNormalizeClipboardImage");async function j(t){let e=await ae(U.join(me(),"kodax-clip-")),i=U.join(e,"clip.png");try{return await t(i)}finally{await de(e,{recursive:!0,force:!0}).catch(o=>{})}}r(j,"runWithTempPng");async function ce(){return j(async t=>{let e=`set png_data to (the clipboard as \xABclass PNGf\xBB)
3
+ set fh to open for access POSIX file "${t.replace(/"/g,'\\"')}" with write permission
4
+ write png_data to fh
5
+ close access fh`;return await G("osascript",["-e",e])?B(t):null})}r(ce,"readMacClipboard");async function fe(){return j(async t=>{let e=["Add-Type -AssemblyName System.Drawing | Out-Null","$img = Get-Clipboard -Format Image","if ($null -eq $img) { exit 1 }",`$img.Save('${t.replace(/'/g,"''")}', [System.Drawing.Imaging.ImageFormat]::Png)`].join("; ");return await G("powershell",["-NoProfile","-Command",e])?B(t):null})}r(fe,"readWinClipboard");async function pe(){return await K("wl-paste",["--type","image/png"])??K("xclip",["-selection","clipboard","-t","image/png","-o"])}r(pe,"readLinuxClipboard");async function B(t){try{let e=await se(t);return e.length>0?e:null}catch(e){return null}}r(B,"readNonEmptyFile");function G(t,e){return new Promise(i=>{let o=!1,n=L(t,[...e],{stdio:"ignore"}),a=setTimeout(()=>{o||(o=!0,n.kill(),i(!1))},q);n.once("error",()=>{o||(o=!0,clearTimeout(a),i(!1))}),n.once("exit",d=>{o||(o=!0,clearTimeout(a),i(d===0))})})}r(G,"runCommand");function K(t,e){return new Promise(i=>{let o=!1,n=[],a=L(t,[...e],{stdio:["ignore","pipe","ignore"]}),d=setTimeout(()=>{o||(o=!0,a.kill(),i(null))},q);a.stdout?.on("data",s=>n.push(s)),a.once("error",()=>{o||(o=!0,clearTimeout(d),i(null))}),a.once("exit",s=>{if(o)return;if(o=!0,clearTimeout(d),s!==0){i(null);return}let m=Buffer.concat(n);i(m.length>0?m:null)})})}r(K,"collectStdoutBytes");import{createHash as le}from"node:crypto";import{mkdir as ge,readdir as he,stat as Te,unlink as ye,writeFile as Ie}from"node:fs/promises";import{tmpdir as Ee}from"node:os";import x from"node:path";var Y="KODAX_PASTE_TMP_DIR",z=1440*60*1e3;function Q(){return process.env[Y]??x.join(Ee(),"kodax-paste")}r(Q,"resolvePasteTmpDir");function we(t){let e=t?.trim().replace(/[^A-Za-z0-9._-]+/g,"-").replace(/^-+|-+$/g,"");return e&&e.length>0?e:"paste"}r(we,"sanitizeFileNamePrefix");async function _e(t,e={}){let i=e.directory??Q();await ge(i,{recursive:!0});let o=t.mediaType==="image/jpeg"?".jpg":".png",n=le("sha256").update(t.buffer).digest("hex").slice(0,16),a=`${we(e.fileNamePrefix)}-${n}${o}`,d=x.join(i,a);return await Ie(d,t.buffer),{type:"image",path:d,mediaType:t.mediaType}}r(_e,"persistImageAsBlock");async function Ae(t=Date.now()){let e=Q(),i;try{i=await he(e)}catch(a){return 0}let o=t-z,n=0;return await Promise.all(i.filter(a=>/-[0-9a-f]{16}\.(?:png|jpg)$/.test(a)).map(async a=>{let d=x.join(e,a);try{(await Te(d)).mtimeMs<o&&(await ye(d),n+=1)}catch(s){}})),n}r(Ae,"prunePasteTmpDir");var h=["image/png","image/jpeg","image/webp","image/gif"],T=["video/mp4","video/mpeg","video/quicktime","video/x-msvideo","video/x-flv","video/webm","video/x-ms-wmv","video/3gpp"],xe=[],ke=new Set(["anthropic","openai"]),Me=new Set(["ark-coding/doubao-seed-2.0-code","ark-coding/doubao-seed-2.0-pro","ark-coding/kimi-k2.6","ark-coding/kimi-k2.7-code","ark-coding/minimax-m3","qwen-token-plan/qwen3.8-max-preview","qwen-token-plan/qwen3.7-plus","qwen-token-plan/qwen3.6-flash"]),De=new Set(["kimi-code/kimi-for-coding","kimi-code/kimi-for-coding-highspeed","kimi-code/k3","kimi/kimi-k2.5","kimi/kimi-k2.6","kimi/kimi-k2.7-code","kimi/kimi-k2.7-code-highspeed","minimax-coding/minimax-m3","minimax/minimax-m3","mimo-coding/mimo-v2.5","mimo/mimo-v2.5"]);function k(t){return{nativeSupported:!1,sdkSupported:!1,status:"unsupported",mediaTypes:[],maxCount:0,reason:t}}r(k,"unsupported");function Pe(t){return{nativeSupported:!0,sdkSupported:!0,status:"supported",mediaTypes:h,nativeMediaTypes:h,reason:t}}r(Pe,"supportedImage");function ve(t){return{nativeSupported:!0,sdkSupported:!1,status:"provider-native-unwired",mediaTypes:[],nativeMediaTypes:T,maxCount:0,reason:t}}r(ve,"nativeVideoUnwired");function Se(t){return t.trim().toLowerCase()}r(Se,"normalizeProvider");function be(t){return _[t]?.model}r(be,"resolveProviderDefaultModel");function V(t,e){if(!e)return;let i=e.trim().toLowerCase();if(t==="kimi"){if(i==="k2.5")return"kimi-k2.5";if(i==="k2.6")return"kimi-k2.6";if(i==="k2.7-code")return"kimi-k2.7-code";if(i==="k2.7-code-highspeed")return"kimi-k2.7-code-highspeed"}return t==="kimi-code"&&i==="k3-256k"?"k3":(t==="minimax-coding"||t==="minimax")&&i==="minimax-m3"?"minimax-m3":i}r(V,"normalizeModel");function Re(t){if(!ke.has(t))return!1;let e=_[t];return e?R(e.capabilityProfile).multimodalSupport!=="none":!1}r(Re,"hasOfficialImageSupport");function Oe(t,e){let i=V(t,e);if(!i)return!1;let o=`${t}/${i}`;return De.has(o)}r(Oe,"hasSourceBackedNativeMedia");function Ne(t,e){let i=V(t,e);return i?Me.has(`${t}/${i}`):!1}r(Ne,"hasSourceBackedImage");function $e(t,e,i){if(i)return"source-backed";if(e){if(t==="openai")return"openai-official";if(t==="anthropic")return"anthropic-official"}}r($e,"resolveImageCapabilityRoute");function Fe(t){switch(t){case"openai-official":return"Model route supports KodaX image input. Direct-path image/gif is sent as image/gif, but OpenAI requires non-animated GIF semantics.";case"anthropic-official":return"Model route supports KodaX image input. Direct-path image/gif is sent as image/gif, but Anthropic uses only the first frame of animated GIFs.";case"source-backed":return"Model route supports KodaX image input. Direct-path image/gif is sent as image/gif; animated-GIF interpretation is provider-owned."}}r(Fe,"imageCapabilityReason");function M(t){let e=Se(t.provider),i=t.model?.trim()||be(e),o=Re(e),n=Oe(e,i),a=n||Ne(e,i),d=$e(e,o,a),s=d!==void 0,m=n;return{text:!0,image:s?Pe(Fe(d)):k("No verified KodaX image-input route for this provider/model."),video:m?ve("Model route is native-video capable, but KodaX SDK video sending is not wired yet. Reject or downgrade before send."):k("No verified native video route for this provider/model."),file:k("File artifact contract is stable, but KodaX SDK file sending/extraction is not wired yet. Reject or downgrade before send.")}}r(M,"getModelInputCapabilities");function Ce(t){return h.includes(t)}r(Ce,"isKnownImageMediaType");function Ue(t){return T.includes(t)}r(Ue,"isKnownVideoMediaType");function D(t){return`${t.provider}${t.model?`/${t.model}`:""}`}r(D,"routeLabel");function P(t){return t.reason?`${t.status}: ${t.reason}`:t.status}r(P,"capabilityDetail");function v(t,e){if(t.length===0)return;let i=M(e);for(let o of t){let n=o;if(n.kind==="image"){if(!i.image.nativeSupported||!i.image.sdkSupported)throw new u("MODEL_INPUT_UNSUPPORTED",`Provider/model cannot consume image artifacts: ${D(e)}.`,{detail:P(i.image)});if(typeof n.mediaType=="string"&&!Ce(n.mediaType))throw new u("UNSUPPORTED_MEDIA_TYPE",`Unsupported image media type: ${n.mediaType}.`);continue}throw n.kind==="video"?typeof n.mediaType!="string"||!Ue(n.mediaType)?new u("UNSUPPORTED_MEDIA_TYPE",`Unsupported video media type: ${String(n.mediaType)}.`,{detail:`Supported video media types: ${T.join(", ")}`}):new u("MODEL_INPUT_UNSUPPORTED",`Provider/model cannot consume video artifacts through this SDK runtime: ${D(e)}.`,{detail:P(i.video)}):n.kind==="file"?typeof n.mediaType=="string"&&typeof n.mimeType=="string"&&n.mediaType!==n.mimeType?new u("UNSUPPORTED_MEDIA_TYPE",`File artifact mediaType and mimeType disagree: ${n.mediaType} != ${n.mimeType}.`):new u("MODEL_INPUT_UNSUPPORTED",`Provider/model cannot consume file artifacts through this SDK runtime: ${D(e)}.`,{detail:P(i.file)}):new u("MODEL_INPUT_UNSUPPORTED",`Unsupported input artifact kind: ${String(n.kind)}.`)}}r(v,"validateInputArtifactsForModel");var g={user:0,background:1};function Ke(t,e){return g[t]<=g[e]}r(Ke,"priorityWithinMax");function W(t,e){return!(t.agentId!==e.agentId||!Ke(t.priority,e.maxPriority)||e.mode!==void 0&&t.mode!==e.mode||e.id!==void 0&&t.id!==e.id||e.predicate&&!e.predicate(t))}r(W,"matchesFilter");var w=class{static{r(this,"MessageQueue")}messages=[];nextSeq=1;listeners=new Set;snapshotRef=Object.freeze([]);notify(e){this.snapshotRef=Object.freeze([...this.messages]);for(let i of this.listeners)try{i(e)}catch{}}subscribe=r(e=>(this.listeners.add(e),()=>{this.listeners.delete(e)}),"subscribe");getSnapshot=r(()=>this.snapshotRef,"getSnapshot");enqueue(e){let i=`msg-${this.nextSeq++}`,o={id:i,priority:e.priority,mode:e.mode,content:e.content,agentId:e.agentId,inputArtifacts:e.inputArtifacts,taskResult:e.taskResult,enqueuedAt:Date.now()};return this.messages=[...this.messages,o],this.notify({kind:"enqueued",message:o}),i}dequeue(e){let i=[];for(let s=0;s<this.messages.length;s++){let m=this.messages[s];m&&W(m,e)&&i.push({originalIndex:s,message:m})}i.sort((s,m)=>{let l=g[s.message.priority]-g[m.message.priority];return l!==0?l:s.originalIndex-m.originalIndex});let o=e.limit,n=typeof o=="number"&&i.length>o?i.slice(0,o):i;if(n.length===0)return[];let a=new Set(n.map(s=>s.originalIndex));this.messages=this.messages.filter((s,m)=>!a.has(m));let d=n.map(s=>s.message);return this.notify({kind:"dequeued",messages:d}),d}peek(e){let i=[];for(let a=0;a<this.messages.length;a++){let d=this.messages[a];d&&W(d,e)&&i.push({originalIndex:a,message:d})}i.sort((a,d)=>{let s=g[a.message.priority]-g[d.message.priority];return s!==0?s:a.originalIndex-d.originalIndex});let o=e.limit;return(typeof o=="number"&&i.length>o?i.slice(0,o):i).map(a=>a.message)}size(){return this.messages.length}count(e){return this.peek(e).length}has(e){return this.count(e)>0}clear(){if(this.messages.length===0)return;let e=this.messages;this.messages=[],this.notify({kind:"cleared",messages:e})}},E;function y(){return E||(E=new w),E}r(y,"getMessageQueue");function Le(){E=void 0}r(Le,"_resetMessageQueueForTests");function S(t,e){return t?`actor:${t}:${e}`:e==="/root"?void 0:e}r(S,"actorQueueId");var f=new Map;function qe(t){f.set(t,(f.get(t)??0)+1);let e=!1;return()=>{if(e)return;e=!0;let i=f.get(t);i===void 0||i<=1?f.delete(t):f.set(t,i-1)}}r(qe,"registerActiveRootQueueRoute");function b(){if(f.size!==0){if(f.size===1)return f.keys().next().value;throw new Error("Cannot infer queued follow-up target: multiple Actor root sessions are active. Pass sessionId or agentId explicitly.")}}r(b,"resolveActiveRootQueueRoute");function Xe(){f.clear()}r(Xe,"_resetActiveRootQueueRoutesForTests");var H=new Set;function J(t){return t.some(i=>H.has(i))?"background":"user"}r(J,"midTurnDrainPriority");function je(t){let e=J(t.lastTurnToolNames);return y().dequeue({agentId:t.agentId,maxPriority:e,limit:t.limit})}r(je,"maybeDrainMidTurn");function Be(t){if(v(t.inputArtifacts??[],t),t.agentId!==void 0&&t.sessionId!==void 0)throw new Error("enqueueWithArtifacts accepts either agentId or sessionId, not both.");if(t.sessionId!==void 0&&t.sessionId.trim().length===0)throw new Error("enqueueWithArtifacts sessionId must not be empty.");let e=t.agentId??(t.sessionId!==void 0?S(t.sessionId,"/root"):b());return y().enqueue({priority:t.priority??"user",mode:"prompt",content:t.content,agentId:e,inputArtifacts:t.inputArtifacts})}r(Be,"enqueueWithArtifacts");export{u as a,p as b,N as c,$ as d,te as e,ie as f,re as g,F as h,C as i,A as j,X as k,ue as l,Y as m,z as n,_e as o,Ae as p,h as q,T as r,xe as s,M as t,v as u,w as v,y as w,Le as x,S as y,qe as z,b as A,Xe as B,H as C,J as D,je as E,Be as F};