@iqai/adk 0.3.1 → 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/CHANGELOG.md +28 -0
- package/dist/index.d.mts +3 -7
- package/dist/index.d.ts +3 -7
- package/dist/index.js +149 -158
- package/dist/index.mjs +32 -41
- package/package.json +34 -35
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
|
-
|
|
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.
|
|
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.
|
|
1584
|
-
candidatesTokenCount: finalUsage.
|
|
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.
|
|
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.
|
|
1614
|
-
candidatesTokenCount: result.usage.
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
1751
|
-
|
|
1752
|
-
|
|
1753
|
-
|
|
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 =
|
|
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
|
|
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 =
|
|
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
|
-
|
|
11213
|
-
|
|
11214
|
-
|
|
11215
|
-
|
|
11216
|
-
|
|
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.
|
|
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,38 +23,37 @@
|
|
|
23
23
|
"author": "IQAI",
|
|
24
24
|
"license": "MIT",
|
|
25
25
|
"dependencies": {
|
|
26
|
-
"@anthropic-ai/sdk": "^0.
|
|
26
|
+
"@anthropic-ai/sdk": "^0.61.0",
|
|
27
27
|
"@clack/prompts": "^0.11.0",
|
|
28
|
-
"@electric-sql/pglite": "^0.3.
|
|
29
|
-
"@google-cloud/storage": "^7.
|
|
30
|
-
"@google-cloud/vertexai": "^
|
|
31
|
-
"@google/genai": "^1.
|
|
32
|
-
"@modelcontextprotocol/sdk": "^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.
|
|
35
|
-
"@opentelemetry/exporter-trace-otlp-http": "^0.
|
|
36
|
-
"@opentelemetry/resources": "^2.0
|
|
37
|
-
"@opentelemetry/sdk-node": "^0.
|
|
38
|
-
"@opentelemetry/sdk-trace-base": "^2.0
|
|
39
|
-
"@opentelemetry/sdk-trace-node": "^2.0
|
|
40
|
-
"@opentelemetry/semantic-conventions": "^1.
|
|
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
|
-
"ai": "^
|
|
43
|
-
"axios": "^1.
|
|
44
|
-
"chalk": "^5.
|
|
42
|
+
"ai": "^5.0.39",
|
|
43
|
+
"axios": "^1.11.0",
|
|
44
|
+
"chalk": "^5.6.2",
|
|
45
45
|
"cors": "^2.8.5",
|
|
46
|
-
"dedent": "^1.
|
|
47
|
-
"dockerode": "^4.0.
|
|
48
|
-
"dotenv": "^
|
|
49
|
-
"drizzle-orm": "^0.
|
|
50
|
-
"
|
|
51
|
-
"
|
|
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",
|
|
52
53
|
"socket.io": "^4.8.1",
|
|
53
54
|
"ts-node": "^10.9.2",
|
|
54
|
-
"uuid": "^
|
|
55
|
-
"zod": "^
|
|
56
|
-
"jsonrepair": "^3.13.0",
|
|
57
|
-
"zod-to-json-schema": "^3.24.6"
|
|
55
|
+
"uuid": "^13.0.0",
|
|
56
|
+
"zod": "^4.1.5"
|
|
58
57
|
},
|
|
59
58
|
"peerDependencies": {
|
|
60
59
|
"better-sqlite3": "^11.10.0",
|
|
@@ -74,14 +73,14 @@
|
|
|
74
73
|
},
|
|
75
74
|
"devDependencies": {
|
|
76
75
|
"@types/better-sqlite3": "^7.6.13",
|
|
77
|
-
"@types/dockerode": "^3.3.
|
|
78
|
-
"@types/node": "^
|
|
79
|
-
"better-sqlite3": "^
|
|
80
|
-
"mysql2": "^3.14.
|
|
81
|
-
"pg": "^8.16.
|
|
82
|
-
"tsup": "^8.
|
|
83
|
-
"typescript": "^5.
|
|
84
|
-
"vitest": "^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",
|
|
85
84
|
"@iqai/tsconfig": "0.0.1"
|
|
86
85
|
},
|
|
87
86
|
"packageManager": "pnpm@9.0.0",
|