mu-agent 0.1.7 → 0.1.10

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 (198) hide show
  1. package/CHANGELOG.md +52 -0
  2. package/README.md +34 -29
  3. package/dist/bundle/chunks/anthropic-messages-4PAJY4R6.js +6 -0
  4. package/dist/bundle/chunks/anthropic.js +2 -2
  5. package/dist/bundle/chunks/azure-openai-responses-Y4BBWQ3N.js +2 -0
  6. package/dist/bundle/chunks/bedrock-converse-stream.js +12 -9
  7. package/dist/bundle/chunks/{chunk-TRDNDS6A.js → chunk-3V45WARH.js} +6 -3
  8. package/dist/bundle/chunks/{chunk-XDUWOHPL.js → chunk-5AGIVGSV.js} +3 -3
  9. package/dist/bundle/chunks/chunk-6QGV3IWD.js +6 -0
  10. package/dist/bundle/chunks/chunk-7CBJINYJ.js +20 -0
  11. package/dist/bundle/chunks/{chunk-DRQDKNXA.js → chunk-7DDKXS2Q.js} +1 -1
  12. package/dist/bundle/chunks/chunk-BSS6T6KQ.js +2 -0
  13. package/dist/bundle/chunks/chunk-CF5GWZHW.js +31 -0
  14. package/dist/bundle/chunks/chunk-DNNHZBQR.js +4 -0
  15. package/dist/bundle/chunks/chunk-FN6OEZYR.js +2 -0
  16. package/dist/bundle/chunks/chunk-FTJT2X6E.js +2 -0
  17. package/dist/bundle/chunks/chunk-HZNN636Z.js +130 -0
  18. package/dist/bundle/chunks/{chunk-4L3WN2XY.js → chunk-JXWJOIH4.js} +1 -1
  19. package/dist/bundle/chunks/{chunk-4O2SCVYF.js → chunk-KIDDRTZP.js} +4 -4
  20. package/dist/bundle/chunks/chunk-LMNWTX2L.js +11 -0
  21. package/dist/bundle/chunks/chunk-LPXNMA2W.js +2 -0
  22. package/dist/bundle/chunks/{chunk-6CYCI3EJ.js → chunk-LVVZS2NO.js} +1 -1
  23. package/dist/bundle/chunks/chunk-NN4BEPYX.js +2 -0
  24. package/dist/bundle/chunks/chunk-O7IPTASE.js +1221 -0
  25. package/dist/bundle/chunks/chunk-PMRZO46Y.js +2 -0
  26. package/dist/bundle/chunks/chunk-QOEEJKS4.js +9 -0
  27. package/dist/bundle/chunks/chunk-R4VPBBDS.js +2 -0
  28. package/dist/bundle/chunks/chunk-RAQ6TU76.js +2 -0
  29. package/dist/bundle/chunks/chunk-RDZVAGPR.js +2 -0
  30. package/dist/bundle/chunks/chunk-SGOTYFMT.js +91 -0
  31. package/dist/bundle/chunks/chunk-TMTOQ7H7.js +2 -0
  32. package/dist/bundle/chunks/chunk-UKVNB6C4.js +2 -0
  33. package/dist/bundle/chunks/chunk-VJLOQZKR.js +9 -0
  34. package/dist/bundle/chunks/chunk-WCGU75WO.js +11 -0
  35. package/dist/bundle/chunks/chunk-X234222Q.js +64 -0
  36. package/dist/bundle/chunks/cli-722OL3K5.js +51 -0
  37. package/dist/bundle/chunks/cloudflare-workers-ai-system-one-MEZHQVNP.js +2 -0
  38. package/dist/bundle/chunks/codemode-worker.js +478 -0
  39. package/dist/bundle/chunks/easter-egg-3d-6H34EDGX.js +2 -0
  40. package/dist/bundle/chunks/execute-KVSEIDWL.js +499 -0
  41. package/dist/bundle/chunks/github-copilot.js +1 -1
  42. package/dist/bundle/chunks/{google-generative-ai-C44KRRZ4.js → google-generative-ai-D2VJQBTK.js} +1 -1
  43. package/dist/bundle/chunks/{google-vertex-25DUXPTJ.js → google-vertex-SQG2BO6C.js} +1 -1
  44. package/dist/bundle/chunks/https-proxy-agent-LVOO5TPL.js +13 -0
  45. package/dist/bundle/chunks/image-resize-worker.js +1 -1
  46. package/dist/bundle/chunks/{jiti-loader-C3NU2SDH.js → jiti-loader-GL4HJFAD.js} +1 -1
  47. package/dist/bundle/chunks/{jiti-static-loader-E6ANQD5T.js → jiti-static-loader-2RCDI6B4.js} +1 -1
  48. package/dist/bundle/chunks/{lib-HGQMNYVT.js → lib-4AVRLBHM.js} +2 -2
  49. package/dist/bundle/chunks/llama-cpp-classify-5YHLY3RC.js +22 -0
  50. package/dist/bundle/chunks/mistral-conversations-BDARVJTT.js +5 -0
  51. package/dist/bundle/chunks/{multipart-parser-SQ6GDJL7.js → multipart-parser-FMGQ7342.js} +1 -1
  52. package/dist/bundle/chunks/{node-TWVVAGPO.js → node-AUOGOBCN.js} +1 -1
  53. package/dist/bundle/chunks/node-KCMANYC2.js +16 -0
  54. package/dist/bundle/chunks/openai-chatgpt.js +86 -0
  55. package/dist/bundle/chunks/openai-codex-responses-CECGTDYD.js +10 -0
  56. package/dist/bundle/chunks/openai-codex.js +2 -2
  57. package/dist/bundle/chunks/openai-completions-UOA7MELD.js +7 -0
  58. package/dist/bundle/chunks/openai-decisions-HLM372N6.js +5 -0
  59. package/dist/bundle/chunks/openai-responses-TII7ZY5X.js +3 -0
  60. package/dist/bundle/chunks/{openrouter-images-JVEJN44Q.js → openrouter-images-7T452AS5.js} +1 -1
  61. package/dist/bundle/chunks/openrouter.js +2 -2
  62. package/dist/bundle/chunks/{pi-messages-TM5SOOIW.js → pi-messages-2UDKLKOO.js} +1 -1
  63. package/dist/bundle/chunks/radius.js +2 -2
  64. package/dist/bundle/chunks/runtime-O3ELDOM7.js +2 -0
  65. package/dist/bundle/chunks/{src-UK77SYZE.js → src-QKGKDFSU.js} +1 -1
  66. package/dist/bundle/chunks/typesafe-system-one-KNCICMO5.js +2 -0
  67. package/dist/bundle/chunks/virtual-modules-IKEARUOZ.js +2 -0
  68. package/dist/bundle/cli-runtime.js +1 -1
  69. package/dist/bundle/index.js +1 -1
  70. package/dist/bundle/native/darwin/prebuilds/darwin-arm64/darwin-platform.node +0 -0
  71. package/dist/bundle/native/darwin/prebuilds/darwin-x64/darwin-platform.node +0 -0
  72. package/dist/bundle/rpc-entry.js +1 -1
  73. package/dist/core/export-html/template.js +37 -16
  74. package/dist/modes/interactive/theme/dark.json +60 -73
  75. package/dist/modes/interactive/theme/light.json +58 -70
  76. package/dist/modes/interactive/theme/system-theme.d.ts +55 -0
  77. package/dist/modes/interactive/theme/system-theme.d.ts.map +1 -0
  78. package/dist/modes/interactive/theme/system-theme.js +546 -0
  79. package/dist/modes/interactive/theme/system-theme.js.map +1 -0
  80. package/dist/modes/interactive/theme/theme-controller.d.ts +43 -9
  81. package/dist/modes/interactive/theme/theme-controller.d.ts.map +1 -1
  82. package/dist/modes/interactive/theme/theme-controller.js +121 -79
  83. package/dist/modes/interactive/theme/theme-controller.js.map +1 -1
  84. package/dist/modes/interactive/theme/theme-schema.d.ts +28 -0
  85. package/dist/modes/interactive/theme/theme-schema.d.ts.map +1 -0
  86. package/dist/modes/interactive/theme/theme-schema.js +105 -0
  87. package/dist/modes/interactive/theme/theme-schema.js.map +1 -0
  88. package/dist/modes/interactive/theme/theme-tokens.d.ts +257 -0
  89. package/dist/modes/interactive/theme/theme-tokens.d.ts.map +1 -0
  90. package/dist/modes/interactive/theme/theme-tokens.js +94 -0
  91. package/dist/modes/interactive/theme/theme-tokens.js.map +1 -0
  92. package/dist/modes/interactive/theme/theme.d.ts +47 -56
  93. package/dist/modes/interactive/theme/theme.d.ts.map +1 -1
  94. package/dist/modes/interactive/theme/theme.js +149 -143
  95. package/dist/modes/interactive/theme/theme.js.map +1 -1
  96. package/dist/native/darwin/prebuilds/darwin-arm64/darwin-platform.node +0 -0
  97. package/dist/native/darwin/prebuilds/darwin-x64/darwin-platform.node +0 -0
  98. package/docs/cli-integration.md +1 -1
  99. package/docs/cli.md +78 -13
  100. package/docs/codemode.md +230 -0
  101. package/docs/compaction.md +5 -5
  102. package/docs/configuration.md +2 -0
  103. package/docs/custom-provider.md +53 -1
  104. package/docs/docs.json +21 -1
  105. package/docs/environment-variables.md +5 -3
  106. package/docs/extensions.md +172 -10
  107. package/docs/index.md +1 -1
  108. package/docs/json.md +3 -3
  109. package/docs/keybindings.md +7 -6
  110. package/docs/llama-cpp.md +21 -1
  111. package/docs/mcp.md +272 -0
  112. package/docs/message-types.md +22 -4
  113. package/docs/models-configuration.md +187 -0
  114. package/docs/models.md +100 -2
  115. package/docs/nvidia-rtx-llama-cpp.md +96 -0
  116. package/docs/packages.md +1 -1
  117. package/docs/providers.md +66 -6
  118. package/docs/quickstart.md +16 -2
  119. package/docs/rpc-commands.md +9 -3
  120. package/docs/rpc.md +3 -1
  121. package/docs/sdk.md +8 -3
  122. package/docs/security.md +2 -0
  123. package/docs/session-format.md +5 -1
  124. package/docs/sessions.md +1 -1
  125. package/docs/settings.md +30 -8
  126. package/docs/terminal-setup.md +14 -0
  127. package/docs/themes.md +31 -7
  128. package/docs/tui.md +71 -1
  129. package/docs/usage.md +2 -2
  130. package/docs/virtual-models.md +114 -0
  131. package/docs/windows.md +2 -0
  132. package/examples/README.md +1 -4
  133. package/examples/extensions/README.md +1 -0
  134. package/examples/extensions/built-in-tool-renderer.ts +16 -40
  135. package/examples/extensions/custom-provider-anthropic/package-lock.json +2 -2
  136. package/examples/extensions/custom-provider-anthropic/package.json +1 -1
  137. package/examples/extensions/custom-provider-gitlab-duo/package.json +1 -1
  138. package/examples/extensions/custom-provider-gitlab-duo/test.ts +5 -5
  139. package/examples/extensions/dynamic-resources/dynamic.json +1 -1
  140. package/examples/extensions/gondolin/package-lock.json +2 -2
  141. package/examples/extensions/gondolin/package.json +1 -1
  142. package/examples/extensions/jev-router.ts +113 -0
  143. package/examples/extensions/minimal-mode.ts +28 -101
  144. package/examples/extensions/overlay-test.ts +2 -2
  145. package/examples/extensions/plan-mode/index.ts +6 -2
  146. package/examples/extensions/sandbox/package-lock.json +2 -2
  147. package/examples/extensions/sandbox/package.json +1 -1
  148. package/examples/extensions/subagent/index.ts +4 -6
  149. package/examples/extensions/with-deps/package-lock.json +2 -2
  150. package/examples/extensions/with-deps/package.json +1 -1
  151. package/examples/rpc-client.ts +1 -1
  152. package/examples/rpc-extension-ui.ts +1 -1
  153. package/examples/sdk/14-codemode-mcp.ts +61 -0
  154. package/examples/sdk/README.md +2 -1
  155. package/judge/THIRD_PARTY_NOTICES.md +63 -0
  156. package/judge/dist/auth.js +169 -123
  157. package/judge/dist/import.js +36 -30
  158. package/judge/dist/setup.js +250 -120
  159. package/judge/manifest.json +1008 -316
  160. package/judge/{dist/kyrn-judge.js → mu/index.js} +6933 -5995
  161. package/judge/themes/mu-dark.json +80 -0
  162. package/judge/themes/mu-light.json +80 -0
  163. package/kyrn/bin/kyrn-doctor +75 -25
  164. package/kyrn/bin/kyrn-judge-local +2 -2
  165. package/kyrn/bin/kyrn-ledger +1 -1
  166. package/kyrn/bin/mu.mjs +149 -107
  167. package/package.json +4 -5
  168. package/dist/bundle/chunks/anthropic-messages-VMESUHQ7.js +0 -6
  169. package/dist/bundle/chunks/azure-openai-responses-K232MQFF.js +0 -2
  170. package/dist/bundle/chunks/chunk-A3JYRWB6.js +0 -2
  171. package/dist/bundle/chunks/chunk-AYFRR3OD.js +0 -2
  172. package/dist/bundle/chunks/chunk-DTD7JQ7Y.js +0 -42
  173. package/dist/bundle/chunks/chunk-FU4XQUSL.js +0 -11
  174. package/dist/bundle/chunks/chunk-GNYZK6XN.js +0 -2
  175. package/dist/bundle/chunks/chunk-HEMXN7VJ.js +0 -1653
  176. package/dist/bundle/chunks/chunk-MVPXOVOJ.js +0 -2
  177. package/dist/bundle/chunks/chunk-NUHFSC37.js +0 -25
  178. package/dist/bundle/chunks/chunk-V7IXECST.js +0 -11
  179. package/dist/bundle/chunks/chunk-XNGRGP62.js +0 -2
  180. package/dist/bundle/chunks/cloudflare-workers-ai-system-one-NR2TDCXU.js +0 -2
  181. package/dist/bundle/chunks/https-proxy-agent-2VXB7436.js +0 -13
  182. package/dist/bundle/chunks/mistral-conversations-6IHQOR4R.js +0 -5
  183. package/dist/bundle/chunks/node-O3RIBJRH.js +0 -16
  184. package/dist/bundle/chunks/openai-codex-responses-3UAYOSSR.js +0 -10
  185. package/dist/bundle/chunks/openai-completions-FIEQGWAH.js +0 -7
  186. package/dist/bundle/chunks/openai-responses-OZJXLHFC.js +0 -2
  187. package/dist/bundle/chunks/typesafe-system-one-VKYX4OGY.js +0 -2
  188. package/dist/bundle/chunks/virtual-modules-V7SXVVLP.js +0 -2
  189. package/dist/modes/interactive/theme/theme-json.d.ts +0 -85
  190. package/dist/modes/interactive/theme/theme-json.d.ts.map +0 -1
  191. package/dist/modes/interactive/theme/theme-json.js +0 -132
  192. package/dist/modes/interactive/theme/theme-json.js.map +0 -1
  193. package/dist/modes/interactive/theme/theme-schema.json +0 -361
  194. package/examples/plugins/pi-example-plugin/README.md +0 -38
  195. package/examples/plugins/pi-example-plugin/package.json +0 -10
  196. package/examples/plugins/pi-example-plugin/src/contract.ts +0 -13
  197. package/examples/plugins/pi-example-plugin/src/session.ts +0 -24
  198. package/examples/plugins/pi-example-plugin/src/tui.ts +0 -31
