@core-ai/core-ai 0.19.0 → 0.21.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 CHANGED
@@ -4,6 +4,11 @@ type Message = SystemMessage | UserMessage | AssistantMessage | ToolResultMessag
4
4
  type SystemMessage = {
5
5
  role: 'system';
6
6
  content: string;
7
+ /**
8
+ * Application-owned metadata for this message. Provider adapters ignore
9
+ * this field and never serialize it to provider APIs.
10
+ */
11
+ metadata?: Record<string, unknown>;
7
12
  };
8
13
  type UserMessage = {
9
14
  role: 'user';
@@ -67,20 +72,35 @@ type ReasoningPart = {
67
72
  metadata?: Record<string, unknown>;
68
73
  /**
69
74
  * Provider-namespaced metadata for this reasoning block. The top-level key is
70
- * the provider identifier (e.g. `'anthropic'`, `'openai'`), which also serves as
71
- * the ownership discriminator: an adapter checks for the presence of its own key
72
- * to detect cross-provider blocks. Cross-provider blocks are downgraded to plain
73
- * text (preserving context) rather than forwarding opaque metadata that would
74
- * cause an API error on the receiving provider.
75
+ * the provider identifier (e.g. `'anthropic'`, `'openai'`, `'azure-openai'`),
76
+ * which also serves as the ownership discriminator: an adapter checks for the
77
+ * presence of its own key to detect cross-provider blocks. Cross-provider
78
+ * blocks are downgraded to plain text (preserving context) rather than
79
+ * forwarding opaque metadata that would cause an API error on the receiving
80
+ * provider.
75
81
  *
76
- * @example Anthropic: `{ anthropic: { signature: '...' } }`
77
- * @example OpenAI: `{ openai: { encryptedContent: '...' } }`
82
+ * @example Anthropic: `{ anthropic: { signature: '...' } }`
83
+ * @example OpenAI: `{ openai: { encryptedContent: '...' } }`
84
+ * @example Azure OpenAI: `{ 'azure-openai': { encryptedContent: '...' } }`
78
85
  */
79
86
  providerMetadata?: Record<string, Record<string, unknown>>;
80
87
  };
81
88
  type ToolCallPart = {
82
89
  type: 'tool-call';
83
90
  toolCall: ToolCall;
91
+ /**
92
+ * Provider-namespaced metadata for this tool call. The top-level key is the
93
+ * provider identifier and serves as the ownership discriminator, exactly as
94
+ * for `ReasoningPart`: an adapter only forwards metadata stored under its
95
+ * own key and ignores blocks produced by another provider.
96
+ *
97
+ * Some providers require this data to be replayed verbatim. Gemini 3 rejects
98
+ * a request when a function call from the current turn is sent back without
99
+ * the thought signature it was issued with.
100
+ *
101
+ * @example Google: `{ google: { thoughtSignature: '...' } }`
102
+ */
103
+ providerMetadata?: Record<string, Record<string, unknown>>;
84
104
  };
85
105
  type AssistantContentPart = AssistantTextPart | ReasoningPart | ToolCallPart;
86
106
  type AssistantMessage = {
@@ -310,6 +330,7 @@ type StreamEvent = {
310
330
  } | {
311
331
  type: 'tool-call-end';
312
332
  toolCall: ToolCall;
333
+ providerMetadata?: Record<string, Record<string, unknown>>;
313
334
  } | {
314
335
  type: 'finish';
315
336
  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);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@core-ai/core-ai",
3
- "version": "0.19.0",
3
+ "version": "0.21.0",
4
4
  "description": "Type-safe LLM abstraction layer over native provider SDKs",
5
5
  "license": "MIT",
6
6
  "author": "Omnifact (https://omnifact.ai)",