@humain/humain-code 0.4.8 → 0.4.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 (143) hide show
  1. package/CHANGELOG.md +44 -0
  2. package/dist/bundle/agent-monitor.js +1 -1
  3. package/dist/bundle/chunks/{anthropic-messages-YMPB2HJ7.js → anthropic-messages-UNHXXOD4.js} +3 -3
  4. package/dist/bundle/chunks/{azure-openai-responses-PDHOT7UC.js → azure-openai-responses-4QRYJCC2.js} +2 -2
  5. package/dist/bundle/chunks/bedrock-converse-stream.js +109 -92
  6. package/dist/bundle/chunks/{chunk-GNOKILVU.js → chunk-2QTTNAD4.js} +3385 -3947
  7. package/dist/bundle/chunks/{chunk-II2442A2.js → chunk-5CDES42D.js} +1 -1
  8. package/dist/bundle/chunks/{chunk-IMR3ZJM5.js → chunk-5XD3DHYL.js} +1 -1
  9. package/dist/bundle/chunks/{chunk-RXHSJSYY.js → chunk-6KAMTNN3.js} +1 -1
  10. package/dist/bundle/chunks/chunk-76X5KOIA.js +28 -0
  11. package/dist/bundle/chunks/{chunk-KRMTBTWU.js → chunk-77EWF2NW.js} +1 -1
  12. package/dist/bundle/chunks/{chunk-SKIP6KJV.js → chunk-7Z5MWPYE.js} +1 -1
  13. package/dist/bundle/chunks/{chunk-PBBQBIHY.js → chunk-AS2Y2MO6.js} +37 -37
  14. package/dist/bundle/chunks/{chunk-TIAXGIMN.js → chunk-AUFEF24K.js} +10 -10
  15. package/dist/bundle/chunks/{chunk-ILRBME2Y.js → chunk-BCF7KZ3R.js} +757 -745
  16. package/dist/bundle/chunks/{chunk-WPLW452J.js → chunk-DZ5C66IU.js} +1 -1
  17. package/dist/bundle/chunks/{chunk-2W5PWUPO.js → chunk-EDKZRYWJ.js} +2 -2
  18. package/dist/bundle/chunks/{chunk-W2QRCQBX.js → chunk-FF26YENK.js} +3 -4
  19. package/dist/bundle/chunks/{chunk-UZ5FVVCP.js → chunk-HMWAH7ZY.js} +1 -1
  20. package/dist/bundle/chunks/{chunk-F7UMX5BV.js → chunk-HSDTSUZE.js} +13 -2
  21. package/dist/bundle/chunks/chunk-I2ZWZAIV.js +751 -0
  22. package/dist/bundle/chunks/{chunk-GUUAEK6G.js → chunk-LCOHFEZZ.js} +1 -1
  23. package/dist/bundle/chunks/chunk-MVYV6MJY.js +23 -0
  24. package/dist/bundle/chunks/{chunk-Z5LYSSTY.js → chunk-QSPDLT2R.js} +2 -2
  25. package/dist/bundle/chunks/{chunk-UBQSONVR.js → chunk-R5VIAWGA.js} +103 -145
  26. package/dist/bundle/chunks/{chunk-YURQPD6Y.js → chunk-RYC5BYVE.js} +1 -2
  27. package/dist/bundle/chunks/{chunk-ROSZII6E.js → chunk-V5ZF7Q7L.js} +1 -1
  28. package/dist/bundle/chunks/chunk-VEYTRNQC.js +5 -0
  29. package/dist/bundle/chunks/{chunk-LQ4S7CRR.js → chunk-VYIIPF57.js} +1 -1
  30. package/dist/bundle/chunks/chunk-WBJN6PEI.js +43 -0
  31. package/dist/bundle/chunks/{chunk-SWRU4BOC.js → chunk-XGO43DKL.js} +1 -1
  32. package/dist/bundle/chunks/{chunk-PMISFIBM.js → chunk-XMHLSV3I.js} +1 -1
  33. package/dist/bundle/chunks/{chunk-3E4SMILM.js → chunk-YJBE3IGR.js} +14 -14
  34. package/dist/bundle/chunks/{chunk-OTXURGIO.js → chunk-YKZGL4MB.js} +1 -1
  35. package/dist/bundle/chunks/chunk-Z33NNMNB.js +6 -0
  36. package/dist/bundle/chunks/{cli-ZKT34WPW.js → cli-5ACW3WND.js} +2 -2
  37. package/dist/bundle/chunks/{cloudflare-workers-ai-system-one-YPOLSCPT.js → cloudflare-workers-ai-system-one-FZ3UQCZ7.js} +1 -1
  38. package/dist/bundle/chunks/{compat-J5FTRJ6S.js → compat-TQKA4I7M.js} +3 -3
  39. package/dist/bundle/chunks/{dist-N7XDUAAO.js → dist-VNSMKBZ6.js} +3 -3
  40. package/dist/bundle/chunks/{dist-6FQCCUSC.js → dist-WHC67QRM.js} +1077 -912
  41. package/dist/bundle/chunks/dist-cjs-RL2OCAP2.js +179 -0
  42. package/dist/bundle/chunks/{easter-egg-3d-5KKDWEIA.js → easter-egg-3d-3L3IKAT6.js} +1 -1
  43. package/dist/bundle/chunks/{esm-NCUV2DF7.js → esm-763X2IA7.js} +1 -1
  44. package/dist/bundle/chunks/event-streams-R5OECII4.js +2 -0
  45. package/dist/bundle/chunks/{execute-OSBDNQU5.js → execute-4X6G65NZ.js} +1 -1
  46. package/dist/bundle/chunks/{extract-56PXVZVW.js → extract-DLZ425VI.js} +4 -4
  47. package/dist/bundle/chunks/github-copilot.js +32 -31
  48. package/dist/bundle/chunks/{google-generative-ai-TS4ZE2RO.js → google-generative-ai-JD2FVOIX.js} +2 -2
  49. package/dist/bundle/chunks/{google-vertex-MJK2SMNE.js → google-vertex-PFBMDCBW.js} +3 -3
  50. package/dist/bundle/chunks/host-4J7H7KDS.js +2 -0
  51. package/dist/bundle/chunks/{llama-cpp-classify-5KAR326J.js → llama-cpp-classify-AGCW7HYN.js} +1 -1
  52. package/dist/bundle/chunks/{mistral-conversations-XA2ZGSAH.js → mistral-conversations-D74NZ65O.js} +2 -2
  53. package/dist/bundle/chunks/{node-XGNY74WT.js → node-W47VUEGE.js} +1 -1
  54. package/dist/bundle/chunks/{openai-codex-responses-Y6NRWMOI.js → openai-codex-responses-JAAA7MSS.js} +3 -3
  55. package/dist/bundle/chunks/{openai-completions-FY77MIZH.js → openai-completions-PGPMGQPU.js} +34 -33
  56. package/dist/bundle/chunks/{openai-decisions-MKH4OJHH.js → openai-decisions-QQ4MEABI.js} +1 -1
  57. package/dist/bundle/chunks/openai-responses-FG2R2M4L.js +23 -0
  58. package/dist/bundle/chunks/{openrouter-images-R3QMMLPH.js → openrouter-images-NTBP3UUE.js} +1 -1
  59. package/dist/bundle/chunks/{pi-messages-LYJZPRST.js → pi-messages-JD4O7KIP.js} +1 -1
  60. package/dist/bundle/chunks/{runtime-JFLZUNYP.js → runtime-SI76JZNE.js} +1 -1
  61. package/dist/bundle/chunks/{typesafe-system-one-PAYJECQK.js → typesafe-system-one-TTC7YCO3.js} +1 -1
  62. package/dist/bundle/chunks/virtual-modules-ID2GA4GE.js +5 -0
  63. package/dist/bundle/cli-runtime.js +3 -3
  64. package/dist/bundle/flow/assets/contract.json +1 -1
  65. package/dist/bundle/flow/package.json +1 -1
  66. package/dist/bundle/index.js +17 -17
  67. package/dist/bundle/rpc-entry.js +3 -2
  68. package/dist/core/account-reporting.d.ts +109 -0
  69. package/dist/core/account-reporting.d.ts.map +1 -0
  70. package/dist/core/account-reporting.js +328 -0
  71. package/dist/core/account-reporting.js.map +1 -0
  72. package/dist/core/agent-session.d.ts +22 -2
  73. package/dist/core/agent-session.d.ts.map +1 -1
  74. package/dist/core/agent-session.js +131 -0
  75. package/dist/core/agent-session.js.map +1 -1
  76. package/dist/core/anthropic-account-reporting.d.ts +76 -0
  77. package/dist/core/anthropic-account-reporting.d.ts.map +1 -0
  78. package/dist/core/anthropic-account-reporting.js +380 -0
  79. package/dist/core/anthropic-account-reporting.js.map +1 -0
  80. package/dist/core/bedrock-account-reporting.d.ts +82 -0
  81. package/dist/core/bedrock-account-reporting.d.ts.map +1 -0
  82. package/dist/core/bedrock-account-reporting.js +402 -0
  83. package/dist/core/bedrock-account-reporting.js.map +1 -0
  84. package/dist/core/model-runtime.d.ts +17 -0
  85. package/dist/core/model-runtime.d.ts.map +1 -1
  86. package/dist/core/model-runtime.js +64 -10
  87. package/dist/core/model-runtime.js.map +1 -1
  88. package/dist/core/oauth-account-pool.d.ts +4 -0
  89. package/dist/core/oauth-account-pool.d.ts.map +1 -1
  90. package/dist/core/oauth-account-pool.js +10 -3
  91. package/dist/core/oauth-account-pool.js.map +1 -1
  92. package/dist/humain/bedrock-provider/vendor/index.bundle.mjs +353 -29
  93. package/dist/humain/flow-accounts-host.d.ts +120 -0
  94. package/dist/humain/flow-accounts-host.d.ts.map +1 -0
  95. package/dist/humain/flow-accounts-host.js +346 -0
  96. package/dist/humain/flow-accounts-host.js.map +1 -0
  97. package/dist/humain/flow-command.d.ts +28 -0
  98. package/dist/humain/flow-command.d.ts.map +1 -0
  99. package/dist/humain/flow-command.js +226 -0
  100. package/dist/humain/flow-command.js.map +1 -0
  101. package/dist/humain/flow-loader.d.ts +4 -2
  102. package/dist/humain/flow-loader.d.ts.map +1 -1
  103. package/dist/humain/flow-loader.js +120 -91
  104. package/dist/humain/flow-loader.js.map +1 -1
  105. package/dist/humain/node-account-failure.d.ts +18 -0
  106. package/dist/humain/node-account-failure.d.ts.map +1 -0
  107. package/dist/humain/node-account-failure.js +73 -0
  108. package/dist/humain/node-account-failure.js.map +1 -0
  109. package/dist/humain/node-account-fallback.d.ts +85 -0
  110. package/dist/humain/node-account-fallback.d.ts.map +1 -0
  111. package/dist/humain/node-account-fallback.js +175 -0
  112. package/dist/humain/node-account-fallback.js.map +1 -0
  113. package/dist/humain/node-http.d.ts.map +1 -1
  114. package/dist/humain/node-http.js +11 -0
  115. package/dist/humain/node-http.js.map +1 -1
  116. package/dist/humain/node-provider.d.ts +4 -0
  117. package/dist/humain/node-provider.d.ts.map +1 -1
  118. package/dist/humain/node-provider.js +11 -0
  119. package/dist/humain/node-provider.js.map +1 -1
  120. package/dist/index.d.ts +4 -0
  121. package/dist/index.d.ts.map +1 -1
  122. package/dist/index.js.map +1 -1
  123. package/dist/modes/interactive/components/login-dialog.d.ts +2 -0
  124. package/dist/modes/interactive/components/login-dialog.d.ts.map +1 -1
  125. package/dist/modes/interactive/components/login-dialog.js +5 -0
  126. package/dist/modes/interactive/components/login-dialog.js.map +1 -1
  127. package/dist/modes/interactive/interactive-mode.d.ts +26 -0
  128. package/dist/modes/interactive/interactive-mode.d.ts.map +1 -1
  129. package/dist/modes/interactive/interactive-mode.js +242 -19
  130. package/dist/modes/interactive/interactive-mode.js.map +1 -1
  131. package/docs/flow-profiles.md +57 -5
  132. package/docs/flow.md +130 -45
  133. package/docs/providers.md +37 -0
  134. package/npm-shrinkwrap.json +48 -6
  135. package/package.json +3 -2
  136. package/dist/bundle/chunks/chunk-AKA7HNO3.js +0 -4
  137. package/dist/bundle/chunks/chunk-JYWVRJYG.js +0 -6
  138. package/dist/bundle/chunks/chunk-MEIYGK5O.js +0 -6
  139. package/dist/bundle/chunks/chunk-PYU5BR3Z.js +0 -27
  140. package/dist/bundle/chunks/event-streams-CGCQQL5M.js +0 -2
  141. package/dist/bundle/chunks/host-2ARI7PQ5.js +0 -2
  142. package/dist/bundle/chunks/openai-responses-LNSCERKH.js +0 -23
  143. package/dist/bundle/chunks/virtual-modules-TT2VTOSY.js +0 -5