@@ -1,4 +1,7 @@
1
1
  import { createRequire as __piCreateRequire } from "node:module"; const require = __piCreateRequire(import.meta.url);
2
- import{__commonJS,__toESM}from"./chunk-4L3WN2XY.js";var require_options=__commonJS({"node_modules/partial-json/dist/options.js"(exports){"use strict";Object.defineProperty(exports,"__esModule",{value:!0});exports.Allow=exports.ALL=exports.COLLECTION=exports.ATOM=exports.SPECIAL=exports.INF=exports._INFINITY=exports.INFINITY=exports.NAN=exports.BOOL=exports.NULL=exports.OBJ=exports.ARR=exports.NUM=exports.STR=void 0;exports.STR=1;exports.NUM=2;exports.ARR=4;exports.OBJ=8;exports.NULL=16;exports.BOOL=32;exports.NAN=64;exports.INFINITY=128;exports._INFINITY=256;exports.INF=exports.INFINITY|exports._INFINITY;exports.SPECIAL=exports.NULL|exports.BOOL|exports.INF|exports.NAN;exports.ATOM=exports.STR|exports.NUM|exports.SPECIAL;exports.COLLECTION=exports.ARR|exports.OBJ;exports.ALL=exports.ATOM|exports.COLLECTION;exports.Allow={STR:exports.STR,NUM:exports.NUM,ARR:exports.ARR,OBJ:exports.OBJ,NULL:exports.NULL,BOOL:exports.BOOL,NAN:exports.NAN,INFINITY:exports.INFINITY,_INFINITY:exports._INFINITY,INF:exports.INF,SPECIAL:exports.SPECIAL,ATOM:exports.ATOM,COLLECTION:exports.COLLECTION,ALL:exports.ALL};exports.default=exports.Allow}});var require_dist=__commonJS({"node_modules/partial-json/dist/index.js"(exports){"use strict";var __createBinding=exports&&exports.__createBinding||(Object.create?(function(o,m,k,k2){k2===void 0&&(k2=k);var desc=Object.getOwnPropertyDescriptor(m,k);(!desc||("get"in desc?!m.__esModule:desc.writable||desc.configurable))&&(desc={enumerable:!0,get:function(){return m[k]}}),Object.defineProperty(o,k2,desc)}):(function(o,m,k,k2){k2===void 0&&(k2=k),o[k2]=m[k]})),__exportStar=exports&&exports.__exportStar||function(m,exports2){for(var p in m)p!=="default"&&!Object.prototype.hasOwnProperty.call(exports2,p)&&__createBinding(exports2,m,p)};Object.defineProperty(exports,"__esModule",{value:!0});exports.Allow=exports.MalformedJSON=exports.PartialJSON=exports.parseJSON=exports.parse=void 0;var options_1=require_options();Object.defineProperty(exports,"Allow",{enumerable:!0,get:function(){return options_1.Allow}});__exportStar(require_options(),exports);var PartialJSON=class extends Error{};exports.PartialJSON=PartialJSON;var MalformedJSON=class extends Error{};exports.MalformedJSON=MalformedJSON;function parseJSON(jsonString,allowPartial=options_1.Allow.ALL){if(typeof jsonString!="string")throw new TypeError(`expecting str, got ${typeof jsonString}`);if(!jsonString.trim())throw new Error(`${jsonString} is empty`);return _parseJSON(jsonString.trim(),allowPartial)}exports.parseJSON=parseJSON;var _parseJSON=(jsonString,allow)=>{let length=jsonString.length,index=0,markPartialJSON=msg=>{throw new PartialJSON(`${msg} at position ${index}`)},throwMalformedError=msg=>{throw new MalformedJSON(`${msg} at position ${index}`)},parseAny=()=>(skipBlank(),index>=length&&markPartialJSON("Unexpected end of input"),jsonString[index]==='"'?parseStr():jsonString[index]==="{"?parseObj():jsonString[index]==="["?parseArr():jsonString.substring(index,index+4)==="null"||options_1.Allow.NULL&allow&&length-index<4&&"null".startsWith(jsonString.substring(index))?(index+=4,null):jsonString.substring(index,index+4)==="true"||options_1.Allow.BOOL&allow&&length-index<4&&"true".startsWith(jsonString.substring(index))?(index+=4,!0):jsonString.substring(index,index+5)==="false"||options_1.Allow.BOOL&allow&&length-index<5&&"false".startsWith(jsonString.substring(index))?(index+=5,!1):jsonString.substring(index,index+8)==="Infinity"||options_1.Allow.INFINITY&allow&&length-index<8&&"Infinity".startsWith(jsonString.substring(index))?(index+=8,1/0):jsonString.substring(index,index+9)==="-Infinity"||options_1.Allow._INFINITY&allow&&1<length-index&&length-index<9&&"-Infinity".startsWith(jsonString.substring(index))?(index+=9,-1/0):jsonString.substring(index,index+3)==="NaN"||options_1.Allow.NAN&allow&&length-index<3&&"NaN".startsWith(jsonString.substring(index))?(index+=3,NaN):parseNum()),parseStr=()=>{let start=index,escape=!1;for(index++;index<length&&(jsonString[index]!=='"'||escape&&jsonString[index-1]==="\\");)escape=jsonString[index]==="\\"?!escape:!1,index++;if(jsonString.charAt(index)=='"')try{return JSON.parse(jsonString.substring(start,++index-Number(escape)))}catch(e){throwMalformedError(String(e))}else if(options_1.Allow.STR&allow)try{return JSON.parse(jsonString.substring(start,index-Number(escape))+'"')}catch{return JSON.parse(jsonString.substring(start,jsonString.lastIndexOf("\\"))+'"')}markPartialJSON("Unterminated string literal")},parseObj=()=>{index++,skipBlank();let obj={};try{for(;jsonString[index]!=="}";){if(skipBlank(),index>=length&&options_1.Allow.OBJ&allow)return obj;let key=parseStr();skipBlank(),index++;try{let value=parseAny();obj[key]=value}catch(e){if(options_1.Allow.OBJ&allow)return obj;throw e}skipBlank(),jsonString[index]===","&&index++}}catch{if(options_1.Allow.OBJ&allow)return obj;markPartialJSON("Expected '}' at end of object")}return index++,obj},parseArr=()=>{index++;let arr=[];try{for(;jsonString[index]!=="]";)arr.push(parseAny()),skipBlank(),jsonString[index]===","&&index++}catch{if(options_1.Allow.ARR&allow)return arr;markPartialJSON("Expected ']' at end of array")}return index++,arr},parseNum=()=>{if(index===0){jsonString==="-"&&throwMalformedError("Not sure what '-' is");try{return JSON.parse(jsonString)}catch(e){if(options_1.Allow.NUM&allow)try{return JSON.parse(jsonString.substring(0,jsonString.lastIndexOf("e")))}catch{}throwMalformedError(String(e))}}let start=index;for(jsonString[index]==="-"&&index++;jsonString[index]&&",]}".indexOf(jsonString[index])===-1;)index++;index==length&&!(options_1.Allow.NUM&allow)&&markPartialJSON("Unterminated number literal");try{return JSON.parse(jsonString.substring(start,index))}catch{jsonString.substring(start,index)==="-"&&markPartialJSON("Not sure what '-' is");try{return JSON.parse(jsonString.substring(start,jsonString.lastIndexOf("e")))}catch(e2){throwMalformedError(String(e2))}}},skipBlank=()=>{for(;index<length&&`
3
- \r `.includes(jsonString[index]);)index++};return parseAny()},parse=parseJSON;exports.parse=parse}});var import_partial_json=__toESM(require_dist(),1),VALID_JSON_ESCAPES=new Set(['"',"\\","/","b","f","n","r","t","u"]);function isControlCharacter(char){let codePoint=char.codePointAt(0);return codePoint!==void 0&&codePoint>=0&&codePoint<=31}function escapeControlCharacter(char){switch(char){case"\b":return"\\b";case"\f":return"\\f";case`
4
- `:return"\\n";case"\r":return"\\r";case" ":return"\\t";default:return`\\u${char.codePointAt(0)?.toString(16).padStart(4,"0")??"0000"}`}}function repairJson(json){let repaired="",inString=!1;for(let index=0;index<json.length;index++){let char=json[index];if(!inString){repaired+=char,char==='"'&&(inString=!0);continue}if(char==='"'){repaired+=char,inString=!1;continue}if(char==="\\"){let nextChar=json[index+1];if(nextChar===void 0){repaired+="\\\\";continue}if(nextChar==="u"){let unicodeDigits=json.slice(index+2,index+6);if(/^[0-9a-fA-F]{4}$/.test(unicodeDigits)){repaired+=`\\u${unicodeDigits}`,index+=5;continue}}if(VALID_JSON_ESCAPES.has(nextChar)){repaired+=`\\${nextChar}`,index+=1;continue}repaired+="\\\\";continue}repaired+=isControlCharacter(char)?escapeControlCharacter(char):char}return repaired}function parseJsonWithRepair(json){try{return JSON.parse(json)}catch(error){let repairedJson=repairJson(json);if(repairedJson!==json)return JSON.parse(repairedJson);throw error}}function parseStreamingJson(partialJson){if(!partialJson||partialJson.trim()==="")return{};try{return parseJsonWithRepair(partialJson)}catch{try{return(0,import_partial_json.parse)(partialJson)??{}}catch{try{return(0,import_partial_json.parse)(repairJson(partialJson))??{}}catch{return{}}}}}export{repairJson,parseJsonWithRepair,parseStreamingJson};
2
+ import{__commonJS,__toESM}from"./chunk-JXWJOIH4.js";var require_options=__commonJS({"node_modules/partial-json/dist/options.js"(exports){"use strict";Object.defineProperty(exports,"__esModule",{value:!0});exports.Allow=exports.ALL=exports.COLLECTION=exports.ATOM=exports.SPECIAL=exports.INF=exports._INFINITY=exports.INFINITY=exports.NAN=exports.BOOL=exports.NULL=exports.OBJ=exports.ARR=exports.NUM=exports.STR=void 0;exports.STR=1;exports.NUM=2;exports.ARR=4;exports.OBJ=8;exports.NULL=16;exports.BOOL=32;exports.NAN=64;exports.INFINITY=128;exports._INFINITY=256;exports.INF=exports.INFINITY|exports._INFINITY;exports.SPECIAL=exports.NULL|exports.BOOL|exports.INF|exports.NAN;exports.ATOM=exports.STR|exports.NUM|exports.SPECIAL;exports.COLLECTION=exports.ARR|exports.OBJ;exports.ALL=exports.ATOM|exports.COLLECTION;exports.Allow={STR:exports.STR,NUM:exports.NUM,ARR:exports.ARR,OBJ:exports.OBJ,NULL:exports.NULL,BOOL:exports.BOOL,NAN:exports.NAN,INFINITY:exports.INFINITY,_INFINITY:exports._INFINITY,INF:exports.INF,SPECIAL:exports.SPECIAL,ATOM:exports.ATOM,COLLECTION:exports.COLLECTION,ALL:exports.ALL};exports.default=exports.Allow}});var require_dist=__commonJS({"node_modules/partial-json/dist/index.js"(exports){"use strict";var __createBinding=exports&&exports.__createBinding||(Object.create?(function(o,m,k,k2){k2===void 0&&(k2=k);var desc=Object.getOwnPropertyDescriptor(m,k);(!desc||("get"in desc?!m.__esModule:desc.writable||desc.configurable))&&(desc={enumerable:!0,get:function(){return m[k]}}),Object.defineProperty(o,k2,desc)}):(function(o,m,k,k2){k2===void 0&&(k2=k),o[k2]=m[k]})),__exportStar=exports&&exports.__exportStar||function(m,exports2){for(var p in m)p!=="default"&&!Object.prototype.hasOwnProperty.call(exports2,p)&&__createBinding(exports2,m,p)};Object.defineProperty(exports,"__esModule",{value:!0});exports.Allow=exports.MalformedJSON=exports.PartialJSON=exports.parseJSON=exports.parse=void 0;var options_1=require_options();Object.defineProperty(exports,"Allow",{enumerable:!0,get:function(){return options_1.Allow}});__exportStar(require_options(),exports);var PartialJSON=class extends Error{};exports.PartialJSON=PartialJSON;var MalformedJSON=class extends Error{};exports.MalformedJSON=MalformedJSON;function parseJSON(jsonString,allowPartial=options_1.Allow.ALL){if(typeof jsonString!="string")throw new TypeError(`expecting str, got ${typeof jsonString}`);if(!jsonString.trim())throw new Error(`${jsonString} is empty`);return _parseJSON(jsonString.trim(),allowPartial)}exports.parseJSON=parseJSON;var _parseJSON=(jsonString,allow)=>{let length=jsonString.length,index=0,markPartialJSON=msg=>{throw new PartialJSON(`${msg} at position ${index}`)},throwMalformedError=msg=>{throw new MalformedJSON(`${msg} at position ${index}`)},parseAny=()=>(skipBlank(),index>=length&&markPartialJSON("Unexpected end of input"),jsonString[index]==='"'?parseStr():jsonString[index]==="{"?parseObj():jsonString[index]==="["?parseArr():jsonString.substring(index,index+4)==="null"||options_1.Allow.NULL&allow&&length-index<4&&"null".startsWith(jsonString.substring(index))?(index+=4,null):jsonString.substring(index,index+4)==="true"||options_1.Allow.BOOL&allow&&length-index<4&&"true".startsWith(jsonString.substring(index))?(index+=4,!0):jsonString.substring(index,index+5)==="false"||options_1.Allow.BOOL&allow&&length-index<5&&"false".startsWith(jsonString.substring(index))?(index+=5,!1):jsonString.substring(index,index+8)==="Infinity"||options_1.Allow.INFINITY&allow&&length-index<8&&"Infinity".startsWith(jsonString.substring(index))?(index+=8,1/0):jsonString.substring(index,index+9)==="-Infinity"||options_1.Allow._INFINITY&allow&&1<length-index&&length-index<9&&"-Infinity".startsWith(jsonString.substring(index))?(index+=9,-1/0):jsonString.substring(index,index+3)==="NaN"||options_1.Allow.NAN&allow&&length-index<3&&"NaN".startsWith(jsonString.substring(index))?(index+=3,NaN):parseNum()),parseStr=()=>{let start=index,escape=!1;for(index++;index<length&&(jsonString[index]!=='"'||escape&&jsonString[index-1]==="\\");)escape=jsonString[index]==="\\"?!escape:!1,index++;if(jsonString.charAt(index)=='"')try{return JSON.parse(jsonString.substring(start,++index-Number(escape)))}catch(e){throwMalformedError(String(e))}else if(options_1.Allow.STR&allow)try{return JSON.parse(jsonString.substring(start,index-Number(escape))+'"')}catch{return JSON.parse(jsonString.substring(start,jsonString.lastIndexOf("\\"))+'"')}markPartialJSON("Unterminated string literal")},parseObj=()=>{index++,skipBlank();let obj={};try{for(;jsonString[index]!=="}";){if(skipBlank(),index>=length&&options_1.Allow.OBJ&allow)return obj;let key=parseStr();skipBlank(),index++;try{let value=parseAny();obj[key]=value}catch(e){if(options_1.Allow.OBJ&allow)return obj;throw e}skipBlank(),jsonString[index]===","&&index++}}catch{if(options_1.Allow.OBJ&allow)return obj;markPartialJSON("Expected '}' at end of object")}return index++,obj},parseArr=()=>{index++;let arr=[];try{for(;jsonString[index]!=="]";)arr.push(parseAny()),skipBlank(),jsonString[index]===","&&index++}catch{if(options_1.Allow.ARR&allow)return arr;markPartialJSON("Expected ']' at end of array")}return index++,arr},parseNum=()=>{if(index===0){jsonString==="-"&&throwMalformedError("Not sure what '-' is");try{return JSON.parse(jsonString)}catch(e){if(options_1.Allow.NUM&allow)try{return JSON.parse(jsonString.substring(0,jsonString.lastIndexOf("e")))}catch{}throwMalformedError(String(e))}}let start=index;for(jsonString[index]==="-"&&index++;jsonString[index]&&",]}".indexOf(jsonString[index])===-1;)index++;index==length&&!(options_1.Allow.NUM&allow)&&markPartialJSON("Unterminated number literal");try{return JSON.parse(jsonString.substring(start,index))}catch{jsonString.substring(start,index)==="-"&&markPartialJSON("Not sure what '-' is");try{return JSON.parse(jsonString.substring(start,jsonString.lastIndexOf("e")))}catch(e2){throwMalformedError(String(e2))}}},skipBlank=()=>{for(;index<length&&`
3
+ \r `.includes(jsonString[index]);)index++};return parseAny()},parse=parseJSON;exports.parse=parse}});var import_partial_json=__toESM(require_dist(),1),VALID_JSON_ESCAPES=new Set(['"',"\\","/","b","f","n","r","t"]);function isControlCharacter(char){let codePoint=char.codePointAt(0);return codePoint!==void 0&&codePoint>=0&&codePoint<=31}function escapeControlCharacter(char){switch(char){case"\b":return"\\b";case"\f":return"\\f";case`
4
+ `:return"\\n";case"\r":return"\\r";case" ":return"\\t";default:return`\\u${char.codePointAt(0)?.toString(16).padStart(4,"0")??"0000"}`}}function repairJson(json){let repaired="",inString=!1;for(let index=0;index<json.length;index++){let char=json[index];if(!inString){repaired+=char,char==='"'&&(inString=!0);continue}if(char==='"'){repaired+=char,inString=!1;continue}if(char==="\\"){let nextChar=json[index+1];if(nextChar===void 0){repaired+="\\\\";continue}if(nextChar==="u"){let unicodeDigits=json.slice(index+2,index+6);if(/^[0-9a-fA-F]{4}$/.test(unicodeDigits)){repaired+=`\\u${unicodeDigits}`,index+=5;continue}}if(VALID_JSON_ESCAPES.has(nextChar)){repaired+=`\\${nextChar}`,index+=1;continue}repaired+="\\\\";continue}repaired+=isControlCharacter(char)?escapeControlCharacter(char):char}return repaired}function parseJsonWithRepair(json){try{return JSON.parse(json)}catch(error){let repairedJson=repairJson(json);if(repairedJson!==json)return JSON.parse(repairedJson);throw error}}function parseToolCallArguments(json){if(!json?.trim())return{arguments:{}};try{let parsed=parseJsonWithRepair(json);if(typeof parsed!="object"||parsed===null||Array.isArray(parsed))throw new Error("Tool arguments must be a JSON object");return{arguments:parsed}}catch(error){return{arguments:{},argumentsError:`${error instanceof Error?error.message:String(error)}
5
+
6
+ Received arguments:
7
+ ${json}`}}}function parseStreamingJson(partialJson){if(!partialJson||partialJson.trim()==="")return{};try{return parseJsonWithRepair(partialJson)}catch{try{return(0,import_partial_json.parse)(partialJson)??{}}catch{try{return(0,import_partial_json.parse)(repairJson(partialJson))??{}}catch{return{}}}}}export{repairJson,parseJsonWithRepair,parseToolCallArguments,parseStreamingJson};