@humain/humain-code 0.4.17 → 0.4.18

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 (38) hide show
  1. package/CHANGELOG.md +13 -1
  2. package/dist/bundle/chunks/{chunk-W2QRCQBX.js → chunk-26EAEXO5.js} +18 -16
  3. package/dist/bundle/chunks/{chunk-65U7MPF4.js → chunk-2ZFUMXOZ.js} +11 -11
  4. package/dist/bundle/chunks/{chunk-AOL6QG6L.js → chunk-3UXBFT4Q.js} +64 -64
  5. package/dist/bundle/chunks/{chunk-PTP2ZHFQ.js → chunk-3XDL5ZE4.js} +1 -1
  6. package/dist/bundle/chunks/{chunk-DUSJT2W4.js → chunk-7VY5IL74.js} +1 -1
  7. package/dist/bundle/chunks/{chunk-X6OTEVGA.js → chunk-G6ABHCPB.js} +45 -30
  8. package/dist/bundle/chunks/{chunk-FHVNUUBF.js → chunk-HPSQKIWK.js} +1 -1
  9. package/dist/bundle/chunks/{chunk-36Q5UVQL.js → chunk-L5OUCJ7N.js} +9 -9
  10. package/dist/bundle/chunks/{chunk-LG2PJ6JN.js → chunk-NSMMDV3N.js} +2 -2
  11. package/dist/bundle/chunks/{chunk-ZRGFX6T6.js → chunk-OWLBGSXY.js} +2 -2
  12. package/dist/bundle/chunks/{chunk-4NFYTS4C.js → chunk-P4UKLIQB.js} +3 -3
  13. package/dist/bundle/chunks/{chunk-DNGJMRJW.js → chunk-SCIGZFN5.js} +11 -11
  14. package/dist/bundle/chunks/chunk-YLYOJQQX.js +1951 -0
  15. package/dist/bundle/chunks/{chunk-TJG52LZB.js → chunk-YMBXWW36.js} +1 -1
  16. package/dist/bundle/chunks/{cli-SRI4UOSL.js → cli-2NKM2RNJ.js} +1 -1
  17. package/dist/bundle/chunks/{compat-ARQPWKBQ.js → compat-VDGEZSVM.js} +1 -1
  18. package/dist/bundle/chunks/{dist-D7M52E3X.js → dist-ZJIYY3GA.js} +3 -3
  19. package/dist/bundle/chunks/{easter-egg-3d-4SUPLBUF.js → easter-egg-3d-VGJ77XZQ.js} +1 -1
  20. package/dist/bundle/chunks/es-N6YFJOD7.js +1901 -0
  21. package/dist/bundle/chunks/{esm-NCUV2DF7.js → esm-GIR7QH65.js} +1 -1
  22. package/dist/bundle/chunks/{execute-NTO3U76E.js → execute-ZBEZNJ4E.js} +1 -1
  23. package/dist/bundle/chunks/{extract-BKBHK4AK.js → extract-RFWEHH6W.js} +3 -3
  24. package/dist/bundle/chunks/{google-generative-ai-SJ4JO2MY.js → google-generative-ai-4OVYRP24.js} +1 -1
  25. package/dist/bundle/chunks/{google-vertex-KNLNNDET.js → google-vertex-3WQAZJQD.js} +1 -1
  26. package/dist/bundle/chunks/{node-ELWNZC34.js → node-A6SZ3T7E.js} +185 -185
  27. package/dist/bundle/chunks/{runtime-VGSK3QCM.js → runtime-HJEUOD4R.js} +1 -1
  28. package/dist/bundle/chunks/{undici-N4LWJ3S3.js → undici-4BK3MVJV.js} +1 -1
  29. package/dist/bundle/chunks/{virtual-modules-LP2ULVLW.js → virtual-modules-CFJTDIXL.js} +2 -2
  30. package/dist/bundle/cli-runtime.js +2 -2
  31. package/dist/bundle/flow/package.json +1 -1
  32. package/dist/bundle/index.js +5 -5
  33. package/dist/bundle/rpc-entry.js +2 -2
  34. package/npm-shrinkwrap.json +6 -6
  35. package/package.json +2 -2
  36. package/dist/bundle/chunks/chunk-4XU7TDAL.js +0 -1954
  37. package/dist/bundle/chunks/es-YEFEOGR3.js +0 -1905
  38. /package/dist/bundle/chunks/{chunk-XQRYOCHA.js → chunk-WZMA7HAJ.js} +0 -0
