@code-yeongyu/senpi-ai 2026.8.29 → 2026.8.30
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/api/anthropic-messages.d.ts.map +1 -1
- package/dist/api/anthropic-messages.js +58 -31
- package/dist/api/anthropic-messages.js.map +1 -1
- package/dist/api/cursor-agent/measure.d.ts +20 -0
- package/dist/api/cursor-agent/measure.d.ts.map +1 -0
- package/dist/api/cursor-agent/measure.js +443 -0
- package/dist/api/cursor-agent/measure.js.map +1 -0
- package/dist/api/cursor-agent.d.ts +2 -0
- package/dist/api/cursor-agent.d.ts.map +1 -1
- package/dist/api/cursor-agent.js +2 -0
- package/dist/api/cursor-agent.js.map +1 -1
- package/dist/api/openai-completions.js +1 -1
- package/dist/api/openai-completions.js.map +1 -1
- package/dist/index.d.ts +1 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -0
- package/dist/index.js.map +1 -1
- package/dist/providers/data/.manifest.json +1 -1
- package/dist/providers/data/cloudflare-ai-gateway.json +1 -1
- package/dist/providers/data/cloudflare-workers-ai.json +1 -1
- package/dist/providers/data/fireworks.json +1 -1
- package/dist/providers/data/opencode-go.json +1 -1
- package/dist/providers/data/opencode.json +1 -1
- package/dist/providers/data/openrouter.json +1 -1
- package/dist/providers/data/together.json +1 -1
- package/dist/providers/data/zai-coding-cn.json +1 -1
- package/dist/providers/data/zai.json +1 -1
- package/package.json +2 -2
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"anthropic-messages.d.ts","sourceRoot":"","sources":["../../src/api/anthropic-messages.ts"],"names":[],"mappings":"AAAA,OAAO,SAAS,MAAM,mBAAmB,CAAC;AAC1C,OAAO,KAAK,EAGX,+BAA+B,EAK/B,MAAM,yCAAyC,CAAC;AAEjD,OAAO,KAAK,EACX,wBAAwB,EAKxB,OAAO,EAGP,KAAK,EAGL,mBAAmB,EAEnB,cAAc,EACd,aAAa,EAOb,MAAM,aAAa,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AAG,OAAO,GAAG,KAAK,CAAC;AAE1E,MAAM,MAAM,wBAAwB,GAAG,YAAY,GAAG,SAAS,CAAC;AAyEhE,MAAM,WAAW,gBAAiB,SAAQ,aAAa;IACtD;;;;;;OAMG;IACH,eAAe,CAAC,EAAE,OAAO,CAAC;IAC1B;;;;OAIG;IACH,oBAAoB,CAAC,EAAE,MAAM,CAAC;IAC9B;;;;;;;;;;;OAWG;IACH,MAAM,CAAC,EAAE,eAAe,CAAC;IACzB;;;;;;;;;;;OAWG;IACH,eAAe,CAAC,EAAE,wBAAwB,CAAC;IAC3C;;;;;OAKG;IACH,mBAAmB,CAAC,EAAE,OAAO,CAAC;IAC9B,wEAAwE;IACxE,gBAAgB,CAAC,EAAE,wBAAwB,CAAC;IAC5C;;;;OAIG;IACH,UAAU,CAAC,EAAE,MAAM,GAAG,KAAK,GAAG,MAAM,GAAG;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,IAAI,EAAE,MAAM,CAAA;KAAE,CAAC;IACtE;;;;OAIG;IACH,MAAM,CAAC,EAAE,SAAS,CAAC;CACnB;AAm4BD,eAAO,MAAM,MAAM,EAAE,cAAc,CAAC,oBAAoB,EAAE,gBAAgB,CAqbzE,CAAC;AA0FF,eAAO,MAAM,YAAY,EAAE,cAAc,CAAC,oBAAoB,EAAE,mBAAmB,CA+ClF,CAAC;AA6IF,wBAAgB,mCAAmC,CAClD,KAAK,EAAE,KAAK,CAAC,oBAAoB,CAAC,EAClC,OAAO,EAAE,OAAO,EAChB,OAAO,CAAC,EAAE,gBAAgB,GACxB,+BAA+B,CAkBjC"}
|
|
@@ -736,6 +736,48 @@ function sanitizeAdaptiveThinkingPayload(model, params, options) {
|
|
|
736
736
|
function isCacheableUserContentBlock(block) {
|
|
737
737
|
return block?.type === "text" || block?.type === "image" || block?.type === "tool_result";
|
|
738
738
|
}
|
|
739
|
+
function appendUserBlocks(params, newBlocks) {
|
|
740
|
+
if (newBlocks.length === 0)
|
|
741
|
+
return;
|
|
742
|
+
const lastParam = params[params.length - 1];
|
|
743
|
+
if (lastParam?.role === "user") {
|
|
744
|
+
if (typeof lastParam.content === "string") {
|
|
745
|
+
lastParam.content = [{ type: "text", text: lastParam.content }, ...newBlocks];
|
|
746
|
+
}
|
|
747
|
+
else if (Array.isArray(lastParam.content)) {
|
|
748
|
+
lastParam.content.push(...newBlocks);
|
|
749
|
+
}
|
|
750
|
+
}
|
|
751
|
+
else {
|
|
752
|
+
params.push({ role: "user", content: newBlocks });
|
|
753
|
+
}
|
|
754
|
+
}
|
|
755
|
+
function isToolLoopContinuation(messages) {
|
|
756
|
+
const tail = messages[messages.length - 1];
|
|
757
|
+
const preceding = messages[messages.length - 2];
|
|
758
|
+
return (tail?.role === "user" &&
|
|
759
|
+
Array.isArray(tail.content) &&
|
|
760
|
+
tail.content.some((block) => block.type === "tool_result") &&
|
|
761
|
+
preceding?.role === "assistant" &&
|
|
762
|
+
Array.isArray(preceding.content) &&
|
|
763
|
+
preceding.content.some((block) => block.type === "tool_use"));
|
|
764
|
+
}
|
|
765
|
+
function markUserMessageCacheCheckpoint(message, cacheControl) {
|
|
766
|
+
if (message.role !== "user")
|
|
767
|
+
return false;
|
|
768
|
+
if (Array.isArray(message.content)) {
|
|
769
|
+
const lastBlock = message.content[message.content.length - 1];
|
|
770
|
+
if (!isCacheableUserContentBlock(lastBlock))
|
|
771
|
+
return false;
|
|
772
|
+
lastBlock.cache_control = cacheControl;
|
|
773
|
+
return true;
|
|
774
|
+
}
|
|
775
|
+
if (typeof message.content === "string") {
|
|
776
|
+
message.content = [{ type: "text", text: message.content, cache_control: cacheControl }];
|
|
777
|
+
return true;
|
|
778
|
+
}
|
|
779
|
+
return false;
|
|
780
|
+
}
|
|
739
781
|
const ANTHROPIC_MESSAGE_EVENTS = new Set([
|
|
740
782
|
"message_start",
|
|
741
783
|
"message_delta",
|
|
@@ -1535,7 +1577,7 @@ function buildParams(model, context, isOAuthToken, options, unsignedThinkingRepl
|
|
|
1535
1577
|
{
|
|
1536
1578
|
type: "text",
|
|
1537
1579
|
text: "You are Claude Code, Anthropic's official CLI for Claude.",
|
|
1538
|
-
...(cacheControl ? { cache_control: cacheControl } : {}),
|
|
1580
|
+
...(!context.systemPrompt && cacheControl ? { cache_control: cacheControl } : {}),
|
|
1539
1581
|
},
|
|
1540
1582
|
];
|
|
1541
1583
|
if (context.systemPrompt) {
|
|
@@ -1701,10 +1743,13 @@ function convertMessages(transformedMessages, model, isOAuthToken, cacheControl,
|
|
|
1701
1743
|
if (msg.role === "user") {
|
|
1702
1744
|
if (typeof msg.content === "string") {
|
|
1703
1745
|
if (msg.content.trim().length > 0) {
|
|
1704
|
-
|
|
1705
|
-
|
|
1706
|
-
|
|
1707
|
-
}
|
|
1746
|
+
const content = sanitizeSurrogates(msg.content);
|
|
1747
|
+
if (params[params.length - 1]?.role === "user") {
|
|
1748
|
+
appendUserBlocks(params, [{ type: "text", text: content }]);
|
|
1749
|
+
}
|
|
1750
|
+
else {
|
|
1751
|
+
params.push({ role: "user", content });
|
|
1752
|
+
}
|
|
1708
1753
|
}
|
|
1709
1754
|
}
|
|
1710
1755
|
else {
|
|
@@ -1744,10 +1789,7 @@ function convertMessages(transformedMessages, model, isOAuthToken, cacheControl,
|
|
|
1744
1789
|
});
|
|
1745
1790
|
if (filteredBlocks.length === 0)
|
|
1746
1791
|
continue;
|
|
1747
|
-
params
|
|
1748
|
-
role: "user",
|
|
1749
|
-
content: filteredBlocks,
|
|
1750
|
-
});
|
|
1792
|
+
appendUserBlocks(params, filteredBlocks);
|
|
1751
1793
|
}
|
|
1752
1794
|
}
|
|
1753
1795
|
else if (msg.role === "assistant") {
|
|
@@ -1862,30 +1904,15 @@ function convertMessages(transformedMessages, model, isOAuthToken, cacheControl,
|
|
|
1862
1904
|
if (toolResults.length === 0)
|
|
1863
1905
|
continue;
|
|
1864
1906
|
// Displaced reference-bearing results must follow every tool_result block.
|
|
1865
|
-
params
|
|
1866
|
-
role: "user",
|
|
1867
|
-
content: [...toolResults, ...siblingContent],
|
|
1868
|
-
});
|
|
1907
|
+
appendUserBlocks(params, [...toolResults, ...siblingContent]);
|
|
1869
1908
|
}
|
|
1870
1909
|
}
|
|
1871
|
-
|
|
1872
|
-
if (cacheControl && params.length > 0) {
|
|
1873
|
-
|
|
1874
|
-
|
|
1875
|
-
|
|
1876
|
-
|
|
1877
|
-
if (isCacheableUserContentBlock(lastBlock)) {
|
|
1878
|
-
lastBlock.cache_control = cacheControl;
|
|
1879
|
-
}
|
|
1880
|
-
}
|
|
1881
|
-
else if (typeof lastMessage.content === "string") {
|
|
1882
|
-
lastMessage.content = [
|
|
1883
|
-
{
|
|
1884
|
-
type: "text",
|
|
1885
|
-
text: lastMessage.content,
|
|
1886
|
-
cache_control: cacheControl,
|
|
1887
|
-
},
|
|
1888
|
-
];
|
|
1910
|
+
const retainPrecedingCheckpoint = isToolLoopContinuation(params);
|
|
1911
|
+
if (cacheControl && params.length > 0 && markUserMessageCacheCheckpoint(params[params.length - 1], cacheControl)) {
|
|
1912
|
+
if (retainPrecedingCheckpoint) {
|
|
1913
|
+
for (let index = params.length - 2; index >= 0; index--) {
|
|
1914
|
+
if (markUserMessageCacheCheckpoint(params[index], cacheControl))
|
|
1915
|
+
break;
|
|
1889
1916
|
}
|
|
1890
1917
|
}
|
|
1891
1918
|
}
|