@iqai/adk 0.3.0 → 0.3.2

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.mjs CHANGED
@@ -1520,7 +1520,11 @@ var AiSdkLlm = class extends BaseLlm {
1520
1520
  * @param model - Pre-configured LanguageModel from provider(modelName)
1521
1521
  */
1522
1522
  constructor(modelInstance) {
1523
- super(modelInstance.modelId || "ai-sdk-model");
1523
+ let modelId = "ai-sdk-model";
1524
+ if (typeof modelInstance !== "string") {
1525
+ modelId = modelInstance.modelId;
1526
+ }
1527
+ super(modelId);
1524
1528
  this.modelInstance = modelInstance;
1525
1529
  }
1526
1530
  /**
@@ -1567,7 +1571,7 @@ var AiSdkLlm = class extends BaseLlm {
1567
1571
  functionCall: {
1568
1572
  id: toolCall.toolCallId,
1569
1573
  name: toolCall.toolName,
1570
- args: toolCall.args
1574
+ args: toolCall.input
1571
1575
  }
1572
1576
  });
1573
1577
  }
@@ -1580,8 +1584,8 @@ var AiSdkLlm = class extends BaseLlm {
1580
1584
  parts: parts.length > 0 ? parts : [{ text: "" }]
1581
1585
  },
1582
1586
  usageMetadata: finalUsage ? {
1583
- promptTokenCount: finalUsage.promptTokens,
1584
- candidatesTokenCount: finalUsage.completionTokens,
1587
+ promptTokenCount: finalUsage.inputTokens,
1588
+ candidatesTokenCount: finalUsage.outputTokens,
1585
1589
  totalTokenCount: finalUsage.totalTokens
1586
1590
  } : void 0,
1587
1591
  finishReason: this.mapFinishReason(finishReason),
@@ -1599,7 +1603,7 @@ var AiSdkLlm = class extends BaseLlm {
1599
1603
  functionCall: {
1600
1604
  id: toolCall.toolCallId,
1601
1605
  name: toolCall.toolName,
1602
- args: toolCall.args
1606
+ args: toolCall.input
1603
1607
  }
1604
1608
  });
1605
1609
  }
@@ -1610,8 +1614,8 @@ var AiSdkLlm = class extends BaseLlm {
1610
1614
  parts: parts.length > 0 ? parts : [{ text: "" }]
1611
1615
  },
1612
1616
  usageMetadata: result.usage ? {
1613
- promptTokenCount: result.usage.promptTokens,
1614
- candidatesTokenCount: result.usage.completionTokens,
1617
+ promptTokenCount: result.usage.inputTokens,
1618
+ candidatesTokenCount: result.usage.outputTokens,
1615
1619
  totalTokenCount: result.usage.totalTokens
1616
1620
  } : void 0,
1617
1621
  finishReason: this.mapFinishReason(result.finishReason),
@@ -1687,7 +1691,7 @@ var AiSdkLlm = class extends BaseLlm {
1687
1691
  for (const funcDecl of toolConfig.functionDeclarations) {
1688
1692
  tools[funcDecl.name] = {
1689
1693
  description: funcDecl.description,
1690
- parameters: jsonSchema(
1694
+ inputSchema: jsonSchema(
1691
1695
  this.transformSchemaForAiSdk(funcDecl.parameters || {})
1692
1696
  )
1693
1697
  };
@@ -1733,7 +1737,7 @@ var AiSdkLlm = class extends BaseLlm {
1733
1737
  type: "tool-call",
1734
1738
  toolCallId: funcPart.functionCall.id,
1735
1739
  toolName: funcPart.functionCall.name,
1736
- args: funcPart.functionCall.args
1740
+ input: funcPart.functionCall.args
1737
1741
  });
1738
1742
  }
1739
1743
  }
@@ -1746,12 +1750,14 @@ var AiSdkLlm = class extends BaseLlm {
1746
1750
  const functionResponses = content.parts.filter(
1747
1751
  (part) => part.functionResponse
1748
1752
  );
1749
- const contentParts2 = functionResponses.map((part) => ({
1750
- type: "tool-result",
1751
- toolCallId: part.functionResponse.id,
1752
- toolName: part.functionResponse.name || "unknown",
1753
- result: part.functionResponse.response
1754
- }));
1753
+ const contentParts2 = functionResponses.map((part) => {
1754
+ return {
1755
+ type: "tool-result",
1756
+ toolCallId: part.functionResponse.id,
1757
+ toolName: part.functionResponse.name || "unknown",
1758
+ output: part.functionResponse.response
1759
+ };
1760
+ });
1755
1761
  return {
1756
1762
  role: "tool",
1757
1763
  content: contentParts2
@@ -2201,16 +2207,6 @@ var GoogleLlm = class extends BaseLlm {
2201
2207
  dataObj.displayName = null;
2202
2208
  }
2203
2209
  }
2204
- /**
2205
- * Builds function declaration log string.
2206
- */
2207
- buildFunctionDeclarationLog(funcDecl) {
2208
- let paramStr = "{}";
2209
- if (funcDecl.parameters?.properties) {
2210
- paramStr = JSON.stringify(funcDecl.parameters.properties);
2211
- }
2212
- return `${funcDecl.name}: ${paramStr}`;
2213
- }
2214
2210
  /**
2215
2211
  * Provides the api client.
2216
2212
  */
@@ -4085,7 +4081,6 @@ init_base_tool();
4085
4081
  // src/tools/base/create-tool.ts
4086
4082
  init_base_tool();
4087
4083
  import * as z from "zod";
4088
- import { zodToJsonSchema } from "zod-to-json-schema";
4089
4084
  var CreatedTool = class extends BaseTool {
4090
4085
  func;
4091
4086
  schema;
@@ -4131,10 +4126,7 @@ var CreatedTool = class extends BaseTool {
4131
4126
  * Builds the function declaration from the Zod schema
4132
4127
  */
4133
4128
  buildDeclaration() {
4134
- const rawParameters = zodToJsonSchema(this.schema, {
4135
- target: "jsonSchema7",
4136
- $refStrategy: "none"
4137
- });
4129
+ const rawParameters = z.toJSONSchema(this.schema);
4138
4130
  const { $schema, ...parameters } = rawParameters;
4139
4131
  return {
4140
4132
  name: this.name,
@@ -8340,7 +8332,7 @@ var IdentityLlmRequestProcessor = class extends BaseLlmRequestProcessor {
8340
8332
  var requestProcessor5 = new IdentityLlmRequestProcessor();
8341
8333
 
8342
8334
  // src/flows/llm-flows/instructions.ts
8343
- import { zodToJsonSchema as zodToJsonSchema2 } from "zod-to-json-schema";
8335
+ import z2 from "zod";
8344
8336
 
8345
8337
  // src/utils/instructions-utils.ts
8346
8338
  async function injectSessionState(template, readonlyContext) {
@@ -8458,10 +8450,7 @@ var InstructionsLlmRequestProcessor = class extends BaseLlmRequestProcessor {
8458
8450
  }
8459
8451
  if (agent.outputSchema) {
8460
8452
  try {
8461
- const raw = zodToJsonSchema2(agent.outputSchema, {
8462
- target: "jsonSchema7",
8463
- $refStrategy: "none"
8464
- });
8453
+ const raw = z2.toJSONSchema(agent.outputSchema);
8465
8454
  const { $schema, ...json } = raw || {};
8466
8455
  llmRequest.appendInstructions([
8467
8456
  "You must respond with application/json that validates against this JSON Schema (do NOT wrap the output in markdown or code fences):",
@@ -11209,12 +11198,14 @@ var AgentBuilder = class _AgentBuilder {
11209
11198
  try {
11210
11199
  return outputSchema.parse(combinedResponse);
11211
11200
  } catch (validationError) {
11212
- throw new Error(
11213
- `Failed to parse and validate LLM output against the schema.
11214
- JSON parse error: ${parseError instanceof Error ? parseError.message : String(parseError)}
11215
- Zod validation error: ${validationError instanceof Error ? validationError.message : String(validationError)}
11216
- Raw output: "${combinedResponse}"`
11217
- );
11201
+ const message2 = `\u{1F6A8} Failed to parse and validate LLM output against the schema.
11202
+
11203
+ \u2139\uFE0F JSON parse error: ${parseError instanceof Error ? parseError.message : String(parseError)}
11204
+
11205
+ \u{1F6A7} Zod validation error: ${validationError instanceof Error ? validationError.message : String(validationError)}
11206
+
11207
+ \u{1F4C4} Raw output: ${combinedResponse}`;
11208
+ throw new Error(message2);
11218
11209
  }
11219
11210
  }
11220
11211
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@iqai/adk",
3
- "version": "0.3.0",
3
+ "version": "0.3.2",
4
4
  "description": "Agent Development Kit for TypeScript with multi-provider LLM support",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
@@ -23,40 +23,37 @@
23
23
  "author": "IQAI",
24
24
  "license": "MIT",
25
25
  "dependencies": {
26
- "@anthropic-ai/sdk": "^0.39.0",
26
+ "@anthropic-ai/sdk": "^0.61.0",
27
27
  "@clack/prompts": "^0.11.0",
28
- "@electric-sql/pglite": "^0.3.2",
29
- "@google-cloud/storage": "^7.16.0",
30
- "@google-cloud/vertexai": "^0.5.0",
31
- "@google/genai": "^1.6.0",
32
- "@modelcontextprotocol/sdk": "^1.11.1",
28
+ "@electric-sql/pglite": "^0.3.8",
29
+ "@google-cloud/storage": "^7.17.0",
30
+ "@google-cloud/vertexai": "^1.10.0",
31
+ "@google/genai": "^1.19.0",
32
+ "@modelcontextprotocol/sdk": "^1.17.5",
33
33
  "@opentelemetry/api": "^1.9.0",
34
- "@opentelemetry/auto-instrumentations-node": "^0.60.1",
35
- "@opentelemetry/exporter-trace-otlp-http": "^0.202.0",
36
- "@opentelemetry/resources": "^2.0.1",
37
- "@opentelemetry/sdk-node": "^0.202.0",
38
- "@opentelemetry/sdk-trace-base": "^2.0.1",
39
- "@opentelemetry/sdk-trace-node": "^2.0.1",
40
- "@opentelemetry/semantic-conventions": "^1.34.0",
34
+ "@opentelemetry/auto-instrumentations-node": "^0.63.0",
35
+ "@opentelemetry/exporter-trace-otlp-http": "^0.204.0",
36
+ "@opentelemetry/resources": "^2.1.0",
37
+ "@opentelemetry/sdk-node": "^0.204.0",
38
+ "@opentelemetry/sdk-trace-base": "^2.1.0",
39
+ "@opentelemetry/sdk-trace-node": "^2.1.0",
40
+ "@opentelemetry/semantic-conventions": "^1.37.0",
41
41
  "@types/cors": "^2.8.19",
42
- "@types/express": "^4.17.21",
43
- "ai": "^4.3.16",
44
- "axios": "^1.6.2",
45
- "chalk": "^5.4.1",
42
+ "ai": "^5.0.39",
43
+ "axios": "^1.11.0",
44
+ "chalk": "^5.6.2",
46
45
  "cors": "^2.8.5",
47
- "dedent": "^1.6.0",
48
- "dockerode": "^4.0.7",
49
- "dotenv": "^16.4.7",
50
- "drizzle-orm": "^0.43.1",
51
- "express": "^4.19.2",
52
- "kysely": "^0.28.2",
53
- "openai": "^4.93.0",
46
+ "dedent": "^1.7.0",
47
+ "dockerode": "^4.0.8",
48
+ "dotenv": "^17.2.2",
49
+ "drizzle-orm": "^0.44.5",
50
+ "jsonrepair": "^3.13.0",
51
+ "kysely": "^0.28.5",
52
+ "openai": "^5.20.0",
54
53
  "socket.io": "^4.8.1",
55
54
  "ts-node": "^10.9.2",
56
- "uuid": "^11.1.0",
57
- "zod": "^3.25.67",
58
- "jsonrepair": "^3.13.0",
59
- "zod-to-json-schema": "^3.24.6"
55
+ "uuid": "^13.0.0",
56
+ "zod": "^4.1.5"
60
57
  },
61
58
  "peerDependencies": {
62
59
  "better-sqlite3": "^11.10.0",
@@ -76,14 +73,14 @@
76
73
  },
77
74
  "devDependencies": {
78
75
  "@types/better-sqlite3": "^7.6.13",
79
- "@types/dockerode": "^3.3.42",
80
- "@types/node": "^20.17.30",
81
- "better-sqlite3": "^11.10.0",
82
- "mysql2": "^3.14.1",
83
- "pg": "^8.16.0",
84
- "tsup": "^8.4.0",
85
- "typescript": "^5.3.2",
86
- "vitest": "^3.1.3",
76
+ "@types/dockerode": "^3.3.43",
77
+ "@types/node": "^24.3.1",
78
+ "better-sqlite3": "^12.2.0",
79
+ "mysql2": "^3.14.5",
80
+ "pg": "^8.16.3",
81
+ "tsup": "^8.5.0",
82
+ "typescript": "^5.9.2",
83
+ "vitest": "^3.2.4",
87
84
  "@iqai/tsconfig": "0.0.1"
88
85
  },
89
86
  "packageManager": "pnpm@9.0.0",