@mast-ai/core 0.4.0 → 0.6.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.
@@ -13,6 +13,12 @@ export interface UrpToolCall {
13
13
  id: string;
14
14
  name: string;
15
15
  arguments: unknown;
16
+ /**
17
+ * Opaque per-call metadata controlled by the server (e.g. Gemini
18
+ * `thoughtSignature`). Round-tripped unchanged on the matching
19
+ * `tool_result` message in the next turn.
20
+ */
21
+ provider_metadata?: unknown;
16
22
  }
17
23
  /** Wire format for a non-streaming URP response. */
18
24
  export interface UrpResponse {
@@ -40,6 +40,7 @@ export class UrpAdapter {
40
40
  id: tc.id,
41
41
  name: tc.name,
42
42
  args: tc.arguments,
43
+ provider_metadata: tc.provider_metadata,
43
44
  }))
44
45
  : [],
45
46
  };
@@ -72,6 +73,7 @@ export class UrpAdapter {
72
73
  id: chunk.tool_call.id,
73
74
  name: chunk.tool_call.name,
74
75
  args: chunk.tool_call.arguments,
76
+ provider_metadata: chunk.tool_call.provider_metadata,
75
77
  },
76
78
  };
77
79
  }
package/dist/runner.js CHANGED
@@ -194,16 +194,21 @@ export class AgentRunner {
194
194
  }
195
195
  }
196
196
  if (toolCalls.length > 0) {
197
+ // Emit tool_call_started only for registered tools so hallucinated
198
+ // calls never appear in the UI.
197
199
  for (const call of toolCalls) {
198
- yield { type: 'tool_call_started', name: call.name, args: call.args };
200
+ if (this.registry.getTool(call.name)) {
201
+ yield { type: 'tool_call_started', name: call.name, args: call.args };
202
+ }
199
203
  }
200
204
  const toolResults = await Promise.all(toolCalls.map(async (call) => {
201
205
  const tool = this.registry.getTool(call.name);
202
206
  if (!tool) {
203
207
  return {
204
208
  call,
205
- result: `Error: Tool '${call.name}' not found.`,
209
+ result: `Tool '${call.name}' does not exist and was not called.`,
206
210
  error: true,
211
+ hallucinated: true,
207
212
  };
208
213
  }
209
214
  try {
@@ -211,19 +216,33 @@ export class AgentRunner {
211
216
  signal,
212
217
  onEvent: onToolEvent ? (event) => onToolEvent(call.name, event) : undefined,
213
218
  });
214
- return { call, result, error: false };
219
+ return { call, result, error: false, hallucinated: false };
215
220
  }
216
221
  catch (err) {
217
222
  const message = err instanceof Error ? err.message : String(err);
218
- return { call, result: `Error executing tool: ${message}`, error: true };
223
+ return {
224
+ call,
225
+ result: `Error executing tool: ${message}`,
226
+ error: true,
227
+ hallucinated: false,
228
+ };
219
229
  }
220
230
  }));
221
231
  const resultMessages = [];
222
- for (const { call, result, error } of toolResults) {
223
- yield { type: 'tool_call_completed', name: call.name, result, error };
232
+ for (const { call, result, error, hallucinated } of toolResults) {
233
+ // Suppress completed events for hallucinated calls they had no started event.
234
+ if (!hallucinated) {
235
+ yield { type: 'tool_call_completed', name: call.name, result, error };
236
+ }
224
237
  resultMessages.push({
225
238
  role: 'user',
226
- content: { type: 'tool_result', id: call.id, name: call.name, result },
239
+ content: {
240
+ type: 'tool_result',
241
+ id: call.id,
242
+ name: call.name,
243
+ result,
244
+ provider_metadata: call.provider_metadata,
245
+ },
227
246
  });
228
247
  }
229
248
  // Assistant tool_calls message must precede tool result messages in history.
package/dist/types.d.ts CHANGED
@@ -9,6 +9,13 @@ export interface ToolCall {
9
9
  id: string;
10
10
  name: string;
11
11
  args: unknown;
12
+ /**
13
+ * Opaque per-call metadata controlled by the adapter / backend
14
+ * (e.g. Gemini `thoughtSignature`). MAST round-trips this value
15
+ * unchanged on the matching `tool_result`; it has no schema and
16
+ * is never inspected by the runner.
17
+ */
18
+ provider_metadata?: unknown;
12
19
  }
13
20
  /**
14
21
  * Discriminated union of possible message content types.
@@ -24,6 +31,8 @@ export type MessageContent = {
24
31
  id: string;
25
32
  name: string;
26
33
  result: unknown;
34
+ /** Copied verbatim from the originating tool call. */
35
+ provider_metadata?: unknown;
27
36
  };
28
37
  /**
29
38
  * A single message in a conversation history.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mast-ai/core",
3
- "version": "0.4.0",
3
+ "version": "0.6.0",
4
4
  "license": "Apache-2.0",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",