@@ -1,5 +1,5 @@
1
1
  import { createRequire as __piCreateRequire } from "node:module"; const require = __piCreateRequire(import.meta.url);
2
- import{compile,init_dist,is,require_canvas,require_lib}from"./chunk-W2QRCQBX.js";import{__export,__toESM}from"./chunk-JXWJOIH4.js";var CHANGED=Symbol("changed"),CLASS_LIST=Symbol("classList"),CUSTOM_ELEMENTS=Symbol("CustomElements"),CONTENT=Symbol("content"),DATASET=Symbol("dataset"),DOCTYPE=Symbol("doctype"),DOM_PARSER=Symbol("DOMParser"),END=Symbol("end"),EVENT_TARGET=Symbol("EventTarget"),GLOBALS=Symbol("globals"),IMAGE=Symbol("image"),MIME=Symbol("mime"),MUTATION_OBSERVER=Symbol("MutationObserver"),NEXT=Symbol("next"),OWNER_ELEMENT=Symbol("ownerElement"),PREV=Symbol("prev"),PRIVATE=Symbol("private"),SHEET=Symbol("sheet"),
2
+ import{compile,init_dist,is,require_canvas,require_lib}from"./chunk-26EAEXO5.js";import{__export,__toESM}from"./chunk-JXWJOIH4.js";var CHANGED=Symbol("changed"),CLASS_LIST=Symbol("classList"),CUSTOM_ELEMENTS=Symbol("CustomElements"),CONTENT=Symbol("content"),DATASET=Symbol("dataset"),DOCTYPE=Symbol("doctype"),DOM_PARSER=Symbol("DOMParser"),END=Symbol("end"),EVENT_TARGET=Symbol("EventTarget"),GLOBALS=Symbol("globals"),IMAGE=Symbol("image"),MIME=Symbol("mime"),MUTATION_OBSERVER=Symbol("MutationObserver"),NEXT=Symbol("next"),OWNER_ELEMENT=Symbol("ownerElement"),PREV=Symbol("prev"),PRIVATE=Symbol("private"),SHEET=Symbol("sheet"),
3
3
  START=Symbol("start"),STYLE=Symbol("style"),UPGRADE=Symbol("upgrade"),VALUE=Symbol("value");var esm_exports3={};__export(esm_exports3,{DefaultHandler:()=>DomHandler,DomHandler:()=>DomHandler,DomUtils:()=>esm_exports2,ElementType:()=>esm_exports,Parser:()=>Parser,QuoteType:()=>QuoteType,Tokenizer:()=>Tokenizer,createDocumentStream:()=>createDocumentStream,createDomStream:()=>createDomStream,getFeed:()=>getFeed,parseDOM:()=>parseDOM,parseDocument:()=>parseDocument,parseFeed:()=>parseFeed});var _a,decodeMap=new Map([[0,65533],[128,8364],[130,8218],[131,402],[132,8222],[133,8230],[134,8224],[135,8225],[136,710],[137,8240],[138,352],[139,8249],[140,338],[142,381],[145,8216],[146,8217],[147,8220],[148,8221],[149,8226],[150,8211],[151,8212],[152,732],[153,8482],[154,353],[155,8250],[156,339],[158,382],[159,376]]),fromCodePoint=(_a=String.fromCodePoint)!==null&&_a!==void 0?_a:(codePoint=>{let output="";return codePoint>65535&&(codePoint-=65536,output+=String.fromCharCode(codePoint>>>10&
4
4
  1023|55296),codePoint=56320|codePoint&1023),output+=String.fromCharCode(codePoint),output});function replaceCodePoint(codePoint){var _a3;return codePoint>=55296&&codePoint<=57343||codePoint>1114111?65533:(_a3=decodeMap.get(codePoint))!==null&&_a3!==void 0?_a3:codePoint}function decodeBase64(input){let binary=typeof atob=="function"?atob(input):typeof Buffer.from=="function"?Buffer.from(input,"base64").toString("binary"):new Buffer(input,"base64").toString("binary"),evenLength=binary.length&-2,out=new Uint16Array(evenLength/2);for(let index=0,outIndex=0;index<evenLength;index+=2){let lo=binary.charCodeAt(index),hi=binary.charCodeAt(index+1);out[outIndex++]=lo|hi<<8}return out}var htmlDecodeTree=decodeBase64("QR08ALkAAgH6AYsDNQR2BO0EPgXZBQEGLAbdBxMISQrvCmQLfQurDKQNLw4fD4YPpA+6D/IPAAAAAAAAAAAAAAAAKhBMEY8TmxUWF2EYLBkxGuAa3RsJHDscWR8YIC8jSCSIJcMl6ie3Ku8rEC0CLjoupS7kLgAIRU1hYmNmZ2xtbm9wcnN0dVQAWgBeAGUAaQBzAHcAfgCBAIQAhwCSAJoAoACsALMAbABpAGcAO4DGAMZAUAA7gCYAJkBjAHUAdABlADuAwQDBQHIiZXZlAAJhAAFpeW0AcgByAGMAO4DCAMJAEGRyAADgNdgE3XIAYQB2AGUAO4DAAMBA8CFoYZFj4SFjcgBhZAAAoFMqAAFncIsAjgBvAG4ABGFmAADgNdg43fAlbHlGdW5jdGlvbgCgYSBpAG4AZwA7gMUAxUAAAWNzpACoAHIAAOA12Jzc6SFnbgCgVCJpAGwAZAB\
5
5
  lADuAwwDDQG0AbAA7gMQAxEAABGFjZWZvcnN1xQDYANoA7QDxAPYA+QD8AAABY3LJAM8AayNzbGFzaAAAoBYidgHTANUAAKDnKmUAZAAAoAYjeQARZIABY3J0AOAA5QDrAGEidXNlAACgNSLuI291bGxpcwCgLCFhAJJjcgAA4DXYBd1wAGYAAOA12Dnd5SF2ZdhiYwDyAOoAbSJwZXEAAKBOIgAHSE9hY2RlZmhpbG9yc3UXARoBHwE6AVIBVQFiAWQBZgGCAakB6QHtAfIBYwB5ACdkUABZADuAqQCpQIABY3B5ACUBKAE1AfUhdGUGYWmg0iJ0KGFsRGlmZmVyZW50aWFsRAAAoEUhbCJleXMAAKAtIQACYWVpb0EBRAFKAU0B8iFvbgxhZABpAGwAO4DHAMdAcgBjAAhhbiJpbnQAAKAwIm8AdAAKYQABZG5ZAV0BaSJsbGEAuGB0I2VyRG90ALdg8gA5AWkAp2NyImNsZQAAAkR\
@@ -1,5 +1,5 @@
1
1
  import { createRequire as __piCreateRequire } from "node:module"; const require = __piCreateRequire(import.meta.url);
2
- import{Bm25Ranker,CODEMODE_DOCS_PATH,CODEMODE_STORE_ENTRY_TYPE,DEFAULT_TOOL_SEARCH_LIMIT,combineUsage,createToolSearchDocument,formatSize,getCodemodeCallableTools,parseCodemodeSource,renderToolSample,toCodemodeDeclaration,toCodemodeIdentifier,writeOutputFile}from"./chunk-LG2PJ6JN.js";import"./chunk-ZRGFX6T6.js";import"./chunk-XQRYOCHA.js";import"./chunk-DNGJMRJW.js";import"./chunk-UGXYG7HN.js";import{getCodemodeWorkerSpecifier,getQuickJSWasmPath}from"./chunk-YRCLNWFV.js";
2
+ import{Bm25Ranker,CODEMODE_DOCS_PATH,CODEMODE_STORE_ENTRY_TYPE,DEFAULT_TOOL_SEARCH_LIMIT,combineUsage,createToolSearchDocument,formatSize,getCodemodeCallableTools,parseCodemodeSource,renderToolSample,toCodemodeDeclaration,toCodemodeIdentifier,writeOutputFile}from"./chunk-NSMMDV3N.js";import"./chunk-OWLBGSXY.js";import"./chunk-WZMA7HAJ.js";import"./chunk-SCIGZFN5.js";import"./chunk-UGXYG7HN.js";import{getCodemodeWorkerSpecifier,getQuickJSWasmPath}from"./chunk-YRCLNWFV.js";
3
3
  import"./chunk-PY7SOXCA.js";import"./chunk-OKALNPTJ.js";import"./chunk-JXWJOIH4.js";function isWorkerToHostMessage(value){if(typeof value!="object"||value===null)return!1;let type=value.type;return type==="call"||type==="output"||type==="done"||type==="crash"||type==="started"||type==="idle"}var DEFAULT_TIMEOUT_MS=3e5,IDENTIFIER=/^[A-Za-z_$][A-Za-z0-9_$]*$/,RESERVED_GLOBALS=new Set(["tools","ALL_TOOLS","console","text","image","exit","globalThis","store","load"]);function errorMessage(error){return error instanceof Error?error.message:String(error)}function serializeStore(store){let serialized={};for(let[key,value]of Object.entries(store??{})){let json=JSON.stringify(value);json!==void 0&&(serialized[key]=json)}return serialized}var BridgeError=class extends Error{};function parseBridgeJson(json,what){
4
4
  try{return JSON.parse(json)}catch{throw new BridgeError(`${what} is not valid JSON`)}}function parseStoreWrites(json){let entries=parseBridgeJson(json,"store writes");if(!Array.isArray(entries))throw new BridgeError("store writes are not an array");let writes={set:{},delete:[]};for(let entry of entries){if(!Array.isArray(entry)||typeof entry[0]!="string"||(entry.length===2?typeof entry[1]!="string":entry.length!==1))throw new BridgeError("store writes contain a malformed entry");let[key,value]=entry;
5
5
  value===void 0?writes.delete.push(key):writes.set[key]=parseBridgeJson(value,`store value for ${JSON.stringify(key)}`)}return writes}function parseScriptError(json){let parsed=parseBridgeJson(json,"script error");if(typeof parsed!="object"||parsed===null)throw new BridgeError("script error is not an object");let{name,message,stack}=parsed;if(typeof message!="string"||name!==void 0&&typeof name!="string"||stack!==void 0&&typeof stack!="string")throw new BridgeError("script error is malformed");return{
@@ -1,7 +1,7 @@
1
1
  import { createRequire as __piCreateRequire } from "node:module"; const require = __piCreateRequire(import.meta.url);
2
2
  import{CredentialResolutionError,DEFAULT_MODEL,activityMonitor,askPerplexity,assertAuthFetchUrl,authFetchRedirectGuard,checkGhAvailable,extractGitHub,extractWithFirecrawl,extractWithKagi,extractWithOllama,extractWithParallel,extractWithParallelMcp,extractWithQuerit,extractWithSearch1API,extractWithTinyFish,fetchGeminiApi,fetchRemoteUrl,formatSeconds,getApiKey,getBrowserCookiesForHosts,getLastBrowserCookieDiagnostic,getUploadBase,getVersionedApiBase,getWebSearchConfigPath,hasCredentialSource,isFirecrawlAvailable,
3
3
  isGatewayConfigured,isGeminiAdcAvailable,isGeminiApiAvailable,isGeminiApiAvailableWithVideo,isGeminiWebAvailable,isKagiExtractAvailable,isLoopbackHostname,isOllamaFetchAvailable,isParallelAvailable,isPerplexityAvailable,isQueritAvailable,isSearch1APIAvailable,isTimeoutError,isTinyFishAvailable,loadFetchContentDomainPolicy,loadFetchContentRedirectPolicy,loadFetchContentUserAgent,loadSsrfConfig,mapFfmpegError,pLimit,parseGitHubUrl,queryGeminiApiWithInlineData,queryGeminiApiWithVideo,queryWithCookies,
4
- readExecError,redactCredential,redactGeminiApiResponse,resolveCredential,rewriteUploadUrlOrigin,showGhHint,trimErrorText,validateRemoteUrl}from"./chunk-PTP2ZHFQ.js";import"./chunk-SCBU5WOP.js";import"./chunk-YRCLNWFV.js";import"./chunk-Y26OS23T.js";import"./chunk-PY7SOXCA.js";import"./chunk-DBL35X7L.js";import"./chunk-YDBNMIA3.js";import"./chunk-5K5RFXXO.js";import"./chunk-IJYVMOB4.js";import"./chunk-VEYTRNQC.js";import"./chunk-AWCJWXGD.js";
4
+ readExecError,redactCredential,redactGeminiApiResponse,resolveCredential,rewriteUploadUrlOrigin,showGhHint,trimErrorText,validateRemoteUrl}from"./chunk-3XDL5ZE4.js";import"./chunk-SCBU5WOP.js";import"./chunk-YRCLNWFV.js";import"./chunk-Y26OS23T.js";import"./chunk-PY7SOXCA.js";import"./chunk-DBL35X7L.js";import"./chunk-YDBNMIA3.js";import"./chunk-5K5RFXXO.js";import"./chunk-IJYVMOB4.js";import"./chunk-VEYTRNQC.js";import"./chunk-AWCJWXGD.js";
5
5
  import"./chunk-OKALNPTJ.js";import"./chunk-JXWJOIH4.js";import{existsSync as existsSync10,readFileSync as readFileSync10}from"node:fs";function extractRSCContent(html){if(!html.includes("self.__next_f.push"))return null;let chunkMap=new Map,scriptRegex=/<script>self\.__next_f\.push\(\[1,"([\s\S]*?)"\]\)<\/script>/g;for(let match of html.matchAll(scriptRegex)){let content2;try{content2=JSON.parse('"'+match[1]+'"')}catch{continue}for(let line of content2.split(`
6
6
  `)){if(!line.trim())continue;let colonIdx=line.indexOf(":");if(colonIdx<=0||colonIdx>4)continue;let id=line.slice(0,colonIdx);if(!/^[0-9a-f]+$/i.test(id))continue;let payload=line.slice(colonIdx+1);if(!payload)continue;let existing=chunkMap.get(id);(!existing||payload.length>existing.length)&&chunkMap.set(id,payload)}}if(chunkMap.size===0)return null;let title=html.match(/<title[^>]*>([^<]+)<\/title>/)?.[1]?.split("|")[0]?.trim()||"",parsedCache=new Map;function getParsedChunk(id){if(parsedCache.
7
7
  has(id))return parsedCache.get(id);let chunk=chunkMap.get(id);if(!chunk||!chunk.startsWith("["))return parsedCache.set(id,null),null;try{let parsed=JSON.parse(chunk);return parsedCache.set(id,parsed),parsed}catch{return parsedCache.set(id,null),null}}let visitedRefs=new Set;function extractNode(node,ctx={inTable:!1,inCode:!1}){if(node==null)return"";if(typeof node=="string"){let refMatch=node.match(/^\$L([0-9a-f]+)$/i);if(refMatch){let refId=refMatch[1];if(visitedRefs.has(refId))return"";visitedRefs.
@@ -282,7 +282,7 @@ pieces.join(""))}function sanitizeInlineDataUris(text,sourcePath){let state={nex
282
282
  `Invalid config in ${WEB_SEARCH_CONFIG_PATH}: expected a JSON object`);let fetchConfig=raw.fetch;if(fetchConfig===void 0)return DEFAULT_TIMEOUT_MS4;if(!fetchConfig||typeof fetchConfig!="object"||Array.isArray(fetchConfig))throw new Error(`fetch in ${WEB_SEARCH_CONFIG_PATH} must be an object`);let value=fetchConfig.timeout;if(value===void 0)return DEFAULT_TIMEOUT_MS4;if(typeof value!="number"||!Number.isFinite(value)||value<=0)throw new Error(`Invalid fetch.timeout in ${WEB_SEARCH_CONFIG_PATH}: e\
283
283
  xpected a positive finite number of seconds, got ${JSON.stringify(value)}`);let timeoutMs=Math.ceil(value*1e3);if(!Number.isSafeInteger(timeoutMs)||timeoutMs<1||timeoutMs>MAX_CONFIGURED_TIMEOUT_MS)throw new Error(`Invalid fetch.timeout in ${WEB_SEARCH_CONFIG_PATH}: converted timeout must be a finite safe integer from 1 through ${MAX_CONFIGURED_TIMEOUT_MS} milliseconds`);return Math.max(1,timeoutMs)}var NON_RECOVERABLE_ERRORS=["Unsupported content type","Response too large","PDF extraction is dis\
284
284
  abled","Image fetching is disabled"],MIN_USEFUL_CONTENT=500,SUPPORTED_IMAGE_TYPES=new Set(["image/png","image/jpeg","image/webp","image/gif"]),FETCH_PROVIDERS=["http","firecrawl","crawl4ai","jina","tinyfish","search1api","querit","kagi","ollama","parallel","parallel-mcp","brightdata","gemini"],DEFAULT_FETCH_PROVIDER_ORDER=["http","firecrawl","crawl4ai","jina","tinyfish","search1api","querit","kagi","ollama","parallel","brightdata","gemini"],REMOTE_HOSTED_FETCH_PROVIDERS=new Set(["jina","tinyfish",
285
- "search1api","querit","kagi","ollama","parallel","parallel-mcp","brightdata","gemini"]);function isDefuddleConsoleError(args){let prefix=args[0];return prefix==="Defuddle"||typeof prefix=="string"&&/^Defuddle(?:\s|:)/.test(prefix)}async function extractWithDefuddle(text,url){let{Defuddle}=await import("./node-ELWNZC34.js"),{parseHTML}=await import("./esm-NCUV2DF7.js"),{document}=parseHTML(text);Object.defineProperty(document,"location",{value:new URL(url),configurable:!0});let processingError,
285
+ "search1api","querit","kagi","ollama","parallel","parallel-mcp","brightdata","gemini"]);function isDefuddleConsoleError(args){let prefix=args[0];return prefix==="Defuddle"||typeof prefix=="string"&&/^Defuddle(?:\s|:)/.test(prefix)}async function extractWithDefuddle(text,url){let{Defuddle}=await import("./node-A6SZ3T7E.js"),{parseHTML}=await import("./esm-GIR7QH65.js"),{document}=parseHTML(text);Object.defineProperty(document,"location",{value:new URL(url),configurable:!0});let processingError,
286
286
  originalConsoleError=console.error;console.error=(...args)=>{if(isDefuddleConsoleError(args)){args[0]==="Defuddle"&&args[1]==="Error processing document:"&&(processingError=args[2]);return}originalConsoleError(...args)};let resultPromise;try{resultPromise=Defuddle(document,url,{markdown:!0,useAsync:!1})}finally{console.error=originalConsoleError}let result=await resultPromise;if(processingError!==void 0)throw new Error(`Defuddle failed to process document: ${errorMessage5(processingError)}`);return typeof result.
287
287
  content=="string"?{title:result.title,content:result.content}:null}function loadSsrfAllowRanges(){return loadSsrfConfig().allowRanges}function errorMessage5(err){return err instanceof Error?err.message:String(err)}function isConfigParseError(err){return errorMessage5(err).startsWith("Failed to parse ")}function isAbortError3(err){return errorMessage5(err).toLowerCase().includes("abort")}function isAbortException2(err){return err instanceof DOMException&&(err.name==="AbortError"||err.name==="Time\
288
288
  outError")}function isRedirectPolicyError(message){return message.startsWith("Authenticated fetch refused cross-origin redirect")||message.startsWith("Refused cross-origin redirect by fetch_content redirect policy")||message.startsWith("Blocked internal ")||message.startsWith("Blocked hostname by fetch_content domain policy")||message.startsWith("Hostname not allowed by fetch_content domain policy")||message.startsWith("Too many redirects fetching ")||message==="Only HTTP and HTTPS URLs can be f\
@@ -365,7 +365,7 @@ includes("image/")||contentType.includes("audio/")||contentType.includes("video/
365
365
  logComplete(activityId,response.status),{url,title:"",content:"",error:`HTTP ${response.status}: Blocked by Cloudflare challenge page`,status:response.status};if(!isHTML){activityMonitor.logComplete(activityId,response.status);let title=extractTextTitle(text,url);if(mimeType!=="text/markdown"&&mimeType!=="text/x-markdown")return{url,title,content:text,error:null};let declaredLinks2=discoverDeclaredWebLinks(null,response.headers.get("link"),response.url||url),markdown2={url,title,content:appendDeclaredWebLinks(
366
366
  text,declaredLinks2),error:null,declaredLinks:declaredLinks2};if(!preferMarkdown||text.trim().length>=MIN_USEFUL_CONTENT)return markdown2;let normal=await extractViaHttp(url,Math.max(1,timeoutMs-(Date.now()-startedAt)),signal,options,!1);return signal?.aborted||isNonRecoverableHttpError(normal.error)||normal.status===404||normal.status===410||isAbortError3(normal.error)||normal.content.trim()!==appendDeclaredWebLinks("",normal.declaredLinks??[]).trim()||!markdown2.content.trim()?normal:{...normal,
367
367
  ...markdown2,error:"Extracted content appears incomplete"+(normal.error?`
368
- Browser retry failed: ${normal.error}`:"")}}let{parseHTML}=await import("./esm-NCUV2DF7.js"),{document}=parseHTML(text),documentTitle=document.title?.trim()??"",declaredLinks=discoverDeclaredWebLinks(document,response.headers.get("link"),response.url||url),{Readability}=await import("./readability-4ONZTBJO.js"),article=new Readability(document).parse();if(!article){let rscResult=extractRSCContent(text);if(rscResult&&rscResult.content.length>=MIN_USEFUL_CONTENT)return activityMonitor.logComplete(
368
+ Browser retry failed: ${normal.error}`:"")}}let{parseHTML}=await import("./esm-GIR7QH65.js"),{document}=parseHTML(text),documentTitle=document.title?.trim()??"",declaredLinks=discoverDeclaredWebLinks(document,response.headers.get("link"),response.url||url),{Readability}=await import("./readability-4ONZTBJO.js"),article=new Readability(document).parse();if(!article){let rscResult=extractRSCContent(text);if(rscResult&&rscResult.content.length>=MIN_USEFUL_CONTENT)return activityMonitor.logComplete(
369
369
  activityId,response.status),{url,title:rscResult.title,content:appendDeclaredWebLinks(rscResult.content,declaredLinks),error:null,declaredLinks};controller.signal.throwIfAborted();let defuddleResult=await extractWithDefuddle(text,response.url||url);if(controller.signal.throwIfAborted(),defuddleResult&&defuddleResult.content.length>=MIN_USEFUL_CONTENT)return activityMonitor.logComplete(activityId,response.status),{url,title:documentTitle||defuddleResult.title,content:appendDeclaredWebLinks(defuddleResult.
370
370
  content,declaredLinks),error:null,declaredLinks};activityMonitor.logComplete(activityId,response.status);let errorMsg=isLikelyJSRendered(text)?"Page appears to be JavaScript-rendered (content loads dynamically)":"Could not extract readable content from HTML structure";return{url,title:documentTitle,content:appendDeclaredWebLinks("",declaredLinks),error:errorMsg,declaredLinks}}if(typeof article.content!="string")throw new Error("Readability returned invalid article content");let markdown=(await getTurndown()).
371
371
  turndown(article.content);if(activityMonitor.logComplete(activityId,response.status),markdown.length<MIN_USEFUL_CONTENT){let rscResult=extractRSCContent(text);if(rscResult&&rscResult.content.length>=MIN_USEFUL_CONTENT)return{url,title:rscResult.title,content:appendDeclaredWebLinks(rscResult.content,declaredLinks),error:null,declaredLinks};controller.signal.throwIfAborted();let defuddleResult=await extractWithDefuddle(text,response.url||url);return controller.signal.throwIfAborted(),defuddleResult&&
@@ -1,5 +1,5 @@
1
1
  import { createRequire as __piCreateRequire } from "node:module"; const require = __piCreateRequire(import.meta.url);
2
- import{GoogleGenAI,convertMessages,convertTools,getDisabledGoogleThinkingConfig,isThinkingPart,mapStopReason,resolveGoogleFunctionCallingMode,resolveGoogleThinkingLevel,retainThoughtSignature,retryGoogleRequest,supportsGoogleStrictToolSampling,toGoogleSdkThinkingLevel,toGoogleThinkingLevel,usesGoogleThinkingLevel}from"./chunk-X6OTEVGA.js";import"./chunk-Z33NNMNB.js";import{formatProviderError,normalizeProviderError}from"./chunk-MVYV6MJY.js";import{buildBaseOptions,getPiUserAgent}from"./chunk-TIFFHHW6.js";
2
+ import{GoogleGenAI,convertMessages,convertTools,getDisabledGoogleThinkingConfig,isThinkingPart,mapStopReason,resolveGoogleFunctionCallingMode,resolveGoogleThinkingLevel,retainThoughtSignature,retryGoogleRequest,supportsGoogleStrictToolSampling,toGoogleSdkThinkingLevel,toGoogleThinkingLevel,usesGoogleThinkingLevel}from"./chunk-G6ABHCPB.js";import"./chunk-Z33NNMNB.js";import{formatProviderError,normalizeProviderError}from"./chunk-MVYV6MJY.js";import{buildBaseOptions,getPiUserAgent}from"./chunk-TIFFHHW6.js";
3
3
  import{hasIncompleteUsage}from"./chunk-YTVFIA3A.js";import{sanitizeSurrogates}from"./chunk-L2ZPNLYD.js";import{createRequestObserver,observeFetch,providerHeadersToRecord}from"./chunk-5CDES42D.js";import{calculateCost,clampThinkingLevel,collapseSystemMessages,getCurrentTools,getInitialSystemMessage,getSystemMessageText}from"./chunk-5K5RFXXO.js";import{AssistantMessageEventStream}from"./chunk-IJYVMOB4.js";import"./chunk-VEYTRNQC.js";import"./chunk-JXWJOIH4.js";var toolCallCounter=0,stream=(model,context,options)=>{let stream2=new AssistantMessageEventStream,normalizedContext=collapseSystemMessages(context);return(async()=>{let output={role:"assistant",content:[],api:"google-generative-ai",provider:model.provider,model:model.id,usage:{usageIncomplete:!0,input:0,output:0,cacheRead:0,cacheWrite:0,totalTokens:0,cost:{input:0,output:0,cacheRead:0,cacheWrite:0,total:0}},stopReason:"pending",timestamp:Date.now()};try{if(options?.fetch&&options.fetch!==globalThis.
4
4
  fetch)throw new Error("Custom fetch is not supported by the Google Generative AI adapter");let apiKey=options?.apiKey;if(!apiKey)throw new Error(`No API key for provider: ${model.provider}`);let observe=createRequestObserver(options,{api:model.api,provider:model.provider,model:model.id,operation:"chat"}),client=createClient(model,apiKey,options?.headers,observeFetch(void 0,observe)),params=buildParams(model,normalizedContext,options),nextParams=await options?.onPayload?.(params,model);nextParams!==
5
5
  void 0&&(params=nextParams);let googleStream=await retryGoogleRequest(()=>client.models.generateContentStream(params),options);stream2.push({type:"start",partial:output});let currentBlock=null,blocks=output.content,blockIndex=()=>blocks.length-1;for await(let chunk of googleStream){await options?.onProviderStreamEvent?.(chunk,model),output.responseId||=chunk.responseId;let candidate=chunk.candidates?.[0];if(candidate?.content?.parts)for(let part of candidate.content.parts){if(part.text!==void 0){
@@ -1,5 +1,5 @@
1
1
  import { createRequire as __piCreateRequire } from "node:module"; const require = __piCreateRequire(import.meta.url);
2
- import{GoogleGenAI,ResourceScope,convertMessages,convertTools,getDisabledGoogleThinkingConfig,isThinkingPart,mapStopReason,resolveGoogleFunctionCallingMode,resolveGoogleThinkingLevel,retainThoughtSignature,retryGoogleRequest,supportsGoogleStrictToolSampling,toGoogleSdkThinkingLevel,toGoogleThinkingLevel,usesGoogleThinkingLevel}from"./chunk-X6OTEVGA.js";import"./chunk-Z33NNMNB.js";import{formatProviderError,normalizeProviderError}from"./chunk-MVYV6MJY.js";import{buildBaseOptions,
2
+ import{GoogleGenAI,ResourceScope,convertMessages,convertTools,getDisabledGoogleThinkingConfig,isThinkingPart,mapStopReason,resolveGoogleFunctionCallingMode,resolveGoogleThinkingLevel,retainThoughtSignature,retryGoogleRequest,supportsGoogleStrictToolSampling,toGoogleSdkThinkingLevel,toGoogleThinkingLevel,usesGoogleThinkingLevel}from"./chunk-G6ABHCPB.js";import"./chunk-Z33NNMNB.js";import{formatProviderError,normalizeProviderError}from"./chunk-MVYV6MJY.js";import{buildBaseOptions,
3
3
  getPiUserAgent}from"./chunk-TIFFHHW6.js";import{hasIncompleteUsage}from"./chunk-YTVFIA3A.js";import{sanitizeSurrogates}from"./chunk-L2ZPNLYD.js";import{createRequestObserver,observeFetch,providerHeadersToRecord}from"./chunk-5CDES42D.js";import{getProviderEnvValue}from"./chunk-FACBDLFU.js";import{calculateCost,clampThinkingLevel,collapseSystemMessages,getCurrentTools,getInitialSystemMessage,getSystemMessageText}from"./chunk-5K5RFXXO.js";import{AssistantMessageEventStream}from"./chunk-IJYVMOB4.js";
4
4
  import"./chunk-VEYTRNQC.js";import"./chunk-JXWJOIH4.js";var API_VERSION="v1",GCP_VERTEX_CREDENTIALS_MARKER="gcp-vertex-credentials",toolCallCounter=0,stream=(model,context,options)=>{let stream2=new AssistantMessageEventStream,normalizedContext=collapseSystemMessages(context);return(async()=>{let output={role:"assistant",content:[],api:"google-vertex",provider:model.provider,model:model.id,usage:{usageIncomplete:!0,input:0,output:0,cacheRead:0,cacheWrite:0,totalTokens:0,cost:{input:0,output:0,cacheRead:0,cacheWrite:0,total:0}},stopReason:"pending",timestamp:Date.
5
5
  now()};try{if(options?.fetch&&options.fetch!==globalThis.fetch)throw new Error("Custom fetch is not supported by the Google Vertex adapter");let apiKey=resolveApiKey(options),observe=createRequestObserver(options,{api:model.api,provider:model.provider,model:model.id,operation:"chat"}),observedFetch=observeFetch(void 0,observe),client=apiKey?createClientWithApiKey(model,apiKey,options?.headers,observedFetch):createClient(model,resolveProject(options),resolveLocation(options),options?.headers,options?.