@core-ai/core-ai 0.19.0 → 0.20.0
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.d.ts +23 -7
- package/dist/index.js +4 -3
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -67,20 +67,35 @@ type ReasoningPart = {
|
|
|
67
67
|
metadata?: Record<string, unknown>;
|
|
68
68
|
/**
|
|
69
69
|
* Provider-namespaced metadata for this reasoning block. The top-level key is
|
|
70
|
-
* the provider identifier (e.g. `'anthropic'`, `'openai'`),
|
|
71
|
-
* the ownership discriminator: an adapter checks for the
|
|
72
|
-
* to detect cross-provider blocks. Cross-provider
|
|
73
|
-
* text (preserving context) rather than
|
|
74
|
-
* cause an API error on the receiving
|
|
70
|
+
* the provider identifier (e.g. `'anthropic'`, `'openai'`, `'azure-openai'`),
|
|
71
|
+
* which also serves as the ownership discriminator: an adapter checks for the
|
|
72
|
+
* presence of its own key to detect cross-provider blocks. Cross-provider
|
|
73
|
+
* blocks are downgraded to plain text (preserving context) rather than
|
|
74
|
+
* forwarding opaque metadata that would cause an API error on the receiving
|
|
75
|
+
* provider.
|
|
75
76
|
*
|
|
76
|
-
* @example Anthropic:
|
|
77
|
-
* @example OpenAI:
|
|
77
|
+
* @example Anthropic: `{ anthropic: { signature: '...' } }`
|
|
78
|
+
* @example OpenAI: `{ openai: { encryptedContent: '...' } }`
|
|
79
|
+
* @example Azure OpenAI: `{ 'azure-openai': { encryptedContent: '...' } }`
|
|
78
80
|
*/
|
|
79
81
|
providerMetadata?: Record<string, Record<string, unknown>>;
|
|
80
82
|
};
|
|
81
83
|
type ToolCallPart = {
|
|
82
84
|
type: 'tool-call';
|
|
83
85
|
toolCall: ToolCall;
|
|
86
|
+
/**
|
|
87
|
+
* Provider-namespaced metadata for this tool call. The top-level key is the
|
|
88
|
+
* provider identifier and serves as the ownership discriminator, exactly as
|
|
89
|
+
* for `ReasoningPart`: an adapter only forwards metadata stored under its
|
|
90
|
+
* own key and ignores blocks produced by another provider.
|
|
91
|
+
*
|
|
92
|
+
* Some providers require this data to be replayed verbatim. Gemini 3 rejects
|
|
93
|
+
* a request when a function call from the current turn is sent back without
|
|
94
|
+
* the thought signature it was issued with.
|
|
95
|
+
*
|
|
96
|
+
* @example Google: `{ google: { thoughtSignature: '...' } }`
|
|
97
|
+
*/
|
|
98
|
+
providerMetadata?: Record<string, Record<string, unknown>>;
|
|
84
99
|
};
|
|
85
100
|
type AssistantContentPart = AssistantTextPart | ReasoningPart | ToolCallPart;
|
|
86
101
|
type AssistantMessage = {
|
|
@@ -310,6 +325,7 @@ type StreamEvent = {
|
|
|
310
325
|
} | {
|
|
311
326
|
type: 'tool-call-end';
|
|
312
327
|
toolCall: ToolCall;
|
|
328
|
+
providerMetadata?: Record<string, Record<string, unknown>>;
|
|
313
329
|
} | {
|
|
314
330
|
type: 'finish';
|
|
315
331
|
finishReason: FinishReason;
|
package/dist/index.js
CHANGED
|
@@ -743,14 +743,15 @@ function createChatStream(source, options = {}) {
|
|
|
743
743
|
}
|
|
744
744
|
textBuffer += text;
|
|
745
745
|
};
|
|
746
|
-
const appendToolCall = (toolCall) => {
|
|
746
|
+
const appendToolCall = (toolCall, providerMetadata) => {
|
|
747
747
|
flushText();
|
|
748
748
|
insideText = false;
|
|
749
749
|
flushReasoning();
|
|
750
750
|
insideReasoning = false;
|
|
751
751
|
parts.push({
|
|
752
752
|
type: "tool-call",
|
|
753
|
-
toolCall
|
|
753
|
+
toolCall,
|
|
754
|
+
...providerMetadata ? { providerMetadata } : {}
|
|
754
755
|
});
|
|
755
756
|
};
|
|
756
757
|
const setFinish = (event) => {
|
|
@@ -806,7 +807,7 @@ function createChatStream(source, options = {}) {
|
|
|
806
807
|
endText(event.metadata);
|
|
807
808
|
break;
|
|
808
809
|
case "tool-call-end":
|
|
809
|
-
appendToolCall(event.toolCall);
|
|
810
|
+
appendToolCall(event.toolCall, event.providerMetadata);
|
|
810
811
|
break;
|
|
811
812
|
case "finish":
|
|
812
813
|
setFinish(event);
|