@herbertgao/pi-extensions 2026.10.11 → 2026.10.12
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.
- package/README.md +7 -7
- package/THIRD_PARTY_NOTICES.md +1 -1
- package/node_modules/@herbertgao/pi-agency/README.md +5 -3
- package/node_modules/@herbertgao/pi-agency/package.json +1 -1
- package/node_modules/@herbertgao/pi-agency/src/index.ts +51 -7
- package/node_modules/@herbertgao/pi-subagents/CHANGELOG.md +6 -0
- package/node_modules/@herbertgao/pi-subagents/package.json +1 -1
- package/node_modules/@herbertgao/pi-subagents/src/agent-color.ts +11 -2
- package/node_modules/@herbertgao/pi-subagents/src/index.ts +10 -5
- package/node_modules/@herbertgao/pi-subagents/src/ui/agent-widget.ts +3 -2
- package/node_modules/@herbertgao/pi-subagents/src/ui/conversation-viewer.ts +1 -1
- package/node_modules/@herbertgao/pi-subagents/src/ui/fleet-list.ts +1 -0
- package/node_modules/@herbertgao/sol-pi/README.md +1 -1
- package/node_modules/@herbertgao/sol-pi/agents-install.md +2 -2
- package/node_modules/@narumitw/pi-btw/README.md +14 -5
- package/node_modules/@narumitw/pi-btw/dist/index.ts +1067 -560
- package/node_modules/@narumitw/pi-btw/dist/index.ts.map +4 -4
- package/node_modules/@narumitw/pi-btw/docs/core-alignment.md +277 -0
- package/node_modules/@narumitw/pi-btw/docs/native-appearance.md +857 -0
- package/node_modules/@narumitw/pi-btw/docs/workflows.md +34 -13
- package/node_modules/@narumitw/pi-btw/package.json +4 -4
- package/node_modules/@narumitw/pi-btw/src/btw.ts +152 -108
- package/node_modules/@narumitw/pi-btw/src/conversation-chrome.ts +93 -0
- package/node_modules/@narumitw/pi-btw/src/fullscreen-renderer.ts +329 -0
- package/node_modules/@narumitw/pi-btw/src/fullscreen-ui.ts +109 -315
- package/node_modules/@narumitw/pi-btw/src/keybindings.ts +100 -22
- package/node_modules/@narumitw/pi-btw/src/menu.ts +42 -27
- package/node_modules/@narumitw/pi-btw/src/session-lifetime.ts +66 -0
- package/node_modules/@narumitw/pi-btw/src/transcript-pager.ts +366 -164
- package/node_modules/@narumitw/pi-btw/src/workspace-layout.ts +96 -36
- package/node_modules/pi-lens/CHANGELOG.md +281 -0
- package/node_modules/pi-lens/README.md +13 -1
- package/node_modules/pi-lens/dist/{chunk-SS36ZX4J.js → chunk-24AKHFGP.js} +6 -6
- package/node_modules/pi-lens/dist/{chunk-JSQFTSC6.js → chunk-2FN63LPV.js} +11 -11
- package/node_modules/pi-lens/dist/{chunk-5UCAH366.js → chunk-2KXTHF3M.js} +20 -20
- package/node_modules/pi-lens/dist/{chunk-EU63SDCG.js → chunk-3DA2JDOL.js} +367 -281
- package/node_modules/pi-lens/dist/{chunk-RWWYJ623.js → chunk-3KAZU3VR.js} +1 -1
- package/node_modules/pi-lens/dist/chunk-3PTHXJXR.js +28 -0
- package/node_modules/pi-lens/dist/chunk-3QED2P4V.js +31 -0
- package/node_modules/pi-lens/dist/{chunk-N2H3ZPZY.js → chunk-3RKP3FMS.js} +1 -0
- package/node_modules/pi-lens/dist/{chunk-XVF2VVXP.js → chunk-5HSRT26B.js} +2 -2
- package/node_modules/pi-lens/dist/{chunk-MXGY6KPT.js → chunk-5IUSNGOC.js} +15 -15
- package/node_modules/pi-lens/dist/{chunk-EJIUXPBX.js → chunk-5OFV52AM.js} +1 -1
- package/node_modules/pi-lens/dist/{chunk-AW7R2GWG.js → chunk-5VSF4UUQ.js} +12 -7
- package/node_modules/pi-lens/dist/{chunk-6STA6Z7I.js → chunk-5WRPDP2A.js} +18 -18
- package/node_modules/pi-lens/dist/{chunk-YIUAVF7E.js → chunk-6DLWKFEX.js} +35 -34
- package/node_modules/pi-lens/dist/{chunk-WOA4LN2R.js → chunk-7D6L4MTX.js} +2 -2
- package/node_modules/pi-lens/dist/{chunk-GAEGEPOC.js → chunk-7HXE67BN.js} +2 -2
- package/node_modules/pi-lens/dist/chunk-AGSS7277.js +84 -0
- package/node_modules/pi-lens/dist/{chunk-R3PCY3YS.js → chunk-AMERCH6V.js} +13 -13
- package/node_modules/pi-lens/dist/{chunk-WU567RSC.js → chunk-ATKJFDQN.js} +14 -10
- package/node_modules/pi-lens/dist/{chunk-VSSBEUFT.js → chunk-AWSCPCN2.js} +16 -16
- package/node_modules/pi-lens/dist/{chunk-VCHXCQFG.js → chunk-BWD5EPKO.js} +3 -3
- package/node_modules/pi-lens/dist/{chunk-H6MF6EVN.js → chunk-CT4MN5IU.js} +1200 -230
- package/node_modules/pi-lens/dist/{chunk-FCSOVF55.js → chunk-CUHSHSB6.js} +6 -6
- package/node_modules/pi-lens/dist/{chunk-CHOW74WE.js → chunk-CYRKQRPM.js} +7 -10
- package/node_modules/pi-lens/dist/{chunk-Q7DUK4LX.js → chunk-DEL2U6CM.js} +5 -5
- package/node_modules/pi-lens/dist/{chunk-6C7JWPCP.js → chunk-DGUKIYSI.js} +26 -23
- package/node_modules/pi-lens/dist/{chunk-PHDMFAKM.js → chunk-DUO2TU77.js} +2 -2
- package/node_modules/pi-lens/dist/{chunk-MRXKYPCS.js → chunk-EBC36LNN.js} +2 -2
- package/node_modules/pi-lens/dist/{chunk-CSHFH5IN.js → chunk-ED36RF6Y.js} +1 -1
- package/node_modules/pi-lens/dist/{chunk-76MWC2K6.js → chunk-EUXZEFTV.js} +90 -97
- package/node_modules/pi-lens/dist/{chunk-QOZXJ4NA.js → chunk-FM4RDMKT.js} +11 -8
- package/node_modules/pi-lens/dist/{chunk-ACXEQZOU.js → chunk-GAQ7OQG6.js} +31 -28
- package/node_modules/pi-lens/dist/{chunk-XAGLWMJ4.js → chunk-GL5LUMZE.js} +23 -23
- package/node_modules/pi-lens/dist/{chunk-BKE7E7TC.js → chunk-GMX5OS7B.js} +9 -9
- package/node_modules/pi-lens/dist/{chunk-ZHFZWTZV.js → chunk-GSLNCYGG.js} +11 -11
- package/node_modules/pi-lens/dist/{chunk-3W7IEVVL.js → chunk-GSM5UU7A.js} +26 -34
- package/node_modules/pi-lens/dist/{chunk-724UL2TJ.js → chunk-GXFV6MYU.js} +3 -3
- package/node_modules/pi-lens/dist/chunk-HAD7QRQI.js +30 -0
- package/node_modules/pi-lens/dist/{chunk-QOBUHWHX.js → chunk-HRNHZA3N.js} +6 -6
- package/node_modules/pi-lens/dist/{chunk-VWCXW2E7.js → chunk-HWCCCQNX.js} +1 -1
- package/node_modules/pi-lens/dist/{chunk-7DYBLXYA.js → chunk-HYGZEMX6.js} +3 -3
- package/node_modules/pi-lens/dist/chunk-IJYGIDF4.js +186 -0
- package/node_modules/pi-lens/dist/{chunk-4W4VLAPJ.js → chunk-IQWN5JCP.js} +11 -11
- package/node_modules/pi-lens/dist/{chunk-SQ4TVJBR.js → chunk-IUE7SSKV.js} +7 -7
- package/node_modules/pi-lens/dist/{chunk-IBGIOBEE.js → chunk-IWDLU6K3.js} +68 -5
- package/node_modules/pi-lens/dist/{chunk-XCJN5IJU.js → chunk-IYNJ6YPZ.js} +4 -4
- package/node_modules/pi-lens/dist/{chunk-JAU72XNY.js → chunk-J64T55EI.js} +3 -3
- package/node_modules/pi-lens/dist/{chunk-2BBLFX75.js → chunk-J6MPGQTS.js} +5 -5
- package/node_modules/pi-lens/dist/chunk-JORED7EX.js +44 -0
- package/node_modules/pi-lens/dist/{chunk-6SDEP3AJ.js → chunk-JUKMK5Y4.js} +8 -8
- package/node_modules/pi-lens/dist/{chunk-FMSO6RDZ.js → chunk-JW3YWBVB.js} +15 -15
- package/node_modules/pi-lens/dist/{chunk-L3BLXZG7.js → chunk-KAPJINKN.js} +30 -69
- package/node_modules/pi-lens/dist/{chunk-2B73ZPOK.js → chunk-KN35K52N.js} +3 -3
- package/node_modules/pi-lens/dist/{chunk-C34ZXZ7O.js → chunk-KUA4OJ5Y.js} +24 -11
- package/node_modules/pi-lens/dist/chunk-KYUB6QDC.js +72 -0
- package/node_modules/pi-lens/dist/{chunk-67WMNWEE.js → chunk-LLJNQKQW.js} +12 -10
- package/node_modules/pi-lens/dist/chunk-LZSEQW6A.js +57 -0
- package/node_modules/pi-lens/dist/{chunk-ZANLILYD.js → chunk-M2IFVFWU.js} +2 -2
- package/node_modules/pi-lens/dist/chunk-M2UD3LPU.js +88 -0
- package/node_modules/pi-lens/dist/{chunk-XIJZVPD5.js → chunk-MBKQHGA7.js} +15 -15
- package/node_modules/pi-lens/dist/{chunk-P7266HLM.js → chunk-MPNJLASA.js} +2 -2
- package/node_modules/pi-lens/dist/{chunk-6GFRNVYR.js → chunk-MZGQNL3Y.js} +10 -10
- package/node_modules/pi-lens/dist/{chunk-ZWFS3OEF.js → chunk-N5FLEO7W.js} +33 -32
- package/node_modules/pi-lens/dist/{chunk-3JNKMP3B.js → chunk-O4NWQT6I.js} +4 -4
- package/node_modules/pi-lens/dist/{chunk-T6CPIZNT.js → chunk-OHKJ7PQF.js} +33 -32
- package/node_modules/pi-lens/dist/{chunk-VRZP76YM.js → chunk-P63GXC37.js} +4 -1
- package/node_modules/pi-lens/dist/{chunk-XTMJ7XDT.js → chunk-POMLXPMY.js} +1 -1
- package/node_modules/pi-lens/dist/{chunk-QQNQ7SJW.js → chunk-QBFBRV2B.js} +10 -4
- package/node_modules/pi-lens/dist/{chunk-CMMHNUZ2.js → chunk-R3T7CLQ2.js} +60 -38
- package/node_modules/pi-lens/dist/{chunk-23WOO7TX.js → chunk-R7YOCSNV.js} +10 -10
- package/node_modules/pi-lens/dist/{chunk-2CD5RS6M.js → chunk-RKBXZN3A.js} +23 -2
- package/node_modules/pi-lens/dist/{chunk-OCAGUNBC.js → chunk-RKKOYPRA.js} +12 -12
- package/node_modules/pi-lens/dist/{chunk-52FUZI6K.js → chunk-RMLC67LF.js} +1 -1
- package/node_modules/pi-lens/dist/{chunk-XMSXXAHW.js → chunk-ROYSX2S5.js} +2 -2
- package/node_modules/pi-lens/dist/{chunk-M6HSLBWY.js → chunk-RVK72CZX.js} +6507 -7514
- package/node_modules/pi-lens/dist/{chunk-FLKWCIZH.js → chunk-S2HEXIWI.js} +5 -5
- package/node_modules/pi-lens/dist/{chunk-UZ3TUTRV.js → chunk-S67KYG37.js} +1 -1
- package/node_modules/pi-lens/dist/{chunk-VCO24T4L.js → chunk-SD4I7ZO4.js} +14 -14
- package/node_modules/pi-lens/dist/{chunk-Z527N6YQ.js → chunk-SKAMFC7A.js} +12 -12
- package/node_modules/pi-lens/dist/{chunk-MQLUAEOC.js → chunk-SRYEJNES.js} +2 -2
- package/node_modules/pi-lens/dist/{chunk-BRGDSBJE.js → chunk-SYE6T2EB.js} +12 -12
- package/node_modules/pi-lens/dist/{chunk-GXW6K4YJ.js → chunk-T57LYLZT.js} +1 -1
- package/node_modules/pi-lens/dist/{chunk-ZXYDQ3TZ.js → chunk-T7FEBKXN.js} +48 -15
- package/node_modules/pi-lens/dist/{chunk-3EFKIGZN.js → chunk-TIQ2PKDW.js} +3 -3
- package/node_modules/pi-lens/dist/{chunk-QILIYSJF.js → chunk-TLX72JTG.js} +1 -1
- package/node_modules/pi-lens/dist/{chunk-TYM6OUIT.js → chunk-TOY6QKOH.js} +12 -12
- package/node_modules/pi-lens/dist/{chunk-IZSHAIJ7.js → chunk-TRETHTQO.js} +12 -12
- package/node_modules/pi-lens/dist/{chunk-3VPVG5SU.js → chunk-U44DJXQP.js} +10 -6
- package/node_modules/pi-lens/dist/{chunk-PNQDPDRC.js → chunk-UA7ZXYDR.js} +1 -1
- package/node_modules/pi-lens/dist/{chunk-OXXKQCSV.js → chunk-UBOQLVT2.js} +4 -4
- package/node_modules/pi-lens/dist/{chunk-QGQ5CCCG.js → chunk-UMS2MFPZ.js} +2 -2
- package/node_modules/pi-lens/dist/{chunk-QHJ6DQ2R.js → chunk-US7ECLD7.js} +55 -13
- package/node_modules/pi-lens/dist/{chunk-AB3YYG6N.js → chunk-UZ2XCLYS.js} +8 -8
- package/node_modules/pi-lens/dist/chunk-V35JG4JB.js +2667 -0
- package/node_modules/pi-lens/dist/{chunk-N3X6Q4YT.js → chunk-VOOAPROD.js} +3 -3
- package/node_modules/pi-lens/dist/{chunk-SAEFPSB6.js → chunk-W66O5E25.js} +21 -11
- package/node_modules/pi-lens/dist/{chunk-KBG47GHP.js → chunk-WMYE35PX.js} +15 -11
- package/node_modules/pi-lens/dist/{chunk-5NGR67U5.js → chunk-XBJVAEEO.js} +32 -5
- package/node_modules/pi-lens/dist/{chunk-YYOIQFRS.js → chunk-XHJBS436.js} +122 -44
- package/node_modules/pi-lens/dist/{chunk-GBPP5P7X.js → chunk-XTBDCR27.js} +4 -4
- package/node_modules/pi-lens/dist/{chunk-4UNXBNE2.js → chunk-XTFDJI3T.js} +11 -11
- package/node_modules/pi-lens/dist/{chunk-UXGETRP4.js → chunk-XYURS6EN.js} +13 -12
- package/node_modules/pi-lens/dist/{chunk-RPLINGVB.js → chunk-Y6GZHWSJ.js} +6 -6
- package/node_modules/pi-lens/dist/{chunk-2VUQMUMT.js → chunk-YCWYO6TQ.js} +41 -38
- package/node_modules/pi-lens/dist/{chunk-77M37OKR.js → chunk-YH5MVY2U.js} +7 -7
- package/node_modules/pi-lens/dist/{chunk-AOHZU2BM.js → chunk-YNE3RP52.js} +1 -1
- package/node_modules/pi-lens/dist/{chunk-YSZNHOBY.js → chunk-ZHH37KZL.js} +12 -12
- package/node_modules/pi-lens/dist/{chunk-ZGDGW2V3.js → chunk-ZIVJBOO3.js} +2 -2
- package/node_modules/pi-lens/dist/{chunk-RXCOMYPY.js → chunk-ZVUL7QYY.js} +29 -28
- package/node_modules/pi-lens/dist/index.js +11052 -5852
- package/node_modules/pi-lens/dist/mcp/analyze-cli.js +10 -9
- package/node_modules/pi-lens/dist/mcp/cli.js +41 -38
- package/node_modules/pi-lens/dist/mcp/server.js +1120 -474
- package/node_modules/pi-lens/dist/mcp/worker.js +61 -58
- package/node_modules/pi-lens/dist/probes/installer.js +19 -19
- package/node_modules/pi-lens/dist/workers/project-snapshot-persist-worker.js +28 -9
- package/node_modules/pi-lens/dist/workers/review-graph-persist-worker.js +1 -1
- package/node_modules/pi-lens/docs/configuration.md +11 -0
- package/node_modules/pi-lens/docs/engineering-principles.md +32 -0
- package/node_modules/pi-lens/docs/lsp-capability-matrix.md +1 -1
- package/node_modules/pi-lens/docs/lsp-idle-eviction.md +15 -26
- package/node_modules/pi-lens/docs/pi-lens-fixer.md +117 -13
- package/node_modules/pi-lens/docs/pi-lens-merge-policy.md +97 -7
- package/node_modules/pi-lens/docs/pi-lens-monitor.md +8 -2
- package/node_modules/pi-lens/docs/pi-lens-retro.md +4 -1
- package/node_modules/pi-lens/docs/pi-lens-reviewer.md +112 -4
- package/node_modules/pi-lens/docs/pi-lens-subagent.md +22 -14
- package/node_modules/pi-lens/docs/release-qa-baseline.md +3 -1
- package/node_modules/pi-lens/docs/servercapabilities.md +9 -19
- package/node_modules/pi-lens/package.json +7 -5
- package/node_modules/pi-lens/scripts/download-grammars.js +40 -7
- package/node_modules/pi-lens/scripts/lib/latency-log-phases.mjs +95 -0
- package/node_modules/pi-lens/scripts/rpc-load-check.mjs +570 -81
- package/node_modules/pi-provider-qoder/dist/index.js +323 -154
- package/node_modules/pi-provider-qoder/package.json +1 -1
- package/node_modules/pi-web-access/CHANGELOG.md +39 -0
- package/node_modules/pi-web-access/README.md +83 -12
- package/node_modules/pi-web-access/anysearch.ts +4 -3
- package/node_modules/pi-web-access/bocha.ts +4 -3
- package/node_modules/pi-web-access/brightdata-unlocker.ts +3 -2
- package/node_modules/pi-web-access/brightdata.ts +4 -3
- package/node_modules/pi-web-access/ceramic.ts +3 -2
- package/node_modules/pi-web-access/curator-page.ts +3 -1
- package/node_modules/pi-web-access/curator-server.ts +1 -0
- package/node_modules/pi-web-access/deepseek.ts +179 -6
- package/node_modules/pi-web-access/dist/index.js +1118 -688
- package/node_modules/pi-web-access/dist/mcp-cli.js +1081 -667
- package/node_modules/pi-web-access/extract.ts +58 -6
- package/node_modules/pi-web-access/gemini-search.ts +29 -6
- package/node_modules/pi-web-access/index.ts +20 -3
- package/node_modules/pi-web-access/jina-search.ts +6 -4
- package/node_modules/pi-web-access/kagi.ts +5 -4
- package/node_modules/pi-web-access/keenable.ts +3 -2
- package/node_modules/pi-web-access/linkup.ts +170 -0
- package/node_modules/pi-web-access/mistral-search.ts +4 -3
- package/node_modules/pi-web-access/ollama.ts +5 -4
- package/node_modules/pi-web-access/package.json +1 -1
- package/node_modules/pi-web-access/parallel.ts +7 -7
- package/node_modules/pi-web-access/perplexity.ts +5 -3
- package/node_modules/pi-web-access/querit.ts +4 -3
- package/node_modules/pi-web-access/search1api.ts +4 -3
- package/node_modules/pi-web-access/searchinfinity.ts +4 -3
- package/node_modules/pi-web-access/serpapi.ts +7 -5
- package/node_modules/pi-web-access/serpbase.ts +5 -4
- package/node_modules/pi-web-access/serpdive.ts +4 -3
- package/node_modules/pi-web-access/serper.ts +6 -4
- package/node_modules/pi-web-access/serply.ts +3 -2
- package/node_modules/pi-web-access/utils.ts +24 -1
- package/node_modules/pi-web-access/valyu.ts +4 -3
- package/node_modules/pi-web-access/web-tool-core.ts +5 -0
- package/node_modules/pi-web-access/xai-search.ts +49 -7
- package/node_modules/pi-web-access/xcrawl.ts +4 -3
- package/node_modules/pi-web-access/you.ts +3 -2
- package/package.json +9 -9
- package/node_modules/pi-lens/dist/chunk-3YN6V5TV.js +0 -85
- package/node_modules/pi-lens/dist/chunk-466Z26MG.js +0 -30
- package/node_modules/pi-lens/dist/chunk-EC47DWFA.js +0 -56
- package/node_modules/pi-lens/dist/chunk-KDERNTCQ.js +0 -28
- package/node_modules/pi-lens/dist/chunk-KSX3TXSZ.js +0 -69
- package/node_modules/pi-lens/dist/chunk-LOP6GRPH.js +0 -31
- package/node_modules/pi-lens/dist/chunk-UOPVJQ4N.js +0 -103
- /package/node_modules/pi-lens/dist/{chunk-FC4RP4I2.js → chunk-6HWVI6MI.js} +0 -0
|
@@ -9830,6 +9830,93 @@ function transformMessagesForQoder(messages) {
|
|
|
9830
9830
|
}
|
|
9831
9831
|
|
|
9832
9832
|
// src/protocol/stream.ts
|
|
9833
|
+
function refreshToolIndexes(output, toolCalls) {
|
|
9834
|
+
const lastToolState = toolCalls.lastToolState;
|
|
9835
|
+
if (!lastToolState || output.content[lastToolState.contentIndex] === lastToolState.block) return;
|
|
9836
|
+
for (let index = 0; index < output.content.length; index++) {
|
|
9837
|
+
const block = output.content[index];
|
|
9838
|
+
if (block.type !== "toolCall") continue;
|
|
9839
|
+
const state = toolCalls.statesByBlock.get(block);
|
|
9840
|
+
if (state) state.contentIndex = index;
|
|
9841
|
+
}
|
|
9842
|
+
}
|
|
9843
|
+
function retireCompleteCandidates(toolCalls, candidates) {
|
|
9844
|
+
for (const state of candidates.complete) {
|
|
9845
|
+
parseToolArguments(state);
|
|
9846
|
+
candidates.states.delete(state);
|
|
9847
|
+
state.candidates.delete(candidates);
|
|
9848
|
+
if (state.candidates.size === 0 && !state.unindexed) toolCalls.unscopedCandidates.delete(state);
|
|
9849
|
+
}
|
|
9850
|
+
candidates.complete.clear();
|
|
9851
|
+
candidates.unique = candidates.states.size === 1 ? candidates.states.values().next().value : void 0;
|
|
9852
|
+
}
|
|
9853
|
+
var TOOL_ARGUMENT_STRUCTURE = /["\\{}[\]]/g;
|
|
9854
|
+
var NON_JSON_WHITESPACE = /[^ \t\r\n]/;
|
|
9855
|
+
function invalidToolArguments(state) {
|
|
9856
|
+
return new Error(`Invalid or incomplete tool-call JSON (characters=${state.argumentLength})`);
|
|
9857
|
+
}
|
|
9858
|
+
function appendToolArguments(state, fragment) {
|
|
9859
|
+
state.argumentChunks.push(fragment);
|
|
9860
|
+
state.argumentLength += fragment.length;
|
|
9861
|
+
if (state.complete) {
|
|
9862
|
+
if (NON_JSON_WHITESPACE.test(fragment)) throw invalidToolArguments(state);
|
|
9863
|
+
return;
|
|
9864
|
+
}
|
|
9865
|
+
let start = 0;
|
|
9866
|
+
if (state.objectRoot === void 0) {
|
|
9867
|
+
start = fragment.search(NON_JSON_WHITESPACE);
|
|
9868
|
+
if (start === -1) return;
|
|
9869
|
+
state.objectRoot = fragment[start] === "{";
|
|
9870
|
+
}
|
|
9871
|
+
if (!state.objectRoot) return;
|
|
9872
|
+
if (state.escaped) {
|
|
9873
|
+
start = 1;
|
|
9874
|
+
state.escaped = false;
|
|
9875
|
+
}
|
|
9876
|
+
TOOL_ARGUMENT_STRUCTURE.lastIndex = start;
|
|
9877
|
+
while (true) {
|
|
9878
|
+
const match = TOOL_ARGUMENT_STRUCTURE.exec(fragment);
|
|
9879
|
+
if (!match) break;
|
|
9880
|
+
const character = match[0];
|
|
9881
|
+
if (state.inString) {
|
|
9882
|
+
if (character === "\\") {
|
|
9883
|
+
if (TOOL_ARGUMENT_STRUCTURE.lastIndex === fragment.length) state.escaped = true;
|
|
9884
|
+
else TOOL_ARGUMENT_STRUCTURE.lastIndex++;
|
|
9885
|
+
} else if (character === '"') {
|
|
9886
|
+
state.inString = false;
|
|
9887
|
+
}
|
|
9888
|
+
} else if (character === '"') {
|
|
9889
|
+
state.inString = true;
|
|
9890
|
+
} else if (character === "{" || character === "[") {
|
|
9891
|
+
state.depth++;
|
|
9892
|
+
} else if (character === "}" || character === "]") {
|
|
9893
|
+
state.depth--;
|
|
9894
|
+
if (state.depth === 0) {
|
|
9895
|
+
state.complete = true;
|
|
9896
|
+
if (NON_JSON_WHITESPACE.test(fragment.slice(TOOL_ARGUMENT_STRUCTURE.lastIndex))) {
|
|
9897
|
+
throw invalidToolArguments(state);
|
|
9898
|
+
}
|
|
9899
|
+
return;
|
|
9900
|
+
}
|
|
9901
|
+
}
|
|
9902
|
+
}
|
|
9903
|
+
}
|
|
9904
|
+
function parseToolArguments(state) {
|
|
9905
|
+
if (state.parsedArguments) return state.parsedArguments;
|
|
9906
|
+
let args = {};
|
|
9907
|
+
if (state.argumentLength > 0) {
|
|
9908
|
+
try {
|
|
9909
|
+
args = JSON.parse(state.argumentChunks.join(""));
|
|
9910
|
+
} catch {
|
|
9911
|
+
throw invalidToolArguments(state);
|
|
9912
|
+
}
|
|
9913
|
+
}
|
|
9914
|
+
if (args === null || typeof args !== "object" || Array.isArray(args)) {
|
|
9915
|
+
throw new Error(`Non-object tool-call arguments (characters=${state.argumentLength})`);
|
|
9916
|
+
}
|
|
9917
|
+
state.parsedArguments = args;
|
|
9918
|
+
return state.parsedArguments;
|
|
9919
|
+
}
|
|
9833
9920
|
function stableHash(prefix, ...inputs) {
|
|
9834
9921
|
const hash = crypto3.createHash("sha256");
|
|
9835
9922
|
hash.update(prefix);
|
|
@@ -9892,10 +9979,15 @@ function resolveRequestContext(piAi, context) {
|
|
|
9892
9979
|
const collapsed = collapseSystemMessages(context);
|
|
9893
9980
|
const transcriptMessages = collapsed.messages;
|
|
9894
9981
|
const initialSystem = getInitialSystemMessage(transcriptMessages);
|
|
9982
|
+
if (!initialSystem) {
|
|
9983
|
+
return {
|
|
9984
|
+
messages: context.messages,
|
|
9985
|
+
systemText: contentToText(context.systemPrompt || ""),
|
|
9986
|
+
tools: context.tools ?? []
|
|
9987
|
+
};
|
|
9988
|
+
}
|
|
9895
9989
|
const tools = getCurrentTools(transcriptMessages);
|
|
9896
|
-
const systemText = contentToText(
|
|
9897
|
-
initialSystem && getSystemMessageText ? getSystemMessageText(initialSystem) : context.systemPrompt || ""
|
|
9898
|
-
);
|
|
9990
|
+
const systemText = contentToText(getSystemMessageText?.(initialSystem) ?? context.systemPrompt ?? "");
|
|
9899
9991
|
const messages = withoutInitialSystemMessage(transcriptMessages);
|
|
9900
9992
|
return { messages, systemText, tools };
|
|
9901
9993
|
}
|
|
@@ -10060,165 +10152,248 @@ function streamQoder(model, context, options) {
|
|
|
10060
10152
|
let contentBlockIndex = -1;
|
|
10061
10153
|
let thinkingBlockIndex = -1;
|
|
10062
10154
|
let rawReasoningTail = "";
|
|
10063
|
-
|
|
10155
|
+
let toolCalls;
|
|
10064
10156
|
const thinkingEnabled = options?.reasoning !== false && options?.reasoning !== "off";
|
|
10065
10157
|
const thinkingParser = thinkingEnabled ? new ThinkingTagParser(output, stream) : null;
|
|
10066
10158
|
stream.push({ type: "start", partial: output });
|
|
10067
10159
|
let sawDone = false;
|
|
10068
|
-
|
|
10069
|
-
|
|
10070
|
-
|
|
10071
|
-
|
|
10072
|
-
|
|
10073
|
-
|
|
10074
|
-
|
|
10075
|
-
buffer += decoder.decode(value, { stream: true });
|
|
10076
|
-
while (true) {
|
|
10077
|
-
const lineEnd = buffer.indexOf("\n", bufferStart);
|
|
10078
|
-
if (lineEnd === -1) break;
|
|
10079
|
-
const line = buffer.substring(bufferStart, lineEnd).trim();
|
|
10080
|
-
bufferStart = lineEnd + 1;
|
|
10081
|
-
if (!line.startsWith("data:")) continue;
|
|
10082
|
-
const dataStr = line.substring(5).trim();
|
|
10083
|
-
if (dataStr === "[DONE]") {
|
|
10084
|
-
sawDone = true;
|
|
10085
|
-
break;
|
|
10160
|
+
try {
|
|
10161
|
+
while (!sawDone) {
|
|
10162
|
+
const { done, value } = await reader.read();
|
|
10163
|
+
if (done) break;
|
|
10164
|
+
if (bufferStart > 0) {
|
|
10165
|
+
buffer = buffer.substring(bufferStart);
|
|
10166
|
+
bufferStart = 0;
|
|
10086
10167
|
}
|
|
10087
|
-
|
|
10088
|
-
|
|
10089
|
-
|
|
10090
|
-
|
|
10091
|
-
|
|
10092
|
-
|
|
10093
|
-
if (
|
|
10168
|
+
buffer += decoder.decode(value, { stream: true });
|
|
10169
|
+
while (true) {
|
|
10170
|
+
const lineEnd = buffer.indexOf("\n", bufferStart);
|
|
10171
|
+
if (lineEnd === -1) break;
|
|
10172
|
+
const line = buffer.substring(bufferStart, lineEnd).trim();
|
|
10173
|
+
bufferStart = lineEnd + 1;
|
|
10174
|
+
if (!line.startsWith("data:")) continue;
|
|
10175
|
+
const dataStr = line.substring(5).trim();
|
|
10176
|
+
if (dataStr === "[DONE]") {
|
|
10094
10177
|
sawDone = true;
|
|
10095
10178
|
break;
|
|
10096
10179
|
}
|
|
10097
|
-
|
|
10098
|
-
|
|
10099
|
-
|
|
10100
|
-
|
|
10101
|
-
|
|
10102
|
-
|
|
10103
|
-
|
|
10104
|
-
|
|
10105
|
-
|
|
10106
|
-
|
|
10107
|
-
|
|
10108
|
-
|
|
10109
|
-
output.
|
|
10110
|
-
output.
|
|
10111
|
-
|
|
10112
|
-
|
|
10113
|
-
|
|
10114
|
-
|
|
10115
|
-
|
|
10116
|
-
|
|
10117
|
-
|
|
10118
|
-
|
|
10119
|
-
|
|
10120
|
-
|
|
10121
|
-
|
|
10122
|
-
|
|
10123
|
-
|
|
10124
|
-
|
|
10125
|
-
|
|
10126
|
-
|
|
10127
|
-
|
|
10128
|
-
|
|
10129
|
-
|
|
10130
|
-
|
|
10131
|
-
|
|
10132
|
-
|
|
10133
|
-
|
|
10134
|
-
|
|
10135
|
-
|
|
10136
|
-
|
|
10137
|
-
|
|
10138
|
-
|
|
10139
|
-
|
|
10140
|
-
|
|
10141
|
-
|
|
10142
|
-
|
|
10143
|
-
|
|
10144
|
-
});
|
|
10145
|
-
thinkingBlockIndex = -1;
|
|
10146
|
-
}
|
|
10147
|
-
if (thinkingParser) {
|
|
10148
|
-
thinkingParser.processChunk(delta.content);
|
|
10149
|
-
} else {
|
|
10150
|
-
if (contentBlockIndex === -1) {
|
|
10151
|
-
contentBlockIndex = output.content.length;
|
|
10152
|
-
output.content.push({ type: "text", text: "" });
|
|
10153
|
-
stream.push({ type: "text_start", contentIndex: contentBlockIndex, partial: output });
|
|
10180
|
+
try {
|
|
10181
|
+
const envelope = JSON.parse(dataStr);
|
|
10182
|
+
if (envelope.statusCodeValue && envelope.statusCodeValue !== 200) {
|
|
10183
|
+
throw new Error(`Upstream status ${envelope.statusCodeValue}: ${envelope.body}`);
|
|
10184
|
+
}
|
|
10185
|
+
const innerStr = envelope.body;
|
|
10186
|
+
if (innerStr === "[DONE]") {
|
|
10187
|
+
sawDone = true;
|
|
10188
|
+
break;
|
|
10189
|
+
}
|
|
10190
|
+
if (!innerStr) continue;
|
|
10191
|
+
const inner = JSON.parse(innerStr);
|
|
10192
|
+
if (inner.id) output.responseId = inner.id;
|
|
10193
|
+
if (inner.model) output.responseModel = inner.model;
|
|
10194
|
+
if (inner.usage) {
|
|
10195
|
+
applyQoderCredits(output.usage, inner.usage, model.provider === "qoder-cn" ? "qoder-cn" : "qoder");
|
|
10196
|
+
const u = inner.usage;
|
|
10197
|
+
const promptTokens = u.prompt_tokens ?? 0;
|
|
10198
|
+
const cacheReadTokens = u.prompt_tokens_details?.cached_tokens ?? 0;
|
|
10199
|
+
const cacheWriteTokens = u.prompt_tokens_details?.cache_write_tokens ?? 0;
|
|
10200
|
+
output.usage.input = Math.max(0, promptTokens - cacheReadTokens - cacheWriteTokens);
|
|
10201
|
+
output.usage.output = u.completion_tokens ?? 0;
|
|
10202
|
+
output.usage.totalTokens = u.total_tokens ?? 0;
|
|
10203
|
+
output.usage.cacheRead = cacheReadTokens;
|
|
10204
|
+
output.usage.cacheWrite = cacheWriteTokens;
|
|
10205
|
+
}
|
|
10206
|
+
if (inner.choices && inner.choices.length > 0) {
|
|
10207
|
+
const choice = inner.choices[0];
|
|
10208
|
+
const delta = choice.delta;
|
|
10209
|
+
if (delta) {
|
|
10210
|
+
if (delta.reasoning_content) {
|
|
10211
|
+
rawReasoningTail = (rawReasoningTail + delta.reasoning_content).slice(-512);
|
|
10212
|
+
const reasoningChunk = stripDsmlResidue(stripThinkingTags(delta.reasoning_content));
|
|
10213
|
+
if (reasoningChunk) {
|
|
10214
|
+
if (thinkingBlockIndex === -1) {
|
|
10215
|
+
thinkingBlockIndex = output.content.length;
|
|
10216
|
+
output.content.push({ type: "thinking", thinking: "" });
|
|
10217
|
+
stream.push({ type: "thinking_start", contentIndex: thinkingBlockIndex, partial: output });
|
|
10218
|
+
}
|
|
10219
|
+
const block = output.content[thinkingBlockIndex];
|
|
10220
|
+
block.thinking += reasoningChunk;
|
|
10221
|
+
stream.push({
|
|
10222
|
+
type: "thinking_delta",
|
|
10223
|
+
contentIndex: thinkingBlockIndex,
|
|
10224
|
+
delta: reasoningChunk,
|
|
10225
|
+
partial: output
|
|
10226
|
+
});
|
|
10154
10227
|
}
|
|
10155
|
-
const block = output.content[contentBlockIndex];
|
|
10156
|
-
block.text += delta.content;
|
|
10157
|
-
stream.push({
|
|
10158
|
-
type: "text_delta",
|
|
10159
|
-
contentIndex: contentBlockIndex,
|
|
10160
|
-
delta: delta.content,
|
|
10161
|
-
partial: output
|
|
10162
|
-
});
|
|
10163
10228
|
}
|
|
10164
|
-
|
|
10165
|
-
|
|
10166
|
-
|
|
10167
|
-
|
|
10168
|
-
|
|
10169
|
-
|
|
10170
|
-
|
|
10171
|
-
|
|
10172
|
-
if (tc.id) state.id = tc.id;
|
|
10173
|
-
if (tc.function?.name) state.name = tc.function.name;
|
|
10174
|
-
if (state.emittedStart === void 0 && (state.id || state.name)) {
|
|
10175
|
-
state.emittedStart = true;
|
|
10176
|
-
state.contentIndex = output.content.length;
|
|
10177
|
-
output.content.push({
|
|
10178
|
-
type: "toolCall",
|
|
10179
|
-
id: state.id,
|
|
10180
|
-
name: state.name,
|
|
10181
|
-
arguments: {}
|
|
10229
|
+
if (delta.content) {
|
|
10230
|
+
if (thinkingBlockIndex !== -1) {
|
|
10231
|
+
const block = output.content[thinkingBlockIndex];
|
|
10232
|
+
stream.push({
|
|
10233
|
+
type: "thinking_end",
|
|
10234
|
+
contentIndex: thinkingBlockIndex,
|
|
10235
|
+
content: block.thinking,
|
|
10236
|
+
partial: output
|
|
10182
10237
|
});
|
|
10183
|
-
|
|
10184
|
-
}
|
|
10185
|
-
if (state.emittedStart) {
|
|
10186
|
-
const block = output.content[state.contentIndex];
|
|
10187
|
-
block.id = state.id;
|
|
10188
|
-
block.name = state.name;
|
|
10238
|
+
thinkingBlockIndex = -1;
|
|
10189
10239
|
}
|
|
10190
|
-
if (
|
|
10191
|
-
|
|
10192
|
-
|
|
10240
|
+
if (thinkingParser) {
|
|
10241
|
+
thinkingParser.processChunk(delta.content);
|
|
10242
|
+
if (toolCalls?.lastToolState) refreshToolIndexes(output, toolCalls);
|
|
10243
|
+
} else {
|
|
10244
|
+
if (contentBlockIndex === -1) {
|
|
10245
|
+
contentBlockIndex = output.content.length;
|
|
10246
|
+
output.content.push({ type: "text", text: "" });
|
|
10247
|
+
stream.push({ type: "text_start", contentIndex: contentBlockIndex, partial: output });
|
|
10248
|
+
}
|
|
10249
|
+
const block = output.content[contentBlockIndex];
|
|
10250
|
+
block.text += delta.content;
|
|
10193
10251
|
stream.push({
|
|
10194
|
-
type: "
|
|
10195
|
-
contentIndex:
|
|
10196
|
-
delta:
|
|
10252
|
+
type: "text_delta",
|
|
10253
|
+
contentIndex: contentBlockIndex,
|
|
10254
|
+
delta: delta.content,
|
|
10197
10255
|
partial: output
|
|
10198
10256
|
});
|
|
10199
10257
|
}
|
|
10200
10258
|
}
|
|
10259
|
+
if (delta.tool_calls && Array.isArray(delta.tool_calls)) {
|
|
10260
|
+
for (const tc of delta.tool_calls) {
|
|
10261
|
+
const id = tc.id || "";
|
|
10262
|
+
const name2 = tc.function?.name || "";
|
|
10263
|
+
const argDelta = tc.function?.arguments ?? "";
|
|
10264
|
+
if (typeof id !== "string" || typeof name2 !== "string") {
|
|
10265
|
+
throw new Error("Tool-call identity conflict: invalid metadata");
|
|
10266
|
+
}
|
|
10267
|
+
if (typeof argDelta !== "string") throw new Error("Invalid tool-call argument fragment");
|
|
10268
|
+
if (!id && !name2 && !argDelta) continue;
|
|
10269
|
+
toolCalls ??= {
|
|
10270
|
+
states: [],
|
|
10271
|
+
byId: /* @__PURE__ */ new Map(),
|
|
10272
|
+
byIndex: /* @__PURE__ */ new Map(),
|
|
10273
|
+
unscopedCandidates: /* @__PURE__ */ new Set(),
|
|
10274
|
+
statesByBlock: /* @__PURE__ */ new Map()
|
|
10275
|
+
};
|
|
10276
|
+
const index = typeof tc.index === "number" ? tc.index : void 0;
|
|
10277
|
+
let candidates;
|
|
10278
|
+
if (index !== void 0) {
|
|
10279
|
+
candidates = toolCalls.byIndex.get(index);
|
|
10280
|
+
if (!candidates) {
|
|
10281
|
+
candidates = { states: /* @__PURE__ */ new Set(), complete: /* @__PURE__ */ new Set(), unique: void 0 };
|
|
10282
|
+
toolCalls.byIndex.set(index, candidates);
|
|
10283
|
+
}
|
|
10284
|
+
}
|
|
10285
|
+
let state = id ? toolCalls.byId.get(id) : void 0;
|
|
10286
|
+
let associated = !!state && !!candidates && candidates.states.has(state);
|
|
10287
|
+
if (id && candidates && !associated && candidates.complete.size > 0) {
|
|
10288
|
+
retireCompleteCandidates(toolCalls, candidates);
|
|
10289
|
+
}
|
|
10290
|
+
const available = candidates?.states ?? toolCalls.unscopedCandidates;
|
|
10291
|
+
if (!state) {
|
|
10292
|
+
const only = available.size === 1 ? candidates ? candidates.unique : available.values().next().value : void 0;
|
|
10293
|
+
if (!id && available.size > 1) {
|
|
10294
|
+
throw new Error(`Ambiguous tool-call continuation (candidates=${available.size})`);
|
|
10295
|
+
}
|
|
10296
|
+
if (only && (!id || !only.id)) {
|
|
10297
|
+
state = only;
|
|
10298
|
+
associated = candidates !== void 0;
|
|
10299
|
+
} else {
|
|
10300
|
+
state = {
|
|
10301
|
+
argumentChunks: [],
|
|
10302
|
+
argumentLength: 0,
|
|
10303
|
+
depth: 0,
|
|
10304
|
+
inString: false,
|
|
10305
|
+
escaped: false,
|
|
10306
|
+
complete: false,
|
|
10307
|
+
id: "",
|
|
10308
|
+
name: "",
|
|
10309
|
+
contentIndex: -1,
|
|
10310
|
+
candidates: /* @__PURE__ */ new Set(),
|
|
10311
|
+
unindexed: index === void 0
|
|
10312
|
+
};
|
|
10313
|
+
toolCalls.states.push(state);
|
|
10314
|
+
}
|
|
10315
|
+
}
|
|
10316
|
+
if (name2 && state.name && name2 !== state.name) {
|
|
10317
|
+
throw new Error("Tool-call identity conflict: inconsistent name");
|
|
10318
|
+
}
|
|
10319
|
+
const newlyIdentified = !!id && !state.id;
|
|
10320
|
+
const newlyNamed = !!name2 && !state.name;
|
|
10321
|
+
if (newlyIdentified) {
|
|
10322
|
+
state.id = id;
|
|
10323
|
+
toolCalls.byId.set(id, state);
|
|
10324
|
+
}
|
|
10325
|
+
if (newlyNamed) state.name = name2;
|
|
10326
|
+
if (!associated) {
|
|
10327
|
+
toolCalls.unscopedCandidates.add(state);
|
|
10328
|
+
if (candidates) {
|
|
10329
|
+
state.unindexed = false;
|
|
10330
|
+
state.candidates.add(candidates);
|
|
10331
|
+
candidates.states.add(state);
|
|
10332
|
+
candidates.unique = candidates.states.size === 1 ? state : void 0;
|
|
10333
|
+
if (state.complete && state.id) candidates.complete.add(state);
|
|
10334
|
+
}
|
|
10335
|
+
}
|
|
10336
|
+
const wasComplete = state.complete;
|
|
10337
|
+
if (argDelta) appendToolArguments(state, argDelta);
|
|
10338
|
+
if (state.complete && state.id && (!wasComplete || newlyIdentified)) {
|
|
10339
|
+
for (const scope of state.candidates) scope.complete.add(state);
|
|
10340
|
+
}
|
|
10341
|
+
if (!state.block && (state.id || state.name)) {
|
|
10342
|
+
state.block = { type: "toolCall", id: state.id, name: state.name, arguments: {} };
|
|
10343
|
+
state.contentIndex = output.content.length;
|
|
10344
|
+
output.content.push(state.block);
|
|
10345
|
+
toolCalls.statesByBlock.set(state.block, state);
|
|
10346
|
+
toolCalls.lastToolState = state;
|
|
10347
|
+
stream.push({ type: "toolcall_start", contentIndex: state.contentIndex, partial: output });
|
|
10348
|
+
for (const fragment of state.argumentChunks) {
|
|
10349
|
+
stream.push({
|
|
10350
|
+
type: "toolcall_delta",
|
|
10351
|
+
contentIndex: state.contentIndex,
|
|
10352
|
+
delta: fragment,
|
|
10353
|
+
partial: output
|
|
10354
|
+
});
|
|
10355
|
+
}
|
|
10356
|
+
} else if (state.block) {
|
|
10357
|
+
if (newlyIdentified) state.block.id = state.id;
|
|
10358
|
+
if (newlyNamed) state.block.name = state.name;
|
|
10359
|
+
if (argDelta) {
|
|
10360
|
+
stream.push({
|
|
10361
|
+
type: "toolcall_delta",
|
|
10362
|
+
contentIndex: state.contentIndex,
|
|
10363
|
+
delta: argDelta,
|
|
10364
|
+
partial: output
|
|
10365
|
+
});
|
|
10366
|
+
}
|
|
10367
|
+
}
|
|
10368
|
+
}
|
|
10369
|
+
}
|
|
10370
|
+
}
|
|
10371
|
+
if (choice.finish_reason) {
|
|
10372
|
+
output.stopReason = choice.finish_reason;
|
|
10201
10373
|
}
|
|
10202
10374
|
}
|
|
10203
|
-
|
|
10204
|
-
|
|
10205
|
-
|
|
10206
|
-
|
|
10207
|
-
|
|
10208
|
-
|
|
10209
|
-
if (process.env.QODER_DEBUG) {
|
|
10210
|
-
console.error("[pi-provider-qoder] skipping malformed SSE line:", dataStr.slice(0, 200));
|
|
10375
|
+
} catch (e) {
|
|
10376
|
+
if (e instanceof SyntaxError) {
|
|
10377
|
+
if (process.env.QODER_DEBUG) {
|
|
10378
|
+
console.error("[pi-provider-qoder] skipping malformed SSE line:", dataStr.slice(0, 200));
|
|
10379
|
+
}
|
|
10380
|
+
continue;
|
|
10211
10381
|
}
|
|
10212
|
-
|
|
10382
|
+
throw e;
|
|
10213
10383
|
}
|
|
10214
|
-
throw e;
|
|
10215
10384
|
}
|
|
10216
10385
|
}
|
|
10386
|
+
} finally {
|
|
10387
|
+
try {
|
|
10388
|
+
await reader.cancel().catch(() => {
|
|
10389
|
+
});
|
|
10390
|
+
} finally {
|
|
10391
|
+
reader.releaseLock();
|
|
10392
|
+
}
|
|
10217
10393
|
}
|
|
10218
|
-
await reader.cancel().catch(() => {
|
|
10219
|
-
});
|
|
10220
10394
|
if (thinkingParser) {
|
|
10221
10395
|
thinkingParser.finalize();
|
|
10396
|
+
if (toolCalls?.lastToolState) refreshToolIndexes(output, toolCalls);
|
|
10222
10397
|
}
|
|
10223
10398
|
if (thinkingBlockIndex !== -1) {
|
|
10224
10399
|
const block = output.content[thinkingBlockIndex];
|
|
@@ -10229,31 +10404,25 @@ function streamQoder(model, context, options) {
|
|
|
10229
10404
|
partial: output
|
|
10230
10405
|
});
|
|
10231
10406
|
}
|
|
10232
|
-
|
|
10233
|
-
|
|
10234
|
-
state.
|
|
10235
|
-
|
|
10236
|
-
try {
|
|
10237
|
-
args = JSON.parse(state.arguments || "{}");
|
|
10238
|
-
} catch {
|
|
10407
|
+
if (toolCalls) {
|
|
10408
|
+
for (const state of toolCalls.states) {
|
|
10409
|
+
if (!state.id || !state.name) {
|
|
10410
|
+
throw new Error(`Unresolved tool-call identity (characters=${state.argumentLength})`);
|
|
10239
10411
|
}
|
|
10240
|
-
|
|
10241
|
-
|
|
10412
|
+
parseToolArguments(state);
|
|
10413
|
+
}
|
|
10414
|
+
for (const [block, state] of toolCalls.statesByBlock) {
|
|
10415
|
+
block.arguments = parseToolArguments(state);
|
|
10242
10416
|
stream.push({
|
|
10243
10417
|
type: "toolcall_end",
|
|
10244
10418
|
contentIndex: state.contentIndex,
|
|
10245
|
-
toolCall:
|
|
10246
|
-
type: "toolCall",
|
|
10247
|
-
id: state.id,
|
|
10248
|
-
name: state.name,
|
|
10249
|
-
arguments: args
|
|
10250
|
-
},
|
|
10419
|
+
toolCall: block,
|
|
10251
10420
|
partial: output
|
|
10252
10421
|
});
|
|
10253
10422
|
}
|
|
10254
|
-
|
|
10255
|
-
|
|
10256
|
-
|
|
10423
|
+
if (toolCalls.statesByBlock.size > 0 && output.stopReason !== "length") {
|
|
10424
|
+
output.stopReason = "toolUse";
|
|
10425
|
+
}
|
|
10257
10426
|
}
|
|
10258
10427
|
if (isDegenerateDsmlTurn(output, rawReasoningTail)) {
|
|
10259
10428
|
output.stopReason = "error";
|
|
@@ -4,6 +4,44 @@ All notable changes to this project will be documented in this file.
|
|
|
4
4
|
|
|
5
5
|
## [Unreleased]
|
|
6
6
|
|
|
7
|
+
## [0.44.0] - 2026-10-20
|
|
8
|
+
|
|
9
|
+
### Highlights
|
|
10
|
+
|
|
11
|
+
- Send most search providers through your own API gateway or proxy, using a config key or an environment variable per provider.
|
|
12
|
+
- API keys are removed when a provider redirects a request to a different site.
|
|
13
|
+
- If you use Pi's `codemode` or `tool_search`, the web tools can now add nothing to your context until a script actually calls one.
|
|
14
|
+
|
|
15
|
+
### Added
|
|
16
|
+
|
|
17
|
+
- Gateway support for Parallel, Serper, SerpApi, Perplexity, DeepSeek, Ollama, Jina search, Mistral, and the other providers listed in the README's gateway table. Set `<provider>BaseUrl` in config, or the matching environment variable, which wins over config. Ollama and DeepSeek read `PI_OLLAMA_BASE_URL` and `PI_DEEPSEEK_BASE_URL`, because the plain names are often already set for a local Ollama server or other DeepSeek clients. Any path prefix on your gateway URL is kept, and the official endpoints stay the default. When a provider redirects to a different site, API key headers and the `api_key` query parameter are dropped. Thanks to [@XWIlluDelu](https://github.com/XWIlluDelu) for [PR #590](https://github.com/nicobailon/pi-web-access/pull/590).
|
|
18
|
+
- `"toolActivation": "none"` removes the `web_enable` loader, so the web tools are reached only from Pi `codemode` scripts or `tool_search` and add no tool definitions until a script calls one. It only works with `"toolExposure": "deferred"`, and it needs `codemode` or `tool_search` turned on in Pi. The other `toolActivation` values work as before. Thanks to [@johnhenaot](https://github.com/johnhenaot) for [PR #591](https://github.com/nicobailon/pi-web-access/pull/591).
|
|
19
|
+
|
|
20
|
+
### Changed
|
|
21
|
+
|
|
22
|
+
- Jina search rejects the queries `.` and `..`, which would otherwise escape a gateway's path. Provider API calls follow at most 5 redirects.
|
|
23
|
+
|
|
24
|
+
## [0.43.0] - 2026-10-20
|
|
25
|
+
|
|
26
|
+
### Highlights
|
|
27
|
+
|
|
28
|
+
- Search with Linkup: a new provider that runs only when you pick it, since each search uses account credits.
|
|
29
|
+
- DeepSeek search can return the full text of the pages it found, and DeepSeek Fetch can read pages for `fetch_content` when you opt in.
|
|
30
|
+
- xAI search can go through your own Responses gateway, with a longer timeout for slow X searches.
|
|
31
|
+
- A default provider list now falls back to your `searchRouting` providers when every provider in it fails.
|
|
32
|
+
- Short, complete pages no longer come back from `fetch_content` marked "incomplete".
|
|
33
|
+
|
|
34
|
+
### Added
|
|
35
|
+
|
|
36
|
+
- Linkup search provider. Set `linkupApiKey` or `LINKUP_API_KEY` and select `provider: "linkup"`. `linkupDepth` picks `flash`, `fast` (default), `standard`, or `deep`. Result limits, domain and recency filters, and inline page text all work. Linkup is never chosen by `auto` or `all`, because searches use account credits. Thanks to [@kestermcullough](https://github.com/kestermcullough) for [PR #584](https://github.com/nicobailon/pi-web-access/pull/584).
|
|
37
|
+
- DeepSeek search with `includeContent` now returns the page text DeepSeek already fetched, so those pages aren't fetched a second time. DeepSeek Fetch is a new opt-in `fetch_content` provider that returns pages as Markdown: add `deepseek` to `fetchRouting.providers` and set `fetchRouting.allowRemoteHostedProviders` to `true`. It uses the same `deepseekApiKey` / `DEEPSEEK_API_KEY` as search. Thanks to [@Jerry2003sky](https://github.com/Jerry2003sky) for [issue #582](https://github.com/nicobailon/pi-web-access/issues/582) and [@Ebotian](https://github.com/Ebotian) for [PR #585](https://github.com/nicobailon/pi-web-access/pull/585).
|
|
38
|
+
- `xaiResponsesUrl` sends xAI search to another Responses endpoint, such as a gateway that relays `x_search` to a Grok subscription. Only `xaiApiKey` or `XAI_API_KEY` is sent there, never Pi's xAI sign-in. `xaiSearchTimeoutMs` raises the 60-second xAI timeout, up to 10 minutes, for `x_search` questions that take longer. Thanks to [@zane668](https://github.com/zane668) for [issue #583](https://github.com/nicobailon/pi-web-access/issues/583).
|
|
39
|
+
|
|
40
|
+
### Fixed
|
|
41
|
+
|
|
42
|
+
- A default `provider` list such as `["exa", "brave"]` now falls back to `searchRouting` when every provider in it fails. Before, setting `provider` switched routing off, so the search just errored. Fallback happens only when each failure is one of your `fallbackOn` types, and it skips providers the list already tried. This covers tool calls, the curator, and `/websearch`; a list passed in a single tool call still doesn't fall back. Thanks to [@isjiajia01](https://github.com/isjiajia01) for [issue #580](https://github.com/nicobailon/pi-web-access/issues/580).
|
|
43
|
+
- `fetch_content` in readable mode returns a complete short page instead of calling it incomplete. A static page with under 500 characters of visible text is accepted once something is extracted from it. Pages that run scripts still try other providers, because their short text may be a loading placeholder. When a page still looks incomplete, the error says how much text was extracted and how much the page shows. Thanks to [@donnielrt](https://github.com/donnielrt) for [issue #581](https://github.com/nicobailon/pi-web-access/issues/581).
|
|
44
|
+
|
|
7
45
|
## [0.42.0] - 2026-10-17
|
|
8
46
|
|
|
9
47
|
### Highlights
|
|
@@ -60,6 +98,7 @@ All notable changes to this project will be documented in this file.
|
|
|
60
98
|
- `fetch_content` answer mode now answers from a YouTube or local-video transcript that comes with a thumbnail, instead of failing with "Page answer requires textual fetched content". Requests for several video frames are refused in answer mode instead of being answered from a placeholder line. Thanks to [@goodman-b](https://github.com/goodman-b) for [PR #562](https://github.com/nicobailon/pi-web-access/pull/562).
|
|
61
99
|
- `get_search_content` `findText` excerpts no longer end in half an emoji. A character split at the excerpt edge shows as `�`, so the text stays valid. Thanks to [@yazanabuashour](https://github.com/yazanabuashour) for [PR #563](https://github.com/nicobailon/pi-web-access/pull/563).
|
|
62
100
|
- Reading stored content page by page with `fetch_content` and `get_search_content` no longer splits an emoji across two pages. The whole character starts the next page, and the next-page offset points to it ([#564](https://github.com/nicobailon/pi-web-access/issues/564)).
|
|
101
|
+
|
|
63
102
|
## [0.39.0] - 2026-10-11
|
|
64
103
|
|
|
65
104
|
### Highlights
|