@code-yeongyu/senpi-ai 2026.8.29 → 2026.8.30-3
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 +67 -38
- 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,aAA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,GAAG,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;AAo4BD,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"}
|
|
@@ -237,12 +237,13 @@ const REPLAYABLE_ANTHROPIC_PROVIDER_NATIVE_TYPES = new Set([
|
|
|
237
237
|
"text_editor_code_execution_tool_result",
|
|
238
238
|
"tool_search_tool_result",
|
|
239
239
|
"container_upload",
|
|
240
|
-
//
|
|
241
|
-
//
|
|
242
|
-
//
|
|
243
|
-
//
|
|
244
|
-
// and
|
|
245
|
-
|
|
240
|
+
// The server-side fallback marker (`fallback`, server-side-fallback-2026-06-01
|
|
241
|
+
// beta) is deliberately absent: the Messages API rejects it as an *input* tag
|
|
242
|
+
// ("Input tag 'fallback' found using 'type' does not match any of the expected
|
|
243
|
+
// tags"), so replaying it 400s every subsequent same-model request. The stored
|
|
244
|
+
// marker is audit metadata and still drives declined-attempt pruning in
|
|
245
|
+
// convertMessages (see lastAnthropicFallbackBoundary and
|
|
246
|
+
// collectDiscardedFallbackToolCallIds); blocks after it replay verbatim.
|
|
246
247
|
]);
|
|
247
248
|
function isReplayableAnthropicProviderNativeBlock(raw) {
|
|
248
249
|
return isRecord(raw) && typeof raw.type === "string" && REPLAYABLE_ANTHROPIC_PROVIDER_NATIVE_TYPES.has(raw.type);
|
|
@@ -736,6 +737,48 @@ function sanitizeAdaptiveThinkingPayload(model, params, options) {
|
|
|
736
737
|
function isCacheableUserContentBlock(block) {
|
|
737
738
|
return block?.type === "text" || block?.type === "image" || block?.type === "tool_result";
|
|
738
739
|
}
|
|
740
|
+
function appendUserBlocks(params, newBlocks) {
|
|
741
|
+
if (newBlocks.length === 0)
|
|
742
|
+
return;
|
|
743
|
+
const lastParam = params[params.length - 1];
|
|
744
|
+
if (lastParam?.role === "user") {
|
|
745
|
+
if (typeof lastParam.content === "string") {
|
|
746
|
+
lastParam.content = [{ type: "text", text: lastParam.content }, ...newBlocks];
|
|
747
|
+
}
|
|
748
|
+
else if (Array.isArray(lastParam.content)) {
|
|
749
|
+
lastParam.content.push(...newBlocks);
|
|
750
|
+
}
|
|
751
|
+
}
|
|
752
|
+
else {
|
|
753
|
+
params.push({ role: "user", content: newBlocks });
|
|
754
|
+
}
|
|
755
|
+
}
|
|
756
|
+
function isToolLoopContinuation(messages) {
|
|
757
|
+
const tail = messages[messages.length - 1];
|
|
758
|
+
const preceding = messages[messages.length - 2];
|
|
759
|
+
return (tail?.role === "user" &&
|
|
760
|
+
Array.isArray(tail.content) &&
|
|
761
|
+
tail.content.some((block) => block.type === "tool_result") &&
|
|
762
|
+
preceding?.role === "assistant" &&
|
|
763
|
+
Array.isArray(preceding.content) &&
|
|
764
|
+
preceding.content.some((block) => block.type === "tool_use"));
|
|
765
|
+
}
|
|
766
|
+
function markUserMessageCacheCheckpoint(message, cacheControl) {
|
|
767
|
+
if (message.role !== "user")
|
|
768
|
+
return false;
|
|
769
|
+
if (Array.isArray(message.content)) {
|
|
770
|
+
const lastBlock = message.content[message.content.length - 1];
|
|
771
|
+
if (!isCacheableUserContentBlock(lastBlock))
|
|
772
|
+
return false;
|
|
773
|
+
lastBlock.cache_control = cacheControl;
|
|
774
|
+
return true;
|
|
775
|
+
}
|
|
776
|
+
if (typeof message.content === "string") {
|
|
777
|
+
message.content = [{ type: "text", text: message.content, cache_control: cacheControl }];
|
|
778
|
+
return true;
|
|
779
|
+
}
|
|
780
|
+
return false;
|
|
781
|
+
}
|
|
739
782
|
const ANTHROPIC_MESSAGE_EVENTS = new Set([
|
|
740
783
|
"message_start",
|
|
741
784
|
"message_delta",
|
|
@@ -1535,7 +1578,7 @@ function buildParams(model, context, isOAuthToken, options, unsignedThinkingRepl
|
|
|
1535
1578
|
{
|
|
1536
1579
|
type: "text",
|
|
1537
1580
|
text: "You are Claude Code, Anthropic's official CLI for Claude.",
|
|
1538
|
-
...(cacheControl ? { cache_control: cacheControl } : {}),
|
|
1581
|
+
...(!context.systemPrompt && cacheControl ? { cache_control: cacheControl } : {}),
|
|
1539
1582
|
},
|
|
1540
1583
|
];
|
|
1541
1584
|
if (context.systemPrompt) {
|
|
@@ -1701,10 +1744,13 @@ function convertMessages(transformedMessages, model, isOAuthToken, cacheControl,
|
|
|
1701
1744
|
if (msg.role === "user") {
|
|
1702
1745
|
if (typeof msg.content === "string") {
|
|
1703
1746
|
if (msg.content.trim().length > 0) {
|
|
1704
|
-
|
|
1705
|
-
|
|
1706
|
-
|
|
1707
|
-
}
|
|
1747
|
+
const content = sanitizeSurrogates(msg.content);
|
|
1748
|
+
if (params[params.length - 1]?.role === "user") {
|
|
1749
|
+
appendUserBlocks(params, [{ type: "text", text: content }]);
|
|
1750
|
+
}
|
|
1751
|
+
else {
|
|
1752
|
+
params.push({ role: "user", content });
|
|
1753
|
+
}
|
|
1708
1754
|
}
|
|
1709
1755
|
}
|
|
1710
1756
|
else {
|
|
@@ -1744,17 +1790,15 @@ function convertMessages(transformedMessages, model, isOAuthToken, cacheControl,
|
|
|
1744
1790
|
});
|
|
1745
1791
|
if (filteredBlocks.length === 0)
|
|
1746
1792
|
continue;
|
|
1747
|
-
params
|
|
1748
|
-
role: "user",
|
|
1749
|
-
content: filteredBlocks,
|
|
1750
|
-
});
|
|
1793
|
+
appendUserBlocks(params, filteredBlocks);
|
|
1751
1794
|
}
|
|
1752
1795
|
}
|
|
1753
1796
|
else if (msg.role === "assistant") {
|
|
1754
1797
|
const blocks = [];
|
|
1755
1798
|
const isSameModel = isSameAnthropicModel(msg, model);
|
|
1756
1799
|
// Blocks before the final fallback marker are the declined attempt; the
|
|
1757
|
-
//
|
|
1800
|
+
// blocks after it are the serving model's output and replay verbatim. The
|
|
1801
|
+
// marker itself never replays: the API rejects `fallback` as an input tag.
|
|
1758
1802
|
const fallbackBoundary = isSameModel ? lastAnthropicFallbackBoundary(msg.content) : -1;
|
|
1759
1803
|
const preBoundaryPairedServerToolUseIds = fallbackBoundary >= 0
|
|
1760
1804
|
? pairedServerToolUseIdsBeforeBoundary(msg.content, fallbackBoundary)
|
|
@@ -1862,30 +1906,15 @@ function convertMessages(transformedMessages, model, isOAuthToken, cacheControl,
|
|
|
1862
1906
|
if (toolResults.length === 0)
|
|
1863
1907
|
continue;
|
|
1864
1908
|
// Displaced reference-bearing results must follow every tool_result block.
|
|
1865
|
-
params
|
|
1866
|
-
role: "user",
|
|
1867
|
-
content: [...toolResults, ...siblingContent],
|
|
1868
|
-
});
|
|
1909
|
+
appendUserBlocks(params, [...toolResults, ...siblingContent]);
|
|
1869
1910
|
}
|
|
1870
1911
|
}
|
|
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
|
-
];
|
|
1912
|
+
const retainPrecedingCheckpoint = isToolLoopContinuation(params);
|
|
1913
|
+
if (cacheControl && params.length > 0 && markUserMessageCacheCheckpoint(params[params.length - 1], cacheControl)) {
|
|
1914
|
+
if (retainPrecedingCheckpoint) {
|
|
1915
|
+
for (let index = params.length - 2; index >= 0; index--) {
|
|
1916
|
+
if (markUserMessageCacheCheckpoint(params[index], cacheControl))
|
|
1917
|
+
break;
|
|
1889
1918
|
}
|
|
1890
1919
|
}
|
|
1891
1920
|
}
|