@agentproto/adapter-pi 0.3.10 → 0.3.11
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/dist/index.mjs +2 -178
- package/dist/index.mjs.map +1 -1
- package/dist/mcp-bridge-extension.mjs +2 -178
- package/dist/mcp-bridge-extension.mjs.map +1 -1
- package/package.json +4 -4
package/dist/index.mjs
CHANGED
|
@@ -18850,189 +18850,13 @@ function mediaTypeEssence(header) {
|
|
|
18850
18850
|
}
|
|
18851
18851
|
}
|
|
18852
18852
|
|
|
18853
|
-
// ../../node_modules/.pnpm/eventsource-parser@3.1.
|
|
18854
|
-
var ParseError2 = class extends Error {
|
|
18855
|
-
constructor(message, options) {
|
|
18856
|
-
super(message), this.name = "ParseError", this.type = options.type, this.field = options.field, this.value = options.value, this.line = options.line;
|
|
18857
|
-
}
|
|
18858
|
-
};
|
|
18859
|
-
var LF2 = 10;
|
|
18860
|
-
var CR2 = 13;
|
|
18861
|
-
var SPACE2 = 32;
|
|
18862
|
-
function noop2(_arg) {
|
|
18863
|
-
}
|
|
18864
|
-
function createParser2(config2) {
|
|
18865
|
-
if (typeof config2 == "function")
|
|
18866
|
-
throw new TypeError(
|
|
18867
|
-
"`config` must be an object, got a function instead. Did you mean `createParser({onEvent: fn})`?"
|
|
18868
|
-
);
|
|
18869
|
-
const { onEvent = noop2, onError = noop2, onRetry = noop2, onComment, maxBufferSize } = config2, pendingFragments = [];
|
|
18870
|
-
let pendingFragmentsLength = 0, isFirstChunk = true, id, data = "", dataLines = 0, eventType, terminated = false;
|
|
18871
|
-
function feed(chunk) {
|
|
18872
|
-
if (terminated)
|
|
18873
|
-
throw new Error(
|
|
18874
|
-
"Cannot feed parser: it was terminated after exceeding the configured max buffer size. Call `reset()` to resume parsing."
|
|
18875
|
-
);
|
|
18876
|
-
if (isFirstChunk && (isFirstChunk = false, chunk.charCodeAt(0) === 239 && chunk.charCodeAt(1) === 187 && chunk.charCodeAt(2) === 191 && (chunk = chunk.slice(3))), pendingFragments.length === 0) {
|
|
18877
|
-
const trailing2 = processLines(chunk);
|
|
18878
|
-
trailing2 !== "" && (pendingFragments.push(trailing2), pendingFragmentsLength = trailing2.length), checkBufferSize();
|
|
18879
|
-
return;
|
|
18880
|
-
}
|
|
18881
|
-
if (chunk.indexOf(`
|
|
18882
|
-
`) === -1 && chunk.indexOf("\r") === -1) {
|
|
18883
|
-
pendingFragments.push(chunk), pendingFragmentsLength += chunk.length, checkBufferSize();
|
|
18884
|
-
return;
|
|
18885
|
-
}
|
|
18886
|
-
pendingFragments.push(chunk);
|
|
18887
|
-
const input = pendingFragments.join("");
|
|
18888
|
-
pendingFragments.length = 0, pendingFragmentsLength = 0;
|
|
18889
|
-
const trailing = processLines(input);
|
|
18890
|
-
trailing !== "" && (pendingFragments.push(trailing), pendingFragmentsLength = trailing.length), checkBufferSize();
|
|
18891
|
-
}
|
|
18892
|
-
function checkBufferSize() {
|
|
18893
|
-
maxBufferSize !== void 0 && (pendingFragmentsLength + data.length <= maxBufferSize || (terminated = true, pendingFragments.length = 0, pendingFragmentsLength = 0, id = void 0, data = "", dataLines = 0, eventType = void 0, onError(
|
|
18894
|
-
new ParseError2(`Buffered data exceeded max buffer size of ${maxBufferSize} characters`, {
|
|
18895
|
-
type: "max-buffer-size-exceeded"
|
|
18896
|
-
})
|
|
18897
|
-
)));
|
|
18898
|
-
}
|
|
18899
|
-
function processLines(chunk) {
|
|
18900
|
-
let searchIndex = 0;
|
|
18901
|
-
if (chunk.indexOf("\r") === -1) {
|
|
18902
|
-
let lfIndex = chunk.indexOf(`
|
|
18903
|
-
`, searchIndex);
|
|
18904
|
-
for (; lfIndex !== -1; ) {
|
|
18905
|
-
if (searchIndex === lfIndex) {
|
|
18906
|
-
dataLines > 0 && onEvent({ id, event: eventType, data }), id = void 0, data = "", dataLines = 0, eventType = void 0, searchIndex = lfIndex + 1, lfIndex = chunk.indexOf(`
|
|
18907
|
-
`, searchIndex);
|
|
18908
|
-
continue;
|
|
18909
|
-
}
|
|
18910
|
-
const firstCharCode = chunk.charCodeAt(searchIndex);
|
|
18911
|
-
if (isDataPrefix2(chunk, searchIndex, firstCharCode)) {
|
|
18912
|
-
const valueStart = chunk.charCodeAt(searchIndex + 5) === SPACE2 ? searchIndex + 6 : searchIndex + 5, value = chunk.slice(valueStart, lfIndex);
|
|
18913
|
-
if (dataLines === 0 && chunk.charCodeAt(lfIndex + 1) === LF2) {
|
|
18914
|
-
onEvent({ id, event: eventType, data: value }), id = void 0, data = "", eventType = void 0, searchIndex = lfIndex + 2, lfIndex = chunk.indexOf(`
|
|
18915
|
-
`, searchIndex);
|
|
18916
|
-
continue;
|
|
18917
|
-
}
|
|
18918
|
-
data = dataLines === 0 ? value : `${data}
|
|
18919
|
-
${value}`, dataLines++;
|
|
18920
|
-
} else isEventPrefix2(chunk, searchIndex, firstCharCode) ? eventType = chunk.slice(
|
|
18921
|
-
chunk.charCodeAt(searchIndex + 6) === SPACE2 ? searchIndex + 7 : searchIndex + 6,
|
|
18922
|
-
lfIndex
|
|
18923
|
-
) || void 0 : parseLine(chunk, searchIndex, lfIndex);
|
|
18924
|
-
searchIndex = lfIndex + 1, lfIndex = chunk.indexOf(`
|
|
18925
|
-
`, searchIndex);
|
|
18926
|
-
}
|
|
18927
|
-
return chunk.slice(searchIndex);
|
|
18928
|
-
}
|
|
18929
|
-
for (; searchIndex < chunk.length; ) {
|
|
18930
|
-
const crIndex = chunk.indexOf("\r", searchIndex), lfIndex = chunk.indexOf(`
|
|
18931
|
-
`, searchIndex);
|
|
18932
|
-
let lineEnd = -1;
|
|
18933
|
-
if (crIndex !== -1 && lfIndex !== -1 ? lineEnd = crIndex < lfIndex ? crIndex : lfIndex : crIndex !== -1 ? crIndex === chunk.length - 1 ? lineEnd = -1 : lineEnd = crIndex : lfIndex !== -1 && (lineEnd = lfIndex), lineEnd === -1)
|
|
18934
|
-
break;
|
|
18935
|
-
parseLine(chunk, searchIndex, lineEnd), searchIndex = lineEnd + 1, chunk.charCodeAt(searchIndex - 1) === CR2 && chunk.charCodeAt(searchIndex) === LF2 && searchIndex++;
|
|
18936
|
-
}
|
|
18937
|
-
return chunk.slice(searchIndex);
|
|
18938
|
-
}
|
|
18939
|
-
function parseLine(chunk, start, end) {
|
|
18940
|
-
if (start === end) {
|
|
18941
|
-
dispatchEvent();
|
|
18942
|
-
return;
|
|
18943
|
-
}
|
|
18944
|
-
const firstCharCode = chunk.charCodeAt(start);
|
|
18945
|
-
if (isDataPrefix2(chunk, start, firstCharCode)) {
|
|
18946
|
-
const valueStart = chunk.charCodeAt(start + 5) === SPACE2 ? start + 6 : start + 5, value2 = chunk.slice(valueStart, end);
|
|
18947
|
-
data = dataLines === 0 ? value2 : `${data}
|
|
18948
|
-
${value2}`, dataLines++;
|
|
18949
|
-
return;
|
|
18950
|
-
}
|
|
18951
|
-
if (isEventPrefix2(chunk, start, firstCharCode)) {
|
|
18952
|
-
eventType = chunk.slice(chunk.charCodeAt(start + 6) === SPACE2 ? start + 7 : start + 6, end) || void 0;
|
|
18953
|
-
return;
|
|
18954
|
-
}
|
|
18955
|
-
if (firstCharCode === 105 && chunk.charCodeAt(start + 1) === 100 && chunk.charCodeAt(start + 2) === 58) {
|
|
18956
|
-
const value2 = chunk.slice(chunk.charCodeAt(start + 3) === SPACE2 ? start + 4 : start + 3, end);
|
|
18957
|
-
id = value2.includes("\0") ? void 0 : value2;
|
|
18958
|
-
return;
|
|
18959
|
-
}
|
|
18960
|
-
if (firstCharCode === 58) {
|
|
18961
|
-
if (onComment) {
|
|
18962
|
-
const line2 = chunk.slice(start, end);
|
|
18963
|
-
onComment(line2.slice(chunk.charCodeAt(start + 1) === SPACE2 ? 2 : 1));
|
|
18964
|
-
}
|
|
18965
|
-
return;
|
|
18966
|
-
}
|
|
18967
|
-
const line = chunk.slice(start, end), fieldSeparatorIndex = line.indexOf(":");
|
|
18968
|
-
if (fieldSeparatorIndex === -1) {
|
|
18969
|
-
processField(line, "", line);
|
|
18970
|
-
return;
|
|
18971
|
-
}
|
|
18972
|
-
const field = line.slice(0, fieldSeparatorIndex), offset = line.charCodeAt(fieldSeparatorIndex + 1) === SPACE2 ? 2 : 1, value = line.slice(fieldSeparatorIndex + offset);
|
|
18973
|
-
processField(field, value, line);
|
|
18974
|
-
}
|
|
18975
|
-
function processField(field, value, line) {
|
|
18976
|
-
switch (field) {
|
|
18977
|
-
case "event":
|
|
18978
|
-
eventType = value || void 0;
|
|
18979
|
-
break;
|
|
18980
|
-
case "data":
|
|
18981
|
-
data = dataLines === 0 ? value : `${data}
|
|
18982
|
-
${value}`, dataLines++;
|
|
18983
|
-
break;
|
|
18984
|
-
case "id":
|
|
18985
|
-
id = value.includes("\0") ? void 0 : value;
|
|
18986
|
-
break;
|
|
18987
|
-
case "retry":
|
|
18988
|
-
/^\d+$/.test(value) ? onRetry(parseInt(value, 10)) : onError(
|
|
18989
|
-
new ParseError2(`Invalid \`retry\` value: "${value}"`, {
|
|
18990
|
-
type: "invalid-retry",
|
|
18991
|
-
value,
|
|
18992
|
-
line
|
|
18993
|
-
})
|
|
18994
|
-
);
|
|
18995
|
-
break;
|
|
18996
|
-
default:
|
|
18997
|
-
onError(
|
|
18998
|
-
new ParseError2(
|
|
18999
|
-
`Unknown field "${field.length > 20 ? `${field.slice(0, 20)}\u2026` : field}"`,
|
|
19000
|
-
{ type: "unknown-field", field, value, line }
|
|
19001
|
-
)
|
|
19002
|
-
);
|
|
19003
|
-
break;
|
|
19004
|
-
}
|
|
19005
|
-
}
|
|
19006
|
-
function dispatchEvent() {
|
|
19007
|
-
dataLines > 0 && onEvent({
|
|
19008
|
-
id,
|
|
19009
|
-
event: eventType,
|
|
19010
|
-
data
|
|
19011
|
-
}), id = void 0, data = "", dataLines = 0, eventType = void 0;
|
|
19012
|
-
}
|
|
19013
|
-
function reset(options = {}) {
|
|
19014
|
-
if (options.consume && pendingFragments.length > 0) {
|
|
19015
|
-
const incompleteLine = pendingFragments.join("");
|
|
19016
|
-
parseLine(incompleteLine, 0, incompleteLine.length);
|
|
19017
|
-
}
|
|
19018
|
-
isFirstChunk = true, id = void 0, data = "", dataLines = 0, eventType = void 0, pendingFragments.length = 0, pendingFragmentsLength = 0, terminated = false;
|
|
19019
|
-
}
|
|
19020
|
-
return { feed, reset };
|
|
19021
|
-
}
|
|
19022
|
-
function isDataPrefix2(chunk, i, firstCharCode) {
|
|
19023
|
-
return firstCharCode === 100 && chunk.charCodeAt(i + 1) === 97 && chunk.charCodeAt(i + 2) === 116 && chunk.charCodeAt(i + 3) === 97 && chunk.charCodeAt(i + 4) === 58;
|
|
19024
|
-
}
|
|
19025
|
-
function isEventPrefix2(chunk, i, firstCharCode) {
|
|
19026
|
-
return firstCharCode === 101 && chunk.charCodeAt(i + 1) === 118 && chunk.charCodeAt(i + 2) === 101 && chunk.charCodeAt(i + 3) === 110 && chunk.charCodeAt(i + 4) === 116 && chunk.charCodeAt(i + 5) === 58;
|
|
19027
|
-
}
|
|
19028
|
-
|
|
19029
|
-
// ../../node_modules/.pnpm/eventsource-parser@3.1.0/node_modules/eventsource-parser/dist/stream.js
|
|
18853
|
+
// ../../node_modules/.pnpm/eventsource-parser@3.1.1/node_modules/eventsource-parser/dist/stream.js
|
|
19030
18854
|
var EventSourceParserStream = class extends TransformStream {
|
|
19031
18855
|
constructor({ onError, onRetry, onComment, maxBufferSize } = {}) {
|
|
19032
18856
|
let parser;
|
|
19033
18857
|
super({
|
|
19034
18858
|
start(controller) {
|
|
19035
|
-
parser =
|
|
18859
|
+
parser = createParser({
|
|
19036
18860
|
onEvent: (event) => {
|
|
19037
18861
|
controller.enqueue(event);
|
|
19038
18862
|
},
|