@@ -1,5 +1,5 @@
1
1
  import { createRequire as __piCreateRequire } from "node:module"; const require = __piCreateRequire(import.meta.url);
2
- import{theme}from"./chunk-LQ4S7CRR.js";var ARMIN_WIDTH=31,ARMIN_HEIGHT=36,WIDTH=ARMIN_WIDTH,HEIGHT=ARMIN_HEIGHT,BITS=[255,255,255,127,255,240,255,127,255,237,255,127,255,219,255,127,255,183,255,127,255,119,254,127,63,248,254,127,223,255,254,127,223,63,252,127,159,195,251,127,111,252,244,127,247,15,247,127,247,255,247,127,247,255,227,127,247,7,232,127,239,248,103,112,15,255,187,111,241,0,208,91,253,63,236,83,193,255,239,87,159,253,238,95,159,252,174,95,31,120,172,95,63,0,80,108,127,0,220,119,255,192,63,120,255,1,248,127,255,3,156,120,
2
+ import{theme}from"./chunk-VYIIPF57.js";var ARMIN_WIDTH=31,ARMIN_HEIGHT=36,WIDTH=ARMIN_WIDTH,HEIGHT=ARMIN_HEIGHT,BITS=[255,255,255,127,255,240,255,127,255,237,255,127,255,219,255,127,255,183,255,127,255,119,254,127,63,248,254,127,223,255,254,127,223,63,252,127,159,195,251,127,111,252,244,127,247,15,247,127,247,255,247,127,247,255,227,127,247,7,232,127,239,248,103,112,15,255,187,111,241,0,208,91,253,63,236,83,193,255,239,87,159,253,238,95,159,252,174,95,31,120,172,95,63,0,80,108,127,0,220,119,255,192,63,120,255,1,248,127,255,3,156,120,
3
3
  255,7,140,124,255,15,206,120,255,255,207,127,255,255,207,120,255,255,223,120,255,255,223,125,255,255,63,126,255,255,255,127],BYTES_PER_ROW=Math.ceil(WIDTH/8),DISPLAY_HEIGHT=Math.ceil(HEIGHT/2),EFFECTS=["typewriter","scanline","rain","fade","crt","glitch","dissolve"];function isArminPixel(x,y){if(y>=HEIGHT)return!1;let byteIndex=y*BYTES_PER_ROW+Math.floor(x/8),bitIndex=x%8;return(BITS[byteIndex]>>bitIndex&1)===0}function getChar(x,row){let upper=isArminPixel(x,row*2),lower=isArminPixel(x,row*2+1);
4
4
  return upper&&lower?"\u2588":upper?"\u2580":lower?"\u2584":" "}function buildFinalGrid(){let grid=[];for(let row=0;row<DISPLAY_HEIGHT;row++){let line=[];for(let x=0;x<WIDTH;x++)line.push(getChar(x,row));grid.push(line)}return grid}var ArminComponent=class{ui;interval=null;effect;finalGrid;currentGrid;effectState={};cachedLines=[];cachedWidth=0;gridVersion=0;cachedVersion=-1;constructor(ui){this.ui=ui,this.effect=EFFECTS[Math.floor(Math.random()*EFFECTS.length)],this.finalGrid=buildFinalGrid(),this.
5
5
  currentGrid=this.createEmptyGrid(),this.initEffect(),this.startAnimation()}invalidate(){this.cachedWidth=0}render(width){if(width===this.cachedWidth&&this.cachedVersion===this.gridVersion)return this.cachedLines;let padding=1,availableWidth=width-padding;this.cachedLines=this.currentGrid.map(row=>{let clipped=row.slice(0,availableWidth).join(""),padRight=Math.max(0,width-padding-clipped.length);return` ${theme.fg("accent",clipped)}${" ".repeat(padRight)}`});let message="ARMIN SAYS HI",msgPadRight=Math.
@@ -0,0 +1,23 @@
1
+ import { createRequire as __piCreateRequire } from "node:module"; const require = __piCreateRequire(import.meta.url);
2
+ import{appendAssistantMessageDiagnostic}from"./chunk-VEYTRNQC.js";var MAX_PROVIDER_ERROR_BODY_CHARS=4e3,MAX_PROVIDER_ERROR_INPUT_CHARS=64*1024,OVERSIZED_ERROR_TEXT="Provider error text exceeded 65536 characters",UNPARSEABLE_ERROR_TEXT="Unparseable structured provider error";function normalizeProviderError(error){if(!(error instanceof Error))return{message:truncateErrorText(safeJsonStringify(error),MAX_PROVIDER_ERROR_BODY_CHARS),messageCarriesBody:!1};let sdkError=error,status=extractStatus(sdkError),body=extractBody(sdkError),message=body==="[REDACTED]"?body:truncateErrorText(
3
+ error.message,MAX_PROVIDER_ERROR_BODY_CHARS),transport=transportEvidence(error);transport.transportCode&&TRANSPORT_CODES.has(transport.transportCode)&&!message.includes(transport.transportCode)&&(message=truncateErrorText(`${message} (${transport.transportCode})`,MAX_PROVIDER_ERROR_BODY_CHARS));let messageCarriesBody=body===void 0||message!=="[REDACTED]"&&message.includes(body);return{status,body,message,messageCarriesBody,...transport}}function transportEvidence(error){let candidate=error,transportCode,
4
+ transportName;for(let depth=0;depth<8&&candidate&&typeof candidate=="object";depth++){let nested=candidate,status=extractStatus(nested);if(status!==void 0&&status>=400||nested.name==="AbortError"||nested.constructor?.name==="APIUserAbortError")return{};typeof nested.code=="string"&&TRANSPORT_CODES.has(nested.code)&&(transportCode??=nested.code);for(let name of[nested.name,nested.constructor?.name])["TimeoutError","APIConnectionTimeoutError","APIConnectionError"].includes(name)&&(transportName??=
5
+ name);candidate=nested.cause}return transportCode??=transportName,transportCode?{transportCode}:{}}function appendProviderTransportDiagnostic(message,error){message.stopReason!=="error"||!error.transportCode||appendAssistantMessageDiagnostic(message,{type:"provider_transport_error",timestamp:Date.now(),details:{reason:"provider_unreachable",code:error.transportCode}})}function extractStatus(error){return[error.statusCode,error.status,error.$metadata?.httpStatusCode,error.$response?.statusCode].find(
6
+ value=>typeof value=="number"&&Number.isInteger(value)&&value>=100&&value<=599)}function extractBody(error){let bodyText=pickBodyText(error);if(bodyText===void 0)return;let trimmed=sanitizeErrorText(bodyText).trim();if(trimmed.length!==0)return truncateErrorText(trimmed,MAX_PROVIDER_ERROR_BODY_CHARS)}function pickBodyText(error){if(typeof error.body=="string")return error.body;if(isPlainNonEmptyObject(error.error))return safeJsonStringify(error.error);let responseBody=error.$response?.body;if(typeof responseBody==
7
+ "string")return responseBody;if(responseBody instanceof Uint8Array)return responseBody.byteLength>MAX_PROVIDER_ERROR_INPUT_CHARS?OVERSIZED_ERROR_TEXT:new TextDecoder().decode(responseBody);if(!isReadableStreamLike(responseBody)&&isPlainNonEmptyObject(responseBody))return safeJsonStringify(responseBody)}function isReadableStreamLike(value){return typeof value=="object"&&value!==null&&"pipe"in value&&typeof value.pipe=="function"}function isPlainNonEmptyObject(value){if(typeof value!="object"||value===
8
+ null)return!1;let proto=Object.getPrototypeOf(value);return proto!==Object.prototype&&proto!==null?!1:Object.keys(value).length>0}function formatProviderError(norm,prefix){if(norm.messageCarriesBody||norm.status===void 0||norm.body===void 0){let message=prefix!==void 0&&norm.status!==void 0?`${prefix} (${norm.status}): ${norm.message}`:norm.message;return truncateErrorText(message,MAX_PROVIDER_ERROR_BODY_CHARS)}return truncateErrorText(prefix!==void 0?`${prefix} (${norm.status}): ${norm.body}`:`${norm.
9
+ status}: ${norm.body}`,MAX_PROVIDER_ERROR_BODY_CHARS)}function truncateErrorText(text,maxChars){let clean=sanitizeErrorText(text),cap=Number.isFinite(maxChars)?Math.max(0,Math.floor(maxChars)):MAX_PROVIDER_ERROR_BODY_CHARS;if(clean.length<=cap)return clean;let start=clean.search(/[{[]/);if(start>=0)try{let parsed=JSON.parse(clean.slice(start));clean=clean.slice(0,start)+summarizeErrorValue(parsed)}catch{}let suffix="... [truncated]";return cap<suffix.length?suffix.slice(0,cap):`${clean.slice(0,cap-
10
+ suffix.length).replace(/\[[^\]]*$/,"")}${suffix}`}function safeJsonStringify(value){try{let serialized=JSON.stringify(value,(key,nested)=>{if(nested!==null&&typeof nested=="object"&&hasSensitiveLabel(nested,!0))return Array.isArray(nested)?["[REDACTED]"]:"[REDACTED]";let label=normalizeErrorLabel(key);if(hasAmbiguousErrorControls(key)||SENSITIVE_KEY.test(label)||/headers?/i.test(label)||Array.isArray(nested)&&nested.some(item=>typeof item=="string"&&SENSITIVE_KEY.test(normalizeErrorLabel(item)))||
11
+ nested!==null&&typeof nested=="object"&&Object.entries(nested).some(([name,item])=>typeof item=="string"&&SENSITIVE_HEADER_NAME.test(normalizeErrorLabel(item))||/^(?:name|key|header|header[-_]?name|header[-_]?key|field[-_]?name|label|identifier)$/i.test(normalizeErrorLabel(name))&&hasSensitiveLabel(item)))return"[REDACTED]";if(Array.isArray(nested)&&hasSensitiveLabel(nested))return["[REDACTED]"];if(nested!==null&&typeof nested=="object"&&!Array.isArray(nested)){let entries=Object.entries(nested);
12
+ if(entries.some(([name])=>sanitizePlainText(name)!==stripErrorControls(name)))return Object.fromEntries(entries.map(([name,value2])=>sanitizePlainText(name)!==stripErrorControls(name)?[sanitizePlainText(name),"[REDACTED]"]:[name,value2]))}return typeof nested=="string"?sanitizeErrorText(nested):nested});return serialized!==void 0&&serialized.length>MAX_PROVIDER_ERROR_INPUT_CHARS?truncateErrorText(summarizeErrorValue(JSON.parse(serialized)),MAX_PROVIDER_ERROR_BODY_CHARS):serialized===void 0?sanitizePlainText(
13
+ String(value)):serialized}catch{return"[Unserializable provider error]"}}function summarizeErrorValue(value){if(typeof value=="string")try{return summarizeErrorValue(JSON.parse(value))}catch{return sanitizePlainText(value)}if(value===null||typeof value!="object")return String(value);let entries=Object.entries(value),reasons=["message","error","reason","detail"];entries.sort(([left],[right])=>(reasons.includes(left)?reasons.indexOf(left):reasons.length)-(reasons.includes(right)?reasons.indexOf(right):
14
+ reasons.length));let parts=[],length=0;for(let[,nested]of entries){let part=truncateErrorText(summarizeErrorValue(nested),MAX_PROVIDER_ERROR_BODY_CHARS);if(parts.push(part),length+=part.length+2,length>=MAX_PROVIDER_ERROR_BODY_CHARS)break}return truncateErrorText(parts.join("; "),MAX_PROVIDER_ERROR_BODY_CHARS)}var TRANSPORT_CODES=new Set(["ECONNREFUSED","ECONNRESET","ETIMEDOUT","ENOTFOUND","EAI_AGAIN","EHOSTUNREACH","ENETUNREACH","EPIPE","EPROTO","CERT_HAS_EXPIRED","DEPTH_ZERO_SELF_SIGNED_CERT",
15
+ "SELF_SIGNED_CERT_IN_CHAIN","UNABLE_TO_VERIFY_LEAF_SIGNATURE","ERR_TLS_CERT_ALTNAME_INVALID","UND_ERR_CONNECT_TIMEOUT","UND_ERR_HEADERS_TIMEOUT","UND_ERR_BODY_TIMEOUT","UND_ERR_SOCKET"]),SENSITIVE_KEY=/(?:authorization|cookie|(?:api[-_\s]*key)|token|password|passwd|secret|credential|signature|private[-_\s]*key)/i,SENSITIVE_HEADER_NAME=/^(?:[a-z0-9]+[-_])*(?:authorization|cookie|(?:api|private|secret)[-_\s]*key|(?:access|refresh|session|security)[-_\s]*token|token|password|passwd|secret|credentials?|signature)$/i;
16
+ function sanitizeErrorText(text){if(text.length>MAX_PROVIDER_ERROR_INPUT_CHARS)return OVERSIZED_ERROR_TEXT;try{let parsed=JSON.parse(text);if(parsed!==null&&typeof parsed=="object")return safeJsonStringify(parsed);if(typeof parsed=="string")return sanitizeErrorText(parsed)}catch{let start=text.search(/[{[]/);if(start>0)try{let parsed=JSON.parse(text.slice(start));return sanitizePlainText(text.slice(0,start))+safeJsonStringify(parsed)}catch{}}return sanitizePlainText(text)}function hasSensitiveLabel(value,ambiguityOnly=!1){
17
+ let pending=[value],seen=new Set,scanned=0;for(;pending.length>0;){if(++scanned>1024)return!0;let item=pending.pop();if(typeof item=="string"){if(item.length>MAX_PROVIDER_ERROR_INPUT_CHARS||hasAmbiguousErrorControls(item)||!ambiguityOnly&&SENSITIVE_HEADER_NAME.test(normalizeErrorLabel(item)))return!0;try{let decoded=JSON.parse(ambiguityOnly?item:stripErrorControls(item," "));(typeof decoded=="string"||decoded!==null&&typeof decoded=="object")&&pending.push(decoded)}catch{let sanitized=sanitizePlainText(
18
+ item);if(ambiguityOnly?sanitized===UNPARSEABLE_ERROR_TEXT:sanitized!==stripErrorControls(item))return!0}}if(item!==null&&typeof item=="object"){if(seen.has(item))return!0;seen.add(item);let entries=Object.entries(item);if(entries.length*2+pending.length>1024)return!0;for(let[name,nested]of entries){if(ambiguityOnly&&hasAmbiguousErrorKey(name))return!0;ambiguityOnly||pending.push(name),pending.push(nested)}}}return!1}function hasAmbiguousErrorKey(name){return name.length>MAX_PROVIDER_ERROR_INPUT_CHARS||
19
+ name!==normalizeErrorLabel(name)||sanitizePlainText(name)===UNPARSEABLE_ERROR_TEXT}function normalizeErrorLabel(text){return stripErrorControls(text).replace(/[\s\p{Default_Ignorable_Code_Point}]/gu,"").trim().replace(/:+$/,"").trim()}var ERROR_TERMINAL_SEQUENCES=/(?:\x1b\]|\x9d)[\s\S]*?(?:\x07|\x1b\\|\x9c|$)|\x1b[PX^_][\s\S]*?(?:\x1b\\|$)|(?:\x1b\[|\x9b)[0-?]*[ -/]*[@-~]|\x1b[@-_]/g,ERROR_CONTROLS=/[\x00-\x08\x0b-\x1f\x7f-\x9f\p{Cf}\p{Default_Ignorable_Code_Point}]/gu;function hasAmbiguousErrorControls(text){
20
+ return text.replace(ERROR_TERMINAL_SEQUENCES,sequence=>(sequence.startsWith("\x1B[")||sequence.startsWith("\x9B"))&&sequence.endsWith("m")?"":sequence).search(ERROR_CONTROLS)>=0}function stripErrorControls(text,replacement=""){return text.replace(ERROR_TERMINAL_SEQUENCES,replacement).replace(ERROR_CONTROLS,replacement)}function sanitizePlainText(text){if(text.length>MAX_PROVIDER_ERROR_INPUT_CHARS)return OVERSIZED_ERROR_TEXT;let boundaries=stripErrorControls(text," "),clean=stripErrorControls(text);
21
+ if((/[@?#<>]/.test(clean)||clean.split(/\s+/).some(part=>{let start=part.search(/(?:https?|wss?|ftp):|[/\\]/i);return start>=0&&/["']/.test(part.slice(start))}))&&/(?:https?|wss?|ftp):|[/\\]/i.test(clean.replace(/\s/g,"")))return"[REDACTED]";if(/\\["/bfnrtu]/i.test(boundaries))return UNPARSEABLE_ERROR_TEXT;let structure=clean.replaceAll("[REDACTED]","").replaceAll("[truncated]","").replace(/\b[a-z_$][\w$]*(?:\[\d+\])+/gi,"");if(/[{}[\]]/.test(structure))return UNPARSEABLE_ERROR_TEXT;if(hasAmbiguousErrorControls(
22
+ text)||SENSITIVE_KEY.test(normalizeErrorLabel(clean))||/\b(?:B\s*e\s*a\s*r\s*e\s*r|B\s*a\s*s\s*i\s*c)\s/i.test(boundaries)||/\b(?:B\s*e\s*a\s*r\s*e\s*r|B\s*a\s*s\s*i\s*c)\s/i.test(clean))return"[REDACTED]";let tokenText=clean.replace(/[\t\n\u2028\u2029]/g,"");return tokenText.replace(/[\w-]+(?:\.[\w-]+)*/g,token=>{let segments=token.split(".");return/\b(?:sk-|glpat-|gh[pousr]_|github_pat_|xox[baprs]-)[\w-]+|\b(?:AKIA|ASIA)[A-Z0-9]{16}\b|\bAIza[\w-]{35}/.test(token)||segments.length>=3&&/\beyJ[\w-]+$/.
23
+ test(segments[0])?"[REDACTED]":token})===tokenText?clean:"[REDACTED]"}export{MAX_PROVIDER_ERROR_BODY_CHARS,normalizeProviderError,appendProviderTransportDiagnostic,formatProviderError,truncateErrorText};
@@ -1,5 +1,5 @@
1
1
  import { createRequire as __piCreateRequire } from "node:module"; const require = __piCreateRequire(import.meta.url);
2
- import{VisualLinePreview,getTextOutput,replaceTabs,str}from"./chunk-PMISFIBM.js";import{Container,Spacer,Text,highlightCode,keyHint}from"./chunk-LQ4S7CRR.js";import{getDocsPath}from"./chunk-3E4SMILM.js";import{typebox_exports}from"./chunk-BHM75BJJ.js";function createUsageTotals(){return{input:0,output:0,cacheRead:0,cacheWrite:0,cost:0}}function addUsageToTotals(totals,usage){usage.usageIncomplete&&(totals.usageIncomplete=!0),totals.input+=usage.input,totals.output+=usage.output,totals.cacheRead+=usage.cacheRead,totals.cacheWrite+=usage.cacheWrite,totals.cost+=usage.cost.total}function combineUsage(first,second){return{...first.usageIncomplete||second.usageIncomplete?{usageIncomplete:!0}:{},input:first.input+second.input,output:first.output+second.
2
+ import{VisualLinePreview,getTextOutput,replaceTabs,str}from"./chunk-XMHLSV3I.js";import{Container,Spacer,Text,highlightCode,keyHint}from"./chunk-VYIIPF57.js";import{getDocsPath}from"./chunk-YJBE3IGR.js";import{typebox_exports}from"./chunk-BHM75BJJ.js";function createUsageTotals(){return{input:0,output:0,cacheRead:0,cacheWrite:0,cost:0}}function addUsageToTotals(totals,usage){usage.usageIncomplete&&(totals.usageIncomplete=!0),totals.input+=usage.input,totals.output+=usage.output,totals.cacheRead+=usage.cacheRead,totals.cacheWrite+=usage.cacheWrite,totals.cost+=usage.cost.total}function combineUsage(first,second){return{...first.usageIncomplete||second.usageIncomplete?{usageIncomplete:!0}:{},input:first.input+second.input,output:first.output+second.
3
3
  output,cacheRead:first.cacheRead+second.cacheRead,cacheWrite:first.cacheWrite+second.cacheWrite,...first.cacheWrite1h!==void 0||second.cacheWrite1h!==void 0?{cacheWrite1h:(first.cacheWrite1h??0)+(second.cacheWrite1h??0)}:{},...first.reasoning!==void 0||second.reasoning!==void 0?{reasoning:(first.reasoning??0)+(second.reasoning??0)}:{},totalTokens:first.totalTokens+second.totalTokens,cost:{input:first.cost.input+second.cost.input,output:first.cost.output+second.cost.output,cacheRead:first.cost.cacheRead+
4
4
  second.cost.cacheRead,cacheWrite:first.cost.cacheWrite+second.cost.cacheWrite,total:first.cost.total+second.cost.total}}}function getUsageCostBreakdown(entries){let totalsByKey=new Map;for(let entry of entries){let key,usage;if(entry.type==="message"&&entry.message.role==="assistant"?(key=`${entry.message.provider}/${entry.message.responseModel??entry.message.model}`,usage=entry.message.usage):entry.type==="usage"?(key=`${entry.provider}/${entry.model}`,usage=entry.usage):entry.type==="message"&&
5
5
  entry.message.role==="toolResult"&&entry.message.usage?(key="Tools/summaries",usage=entry.message.usage):(entry.type==="branch_summary"||entry.type==="compaction")&&entry.usage&&(key="Tools/summaries",usage=entry.usage),!key||!usage)continue;let totals=totalsByKey.get(key);totals||(totals=createUsageTotals(),totalsByKey.set(key,totals)),addUsageToTotals(totals,usage)}return Array.from(totalsByKey,([key,totals])=>({key,...totals.usageIncomplete?{usageIncomplete:!0}:{},cost:totals.cost,tokens:totals.
@@ -120,7 +120,7 @@ Searches over deferred tool metadata with BM25 and exposes matching tools for th
120
120
  Some of the tools, such as tools of MCP servers, may not have been provided to you upfront, and you should use this tool (\`${TOOL_SEARCH_TOOL_NAME}\`) to search for the required tools. For MCP tool discovery, always use \`${TOOL_SEARCH_TOOL_NAME}\`.`;function createToolSearchToolDefinition(options={}){return{name:TOOL_SEARCH_TOOL_NAME,label:TOOL_SEARCH_TOOL_NAME,description:TOOL_SEARCH_DESCRIPTION,promptSnippet:"Search for tools that are not loaded yet and load the matches",parameters:toolSearchSchema,
121
121
  exposure:"model-only",async execute(_toolCallId,{query,limit}){if(query.trim()==="")throw new Error("query must not be empty");let max=limit??DEFAULT_TOOL_SEARCH_LIMIT;if(!Number.isInteger(max)||max<=0)throw new Error("limit must be a positive integer");let tools=options.tools?searchAndLoad(options.tools,query,max):[];return{content:[{type:"text",text:tools.length===0?"No matching tools found.":`Loaded ${tools.length} tool${tools.length===1?"":"s"}. They are available from your next call:
122
122
  ${tools.map(tool=>`- ${tool.name}: ${tool.description.trim().split(/\r?\n/)[0]}`).join(`
123
- `)}`}],details:{loaded:tools.map(tool=>tool.name)}}}}}import{join}from"node:path";function wrapToolDefinition(definition,ctxFactory){return{name:definition.name,label:definition.label,description:definition.description,parameters:definition.parameters,outputSchema:definition.outputSchema,constrainedSampling:definition.constrainedSampling,prepareArguments:definition.prepareArguments,executionMode:definition.executionMode,execute:(toolCallId,params,signal,onUpdate,ctx)=>definition.execute(toolCallId,params,signal,onUpdate,ctx??ctxFactory?.(toolCallId,signal))}}function createToolDefinitionFromAgentTool(tool){return{name:tool.name,label:tool.label,description:tool.description,parameters:tool.parameters,outputSchema:tool.outputSchema,constrainedSampling:tool.constrainedSampling,prepareArguments:tool.prepareArguments,executionMode:tool.executionMode,execute:async(toolCallId,params,signal,onUpdate)=>tool.execute(toolCallId,params,signal,onUpdate)}}var loadCodemodeExecutor=()=>import("./execute-OSBDNQU5.js");var CODE_PREVIEW_LINES=10,CALL_PREVIEW_COUNT=8,OUTPUT_PREVIEW_LINES=5,COLLAPSED_ARGS_CHARS=80,SCRIPT_HEADER=/^Script (completed|failed)\nWall time [\d.]+ seconds\nOutput:\n$/;function expandHint(theme,hidden,noun){return`${theme.fg("muted",`... (${hidden} more ${noun},`)} ${keyHint("app.tools.expand","to expand")}${theme.fg("muted",")")}`}function formatDuration(ms){return ms===void 0?"":ms<1e3?`${Math.round(ms)}ms`:`${(ms/1e3).toFixed(1)}s`}function formatCost(cost){return`$${cost>=.01?cost.toFixed(
123
+ `)}`}],details:{loaded:tools.map(tool=>tool.name)}}}}}import{join}from"node:path";function wrapToolDefinition(definition,ctxFactory){return{name:definition.name,label:definition.label,description:definition.description,parameters:definition.parameters,outputSchema:definition.outputSchema,constrainedSampling:definition.constrainedSampling,prepareArguments:definition.prepareArguments,executionMode:definition.executionMode,execute:(toolCallId,params,signal,onUpdate,ctx)=>definition.execute(toolCallId,params,signal,onUpdate,ctx??ctxFactory?.(toolCallId,signal))}}function createToolDefinitionFromAgentTool(tool){return{name:tool.name,label:tool.label,description:tool.description,parameters:tool.parameters,outputSchema:tool.outputSchema,constrainedSampling:tool.constrainedSampling,prepareArguments:tool.prepareArguments,executionMode:tool.executionMode,execute:async(toolCallId,params,signal,onUpdate)=>tool.execute(toolCallId,params,signal,onUpdate)}}var loadCodemodeExecutor=()=>import("./execute-4X6G65NZ.js");var CODE_PREVIEW_LINES=10,CALL_PREVIEW_COUNT=8,OUTPUT_PREVIEW_LINES=5,COLLAPSED_ARGS_CHARS=80,SCRIPT_HEADER=/^Script (completed|failed)\nWall time [\d.]+ seconds\nOutput:\n$/;function expandHint(theme,hidden,noun){return`${theme.fg("muted",`... (${hidden} more ${noun},`)} ${keyHint("app.tools.expand","to expand")}${theme.fg("muted",")")}`}function formatDuration(ms){return ms===void 0?"":ms<1e3?`${Math.round(ms)}ms`:`${(ms/1e3).toFixed(1)}s`}function formatCost(cost){return`$${cost>=.01?cost.toFixed(
124
124
  2):cost.toPrecision(2)}`}function statusIcon(call,theme){switch(call.status){case"running":return theme.fg("warning","\u2026");case"ok":return theme.fg("success","\u2713");case"error":return theme.fg("error","\u2717");case"cancelled":return theme.fg("muted","\u2298")}}function formatCall(call,theme,expanded){let args=!expanded&&call.args.length>COLLAPSED_ARGS_CHARS?`${call.args.slice(0,COLLAPSED_ARGS_CHARS-3)}...`:call.args,duration=formatDuration(call.durationMs),line=`${statusIcon(call,theme)}\
125
125
  ${theme.fg("toolTitle",call.name)}`;return args&&(line+=` ${theme.fg("muted",args)}`),duration&&(line+=` ${theme.fg("dim",duration)}`),call.cost&&(line+=` ${theme.fg("dim",formatCost(call.cost))}`),expanded&&call.error&&(line+=`
126
126
  ${theme.fg("error",call.error.split(`